@alea-design/ui 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/button/Button.d.ts +3 -1
- package/dist/components/button/Button.js +58 -57
- package/dist/components/button/Groups.js +41 -41
- package/dist/components/data/Data.d.ts +6 -4
- package/dist/components/data/Data.js +49 -49
- package/dist/components/date/Date.d.ts +3 -1
- package/dist/components/date/Date.js +74 -74
- package/dist/components/form/Form.d.ts +3 -1
- package/dist/components/form/Form.js +44 -52
- package/dist/components/form/validity.d.ts +22 -0
- package/dist/components/form/validity.js +38 -0
- package/dist/components/list/List.d.ts +3 -2
- package/dist/components/more/More.d.ts +3 -1
- package/dist/components/more/More.js +46 -46
- package/dist/components/navigation/Navigation.d.ts +4 -4
- package/dist/components/navigation/Navigation.js +94 -94
- package/dist/components/navigation/Navigation2.d.ts +3 -1
- package/dist/components/navigation/Navigation2.js +218 -210
- package/dist/components/page/PageParts.d.ts +6 -2
- package/dist/components/page/PageParts.js +85 -85
- package/dist/components/shell/AppShell.d.ts +3 -1
- package/dist/components/shell/AppShell.js +33 -32
- package/dist/components/table/Table.d.ts +8 -3
- package/dist/components/table/Table.js +58 -57
- package/dist/components/theme/Theme.d.ts +5 -1
- package/dist/components/theme/Theme.js +63 -63
- package/dist/css/base.css +1 -1
- package/dist/css/button.css +1 -1
- package/dist/css/data.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/groups.json +13 -13
- package/dist/css/more.css +1 -1
- package/dist/css/navigation.css +1 -1
- package/dist/css/page.css +1 -1
- package/dist/css/shell.css +1 -1
- package/dist/css/table.css +1 -1
- package/dist/css/tabs.css +1 -1
- package/dist/css/typography.css +1 -1
- package/dist/i18n/strings.d.ts +1 -0
- package/dist/i18n/strings.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +279 -275
- package/dist/styles.css +1 -1
- package/dist/utils/animateRows.d.ts +3 -2
- package/dist/utils/animateRows.js +15 -15
- package/dist/utils/measure.d.ts +12 -0
- package/dist/utils/measure.js +20 -0
- package/dist/utils/scrollEdges.d.ts +1 -1
- package/dist/utils/scrollEdges.js +23 -22
- 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 J, Fragment as rt, jsx as v } from "react/jsx-runtime";
|
|
3
|
+
import { useState as ot, useSyncExternalStore as U, useEffect as w, useMemo as M, useId as ct, useCallback as it, useContext as st, createContext as lt } from "react";
|
|
4
|
+
import { warnDeprecated as mt } from "../../utils/vocabulary.js";
|
|
5
|
+
import { RouterProvider as dt, I18nProvider as ut } from "react-aria-components";
|
|
6
|
+
import { motionVariables as ft, motionAttributes as ht, motionComponentCss as pt } from "@alea-design/motion";
|
|
7
|
+
import { cx as yt } from "../../utils/cx.js";
|
|
8
|
+
import { StringsContext as xt } from "../../i18n/strings.js";
|
|
9
|
+
import { refractionLevel as gt, startGlassLens as wt } from "./lens.js";
|
|
10
|
+
const vt = {
|
|
11
11
|
"--alea-spacing-base": "0.125rem",
|
|
12
12
|
"--alea-space-0": "0rem",
|
|
13
13
|
"--alea-space-0-25": "0.0625rem",
|
|
@@ -29,8 +29,8 @@ const gt = {
|
|
|
29
29
|
"--alea-space-20": "2.5rem",
|
|
30
30
|
"--alea-space-22": "2.75rem",
|
|
31
31
|
"--alea-space-24": "3rem"
|
|
32
|
-
},
|
|
33
|
-
function
|
|
32
|
+
}, q = [["3xs", 1], ["2xs", 2], ["xs", 4], ["sm", 6], ["field", 8], ["md", 10], ["lg", 12], ["xl", 16], ["2xl", 20], ["3xl", 24], ["4xl", 32]], kt = q.map(([t, n]) => [t, t === "3xs" || t === "2xs" ? n : n * 2]);
|
|
33
|
+
function Z(t) {
|
|
34
34
|
const n = t.trim().toLowerCase(), e = /^#([0-9a-f]{3,8})$/.exec(n);
|
|
35
35
|
if (e) {
|
|
36
36
|
let s = e[1];
|
|
@@ -50,46 +50,46 @@ function J(t) {
|
|
|
50
50
|
};
|
|
51
51
|
return [y(0), y(8), y(4)];
|
|
52
52
|
}
|
|
53
|
-
const
|
|
53
|
+
const H = ([t, n, e]) => {
|
|
54
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 e =
|
|
59
|
+
}, $t = (t, n) => {
|
|
60
|
+
const e = H(t), a = H(n);
|
|
61
61
|
return (Math.max(e, a) + 0.05) / (Math.min(e, a) + 0.05);
|
|
62
|
-
},
|
|
63
|
-
function
|
|
64
|
-
const e = {}, a =
|
|
62
|
+
}, Q = (t) => `#${t.map((n) => n.toString(16).padStart(2, "0")).join("")}`, At = (t, n) => t.map((e) => Math.round(e * n));
|
|
63
|
+
function Et(t, n) {
|
|
64
|
+
const e = {}, a = Z(t);
|
|
65
65
|
let r = t, c = `color-mix(in srgb, ${t} 88%, black)`, i = "var(--alea-accent-on)";
|
|
66
66
|
if (a) {
|
|
67
|
-
const p = [a,
|
|
67
|
+
const p = [a, At(a, 0.88)], l = [n, "#0a0a0a", "#000000", "#ffffff"].filter((d) => !!d).map((d) => ({ css: d, rgb: Z(d) })).filter((d) => !!d.rgb), y = (d, x) => Math.min(...x.map((h) => $t(d, h))), s = (d) => {
|
|
68
68
|
const x = l.map((h) => ({ css: h.css, ratio: y(h.rgb, d) }));
|
|
69
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
71
|
let m = s(p), f = p;
|
|
72
|
-
m.ratio < 4.5 && (f = [a, a], m = s(f)), r =
|
|
72
|
+
m.ratio < 4.5 && (f = [a, a], m = s(f)), r = Q(f[0]), c = Q(f[1]), i = m.css;
|
|
73
73
|
}
|
|
74
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
|
|
76
|
+
function St(t = {}, n = "default") {
|
|
77
77
|
var r, c, i, p;
|
|
78
78
|
const e = {};
|
|
79
79
|
if (t.accent) {
|
|
80
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
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,
|
|
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, Et(t.accent, t.accentOn));
|
|
83
83
|
}
|
|
84
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" ?
|
|
85
|
+
for (const [l, y] of n === "glass" ? kt : q) e[`--alea-radius-${l}`] = `${Math.round(y * t.radius)}px`;
|
|
86
86
|
e["--alea-radius-full"] = t.radius >= 1 ? "9999px" : `${Math.round(18 * t.radius)}px`;
|
|
87
87
|
}
|
|
88
|
-
t.density === "compact" && Object.assign(e,
|
|
88
|
+
t.density === "compact" && Object.assign(e, vt), (r = t.fonts) != null && r.body && (e["--alea-font-family-body"] = t.fonts.body);
|
|
89
89
|
const a = ((c = t.fonts) == null ? void 0 : c.heading) ?? ((i = t.fonts) == null ? void 0 : i.display);
|
|
90
90
|
return a && (e["--alea-font-family-display"] = a), (p = t.fonts) != null && p.mono && (e["--alea-font-family-mono"] = t.fonts.mono), e;
|
|
91
91
|
}
|
|
92
|
-
const
|
|
92
|
+
const K = lt(null), bt = /* @__PURE__ */ new Set(["ar", "arc", "ckb", "dv", "fa", "he", "ks", "ku", "ps", "sd", "ug", "ur", "yi"]);
|
|
93
93
|
function T(t) {
|
|
94
94
|
var e, a;
|
|
95
95
|
if (!t) return "ltr";
|
|
@@ -99,12 +99,12 @@ function T(t) {
|
|
|
99
99
|
} catch {
|
|
100
100
|
}
|
|
101
101
|
const n = t.toLowerCase().split(/[-_]/)[0];
|
|
102
|
-
return
|
|
102
|
+
return bt.has(n) ? "rtl" : "ltr";
|
|
103
103
|
}
|
|
104
104
|
function C() {
|
|
105
105
|
return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function Mt(t) {
|
|
108
108
|
var e;
|
|
109
109
|
if (typeof window > "u" || !window.matchMedia) return () => {
|
|
110
110
|
};
|
|
@@ -114,16 +114,16 @@ function St(t) {
|
|
|
114
114
|
return (a = n.removeEventListener) == null ? void 0 : a.call(n, "change", t);
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
-
const
|
|
117
|
+
const Ot = () => () => {
|
|
118
118
|
};
|
|
119
|
-
function
|
|
119
|
+
function It(t = "alea-theme", n = "dark") {
|
|
120
120
|
const e = (a) => JSON.stringify(a).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
121
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){}})()`;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
return /* @__PURE__ */ v("script", { dangerouslySetInnerHTML: { __html:
|
|
123
|
+
function Vt({ storageKey: t = "alea-theme", defaultTheme: n = "dark" }) {
|
|
124
|
+
return /* @__PURE__ */ v("script", { dangerouslySetInnerHTML: { __html: It(t, n) } });
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function X(t) {
|
|
127
127
|
if (!t || typeof window > "u") return null;
|
|
128
128
|
try {
|
|
129
129
|
const n = window.localStorage.getItem(t);
|
|
@@ -132,27 +132,27 @@ function H(t) {
|
|
|
132
132
|
return null;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
const Lt = /^([a-z][a-z0-9+.-]*:|\/\/|#)/i,
|
|
136
|
-
function
|
|
137
|
-
let n =
|
|
135
|
+
const Lt = /^([a-z][a-z0-9+.-]*:|\/\/|#)/i, Y = /* @__PURE__ */ new WeakMap();
|
|
136
|
+
function jt(t) {
|
|
137
|
+
let n = Y.get(t);
|
|
138
138
|
return n || (n = (e) => {
|
|
139
139
|
const a = t(e);
|
|
140
140
|
return Lt.test(e) ? e : a;
|
|
141
|
-
},
|
|
141
|
+
}, Y.set(t, n)), n;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function Pt(t, n, e = !0) {
|
|
144
144
|
w(() => {
|
|
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"),
|
|
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"), wt(n).refresh());
|
|
146
146
|
}, [t, n, e]);
|
|
147
147
|
}
|
|
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",
|
|
149
|
-
|
|
150
|
-
const [
|
|
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", underlineLinks: _ = !1, wrapButtons: W = !1, strings: z, glass: g }) {
|
|
149
|
+
Pt(gt(g == null ? void 0 : g.refraction), g == null ? void 0 : g.lensSelector, (g == null ? void 0 : g.pauseOnScroll) !== !1);
|
|
150
|
+
const [O, tt] = ot(null), et = U(Ot, () => X(c), () => null), $ = a ?? O ?? et ?? e, nt = U(Mt, C, () => "dark"), A = $ === "system" ? nt : $;
|
|
151
151
|
w(() => {
|
|
152
152
|
if (i !== "document" || typeof document > "u") return;
|
|
153
|
-
const o = a ??
|
|
153
|
+
const o = a ?? O ?? X(c) ?? e;
|
|
154
154
|
document.documentElement.setAttribute("data-theme", o === "system" ? C() : o), document.documentElement.classList.add("alea-root");
|
|
155
|
-
}, [A, i, a,
|
|
155
|
+
}, [A, i, a, O, c, e]), w(() => {
|
|
156
156
|
if (i !== "document" || typeof window > "u") return;
|
|
157
157
|
const o = document.documentElement, u = () => o.style.setProperty("--alea-scrollbar", `${Math.max(0, window.innerWidth - o.clientWidth)}px`);
|
|
158
158
|
return u(), window.addEventListener("resize", u), () => {
|
|
@@ -169,11 +169,11 @@ function Bt({ children: t, dir: n, defaultTheme: e = "dark", theme: a, onThemeCh
|
|
|
169
169
|
}, [E, i]), w(() => {
|
|
170
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
171
|
}, [n, f]);
|
|
172
|
-
const
|
|
172
|
+
const I = JSON.stringify(d || {}), S = M(() => ({ ...St(l, x), ...ft(d) }), [l, I, x]);
|
|
173
173
|
w(() => {
|
|
174
|
-
(y === "comfortable" || (l == null ? void 0 : l.density) === "comfortable") &&
|
|
174
|
+
(y === "comfortable" || (l == null ? void 0 : l.density) === "comfortable") && mt("ThemeProvider", 'density="comfortable"', 'density="comfy"');
|
|
175
175
|
}, [y, l == null ? void 0 : l.density]);
|
|
176
|
-
const
|
|
176
|
+
const G = y ?? ((l == null ? void 0 : l.density) === "compact" ? "compact" : "comfy"), R = G === "compact", V = G === "touch", b = M(() => ({ ...ht(d), ...R ? { "data-density": "compact" } : V ? { "data-density": "touch" } : {}, ...x !== "default" ? { "data-preset": x } : {}, ...h !== "solid" ? { "data-surface": h } : {}, ...k !== "system" ? { "data-contrast": k } : {}, ...N === "plain" ? { "data-background": "plain" } : {}, ..._ ? { "data-underline-links": "true" } : {}, ...W ? { "data-wrap-buttons": "true" } : {} }), [I, x, h, k, N, _, W, R, V]), L = ct().replace(/[^a-zA-Z0-9_-]/g, ""), j = M(() => pt(d == null ? void 0 : d.components, i === "document" ? ":root" : `[data-alea-scope="${L}"]`), [I, i, L]);
|
|
177
177
|
w(() => {
|
|
178
178
|
if (i !== "document" || typeof document > "u") return;
|
|
179
179
|
const o = document.documentElement;
|
|
@@ -187,26 +187,26 @@ function Bt({ children: t, dir: n, defaultTheme: e = "dark", theme: a, onThemeCh
|
|
|
187
187
|
Object.keys(S).forEach((u) => o.style.removeProperty(u));
|
|
188
188
|
};
|
|
189
189
|
}, [S, i]);
|
|
190
|
-
const B =
|
|
191
|
-
if (a === void 0 &&
|
|
190
|
+
const B = it((o) => {
|
|
191
|
+
if (a === void 0 && tt(o), r == null || r(o), c)
|
|
192
192
|
try {
|
|
193
193
|
window.localStorage.setItem(c, o);
|
|
194
194
|
} catch {
|
|
195
195
|
}
|
|
196
|
-
}, [a, r, c]),
|
|
197
|
-
|
|
196
|
+
}, [a, r, c]), at = M(() => ({ theme: $, resolvedTheme: A, setTheme: B }), [$, A, B]), D = j ? /* @__PURE__ */ v("style", { children: j }) : null, F = i === "element" ? /* @__PURE__ */ J("div", { className: yt("alea-root", p), dir: E, "data-theme": A, "data-alea-scope": j ? L : void 0, ...b, style: S, children: [
|
|
197
|
+
D,
|
|
198
198
|
t
|
|
199
|
-
] }) : /* @__PURE__ */
|
|
200
|
-
|
|
199
|
+
] }) : /* @__PURE__ */ J(rt, { children: [
|
|
200
|
+
D,
|
|
201
201
|
t
|
|
202
202
|
] });
|
|
203
|
-
return /* @__PURE__ */ v(
|
|
204
|
-
const o =
|
|
205
|
-
return f ? /* @__PURE__ */ v(
|
|
203
|
+
return /* @__PURE__ */ v(K.Provider, { value: at, children: (() => {
|
|
204
|
+
const o = z ? /* @__PURE__ */ v(xt.Provider, { value: z, children: F }) : F, u = s ? /* @__PURE__ */ v(dt, { navigate: s, useHref: m ? jt(m) : void 0, children: o }) : o;
|
|
205
|
+
return f ? /* @__PURE__ */ v(ut, { locale: f, children: u }) : u;
|
|
206
206
|
})() });
|
|
207
207
|
}
|
|
208
|
-
function
|
|
209
|
-
const t =
|
|
208
|
+
function Dt() {
|
|
209
|
+
const t = st(K);
|
|
210
210
|
if (t) return t;
|
|
211
211
|
const n = typeof document < "u" && document.documentElement.getAttribute("data-theme") === "light" ? "light" : "dark";
|
|
212
212
|
return { theme: n, resolvedTheme: n, setTheme: (e) => {
|
|
@@ -214,13 +214,13 @@ function Rt() {
|
|
|
214
214
|
} };
|
|
215
215
|
}
|
|
216
216
|
export {
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
vt as COMPACT_SPACE,
|
|
218
|
+
kt as GLASS_RADII,
|
|
219
219
|
Bt as ThemeProvider,
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
Vt as ThemeScript,
|
|
221
|
+
St as brandVariables,
|
|
222
222
|
T as directionOf,
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
jt as keepAbsolute,
|
|
224
|
+
It as themeScript,
|
|
225
|
+
Dt as useTheme
|
|
226
226
|
};
|