@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.
- package/dist/components/button/Button.d.ts +3 -1
- package/dist/components/button/Button.js +64 -63
- package/dist/components/card/Card.d.ts +6 -2
- package/dist/components/card/Card.js +20 -20
- package/dist/components/combobox/Autocomplete.d.ts +4 -0
- package/dist/components/combobox/Autocomplete.js +89 -87
- package/dist/components/command/CommandPalette.d.ts +10 -0
- package/dist/components/command/CommandPalette.js +76 -52
- package/dist/components/data/Data.d.ts +6 -4
- package/dist/components/data/Data.js +66 -56
- package/dist/components/date/Date.d.ts +16 -2
- package/dist/components/date/Date.js +80 -69
- package/dist/components/display/Display.d.ts +3 -1
- package/dist/components/display/Display.js +27 -27
- package/dist/components/display/Display2.d.ts +2 -2
- package/dist/components/display/Display2.js +28 -27
- package/dist/components/feedback/Feedback.d.ts +3 -1
- package/dist/components/feedback/Feedback.js +102 -102
- package/dist/components/feedback/PageSkeleton.d.ts +19 -0
- package/dist/components/feedback/PageSkeleton.js +58 -0
- package/dist/components/field/Field.d.ts +3 -1
- package/dist/components/field/Field.js +82 -82
- package/dist/components/filter/FilterBar.d.ts +5 -2
- package/dist/components/filter/FilterBar.js +97 -66
- package/dist/components/form/Form.d.ts +8 -2
- package/dist/components/form/Form.js +53 -40
- package/dist/components/icon/icon-names.d.ts +2 -2
- package/dist/components/icon/icon-names.js +4 -2
- package/dist/components/list/List.d.ts +6 -2
- package/dist/components/list/List.js +65 -62
- package/dist/components/list/Lists2.d.ts +4 -0
- package/dist/components/list/Lists2.js +35 -35
- package/dist/components/media/Media.js +27 -27
- package/dist/components/more/More.d.ts +2 -2
- package/dist/components/more/More.js +46 -45
- package/dist/components/navigation/Navigation.d.ts +7 -5
- package/dist/components/navigation/Navigation.js +91 -74
- package/dist/components/navigation/Navigation2.d.ts +9 -3
- package/dist/components/navigation/Navigation2.js +209 -195
- package/dist/components/notification/NotificationCenter.js +70 -70
- package/dist/components/overlay/Drawer.d.ts +6 -1
- package/dist/components/overlay/Drawer.js +27 -25
- package/dist/components/overlay/Modal.d.ts +5 -0
- package/dist/components/overlay/Modal.js +16 -15
- package/dist/components/overlay/Overlay.d.ts +10 -1
- package/dist/components/overlay/Overlay.js +54 -52
- package/dist/components/overlay/Sheet.d.ts +2 -0
- package/dist/components/overlay/Sheet.js +30 -30
- package/dist/components/page/PageParts.js +20 -20
- package/dist/components/select/Select.js +75 -70
- package/dist/components/settings/Settings.d.ts +29 -0
- package/dist/components/settings/Settings.js +31 -0
- package/dist/components/shell/AccountMenu.d.ts +20 -0
- package/dist/components/shell/AccountMenu.js +32 -0
- package/dist/components/shell/AppShell.d.ts +9 -2
- package/dist/components/shell/AppShell.js +37 -37
- package/dist/components/shell/AppSidebar.d.ts +9 -3
- package/dist/components/shell/AppSidebar.js +45 -39
- package/dist/components/table/Table.d.ts +18 -4
- package/dist/components/table/Table.js +70 -46
- package/dist/components/tabs/Tabs.js +105 -94
- package/dist/components/theme/Theme.d.ts +7 -4
- package/dist/components/theme/Theme.js +127 -130
- package/dist/components/upload/Upload.js +62 -54
- package/dist/css/base.css +1 -1
- package/dist/css/button.css +1 -1
- package/dist/css/card.css +1 -1
- package/dist/css/command.css +1 -1
- package/dist/css/date.css +1 -1
- package/dist/css/display.css +1 -1
- package/dist/css/feedback.css +1 -1
- package/dist/css/field.css +1 -1
- package/dist/css/form.css +1 -1
- package/dist/css/groups.json +36 -20
- package/dist/css/list.css +1 -1
- package/dist/css/menu.css +1 -1
- package/dist/css/navigation.css +1 -1
- package/dist/css/notification.css +1 -1
- package/dist/css/overlay.css +1 -1
- package/dist/css/page.css +1 -1
- package/dist/css/select.css +1 -1
- package/dist/css/settings.css +1 -0
- package/dist/css/shell.css +1 -1
- package/dist/css/table.css +1 -1
- package/dist/css/tabs.css +1 -1
- package/dist/css/upload.css +1 -1
- package/dist/i18n/strings.d.ts +7 -0
- package/dist/i18n/strings.js +14 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +318 -306
- package/dist/styles.css +1 -1
- package/dist/utils/animateRows.d.ts +11 -0
- package/dist/utils/animateRows.js +23 -0
- package/dist/utils/decimal.d.ts +12 -0
- package/dist/utils/decimal.js +48 -0
- package/dist/utils/initialFocus.d.ts +6 -0
- package/dist/utils/initialFocus.js +24 -0
- package/dist/utils/refs.d.ts +2 -0
- package/dist/utils/refs.js +14 -6
- package/package.json +3 -3
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { warnDeprecated as
|
|
5
|
-
import { RouterProvider as
|
|
6
|
-
import { motionVariables as
|
|
7
|
-
import { cx as
|
|
8
|
-
import { StringsContext as
|
|
9
|
-
import { refractionLevel as
|
|
10
|
-
const
|
|
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
|
-
},
|
|
33
|
-
function
|
|
34
|
-
const n =
|
|
35
|
-
if (
|
|
36
|
-
let s =
|
|
37
|
-
return (s.length === 3 || s.length === 4) && (s = s.split("").map((
|
|
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((
|
|
45
|
-
return r.map((
|
|
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,
|
|
48
|
-
const
|
|
49
|
-
return Math.round(255 * (
|
|
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 [
|
|
51
|
+
return [y(0), y(8), y(4)];
|
|
52
52
|
}
|
|
53
|
-
const
|
|
54
|
-
const a = [
|
|
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
|
-
},
|
|
60
|
-
const
|
|
61
|
-
return (Math.max(
|
|
62
|
-
},
|
|
63
|
-
function
|
|
64
|
-
const
|
|
65
|
-
let r =
|
|
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
|
|
68
|
-
const
|
|
69
|
-
return
|
|
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
|
|
72
|
-
|
|
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
|
|
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
|
|
77
|
-
var
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
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 (
|
|
85
|
-
for (const [
|
|
86
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
|
96
|
-
function
|
|
97
|
-
var
|
|
98
|
-
if (!
|
|
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(
|
|
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 =
|
|
105
|
-
return
|
|
101
|
+
const n = t.toLowerCase().split(/[-_]/)[0];
|
|
102
|
+
return Et.has(n) ? "rtl" : "ltr";
|
|
106
103
|
}
|
|
107
|
-
function
|
|
104
|
+
function C() {
|
|
108
105
|
return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
|
|
109
106
|
}
|
|
110
|
-
function
|
|
111
|
-
var
|
|
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 (
|
|
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",
|
|
114
|
+
return (a = n.removeEventListener) == null ? void 0 : a.call(n, "change", t);
|
|
118
115
|
};
|
|
119
116
|
}
|
|
120
|
-
const
|
|
117
|
+
const bt = () => () => {
|
|
121
118
|
};
|
|
122
|
-
function
|
|
123
|
-
const
|
|
124
|
-
return `(function(){try{var k=${t
|
|
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
|
|
127
|
-
return /* @__PURE__ */ v("script", { dangerouslySetInnerHTML: { __html:
|
|
123
|
+
function Gt({ storageKey: t = "alea-theme", defaultTheme: n = "dark" }) {
|
|
124
|
+
return /* @__PURE__ */ v("script", { dangerouslySetInnerHTML: { __html: Mt(t, n) } });
|
|
128
125
|
}
|
|
129
|
-
function
|
|
130
|
-
if (!
|
|
126
|
+
function H(t) {
|
|
127
|
+
if (!t || typeof window > "u") return null;
|
|
131
128
|
try {
|
|
132
|
-
const n = window.localStorage.getItem(
|
|
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
|
|
139
|
-
function
|
|
140
|
-
let n =
|
|
141
|
-
return n || (n = (
|
|
142
|
-
const a = e
|
|
143
|
-
return
|
|
144
|
-
},
|
|
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
|
|
143
|
+
function It(t, n, e = !0) {
|
|
147
144
|
w(() => {
|
|
148
|
-
typeof document > "u" || (document.documentElement.setAttribute("data-alea-refraction", String(
|
|
149
|
-
}, [
|
|
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
|
|
152
|
-
|
|
153
|
-
const [L,
|
|
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 ??
|
|
157
|
-
document.documentElement.setAttribute("data-theme", o === "system" ?
|
|
158
|
-
}, [A, i, a, L, c,
|
|
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,
|
|
161
|
-
return
|
|
162
|
-
window.removeEventListener("resize",
|
|
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 ?? (
|
|
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,
|
|
165
|
+
const o = document.documentElement, u = o.getAttribute("dir");
|
|
169
166
|
return o.setAttribute("dir", E), () => {
|
|
170
|
-
|
|
167
|
+
u == null ? o.removeAttribute("dir") : o.setAttribute("dir", u);
|
|
171
168
|
};
|
|
172
169
|
}, [E, i]), w(() => {
|
|
173
|
-
!n || !
|
|
174
|
-
}, [n,
|
|
175
|
-
const O = JSON.stringify(
|
|
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
|
-
(
|
|
178
|
-
}, [
|
|
179
|
-
const
|
|
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(([
|
|
184
|
-
Object.keys(b).forEach((
|
|
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(([
|
|
190
|
-
Object.keys(S).forEach((
|
|
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
|
|
194
|
-
if (a === void 0 &&
|
|
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]),
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
] }) : /* @__PURE__ */
|
|
203
|
-
|
|
204
|
-
|
|
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(
|
|
207
|
-
const o =
|
|
208
|
-
return
|
|
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
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
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: (
|
|
216
|
-
typeof document < "u" && document.documentElement.setAttribute("data-theme",
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
|
4
|
-
import { DropZone as
|
|
5
|
-
import { Paperclip as
|
|
6
|
-
import { withBase as
|
|
7
|
-
import { Button as
|
|
8
|
-
import { ProgressBar as
|
|
9
|
-
import { useStrings as
|
|
10
|
-
const N = (r) => r < 1024 ? `${r} B` : r < 1048576 ? `${Math.round(r / 102.4) / 10} KB` : `${Math.round(r / 104857.6) / 10} MB`,
|
|
11
|
-
function
|
|
12
|
-
const [
|
|
13
|
-
return
|
|
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
|
|
16
|
-
return
|
|
17
|
-
}, [r]),
|
|
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
|
|
20
|
-
const s =
|
|
21
|
-
|
|
22
|
-
const [
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
const
|
|
26
|
-
id: `${
|
|
27
|
-
file:
|
|
28
|
-
error:
|
|
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
|
-
|
|
31
|
-
},
|
|
32
|
-
return /* @__PURE__ */ u("div", { className:
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
] }) :
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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 || (
|
|
52
|
-
|
|
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
|
-
|
|
55
|
-
e.error &&
|
|
56
|
-
/* @__PURE__ */ a("button", { type: "button", className: "alea-upload-action alea-focus-ring", "aria-label": s.removeItem(e.file.name), onClick: () =>
|
|
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
|
|
62
|
-
|
|
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
|
|
65
|
-
return /* @__PURE__ */ a(
|
|
72
|
+
function Q(r) {
|
|
73
|
+
return /* @__PURE__ */ a(Z, { ...r });
|
|
66
74
|
}
|
|
67
75
|
export {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
J as DropZone,
|
|
77
|
+
Q as FileTrigger,
|
|
78
|
+
se as FileUpload
|
|
71
79
|
};
|