@alea-design/ui 0.6.0 → 0.7.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 +58 -57
- package/dist/components/button/Groups.js +41 -41
- package/dist/components/command/CommandPalette.js +63 -61
- package/dist/components/data/Data.d.ts +10 -6
- package/dist/components/data/Data.js +53 -53
- 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/media/Media.d.ts +5 -1
- package/dist/components/media/Media.js +113 -111
- package/dist/components/navigation/Navigation.d.ts +11 -7
- package/dist/components/navigation/Navigation.js +97 -97
- package/dist/components/navigation/Navigation2.d.ts +4 -2
- package/dist/components/navigation/Navigation2.js +219 -211
- package/dist/components/overlay/Overlay.d.ts +4 -0
- package/dist/components/overlay/Overlay.js +52 -52
- package/dist/components/page/PageParts.d.ts +8 -2
- package/dist/components/page/PageParts.js +95 -87
- package/dist/components/shell/AppShell.d.ts +3 -1
- package/dist/components/shell/AppShell.js +33 -32
- package/dist/components/table/Table.d.ts +6 -3
- package/dist/components/table/Table.js +45 -45
- 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/feedback.css +1 -1
- package/dist/css/groups.json +11 -11
- 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/typography.css +1 -1
- package/dist/i18n/strings.d.ts +4 -1
- package/dist/i18n/strings.js +8 -2
- 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/package.json +3 -3
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as t, jsxs as h } from "react/jsx-runtime";
|
|
3
|
-
import { useContext as
|
|
4
|
-
import { Cell as u, Column as b, useTableOptions as
|
|
5
|
-
import { ArrowUp as
|
|
3
|
+
import { useContext as A, createContext as S, useRef as D, useEffect as F } from "react";
|
|
4
|
+
import { Cell as u, Column as b, useTableOptions as x, Row as M, Collection as R, Table as O, Virtualizer as W, TableLayout as E, ResizableTableContainer as P, TableBody as j, TableFooter as V, TableHeader as L, TableColumnResizeStateContext as U, ColumnResizer as q, Checkbox as G } from "react-aria-components";
|
|
5
|
+
import { ArrowUp as I, Minus as J, Check as K } from "lucide-react";
|
|
6
6
|
import { surfaceAttrs as T } from "../surface/Surface.js";
|
|
7
7
|
import { withBase as m, cx as f } from "../../utils/cx.js";
|
|
8
|
-
import { DragHandle as
|
|
9
|
-
import { useStrings as
|
|
10
|
-
import { renamedValue as
|
|
11
|
-
import { useAnimatedRows as
|
|
12
|
-
function
|
|
13
|
-
return /* @__PURE__ */ t(
|
|
8
|
+
import { DragHandle as Q } from "../list/List.js";
|
|
9
|
+
import { useStrings as X } from "../../i18n/strings.js";
|
|
10
|
+
import { renamedValue as Y } from "../../utils/vocabulary.js";
|
|
11
|
+
import { useAnimatedRows as Z } from "../../utils/animateRows.js";
|
|
12
|
+
function k({ slot: a }) {
|
|
13
|
+
return /* @__PURE__ */ t(G, { slot: a, className: "alea-check alea-table-check", children: ({ isIndeterminate: r }) => /* @__PURE__ */ t("span", { className: "alea-check-box", "aria-hidden": "true", children: r ? /* @__PURE__ */ t(J, { size: 14, strokeWidth: 3 }) : /* @__PURE__ */ t(K, { size: 14, strokeWidth: 3 }) }) });
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const r =
|
|
17
|
-
return
|
|
15
|
+
function _(a) {
|
|
16
|
+
const r = D(null);
|
|
17
|
+
return F(() => {
|
|
18
18
|
const e = r.current;
|
|
19
19
|
if (!a || !e) return;
|
|
20
20
|
const o = () => {
|
|
@@ -29,54 +29,54 @@ function Z(a) {
|
|
|
29
29
|
};
|
|
30
30
|
}, [a]), r;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
const
|
|
34
|
-
return o ? /* @__PURE__ */ t(
|
|
32
|
+
function ue({ stickyHeader: a, density: r = "comfy", maxHeight: e, resizable: o, variant: l = "default", stackBelow: n, stackHideEmpty: i, stickyFooter: d, scrollLabel: s, noWrap: p, virtualized: c, surface: v, radius: g, className: $, ...B }) {
|
|
33
|
+
const H = Y("Table", "density", r, { comfortable: "comfy" }) === "compact" ? "compact" : "comfy", y = /* @__PURE__ */ t(O, { ...B, className: m("alea-table", $), "data-density": H, "data-sticky": a || c ? !0 : void 0, "data-variant": l !== "default" ? l : void 0, "data-stack": n, "data-stack-hide-empty": n && i ? !0 : void 0, "data-sticky-footer": d ? !0 : void 0, "data-virtualized": c ? !0 : void 0, "data-nowrap": p || void 0 }), N = c ? /* @__PURE__ */ t(W, { layout: E, layoutOptions: { rowHeight: c.rowHeight, headingHeight: c.headingHeight ?? 44 }, children: y }) : y, w = e ? { maxHeight: e, ...c ? { height: e } : {} } : void 0, C = _(s);
|
|
34
|
+
return o ? /* @__PURE__ */ t(P, { ref: C, className: "alea-table-wrap", style: w, ...T({ surface: v, radius: g }), children: N }) : /* @__PURE__ */ t("div", { ref: C, className: "alea-table-wrap", style: w, ...T({ surface: v, radius: g }), children: N });
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
const l =
|
|
38
|
-
return /* @__PURE__ */ h(
|
|
36
|
+
function be({ columns: a, children: r, className: e, ...o }) {
|
|
37
|
+
const l = X(), { selectionBehavior: n, selectionMode: i, allowsDragging: d } = x();
|
|
38
|
+
return /* @__PURE__ */ h(L, { ...o, className: f("alea-thead", e), children: [
|
|
39
39
|
d && /* @__PURE__ */ t(b, { className: "alea-th alea-th-narrow", children: /* @__PURE__ */ t("span", { className: "alea-visually-hidden", children: l.dragToMove }) }),
|
|
40
|
-
n === "toggle" && /* @__PURE__ */ t(b, { className: "alea-th alea-th-narrow", children: i === "multiple" && /* @__PURE__ */ t(
|
|
41
|
-
/* @__PURE__ */ t(
|
|
40
|
+
n === "toggle" && /* @__PURE__ */ t(b, { className: "alea-th alea-th-narrow", children: i === "multiple" && /* @__PURE__ */ t(k, { slot: "selection" }) }),
|
|
41
|
+
/* @__PURE__ */ t(R, { items: a, children: r })
|
|
42
42
|
] });
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function he({ children: a, align: r = "start", className: e, ...o }) {
|
|
45
45
|
return /* @__PURE__ */ t(b, { ...o, className: m("alea-th", e), "data-align": r, children: ({ allowsSorting: l, sortDirection: n }) => /* @__PURE__ */ h("div", { className: "alea-th-inner", children: [
|
|
46
46
|
/* @__PURE__ */ t("span", { className: "alea-th-label", children: a }),
|
|
47
|
-
l && /* @__PURE__ */ t(
|
|
48
|
-
/* @__PURE__ */ t(
|
|
47
|
+
l && /* @__PURE__ */ t(I, { size: 14, "aria-hidden": "true", className: "alea-sort", "data-direction": n }),
|
|
48
|
+
/* @__PURE__ */ t(ee, {})
|
|
49
49
|
] }) });
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return
|
|
51
|
+
function ee() {
|
|
52
|
+
return A(U) ? /* @__PURE__ */ t(q, { className: "alea-col-resizer" }) : null;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
const i =
|
|
56
|
-
return /* @__PURE__ */ t(
|
|
54
|
+
function fe({ className: a, animateRows: r, items: e, children: o, dependencies: l, ...n }) {
|
|
55
|
+
const i = Z(e, o, r);
|
|
56
|
+
return /* @__PURE__ */ t(j, { ...n, items: i.items, dependencies: i.dependencies ? [...l ?? [], ...i.dependencies] : l, className: f("alea-tbody", a), children: i.children });
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
function
|
|
60
|
-
return /* @__PURE__ */ t(
|
|
58
|
+
const z = S(!1);
|
|
59
|
+
function pe({ className: a, children: r, ...e }) {
|
|
60
|
+
return /* @__PURE__ */ t(V, { ...e, className: f("alea-tfoot", a), children: /* @__PURE__ */ t(z.Provider, { value: !0, children: r }) });
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
const { selectionBehavior: n, allowsDragging: i, selectionMode: d } =
|
|
64
|
-
return /* @__PURE__ */ h(
|
|
65
|
-
i && /* @__PURE__ */ t(u, { className: "alea-td alea-td-narrow", children:
|
|
66
|
-
n === "toggle" && /* @__PURE__ */ t(u, { className: "alea-td alea-td-narrow", children:
|
|
67
|
-
/* @__PURE__ */ t(
|
|
62
|
+
function ve({ id: a, columns: r, children: e, className: o, ...l }) {
|
|
63
|
+
const { selectionBehavior: n, allowsDragging: i, selectionMode: d } = x(), s = A(z);
|
|
64
|
+
return /* @__PURE__ */ h(M, { id: a, ...s && d !== "none" ? { isDisabled: !0 } : {}, ...l, className: m("alea-tr", o), "data-footer": s ? !0 : void 0, children: [
|
|
65
|
+
i && /* @__PURE__ */ t(u, { className: "alea-td alea-td-narrow", children: s ? null : /* @__PURE__ */ t(Q, {}) }),
|
|
66
|
+
n === "toggle" && /* @__PURE__ */ t(u, { className: "alea-td alea-td-narrow", children: s ? null : /* @__PURE__ */ t(k, { slot: "selection" }) }),
|
|
67
|
+
/* @__PURE__ */ t(R, { items: r, dependencies: l.dependencies, children: e })
|
|
68
68
|
] });
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function ge({ className: a, ...r }) {
|
|
71
71
|
const { align: e, label: o, ...l } = r;
|
|
72
72
|
return /* @__PURE__ */ t(u, { ...l, "data-align": e, "data-label": o, className: m("alea-td", a) });
|
|
73
73
|
}
|
|
74
74
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
ge as Cell,
|
|
76
|
+
he as Column,
|
|
77
|
+
ve as Row,
|
|
78
|
+
ue as Table,
|
|
79
|
+
fe as TableBody,
|
|
80
|
+
pe as TableFooter,
|
|
81
|
+
be as TableHeader
|
|
82
82
|
};
|
|
@@ -70,6 +70,10 @@ export interface ThemeProviderProps {
|
|
|
70
70
|
contrast?: 'system' | 'more' | 'normal';
|
|
71
71
|
/** decorated (default) keeps the background orbs and aurora; plain turns them off for a flat page, in any look and contrast. */
|
|
72
72
|
background?: 'decorated' | 'plain';
|
|
73
|
+
/** Underline every text link (links, breadcrumbs, side navigation links and menu links), not only on hover, so a link never depends on its color alone. For a "links are underlined" setting or an AAA context. Default false. */
|
|
74
|
+
underlineLinks?: boolean;
|
|
75
|
+
/** Let every Button below break a long label onto lines instead of cutting it with an ellipsis (what `wrap` does on one button). Short labels look the same; a label wider than its container wraps, which keeps 375 px with large text from overflowing. Default false. */
|
|
76
|
+
wrapButtons?: boolean;
|
|
73
77
|
/** The glass look's liquid edge (Chromium; others keep the frost): how much what is behind a glass surface bends at its edge,
|
|
74
78
|
* 'off', 'subtle', 'medium' (default) or 'strong', or a multiplier; lensSelector adds your own surfaces (CSS selector).
|
|
75
79
|
* The lens rests while the page scrolls and comes back ~150 ms after it stops (the frost stays); pauseOnScroll={false} keeps it on always. Surfaces over 400 x 300 px keep the frost only. */
|
|
@@ -96,7 +100,7 @@ export declare function ThemeScript({ storageKey, defaultTheme }: {
|
|
|
96
100
|
}): import("react").JSX.Element;
|
|
97
101
|
/** A router's useHref that leaves absolute URLs, protocol-relative URLs and #anchors alone (routers would turn https://… into /current/https:/…). */
|
|
98
102
|
export declare function keepAbsolute(useHref: (href: string) => string): (href: string) => string;
|
|
99
|
-
export declare function ThemeProvider({ children, dir: dirProp, defaultTheme, theme: controlled, onThemeChange, storageKey, scope, className, brand, density, navigate, useHref, locale, motion, preset, surface, contrast, background, strings, glass }: ThemeProviderProps): import("react").JSX.Element;
|
|
103
|
+
export declare function ThemeProvider({ children, dir: dirProp, defaultTheme, theme: controlled, onThemeChange, storageKey, scope, className, brand, density, navigate, useHref, locale, motion, preset, surface, contrast, background, underlineLinks, wrapButtons, strings, glass }: ThemeProviderProps): import("react").JSX.Element;
|
|
100
104
|
/** The current theme and a setter. Works without a provider (reads the document). */
|
|
101
105
|
export declare function useTheme(): ThemeContextValue;
|
|
102
106
|
export {};
|
|
@@ -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
|
};
|