@alea-design/ui 0.5.1 → 0.6.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.
Files changed (100) hide show
  1. package/dist/components/button/Button.d.ts +3 -1
  2. package/dist/components/button/Button.js +64 -63
  3. package/dist/components/card/Card.d.ts +6 -2
  4. package/dist/components/card/Card.js +20 -20
  5. package/dist/components/combobox/Autocomplete.d.ts +4 -0
  6. package/dist/components/combobox/Autocomplete.js +89 -87
  7. package/dist/components/command/CommandPalette.d.ts +10 -0
  8. package/dist/components/command/CommandPalette.js +76 -52
  9. package/dist/components/data/Data.d.ts +6 -4
  10. package/dist/components/data/Data.js +66 -56
  11. package/dist/components/date/Date.d.ts +16 -2
  12. package/dist/components/date/Date.js +80 -69
  13. package/dist/components/display/Display.d.ts +3 -1
  14. package/dist/components/display/Display.js +27 -27
  15. package/dist/components/display/Display2.d.ts +2 -2
  16. package/dist/components/display/Display2.js +28 -27
  17. package/dist/components/feedback/Feedback.d.ts +3 -1
  18. package/dist/components/feedback/Feedback.js +102 -102
  19. package/dist/components/feedback/PageSkeleton.d.ts +19 -0
  20. package/dist/components/feedback/PageSkeleton.js +58 -0
  21. package/dist/components/field/Field.d.ts +3 -1
  22. package/dist/components/field/Field.js +82 -82
  23. package/dist/components/filter/FilterBar.d.ts +5 -2
  24. package/dist/components/filter/FilterBar.js +97 -66
  25. package/dist/components/form/Form.d.ts +8 -2
  26. package/dist/components/form/Form.js +53 -40
  27. package/dist/components/icon/icon-names.d.ts +2 -2
  28. package/dist/components/icon/icon-names.js +4 -2
  29. package/dist/components/list/List.d.ts +6 -2
  30. package/dist/components/list/List.js +65 -62
  31. package/dist/components/list/Lists2.d.ts +4 -0
  32. package/dist/components/list/Lists2.js +35 -35
  33. package/dist/components/media/Media.js +27 -27
  34. package/dist/components/more/More.d.ts +2 -2
  35. package/dist/components/more/More.js +46 -45
  36. package/dist/components/navigation/Navigation.d.ts +7 -5
  37. package/dist/components/navigation/Navigation.js +91 -74
  38. package/dist/components/navigation/Navigation2.d.ts +9 -3
  39. package/dist/components/navigation/Navigation2.js +209 -195
  40. package/dist/components/notification/NotificationCenter.js +70 -70
  41. package/dist/components/overlay/Drawer.d.ts +6 -1
  42. package/dist/components/overlay/Drawer.js +27 -25
  43. package/dist/components/overlay/Modal.d.ts +5 -0
  44. package/dist/components/overlay/Modal.js +16 -15
  45. package/dist/components/overlay/Overlay.d.ts +10 -1
  46. package/dist/components/overlay/Overlay.js +54 -52
  47. package/dist/components/overlay/Sheet.d.ts +2 -0
  48. package/dist/components/overlay/Sheet.js +30 -30
  49. package/dist/components/page/PageParts.js +20 -20
  50. package/dist/components/select/Select.js +75 -70
  51. package/dist/components/settings/Settings.d.ts +29 -0
  52. package/dist/components/settings/Settings.js +31 -0
  53. package/dist/components/shell/AccountMenu.d.ts +20 -0
  54. package/dist/components/shell/AccountMenu.js +32 -0
  55. package/dist/components/shell/AppShell.d.ts +9 -2
  56. package/dist/components/shell/AppShell.js +37 -37
  57. package/dist/components/shell/AppSidebar.d.ts +9 -3
  58. package/dist/components/shell/AppSidebar.js +45 -39
  59. package/dist/components/table/Table.d.ts +18 -4
  60. package/dist/components/table/Table.js +70 -46
  61. package/dist/components/tabs/Tabs.js +105 -94
  62. package/dist/components/theme/Theme.d.ts +7 -4
  63. package/dist/components/theme/Theme.js +127 -130
  64. package/dist/components/upload/Upload.js +62 -54
  65. package/dist/css/base.css +1 -1
  66. package/dist/css/button.css +1 -1
  67. package/dist/css/card.css +1 -1
  68. package/dist/css/command.css +1 -1
  69. package/dist/css/date.css +1 -1
  70. package/dist/css/display.css +1 -1
  71. package/dist/css/feedback.css +1 -1
  72. package/dist/css/field.css +1 -1
  73. package/dist/css/form.css +1 -1
  74. package/dist/css/groups.json +36 -20
  75. package/dist/css/list.css +1 -1
  76. package/dist/css/menu.css +1 -1
  77. package/dist/css/navigation.css +1 -1
  78. package/dist/css/notification.css +1 -1
  79. package/dist/css/overlay.css +1 -1
  80. package/dist/css/page.css +1 -1
  81. package/dist/css/select.css +1 -1
  82. package/dist/css/settings.css +1 -0
  83. package/dist/css/shell.css +1 -1
  84. package/dist/css/table.css +1 -1
  85. package/dist/css/tabs.css +1 -1
  86. package/dist/css/upload.css +1 -1
  87. package/dist/i18n/strings.d.ts +7 -0
  88. package/dist/i18n/strings.js +14 -0
  89. package/dist/index.d.ts +4 -0
  90. package/dist/index.js +318 -306
  91. package/dist/styles.css +1 -1
  92. package/dist/utils/animateRows.d.ts +11 -0
  93. package/dist/utils/animateRows.js +23 -0
  94. package/dist/utils/decimal.d.ts +12 -0
  95. package/dist/utils/decimal.js +48 -0
  96. package/dist/utils/initialFocus.d.ts +6 -0
  97. package/dist/utils/initialFocus.js +24 -0
  98. package/dist/utils/refs.d.ts +2 -0
  99. package/dist/utils/refs.js +14 -6
  100. package/package.json +3 -3
@@ -1,13 +1,13 @@
1
1
  "use client";
2
- import { jsxs as R, Fragment as ee, jsx as v } from "react/jsx-runtime";
3
- import { useState as te, useSyncExternalStore as V, useEffect as w, useMemo as M, useId as ne, useCallback as ae, useContext as re, createContext as oe } from "react";
4
- import { warnDeprecated as ce } from "../../utils/vocabulary.js";
5
- import { RouterProvider as ie, I18nProvider as se } from "react-aria-components";
6
- import { motionVariables as le, motionAttributes as me, motionComponentCss as de } from "@alea-design/motion";
7
- import { cx as ue } from "../../utils/cx.js";
8
- import { StringsContext as fe } from "../../i18n/strings.js";
9
- import { refractionLevel as pe, startGlassLens as he } from "./lens.js";
10
- const ye = {
2
+ import { jsxs as D, Fragment as nt, jsx as v } from "react/jsx-runtime";
3
+ import { useState as at, useSyncExternalStore as F, useEffect as w, useMemo as M, useId as rt, useCallback as ot, useContext as ct, createContext as it } from "react";
4
+ import { warnDeprecated as st } from "../../utils/vocabulary.js";
5
+ import { RouterProvider as lt, I18nProvider as mt } from "react-aria-components";
6
+ import { motionVariables as dt, motionAttributes as ut, motionComponentCss as ft } from "@alea-design/motion";
7
+ import { cx as ht } from "../../utils/cx.js";
8
+ import { StringsContext as pt } from "../../i18n/strings.js";
9
+ import { refractionLevel as yt, startGlassLens as xt } from "./lens.js";
10
+ const gt = {
11
11
  "--alea-spacing-base": "0.125rem",
12
12
  "--alea-space-0": "0rem",
13
13
  "--alea-space-0-25": "0.0625rem",
@@ -29,201 +29,198 @@ const ye = {
29
29
  "--alea-space-20": "2.5rem",
30
30
  "--alea-space-22": "2.75rem",
31
31
  "--alea-space-24": "3rem"
32
- }, H = [["3xs", 1], ["2xs", 2], ["xs", 4], ["sm", 6], ["field", 8], ["md", 10], ["lg", 12], ["xl", 16], ["2xl", 20], ["3xl", 24], ["4xl", 32]], xe = H.map(([e, n]) => [e, e === "3xs" || e === "2xs" ? n : n * 2]);
33
- function D(e) {
34
- const n = e.trim().toLowerCase(), t = /^#([0-9a-f]{3,8})$/.exec(n);
35
- if (t) {
36
- let s = t[1];
37
- return (s.length === 3 || s.length === 4) && (s = s.split("").map((l) => l + l).join("")), s.length !== 6 && s.length !== 8 ? null : [0, 2, 4].map((l) => parseInt(s.slice(l, l + 2), 16));
32
+ }, X = [["3xs", 1], ["2xs", 2], ["xs", 4], ["sm", 6], ["field", 8], ["md", 10], ["lg", 12], ["xl", 16], ["2xl", 20], ["3xl", 24], ["4xl", 32]], wt = X.map(([t, n]) => [t, t === "3xs" || t === "2xs" ? n : n * 2]);
33
+ function J(t) {
34
+ const n = t.trim().toLowerCase(), e = /^#([0-9a-f]{3,8})$/.exec(n);
35
+ if (e) {
36
+ let s = e[1];
37
+ return (s.length === 3 || s.length === 4) && (s = s.split("").map((m) => m + m).join("")), s.length !== 6 && s.length !== 8 ? null : [0, 2, 4].map((m) => parseInt(s.slice(m, m + 2), 16));
38
38
  }
39
39
  const a = /^(rgba?|hsla?)\(([^)]+)\)$/.exec(n);
40
40
  if (!a) return null;
41
41
  const r = a[2].split(/[\s,/]+/).filter(Boolean).slice(0, 3).map((s) => s.endsWith("%") ? parseFloat(s) / 100 : parseFloat(s));
42
42
  if (r.length < 3 || r.some(Number.isNaN)) return null;
43
43
  if (a[1].startsWith("rgb")) {
44
- const s = a[2].split(/[\s,/]+/).filter(Boolean).slice(0, 3).map((l) => l.endsWith("%"));
45
- return r.map((l, u) => Math.max(0, Math.min(255, Math.round(s[u] ? l * 255 : l))));
44
+ const s = a[2].split(/[\s,/]+/).filter(Boolean).slice(0, 3).map((m) => m.endsWith("%"));
45
+ return r.map((m, f) => Math.max(0, Math.min(255, Math.round(s[f] ? m * 255 : m))));
46
46
  }
47
- const [c, i, y] = [(r[0] % 360 + 360) % 360, r[1] > 1 ? r[1] / 100 : r[1], r[2] > 1 ? r[2] / 100 : r[2]], f = i * Math.min(y, 1 - y), x = (s) => {
48
- const l = (s + c / 30) % 12;
49
- return Math.round(255 * (y - f * Math.max(-1, Math.min(l - 3, 9 - l, 1))));
47
+ const [c, i, p] = [(r[0] % 360 + 360) % 360, r[1] > 1 ? r[1] / 100 : r[1], r[2] > 1 ? r[2] / 100 : r[2]], l = i * Math.min(p, 1 - p), y = (s) => {
48
+ const m = (s + c / 30) % 12;
49
+ return Math.round(255 * (p - l * Math.max(-1, Math.min(m - 3, 9 - m, 1))));
50
50
  };
51
- return [x(0), x(8), x(4)];
51
+ return [y(0), y(8), y(4)];
52
52
  }
53
- const F = ([e, n, t]) => {
54
- const a = [e, n, t].map((r) => {
53
+ const U = ([t, n, e]) => {
54
+ const a = [t, n, e].map((r) => {
55
55
  const c = r / 255;
56
56
  return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
57
57
  });
58
58
  return 0.2126 * a[0] + 0.7152 * a[1] + 0.0722 * a[2];
59
- }, ge = (e, n) => {
60
- const t = F(e), a = F(n);
61
- return (Math.max(t, a) + 0.05) / (Math.min(t, a) + 0.05);
62
- }, J = (e) => `#${e.map((n) => n.toString(16).padStart(2, "0")).join("")}`, we = (e, n) => e.map((t) => Math.round(t * n));
63
- function ve(e, n) {
64
- const t = {}, a = D(e);
65
- let r = e, c = `color-mix(in srgb, ${e} 88%, black)`, i = "var(--alea-accent-on)";
59
+ }, vt = (t, n) => {
60
+ const e = U(t), a = U(n);
61
+ return (Math.max(e, a) + 0.05) / (Math.min(e, a) + 0.05);
62
+ }, Z = (t) => `#${t.map((n) => n.toString(16).padStart(2, "0")).join("")}`, kt = (t, n) => t.map((e) => Math.round(e * n));
63
+ function $t(t, n) {
64
+ const e = {}, a = J(t);
65
+ let r = t, c = `color-mix(in srgb, ${t} 88%, black)`, i = "var(--alea-accent-on)";
66
66
  if (a) {
67
- const y = [a, we(a, 0.88)], f = [n, "#0a0a0a", "#000000", "#ffffff"].filter((m) => !!m).map((m) => ({ css: m, rgb: D(m) })).filter((m) => !!m.rgb), x = (m, h) => Math.min(...h.map((p) => ge(m, p))), s = (m) => {
68
- const h = f.map((p) => ({ css: p.css, ratio: x(p.rgb, m) }));
69
- return h.find((p) => p.ratio >= 7) ?? h.find((p) => p.ratio >= 4.5) ?? h.slice().sort((p, k) => k.ratio - p.ratio)[0];
67
+ const p = [a, kt(a, 0.88)], l = [n, "#0a0a0a", "#000000", "#ffffff"].filter((d) => !!d).map((d) => ({ css: d, rgb: J(d) })).filter((d) => !!d.rgb), y = (d, x) => Math.min(...x.map((h) => vt(d, h))), s = (d) => {
68
+ const x = l.map((h) => ({ css: h.css, ratio: y(h.rgb, d) }));
69
+ return x.find((h) => h.ratio >= 7) ?? x.find((h) => h.ratio >= 4.5) ?? x.slice().sort((h, k) => k.ratio - h.ratio)[0];
70
70
  };
71
- let l = s(y), u = y;
72
- l.ratio < 4.5 && (u = [a, a], l = s(u)), r = J(u[0]), c = J(u[1]), i = l.css;
71
+ let m = s(p), f = p;
72
+ m.ratio < 4.5 && (f = [a, a], m = s(f)), r = Z(f[0]), c = Z(f[1]), i = m.css;
73
73
  }
74
- return t["--alea-button-top"] = r, t["--alea-button-bottom"] = c, t["--alea-button-text"] = i, t["--alea-button-ring"] = `color-mix(in srgb, ${e} 25%, transparent)`, t["--alea-gradient-button"] = `linear-gradient(180deg, ${r} 0%, ${c} 100%)`, t["--alea-accent-second"] = `color-mix(in oklch, ${e} 55%, white)`, t["--alea-accent-third"] = `color-mix(in oklch, ${e} 45%, var(--alea-text))`, t;
74
+ return e["--alea-button-top"] = r, e["--alea-button-bottom"] = c, e["--alea-button-text"] = i, e["--alea-button-ring"] = `color-mix(in srgb, ${t} 25%, transparent)`, e["--alea-gradient-button"] = `linear-gradient(180deg, ${r} 0%, ${c} 100%)`, e["--alea-accent-second"] = `color-mix(in oklch, ${t} 55%, white)`, e["--alea-accent-third"] = `color-mix(in oklch, ${t} 45%, var(--alea-text))`, e;
75
75
  }
76
- function ke(e = {}, n = "default") {
77
- var a, r, c;
78
- const t = {};
79
- if (e.accent) {
80
- t["--alea-accent"] = e.accent, t["--alea-accent-strong"] = `color-mix(in oklch, ${e.accent} 62%, var(--alea-text))`, t["--alea-accent-subtle"] = `color-mix(in oklch, ${e.accent} 16%, transparent)`, t["--alea-focus"] = e.accent, t["--alea-focus-halo"] = `color-mix(in oklch, ${e.accent} 30%, transparent)`, t["--alea-accent-solid"] = e.accent;
81
- const i = `color-mix(in oklch, ${e.accent} 55%, white)`;
82
- t["--alea-gradient-accent"] = `radial-gradient(100% 100% at 25% 100%, ${e.accent} 0%, ${i} 100%)`, t["--alea-gradient-accent-linear"] = `linear-gradient(120deg, ${e.accent} 0%, ${i} 100%)`, t["--alea-gradient-text"] = t["--alea-gradient-accent"], t["--alea-gradient-text-linear"] = t["--alea-gradient-accent-linear"], t["--alea-shadow-glow"] = `0 10px 30px -10px color-mix(in srgb, ${e.accent} 55%, transparent)`, Object.assign(t, ve(e.accent, e.accentOn));
76
+ function At(t = {}, n = "default") {
77
+ var r, c, i, p;
78
+ const e = {};
79
+ if (t.accent) {
80
+ e["--alea-accent"] = t.accent, e["--alea-accent-strong"] = `color-mix(in oklch, ${t.accent} 62%, var(--alea-text))`, e["--alea-accent-subtle"] = `color-mix(in oklch, ${t.accent} 16%, transparent)`, e["--alea-focus"] = "var(--alea-accent-strong)", e["--alea-focus-halo"] = `color-mix(in oklch, ${t.accent} 30%, transparent)`, e["--alea-accent-solid"] = t.accent;
81
+ const l = `color-mix(in oklch, ${t.accent} 55%, white)`;
82
+ e["--alea-gradient-accent"] = `radial-gradient(100% 100% at 25% 100%, ${t.accent} 0%, ${l} 100%)`, e["--alea-gradient-accent-linear"] = `linear-gradient(120deg, ${t.accent} 0%, ${l} 100%)`, e["--alea-gradient-text"] = e["--alea-gradient-accent"], e["--alea-gradient-text-linear"] = e["--alea-gradient-accent-linear"], e["--alea-shadow-glow"] = `0 10px 30px -10px color-mix(in srgb, ${t.accent} 55%, transparent)`, Object.assign(e, $t(t.accent, t.accentOn));
83
83
  }
84
- if (e.accentOn && (t["--alea-accent-on"] = e.accentOn), e.radius != null) {
85
- for (const [i, y] of n === "glass" ? xe : H) t[`--alea-radius-${i}`] = `${Math.round(y * e.radius)}px`;
86
- t["--alea-radius-full"] = e.radius >= 1 ? "9999px" : `${Math.round(18 * e.radius)}px`;
84
+ if (t.accentOn && (e["--alea-accent-on"] = t.accentOn), t.focus && (e["--alea-focus"] = t.focus), t.radius != null) {
85
+ for (const [l, y] of n === "glass" ? wt : X) e[`--alea-radius-${l}`] = `${Math.round(y * t.radius)}px`;
86
+ e["--alea-radius-full"] = t.radius >= 1 ? "9999px" : `${Math.round(18 * t.radius)}px`;
87
87
  }
88
- return e.density === "compact" && Object.assign(t, ye, {
89
- "--alea-size-control-sm": "24px",
90
- "--alea-size-control-md": "32px",
91
- "--alea-size-control-lg": "40px",
92
- "--alea-size-field": "36px"
93
- }), (a = e.fonts) != null && a.body && (t["--alea-font-family-body"] = e.fonts.body), (r = e.fonts) != null && r.display && (t["--alea-font-family-display"] = e.fonts.display), (c = e.fonts) != null && c.mono && (t["--alea-font-family-mono"] = e.fonts.mono), t;
88
+ t.density === "compact" && Object.assign(e, gt), (r = t.fonts) != null && r.body && (e["--alea-font-family-body"] = t.fonts.body);
89
+ const a = ((c = t.fonts) == null ? void 0 : c.heading) ?? ((i = t.fonts) == null ? void 0 : i.display);
90
+ return a && (e["--alea-font-family-display"] = a), (p = t.fonts) != null && p.mono && (e["--alea-font-family-mono"] = t.fonts.mono), e;
94
91
  }
95
- const Q = oe(null), $e = /* @__PURE__ */ new Set(["ar", "arc", "ckb", "dv", "fa", "he", "ks", "ku", "ps", "sd", "ug", "ur", "yi"]);
96
- function P(e) {
97
- var t, a;
98
- if (!e) return "ltr";
92
+ const Y = it(null), Et = /* @__PURE__ */ new Set(["ar", "arc", "ckb", "dv", "fa", "he", "ks", "ku", "ps", "sd", "ug", "ur", "yi"]);
93
+ function T(t) {
94
+ var e, a;
95
+ if (!t) return "ltr";
99
96
  try {
100
- const r = new Intl.Locale(e), c = ((t = r.getTextInfo) == null ? void 0 : t.call(r).direction) ?? ((a = r.textInfo) == null ? void 0 : a.direction);
97
+ const r = new Intl.Locale(t), c = ((e = r.getTextInfo) == null ? void 0 : e.call(r).direction) ?? ((a = r.textInfo) == null ? void 0 : a.direction);
101
98
  if (c === "rtl" || c === "ltr") return c;
102
99
  } catch {
103
100
  }
104
- const n = e.toLowerCase().split(/[-_]/)[0];
105
- return $e.has(n) ? "rtl" : "ltr";
101
+ const n = t.toLowerCase().split(/[-_]/)[0];
102
+ return Et.has(n) ? "rtl" : "ltr";
106
103
  }
107
- function T() {
104
+ function C() {
108
105
  return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
109
106
  }
110
- function Ae(e) {
111
- var t;
107
+ function St(t) {
108
+ var e;
112
109
  if (typeof window > "u" || !window.matchMedia) return () => {
113
110
  };
114
111
  const n = window.matchMedia("(prefers-color-scheme: light)");
115
- return (t = n.addEventListener) == null || t.call(n, "change", e), () => {
112
+ return (e = n.addEventListener) == null || e.call(n, "change", t), () => {
116
113
  var a;
117
- return (a = n.removeEventListener) == null ? void 0 : a.call(n, "change", e);
114
+ return (a = n.removeEventListener) == null ? void 0 : a.call(n, "change", t);
118
115
  };
119
116
  }
120
- const Ee = () => () => {
117
+ const bt = () => () => {
121
118
  };
122
- function Se(e = "alea-theme", n = "dark") {
123
- const t = (a) => JSON.stringify(a).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
124
- return `(function(){try{var k=${t(e)},t=k&&localStorage.getItem(k);if(t!=='dark'&&t!=='light'&&t!=='system')t=${t(n)};if(t==='system')t=matchMedia('(prefers-color-scheme: light)').matches?'light':'dark';document.documentElement.setAttribute('data-theme',t)}catch(e){}})()`;
119
+ function Mt(t = "alea-theme", n = "dark") {
120
+ const e = (a) => JSON.stringify(a).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
121
+ return `(function(){try{var k=${e(t)},t=k&&localStorage.getItem(k);if(t!=='dark'&&t!=='light'&&t!=='system')t=${e(n)};if(t==='system')t=matchMedia('(prefers-color-scheme: light)').matches?'light':'dark';document.documentElement.setAttribute('data-theme',t)}catch(e){}})()`;
125
122
  }
126
- function _e({ storageKey: e = "alea-theme", defaultTheme: n = "dark" }) {
127
- return /* @__PURE__ */ v("script", { dangerouslySetInnerHTML: { __html: Se(e, n) } });
123
+ function Gt({ storageKey: t = "alea-theme", defaultTheme: n = "dark" }) {
124
+ return /* @__PURE__ */ v("script", { dangerouslySetInnerHTML: { __html: Mt(t, n) } });
128
125
  }
129
- function U(e) {
130
- if (!e || typeof window > "u") return null;
126
+ function H(t) {
127
+ if (!t || typeof window > "u") return null;
131
128
  try {
132
- const n = window.localStorage.getItem(e);
129
+ const n = window.localStorage.getItem(t);
133
130
  return n === "dark" || n === "light" || n === "system" ? n : null;
134
131
  } catch {
135
132
  return null;
136
133
  }
137
134
  }
138
- const be = /^([a-z][a-z0-9+.-]*:|\/\/|#)/i, Z = /* @__PURE__ */ new WeakMap();
139
- function Me(e) {
140
- let n = Z.get(e);
141
- return n || (n = (t) => {
142
- const a = e(t);
143
- return be.test(t) ? t : a;
144
- }, Z.set(e, n)), n;
135
+ const Lt = /^([a-z][a-z0-9+.-]*:|\/\/|#)/i, Q = /* @__PURE__ */ new WeakMap();
136
+ function Ot(t) {
137
+ let n = Q.get(t);
138
+ return n || (n = (e) => {
139
+ const a = t(e);
140
+ return Lt.test(e) ? e : a;
141
+ }, Q.set(t, n)), n;
145
142
  }
146
- function Le(e, n, t = !0) {
143
+ function It(t, n, e = !0) {
147
144
  w(() => {
148
- typeof document > "u" || (document.documentElement.setAttribute("data-alea-refraction", String(e)), t ? document.documentElement.removeAttribute("data-alea-lens-pause") : document.documentElement.setAttribute("data-alea-lens-pause", "off"), he(n).refresh());
149
- }, [e, n, t]);
145
+ typeof document > "u" || (document.documentElement.setAttribute("data-alea-refraction", String(t)), e ? document.documentElement.removeAttribute("data-alea-lens-pause") : document.documentElement.setAttribute("data-alea-lens-pause", "off"), xt(n).refresh());
146
+ }, [t, n, e]);
150
147
  }
151
- function We({ children: e, dir: n, defaultTheme: t = "dark", theme: a, onThemeChange: r, storageKey: c = "alea-theme", scope: i = "document", className: y, brand: f, density: x, navigate: s, useHref: l, locale: u, motion: m, preset: h = "default", surface: p = "solid", contrast: k = "system", background: C = "decorated", strings: N, glass: g }) {
152
- Le(pe(g == null ? void 0 : g.refraction), g == null ? void 0 : g.lensSelector, (g == null ? void 0 : g.pauseOnScroll) !== !1);
153
- const [L, X] = te(null), Y = V(Ee, () => U(c), () => null), $ = a ?? L ?? Y ?? t, q = V(Ae, T, () => "dark"), A = $ === "system" ? q : $;
148
+ function Bt({ children: t, dir: n, defaultTheme: e = "dark", theme: a, onThemeChange: r, storageKey: c = "alea-theme", scope: i = "document", className: p, brand: l, density: y, navigate: s, useHref: m, locale: f, motion: d, preset: x = "default", surface: h = "solid", contrast: k = "system", background: N = "decorated", strings: _, glass: g }) {
149
+ It(yt(g == null ? void 0 : g.refraction), g == null ? void 0 : g.lensSelector, (g == null ? void 0 : g.pauseOnScroll) !== !1);
150
+ const [L, q] = at(null), K = F(bt, () => H(c), () => null), $ = a ?? L ?? K ?? e, tt = F(St, C, () => "dark"), A = $ === "system" ? tt : $;
154
151
  w(() => {
155
152
  if (i !== "document" || typeof document > "u") return;
156
- const o = a ?? L ?? U(c) ?? t;
157
- document.documentElement.setAttribute("data-theme", o === "system" ? T() : o), document.documentElement.classList.add("alea-root");
158
- }, [A, i, a, L, c, t]), w(() => {
153
+ const o = a ?? L ?? H(c) ?? e;
154
+ document.documentElement.setAttribute("data-theme", o === "system" ? C() : o), document.documentElement.classList.add("alea-root");
155
+ }, [A, i, a, L, c, e]), w(() => {
159
156
  if (i !== "document" || typeof window > "u") return;
160
- const o = document.documentElement, d = () => o.style.setProperty("--alea-scrollbar", `${Math.max(0, window.innerWidth - o.clientWidth)}px`);
161
- return d(), window.addEventListener("resize", d), () => {
162
- window.removeEventListener("resize", d), o.style.removeProperty("--alea-scrollbar");
157
+ const o = document.documentElement, u = () => o.style.setProperty("--alea-scrollbar", `${Math.max(0, window.innerWidth - o.clientWidth)}px`);
158
+ return u(), window.addEventListener("resize", u), () => {
159
+ window.removeEventListener("resize", u), o.style.removeProperty("--alea-scrollbar");
163
160
  };
164
161
  }, [i]);
165
- const E = n ?? (u ? P(u) : void 0);
162
+ const E = n ?? (f ? T(f) : void 0);
166
163
  w(() => {
167
164
  if (i !== "document" || typeof document > "u" || !E) return;
168
- const o = document.documentElement, d = o.getAttribute("dir");
165
+ const o = document.documentElement, u = o.getAttribute("dir");
169
166
  return o.setAttribute("dir", E), () => {
170
- d == null ? o.removeAttribute("dir") : o.setAttribute("dir", d);
167
+ u == null ? o.removeAttribute("dir") : o.setAttribute("dir", u);
171
168
  };
172
169
  }, [E, i]), w(() => {
173
- !n || !u || P(u) === n || console.warn(`[alea] dir="${n}" does not match locale "${u}" (${P(u)}): the styles mirror, but the arrow keys, sliders and calendars follow the locale. Pass a ${n === "rtl" ? "right to left" : "left to right"} locale as well.`);
174
- }, [n, u]);
175
- const O = JSON.stringify(m || {}), S = M(() => ({ ...ke(f, h), ...le(m) }), [f, O, h]);
170
+ !n || !f || T(f) === n || console.warn(`[alea] dir="${n}" does not match locale "${f}" (${T(f)}): the styles mirror, but the arrow keys, sliders and calendars follow the locale. Pass a ${n === "rtl" ? "right to left" : "left to right"} locale as well.`);
171
+ }, [n, f]);
172
+ const O = JSON.stringify(d || {}), S = M(() => ({ ...At(l, x), ...dt(d) }), [l, O, x]);
176
173
  w(() => {
177
- (x === "comfortable" || (f == null ? void 0 : f.density) === "comfortable") && ce("ThemeProvider", 'density="comfortable"', 'density="comfy"');
178
- }, [x, f == null ? void 0 : f.density]);
179
- const _ = (x ?? ((f == null ? void 0 : f.density) === "compact" ? "compact" : "comfy")) === "compact", b = M(() => ({ ...me(m), ..._ ? { "data-density": "compact" } : {}, ...h !== "default" ? { "data-preset": h } : {}, ...p !== "solid" ? { "data-surface": p } : {}, ...k !== "system" ? { "data-contrast": k } : {}, ...C === "plain" ? { "data-background": "plain" } : {} }), [O, h, p, k, C, _]), I = ne().replace(/[^a-zA-Z0-9_-]/g, ""), j = M(() => de(m == null ? void 0 : m.components, i === "document" ? ":root" : `[data-alea-scope="${I}"]`), [O, i, I]);
174
+ (y === "comfortable" || (l == null ? void 0 : l.density) === "comfortable") && st("ThemeProvider", 'density="comfortable"', 'density="comfy"');
175
+ }, [y, l == null ? void 0 : l.density]);
176
+ const W = y ?? ((l == null ? void 0 : l.density) === "compact" ? "compact" : "comfy"), z = W === "compact", G = W === "touch", b = M(() => ({ ...ut(d), ...z ? { "data-density": "compact" } : G ? { "data-density": "touch" } : {}, ...x !== "default" ? { "data-preset": x } : {}, ...h !== "solid" ? { "data-surface": h } : {}, ...k !== "system" ? { "data-contrast": k } : {}, ...N === "plain" ? { "data-background": "plain" } : {} }), [O, x, h, k, N, z, G]), I = rt().replace(/[^a-zA-Z0-9_-]/g, ""), j = M(() => ft(d == null ? void 0 : d.components, i === "document" ? ":root" : `[data-alea-scope="${I}"]`), [O, i, I]);
180
177
  w(() => {
181
178
  if (i !== "document" || typeof document > "u") return;
182
179
  const o = document.documentElement;
183
- return Object.entries(b).forEach(([d, z]) => o.setAttribute(d, z)), () => {
184
- Object.keys(b).forEach((d) => o.removeAttribute(d));
180
+ return Object.entries(b).forEach(([u, P]) => o.setAttribute(u, P)), () => {
181
+ Object.keys(b).forEach((u) => o.removeAttribute(u));
185
182
  };
186
183
  }, [b, i]), w(() => {
187
184
  if (i !== "document" || typeof document > "u") return;
188
185
  const o = document.documentElement;
189
- return Object.entries(S).forEach(([d, z]) => o.style.setProperty(d, z)), () => {
190
- Object.keys(S).forEach((d) => o.style.removeProperty(d));
186
+ return Object.entries(S).forEach(([u, P]) => o.style.setProperty(u, P)), () => {
187
+ Object.keys(S).forEach((u) => o.style.removeProperty(u));
191
188
  };
192
189
  }, [S, i]);
193
- const W = ae((o) => {
194
- if (a === void 0 && X(o), r == null || r(o), c)
190
+ const B = ot((o) => {
191
+ if (a === void 0 && q(o), r == null || r(o), c)
195
192
  try {
196
193
  window.localStorage.setItem(c, o);
197
194
  } catch {
198
195
  }
199
- }, [a, r, c]), K = M(() => ({ theme: $, resolvedTheme: A, setTheme: W }), [$, A, W]), G = j ? /* @__PURE__ */ v("style", { children: j }) : null, B = i === "element" ? /* @__PURE__ */ R("div", { className: ue("alea-root", y), dir: E, "data-theme": A, "data-alea-scope": j ? I : void 0, ...b, style: S, children: [
200
- G,
201
- e
202
- ] }) : /* @__PURE__ */ R(ee, { children: [
203
- G,
204
- e
196
+ }, [a, r, c]), et = M(() => ({ theme: $, resolvedTheme: A, setTheme: B }), [$, A, B]), R = j ? /* @__PURE__ */ v("style", { children: j }) : null, V = i === "element" ? /* @__PURE__ */ D("div", { className: ht("alea-root", p), dir: E, "data-theme": A, "data-alea-scope": j ? I : void 0, ...b, style: S, children: [
197
+ R,
198
+ t
199
+ ] }) : /* @__PURE__ */ D(nt, { children: [
200
+ R,
201
+ t
205
202
  ] });
206
- return /* @__PURE__ */ v(Q.Provider, { value: K, children: (() => {
207
- const o = N ? /* @__PURE__ */ v(fe.Provider, { value: N, children: B }) : B, d = s ? /* @__PURE__ */ v(ie, { navigate: s, useHref: l ? Me(l) : void 0, children: o }) : o;
208
- return u ? /* @__PURE__ */ v(se, { locale: u, children: d }) : d;
203
+ return /* @__PURE__ */ v(Y.Provider, { value: et, children: (() => {
204
+ const o = _ ? /* @__PURE__ */ v(pt.Provider, { value: _, children: V }) : V, u = s ? /* @__PURE__ */ v(lt, { navigate: s, useHref: m ? Ot(m) : void 0, children: o }) : o;
205
+ return f ? /* @__PURE__ */ v(mt, { locale: f, children: u }) : u;
209
206
  })() });
210
207
  }
211
- function Ge() {
212
- const e = re(Q);
213
- if (e) return e;
208
+ function Rt() {
209
+ const t = ct(Y);
210
+ if (t) return t;
214
211
  const n = typeof document < "u" && document.documentElement.getAttribute("data-theme") === "light" ? "light" : "dark";
215
- return { theme: n, resolvedTheme: n, setTheme: (t) => {
216
- typeof document < "u" && document.documentElement.setAttribute("data-theme", t === "system" ? T() : t);
212
+ return { theme: n, resolvedTheme: n, setTheme: (e) => {
213
+ typeof document < "u" && document.documentElement.setAttribute("data-theme", e === "system" ? C() : e);
217
214
  } };
218
215
  }
219
216
  export {
220
- ye as COMPACT_SPACE,
221
- xe as GLASS_RADII,
222
- We as ThemeProvider,
223
- _e as ThemeScript,
224
- ke as brandVariables,
225
- P as directionOf,
226
- Me as keepAbsolute,
227
- Se as themeScript,
228
- Ge as useTheme
217
+ gt as COMPACT_SPACE,
218
+ wt as GLASS_RADII,
219
+ Bt as ThemeProvider,
220
+ Gt as ThemeScript,
221
+ At as brandVariables,
222
+ T as directionOf,
223
+ Ot as keepAbsolute,
224
+ Mt as themeScript,
225
+ Rt as useTheme
229
226
  };
@@ -1,71 +1,79 @@
1
1
  "use client";
2
2
  import { jsx as a, jsxs as u } from "react/jsx-runtime";
3
- import { useState as L, useEffect as w } from "react";
4
- import { DropZone as W, FileTrigger as x, Text as O } from "react-aria-components";
5
- import { Paperclip as C, UploadCloud as D, FileText as k, Check as P, RotateCw as S, X as Z } from "lucide-react";
6
- import { withBase as A, cx as M } from "../../utils/cx.js";
7
- import { Button as E } from "../button/Button.js";
8
- import { ProgressBar as I } from "../feedback/Feedback.js";
9
- import { useStrings as K } from "../../i18n/strings.js";
10
- const N = (r) => r < 1024 ? `${r} B` : r < 1048576 ? `${Math.round(r / 102.4) / 10} KB` : `${Math.round(r / 104857.6) / 10} MB`, X = (r, t) => !t || t.some((o) => o.startsWith(".") ? r.name.toLowerCase().endsWith(o.toLowerCase()) : o.endsWith("/*") ? r.type.startsWith(o.slice(0, -1)) : r.type === o);
11
- function q({ file: r }) {
12
- const [t, o] = L(null);
13
- return w(() => {
3
+ import { useState as f, useRef as O, useEffect as W } from "react";
4
+ import { DropZone as C, FileTrigger as Z, Text as P } from "react-aria-components";
5
+ import { Paperclip as S, UploadCloud as A, FileText as L, Check as D, RotateCw as M, X as E } from "lucide-react";
6
+ import { withBase as I, cx as K } from "../../utils/cx.js";
7
+ import { Button as X } from "../button/Button.js";
8
+ import { ProgressBar as q } from "../feedback/Feedback.js";
9
+ import { useStrings as T } from "../../i18n/strings.js";
10
+ const N = (r) => r < 1024 ? `${r} B` : r < 1048576 ? `${Math.round(r / 102.4) / 10} KB` : `${Math.round(r / 104857.6) / 10} MB`, G = (r, o) => !o || o.some((t) => t.startsWith(".") ? r.name.toLowerCase().endsWith(t.toLowerCase()) : t.endsWith("/*") ? r.type.startsWith(t.slice(0, -1)) : r.type === t);
11
+ function H({ file: r }) {
12
+ const [o, t] = f(null);
13
+ return W(() => {
14
14
  if (!r.type.startsWith("image/") || typeof URL.createObjectURL != "function") return;
15
- const d = URL.createObjectURL(r);
16
- return o(d), () => URL.revokeObjectURL(d);
17
- }, [r]), t ? /* @__PURE__ */ a("img", { className: "alea-upload-thumb", src: t, alt: "" }) : /* @__PURE__ */ a("span", { className: "alea-upload-thumb", "aria-hidden": "true", children: /* @__PURE__ */ a(k, { size: 20 }) });
15
+ const c = URL.createObjectURL(r);
16
+ return t(c), () => URL.revokeObjectURL(c);
17
+ }, [r]), o ? /* @__PURE__ */ a("img", { className: "alea-upload-thumb", src: o, alt: "" }) : /* @__PURE__ */ a("span", { className: "alea-upload-thumb", "aria-hidden": "true", children: /* @__PURE__ */ a(L, { size: 20 }) });
18
18
  }
19
- function te({ accept: r, allowsMultiple: t = !0, maxSize: o, files: d, onChange: p, label: b, description: m, isDisabled: v, listType: z = "text", variant: h = "dropzone", maxFiles: g, onRetry: y, buttonLabel: T, className: B }) {
20
- const s = K();
21
- b ?? (b = s.dropFiles);
22
- const [R, f] = L([]), c = d ?? R, $ = (e) => {
23
- d === void 0 && f(e), p == null || p(e);
24
- }, U = (e) => {
25
- const n = c.filter((l) => !l.error).length, i = (t ? e : e.slice(0, 1)).map((l, j) => ({
26
- id: `${l.name}-${l.size}-${Math.random().toString(36).slice(2, 7)}`,
27
- file: l,
28
- error: X(l, r) ? o && l.size > o ? s.largerThan(N(o)) : g !== void 0 && t && n + j >= g ? s.tooManyFiles(g) : void 0 : s.typeNotAccepted
19
+ function se({ accept: r, allowsMultiple: o = !0, maxSize: t, files: c, onChange: h, label: y, description: m, isDisabled: g, listType: z = "text", variant: p = "dropzone", maxFiles: b, onRetry: v, buttonLabel: B, className: R }) {
20
+ const s = T();
21
+ y ?? (y = s.dropFiles);
22
+ const [w, j] = f([]), d = c ?? w, $ = O(null), k = (e) => {
23
+ c === void 0 && j(e), h == null || h(e);
24
+ }, F = (e) => {
25
+ const i = d.filter((n) => !n.error).length, l = (o ? e : e.slice(0, 1)).map((n, x) => ({
26
+ id: `${n.name}-${n.size}-${Math.random().toString(36).slice(2, 7)}`,
27
+ file: n,
28
+ error: G(n, r) ? t && n.size > t ? s.largerThan(N(t)) : b !== void 0 && o && i + x >= b ? s.tooManyFiles(b) : void 0 : s.typeNotAccepted
29
29
  }));
30
- $(t ? [...c, ...i] : i);
31
- }, F = /* @__PURE__ */ a(H, { acceptedFileTypes: r, allowsMultiple: t, onSelect: (e) => e && U(Array.from(e)), children: /* @__PURE__ */ a(E, { size: "sm", variant: "secondary", isDisabled: v, iconStart: h === "button" ? /* @__PURE__ */ a(C, {}) : void 0, children: T ?? s.browseFiles }) });
32
- return /* @__PURE__ */ u("div", { className: M("alea-upload", B), "data-list": z, "data-variant": h, children: [
33
- h === "button" ? /* @__PURE__ */ u("div", { className: "alea-upload-button", children: [
34
- F,
30
+ k(o ? [...d, ...l] : l);
31
+ }, U = /* @__PURE__ */ a(Q, { acceptedFileTypes: r, allowsMultiple: o, onSelect: (e) => e && F(Array.from(e)), children: /* @__PURE__ */ a(X, { ref: $, size: "sm", variant: "secondary", isDisabled: g, excludeFromTabOrder: p === "dropzone", iconStart: p === "button" ? /* @__PURE__ */ a(S, {}) : void 0, children: B ?? s.browseFiles }) });
32
+ return /* @__PURE__ */ u("div", { className: K("alea-upload", R), "data-list": z, "data-variant": p, children: [
33
+ p === "button" ? /* @__PURE__ */ u("div", { className: "alea-upload-button", children: [
34
+ U,
35
35
  m && /* @__PURE__ */ a("span", { className: "alea-upload-desc", children: m })
36
- ] }) : /* @__PURE__ */ u(G, { isDisabled: v, onDrop: async (e) => {
37
- const n = e.items.filter((i) => i.kind === "file");
38
- U(await Promise.all(n.map((i) => i.getFile())));
39
- }, children: [
40
- /* @__PURE__ */ a(D, { size: 28, "aria-hidden": "true", className: "alea-upload-icon" }),
41
- /* @__PURE__ */ a(O, { slot: "label", className: "alea-upload-label", children: b }),
42
- m && /* @__PURE__ */ a("span", { className: "alea-upload-desc", children: m }),
43
- F
44
- ] }),
45
- c.length > 0 && /* @__PURE__ */ a("ul", { className: "alea-upload-list", "aria-label": s.files, children: c.map((e) => {
46
- const n = e.progress !== void 0 && e.progress < 100 && !e.error, i = e.progress !== void 0 && e.progress >= 100 && !e.error;
47
- return /* @__PURE__ */ u("li", { className: "alea-upload-item", "data-error": e.error ? !0 : void 0, "data-done": i || void 0, "aria-busy": n || void 0, children: [
48
- z === "text" ? /* @__PURE__ */ a(k, { size: 18, "aria-hidden": "true", className: "alea-upload-file-icon" }) : /* @__PURE__ */ a(q, { file: e.file }),
36
+ ] }) : (
37
+ // The whole zone is one keyboard and pointer target: the engine's paste button covers it (see upload.css), and pressing the zone anywhere
38
+ // (or Enter on the focused button) opens the file picker; the Browse button stays for the pointer but is out of the tab order.
39
+ /* @__PURE__ */ a("div", { style: { display: "contents" }, onClick: (e) => {
40
+ var i;
41
+ !g && !e.target.closest(".alea-button, input") && ((i = $.current) == null || i.click());
42
+ }, children: /* @__PURE__ */ u(J, { isDisabled: g, onDrop: async (e) => {
43
+ const i = e.items.filter((l) => l.kind === "file");
44
+ F(await Promise.all(i.map((l) => l.getFile())));
45
+ }, children: [
46
+ /* @__PURE__ */ a(A, { size: 28, "aria-hidden": "true", className: "alea-upload-icon" }),
47
+ /* @__PURE__ */ a(P, { slot: "label", className: "alea-upload-label", children: y }),
48
+ m && /* @__PURE__ */ a("span", { className: "alea-upload-desc", children: m }),
49
+ U
50
+ ] }) })
51
+ ),
52
+ d.length > 0 && /* @__PURE__ */ a("ul", { className: "alea-upload-list", "aria-label": s.files, children: d.map((e) => {
53
+ const i = e.progress !== void 0 && e.progress < 100 && !e.error, l = e.progress !== void 0 && e.progress >= 100 && !e.error;
54
+ return /* @__PURE__ */ u("li", { className: "alea-upload-item", "data-error": e.error ? !0 : void 0, "data-done": l || void 0, "aria-busy": i || void 0, children: [
55
+ z === "text" ? /* @__PURE__ */ a(L, { size: 18, "aria-hidden": "true", className: "alea-upload-file-icon" }) : /* @__PURE__ */ a(H, { file: e.file }),
49
56
  /* @__PURE__ */ u("div", { className: "alea-upload-meta", children: [
50
57
  /* @__PURE__ */ a("span", { className: "alea-upload-name", children: e.file.name }),
51
- /* @__PURE__ */ a("span", { className: "alea-upload-size", children: e.error || (i ? `${N(e.file.size)} · ${s.uploaded}` : N(e.file.size)) }),
52
- n && /* @__PURE__ */ a(I, { "aria-label": s.uploading(e.file.name), value: e.progress, size: "sm" })
58
+ /* @__PURE__ */ a("span", { className: "alea-upload-size", children: e.error || (l ? `${N(e.file.size)} · ${s.uploaded}` : N(e.file.size)) }),
59
+ i && /* @__PURE__ */ a(q, { "aria-label": s.uploading(e.file.name), value: e.progress, size: "sm" })
53
60
  ] }),
54
- i && /* @__PURE__ */ a(P, { size: 16, "aria-hidden": "true", className: "alea-upload-done" }),
55
- e.error && y && /* @__PURE__ */ a("button", { type: "button", className: "alea-upload-action alea-focus-ring", "aria-label": `${s.retry}: ${e.file.name}`, onClick: () => y(e), children: /* @__PURE__ */ a(S, { size: 14 }) }),
56
- /* @__PURE__ */ a("button", { type: "button", className: "alea-upload-action alea-focus-ring", "aria-label": s.removeItem(e.file.name), onClick: () => $(c.filter((l) => l.id !== e.id)), children: /* @__PURE__ */ a(Z, { size: 14 }) })
61
+ l && /* @__PURE__ */ a(D, { size: 16, "aria-hidden": "true", className: "alea-upload-done" }),
62
+ e.error && v && /* @__PURE__ */ a("button", { type: "button", className: "alea-upload-action alea-focus-ring", "aria-label": `${s.retry}: ${e.file.name}`, onClick: () => v(e), children: /* @__PURE__ */ a(M, { size: 14 }) }),
63
+ /* @__PURE__ */ a("button", { type: "button", className: "alea-upload-action alea-focus-ring", "aria-label": s.removeItem(e.file.name), onClick: () => k(d.filter((n) => n.id !== e.id)), children: /* @__PURE__ */ a(E, { size: 14 }) })
57
64
  ] }, e.id);
58
65
  }) })
59
66
  ] });
60
67
  }
61
- function G({ className: r, ...t }) {
62
- return /* @__PURE__ */ a(W, { ...t, className: A("alea-dropzone", r) });
68
+ function J({ className: r, ...o }) {
69
+ const t = T();
70
+ return /* @__PURE__ */ a(C, { "aria-label": t.dropZoneButton, ...o, className: I("alea-dropzone", r) });
63
71
  }
64
- function H(r) {
65
- return /* @__PURE__ */ a(x, { ...r });
72
+ function Q(r) {
73
+ return /* @__PURE__ */ a(Z, { ...r });
66
74
  }
67
75
  export {
68
- G as DropZone,
69
- H as FileTrigger,
70
- te as FileUpload
76
+ J as DropZone,
77
+ Q as FileTrigger,
78
+ se as FileUpload
71
79
  };