@reitwagen/design-components 0.4.0 → 0.6.1

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 (62) hide show
  1. package/dist/components/Button/Button.stories.d.ts +1 -0
  2. package/dist/components/Button/Button.stories.d.ts.map +1 -1
  3. package/dist/components/Button/Button.stories.js +4 -0
  4. package/dist/components/Checkbox/Checkbox.stories.d.ts +1 -0
  5. package/dist/components/Checkbox/Checkbox.stories.d.ts.map +1 -1
  6. package/dist/components/Checkbox/Checkbox.stories.js +4 -0
  7. package/dist/components/Chip/Chip.stories.d.ts +1 -0
  8. package/dist/components/Chip/Chip.stories.d.ts.map +1 -1
  9. package/dist/components/Chip/Chip.stories.js +2 -0
  10. package/dist/components/Chip/index.d.ts.map +1 -1
  11. package/dist/components/FormControl/FormControl.d.ts +55 -0
  12. package/dist/components/FormControl/FormControl.d.ts.map +1 -0
  13. package/dist/components/FormControl/FormControl.js +79 -0
  14. package/dist/components/FormControl/FormControl.stories.d.ts +19 -0
  15. package/dist/components/FormControl/FormControl.stories.d.ts.map +1 -0
  16. package/dist/components/FormControl/FormControl.stories.js +75 -0
  17. package/dist/components/FormControl/FormControlLabel.d.ts +20 -0
  18. package/dist/components/FormControl/FormControlLabel.d.ts.map +1 -0
  19. package/dist/components/FormControl/FormControlLabel.js +32 -0
  20. package/dist/components/FormControl/FormControlValidation.d.ts +13 -0
  21. package/dist/components/FormControl/FormControlValidation.d.ts.map +1 -0
  22. package/dist/components/FormControl/FormControlValidation.js +22 -0
  23. package/dist/components/FormControl/index.d.ts +2 -0
  24. package/dist/components/FormControl/index.d.ts.map +1 -0
  25. package/dist/components/FormControl/index.js +5 -0
  26. package/dist/components/Icons/IconPlaceLine.js +1 -1
  27. package/dist/components/Radio/Radio.d.ts +6 -6
  28. package/dist/components/Radio/Radio.d.ts.map +1 -1
  29. package/dist/components/Radio/Radio.js +27 -9
  30. package/dist/components/Radio/Radio.stories.d.ts +1 -0
  31. package/dist/components/Radio/Radio.stories.d.ts.map +1 -1
  32. package/dist/components/Radio/Radio.stories.js +6 -2
  33. package/dist/components/Radio/index.d.ts.map +1 -1
  34. package/dist/components/RadioGroup/RadioGroup.d.ts +55 -0
  35. package/dist/components/RadioGroup/RadioGroup.d.ts.map +1 -0
  36. package/dist/components/RadioGroup/RadioGroup.js +45 -0
  37. package/dist/components/RadioGroup/RadioGroup.stories.d.ts +40 -0
  38. package/dist/components/RadioGroup/RadioGroup.stories.d.ts.map +1 -0
  39. package/dist/components/RadioGroup/RadioGroup.stories.js +103 -0
  40. package/dist/components/RadioGroup/index.d.ts +2 -0
  41. package/dist/components/RadioGroup/index.d.ts.map +1 -0
  42. package/dist/components/RadioGroup/index.js +5 -0
  43. package/dist/components/TextInput/TextInput.d.ts +36 -0
  44. package/dist/components/TextInput/TextInput.d.ts.map +1 -0
  45. package/dist/components/TextInput/TextInput.js +53 -0
  46. package/dist/components/TextInput/TextInput.stories.d.ts +41 -0
  47. package/dist/components/TextInput/TextInput.stories.d.ts.map +1 -0
  48. package/dist/components/TextInput/TextInput.stories.js +112 -0
  49. package/dist/components/TextInput/TextInput.styles.d.ts +5 -0
  50. package/dist/components/TextInput/TextInput.styles.d.ts.map +1 -0
  51. package/dist/components/TextInput/TextInput.styles.js +20 -0
  52. package/dist/components/TextInput/index.d.ts +2 -0
  53. package/dist/components/TextInput/index.d.ts.map +1 -0
  54. package/dist/components/TextInput/index.js +5 -0
  55. package/dist/components/Toggle/index.d.ts.map +1 -1
  56. package/dist/index.css +90 -0
  57. package/dist/index.d.ts +3 -0
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +3 -0
  60. package/dist/types/props.d.ts +2 -2
  61. package/dist/types/props.d.ts.map +1 -1
  62. package/package.json +3 -3
@@ -8,10 +8,11 @@ const meta = {
8
8
  component: Radio_1.Radio,
9
9
  tags: ["autodocs"],
10
10
  parameters: {
11
+ layout: "centered",
11
12
  docs: {
12
13
  description: {
13
14
  component: `
14
- 그룹 내 단일 선택만 가능한 요소로, 상호 배타적 옵션을 나타냅니다. 라벨과 함께 사용하거나 단독으로 사용할 수 있습니다.
15
+ 그룹 내 단일 선택만 가능한 요소로, 상호 배타적 옵션을 나타냅니다. 라벨과 함께 사용하거나 단독으로 사용할 수 있습니다. 둘 이상의 Radio를 활용할 때는, \`<RadioGroup>\` 컴포넌트를 활용하는 것을 권장합니다.
15
16
  `,
16
17
  },
17
18
  },
@@ -28,6 +29,7 @@ const meta = {
28
29
  exports.default = meta;
29
30
  exports.Controlled = {
30
31
  parameters: {
32
+ layout: "centered",
31
33
  docs: {
32
34
  description: {
33
35
  story: `
@@ -60,6 +62,7 @@ function Controlled() {
60
62
  };
61
63
  exports.ControlledWithLabel = {
62
64
  parameters: {
65
+ layout: "centered",
63
66
  docs: {
64
67
  source: {
65
68
  code: `
@@ -88,12 +91,13 @@ function ControlledWithLabel() {
88
91
  };
89
92
  exports.UnControlled = {
90
93
  parameters: {
94
+ layout: "centered",
91
95
  docs: {
92
96
  description: {
93
97
  story: `
94
98
  ### 상태를 내부에서 관리하는 방식
95
99
 
96
- Radio상태를 내부에서 자동으로 관리하려면 <code>defaultChecked</code> 속성을 사용하세요. 이 속성은 Checkbox이 처음 화면에 표시될 때 선택 상태를 정해주고, 그 후에는 컴포넌트가 스스로 상태를 관리해요. 상태 변화를 추적하지 않아도 될 때 유용해요.
100
+ Radio상태를 내부에서 자동으로 관리하려면 <code>defaultChecked</code> 속성을 사용하세요. 이 속성은 Checkbox이 처음 화면에 표시될 때 선택 상태를 정해주고, 그 후에는 컴포넌트가 스스로 상태를 관리해요. 상태 변화를 추적하지 않아도 될 때 유용해요.
97
101
  `,
98
102
  },
99
103
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Radio/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Radio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { ComponentPropsWithoutRef } from "react";
2
+ interface RadioGroupContextValue {
3
+ name: string;
4
+ disabled?: boolean;
5
+ value?: string;
6
+ setValue: (value: string) => void;
7
+ }
8
+ export declare const useRadioGroup: () => RadioGroupContextValue | null;
9
+ export interface RadioGroupProps extends ComponentPropsWithoutRef<"div"> {
10
+ /**
11
+ * `Radio` 컴포넌트 목록
12
+ */
13
+ children: React.ReactNode;
14
+ /**
15
+ * 선택된 value (Controlled)
16
+ */
17
+ value?: string;
18
+ /**
19
+ * 초기 선택 값 (Uncontrolled)
20
+ */
21
+ defaultValue?: string;
22
+ /**
23
+ * 선택 값이 변경될 때 호출되는 이벤트 핸들러
24
+ */
25
+ onValueChange?: (value: string) => void;
26
+ /**
27
+ * 그룹 전체 비활성화 여부
28
+ */
29
+ disabled?: boolean;
30
+ }
31
+ /**
32
+ * `RadioGroup`: 하나의 값을 선택할 수 있는 라디오 옵션 그룹입니다.
33
+ * 내부의 `Radio` 컴포넌트는 자동으로 그룹 상태를 공유하며, 그룹 단위로 value 제어 및 disabled 상태를 관리할 수 있습니다.
34
+ *
35
+ * @see [RDS Storybook: RadioGroup](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-radiogroup--docs)
36
+ * @example
37
+ * ```tsx
38
+ * // Controlled
39
+ * const [value, setValue] = useState("a");
40
+ *
41
+ * <RadioGroup value={value} onValueChange={setValue}>
42
+ * <Radio value="a">Option A</Radio>
43
+ * <Radio value="b">Option B</Radio>
44
+ * </RadioGroup>
45
+ *
46
+ * // Uncontrolled
47
+ * <RadioGroup defaultValue="b">
48
+ * <Radio value="a">Option A</Radio>
49
+ * <Radio value="b">Option B</Radio>
50
+ * </RadioGroup>
51
+ * ```
52
+ */
53
+ export declare function RadioGroup({ children, value: controlledValue, defaultValue, onValueChange, disabled, className, ...props }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
54
+ export {};
55
+ //# sourceMappingURL=RadioGroup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../src/components/RadioGroup/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EAKzB,MAAM,OAAO,CAAC;AAGf,UAAU,sBAAsB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAID,eAAO,MAAM,aAAa,qCAA+B,CAAC;AAE1D,MAAM,WAAW,eAAgB,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IACtE;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAExC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,KAAK,EAAE,eAAe,EACtB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,eAAe,2CAwBjB"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useRadioGroup = void 0;
4
+ exports.RadioGroup = RadioGroup;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const style_1 = require("../../utils/style");
8
+ const RadioGroupContext = (0, react_1.createContext)(null);
9
+ const useRadioGroup = () => (0, react_1.use)(RadioGroupContext);
10
+ exports.useRadioGroup = useRadioGroup;
11
+ /**
12
+ * `RadioGroup`: 하나의 값을 선택할 수 있는 라디오 옵션 그룹입니다.
13
+ * 내부의 `Radio` 컴포넌트는 자동으로 그룹 상태를 공유하며, 그룹 단위로 value 제어 및 disabled 상태를 관리할 수 있습니다.
14
+ *
15
+ * @see [RDS Storybook: RadioGroup](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-radiogroup--docs)
16
+ * @example
17
+ * ```tsx
18
+ * // Controlled
19
+ * const [value, setValue] = useState("a");
20
+ *
21
+ * <RadioGroup value={value} onValueChange={setValue}>
22
+ * <Radio value="a">Option A</Radio>
23
+ * <Radio value="b">Option B</Radio>
24
+ * </RadioGroup>
25
+ *
26
+ * // Uncontrolled
27
+ * <RadioGroup defaultValue="b">
28
+ * <Radio value="a">Option A</Radio>
29
+ * <Radio value="b">Option B</Radio>
30
+ * </RadioGroup>
31
+ * ```
32
+ */
33
+ function RadioGroup({ children, value: controlledValue, defaultValue, onValueChange, disabled, className, ...props }) {
34
+ const [uncontrolledValue, setUncontrolledValue] = (0, react_1.useState)(defaultValue);
35
+ const name = (0, react_1.useId)();
36
+ const isControlled = controlledValue !== undefined;
37
+ const currentValue = isControlled ? controlledValue : uncontrolledValue;
38
+ const setValue = (newValue) => {
39
+ if (!isControlled) {
40
+ setUncontrolledValue(newValue);
41
+ }
42
+ onValueChange?.(newValue);
43
+ };
44
+ return ((0, jsx_runtime_1.jsx)(RadioGroupContext, { value: { name, value: currentValue, disabled, setValue }, children: (0, jsx_runtime_1.jsx)("div", { className: (0, style_1.cn)("ui:flex ui:flex-col", className), ...props, children: children }) }));
45
+ }
@@ -0,0 +1,40 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { RadioGroup } from "./RadioGroup";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof RadioGroup;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ docs: {
10
+ description: {
11
+ component: string;
12
+ };
13
+ };
14
+ };
15
+ argTypes: {
16
+ value: {
17
+ control: "text";
18
+ };
19
+ defaultValue: {
20
+ control: "text";
21
+ };
22
+ disabled: {
23
+ control: "boolean";
24
+ };
25
+ className: {
26
+ control: "text";
27
+ description: string;
28
+ };
29
+ children: {
30
+ table: {
31
+ disable: true;
32
+ };
33
+ };
34
+ };
35
+ };
36
+ export default meta;
37
+ type Story = StoryObj<typeof meta>;
38
+ export declare const Controlled: Story;
39
+ export declare const Uncontrolled: Story;
40
+ //# sourceMappingURL=RadioGroup.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioGroup.stories.d.ts","sourceRoot":"","sources":["../../../src/components/RadioGroup/RadioGroup.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAG3D,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCyB,CAAC;AAEpC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAcnC,eAAO,MAAM,UAAU,EAAE,KAmCxB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KA0B1B,CAAC"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Uncontrolled = exports.Controlled = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const RadioGroup_1 = require("./RadioGroup");
7
+ const Radio_1 = require("../Radio/Radio");
8
+ const meta = {
9
+ title: "Components/RadioGroup",
10
+ component: RadioGroup_1.RadioGroup,
11
+ tags: ["autodocs"],
12
+ parameters: {
13
+ layout: "centered",
14
+ docs: {
15
+ description: {
16
+ component: `
17
+ 여러 개의 Radio를 묶어 단일 선택을 강제하는 컴포넌트입니다.
18
+ \`value\`를 넘기면 제어 모드로, \`defaultValue\`만 넘기면 비제어 모드로 동작합니다.
19
+ `,
20
+ },
21
+ },
22
+ },
23
+ argTypes: {
24
+ value: {
25
+ control: "text",
26
+ },
27
+ defaultValue: {
28
+ control: "text",
29
+ },
30
+ disabled: { control: "boolean" },
31
+ className: {
32
+ control: "text",
33
+ description: "ui:gap-3",
34
+ },
35
+ children: {
36
+ table: {
37
+ disable: true,
38
+ },
39
+ },
40
+ },
41
+ };
42
+ exports.default = meta;
43
+ function ControlledRadioGroup(props) {
44
+ const [value, setValue] = (0, react_1.useState)("b");
45
+ return ((0, jsx_runtime_1.jsxs)(RadioGroup_1.RadioGroup, { ...props, value: value, onValueChange: setValue, children: [(0, jsx_runtime_1.jsx)(Radio_1.Radio, { value: "a", children: "A" }), (0, jsx_runtime_1.jsx)(Radio_1.Radio, { value: "b", children: "B" }), (0, jsx_runtime_1.jsx)(Radio_1.Radio, { value: "c", children: "C" })] }));
46
+ }
47
+ exports.Controlled = {
48
+ parameters: {
49
+ layout: "centered",
50
+ docs: {
51
+ description: {
52
+ story: `
53
+ ### 상태를 외부에서 관리하는 방식
54
+
55
+ RadioGroup의 상태를 외부에서 관리하려면 \`value\`와 \`onValueChange\` 속성을 함께 사용하세요.
56
+ `,
57
+ },
58
+ source: {
59
+ code: `
60
+ function Controlled() {
61
+ const [value, setValue] = useState("b");
62
+
63
+ return (
64
+ <RadioGroup value={value} onValueChange={setValue} className="gap-3">
65
+ <Radio value="a">A</Radio>
66
+ <Radio value="b">B</Radio>
67
+ <Radio value="c">C</Radio>
68
+ </RadioGroup>
69
+ );
70
+ }
71
+ `.trim(),
72
+ },
73
+ },
74
+ },
75
+ render: (props) => (0, jsx_runtime_1.jsx)(ControlledRadioGroup, { ...props }),
76
+ args: {
77
+ value: "b",
78
+ children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}),
79
+ disabled: false,
80
+ className: "ui:gap-3",
81
+ },
82
+ };
83
+ exports.Uncontrolled = {
84
+ parameters: {
85
+ layout: "centered",
86
+ docs: {
87
+ description: {
88
+ story: `
89
+ ### 상태를 내부에서 관리하는 방식
90
+
91
+ RadioGroup의 상태를 내부에서 자동으로 관리하려면 \`defaultValue\` 속성을 사용하세요.
92
+ `,
93
+ },
94
+ },
95
+ },
96
+ render: (props) => ((0, jsx_runtime_1.jsxs)(RadioGroup_1.RadioGroup, { ...props, defaultValue: "b", children: [(0, jsx_runtime_1.jsx)(Radio_1.Radio, { value: "a", children: "A" }), (0, jsx_runtime_1.jsx)(Radio_1.Radio, { value: "b", children: "B" }), (0, jsx_runtime_1.jsx)(Radio_1.Radio, { value: "c", children: "C" })] })),
97
+ args: {
98
+ defaultValue: "b",
99
+ children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}),
100
+ disabled: false,
101
+ className: "ui:gap-3",
102
+ },
103
+ };
@@ -0,0 +1,2 @@
1
+ export { RadioGroup } from "./RadioGroup";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/RadioGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RadioGroup = void 0;
4
+ var RadioGroup_1 = require("./RadioGroup");
5
+ Object.defineProperty(exports, "RadioGroup", { enumerable: true, get: function () { return RadioGroup_1.RadioGroup; } });
@@ -0,0 +1,36 @@
1
+ import { ComponentPropsWithRef } from "react";
2
+ import { VariantProps } from "class-variance-authority";
3
+ import { inputVariants } from "./TextInput.styles";
4
+ export type TextInputProps = ComponentPropsWithRef<"input"> & VariantProps<typeof inputVariants> & {
5
+ /**
6
+ * 클리어 버튼이 표시되는 조건
7
+ * - 'never': 표시 안 함 (기본값)
8
+ * - 'while-editing': 입력값이 있을 때만 표시
9
+ * - 'always': 항상 표시
10
+ */
11
+ clearButtonMode?: "always" | "while-editing" | "never";
12
+ };
13
+ /**
14
+ * `TextInput`: 텍스트 입력을 위한 기본 컴포넌트입니다. FormControl과 함께 사용하면 label, validation 등의 기능을 자동으로 제공받습니다.
15
+ * @see [RDS Storybook: TextInput](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-textinput--docs)
16
+ * @see [RDS Storybook: FormControl](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-formcontrol--docs)
17
+ * @example
18
+ * ```tsx
19
+ * // 독립적으로 사용
20
+ * <TextInput
21
+ * placeholder="이메일을 입력하세요"
22
+ * onChange={(e) => setEmail(e.target.value)}
23
+ * />
24
+ *
25
+ * // FormControl과 함께 사용
26
+ * <FormControl required>
27
+ * <FormControl.Label>이메일</FormControl.Label>
28
+ * <TextInput type="email" />
29
+ * </FormControl>
30
+ * ```
31
+ */
32
+ export declare function TextInput({ variant, disabled, className, clearButtonMode, value: controlledValue, onChange, ...props }: TextInputProps): import("react/jsx-runtime").JSX.Element;
33
+ export declare namespace TextInput {
34
+ var displayName: string;
35
+ }
36
+ //# sourceMappingURL=TextInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../src/components/TextInput/TextInput.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAe,qBAAqB,EAAY,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,OAAO,CAAC,GACzD,YAAY,CAAC,OAAO,aAAa,CAAC,GAAG;IACnC;;;;;OAKG;IACH,eAAe,CAAC,EAAE,QAAQ,GAAG,eAAe,GAAG,OAAO,CAAC;CACxD,CAAC;AAEJ;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,EACxB,OAAO,EACP,QAAQ,EACR,SAAS,EACT,eAAyB,EACzB,KAAK,EAAE,eAAe,EACtB,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,2CAqDhB;yBA7De,SAAS"}
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.TextInput = TextInput;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const style_1 = require("../../utils/style");
8
+ const TextInput_styles_1 = require("./TextInput.styles");
9
+ const Icons_1 = require("../Icons");
10
+ /**
11
+ * `TextInput`: 텍스트 입력을 위한 기본 컴포넌트입니다. FormControl과 함께 사용하면 label, validation 등의 기능을 자동으로 제공받습니다.
12
+ * @see [RDS Storybook: TextInput](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-textinput--docs)
13
+ * @see [RDS Storybook: FormControl](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-formcontrol--docs)
14
+ * @example
15
+ * ```tsx
16
+ * // 독립적으로 사용
17
+ * <TextInput
18
+ * placeholder="이메일을 입력하세요"
19
+ * onChange={(e) => setEmail(e.target.value)}
20
+ * />
21
+ *
22
+ * // FormControl과 함께 사용
23
+ * <FormControl required>
24
+ * <FormControl.Label>이메일</FormControl.Label>
25
+ * <TextInput type="email" />
26
+ * </FormControl>
27
+ * ```
28
+ */
29
+ function TextInput({ variant, disabled, className, clearButtonMode = "never", value: controlledValue, onChange, ...props }) {
30
+ const [internalValue, setInternalValue] = (0, react_1.useState)("");
31
+ const isControlled = controlledValue !== undefined;
32
+ const value = isControlled ? controlledValue : internalValue;
33
+ const isShowClearButton = clearButtonMode === "always" ||
34
+ (clearButtonMode === "while-editing" && String(value).length > 0);
35
+ const handleChange = (e) => {
36
+ if (!isControlled) {
37
+ setInternalValue(e.target.value);
38
+ }
39
+ onChange?.(e);
40
+ };
41
+ const handleClear = () => {
42
+ const syntheticEvent = {
43
+ target: { value: "" },
44
+ currentTarget: { value: "" },
45
+ };
46
+ if (!isControlled) {
47
+ setInternalValue("");
48
+ }
49
+ onChange?.(syntheticEvent);
50
+ };
51
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "ui:relative ui:flex-1 ui:flex ui:items-center", children: [(0, jsx_runtime_1.jsx)("input", { disabled: disabled, value: value, onChange: handleChange, className: (0, style_1.cn)((0, TextInput_styles_1.inputVariants)({ variant, disabled, className }), isShowClearButton && "ui:pr-[52px]"), ...props }), isShowClearButton && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: handleClear, disabled: disabled, className: "ui:absolute ui:right-4 ui:top-1/2 ui:-translate-y-1/2 ui:cursor-pointer disabled:ui:cursor-not-allowed disabled:ui:opacity-50", "aria-label": "Clear input", children: (0, jsx_runtime_1.jsx)(Icons_1.IconCloseCircle, { className: "ui:text-gray-400" }) }))] }));
52
+ }
53
+ TextInput.displayName = "TextInput";
@@ -0,0 +1,41 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { TextInput } from "./TextInput";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof TextInput;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ docs: {
10
+ description: {
11
+ component: string;
12
+ };
13
+ };
14
+ };
15
+ argTypes: {
16
+ variant: {
17
+ control: {
18
+ type: "radio";
19
+ };
20
+ options: string[];
21
+ };
22
+ disabled: {
23
+ control: {
24
+ type: "boolean";
25
+ };
26
+ options: string[];
27
+ };
28
+ clearButtonMode: {
29
+ control: {
30
+ type: "radio";
31
+ };
32
+ options: string[];
33
+ };
34
+ };
35
+ };
36
+ export default meta;
37
+ type Story = StoryObj<typeof meta>;
38
+ export declare const Default: Story;
39
+ export declare const Error: Story;
40
+ export declare const DefaultWithClearButton: Story;
41
+ //# sourceMappingURL=TextInput.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextInput.stories.d.ts","sourceRoot":"","sources":["../../../src/components/TextInput/TextInput.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCwB,CAAC;AAEnC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KA2BrB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KA2BnB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,KA+BpC,CAAC"}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultWithClearButton = exports.Error = exports.Default = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const TextInput_1 = require("./TextInput");
6
+ const meta = {
7
+ title: "Components/TextInput",
8
+ component: TextInput_1.TextInput,
9
+ tags: ["autodocs"],
10
+ parameters: {
11
+ layout: "centered",
12
+ docs: {
13
+ description: {
14
+ component: `
15
+ TextInput은 한 줄의 텍스트 값을 설정하는데 사용됩니다.
16
+
17
+ ## <b>TextInput guide</b>
18
+
19
+ 입력 필드는 텍스트의 길이를 고려하여 적절한 크기로 제공하며, 플레이스홀더를 레이블이나 도움말의 대체 수단으로 사용하지 않도록 합니다.
20
+ `,
21
+ },
22
+ },
23
+ },
24
+ argTypes: {
25
+ variant: {
26
+ control: { type: "radio" },
27
+ options: ["default"],
28
+ },
29
+ disabled: {
30
+ control: { type: "boolean" },
31
+ options: ["true", "false"],
32
+ },
33
+ clearButtonMode: {
34
+ control: { type: "radio" },
35
+ options: ["never", "always", "while-editing"],
36
+ },
37
+ },
38
+ };
39
+ exports.default = meta;
40
+ exports.Default = {
41
+ parameters: {
42
+ layout: "centered",
43
+ docs: {
44
+ description: {
45
+ story: `
46
+
47
+ `,
48
+ },
49
+ },
50
+ },
51
+ render: (props) => ((0, jsx_runtime_1.jsxs)("div", { className: "ui:flex ui:gap-2", children: [(0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { ...props }), props.children] })),
52
+ args: {
53
+ placeholder: "placeholder",
54
+ variant: "default",
55
+ },
56
+ argTypes: {
57
+ disabled: {
58
+ control: { type: "boolean" },
59
+ options: ["true", "false"],
60
+ },
61
+ },
62
+ };
63
+ exports.Error = {
64
+ parameters: {
65
+ layout: "centered",
66
+ docs: {
67
+ description: {
68
+ story: `
69
+
70
+ `,
71
+ },
72
+ },
73
+ },
74
+ render: (props) => ((0, jsx_runtime_1.jsxs)("div", { className: "ui:flex ui:gap-2", children: [(0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { ...props, variant: "error" }), props.children] })),
75
+ args: {
76
+ placeholder: "placeholder",
77
+ variant: "error",
78
+ },
79
+ argTypes: {
80
+ disabled: {
81
+ control: { type: "boolean" },
82
+ options: ["true", "false"],
83
+ },
84
+ },
85
+ };
86
+ exports.DefaultWithClearButton = {
87
+ parameters: {
88
+ layout: "centered",
89
+ docs: {
90
+ description: {
91
+ story: `
92
+
93
+ `,
94
+ },
95
+ },
96
+ },
97
+ render: (props) => ((0, jsx_runtime_1.jsxs)("div", { className: "ui:flex ui:gap-2", children: [(0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { clearButtonMode: "while-editing", ...props }), props.children] })),
98
+ args: {
99
+ clearButtonMode: "while-editing",
100
+ placeholder: "placeholder",
101
+ },
102
+ argTypes: {
103
+ disabled: {
104
+ control: { type: "boolean" },
105
+ options: ["true", "false"],
106
+ },
107
+ clearButtonMode: {
108
+ control: { type: "radio" },
109
+ options: ["never", "always", "while-editing"],
110
+ },
111
+ },
112
+ };
@@ -0,0 +1,5 @@
1
+ export declare const inputVariants: (props?: ({
2
+ variant?: "default" | "error" | null | undefined;
3
+ disabled?: boolean | null | undefined;
4
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
5
+ //# sourceMappingURL=TextInput.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/TextInput/TextInput.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;;;8EAmBzB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inputVariants = void 0;
4
+ const class_variance_authority_1 = require("class-variance-authority");
5
+ exports.inputVariants = (0, class_variance_authority_1.cva)("ui:h-[50px] ui:bg-white ui:px-4 ui:rounded-2xl ui:w-full ui:border ui:text-body4 ui:transition-colors ui:outline-none", {
6
+ variants: {
7
+ variant: {
8
+ default: "ui:border-gray-100 ui:text-gray-800 ui:placeholder:text-body4 ui:placeholder:text-gray-500 ui:focus:bg-gray-50 ui:focus:border-gray-200",
9
+ error: "ui:border-red-200 ui:bg-red-50",
10
+ },
11
+ disabled: {
12
+ true: "ui:cursor-not-allowed ui:bg-gray-50 ui:border-gray-100 ui:text-gray-500 ui:placeholder:text-300",
13
+ false: "",
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ variant: "default",
18
+ disabled: false,
19
+ },
20
+ });
@@ -0,0 +1,2 @@
1
+ export { TextInput } from "./TextInput";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TextInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextInput = void 0;
4
+ var TextInput_1 = require("./TextInput");
5
+ Object.defineProperty(exports, "TextInput", { enumerable: true, get: function () { return TextInput_1.TextInput; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Toggle/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Toggle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}