@@ -22,12 +25,112 @@ const NumberInputComp = (props: UseNumberInputProps) => {
export default {
title: "NumberInput",
component: NumberInput,
+ argTypes: {
+ value: { control: "number" },
+ min: { control: "number" },
+ step: { control: "number" },
+ max: { control: "number" },
+ precision: { control: "number" },
+ defaultValue: { control: "number" },
+ isDisabled: { control: "boolean" },
+ isReadOnly: { control: "boolean" },
+ keepWithinRange: { control: "boolean" },
+ clampValueOnBlur: { control: "boolean" },
+ focusInputOnChange: { control: "boolean" },
+ },
} as Meta;
-export const Default = () => {
- const props = {};
+const Base: Story = args => {
+ const [{ value, defaultValue }, updateArgs] = useArgs();
+
+ return (
+
{
+ updateArgs({ value });
+ }}
+ defaultValue={defaultValue}
+ value={value || defaultValue}
+ {...args}
+ />
+ );
+};
+
+export const Default = Base.bind({});
+
+export const DefaultValue = Base.bind({});
+DefaultValue.args = {
+ defaultValue: 15,
+ min: 10,
+ max: 20,
+};
+
+export const Step = Base.bind({});
+Step.args = {
+ defaultValue: 15,
+ min: 10,
+ max: 30,
+ step: 5,
+};
+
+export const Precision = Base.bind({});
+Precision.args = {
+ defaultValue: 15,
+ min: 10,
+ max: 30,
+ step: 0.2,
+ precision: 2,
+};
+
+export const ClampValueOnBlurFalse = Base.bind({});
+ClampValueOnBlurFalse.args = {
+ defaultValue: 15,
+ min: 10,
+ max: 30,
+ step: 0.2,
+ precision: 2,
+ clampValueOnBlur: false,
+ keepWithinRange: false,
+};
+
+export const KeepWithinRangeFalse = Base.bind({});
+KeepWithinRangeFalse.args = {
+ defaultValue: 15,
+ min: 10,
+ max: 30,
+ step: 0.2,
+ precision: 2,
+ clampValueOnBlur: false,
+ keepWithinRange: false,
+};
+
+export const Disabled = Base.bind({});
+Disabled.args = {
+ defaultValue: 15,
+ min: 10,
+ max: 20,
+ isDisabled: true,
+};
+
+export const ReadOnly = Base.bind({});
+ReadOnly.args = {
+ defaultValue: 15,
+ min: 10,
+ max: 20,
+ isReadOnly: true,
+};
- return ;
+export const Options = Base.bind({});
+Options.args = {
+ min: 0,
+ step: 1,
+ max: 100,
+ precision: 1,
+ defaultValue: 5,
+ isDisabled: false,
+ isReadOnly: false,
+ keepWithinRange: true,
+ clampValueOnBlur: false,
+ focusInputOnChange: false,
};
const NumberComponent: React.FC = ({ onChange, value, name }) => {
@@ -65,86 +168,3 @@ export const ReactHookForm = () => {
);
};
-
-export const DefaultValue = () => {
- const props = {
- defaultValue: 15,
- min: 10,
- max: 20,
- };
-
- return ;
-};
-
-export const Step = () => {
- const props = {
- defaultValue: 15,
- min: 10,
- max: 30,
- step: 5,
- };
-
- return ;
-};
-
-export const Precision = () => {
- const props = {
- defaultValue: 15,
- min: 10,
- max: 30,
- step: 0.2,
- precision: 2,
- };
-
- return ;
-};
-
-export const ClampValueOnBlurFalse = () => {
- const props = {
- defaultValue: 15,
- min: 10,
- max: 30,
- step: 0.2,
- precision: 2,
- clampValueOnBlur: false,
- keepWithinRange: false,
- };
-
- return ;
-};
-
-export const KeepWithinRangeFalse = () => {
- const props = {
- defaultValue: 15,
- min: 10,
- max: 30,
- step: 0.2,
- precision: 2,
- clampValueOnBlur: false,
- keepWithinRange: false,
- };
-
- return ;
-};
-
-export const Disabled = () => {
- const props = {
- defaultValue: 15,
- min: 10,
- max: 20,
- isDisabled: true,
- };
-
- return ;
-};
-
-export const ReadOnly = () => {
- const props = {
- defaultValue: 15,
- min: 10,
- max: 20,
- isReadOnly: true,
- };
-
- return ;
-};