laif-ds 0.1.43 → 0.1.44

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,53 +1,54 @@
1
1
  "use client";
2
- import { jsx as d, jsxs as V, Fragment as U } from "react/jsx-runtime";
3
- import { Command as de, useCommandState as ue } from "../../node_modules/cmdk/dist/index.js";
4
- import * as a from "react";
2
+ import { jsx as u, jsxs as V, Fragment as U } from "react/jsx-runtime";
3
+ import { Command as ue, useCommandState as de } from "../../node_modules/cmdk/dist/index.js";
4
+ import * as o from "react";
5
5
  import { useEffect as L, forwardRef as fe } from "react";
6
- import { Badge as ae } from "./badge.js";
7
- import { CommandItem as K, Command as oe, CommandList as ce, CommandGroup as ve } from "./command.js";
6
+ import { CommandPortal as ae } from "./command-portal.js";
7
+ import { Badge as oe } from "./badge.js";
8
+ import { CommandItem as G, Command as ce, CommandList as ve, CommandGroup as be } from "./command.js";
8
9
  import { cn as g } from "../../lib/utils.js";
9
- import { Label as be } from "./label.js";
10
+ import { Label as me } from "./label.js";
10
11
  import Y from "../../node_modules/lucide-react/dist/esm/icons/x.js";
11
- function me(i, l) {
12
- const [u, b] = a.useState(i);
12
+ function ge(i, l) {
13
+ const [d, b] = o.useState(i);
13
14
  return L(() => {
14
- const o = setTimeout(() => b(i), l);
15
+ const c = setTimeout(() => b(i), l);
15
16
  return () => {
16
- clearTimeout(o);
17
+ clearTimeout(c);
17
18
  };
18
- }, [i, l]), u;
19
+ }, [i, l]), d;
19
20
  }
20
- function z(i, l) {
21
+ function R(i, l) {
21
22
  if (i.length === 0)
22
23
  return {};
23
24
  if (!l)
24
25
  return {
25
26
  "": i
26
27
  };
27
- const u = {};
28
+ const d = {};
28
29
  return i.forEach((b) => {
29
- const o = b[l] || "";
30
- u[o] || (u[o] = []), u[o].push(b);
31
- }), u;
30
+ const c = b[l] || "";
31
+ d[c] || (d[c] = []), d[c].push(b);
32
+ }), d;
32
33
  }
33
- function ge(i, l) {
34
- const u = JSON.parse(JSON.stringify(i));
35
- for (const [b, o] of Object.entries(u))
36
- u[b] = o.filter(
37
- (C) => !l.find((v) => v.value === C.value)
34
+ function we(i, l) {
35
+ const d = JSON.parse(JSON.stringify(i));
36
+ for (const [b, c] of Object.entries(d))
37
+ d[b] = c.filter(
38
+ (_) => !l.find((v) => v.value === _.value)
38
39
  );
39
- return u;
40
+ return d;
40
41
  }
41
- function we(i, l) {
42
- for (const [, u] of Object.entries(i))
43
- if (u.some((b) => l.find((o) => o.value === b.value)))
42
+ function xe(i, l) {
43
+ for (const [, d] of Object.entries(i))
44
+ if (d.some((b) => l.find((c) => c.value === b.value)))
44
45
  return !0;
45
46
  return !1;
46
47
  }
47
- const Z = fe(({ className: i, ...l }, u) => ue((o) => o.filtered.count === 0) ? /* @__PURE__ */ d(
48
+ const Z = fe(({ className: i, ...l }, d) => de((c) => c.filtered.count === 0) ? /* @__PURE__ */ u(
48
49
  "div",
49
50
  {
50
- ref: u,
51
+ ref: d,
51
52
  className: g("py-6 text-center text-sm", i),
52
53
  "cmdk-empty": "",
53
54
  role: "presentation",
@@ -55,18 +56,18 @@ const Z = fe(({ className: i, ...l }, u) => ue((o) => o.filtered.count === 0) ?
55
56
  }
56
57
  ) : null);
57
58
  Z.displayName = "CommandEmpty";
58
- const xe = a.forwardRef(
59
+ const he = o.forwardRef(
59
60
  ({
60
61
  value: i,
61
62
  onChange: l,
62
- placeholder: u,
63
+ placeholder: d,
63
64
  defaultOptions: b = [],
64
- options: o,
65
- delay: C,
65
+ options: c,
66
+ delay: _,
66
67
  onSearch: v,
67
68
  onSearchSync: I,
68
69
  loadingIndicator: W,
69
- emptyIndicator: F,
70
+ emptyIndicator: C,
70
71
  maxSelected: X = Number.MAX_SAFE_INTEGER,
71
72
  onMaxSelected: E,
72
73
  hidePlaceholderWhenSelected: H,
@@ -76,42 +77,42 @@ const xe = a.forwardRef(
76
77
  badgeClassName: S,
77
78
  selectFirstItem: p = !0,
78
79
  creatable: D = !1,
79
- triggerSearchOnFocus: T = !1,
80
+ triggerSearchOnFocus: F = !1,
80
81
  commandProps: n,
81
82
  inputProps: s,
82
83
  hideClearAllButton: P = !1,
83
84
  label: M
84
85
  }, ee) => {
85
- const c = a.useRef(null), [h, G] = a.useState(!1), [te, $] = a.useState(!1), [q, Q] = a.useState(!1), _ = a.useRef(null), [r, O] = a.useState(i || []), [N, A] = a.useState(
86
- z(b, x)
87
- ), [m, R] = a.useState(""), y = me(m, C || 500);
88
- a.useImperativeHandle(
86
+ const f = o.useRef(null), [h, T] = o.useState(!1), [te, $] = o.useState(!1), [q, Q] = o.useState(!1), J = o.useRef(null), [r, O] = o.useState(i || []), [N, z] = o.useState(
87
+ R(b, x)
88
+ ), [m, A] = o.useState(""), y = ge(m, _ || 500);
89
+ o.useImperativeHandle(
89
90
  ee,
90
91
  () => ({
91
92
  selectedValue: [...r],
92
- input: c.current,
93
+ input: f.current,
93
94
  focus: () => {
94
95
  var e;
95
- return (e = c == null ? void 0 : c.current) == null ? void 0 : e.focus();
96
+ return (e = f == null ? void 0 : f.current) == null ? void 0 : e.focus();
96
97
  },
97
98
  reset: () => O([])
98
99
  }),
99
100
  [r]
100
101
  );
101
102
  const k = (e) => {
102
- _.current && !_.current.contains(e.target) && c.current && !c.current.contains(e.target) && (G(!1), c.current.blur());
103
- }, J = a.useCallback(
103
+ J.current && !J.current.contains(e.target) && f.current && !f.current.contains(e.target) && (T(!1), f.current.blur());
104
+ }, K = o.useCallback(
104
105
  (e) => {
105
- const t = r.filter((f) => f.value !== e.value);
106
+ const t = r.filter((a) => a.value !== e.value);
106
107
  O(t), l == null || l(t);
107
108
  },
108
109
  [l, r]
109
- ), re = a.useCallback(
110
+ ), re = o.useCallback(
110
111
  (e) => {
111
- const t = c.current;
112
- t && ((e.key === "Delete" || e.key === "Backspace") && t.value === "" && r.length > 0 && (r[r.length - 1].fixed || J(r[r.length - 1])), e.key === "Escape" && t.blur());
112
+ const t = f.current;
113
+ t && ((e.key === "Delete" || e.key === "Backspace") && t.value === "" && r.length > 0 && (r[r.length - 1].fixed || K(r[r.length - 1])), e.key === "Escape" && t.blur());
113
114
  },
114
- [J, r]
115
+ [K, r]
115
116
  );
116
117
  L(() => {
117
118
  if (typeof document < "u")
@@ -121,33 +122,33 @@ const xe = a.forwardRef(
121
122
  }, [h, k]), L(() => {
122
123
  i && O(i);
123
124
  }, [i]), L(() => {
124
- if (!o || v)
125
+ if (!c || v)
125
126
  return;
126
- const e = z(o || [], x);
127
- JSON.stringify(e) !== JSON.stringify(N) && A(e);
128
- }, [b, o, x, v, N]), L(() => {
127
+ const e = R(c || [], x);
128
+ JSON.stringify(e) !== JSON.stringify(N) && z(e);
129
+ }, [b, c, x, v, N]), L(() => {
129
130
  const e = () => {
130
- const f = I == null ? void 0 : I(y);
131
- A(z(f || [], x));
131
+ const a = I == null ? void 0 : I(y);
132
+ z(R(a || [], x));
132
133
  };
133
134
  (async () => {
134
- !I || !h || (T && e(), y && e());
135
+ !I || !h || (F && e(), y && e());
135
136
  })();
136
- }, [y, x, h, T]), L(() => {
137
+ }, [y, x, h, F]), L(() => {
137
138
  const e = async () => {
138
139
  Q(!0);
139
- const f = await (v == null ? void 0 : v(y));
140
- A(z(f || [], x)), Q(!1);
140
+ const a = await (v == null ? void 0 : v(y));
141
+ z(R(a || [], x)), Q(!1);
141
142
  };
142
143
  (async () => {
143
- !v || !h || (T && await e(), y && await e());
144
+ !v || !h || (F && await e(), y && await e());
144
145
  })();
145
- }, [y, x, h, T]);
146
+ }, [y, x, h, F]);
146
147
  const le = () => {
147
- if (!D || we(N, [{ value: m, label: m }]) || r.find((t) => t.value === m))
148
+ if (!D || xe(N, [{ value: m, label: m }]) || r.find((t) => t.value === m))
148
149
  return;
149
- const e = /* @__PURE__ */ d(
150
- K,
150
+ const e = /* @__PURE__ */ u(
151
+ G,
151
152
  {
152
153
  value: m,
153
154
  className: "cursor-pointer",
@@ -159,33 +160,33 @@ const xe = a.forwardRef(
159
160
  E == null || E(r.length);
160
161
  return;
161
162
  }
162
- R("");
163
- const f = [...r, { value: t, label: t }];
164
- O(f), l == null || l(f);
163
+ A("");
164
+ const a = [...r, { value: t, label: t }];
165
+ O(a), l == null || l(a);
165
166
  },
166
167
  children: `Create "${m}"`
167
168
  }
168
169
  );
169
170
  if (!v && m.length > 0 || v && y.length > 0 && !q)
170
171
  return e;
171
- }, ne = a.useCallback(() => {
172
- if (F)
173
- return v && !D && Object.keys(N).length === 0 ? /* @__PURE__ */ d(K, { value: "-", disabled: !0, children: F }) : /* @__PURE__ */ d(Z, { children: F });
174
- }, [D, F, v, N]), se = a.useMemo(
175
- () => ge(N, r),
172
+ }, ne = o.useCallback(() => {
173
+ if (C)
174
+ return v && !D && Object.keys(N).length === 0 ? /* @__PURE__ */ u(G, { value: "-", disabled: !0, children: C }) : /* @__PURE__ */ u(Z, { children: C });
175
+ }, [D, C, v, N]), se = o.useMemo(
176
+ () => we(N, r),
176
177
  [N, r]
177
- ), ie = a.useCallback(() => {
178
+ ), ie = o.useCallback(() => {
178
179
  if (n != null && n.filter)
179
180
  return n.filter;
180
181
  if (D)
181
182
  return (e, t) => e.toLowerCase().includes(t.toLowerCase()) ? 1 : -1;
182
183
  }, [D, n == null ? void 0 : n.filter]);
183
184
  return /* @__PURE__ */ V("div", { className: "flex flex-col space-y-1.5", children: [
184
- M && /* @__PURE__ */ d(be, { children: M }),
185
+ M && /* @__PURE__ */ u(me, { children: M }),
185
186
  /* @__PURE__ */ V(
186
- oe,
187
+ ce,
187
188
  {
188
- ref: _,
189
+ ref: J,
189
190
  ...n,
190
191
  onKeyDown: (e) => {
191
192
  var t;
@@ -198,7 +199,7 @@ const xe = a.forwardRef(
198
199
  shouldFilter: (n == null ? void 0 : n.shouldFilter) !== void 0 ? n.shouldFilter : !v,
199
200
  filter: ie(),
200
201
  children: [
201
- /* @__PURE__ */ d(
202
+ /* @__PURE__ */ u(
202
203
  "div",
203
204
  {
204
205
  className: g(
@@ -212,11 +213,11 @@ const xe = a.forwardRef(
212
213
  ),
213
214
  onClick: () => {
214
215
  var e;
215
- w || (e = c == null ? void 0 : c.current) == null || e.focus();
216
+ w || (e = f == null ? void 0 : f.current) == null || e.focus();
216
217
  },
217
218
  children: /* @__PURE__ */ V("div", { className: "relative flex flex-wrap gap-1", children: [
218
219
  r.map((e) => /* @__PURE__ */ V(
219
- ae,
220
+ oe,
220
221
  {
221
222
  className: g(
222
223
  "data-[disabled]:bg-d-secondary-foreground data-[disabled]:text-d-secondary data-[disabled]:hover:bg-d-secondary-foreground",
@@ -227,7 +228,7 @@ const xe = a.forwardRef(
227
228
  "data-disabled": w || void 0,
228
229
  children: [
229
230
  e.label,
230
- /* @__PURE__ */ d(
231
+ /* @__PURE__ */ u(
231
232
  "button",
232
233
  {
233
234
  type: "button",
@@ -236,39 +237,39 @@ const xe = a.forwardRef(
236
237
  (w || e.fixed) && "hidden"
237
238
  ),
238
239
  onKeyDown: (t) => {
239
- t.key === "Enter" && J(e);
240
+ t.key === "Enter" && K(e);
240
241
  },
241
242
  onMouseDown: (t) => {
242
243
  t.preventDefault(), t.stopPropagation();
243
244
  },
244
- onClick: () => J(e),
245
- children: /* @__PURE__ */ d(Y, { className: "text-d-secondary-foreground hover:text-d-foreground h-3 w-3" })
245
+ onClick: () => K(e),
246
+ children: /* @__PURE__ */ u(Y, { className: "text-d-secondary-foreground hover:text-d-foreground h-3 w-3" })
246
247
  }
247
248
  )
248
249
  ]
249
250
  },
250
251
  e.value
251
252
  )),
252
- /* @__PURE__ */ d(
253
- de.Input,
253
+ /* @__PURE__ */ u(
254
+ ue.Input,
254
255
  {
255
256
  ...s,
256
- ref: c,
257
+ ref: f,
257
258
  value: m,
258
259
  disabled: w,
259
260
  onValueChange: (e) => {
260
261
  var t;
261
- R(e), (t = s == null ? void 0 : s.onValueChange) == null || t.call(s, e);
262
+ A(e), (t = s == null ? void 0 : s.onValueChange) == null || t.call(s, e);
262
263
  },
263
264
  onBlur: (e) => {
264
265
  var t;
265
- te || G(!1), (t = s == null ? void 0 : s.onBlur) == null || t.call(s, e);
266
+ te || T(!1), (t = s == null ? void 0 : s.onBlur) == null || t.call(s, e);
266
267
  },
267
268
  onFocus: (e) => {
268
269
  var t;
269
- G(!0), (t = s == null ? void 0 : s.onFocus) == null || t.call(s, e);
270
+ T(!0), (t = s == null ? void 0 : s.onFocus) == null || t.call(s, e);
270
271
  },
271
- placeholder: H && r.length !== 0 ? "" : u,
272
+ placeholder: H && r.length !== 0 ? "" : d,
272
273
  className: g(
273
274
  "placeholder:text-d-muted-foreground flex-1 bg-transparent outline-none",
274
275
  {
@@ -280,7 +281,7 @@ const xe = a.forwardRef(
280
281
  )
281
282
  }
282
283
  ),
283
- /* @__PURE__ */ d(
284
+ /* @__PURE__ */ u(
284
285
  "div",
285
286
  {
286
287
  className: g(
@@ -291,74 +292,85 @@ const xe = a.forwardRef(
291
292
  O(r.filter((e) => e.fixed)), l == null || l(r.filter((e) => e.fixed));
292
293
  },
293
294
  "aria-label": "Clear selection",
294
- children: /* @__PURE__ */ d(Y, { size: 12, className: "text-d-foreground" })
295
+ children: /* @__PURE__ */ u(Y, { size: 12, className: "text-d-foreground" })
295
296
  }
296
297
  )
297
298
  ] })
298
299
  }
299
300
  ),
300
- /* @__PURE__ */ d("div", { className: "relative", children: h && /* @__PURE__ */ d(
301
- ce,
301
+ /* @__PURE__ */ u(
302
+ ae,
302
303
  {
303
- className: "bg-d-popover text-d-popover-foreground animate-in absolute top-1 z-10 w-full rounded-md border shadow-md outline-none",
304
- onMouseLeave: () => {
305
- $(!1);
306
- },
307
- onMouseEnter: () => {
308
- $(!0);
309
- },
310
- onMouseUp: () => {
304
+ open: h,
305
+ triggerRef: J,
306
+ onClose: () => {
311
307
  var e;
312
- (e = c == null ? void 0 : c.current) == null || e.focus();
308
+ T(!1), (e = f.current) == null || e.blur();
313
309
  },
314
- children: q ? /* @__PURE__ */ d(U, { children: W }) : /* @__PURE__ */ V(U, { children: [
315
- ne(),
316
- le(),
317
- !p && /* @__PURE__ */ d(K, { value: "-", className: "hidden" }),
318
- Object.entries(se).map(([e, t]) => /* @__PURE__ */ d(
319
- ve,
320
- {
321
- heading: e,
322
- className: "h-full overflow-auto",
323
- children: /* @__PURE__ */ d(U, { children: t.map((f) => /* @__PURE__ */ d(
324
- K,
310
+ children: /* @__PURE__ */ u(
311
+ ve,
312
+ {
313
+ className: "bg-d-popover text-d-popover-foreground animate-in w-full rounded-md border shadow-md outline-none",
314
+ onMouseLeave: () => {
315
+ $(!1);
316
+ },
317
+ onMouseEnter: () => {
318
+ $(!0);
319
+ },
320
+ onMouseUp: () => {
321
+ var e;
322
+ (e = f == null ? void 0 : f.current) == null || e.focus();
323
+ },
324
+ children: q ? /* @__PURE__ */ u(U, { children: W }) : /* @__PURE__ */ V(U, { children: [
325
+ ne(),
326
+ le(),
327
+ !p && /* @__PURE__ */ u(G, { value: "-", className: "hidden" }),
328
+ Object.entries(se).map(([e, t]) => /* @__PURE__ */ u(
329
+ be,
325
330
  {
326
- value: f.label,
327
- disabled: f.disable,
328
- onMouseDown: (j) => {
329
- j.preventDefault(), j.stopPropagation();
330
- },
331
- onSelect: () => {
332
- if (r.length >= X) {
333
- E == null || E(r.length);
334
- return;
335
- }
336
- R("");
337
- const j = [...r, f];
338
- O(j), l == null || l(j);
339
- },
340
- className: g(
341
- "cursor-pointer",
342
- f.disable && "text-d-secondary-foreground cursor-default"
343
- ),
344
- children: f.label
331
+ heading: e,
332
+ className: "h-full overflow-auto",
333
+ children: /* @__PURE__ */ u(U, { children: t.map((a) => /* @__PURE__ */ u(
334
+ G,
335
+ {
336
+ value: a.label,
337
+ disabled: a.disable,
338
+ onMouseDown: (j) => {
339
+ j.preventDefault(), j.stopPropagation();
340
+ },
341
+ onSelect: () => {
342
+ if (r.length >= X) {
343
+ E == null || E(r.length);
344
+ return;
345
+ }
346
+ A("");
347
+ const j = [...r, a];
348
+ O(j), l == null || l(j);
349
+ },
350
+ className: g(
351
+ "cursor-pointer",
352
+ a.disable && "text-d-secondary-foreground cursor-default"
353
+ ),
354
+ children: a.label
355
+ },
356
+ a.value
357
+ )) })
345
358
  },
346
- f.value
347
- )) })
348
- },
349
- e
350
- ))
351
- ] })
359
+ e
360
+ ))
361
+ ] })
362
+ }
363
+ )
352
364
  }
353
- ) })
365
+ )
354
366
  ]
355
367
  }
356
368
  )
357
369
  ] });
358
370
  }
359
371
  );
360
- xe.displayName = "MultipleSelector";
372
+ he.displayName = "MultipleSelector";
361
373
  export {
362
- xe as MultipleSelector,
363
- me as useDebounce
374
+ he as MultipleSelector,
375
+ ge as useDebounce
364
376
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { s as e } from "../../../../_virtual/index3.js";
2
+ import { s as e } from "../../../../_virtual/index.js";
3
3
  function s() {
4
4
  return e.useSyncExternalStore(
5
5
  r,
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __module as e } from "../../_virtual/index2.js";
2
+ import { __module as e } from "../../_virtual/index6.js";
3
3
  import { __require as t } from "./cjs/react-is.production.min.js";
4
4
  import { __require as o } from "./cjs/react-is.development.js";
5
5
  var r;
@@ -5,7 +5,7 @@ import "../../../../_virtual/isString.js";
5
5
  import f from "../../../../_virtual/isFunction.js";
6
6
  import s from "../../../../_virtual/isObject.js";
7
7
  import { isValidElement as d } from "react";
8
- import "../../../../_virtual/index.js";
8
+ import "../../../../_virtual/index3.js";
9
9
  import { SVGElementPropKeys as m, EventKeys as p, FilteredElementKeyMap as o } from "./types.js";
10
10
  var h = function(i) {
11
11
  return typeof i == "string" ? i : i ? i.displayName || i.name || "Component" : "";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __exports as r } from "../../../_virtual/index7.js";
2
+ import { __exports as r } from "../../../_virtual/index8.js";
3
3
  import { __require as c } from "../../inline-style-parser/index.js";
4
4
  var f;
5
5
  function j() {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __module as e } from "../../../_virtual/index6.js";
2
+ import { __module as e } from "../../../_virtual/index2.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;