@lunit/design-system 1.0.0-b.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/cjs/components/Alert/index.js +1 -1
  2. package/dist/cjs/components/Alert/index.js.map +1 -1
  3. package/dist/cjs/components/Button/index.js +1 -1
  4. package/dist/cjs/components/Button/index.js.map +1 -1
  5. package/dist/cjs/components/Checkbox/index.js +1 -1
  6. package/dist/cjs/components/Checkbox/index.js.map +1 -1
  7. package/dist/cjs/components/Chip/index.js +1 -1
  8. package/dist/cjs/components/Chip/index.js.map +1 -1
  9. package/dist/cjs/components/Dialog/index.js +2 -0
  10. package/dist/cjs/components/Dialog/index.js.map +1 -0
  11. package/dist/cjs/components/Radio/index.js +1 -1
  12. package/dist/cjs/components/Radio/index.js.map +1 -1
  13. package/dist/cjs/components/TextField/index.js +1 -1
  14. package/dist/cjs/components/TextField/index.js.map +1 -1
  15. package/dist/cjs/components/ToggleButton/index.js +1 -1
  16. package/dist/cjs/components/ToggleButton/index.js.map +1 -1
  17. package/dist/cjs/index.js +1 -1
  18. package/dist/cjs/index.js.map +1 -1
  19. package/dist/components/Button/Button.js +21 -3
  20. package/dist/components/Button/Button.js.map +1 -1
  21. package/dist/components/Button/Button.styled.js +3 -6
  22. package/dist/components/Button/Button.styled.js.map +1 -1
  23. package/dist/components/Checkbox/Checkbox.js +9 -19
  24. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  25. package/dist/components/Chip/Chip.js +6 -5
  26. package/dist/components/Chip/Chip.js.map +1 -1
  27. package/dist/components/Dialog/Dialog.js +61 -0
  28. package/dist/components/Dialog/Dialog.js.map +1 -0
  29. package/dist/components/Dialog/Dialog.styled.js +137 -0
  30. package/dist/components/Dialog/Dialog.styled.js.map +1 -0
  31. package/dist/components/Dialog/components/DialogAction.js +18 -0
  32. package/dist/components/Dialog/components/DialogAction.js.map +1 -0
  33. package/dist/components/Dialog/index.js +2 -0
  34. package/dist/components/Dialog/index.js.map +1 -0
  35. package/dist/components/Radio/Radio.js +7 -21
  36. package/dist/components/Radio/Radio.js.map +1 -1
  37. package/dist/components/TextField/TextField.js +4 -4
  38. package/dist/components/TextField/TextField.js.map +1 -1
  39. package/dist/components/ToggleButton/ToggleButton.styled.js +2 -3
  40. package/dist/components/ToggleButton/ToggleButton.styled.js.map +1 -1
  41. package/dist/foundation/Elevation/index.js +1 -1
  42. package/dist/foundation/Elevation/index.js.map +1 -1
  43. package/dist/foundation/Typography/index.js +12 -0
  44. package/dist/foundation/Typography/index.js.map +1 -1
  45. package/dist/foundation/Typography/tokens.js +1 -17
  46. package/dist/foundation/Typography/tokens.js.map +1 -1
  47. package/dist/foundation/colors/base/grey.js +3 -1
  48. package/dist/foundation/colors/base/grey.js.map +1 -1
  49. package/dist/foundation/colors/index.js +9 -6
  50. package/dist/foundation/colors/index.js.map +1 -1
  51. package/dist/foundation/colors/token/component.js +31 -115
  52. package/dist/foundation/colors/token/component.js.map +1 -1
  53. package/dist/foundation/colors/token/core.js +43 -75
  54. package/dist/foundation/colors/token/core.js.map +1 -1
  55. package/dist/foundation/index.js +1 -1
  56. package/dist/foundation/index.js.map +1 -1
  57. package/dist/index.js +1 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/types/components/Alert/Alert.utils.d.ts +3 -3
  60. package/dist/types/components/Button/Button.styled.d.ts +9 -12
  61. package/dist/types/components/Button/Button.types.d.ts +8 -5
  62. package/dist/types/components/Chip/Chip.styled.d.ts +12 -12
  63. package/dist/types/components/Chip/Chip.types.d.ts +7 -2
  64. package/dist/types/components/Dialog/Dialog.d.ts +50 -0
  65. package/dist/types/components/Dialog/Dialog.styled.d.ts +12 -0
  66. package/dist/types/components/Dialog/components/DialogAction.d.ts +8 -0
  67. package/dist/types/components/Dialog/index.d.ts +2 -0
  68. package/dist/types/components/TextField/TextField.types.d.ts +8 -3
  69. package/dist/types/components/Toast/Toast.utils.d.ts +1 -1
  70. package/dist/types/components/ToggleButton/ToggleButton.styled.d.ts +2 -2
  71. package/dist/types/foundation/Elevation/index.d.ts +1 -1
  72. package/dist/types/foundation/Typography/index.d.ts +13 -1
  73. package/dist/types/foundation/Typography/tokens.d.ts +1 -1
  74. package/dist/types/foundation/colors/base/grey.d.ts +2 -0
  75. package/dist/types/foundation/colors/index.d.ts +9 -6
  76. package/dist/types/foundation/colors/token/types.d.ts +0 -2
  77. package/dist/types/foundation/colors/types.d.ts +78 -76
  78. package/dist/types/foundation/index.d.ts +9 -0
  79. package/dist/types/index.d.ts +1 -1
  80. package/package.json +1 -1
  81. package/src/components/Button/Button.styled.ts +3 -6
  82. package/src/components/Button/Button.tsx +117 -42
  83. package/src/components/Button/Button.types.ts +8 -4
  84. package/src/components/Checkbox/Checkbox.tsx +39 -22
  85. package/src/components/Chip/Chip.tsx +15 -4
  86. package/src/components/Chip/Chip.types.ts +9 -2
  87. package/src/components/Dialog/Dialog.styled.ts +165 -0
  88. package/src/components/Dialog/Dialog.tsx +195 -0
  89. package/src/components/Dialog/components/DialogAction.tsx +36 -0
  90. package/src/components/Dialog/index.ts +14 -0
  91. package/src/components/Radio/Radio.tsx +37 -25
  92. package/src/components/TextField/TextField.tsx +10 -10
  93. package/src/components/TextField/TextField.types.ts +11 -4
  94. package/src/components/ToggleButton/ToggleButton.styled.ts +2 -3
  95. package/src/foundation/Elevation/index.ts +1 -1
  96. package/src/foundation/Typography/index.ts +12 -0
  97. package/src/foundation/Typography/tokens.ts +1 -17
  98. package/src/foundation/colors/base/grey.ts +3 -1
  99. package/src/foundation/colors/index.ts +9 -6
  100. package/src/foundation/colors/token/component.ts +24 -108
  101. package/src/foundation/colors/token/core.ts +39 -71
  102. package/src/foundation/colors/token/types.ts +0 -2
  103. package/src/foundation/colors/types.ts +78 -75
  104. package/src/foundation/index.ts +1 -1
  105. package/src/index.ts +1 -1
  106. package/src/stories/GettingStarted.mdx +88 -0
  107. package/src/stories/components/Button/BasicButton.stories.tsx +91 -52
  108. package/src/stories/components/Button/ButtonDocs.mdx +187 -0
  109. package/src/stories/components/Button/Color.stories.tsx +132 -0
  110. package/src/stories/components/Button/IconButton.stories.tsx +42 -25
  111. package/src/stories/components/Button/Kind.stories.tsx +75 -77
  112. package/src/stories/components/{SelectControl/Checkbox.stories.tsx → CheckBox/BasicCheckbox.stories.tsx} +84 -105
  113. package/src/stories/components/CheckBox/CheckboxDocs.mdx +85 -0
  114. package/src/stories/components/Chip/Chip.stories.tsx +80 -5
  115. package/src/stories/components/Chip/ChipDocs.mdx +132 -0
  116. package/src/stories/components/Dialog/Dialog.stories.tsx +320 -0
  117. package/src/stories/components/TextField/BasicTextField.stories.tsx +214 -0
  118. package/src/stories/components/TextField/TextFieldDocs.mdx +140 -0
  119. package/src/stories/components/TextField/TextFieldSize.stories.tsx +26 -3
  120. package/src/stories/components/ToggleButton/Basic.stories.tsx +312 -0
  121. package/src/stories/components/ToggleButton/ToggleButtonDocs.mdx +180 -0
  122. package/src/stories/components/ToggleButton/ToggleButtonKind.stories.tsx +65 -0
  123. package/src/stories/components/ToggleButton/WithIcon.stories.tsx +138 -0
  124. package/src/stories/foundation/Typography/Typography.mdx +31 -46
  125. package/src/stories/foundation/Typography/Typography.stories.tsx +30 -1
  126. package/src/stories/foundation/colors/ColorSystem.tsx +86 -0
  127. package/src/stories/foundation/colors/Docs.mdx +225 -0
  128. package/src/stories/foundation/colors/TokenPaletteTable.tsx +1 -5
  129. package/src/components/Modal/Modal.tsx +0 -8
  130. package/src/components/Modal/index.ts +0 -1
  131. package/src/stories/components/Modal/Modal.stories.tsx +0 -15
  132. package/src/stories/foundation/Typography/TypographyExamples.stories.tsx +0 -44
@@ -0,0 +1,320 @@
1
+ import React, { useState } from "react";
2
+ import { Box } from "@mui/material";
3
+ import Error from "@lunit/design-system-icons/Error";
4
+
5
+ import Button from "@/components/Button";
6
+ import Dialog from "@/components/Dialog";
7
+
8
+ import type { Meta, StoryObj } from "@storybook/react";
9
+
10
+ const meta: Meta<typeof Dialog> = {
11
+ title: "components/Dialog",
12
+ component: Dialog,
13
+ tags: ["autodocs"],
14
+ parameters: {
15
+ docs: { disable: true, hidden: true },
16
+ },
17
+ argTypes: {
18
+ onClose: { action: "onClose" },
19
+ },
20
+ };
21
+
22
+ export default meta;
23
+ type Story = StoryObj<typeof Dialog>;
24
+
25
+ export const PassiveModal: Story = {
26
+ name: "Type: passive modal",
27
+ render: function PassiveModalRender(_Story, context) {
28
+ const classNameFromGlobal = context.globals.theme;
29
+ const [target, setTarget] = useState<HTMLDivElement | null>(null);
30
+
31
+ return (
32
+ <div style={{ width: "100vw", height: "100vh" }}>
33
+ <div ref={(ref) => setTarget(ref)} />
34
+ <Dialog
35
+ className={classNameFromGlobal}
36
+ isOpen={Boolean(target)}
37
+ onClose={close}
38
+ type="passive"
39
+ title="Title area"
40
+ >
41
+ Lorem Ipsum is simply dummy text of the a printing and typesetting
42
+ industry
43
+ </Dialog>
44
+ </div>
45
+ );
46
+ },
47
+ };
48
+
49
+ export const ActionModal: Story = {
50
+ name: "Type: action modal",
51
+ render: function ActionModalRender(_Story, context) {
52
+ const classNameFromGlobal = context.globals.theme;
53
+ const [target, setTarget] = useState<HTMLDivElement | null>(null);
54
+
55
+ return (
56
+ <div style={{ width: "100vw", height: "100vh" }}>
57
+ <div ref={(ref) => setTarget(ref)} />
58
+ <Dialog
59
+ className={classNameFromGlobal}
60
+ isOpen={Boolean(target)}
61
+ onClose={close}
62
+ type="action"
63
+ title="Title area"
64
+ actions={
65
+ <>
66
+ <Button
67
+ kind="ghost"
68
+ color="secondary"
69
+ size="medium"
70
+ onClick={close}
71
+ >
72
+ Cancel
73
+ </Button>
74
+ <Button kind="contained" size="medium" onClick={close}>
75
+ Save
76
+ </Button>
77
+ </>
78
+ }
79
+ >
80
+ Lorem Ipsum is simply dummy text of the a printing and typesetting
81
+ industry
82
+ </Dialog>
83
+ </div>
84
+ );
85
+ },
86
+ };
87
+
88
+ export const NonModal: Story = {
89
+ name: "Type: non modal",
90
+ render: function NonModalRender(_Story, context) {
91
+ const classNameFromGlobal = context.globals.theme;
92
+ const [isOpen, setIsOpen] = useState(false);
93
+ function open() {
94
+ setIsOpen(true);
95
+ }
96
+
97
+ function close() {
98
+ setIsOpen(false);
99
+ }
100
+
101
+ return (
102
+ <>
103
+ <Box sx={{ display: "flex", gap: "8px" }}>
104
+ <Button kind="contained" size="medium" onClick={open}>
105
+ Open to see Dialog
106
+ </Button>
107
+ <Button kind="contained" size="medium" onClick={close}>
108
+ click to close Dialog
109
+ </Button>
110
+ </Box>
111
+
112
+ <Dialog
113
+ className={classNameFromGlobal}
114
+ isOpen={isOpen}
115
+ nonModal
116
+ type="action"
117
+ onClose={close}
118
+ title="Title area"
119
+ actions={
120
+ <>
121
+ <Button
122
+ kind="ghost"
123
+ color="secondary"
124
+ size="medium"
125
+ onClick={close}
126
+ >
127
+ Cancel
128
+ </Button>
129
+ <Button kind="contained" size="medium" onClick={close}>
130
+ Save
131
+ </Button>
132
+ </>
133
+ }
134
+ >
135
+ Lorem Ipsum is simply dummy text of the a printing and typesetting
136
+ industry
137
+ </Dialog>
138
+ </>
139
+ );
140
+ },
141
+ };
142
+
143
+ export const SmallFalse: Story = {
144
+ name: "Option: small false",
145
+ render: function SmallFalseRender(_Story, context) {
146
+ const classNameFromGlobal = context.globals.theme;
147
+ const [target, setTarget] = useState<HTMLDivElement | null>(null);
148
+
149
+ return (
150
+ <div style={{ width: "100vw", height: "100vh" }}>
151
+ <div ref={(ref) => setTarget(ref)} />
152
+ <Dialog
153
+ className={classNameFromGlobal}
154
+ isOpen={Boolean(target)}
155
+ type="passive"
156
+ onClose={close}
157
+ title="Title area"
158
+ size="medium"
159
+ >
160
+ Lorem Ipsum is simply dummy text of the a printing and typesetting
161
+ industry
162
+ </Dialog>
163
+ </div>
164
+ );
165
+ },
166
+ };
167
+
168
+ export const WithTitleIcon: Story = {
169
+ name: "Option: title icon",
170
+ render: function WithTitleIconRender(_Story, context) {
171
+ const classNameFromGlobal = context.globals.theme;
172
+ const [target, setTarget] = useState<HTMLDivElement | null>(null);
173
+
174
+ return (
175
+ <div style={{ width: "100vw", height: "100vh" }}>
176
+ <div ref={(ref) => setTarget(ref)} />
177
+ <Dialog
178
+ className={classNameFromGlobal}
179
+ isOpen={Boolean(target)}
180
+ type="action"
181
+ onClose={close}
182
+ title="Title area"
183
+ titleIcon={<Error color="error" variant="filled" />}
184
+ actions={
185
+ <>
186
+ <Button
187
+ kind="ghost"
188
+ color="secondary"
189
+ size="medium"
190
+ onClick={close}
191
+ >
192
+ Cancel
193
+ </Button>
194
+ <Button
195
+ kind="contained"
196
+ color="error"
197
+ size="medium"
198
+ onClick={close}
199
+ >
200
+ Confirm
201
+ </Button>
202
+ </>
203
+ }
204
+ >
205
+ Lorem Ipsum is simply dummy text of the a printing and typesetting
206
+ industry
207
+ </Dialog>
208
+ </div>
209
+ );
210
+ },
211
+ };
212
+
213
+ export const WithCustomStyle: Story = {
214
+ name: "Option: custom style",
215
+ render: function WithCustomStyleRender(_Story, context) {
216
+ const classNameFromGlobal = context.globals.theme;
217
+ const [target, setTarget] = useState<HTMLDivElement | null>(null);
218
+
219
+ return (
220
+ <div style={{ width: "100vw", height: "100vh" }}>
221
+ <div ref={(ref) => setTarget(ref)} />
222
+ <Dialog
223
+ className={classNameFromGlobal}
224
+ isOpen={Boolean(target)}
225
+ type="passive"
226
+ onClose={close}
227
+ title="Title area"
228
+ sx={{
229
+ "& .dialog-title-wrapper": {
230
+ border: "4px dashed red",
231
+ borderRadius: "10px",
232
+ backgroundColor: "green",
233
+ },
234
+ }}
235
+ >
236
+ Lorem Ipsum is simply dummy text of the a printing and typesetting
237
+ industry
238
+ </Dialog>
239
+ </div>
240
+ );
241
+ },
242
+ };
243
+
244
+ export const WithScroll: Story = {
245
+ name: "Option: with scroll",
246
+ render: function WithScrollRender(_Story, context) {
247
+ const classNameFromGlobal = context.globals.theme;
248
+ const [target, setTarget] = useState<HTMLDivElement | null>(null);
249
+
250
+ return (
251
+ <div style={{ width: "100vw", height: "100vh" }}>
252
+ <div ref={(ref) => setTarget(ref)} />
253
+ <Dialog
254
+ className={classNameFromGlobal}
255
+ isOpen={Boolean(target)}
256
+ type="action"
257
+ onClose={close}
258
+ title="Title area"
259
+ actions={
260
+ <>
261
+ <Button
262
+ kind="ghost"
263
+ color="secondary"
264
+ size="medium"
265
+ onClick={close}
266
+ >
267
+ Cancel
268
+ </Button>
269
+ <Button
270
+ kind="contained"
271
+ color="error"
272
+ size="medium"
273
+ onClick={close}
274
+ >
275
+ Confirm
276
+ </Button>
277
+ </>
278
+ }
279
+ >
280
+ Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quis,
281
+ suscipit at. Atque enim, hic architecto sequi libero deserunt dolores
282
+ omnis, cumque dignissimos ab animi. Recusandae saepe facere error
283
+ tempore quasi. Lorem ipsum dolor sit amet consectetur adipisicing
284
+ elit. Consectetur eius commodi deserunt reiciendis. Officia veniam
285
+ consequuntur doloribus debitis numquam ipsum autem, eos repellendus
286
+ eligendi esse voluptatum natus, cum optio? Unde! Lorem ipsum dolor sit
287
+ amet consectetur adipisicing elit. Quibusdam praesentium incidunt
288
+ tempora quam aut nulla corrupti ipsa voluptatem vitae soluta ex
289
+ officia, explicabo, voluptate porro. Eius mollitia veritatis corporis
290
+ neque. Lorem Ipsum is simply dummy text of the a printing and
291
+ typesetting industry Lorem ipsum dolor sit amet consectetur Lorem
292
+ ipsum dolor sit amet consectetur, adipisicing elit. Quis, suscipit at.
293
+ Atque enim, hic architecto sequi libero deserunt dolores omnis, cumque
294
+ dignissimos ab animi. Recusandae saepe facere error tempore quasi.
295
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consectetur
296
+ eius commodi deserunt reiciendis. Officia veniam consequuntur
297
+ doloribus debitis numquam ipsum autem, eos repellendus eligendi esse
298
+ voluptatum natus, cum optio? Unde! Lorem ipsum dolor sit amet
299
+ consectetur adipisicing elit. Quibusdam praesentium incidunt tempora
300
+ quam aut nulla corrupti ipsa voluptatem vitae soluta ex officia,
301
+ explicabo, voluptate porro. Eius mollitia veritatis corporis neque.
302
+ Lorem Ipsum is simply dummy text of the a printing and typesetting
303
+ industry Lorem ipsum dolor sit amet consectetur Lorem ipsum dolor sit
304
+ amet consectetur, adipisicing elit. Quis, suscipit at. Atque enim, hic
305
+ architecto sequi libero deserunt dolores omnis, cumque dignissimos ab
306
+ animi. Recusandae saepe facere error tempore quasi. Lorem ipsum dolor
307
+ sit amet consectetur adipisicing elit. Consectetur eius commodi
308
+ deserunt reiciendis. Officia veniam consequuntur doloribus debitis
309
+ numquam ipsum autem, eos repellendus eligendi esse voluptatum natus,
310
+ cum optio? Unde! Lorem ipsum dolor sit amet consectetur adipisicing
311
+ elit. Quibusdam praesentium incidunt tempora quam aut nulla corrupti
312
+ ipsa voluptatem vitae soluta ex officia, explicabo, voluptate porro.
313
+ Eius mollitia veritatis corporis neque. Lorem Ipsum is simply dummy
314
+ text of the a printing and typesetting industry Lorem ipsum dolor sit
315
+ amet consectetur
316
+ </Dialog>
317
+ </div>
318
+ );
319
+ },
320
+ };
@@ -0,0 +1,214 @@
1
+ import React from "react";
2
+ import { Box } from "@mui/material";
3
+ import { Bell } from "@lunit/design-system-icons";
4
+
5
+ import TextField from "@/components/TextField/TextField";
6
+
7
+ import type { StoryObj, Meta, StoryFn } from "@storybook/react";
8
+
9
+ export default {
10
+ title: "Components/TextField",
11
+ component: TextField,
12
+ args: {
13
+ multiline: false,
14
+ size: "small",
15
+ disabled: false,
16
+ error: false,
17
+ placeholder: "Please typing...",
18
+ helperText: "",
19
+ },
20
+ argTypes: {
21
+ multiline: {
22
+ control: {
23
+ type: "radio",
24
+ },
25
+ options: [true, false],
26
+ description:
27
+ "The multiline prop transforms the text field into a TextareaAutosize element.",
28
+ },
29
+ error: {
30
+ control: {
31
+ type: "radio",
32
+ },
33
+ options: [true, false],
34
+ description:
35
+ "The error prop toggles the error state. The helperText prop can then be used to provide feedback to the user about the error.",
36
+ },
37
+ disabled: {
38
+ control: {
39
+ type: "radio",
40
+ },
41
+ options: [true, false],
42
+ description: "If true, the text field will be disabled.",
43
+ table: {
44
+ defaultValue: { summary: false },
45
+ type: { summary: [true, false] },
46
+ },
47
+ },
48
+ size: {
49
+ control: {
50
+ type: "radio",
51
+ },
52
+ description: "The size of the text field.",
53
+ table: {
54
+ defaultValue: { summary: "small" },
55
+ type: { summary: ["small", "medium", "large"] },
56
+ },
57
+ },
58
+ placeholder: {
59
+ type: "string",
60
+ description: "The placeholder content.",
61
+ table: {
62
+ defaultValue: { summary: "undefined" },
63
+ type: { summary: "string" },
64
+ },
65
+ },
66
+ helperText: {
67
+ type: "string",
68
+ description:
69
+ 'The helper text content, use "error " or "sub text " to display helper text.',
70
+ table: {
71
+ defaultValue: { summary: "undefined" },
72
+ type: { summary: "string" },
73
+ },
74
+ },
75
+ },
76
+ parameters: {
77
+ controls: {
78
+ include: [
79
+ "size",
80
+ "disabled",
81
+ "helperText",
82
+ "placeholder",
83
+ "multiline",
84
+ "error",
85
+ ],
86
+ },
87
+ docs: {
88
+ description: {
89
+ component: `It is a text field that allows users to enter and edit text.
90
+ \n It is usually used in forms. It can be used as a single line or multi-line text field.
91
+ \n It can be used with an icon on the left or right side.`,
92
+ },
93
+ },
94
+ },
95
+ decorators: [(Story) => <Box>{Story()}</Box>],
96
+ } as Meta<typeof TextField>;
97
+
98
+ export const BasicTextField: StoryObj<typeof TextField> = {
99
+ render: (args) => <TextField {...args}>{args.children}</TextField>,
100
+ parameters: {
101
+ chromatic: { disableSnapshot: true },
102
+ },
103
+ };
104
+
105
+ const MultiAndSingleTemplate: StoryFn<typeof TextField> = (args) => {
106
+ return (
107
+ <Box sx={{ display: "flex", gap: 2 }}>
108
+ <TextField {...args} />
109
+ <TextField {...args} multiline={true} />
110
+ </Box>
111
+ );
112
+ };
113
+
114
+ export const MultiAndSingle: StoryObj<typeof TextField> = {
115
+ render: MultiAndSingleTemplate,
116
+ parameters: {
117
+ controls: {
118
+ include: ["size", "disabled", "helperText", "placeholder", "error"],
119
+ },
120
+ chromatic: { disableSnapshot: true },
121
+ },
122
+ };
123
+
124
+ const DisabledTemplate: StoryFn<typeof TextField> = (args) => {
125
+ return (
126
+ <Box sx={{ display: "flex", gap: 2 }}>
127
+ <TextField {...args} disabled />
128
+ <TextField {...args} multiline={true} disabled />
129
+ </Box>
130
+ );
131
+ };
132
+
133
+ export const Disabled: StoryObj<typeof TextField> = {
134
+ render: DisabledTemplate,
135
+ parameters: {
136
+ controls: {
137
+ include: ["size", "helperText", "placeholder", "error", "disabled"],
138
+ },
139
+ chromatic: { disableSnapshot: true },
140
+ },
141
+ };
142
+
143
+ const ErrorTemplate: StoryFn<typeof TextField> = (args) => {
144
+ return (
145
+ <Box sx={{ display: "flex", gap: 2 }}>
146
+ <TextField {...args} error />
147
+ <TextField {...args} multiline={true} error />
148
+ </Box>
149
+ );
150
+ };
151
+
152
+ export const Error: StoryObj<typeof TextField> = {
153
+ render: ErrorTemplate,
154
+ parameters: {
155
+ controls: {
156
+ include: ["size", "helperText", "placeholder", "disabled"],
157
+ },
158
+ chromatic: { disableSnapshot: true },
159
+ },
160
+ };
161
+
162
+ const PlaceholderTemplate: StoryFn<typeof TextField> = (args) => {
163
+ return (
164
+ <Box sx={{ display: "flex", gap: 2 }}>
165
+ <TextField {...args} placeholder="Please typing..." />
166
+ <TextField {...args} multiline={true} placeholder="Please typing..." />
167
+ </Box>
168
+ );
169
+ };
170
+
171
+ export const Placeholder: StoryObj<typeof TextField> = {
172
+ render: PlaceholderTemplate,
173
+ parameters: {
174
+ controls: {
175
+ include: ["size", "helperText", "disabled", "error"],
176
+ },
177
+ chromatic: { disableSnapshot: true },
178
+ },
179
+ };
180
+
181
+ const HelperTextTemplate: StoryFn<typeof TextField> = (args) => {
182
+ return (
183
+ <Box sx={{ display: "flex", gap: 2 }}>
184
+ <TextField {...args} helperText="helper text" />
185
+ <TextField {...args} multiline={true} helperText="helper text" />
186
+ </Box>
187
+ );
188
+ };
189
+
190
+ export const HelperText: StoryObj<typeof TextField> = {
191
+ render: HelperTextTemplate,
192
+ parameters: {
193
+ controls: {
194
+ include: ["size", "disabled", "error", "placeholder"],
195
+ },
196
+ chromatic: { disableSnapshot: true },
197
+ },
198
+ };
199
+
200
+ const IconTemplate: StoryFn<typeof TextField> = (args) => {
201
+ return (
202
+ <Box sx={{ display: "flex", gap: 2 }}>
203
+ <TextField {...args} leftIcon={<Bell />} />
204
+ <TextField {...args} rightIcon={<Bell />} />
205
+ </Box>
206
+ );
207
+ };
208
+
209
+ export const Icon: StoryObj<typeof TextField> = {
210
+ render: IconTemplate,
211
+ parameters: {
212
+ chromatic: { disableSnapshot: true },
213
+ },
214
+ };
@@ -0,0 +1,140 @@
1
+ import { Canvas, Stories, Controls, Meta, Story } from "@storybook/blocks";
2
+ import Box from "@mui/material/Box";
3
+
4
+ import TextField from "@/components/TextField";
5
+ import * as TextFieldStories from "./BasicTextField.stories";
6
+ import * as TextFieldSizeStories from "./TextFieldSize.stories";
7
+
8
+ <Meta name="TextField Docs" of={TextFieldStories} />
9
+
10
+ # TextField
11
+
12
+ Text Fields let users enter and edit text.
13
+
14
+ ## Usage
15
+
16
+ ### Basic TextField
17
+
18
+ ```tsx
19
+ import { TextField } from "@lunit/design-system";
20
+ // or
21
+ import TextField from "@lunit/design-system/TextField";
22
+
23
+ <TextField />;
24
+ ```
25
+
26
+ ### Demo
27
+
28
+ <Canvas of={TextFieldStories.BasicTextField} sourceState="none" />
29
+
30
+ <Controls />
31
+
32
+ ### MultiLine
33
+
34
+ The multiline prop transforms the text field into a [TextareaAutosize](https://mui.com/material-ui/react-textarea-autosize/) element.<br />
35
+ If multiline is undefined, it behaves the same as false.<br />
36
+ Default multiline is `false`.
37
+
38
+ <Canvas of={TextFieldStories.MultiAndSingle} sourceState="none" />
39
+
40
+ ```tsx
41
+ <TextField />
42
+ <TextField multiline />
43
+ ```
44
+
45
+ ### Size
46
+
47
+ The TextField have three sizes: `small`, `medium` and `large`.<br />
48
+ Using the `size` prop, you can change the size of the TextField.<br />
49
+ Default size is `small`.
50
+
51
+ <Canvas
52
+ of={TextFieldSizeStories.TextFieldSize}
53
+ meta={TextFieldSizeStories}
54
+ sourceState="none"
55
+ />
56
+
57
+ ```tsx
58
+ // multiline is false or undefined
59
+ <TextField size="small" />
60
+ <TextField size="medium" />
61
+ <TextField size="large" />
62
+
63
+ // multiline is true
64
+ <TextField multiline size="small" />
65
+ <TextField multiline size="medium" />
66
+ <TextField multiline size="large" />
67
+ ```
68
+
69
+ ### Disabled
70
+
71
+ If you want to disable the TextField, you can use the `disabled` prop.<br />
72
+ Default disabled is `false`.
73
+
74
+ <Canvas of={TextFieldStories.Disabled} sourceState="none" />
75
+
76
+ ```tsx
77
+ <TextField disabled />
78
+ <TextField multiline disabled />
79
+ ```
80
+
81
+ ### Error
82
+
83
+ The error prop toggles the error state.<br />
84
+ The helperText prop can then be used to provide feedback to the user about the error.<br />
85
+ Default error is `false`.
86
+
87
+ <Canvas of={TextFieldStories.Error} sourceState="none" />
88
+
89
+ ```tsx
90
+ <TextField {...args} error />
91
+ <TextField {...args} error multiline={true} />
92
+ ```
93
+
94
+ ### Placeholder
95
+
96
+ The placeholder attribute defines the text displayed in a form control when the control has no value.<br />
97
+ The placeholder text should provide a brief hint to the user as to the expected type of data<br />
98
+ that should be entered into the control.
99
+
100
+ <Canvas of={TextFieldStories.Placeholder} sourceState="none" />
101
+
102
+ ```tsx
103
+ <TextField placeholder="Please typing..." />
104
+ <TextField multiline placeholder="Please typing..." />
105
+ ```
106
+
107
+ ### helperText
108
+
109
+ The helper text content, use "error " or "sub text " to display helper text.
110
+
111
+ <Canvas of={TextFieldStories.HelperText} sourceState="none" />
112
+
113
+ ```tsx
114
+ <TextField helperText="helper text" />
115
+ <TextField multiline helperText="helper text" />
116
+ ```
117
+
118
+ ### Icon
119
+
120
+ TextField icons can be added to the left and right sides.<br />
121
+ Use the leftIcon prop for the left side and the rightIcon prop for the right side. <br />
122
+ Icon can only be used with a single TextField.
123
+
124
+ <Canvas of={TextFieldStories.Icon} sourceState="none" />
125
+
126
+ ```tsx
127
+ <TextField leftIcon={<Bell />} />
128
+ <TextField rightIcon={<Bell />} />
129
+ ```
130
+
131
+ ## Reference
132
+
133
+ - [Material-UI TextField](https://mui.com/material-ui/react-text-field/)
134
+ - [Material-UI TextField API](https://mui.com/material-ui/api/text-field/)
135
+ - [Lunit Design System TextField Figma](https://www.figma.com/file/BSdRUpEPp7XiJ9YnEqpf6F/1.0.0_Components?node-id=284%3A151&mode=dev)
136
+
137
+ ## Support
138
+
139
+ - Github: [Create a new issue](https://github.com/lunit-io/design-system/issues/new)
140
+ - Slack: #tf_design_system