@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,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A calendar surface for choosing a start and end date as one connected
|
|
3
|
+
* range, sharing every header, grid, and row part with {@link Calendar} and
|
|
4
|
+
* layering range position on top of its day cell. Used bare, with no
|
|
5
|
+
* composed children, it renders a pair of native `<input type="date">`
|
|
6
|
+
* fields instead — start and end, each independently keyboard-operable —
|
|
7
|
+
* ready for the `calendarKeys()`/`rangePreview()` mixins a consumer attaches
|
|
8
|
+
* to turn the composed grid into a live, drag- or arrow-key-extended range.
|
|
9
|
+
*
|
|
10
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
11
|
+
* @copyright Sergio Xalambrí 2026
|
|
12
|
+
*/
|
|
13
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
14
|
+
import { Calendar } from "./calendar.js";
|
|
15
|
+
/**
|
|
16
|
+
* Prop types for {@link RangeCalendar} and its compound parts. Every part
|
|
17
|
+
* but {@link RangeCalendar.Cell} aliases {@link Calendar}'s matching part,
|
|
18
|
+
* sharing its header, grid, and row markup.
|
|
19
|
+
*/
|
|
20
|
+
export declare namespace RangeCalendar {
|
|
21
|
+
/**
|
|
22
|
+
* Semantic color role for the bare fallback pair's keyboard focus rings,
|
|
23
|
+
* mapped to `--ui-*` variables like {@link Calendar.Color}. The composed
|
|
24
|
+
* grid's day cells always use fixed semantic roles, regardless of this value.
|
|
25
|
+
*/
|
|
26
|
+
type Color = Calendar.Color;
|
|
27
|
+
/**
|
|
28
|
+
* Per-part styling for the bare fallback pair's two internally composed
|
|
29
|
+
* inputs, layered after each input's own built-in styling. Style the
|
|
30
|
+
* composed grid's parts through {@link Calendar}'s own compound parts.
|
|
31
|
+
*/
|
|
32
|
+
interface PartsProps {
|
|
33
|
+
/** Styling for the bare fallback's start-date input, rendered through {@link Input}. */
|
|
34
|
+
start?: TagProps<"input">["mix"];
|
|
35
|
+
/** Styling for the bare fallback's end-date input, rendered through {@link Input}. */
|
|
36
|
+
end?: TagProps<"input">["mix"];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Props accepted by {@link RangeCalendar}. Composing
|
|
40
|
+
* {@link RangeCalendar.Header} and {@link RangeCalendar.Grid} as `children`
|
|
41
|
+
* renders the visual month surface; omitting `children` renders a bare native `<input type="date">` pair from the fields below.
|
|
42
|
+
*/
|
|
43
|
+
interface Props extends TagProps<"div"> {
|
|
44
|
+
/** Semantic color role for the bare fallback pair's focus rings. Defaults to {@link DEFAULT_COLOR}. */
|
|
45
|
+
color?: Color;
|
|
46
|
+
/** Native `name` submitted with an enclosing form, read only by the bare fallback's start-date input. */
|
|
47
|
+
startName?: string;
|
|
48
|
+
/** Native `name` submitted with an enclosing form, read only by the bare fallback's end-date input. */
|
|
49
|
+
endName?: string;
|
|
50
|
+
/** Current start-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair a consumer tracks itself. */
|
|
51
|
+
startValue?: string;
|
|
52
|
+
/** Current end-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair a consumer tracks itself. */
|
|
53
|
+
endValue?: string;
|
|
54
|
+
/** Initial start-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair left to the platform's own uncontrolled state. */
|
|
55
|
+
startDefaultValue?: string;
|
|
56
|
+
/** Initial end-of-range value, in `YYYY-MM-DD` form, for a bare fallback pair left to the platform's own uncontrolled state. */
|
|
57
|
+
endDefaultValue?: string;
|
|
58
|
+
/** Earliest accepted date, in `YYYY-MM-DD` form, read by both of the bare fallback pair's inputs. */
|
|
59
|
+
min?: string;
|
|
60
|
+
/** Latest accepted date, in `YYYY-MM-DD` form, read by both of the bare fallback pair's inputs. */
|
|
61
|
+
max?: string;
|
|
62
|
+
/** Granularity, in days, both of the bare fallback pair's values must fall on. */
|
|
63
|
+
step?: number;
|
|
64
|
+
/** Marks both of the bare fallback pair's inputs required for their enclosing form. */
|
|
65
|
+
required?: boolean;
|
|
66
|
+
/** Marks both of the bare fallback pair's inputs inert and excluded from the tab order. */
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
/** Marks both of the bare fallback pair's inputs' values fixed, while keeping them focusable and included in form submission. */
|
|
69
|
+
readOnly?: boolean;
|
|
70
|
+
/** Native autofill hint for both of the bare fallback pair's inputs, e.g. `"bday"`. */
|
|
71
|
+
autoComplete?: string;
|
|
72
|
+
/** Accessible label for the bare fallback pair's start-date input. Read only when `children` is unset. */
|
|
73
|
+
startLabel?: string;
|
|
74
|
+
/** Accessible label for the bare fallback pair's end-date input. Read only when `children` is unset. */
|
|
75
|
+
endLabel?: string;
|
|
76
|
+
/** Per-part styling for the bare fallback pair's internally composed inputs. */
|
|
77
|
+
parts?: PartsProps;
|
|
78
|
+
}
|
|
79
|
+
/** Every prop {@link Calendar.HeaderProps} accepts, unchanged. */
|
|
80
|
+
interface HeaderProps extends Calendar.HeaderProps {
|
|
81
|
+
}
|
|
82
|
+
/** Every prop {@link Calendar.PreviousButtonProps} accepts, unchanged. */
|
|
83
|
+
interface PreviousButtonProps extends Calendar.PreviousButtonProps {
|
|
84
|
+
}
|
|
85
|
+
/** Every prop {@link Calendar.NextButtonProps} accepts, unchanged. */
|
|
86
|
+
interface NextButtonProps extends Calendar.NextButtonProps {
|
|
87
|
+
}
|
|
88
|
+
/** Every prop {@link Calendar.HeadingProps} accepts, unchanged. */
|
|
89
|
+
interface HeadingProps extends Calendar.HeadingProps {
|
|
90
|
+
}
|
|
91
|
+
/** Every prop {@link Calendar.GridProps} accepts, unchanged. */
|
|
92
|
+
interface GridProps extends Calendar.GridProps {
|
|
93
|
+
}
|
|
94
|
+
/** Every prop {@link Calendar.GridHeaderProps} accepts, unchanged. */
|
|
95
|
+
interface GridHeaderProps extends Calendar.GridHeaderProps {
|
|
96
|
+
}
|
|
97
|
+
/** Every prop {@link Calendar.RowProps} accepts, unchanged. */
|
|
98
|
+
interface RowProps extends Calendar.RowProps {
|
|
99
|
+
}
|
|
100
|
+
/** Every prop {@link Calendar.HeaderCellProps} accepts, unchanged. */
|
|
101
|
+
interface HeaderCellProps extends Calendar.HeaderCellProps {
|
|
102
|
+
}
|
|
103
|
+
/** Every prop {@link Calendar.GridBodyProps} accepts, unchanged. */
|
|
104
|
+
interface GridBodyProps extends Calendar.GridBodyProps {
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Every prop {@link Calendar.CellProps} accepts, unchanged. Set
|
|
108
|
+
* `data-selection-start` on the range's first day, `data-selection-end`
|
|
109
|
+
* on its last, and `aria-selected="true"` alone on the days between — each read straight off what the consumer sets on this instance.
|
|
110
|
+
*/
|
|
111
|
+
interface CellProps extends Calendar.CellProps {
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Renders {@link RangeCalendar}'s root through {@link Calendar}. Composing
|
|
116
|
+
* {@link RangeCalendar.Header} and {@link RangeCalendar.Grid} as `children`
|
|
117
|
+
* renders the visual month surface; omitting `children` renders a bare, script-free native `<input type="date">` pair from this instance's own fields.
|
|
118
|
+
*
|
|
119
|
+
* @param handle Runtime handle carrying the root element's props.
|
|
120
|
+
* @returns The render function producing the range calendar's markup.
|
|
121
|
+
* @example
|
|
122
|
+
* <RangeCalendar startLabel={t("form.stay.checkIn")} endLabel={t("form.stay.checkOut")} startName="checkIn" endName="checkOut" />
|
|
123
|
+
* @example
|
|
124
|
+
* <RangeCalendar aria-label={t("calendar.label")}>
|
|
125
|
+
* <RangeCalendar.Header>
|
|
126
|
+
* <RangeCalendar.PreviousButton aria-label={t("calendar.previous")} />
|
|
127
|
+
* <RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>
|
|
128
|
+
* <RangeCalendar.NextButton aria-label={t("calendar.next")} />
|
|
129
|
+
* </RangeCalendar.Header>
|
|
130
|
+
* <RangeCalendar.Grid aria-label={monthLabel}>
|
|
131
|
+
* <RangeCalendar.GridHeader>
|
|
132
|
+
* <RangeCalendar.Row>
|
|
133
|
+
* {weekdayLabels.map((day) => (
|
|
134
|
+
* <RangeCalendar.HeaderCell key={day}>{day}</RangeCalendar.HeaderCell>
|
|
135
|
+
* ))}
|
|
136
|
+
* </RangeCalendar.Row>
|
|
137
|
+
* </RangeCalendar.GridHeader>
|
|
138
|
+
* <RangeCalendar.GridBody>
|
|
139
|
+
* {weeks.map((week) => (
|
|
140
|
+
* <RangeCalendar.Row key={week[0].iso}>
|
|
141
|
+
* {week.map((day) => (
|
|
142
|
+
* <RangeCalendar.Cell
|
|
143
|
+
* key={day.iso}
|
|
144
|
+
* aria-selected={day.inRange ? "true" : undefined}
|
|
145
|
+
* data-selection-start={day.iso === range.start ? "" : undefined}
|
|
146
|
+
* data-selection-end={day.iso === range.end ? "" : undefined}
|
|
147
|
+
* >
|
|
148
|
+
* {day.label}
|
|
149
|
+
* </RangeCalendar.Cell>
|
|
150
|
+
* ))}
|
|
151
|
+
* </RangeCalendar.Row>
|
|
152
|
+
* ))}
|
|
153
|
+
* </RangeCalendar.GridBody>
|
|
154
|
+
* </RangeCalendar.Grid>
|
|
155
|
+
* </RangeCalendar>
|
|
156
|
+
*/
|
|
157
|
+
export declare function RangeCalendar(handle: Handle<RangeCalendar.Props>): () => import("remix/ui").RemixElement;
|
|
158
|
+
export declare namespace RangeCalendar {
|
|
159
|
+
var Header: (handle: Handle<Calendar.HeaderProps>) => () => import("remix/ui").RemixElement;
|
|
160
|
+
var PreviousButton: (handle: Handle<Calendar.PreviousButtonProps>) => () => import("remix/ui").RemixElement;
|
|
161
|
+
var NextButton: (handle: Handle<Calendar.NextButtonProps>) => () => import("remix/ui").RemixElement;
|
|
162
|
+
var Heading: (handle: Handle<Calendar.HeadingProps>) => () => import("remix/ui").RemixElement;
|
|
163
|
+
var Grid: (handle: Handle<Calendar.GridProps>) => () => import("remix/ui").RemixElement;
|
|
164
|
+
var GridHeader: (handle: Handle<Calendar.GridHeaderProps>) => () => import("remix/ui").RemixElement;
|
|
165
|
+
var Row: (handle: Handle<Calendar.RowProps>) => () => import("remix/ui").RemixElement;
|
|
166
|
+
var HeaderCell: (handle: Handle<Calendar.HeaderCellProps>) => () => import("remix/ui").RemixElement;
|
|
167
|
+
var GridBody: (handle: Handle<Calendar.GridBodyProps>) => () => import("remix/ui").RemixElement;
|
|
168
|
+
var Cell: (handle: Handle<RangeCalendar.CellProps>) => () => import("remix/ui").RemixElement;
|
|
169
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, fg } from "@sdxc/u/color";
|
|
3
|
+
import { roundedCorner } from "@sdxc/u/effects";
|
|
4
|
+
import { flex, gap, items } from "@sdxc/u/layout";
|
|
5
|
+
import { data, when } from "@sdxc/u/state";
|
|
6
|
+
import { attrs } from "remix/ui";
|
|
7
|
+
import { Calendar } from "./calendar.js";
|
|
8
|
+
import { Input } from "./input.js";
|
|
9
|
+
/** Semantic color role {@link RangeCalendar}'s bare fallback pair falls back to when `color` is omitted. */
|
|
10
|
+
const DEFAULT_COLOR = "neutral";
|
|
11
|
+
/**
|
|
12
|
+
* Renders {@link RangeCalendar}'s root through {@link Calendar}. Composing
|
|
13
|
+
* {@link RangeCalendar.Header} and {@link RangeCalendar.Grid} as `children`
|
|
14
|
+
* renders the visual month surface; omitting `children` renders a bare, script-free native `<input type="date">` pair from this instance's own fields.
|
|
15
|
+
*
|
|
16
|
+
* @param handle Runtime handle carrying the root element's props.
|
|
17
|
+
* @returns The render function producing the range calendar's markup.
|
|
18
|
+
* @example
|
|
19
|
+
* <RangeCalendar startLabel={t("form.stay.checkIn")} endLabel={t("form.stay.checkOut")} startName="checkIn" endName="checkOut" />
|
|
20
|
+
* @example
|
|
21
|
+
* <RangeCalendar aria-label={t("calendar.label")}>
|
|
22
|
+
* <RangeCalendar.Header>
|
|
23
|
+
* <RangeCalendar.PreviousButton aria-label={t("calendar.previous")} />
|
|
24
|
+
* <RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>
|
|
25
|
+
* <RangeCalendar.NextButton aria-label={t("calendar.next")} />
|
|
26
|
+
* </RangeCalendar.Header>
|
|
27
|
+
* <RangeCalendar.Grid aria-label={monthLabel}>
|
|
28
|
+
* <RangeCalendar.GridHeader>
|
|
29
|
+
* <RangeCalendar.Row>
|
|
30
|
+
* {weekdayLabels.map((day) => (
|
|
31
|
+
* <RangeCalendar.HeaderCell key={day}>{day}</RangeCalendar.HeaderCell>
|
|
32
|
+
* ))}
|
|
33
|
+
* </RangeCalendar.Row>
|
|
34
|
+
* </RangeCalendar.GridHeader>
|
|
35
|
+
* <RangeCalendar.GridBody>
|
|
36
|
+
* {weeks.map((week) => (
|
|
37
|
+
* <RangeCalendar.Row key={week[0].iso}>
|
|
38
|
+
* {week.map((day) => (
|
|
39
|
+
* <RangeCalendar.Cell
|
|
40
|
+
* key={day.iso}
|
|
41
|
+
* aria-selected={day.inRange ? "true" : undefined}
|
|
42
|
+
* data-selection-start={day.iso === range.start ? "" : undefined}
|
|
43
|
+
* data-selection-end={day.iso === range.end ? "" : undefined}
|
|
44
|
+
* >
|
|
45
|
+
* {day.label}
|
|
46
|
+
* </RangeCalendar.Cell>
|
|
47
|
+
* ))}
|
|
48
|
+
* </RangeCalendar.Row>
|
|
49
|
+
* ))}
|
|
50
|
+
* </RangeCalendar.GridBody>
|
|
51
|
+
* </RangeCalendar.Grid>
|
|
52
|
+
* </RangeCalendar>
|
|
53
|
+
*/
|
|
54
|
+
export function RangeCalendar(handle) {
|
|
55
|
+
return () => {
|
|
56
|
+
let { color, startName, endName, startValue, endValue, startDefaultValue, endDefaultValue, min, max, step, required, disabled, readOnly, autoComplete, startLabel, endLabel, parts, children, mix, ...rest } = handle.props;
|
|
57
|
+
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
58
|
+
if (import.meta.env.DEV && !children) {
|
|
59
|
+
if (!startLabel) {
|
|
60
|
+
console.warn('RangeCalendar: falling back to a plain "input type=date" pair needs a "startLabel" describing the range\'s start for assistive technology.');
|
|
61
|
+
}
|
|
62
|
+
if (!endLabel) {
|
|
63
|
+
console.warn('RangeCalendar: falling back to a plain "input type=date" pair needs an "endLabel" describing the range\'s end for assistive technology.');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return (_jsx(Calendar, { ...rest, mix: mix, children: children ?? (_jsxs("div", { "data-slot": "fields", mix: [attrs({ role: "group" }), flex(), items("center"), gap("0.5rem")], children: [_jsx(Input, { type: "date", "data-slot": "start-input", color: resolvedColor, name: startName, value: startValue, defaultValue: startDefaultValue, min: min, max: max, step: step, required: required, disabled: disabled, readOnly: readOnly, autoComplete: autoComplete, "aria-label": startLabel, mix: parts?.start }), _jsx(Input, { type: "date", "data-slot": "end-input", color: resolvedColor, name: endName, value: endValue, defaultValue: endDefaultValue, min: min, max: max, step: step, required: required, disabled: disabled, readOnly: readOnly, autoComplete: autoComplete, "aria-label": endLabel, mix: parts?.end })] })) }));
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Renders {@link RangeCalendar.HeaderProps.children} as the nav row: identical
|
|
71
|
+
* to {@link Calendar.Header}, since {@link RangeCalendar} reuses
|
|
72
|
+
* {@link Calendar}'s grid markup for its own header.
|
|
73
|
+
*
|
|
74
|
+
* @param handle Runtime handle carrying the host `<header>`'s props.
|
|
75
|
+
* @returns The render function producing the nav row's markup.
|
|
76
|
+
* @example
|
|
77
|
+
* <RangeCalendar.Header>
|
|
78
|
+
* <RangeCalendar.PreviousButton aria-label={t("calendar.previous")} />
|
|
79
|
+
* <RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>
|
|
80
|
+
* <RangeCalendar.NextButton aria-label={t("calendar.next")} />
|
|
81
|
+
* </RangeCalendar.Header>
|
|
82
|
+
*/
|
|
83
|
+
RangeCalendar.Header = Calendar.Header;
|
|
84
|
+
/**
|
|
85
|
+
* Renders a control standing for "show the previous month": identical to
|
|
86
|
+
* {@link Calendar.PreviousButton}.
|
|
87
|
+
*
|
|
88
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
89
|
+
* @returns The render function producing the control's markup.
|
|
90
|
+
* @example
|
|
91
|
+
* <RangeCalendar.PreviousButton aria-label={t("calendar.previous")} />
|
|
92
|
+
*/
|
|
93
|
+
RangeCalendar.PreviousButton = Calendar.PreviousButton;
|
|
94
|
+
/**
|
|
95
|
+
* Renders a control standing for "show the following month": identical to
|
|
96
|
+
* {@link Calendar.NextButton}.
|
|
97
|
+
*
|
|
98
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
99
|
+
* @returns The render function producing the control's markup.
|
|
100
|
+
* @example
|
|
101
|
+
* <RangeCalendar.NextButton aria-label={t("calendar.next")} />
|
|
102
|
+
*/
|
|
103
|
+
RangeCalendar.NextButton = Calendar.NextButton;
|
|
104
|
+
/**
|
|
105
|
+
* Renders the calendar's visible month/year caption: identical to
|
|
106
|
+
* {@link Calendar.Heading}.
|
|
107
|
+
*
|
|
108
|
+
* @param handle Runtime handle carrying the host heading element's props.
|
|
109
|
+
* @returns The render function producing the caption's markup.
|
|
110
|
+
* @example
|
|
111
|
+
* <RangeCalendar.Heading>{monthLabel}</RangeCalendar.Heading>
|
|
112
|
+
*/
|
|
113
|
+
RangeCalendar.Heading = Calendar.Heading;
|
|
114
|
+
/**
|
|
115
|
+
* Renders the day grid's native `<table>` host: identical to
|
|
116
|
+
* {@link Calendar.Grid}.
|
|
117
|
+
*
|
|
118
|
+
* @param handle Runtime handle carrying the host `<table>`'s props.
|
|
119
|
+
* @returns The render function producing the grid's markup.
|
|
120
|
+
* @example
|
|
121
|
+
* <RangeCalendar.Grid aria-label={monthLabel}>
|
|
122
|
+
* <RangeCalendar.GridHeader>...</RangeCalendar.GridHeader>
|
|
123
|
+
* <RangeCalendar.GridBody>...</RangeCalendar.GridBody>
|
|
124
|
+
* </RangeCalendar.Grid>
|
|
125
|
+
*/
|
|
126
|
+
RangeCalendar.Grid = Calendar.Grid;
|
|
127
|
+
/**
|
|
128
|
+
* Renders the grid's `<thead>` host: identical to {@link Calendar.GridHeader}.
|
|
129
|
+
*
|
|
130
|
+
* @param handle Runtime handle carrying the host `<thead>`'s props.
|
|
131
|
+
* @returns The render function producing the header section's markup.
|
|
132
|
+
* @example
|
|
133
|
+
* <RangeCalendar.GridHeader>
|
|
134
|
+
* <RangeCalendar.Row>
|
|
135
|
+
* <RangeCalendar.HeaderCell>{t("calendar.weekdays.sun")}</RangeCalendar.HeaderCell>
|
|
136
|
+
* </RangeCalendar.Row>
|
|
137
|
+
* </RangeCalendar.GridHeader>
|
|
138
|
+
*/
|
|
139
|
+
RangeCalendar.GridHeader = Calendar.GridHeader;
|
|
140
|
+
/**
|
|
141
|
+
* Renders a native `<tr>` host: identical to {@link Calendar.Row}. Composes
|
|
142
|
+
* a row of {@link RangeCalendar.HeaderCell} inside
|
|
143
|
+
* {@link RangeCalendar.GridHeader}, or a week's row of {@link RangeCalendar.Cell} inside {@link RangeCalendar.GridBody}.
|
|
144
|
+
*
|
|
145
|
+
* @param handle Runtime handle carrying the host `<tr>`'s props.
|
|
146
|
+
* @returns The render function producing the row's markup.
|
|
147
|
+
* @example
|
|
148
|
+
* <RangeCalendar.Row>
|
|
149
|
+
* <RangeCalendar.Cell>{day.label}</RangeCalendar.Cell>
|
|
150
|
+
* </RangeCalendar.Row>
|
|
151
|
+
*/
|
|
152
|
+
RangeCalendar.Row = Calendar.Row;
|
|
153
|
+
/**
|
|
154
|
+
* Renders a weekday abbreviation: identical to {@link Calendar.HeaderCell}.
|
|
155
|
+
*
|
|
156
|
+
* @param handle Runtime handle carrying the host `<th>`'s props.
|
|
157
|
+
* @returns The render function producing the weekday header's markup.
|
|
158
|
+
* @example
|
|
159
|
+
* <RangeCalendar.HeaderCell>{t("calendar.weekdays.sun")}</RangeCalendar.HeaderCell>
|
|
160
|
+
*/
|
|
161
|
+
RangeCalendar.HeaderCell = Calendar.HeaderCell;
|
|
162
|
+
/**
|
|
163
|
+
* Renders the grid's `<tbody>` host: identical to {@link Calendar.GridBody}.
|
|
164
|
+
*
|
|
165
|
+
* @param handle Runtime handle carrying the host `<tbody>`'s props.
|
|
166
|
+
* @returns The render function producing the body section's markup.
|
|
167
|
+
* @example
|
|
168
|
+
* <RangeCalendar.GridBody>
|
|
169
|
+
* {weeks.map((week) => (
|
|
170
|
+
* <RangeCalendar.Row key={week[0].iso}>...</RangeCalendar.Row>
|
|
171
|
+
* ))}
|
|
172
|
+
* </RangeCalendar.GridBody>
|
|
173
|
+
*/
|
|
174
|
+
RangeCalendar.GridBody = Calendar.GridBody;
|
|
175
|
+
/**
|
|
176
|
+
* Renders one calendar day for {@link RangeCalendar}, building on
|
|
177
|
+
* {@link Calendar.Cell}. `data-selection-start`/`data-selection-end`
|
|
178
|
+
* square off each end's outer corners so the range reads as one unbroken bar, driven by whatever state the consumer sets for the `calendarKeys()`/`rangePreview()` mixins.
|
|
179
|
+
*
|
|
180
|
+
* @param handle Runtime handle carrying the host `<td>`'s props.
|
|
181
|
+
* @returns The render function producing the day's markup.
|
|
182
|
+
* @example
|
|
183
|
+
* <RangeCalendar.Cell data-selection-start="">{day.label}</RangeCalendar.Cell>
|
|
184
|
+
* @example
|
|
185
|
+
* <RangeCalendar.Cell aria-selected="true">{day.label}</RangeCalendar.Cell>
|
|
186
|
+
* @example
|
|
187
|
+
* <RangeCalendar.Cell data-selection-end="">{day.label}</RangeCalendar.Cell>
|
|
188
|
+
*/
|
|
189
|
+
RangeCalendar.Cell = function RangeCalendarCell(handle) {
|
|
190
|
+
return () => {
|
|
191
|
+
let { mix, ...rest } = handle.props;
|
|
192
|
+
return (_jsx(Calendar.Cell, { ...rest, mix: [
|
|
193
|
+
data("selection-start", [
|
|
194
|
+
bg("brand.solid"),
|
|
195
|
+
fg("brand.onSolid"),
|
|
196
|
+
roundedCorner("start-end", "none"),
|
|
197
|
+
roundedCorner("end-end", "none"),
|
|
198
|
+
]),
|
|
199
|
+
data("selection-end", [
|
|
200
|
+
bg("brand.solid"),
|
|
201
|
+
fg("brand.onSolid"),
|
|
202
|
+
roundedCorner("start-start", "none"),
|
|
203
|
+
roundedCorner("end-start", "none"),
|
|
204
|
+
]),
|
|
205
|
+
when('&[aria-selected="true"]:not([data-selection-start]):not([data-selection-end])', [
|
|
206
|
+
bg("brand.tint"),
|
|
207
|
+
fg("brand.emphasis"),
|
|
208
|
+
roundedCorner("start-start", "none"),
|
|
209
|
+
roundedCorner("start-end", "none"),
|
|
210
|
+
roundedCorner("end-start", "none"),
|
|
211
|
+
roundedCorner("end-end", "none"),
|
|
212
|
+
]),
|
|
213
|
+
mix,
|
|
214
|
+
] }));
|
|
215
|
+
};
|
|
216
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A split-pane layout arranging {@link Resizable.Panel} and
|
|
3
|
+
* {@link Resizable.Handle} parts along a shared axis, each panel taking up
|
|
4
|
+
* its own declared share of the group's main axis and each handle between
|
|
5
|
+
* two panels reserving a fixed track across the cross axis. Every part
|
|
6
|
+
* mirrors the root's orientation onto itself through component context, so a
|
|
7
|
+
* panel's own minimum and maximum share and a handle's cursor and track both
|
|
8
|
+
* switch axis together without a consumer repeating the orientation on each
|
|
9
|
+
* one.
|
|
10
|
+
*
|
|
11
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
12
|
+
* @copyright Sergio Xalambrí 2026
|
|
13
|
+
*/
|
|
14
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
15
|
+
/**
|
|
16
|
+
* Prop types for {@link Resizable} and its compound parts.
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace Resizable {
|
|
19
|
+
/**
|
|
20
|
+
* Axis the panels lay out along: a row of panels side by side, or a
|
|
21
|
+
* column of panels stacked one above another.
|
|
22
|
+
*/
|
|
23
|
+
type Orientation = "horizontal" | "vertical";
|
|
24
|
+
/**
|
|
25
|
+
* Value {@link Resizable} stores in component context so every
|
|
26
|
+
* {@link Resizable.Panel} and {@link Resizable.Handle} nested inside reads
|
|
27
|
+
* the same axis for its own `data-orientation`, sizing, and cursor.
|
|
28
|
+
*/
|
|
29
|
+
interface Context {
|
|
30
|
+
/** The root's resolved layout axis. */
|
|
31
|
+
orientation: Orientation;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Props accepted by {@link Resizable}.
|
|
35
|
+
*/
|
|
36
|
+
interface Props extends TagProps<"div"> {
|
|
37
|
+
/** Layout axis. Defaults to {@link DEFAULT_ORIENTATION}. */
|
|
38
|
+
orientation?: Orientation;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Props accepted by {@link Resizable.Panel}.
|
|
42
|
+
*/
|
|
43
|
+
interface PanelProps extends TagProps<"div"> {
|
|
44
|
+
/**
|
|
45
|
+
* Starting share of the group's main axis, as a percentage (e.g. `30`
|
|
46
|
+
* for 30%). Panels left without one split whatever share remains
|
|
47
|
+
* evenly among themselves.
|
|
48
|
+
*/
|
|
49
|
+
defaultSize?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Smallest share of the group's main axis this panel will shrink to,
|
|
52
|
+
* as a percentage. Left unset, the panel can shrink down to nothing.
|
|
53
|
+
*/
|
|
54
|
+
minSize?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Largest share of the group's main axis this panel will grow to, as
|
|
57
|
+
* a percentage. Left unset, the panel can grow up to the group's
|
|
58
|
+
* entire main axis.
|
|
59
|
+
*/
|
|
60
|
+
maxSize?: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Props accepted by {@link Resizable.Handle}. Its accessible name comes
|
|
64
|
+
* entirely from `aria-label` or `aria-labelledby`; pair it with
|
|
65
|
+
* `aria-controls` naming the panels on either side.
|
|
66
|
+
*/
|
|
67
|
+
interface HandleProps extends TagProps<"div"> {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Renders the root host: a `<div>` laying {@link Resizable.Panel} and
|
|
72
|
+
* {@link Resizable.Handle} children out in a row, or a column when
|
|
73
|
+
* `orientation` is `"vertical"`, sharing the resolved axis through context; set `aria-disabled="true"` to dim the whole group.
|
|
74
|
+
*
|
|
75
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link Resizable.Context}.
|
|
76
|
+
* @returns The render function producing the root's markup.
|
|
77
|
+
* @example
|
|
78
|
+
* <Resizable aria-label={t("layout.panes")}>
|
|
79
|
+
* <Resizable.Panel id="sidebar" defaultSize={30} minSize={15}>
|
|
80
|
+
* {t("layout.sidebar")}
|
|
81
|
+
* </Resizable.Panel>
|
|
82
|
+
* <Resizable.Handle aria-label={t("layout.resizeSidebar")} aria-controls="sidebar main" />
|
|
83
|
+
* <Resizable.Panel id="main" defaultSize={70}>
|
|
84
|
+
* {t("layout.main")}
|
|
85
|
+
* </Resizable.Panel>
|
|
86
|
+
* </Resizable>
|
|
87
|
+
* @example
|
|
88
|
+
* <Resizable orientation="vertical" aria-label={t("layout.panes")}>
|
|
89
|
+
* <Resizable.Panel defaultSize={60}>{t("layout.top")}</Resizable.Panel>
|
|
90
|
+
* <Resizable.Handle aria-label={t("layout.resizeVertically")} />
|
|
91
|
+
* <Resizable.Panel defaultSize={40}>{t("layout.bottom")}</Resizable.Panel>
|
|
92
|
+
* </Resizable>
|
|
93
|
+
*/
|
|
94
|
+
export declare function Resizable(handle: Handle<Resizable.Props, Resizable.Context>): () => import("remix/ui").RemixElement;
|
|
95
|
+
export declare namespace Resizable {
|
|
96
|
+
var Panel: (handle: Handle<Resizable.PanelProps>) => () => import("remix/ui").RemixElement;
|
|
97
|
+
var Handle: (handle: Handle<Resizable.HandleProps>) => () => import("remix/ui").RemixElement;
|
|
98
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, border, fg, outline, outlineStyle } from "@sdxc/u/color";
|
|
3
|
+
import { opacity, rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, raw, touchAction, userSelect } from "@sdxc/u/general";
|
|
5
|
+
import { basis, flex, flexCol, flexRow, grow, items, justify, relative, shrink, } from "@sdxc/u/layout";
|
|
6
|
+
import { overflow } from "@sdxc/u/overflow";
|
|
7
|
+
import { bs, is, maxBs, maxIs, minBs, minIs } from "@sdxc/u/size";
|
|
8
|
+
import { before, data, focusVisible, hover, when } from "@sdxc/u/state";
|
|
9
|
+
import { attrs } from "remix/ui";
|
|
10
|
+
import { mergeStyle } from "../utils/merge-style.js";
|
|
11
|
+
/** Default {@link Resizable.Props} orientation, applied when `orientation` is omitted. */
|
|
12
|
+
const DEFAULT_ORIENTATION = "horizontal";
|
|
13
|
+
/** `role="separator"` applied to {@link Resizable.Handle} through {@link attrs} unless a consumer supplies its own `role`. */
|
|
14
|
+
const DEFAULT_HANDLE_ROLE = "separator";
|
|
15
|
+
/**
|
|
16
|
+
* Default {@link Resizable.HandleProps} tab index, applied through
|
|
17
|
+
* {@link attrs} unless a consumer supplies its own, keeping a handle
|
|
18
|
+
* reachable in Tab order per the WAI-ARIA window splitter pattern.
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_HANDLE_TAB_INDEX = 0;
|
|
21
|
+
/**
|
|
22
|
+
* Renders the root host: a `<div>` laying {@link Resizable.Panel} and
|
|
23
|
+
* {@link Resizable.Handle} children out in a row, or a column when
|
|
24
|
+
* `orientation` is `"vertical"`, sharing the resolved axis through context; set `aria-disabled="true"` to dim the whole group.
|
|
25
|
+
*
|
|
26
|
+
* @param handle Runtime handle carrying the host `<div>`'s props and providing {@link Resizable.Context}.
|
|
27
|
+
* @returns The render function producing the root's markup.
|
|
28
|
+
* @example
|
|
29
|
+
* <Resizable aria-label={t("layout.panes")}>
|
|
30
|
+
* <Resizable.Panel id="sidebar" defaultSize={30} minSize={15}>
|
|
31
|
+
* {t("layout.sidebar")}
|
|
32
|
+
* </Resizable.Panel>
|
|
33
|
+
* <Resizable.Handle aria-label={t("layout.resizeSidebar")} aria-controls="sidebar main" />
|
|
34
|
+
* <Resizable.Panel id="main" defaultSize={70}>
|
|
35
|
+
* {t("layout.main")}
|
|
36
|
+
* </Resizable.Panel>
|
|
37
|
+
* </Resizable>
|
|
38
|
+
* @example
|
|
39
|
+
* <Resizable orientation="vertical" aria-label={t("layout.panes")}>
|
|
40
|
+
* <Resizable.Panel defaultSize={60}>{t("layout.top")}</Resizable.Panel>
|
|
41
|
+
* <Resizable.Handle aria-label={t("layout.resizeVertically")} />
|
|
42
|
+
* <Resizable.Panel defaultSize={40}>{t("layout.bottom")}</Resizable.Panel>
|
|
43
|
+
* </Resizable>
|
|
44
|
+
*/
|
|
45
|
+
export function Resizable(handle) {
|
|
46
|
+
return () => {
|
|
47
|
+
let { orientation, mix, ...rest } = handle.props;
|
|
48
|
+
let resolvedOrientation = orientation ?? DEFAULT_ORIENTATION;
|
|
49
|
+
handle.context.set({ orientation: resolvedOrientation });
|
|
50
|
+
return (_jsx("div", { "data-orientation": resolvedOrientation, ...rest, mix: [
|
|
51
|
+
flex(),
|
|
52
|
+
flexRow(),
|
|
53
|
+
is("full"),
|
|
54
|
+
overflow("hidden"),
|
|
55
|
+
when('&[data-orientation="vertical"]', flexCol()),
|
|
56
|
+
when('&[aria-disabled="true"]', opacity(70)),
|
|
57
|
+
rounded("lg"),
|
|
58
|
+
border({ color: "neutral", width: 1 }),
|
|
59
|
+
bg("neutral.tint"),
|
|
60
|
+
mix,
|
|
61
|
+
] }));
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Renders a single pane: a `<div>` that grows and shrinks to fill its share
|
|
66
|
+
* of the group's main axis, clipping overflow with scrolling. Each of
|
|
67
|
+
* `defaultSize`/`minSize`/`maxSize` lives on a `--ui-resizable-panel-*` custom property a pointer-tracking behavior can update to resize it live.
|
|
68
|
+
*
|
|
69
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
70
|
+
* @returns The render function producing the pane's markup.
|
|
71
|
+
* @example
|
|
72
|
+
* <Resizable.Panel defaultSize={30} minSize={15} maxSize={50}>
|
|
73
|
+
* {t("layout.sidebar")}
|
|
74
|
+
* </Resizable.Panel>
|
|
75
|
+
*/
|
|
76
|
+
Resizable.Panel = function ResizablePanel(handle) {
|
|
77
|
+
return () => {
|
|
78
|
+
let { mix, style, defaultSize, minSize, maxSize, ...rest } = handle.props;
|
|
79
|
+
let context = handle.context.get(Resizable);
|
|
80
|
+
let resolvedStyle = mergeStyle(style, {
|
|
81
|
+
"--ui-resizable-panel-size": defaultSize == null ? null : `${defaultSize}%`,
|
|
82
|
+
"--ui-resizable-panel-min-size": minSize == null ? null : `${minSize}%`,
|
|
83
|
+
"--ui-resizable-panel-max-size": maxSize == null ? null : `${maxSize}%`,
|
|
84
|
+
});
|
|
85
|
+
return (_jsx("div", { "data-orientation": context.orientation, "data-default-size": defaultSize, "data-min-size": minSize, "data-max-size": maxSize, ...rest, style: resolvedStyle, mix: [
|
|
86
|
+
grow(),
|
|
87
|
+
shrink(1),
|
|
88
|
+
basis("var(--ui-resizable-panel-size, 0%)"),
|
|
89
|
+
minBs(0),
|
|
90
|
+
minIs(0),
|
|
91
|
+
data("orientation", "horizontal", [
|
|
92
|
+
minIs("var(--ui-resizable-panel-min-size, 0%)"),
|
|
93
|
+
maxIs("var(--ui-resizable-panel-max-size, 100%)"),
|
|
94
|
+
]),
|
|
95
|
+
data("orientation", "vertical", [
|
|
96
|
+
minBs("var(--ui-resizable-panel-min-size, 0%)"),
|
|
97
|
+
maxBs("var(--ui-resizable-panel-max-size, 100%)"),
|
|
98
|
+
]),
|
|
99
|
+
overflow("auto"),
|
|
100
|
+
mix,
|
|
101
|
+
] }));
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Renders a draggable divider between two adjacent panels: a
|
|
106
|
+
* `role="separator"` `<div>` reachable in Tab order, its bar darkening on
|
|
107
|
+
* hover and ready for `&[data-resizing]` to color it during a drag. Its accessible name comes entirely from `aria-label`/`aria-labelledby`, paired with `aria-controls` naming the panels it resizes.
|
|
108
|
+
*
|
|
109
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
110
|
+
* @returns The render function producing the handle's markup.
|
|
111
|
+
* @example
|
|
112
|
+
* <Resizable.Handle aria-label={t("layout.resizeSidebar")} aria-controls="sidebar main" />
|
|
113
|
+
* @example
|
|
114
|
+
* <Resizable.Handle aria-label={t("layout.resizeSidebar")} aria-disabled="true" />
|
|
115
|
+
*/
|
|
116
|
+
Resizable.Handle = function ResizableHandle(handle) {
|
|
117
|
+
return () => {
|
|
118
|
+
let { mix, ...rest } = handle.props;
|
|
119
|
+
let context = handle.context.get(Resizable);
|
|
120
|
+
if (import.meta.env.DEV && !rest["aria-label"] && !rest["aria-labelledby"]) {
|
|
121
|
+
console.warn("Resizable.Handle: a resize handle with no `aria-label` or `aria-labelledby` needs one describing what it resizes — assistive technology has no accessible name to announce otherwise.");
|
|
122
|
+
}
|
|
123
|
+
return (_jsx("div", { "data-orientation": context.orientation, "aria-orientation": context.orientation, ...rest, mix: [
|
|
124
|
+
attrs({ role: DEFAULT_HANDLE_ROLE, tabIndex: DEFAULT_HANDLE_TAB_INDEX }),
|
|
125
|
+
relative(),
|
|
126
|
+
flex(),
|
|
127
|
+
grow(0),
|
|
128
|
+
shrink(0),
|
|
129
|
+
basis("var(--ui-resizable-handle-size, 0.75rem)"),
|
|
130
|
+
items("center"),
|
|
131
|
+
justify("center"),
|
|
132
|
+
bg("transparent"),
|
|
133
|
+
userSelect(),
|
|
134
|
+
touchAction(),
|
|
135
|
+
outlineStyle("none"),
|
|
136
|
+
when('&[data-orientation="horizontal"]', cursor("col-resize")),
|
|
137
|
+
when('&[data-orientation="vertical"]', cursor("row-resize")),
|
|
138
|
+
/** `raw()` sets the bare CSS `content` property directly, its only utility path. */
|
|
139
|
+
before(raw({ content: '""' })),
|
|
140
|
+
data("orientation", "horizontal", before([bs("2.5rem"), is("0.125rem")])),
|
|
141
|
+
data("orientation", "vertical", before([bs("0.125rem"), is("2.5rem")])),
|
|
142
|
+
when('&[aria-disabled="true"]', [cursor("not-allowed"), opacity(50)]),
|
|
143
|
+
fg("neutral.muted"),
|
|
144
|
+
when("&::before", [rounded("full"), bg("neutral.border")]),
|
|
145
|
+
hover(when("&::before", bg("neutral.strong"))),
|
|
146
|
+
when("&[data-resizing]::before", bg("brand.solid")),
|
|
147
|
+
focusVisible(outline({ color: "brand.ring" })),
|
|
148
|
+
mix,
|
|
149
|
+
] }));
|
|
150
|
+
};
|
|
151
|
+
};
|