@lunit/design-system 1.0.0-b.1 → 1.0.0-b.2

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 (54) 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/Chip/index.js +1 -1
  6. package/dist/cjs/components/Chip/index.js.map +1 -1
  7. package/dist/cjs/components/TextField/index.js +1 -1
  8. package/dist/cjs/components/TextField/index.js.map +1 -1
  9. package/dist/cjs/components/ToggleButton/index.js +1 -1
  10. package/dist/cjs/components/ToggleButton/index.js.map +1 -1
  11. package/dist/cjs/components/Typography/index.js +1 -1
  12. package/dist/cjs/components/Typography/index.js.map +1 -1
  13. package/dist/cjs/index.js +1 -1
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/components/Button/Button.js.map +1 -1
  16. package/dist/components/Button/Button.styled.js +3 -3
  17. package/dist/components/Button/Button.styled.js.map +1 -1
  18. package/dist/components/Chip/Chip.js +1 -1
  19. package/dist/components/Chip/Chip.js.map +1 -1
  20. package/dist/components/TextField/TextField.js +16 -12
  21. package/dist/components/TextField/TextField.js.map +1 -1
  22. package/dist/components/TextField/TextField.style.js +5 -7
  23. package/dist/components/TextField/TextField.style.js.map +1 -1
  24. package/dist/components/Typography/Typography.js +7 -0
  25. package/dist/components/Typography/Typography.js.map +1 -0
  26. package/dist/components/Typography/index.js +1 -2
  27. package/dist/components/Typography/index.js.map +1 -1
  28. package/dist/foundation/colors/index.js.map +1 -1
  29. package/dist/types/components/Button/Button.d.ts +2 -2
  30. package/dist/types/components/Button/Button.styled.d.ts +4 -4
  31. package/dist/types/components/Button/Button.types.d.ts +11 -1
  32. package/dist/types/components/Chip/Chip.d.ts +2 -2
  33. package/dist/types/components/Chip/Chip.styled.d.ts +12 -12
  34. package/dist/types/components/Chip/Chip.types.d.ts +7 -1
  35. package/dist/types/components/TextField/TextField.d.ts +3 -2
  36. package/dist/types/components/ToggleButton/ToggleButton.styled.d.ts +2 -2
  37. package/dist/types/components/Typography/Typography.d.ts +11 -0
  38. package/dist/types/components/Typography/index.d.ts +1 -7
  39. package/dist/types/foundation/colors/index.d.ts +3 -0
  40. package/dist/types/foundation/index.d.ts +1 -0
  41. package/package.json +1 -1
  42. package/src/components/Button/Button.styled.ts +3 -3
  43. package/src/components/Button/Button.tsx +2 -2
  44. package/src/components/Button/Button.types.ts +19 -1
  45. package/src/components/Chip/Chip.tsx +10 -2
  46. package/src/components/Chip/Chip.types.ts +15 -1
  47. package/src/components/TextField/TextField.style.ts +5 -7
  48. package/src/components/TextField/TextField.tsx +55 -47
  49. package/src/components/Typography/Typography.tsx +18 -0
  50. package/src/components/Typography/index.ts +1 -9
  51. package/src/foundation/colors/index.ts +2 -0
  52. package/src/stories/components/Button/BasicButton.stories.tsx +1 -3
  53. package/src/stories/components/TextField/TextFieldMulti.stories.tsx +6 -0
  54. package/src/stories/components/TextField/TextFieldSingle.stories.tsx +24 -0
@@ -1,5 +1,13 @@
1
- import type { ButtonProps as MuiButtonProps } from "@mui/material";
1
+ import type {
2
+ ButtonProps as MuiButtonProps,
3
+ ButtonTypeMap as MuiButtonTypeMap,
4
+ } from "@mui/material";
5
+ import type { OverridableComponent } from "@mui/material/OverridableComponent";
2
6
 
7
+ /**
8
+ * TODO: Omit 을 사용할 경우 component prop 타입 추론이 안되는 이슈 발생
9
+ * https://github.com/lunit-io/design-system/pull/133#discussion_r1354277785
10
+ * */
3
11
  interface BaseButtonProps extends Omit<MuiButtonProps, "variant"> {
4
12
  icon?: React.ReactNode;
5
13
  }
@@ -23,3 +31,13 @@ export type ButtonProps =
23
31
  | ContainedButtonProps
24
32
  | GhostButtonProps
25
33
  | OutlinedButtonProps;
34
+
35
+ export type ButtonTypeMap<
36
+ P = {},
37
+ D extends React.ElementType = MuiButtonTypeMap["defaultComponent"]
38
+ > = {
39
+ props: P & ButtonProps;
40
+ defaultComponent: D;
41
+ };
42
+
43
+ export type ButtonType = OverridableComponent<ButtonTypeMap>;
@@ -14,10 +14,11 @@ import type {
14
14
  EnableContainedChipProps,
15
15
  DeletableContainedChipProps,
16
16
  ChipProps,
17
+ ChipType,
17
18
  ChipThumbnail,
18
19
  } from "./Chip.types";
19
20
 
20
- const Chip = (props: ChipProps) => {
21
+ const Chip: ChipType = (props: ChipProps) => {
21
22
  const { kind, onDelete, onClick, ...restProps } = props;
22
23
  if (kind === "outlined") return <OutlinedChip {...props} />;
23
24
  else if (onClick) return <EnableContainedChip {...props} />;
@@ -82,7 +83,14 @@ const ReadOnlyContainedChip = (props: ReadOnlyContainedChipProps) => {
82
83
  };
83
84
 
84
85
  const EnableContainedChip = (props: EnableContainedChipProps) => {
85
- const { color = "primary", thumbnail, onClick, sx, ...restProps } = props;
86
+ const {
87
+ color = "primary",
88
+ thumbnail,
89
+ onDelete,
90
+ onClick,
91
+ sx,
92
+ ...restProps
93
+ } = props;
86
94
 
87
95
  return (
88
96
  <StyledContainedChipEnable
@@ -1,6 +1,10 @@
1
1
  import { CHIP_COLORS } from "./consts";
2
2
 
3
- import type { ChipProps as MuiChipProps } from "@mui/material";
3
+ import type {
4
+ ChipProps as MuiChipProps,
5
+ ChipTypeMap as MuiChipTypeMap,
6
+ } from "@mui/material";
7
+ import type { OverridableComponent } from "@mui/material/OverridableComponent";
4
8
 
5
9
  type ColorKeys = keyof typeof CHIP_COLORS;
6
10
  export type ChipColor = (typeof CHIP_COLORS)[ColorKeys];
@@ -54,3 +58,13 @@ export type ContainedChipProps =
54
58
  | DeletableContainedChipProps;
55
59
 
56
60
  export type ChipProps = OutlinedChipProps | ContainedChipProps;
61
+
62
+ export type ChipTypeMap<
63
+ P = {},
64
+ D extends React.ElementType = MuiChipTypeMap["defaultComponent"]
65
+ > = {
66
+ props: P & ChipProps;
67
+ defaultComponent: D;
68
+ };
69
+
70
+ export type ChipType = OverridableComponent<ChipTypeMap>;
@@ -71,12 +71,8 @@ const getTextFieldPaddingBySize = ({
71
71
  };
72
72
 
73
73
  const commonStyle = ({ lunit_token }: { lunit_token: ColorToken }) => ({
74
- "&.MuiTextField-root": {
75
- width: "100%",
76
- },
77
74
  "& .MuiOutlinedInput-root": {
78
75
  borderRadius: "8px",
79
- width: "100%",
80
76
 
81
77
  "& fieldset": {
82
78
  border: "none",
@@ -87,6 +83,9 @@ const commonStyle = ({ lunit_token }: { lunit_token: ColorToken }) => ({
87
83
  "&.Mui-focused fieldset": {
88
84
  border: `1px solid ${lunit_token.core.focused}`,
89
85
  },
86
+ "&.Mui-error.Mui-focused fieldset": {
87
+ border: `2px solid ${lunit_token.component.textfield_border_error}`,
88
+ },
90
89
  "&.Mui-disabled": {
91
90
  opacity: 0.38,
92
91
  "&:hover::before": {
@@ -97,9 +96,9 @@ const commonStyle = ({ lunit_token }: { lunit_token: ColorToken }) => ({
97
96
  padding: 0,
98
97
  textOverflow: "ellipsis",
99
98
  "&::placeholder": {
100
- color: lunit_token.core.text_medium,
99
+ color: lunit_token.core.text_light,
101
100
  opacity: 1,
102
- WebkitTextFillColor: lunit_token.core.text_medium,
101
+ WebkitTextFillColor: lunit_token.core.text_light,
103
102
  },
104
103
  },
105
104
  "& textarea": {
@@ -114,7 +113,6 @@ const commonStyle = ({ lunit_token }: { lunit_token: ColorToken }) => ({
114
113
  },
115
114
  },
116
115
  background: lunit_token.component.textfield_bg,
117
- overflow: "hidden",
118
116
  color: lunit_token.core.text_normal,
119
117
  "&:hover": {
120
118
  position: "relative",
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { forwardRef } from "react";
2
2
 
3
3
  import TextFieldIcon from "./TextFieldIcon";
4
4
  import { BaseTextField } from "./TextField.style";
@@ -9,53 +9,60 @@ import type {
9
9
  SingleTextFieldProps,
10
10
  } from "./TextField.types";
11
11
 
12
- const SingleTextField = (props: SingleTextFieldProps) => {
13
- const {
14
- size = "small",
15
- leftIcon,
16
- rightIcon,
17
- leftIconSx,
18
- rightIconSx,
19
- onLeftIconClick,
20
- onRightIconClick,
21
- ...restProps
22
- } = props;
12
+ const SingleTextField = forwardRef<HTMLDivElement, SingleTextFieldProps>(
13
+ (props, ref) => {
14
+ const {
15
+ size = "small",
16
+ leftIcon,
17
+ rightIcon,
18
+ leftIconSx,
19
+ rightIconSx,
20
+ onLeftIconClick,
21
+ onRightIconClick,
22
+ InputProps,
23
+ ...restProps
24
+ } = props;
23
25
 
24
- return (
25
- <BaseTextField
26
- {...restProps}
27
- textFieldSize={size}
28
- hasLeftIcon={Boolean(leftIcon)}
29
- hasRightIcon={Boolean(rightIcon)}
30
- InputProps={{
31
- startAdornment: leftIcon && (
32
- <TextFieldIcon
33
- sx={{ marginRight: "4px", ...leftIconSx }}
34
- icon={leftIcon}
35
- onIconClick={onLeftIconClick}
36
- />
37
- ),
38
- endAdornment: rightIcon && (
39
- <TextFieldIcon
40
- sx={{ marginLeft: "4px", ...rightIconSx }}
41
- icon={rightIcon}
42
- onIconClick={onRightIconClick}
43
- />
44
- ),
45
- }}
46
- />
47
- );
48
- };
26
+ return (
27
+ <BaseTextField
28
+ {...restProps}
29
+ ref={ref}
30
+ textFieldSize={size}
31
+ hasLeftIcon={Boolean(leftIcon)}
32
+ hasRightIcon={Boolean(rightIcon)}
33
+ InputProps={{
34
+ ...{
35
+ startAdornment: leftIcon && (
36
+ <TextFieldIcon
37
+ sx={{ marginRight: "4px", ...leftIconSx }}
38
+ icon={leftIcon}
39
+ onIconClick={onLeftIconClick}
40
+ />
41
+ ),
42
+ endAdornment: rightIcon && (
43
+ <TextFieldIcon
44
+ sx={{ marginLeft: "4px", ...rightIconSx }}
45
+ icon={rightIcon}
46
+ onIconClick={onRightIconClick}
47
+ />
48
+ ),
49
+ },
50
+ ...InputProps,
51
+ }}
52
+ />
53
+ );
54
+ }
55
+ );
49
56
 
50
- const MultiTextField = ({
51
- size = "small",
52
- onChange,
53
- ...restProps
54
- }: MultiTextFieldProps) => {
55
- return <BaseTextField {...restProps} textFieldSize={size} multiline />;
56
- };
57
+ const MultiTextField = forwardRef<HTMLDivElement, MultiTextFieldProps>(
58
+ ({ size = "small", onChange, ...restProps }, ref) => {
59
+ return (
60
+ <BaseTextField {...restProps} ref={ref} textFieldSize={size} multiline />
61
+ );
62
+ }
63
+ );
57
64
 
58
- const TextField = (props: TextFieldProps) => {
65
+ const TextField = forwardRef<HTMLDivElement, TextFieldProps>((props, ref) => {
59
66
  const {
60
67
  rows,
61
68
  size,
@@ -67,14 +74,15 @@ const TextField = (props: TextFieldProps) => {
67
74
  return multiline ? (
68
75
  <MultiTextField
69
76
  {...restProps}
77
+ ref={ref}
70
78
  maxRows={Infinity}
71
79
  size={size}
72
80
  variant={variant}
73
81
  rows={rows}
74
82
  />
75
83
  ) : (
76
- <SingleTextField {...restProps} size={size} variant={variant} />
84
+ <SingleTextField {...restProps} ref={ref} size={size} variant={variant} />
77
85
  );
78
- };
86
+ });
79
87
 
80
88
  export default TextField;
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import MuiTypography from "@mui/material/Typography";
3
+
4
+ import type { TypographyProps } from "@mui/material/Typography";
5
+ import type { TypographyPropsVariantOverridesType } from "../../foundation/Typography";
6
+
7
+ declare module "@mui/material/Typography" {
8
+ interface TypographyPropsVariantOverrides
9
+ extends TypographyPropsVariantOverridesType {}
10
+ }
11
+
12
+ const Typography = <C extends React.ElementType>(
13
+ props: TypographyProps<C, { component?: C }>
14
+ ) => {
15
+ return <MuiTypography {...props} />;
16
+ };
17
+
18
+ export default Typography;
@@ -1,9 +1 @@
1
- import Typography from "@mui/material/Typography";
2
- import type { TypographyPropsVariantOverridesType } from "../../foundation/Typography";
3
-
4
- declare module "@mui/material/Typography" {
5
- interface TypographyPropsVariantOverrides
6
- extends TypographyPropsVariantOverridesType {}
7
- }
8
-
9
- export default Typography;
1
+ export { default } from "./Typography";
@@ -19,6 +19,7 @@ declare module "@mui/material/styles/createPalette" {
19
19
  lunit_teal: BaseColor;
20
20
  magenta: BaseColor;
21
21
  orange: BaseColor;
22
+ purple: BaseColor;
22
23
  red: BaseColor;
23
24
  yellow: BaseColor;
24
25
  };
@@ -34,6 +35,7 @@ declare module "@mui/material/styles/createPalette" {
34
35
  lunit_teal: BaseColor;
35
36
  magenta: BaseColor;
36
37
  orange: BaseColor;
38
+ purple: BaseColor;
37
39
  red: BaseColor;
38
40
  yellow: BaseColor;
39
41
  };
@@ -12,10 +12,8 @@ import Bell from "@lunit/design-system-icons/Bell";
12
12
  import Button from "@/components/Button";
13
13
 
14
14
  import type { StoryObj, StoryFn, Meta } from "@storybook/react";
15
- import type { ButtonProps } from "@/components/Button/Button.types";
16
15
 
17
- type Size = Pick<ButtonProps, "size">;
18
- type SizeValues = Size[keyof Size];
16
+ type SizeValues = "small" | "medium" | "large";
19
17
  const sizeList: SizeValues[] = ["small", "medium", "large"];
20
18
 
21
19
  export default {
@@ -107,6 +107,9 @@ const MultiTemplate: StoryFn<typeof TextField> = (args) => (
107
107
  <TableCell sx={{ typography: "body2_14_medium", color: "inherit" }}>
108
108
  Focused
109
109
  </TableCell>
110
+ <TableCell sx={{ typography: "body2_14_medium", color: "inherit" }}>
111
+ Error Focused
112
+ </TableCell>
110
113
  <TableCell sx={{ typography: "body2_14_medium", color: "inherit" }}>
111
114
  Disabled
112
115
  </TableCell>
@@ -123,6 +126,9 @@ const MultiTemplate: StoryFn<typeof TextField> = (args) => (
123
126
  <TableCell>
124
127
  <TextField {...args} multiline focused />
125
128
  </TableCell>
129
+ <TableCell>
130
+ <TextField {...args} multiline error focused />
131
+ </TableCell>
126
132
  <TableCell>
127
133
  <TextField {...args} multiline disabled />
128
134
  </TableCell>
@@ -99,6 +99,9 @@ const SingleTemplate: StoryFn<typeof TextField> = (args) => (
99
99
  <TableCell sx={{ typography: "body2_14_medium", color: "inherit" }}>
100
100
  Focused
101
101
  </TableCell>
102
+ <TableCell sx={{ typography: "body2_14_medium", color: "inherit" }}>
103
+ Error Focused
104
+ </TableCell>
102
105
  <TableCell sx={{ typography: "body2_14_medium", color: "inherit" }}>
103
106
  Disabled
104
107
  </TableCell>
@@ -115,6 +118,9 @@ const SingleTemplate: StoryFn<typeof TextField> = (args) => (
115
118
  <TableCell>
116
119
  <TextField {...args} focused />
117
120
  </TableCell>
121
+ <TableCell>
122
+ <TextField {...args} error focused />
123
+ </TableCell>
118
124
  <TableCell>
119
125
  <TextField {...args} disabled />
120
126
  </TableCell>
@@ -137,6 +143,9 @@ const SingleWithIconTemplate: StoryFn<typeof TextField> = (args) => (
137
143
  <TableCell sx={{ typography: "body2_14_medium", color: "inherit" }}>
138
144
  focused
139
145
  </TableCell>
146
+ <TableCell sx={{ typography: "body2_14_medium", color: "inherit" }}>
147
+ Error focused
148
+ </TableCell>
140
149
  <TableCell sx={{ typography: "body2_14_medium", color: "inherit" }}>
141
150
  Disabled
142
151
  </TableCell>
@@ -156,6 +165,9 @@ const SingleWithIconTemplate: StoryFn<typeof TextField> = (args) => (
156
165
  <TableCell>
157
166
  <TextField {...args} focused leftIcon={<Bell />} />
158
167
  </TableCell>
168
+ <TableCell>
169
+ <TextField {...args} error focused leftIcon={<Bell />} />
170
+ </TableCell>
159
171
  <TableCell>
160
172
  <TextField {...args} disabled leftIcon={<Bell />} />
161
173
  </TableCell>
@@ -173,6 +185,9 @@ const SingleWithIconTemplate: StoryFn<typeof TextField> = (args) => (
173
185
  <TableCell>
174
186
  <TextField {...args} focused rightIcon={<Bell />} />
175
187
  </TableCell>
188
+ <TableCell>
189
+ <TextField {...args} error focused rightIcon={<Bell />} />
190
+ </TableCell>
176
191
  <TableCell>
177
192
  <TextField {...args} disabled rightIcon={<Bell />} />
178
193
  </TableCell>
@@ -195,6 +210,15 @@ const SingleWithIconTemplate: StoryFn<typeof TextField> = (args) => (
195
210
  rightIcon={<Bell />}
196
211
  />
197
212
  </TableCell>
213
+ <TableCell>
214
+ <TextField
215
+ {...args}
216
+ error
217
+ focused
218
+ leftIcon={<Bell />}
219
+ rightIcon={<Bell />}
220
+ />
221
+ </TableCell>
198
222
  <TableCell>
199
223
  <TextField
200
224
  {...args}