@thewrong/ui 0.3.0 → 0.4.0
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/README.md +2 -2
- package/dist/components/button/Button.cjs +1 -1
- package/dist/components/button/Button.d.ts +3 -0
- package/dist/components/button/Button.esm.js +17 -5
- package/dist/components/button/types.d.ts +3 -1
- package/dist/components/button/utils.cjs +1 -1
- package/dist/components/button/utils.d.ts +2 -2
- package/dist/components/button/utils.esm.js +6 -2
- package/dist/components/progress/Progress.cjs +1 -1
- package/dist/components/progress/Progress.d.ts +3 -4
- package/dist/components/progress/Progress.esm.js +5 -5
- package/dist/components/progress/types.d.ts +2 -2
- package/dist/components/select/MultiSelect.cjs +1 -1
- package/dist/components/select/MultiSelect.esm.js +140 -138
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.esm.js +190 -182
- package/dist/components/select/types.d.ts +7 -0
- package/dist/components/slider/Slider.cjs +1 -0
- package/dist/components/slider/Slider.d.ts +6 -0
- package/dist/components/slider/Slider.esm.js +36 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/types.d.ts +15 -0
- package/dist/components/slider/utils.cjs +1 -0
- package/dist/components/slider/utils.d.ts +3 -0
- package/dist/components/slider/utils.esm.js +15 -0
- package/dist/components/table/accordion-table.cjs +1 -1
- package/dist/components/table/accordion-table.esm.js +194 -180
- package/dist/components/table/components/SortHeader.cjs +1 -0
- package/dist/components/table/components/SortHeader.d.ts +10 -0
- package/dist/components/table/components/SortHeader.esm.js +27 -0
- package/dist/components/table/components/SortableHeaderCell.cjs +1 -1
- package/dist/components/table/components/SortableHeaderCell.d.ts +10 -2
- package/dist/components/table/components/SortableHeaderCell.esm.js +54 -26
- package/dist/components/table/hooks/sort-state.cjs +1 -0
- package/dist/components/table/hooks/sort-state.d.ts +5 -0
- package/dist/components/table/hooks/sort-state.esm.js +21 -0
- package/dist/components/table/hooks/useTableSort.cjs +1 -1
- package/dist/components/table/hooks/useTableSort.d.ts +6 -3
- package/dist/components/table/hooks/useTableSort.esm.js +18 -19
- package/dist/components/table/paginated-table.d.ts +2 -0
- package/dist/components/table/table.cjs +1 -1
- package/dist/components/table/table.d.ts +2 -0
- package/dist/components/table/table.esm.js +119 -104
- package/dist/components/table/types.d.ts +11 -4
- package/dist/components/tabs/Tabs.cjs +1 -0
- package/dist/components/tabs/Tabs.d.ts +8 -0
- package/dist/components/tabs/Tabs.esm.js +53 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/navigation.cjs +1 -0
- package/dist/components/tabs/navigation.d.ts +2 -0
- package/dist/components/tabs/navigation.esm.js +18 -0
- package/dist/components/tabs/types.d.ts +20 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +3 -1
- package/dist/node_modules/lucide-react/dist/esm/icons/arrow-down.cjs +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/arrow-down.esm.js +10 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/arrow-up-down.cjs +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/arrow-up-down.esm.js +21 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/arrow-up.cjs +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/arrow-up.esm.js +10 -0
- package/dist/tokens.css +78 -5
- package/dist/ui.css +1 -1
- package/llms.txt +9 -6
- package/package.json +1 -1
|
@@ -7,32 +7,32 @@ import { CHEVRON_SIZE_CLASS as a, CONTROL_TEXT_CLASS as o, SLOT_BADGE_TEXT_CLASS
|
|
|
7
7
|
import { getInputContainerClasses as ie, getInputHelpClasses as ae, getInputLabelClasses as oe, getInputTrailingIconColor as se, getInputVariantClasses as ce } from "../input/utils.esm.js";
|
|
8
8
|
import { LoadingDots as le } from "./loading-dots.esm.js";
|
|
9
9
|
import { computeSelectPanelMaxWidth as ue } from "./panel-width.esm.js";
|
|
10
|
-
import { forwardRef as s, useEffect as c, useId as
|
|
11
|
-
import { jsx as
|
|
12
|
-
import { FloatingFocusManager as
|
|
10
|
+
import { forwardRef as s, useEffect as c, useId as de, useLayoutEffect as fe, useMemo as l, useRef as u, useState as d } from "react";
|
|
11
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
12
|
+
import { FloatingFocusManager as pe, FloatingPortal as me, autoUpdate as he, flip as ge, offset as _e, shift as ve, size as ye, useClick as be, useDismiss as xe, useFloating as Se, useInteractions as Ce, useListNavigation as we, useRole as Te } from "@floating-ui/react";
|
|
13
13
|
//#region src/components/select/MultiSelect.tsx
|
|
14
|
-
var
|
|
15
|
-
let [
|
|
16
|
-
|
|
17
|
-
let
|
|
18
|
-
if (!
|
|
19
|
-
let e =
|
|
14
|
+
var Ee = (e) => e.length === 0 ? "" : e.map((e) => e.label).join(", "), De = (e) => e.length === 0 ? "" : `${e.length}개 선택`, m = s(function({ options: s, value: m, onChange: h, variant: Oe, selectSize: g = "medium", label: _, "aria-label": ke, "aria-labelledby": Ae, labelOption: v = "appear", help: y, placeholder: je = "선택해주세요", hasError: b = !1, disabled: x = !1, suffix: Me, trailingIcon: Ne, clearable: S = !1, badge: C, searchable: w = !1, searchPlaceholder: Pe = "검색...", onSearchChange: T, isSearchLoading: E = !1, containerProps: Fe, containerRef: Ie, className: Le = "", panelClassName: Re = "", formatTrigger: ze = Ee, formatCollapsed: Be = De, disableAutoCollapse: D = !1, showSelectAll: Ve = !1, id: He, name: O, "data-testid": Ue }, k) {
|
|
15
|
+
let [A, We] = d(!1), [j, M] = d(null), [N, P] = d(""), [Ge, Ke] = d(!1), qe = u([]), F = u(null), I = u(null), L = u(null), R = u(null), z = de(), Je = de(), B = He ?? Je, V = (e) => `${z}-opt-${e}`, Ye = j === null ? void 0 : V(j), H = typeof T == "function", U = u(T);
|
|
16
|
+
U.current = T;
|
|
17
|
+
let W = l(() => {
|
|
18
|
+
if (!w || H || N.length === 0) return s;
|
|
19
|
+
let e = N.toLowerCase();
|
|
20
20
|
return s.filter((t) => t.label.toLowerCase().includes(e));
|
|
21
21
|
}, [
|
|
22
22
|
s,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
]),
|
|
27
|
-
open:
|
|
28
|
-
onOpenChange:
|
|
23
|
+
w,
|
|
24
|
+
H,
|
|
25
|
+
N
|
|
26
|
+
]), G = l(() => new Set(m), [m]), K = l(() => s.filter((e) => G.has(String(e.value))), [s, G]), { refs: q, floatingStyles: Xe, context: J } = Se({
|
|
27
|
+
open: A,
|
|
28
|
+
onOpenChange: We,
|
|
29
29
|
placement: "bottom-start",
|
|
30
|
-
whileElementsMounted:
|
|
30
|
+
whileElementsMounted: he,
|
|
31
31
|
middleware: [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
_e(4),
|
|
33
|
+
ge({ padding: 8 }),
|
|
34
|
+
ve({ padding: 8 }),
|
|
35
|
+
ye({
|
|
36
36
|
apply({ rects: e, elements: t, availableHeight: n, availableWidth: r }) {
|
|
37
37
|
Object.assign(t.floating.style, {
|
|
38
38
|
minWidth: `${e.reference.width}px`,
|
|
@@ -43,187 +43,189 @@ var Te = (e) => e.length === 0 ? "" : e.map((e) => e.label).join(", "), Ee = (e)
|
|
|
43
43
|
padding: 8
|
|
44
44
|
})
|
|
45
45
|
]
|
|
46
|
-
}), { getReferenceProps: Ze, getFloatingProps: Qe, getItemProps: $e } =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
listRef:
|
|
52
|
-
activeIndex:
|
|
53
|
-
onNavigate:
|
|
54
|
-
virtual:
|
|
46
|
+
}), { getReferenceProps: Ze, getFloatingProps: Qe, getItemProps: $e } = Ce([
|
|
47
|
+
be(J, { enabled: !x }),
|
|
48
|
+
xe(J),
|
|
49
|
+
Te(J, { role: "listbox" }),
|
|
50
|
+
we(J, {
|
|
51
|
+
listRef: qe,
|
|
52
|
+
activeIndex: j,
|
|
53
|
+
onNavigate: M,
|
|
54
|
+
virtual: w,
|
|
55
55
|
loop: !0
|
|
56
56
|
})
|
|
57
|
-
]), et =
|
|
57
|
+
]), et = u(!1);
|
|
58
58
|
c(() => {
|
|
59
|
-
|
|
60
|
-
}, [
|
|
61
|
-
|
|
62
|
-
}, [
|
|
63
|
-
if (
|
|
64
|
-
|
|
59
|
+
A ? et.current = !0 : (P(""), M(null), et.current && U.current?.(""));
|
|
60
|
+
}, [A]), c(() => {
|
|
61
|
+
A && w && F.current && F.current.focus();
|
|
62
|
+
}, [A, w]), fe(() => {
|
|
63
|
+
if (D) {
|
|
64
|
+
Ke(!1);
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
let e =
|
|
67
|
+
let e = L.current, t = R.current;
|
|
68
68
|
if (!e || !t) return;
|
|
69
69
|
let n = () => {
|
|
70
70
|
let n = t.scrollWidth, r = e.clientWidth;
|
|
71
|
-
|
|
71
|
+
Ke(n > r - 1);
|
|
72
72
|
};
|
|
73
73
|
n();
|
|
74
74
|
let r = new ResizeObserver(() => {
|
|
75
75
|
requestAnimationFrame(n);
|
|
76
76
|
});
|
|
77
77
|
return r.observe(e), () => r.disconnect();
|
|
78
|
-
}, [
|
|
79
|
-
let
|
|
80
|
-
let t = new Set(
|
|
81
|
-
t.has(e) ? t.delete(e) : t.add(e),
|
|
78
|
+
}, [D, m.join(",")]);
|
|
79
|
+
let Y = (e) => {
|
|
80
|
+
let t = new Set(G);
|
|
81
|
+
t.has(e) ? t.delete(e) : t.add(e), h(s.filter((e) => t.has(String(e.value))).map((e) => String(e.value)));
|
|
82
82
|
}, tt = (e) => {
|
|
83
|
-
e.stopPropagation(),
|
|
84
|
-
},
|
|
85
|
-
if (
|
|
86
|
-
let e = new Set(
|
|
87
|
-
|
|
83
|
+
e.stopPropagation(), h([]);
|
|
84
|
+
}, X = W.filter((e) => !e.disabled).map((e) => String(e.value)), nt = X.length > 0 && X.every((e) => G.has(e)), rt = () => {
|
|
85
|
+
if (nt) {
|
|
86
|
+
let e = new Set(X);
|
|
87
|
+
h(m.filter((t) => !e.has(t)));
|
|
88
88
|
} else {
|
|
89
|
-
let e = new Set([...
|
|
90
|
-
|
|
89
|
+
let e = new Set([...m, ...X]);
|
|
90
|
+
h(s.filter((t) => e.has(String(t.value))).map((e) => String(e.value)));
|
|
91
91
|
}
|
|
92
|
-
}, rt = (e) => {
|
|
93
|
-
!T || S || h.length === 0 || N || (e.key === "Backspace" || e.key === "Delete") && (e.preventDefault(), g([]));
|
|
94
92
|
}, it = (e) => {
|
|
95
|
-
|
|
96
|
-
t !== I && (B.current && (B.current.scrollTop = 0), F(null)), L(t), H.current?.(t);
|
|
93
|
+
!S || x || m.length === 0 || A || (e.key === "Backspace" || e.key === "Delete") && (e.preventDefault(), h([]));
|
|
97
94
|
}, at = (e) => {
|
|
98
|
-
|
|
95
|
+
let t = e.target.value;
|
|
96
|
+
t !== N && (I.current && (I.current.scrollTop = 0), M(null)), P(t), U.current?.(t);
|
|
97
|
+
}, ot = (e) => {
|
|
98
|
+
if (!e.nativeEvent.isComposing && e.key === "Enter" && j !== null) {
|
|
99
99
|
e.preventDefault();
|
|
100
|
-
let t =
|
|
101
|
-
t && !t.disabled &&
|
|
100
|
+
let t = W[j];
|
|
101
|
+
t && !t.disabled && Y(String(t.value));
|
|
102
102
|
}
|
|
103
|
-
},
|
|
104
|
-
return /* @__PURE__ */
|
|
105
|
-
ref:
|
|
103
|
+
}, Z = K.length > 0, st = v === "sustain" || v === "appear" && Z, ct = Z ? ze(K) : "", lt = Z ? Be(K) : "", ut = Z ? Ge ? lt : ct : je, dt = ne[g], ft = te[g], pt = ee[g], mt = re[g], ht = a[g], gt = ce(Oe, b, x, g), Q = se(b, x, Z || A), $ = o[g], _t = x ? "text-fg-disabled" : b ? "text-fg-danger" : Z ? "text-fg-default" : "text-fg-subtle";
|
|
104
|
+
return /* @__PURE__ */ p("div", {
|
|
105
|
+
ref: Ie,
|
|
106
106
|
className: e(ie(), "min-w-0"),
|
|
107
|
-
...
|
|
107
|
+
...Fe,
|
|
108
108
|
children: [
|
|
109
|
-
!
|
|
110
|
-
ref:
|
|
109
|
+
!D && Z && /* @__PURE__ */ f("span", {
|
|
110
|
+
ref: R,
|
|
111
111
|
"aria-hidden": !0,
|
|
112
112
|
className: e("pointer-events-none fixed left-0 -top-[9999px] whitespace-nowrap", $),
|
|
113
|
-
children:
|
|
113
|
+
children: ct
|
|
114
114
|
}),
|
|
115
|
-
|
|
116
|
-
className: oe(
|
|
117
|
-
htmlFor:
|
|
118
|
-
children:
|
|
115
|
+
st && _ && /* @__PURE__ */ f("label", {
|
|
116
|
+
className: oe(Oe, b),
|
|
117
|
+
htmlFor: B,
|
|
118
|
+
children: _
|
|
119
119
|
}),
|
|
120
|
-
/* @__PURE__ */
|
|
120
|
+
/* @__PURE__ */ p("button", {
|
|
121
121
|
ref: (e) => {
|
|
122
|
-
|
|
122
|
+
q.setReference(e), typeof k == "function" ? k(e) : k && (k.current = e);
|
|
123
123
|
},
|
|
124
|
-
id:
|
|
124
|
+
id: B,
|
|
125
125
|
type: "button",
|
|
126
|
-
disabled:
|
|
126
|
+
disabled: x,
|
|
127
127
|
"aria-haspopup": "listbox",
|
|
128
|
-
"aria-expanded":
|
|
129
|
-
"aria-controls":
|
|
130
|
-
"aria-activedescendant":
|
|
131
|
-
"data-testid":
|
|
132
|
-
...Ze({ onKeyDown:
|
|
133
|
-
|
|
128
|
+
"aria-expanded": A,
|
|
129
|
+
"aria-controls": A ? z : void 0,
|
|
130
|
+
"aria-activedescendant": Ye,
|
|
131
|
+
"data-testid": Ue,
|
|
132
|
+
...Ze({ onKeyDown: it }),
|
|
133
|
+
"aria-label": ke,
|
|
134
|
+
"aria-labelledby": Ae,
|
|
135
|
+
className: e(gt, "flex w-full min-w-0 items-center", dt, x ? "cursor-not-allowed" : "cursor-pointer", Le),
|
|
134
136
|
children: [
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
ref:
|
|
137
|
-
className: e("min-w-0 flex-1 truncate text-left", $,
|
|
138
|
-
children:
|
|
137
|
+
/* @__PURE__ */ f("span", {
|
|
138
|
+
ref: L,
|
|
139
|
+
className: e("min-w-0 flex-1 truncate text-left", $, _t),
|
|
140
|
+
children: ut
|
|
139
141
|
}),
|
|
140
|
-
|
|
142
|
+
Me && /* @__PURE__ */ f("span", {
|
|
141
143
|
className: e("shrink-0 whitespace-nowrap", $, Q),
|
|
142
|
-
children:
|
|
144
|
+
children: Me
|
|
143
145
|
}),
|
|
144
|
-
|
|
145
|
-
className: e("flex shrink-0 items-center", Q,
|
|
146
|
-
children:
|
|
146
|
+
Ne && /* @__PURE__ */ f("span", {
|
|
147
|
+
className: e("flex shrink-0 items-center", Q, ft),
|
|
148
|
+
children: Ne
|
|
147
149
|
}),
|
|
148
|
-
|
|
150
|
+
S && !x && Z && /* @__PURE__ */ f("span", {
|
|
149
151
|
role: "button",
|
|
150
152
|
tabIndex: -1,
|
|
151
153
|
onClick: tt,
|
|
152
154
|
"aria-label": "선택 모두 지우기",
|
|
153
155
|
className: e("flex shrink-0 cursor-pointer items-center", Q, "hover:text-fg-default"),
|
|
154
|
-
children: /* @__PURE__ */
|
|
155
|
-
className:
|
|
156
|
+
children: /* @__PURE__ */ f(r, {
|
|
157
|
+
className: mt,
|
|
156
158
|
strokeWidth: 1.5,
|
|
157
159
|
"aria-hidden": !0
|
|
158
160
|
})
|
|
159
161
|
}),
|
|
160
|
-
|
|
161
|
-
className: e("flex shrink-0 items-center",
|
|
162
|
-
children:
|
|
162
|
+
C && /* @__PURE__ */ f("span", {
|
|
163
|
+
className: e("flex shrink-0 items-center", ft, pt),
|
|
164
|
+
children: C
|
|
163
165
|
}),
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
-
className: e("shrink-0 transition-transform",
|
|
166
|
+
/* @__PURE__ */ f(n, {
|
|
167
|
+
className: e("shrink-0 transition-transform", ht, Q, A && "rotate-180"),
|
|
166
168
|
strokeWidth: 1.5,
|
|
167
169
|
"aria-hidden": !0
|
|
168
170
|
})
|
|
169
171
|
]
|
|
170
172
|
}),
|
|
171
|
-
|
|
173
|
+
O && /* @__PURE__ */ f("input", {
|
|
172
174
|
type: "hidden",
|
|
173
|
-
name:
|
|
174
|
-
value:
|
|
175
|
+
name: O,
|
|
176
|
+
value: m.join(",")
|
|
175
177
|
}),
|
|
176
|
-
|
|
177
|
-
context:
|
|
178
|
+
A && /* @__PURE__ */ f(me, { children: /* @__PURE__ */ f(pe, {
|
|
179
|
+
context: J,
|
|
178
180
|
modal: !1,
|
|
179
|
-
initialFocus:
|
|
180
|
-
children: /* @__PURE__ */
|
|
181
|
-
ref:
|
|
182
|
-
id:
|
|
181
|
+
initialFocus: w ? -1 : 0,
|
|
182
|
+
children: /* @__PURE__ */ p("div", {
|
|
183
|
+
ref: q.setFloating,
|
|
184
|
+
id: z,
|
|
183
185
|
style: Xe,
|
|
184
186
|
...Qe(),
|
|
185
|
-
className: e("z-floating overflow-hidden rounded-surface border border-border-subtle bg-bg-surface text-fg-default shadow-overlay",
|
|
187
|
+
className: e("z-floating overflow-hidden rounded-surface border border-border-subtle bg-bg-surface text-fg-default shadow-overlay", Re),
|
|
186
188
|
children: [
|
|
187
|
-
|
|
189
|
+
w && /* @__PURE__ */ p("div", {
|
|
188
190
|
className: "flex items-center gap-2 border-b border-border-subtle px-3 py-2",
|
|
189
191
|
children: [
|
|
190
|
-
/* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */ f(i, {
|
|
191
193
|
className: "h-4 w-4 shrink-0 text-fg-subtle",
|
|
192
194
|
"aria-hidden": !0
|
|
193
195
|
}),
|
|
194
|
-
/* @__PURE__ */
|
|
195
|
-
ref:
|
|
196
|
+
/* @__PURE__ */ f("input", {
|
|
197
|
+
ref: F,
|
|
196
198
|
type: "text",
|
|
197
|
-
value:
|
|
198
|
-
onChange:
|
|
199
|
-
onKeyDown:
|
|
200
|
-
placeholder:
|
|
199
|
+
value: N,
|
|
200
|
+
onChange: at,
|
|
201
|
+
onKeyDown: ot,
|
|
202
|
+
placeholder: Pe,
|
|
201
203
|
className: "flex-1 bg-transparent text-sm outline-hidden placeholder:text-fg-subtle"
|
|
202
204
|
}),
|
|
203
|
-
|
|
205
|
+
E && /* @__PURE__ */ f(le, { className: "h-4 w-4 shrink-0 text-fg-subtle" })
|
|
204
206
|
]
|
|
205
207
|
}),
|
|
206
|
-
|
|
208
|
+
Ve && W.length > 0 && /* @__PURE__ */ p("button", {
|
|
207
209
|
type: "button",
|
|
208
|
-
onClick:
|
|
210
|
+
onClick: rt,
|
|
209
211
|
className: "flex w-full items-center justify-between border-b border-border-subtle px-3 py-2 text-xs text-fg-muted transition-colors hover:bg-bg-subtle",
|
|
210
|
-
children: [/* @__PURE__ */
|
|
212
|
+
children: [/* @__PURE__ */ f("span", { children: nt ? "전체 해제" : "전체 선택" }), /* @__PURE__ */ p("span", {
|
|
211
213
|
className: "text-fg-subtle",
|
|
212
|
-
children: [
|
|
214
|
+
children: [X.length, "개"]
|
|
213
215
|
})]
|
|
214
216
|
}),
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
-
ref:
|
|
217
|
+
/* @__PURE__ */ f("div", {
|
|
218
|
+
ref: I,
|
|
217
219
|
className: "max-h-72 overflow-y-auto py-1",
|
|
218
|
-
children:
|
|
220
|
+
children: W.length === 0 ? /* @__PURE__ */ f("div", {
|
|
219
221
|
className: "px-3 py-4 text-center text-sm text-fg-subtle",
|
|
220
|
-
children:
|
|
221
|
-
}) :
|
|
222
|
-
let i = String(n.value), a =
|
|
223
|
-
return /* @__PURE__ */
|
|
224
|
-
id:
|
|
222
|
+
children: E ? "검색 중..." : "옵션이 없어요"
|
|
223
|
+
}) : W.map((n, r) => {
|
|
224
|
+
let i = String(n.value), a = G.has(i), o = j === r;
|
|
225
|
+
return /* @__PURE__ */ p("div", {
|
|
226
|
+
id: V(r),
|
|
225
227
|
ref: (e) => {
|
|
226
|
-
|
|
228
|
+
qe.current[r] = e;
|
|
227
229
|
},
|
|
228
230
|
role: "option",
|
|
229
231
|
"aria-selected": a,
|
|
@@ -231,33 +233,33 @@ var Te = (e) => e.length === 0 ? "" : e.map((e) => e.label).join(", "), Ee = (e)
|
|
|
231
233
|
tabIndex: o ? 0 : -1,
|
|
232
234
|
...$e({
|
|
233
235
|
onClick: () => {
|
|
234
|
-
n.disabled ||
|
|
236
|
+
n.disabled || Y(i);
|
|
235
237
|
},
|
|
236
238
|
onKeyDown: (e) => {
|
|
237
|
-
n.disabled || (e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
239
|
+
n.disabled || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), Y(i));
|
|
238
240
|
}
|
|
239
241
|
}),
|
|
240
242
|
className: e("flex cursor-pointer items-start gap-3 px-3 py-2 text-sm transition-colors", n.disabled ? "cursor-not-allowed text-fg-disabled" : o ? "bg-bg-subtle text-fg-default" : "text-fg-default hover:bg-bg-subtle"),
|
|
241
243
|
children: [
|
|
242
|
-
/* @__PURE__ */
|
|
244
|
+
/* @__PURE__ */ f("span", {
|
|
243
245
|
className: e("mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-checkbox border", a ? "border-primary bg-primary text-fg-inverse" : "border-border-subtle"),
|
|
244
246
|
"aria-hidden": !0,
|
|
245
|
-
children: a && /* @__PURE__ */
|
|
247
|
+
children: a && /* @__PURE__ */ f(t, {
|
|
246
248
|
className: "h-3 w-3",
|
|
247
249
|
strokeWidth: 3
|
|
248
250
|
})
|
|
249
251
|
}),
|
|
250
|
-
/* @__PURE__ */
|
|
252
|
+
/* @__PURE__ */ p("div", {
|
|
251
253
|
className: "min-w-0 flex-1",
|
|
252
|
-
children: [/* @__PURE__ */
|
|
254
|
+
children: [/* @__PURE__ */ f("div", {
|
|
253
255
|
className: e("truncate", a && "font-medium"),
|
|
254
256
|
children: n.label
|
|
255
|
-
}), n.description && /* @__PURE__ */
|
|
257
|
+
}), n.description && /* @__PURE__ */ f("div", {
|
|
256
258
|
className: "mt-0.5 truncate text-xs text-fg-subtle",
|
|
257
259
|
children: n.description
|
|
258
260
|
})]
|
|
259
261
|
}),
|
|
260
|
-
n.trailing && /* @__PURE__ */
|
|
262
|
+
n.trailing && /* @__PURE__ */ f("span", {
|
|
261
263
|
className: "shrink-0 text-xs text-fg-subtle",
|
|
262
264
|
children: n.trailing
|
|
263
265
|
})
|
|
@@ -268,12 +270,12 @@ var Te = (e) => e.length === 0 ? "" : e.map((e) => e.label).join(", "), Ee = (e)
|
|
|
268
270
|
]
|
|
269
271
|
})
|
|
270
272
|
}) }),
|
|
271
|
-
|
|
272
|
-
className: ae(
|
|
273
|
-
children:
|
|
273
|
+
y && /* @__PURE__ */ f("div", {
|
|
274
|
+
className: ae(b),
|
|
275
|
+
children: y
|
|
274
276
|
})
|
|
275
277
|
]
|
|
276
278
|
});
|
|
277
279
|
});
|
|
278
280
|
//#endregion
|
|
279
|
-
export {
|
|
281
|
+
export { m as MultiSelect };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("../../lib/utils.cjs"),t=require("../../node_modules/lucide-react/dist/esm/icons/chevron-down.cjs"),n=require("../../node_modules/lucide-react/dist/esm/icons/circle-x.cjs"),r=require("../_shared/form-size-tokens.cjs"),i=require("../input/utils.cjs"),ee=require("../../node_modules/use-debounce/dist/index.module.cjs"),te=require("./loading-dots.cjs"),ne=require("./panel-width.cjs");let a=require("react"),o=require("react/jsx-runtime"),s=require("@floating-ui/react");var c=(0,a.forwardRef)(function({options:c,value:l,onChange:u,variant:d,selectSize:f=`medium`,label:re,labelOption:
|
|
1
|
+
const e=require("../../lib/utils.cjs"),t=require("../../node_modules/lucide-react/dist/esm/icons/chevron-down.cjs"),n=require("../../node_modules/lucide-react/dist/esm/icons/circle-x.cjs"),r=require("../_shared/form-size-tokens.cjs"),i=require("../input/utils.cjs"),ee=require("../../node_modules/use-debounce/dist/index.module.cjs"),te=require("./loading-dots.cjs"),ne=require("./panel-width.cjs");let a=require("react"),o=require("react/jsx-runtime"),s=require("@floating-ui/react");var c=(0,a.forwardRef)(function({options:c,value:l,onChange:u,variant:d,selectSize:f=`medium`,label:re,"aria-label":ie,"aria-labelledby":ae,labelOption:oe=`appear`,help:p,placeholder:m=`선택해주세요`,hasError:h=!1,disabled:g=!1,suffix:_,trailingIcon:v,clearable:y=!1,badge:b,searchable:x=!1,searchPlaceholder:se=`검색...`,onSearchChange:S,isSearchLoading:C=!1,containerProps:ce,containerRef:le,className:ue=``,panelClassName:de=``,id:fe,name:pe,onLoadMore:w,hasMore:T=!1,searchDebounceMs:E=300,openOnFocus:me=!1,validateSearchQuery:he,open:ge,onOpenChange:_e,"data-testid":ve},D){let[ye,be]=(0,a.useState)(!1),O=ge??ye,k=e=>{ge===void 0&&be(e),_e?.(e)},[A,j]=(0,a.useState)(null),[M,N]=(0,a.useState)(``),P=(0,a.useRef)([]),F=(0,a.useRef)(null),[I,xe]=(0,a.useState)(null),[L,Se]=(0,a.useState)(null),R=(0,a.useId)(),Ce=(0,a.useId)(),z=fe??Ce,we=e=>`${R}-opt-${e}`,Te=A===null?void 0:we(A),B=typeof S==`function`,V=(0,a.useRef)(S);V.current=S;let Ee=E===!1||E<=0?0:E,De=ee.c(e=>{V.current?.(e)},Ee),H=(e,t)=>{B&&(t||Ee===0?(De.cancel(),V.current?.(e)):De(e))},U=c.find(e=>String(e.value)===l),Oe=(0,a.useRef)(U?.label??``);Oe.current=U?.label??``;let ke=(0,a.useRef)(H);ke.current=H;let Ae=x&&(U!==void 0&&M===U.label||U===void 0&&l!==``&&M!==``),W=(0,a.useMemo)(()=>{if(!x||B||M.length===0||Ae)return c;let e=M.toLowerCase();return c.filter(t=>t.label.toLowerCase().includes(e))},[c,x,B,M,Ae]),{refs:G,floatingStyles:je,context:K}=(0,s.useFloating)({open:O,onOpenChange:k,placement:`bottom-start`,whileElementsMounted:s.autoUpdate,middleware:[(0,s.offset)(4),(0,s.flip)({padding:8}),(0,s.shift)({padding:8}),(0,s.size)({apply({rects:e,elements:t,availableHeight:n,availableWidth:r}){Object.assign(t.floating.style,{minWidth:`${e.reference.width}px`,maxWidth:`${ne.computeSelectPanelMaxWidth(e.reference.width,r)}px`,maxHeight:`${Math.min(n,320)}px`})},padding:8})]}),{getReferenceProps:Me,getFloatingProps:Ne,getItemProps:Pe}=(0,s.useInteractions)([(0,s.useClick)(K,{enabled:!g&&!x}),(0,s.useDismiss)(K),(0,s.useRole)(K,{role:`listbox`}),(0,s.useListNavigation)(K,{listRef:P,activeIndex:A,onNavigate:j,virtual:x,loop:!0}),(0,s.useTypeahead)(K,{listRef:{current:W.map(e=>e.label)},activeIndex:A,onMatch:j,enabled:!x})]),Fe=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(O){if(Fe.current=!0,x){let e=Oe.current;N(e),e!==``&&requestAnimationFrame(()=>{F.current?.select()})}}else N(``),j(null),Fe.current&&ke.current(``,!0)},[O,x,B]),(0,a.useEffect)(()=>{if(!O||!w||!T||!I||!L)return;let e=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&!C&&w()},{root:L,rootMargin:`0px 0px 80px 0px`});return e.observe(I),()=>e.disconnect()},[O,w,T,C,I,L]);let q=e=>{u(e),k(!1)},Ie=e=>{e.stopPropagation(),u(``),N(``)},Le=e=>{x||!y||g||!J||O||(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),u(``))},Re=e=>{let t=e.target.value;he&&!he(t)||(t!==M&&(L&&(L.scrollTop=0),j(null)),N(t),H(t,!1),O||k(!0))},ze=e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`&&A!==null){e.preventDefault();let t=W[A];t&&!t.disabled&&q(String(t.value));return}(e.key===`Backspace`||e.key===`Delete`)&&U&&(!O||M===``)&&(e.preventDefault(),u(``))}},Be=oe===`sustain`||oe===`appear`&&!!U,J=!!U,Ve=U?U.label:m,He=O?M:U?.label??``,Ue=r.SLOT_GAP_CLASS[f],Y=r.SLOT_CHILD_ICON_CLASS[f],We=r.SLOT_BADGE_TEXT_CLASS[f],X=r.SLOT_ICON_SIZE_CLASS[f],Ge=r.CHEVRON_SIZE_CLASS[f],Ke=i.getInputVariantClasses(d,h,g,f),Z=i.getInputTrailingIconColor(h,g,J||O),Q=r.CONTROL_TEXT_CLASS[f],$=g?`text-fg-disabled`:h?`text-fg-danger`:J?`text-fg-default`:`text-fg-subtle`;return(0,o.jsxs)(`div`,{ref:le,className:e.cn(i.getInputContainerClasses(),`min-w-0`),...ce,children:[Be&&re&&(0,o.jsx)(`label`,{className:i.getInputLabelClasses(d,h),htmlFor:z,children:re}),x?(0,o.jsxs)(`div`,{ref:e=>{G.setReference(e)},...Me({onClick:()=>{g||(F.current?.focus(),O||k(!0))}}),role:`presentation`,"aria-expanded":void 0,"aria-controls":void 0,"aria-haspopup":void 0,className:e.cn(Ke,`flex w-full min-w-0 items-center`,Ue,d!==`box`&&`focus-within:border-primary`,d!==`box`&&d!==`line`&&`focus-within:ring-control focus-within:ring-primary`,g?`cursor-not-allowed`:`cursor-text`,ue),children:[(0,o.jsx)(`input`,{ref:e=>{F.current=e,typeof D==`function`?D(e):D&&(D.current=e)},id:z,type:`text`,role:`combobox`,"aria-label":ie,"aria-labelledby":ae,readOnly:!O,disabled:g,"aria-haspopup":`listbox`,"aria-expanded":O,"aria-controls":O?R:void 0,"aria-activedescendant":Te,"aria-autocomplete":`list`,"data-testid":ve,value:He,placeholder:U?se:m,onChange:Re,onKeyDown:ze,onFocus:()=>{me&&!g&&!O&&k(!0)},className:e.cn(`min-w-0 flex-1 truncate bg-transparent text-left outline-hidden placeholder:text-fg-subtle`,Q,$,g&&`cursor-not-allowed`)}),_&&(0,o.jsx)(`span`,{className:e.cn(`shrink-0 whitespace-nowrap`,Q,Z),children:_}),v&&(0,o.jsx)(`span`,{className:e.cn(`flex shrink-0 items-center`,Z,Y),children:v}),C&&(0,o.jsx)(te.LoadingDots,{className:e.cn(`shrink-0 text-fg-subtle`,X)}),y&&!g&&J&&(0,o.jsx)(`button`,{type:`button`,tabIndex:-1,onClick:Ie,"aria-label":`선택 지우기`,className:e.cn(`flex shrink-0 cursor-pointer items-center rounded`,Z,`hover:text-fg-default focus:outline-hidden focus-visible:ring-input-clear focus-visible:ring-input-clear-ring`),children:(0,o.jsx)(n.CircleX,{className:X,strokeWidth:1.5,"aria-hidden":!0})}),b&&(0,o.jsx)(`span`,{className:e.cn(`flex shrink-0 items-center`,Y,We),children:b}),(0,o.jsx)(t.ChevronDown,{className:e.cn(`shrink-0 transition-transform`,Ge,Z,O&&`rotate-180`),strokeWidth:1.5,"aria-hidden":!0})]}):(0,o.jsxs)(`button`,{ref:e=>{G.setReference(e),typeof D==`function`?D(e):D&&(D.current=e)},id:z,type:`button`,disabled:g,"aria-haspopup":`listbox`,"aria-expanded":O,"aria-controls":O?R:void 0,"aria-activedescendant":Te,"data-testid":ve,...Me({onKeyDown:Le}),"aria-label":ie,"aria-labelledby":ae,className:e.cn(Ke,`flex w-full min-w-0 items-center`,Ue,g?`cursor-not-allowed`:`cursor-pointer`,ue),children:[(0,o.jsx)(`span`,{className:e.cn(`min-w-0 flex-1 truncate text-left`,Q,$),children:Ve}),_&&(0,o.jsx)(`span`,{className:e.cn(`shrink-0 whitespace-nowrap`,Q,Z),children:_}),v&&(0,o.jsx)(`span`,{className:e.cn(`flex shrink-0 items-center`,Z,Y),children:v}),y&&!g&&J&&(0,o.jsx)(`span`,{role:`button`,tabIndex:-1,onClick:Ie,"aria-label":`선택 지우기`,className:e.cn(`flex shrink-0 cursor-pointer items-center`,Z,`hover:text-fg-default`),children:(0,o.jsx)(n.CircleX,{className:X,strokeWidth:1.5,"aria-hidden":!0})}),b&&(0,o.jsx)(`span`,{className:e.cn(`flex shrink-0 items-center`,Y,We),children:b}),(0,o.jsx)(t.ChevronDown,{className:e.cn(`shrink-0 transition-transform`,Ge,Z,O&&`rotate-180`),strokeWidth:1.5,"aria-hidden":!0})]}),pe&&(0,o.jsx)(`input`,{type:`hidden`,name:pe,value:l}),O&&(0,o.jsx)(s.FloatingPortal,{children:(0,o.jsx)(s.FloatingFocusManager,{context:K,modal:!1,initialFocus:x?-1:0,children:(0,o.jsx)(`div`,{ref:G.setFloating,id:R,style:je,...Ne(),className:e.cn(`z-floating overflow-hidden rounded-surface border border-border-subtle bg-bg-surface shadow-overlay`,de),children:(0,o.jsxs)(`div`,{ref:Se,className:`max-h-72 overflow-y-auto py-1`,children:[W.length===0?(0,o.jsx)(`div`,{className:`px-3 py-4 text-center text-sm text-fg-subtle`,children:C?`검색 중...`:`옵션이 없어요`}):W.map((t,n)=>{let r=String(t.value)===l,i=A===n;return(0,o.jsxs)(`div`,{id:we(n),ref:e=>{P.current[n]=e},role:`option`,"aria-selected":r,"aria-disabled":t.disabled||void 0,tabIndex:i?0:-1,...Pe({onClick:()=>{t.disabled||q(String(t.value))},onKeyDown:e=>{t.disabled||(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),q(String(t.value)))}}),className:e.cn(`flex cursor-pointer items-start gap-3 px-3 py-2 text-sm transition-colors`,t.disabled?`cursor-not-allowed text-fg-disabled`:r?e.cn(`font-medium text-primary-fg`,i?`bg-primary-subtle`:`bg-primary-subtle/60 hover:bg-primary-subtle/80`):i?`bg-bg-subtle text-fg-default`:`text-fg-default hover:bg-bg-subtle`),children:[(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,o.jsx)(`div`,{className:`truncate`,children:t.label}),t.description&&(0,o.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-fg-subtle`,children:t.description})]}),t.trailing&&(0,o.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:t.trailing})]},String(t.value))}),w&&T&&(0,o.jsx)(`div`,{ref:xe,"aria-hidden":!0,className:`flex items-center justify-center px-3 py-3 text-fg-subtle`,children:C&&(0,o.jsx)(te.LoadingDots,{})})]})})})}),p&&(0,o.jsx)(`div`,{className:i.getInputHelpClasses(h),children:p})]})});exports.Select=c;
|