@slashsuite/ui-react 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATING.md +386 -8
- package/README.md +101 -44
- package/agent-docs/components/app-shell.md +139 -0
- package/agent-docs/components/article-layout.md +140 -0
- package/agent-docs/components/audio.md +42 -0
- package/agent-docs/components/avatar-stack.md +64 -0
- package/agent-docs/components/avatar.md +76 -0
- package/agent-docs/components/badge.md +62 -0
- package/agent-docs/components/body-text.md +169 -0
- package/agent-docs/components/bottom-sheet.md +105 -0
- package/agent-docs/components/breadcrumbs.md +66 -0
- package/agent-docs/components/bullet-list.md +54 -0
- package/agent-docs/components/button.md +135 -0
- package/agent-docs/components/call-to-action.md +59 -0
- package/agent-docs/components/callout.md +87 -0
- package/agent-docs/components/card-grid.md +116 -0
- package/agent-docs/components/card.md +128 -0
- package/agent-docs/components/cart-button.md +63 -0
- package/agent-docs/components/centered-layout.md +90 -0
- package/agent-docs/components/chat-composer.md +49 -0
- package/agent-docs/components/chat-message.md +61 -0
- package/agent-docs/components/chat-thread.md +49 -0
- package/agent-docs/components/checkbox.md +81 -0
- package/agent-docs/components/cluster.md +108 -0
- package/agent-docs/components/code-example.md +48 -0
- package/agent-docs/components/code.md +72 -0
- package/agent-docs/components/colour-scheme-toggle.md +98 -0
- package/agent-docs/components/colour-swatch.md +41 -0
- package/agent-docs/components/combobox.md +88 -0
- package/agent-docs/components/confirm-dialog.md +98 -0
- package/agent-docs/components/container.md +51 -0
- package/agent-docs/components/copy-button.md +63 -0
- package/agent-docs/components/copy-line.md +55 -0
- package/agent-docs/components/date-field.md +106 -0
- package/agent-docs/components/date-range-picker.md +108 -0
- package/agent-docs/components/date-time-field.md +73 -0
- package/agent-docs/components/detail-layout.md +147 -0
- package/agent-docs/components/dialog.md +132 -0
- package/agent-docs/components/disclosure.md +70 -0
- package/agent-docs/components/divider.md +62 -0
- package/agent-docs/components/docs-layout.md +164 -0
- package/agent-docs/components/drawer.md +137 -0
- package/agent-docs/components/embed-frame.md +48 -0
- package/agent-docs/components/empty-state.md +70 -0
- package/agent-docs/components/field-dialog.md +98 -0
- package/agent-docs/components/field.md +71 -0
- package/agent-docs/components/fieldset.md +82 -0
- package/agent-docs/components/file-drop.md +52 -0
- package/agent-docs/components/flow-diagram.md +87 -0
- package/agent-docs/components/form-layout.md +144 -0
- package/agent-docs/components/form-row.md +93 -0
- package/agent-docs/components/full-bleed-layout.md +114 -0
- package/agent-docs/components/headings.md +107 -0
- package/agent-docs/components/hero.md +68 -0
- package/agent-docs/components/icon-button.md +90 -0
- package/agent-docs/components/icon.md +59 -0
- package/agent-docs/components/image.md +74 -0
- package/agent-docs/components/input.md +84 -0
- package/agent-docs/components/kbd.md +38 -0
- package/agent-docs/components/key-value-list.md +84 -0
- package/agent-docs/components/lightbox.md +97 -0
- package/agent-docs/components/list-layout.md +152 -0
- package/agent-docs/components/list-row.md +119 -0
- package/agent-docs/components/loading.md +69 -0
- package/agent-docs/components/markdown.md +51 -0
- package/agent-docs/components/media-tile.md +101 -0
- package/agent-docs/components/menu.md +110 -0
- package/agent-docs/components/meta-list.md +69 -0
- package/agent-docs/components/morph.md +134 -0
- package/agent-docs/components/navigation-progress.md +56 -0
- package/agent-docs/components/number-field.md +75 -0
- package/agent-docs/components/outline-region.md +74 -0
- package/agent-docs/components/page-fade.md +117 -0
- package/agent-docs/components/page-header.md +93 -0
- package/agent-docs/components/pagination.md +64 -0
- package/agent-docs/components/pill.md +105 -0
- package/agent-docs/components/popover.md +63 -0
- package/agent-docs/components/price.md +49 -0
- package/agent-docs/components/product-tile.md +78 -0
- package/agent-docs/components/progress-bar.md +66 -0
- package/agent-docs/components/promo-banner.md +46 -0
- package/agent-docs/components/prose-layout.md +87 -0
- package/agent-docs/components/prose.md +41 -0
- package/agent-docs/components/radio-group.md +77 -0
- package/agent-docs/components/scroll-strip.md +48 -0
- package/agent-docs/components/segmented-control.md +135 -0
- package/agent-docs/components/select.md +70 -0
- package/agent-docs/components/show.md +120 -0
- package/agent-docs/components/side-column.md +74 -0
- package/agent-docs/components/sidebar-layout.md +134 -0
- package/agent-docs/components/site-footer.md +63 -0
- package/agent-docs/components/site-search.md +79 -0
- package/agent-docs/components/slider.md +59 -0
- package/agent-docs/components/sortable-list.md +112 -0
- package/agent-docs/components/split-bar.md +54 -0
- package/agent-docs/components/stack.md +197 -0
- package/agent-docs/components/stacked-bar.md +91 -0
- package/agent-docs/components/stat-tile.md +69 -0
- package/agent-docs/components/state-machine.md +95 -0
- package/agent-docs/components/status-pages.md +112 -0
- package/agent-docs/components/stepper.md +54 -0
- package/agent-docs/components/steps.md +74 -0
- package/agent-docs/components/sticky-bar.md +51 -0
- package/agent-docs/components/switch.md +79 -0
- package/agent-docs/components/table-of-contents.md +78 -0
- package/agent-docs/components/table.md +384 -0
- package/agent-docs/components/tabs.md +178 -0
- package/agent-docs/components/text-link.md +110 -0
- package/agent-docs/components/textarea.md +53 -0
- package/agent-docs/components/timeline.md +79 -0
- package/agent-docs/components/toast.md +91 -0
- package/agent-docs/components/trend-chart.md +61 -0
- package/agent-docs/components/video.md +49 -0
- package/agent-docs/llms.txt +174 -0
- package/dist/AppShell.d.ts +25 -9
- package/dist/AppShell.js +67 -33
- package/dist/AppShellMenu.d.ts +31 -18
- package/dist/AppShellMenu.js +72 -45
- package/dist/ArticleLayout.d.ts +36 -0
- package/dist/ArticleLayout.js +27 -0
- package/dist/Audio.d.ts +16 -0
- package/dist/Audio.js +11 -0
- package/dist/Badge.d.ts +2 -1
- package/dist/Badge.js +3 -2
- package/dist/BottomSheet.d.ts +17 -6
- package/dist/BottomSheet.js +62 -11
- package/dist/Breadcrumbs.d.ts +8 -6
- package/dist/Breadcrumbs.js +17 -7
- package/dist/Button.d.ts +1 -0
- package/dist/Button.js +4 -3
- package/dist/CallToAction.d.ts +25 -0
- package/dist/CallToAction.js +17 -0
- package/dist/Callout.d.ts +2 -2
- package/dist/Callout.js +2 -2
- package/dist/Card.d.ts +88 -31
- package/dist/Card.js +55 -92
- package/dist/CardBody.d.ts +2 -0
- package/dist/CardBody.js +33 -3
- package/dist/CardGrid.d.ts +32 -4
- package/dist/CardGrid.js +42 -8
- package/dist/CardParts.d.ts +7 -1
- package/dist/CardParts.js +7 -2
- package/dist/CartButton.d.ts +33 -0
- package/dist/CartButton.js +18 -0
- package/dist/ChatComposer.d.ts +10 -4
- package/dist/ChatComposer.js +35 -13
- package/dist/Checkbox.d.ts +21 -3
- package/dist/Checkbox.js +66 -20
- package/dist/Chevron.js +1 -1
- package/dist/Cluster.d.ts +28 -15
- package/dist/Cluster.js +21 -4
- package/dist/Code.d.ts +15 -3
- package/dist/Code.js +23 -3
- package/dist/CodeBlock.d.ts +4 -4
- package/dist/CodeBlock.js +2 -2
- package/dist/CodeBody.d.ts +1 -1
- package/dist/CodeBody.js +4 -10
- package/dist/CodeExample.d.ts +1 -1
- package/dist/CodeExample.js +3 -2
- package/dist/ColourSchemeToggle.d.ts +21 -5
- package/dist/ColourSchemeToggle.js +15 -9
- package/dist/ColourSwatch.d.ts +15 -0
- package/dist/ColourSwatch.js +14 -0
- package/dist/Combobox.d.ts +42 -0
- package/dist/Combobox.js +43 -0
- package/dist/ConfirmDialog.d.ts +40 -0
- package/dist/ConfirmDialog.js +36 -0
- package/dist/Container.d.ts +3 -3
- package/dist/Container.js +1 -1
- package/dist/CopyButton.d.ts +8 -2
- package/dist/CopyButton.js +38 -28
- package/dist/CopyLine.d.ts +4 -2
- package/dist/CopyLine.js +4 -4
- package/dist/DateCalendar.d.ts +2 -0
- package/dist/DateCalendar.js +11 -9
- package/dist/DateField.d.ts +52 -21
- package/dist/DateField.js +73 -37
- package/dist/DateFieldCalendar.d.ts +12 -8
- package/dist/DateFieldCalendar.js +37 -18
- package/dist/DateRangePicker.d.ts +23 -3
- package/dist/DateRangePicker.js +10 -8
- package/dist/DateTimeField.d.ts +31 -0
- package/dist/DateTimeField.js +19 -0
- package/dist/Dialog.d.ts +42 -6
- package/dist/Dialog.js +50 -12
- package/dist/Disclosure.js +9 -1
- package/dist/DocsLayout.d.ts +13 -5
- package/dist/DocsLayout.js +11 -9
- package/dist/Drawer.d.ts +22 -7
- package/dist/Drawer.js +89 -8
- package/dist/EmbedFrame.d.ts +36 -0
- package/dist/EmbedFrame.js +18 -0
- package/dist/Field.d.ts +41 -4
- package/dist/Field.js +61 -25
- package/dist/FieldDialog.d.ts +8 -3
- package/dist/FieldDialog.js +19 -9
- package/dist/Fieldset.d.ts +3 -3
- package/dist/Fieldset.js +7 -9
- package/dist/FileDrop.js +2 -1
- package/dist/FlowDiagram.d.ts +92 -0
- package/dist/FlowDiagram.js +100 -0
- package/dist/FormRow.d.ts +6 -4
- package/dist/FormRow.js +11 -9
- package/dist/Hero.d.ts +30 -7
- package/dist/Hero.js +23 -9
- package/dist/Icon.d.ts +1 -1
- package/dist/Icon.js +1 -1
- package/dist/IconButton.js +1 -1
- package/dist/Image.d.ts +33 -9
- package/dist/Image.js +61 -16
- package/dist/Input.d.ts +1 -1
- package/dist/Input.js +4 -4
- package/dist/InputShell.d.ts +7 -0
- package/dist/InputShell.js +18 -3
- package/dist/KeyValueList.d.ts +2 -2
- package/dist/Lightbox.js +5 -3
- package/dist/ListRow.d.ts +4 -5
- package/dist/ListRow.js +36 -26
- package/dist/Mark.d.ts +10 -0
- package/dist/Mark.js +9 -0
- package/dist/Markdown.d.ts +18 -4
- package/dist/Markdown.js +176 -37
- package/dist/MediaTile.d.ts +9 -3
- package/dist/MediaTile.js +8 -4
- package/dist/Menu.d.ts +19 -8
- package/dist/Menu.js +13 -11
- package/dist/MetaList.d.ts +4 -3
- package/dist/MetaList.js +12 -4
- package/dist/Morph.d.ts +15 -1
- package/dist/Morph.js +70 -22
- package/dist/NavigationProgress.d.ts +2 -2
- package/dist/NavigationProgress.js +7 -5
- package/dist/NumberField.d.ts +66 -0
- package/dist/NumberField.js +68 -0
- package/dist/OutlineRegion.d.ts +41 -10
- package/dist/OutlineRegion.js +31 -6
- package/dist/PageFade.d.ts +9 -5
- package/dist/PageFade.js +39 -8
- package/dist/PageLayouts.d.ts +15 -5
- package/dist/PageLayouts.js +3 -3
- package/dist/Pill.d.ts +9 -4
- package/dist/Pill.js +15 -6
- package/dist/Popover.d.ts +31 -0
- package/dist/Popover.js +43 -0
- package/dist/Price.d.ts +21 -0
- package/dist/Price.js +34 -0
- package/dist/ProductTile.d.ts +36 -0
- package/dist/ProductTile.js +31 -0
- package/dist/ProgressBar.js +4 -2
- package/dist/PromoBanner.d.ts +25 -0
- package/dist/PromoBanner.js +16 -0
- package/dist/RadioGroup.d.ts +18 -8
- package/dist/RadioGroup.js +42 -18
- package/dist/ScrollStrip.d.ts +1 -1
- package/dist/ScrollStrip.js +1 -1
- package/dist/SearchInput.d.ts +17 -2
- package/dist/SearchInput.js +72 -13
- package/dist/SegmentedField.d.ts +15 -0
- package/dist/SegmentedField.js +15 -0
- package/dist/Select.js +5 -4
- package/dist/Show.d.ts +1 -1
- package/dist/Show.js +1 -1
- package/dist/SideColumn.d.ts +42 -15
- package/dist/SideColumn.js +45 -19
- package/dist/SiteFooter.d.ts +3 -3
- package/dist/SiteFooter.js +4 -3
- package/dist/SiteSearch.d.ts +57 -27
- package/dist/SiteSearch.js +13 -93
- package/dist/Slider.d.ts +27 -0
- package/dist/Slider.js +58 -0
- package/dist/SortableList.d.ts +19 -35
- package/dist/SortableList.js +36 -88
- package/dist/Stack.d.ts +4 -4
- package/dist/StackedBar.d.ts +13 -4
- package/dist/StackedBar.js +12 -7
- package/dist/StateMachine.d.ts +65 -0
- package/dist/StateMachine.js +113 -0
- package/dist/StatusPages.d.ts +28 -10
- package/dist/StatusPages.js +10 -10
- package/dist/Stepper.d.ts +21 -0
- package/dist/Stepper.js +33 -0
- package/dist/Steps.js +4 -3
- package/dist/Switch.d.ts +3 -3
- package/dist/Switch.js +18 -14
- package/dist/Table.d.ts +32 -9
- package/dist/Table.js +50 -20
- package/dist/TableCells.d.ts +24 -21
- package/dist/TableCells.js +68 -27
- package/dist/TableEditCell.d.ts +1 -1
- package/dist/TableOfContents.d.ts +34 -0
- package/dist/TableOfContents.js +23 -0
- package/dist/Tabs.d.ts +31 -16
- package/dist/Tabs.js +97 -22
- package/dist/TextLink.d.ts +18 -5
- package/dist/TextLink.js +19 -6
- package/dist/Textarea.d.ts +12 -1
- package/dist/Textarea.js +15 -2
- package/dist/ToastRegion.d.ts +17 -9
- package/dist/ToastRegion.js +70 -13
- package/dist/Tooltip.d.ts +10 -2
- package/dist/Tooltip.js +32 -11
- package/dist/Video.d.ts +19 -4
- package/dist/Video.js +15 -5
- package/dist/cardContext.d.ts +7 -0
- package/dist/cardContext.js +14 -0
- package/dist/cardControl.d.ts +15 -0
- package/dist/cardControl.js +32 -0
- package/dist/cardForm.d.ts +39 -0
- package/dist/cardForm.js +81 -0
- package/dist/cardWait.js +2 -1
- package/dist/colourScheme.d.ts +12 -2
- package/dist/colourScheme.js +32 -6
- package/dist/control.d.ts +30 -8
- package/dist/control.js +74 -7
- package/dist/copyScript.d.ts +7 -8
- package/dist/copyScript.js +8 -9
- package/dist/cx.d.ts +22 -3
- package/dist/cx.js +22 -3
- package/dist/dateLocale.d.ts +17 -0
- package/dist/dateLocale.js +30 -0
- package/dist/density.d.ts +15 -1
- package/dist/density.js +27 -8
- package/dist/emptySlot.d.ts +1 -0
- package/dist/fieldAnnounce.d.ts +11 -0
- package/dist/fieldAnnounce.js +36 -0
- package/dist/fieldControl.d.ts +7 -2
- package/dist/fieldControl.js +6 -2
- package/dist/fieldWait.d.ts +3 -3
- package/dist/fieldWait.js +3 -4
- package/dist/flowLayout.d.ts +68 -0
- package/dist/flowLayout.js +105 -0
- package/dist/fromXState.d.ts +73 -0
- package/dist/fromXState.js +110 -0
- package/dist/icons.d.ts +1 -1
- package/dist/icons.js +15 -0
- package/dist/index.d.ts +37 -11
- package/dist/index.js +24 -2
- package/dist/isoDate.d.ts +8 -1
- package/dist/isoDate.js +20 -1
- package/dist/labelWords.d.ts +16 -7
- package/dist/labelWords.js +14 -12
- package/dist/listRowProps.d.ts +17 -15
- package/dist/modal.d.ts +5 -0
- package/dist/modal.js +21 -1
- package/dist/navFold.js +6 -3
- package/dist/optionCard.d.ts +18 -0
- package/dist/optionCard.js +16 -0
- package/dist/scrollBody.d.ts +16 -0
- package/dist/scrollBody.js +15 -0
- package/dist/scrollEdges.d.ts +7 -0
- package/dist/scrollEdges.js +39 -5
- package/dist/scrollStop.d.ts +6 -2
- package/dist/scrollStop.js +24 -8
- package/dist/shownDate.d.ts +28 -10
- package/dist/shownDate.js +41 -22
- package/dist/siteSearchBody.d.ts +34 -0
- package/dist/siteSearchBody.js +117 -0
- package/dist/size.d.ts +7 -1
- package/dist/sortableDrop.d.ts +44 -0
- package/dist/sortableDrop.js +78 -0
- package/dist/sortableSlide.d.ts +9 -0
- package/dist/sortableSlide.js +70 -0
- package/dist/sortableTitle.d.ts +10 -0
- package/dist/sortableTitle.js +48 -0
- package/dist/stateMachineDots.d.ts +45 -0
- package/dist/stateMachineDots.js +162 -0
- package/dist/stickyColumn.d.ts +2 -2
- package/dist/stickyColumn.js +2 -2
- package/dist/switcher.d.ts +10 -5
- package/dist/switcher.js +7 -5
- package/dist/tableColumns.d.ts +17 -0
- package/dist/tableColumns.js +30 -2
- package/dist/tableEmpty.js +5 -5
- package/dist/tableRow.d.ts +26 -2
- package/dist/tableRow.js +23 -1
- package/dist/tableSort.d.ts +10 -5
- package/dist/tableSort.js +15 -4
- package/dist/target.d.ts +12 -0
- package/dist/target.js +12 -0
- package/dist/textBox.js +1 -1
- package/dist/truncated.d.ts +31 -0
- package/dist/truncated.js +51 -0
- package/dist/typography.d.ts +19 -11
- package/dist/typography.js +11 -13
- package/dist/useFlowLayout.d.ts +27 -0
- package/dist/useFlowLayout.js +119 -0
- package/package.json +7 -3
- package/skills/uislash/SKILL.md +20 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DropTarget, Key } from "react-aria-components";
|
|
2
|
+
/** A move the user made: which item, the section it lands in, and the item it lands next to. */
|
|
3
|
+
export type SortableMove = {
|
|
4
|
+
/** The `id` of the item that moved. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** The `id` of the `SortableSection` the item lands in. Set whenever the list has sections. */
|
|
7
|
+
section?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The item it was dropped before or after. Absent only for a drop into an empty section, where
|
|
10
|
+
* there is no item to land next to.
|
|
11
|
+
*/
|
|
12
|
+
target?: {
|
|
13
|
+
id: string;
|
|
14
|
+
position: "before" | "after";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/** A marker on every row a pointer can drop next to: the items and each section's tail row. */
|
|
18
|
+
export declare const ROW_MARK = "data-sortable-row";
|
|
19
|
+
/**
|
|
20
|
+
* The key of a section's tail row. Every section ends with one: in an empty section it is the "Drop
|
|
21
|
+
* here" row, in one with items it is an empty row of no height. A drop before it is a drop at the
|
|
22
|
+
* end of the section. react-aria's keyboard drop moves cannot step from "after the last item" of a
|
|
23
|
+
* section into the next one (it wraps to the top), but they do step from "before" a row to "before"
|
|
24
|
+
* the next row across sections, so with a tail row the end of each section is a "before" target.
|
|
25
|
+
*/
|
|
26
|
+
export declare function tailKey(section: string): string;
|
|
27
|
+
/** A row's section and title; a tail row also lists its section's items, in order. */
|
|
28
|
+
export type Place = {
|
|
29
|
+
section?: string;
|
|
30
|
+
title: string;
|
|
31
|
+
tail?: string[];
|
|
32
|
+
};
|
|
33
|
+
/** react-aria's pointer drop delegate, aware of sections (the stock one sees only top-level items). */
|
|
34
|
+
export declare function sectionDelegate(listId: string): {
|
|
35
|
+
getDropTargetFromPoint: (_x: number, y: number) => DropTarget | null;
|
|
36
|
+
};
|
|
37
|
+
/** Only a drop between two rows is a move; a drop on a row's centre, or on the list itself, is not. */
|
|
38
|
+
export declare function dropOperation(target: DropTarget): "move" | "cancel";
|
|
39
|
+
/**
|
|
40
|
+
* The move react-aria reported, as the app's `SortableMove`, or nothing when it is not one (a drop
|
|
41
|
+
* on a row's centre, or next to the item itself). A drop at a section's tail lands after the
|
|
42
|
+
* section's last other item, or with no target when it has none.
|
|
43
|
+
*/
|
|
44
|
+
export declare function moveOf(places: Map<string, Place>, keys: Iterable<Key>, target: DropTarget): SortableMove | null;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** A marker on every row a pointer can drop next to: the items and each section's tail row. */
|
|
2
|
+
export const ROW_MARK = "data-sortable-row";
|
|
3
|
+
/**
|
|
4
|
+
* The key of a section's tail row. Every section ends with one: in an empty section it is the "Drop
|
|
5
|
+
* here" row, in one with items it is an empty row of no height. A drop before it is a drop at the
|
|
6
|
+
* end of the section. react-aria's keyboard drop moves cannot step from "after the last item" of a
|
|
7
|
+
* section into the next one (it wraps to the top), but they do step from "before" a row to "before"
|
|
8
|
+
* the next row across sections, so with a tail row the end of each section is a "before" target.
|
|
9
|
+
*/
|
|
10
|
+
export function tailKey(section) {
|
|
11
|
+
return `hackcove-sortable-end:${section}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Where a pointer drops: before or after the row it is over, by which half it is in. Over a section
|
|
15
|
+
* heading, or in a gap, it is before the next row below (the first item of that section, or its
|
|
16
|
+
* "Drop here" row), and below every row it is after the last. Never "on" a row.
|
|
17
|
+
*/
|
|
18
|
+
function dropTargetAt(list, y) {
|
|
19
|
+
if (!list)
|
|
20
|
+
return null;
|
|
21
|
+
const top = y + list.getBoundingClientRect().top;
|
|
22
|
+
const rows = [...list.querySelectorAll(`[${ROW_MARK}]`)];
|
|
23
|
+
for (const row of rows) {
|
|
24
|
+
const key = row.dataset.key;
|
|
25
|
+
if (key == null)
|
|
26
|
+
continue;
|
|
27
|
+
const box = row.getBoundingClientRect();
|
|
28
|
+
if (top < box.top)
|
|
29
|
+
return { type: "item", key, dropPosition: "before" };
|
|
30
|
+
if (top <= box.bottom) {
|
|
31
|
+
return {
|
|
32
|
+
type: "item",
|
|
33
|
+
key,
|
|
34
|
+
dropPosition: top < box.top + box.height / 2 ? "before" : "after",
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const last = rows.at(-1)?.dataset.key;
|
|
39
|
+
return last == null ? null : { type: "item", key: last, dropPosition: "after" };
|
|
40
|
+
}
|
|
41
|
+
/** react-aria's pointer drop delegate, aware of sections (the stock one sees only top-level items). */
|
|
42
|
+
export function sectionDelegate(listId) {
|
|
43
|
+
return {
|
|
44
|
+
getDropTargetFromPoint: (_x, y) => dropTargetAt(document.getElementById(listId), y),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Only a drop between two rows is a move; a drop on a row's centre, or on the list itself, is not. */
|
|
48
|
+
export function dropOperation(target) {
|
|
49
|
+
return target.type === "item" && target.dropPosition !== "on" ? "move" : "cancel";
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The move react-aria reported, as the app's `SortableMove`, or nothing when it is not one (a drop
|
|
53
|
+
* on a row's centre, or next to the item itself). A drop at a section's tail lands after the
|
|
54
|
+
* section's last other item, or with no target when it has none.
|
|
55
|
+
*/
|
|
56
|
+
export function moveOf(places, keys, target) {
|
|
57
|
+
const [key] = keys;
|
|
58
|
+
if (key == null || target.type !== "item" || target.dropPosition === "on")
|
|
59
|
+
return null;
|
|
60
|
+
const place = places.get(String(target.key));
|
|
61
|
+
if (!place)
|
|
62
|
+
return null;
|
|
63
|
+
const id = String(key);
|
|
64
|
+
if (String(target.key) === id)
|
|
65
|
+
return null;
|
|
66
|
+
const section = place.section === undefined ? {} : { section: place.section };
|
|
67
|
+
if (place.tail) {
|
|
68
|
+
const last = place.tail.filter((item) => item !== id).at(-1);
|
|
69
|
+
return last === undefined
|
|
70
|
+
? { id, ...section }
|
|
71
|
+
: { id, ...section, target: { id: last, position: "after" } };
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
id,
|
|
75
|
+
...section,
|
|
76
|
+
target: { id: String(target.key), position: target.dropPosition },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* After the app applies a move, every row (an element carrying `mark`) that changed place slides
|
|
3
|
+
* from where it was to where it is (a FLIP step through the Web Animations API), so the eye can
|
|
4
|
+
* follow the move. The list records where its rows are each time the app renders it; react-aria
|
|
5
|
+
* then puts the rows in their new order in a later commit, and an observer slides them before the
|
|
6
|
+
* next paint. Only a change of order slides anything (a drop indicator coming and going does not),
|
|
7
|
+
* and nothing slides under `prefers-reduced-motion` or on a first render.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useSlide(listId: string, mark: string): void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
2
|
+
// How a `SortableList` row slides to its new place after a move.
|
|
3
|
+
/** How long a row takes to slide to its new place after a move. */
|
|
4
|
+
const SLIDE = { duration: 200, easing: "ease-out" };
|
|
5
|
+
/** The rows' keys in order, read without measuring anything. */
|
|
6
|
+
function orderOf(list, mark) {
|
|
7
|
+
return [...list.querySelectorAll(`[${mark}][data-key]`)]
|
|
8
|
+
.map((row) => row.dataset.key ?? "")
|
|
9
|
+
.join("\n");
|
|
10
|
+
}
|
|
11
|
+
function places(list, mark) {
|
|
12
|
+
const top = list.getBoundingClientRect().top;
|
|
13
|
+
const tops = new Map();
|
|
14
|
+
for (const row of list.querySelectorAll(`[${mark}][data-key]`)) {
|
|
15
|
+
const key = row.dataset.key ?? "";
|
|
16
|
+
tops.set(key, row.getBoundingClientRect().top - top);
|
|
17
|
+
}
|
|
18
|
+
return { order: [...tops.keys()].join("\n"), tops };
|
|
19
|
+
}
|
|
20
|
+
/** Whether rows may slide: only where the Web Animations API is, and not under `prefers-reduced-motion`. */
|
|
21
|
+
function maySlide(list) {
|
|
22
|
+
if (typeof list.animate !== "function")
|
|
23
|
+
return false;
|
|
24
|
+
return !window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
25
|
+
}
|
|
26
|
+
/** Slides each row that moved from where it was (`before`) to where it is (`after`). */
|
|
27
|
+
function slide(list, mark, before, after) {
|
|
28
|
+
for (const row of list.querySelectorAll(`[${mark}][data-key]`)) {
|
|
29
|
+
const key = row.dataset.key ?? "";
|
|
30
|
+
const was = before.tops.get(key);
|
|
31
|
+
const now = after.tops.get(key);
|
|
32
|
+
if (was === undefined || now === undefined || was === now)
|
|
33
|
+
continue;
|
|
34
|
+
row.animate([{ translate: `0 ${was - now}px` }, { translate: "0 0" }], SLIDE);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* After the app applies a move, every row (an element carrying `mark`) that changed place slides
|
|
39
|
+
* from where it was to where it is (a FLIP step through the Web Animations API), so the eye can
|
|
40
|
+
* follow the move. The list records where its rows are each time the app renders it; react-aria
|
|
41
|
+
* then puts the rows in their new order in a later commit, and an observer slides them before the
|
|
42
|
+
* next paint. Only a change of order slides anything (a drop indicator coming and going does not),
|
|
43
|
+
* and nothing slides under `prefers-reduced-motion` or on a first render.
|
|
44
|
+
*/
|
|
45
|
+
export function useSlide(listId, mark) {
|
|
46
|
+
const last = useRef(null);
|
|
47
|
+
// Each render of the list: where the rows are before its new order lands.
|
|
48
|
+
useLayoutEffect(() => {
|
|
49
|
+
const list = document.getElementById(listId);
|
|
50
|
+
if (list)
|
|
51
|
+
last.current = places(list, mark);
|
|
52
|
+
});
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const list = document.getElementById(listId);
|
|
55
|
+
if (!list || typeof MutationObserver !== "function")
|
|
56
|
+
return undefined;
|
|
57
|
+
const observer = new MutationObserver(() => {
|
|
58
|
+
const before = last.current;
|
|
59
|
+
// A drop indicator coming and going changes no order: leave it without measuring a row.
|
|
60
|
+
if (before?.order === orderOf(list, mark))
|
|
61
|
+
return;
|
|
62
|
+
const after = places(list, mark);
|
|
63
|
+
last.current = after;
|
|
64
|
+
if (before && maySlide(list))
|
|
65
|
+
slide(list, mark, before, after);
|
|
66
|
+
});
|
|
67
|
+
observer.observe(list, { childList: true, subtree: true });
|
|
68
|
+
return () => observer.disconnect();
|
|
69
|
+
}, [listId, mark]);
|
|
70
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A `SortableItem`'s one-line title. Cut, it shows in full in a tooltip: on the pointer over it, a
|
|
4
|
+
* tap, or the keyboard's focus on the row or its handle. react-aria renders an item's own hooks
|
|
5
|
+
* outside the page, so the title is its own part, and it listens for focus on the row it lands in.
|
|
6
|
+
* Internal.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ItemTitle({ title }: {
|
|
9
|
+
title: string;
|
|
10
|
+
}): ReactElement;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useTooltip } from "./Tooltip.js";
|
|
4
|
+
import { useCut } from "./truncated.js";
|
|
5
|
+
/** Whether the element has the focus ring's focus (the keyboard's); a browser without `:focus-visible` counts every focus. */
|
|
6
|
+
function ringed(target) {
|
|
7
|
+
if (!(target instanceof Element))
|
|
8
|
+
return false;
|
|
9
|
+
try {
|
|
10
|
+
return target.matches(":focus-visible");
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A `SortableItem`'s one-line title. Cut, it shows in full in a tooltip: on the pointer over it, a
|
|
18
|
+
* tap, or the keyboard's focus on the row or its handle. react-aria renders an item's own hooks
|
|
19
|
+
* outside the page, so the title is its own part, and it listens for focus on the row it lands in.
|
|
20
|
+
* Internal.
|
|
21
|
+
*/
|
|
22
|
+
export function ItemTitle({ title }) {
|
|
23
|
+
const line = useRef(null);
|
|
24
|
+
const [focused, setFocused] = useState(false);
|
|
25
|
+
const { cut } = useCut(line, title);
|
|
26
|
+
const { props: tip, tooltip } = useTooltip(cut ? title : undefined, { describes: false, tap: true, focused }, {});
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const row = line.current?.closest('[role="row"]');
|
|
29
|
+
if (!row)
|
|
30
|
+
return undefined;
|
|
31
|
+
const focus = (event) => setFocused(ringed(event.target));
|
|
32
|
+
const blur = () => setFocused(false);
|
|
33
|
+
// Dismissed where it stands (WCAG 1.4.13); the key goes on to the list.
|
|
34
|
+
const key = (event) => {
|
|
35
|
+
if (event.key === "Escape")
|
|
36
|
+
setFocused(false);
|
|
37
|
+
};
|
|
38
|
+
row.addEventListener("focusin", focus);
|
|
39
|
+
row.addEventListener("focusout", blur);
|
|
40
|
+
row.addEventListener("keydown", key);
|
|
41
|
+
return () => {
|
|
42
|
+
row.removeEventListener("focusin", focus);
|
|
43
|
+
row.removeEventListener("focusout", blur);
|
|
44
|
+
row.removeEventListener("keydown", key);
|
|
45
|
+
};
|
|
46
|
+
}, []);
|
|
47
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { ref: line, className: "truncate", style: tip.style, onPointerEnter: tip.onPointerEnter, onPointerLeave: tip.onPointerLeave, onPointerDown: tip.onPointerDown, title: tip.title, children: title }), tooltip] }));
|
|
48
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import type { FlowLayout } from "./flowLayout.js";
|
|
3
|
+
import type { StateMachineItem } from "./StateMachine.js";
|
|
4
|
+
/**
|
|
5
|
+
* The box items whose `state` is no state of the machine go in. Printable, since it reaches the DOM
|
|
6
|
+
* (a box's `data-measure`), where a server render would turn a control character into U+FFFD.
|
|
7
|
+
*/
|
|
8
|
+
export declare const UNPLACED = "hc-sm:unplaced";
|
|
9
|
+
/** A dot's slot in its box: three to a row, each wide enough for a short ref. */
|
|
10
|
+
export declare const SLOT_W = 76;
|
|
11
|
+
export declare const SLOT_H = 22;
|
|
12
|
+
export declare const COLS = 3;
|
|
13
|
+
/** An item on its way from one state to another; `seq` restarts the run when it moves again. */
|
|
14
|
+
type Move = {
|
|
15
|
+
from: string;
|
|
16
|
+
to: string;
|
|
17
|
+
seq: number;
|
|
18
|
+
};
|
|
19
|
+
/** Which box each item sits in: its state's, else the unplaced box. */
|
|
20
|
+
export declare function placeOf(items: readonly StateMachineItem[], known: ReadonlySet<string>): Map<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* Remembers where every item was, and when one's place changes records the move, during render
|
|
23
|
+
* (React's "adjust state when a prop changes"), so the re-render that measures the boxes does not
|
|
24
|
+
* lose it. A move ends on its run's `animationend` (`done`), at the next change of places (which
|
|
25
|
+
* records only its own moves), or on `clear` (a box opened, which would start a run long over).
|
|
26
|
+
*/
|
|
27
|
+
export declare function useMoves(items: readonly StateMachineItem[], known: ReadonlySet<string>): {
|
|
28
|
+
moves: ReadonlyMap<string, Move>;
|
|
29
|
+
done: (id: string, seq: number) => void;
|
|
30
|
+
clear: () => void;
|
|
31
|
+
};
|
|
32
|
+
/** How many slots a box with `count` items draws: all of them, or the first few and a `+N`; one more for "fewer" when open. */
|
|
33
|
+
export declare function slotsFor(count: number, open: boolean): number;
|
|
34
|
+
/** What the dot layer draws from: the items in each box, the boxes' names, which boxes are open, and the moves. */
|
|
35
|
+
type DotPlaces = {
|
|
36
|
+
inBox: ReadonlyMap<string, readonly StateMachineItem[]>;
|
|
37
|
+
names: ReadonlyMap<string, string>;
|
|
38
|
+
open: ReadonlySet<string>;
|
|
39
|
+
toggle: (id: string) => void;
|
|
40
|
+
moves: ReadonlyMap<string, Move>;
|
|
41
|
+
done: (id: string, seq: number) => void;
|
|
42
|
+
};
|
|
43
|
+
/** Every box's dots, over the drawn diagram. */
|
|
44
|
+
export declare function dotLayer(layout: FlowLayout, places: DotPlaces): ReactElement;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { cx, focusRing } from "./cx.js";
|
|
4
|
+
import { renderLink } from "./link.js";
|
|
5
|
+
import { VIZ_TONE } from "./StackedBar.js";
|
|
6
|
+
import { useTooltip } from "./Tooltip.js";
|
|
7
|
+
/**
|
|
8
|
+
* The box items whose `state` is no state of the machine go in. Printable, since it reaches the DOM
|
|
9
|
+
* (a box's `data-measure`), where a server render would turn a control character into U+FFFD.
|
|
10
|
+
*/
|
|
11
|
+
export const UNPLACED = "hc-sm:unplaced";
|
|
12
|
+
/** A dot's slot in its box: three to a row, each wide enough for a short ref. */
|
|
13
|
+
export const SLOT_W = 76;
|
|
14
|
+
export const SLOT_H = 22;
|
|
15
|
+
export const COLS = 3;
|
|
16
|
+
/** Up to this many dots show in a box; past it, one fewer and a `+N` that shows the rest. */
|
|
17
|
+
const LIMIT = 9;
|
|
18
|
+
/** From a box's bottom edge to its dots' bottom: its border and its bottom padding. */
|
|
19
|
+
const BOX_INSET = 9;
|
|
20
|
+
/** From a slot's left edge to its dot's centre: the chip's inset, its padding and half the dot. */
|
|
21
|
+
const DOT_X = 2 + 4 + 5;
|
|
22
|
+
const CATEGORIES = [
|
|
23
|
+
"cat1",
|
|
24
|
+
"cat2",
|
|
25
|
+
"cat3",
|
|
26
|
+
"cat4",
|
|
27
|
+
"cat5",
|
|
28
|
+
"cat6",
|
|
29
|
+
"cat7",
|
|
30
|
+
"cat8",
|
|
31
|
+
];
|
|
32
|
+
/** An item's colour, the same for its id wherever it is drawn. */
|
|
33
|
+
function colourOf(id) {
|
|
34
|
+
let sum = 0;
|
|
35
|
+
for (const ch of id)
|
|
36
|
+
sum = (sum * 31 + (ch.codePointAt(0) ?? 0)) % 997;
|
|
37
|
+
return VIZ_TONE[CATEGORIES[sum % CATEGORIES.length] ?? "cat1"];
|
|
38
|
+
}
|
|
39
|
+
// The move is CSS: a dot runs along the arrow's path (`offset-path`) in 600ms while the dot at
|
|
40
|
+
// its new place waits hidden for the same time. Nothing is timed in script: the run ends on its
|
|
41
|
+
// own `animationend`. With reduced motion the run is hidden and over at once (so it still ends),
|
|
42
|
+
// and the dot is in its new place at once.
|
|
43
|
+
const css = `[data-hc-sm-travel]{offset-anchor:center;offset-rotate:0deg;animation:hc-sm-travel .6s ease-in-out forwards}[data-hc-sm-arrive]{animation:hc-sm-arrive .6s linear}@keyframes hc-sm-travel{from{offset-distance:0%}to{offset-distance:100%}}@keyframes hc-sm-arrive{from,to{visibility:hidden}}@media (prefers-reduced-motion:reduce){[data-hc-sm-travel]{visibility:hidden;animation-duration:1ms}[data-hc-sm-arrive]{animation:none}}`;
|
|
44
|
+
/** Which box each item sits in: its state's, else the unplaced box. */
|
|
45
|
+
export function placeOf(items, known) {
|
|
46
|
+
return new Map(items.map((i) => [i.id, known.has(i.state) ? i.state : UNPLACED]));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Remembers where every item was, and when one's place changes records the move, during render
|
|
50
|
+
* (React's "adjust state when a prop changes"), so the re-render that measures the boxes does not
|
|
51
|
+
* lose it. A move ends on its run's `animationend` (`done`), at the next change of places (which
|
|
52
|
+
* records only its own moves), or on `clear` (a box opened, which would start a run long over).
|
|
53
|
+
*/
|
|
54
|
+
export function useMoves(items, known) {
|
|
55
|
+
const now = placeOf(items, known);
|
|
56
|
+
const key = JSON.stringify([...now]);
|
|
57
|
+
const [seen, setSeen] = useState({ key, places: now });
|
|
58
|
+
const [moves, setMoves] = useState(new Map());
|
|
59
|
+
// Compared by value: a caller's `items` is often a new array on every render.
|
|
60
|
+
if (seen.key !== key) {
|
|
61
|
+
const next = new Map();
|
|
62
|
+
for (const [id, to] of now) {
|
|
63
|
+
const from = seen.places.get(id);
|
|
64
|
+
if (from !== undefined && from !== to) {
|
|
65
|
+
next.set(id, { from, to, seq: (moves.get(id)?.seq ?? 0) + 1 });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
setSeen({ key, places: now });
|
|
69
|
+
setMoves(next);
|
|
70
|
+
}
|
|
71
|
+
const done = (id, seq) => setMoves((current) => {
|
|
72
|
+
if (current.get(id)?.seq !== seq)
|
|
73
|
+
return current;
|
|
74
|
+
const next = new Map(current);
|
|
75
|
+
next.delete(id);
|
|
76
|
+
return next;
|
|
77
|
+
});
|
|
78
|
+
return { moves, done, clear: () => setMoves(new Map()) };
|
|
79
|
+
}
|
|
80
|
+
/** How many slots a box with `count` items draws: all of them, or the first few and a `+N`; one more for "fewer" when open. */
|
|
81
|
+
export function slotsFor(count, open) {
|
|
82
|
+
if (count <= LIMIT)
|
|
83
|
+
return count;
|
|
84
|
+
return open ? count + 1 : LIMIT;
|
|
85
|
+
}
|
|
86
|
+
/** Where slot `i` of `slots` sits in `box`: its left edge and its vertical centre. */
|
|
87
|
+
function slotAt(box, i, slots) {
|
|
88
|
+
const cols = Math.min(COLS, slots);
|
|
89
|
+
const rows = Math.ceil(slots / COLS);
|
|
90
|
+
const top = box.y + box.height - BOX_INSET - rows * SLOT_H;
|
|
91
|
+
return {
|
|
92
|
+
left: box.x + box.width / 2 - (cols * SLOT_W) / 2 + (i % COLS) * SLOT_W,
|
|
93
|
+
y: top + Math.floor(i / COLS) * SLOT_H + SLOT_H / 2,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** One dot: its colour, its short ref, its full label as name and tooltip, a link when it has `href`. */
|
|
97
|
+
function Dot({ item, where, left, y, arriving, }) {
|
|
98
|
+
const { props, tooltip } = useTooltip(item.label, { describes: false, tap: item.href === undefined }, {});
|
|
99
|
+
const className = cx("pointer-events-auto absolute flex h-5 items-center gap-1 rounded px-1 text-xs text-slate-700", focusRing);
|
|
100
|
+
const position = { ...props.style, left: left + 2, top: y - 10, width: SLOT_W - 4 };
|
|
101
|
+
const body = (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", className: cx("size-2.5 shrink-0 rounded-full bg-current", colourOf(item.id)) }), _jsx("span", { "aria-hidden": "true", className: "truncate", children: item.id })] }));
|
|
102
|
+
const own = {
|
|
103
|
+
...props,
|
|
104
|
+
style: position,
|
|
105
|
+
"aria-label": `${item.label}, in ${where}`,
|
|
106
|
+
...(arriving ? { "data-hc-sm-arrive": "" } : {}),
|
|
107
|
+
};
|
|
108
|
+
return (_jsxs(_Fragment, { children: [item.href === undefined ? (_jsx("span", { ...own, role: "img", tabIndex: 0, className: className, children: body })) : (renderLink({
|
|
109
|
+
...own,
|
|
110
|
+
href: item.href,
|
|
111
|
+
className: cx(className, "hover:underline"),
|
|
112
|
+
children: body,
|
|
113
|
+
})), tooltip] }));
|
|
114
|
+
}
|
|
115
|
+
/** The dot that runs from an item's old box to its new one: along the arrow between them, else straight. */
|
|
116
|
+
function Travel({ item, move, drawn, to, done, }) {
|
|
117
|
+
const from = drawn.nodes.find((n) => n.id === move.from);
|
|
118
|
+
if (!from)
|
|
119
|
+
return null;
|
|
120
|
+
const start = slotAt(from, 0, 1);
|
|
121
|
+
const x0 = start.left + DOT_X;
|
|
122
|
+
const edge = drawn.edges.find((e) => e.from === move.from && e.to === move.to);
|
|
123
|
+
const via = edge ? ` L${edge.path.slice(1)}` : "";
|
|
124
|
+
const d = `M${x0},${start.y}${via} L${to.x},${to.y}`;
|
|
125
|
+
return (_jsx("span", { "aria-hidden": "true", "data-hc-sm-travel": "", onAnimationEnd: done, className: cx("absolute left-0 top-0 size-2.5 rounded-full bg-current", colourOf(item.id)), style: { offsetPath: `path("${d}")` } }));
|
|
126
|
+
}
|
|
127
|
+
/** The `+N` (or "fewer") switch in a full box's last slot. */
|
|
128
|
+
function MoreToggle({ hidden, open, where, left, y, toggle, }) {
|
|
129
|
+
return (_jsx("button", { type: "button", "aria-expanded": open, "aria-label": open ? `Show fewer in ${where}` : `Show ${hidden} more in ${where}`, onClick: toggle, className: cx("pointer-events-auto absolute flex h-5 cursor-pointer items-center rounded px-1 text-xs font-medium text-violet-600 hover:text-violet-700", focusRing), style: { left: left + 2, top: y - 10 }, children: open ? "fewer" : `+${hidden}` }));
|
|
130
|
+
}
|
|
131
|
+
/** One item's dot in `box`, and its run there when it has just moved in. */
|
|
132
|
+
function placeDot(item, at, box, places) {
|
|
133
|
+
const move = places.moves.get(item.id);
|
|
134
|
+
// A run needs the box it leaves; with that box gone (the last unplaced item placed) it just lands.
|
|
135
|
+
const arriving = move?.to === box.id && places.layout.nodes.some((n) => n.id === move.from);
|
|
136
|
+
const dot = (_jsx(Dot, { item: item, where: places.names.get(box.id) ?? box.id, left: at.left, y: at.y, arriving: arriving }, `${item.id}:${box.id}`));
|
|
137
|
+
if (!move || !arriving)
|
|
138
|
+
return [dot];
|
|
139
|
+
return [
|
|
140
|
+
dot,
|
|
141
|
+
_jsx(Travel, { item: item, move: move, drawn: places.layout, to: { x: at.left + DOT_X, y: at.y }, done: () => places.done(item.id, move.seq) }, `${item.id}:${move.seq}`),
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
/** A box's dots: every item, or the first few and the `+N` that shows the rest. */
|
|
145
|
+
function boxDots(box, places) {
|
|
146
|
+
const here = places.inBox.get(box.id) ?? [];
|
|
147
|
+
const open = places.open.has(box.id);
|
|
148
|
+
const count = slotsFor(here.length, open);
|
|
149
|
+
const shown = here.length <= LIMIT || open ? here : here.slice(0, LIMIT - 1);
|
|
150
|
+
const dots = shown.flatMap((item, i) => placeDot(item, slotAt(box, i, count), box, places));
|
|
151
|
+
if (here.length <= LIMIT)
|
|
152
|
+
return dots;
|
|
153
|
+
const at = slotAt(box, count - 1, count);
|
|
154
|
+
return [
|
|
155
|
+
...dots,
|
|
156
|
+
_jsx(MoreToggle, { hidden: here.length - shown.length, open: open, where: places.names.get(box.id) ?? box.id, left: at.left, y: at.y, toggle: () => places.toggle(box.id) }, `more:${box.id}`),
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
/** Every box's dots, over the drawn diagram. */
|
|
160
|
+
export function dotLayer(layout, places) {
|
|
161
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { children: css }), layout.nodes.flatMap((box) => boxDots(box, { ...places, layout }))] }));
|
|
162
|
+
}
|
package/dist/stickyColumn.d.ts
CHANGED
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
export declare const STICKY_ASIDE_MD = "md:sticky md:top-[var(--app-header,0px)] md:self-start";
|
|
15
15
|
export declare const STICKY_SCROLL_MD = "md:-m-1 md:max-h-[calc(100dvh-var(--app-header,0px)-2rem)] md:overflow-y-auto md:p-1";
|
|
16
16
|
/**
|
|
17
|
-
* The
|
|
17
|
+
* The themed scrollbar (`themedScrollbar` in `cx.ts`) on a rail's scroller from `md`, where it
|
|
18
18
|
* scrolls, instead of the heavy native one with arrow buttons. Its thumb is the scroller's own text
|
|
19
19
|
* colour, so the rail's real ink goes back on an inner box (`STICKY_INK_MD`), the colour the shell
|
|
20
20
|
* gives every page.
|
|
21
21
|
*/
|
|
22
|
-
export declare const STICKY_BAR_MD = "md:text-slate-400 md:[scrollbar-
|
|
22
|
+
export declare const STICKY_BAR_MD = "md:text-slate-400 md:[scrollbar-color:currentColor_transparent]";
|
|
23
23
|
export declare const STICKY_INK_MD = "md:text-slate-900";
|
|
24
24
|
export declare const STICKY_ASIDE_LG = "lg:sticky lg:top-[var(--app-header,0px)] lg:self-start";
|
|
25
25
|
export declare const STICKY_SCROLL_LG = "lg:-m-1 lg:max-h-[calc(100dvh-var(--app-header,0px)-2rem)] lg:overflow-y-auto lg:p-1";
|
package/dist/stickyColumn.js
CHANGED
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
export const STICKY_ASIDE_MD = "md:sticky md:top-[var(--app-header,0px)] md:self-start";
|
|
15
15
|
export const STICKY_SCROLL_MD = "md:-m-1 md:max-h-[calc(100dvh-var(--app-header,0px)-2rem)] md:overflow-y-auto md:p-1";
|
|
16
16
|
/**
|
|
17
|
-
* The
|
|
17
|
+
* The themed scrollbar (`themedScrollbar` in `cx.ts`) on a rail's scroller from `md`, where it
|
|
18
18
|
* scrolls, instead of the heavy native one with arrow buttons. Its thumb is the scroller's own text
|
|
19
19
|
* colour, so the rail's real ink goes back on an inner box (`STICKY_INK_MD`), the colour the shell
|
|
20
20
|
* gives every page.
|
|
21
21
|
*/
|
|
22
|
-
export const STICKY_BAR_MD = "md:text-slate-400 md:[scrollbar-
|
|
22
|
+
export const STICKY_BAR_MD = "md:text-slate-400 md:[scrollbar-color:currentColor_transparent]";
|
|
23
23
|
export const STICKY_INK_MD = "md:text-slate-900";
|
|
24
24
|
export const STICKY_ASIDE_LG = "lg:sticky lg:top-[var(--app-header,0px)] lg:self-start";
|
|
25
25
|
export const STICKY_SCROLL_LG = "lg:-m-1 lg:max-h-[calc(100dvh-var(--app-header,0px)-2rem)] lg:overflow-y-auto lg:p-1";
|
package/dist/switcher.d.ts
CHANGED
|
@@ -26,8 +26,6 @@ export type SwitchButton = Option & {
|
|
|
26
26
|
* keyboard focus and a tap, read out as its description.
|
|
27
27
|
*/
|
|
28
28
|
disabledReason?: string;
|
|
29
|
-
/** The id of the element this option controls (a tab's panel). */
|
|
30
|
-
controls?: string;
|
|
31
29
|
href?: undefined;
|
|
32
30
|
external?: undefined;
|
|
33
31
|
};
|
|
@@ -43,7 +41,6 @@ export type SwitchLink = Option & {
|
|
|
43
41
|
selected?: boolean;
|
|
44
42
|
disabled?: undefined;
|
|
45
43
|
disabledReason?: undefined;
|
|
46
|
-
controls?: undefined;
|
|
47
44
|
external?: boolean;
|
|
48
45
|
/** Where the option links. */
|
|
49
46
|
href: string;
|
|
@@ -54,9 +51,10 @@ type Shared = {
|
|
|
54
51
|
/** The accessible name of the group. */
|
|
55
52
|
label: string;
|
|
56
53
|
} & Passthrough;
|
|
57
|
-
|
|
54
|
+
/** A group's props; `Button` is its button option (Tabs adds a `panel` to it). */
|
|
55
|
+
export type SwitchProps<Button extends SwitchButton = SwitchButton> = Shared & ({
|
|
58
56
|
/** The options in order: `{ value, label }` buttons, or links (`href`), the current link marked by its `selected` or by a `value` equal to the group's. Either may carry a `count`; a button may be `disabled`. */
|
|
59
|
-
items:
|
|
57
|
+
items: Button[];
|
|
60
58
|
/** The `value` of the current option; for links, an alternative to `selected` on the item. */
|
|
61
59
|
value: string;
|
|
62
60
|
/** Called with the option's `value` when one is chosen, by click or arrow key. */
|
|
@@ -81,6 +79,13 @@ type Parts = {
|
|
|
81
79
|
stacked?: boolean;
|
|
82
80
|
root: string;
|
|
83
81
|
option: (active: boolean, disabled: boolean) => string;
|
|
82
|
+
/** Handed the group's root element (the box that scrolls, for a Tabs row). */
|
|
83
|
+
onRoot?: (root: HTMLElement | null) => void;
|
|
84
|
+
/** A button option's own id and the id of the panel it controls (`aria-controls`), by index; none for an option with no panel. */
|
|
85
|
+
ids?: (index: number) => {
|
|
86
|
+
tab: string;
|
|
87
|
+
panel: string;
|
|
88
|
+
} | undefined;
|
|
84
89
|
};
|
|
85
90
|
/**
|
|
86
91
|
* The shared body of Tabs and SegmentedControl: a row of options with one current. Buttons form a
|
package/dist/switcher.js
CHANGED
|
@@ -22,6 +22,8 @@ function Label({ item }) {
|
|
|
22
22
|
return _jsx(_Fragment, { children: item.label });
|
|
23
23
|
return (_jsxs(_Fragment, { children: [item.label, " ", _jsx("span", { className: "ml-0.5 text-xs tabular-nums opacity-70", children: item.count })] }));
|
|
24
24
|
}
|
|
25
|
+
/** A tab's own id and `aria-controls`, when it has a panel. */
|
|
26
|
+
const ariaIds = (ids) => ids ? { id: ids.tab, "aria-controls": ids.panel } : {};
|
|
25
27
|
const isLinks = (items) => items.some((item) => item.href !== undefined);
|
|
26
28
|
const isCurrent = (item, value) => item.selected === true || (item.value !== undefined && item.value === value);
|
|
27
29
|
function SwitchLinkItem({ item, current, parts, }) {
|
|
@@ -60,19 +62,19 @@ function moveByArrows(event, vertical) {
|
|
|
60
62
|
* chooses); links form a `<nav>` with `aria-current="page"` on the current one.
|
|
61
63
|
*/
|
|
62
64
|
export function Switcher({ items, value, onChange, disabled: groupDisabled, label, parts, ...rest }) {
|
|
63
|
-
const root = parts
|
|
65
|
+
const { root, onRoot } = parts;
|
|
64
66
|
if (isLinks(items)) {
|
|
65
|
-
return (_jsx("nav", { ...rest, "aria-label": label, className: root, children: items.map((item, index) => (_jsx(SwitchLinkItem, { item: item, current: isCurrent(item, value), parts: parts }, item.value ?? item.href ?? index))) }));
|
|
67
|
+
return (_jsx("nav", { ...rest, ref: onRoot, "aria-label": label, className: root, children: items.map((item, index) => (_jsx(SwitchLinkItem, { item: item, current: isCurrent(item, value), parts: parts }, item.value ?? item.href ?? index))) }));
|
|
66
68
|
}
|
|
67
69
|
const off = (item) => groupDisabled === true || item.disabled === true || hasReason(item.disabledReason);
|
|
68
70
|
// An option with a reason stays reachable by the arrow keys, so the keyboard finds out why.
|
|
69
71
|
const reasoned = (item) => groupDisabled !== true && hasReason(item.disabledReason);
|
|
70
72
|
const enabled = items.filter((item) => !off(item));
|
|
71
73
|
const stop = enabled.some((item) => item.value === value) ? value : enabled[0]?.value;
|
|
72
|
-
return (_jsx("div", { ...rest, role: parts.group, "aria-label": label, ...(parts.stacked ? { "aria-orientation": "vertical" } : {}), ...(groupDisabled ? { "aria-disabled": true } : {}), onKeyDown: (event) => moveByArrows(event, parts.vertical), className: root, children: items.map((item) => (_jsx(Tipped, { text: hasReason(item.disabledReason) ? item.disabledReason : item.title, describes: true, tap: off(item), own: {}, children: (tip) => (_jsx("button", { ...dataAttributes(item), type: "button", role: parts.item, ...(parts.item === "tab"
|
|
74
|
+
return (_jsx("div", { ...rest, ref: onRoot, role: parts.group, "aria-label": label, ...(parts.stacked ? { "aria-orientation": "vertical" } : {}), ...(groupDisabled ? { "aria-disabled": true } : {}), onKeyDown: (event) => moveByArrows(event, parts.vertical), className: root, children: items.map((item, index) => (_jsx(Tipped, { text: hasReason(item.disabledReason) ? item.disabledReason : item.title, describes: true, tap: off(item), own: {}, children: (tip) => (_jsx("button", { ...dataAttributes(item), type: "button", role: parts.item, ...(parts.item === "tab"
|
|
73
75
|
? { "aria-selected": item.value === value }
|
|
74
|
-
: { "aria-checked": item.value === value }), ...(
|
|
76
|
+
: { "aria-checked": item.value === value }), ...ariaIds(parts.ids?.(index)), tabIndex: item.value === stop ? 0 : -1, ...(off(item) ? { "aria-disabled": true } : {}), ...(reasoned(item) ? { "data-hc-reason": "" } : {}), ...tip, onClick: () => {
|
|
75
77
|
if (!off(item))
|
|
76
78
|
onChange?.(item.value);
|
|
77
|
-
}, className: cx(parts.option(item.value === value, off(item)), off(item)
|
|
79
|
+
}, className: cx(parts.option(item.value === value, off(item)), off(item) ? "cursor-not-allowed opacity-50" : "cursor-pointer"), children: _jsx(Label, { item: item }) })) }, item.value))) }));
|
|
78
80
|
}
|
package/dist/tableColumns.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ type TableSetting = {
|
|
|
10
10
|
numeric: readonly boolean[];
|
|
11
11
|
/** How many columns the head declares, or `undefined` with no `TableHead`. */
|
|
12
12
|
columns: number | undefined;
|
|
13
|
+
/** Says a new sort aloud, through the table's status region: the column's title and its direction. */
|
|
14
|
+
announce: (column: string, sort: "ascending" | "descending") => void;
|
|
15
|
+
/** Whether the table stacks its rows into cards in a narrow box (`narrow="stack"`). */
|
|
16
|
+
stack: boolean;
|
|
17
|
+
/** Each column's visible title from the head, for a stacked cell's label; `undefined` for a column with none. */
|
|
18
|
+
titles: readonly ReactNode[];
|
|
13
19
|
};
|
|
14
20
|
export declare const TableContext: import("react").Context<TableSetting>;
|
|
15
21
|
/**
|
|
@@ -18,6 +24,12 @@ export declare const TableContext: import("react").Context<TableSetting>;
|
|
|
18
24
|
* own component is not seen; its body cells then say `numeric` themselves.
|
|
19
25
|
*/
|
|
20
26
|
export declare function numericColumns(children: ReactNode, head: unknown, row: unknown): boolean[];
|
|
27
|
+
/**
|
|
28
|
+
* Each column's visible title, read from the first head row like `numericColumns`: the head cell's
|
|
29
|
+
* children, or `undefined` for a column whose title is a hidden `label` (a row's actions) and for
|
|
30
|
+
* the later columns a spanning title covers.
|
|
31
|
+
*/
|
|
32
|
+
export declare function columnTitles(children: ReactNode, head: unknown, row: unknown): ReactNode[];
|
|
21
33
|
/**
|
|
22
34
|
* How many columns the table has: the largest total of `colSpan`s (one each when unset) over the
|
|
23
35
|
* rows of its `TableHead`, read through arrays and fragments. `undefined` when there is no head;
|
|
@@ -28,4 +40,9 @@ export declare function columnCount(children: ReactNode, head: unknown, row: unk
|
|
|
28
40
|
export declare function withColumns(children: ReactNode): ReactNode[];
|
|
29
41
|
/** Whether the head declared this cell's column numeric. */
|
|
30
42
|
export declare function useNumericColumn(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* A stacked cell's label: its column's title from the head. None for the first column (the card's
|
|
45
|
+
* title), for a cell that spans columns, and outside a stacking table.
|
|
46
|
+
*/
|
|
47
|
+
export declare function useStackLabel(spans: boolean): ReactNode;
|
|
31
48
|
export {};
|