@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.
Files changed (52) hide show
  1. package/dist/components/button/Button.d.ts +3 -1
  2. package/dist/components/button/Button.js +58 -57
  3. package/dist/components/button/Groups.js +41 -41
  4. package/dist/components/data/Data.d.ts +6 -4
  5. package/dist/components/data/Data.js +49 -49
  6. package/dist/components/date/Date.d.ts +3 -1
  7. package/dist/components/date/Date.js +74 -74
  8. package/dist/components/form/Form.d.ts +3 -1
  9. package/dist/components/form/Form.js +44 -52
  10. package/dist/components/form/validity.d.ts +22 -0
  11. package/dist/components/form/validity.js +38 -0
  12. package/dist/components/list/List.d.ts +3 -2
  13. package/dist/components/more/More.d.ts +3 -1
  14. package/dist/components/more/More.js +46 -46
  15. package/dist/components/navigation/Navigation.d.ts +4 -4
  16. package/dist/components/navigation/Navigation.js +94 -94
  17. package/dist/components/navigation/Navigation2.d.ts +3 -1
  18. package/dist/components/navigation/Navigation2.js +218 -210
  19. package/dist/components/page/PageParts.d.ts +6 -2
  20. package/dist/components/page/PageParts.js +85 -85
  21. package/dist/components/shell/AppShell.d.ts +3 -1
  22. package/dist/components/shell/AppShell.js +33 -32
  23. package/dist/components/table/Table.d.ts +8 -3
  24. package/dist/components/table/Table.js +58 -57
  25. package/dist/components/theme/Theme.d.ts +5 -1
  26. package/dist/components/theme/Theme.js +63 -63
  27. package/dist/css/base.css +1 -1
  28. package/dist/css/button.css +1 -1
  29. package/dist/css/data.css +1 -1
  30. package/dist/css/date.css +1 -1
  31. package/dist/css/display.css +1 -1
  32. package/dist/css/feedback.css +1 -1
  33. package/dist/css/groups.json +13 -13
  34. package/dist/css/more.css +1 -1
  35. package/dist/css/navigation.css +1 -1
  36. package/dist/css/page.css +1 -1
  37. package/dist/css/shell.css +1 -1
  38. package/dist/css/table.css +1 -1
  39. package/dist/css/tabs.css +1 -1
  40. package/dist/css/typography.css +1 -1
  41. package/dist/i18n/strings.d.ts +1 -0
  42. package/dist/i18n/strings.js +2 -0
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.js +279 -275
  45. package/dist/styles.css +1 -1
  46. package/dist/utils/animateRows.d.ts +3 -2
  47. package/dist/utils/animateRows.js +15 -15
  48. package/dist/utils/measure.d.ts +12 -0
  49. package/dist/utils/measure.js +20 -0
  50. package/dist/utils/scrollEdges.d.ts +1 -1
  51. package/dist/utils/scrollEdges.js +23 -22
  52. 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. With enabled false it returns the inputs untouched. */
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>, enabled: boolean | undefined): {
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 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);
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 j(a, {
14
- ...m ? { className: b(l.className, m) } : {},
15
- ...o.entering ? { style: h(l.style, { "--alea-i": Math.min(o.enterIndex, 11) }) } : {},
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: v
17
+ ref: j
18
18
  });
19
19
  }, dependencies: [g] };
20
20
  }
21
21
  export {
22
- B as useAnimatedRows
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 (found inside box by selector) has hidden content at its start and end, and a function to page it. */
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 f, useEffect as a } from "react";
3
- function p(n, l, c = !0) {
4
- const [d, o] = f({ start: !1, end: !1 });
5
- return a(() => {
6
- var i;
7
- const t = c ? (i = n.current) == null ? void 0 : i.querySelector(l) : null;
8
- if (!t) {
9
- o({ start: !1, end: !1 });
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 e = () => {
13
- const u = Math.abs(t.scrollLeft);
14
- o({ start: u > 2, end: u + t.clientWidth < t.scrollWidth - 2 });
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
- e(), t.addEventListener("scroll", e, { passive: !0 });
17
- const s = typeof ResizeObserver > "u" ? null : new ResizeObserver(e);
18
- s == null || s.observe(t);
19
- const r = typeof MutationObserver > "u" ? null : new MutationObserver(e);
20
- return r == null || r.observe(t, { childList: !0 }), () => {
21
- t.removeEventListener("scroll", e), s == null || s.disconnect(), r == null || r.disconnect();
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
- }, [n, l, c]), { edges: d, scroll: (t) => {
24
- var s;
25
- const e = (s = n.current) == null ? void 0 : s.querySelector(l);
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
- p as useScrollEdges
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.6.1",
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.6.1",
65
- "@alea-design/tokens": "0.6.1",
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",