@slashsuite/ui-react 0.12.1 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +4 -2
- package/dist/Button.js +9 -87
- 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 +116 -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/core/button.d.ts +33 -0
- package/dist/core/button.js +89 -0
- package/dist/core/control.d.ts +15 -0
- package/dist/core/control.js +14 -0
- package/dist/core/fixtures/button.d.ts +26 -0
- package/dist/core/fixtures/button.js +52 -0
- package/dist/core/fixtures/types.d.ts +13 -0
- package/dist/core/fixtures/types.js +10 -0
- package/dist/core/focus.d.ts +7 -0
- package/dist/core/focus.js +7 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.js +12 -0
- package/dist/core/parity.d.ts +22 -0
- package/dist/core/parity.js +53 -0
- package/dist/core/themeNative.d.ts +62 -0
- package/dist/core/themeNative.js +290 -0
- package/dist/cx.d.ts +17 -5
- package/dist/cx.js +18 -5
- package/dist/dateLocale.d.ts +17 -0
- package/dist/dateLocale.js +30 -0
- package/dist/density.d.ts +17 -3
- package/dist/density.js +30 -19
- 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/focus.d.ts +2 -0
- package/dist/focus.js +9 -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 +77 -0
- package/dist/stateMachineDots.js +188 -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 +38 -0
- package/dist/useFlowLayout.js +122 -0
- package/package.json +5 -3
package/dist/Card.js
CHANGED
|
@@ -1,66 +1,36 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId } from "react";
|
|
3
|
-
import { TONE_SURFACE } from "./Callout.js";
|
|
4
3
|
import { CardBadge } from "./CardBadge.js";
|
|
5
|
-
import {
|
|
6
|
-
import { InCard } from "./cardContext.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { cardBody } from "./CardBody.js";
|
|
5
|
+
import { InCard, InRegions, useRegions } from "./cardContext.js";
|
|
6
|
+
import { cardControl, splitRootAttrs } from "./cardControl.js";
|
|
7
|
+
import { cardClass, cardForm, withFooter } from "./cardForm.js";
|
|
8
|
+
import { CardFooter, CardMore } from "./CardParts.js";
|
|
9
|
+
import { cx } from "./cx.js";
|
|
9
10
|
import { DensityProvider } from "./density.js";
|
|
10
11
|
import { HeadingLevelProvider, useHeadingLevel } from "./headingLevel.js";
|
|
11
|
-
import { renderLink } from "./link.js";
|
|
12
12
|
import { GapProvider } from "./stackGap.js";
|
|
13
13
|
import { busy, LoadingScope, useLoading } from "./skeleton.js";
|
|
14
14
|
import { CardWait } from "./cardWait.js";
|
|
15
|
-
/** A card with a `footer`. */
|
|
16
|
-
function withFooter(form, footer) {
|
|
17
|
-
return { ...form, footer: Boolean(footer) };
|
|
18
|
-
}
|
|
19
|
-
/** A mark needs the padded body above a heading, so it has no place in a strip or a flush card. */
|
|
20
|
-
function paddedIcon(asked, bar) {
|
|
21
|
-
return bar || asked.flush ? undefined : asked.icon;
|
|
22
|
-
}
|
|
23
|
-
/** `bar` needs a title or actions to fill it and has no tone. */
|
|
24
|
-
function cardForm(asked, hasHeader) {
|
|
25
|
-
const bar = (asked.bar ?? false) && hasHeader;
|
|
26
|
-
return {
|
|
27
|
-
flush: asked.flush ?? false,
|
|
28
|
-
bar,
|
|
29
|
-
tone: bar ? undefined : asked.tone,
|
|
30
|
-
attention: asked.attention ?? false,
|
|
31
|
-
icon: paddedIcon(asked, bar),
|
|
32
|
-
fill: asked.fill ?? false,
|
|
33
|
-
size: asked.size,
|
|
34
|
-
footer: false,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function cardBorder(form) {
|
|
38
|
-
const surface = form.tone ? TONE_SURFACE[form.tone] : "border-slate-200/70 bg-white";
|
|
39
|
-
if (!form.attention)
|
|
40
|
-
return surface;
|
|
41
|
-
// The warn tone's strong edge in place of the border colour; the fill stays.
|
|
42
|
-
const fill = surface.split(" ").filter((c) => c.startsWith("bg-"));
|
|
43
|
-
return cx("border-amber-600", ...fill);
|
|
44
|
-
}
|
|
45
|
-
function cardPadding(form) {
|
|
46
|
-
return !form.flush && !form.bar && !form.footer && !form.fill && BODY_PAD[form.size];
|
|
47
|
-
}
|
|
48
|
-
function cardClass(form) {
|
|
49
|
-
return cx("relative scroll-mt-[calc(var(--app-header,0px)+1rem)] rounded-xl border target:outline-2 target:outline-violet-600", liftInteractive, cardBorder(form), cardPadding(form), !form.tone && "shadow-sm", (form.flush || form.bar || form.footer || form.fill) && "overflow-hidden", form.fill ? "flex h-full min-h-0 flex-col" : form.footer && "flex flex-col");
|
|
50
|
-
}
|
|
51
15
|
function isCardLink(props) {
|
|
52
16
|
return props.href !== undefined;
|
|
53
17
|
}
|
|
18
|
+
function isCardButton(props) {
|
|
19
|
+
return props.onPress !== undefined;
|
|
20
|
+
}
|
|
54
21
|
/**
|
|
55
|
-
* A bordered panel with an optional title, count and status. A titled card is
|
|
56
|
-
* its title, one with only an `aria-label`
|
|
22
|
+
* A bordered panel with an optional title, count and status. A titled card is an `article` named by
|
|
23
|
+
* its title, one with only an `aria-label` an `article` too, and any other a `div`. Two opt-in forms
|
|
57
24
|
* for data views: `flush` drops the padding and clips the corners, for a table that runs edge to
|
|
58
25
|
* edge; `bar` puts the title, count and `actions` in a tinted strip across the top, over the body.
|
|
59
26
|
* A flush card has no padding for a `title`, so give it a `bar`. An empty state is an `EmptyState`,
|
|
60
27
|
* which draws its own dashed frame. Inside a card a `Stack` is `xs` apart, and the title's
|
|
61
28
|
* heading level is one below the heading that holds the card. `size="sm"` is the dense padding and `size="lg"` the
|
|
62
29
|
* roomy one, the same on a `ListRow` and a `FileDrop`. `tone` is the Callout's set, for a data panel that carries a status
|
|
63
|
-
* (a soft fill and border, no shadow); a message is still a `Callout`, and `bar` has no tone.
|
|
30
|
+
* (a soft fill and border, no shadow); a message is still a `Callout`, and `bar` has no tone. `hue`
|
|
31
|
+
* paints one of a set of peer cards in its own hue, the theme's; it is not a status, and `tone`,
|
|
32
|
+
* `bar` and `dashed` win over it. `dashed` draws a dashed edge for a card that stands for something
|
|
33
|
+
* not real yet, and with `bar` the strip's edge is dashed too. `width="sm"` caps the card at 24rem. A
|
|
64
34
|
* titled panel is named by its title: the root gets
|
|
65
35
|
* `aria-labelledby` pointing at the heading, unless the caller passes its own `aria-label` or
|
|
66
36
|
* `aria-labelledby`, which wins. Other props (`id`, `data-*`, `aria-*`) go on the root. The root is `relative`, so a
|
|
@@ -75,47 +45,55 @@ function isCardLink(props) {
|
|
|
75
45
|
* total; in a `CardGrid` it stays at the foot of a card that is stretched to the row's height. It
|
|
76
46
|
* suits a panel, not a card that is a link.
|
|
77
47
|
*
|
|
78
|
-
* `fill` makes a panel take its parent's full height (the parent sets it): the title or bar
|
|
79
|
-
* put and the body scrolls
|
|
48
|
+
* `fill` makes a panel take its parent's full height (the parent sets it): the title or bar and the
|
|
49
|
+
* `inset` band stay put and the body scrolls, with room inside it for a focus ring at its edge. Not
|
|
50
|
+
* on a link card.
|
|
80
51
|
*
|
|
81
52
|
* `href` makes the whole card one link: a hover border and the focus ring, with the link stretched
|
|
82
|
-
* over the card, so it takes no `actions
|
|
83
|
-
* the body sits above the link and is clickable on its own. An
|
|
84
|
-
* router link through `LinkProvider`. `external` opens it in a
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
53
|
+
* over the card, so it takes no `actions` or `footer`. `onPress` makes it one button the same way. A
|
|
54
|
+
* `TextLink`, `Button` or `Checkbox` in the body sits above the link and is clickable on its own. An
|
|
55
|
+
* in-app `href` is drawn by the app's router link through `LinkProvider`. `external` opens it in a
|
|
56
|
+
* new tab, and `more` draws a "Read more" line at its foot. On a link or button card `id`, `data-*`
|
|
57
|
+
* and the describing `aria-*` (`aria-describedby`, `aria-details`, …) go on the card root; the
|
|
58
|
+
* control's own `aria-label`, `aria-labelledby`, `aria-current` and `aria-pressed` stay on it. The
|
|
59
|
+
* link or button is named by the card's title; an untitled one by the card's text, through the root's
|
|
60
|
+
* id, which is generated when the caller gives none.
|
|
61
|
+
*
|
|
62
|
+
* In a `CardGrid align="regions"` the card's header, body and footer line up with its neighbours'
|
|
63
|
+
* across the row.
|
|
89
64
|
*
|
|
90
65
|
* While `loading` a card with no children draws three lines of text bones, a `flush` one three
|
|
91
66
|
* `ListRow` bones; what it has (its title, its children) draws as usual.
|
|
92
67
|
*/
|
|
93
68
|
export function Card(props) {
|
|
94
69
|
const level = useHeadingLevel(props.level);
|
|
70
|
+
const regions = useRegions();
|
|
95
71
|
const { loading, owner } = useLoading(props.loading);
|
|
96
72
|
const shown = {
|
|
97
73
|
...props,
|
|
98
74
|
...busy(owner, loading),
|
|
99
75
|
children: (_jsx(CardWait, { loading: loading, owner: owner, label: props.loadingLabel, flush: props.flush, children: props.children })),
|
|
100
76
|
};
|
|
101
|
-
return (_jsx(InCard, { children: _jsx(GapProvider, { gap: "xs", children: _jsx(DensityProvider, { size: props.size === "sm" ? "sm" : null, children: _jsx(LoadingScope, { loading: loading, children: props.title ? (_jsx(HeadingLevelProvider, { level: level, children: cardOf(shown, level) })) : (cardOf(shown, level)) }) }) }) }));
|
|
77
|
+
return (_jsx(InCard, { children: _jsx(InRegions, { value: false, children: _jsx(GapProvider, { gap: "xs", children: _jsx(DensityProvider, { size: props.size === "sm" ? "sm" : null, children: _jsx(LoadingScope, { loading: loading, children: props.title ? (_jsx(HeadingLevelProvider, { level: level, children: cardOf(shown, level, regions) })) : (cardOf(shown, level, regions)) }) }) }) }) }));
|
|
102
78
|
}
|
|
103
|
-
/** Whether a caller named the card: a card with a name is
|
|
79
|
+
/** Whether a caller named the card: a card with a name is an article, as a plain div may carry no `aria-label`. */
|
|
104
80
|
function hasOwnName(rest) {
|
|
105
81
|
return rest["aria-label"] !== undefined || rest["aria-labelledby"] !== undefined;
|
|
106
82
|
}
|
|
107
83
|
/** The card in its form, its title at `level`. An untitled card adds no heading, so what is inside keeps the level of what holds it. */
|
|
108
|
-
function cardOf(props, level) {
|
|
109
|
-
|
|
84
|
+
function cardOf(props, level, regions) {
|
|
85
|
+
if (isCardLink(props) || isCardButton(props)) {
|
|
86
|
+
return _jsx(ActionCard, { ...props, level: level, regions: regions });
|
|
87
|
+
}
|
|
88
|
+
return _jsx(PanelCard, { ...props, level: level, regions: regions });
|
|
110
89
|
}
|
|
111
|
-
/** A card that is not a link
|
|
90
|
+
/** A card that is not a link or a button: an `article` named by its heading or the caller's name, a `div` without one. */
|
|
112
91
|
function PanelCard(props) {
|
|
113
|
-
const { title, titleStyle, count, status, actions, footer, bar, flush, tone, badge, inset, attention, icon, fill, size = "md", level, children, loading: _loading, loadingLabel: _loadingLabel, ...
|
|
114
|
-
const { as, ...rest } = panel;
|
|
92
|
+
const { title, titleStyle, count, status, actions, footer, bar, dashed, flush, tone, hue, badge, inset, attention, icon, fill, width, size = "md", level, regions, children, loading: _loading, loadingLabel: _loadingLabel, href: _href, external: _external, more: _more, moreLabel: _moreLabel, onPress: _onPress, ...rest } = props;
|
|
115
93
|
const labelled = hasOwnName(rest);
|
|
116
|
-
const Tag =
|
|
94
|
+
const Tag = title || labelled ? "article" : "div";
|
|
117
95
|
const headingId = useId();
|
|
118
|
-
const form = withFooter(cardForm({ flush, bar, tone, attention, icon, fill, size }, Boolean(title || actions)), footer);
|
|
96
|
+
const form = withFooter(cardForm({ flush, bar, dashed, tone, hue, attention, icon, fill, width, size }, Boolean(title || actions), regions), footer);
|
|
119
97
|
// The title names the card; a caller's own name wins.
|
|
120
98
|
const named = title && !labelled;
|
|
121
99
|
return (_jsxs(Tag, { ...(named ? { "aria-labelledby": headingId } : {}), ...rest, className: cardClass(form), children: [cardBody(form, {
|
|
@@ -130,34 +108,19 @@ function PanelCard(props) {
|
|
|
130
108
|
headingId,
|
|
131
109
|
}), form.footer && _jsx(CardFooter, { size: form.size, children: footer }), badge && _jsx(CardBadge, { size: form.size, children: badge })] }));
|
|
132
110
|
}
|
|
133
|
-
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
const onRoot = key === "id" || key.startsWith("data-") || (key.startsWith("aria-") && !LINK_OWN.has(key));
|
|
141
|
-
(onRoot ? root : link)[key] = value;
|
|
142
|
-
}
|
|
143
|
-
return [root, link];
|
|
144
|
-
}
|
|
145
|
-
/** A card that is a link: a `div` with the link stretched over it as an empty overlay, so the card's own links and buttons are not nested in it. */
|
|
146
|
-
function LinkCard(props) {
|
|
147
|
-
const { title, titleStyle, count, status, actions, bar, flush, tone, badge, inset, attention, icon, size = "md", level, children, external = false, href, loading: _loading, loadingLabel: _loadingLabel, ...rest } = props;
|
|
148
|
-
const form = cardForm({ flush, bar, tone, attention, icon, size }, Boolean(title));
|
|
111
|
+
/**
|
|
112
|
+
* A card that is a link or a button: a `div` with the control stretched over it as an empty
|
|
113
|
+
* overlay, so the card's own links and buttons are not nested in it.
|
|
114
|
+
*/
|
|
115
|
+
function ActionCard(props) {
|
|
116
|
+
const { title, titleStyle, count, status, actions, bar, dashed, flush, tone, hue, badge, inset, attention, icon, width, size = "md", level, regions, children, external: _external, href: _href, onPress: _onPress, more, moreLabel = "Read more", loading: _loading, loadingLabel: _loadingLabel, ...rest } = props;
|
|
117
|
+
const form = cardForm({ flush, bar, dashed, tone, hue, attention, icon, width, size }, Boolean(title), regions);
|
|
149
118
|
const generated = useId();
|
|
150
|
-
const
|
|
151
|
-
|
|
119
|
+
const headingId = useId();
|
|
120
|
+
const [root, control] = splitRootAttrs(rest);
|
|
121
|
+
// An untitled card's control is named by the whole card, so the root needs an id: the caller's, else a generated one.
|
|
152
122
|
const cardId = typeof root["id"] === "string" ? root["id"] : generated;
|
|
153
|
-
return (_jsxs("div", { ...root, id: cardId, className: cx(cardClass(form), "transition hover:border-violet-400"), children: [
|
|
154
|
-
...(link["aria-label"] === undefined ? { "aria-labelledby": cardId } : {}),
|
|
155
|
-
...link,
|
|
156
|
-
href,
|
|
157
|
-
external,
|
|
158
|
-
className: cx("link-stretch absolute inset-0 rounded-xl", focusRing, "focus-visible:-outline-offset-2"),
|
|
159
|
-
children: null,
|
|
160
|
-
}), cardBody(form, {
|
|
123
|
+
return (_jsxs("div", { ...root, id: cardId, className: cx(cardClass(form), "transition hover:border-violet-400"), children: [cardControl(props, control, title ? headingId : cardId), cardBody(form, {
|
|
161
124
|
title,
|
|
162
125
|
titleStyle,
|
|
163
126
|
level,
|
|
@@ -165,7 +128,7 @@ function LinkCard(props) {
|
|
|
165
128
|
status,
|
|
166
129
|
actions,
|
|
167
130
|
inset,
|
|
168
|
-
children,
|
|
169
|
-
headingId
|
|
131
|
+
children: more ? (_jsxs(_Fragment, { children: [children, _jsx(CardMore, { children: moreLabel })] })) : (children),
|
|
132
|
+
headingId,
|
|
170
133
|
}), badge && _jsx(CardBadge, { size: form.size, children: badge })] }));
|
|
171
134
|
}
|
package/dist/CardBody.d.ts
CHANGED
package/dist/CardBody.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { CardBar, CardHeader, CardHeading, CardIcon, CardInset } from "./CardParts.js";
|
|
3
3
|
import { cx } from "./cx.js";
|
|
4
|
+
import { ScrollBody } from "./scrollBody.js";
|
|
4
5
|
/** The padding of a card's body by `size`. */
|
|
5
6
|
export const BODY_PAD = { sm: "p-3", md: "p-5", lg: "p-6" };
|
|
6
7
|
function insetBand(form, inset) {
|
|
@@ -10,21 +11,50 @@ function insetBand(form, inset) {
|
|
|
10
11
|
}
|
|
11
12
|
/** With `fill` the body takes the room the header (and a footer) leave, and only it scrolls. */
|
|
12
13
|
const SCROLL = "min-h-0 flex-1 overflow-y-auto";
|
|
14
|
+
/**
|
|
15
|
+
* The room a scroller with no padding of its own gives a focus ring at its edge: `focusRing` draws
|
|
16
|
+
* 2px out past a 2px offset, so 4px inside the scroller, given back by the same margin outside it.
|
|
17
|
+
*/
|
|
18
|
+
const RING_ROOM = "-m-1 p-1";
|
|
19
|
+
/** What names a filled body when it takes a tab stop: the card's heading, or its title where the heading has no id. */
|
|
20
|
+
function scrollName(parts) {
|
|
21
|
+
if (!parts.title)
|
|
22
|
+
return {};
|
|
23
|
+
return parts.headingId ? { labelledBy: parts.headingId } : { label: parts.title };
|
|
24
|
+
}
|
|
13
25
|
/** The padding the body takes itself, when the root has none: never on a flush card. */
|
|
14
26
|
const pad = (form) => !form.flush && BODY_PAD[form.size];
|
|
15
27
|
/** The icon, header, inset band and children of a card with no bar. */
|
|
16
28
|
function plainBody(form, heading, parts) {
|
|
17
|
-
const content = (_jsxs(_Fragment, { children: [form.icon && _jsx(CardIcon, { name: form.icon, size: form.size }), _jsx(CardHeader, { heading: heading, actions: parts.actions, size: form.size }), insetBand(form, parts.inset), form.fill ? _jsx(
|
|
29
|
+
const content = (_jsxs(_Fragment, { children: [form.icon && _jsx(CardIcon, { name: form.icon, size: form.size }), _jsx(CardHeader, { heading: heading, actions: parts.actions, size: form.size }), insetBand(form, parts.inset), form.fill ? (_jsx(ScrollBody, { ...scrollName(parts), className: cx(SCROLL, !form.flush && RING_ROOM), children: parts.children })) : (parts.children)] }));
|
|
18
30
|
if (form.fill) {
|
|
19
31
|
return _jsx("div", { className: cx("flex min-h-0 flex-1 flex-col", pad(form)), children: content });
|
|
20
32
|
}
|
|
21
33
|
// With a footer the root has no padding, so the body pads itself and takes the room left over.
|
|
22
34
|
return form.footer ? _jsx("div", { className: cx("flex-1", pad(form)), children: content }) : content;
|
|
23
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* A card in a `CardGrid align="regions"`: its header, body and footer are rows of the grid's
|
|
38
|
+
* subgrid, so each starts where its neighbours' do. The root has no padding; each row pads itself.
|
|
39
|
+
*/
|
|
40
|
+
function regionsBody(form, heading, parts) {
|
|
41
|
+
if (form.bar) {
|
|
42
|
+
return (_jsxs(_Fragment, { children: [_jsx(CardBar, { heading: heading, actions: parts.actions, size: form.size, dashed: form.dashed }), _jsxs("div", { className: pad(form) || undefined, children: [insetBand(form, parts.inset), parts.children] })] }));
|
|
43
|
+
}
|
|
44
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: cx(pad(form), "pb-0"), children: [form.icon && _jsx(CardIcon, { name: form.icon, size: form.size }), _jsx(CardHeader, { heading: heading, actions: parts.actions, size: form.size }), insetBand(form, parts.inset)] }), _jsx("div", { className: cx(pad(form), "pt-0"), children: parts.children })] }));
|
|
45
|
+
}
|
|
46
|
+
/** A bar card's body. With `fill` the inset band stays put above the scroller, as it does without a bar. */
|
|
47
|
+
function barBody(form, parts) {
|
|
48
|
+
if (!form.fill) {
|
|
49
|
+
return (_jsxs("div", { className: cx(form.footer && "flex-1", pad(form)) || undefined, children: [insetBand(form, parts.inset), parts.children] }));
|
|
50
|
+
}
|
|
51
|
+
return (_jsxs(_Fragment, { children: [parts.inset && _jsx("div", { className: cx(pad(form), "pb-0"), children: insetBand(form, parts.inset) }), _jsx(ScrollBody, { ...scrollName(parts), className: cx(SCROLL, pad(form), Boolean(parts.inset) && (form.flush ? "pt-0" : "-mt-1 pt-1")), children: parts.children })] }));
|
|
52
|
+
}
|
|
24
53
|
export function cardBody(form, parts) {
|
|
25
54
|
const heading = parts.title && (_jsx(CardHeading, { id: parts.headingId, title: parts.title, titleStyle: parts.titleStyle, level: parts.level, count: parts.count, status: parts.status, bar: form.bar, spaced: !form.bar && !parts.actions, size: form.size }));
|
|
55
|
+
if (form.regions)
|
|
56
|
+
return regionsBody(form, heading, parts);
|
|
26
57
|
if (!form.bar)
|
|
27
58
|
return plainBody(form, heading, parts);
|
|
28
|
-
|
|
29
|
-
return (_jsxs(_Fragment, { children: [_jsx(CardBar, { heading: heading, actions: parts.actions, size: form.size }), _jsxs("div", { className: cx(grow, pad(form)) || undefined, children: [insetBand(form, parts.inset), parts.children] })] }));
|
|
59
|
+
return (_jsxs(_Fragment, { children: [_jsx(CardBar, { heading: heading, actions: parts.actions, size: form.size, dashed: form.dashed }), barBody(form, parts)] }));
|
|
30
60
|
}
|
package/dist/CardGrid.d.ts
CHANGED
|
@@ -11,6 +11,12 @@ declare const AUTO_MIN_WIDTH: {
|
|
|
11
11
|
readonly sm: "grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]";
|
|
12
12
|
readonly md: "grid-cols-[repeat(auto-fill,minmax(17rem,1fr))]";
|
|
13
13
|
};
|
|
14
|
+
/** How the cards of a row meet: `regions` makes every cell a subgrid of three rows (header, body, footer). */
|
|
15
|
+
declare const ALIGN: {
|
|
16
|
+
readonly stretch: undefined;
|
|
17
|
+
readonly start: "items-start";
|
|
18
|
+
readonly regions: undefined;
|
|
19
|
+
};
|
|
14
20
|
type CardGridProps = ({
|
|
15
21
|
/**
|
|
16
22
|
* Cards per row from `lg` (one on a phone, two from `sm`), or `auto` for as many as fit.
|
|
@@ -31,8 +37,19 @@ type CardGridProps = ({
|
|
|
31
37
|
*/
|
|
32
38
|
minWidth?: keyof typeof AUTO_MIN_WIDTH | undefined;
|
|
33
39
|
}) & {
|
|
34
|
-
/**
|
|
35
|
-
|
|
40
|
+
/**
|
|
41
|
+
* `start` keeps each card its own height; the default stretches every card to the tallest in its
|
|
42
|
+
* row. `regions` stretches them too and lines up each card's header, body and footer with its
|
|
43
|
+
* neighbours' across the row, so titles of different lengths do not push the bodies out of line.
|
|
44
|
+
* @default stretch
|
|
45
|
+
*/
|
|
46
|
+
align?: keyof typeof ALIGN | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* The fewest cards in a row: `2` keeps two small tiles side by side on a phone (products in a
|
|
49
|
+
* shop), where the default is one.
|
|
50
|
+
* @default 1
|
|
51
|
+
*/
|
|
52
|
+
minColumns?: 1 | 2 | undefined;
|
|
36
53
|
/** `ul` makes the grid a list: each child is wrapped in an `<li>`. Default `div`. */
|
|
37
54
|
as?: "div" | "ul" | undefined;
|
|
38
55
|
/** Drawn in place of the grid when there are no children: an `EmptyState`. */
|
|
@@ -44,10 +61,21 @@ type CardGridProps = ({
|
|
|
44
61
|
* A main area beside a narrower one is not a grid of tiles: it is `SideColumn` (`asideWidth="third"`
|
|
45
62
|
* for two thirds and one). `columns="auto"` instead fits as many per row as the width allows, each at least `minWidth` wide:
|
|
46
63
|
* `md` (17rem, the default) or `sm` (12rem). `align="start"` keeps each card its own height
|
|
47
|
-
* instead of stretching it to the tallest in its row
|
|
64
|
+
* instead of stretching it to the tallest in its row; `align="regions"` lines up each card's header,
|
|
65
|
+
* body and footer across the row (CSS subgrid). `minColumns={2}` keeps two tiles to a row on a
|
|
66
|
+
* phone. Every cell has `min-w-0`, so a truncating name inside a card cuts instead of widening its
|
|
67
|
+
* column. A `CardGridRow` spans every column. `as="ul"` makes it a list of cards for a
|
|
48
68
|
* screen reader: the grid is a `<ul>` and each child is wrapped in an `<li>`, still stretched.
|
|
49
69
|
* With no children it draws `empty` (an `EmptyState`) in place of the grid. While `loading` with
|
|
50
70
|
* none it draws one card of bones per column (three for `auto`), never `empty`.
|
|
51
71
|
*/
|
|
52
|
-
export declare function CardGrid({ columns, minWidth, align, as: Tag, empty, children, loading, loadingLabel, ...rest }: CardGridProps): ReactElement;
|
|
72
|
+
export declare function CardGrid({ columns, minWidth, align, minColumns, as: Tag, empty, children, loading, loadingLabel, ...rest }: CardGridProps): ReactElement;
|
|
73
|
+
/**
|
|
74
|
+
* One item that spans every column of a `CardGrid`: a heading over a group of cards, or one wide
|
|
75
|
+
* card in the run (an announcement among products). In `as="ul"` its `<li>` spans the row. It takes
|
|
76
|
+
* no `align="regions"` rows: what it holds keeps its own layout.
|
|
77
|
+
*/
|
|
78
|
+
export declare function CardGridRow({ children, ...rest }: {
|
|
79
|
+
children: ReactNode;
|
|
80
|
+
} & Passthrough): ReactElement;
|
|
53
81
|
export {};
|
package/dist/CardGrid.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Children, isValidElement } from "react";
|
|
3
3
|
import { Card } from "./Card.js";
|
|
4
|
+
import { InRegions } from "./cardContext.js";
|
|
4
5
|
import { cx } from "./cx.js";
|
|
5
6
|
import { EmptySlot, hasNoChildren } from "./emptySlot.js";
|
|
6
7
|
import { useWait } from "./layoutWait.js";
|
|
@@ -15,38 +16,71 @@ const AUTO_MIN_WIDTH = {
|
|
|
15
16
|
sm: "grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]",
|
|
16
17
|
md: "grid-cols-[repeat(auto-fill,minmax(17rem,1fr))]",
|
|
17
18
|
};
|
|
18
|
-
|
|
19
|
+
/** The same with `minColumns={2}`: a card narrows to half the row (less the `gap-4`) before the row drops to one. */
|
|
20
|
+
const AUTO_MIN_WIDTH_TWO = {
|
|
21
|
+
sm: "grid-cols-[repeat(auto-fill,minmax(min(12rem,calc((100%_-_1rem)/2)),1fr))]",
|
|
22
|
+
md: "grid-cols-[repeat(auto-fill,minmax(min(17rem,calc((100%_-_1rem)/2)),1fr))]",
|
|
23
|
+
};
|
|
24
|
+
/** How the cards of a row meet: `regions` makes every cell a subgrid of three rows (header, body, footer). */
|
|
25
|
+
const ALIGN = {
|
|
26
|
+
stretch: undefined,
|
|
27
|
+
start: "items-start",
|
|
28
|
+
regions: undefined,
|
|
29
|
+
};
|
|
30
|
+
/** A list item's own layout: a grid, so its one card fills the item, or for `regions` a subgrid of the card's three rows. */
|
|
31
|
+
const ITEM = {
|
|
32
|
+
stretch: "grid grid-cols-1",
|
|
33
|
+
start: "grid grid-cols-1",
|
|
34
|
+
regions: "row-span-3 grid grid-rows-subgrid",
|
|
35
|
+
};
|
|
36
|
+
function gridColumns(columns, minWidth, minColumns) {
|
|
19
37
|
if (columns === "auto")
|
|
20
|
-
return AUTO_MIN_WIDTH[minWidth];
|
|
21
|
-
return cx("grid-cols-1 sm:grid-cols-2", COLUMNS[columns]);
|
|
38
|
+
return (minColumns === 2 ? AUTO_MIN_WIDTH_TWO : AUTO_MIN_WIDTH)[minWidth];
|
|
39
|
+
return cx(minColumns === 2 ? "grid-cols-2" : "grid-cols-1 sm:grid-cols-2", COLUMNS[columns]);
|
|
22
40
|
}
|
|
23
41
|
/**
|
|
24
42
|
* A responsive grid of tiles of one width: one column on a phone, two from `sm`, `columns` from `lg`.
|
|
25
43
|
* A main area beside a narrower one is not a grid of tiles: it is `SideColumn` (`asideWidth="third"`
|
|
26
44
|
* for two thirds and one). `columns="auto"` instead fits as many per row as the width allows, each at least `minWidth` wide:
|
|
27
45
|
* `md` (17rem, the default) or `sm` (12rem). `align="start"` keeps each card its own height
|
|
28
|
-
* instead of stretching it to the tallest in its row
|
|
46
|
+
* instead of stretching it to the tallest in its row; `align="regions"` lines up each card's header,
|
|
47
|
+
* body and footer across the row (CSS subgrid). `minColumns={2}` keeps two tiles to a row on a
|
|
48
|
+
* phone. Every cell has `min-w-0`, so a truncating name inside a card cuts instead of widening its
|
|
49
|
+
* column. A `CardGridRow` spans every column. `as="ul"` makes it a list of cards for a
|
|
29
50
|
* screen reader: the grid is a `<ul>` and each child is wrapped in an `<li>`, still stretched.
|
|
30
51
|
* With no children it draws `empty` (an `EmptyState`) in place of the grid. While `loading` with
|
|
31
52
|
* none it draws one card of bones per column (three for `auto`), never `empty`.
|
|
32
53
|
*/
|
|
33
|
-
export function CardGrid({ columns = 3, minWidth = "md", align = "stretch", as: Tag = "div", empty, children, loading, loadingLabel, ...rest }) {
|
|
54
|
+
export function CardGrid({ columns = 3, minWidth = "md", align = "stretch", minColumns = 1, as: Tag = "div", empty, children, loading, loadingLabel, ...rest }) {
|
|
34
55
|
const wait = useWait(loading, loadingLabel);
|
|
35
56
|
const none = hasNoChildren(children);
|
|
36
57
|
if (none && !wait.loading) {
|
|
37
58
|
return _jsx(EmptySlot, { size: "md", children: empty });
|
|
38
59
|
}
|
|
39
60
|
const cards = none ? gridBones(columns) : children;
|
|
40
|
-
return (_jsx(LoadingScope, { loading: wait.loading, children: _jsx(Tag, { ...rest, ...wait.attrs, ...(Tag === "ul" ? { role: "list" } : {}), className: cx("grid gap-4", gridColumns(columns, minWidth), align
|
|
61
|
+
return (_jsx(LoadingScope, { loading: wait.loading, children: _jsx(Tag, { ...rest, ...wait.attrs, ...(Tag === "ul" ? { role: "list" } : {}), className: cx("grid gap-4 *:min-w-0", gridColumns(columns, minWidth, minColumns), ALIGN[align]), children: _jsx(InRegions, { value: align === "regions", children: _jsx(GridItems, { list: Tag === "ul", item: ITEM[align], owner: wait.owner, label: wait.label, children: cards }) }) }) }));
|
|
41
62
|
}
|
|
42
63
|
/** A loading grid's cards when it has none yet: one card of bones per column, three for `auto`. */
|
|
43
64
|
function gridBones(columns) {
|
|
44
65
|
return Array.from({ length: columns === "auto" ? 3 : columns }, (_, i) => (_jsx(Card, { children: null }, i)));
|
|
45
66
|
}
|
|
46
67
|
/** The grid's cards, each in an `<li>` for a list, then the owner's hidden label (in an `<li>` too). */
|
|
47
|
-
function GridItems({ list, owner, label, children, }) {
|
|
68
|
+
function GridItems({ list, item, owner, label, children, }) {
|
|
48
69
|
if (!list) {
|
|
49
70
|
return (_jsxs(_Fragment, { children: [children, label] }));
|
|
50
71
|
}
|
|
51
|
-
return (_jsxs(_Fragment, { children: [Children.toArray(children).map((child, index) =>
|
|
72
|
+
return (_jsxs(_Fragment, { children: [Children.toArray(children).map((child, index) => {
|
|
73
|
+
const row = isValidElement(child) && child.type === CardGridRow;
|
|
74
|
+
return (_jsx("li", { className: row ? ROW : item, children: child }, isValidElement(child) ? child.key : index));
|
|
75
|
+
}), owner && _jsx("li", { className: "sr-only", children: label })] }));
|
|
76
|
+
}
|
|
77
|
+
/** A row's span: every column, whatever the grid's count. */
|
|
78
|
+
const ROW = "col-span-full";
|
|
79
|
+
/**
|
|
80
|
+
* One item that spans every column of a `CardGrid`: a heading over a group of cards, or one wide
|
|
81
|
+
* card in the run (an announcement among products). In `as="ul"` its `<li>` spans the row. It takes
|
|
82
|
+
* no `align="regions"` rows: what it holds keeps its own layout.
|
|
83
|
+
*/
|
|
84
|
+
export function CardGridRow({ children, ...rest }) {
|
|
85
|
+
return (_jsx("div", { ...rest, className: ROW, children: _jsx(InRegions, { value: false, children: children }) }));
|
|
52
86
|
}
|
package/dist/CardParts.d.ts
CHANGED
|
@@ -24,10 +24,12 @@ export declare function CardInset({ children, size, bleed, }: {
|
|
|
24
24
|
size: Size;
|
|
25
25
|
bleed: boolean;
|
|
26
26
|
}): import("react").JSX.Element;
|
|
27
|
-
|
|
27
|
+
/** A `dashed` card's bar has a dashed lower edge, like the card's own. */
|
|
28
|
+
export declare function CardBar({ heading, actions, size, dashed, }: {
|
|
28
29
|
heading: ReactNode;
|
|
29
30
|
actions: ReactNode;
|
|
30
31
|
size: Size;
|
|
32
|
+
dashed: boolean;
|
|
31
33
|
}): import("react").JSX.Element;
|
|
32
34
|
export declare function CardFooter({ children, size }: {
|
|
33
35
|
children: ReactNode;
|
|
@@ -38,3 +40,7 @@ export declare function CardHeader({ heading, actions, size, }: {
|
|
|
38
40
|
actions: ReactNode;
|
|
39
41
|
size: Size;
|
|
40
42
|
}): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
|
|
43
|
+
/** A link card's "Read more" cue at its foot: a mark for the eye, as the link is named by the title. */
|
|
44
|
+
export declare function CardMore({ children }: {
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
}): import("react").JSX.Element;
|
package/dist/CardParts.js
CHANGED
|
@@ -28,8 +28,9 @@ export function CardInset({ children, size, bleed, }) {
|
|
|
28
28
|
function CardActions({ children }) {
|
|
29
29
|
return _jsx("div", { className: "ml-auto flex items-center gap-2", children: children });
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
/** A `dashed` card's bar has a dashed lower edge, like the card's own. */
|
|
32
|
+
export function CardBar({ heading, actions, size, dashed, }) {
|
|
33
|
+
return (_jsxs("div", { className: cx("flex items-center justify-between gap-3 border-b border-slate-200/70 bg-slate-50", dashed && "border-dashed", STRIP_PAD[size]), children: [heading, actions && _jsx(CardActions, { children: actions })] }));
|
|
33
34
|
}
|
|
34
35
|
export function CardFooter({ children, size }) {
|
|
35
36
|
return (_jsx("div", { className: cx("flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-slate-200/70 bg-slate-50 [&>[data-button-group]]:grow", STRIP_PAD[size]), children: children }));
|
|
@@ -39,3 +40,7 @@ export function CardHeader({ heading, actions, size, }) {
|
|
|
39
40
|
return heading;
|
|
40
41
|
return (_jsxs("div", { className: cx("flex items-center justify-between gap-3", HEADING_GAP[size]), children: [heading, _jsx(CardActions, { children: actions })] }));
|
|
41
42
|
}
|
|
43
|
+
/** A link card's "Read more" cue at its foot: a mark for the eye, as the link is named by the title. */
|
|
44
|
+
export function CardMore({ children }) {
|
|
45
|
+
return (_jsxs("p", { "aria-hidden": "true", className: "mt-3 text-sm font-medium text-violet-700", children: [children, " ", _jsx("span", { children: "\u2192" })] }));
|
|
46
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { MouseEventHandler, ReactElement } from "react";
|
|
2
|
+
import type { Passthrough } from "./props.js";
|
|
3
|
+
/**
|
|
4
|
+
* The header's cart: the bag icon, how many things are in it and, with `total`, what they come to.
|
|
5
|
+
* It is one ghost button that opens the cart (a `Drawer`), so pass `aria-expanded` and
|
|
6
|
+
* `aria-controls` with the drawer's state; with `href` it is a link to the cart page instead. A
|
|
7
|
+
* screen reader hears it as "Cart, 2 items, R480": the label, the count in words and the total.
|
|
8
|
+
* The count is drawn whatever it is, `0` included, so the header does not shift as things go in.
|
|
9
|
+
*/
|
|
10
|
+
export declare function CartButton({ count, total, label, itemsLabel, onClick, href, ...rest }: {
|
|
11
|
+
/** How many things are in the cart; `0` is shown. */
|
|
12
|
+
count: number;
|
|
13
|
+
/** What they come to, formatted by the app ("R480"). Left out, only the count shows. */
|
|
14
|
+
total?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The button's name before the count.
|
|
17
|
+
* @default Cart
|
|
18
|
+
*/
|
|
19
|
+
label?: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The count in words, for a screen reader, in an app's own language.
|
|
22
|
+
* @default 1 item, or n items
|
|
23
|
+
*/
|
|
24
|
+
itemsLabel?: ((count: number) => string) | undefined;
|
|
25
|
+
} & Passthrough & ({
|
|
26
|
+
/** Opens the cart; pass `aria-expanded` and `aria-controls` for the drawer it opens. */
|
|
27
|
+
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
28
|
+
href?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
onClick?: undefined;
|
|
31
|
+
/** The cart's own page, in place of a drawer; an in-app path goes through `LinkProvider`. */
|
|
32
|
+
href: string;
|
|
33
|
+
})): ReactElement;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, COUNT } from "./Button.js";
|
|
3
|
+
const itemsOf = (count) => (count === 1 ? "1 item" : `${count} items`);
|
|
4
|
+
/**
|
|
5
|
+
* The header's cart: the bag icon, how many things are in it and, with `total`, what they come to.
|
|
6
|
+
* It is one ghost button that opens the cart (a `Drawer`), so pass `aria-expanded` and
|
|
7
|
+
* `aria-controls` with the drawer's state; with `href` it is a link to the cart page instead. A
|
|
8
|
+
* screen reader hears it as "Cart, 2 items, R480": the label, the count in words and the total.
|
|
9
|
+
* The count is drawn whatever it is, `0` included, so the header does not shift as things go in.
|
|
10
|
+
*/
|
|
11
|
+
export function CartButton({ count, total, label = "Cart", itemsLabel = itemsOf, onClick, href, ...rest }) {
|
|
12
|
+
const words = `${label}, ${itemsLabel(count)}${total ? `, ${total}` : ""}`;
|
|
13
|
+
const body = (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children: words }), _jsx("span", { "aria-hidden": "true", className: COUNT, children: count }), total && (_jsx("span", { "aria-hidden": "true", className: "tabular-nums", children: total }))] }));
|
|
14
|
+
if (href !== undefined) {
|
|
15
|
+
return (_jsx(Button, { ...rest, variant: "ghost", icon: "cart", href: href, children: body }));
|
|
16
|
+
}
|
|
17
|
+
return (_jsx(Button, { ...rest, variant: "ghost", icon: "cart", onClick: onClick, children: body }));
|
|
18
|
+
}
|
package/dist/ChatComposer.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { type ReactElement } from "react";
|
|
2
2
|
import type { Passthrough } from "./props.js";
|
|
3
3
|
/**
|
|
4
|
-
* The box a message is typed into, with its button beside it. It keeps its own text
|
|
5
|
-
* the trimmed text and clears the box; Shift+Enter is a
|
|
6
|
-
*
|
|
4
|
+
* The box a message is typed into, with its button beside it. It keeps its own text, and the box
|
|
5
|
+
* grows with it from 2 rows to 8. Enter sends the trimmed text and clears the box; Shift+Enter is a
|
|
6
|
+
* newline. Send stays enabled on an empty box: sending empty or whitespace-only text sends nothing
|
|
7
|
+
* and shows `emptyReason` under the box until the next keystroke. While `busy` a reply is on its way: the button is Stop, Enter does not send, and typing
|
|
7
8
|
* carries on with the text kept for the next send.
|
|
8
9
|
*/
|
|
9
|
-
export declare function ChatComposer({ label, placeholder, disabled, busy, onSend, onStop, sendLabel, stopLabel, ...rest }: {
|
|
10
|
+
export declare function ChatComposer({ label, placeholder, disabled, busy, onSend, onStop, sendLabel, stopLabel, emptyReason, ...rest }: {
|
|
10
11
|
/** The box's name for assistive tech; it is not drawn. */
|
|
11
12
|
label: string;
|
|
12
13
|
/** The hint inside the empty box. */
|
|
@@ -32,4 +33,9 @@ export declare function ChatComposer({ label, placeholder, disabled, busy, onSen
|
|
|
32
33
|
* @default Stop
|
|
33
34
|
*/
|
|
34
35
|
stopLabel?: string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Shown under the box when Send is pressed on an empty box.
|
|
38
|
+
* @default Write a message first.
|
|
39
|
+
*/
|
|
40
|
+
emptyReason?: string | undefined;
|
|
35
41
|
} & Passthrough): ReactElement;
|