@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,115 +1,126 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { Tab as
|
|
5
|
-
import { X as
|
|
6
|
-
import { withBase as
|
|
7
|
-
import { tabIcon as
|
|
8
|
-
import { useScrollEdges as
|
|
9
|
-
import { useStrings as
|
|
10
|
-
function ie({ variant:
|
|
11
|
-
const
|
|
12
|
-
return
|
|
13
|
-
const o =
|
|
2
|
+
import { jsx as a, jsxs as k, Fragment as $ } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as y, useEffect as E, useState as K, useId as W, useLayoutEffect as H } from "react";
|
|
4
|
+
import { Tab as U, SelectionIndicator as X, TabList as G, Link as J, TabPanel as Q, Tabs as V } from "react-aria-components";
|
|
5
|
+
import { X as Y, ChevronLeft as j, ChevronRight as B } from "lucide-react";
|
|
6
|
+
import { withBase as A } from "../../utils/cx.js";
|
|
7
|
+
import { tabIcon as Z } from "../icon/icon-contexts.js";
|
|
8
|
+
import { useScrollEdges as C } from "../../utils/scrollEdges.js";
|
|
9
|
+
import { useStrings as F } from "../../i18n/strings.js";
|
|
10
|
+
function ie({ variant: m = "underline", size: i, fitted: c, justify: v, className: l, ...h }) {
|
|
11
|
+
const d = y(null);
|
|
12
|
+
return H(() => {
|
|
13
|
+
const o = d.current;
|
|
14
14
|
if (!o) return;
|
|
15
|
-
const
|
|
16
|
-
document.getElementById(
|
|
15
|
+
const u = () => o.querySelectorAll('[role="tab"][aria-controls]').forEach((n) => {
|
|
16
|
+
document.getElementById(n.getAttribute("aria-controls")) || n.removeAttribute("aria-controls");
|
|
17
17
|
});
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
return
|
|
21
|
-
}, []), /* @__PURE__ */
|
|
18
|
+
if (u(), typeof MutationObserver > "u") return;
|
|
19
|
+
const e = new MutationObserver(u);
|
|
20
|
+
return e.observe(o, { subtree: !0, childList: !0, attributes: !0, attributeFilter: ["aria-controls"] }), () => e.disconnect();
|
|
21
|
+
}, []), /* @__PURE__ */ a(V, { ...h, ref: d, "data-variant": m, "data-size": i, "data-fitted": c || void 0, "data-justify": v, className: A("alea-tabs", l) });
|
|
22
22
|
}
|
|
23
|
-
function le({ className:
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
var
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
29
|
-
const
|
|
30
|
-
|
|
23
|
+
function le({ className: m, extra: i, onReorder: c, ...v }) {
|
|
24
|
+
const l = F(), h = y(null), { edges: d, scroll: o } = C(h, ".alea-tab-list"), [u, e] = K(""), n = W(), b = y(c);
|
|
25
|
+
return b.current = c, E(() => {
|
|
26
|
+
var P;
|
|
27
|
+
const r = (P = h.current) == null ? void 0 : P.querySelector(".alea-tab-list");
|
|
28
|
+
if (!r || !c) return;
|
|
29
|
+
const g = () => Array.from(r.querySelectorAll('[role="tab"]')), S = () => g().forEach((t) => {
|
|
30
|
+
t.setAttribute("draggable", "true"), t.setAttribute("aria-describedby", n), t.setAttribute("aria-keyshortcuts", "Alt+Shift+ArrowLeft Alt+Shift+ArrowRight");
|
|
31
31
|
});
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const
|
|
32
|
+
S();
|
|
33
|
+
const x = new MutationObserver(S);
|
|
34
|
+
x.observe(r, { childList: !0 });
|
|
35
|
+
const w = () => r.getAttribute("aria-orientation") === "vertical", T = (t, s) => {
|
|
36
36
|
var N;
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
return (
|
|
37
|
+
const L = g(), p = t.dataset.key;
|
|
38
|
+
s = Math.max(0, Math.min(L.length - 1, s)), s !== L.indexOf(t) && ((N = b.current) == null || N.call(b, p, s), e(l.movedTo(t.textContent ?? p, s + 1, L.length)), requestAnimationFrame(() => {
|
|
39
|
+
var M;
|
|
40
|
+
return (M = r.querySelector(`[data-key="${CSS.escape(p)}"]`)) == null ? void 0 : M.focus();
|
|
41
41
|
}));
|
|
42
|
-
},
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
const N = getComputedStyle(
|
|
49
|
-
T(
|
|
42
|
+
}, D = (t) => {
|
|
43
|
+
const s = t.target.closest('[role="tab"]');
|
|
44
|
+
if (!s || !t.altKey || !t.shiftKey) return;
|
|
45
|
+
const L = w() ? "ArrowUp" : "ArrowLeft", p = w() ? "ArrowDown" : "ArrowRight";
|
|
46
|
+
if (t.key !== L && t.key !== p) return;
|
|
47
|
+
t.preventDefault(), t.stopPropagation();
|
|
48
|
+
const N = getComputedStyle(r).direction === "rtl" && !w();
|
|
49
|
+
T(s, g().indexOf(s) + (t.key === p !== N ? 1 : -1));
|
|
50
50
|
};
|
|
51
|
-
let
|
|
52
|
-
const
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
|
|
51
|
+
let f = null;
|
|
52
|
+
const I = (t) => {
|
|
53
|
+
var s;
|
|
54
|
+
f = t.target.closest('[role="tab"]'), f && ((s = t.dataTransfer) == null || s.setData("text/plain", f.dataset.key ?? ""), f.dataset.dragging = "true");
|
|
55
|
+
}, q = (t) => {
|
|
56
|
+
f && t.preventDefault();
|
|
57
|
+
}, z = (t) => {
|
|
58
|
+
const s = t.target.closest('[role="tab"]');
|
|
59
|
+
f && s && s !== f && (t.preventDefault(), T(f, g().indexOf(s)));
|
|
60
|
+
}, O = () => {
|
|
61
|
+
f && delete f.dataset.dragging, f = null;
|
|
62
62
|
};
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
return r.addEventListener("keydown", D, !0), r.addEventListener("dragstart", I), r.addEventListener("dragover", q), r.addEventListener("drop", z), r.addEventListener("dragend", O), () => {
|
|
64
|
+
x.disconnect(), r.removeEventListener("keydown", D, !0), r.removeEventListener("dragstart", I), r.removeEventListener("dragover", q), r.removeEventListener("drop", z), r.removeEventListener("dragend", O), g().forEach((t) => {
|
|
65
|
+
t.removeAttribute("draggable"), t.removeAttribute("aria-describedby"), t.removeAttribute("aria-keyshortcuts");
|
|
66
66
|
});
|
|
67
67
|
};
|
|
68
|
-
}, [!!
|
|
69
|
-
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
68
|
+
}, [!!c, n]), /* @__PURE__ */ k("div", { ref: h, className: "alea-tab-bar", "data-overflow-start": d.start || void 0, "data-overflow-end": d.end || void 0, "data-reorderable": c ? !0 : void 0, children: [
|
|
69
|
+
d.start && /* @__PURE__ */ a("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () => o(-1), children: /* @__PURE__ */ a(j, { size: 16 }) }),
|
|
70
|
+
/* @__PURE__ */ a(G, { ...v, "aria-label": v["aria-label"], className: A("alea-tab-list", m) }),
|
|
71
|
+
d.end && /* @__PURE__ */ a("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () => o(1), children: /* @__PURE__ */ a(B, { size: 16 }) }),
|
|
72
|
+
i && /* @__PURE__ */ a("div", { className: "alea-tab-extra", children: i }),
|
|
73
|
+
c && /* @__PURE__ */ k($, { children: [
|
|
74
|
+
/* @__PURE__ */ a("span", { id: n, hidden: !0, children: l.reorderHint }),
|
|
75
|
+
/* @__PURE__ */ a("span", { className: "alea-visually-hidden", role: "status", children: u })
|
|
76
76
|
] })
|
|
77
77
|
] });
|
|
78
78
|
}
|
|
79
|
-
function oe({ className:
|
|
80
|
-
const
|
|
81
|
-
return
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
var
|
|
87
|
-
(
|
|
79
|
+
function oe({ className: m, children: i, icon: c, badge: v, onClose: l, ...h }) {
|
|
80
|
+
const d = F(), o = y(null), u = y(l);
|
|
81
|
+
return u.current = l, E(() => {
|
|
82
|
+
const e = o.current;
|
|
83
|
+
if (!e || !l) return;
|
|
84
|
+
e.setAttribute("aria-keyshortcuts", "Delete");
|
|
85
|
+
const n = (b) => {
|
|
86
|
+
var r;
|
|
87
|
+
(b.key === "Delete" || b.key === "Backspace") && (b.preventDefault(), (r = u.current) == null || r.call(u));
|
|
88
88
|
};
|
|
89
|
-
return
|
|
90
|
-
}, [!!
|
|
91
|
-
|
|
92
|
-
/* @__PURE__ */
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}, children: /* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */
|
|
89
|
+
return e.addEventListener("keydown", n), () => e.removeEventListener("keydown", n);
|
|
90
|
+
}, [!!l]), /* @__PURE__ */ a(U, { ...h, ref: o, className: A("alea-tab alea-focus-ring", m), "data-closable": l ? !0 : void 0, children: (e) => /* @__PURE__ */ k($, { children: [
|
|
91
|
+
c && /* @__PURE__ */ a("span", { className: "alea-tab-icon", "aria-hidden": "true", ...Z(e.isSelected), children: c }),
|
|
92
|
+
/* @__PURE__ */ a("span", { className: "alea-tab-label", children: typeof i == "function" ? i(e) : i }),
|
|
93
|
+
v != null && /* @__PURE__ */ a("span", { className: "alea-tab-badge", children: v }),
|
|
94
|
+
l && /* @__PURE__ */ a("span", { className: "alea-tab-close", "aria-hidden": "true", title: d.close, onPointerDown: (n) => n.stopPropagation(), onClick: (n) => {
|
|
95
|
+
n.stopPropagation(), l();
|
|
96
|
+
}, children: /* @__PURE__ */ a(Y, { size: 12 }) }),
|
|
97
|
+
/* @__PURE__ */ a(X, { className: "alea-sel-indicator" })
|
|
98
98
|
] }) });
|
|
99
99
|
}
|
|
100
|
-
function ce({ className:
|
|
101
|
-
return
|
|
100
|
+
function ce({ className: m, ...i }) {
|
|
101
|
+
return i.children == null || i.children === !1 ? null : /* @__PURE__ */ a(Q, { ...i, className: A("alea-tab-panel alea-focus-ring", m) });
|
|
102
102
|
}
|
|
103
|
-
function de({ items:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
103
|
+
function de({ items: m, current: i, variant: c = "underline", size: v, className: l, "aria-label": h }) {
|
|
104
|
+
const d = y(null), { edges: o, scroll: u } = C(d, ".alea-tab-list");
|
|
105
|
+
return E(() => {
|
|
106
|
+
var g;
|
|
107
|
+
const e = (g = d.current) == null ? void 0 : g.querySelector(".alea-tab-list"), n = e == null ? void 0 : e.querySelector('[aria-current="page"]');
|
|
108
|
+
if (!e || !n) return;
|
|
109
|
+
const b = n.offsetLeft - e.offsetLeft, r = b + n.offsetWidth;
|
|
110
|
+
r > e.scrollLeft + e.clientWidth ? e.scrollLeft = r - e.clientWidth + 8 : b < e.scrollLeft && (e.scrollLeft = Math.max(0, b - 8));
|
|
111
|
+
}, [i]), /* @__PURE__ */ a("nav", { "aria-label": h, className: ["alea-tabs alea-tab-nav", l].filter(Boolean).join(" "), "data-variant": c, "data-size": v, children: /* @__PURE__ */ k("div", { ref: d, className: "alea-tab-bar", "data-overflow-start": o.start || void 0, "data-overflow-end": o.end || void 0, children: [
|
|
112
|
+
o.start && /* @__PURE__ */ a("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () => u(-1), children: /* @__PURE__ */ a(j, { size: 16 }) }),
|
|
113
|
+
/* @__PURE__ */ a("div", { className: "alea-tab-list", children: m.map((e) => {
|
|
114
|
+
const n = e.id === i;
|
|
115
|
+
return /* @__PURE__ */ k(J, { href: e.href, "aria-current": n ? "page" : void 0, "data-selected": n || void 0, className: "alea-tab alea-focus-ring", children: [
|
|
116
|
+
e.icon && /* @__PURE__ */ a("span", { className: "alea-tab-icon", "aria-hidden": "true", children: e.icon }),
|
|
117
|
+
/* @__PURE__ */ a("span", { className: "alea-tab-label", children: e.label }),
|
|
118
|
+
e.badge != null && /* @__PURE__ */ a("span", { className: "alea-tab-badge", children: e.badge }),
|
|
119
|
+
n && /* @__PURE__ */ a("span", { className: "alea-sel-indicator" })
|
|
120
|
+
] }, e.id);
|
|
121
|
+
}) }),
|
|
122
|
+
o.end && /* @__PURE__ */ a("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () => u(1), children: /* @__PURE__ */ a(B, { size: 16 }) })
|
|
123
|
+
] }) });
|
|
113
124
|
}
|
|
114
125
|
export {
|
|
115
126
|
oe as Tab,
|
|
@@ -8,13 +8,16 @@ export interface BrandTheme {
|
|
|
8
8
|
accent?: string;
|
|
9
9
|
/** Text on solid accent surfaces. Default the kit's (near black). */
|
|
10
10
|
accentOn?: string;
|
|
11
|
+
/** Focus ring color (any CSS color). Default: the strong accent, which is darker than the accent in Light and lighter in Dark, so a light brand color still gives a ring of at least 3:1 on the page. Set it only when you have checked your own pair. */
|
|
12
|
+
focus?: string;
|
|
11
13
|
/** Multiplies every radius: 0 square, 0.5 tight, 1 the Alea default, 1.4 rounder. */
|
|
12
14
|
radius?: number;
|
|
13
|
-
/** compact (controls
|
|
15
|
+
/** compact (controls 4 px shorter, the Compact space scale with base 2 px, and control padding that stays wide: horizontal at or above vertical; 44 px controls on a touch pointer) or comfy (default). Same as the density prop of ThemeProvider. 'comfortable' is a deprecated alias of 'comfy'. */
|
|
14
16
|
density?: 'comfy' | 'compact' | /** @deprecated Use comfy. */ 'comfortable';
|
|
15
|
-
/** Font stacks: body (
|
|
17
|
+
/** Font stacks, a runtime override of the font.family tokens: body (--alea-font-family-body: all text and every control), heading (--alea-font-family-display: titles; display is the same thing), mono (--alea-font-family-mono: code, left alone unless set). Load the font files yourself. */
|
|
16
18
|
fonts?: {
|
|
17
19
|
body?: string;
|
|
20
|
+
heading?: string; /** Same as heading. If both are set, heading wins. */
|
|
18
21
|
display?: string;
|
|
19
22
|
mono?: string;
|
|
20
23
|
};
|
|
@@ -48,8 +51,8 @@ export interface ThemeProviderProps {
|
|
|
48
51
|
className?: string;
|
|
49
52
|
/** Brand changes: accent color, radius, density, fonts. */
|
|
50
53
|
brand?: BrandTheme;
|
|
51
|
-
/** Space density: "comfy" (default, base 4 px; "comfortable" is a deprecated alias) or "compact" (base 2 px: every space token halves, odd results rounded up to even). Sets data-density on the root or the wrapper
|
|
52
|
-
density?: 'comfy' | 'compact' | /** @deprecated Use comfy. */ 'comfortable';
|
|
54
|
+
/** Space density: "comfy" (default, base 4 px; "comfortable" is a deprecated alias) or "compact" (base 2 px: every space token halves, odd results rounded up to even). Sets data-density on the root or the wrapper: the control heights go down 4 px, the control padding stays wide (never narrower than the vertical air) and a touch pointer keeps every control at 44 px or more. */
|
|
55
|
+
density?: 'comfy' | 'compact' | /** Comfy spacing with every control at least 44 px tall and a 44 px hit area on small targets (checks, breadcrumb links, the side navigation), whatever the pointer: for apps used on phones and tablets. */ 'touch' | /** @deprecated Use comfy. */ 'comfortable';
|
|
53
56
|
/** Your router's navigate function (React Router's useNavigate(), Next's router.push): links in the kit then navigate without a reload. */
|
|
54
57
|
navigate?: (path: string, options?: any) => void;
|
|
55
58
|
/** Your router's useHref, for routers with a base path. */
|