@oneplatformdev/ui 0.0.1-beta.104 → 0.0.1-beta.105

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.
@@ -9,7 +9,7 @@ import "../Command/Command.mjs";
9
9
  import "@oneplatformdev/utils";
10
10
  import "@oneplatformdev/hooks";
11
11
  import "lucide-react";
12
- import { C as c } from "../Combobox-B9bMpp7r.js";
12
+ import { C as c } from "../Combobox-Dv_LBsW2.js";
13
13
  export {
14
14
  c as Combobox
15
15
  };
@@ -5,11 +5,19 @@ export interface ComboboxOption {
5
5
  label: string;
6
6
  items?: ComboboxOption[];
7
7
  }
8
- export interface ComboboxPropsOnMountParams {
8
+ export interface ComboboxCallbackStateParams {
9
+ options: ComboboxOption[];
9
10
  setOptions: Dispatch<SetStateAction<ComboboxOption[]>>;
11
+ selectedOption?: ComboboxOption;
12
+ setSelectedOption: Dispatch<SetStateAction<ComboboxOption | undefined>>;
10
13
  search: string;
14
+ setSearch: Dispatch<SetStateAction<string>>;
11
15
  open: boolean;
12
16
  setOpen: Dispatch<SetStateAction<boolean>>;
17
+ loading: boolean;
18
+ setLoading: Dispatch<SetStateAction<boolean>>;
19
+ isEmptyList: boolean;
20
+ isSearchedEmptyList: boolean;
13
21
  }
14
22
  export interface IComboboxOptionsNodeProps {
15
23
  value?: string;
@@ -32,9 +40,11 @@ export interface ComboboxProps {
32
40
  /** Command Empty list label*/
33
41
  emptyLabel?: string;
34
42
  /** Command Empty list action */
35
- emptyAction?: ((params: ComboboxPropsOnMountParams) => ReactNode) | ReactNode;
43
+ emptyAction?: ((params: ComboboxCallbackStateParams) => ReactNode) | ReactNode;
36
44
  /** Command Input footer action */
37
- commandInputAction?: ((params: ComboboxPropsOnMountParams) => ReactNode) | ReactNode;
45
+ commandInputAction?: ((params: ComboboxCallbackStateParams) => ReactNode) | ReactNode;
46
+ /** Command List first element action */
47
+ listHeadAction?: ((params: ComboboxCallbackStateParams) => ReactNode) | ReactNode;
38
48
  /** Callback for load data on start component */
39
- onMount?: (params: ComboboxPropsOnMountParams) => Promise<void>;
49
+ onMount?: (params: ComboboxCallbackStateParams) => Promise<void>;
40
50
  }
@@ -20,7 +20,7 @@ import "../Card/Card.mjs";
20
20
  import "../Carousel/Carousel.mjs";
21
21
  import "../Checkbox/Checkbox.mjs";
22
22
  import "@radix-ui/react-collapsible";
23
- import { a as no } from "../Combobox-B9bMpp7r.js";
23
+ import { a as no } from "../Combobox-Dv_LBsW2.js";
24
24
  import "../Command/Command.mjs";
25
25
  import "../DropdownMenu/DropdownMenu.mjs";
26
26
  import "../Table/Table.mjs";
@@ -3,7 +3,7 @@ import "../Button/Button.mjs";
3
3
  import "../Button/buttonVariants.mjs";
4
4
  import "react";
5
5
  import "../Collapsible/Collapsible.mjs";
6
- import { c as a, b as e } from "../Combobox-B9bMpp7r.js";
6
+ import { c as a, b as e } from "../Combobox-Dv_LBsW2.js";
7
7
  import "lucide-react";
8
8
  import "@oneplatformdev/utils";
9
9
  export {
@@ -1,4 +1,4 @@
1
- import { C as m } from "../Combobox-B9bMpp7r.js";
1
+ import { C as m } from "../Combobox-Dv_LBsW2.js";
2
2
  export {
3
3
  m as Combobox
4
4
  };
@@ -0,0 +1,323 @@
1
+ import { jsxs as c, jsx as e, Fragment as G } from "react/jsx-runtime";
2
+ import { forwardRef as S, useState as v, useRef as Y, useEffect as Z, useCallback as x, useMemo as I, useLayoutEffect as $ } from "react";
3
+ import { LoadingMask as ee } from "./LoadingMask/LoadingMask.mjs";
4
+ import "./LoadingMask/RenderLoadingMask.mjs";
5
+ import { Popover as te, PopoverTrigger as oe, PopoverContent as re } from "./Popover/Popover.mjs";
6
+ import { Button as _ } from "./Button/Button.mjs";
7
+ import "./Button/buttonVariants.mjs";
8
+ import { CommandItem as H, Command as ne, CommandInput as ae, CommandList as ie, CommandGroup as le, CommandEmpty as R } from "./Command/Command.mjs";
9
+ import { cn as p } from "@oneplatformdev/utils";
10
+ import { useDebounceCallback as se } from "@oneplatformdev/hooks";
11
+ import { Check as ce, ChevronDownIcon as me, X as pe, ChevronsUpDown as de } from "lucide-react";
12
+ import { Collapsible as ue, CollapsibleTrigger as he, CollapsibleContent as fe } from "./Collapsible/Collapsible.mjs";
13
+ import "./Accordion/Accordion.mjs";
14
+ import "./Alert/Alert.mjs";
15
+ import "./AlertDialog/AlertDialogRoot.mjs";
16
+ import "recharts";
17
+ import "./Chart/Chart.mjs";
18
+ import "./Sidebar/Sidebar.mjs";
19
+ import "@radix-ui/react-aspect-ratio";
20
+ import "./Avatar/Avatar.mjs";
21
+ import "./Badge/badgeVariants.mjs";
22
+ import "./Breadcrumb/Breadcrumb.mjs";
23
+ import "./ButtonIcon/ButtonIcon.mjs";
24
+ import "./ButtonIcon/buttonIconVariants.mjs";
25
+ import "./Calendar/Calendar.mjs";
26
+ import "./Card/Card.mjs";
27
+ import "./Carousel/Carousel.mjs";
28
+ import "./Checkbox/Checkbox.mjs";
29
+ import "@radix-ui/react-collapsible";
30
+ import "./DropdownMenu/DropdownMenu.mjs";
31
+ import "./Table/Table.mjs";
32
+ import "@tanstack/react-table";
33
+ import "./DatePicker/DatePicker.mjs";
34
+ import "./Dialog/Dialog.mjs";
35
+ import "./Drawer/Drawer.mjs";
36
+ import "./Form/Form.mjs";
37
+ import "./FormInput/FormInput.mjs";
38
+ import "./Select/SelectRoot.mjs";
39
+ import "./Textarea/Textarea.mjs";
40
+ import "./Separator/Separator.mjs";
41
+ import "./HoverCard/HoverCard.mjs";
42
+ import "./Input/Input.mjs";
43
+ import "./InputOTP/InputOTP.mjs";
44
+ import "./Label/Label.mjs";
45
+ import "./Label/labelVariants.mjs";
46
+ import "./LoadingProgress/loadingProgressVariants.mjs";
47
+ import "./Menubar/Menubar.mjs";
48
+ import "./NavigationMenu/NavigationMenu.mjs";
49
+ import "./NavigationMenu/navigationMenuVariants.mjs";
50
+ import "./Pagination/Pagination.mjs";
51
+ import "./Progress/Progress.mjs";
52
+ import "./RadioGroup/RadioGroup.mjs";
53
+ import "react-resizable-panels";
54
+ import "./ScrollArea/ScrollArea.mjs";
55
+ import "./Sheet/Sheet.mjs";
56
+ import "./Slider/Slider.mjs";
57
+ import "next-themes";
58
+ import "sonner";
59
+ import "./Switch/Switch.mjs";
60
+ import "./Tabs/TabsRoot.mjs";
61
+ import "./Toast/Toast.mjs";
62
+ import "./Toggle/Toggle.mjs";
63
+ import "./ToggleGroup/ToggleGroup.mjs";
64
+ import "./Tooltip/TooltipRoot.mjs";
65
+ import "./Dropzone/Dropzone.mjs";
66
+ const ge = 8, U = S((i, m) => {
67
+ const { children: t, setOpen: d, option: o, onChangeOption: a, value: u = "", deep: n = 0 } = i;
68
+ return /* @__PURE__ */ c(
69
+ H,
70
+ {
71
+ ref: m,
72
+ value: o.value,
73
+ onSelect: () => {
74
+ u === o.value ? a == null || a({ value: "", label: "" }) : a == null || a(o), d(!1);
75
+ },
76
+ style: {
77
+ paddingLeft: (n + 1) * ge
78
+ },
79
+ children: [
80
+ t,
81
+ /* @__PURE__ */ e(
82
+ "span",
83
+ {
84
+ className: p(
85
+ "overflow-hidden whitespace-wrap text-ellipsis line-clamp-2"
86
+ ),
87
+ children: o.label
88
+ }
89
+ ),
90
+ /* @__PURE__ */ e(
91
+ ce,
92
+ {
93
+ className: p(
94
+ "ml-auto",
95
+ u === o.value ? "opacity-100" : "opacity-0"
96
+ )
97
+ }
98
+ )
99
+ ]
100
+ },
101
+ o.value
102
+ );
103
+ }), V = S((i, m) => {
104
+ var u;
105
+ const { option: t, deep: d = 0 } = i, [o, a] = v(!0);
106
+ return (u = t == null ? void 0 : t.items) != null && u.length ? /* @__PURE__ */ c(
107
+ ue,
108
+ {
109
+ ref: m,
110
+ open: o,
111
+ onOpenChange: a,
112
+ "data-opened": o,
113
+ className: p("group/collapsible"),
114
+ children: [
115
+ /* @__PURE__ */ e(U, { ...i, children: /* @__PURE__ */ e(he, { asChild: !0, children: /* @__PURE__ */ c(
116
+ _,
117
+ {
118
+ onClick: (n) => {
119
+ n == null || n.preventDefault(), n == null || n.stopPropagation(), a((h) => !h);
120
+ },
121
+ type: "button",
122
+ variant: "ghost",
123
+ size: "sm",
124
+ className: p("aspect-square size-6", "transition-transform"),
125
+ children: [
126
+ /* @__PURE__ */ e(
127
+ me,
128
+ {
129
+ className: p(
130
+ "!size-5",
131
+ "transition-transform",
132
+ o && "rotate-180"
133
+ )
134
+ }
135
+ ),
136
+ /* @__PURE__ */ e("span", { className: "sr-only", children: "Toggle" })
137
+ ]
138
+ }
139
+ ) }) }),
140
+ /* @__PURE__ */ e(fe, { children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-0", children: t == null ? void 0 : t.items.map((n) => /* @__PURE__ */ e(
141
+ V,
142
+ {
143
+ ...i,
144
+ deep: d + 1,
145
+ option: n
146
+ },
147
+ n.value
148
+ )) }) })
149
+ ]
150
+ }
151
+ ) : /* @__PURE__ */ e(U, { ...i, ref: m });
152
+ }), be = S((i, m) => {
153
+ const { options: t = [], ...d } = i;
154
+ return /* @__PURE__ */ e("div", { ref: m, className: "flex flex-col gap-0", children: t.map((o) => /* @__PURE__ */ e(V, { ...d, option: o }, o.value)) });
155
+ }), kt = S(
156
+ (i, m) => {
157
+ var q;
158
+ const {
159
+ value: t,
160
+ onChange: d,
161
+ placeholder: o,
162
+ disabled: a,
163
+ searchLabel: u = "Type to search...",
164
+ fetchOptions: n,
165
+ options: h,
166
+ emptyLabel: M = "No options",
167
+ emptyAction: w,
168
+ commandInputAction: L,
169
+ listHeadAction: N,
170
+ onMount: O
171
+ } = i, E = Y(!1), [g, P] = v(!1), [f, k] = v(""), [l, D] = v([]), [C, T] = v(), [s, b] = v(!1);
172
+ Z(() => {
173
+ h != null && h.length && D(h);
174
+ }, [h]);
175
+ const W = async () => {
176
+ g || (j(), k(""));
177
+ }, j = x(async (r) => {
178
+ b(!0);
179
+ try {
180
+ const z = await n(r);
181
+ D(z);
182
+ } catch (z) {
183
+ console.error("Unexpected error while get option:", z);
184
+ } finally {
185
+ b(!1);
186
+ }
187
+ }, []), X = se(j, 1e3, {
188
+ leading: !1,
189
+ trailing: !0
190
+ }), J = x((r) => {
191
+ b(!0), k(r), X(r);
192
+ }, []), B = x((r) => {
193
+ d(r.value), T(r), b(!1);
194
+ }, []), K = x(() => {
195
+ B({ value: "", label: "" }), T(void 0), b(!1);
196
+ }, []), F = I(() => !!f && !l.length && !s, [s, l.length, f]), A = I(() => !l.length && !s, [s, l.length, f]), y = I(() => ({
197
+ options: l,
198
+ setOptions: D,
199
+ selectedOption: C,
200
+ setSelectedOption: T,
201
+ search: f || "",
202
+ setSearch: k,
203
+ open: g,
204
+ setOpen: P,
205
+ loading: s,
206
+ setLoading: b,
207
+ isEmptyList: A,
208
+ isSearchedEmptyList: F
209
+ }), [s, g, l, f, C, A, F]), Q = x(() => {
210
+ if (!O) {
211
+ E.current = !0;
212
+ return;
213
+ }
214
+ O(y).finally(() => {
215
+ E.current = !0;
216
+ });
217
+ }, [y, O]);
218
+ return $(() => (Q(), () => {
219
+ E.current = !1;
220
+ }), []), /* @__PURE__ */ e("div", { className: "w-full", ref: m, children: /* @__PURE__ */ c(
221
+ te,
222
+ {
223
+ open: g,
224
+ onOpenChange: (r) => {
225
+ P(r), r && W();
226
+ },
227
+ children: [
228
+ /* @__PURE__ */ e(oe, { asChild: !0, className: "border-input", children: /* @__PURE__ */ c(
229
+ _,
230
+ {
231
+ variant: "outline",
232
+ role: "combobox",
233
+ size: "lg",
234
+ "aria-expanded": g,
235
+ className: p(
236
+ "w-full justify-between font-normal text-sm bg-transparent relative p-3",
237
+ "border border-border",
238
+ g && "border-2 outline-none ring-1 ring-ring",
239
+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
240
+ ),
241
+ disabled: a,
242
+ children: [
243
+ /* @__PURE__ */ e("span", { className: "truncate max-w-[calc(100%-1.5rem)] overflow-hidden whitespace-nowrap", children: t ? ((q = l.find((r) => r.value === t)) == null ? void 0 : q.label) || (C == null ? void 0 : C.label) : /* @__PURE__ */ e("span", { className: "text-gray-400", children: o }) }),
244
+ t ? /* @__PURE__ */ e(
245
+ "div",
246
+ {
247
+ className: p(
248
+ "absolute top-0 right-1",
249
+ "flex items-center justify-center",
250
+ "w-9 aspect-square [&_svg]:size-5",
251
+ "opacity-50 cursor-pointer hover:opacity-100"
252
+ ),
253
+ onClick: (r) => {
254
+ r.stopPropagation(), K();
255
+ },
256
+ children: /* @__PURE__ */ e(pe, {})
257
+ }
258
+ ) : /* @__PURE__ */ e(de, { className: "opacity-50 w-4 h-4" })
259
+ ]
260
+ }
261
+ ) }),
262
+ /* @__PURE__ */ e(
263
+ re,
264
+ {
265
+ className: "w-[var(--radix-popper-anchor-width)] max-w-none p-0",
266
+ align: "start",
267
+ children: /* @__PURE__ */ c(ne, { shouldFilter: !1, children: [
268
+ /* @__PURE__ */ e(
269
+ ae,
270
+ {
271
+ placeholder: u,
272
+ value: f,
273
+ onValueChange: J
274
+ }
275
+ ),
276
+ typeof L == "function" ? L(y) : L,
277
+ /* @__PURE__ */ e(ie, { children: /* @__PURE__ */ c(
278
+ le,
279
+ {
280
+ className: p(!l.length && "p-0 shadow-none"),
281
+ children: [
282
+ s && /* @__PURE__ */ e(ee, { fullWidth: !0 }),
283
+ !s && !!f && /* @__PURE__ */ e(G, { children: w ? /* @__PURE__ */ c(R, { className: "flex flex-col gap-3 py-5 px-3 items-center", children: [
284
+ /* @__PURE__ */ e("span", { children: M }),
285
+ typeof w == "function" ? w(y) : w
286
+ ] }) : /* @__PURE__ */ e(R, { children: M }) }),
287
+ !s && /* @__PURE__ */ c(G, { children: [
288
+ !!l.length && N && /* @__PURE__ */ e(
289
+ H,
290
+ {
291
+ asChild: !0,
292
+ className: "w-full",
293
+ children: typeof N == "function" ? N(y) : N
294
+ },
295
+ "combobox-list-head-action"
296
+ ),
297
+ /* @__PURE__ */ e(
298
+ be,
299
+ {
300
+ value: t,
301
+ options: l,
302
+ onChangeOption: B,
303
+ setOpen: P
304
+ }
305
+ )
306
+ ] })
307
+ ]
308
+ }
309
+ ) })
310
+ ] })
311
+ }
312
+ )
313
+ ]
314
+ }
315
+ ) });
316
+ }
317
+ );
318
+ export {
319
+ kt as C,
320
+ U as a,
321
+ V as b,
322
+ be as c
323
+ };
@@ -1,7 +1,7 @@
1
1
  import { jsx as o } from "react/jsx-runtime";
2
2
  import { FormControl as a } from "../Form/Form.mjs";
3
3
  import { FormRenderControl as b } from "../Form/FormRenderControl.mjs";
4
- import { C as p } from "../Combobox-B9bMpp7r.js";
4
+ import { C as p } from "../Combobox-Dv_LBsW2.js";
5
5
  const x = (m) => {
6
6
  const { form: n, label: e, name: t, ...C } = m;
7
7
  return /* @__PURE__ */ o(
package/index.mjs CHANGED
@@ -20,7 +20,7 @@ import { Carousel as go, CarouselContent as xo, CarouselItem as fo, CarouselNext
20
20
  import { ChartContainer as To, ChartLegend as Do, ChartLegendContent as co, ChartStyle as Mo, ChartTooltip as Po, ChartTooltipContent as Ao } from "./Chart/Chart.mjs";
21
21
  import { Checkbox as wo, CheckboxLabel as ho } from "./Checkbox/Checkbox.mjs";
22
22
  import { Collapsible as Fo, CollapsibleContent as Lo, CollapsibleTrigger as Ro } from "./Collapsible/Collapsible.mjs";
23
- import { C as Go } from "./Combobox-B9bMpp7r.js";
23
+ import { C as Go } from "./Combobox-Dv_LBsW2.js";
24
24
  import { Command as Ho, CommandDialog as No, CommandEmpty as Vo, CommandGroup as yo, CommandInput as Eo, CommandItem as Oo, CommandList as zo, CommandSeparator as _o, CommandShortcut as Uo } from "./Command/Command.mjs";
25
25
  import { DataTable as jo } from "./DataTable/DataTable.mjs";
26
26
  import { DatePicker as Jo } from "./DatePicker/DatePicker.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneplatformdev/ui",
3
- "version": "0.0.1-beta.104",
3
+ "version": "0.0.1-beta.105",
4
4
  "description": "UI React Components.",
5
5
  "author": "One Platform Development Team",
6
6
  "keywords": [
@@ -1,305 +0,0 @@
1
- import { jsxs as l, jsx as e, Fragment as W } from "react/jsx-runtime";
2
- import f, { forwardRef as y, useState as X, useRef as H, useEffect as J, useCallback as b, useMemo as K, useLayoutEffect as Q } from "react";
3
- import { LoadingMask as Y } from "./LoadingMask/LoadingMask.mjs";
4
- import "./LoadingMask/RenderLoadingMask.mjs";
5
- import { Popover as Z, PopoverTrigger as $, PopoverContent as ee } from "./Popover/Popover.mjs";
6
- import { Button as R } from "./Button/Button.mjs";
7
- import "./Button/buttonVariants.mjs";
8
- import { CommandItem as te, Command as oe, CommandInput as re, CommandList as ae, CommandGroup as ne, CommandEmpty as F } from "./Command/Command.mjs";
9
- import { cn as p } from "@oneplatformdev/utils";
10
- import { useDebounceCallback as ie } from "@oneplatformdev/hooks";
11
- import { Check as se, ChevronDownIcon as le, X as pe, ChevronsUpDown as me } from "lucide-react";
12
- import { Collapsible as ce, CollapsibleTrigger as de, CollapsibleContent as ue } from "./Collapsible/Collapsible.mjs";
13
- import "./Accordion/Accordion.mjs";
14
- import "./Alert/Alert.mjs";
15
- import "./AlertDialog/AlertDialogRoot.mjs";
16
- import "recharts";
17
- import "./Chart/Chart.mjs";
18
- import "./Sidebar/Sidebar.mjs";
19
- import "@radix-ui/react-aspect-ratio";
20
- import "./Avatar/Avatar.mjs";
21
- import "./Badge/badgeVariants.mjs";
22
- import "./Breadcrumb/Breadcrumb.mjs";
23
- import "./ButtonIcon/ButtonIcon.mjs";
24
- import "./ButtonIcon/buttonIconVariants.mjs";
25
- import "./Calendar/Calendar.mjs";
26
- import "./Card/Card.mjs";
27
- import "./Carousel/Carousel.mjs";
28
- import "./Checkbox/Checkbox.mjs";
29
- import "@radix-ui/react-collapsible";
30
- import "./DropdownMenu/DropdownMenu.mjs";
31
- import "./Table/Table.mjs";
32
- import "@tanstack/react-table";
33
- import "./DatePicker/DatePicker.mjs";
34
- import "./Dialog/Dialog.mjs";
35
- import "./Drawer/Drawer.mjs";
36
- import "./Form/Form.mjs";
37
- import "./FormInput/FormInput.mjs";
38
- import "./Select/SelectRoot.mjs";
39
- import "./Textarea/Textarea.mjs";
40
- import "./Separator/Separator.mjs";
41
- import "./HoverCard/HoverCard.mjs";
42
- import "./Input/Input.mjs";
43
- import "./InputOTP/InputOTP.mjs";
44
- import "./Label/Label.mjs";
45
- import "./Label/labelVariants.mjs";
46
- import "./LoadingProgress/loadingProgressVariants.mjs";
47
- import "./Menubar/Menubar.mjs";
48
- import "./NavigationMenu/NavigationMenu.mjs";
49
- import "./NavigationMenu/navigationMenuVariants.mjs";
50
- import "./Pagination/Pagination.mjs";
51
- import "./Progress/Progress.mjs";
52
- import "./RadioGroup/RadioGroup.mjs";
53
- import "react-resizable-panels";
54
- import "./ScrollArea/ScrollArea.mjs";
55
- import "./Sheet/Sheet.mjs";
56
- import "./Slider/Slider.mjs";
57
- import "next-themes";
58
- import "sonner";
59
- import "./Switch/Switch.mjs";
60
- import "./Tabs/TabsRoot.mjs";
61
- import "./Toast/Toast.mjs";
62
- import "./Toggle/Toggle.mjs";
63
- import "./ToggleGroup/ToggleGroup.mjs";
64
- import "./Tooltip/TooltipRoot.mjs";
65
- import "./Dropzone/Dropzone.mjs";
66
- const he = 8, _ = y((i, s) => {
67
- const { children: t, setOpen: m, option: o, onChangeOption: n, value: c = "", deep: a = 0 } = i;
68
- return /* @__PURE__ */ l(
69
- te,
70
- {
71
- ref: s,
72
- value: o.value,
73
- onSelect: () => {
74
- c === o.value ? n == null || n({ value: "", label: "" }) : n == null || n(o), m(!1);
75
- },
76
- style: {
77
- paddingLeft: (a + 1) * he
78
- },
79
- children: [
80
- t,
81
- /* @__PURE__ */ e(
82
- "span",
83
- {
84
- className: p(
85
- "overflow-hidden whitespace-wrap text-ellipsis line-clamp-2"
86
- ),
87
- children: o.label
88
- }
89
- ),
90
- /* @__PURE__ */ e(
91
- se,
92
- {
93
- className: p(
94
- "ml-auto",
95
- c === o.value ? "opacity-100" : "opacity-0"
96
- )
97
- }
98
- )
99
- ]
100
- },
101
- o.value
102
- );
103
- }), q = y((i, s) => {
104
- var c;
105
- const { option: t, deep: m = 0 } = i, [o, n] = X(!0);
106
- return (c = t == null ? void 0 : t.items) != null && c.length ? /* @__PURE__ */ l(
107
- ce,
108
- {
109
- ref: s,
110
- open: o,
111
- onOpenChange: n,
112
- "data-opened": o,
113
- className: p("group/collapsible"),
114
- children: [
115
- /* @__PURE__ */ e(_, { ...i, children: /* @__PURE__ */ e(de, { asChild: !0, children: /* @__PURE__ */ l(
116
- R,
117
- {
118
- onClick: (a) => {
119
- a == null || a.preventDefault(), a == null || a.stopPropagation(), n((d) => !d);
120
- },
121
- type: "button",
122
- variant: "ghost",
123
- size: "sm",
124
- className: p("aspect-square size-6", "transition-transform"),
125
- children: [
126
- /* @__PURE__ */ e(
127
- le,
128
- {
129
- className: p(
130
- "!size-5",
131
- "transition-transform",
132
- o && "rotate-180"
133
- )
134
- }
135
- ),
136
- /* @__PURE__ */ e("span", { className: "sr-only", children: "Toggle" })
137
- ]
138
- }
139
- ) }) }),
140
- /* @__PURE__ */ e(ue, { children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-0", children: t == null ? void 0 : t.items.map((a) => /* @__PURE__ */ e(
141
- q,
142
- {
143
- ...i,
144
- deep: m + 1,
145
- option: a
146
- },
147
- a.value
148
- )) }) })
149
- ]
150
- }
151
- ) : /* @__PURE__ */ e(_, { ...i, ref: s });
152
- }), fe = y((i, s) => {
153
- const { options: t = [], ...m } = i;
154
- return /* @__PURE__ */ e("div", { ref: s, className: "flex flex-col gap-0", children: t.map((o) => /* @__PURE__ */ e(q, { ...m, option: o }, o.value)) });
155
- }), Dt = y(
156
- (i, s) => {
157
- var j;
158
- const {
159
- value: t,
160
- onChange: m,
161
- placeholder: o,
162
- disabled: n,
163
- searchLabel: c = "Type to search...",
164
- fetchOptions: a,
165
- options: d,
166
- emptyLabel: L = "No options",
167
- emptyAction: g,
168
- commandInputAction: w,
169
- onMount: T
170
- } = i, N = H(!1), [u, v] = f.useState(!1), [C, k] = f.useState(""), [S, x] = f.useState([]), [O, E] = f.useState(), [P, h] = f.useState(!1);
171
- J(() => {
172
- d != null && d.length && x(d);
173
- }, [d]);
174
- const A = async () => {
175
- u || (z(), k(""));
176
- }, z = b(async (r) => {
177
- h(!0);
178
- try {
179
- const D = await a(r);
180
- x(D);
181
- } catch (D) {
182
- console.error("Unexpected error while get option:", D);
183
- } finally {
184
- h(!1);
185
- }
186
- }, []), B = ie(z, 1e3, {
187
- leading: !1,
188
- trailing: !0
189
- }), G = b((r) => {
190
- h(!0), k(r), B(r);
191
- }, []), I = b((r) => {
192
- m(r.value), E(r), h(!1);
193
- }, []), U = b(() => {
194
- I({ value: "", label: "" }), E(void 0), h(!1);
195
- }, []), M = K(() => ({
196
- setOptions: x,
197
- search: C || "",
198
- open: u,
199
- setOpen: v
200
- }), []), V = b(() => {
201
- if (!T) {
202
- N.current = !0;
203
- return;
204
- }
205
- T({ setOptions: x, search: C || "", open: u, setOpen: v }).finally(
206
- () => {
207
- N.current = !0;
208
- }
209
- );
210
- }, []);
211
- return Q(() => (V(), () => {
212
- N.current = !1;
213
- }), []), /* @__PURE__ */ e("div", { className: "w-full", ref: s, children: /* @__PURE__ */ l(
214
- Z,
215
- {
216
- open: u,
217
- onOpenChange: (r) => {
218
- v(r), r && A();
219
- },
220
- children: [
221
- /* @__PURE__ */ e($, { asChild: !0, className: "border-input", children: /* @__PURE__ */ l(
222
- R,
223
- {
224
- variant: "outline",
225
- role: "combobox",
226
- size: "lg",
227
- "aria-expanded": u,
228
- className: p(
229
- "w-full justify-between font-normal text-sm bg-transparent relative p-3",
230
- "border border-border",
231
- u && "border-2 outline-none ring-1 ring-ring",
232
- "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
233
- ),
234
- disabled: n,
235
- children: [
236
- /* @__PURE__ */ e("span", { className: "truncate max-w-[calc(100%-1.5rem)] overflow-hidden whitespace-nowrap", children: t ? ((j = S.find((r) => r.value === t)) == null ? void 0 : j.label) || (O == null ? void 0 : O.label) : /* @__PURE__ */ e("span", { className: "text-gray-400", children: o }) }),
237
- t ? /* @__PURE__ */ e(
238
- "div",
239
- {
240
- className: p(
241
- "absolute top-0 right-1",
242
- "flex items-center justify-center",
243
- "w-9 aspect-square [&_svg]:size-5",
244
- "opacity-50 cursor-pointer hover:opacity-100"
245
- ),
246
- onClick: (r) => {
247
- r.stopPropagation(), U();
248
- },
249
- children: /* @__PURE__ */ e(pe, {})
250
- }
251
- ) : /* @__PURE__ */ e(me, { className: "opacity-50 w-4 h-4" })
252
- ]
253
- }
254
- ) }),
255
- /* @__PURE__ */ e(
256
- ee,
257
- {
258
- className: "w-[var(--radix-popper-anchor-width)] max-w-none p-0",
259
- align: "start",
260
- children: /* @__PURE__ */ l(oe, { shouldFilter: !1, children: [
261
- /* @__PURE__ */ e(
262
- re,
263
- {
264
- placeholder: c,
265
- value: C,
266
- onValueChange: G
267
- }
268
- ),
269
- typeof w == "function" ? w(M) : w,
270
- /* @__PURE__ */ e(ae, { children: /* @__PURE__ */ l(
271
- ne,
272
- {
273
- className: p(!S.length && "p-0 shadow-none"),
274
- children: [
275
- P && /* @__PURE__ */ e(Y, { fullWidth: !0 }),
276
- !P && !!C && /* @__PURE__ */ e(W, { children: g ? /* @__PURE__ */ l(F, { className: "flex flex-col gap-3 py-5 px-3 items-center", children: [
277
- /* @__PURE__ */ e("span", { children: L }),
278
- typeof g == "function" ? g(M) : g
279
- ] }) : /* @__PURE__ */ e(F, { children: L }) }),
280
- !P && /* @__PURE__ */ e(
281
- fe,
282
- {
283
- value: t,
284
- options: S,
285
- onChangeOption: I,
286
- setOpen: v
287
- }
288
- )
289
- ]
290
- }
291
- ) })
292
- ] })
293
- }
294
- )
295
- ]
296
- }
297
- ) });
298
- }
299
- );
300
- export {
301
- Dt as C,
302
- _ as a,
303
- q as b,
304
- fe as c
305
- };