laif-ds 0.1.94 → 0.1.95

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.
@@ -1,5 +1,8 @@
1
1
  "use client";
2
- var e = { exports: {} };
2
+ import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
3
+ import { __require as t } from "../node_modules/eventemitter3/index2.js";
4
+ var r = t();
5
+ const m = /* @__PURE__ */ e(r);
3
6
  export {
4
- e as __module
7
+ m as default
5
8
  };
@@ -1,8 +1,5 @@
1
1
  "use client";
2
- import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
3
- import { __require as t } from "../node_modules/eventemitter3/index2.js";
4
- var r = t();
5
- const m = /* @__PURE__ */ e(r);
2
+ var e = { exports: {} };
6
3
  export {
7
- m as default
4
+ e as __module
8
5
  };
@@ -1,17 +1,17 @@
1
1
  "use client";
2
- import { jsxs as l, jsx as e } from "react/jsx-runtime";
3
- import * as p from "react";
4
- import { useState as i, useEffect as g, useCallback as B } from "react";
5
- import { useDebounce as re } from "../../hooks/use-debounce.js";
6
- import { cva as le } from "../../node_modules/class-variance-authority/dist/index.js";
7
- import { cn as x } from "../../lib/utils.js";
8
- import { Label as oe } from "./label.js";
9
- import { Popover as ie, PopoverTrigger as ae, PopoverContent as ce } from "./popover.js";
10
- import { Command as de, CommandInput as fe, CommandList as me, CommandEmpty as ue, CommandGroup as M, CommandItem as U } from "./command.js";
11
- import { Icon as G } from "./icon.js";
12
- import he from "../../node_modules/lucide-react/dist/esm/icons/loader-circle.js";
13
- import pe from "../../node_modules/lucide-react/dist/esm/icons/check.js";
14
- const ge = le(
2
+ import { jsxs as s, jsx as t } from "react/jsx-runtime";
3
+ import * as h from "react";
4
+ import { useState as p, useEffect as C, useCallback as O } from "react";
5
+ import { useDebounce as te } from "../../hooks/use-debounce.js";
6
+ import { cva as ne } from "../../node_modules/class-variance-authority/dist/index.js";
7
+ import { cn as v } from "../../lib/utils.js";
8
+ import { Label as re } from "./label.js";
9
+ import { Popover as se, PopoverTrigger as ae, PopoverContent as oe } from "./popover.js";
10
+ import { Command as le, CommandInput as ie, CommandList as ce, CommandEmpty as de, CommandGroup as $, CommandItem as A } from "./command.js";
11
+ import { Icon as K } from "./icon.js";
12
+ import fe from "../../node_modules/lucide-react/dist/esm/icons/loader-circle.js";
13
+ import me from "../../node_modules/lucide-react/dist/esm/icons/check.js";
14
+ const ue = ne(
15
15
  "flex items-center justify-between whitespace-nowrap rounded-md border border-d-input bg-d-input px-3 py-2 data-[placeholder]:text-muted-foreground focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 ",
16
16
  {
17
17
  variants: {
@@ -26,141 +26,141 @@ const ge = le(
26
26
  }
27
27
  }
28
28
  );
29
- function Ie({
30
- fetcher: c,
31
- preload: m,
29
+ function _e({
30
+ fetcher: i,
31
+ preload: g,
32
32
  filterFn: S,
33
- renderOption: P,
34
- getOptionValue: a,
35
- getDisplayValue: w,
36
- notFound: X,
37
- loadingSkeleton: q,
38
- label: z,
39
- labelClassName: H,
40
- placeholder: O = "Select...",
41
- value: r = "",
42
- onChange: N,
43
- disabled: W = !1,
44
- width: u = "200px",
45
- triggerClassName: J,
46
- noResultsMessage: K,
47
- clearable: L = !0,
48
- size: Q
33
+ renderOption: M,
34
+ getOptionValue: x,
35
+ getDisplayValue: N,
36
+ notFound: B,
37
+ loadingSkeleton: G,
38
+ label: T,
39
+ labelClassName: U,
40
+ placeholder: P = "Select...",
41
+ value: c = "",
42
+ onChange: y,
43
+ disabled: z = !1,
44
+ width: w = "200px",
45
+ triggerClassName: X,
46
+ noResultsMessage: q,
47
+ clearable: R = !0,
48
+ size: H
49
49
  }) {
50
- const [o, j] = i(!1), d = u === "auto", k = p.useRef(null), I = p.useRef(null), Y = p.useRef(null), Z = p.useRef(null), [v, y] = i(!1), [b, C] = i(null), [T, R] = i(null), [D, _] = i(""), h = re(D, m ? 0 : 300), [E, F] = i([]), [n, f] = i([]), [$, V] = i(
50
+ const [a, _] = p(!1), d = w === "auto", j = h.useRef(null), L = h.useRef(null), J = h.useRef(null), Q = h.useRef(null), [o, f] = p({ loading: !1, error: null }), [E, Y] = p(""), m = te(E, g ? 0 : 300), [b, k] = p(/* @__PURE__ */ new Map()), [l, u] = p([]), [F, Z] = p(
51
51
  void 0
52
- );
53
- g(() => ((async () => {
52
+ ), D = h.useMemo(() => !c || l.length === 0 ? null : l.find((e) => x(e) === c) || null, [c, l, x]);
53
+ C(() => ((async () => {
54
54
  try {
55
- if (y(!0), C(null), m) {
56
- const s = await c("");
57
- F(s), f(s);
58
- } else {
59
- const s = await c(r);
60
- f(s);
61
- }
62
- } catch (s) {
63
- C(
64
- s instanceof Error ? s.message : "Failed to fetch options"
65
- );
55
+ f({ loading: !0, error: null });
56
+ const r = g ? "__preload__" : "", n = await i("");
57
+ k((I) => new Map(I).set(r, n)), u(n);
58
+ } catch (r) {
59
+ f({
60
+ loading: !1,
61
+ error: r instanceof Error ? r.message : "Failed to fetch options"
62
+ });
66
63
  } finally {
67
- y(!1);
64
+ f((r) => ({ ...r, loading: !1 }));
68
65
  }
69
66
  })(), () => {
70
- f([]), F([]);
71
- }), [c, r, m]), g(() => {
72
- if (o)
73
- if (m)
74
- if (h) {
75
- const t = E.filter(
76
- (s) => S ? S(s, h) : String(w(s)).toLowerCase().includes(h.toLowerCase())
67
+ u([]), k(/* @__PURE__ */ new Map());
68
+ }), [i, g]), C(() => {
69
+ if (a)
70
+ if (g) {
71
+ const e = b.get("__preload__") || [];
72
+ if (m) {
73
+ const r = e.filter(
74
+ (n) => S ? S(n, m) : String(N(n)).toLowerCase().includes(m.toLowerCase())
77
75
  );
78
- f(t);
76
+ u(r);
79
77
  } else
80
- f(E);
81
- else
82
- (async () => {
83
- try {
84
- y(!0), C(null);
85
- const s = await c(h);
86
- f(s);
87
- } catch (s) {
88
- C(
89
- s instanceof Error ? s.message : "Failed to fetch options"
90
- );
91
- } finally {
92
- y(!1);
93
- }
94
- })();
78
+ u(e);
79
+ } else {
80
+ const e = m || "";
81
+ if (b.has(e)) {
82
+ const r = b.get(e);
83
+ u(r);
84
+ } else
85
+ (async () => {
86
+ try {
87
+ f({ loading: !0, error: null });
88
+ const n = await i(m);
89
+ k((I) => new Map(I).set(e, n)), u(n);
90
+ } catch (n) {
91
+ f({
92
+ loading: !1,
93
+ error: n instanceof Error ? n.message : "Failed to fetch options"
94
+ });
95
+ } finally {
96
+ f((n) => ({ ...n, loading: !1 }));
97
+ }
98
+ })();
99
+ }
95
100
  }, [
96
- o,
97
- h,
101
+ a,
98
102
  m,
103
+ g,
99
104
  S,
100
- E,
101
- w
102
- ]), g(() => {
103
- if (r && n.length > 0) {
104
- const t = n.find((s) => a(s) === r);
105
- R(t || null);
106
- } else r || R(null);
107
- }, [r, n, a]), g(() => {
108
- o && k.current && k.current.focus();
109
- }, [o]), g(() => {
110
- if (o && I.current && d) {
111
- const t = I.current.getBoundingClientRect();
112
- V(t.width);
105
+ b,
106
+ N,
107
+ i
108
+ ]), C(() => {
109
+ a && j.current && j.current.focus();
110
+ }, [a]), C(() => {
111
+ if (a && L.current && d) {
112
+ const e = L.current.getBoundingClientRect();
113
+ Z(e.width);
113
114
  }
114
- }, [o, d]);
115
- const ee = B(
116
- (t) => {
117
- const s = L && t === r ? "" : t, se = n.find((ne) => a(ne) === s) || null;
118
- R(se), N(s), j(!1);
115
+ }, [a, d]);
116
+ const V = O(
117
+ (e) => {
118
+ y?.(R && e === c ? "" : e), _(!1);
119
119
  },
120
- [r, N, L, n, a]
121
- ), te = B(
122
- (t) => {
123
- t.stopPropagation(), t.preventDefault(), R(null), N(""), j(!1);
120
+ [c, y, R]
121
+ ), ee = O(
122
+ (e) => {
123
+ e.stopPropagation(), e.preventDefault(), y?.(""), _(!1);
124
124
  },
125
- [N]
126
- ), A = p.useId();
127
- return /* @__PURE__ */ l(
125
+ [y]
126
+ ), W = h.useId();
127
+ return /* @__PURE__ */ s(
128
128
  "div",
129
129
  {
130
- className: x("grid grid-cols-1 space-y-1.5", d && "w-full"),
130
+ className: v("grid grid-cols-1 space-y-1.5", d && "w-full"),
131
131
  children: [
132
- z && /* @__PURE__ */ e(oe, { htmlFor: A, className: x(H, "w-fit"), children: z }),
133
- /* @__PURE__ */ e("div", { ref: Y, className: "relative", "data-slot": "async-select", children: /* @__PURE__ */ l(ie, { open: o, onOpenChange: j, children: [
134
- /* @__PURE__ */ e(ae, { asChild: !0, children: /* @__PURE__ */ e(
132
+ T && /* @__PURE__ */ t(re, { htmlFor: W, className: v(U, "w-fit"), children: T }),
133
+ /* @__PURE__ */ t("div", { ref: J, className: "relative", "data-slot": "async-select", children: /* @__PURE__ */ s(se, { open: a, onOpenChange: _, children: [
134
+ /* @__PURE__ */ t(ae, { asChild: !0, children: /* @__PURE__ */ t(
135
135
  "button",
136
136
  {
137
- id: A,
138
- ref: I,
137
+ id: W,
138
+ ref: L,
139
139
  type: "button",
140
- disabled: W,
141
- className: x(
142
- ge({ size: Q }),
140
+ disabled: z,
141
+ className: v(
142
+ ue({ size: H }),
143
143
  "!border-d-border/50 border !shadow-none",
144
- W && "cursor-not-allowed opacity-50",
145
- J,
144
+ z && "cursor-not-allowed opacity-50",
145
+ X,
146
146
  "font-normal",
147
147
  d && "w-full",
148
148
  "focus-visible:ring-d-ring focus-visible:ring-1",
149
- o && "ring-d-ring ring-1"
149
+ a && "ring-d-ring ring-1"
150
150
  ),
151
- style: d ? void 0 : { width: u },
152
- children: /* @__PURE__ */ l("div", { className: "flex w-full flex-1 items-center justify-between overflow-hidden", children: [
153
- T ? /* @__PURE__ */ e("div", { className: "min-w-0 flex-1 truncate text-left", children: w(T) }) : /* @__PURE__ */ e("span", { className: "text-d-muted-foreground truncate text-left", children: O }),
154
- /* @__PURE__ */ l("div", { className: "flex flex-shrink-0 items-center justify-end gap-1", children: [
155
- L && T && /* @__PURE__ */ e(
151
+ style: d ? void 0 : { width: w },
152
+ children: /* @__PURE__ */ s("div", { className: "flex w-full flex-1 items-center justify-between overflow-hidden", children: [
153
+ D ? /* @__PURE__ */ t("div", { className: "min-w-0 flex-1 truncate text-left", children: N(D) }) : /* @__PURE__ */ t("span", { className: "text-d-muted-foreground truncate text-left", children: P }),
154
+ /* @__PURE__ */ s("div", { className: "flex flex-shrink-0 items-center justify-end gap-1", children: [
155
+ R && D && /* @__PURE__ */ t(
156
156
  "div",
157
157
  {
158
158
  className: "border-d-input bg-d-accent cursor-pointer rounded-full p-1",
159
- onClick: te,
160
- onMouseDown: (t) => t.preventDefault(),
159
+ onClick: ee,
160
+ onMouseDown: (e) => e.preventDefault(),
161
161
  "aria-label": "Clear selection",
162
- children: /* @__PURE__ */ e(
163
- G,
162
+ children: /* @__PURE__ */ t(
163
+ K,
164
164
  {
165
165
  name: "X",
166
166
  size: "xs",
@@ -169,8 +169,8 @@ function Ie({
169
169
  )
170
170
  }
171
171
  ),
172
- /* @__PURE__ */ e(
173
- G,
172
+ /* @__PURE__ */ t(
173
+ K,
174
174
  {
175
175
  name: "ChevronsUpDown",
176
176
  size: "xs",
@@ -181,59 +181,59 @@ function Ie({
181
181
  ] })
182
182
  }
183
183
  ) }),
184
- /* @__PURE__ */ e(
185
- ce,
184
+ /* @__PURE__ */ t(
185
+ oe,
186
186
  {
187
- className: x("p-0"),
187
+ className: v("p-0"),
188
188
  style: {
189
- width: d ? $ ? `${$}px` : void 0 : typeof u == "number" ? `${u}px` : u
189
+ width: d ? F ? `${F}px` : void 0 : typeof w == "number" ? `${w}px` : w
190
190
  },
191
191
  align: "start",
192
192
  side: "bottom",
193
193
  sideOffset: 4,
194
- onWheel: (t) => t.stopPropagation(),
194
+ onWheel: (e) => e.stopPropagation(),
195
195
  avoidCollisions: !1,
196
- children: /* @__PURE__ */ l(
197
- de,
196
+ children: /* @__PURE__ */ s(
197
+ le,
198
198
  {
199
199
  shouldFilter: !1,
200
200
  className: "w-full border-none shadow-sm",
201
201
  children: [
202
- /* @__PURE__ */ e(
203
- fe,
202
+ /* @__PURE__ */ t(
203
+ ie,
204
204
  {
205
- ref: k,
206
- placeholder: O,
205
+ ref: j,
206
+ placeholder: P,
207
207
  className: "placeholder:text-d-muted-foreground",
208
- value: D,
209
- onValueChange: _
208
+ value: E,
209
+ onValueChange: Y
210
210
  }
211
211
  ),
212
- v && n.length > 0 && /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-2", children: /* @__PURE__ */ e(he, { className: "h-4 w-4 animate-spin" }) }),
213
- /* @__PURE__ */ l(me, { ref: Z, children: [
214
- b && /* @__PURE__ */ e("div", { className: "text-d-destructive p-3 text-center", children: b }),
215
- v && n.length === 0 && (q || /* @__PURE__ */ e(xe, {})),
216
- !v && !b && n.length === 0 && (X || /* @__PURE__ */ e(ue, { children: K || "No results found." })),
217
- !v && !b && n.length > 0 && /* @__PURE__ */ e(M, { children: n.map((t) => /* @__PURE__ */ e(
218
- U,
212
+ o.loading && l.length > 0 && /* @__PURE__ */ t("div", { className: "flex items-center justify-center p-2", children: /* @__PURE__ */ t(fe, { className: "h-4 w-4 animate-spin" }) }),
213
+ /* @__PURE__ */ s(ce, { ref: Q, children: [
214
+ o.error && /* @__PURE__ */ t("div", { className: "text-d-destructive p-3 text-center", children: o.error }),
215
+ o.loading && l.length === 0 && (G || /* @__PURE__ */ t(he, {})),
216
+ !o.loading && !o.error && l.length === 0 && (B || /* @__PURE__ */ t(de, { children: q || "No results found." })),
217
+ !o.loading && !o.error && l.length > 0 && /* @__PURE__ */ t($, { children: l.map((e) => /* @__PURE__ */ t(
218
+ A,
219
219
  {
220
- value: a(t),
221
- onSelect: ee,
220
+ value: x(e),
221
+ onSelect: V,
222
222
  className: "cursor-pointer",
223
- children: /* @__PURE__ */ l("div", { className: "flex w-full items-center justify-between overflow-hidden", children: [
224
- /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: P ? /* @__PURE__ */ e("div", { className: "truncate", children: P(t) }) : /* @__PURE__ */ e("span", { className: "truncate", children: w(t) }) }),
225
- /* @__PURE__ */ e(
226
- pe,
223
+ children: /* @__PURE__ */ s("div", { className: "flex w-full items-center justify-between overflow-hidden", children: [
224
+ /* @__PURE__ */ t("div", { className: "min-w-0 flex-1", children: M ? /* @__PURE__ */ t("div", { className: "truncate", children: M(e) }) : /* @__PURE__ */ t("span", { className: "truncate", children: N(e) }) }),
225
+ /* @__PURE__ */ t(
226
+ me,
227
227
  {
228
- className: x(
228
+ className: v(
229
229
  "ml-2 h-4 w-4 flex-shrink-0",
230
- r === a(t) ? "opacity-100" : "opacity-0"
230
+ c === x(e) ? "opacity-100" : "opacity-0"
231
231
  )
232
232
  }
233
233
  )
234
234
  ] })
235
235
  },
236
- a(t)
236
+ x(e)
237
237
  )) })
238
238
  ] })
239
239
  ]
@@ -246,16 +246,16 @@ function Ie({
246
246
  }
247
247
  );
248
248
  }
249
- function xe() {
250
- return /* @__PURE__ */ e(M, { children: [1, 2, 3].map((c) => /* @__PURE__ */ e(U, { disabled: !0, children: /* @__PURE__ */ l("div", { className: "flex w-full items-center gap-2", children: [
251
- /* @__PURE__ */ e("div", { className: "bg-d-secondary h-6 w-6 animate-pulse rounded-full" }),
252
- /* @__PURE__ */ l("div", { className: "flex flex-1 flex-col gap-1", children: [
253
- /* @__PURE__ */ e("div", { className: "bg-d-secondary h-4 w-24 animate-pulse rounded" }),
254
- /* @__PURE__ */ e("div", { className: "bg-d-secondary h-3 w-16 animate-pulse rounded" })
249
+ function he() {
250
+ return /* @__PURE__ */ t($, { children: [1, 2, 3].map((i) => /* @__PURE__ */ t(A, { disabled: !0, children: /* @__PURE__ */ s("div", { className: "flex w-full items-center gap-2", children: [
251
+ /* @__PURE__ */ t("div", { className: "bg-d-secondary h-6 w-6 animate-pulse rounded-full" }),
252
+ /* @__PURE__ */ s("div", { className: "flex flex-1 flex-col gap-1", children: [
253
+ /* @__PURE__ */ t("div", { className: "bg-d-secondary h-4 w-24 animate-pulse rounded" }),
254
+ /* @__PURE__ */ t("div", { className: "bg-d-secondary h-3 w-16 animate-pulse rounded" })
255
255
  ] })
256
- ] }) }, c)) });
256
+ ] }) }, i)) });
257
257
  }
258
258
  export {
259
- Ie as AsyncSelect,
260
- ge as selectTriggerVariants
259
+ _e as AsyncSelect,
260
+ ue as selectTriggerVariants
261
261
  };
package/dist/index.d.ts CHANGED
@@ -201,7 +201,7 @@ declare interface AsyncSelectProps<T> extends VariantProps<typeof selectTriggerV
201
201
  notFound?: React_2.ReactNode;
202
202
  loadingSkeleton?: React_2.ReactNode;
203
203
  value?: string;
204
- onChange: (value: string) => void;
204
+ onChange?: (value: string) => void;
205
205
  label?: string | React_2.ReactNode;
206
206
  labelClassName?: string;
207
207
  placeholder?: string;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import e from "../../_virtual/index5.js";
2
+ import e from "../../_virtual/index2.js";
3
3
  export {
4
4
  e as EventEmitter,
5
5
  e as default
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import e from "../../../../_virtual/index5.js";
2
+ import e from "../../../../_virtual/index2.js";
3
3
  var r = new e(), n = "recharts.syncEvent.tooltip";
4
4
  export {
5
5
  n as TOOLTIP_SYNC_EVENT,
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __module as e } from "../../../_virtual/index2.js";
2
+ import { __module as e } from "../../../_virtual/index5.js";
3
3
  import { __require as i } from "../cjs/use-sync-external-store-shim.production.js";
4
4
  import { __require as o } from "../cjs/use-sync-external-store-shim.development.js";
5
5
  var r;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "laif-ds",
3
3
  "private": false,
4
- "version": "0.1.94",
4
+ "version": "0.1.95",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",