@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,9 +1,10 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type RowMotion } from '@alea-design/motion';
|
|
2
3
|
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.
|
|
4
|
+
/** 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. `motion` is the value of animateRows. While nothing animates (false, or more rows than its max) it returns the inputs untouched. */
|
|
4
5
|
export declare function useAnimatedRows<T extends {
|
|
5
6
|
id?: string | number;
|
|
6
|
-
}>(items: Iterable<T> | undefined, children: Render<T>,
|
|
7
|
+
}>(items: Iterable<T> | undefined, children: Render<T>, motion: RowMotion | undefined): {
|
|
7
8
|
items: Iterable<T> | undefined;
|
|
8
9
|
children: Render<T>;
|
|
9
10
|
dependencies: unknown[] | undefined;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { usePresenceList as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
return !
|
|
8
|
-
const
|
|
9
|
-
if (!o || !
|
|
10
|
-
const
|
|
11
|
-
|
|
2
|
+
import { useMemo as p, isValidElement as M, cloneElement as b } from "react";
|
|
3
|
+
import { usePresenceList as h, resolveRowMotion as R } from "@alea-design/motion";
|
|
4
|
+
const k = (n, t) => typeof n == "function" ? (r) => [n(r), t].filter(Boolean).join(" ") : [n, t].filter(Boolean).join(" "), x = (n, t) => typeof n == "function" ? (r) => ({ ...n(r), ...t }) : { ...n, ...t };
|
|
5
|
+
function I(n, t, r) {
|
|
6
|
+
const i = p(() => n ? Array.from(n) : void 0, [n]), { entries: s, ref: m } = h(i, (e) => e.id, r), y = p(() => s.map((e) => e.item), [s]), g = s.map((e) => `${e.key}:${e.leaving ? "l" : e.entering ? "e" : ""}`).join("|"), d = p(() => new Map(s.map((e) => [e.item, e])), [s]), { enter: v, leave: w } = R(r, (i == null ? void 0 : i.length) ?? 0);
|
|
7
|
+
return !v && !w || !i || typeof t != "function" ? { items: n, children: t, dependencies: void 0 } : { items: y, children: (e) => {
|
|
8
|
+
const l = t(e), o = d.get(e);
|
|
9
|
+
if (!o || !M(l)) return l;
|
|
10
|
+
const c = l.props, u = o.leaving ? "alea-row-leave" : o.entering ? "alea-row-enter" : "", a = c.ref, j = (f) => {
|
|
11
|
+
m(o.key)(f), typeof a == "function" ? a(f) : a && typeof a == "object" && (a.current = f);
|
|
12
12
|
};
|
|
13
|
-
return
|
|
14
|
-
...
|
|
15
|
-
...o.entering ? { style:
|
|
13
|
+
return b(l, {
|
|
14
|
+
...u ? { className: k(c.className, u) } : {},
|
|
15
|
+
...o.entering ? { style: x(c.style, { "--alea-i": Math.min(o.enterIndex, 11) }) } : {},
|
|
16
16
|
...o.leaving ? { isDisabled: !0, "data-leaving": !0 } : {},
|
|
17
|
-
ref:
|
|
17
|
+
ref: j
|
|
18
18
|
});
|
|
19
19
|
}, dependencies: [g] };
|
|
20
20
|
}
|
|
21
21
|
export {
|
|
22
|
-
|
|
22
|
+
I as useAnimatedRows
|
|
23
23
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useEffect, type DependencyList, type RefObject } from 'react';
|
|
2
|
+
/** useLayoutEffect on the client, useEffect on the server (no warning there). */
|
|
3
|
+
export declare const useIsoLayoutEffect: typeof useEffect;
|
|
4
|
+
/**
|
|
5
|
+
* Asks the DOM a question about an element and keeps the answer up to date: once before the first paint (so the
|
|
6
|
+
* first thing people see is already the right layout) and again whenever the element changes size, which includes
|
|
7
|
+
* a change of text size or zoom for anything that is sized in rem. `initial` is what the server and the first
|
|
8
|
+
* render use; `deps` re-run the question when content that is not a size change changes (a longer label).
|
|
9
|
+
*/
|
|
10
|
+
export declare function useMeasured<T extends string | number | boolean>(ref: RefObject<HTMLElement | null>, measure: (el: HTMLElement) => T, initial: T, deps?: DependencyList): T;
|
|
11
|
+
/** One rem in px: the root font size, which is what rem container queries and media queries follow. */
|
|
12
|
+
export declare const remPx: () => number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState as d, useRef as a, useLayoutEffect as l, useEffect as m } from "react";
|
|
3
|
+
const p = typeof document < "u" ? l : m;
|
|
4
|
+
function v(o, t, s, c = []) {
|
|
5
|
+
const [f, i] = d(s), n = a(t);
|
|
6
|
+
return n.current = t, p(() => {
|
|
7
|
+
const e = o.current;
|
|
8
|
+
if (!e) return;
|
|
9
|
+
const r = () => i(n.current(e));
|
|
10
|
+
if (r(), typeof ResizeObserver > "u") return;
|
|
11
|
+
const u = new ResizeObserver(r);
|
|
12
|
+
return u.observe(e), () => u.disconnect();
|
|
13
|
+
}, c), f;
|
|
14
|
+
}
|
|
15
|
+
const E = () => parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
|
|
16
|
+
export {
|
|
17
|
+
E as remPx,
|
|
18
|
+
p as useIsoLayoutEffect,
|
|
19
|
+
v as useMeasured
|
|
20
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RefObject } from 'react';
|
|
2
|
-
/** Whether a horizontal scroller
|
|
2
|
+
/** Whether a horizontal scroller has hidden content at its start and end, and a function to page it. The scroller is found inside box by selector, or is box itself when the selector is empty. */
|
|
3
3
|
export declare function useScrollEdges(box: RefObject<HTMLElement | null>, selector: string, enabled?: boolean): {
|
|
4
4
|
edges: {
|
|
5
5
|
start: boolean;
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState as
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { useState as h, useEffect as E } from "react";
|
|
3
|
+
function y(r, l, c = !0) {
|
|
4
|
+
const o = () => {
|
|
5
|
+
var e;
|
|
6
|
+
return (l ? (e = r.current) == null ? void 0 : e.querySelector(l) : r.current) ?? null;
|
|
7
|
+
}, [v, d] = h({ start: !1, end: !1 });
|
|
8
|
+
return E(() => {
|
|
9
|
+
const e = c ? o() : null;
|
|
10
|
+
if (!e) {
|
|
11
|
+
d({ start: !1, end: !1 });
|
|
10
12
|
return;
|
|
11
13
|
}
|
|
12
|
-
const
|
|
13
|
-
const u = Math.abs(
|
|
14
|
-
|
|
14
|
+
const t = () => {
|
|
15
|
+
const u = Math.abs(e.scrollLeft), f = u > 2, a = u + e.clientWidth < e.scrollWidth - 2;
|
|
16
|
+
d((i) => i.start === f && i.end === a ? i : { start: f, end: a });
|
|
15
17
|
};
|
|
16
|
-
|
|
17
|
-
const s = typeof ResizeObserver > "u" ? null : new ResizeObserver(
|
|
18
|
-
s == null || s.observe(
|
|
19
|
-
const
|
|
20
|
-
return
|
|
21
|
-
|
|
18
|
+
t(), e.addEventListener("scroll", t, { passive: !0 });
|
|
19
|
+
const s = typeof ResizeObserver > "u" ? null : new ResizeObserver(t);
|
|
20
|
+
s == null || s.observe(e), e.firstElementChild && (s == null || s.observe(e.firstElementChild));
|
|
21
|
+
const n = typeof MutationObserver > "u" ? null : new MutationObserver(t);
|
|
22
|
+
return n == null || n.observe(e, { childList: !0 }), () => {
|
|
23
|
+
e.removeEventListener("scroll", t), s == null || s.disconnect(), n == null || n.disconnect();
|
|
22
24
|
};
|
|
23
|
-
}, [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
e == null || e.scrollBy({ left: t * (getComputedStyle(e).direction === "rtl" ? -1 : 1) * e.clientWidth * 0.8, behavior: "smooth" });
|
|
25
|
+
}, [r, l, c]), { edges: v, scroll: (e) => {
|
|
26
|
+
const t = o();
|
|
27
|
+
t == null || t.scrollBy({ left: e * (getComputedStyle(t).direction === "rtl" ? -1 : 1) * t.clientWidth * 0.8, behavior: "smooth" });
|
|
27
28
|
} };
|
|
28
29
|
}
|
|
29
30
|
export {
|
|
30
|
-
|
|
31
|
+
y as useScrollEdges
|
|
31
32
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alea-design/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
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.7.1",
|
|
65
|
+
"@alea-design/tokens": "0.7.1",
|
|
66
66
|
"@internationalized/date": "^3.8.0",
|
|
67
67
|
"lucide-react": "^0.525.0",
|
|
68
68
|
"qrcode-generator": "^1.5.2",
|