@slashsuite/ui-react 0.17.0 → 0.17.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.
@@ -10,9 +10,11 @@ A row of media that runs past the page is a `ScrollStrip`: one line, a themed sc
10
10
  import { MediaTile, ScrollStrip } from "@slashsuite/ui-react";
11
11
 
12
12
  <ScrollStrip label="Recent statuses">
13
- {[...sampleScenes, ...sampleScenes].map((scene, index) => (
14
- <MediaTile key={index} src={scene.src} alt={scene.alt} label="Anna" />
15
- ))}
13
+ {[1, 2].flatMap((round) =>
14
+ sampleScenes.map((scene) => (
15
+ <MediaTile key={`${round} ${scene.alt}`} src={scene.src} alt={scene.alt} label="Anna" />
16
+ )),
17
+ )}
16
18
  </ScrollStrip>
17
19
  ```
18
20
 
@@ -29,9 +31,11 @@ A `Cluster` wraps the tiles onto several lines, so the row takes over the page i
29
31
  import { Cluster, MediaTile } from "@slashsuite/ui-react";
30
32
 
31
33
  <Cluster>
32
- {[...sampleScenes, ...sampleScenes].map((scene, index) => (
33
- <MediaTile key={index} src={scene.src} alt={scene.alt} label="Anna" />
34
- ))}
34
+ {[1, 2].flatMap((round) =>
35
+ sampleScenes.map((scene) => (
36
+ <MediaTile key={`${round} ${scene.alt}`} src={scene.src} alt={scene.alt} label="Anna" />
37
+ )),
38
+ )}
35
39
  </Cluster>
36
40
  ```
37
41
 
@@ -30,7 +30,10 @@ export function AvatarStack({ items, max, size = "md", shape = "round", loading,
30
30
  const overlap = OVERLAP[size];
31
31
  const names = shown.map((person) => person.name);
32
32
  const label = hidden.length > 0 ? `${names.join(", ")} and ${hidden.length} more` : names.join(", ");
33
- return (_jsxs("span", { role: "img", "aria-label": label, className: "inline-flex items-center", ...rest, children: [shown.map((person, index) => (_jsx(AvatarMark, { name: person.name, src: person.src, size: size, shape: shape, ring: cx(RING, index > 0 && overlap) }, `${index}:${person.name}`))), hidden.length > 0 && (_jsxs("span", { "aria-hidden": "true", title: hidden.map((person) => person.name).join(", "), className: cx("inline-grid shrink-0 place-items-center bg-slate-100 font-semibold text-slate-700 tabular-nums", RING,
33
+ return (_jsxs("span", { role: "img", "aria-label": label, className: "inline-flex items-center", ...rest, children: [shown
34
+ // Two people can share a name and have no picture, so the place in the row keys each.
35
+ .map((person, place) => ({ person, place }))
36
+ .map(({ person, place }) => (_jsx(AvatarMark, { name: person.name, src: person.src, size: size, shape: shape, ring: cx(RING, place > 0 && overlap) }, `${place}:${person.name}`))), hidden.length > 0 && (_jsxs("span", { "aria-hidden": "true", title: hidden.map((person) => person.name).join(", "), className: cx("inline-grid shrink-0 place-items-center bg-slate-100 font-semibold text-slate-700 tabular-nums", RING,
34
37
  // At 16px "+N" at 14px does not fit a square, so the xs chip widens to its count.
35
38
  size === "xs" ? "h-4 min-w-4 px-1 text-sm/4" : avatarSizeClass(size), avatarShapeClass(shape, size), shown.length > 0 && overlap), children: ["+", hidden.length] }))] }));
36
39
  }
@@ -3,7 +3,7 @@ import type { Passthrough } from "./props.js";
3
3
  import { type BottomSheetSnap } from "./sheetSnap.js";
4
4
  export type { BottomSheetSnap } from "./sheetSnap.js";
5
5
  /** The widths from which a sheet is plain content in the page: Tailwind's `md` (768px) and `lg` (1024px). */
6
- export type InlineFrom = "md" | "lg";
6
+ type InlineFrom = "md" | "lg";
7
7
  export type BottomSheetProps = {
8
8
  /** The sheet's accessible name, as a region, and its handle button's. */
9
9
  label: string;
@@ -1,7 +1,5 @@
1
1
  import { type ReactElement, type ReactNode } from "react";
2
2
  import type { Passthrough } from "./props.js";
3
- /** The classes of a crumb that links somewhere, for a router's own <Link>. */
4
- export declare const crumbLinkClass: string;
5
3
  /**
6
4
  * A crumb that links: `href`, drawn by the app's router link through `LinkProvider` for an in-app
7
5
  * path, else a plain `<a>`. `external` opens in a new tab. The last crumb is the current page: given
@@ -4,7 +4,7 @@ import { cx, focusRing } from "./cx.js";
4
4
  import { renderLink } from "./link.js";
5
5
  import { Truncated } from "./truncated.js";
6
6
  /** The classes of a crumb that links somewhere, for a router's own <Link>. */
7
- export const crumbLinkClass = cx("rounded hover:underline", focusRing);
7
+ const crumbLinkClass = cx("rounded hover:underline", focusRing);
8
8
  function isCrumb(crumb) {
9
9
  return typeof crumb === "object" && crumb !== null && !isValidElement(crumb) && "label" in crumb;
10
10
  }
@@ -32,8 +32,11 @@ function CrumbContent({ crumb, current, }) {
32
32
  */
33
33
  export function Breadcrumbs({ items, label = "Breadcrumb", ...rest }) {
34
34
  const last = items.length - 1;
35
- return (_jsx("nav", { ...rest, "aria-label": label, className: "min-w-0", children: _jsx("ol", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-sm", children: items.map((crumb, index) => {
36
- const current = index === last;
37
- return (_jsxs("li", { "aria-current": current && !isCrumb(crumb) ? "page" : undefined, className: "flex min-w-0 items-center gap-2", children: [index > 0 && (_jsx("span", { "aria-hidden": "true", className: "text-slate-400", children: "/" })), current ? (_jsx("span", { className: "min-w-0 font-medium [overflow-wrap:anywhere] text-slate-900", children: _jsx(CrumbContent, { crumb: crumb, current: current }) })) : (_jsx(Truncated, { text: crumbText(crumb), className: "max-w-48 min-w-0 text-slate-500", children: _jsx(CrumbContent, { crumb: crumb, current: current }) }))] }, index));
35
+ return (_jsx("nav", { ...rest, "aria-label": label, className: "min-w-0", children: _jsx("ol", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-sm", children: items
36
+ // A plain crumb is any node, with no id and free to repeat, so its depth keys it.
37
+ .map((crumb, depth) => ({ crumb, depth }))
38
+ .map(({ crumb, depth }) => {
39
+ const current = depth === last;
40
+ return (_jsxs("li", { "aria-current": current && !isCrumb(crumb) ? "page" : undefined, className: "flex min-w-0 items-center gap-2", children: [current ? (_jsx("span", { className: "min-w-0 font-medium [overflow-wrap:anywhere] text-slate-900", children: _jsx(CrumbContent, { crumb: crumb, current: current }) })) : (_jsx(Truncated, { text: crumbText(crumb), className: "max-w-48 min-w-0 text-slate-500", children: _jsx(CrumbContent, { crumb: crumb, current: current }) })), depth < last && (_jsx("span", { "aria-hidden": "true", className: "text-slate-400", children: "/" }))] }, isCrumb(crumb) ? crumb.href : depth));
38
41
  }) }) }));
39
42
  }
@@ -37,6 +37,8 @@ function subscribe(onChange) {
37
37
  // False in the server markup and while the client hydrates, true after: `title` is the one thing CSS
38
38
  // cannot choose, so it is rendered only once the client knows the scheme.
39
39
  const never = () => () => { };
40
+ /** The classes the schemes put on `<html>` when the app names none. */
41
+ const DEFAULT_SCHEMES = { light: "", dark: "dark" };
40
42
  /**
41
43
  * A sun/moon button that switches `<html>` between light and dark and remembers the choice. It shows the scheme you would switch to.
42
44
  * A click that lands on the system's own scheme forgets the stored choice, so the page follows the system again; a click away from it stores the choice.
@@ -53,7 +55,7 @@ const never = () => () => { };
53
55
  * `store={false}` skips `localStorage`, for an app that keeps the choice in a server cookie and
54
56
  * writes it from `onChange`. Every other button prop (`id`, `data-*`, `aria-*`) goes on the button.
55
57
  */
56
- export function ColourSchemeToggle({ onChange, schemes = { light: "", dark: "dark" }, defaultValue, store = true, size = "md", darkLabel = "Switch to dark theme", lightLabel = "Switch to light theme", ...rest }) {
58
+ export function ColourSchemeToggle({ onChange, schemes = DEFAULT_SCHEMES, defaultValue, store = true, size = "md", darkLabel = "Switch to dark theme", lightLabel = "Switch to light theme", ...rest }) {
57
59
  const scheme = useSyncExternalStore(subscribe, () => appliedColourScheme(document.documentElement, schemes), () => defaultValue ?? "light");
58
60
  const hydrated = useSyncExternalStore(never, () => true, () => false);
59
61
  const { light, dark } = schemes;
@@ -1,5 +1,5 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback, useContext, useState } from "react";
2
+ import { useCallback, useContext, useMemo, useState, } from "react";
3
3
  import { Button, DatePicker as AriaDatePicker, DateFieldContext, DateInput, Group, } from "react-aria-components";
4
4
  import { cx } from "./cx.js";
5
5
  import { CalendarPopover, calendarIcon } from "./DateCalendar.js";
@@ -48,7 +48,8 @@ export function usePickerFrame(size) {
48
48
  */
49
49
  function PickerInput({ leaving, onLeft, children, }) {
50
50
  const field = useContext(DateFieldContext);
51
- return (_jsx(DateFieldContext.Provider, { value: { ...field, isReadOnly: leaving, onBlur: onLeft }, children: children }));
51
+ const value = useMemo(() => ({ ...field, isReadOnly: leaving, onBlur: onLeft }), [field, leaving, onLeft]);
52
+ return _jsx(DateFieldContext.Provider, { value: value, children: children });
52
53
  }
53
54
  /**
54
55
  * The modal `<dialog>` a picker sits in, if any, for its popover's `container`: pass `findDialog` as the
@@ -1,5 +1,5 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useContext } from "react";
2
+ import { useContext, useMemo } from "react";
3
3
  import { Button, DateFieldContext, DateInput, DateRangePicker as AriaDateRangePicker, Group, } from "react-aria-components";
4
4
  import { cx } from "./cx.js";
5
5
  import { RangeCalendarPopover, calendarIcon } from "./DateCalendar.js";
@@ -16,13 +16,13 @@ import { ShownInput, useShownRange } from "./shownDate.js";
16
16
  function SideInput({ slot, name, side, onRead, }) {
17
17
  const field = useContext(DateFieldContext);
18
18
  const slots = field && "slots" in field ? field.slots : undefined;
19
- const own = slots?.[slot] ?? {};
20
- return (_jsx("div", { role: "group", "aria-label": name, className: "flex items-center", onBlurCapture: side.onBlurCapture, children: _jsx(DateFieldContext.Provider, { value: {
21
- slots: {
22
- ...slots,
23
- [slot]: { ...own, isReadOnly: side.leaving, onBlur: side.onLeft },
24
- },
25
- }, children: _jsx(DateInput, { slot: slot, className: "flex", children: (segment) => (_jsx(FieldSegment, { segment: segment, ...(segment.type === "day" ? { onRead } : {}) })) }) }) }));
19
+ const value = useMemo(() => ({
20
+ slots: {
21
+ ...slots,
22
+ [slot]: { ...slots?.[slot], isReadOnly: side.leaving, onBlur: side.onLeft },
23
+ },
24
+ }), [slots, slot, side.leaving, side.onLeft]);
25
+ return (_jsx("div", { role: "group", "aria-label": name, className: "flex items-center", onBlurCapture: side.onBlurCapture, children: _jsx(DateFieldContext.Provider, { value: value, children: _jsx(DateInput, { slot: slot, className: "flex", children: (segment) => (_jsx(FieldSegment, { segment: segment, ...(segment.type === "day" ? { onRead } : {}) })) }) }) }));
26
26
  }
27
27
  /**
28
28
  * A from and to date in one field, each side in the locale's order, and a calendar button that opens one
@@ -11,6 +11,8 @@ import { ContentsList } from "./TableOfContents.js";
11
11
  import { STICKY_ASIDE_XL, STICKY_FADE_XL, STICKY_SCROLL_XL } from "./stickyColumn.js";
12
12
  import { Tabs } from "./Tabs.js";
13
13
  import { Overline } from "./typography.js";
14
+ /** No headings: no "On this page" list. */
15
+ const NO_CONTENTS = [];
14
16
  /** The rail: each group's title over a vertical list of its pages, the groups `md` apart. */
15
17
  function DocsNav({ nav, label }) {
16
18
  return (_jsx(Stack, { gap: "md", children: nav.map((group, index) => (_jsxs(Stack, { gap: "xs", children: [group.title !== undefined && _jsx(Overline, { children: group.title }), _jsx(Tabs, { orientation: "vertical", size: "sm", label: group.title ?? label, items: group.items })] }, group.title ?? `group-${index}`))) }));
@@ -58,7 +60,7 @@ function DocsPager({ previous, next, previousLabel, nextLabel, }) {
58
60
  * article holds draws its own bones; the nav, the contents list and the previous and next links are
59
61
  * navigation, drawn as themselves. The layout owns the wait.
60
62
  */
61
- export function DocsLayout({ nav, asideLabel, title, description, breadcrumbs, contents = [], current, contentsLabel = "On this page", previous, next, previousLabel = "Previous", nextLabel = "Next", children, ...rest }) {
63
+ export function DocsLayout({ nav, asideLabel, title, description, breadcrumbs, contents = NO_CONTENTS, current, contentsLabel = "On this page", previous, next, previousLabel = "Previous", nextLabel = "Next", children, ...rest }) {
62
64
  const listed = contents.length >= 2;
63
65
  return (_jsx(SidebarLayout, { ...rest, asideLabel: asideLabel, aside: _jsx(DocsNav, { nav: nav, label: asideLabel }), children: _jsxs("div", { className: cx("flex flex-col gap-12 sm:gap-16",
64
66
  // The contents column only when there is a list, so a page without one keeps the width.
package/dist/Hero.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import type { ReactElement, ReactNode } from "react";
2
2
  import type { Passthrough } from "./props.js";
3
- /** The one keyframes name the glow drifts on; a consumer's own CSS never needs it. */
4
- export declare const HERO_DRIFT = "hc-hero-tide";
5
3
  export type HeroProps = {
6
4
  /** The small label above the title, set in the monospace face. */
7
5
  overline?: ReactNode;
package/dist/Hero.js CHANGED
@@ -3,7 +3,7 @@ import { cx } from "./cx.js";
3
3
  import { Icon } from "./Icon.js";
4
4
  import { Display, Overline } from "./typography.js";
5
5
  /** The one keyframes name the glow drifts on; a consumer's own CSS never needs it. */
6
- export const HERO_DRIFT = "hc-hero-tide";
6
+ const HERO_DRIFT = "hc-hero-tide";
7
7
  // What Tailwind classes cannot say: the soft fade at the layer's four edges (two masks, intersected,
8
8
  // so no ribbon ends in a hard line where the layer clips it) and the drift. The drift is a slow
9
9
  // sideways sway and stretch, like light on water, each ribbon on its own period so the three never
package/dist/Markdown.js CHANGED
@@ -15,20 +15,29 @@ const SAFE_SRC = /^(https?:|\/|\.\/|\.\.\/|data:image\/)/i;
15
15
  const INLINE = /(\*\*[^*]+\*\*|!?\[[^\]]*\]\([^)\s]*\))/g;
16
16
  const LINK = /^\[([^\]]*)\]\(([^)\s]*)\)$/;
17
17
  const IMAGE = /^!\[([^\]]*)\]\(([^)\s]*)\)$/;
18
+ /** A line's parts, split at each inline mark, each with where it starts in the line: its key. */
19
+ function parts(text) {
20
+ let at = 0;
21
+ return text.split(INLINE).map((p) => {
22
+ const part = { at, p };
23
+ at += p.length;
24
+ return part;
25
+ });
26
+ }
18
27
  /** A line's inline parts; plain words stay plain text, so a table cell of them reads as prose and wraps. */
19
28
  function inline(text) {
20
- return text.split(INLINE).flatMap((p, i) => {
29
+ return parts(text).flatMap(({ at, p }) => {
21
30
  if (p === "")
22
31
  return [];
23
32
  if (p.startsWith("**") && p.endsWith("**") && p.length > 4) {
24
- return (_jsx("strong", { className: "font-semibold text-slate-900", children: p.slice(2, -2) }, i));
33
+ return (_jsx("strong", { className: "font-semibold text-slate-900", children: p.slice(2, -2) }, at));
25
34
  }
26
35
  const link = LINK.exec(p);
27
36
  if (link) {
28
37
  const [, words = "", href = ""] = link;
29
38
  if (!SAFE_HREF.test(href))
30
39
  return words;
31
- return (_jsx(TextLink, { href: href, underline: true, children: words }, i));
40
+ return (_jsx(TextLink, { href: href, underline: true, children: words }, at));
32
41
  }
33
42
  return p;
34
43
  });
@@ -58,9 +67,11 @@ function alignOf(rule) {
58
67
  /** A GFM table: its head row, its rule and its body rows, named by the heading above it. */
59
68
  function table(lines, label, key) {
60
69
  const [head = "", rule = "", ...body] = lines;
61
- const titles = cells(head);
62
70
  const align = cells(rule).map(alignOf);
63
- return (_jsxs(Table, { label: label, children: [_jsx(TableHead, { children: _jsx(TableRow, { children: titles.map((title, i) => (_jsx(TableHeaderCell, { align: align[i], children: inline(title) }, i))) }) }), _jsx(TableBody, { children: body.map((row, r) => (_jsx(TableRow, { children: titles.map((_, i) => (_jsx(TableCell, { align: align[i], children: inline(cells(row)[i] ?? "") }, i))) }, r))) })] }, key));
71
+ // Each column and each body row with its number, which keys it: two can read the same.
72
+ const columns = cells(head).map((title, column) => ({ title, column, align: align[column] }));
73
+ const rows = body.map((row, n) => ({ n, cells: cells(row) }));
74
+ return (_jsxs(Table, { label: label, children: [_jsx(TableHead, { children: _jsx(TableRow, { children: columns.map((c) => (_jsx(TableHeaderCell, { align: c.align, children: inline(c.title) }, c.column))) }) }), _jsx(TableBody, { children: rows.map((row) => (_jsx(TableRow, { children: columns.map((c) => (_jsx(TableCell, { align: c.align, children: inline(row.cells[c.column] ?? "") }, c.column))) }, row.n))) })] }, key));
64
75
  }
65
76
  /** A list item's line, bulleted or numbered, or nothing. */
66
77
  function itemOf(t) {
@@ -111,7 +122,7 @@ function parse(md) {
111
122
  }
112
123
  /** A run of list items of one kind, as a `ul` or an `ol` that counts from the first item's number. */
113
124
  function list(items, kind, key) {
114
- const lis = items.map((it, i) => (_jsx("li", { className: "text-sm text-slate-700", children: inline(it.text) }, i)));
125
+ const lis = items.map((it) => (_jsx("li", { className: "text-sm text-slate-700", children: inline(it.text) }, it.id)));
115
126
  if (kind === "ul") {
116
127
  return (_jsx("ul", { className: "ml-4 list-disc space-y-1", children: lis }, key));
117
128
  }
@@ -139,8 +150,9 @@ function single(block, key, h, label) {
139
150
  function run(all, from, kind) {
140
151
  const items = [];
141
152
  let i = from;
142
- for (let b = all[i]; b?.kind === kind; b = all[++i])
143
- items.push(b);
153
+ for (let b = all[i]; b?.kind === kind; b = all[++i]) {
154
+ items.push({ id: i, start: b.start, text: b.text });
155
+ }
144
156
  return [items, i];
145
157
  }
146
158
  /** The blocks of `md` drawn: its `## ` headings at `top`, its `### ` at `sub`. */
package/dist/Menu.js CHANGED
@@ -60,7 +60,7 @@ export function Menu({ label, items, trigger = "icon", size = "md", defaultOpen
60
60
  }, ...(icon ? { "aria-label": label } : {}), className: icon ? look({ variant: "ghost", size }) : buttonClass("outline", { size }), children: _jsx(Face, { icon: icon, label: label, size: size }) }));
61
61
  // The three-dot trigger shows its name as the library's tooltip, as an `IconButton` does. React
62
62
  // Aria's button takes no pointer handlers, so they sit on a wrapper; focus and keys bubble to it.
63
- return (_jsxs(MenuTrigger, { defaultOpen: defaultOpen, ...definedProps({ isOpen: open, onOpenChange }), children: [icon ? (_jsx(Tipped, { text: label, describes: false, own: {}, children: (tip) => (_jsx("span", { className: "inline-flex", ...tip, children: button })) })) : (button), _jsx(Popover, { ...(container ? { UNSTABLE_portalContainer: container } : {}), placement: "bottom end", className: FRAME, children: _jsx(AriaMenu, { className: "outline-none", ...(pointer ? { autoFocus: "first" } : {}), children: items.map((item, index) => (_jsx(Item, { item: item }, `${index}:${item.label}`))) }) })] }));
63
+ return (_jsxs(MenuTrigger, { defaultOpen: defaultOpen, ...definedProps({ isOpen: open, onOpenChange }), children: [icon ? (_jsx(Tipped, { text: label, describes: false, own: {}, children: (tip) => (_jsx("span", { className: "inline-flex", ...tip, children: button })) })) : (button), _jsx(Popover, { ...(container ? { UNSTABLE_portalContainer: container } : {}), placement: "bottom end", className: FRAME, children: _jsx(AriaMenu, { className: "outline-none", ...(pointer ? { autoFocus: "first" } : {}), children: items.map((item) => (_jsx(Item, { item: item }, item.label))) }) })] }));
64
64
  }
65
65
  function Item({ item }) {
66
66
  const tone = ITEM_TONE[item.tone ?? "neutral"];
package/dist/MetaList.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Children } from "react";
2
+ import { Children, isValidElement } from "react";
3
3
  import { cx } from "./cx.js";
4
4
  import { Bone, BusyLabel, busy, isEmptySlot, LoadingScope, useLoading, } from "./skeleton.js";
5
5
  import { Caption } from "./typography.js";
@@ -24,5 +24,8 @@ export function MetaList({ mono = false, separator = "·", loading: ownLoading,
24
24
  : Children.toArray(children);
25
25
  const slot = SLOT[separator === "none" ? "none" : "mark"];
26
26
  // The box clips sideways only, with a little room at the start for a link's focus ring.
27
- return (_jsx("div", { className: "-ms-1 overflow-x-clip ps-1", children: _jsxs("ul", { ...rest, ...busy(owner, loading), className: cx("flex flex-wrap items-center gap-y-1 text-sm text-slate-500", slot.list, mono && "font-mono"), children: [items.map((child, index) => (_jsxs("li", { className: "inline-flex items-center whitespace-nowrap", children: [_jsx("span", { "aria-hidden": "true", className: cx("inline-block text-center", slot.slot), children: separator !== "none" && _jsx(Caption, { as: "span", children: separator }) }), _jsx(LoadingScope, { loading: loading, children: child })] }, index))), owner && loading && (_jsx("li", { className: "sr-only", children: _jsx(BusyLabel, { owner: owner, loading: loading, label: loadingLabel }) }))] }) }));
27
+ return (_jsx("div", { className: "-ms-1 overflow-x-clip ps-1", children: _jsxs("ul", { ...rest, ...busy(owner, loading), className: cx("flex flex-wrap items-center gap-y-1 text-sm text-slate-500", slot.list, mono && "font-mono"), children: [items
28
+ // Children.toArray keys each element; bare text has no key and can repeat, so its place keys it.
29
+ .map((child, place) => ({ child, place }))
30
+ .map(({ child, place }) => (_jsxs("li", { className: "inline-flex items-center whitespace-nowrap", children: [_jsx("span", { "aria-hidden": "true", className: cx("inline-block text-center", slot.slot), children: separator !== "none" && _jsx(Caption, { as: "span", children: separator }) }), _jsx(LoadingScope, { loading: loading, children: child })] }, isValidElement(child) ? child.key : place))), owner && loading && (_jsx("li", { className: "sr-only", children: _jsx(BusyLabel, { owner: owner, loading: loading, label: loadingLabel }) }))] }) }));
28
31
  }
@@ -47,13 +47,6 @@ export type NumberFieldProps = {
47
47
  */
48
48
  incrementLabel?: string | undefined;
49
49
  } & ControlProps & LoadingProps & Passthrough;
50
- /** The stepper's size tables and their `md:` twins, for the data test. */
51
- export declare const numberSizeTables: {
52
- box: Record<import("./size.js").Size, string>;
53
- boxMd: Record<import("./size.js").Size, string>;
54
- icon: Record<import("./size.js").Size, string>;
55
- iconMd: Record<import("./size.js").Size, string>;
56
- };
57
50
  /**
58
51
  * A number with a minus and a plus button either side of it, for a quantity, a count or an amount:
59
52
  * React Aria's `NumberField`. The person types the number or steps it by `step` with the buttons,
@@ -28,13 +28,6 @@ const STEP_ICON_MD = {
28
28
  md: "md:[&>svg]:size-4",
29
29
  lg: "md:[&>svg]:size-5",
30
30
  };
31
- /** The stepper's size tables and their `md:` twins, for the data test. */
32
- export const numberSizeTables = {
33
- box: STEP_BOX,
34
- boxMd: STEP_BOX_MD,
35
- icon: STEP_ICON,
36
- iconMd: STEP_ICON_MD,
37
- };
38
31
  const STEP_LOOK = "flex shrink-0 cursor-pointer items-center justify-center self-stretch text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50";
39
32
  /** A minus or plus button. React Aria keeps it out of the tab order: the arrow keys step the number. */
40
33
  function StepButton({ slot, label, size, }) {
@@ -4,9 +4,9 @@ import type { Passthrough } from "./props.js";
4
4
  * The slots of the number row: always the first and the last page, the current page and its two
5
5
  * neighbours, and a gap for a run of two or more hidden pages. A gap never hides a single page,
6
6
  * and the row never holds more than seven slots. Page 1 of 20 is `1 2 3 4 5 … 20`, page 10 is
7
- * `1 … 9 10 11 … 20`.
7
+ * `1 … 9 10 11 … 20`. A gap is named for its side of the current page, which keys it.
8
8
  */
9
- export declare function pageWindow(page: number, pageCount: number): Array<number | "gap">;
9
+ export declare function pageWindow(page: number, pageCount: number): Array<number | "gap-start" | "gap-end">;
10
10
  /**
11
11
  * Page links for a long list: Previous, the page numbers and Next, in a `<nav>` named by `label`.
12
12
  * Each is a link to `pageHref(page)`, drawn by the app's router link through `LinkProvider`, so the
@@ -4,6 +4,8 @@ import { cx } from "./cx.js";
4
4
  import { useTypeStep } from "./density.js";
5
5
  import { renderLink } from "./link.js";
6
6
  import { pillTabClass } from "./Tabs.js";
7
+ /** "Page 2 of 4": the summary below `sm` when the app names none. */
8
+ const pageOf = (at, count) => `Page ${at} of ${count}`;
7
9
  /** The most slots the number row holds, so it keeps one width as the page moves. */
8
10
  const SLOTS = 7;
9
11
  /** `page` moved into `1` to `pageCount`, so a stale `?page=9` of 4 draws page 4. */
@@ -18,17 +20,17 @@ function range(from, to) {
18
20
  * The slots of the number row: always the first and the last page, the current page and its two
19
21
  * neighbours, and a gap for a run of two or more hidden pages. A gap never hides a single page,
20
22
  * and the row never holds more than seven slots. Page 1 of 20 is `1 2 3 4 5 … 20`, page 10 is
21
- * `1 … 9 10 11 … 20`.
23
+ * `1 … 9 10 11 … 20`. A gap is named for its side of the current page, which keys it.
22
24
  */
23
25
  export function pageWindow(page, pageCount) {
24
26
  if (pageCount <= SLOTS)
25
27
  return range(1, pageCount);
26
28
  const at = clamp(page, pageCount);
27
29
  if (at <= 4)
28
- return [...range(1, 5), "gap", pageCount];
30
+ return [...range(1, 5), "gap-end", pageCount];
29
31
  if (at >= pageCount - 3)
30
- return [1, "gap", ...range(pageCount - 4, pageCount)];
31
- return [1, "gap", at - 1, at, at + 1, "gap", pageCount];
32
+ return [1, "gap-start", ...range(pageCount - 4, pageCount)];
33
+ return [1, "gap-start", at - 1, at, at + 1, "gap-end", pageCount];
32
34
  }
33
35
  /** Previous or Next: a link in the outline look, or the same box as plain text at the edge. */
34
36
  function Edge({ to, pageCount, pageHref, rel, step, children, }) {
@@ -50,13 +52,13 @@ function Edge({ to, pageCount, pageHref, rel, step, children, }) {
50
52
  * with `aria-current="page"`. Below `sm` the numbers give way to `pageLabel` ("Page 2 of 4").
51
53
  * Renders nothing for one page. The count line ("21 to 40 of 312") is the caller's `Caption`.
52
54
  */
53
- export function Pagination({ label, page, pageCount, pageHref, previousLabel = "Previous", nextLabel = "Next", pageLabel = (at, count) => `Page ${at} of ${count}`, ...rest }) {
55
+ export function Pagination({ label, page, pageCount, pageHref, previousLabel = "Previous", nextLabel = "Next", pageLabel = pageOf, ...rest }) {
54
56
  const step = useTypeStep();
55
57
  if (pageCount <= 1)
56
58
  return null;
57
59
  const at = clamp(page, pageCount);
58
60
  const edge = { pageCount, pageHref, step };
59
- return (_jsx("nav", { ...rest, "aria-label": label, children: _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Edge, { to: at - 1, rel: "prev", ...edge, children: previousLabel }), _jsx("ol", { className: "hidden items-center gap-1 sm:flex", children: pageWindow(at, pageCount).map((slot, index) => slot === "gap" ? (_jsx("li", { "aria-hidden": "true", className: "px-1 text-sm text-slate-400", children: "\u2026" }, `gap-${index}`)) : (_jsx("li", { children: renderLink({
61
+ return (_jsx("nav", { ...rest, "aria-label": label, children: _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Edge, { to: at - 1, rel: "prev", ...edge, children: previousLabel }), _jsx("ol", { className: "hidden items-center gap-1 sm:flex", children: pageWindow(at, pageCount).map((slot) => typeof slot === "string" ? (_jsx("li", { "aria-hidden": "true", className: "px-1 text-sm text-slate-400", children: "\u2026" }, slot)) : (_jsx("li", { children: renderLink({
60
62
  href: pageHref(slot),
61
63
  "aria-current": slot === at ? "page" : undefined,
62
64
  className: cx(pillTabClass(slot === at, false, "sm", step), "inline-flex min-w-8 justify-center tabular-nums"),
@@ -1,5 +1,5 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { createContext, useContext, useId } from "react";
2
+ import { createContext, useContext, useId, useMemo, } from "react";
3
3
  import { FieldError, Label, Radio as AriaRadio, RadioGroup as AriaRadioGroup, Text, } from "react-aria-components";
4
4
  import { cx } from "./cx.js";
5
5
  import { controlText, useFieldType, useTypeStep } from "./density.js";
@@ -37,7 +37,8 @@ const RadioLook = createContext({
37
37
  export function RadioGroup({ label, hint, error, size = "md", variant = "plain", disabled, required, loading, loadingLabel, children, ...rest }) {
38
38
  const { loading: waiting, owner } = useLoading(loading);
39
39
  const type = useFieldType();
40
- return (_jsxs(AriaRadioGroup, { ...definedProps(rest), ...(error ? { isInvalid: true } : {}), ...(disabled ? { isDisabled: true } : {}), ...(required ? { isRequired: true } : {}), className: "flex flex-col gap-2", children: [_jsxs(Label, { className: cx(type.label, "font-medium text-slate-700"), children: [label, _jsx(RequiredMark, { required: required })] }), _jsxs("div", { ...busy(owner, waiting), className: "flex flex-col gap-2.5", children: [_jsx(RadioLook.Provider, { value: { size, variant }, children: _jsx(LoadingScope, { loading: waiting, children: children }) }), _jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel })] }), hint ? (_jsx(Text, { slot: "description", className: cx("text-slate-500", type.note), children: hint })) : null, _jsx(FieldError, { children: _jsx(ErrorLine, { error: error }) })] }));
40
+ const look = useMemo(() => ({ size, variant }), [size, variant]);
41
+ return (_jsxs(AriaRadioGroup, { ...definedProps(rest), ...(error ? { isInvalid: true } : {}), ...(disabled ? { isDisabled: true } : {}), ...(required ? { isRequired: true } : {}), className: "flex flex-col gap-2", children: [_jsxs(Label, { className: cx(type.label, "font-medium text-slate-700"), children: [label, _jsx(RequiredMark, { required: required })] }), _jsxs("div", { ...busy(owner, waiting), className: "flex flex-col gap-2.5", children: [_jsx(RadioLook.Provider, { value: look, children: _jsx(LoadingScope, { loading: waiting, children: children }) }), _jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel })] }), hint ? (_jsx(Text, { slot: "description", className: cx("text-slate-500", type.note), children: hint })) : null, _jsx(FieldError, { children: _jsx(ErrorLine, { error: error }) })] }));
41
42
  }
42
43
  function ringTone(invalid, selected) {
43
44
  if (invalid)
@@ -6,13 +6,17 @@ import { MetaList } from "./MetaList.js";
6
6
  import { Stack } from "./Stack.js";
7
7
  import { TextLink } from "./TextLink.js";
8
8
  import { Caption } from "./typography.js";
9
+ /** No links: no row of them. */
10
+ const NO_LINKS = [];
11
+ /** No fine print. */
12
+ const NO_NOTES = [];
9
13
  /**
10
14
  * The footer a site puts in `AppShell`'s `footer` slot: the site's mark linked home with a contact
11
15
  * line beside it, a row of the site's own links (Privacy, Terms, GitHub), then lines of fine print.
12
16
  * It is not a `<footer>`: the shell draws the one `contentinfo` landmark around its slot. No link
13
17
  * columns, newsletter form or social icons: a site footer is this and nothing else.
14
18
  */
15
- export function SiteFooter({ brand, brandHref, brandLabel, links = [], notes = [], children, ...rest }) {
19
+ export function SiteFooter({ brand, brandHref, brandLabel, links = NO_LINKS, notes = NO_NOTES, children, ...rest }) {
16
20
  const home = useHome();
17
21
  const top = brand != null || children != null;
18
22
  return (_jsxs(Stack, { ...rest, gap: "sm", children: [top && (_jsxs(Cluster, { gap: "md", children: [brand != null &&
@@ -21,5 +25,8 @@ export function SiteFooter({ brand, brandHref, brandLabel, links = [], notes = [
21
25
  "aria-label": brandLabel,
22
26
  className: cx("rounded text-slate-900", focusRing),
23
27
  children: brand,
24
- }), children] })), links.length > 0 && (_jsx(MetaList, { children: links.map((link) => (_jsx(TextLink, { href: link.href, external: link.external, children: link.label }, `${link.label} ${link.href}`))) })), notes.map((note, index) => (_jsx(Caption, { children: note }, index)))] }));
28
+ }), children] })), links.length > 0 && (_jsx(MetaList, { children: links.map((link) => (_jsx(TextLink, { href: link.href, external: link.external, children: link.label }, `${link.label} ${link.href}`))) })), notes
29
+ // A note is any node, with no id and free to repeat, so its line keys it.
30
+ .map((note, line) => ({ note, line }))
31
+ .map(({ note, line }) => (_jsx(Caption, { children: note }, line)))] }));
25
32
  }
package/dist/Stack.d.ts CHANGED
@@ -5,8 +5,6 @@ export type StackGap = "xs" | "sm" | "md" | "lg" | "xl";
5
5
  export declare const STACK_GAP: Record<StackGap, string>;
6
6
  /** The breakpoint from which a `Stack` turns from a column into a row: `sm`, `md` or `lg`. */
7
7
  export type StackRowFrom = "sm" | "md" | "lg";
8
- /** The breakpoint where a `rowFrom` Stack turns from a column into a row. */
9
- export declare const STACK_ROW_FROM: Record<StackRowFrom, string>;
10
8
  /** A `Stack`'s width cap at the start edge: `compact`, `narrow` (a reading measure), `default`, `wide` or `full`. */
11
9
  export type StackWidth = "compact" | "narrow" | "default" | "wide" | "full";
12
10
  /** `default` adds nothing: the Stack is as wide as its parent. */
package/dist/Stack.js CHANGED
@@ -11,7 +11,7 @@ export const STACK_GAP = {
11
11
  xl: "gap-12 sm:gap-16",
12
12
  };
13
13
  /** The breakpoint where a `rowFrom` Stack turns from a column into a row. */
14
- export const STACK_ROW_FROM = {
14
+ const STACK_ROW_FROM = {
15
15
  sm: "sm:flex-row",
16
16
  md: "md:flex-row",
17
17
  lg: "lg:flex-row",
@@ -34,7 +34,9 @@ function SWATCH(item) {
34
34
  */
35
35
  export function Legend({ items, loading, loadingLabel, ...rest }) {
36
36
  const { loading: waiting, owner } = useLoading(loading);
37
- return (_jsxs("ul", { ...rest, ...busy(owner, waiting), className: "flex flex-wrap gap-x-4 gap-y-1 text-sm text-slate-600", children: [waiting && items.length === 0 && _jsx(LegendBones, {}), owner && waiting && (_jsx("li", { className: "sr-only", children: _jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel }) })), items.map((item) => (_jsxs("li", { className: "flex items-center gap-1.5", children: [_jsx("span", { "aria-hidden": "true", className: cx("size-2.5 shrink-0 rounded-full", SWATCH(item)) }), _jsx("span", { children: item.label }), item.detail !== undefined && (_jsx("span", { className: "tabular-nums text-slate-500", children: item.detail }))] }, item.label)))] }));
37
+ return (_jsxs("ul", { ...rest, ...busy(owner, waiting), className: "flex flex-wrap gap-x-4 gap-y-1 text-sm text-slate-600", children: [waiting && items.length === 0 && _jsx(LegendBones, {}), owner && waiting && (_jsx("li", { className: "sr-only", children: _jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel }) })), items
38
+ .map((item, place) => ({ item, place }))
39
+ .map(({ item, place }) => (_jsxs("li", { className: "flex items-center gap-1.5", children: [_jsx("span", { "aria-hidden": "true", className: cx("size-2.5 shrink-0 rounded-full", SWATCH(item)) }), _jsx("span", { children: item.label }), item.detail !== undefined && (_jsx("span", { className: "tabular-nums text-slate-500", children: item.detail }))] }, `${place}:${item.label}`)))] }));
38
40
  }
39
41
  /** Three entries of bones, a swatch and a word each, for a key whose entries are not here yet. */
40
42
  function LegendBones() {
@@ -10,6 +10,8 @@ import { dotLayer } from "./stateMachineDots.js";
10
10
  import { boxContentSize, MACHINE_SPACING, dotArea, placeOf, slotsFor, UNPLACED, } from "./stateMachineGrid.js";
11
11
  import { useMoves } from "./stateMachineMoves.js";
12
12
  import { useFlowLayout } from "./useFlowLayout.js";
13
+ /** No items: every state empty. */
14
+ const NO_ITEMS = [];
13
15
  /** Each kind's box tone, and the tag that says it in words. */
14
16
  const KIND_TONE = {
15
17
  initial: "neutral",
@@ -117,7 +119,7 @@ function useOpenBoxes() {
117
119
  *
118
120
  * `fromXState` makes `states` and `transitions` from an xstate machine.
119
121
  */
120
- export function StateMachine({ label, states, transitions, items = [], active, roleTones: pinned, loading, loadingLabel, ...rest }) {
122
+ export function StateMachine({ label, states, transitions, items = NO_ITEMS, active, roleTones: pinned, loading, loadingLabel, ...rest }) {
121
123
  const { loading: waiting, owner } = useLoading(loading);
122
124
  const known = new Set(states.map((s) => s.id));
123
125
  const [open, toggle] = useOpenBoxes();
package/dist/Stepper.js CHANGED
@@ -28,6 +28,6 @@ export function Stepper({ steps, current, label, doneLabel = "done", ...rest })
28
28
  const last = steps.length - 1;
29
29
  return (_jsx("ol", { ...rest, "aria-label": label, className: "flex flex-col gap-3 text-sm sm:flex-row sm:items-center", children: steps.map((step, index) => {
30
30
  const state = stateOf(index + 1, current);
31
- return (_jsxs("li", { "aria-current": state === "current" ? "step" : undefined, className: cx("flex min-w-0 items-center gap-2", index < last && "sm:flex-1"), children: [_jsx("span", { "aria-hidden": "true", className: cx("flex size-7 shrink-0 items-center justify-center rounded-full border-2 font-medium tabular-nums", MARKER[state]), children: state === "done" ? _jsx(Icon, { name: "check", size: "sm" }) : index + 1 }), _jsxs("span", { className: LABEL[state], children: [step, state === "done" && _jsxs("span", { className: "sr-only", children: [" (", doneLabel, ")"] })] }), index < last && (_jsx("span", { "aria-hidden": "true", className: cx("hidden h-0 min-w-4 flex-1 border-t-2 sm:block", state === "done" ? "border-violet-600" : "border-slate-300") }))] }, index));
31
+ return (_jsxs("li", { "aria-current": state === "current" ? "step" : undefined, className: cx("flex min-w-0 items-center gap-2", index < last && "sm:flex-1"), children: [_jsx("span", { "aria-hidden": "true", className: cx("flex size-7 shrink-0 items-center justify-center rounded-full border-2 font-medium tabular-nums", MARKER[state]), children: state === "done" ? _jsx(Icon, { name: "check", size: "sm" }) : index + 1 }), _jsxs("span", { className: LABEL[state], children: [step, state === "done" && _jsxs("span", { className: "sr-only", children: [" (", doneLabel, ")"] })] }), index < last && (_jsx("span", { "aria-hidden": "true", className: cx("hidden h-0 min-w-4 flex-1 border-t-2 sm:block", state === "done" ? "border-violet-600" : "border-slate-300") }))] }, step));
32
32
  }) }));
33
33
  }
package/dist/Table.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback, useContext, useState } from "react";
2
+ import { useCallback, useContext, useMemo, useState } from "react";
3
3
  import { useInCard } from "./cardContext.js";
4
4
  import { cx } from "./cx.js";
5
5
  import { DensityProvider } from "./density.js";
@@ -11,6 +11,8 @@ export { TableCell, TableHeaderCell } from "./TableCells.js";
11
11
  export { TableExpandCell } from "./TableExpandCell.js";
12
12
  import { BoneRows, EmptyRow } from "./tableEmpty.js";
13
13
  import { BusyLabel, busy, LoadingScope, useLoading } from "./skeleton.js";
14
+ /** A table that does not stack draws no column titles on its rows. */
15
+ const NO_TITLES = [];
14
16
  /**
15
17
  * A list of records in a rounded, bordered card. Compose it
16
18
  * from `TableHead`, `TableBody`, `TableFoot`, `TableRow`, `TableHeaderCell` and `TableCell`. `label`
@@ -32,7 +34,7 @@ export function Table({ label, size = "sm", narrow = "scroll", sortedLabel = eng
32
34
  const numeric = numericColumns(children, TableHead, TableRow);
33
35
  const columns = columnCount(children, TableHead, TableRow);
34
36
  const stack = narrow === "stack";
35
- const titles = stack ? columnTitles(children, TableHead, TableRow) : [];
37
+ const titles = stack ? columnTitles(children, TableHead, TableRow) : NO_TITLES;
36
38
  const [said, setSaid] = useState("");
37
39
  const announce = useCallback((column, sort) => setSaid(sortedLabel(column, sort)), [sortedLabel]);
38
40
  const { attach, stop, measured, overflows } = useScrollStop("x", tableWider);
@@ -40,7 +42,8 @@ export function Table({ label, size = "sm", narrow = "scroll", sortedLabel = eng
40
42
  // Until measured (a page rendered on the server) and while too wide, the box scrolls sideways.
41
43
  // Once it fits, it clips instead: a clipping box is no scroll container, so the head can stick.
42
44
  const fits = measured && !overflows;
43
- return (_jsx(TableContext.Provider, { value: { plain, fits, size, numeric, columns, announce, stack, titles }, children: _jsx(DensityProvider, { size: size, children: _jsxs("div", { ref: attach, ...stopProps, className: cx(fits ? "overflow-clip" : "overflow-x-auto", ring, !plain && "rounded-xl border border-slate-200/70 bg-white shadow-sm"), children: [_jsxs("table", { ...rest, ...stackRole(stack, "table"), ...busy(owner, waiting), className: cx("w-full text-left text-sm", stack && STACK.table), children: [_jsx("caption", { className: "sr-only", children: label }), _jsx(LoadingScope, { loading: waiting, children: children })] }), _jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel }), _jsx("div", { role: "status", className: "sr-only", children: said })] }) }) }));
45
+ const context = useMemo(() => ({ plain, fits, size, numeric, columns, announce, stack, titles }), [plain, fits, size, numeric, columns, announce, stack, titles]);
46
+ return (_jsx(TableContext.Provider, { value: context, children: _jsx(DensityProvider, { size: size, children: _jsxs("div", { ref: attach, ...stopProps, className: cx(fits ? "overflow-clip" : "overflow-x-auto", ring, !plain && "rounded-xl border border-slate-200/70 bg-white shadow-sm"), children: [_jsxs("table", { ...rest, ...stackRole(stack, "table"), ...busy(owner, waiting), className: cx("w-full text-left text-sm", stack && STACK.table), children: [_jsx("caption", { className: "sr-only", children: label }), _jsx(LoadingScope, { loading: waiting, children: children })] }), _jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel }), _jsx("div", { role: "status", className: "sr-only", children: said })] }) }) }));
44
47
  }
45
48
  /** The default `sortedLabel`. */
46
49
  function englishSorted(column, sort) {
@@ -3,15 +3,6 @@ import { type IconName } from "./icons.js";
3
3
  import type { Unstyled } from "./props.js";
4
4
  import type { Size } from "./size.js";
5
5
  import { type TextTone } from "./typography.js";
6
- /** The classes of an inline text link, for a router's own <Link> that should look like one. */
7
- export declare const linkClass: string;
8
- /**
9
- * Stretches a link's hit area over its nearest `relative` ancestor (a table row, a card), so the
10
- * whole of it opens the link. Add it to the one link in the row; the ancestor needs `relative`.
11
- * `link-stretch` marks the link, so a `TableRow` or `Card` that lifts its other links and buttons
12
- * above it leaves this one alone.
13
- */
14
- export declare const linkStretchClass = "link-stretch after:absolute after:inset-0";
15
6
  /**
16
7
  * A TextLink's colour: a text tone, as on the inline roles, or `quiet`, the primary ink at rest and
17
8
  * the accent on hover, for a link in a row or list of links (a footer row, a table of contents),
package/dist/TextLink.js CHANGED
@@ -5,7 +5,7 @@ import { renderLink } from "./link.js";
5
5
  import { TEXT_TONE } from "./typography.js";
6
6
  const LINK = "rounded font-medium underline-offset-2 transition-colors";
7
7
  /** The classes of an inline text link, for a router's own <Link> that should look like one. */
8
- export const linkClass = cx(LINK, "text-violet-600 hover:text-violet-700", focusRing);
8
+ const linkClass = cx(LINK, "text-violet-600 hover:text-violet-700", focusRing);
9
9
  // A toned link takes its tone's text colour, shared with Table's cells and the inline roles, and
10
10
  // underlines on hover in place of a hover shade.
11
11
  const toneClass = (tone) => cx(LINK, TEXT_TONE[tone], "hover:underline", focusRing);
@@ -15,7 +15,7 @@ const toneClass = (tone) => cx(LINK, TEXT_TONE[tone], "hover:underline", focusRi
15
15
  * `link-stretch` marks the link, so a `TableRow` or `Card` that lifts its other links and buttons
16
16
  * above it leaves this one alone.
17
17
  */
18
- export const linkStretchClass = "link-stretch after:absolute after:inset-0";
18
+ const linkStretchClass = "link-stretch after:absolute after:inset-0";
19
19
  // The ink at rest, the accent on hover; focus draws the accent ring, as on every link.
20
20
  const QUIET = cx(LINK, "text-slate-900 hover:text-violet-700", focusRing);
21
21
  // The tone's colour, the quiet ink, or the accent with its hover shade.
@@ -20,7 +20,9 @@ export function TrendChart({ label, buckets, series, kind = "bar", loading, load
20
20
  const values = series.map((s) => buckets.map((_, i) => drawn(s.values[i])));
21
21
  const max = scaleMax(largest(values));
22
22
  const ticks = [max, max / 2, 0];
23
- return (_jsxs("figure", { ...rest, ...busy(owner, waiting), "aria-label": label, className: "flex flex-col gap-3", children: [_jsxs("div", { "aria-hidden": "true", className: "flex gap-2 pt-2 text-sm tabular-nums text-slate-500", children: [_jsx(YAxis, { ticks: waiting ? [] : ticks, max: max }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1.5", children: [waiting ? (_jsx(Bone, { shape: "block h-48 rounded-lg" })) : (_jsx(Plot, { ticks: ticks, max: max, kind: kind, series: series, values: values })), _jsx(XAxis, { buckets: buckets })] })] }), series.length === 2 && (_jsx(LoadingScope, { loading: false, children: _jsx(Legend, { items: series.map((s) => ({ label: s.label, tone: s.tone })) }) })), waiting ? (_jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel })) : (_jsx(FigureTable, { label: label, buckets: buckets, series: series }))] }));
23
+ const columns = buckets.map((name, at) => ({ at, name }));
24
+ const placed = series.map((s, at) => ({ at, s }));
25
+ return (_jsxs("figure", { ...rest, ...busy(owner, waiting), "aria-label": label, className: "flex flex-col gap-3", children: [_jsxs("div", { "aria-hidden": "true", className: "flex gap-2 pt-2 text-sm tabular-nums text-slate-500", children: [_jsx(YAxis, { ticks: waiting ? [] : ticks, max: max }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1.5", children: [waiting ? (_jsx(Bone, { shape: "block h-48 rounded-lg" })) : (_jsx(Plot, { ticks: ticks, max: max, kind: kind, series: placed, values: values })), _jsx(XAxis, { buckets: columns })] })] }), series.length === 2 && (_jsx(LoadingScope, { loading: false, children: _jsx(Legend, { items: series.map((s) => ({ label: s.label, tone: s.tone })) }) })), waiting ? (_jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel })) : (_jsx(FigureTable, { label: label, buckets: columns, series: placed }))] }));
24
26
  }
25
27
  /** The plot: a gridline per tick, and the series' bars or lines over them. */
26
28
  function Plot({ ticks, max, kind, series, values, }) {
@@ -33,14 +35,16 @@ function YAxis({ ticks, max }) {
33
35
  /** One equal column per bucket; past 8 buckets, every k-th label from the first. */
34
36
  function XAxis({ buckets }) {
35
37
  const every = Math.max(1, Math.ceil(buckets.length / MAX_X_LABELS));
36
- return (_jsx("div", { className: "grid text-center", style: { gridTemplateColumns: `repeat(${buckets.length}, minmax(0, 1fr))` }, children: buckets.map((bucket, i) => (_jsx("span", { className: "whitespace-nowrap", children: i % every === 0 ? bucket : null }, `${bucket}-${i}`))) }));
38
+ return (_jsx("div", { className: "grid text-center", style: { gridTemplateColumns: `repeat(${buckets.length}, minmax(0, 1fr))` }, children: buckets.map((bucket) => (_jsx("span", { className: "whitespace-nowrap", children: bucket.at % every === 0 ? bucket.name : null }, bucket.at))) }));
37
39
  }
38
40
  /** A rect per present value, the series side by side in each bucket. */
39
41
  function Bars({ series, values, max }) {
40
42
  const width = 100 / Math.max(1, values[0]?.length ?? 1);
41
43
  const bar = (width * BAR_SPAN) / series.length;
42
44
  const inset = (width * (1 - BAR_SPAN)) / 2;
43
- return (_jsx(_Fragment, { children: series.map((s, si) => values[si]?.map((value, i) => {
45
+ return (_jsx(_Fragment, { children: series.map(({ at: si, s }) => values[si]
46
+ ?.map((value, i) => ({ value, i }))
47
+ .map(({ value, i }) => {
44
48
  if (value === null)
45
49
  return null;
46
50
  const y = plotY(value, max);
@@ -50,9 +54,9 @@ function Bars({ series, values, max }) {
50
54
  /** A polyline per run of present values, through the middle of each bucket. */
51
55
  function Lines({ series, values, max }) {
52
56
  const width = 100 / Math.max(1, values[0]?.length ?? 1);
53
- return (_jsx(_Fragment, { children: series.map((s, si) => runs((values[si] ?? []).map((value, i) => value === null ? null : { x: width * (i + 0.5), y: plotY(value, max) })).map((points) => (_jsx("polyline", { className: VIZ_TONE[s.tone], points: points, fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", vectorEffect: "non-scaling-stroke" }, `${si}-${points}`)))) }));
57
+ return (_jsx(_Fragment, { children: series.map(({ at: si, s }) => runs((values[si] ?? []).map((value, i) => value === null ? null : { x: width * (i + 0.5), y: plotY(value, max) })).map((points) => (_jsx("polyline", { className: VIZ_TONE[s.tone], points: points, fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", vectorEffect: "non-scaling-stroke" }, `${si}-${points}`)))) }));
54
58
  }
55
59
  /** The chart's figures for a screen reader: a row per bucket, a column per series. */
56
60
  function FigureTable({ label, buckets, series, }) {
57
- return (_jsxs("table", { className: "sr-only", children: [_jsx("caption", { children: label }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("td", {}), series.map((s, si) => (_jsx("th", { scope: "col", children: s.label }, si)))] }) }), _jsx("tbody", { children: buckets.map((bucket, i) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", children: bucket }), series.map((s, si) => (_jsx("td", { children: spoken(s.values[i]) }, si)))] }, `${bucket}-${i}`))) })] }));
61
+ return (_jsxs("table", { className: "sr-only", children: [_jsx("caption", { children: label }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("td", {}), series.map(({ at, s }) => (_jsx("th", { scope: "col", children: s.label }, at)))] }) }), _jsx("tbody", { children: buckets.map((bucket) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", children: bucket.name }), series.map(({ at, s }) => (_jsx("td", { children: spoken(s.values[bucket.at]) }, at)))] }, bucket.at))) })] }));
58
62
  }
@@ -102,7 +102,7 @@ function routeLayout(g, { ids, groups, kept }, across) {
102
102
  return {
103
103
  width: Math.ceil(grown.x),
104
104
  height: Math.ceil(grown.y),
105
- nodes: [...ids].map((id) => ({ id, ...place(raw(id)) })),
105
+ nodes: [...ids].map((id) => Object.assign({ id }, place(raw(id)))),
106
106
  groups: groups.map((name) => ({ name, ...place(raw(groupKey(name))) })),
107
107
  edges: routes.map(({ e, index }, i) => {
108
108
  const points = (lines[i] ?? []).map((p) => {
@@ -6,7 +6,7 @@ export type XStateTransitionConfig = string | undefined | {
6
6
  };
7
7
  type XStateTransitions = XStateTransitionConfig | readonly XStateTransitionConfig[];
8
8
  /** One `invoke`: where it goes when the invoked actor is done, and when it fails. */
9
- export type XStateInvokeConfig = {
9
+ type XStateInvokeConfig = {
10
10
  onDone?: XStateTransitions;
11
11
  onError?: XStateTransitions;
12
12
  };
@@ -27,7 +27,7 @@ export type XStateNodeConfig = {
27
27
  states?: Record<string, XStateNodeConfig> | undefined;
28
28
  };
29
29
  /** Where a machine starts: a state's key, or `{ target }`. */
30
- export type XStateInitial = string | {
30
+ type XStateInitial = string | {
31
31
  target: string;
32
32
  } | undefined;
33
33
  /** A machine's config, or what `setup(…).createMachine(config)` returns (it keeps it as `config`). */
@@ -105,12 +105,12 @@ export function fromXState(machine, options = {}) {
105
105
  return to
106
106
  .map((t) => targetState(t, from, ids))
107
107
  .filter((t) => t !== from && keys.has(t))
108
- .map((t) => ({
109
- from,
110
- to: t,
111
- event: name,
112
- ...(actor === undefined ? {} : { actor }),
113
- }));
108
+ .map((t) => {
109
+ const move = { from, to: t, event: name };
110
+ if (actor !== undefined)
111
+ move.actor = actor;
112
+ return move;
113
+ });
114
114
  })));
115
115
  return { states, transitions };
116
116
  }
@@ -65,7 +65,7 @@ export function moveOf(places, keys, target) {
65
65
  return null;
66
66
  const section = place.section === undefined ? {} : { section: place.section };
67
67
  if (place.tail) {
68
- const last = place.tail.filter((item) => item !== id).at(-1);
68
+ const last = place.tail.findLast((item) => item !== id);
69
69
  return last === undefined
70
70
  ? { id, ...section }
71
71
  : { id, ...section, target: { id: last, position: "after" } };
@@ -17,12 +17,6 @@ export declare const DOT_X: number;
17
17
  export declare function placeOf(items: readonly StateMachineItem[], known: ReadonlySet<string>): Map<string, string>;
18
18
  /** How many slots a box with `count` items draws: all of them, or the first few and a `+N`; one more for "fewer" when open. */
19
19
  export declare function slotsFor(count: number, open: boolean): number;
20
- /**
21
- * The rows a box reserves for its dots, whatever its count: the six it shows (the `+N` included),
22
- * or the rows of an open box's full list. A box with few or no items reserves the same rows, so
23
- * its size does not depend on how many items it holds.
24
- */
25
- export declare function rowsFor(slots: number): number;
26
20
  /**
27
21
  * The room a box reserves under its tags for `slots` dots: the full grid's width and `rowsFor`'s
28
22
  * height, so it is the same at 0, 1, 6 or 12 items (closed) and grows only when a box is opened.
@@ -29,7 +29,7 @@ export function slotsFor(count, open) {
29
29
  * or the rows of an open box's full list. A box with few or no items reserves the same rows, so
30
30
  * its size does not depend on how many items it holds.
31
31
  */
32
- export function rowsFor(slots) {
32
+ function rowsFor(slots) {
33
33
  return Math.ceil(Math.max(LIMIT, slots) / COLS);
34
34
  }
35
35
  /**
@@ -100,6 +100,40 @@ export function useFit(width) {
100
100
  const scale = room > 0 && width > room ? room / width : 1;
101
101
  return { frame, scale };
102
102
  }
103
+ const isRecord = (value) => typeof value === "object" && value !== null;
104
+ const isSize = (value) => isRecord(value) && typeof value["width"] === "number" && typeof value["height"] === "number";
105
+ const isLayoutNode = (value) => isRecord(value) &&
106
+ typeof value["id"] === "string" &&
107
+ (value["group"] === undefined || typeof value["group"] === "string") &&
108
+ isSize(value);
109
+ const isLayoutEdge = (value) => isRecord(value) &&
110
+ typeof value["from"] === "string" &&
111
+ typeof value["to"] === "string" &&
112
+ (value["label"] === undefined || isSize(value["label"]));
113
+ const isSpacing = (value) => isRecord(value) &&
114
+ typeof value["node"] === "number" &&
115
+ typeof value["rank"] === "number" &&
116
+ typeof value["edge"] === "number";
117
+ /** The key read back: the layout's input, as `useFlowLayout` wrote it. */
118
+ function isLayoutInput(value) {
119
+ if (!Array.isArray(value) || value.length !== 4)
120
+ return false;
121
+ const items = value;
122
+ const [direction, spacing, nodes, edges] = items;
123
+ return ((direction === "down" || direction === "right") &&
124
+ (spacing === null || isSpacing(spacing)) &&
125
+ Array.isArray(nodes) &&
126
+ nodes.every(isLayoutNode) &&
127
+ Array.isArray(edges) &&
128
+ edges.every(isLayoutEdge));
129
+ }
130
+ /** A size the key can carry: JSON writes NaN and Infinity as null, which dagre has always placed as 0. */
131
+ const finite = ({ width, height }) => ({
132
+ width: Number.isFinite(width) ? width : 0,
133
+ height: Number.isFinite(height) ? height : 0,
134
+ });
135
+ /** What draws when the key does not read back: nothing, rather than a throw during render. */
136
+ const NO_LAYOUT = { width: 0, height: 0, nodes: [], groups: [], edges: [] };
103
137
  const sameSizes = (a, b) => {
104
138
  const keys = Object.keys(a);
105
139
  return (keys.length === Object.keys(b).length &&
@@ -119,18 +153,21 @@ export function useFlowLayout(nodes, edges, direction, options = {}) {
119
153
  const layoutNodes = nodes.map((n) => ({
120
154
  id: n.id,
121
155
  group: n.group,
122
- ...(uniform?.get(n.id) ?? measured[nodeKey(n.id)] ?? guessNode(n)),
156
+ ...finite(uniform?.get(n.id) ?? measured[nodeKey(n.id)] ?? guessNode(n)),
123
157
  }));
124
158
  const layoutEdges = edges.map((e, index) => ({
125
159
  from: e.from,
126
160
  to: e.to,
127
- label: e.label ? (measured[edgeKey(index)] ?? guessLabel(e.label)) : undefined,
161
+ label: e.label ? finite(measured[edgeKey(index)] ?? guessLabel(e.label)) : undefined,
128
162
  }));
129
163
  const key = JSON.stringify([direction, options.spacing, layoutNodes, layoutEdges]);
130
164
  // The layout reads its input back from the key, so the key is its one dependency and the layout
131
165
  // reruns only when a size, an id or a gap changes, not on every render's fresh arrays.
132
166
  const drawn = useMemo(() => {
133
- const [d, spacing, n, e] = JSON.parse(key);
167
+ const input = JSON.parse(key);
168
+ if (!isLayoutInput(input))
169
+ return NO_LAYOUT;
170
+ const [d, spacing, n, e] = input;
134
171
  return layoutFlow(n, e, d, spacing ?? undefined);
135
172
  }, [key]);
136
173
  useLayoutEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slashsuite/ui-react",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "UISlash React components: primitives, typography roles and a safe Markdown renderer, written against Tailwind v4 utilities. Pair with a theme from @slashsuite/themes.",
5
5
  "keywords": [
6
6
  "components",
@@ -67,7 +67,6 @@
67
67
  "jsdom": "^31.0.1",
68
68
  "react": "^19.3.1",
69
69
  "react-dom": "^19.3.1",
70
- "tailwindcss": "^4.3.5",
71
70
  "vitest": "5.1.1"
72
71
  },
73
72
  "peerDependencies": {