@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
@@ -5,6 +5,7 @@ declare const meta: {
5
5
  component: typeof Button;
6
6
  tags: string[];
7
7
  parameters: {
8
+ layout: string;
8
9
  docs: {
9
10
  description: {
10
11
  component: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Button.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDqB,CAAC;AAEhC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,QAAQ,EAAE,KA6BtB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAgCpB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KA+BnB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAcnB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAoBtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAoBlB,CAAC"}
1
+ {"version":3,"file":"Button.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDqB,CAAC;AAEhC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,QAAQ,EAAE,KA8BtB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAiCpB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAgCnB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAcnB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAoBtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAoBlB,CAAC"}
@@ -8,6 +8,7 @@ const meta = {
8
8
  component: Button_1.Button,
9
9
  tags: ["autodocs"],
10
10
  parameters: {
11
+ layout: "centered",
11
12
  docs: {
12
13
  description: {
13
14
  component: `
@@ -56,6 +57,7 @@ const meta = {
56
57
  exports.default = meta;
57
58
  exports.Variants = {
58
59
  parameters: {
60
+ layout: "centered",
59
61
  docs: {
60
62
  description: {
61
63
  story: `
@@ -74,6 +76,7 @@ exports.Variants = {
74
76
  };
75
77
  exports.Colors = {
76
78
  parameters: {
79
+ layout: "centered",
77
80
  docs: {
78
81
  description: {
79
82
  story: `
@@ -92,6 +95,7 @@ exports.Colors = {
92
95
  };
93
96
  exports.Sizes = {
94
97
  parameters: {
98
+ layout: "centered",
95
99
  docs: {
96
100
  description: {
97
101
  story: `
@@ -5,6 +5,7 @@ declare const meta: {
5
5
  component: typeof Checkbox;
6
6
  tags: string[];
7
7
  parameters: {
8
+ layout: string;
8
9
  docs: {
9
10
  description: {
10
11
  component: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAGrD,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;CAuBuB,CAAC;AAElC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAgBnC,eAAO,MAAM,UAAU,EAAE,KA8CxB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KA0CjC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KA2B1B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAqBnC,CAAC"}
1
+ {"version":3,"file":"Checkbox.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAGrD,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBuB,CAAC;AAElC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAgBnC,eAAO,MAAM,UAAU,EAAE,KA+CxB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KA2CjC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KA4B1B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAqBnC,CAAC"}
@@ -10,6 +10,7 @@ const meta = {
10
10
  component: Checkbox_1.Checkbox,
11
11
  tags: ["autodocs"],
12
12
  parameters: {
13
+ layout: "centered",
13
14
  docs: {
14
15
  description: {
15
16
  component: `
@@ -36,6 +37,7 @@ function CheckboxWithControlled(props) {
36
37
  }
37
38
  exports.Controlled = {
38
39
  parameters: {
40
+ layout: "centered",
39
41
  docs: {
40
42
  description: {
41
43
  story: `
@@ -83,6 +85,7 @@ function Controlled() {
83
85
  };
84
86
  exports.ControlledWithLabel = {
85
87
  parameters: {
88
+ layout: "centered",
86
89
  docs: {
87
90
  source: {
88
91
  code: `
@@ -126,6 +129,7 @@ function Controlled() {
126
129
  };
127
130
  exports.UnControlled = {
128
131
  parameters: {
132
+ layout: "centered",
129
133
  docs: {
130
134
  description: {
131
135
  story: `
@@ -5,6 +5,7 @@ declare const meta: {
5
5
  component: typeof Chip;
6
6
  tags: string[];
7
7
  parameters: {
8
+ layout: string;
8
9
  docs: {
9
10
  description: {
10
11
  component: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Chip.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Chip/Chip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCmB,CAAC;AAE9B,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,QAAQ,EAAE,KAqCtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAmBlB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAkBlB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAmBlB,CAAC"}
1
+ {"version":3,"file":"Chip.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Chip/Chip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCmB,CAAC;AAE9B,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,QAAQ,EAAE,KAsCtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAmBlB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAkBlB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAmBlB,CAAC"}
@@ -8,6 +8,7 @@ const meta = {
8
8
  component: Chip_1.Chip,
9
9
  tags: ["autodocs"],
10
10
  parameters: {
11
+ layout: "centered",
11
12
  docs: {
12
13
  description: {
13
14
  component: `
@@ -46,6 +47,7 @@ const meta = {
46
47
  exports.default = meta;
47
48
  exports.Variants = {
48
49
  parameters: {
50
+ layout: "centered",
49
51
  docs: {
50
52
  description: {
51
53
  story: `
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Chip/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Chip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { ComponentPropsWithRef } from "react";
2
+ import { VariantProps } from "class-variance-authority";
3
+ import { ChildrenProps } from "../../types/props";
4
+ import { FormControlLabel } from "./FormControlLabel";
5
+ import { FormControlValidation } from "./FormControlValidation";
6
+ type FormControlContextValue = {
7
+ id: string;
8
+ disabled?: boolean;
9
+ required?: boolean;
10
+ error?: boolean;
11
+ labelId: string;
12
+ validationId?: string;
13
+ };
14
+ export declare const useFormControl: () => FormControlContextValue;
15
+ declare const formControlVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
16
+ export type FormControlBaseProps = ComponentPropsWithRef<"div"> & ChildrenProps & VariantProps<typeof formControlVariants> & {
17
+ /**
18
+ * 입력 필드의 고유 ID
19
+ */
20
+ id?: string;
21
+ /**
22
+ * 필수 입력 여부
23
+ */
24
+ required?: boolean;
25
+ /**
26
+ * 비활성화 여부
27
+ */
28
+ disabled?: boolean;
29
+ /**
30
+ * 에러 상태 여부
31
+ */
32
+ error?: boolean;
33
+ };
34
+ /**
35
+ * `FormControl`: Input 컴포넌트에 Label, Validation 등을 제공하는 래퍼 컴포넌트입니다.
36
+ * @see [RDS Storybook: FormControl](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-formcontrol--docs)
37
+ * @example
38
+ * ```tsx
39
+ * <FormControl required error>
40
+ * <FormControl.Label>이메일</FormControl.Label>
41
+ * <Input type="email" placeholder="example@baree.net" />
42
+ * <FormControl.Validation>올바른 이메일 형식이 아닙니다</FormControl.Validation>
43
+ * </FormControl>
44
+ * ```
45
+ */
46
+ declare function FormControlBase({ id: idProp, required, disabled, error, className, children, ...props }: FormControlBaseProps): import("react/jsx-runtime").JSX.Element;
47
+ declare namespace FormControlBase {
48
+ var displayName: string;
49
+ }
50
+ export declare const FormControl: typeof FormControlBase & {
51
+ Label: typeof FormControlLabel;
52
+ Validation: typeof FormControlValidation;
53
+ };
54
+ export {};
55
+ //# sourceMappingURL=FormControl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormControl.d.ts","sourceRoot":"","sources":["../../../src/components/FormControl/FormControl.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EAQtB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAO,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,KAAK,uBAAuB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAIF,eAAO,MAAM,cAAc,+BAS1B,CAAC;AAEF,QAAA,MAAM,mBAAmB,oFAAwC,CAAC;AAElE,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAC7D,aAAa,GACb,YAAY,CAAC,OAAO,mBAAmB,CAAC,GAAG;IACzC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEJ;;;;;;;;;;;GAWG;AACH,iBAAS,eAAe,CAAC,EACvB,EAAE,EAAE,MAAM,EACV,QAAgB,EAChB,QAAgB,EAChB,KAAa,EACb,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,oBAAoB,2CAyDtB;kBAjEQ,eAAe;;;AAqExB,eAAO,MAAM,WAAW;;;CAGtB,CAAC"}
@@ -0,0 +1,79 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FormControl = exports.useFormControl = void 0;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const class_variance_authority_1 = require("class-variance-authority");
8
+ const style_1 = require("../../utils/style");
9
+ const TextInput_1 = require("../TextInput/TextInput");
10
+ const FormControlLabel_1 = require("./FormControlLabel");
11
+ const FormControlValidation_1 = require("./FormControlValidation");
12
+ const FormControlContext = (0, react_1.createContext)(null);
13
+ const useFormControl = () => {
14
+ const context = (0, react_1.use)(FormControlContext);
15
+ if (!context) {
16
+ throw new Error("FormControl compound components must be used within FormControl");
17
+ }
18
+ return context;
19
+ };
20
+ exports.useFormControl = useFormControl;
21
+ const formControlVariants = (0, class_variance_authority_1.cva)("ui:flex ui:flex-col ui:gap-1.5");
22
+ /**
23
+ * `FormControl`: Input 컴포넌트에 Label, Validation 등을 제공하는 래퍼 컴포넌트입니다.
24
+ * @see [RDS Storybook: FormControl](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-formcontrol--docs)
25
+ * @example
26
+ * ```tsx
27
+ * <FormControl required error>
28
+ * <FormControl.Label>이메일</FormControl.Label>
29
+ * <Input type="email" placeholder="example@baree.net" />
30
+ * <FormControl.Validation>올바른 이메일 형식이 아닙니다</FormControl.Validation>
31
+ * </FormControl>
32
+ * ```
33
+ */
34
+ function FormControlBase({ id: idProp, required = false, disabled = false, error = false, className, children, ...props }) {
35
+ const uniqId = (0, react_1.useId)();
36
+ const id = idProp || uniqId;
37
+ const labelId = `${id}-label`;
38
+ const validationId = `${id}-validation`;
39
+ let labelSlot = null;
40
+ let inputSlot = null;
41
+ let validationSlot = null;
42
+ const childArray = Array.isArray(children) ? children : [children];
43
+ childArray.forEach((child) => {
44
+ if (!(0, react_1.isValidElement)(child)) {
45
+ return;
46
+ }
47
+ switch (child.type) {
48
+ case FormControlLabel_1.FormControlLabel:
49
+ labelSlot = child;
50
+ break;
51
+ case TextInput_1.TextInput: {
52
+ const inputChild = child;
53
+ inputSlot = (0, react_1.cloneElement)(inputChild, {
54
+ id,
55
+ disabled: disabled || inputChild.props.disabled,
56
+ required: required || inputChild.props.required,
57
+ variant: error ? "error" : inputChild.props.variant,
58
+ });
59
+ break;
60
+ }
61
+ case FormControlValidation_1.FormControlValidation:
62
+ validationSlot = child;
63
+ break;
64
+ }
65
+ });
66
+ return ((0, jsx_runtime_1.jsx)(FormControlContext, { value: {
67
+ id,
68
+ disabled,
69
+ required,
70
+ error,
71
+ labelId,
72
+ validationId,
73
+ }, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, style_1.cn)(formControlVariants({ className })), ...props, children: [labelSlot, (0, jsx_runtime_1.jsxs)("div", { className: "ui:flex ui:flex-col ui:gap-1", children: [inputSlot, validationSlot] })] }) }));
74
+ }
75
+ FormControlBase.displayName = "FormControlBase";
76
+ exports.FormControl = Object.assign(FormControlBase, {
77
+ Label: FormControlLabel_1.FormControlLabel,
78
+ Validation: FormControlValidation_1.FormControlValidation,
79
+ });
@@ -0,0 +1,19 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { FormControlBaseProps } from "./FormControl";
3
+ declare const meta: Meta<FormControlBaseProps>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ export declare const Required: Story;
8
+ export declare const Disabled: Story;
9
+ export declare const WithError: Story;
10
+ /**
11
+ * 필수 입력이면서 에러 상태인 필드입니다.
12
+ */
13
+ export declare const RequiredWithError: Story;
14
+ /**
15
+ * 시각적으로 숨겨진 라벨입니다. 접근성은 유지됩니다.
16
+ */
17
+ export declare const VisuallyHiddenLabel: Story;
18
+ export declare const MultipleInputTypes: Story;
19
+ //# sourceMappingURL=FormControl.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormControl.stories.d.ts","sourceRoot":"","sources":["../../../src/components/FormControl/FormControl.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAe,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGlE,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,oBAAoB,CAwCC,CAAC;AAEvC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KASrB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAStB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAStB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAYvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAY/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,KASjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAwBhC,CAAC"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MultipleInputTypes = exports.VisuallyHiddenLabel = exports.RequiredWithError = exports.WithError = exports.Disabled = exports.Required = exports.Default = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const FormControl_1 = require("./FormControl");
6
+ const TextInput_1 = require("../TextInput");
7
+ const meta = {
8
+ title: "Components/FormControl",
9
+ component: FormControl_1.FormControl,
10
+ parameters: {
11
+ layout: "centered",
12
+ docs: {
13
+ description: {
14
+ component: `
15
+ 컴포넌트에 Label, Validation 등을 제공하는 래퍼 컴포넌트입니다.
16
+ `,
17
+ },
18
+ },
19
+ },
20
+ tags: ["autodocs"],
21
+ argTypes: {
22
+ required: {
23
+ control: "boolean",
24
+ options: ["true", "false"],
25
+ description: "필수 입력 여부",
26
+ },
27
+ disabled: {
28
+ control: "boolean",
29
+ options: ["true", "false"],
30
+ description: "비활성화 여부",
31
+ },
32
+ error: {
33
+ control: "boolean",
34
+ options: ["true", "false"],
35
+ description: "에러 상태 여부",
36
+ },
37
+ id: {
38
+ control: "text",
39
+ description: "입력 필드의 고유 ID",
40
+ },
41
+ children: {
42
+ table: {
43
+ disable: true,
44
+ },
45
+ },
46
+ },
47
+ };
48
+ exports.default = meta;
49
+ exports.Default = {
50
+ render: (props) => ((0, jsx_runtime_1.jsx)("div", { className: "ui:w-80", children: (0, jsx_runtime_1.jsxs)(FormControl_1.FormControl, { ...props, children: [(0, jsx_runtime_1.jsx)(FormControl_1.FormControl.Label, { children: "\uC774\uBA54\uC77C" }), (0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { type: "email", placeholder: "example@baree.net" })] }) })),
51
+ };
52
+ exports.Required = {
53
+ render: (props) => ((0, jsx_runtime_1.jsx)("div", { className: "ui:w-80", children: (0, jsx_runtime_1.jsxs)(FormControl_1.FormControl, { required: true, ...props, children: [(0, jsx_runtime_1.jsx)(FormControl_1.FormControl.Label, { children: "\uC774\uBA54\uC77C" }), (0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { type: "email", placeholder: "example@baree.net" })] }) })),
54
+ };
55
+ exports.Disabled = {
56
+ render: (props) => ((0, jsx_runtime_1.jsx)("div", { className: "ui:w-80", children: (0, jsx_runtime_1.jsxs)(FormControl_1.FormControl, { disabled: true, ...props, children: [(0, jsx_runtime_1.jsx)(FormControl_1.FormControl.Label, { children: "\uC774\uBA54\uC77C" }), (0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { type: "email", placeholder: "example@baree.net" })] }) })),
57
+ };
58
+ exports.WithError = {
59
+ render: (props) => ((0, jsx_runtime_1.jsx)("div", { className: "ui:w-80", children: (0, jsx_runtime_1.jsxs)(FormControl_1.FormControl, { error: true, ...props, children: [(0, jsx_runtime_1.jsx)(FormControl_1.FormControl.Label, { children: "\uC774\uBA54\uC77C" }), (0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { type: "email", placeholder: "example@baree.net" }), (0, jsx_runtime_1.jsx)(FormControl_1.FormControl.Validation, { children: "\uC62C\uBC14\uB978 \uC774\uBA54\uC77C \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4" })] }) })),
60
+ };
61
+ /**
62
+ * 필수 입력이면서 에러 상태인 필드입니다.
63
+ */
64
+ exports.RequiredWithError = {
65
+ render: (props) => ((0, jsx_runtime_1.jsx)("div", { className: "ui:w-80", children: (0, jsx_runtime_1.jsxs)(FormControl_1.FormControl, { required: true, error: true, ...props, children: [(0, jsx_runtime_1.jsx)(FormControl_1.FormControl.Label, { children: "\uBE44\uBC00\uBC88\uD638" }), (0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { type: "password", placeholder: "8\uC790 \uC774\uC0C1 \uC785\uB825" }), (0, jsx_runtime_1.jsx)(FormControl_1.FormControl.Validation, { children: "\uBE44\uBC00\uBC88\uD638\uB294 \uCD5C\uC18C 8\uC790 \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4" })] }) })),
66
+ };
67
+ /**
68
+ * 시각적으로 숨겨진 라벨입니다. 접근성은 유지됩니다.
69
+ */
70
+ exports.VisuallyHiddenLabel = {
71
+ render: (props) => ((0, jsx_runtime_1.jsx)("div", { className: "ui:w-80", children: (0, jsx_runtime_1.jsxs)(FormControl_1.FormControl, { ...props, children: [(0, jsx_runtime_1.jsx)(FormControl_1.FormControl.Label, { visuallyHidden: true, children: "\uAC80\uC0C9" }), (0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { type: "search", placeholder: "\uAC80\uC0C9\uC5B4\uB97C \uC785\uB825\uD558\uC138\uC694" })] }) })),
72
+ };
73
+ exports.MultipleInputTypes = {
74
+ render: (props) => ((0, jsx_runtime_1.jsxs)("div", { className: "ui:space-y-6 ui:w-80", children: [(0, jsx_runtime_1.jsxs)(FormControl_1.FormControl, { required: true, ...props, children: [(0, jsx_runtime_1.jsx)(FormControl_1.FormControl.Label, { children: "\uC774\uBA54\uC77C" }), (0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { type: "email", placeholder: "example@baree.net" })] }), (0, jsx_runtime_1.jsxs)(FormControl_1.FormControl, { required: true, ...props, children: [(0, jsx_runtime_1.jsx)(FormControl_1.FormControl.Label, { children: "\uBE44\uBC00\uBC88\uD638" }), (0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { type: "password", placeholder: "8\uC790 \uC774\uC0C1 \uC785\uB825" })] }), (0, jsx_runtime_1.jsxs)(FormControl_1.FormControl, { ...props, children: [(0, jsx_runtime_1.jsx)(FormControl_1.FormControl.Label, { children: "\uC804\uD654\uBC88\uD638" }), (0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { type: "tel", placeholder: "010-1234-5678" })] }), (0, jsx_runtime_1.jsxs)(FormControl_1.FormControl, { ...props, children: [(0, jsx_runtime_1.jsx)(FormControl_1.FormControl.Label, { children: "\uB0A0\uC9DC" }), (0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { type: "date" })] })] })),
75
+ };
@@ -0,0 +1,20 @@
1
+ import { ComponentPropsWithRef } from "react";
2
+ import { ChildrenProps } from "../../types/props";
3
+ import { VariantProps } from "class-variance-authority";
4
+ declare const labelVariants: (props?: ({
5
+ required?: boolean | null | undefined;
6
+ error?: boolean | null | undefined;
7
+ disabled?: boolean | null | undefined;
8
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
9
+ type FormControlLabelProps = ComponentPropsWithRef<"label"> & ChildrenProps & VariantProps<typeof labelVariants> & {
10
+ /**
11
+ * 시각적으로 숨김 처리 (접근성 유지)
12
+ */
13
+ visuallyHidden?: boolean;
14
+ };
15
+ export declare function FormControlLabel({ visuallyHidden, className, children, ...props }: FormControlLabelProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare namespace FormControlLabel {
17
+ var displayName: string;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=FormControlLabel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormControlLabel.d.ts","sourceRoot":"","sources":["../../../src/components/FormControl/FormControlLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAO,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAI7D,QAAA,MAAM,aAAa;;;;8EAmBjB,CAAC;AAEH,KAAK,qBAAqB,GAAG,qBAAqB,CAAC,OAAO,CAAC,GACzD,aAAa,GACb,YAAY,CAAC,OAAO,aAAa,CAAC,GAAG;IACnC;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEJ,wBAAgB,gBAAgB,CAAC,EAC/B,cAAc,EACd,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,qBAAqB,2CAgBvB;yBArBe,gBAAgB"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormControlLabel = FormControlLabel;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const class_variance_authority_1 = require("class-variance-authority");
6
+ const FormControl_1 = require("./FormControl");
7
+ const style_1 = require("../../utils/style");
8
+ const labelVariants = (0, class_variance_authority_1.cva)("ui:text-body6", {
9
+ variants: {
10
+ required: {
11
+ true: "after:ui:content-['*'] after:ui:ml-0.5 after:ui:text-red-500",
12
+ },
13
+ error: {
14
+ true: "ui:text-red-500",
15
+ false: "",
16
+ },
17
+ disabled: {
18
+ true: "ui:text-gray-300",
19
+ false: "",
20
+ },
21
+ },
22
+ defaultVariants: {
23
+ required: false,
24
+ disabled: false,
25
+ error: false,
26
+ },
27
+ });
28
+ function FormControlLabel({ visuallyHidden, className, children, ...props }) {
29
+ const { id, required, disabled, labelId, error } = (0, FormControl_1.useFormControl)();
30
+ return ((0, jsx_runtime_1.jsx)("label", { id: labelId, htmlFor: id, className: (0, style_1.cn)(labelVariants({ required, disabled, error, className }), visuallyHidden && "ui:sr-only"), ...props, children: children }));
31
+ }
32
+ FormControlLabel.displayName = "FormControl.Label";
@@ -0,0 +1,13 @@
1
+ import { ComponentPropsWithRef } from "react";
2
+ import { ChildrenProps } from "../../types/props";
3
+ import { VariantProps } from "class-variance-authority";
4
+ declare const validationVariants: (props?: ({
5
+ variant?: "error" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ type FormControlValidationProps = ComponentPropsWithRef<"div"> & ChildrenProps & VariantProps<typeof validationVariants>;
8
+ export declare function FormControlValidation({ variant, className, children, ...props }: FormControlValidationProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare namespace FormControlValidation {
10
+ var displayName: string;
11
+ }
12
+ export {};
13
+ //# sourceMappingURL=FormControlValidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormControlValidation.d.ts","sourceRoot":"","sources":["../../../src/components/FormControl/FormControlValidation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAO,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAI7D,QAAA,MAAM,kBAAkB;;8EAYvB,CAAC;AACF,KAAK,0BAA0B,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAC5D,aAAa,GACb,YAAY,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE1C,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,0BAA0B,2CAa5B;yBAlBe,qBAAqB"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormControlValidation = FormControlValidation;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const class_variance_authority_1 = require("class-variance-authority");
6
+ const FormControl_1 = require("./FormControl");
7
+ const style_1 = require("../../utils/style");
8
+ const validationVariants = (0, class_variance_authority_1.cva)("ui:text-caption1 ui:flex ui:items-center ui:gap-1", {
9
+ variants: {
10
+ variant: {
11
+ error: "ui:text-red-500",
12
+ },
13
+ },
14
+ defaultVariants: {
15
+ variant: "error",
16
+ },
17
+ });
18
+ function FormControlValidation({ variant, className, children, ...props }) {
19
+ const { validationId } = (0, FormControl_1.useFormControl)();
20
+ return ((0, jsx_runtime_1.jsx)("div", { id: validationId, role: "alert", className: (0, style_1.cn)(validationVariants({ variant, className })), ...props, children: children }));
21
+ }
22
+ FormControlValidation.displayName = "FormControl.Validation";
@@ -0,0 +1,2 @@
1
+ export { FormControl } from "./FormControl";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FormControl/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormControl = void 0;
4
+ var FormControl_1 = require("./FormControl");
5
+ Object.defineProperty(exports, "FormControl", { enumerable: true, get: function () { return FormControl_1.FormControl; } });
@@ -12,6 +12,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
12
12
  * ```
13
13
  */
14
14
  function IconPlaceLine({ className, width = 24, height = 24, ...props }) {
15
- return ((0, jsx_runtime_1.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: width, height: height, fill: "none", viewBox: "0 0 24 24", className: className, ...props, children: [(0, jsx_runtime_1.jsx)("path", { fill: "currentColor", fillRule: "evenodd", d: "M12.194 7.144a3.78 3.78 0 0 1 3.586 3.776l-.005.194A3.78 3.78 0 0 1 12 14.7l-.194-.005a3.78 3.78 0 0 1-3.581-3.581l-.005-.194A3.78 3.78 0 0 1 12 7.14zM12 8.64a2.28 2.28 0 1 0 0 4.562 2.28 2.28 0 0 0 0-4.562", clipRule: "evenodd" }), (0, jsx_runtime_1.jsx)("path", { fill: "currentColor", fillRule: "evenodd", d: "M12 1.65a9 9 0 0 1 9 9c0 6.768-8.524 11.697-9 11.7-.474-.002-9.001-4.931-9.001-11.7 0-4.971 4.03-9 9.001-9m0 1.5a7.5 7.5 0 0 0-7.501 7.5c0 2.76 1.763 5.315 3.856 7.3a21 21 0 0 0 2.863 2.27c.304.2.57.358.781.477.21-.12.477-.276.782-.477a21 21 0 0 0 2.863-2.27c2.093-1.985 3.856-4.54 3.856-7.3a7.5 7.5 0 0 0-7.5-7.5", clipRule: "evenodd" })] }));
15
+ return ((0, jsx_runtime_1.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: width, height: height, fill: "none", viewBox: "0 0 24 24", className: className, ...props, children: [(0, jsx_runtime_1.jsx)("path", { fill: "currentColor", fillRule: "evenodd", d: "M12.194 7.144a3.78 3.78 0 0 1 3.586 3.776l-.005.194A3.78 3.78 0 0 1 12 14.7l-.194-.005a3.78 3.78 0 0 1-3.581-3.581l-.005-.194A3.78 3.78 0 0 1 12 7.14zM12 8.64a2.28 2.28 0 1 0 0 4.562 2.28 2.28 0 0 0 0-4.562", clipRule: "evenodd" }), (0, jsx_runtime_1.jsx)("path", { fill: "currentColor", fillRule: "evenodd", d: "M12 1.649a9 9 0 0 1 9 9c0 6.769-8.524 11.698-9 11.701-.474-.002-9.001-4.932-9.001-11.701 0-4.97 4.03-9 9.001-9m0 1.5a7.5 7.5 0 0 0-7.501 7.5c0 2.761 1.763 5.316 3.856 7.302a21 21 0 0 0 2.863 2.27c.304.2.57.357.781.476.21-.12.477-.277.782-.477a21 21 0 0 0 2.863-2.27c2.093-1.985 3.856-4.54 3.856-7.301a7.5 7.5 0 0 0-7.5-7.5", clipRule: "evenodd" })] }));
16
16
  }
17
17
  exports.default = IconPlaceLine;
@@ -9,25 +9,25 @@ export type RadioProps = ComponentPropsWithRef<"input"> & ChildrenProps & Varian
9
9
  onCheckedChange?: (checked: boolean) => void;
10
10
  };
11
11
  /**
12
- * `Radio`: 그룹 내 단일 선택만 가능한 요소로, 상호 배타적 옵션을 나타냅니다.
12
+ * `Radio`: 그룹 내 단일 선택만 가능한 요소로, 상호 배타적 옵션을 나타냅니다. 그룹과 함께 사용하려면, `RadioGroup`을 사용하세요.
13
13
  * @see [RDS Storybook: Radio](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-radio--docs)
14
+ * @see [RDS Storybook: RadioGroup](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-radiogroup--docs)
14
15
  * @example
15
16
  * ```tsx
16
- * const [selected, setSelected] = useState(false)
17
+ * const [checked, setChecked] = useState(false)
17
18
  *
18
19
  * // Controlled
19
20
  * <Radio
20
- * checked={selected}
21
- * onCheckedChange={setSelected}
21
+ * checked={checked}
22
+ * onCheckedChange={() => setChecked(!checked)}
22
23
  * >
23
24
  * Option
24
25
  * </Radio>
25
- *
26
26
  * // Uncontrolled
27
27
  * <Radio defaultChecked>Option</Radio>
28
28
  * ```
29
29
  */
30
- export declare function Radio({ id: idProp, checked: controlledChecked, defaultChecked, disabled, className, onCheckedChange, children, ...props }: RadioProps): import("react/jsx-runtime").JSX.Element;
30
+ export declare function Radio({ id: idProp, checked: controlledChecked, defaultChecked, disabled, className, onCheckedChange, children, value, ...props }: RadioProps): import("react/jsx-runtime").JSX.Element;
31
31
  export declare namespace Radio {
32
32
  var displayName: string;
33
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../../src/components/Radio/Radio.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAmB,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAoB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEjE,MAAM,MAAM,UAAU,GAAG,qBAAqB,CAAC,OAAO,CAAC,GACrD,aAAa,GACb,YAAY,CAAC,OAAO,aAAa,CAAC,GAAG;IACnC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEJ;;;;;;;;;;;;;;;;;;GAkBG;AAEH,wBAAgB,KAAK,CAAC,EACpB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,iBAAiB,EAC1B,cAAc,EACd,QAAQ,EACR,SAAS,EACT,eAAe,EACf,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,UAAU,2CAwDZ;yBAjEe,KAAK"}
1
+ {"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../../src/components/Radio/Radio.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAmB,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAoB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGjE,MAAM,MAAM,UAAU,GAAG,qBAAqB,CAAC,OAAO,CAAC,GACrD,aAAa,GACb,YAAY,CAAC,OAAO,aAAa,CAAC,GAAG;IACnC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEJ;;;;;;;;;;;;;;;;;;GAkBG;AAEH,wBAAgB,KAAK,CAAC,EACpB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,iBAAiB,EAC1B,cAAc,EACd,QAAQ,EACR,SAAS,EACT,eAAe,EACf,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACT,EAAE,UAAU,2CA8EZ;yBAxFe,KAAK"}
@@ -6,39 +6,57 @@ const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_1 = require("react");
7
7
  const style_1 = require("../../utils/style");
8
8
  const Radio_styles_1 = require("./Radio.styles");
9
+ const RadioGroup_1 = require("../RadioGroup/RadioGroup");
9
10
  /**
10
- * `Radio`: 그룹 내 단일 선택만 가능한 요소로, 상호 배타적 옵션을 나타냅니다.
11
+ * `Radio`: 그룹 내 단일 선택만 가능한 요소로, 상호 배타적 옵션을 나타냅니다. 그룹과 함께 사용하려면, `RadioGroup`을 사용하세요.
11
12
  * @see [RDS Storybook: Radio](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-radio--docs)
13
+ * @see [RDS Storybook: RadioGroup](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-radiogroup--docs)
12
14
  * @example
13
15
  * ```tsx
14
- * const [selected, setSelected] = useState(false)
16
+ * const [checked, setChecked] = useState(false)
15
17
  *
16
18
  * // Controlled
17
19
  * <Radio
18
- * checked={selected}
19
- * onCheckedChange={setSelected}
20
+ * checked={checked}
21
+ * onCheckedChange={() => setChecked(!checked)}
20
22
  * >
21
23
  * Option
22
24
  * </Radio>
23
- *
24
25
  * // Uncontrolled
25
26
  * <Radio defaultChecked>Option</Radio>
26
27
  * ```
27
28
  */
28
- function Radio({ id: idProp, checked: controlledChecked, defaultChecked, disabled, className, onCheckedChange, children, ...props }) {
29
+ function Radio({ id: idProp, checked: controlledChecked, defaultChecked, disabled, className, onCheckedChange, children, value, ...props }) {
29
30
  const [uncontrolledChecked, setUncontrolledChecked] = (0, react_1.useState)(defaultChecked);
31
+ const group = (0, RadioGroup_1.useRadioGroup)();
30
32
  const uniqId = (0, react_1.useId)();
31
33
  const id = idProp || uniqId;
32
- const isChecked = controlledChecked ?? uncontrolledChecked;
34
+ const isInGroup = !!group;
35
+ const isDisabled = group?.disabled || disabled;
36
+ const isChecked = isInGroup
37
+ ? group.value === value
38
+ : (controlledChecked ?? uncontrolledChecked);
33
39
  const handleChange = () => {
34
- if (disabled)
40
+ if (disabled) {
41
+ return;
42
+ }
43
+ if (isInGroup) {
44
+ group.setValue(value);
35
45
  return;
46
+ }
36
47
  if (controlledChecked === undefined) {
37
48
  setUncontrolledChecked(true);
38
49
  }
39
50
  onCheckedChange?.(true);
40
51
  };
41
- return ((0, jsx_runtime_1.jsxs)("label", { htmlFor: id, className: (0, style_1.cn)("ui:flex ui:items-center ui:gap-2 ui:cursor-pointer ui:select-none", disabled && "ui:cursor-default ui:pointer-events-none"), children: [(0, jsx_runtime_1.jsx)("input", { id: id, type: "radio", checked: isChecked, defaultChecked: defaultChecked, disabled: disabled || undefined, onChange: handleChange, className: "ui:sr-only", ...props }), (0, jsx_runtime_1.jsx)("div", { className: (0, Radio_styles_1.radioVariants)({ checked: isChecked, disabled, className }), children: (0, jsx_runtime_1.jsx)("div", { className: (0, Radio_styles_1.radioDotVariants)({ checked: isChecked, disabled }) }) }), children && ((0, jsx_runtime_1.jsx)("span", { className: (0, style_1.cn)("ui:text-body5", disabled
52
+ return ((0, jsx_runtime_1.jsxs)("label", { htmlFor: id, className: (0, style_1.cn)("ui:flex ui:items-center ui:gap-2 ui:cursor-pointer", isDisabled && "ui:cursor-default ui:pointer-events-none"), children: [(0, jsx_runtime_1.jsx)("input", { id: id, type: "radio", name: group?.name, value: value, checked: isChecked, defaultChecked: defaultChecked, disabled: isDisabled, onChange: handleChange, className: "ui:sr-only", ...props }), (0, jsx_runtime_1.jsx)("div", { className: (0, Radio_styles_1.radioVariants)({
53
+ checked: isChecked,
54
+ disabled: isDisabled,
55
+ className,
56
+ }), children: (0, jsx_runtime_1.jsx)("div", { className: (0, Radio_styles_1.radioDotVariants)({
57
+ checked: isChecked,
58
+ disabled: isDisabled,
59
+ }) }) }), children && ((0, jsx_runtime_1.jsx)("span", { className: (0, style_1.cn)("ui:text-body5", isDisabled
42
60
  ? "ui:text-gray-400 ui:pointer-events-none"
43
61
  : "ui:cursor-pointer"), children: children }))] }));
44
62
  }
@@ -5,6 +5,7 @@ declare const meta: {
5
5
  component: typeof Radio;
6
6
  tags: string[];
7
7
  parameters: {
8
+ layout: string;
8
9
  docs: {
9
10
  description: {
10
11
  component: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Radio/Radio.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAc,MAAM,SAAS,CAAC;AAG5C,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;CAqBoB,CAAC;AAE/B,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,UAAU,EAAE,KA+BxB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KA2BjC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAmB1B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KASnC,CAAC"}
1
+ {"version":3,"file":"Radio.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Radio/Radio.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;CAsBoB,CAAC;AAE/B,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,UAAU,EAAE,KAgCxB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KA4BjC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAoB1B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KASnC,CAAC"}