@slashsuite/ui-react 0.12.1 → 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 +89 -44
- package/agent-docs/components/app-shell.md +9 -6
- package/agent-docs/components/article-layout.md +140 -0
- package/agent-docs/components/audio.md +42 -0
- package/agent-docs/components/badge.md +2 -1
- package/agent-docs/components/body-text.md +26 -15
- package/agent-docs/components/bottom-sheet.md +27 -17
- package/agent-docs/components/breadcrumbs.md +10 -6
- package/agent-docs/components/button.md +2 -2
- package/agent-docs/components/call-to-action.md +59 -0
- package/agent-docs/components/callout.md +4 -3
- package/agent-docs/components/card-grid.md +15 -7
- package/agent-docs/components/card.md +33 -18
- package/agent-docs/components/cart-button.md +63 -0
- package/agent-docs/components/chat-composer.md +4 -3
- package/agent-docs/components/checkbox.md +11 -5
- package/agent-docs/components/cluster.md +10 -8
- package/agent-docs/components/code-example.md +2 -2
- package/agent-docs/components/code.md +7 -5
- package/agent-docs/components/colour-scheme-toggle.md +12 -6
- 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 +2 -1
- package/agent-docs/components/copy-button.md +7 -5
- package/agent-docs/components/copy-line.md +6 -5
- package/agent-docs/components/date-field.md +14 -11
- package/agent-docs/components/date-range-picker.md +16 -9
- package/agent-docs/components/date-time-field.md +73 -0
- package/agent-docs/components/dialog.md +22 -68
- package/agent-docs/components/disclosure.md +4 -0
- package/agent-docs/components/docs-layout.md +10 -6
- package/agent-docs/components/drawer.md +13 -4
- package/agent-docs/components/embed-frame.md +48 -0
- package/agent-docs/components/empty-state.md +4 -1
- package/agent-docs/components/field-dialog.md +6 -5
- package/agent-docs/components/field.md +10 -7
- package/agent-docs/components/fieldset.md +4 -4
- package/agent-docs/components/flow-diagram.md +87 -0
- package/agent-docs/components/form-layout.md +4 -1
- package/agent-docs/components/form-row.md +7 -7
- package/agent-docs/components/full-bleed-layout.md +0 -2
- package/agent-docs/components/headings.md +13 -7
- package/agent-docs/components/hero.md +11 -2
- package/agent-docs/components/icon-button.md +1 -3
- package/agent-docs/components/icon.md +6 -13
- package/agent-docs/components/image.md +24 -14
- package/agent-docs/components/input.md +8 -7
- package/agent-docs/components/key-value-list.md +4 -1
- package/agent-docs/components/lightbox.md +1 -1
- package/agent-docs/components/list-layout.md +5 -7
- package/agent-docs/components/list-row.md +37 -34
- package/agent-docs/components/loading.md +2 -2
- package/agent-docs/components/markdown.md +13 -13
- package/agent-docs/components/media-tile.md +8 -4
- package/agent-docs/components/menu.md +19 -12
- package/agent-docs/components/meta-list.md +2 -2
- package/agent-docs/components/morph.md +11 -5
- package/agent-docs/components/navigation-progress.md +2 -2
- package/agent-docs/components/number-field.md +75 -0
- package/agent-docs/components/outline-region.md +19 -8
- package/agent-docs/components/page-fade.md +2 -1
- package/agent-docs/components/pill.md +7 -6
- 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/promo-banner.md +46 -0
- package/agent-docs/components/prose-layout.md +1 -1
- package/agent-docs/components/radio-group.md +9 -6
- package/agent-docs/components/scroll-strip.md +3 -3
- package/agent-docs/components/segmented-control.md +4 -2
- package/agent-docs/components/select.md +8 -3
- package/agent-docs/components/show.md +2 -2
- package/agent-docs/components/side-column.md +13 -9
- package/agent-docs/components/sidebar-layout.md +1 -1
- package/agent-docs/components/site-footer.md +4 -4
- package/agent-docs/components/site-search.md +21 -9
- package/agent-docs/components/slider.md +59 -0
- package/agent-docs/components/sortable-list.md +15 -10
- package/agent-docs/components/stack.md +3 -3
- package/agent-docs/components/stacked-bar.md +7 -4
- package/agent-docs/components/state-machine.md +95 -0
- package/agent-docs/components/status-pages.md +13 -6
- package/agent-docs/components/stepper.md +54 -0
- package/agent-docs/components/switch.md +4 -4
- package/agent-docs/components/table-of-contents.md +78 -0
- package/agent-docs/components/table.md +35 -24
- package/agent-docs/components/tabs.md +24 -26
- package/agent-docs/components/text-link.md +12 -7
- package/agent-docs/components/textarea.md +4 -2
- package/agent-docs/components/toast.md +19 -14
- package/agent-docs/components/video.md +7 -2
- package/agent-docs/llms.txt +22 -3
- 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 +3 -2
package/dist/BottomSheet.js
CHANGED
|
@@ -1,30 +1,68 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useId, useRef, useState, } from "react";
|
|
3
|
-
import { focusRing } from "./cx.js";
|
|
3
|
+
import { cx, focusRing } from "./cx.js";
|
|
4
|
+
import { ScrollBody } from "./scrollBody.js";
|
|
4
5
|
import { GapProvider } from "./stackGap.js";
|
|
5
6
|
import { releaseVelocity, restingSnap, snapCss, snapPx, } from "./sheetSnap.js";
|
|
6
|
-
|
|
7
|
+
/** The sheet's surface and its docking at the bottom edge, at every width. */
|
|
8
|
+
const SHEET = "absolute inset-x-0 bottom-0 z-10 flex max-h-full flex-col overflow-hidden rounded-t-2xl border border-b-0 border-slate-200 bg-white pb-[env(safe-area-inset-bottom)] text-slate-900 shadow-2xl transition-[height] duration-200 ease-out data-dragging:transition-none motion-reduce:transition-none";
|
|
9
|
+
/** From `md` up, a sheet that is not inline is a panel at the start edge. */
|
|
10
|
+
const PANEL = "md:start-4 md:end-auto md:w-96";
|
|
11
|
+
/**
|
|
12
|
+
* From `md` up: a panel at the start edge, or, with `inlineFrom`, plain content in the parent's flow
|
|
13
|
+
* from that width (no docking, no height of its own, no handle), so the parent's grid places it;
|
|
14
|
+
* its body still scrolls within the parent's height.
|
|
15
|
+
*/
|
|
16
|
+
const WIDE = {
|
|
17
|
+
panel: { sheet: PANEL, handle: "", header: "" },
|
|
18
|
+
md: {
|
|
19
|
+
sheet: "md:static md:z-auto md:h-auto! md:max-h-full md:rounded-none md:border-0 md:pb-0 md:shadow-none",
|
|
20
|
+
handle: "md:hidden",
|
|
21
|
+
header: "md:pt-3.5",
|
|
22
|
+
},
|
|
23
|
+
lg: {
|
|
24
|
+
sheet: `${PANEL} lg:static lg:z-auto lg:h-auto! lg:w-auto lg:max-h-full lg:rounded-none lg:border-0 lg:pb-0 lg:shadow-none`,
|
|
25
|
+
handle: "lg:hidden",
|
|
26
|
+
header: "lg:pt-3.5",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
7
29
|
const HANDLE = `flex h-6 w-full shrink-0 cursor-grab touch-none items-center justify-center text-slate-400 active:cursor-grabbing ${focusRing} focus-visible:-outline-offset-2`;
|
|
30
|
+
/** The arrow keys on the handle, and the step through the snaps each makes. */
|
|
31
|
+
const STEP = { ArrowUp: 1, ArrowDown: -1 };
|
|
8
32
|
/** Pointer travel (px) under which a press on the handle is a tap, not a drag. */
|
|
9
33
|
const TAP = 6;
|
|
10
34
|
/** The pill grip on the handle. */
|
|
11
35
|
const GRIP = (_jsx("svg", { viewBox: "0 0 36 4", fill: "currentColor", "aria-hidden": "true", className: "h-1 w-9", children: _jsx("rect", { width: "36", height: "4", rx: "2" }) }));
|
|
12
36
|
const parentOf = (el) => el.offsetParent instanceof HTMLElement ? el.offsetParent : el.parentElement;
|
|
13
|
-
/** Report the
|
|
14
|
-
function useReportedHeight(sheet, resting, onHeightChange) {
|
|
37
|
+
/** Report the sheet's height: now, on a change of snap, when its parent resizes and through a drag. */
|
|
38
|
+
function useReportedHeight(sheet, resting, dragHeight, onHeightChange) {
|
|
15
39
|
const report = useRef(onHeightChange);
|
|
16
40
|
const reported = useRef(null);
|
|
41
|
+
const dragging = useRef(false);
|
|
17
42
|
useEffect(() => {
|
|
18
43
|
report.current = onHeightChange;
|
|
19
44
|
});
|
|
45
|
+
// A drag reports each height it passes through, and its end the height the sheet rests at (the
|
|
46
|
+
// same snap included, which the effect below does not hear about).
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const el = sheet.current;
|
|
49
|
+
const parent = el && parentOf(el);
|
|
50
|
+
dragging.current = dragHeight !== null;
|
|
51
|
+
const px = dragHeight ?? (parent ? snapPx(resting, parent.clientHeight) : null);
|
|
52
|
+
if (px === null || px === reported.current)
|
|
53
|
+
return;
|
|
54
|
+
reported.current = px;
|
|
55
|
+
report.current?.(px);
|
|
56
|
+
}, [sheet, resting, dragHeight]);
|
|
20
57
|
useEffect(() => {
|
|
21
58
|
const el = sheet.current;
|
|
22
59
|
const parent = el && parentOf(el);
|
|
23
60
|
if (!parent)
|
|
24
61
|
return undefined;
|
|
62
|
+
// A resize mid-drag reports nothing: the drag reports the height the sheet is at.
|
|
25
63
|
const send = () => {
|
|
26
64
|
const px = snapPx(resting, parent.clientHeight);
|
|
27
|
-
if (px === reported.current)
|
|
65
|
+
if (dragging.current || px === reported.current)
|
|
28
66
|
return;
|
|
29
67
|
reported.current = px;
|
|
30
68
|
report.current?.(px);
|
|
@@ -104,10 +142,21 @@ function useSheetDrag(sheet, { snaps, snap, onSnapChange }) {
|
|
|
104
142
|
if (!swallow)
|
|
105
143
|
onSnapChange((snap + 1) % snaps.length);
|
|
106
144
|
};
|
|
145
|
+
/** ArrowUp steps one snap taller and ArrowDown one shorter, stopping at the ends. */
|
|
146
|
+
const onKeyDown = (event) => {
|
|
147
|
+
const step = STEP[event.key];
|
|
148
|
+
if (step === undefined)
|
|
149
|
+
return;
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
const next = Math.min(Math.max(snap + step, 0), snaps.length - 1);
|
|
152
|
+
if (next !== snap)
|
|
153
|
+
onSnapChange(next);
|
|
154
|
+
};
|
|
107
155
|
return {
|
|
108
156
|
dragHeight,
|
|
109
157
|
handle: {
|
|
110
158
|
onClick,
|
|
159
|
+
onKeyDown,
|
|
111
160
|
onPointerDown,
|
|
112
161
|
onPointerMove,
|
|
113
162
|
onPointerUp: (event) => release(event, false),
|
|
@@ -118,16 +167,18 @@ function useSheetDrag(sheet, { snaps, snap, onSnapChange }) {
|
|
|
118
167
|
/**
|
|
119
168
|
* A non-modal panel docked to the bottom edge of its positioned parent, over a full-screen view (a
|
|
120
169
|
* map, a canvas) that stays usable behind it. It rests at one of its `snaps`; the handle steps
|
|
121
|
-
* through them (Enter and Space), a drag of the handle moves
|
|
122
|
-
* (a fling steps on), and Escape inside it returns it to the
|
|
123
|
-
* never moves. Full width below `md`, a panel at the start
|
|
170
|
+
* through them (Enter and Space; ArrowUp and ArrowDown one up or down), a drag of the handle moves
|
|
171
|
+
* it and releases to the nearest snap (a fling steps on), and Escape inside it returns it to the
|
|
172
|
+
* first. Nothing is made inert and focus never moves. Full width below `md`, a panel at the start
|
|
173
|
+
* edge from `md` up, or, with `inlineFrom`, plain content in the page from that width.
|
|
124
174
|
*/
|
|
125
|
-
export function BottomSheet({ label, snaps, snap, onSnapChange, header, footer, children, onHeightChange, ...rest }) {
|
|
175
|
+
export function BottomSheet({ label, snaps, snap, onSnapChange, header, footer, children, onHeightChange, inlineFrom, ...rest }) {
|
|
126
176
|
const sheet = useRef(null);
|
|
127
177
|
const bodyId = useId();
|
|
128
178
|
const resting = snaps[snap] ?? snaps[0];
|
|
129
|
-
useReportedHeight(sheet, resting, onHeightChange);
|
|
130
179
|
const { dragHeight, handle } = useSheetDrag(sheet, { snaps, snap, onSnapChange });
|
|
180
|
+
useReportedHeight(sheet, resting, dragHeight, onHeightChange);
|
|
181
|
+
const wide = WIDE[inlineFrom ?? "panel"];
|
|
131
182
|
const onKeyDown = (event) => {
|
|
132
183
|
if (event.key !== "Escape" || event.defaultPrevented || snap === 0)
|
|
133
184
|
return;
|
|
@@ -138,5 +189,5 @@ export function BottomSheet({ label, snaps, snap, onSnapChange, header, footer,
|
|
|
138
189
|
event.preventDefault();
|
|
139
190
|
onSnapChange(0);
|
|
140
191
|
};
|
|
141
|
-
return (_jsxs("section", { ...rest, ref: sheet, "aria-label": label, onKeyDown: onKeyDown, "data-dragging": dragHeight === null ? undefined : "", className: SHEET, style: { height: dragHeight === null ? snapCss(resting) : `${dragHeight}px` }, children: [_jsx("button", { ...handle, type: "button", "aria-label": label, "aria-expanded": snap > 0, "aria-controls": bodyId, className: HANDLE, children: GRIP }), header != null && (_jsx("div", { className: "flex shrink-0 items-center justify-between gap-3 border-b border-slate-200 px-5.5 pb-3.5", children: header })), _jsx(
|
|
192
|
+
return (_jsxs("section", { ...rest, ref: sheet, "aria-label": label, onKeyDown: onKeyDown, "data-dragging": dragHeight === null ? undefined : "", className: cx(SHEET, wide.sheet), style: { height: dragHeight === null ? snapCss(resting) : `${dragHeight}px` }, children: [_jsx("button", { ...handle, type: "button", "aria-label": label, "aria-expanded": snap > 0, "aria-controls": bodyId, className: cx(HANDLE, wide.handle), children: GRIP }), header != null && (_jsx("div", { className: cx("flex shrink-0 items-center justify-between gap-3 border-b border-slate-200 px-5.5 pb-3.5", wide.header), children: header })), _jsx(ScrollBody, { id: bodyId, label: label, className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-5.5 py-4", children: _jsx(GapProvider, { gap: "xs", children: children }) }), footer != null && (_jsx("footer", { className: "flex shrink-0 justify-end gap-2 border-t border-slate-200 px-5.5 py-3.5", children: footer }))] }));
|
|
142
193
|
}
|
package/dist/Breadcrumbs.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from "react";
|
|
2
2
|
import type { Passthrough } from "./props.js";
|
|
3
|
-
/** The classes of a crumb that links somewhere, for a router's own <Link>.
|
|
3
|
+
/** The classes of a crumb that links somewhere, for a router's own <Link>. */
|
|
4
4
|
export declare const crumbLinkClass: string;
|
|
5
5
|
/**
|
|
6
6
|
* A crumb that links: `href`, drawn by the app's router link through `LinkProvider` for an in-app
|
|
7
|
-
* path, else a plain `<a>`. `external` opens in a new tab. The last crumb is the current page
|
|
8
|
-
*
|
|
7
|
+
* path, else a plain `<a>`. `external` opens in a new tab. The last crumb is the current page: given
|
|
8
|
+
* an `href` it is a link to this page with `aria-current="page"`.
|
|
9
9
|
*/
|
|
10
10
|
export type Crumb = {
|
|
11
11
|
label: ReactNode;
|
|
@@ -13,11 +13,13 @@ export type Crumb = {
|
|
|
13
13
|
external?: boolean;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
* `org / project / build / snapshot`:
|
|
17
|
-
*
|
|
16
|
+
* `org / project / build / snapshot`: the last crumb is the current page. A crumb is a node, or a
|
|
17
|
+
* `Crumb` object when it links. A trail too long for its row wraps onto the next line; a long parent
|
|
18
|
+
* truncates, showing its whole label in a tooltip on hover, focus and a tap, and the current page is
|
|
19
|
+
* never cut: its words wrap instead.
|
|
18
20
|
*/
|
|
19
21
|
export declare function Breadcrumbs({ items, label, ...rest }: {
|
|
20
|
-
/** The trail, first to current: a node, or a `Crumb` (`{ label, href, external? }`) for one that links. The last is the current page
|
|
22
|
+
/** The trail, first to current: a node, or a `Crumb` (`{ label, href, external? }`) for one that links. The last is the current page; a `Crumb` there links to it with `aria-current="page"`. */
|
|
21
23
|
items: Array<Crumb | ReactNode>;
|
|
22
24
|
/**
|
|
23
25
|
* The trail's accessible name, on its `<nav>`, for an app in another language.
|
package/dist/Breadcrumbs.js
CHANGED
|
@@ -2,28 +2,38 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { isValidElement } from "react";
|
|
3
3
|
import { cx, focusRing } from "./cx.js";
|
|
4
4
|
import { renderLink } from "./link.js";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { Truncated } from "./truncated.js";
|
|
6
|
+
/** The classes of a crumb that links somewhere, for a router's own <Link>. */
|
|
7
|
+
export const crumbLinkClass = cx("rounded hover:underline", focusRing);
|
|
7
8
|
function isCrumb(crumb) {
|
|
8
9
|
return typeof crumb === "object" && crumb !== null && !isValidElement(crumb) && "label" in crumb;
|
|
9
10
|
}
|
|
11
|
+
/** A crumb's words as plain text, for the tooltip of a cut parent; a node that is not text has none. */
|
|
12
|
+
function crumbText(crumb) {
|
|
13
|
+
const label = isCrumb(crumb) ? crumb.label : crumb;
|
|
14
|
+
return typeof label === "string" || typeof label === "number" ? String(label) : undefined;
|
|
15
|
+
}
|
|
10
16
|
function CrumbContent({ crumb, current, }) {
|
|
11
17
|
if (!isCrumb(crumb))
|
|
12
18
|
return crumb;
|
|
13
|
-
if (current)
|
|
14
|
-
return crumb.label;
|
|
15
19
|
return renderLink({
|
|
16
20
|
href: crumb.href,
|
|
17
21
|
external: crumb.external,
|
|
18
22
|
className: crumbLinkClass,
|
|
23
|
+
"aria-current": current ? "page" : undefined,
|
|
19
24
|
children: crumb.label,
|
|
20
25
|
});
|
|
21
26
|
}
|
|
22
27
|
/**
|
|
23
|
-
* `org / project / build / snapshot`:
|
|
24
|
-
*
|
|
28
|
+
* `org / project / build / snapshot`: the last crumb is the current page. A crumb is a node, or a
|
|
29
|
+
* `Crumb` object when it links. A trail too long for its row wraps onto the next line; a long parent
|
|
30
|
+
* truncates, showing its whole label in a tooltip on hover, focus and a tap, and the current page is
|
|
31
|
+
* never cut: its words wrap instead.
|
|
25
32
|
*/
|
|
26
33
|
export function Breadcrumbs({ items, label = "Breadcrumb", ...rest }) {
|
|
27
34
|
const last = items.length - 1;
|
|
28
|
-
return (_jsx("nav", { ...rest, "aria-label": label, className: "min-w-0", children: _jsx("ol", { className: "flex min-w-0 items-center gap-2 text-sm", children: items.map((crumb, index) =>
|
|
35
|
+
return (_jsx("nav", { ...rest, "aria-label": label, className: "min-w-0", children: _jsx("ol", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-sm", children: items.map((crumb, index) => {
|
|
36
|
+
const current = index === last;
|
|
37
|
+
return (_jsxs("li", { "aria-current": current && !isCrumb(crumb) ? "page" : undefined, className: "flex min-w-0 items-center gap-2", children: [index > 0 && (_jsx("span", { "aria-hidden": "true", className: "text-slate-400", children: "/" })), current ? (_jsx("span", { className: "min-w-0 font-medium [overflow-wrap:anywhere] text-slate-900", children: _jsx(CrumbContent, { crumb: crumb, current: current }) })) : (_jsx(Truncated, { text: crumbText(crumb), className: "max-w-48 min-w-0 text-slate-500", children: _jsx(CrumbContent, { crumb: crumb, current: current }) }))] }, index));
|
|
38
|
+
}) }) }));
|
|
29
39
|
}
|
package/dist/Button.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare const buttonSizeTables: {
|
|
|
15
15
|
box: Record<Size, string>;
|
|
16
16
|
boxMd: Record<Size, string>;
|
|
17
17
|
};
|
|
18
|
+
export declare const COUNT = "inline-flex min-h-4 min-w-4 items-center justify-center rounded-full border border-current px-1 text-[0.625rem]/[1.4] font-semibold tabular-nums";
|
|
18
19
|
/** Size, tone and variant: the look of a button, apart from its state. */
|
|
19
20
|
type ButtonLook = {
|
|
20
21
|
/**
|
package/dist/Button.js
CHANGED
|
@@ -69,8 +69,9 @@ const TOGGLE_OFF = {
|
|
|
69
69
|
hover: "hover:border-violet-400",
|
|
70
70
|
};
|
|
71
71
|
// The count chip: a pill in the button's own text colour (a hairline of `currentColor`), so it reads
|
|
72
|
-
// on every variant and tone and needs no palette entry. The size is a Badge's
|
|
73
|
-
|
|
72
|
+
// on every variant and tone and needs no palette entry. The size is a Badge's: rem text and a
|
|
73
|
+
// min-height, so the chip grows with the reader's text size.
|
|
74
|
+
export const COUNT = "inline-flex min-h-4 min-w-4 items-center justify-center rounded-full border border-current px-1 text-[0.625rem]/[1.4] font-semibold tabular-nums";
|
|
74
75
|
/** The label, then the count chip. The comma is for a screen reader only, so the name reads "Splits, 3". */
|
|
75
76
|
function withCount(children, count) {
|
|
76
77
|
if (count === undefined)
|
|
@@ -110,7 +111,7 @@ export function blockedButtonClass(variant = "primary", { size = "md" } = {}, st
|
|
|
110
111
|
}
|
|
111
112
|
function idleClass(variant, size, tone, { step, pressed }) {
|
|
112
113
|
const look = lookOf(variant, tone, pressed);
|
|
113
|
-
return cx(shape(variant, size, step), DISABLED_PLAIN, look.color, look.hover);
|
|
114
|
+
return cx(shape(variant, size, step), "cursor-pointer", DISABLED_PLAIN, look.color, look.hover);
|
|
114
115
|
}
|
|
115
116
|
function isLink(props) {
|
|
116
117
|
return props.href !== undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import { type HeadingLevel } from "./headingLevel.js";
|
|
3
|
+
import type { Passthrough } from "./props.js";
|
|
4
|
+
export type CallToActionProps = {
|
|
5
|
+
/** The ask, one line: "Start your first review today". Its heading names the band. */
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
/** A small label above the title, set in the monospace face. */
|
|
8
|
+
overline?: ReactNode;
|
|
9
|
+
/** One sentence under the title, as a `Lead`. */
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
/** One or two actions: a primary `Button` and, if it has one, an `outline` or `ghost` one. */
|
|
12
|
+
actions: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* The title's heading level, 2 to 6. It does not change how the title looks.
|
|
15
|
+
* @default one below the heading that holds the band: 2 on the page
|
|
16
|
+
*/
|
|
17
|
+
level?: HeadingLevel | undefined;
|
|
18
|
+
} & Passthrough;
|
|
19
|
+
/**
|
|
20
|
+
* The closing ask of a landing page: a rounded band on the subtle surface with a hairline edge, its
|
|
21
|
+
* overline, title, one sentence and one or two actions centred in it. It is a `<section>` named by
|
|
22
|
+
* its title. One per page, as the last block before the footer; a section's own actions stay in its
|
|
23
|
+
* `Section`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function CallToAction({ title, overline, description, actions, level, ...rest }: CallToActionProps): ReactElement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { Cluster } from "./Cluster.js";
|
|
4
|
+
import { useHeadingLevel } from "./headingLevel.js";
|
|
5
|
+
import { Lead, Overline, PageHeading } from "./typography.js";
|
|
6
|
+
/**
|
|
7
|
+
* The closing ask of a landing page: a rounded band on the subtle surface with a hairline edge, its
|
|
8
|
+
* overline, title, one sentence and one or two actions centred in it. It is a `<section>` named by
|
|
9
|
+
* its title. One per page, as the last block before the footer; a section's own actions stay in its
|
|
10
|
+
* `Section`.
|
|
11
|
+
*/
|
|
12
|
+
export function CallToAction({ title, overline, description, actions, level, ...rest }) {
|
|
13
|
+
const id = useId();
|
|
14
|
+
const own = useHeadingLevel(level);
|
|
15
|
+
const kicker = overline != null && overline !== false;
|
|
16
|
+
return (_jsx("section", { ...rest, "aria-labelledby": id, className: "rounded-2xl border border-slate-200 bg-slate-50 px-6 py-12 text-center sm:px-12 sm:py-16", children: _jsxs("div", { className: "mx-auto flex max-w-2xl flex-col items-center gap-4", children: [_jsxs("header", { children: [kicker && _jsx(Overline, { mono: true, children: overline }), _jsx(PageHeading, { as: `h${own}`, id: id, children: title })] }), description != null && description !== false && _jsx(Lead, { children: description }), _jsx("div", { className: "pt-2", children: _jsx(Cluster, { justify: "center", children: actions }) })] }) }));
|
|
17
|
+
}
|
package/dist/Callout.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const TONE_TEXT: Record<Tone, string>;
|
|
|
9
9
|
/**
|
|
10
10
|
* A tinted notice box, with an optional bold title above its body. Its text is text-sm (text-base/7
|
|
11
11
|
* inside a `Prose`, boxed or `banner`). `actions` puts a button or link
|
|
12
|
-
* at the end of the row
|
|
12
|
+
* at the end of the row, or under the text at full width below `sm`; `banner` makes it a flat strip (bottom border only, no radius) for the
|
|
13
13
|
* top of a `Card flush` and nowhere else: a padded card or a padded `FullBleedLayout` column
|
|
14
14
|
* would inset it. `align="center"` centres the text. In a page's column the notice is a plain Callout, first in the column's `Stack`. With `actions` the box is `relative`, so a `TextLink
|
|
15
15
|
* stretch` there makes the whole callout its click target, like a link in a table row. `icon`
|
|
@@ -37,7 +37,7 @@ export declare function Callout({ tone, icon, title, actions, banner, align, chi
|
|
|
37
37
|
* @default start
|
|
38
38
|
*/
|
|
39
39
|
align?: "start" | "center" | undefined;
|
|
40
|
-
/** A button or link at the end of the row, beside the title and body. */
|
|
40
|
+
/** A button or link at the end of the row, beside the title and body; on a phone, under them at full width. */
|
|
41
41
|
actions?: ReactNode;
|
|
42
42
|
children: ReactNode;
|
|
43
43
|
} & Passthrough): ReactElement;
|
package/dist/Callout.js
CHANGED
|
@@ -24,7 +24,7 @@ export const TONE_TEXT = {
|
|
|
24
24
|
/**
|
|
25
25
|
* A tinted notice box, with an optional bold title above its body. Its text is text-sm (text-base/7
|
|
26
26
|
* inside a `Prose`, boxed or `banner`). `actions` puts a button or link
|
|
27
|
-
* at the end of the row
|
|
27
|
+
* at the end of the row, or under the text at full width below `sm`; `banner` makes it a flat strip (bottom border only, no radius) for the
|
|
28
28
|
* top of a `Card flush` and nowhere else: a padded card or a padded `FullBleedLayout` column
|
|
29
29
|
* would inset it. `align="center"` centres the text. In a page's column the notice is a plain Callout, first in the column's `Stack`. With `actions` the box is `relative`, so a `TextLink
|
|
30
30
|
* stretch` there makes the whole callout its click target, like a link in a table row. `icon`
|
|
@@ -35,7 +35,7 @@ export const TONE_TEXT = {
|
|
|
35
35
|
export function Callout({ tone = "neutral", icon, title, actions, banner = false, align = "start", children, ...rest }) {
|
|
36
36
|
const size = useProse() ? "text-base/7" : "text-sm";
|
|
37
37
|
const content = withIcon(icon, title ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "font-semibold", children: title }), _jsx("div", { className: "mt-1", children: children })] })) : (children));
|
|
38
|
-
return (_jsx("div", { role: ROLE[tone], className: cx(Boolean(actions) && "relative", banner ? "border-b px-5 py-3" : "rounded-xl border p-4", size, TONE_SURFACE[tone], TONE_TEXT[tone], align === "center" && "text-center"), ...rest, children: _jsx(GapProvider, { gap: "xs", children: actions ? (_jsxs("div", { className: "flex items-center justify-between
|
|
38
|
+
return (_jsx("div", { role: ROLE[tone], className: cx(Boolean(actions) && "relative", banner ? "border-b px-5 py-3" : "rounded-xl border p-4", size, TONE_SURFACE[tone], TONE_TEXT[tone], align === "center" && "text-center"), ...rest, children: _jsx(GapProvider, { gap: "xs", children: actions ? (_jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [_jsx("div", { className: "min-w-0", children: content }), _jsx("div", { className: "flex items-center gap-2 *:flex-1 sm:shrink-0 sm:*:flex-none", children: actions })] })) : (content) }) }));
|
|
39
39
|
}
|
|
40
40
|
/** The callout's text with its `icon` at the start, the icon centred on the first line. */
|
|
41
41
|
function withIcon(icon, text) {
|
package/dist/Card.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef, type ReactElement, type ReactNode } from "react";
|
|
2
2
|
import type { Tone } from "./tone.js";
|
|
3
|
+
import { type CardHue } from "./cardForm.js";
|
|
3
4
|
import { type HeadingLevel } from "./headingLevel.js";
|
|
4
5
|
import type { IconName } from "./icons.js";
|
|
5
|
-
import type {
|
|
6
|
+
import type { Passthrough } from "./props.js";
|
|
6
7
|
import { type LoadingProps } from "./skeleton.js";
|
|
8
|
+
export type { CardHue } from "./cardForm.js";
|
|
7
9
|
import type { Size } from "./size.js";
|
|
8
10
|
type CardBase = LoadingProps & {
|
|
9
|
-
/** The card's heading (a small uppercase label unless `titleStyle` says otherwise). It names the card, which is then
|
|
11
|
+
/** The card's heading (a small uppercase label unless `titleStyle` says otherwise). It names the card, which is then an `article`. */
|
|
10
12
|
title?: string;
|
|
11
13
|
/**
|
|
12
14
|
* The title's heading level, 2 to 6. It does not change how the title looks.
|
|
@@ -28,8 +30,11 @@ type CardBase = LoadingProps & {
|
|
|
28
30
|
bar?: boolean;
|
|
29
31
|
/** No padding and `overflow-hidden`: the body (a table, a list) fills the card. */
|
|
30
32
|
flush?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
+
/**
|
|
34
|
+
* A dashed edge, for a card that stands for something not real yet: a plan, a draft, an imagined
|
|
35
|
+
* result beside a real one. With `bar` the strip's lower edge is dashed too.
|
|
36
|
+
*/
|
|
37
|
+
dashed?: boolean;
|
|
33
38
|
/**
|
|
34
39
|
* One of the library's icons, drawn at feature size in the accent colour above the title: the
|
|
35
40
|
* mark of a feature card. Ignored with `bar` and `flush`.
|
|
@@ -46,8 +51,9 @@ type CardBase = LoadingProps & {
|
|
|
46
51
|
inset?: ReactNode;
|
|
47
52
|
/**
|
|
48
53
|
* A `Pill` (or any small node) pinned in the top corner at the end edge, over the content and
|
|
49
|
-
* inside the radius, with no change to the layout. On a
|
|
50
|
-
*
|
|
54
|
+
* inside the radius, with no change to the layout. On a titled link card the link is named by the
|
|
55
|
+
* title alone; an untitled one is named by its whole content, badge included. A link or button in
|
|
56
|
+
* it is clickable on its own.
|
|
51
57
|
*
|
|
52
58
|
* Use it for a category (`Pill tone="info"`) or a flag on the thing itself.
|
|
53
59
|
*/
|
|
@@ -68,7 +74,26 @@ type CardBase = LoadingProps & {
|
|
|
68
74
|
* @default md
|
|
69
75
|
*/
|
|
70
76
|
size?: Size;
|
|
77
|
+
/**
|
|
78
|
+
* `sm` caps the card at 24rem, for a card that stands alone in a wide column (a sign-in panel, a
|
|
79
|
+
* plan). Left out, the card takes the width it is given.
|
|
80
|
+
*/
|
|
81
|
+
width?: "sm" | undefined;
|
|
71
82
|
children: ReactNode;
|
|
83
|
+
} & CardSurface;
|
|
84
|
+
/** `tone` and `hue` paint the same fill and edge, so a card takes one or the other. */
|
|
85
|
+
type CardSurface = {
|
|
86
|
+
/** A soft fill and border in the Callout's tones, for a data panel with a status. Ignored with `bar`. */
|
|
87
|
+
tone?: Tone | undefined;
|
|
88
|
+
hue?: undefined;
|
|
89
|
+
} | {
|
|
90
|
+
tone?: undefined;
|
|
91
|
+
/**
|
|
92
|
+
* One hue of a set of peer cards, such as one card per product: a soft fill and edge the theme
|
|
93
|
+
* paints. It is not a status (that is `tone`), and the title still names the card. Ignored with
|
|
94
|
+
* `bar` and `dashed`.
|
|
95
|
+
*/
|
|
96
|
+
hue?: CardHue | undefined;
|
|
72
97
|
};
|
|
73
98
|
type CardPanelProps = CardBase & {
|
|
74
99
|
/** Buttons or links at the end of the header: in the strip with `bar`, else beside the title. */
|
|
@@ -83,38 +108,66 @@ type CardPanelProps = CardBase & {
|
|
|
83
108
|
* body, so a keyboard can reach and scroll it.
|
|
84
109
|
*/
|
|
85
110
|
fill?: boolean;
|
|
86
|
-
/**
|
|
87
|
-
* `article` for a card that stands alone as a piece of content (a post, a listing). Left out, a
|
|
88
|
-
* titled card is a `section` named by its title, one with only an `aria-label` a `section` named
|
|
89
|
-
* by that, and any other a `div`. Not on a card that is a link.
|
|
90
|
-
*/
|
|
91
|
-
as?: "article" | undefined;
|
|
92
111
|
href?: undefined;
|
|
93
112
|
external?: undefined;
|
|
94
|
-
|
|
113
|
+
more?: undefined;
|
|
114
|
+
moreLabel?: undefined;
|
|
115
|
+
onPress?: undefined;
|
|
116
|
+
} & Omit<ComponentPropsWithoutRef<"article">, "title" | "className" | "style" | "children">;
|
|
95
117
|
type CardLinkProps = CardBase & {
|
|
96
118
|
actions?: undefined;
|
|
97
119
|
footer?: undefined;
|
|
98
120
|
fill?: undefined;
|
|
99
|
-
|
|
121
|
+
onPress?: undefined;
|
|
100
122
|
/** Opens in a new tab: adds `target="_blank"` and `rel="noreferrer"`. */
|
|
101
123
|
external?: boolean | undefined;
|
|
102
124
|
/**
|
|
103
|
-
* Makes the whole card one link to this URL, with no `actions
|
|
104
|
-
*
|
|
125
|
+
* Makes the whole card one link to this URL, with no `actions` or `footer`; an in-app path goes
|
|
126
|
+
* through the app's `LinkProvider`. The link is named by the card's title.
|
|
105
127
|
*/
|
|
106
128
|
href: string;
|
|
107
|
-
|
|
129
|
+
/**
|
|
130
|
+
* A "Read more" line with an arrow at the foot of the card, in the accent colour: the cue that the
|
|
131
|
+
* card goes somewhere, for a post or an article. Draw it on every card of a set or on none.
|
|
132
|
+
*/
|
|
133
|
+
more?: boolean | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* The words of the `more` line.
|
|
136
|
+
* @default "Read more"
|
|
137
|
+
*/
|
|
138
|
+
moreLabel?: string | undefined;
|
|
139
|
+
} & Passthrough &
|
|
140
|
+
/** The link's own: a file to save, a `rel` beyond `external`'s, and a press to track. */
|
|
141
|
+
Pick<ComponentPropsWithoutRef<"a">, "download" | "rel" | "onClick">;
|
|
142
|
+
type CardButtonProps = CardBase & {
|
|
143
|
+
actions?: undefined;
|
|
144
|
+
footer?: undefined;
|
|
145
|
+
fill?: undefined;
|
|
146
|
+
href?: undefined;
|
|
147
|
+
external?: undefined;
|
|
148
|
+
more?: undefined;
|
|
149
|
+
moreLabel?: undefined;
|
|
150
|
+
/**
|
|
151
|
+
* Makes the whole card one button that runs this, stretched over the card like a link card's link
|
|
152
|
+
* and named by its title: a card the user picks (a store, a plan). With no `actions`, `footer` or
|
|
153
|
+
* `href`. A picked card says so with `aria-pressed` and its own words (a `Pill` in `badge`).
|
|
154
|
+
*/
|
|
155
|
+
onPress: () => void;
|
|
156
|
+
} & Passthrough;
|
|
157
|
+
type CardProps = CardPanelProps | CardLinkProps | CardButtonProps;
|
|
108
158
|
/**
|
|
109
|
-
* A bordered panel with an optional title, count and status. A titled card is
|
|
110
|
-
* its title, one with only an `aria-label`
|
|
159
|
+
* A bordered panel with an optional title, count and status. A titled card is an `article` named by
|
|
160
|
+
* its title, one with only an `aria-label` an `article` too, and any other a `div`. Two opt-in forms
|
|
111
161
|
* for data views: `flush` drops the padding and clips the corners, for a table that runs edge to
|
|
112
162
|
* edge; `bar` puts the title, count and `actions` in a tinted strip across the top, over the body.
|
|
113
163
|
* A flush card has no padding for a `title`, so give it a `bar`. An empty state is an `EmptyState`,
|
|
114
164
|
* which draws its own dashed frame. Inside a card a `Stack` is `xs` apart, and the title's
|
|
115
165
|
* heading level is one below the heading that holds the card. `size="sm"` is the dense padding and `size="lg"` the
|
|
116
166
|
* roomy one, the same on a `ListRow` and a `FileDrop`. `tone` is the Callout's set, for a data panel that carries a status
|
|
117
|
-
* (a soft fill and border, no shadow); a message is still a `Callout`, and `bar` has no tone.
|
|
167
|
+
* (a soft fill and border, no shadow); a message is still a `Callout`, and `bar` has no tone. `hue`
|
|
168
|
+
* paints one of a set of peer cards in its own hue, the theme's; it is not a status, and `tone`,
|
|
169
|
+
* `bar` and `dashed` win over it. `dashed` draws a dashed edge for a card that stands for something
|
|
170
|
+
* not real yet, and with `bar` the strip's edge is dashed too. `width="sm"` caps the card at 24rem. A
|
|
118
171
|
* titled panel is named by its title: the root gets
|
|
119
172
|
* `aria-labelledby` pointing at the heading, unless the caller passes its own `aria-label` or
|
|
120
173
|
* `aria-labelledby`, which wins. Other props (`id`, `data-*`, `aria-*`) go on the root. The root is `relative`, so a
|
|
@@ -129,20 +182,24 @@ type CardLinkProps = CardBase & {
|
|
|
129
182
|
* total; in a `CardGrid` it stays at the foot of a card that is stretched to the row's height. It
|
|
130
183
|
* suits a panel, not a card that is a link.
|
|
131
184
|
*
|
|
132
|
-
* `fill` makes a panel take its parent's full height (the parent sets it): the title or bar
|
|
133
|
-
* put and the body scrolls
|
|
185
|
+
* `fill` makes a panel take its parent's full height (the parent sets it): the title or bar and the
|
|
186
|
+
* `inset` band stay put and the body scrolls, with room inside it for a focus ring at its edge. Not
|
|
187
|
+
* on a link card.
|
|
134
188
|
*
|
|
135
189
|
* `href` makes the whole card one link: a hover border and the focus ring, with the link stretched
|
|
136
|
-
* over the card, so it takes no `actions
|
|
137
|
-
* the body sits above the link and is clickable on its own. An
|
|
138
|
-
* router link through `LinkProvider`. `external` opens it in a
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
190
|
+
* over the card, so it takes no `actions` or `footer`. `onPress` makes it one button the same way. A
|
|
191
|
+
* `TextLink`, `Button` or `Checkbox` in the body sits above the link and is clickable on its own. An
|
|
192
|
+
* in-app `href` is drawn by the app's router link through `LinkProvider`. `external` opens it in a
|
|
193
|
+
* new tab, and `more` draws a "Read more" line at its foot. On a link or button card `id`, `data-*`
|
|
194
|
+
* and the describing `aria-*` (`aria-describedby`, `aria-details`, …) go on the card root; the
|
|
195
|
+
* control's own `aria-label`, `aria-labelledby`, `aria-current` and `aria-pressed` stay on it. The
|
|
196
|
+
* link or button is named by the card's title; an untitled one by the card's text, through the root's
|
|
197
|
+
* id, which is generated when the caller gives none.
|
|
198
|
+
*
|
|
199
|
+
* In a `CardGrid align="regions"` the card's header, body and footer line up with its neighbours'
|
|
200
|
+
* across the row.
|
|
143
201
|
*
|
|
144
202
|
* While `loading` a card with no children draws three lines of text bones, a `flush` one three
|
|
145
203
|
* `ListRow` bones; what it has (its title, its children) draws as usual.
|
|
146
204
|
*/
|
|
147
|
-
export declare function Card(props:
|
|
148
|
-
export {};
|
|
205
|
+
export declare function Card(props: CardProps): ReactElement;
|