@slashsuite/ui-react 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATING.md +386 -8
- package/README.md +101 -44
- package/agent-docs/components/app-shell.md +139 -0
- package/agent-docs/components/article-layout.md +140 -0
- package/agent-docs/components/audio.md +42 -0
- package/agent-docs/components/avatar-stack.md +64 -0
- package/agent-docs/components/avatar.md +76 -0
- package/agent-docs/components/badge.md +62 -0
- package/agent-docs/components/body-text.md +169 -0
- package/agent-docs/components/bottom-sheet.md +105 -0
- package/agent-docs/components/breadcrumbs.md +66 -0
- package/agent-docs/components/bullet-list.md +54 -0
- package/agent-docs/components/button.md +135 -0
- package/agent-docs/components/call-to-action.md +59 -0
- package/agent-docs/components/callout.md +87 -0
- package/agent-docs/components/card-grid.md +116 -0
- package/agent-docs/components/card.md +128 -0
- package/agent-docs/components/cart-button.md +63 -0
- package/agent-docs/components/centered-layout.md +90 -0
- package/agent-docs/components/chat-composer.md +49 -0
- package/agent-docs/components/chat-message.md +61 -0
- package/agent-docs/components/chat-thread.md +49 -0
- package/agent-docs/components/checkbox.md +81 -0
- package/agent-docs/components/cluster.md +108 -0
- package/agent-docs/components/code-example.md +48 -0
- package/agent-docs/components/code.md +72 -0
- package/agent-docs/components/colour-scheme-toggle.md +98 -0
- package/agent-docs/components/colour-swatch.md +41 -0
- package/agent-docs/components/combobox.md +88 -0
- package/agent-docs/components/confirm-dialog.md +98 -0
- package/agent-docs/components/container.md +51 -0
- package/agent-docs/components/copy-button.md +63 -0
- package/agent-docs/components/copy-line.md +55 -0
- package/agent-docs/components/date-field.md +106 -0
- package/agent-docs/components/date-range-picker.md +108 -0
- package/agent-docs/components/date-time-field.md +73 -0
- package/agent-docs/components/detail-layout.md +147 -0
- package/agent-docs/components/dialog.md +132 -0
- package/agent-docs/components/disclosure.md +70 -0
- package/agent-docs/components/divider.md +62 -0
- package/agent-docs/components/docs-layout.md +164 -0
- package/agent-docs/components/drawer.md +137 -0
- package/agent-docs/components/embed-frame.md +48 -0
- package/agent-docs/components/empty-state.md +70 -0
- package/agent-docs/components/field-dialog.md +98 -0
- package/agent-docs/components/field.md +71 -0
- package/agent-docs/components/fieldset.md +82 -0
- package/agent-docs/components/file-drop.md +52 -0
- package/agent-docs/components/flow-diagram.md +87 -0
- package/agent-docs/components/form-layout.md +144 -0
- package/agent-docs/components/form-row.md +93 -0
- package/agent-docs/components/full-bleed-layout.md +114 -0
- package/agent-docs/components/headings.md +107 -0
- package/agent-docs/components/hero.md +68 -0
- package/agent-docs/components/icon-button.md +90 -0
- package/agent-docs/components/icon.md +59 -0
- package/agent-docs/components/image.md +74 -0
- package/agent-docs/components/input.md +84 -0
- package/agent-docs/components/kbd.md +38 -0
- package/agent-docs/components/key-value-list.md +84 -0
- package/agent-docs/components/lightbox.md +97 -0
- package/agent-docs/components/list-layout.md +152 -0
- package/agent-docs/components/list-row.md +119 -0
- package/agent-docs/components/loading.md +69 -0
- package/agent-docs/components/markdown.md +51 -0
- package/agent-docs/components/media-tile.md +101 -0
- package/agent-docs/components/menu.md +110 -0
- package/agent-docs/components/meta-list.md +69 -0
- package/agent-docs/components/morph.md +134 -0
- package/agent-docs/components/navigation-progress.md +56 -0
- package/agent-docs/components/number-field.md +75 -0
- package/agent-docs/components/outline-region.md +74 -0
- package/agent-docs/components/page-fade.md +117 -0
- package/agent-docs/components/page-header.md +93 -0
- package/agent-docs/components/pagination.md +64 -0
- package/agent-docs/components/pill.md +105 -0
- package/agent-docs/components/popover.md +63 -0
- package/agent-docs/components/price.md +49 -0
- package/agent-docs/components/product-tile.md +78 -0
- package/agent-docs/components/progress-bar.md +66 -0
- package/agent-docs/components/promo-banner.md +46 -0
- package/agent-docs/components/prose-layout.md +87 -0
- package/agent-docs/components/prose.md +41 -0
- package/agent-docs/components/radio-group.md +77 -0
- package/agent-docs/components/scroll-strip.md +48 -0
- package/agent-docs/components/segmented-control.md +135 -0
- package/agent-docs/components/select.md +70 -0
- package/agent-docs/components/show.md +120 -0
- package/agent-docs/components/side-column.md +74 -0
- package/agent-docs/components/sidebar-layout.md +134 -0
- package/agent-docs/components/site-footer.md +63 -0
- package/agent-docs/components/site-search.md +79 -0
- package/agent-docs/components/slider.md +59 -0
- package/agent-docs/components/sortable-list.md +112 -0
- package/agent-docs/components/split-bar.md +54 -0
- package/agent-docs/components/stack.md +197 -0
- package/agent-docs/components/stacked-bar.md +91 -0
- package/agent-docs/components/stat-tile.md +69 -0
- package/agent-docs/components/state-machine.md +95 -0
- package/agent-docs/components/status-pages.md +112 -0
- package/agent-docs/components/stepper.md +54 -0
- package/agent-docs/components/steps.md +74 -0
- package/agent-docs/components/sticky-bar.md +51 -0
- package/agent-docs/components/switch.md +79 -0
- package/agent-docs/components/table-of-contents.md +78 -0
- package/agent-docs/components/table.md +384 -0
- package/agent-docs/components/tabs.md +178 -0
- package/agent-docs/components/text-link.md +110 -0
- package/agent-docs/components/textarea.md +53 -0
- package/agent-docs/components/timeline.md +79 -0
- package/agent-docs/components/toast.md +91 -0
- package/agent-docs/components/trend-chart.md +61 -0
- package/agent-docs/components/video.md +49 -0
- package/agent-docs/llms.txt +174 -0
- package/dist/AppShell.d.ts +25 -9
- package/dist/AppShell.js +67 -33
- package/dist/AppShellMenu.d.ts +31 -18
- package/dist/AppShellMenu.js +72 -45
- package/dist/ArticleLayout.d.ts +36 -0
- package/dist/ArticleLayout.js +27 -0
- package/dist/Audio.d.ts +16 -0
- package/dist/Audio.js +11 -0
- package/dist/Badge.d.ts +2 -1
- package/dist/Badge.js +3 -2
- package/dist/BottomSheet.d.ts +17 -6
- package/dist/BottomSheet.js +62 -11
- package/dist/Breadcrumbs.d.ts +8 -6
- package/dist/Breadcrumbs.js +17 -7
- package/dist/Button.d.ts +1 -0
- package/dist/Button.js +4 -3
- package/dist/CallToAction.d.ts +25 -0
- package/dist/CallToAction.js +17 -0
- package/dist/Callout.d.ts +2 -2
- package/dist/Callout.js +2 -2
- package/dist/Card.d.ts +88 -31
- package/dist/Card.js +55 -92
- package/dist/CardBody.d.ts +2 -0
- package/dist/CardBody.js +33 -3
- package/dist/CardGrid.d.ts +32 -4
- package/dist/CardGrid.js +42 -8
- package/dist/CardParts.d.ts +7 -1
- package/dist/CardParts.js +7 -2
- package/dist/CartButton.d.ts +33 -0
- package/dist/CartButton.js +18 -0
- package/dist/ChatComposer.d.ts +10 -4
- package/dist/ChatComposer.js +35 -13
- package/dist/Checkbox.d.ts +21 -3
- package/dist/Checkbox.js +66 -20
- package/dist/Chevron.js +1 -1
- package/dist/Cluster.d.ts +28 -15
- package/dist/Cluster.js +21 -4
- package/dist/Code.d.ts +15 -3
- package/dist/Code.js +23 -3
- package/dist/CodeBlock.d.ts +4 -4
- package/dist/CodeBlock.js +2 -2
- package/dist/CodeBody.d.ts +1 -1
- package/dist/CodeBody.js +4 -10
- package/dist/CodeExample.d.ts +1 -1
- package/dist/CodeExample.js +3 -2
- package/dist/ColourSchemeToggle.d.ts +21 -5
- package/dist/ColourSchemeToggle.js +15 -9
- package/dist/ColourSwatch.d.ts +15 -0
- package/dist/ColourSwatch.js +14 -0
- package/dist/Combobox.d.ts +42 -0
- package/dist/Combobox.js +43 -0
- package/dist/ConfirmDialog.d.ts +40 -0
- package/dist/ConfirmDialog.js +36 -0
- package/dist/Container.d.ts +3 -3
- package/dist/Container.js +1 -1
- package/dist/CopyButton.d.ts +8 -2
- package/dist/CopyButton.js +38 -28
- package/dist/CopyLine.d.ts +4 -2
- package/dist/CopyLine.js +4 -4
- package/dist/DateCalendar.d.ts +2 -0
- package/dist/DateCalendar.js +11 -9
- package/dist/DateField.d.ts +52 -21
- package/dist/DateField.js +73 -37
- package/dist/DateFieldCalendar.d.ts +12 -8
- package/dist/DateFieldCalendar.js +37 -18
- package/dist/DateRangePicker.d.ts +23 -3
- package/dist/DateRangePicker.js +10 -8
- package/dist/DateTimeField.d.ts +31 -0
- package/dist/DateTimeField.js +19 -0
- package/dist/Dialog.d.ts +42 -6
- package/dist/Dialog.js +50 -12
- package/dist/Disclosure.js +9 -1
- package/dist/DocsLayout.d.ts +13 -5
- package/dist/DocsLayout.js +11 -9
- package/dist/Drawer.d.ts +22 -7
- package/dist/Drawer.js +89 -8
- package/dist/EmbedFrame.d.ts +36 -0
- package/dist/EmbedFrame.js +18 -0
- package/dist/Field.d.ts +41 -4
- package/dist/Field.js +61 -25
- package/dist/FieldDialog.d.ts +8 -3
- package/dist/FieldDialog.js +19 -9
- package/dist/Fieldset.d.ts +3 -3
- package/dist/Fieldset.js +7 -9
- package/dist/FileDrop.js +2 -1
- package/dist/FlowDiagram.d.ts +92 -0
- package/dist/FlowDiagram.js +100 -0
- package/dist/FormRow.d.ts +6 -4
- package/dist/FormRow.js +11 -9
- package/dist/Hero.d.ts +30 -7
- package/dist/Hero.js +23 -9
- package/dist/Icon.d.ts +1 -1
- package/dist/Icon.js +1 -1
- package/dist/IconButton.js +1 -1
- package/dist/Image.d.ts +33 -9
- package/dist/Image.js +61 -16
- package/dist/Input.d.ts +1 -1
- package/dist/Input.js +4 -4
- package/dist/InputShell.d.ts +7 -0
- package/dist/InputShell.js +18 -3
- package/dist/KeyValueList.d.ts +2 -2
- package/dist/Lightbox.js +5 -3
- package/dist/ListRow.d.ts +4 -5
- package/dist/ListRow.js +36 -26
- package/dist/Mark.d.ts +10 -0
- package/dist/Mark.js +9 -0
- package/dist/Markdown.d.ts +18 -4
- package/dist/Markdown.js +176 -37
- package/dist/MediaTile.d.ts +9 -3
- package/dist/MediaTile.js +8 -4
- package/dist/Menu.d.ts +19 -8
- package/dist/Menu.js +13 -11
- package/dist/MetaList.d.ts +4 -3
- package/dist/MetaList.js +12 -4
- package/dist/Morph.d.ts +15 -1
- package/dist/Morph.js +70 -22
- package/dist/NavigationProgress.d.ts +2 -2
- package/dist/NavigationProgress.js +7 -5
- package/dist/NumberField.d.ts +66 -0
- package/dist/NumberField.js +68 -0
- package/dist/OutlineRegion.d.ts +41 -10
- package/dist/OutlineRegion.js +31 -6
- package/dist/PageFade.d.ts +9 -5
- package/dist/PageFade.js +39 -8
- package/dist/PageLayouts.d.ts +15 -5
- package/dist/PageLayouts.js +3 -3
- package/dist/Pill.d.ts +9 -4
- package/dist/Pill.js +15 -6
- package/dist/Popover.d.ts +31 -0
- package/dist/Popover.js +43 -0
- package/dist/Price.d.ts +21 -0
- package/dist/Price.js +34 -0
- package/dist/ProductTile.d.ts +36 -0
- package/dist/ProductTile.js +31 -0
- package/dist/ProgressBar.js +4 -2
- package/dist/PromoBanner.d.ts +25 -0
- package/dist/PromoBanner.js +16 -0
- package/dist/RadioGroup.d.ts +18 -8
- package/dist/RadioGroup.js +42 -18
- package/dist/ScrollStrip.d.ts +1 -1
- package/dist/ScrollStrip.js +1 -1
- package/dist/SearchInput.d.ts +17 -2
- package/dist/SearchInput.js +72 -13
- package/dist/SegmentedField.d.ts +15 -0
- package/dist/SegmentedField.js +15 -0
- package/dist/Select.js +5 -4
- package/dist/Show.d.ts +1 -1
- package/dist/Show.js +1 -1
- package/dist/SideColumn.d.ts +42 -15
- package/dist/SideColumn.js +45 -19
- package/dist/SiteFooter.d.ts +3 -3
- package/dist/SiteFooter.js +4 -3
- package/dist/SiteSearch.d.ts +57 -27
- package/dist/SiteSearch.js +13 -93
- package/dist/Slider.d.ts +27 -0
- package/dist/Slider.js +58 -0
- package/dist/SortableList.d.ts +19 -35
- package/dist/SortableList.js +36 -88
- package/dist/Stack.d.ts +4 -4
- package/dist/StackedBar.d.ts +13 -4
- package/dist/StackedBar.js +12 -7
- package/dist/StateMachine.d.ts +65 -0
- package/dist/StateMachine.js +113 -0
- package/dist/StatusPages.d.ts +28 -10
- package/dist/StatusPages.js +10 -10
- package/dist/Stepper.d.ts +21 -0
- package/dist/Stepper.js +33 -0
- package/dist/Steps.js +4 -3
- package/dist/Switch.d.ts +3 -3
- package/dist/Switch.js +18 -14
- package/dist/Table.d.ts +32 -9
- package/dist/Table.js +50 -20
- package/dist/TableCells.d.ts +24 -21
- package/dist/TableCells.js +68 -27
- package/dist/TableEditCell.d.ts +1 -1
- package/dist/TableOfContents.d.ts +34 -0
- package/dist/TableOfContents.js +23 -0
- package/dist/Tabs.d.ts +31 -16
- package/dist/Tabs.js +97 -22
- package/dist/TextLink.d.ts +18 -5
- package/dist/TextLink.js +19 -6
- package/dist/Textarea.d.ts +12 -1
- package/dist/Textarea.js +15 -2
- package/dist/ToastRegion.d.ts +17 -9
- package/dist/ToastRegion.js +70 -13
- package/dist/Tooltip.d.ts +10 -2
- package/dist/Tooltip.js +32 -11
- package/dist/Video.d.ts +19 -4
- package/dist/Video.js +15 -5
- package/dist/cardContext.d.ts +7 -0
- package/dist/cardContext.js +14 -0
- package/dist/cardControl.d.ts +15 -0
- package/dist/cardControl.js +32 -0
- package/dist/cardForm.d.ts +39 -0
- package/dist/cardForm.js +81 -0
- package/dist/cardWait.js +2 -1
- package/dist/colourScheme.d.ts +12 -2
- package/dist/colourScheme.js +32 -6
- package/dist/control.d.ts +30 -8
- package/dist/control.js +74 -7
- package/dist/copyScript.d.ts +7 -8
- package/dist/copyScript.js +8 -9
- package/dist/cx.d.ts +22 -3
- package/dist/cx.js +22 -3
- package/dist/dateLocale.d.ts +17 -0
- package/dist/dateLocale.js +30 -0
- package/dist/density.d.ts +15 -1
- package/dist/density.js +27 -8
- package/dist/emptySlot.d.ts +1 -0
- package/dist/fieldAnnounce.d.ts +11 -0
- package/dist/fieldAnnounce.js +36 -0
- package/dist/fieldControl.d.ts +7 -2
- package/dist/fieldControl.js +6 -2
- package/dist/fieldWait.d.ts +3 -3
- package/dist/fieldWait.js +3 -4
- package/dist/flowLayout.d.ts +68 -0
- package/dist/flowLayout.js +105 -0
- package/dist/fromXState.d.ts +73 -0
- package/dist/fromXState.js +110 -0
- package/dist/icons.d.ts +1 -1
- package/dist/icons.js +15 -0
- package/dist/index.d.ts +37 -11
- package/dist/index.js +24 -2
- package/dist/isoDate.d.ts +8 -1
- package/dist/isoDate.js +20 -1
- package/dist/labelWords.d.ts +16 -7
- package/dist/labelWords.js +14 -12
- package/dist/listRowProps.d.ts +17 -15
- package/dist/modal.d.ts +5 -0
- package/dist/modal.js +21 -1
- package/dist/navFold.js +6 -3
- package/dist/optionCard.d.ts +18 -0
- package/dist/optionCard.js +16 -0
- package/dist/scrollBody.d.ts +16 -0
- package/dist/scrollBody.js +15 -0
- package/dist/scrollEdges.d.ts +7 -0
- package/dist/scrollEdges.js +39 -5
- package/dist/scrollStop.d.ts +6 -2
- package/dist/scrollStop.js +24 -8
- package/dist/shownDate.d.ts +28 -10
- package/dist/shownDate.js +41 -22
- package/dist/siteSearchBody.d.ts +34 -0
- package/dist/siteSearchBody.js +117 -0
- package/dist/size.d.ts +7 -1
- package/dist/sortableDrop.d.ts +44 -0
- package/dist/sortableDrop.js +78 -0
- package/dist/sortableSlide.d.ts +9 -0
- package/dist/sortableSlide.js +70 -0
- package/dist/sortableTitle.d.ts +10 -0
- package/dist/sortableTitle.js +48 -0
- package/dist/stateMachineDots.d.ts +45 -0
- package/dist/stateMachineDots.js +162 -0
- package/dist/stickyColumn.d.ts +2 -2
- package/dist/stickyColumn.js +2 -2
- package/dist/switcher.d.ts +10 -5
- package/dist/switcher.js +7 -5
- package/dist/tableColumns.d.ts +17 -0
- package/dist/tableColumns.js +30 -2
- package/dist/tableEmpty.js +5 -5
- package/dist/tableRow.d.ts +26 -2
- package/dist/tableRow.js +23 -1
- package/dist/tableSort.d.ts +10 -5
- package/dist/tableSort.js +15 -4
- package/dist/target.d.ts +12 -0
- package/dist/target.js +12 -0
- package/dist/textBox.js +1 -1
- package/dist/truncated.d.ts +31 -0
- package/dist/truncated.js +51 -0
- package/dist/typography.d.ts +19 -11
- package/dist/typography.js +11 -13
- package/dist/useFlowLayout.d.ts +27 -0
- package/dist/useFlowLayout.js +119 -0
- package/package.json +7 -3
- package/skills/uislash/SKILL.md +20 -0
package/dist/AppShell.d.ts
CHANGED
|
@@ -4,9 +4,15 @@ import type { Passthrough } from "./props.js";
|
|
|
4
4
|
import type { Size } from "./size.js";
|
|
5
5
|
/**
|
|
6
6
|
* The class an app puts on its own `<html>`: it always reserves the scrollbar, so centred content
|
|
7
|
-
* does not shift between a short page and a long one
|
|
7
|
+
* does not shift between a short page and a long one, and it paints the page canvas and sets the
|
|
8
|
+
* type face, ink and font smoothing, so a page outside AppShell (a `CenteredLayout` sign-in, a bare
|
|
9
|
+
* error page) looks like one inside it and an app writes no `<body>` or `<html>` styling of its own.
|
|
10
|
+
* A theme's scope class sits on the same element, where its `.<scope> .<utility>` rules do not reach,
|
|
11
|
+
* so the scope block itself sets the canvas, ink and face (unlayered, over these layered utilities).
|
|
12
|
+
* AppShell never touches `<html>` itself. Several classes: add them with `className`, or split them
|
|
13
|
+
* for `classList.add(...)`.
|
|
8
14
|
*/
|
|
9
|
-
export declare const appShellRootClass = "overflow-y-scroll";
|
|
15
|
+
export declare const appShellRootClass = "overflow-y-scroll bg-gray-50 font-sans text-slate-900 antialiased";
|
|
10
16
|
/**
|
|
11
17
|
* Everything an app puts on its own `<html>` from the scheme the server knows: that scheme's class
|
|
12
18
|
* (`schemeClass`) and the shell's root class, joined: `<html className={appShellRootClassFor(scheme,
|
|
@@ -57,8 +63,9 @@ export type AppShellDensity = "compact";
|
|
|
57
63
|
*
|
|
58
64
|
* On a phone (below `md`) the header is one 56px row at every page: `brand`, `header`, `controls`
|
|
59
65
|
* and a "Menu" button (`menuLabel`), and `nav` and `subnav` move into that menu, so every link is
|
|
60
|
-
* reachable and nothing scrolls sideways. The menu is
|
|
61
|
-
* keyboard,
|
|
66
|
+
* reachable and nothing scrolls sideways. The menu is the browser's popover (`popovertarget`), so
|
|
67
|
+
* it works with the keyboard, closes on Escape and a click outside, hands focus back to the button,
|
|
68
|
+
* and opens on a page that never hydrates. From `md` the header is the
|
|
62
69
|
* row, and the `subnav` row, as they are, except that a `nav` too wide for the row folds into the
|
|
63
70
|
* Menu and comes back when the screen is wide enough (measured, with script; a `subnav` never
|
|
64
71
|
* folds, it scrolls sideways with a fade).
|
|
@@ -70,10 +77,12 @@ export type AppShellDensity = "compact";
|
|
|
70
77
|
*
|
|
71
78
|
* `controls` stay in the row at every width, so keep them few (a theme toggle, the viewer's avatar);
|
|
72
79
|
* on a phone a crowded `controls` clips, and the Menu button is never the part cut off. Pickers and
|
|
73
|
-
* actions that do not fit a phone row go in `menuControls`: rendered once, they sit
|
|
74
|
-
* `
|
|
80
|
+
* actions that do not fit a phone row go in `menuControls`: rendered once, from `md` they sit at the
|
|
81
|
+
* row's end, before `header` and `controls`, and fold into the Menu with a `nav` that does not fit;
|
|
82
|
+
* below `md` they are at the foot of the Menu, after `nav` and `subnav`. The markup is in the order
|
|
83
|
+
* the row shows, so the focus moves as the eye does.
|
|
75
84
|
*/
|
|
76
|
-
export declare function AppShell({ brand, nav, controls, menuControls, header, subnav, menuLabel, footer, bleed, printChrome, density, children, ...rest }: {
|
|
85
|
+
export declare function AppShell({ brand, nav, controls, menuControls, header, subnav, menuLabel, footer, bleed, printChrome, density, skipLabel, children, ...rest }: {
|
|
77
86
|
/** The brand: a logo and a name, in the header's brand type, with the gap between them. `AppShellBrand` makes both one link. */
|
|
78
87
|
brand?: ReactNode;
|
|
79
88
|
/** The main navigation, e.g. a `Tabs` of links (it is already a `<nav>`). Below `md` it is in the menu. */
|
|
@@ -82,8 +91,9 @@ export declare function AppShell({ brand, nav, controls, menuControls, header, s
|
|
|
82
91
|
controls?: ReactNode;
|
|
83
92
|
/**
|
|
84
93
|
* Pickers and actions that do not fit a phone row, such as a project `Select` and a Sign out
|
|
85
|
-
* `Button`. From `md` they sit
|
|
86
|
-
* Menu
|
|
94
|
+
* `Button`. From `md` they sit at the row's end, before `header` and `controls`, and fold into the
|
|
95
|
+
* Menu with the `nav`; below `md` they are at the foot of the Menu, after `nav` and `subnav`.
|
|
96
|
+
* Rendered once, so a field keeps its state and ids stay unique.
|
|
87
97
|
* `controls` stay in the row at every width, so keep those few.
|
|
88
98
|
*/
|
|
89
99
|
menuControls?: ReactNode;
|
|
@@ -123,5 +133,11 @@ export declare function AppShell({ brand, nav, controls, menuControls, header, s
|
|
|
123
133
|
* one step down everywhere inside, for an app's dense chrome. Left out, text is 16px, as a site's.
|
|
124
134
|
*/
|
|
125
135
|
density?: AppShellDensity | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* The skip link's words, for an app in another language. The link is the page's first tab stop,
|
|
138
|
+
* hidden until it has the focus, and moves the focus past the header to the main area.
|
|
139
|
+
* @default Skip to content
|
|
140
|
+
*/
|
|
141
|
+
skipLabel?: string;
|
|
126
142
|
children: ReactNode;
|
|
127
143
|
} & Passthrough): ReactElement;
|
package/dist/AppShell.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useState } from "react";
|
|
3
|
-
import {
|
|
2
|
+
import { useCallback, useId, useState } from "react";
|
|
3
|
+
import { AppShellMenuButton, AppShellMenuPanel } from "./AppShellMenu.js";
|
|
4
4
|
import { ContainerFrame } from "./Container.js";
|
|
5
5
|
import { schemeClass } from "./colourScheme.js";
|
|
6
6
|
import { cx, focusRing } from "./cx.js";
|
|
@@ -10,9 +10,15 @@ import { useNavFold } from "./navFold.js";
|
|
|
10
10
|
import { useScrollEdges } from "./scrollEdges.js";
|
|
11
11
|
/**
|
|
12
12
|
* The class an app puts on its own `<html>`: it always reserves the scrollbar, so centred content
|
|
13
|
-
* does not shift between a short page and a long one
|
|
13
|
+
* does not shift between a short page and a long one, and it paints the page canvas and sets the
|
|
14
|
+
* type face, ink and font smoothing, so a page outside AppShell (a `CenteredLayout` sign-in, a bare
|
|
15
|
+
* error page) looks like one inside it and an app writes no `<body>` or `<html>` styling of its own.
|
|
16
|
+
* A theme's scope class sits on the same element, where its `.<scope> .<utility>` rules do not reach,
|
|
17
|
+
* so the scope block itself sets the canvas, ink and face (unlayered, over these layered utilities).
|
|
18
|
+
* AppShell never touches `<html>` itself. Several classes: add them with `className`, or split them
|
|
19
|
+
* for `classList.add(...)`.
|
|
14
20
|
*/
|
|
15
|
-
export const appShellRootClass = "overflow-y-scroll";
|
|
21
|
+
export const appShellRootClass = "overflow-y-scroll bg-gray-50 font-sans text-slate-900 antialiased";
|
|
16
22
|
/**
|
|
17
23
|
* Everything an app puts on its own `<html>` from the scheme the server knows: that scheme's class
|
|
18
24
|
* (`schemeClass`) and the shell's root class, joined: `<html className={appShellRootClassFor(scheme,
|
|
@@ -41,8 +47,10 @@ export function AppShellBrand({ logo, logoSize = "md", label, collapse = false,
|
|
|
41
47
|
const ROW = "items-center gap-4 overflow-x-clip whitespace-nowrap md:overflow-x-auto *:shrink-0";
|
|
42
48
|
// From `md`, while a row has more to scroll to on a side, that edge fades out (a mask, so it follows
|
|
43
49
|
// any theme). `ScrollRow` sets `data-more-start` / `data-more-end` (and `data-more` for either); a
|
|
44
|
-
// row that fits has none and is untouched.
|
|
45
|
-
|
|
50
|
+
// row that fits has none and is untouched. The gradient runs from the inline start, so it flips
|
|
51
|
+
// right to left. While the keyboard's focus is in the row (`focus-visible`) the mask is off, so a
|
|
52
|
+
// focus ring at a faded edge stays whole. Below `md` there is no mask, which would clip the menu.
|
|
53
|
+
const FADE = "[--fade-dir:to_right] rtl:[--fade-dir:to_left] md:data-more-start:[--fade-start:2rem] md:data-more-end:[--fade-end:2rem] md:data-more:[mask-image:linear-gradient(var(--fade-dir),transparent,#000_var(--fade-start,0px),#000_calc(100%_-_var(--fade-end,0px)),transparent)] md:data-more:has-focus-visible:[mask-image:none]";
|
|
46
54
|
/** A row in a Container, with the fade on whichever side still has content to scroll to. `onRow` is also handed the row. */
|
|
47
55
|
function ScrollRow({ className, onRow, children, }) {
|
|
48
56
|
const [row, setRow] = useState(null);
|
|
@@ -54,27 +62,52 @@ function ScrollRow({ className, onRow, children, }) {
|
|
|
54
62
|
return (_jsx(ContainerFrame, { ref: attach, className: cx(ROW, FADE, className), children: children }));
|
|
55
63
|
}
|
|
56
64
|
/**
|
|
57
|
-
* The
|
|
58
|
-
* the
|
|
65
|
+
* The row's end: `controls`, then the Menu button (`children`). Below `md` this wrapper may shrink
|
|
66
|
+
* (the row's `*:shrink-0` is overridden), so a crowded `controls` clips inside its own box and the
|
|
67
|
+
* button stays on screen; from `md` it keeps its width and the row scrolls.
|
|
68
|
+
*/
|
|
69
|
+
function HeaderEnd({ controls, folded, afterMenuControls, children, }) {
|
|
70
|
+
return (_jsxs("div", { className: cx("ml-auto flex min-w-0 items-center gap-2 max-md:shrink!", afterMenuControls && !folded && "md:ml-0", !controls && !folded && "md:hidden"), children: [controls && (_jsx("div", { className: "flex min-w-0 items-center gap-2 *:shrink-0 max-md:-mx-1 max-md:overflow-x-clip max-md:px-1 [&>.w-full]:w-auto", children: controls })), children] }));
|
|
71
|
+
}
|
|
72
|
+
/** The sticky header's box. */
|
|
73
|
+
function headerClass(hideChromeInPrint) {
|
|
74
|
+
return cx("group/shell sticky top-0 z-10 border-b border-slate-200 bg-white/95 pt-[env(safe-area-inset-top)]", hideChromeInPrint && "print:hidden");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The sticky header: one row of slots in order, brand, the menu panel (`nav` and `menuControls`,
|
|
78
|
+
* each rendered once, and the phone's `subnav`), the free `children`, then `controls` and the Menu
|
|
79
|
+
* button at the end. `controls` have a wrapper of their own that shrinks and clips, and the button
|
|
59
80
|
* sits beside it, so a crowded `controls` never pushes the Menu off a phone screen. From `md` the
|
|
60
|
-
*
|
|
61
|
-
*
|
|
81
|
+
* panel's parts are the row's (`AppShellMenuPanel`), the subnav is a second row under it, outside
|
|
82
|
+
* the first row's fade, and a nav that does not fit folds the panel back into menu mode (`folded`).
|
|
83
|
+
* The markup is in the order the eye reads, so the focus follows it. It pads by the top safe-area
|
|
84
|
+
* inset.
|
|
62
85
|
*/
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
86
|
+
function AppShellHeader({ brand, nav, controls, menuControls, subnav, menuLabel, folded, onRow, hideChromeInPrint, children, }) {
|
|
87
|
+
const panelId = `${useId()}-menu`;
|
|
88
|
+
const menu = !!(nav || subnav || menuControls);
|
|
89
|
+
return (_jsxs("header", { className: headerClass(hideChromeInPrint), children: [_jsxs(ScrollRow, { className: "flex h-14", onRow: onRow, children: [brand && (_jsx("div", { className: "flex items-center gap-2 text-base font-bold tracking-tight text-slate-900", children: brand })), menu && (_jsx(AppShellMenuPanel, { id: panelId, controls: menuControls, nav: nav, subnav: subnav, folded: folded })), children, (controls || menu) && (_jsx(HeaderEnd, { controls: controls, folded: folded, afterMenuControls: !!menuControls, children: menu && _jsx(AppShellMenuButton, { label: menuLabel, panelId: panelId, folded: folded }) }))] }), subnav && _jsx(ScrollRow, { className: "hidden h-12 md:flex", children: subnav })] }));
|
|
90
|
+
}
|
|
91
|
+
/** The shell's own box: the canvas, ink and face, the bottom inset, and the header's height. */
|
|
92
|
+
function shellClass(subnavRow) {
|
|
93
|
+
return cx("flex min-h-dvh flex-col bg-gray-50 pb-[env(safe-area-inset-bottom)] font-sans text-slate-900 antialiased",
|
|
94
|
+
// The sticky header's height (its rows, the top inset and the bottom border), for a bar
|
|
95
|
+
// that sticks under it. Below `md` it is one row whatever the slots are: the subnav is in the
|
|
96
|
+
// menu. A subnav never folds, so from `md` it is two rows with one.
|
|
97
|
+
"[--app-header:calc(3.5rem+1px+env(safe-area-inset-top))]", subnavRow && "md:[--app-header:calc(6.5rem+1px+env(safe-area-inset-top))]",
|
|
98
|
+
// A link or focus that scrolls to any element with an id stops below the sticky header.
|
|
99
|
+
"[&_[id]]:scroll-mt-[calc(var(--app-header,0px)+1rem)]");
|
|
100
|
+
}
|
|
101
|
+
/** The page's first tab stop, shown only while it has the focus: it moves the focus to `target`. */
|
|
102
|
+
function SkipLink({ target, label }) {
|
|
103
|
+
return (_jsx("a", { href: `#${target}`, className: cx("sr-only z-20 rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm font-medium text-slate-900 focus:not-sr-only focus:fixed focus:top-[calc(env(safe-area-inset-top)+0.5rem)] focus:left-[calc(env(safe-area-inset-left)+0.5rem)]", focusRing), children: label }));
|
|
68
104
|
}
|
|
69
105
|
/**
|
|
70
|
-
* The
|
|
71
|
-
*
|
|
72
|
-
* (`data-nav-folded`) and comes back when the row is wide enough again (`useNavFold`).
|
|
106
|
+
* The main area, the skip link's target: focusable from script only, so it takes the focus with no
|
|
107
|
+
* ring of its own. In a Container unless `bleed`.
|
|
73
108
|
*/
|
|
74
|
-
function
|
|
75
|
-
|
|
76
|
-
const folded = useNavFold(row, !!nav);
|
|
77
|
-
return (_jsxs("header", { "data-nav-folded": folded ? "" : undefined, className: cx("sticky top-0 z-10 border-b border-slate-200 bg-white pt-[env(safe-area-inset-top)]", hideChromeInPrint && "print:hidden"), children: [_jsx(ScrollRow, { className: "flex h-14", onRow: setRow, children: _jsx(HeaderSlots, { brand: brand, nav: nav, controls: controls, menuInline: !!menuControls, folded: folded, menu: (nav || subnav || menuControls) && (_jsx(AppShellMenu, { label: menuLabel, controls: menuControls, nav: nav, subnav: subnav, folded: folded })), children: children }) }), subnav && _jsx(ScrollRow, { className: "hidden h-12 md:flex", children: subnav })] }));
|
|
109
|
+
function ShellMain({ id, bleed, hideChromeInPrint, children, }) {
|
|
110
|
+
return (_jsx("main", { id: id, tabIndex: -1, className: "flex flex-1 flex-col outline-none", children: bleed ? (children) : (_jsx(ContainerFrame, { className: cx("py-8", hideChromeInPrint && "print:p-0"), children: children })) }));
|
|
78
111
|
}
|
|
79
112
|
/**
|
|
80
113
|
* The page frame: it paints the page canvas and sets the type face, ink and font smoothing
|
|
@@ -92,8 +125,9 @@ function AppShellHeader({ brand, nav, controls, menuControls, subnav, menuLabel,
|
|
|
92
125
|
*
|
|
93
126
|
* On a phone (below `md`) the header is one 56px row at every page: `brand`, `header`, `controls`
|
|
94
127
|
* and a "Menu" button (`menuLabel`), and `nav` and `subnav` move into that menu, so every link is
|
|
95
|
-
* reachable and nothing scrolls sideways. The menu is
|
|
96
|
-
* keyboard,
|
|
128
|
+
* reachable and nothing scrolls sideways. The menu is the browser's popover (`popovertarget`), so
|
|
129
|
+
* it works with the keyboard, closes on Escape and a click outside, hands focus back to the button,
|
|
130
|
+
* and opens on a page that never hydrates. From `md` the header is the
|
|
97
131
|
* row, and the `subnav` row, as they are, except that a `nav` too wide for the row folds into the
|
|
98
132
|
* Menu and comes back when the screen is wide enough (measured, with script; a `subnav` never
|
|
99
133
|
* folds, it scrolls sideways with a fade).
|
|
@@ -105,15 +139,15 @@ function AppShellHeader({ brand, nav, controls, menuControls, subnav, menuLabel,
|
|
|
105
139
|
*
|
|
106
140
|
* `controls` stay in the row at every width, so keep them few (a theme toggle, the viewer's avatar);
|
|
107
141
|
* on a phone a crowded `controls` clips, and the Menu button is never the part cut off. Pickers and
|
|
108
|
-
* actions that do not fit a phone row go in `menuControls`: rendered once, they sit
|
|
109
|
-
* `
|
|
142
|
+
* actions that do not fit a phone row go in `menuControls`: rendered once, from `md` they sit at the
|
|
143
|
+
* row's end, before `header` and `controls`, and fold into the Menu with a `nav` that does not fit;
|
|
144
|
+
* below `md` they are at the foot of the Menu, after `nav` and `subnav`. The markup is in the order
|
|
145
|
+
* the row shows, so the focus moves as the eye does.
|
|
110
146
|
*/
|
|
111
|
-
export function AppShell({ brand, nav, controls, menuControls, header, subnav, menuLabel = "Menu", footer, bleed = false, printChrome = true, density, children, ...rest }) {
|
|
147
|
+
export function AppShell({ brand, nav, controls, menuControls, header, subnav, menuLabel = "Menu", footer, bleed = false, printChrome = true, density, skipLabel = "Skip to content", children, ...rest }) {
|
|
112
148
|
const hideChromeInPrint = !printChrome;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// A link or focus that scrolls to any element with an id stops below the sticky header.
|
|
118
|
-
"[&_[id]]:scroll-mt-[calc(var(--app-header,0px)+1rem)]"), children: [_jsx(AppShellHeader, { brand: brand, nav: nav, controls: controls, menuControls: menuControls, subnav: subnav, menuLabel: menuLabel, hideChromeInPrint: hideChromeInPrint, children: header }), _jsx("main", { className: "flex flex-1 flex-col", children: bleed ? (children) : (_jsx(ContainerFrame, { className: cx("py-8", hideChromeInPrint && "print:p-0"), children: children })) }), footer && (_jsx("footer", { className: cx("border-t border-slate-200", hideChromeInPrint && "print:hidden"), children: _jsx(ContainerFrame, { className: "py-6 text-sm text-slate-500", children: footer }) }))] }) }));
|
|
149
|
+
const mainId = `${useId()}-main`;
|
|
150
|
+
const [row, setRow] = useState(null);
|
|
151
|
+
const folded = useNavFold(row, !!nav);
|
|
152
|
+
return (_jsx(DensityProvider, { type: density, children: _jsxs("div", { ...rest, className: shellClass(!!subnav), children: [_jsx(SkipLink, { target: mainId, label: skipLabel }), _jsx(AppShellHeader, { brand: brand, nav: nav, controls: controls, menuControls: menuControls, subnav: subnav, menuLabel: menuLabel, folded: folded, onRow: setRow, hideChromeInPrint: hideChromeInPrint, children: header }), _jsx(ShellMain, { id: mainId, bleed: bleed, hideChromeInPrint: hideChromeInPrint, children: children }), footer && (_jsx("footer", { className: cx("border-t border-slate-200", hideChromeInPrint && "print:hidden"), children: _jsx(ContainerFrame, { className: "py-6 text-sm text-slate-500", children: footer }) }))] }) }));
|
|
119
153
|
}
|
package/dist/AppShellMenu.d.ts
CHANGED
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from "react";
|
|
2
2
|
/**
|
|
3
|
-
* The header's
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* it is followed, for a router that changes the page without a reload.
|
|
9
|
-
*
|
|
10
|
-
* `controls` (AppShell's `menuControls`) sit at the top of the panel, above the links. From `md`
|
|
11
|
-
* the `<details>` drops its own box and shows only them, inline at the row's end, whether it is
|
|
12
|
-
* open or not: the summary and the link copies are hidden (the links render in their own rows from
|
|
13
|
-
* `md`) and the panel is a plain row. They are rendered once, so a field keeps its state.
|
|
14
|
-
*
|
|
15
|
-
* `folded` (the nav did not fit the row from `md`) keeps the summary from `md` too, and its nav copy
|
|
16
|
-
* then hangs under the header as the panel does on a phone. The `subnav` copy stays phone only.
|
|
3
|
+
* The header's Menu button: a native `popovertarget` for the panel, so it opens and closes by
|
|
4
|
+
* pointer, Enter and Space and is announced with its expanded state, with no script (a page that
|
|
5
|
+
* never hydrates still has its menu). Shown below `md`, and from `md` while the nav is `folded`.
|
|
6
|
+
* Its icon follows the panel (`:popover-open`, its own and no other popover's) through the header's
|
|
7
|
+
* `group/shell`.
|
|
17
8
|
*/
|
|
18
|
-
export declare function
|
|
9
|
+
export declare function AppShellMenuButton({ label, panelId, folded, }: {
|
|
19
10
|
label: string;
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
panelId: string;
|
|
12
|
+
folded: boolean;
|
|
13
|
+
}): ReactElement;
|
|
14
|
+
/**
|
|
15
|
+
* The one home of AppShell's `nav` and `menuControls`, and the phone's copy of the `subnav`: the nav
|
|
16
|
+
* and `menuControls` are rendered once, here, so a field keeps its state, ids stay unique and a
|
|
17
|
+
* screen reader meets the nav once. It is a `popover="auto"` panel the Menu button targets, so it
|
|
18
|
+
* light-dismisses on a click outside and on Escape, and hands the focus back to the button, all the
|
|
19
|
+
* browser's.
|
|
20
|
+
*
|
|
21
|
+
* In row mode (from `md`, nav not `folded`) the panel draws no box of its own (`display: contents`,
|
|
22
|
+
* over the UA's `display: none`): its parts are the header row's items, the nav after the brand and
|
|
23
|
+
* `menuControls` pushed to the row's end, before `controls`, in the order they are in the markup, so
|
|
24
|
+
* the focus moves as the eye does. The subnav copy is `display: none` there (the header draws the
|
|
25
|
+
* subnav's own row, `display: none` below `md`), so a screen reader meets one subnav at any width.
|
|
26
|
+
* In menu mode (below `md`, or `folded`) it is the dropdown: the nav, the subnav below `md`, then
|
|
27
|
+
* `menuControls`. Script closes it when a link in it is followed (for a router that does not reload)
|
|
28
|
+
* and when the header leaves menu mode while it is open.
|
|
29
|
+
*/
|
|
30
|
+
export declare function AppShellMenuPanel({ id, controls, nav, subnav, folded, }: {
|
|
31
|
+
id: string;
|
|
32
|
+
/** AppShell's `menuControls`: last in the panel in menu mode, at the row's end otherwise. */
|
|
33
|
+
controls: ReactNode;
|
|
22
34
|
nav: ReactNode;
|
|
35
|
+
/** The subnav's phone copy; from `md` the header draws its own row. */
|
|
23
36
|
subnav: ReactNode;
|
|
24
|
-
/** From `md` the
|
|
37
|
+
/** From `md` the header is in menu mode too: the nav did not fit the row. */
|
|
25
38
|
folded: boolean;
|
|
26
39
|
}): ReactElement;
|
package/dist/AppShellMenu.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRef } from "react";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
3
|
import { ContainerFrame } from "./Container.js";
|
|
4
4
|
import { cx, focusRing } from "./cx.js";
|
|
5
|
+
// AppShell's `md` step: below it the header is always in menu mode.
|
|
6
|
+
const WIDE = "(width >= 48rem)";
|
|
5
7
|
const ICON = {
|
|
6
8
|
viewBox: "0 0 20 20",
|
|
7
9
|
width: 16,
|
|
@@ -14,53 +16,78 @@ const ICON = {
|
|
|
14
16
|
"aria-hidden": true,
|
|
15
17
|
className: "shrink-0 text-slate-500",
|
|
16
18
|
};
|
|
17
|
-
// A folded nav from `md`: the phone panel's dropdown, shown while the menu is open. The surface
|
|
18
|
-
// colours are unprefixed (below `md` the panel already draws them), so no palette utility takes a variant.
|
|
19
|
-
const FOLDED_NAV = "border-slate-200 bg-white md:absolute md:inset-x-0 md:top-full md:hidden md:max-h-[calc(100dvh-var(--app-header))] md:overflow-y-auto md:overscroll-contain md:border-y md:shadow-lg md:group-open:block";
|
|
20
19
|
/**
|
|
21
|
-
* The
|
|
22
|
-
*
|
|
20
|
+
* The header's Menu button: a native `popovertarget` for the panel, so it opens and closes by
|
|
21
|
+
* pointer, Enter and Space and is announced with its expanded state, with no script (a page that
|
|
22
|
+
* never hydrates still has its menu). Shown below `md`, and from `md` while the nav is `folded`.
|
|
23
|
+
* Its icon follows the panel (`:popover-open`, its own and no other popover's) through the header's
|
|
24
|
+
* `group/shell`.
|
|
23
25
|
*/
|
|
24
|
-
function
|
|
25
|
-
return (_jsxs(
|
|
26
|
+
export function AppShellMenuButton({ label, panelId, folded, }) {
|
|
27
|
+
return (_jsxs("button", { type: "button", popoverTarget: panelId, className: cx("flex shrink-0 cursor-pointer items-center gap-2 rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm font-medium text-slate-900 select-none hover:bg-slate-50", focusRing, !folded && "md:hidden"), children: [_jsx("svg", { ...ICON, className: cx(ICON.className, "group-has-[[data-shell-menu]:popover-open]/shell:hidden"), children: _jsx("path", { d: "M3 5.5h14M3 10h14M3 14.5h14" }) }), _jsx("svg", { ...ICON, className: cx(ICON.className, "hidden group-has-[[data-shell-menu]:popover-open]/shell:block"), children: _jsx("path", { d: "M5 5l10 10M15 5L5 15" }) }), label] }));
|
|
28
|
+
}
|
|
29
|
+
// Menu mode: the browser's popover, in the top layer, hung under the sticky header across the
|
|
30
|
+
// screen. The UA box (inset 0, auto margins, fit-content, its border and padding, Canvas colours)
|
|
31
|
+
// is replaced; the ink is the shell's.
|
|
32
|
+
const PANEL_MENU = "fixed inset-x-0 top-(--app-header) bottom-auto m-0 h-auto max-h-[calc(100dvh-var(--app-header))] w-auto max-w-none overflow-y-auto overscroll-contain border-x-0 border-y border-slate-200 bg-white p-0 text-inherit shadow-lg";
|
|
33
|
+
// In the Menu a tab row (`Tabs` of links is a `nav`, of buttons a `tablist`) wraps rather than
|
|
34
|
+
// scrolling sideways, so every link shows in the panel.
|
|
35
|
+
const WRAP = "[&_nav]:flex-wrap [&_nav]:gap-y-1 [&_[role=tablist]]:flex-wrap [&_[role=tablist]]:gap-y-1";
|
|
36
|
+
/** Close the panel if it is open; one that is not shown, or a browser with no popover API, does nothing. */
|
|
37
|
+
function hide(panel) {
|
|
38
|
+
if (panel && "hidePopover" in panel)
|
|
39
|
+
panel.hidePopover();
|
|
26
40
|
}
|
|
27
41
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
* Unfolding puts the panel back in the row, so it must not stay open in the top layer: close it when
|
|
43
|
+
* the header is in row mode and the screen is from `md`. Hiding a popover that is not shown does
|
|
44
|
+
* nothing.
|
|
45
|
+
*/
|
|
46
|
+
function useCloseInRowMode(panel, rowMode) {
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const el = panel.current;
|
|
49
|
+
// jsdom (a consumer's own tests) has neither the popover API nor matchMedia.
|
|
50
|
+
if (!rowMode || !el || !("hidePopover" in el) || typeof window.matchMedia !== "function") {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const wide = window.matchMedia(WIDE);
|
|
54
|
+
const close = () => {
|
|
55
|
+
if (wide.matches)
|
|
56
|
+
hide(el);
|
|
57
|
+
};
|
|
58
|
+
close();
|
|
59
|
+
wide.addEventListener("change", close);
|
|
60
|
+
return () => wide.removeEventListener("change", close);
|
|
61
|
+
}, [panel, rowMode]);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The one home of AppShell's `nav` and `menuControls`, and the phone's copy of the `subnav`: the nav
|
|
65
|
+
* and `menuControls` are rendered once, here, so a field keeps its state, ids stay unique and a
|
|
66
|
+
* screen reader meets the nav once. It is a `popover="auto"` panel the Menu button targets, so it
|
|
67
|
+
* light-dismisses on a click outside and on Escape, and hands the focus back to the button, all the
|
|
68
|
+
* browser's.
|
|
39
69
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
70
|
+
* In row mode (from `md`, nav not `folded`) the panel draws no box of its own (`display: contents`,
|
|
71
|
+
* over the UA's `display: none`): its parts are the header row's items, the nav after the brand and
|
|
72
|
+
* `menuControls` pushed to the row's end, before `controls`, in the order they are in the markup, so
|
|
73
|
+
* the focus moves as the eye does. The subnav copy is `display: none` there (the header draws the
|
|
74
|
+
* subnav's own row, `display: none` below `md`), so a screen reader meets one subnav at any width.
|
|
75
|
+
* In menu mode (below `md`, or `folded`) it is the dropdown: the nav, the subnav below `md`, then
|
|
76
|
+
* `menuControls`. Script closes it when a link in it is followed (for a router that does not reload)
|
|
77
|
+
* and when the header leaves menu mode while it is open.
|
|
42
78
|
*/
|
|
43
|
-
export function
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (event.key === "Escape" &&
|
|
58
|
-
!(event.target instanceof Element && event.target.closest("dialog")))
|
|
59
|
-
close(true);
|
|
60
|
-
}, children: [_jsxs("summary", { className: cx("flex cursor-pointer list-none items-center gap-2 rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm font-medium text-slate-900 select-none hover:bg-slate-50 [&::-webkit-details-marker]:hidden", focusRing, !folded && "md:hidden"), children: [_jsx("svg", { ...ICON, className: cx(ICON.className, "group-open:hidden"), children: _jsx("path", { d: "M3 5.5h14M3 10h14M3 14.5h14" }) }), _jsx("svg", { ...ICON, className: cx(ICON.className, "hidden group-open:block"), children: _jsx("path", { d: "M5 5l10 10M15 5L5 15" }) }), label] }), _jsx("div", {
|
|
61
|
-
// From `md` the panel draws no box (`contents`), so its dropdown look applies below `md` only.
|
|
62
|
-
className: "absolute inset-x-0 top-full max-h-[calc(100dvh-var(--app-header))] overflow-y-auto overscroll-contain border-y border-slate-200 bg-white shadow-lg md:contents", onClick: (event) => {
|
|
63
|
-
if (event.target instanceof Element && event.target.closest("a[href]"))
|
|
64
|
-
close(false);
|
|
65
|
-
}, children: _jsxs(ContainerFrame, { className: "flex flex-col gap-3 py-3 md:contents", children: [controls && (_jsx("div", { className: "flex flex-wrap items-center gap-2 md:flex-nowrap md:*:shrink-0 md:[&>.w-full]:w-auto", children: controls })), _jsx(MenuLinks, { nav: nav, subnav: subnav, folded: folded })] }) })] }));
|
|
79
|
+
export function AppShellMenuPanel({ id, controls, nav, subnav, folded, }) {
|
|
80
|
+
const panel = useRef(null);
|
|
81
|
+
const rowMode = !folded;
|
|
82
|
+
useCloseInRowMode(panel, rowMode);
|
|
83
|
+
return (_jsx("div", { ref: panel, id: id, popover: "auto", "data-shell-menu": "", className: cx(PANEL_MENU, rowMode && "md:contents"), onClick: (event) => {
|
|
84
|
+
if (event.target instanceof Element && event.target.closest("a[href]"))
|
|
85
|
+
hide(panel.current);
|
|
86
|
+
}, children: _jsxs(ContainerFrame, { className: cx("flex flex-col gap-3 py-3", rowMode && "md:contents"), children: [nav && (_jsx("div", {
|
|
87
|
+
// From `md` the nav is a row item of its own (the row's `*:shrink-0` does not reach through
|
|
88
|
+
// `contents`): it keeps its full width, so a nav too wide overflows the row and folds.
|
|
89
|
+
// In the Menu its tab rows wrap, so no link is left past the panel's edge.
|
|
90
|
+
className: cx("flex flex-col gap-3", WRAP, rowMode &&
|
|
91
|
+
"md:shrink-0 md:flex-row md:items-center md:gap-4 md:*:shrink-0 md:[&_nav]:flex-nowrap md:[&_[role=tablist]]:flex-nowrap"), children: nav })), subnav && _jsx("div", { className: cx("flex flex-col gap-3 md:hidden", WRAP), children: subnav }), controls && (_jsx("div", { className: cx("flex flex-wrap items-center gap-2", rowMode &&
|
|
92
|
+
"md:ml-auto md:shrink-0 md:flex-nowrap md:*:shrink-0 md:[&>.w-full]:w-auto"), children: controls }))] }) }));
|
|
66
93
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import { type PageHeaderProps } from "./PageHeader.js";
|
|
3
|
+
import type { Passthrough } from "./props.js";
|
|
4
|
+
export type ArticleLayoutProps = Pick<PageHeaderProps, "breadcrumbs" | "title" | "description" | "loading" | "loadingLabel"> & {
|
|
5
|
+
/** Who wrote it: a name, or a `TextLink` to their page. */
|
|
6
|
+
author?: ReactNode;
|
|
7
|
+
/** When it was published, as the reader reads it: "12 November 2026". */
|
|
8
|
+
date?: string | undefined;
|
|
9
|
+
/** The same day as an ISO date (`2026-11-12`), for the `<time>` a machine reads. */
|
|
10
|
+
dateTime?: string | undefined;
|
|
11
|
+
/** How long it takes to read, worked out by the app: "6 min read". */
|
|
12
|
+
readingTime?: string | undefined;
|
|
13
|
+
/** The lead picture under the byline: an `Image` at `width="full"`. */
|
|
14
|
+
image?: ReactNode;
|
|
15
|
+
/** The article itself: `Prose`, or `SectionHeading`s and `Text` paragraphs, spaced `md` apart. */
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* The cards at the foot under "More like this", three to a row from `lg`: a `.map` of `Card`s or
|
|
19
|
+
* `ProductTile`s. Left out, there is no foot.
|
|
20
|
+
*/
|
|
21
|
+
related?: ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* The heading over `related`, for an app in another language or another word ("Recipes for this kit").
|
|
24
|
+
* @default More like this
|
|
25
|
+
*/
|
|
26
|
+
relatedTitle?: string | undefined;
|
|
27
|
+
} & Passthrough;
|
|
28
|
+
/**
|
|
29
|
+
* A blog article: the title (the page's `h1`) and its lede, a byline of the author, the date and the
|
|
30
|
+
* reading time in muted text, the lead picture, the body, and a "More like this" row of cards at the
|
|
31
|
+
* foot. The article sits in the reading column (`max-w-3xl`) at the Container's start edge, and the
|
|
32
|
+
* related cards take the Container's whole width under it. The date is a `<time>` when `dateTime`
|
|
33
|
+
* says which day it is. Every part but the title is optional. While `loading` it owns the wait and
|
|
34
|
+
* passes it to everything inside, the header too.
|
|
35
|
+
*/
|
|
36
|
+
export declare function ArticleLayout({ breadcrumbs, title, description, author, date, dateTime, readingTime, image, children, related, relatedTitle, loading, loadingLabel, ...rest }: ArticleLayoutProps): ReactElement;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CardGrid } from "./CardGrid.js";
|
|
3
|
+
import { useWait } from "./layoutWait.js";
|
|
4
|
+
import { MetaList } from "./MetaList.js";
|
|
5
|
+
import { PageHeaderContent } from "./PageHeader.js";
|
|
6
|
+
import { Section } from "./Section.js";
|
|
7
|
+
import { LoadingScope } from "./skeleton.js";
|
|
8
|
+
import { Stack } from "./Stack.js";
|
|
9
|
+
/**
|
|
10
|
+
* A blog article: the title (the page's `h1`) and its lede, a byline of the author, the date and the
|
|
11
|
+
* reading time in muted text, the lead picture, the body, and a "More like this" row of cards at the
|
|
12
|
+
* foot. The article sits in the reading column (`max-w-3xl`) at the Container's start edge, and the
|
|
13
|
+
* related cards take the Container's whole width under it. The date is a `<time>` when `dateTime`
|
|
14
|
+
* says which day it is. Every part but the title is optional. While `loading` it owns the wait and
|
|
15
|
+
* passes it to everything inside, the header too.
|
|
16
|
+
*/
|
|
17
|
+
export function ArticleLayout({ breadcrumbs, title, description, author, date, dateTime, readingTime, image, children, related, relatedTitle = "More like this", loading, loadingLabel, ...rest }) {
|
|
18
|
+
const wait = useWait(loading, loadingLabel);
|
|
19
|
+
return (_jsx(LoadingScope, { loading: wait.loading, children: _jsxs("div", { ...rest, ...wait.attrs, className: "flex flex-col gap-16", children: [_jsxs("article", { className: "max-w-3xl", children: [_jsxs("header", { className: "mb-8 flex flex-col gap-3", children: [_jsx(PageHeaderContent, { breadcrumbs: breadcrumbs, title: title, description: description }), _jsx(Byline, { author: author, date: date, dateTime: dateTime, readingTime: readingTime })] }), image != null && image !== false && _jsx("div", { className: "mb-8", children: image }), _jsx(Stack, { children: children })] }), related != null && related !== false && (_jsx(Section, { title: relatedTitle, children: _jsx(CardGrid, { as: "ul", columns: 3, children: related }) })), wait.label] }) }));
|
|
20
|
+
}
|
|
21
|
+
/** The author, the date and the reading time on one muted row; nothing when none is given. */
|
|
22
|
+
function Byline({ author, date, dateTime, readingTime, }) {
|
|
23
|
+
const hasAuthor = author != null && author !== false;
|
|
24
|
+
if (!hasAuthor && date === undefined && readingTime === undefined)
|
|
25
|
+
return null;
|
|
26
|
+
return (_jsxs(MetaList, { children: [hasAuthor && _jsx("span", { children: author }), date !== undefined && _jsx("time", { dateTime: dateTime, children: date }), readingTime !== undefined && _jsx("span", { children: readingTime })] }));
|
|
27
|
+
}
|
package/dist/Audio.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AudioHTMLAttributes, ReactElement, ReactNode } from "react";
|
|
2
|
+
import type { Unstyled } from "./props.js";
|
|
3
|
+
/**
|
|
4
|
+
* An `<audio>` with the browser's own controls, at one fixed size: 20rem wide, narrower only when its column is. It loads
|
|
5
|
+
* metadata only, and lazily where the browser can, so the page does not pull the file until it is
|
|
6
|
+
* played. A voice note or a clip has no visible title, so `label` names the player. `src` is the
|
|
7
|
+
* app's own file; `children` is the fallback for a browser that cannot play it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function Audio({ src, label, children, ...rest }: {
|
|
10
|
+
/** The audio file, the app's own. */
|
|
11
|
+
src: string;
|
|
12
|
+
/** Names the player for a screen reader, as "Voice note from Anna": audio has no visible title. */
|
|
13
|
+
label: string;
|
|
14
|
+
/** The text for a browser that cannot play it. */
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
} & Unstyled<Omit<AudioHTMLAttributes<HTMLAudioElement>, "src" | "controls" | "children">>): ReactElement;
|
package/dist/Audio.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { LAZY_MEDIA } from "./Video.js";
|
|
3
|
+
/**
|
|
4
|
+
* An `<audio>` with the browser's own controls, at one fixed size: 20rem wide, narrower only when its column is. It loads
|
|
5
|
+
* metadata only, and lazily where the browser can, so the page does not pull the file until it is
|
|
6
|
+
* played. A voice note or a clip has no visible title, so `label` names the player. `src` is the
|
|
7
|
+
* app's own file; `children` is the fallback for a browser that cannot play it.
|
|
8
|
+
*/
|
|
9
|
+
export function Audio({ src, label, children, ...rest }) {
|
|
10
|
+
return (_jsx("audio", { controls: true, preload: "metadata", ...LAZY_MEDIA, src: src, ...rest, "aria-label": label, className: "block h-10 w-xs max-w-full", children: children }));
|
|
11
|
+
}
|
package/dist/Badge.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import type { ReactElement } from "react";
|
|
|
2
2
|
import type { Passthrough } from "./props.js";
|
|
3
3
|
import { type LoadingProps } from "./skeleton.js";
|
|
4
4
|
/**
|
|
5
|
-
* A small red count, 10px, for sitting on an icon.
|
|
5
|
+
* A small red count, 10px, for sitting on an icon. Its size is in rem and its height grows with
|
|
6
|
+
* its line, so it scales with the reader's text size instead of clipping. An icon with a count is an `IconButton` with
|
|
6
7
|
* its `count`, which pins the Badge to its corner and puts the count in the button's name. A
|
|
7
8
|
* count above 99 reads `99+`. While `loading` it is
|
|
8
9
|
* a bone of its size: a count is a number, so 0 is a value and not a gap.
|
package/dist/Badge.js
CHANGED
|
@@ -2,7 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { cx } from "./cx.js";
|
|
3
3
|
import { useLoading, WaitingBone } from "./skeleton.js";
|
|
4
4
|
/**
|
|
5
|
-
* A small red count, 10px, for sitting on an icon.
|
|
5
|
+
* A small red count, 10px, for sitting on an icon. Its size is in rem and its height grows with
|
|
6
|
+
* its line, so it scales with the reader's text size instead of clipping. An icon with a count is an `IconButton` with
|
|
6
7
|
* its `count`, which pins the Badge to its corner and puts the count in the button's name. A
|
|
7
8
|
* count above 99 reads `99+`. While `loading` it is
|
|
8
9
|
* a bone of its size: a count is a number, so 0 is a value and not a gap.
|
|
@@ -11,5 +12,5 @@ export function Badge({ count, corner = false, loading: ownLoading, loadingLabel
|
|
|
11
12
|
if (useLoading(ownLoading).loading) {
|
|
12
13
|
return (_jsx(WaitingBone, { own: ownLoading, label: loadingLabel, attrs: rest, root: cx("inline-flex", corner && "absolute -end-1.5 -top-1.5"), shape: "inline-block h-4 w-5 rounded-full" }));
|
|
13
14
|
}
|
|
14
|
-
return (_jsx("span", { ...rest, className: cx("inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-red-600 px-1 text-[
|
|
15
|
+
return (_jsx("span", { ...rest, className: cx("inline-flex min-h-4 min-w-4 items-center justify-center rounded-full bg-red-600 px-1 text-[0.625rem]/[1.6] font-semibold text-red-50", corner && "absolute -end-1.5 -top-1.5"), children: count > 99 ? "99+" : count }));
|
|
15
16
|
}
|
package/dist/BottomSheet.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { type ReactElement, type ReactNode } from "react";
|
|
|
2
2
|
import type { Passthrough } from "./props.js";
|
|
3
3
|
import { type BottomSheetSnap } from "./sheetSnap.js";
|
|
4
4
|
export type { BottomSheetSnap } from "./sheetSnap.js";
|
|
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";
|
|
5
7
|
export type BottomSheetProps = {
|
|
6
8
|
/** The sheet's accessible name, as a region, and its handle button's. */
|
|
7
9
|
label: string;
|
|
@@ -21,16 +23,25 @@ export type BottomSheetProps = {
|
|
|
21
23
|
/** The scrolling body. */
|
|
22
24
|
children?: ReactNode;
|
|
23
25
|
/**
|
|
24
|
-
* Called with the height (px)
|
|
25
|
-
*
|
|
26
|
+
* Called with the sheet's height (px): on mount, on every change of `snap`, when the parent
|
|
27
|
+
* resizes, and on every move of a drag, so a map camera padded by it follows the finger.
|
|
26
28
|
*/
|
|
27
29
|
onHeightChange?: (px: number) => void;
|
|
30
|
+
/**
|
|
31
|
+
* From this width up the sheet is no sheet: its header, body and footer sit in the page's flow
|
|
32
|
+
* with no handle, no snaps and no height of its own, so the parent's grid places it (a list
|
|
33
|
+
* column beside a map). Below it, it is the sheet. One tree, switched by CSS: nothing renders
|
|
34
|
+
* twice, so `onHeightChange` still reports the snap's height: there the view has nothing under
|
|
35
|
+
* the list to pad. Without it the sheet is a panel at the start edge from `md` up.
|
|
36
|
+
*/
|
|
37
|
+
inlineFrom?: InlineFrom | undefined;
|
|
28
38
|
} & Passthrough;
|
|
29
39
|
/**
|
|
30
40
|
* A non-modal panel docked to the bottom edge of its positioned parent, over a full-screen view (a
|
|
31
41
|
* map, a canvas) that stays usable behind it. It rests at one of its `snaps`; the handle steps
|
|
32
|
-
* through them (Enter and Space), a drag of the handle moves
|
|
33
|
-
* (a fling steps on), and Escape inside it returns it to the
|
|
34
|
-
* never moves. Full width below `md`, a panel at the start
|
|
42
|
+
* through them (Enter and Space; ArrowUp and ArrowDown one up or down), a drag of the handle moves
|
|
43
|
+
* it and releases to the nearest snap (a fling steps on), and Escape inside it returns it to the
|
|
44
|
+
* first. Nothing is made inert and focus never moves. Full width below `md`, a panel at the start
|
|
45
|
+
* edge from `md` up, or, with `inlineFrom`, plain content in the page from that width.
|
|
35
46
|
*/
|
|
36
|
-
export declare function BottomSheet({ label, snaps, snap, onSnapChange, header, footer, children, onHeightChange, ...rest }: BottomSheetProps): ReactElement;
|
|
47
|
+
export declare function BottomSheet({ label, snaps, snap, onSnapChange, header, footer, children, onHeightChange, inlineFrom, ...rest }: BottomSheetProps): ReactElement;
|