@t3q-ui/design-system 1.68.1 → 1.68.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/CHANGELOG.md +3 -0
- package/dist/components/_internal/floatingLabelOutline.cjs +68 -1
- package/dist/components/_internal/floatingLabelOutline.cjs.map +1 -1
- package/dist/components/_internal/floatingLabelOutline.js +52 -2
- package/dist/components/_internal/floatingLabelOutline.js.map +1 -1
- package/dist/components/_internal/textInput.cjs +217 -0
- package/dist/components/_internal/textInput.cjs.map +1 -0
- package/dist/components/_internal/textInput.js +200 -0
- package/dist/components/_internal/textInput.js.map +1 -0
- package/dist/components/datePicker.cjs +11 -47
- package/dist/components/datePicker.cjs.map +1 -1
- package/dist/components/datePicker.js +12 -48
- package/dist/components/datePicker.js.map +1 -1
- package/dist/components/multiSelect/multiSelectTrigger.cjs +18 -38
- package/dist/components/multiSelect/multiSelectTrigger.cjs.map +1 -1
- package/dist/components/multiSelect/multiSelectTrigger.js +19 -39
- package/dist/components/multiSelect/multiSelectTrigger.js.map +1 -1
- package/dist/components/select/selectTrigger.cjs +11 -47
- package/dist/components/select/selectTrigger.cjs.map +1 -1
- package/dist/components/select/selectTrigger.js +12 -48
- package/dist/components/select/selectTrigger.js.map +1 -1
- package/dist/components/textArea.cjs +15 -172
- package/dist/components/textArea.cjs.map +1 -1
- package/dist/components/textArea.js +15 -172
- package/dist/components/textArea.js.map +1 -1
- package/dist/components/textField.cjs +48 -222
- package/dist/components/textField.cjs.map +1 -1
- package/dist/components/textField.js +48 -222
- package/dist/components/textField.js.map +1 -1
- package/dist/components/timePicker.cjs +11 -47
- package/dist/components/timePicker.cjs.map +1 -1
- package/dist/components/timePicker.js +12 -48
- package/dist/components/timePicker.js.map +1 -1
- package/mcp/manifests/components.json +6 -1
- package/package.json +1 -1
|
@@ -3,13 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const jsxRuntime = require("react/jsx-runtime");
|
|
5
5
|
const React = require("react");
|
|
6
|
-
const classVarianceAuthority = require("class-variance-authority");
|
|
7
6
|
const cancelIcon = require("./_internal/cancelIcon.cjs");
|
|
8
|
-
const
|
|
9
|
-
const useControllableValue = require("../hooks/useControllableValue.cjs");
|
|
10
|
-
const useFloatingLabel = require("../hooks/useFloatingLabel.cjs");
|
|
7
|
+
const textInput = require("./_internal/textInput.cjs");
|
|
11
8
|
const cn = require("../utils/cn.cjs");
|
|
12
|
-
const form = require("./form.cjs");
|
|
13
9
|
function _interopNamespaceDefault(e) {
|
|
14
10
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
15
11
|
if (e) {
|
|
@@ -27,231 +23,61 @@ function _interopNamespaceDefault(e) {
|
|
|
27
23
|
return Object.freeze(n);
|
|
28
24
|
}
|
|
29
25
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
30
|
-
const textFieldContainerVariants = classVarianceAuthority.cva(
|
|
31
|
-
[
|
|
32
|
-
"flex w-full items-center gap-[2px] bg-transparent",
|
|
33
|
-
"rounded-small min-h-[36px] text-base-medium text-sys-text-main",
|
|
34
|
-
"transition-colors"
|
|
35
|
-
].join(" "),
|
|
36
|
-
{
|
|
37
|
-
variants: {
|
|
38
|
-
appearance: {
|
|
39
|
-
standard: [
|
|
40
|
-
"bg-sys-background border border-sys-divider-main py-[3px] px-[5px]",
|
|
41
|
-
"hover:bg-secondary-o10"
|
|
42
|
-
].join(" "),
|
|
43
|
-
none: "bg-transparent border-none py-[4px] px-[6px]"
|
|
44
|
-
},
|
|
45
|
-
isInvalid: {
|
|
46
|
-
true: "",
|
|
47
|
-
false: ""
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
compoundVariants: [
|
|
51
|
-
{
|
|
52
|
-
appearance: "standard",
|
|
53
|
-
isInvalid: true,
|
|
54
|
-
class: "border-[2px] border-danger30 py-[2px] px-[4px]"
|
|
55
|
-
}
|
|
56
|
-
],
|
|
57
|
-
defaultVariants: {
|
|
58
|
-
appearance: "standard",
|
|
59
|
-
isInvalid: false
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
26
|
const TextField = React__namespace.forwardRef(
|
|
64
|
-
({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
elemBeforeInput,
|
|
70
|
-
elemAfterInput,
|
|
71
|
-
isInvalid: isInvalidProp,
|
|
72
|
-
containerClassName,
|
|
73
|
-
className,
|
|
74
|
-
disabled,
|
|
75
|
-
readOnly,
|
|
76
|
-
value: valueProp,
|
|
77
|
-
defaultValue,
|
|
78
|
-
onChange: onChangeProp,
|
|
79
|
-
onFocus: onFocusProp,
|
|
80
|
-
onBlur: onBlurProp,
|
|
81
|
-
...inputProps
|
|
82
|
-
}, forwardedRef) => {
|
|
83
|
-
const formControl = form.useFormControlContext();
|
|
84
|
-
const isInvalid = isInvalidProp ?? formControl?.isInvalid ?? false;
|
|
85
|
-
const inputRef = React__namespace.useRef(null);
|
|
86
|
-
const [isFocused, setIsFocused] = React__namespace.useState(false);
|
|
87
|
-
const {
|
|
88
|
-
value,
|
|
89
|
-
setValue: trackValue,
|
|
90
|
-
isControlled
|
|
91
|
-
} = useControllableValue.useControllableValue({ value: valueProp, defaultValue, empty: "" });
|
|
92
|
-
const hasValue = String(value) !== "";
|
|
93
|
-
const composedRef = React__namespace.useCallback(
|
|
94
|
-
(node) => {
|
|
95
|
-
inputRef.current = node;
|
|
96
|
-
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
97
|
-
else if (forwardedRef)
|
|
98
|
-
forwardedRef.current = node;
|
|
99
|
-
},
|
|
100
|
-
[forwardedRef]
|
|
101
|
-
);
|
|
102
|
-
const {
|
|
103
|
-
hasLabel,
|
|
104
|
-
isFloating,
|
|
105
|
-
isMounted,
|
|
106
|
-
labelColorClass,
|
|
107
|
-
borderColorClass,
|
|
108
|
-
isThickBorder,
|
|
109
|
-
labelId
|
|
110
|
-
} = useFloatingLabel.useFloatingLabel({
|
|
111
|
-
label,
|
|
112
|
-
hasValue,
|
|
113
|
-
isFocused,
|
|
114
|
-
isInvalid: !!isInvalid,
|
|
115
|
-
isDisabled: !!disabled
|
|
116
|
-
});
|
|
117
|
-
const showNotchedOutline = hasLabel && appearance !== "none";
|
|
118
|
-
const showNoneLabel = hasLabel && appearance === "none";
|
|
119
|
-
const handleChange = React__namespace.useCallback(
|
|
120
|
-
(e) => {
|
|
121
|
-
trackValue(e.target.value);
|
|
122
|
-
onChangeProp?.(e);
|
|
123
|
-
},
|
|
124
|
-
[trackValue, onChangeProp]
|
|
125
|
-
);
|
|
126
|
-
const handleFocus = React__namespace.useCallback(
|
|
127
|
-
(e) => {
|
|
128
|
-
setIsFocused(true);
|
|
129
|
-
onFocusProp?.(e);
|
|
130
|
-
},
|
|
131
|
-
[onFocusProp]
|
|
132
|
-
);
|
|
133
|
-
const handleBlur = React__namespace.useCallback(
|
|
134
|
-
(e) => {
|
|
135
|
-
setIsFocused(false);
|
|
136
|
-
onBlurProp?.(e);
|
|
137
|
-
},
|
|
138
|
-
[onBlurProp]
|
|
27
|
+
({ appearance = "standard", hasClearButton, elemBeforeInput, elemAfterInput, ...props }, forwardedRef) => {
|
|
28
|
+
const { elementRef, hasValue, floating, containerProps, elementProps } = textInput.useTextInput(
|
|
29
|
+
{ ...props, appearance },
|
|
30
|
+
forwardedRef,
|
|
31
|
+
{ multiline: false, containerClass: cancelIcon.CLEAR_HOST_CLASS }
|
|
139
32
|
);
|
|
140
33
|
const handleClear = React__namespace.useCallback(() => {
|
|
141
|
-
const input =
|
|
34
|
+
const input = elementRef.current;
|
|
142
35
|
if (!input) return;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (nativeSetter) {
|
|
146
|
-
nativeSetter.call(input, "");
|
|
147
|
-
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
148
|
-
}
|
|
36
|
+
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(input, "");
|
|
37
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
149
38
|
input.focus();
|
|
150
|
-
}, [
|
|
151
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
"
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// Floating label positioning
|
|
162
|
-
(showNotchedOutline || showNoneLabel) && "relative",
|
|
163
|
-
// Notched outline draws border — remove container's own border
|
|
164
|
-
showNotchedOutline && "!border-0 !py-[4px] !px-[6px]",
|
|
165
|
-
// Disabled / cursor
|
|
166
|
-
disabled ? "cursor-not-allowed opacity-50" : "cursor-text",
|
|
167
|
-
// disabled 시 hover 배경 무력화 (div container라 :disabled 불가 → JS 조건부; none은 원래 hover bg 없음)
|
|
168
|
-
disabled && appearance !== "none" && "hover:bg-sys-background",
|
|
169
|
-
containerClassName,
|
|
170
|
-
// 외부 className 은 root container 에 적용 — FormControl 의 maxWidth 가
|
|
171
|
-
// 자식 className 에 inject 되는데, wrapper div 의 폭 제어가 의도이므로
|
|
172
|
-
// inner input 이 아닌 여기에 머지한다.
|
|
173
|
-
className
|
|
174
|
-
),
|
|
175
|
-
children: [
|
|
176
|
-
(showNotchedOutline || showNoneLabel) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
177
|
-
floatingLabelOutline.FloatingLabelOutline,
|
|
178
|
-
{
|
|
179
|
-
mode: showNotchedOutline ? "standard" : "none",
|
|
180
|
-
label,
|
|
181
|
-
required: requiredProp,
|
|
182
|
-
isFloating,
|
|
183
|
-
isMounted,
|
|
184
|
-
labelColorClass,
|
|
185
|
-
borderColorClass,
|
|
186
|
-
isThickBorder,
|
|
187
|
-
labelId
|
|
188
|
-
}
|
|
39
|
+
}, [elementRef]);
|
|
40
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-slot": "text-field", ...containerProps, children: [
|
|
41
|
+
floating.outline,
|
|
42
|
+
elemBeforeInput && /* @__PURE__ */ jsxRuntime.jsx(
|
|
43
|
+
"span",
|
|
44
|
+
{
|
|
45
|
+
className: cn.cn(
|
|
46
|
+
// 아이콘은 24×24, 글자("개"·"코어")는 줄바꿈 없이 폭이 늘어난다 — 고정 size-[24px] 는 두 글자가 두 줄로 깨졌다 (2026-10-12)
|
|
47
|
+
"shrink-0 flex items-center justify-center h-[24px] min-w-[24px] whitespace-nowrap",
|
|
48
|
+
typeof elemBeforeInput === "string" && "px-[2px] text-sys-text-subtle",
|
|
49
|
+
floating.hasLabel && !floating.isFloating && "invisible"
|
|
189
50
|
),
|
|
190
|
-
elemBeforeInput
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
51
|
+
children: elemBeforeInput
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { ...elementProps }),
|
|
55
|
+
hasClearButton && /* @__PURE__ */ jsxRuntime.jsx(
|
|
56
|
+
"button",
|
|
57
|
+
{
|
|
58
|
+
type: "button",
|
|
59
|
+
onClick: handleClear,
|
|
60
|
+
className: cn.cn(
|
|
61
|
+
"shrink-0 flex items-center justify-center p-[2px] rounded-small hover:bg-secondary-o10 text-sys-text-subtler",
|
|
62
|
+
cancelIcon.CLEAR_REVEAL_CLASS,
|
|
63
|
+
(!hasValue || props.disabled || props.readOnly) && "invisible"
|
|
201
64
|
),
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
"aria-labelledby": hasLabel ? labelId : void 0,
|
|
214
|
-
"aria-required": hasLabel && requiredProp ? true : void 0,
|
|
215
|
-
className: cn.cn(
|
|
216
|
-
"flex-1 min-w-0 bg-transparent border-none outline-none",
|
|
217
|
-
"text-base-medium text-sys-text-main",
|
|
218
|
-
"placeholder:text-sys-text-placeholder",
|
|
219
|
-
"disabled:cursor-not-allowed",
|
|
220
|
-
"px-[4px] py-[2px]",
|
|
221
|
-
// When label is down (acting as placeholder), hide input's placeholder
|
|
222
|
-
hasLabel && !hasValue && !isFocused && "placeholder:text-transparent"
|
|
223
|
-
),
|
|
224
|
-
...inputProps
|
|
225
|
-
}
|
|
65
|
+
"aria-label": "입력 지우기",
|
|
66
|
+
tabIndex: -1,
|
|
67
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(cancelIcon.CancelIcon, { size: 20 })
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
elemAfterInput && /* @__PURE__ */ jsxRuntime.jsx(
|
|
71
|
+
"span",
|
|
72
|
+
{
|
|
73
|
+
className: cn.cn(
|
|
74
|
+
"shrink-0 flex items-center justify-center h-[24px] min-w-[24px] whitespace-nowrap",
|
|
75
|
+
typeof elemAfterInput === "string" && "px-[2px] text-sys-text-subtle"
|
|
226
76
|
),
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
onClick: handleClear,
|
|
232
|
-
className: cn.cn(
|
|
233
|
-
"shrink-0 flex items-center justify-center p-[2px] rounded-small hover:bg-secondary-o10 text-sys-text-subtler",
|
|
234
|
-
cancelIcon.CLEAR_REVEAL_CLASS,
|
|
235
|
-
(!hasValue || disabled || readOnly) && "invisible"
|
|
236
|
-
),
|
|
237
|
-
"aria-label": "입력 지우기",
|
|
238
|
-
tabIndex: -1,
|
|
239
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(cancelIcon.CancelIcon, { size: 20 })
|
|
240
|
-
}
|
|
241
|
-
),
|
|
242
|
-
elemAfterInput && /* @__PURE__ */ jsxRuntime.jsx(
|
|
243
|
-
"span",
|
|
244
|
-
{
|
|
245
|
-
className: cn.cn(
|
|
246
|
-
"shrink-0 flex items-center justify-center h-[24px] min-w-[24px] whitespace-nowrap",
|
|
247
|
-
typeof elemAfterInput === "string" && "px-[2px] text-sys-text-subtle"
|
|
248
|
-
),
|
|
249
|
-
children: elemAfterInput
|
|
250
|
-
}
|
|
251
|
-
)
|
|
252
|
-
]
|
|
253
|
-
}
|
|
254
|
-
);
|
|
77
|
+
children: elemAfterInput
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
] });
|
|
255
81
|
}
|
|
256
82
|
);
|
|
257
83
|
TextField.displayName = "TextField";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textField.cjs","sources":["../../src/components/textField.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { cva } from 'class-variance-authority'\n\nimport { CancelIcon, CLEAR_HOST_CLASS, CLEAR_REVEAL_CLASS } from './_internal/cancelIcon'\nimport { FloatingLabelOutline } from './_internal/floatingLabelOutline'\nimport { useControllableValue } from '../hooks/useControllableValue'\nimport { useFloatingLabel } from '../hooks/useFloatingLabel'\nimport { cn } from '../utils/cn'\nimport { useFormControlContext } from './form'\n\nconst textFieldContainerVariants = cva(\n [\n 'flex w-full items-center gap-[2px] bg-transparent',\n 'rounded-small min-h-[36px] text-base-medium text-sys-text-main',\n 'transition-colors',\n ].join(' '),\n {\n variants: {\n appearance: {\n standard: [\n 'bg-sys-background border border-sys-divider-main py-[3px] px-[5px]',\n 'hover:bg-secondary-o10',\n ].join(' '),\n none: 'bg-transparent border-none py-[4px] px-[6px]',\n },\n isInvalid: {\n true: '',\n false: '',\n },\n },\n compoundVariants: [\n {\n appearance: 'standard',\n isInvalid: true,\n class: 'border-[2px] border-danger30 py-[2px] px-[4px]',\n },\n ],\n defaultVariants: {\n appearance: 'standard',\n isInvalid: false,\n },\n },\n)\n\nexport type TextFieldProps = Omit<React.ComponentProps<'input'>, 'children'> & {\n /** @default 'standard' */\n appearance?: 'standard' | 'none'\n /** Floating label 텍스트 */\n label?: string\n /** 라벨 필수 표시 (*) */\n required?: boolean\n /** Clear 버튼 표시 여부 */\n hasClearButton?: boolean\n /** 입력 필드 왼쪽 아이콘/요소 슬롯 */\n elemBeforeInput?: React.ReactNode\n /** 입력 필드 오른쪽 아이콘/요소 슬롯 */\n elemAfterInput?: React.ReactNode\n /** 에러 상태 */\n isInvalid?: boolean\n /** 컨테이너 div에 적용할 추가 className */\n containerClassName?: string\n}\n\n/**\n * 한 줄 텍스트 입력. 폼의 이름·코드·URL·숫자 같은 짧은 값에 쓴다.\n *\n * 언제 쓰나: `FormField` 안에서 `FormControl` 로 감싸 오류 상태를 받는다. 라벨은 `FormLabel` 로 두고, 독립 사용 시에만 `label`(floating) 을 쓴다.\n * 언제 안 쓰나: 여러 줄 입력(→ Textarea), 정해진 선택지(→ Select·RadioGroup), 목록 검색·필터(→ ColumnFilter·TableFilter*).\n * 대신/함께: 지우기 버튼은 `hasClearButton`, 단위·아이콘은 `elemBeforeInput`/`elemAfterInput`.\n */\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(\n (\n {\n appearance = 'standard',\n label,\n required: requiredProp,\n hasClearButton,\n elemBeforeInput,\n elemAfterInput,\n isInvalid: isInvalidProp,\n containerClassName,\n className,\n disabled,\n readOnly,\n value: valueProp,\n defaultValue,\n onChange: onChangeProp,\n onFocus: onFocusProp,\n onBlur: onBlurProp,\n ...inputProps\n },\n forwardedRef,\n ) => {\n const formControl = useFormControlContext()\n const isInvalid = isInvalidProp ?? formControl?.isInvalid ?? false\n const inputRef = React.useRef<HTMLInputElement>(null)\n const [isFocused, setIsFocused] = React.useState(false)\n\n // 비제어일 때 네이티브 입력이 값을 들고, 훅은 라벨·지우기 버튼용 hasValue 만 따라간다\n const {\n value,\n setValue: trackValue,\n isControlled,\n } = useControllableValue({ value: valueProp, defaultValue, empty: '' })\n const hasValue = String(value) !== ''\n\n // Compose refs (forwarded ref + internal ref)\n const composedRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n ;(inputRef as React.MutableRefObject<HTMLInputElement | null>).current = node\n if (typeof forwardedRef === 'function') forwardedRef(node)\n else if (forwardedRef)\n (forwardedRef as React.MutableRefObject<HTMLInputElement | null>).current = node\n },\n [forwardedRef],\n )\n\n // Floating label\n const {\n hasLabel,\n isFloating,\n isMounted,\n labelColorClass,\n borderColorClass,\n isThickBorder,\n labelId,\n } = useFloatingLabel({\n label,\n hasValue,\n isFocused,\n isInvalid: !!isInvalid,\n isDisabled: !!disabled,\n appearance,\n })\n\n const showNotchedOutline = hasLabel && appearance !== 'none'\n const showNoneLabel = hasLabel && appearance === 'none'\n\n // --- Handlers ---\n\n const handleChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n trackValue(e.target.value)\n onChangeProp?.(e)\n },\n [trackValue, onChangeProp],\n )\n\n const handleFocus = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n setIsFocused(true)\n onFocusProp?.(e)\n },\n [onFocusProp],\n )\n\n const handleBlur = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n setIsFocused(false)\n onBlurProp?.(e)\n },\n [onBlurProp],\n )\n\n const handleClear = React.useCallback(() => {\n const input = inputRef.current\n if (!input) return\n\n trackValue('')\n\n // Set value via native setter to trigger React's onChange\n const nativeSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set\n if (nativeSetter) {\n nativeSetter.call(input, '')\n input.dispatchEvent(new Event('input', { bubbles: true }))\n }\n\n input.focus()\n }, [trackValue])\n\n return (\n <div\n data-slot='text-field'\n aria-disabled={disabled || undefined}\n className={cn(\n textFieldContainerVariants({ appearance, isInvalid }),\n CLEAR_HOST_CLASS,\n // Focus styling (state-managed, standard appearance without notched outline only)\n isFocused &&\n !isInvalid &&\n appearance === 'standard' &&\n !showNotchedOutline &&\n 'border-[2px] border-sys-focus-ring-bold py-[2px] px-[4px]',\n // Floating label positioning\n (showNotchedOutline || showNoneLabel) && 'relative',\n // Notched outline draws border — remove container's own border\n showNotchedOutline && '!border-0 !py-[4px] !px-[6px]',\n // Disabled / cursor\n disabled ? 'cursor-not-allowed opacity-50' : 'cursor-text',\n // disabled 시 hover 배경 무력화 (div container라 :disabled 불가 → JS 조건부; none은 원래 hover bg 없음)\n disabled && appearance !== 'none' && 'hover:bg-sys-background',\n containerClassName,\n // 외부 className 은 root container 에 적용 — FormControl 의 maxWidth 가\n // 자식 className 에 inject 되는데, wrapper div 의 폭 제어가 의도이므로\n // inner input 이 아닌 여기에 머지한다.\n className,\n )}\n >\n {/* Floating label (standard: notched outline, none: inline label) */}\n {(showNotchedOutline || showNoneLabel) && (\n <FloatingLabelOutline\n mode={showNotchedOutline ? 'standard' : 'none'}\n label={label!}\n required={requiredProp}\n isFloating={isFloating}\n isMounted={isMounted}\n labelColorClass={labelColorClass}\n borderColorClass={borderColorClass}\n isThickBorder={isThickBorder}\n labelId={labelId}\n />\n )}\n\n {/* Left icon slot — label이 down 상태(placeholder 역할)일 때 숨김 */}\n {elemBeforeInput && (\n <span\n className={cn(\n // 아이콘은 24×24, 글자(\"개\"·\"코어\")는 줄바꿈 없이 폭이 늘어난다 — 고정 size-[24px] 는 두 글자가 두 줄로 깨졌다 (2026-10-12)\n 'shrink-0 flex items-center justify-center h-[24px] min-w-[24px] whitespace-nowrap',\n typeof elemBeforeInput === 'string' && 'px-[2px] text-sys-text-subtle',\n hasLabel && !isFloating && 'invisible',\n )}\n >\n {elemBeforeInput}\n </span>\n )}\n\n {/* Input */}\n <input\n ref={composedRef}\n disabled={disabled}\n readOnly={readOnly}\n value={isControlled ? value : undefined}\n defaultValue={!isControlled ? defaultValue : undefined}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n aria-labelledby={hasLabel ? labelId : undefined}\n aria-required={hasLabel && requiredProp ? true : undefined}\n className={cn(\n 'flex-1 min-w-0 bg-transparent border-none outline-none',\n 'text-base-medium text-sys-text-main',\n 'placeholder:text-sys-text-placeholder',\n 'disabled:cursor-not-allowed',\n 'px-[4px] py-[2px]',\n // When label is down (acting as placeholder), hide input's placeholder\n hasLabel && !hasValue && !isFocused && 'placeholder:text-transparent',\n )}\n {...inputProps}\n />\n\n {/* Clear button — 항상 공간 확보, 값 없으면 invisible (너비 점프 방지), 값이 있으면 마우스·포커스 때만 보임 */}\n {hasClearButton && (\n <button\n type='button'\n onClick={handleClear}\n className={cn(\n 'shrink-0 flex items-center justify-center p-[2px] rounded-small hover:bg-secondary-o10 text-sys-text-subtler',\n CLEAR_REVEAL_CLASS,\n (!hasValue || disabled || readOnly) && 'invisible',\n )}\n aria-label='입력 지우기'\n tabIndex={-1}\n >\n <CancelIcon size={20} />\n </button>\n )}\n\n {/* Right icon slot */}\n {elemAfterInput && (\n <span\n className={cn(\n 'shrink-0 flex items-center justify-center h-[24px] min-w-[24px] whitespace-nowrap',\n typeof elemAfterInput === 'string' && 'px-[2px] text-sys-text-subtle',\n )}\n >\n {elemAfterInput}\n </span>\n )}\n </div>\n )\n },\n)\nTextField.displayName = 'TextField'\n\nexport { TextField }\n"],"names":["cva","React","useFormControlContext","useControllableValue","useFloatingLabel","jsxs","cn","CLEAR_HOST_CLASS","jsx","FloatingLabelOutline","CLEAR_REVEAL_CLASS","CancelIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,6BAA6BA,uBAAAA;AAAAA,EACjC;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EAAA,EACA,KAAK,GAAG;AAAA,EACV;AAAA,IACE,UAAU;AAAA,MACR,YAAY;AAAA,QACV,UAAU;AAAA,UACR;AAAA,UACA;AAAA,QAAA,EACA,KAAK,GAAG;AAAA,QACV,MAAM;AAAA,MAAA;AAAA,MAER,WAAW;AAAA,QACT,MAAM;AAAA,QACN,OAAO;AAAA,MAAA;AAAA,IACT;AAAA,IAEF,kBAAkB;AAAA,MAChB;AAAA,QACE,YAAY;AAAA,QACZ,WAAW;AAAA,QACX,OAAO;AAAA,MAAA;AAAA,IACT;AAAA,IAEF,iBAAiB;AAAA,MACf,YAA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GAAAA;AAAAA,gBACT;AAAA,gBACA,OAAO,mBAAmB,YAAY;AAAA,cAAA;AAAA,cAGvC,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AACA,UAAU,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"textField.cjs","sources":["../../src/components/textField.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nimport { CancelIcon, CLEAR_HOST_CLASS, CLEAR_REVEAL_CLASS } from './_internal/cancelIcon'\nimport { useTextInput } from './_internal/textInput'\nimport { cn } from '../utils/cn'\n\nexport type TextFieldProps = Omit<React.ComponentProps<'input'>, 'children'> & {\n /** @default 'standard' */\n appearance?: 'standard' | 'none'\n /** Floating label 텍스트 */\n label?: string\n /** 라벨 필수 표시 (*) */\n required?: boolean\n /** Clear 버튼 표시 여부 */\n hasClearButton?: boolean\n /** 입력 필드 왼쪽 아이콘/요소 슬롯 */\n elemBeforeInput?: React.ReactNode\n /** 입력 필드 오른쪽 아이콘/요소 슬롯 */\n elemAfterInput?: React.ReactNode\n /** 에러 상태 */\n isInvalid?: boolean\n /** 컨테이너 div에 적용할 추가 className */\n containerClassName?: string\n}\n\n/**\n * 한 줄 텍스트 입력. 폼의 이름·코드·URL·숫자 같은 짧은 값에 쓴다.\n *\n * 언제 쓰나: `FormField` 안에서 `FormControl` 로 감싸 오류 상태를 받는다. 라벨은 `FormLabel` 로 두고, 독립 사용 시에만 `label`(floating) 을 쓴다.\n * 언제 안 쓰나: 여러 줄 입력(→ Textarea), 정해진 선택지(→ Select·RadioGroup), 목록 검색·필터(→ ColumnFilter·TableFilter*).\n * 대신/함께: 지우기 버튼은 `hasClearButton`, 단위·아이콘은 `elemBeforeInput`/`elemAfterInput`.\n */\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(\n (\n { appearance = 'standard', hasClearButton, elemBeforeInput, elemAfterInput, ...props },\n forwardedRef,\n ) => {\n const { elementRef, hasValue, floating, containerProps, elementProps } = useTextInput(\n { ...props, appearance },\n forwardedRef,\n { multiline: false, containerClass: CLEAR_HOST_CLASS },\n )\n\n const handleClear = React.useCallback(() => {\n const input = elementRef.current\n if (!input) return\n // 원래 setter 로 써야 React 가 값 바뀜을 알아채 onChange 를 부른다\n Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, '')\n input.dispatchEvent(new Event('input', { bubbles: true }))\n input.focus()\n }, [elementRef])\n\n return (\n <div data-slot='text-field' {...containerProps}>\n {/* Floating label (standard: notched outline, none: inline label) */}\n {floating.outline}\n\n {/* Left icon slot — label이 down 상태(placeholder 역할)일 때 숨김 */}\n {elemBeforeInput && (\n <span\n className={cn(\n // 아이콘은 24×24, 글자(\"개\"·\"코어\")는 줄바꿈 없이 폭이 늘어난다 — 고정 size-[24px] 는 두 글자가 두 줄로 깨졌다 (2026-10-12)\n 'shrink-0 flex items-center justify-center h-[24px] min-w-[24px] whitespace-nowrap',\n typeof elemBeforeInput === 'string' && 'px-[2px] text-sys-text-subtle',\n floating.hasLabel && !floating.isFloating && 'invisible',\n )}\n >\n {elemBeforeInput}\n </span>\n )}\n\n <input {...elementProps} />\n\n {/* Clear button — 항상 공간 확보, 값 없으면 invisible (너비 점프 방지), 값이 있으면 마우스·포커스 때만 보임 */}\n {hasClearButton && (\n <button\n type='button'\n onClick={handleClear}\n className={cn(\n 'shrink-0 flex items-center justify-center p-[2px] rounded-small hover:bg-secondary-o10 text-sys-text-subtler',\n CLEAR_REVEAL_CLASS,\n (!hasValue || props.disabled || props.readOnly) && 'invisible',\n )}\n aria-label='입력 지우기'\n tabIndex={-1}\n >\n <CancelIcon size={20} />\n </button>\n )}\n\n {/* Right icon slot */}\n {elemAfterInput && (\n <span\n className={cn(\n 'shrink-0 flex items-center justify-center h-[24px] min-w-[24px] whitespace-nowrap',\n typeof elemAfterInput === 'string' && 'px-[2px] text-sys-text-subtle',\n )}\n >\n {elemAfterInput}\n </span>\n )}\n </div>\n )\n },\n)\nTextField.displayName = 'TextField'\n\nexport { TextField }\n"],"names":["React","useTextInput","CLEAR_HOST_CLASS","jsxs","jsx","cn","CLEAR_REVEAL_CLASS","CancelIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,YAAYA,iBAAM;AAAA,EACtB,CACE,EAAE,aAAa,YAAY,gBAAgB,iBAAiB,gBAAgB,GAAG,MAAA,GAC/E,iBACG;AACH,UAAM,EAAE,YAAY,UAAU,UAAU,gBAAgB,iBAAiBC,UAAAA;AAAAA,MACvE,EAAE,GAAG,OAAO,WAAA;AAAA,MACZ;AAAA,MACA,EAAE,WAAW,OAAO,gBAAgBC,WAAAA,iBAAA;AAAA,IAAiB;AAGvD,UAAM,cAAcF,iBAAM,YAAY,MAAM;AAC1C,YAAM,QAAQ,WAAW;AACzB,UAAI,CAAC,MAAO;AAEZ,aAAO,yBAAyB,iBAAiB,WAAW,OAAO,GAAG,KAAK,KAAK,OAAO,EAAE;AACzF,YAAM,cAAc,IAAI,MAAM,SAAS,EAAE,SAAS,KAAA,CAAM,CAAC;AACzD,YAAM,MAAA;AAAA,IACR,GAAG,CAAC,UAAU,CAAC;AAEf,WACEG,2BAAAA,KAAC,OAAA,EAAI,aAAU,cAAc,GAAG,gBAE7B,UAAA;AAAA,MAAA,SAAS;AAAA,MAGT,mBACCC,2BAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWC,GAAAA;AAAAA;AAAAA,YAET;AAAA,YACA,OAAO,oBAAoB,YAAY;AAAA,YACvC,SAAS,YAAY,CAAC,SAAS,cAAc;AAAA,UAAA;AAAA,UAG9C,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAILD,2BAAAA,IAAC,SAAA,EAAO,GAAG,cAAc;AAAA,MAGxB,kBACCA,2BAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAS;AAAA,UACT,WAAWC,GAAAA;AAAAA,YACT;AAAA,YACAC,WAAAA;AAAAA,aACC,CAAC,YAAY,MAAM,YAAY,MAAM,aAAa;AAAA,UAAA;AAAA,UAErD,cAAW;AAAA,UACX,UAAU;AAAA,UAEV,UAAAF,2BAAAA,IAACG,WAAAA,YAAA,EAAW,MAAM,GAAA,CAAI;AAAA,QAAA;AAAA,MAAA;AAAA,MAKzB,kBACCH,2BAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWC,GAAAA;AAAAA,YACT;AAAA,YACA,OAAO,mBAAmB,YAAY;AAAA,UAAA;AAAA,UAGvC,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACH,GAEJ;AAAA,EAEJ;AACF;AACA,UAAU,cAAc;;"}
|
|
@@ -1,238 +1,64 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { cva } from "class-variance-authority";
|
|
5
4
|
import { CancelIcon, CLEAR_REVEAL_CLASS, CLEAR_HOST_CLASS } from "./_internal/cancelIcon.js";
|
|
6
|
-
import {
|
|
7
|
-
import { useControllableValue } from "../hooks/useControllableValue.js";
|
|
8
|
-
import { useFloatingLabel } from "../hooks/useFloatingLabel.js";
|
|
5
|
+
import { useTextInput } from "./_internal/textInput.js";
|
|
9
6
|
import { cn } from "../utils/cn.js";
|
|
10
|
-
import { useFormControlContext } from "./form.js";
|
|
11
|
-
const textFieldContainerVariants = cva(
|
|
12
|
-
[
|
|
13
|
-
"flex w-full items-center gap-[2px] bg-transparent",
|
|
14
|
-
"rounded-small min-h-[36px] text-base-medium text-sys-text-main",
|
|
15
|
-
"transition-colors"
|
|
16
|
-
].join(" "),
|
|
17
|
-
{
|
|
18
|
-
variants: {
|
|
19
|
-
appearance: {
|
|
20
|
-
standard: [
|
|
21
|
-
"bg-sys-background border border-sys-divider-main py-[3px] px-[5px]",
|
|
22
|
-
"hover:bg-secondary-o10"
|
|
23
|
-
].join(" "),
|
|
24
|
-
none: "bg-transparent border-none py-[4px] px-[6px]"
|
|
25
|
-
},
|
|
26
|
-
isInvalid: {
|
|
27
|
-
true: "",
|
|
28
|
-
false: ""
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
compoundVariants: [
|
|
32
|
-
{
|
|
33
|
-
appearance: "standard",
|
|
34
|
-
isInvalid: true,
|
|
35
|
-
class: "border-[2px] border-danger30 py-[2px] px-[4px]"
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
defaultVariants: {
|
|
39
|
-
appearance: "standard",
|
|
40
|
-
isInvalid: false
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
7
|
const TextField = React.forwardRef(
|
|
45
|
-
({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
elemBeforeInput,
|
|
51
|
-
elemAfterInput,
|
|
52
|
-
isInvalid: isInvalidProp,
|
|
53
|
-
containerClassName,
|
|
54
|
-
className,
|
|
55
|
-
disabled,
|
|
56
|
-
readOnly,
|
|
57
|
-
value: valueProp,
|
|
58
|
-
defaultValue,
|
|
59
|
-
onChange: onChangeProp,
|
|
60
|
-
onFocus: onFocusProp,
|
|
61
|
-
onBlur: onBlurProp,
|
|
62
|
-
...inputProps
|
|
63
|
-
}, forwardedRef) => {
|
|
64
|
-
const formControl = useFormControlContext();
|
|
65
|
-
const isInvalid = isInvalidProp ?? formControl?.isInvalid ?? false;
|
|
66
|
-
const inputRef = React.useRef(null);
|
|
67
|
-
const [isFocused, setIsFocused] = React.useState(false);
|
|
68
|
-
const {
|
|
69
|
-
value,
|
|
70
|
-
setValue: trackValue,
|
|
71
|
-
isControlled
|
|
72
|
-
} = useControllableValue({ value: valueProp, defaultValue, empty: "" });
|
|
73
|
-
const hasValue = String(value) !== "";
|
|
74
|
-
const composedRef = React.useCallback(
|
|
75
|
-
(node) => {
|
|
76
|
-
inputRef.current = node;
|
|
77
|
-
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
78
|
-
else if (forwardedRef)
|
|
79
|
-
forwardedRef.current = node;
|
|
80
|
-
},
|
|
81
|
-
[forwardedRef]
|
|
82
|
-
);
|
|
83
|
-
const {
|
|
84
|
-
hasLabel,
|
|
85
|
-
isFloating,
|
|
86
|
-
isMounted,
|
|
87
|
-
labelColorClass,
|
|
88
|
-
borderColorClass,
|
|
89
|
-
isThickBorder,
|
|
90
|
-
labelId
|
|
91
|
-
} = useFloatingLabel({
|
|
92
|
-
label,
|
|
93
|
-
hasValue,
|
|
94
|
-
isFocused,
|
|
95
|
-
isInvalid: !!isInvalid,
|
|
96
|
-
isDisabled: !!disabled
|
|
97
|
-
});
|
|
98
|
-
const showNotchedOutline = hasLabel && appearance !== "none";
|
|
99
|
-
const showNoneLabel = hasLabel && appearance === "none";
|
|
100
|
-
const handleChange = React.useCallback(
|
|
101
|
-
(e) => {
|
|
102
|
-
trackValue(e.target.value);
|
|
103
|
-
onChangeProp?.(e);
|
|
104
|
-
},
|
|
105
|
-
[trackValue, onChangeProp]
|
|
106
|
-
);
|
|
107
|
-
const handleFocus = React.useCallback(
|
|
108
|
-
(e) => {
|
|
109
|
-
setIsFocused(true);
|
|
110
|
-
onFocusProp?.(e);
|
|
111
|
-
},
|
|
112
|
-
[onFocusProp]
|
|
113
|
-
);
|
|
114
|
-
const handleBlur = React.useCallback(
|
|
115
|
-
(e) => {
|
|
116
|
-
setIsFocused(false);
|
|
117
|
-
onBlurProp?.(e);
|
|
118
|
-
},
|
|
119
|
-
[onBlurProp]
|
|
8
|
+
({ appearance = "standard", hasClearButton, elemBeforeInput, elemAfterInput, ...props }, forwardedRef) => {
|
|
9
|
+
const { elementRef, hasValue, floating, containerProps, elementProps } = useTextInput(
|
|
10
|
+
{ ...props, appearance },
|
|
11
|
+
forwardedRef,
|
|
12
|
+
{ multiline: false, containerClass: CLEAR_HOST_CLASS }
|
|
120
13
|
);
|
|
121
14
|
const handleClear = React.useCallback(() => {
|
|
122
|
-
const input =
|
|
15
|
+
const input = elementRef.current;
|
|
123
16
|
if (!input) return;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (nativeSetter) {
|
|
127
|
-
nativeSetter.call(input, "");
|
|
128
|
-
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
129
|
-
}
|
|
17
|
+
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(input, "");
|
|
18
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
130
19
|
input.focus();
|
|
131
|
-
}, [
|
|
132
|
-
return /* @__PURE__ */ jsxs(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// Floating label positioning
|
|
143
|
-
(showNotchedOutline || showNoneLabel) && "relative",
|
|
144
|
-
// Notched outline draws border — remove container's own border
|
|
145
|
-
showNotchedOutline && "!border-0 !py-[4px] !px-[6px]",
|
|
146
|
-
// Disabled / cursor
|
|
147
|
-
disabled ? "cursor-not-allowed opacity-50" : "cursor-text",
|
|
148
|
-
// disabled 시 hover 배경 무력화 (div container라 :disabled 불가 → JS 조건부; none은 원래 hover bg 없음)
|
|
149
|
-
disabled && appearance !== "none" && "hover:bg-sys-background",
|
|
150
|
-
containerClassName,
|
|
151
|
-
// 외부 className 은 root container 에 적용 — FormControl 의 maxWidth 가
|
|
152
|
-
// 자식 className 에 inject 되는데, wrapper div 의 폭 제어가 의도이므로
|
|
153
|
-
// inner input 이 아닌 여기에 머지한다.
|
|
154
|
-
className
|
|
155
|
-
),
|
|
156
|
-
children: [
|
|
157
|
-
(showNotchedOutline || showNoneLabel) && /* @__PURE__ */ jsx(
|
|
158
|
-
FloatingLabelOutline,
|
|
159
|
-
{
|
|
160
|
-
mode: showNotchedOutline ? "standard" : "none",
|
|
161
|
-
label,
|
|
162
|
-
required: requiredProp,
|
|
163
|
-
isFloating,
|
|
164
|
-
isMounted,
|
|
165
|
-
labelColorClass,
|
|
166
|
-
borderColorClass,
|
|
167
|
-
isThickBorder,
|
|
168
|
-
labelId
|
|
169
|
-
}
|
|
170
|
-
),
|
|
171
|
-
elemBeforeInput && /* @__PURE__ */ jsx(
|
|
172
|
-
"span",
|
|
173
|
-
{
|
|
174
|
-
className: cn(
|
|
175
|
-
// 아이콘은 24×24, 글자("개"·"코어")는 줄바꿈 없이 폭이 늘어난다 — 고정 size-[24px] 는 두 글자가 두 줄로 깨졌다 (2026-10-12)
|
|
176
|
-
"shrink-0 flex items-center justify-center h-[24px] min-w-[24px] whitespace-nowrap",
|
|
177
|
-
typeof elemBeforeInput === "string" && "px-[2px] text-sys-text-subtle",
|
|
178
|
-
hasLabel && !isFloating && "invisible"
|
|
179
|
-
),
|
|
180
|
-
children: elemBeforeInput
|
|
181
|
-
}
|
|
20
|
+
}, [elementRef]);
|
|
21
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "text-field", ...containerProps, children: [
|
|
22
|
+
floating.outline,
|
|
23
|
+
elemBeforeInput && /* @__PURE__ */ jsx(
|
|
24
|
+
"span",
|
|
25
|
+
{
|
|
26
|
+
className: cn(
|
|
27
|
+
// 아이콘은 24×24, 글자("개"·"코어")는 줄바꿈 없이 폭이 늘어난다 — 고정 size-[24px] 는 두 글자가 두 줄로 깨졌다 (2026-10-12)
|
|
28
|
+
"shrink-0 flex items-center justify-center h-[24px] min-w-[24px] whitespace-nowrap",
|
|
29
|
+
typeof elemBeforeInput === "string" && "px-[2px] text-sys-text-subtle",
|
|
30
|
+
floating.hasLabel && !floating.isFloating && "invisible"
|
|
182
31
|
),
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
className: cn(
|
|
197
|
-
"flex-1 min-w-0 bg-transparent border-none outline-none",
|
|
198
|
-
"text-base-medium text-sys-text-main",
|
|
199
|
-
"placeholder:text-sys-text-placeholder",
|
|
200
|
-
"disabled:cursor-not-allowed",
|
|
201
|
-
"px-[4px] py-[2px]",
|
|
202
|
-
// When label is down (acting as placeholder), hide input's placeholder
|
|
203
|
-
hasLabel && !hasValue && !isFocused && "placeholder:text-transparent"
|
|
204
|
-
),
|
|
205
|
-
...inputProps
|
|
206
|
-
}
|
|
32
|
+
children: elemBeforeInput
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
/* @__PURE__ */ jsx("input", { ...elementProps }),
|
|
36
|
+
hasClearButton && /* @__PURE__ */ jsx(
|
|
37
|
+
"button",
|
|
38
|
+
{
|
|
39
|
+
type: "button",
|
|
40
|
+
onClick: handleClear,
|
|
41
|
+
className: cn(
|
|
42
|
+
"shrink-0 flex items-center justify-center p-[2px] rounded-small hover:bg-secondary-o10 text-sys-text-subtler",
|
|
43
|
+
CLEAR_REVEAL_CLASS,
|
|
44
|
+
(!hasValue || props.disabled || props.readOnly) && "invisible"
|
|
207
45
|
),
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
tabIndex: -1,
|
|
220
|
-
children: /* @__PURE__ */ jsx(CancelIcon, { size: 20 })
|
|
221
|
-
}
|
|
46
|
+
"aria-label": "입력 지우기",
|
|
47
|
+
tabIndex: -1,
|
|
48
|
+
children: /* @__PURE__ */ jsx(CancelIcon, { size: 20 })
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
elemAfterInput && /* @__PURE__ */ jsx(
|
|
52
|
+
"span",
|
|
53
|
+
{
|
|
54
|
+
className: cn(
|
|
55
|
+
"shrink-0 flex items-center justify-center h-[24px] min-w-[24px] whitespace-nowrap",
|
|
56
|
+
typeof elemAfterInput === "string" && "px-[2px] text-sys-text-subtle"
|
|
222
57
|
),
|
|
223
|
-
elemAfterInput
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
"shrink-0 flex items-center justify-center h-[24px] min-w-[24px] whitespace-nowrap",
|
|
228
|
-
typeof elemAfterInput === "string" && "px-[2px] text-sys-text-subtle"
|
|
229
|
-
),
|
|
230
|
-
children: elemAfterInput
|
|
231
|
-
}
|
|
232
|
-
)
|
|
233
|
-
]
|
|
234
|
-
}
|
|
235
|
-
);
|
|
58
|
+
children: elemAfterInput
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] });
|
|
236
62
|
}
|
|
237
63
|
);
|
|
238
64
|
TextField.displayName = "TextField";
|