@alfadocs/ui-kit 1.9.3 → 1.10.0

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.
@@ -0,0 +1,412 @@
1
+ import { useMemo as M, useState as E, useRef as T, useEffect as _ } from "react";
2
+ import { jsx as i, jsxs as L } from "react/jsx-runtime";
3
+ import { T as P } from "./tag-3wgkwwDB.js";
4
+ import { useTranslation as x } from "react-i18next";
5
+ import { I as S } from "./icon-button-DA2CAGHZ.js";
6
+ import { I as V } from "./icon-button-group-D6SVMteH.js";
7
+ import { A as $, a as H } from "./arrow-up-BYvcvTkB.js";
8
+ import { S as G } from "./square-check-big-dj0o8yA3.js";
9
+ import { S as O } from "./square-DASBRZ0U.js";
10
+ import { u as X } from "./use-isomorphic-layout-effect-BGfaCOP1.js";
11
+ import { c as D, a as U, b as j, d as A } from "./input-surface-xyERuLU_.js";
12
+ function me(t, e, n) {
13
+ return M(() => {
14
+ const c = {};
15
+ for (const r of e) {
16
+ let m = 0;
17
+ for (const u of t ?? []) {
18
+ const s = u[r], d = typeof s == "number" ? s : Number(s);
19
+ Number.isFinite(d) && (m += d);
20
+ }
21
+ c[r] = m;
22
+ }
23
+ return n != null && n.labelField && n.labelValue !== void 0 && (c[n.labelField] = n.labelValue), c;
24
+ }, [t, e, n == null ? void 0 : n.labelField, n == null ? void 0 : n.labelValue]);
25
+ }
26
+ function q() {
27
+ return /* @__PURE__ */ i(
28
+ "svg",
29
+ {
30
+ viewBox: "0 0 24 24",
31
+ fill: "none",
32
+ stroke: "currentColor",
33
+ strokeWidth: 1.75,
34
+ strokeLinecap: "round",
35
+ strokeLinejoin: "round",
36
+ "aria-hidden": "true",
37
+ className: "ds:size-3.5",
38
+ children: /* @__PURE__ */ i("path", { d: "M12 5.5c-1.074 -1.426 -2.45 -2.2 -4 -2c-2.5 .323 -3.7 2.5 -3.5 5c.1 1.5 .5 3 .5 4.5c0 1.5 .5 3.5 1 5c.3 .9 .5 2 1.5 2s1.3 -1.5 1.5 -2.5c.2 -1 .5 -2 1.5 -2s1.3 1 1.5 2c.2 1 .5 2.5 1.5 2.5s1.2 -1.1 1.5 -2c.5 -1.5 1 -3.5 1 -5c0 -1.5 .4 -3 .5 -4.5c.2 -2.5 -1 -4.677 -3.5 -5c-1.55 -.2 -2.926 .574 -4 2z" })
39
+ }
40
+ );
41
+ }
42
+ function pe(t) {
43
+ const { value: e, maxInlineSize: n = "8rem" } = t;
44
+ return !Array.isArray(e) || e.length === 0 ? null : /* @__PURE__ */ i(
45
+ P,
46
+ {
47
+ label: e.join(", "),
48
+ size: "sm",
49
+ fill: "outline",
50
+ leading: /* @__PURE__ */ i(q, {}),
51
+ maxInlineSize: n
52
+ }
53
+ );
54
+ }
55
+ function K(t) {
56
+ if (t == null || t === "") return null;
57
+ const e = typeof t == "number" ? t : Number(t);
58
+ return Number.isFinite(e) ? e : null;
59
+ }
60
+ function be(t) {
61
+ const {
62
+ value: e,
63
+ currency: n = "EUR",
64
+ colorNegative: c,
65
+ strikethrough: r,
66
+ options: m
67
+ } = t, { i18n: u } = x(), s = K(e);
68
+ if (s === null) return null;
69
+ const d = u.language || "en", a = new Intl.NumberFormat(d, {
70
+ style: "currency",
71
+ currency: n,
72
+ ...m
73
+ }).format(s), o = ["ds:tabular-nums"];
74
+ return c && s < 0 && o.push("ds:text-[color:var(--destructive)]"), r && o.push("line-through"), /* @__PURE__ */ i("span", { className: o.join(" "), children: a });
75
+ }
76
+ function ge() {
77
+ return 90;
78
+ }
79
+ function he(t) {
80
+ const {
81
+ data: e,
82
+ node: n,
83
+ api: c,
84
+ onMove: r,
85
+ moveUpLabel: m,
86
+ moveDownLabel: u,
87
+ intent: s = "ghost",
88
+ group: d = !0,
89
+ disableAtEnds: a = !0
90
+ } = t, { t: o } = x();
91
+ if (!e) return null;
92
+ const l = n.rowIndex ?? -1, b = c.getDisplayedRowCount() - 1, g = a && l <= 0, C = a && l >= b, N = m ?? o("dataTable.moveUp", "Move up"), y = u ?? o("dataTable.moveDown", "Move down"), f = [
93
+ /* @__PURE__ */ i(
94
+ S,
95
+ {
96
+ size: "sm",
97
+ intent: s,
98
+ icon: /* @__PURE__ */ i($, { "aria-hidden": !0, className: "ds:size-4" }),
99
+ tooltip: N,
100
+ "aria-label": N,
101
+ disabled: g,
102
+ onClick: (p) => {
103
+ p.stopPropagation(), r(e, "up");
104
+ }
105
+ },
106
+ "up"
107
+ ),
108
+ /* @__PURE__ */ i(
109
+ S,
110
+ {
111
+ size: "sm",
112
+ intent: s,
113
+ icon: /* @__PURE__ */ i(H, { "aria-hidden": !0, className: "ds:size-4" }),
114
+ tooltip: y,
115
+ "aria-label": y,
116
+ disabled: C,
117
+ onClick: (p) => {
118
+ p.stopPropagation(), r(e, "down");
119
+ }
120
+ },
121
+ "down"
122
+ )
123
+ ];
124
+ return d ? /* @__PURE__ */ i(
125
+ V,
126
+ {
127
+ "aria-label": o("dataTable.reorder", "Reorder row"),
128
+ size: "sm",
129
+ children: f
130
+ }
131
+ ) : /* @__PURE__ */ i("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]", children: f });
132
+ }
133
+ function ve(t) {
134
+ const {
135
+ value: e,
136
+ data: n,
137
+ onToggle: c,
138
+ onError: r,
139
+ trueIcon: m,
140
+ falseIcon: u,
141
+ trueClass: s = "ds:text-[color:var(--success)]",
142
+ falseClass: d = "ds:text-[color:var(--muted-foreground)]",
143
+ label: a
144
+ } = t, { t: o } = x(), [l, b] = E(!1);
145
+ if (!n) return null;
146
+ const g = !!e, C = g ? m ?? /* @__PURE__ */ i(G, { "aria-hidden": !0, className: "ds:size-4" }) : u ?? /* @__PURE__ */ i(O, { "aria-hidden": !0, className: "ds:size-4" }), N = g ? s : d, y = a ?? o(g ? "inputs.switch.on" : "inputs.switch.off");
147
+ async function f(p) {
148
+ if (p.stopPropagation(), l || !n) return;
149
+ const v = c(n, !g);
150
+ if (v && typeof v.then == "function") {
151
+ b(!0);
152
+ try {
153
+ await v;
154
+ } catch (w) {
155
+ r == null || r(n, w);
156
+ } finally {
157
+ b(!1);
158
+ }
159
+ }
160
+ }
161
+ return /* @__PURE__ */ i(
162
+ "button",
163
+ {
164
+ type: "button",
165
+ role: "switch",
166
+ "aria-checked": g,
167
+ "aria-busy": l,
168
+ "aria-label": y,
169
+ disabled: l,
170
+ onClick: f,
171
+ className: [
172
+ "ds:inline-flex ds:items-center ds:justify-center",
173
+ "ds:min-h-[var(--min-target-size)] ds:min-w-[var(--min-target-size)]",
174
+ "ds:appearance-none ds:bg-transparent ds:p-[var(--spacing-xs)]",
175
+ "ds:rounded-[var(--radius-sm)]",
176
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
177
+ "ds:focus-visible:outline-solid",
178
+ "ds:focus-visible:outline-[color:var(--ring)]",
179
+ "ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
180
+ "ds:disabled:opacity-50",
181
+ N
182
+ ].join(" "),
183
+ children: C
184
+ }
185
+ );
186
+ }
187
+ const W = {
188
+ sm: "ds:size-[var(--icon-size-sm)]",
189
+ md: "ds:size-[var(--icon-size-md)]",
190
+ lg: "ds:size-[var(--icon-size-lg)]"
191
+ };
192
+ function k(t, e) {
193
+ if (!t || typeof t != "object") return;
194
+ const n = t[e];
195
+ return typeof n == "string" ? n : void 0;
196
+ }
197
+ const Z = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, J = /^rgba?\(\s*[\d.\s,%/]+\)$/i, Q = /^hsla?\(\s*[\d.\s,%/]+\)$/i, Y = /^var\(--[a-z0-9-]+(?:,\s*[^)]+)?\)$/i;
198
+ function ee(t) {
199
+ if (!t) return;
200
+ const e = t.trim();
201
+ if (Z.test(e) || J.test(e) || Q.test(e) || Y.test(e))
202
+ return e;
203
+ }
204
+ function Ne(t) {
205
+ const { data: e, colorField: n, size: c = "md", labelField: r } = t, m = T(null), u = e ? k(e, n) : void 0, s = ee(u), d = e && r ? k(e, r) : void 0;
206
+ return X(() => {
207
+ const a = m.current;
208
+ a && (s ? a.style.setProperty("--data-table-dot-color", s) : a.style.removeProperty("--data-table-dot-color"));
209
+ }, [s]), s ? /* @__PURE__ */ L("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
210
+ /* @__PURE__ */ i(
211
+ "span",
212
+ {
213
+ ref: m,
214
+ "aria-hidden": "true",
215
+ className: [
216
+ "ds:inline-block ds:shrink-0 ds:rounded-[var(--radius-full)]",
217
+ "ds:bg-[var(--data-table-dot-color)]",
218
+ "ds:border ds:border-[color:var(--border)]",
219
+ W[c]
220
+ ].join(" ")
221
+ }
222
+ ),
223
+ d ? /* @__PURE__ */ i("span", { children: d }) : null
224
+ ] }) : null;
225
+ }
226
+ function ne(t, e) {
227
+ if (!t || typeof t != "object") return null;
228
+ const n = t[e], c = typeof n == "number" ? n : Number(n);
229
+ return Number.isFinite(c) ? c : null;
230
+ }
231
+ function ye(t) {
232
+ const { data: e, lines: n, currency: c = "EUR", highlightNegative: r } = t, { i18n: m } = x();
233
+ if (!e) return null;
234
+ const u = m.language || "en", s = (a) => {
235
+ const o = ne(e, a.valueField);
236
+ if (o === null) return null;
237
+ let l;
238
+ switch (a.format ?? "number") {
239
+ case "currency":
240
+ l = new Intl.NumberFormat(u, {
241
+ style: "currency",
242
+ currency: c
243
+ }).format(o);
244
+ break;
245
+ case "percent":
246
+ l = new Intl.NumberFormat(u, {
247
+ style: "percent",
248
+ maximumFractionDigits: 1
249
+ }).format(o / 100);
250
+ break;
251
+ default:
252
+ l = new Intl.NumberFormat(u).format(o);
253
+ }
254
+ return {
255
+ label: a.label,
256
+ formatted: l,
257
+ negative: !!r && o < 0
258
+ };
259
+ }, d = n.map(s).filter(
260
+ (a) => a !== null
261
+ );
262
+ return d.length === 0 ? null : /* @__PURE__ */ i(
263
+ "div",
264
+ {
265
+ className: [
266
+ "ds:flex",
267
+ "ds:flex-wrap",
268
+ "ds:items-center",
269
+ "ds:gap-x-[var(--spacing-sm)]",
270
+ "ds:gap-y-0",
271
+ "type-meta",
272
+ "ds:leading-tight"
273
+ ].join(" "),
274
+ children: d.map((a, o) => /* @__PURE__ */ L(
275
+ "span",
276
+ {
277
+ className: "ds:inline-flex ds:items-baseline ds:gap-x-[var(--spacing-xs)]",
278
+ children: [
279
+ o > 0 ? /* @__PURE__ */ i(
280
+ "span",
281
+ {
282
+ "aria-hidden": "true",
283
+ className: "ds:me-[var(--spacing-xs)] ds:text-[color:var(--muted-foreground)]",
284
+ children: "·"
285
+ }
286
+ ) : null,
287
+ /* @__PURE__ */ i("span", { className: "ds:text-[color:var(--muted-foreground)]", children: a.label }),
288
+ /* @__PURE__ */ i(
289
+ "span",
290
+ {
291
+ className: [
292
+ "ds:tabular-nums",
293
+ "ds:font-medium",
294
+ a.negative ? "ds:text-[color:var(--destructive)]" : ""
295
+ ].filter(Boolean).join(" "),
296
+ children: a.formatted
297
+ }
298
+ )
299
+ ]
300
+ },
301
+ `${a.label}-${o}`
302
+ ))
303
+ }
304
+ );
305
+ }
306
+ function Ce(t) {
307
+ var a, o;
308
+ const { initialValue: e, onValueChange: n, stopEditing: c, column: r } = t, [m, u] = E(e ?? ""), s = T(null);
309
+ _(() => {
310
+ const l = s.current;
311
+ l && (l.focus(), l.select());
312
+ }, []);
313
+ const d = ((o = (a = r == null ? void 0 : r.getColDef) == null ? void 0 : a.call(r)) == null ? void 0 : o.headerName) ?? void 0;
314
+ return /* @__PURE__ */ i(
315
+ "input",
316
+ {
317
+ ref: s,
318
+ type: "text",
319
+ value: m,
320
+ "aria-label": d,
321
+ onChange: (l) => {
322
+ const b = l.target.value;
323
+ u(b), n(b);
324
+ },
325
+ onKeyDown: (l) => {
326
+ l.key === "Enter" && (l.preventDefault(), c());
327
+ },
328
+ className: [
329
+ "ds:block ds:w-full ds:appearance-none",
330
+ // Input surface chrome: rounded border + bg + focus halo.
331
+ D,
332
+ // Use the `md` height (`--min-target-size`) so the input
333
+ // auto-lifts to 48px under `.theme-accessible` to satisfy
334
+ // WCAG 2.5.5 target size.
335
+ U.md,
336
+ j.sm,
337
+ A.sm
338
+ ].join(" ")
339
+ }
340
+ );
341
+ }
342
+ function xe(t) {
343
+ var N, y;
344
+ const {
345
+ initialValue: e,
346
+ onValueChange: n,
347
+ stopEditing: c,
348
+ column: r,
349
+ decimals: m = 2,
350
+ min: u,
351
+ max: s
352
+ } = t, { i18n: d } = x(), a = T(null), o = ((y = (N = r == null ? void 0 : r.getColDef) == null ? void 0 : N.call(r)) == null ? void 0 : y.headerName) ?? void 0, [l, b] = E(() => e == null || Number.isNaN(e) ? "" : String(e));
353
+ _(() => {
354
+ const f = a.current;
355
+ f && (f.focus(), f.select());
356
+ }, []);
357
+ function g(f) {
358
+ var z, F;
359
+ if (f.trim().length === 0) return null;
360
+ const p = d.language || "en", h = new Intl.NumberFormat(p).formatToParts(12345.6), v = ((z = h.find((R) => R.type === "group")) == null ? void 0 : z.value) ?? "", w = ((F = h.find((R) => R.type === "decimal")) == null ? void 0 : F.value) ?? ".", B = f.replace(new RegExp(`\\${v}`, "g"), "").replace(w, ".").replace(/[^\d.-]/g, ""), I = Number(B);
361
+ return Number.isFinite(I) ? I : null;
362
+ }
363
+ function C(f) {
364
+ const p = g(f);
365
+ if (p == null) {
366
+ n(null);
367
+ return;
368
+ }
369
+ let h = p;
370
+ typeof u == "number" && (h = Math.max(u, h)), typeof s == "number" && (h = Math.min(s, h));
371
+ const v = 10 ** m;
372
+ n(Math.round(h * v) / v);
373
+ }
374
+ return /* @__PURE__ */ i(
375
+ "input",
376
+ {
377
+ ref: a,
378
+ type: "text",
379
+ inputMode: "decimal",
380
+ value: l,
381
+ "aria-label": o,
382
+ onChange: (f) => {
383
+ const p = f.target.value;
384
+ b(p), C(p);
385
+ },
386
+ onKeyDown: (f) => {
387
+ f.key === "Enter" && (f.preventDefault(), c());
388
+ },
389
+ className: [
390
+ "ds:block ds:w-full ds:appearance-none ds:text-end ds:tabular-nums",
391
+ D,
392
+ // Use `md` height — see editable-text-cell-renderer for rationale.
393
+ U.md,
394
+ j.sm,
395
+ A.sm
396
+ ].join(" ")
397
+ }
398
+ );
399
+ }
400
+ export {
401
+ ye as B,
402
+ Ne as C,
403
+ xe as E,
404
+ he as R,
405
+ ve as T,
406
+ be as a,
407
+ Ce as b,
408
+ pe as c,
409
+ ge as r,
410
+ me as u
411
+ };
412
+ //# sourceMappingURL=editable-currency-cell-renderer-zLf_bXvL.js.map
@@ -16,7 +16,7 @@ import { F as Nt, a as Tt } from "./file-Cwe9VC1A.js";
16
16
  import { F as Ft } from "./file-text-5yv6r2ls.js";
17
17
  import { F as At } from "./file-spreadsheet-DmwyfV4O.js";
18
18
  import { C as Dt } from "./chevron-right-I9AeSxH2.js";
19
- import { A as Rt, d as It, D as Te } from "./actions-cell-renderer-B2pw6iH8.js";
19
+ import { A as Rt, d as It, D as Te } from "./actions-cell-renderer-BbzCqcld.js";
20
20
  import { B as $e } from "./badge-sTusUqZD.js";
21
21
  import { D as Ge } from "./download-CfYKJO_j.js";
22
22
  import { P as zt } from "./pen-line-D0De5zdl.js";
@@ -1756,4 +1756,4 @@ export {
1756
1756
  yn as F,
1757
1757
  Gt as f
1758
1758
  };
1759
- //# sourceMappingURL=file-manager-Crg5dKez.js.map
1759
+ //# sourceMappingURL=file-manager-CRxq0UIl.js.map