@adamosuiteservices/ui 2.17.1 → 2.18.1

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,32 +1,32 @@
1
- import { j as e } from "./jsx-runtime-BzflLqGi.js";
2
- import { B as O } from "./button-BnUlAtuD.js";
3
- import { I as L } from "./icon-BFQz1tQC.js";
4
- import { T as y } from "./typography-MnY0LQoZ.js";
1
+ import { j as t } from "./jsx-runtime-BzflLqGi.js";
2
+ import { B } from "./button-BnUlAtuD.js";
3
+ import { I as A } from "./icon-BFQz1tQC.js";
4
+ import { T as $ } from "./typography-MnY0LQoZ.js";
5
5
  import { c as v } from "./index-CRiPKpXj.js";
6
- import { useState as B, useRef as W, useEffect as X } from "react";
7
- function Y({
8
- isDragging: n,
6
+ import { useState as U, useRef as P, useEffect as F } from "react";
7
+ function S({
8
+ isDragging: i,
9
9
  isMultiple: d,
10
10
  invalid: a,
11
11
  disabled: r,
12
12
  accept: m,
13
- acceptedExtensions: l,
14
- maxSizeInMB: c,
15
- maxFiles: x,
16
- labels: f,
17
- input: b,
18
- onDragOver: D,
13
+ acceptedExtensions: c,
14
+ maxSizeInMB: h,
15
+ maxFiles: f,
16
+ labels: l,
17
+ input: p,
18
+ onDragOver: g,
19
19
  onDragLeave: w,
20
- onDrop: C,
21
- onFileChange: A
20
+ onDrop: j,
21
+ onFileChange: T
22
22
  }) {
23
- const p = b?.id || `file-upload-${Math.random().toString(36).substring(2, 11)}`;
24
- return /* @__PURE__ */ e.jsxs(
23
+ const y = p?.id || `file-upload-${Math.random().toString(36).substring(2, 11)}`;
24
+ return /* @__PURE__ */ t.jsxs(
25
25
  "div",
26
26
  {
27
- onDragOver: r ? void 0 : D,
27
+ onDragOver: r ? void 0 : g,
28
28
  onDragLeave: r ? void 0 : w,
29
- onDrop: r ? void 0 : C,
29
+ onDrop: r ? void 0 : j,
30
30
  className: v(
31
31
  `
32
32
  adm:flex adm:flex-col adm:items-center adm:gap-6 adm:rounded-2xl
@@ -34,22 +34,22 @@ function Y({
34
34
  `,
35
35
  "adm:border-dashed adm:bg-background adm:p-6 adm:transition-colors",
36
36
  {
37
- "adm:border-primary": n && !a && !r,
37
+ "adm:border-primary": i && !a && !r,
38
38
  "adm:border-destructive": a && !r,
39
- "adm:border-input": !n && !a,
39
+ "adm:border-input": !i && !a,
40
40
  "adm:cursor-not-allowed adm:opacity-50": r
41
41
  }
42
42
  ),
43
43
  children: [
44
- /* @__PURE__ */ e.jsx(
44
+ /* @__PURE__ */ t.jsx(
45
45
  "div",
46
46
  {
47
47
  className: v(
48
48
  "adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
49
49
  a && !r ? "adm:bg-destructive/10" : "adm:bg-primary-50"
50
50
  ),
51
- children: /* @__PURE__ */ e.jsx(
52
- L,
51
+ children: /* @__PURE__ */ t.jsx(
52
+ A,
53
53
  {
54
54
  symbol: "text_snippet",
55
55
  className: a && !r ? "adm:text-destructive" : "adm:text-primary"
@@ -57,24 +57,24 @@ function Y({
57
57
  )
58
58
  }
59
59
  ),
60
- /* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:flex-col adm:items-center adm:gap-2", children: [
61
- /* @__PURE__ */ e.jsx(y, { color: a && !r ? "destructive" : void 0, children: f?.dragDrop || (d ? "Drag and drop your files here or" : "Drag and drop your file here or") }),
62
- /* @__PURE__ */ e.jsxs("label", { htmlFor: p, children: [
63
- /* @__PURE__ */ e.jsx(
60
+ /* @__PURE__ */ t.jsxs("div", { className: "adm:flex adm:flex-col adm:items-center adm:gap-2", children: [
61
+ /* @__PURE__ */ t.jsx($, { color: a && !r ? "destructive" : void 0, children: l?.dragDrop || (d ? "Drag and drop your files here or" : "Drag and drop your file here or") }),
62
+ /* @__PURE__ */ t.jsxs("label", { htmlFor: y, children: [
63
+ /* @__PURE__ */ t.jsx(
64
64
  "input",
65
65
  {
66
- ...b,
67
- id: p,
66
+ ...p,
67
+ id: y,
68
68
  type: "file",
69
69
  accept: m,
70
70
  multiple: d,
71
- onChange: A,
71
+ onChange: T,
72
72
  disabled: r,
73
73
  className: "adm:hidden"
74
74
  }
75
75
  ),
76
- /* @__PURE__ */ e.jsx(
77
- O,
76
+ /* @__PURE__ */ t.jsx(
77
+ B,
78
78
  {
79
79
  asChild: !0,
80
80
  type: "button",
@@ -83,18 +83,18 @@ function Y({
83
83
  adm:pointer-events-none
84
84
  `),
85
85
  disabled: r,
86
- children: /* @__PURE__ */ e.jsx("span", { children: f?.selectFile || (d ? "Select files" : "Select the file") })
86
+ children: /* @__PURE__ */ t.jsx("span", { children: l?.selectFile || (d ? "Select files" : "Select the file") })
87
87
  }
88
88
  )
89
89
  ] })
90
90
  ] }),
91
- /* @__PURE__ */ e.jsx(y, { className: "adm:text-center", color: a && !r ? "destructive" : "muted", children: f?.fileRequirements || (l && l.length > 0 ? `Allowed files: ${l.join(", ")}. Maximum size ${c} MB${d ? `. Up to ${x} files` : ""}.` : `Maximum size ${c} MB${d ? `. Up to ${x} files` : ""}.`) })
91
+ /* @__PURE__ */ t.jsx($, { className: "adm:text-center", color: a && !r ? "destructive" : "muted", children: l?.fileRequirements || (c && c.length > 0 ? `Allowed files: ${c.join(", ")}. Maximum size ${h} MB${d ? `. Up to ${f} files` : ""}.` : `Maximum size ${h} MB${d ? `. Up to ${f} files` : ""}.`) })
92
92
  ]
93
93
  }
94
94
  );
95
95
  }
96
- function Z({ file: n, invalid: d, disabled: a, onRemove: r }) {
97
- return /* @__PURE__ */ e.jsxs(
96
+ function ee({ file: i, invalid: d, disabled: a, onRemove: r }) {
97
+ return /* @__PURE__ */ t.jsxs(
98
98
  "div",
99
99
  {
100
100
  className: v(
@@ -103,15 +103,15 @@ function Z({ file: n, invalid: d, disabled: a, onRemove: r }) {
103
103
  a && "adm:cursor-not-allowed adm:opacity-50"
104
104
  ),
105
105
  children: [
106
- /* @__PURE__ */ e.jsx(
106
+ /* @__PURE__ */ t.jsx(
107
107
  "div",
108
108
  {
109
109
  className: v(
110
110
  "adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
111
111
  d && !a ? "adm:bg-destructive/10" : "adm:bg-primary-50"
112
112
  ),
113
- children: /* @__PURE__ */ e.jsx(
114
- L,
113
+ children: /* @__PURE__ */ t.jsx(
114
+ A,
115
115
  {
116
116
  symbol: "text_snippet",
117
117
  className: d && !a ? "adm:text-destructive" : "adm:text-primary"
@@ -119,199 +119,206 @@ function Z({ file: n, invalid: d, disabled: a, onRemove: r }) {
119
119
  )
120
120
  }
121
121
  ),
122
- /* @__PURE__ */ e.jsxs(
122
+ /* @__PURE__ */ t.jsxs(
123
123
  "div",
124
124
  {
125
125
  className: `
126
126
  adm:flex adm:min-w-0 adm:flex-1 adm:items-start adm:gap-3
127
127
  `,
128
128
  children: [
129
- /* @__PURE__ */ e.jsx("div", { className: "adm:min-w-0 adm:flex-1", children: /* @__PURE__ */ e.jsx(y, { className: "adm:truncate adm:font-semibold", children: n.name }) }),
130
- /* @__PURE__ */ e.jsxs(y, { className: "adm:shrink-0", color: "muted", children: [
131
- (n.size / 1024 / 1024).toFixed(1),
129
+ /* @__PURE__ */ t.jsx("div", { className: "adm:min-w-0 adm:flex-1", children: /* @__PURE__ */ t.jsx($, { className: "adm:truncate adm:font-semibold", children: i.name }) }),
130
+ /* @__PURE__ */ t.jsxs($, { className: "adm:shrink-0", color: "muted", children: [
131
+ (i.size / 1024 / 1024).toFixed(1),
132
132
  " MB"
133
133
  ] })
134
134
  ]
135
135
  }
136
136
  ),
137
- /* @__PURE__ */ e.jsx(
138
- O,
137
+ /* @__PURE__ */ t.jsx(
138
+ B,
139
139
  {
140
140
  variant: "destructive-medium",
141
141
  onClick: r,
142
142
  type: "button",
143
143
  disabled: a,
144
- children: /* @__PURE__ */ e.jsx(L, { symbol: "delete", className: "adm:text-destructive" })
144
+ children: /* @__PURE__ */ t.jsx(A, { symbol: "delete", className: "adm:text-destructive" })
145
145
  }
146
146
  )
147
147
  ]
148
148
  }
149
149
  );
150
150
  }
151
- function I({ files: n, isMultiple: d, invalid: a, disabled: r, labels: m, onRemoveFile: l, onClearAll: c }) {
152
- return n.length === 0 ? null : /* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:flex-col adm:gap-3", children: [
153
- d && n.length > 1 && /* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:items-center adm:justify-between", children: [
154
- /* @__PURE__ */ e.jsx(y, { className: "adm:text-sm adm:font-medium", color: a && !r ? "destructive" : void 0, children: m?.filesSelected?.(n.length) || `${n.length} file${n.length !== 1 ? "s" : ""} selected` }),
155
- /* @__PURE__ */ e.jsx(
156
- O,
151
+ function R({ files: i, isMultiple: d, invalid: a, disabled: r, labels: m, onRemoveFile: c, onClearAll: h }) {
152
+ return i.length === 0 ? null : /* @__PURE__ */ t.jsxs("div", { className: "adm:flex adm:flex-col adm:gap-3", children: [
153
+ d && i.length > 1 && /* @__PURE__ */ t.jsxs("div", { className: "adm:flex adm:items-center adm:justify-between", children: [
154
+ /* @__PURE__ */ t.jsx($, { className: "adm:text-sm adm:font-medium", color: a && !r ? "destructive" : void 0, children: m?.filesSelected?.(i.length) || `${i.length} file${i.length !== 1 ? "s" : ""} selected` }),
155
+ /* @__PURE__ */ t.jsx(
156
+ B,
157
157
  {
158
158
  variant: "ghost",
159
159
  size: "sm",
160
- onClick: c,
160
+ onClick: h,
161
161
  type: "button",
162
162
  disabled: r,
163
163
  children: "Clear all"
164
164
  }
165
165
  )
166
166
  ] }),
167
- n.map((x, f) => /* @__PURE__ */ e.jsx(
168
- Z,
167
+ i.map((f, l) => /* @__PURE__ */ t.jsx(
168
+ ee,
169
169
  {
170
- file: x,
170
+ file: f,
171
171
  invalid: a,
172
172
  disabled: r,
173
- onRemove: () => l(f)
173
+ onRemove: () => c(l)
174
174
  },
175
- `${x.name}-${f}`
175
+ `${f.name}-${l}`
176
176
  ))
177
177
  ] });
178
178
  }
179
- function ae({
180
- className: n,
179
+ function de({
180
+ className: i,
181
181
  selectedFile: d,
182
182
  selectedFiles: a,
183
183
  onFileSelect: r,
184
184
  onFilesSelect: m,
185
- onInvalidFile: l,
186
- acceptedExtensions: c,
187
- maxSizeInMB: x = 50,
188
- maxFiles: f = 10,
189
- multiple: b = !1,
190
- filesPosition: D = "below",
191
- invalid: w = !1,
192
- disabled: C = !1,
193
- "aria-invalid": A,
194
- labels: p,
195
- input: T,
196
- ...U
185
+ onFileAdd: c,
186
+ onFileRemove: h,
187
+ onFilesAdd: f,
188
+ onFilesRemove: l,
189
+ onInvalidFile: p,
190
+ acceptedExtensions: g,
191
+ maxSizeInMB: w = 50,
192
+ maxFiles: j = 10,
193
+ multiple: T = !1,
194
+ filesPosition: y = "below",
195
+ invalid: V = !1,
196
+ disabled: _ = !1,
197
+ "aria-invalid": M,
198
+ labels: C,
199
+ input: q,
200
+ ...G
197
201
  }) {
198
- const [V, R] = B(!1), [_, M] = B(!1), j = W(null);
199
- X(() => {
200
- const t = () => {
201
- if (j.current) {
202
- const i = j.current.closest("fieldset");
203
- M(i?.disabled ?? !1);
202
+ const [H, I] = U(!1), [J, K] = U(!1), b = P(null);
203
+ F(() => {
204
+ const e = () => {
205
+ if (b.current) {
206
+ const n = b.current.closest("fieldset");
207
+ K(n?.disabled ?? !1);
204
208
  }
205
209
  };
206
- t();
207
- const s = new MutationObserver(t);
208
- if (j.current) {
209
- const i = j.current.closest("fieldset");
210
- i && s.observe(i, { attributes: !0, attributeFilter: ["disabled"] });
210
+ e();
211
+ const s = new MutationObserver(e);
212
+ if (b.current) {
213
+ const n = b.current.closest("fieldset");
214
+ n && s.observe(n, { attributes: !0, attributeFilter: ["disabled"] });
211
215
  }
212
216
  return () => s.disconnect();
213
217
  }, []);
214
- const q = c?.join(",") || "", G = x * 1024 * 1024, o = b || a !== void 0 || m !== void 0, h = o ? a || [] : d ? [d] : [], N = w || A, u = C || _, H = (t) => {
215
- u || (t.preventDefault(), R(!0));
216
- }, J = (t) => {
217
- u || (t.preventDefault(), R(!1));
218
- }, K = (t) => {
218
+ const Q = g?.join(",") || "", W = w * 1024 * 1024, o = T || a !== void 0 || m !== void 0, x = o ? a || [] : d ? [d] : [], k = V || M, u = _ || J, X = (e) => {
219
+ u || (e.preventDefault(), I(!0));
220
+ }, Y = (e) => {
221
+ u || (e.preventDefault(), I(!1));
222
+ }, Z = (e) => {
219
223
  if (!u)
220
- if (t.preventDefault(), R(!1), o) {
221
- const i = Array.from(t.dataTransfer.files).filter($);
222
- if (i.length > 0) {
223
- const F = [...a || [], ...i].slice(0, f);
224
- m && m(F);
224
+ if (e.preventDefault(), I(!1), o) {
225
+ const n = Array.from(e.dataTransfer.files).filter(z);
226
+ if (n.length > 0) {
227
+ const N = [...a || [], ...n].slice(0, j);
228
+ m && m(N), f && f(n);
225
229
  }
226
230
  } else {
227
- const s = t.dataTransfer.files[0];
228
- s && $(s) && r && r(s);
231
+ const s = e.dataTransfer.files[0];
232
+ s && z(s) && (r && r(s), c && c(s));
229
233
  }
230
- }, Q = (t) => {
234
+ }, E = (e) => {
231
235
  if (!u) {
232
236
  if (o) {
233
- const i = (t.target.files ? Array.from(t.target.files) : []).filter($);
234
- if (i.length > 0) {
235
- const F = [...a || [], ...i].slice(0, f);
236
- m && m(F);
237
+ const n = (e.target.files ? Array.from(e.target.files) : []).filter(z);
238
+ if (n.length > 0) {
239
+ const N = [...a || [], ...n].slice(0, j);
240
+ m && m(N), f && f(n);
237
241
  }
238
242
  } else {
239
- const s = t.target.files?.[0];
240
- s && $(s) && r && r(s);
243
+ const s = e.target.files?.[0];
244
+ s && z(s) && (r && r(s), c && c(s));
241
245
  }
242
- t.target.value = "";
246
+ e.target.value = "";
243
247
  }
244
- }, k = (t) => {
245
- if (!u)
246
- if (o) {
247
- const s = h.filter((i, g) => g !== t);
248
- m && m(s);
249
- } else
250
- r && r(null);
251
- }, $ = (t) => {
252
- const s = t.name.substring(t.name.lastIndexOf(".")), i = !c || c.length === 0 || c.includes(s.toLowerCase()), g = t.size <= G;
253
- return !i && l ? l(t, "extension") : !g && l && l(t, "size"), i && g;
254
- }, z = () => {
255
- u || (o ? m && m([]) : r && r(null));
248
+ }, L = (e) => {
249
+ if (u) return;
250
+ const s = x[e];
251
+ if (o) {
252
+ const n = x.filter((D, N) => N !== e);
253
+ m && m(n), l && s && l([s]);
254
+ } else
255
+ r && r(null), h && s && h(s);
256
+ }, z = (e) => {
257
+ const s = e.name.substring(e.name.lastIndexOf(".")), n = !g || g.length === 0 || g.includes(s.toLowerCase()), D = e.size <= W;
258
+ return !n && p ? p(e, "extension") : !D && p && p(e, "size"), n && D;
259
+ }, O = () => {
260
+ if (u) return;
261
+ const e = [...x];
262
+ o ? (m && m([]), l && e.length > 0 && l(e)) : (r && r(null), h && e.length > 0 && h(e[0]));
256
263
  };
257
- return /* @__PURE__ */ e.jsxs("div", { ref: j, className: v("adm:flex adm:flex-col adm:gap-4", n), ...U, children: [
258
- o && D === "above" && /* @__PURE__ */ e.jsx(
259
- I,
264
+ return /* @__PURE__ */ t.jsxs("div", { ref: b, className: v("adm:flex adm:flex-col adm:gap-4", i), ...G, children: [
265
+ o && y === "above" && /* @__PURE__ */ t.jsx(
266
+ R,
260
267
  {
261
- files: h,
268
+ files: x,
262
269
  isMultiple: o,
263
- invalid: N,
270
+ invalid: k,
264
271
  disabled: u,
265
- labels: p,
266
- onRemoveFile: k,
267
- onClearAll: z
272
+ labels: C,
273
+ onRemoveFile: L,
274
+ onClearAll: O
268
275
  }
269
276
  ),
270
- (o || h.length === 0) && /* @__PURE__ */ e.jsx(
271
- Y,
277
+ (o || x.length === 0) && /* @__PURE__ */ t.jsx(
278
+ S,
272
279
  {
273
- isDragging: V,
280
+ isDragging: H,
274
281
  isMultiple: o,
275
- invalid: N,
282
+ invalid: k,
276
283
  disabled: u,
277
- accept: q,
278
- acceptedExtensions: c,
279
- maxSizeInMB: x,
280
- maxFiles: f,
281
- labels: p,
282
- input: T,
283
- onDragOver: H,
284
- onDragLeave: J,
285
- onDrop: K,
286
- onFileChange: Q
284
+ accept: Q,
285
+ acceptedExtensions: g,
286
+ maxSizeInMB: w,
287
+ maxFiles: j,
288
+ labels: C,
289
+ input: q,
290
+ onDragOver: X,
291
+ onDragLeave: Y,
292
+ onDrop: Z,
293
+ onFileChange: E
287
294
  }
288
295
  ),
289
- !o && h.length > 0 && /* @__PURE__ */ e.jsx(
290
- I,
296
+ !o && x.length > 0 && /* @__PURE__ */ t.jsx(
297
+ R,
291
298
  {
292
- files: h,
299
+ files: x,
293
300
  isMultiple: o,
294
- invalid: N,
301
+ invalid: k,
295
302
  disabled: u,
296
- labels: p,
297
- onRemoveFile: k,
298
- onClearAll: z
303
+ labels: C,
304
+ onRemoveFile: L,
305
+ onClearAll: O
299
306
  }
300
307
  ),
301
- o && D === "below" && /* @__PURE__ */ e.jsx(
302
- I,
308
+ o && y === "below" && /* @__PURE__ */ t.jsx(
309
+ R,
303
310
  {
304
- files: h,
311
+ files: x,
305
312
  isMultiple: o,
306
- invalid: N,
313
+ invalid: k,
307
314
  disabled: u,
308
- labels: p,
309
- onRemoveFile: k,
310
- onClearAll: z
315
+ labels: C,
316
+ onRemoveFile: L,
317
+ onClearAll: O
311
318
  }
312
319
  )
313
320
  ] });
314
321
  }
315
322
  export {
316
- ae as FileUpload
323
+ de as FileUpload
317
324
  };