Skip to content

Commit

Permalink
Remove type cast and update story
Browse files Browse the repository at this point in the history
  • Loading branch information
gigxz committed Dec 9, 2024
1 parent 424b24c commit f0721bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 6 additions & 8 deletions src/components/elements/input/NumberInput.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { Box } from '@mui/material';
import { useArgs } from '@storybook/preview-api';
import { Meta, StoryObj } from '@storybook/react';

import NumberInput from './NumberInput';

export default {
component: NumberInput,
argTypes: { label: { control: 'text' } },
decorators: [
(Story) => (
<Box sx={{ width: 400 }}>
<Story />
</Box>
),
],
render: (args: any) => {
const [{ value }, updateArgs] = useArgs();
const onChange = (event: any) => updateArgs({ value: event.target.value });
return <NumberInput {...args} onChange={onChange} value={value} />;
},
} as Meta<typeof NumberInput>;

type Story = StoryObj<typeof NumberInput>;
Expand Down
6 changes: 5 additions & 1 deletion src/components/elements/input/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const NumberInput: React.FC<Props> = ({
helperText,
ariaLabelledBy,
onChange,
defaultValue,
type,
...props
}) => {
const [errorMessage, setErrorMessage] = useState<string | null>(null);
Expand Down Expand Up @@ -110,7 +112,9 @@ const NumberInput: React.FC<Props> = ({
) : undefined,
...InputProps,
}}
{...(props as any)}
defaultValue={(defaultValue || '') as string}
type={type as any}
{...props}
/>
);
};
Expand Down

0 comments on commit f0721bb

Please sign in to comment.