@reitwagen/design-components 0.6.0 → 0.6.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.
- package/dist/components/FormControl/FormControl.d.ts.map +1 -1
- package/dist/components/FormControl/FormControl.js +2 -2
- package/dist/components/FormControl/FormControl.stories.js +9 -9
- package/dist/components/TextInput/TextInput.d.ts +48 -0
- package/dist/components/TextInput/TextInput.d.ts.map +1 -0
- package/dist/components/TextInput/TextInput.js +98 -0
- package/dist/components/{Input/Input.stories.d.ts → TextInput/TextInput.stories.d.ts} +16 -3
- package/dist/components/TextInput/TextInput.stories.d.ts.map +1 -0
- package/dist/components/TextInput/TextInput.stories.js +136 -0
- package/dist/components/{Input/Input.styles.d.ts → TextInput/TextInput.styles.d.ts} +1 -1
- package/dist/components/TextInput/TextInput.styles.d.ts.map +1 -0
- package/dist/components/{Input/Input.styles.js → TextInput/TextInput.styles.js} +1 -1
- package/dist/components/TextInput/index.d.ts +2 -0
- package/dist/components/TextInput/index.d.ts.map +1 -0
- package/dist/components/TextInput/index.js +5 -0
- package/dist/index.css +20 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/components/Input/Input.d.ts +0 -28
- package/dist/components/Input/Input.d.ts.map +0 -1
- package/dist/components/Input/Input.js +0 -30
- package/dist/components/Input/Input.stories.d.ts.map +0 -1
- package/dist/components/Input/Input.stories.js +0 -81
- package/dist/components/Input/Input.styles.d.ts.map +0 -1
- package/dist/components/Input/index.d.ts +0 -2
- package/dist/components/Input/index.d.ts.map +0 -1
- package/dist/components/Input/index.js +0 -5
|
@@ -1 +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;
|
|
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"}
|
|
@@ -6,7 +6,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const class_variance_authority_1 = require("class-variance-authority");
|
|
8
8
|
const style_1 = require("../../utils/style");
|
|
9
|
-
const
|
|
9
|
+
const TextInput_1 = require("../TextInput/TextInput");
|
|
10
10
|
const FormControlLabel_1 = require("./FormControlLabel");
|
|
11
11
|
const FormControlValidation_1 = require("./FormControlValidation");
|
|
12
12
|
const FormControlContext = (0, react_1.createContext)(null);
|
|
@@ -48,7 +48,7 @@ function FormControlBase({ id: idProp, required = false, disabled = false, error
|
|
|
48
48
|
case FormControlLabel_1.FormControlLabel:
|
|
49
49
|
labelSlot = child;
|
|
50
50
|
break;
|
|
51
|
-
case
|
|
51
|
+
case TextInput_1.TextInput: {
|
|
52
52
|
const inputChild = child;
|
|
53
53
|
inputSlot = (0, react_1.cloneElement)(inputChild, {
|
|
54
54
|
id,
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MultipleInputTypes = exports.VisuallyHiddenLabel = exports.RequiredWithError = exports.WithError = exports.Disabled = exports.Required = exports.Default = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const FormControl_1 = require("./FormControl");
|
|
6
|
-
const
|
|
6
|
+
const TextInput_1 = require("../TextInput");
|
|
7
7
|
const meta = {
|
|
8
8
|
title: "Components/FormControl",
|
|
9
9
|
component: FormControl_1.FormControl,
|
|
@@ -12,7 +12,7 @@ const meta = {
|
|
|
12
12
|
docs: {
|
|
13
13
|
description: {
|
|
14
14
|
component: `
|
|
15
|
-
|
|
15
|
+
컴포넌트에 Label, Validation 등을 제공하는 래퍼 컴포넌트입니다.
|
|
16
16
|
`,
|
|
17
17
|
},
|
|
18
18
|
},
|
|
@@ -47,29 +47,29 @@ Input 컴포넌트에 Label, Validation 등을 제공하는 래퍼 컴포넌트
|
|
|
47
47
|
};
|
|
48
48
|
exports.default = meta;
|
|
49
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)(
|
|
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
51
|
};
|
|
52
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)(
|
|
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
54
|
};
|
|
55
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)(
|
|
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
57
|
};
|
|
58
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)(
|
|
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
60
|
};
|
|
61
61
|
/**
|
|
62
62
|
* 필수 입력이면서 에러 상태인 필드입니다.
|
|
63
63
|
*/
|
|
64
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)(
|
|
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
66
|
};
|
|
67
67
|
/**
|
|
68
68
|
* 시각적으로 숨겨진 라벨입니다. 접근성은 유지됩니다.
|
|
69
69
|
*/
|
|
70
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)(
|
|
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
72
|
};
|
|
73
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)(
|
|
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
75
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
* 입력값의 단위 (예: "km", "원", "%")
|
|
14
|
+
* 입력 필드 오른쪽에 표시됩니다.
|
|
15
|
+
*/
|
|
16
|
+
unit?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* `TextInput`: 텍스트 입력을 위한 기본 컴포넌트입니다. FormControl과 함께 사용하면 label, validation 등의 기능을 자동으로 제공받습니다.
|
|
20
|
+
* @see [RDS Storybook: TextInput](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-textinput--docs)
|
|
21
|
+
* @see [RDS Storybook: FormControl](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-formcontrol--docs)
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* // 독립적으로 사용
|
|
25
|
+
* <TextInput
|
|
26
|
+
* placeholder="이메일을 입력하세요"
|
|
27
|
+
* onChange={(e) => setEmail(e.target.value)}
|
|
28
|
+
* />
|
|
29
|
+
*
|
|
30
|
+
* // FormControl과 함께 사용
|
|
31
|
+
* <FormControl required>
|
|
32
|
+
* <FormControl.Label>이메일</FormControl.Label>
|
|
33
|
+
* <TextInput type="email" />
|
|
34
|
+
* </FormControl>
|
|
35
|
+
*
|
|
36
|
+
* // 단위와 함께 사용
|
|
37
|
+
* <TextInput
|
|
38
|
+
* type="number"
|
|
39
|
+
* unit="km"
|
|
40
|
+
* placeholder="거리를 입력하세요"
|
|
41
|
+
* />
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function TextInput({ variant, disabled, className, clearButtonMode, unit, value: controlledValue, onChange, ...props }: TextInputProps): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export declare namespace TextInput {
|
|
46
|
+
var displayName: string;
|
|
47
|
+
}
|
|
48
|
+
//# 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,EAEL,qBAAqB,EAKtB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQnD,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;IACvD;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,SAAS,CAAC,EACxB,OAAO,EACP,QAAQ,EACR,SAAS,EACT,eAAiC,EACjC,IAAI,EACJ,KAAK,EAAE,eAAe,EACtB,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,2CA6GhB;yBAtHe,SAAS"}
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
const SPACING = {
|
|
11
|
+
GAP_BETWEEN_ELEMENTS: 12,
|
|
12
|
+
RIGHT_PADDING: 16,
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* `TextInput`: 텍스트 입력을 위한 기본 컴포넌트입니다. FormControl과 함께 사용하면 label, validation 등의 기능을 자동으로 제공받습니다.
|
|
16
|
+
* @see [RDS Storybook: TextInput](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-textinput--docs)
|
|
17
|
+
* @see [RDS Storybook: FormControl](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-formcontrol--docs)
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* // 독립적으로 사용
|
|
21
|
+
* <TextInput
|
|
22
|
+
* placeholder="이메일을 입력하세요"
|
|
23
|
+
* onChange={(e) => setEmail(e.target.value)}
|
|
24
|
+
* />
|
|
25
|
+
*
|
|
26
|
+
* // FormControl과 함께 사용
|
|
27
|
+
* <FormControl required>
|
|
28
|
+
* <FormControl.Label>이메일</FormControl.Label>
|
|
29
|
+
* <TextInput type="email" />
|
|
30
|
+
* </FormControl>
|
|
31
|
+
*
|
|
32
|
+
* // 단위와 함께 사용
|
|
33
|
+
* <TextInput
|
|
34
|
+
* type="number"
|
|
35
|
+
* unit="km"
|
|
36
|
+
* placeholder="거리를 입력하세요"
|
|
37
|
+
* />
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
function TextInput({ variant, disabled, className, clearButtonMode = "while-editing", unit, value: controlledValue, onChange, ...props }) {
|
|
41
|
+
const [internalValue, setInternalValue] = (0, react_1.useState)("");
|
|
42
|
+
const [isFocused, setIsFocused] = (0, react_1.useState)(false);
|
|
43
|
+
const [rightContentWidth, setRightContentWidth] = (0, react_1.useState)(0);
|
|
44
|
+
const unitRef = (0, react_1.useRef)(null);
|
|
45
|
+
const clearButtonRef = (0, react_1.useRef)(null);
|
|
46
|
+
const isControlled = controlledValue !== undefined;
|
|
47
|
+
const value = isControlled ? controlledValue : internalValue;
|
|
48
|
+
const isShowClearButton = clearButtonMode === "always" ||
|
|
49
|
+
(clearButtonMode === "while-editing" &&
|
|
50
|
+
String(value).length > 0 &&
|
|
51
|
+
isFocused);
|
|
52
|
+
const handleFocus = (e) => {
|
|
53
|
+
setIsFocused(true);
|
|
54
|
+
props.onFocus?.(e);
|
|
55
|
+
};
|
|
56
|
+
const handleBlur = (e) => {
|
|
57
|
+
setIsFocused(false);
|
|
58
|
+
props.onBlur?.(e);
|
|
59
|
+
};
|
|
60
|
+
const handleChange = (e) => {
|
|
61
|
+
if (!isControlled) {
|
|
62
|
+
setInternalValue(e.target.value);
|
|
63
|
+
}
|
|
64
|
+
onChange?.(e);
|
|
65
|
+
};
|
|
66
|
+
const handleClear = () => {
|
|
67
|
+
const syntheticEvent = {
|
|
68
|
+
target: { value: "" },
|
|
69
|
+
currentTarget: { value: "" },
|
|
70
|
+
};
|
|
71
|
+
if (!isControlled) {
|
|
72
|
+
setInternalValue("");
|
|
73
|
+
}
|
|
74
|
+
onChange?.(syntheticEvent);
|
|
75
|
+
};
|
|
76
|
+
(0, react_1.useEffect)(() => {
|
|
77
|
+
let totalWidth = 0;
|
|
78
|
+
if (unit && unitRef.current) {
|
|
79
|
+
totalWidth += unitRef.current.offsetWidth;
|
|
80
|
+
}
|
|
81
|
+
if (isShowClearButton && clearButtonRef.current) {
|
|
82
|
+
if (totalWidth > 0) {
|
|
83
|
+
totalWidth += SPACING.GAP_BETWEEN_ELEMENTS;
|
|
84
|
+
}
|
|
85
|
+
totalWidth += clearButtonRef.current.offsetWidth;
|
|
86
|
+
}
|
|
87
|
+
if (totalWidth > 0) {
|
|
88
|
+
totalWidth += SPACING.RIGHT_PADDING;
|
|
89
|
+
}
|
|
90
|
+
setRightContentWidth(totalWidth);
|
|
91
|
+
}, [unit, isShowClearButton]);
|
|
92
|
+
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, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange, style: {
|
|
93
|
+
paddingRight: rightContentWidth > 0
|
|
94
|
+
? `${rightContentWidth + SPACING.GAP_BETWEEN_ELEMENTS}px`
|
|
95
|
+
: undefined,
|
|
96
|
+
}, className: (0, style_1.cn)((0, TextInput_styles_1.inputVariants)({ variant, disabled, className })), ...props }), (0, jsx_runtime_1.jsxs)("div", { className: "ui:absolute ui:right-4 ui:top-1/2 ui:-translate-y-1/2 ui:flex ui:items-center ui:gap-3", children: [unit && ((0, jsx_runtime_1.jsx)("span", { ref: unitRef, className: "ui:text-gray-500 ui:text-body4 ui:select-none ui:pointer-events-none", children: unit })), isShowClearButton && ((0, jsx_runtime_1.jsx)("button", { ref: clearButtonRef, type: "button", onClick: handleClear, disabled: disabled, onMouseDown: (e) => e.preventDefault(), className: "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" }) }))] })] }));
|
|
97
|
+
}
|
|
98
|
+
TextInput.displayName = "TextInput";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StoryObj } from "@storybook/react";
|
|
2
|
-
import {
|
|
2
|
+
import { TextInput } from "./TextInput";
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: typeof
|
|
5
|
+
component: typeof TextInput;
|
|
6
6
|
tags: string[];
|
|
7
7
|
parameters: {
|
|
8
8
|
layout: string;
|
|
@@ -25,10 +25,23 @@ declare const meta: {
|
|
|
25
25
|
};
|
|
26
26
|
options: string[];
|
|
27
27
|
};
|
|
28
|
+
clearButtonMode: {
|
|
29
|
+
control: {
|
|
30
|
+
type: "radio";
|
|
31
|
+
};
|
|
32
|
+
options: string[];
|
|
33
|
+
};
|
|
34
|
+
unit: {
|
|
35
|
+
control: {
|
|
36
|
+
type: "text";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
28
39
|
};
|
|
29
40
|
};
|
|
30
41
|
export default meta;
|
|
31
42
|
type Story = StoryObj<typeof meta>;
|
|
32
43
|
export declare const Default: Story;
|
|
33
44
|
export declare const Error: Story;
|
|
34
|
-
|
|
45
|
+
export declare const Unit: Story;
|
|
46
|
+
export declare const DefaultWithClearButton: Story;
|
|
47
|
+
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCwB,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,IAAI,EAAE,KAyBlB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,KA+BpC,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultWithClearButton = exports.Unit = 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
|
+
unit: {
|
|
38
|
+
control: { type: "text" },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
exports.default = meta;
|
|
43
|
+
exports.Default = {
|
|
44
|
+
parameters: {
|
|
45
|
+
layout: "centered",
|
|
46
|
+
docs: {
|
|
47
|
+
description: {
|
|
48
|
+
story: `
|
|
49
|
+
|
|
50
|
+
`,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
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] })),
|
|
55
|
+
args: {
|
|
56
|
+
placeholder: "placeholder",
|
|
57
|
+
variant: "default",
|
|
58
|
+
},
|
|
59
|
+
argTypes: {
|
|
60
|
+
disabled: {
|
|
61
|
+
control: { type: "boolean" },
|
|
62
|
+
options: ["true", "false"],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
exports.Error = {
|
|
67
|
+
parameters: {
|
|
68
|
+
layout: "centered",
|
|
69
|
+
docs: {
|
|
70
|
+
description: {
|
|
71
|
+
story: `
|
|
72
|
+
|
|
73
|
+
`,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
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] })),
|
|
78
|
+
args: {
|
|
79
|
+
placeholder: "placeholder",
|
|
80
|
+
variant: "error",
|
|
81
|
+
},
|
|
82
|
+
argTypes: {
|
|
83
|
+
disabled: {
|
|
84
|
+
control: { type: "boolean" },
|
|
85
|
+
options: ["true", "false"],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
exports.Unit = {
|
|
90
|
+
parameters: {
|
|
91
|
+
layout: "centered",
|
|
92
|
+
docs: {
|
|
93
|
+
description: {
|
|
94
|
+
story: ``,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
render: (props) => ((0, jsx_runtime_1.jsxs)("div", { className: "ui:flex ui:gap-2", children: [(0, jsx_runtime_1.jsx)(TextInput_1.TextInput, { ...props, unit: "km" }), props.children] })),
|
|
99
|
+
args: {
|
|
100
|
+
placeholder: "주행거리를 입력하세요",
|
|
101
|
+
variant: "default",
|
|
102
|
+
},
|
|
103
|
+
argTypes: {
|
|
104
|
+
disabled: {
|
|
105
|
+
control: { type: "boolean" },
|
|
106
|
+
options: ["true", "false"],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
exports.DefaultWithClearButton = {
|
|
111
|
+
parameters: {
|
|
112
|
+
layout: "centered",
|
|
113
|
+
docs: {
|
|
114
|
+
description: {
|
|
115
|
+
story: `
|
|
116
|
+
|
|
117
|
+
`,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
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] })),
|
|
122
|
+
args: {
|
|
123
|
+
clearButtonMode: "while-editing",
|
|
124
|
+
placeholder: "placeholder",
|
|
125
|
+
},
|
|
126
|
+
argTypes: {
|
|
127
|
+
disabled: {
|
|
128
|
+
control: { type: "boolean" },
|
|
129
|
+
options: ["true", "false"],
|
|
130
|
+
},
|
|
131
|
+
clearButtonMode: {
|
|
132
|
+
control: { type: "radio" },
|
|
133
|
+
options: ["never", "always", "while-editing"],
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
};
|
|
@@ -2,4 +2,4 @@ export declare const inputVariants: (props?: ({
|
|
|
2
2
|
variant?: "default" | "error" | null | undefined;
|
|
3
3
|
disabled?: boolean | null | undefined;
|
|
4
4
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
5
|
-
//# sourceMappingURL=
|
|
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"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.inputVariants = void 0;
|
|
4
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-
|
|
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
6
|
variants: {
|
|
7
7
|
variant: {
|
|
8
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",
|
|
@@ -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; } });
|
package/dist/index.css
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
--ui-color-gray-900: #04041b;
|
|
30
30
|
--ui-color-white: #ffffff;
|
|
31
31
|
--ui-spacing: 0.25rem;
|
|
32
|
+
--ui-radius-2xl: 1rem;
|
|
32
33
|
--ui-default-transition-duration: 150ms;
|
|
33
34
|
--ui-default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
34
35
|
--ui-default-font-family: var(--ui-font-sans);
|
|
@@ -282,6 +283,18 @@
|
|
|
282
283
|
white-space: nowrap;
|
|
283
284
|
border-width: 0;
|
|
284
285
|
}
|
|
286
|
+
.ui\:absolute {
|
|
287
|
+
position: absolute;
|
|
288
|
+
}
|
|
289
|
+
.ui\:relative {
|
|
290
|
+
position: relative;
|
|
291
|
+
}
|
|
292
|
+
.ui\:top-1\/2 {
|
|
293
|
+
top: calc(1/2 * 100%);
|
|
294
|
+
}
|
|
295
|
+
.ui\:right-4 {
|
|
296
|
+
right: calc(var(--ui-spacing) * 4);
|
|
297
|
+
}
|
|
285
298
|
.ui\:my-3 {
|
|
286
299
|
margin-block: calc(var(--ui-spacing) * 3);
|
|
287
300
|
}
|
|
@@ -374,6 +387,10 @@
|
|
|
374
387
|
--tw-translate-x: calc(var(--ui-spacing) * 6);
|
|
375
388
|
translate: var(--tw-translate-x) var(--tw-translate-y);
|
|
376
389
|
}
|
|
390
|
+
.ui\:-translate-y-1\/2 {
|
|
391
|
+
--tw-translate-y: calc(calc(1/2 * 100%) * -1);
|
|
392
|
+
translate: var(--tw-translate-x) var(--tw-translate-y);
|
|
393
|
+
}
|
|
377
394
|
.ui\:cursor-default {
|
|
378
395
|
cursor: default;
|
|
379
396
|
}
|
|
@@ -423,6 +440,9 @@
|
|
|
423
440
|
margin-block-end: calc(calc(var(--ui-spacing) * 6) * calc(1 - var(--tw-space-y-reverse)));
|
|
424
441
|
}
|
|
425
442
|
}
|
|
443
|
+
.ui\:rounded-2xl {
|
|
444
|
+
border-radius: var(--ui-radius-2xl);
|
|
445
|
+
}
|
|
426
446
|
.ui\:rounded-\[8px\] {
|
|
427
447
|
border-radius: 8px;
|
|
428
448
|
}
|
|
@@ -435,9 +455,6 @@
|
|
|
435
455
|
.ui\:rounded-\[14px\] {
|
|
436
456
|
border-radius: 14px;
|
|
437
457
|
}
|
|
438
|
-
.ui\:rounded-\[16px\] {
|
|
439
|
-
border-radius: 16px;
|
|
440
|
-
}
|
|
441
458
|
.ui\:rounded-full {
|
|
442
459
|
border-radius: calc(infinity * 1px);
|
|
443
460
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from "./components/Toggle";
|
|
|
4
4
|
export * from "./components/Checkbox";
|
|
5
5
|
export * from "./components/Radio";
|
|
6
6
|
export * from "./components/RadioGroup";
|
|
7
|
-
export * from "./components/
|
|
7
|
+
export * from "./components/TextInput";
|
|
8
8
|
export * from "./components/FormControl";
|
|
9
9
|
export * from "./components/Icons";
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,7 @@ __exportStar(require("./components/Toggle"), exports);
|
|
|
21
21
|
__exportStar(require("./components/Checkbox"), exports);
|
|
22
22
|
__exportStar(require("./components/Radio"), exports);
|
|
23
23
|
__exportStar(require("./components/RadioGroup"), exports);
|
|
24
|
-
__exportStar(require("./components/
|
|
24
|
+
__exportStar(require("./components/TextInput"), exports);
|
|
25
25
|
__exportStar(require("./components/FormControl"), exports);
|
|
26
26
|
/* --------------------------------- ICONS ---------------------------------- */
|
|
27
27
|
__exportStar(require("./components/Icons"), exports);
|
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ComponentPropsWithRef } from "react";
|
|
2
|
-
import { VariantProps } from "class-variance-authority";
|
|
3
|
-
import { inputVariants } from "./Input.styles";
|
|
4
|
-
export type InputProps = ComponentPropsWithRef<"input"> & VariantProps<typeof inputVariants>;
|
|
5
|
-
/**
|
|
6
|
-
* `Input`: 텍스트 입력을 위한 기본 컴포넌트입니다. FormControl과 함께 사용하면 label, validation 등의 기능을 자동으로 제공받습니다.
|
|
7
|
-
* @see [RDS Storybook: Input](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-input--docs)
|
|
8
|
-
* @see [RDS Storybook: FormControl](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-formcontrol--docs)
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* // 독립적으로 사용
|
|
12
|
-
* <Input
|
|
13
|
-
* placeholder="이메일을 입력하세요"
|
|
14
|
-
* onChange={(e) => setEmail(e.target.value)}
|
|
15
|
-
* />
|
|
16
|
-
*
|
|
17
|
-
* // FormControl과 함께 사용
|
|
18
|
-
* <FormControl required>
|
|
19
|
-
* <FormControl.Label>이메일</FormControl.Label>
|
|
20
|
-
* <Input type="email" />
|
|
21
|
-
* </FormControl>
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare function Input({ variant, disabled, className, ...props }: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
export declare namespace Input {
|
|
26
|
-
var displayName: string;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG,qBAAqB,CAAC,OAAO,CAAC,GACrD,YAAY,CAAC,OAAO,aAAa,CAAC,CAAC;AAErC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,KAAK,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,2CAQ3E;yBARe,KAAK"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Input = Input;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const style_1 = require("../../utils/style");
|
|
7
|
-
const Input_styles_1 = require("./Input.styles");
|
|
8
|
-
/**
|
|
9
|
-
* `Input`: 텍스트 입력을 위한 기본 컴포넌트입니다. FormControl과 함께 사용하면 label, validation 등의 기능을 자동으로 제공받습니다.
|
|
10
|
-
* @see [RDS Storybook: Input](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-input--docs)
|
|
11
|
-
* @see [RDS Storybook: FormControl](https://main--691ac7d6da1eb0c0acb5f3e2.chromatic.com/?path=/docs/components-formcontrol--docs)
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* // 독립적으로 사용
|
|
15
|
-
* <Input
|
|
16
|
-
* placeholder="이메일을 입력하세요"
|
|
17
|
-
* onChange={(e) => setEmail(e.target.value)}
|
|
18
|
-
* />
|
|
19
|
-
*
|
|
20
|
-
* // FormControl과 함께 사용
|
|
21
|
-
* <FormControl required>
|
|
22
|
-
* <FormControl.Label>이메일</FormControl.Label>
|
|
23
|
-
* <Input type="email" />
|
|
24
|
-
* </FormControl>
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
function Input({ variant, disabled, className, ...props }) {
|
|
28
|
-
return ((0, jsx_runtime_1.jsx)("input", { disabled: disabled, className: (0, style_1.cn)((0, Input_styles_1.inputVariants)({ variant, disabled, className })), ...props }));
|
|
29
|
-
}
|
|
30
|
-
Input.displayName = "Input";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Input.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Input.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;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BoB,CAAC;AAE/B,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"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Error = exports.Default = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const Input_1 = require("./Input");
|
|
6
|
-
const meta = {
|
|
7
|
-
title: "Components/Input",
|
|
8
|
-
component: Input_1.Input,
|
|
9
|
-
tags: ["autodocs"],
|
|
10
|
-
parameters: {
|
|
11
|
-
layout: "centered",
|
|
12
|
-
docs: {
|
|
13
|
-
description: {
|
|
14
|
-
component: `
|
|
15
|
-
Input은 한 줄의 텍스트 값을 설정하는데 사용됩니다.
|
|
16
|
-
|
|
17
|
-
## <b>Input 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
|
-
},
|
|
34
|
-
};
|
|
35
|
-
exports.default = meta;
|
|
36
|
-
exports.Default = {
|
|
37
|
-
parameters: {
|
|
38
|
-
layout: "centered",
|
|
39
|
-
docs: {
|
|
40
|
-
description: {
|
|
41
|
-
story: `
|
|
42
|
-
|
|
43
|
-
`,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
render: (props) => ((0, jsx_runtime_1.jsxs)("div", { className: "ui:flex ui:gap-2", children: [(0, jsx_runtime_1.jsx)(Input_1.Input, { ...props }), props.children] })),
|
|
48
|
-
args: {
|
|
49
|
-
placeholder: "placeholder",
|
|
50
|
-
variant: "default",
|
|
51
|
-
},
|
|
52
|
-
argTypes: {
|
|
53
|
-
disabled: {
|
|
54
|
-
control: { type: "boolean" },
|
|
55
|
-
options: ["true", "false"],
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
exports.Error = {
|
|
60
|
-
parameters: {
|
|
61
|
-
layout: "centered",
|
|
62
|
-
docs: {
|
|
63
|
-
description: {
|
|
64
|
-
story: `
|
|
65
|
-
|
|
66
|
-
`,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
render: (props) => ((0, jsx_runtime_1.jsxs)("div", { className: "ui:flex ui:gap-2", children: [(0, jsx_runtime_1.jsx)(Input_1.Input, { ...props, variant: "error" }), props.children] })),
|
|
71
|
-
args: {
|
|
72
|
-
placeholder: "placeholder",
|
|
73
|
-
variant: "error",
|
|
74
|
-
},
|
|
75
|
-
argTypes: {
|
|
76
|
-
disabled: {
|
|
77
|
-
control: { type: "boolean" },
|
|
78
|
-
options: ["true", "false"],
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Input.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Input.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;;;8EAmBzB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|