import React from 'react';
import { Box } from '@mui/material';
import { Bell } from '@lunit/design-system-icons';
import TextField from '@/components/TextField/TextField';
import type { StoryObj, Meta, StoryFn } from '@storybook/react-webpack5';
export default {
title: 'Components/TextField',
component: TextField,
args: {
multiline: false,
size: 'small',
disabled: false,
error: false,
placeholder: 'Please typing...',
helperText: '',
},
argTypes: {
multiline: {
control: { type: 'radio' },
options: [true, false],
description: 'The multiline prop transforms the text field into a TextareaAutosize element.',
},
error: {
control: { type: 'radio' },
options: [true, false],
description:
'The error prop toggles the error state. The helperText prop can then be used to provide feedback to the user about the error.',
},
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', 'multiline', 'error'],
},
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;
export const BasicTextField: StoryObj = {
render: (args) => {args.children},
parameters: {
chromatic: { disableSnapshot: true },
},
};
const MultiAndSingleTemplate: StoryFn = (args) => {
return (
);
};
export const MultiAndSingle: StoryObj = {
render: MultiAndSingleTemplate,
parameters: {
controls: {
include: ['size', 'disabled', 'helperText', 'placeholder', 'error'],
},
chromatic: { disableSnapshot: true },
},
};
const DisabledTemplate: StoryFn = (args) => {
return (
);
};
export const Disabled: StoryObj = {
render: DisabledTemplate,
parameters: {
controls: {
include: ['size', 'helperText', 'placeholder', 'error', 'disabled'],
},
chromatic: { disableSnapshot: true },
},
};
const ReadOnlyTemplate: StoryFn = (args) => {
return (
);
};
export const ReadOnly: StoryObj = {
render: ReadOnlyTemplate,
parameters: {
controls: {
include: ['size', 'helperText', 'error', 'disabled'],
},
chromatic: { disableSnapshot: true },
},
};
const ErrorTemplate: StoryFn = (args) => {
return (
);
};
export const Error: StoryObj = {
render: ErrorTemplate,
parameters: {
controls: {
include: ['size', 'helperText', 'placeholder', 'disabled'],
},
chromatic: { disableSnapshot: true },
},
};
const PlaceholderTemplate: StoryFn = (args) => {
return (
);
};
export const Placeholder: StoryObj = {
render: PlaceholderTemplate,
parameters: {
controls: {
include: ['size', 'helperText', 'disabled', 'error'],
},
chromatic: { disableSnapshot: true },
},
};
const HelperTextTemplate: StoryFn = (args) => {
return (
);
};
export const HelperText: StoryObj = {
render: HelperTextTemplate,
parameters: {
controls: {
include: ['size', 'disabled', 'error', 'placeholder'],
},
chromatic: { disableSnapshot: true },
},
};
const IconTemplate: StoryFn = (args) => {
return (
} />
} />
);
};
export const Icon: StoryObj = {
render: IconTemplate,
parameters: {
chromatic: { disableSnapshot: true },
},
};