import React from 'react'; import { Box, Table, TableBody, TableCell, TableHead, TableRow } from '@mui/material'; import { action } from 'storybook/actions'; import { Bell } from '@lunit/design-system-icons'; import TextField from '@/components/TextField/TextField'; import type { StoryFn, Meta } from '@storybook/react-webpack5'; export default { title: 'Components/TextField', component: TextField, args: { disabled: false, size: 'small', placeholder: 'Please typing...', helperText: 'Helper Text', multiline: false, }, argTypes: { disabled: { control: { type: 'radio' }, options: [true, false], description: 'If true, the text field will be disabled.', table: { defaultValue: { summary: 'false' }, type: { summary: 'boolean' }, }, }, size: { control: { type: 'radio' }, options: ['small', 'medium', 'large'], description: 'The size of the text field.', table: { defaultValue: { summary: 'small' }, type: { summary: 'string' }, }, }, placeholder: { type: 'string', description: 'The placeholder content.', table: { defaultValue: { summary: 'undefined' }, type: { summary: 'string' }, }, }, helperText: { type: 'string', description: 'The helper text content, use "error " or "sub text " to display helper text.', table: { defaultValue: { summary: 'undefined' }, type: { summary: 'string' }, }, }, }, parameters: { controls: { include: [ 'size', 'disabled', 'helperText', 'placeholder', 'onLeftIconClick', 'onRightIconClick', ], }, docs: { description: { component: `It is a text field that allows users to enter and edit text. \n It is usually used in forms. It can be used as a single line or multi-line text field. \n It can be used with an icon on the left or right side.`, }, }, }, decorators: [(Story) => {Story()}], } as Meta; const SingleTemplate: StoryFn = (args) => ( Default Error Focused Error Focused Disabled
); const SingleWithIconTemplate: StoryFn = (args) => ( Default Error focused Error focused Disabled Left Icon } /> } /> } /> } /> } /> Right Icon } /> } /> } /> } /> } /> Left Right Both Icon } rightIcon={} /> } rightIcon={} /> } rightIcon={} /> } rightIcon={} /> } rightIcon={} />
); export const TextFieldWithSingle = { render: SingleTemplate, argTypes: { onLeftIconClick: { control: false, options: ['function', undefined], mapping: { function: action('onLeftIconClick'), undefined: undefined, }, description: 'The left icon click event call back function.', table: { defaultValue: { summary: 'undefined' }, type: { summary: 'function' }, }, }, onRightIconClick: { control: false, options: ['function', undefined], mapping: { function: action('onRightIconClick'), undefined: undefined, }, description: 'The right icon click event call back function.', table: { defaultValue: { summary: 'undefined' }, type: { summary: 'function' }, }, }, }, name: 'Single Line', }; export const TextFieldWithIcon = { render: SingleWithIconTemplate, argTypes: { onLeftIconClick: { control: { type: 'select', }, options: ['function', undefined], mapping: { function: action('onLeftIconClick'), undefined: undefined, }, description: 'The left icon click event call back function.', table: { defaultValue: { summary: 'undefined' }, type: { summary: 'function' }, }, }, onRightIconClick: { control: { type: 'select', }, options: ['function', undefined], mapping: { function: action('onRightIconClick'), undefined: undefined, }, description: 'The right icon click event call back function.', table: { defaultValue: { summary: 'undefined' }, type: { summary: 'function' }, }, }, }, name: 'With Icon(single-line only)', };