@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/isoDate.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import { CalendarDate } from "@internationalized/date";
|
|
1
|
+
import { CalendarDate, CalendarDateTime } from "@internationalized/date";
|
|
2
2
|
/** `"1990-05-17"` for `CalendarDate(1990, 5, 17)`; `""` for no date, so it drops into a form field. */
|
|
3
3
|
export declare function toISODate(date: CalendarDate | null | undefined): string;
|
|
4
4
|
/** The `CalendarDate` of a `"YYYY-MM-DD"` string; `null` for an empty, malformed or impossible one. */
|
|
5
5
|
export declare function fromISODate(iso: string | null | undefined): CalendarDate | null;
|
|
6
|
+
/** `"2026-11-29T14:30"` for `CalendarDateTime(2026, 11, 29, 14, 30)`, seconds dropped; `""` for none. */
|
|
7
|
+
export declare function toISODateTime(value: CalendarDateTime | null | undefined): string;
|
|
8
|
+
/**
|
|
9
|
+
* The `CalendarDateTime` of a `"YYYY-MM-DDTHH:mm"` string; `null` for an empty, malformed or
|
|
10
|
+
* impossible one (a day the month does not have, an hour past 23).
|
|
11
|
+
*/
|
|
12
|
+
export declare function fromISODateTime(iso: string | null | undefined): CalendarDateTime | null;
|
package/dist/isoDate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CalendarDate } from "@internationalized/date";
|
|
1
|
+
import { CalendarDate, CalendarDateTime } from "@internationalized/date";
|
|
2
2
|
const ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
3
3
|
/** `"1990-05-17"` for `CalendarDate(1990, 5, 17)`; `""` for no date, so it drops into a form field. */
|
|
4
4
|
export function toISODate(date) {
|
|
@@ -14,3 +14,22 @@ export function fromISODate(iso) {
|
|
|
14
14
|
// CalendarDate constrains 1990-02-31 to 1990-02-28; a string that does not survive is impossible.
|
|
15
15
|
return date.toString() === iso ? date : null;
|
|
16
16
|
}
|
|
17
|
+
const ISO_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/;
|
|
18
|
+
/** `"2026-11-29T14:30"` for `CalendarDateTime(2026, 11, 29, 14, 30)`, seconds dropped; `""` for none. */
|
|
19
|
+
export function toISODateTime(value) {
|
|
20
|
+
return value ? value.toString().slice(0, 16) : "";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The `CalendarDateTime` of a `"YYYY-MM-DDTHH:mm"` string; `null` for an empty, malformed or
|
|
24
|
+
* impossible one (a day the month does not have, an hour past 23).
|
|
25
|
+
*/
|
|
26
|
+
export function fromISODateTime(iso) {
|
|
27
|
+
const match = ISO_DATE_TIME.exec(iso ?? "");
|
|
28
|
+
if (!match)
|
|
29
|
+
return null;
|
|
30
|
+
const [year, month, day, hour, minute] = [1, 2, 3, 4, 5].map((at) => Number(match[at]));
|
|
31
|
+
if (Number(hour) > 23 || Number(minute) > 59)
|
|
32
|
+
return null;
|
|
33
|
+
const value = new CalendarDateTime(Number(year), Number(month), Number(day), Number(hour), Number(minute));
|
|
34
|
+
return toISODateTime(value) === iso ? value : null;
|
|
35
|
+
}
|
package/dist/labelWords.d.ts
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
/** The ids of a choice's two note lines. */
|
|
3
|
+
export type NoteIds = {
|
|
4
|
+
hint: string;
|
|
5
|
+
error: string;
|
|
6
|
+
};
|
|
2
7
|
/**
|
|
3
|
-
* The label, with its
|
|
4
|
-
*
|
|
8
|
+
* The label, with its notes under it when there are any: the muted hint, and under it the error
|
|
9
|
+
* (an alert icon and red text, announced politely) when set. The hint stays while the error shows.
|
|
5
10
|
*/
|
|
6
|
-
export declare function Words({ label, hint, error,
|
|
11
|
+
export declare function Words({ label, hint, error, ids, }: {
|
|
7
12
|
label: ReactNode;
|
|
8
13
|
hint: ReactNode;
|
|
9
14
|
error: ReactNode;
|
|
10
|
-
|
|
15
|
+
ids: NoteIds | undefined;
|
|
11
16
|
}): ReactNode;
|
|
12
17
|
/**
|
|
13
|
-
* The
|
|
14
|
-
* whether it is invalid (an error is set)
|
|
18
|
+
* The notes' ids (none without a hint or an error), the control's whole `aria-describedby` (the
|
|
19
|
+
* caller's, then the hint, then the error), and whether it is invalid (an error is set), as in a
|
|
20
|
+
* `Field`.
|
|
15
21
|
*/
|
|
16
22
|
export declare function useNote(hint: ReactNode, error: ReactNode, describedBy: string | undefined): {
|
|
17
|
-
|
|
23
|
+
ids: {
|
|
24
|
+
hint: string;
|
|
25
|
+
error: string;
|
|
26
|
+
} | undefined;
|
|
18
27
|
describedIds: string;
|
|
19
28
|
invalid: boolean;
|
|
20
29
|
};
|
package/dist/labelWords.js
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId } from "react";
|
|
3
|
+
import { ErrorLine, Hint, noteDescribedBy } from "./Field.js";
|
|
3
4
|
/** Whether a note is set: `null`, `undefined`, `false` and `""` draw nothing. */
|
|
4
5
|
const given = (note) => note != null && note !== false && note !== "";
|
|
5
6
|
/**
|
|
6
|
-
* The label, with its
|
|
7
|
-
*
|
|
7
|
+
* The label, with its notes under it when there are any: the muted hint, and under it the error
|
|
8
|
+
* (an alert icon and red text, announced politely) when set. The hint stays while the error shows.
|
|
8
9
|
*/
|
|
9
|
-
export function Words({ label, hint, error,
|
|
10
|
-
if (
|
|
10
|
+
export function Words({ label, hint, error, ids, }) {
|
|
11
|
+
if (ids === undefined)
|
|
11
12
|
return label;
|
|
12
|
-
|
|
13
|
-
return (_jsxs("span", { className: "flex flex-col gap-0.5", children: [_jsx("span", { children: label }), _jsx("span", { id: id, role: failed ? "alert" : undefined, className: failed ? "text-xs text-red-700" : "text-xs text-slate-500", children: failed ? error : hint })] }));
|
|
13
|
+
return (_jsxs("span", { className: "flex flex-col gap-0.5", children: [_jsx("span", { children: label }), given(hint) ? _jsx(Hint, { id: ids.hint, children: hint }) : null, given(error) ? _jsx(ErrorLine, { id: ids.error, error: error }) : null] }));
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* The
|
|
17
|
-
* whether it is invalid (an error is set)
|
|
16
|
+
* The notes' ids (none without a hint or an error), the control's whole `aria-describedby` (the
|
|
17
|
+
* caller's, then the hint, then the error), and whether it is invalid (an error is set), as in a
|
|
18
|
+
* `Field`.
|
|
18
19
|
*/
|
|
19
20
|
export function useNote(hint, error, describedBy) {
|
|
20
|
-
const
|
|
21
|
+
const own = { hint: useId(), error: useId() };
|
|
21
22
|
const invalid = given(error);
|
|
22
|
-
const
|
|
23
|
+
const ids = invalid || given(hint) ? own : undefined;
|
|
24
|
+
const notes = noteDescribedBy(given(hint), invalid, own);
|
|
23
25
|
return {
|
|
24
|
-
|
|
25
|
-
describedIds: [describedBy,
|
|
26
|
+
ids,
|
|
27
|
+
describedIds: [describedBy, notes].filter(Boolean).join(" "),
|
|
26
28
|
invalid,
|
|
27
29
|
};
|
|
28
30
|
}
|
package/dist/listRowProps.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef, MouseEventHandler, PointerEventHandler, ReactNode } from "react";
|
|
2
|
-
import type { Unstyled } from "./props.js";
|
|
2
|
+
import type { Passthrough, Unstyled } from "./props.js";
|
|
3
3
|
import type { Size } from "./size.js";
|
|
4
4
|
import type { LoadingProps } from "./skeleton.js";
|
|
5
|
+
import type { TextTone } from "./typography.js";
|
|
5
6
|
type Shared = LoadingProps & {
|
|
6
7
|
/**
|
|
7
8
|
* `sm` is dense padding, `lg` one step roomier than `md`. A `Button`, `IconButton` or `Pill` in a
|
|
@@ -9,8 +10,6 @@ type Shared = LoadingProps & {
|
|
|
9
10
|
* @default md
|
|
10
11
|
*/
|
|
11
12
|
size?: Size | undefined;
|
|
12
|
-
/** A hairline above the row: set it on every row after the first. */
|
|
13
|
-
divided?: boolean | undefined;
|
|
14
13
|
/** Content before the label: an Avatar, a thumbnail, an icon. */
|
|
15
14
|
leading?: ReactNode | undefined;
|
|
16
15
|
/** A second, muted line under the label (a date, a note), like `TableCell`'s `secondary`. */
|
|
@@ -31,8 +30,7 @@ type Shared = LoadingProps & {
|
|
|
31
30
|
/**
|
|
32
31
|
* Marks the row a list follows with the pointer and the keyboard alike (set it from
|
|
33
32
|
* `onPointerEnter` and `onFocus`): a fill one step deeper than hover, so it shows on a white card
|
|
34
|
-
* and on a tinted panel alike.
|
|
35
|
-
* shows `actions` that `revealOnHover` hides. `selected` wins.
|
|
33
|
+
* and on a tinted panel alike. It is the only fill a static row takes. `selected` wins.
|
|
36
34
|
*
|
|
37
35
|
* Clear it from `onPointerLeave`.
|
|
38
36
|
*/
|
|
@@ -44,11 +42,15 @@ type Shared = LoadingProps & {
|
|
|
44
42
|
* For a row that shows a screenshot.
|
|
45
43
|
*/
|
|
46
44
|
leadingWidth?: "thumbnail" | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* The row's status, as a stripe on its leading edge in this tone, as a `Table` row's `stripe`. The
|
|
47
|
+
* colour says it to the eye only, so the row's words say it too (a `Pill`, a status in `trailing`).
|
|
48
|
+
*/
|
|
49
|
+
stripe?: Exclude<TextTone, "neutral"> | undefined;
|
|
47
50
|
children: ReactNode;
|
|
48
51
|
};
|
|
49
52
|
type NotStatic = {
|
|
50
53
|
actions?: undefined;
|
|
51
|
-
revealOnHover?: undefined;
|
|
52
54
|
panel?: undefined;
|
|
53
55
|
};
|
|
54
56
|
export type ListRowButtonProps = Shared & NotStatic & {
|
|
@@ -81,21 +83,19 @@ export type ListRowLinkProps = Shared & NotStatic & {
|
|
|
81
83
|
href: string;
|
|
82
84
|
};
|
|
83
85
|
/**
|
|
84
|
-
* A row with no `href` and no `onClick`: a `<div>` with no click target and no hover fill
|
|
85
|
-
*
|
|
86
|
+
* A row with no `href` and no `onClick`: a `<div>` with no click target and no hover fill, for one
|
|
87
|
+
* that holds its own controls, taking `actions` as well.
|
|
86
88
|
*/
|
|
87
89
|
export type ListRowStaticProps = Shared & {
|
|
88
|
-
/** Buttons for this row, after `trailing`: `Button size="sm"`, `IconButton`. */
|
|
89
|
-
actions?: ReactNode | undefined;
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
91
|
+
* Buttons for this row, after `trailing`: `Button size="sm"`, `IconButton`, a `Menu`. Always
|
|
92
|
+
* shown: an action that shows only on hover is one a touch or keyboard user cannot find.
|
|
93
93
|
*/
|
|
94
|
-
|
|
94
|
+
actions?: ReactNode | undefined;
|
|
95
95
|
/**
|
|
96
96
|
* Content under the row, lined up with the label rather than the row's edge (past `leading`): the
|
|
97
97
|
* panel of a row that opens in place, such as a conversation under its chat. It sits inside the
|
|
98
|
-
* row, so
|
|
98
|
+
* row, so the fill and a `Stack divided` line cover it too. Only a row that is neither a
|
|
99
99
|
* button nor a link takes it.
|
|
100
100
|
*/
|
|
101
101
|
panel?: ReactNode | undefined;
|
|
@@ -103,6 +103,8 @@ export type ListRowStaticProps = Shared & {
|
|
|
103
103
|
onClick?: undefined;
|
|
104
104
|
disabledReason?: undefined;
|
|
105
105
|
href?: undefined;
|
|
106
|
-
} &
|
|
106
|
+
} & Passthrough &
|
|
107
|
+
/** What sets and clears `highlighted`; focus events bubble up from the row's own controls. */
|
|
108
|
+
Pick<ComponentPropsWithoutRef<"div">, "onPointerEnter" | "onPointerLeave" | "onFocus" | "onBlur">;
|
|
107
109
|
export type ListRowProps = ListRowButtonProps | ListRowLinkProps | ListRowStaticProps;
|
|
108
110
|
export {};
|
package/dist/modal.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { type RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Whether a `Dialog`, `Drawer` or `Lightbox` is open. `ToastRegion` holds its toasts back while one
|
|
4
|
+
* is: the page behind a modal is inert, so a toast there could be neither read nor reached.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useModalOpen(): boolean;
|
|
2
7
|
/**
|
|
3
8
|
* Opens the `<dialog>` with `showModal()` on mount and closes it on unmount. Closing on unmount
|
|
4
9
|
* (not just on Esc or the backdrop) hands focus back to the opener and drops the inert page behind
|
package/dist/modal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useLayoutEffect, useRef } from "react";
|
|
1
|
+
import { useLayoutEffect, useRef, useSyncExternalStore } from "react";
|
|
2
2
|
/** Resolves when the transitions running on the dialog (and its backdrop) have ended. */
|
|
3
3
|
async function exitTransitions(dialog) {
|
|
4
4
|
// A browser without the Web Animations API (or jsdom) has nothing to wait for.
|
|
@@ -7,6 +7,24 @@ async function exitTransitions(dialog) {
|
|
|
7
7
|
const running = dialog.getAnimations({ subtree: true }).filter((a) => "transitionProperty" in a);
|
|
8
8
|
await Promise.allSettled(running.map((a) => a.finished));
|
|
9
9
|
}
|
|
10
|
+
/** How many of the library's modals are open, and who wants to hear when that changes. */
|
|
11
|
+
let openModals = 0;
|
|
12
|
+
const watchers = new Set();
|
|
13
|
+
const opened = (by) => {
|
|
14
|
+
openModals += by;
|
|
15
|
+
for (const watcher of watchers)
|
|
16
|
+
watcher();
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Whether a `Dialog`, `Drawer` or `Lightbox` is open. `ToastRegion` holds its toasts back while one
|
|
20
|
+
* is: the page behind a modal is inert, so a toast there could be neither read nor reached.
|
|
21
|
+
*/
|
|
22
|
+
export function useModalOpen() {
|
|
23
|
+
return useSyncExternalStore((watcher) => {
|
|
24
|
+
watchers.add(watcher);
|
|
25
|
+
return () => watchers.delete(watcher);
|
|
26
|
+
}, () => openModals > 0, () => false);
|
|
27
|
+
}
|
|
10
28
|
/**
|
|
11
29
|
* Opens the `<dialog>` with `showModal()` on mount and closes it on unmount. Closing on unmount
|
|
12
30
|
* (not just on Esc or the backdrop) hands focus back to the opener and drops the inert page behind
|
|
@@ -22,9 +40,11 @@ export function useModal(dialog, onClose) {
|
|
|
22
40
|
const el = dialog.current;
|
|
23
41
|
mounted.current = true;
|
|
24
42
|
el?.showModal();
|
|
43
|
+
opened(1);
|
|
25
44
|
return () => {
|
|
26
45
|
mounted.current = false;
|
|
27
46
|
el?.close();
|
|
47
|
+
opened(-1);
|
|
28
48
|
};
|
|
29
49
|
}, [dialog]);
|
|
30
50
|
return () => {
|
package/dist/navFold.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { observeItems } from "./scrollEdges.js";
|
|
2
3
|
// AppShell's `md` step: below it the nav is always in the Menu, so nothing is measured there.
|
|
3
4
|
const WIDE = "(width >= 48rem)";
|
|
4
5
|
/**
|
|
@@ -23,6 +24,8 @@ export function useNavFold(row, enabled) {
|
|
|
23
24
|
return undefined;
|
|
24
25
|
const wide = window.matchMedia(WIDE);
|
|
25
26
|
const check = () => {
|
|
27
|
+
// A slot hidden when the effect ran (the closed Menu below `md`) is picked up once shown.
|
|
28
|
+
observeItems(observer, row);
|
|
26
29
|
if (!wide.matches)
|
|
27
30
|
return;
|
|
28
31
|
const now = state.current;
|
|
@@ -36,10 +39,10 @@ export function useNavFold(row, enabled) {
|
|
|
36
39
|
};
|
|
37
40
|
const observer = new ResizeObserver(check);
|
|
38
41
|
// The row is the header's width, so it resizes only with the screen; its slots resize with
|
|
39
|
-
// their content (a font swap, a label that changes), so they are watched too
|
|
42
|
+
// their content (a font swap, a label that changes), so they are watched too, through the
|
|
43
|
+
// menu panel, which draws no box of its own in the row.
|
|
40
44
|
observer.observe(row);
|
|
41
|
-
|
|
42
|
-
observer.observe(slot);
|
|
45
|
+
observeItems(observer, row);
|
|
43
46
|
return () => observer.disconnect();
|
|
44
47
|
});
|
|
45
48
|
return enabled && folded;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A choice's look: `plain` is the mark and its words; `card` puts them in a bordered box, the whole box the click target. */
|
|
2
|
+
export type ChoiceVariant = "plain" | "card";
|
|
3
|
+
/**
|
|
4
|
+
* The box of a `card` choice (a `Checkbox`, a `Radio`): full width, padded, the control's border
|
|
5
|
+
* colour, and the hover edge of a field. Its parent is `relative` (the touch target's), so the
|
|
6
|
+
* chosen edge below sits on it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const OPTION_CARD = "w-full rounded-lg border border-slate-300 bg-white p-3 transition";
|
|
9
|
+
/** A card's edge under the pointer, when it is enabled. */
|
|
10
|
+
export declare const OPTION_CARD_HOVER = "hover:border-violet-400";
|
|
11
|
+
/**
|
|
12
|
+
* The chosen card's edge: a 2px accent border drawn over the card's own, so the words do not move.
|
|
13
|
+
* It is shown by the caller (`visible` from the input's state), so a card that keeps its own state
|
|
14
|
+
* changes with no re-render.
|
|
15
|
+
*/
|
|
16
|
+
export declare const OPTION_CARD_CHOSEN = "pointer-events-none absolute -inset-px rounded-lg border-2 border-violet-600";
|
|
17
|
+
/** The card's title: a step heavier than a plain choice's words, as a card's heading is. */
|
|
18
|
+
export declare const OPTION_CARD_TITLE = "font-medium text-slate-900";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The box of a `card` choice (a `Checkbox`, a `Radio`): full width, padded, the control's border
|
|
3
|
+
* colour, and the hover edge of a field. Its parent is `relative` (the touch target's), so the
|
|
4
|
+
* chosen edge below sits on it.
|
|
5
|
+
*/
|
|
6
|
+
export const OPTION_CARD = "w-full rounded-lg border border-slate-300 bg-white p-3 transition";
|
|
7
|
+
/** A card's edge under the pointer, when it is enabled. */
|
|
8
|
+
export const OPTION_CARD_HOVER = "hover:border-violet-400";
|
|
9
|
+
/**
|
|
10
|
+
* The chosen card's edge: a 2px accent border drawn over the card's own, so the words do not move.
|
|
11
|
+
* It is shown by the caller (`visible` from the input's state), so a card that keeps its own state
|
|
12
|
+
* changes with no re-render.
|
|
13
|
+
*/
|
|
14
|
+
export const OPTION_CARD_CHOSEN = "pointer-events-none absolute -inset-px rounded-lg border-2 border-violet-600";
|
|
15
|
+
/** The card's title: a step heavier than a plain choice's words, as a card's heading is. */
|
|
16
|
+
export const OPTION_CARD_TITLE = "font-medium text-slate-900";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A box that scrolls (a `Drawer`'s or a `BottomSheet`'s body, a filled `Card`'s body, a
|
|
4
|
+
* `CodeExample`'s preview), with the keyboard side `useScrollStop` gives it: while it overflows and
|
|
5
|
+
* holds nothing the keyboard can reach, it takes a tab stop, a group named by `label` or
|
|
6
|
+
* `labelledBy`. Its ring is drawn inside it, since each of these sits in a frame that clips.
|
|
7
|
+
* Internal: `className` is the library's own.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ScrollBody({ axis, label, labelledBy, id, className, children, }: {
|
|
10
|
+
axis?: "x" | "y";
|
|
11
|
+
label?: string | undefined;
|
|
12
|
+
labelledBy?: string | undefined;
|
|
13
|
+
id?: string | undefined;
|
|
14
|
+
className: string;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}): ReactElement;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx, insetFocusRing } from "./cx.js";
|
|
3
|
+
import { scrollStopProps, useScrollStop } from "./scrollStop.js";
|
|
4
|
+
/**
|
|
5
|
+
* A box that scrolls (a `Drawer`'s or a `BottomSheet`'s body, a filled `Card`'s body, a
|
|
6
|
+
* `CodeExample`'s preview), with the keyboard side `useScrollStop` gives it: while it overflows and
|
|
7
|
+
* holds nothing the keyboard can reach, it takes a tab stop, a group named by `label` or
|
|
8
|
+
* `labelledBy`. Its ring is drawn inside it, since each of these sits in a frame that clips.
|
|
9
|
+
* Internal: `className` is the library's own.
|
|
10
|
+
*/
|
|
11
|
+
export function ScrollBody({ axis = "y", label, labelledBy, id, className, children, }) {
|
|
12
|
+
const { attach, stop } = useScrollStop(axis);
|
|
13
|
+
const { props } = scrollStopProps(stop, { label, labelledBy });
|
|
14
|
+
return (_jsx("div", { ref: attach, id: id, ...props, className: cx(className, stop && insetFocusRing), children: children }));
|
|
15
|
+
}
|
package/dist/scrollEdges.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observes each child of `box` that draws a box and is not watched yet. A ResizeObserver never
|
|
3
|
+
* fires for a `display: contents` element (it has no box), so such a child is looked through and
|
|
4
|
+
* its own children are observed instead, down any depth. A hidden child is skipped; call it again
|
|
5
|
+
* once it may show (from the observer's callback), and only the new ones are added.
|
|
6
|
+
*/
|
|
7
|
+
export declare function observeItems(observer: ResizeObserver, box: Element): void;
|
|
1
8
|
/**
|
|
2
9
|
* Marks a box that scrolls with which of its edges still has content past it, so the layout can fade
|
|
3
10
|
* them: `data-more-start` (scrolled away from the start), `data-more-end` (more to scroll to) and
|
package/dist/scrollEdges.js
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
|
+
// What each observer already watches. Observing an element again restarts it, which reports its
|
|
3
|
+
// size once more and, from inside the callback, would loop.
|
|
4
|
+
const watched = new WeakMap();
|
|
5
|
+
/**
|
|
6
|
+
* Observes each child of `box` that draws a box and is not watched yet. A ResizeObserver never
|
|
7
|
+
* fires for a `display: contents` element (it has no box), so such a child is looked through and
|
|
8
|
+
* its own children are observed instead, down any depth. A hidden child is skipped; call it again
|
|
9
|
+
* once it may show (from the observer's callback), and only the new ones are added.
|
|
10
|
+
*/
|
|
11
|
+
export function observeItems(observer, box) {
|
|
12
|
+
const seen = watched.get(observer) ?? new WeakSet();
|
|
13
|
+
watched.set(observer, seen);
|
|
14
|
+
for (const child of box.children) {
|
|
15
|
+
const display = getComputedStyle(child).display;
|
|
16
|
+
if (display === "none")
|
|
17
|
+
continue;
|
|
18
|
+
if (display === "contents")
|
|
19
|
+
observeItems(observer, child);
|
|
20
|
+
else if (!seen.has(child)) {
|
|
21
|
+
seen.add(child);
|
|
22
|
+
observer.observe(child);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
2
26
|
/**
|
|
3
27
|
* Marks a box that scrolls with which of its edges still has content past it, so the layout can fade
|
|
4
28
|
* them: `data-more-start` (scrolled away from the start), `data-more-end` (more to scroll to) and
|
|
@@ -17,7 +41,8 @@ export function useScrollEdges(element, axis) {
|
|
|
17
41
|
const el = element;
|
|
18
42
|
const update = () => {
|
|
19
43
|
const [position, scrollSize, clientSize] = axis === "x"
|
|
20
|
-
?
|
|
44
|
+
? // Right to left, scrollLeft runs from 0 at the start to negative at the end.
|
|
45
|
+
[Math.abs(el.scrollLeft), el.scrollWidth, el.clientWidth]
|
|
21
46
|
: [el.scrollTop, el.scrollHeight, el.clientHeight];
|
|
22
47
|
const start = position > 1;
|
|
23
48
|
const end = scrollSize - clientSize - position > 1;
|
|
@@ -28,10 +53,19 @@ export function useScrollEdges(element, axis) {
|
|
|
28
53
|
update();
|
|
29
54
|
el.addEventListener("scroll", update, { passive: true });
|
|
30
55
|
// jsdom (a consumer's own tests) has no ResizeObserver.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
56
|
+
// Each resize looks for items again: one hidden when the effect ran (`display: none` below a
|
|
57
|
+
// breakpoint) is observed once it shows. Observing an item twice is a no-op.
|
|
58
|
+
const resize = typeof ResizeObserver === "undefined"
|
|
59
|
+
? undefined
|
|
60
|
+
: new ResizeObserver(() => {
|
|
61
|
+
if (resize)
|
|
62
|
+
observeItems(resize, el);
|
|
63
|
+
update();
|
|
64
|
+
});
|
|
65
|
+
if (resize) {
|
|
66
|
+
resize.observe(el);
|
|
67
|
+
observeItems(resize, el);
|
|
68
|
+
}
|
|
35
69
|
return () => {
|
|
36
70
|
el.removeEventListener("scroll", update);
|
|
37
71
|
resize?.disconnect();
|
package/dist/scrollStop.d.ts
CHANGED
|
@@ -11,13 +11,17 @@ export declare const TABBABLE = ":is(a[href], button, input:not([type=\"hidden\"
|
|
|
11
11
|
* scrolls: "y" (down, the default) or "x" (sideways); overflow the other way is not measured,
|
|
12
12
|
* since the box does not scroll that way. `measured` is false until the box has been measured once
|
|
13
13
|
* and true after: a page rendered to HTML and never hydrated is never measured, and neither is a
|
|
14
|
-
* box where `ResizeObserver` is missing (a consumer's jsdom tests with no stub).
|
|
14
|
+
* box where `ResizeObserver` is missing (a consumer's jsdom tests with no stub). `overflows` is
|
|
15
|
+
* whether the box overflowed when last measured. `wider`, for a box that may stop scrolling while it
|
|
16
|
+
* fits (a `Table`'s, which clips instead so its head can stick to the page), measures the overflow
|
|
17
|
+
* from the content instead of the box's own scroll width.
|
|
15
18
|
*/
|
|
16
|
-
export declare function useScrollStop(axis?: "x" | "y"): {
|
|
19
|
+
export declare function useScrollStop(axis?: "x" | "y", wider?: (box: HTMLElement) => boolean): {
|
|
17
20
|
element: HTMLElement | null;
|
|
18
21
|
attach: (el: HTMLDivElement | null) => void;
|
|
19
22
|
stop: boolean;
|
|
20
23
|
measured: boolean;
|
|
24
|
+
overflows: boolean;
|
|
21
25
|
};
|
|
22
26
|
/**
|
|
23
27
|
* The props a scroller takes while it holds the tab stop: focusable, ringed and, when the column
|
package/dist/scrollStop.js
CHANGED
|
@@ -22,21 +22,31 @@ function holdsTabbable(scroller) {
|
|
|
22
22
|
* scrolls: "y" (down, the default) or "x" (sideways); overflow the other way is not measured,
|
|
23
23
|
* since the box does not scroll that way. `measured` is false until the box has been measured once
|
|
24
24
|
* and true after: a page rendered to HTML and never hydrated is never measured, and neither is a
|
|
25
|
-
* box where `ResizeObserver` is missing (a consumer's jsdom tests with no stub).
|
|
25
|
+
* box where `ResizeObserver` is missing (a consumer's jsdom tests with no stub). `overflows` is
|
|
26
|
+
* whether the box overflowed when last measured. `wider`, for a box that may stop scrolling while it
|
|
27
|
+
* fits (a `Table`'s, which clips instead so its head can stick to the page), measures the overflow
|
|
28
|
+
* from the content instead of the box's own scroll width.
|
|
26
29
|
*/
|
|
27
|
-
export function useScrollStop(axis = "y") {
|
|
30
|
+
export function useScrollStop(axis = "y", wider) {
|
|
28
31
|
const [element, setElement] = useState(null);
|
|
29
32
|
const [stop, setStop] = useState(false);
|
|
30
33
|
const [measured, setMeasured] = useState(false);
|
|
34
|
+
const [overflowing, setOverflowing] = useState(false);
|
|
31
35
|
useEffect(() => {
|
|
32
36
|
// jsdom (a consumer's own tests) has no ResizeObserver.
|
|
33
37
|
if (!element || typeof ResizeObserver === "undefined")
|
|
34
38
|
return undefined;
|
|
35
|
-
const overflows = () =>
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
const overflows = () => {
|
|
40
|
+
if (wider)
|
|
41
|
+
return wider(element);
|
|
42
|
+
return axis === "y"
|
|
43
|
+
? element.scrollHeight > element.clientHeight
|
|
44
|
+
: element.scrollWidth > element.clientWidth;
|
|
45
|
+
};
|
|
38
46
|
const measure = () => {
|
|
39
|
-
|
|
47
|
+
const over = overflows();
|
|
48
|
+
setOverflowing(over);
|
|
49
|
+
setStop(over && !holdsTabbable(element));
|
|
40
50
|
setMeasured(true);
|
|
41
51
|
};
|
|
42
52
|
// Each observer reports once when it starts, and again when the box is resized, its content
|
|
@@ -56,8 +66,14 @@ export function useScrollStop(axis = "y") {
|
|
|
56
66
|
resize.disconnect();
|
|
57
67
|
change.disconnect();
|
|
58
68
|
};
|
|
59
|
-
}, [element, axis]);
|
|
60
|
-
return {
|
|
69
|
+
}, [element, axis, wider]);
|
|
70
|
+
return {
|
|
71
|
+
element,
|
|
72
|
+
attach: setElement,
|
|
73
|
+
stop: stop && element !== null,
|
|
74
|
+
measured,
|
|
75
|
+
overflows: overflowing && element !== null,
|
|
76
|
+
};
|
|
61
77
|
}
|
|
62
78
|
/**
|
|
63
79
|
* The props a scroller takes while it holds the tab stop: focusable, ringed and, when the column
|
package/dist/shownDate.d.ts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CalendarDate, type CalendarDateTime, type DateValue } from "@internationalized/date";
|
|
2
2
|
import { type FocusEvent, type ReactElement } from "react";
|
|
3
3
|
import type { FieldProps, Read } from "./DateField.js";
|
|
4
|
-
|
|
4
|
+
/** What a typed field holds: its value type, how it is written as ISO text, and how fine it is. */
|
|
5
|
+
export type Kind<T extends CalendarDate | CalendarDateTime> = {
|
|
6
|
+
granularity: "day" | "minute";
|
|
7
|
+
toISO: (value: T | null | undefined) => string;
|
|
8
|
+
fromISO: (iso: string) => T | null;
|
|
9
|
+
/** The field's value as this kind's own type. */
|
|
10
|
+
narrow: (value: DateValue | null) => T | null;
|
|
11
|
+
/** The message for a required field left partly typed. */
|
|
12
|
+
whole: string;
|
|
13
|
+
};
|
|
14
|
+
/** A day: `YYYY-MM-DD`. */
|
|
15
|
+
export declare const DATE: Kind<CalendarDate>;
|
|
16
|
+
/** A day and a time to the minute: `YYYY-MM-DDTHH:mm`. */
|
|
17
|
+
export declare const DATE_TIME: Kind<CalendarDateTime>;
|
|
5
18
|
/** The value props, each of which may be passed as `undefined`. */
|
|
6
|
-
type ValueProps = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
19
|
+
type ValueProps<T> = {
|
|
20
|
+
value?: T | null | undefined;
|
|
21
|
+
defaultValue?: T | null | undefined;
|
|
22
|
+
onChange?: ((value: T | null) => void) | null | undefined;
|
|
23
|
+
minValue?: DateValue | null | undefined;
|
|
24
|
+
maxValue?: DateValue | null | undefined;
|
|
25
|
+
isRequired?: boolean | undefined;
|
|
10
26
|
};
|
|
11
27
|
/**
|
|
12
28
|
* The value the field reports is always what it shows: the typed date when it is complete, exists
|
|
@@ -27,13 +43,13 @@ type ValueProps = {
|
|
|
27
43
|
*
|
|
28
44
|
* `shown` (`YYYY-MM-DD` or `""`) is what the hidden `name` input posts.
|
|
29
45
|
*/
|
|
30
|
-
export declare function useShownDate(props: ValueProps): {
|
|
31
|
-
inner:
|
|
32
|
-
setInner: import("react").Dispatch<import("react").SetStateAction<
|
|
46
|
+
export declare function useShownDate<T extends CalendarDate | CalendarDateTime>(props: ValueProps<T>, kind: Kind<T>): {
|
|
47
|
+
inner: T | null;
|
|
48
|
+
setInner: import("react").Dispatch<import("react").SetStateAction<T | null>>;
|
|
33
49
|
shown: string;
|
|
34
50
|
impossible: string | null;
|
|
35
51
|
onRead: (next: Read) => void;
|
|
36
|
-
validate: () =>
|
|
52
|
+
validate: () => string | null;
|
|
37
53
|
leaving: boolean;
|
|
38
54
|
onBlurCapture: (event: FocusEvent<HTMLElement>) => void;
|
|
39
55
|
onLeft: () => void;
|
|
@@ -50,6 +66,8 @@ type RangeProps = {
|
|
|
50
66
|
minValue?: FieldProps["minValue"] | undefined;
|
|
51
67
|
maxValue?: FieldProps["maxValue"] | undefined;
|
|
52
68
|
isRequired?: boolean | undefined;
|
|
69
|
+
/** The start and end side's names, which start an impossible day's message. */
|
|
70
|
+
labels: [string, string];
|
|
53
71
|
};
|
|
54
72
|
/**
|
|
55
73
|
* `useShownDate` for a range: each side's segments are read on their own, and the range reported is
|