laif-ds 0.2.75 → 0.2.77

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.
@@ -27,7 +27,7 @@ const s = n.createContext({
27
27
  gap: ""
28
28
  }
29
29
  };
30
- function x({ className: r, size: t = "default", ...e }) {
30
+ function f({ className: r, size: t = "default", ...e }) {
31
31
  return /* @__PURE__ */ a(s.Provider, { value: { size: t }, children: /* @__PURE__ */ a(
32
32
  "div",
33
33
  {
@@ -47,7 +47,7 @@ function x({ className: r, size: t = "default", ...e }) {
47
47
  }
48
48
  ) });
49
49
  }
50
- function f({ className: r, ...t }) {
50
+ function x({ className: r, ...t }) {
51
51
  const { size: e } = n.useContext(s);
52
52
  return /* @__PURE__ */ a(
53
53
  "div",
@@ -81,6 +81,19 @@ function g({ className: r, ...t }) {
81
81
  }
82
82
  );
83
83
  }
84
+ function C({ className: r, ...t }) {
85
+ return /* @__PURE__ */ a(
86
+ "div",
87
+ {
88
+ "data-slot": "card-action",
89
+ className: o(
90
+ "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
91
+ r
92
+ ),
93
+ ...t
94
+ }
95
+ );
96
+ }
84
97
  function b({ className: r, ...t }) {
85
98
  const { size: e } = n.useContext(s);
86
99
  return /* @__PURE__ */ a(
@@ -92,7 +105,7 @@ function b({ className: r, ...t }) {
92
105
  }
93
106
  );
94
107
  }
95
- function C({ className: r, ...t }) {
108
+ function y({ className: r, ...t }) {
96
109
  const { size: e } = n.useContext(s);
97
110
  return /* @__PURE__ */ a(
98
111
  "div",
@@ -107,10 +120,11 @@ function C({ className: r, ...t }) {
107
120
  );
108
121
  }
109
122
  export {
110
- x as Card,
123
+ f as Card,
124
+ C as CardAction,
111
125
  b as CardContent,
112
126
  g as CardDescription,
113
- C as CardFooter,
114
- f as CardHeader,
127
+ y as CardFooter,
128
+ x as CardHeader,
115
129
  m as CardTitle
116
130
  };
@@ -22,132 +22,140 @@ const U = {
22
22
  gif: ".gif",
23
23
  image: "image/*",
24
24
  video: "video/*",
25
- audio: "audio/*"
25
+ audio: "audio/*",
26
+ // Keep both extensions and MIME aliases because archive file types are
27
+ // reported inconsistently across browsers and operating systems.
28
+ zip: ".zip,application/zip,application/x-zip-compressed,multipart/x-zip",
29
+ rar: ".rar,application/vnd.rar,application/x-rar-compressed",
30
+ "7z": ".7z,application/x-7z-compressed",
31
+ tar: ".tar,application/x-tar",
32
+ gz: ".gz,application/gzip,application/x-gzip",
33
+ tgz: ".tgz,.tar.gz,application/gzip,application/x-compressed-tar"
26
34
  }, R = (g) => Math.ceil(g / (1024 * 1024)), ee = ({
27
35
  extensions: g = ["pdf", "image", "video", "audio"],
28
- multiple: f = !1,
29
- onUpload: b,
30
- description: y = "Trascina un file o clicca per selezionare",
31
- formatDescription: w = "Formato accettato: PDF, Immagini, Video, Audio",
32
- selectedLabel: N = "File selezionati",
33
- maxTotalSize: d,
34
- removeAllLabel: j = "rimuovi tutto",
36
+ multiple: p = !1,
37
+ onUpload: z,
38
+ description: I = "Trascina un file o clicca per selezionare",
39
+ formatDescription: b = "Formato accettato: PDF, Immagini, Video, Audio",
40
+ selectedLabel: y = "File selezionati",
41
+ maxTotalSize: c,
42
+ removeAllLabel: N = "rimuovi tutto",
35
43
  maxFiles: x,
36
- id: i,
37
- "data-testid": z
44
+ id: s,
45
+ "data-testid": j
38
46
  }) => {
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("*", ""))))
47
+ const f = g.map((e) => U[e]).join(","), [a, u] = l.useState([]), [w, D] = l.useState(""), o = (e) => {
48
+ const n = Array.from(e).filter(
49
+ (i) => f.split(",").some((t) => (t = t.trim(), i.type.startsWith(t.replace("/*", "")) || i.name.toLowerCase().endsWith(t.replace("*", ""))))
42
50
  );
43
- let c = [];
51
+ let d = [];
44
52
  const m = [];
45
- if (f) {
46
- let n = o;
53
+ if (p) {
54
+ let i = n;
47
55
  if (typeof x == "number") {
48
- const t = Math.max(x - s.length, 0);
49
- t < o.length && (n = o.slice(0, t), m.push(`Max ${x} file`));
56
+ const t = Math.max(x - a.length, 0);
57
+ t < n.length && (i = n.slice(0, t), m.push(`Max ${x} file`));
50
58
  }
51
- if (typeof d == "number") {
52
- const t = d;
53
- let F = s.reduce((h, A) => h + (A.size || 0), 0);
59
+ if (typeof c == "number") {
60
+ const t = c;
61
+ let F = a.reduce((h, A) => h + (A.size || 0), 0);
54
62
  const M = [];
55
63
  let $ = !1;
56
- for (const h of n)
64
+ for (const h of i)
57
65
  F + (h.size || 0) <= t ? (M.push(h), F += h.size || 0) : $ || (m.push(`Max ${R(t)} MB`), $ = !0);
58
- n = M;
66
+ i = M;
59
67
  }
60
- c = [...s, ...n];
68
+ d = [...a, ...i];
61
69
  } else {
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;
70
+ const i = n[0] ? [n[0]] : [];
71
+ if (typeof c == "number" && i[0]) {
72
+ const t = c;
73
+ (i[0].size || 0) > t ? (m.push(`Max ${R(t)} MB`), d = a) : d = i;
66
74
  } else
67
- c = n;
75
+ d = i;
68
76
  }
69
- p(c), I(m.join(" • ")), b?.(c);
77
+ u(d), D(m.join(" • ")), z?.(d);
70
78
  }, E = (e) => {
71
- e.target.files && a(e.target.files), e.target.value = "";
79
+ e.target.files && o(e.target.files), e.target.value = "";
72
80
  }, L = (e) => {
73
- e.preventDefault(), a(e.dataTransfer.files);
81
+ e.preventDefault(), o(e.dataTransfer.files);
74
82
  }, C = (e) => {
75
- const o = s.filter((c, m) => m !== e);
76
- p(o), I(""), b?.(o);
83
+ const n = a.filter((d, m) => m !== e);
84
+ u(n), D(""), z?.(n);
77
85
  };
78
86
  return /* @__PURE__ */ v("div", { className: "mx-auto w-full space-y-4", children: [
79
- (f || s.length === 0) && /* @__PURE__ */ r(
87
+ (p || a.length === 0) && /* @__PURE__ */ r(
80
88
  V,
81
89
  {
82
- accept: u,
83
- multiple: f,
90
+ accept: f,
91
+ multiple: p,
84
92
  onDrop: L,
85
93
  onChange: E,
86
- description: y,
87
- formatDescription: w,
88
- errorCaption: D,
89
- id: i,
90
- "data-testid": z
94
+ description: I,
95
+ formatDescription: b,
96
+ errorCaption: w,
97
+ id: s,
98
+ "data-testid": j
91
99
  }
92
100
  ),
93
- s.length > 0 && /* @__PURE__ */ r(B, { children: /* @__PURE__ */ v(P, { size: "sm", className: "shadow-none", children: [
101
+ a.length > 0 && /* @__PURE__ */ r(B, { children: /* @__PURE__ */ v(P, { size: "sm", className: "shadow-none", children: [
94
102
  /* @__PURE__ */ v(_, { className: "flex justify-between", children: [
95
- /* @__PURE__ */ r(W, { children: N }),
103
+ /* @__PURE__ */ r(W, { children: y }),
96
104
  /* @__PURE__ */ r(
97
105
  S,
98
106
  {
99
107
  size: "sm",
100
108
  variant: "ghost",
101
109
  className: "text-xs",
102
- onClick: () => p([]),
103
- children: j
110
+ onClick: () => u([]),
111
+ children: N
104
112
  }
105
113
  )
106
114
  ] }),
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(
115
+ /* @__PURE__ */ r(H, { children: p ? /* @__PURE__ */ r("div", { className: "flex flex-nowrap gap-2 overflow-x-auto py-2", children: a.map((e, n) => /* @__PURE__ */ r(
108
116
  k,
109
117
  {
110
118
  file: e,
111
- onRemove: () => C(o)
119
+ onRemove: () => C(n)
112
120
  },
113
- e.name + o
114
- )) }) : /* @__PURE__ */ r(k, { file: s[0], onRemove: () => C(0) }) })
121
+ e.name + n
122
+ )) }) : /* @__PURE__ */ r(k, { file: a[0], onRemove: () => C(0) }) })
115
123
  ] }) })
116
124
  ] });
117
125
  }, V = ({
118
126
  accept: g,
119
- multiple: f,
120
- onDrop: b,
121
- onChange: y,
122
- description: w,
123
- formatDescription: N,
124
- errorCaption: d,
125
- id: j,
127
+ multiple: p,
128
+ onDrop: z,
129
+ onChange: I,
130
+ description: b,
131
+ formatDescription: y,
132
+ errorCaption: c,
133
+ id: N,
126
134
  "data-testid": x
127
135
  }) => {
128
- const i = l.useRef(null), [z, u] = l.useState(!1), s = l.useId(), p = l.useId(), D = l.useId(), I = l.useId();
136
+ const s = l.useRef(null), [j, f] = l.useState(!1), a = l.useId(), u = l.useId(), w = l.useId(), D = l.useId();
129
137
  return /* @__PURE__ */ v(
130
138
  "div",
131
139
  {
132
- id: j,
140
+ id: N,
133
141
  "data-testid": x,
134
142
  role: "button",
135
143
  tabIndex: 0,
136
- "aria-label": w || "Seleziona file",
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()));
144
+ "aria-label": b || "Seleziona file",
145
+ "aria-describedby": `${a} ${u}${c ? ` ${w}` : ""}`,
146
+ onKeyDown: (o) => {
147
+ (o.key === "Enter" || o.key === " ") && (o.preventDefault(), s.current && (s.current.value = "", s.current.click()));
140
148
  },
141
149
  onClick: () => {
142
- i.current && (i.current.value = "", i.current.click());
150
+ s.current && (s.current.value = "", s.current.click());
143
151
  },
144
- onDragEnter: () => u(!0),
145
- onDragOver: (a) => a.preventDefault(),
146
- onDragLeave: () => u(!1),
147
- onDrop: (a) => {
148
- u(!1), b(a);
152
+ onDragEnter: () => f(!0),
153
+ onDragOver: (o) => o.preventDefault(),
154
+ onDragLeave: () => f(!1),
155
+ onDrop: (o) => {
156
+ f(!1), z(o);
149
157
  },
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" : ""}`,
158
+ 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 ${j ? "bg-muted/40" : ""}`,
151
159
  children: [
152
160
  /* @__PURE__ */ r(
153
161
  K,
@@ -157,27 +165,27 @@ const U = {
157
165
  }
158
166
  ),
159
167
  /* @__PURE__ */ v("div", { className: "max-w-xs text-center", children: [
160
- /* @__PURE__ */ r("p", { id: s, className: "text-d-muted-foreground text-sm font-medium", children: w }),
168
+ /* @__PURE__ */ r("p", { id: a, className: "text-d-muted-foreground text-sm font-medium", children: b }),
161
169
  /* @__PURE__ */ r(
162
170
  "p",
163
171
  {
164
- id: p,
172
+ id: u,
165
173
  className: "text-d-muted-foreground text-muted-foreground mt-1 text-xs",
166
- children: N
174
+ children: y
167
175
  }
168
176
  ),
169
- d ? /* @__PURE__ */ r("p", { id: D, className: "mt-2 text-xs font-medium text-red-600", children: d }) : null
177
+ c ? /* @__PURE__ */ r("p", { id: w, className: "mt-2 text-xs font-medium text-red-600", children: c }) : null
170
178
  ] }),
171
179
  /* @__PURE__ */ r(
172
180
  O,
173
181
  {
174
- ref: i,
175
- id: I,
182
+ ref: s,
183
+ id: D,
176
184
  type: "file",
177
185
  className: "hidden",
178
186
  accept: g,
179
- multiple: f,
180
- onChange: y
187
+ multiple: p,
188
+ onChange: I
181
189
  }
182
190
  )
183
191
  ]