@forsyteco/product-ui 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{active-element-history-BJ1HYFpN.mjs → active-element-history-B7wA4w4L.mjs} +3 -3
- package/dist/autocomplete/autocomplete.d.ts +87 -0
- package/dist/autocomplete/autocomplete.d.ts.map +1 -0
- package/dist/autocomplete/index.cjs +1 -0
- package/dist/autocomplete/index.d.ts +4 -0
- package/dist/autocomplete/index.d.ts.map +1 -0
- package/dist/autocomplete/index.mjs +4 -0
- package/dist/autocomplete/types.d.ts +7 -0
- package/dist/autocomplete/types.d.ts.map +1 -0
- package/dist/autocomplete-DqDP76nV.mjs +318 -0
- package/dist/autocomplete-DuGKfbQn.js +1 -0
- package/dist/avatar/index.mjs +1 -1
- package/dist/{avatar-CN9vtSKm.mjs → avatar-Br4ih6PQ.mjs} +2 -2
- package/dist/breadcrumb/index.cjs +1 -1
- package/dist/breadcrumb/index.mjs +1 -1
- package/dist/{breadcrumb-Bz_JVFcb.mjs → breadcrumb-C81R8CJz.mjs} +2 -2
- package/dist/{breadcrumb-y_RB72EG.js → breadcrumb-DJGlCCR1.js} +1 -1
- package/dist/{bugs-bn44RJ1Q.mjs → bugs-g7aYPtcD.mjs} +1 -1
- package/dist/calendar/calendar.d.ts.map +1 -1
- package/dist/calendar/index.cjs +1 -1
- package/dist/calendar/index.mjs +1 -1
- package/dist/{calendar-CAySGYDy.mjs → calendar-DQdo9vO-.mjs} +1058 -993
- package/dist/calendar-v2NOtsdr.js +1 -0
- package/dist/chevron-right-CIgI-iLu.js +1 -0
- package/dist/{chevron-right-DcjcIxI2.mjs → chevron-right-Ck5BtE5n.mjs} +11 -6
- package/dist/combobox/combobox.d.ts +72 -17
- package/dist/combobox/combobox.d.ts.map +1 -1
- package/dist/combobox/index.cjs +1 -1
- package/dist/combobox/index.d.ts +2 -1
- package/dist/combobox/index.d.ts.map +1 -1
- package/dist/combobox/index.mjs +1 -1
- package/dist/combobox/types.d.ts +7 -0
- package/dist/combobox/types.d.ts.map +1 -0
- package/dist/combobox-B1h2hn6a.js +4 -0
- package/dist/combobox-BHLjk9D9.mjs +293 -0
- package/dist/combobox-DxpuSWuM.js +1 -0
- package/dist/{combobox-Dyen_KC6.mjs → combobox-Umb1ZW9S.mjs} +358 -408
- package/dist/data-table/components/table-body.d.ts.map +1 -1
- package/dist/date-picker/date-picker.d.ts.map +1 -1
- package/dist/{description-CAH1nOgr.mjs → description-hiFZ303Y.mjs} +2 -2
- package/dist/dialog/index.mjs +1 -1
- package/dist/{dialog-nGcnK6o1.mjs → dialog-Cs7TMa7R.mjs} +53 -53
- package/dist/disclosure/index.cjs +1 -1
- package/dist/disclosure/index.mjs +1 -1
- package/dist/{disclosure-CA45jH3I.mjs → disclosure-DOWglOHy.mjs} +8 -12
- package/dist/{disclosure-CGxPdR-8.js → disclosure-qEQ_kll8.js} +1 -1
- package/dist/dropdown-menu/index.cjs +1 -1
- package/dist/dropdown-menu/index.mjs +1 -1
- package/dist/{dropdown-menu-Bj9ftuBZ.mjs → dropdown-menu--aGYYbJi.mjs} +22 -30
- package/dist/dropdown-menu-B9fTvSZe.js +1 -0
- package/dist/{element-movement-B3AVr940.mjs → element-movement-Bad2OqSj.mjs} +4 -4
- package/dist/floating-C1n3e5u7.js +1 -0
- package/dist/{floating-dEgEvBqv.mjs → floating-DQ2M2ViQ.mjs} +429 -425
- package/dist/{focus-management-DUVCz_zm.mjs → focus-management-BGuC9pKE.mjs} +2 -2
- package/dist/{form-fields-CXtJvVC5.mjs → form-fields-Bpp9kTvo.mjs} +2 -2
- package/dist/{frozen-Cpa22rmr.mjs → frozen-CXF36eio.mjs} +2 -2
- package/dist/{hidden-Blo8kfIB.mjs → hidden-H5tOTsXH.mjs} +1 -1
- package/dist/{index-CuNisU0H.mjs → index-Dh75VhI6.mjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +769 -776
- package/dist/{keyboard-Bi11Rnr0.mjs → keyboard-BzaAKRwG.mjs} +1 -1
- package/dist/{label-DAaE-vxI.mjs → label--pGndX3z.mjs} +3 -3
- package/dist/listbox/index.cjs +1 -1
- package/dist/listbox/index.mjs +1 -1
- package/dist/{listbox-DZ4v8TYt.mjs → listbox-3DAgC6_y.mjs} +17 -21
- package/dist/{listbox-BIwbzCji.js → listbox-cpJossI7.js} +1 -1
- package/dist/{open-closed-BkH8ZC7H.mjs → open-closed-Be5nD5U2.mjs} +4 -4
- package/dist/popover/index.cjs +1 -1
- package/dist/popover/index.mjs +1 -1
- package/dist/{popover-BAm_8SCx.mjs → popover-CZO6Afya.mjs} +22 -22
- package/dist/{popover-B5-dVDC1.js → popover-CysmX396.js} +1 -1
- package/dist/{portal-BaBdcS83.mjs → portal-D-TZOwvF.mjs} +6 -6
- package/dist/radio-group/index.cjs +1 -1
- package/dist/radio-group/index.mjs +1 -1
- package/dist/{radio-group-CTf6mrDs.mjs → radio-group-BIQWXrVI.mjs} +8 -8
- package/dist/{radio-group-d2V69c7t.js → radio-group-CbQAsBFv.js} +1 -1
- package/dist/sonner/index.cjs +1 -1
- package/dist/sonner/index.mjs +1 -1
- package/dist/{sonner-CuPfwlK5.js → sonner-BRjN2nJD.js} +1 -1
- package/dist/{sonner-Ce9PJbum.mjs → sonner-Cgc0p6ph.mjs} +3 -5
- package/dist/switch/index.cjs +1 -1
- package/dist/switch/index.mjs +1 -1
- package/dist/{switch-DqAuXwa2.js → switch-D0OrcI50.js} +1 -1
- package/dist/{switch-DKcD0IFH.mjs → switch-Eoi1pTsi.mjs} +13 -13
- package/dist/tabs/index.cjs +1 -1
- package/dist/tabs/index.mjs +1 -1
- package/dist/{tabs-DLqfQ301.mjs → tabs-Cufnu60W.mjs} +15 -15
- package/dist/{tabs-X4sPQQYs.js → tabs-TTkcVq-Q.js} +1 -1
- package/dist/transition/index.mjs +1 -1
- package/dist/{transition-B0MGuDho.mjs → transition-B4KhhkrB.mjs} +4 -4
- package/dist/{transition-D0HuUd2-.mjs → transition-Dfxdl8Si.mjs} +1 -1
- package/dist/{use-event-listener-BjXsgSkG.mjs → use-event-listener-BUA2xXRr.mjs} +1 -1
- package/dist/{use-inert-others-BCB16FKE.mjs → use-inert-others-CgSXXC-d.mjs} +3 -3
- package/dist/{use-is-mounted-COmayWN0.mjs → use-is-mounted-DJc35WXO.mjs} +1 -1
- package/dist/{use-resolve-button-type-637wy6MK.mjs → use-resolve-button-type-BhmWA6Dl.mjs} +2 -2
- package/dist/{use-sync-refs-B0fmGxD4.mjs → use-sync-refs-CDCE8QtA.mjs} +2 -2
- package/dist/{use-tab-direction-BTonGsg0.mjs → use-tab-direction-tJsn3ckX.mjs} +8 -8
- package/dist/{use-text-value-BMXU9EaO.mjs → use-text-value-BKEvykNe.mjs} +2 -2
- package/dist/{use-tree-walker-D25YXIMY.mjs → use-tree-walker-CHC6ccbq.mjs} +2 -2
- package/dist/useFocusRing-BM96K_1O.js +1 -0
- package/dist/useFocusRing-Df1NuOsX.mjs +497 -0
- package/package.json +32 -22
- package/dist/calendar-BIhWkTtG.js +0 -1
- package/dist/chevron-right-HwlOajQy.js +0 -1
- package/dist/combobox-Cm_xVD4l.js +0 -4
- package/dist/dropdown-menu-BPMdVlet.js +0 -1
- package/dist/floating-CTjRm9bt.js +0 -1
- package/dist/useFocusRing-Bocdsy5M.mjs +0 -446
- package/dist/useFocusRing-uXUSOfAR.js +0 -1
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { jsx as o, Fragment as T } from "react/jsx-runtime";
|
|
2
|
+
import * as c from "react";
|
|
3
|
+
import { c as u } from "./tailwind-DtaLkIY8.mjs";
|
|
4
|
+
import { H as j, U as A, B as U, k as z, a as W } from "./combobox-Umb1ZW9S.mjs";
|
|
5
|
+
const F = c.createContext(null);
|
|
6
|
+
function g() {
|
|
7
|
+
const e = c.useContext(F);
|
|
8
|
+
if (!e) throw new globalThis.Error("Combobox.* must be used within <Combobox.Root>.");
|
|
9
|
+
return e;
|
|
10
|
+
}
|
|
11
|
+
function Z(e, t) {
|
|
12
|
+
const l = t.trim().toLowerCase();
|
|
13
|
+
return l ? e.label.toLowerCase().includes(l) : !0;
|
|
14
|
+
}
|
|
15
|
+
function q({
|
|
16
|
+
options: e,
|
|
17
|
+
value: t,
|
|
18
|
+
defaultValue: l = null,
|
|
19
|
+
onChange: s,
|
|
20
|
+
query: n,
|
|
21
|
+
defaultQuery: i = "",
|
|
22
|
+
onQueryChange: a,
|
|
23
|
+
placeholder: r = "Select an option…",
|
|
24
|
+
disabled: f = !1,
|
|
25
|
+
invalid: p = !1,
|
|
26
|
+
clearable: v = !0,
|
|
27
|
+
filterFn: b,
|
|
28
|
+
renderOption: m,
|
|
29
|
+
className: V,
|
|
30
|
+
children: B
|
|
31
|
+
}) {
|
|
32
|
+
const [H, M] = c.useState(l), C = t !== void 0 ? t : H, y = c.useCallback(
|
|
33
|
+
(d) => {
|
|
34
|
+
t === void 0 && M(d), s?.(d);
|
|
35
|
+
},
|
|
36
|
+
[s, t]
|
|
37
|
+
), [Q, S] = c.useState(i), x = n !== void 0 ? n : Q, k = c.useCallback(
|
|
38
|
+
(d) => {
|
|
39
|
+
n === void 0 && S(d), a?.(d);
|
|
40
|
+
},
|
|
41
|
+
[a, n]
|
|
42
|
+
), [N, w] = c.useState(!1), O = c.useRef(null), h = b ?? Z, L = c.useMemo(() => x.trim() ? e.filter((d) => h(d, x)) : e, [e, x, h]), E = c.useMemo(
|
|
43
|
+
() => ({
|
|
44
|
+
options: e,
|
|
45
|
+
filteredOptions: L,
|
|
46
|
+
value: C,
|
|
47
|
+
setValue: y,
|
|
48
|
+
query: x,
|
|
49
|
+
setQuery: k,
|
|
50
|
+
placeholder: r,
|
|
51
|
+
disabled: f,
|
|
52
|
+
invalid: p,
|
|
53
|
+
isOpen: N,
|
|
54
|
+
setIsOpen: w,
|
|
55
|
+
clearable: v,
|
|
56
|
+
rootRef: O,
|
|
57
|
+
filterFn: h,
|
|
58
|
+
renderOption: m
|
|
59
|
+
}),
|
|
60
|
+
[
|
|
61
|
+
e,
|
|
62
|
+
L,
|
|
63
|
+
C,
|
|
64
|
+
y,
|
|
65
|
+
x,
|
|
66
|
+
k,
|
|
67
|
+
r,
|
|
68
|
+
f,
|
|
69
|
+
p,
|
|
70
|
+
N,
|
|
71
|
+
v,
|
|
72
|
+
h,
|
|
73
|
+
m
|
|
74
|
+
]
|
|
75
|
+
);
|
|
76
|
+
return /* @__PURE__ */ o(F.Provider, { value: E, children: /* @__PURE__ */ o("div", { ref: O, className: u("relative", V), children: /* @__PURE__ */ o(
|
|
77
|
+
W,
|
|
78
|
+
{
|
|
79
|
+
by: "id",
|
|
80
|
+
value: C,
|
|
81
|
+
onChange: (d) => {
|
|
82
|
+
y(d), w(!1);
|
|
83
|
+
},
|
|
84
|
+
onClose: () => w(!1),
|
|
85
|
+
disabled: f,
|
|
86
|
+
nullable: !0,
|
|
87
|
+
children: B
|
|
88
|
+
}
|
|
89
|
+
) }) });
|
|
90
|
+
}
|
|
91
|
+
function D({
|
|
92
|
+
className: e,
|
|
93
|
+
...t
|
|
94
|
+
}) {
|
|
95
|
+
return /* @__PURE__ */ o(
|
|
96
|
+
"label",
|
|
97
|
+
{
|
|
98
|
+
...t,
|
|
99
|
+
className: u("mb-1 block text-sm font-medium text-foreground", e)
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
function G({
|
|
104
|
+
className: e,
|
|
105
|
+
...t
|
|
106
|
+
}) {
|
|
107
|
+
return /* @__PURE__ */ o("div", { ...t, className: u("relative", e) });
|
|
108
|
+
}
|
|
109
|
+
function J({
|
|
110
|
+
className: e,
|
|
111
|
+
displayValue: t,
|
|
112
|
+
onValueTextChange: l,
|
|
113
|
+
onFocus: s,
|
|
114
|
+
onBlur: n,
|
|
115
|
+
openOnFocus: i = !0,
|
|
116
|
+
...a
|
|
117
|
+
}) {
|
|
118
|
+
const r = g(), f = t ?? ((b) => b?.label ?? ""), p = a.placeholder ?? r.placeholder, v = {
|
|
119
|
+
...a,
|
|
120
|
+
placeholder: p,
|
|
121
|
+
displayValue: f
|
|
122
|
+
};
|
|
123
|
+
return /* @__PURE__ */ o(
|
|
124
|
+
z,
|
|
125
|
+
{
|
|
126
|
+
...v,
|
|
127
|
+
className: u(
|
|
128
|
+
"w-full rounded-md border bg-background py-2 pl-3 pr-20 text-base leading-5 text-foreground",
|
|
129
|
+
"border-input focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background",
|
|
130
|
+
r.invalid && "border-destructive focus:ring-destructive",
|
|
131
|
+
r.disabled && "cursor-not-allowed opacity-50",
|
|
132
|
+
e
|
|
133
|
+
),
|
|
134
|
+
onChange: (b) => {
|
|
135
|
+
const m = b.target.value;
|
|
136
|
+
r.setQuery(m), l?.(m), r.disabled || r.setIsOpen(!0);
|
|
137
|
+
},
|
|
138
|
+
onFocus: (b) => {
|
|
139
|
+
!r.disabled && i && r.setIsOpen(!0), s?.(b);
|
|
140
|
+
},
|
|
141
|
+
onBlur: n
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
function K({
|
|
146
|
+
className: e,
|
|
147
|
+
"aria-label": t,
|
|
148
|
+
onClick: l,
|
|
149
|
+
...s
|
|
150
|
+
}) {
|
|
151
|
+
const n = g();
|
|
152
|
+
return n.clearable && !!n.value && !n.disabled ? /* @__PURE__ */ o(
|
|
153
|
+
"button",
|
|
154
|
+
{
|
|
155
|
+
type: "button",
|
|
156
|
+
...s,
|
|
157
|
+
"aria-label": t ?? "Clear selection",
|
|
158
|
+
className: u(
|
|
159
|
+
"absolute inset-y-0 right-7 flex items-center px-2 text-muted-foreground hover:text-foreground",
|
|
160
|
+
e
|
|
161
|
+
),
|
|
162
|
+
onClick: (a) => {
|
|
163
|
+
a.preventDefault(), n.setValue(null), n.setQuery(""), n.setIsOpen(!1), l?.(a);
|
|
164
|
+
},
|
|
165
|
+
children: /* @__PURE__ */ o("svg", { className: "h-4 w-4", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ o(
|
|
166
|
+
"path",
|
|
167
|
+
{
|
|
168
|
+
fillRule: "evenodd",
|
|
169
|
+
d: "M10 8.586 4.293 2.879A1 1 0 1 0 2.879 4.293L8.586 10l-5.707 5.707a1 1 0 1 0 1.414 1.414L10 11.414l5.707 5.707a1 1 0 0 0 1.414-1.414L11.414 10l5.707-5.707A1 1 0 0 0 15.707 2.88L10 8.586Z",
|
|
170
|
+
clipRule: "evenodd"
|
|
171
|
+
}
|
|
172
|
+
) })
|
|
173
|
+
}
|
|
174
|
+
) : null;
|
|
175
|
+
}
|
|
176
|
+
function X({
|
|
177
|
+
className: e,
|
|
178
|
+
children: t,
|
|
179
|
+
onClick: l,
|
|
180
|
+
...s
|
|
181
|
+
}) {
|
|
182
|
+
const n = g();
|
|
183
|
+
return /* @__PURE__ */ o(
|
|
184
|
+
U,
|
|
185
|
+
{
|
|
186
|
+
...s,
|
|
187
|
+
"aria-label": s["aria-label"] ?? "Toggle options",
|
|
188
|
+
className: u(
|
|
189
|
+
"absolute inset-y-0 right-0 flex items-center pr-2 text-muted-foreground",
|
|
190
|
+
n.disabled && "cursor-not-allowed opacity-50",
|
|
191
|
+
e
|
|
192
|
+
),
|
|
193
|
+
onClick: l,
|
|
194
|
+
children: t ?? /* @__PURE__ */ o("svg", { className: "h-5 w-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ o("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) })
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
function Y({
|
|
199
|
+
className: e,
|
|
200
|
+
children: t,
|
|
201
|
+
...l
|
|
202
|
+
}) {
|
|
203
|
+
const s = g();
|
|
204
|
+
if (s.disabled) return null;
|
|
205
|
+
const n = s.filteredOptions.length > 0;
|
|
206
|
+
return /* @__PURE__ */ o(
|
|
207
|
+
A,
|
|
208
|
+
{
|
|
209
|
+
...l,
|
|
210
|
+
anchor: "bottom start",
|
|
211
|
+
className: u(
|
|
212
|
+
"z-10 max-h-60 w-[var(--input-width)] overflow-auto rounded-md bg-background py-1 text-base shadow-lg",
|
|
213
|
+
"invisible empty:invisible data-open:visible",
|
|
214
|
+
"ring-1 ring-border focus:outline-none",
|
|
215
|
+
e
|
|
216
|
+
),
|
|
217
|
+
children: t || (n ? s.filteredOptions.map((i) => /* @__PURE__ */ o(I, { option: i }, i.id)) : /* @__PURE__ */ o(R, {}))
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
function R({ className: e, ...t }) {
|
|
222
|
+
return /* @__PURE__ */ o(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
...t,
|
|
226
|
+
className: u("cursor-default select-none px-4 py-2 text-muted-foreground", e),
|
|
227
|
+
children: "Nothing found."
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
function I({
|
|
232
|
+
option: e,
|
|
233
|
+
className: t,
|
|
234
|
+
children: l,
|
|
235
|
+
...s
|
|
236
|
+
}) {
|
|
237
|
+
const n = g();
|
|
238
|
+
return /* @__PURE__ */ o(
|
|
239
|
+
j,
|
|
240
|
+
{
|
|
241
|
+
...s,
|
|
242
|
+
value: e,
|
|
243
|
+
disabled: e.disabled,
|
|
244
|
+
className: ({
|
|
245
|
+
active: i,
|
|
246
|
+
selected: a,
|
|
247
|
+
disabled: r
|
|
248
|
+
}) => u(
|
|
249
|
+
"relative select-none py-2 pl-3 pr-4",
|
|
250
|
+
r ? "cursor-not-allowed opacity-50" : "cursor-default",
|
|
251
|
+
i ? "bg-accent text-accent-foreground" : "text-foreground",
|
|
252
|
+
a && "font-medium",
|
|
253
|
+
typeof t == "function" ? t({ active: i, selected: a, disabled: r }) : t
|
|
254
|
+
),
|
|
255
|
+
children: ({
|
|
256
|
+
active: i,
|
|
257
|
+
selected: a,
|
|
258
|
+
disabled: r
|
|
259
|
+
}) => {
|
|
260
|
+
const f = l || (n.renderOption ? n.renderOption(e, { active: i, selected: a, disabled: r }) : e.label);
|
|
261
|
+
return /* @__PURE__ */ o(T, { children: f });
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
function _({
|
|
267
|
+
className: e,
|
|
268
|
+
...t
|
|
269
|
+
}) {
|
|
270
|
+
return /* @__PURE__ */ o("p", { ...t, className: u("mt-1 text-sm text-muted-foreground", e) });
|
|
271
|
+
}
|
|
272
|
+
function $({
|
|
273
|
+
className: e,
|
|
274
|
+
...t
|
|
275
|
+
}) {
|
|
276
|
+
return /* @__PURE__ */ o("p", { ...t, className: u("mt-1 text-sm text-destructive", e) });
|
|
277
|
+
}
|
|
278
|
+
const ne = {
|
|
279
|
+
Root: q,
|
|
280
|
+
Label: D,
|
|
281
|
+
Control: G,
|
|
282
|
+
Input: J,
|
|
283
|
+
ClearButton: K,
|
|
284
|
+
ToggleButton: X,
|
|
285
|
+
Options: Y,
|
|
286
|
+
Option: I,
|
|
287
|
+
Empty: R,
|
|
288
|
+
Hint: _,
|
|
289
|
+
Error: $
|
|
290
|
+
};
|
|
291
|
+
export {
|
|
292
|
+
ne as C
|
|
293
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),E=require("react"),a=require("./tailwind-D2U2F80P.js"),g=require("./combobox-B1h2hn6a.js");function H(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,s.get?s:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const c=H(E),L=c.createContext(null);function p(){const e=c.useContext(L);if(!e)throw new globalThis.Error("Combobox.* must be used within <Combobox.Root>.");return e}function _(e,t){const o=t.trim().toLowerCase();return o?e.label.toLowerCase().includes(o):!0}function z({options:e,value:t,defaultValue:o=null,onChange:s,query:r,defaultQuery:u="",onQueryChange:i,placeholder:l="Select an option…",disabled:f=!1,invalid:v=!1,clearable:h=!0,filterFn:b,renderOption:x,className:V,children:S}){const[B,M]=c.useState(o),y=t!==void 0?t:B,C=c.useCallback(d=>{t===void 0&&M(d),s?.(d)},[s,t]),[q,Q]=c.useState(u),m=r!==void 0?r:q,O=c.useCallback(d=>{r===void 0&&Q(d),i?.(d)},[i,r]),[k,w]=c.useState(!1),N=c.useRef(null),j=b??_,R=c.useMemo(()=>m.trim()?e.filter(d=>j(d,m)):e,[e,m,j]),T=c.useMemo(()=>({options:e,filteredOptions:R,value:y,setValue:C,query:m,setQuery:O,placeholder:l,disabled:f,invalid:v,isOpen:k,setIsOpen:w,clearable:h,rootRef:N,filterFn:j,renderOption:x}),[e,R,y,C,m,O,l,f,v,k,h,j,x]);return n.jsx(L.Provider,{value:T,children:n.jsx("div",{ref:N,className:a.cn("relative",V),children:n.jsx(g.Ht,{by:"id",value:y,onChange:d=>{C(d),w(!1)},onClose:()=>w(!1),disabled:f,nullable:!0,children:S})})})}function A({className:e,...t}){return n.jsx("label",{...t,className:a.cn("mb-1 block text-sm font-medium text-foreground",e)})}function D({className:e,...t}){return n.jsx("div",{...t,className:a.cn("relative",e)})}function U({className:e,displayValue:t,onValueTextChange:o,onFocus:s,onBlur:r,openOnFocus:u=!0,...i}){const l=p(),f=t??(b=>b?.label??""),v=i.placeholder??l.placeholder,h={...i,placeholder:v,displayValue:f};return n.jsx(g.ko,{...h,className:a.cn("w-full rounded-md border bg-background py-2 pl-3 pr-20 text-base leading-5 text-foreground","border-input focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background",l.invalid&&"border-destructive focus:ring-destructive",l.disabled&&"cursor-not-allowed opacity-50",e),onChange:b=>{const x=b.target.value;l.setQuery(x),o?.(x),l.disabled||l.setIsOpen(!0)},onFocus:b=>{!l.disabled&&u&&l.setIsOpen(!0),s?.(b)},onBlur:r})}function W({className:e,"aria-label":t,onClick:o,...s}){const r=p();return r.clearable&&!!r.value&&!r.disabled?n.jsx("button",{type:"button",...s,"aria-label":t??"Clear selection",className:a.cn("absolute inset-y-0 right-7 flex items-center px-2 text-muted-foreground hover:text-foreground",e),onClick:i=>{i.preventDefault(),r.setValue(null),r.setQuery(""),r.setIsOpen(!1),o?.(i)},children:n.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{fillRule:"evenodd",d:"M10 8.586 4.293 2.879A1 1 0 1 0 2.879 4.293L8.586 10l-5.707 5.707a1 1 0 1 0 1.414 1.414L10 11.414l5.707 5.707a1 1 0 0 0 1.414-1.414L11.414 10l5.707-5.707A1 1 0 0 0 15.707 2.88L10 8.586Z",clipRule:"evenodd"})})}):null}function Z({className:e,children:t,onClick:o,...s}){const r=p();return n.jsx(g.Bo,{...s,"aria-label":s["aria-label"]??"Toggle options",className:a.cn("absolute inset-y-0 right-0 flex items-center pr-2 text-muted-foreground",r.disabled&&"cursor-not-allowed opacity-50",e),onClick:o,children:t??n.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})}function G({className:e,children:t,...o}){const s=p();if(s.disabled)return null;const r=s.filteredOptions.length>0;return n.jsx(g.Uo,{...o,anchor:"bottom start",className:a.cn("z-10 max-h-60 w-[var(--input-width)] overflow-auto rounded-md bg-background py-1 text-base shadow-lg","invisible empty:invisible data-open:visible","ring-1 ring-border focus:outline-none",e),children:t||(r?s.filteredOptions.map(u=>n.jsx(I,{option:u},u.id)):n.jsx(F,{}))})}function F({className:e,...t}){return n.jsx("div",{...t,className:a.cn("cursor-default select-none px-4 py-2 text-muted-foreground",e),children:"Nothing found."})}function I({option:e,className:t,children:o,...s}){const r=p();return n.jsx(g.Ho,{...s,value:e,disabled:e.disabled,className:({active:u,selected:i,disabled:l})=>a.cn("relative select-none py-2 pl-3 pr-4",l?"cursor-not-allowed opacity-50":"cursor-default",u?"bg-accent text-accent-foreground":"text-foreground",i&&"font-medium",typeof t=="function"?t({active:u,selected:i,disabled:l}):t),children:({active:u,selected:i,disabled:l})=>{const f=o||(r.renderOption?r.renderOption(e,{active:u,selected:i,disabled:l}):e.label);return n.jsx(n.Fragment,{children:f})}})}function J({className:e,...t}){return n.jsx("p",{...t,className:a.cn("mt-1 text-sm text-muted-foreground",e)})}function K({className:e,...t}){return n.jsx("p",{...t,className:a.cn("mt-1 text-sm text-destructive",e)})}const X={Root:z,Label:A,Control:D,Input:U,ClearButton:W,ToggleButton:Z,Options:G,Option:I,Empty:F,Hint:J,Error:K};exports.Combobox=X;
|