@sdxc/ui 0.0.0-pre.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/LICENSE.md +21 -0
- package/README.md +812 -0
- package/dist/animations/index.d.ts +12 -0
- package/dist/animations/index.js +12 -0
- package/dist/animations/keyframes.d.ts +162 -0
- package/dist/animations/keyframes.js +297 -0
- package/dist/animations/scroll.d.ts +154 -0
- package/dist/animations/scroll.js +228 -0
- package/dist/animations/tokens.d.ts +47 -0
- package/dist/animations/tokens.js +47 -0
- package/dist/animations/transitions.d.ts +143 -0
- package/dist/animations/transitions.js +147 -0
- package/dist/behaviors/announcer.d.ts +90 -0
- package/dist/behaviors/announcer.js +93 -0
- package/dist/behaviors/calendar-model.d.ts +218 -0
- package/dist/behaviors/calendar-model.js +376 -0
- package/dist/behaviors/drag-session.d.ts +119 -0
- package/dist/behaviors/drag-session.js +110 -0
- package/dist/behaviors/filter-model.d.ts +117 -0
- package/dist/behaviors/filter-model.js +185 -0
- package/dist/behaviors/index.d.ts +16 -0
- package/dist/behaviors/index.js +16 -0
- package/dist/behaviors/resize-session.d.ts +115 -0
- package/dist/behaviors/resize-session.js +157 -0
- package/dist/behaviors/scroll-follow-model.d.ts +180 -0
- package/dist/behaviors/scroll-follow-model.js +197 -0
- package/dist/behaviors/selection-model.d.ts +129 -0
- package/dist/behaviors/selection-model.js +259 -0
- package/dist/behaviors/toaster.d.ts +144 -0
- package/dist/behaviors/toaster.js +228 -0
- package/dist/components/accordion.d.ts +93 -0
- package/dist/components/accordion.js +165 -0
- package/dist/components/alert-dialog.d.ts +110 -0
- package/dist/components/alert-dialog.js +169 -0
- package/dist/components/alert.d.ts +109 -0
- package/dist/components/alert.js +160 -0
- package/dist/components/aspect-ratio.d.ts +44 -0
- package/dist/components/aspect-ratio.js +35 -0
- package/dist/components/attachment.d.ts +146 -0
- package/dist/components/attachment.js +320 -0
- package/dist/components/avatar.d.ts +118 -0
- package/dist/components/avatar.js +89 -0
- package/dist/components/badge.d.ts +66 -0
- package/dist/components/badge.js +129 -0
- package/dist/components/breadcrumbs.d.ts +67 -0
- package/dist/components/breadcrumbs.js +121 -0
- package/dist/components/bubble.d.ts +91 -0
- package/dist/components/bubble.js +216 -0
- package/dist/components/button.d.ts +78 -0
- package/dist/components/button.js +207 -0
- package/dist/components/calendar.d.ts +166 -0
- package/dist/components/calendar.js +320 -0
- package/dist/components/card.d.ts +82 -0
- package/dist/components/card.js +126 -0
- package/dist/components/carousel.d.ts +96 -0
- package/dist/components/carousel.js +214 -0
- package/dist/components/chart.d.ts +485 -0
- package/dist/components/chart.js +563 -0
- package/dist/components/checkbox-group.d.ts +58 -0
- package/dist/components/checkbox-group.js +53 -0
- package/dist/components/checkbox.d.ts +61 -0
- package/dist/components/checkbox.js +81 -0
- package/dist/components/color-area.d.ts +83 -0
- package/dist/components/color-area.js +251 -0
- package/dist/components/color-field.d.ts +128 -0
- package/dist/components/color-field.js +73 -0
- package/dist/components/color-picker.d.ts +132 -0
- package/dist/components/color-picker.js +183 -0
- package/dist/components/color-slider.d.ts +103 -0
- package/dist/components/color-slider.js +198 -0
- package/dist/components/color-swatch-picker.d.ts +106 -0
- package/dist/components/color-swatch-picker.js +75 -0
- package/dist/components/color-swatch.d.ts +57 -0
- package/dist/components/color-swatch.js +82 -0
- package/dist/components/color-wheel.d.ts +58 -0
- package/dist/components/color-wheel.js +160 -0
- package/dist/components/combobox.d.ts +73 -0
- package/dist/components/combobox.js +108 -0
- package/dist/components/command.d.ts +80 -0
- package/dist/components/command.js +151 -0
- package/dist/components/confirm.d.ts +124 -0
- package/dist/components/confirm.js +56 -0
- package/dist/components/context-menu.d.ts +108 -0
- package/dist/components/context-menu.js +200 -0
- package/dist/components/date-field.d.ts +110 -0
- package/dist/components/date-field.js +49 -0
- package/dist/components/date-picker.d.ts +136 -0
- package/dist/components/date-picker.js +155 -0
- package/dist/components/date-range-picker.d.ts +152 -0
- package/dist/components/date-range-picker.js +106 -0
- package/dist/components/description.d.ts +36 -0
- package/dist/components/description.js +21 -0
- package/dist/components/dialog.d.ts +97 -0
- package/dist/components/dialog.js +203 -0
- package/dist/components/disclosure.d.ts +85 -0
- package/dist/components/disclosure.js +180 -0
- package/dist/components/drawer.d.ts +82 -0
- package/dist/components/drawer.js +162 -0
- package/dist/components/drop-indicator.d.ts +43 -0
- package/dist/components/drop-indicator.js +47 -0
- package/dist/components/drop-zone.d.ts +73 -0
- package/dist/components/drop-zone.js +54 -0
- package/dist/components/empty.d.ts +89 -0
- package/dist/components/empty.js +129 -0
- package/dist/components/field-error.d.ts +41 -0
- package/dist/components/field-error.js +36 -0
- package/dist/components/file-trigger.d.ts +84 -0
- package/dist/components/file-trigger.js +169 -0
- package/dist/components/form.d.ts +118 -0
- package/dist/components/form.js +113 -0
- package/dist/components/grid-list.d.ts +112 -0
- package/dist/components/grid-list.js +220 -0
- package/dist/components/group.d.ts +45 -0
- package/dist/components/group.js +44 -0
- package/dist/components/header.d.ts +33 -0
- package/dist/components/header.js +29 -0
- package/dist/components/heading-scope.d.ts +83 -0
- package/dist/components/heading-scope.js +82 -0
- package/dist/components/heading.d.ts +50 -0
- package/dist/components/heading.js +31 -0
- package/dist/components/hover-card.d.ts +77 -0
- package/dist/components/hover-card.js +151 -0
- package/dist/components/image-placeholder.d.ts +105 -0
- package/dist/components/image-placeholder.js +212 -0
- package/dist/components/index.d.ts +109 -0
- package/dist/components/index.js +109 -0
- package/dist/components/input.d.ts +53 -0
- package/dist/components/input.js +76 -0
- package/dist/components/item.d.ts +97 -0
- package/dist/components/item.js +185 -0
- package/dist/components/keyboard.d.ts +33 -0
- package/dist/components/keyboard.js +20 -0
- package/dist/components/label.d.ts +38 -0
- package/dist/components/label.js +24 -0
- package/dist/components/link-button.d.ts +59 -0
- package/dist/components/link-button.js +174 -0
- package/dist/components/link.d.ts +43 -0
- package/dist/components/link.js +85 -0
- package/dist/components/listbox.d.ts +119 -0
- package/dist/components/listbox.js +114 -0
- package/dist/components/logo.d.ts +117 -0
- package/dist/components/logo.js +89 -0
- package/dist/components/marker.d.ts +82 -0
- package/dist/components/marker.js +163 -0
- package/dist/components/menu.d.ts +90 -0
- package/dist/components/menu.js +146 -0
- package/dist/components/menubar.d.ts +54 -0
- package/dist/components/menubar.js +118 -0
- package/dist/components/message-scroller.d.ts +109 -0
- package/dist/components/message-scroller.js +180 -0
- package/dist/components/message.d.ts +104 -0
- package/dist/components/message.js +200 -0
- package/dist/components/meter.d.ts +60 -0
- package/dist/components/meter.js +110 -0
- package/dist/components/modal.d.ts +71 -0
- package/dist/components/modal.js +120 -0
- package/dist/components/nav-link.d.ts +53 -0
- package/dist/components/nav-link.js +83 -0
- package/dist/components/navigation-menu.d.ts +150 -0
- package/dist/components/navigation-menu.js +381 -0
- package/dist/components/number-field.d.ts +76 -0
- package/dist/components/number-field.js +190 -0
- package/dist/components/otp-field.d.ts +68 -0
- package/dist/components/otp-field.js +46 -0
- package/dist/components/overlay-arrow.d.ts +51 -0
- package/dist/components/overlay-arrow.js +77 -0
- package/dist/components/pagination.d.ts +67 -0
- package/dist/components/pagination.js +164 -0
- package/dist/components/popover.d.ts +69 -0
- package/dist/components/popover.js +68 -0
- package/dist/components/progress-bar.d.ts +53 -0
- package/dist/components/progress-bar.js +90 -0
- package/dist/components/radio-group.d.ts +102 -0
- package/dist/components/radio-group.js +114 -0
- package/dist/components/range-calendar.d.ts +169 -0
- package/dist/components/range-calendar.js +216 -0
- package/dist/components/resizable.d.ts +98 -0
- package/dist/components/resizable.js +151 -0
- package/dist/components/scroll-area.d.ts +54 -0
- package/dist/components/scroll-area.js +89 -0
- package/dist/components/search-field.d.ts +55 -0
- package/dist/components/search-field.js +49 -0
- package/dist/components/section.d.ts +37 -0
- package/dist/components/section.js +22 -0
- package/dist/components/select.d.ts +96 -0
- package/dist/components/select.js +285 -0
- package/dist/components/selection-indicator.d.ts +47 -0
- package/dist/components/selection-indicator.js +50 -0
- package/dist/components/sentinel-row.d.ts +22 -0
- package/dist/components/sentinel-row.js +29 -0
- package/dist/components/separator.d.ts +35 -0
- package/dist/components/separator.js +48 -0
- package/dist/components/shared-element.d.ts +45 -0
- package/dist/components/shared-element.js +48 -0
- package/dist/components/sheet.d.ts +78 -0
- package/dist/components/sheet.js +167 -0
- package/dist/components/sidebar.d.ts +288 -0
- package/dist/components/sidebar.js +1068 -0
- package/dist/components/skeleton.d.ts +36 -0
- package/dist/components/skeleton.js +38 -0
- package/dist/components/slider.d.ts +102 -0
- package/dist/components/slider.js +179 -0
- package/dist/components/spinner.d.ts +55 -0
- package/dist/components/spinner.js +51 -0
- package/dist/components/switch.d.ts +47 -0
- package/dist/components/switch.js +82 -0
- package/dist/components/table.d.ts +139 -0
- package/dist/components/table.js +216 -0
- package/dist/components/tabs.d.ts +124 -0
- package/dist/components/tabs.js +246 -0
- package/dist/components/tag-group.d.ts +83 -0
- package/dist/components/tag-group.js +157 -0
- package/dist/components/text-field.d.ts +119 -0
- package/dist/components/text-field.js +51 -0
- package/dist/components/text.d.ts +34 -0
- package/dist/components/text.js +19 -0
- package/dist/components/textarea.d.ts +52 -0
- package/dist/components/textarea.js +82 -0
- package/dist/components/time-field.d.ts +110 -0
- package/dist/components/time-field.js +48 -0
- package/dist/components/toast.d.ts +149 -0
- package/dist/components/toast.js +365 -0
- package/dist/components/toggle-button.d.ts +115 -0
- package/dist/components/toggle-button.js +237 -0
- package/dist/components/toolbar.d.ts +47 -0
- package/dist/components/toolbar.js +54 -0
- package/dist/components/tooltip.d.ts +52 -0
- package/dist/components/tooltip.js +92 -0
- package/dist/components/tree.d.ts +123 -0
- package/dist/components/tree.js +239 -0
- package/dist/components/typeset.d.ts +53 -0
- package/dist/components/typeset.js +271 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/mixins/aria-checked.d.ts +42 -0
- package/dist/mixins/aria-checked.js +127 -0
- package/dist/mixins/attachment-trigger.d.ts +64 -0
- package/dist/mixins/attachment-trigger.js +190 -0
- package/dist/mixins/calendar-keys.d.ts +27 -0
- package/dist/mixins/calendar-keys.js +113 -0
- package/dist/mixins/carousel-controls.d.ts +30 -0
- package/dist/mixins/carousel-controls.js +222 -0
- package/dist/mixins/chart-tooltip.d.ts +118 -0
- package/dist/mixins/chart-tooltip.js +323 -0
- package/dist/mixins/clear-field.d.ts +60 -0
- package/dist/mixins/clear-field.js +100 -0
- package/dist/mixins/color-area-drag.d.ts +58 -0
- package/dist/mixins/color-area-drag.js +162 -0
- package/dist/mixins/color-channel-sync.d.ts +73 -0
- package/dist/mixins/color-channel-sync.js +169 -0
- package/dist/mixins/color-preview.d.ts +28 -0
- package/dist/mixins/color-preview.js +77 -0
- package/dist/mixins/color-wheel-drag.d.ts +58 -0
- package/dist/mixins/color-wheel-drag.js +139 -0
- package/dist/mixins/combobox-filter.d.ts +59 -0
- package/dist/mixins/combobox-filter.js +81 -0
- package/dist/mixins/command-filter.d.ts +55 -0
- package/dist/mixins/command-filter.js +121 -0
- package/dist/mixins/command-keys.d.ts +31 -0
- package/dist/mixins/command-keys.js +116 -0
- package/dist/mixins/context-menu.d.ts +24 -0
- package/dist/mixins/context-menu.js +64 -0
- package/dist/mixins/copy-to-clipboard.d.ts +64 -0
- package/dist/mixins/copy-to-clipboard.js +109 -0
- package/dist/mixins/dismiss.d.ts +77 -0
- package/dist/mixins/dismiss.js +151 -0
- package/dist/mixins/drag-reorder.d.ts +88 -0
- package/dist/mixins/drag-reorder.js +214 -0
- package/dist/mixins/drop-zone.d.ts +52 -0
- package/dist/mixins/drop-zone.js +132 -0
- package/dist/mixins/dual-range.d.ts +60 -0
- package/dist/mixins/dual-range.js +100 -0
- package/dist/mixins/grid-list-keys.d.ts +34 -0
- package/dist/mixins/grid-list-keys.js +260 -0
- package/dist/mixins/heading-level-fallback.d.ts +81 -0
- package/dist/mixins/heading-level-fallback.js +112 -0
- package/dist/mixins/hotkey.d.ts +26 -0
- package/dist/mixins/hotkey.js +132 -0
- package/dist/mixins/image-fallback.d.ts +57 -0
- package/dist/mixins/image-fallback.js +86 -0
- package/dist/mixins/index.d.ts +48 -0
- package/dist/mixins/index.js +48 -0
- package/dist/mixins/listbox-keys.d.ts +52 -0
- package/dist/mixins/listbox-keys.js +63 -0
- package/dist/mixins/long-press.d.ts +76 -0
- package/dist/mixins/long-press.js +130 -0
- package/dist/mixins/menu-keys.d.ts +40 -0
- package/dist/mixins/menu-keys.js +117 -0
- package/dist/mixins/menubar-keys.d.ts +59 -0
- package/dist/mixins/menubar-keys.js +230 -0
- package/dist/mixins/message-follow.d.ts +56 -0
- package/dist/mixins/message-follow.js +368 -0
- package/dist/mixins/otp-slots.d.ts +53 -0
- package/dist/mixins/otp-slots.js +175 -0
- package/dist/mixins/persist.d.ts +36 -0
- package/dist/mixins/persist.js +78 -0
- package/dist/mixins/press-toggle.d.ts +43 -0
- package/dist/mixins/press-toggle.js +61 -0
- package/dist/mixins/range-preview.d.ts +26 -0
- package/dist/mixins/range-preview.js +120 -0
- package/dist/mixins/resize-handle.d.ts +101 -0
- package/dist/mixins/resize-handle.js +288 -0
- package/dist/mixins/stepper.d.ts +81 -0
- package/dist/mixins/stepper.js +194 -0
- package/dist/mixins/tab-keys.d.ts +30 -0
- package/dist/mixins/tab-keys.js +63 -0
- package/dist/mixins/theme-toggle.d.ts +82 -0
- package/dist/mixins/theme-toggle.js +158 -0
- package/dist/mixins/track-host-node.d.ts +34 -0
- package/dist/mixins/track-host-node.js +42 -0
- package/dist/mixins/treeKeys.d.ts +57 -0
- package/dist/mixins/treeKeys.js +266 -0
- package/dist/mixins/validate.d.ts +65 -0
- package/dist/mixins/validate.js +139 -0
- package/dist/mixins/view-transition.d.ts +56 -0
- package/dist/mixins/view-transition.js +111 -0
- package/dist/styles/chart-palette.d.ts +34 -0
- package/dist/styles/chart-palette.js +27 -0
- package/dist/styles/field-stack-layout.d.ts +27 -0
- package/dist/styles/field-stack-layout.js +16 -0
- package/dist/styles/floating-surface.d.ts +32 -0
- package/dist/styles/floating-surface.js +30 -0
- package/dist/styles/graphic-host.d.ts +25 -0
- package/dist/styles/graphic-host.js +18 -0
- package/dist/styles/index.d.ts +20 -0
- package/dist/styles/index.js +20 -0
- package/dist/styles/interactive-transition.d.ts +32 -0
- package/dist/styles/interactive-transition.js +32 -0
- package/dist/styles/legend-toggle.d.ts +29 -0
- package/dist/styles/legend-toggle.js +24 -0
- package/dist/styles/output-caption-text.d.ts +22 -0
- package/dist/styles/output-caption-text.js +15 -0
- package/dist/styles/panel-chrome.d.ts +34 -0
- package/dist/styles/panel-chrome.js +26 -0
- package/dist/styles/range-thumb-appearance.d.ts +36 -0
- package/dist/styles/range-thumb-appearance.js +76 -0
- package/dist/styles/rtl-aware-gradient-direction.d.ts +28 -0
- package/dist/styles/rtl-aware-gradient-direction.js +28 -0
- package/dist/styles/semantic-color-panel.d.ts +35 -0
- package/dist/styles/semantic-color-panel.js +41 -0
- package/dist/utils/chart-marker-indices.d.ts +22 -0
- package/dist/utils/chart-marker-indices.js +45 -0
- package/dist/utils/chart-path.d.ts +86 -0
- package/dist/utils/chart-path.js +122 -0
- package/dist/utils/chart-scale.d.ts +182 -0
- package/dist/utils/chart-scale.js +221 -0
- package/dist/utils/color-math.d.ts +252 -0
- package/dist/utils/color-math.js +480 -0
- package/dist/utils/command-event.d.ts +24 -0
- package/dist/utils/command-event.js +26 -0
- package/dist/utils/css-styles.d.ts +21 -0
- package/dist/utils/css-styles.js +11 -0
- package/dist/utils/decorative-icon.d.ts +15 -0
- package/dist/utils/decorative-icon.js +15 -0
- package/dist/utils/disabled-selector.d.ts +22 -0
- package/dist/utils/disabled-selector.js +22 -0
- package/dist/utils/dispatch-change.d.ts +17 -0
- package/dist/utils/dispatch-change.js +19 -0
- package/dist/utils/field-parts.d.ts +26 -0
- package/dist/utils/field-parts.js +12 -0
- package/dist/utils/full-turn-radians.d.ts +16 -0
- package/dist/utils/full-turn-radians.js +16 -0
- package/dist/utils/geometry.d.ts +14 -0
- package/dist/utils/geometry.js +9 -0
- package/dist/utils/has-accessible-text.d.ts +19 -0
- package/dist/utils/has-accessible-text.js +30 -0
- package/dist/utils/hue-spectrum.d.ts +19 -0
- package/dist/utils/hue-spectrum.js +19 -0
- package/dist/utils/index.d.ts +35 -0
- package/dist/utils/index.js +35 -0
- package/dist/utils/is-new-primary-press.d.ts +29 -0
- package/dist/utils/is-new-primary-press.js +31 -0
- package/dist/utils/keyboard-nav.d.ts +64 -0
- package/dist/utils/keyboard-nav.js +79 -0
- package/dist/utils/merge-style.d.ts +33 -0
- package/dist/utils/merge-style.js +30 -0
- package/dist/utils/paired-range-inputs.d.ts +26 -0
- package/dist/utils/paired-range-inputs.js +29 -0
- package/dist/utils/placement.d.ts +18 -0
- package/dist/utils/placement.js +12 -0
- package/dist/utils/prefers-reduced-motion.d.ts +17 -0
- package/dist/utils/prefers-reduced-motion.js +19 -0
- package/dist/utils/resolve-field-wiring.d.ts +83 -0
- package/dist/utils/resolve-field-wiring.js +53 -0
- package/dist/utils/resolve-fill-percent.d.ts +28 -0
- package/dist/utils/resolve-fill-percent.js +34 -0
- package/dist/utils/round-precision.d.ts +22 -0
- package/dist/utils/round-precision.js +25 -0
- package/dist/utils/semantic-color-panel.d.ts +35 -0
- package/dist/utils/semantic-color-panel.js +28 -0
- package/dist/utils/semantic-color.d.ts +17 -0
- package/dist/utils/semantic-color.js +11 -0
- package/dist/utils/warn-if-no-accessible-name.d.ts +52 -0
- package/dist/utils/warn-if-no-accessible-name.js +55 -0
- package/dist/utils/write-cookie.d.ts +35 -0
- package/dist/utils/write-cookie.js +37 -0
- package/package.json +32 -0
- package/src/reset.css +223 -0
- package/src/theme.css +146 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless queue of aria-live announcements: a live-region island subscribes
|
|
3
|
+
* to its state and re-renders on change. Backs transient accessibility
|
|
4
|
+
* announcements such as match counts, drag-and-drop position updates, and
|
|
5
|
+
* toast messages.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import { TypedEventTarget } from "remix/ui";
|
|
11
|
+
/**
|
|
12
|
+
* Types describing the announcements and events {@link Announcer} owns.
|
|
13
|
+
*/
|
|
14
|
+
export declare namespace Announcer {
|
|
15
|
+
/**
|
|
16
|
+
* Politeness a queued message announces with, mirrored onto a live
|
|
17
|
+
* region's `aria-live` attribute. `"assertive"` interrupts the current
|
|
18
|
+
* utterance and moves ahead of any `"polite"` messages already queued.
|
|
19
|
+
*/
|
|
20
|
+
type Priority = "polite" | "assertive";
|
|
21
|
+
/**
|
|
22
|
+
* One queued announcement.
|
|
23
|
+
*/
|
|
24
|
+
interface Message {
|
|
25
|
+
/** Stable id used to target this message with {@link Announcer.dismiss}. */
|
|
26
|
+
readonly id: string;
|
|
27
|
+
/** Announcement copy, read verbatim by the live region. */
|
|
28
|
+
readonly text: string;
|
|
29
|
+
readonly priority: Priority;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Events dispatched by {@link Announcer}.
|
|
33
|
+
*/
|
|
34
|
+
interface Events {
|
|
35
|
+
/**
|
|
36
|
+
* Dispatched after a message is queued, dismissed, advanced past, or
|
|
37
|
+
* the queue is cleared.
|
|
38
|
+
*/
|
|
39
|
+
change: Event;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Owns a priority-ordered queue of aria-live announcements. A live-region
|
|
44
|
+
* island subscribes to `"change"`, renders {@link Announcer.current} into an
|
|
45
|
+
* `aria-live` element, and calls {@link Announcer.next} once it has been read.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* announcer.addEventListener("change", () => handle.update(), { signal: handle.signal });
|
|
49
|
+
*/
|
|
50
|
+
export declare class Announcer extends TypedEventTarget<Announcer.Events> {
|
|
51
|
+
#private;
|
|
52
|
+
/**
|
|
53
|
+
* The message a live region should currently render, or `undefined` when
|
|
54
|
+
* the queue is empty.
|
|
55
|
+
*/
|
|
56
|
+
get current(): Announcer.Message | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Every queued message, in the order a live region should announce them.
|
|
59
|
+
*/
|
|
60
|
+
get messages(): readonly Announcer.Message[];
|
|
61
|
+
/**
|
|
62
|
+
* Queues a message for announcement. Assertive messages are inserted ahead
|
|
63
|
+
* of any polite messages already queued so they interrupt the live region,
|
|
64
|
+
* and behind assertive messages queued earlier; polite messages append.
|
|
65
|
+
*
|
|
66
|
+
* @param text Announcement copy, read verbatim by the live region.
|
|
67
|
+
* @param priority Politeness setting the message announces with. Defaults to `"polite"`.
|
|
68
|
+
* @returns The generated id, usable with {@link Announcer.dismiss}.
|
|
69
|
+
* @example
|
|
70
|
+
* announcer.announce("5 results found");
|
|
71
|
+
*/
|
|
72
|
+
announce(text: string, priority?: Announcer.Priority): string;
|
|
73
|
+
/**
|
|
74
|
+
* Removes one queued message by id, wherever it sits in the queue,
|
|
75
|
+
* dispatching `"change"` only when a message with that id was queued.
|
|
76
|
+
*
|
|
77
|
+
* @param id Id returned by {@link Announcer.announce}.
|
|
78
|
+
*/
|
|
79
|
+
dismiss(id: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* Advances past the current message so the next queued one becomes
|
|
82
|
+
* {@link Announcer.current}, dispatching `"change"` only when the queue
|
|
83
|
+
* held a message.
|
|
84
|
+
*/
|
|
85
|
+
next(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Empties the queue, dispatching `"change"` only when it held messages.
|
|
88
|
+
*/
|
|
89
|
+
clear(): void;
|
|
90
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless queue of aria-live announcements: a live-region island subscribes
|
|
3
|
+
* to its state and re-renders on change. Backs transient accessibility
|
|
4
|
+
* announcements such as match counts, drag-and-drop position updates, and
|
|
5
|
+
* toast messages.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import { TypedEventTarget } from "remix/ui";
|
|
11
|
+
const DEFAULT_PRIORITY = "polite";
|
|
12
|
+
/**
|
|
13
|
+
* Owns a priority-ordered queue of aria-live announcements. A live-region
|
|
14
|
+
* island subscribes to `"change"`, renders {@link Announcer.current} into an
|
|
15
|
+
* `aria-live` element, and calls {@link Announcer.next} once it has been read.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* announcer.addEventListener("change", () => handle.update(), { signal: handle.signal });
|
|
19
|
+
*/
|
|
20
|
+
export class Announcer extends TypedEventTarget {
|
|
21
|
+
#queue = [];
|
|
22
|
+
/**
|
|
23
|
+
* The message a live region should currently render, or `undefined` when
|
|
24
|
+
* the queue is empty.
|
|
25
|
+
*/
|
|
26
|
+
get current() {
|
|
27
|
+
return this.#queue.at(0);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Every queued message, in the order a live region should announce them.
|
|
31
|
+
*/
|
|
32
|
+
get messages() {
|
|
33
|
+
return this.#queue;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Queues a message for announcement. Assertive messages are inserted ahead
|
|
37
|
+
* of any polite messages already queued so they interrupt the live region,
|
|
38
|
+
* and behind assertive messages queued earlier; polite messages append.
|
|
39
|
+
*
|
|
40
|
+
* @param text Announcement copy, read verbatim by the live region.
|
|
41
|
+
* @param priority Politeness setting the message announces with. Defaults to `"polite"`.
|
|
42
|
+
* @returns The generated id, usable with {@link Announcer.dismiss}.
|
|
43
|
+
* @example
|
|
44
|
+
* announcer.announce("5 results found");
|
|
45
|
+
*/
|
|
46
|
+
announce(text, priority = DEFAULT_PRIORITY) {
|
|
47
|
+
let message = { id: crypto.randomUUID(), text, priority };
|
|
48
|
+
if (priority === "assertive") {
|
|
49
|
+
let index = this.#queue.findIndex((queued) => queued.priority !== "assertive");
|
|
50
|
+
if (index === -1)
|
|
51
|
+
this.#queue.push(message);
|
|
52
|
+
else
|
|
53
|
+
this.#queue.splice(index, 0, message);
|
|
54
|
+
}
|
|
55
|
+
else
|
|
56
|
+
this.#queue.push(message);
|
|
57
|
+
this.dispatchEvent(new Event("change"));
|
|
58
|
+
return message.id;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Removes one queued message by id, wherever it sits in the queue,
|
|
62
|
+
* dispatching `"change"` only when a message with that id was queued.
|
|
63
|
+
*
|
|
64
|
+
* @param id Id returned by {@link Announcer.announce}.
|
|
65
|
+
*/
|
|
66
|
+
dismiss(id) {
|
|
67
|
+
let index = this.#queue.findIndex((message) => message.id === id);
|
|
68
|
+
if (index === -1)
|
|
69
|
+
return;
|
|
70
|
+
this.#queue.splice(index, 1);
|
|
71
|
+
this.dispatchEvent(new Event("change"));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Advances past the current message so the next queued one becomes
|
|
75
|
+
* {@link Announcer.current}, dispatching `"change"` only when the queue
|
|
76
|
+
* held a message.
|
|
77
|
+
*/
|
|
78
|
+
next() {
|
|
79
|
+
if (this.#queue.length === 0)
|
|
80
|
+
return;
|
|
81
|
+
this.#queue.shift();
|
|
82
|
+
this.dispatchEvent(new Event("change"));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Empties the queue, dispatching `"change"` only when it held messages.
|
|
86
|
+
*/
|
|
87
|
+
clear() {
|
|
88
|
+
if (this.#queue.length === 0)
|
|
89
|
+
return;
|
|
90
|
+
this.#queue = [];
|
|
91
|
+
this.dispatchEvent(new Event("change"));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless state model for calendar grids: tracks the keyboard-focused day,
|
|
3
|
+
* the visible month page, and an in-progress range selection (anchor plus
|
|
4
|
+
* hover preview), leaving value storage and rendering to the consumer.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { TypedEventTarget } from "remix/ui";
|
|
10
|
+
/**
|
|
11
|
+
* Prop and event-payload types for {@link CalendarModel}.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace CalendarModel {
|
|
14
|
+
/**
|
|
15
|
+
* An inclusive start/end pair of calendar days, always normalized so
|
|
16
|
+
* `start` comes first, whatever order the two endpoints were picked in.
|
|
17
|
+
*/
|
|
18
|
+
interface Range {
|
|
19
|
+
start: Date;
|
|
20
|
+
end: Date;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Constructor options for {@link CalendarModel}.
|
|
24
|
+
*/
|
|
25
|
+
interface Options {
|
|
26
|
+
/**
|
|
27
|
+
* Day that starts focused. Defaults to today when omitted. Only the
|
|
28
|
+
* calendar date is read; time-of-day is discarded.
|
|
29
|
+
*/
|
|
30
|
+
focusedDate?: Date;
|
|
31
|
+
/**
|
|
32
|
+
* Earliest day the model will focus or accept as a range endpoint;
|
|
33
|
+
* navigation and range methods clamp to it.
|
|
34
|
+
*/
|
|
35
|
+
min?: Date;
|
|
36
|
+
/**
|
|
37
|
+
* Latest day the model will focus or accept as a range endpoint;
|
|
38
|
+
* navigation and range methods clamp to it.
|
|
39
|
+
*/
|
|
40
|
+
max?: Date;
|
|
41
|
+
/**
|
|
42
|
+
* Predicate marking individual days as unselectable (closures on a
|
|
43
|
+
* weekend, already-booked slots, …). Navigation still visits these days,
|
|
44
|
+
* so keyboard users can reach a selectable day past them.
|
|
45
|
+
*/
|
|
46
|
+
isDateDisabled?: (date: Date) => boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Events dispatched by {@link CalendarModel} as its state changes. */
|
|
49
|
+
interface EventMap {
|
|
50
|
+
/**
|
|
51
|
+
* Dispatched after focus, the visible month, the range anchor, or the
|
|
52
|
+
* range preview changes.
|
|
53
|
+
*/
|
|
54
|
+
change: Event;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Owns the ephemeral state around picking a date: the keyboard-focused day,
|
|
59
|
+
* the visible month page, and a range's anchor plus hover preview. The chosen
|
|
60
|
+
* value stays with the consumer, and every state change dispatches `"change"`.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* let model = new CalendarModel({ focusedDate: new Date(2026, 0, 15) });
|
|
64
|
+
* model.addEventListener("change", () => update());
|
|
65
|
+
* model.focusNextDay();
|
|
66
|
+
*/
|
|
67
|
+
export declare class CalendarModel extends TypedEventTarget<CalendarModel.EventMap> {
|
|
68
|
+
#private;
|
|
69
|
+
/**
|
|
70
|
+
* Builds the model with an initial focused day and optional selectable
|
|
71
|
+
* bounds. The visible month follows from the focused day.
|
|
72
|
+
*
|
|
73
|
+
* @param options Initial focus, selectable bounds, and disabled-day rule.
|
|
74
|
+
*/
|
|
75
|
+
constructor(options?: CalendarModel.Options);
|
|
76
|
+
/**
|
|
77
|
+
* The day that currently carries keyboard/roving-tabindex focus. Always
|
|
78
|
+
* a fresh `Date` instance, so callers may mutate it freely.
|
|
79
|
+
*/
|
|
80
|
+
get focusedDate(): Date;
|
|
81
|
+
/**
|
|
82
|
+
* The first day of the month page on screen. Follows focus into a new
|
|
83
|
+
* month, and moves on its own when the consumer pages the grid via
|
|
84
|
+
* {@link showMonth}/{@link showNextMonth}/{@link showPreviousMonth}.
|
|
85
|
+
*/
|
|
86
|
+
get visibleMonth(): Date;
|
|
87
|
+
/**
|
|
88
|
+
* The first day picked while building a range, or `null` when no range
|
|
89
|
+
* selection is in progress.
|
|
90
|
+
*/
|
|
91
|
+
get anchorDate(): Date | null;
|
|
92
|
+
/**
|
|
93
|
+
* The day currently under hover/focus while a range's second endpoint is
|
|
94
|
+
* being chosen, or `null` when there is no pending range or no day has
|
|
95
|
+
* been previewed yet.
|
|
96
|
+
*/
|
|
97
|
+
get previewDate(): Date | null;
|
|
98
|
+
/**
|
|
99
|
+
* The range implied by the current anchor and preview day, normalized so
|
|
100
|
+
* `start` comes first; `null` when no range selection is in progress.
|
|
101
|
+
* Before a preview day is set it collapses to a single day on the anchor.
|
|
102
|
+
*/
|
|
103
|
+
get previewRange(): CalendarModel.Range | null;
|
|
104
|
+
/** Earliest day the model accepts, or `null` when unbounded. */
|
|
105
|
+
get min(): Date | null;
|
|
106
|
+
/** Latest day the model accepts, or `null` when unbounded. */
|
|
107
|
+
get max(): Date | null;
|
|
108
|
+
/**
|
|
109
|
+
* Moves focus to an arbitrary day, clamped to the selectable bounds, and
|
|
110
|
+
* pages the visible month to match. Suits pointer selection of a grid
|
|
111
|
+
* cell; the directional `focus*` methods own the keyboard offset math.
|
|
112
|
+
*
|
|
113
|
+
* @param date Day to focus.
|
|
114
|
+
*/
|
|
115
|
+
focusDate(date: Date): void;
|
|
116
|
+
/** Moves focus one day forward (typically the ArrowRight key). */
|
|
117
|
+
focusNextDay(): void;
|
|
118
|
+
/** Moves focus one day back (typically the ArrowLeft key). */
|
|
119
|
+
focusPreviousDay(): void;
|
|
120
|
+
/** Moves focus one week forward (typically the ArrowDown key). */
|
|
121
|
+
focusNextWeek(): void;
|
|
122
|
+
/** Moves focus one week back (typically the ArrowUp key). */
|
|
123
|
+
focusPreviousWeek(): void;
|
|
124
|
+
/**
|
|
125
|
+
* Moves focus one month forward, clamping the day of month to the
|
|
126
|
+
* target month's last day when it's shorter (typically the PageDown
|
|
127
|
+
* key).
|
|
128
|
+
*/
|
|
129
|
+
focusNextMonth(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Moves focus one month back, clamping the day of month to the target
|
|
132
|
+
* month's last day when it's shorter (typically the PageUp key).
|
|
133
|
+
*/
|
|
134
|
+
focusPreviousMonth(): void;
|
|
135
|
+
/** Moves focus to the first day of the focused month (typically the Home key). */
|
|
136
|
+
focusMonthStart(): void;
|
|
137
|
+
/** Moves focus to the last day of the focused month (typically the End key). */
|
|
138
|
+
focusMonthEnd(): void;
|
|
139
|
+
/**
|
|
140
|
+
* Pages the visible month to the month containing `date`, leaving focus
|
|
141
|
+
* where it is — the focused day scrolls out of the rendered grid until
|
|
142
|
+
* focus moves again. Suits a header's month/year picker.
|
|
143
|
+
*
|
|
144
|
+
* @param date Any day within the month to display.
|
|
145
|
+
*/
|
|
146
|
+
showMonth(date: Date): void;
|
|
147
|
+
/** Pages the visible month forward by one, leaving focus where it is. */
|
|
148
|
+
showNextMonth(): void;
|
|
149
|
+
/** Pages the visible month back by one, leaving focus where it is. */
|
|
150
|
+
showPreviousMonth(): void;
|
|
151
|
+
/**
|
|
152
|
+
* Starts a range selection at `date`, clearing any preview from a
|
|
153
|
+
* previous attempt. Call this when the user picks the first endpoint
|
|
154
|
+
* (e.g. the first click in a range calendar).
|
|
155
|
+
*
|
|
156
|
+
* @param date Day to anchor the range at.
|
|
157
|
+
*/
|
|
158
|
+
beginRange(date: Date): void;
|
|
159
|
+
/**
|
|
160
|
+
* Updates the pending second endpoint so {@link previewRange} tracks the
|
|
161
|
+
* day under hover or focus. A no-op while no range is in progress, so
|
|
162
|
+
* hover handlers can call it unconditionally.
|
|
163
|
+
*
|
|
164
|
+
* @param date Day currently under hover/focus.
|
|
165
|
+
*/
|
|
166
|
+
updateRangePreview(date: Date): void;
|
|
167
|
+
/**
|
|
168
|
+
* Commits the range from the current anchor to `date` and clears the
|
|
169
|
+
* pending selection, returning it normalized. With no range in progress
|
|
170
|
+
* the consumer's selected value stays untouched.
|
|
171
|
+
*
|
|
172
|
+
* @param date Day chosen as the second endpoint.
|
|
173
|
+
* @returns The committed range, or `null` when there was no anchor.
|
|
174
|
+
*/
|
|
175
|
+
completeRange(date: Date): CalendarModel.Range | null;
|
|
176
|
+
/**
|
|
177
|
+
* Abandons an in-progress range selection (e.g. on Escape or blur),
|
|
178
|
+
* leaving the consumer's selected value untouched. A no-op when no range
|
|
179
|
+
* is in progress.
|
|
180
|
+
*/
|
|
181
|
+
cancelRange(): void;
|
|
182
|
+
/**
|
|
183
|
+
* Whether `date` is the day currently carrying keyboard focus.
|
|
184
|
+
*
|
|
185
|
+
* @param date Day to test.
|
|
186
|
+
*/
|
|
187
|
+
isFocused(date: Date): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Whether `date` is the anchor of an in-progress range selection.
|
|
190
|
+
*
|
|
191
|
+
* @param date Day to test.
|
|
192
|
+
*/
|
|
193
|
+
isRangeAnchor(date: Date): boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Whether `date` falls within the current {@link previewRange},
|
|
196
|
+
* inclusive of both endpoints. Always `false` when no range is in
|
|
197
|
+
* progress.
|
|
198
|
+
*
|
|
199
|
+
* @param date Day to test.
|
|
200
|
+
*/
|
|
201
|
+
isInPreviewRange(date: Date): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Whether `date` falls in the same month as {@link visibleMonth}. Useful
|
|
204
|
+
* for dimming the leading/trailing days a month grid renders from
|
|
205
|
+
* adjacent months.
|
|
206
|
+
*
|
|
207
|
+
* @param date Day to test.
|
|
208
|
+
*/
|
|
209
|
+
isInVisibleMonth(date: Date): boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Whether `date` falls outside the selectable bounds — before
|
|
212
|
+
* {@link min}, after {@link max}, or rejected by the `isDateDisabled`
|
|
213
|
+
* predicate.
|
|
214
|
+
*
|
|
215
|
+
* @param date Day to test.
|
|
216
|
+
*/
|
|
217
|
+
isDisabled(date: Date): boolean;
|
|
218
|
+
}
|