@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
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,26 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const useFloatingLabel = require("../../hooks/useFloatingLabel.cjs");
|
|
5
7
|
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
6
25
|
function FloatingLabelOutline({
|
|
7
26
|
mode,
|
|
8
27
|
label,
|
|
@@ -114,5 +133,53 @@ function FloatingLabelOutline({
|
|
|
114
133
|
}
|
|
115
134
|
);
|
|
116
135
|
}
|
|
117
|
-
|
|
136
|
+
function useFloatingLabelOutline({
|
|
137
|
+
label,
|
|
138
|
+
required,
|
|
139
|
+
appearance = "standard",
|
|
140
|
+
hasValue,
|
|
141
|
+
isOpen,
|
|
142
|
+
isInvalid,
|
|
143
|
+
isDisabled,
|
|
144
|
+
onFocus,
|
|
145
|
+
onBlur
|
|
146
|
+
}) {
|
|
147
|
+
const [isFocused, setIsFocused] = React__namespace.useState(false);
|
|
148
|
+
const handleFocus = React__namespace.useCallback(
|
|
149
|
+
(e) => {
|
|
150
|
+
setIsFocused(true);
|
|
151
|
+
onFocus?.(e);
|
|
152
|
+
},
|
|
153
|
+
[onFocus]
|
|
154
|
+
);
|
|
155
|
+
const handleBlur = React__namespace.useCallback(
|
|
156
|
+
(e) => {
|
|
157
|
+
setIsFocused(false);
|
|
158
|
+
onBlur?.(e);
|
|
159
|
+
},
|
|
160
|
+
[onBlur]
|
|
161
|
+
);
|
|
162
|
+
const { hasLabel, ...floating } = useFloatingLabel.useFloatingLabel({
|
|
163
|
+
label,
|
|
164
|
+
hasValue,
|
|
165
|
+
isOpen,
|
|
166
|
+
isFocused,
|
|
167
|
+
isInvalid,
|
|
168
|
+
isDisabled
|
|
169
|
+
});
|
|
170
|
+
const mode = hasLabel ? appearance === "none" ? "none" : "standard" : void 0;
|
|
171
|
+
return {
|
|
172
|
+
hasLabel,
|
|
173
|
+
isFocused,
|
|
174
|
+
isFloating: floating.isFloating,
|
|
175
|
+
labelId: floating.labelId,
|
|
176
|
+
mode,
|
|
177
|
+
// notch 테두리가 칸의 테두리를 대신 그린다 — 칸 자신의 테두리를 지우고 그 두께만큼 padding 을 늘려 글자 자리를 지킨다
|
|
178
|
+
hostClassName: mode === "standard" ? "relative !border-0 !py-[4px] !px-[6px]" : mode && "relative",
|
|
179
|
+
outline: mode && /* @__PURE__ */ jsxRuntime.jsx(FloatingLabelOutline, { mode, label, required, ...floating }),
|
|
180
|
+
onFocus: handleFocus,
|
|
181
|
+
onBlur: handleBlur
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
exports.useFloatingLabelOutline = useFloatingLabelOutline;
|
|
118
185
|
//# sourceMappingURL=floatingLabelOutline.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floatingLabelOutline.cjs","sources":["../../../src/components/_internal/floatingLabelOutline.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nimport { cn } from '../../utils/cn'\n\
|
|
1
|
+
{"version":3,"file":"floatingLabelOutline.cjs","sources":["../../../src/components/_internal/floatingLabelOutline.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nimport { useFloatingLabel, type UseFloatingLabelReturn } from '../../hooks/useFloatingLabel'\nimport { cn } from '../../utils/cn'\n\ninterface FloatingLabelOutlineProps extends Omit<UseFloatingLabelReturn, 'hasLabel'> {\n /** 'standard' = three-box notched outline, 'none' = inline floating label */\n mode: 'standard' | 'none'\n label: string\n required?: boolean\n}\n\nfunction FloatingLabelOutline({\n mode,\n label,\n required,\n isFloating,\n isMounted,\n labelColorClass,\n borderColorClass,\n isThickBorder,\n labelId,\n}: FloatingLabelOutlineProps) {\n const transitionClass = cn(\n isMounted &&\n 'transition-[top,translate,scale,color] duration-150 ease-[cubic-bezier(0.4,0,0.2,1)]',\n 'motion-reduce:transition-none',\n )\n\n if (mode === 'standard') {\n return (\n <div\n className='pointer-events-none absolute inset-0 flex rounded-small'\n data-slot='notched-outline'\n >\n {/* Left border */}\n <span\n className={cn(\n 'h-full w-[8px] rounded-l-small',\n borderColorClass,\n isThickBorder\n ? 'border-t-[2px] border-b-[2px] border-l-[2px] border-r-0'\n : 'border-t border-b border-l border-r-0',\n )}\n />\n {/* Center border (notch) */}\n <span\n className={cn(\n 'h-full relative',\n borderColorClass,\n isThickBorder\n ? 'border-t-[2px] border-b-[2px] border-l-0 border-r-0'\n : 'border-t border-b border-l-0 border-r-0',\n isFloating && '!border-t-transparent',\n isMounted &&\n 'transition-[border-top-color] duration-150 ease-[cubic-bezier(0.4,0,0.2,1)]',\n 'motion-reduce:transition-none',\n )}\n >\n {/* Invisible spacer: center span의 너비를 label 텍스트에 맞추기 위한 요소 */}\n <span\n className='invisible text-small-medium px-[2px] leading-none whitespace-nowrap'\n aria-hidden='true'\n >\n {label}\n {required && '*'}\n </span>\n {/* Floating label */}\n <span\n id={labelId}\n data-slot='floating-label'\n data-floating={isFloating}\n className={cn(\n 'absolute left-0 px-[2px] whitespace-nowrap origin-left',\n 'text-small-medium leading-none -translate-y-1/2',\n isFloating\n ? cn('scale-100 -top-[2px]', isThickBorder && '-mt-[1px]')\n : 'top-[min(50%,18px)] scale-[1.167]',\n labelColorClass,\n transitionClass,\n )}\n >\n {label}\n {required && (\n <span className='text-danger30 ml-[1px]' aria-hidden='true'>\n *\n </span>\n )}\n </span>\n </span>\n {/* Right border */}\n <span\n className={cn(\n 'h-full flex-1 rounded-r-small',\n borderColorClass,\n isThickBorder\n ? 'border-t-[2px] border-b-[2px] border-r-[2px] border-l-0'\n : 'border-t border-b border-r border-l-0',\n )}\n />\n </div>\n )\n }\n\n // mode === 'none'\n return (\n <span\n id={labelId}\n data-slot='floating-label'\n data-floating={isFloating}\n className={cn(\n 'absolute left-[8px] pointer-events-none origin-left z-10',\n 'text-small-medium leading-none whitespace-nowrap -translate-y-1/2',\n isFloating ? '-top-[2px] scale-100' : 'top-[min(50%,18px)] scale-[1.167]',\n labelColorClass,\n transitionClass,\n )}\n >\n {label}\n {required && (\n <span className='text-danger30 ml-[1px]' aria-hidden='true'>\n *\n </span>\n )}\n </span>\n )\n}\n\nexport interface UseFloatingLabelOutlineOptions<T extends Element> {\n label?: string\n required?: boolean\n appearance?: 'standard' | 'none'\n hasValue: boolean\n /** 목록이 열렸는지 (Select·MultiSelect·DatePicker·TimePicker) */\n isOpen?: boolean\n isInvalid?: boolean\n isDisabled?: boolean\n onFocus?: React.FocusEventHandler<T>\n onBlur?: React.FocusEventHandler<T>\n}\n\n/**\n * 떠 있는 라벨을 쓰는 칸(TextField·Textarea·Select·MultiSelect·DatePicker·TimePicker)이 함께 쓰는 부분.\n * 포커스를 따라가 라벨을 띄우고, 라벨 테두리(`outline`)를 만들고, 그 테두리가 놓일 칸의 클래스(`hostClassName`)를 준다.\n */\nfunction useFloatingLabelOutline<T extends Element>({\n label,\n required,\n appearance = 'standard',\n hasValue,\n isOpen,\n isInvalid,\n isDisabled,\n onFocus,\n onBlur,\n}: UseFloatingLabelOutlineOptions<T>) {\n const [isFocused, setIsFocused] = React.useState(false)\n const handleFocus = React.useCallback(\n (e: React.FocusEvent<T>) => {\n setIsFocused(true)\n onFocus?.(e)\n },\n [onFocus],\n )\n const handleBlur = React.useCallback(\n (e: React.FocusEvent<T>) => {\n setIsFocused(false)\n onBlur?.(e)\n },\n [onBlur],\n )\n\n const { hasLabel, ...floating } = useFloatingLabel({\n label,\n hasValue,\n isOpen,\n isFocused,\n isInvalid,\n isDisabled,\n appearance,\n })\n // 라벨이 없으면 undefined. standard 는 notch 테두리, none 은 테두리 없이 라벨만\n const mode = hasLabel ? (appearance === 'none' ? 'none' : 'standard') : undefined\n\n return {\n hasLabel,\n isFocused,\n isFloating: floating.isFloating,\n labelId: floating.labelId,\n mode,\n // notch 테두리가 칸의 테두리를 대신 그린다 — 칸 자신의 테두리를 지우고 그 두께만큼 padding 을 늘려 글자 자리를 지킨다\n hostClassName:\n mode === 'standard' ? 'relative !border-0 !py-[4px] !px-[6px]' : mode && 'relative',\n outline: mode && (\n <FloatingLabelOutline mode={mode} label={label!} required={required} {...floating} />\n ),\n onFocus: handleFocus,\n onBlur: handleBlur,\n }\n}\n\nexport { useFloatingLabelOutline }\n"],"names":["cn","jsxs","jsx","React","useFloatingLabel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,qBAAqB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,QAAM,kBAAkBA,GAAAA;AAAAA,IACtB,aACE;AAAA,IACF;AAAA,EAAA;AAGF,MAAI,SAAS,YAAY;AACvB,WACEC,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,aAAU;AAAA,QAGV,UAAA;AAAA,UAAAC,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWF,GAAAA;AAAAA,gBACT;AAAA,gBACA;AAAA,gBACA,gBACI,4DACA;AAAA,cAAA;AAAA,YACN;AAAA,UAAA;AAAA,UAGFC,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWD,GAAAA;AAAAA,gBACT;AAAA,gBACA;AAAA,gBACA,gBACI,wDACA;AAAA,gBACJ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AA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;AAmBA,SAAS,wBAA2C;AAAA,EAClD;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsC;AACpC,QAAM,CAAC,WAAW,YAAY,IAAIC,iBAAM,SAAS,KAAK;AACtD,QAAM,cAAcA,iBAAM;AAAA,IACxB,CAAC,MAA2B;AAC1B,mBAAa,IAAI;AACjB,gBAAU,CAAC;AAAA,IACb;AAAA,IACA,CAAC,OAAO;AAAA,EAAA;AAEV,QAAM,aAAaA,iBAAM;AAAA,IACvB,CAAC,MAA2B;AAC1B,mBAAa,KAAK;AAClB,eAAS,CAAC;AAAA,IACZ;AAAA,IACA,CAAC,MAAM;AAAA,EAAA;AAGT,QAAM,EAAE,UAAU,GAAG,SAAA,IAAaC,iBAAAA,iBAAiB;AAAA,IACjD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAEF,CAAC;AAED,QAAM,OAAO,WAAY,eAAe,SAAS,SAAS,aAAc;AAExE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,YAAY,SAAS;AAAA,IACrB,SAAS,SAAS;AAAA,IAClB;AAAA;AAAA,IAEA,eACE,SAAS,aAAa,2CAA2C,QAAQ;AAAA,IAC3E,SAAS,QACPF,2BAAAA,IAAC,sBAAA,EAAqB,MAAY,OAAe,UAAqB,GAAG,UAAU;AAAA,IAErF,SAAS;AAAA,IACT,QAAQ;AAAA,EAAA;AAEZ;;"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useFloatingLabel } from "../../hooks/useFloatingLabel.js";
|
|
3
5
|
import { cn } from "../../utils/cn.js";
|
|
4
6
|
function FloatingLabelOutline({
|
|
5
7
|
mode,
|
|
@@ -112,7 +114,55 @@ function FloatingLabelOutline({
|
|
|
112
114
|
}
|
|
113
115
|
);
|
|
114
116
|
}
|
|
117
|
+
function useFloatingLabelOutline({
|
|
118
|
+
label,
|
|
119
|
+
required,
|
|
120
|
+
appearance = "standard",
|
|
121
|
+
hasValue,
|
|
122
|
+
isOpen,
|
|
123
|
+
isInvalid,
|
|
124
|
+
isDisabled,
|
|
125
|
+
onFocus,
|
|
126
|
+
onBlur
|
|
127
|
+
}) {
|
|
128
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
129
|
+
const handleFocus = React.useCallback(
|
|
130
|
+
(e) => {
|
|
131
|
+
setIsFocused(true);
|
|
132
|
+
onFocus?.(e);
|
|
133
|
+
},
|
|
134
|
+
[onFocus]
|
|
135
|
+
);
|
|
136
|
+
const handleBlur = React.useCallback(
|
|
137
|
+
(e) => {
|
|
138
|
+
setIsFocused(false);
|
|
139
|
+
onBlur?.(e);
|
|
140
|
+
},
|
|
141
|
+
[onBlur]
|
|
142
|
+
);
|
|
143
|
+
const { hasLabel, ...floating } = useFloatingLabel({
|
|
144
|
+
label,
|
|
145
|
+
hasValue,
|
|
146
|
+
isOpen,
|
|
147
|
+
isFocused,
|
|
148
|
+
isInvalid,
|
|
149
|
+
isDisabled
|
|
150
|
+
});
|
|
151
|
+
const mode = hasLabel ? appearance === "none" ? "none" : "standard" : void 0;
|
|
152
|
+
return {
|
|
153
|
+
hasLabel,
|
|
154
|
+
isFocused,
|
|
155
|
+
isFloating: floating.isFloating,
|
|
156
|
+
labelId: floating.labelId,
|
|
157
|
+
mode,
|
|
158
|
+
// notch 테두리가 칸의 테두리를 대신 그린다 — 칸 자신의 테두리를 지우고 그 두께만큼 padding 을 늘려 글자 자리를 지킨다
|
|
159
|
+
hostClassName: mode === "standard" ? "relative !border-0 !py-[4px] !px-[6px]" : mode && "relative",
|
|
160
|
+
outline: mode && /* @__PURE__ */ jsx(FloatingLabelOutline, { mode, label, required, ...floating }),
|
|
161
|
+
onFocus: handleFocus,
|
|
162
|
+
onBlur: handleBlur
|
|
163
|
+
};
|
|
164
|
+
}
|
|
115
165
|
export {
|
|
116
|
-
|
|
166
|
+
useFloatingLabelOutline
|
|
117
167
|
};
|
|
118
168
|
//# sourceMappingURL=floatingLabelOutline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floatingLabelOutline.js","sources":["../../../src/components/_internal/floatingLabelOutline.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nimport { cn } from '../../utils/cn'\n\
|
|
1
|
+
{"version":3,"file":"floatingLabelOutline.js","sources":["../../../src/components/_internal/floatingLabelOutline.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nimport { useFloatingLabel, type UseFloatingLabelReturn } from '../../hooks/useFloatingLabel'\nimport { cn } from '../../utils/cn'\n\ninterface FloatingLabelOutlineProps extends Omit<UseFloatingLabelReturn, 'hasLabel'> {\n /** 'standard' = three-box notched outline, 'none' = inline floating label */\n mode: 'standard' | 'none'\n label: string\n required?: boolean\n}\n\nfunction FloatingLabelOutline({\n mode,\n label,\n required,\n isFloating,\n isMounted,\n labelColorClass,\n borderColorClass,\n isThickBorder,\n labelId,\n}: FloatingLabelOutlineProps) {\n const transitionClass = cn(\n isMounted &&\n 'transition-[top,translate,scale,color] duration-150 ease-[cubic-bezier(0.4,0,0.2,1)]',\n 'motion-reduce:transition-none',\n )\n\n if (mode === 'standard') {\n return (\n <div\n className='pointer-events-none absolute inset-0 flex rounded-small'\n data-slot='notched-outline'\n >\n {/* Left border */}\n <span\n className={cn(\n 'h-full w-[8px] rounded-l-small',\n borderColorClass,\n isThickBorder\n ? 'border-t-[2px] border-b-[2px] border-l-[2px] border-r-0'\n : 'border-t border-b border-l border-r-0',\n )}\n />\n {/* Center border (notch) */}\n <span\n className={cn(\n 'h-full relative',\n borderColorClass,\n isThickBorder\n ? 'border-t-[2px] border-b-[2px] border-l-0 border-r-0'\n : 'border-t border-b border-l-0 border-r-0',\n isFloating && '!border-t-transparent',\n isMounted &&\n 'transition-[border-top-color] duration-150 ease-[cubic-bezier(0.4,0,0.2,1)]',\n 'motion-reduce:transition-none',\n )}\n >\n {/* Invisible spacer: center span의 너비를 label 텍스트에 맞추기 위한 요소 */}\n <span\n className='invisible text-small-medium px-[2px] leading-none whitespace-nowrap'\n aria-hidden='true'\n >\n {label}\n {required && '*'}\n </span>\n {/* Floating label */}\n <span\n id={labelId}\n data-slot='floating-label'\n data-floating={isFloating}\n className={cn(\n 'absolute left-0 px-[2px] whitespace-nowrap origin-left',\n 'text-small-medium leading-none -translate-y-1/2',\n isFloating\n ? cn('scale-100 -top-[2px]', isThickBorder && '-mt-[1px]')\n : 'top-[min(50%,18px)] scale-[1.167]',\n labelColorClass,\n transitionClass,\n )}\n >\n {label}\n {required && (\n <span className='text-danger30 ml-[1px]' aria-hidden='true'>\n *\n </span>\n )}\n </span>\n </span>\n {/* Right border */}\n <span\n className={cn(\n 'h-full flex-1 rounded-r-small',\n borderColorClass,\n isThickBorder\n ? 'border-t-[2px] border-b-[2px] border-r-[2px] border-l-0'\n : 'border-t border-b border-r border-l-0',\n )}\n />\n </div>\n )\n }\n\n // mode === 'none'\n return (\n <span\n id={labelId}\n data-slot='floating-label'\n data-floating={isFloating}\n className={cn(\n 'absolute left-[8px] pointer-events-none origin-left z-10',\n 'text-small-medium leading-none whitespace-nowrap -translate-y-1/2',\n isFloating ? '-top-[2px] scale-100' : 'top-[min(50%,18px)] scale-[1.167]',\n labelColorClass,\n transitionClass,\n )}\n >\n {label}\n {required && (\n <span className='text-danger30 ml-[1px]' aria-hidden='true'>\n *\n </span>\n )}\n </span>\n )\n}\n\nexport interface UseFloatingLabelOutlineOptions<T extends Element> {\n label?: string\n required?: boolean\n appearance?: 'standard' | 'none'\n hasValue: boolean\n /** 목록이 열렸는지 (Select·MultiSelect·DatePicker·TimePicker) */\n isOpen?: boolean\n isInvalid?: boolean\n isDisabled?: boolean\n onFocus?: React.FocusEventHandler<T>\n onBlur?: React.FocusEventHandler<T>\n}\n\n/**\n * 떠 있는 라벨을 쓰는 칸(TextField·Textarea·Select·MultiSelect·DatePicker·TimePicker)이 함께 쓰는 부분.\n * 포커스를 따라가 라벨을 띄우고, 라벨 테두리(`outline`)를 만들고, 그 테두리가 놓일 칸의 클래스(`hostClassName`)를 준다.\n */\nfunction useFloatingLabelOutline<T extends Element>({\n label,\n required,\n appearance = 'standard',\n hasValue,\n isOpen,\n isInvalid,\n isDisabled,\n onFocus,\n onBlur,\n}: UseFloatingLabelOutlineOptions<T>) {\n const [isFocused, setIsFocused] = React.useState(false)\n const handleFocus = React.useCallback(\n (e: React.FocusEvent<T>) => {\n setIsFocused(true)\n onFocus?.(e)\n },\n [onFocus],\n )\n const handleBlur = React.useCallback(\n (e: React.FocusEvent<T>) => {\n setIsFocused(false)\n onBlur?.(e)\n },\n [onBlur],\n )\n\n const { hasLabel, ...floating } = useFloatingLabel({\n label,\n hasValue,\n isOpen,\n isFocused,\n isInvalid,\n isDisabled,\n appearance,\n })\n // 라벨이 없으면 undefined. standard 는 notch 테두리, none 은 테두리 없이 라벨만\n const mode = hasLabel ? (appearance === 'none' ? 'none' : 'standard') : undefined\n\n return {\n hasLabel,\n isFocused,\n isFloating: floating.isFloating,\n labelId: floating.labelId,\n mode,\n // notch 테두리가 칸의 테두리를 대신 그린다 — 칸 자신의 테두리를 지우고 그 두께만큼 padding 을 늘려 글자 자리를 지킨다\n hostClassName:\n mode === 'standard' ? 'relative !border-0 !py-[4px] !px-[6px]' : mode && 'relative',\n outline: mode && (\n <FloatingLabelOutline mode={mode} label={label!} required={required} {...floating} />\n ),\n onFocus: handleFocus,\n onBlur: handleBlur,\n }\n}\n\nexport { useFloatingLabelOutline }\n"],"names":[],"mappings":";;;;;AAcA,SAAS,qBAAqB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA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AAA,IAErF,SAAS;AAAA,IACT,QAAQ;AAAA,EAAA;AAEZ;"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const classVarianceAuthority = require("class-variance-authority");
|
|
6
|
+
const useControllableValue = require("../../hooks/useControllableValue.cjs");
|
|
7
|
+
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
const form = require("../form.cjs");
|
|
9
|
+
const floatingLabelOutline = require("./floatingLabelOutline.cjs");
|
|
10
|
+
function _interopNamespaceDefault(e) {
|
|
11
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
12
|
+
if (e) {
|
|
13
|
+
for (const k in e) {
|
|
14
|
+
if (k !== "default") {
|
|
15
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: () => e[k]
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
27
|
+
const useIsoLayoutEffect = typeof window === "undefined" ? React__namespace.useEffect : React__namespace.useLayoutEffect;
|
|
28
|
+
const textInputContainerVariants = classVarianceAuthority.cva(
|
|
29
|
+
"flex w-full bg-transparent rounded-small text-base-medium text-sys-text-main transition-colors",
|
|
30
|
+
{
|
|
31
|
+
variants: {
|
|
32
|
+
multiline: {
|
|
33
|
+
false: "items-center gap-[2px] min-h-[36px]",
|
|
34
|
+
true: "items-start min-h-[84px]"
|
|
35
|
+
},
|
|
36
|
+
appearance: {
|
|
37
|
+
standard: [
|
|
38
|
+
"bg-sys-background border border-sys-divider-main py-[3px] px-[5px]",
|
|
39
|
+
"hover:bg-secondary-o10"
|
|
40
|
+
].join(" "),
|
|
41
|
+
none: "bg-transparent border-none py-[4px] px-[6px]"
|
|
42
|
+
},
|
|
43
|
+
isInvalid: {
|
|
44
|
+
true: "",
|
|
45
|
+
false: ""
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
compoundVariants: [
|
|
49
|
+
{
|
|
50
|
+
appearance: "standard",
|
|
51
|
+
isInvalid: true,
|
|
52
|
+
class: "border-[2px] border-danger30 py-[2px] px-[4px]"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
defaultVariants: {
|
|
56
|
+
appearance: "standard",
|
|
57
|
+
isInvalid: false
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
const ignoreChange = () => {
|
|
62
|
+
};
|
|
63
|
+
function assignRef(ref, node) {
|
|
64
|
+
if (typeof ref === "function") ref(node);
|
|
65
|
+
else if (ref) ref.current = node;
|
|
66
|
+
}
|
|
67
|
+
function watchValueWrites(el, onWrite) {
|
|
68
|
+
const own = Object.getOwnPropertyDescriptor(el, "value");
|
|
69
|
+
const descriptor = own ?? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), "value");
|
|
70
|
+
const { get, set } = descriptor ?? {};
|
|
71
|
+
if (!get || !set) return () => {
|
|
72
|
+
};
|
|
73
|
+
Object.defineProperty(el, "value", {
|
|
74
|
+
configurable: true,
|
|
75
|
+
enumerable: descriptor?.enumerable,
|
|
76
|
+
get() {
|
|
77
|
+
return get.call(this);
|
|
78
|
+
},
|
|
79
|
+
set(next) {
|
|
80
|
+
set.call(this, next);
|
|
81
|
+
onWrite();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return () => {
|
|
85
|
+
if (own) Object.defineProperty(el, "value", own);
|
|
86
|
+
else delete el.value;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function useUncontrolledHasValue(ref, defaultValue, enabled) {
|
|
90
|
+
const [hasValue, setHasValue] = React__namespace.useState(() => String(defaultValue ?? "") !== "");
|
|
91
|
+
const sync = React__namespace.useCallback(() => {
|
|
92
|
+
const el = ref.current;
|
|
93
|
+
if (el) setHasValue(el.value !== "" || el.validity.badInput);
|
|
94
|
+
}, [ref]);
|
|
95
|
+
useIsoLayoutEffect(() => {
|
|
96
|
+
if (enabled) sync();
|
|
97
|
+
});
|
|
98
|
+
useIsoLayoutEffect(() => {
|
|
99
|
+
const el = ref.current;
|
|
100
|
+
if (!enabled || !el) return;
|
|
101
|
+
const form2 = el.form;
|
|
102
|
+
let resetTimer;
|
|
103
|
+
const afterReset = () => {
|
|
104
|
+
resetTimer = setTimeout(sync);
|
|
105
|
+
};
|
|
106
|
+
el.addEventListener("input", sync);
|
|
107
|
+
el.addEventListener("change", sync);
|
|
108
|
+
form2?.addEventListener("reset", afterReset);
|
|
109
|
+
const stopWatching = watchValueWrites(el, sync);
|
|
110
|
+
return () => {
|
|
111
|
+
el.removeEventListener("input", sync);
|
|
112
|
+
el.removeEventListener("change", sync);
|
|
113
|
+
form2?.removeEventListener("reset", afterReset);
|
|
114
|
+
clearTimeout(resetTimer);
|
|
115
|
+
stopWatching();
|
|
116
|
+
};
|
|
117
|
+
}, [enabled, ref, sync]);
|
|
118
|
+
return hasValue;
|
|
119
|
+
}
|
|
120
|
+
function useTextInput(props, forwardedRef, {
|
|
121
|
+
multiline,
|
|
122
|
+
containerClass,
|
|
123
|
+
elementClass
|
|
124
|
+
}) {
|
|
125
|
+
const {
|
|
126
|
+
appearance,
|
|
127
|
+
label,
|
|
128
|
+
required,
|
|
129
|
+
isInvalid: isInvalidProp,
|
|
130
|
+
containerClassName,
|
|
131
|
+
className,
|
|
132
|
+
disabled,
|
|
133
|
+
readOnly,
|
|
134
|
+
value: valueProp,
|
|
135
|
+
defaultValue,
|
|
136
|
+
onChange,
|
|
137
|
+
onFocus,
|
|
138
|
+
onBlur,
|
|
139
|
+
...rest
|
|
140
|
+
} = props;
|
|
141
|
+
const formControl = form.useFormControlContext();
|
|
142
|
+
const isInvalid = isInvalidProp ?? formControl?.isInvalid ?? false;
|
|
143
|
+
const elementRef = React__namespace.useRef(null);
|
|
144
|
+
const { value, isControlled } = useControllableValue.useControllableValue({
|
|
145
|
+
value: valueProp,
|
|
146
|
+
defaultValue,
|
|
147
|
+
empty: ""
|
|
148
|
+
});
|
|
149
|
+
const uncontrolledHasValue = useUncontrolledHasValue(elementRef, defaultValue, !isControlled);
|
|
150
|
+
const hasValue = isControlled ? String(value ?? "") !== "" : uncontrolledHasValue;
|
|
151
|
+
const ref = React__namespace.useCallback(
|
|
152
|
+
(node) => {
|
|
153
|
+
assignRef(elementRef, node);
|
|
154
|
+
assignRef(forwardedRef, node);
|
|
155
|
+
},
|
|
156
|
+
[forwardedRef]
|
|
157
|
+
);
|
|
158
|
+
const floating = floatingLabelOutline.useFloatingLabelOutline({
|
|
159
|
+
label,
|
|
160
|
+
required,
|
|
161
|
+
appearance,
|
|
162
|
+
hasValue,
|
|
163
|
+
isInvalid: !!isInvalid,
|
|
164
|
+
isDisabled: !!disabled,
|
|
165
|
+
onFocus,
|
|
166
|
+
onBlur
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
elementRef,
|
|
170
|
+
hasValue,
|
|
171
|
+
floating,
|
|
172
|
+
containerProps: {
|
|
173
|
+
"aria-disabled": disabled || void 0,
|
|
174
|
+
className: cn.cn(
|
|
175
|
+
textInputContainerVariants({ multiline, appearance, isInvalid }),
|
|
176
|
+
containerClass,
|
|
177
|
+
// 라벨 없는 standard 칸은 포커스 테두리를 스스로 그린다(라벨이 있으면 notch 테두리가 그린다). 2px 만큼 padding 을 줄인다
|
|
178
|
+
floating.isFocused && !isInvalid && appearance === "standard" && !floating.hasLabel && "border-[2px] border-sys-focus-ring-bold py-[2px] px-[4px]",
|
|
179
|
+
floating.hostClassName,
|
|
180
|
+
disabled ? "cursor-not-allowed opacity-50" : "cursor-text",
|
|
181
|
+
// disabled 시 hover 배경 무력화 (div container라 :disabled 불가 → JS 조건부; none은 원래 hover bg 없음)
|
|
182
|
+
disabled && appearance !== "none" && "hover:bg-sys-background",
|
|
183
|
+
containerClassName,
|
|
184
|
+
// 외부 className 은 root container 에 적용 — FormControl 의 maxWidth 가
|
|
185
|
+
// 자식 className 에 inject 되는데, wrapper div 의 폭 제어가 의도이므로
|
|
186
|
+
// 안쪽 입력 요소가 아닌 여기에 머지한다.
|
|
187
|
+
className
|
|
188
|
+
)
|
|
189
|
+
},
|
|
190
|
+
elementProps: {
|
|
191
|
+
ref,
|
|
192
|
+
disabled,
|
|
193
|
+
readOnly,
|
|
194
|
+
value: isControlled ? value : void 0,
|
|
195
|
+
defaultValue: !isControlled ? defaultValue : void 0,
|
|
196
|
+
// 핸들러를 늘 둔다 — 없으면 value 만 준 칸에 React 가 read-only 경고를 낸다(전부터 그랬다)
|
|
197
|
+
onChange: onChange ?? ignoreChange,
|
|
198
|
+
onFocus: floating.onFocus,
|
|
199
|
+
onBlur: floating.onBlur,
|
|
200
|
+
"aria-labelledby": floating.hasLabel ? floating.labelId : void 0,
|
|
201
|
+
"aria-required": floating.hasLabel && required ? true : void 0,
|
|
202
|
+
className: cn.cn(
|
|
203
|
+
"flex-1 min-w-0 bg-transparent border-none outline-none",
|
|
204
|
+
"text-base-medium text-sys-text-main",
|
|
205
|
+
"placeholder:text-sys-text-placeholder",
|
|
206
|
+
"disabled:cursor-not-allowed",
|
|
207
|
+
"px-[4px] py-[2px]",
|
|
208
|
+
elementClass,
|
|
209
|
+
// 라벨이 내려와 placeholder 자리를 차지하면 placeholder 는 숨긴다
|
|
210
|
+
floating.hasLabel && !hasValue && !floating.isFocused && "placeholder:text-transparent"
|
|
211
|
+
),
|
|
212
|
+
...rest
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
exports.useTextInput = useTextInput;
|
|
217
|
+
//# sourceMappingURL=textInput.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textInput.cjs","sources":["../../../src/components/_internal/textInput.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { cva } from 'class-variance-authority'\n\nimport { useControllableValue } from '../../hooks/useControllableValue'\nimport { cn } from '../../utils/cn'\nimport { useFormControlContext } from '../form'\nimport { useFloatingLabelOutline } from './floatingLabelOutline'\n\ntype TextElement = HTMLInputElement | HTMLTextAreaElement\n\n// 서버에서는 useLayoutEffect 가 경고만 내고 돌지 않는다\nconst useIsoLayoutEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect\n\nconst textInputContainerVariants = cva(\n 'flex w-full bg-transparent rounded-small text-base-medium text-sys-text-main transition-colors',\n {\n variants: {\n multiline: {\n false: 'items-center gap-[2px] min-h-[36px]',\n true: 'items-start min-h-[84px]',\n },\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\n/** TextField·Textarea 가 함께 받는 props */\ninterface TextInputProps<T extends TextElement> {\n appearance: 'standard' | 'none'\n label?: string\n required?: boolean\n isInvalid?: boolean\n containerClassName?: string\n className?: string\n disabled?: boolean\n readOnly?: boolean\n value?: string | number | readonly string[]\n defaultValue?: string | number | readonly string[]\n onChange?: React.ChangeEventHandler<T>\n onFocus?: React.FocusEventHandler<T>\n onBlur?: React.FocusEventHandler<T>\n}\n\nconst ignoreChange = () => {}\n\nfunction assignRef<T>(ref: React.Ref<T> | undefined, node: T | null) {\n if (typeof ref === 'function') ref(node)\n else if (ref) (ref as React.MutableRefObject<T | null>).current = node\n}\n\n/**\n * `el.value = …` 쓰기를 알린다. react-hook-form `setValue`·`reset` 은 이벤트 없이 이렇게 값을 바꾼다.\n * React 도 같은 방법(요소에 value 접근자를 덧씌움)으로 값 쓰기를 따라간다 — 그 위에 한 겹 더 씌우고, 끝나면 되돌린다.\n */\nfunction watchValueWrites(el: TextElement, onWrite: () => void) {\n const own = Object.getOwnPropertyDescriptor(el, 'value')\n const descriptor = own ?? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), 'value')\n const { get, set } = descriptor ?? {}\n if (!get || !set) return () => {}\n Object.defineProperty(el, 'value', {\n configurable: true,\n enumerable: descriptor?.enumerable,\n get() {\n return get.call(this)\n },\n set(next: string) {\n set.call(this, next)\n onWrite()\n },\n })\n return () => {\n if (own) Object.defineProperty(el, 'value', own)\n else delete (el as { value?: string }).value\n }\n}\n\n/**\n * 비제어 칸에 글자가 있는지 요소에서 읽는다. register·setValue·reset·폼 reset 버튼·자동 완성은 React state 를 거치지 않는다.\n * 다시 읽는 때: 렌더마다(layout, 페인트 전) · input·change 이벤트 · `el.value = …` 쓰기 · 폼 reset 이 끝난 뒤.\n * 마운트 전(첫 렌더·SSR)에는 defaultValue 로 짐작하고, 첫 layout 에서 바로잡는다.\n * 제어 칸(`enabled` false)은 읽지 않는다 — 값은 props 가 정하고, 입력 이벤트 도중에 다시 그리면\n * React 가 아직 바뀌지 않은 value 로 칸을 되돌려 입력이 사라진다(Chromium 에서 확인).\n */\nfunction useUncontrolledHasValue(\n ref: React.RefObject<TextElement>,\n defaultValue: unknown,\n enabled: boolean,\n) {\n const [hasValue, setHasValue] = React.useState(() => String(defaultValue ?? '') !== '')\n const sync = React.useCallback(() => {\n const el = ref.current\n // 숫자 칸에 덜 쓴 값(\"-\", \"1e\")은 value 가 \"\" 지만 글자가 보인다\n if (el) setHasValue(el.value !== '' || el.validity.badInput)\n }, [ref])\n\n useIsoLayoutEffect(() => {\n if (enabled) sync()\n })\n useIsoLayoutEffect(() => {\n const el = ref.current\n if (!enabled || !el) return\n const form = el.form\n // 폼 reset 은 reset 이벤트를 먼저 보내고 나서 값을 되돌린다 — 되돌린 뒤(다음 task)에 읽는다\n let resetTimer: ReturnType<typeof setTimeout> | undefined\n const afterReset = () => {\n resetTimer = setTimeout(sync)\n }\n el.addEventListener('input', sync)\n el.addEventListener('change', sync)\n form?.addEventListener('reset', afterReset)\n const stopWatching = watchValueWrites(el, sync)\n return () => {\n el.removeEventListener('input', sync)\n el.removeEventListener('change', sync)\n form?.removeEventListener('reset', afterReset)\n clearTimeout(resetTimer)\n stopWatching()\n }\n }, [enabled, ref, sync])\n\n return hasValue\n}\n\n/**\n * TextField·Textarea 공통: 오류 상태(FormControl), 제어/비제어 값, 값 감지, 떠 있는 라벨, 칸 테두리·포커스 모양.\n * 칸(div)에는 `containerProps`, 입력 요소에는 `elementProps`(나머지 props 포함)를 펼친다.\n */\nfunction useTextInput<T extends TextElement, P extends TextInputProps<T>>(\n props: P,\n forwardedRef: React.ForwardedRef<T>,\n {\n multiline,\n containerClass,\n elementClass,\n }: { multiline: boolean; containerClass?: string; elementClass?: string | false },\n) {\n const {\n appearance,\n label,\n required,\n isInvalid: isInvalidProp,\n containerClassName,\n className,\n disabled,\n readOnly,\n value: valueProp,\n defaultValue,\n onChange,\n onFocus,\n onBlur,\n ...rest\n } = props\n const formControl = useFormControlContext()\n const isInvalid = isInvalidProp ?? formControl?.isInvalid ?? false\n const elementRef = React.useRef<T>(null)\n\n // 비제어일 때 네이티브 입력이 값을 든다. 훅은 value·defaultValue 중 무엇을 넘길지 정한다\n const { value, isControlled } = useControllableValue({\n value: valueProp,\n defaultValue,\n empty: '',\n })\n const uncontrolledHasValue = useUncontrolledHasValue(elementRef, defaultValue, !isControlled)\n // 제어 값은 props 그대로 — null(서버 값 없음)은 빈 칸이다\n const hasValue = isControlled ? String(value ?? '') !== '' : uncontrolledHasValue\n\n const ref = React.useCallback(\n (node: T | null) => {\n assignRef(elementRef, node)\n assignRef(forwardedRef, node)\n },\n [forwardedRef],\n )\n\n const floating = useFloatingLabelOutline<T>({\n label,\n required,\n appearance,\n hasValue,\n isInvalid: !!isInvalid,\n isDisabled: !!disabled,\n onFocus,\n onBlur,\n })\n\n return {\n elementRef,\n hasValue,\n floating,\n containerProps: {\n 'aria-disabled': disabled || undefined,\n className: cn(\n textInputContainerVariants({ multiline, appearance, isInvalid }),\n containerClass,\n // 라벨 없는 standard 칸은 포커스 테두리를 스스로 그린다(라벨이 있으면 notch 테두리가 그린다). 2px 만큼 padding 을 줄인다\n floating.isFocused &&\n !isInvalid &&\n appearance === 'standard' &&\n !floating.hasLabel &&\n 'border-[2px] border-sys-focus-ring-bold py-[2px] px-[4px]',\n floating.hostClassName,\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 // 안쪽 입력 요소가 아닌 여기에 머지한다.\n className,\n ),\n },\n elementProps: {\n ref,\n disabled,\n readOnly,\n value: isControlled ? value : undefined,\n defaultValue: !isControlled ? defaultValue : undefined,\n // 핸들러를 늘 둔다 — 없으면 value 만 준 칸에 React 가 read-only 경고를 낸다(전부터 그랬다)\n onChange: onChange ?? ignoreChange,\n onFocus: floating.onFocus,\n onBlur: floating.onBlur,\n 'aria-labelledby': floating.hasLabel ? floating.labelId : undefined,\n 'aria-required': floating.hasLabel && required ? 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 elementClass,\n // 라벨이 내려와 placeholder 자리를 차지하면 placeholder 는 숨긴다\n floating.hasLabel && !hasValue && !floating.isFocused && 'placeholder:text-transparent',\n ),\n ...rest,\n },\n }\n}\n\nexport { useTextInput }\n"],"names":["React","c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