@lunit/design-system 2.0.2 → 2.2.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 (187) hide show
  1. package/README.md +107 -7
  2. package/dist/cjs/components/Alert/index.js +1 -1
  3. package/dist/cjs/components/Alert/index.js.map +1 -1
  4. package/dist/cjs/components/Button/index.js +1 -1
  5. package/dist/cjs/components/Button/index.js.map +1 -1
  6. package/dist/cjs/components/Checkbox/index.js +1 -1
  7. package/dist/cjs/components/Checkbox/index.js.map +1 -1
  8. package/dist/cjs/components/Chip/index.js +1 -1
  9. package/dist/cjs/components/Chip/index.js.map +1 -1
  10. package/dist/cjs/components/DataTable/index.js.map +1 -1
  11. package/dist/cjs/components/DatePicker/index.js.map +1 -1
  12. package/dist/cjs/components/Dialog/index.js +1 -1
  13. package/dist/cjs/components/Dialog/index.js.map +1 -1
  14. package/dist/cjs/components/Dropdown/index.js +1 -1
  15. package/dist/cjs/components/Dropdown/index.js.map +1 -1
  16. package/dist/cjs/components/FormLabel/index.js +1 -1
  17. package/dist/cjs/components/FormLabel/index.js.map +1 -1
  18. package/dist/cjs/components/Radio/index.js +1 -1
  19. package/dist/cjs/components/Radio/index.js.map +1 -1
  20. package/dist/cjs/components/RadioGroup/index.js.map +1 -1
  21. package/dist/cjs/components/TextField/index.js +1 -1
  22. package/dist/cjs/components/TextField/index.js.map +1 -1
  23. package/dist/cjs/components/Toggle/index.js +1 -1
  24. package/dist/cjs/components/Toggle/index.js.map +1 -1
  25. package/dist/cjs/components/ToggleButton/index.js +1 -1
  26. package/dist/cjs/components/ToggleButton/index.js.map +1 -1
  27. package/dist/cjs/components/Tooltip/index.js.map +1 -1
  28. package/dist/cjs/components/Typography/index.js.map +1 -1
  29. package/dist/cjs/index.js +1 -1
  30. package/dist/cjs/index.js.map +1 -1
  31. package/dist/components/Chip/Chip.styled.js +9 -16
  32. package/dist/components/Chip/Chip.styled.js.map +1 -1
  33. package/dist/components/Dialog/Dialog.js +0 -6
  34. package/dist/components/Dialog/Dialog.js.map +1 -1
  35. package/dist/components/Dropdown/Dropdown.js +37 -4
  36. package/dist/components/Dropdown/Dropdown.js.map +1 -1
  37. package/dist/components/Dropdown/Dropdown.styled.js +161 -0
  38. package/dist/components/Dropdown/Dropdown.styled.js.map +1 -0
  39. package/dist/components/Dropdown/Dropdown.types.js +2 -0
  40. package/dist/components/Dropdown/Dropdown.types.js.map +1 -0
  41. package/dist/components/Dropdown/DropdownItem.js +36 -0
  42. package/dist/components/Dropdown/DropdownItem.js.map +1 -0
  43. package/dist/components/Dropdown/index.js +1 -0
  44. package/dist/components/Dropdown/index.js.map +1 -1
  45. package/dist/components/TextField/TextField.js +1 -1
  46. package/dist/components/TextField/TextField.js.map +1 -1
  47. package/dist/components/TextField/TextField.style.js +27 -3
  48. package/dist/components/TextField/TextField.style.js.map +1 -1
  49. package/dist/foundation/Typography/index.js +5 -0
  50. package/dist/foundation/Typography/index.js.map +1 -1
  51. package/dist/foundation/Typography/tokens.js +44 -0
  52. package/dist/foundation/Typography/tokens.js.map +1 -1
  53. package/dist/foundation/colors/base/blue.js +12 -10
  54. package/dist/foundation/colors/base/blue.js.map +1 -1
  55. package/dist/foundation/colors/base/green.js +11 -9
  56. package/dist/foundation/colors/base/green.js.map +1 -1
  57. package/dist/foundation/colors/base/grey.js +30 -15
  58. package/dist/foundation/colors/base/grey.js.map +1 -1
  59. package/dist/foundation/colors/base/lunitTeal.js +2 -0
  60. package/dist/foundation/colors/base/lunitTeal.js.map +1 -1
  61. package/dist/foundation/colors/base/magenta.js +3 -1
  62. package/dist/foundation/colors/base/magenta.js.map +1 -1
  63. package/dist/foundation/colors/base/orange.js +11 -9
  64. package/dist/foundation/colors/base/orange.js.map +1 -1
  65. package/dist/foundation/colors/base/purple.js +3 -1
  66. package/dist/foundation/colors/base/purple.js.map +1 -1
  67. package/dist/foundation/colors/base/red.js +5 -3
  68. package/dist/foundation/colors/base/red.js.map +1 -1
  69. package/dist/foundation/colors/base/yellow.js +12 -10
  70. package/dist/foundation/colors/base/yellow.js.map +1 -1
  71. package/dist/foundation/colors/index.js +3 -0
  72. package/dist/foundation/colors/index.js.map +1 -1
  73. package/dist/foundation/colors/token/component.js +26 -22
  74. package/dist/foundation/colors/token/component.js.map +1 -1
  75. package/dist/foundation/colors/token/core.js +21 -0
  76. package/dist/foundation/colors/token/core.js.map +1 -1
  77. package/dist/index.js +1 -1
  78. package/dist/index.js.map +1 -1
  79. package/dist/types/components/Button/Button.styled.d.ts +35 -50
  80. package/dist/types/components/Chip/Chip.styled.d.ts +4 -76
  81. package/dist/types/components/Chip/Chip.types.d.ts +1 -1
  82. package/dist/types/components/Dialog/Dialog.d.ts +0 -3
  83. package/dist/types/components/Dropdown/Dropdown.d.ts +3 -1
  84. package/dist/types/components/Dropdown/Dropdown.styled.d.ts +7 -0
  85. package/dist/types/components/Dropdown/Dropdown.types.d.ts +11 -0
  86. package/dist/types/components/Dropdown/DropdownItem.d.ts +13 -0
  87. package/dist/types/components/Dropdown/index.d.ts +2 -0
  88. package/dist/types/components/TextField/TextField.types.d.ts +1 -1
  89. package/dist/types/components/TextField/TextFieldIcon.d.ts +1 -1
  90. package/dist/types/components/ToggleButton/ToggleButton.styled.d.ts +1 -32
  91. package/dist/types/components/Typography/Typography.d.ts +1 -1
  92. package/dist/types/foundation/Typography/index.d.ts +21 -1
  93. package/dist/types/foundation/Typography/tokens.d.ts +15 -0
  94. package/dist/types/foundation/colors/base/blue.d.ts +2 -0
  95. package/dist/types/foundation/colors/base/green.d.ts +2 -0
  96. package/dist/types/foundation/colors/base/grey.d.ts +15 -0
  97. package/dist/types/foundation/colors/base/lunitTeal.d.ts +2 -0
  98. package/dist/types/foundation/colors/base/magenta.d.ts +2 -0
  99. package/dist/types/foundation/colors/base/orange.d.ts +2 -0
  100. package/dist/types/foundation/colors/base/purple.d.ts +2 -0
  101. package/dist/types/foundation/colors/base/red.d.ts +2 -0
  102. package/dist/types/foundation/colors/base/yellow.d.ts +2 -0
  103. package/dist/types/foundation/colors/index.d.ts +3 -0
  104. package/dist/types/foundation/colors/types.d.ts +3 -0
  105. package/dist/types/foundation/index.d.ts +3 -0
  106. package/dist/types/index.d.ts +1 -1
  107. package/package.json +20 -22
  108. package/src/components/Chip/Chip.styled.ts +9 -16
  109. package/src/components/Chip/Chip.types.ts +2 -0
  110. package/src/components/Dialog/Dialog.tsx +0 -8
  111. package/src/components/Dropdown/Dropdown.styled.tsx +170 -0
  112. package/src/components/Dropdown/Dropdown.tsx +59 -8
  113. package/src/components/Dropdown/Dropdown.types.ts +17 -0
  114. package/src/components/Dropdown/DropdownItem.tsx +107 -0
  115. package/src/components/Dropdown/index.ts +6 -0
  116. package/src/components/TextField/TextField.style.ts +28 -3
  117. package/src/components/TextField/TextField.tsx +1 -7
  118. package/src/components/TextField/TextField.types.ts +2 -0
  119. package/src/components/TextField/TextFieldIcon.tsx +1 -1
  120. package/src/foundation/Typography/index.ts +10 -0
  121. package/src/foundation/Typography/tokens.ts +45 -0
  122. package/src/foundation/colors/base/blue.ts +12 -10
  123. package/src/foundation/colors/base/green.ts +11 -9
  124. package/src/foundation/colors/base/grey.ts +30 -15
  125. package/src/foundation/colors/base/lunitTeal.ts +2 -0
  126. package/src/foundation/colors/base/magenta.ts +3 -1
  127. package/src/foundation/colors/base/orange.ts +11 -9
  128. package/src/foundation/colors/base/purple.ts +3 -1
  129. package/src/foundation/colors/base/red.ts +5 -3
  130. package/src/foundation/colors/base/yellow.ts +12 -10
  131. package/src/foundation/colors/index.ts +3 -0
  132. package/src/foundation/colors/token/component.ts +26 -22
  133. package/src/foundation/colors/token/core.ts +21 -0
  134. package/src/foundation/colors/types.ts +3 -0
  135. package/src/index.ts +6 -1
  136. package/src/stories/GettingStarted.mdx +10 -16
  137. package/src/stories/components/Alert/Alert.stories.tsx +3 -3
  138. package/src/stories/components/Button/BasicButton.stories.tsx +2 -2
  139. package/src/stories/components/Button/ButtonDocs.mdx +1 -1
  140. package/src/stories/components/Button/Color.stories.tsx +2 -2
  141. package/src/stories/components/Button/IconButton.stories.tsx +2 -2
  142. package/src/stories/components/Button/Kind.stories.tsx +2 -2
  143. package/src/stories/components/CheckBox/BasicCheckbox.stories.tsx +2 -2
  144. package/src/stories/components/CheckBox/CheckboxDocs.mdx +1 -1
  145. package/src/stories/components/Chip/Chip.stories.tsx +20 -2
  146. package/src/stories/components/Chip/ChipDocs.mdx +21 -1
  147. package/src/stories/components/DataTable/DataTable.stories.tsx +1 -1
  148. package/src/stories/components/DatePicker/DatePicker.stories.tsx +1 -1
  149. package/src/stories/components/Dialog/Dialog.stories.tsx +19 -8
  150. package/src/stories/components/Dialog/DialogDocs.mdx +3 -11
  151. package/src/stories/components/Dropdown/Dropdown.stories.tsx +299 -10
  152. package/src/stories/components/Dropdown/DropdownExamples.stories.tsx +221 -0
  153. package/src/stories/components/Dropdown/DropdownItem.stories.tsx +360 -0
  154. package/src/stories/components/SelectControl/RadioGroup.stories.tsx +1 -1
  155. package/src/stories/components/SelectControl/RadioStatus.stories.tsx +1 -1
  156. package/src/stories/components/SelectControl/Toggle.stories.tsx +2 -2
  157. package/src/stories/components/TextField/BasicTextField.stories.tsx +37 -16
  158. package/src/stories/components/TextField/TextFieldDocs.mdx +13 -1
  159. package/src/stories/components/TextField/TextFieldMulti.stories.tsx +8 -11
  160. package/src/stories/components/TextField/TextFieldSingle.stories.tsx +8 -11
  161. package/src/stories/components/TextField/TextFieldSize.stories.tsx +7 -8
  162. package/src/stories/components/Toast/Toast.stories.tsx +8 -3
  163. package/src/stories/components/ToggleButton/Basic.stories.tsx +152 -113
  164. package/src/stories/components/ToggleButton/ToggleButtonDocs.mdx +1 -1
  165. package/src/stories/components/ToggleButton/ToggleButtonKind.stories.tsx +5 -5
  166. package/src/stories/components/ToggleButton/WithIcon.stories.tsx +2 -2
  167. package/src/stories/components/Tooltip/Tooltip.stories.tsx +1 -1
  168. package/src/stories/foundation/Elevation/Elevation.stories.tsx +1 -20
  169. package/src/stories/foundation/Typography/Typography.mdx +1 -1
  170. package/src/stories/foundation/Typography/Typography.stories.tsx +14 -1
  171. package/src/stories/foundation/Typography/const.ts +6 -1
  172. package/src/stories/foundation/colors/Colors.stories.tsx +2 -2
  173. package/src/stories/foundation/colors/Docs.mdx +1 -1
  174. package/src/stories/foundation/colors/Mui.stories.tsx +1 -1
  175. package/src/stories/foundation/colors/Token.inComponent.stories.tsx +1 -1
  176. package/src/stories/foundation/colors/TokenPaletteTable.stories.tsx +1 -1
  177. package/src/stories/foundation/colors/TokenPaletteTable.tsx +19 -1
  178. package/tsconfig.json +0 -1
  179. package/dist/cjs/components/Modal/index.js +0 -2
  180. package/dist/cjs/components/Modal/index.js.map +0 -1
  181. package/dist/components/Modal/Modal.js +0 -7
  182. package/dist/components/Modal/Modal.js.map +0 -1
  183. package/dist/components/Modal/index.js +0 -2
  184. package/dist/components/Modal/index.js.map +0 -1
  185. package/dist/types/components/Modal/Modal.d.ts +0 -2
  186. package/dist/types/components/Modal/index.d.ts +0 -1
  187. package/src/stories/components/ToggleButton/Group.stories.tsx +0 -221
@@ -1,4 +1,4 @@
1
- import { Meta } from '@storybook/blocks';
1
+ import { Meta } from "@storybook/addon-docs/blocks";
2
2
 
3
3
  <Meta title="Getting Started/Overview" />
4
4
 
@@ -17,9 +17,9 @@ Material UI is peer dependency of Lunit Design System Library. You need to insta
17
17
  ```json
18
18
  "peerDependencies": {
19
19
  "@mui/material": "^5.0.0",
20
- "@types/react": "^17.0.0 || ^18.0.0",
21
- "react": "^17.0.0 || ^18.0.0",
22
- "react-dom": "^17.0.0 || ^18.0.0"
20
+ "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
21
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
22
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
23
23
  }
24
24
  ```
25
25
 
@@ -30,12 +30,9 @@ Material UI is peer dependency of Lunit Design System Library. You need to insta
30
30
  This library is based on Material UI's themes feature, so it imports themes and puts them into the provider. We also recommend using the `CssBaseline` component.
31
31
 
32
32
  ```tsx
33
- import {
34
- createTheme,
35
- ThemeProvider,
36
- } from '@mui/material/styles';
37
- import CssBaseline from '@mui/material/CssBaseline';
38
- import { themeOptions } from '@lunit/design-system';
33
+ import { createTheme, ThemeProvider } from "@mui/material/styles";
34
+ import CssBaseline from "@mui/material/CssBaseline";
35
+ import { themeOptions } from "@lunit/design-system";
39
36
 
40
37
  const theme = createTheme(themeOptions);
41
38
 
@@ -61,11 +58,8 @@ This library uses the `Pretendard` font-family by default. The [Pretendard font]
61
58
  const theme = createTheme(
62
59
  deepmerge(themeOptions, {
63
60
  typography: {
64
- fontFamily: [
65
- 'Pretendard Variable',
66
- 'sans-serif',
67
- ]
68
- }
61
+ fontFamily: ["Pretendard Variable", "sans-serif"],
62
+ },
69
63
  })
70
64
  );
71
65
  ```
@@ -85,4 +79,4 @@ This library provides a variety of components that are used in Lunit's products.
85
79
  ## Support
86
80
 
87
81
  - Github: [Create a new issue](https://github.com/lunit-io/design-system/issues/new)
88
- - Slack: #tf_design_system
82
+ - Slack: #tf_design_system
@@ -1,11 +1,11 @@
1
1
  import React from "react";
2
2
  import { Box, Typography } from "@mui/material";
3
- import { StoryFn, Meta } from "@storybook/react";
3
+ import { StoryFn, Meta } from "@storybook/react-webpack5";
4
4
 
5
5
  import Alert from "@/components/Alert";
6
6
  import Button from "@/components/Button";
7
7
  import theme from "@/theme";
8
- import { action } from "@storybook/addon-actions";
8
+ import { action } from "storybook/actions";
9
9
 
10
10
  export default {
11
11
  title: "Components/Alert",
@@ -24,7 +24,7 @@ export default {
24
24
  description: `\`success\`, \`info\`, \`warning\`, \`error\`, \`undefined\``,
25
25
  },
26
26
  onClose: {
27
- control: "function",
27
+ control: false, // TODO: 스토리북 버전업 과정에서 control 이 'function' 타입을 지원하지 않아 false 로 변경. 현재 스토리북에서 동작은 이상없으나 필요한 사항이 있으면 수정할 것
28
28
  description: `Callback fired when the component requests to be closed.
29
29
  When provided, a close icon button is displayed that triggers the callback when clicked.`,
30
30
  },
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
- import { action } from "@storybook/addon-actions";
2
+ import { action } from "storybook/actions";
3
3
  import { Box } from "@mui/material";
4
4
 
5
5
  import Button from "@/components/Button";
6
6
 
7
- import type { StoryObj, StoryFn, Meta } from "@storybook/react";
7
+ import type { StoryObj, StoryFn, Meta } from "@storybook/react-webpack5";
8
8
 
9
9
  export default {
10
10
  title: "Components/Button",
@@ -1,4 +1,4 @@
1
- import { Canvas, Stories, Controls, Meta, Story } from "@storybook/blocks";
1
+ import { Canvas, Stories, Controls, Meta, Story } from "@storybook/addon-docs/blocks";
2
2
  import Box from "@mui/material/Box";
3
3
  import Bell from "@lunit/design-system-icons/Bell";
4
4
 
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
2
  import { Box } from "@mui/material";
3
- import { action } from "@storybook/addon-actions";
3
+ import { action } from "storybook/actions";
4
4
 
5
5
  import Button from "@/components/Button";
6
6
 
7
- import type { StoryFn, Meta } from "@storybook/react";
7
+ import type { StoryFn, Meta } from "@storybook/react-webpack5";
8
8
 
9
9
  export default {
10
10
  title: "Components/Button",
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
2
  import Bell from "@lunit/design-system-icons/Bell";
3
- import { action } from "@storybook/addon-actions";
3
+ import { action } from "storybook/actions";
4
4
 
5
5
  import Button from "@/components/Button";
6
6
 
7
- import type { StoryFn, Meta } from "@storybook/react";
7
+ import type { StoryFn, Meta } from "@storybook/react-webpack5";
8
8
  import { Box } from "@mui/material";
9
9
 
10
10
  export default {
@@ -6,11 +6,11 @@ import {
6
6
  TableBody,
7
7
  TableCell,
8
8
  } from "@mui/material";
9
- import { action } from "@storybook/addon-actions";
9
+ import { action } from "storybook/actions";
10
10
 
11
11
  import Button from "@/components/Button";
12
12
 
13
- import type { StoryFn, Meta } from "@storybook/react";
13
+ import type { StoryFn, Meta } from "@storybook/react-webpack5";
14
14
 
15
15
  export default {
16
16
  title: "Components/Button",
@@ -1,9 +1,9 @@
1
1
  import React, { useState, useEffect } from "react";
2
2
  import { Box, FormControlLabel } from "@mui/material";
3
- import { action } from "@storybook/addon-actions";
3
+ import { action } from "storybook/actions";
4
4
  import Checkbox from "@/components/Checkbox";
5
5
  import FormLabel from "@/components/FormLabel";
6
- import { Meta, StoryFn } from "@storybook/react";
6
+ import { Meta, StoryFn } from "@storybook/react-webpack5";
7
7
 
8
8
  export default {
9
9
  title: "Components/Checkbox",
@@ -1,4 +1,4 @@
1
- import { Canvas, Stories, Controls, Meta, Story } from "@storybook/blocks";
1
+ import { Canvas, Stories, Controls, Meta, Story } from "@storybook/addon-docs/blocks";
2
2
  import Box from "@mui/material/Box";
3
3
  import Bell from "@lunit/design-system-icons/Bell";
4
4
 
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import { Meta } from "@storybook/react";
3
- import { action } from "@storybook/addon-actions";
2
+ import { Meta } from "@storybook/react-webpack5";
3
+ import { action } from "storybook/actions";
4
4
  import { Box } from "@mui/system";
5
5
 
6
6
  import Chip from "@/components/Chip";
@@ -281,3 +281,21 @@ export const ContainedWithDeleteAndThumbnail = {
281
281
 
282
282
  name: "Kind(Variant): Contained with Thumbnail and Deletable",
283
283
  };
284
+
285
+ export const Multiline = {
286
+ render: () => (
287
+ <Box sx={{ width: 100 }}>
288
+ <Chip
289
+ sx={{
290
+ height: "auto",
291
+ "& .MuiChip-label": {
292
+ display: "block",
293
+ whiteSpace: "normal",
294
+ },
295
+ }}
296
+ label="This is a chip that has multiple lines."
297
+ />
298
+ <Chip label="This is a chip that has ellipsis." />
299
+ </Box>
300
+ ),
301
+ };
@@ -1,4 +1,4 @@
1
- import { Canvas, Stories, Controls, Meta, Story } from "@storybook/blocks";
1
+ import { Canvas, Stories, Controls, Meta, Story } from "@storybook/addon-docs/blocks";
2
2
  import { Error } from "@lunit/design-system-icons";
3
3
 
4
4
  import Chip from "@/components/Chip";
@@ -120,6 +120,26 @@ The hover/pressed effects are only applied to the delete icon. <br />
120
120
  <Chip label="label@lunit.io" onDelete={() => console.log("onDelete")} thumbnail="W as initial" />
121
121
  ````
122
122
 
123
+ ### Multiline
124
+ By default, Chips displays labels only in a single line. To have them support multiline content, use the `sx` prop to add `height:auto` to the Chip component, and `whiteSpace: normal` to the `label` styles.
125
+
126
+ <Canvas of={ChipStories.Multiline} />
127
+ ```tsx
128
+ <Chip
129
+ sx={{
130
+ height: "auto",
131
+ "& .MuiChip-label": {
132
+ display: "block",
133
+ whiteSpace: "normal",
134
+ },
135
+ }}
136
+ label="This is a chip that has multiple lines."
137
+ />
138
+ <Chip label="This is a chip that has ellipsis." />
139
+ ````
140
+
141
+
142
+
123
143
  ## Reference
124
144
 
125
145
  - [Material-UI Chip](https://mui.com/material-ui/react-chip/)
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { StoryFn, Meta } from "@storybook/react";
2
+ import { StoryFn, Meta } from "@storybook/react-webpack5";
3
3
 
4
4
  import DataTable from "@/components/DataTable";
5
5
 
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { StoryFn, Meta } from "@storybook/react";
2
+ import { StoryFn, Meta } from "@storybook/react-webpack5";
3
3
 
4
4
  import DatePicker from "@/components/DatePicker";
5
5
 
@@ -5,12 +5,11 @@ import Error from "@lunit/design-system-icons/Error";
5
5
  import Button from "@/components/Button";
6
6
  import Dialog from "@/components/Dialog";
7
7
 
8
- import type { Meta, StoryObj } from "@storybook/react";
8
+ import type { Meta, StoryObj } from "@storybook/react-webpack5";
9
9
 
10
10
  const meta: Meta<typeof Dialog> = {
11
11
  title: "components/Dialog",
12
12
  component: Dialog,
13
- tags: ["autodocs"],
14
13
  parameters: {
15
14
  docs: { disable: true, hidden: true },
16
15
  },
@@ -30,7 +29,9 @@ export const PassiveModal: Story = {
30
29
 
31
30
  return (
32
31
  <div style={{ width: "100vw", height: "100vh" }}>
33
- <div ref={(ref) => setTarget(ref)} />
32
+ <div ref={ref => {
33
+ setTarget(ref);
34
+ }} />
34
35
  <Dialog
35
36
  className={classNameFromGlobal}
36
37
  isOpen={Boolean(target)}
@@ -54,7 +55,9 @@ export const ActionModal: Story = {
54
55
 
55
56
  return (
56
57
  <div style={{ width: "100vw", height: "100vh" }}>
57
- <div ref={(ref) => setTarget(ref)} />
58
+ <div ref={ref => {
59
+ setTarget(ref);
60
+ }} />
58
61
  <Dialog
59
62
  className={classNameFromGlobal}
60
63
  isOpen={Boolean(target)}
@@ -148,7 +151,9 @@ export const SmallFalse: Story = {
148
151
 
149
152
  return (
150
153
  <div style={{ width: "100vw", height: "100vh" }}>
151
- <div ref={(ref) => setTarget(ref)} />
154
+ <div ref={ref => {
155
+ setTarget(ref);
156
+ }} />
152
157
  <Dialog
153
158
  className={classNameFromGlobal}
154
159
  isOpen={Boolean(target)}
@@ -173,7 +178,9 @@ export const WithTitleIcon: Story = {
173
178
 
174
179
  return (
175
180
  <div style={{ width: "100vw", height: "100vh" }}>
176
- <div ref={(ref) => setTarget(ref)} />
181
+ <div ref={ref => {
182
+ setTarget(ref);
183
+ }} />
177
184
  <Dialog
178
185
  className={classNameFromGlobal}
179
186
  isOpen={Boolean(target)}
@@ -218,7 +225,9 @@ export const WithCustomStyle: Story = {
218
225
 
219
226
  return (
220
227
  <div style={{ width: "100vw", height: "100vh" }}>
221
- <div ref={(ref) => setTarget(ref)} />
228
+ <div ref={ref => {
229
+ setTarget(ref);
230
+ }} />
222
231
  <Dialog
223
232
  className={classNameFromGlobal}
224
233
  isOpen={Boolean(target)}
@@ -249,7 +258,9 @@ export const WithScroll: Story = {
249
258
 
250
259
  return (
251
260
  <div style={{ width: "100vw", height: "100vh" }}>
252
- <div ref={(ref) => setTarget(ref)} />
261
+ <div ref={ref => {
262
+ setTarget(ref);
263
+ }} />
253
264
  <Dialog
254
265
  className={classNameFromGlobal}
255
266
  isOpen={Boolean(target)}
@@ -1,4 +1,4 @@
1
- import { Canvas, Stories, Controls, Meta, Story } from "@storybook/blocks";
1
+ import { Canvas, Stories, Controls, Meta, Story } from "@storybook/addon-docs/blocks";
2
2
  import { Error } from "@lunit/design-system-icons";
3
3
 
4
4
  import Dialog from "@/components/Dialog";
@@ -41,24 +41,16 @@ If it is set to `false`, the Dialog will not be rendered in the DOM.
41
41
  </Dialog>
42
42
  ```
43
43
 
44
- ### Dismiss(onClose, enableBackButtonClose, enableBackdropClick)
44
+ ### Dismiss(onClose, enableBackdropClick)
45
45
 
46
46
  The `onClose` prop is used to close the Dialog. You can pass a function to the prop to close the Dialog. <br />
47
- If the `enableBackButtonClick` prop is set to `true`, the Dialog will be closed when the back button(escape/backspace key) is pressed. <br />
48
47
  If the `enableBackdropClose` prop is set to `true`, the Dialog will be closed when the backdrop(outside of the dialog area) is clicked. <br />
49
-
50
- <br />
51
- The `enableBackButtonClick` is awalys `true` in Passive Modal, but it is optional
52
- in Action Modal. <br />
53
- The `enableBackdropClose` is awalys `true` only in Passive Modal.
48
+ The `enableBackdropClose` is always `true` only in Passive Modal.
54
49
 
55
50
  ```tsx
56
51
  <Dialog isOpen={true} onClose={close} type="passive" title="Title area">
57
52
  Lorem Ipsum is simply dummy text of the a printing and typesetting industry
58
53
  </Dialog>
59
- <Dialog isOpen={true} onClose={close} type="action" title="Title area" actions={actionsChildren} enableBackButtonClick>
60
- Lorem Ipsum is simply dummy text of the a printing and typesetting industry
61
- </Dialog>
62
54
  ```
63
55
 
64
56
  ### Type
@@ -1,21 +1,310 @@
1
- import React from "react";
2
- import { StoryFn, Meta } from "@storybook/react";
1
+ import React, { useState } from "react";
2
+ import { StoryFn, Meta, StoryObj } from "@storybook/react-webpack5";
3
3
 
4
- import Dropdown from "@/components/Dropdown";
4
+ import Dropdown, { DropdownItem } from "@/components/Dropdown";
5
+ import { Box, SelectChangeEvent } from "@mui/material";
5
6
 
6
7
  export default {
7
8
  title: "Components/Dropdown",
8
9
  component: Dropdown,
10
+ argTypes: {
11
+ size: {
12
+ control: {
13
+ type: "radio",
14
+ },
15
+ options: ["small", "medium", "large"],
16
+ description: "The size of the dropdown. Default is medium.",
17
+ },
18
+ select: {
19
+ control: {
20
+ type: "radio",
21
+ },
22
+ options: ["single", "multiple"],
23
+ description: "The select type of the dropdown. Default is single.",
24
+ },
25
+ error: {
26
+ control: {
27
+ type: "radio",
28
+ },
29
+ options: [true, false],
30
+ description: "The error prop toggles the error state.",
31
+ },
32
+ disabled: {
33
+ control: {
34
+ type: "radio",
35
+ },
36
+ options: [true, false],
37
+ description: "If true, the text field will be disabled.",
38
+ },
39
+ },
9
40
  } as Meta<typeof Dropdown>;
10
41
 
11
- const Template: StoryFn<typeof Dropdown> = () => <Dropdown />;
42
+ const BasicDropdownTemplate: StoryFn<typeof Dropdown> = (args, context) => {
43
+ const classNameFromGlobal = context.globals.theme;
12
44
 
13
- export const SingleSelect = {
14
- render: Template,
45
+ // In a single select, selectedValue can be used as a string type instead of an array.
46
+ // In the current Storybook Template, we use selectedValue as a string[] in order to also use it as multiple depending on the control selection.
47
+ const [selectedValue, setSelectedValue] = useState<string[]>(["test1"]);
48
+ const handleSelectedValueChange = (event: SelectChangeEvent<unknown>) => {
49
+ const {
50
+ target: { value },
51
+ } = event;
52
+ setSelectedValue(
53
+ // On autofill we get a stringified value.
54
+ typeof value === "string" ? value.split(",") : (value as string[]),
55
+ );
56
+ };
57
+
58
+ return (
59
+ <Box>
60
+ <Dropdown
61
+ className={classNameFromGlobal}
62
+ value={selectedValue}
63
+ onChange={handleSelectedValueChange}
64
+ sx={{ width: "150px" }}
65
+ {...args}
66
+ >
67
+ <DropdownItem value={"test1"}>Conquer cancer through AI</DropdownItem>
68
+ <DropdownItem value={"test2"}>test item 2</DropdownItem>
69
+ <DropdownItem value={"test3"}>test item 3</DropdownItem>
70
+ </Dropdown>
71
+ </Box>
72
+ );
15
73
  };
16
- export const MultiSelect = {
17
- render: Template,
74
+
75
+ export const BasicDropdown: StoryObj<typeof Dropdown> = {
76
+ render: BasicDropdownTemplate,
77
+ parameters: {
78
+ chromatic: { disableSnapshot: true },
79
+ },
18
80
  };
19
- export const NoSelect = {
20
- render: Template,
81
+
82
+ const SizeTemplate: StoryFn<typeof Dropdown> = (args, context) => {
83
+ const classNameFromGlobal = context.globals.theme;
84
+
85
+ // In a single select, selectedValue can be used as a string type instead of an array.
86
+ // In the current Storybook Template, we use selectedValue as a string[] in order to also use it as multiple depending on the control selection.
87
+ const [selectedValue, setSelectedValue] = useState<string[]>(["test1"]);
88
+ const handleSelectedValueChange = (event: SelectChangeEvent<unknown>) => {
89
+ const {
90
+ target: { value },
91
+ } = event;
92
+ setSelectedValue(
93
+ // On autofill we get a stringified value.
94
+ typeof value === "string" ? value.split(",") : (value as string[]),
95
+ );
96
+ };
97
+
98
+ return (
99
+ <Box sx={{ display: "flex", alignItems: "center", gap: 4 }}>
100
+ <Box>
101
+ <Dropdown
102
+ className={classNameFromGlobal}
103
+ value={selectedValue}
104
+ onChange={handleSelectedValueChange}
105
+ size="small"
106
+ sx={{ width: "150px" }}
107
+ {...args}
108
+ >
109
+ <DropdownItem value={"test1"}>Small item 1</DropdownItem>
110
+ <DropdownItem value={"test2"}>Small item 2</DropdownItem>
111
+ <DropdownItem value={"test3"}>Small item 3</DropdownItem>
112
+ </Dropdown>
113
+ </Box>
114
+ <Box>
115
+ <Dropdown
116
+ className={classNameFromGlobal}
117
+ value={selectedValue}
118
+ onChange={handleSelectedValueChange}
119
+ size="medium"
120
+ sx={{ width: "150px" }}
121
+ {...args}
122
+ >
123
+ <DropdownItem value={"test1"}>Medium item 1</DropdownItem>
124
+ <DropdownItem value={"test2"}>Medium item 2</DropdownItem>
125
+ <DropdownItem value={"test3"}>Medium item 3</DropdownItem>
126
+ </Dropdown>
127
+ </Box>
128
+ <Box>
129
+ <Dropdown
130
+ className={classNameFromGlobal}
131
+ value={selectedValue}
132
+ onChange={handleSelectedValueChange}
133
+ size="large"
134
+ sx={{ width: "150px" }}
135
+ {...args}
136
+ >
137
+ <DropdownItem value={"test1"}>Large item 1</DropdownItem>
138
+ <DropdownItem value={"test2"}>Large item 2</DropdownItem>
139
+ <DropdownItem value={"test3"}>Large item 3</DropdownItem>
140
+ </Dropdown>
141
+ </Box>
142
+ </Box>
143
+ );
144
+ };
145
+
146
+ export const Size: StoryObj<typeof Dropdown> = {
147
+ render: SizeTemplate,
148
+ parameters: {
149
+ controls: {
150
+ include: ["select", "error", "disabled"],
151
+ },
152
+ chromatic: { disableSnapshot: true },
153
+ },
154
+ };
155
+
156
+ const SelectTypeTemplate: StoryFn<typeof Dropdown> = (args, context) => {
157
+ const classNameFromGlobal = context.globals.theme;
158
+
159
+ const [selectedValue, setSelectedValue] = useState<string>("single1");
160
+ const handleSelectedValueChange = (event: SelectChangeEvent<unknown>) => {
161
+ const {
162
+ target: { value },
163
+ } = event;
164
+ setSelectedValue(value as string);
165
+ };
166
+ const [selectedValue2, setSelectedValue2] = useState<string[]>(["multiple1"]);
167
+ const handleSelectedValueChange2 = (event: SelectChangeEvent<unknown>) => {
168
+ const {
169
+ target: { value },
170
+ } = event;
171
+ setSelectedValue2(
172
+ // On autofill we get a stringified value.
173
+ typeof value === "string" ? value.split(",") : (value as string[]),
174
+ );
175
+ };
176
+
177
+ return (
178
+ <Box sx={{ display: "flex", alignItems: "center", gap: 4 }}>
179
+ <Box>
180
+ <Dropdown
181
+ className={classNameFromGlobal}
182
+ value={selectedValue}
183
+ onChange={handleSelectedValueChange}
184
+ sx={{ width: "150px" }}
185
+ {...args}
186
+ >
187
+ <DropdownItem value={"single1"}>Single item 1</DropdownItem>
188
+ <DropdownItem value={"single2"}>Single item 2</DropdownItem>
189
+ <DropdownItem value={"single3"}>Single item 3</DropdownItem>
190
+ </Dropdown>
191
+ </Box>
192
+ <Box>
193
+ <Dropdown
194
+ className={classNameFromGlobal}
195
+ value={selectedValue2}
196
+ onChange={handleSelectedValueChange2}
197
+ select="multiple"
198
+ sx={{ width: "200px" }}
199
+ {...args}
200
+ >
201
+ <DropdownItem value={"multiple1"}>Multiple item 1</DropdownItem>
202
+ <DropdownItem value={"multiple2"}>Multiple item 2</DropdownItem>
203
+ <DropdownItem value={"multiple3"}>Multiple item 3</DropdownItem>
204
+ </Dropdown>
205
+ </Box>
206
+ </Box>
207
+ );
208
+ };
209
+
210
+ export const SelectType: StoryObj<typeof Dropdown> = {
211
+ render: SelectTypeTemplate,
212
+ parameters: {
213
+ controls: {
214
+ include: ["size", "error", "disabled"],
215
+ },
216
+ chromatic: { disableSnapshot: true },
217
+ },
218
+ };
219
+
220
+ const ErrorTemplate: StoryFn<typeof Dropdown> = (args, context) => {
221
+ const classNameFromGlobal = context.globals.theme;
222
+
223
+ // In a single select, selectedValue can be used as a string type instead of an array.
224
+ // In the current Storybook Template, we use selectedValue as a string[] in order to also use it as multiple depending on the control selection.
225
+ const [selectedValue, setSelectedValue] = useState<string[]>(["test1"]);
226
+ const handleSelectedValueChange = (event: SelectChangeEvent<unknown>) => {
227
+ const {
228
+ target: { value },
229
+ } = event;
230
+ setSelectedValue(
231
+ // On autofill we get a stringified value.
232
+ typeof value === "string" ? value.split(",") : (value as string[]),
233
+ );
234
+ };
235
+
236
+ return (
237
+ <Box sx={{ display: "flex", alignItems: "center", gap: 4 }}>
238
+ <Box>
239
+ <Dropdown
240
+ className={classNameFromGlobal}
241
+ value={selectedValue}
242
+ onChange={handleSelectedValueChange}
243
+ error
244
+ sx={{ width: "150px" }}
245
+ {...args}
246
+ >
247
+ <DropdownItem value={"test1"}>Small item 1</DropdownItem>
248
+ <DropdownItem value={"test2"}>Small item 2</DropdownItem>
249
+ <DropdownItem value={"test3"}>Small item 3</DropdownItem>
250
+ </Dropdown>
251
+ </Box>
252
+ </Box>
253
+ );
254
+ };
255
+
256
+ export const Error: StoryObj<typeof Dropdown> = {
257
+ render: ErrorTemplate,
258
+ parameters: {
259
+ controls: {
260
+ include: [],
261
+ },
262
+ chromatic: { disableSnapshot: true },
263
+ },
264
+ };
265
+
266
+ const DisabledTemplate: StoryFn<typeof Dropdown> = (args, context) => {
267
+ const classNameFromGlobal = context.globals.theme;
268
+
269
+ // In a single select, selectedValue can be used as a string type instead of an array.
270
+ // In the current Storybook Template, we use selectedValue as a string[] in order to also use it as multiple depending on the control selection.
271
+ const [selectedValue, setSelectedValue] = useState<string[]>(["test1"]);
272
+ const handleSelectedValueChange = (event: SelectChangeEvent<unknown>) => {
273
+ const {
274
+ target: { value },
275
+ } = event;
276
+ setSelectedValue(
277
+ // On autofill we get a stringified value.
278
+ typeof value === "string" ? value.split(",") : (value as string[]),
279
+ );
280
+ };
281
+
282
+ return (
283
+ <Box sx={{ display: "flex", alignItems: "center", gap: 4 }}>
284
+ <Box>
285
+ <Dropdown
286
+ className={classNameFromGlobal}
287
+ value={selectedValue}
288
+ onChange={handleSelectedValueChange}
289
+ disabled
290
+ sx={{ width: "150px" }}
291
+ {...args}
292
+ >
293
+ <DropdownItem value={"test1"}>Small item 1</DropdownItem>
294
+ <DropdownItem value={"test2"}>Small item 2</DropdownItem>
295
+ <DropdownItem value={"test3"}>Small item 3</DropdownItem>
296
+ </Dropdown>
297
+ </Box>
298
+ </Box>
299
+ );
300
+ };
301
+
302
+ export const Disabled: StoryObj<typeof Dropdown> = {
303
+ render: DisabledTemplate,
304
+ parameters: {
305
+ controls: {
306
+ include: [],
307
+ },
308
+ chromatic: { disableSnapshot: true },
309
+ },
21
310
  };