@slashsuite/ui-react 0.16.2 → 0.16.4

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.
@@ -52,7 +52,7 @@ import { CodeBlock } from "@slashsuite/ui-react";
52
52
 
53
53
  ### Props
54
54
  ### Code
55
- Inline code: mono, on a subtle inset background. It takes the surrounding text colour and size (a touch smaller, for the mono face). `lines={1}` keeps a long value (a hash, a path) on one line, cut with an ellipsis, and shows its whole text in a tooltip while it is cut; `breakWords` instead breaks a long unbroken value at the edge of its box, as `Text` does.
55
+ Inline code: mono, on a subtle inset background. It takes the surrounding text colour and size (a touch smaller, for the mono face, and never under 14px). `lines={1}` keeps a long value (a hash, a path) on one line, cut with an ellipsis, and shows its whole text in a tooltip while it is cut; `breakWords` instead breaks a long unbroken value at the edge of its box, as `Text` does.
56
56
  - breakWords: boolean (default false). Breaks a long unbroken value (a URL, a hash) at the edge of its box.
57
57
  - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
58
58
  - lines: 1. `1` keeps it on one line, cut with an ellipsis; while it is cut, its whole text shows in a tooltip.
@@ -76,7 +76,7 @@ function Example() {
76
76
  ```
77
77
 
78
78
  ### Accessibility
79
- - It is an `alertdialog` on the browser's own `<dialog>`: the page behind goes inert, focus stays inside and Esc closes it.
79
+ - It is an `alertdialog` on the browser's own `<dialog>`: the page behind goes inert, Tab and Shift+Tab wrap inside it and Esc closes it.
80
80
  - It is named by its `title` and described by its `description`, so a screen reader reads the question and the consequence as it opens.
81
81
  - It opens on Cancel, so Enter or Space pressed by habit cancels rather than destroys.
82
82
  - Esc, the backdrop and the close button all cancel, as Cancel does; only the confirm button runs the action.
@@ -96,7 +96,7 @@ function Example() {
96
96
  ```
97
97
 
98
98
  ### Accessibility
99
- - A Dialog is the browser's own `<dialog>` opened with `showModal()`: the page behind goes inert, focus stays inside it and Esc closes it.
99
+ - A Dialog is the browser's own `<dialog>` opened with `showModal()`: the page behind goes inert, Tab and Shift+Tab wrap inside it and Esc closes it.
100
100
  - The fade and slide are switched off under `prefers-reduced-motion: reduce`, and then it closes at once.
101
101
  - It is named by its `title`, an `h2`, through `aria-labelledby`.
102
102
  - A click on the backdrop closes it, and so do the close button and a submit of a `<form method="dialog">`; every close calls `onClose`.
@@ -107,7 +107,7 @@ function Example() {
107
107
 
108
108
  ### Props
109
109
  ### Dialog
110
- A modal on the browser's own `<dialog>`: it is opened with `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc closes it and focus stays inside; a click on the backdrop (the `<dialog>` element itself, not its contents) closes it too, and so does the close button in its top corner, which every dialog has. The close button comes last in the keyboard order, so the open focuses the first field, not it. A windowed dialog is never taller than the screen: a tall body scrolls and the title and footer stay on screen, and a scroll inside it never carries on to the page behind.
110
+ A modal on the browser's own `<dialog>`: it is opened with `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc closes it and Tab wraps inside it; a click on the backdrop (the `<dialog>` element itself, not its contents) closes it too, and so does the close button in its top corner, which every dialog has. The close button comes last in the keyboard order, so the open focuses the first field, not it. A windowed dialog is never taller than the screen: a tall body scrolls and the title and footer stay on screen, and a scroll inside it never carries on to the page behind.
111
111
  - closeLabel: string (default Close). The name of the close button in the top corner, for an app in another language.
112
112
  - description: ReactNode. A muted line under the title.
113
113
  - error: ReactNode. What went wrong with the whole submit (the server refused it, no connection): a danger
@@ -111,7 +111,7 @@ function Example() {
111
111
  ```
112
112
 
113
113
  ### Accessibility
114
- - A Drawer is the browser's own `<dialog>` opened with `showModal()`: the page behind goes inert, focus stays inside it and Esc closes it.
114
+ - A Drawer is the browser's own `<dialog>` opened with `showModal()`: the page behind goes inert, Tab and Shift+Tab wrap inside it and Esc closes it.
115
115
  - It is named by its `title`, an `h2`, through `aria-labelledby`.
116
116
  - The header's close button is an `IconButton` named by `closeLabel` ("Close" by default); a click on the scrim closes it too.
117
117
  - On a touch screen a swipe to the right drags it off: past a third of its width, or a quick flick, closes it, and a shorter one springs back. A vertical swipe scrolls the body, and a swipe that starts in a field or a slider is the field's own.
@@ -120,7 +120,7 @@ function Example() {
120
120
 
121
121
  ### Props
122
122
  ### Drawer
123
- A modal slide-over anchored to the right edge, on the browser's own `<dialog>`: it is opened with `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc closes it and focus stays inside; a click on the scrim (the `<dialog>` element itself, not its contents) closes it too, and on touch a swipe to the right drags it off (a short one springs back). The header holds the title, an optional `description` under it and a close button; the body scrolls between it and an optional pinned `footer`, and a scroll in it never carries on to the page behind. `onSubmit` makes it a form and `error` shows what went wrong with the submit, as on a `Dialog`.
123
+ A modal slide-over anchored to the right edge, on the browser's own `<dialog>`: it is opened with `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc closes it and Tab wraps inside it; a click on the scrim (the `<dialog>` element itself, not its contents) closes it too, and on touch a swipe to the right drags it off (a short one springs back). The header holds the title, an optional `description` under it and a close button; the body scrolls between it and an optional pinned `footer`, and a scroll in it never carries on to the page behind. `onSubmit` makes it a form and `error` shows what went wrong with the submit, as on a `Dialog`.
124
124
  - closeLabel: string (default Close). The accessible name of the close button.
125
125
  - description: ReactNode. A muted line under the title, as on a `Dialog`.
126
126
  - error: ReactNode. What went wrong with the whole submit, as on a `Dialog`: a danger `Callout`, announced as an
@@ -76,7 +76,7 @@ function Example() {
76
76
  ```
77
77
 
78
78
  ### Accessibility
79
- - It is a `Dialog`: native `<dialog>`, page behind inert, focus kept inside, Esc closes, named by its `title`.
79
+ - It is a `Dialog`: native `<dialog>`, page behind inert, Tab wraps inside, Esc closes, named by its `title`.
80
80
  - The input has focus when it opens and is named by `label`.
81
81
  - The submit button is never disabled: an empty submit marks the field invalid, shows `emptyReason` as its error (announced politely) and moves the focus to it. Typing clears the error.
82
82
  - While `onSubmit` is pending the button is busy (`aria-busy`); a rejection shows in the field's error line, announced politely from a live region inside the dialog.
@@ -21,6 +21,7 @@ import { Hero, Lead } from "@slashsuite/ui-react";
21
21
  - It caps itself at a reading measure at the parent's start edge, and the glow is clipped to it, so a phone never scrolls sideways. Put it as the first child of the page's `Stack`.
22
22
  - A product page passes its picture as `media`: an `Image` at `width="full"`, beside the words from `md` up and under them on a phone.
23
23
  - A landing page with no picture and one or two actions may set `align="center"`, with its actions' `Cluster` at `justify="center"`.
24
+ - To put the pause control in a slot of your own, such as a demo window's bar, set `pause="none"` and place one `HeroPause` there.
24
25
 
25
26
  ### Don't
26
27
  - Never build the block from an `Overline`, a `Display` and a `Lead` by hand: the hand-built one has no glow and drifts from the one top block.
@@ -51,7 +52,7 @@ import { Hero, Lead } from "@slashsuite/ui-react";
51
52
  - The title is the page's `<h1>`, in a `<header>` with the overline.
52
53
  - The glow is `aria-hidden="true"` and takes no pointer; the text sits above it and holds AA contrast over it in every theme.
53
54
  - The glow drifts only under `prefers-reduced-motion: no-preference`; with reduced motion it stands still. It is plain markup and CSS, so it renders on the server and needs no script.
54
- - The drift never ends on its own, so a checkbox in the hero's top corner, named by `pauseLabel` (Pause the background motion), holds it still. It is a native checkbox, reached by Tab and toggled by Space, and is not drawn under reduced motion.
55
+ - The drift never ends on its own, so a checkbox in the hero's top corner, named by `pauseLabel` (Pause the background motion), holds it still. It is a native checkbox, reached by Tab and toggled by Space, and is not drawn under reduced motion. With `pause="none"` the hero draws none; a `HeroPause` placed anywhere on the page does the same job.
55
56
 
56
57
  ### Props
57
58
  ### Hero
@@ -64,5 +65,13 @@ with no picture whose actions are one or two buttons. Pass the actions' `Cluster
64
65
  - media: ReactNode. A picture beside the words from `md` up, and under them on a phone: an `Image` of the
65
66
  product, at `width="full"`. The words keep the glow; the picture sits clear of it.
66
67
  - overline: ReactNode. The small label above the title, set in the monospace face.
68
+ - pause: "none" | "corner" (default corner). Where the control that holds the glow still goes. `corner` draws it in the words' top corner.
69
+ `none` leaves it out of the hero: place a `HeroPause` in a slot of your own (a demo window's
70
+ bar), or draw none when the page has nothing else to pause it with.
67
71
  - pauseLabel: string (default Pause the background motion). The name of the control that holds the glow still, for an app in another language.
68
72
  - title: ReactNode (required). The page's `h1`, at display size.
73
+
74
+ ### HeroPause
75
+ The control that holds the page's `Hero` glow still, for a slot of the caller's own: a demo window's bar, a toolbar. Use it with `<Hero pause="none">`, once per page; anywhere on the page it pauses the one hero's ribbons while checked, in CSS with no script, and it is not drawn under `prefers-reduced-motion: reduce`, where nothing moves.
76
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
77
+ - label: string (default Pause the background motion). The control's name, for an app in another language.
@@ -74,7 +74,7 @@ function Example() {
74
74
  ```
75
75
 
76
76
  ### Accessibility
77
- - A Lightbox is the browser's own `<dialog>` opened with `showModal()`: the page behind goes inert, focus stays inside it and Esc closes it.
77
+ - A Lightbox is the browser's own `<dialog>` opened with `showModal()`: the page behind goes inert, Tab and Shift+Tab wrap inside it and Esc closes it.
78
78
  - It is named by `label` through `aria-label`; give the `<img>` its own `alt`.
79
79
  - The close, previous and next buttons are named Close, Previous and Next (`closeLabel`, `previousLabel` and `nextLabel` for another language), and keep a light focus ring that shows on the dark scrim in every theme.
80
80
  - A click on the scrim around the media closes it; a click on the media or its text does not.
@@ -82,7 +82,7 @@ function Example() {
82
82
 
83
83
  ### Props
84
84
  ### Lightbox
85
- A full-screen photo or video viewer on the browser's own `<dialog>`: it is opened with `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc closes it and focus stays inside; a click on the scrim around the media and its text closes it too. The scrim stays near-black with light text in every theme. `onPrevious` and `onNext` add step buttons and the arrow keys.
85
+ A full-screen photo or video viewer on the browser's own `<dialog>`: it is opened with `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc closes it and Tab wraps inside it; a click on the scrim around the media and its text closes it too. The scrim stays near-black with light text in every theme. `onPrevious` and `onNext` add step buttons and the arrow keys.
86
86
  - caption: ReactNode. Muted text on the scrim under the media.
87
87
  - children: ReactNode (required). The media: one `<img>` or `<video>`, scaled down to fit the screen.
88
88
  - closeLabel: string (default Close). The close button's name, for an app in another language.
@@ -37,7 +37,7 @@ function Example() {
37
37
  - Loading beats empty: while `loading`, an empty slot is a bone, never the `empty` state.
38
38
  - Three words, three meanings: `loading` is data not here yet (a skeleton); `busy` is an action in flight on a control (`Button`, `Switch`, `ChatComposer`); `streaming` is content arriving piece by piece (`ChatMessage`). `NavigationProgress loading` is the bar for a page change, not a skeleton.
39
39
  - Take `loading`. Page layouts, each the owner of its page's wait, passing it to everything inside, the header too: `PageHeader`, `ListLayout`, `DetailLayout`, `FormLayout`, `ProseLayout`, `ArticleLayout`, `SidebarLayout` (its canvas; the rail is navigation), `DocsLayout` (its article; the nav, contents and pager are navigation), `FullBleedLayout`, `CenteredLayout` and `CardGrid`. Text: `Text`, `Lead`, `Caption`, `Overline`, `Display`, `PageHeading`, `SectionHeading`, `SubsectionHeading` and `Markdown`. Data and content: `StatTile`, `KeyValueList`, `KeyValue`, `Badge`, `Pill`, `MetaList`, `Card`, `Table` and `TableCell` (`TableHead`, `TableBody`, `TableRow`, `TableFoot`, `TableGroupRow` and `TableHeaderCell` wait with their table), `ListRow`, `Timeline`, `TimelineItem`, `Avatar`, `AvatarStack`, `Image`, `RegionFrame`, `MediaTile`, `Price`, `ProductTile`, `ProgressBar`, `SplitBar`, `StackedBar`, `Legend`, `TrendChart`, `FlowDiagram` and `StateMachine`. Forms: `Field` and `FormRowField` draw their label and a bone the height of their control (read from the density around them, so a `sm` card's is `sm`), and `Checkbox`, `Switch`, `RadioGroup` with `Radio`, `DateField`, `DateTimeField`, `NumberField` and `Combobox` draw their labels with the box, track, circles or field as bones.
40
- - Draw as themselves, by design. Actions and navigation are known before the data: `Button`, `ButtonGroup`, `IconButton`, `CopyButton`, `CopyLine`, `ColourSchemeToggle`, `Menu`, `Popover`, `Tabs`, `SegmentedControl`, `Breadcrumbs`, `Pagination`, `Stepper`, `TextLink`, `TableOfContents`, `SiteSearch`, `CartButton` and `TableExpandCell`; an action that needs the data says why it waits with `disabledReason`. Bare controls hold the caller's own state, and a fetched value waits in its `Field` or `FormRowField`: `Input`, `Select`, `Slider`, `Textarea`, `FileDrop`, `DateRangePicker`, `Fieldset`, `InlineEdit` and `TableEditCell`. Frames and primitives have no data of their own, and what they hold draws its own bones: `AppShell`, `AppShellBrand`, `Container`, `Stack`, `Section`, `CardGridRow`, `Cluster`, `ClusterGrow`, `SideColumn`, `StickyBar`, `Show`, `ScrollStrip`, `FormGrid`, `FormRow`, `Divider`, `Icon`, `Kbd`, `Code`, `Mark`, `Prose`, `BulletList`, `BulletItem`, `Steps`, `Step`, `Hero`, `PromoBanner`, `CallToAction`, `SiteFooter`, `Callout`, `EmptyState`, `Disclosure` and `LinkProvider`. Overlays open on an action and their contents draw bones: `Dialog`, `Drawer`, `BottomSheet`, `Lightbox`, `ConfirmDialog`, `FieldDialog` and `ToastRegion`. Static copy and authored code: `ErrorPage`, `NotFound`, `Forbidden`, `Offline`, `Maintenance`, `CodeBlock`, `CodeExample` and `ColourSwatch` (a value the page already has). In flight on their own terms: `ChatThread`, `ChatMessage` (`streaming`), `ChatComposer` (`busy`), `NavigationProgress`, `PageFade`, `Morph`, `Video` (the browser's poster), `Audio` (the browser's player) and `EmbedFrame` (`status`, since the embed loads on its own). `OutlineRegion` is drawn over its `RegionFrame` and waits with it. `SortableList`, `SortableItem` and `SortableSection` need their items to reorder; `ListRow` bones stand in.
40
+ - Draw as themselves, by design. Actions and navigation are known before the data: `Button`, `ButtonGroup`, `IconButton`, `CopyButton`, `CopyLine`, `ColourSchemeToggle`, `Menu`, `Popover`, `Tabs`, `SegmentedControl`, `Breadcrumbs`, `Pagination`, `Stepper`, `TextLink`, `TableOfContents`, `SiteSearch`, `CartButton` and `TableExpandCell`; an action that needs the data says why it waits with `disabledReason`. Bare controls hold the caller's own state, and a fetched value waits in its `Field` or `FormRowField`: `Input`, `Select`, `Slider`, `Textarea`, `FileDrop`, `DateRangePicker`, `Fieldset`, `InlineEdit` and `TableEditCell`. Frames and primitives have no data of their own, and what they hold draws its own bones: `AppShell`, `AppShellBrand`, `Container`, `Stack`, `Section`, `CardGridRow`, `Cluster`, `ClusterGrow`, `SideColumn`, `StickyBar`, `Show`, `ScrollStrip`, `FormGrid`, `FormRow`, `Divider`, `Icon`, `Kbd`, `Code`, `Mark`, `Prose`, `BulletList`, `BulletItem`, `Steps`, `Step`, `Hero`, `HeroPause`, `PromoBanner`, `CallToAction`, `SiteFooter`, `Callout`, `EmptyState`, `Disclosure` and `LinkProvider`. Overlays open on an action and their contents draw bones: `Dialog`, `Drawer`, `BottomSheet`, `Lightbox`, `ConfirmDialog`, `FieldDialog` and `ToastRegion`. Static copy and authored code: `ErrorPage`, `NotFound`, `Forbidden`, `Offline`, `Maintenance`, `CodeBlock`, `CodeExample` and `ColourSwatch` (a value the page already has). In flight on their own terms: `ChatThread`, `ChatMessage` (`streaming`), `ChatComposer` (`busy`), `NavigationProgress`, `PageFade`, `Morph`, `Video` (the browser's poster), `Audio` (the browser's player) and `EmbedFrame` (`status`, since the embed loads on its own). `OutlineRegion` is drawn over its `RegionFrame` and waits with it. `SortableList`, `SortableItem` and `SortableSection` need their items to reorder; `ListRow` bones stand in.
41
41
 
42
42
  ### Don't
43
43
  - Do not build a grey box by hand or write a "Loading..." `Text`: it drops the captions the reader could already see, and the page jumps when the data lands.
@@ -46,13 +46,13 @@ import { Button, Popover } from "@slashsuite/ui-react";
46
46
 
47
47
  ### Accessibility
48
48
  - It is the browser's own popover: a click outside it, Esc or the trigger closes it, and Esc puts the focus back on the trigger.
49
- - It is not modal: the page stays usable, and Tab moves from the trigger into the panel and on.
49
+ - Opening it moves the focus into the panel. It is not modal: the page stays usable, and Tab moves on through the panel and out of it.
50
50
  - The trigger says whether it is open (`aria-expanded`), and the panel is a `dialog` named by `label`.
51
51
  - Where the browser positions by anchor, the panel sits under the trigger and flips above when there is no room; elsewhere it shows in the middle of the screen.
52
52
 
53
53
  ### Props
54
54
  ### Popover
55
- A button that opens a small panel of content beside it: a detail, a short list, a filter. It is the browser's own popover, rendered in place: a click outside it, Esc or the trigger closes it, and the focus goes back to the trigger. It is not modal: the page stays usable, and Tab moves from the trigger into the panel and on. A list of actions is a `Menu`; a question to answer first is a `Dialog`. `data-*` and `aria-*` land on the trigger.
55
+ A button that opens a small panel of content beside it: a detail, a short list, a filter. It is the browser's own popover, rendered in place: a click outside it, Esc or the trigger closes it, and the focus goes back to the trigger. Opening it moves the focus into the panel. It is not modal: the page stays usable, and Tab moves on through the panel and out of it. A list of actions is a `Menu`; a question to answer first is a `Dialog`. `data-*` and `aria-*` land on the trigger.
56
56
  - children: ReactNode (required). What the panel holds: a few lines, a short list, a filter or two.
57
57
  - defaultOpen: boolean (default false). Opens on mount, for a story or a test that shows the open panel.
58
58
  - icon: "page" | "grid" | "search" | "alert" | "table" | "type" | "diff" | "baseline" | "review" | "ci" | "self-host" | "privacy" | "capture" | "branch" | "theme" | "speed" | "chevron-right" | "chevron-down" | "close" | "external-link" | "settings" | "bell" | "check" | "plus" | "minus" | "more" | "window" | "card" | "pointer" | "field" | "compass" | "briefcase" | "cart" | "pause" | "play". Makes the trigger a ghost square button holding this glyph, named by `label` (shown as its
package/dist/Code.d.ts CHANGED
@@ -2,7 +2,7 @@ import { type ReactElement, type ReactNode } from "react";
2
2
  import type { Passthrough } from "./props.js";
3
3
  /**
4
4
  * Inline code: mono, on a subtle inset background. It takes the surrounding text colour and size (a
5
- * touch smaller, for the mono face). `lines={1}` keeps a long value (a hash, a path) on one line,
5
+ * touch smaller, for the mono face, and never under 14px). `lines={1}` keeps a long value (a hash, a path) on one line,
6
6
  * cut with an ellipsis, and shows its whole text in a tooltip while it is cut; `breakWords` instead breaks a long unbroken
7
7
  * value at the edge of its box, as `Text` does.
8
8
  */
package/dist/Code.js CHANGED
@@ -5,12 +5,12 @@ import { layoutClass } from "./textBox.js";
5
5
  import { Truncated } from "./truncated.js";
6
6
  /**
7
7
  * Inline code: mono, on a subtle inset background. It takes the surrounding text colour and size (a
8
- * touch smaller, for the mono face). `lines={1}` keeps a long value (a hash, a path) on one line,
8
+ * touch smaller, for the mono face, and never under 14px). `lines={1}` keeps a long value (a hash, a path) on one line,
9
9
  * cut with an ellipsis, and shows its whole text in a tooltip while it is cut; `breakWords` instead breaks a long unbroken
10
10
  * value at the edge of its box, as `Text` does.
11
11
  */
12
12
  export function Code({ lines, breakWords = false, children, ...rest }) {
13
- const look = cx("rounded bg-slate-100 px-1 py-0.5 font-mono text-[0.9em]", layoutClass(undefined, lines), breakWords && "break-words");
13
+ const look = cx("rounded bg-slate-100 px-1 py-0.5 font-mono text-[length:max(0.9em,0.875rem)]", layoutClass(undefined, lines), breakWords && "break-words");
14
14
  if (lines === 1) {
15
15
  return (_jsx(Truncated, { as: "code", attrs: rest, text: plainText(children), className: look, children: children }));
16
16
  }
package/dist/Dialog.d.ts CHANGED
@@ -58,7 +58,7 @@ export declare function BodyContext({ children }: {
58
58
  }): ReactElement;
59
59
  /**
60
60
  * A modal on the browser's own `<dialog>`: it is opened with `showModal()` on mount, so render it
61
- * only while it is open. The page behind goes inert, Esc closes it and focus stays inside; a click
61
+ * only while it is open. The page behind goes inert, Esc closes it and Tab wraps inside it; a click
62
62
  * on the backdrop (the `<dialog>` element itself, not its contents) closes it too, and so does the
63
63
  * close button in its top corner, which every dialog has. The close button comes last in the
64
64
  * keyboard order, so the open focuses the first field, not it. A windowed dialog is never taller
package/dist/Dialog.js CHANGED
@@ -68,7 +68,7 @@ export function BodyContext({ children }) {
68
68
  }
69
69
  /**
70
70
  * A modal on the browser's own `<dialog>`: it is opened with `showModal()` on mount, so render it
71
- * only while it is open. The page behind goes inert, Esc closes it and focus stays inside; a click
71
+ * only while it is open. The page behind goes inert, Esc closes it and Tab wraps inside it; a click
72
72
  * on the backdrop (the `<dialog>` element itself, not its contents) closes it too, and so does the
73
73
  * close button in its top corner, which every dialog has. The close button comes last in the
74
74
  * keyboard order, so the open focuses the first field, not it. A windowed dialog is never taller
package/dist/Drawer.d.ts CHANGED
@@ -35,7 +35,7 @@ export type DrawerProps = {
35
35
  /**
36
36
  * A modal slide-over anchored to the right edge, on the browser's own `<dialog>`: it is opened
37
37
  * with `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc
38
- * closes it and focus stays inside; a click on the scrim (the `<dialog>` element itself, not its
38
+ * closes it and Tab wraps inside it; a click on the scrim (the `<dialog>` element itself, not its
39
39
  * contents) closes it too, and on touch a swipe to the right drags it off (a short one springs
40
40
  * back). The header holds the title, an optional `description` under it and a close button; the
41
41
  * body scrolls between it and an optional pinned `footer`, and a scroll in it never carries on to
package/dist/Drawer.js CHANGED
@@ -85,7 +85,7 @@ function useSwipeClose(dialog) {
85
85
  /**
86
86
  * A modal slide-over anchored to the right edge, on the browser's own `<dialog>`: it is opened
87
87
  * with `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc
88
- * closes it and focus stays inside; a click on the scrim (the `<dialog>` element itself, not its
88
+ * closes it and Tab wraps inside it; a click on the scrim (the `<dialog>` element itself, not its
89
89
  * contents) closes it too, and on touch a swipe to the right drags it off (a short one springs
90
90
  * back). The header holds the title, an optional `description` under it and a close button; the
91
91
  * body scrolls between it and an optional pinned `footer`, and a scroll in it never carries on to
package/dist/Hero.d.ts CHANGED
@@ -14,6 +14,13 @@ export type HeroProps = {
14
14
  * @default Pause the background motion
15
15
  */
16
16
  pauseLabel?: string | undefined;
17
+ /**
18
+ * Where the control that holds the glow still goes. `corner` draws it in the words' top corner.
19
+ * `none` leaves it out of the hero: place a `HeroPause` in a slot of your own (a demo window's
20
+ * bar), or draw none when the page has nothing else to pause it with.
21
+ * @default corner
22
+ */
23
+ pause?: "corner" | "none" | undefined;
17
24
  } & ({
18
25
  /**
19
26
  * A picture beside the words from `md` up, and under them on a phone: an `Image` of the
@@ -43,4 +50,18 @@ export type HeroProps = {
43
50
  * checkbox is not drawn. Pure markup and one inline stylesheet: it works rendered on the server with
44
51
  * no script. One per page, on a landing page; every other page opens with a `PageHeader`.
45
52
  */
46
- export declare function Hero({ overline, title, children, media, align, pauseLabel, ...rest }: HeroProps & Passthrough): ReactElement;
53
+ export declare function Hero({ overline, title, children, media, align, pauseLabel, pause, ...rest }: HeroProps & Passthrough): ReactElement;
54
+ export type HeroPauseProps = {
55
+ /**
56
+ * The control's name, for an app in another language.
57
+ * @default Pause the background motion
58
+ */
59
+ label?: string | undefined;
60
+ };
61
+ /**
62
+ * The control that holds the page's `Hero` glow still, for a slot of the caller's own: a demo
63
+ * window's bar, a toolbar. Use it with `<Hero pause="none">`, once per page; anywhere on the page it
64
+ * pauses the one hero's ribbons while checked, in CSS with no script, and it is not drawn under
65
+ * `prefers-reduced-motion: reduce`, where nothing moves.
66
+ */
67
+ export declare function HeroPause({ label, ...rest }: HeroPauseProps & Passthrough): ReactElement;
package/dist/Hero.js CHANGED
@@ -9,17 +9,23 @@ export const HERO_DRIFT = "hc-hero-tide";
9
9
  // sideways sway and stretch, like light on water, each ribbon on its own period so the three never
10
10
  // line up; it runs only under `prefers-reduced-motion: no-preference`, so a visitor who asks for less
11
11
  // motion sees the ribbons standing at their resting place. The pause control holds the ribbons where
12
- // they are while it is checked, and is not drawn under reduced motion, where nothing moves. It sets
12
+ // they are while it is checked, wherever on the page it is drawn (one Hero per page), and is not drawn under reduced motion, where nothing moves. It sets
13
13
  // no colour (the mask's black and transparent only set how much shows): the theme paints the ribbons.
14
14
  const css = `[data-hero-glow]{mask-image:linear-gradient(to bottom,transparent,black 22%,black 78%,transparent),linear-gradient(to right,transparent,black 8%,black 92%,transparent);mask-composite:intersect}
15
15
  @media (prefers-reduced-motion:no-preference){[data-hero-glow] span{animation:${HERO_DRIFT} 41s ease-in-out -7s infinite alternate}[data-hero-glow] span:nth-child(2){animation-duration:53s;animation-delay:-29s}[data-hero-glow] span:nth-child(3){animation-duration:67s;animation-delay:-43s;animation-direction:alternate-reverse}}
16
16
  @media (prefers-reduced-motion:reduce){[data-hero-pause]{display:none}}
17
- [data-hero-text]:has([data-hero-pause] input:checked) [data-hero-glow] span{animation-play-state:paused}
17
+ :root:has([data-hero-pause] input:checked) [data-hero-glow] span{animation-play-state:paused}
18
18
  @keyframes ${HERO_DRIFT}{0%{translate:-7% 0;scale:1 1}50%{translate:5% 10%;scale:1.14 .86}100%{translate:12% -6%;scale:.92 1.1}}`;
19
19
  /** Every ribbon: an ellipse, blurred soft. Its place, size, tilt and colour follow. */
20
20
  const RIBBON = "absolute rounded-[50%] blur-[56px]";
21
21
  /** The pause control: a round ghost button's look on a checkbox's label, so it works with no script. */
22
- const PAUSE = "absolute top-0 right-0 inline-flex size-8 cursor-pointer items-center justify-center rounded-full text-slate-600 hover:bg-slate-100 has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-violet-600";
22
+ const PAUSE = "inline-flex size-8 cursor-pointer items-center justify-center rounded-full text-slate-600 hover:bg-slate-100 has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-violet-600";
23
+ /** The header keeps clear of the corner control, on both sides when centred, and needs no room without it. */
24
+ function headerGutter(pause, centre) {
25
+ if (pause === "none")
26
+ return undefined;
27
+ return centre ? "px-10" : "pe-10";
28
+ }
23
29
  /**
24
30
  * A landing page's top block: an overline, the display title (the page's `h1`) and the lede under
25
31
  * it, over a soft glow of three tilted ribbons that drift slowly behind the text. The glow is always
@@ -32,11 +38,20 @@ const PAUSE = "absolute top-0 right-0 inline-flex size-8 cursor-pointer items-ce
32
38
  * checkbox is not drawn. Pure markup and one inline stylesheet: it works rendered on the server with
33
39
  * no script. One per page, on a landing page; every other page opens with a `PageHeader`.
34
40
  */
35
- export function Hero({ overline, title, children, media, align = "start", pauseLabel = "Pause the background motion", ...rest }) {
41
+ export function Hero({ overline, title, children, media, align = "start", pauseLabel = "Pause the background motion", pause = "corner", ...rest }) {
36
42
  const centre = align === "center";
37
- const words = (_jsxs("div", { "data-hero-text": "", className: cx("relative isolate max-w-3xl", centre && "mx-auto text-center"), children: [_jsxs("div", { "aria-hidden": "true", "data-hero-glow": "", className: "pointer-events-none absolute inset-x-0 -inset-y-14 -z-10 overflow-hidden", children: [_jsx("span", { className: `${RIBBON} top-[14%] left-[-6%] h-[34%] w-[78%] -rotate-[7deg] bg-indigo-400/25` }), _jsx("span", { className: `${RIBBON} top-[34%] left-[28%] h-[30%] w-[70%] rotate-[4deg] bg-teal-400/25` }), _jsx("span", { className: `${RIBBON} top-[56%] left-[6%] h-[26%] w-[58%] -rotate-[2deg] bg-rose-400/25` })] }), _jsxs("div", { className: "relative flex flex-col gap-4", children: [_jsxs("header", { className: centre ? "px-10" : "pe-10", children: [overline != null && overline !== false && _jsx(Overline, { mono: true, children: overline }), _jsx(Display, { children: title })] }), children] }), _jsxs("label", { "data-hero-pause": "", className: PAUSE, children: [_jsx("input", { type: "checkbox", className: "peer sr-only" }), _jsx("span", { className: "sr-only", children: pauseLabel }), _jsx("span", { className: "inline-flex peer-checked:hidden", children: _jsx(Icon, { name: "pause" }) }), _jsx("span", { className: "hidden peer-checked:inline-flex", children: _jsx(Icon, { name: "play" }) })] })] }));
43
+ const words = (_jsxs("div", { "data-hero-text": "", className: cx("relative isolate max-w-3xl", centre && "mx-auto text-center"), children: [_jsxs("div", { "aria-hidden": "true", "data-hero-glow": "", className: "pointer-events-none absolute inset-x-0 -inset-y-14 -z-10 overflow-hidden", children: [_jsx("span", { className: `${RIBBON} top-[14%] left-[-6%] h-[34%] w-[78%] -rotate-[7deg] bg-indigo-400/25` }), _jsx("span", { className: `${RIBBON} top-[34%] left-[28%] h-[30%] w-[70%] rotate-[4deg] bg-teal-400/25` }), _jsx("span", { className: `${RIBBON} top-[56%] left-[6%] h-[26%] w-[58%] -rotate-[2deg] bg-rose-400/25` })] }), _jsxs("div", { className: "relative flex flex-col gap-4", children: [_jsxs("header", { className: headerGutter(pause, centre), children: [overline != null && overline !== false && _jsx(Overline, { mono: true, children: overline }), _jsx(Display, { children: title })] }), children] }), pause === "corner" && (_jsx("span", { className: "absolute top-0 right-0", children: _jsx(HeroPause, { label: pauseLabel }) }))] }));
38
44
  if (media === undefined) {
39
45
  return (_jsxs("div", { ...rest, children: [_jsx("style", { children: css }), words] }));
40
46
  }
41
47
  return (_jsxs("div", { ...rest, className: "grid items-center gap-8 md:grid-cols-2 md:gap-12", children: [_jsx("style", { children: css }), words, _jsx("div", { className: "min-w-0", children: media })] }));
42
48
  }
49
+ /**
50
+ * The control that holds the page's `Hero` glow still, for a slot of the caller's own: a demo
51
+ * window's bar, a toolbar. Use it with `<Hero pause="none">`, once per page; anywhere on the page it
52
+ * pauses the one hero's ribbons while checked, in CSS with no script, and it is not drawn under
53
+ * `prefers-reduced-motion: reduce`, where nothing moves.
54
+ */
55
+ export function HeroPause({ label = "Pause the background motion", ...rest }) {
56
+ return (_jsxs("label", { ...rest, "data-hero-pause": "", className: PAUSE, children: [_jsx("input", { type: "checkbox", className: "peer sr-only" }), _jsx("span", { className: "sr-only", children: label }), _jsx("span", { className: "inline-flex peer-checked:hidden", children: _jsx(Icon, { name: "pause" }) }), _jsx("span", { className: "hidden peer-checked:inline-flex", children: _jsx(Icon, { name: "play" }) })] }));
57
+ }
@@ -38,7 +38,7 @@ export type LightboxProps = {
38
38
  /**
39
39
  * A full-screen photo or video viewer on the browser's own `<dialog>`: it is opened with
40
40
  * `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc
41
- * closes it and focus stays inside; a click on the scrim around the media and its text closes it
41
+ * closes it and Tab wraps inside it; a click on the scrim around the media and its text closes it
42
42
  * too. The scrim stays near-black with light text in every theme. `onPrevious` and `onNext` add
43
43
  * step buttons and the arrow keys.
44
44
  */
package/dist/Lightbox.js CHANGED
@@ -23,7 +23,7 @@ function ScrimButton({ label, path, onClick, }) {
23
23
  /**
24
24
  * A full-screen photo or video viewer on the browser's own `<dialog>`: it is opened with
25
25
  * `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc
26
- * closes it and focus stays inside; a click on the scrim around the media and its text closes it
26
+ * closes it and Tab wraps inside it; a click on the scrim around the media and its text closes it
27
27
  * too. The scrim stays near-black with light text in every theme. `onPrevious` and `onNext` add
28
28
  * step buttons and the arrow keys.
29
29
  */
package/dist/Popover.d.ts CHANGED
@@ -24,8 +24,8 @@ export type PopoverProps = Passthrough & {
24
24
  /**
25
25
  * A button that opens a small panel of content beside it: a detail, a short list, a filter. It is
26
26
  * the browser's own popover, rendered in place: a click outside it, Esc or the trigger closes it,
27
- * and the focus goes back to the trigger. It is not modal: the page stays usable, and Tab moves from
28
- * the trigger into the panel and on. A list of actions is a `Menu`; a question to answer first is a
27
+ * and the focus goes back to the trigger. Opening it moves the focus into the panel. It is not
28
+ * modal: the page stays usable, and Tab moves on through the panel and out of it. A list of actions is a `Menu`; a question to answer first is a
29
29
  * `Dialog`. `data-*` and `aria-*` land on the trigger.
30
30
  */
31
31
  export declare function Popover({ label, icon, children, size, defaultOpen, ...rest }: PopoverProps): ReactElement;
package/dist/Popover.js CHANGED
@@ -21,8 +21,8 @@ function Face({ icon, label, size }) {
21
21
  /**
22
22
  * A button that opens a small panel of content beside it: a detail, a short list, a filter. It is
23
23
  * the browser's own popover, rendered in place: a click outside it, Esc or the trigger closes it,
24
- * and the focus goes back to the trigger. It is not modal: the page stays usable, and Tab moves from
25
- * the trigger into the panel and on. A list of actions is a `Menu`; a question to answer first is a
24
+ * and the focus goes back to the trigger. Opening it moves the focus into the panel. It is not
25
+ * modal: the page stays usable, and Tab moves on through the panel and out of it. A list of actions is a `Menu`; a question to answer first is a
26
26
  * `Dialog`. `data-*` and `aria-*` land on the trigger.
27
27
  */
28
28
  export function Popover({ label, icon, children, size = "md", defaultOpen = false, ...rest }) {
@@ -31,13 +31,28 @@ export function Popover({ label, icon, children, size = "md", defaultOpen = fals
31
31
  const anchor = `--hc-pop${id.replaceAll(/[^a-zA-Z0-9_-]/g, "")}`;
32
32
  const panel = useRef(null);
33
33
  const [open, setOpen] = useState(false);
34
+ // An open on mount (`defaultOpen`) leaves the focus where it is: nobody asked for the panel.
35
+ const onMount = useRef(false);
34
36
  useEffect(() => {
35
- if (defaultOpen)
36
- panel.current?.showPopover();
37
+ if (!defaultOpen)
38
+ return;
39
+ onMount.current = true;
40
+ panel.current?.showPopover();
37
41
  }, [defaultOpen]);
38
42
  // The tooltip's props come after the caller's, merged with them; its anchor joins the panel's.
39
43
  const trigger = ({ style, ...own }) => (_jsx("button", { ...definedProps(rest), ...own, type: "button", popoverTarget: panelId, "aria-expanded": open, ...(icon ? { "aria-label": label } : {}), className: icon ? look({ variant: "ghost", size }) : buttonClass("outline", { size }), style: { anchorName: [style?.anchorName, anchor].filter(Boolean).join(", ") }, children: _jsx(Face, { icon: icon, label: label, size: size }) }));
40
44
  return (_jsxs(_Fragment, { children: [icon ? (_jsx(Tipped, { text: label, describes: false, own: definedProps(rest), children: trigger })) : (trigger({})), _jsx("div", { ref: panel, id: panelId, popover: "auto", role: "dialog", "aria-label": label,
41
45
  // A click on its text keeps the focus in the panel, so Esc returns it to the trigger.
42
- tabIndex: -1, onToggle: (event) => setOpen(event.newState === "open"), className: PANEL, style: { positionAnchor: anchor }, children: children })] }));
46
+ tabIndex: -1, onToggle: (event) => {
47
+ const opening = event.newState === "open";
48
+ setOpen(opening);
49
+ // Into the panel, so Esc hands the focus back to the trigger (the browser does only
50
+ // when the focus is inside it). The panel itself, not its first control, so a click
51
+ // does not ring a control the person did not choose.
52
+ const el = event.currentTarget;
53
+ const asked = !onMount.current;
54
+ onMount.current = false;
55
+ if (opening && asked && !el.contains(el.ownerDocument.activeElement))
56
+ el.focus();
57
+ }, className: PANEL, style: { positionAnchor: anchor }, children: children })] }));
43
58
  }
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export { AppShell, AppShellBrand, type AppShellDensity, appShellRootClassFor } f
16
16
  export { SiteFooter, type SiteFooterLink } from "./SiteFooter.js";
17
17
  export { Container } from "./Container.js";
18
18
  export { PageHeader } from "./PageHeader.js";
19
- export { Hero } from "./Hero.js";
19
+ export { Hero, HeroPause } from "./Hero.js";
20
20
  export { CardGrid, CenteredLayout, DetailLayout, FormLayout, FullBleedLayout, ListLayout, ProseLayout, } from "./PageLayouts.js";
21
21
  export { ArticleLayout } from "./ArticleLayout.js";
22
22
  export { SidebarLayout } from "./SidebarLayout.js";
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ export { AppShell, AppShellBrand, appShellRootClassFor } from "./AppShell.js";
15
15
  export { SiteFooter } from "./SiteFooter.js";
16
16
  export { Container } from "./Container.js";
17
17
  export { PageHeader } from "./PageHeader.js";
18
- export { Hero } from "./Hero.js";
18
+ export { Hero, HeroPause } from "./Hero.js";
19
19
  export { CardGrid, CenteredLayout, DetailLayout, FormLayout, FullBleedLayout, ListLayout, ProseLayout, } from "./PageLayouts.js";
20
20
  export { ArticleLayout } from "./ArticleLayout.js";
21
21
  export { SidebarLayout } from "./SidebarLayout.js";
package/dist/modal.d.ts CHANGED
@@ -5,7 +5,8 @@ import { type RefObject } from "react";
5
5
  */
6
6
  export declare function useModalOpen(): boolean;
7
7
  /**
8
- * Opens the `<dialog>` with `showModal()` on mount and closes it on unmount. Closing on unmount
8
+ * Opens the `<dialog>` with `showModal()` on mount and closes it on unmount, and keeps Tab inside it
9
+ * while it is open (`wrapTab`). Closing on unmount
9
10
  * (not just on Esc or the backdrop) hands focus back to the opener and drops the inert page behind
10
11
  * when the parent unmounts the dialog, and keeps StrictMode's second mount from reopening an open one.
11
12
  *
package/dist/modal.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { useLayoutEffect, useRef, useSyncExternalStore } from "react";
2
+ import { TABBABLE } from "./scrollStop.js";
2
3
  /** Resolves when the transitions running on the dialog (and its backdrop) have ended. */
3
4
  async function exitTransitions(dialog) {
4
5
  // A browser without the Web Animations API (or jsdom) has nothing to wait for.
@@ -7,6 +8,39 @@ async function exitTransitions(dialog) {
7
8
  const running = dialog.getAnimations({ subtree: true }).filter((a) => "transitionProperty" in a);
8
9
  await Promise.allSettled(running.map((a) => a.finished));
9
10
  }
11
+ /** The tab stops inside `dialog`, in tab order: shown (jsdom has no `checkVisibility`) and not inert. */
12
+ function tabStops(dialog) {
13
+ return [...dialog.querySelectorAll(TABBABLE)].filter((el) => (typeof el.checkVisibility !== "function" || el.checkVisibility()) && !el.closest("[inert]"));
14
+ }
15
+ /**
16
+ * Keeps Tab and Shift+Tab inside an open modal, wrapping from the last tab stop to the first and
17
+ * back (WAI-ARIA APG, dialog). The browser's own modal `<dialog>` lets Tab leave the page for the
18
+ * browser's toolbar before it comes back.
19
+ */
20
+ const plainTab = (event) => event.key === "Tab" &&
21
+ !event.defaultPrevented &&
22
+ !event.altKey &&
23
+ !event.ctrlKey &&
24
+ !event.metaKey;
25
+ function wrapTab(dialog) {
26
+ return (event) => {
27
+ if (!plainTab(event))
28
+ return;
29
+ const stops = tabStops(dialog);
30
+ const first = stops[0];
31
+ const last = stops.at(-1);
32
+ const active = dialog.ownerDocument.activeElement;
33
+ if (!first || !last) {
34
+ event.preventDefault();
35
+ return;
36
+ }
37
+ const leaving = event.shiftKey ? active === first || active === dialog : active === last;
38
+ if (!leaving)
39
+ return;
40
+ event.preventDefault();
41
+ (event.shiftKey ? last : first).focus();
42
+ };
43
+ }
10
44
  /** How many of the library's modals are open, and who wants to hear when that changes. */
11
45
  let openModals = 0;
12
46
  const watchers = new Set();
@@ -26,7 +60,8 @@ export function useModalOpen() {
26
60
  }, () => openModals > 0, () => false);
27
61
  }
28
62
  /**
29
- * Opens the `<dialog>` with `showModal()` on mount and closes it on unmount. Closing on unmount
63
+ * Opens the `<dialog>` with `showModal()` on mount and closes it on unmount, and keeps Tab inside it
64
+ * while it is open (`wrapTab`). Closing on unmount
30
65
  * (not just on Esc or the backdrop) hands focus back to the opener and drops the inert page behind
31
66
  * when the parent unmounts the dialog, and keeps StrictMode's second mount from reopening an open one.
32
67
  *
@@ -40,9 +75,14 @@ export function useModal(dialog, onClose) {
40
75
  const el = dialog.current;
41
76
  mounted.current = true;
42
77
  el?.showModal();
78
+ const trap = el ? wrapTab(el) : undefined;
79
+ if (el && trap)
80
+ el.addEventListener("keydown", trap);
43
81
  opened(1);
44
82
  return () => {
45
83
  mounted.current = false;
84
+ if (el && trap)
85
+ el.removeEventListener("keydown", trap);
46
86
  el?.close();
47
87
  opened(-1);
48
88
  };
@@ -1,7 +1,7 @@
1
1
  import { type ReactElement } from "react";
2
2
  import type { FlowLayout } from "./flowLayout.js";
3
3
  import type { StateMachineItem } from "./StateMachine.js";
4
- export declare const moveCss = "[data-hc-sm-travel]{offset-anchor:center;offset-rotate:0deg;animation:hc-sm-travel .6s ease-in-out forwards}[data-hc-sm-arrive]{animation:hc-sm-arrive .6s linear}[data-hc-sm-shift=\"a\"]{animation:hc-sm-shift-a .6s ease-in-out}[data-hc-sm-shift=\"b\"]{animation:hc-sm-shift-b .6s ease-in-out}@keyframes hc-sm-travel{from{offset-distance:0%}to{offset-distance:100%}}@keyframes hc-sm-arrive{from,to{visibility:hidden}}@keyframes hc-sm-shift-a{from{translate:var(--hc-sm-dx) var(--hc-sm-dy)}}@keyframes hc-sm-shift-b{from{translate:var(--hc-sm-dx) var(--hc-sm-dy)}}@media (prefers-reduced-motion:reduce){[data-hc-sm-travel]{visibility:hidden;animation-duration:1ms}[data-hc-sm-arrive],[data-hc-sm-shift]{animation:none}}";
4
+ export declare const moveCss = "[data-hc-sm-travel]{offset-anchor:center;offset-rotate:0deg;animation:hc-sm-travel .6s ease-in-out forwards}[data-hc-sm-arrive]{animation:hc-sm-arrive .6s linear}[data-hc-sm-shift=\"a\"]{animation:hc-sm-shift-a .6s ease-in-out}[data-hc-sm-shift=\"b\"]{animation:hc-sm-shift-b .6s ease-in-out}@keyframes hc-sm-travel{from{offset-distance:0%}to{offset-distance:100%;visibility:hidden}}@keyframes hc-sm-arrive{from,to{visibility:hidden}}@keyframes hc-sm-shift-a{from{translate:var(--hc-sm-dx) var(--hc-sm-dy)}}@keyframes hc-sm-shift-b{from{translate:var(--hc-sm-dx) var(--hc-sm-dy)}}@media (prefers-reduced-motion:reduce){[data-hc-sm-travel]{visibility:hidden;animation-duration:1ms}[data-hc-sm-arrive],[data-hc-sm-shift]{animation:none}}";
5
5
  /**
6
6
  * Where an item's dot sits: its box, its slot there (`null` when it is one of the dots a full box
7
7
  * hides behind its `+N`), and the number of slots the box draws.
@@ -6,10 +6,12 @@ import { COLS, DOT_X, LIMIT, placeOf, SLOT_H, SLOT_W, slotAt, slotsFor, } from "
6
6
  // its new place waits hidden for the same time; a dot that stays in its box but changes slot (one
7
7
  // before it left, or one came in) slides from its old slot to its new one (`translate`, from the
8
8
  // `--hc-sm-dx` and `--hc-sm-dy` it is given), under two keyframe names taken in turn so a second
9
- // slide restarts. Nothing is timed in script: each ends on its own `animationend`. With reduced
9
+ // slide restarts. Nothing is timed in script: each ends on its own `animationend`. A run's last
10
+ // frame is hidden, so a landed run looks the same before and after that event removes it (a shot
11
+ // taken once the animations are finished never catches it sitting on its new dot). With reduced
10
12
  // motion the run is hidden and over at once (so it still ends), and every dot is in its new place
11
13
  // at once.
12
- export const moveCss = `[data-hc-sm-travel]{offset-anchor:center;offset-rotate:0deg;animation:hc-sm-travel .6s ease-in-out forwards}[data-hc-sm-arrive]{animation:hc-sm-arrive .6s linear}[data-hc-sm-shift="a"]{animation:hc-sm-shift-a .6s ease-in-out}[data-hc-sm-shift="b"]{animation:hc-sm-shift-b .6s ease-in-out}@keyframes hc-sm-travel{from{offset-distance:0%}to{offset-distance:100%}}@keyframes hc-sm-arrive{from,to{visibility:hidden}}@keyframes hc-sm-shift-a{from{translate:var(--hc-sm-dx) var(--hc-sm-dy)}}@keyframes hc-sm-shift-b{from{translate:var(--hc-sm-dx) var(--hc-sm-dy)}}@media (prefers-reduced-motion:reduce){[data-hc-sm-travel]{visibility:hidden;animation-duration:1ms}[data-hc-sm-arrive],[data-hc-sm-shift]{animation:none}}`;
14
+ export const moveCss = `[data-hc-sm-travel]{offset-anchor:center;offset-rotate:0deg;animation:hc-sm-travel .6s ease-in-out forwards}[data-hc-sm-arrive]{animation:hc-sm-arrive .6s linear}[data-hc-sm-shift="a"]{animation:hc-sm-shift-a .6s ease-in-out}[data-hc-sm-shift="b"]{animation:hc-sm-shift-b .6s ease-in-out}@keyframes hc-sm-travel{from{offset-distance:0%}to{offset-distance:100%;visibility:hidden}}@keyframes hc-sm-arrive{from,to{visibility:hidden}}@keyframes hc-sm-shift-a{from{translate:var(--hc-sm-dx) var(--hc-sm-dy)}}@keyframes hc-sm-shift-b{from{translate:var(--hc-sm-dx) var(--hc-sm-dy)}}@media (prefers-reduced-motion:reduce){[data-hc-sm-travel]{visibility:hidden;animation-duration:1ms}[data-hc-sm-arrive],[data-hc-sm-shift]{animation:none}}`;
13
15
  /** The slot of the `i`th of `count` items in a box: its own, or `null` when the `+N` hides it. */
14
16
  function slotOf(i, count, open) {
15
17
  return count <= LIMIT || open || i < LIMIT - 1 ? i : null;
@@ -127,10 +127,12 @@ export function useFlowLayout(nodes, edges, direction, options = {}) {
127
127
  label: e.label ? (measured[edgeKey(index)] ?? guessLabel(e.label)) : undefined,
128
128
  }));
129
129
  const key = JSON.stringify([direction, options.spacing, layoutNodes, layoutEdges]);
130
- // The key holds every input the layout reads, so the layout reruns only when one changes.
131
- const drawn = useMemo(() => layoutFlow(layoutNodes, layoutEdges, direction, options.spacing),
132
- // oxlint-disable-next-line react-hooks/exhaustive-deps -- keyed on the serialised input above
133
- [key]);
130
+ // The layout reads its input back from the key, so the key is its one dependency and the layout
131
+ // reruns only when a size, an id or a gap changes, not on every render's fresh arrays.
132
+ const drawn = useMemo(() => {
133
+ const [d, spacing, n, e] = JSON.parse(key);
134
+ return layoutFlow(n, e, d, spacing ?? undefined);
135
+ }, [key]);
134
136
  useLayoutEffect(() => {
135
137
  const root = canvas.current;
136
138
  if (!root)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slashsuite/ui-react",
3
- "version": "0.16.2",
3
+ "version": "0.16.4",
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",
@@ -52,7 +52,7 @@
52
52
  "prepack": "bun run build && bun run agent-docs"
53
53
  },
54
54
  "dependencies": {
55
- "@dagrejs/dagre": "^3.1.3",
55
+ "@dagrejs/dagre": "^3.1.4",
56
56
  "@internationalized/date": "^3.12.4",
57
57
  "react-aria-components": "^1.22.1"
58
58
  },
@@ -60,15 +60,15 @@
60
60
  "@slashsuite/core": "0.0.0",
61
61
  "@testing-library/dom": "10.4.2",
62
62
  "@testing-library/react": "16.3.3",
63
- "@testing-library/user-event": "14.6.12",
64
- "@types/bun": "1.4.4",
65
- "@types/react": "^19.3.0",
63
+ "@testing-library/user-event": "14.6.13",
64
+ "@types/bun": "1.4.5",
65
+ "@types/react": "^19.3.1",
66
66
  "@types/react-dom": "^19.3.0",
67
67
  "jsdom": "^31.0.1",
68
68
  "react": "^19.3.1",
69
69
  "react-dom": "^19.3.1",
70
70
  "tailwindcss": "^4.3.5",
71
- "vitest": "5.1.0"
71
+ "vitest": "5.1.1"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "@types/react": ">=18",