@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/SearchInput.js
CHANGED
|
@@ -4,22 +4,62 @@ import { controlClass } from "./control.js";
|
|
|
4
4
|
import { cx, focusRing } from "./cx.js";
|
|
5
5
|
import { useTypeStep } from "./density.js";
|
|
6
6
|
import { InputShell } from "./InputShell.js";
|
|
7
|
+
import { sizeClass } from "./size.js";
|
|
7
8
|
import { Tipped } from "./Tooltip.js";
|
|
8
9
|
/** The browser's own search look is reset: no `searchfield` appearance, no cancel button or decoration. The clear button below replaces them. */
|
|
9
10
|
const SEARCH_RESET = "appearance-none [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden [&::-webkit-search-results-button]:hidden [&::-webkit-search-results-decoration]:hidden";
|
|
10
11
|
/** A search field's padding: the leading side as a plain field or with an icon, the trailing side clear of the clear button. */
|
|
11
12
|
const SEARCH_PAD = {
|
|
12
|
-
sm:
|
|
13
|
-
md:
|
|
14
|
-
lg:
|
|
13
|
+
sm: "pl-2 pr-7",
|
|
14
|
+
md: "pl-3 pr-9",
|
|
15
|
+
lg: "pl-4 pr-11",
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
lg: { box: "right-2.5 h-7 w-7", icon: "h-4 w-4" },
|
|
17
|
+
const SEARCH_PAD_MD = {
|
|
18
|
+
sm: "md:pl-2 md:pr-7",
|
|
19
|
+
md: "md:pl-3 md:pr-9",
|
|
20
|
+
lg: "md:pl-4 md:pr-11",
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
/** With a leading icon. */
|
|
23
|
+
const SEARCH_PAD_ICON = {
|
|
24
|
+
sm: "pl-7 pr-7",
|
|
25
|
+
md: "pl-9 pr-9",
|
|
26
|
+
lg: "pl-11 pr-11",
|
|
27
|
+
};
|
|
28
|
+
const SEARCH_PAD_ICON_MD = {
|
|
29
|
+
sm: "md:pl-7 md:pr-7",
|
|
30
|
+
md: "md:pl-9 md:pr-9",
|
|
31
|
+
lg: "md:pl-11 md:pr-11",
|
|
32
|
+
};
|
|
33
|
+
/** The clear button's place and box, by the field's size. */
|
|
34
|
+
const CLEAR_BOX = {
|
|
35
|
+
sm: "right-1 h-5 w-5",
|
|
36
|
+
md: "right-2 h-6 w-6",
|
|
37
|
+
lg: "right-2.5 h-7 w-7",
|
|
38
|
+
};
|
|
39
|
+
const CLEAR_BOX_MD = {
|
|
40
|
+
sm: "md:right-1 md:h-5 md:w-5",
|
|
41
|
+
md: "md:right-2 md:h-6 md:w-6",
|
|
42
|
+
lg: "md:right-2.5 md:h-7 md:w-7",
|
|
43
|
+
};
|
|
44
|
+
/** The clear button's icon, by the field's size. */
|
|
45
|
+
const CLEAR_ICON = { sm: "h-3 w-3", md: "h-3.5 w-3.5", lg: "h-4 w-4" };
|
|
46
|
+
const CLEAR_ICON_MD = {
|
|
47
|
+
sm: "md:h-3 md:w-3",
|
|
48
|
+
md: "md:h-3.5 md:w-3.5",
|
|
49
|
+
lg: "md:h-4 md:w-4",
|
|
50
|
+
};
|
|
51
|
+
/** A search field's size tables and their `md:` twins (each `_MD` is its table from the `md` breakpoint up), for the data test. */
|
|
52
|
+
export const searchSizeTables = {
|
|
53
|
+
pad: SEARCH_PAD,
|
|
54
|
+
padMd: SEARCH_PAD_MD,
|
|
55
|
+
padIcon: SEARCH_PAD_ICON,
|
|
56
|
+
padIconMd: SEARCH_PAD_ICON_MD,
|
|
57
|
+
clearBox: CLEAR_BOX,
|
|
58
|
+
clearBoxMd: CLEAR_BOX_MD,
|
|
59
|
+
clearIcon: CLEAR_ICON,
|
|
60
|
+
clearIconMd: CLEAR_ICON_MD,
|
|
61
|
+
};
|
|
62
|
+
const CLEAR_BUTTON = `absolute top-1/2 -translate-y-1/2 inline-flex cursor-pointer items-center justify-center rounded text-slate-500 hover:bg-slate-100 ${focusRing}`;
|
|
23
63
|
/** Set `value` the way a keystroke does (past React's value tracker), so `onChange` fires for a controlled and an uncontrolled field alike. */
|
|
24
64
|
function clearValue(input) {
|
|
25
65
|
const descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value");
|
|
@@ -27,8 +67,12 @@ function clearValue(input) {
|
|
|
27
67
|
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
28
68
|
input.focus();
|
|
29
69
|
}
|
|
70
|
+
/** Whether Escape has something to clear: a value, in a field the person can edit. */
|
|
71
|
+
function clearable(input) {
|
|
72
|
+
return input.value !== "" && !input.readOnly && !input.disabled;
|
|
73
|
+
}
|
|
30
74
|
function ClearButton({ size, label, onClear, }) {
|
|
31
|
-
return (_jsx(Tipped, { text: label, describes: false, own: {}, children: (tip) => (_jsx("button", { type: "button", "aria-label": label, ...tip, onClick: onClear, className: cx(CLEAR_BUTTON,
|
|
75
|
+
return (_jsx(Tipped, { text: label, describes: false, own: {}, children: (tip) => (_jsx("button", { type: "button", "aria-label": label, ...tip, onClick: onClear, className: cx(CLEAR_BUTTON, sizeClass(CLEAR_BOX, CLEAR_BOX_MD, size)), children: _jsx("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", className: sizeClass(CLEAR_ICON, CLEAR_ICON_MD, size), children: _jsx("path", { d: "M5.28 4.22a.75.75 0 0 0-1.06 1.06L8.94 10l-4.72 4.72a.75.75 0 1 0 1.06 1.06L10 11.06l4.72 4.72a.75.75 0 1 0 1.06-1.06L11.06 10l4.72-4.72a.75.75 0 0 0-1.06-1.06L10 8.94 5.28 4.22Z" }) }) })) }));
|
|
32
76
|
}
|
|
33
77
|
/** Sets both the field's own ref and the consumer's. */
|
|
34
78
|
function bothRefs(own, theirs) {
|
|
@@ -40,8 +84,12 @@ function bothRefs(own, theirs) {
|
|
|
40
84
|
theirs.current = el;
|
|
41
85
|
};
|
|
42
86
|
}
|
|
43
|
-
/**
|
|
44
|
-
|
|
87
|
+
/**
|
|
88
|
+
* `Input` for `type="search"`: native search look reset, and a clear button named `clearLabel` at the
|
|
89
|
+
* trailing edge while the field has a value. Escape in a field with a value clears it and goes no
|
|
90
|
+
* further, so a dialog around it stays open; Escape in an empty field passes on and closes it.
|
|
91
|
+
*/
|
|
92
|
+
export function SearchInput({ icon, size = "md", width = "full", clearLabel, onChange, onKeyDown, ref, ...rest }) {
|
|
45
93
|
const step = useTypeStep();
|
|
46
94
|
const inputRef = useRef(null);
|
|
47
95
|
// One callback for the life of the ref, so a caller's function ref is not called on every keystroke.
|
|
@@ -51,5 +99,16 @@ export function SearchInput({ icon, size = "md", width = "full", clearLabel, onC
|
|
|
51
99
|
return (_jsxs(InputShell, { icon: icon, size: size, width: width, children: [_jsx("input", { ...rest, ref: attach, onChange: (event) => {
|
|
52
100
|
setTyped(event.currentTarget.value !== "");
|
|
53
101
|
onChange?.(event);
|
|
54
|
-
},
|
|
102
|
+
}, onKeyDown: (event) => {
|
|
103
|
+
onKeyDown?.(event);
|
|
104
|
+
if (event.key !== "Escape" || event.defaultPrevented)
|
|
105
|
+
return;
|
|
106
|
+
if (!clearable(event.currentTarget))
|
|
107
|
+
return;
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
event.stopPropagation();
|
|
110
|
+
clearValue(event.currentTarget);
|
|
111
|
+
}, className: cx(controlClass(size, width === "auto" ? "auto" : "full", step), icon === undefined
|
|
112
|
+
? sizeClass(SEARCH_PAD, SEARCH_PAD_MD, size)
|
|
113
|
+
: sizeClass(SEARCH_PAD_ICON, SEARCH_PAD_ICON_MD, size), SEARCH_RESET) }), filled && !rest.disabled && !rest.readOnly && (_jsx(ClearButton, { size: size, label: clearLabel, onClear: () => inputRef.current && clearValue(inputRef.current) }))] }));
|
|
55
114
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CalendarDate, CalendarDateTime, DateValue } from "@internationalized/date";
|
|
2
|
+
import type { ReactElement } from "react";
|
|
3
|
+
import { type FieldProps } from "./DateField.js";
|
|
4
|
+
import { type Kind } from "./shownDate.js";
|
|
5
|
+
/** A typed field's props: a `DateField`'s, with the value props of its value type and its `kind`. */
|
|
6
|
+
export type SegmentedProps<T extends CalendarDate | CalendarDateTime> = Omit<FieldProps, "value" | "defaultValue" | "onChange" | "minValue" | "maxValue"> & {
|
|
7
|
+
value?: T | null | undefined;
|
|
8
|
+
defaultValue?: T | null | undefined;
|
|
9
|
+
onChange?: ((value: T | null) => void) | undefined;
|
|
10
|
+
minValue?: DateValue | null | undefined;
|
|
11
|
+
maxValue?: DateValue | null | undefined;
|
|
12
|
+
kind: Kind<T>;
|
|
13
|
+
};
|
|
14
|
+
/** The typed field without a calendar: a `DateField`, or a `DateTimeField` with its time segments. */
|
|
15
|
+
export declare function SegmentedField<T extends CalendarDate | CalendarDateTime>({ kind, label, hint, error, disabled, required, value, defaultValue, onChange, name, locale, size, ...rest }: SegmentedProps<T>): ReactElement;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DateField as AriaDateField, DateInput } from "react-aria-components";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
import { fieldPad, FieldLabel, FieldSegment, fieldFlags, forcedInvalid, frameClass, Notes, } from "./DateField.js";
|
|
5
|
+
import { DateLocale } from "./dateLocale.js";
|
|
6
|
+
import { controlText, useTypeStep } from "./density.js";
|
|
7
|
+
import { definedProps } from "./props.js";
|
|
8
|
+
import { ShownInput, useShownDate } from "./shownDate.js";
|
|
9
|
+
/** The typed field without a calendar: a `DateField`, or a `DateTimeField` with its time segments. */
|
|
10
|
+
export function SegmentedField({ kind, label, hint, error, disabled, required, value, defaultValue, onChange, name, locale, size = "md", ...rest }) {
|
|
11
|
+
const step = useTypeStep();
|
|
12
|
+
const bounds = { minValue: rest.minValue, maxValue: rest.maxValue };
|
|
13
|
+
const { inner, setInner, shown, impossible, onRead, validate, leaving, onBlurCapture, onLeft } = useShownDate({ value, defaultValue, onChange, ...bounds, isRequired: required }, kind);
|
|
14
|
+
return (_jsx(DateLocale, { locale: locale, children: _jsx(AriaDateField, { ...definedProps(rest), ...fieldFlags(disabled, required), value: inner, onChange: (next) => setInner(kind.narrow(next)), validate: validate, ...forcedInvalid({ impossible, error }), isReadOnly: leaving, onBlur: onLeft, granularity: kind.granularity, shouldForceLeadingZeros: true, className: "flex flex-col gap-1.5", children: () => (_jsxs(_Fragment, { children: [_jsx(FieldLabel, { label: label, required: required }), _jsx("div", { className: "contents", onBlurCapture: onBlurCapture, children: _jsx(DateInput, { className: (state) => cx(frameClass(state), fieldPad(size), controlText(size, step, true)), children: (segment) => (_jsx(FieldSegment, { segment: segment, ...(segment.type === "day" ? { onRead } : {}) })) }) }), _jsx(ShownInput, { name: name, shown: shown, isDisabled: disabled }), _jsx(Notes, { hint: hint, error: error, impossible: impossible, bounds: bounds, time: kind.granularity === "minute" })] })) }) }));
|
|
15
|
+
}
|
package/dist/Select.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { controlClass, controlHeight, controlPad } from "./control.js";
|
|
4
4
|
import { cx } from "./cx.js";
|
|
5
5
|
import { useTypeStep } from "./density.js";
|
|
6
6
|
import { FieldContext, useFieldControl } from "./fieldControl.js";
|
|
7
|
-
/** The height of a `Select` by `size`, the `Input`'s 26px, 38px and 46px: a native `<select>` sizes its text from the font and ignores the line height, so padding alone falls short at `md` and `lg`. */
|
|
8
|
-
const SELECT_HEIGHT = { sm: "h-6.5", md: "h-9.5", lg: "h-11.5" };
|
|
9
7
|
/**
|
|
10
8
|
* A native `<select>` styled like `Input`, keeping the browser's own arrow, over its `items`. Takes
|
|
11
9
|
* `size` and `width` too: inside a `Field` it fills the row, and on its own it is as wide as its
|
|
@@ -15,5 +13,8 @@ export function Select({ items, size = "md", width, ...own }) {
|
|
|
15
13
|
const step = useTypeStep();
|
|
16
14
|
const inField = useContext(FieldContext) !== undefined;
|
|
17
15
|
const field = useFieldControl(own);
|
|
18
|
-
return (_jsx("select", { ...own, ...field, className: cx(controlClass(size, width ?? (inField ? "full" : "auto"), step),
|
|
16
|
+
return (_jsx("select", { ...own, ...field, className: cx(controlClass(size, width ?? (inField ? "full" : "auto"), step),
|
|
17
|
+
// A native `<select>` sizes its text from the font and ignores the line height, so padding
|
|
18
|
+
// alone falls short at `md` and `lg`: it takes the `Input`'s height outright.
|
|
19
|
+
controlHeight(size), controlPad(size), "cursor-pointer disabled:cursor-not-allowed"), children: items.map((item) => (_jsx("option", { value: item.value, disabled: item.disabled, children: item.label }, item.value))) }));
|
|
19
20
|
}
|
package/dist/Show.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ type ShowWhen = {
|
|
|
20
20
|
* Content that only fits a wide screen is in a `Show from`; its narrow-screen form is in a
|
|
21
21
|
* `Show below` at the same breakpoint. Hidden content stays mounted, so two `Show`s of the same
|
|
22
22
|
* content mount it twice: a stateful panel shown at every width with a fold is a
|
|
23
|
-
* `SideColumn
|
|
23
|
+
* `SideColumn fold`. `as="span"` is for phrasing content (inside a `<p>` or a button row).
|
|
24
24
|
*/
|
|
25
25
|
export declare function Show({ from, below, as: Tag, children, ...rest }: ShowWhen & {
|
|
26
26
|
/**
|
package/dist/Show.js
CHANGED
|
@@ -20,7 +20,7 @@ const BELOW = {
|
|
|
20
20
|
* Content that only fits a wide screen is in a `Show from`; its narrow-screen form is in a
|
|
21
21
|
* `Show below` at the same breakpoint. Hidden content stays mounted, so two `Show`s of the same
|
|
22
22
|
* content mount it twice: a stateful panel shown at every width with a fold is a
|
|
23
|
-
* `SideColumn
|
|
23
|
+
* `SideColumn fold`. `as="span"` is for phrasing content (inside a `<p>` or a button row).
|
|
24
24
|
*/
|
|
25
25
|
export function Show({ from, below, as: Tag = "div", children, ...rest }) {
|
|
26
26
|
return (_jsx(Tag, { ...rest, className: from ? FROM[from] : BELOW[below ?? "sm"], children: children }));
|
package/dist/SideColumn.d.ts
CHANGED
|
@@ -1,33 +1,42 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from "react";
|
|
2
2
|
import type { Passthrough } from "./props.js";
|
|
3
|
-
/** How wide a `SideColumn`'s aside is from `lg`: `sm` 18rem, `md` 24rem, or `third` a third of the row. */
|
|
4
|
-
export type SideColumnWidth = "sm" | "md" | "third";
|
|
3
|
+
/** How wide a `SideColumn`'s aside is from `lg`: `xs` 12rem, `sm` 18rem, `md` 24rem, or `third` a third of the row. */
|
|
4
|
+
export type SideColumnWidth = "xs" | "sm" | "md" | "third";
|
|
5
|
+
/** Which side of the main area a `SideColumn`'s aside sits on from `lg`: `end` (the right) or `start` (the left). */
|
|
6
|
+
export type SideColumnSide = "end" | "start";
|
|
5
7
|
/**
|
|
6
8
|
* A main area beside a side column, in the Container the page already has: from `lg` the `aside`
|
|
7
9
|
* is `asideWidth` on the right and `children` take the room left; below `lg` the aside stacks under
|
|
8
10
|
* `children`. It sets no page width, padding or header of its own, so it sits inside a layout, a
|
|
9
|
-
* `Card` or a panel. `asideWidth` is `sm` (18rem), `md` (24rem) or `third` (one
|
|
10
|
-
* the main area two thirds: the split `DetailLayout` draws). A rail of links on
|
|
11
|
-
* `SidebarLayout`.
|
|
11
|
+
* `Card` or a panel. `asideWidth` is `xs` (12rem), `sm` (18rem), `md` (24rem) or `third` (one
|
|
12
|
+
* third of the row, the main area two thirds: the split `DetailLayout` draws). A rail of links on
|
|
13
|
+
* the left is `SidebarLayout`.
|
|
12
14
|
*
|
|
13
|
-
* `
|
|
14
|
-
*
|
|
15
|
-
*
|
|
15
|
+
* `side="start"` puts the aside on the left from `lg`, and first in reading order, so below `lg`
|
|
16
|
+
* it stacks above `children`.
|
|
17
|
+
*
|
|
18
|
+
* `asideLabel` names the `<aside>` landmark. `fold` is for an aside that should not take the
|
|
19
|
+
* phone's screen: below `lg` it folds, closed, behind a native disclosure named by `asideLabel`,
|
|
20
|
+
* and from `lg` it is the same column, always shown. The aside stays mounted while folded, so a
|
|
21
|
+
* conversation or a draft inside it is kept.
|
|
16
22
|
*
|
|
17
23
|
* `sticky` keeps the aside in view from `lg` as a long page scrolls: it sticks under AppShell's
|
|
18
24
|
* header and, if it is taller than the room left, scrolls itself (a tab stop named by `asideLabel`)
|
|
19
25
|
* so its end stays reachable.
|
|
20
26
|
*/
|
|
21
|
-
export declare function SideColumn({ asideLabel, ...props }: {
|
|
22
|
-
/** The side column: `asideWidth` wide on
|
|
27
|
+
export declare function SideColumn({ asideLabel, fold, ...props }: {
|
|
28
|
+
/** The side column: `asideWidth` wide on `side` from `lg`, stacked with `children` below it. */
|
|
23
29
|
aside: ReactNode;
|
|
24
30
|
/**
|
|
25
|
-
* The aside's width from `lg`: `sm` 18rem, `md` 24rem, or `third`, one third of the row.
|
|
31
|
+
* The aside's width from `lg`: `xs` 12rem, `sm` 18rem, `md` 24rem, or `third`, one third of the row.
|
|
26
32
|
* @default md
|
|
27
33
|
*/
|
|
28
34
|
asideWidth?: SideColumnWidth | undefined;
|
|
29
|
-
/**
|
|
30
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The aside's side from `lg`: `end` (the right) or `start` (the left, and first in reading order).
|
|
37
|
+
* @default end
|
|
38
|
+
*/
|
|
39
|
+
side?: SideColumnSide | undefined;
|
|
31
40
|
/**
|
|
32
41
|
* From `lg`, keeps the aside in view under the header as the page scrolls; an aside taller than
|
|
33
42
|
* the screen scrolls inside itself.
|
|
@@ -35,16 +44,34 @@ export declare function SideColumn({ asideLabel, ...props }: {
|
|
|
35
44
|
*/
|
|
36
45
|
sticky?: boolean | undefined;
|
|
37
46
|
children: ReactNode;
|
|
38
|
-
} & Passthrough): ReactElement;
|
|
47
|
+
} & SideColumnFold & Passthrough): ReactElement;
|
|
48
|
+
/**
|
|
49
|
+
* A `SideColumn`'s name and fold: `asideLabel` names the `<aside>` landmark, and `fold` folds the
|
|
50
|
+
* aside below `lg` behind a disclosure of that name, so `fold` needs `asideLabel`.
|
|
51
|
+
*/
|
|
52
|
+
type SideColumnFold = {
|
|
53
|
+
/** Names the `<aside>` landmark, and the disclosure when `fold` is set. Left out, the aside is unnamed. */
|
|
54
|
+
asideLabel?: string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Folds the aside, closed, behind a disclosure named by `asideLabel` below `lg`.
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
fold?: false | undefined;
|
|
60
|
+
} | {
|
|
61
|
+
asideLabel: string;
|
|
62
|
+
fold: true;
|
|
63
|
+
};
|
|
39
64
|
/**
|
|
40
65
|
* The one two-column split: `SideColumn`, and `DetailLayout`'s columns, whose `asideLabel` names
|
|
41
66
|
* the aside without folding it. Internal.
|
|
42
67
|
*/
|
|
43
|
-
export declare function SplitColumns({ aside, asideWidth, label, fold, sticky, children, ...rest }: {
|
|
68
|
+
export declare function SplitColumns({ aside, asideWidth, side, label, fold, sticky, children, ...rest }: {
|
|
44
69
|
aside: ReactNode;
|
|
45
70
|
asideWidth?: SideColumnWidth | undefined;
|
|
71
|
+
side?: SideColumnSide | undefined;
|
|
46
72
|
label: string | undefined;
|
|
47
73
|
fold: boolean;
|
|
48
74
|
sticky?: boolean | undefined;
|
|
49
75
|
children: ReactNode;
|
|
50
76
|
} & Passthrough): ReactElement;
|
|
77
|
+
export {};
|
package/dist/SideColumn.js
CHANGED
|
@@ -5,41 +5,67 @@ import { useScrollEdges } from "./scrollEdges.js";
|
|
|
5
5
|
import { scrollStopProps, useScrollStop } from "./scrollStop.js";
|
|
6
6
|
import { STICKY_ASIDE_LG, STICKY_FADE_LG, STICKY_SCROLL_LG } from "./stickyColumn.js";
|
|
7
7
|
/**
|
|
8
|
-
* The grid from `lg`, and the main area's share of it: `sm` and `md` give the
|
|
9
|
-
* width and the main area the room left; `third` gives the aside one third and
|
|
8
|
+
* The grid from `lg`, and the main area's share of it, for each side: `xs`, `sm` and `md` give the
|
|
9
|
+
* aside exactly that width and the main area the room left; `third` gives the aside one third and
|
|
10
|
+
* the main area two.
|
|
10
11
|
*/
|
|
11
12
|
const COLUMNS = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
end: {
|
|
14
|
+
xs: { grid: "lg:grid-cols-[minmax(0,1fr)_12rem]", main: "" },
|
|
15
|
+
sm: { grid: "lg:grid-cols-[minmax(0,1fr)_18rem]", main: "" },
|
|
16
|
+
md: { grid: "lg:grid-cols-[minmax(0,1fr)_24rem]", main: "" },
|
|
17
|
+
third: { grid: "lg:grid-cols-3", main: "lg:col-span-2" },
|
|
18
|
+
},
|
|
19
|
+
start: {
|
|
20
|
+
xs: { grid: "lg:grid-cols-[12rem_minmax(0,1fr)]", main: "" },
|
|
21
|
+
sm: { grid: "lg:grid-cols-[18rem_minmax(0,1fr)]", main: "" },
|
|
22
|
+
md: { grid: "lg:grid-cols-[24rem_minmax(0,1fr)]", main: "" },
|
|
23
|
+
third: { grid: "lg:grid-cols-3", main: "lg:col-span-2" },
|
|
24
|
+
},
|
|
15
25
|
};
|
|
16
26
|
/**
|
|
17
27
|
* A main area beside a side column, in the Container the page already has: from `lg` the `aside`
|
|
18
28
|
* is `asideWidth` on the right and `children` take the room left; below `lg` the aside stacks under
|
|
19
29
|
* `children`. It sets no page width, padding or header of its own, so it sits inside a layout, a
|
|
20
|
-
* `Card` or a panel. `asideWidth` is `sm` (18rem), `md` (24rem) or `third` (one
|
|
21
|
-
* the main area two thirds: the split `DetailLayout` draws). A rail of links on
|
|
22
|
-
* `SidebarLayout`.
|
|
30
|
+
* `Card` or a panel. `asideWidth` is `xs` (12rem), `sm` (18rem), `md` (24rem) or `third` (one
|
|
31
|
+
* third of the row, the main area two thirds: the split `DetailLayout` draws). A rail of links on
|
|
32
|
+
* the left is `SidebarLayout`.
|
|
23
33
|
*
|
|
24
|
-
* `
|
|
25
|
-
*
|
|
26
|
-
*
|
|
34
|
+
* `side="start"` puts the aside on the left from `lg`, and first in reading order, so below `lg`
|
|
35
|
+
* it stacks above `children`.
|
|
36
|
+
*
|
|
37
|
+
* `asideLabel` names the `<aside>` landmark. `fold` is for an aside that should not take the
|
|
38
|
+
* phone's screen: below `lg` it folds, closed, behind a native disclosure named by `asideLabel`,
|
|
39
|
+
* and from `lg` it is the same column, always shown. The aside stays mounted while folded, so a
|
|
40
|
+
* conversation or a draft inside it is kept.
|
|
27
41
|
*
|
|
28
42
|
* `sticky` keeps the aside in view from `lg` as a long page scrolls: it sticks under AppShell's
|
|
29
43
|
* header and, if it is taller than the room left, scrolls itself (a tab stop named by `asideLabel`)
|
|
30
44
|
* so its end stays reachable.
|
|
31
45
|
*/
|
|
32
|
-
export function SideColumn({ asideLabel, ...props }) {
|
|
33
|
-
return _jsx(SplitColumns, { ...props, label: asideLabel, fold:
|
|
46
|
+
export function SideColumn({ asideLabel, fold = false, ...props }) {
|
|
47
|
+
return _jsx(SplitColumns, { ...props, label: asideLabel, fold: fold });
|
|
48
|
+
}
|
|
49
|
+
/** The aside's content: folded behind a disclosure below `lg` when `fold` and a label are set. */
|
|
50
|
+
function AsideContent({ aside, label, fold, }) {
|
|
51
|
+
if (!fold || label === undefined)
|
|
52
|
+
return aside;
|
|
53
|
+
return (_jsx(FoldedColumn, { from: "lg", label: label, children: aside }));
|
|
54
|
+
}
|
|
55
|
+
/** The `<aside>`: when `sticky`, it stays under the header from `lg` and scrolls itself, with a scroll stop when it overflows. */
|
|
56
|
+
function Aside({ label, sticky, children, }) {
|
|
57
|
+
const { element, attach, stop } = useScrollStop();
|
|
58
|
+
useScrollEdges(element, "y");
|
|
59
|
+
const { props, ring } = scrollStopProps(sticky && stop, { label });
|
|
60
|
+
return (_jsx("aside", { className: cx("min-w-0", sticky && STICKY_ASIDE_LG), "aria-label": label, children: _jsx("div", { ref: sticky ? attach : undefined, ...props, className: sticky ? cx(STICKY_SCROLL_LG, STICKY_FADE_LG, ring) : undefined, children: children }) }));
|
|
34
61
|
}
|
|
35
62
|
/**
|
|
36
63
|
* The one two-column split: `SideColumn`, and `DetailLayout`'s columns, whose `asideLabel` names
|
|
37
64
|
* the aside without folding it. Internal.
|
|
38
65
|
*/
|
|
39
|
-
export function SplitColumns({ aside, asideWidth = "md", label, fold, sticky = false, children, ...rest }) {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
return (_jsxs("div", { ...rest, className: cx("grid grid-cols-1 gap-6", columns.grid), children: [_jsx("div", { className: cx("min-w-0", columns.main), children: children }), _jsx("aside", { className: cx("min-w-0", sticky && STICKY_ASIDE_LG), "aria-label": label, children: _jsx("div", { ref: sticky ? attach : undefined, ...props, className: sticky ? cx(STICKY_SCROLL_LG, STICKY_FADE_LG, ring) : undefined, children: fold && label !== undefined ? (_jsx(FoldedColumn, { from: "lg", label: label, children: aside })) : (aside) }) })] }));
|
|
66
|
+
export function SplitColumns({ aside, asideWidth = "md", side = "end", label, fold, sticky = false, children, ...rest }) {
|
|
67
|
+
const columns = COLUMNS[side][asideWidth];
|
|
68
|
+
const main = _jsx("div", { className: cx("min-w-0", columns.main), children: children });
|
|
69
|
+
const column = (_jsx(Aside, { label: label, sticky: sticky, children: _jsx(AsideContent, { aside: aside, label: label, fold: fold }) }));
|
|
70
|
+
return (_jsxs("div", { ...rest, className: cx("grid grid-cols-1 gap-6", columns.grid), children: [side === "start" ? column : null, main, side === "end" ? column : null] }));
|
|
45
71
|
}
|
package/dist/SiteFooter.d.ts
CHANGED
|
@@ -17,15 +17,15 @@ export declare function SiteFooter({ brand, brandHref, brandLabel, links, notes,
|
|
|
17
17
|
brand?: ReactNode;
|
|
18
18
|
/**
|
|
19
19
|
* Where the brand links. Needs `brand`.
|
|
20
|
-
* @default "/"
|
|
20
|
+
* @default the nearest `LinkProvider`'s `home`, else "/"
|
|
21
21
|
*/
|
|
22
22
|
brandHref?: string | undefined;
|
|
23
23
|
/** Names the brand link for assistive tech ("PixelSlash home"). Needs `brand`. */
|
|
24
24
|
brandLabel?: string | undefined;
|
|
25
25
|
/** The site's own links (Privacy, Terms, GitHub, a mail address), one wrapping row. */
|
|
26
|
-
links?: SiteFooterLink[] | undefined;
|
|
26
|
+
links?: readonly SiteFooterLink[] | undefined;
|
|
27
27
|
/** Lines of fine print under the links (a licence, a trademark, a credit), one paragraph each. */
|
|
28
|
-
notes?: ReactNode[] | undefined;
|
|
28
|
+
notes?: readonly ReactNode[] | undefined;
|
|
29
29
|
/** A sentence at body size beside the brand: the contact line ("Email hello@..."). */
|
|
30
30
|
children?: ReactNode;
|
|
31
31
|
} & Passthrough): ReactElement;
|
package/dist/SiteFooter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Cluster } from "./Cluster.js";
|
|
3
3
|
import { cx, focusRing } from "./cx.js";
|
|
4
|
-
import { renderLink } from "./link.js";
|
|
4
|
+
import { renderLink, useHome } from "./link.js";
|
|
5
5
|
import { MetaList } from "./MetaList.js";
|
|
6
6
|
import { Stack } from "./Stack.js";
|
|
7
7
|
import { TextLink } from "./TextLink.js";
|
|
@@ -12,11 +12,12 @@ import { Caption } from "./typography.js";
|
|
|
12
12
|
* It is not a `<footer>`: the shell draws the one `contentinfo` landmark around its slot. No link
|
|
13
13
|
* columns, newsletter form or social icons: a site footer is this and nothing else.
|
|
14
14
|
*/
|
|
15
|
-
export function SiteFooter({ brand, brandHref
|
|
15
|
+
export function SiteFooter({ brand, brandHref, brandLabel, links = [], notes = [], children, ...rest }) {
|
|
16
|
+
const home = useHome();
|
|
16
17
|
const top = brand != null || children != null;
|
|
17
18
|
return (_jsxs(Stack, { ...rest, gap: "sm", children: [top && (_jsxs(Cluster, { gap: "md", children: [brand != null &&
|
|
18
19
|
renderLink({
|
|
19
|
-
href: brandHref,
|
|
20
|
+
href: brandHref ?? home,
|
|
20
21
|
"aria-label": brandLabel,
|
|
21
22
|
className: cx("rounded text-slate-900", focusRing),
|
|
22
23
|
children: brand,
|
package/dist/SiteSearch.d.ts
CHANGED
|
@@ -1,35 +1,14 @@
|
|
|
1
1
|
import { type ReactElement } from "react";
|
|
2
2
|
import type { Passthrough } from "./props.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/** A muted line under the label, matched last. */
|
|
8
|
-
description?: string | undefined;
|
|
9
|
-
/** Where the row goes. */
|
|
10
|
-
href: string;
|
|
11
|
-
/** Other names the page answers to (the exports it documents), matched like the label but not shown. */
|
|
12
|
-
keywords?: string[] | undefined;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* The items that match `text`, best first: the label starts with it, then the label contains it,
|
|
16
|
-
* then a keyword contains it, then the description does. Case is ignored, and items of the same
|
|
17
|
-
* rank keep their order in `items`. Empty text matches nothing.
|
|
18
|
-
*/
|
|
19
|
-
export declare function rankSiteSearch(items: readonly SiteSearchItem[], text: string): SiteSearchItem[];
|
|
20
|
-
/**
|
|
21
|
-
* The site's search: a header button that opens a dialog with a search field over a list of links
|
|
22
|
-
* to the pages that match. Put it in `AppShell`'s `controls` and pass every page as `items`. Ctrl+K
|
|
23
|
-
* (⌘ K on a Mac) opens it from anywhere on the page, and the button shows that key. Typing filters
|
|
24
|
-
* by name, then by `keywords`, then by description; Enter opens the first result, the arrow keys
|
|
25
|
-
* move through them, and Esc closes it and puts focus back where it was. Render it once per page.
|
|
26
|
-
*/
|
|
27
|
-
export declare function SiteSearch({ items, label, resultsLabel, ...rest }: {
|
|
3
|
+
import { type SiteSearchItem } from "./siteSearchBody.js";
|
|
4
|
+
import type { Size } from "./size.js";
|
|
5
|
+
export { rankSiteSearch, type SiteSearchItem } from "./siteSearchBody.js";
|
|
6
|
+
type SiteSearchProps = {
|
|
28
7
|
/** Every page to search, in the order ties are listed (the rail's order). */
|
|
29
8
|
items: readonly SiteSearchItem[];
|
|
30
9
|
/**
|
|
31
10
|
* The dialog's title and the phone's icon button's accessible name: "Search components". The wide
|
|
32
|
-
* button is named by its own text,
|
|
11
|
+
* button is named by its own text, `buttonLabel`.
|
|
33
12
|
*/
|
|
34
13
|
label: string;
|
|
35
14
|
/**
|
|
@@ -37,4 +16,55 @@ export declare function SiteSearch({ items, label, resultsLabel, ...rest }: {
|
|
|
37
16
|
* @default Results
|
|
38
17
|
*/
|
|
39
18
|
resultsLabel?: string | undefined;
|
|
40
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The wide button's text, which is also its accessible name.
|
|
21
|
+
* @default Search
|
|
22
|
+
*/
|
|
23
|
+
buttonLabel?: string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The search field's placeholder.
|
|
26
|
+
* @default Search
|
|
27
|
+
*/
|
|
28
|
+
placeholder?: string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The muted line under the field before anything is typed.
|
|
31
|
+
* @default Type a name
|
|
32
|
+
*/
|
|
33
|
+
hintLabel?: string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The muted line when nothing matches; the typed text follows it: "No results for tabel".
|
|
36
|
+
* @default No results for
|
|
37
|
+
*/
|
|
38
|
+
noResultsLabel?: string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* What a screen reader hears for the number of matches once something is typed.
|
|
41
|
+
* @default `No results`, `1 result`, `4 results`
|
|
42
|
+
*/
|
|
43
|
+
countLabel?: ((count: number) => string) | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The site's full results page for a query, built from the typed text (trimmed):
|
|
46
|
+
* `(query) => "/search?q=" + encodeURIComponent(query)`. Given, a link to it is the last row
|
|
47
|
+
* once something is typed, matches or not, and Enter in the field goes there.
|
|
48
|
+
*/
|
|
49
|
+
resultsHref?: ((query: string) => string) | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* The full results link's text; the typed text follows it: "See all results for tabel".
|
|
52
|
+
* @default See all results for
|
|
53
|
+
*/
|
|
54
|
+
allResultsLabel?: string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The trigger's height and text, on the scale of a `Button` and an `IconButton`, so it lines up
|
|
57
|
+
* with the other controls in a header row.
|
|
58
|
+
* @default sm
|
|
59
|
+
*/
|
|
60
|
+
size?: Size | undefined;
|
|
61
|
+
} & Passthrough;
|
|
62
|
+
/**
|
|
63
|
+
* The site's search: a header button that opens a dialog with a search field over a list of links
|
|
64
|
+
* to the pages that match. Put it in `AppShell`'s `controls` and pass every page as `items`. Ctrl+K
|
|
65
|
+
* (⌘ K on a Mac) opens it from anywhere on the page, and the button shows that key. Typing filters
|
|
66
|
+
* by name, then by `keywords`, then by description; Enter opens the first result (or, with
|
|
67
|
+
* `resultsHref`, the full results page), the arrow keys move through them, and Esc closes it and
|
|
68
|
+
* puts focus back where it was. The field is a `<search>` landmark. Render it once per page.
|
|
69
|
+
*/
|
|
70
|
+
export declare function SiteSearch({ items, label, buttonLabel, resultsHref, size, ...props }: SiteSearchProps): ReactElement;
|