laif-ds 0.2.52 → 0.2.54

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.
@@ -2,10 +2,10 @@
2
2
  import { jsxs as u, jsx as r } from "react/jsx-runtime";
3
3
  import { useDebounce as de } from "../../hooks/use-debounce.js";
4
4
  import { cva as ie } from "../../node_modules/class-variance-authority/dist/index.js";
5
- import * as M from "react";
6
- import { useState as p, useEffect as N, useCallback as j } from "react";
7
- import { designTokens as b } from "../../lib/design-tokens.js";
8
- import { cn as k } from "../../lib/utils.js";
5
+ import * as R from "react";
6
+ import { useState as p, useEffect as b, useCallback as j } from "react";
7
+ import { designTokens as x } from "../../lib/design-tokens.js";
8
+ import { cn as M } from "../../lib/utils.js";
9
9
  import { Checkbox as fe } from "./checkbox.js";
10
10
  import { Command as me, CommandInput as ue, CommandList as he, CommandEmpty as ge, CommandGroup as O, CommandItem as V } from "./command.js";
11
11
  import { Icon as _ } from "./icon.js";
@@ -14,10 +14,10 @@ import { Popover as xe, PopoverTrigger as we, PopoverContent as ye } from "./pop
14
14
  import Ne from "../../node_modules/lucide-react/dist/esm/icons/loader-circle.js";
15
15
  import be from "../../node_modules/lucide-react/dist/esm/icons/check.js";
16
16
  const Ce = ie(
17
- k(
18
- b.input.base,
19
- b.radius.default,
20
- b.interaction.disabled,
17
+ M(
18
+ x.input.base,
19
+ x.radius.default,
20
+ x.interaction.disabled,
21
21
  "flex items-center justify-between whitespace-nowrap transition-all [&>span]:line-clamp-1",
22
22
  "data-[placeholder]:text-d-muted-foreground",
23
23
  "focus:outline-none"
@@ -25,9 +25,9 @@ const Ce = ie(
25
25
  {
26
26
  variants: {
27
27
  size: {
28
- default: b.sizes.default,
29
- sm: b.sizes.sm,
30
- lg: b.sizes.lg
28
+ default: x.sizes.default,
29
+ sm: x.sizes.sm,
30
+ lg: x.sizes.lg
31
31
  }
32
32
  },
33
33
  defaultVariants: {
@@ -38,27 +38,27 @@ const Ce = ie(
38
38
  function Be({
39
39
  fetcher: i,
40
40
  initialOptions: t,
41
- debounce: x = 300,
41
+ debounce: w = 300,
42
42
  renderOptionItem: C,
43
43
  resolveOptionValue: a,
44
44
  renderSelectedValue: s,
45
45
  notFound: h,
46
- label: y,
46
+ label: N,
47
47
  placeholder: f = "Select...",
48
48
  value: n,
49
49
  onChange: g,
50
50
  disabled: A = !1,
51
- className: v,
52
- wrpClassName: D,
51
+ className: D,
52
+ wrpClassName: v,
53
53
  noResultsMessage: E,
54
54
  clearable: S = !0,
55
55
  multiple: l = !1,
56
56
  size: ee
57
57
  }) {
58
- const [m, L] = p(!1), P = M.useRef(null), F = M.useRef(null), re = M.useRef(null), [ne, I] = p({ loading: !1, error: null }), [X, te] = p(""), W = de(X, x), [B, q] = p(/* @__PURE__ */ new Map()), [$, G] = p([]), [H, se] = p(0), [J, Q] = p(() => t?.length ? new Map(
58
+ const [m, L] = p(!1), P = R.useRef(null), F = R.useRef(null), re = R.useRef(null), [ne, I] = p({ loading: !1, error: null }), [X, te] = p(""), W = de(X, w), [B, q] = p(/* @__PURE__ */ new Map()), [$, G] = p([]), [H, se] = p(0), [J, Q] = p(() => t?.length ? new Map(
59
59
  t.map((e) => [a(e), e])
60
60
  ) : /* @__PURE__ */ new Map());
61
- N(() => {
61
+ b(() => {
62
62
  t?.length && (q((e) => {
63
63
  const o = new Map(e);
64
64
  return o.has("") || o.set("", t), o;
@@ -67,15 +67,15 @@ function Be({
67
67
  return t.forEach((c) => o.set(a(c), c)), o;
68
68
  }));
69
69
  }, [t, a]);
70
- const [R, Y] = p([]), z = j(
70
+ const [k, Y] = p([]), z = j(
71
71
  (e) => {
72
72
  if (!e) {
73
73
  Y([]);
74
74
  return;
75
75
  }
76
76
  const c = (Array.isArray(e) ? e : [e]).map((d) => {
77
- const w = J.get(d);
78
- if (w) return w;
77
+ const y = J.get(d);
78
+ if (y) return y;
79
79
  if (t?.length) {
80
80
  const T = t.find(
81
81
  (le) => a(le) === d
@@ -90,11 +90,11 @@ function Be({
90
90
  },
91
91
  [J, a, t, $]
92
92
  );
93
- N(() => {
93
+ b(() => {
94
94
  z(n);
95
95
  }, [n, z]);
96
- const K = M.useMemo(() => l ? null : R[0] ?? null, [l, R]);
97
- N(() => {
96
+ const K = R.useMemo(() => l ? null : k[0] ?? null, [l, k]);
97
+ b(() => {
98
98
  if (!m) return;
99
99
  const e = W || "";
100
100
  if (B.has(e)) {
@@ -106,8 +106,8 @@ function Be({
106
106
  I({ loading: !0, error: null });
107
107
  const c = await i(W);
108
108
  q((d) => new Map(d).set(e, c)), G(c), Q((d) => {
109
- const w = new Map(d);
110
- return c.forEach((U) => w.set(a(U), U)), w;
109
+ const y = new Map(d);
110
+ return c.forEach((U) => y.set(a(U), U)), y;
111
111
  });
112
112
  } catch (c) {
113
113
  I({
@@ -118,11 +118,11 @@ function Be({
118
118
  I((c) => ({ ...c, loading: !1 }));
119
119
  }
120
120
  })();
121
- }, [m, W, B, i, a]), N(() => {
121
+ }, [m, W, B, i, a]), b(() => {
122
122
  m && z(n);
123
- }, [m, z, n]), N(() => {
123
+ }, [m, z, n]), b(() => {
124
124
  m && P.current && P.current.focus();
125
- }, [m]), N(() => {
125
+ }, [m]), b(() => {
126
126
  if (!m || !F.current) return;
127
127
  const e = F.current.getBoundingClientRect();
128
128
  se(e.width);
@@ -137,7 +137,7 @@ function Be({
137
137
  if (!l) return;
138
138
  const o = Array.isArray(n) ? n : [], c = o.includes(e);
139
139
  let d;
140
- c ? d = o.filter((w) => w !== e) : d = [...o, e], g?.(d);
140
+ c ? d = o.filter((y) => y !== e) : d = [...o, e], g?.(d);
141
141
  },
142
142
  [n, g, l]
143
143
  ), oe = j(
@@ -145,9 +145,9 @@ function Be({
145
145
  e.stopPropagation(), e.preventDefault(), g?.(l ? [] : ""), L(!1);
146
146
  },
147
147
  [g]
148
- ), Z = M.useId();
149
- return /* @__PURE__ */ u("div", { className: k("flex flex-col gap-2", D), children: [
150
- y && /* @__PURE__ */ r(pe, { htmlFor: Z, children: y }),
148
+ ), Z = R.useId();
149
+ return /* @__PURE__ */ u("div", { className: M("flex flex-col gap-1.5", v), children: [
150
+ N && /* @__PURE__ */ r(pe, { htmlFor: Z, children: N }),
151
151
  /* @__PURE__ */ u(xe, { open: m, onOpenChange: L, children: [
152
152
  /* @__PURE__ */ r(we, { asChild: !0, children: /* @__PURE__ */ r(
153
153
  "button",
@@ -156,18 +156,19 @@ function Be({
156
156
  ref: F,
157
157
  type: "button",
158
158
  disabled: A,
159
- className: k(
159
+ className: M(
160
160
  Ce({ size: ee }),
161
161
  "!border-d-border/50 border !shadow-none",
162
162
  A && "cursor-not-allowed opacity-50",
163
163
  "font-normal",
164
164
  "w-full",
165
- "focus-visible:ring-d-ring focus-visible:ring-1",
166
- m && "ring-d-ring ring-1",
167
- v
165
+ "w-full",
166
+ x.focusRing,
167
+ m && x.activeRing,
168
+ D
168
169
  ),
169
170
  children: /* @__PURE__ */ u("div", { className: "flex w-full flex-1 items-center justify-between overflow-hidden", children: [
170
- l ? Array.isArray(n) && n.length > 0 ? /* @__PURE__ */ r("div", { className: "min-w-0 flex-1 truncate text-left", children: n.length === 1 ? R[0] && s(R[0]) : `${n.length} elementi selezionati` }) : /* @__PURE__ */ r("span", { className: "text-d-muted-foreground truncate text-left", children: f }) : K ? /* @__PURE__ */ r("div", { className: "min-w-0 flex-1 truncate text-left", children: s(K) }) : /* @__PURE__ */ r("span", { className: "text-d-muted-foreground truncate text-left", children: f }),
171
+ l ? Array.isArray(n) && n.length > 0 ? /* @__PURE__ */ r("div", { className: "min-w-0 flex-1 truncate text-left", children: n.length === 1 ? k[0] && s(k[0]) : `${n.length} elementi selezionati` }) : /* @__PURE__ */ r("span", { className: "text-d-muted-foreground truncate text-left", children: f }) : K ? /* @__PURE__ */ r("div", { className: "min-w-0 flex-1 truncate text-left", children: s(K) }) : /* @__PURE__ */ r("span", { className: "text-d-muted-foreground truncate text-left", children: f }),
171
172
  /* @__PURE__ */ u("div", { className: "flex flex-shrink-0 items-center justify-end gap-1", children: [
172
173
  S && (l && Array.isArray(n) && n.length > 0 || !l && K) && /* @__PURE__ */ r(
173
174
  "div",
@@ -201,7 +202,7 @@ function Be({
201
202
  /* @__PURE__ */ r(
202
203
  ye,
203
204
  {
204
- className: k("p-0"),
205
+ className: M("p-0"),
205
206
  style: { width: H ? `${H}px` : void 0 },
206
207
  align: "start",
207
208
  side: "bottom",
@@ -237,20 +238,20 @@ function Be({
237
238
  function Ae({
238
239
  option: i,
239
240
  multiple: t,
240
- value: x,
241
+ value: w,
241
242
  resolveOptionValue: C,
242
243
  renderSelectedValue: a,
243
244
  renderOptionItem: s,
244
245
  onSelect: h,
245
- onSelectMultiple: y
246
+ onSelectMultiple: N
246
247
  }) {
247
248
  const f = C(i);
248
249
  let n = !1;
249
- return t ? n = Array.isArray(x) && x.includes(f) : n = x === f, /* @__PURE__ */ r(
250
+ return t ? n = Array.isArray(w) && w.includes(f) : n = w === f, /* @__PURE__ */ r(
250
251
  V,
251
252
  {
252
253
  value: f,
253
- onSelect: t ? y : h,
254
+ onSelect: t ? N : h,
254
255
  className: "cursor-pointer",
255
256
  children: /* @__PURE__ */ u("div", { className: "flex w-full items-center justify-between overflow-hidden", children: [
256
257
  /* @__PURE__ */ u("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
@@ -260,7 +261,7 @@ function Ae({
260
261
  /* @__PURE__ */ r(
261
262
  be,
262
263
  {
263
- className: k(
264
+ className: M(
264
265
  "ml-2 h-4 w-4 flex-shrink-0",
265
266
  n ? "opacity-100" : "opacity-0"
266
267
  )
@@ -274,18 +275,18 @@ function Ae({
274
275
  function Se({
275
276
  inputRef: i,
276
277
  commandListRef: t,
277
- placeholder: x,
278
+ placeholder: w,
278
279
  searchTerm: C,
279
280
  onSearchTermChange: a,
280
281
  fetchState: s,
281
282
  options: h,
282
- notFound: y,
283
+ notFound: N,
283
284
  noResultsMessage: f,
284
285
  multiple: n,
285
286
  value: g,
286
287
  resolveOptionValue: A,
287
- renderSelectedValue: v,
288
- renderOptionItem: D,
288
+ renderSelectedValue: D,
289
+ renderOptionItem: v,
289
290
  onSelect: E,
290
291
  onSelectMultiple: S
291
292
  }) {
@@ -294,7 +295,7 @@ function Se({
294
295
  ue,
295
296
  {
296
297
  ref: i,
297
- placeholder: x,
298
+ placeholder: w,
298
299
  className: "placeholder:text-d-muted-foreground",
299
300
  value: C,
300
301
  onValueChange: a
@@ -303,8 +304,8 @@ function Se({
303
304
  s.loading && h.length > 0 && /* @__PURE__ */ r("div", { className: "flex items-center justify-center p-2", children: /* @__PURE__ */ r(Ne, { className: "h-4 w-4 animate-spin" }) }),
304
305
  /* @__PURE__ */ u(he, { ref: t, children: [
305
306
  s.error && /* @__PURE__ */ r("div", { className: "text-d-destructive p-3 text-center", children: s.error }),
306
- s.loading && h.length === 0 && /* @__PURE__ */ r(Me, {}),
307
- !s.loading && !s.error && h.length === 0 && (y || /* @__PURE__ */ r(ge, { children: f || "No results found." })),
307
+ s.loading && h.length === 0 && /* @__PURE__ */ r(Re, {}),
308
+ !s.loading && !s.error && h.length === 0 && (N || /* @__PURE__ */ r(ge, { children: f || "No results found." })),
308
309
  !s.loading && !s.error && h.length > 0 && /* @__PURE__ */ r(O, { children: h.map((l) => /* @__PURE__ */ r(
309
310
  Ae,
310
311
  {
@@ -312,8 +313,8 @@ function Se({
312
313
  multiple: n,
313
314
  value: g,
314
315
  resolveOptionValue: A,
315
- renderSelectedValue: v,
316
- renderOptionItem: D,
316
+ renderSelectedValue: D,
317
+ renderOptionItem: v,
317
318
  onSelect: E,
318
319
  onSelectMultiple: S
319
320
  },
@@ -322,7 +323,7 @@ function Se({
322
323
  ] })
323
324
  ] });
324
325
  }
325
- function Me() {
326
+ function Re() {
326
327
  return /* @__PURE__ */ r(O, { children: [1, 2, 3].map((i) => /* @__PURE__ */ r(V, { disabled: !0, children: /* @__PURE__ */ u("div", { className: "flex w-full items-center gap-2", children: [
327
328
  /* @__PURE__ */ r("div", { className: "bg-d-secondary h-6 w-6 animate-pulse rounded-full" }),
328
329
  /* @__PURE__ */ u("div", { className: "flex flex-1 flex-col gap-1", children: [
@@ -64,7 +64,7 @@ function N({
64
64
  u,
65
65
  {
66
66
  "data-slot": "button",
67
- className: s(m({ variant: a, size: e, className: d }), "relative"),
67
+ className: s("relative", m({ variant: a, size: e, className: d })),
68
68
  ...o,
69
69
  children: [
70
70
  /* @__PURE__ */ t("span", { className: "absolute inset-0 overflow-hidden rounded-[inherit] pointer-events-none", children: /* @__PURE__ */ t("span", { className: "absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-700 ease-out" }) }),
@@ -1,98 +1,108 @@
1
1
  "use client";
2
- import { jsxs as c, jsx as r } from "react/jsx-runtime";
3
- import { Calendar as N } from "./calendar.js";
4
- import { Icon as k } from "./icon.js";
5
- import { Popover as I, PopoverTrigger as T, PopoverContent as v } from "./popover.js";
6
- import { designTokens as t } from "../../lib/design-tokens.js";
7
- import { cn as z } from "../../lib/utils.js";
8
- import * as b from "react";
9
- import { useEffect as E } from "react";
10
- import { it as R } from "../../node_modules/date-fns/locale/it.js";
2
+ import { jsxs as f, jsx as t } from "react/jsx-runtime";
3
+ import { Calendar as w } from "./calendar.js";
4
+ import { Icon as E } from "./icon.js";
5
+ import { Label as L } from "./label.js";
6
+ import { Popover as q, PopoverTrigger as A, PopoverContent as B } from "./popover.js";
7
+ import { designTokens as o } from "../../lib/design-tokens.js";
8
+ import { cn as P } from "../../lib/utils.js";
9
+ import * as c from "react";
10
+ import { useEffect as F } from "react";
11
+ import { it as G } from "../../node_modules/date-fns/locale/it.js";
11
12
  import { formatDate as d } from "../../node_modules/date-fns/format.js";
12
- import { isSameDay as q } from "../../node_modules/date-fns/isSameDay.js";
13
- function V({
13
+ import { isSameDay as H } from "../../node_modules/date-fns/isSameDay.js";
14
+ function v({
14
15
  value: e,
15
16
  onChange: p,
16
- placeholder: y = "Seleziona data",
17
- dateFormat: m = "dd/MM/yyyy",
18
- className: j,
19
- disabled: i = !1,
20
- size: n = "default",
21
- firstDate: a,
22
- lastDate: l,
23
- availableDates: u,
24
- locale: C = R,
25
- initialCalendarMonth: h,
26
- customCalendarProps: P
17
+ placeholder: I = "Seleziona data",
18
+ dateFormat: a = "dd/MM/yyyy",
19
+ className: M,
20
+ disabled: n = !1,
21
+ size: m = "default",
22
+ firstDate: l,
23
+ lastDate: u,
24
+ availableDates: h,
25
+ locale: N = G,
26
+ initialCalendarMonth: g,
27
+ customCalendarProps: j,
28
+ label: x,
29
+ wrpClassName: k
27
30
  }) {
28
- const [o, g] = b.useState(e), [S, x] = b.useState(
29
- h
30
- ), w = (s) => {
31
- g(s), s && x(s), p && p(s);
31
+ const [r, y] = c.useState(e), [O, C] = c.useState(
32
+ g
33
+ ), [S, R] = c.useState(!1), z = (s) => {
34
+ y(s), s && C(s), p && p(s);
32
35
  };
33
- let f = [];
34
- return a && f.push({ before: a }), l && f.push({ after: l }), u?.length && f.push(
35
- (s) => !u.some(
36
- (M) => q(M, s)
36
+ let i = [];
37
+ l && i.push({ before: l }), u && i.push({ after: u }), h?.length && i.push(
38
+ (s) => !h.some(
39
+ (T) => H(T, s)
37
40
  )
38
- ), i && (f = [!0]), E(() => {
39
- g(o), x(o || h);
40
- }, [o]), /* @__PURE__ */ c(I, { open: i ? !1 : void 0, children: [
41
- /* @__PURE__ */ r(T, { asChild: !0, children: /* @__PURE__ */ r(
42
- "div",
43
- {
44
- className: z(
45
- t.input.base,
46
- t.radius.default,
47
- t.text.base,
48
- t.interaction.disabled,
49
- "flex items-center justify-between px-3 py-2 font-normal whitespace-nowrap [&>span]:line-clamp-1",
50
- "focus-visible:ring-d-ring/50 focus-visible:border-d-ring outline-none focus-visible:ring-[3px]",
51
- "hover:border-d-ring cursor-pointer transition-colors",
52
- !o && "text-d-muted-foreground",
53
- i && "cursor-not-allowed opacity-50",
54
- n === "default" && t.sizes.default,
55
- n === "sm" && t.sizes.sm,
56
- n === "lg" && t.sizes.lg,
57
- j
58
- ),
59
- "aria-disabled": i,
60
- role: "button",
61
- tabIndex: i ? -1 : 0,
62
- onClick: i ? void 0 : () => {
63
- },
64
- children: /* @__PURE__ */ c("div", { className: "flex w-full items-center justify-between gap-2", children: [
65
- /* @__PURE__ */ r(
66
- k,
67
- {
68
- name: "Calendar",
69
- size: n === "default" ? "md" : n === "sm" ? "xs" : "sm"
70
- }
41
+ ), n && (i = [!0]), F(() => {
42
+ y(r), C(r || g);
43
+ }, [r]);
44
+ const b = c.useId();
45
+ return /* @__PURE__ */ f("div", { className: P("flex flex-col gap-1.5", k), children: [
46
+ x && /* @__PURE__ */ t(L, { htmlFor: b, children: x }),
47
+ /* @__PURE__ */ f(q, { open: n ? !1 : S, onOpenChange: R, children: [
48
+ /* @__PURE__ */ t(A, { asChild: !0, children: /* @__PURE__ */ f(
49
+ "div",
50
+ {
51
+ id: b,
52
+ className: P(
53
+ o.input.base,
54
+ o.radius.default,
55
+ o.text.base,
56
+ o.interaction.disabled,
57
+ "flex items-center gap-2 font-normal whitespace-nowrap [&>span]:line-clamp-1",
58
+ o.focusRing,
59
+ S && o.activeRing,
60
+ "hover:border-d-ring cursor-pointer transition-colors",
61
+ !r && "text-d-muted-foreground",
62
+ n && "cursor-not-allowed opacity-50",
63
+ m === "default" && o.sizes.default,
64
+ m === "sm" && o.sizes.sm,
65
+ m === "lg" && o.sizes.lg,
66
+ M
71
67
  ),
72
- e && typeof e == "object" && "from" in e ? /* @__PURE__ */ c("span", { children: [
73
- e.from && d(e.from, m),
74
- e.from && e.to && " - ",
75
- e.to && d(e.to, m)
76
- ] }) : o ? /* @__PURE__ */ r("span", { children: d(o, m) }) : /* @__PURE__ */ r("span", { className: "text-d-muted-foreground", children: y })
77
- ] })
78
- }
79
- ) }),
80
- /* @__PURE__ */ r(v, { className: "w-auto p-0", children: /* @__PURE__ */ r(
81
- N,
82
- {
83
- ...P || {
84
- mode: "single",
85
- selected: o,
86
- onSelect: w
87
- },
88
- autoFocus: !0,
89
- disabled: f,
90
- locale: C,
91
- defaultMonth: S
92
- }
93
- ) })
68
+ "aria-disabled": n,
69
+ role: "button",
70
+ tabIndex: n ? -1 : 0,
71
+ onClick: n ? void 0 : () => {
72
+ },
73
+ children: [
74
+ /* @__PURE__ */ t(
75
+ E,
76
+ {
77
+ name: "Calendar",
78
+ size: m === "lg" ? "sm" : "xs"
79
+ }
80
+ ),
81
+ /* @__PURE__ */ t("div", { children: e && typeof e == "object" && "from" in e ? /* @__PURE__ */ f("span", { children: [
82
+ e.from && d(e.from, a),
83
+ e.from && e.to && " - ",
84
+ e.to && d(e.to, a)
85
+ ] }) : r ? /* @__PURE__ */ t("span", { children: d(r, a) }) : /* @__PURE__ */ t("span", { className: "text-d-muted-foreground", children: I }) })
86
+ ]
87
+ }
88
+ ) }),
89
+ /* @__PURE__ */ t(B, { className: "w-auto p-0", children: /* @__PURE__ */ t(
90
+ w,
91
+ {
92
+ ...j || {
93
+ mode: "single",
94
+ selected: r,
95
+ onSelect: z
96
+ },
97
+ autoFocus: !0,
98
+ disabled: i,
99
+ locale: N,
100
+ defaultMonth: O
101
+ }
102
+ ) })
103
+ ] })
94
104
  ] });
95
105
  }
96
106
  export {
97
- V as DatePicker
107
+ v as DatePicker
98
108
  };