laif-ds 0.1.15 → 0.1.17

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,75 +1,75 @@
1
1
  "use client";
2
- import { jsx as u, jsxs as j, Fragment as X } from "react/jsx-runtime";
2
+ import { jsx as u, jsxs as V, Fragment as U } from "react/jsx-runtime";
3
3
  import { Command as ue, useCommandState as fe } from "../../node_modules/cmdk/dist/index.js";
4
4
  import * as a from "react";
5
5
  import { useEffect as L, forwardRef as de } from "react";
6
6
  import { Badge as ae } from "./badge.js";
7
- import { CommandItem as K, Command as ce, CommandList as oe, CommandGroup as ve } from "./command.js";
8
- import { cn as w } from "../../lib/utils.js";
7
+ import { CommandItem as K, Command as oe, CommandList as ce, CommandGroup as ve } from "./command.js";
8
+ import { cn as g } from "../../lib/utils.js";
9
9
  import { Label as be } from "./label.js";
10
10
  import Y from "../../node_modules/lucide-react/dist/esm/icons/x.js";
11
- function me(i, r) {
11
+ function me(i, l) {
12
12
  const [f, b] = a.useState(i);
13
13
  return L(() => {
14
- const c = setTimeout(() => b(i), r);
14
+ const o = setTimeout(() => b(i), l);
15
15
  return () => {
16
- clearTimeout(c);
16
+ clearTimeout(o);
17
17
  };
18
- }, [i, r]), f;
18
+ }, [i, l]), f;
19
19
  }
20
- function G(i, r) {
20
+ function z(i, l) {
21
21
  if (i.length === 0)
22
22
  return {};
23
- if (!r)
23
+ if (!l)
24
24
  return {
25
25
  "": i
26
26
  };
27
27
  const f = {};
28
28
  return i.forEach((b) => {
29
- const c = b[r] || "";
30
- f[c] || (f[c] = []), f[c].push(b);
29
+ const o = b[l] || "";
30
+ f[o] || (f[o] = []), f[o].push(b);
31
31
  }), f;
32
32
  }
33
- function we(i, r) {
33
+ function ge(i, l) {
34
34
  const f = JSON.parse(JSON.stringify(i));
35
- for (const [b, c] of Object.entries(f))
36
- f[b] = c.filter((_) => !r.find((v) => v.value === _.value));
35
+ for (const [b, o] of Object.entries(f))
36
+ f[b] = o.filter((C) => !l.find((v) => v.value === C.value));
37
37
  return f;
38
38
  }
39
- function ge(i, r) {
39
+ function we(i, l) {
40
40
  for (const [, f] of Object.entries(i))
41
- if (f.some((b) => r.find((c) => c.value === b.value)))
41
+ if (f.some((b) => l.find((o) => o.value === b.value)))
42
42
  return !0;
43
43
  return !1;
44
44
  }
45
- const Z = de(({ className: i, ...r }, f) => fe((c) => c.filtered.count === 0) ? /* @__PURE__ */ u(
45
+ const Z = de(({ className: i, ...l }, f) => fe((o) => o.filtered.count === 0) ? /* @__PURE__ */ u(
46
46
  "div",
47
47
  {
48
48
  ref: f,
49
- className: w("py-6 text-center text-sm", i),
49
+ className: g("py-6 text-center text-sm", i),
50
50
  "cmdk-empty": "",
51
51
  role: "presentation",
52
- ...r
52
+ ...l
53
53
  }
54
54
  ) : null);
55
55
  Z.displayName = "CommandEmpty";
56
- const he = a.forwardRef(
56
+ const xe = a.forwardRef(
57
57
  ({
58
58
  value: i,
59
- onChange: r,
59
+ onChange: l,
60
60
  placeholder: f,
61
61
  defaultOptions: b = [],
62
- options: c,
63
- delay: _,
62
+ options: o,
63
+ delay: C,
64
64
  onSearch: v,
65
65
  onSearchSync: I,
66
66
  loadingIndicator: W,
67
67
  emptyIndicator: F,
68
- maxSelected: z = Number.MAX_SAFE_INTEGER,
68
+ maxSelected: X = Number.MAX_SAFE_INTEGER,
69
69
  onMaxSelected: k,
70
70
  hidePlaceholderWhenSelected: H,
71
71
  disabled: E,
72
- groupBy: g,
72
+ groupBy: w,
73
73
  className: B,
74
74
  badgeClassName: S,
75
75
  selectFirstItem: p = !0,
@@ -80,69 +80,69 @@ const he = a.forwardRef(
80
80
  hideClearAllButton: P = !1,
81
81
  label: M
82
82
  }, ee) => {
83
- const o = a.useRef(null), [h, A] = a.useState(!1), [te, $] = a.useState(!1), [q, Q] = a.useState(!1), C = a.useRef(null), [l, O] = a.useState(i || []), [x, R] = a.useState(
84
- G(b, g)
85
- ), [m, U] = a.useState(""), N = me(m, _ || 500);
83
+ const c = a.useRef(null), [x, G] = a.useState(!1), [te, $] = a.useState(!1), [q, Q] = a.useState(!1), _ = a.useRef(null), [r, O] = a.useState(i || []), [h, A] = a.useState(
84
+ z(b, w)
85
+ ), [m, R] = a.useState(""), N = me(m, C || 500);
86
86
  a.useImperativeHandle(
87
87
  ee,
88
88
  () => ({
89
- selectedValue: [...l],
90
- input: o.current,
89
+ selectedValue: [...r],
90
+ input: c.current,
91
91
  focus: () => {
92
92
  var e;
93
- return (e = o == null ? void 0 : o.current) == null ? void 0 : e.focus();
93
+ return (e = c == null ? void 0 : c.current) == null ? void 0 : e.focus();
94
94
  },
95
95
  reset: () => O([])
96
96
  }),
97
- [l]
97
+ [r]
98
98
  );
99
99
  const y = (e) => {
100
- C.current && !C.current.contains(e.target) && o.current && !o.current.contains(e.target) && (A(!1), o.current.blur());
100
+ _.current && !_.current.contains(e.target) && c.current && !c.current.contains(e.target) && (G(!1), c.current.blur());
101
101
  }, J = a.useCallback(
102
102
  (e) => {
103
- const t = l.filter((d) => d.value !== e.value);
104
- O(t), r == null || r(t);
103
+ const t = r.filter((d) => d.value !== e.value);
104
+ O(t), l == null || l(t);
105
105
  },
106
- [r, l]
107
- ), le = a.useCallback(
106
+ [l, r]
107
+ ), re = a.useCallback(
108
108
  (e) => {
109
- const t = o.current;
110
- t && ((e.key === "Delete" || e.key === "Backspace") && t.value === "" && l.length > 0 && (l[l.length - 1].fixed || J(l[l.length - 1])), e.key === "Escape" && t.blur());
109
+ const t = c.current;
110
+ 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());
111
111
  },
112
- [J, l]
112
+ [J, r]
113
113
  );
114
114
  L(() => {
115
115
  if (typeof document < "u")
116
- return h ? (document.addEventListener("mousedown", y), document.addEventListener("touchend", y)) : (document.removeEventListener("mousedown", y), document.removeEventListener("touchend", y)), () => {
116
+ return x ? (document.addEventListener("mousedown", y), document.addEventListener("touchend", y)) : (document.removeEventListener("mousedown", y), document.removeEventListener("touchend", y)), () => {
117
117
  document.removeEventListener("mousedown", y), document.removeEventListener("touchend", y);
118
118
  };
119
- }, [h, y]), L(() => {
119
+ }, [x, y]), L(() => {
120
120
  i && O(i);
121
121
  }, [i]), L(() => {
122
- if (!c || v)
122
+ if (!o || v)
123
123
  return;
124
- const e = G(c || [], g);
125
- JSON.stringify(e) !== JSON.stringify(x) && R(e);
126
- }, [b, c, g, v, x]), L(() => {
124
+ const e = z(o || [], w);
125
+ JSON.stringify(e) !== JSON.stringify(h) && A(e);
126
+ }, [b, o, w, v, h]), L(() => {
127
127
  const e = () => {
128
128
  const d = I == null ? void 0 : I(N);
129
- R(G(d || [], g));
129
+ A(z(d || [], w));
130
130
  };
131
131
  (async () => {
132
- !I || !h || (T && e(), N && e());
132
+ !I || !x || (T && e(), N && e());
133
133
  })();
134
- }, [N, g, h, T]), L(() => {
134
+ }, [N, w, x, T]), L(() => {
135
135
  const e = async () => {
136
136
  Q(!0);
137
137
  const d = await (v == null ? void 0 : v(N));
138
- R(G(d || [], g)), Q(!1);
138
+ A(z(d || [], w)), Q(!1);
139
139
  };
140
140
  (async () => {
141
- !v || !h || (T && await e(), N && await e());
141
+ !v || !x || (T && await e(), N && await e());
142
142
  })();
143
- }, [N, g, h, T]);
144
- const re = () => {
145
- if (!D || ge(x, [{ value: m, label: m }]) || l.find((t) => t.value === m))
143
+ }, [N, w, x, T]);
144
+ const le = () => {
145
+ if (!D || we(h, [{ value: m, label: m }]) || r.find((t) => t.value === m))
146
146
  return;
147
147
  const e = /* @__PURE__ */ u(
148
148
  K,
@@ -153,13 +153,13 @@ const he = a.forwardRef(
153
153
  t.preventDefault(), t.stopPropagation();
154
154
  },
155
155
  onSelect: (t) => {
156
- if (l.length >= z) {
157
- k == null || k(l.length);
156
+ if (r.length >= X) {
157
+ k == null || k(r.length);
158
158
  return;
159
159
  }
160
- U("");
161
- const d = [...l, { value: t, label: t }];
162
- O(d), r == null || r(d);
160
+ R("");
161
+ const d = [...r, { value: t, label: t }];
162
+ O(d), l == null || l(d);
163
163
  },
164
164
  children: `Create "${m}"`
165
165
  }
@@ -168,51 +168,51 @@ const he = a.forwardRef(
168
168
  return e;
169
169
  }, ne = a.useCallback(() => {
170
170
  if (F)
171
- return v && !D && Object.keys(x).length === 0 ? /* @__PURE__ */ u(K, { value: "-", disabled: !0, children: F }) : /* @__PURE__ */ u(Z, { children: F });
172
- }, [D, F, v, x]), se = a.useMemo(
173
- () => we(x, l),
174
- [x, l]
171
+ return v && !D && Object.keys(h).length === 0 ? /* @__PURE__ */ u(K, { value: "-", disabled: !0, children: F }) : /* @__PURE__ */ u(Z, { children: F });
172
+ }, [D, F, v, h]), se = a.useMemo(
173
+ () => ge(h, r),
174
+ [h, r]
175
175
  ), ie = a.useCallback(() => {
176
176
  if (n != null && n.filter)
177
177
  return n.filter;
178
178
  if (D)
179
179
  return (e, t) => e.toLowerCase().includes(t.toLowerCase()) ? 1 : -1;
180
180
  }, [D, n == null ? void 0 : n.filter]);
181
- return /* @__PURE__ */ j("div", { className: "flex flex-col space-y-1.5", children: [
181
+ return /* @__PURE__ */ V("div", { className: "flex flex-col space-y-1.5", children: [
182
182
  M && /* @__PURE__ */ u(be, { children: M }),
183
- /* @__PURE__ */ j(
184
- ce,
183
+ /* @__PURE__ */ V(
184
+ oe,
185
185
  {
186
- ref: C,
186
+ ref: _,
187
187
  ...n,
188
188
  onKeyDown: (e) => {
189
189
  var t;
190
- le(e), (t = n == null ? void 0 : n.onKeyDown) == null || t.call(n, e);
190
+ re(e), (t = n == null ? void 0 : n.onKeyDown) == null || t.call(n, e);
191
191
  },
192
- className: w("h-auto overflow-visible bg-transparent", n == null ? void 0 : n.className),
192
+ className: g("h-auto overflow-visible bg-transparent", n == null ? void 0 : n.className),
193
193
  shouldFilter: (n == null ? void 0 : n.shouldFilter) !== void 0 ? n.shouldFilter : !v,
194
194
  filter: ie(),
195
195
  children: [
196
196
  /* @__PURE__ */ u(
197
197
  "div",
198
198
  {
199
- className: w(
199
+ className: g(
200
200
  "min-h-10 rounded-md border border-d-input text-base ring-offset-d-background focus-within:ring-2 focus-within:ring-d-ring focus-within:ring-offset-2 md:text-sm",
201
201
  {
202
- "px-3 py-2": l.length !== 0,
203
- "cursor-text": !E && l.length !== 0
202
+ "px-3 py-2": r.length !== 0,
203
+ "cursor-text": !E && r.length !== 0
204
204
  },
205
205
  B
206
206
  ),
207
207
  onClick: () => {
208
208
  var e;
209
- E || (e = o == null ? void 0 : o.current) == null || e.focus();
209
+ E || (e = c == null ? void 0 : c.current) == null || e.focus();
210
210
  },
211
- children: /* @__PURE__ */ j("div", { className: "relative flex flex-wrap gap-1", children: [
212
- l.map((e) => /* @__PURE__ */ j(
211
+ children: /* @__PURE__ */ V("div", { className: "relative flex flex-wrap gap-1", children: [
212
+ r.map((e) => /* @__PURE__ */ V(
213
213
  ae,
214
214
  {
215
- className: w(
215
+ className: g(
216
216
  "data-[disabled]:bg-d-secondary-foreground data-[disabled]:text-d-secondary data-[disabled]:hover:bg-d-secondary-foreground",
217
217
  "data-[fixed]:bg-d-secondary-foreground data-[fixed]:text-d-secondary data-[fixed]:hover:bg-d-secondary-foreground",
218
218
  S
@@ -225,8 +225,8 @@ const he = a.forwardRef(
225
225
  "button",
226
226
  {
227
227
  type: "button",
228
- className: w(
229
- "ml-1 rounded-full outline-none ring-offset-d-background focus:ring-2 focus:ring-d-ring focus:ring-offset-2",
228
+ className: g(
229
+ "ml-1 rounded-full text-d-secondary-foreground outline-none ring-offset-d-background focus:ring-2 focus:ring-d-ring focus:ring-offset-2",
230
230
  (E || e.fixed) && "hidden"
231
231
  ),
232
232
  onKeyDown: (t) => {
@@ -236,7 +236,7 @@ const he = a.forwardRef(
236
236
  t.preventDefault(), t.stopPropagation();
237
237
  },
238
238
  onClick: () => J(e),
239
- children: /* @__PURE__ */ u(Y, { className: "h-3 w-3 text-d-secondary-foreground hover:text-foreground" })
239
+ children: /* @__PURE__ */ u(Y, { className: "h-3 w-3 text-d-secondary-foreground hover:text-d-foreground" })
240
240
  }
241
241
  )
242
242
  ]
@@ -247,52 +247,52 @@ const he = a.forwardRef(
247
247
  ue.Input,
248
248
  {
249
249
  ...s,
250
- ref: o,
250
+ ref: c,
251
251
  value: m,
252
252
  disabled: E,
253
253
  onValueChange: (e) => {
254
254
  var t;
255
- U(e), (t = s == null ? void 0 : s.onValueChange) == null || t.call(s, e);
255
+ R(e), (t = s == null ? void 0 : s.onValueChange) == null || t.call(s, e);
256
256
  },
257
257
  onBlur: (e) => {
258
258
  var t;
259
- te || A(!1), (t = s == null ? void 0 : s.onBlur) == null || t.call(s, e);
259
+ te || G(!1), (t = s == null ? void 0 : s.onBlur) == null || t.call(s, e);
260
260
  },
261
261
  onFocus: (e) => {
262
262
  var t;
263
- A(!0), (t = s == null ? void 0 : s.onFocus) == null || t.call(s, e);
263
+ G(!0), (t = s == null ? void 0 : s.onFocus) == null || t.call(s, e);
264
264
  },
265
- placeholder: H && l.length !== 0 ? "" : f,
266
- className: w(
265
+ placeholder: H && r.length !== 0 ? "" : f,
266
+ className: g(
267
267
  "flex-1 bg-transparent outline-none placeholder:text-d-secondary-foreground",
268
268
  {
269
269
  "w-full": H,
270
- "px-3 py-2": l.length === 0,
271
- "ml-1": l.length !== 0
270
+ "px-3 py-2": r.length === 0,
271
+ "ml-1": r.length !== 0
272
272
  },
273
273
  s == null ? void 0 : s.className
274
274
  )
275
275
  }
276
276
  ),
277
277
  /* @__PURE__ */ u(
278
- "button",
278
+ "div",
279
279
  {
280
- type: "button",
280
+ className: g(
281
+ "absolute right-0 top-0 flex items-center justify-center rounded-full bg-d-secondary/20 hover:bg-d-secondary/30 p-1 cursor-pointer z-20 border",
282
+ (P || E || r.length < 1 || r.filter((e) => e.fixed).length === r.length) && "hidden"
283
+ ),
281
284
  onClick: () => {
282
- O(l.filter((e) => e.fixed)), r == null || r(l.filter((e) => e.fixed));
285
+ O(r.filter((e) => e.fixed)), l == null || l(r.filter((e) => e.fixed));
283
286
  },
284
- className: w(
285
- "absolute right-0 h-6 w-6 p-0",
286
- (P || E || l.length < 1 || l.filter((e) => e.fixed).length === l.length) && "hidden"
287
- ),
288
- children: /* @__PURE__ */ u(Y, {})
287
+ "aria-label": "Clear selection",
288
+ children: /* @__PURE__ */ u(Y, { size: 12, className: "text-d-foreground" })
289
289
  }
290
290
  )
291
291
  ] })
292
292
  }
293
293
  ),
294
- /* @__PURE__ */ u("div", { className: "relative", children: h && /* @__PURE__ */ u(
295
- oe,
294
+ /* @__PURE__ */ u("div", { className: "relative", children: x && /* @__PURE__ */ u(
295
+ ce,
296
296
  {
297
297
  className: "absolute top-1 z-10 w-full rounded-md border bg-d-popover text-d-popover-foreground shadow-md outline-none animate-in",
298
298
  onMouseLeave: () => {
@@ -303,30 +303,30 @@ const he = a.forwardRef(
303
303
  },
304
304
  onMouseUp: () => {
305
305
  var e;
306
- (e = o == null ? void 0 : o.current) == null || e.focus();
306
+ (e = c == null ? void 0 : c.current) == null || e.focus();
307
307
  },
308
- children: q ? /* @__PURE__ */ u(X, { children: W }) : /* @__PURE__ */ j(X, { children: [
308
+ children: q ? /* @__PURE__ */ u(U, { children: W }) : /* @__PURE__ */ V(U, { children: [
309
309
  ne(),
310
- re(),
310
+ le(),
311
311
  !p && /* @__PURE__ */ u(K, { value: "-", className: "hidden" }),
312
- Object.entries(se).map(([e, t]) => /* @__PURE__ */ u(ve, { heading: e, className: "h-full overflow-auto", children: /* @__PURE__ */ u(X, { children: t.map((d) => /* @__PURE__ */ u(
312
+ Object.entries(se).map(([e, t]) => /* @__PURE__ */ u(ve, { heading: e, className: "h-full overflow-auto", children: /* @__PURE__ */ u(U, { children: t.map((d) => /* @__PURE__ */ u(
313
313
  K,
314
314
  {
315
315
  value: d.label,
316
316
  disabled: d.disable,
317
- onMouseDown: (V) => {
318
- V.preventDefault(), V.stopPropagation();
317
+ onMouseDown: (j) => {
318
+ j.preventDefault(), j.stopPropagation();
319
319
  },
320
320
  onSelect: () => {
321
- if (l.length >= z) {
322
- k == null || k(l.length);
321
+ if (r.length >= X) {
322
+ k == null || k(r.length);
323
323
  return;
324
324
  }
325
- U("");
326
- const V = [...l, d];
327
- O(V), r == null || r(V);
325
+ R("");
326
+ const j = [...r, d];
327
+ O(j), l == null || l(j);
328
328
  },
329
- className: w(
329
+ className: g(
330
330
  "cursor-pointer",
331
331
  d.disable && "cursor-default text-d-secondary-foreground"
332
332
  ),
@@ -343,8 +343,8 @@ const he = a.forwardRef(
343
343
  ] });
344
344
  }
345
345
  );
346
- he.displayName = "MultipleSelector";
346
+ xe.displayName = "MultipleSelector";
347
347
  export {
348
- he as MultipleSelector,
348
+ xe as MultipleSelector,
349
349
  me as useDebounce
350
350
  };
package/dist/index.d.ts CHANGED
@@ -266,7 +266,7 @@ export declare interface CardProps extends React_2.ComponentProps<"div"> {
266
266
  size?: CardSize;
267
267
  }
268
268
 
269
- declare type CardSize = "default" | "sm" | "lg";
269
+ declare type CardSize = "default" | "sm" | "lg" | "none";
270
270
 
271
271
  export declare function CardTitle({ className, ...props }: React_2.ComponentProps<"div">): JSX.Element;
272
272
 
@@ -418,6 +418,22 @@ declare interface ChatPropsWithSuggestions extends ChatPropsBase {
418
418
 
419
419
  export declare function Checkbox({ className, ...props }: React_2.ComponentProps<typeof CheckboxPrimitive.Root>): JSX.Element;
420
420
 
421
+ export declare function CircularProgress({ value, renderLabel, className, progressClassName, labelClassName, showLabel, shape, size, strokeWidth, circleStrokeWidth, progressStrokeWidth, }: CircularProgressProps): JSX.Element;
422
+
423
+ declare interface CircularProgressProps {
424
+ value: number;
425
+ renderLabel?: (progress: number) => number | string;
426
+ size?: number;
427
+ strokeWidth?: number;
428
+ circleStrokeWidth?: number;
429
+ progressStrokeWidth?: number;
430
+ shape?: "square" | "round";
431
+ className?: string;
432
+ progressClassName?: string;
433
+ labelClassName?: string;
434
+ showLabel?: boolean;
435
+ }
436
+
421
437
  export declare function Collapsible({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.Root>): JSX.Element;
422
438
 
423
439
  export declare function CollapsibleContent({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>): JSX.Element;
@@ -683,7 +699,7 @@ export declare function HoverCardTrigger({ ...props }: React_2.ComponentProps<ty
683
699
  */
684
700
  export declare function Icon({ name, size, className, color, ...props }: IconProps): JSX.Element | null;
685
701
 
686
- declare type IconName = keyof typeof LucideIcons;
702
+ export declare type IconName = keyof typeof LucideIcons;
687
703
 
688
704
  declare interface IconProps {
689
705
  name: IconName;
@@ -929,6 +945,14 @@ declare interface NavItem {
929
945
  url: string;
930
946
  isActive?: boolean;
931
947
  iconName?: IconName;
948
+ subItems?: NavSubItem[];
949
+ }
950
+
951
+ declare interface NavSubItem {
952
+ title: string;
953
+ url: string;
954
+ isActive?: boolean;
955
+ iconName?: IconName;
932
956
  }
933
957
 
934
958
  declare type NoRepeatDataType = {