@alfadocs/ui-kit 1.9.2 → 1.9.4

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