laif-ds 0.2.63 → 0.2.64

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,69 +1,72 @@
1
1
  "use client";
2
- import { jsxs as f, jsx as t } from "react/jsx-runtime";
2
+ import { jsxs as a, jsx as r } from "react/jsx-runtime";
3
3
  import { designTokens as o } from "../design-tokens.js";
4
- import { Calendar as T } from "./calendar.js";
5
- import { Icon as E } from "./icon.js";
6
- import { Label as L } from "./label.js";
7
- import { Popover as q, PopoverTrigger as A, PopoverContent as B } from "./popover.js";
8
- import { cn as P } from "../../lib/utils.js";
4
+ import { Calendar as q } from "./calendar.js";
5
+ import { Icon as A } from "./icon.js";
6
+ import { Label as B } from "./label.js";
7
+ import { Popover as F, PopoverTrigger as G, PopoverContent as H } from "./popover.js";
8
+ import { cn as b } from "../../lib/utils.js";
9
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";
12
- import { formatDate as d } from "../../node_modules/date-fns/format.js";
13
- import { isSameDay as H } from "../../node_modules/date-fns/isSameDay.js";
14
- function v({
10
+ import { useEffect as J } from "react";
11
+ import { it as K } from "../../node_modules/date-fns/locale/it.js";
12
+ import { formatDate as f } from "../../node_modules/date-fns/format.js";
13
+ import { isSameDay as Q } from "../../node_modules/date-fns/isSameDay.js";
14
+ function oe({
15
15
  value: e,
16
16
  onChange: p,
17
- placeholder: I = "Seleziona data",
18
- dateFormat: a = "dd/MM/yyyy",
19
- className: M,
17
+ placeholder: P = "Seleziona data",
18
+ dateFormat: m = "dd/MM/yyyy",
19
+ className: k,
20
20
  disabled: s = !1,
21
- size: m = "default",
21
+ size: d = "default",
22
22
  firstDate: l,
23
23
  lastDate: u,
24
24
  availableDates: h,
25
- locale: N = G,
25
+ locale: M = K,
26
26
  initialCalendarMonth: g,
27
- customCalendarProps: j,
27
+ customCalendarProps: N,
28
28
  label: x,
29
- wrpClassName: k
29
+ wrpClassName: j,
30
+ id: O,
31
+ "data-testid": R
30
32
  }) {
31
- const [r, y] = c.useState(e), [O, C] = c.useState(
33
+ const [t, y] = c.useState(e), [w, C] = c.useState(
32
34
  g
33
- ), [S, R] = c.useState(!1), w = (n) => {
35
+ ), [I, z] = c.useState(!1), T = (n) => {
34
36
  y(n), n && C(n), p && p(n);
35
37
  };
36
38
  let i = [];
37
39
  l && i.push({ before: l }), u && i.push({ after: u }), h?.length && i.push(
38
40
  (n) => !h.some(
39
- (z) => H(z, n)
41
+ (L) => Q(L, n)
40
42
  )
41
- ), s && (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: s ? !1 : S, onOpenChange: R, children: [
48
- /* @__PURE__ */ t(A, { asChild: !0, children: /* @__PURE__ */ f(
43
+ ), s && (i = [!0]), J(() => {
44
+ y(t), C(t || g);
45
+ }, [t]);
46
+ const E = c.useId(), S = O ?? E;
47
+ return /* @__PURE__ */ a("div", { className: b("flex flex-col gap-1.5", j), children: [
48
+ x && /* @__PURE__ */ r(B, { htmlFor: S, children: x }),
49
+ /* @__PURE__ */ a(F, { open: s ? !1 : I, onOpenChange: z, children: [
50
+ /* @__PURE__ */ r(G, { asChild: !0, children: /* @__PURE__ */ a(
49
51
  "div",
50
52
  {
51
- id: b,
52
- className: P(
53
+ id: S,
54
+ "data-testid": R,
55
+ className: b(
53
56
  o.input.base,
54
57
  o.radius.default,
55
58
  o.text.base,
56
59
  o.interaction.disabled,
57
60
  "flex items-center gap-2 font-normal whitespace-nowrap [&>span]:line-clamp-1",
58
61
  o.focusRing,
59
- S && o.activeRing,
62
+ I && o.activeRing,
60
63
  "hover:border-d-ring cursor-pointer transition-colors",
61
- !r && "text-d-muted-foreground",
64
+ !t && "text-d-muted-foreground",
62
65
  s && "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
66
+ d === "default" && o.sizes.default,
67
+ d === "sm" && o.sizes.sm,
68
+ d === "lg" && o.sizes.lg,
69
+ k
67
70
  ),
68
71
  "aria-disabled": s,
69
72
  role: "button",
@@ -71,32 +74,32 @@ function v({
71
74
  onClick: s ? void 0 : () => {
72
75
  },
73
76
  children: [
74
- /* @__PURE__ */ t(E, { name: "Calendar", size: m === "lg" ? "sm" : "xs" }),
75
- /* @__PURE__ */ t("div", { children: e && typeof e == "object" && "from" in e ? /* @__PURE__ */ f("span", { children: [
76
- e.from && d(e.from, a),
77
+ /* @__PURE__ */ r(A, { name: "Calendar", size: d === "lg" ? "sm" : "xs" }),
78
+ /* @__PURE__ */ r("div", { children: e && typeof e == "object" && "from" in e ? /* @__PURE__ */ a("span", { children: [
79
+ e.from && f(e.from, m),
77
80
  e.from && e.to && " - ",
78
- e.to && d(e.to, a)
79
- ] }) : r ? /* @__PURE__ */ t("span", { children: d(r, a) }) : /* @__PURE__ */ t("span", { className: "text-d-muted-foreground", children: I }) })
81
+ e.to && f(e.to, m)
82
+ ] }) : t ? /* @__PURE__ */ r("span", { children: f(t, m) }) : /* @__PURE__ */ r("span", { className: "text-d-muted-foreground", children: P }) })
80
83
  ]
81
84
  }
82
85
  ) }),
83
- /* @__PURE__ */ t(B, { className: "w-auto p-0 shadow", children: /* @__PURE__ */ t(
84
- T,
86
+ /* @__PURE__ */ r(H, { className: "w-auto p-0 shadow", children: /* @__PURE__ */ r(
87
+ q,
85
88
  {
86
- ...j || {
89
+ ...N || {
87
90
  mode: "single",
88
- selected: r,
89
- onSelect: w
91
+ selected: t,
92
+ onSelect: T
90
93
  },
91
94
  autoFocus: !0,
92
95
  disabled: i,
93
- locale: N,
94
- defaultMonth: O
96
+ locale: M,
97
+ defaultMonth: w
95
98
  }
96
99
  ) })
97
100
  ] })
98
101
  ] });
99
102
  }
100
103
  export {
101
- v as DatePicker
104
+ oe as DatePicker
102
105
  };
@@ -1,12 +1,12 @@
1
1
  "use client";
2
- import { jsxs as v, jsx as r, Fragment as L } from "react/jsx-runtime";
3
- import c from "react";
4
- import { Button as A } from "./button.js";
5
- import { Card as B, CardHeader as S, CardTitle as P, CardContent as _ } from "./card.js";
6
- import { FilePreview as M } from "./file-preview.js";
7
- import { Icon as W } from "./icon.js";
8
- import { Input as H } from "./input.js";
9
- const K = {
2
+ import { jsxs as v, jsx as r, Fragment as B } from "react/jsx-runtime";
3
+ import l from "react";
4
+ import { Button as S } from "./button.js";
5
+ import { Card as P, CardHeader as _, CardTitle as W, CardContent as H } from "./card.js";
6
+ import { FilePreview as k } from "./file-preview.js";
7
+ import { Icon as K } from "./icon.js";
8
+ import { Input as O } from "./input.js";
9
+ const U = {
10
10
  pdf: "application/pdf",
11
11
  doc: ".doc",
12
12
  docx: ".docx",
@@ -23,133 +23,141 @@ const K = {
23
23
  image: "image/*",
24
24
  video: "video/*",
25
25
  audio: "audio/*"
26
- }, $ = (g) => Math.ceil(g / (1024 * 1024)), X = ({
26
+ }, R = (g) => Math.ceil(g / (1024 * 1024)), ee = ({
27
27
  extensions: g = ["pdf", "image", "video", "audio"],
28
28
  multiple: f = !1,
29
29
  onUpload: b,
30
30
  description: y = "Trascina un file o clicca per selezionare",
31
31
  formatDescription: w = "Formato accettato: PDF, Immagini, Video, Audio",
32
32
  selectedLabel: N = "File selezionati",
33
- maxTotalSize: l,
34
- removeAllLabel: a = "rimuovi tutto",
35
- maxFiles: x
33
+ maxTotalSize: d,
34
+ removeAllLabel: j = "rimuovi tutto",
35
+ maxFiles: x,
36
+ id: i,
37
+ "data-testid": z
36
38
  }) => {
37
- const u = g.map((e) => K[e]).join(","), [n, p] = c.useState([]), [D, I] = c.useState(""), i = (e) => {
38
- const s = Array.from(e).filter(
39
- (o) => u.split(",").some((t) => (t = t.trim(), o.type.startsWith(t.replace("/*", "")) || o.name.toLowerCase().endsWith(t.replace("*", ""))))
39
+ const u = g.map((e) => U[e]).join(","), [s, p] = l.useState([]), [D, I] = l.useState(""), a = (e) => {
40
+ const o = Array.from(e).filter(
41
+ (n) => u.split(",").some((t) => (t = t.trim(), n.type.startsWith(t.replace("/*", "")) || n.name.toLowerCase().endsWith(t.replace("*", ""))))
40
42
  );
41
- let d = [];
43
+ let c = [];
42
44
  const m = [];
43
45
  if (f) {
44
- let o = s;
46
+ let n = o;
45
47
  if (typeof x == "number") {
46
- const t = Math.max(x - n.length, 0);
47
- t < s.length && (o = s.slice(0, t), m.push(`Max ${x} file`));
48
+ const t = Math.max(x - s.length, 0);
49
+ t < o.length && (n = o.slice(0, t), m.push(`Max ${x} file`));
48
50
  }
49
- if (typeof l == "number") {
50
- const t = l;
51
- let z = n.reduce((h, E) => h + (E.size || 0), 0);
52
- const C = [];
53
- let F = !1;
54
- for (const h of o)
55
- z + (h.size || 0) <= t ? (C.push(h), z += h.size || 0) : F || (m.push(`Max ${$(t)} MB`), F = !0);
56
- o = C;
51
+ if (typeof d == "number") {
52
+ const t = d;
53
+ let F = s.reduce((h, A) => h + (A.size || 0), 0);
54
+ const M = [];
55
+ let $ = !1;
56
+ for (const h of n)
57
+ F + (h.size || 0) <= t ? (M.push(h), F += h.size || 0) : $ || (m.push(`Max ${R(t)} MB`), $ = !0);
58
+ n = M;
57
59
  }
58
- d = [...n, ...o];
60
+ c = [...s, ...n];
59
61
  } else {
60
- const o = s[0] ? [s[0]] : [];
61
- if (typeof l == "number" && o[0]) {
62
- const t = l;
63
- (o[0].size || 0) > t ? (m.push(`Max ${$(t)} MB`), d = n) : d = o;
62
+ const n = o[0] ? [o[0]] : [];
63
+ if (typeof d == "number" && n[0]) {
64
+ const t = d;
65
+ (n[0].size || 0) > t ? (m.push(`Max ${R(t)} MB`), c = s) : c = n;
64
66
  } else
65
- d = o;
67
+ c = n;
66
68
  }
67
- p(d), I(m.join(" • ")), b?.(d);
68
- }, k = (e) => {
69
- e.target.files && i(e.target.files), e.target.value = "";
70
- }, R = (e) => {
71
- e.preventDefault(), i(e.dataTransfer.files);
72
- }, j = (e) => {
73
- const s = n.filter((d, m) => m !== e);
74
- p(s), I(""), b?.(s);
69
+ p(c), I(m.join(" • ")), b?.(c);
70
+ }, E = (e) => {
71
+ e.target.files && a(e.target.files), e.target.value = "";
72
+ }, L = (e) => {
73
+ e.preventDefault(), a(e.dataTransfer.files);
74
+ }, C = (e) => {
75
+ const o = s.filter((c, m) => m !== e);
76
+ p(o), I(""), b?.(o);
75
77
  };
76
78
  return /* @__PURE__ */ v("div", { className: "mx-auto w-full space-y-4", children: [
77
- (f || n.length === 0) && /* @__PURE__ */ r(
78
- O,
79
+ (f || s.length === 0) && /* @__PURE__ */ r(
80
+ V,
79
81
  {
80
82
  accept: u,
81
83
  multiple: f,
82
- onDrop: R,
83
- onChange: k,
84
+ onDrop: L,
85
+ onChange: E,
84
86
  description: y,
85
87
  formatDescription: w,
86
- errorCaption: D
88
+ errorCaption: D,
89
+ id: i,
90
+ "data-testid": z
87
91
  }
88
92
  ),
89
- n.length > 0 && /* @__PURE__ */ r(L, { children: /* @__PURE__ */ v(B, { size: "sm", className: "shadow-none", children: [
90
- /* @__PURE__ */ v(S, { className: "flex justify-between", children: [
91
- /* @__PURE__ */ r(P, { children: N }),
93
+ s.length > 0 && /* @__PURE__ */ r(B, { children: /* @__PURE__ */ v(P, { size: "sm", className: "shadow-none", children: [
94
+ /* @__PURE__ */ v(_, { className: "flex justify-between", children: [
95
+ /* @__PURE__ */ r(W, { children: N }),
92
96
  /* @__PURE__ */ r(
93
- A,
97
+ S,
94
98
  {
95
99
  size: "sm",
96
100
  variant: "ghost",
97
101
  className: "text-xs",
98
102
  onClick: () => p([]),
99
- children: a
103
+ children: j
100
104
  }
101
105
  )
102
106
  ] }),
103
- /* @__PURE__ */ r(_, { children: f ? /* @__PURE__ */ r("div", { className: "flex flex-nowrap gap-2 overflow-x-auto py-2", children: n.map((e, s) => /* @__PURE__ */ r(
104
- M,
107
+ /* @__PURE__ */ r(H, { children: f ? /* @__PURE__ */ r("div", { className: "flex flex-nowrap gap-2 overflow-x-auto py-2", children: s.map((e, o) => /* @__PURE__ */ r(
108
+ k,
105
109
  {
106
110
  file: e,
107
- onRemove: () => j(s)
111
+ onRemove: () => C(o)
108
112
  },
109
- e.name + s
110
- )) }) : /* @__PURE__ */ r(M, { file: n[0], onRemove: () => j(0) }) })
113
+ e.name + o
114
+ )) }) : /* @__PURE__ */ r(k, { file: s[0], onRemove: () => C(0) }) })
111
115
  ] }) })
112
116
  ] });
113
- }, O = ({
117
+ }, V = ({
114
118
  accept: g,
115
119
  multiple: f,
116
120
  onDrop: b,
117
121
  onChange: y,
118
122
  description: w,
119
123
  formatDescription: N,
120
- errorCaption: l
124
+ errorCaption: d,
125
+ id: j,
126
+ "data-testid": x
121
127
  }) => {
122
- const a = c.useRef(null), [x, u] = c.useState(!1), n = c.useId(), p = c.useId(), D = c.useId(), I = c.useId();
128
+ const i = l.useRef(null), [z, u] = l.useState(!1), s = l.useId(), p = l.useId(), D = l.useId(), I = l.useId();
123
129
  return /* @__PURE__ */ v(
124
130
  "div",
125
131
  {
132
+ id: j,
133
+ "data-testid": x,
126
134
  role: "button",
127
135
  tabIndex: 0,
128
136
  "aria-label": w || "Seleziona file",
129
- "aria-describedby": `${n} ${p}${l ? ` ${D}` : ""}`,
130
- onKeyDown: (i) => {
131
- (i.key === "Enter" || i.key === " ") && (i.preventDefault(), a.current && (a.current.value = "", a.current.click()));
137
+ "aria-describedby": `${s} ${p}${d ? ` ${D}` : ""}`,
138
+ onKeyDown: (a) => {
139
+ (a.key === "Enter" || a.key === " ") && (a.preventDefault(), i.current && (i.current.value = "", i.current.click()));
132
140
  },
133
141
  onClick: () => {
134
- a.current && (a.current.value = "", a.current.click());
142
+ i.current && (i.current.value = "", i.current.click());
135
143
  },
136
144
  onDragEnter: () => u(!0),
137
- onDragOver: (i) => i.preventDefault(),
145
+ onDragOver: (a) => a.preventDefault(),
138
146
  onDragLeave: () => u(!1),
139
- onDrop: (i) => {
140
- u(!1), b(i);
147
+ onDrop: (a) => {
148
+ u(!1), b(a);
141
149
  },
142
- className: `border-d-border flex w-full cursor-pointer flex-col items-center gap-3 rounded-lg border-2 border-dashed px-4 py-8 ${x ? "bg-muted/40" : ""}`,
150
+ className: `border-d-border flex w-full cursor-pointer flex-col items-center gap-3 rounded-lg border-2 border-dashed px-4 py-8 ${z ? "bg-muted/40" : ""}`,
143
151
  children: [
144
152
  /* @__PURE__ */ r(
145
- W,
153
+ K,
146
154
  {
147
155
  name: "ArrowUpFromLine",
148
156
  className: "text-d-muted-foreground h-10 w-10"
149
157
  }
150
158
  ),
151
159
  /* @__PURE__ */ v("div", { className: "max-w-xs text-center", children: [
152
- /* @__PURE__ */ r("p", { id: n, className: "text-d-muted-foreground text-sm font-medium", children: w }),
160
+ /* @__PURE__ */ r("p", { id: s, className: "text-d-muted-foreground text-sm font-medium", children: w }),
153
161
  /* @__PURE__ */ r(
154
162
  "p",
155
163
  {
@@ -158,12 +166,12 @@ const K = {
158
166
  children: N
159
167
  }
160
168
  ),
161
- l ? /* @__PURE__ */ r("p", { id: D, className: "mt-2 text-xs font-medium text-red-600", children: l }) : null
169
+ d ? /* @__PURE__ */ r("p", { id: D, className: "mt-2 text-xs font-medium text-red-600", children: d }) : null
162
170
  ] }),
163
171
  /* @__PURE__ */ r(
164
- H,
172
+ O,
165
173
  {
166
- ref: a,
174
+ ref: i,
167
175
  id: I,
168
176
  type: "file",
169
177
  className: "hidden",
@@ -177,5 +185,5 @@ const K = {
177
185
  );
178
186
  };
179
187
  export {
180
- X as FileUploader
188
+ ee as FileUploader
181
189
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx as t, jsxs as N } from "react/jsx-runtime";
2
+ import { jsx as e, jsxs as w } from "react/jsx-runtime";
3
3
  import { cn as n } from "../../lib/utils.js";
4
4
  import { motion as c } from "framer-motion";
5
5
  import * as s from "react";
@@ -10,37 +10,41 @@ const x = {
10
10
  exit: { opacity: 0, y: -20 }
11
11
  }
12
12
  };
13
- function k({
13
+ function I({
14
14
  value: r = 1,
15
15
  onChange: l,
16
16
  min: p = 1,
17
17
  max: b = 4,
18
18
  className: g,
19
19
  buttonClassName: d,
20
- counterClassName: h
20
+ counterClassName: h,
21
+ id: v,
22
+ "data-testid": y
21
23
  }) {
22
- const [e, a] = s.useState(r), [u, m] = s.useState(!1);
24
+ const [t, a] = s.useState(r), [u, m] = s.useState(!1);
23
25
  s.useEffect(() => {
24
26
  a(r);
25
27
  }, [r]);
26
- const v = (o) => {
27
- if (o.preventDefault(), e < b) {
28
- const i = e + 1;
28
+ const N = (o) => {
29
+ if (o.preventDefault(), t < b) {
30
+ const i = t + 1;
29
31
  a(i), l?.(i);
30
32
  } else
31
33
  f();
32
- }, y = (o) => {
33
- if (o.preventDefault(), e > p) {
34
- const i = e - 1;
34
+ }, j = (o) => {
35
+ if (o.preventDefault(), t > p) {
36
+ const i = t - 1;
35
37
  a(i), l?.(i);
36
38
  } else
37
39
  f();
38
40
  }, f = () => {
39
41
  m(!0), setTimeout(() => m(!1), 300);
40
42
  };
41
- return /* @__PURE__ */ t(
43
+ return /* @__PURE__ */ e(
42
44
  c.div,
43
45
  {
46
+ id: v,
47
+ "data-testid": y,
44
48
  "data-slot": "input-selector",
45
49
  variants: x.container,
46
50
  initial: "initial",
@@ -50,7 +54,7 @@ function k({
50
54
  "flex w-full flex-col items-center justify-center gap-8",
51
55
  g
52
56
  ),
53
- children: /* @__PURE__ */ N(
57
+ children: /* @__PURE__ */ w(
54
58
  c.div,
55
59
  {
56
60
  variants: u ? {
@@ -64,11 +68,11 @@ function k({
64
68
  animate: u ? "vibrate" : "initial",
65
69
  className: "flex items-center gap-8",
66
70
  children: [
67
- /* @__PURE__ */ t(
71
+ /* @__PURE__ */ e(
68
72
  "button",
69
73
  {
70
74
  type: "button",
71
- onClick: y,
75
+ onClick: j,
72
76
  className: n(
73
77
  "border-d-border h-12 w-12 rounded-full",
74
78
  "bg-d-background",
@@ -77,10 +81,10 @@ function k({
77
81
  "flex items-center justify-center",
78
82
  d
79
83
  ),
80
- children: /* @__PURE__ */ t("span", { className: "text-2xl font-medium", children: "-" })
84
+ children: /* @__PURE__ */ e("span", { className: "text-2xl font-medium", children: "-" })
81
85
  }
82
86
  ),
83
- /* @__PURE__ */ t(
87
+ /* @__PURE__ */ e(
84
88
  c.span,
85
89
  {
86
90
  variants: x.container,
@@ -91,15 +95,15 @@ function k({
91
95
  "text-d-foreground text-2xl font-medium",
92
96
  h
93
97
  ),
94
- children: e
98
+ children: t
95
99
  },
96
- e
100
+ t
97
101
  ),
98
- /* @__PURE__ */ t(
102
+ /* @__PURE__ */ e(
99
103
  "button",
100
104
  {
101
105
  type: "button",
102
- onClick: v,
106
+ onClick: N,
103
107
  className: n(
104
108
  "border-d-border h-12 w-12 rounded-full border",
105
109
  "bg-d-background",
@@ -108,7 +112,7 @@ function k({
108
112
  "flex items-center justify-center",
109
113
  d
110
114
  ),
111
- children: /* @__PURE__ */ t("span", { className: "text-2xl font-medium", children: "+" })
115
+ children: /* @__PURE__ */ e("span", { className: "text-2xl font-medium", children: "+" })
112
116
  }
113
117
  )
114
118
  ]
@@ -118,5 +122,5 @@ function k({
118
122
  );
119
123
  }
120
124
  export {
121
- k as InputSelector
125
+ I as InputSelector
122
126
  };