@alea-design/ui 0.5.0 → 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 +393 -21
- 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 +8 -0
- package/dist/i18n/strings.js +16 -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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
type Render<T> = ReactNode | ((item: T) => ReactNode);
|
|
3
|
+
/** Rows of a ListView or a Table body that enter when added and leave when removed. Pass what the component was given (the items and the render function) and hand back what it returns: the removed rows stay in the collection, disabled, until their exit ends. With enabled false it returns the inputs untouched. */
|
|
4
|
+
export declare function useAnimatedRows<T extends {
|
|
5
|
+
id?: string | number;
|
|
6
|
+
}>(items: Iterable<T> | undefined, children: Render<T>, enabled: boolean | undefined): {
|
|
7
|
+
items: Iterable<T> | undefined;
|
|
8
|
+
children: Render<T>;
|
|
9
|
+
dependencies: unknown[] | undefined;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMemo as f, isValidElement as w, cloneElement as j } from "react";
|
|
3
|
+
import { usePresenceList as M } from "@alea-design/motion";
|
|
4
|
+
const b = (n, t) => typeof n == "function" ? (i) => [n(i), t].filter(Boolean).join(" ") : [n, t].filter(Boolean).join(" "), h = (n, t) => typeof n == "function" ? (i) => ({ ...n(i), ...t }) : { ...n, ...t };
|
|
5
|
+
function B(n, t, i) {
|
|
6
|
+
const p = f(() => n ? Array.from(n) : void 0, [n]), { entries: r, ref: u } = M(p, (e) => e.id, !!i), y = f(() => r.map((e) => e.item), [r]), g = r.map((e) => `${e.key}:${e.leaving ? "l" : e.entering ? "e" : ""}`).join("|"), d = f(() => new Map(r.map((e) => [e.item, e])), [r]);
|
|
7
|
+
return !i || !p || typeof t != "function" ? { items: n, children: t, dependencies: void 0 } : { items: y, children: (e) => {
|
|
8
|
+
const a = t(e), o = d.get(e);
|
|
9
|
+
if (!o || !w(a)) return a;
|
|
10
|
+
const l = a.props, m = o.leaving ? "alea-row-leave" : o.entering ? "alea-row-enter" : "", s = l.ref, v = (c) => {
|
|
11
|
+
u(o.key)(c), typeof s == "function" ? s(c) : s && typeof s == "object" && (s.current = c);
|
|
12
|
+
};
|
|
13
|
+
return j(a, {
|
|
14
|
+
...m ? { className: b(l.className, m) } : {},
|
|
15
|
+
...o.entering ? { style: h(l.style, { "--alea-i": Math.min(o.enterIndex, 11) }) } : {},
|
|
16
|
+
...o.leaving ? { isDisabled: !0, "data-leaving": !0 } : {},
|
|
17
|
+
ref: v
|
|
18
|
+
});
|
|
19
|
+
}, dependencies: [g] };
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
B as useAnimatedRows
|
|
23
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Whether a string is a plain decimal numeral: optional sign, digits, optional fraction ("-12.50", ".5", "7"). No exponent, no grouping. */
|
|
2
|
+
export declare function isDecimalString(value: unknown): value is string;
|
|
3
|
+
/** True when the decimal string is zero ("0", "-0.00"). */
|
|
4
|
+
export declare function isZeroDecimal(value: string): boolean;
|
|
5
|
+
/** Whether a decimal string is below zero ("-0.00" is not). */
|
|
6
|
+
export declare function isNegativeDecimal(value: string): boolean;
|
|
7
|
+
/** Orders two decimal strings exactly: negative if a < b, 0 if equal, positive if a > b. Use it as a Table or DataGrid `compare`. A string that is not a decimal sorts after the ones that are. */
|
|
8
|
+
export declare function compareDecimal(a: string, b: string): number;
|
|
9
|
+
/** Adds decimal strings exactly and returns the sum as a decimal string, with as many fraction digits as the longest input. Strings that are not decimals are ignored. */
|
|
10
|
+
export declare function sumDecimal(values: Array<string | null | undefined>): string;
|
|
11
|
+
/** Formats a number or a decimal string with Intl.NumberFormat. A decimal string is passed through untouched so the engine formats it exactly (browsers before 2023 read it as a float). */
|
|
12
|
+
export declare function formatDecimal(value: number | string, locale: string | undefined, options?: Intl.NumberFormatOptions): string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const p = /^[+-]?(\d+\.?\d*|\.\d+)$/;
|
|
3
|
+
function g(t) {
|
|
4
|
+
return typeof t == "string" && p.test(t.trim());
|
|
5
|
+
}
|
|
6
|
+
function a(t) {
|
|
7
|
+
const e = t.trim(), n = e.startsWith("-"), [c = "", o = ""] = e.replace(/^[+-]/, "").split(".");
|
|
8
|
+
return { neg: n, whole: c.replace(/^0+(?=\d)/, "") || "0", frac: o };
|
|
9
|
+
}
|
|
10
|
+
function u(t) {
|
|
11
|
+
const { whole: e, frac: n } = a(t);
|
|
12
|
+
return /^0*$/.test(e) && /^0*$/.test(n);
|
|
13
|
+
}
|
|
14
|
+
function x(t) {
|
|
15
|
+
return a(t).neg && !u(t);
|
|
16
|
+
}
|
|
17
|
+
function D(t, e) {
|
|
18
|
+
const n = g(t), c = g(e);
|
|
19
|
+
if (!n || !c) return n === c ? 0 : n ? -1 : 1;
|
|
20
|
+
const o = a(t), r = a(e), f = u(t), h = u(e), s = o.neg && !f, l = r.neg && !h;
|
|
21
|
+
if (s !== l) return s ? -1 : 1;
|
|
22
|
+
const i = s ? -1 : 1;
|
|
23
|
+
if (o.whole.length !== r.whole.length) return i * (o.whole.length < r.whole.length ? -1 : 1);
|
|
24
|
+
if (o.whole !== r.whole) return i * (o.whole < r.whole ? -1 : 1);
|
|
25
|
+
const m = Math.max(o.frac.length, r.frac.length), w = o.frac.padEnd(m, "0"), d = r.frac.padEnd(m, "0");
|
|
26
|
+
return w === d ? 0 : i * (w < d ? -1 : 1);
|
|
27
|
+
}
|
|
28
|
+
function y(t) {
|
|
29
|
+
const e = t.filter(g), n = e.reduce((s, l) => Math.max(s, a(l).frac.length), 0);
|
|
30
|
+
let c = 0n;
|
|
31
|
+
for (const s of e) {
|
|
32
|
+
const l = a(s), i = BigInt(l.whole + l.frac.padEnd(n, "0"));
|
|
33
|
+
c += l.neg ? -i : i;
|
|
34
|
+
}
|
|
35
|
+
const o = c < 0n, r = (o ? -c : c).toString().padStart(n + 1, "0"), f = r.slice(0, r.length - n), h = r.slice(r.length - n);
|
|
36
|
+
return (o ? "-" : "") + f + (n ? "." + h : "");
|
|
37
|
+
}
|
|
38
|
+
function E(t, e, n) {
|
|
39
|
+
return new Intl.NumberFormat(e, n).format(t);
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
D as compareDecimal,
|
|
43
|
+
E as formatDecimal,
|
|
44
|
+
g as isDecimalString,
|
|
45
|
+
x as isNegativeDecimal,
|
|
46
|
+
u as isZeroDecimal,
|
|
47
|
+
y as sumDecimal
|
|
48
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Where focus goes when a modal layer opens. `dialog` (default): the dialog itself, so a screen reader reads its title first. `first-field`: the first input, picker or date field in the body. Any CSS selector: the first match inside the layer. */
|
|
2
|
+
export type InitialFocus = 'dialog' | 'first-field' | (string & {});
|
|
3
|
+
/** Moves focus into a modal layer as it opens. Does nothing for the default, so the engine focuses the dialog as before. */
|
|
4
|
+
export declare function focusInitial(root: HTMLElement | null, mode?: InitialFocus): void;
|
|
5
|
+
/** A ref callback for the modal element: focuses the chosen control when the layer mounts, before the engine settles focus on the dialog (it leaves focus alone when something inside already has it). */
|
|
6
|
+
export declare function useInitialFocus(mode?: InitialFocus): (el: HTMLElement | null) => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback as i } from "react";
|
|
3
|
+
const n = 'input:not([type="hidden"]), textarea, select, [role="combobox"], [role="spinbutton"], .alea-select-trigger, [contenteditable="true"]';
|
|
4
|
+
function l(e) {
|
|
5
|
+
const t = e.querySelector(".alea-xmodal-body, .alea-dialog-body") ?? e;
|
|
6
|
+
for (const r of Array.from(t.querySelectorAll(n)))
|
|
7
|
+
if (!(r.matches(':disabled, [aria-disabled="true"], [tabindex="-1"]') || r.closest('[aria-hidden="true"], [hidden], [inert]')))
|
|
8
|
+
return r;
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
function o(e, t) {
|
|
12
|
+
if (!e || !t || t === "dialog") return;
|
|
13
|
+
const r = t === "first-field" ? l(e) : e.querySelector(t);
|
|
14
|
+
r == null || r.focus({ preventScroll: !0 });
|
|
15
|
+
}
|
|
16
|
+
function c(e) {
|
|
17
|
+
return i((t) => {
|
|
18
|
+
t && o(t, e);
|
|
19
|
+
}, [e]);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
o as focusInitial,
|
|
23
|
+
c as useInitialFocus
|
|
24
|
+
};
|
package/dist/utils/refs.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { type Ref } from 'react';
|
|
2
2
|
/** One ref callback that fills several refs (the forwarded one and the component's own). */
|
|
3
3
|
export declare function useMergedRef<T>(...refs: Array<Ref<T> | undefined>): (el: T | null) => void;
|
|
4
|
+
/** Marks an element aria-invalid from outside: the accessibility engine's Button drops that attribute (it only forwards the naming ones), so a picker trigger sets it on the DOM node. Returns the ref to put on the element. */
|
|
5
|
+
export declare function useAriaInvalid<T extends HTMLElement>(invalid: boolean, forwarded?: Ref<T>): (el: T | null) => void;
|
package/dist/utils/refs.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useCallback as
|
|
3
|
-
function
|
|
4
|
-
return
|
|
5
|
-
for (const e of
|
|
2
|
+
import { useCallback as u, useRef as i, useEffect as f } from "react";
|
|
3
|
+
function o(...t) {
|
|
4
|
+
return u((r) => {
|
|
5
|
+
for (const e of t)
|
|
6
6
|
typeof e == "function" ? e(r) : e && (e.current = r);
|
|
7
|
-
},
|
|
7
|
+
}, t);
|
|
8
|
+
}
|
|
9
|
+
function s(t, r) {
|
|
10
|
+
const e = i(null);
|
|
11
|
+
return f(() => {
|
|
12
|
+
const n = e.current;
|
|
13
|
+
n && (t ? n.setAttribute("aria-invalid", "true") : n.removeAttribute("aria-invalid"));
|
|
14
|
+
}, [t]), o(e, r);
|
|
8
15
|
}
|
|
9
16
|
export {
|
|
10
|
-
|
|
17
|
+
s as useAriaInvalid,
|
|
18
|
+
o as useMergedRef
|
|
11
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alea-design/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Alea: the complete React design system. Accessible components from forms to AI, charts and editors, Alea Motion, and W3C design tokens for dark, light and high contrast.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"react-dom": ">=18.3"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@alea-design/motion": "0.
|
|
65
|
-
"@alea-design/tokens": "0.
|
|
64
|
+
"@alea-design/motion": "0.6.0",
|
|
65
|
+
"@alea-design/tokens": "0.6.0",
|
|
66
66
|
"@internationalized/date": "^3.8.0",
|
|
67
67
|
"lucide-react": "^0.525.0",
|
|
68
68
|
"qrcode-generator": "^1.5.2",
|