@rivetjs/cdk 0.0.0-stage → 0.1.0-alpha.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/LICENSE +21 -0
- package/NOTICE +483 -0
- package/README.md +10 -2
- package/_adapters/collection.d.ts +160 -0
- package/_adapters/collection.js +235 -0
- package/_adapters/collections.d.ts +325 -0
- package/_adapters/collections.js +934 -0
- package/_adapters/dom-collection.d.ts +42 -0
- package/_adapters/dom-collection.js +228 -0
- package/_adapters/grid-selection.d.ts +115 -0
- package/_adapters/grid-selection.js +436 -0
- package/_adapters/interactions.d.ts +19 -0
- package/_adapters/interactions.js +45 -0
- package/_adapters/intl.d.ts +8 -0
- package/_adapters/intl.js +106 -0
- package/_adapters/press.d.ts +22 -0
- package/_adapters/press.js +34 -0
- package/_adapters/selectable.d.ts +132 -0
- package/_adapters/selectable.js +599 -0
- package/_adapters/selection.d.ts +109 -0
- package/_adapters/selection.js +685 -0
- package/_adapters/type-select.d.ts +8 -0
- package/_adapters/type-select.js +59 -0
- package/a11y/aria-describer.d.ts +46 -0
- package/a11y/aria-describer.js +169 -0
- package/a11y/focus-monitor.d.ts +98 -0
- package/a11y/focus-monitor.js +321 -0
- package/a11y/focus-trap.d.ts +137 -0
- package/a11y/focus-trap.js +378 -0
- package/a11y/high-contrast.d.ts +26 -0
- package/a11y/high-contrast.js +84 -0
- package/a11y/index.d.ts +37 -0
- package/a11y/index.js +97 -0
- package/a11y/interactivity-checker.d.ts +18 -0
- package/a11y/interactivity-checker.js +126 -0
- package/a11y/key-manager.d.ts +152 -0
- package/a11y/key-manager.js +397 -0
- package/a11y/live-announcer.d.ts +53 -0
- package/a11y/live-announcer.js +143 -0
- package/accordion/index.d.ts +2 -0
- package/accordion/index.jsx +10 -0
- package/announcer/index.d.ts +8 -0
- package/announcer/index.jsx +22 -0
- package/announcer/live-announcer.d.ts +15 -0
- package/announcer/live-announcer.js +123 -0
- package/autocomplete/behaviour.d.ts +94 -0
- package/autocomplete/behaviour.jsx +423 -0
- package/autocomplete/contexts.d.ts +54 -0
- package/autocomplete/contexts.js +28 -0
- package/autocomplete/index.d.ts +12 -0
- package/autocomplete/index.jsx +31 -0
- package/autocomplete/intl.d.ts +2 -0
- package/autocomplete/intl.js +36 -0
- package/bidi/bidi-dir.d.ts +23 -0
- package/bidi/bidi-dir.jsx +36 -0
- package/bidi/index.d.ts +58 -0
- package/bidi/index.js +84 -0
- package/breadcrumbs/behaviour.d.ts +6 -0
- package/breadcrumbs/behaviour.js +17 -0
- package/breadcrumbs/index.d.ts +68 -0
- package/breadcrumbs/index.jsx +224 -0
- package/breadcrumbs/intl.d.ts +3 -0
- package/breadcrumbs/intl.js +104 -0
- package/button/behaviour.d.ts +61 -0
- package/button/behaviour.js +90 -0
- package/button/index.d.ts +38 -0
- package/button/index.jsx +374 -0
- package/button/press.d.ts +25 -0
- package/button/press.js +54 -0
- package/calendar/behaviour.d.ts +250 -0
- package/calendar/behaviour.jsx +939 -0
- package/calendar/index.d.ts +157 -0
- package/calendar/index.jsx +484 -0
- package/calendar/intl.d.ts +3 -0
- package/calendar/intl.js +36 -0
- package/carousel/behaviour.d.ts +50 -0
- package/carousel/behaviour.jsx +365 -0
- package/carousel/engine/Alignment.d.ts +5 -0
- package/carousel/engine/Alignment.js +24 -0
- package/carousel/engine/Animations.d.ts +13 -0
- package/carousel/engine/Animations.js +28 -0
- package/carousel/engine/Axis.d.ts +14 -0
- package/carousel/engine/Axis.js +35 -0
- package/carousel/engine/Counter.d.ts +7 -0
- package/carousel/engine/Counter.js +32 -0
- package/carousel/engine/DragHandler.d.ts +22 -0
- package/carousel/engine/DragHandler.js +141 -0
- package/carousel/engine/DragTracker.d.ts +10 -0
- package/carousel/engine/DragTracker.js +29 -0
- package/carousel/engine/EmblaCarousel.d.ts +32 -0
- package/carousel/engine/EmblaCarousel.js +177 -0
- package/carousel/engine/Engine.d.ts +64 -0
- package/carousel/engine/Engine.js +137 -0
- package/carousel/engine/EventHandler.d.ts +27 -0
- package/carousel/engine/EventHandler.js +33 -0
- package/carousel/engine/EventStore.d.ts +9 -0
- package/carousel/engine/EventStore.js +25 -0
- package/carousel/engine/NodeRects.d.ts +12 -0
- package/carousel/engine/NodeRects.js +18 -0
- package/carousel/engine/Options.d.ts +40 -0
- package/carousel/engine/Options.js +22 -0
- package/carousel/engine/OptionsHandler.d.ts +10 -0
- package/carousel/engine/OptionsHandler.js +26 -0
- package/carousel/engine/PercentOfView.d.ts +4 -0
- package/carousel/engine/PercentOfView.js +9 -0
- package/carousel/engine/Plugins.d.ts +16 -0
- package/carousel/engine/Plugins.js +1 -0
- package/carousel/engine/PluginsHandler.d.ts +8 -0
- package/carousel/engine/PluginsHandler.js +16 -0
- package/carousel/engine/ResizeHandler.d.ts +13 -0
- package/carousel/engine/ResizeHandler.js +51 -0
- package/carousel/engine/ScrollBounds.d.ts +10 -0
- package/carousel/engine/ScrollBounds.js +41 -0
- package/carousel/engine/ScrollContain.d.ts +7 -0
- package/carousel/engine/ScrollContain.js +52 -0
- package/carousel/engine/ScrollLimit.d.ts +5 -0
- package/carousel/engine/ScrollLimit.js +13 -0
- package/carousel/engine/ScrollLooper.d.ts +6 -0
- package/carousel/engine/ScrollLooper.js +26 -0
- package/carousel/engine/ScrollProgress.d.ts +5 -0
- package/carousel/engine/ScrollProgress.js +11 -0
- package/carousel/engine/ScrollSnaps.d.ts +9 -0
- package/carousel/engine/ScrollSnaps.js +26 -0
- package/carousel/engine/ScrollTarget.d.ts +12 -0
- package/carousel/engine/ScrollTarget.js +47 -0
- package/carousel/engine/ScrollTo.d.ts +11 -0
- package/carousel/engine/ScrollTo.js +36 -0
- package/carousel/engine/SlideFocus.d.ts +13 -0
- package/carousel/engine/SlideFocus.js +39 -0
- package/carousel/engine/SlideLooper.d.ts +18 -0
- package/carousel/engine/SlideLooper.js +78 -0
- package/carousel/engine/SlideRegistry.d.ts +7 -0
- package/carousel/engine/SlideRegistry.js +31 -0
- package/carousel/engine/SlideSizes.d.ts +10 -0
- package/carousel/engine/SlideSizes.js +41 -0
- package/carousel/engine/SlidesHandler.d.ts +10 -0
- package/carousel/engine/SlidesHandler.js +36 -0
- package/carousel/engine/SlidesInView.d.ts +8 -0
- package/carousel/engine/SlidesInView.js +59 -0
- package/carousel/engine/SlidesToScroll.d.ts +7 -0
- package/carousel/engine/SlidesToScroll.js +41 -0
- package/carousel/engine/Translate.d.ts +7 -0
- package/carousel/engine/Translate.js +38 -0
- package/carousel/engine/index.d.ts +11 -0
- package/carousel/engine/index.js +1 -0
- package/carousel/engine/utils.d.ts +15 -0
- package/carousel/engine/utils.js +45 -0
- package/carousel/index.d.ts +202 -0
- package/carousel/index.jsx +469 -0
- package/carousel/plugins/auto-height/AutoHeight.d.ts +14 -0
- package/carousel/plugins/auto-height/AutoHeight.js +43 -0
- package/carousel/plugins/auto-height/Options.d.ts +2 -0
- package/carousel/plugins/auto-height/Options.js +1 -0
- package/carousel/plugins/auto-height/index.d.ts +2 -0
- package/carousel/plugins/auto-height/index.js +1 -0
- package/carousel/plugins/auto-scroll/AutoScroll.d.ts +25 -0
- package/carousel/plugins/auto-scroll/AutoScroll.js +185 -0
- package/carousel/plugins/auto-scroll/Options.d.ts +13 -0
- package/carousel/plugins/auto-scroll/Options.js +12 -0
- package/carousel/plugins/auto-scroll/index.d.ts +2 -0
- package/carousel/plugins/auto-scroll/index.js +1 -0
- package/carousel/plugins/auto-scroll/utils.d.ts +3 -0
- package/carousel/plugins/auto-scroll/utils.js +4 -0
- package/carousel/plugins/autoplay/Autoplay.d.ts +29 -0
- package/carousel/plugins/autoplay/Autoplay.js +173 -0
- package/carousel/plugins/autoplay/Options.d.ts +14 -0
- package/carousel/plugins/autoplay/Options.js +12 -0
- package/carousel/plugins/autoplay/index.d.ts +2 -0
- package/carousel/plugins/autoplay/index.js +1 -0
- package/carousel/plugins/autoplay/utils.d.ts +4 -0
- package/carousel/plugins/autoplay/utils.js +11 -0
- package/carousel/plugins/class-names/ClassNames.d.ts +14 -0
- package/carousel/plugins/class-names/ClassNames.js +98 -0
- package/carousel/plugins/class-names/Options.d.ts +13 -0
- package/carousel/plugins/class-names/Options.js +9 -0
- package/carousel/plugins/class-names/index.d.ts +2 -0
- package/carousel/plugins/class-names/index.js +1 -0
- package/carousel/plugins/class-names/utils.d.ts +4 -0
- package/carousel/plugins/class-names/utils.js +14 -0
- package/carousel/plugins/fade/Fade.d.ts +14 -0
- package/carousel/plugins/fade/Fade.js +199 -0
- package/carousel/plugins/fade/Options.d.ts +2 -0
- package/carousel/plugins/fade/Options.js +1 -0
- package/carousel/plugins/fade/index.d.ts +2 -0
- package/carousel/plugins/fade/index.js +1 -0
- package/carousel/plugins/fade/utils.d.ts +2 -0
- package/carousel/plugins/fade/utils.js +8 -0
- package/carousel/state.d.ts +81 -0
- package/carousel/state.js +71 -0
- package/chat/index.d.ts +83 -0
- package/chat/index.jsx +287 -0
- package/checkbox/behaviour.d.ts +172 -0
- package/checkbox/behaviour.jsx +412 -0
- package/checkbox/index.d.ts +168 -0
- package/checkbox/index.jsx +310 -0
- package/clipboard/index.d.ts +49 -0
- package/clipboard/index.js +136 -0
- package/coercion/index.d.ts +36 -0
- package/coercion/index.js +58 -0
- package/collections/base.d.ts +115 -0
- package/collections/base.js +346 -0
- package/collections/builder.d.ts +44 -0
- package/collections/builder.js +283 -0
- package/collections/components.d.ts +217 -0
- package/collections/components.jsx +537 -0
- package/collections/data-source.d.ts +26 -0
- package/collections/data-source.js +27 -0
- package/collections/dom.d.ts +34 -0
- package/collections/dom.js +127 -0
- package/collections/grid.d.ts +45 -0
- package/collections/grid.js +125 -0
- package/collections/hidden.d.ts +4 -0
- package/collections/hidden.js +12 -0
- package/collections/index.d.ts +45 -0
- package/collections/index.js +105 -0
- package/collections/list-state.d.ts +99 -0
- package/collections/list-state.js +156 -0
- package/collections/list.d.ts +20 -0
- package/collections/list.js +77 -0
- package/collections/nodes.d.ts +9 -0
- package/collections/nodes.js +81 -0
- package/collections/selection-model.d.ts +93 -0
- package/collections/selection-model.js +192 -0
- package/collections/server-dev.d.ts +5 -0
- package/collections/server-dev.js +16 -0
- package/collections/server-off.d.ts +5 -0
- package/collections/server-off.js +7 -0
- package/collections/server-on.d.ts +28 -0
- package/collections/server-on.jsx +76 -0
- package/collections/table.d.ts +114 -0
- package/collections/table.js +439 -0
- package/collections/tree-state.d.ts +47 -0
- package/collections/tree-state.js +73 -0
- package/collections/tree.d.ts +20 -0
- package/collections/tree.js +66 -0
- package/collections/types.d.ts +229 -0
- package/collections/types.js +4 -0
- package/collections/unique-selection-dispatcher.d.ts +10 -0
- package/collections/unique-selection-dispatcher.js +25 -0
- package/color/area-state.d.ts +99 -0
- package/color/area-state.js +160 -0
- package/color/aria-intl.d.ts +3 -0
- package/color/aria-intl.js +274 -0
- package/color/channel-field-state.d.ts +50 -0
- package/color/channel-field-state.jsx +87 -0
- package/color/color.d.ts +78 -0
- package/color/color.js +738 -0
- package/color/field-state.d.ts +66 -0
- package/color/field-state.jsx +159 -0
- package/color/index.d.ts +58 -0
- package/color/index.js +88 -0
- package/color/intl.d.ts +3 -0
- package/color/intl.js +1328 -0
- package/color/picker-state.d.ts +20 -0
- package/color/picker-state.js +19 -0
- package/color/slider-state.d.ts +78 -0
- package/color/slider-state.jsx +98 -0
- package/color/value.d.ts +27 -0
- package/color/value.js +36 -0
- package/color/wheel-state.d.ts +77 -0
- package/color/wheel-state.js +152 -0
- package/color-area/behaviour.d.ts +161 -0
- package/color-area/behaviour.jsx +454 -0
- package/color-area/index.d.ts +34 -0
- package/color-area/index.jsx +187 -0
- package/color-field/behaviour.d.ts +112 -0
- package/color-field/behaviour.jsx +262 -0
- package/color-field/index.d.ts +72 -0
- package/color-field/index.jsx +309 -0
- package/color-picker/index.d.ts +19 -0
- package/color-picker/index.jsx +49 -0
- package/color-slider/behaviour.d.ts +103 -0
- package/color-slider/behaviour.jsx +234 -0
- package/color-slider/index.d.ts +40 -0
- package/color-slider/index.jsx +162 -0
- package/color-swatch/behaviour.d.ts +40 -0
- package/color-swatch/behaviour.js +36 -0
- package/color-swatch/index.d.ts +29 -0
- package/color-swatch/index.jsx +82 -0
- package/color-swatch-picker/index.d.ts +62 -0
- package/color-swatch-picker/index.jsx +95 -0
- package/color-swatch-picker/intl.d.ts +3 -0
- package/color-swatch-picker/intl.js +104 -0
- package/color-thumb/index.d.ts +85 -0
- package/color-thumb/index.jsx +93 -0
- package/color-wheel/behaviour.d.ts +123 -0
- package/color-wheel/behaviour.jsx +301 -0
- package/color-wheel/index.d.ts +50 -0
- package/color-wheel/index.jsx +166 -0
- package/combobox/behaviour.d.ts +120 -0
- package/combobox/behaviour.jsx +588 -0
- package/combobox/index.d.ts +101 -0
- package/combobox/index.jsx +365 -0
- package/combobox/intl.d.ts +2 -0
- package/combobox/intl.js +240 -0
- package/compare/behaviour.d.ts +101 -0
- package/compare/behaviour.js +288 -0
- package/compare/index.d.ts +58 -0
- package/compare/index.jsx +129 -0
- package/data/async-list.d.ts +78 -0
- package/data/async-list.jsx +257 -0
- package/data/index.d.ts +3 -0
- package/data/index.jsx +6 -0
- package/data/list-data.d.ts +88 -0
- package/data/list-data.jsx +210 -0
- package/data/tree-data.d.ts +59 -0
- package/data/tree-data.jsx +278 -0
- package/data-grid/behaviour.d.ts +95 -0
- package/data-grid/behaviour.js +725 -0
- package/data-grid/index.d.ts +138 -0
- package/data-grid/index.jsx +452 -0
- package/data-grid/state.d.ts +131 -0
- package/data-grid/state.js +288 -0
- package/date/CalendarDate.d.ts +207 -0
- package/date/CalendarDate.js +374 -0
- package/date/DateFormatter.d.ts +24 -0
- package/date/DateFormatter.js +175 -0
- package/date/calendars/BuddhistCalendar.d.ts +16 -0
- package/date/calendars/BuddhistCalendar.js +46 -0
- package/date/calendars/EthiopicCalendar.d.ts +45 -0
- package/date/calendars/EthiopicCalendar.js +178 -0
- package/date/calendars/GregorianCalendar.d.ts +26 -0
- package/date/calendars/GregorianCalendar.js +122 -0
- package/date/calendars/HebrewCalendar.d.ts +21 -0
- package/date/calendars/HebrewCalendar.js +174 -0
- package/date/calendars/IndianCalendar.d.ts +17 -0
- package/date/calendars/IndianCalendar.js +111 -0
- package/date/calendars/IslamicCalendar.d.ts +51 -0
- package/date/calendars/IslamicCalendar.js +205 -0
- package/date/calendars/JapaneseCalendar.d.ts +22 -0
- package/date/calendars/JapaneseCalendar.js +148 -0
- package/date/calendars/PersianCalendar.d.ts +19 -0
- package/date/calendars/PersianCalendar.js +85 -0
- package/date/calendars/TaiwanCalendar.d.ts +19 -0
- package/date/calendars/TaiwanCalendar.js +70 -0
- package/date/conversion.d.ts +45 -0
- package/date/conversion.js +269 -0
- package/date/createCalendar.d.ts +3 -0
- package/date/createCalendar.js +55 -0
- package/date/index.d.ts +20 -0
- package/date/index.js +30 -0
- package/date/manipulation.d.ts +25 -0
- package/date/manipulation.js +399 -0
- package/date/queries.d.ts +93 -0
- package/date/queries.js +303 -0
- package/date/serialize.d.ts +18 -0
- package/date/serialize.js +55 -0
- package/date/string.d.ts +36 -0
- package/date/string.js +223 -0
- package/date/types.d.ts +136 -0
- package/date/types.js +14 -0
- package/date/utils.d.ts +4 -0
- package/date/utils.js +16 -0
- package/date/weekStartData.d.ts +1 -0
- package/date/weekStartData.js +112 -0
- package/date-field/behaviour.d.ts +188 -0
- package/date-field/behaviour.jsx +1025 -0
- package/date-field/index.d.ts +150 -0
- package/date-field/index.jsx +354 -0
- package/date-field/intl.d.ts +3 -0
- package/date-field/intl.js +36 -0
- package/date-field/live-value.d.ts +22 -0
- package/date-field/live-value.jsx +44 -0
- package/date-picker/behaviour.d.ts +95 -0
- package/date-picker/behaviour.jsx +343 -0
- package/date-picker/index.d.ts +66 -0
- package/date-picker/index.jsx +243 -0
- package/dialog/behaviour.d.ts +63 -0
- package/dialog/behaviour.jsx +90 -0
- package/dialog/contexts.d.ts +12 -0
- package/dialog/contexts.js +8 -0
- package/dialog/index.d.ts +48 -0
- package/dialog/index.jsx +301 -0
- package/disclosure/behaviour.d.ts +50 -0
- package/disclosure/behaviour.jsx +128 -0
- package/disclosure/details.d.ts +21 -0
- package/disclosure/details.jsx +14 -0
- package/disclosure/index.d.ts +92 -0
- package/disclosure/index.jsx +300 -0
- package/drag-drop/cdk-index.d.ts +22 -0
- package/drag-drop/cdk-index.jsx +25 -0
- package/drag-drop/directives/assertions.d.ts +6 -0
- package/drag-drop/directives/assertions.js +13 -0
- package/drag-drop/directives/config.d.ts +30 -0
- package/drag-drop/directives/config.js +7 -0
- package/drag-drop/directives/drag-handle.d.ts +10 -0
- package/drag-drop/directives/drag-handle.js +29 -0
- package/drag-drop/directives/drag.d.ts +194 -0
- package/drag-drop/directives/drag.js +522 -0
- package/drag-drop/directives/drop-list-group.d.ts +25 -0
- package/drag-drop/directives/drop-list-group.js +55 -0
- package/drag-drop/directives/drop-list.d.ts +163 -0
- package/drag-drop/directives/drop-list.js +396 -0
- package/drag-drop/directives/registry.d.ts +32 -0
- package/drag-drop/directives/registry.js +61 -0
- package/drag-drop/dom/clone-node.d.ts +2 -0
- package/drag-drop/dom/clone-node.js +58 -0
- package/drag-drop/dom/coerce.d.ts +6 -0
- package/drag-drop/dom/coerce.js +8 -0
- package/drag-drop/dom/dom-rect.d.ts +37 -0
- package/drag-drop/dom/dom-rect.js +71 -0
- package/drag-drop/dom/fake-event.d.ts +4 -0
- package/drag-drop/dom/fake-event.js +22 -0
- package/drag-drop/dom/inherited-text.d.ts +4 -0
- package/drag-drop/dom/inherited-text.js +44 -0
- package/drag-drop/dom/layout-shift.d.ts +8 -0
- package/drag-drop/dom/layout-shift.js +87 -0
- package/drag-drop/dom/mount-content.d.ts +2 -0
- package/drag-drop/dom/mount-content.js +7 -0
- package/drag-drop/dom/parent-position-tracker.d.ts +32 -0
- package/drag-drop/dom/parent-position-tracker.js +71 -0
- package/drag-drop/dom/root-node.d.ts +21 -0
- package/drag-drop/dom/root-node.js +41 -0
- package/drag-drop/dom/shadow-dom.d.ts +4 -0
- package/drag-drop/dom/shadow-dom.js +18 -0
- package/drag-drop/dom/styling.d.ts +52 -0
- package/drag-drop/dom/styling.js +86 -0
- package/drag-drop/dom/transition-duration.d.ts +2 -0
- package/drag-drop/dom/transition-duration.js +29 -0
- package/drag-drop/drag-drop-registry.d.ts +69 -0
- package/drag-drop/drag-drop-registry.js +224 -0
- package/drag-drop/drag-drop.d.ts +19 -0
- package/drag-drop/drag-drop.js +10 -0
- package/drag-drop/drag-events.d.ts +117 -0
- package/drag-drop/drag-events.js +1 -0
- package/drag-drop/drag-handle.d.ts +18 -0
- package/drag-drop/drag-handle.jsx +53 -0
- package/drag-drop/drag-placeholder.d.ts +8 -0
- package/drag-drop/drag-placeholder.jsx +25 -0
- package/drag-drop/drag-preview.d.ts +10 -0
- package/drag-drop/drag-preview.jsx +31 -0
- package/drag-drop/drag-ref.d.ts +476 -0
- package/drag-drop/drag-ref.js +1306 -0
- package/drag-drop/drag-utils.d.ts +25 -0
- package/drag-drop/drag-utils.js +53 -0
- package/drag-drop/drag.d.ts +23 -0
- package/drag-drop/drag.jsx +126 -0
- package/drag-drop/drop-list-group.d.ts +22 -0
- package/drag-drop/drop-list-group.jsx +19 -0
- package/drag-drop/drop-list-ref.d.ts +295 -0
- package/drag-drop/drop-list-ref.js +707 -0
- package/drag-drop/drop-list.d.ts +19 -0
- package/drag-drop/drop-list.jsx +87 -0
- package/drag-drop/index.d.ts +1 -0
- package/drag-drop/index.jsx +4 -0
- package/drag-drop/lazy-refs.d.ts +28 -0
- package/drag-drop/lazy-refs.js +133 -0
- package/drag-drop/preview-ref.d.ts +38 -0
- package/drag-drop/preview-ref.js +132 -0
- package/drag-drop/sorting/drop-list-sort-strategy.d.ts +29 -0
- package/drag-drop/sorting/drop-list-sort-strategy.js +1 -0
- package/drag-drop/sorting/mixed-sort-strategy.d.ts +99 -0
- package/drag-drop/sorting/mixed-sort-strategy.js +259 -0
- package/drag-drop/sorting/single-axis-sort-strategy.d.ts +112 -0
- package/drag-drop/sorting/single-axis-sort-strategy.js +343 -0
- package/file-trigger/index.d.ts +24 -0
- package/file-trigger/index.jsx +41 -0
- package/flip/index.d.ts +59 -0
- package/flip/index.js +124 -0
- package/focus/focus-ring.d.ts +42 -0
- package/focus/focus-ring.jsx +77 -0
- package/focus/focus-scope.d.ts +51 -0
- package/focus/focus-scope.jsx +431 -0
- package/focus/focusable.d.ts +33 -0
- package/focus/focusable.jsx +93 -0
- package/focus/index.d.ts +74 -0
- package/focus/index.js +274 -0
- package/form/behaviour.d.ts +29 -0
- package/form/behaviour.js +145 -0
- package/form/field-error.d.ts +38 -0
- package/form/field-error.jsx +67 -0
- package/form/index.d.ts +77 -0
- package/form/index.jsx +116 -0
- package/grid/behaviour.d.ts +290 -0
- package/grid/behaviour.js +683 -0
- package/grid/intl.d.ts +2 -0
- package/grid/intl.js +36 -0
- package/grid/keyboard-delegate.d.ts +56 -0
- package/grid/keyboard-delegate.js +316 -0
- package/grid-list/behaviour.d.ts +242 -0
- package/grid-list/behaviour.js +598 -0
- package/grid-list/index.d.ts +202 -0
- package/grid-list/index.jsx +685 -0
- package/grid-list/row.d.ts +24 -0
- package/grid-list/row.js +57 -0
- package/group/index.d.ts +48 -0
- package/group/index.jsx +126 -0
- package/header/index.d.ts +13 -0
- package/header/index.jsx +34 -0
- package/heading/index.d.ts +19 -0
- package/heading/index.jsx +55 -0
- package/highlight/index.d.ts +12 -0
- package/highlight/index.jsx +357 -0
- package/i18n/filter.d.ts +16 -0
- package/i18n/filter.js +66 -0
- package/i18n/i18n-provider.d.ts +10 -0
- package/i18n/i18n-provider.jsx +15 -0
- package/i18n/index.d.ts +27 -0
- package/i18n/index.js +115 -0
- package/i18n/intl-cache.d.ts +4 -0
- package/i18n/intl-cache.js +40 -0
- package/i18n/list-formatter.d.ts +2 -0
- package/i18n/list-formatter.js +11 -0
- package/input/index.d.ts +51 -0
- package/input/index.jsx +95 -0
- package/interactions/controllable.d.ts +42 -0
- package/interactions/controllable.js +67 -0
- package/interactions/focus-visible.d.ts +68 -0
- package/interactions/focus-visible.jsx +291 -0
- package/interactions/focus.d.ts +58 -0
- package/interactions/focus.jsx +152 -0
- package/interactions/hover.d.ts +54 -0
- package/interactions/hover.jsx +139 -0
- package/interactions/index.d.ts +1 -0
- package/interactions/index.js +3 -0
- package/interactions/interact-outside.d.ts +24 -0
- package/interactions/interact-outside.jsx +57 -0
- package/interactions/keyboard.d.ts +28 -0
- package/interactions/keyboard.jsx +51 -0
- package/interactions/long-press.d.ts +41 -0
- package/interactions/long-press.jsx +79 -0
- package/interactions/merge-props.d.ts +54 -0
- package/interactions/merge-props.jsx +257 -0
- package/interactions/move.d.ts +48 -0
- package/interactions/move.jsx +96 -0
- package/interactions/press.d.ts +129 -0
- package/interactions/press.jsx +538 -0
- package/interactions/pressable.d.ts +22 -0
- package/interactions/pressable.jsx +93 -0
- package/interactions/scroll-wheel.d.ts +20 -0
- package/interactions/scroll-wheel.jsx +40 -0
- package/interactions/utils.d.ts +53 -0
- package/interactions/utils.js +252 -0
- package/keyboard/index.d.ts +12 -0
- package/keyboard/index.jsx +34 -0
- package/keys/index.d.ts +68 -0
- package/keys/index.js +199 -0
- package/label/behaviour.d.ts +54 -0
- package/label/behaviour.js +60 -0
- package/label/index.d.ts +35 -0
- package/label/index.jsx +85 -0
- package/landmark/index.d.ts +10 -0
- package/landmark/index.jsx +35 -0
- package/landmark/manager.d.ts +50 -0
- package/landmark/manager.js +364 -0
- package/layout/index.d.ts +90 -0
- package/layout/index.js +207 -0
- package/lightbox/behaviour.d.ts +82 -0
- package/lightbox/behaviour.js +490 -0
- package/lightbox/captions/index.d.ts +39 -0
- package/lightbox/captions/index.jsx +44 -0
- package/lightbox/counter/index.d.ts +10 -0
- package/lightbox/counter/index.jsx +10 -0
- package/lightbox/download/index.d.ts +32 -0
- package/lightbox/download/index.jsx +89 -0
- package/lightbox/embed/index.d.ts +15 -0
- package/lightbox/embed/index.jsx +58 -0
- package/lightbox/fullscreen/index.d.ts +24 -0
- package/lightbox/fullscreen/index.jsx +80 -0
- package/lightbox/index.d.ts +129 -0
- package/lightbox/index.jsx +284 -0
- package/lightbox/inline/index.d.ts +18 -0
- package/lightbox/inline/index.jsx +15 -0
- package/lightbox/pdf/index.d.ts +18 -0
- package/lightbox/pdf/index.jsx +31 -0
- package/lightbox/share/index.d.ts +29 -0
- package/lightbox/share/index.jsx +43 -0
- package/lightbox/slideshow/index.d.ts +24 -0
- package/lightbox/slideshow/index.jsx +118 -0
- package/lightbox/state.d.ts +334 -0
- package/lightbox/state.js +192 -0
- package/lightbox/thumbnails/index.d.ts +54 -0
- package/lightbox/thumbnails/index.jsx +96 -0
- package/lightbox/video/index.d.ts +13 -0
- package/lightbox/video/index.jsx +42 -0
- package/lightbox/zoom/index.d.ts +67 -0
- package/lightbox/zoom/index.jsx +456 -0
- package/link/behaviour.d.ts +41 -0
- package/link/behaviour.js +58 -0
- package/link/index.d.ts +30 -0
- package/link/index.jsx +179 -0
- package/link/router.d.ts +1 -0
- package/link/router.js +5 -0
- package/listbox/behaviour.d.ts +175 -0
- package/listbox/behaviour.jsx +492 -0
- package/listbox/index.d.ts +129 -0
- package/listbox/index.jsx +596 -0
- package/markdown/index.d.ts +82 -0
- package/markdown/index.jsx +654 -0
- package/masonry/behaviour.d.ts +121 -0
- package/masonry/behaviour.js +676 -0
- package/masonry/flip.d.ts +27 -0
- package/masonry/flip.js +61 -0
- package/masonry/geometry.d.ts +44 -0
- package/masonry/geometry.js +184 -0
- package/masonry/index.d.ts +153 -0
- package/masonry/index.jsx +833 -0
- package/masonry/justified.d.ts +49 -0
- package/masonry/justified.js +250 -0
- package/masonry/layout.d.ts +200 -0
- package/masonry/layout.js +668 -0
- package/masonry/masonry-layout.d.ts +57 -0
- package/masonry/masonry-layout.js +159 -0
- package/masonry/masonry.css +29 -0
- package/menu/behaviour.d.ts +205 -0
- package/menu/behaviour.jsx +847 -0
- package/menu/index.d.ts +171 -0
- package/menu/index.jsx +671 -0
- package/menu/intl.d.ts +2 -0
- package/menu/intl.js +36 -0
- package/menu/safely-mouse-to-submenu.d.ts +12 -0
- package/menu/safely-mouse-to-submenu.js +128 -0
- package/meter/behaviour.d.ts +18 -0
- package/meter/behaviour.jsx +17 -0
- package/meter/index.d.ts +30 -0
- package/meter/index.jsx +85 -0
- package/modal/index.d.ts +79 -0
- package/modal/index.jsx +359 -0
- package/modal/provider.d.ts +47 -0
- package/modal/provider.jsx +105 -0
- package/morph/index.d.ts +91 -0
- package/morph/index.jsx +372 -0
- package/morph/item.d.ts +89 -0
- package/morph/item.jsx +546 -0
- package/motion/Animations.d.ts +17 -0
- package/motion/Animations.js +56 -0
- package/motion/DragRelease.d.ts +22 -0
- package/motion/DragRelease.js +26 -0
- package/motion/DragTracker.d.ts +7 -0
- package/motion/DragTracker.js +43 -0
- package/motion/Limit.d.ts +12 -0
- package/motion/Limit.js +37 -0
- package/motion/Motion1D.d.ts +38 -0
- package/motion/Motion1D.js +72 -0
- package/motion/ScrollBody.d.ts +13 -0
- package/motion/ScrollBody.js +75 -0
- package/motion/Vector1d.d.ts +8 -0
- package/motion/Vector1d.js +29 -0
- package/motion/index.d.ts +8 -0
- package/motion/index.js +12 -0
- package/motion/utils.d.ts +5 -0
- package/motion/utils.js +23 -0
- package/native-select/index.d.ts +46 -0
- package/native-select/index.jsx +99 -0
- package/navigation-tree/index.d.ts +43 -0
- package/navigation-tree/index.jsx +110 -0
- package/number/NumberFormatter.d.ts +28 -0
- package/number/NumberFormatter.js +144 -0
- package/number/NumberParser.d.ts +27 -0
- package/number/NumberParser.js +316 -0
- package/number/index.d.ts +5 -0
- package/number/index.jsx +17 -0
- package/number/number-field-state.d.ts +132 -0
- package/number/number-field-state.jsx +364 -0
- package/number-field/behaviour.d.ts +165 -0
- package/number-field/behaviour.jsx +512 -0
- package/number-field/index.d.ts +52 -0
- package/number-field/index.jsx +207 -0
- package/number-field/intl.d.ts +2 -0
- package/number-field/intl.js +36 -0
- package/observers/index.d.ts +70 -0
- package/observers/index.js +279 -0
- package/overflow/index.d.ts +93 -0
- package/overflow/index.jsx +267 -0
- package/overlay/aria-hide-outside.d.ts +12 -0
- package/overlay/aria-hide-outside.js +141 -0
- package/overlay/close-on-scroll.d.ts +1 -0
- package/overlay/close-on-scroll.js +6 -0
- package/overlay/contexts.d.ts +34 -0
- package/overlay/contexts.js +21 -0
- package/overlay/dismiss-button.d.ts +10 -0
- package/overlay/dismiss-button.jsx +18 -0
- package/overlay/hover-trigger.d.ts +54 -0
- package/overlay/hover-trigger.jsx +221 -0
- package/overlay/index.d.ts +40 -0
- package/overlay/index.js +139 -0
- package/overlay/modal-overlay.d.ts +16 -0
- package/overlay/modal-overlay.js +38 -0
- package/overlay/overlay-strings.d.ts +4 -0
- package/overlay/overlay-strings.js +52 -0
- package/overlay/overlay-trigger-state.d.ts +1 -0
- package/overlay/overlay-trigger-state.js +3 -0
- package/overlay/overlay-trigger.d.ts +27 -0
- package/overlay/overlay-trigger.jsx +50 -0
- package/overlay/position.d.ts +160 -0
- package/overlay/position.js +559 -0
- package/overlay/prevent-scroll-ios.d.ts +17 -0
- package/overlay/prevent-scroll-ios.js +331 -0
- package/overlay/prevent-scroll.d.ts +18 -0
- package/overlay/prevent-scroll.js +122 -0
- package/overlay/safe-area.d.ts +28 -0
- package/overlay/safe-area.js +108 -0
- package/overlay-arrow/index.d.ts +23 -0
- package/overlay-arrow/index.jsx +59 -0
- package/overlay-service/connected-position.d.ts +163 -0
- package/overlay-service/connected-position.js +661 -0
- package/overlay-service/global-position.d.ts +34 -0
- package/overlay-service/global-position.js +154 -0
- package/overlay-service/index.d.ts +15 -0
- package/overlay-service/index.js +27 -0
- package/overlay-service/overlay-container.d.ts +27 -0
- package/overlay-service/overlay-container.js +93 -0
- package/overlay-service/overlay-dispatchers.d.ts +44 -0
- package/overlay-service/overlay-dispatchers.js +149 -0
- package/overlay-service/overlay-position-builder.d.ts +8 -0
- package/overlay-service/overlay-position-builder.js +15 -0
- package/overlay-service/overlay-ref.d.ts +155 -0
- package/overlay-service/overlay-ref.js +436 -0
- package/overlay-service/overlay-strategy.d.ts +48 -0
- package/overlay-service/overlay-strategy.js +3 -0
- package/overlay-service/overlay-viewport.d.ts +85 -0
- package/overlay-service/overlay-viewport.js +192 -0
- package/overlay-service/overlay.css +94 -0
- package/overlay-service/scroll-strategies.d.ts +71 -0
- package/overlay-service/scroll-strategies.js +185 -0
- package/package.json +754 -4
- package/platform/index.d.ts +100 -0
- package/platform/index.js +304 -0
- package/popover/behaviour.d.ts +23 -0
- package/popover/behaviour.js +39 -0
- package/popover/index.d.ts +60 -0
- package/popover/index.jsx +285 -0
- package/popover/popover-overlay.d.ts +27 -0
- package/popover/popover-overlay.jsx +60 -0
- package/popover/use-popover.d.ts +57 -0
- package/popover/use-popover.js +92 -0
- package/portal/index.d.ts +47 -0
- package/portal/index.jsx +76 -0
- package/portal/portal-mount.d.ts +8 -0
- package/portal/portal-mount.js +7 -0
- package/portal/portal-outlet.d.ts +88 -0
- package/portal/portal-outlet.js +222 -0
- package/preview-trigger/behaviour.d.ts +70 -0
- package/preview-trigger/behaviour.jsx +258 -0
- package/preview-trigger/index.d.ts +12 -0
- package/preview-trigger/index.jsx +82 -0
- package/progress-bar/behaviour.d.ts +77 -0
- package/progress-bar/behaviour.jsx +75 -0
- package/progress-bar/context.d.ts +4 -0
- package/progress-bar/context.js +7 -0
- package/progress-bar/index.d.ts +38 -0
- package/progress-bar/index.jsx +90 -0
- package/radio-group/behaviour.d.ts +11 -0
- package/radio-group/behaviour.js +85 -0
- package/radio-group/index.d.ts +82 -0
- package/radio-group/index.jsx +139 -0
- package/radio-group/parts.d.ts +223 -0
- package/radio-group/parts.jsx +425 -0
- package/range-calendar/behaviour.d.ts +2 -0
- package/range-calendar/behaviour.jsx +5 -0
- package/range-calendar/index.d.ts +2 -0
- package/range-calendar/index.jsx +4 -0
- package/resizable/engine/components/group/auto-save/getStorageKey.d.ts +1 -0
- package/resizable/engine/components/group/auto-save/getStorageKey.js +5 -0
- package/resizable/engine/components/group/compareDocumentPosition.d.ts +5 -0
- package/resizable/engine/components/group/compareDocumentPosition.js +19 -0
- package/resizable/engine/components/group/readLegacyLayout.d.ts +16 -0
- package/resizable/engine/components/group/readLegacyLayout.js +48 -0
- package/resizable/engine/components/group/sortByElementOffset.d.ts +4 -0
- package/resizable/engine/components/group/sortByElementOffset.js +28 -0
- package/resizable/engine/components/group/types.d.ts +50 -0
- package/resizable/engine/components/group/types.js +1 -0
- package/resizable/engine/components/panel/types.d.ts +90 -0
- package/resizable/engine/components/panel/types.js +4 -0
- package/resizable/engine/constants.d.ts +15 -0
- package/resizable/engine/constants.js +27 -0
- package/resizable/engine/global/cursor/getCursorStyle.d.ts +7 -0
- package/resizable/engine/global/cursor/getCursorStyle.js +94 -0
- package/resizable/engine/global/cursor/supportsAdvancedCursorStyles.d.ts +5 -0
- package/resizable/engine/global/cursor/supportsAdvancedCursorStyles.js +20 -0
- package/resizable/engine/global/cursor/updateCursorStyle.d.ts +1 -0
- package/resizable/engine/global/cursor/updateCursorStyle.js +64 -0
- package/resizable/engine/global/dom/calculateAvailableAxisSize.d.ts +4 -0
- package/resizable/engine/global/dom/calculateAvailableAxisSize.js +10 -0
- package/resizable/engine/global/dom/calculateHitRegions.d.ts +13 -0
- package/resizable/engine/global/dom/calculateHitRegions.js +153 -0
- package/resizable/engine/global/dom/calculateItemConstraints.d.ts +2 -0
- package/resizable/engine/global/dom/calculateItemConstraints.js +82 -0
- package/resizable/engine/global/event-handlers/onDocumentContextMenu.d.ts +1 -0
- package/resizable/engine/global/event-handlers/onDocumentContextMenu.js +9 -0
- package/resizable/engine/global/event-handlers/onDocumentDoubleClick.d.ts +1 -0
- package/resizable/engine/global/event-handlers/onDocumentDoubleClick.js +28 -0
- package/resizable/engine/global/event-handlers/onDocumentKeyDown.d.ts +1 -0
- package/resizable/engine/global/event-handlers/onDocumentKeyDown.js +97 -0
- package/resizable/engine/global/event-handlers/onDocumentLostPointerCapture.d.ts +1 -0
- package/resizable/engine/global/event-handlers/onDocumentLostPointerCapture.js +18 -0
- package/resizable/engine/global/event-handlers/onDocumentPointerCancel.d.ts +1 -0
- package/resizable/engine/global/event-handlers/onDocumentPointerCancel.js +8 -0
- package/resizable/engine/global/event-handlers/onDocumentPointerDown.d.ts +1 -0
- package/resizable/engine/global/event-handlers/onDocumentPointerDown.js +54 -0
- package/resizable/engine/global/event-handlers/onDocumentPointerLeave.d.ts +1 -0
- package/resizable/engine/global/event-handlers/onDocumentPointerLeave.js +22 -0
- package/resizable/engine/global/event-handlers/onDocumentPointerMove.d.ts +1 -0
- package/resizable/engine/global/event-handlers/onDocumentPointerMove.js +69 -0
- package/resizable/engine/global/event-handlers/onDocumentPointerOut.d.ts +1 -0
- package/resizable/engine/global/event-handlers/onDocumentPointerOut.js +20 -0
- package/resizable/engine/global/event-handlers/onDocumentPointerUp.d.ts +1 -0
- package/resizable/engine/global/event-handlers/onDocumentPointerUp.js +15 -0
- package/resizable/engine/global/event-handlers/onWindowBlur.d.ts +1 -0
- package/resizable/engine/global/event-handlers/onWindowBlur.js +11 -0
- package/resizable/engine/global/mountAxis.d.ts +2 -0
- package/resizable/engine/global/mountAxis.js +187 -0
- package/resizable/engine/global/mutable-state/axes.d.ts +37 -0
- package/resizable/engine/global/mutable-state/axes.js +52 -0
- package/resizable/engine/global/mutable-state/interactions.d.ts +17 -0
- package/resizable/engine/global/mutable-state/interactions.js +92 -0
- package/resizable/engine/global/mutable-state/types.d.ts +32 -0
- package/resizable/engine/global/mutable-state/types.js +1 -0
- package/resizable/engine/global/styles/convertEmToPixels.d.ts +1 -0
- package/resizable/engine/global/styles/convertEmToPixels.js +7 -0
- package/resizable/engine/global/styles/convertRemToPixels.d.ts +1 -0
- package/resizable/engine/global/styles/convertRemToPixels.js +7 -0
- package/resizable/engine/global/styles/convertVhToPixels.d.ts +1 -0
- package/resizable/engine/global/styles/convertVhToPixels.js +5 -0
- package/resizable/engine/global/styles/convertVwToPixels.d.ts +1 -0
- package/resizable/engine/global/styles/convertVwToPixels.js +5 -0
- package/resizable/engine/global/styles/parseSizeAndUnit.d.ts +2 -0
- package/resizable/engine/global/styles/parseSizeAndUnit.js +29 -0
- package/resizable/engine/global/styles/sizeStyleToPixels.d.ts +5 -0
- package/resizable/engine/global/styles/sizeStyleToPixels.js +38 -0
- package/resizable/engine/global/types.d.ts +120 -0
- package/resizable/engine/global/types.js +1 -0
- package/resizable/engine/global/utils/abortActivePointerResize.d.ts +9 -0
- package/resizable/engine/global/utils/abortActivePointerResize.js +52 -0
- package/resizable/engine/global/utils/adjustLayoutByDelta.d.ts +9 -0
- package/resizable/engine/global/utils/adjustLayoutByDelta.js +219 -0
- package/resizable/engine/global/utils/adjustLayoutForSeparator.d.ts +1 -0
- package/resizable/engine/global/utils/adjustLayoutForSeparator.js +48 -0
- package/resizable/engine/global/utils/calculateDefaultLayout.d.ts +2 -0
- package/resizable/engine/global/utils/calculateDefaultLayout.js +30 -0
- package/resizable/engine/global/utils/calculateResizePreviews.d.ts +3 -0
- package/resizable/engine/global/utils/calculateResizePreviews.js +39 -0
- package/resizable/engine/global/utils/calculateSeparatorAriaValues.d.ts +12 -0
- package/resizable/engine/global/utils/calculateSeparatorAriaValues.js +43 -0
- package/resizable/engine/global/utils/compareLayoutNumbers.d.ts +1 -0
- package/resizable/engine/global/utils/compareLayoutNumbers.js +11 -0
- package/resizable/engine/global/utils/completeActivePointerResize.d.ts +6 -0
- package/resizable/engine/global/utils/completeActivePointerResize.js +49 -0
- package/resizable/engine/global/utils/doRectsIntersect.d.ts +2 -0
- package/resizable/engine/global/utils/doRectsIntersect.js +3 -0
- package/resizable/engine/global/utils/expandHitTarget.d.ts +10 -0
- package/resizable/engine/global/utils/expandHitTarget.js +19 -0
- package/resizable/engine/global/utils/findClosestHitRegion.d.ts +9 -0
- package/resizable/engine/global/utils/findClosestHitRegion.js +35 -0
- package/resizable/engine/global/utils/findClosestRect.d.ts +6 -0
- package/resizable/engine/global/utils/findClosestRect.js +22 -0
- package/resizable/engine/global/utils/findMatchingHitRegions.d.ts +7 -0
- package/resizable/engine/global/utils/findMatchingHitRegions.js +29 -0
- package/resizable/engine/global/utils/findSeparatorAxis.d.ts +21 -0
- package/resizable/engine/global/utils/findSeparatorAxis.js +12 -0
- package/resizable/engine/global/utils/formatLayoutNumber.d.ts +1 -0
- package/resizable/engine/global/utils/formatLayoutNumber.js +5 -0
- package/resizable/engine/global/utils/getDefaultLayout.d.ts +5 -0
- package/resizable/engine/global/utils/getDefaultLayout.js +11 -0
- package/resizable/engine/global/utils/getDistanceBetweenPointAndRect.d.ts +5 -0
- package/resizable/engine/global/utils/getDistanceBetweenPointAndRect.js +6 -0
- package/resizable/engine/global/utils/getImperativeAxisMethods.d.ts +4 -0
- package/resizable/engine/global/utils/getImperativeAxisMethods.js +53 -0
- package/resizable/engine/global/utils/getImperativeItemMethods.d.ts +5 -0
- package/resizable/engine/global/utils/getImperativeItemMethods.js +169 -0
- package/resizable/engine/global/utils/isCoarsePointer.d.ts +4 -0
- package/resizable/engine/global/utils/isCoarsePointer.js +17 -0
- package/resizable/engine/global/utils/isModal.d.ts +1 -0
- package/resizable/engine/global/utils/isModal.js +11 -0
- package/resizable/engine/global/utils/isViableHitTarget.d.ts +5 -0
- package/resizable/engine/global/utils/isViableHitTarget.js +50 -0
- package/resizable/engine/global/utils/itemConstraintsEqual.d.ts +2 -0
- package/resizable/engine/global/utils/itemConstraintsEqual.js +9 -0
- package/resizable/engine/global/utils/layoutNumbersEqual.d.ts +1 -0
- package/resizable/engine/global/utils/layoutNumbersEqual.js +6 -0
- package/resizable/engine/global/utils/layoutsEqual.d.ts +2 -0
- package/resizable/engine/global/utils/layoutsEqual.js +15 -0
- package/resizable/engine/global/utils/normalizeLayout.d.ts +11 -0
- package/resizable/engine/global/utils/normalizeLayout.js +21 -0
- package/resizable/engine/global/utils/notifyItemOnResize.d.ts +2 -0
- package/resizable/engine/global/utils/notifyItemOnResize.js +23 -0
- package/resizable/engine/global/utils/objectsEqual.d.ts +1 -0
- package/resizable/engine/global/utils/objectsEqual.js +14 -0
- package/resizable/engine/global/utils/preserveFixedItemSizes.d.ts +7 -0
- package/resizable/engine/global/utils/preserveFixedItemSizes.js +53 -0
- package/resizable/engine/global/utils/recordAxisLayoutChange.d.ts +15 -0
- package/resizable/engine/global/utils/recordAxisLayoutChange.js +25 -0
- package/resizable/engine/global/utils/updateActiveHitRegion.d.ts +18 -0
- package/resizable/engine/global/utils/updateActiveHitRegion.js +119 -0
- package/resizable/engine/global/utils/validateAxisLayout.d.ts +5 -0
- package/resizable/engine/global/utils/validateAxisLayout.js +70 -0
- package/resizable/engine/global/utils/validateItemSize.d.ts +7 -0
- package/resizable/engine/global/utils/validateItemSize.js +31 -0
- package/resizable/engine/global/utils/validateLayoutKeys.d.ts +2 -0
- package/resizable/engine/global/utils/validateLayoutKeys.js +13 -0
- package/resizable/engine/types.d.ts +13 -0
- package/resizable/engine/types.js +1 -0
- package/resizable/engine/utils/EventEmitter.d.ts +11 -0
- package/resizable/engine/utils/EventEmitter.js +60 -0
- package/resizable/engine/utils/assert.d.ts +1 -0
- package/resizable/engine/utils/assert.js +7 -0
- package/resizable/engine/utils/isArrayEqual.d.ts +1 -0
- package/resizable/engine/utils/isArrayEqual.js +15 -0
- package/resizable/engine/utils/isHTMLElement.d.ts +1 -0
- package/resizable/engine/utils/isHTMLElement.js +6 -0
- package/resizable/engine/utils/isShadowRoot.d.ts +1 -0
- package/resizable/engine/utils/isShadowRoot.js +6 -0
- package/resizable/engine/vendor/stacking-order.d.ts +7 -0
- package/resizable/engine/vendor/stacking-order.js +122 -0
- package/resizable/index.d.ts +263 -0
- package/resizable/index.jsx +537 -0
- package/resizable/mount.d.ts +115 -0
- package/resizable/mount.js +540 -0
- package/scheduler/behaviour.d.ts +71 -0
- package/scheduler/behaviour.js +243 -0
- package/scheduler/context.d.ts +100 -0
- package/scheduler/context.jsx +7 -0
- package/scheduler/dates.d.ts +53 -0
- package/scheduler/dates.js +183 -0
- package/scheduler/drag.d.ts +20 -0
- package/scheduler/drag.js +361 -0
- package/scheduler/event.d.ts +26 -0
- package/scheduler/event.jsx +93 -0
- package/scheduler/index.d.ts +57 -0
- package/scheduler/index.jsx +303 -0
- package/scheduler/intl.d.ts +16 -0
- package/scheduler/intl.js +529 -0
- package/scheduler/keys-month.d.ts +7 -0
- package/scheduler/keys-month.js +110 -0
- package/scheduler/keys-time-grid.d.ts +9 -0
- package/scheduler/keys-time-grid.js +115 -0
- package/scheduler/keys.d.ts +103 -0
- package/scheduler/keys.js +527 -0
- package/scheduler/layout-index.d.ts +3 -0
- package/scheduler/layout-index.js +6 -0
- package/scheduler/layout.d.ts +285 -0
- package/scheduler/layout.js +378 -0
- package/scheduler/menus.d.ts +66 -0
- package/scheduler/menus.jsx +88 -0
- package/scheduler/month.d.ts +26 -0
- package/scheduler/month.jsx +215 -0
- package/scheduler/pointer.d.ts +64 -0
- package/scheduler/pointer.js +203 -0
- package/scheduler/select.d.ts +11 -0
- package/scheduler/select.js +64 -0
- package/scheduler/selection.d.ts +34 -0
- package/scheduler/selection.js +39 -0
- package/scheduler/state.d.ts +296 -0
- package/scheduler/state.js +496 -0
- package/scheduler/time-grid-client.d.ts +32 -0
- package/scheduler/time-grid-client.jsx +133 -0
- package/scheduler/time-grid.d.ts +26 -0
- package/scheduler/time-grid.jsx +266 -0
- package/scheduler/time.d.ts +35 -0
- package/scheduler/time.js +56 -0
- package/scheduler/toolbar.d.ts +43 -0
- package/scheduler/toolbar.jsx +38 -0
- package/scroll-area/dom.d.ts +11 -0
- package/scroll-area/dom.js +55 -0
- package/scroll-area/index.d.ts +96 -0
- package/scroll-area/index.jsx +884 -0
- package/scroll-area/presence.d.ts +12 -0
- package/scroll-area/presence.jsx +131 -0
- package/scrolling/auto-size-virtual-scroll.d.ts +53 -0
- package/scrolling/auto-size-virtual-scroll.js +213 -0
- package/scrolling/behaviour.d.ts +3 -0
- package/scrolling/behaviour.js +5 -0
- package/scrolling/emitter.d.ts +34 -0
- package/scrolling/emitter.js +144 -0
- package/scrolling/fixed-size-virtual-scroll.d.ts +28 -0
- package/scrolling/fixed-size-virtual-scroll.js +107 -0
- package/scrolling/index.d.ts +11 -0
- package/scrolling/index.jsx +13 -0
- package/scrolling/rtl.d.ts +16 -0
- package/scrolling/rtl.js +64 -0
- package/scrolling/scroll-dispatcher.d.ts +49 -0
- package/scrolling/scroll-dispatcher.js +107 -0
- package/scrolling/scrollable.d.ts +75 -0
- package/scrolling/scrollable.js +149 -0
- package/scrolling/scrolling.css +11 -0
- package/scrolling/state.d.ts +92 -0
- package/scrolling/state.js +94 -0
- package/scrolling/viewport-ruler.d.ts +47 -0
- package/scrolling/viewport-ruler.js +100 -0
- package/scrolling/viewport.d.ts +54 -0
- package/scrolling/viewport.jsx +105 -0
- package/scrolling/virtual-scroll-strategy.d.ts +41 -0
- package/scrolling/virtual-scroll-strategy.js +2 -0
- package/scrolling/virtual-scroll-viewport.d.ts +95 -0
- package/scrolling/virtual-scroll-viewport.js +370 -0
- package/search-field/behaviour.d.ts +62 -0
- package/search-field/behaviour.jsx +116 -0
- package/search-field/index.d.ts +57 -0
- package/search-field/index.jsx +158 -0
- package/search-field/intl.d.ts +2 -0
- package/search-field/intl.js +36 -0
- package/select/behaviour.d.ts +188 -0
- package/select/behaviour.jsx +445 -0
- package/select/hidden-select.d.ts +44 -0
- package/select/hidden-select.jsx +68 -0
- package/select/index.d.ts +123 -0
- package/select/index.jsx +255 -0
- package/select/intl.d.ts +2 -0
- package/select/intl.js +36 -0
- package/select/parts.d.ts +11 -0
- package/select/parts.jsx +12 -0
- package/select/select-parts.d.ts +73 -0
- package/select/select-parts.jsx +293 -0
- package/select/select-value.d.ts +58 -0
- package/select/select-value.jsx +142 -0
- package/selection/dom-utils.d.ts +25 -0
- package/selection/dom-utils.js +77 -0
- package/selection/keyed.d.ts +19 -0
- package/selection/keyed.js +76 -0
- package/selection/list-keyboard-delegate.d.ts +67 -0
- package/selection/list-keyboard-delegate.js +274 -0
- package/selection/manager.d.ts +112 -0
- package/selection/manager.js +340 -0
- package/selection/selectable-collection.d.ts +123 -0
- package/selection/selectable-collection.js +535 -0
- package/selection/selectable-item.d.ts +128 -0
- package/selection/selectable-item.js +486 -0
- package/selection/selectable-list.d.ts +42 -0
- package/selection/selectable-list.js +34 -0
- package/selection/state.d.ts +96 -0
- package/selection/state.js +131 -0
- package/selection/type-select.d.ts +37 -0
- package/selection/type-select.js +114 -0
- package/selection/utils.d.ts +23 -0
- package/selection/utils.js +38 -0
- package/selection-indicator/context.d.ts +10 -0
- package/selection-indicator/context.js +7 -0
- package/selection-indicator/index.d.ts +20 -0
- package/selection-indicator/index.jsx +25 -0
- package/separator/behaviour.d.ts +17 -0
- package/separator/behaviour.js +17 -0
- package/separator/index.d.ts +23 -0
- package/separator/index.jsx +64 -0
- package/shared-element-transition/index.d.ts +36 -0
- package/shared-element-transition/index.jsx +182 -0
- package/shared-element-transition/transition.d.ts +19 -0
- package/shared-element-transition/transition.jsx +20 -0
- package/sheet-motion/index.d.ts +82 -0
- package/sheet-motion/index.js +386 -0
- package/sidebar/index.d.ts +257 -0
- package/sidebar/index.jsx +624 -0
- package/sidebar/pages.d.ts +71 -0
- package/sidebar/pages.jsx +177 -0
- package/sidebar/resize.d.ts +69 -0
- package/sidebar/resize.js +237 -0
- package/sidebar/sheet-motion.d.ts +15 -0
- package/sidebar/sheet-motion.js +170 -0
- package/sidebar/state.d.ts +126 -0
- package/sidebar/state.js +204 -0
- package/slider/behaviour.d.ts +141 -0
- package/slider/behaviour.jsx +492 -0
- package/slider/index.d.ts +171 -0
- package/slider/index.jsx +392 -0
- package/slider/state.d.ts +203 -0
- package/slider/state.js +377 -0
- package/slots/index.d.ts +248 -0
- package/slots/index.jsx +473 -0
- package/spinbutton/behaviour.d.ts +66 -0
- package/spinbutton/behaviour.jsx +312 -0
- package/spinbutton/intl.d.ts +2 -0
- package/spinbutton/intl.js +36 -0
- package/state/autocomplete.d.ts +26 -0
- package/state/autocomplete.js +32 -0
- package/state/calendar.d.ts +284 -0
- package/state/calendar.js +755 -0
- package/state/checkbox-group.d.ts +67 -0
- package/state/checkbox-group.js +76 -0
- package/state/combobox.d.ts +238 -0
- package/state/combobox.js +708 -0
- package/state/date-field.d.ts +407 -0
- package/state/date-field.js +1117 -0
- package/state/date-intl.d.ts +3 -0
- package/state/date-intl.js +36 -0
- package/state/date-picker.d.ts +144 -0
- package/state/date-picker.js +387 -0
- package/state/disclosure.d.ts +90 -0
- package/state/disclosure.js +148 -0
- package/state/form-validation.d.ts +89 -0
- package/state/form-validation.js +158 -0
- package/state/grid.d.ts +62 -0
- package/state/grid.js +127 -0
- package/state/list.d.ts +58 -0
- package/state/list.js +124 -0
- package/state/menu.d.ts +159 -0
- package/state/menu.js +184 -0
- package/state/overlays.d.ts +35 -0
- package/state/overlays.js +29 -0
- package/state/radio-group.d.ts +58 -0
- package/state/radio-group.js +68 -0
- package/state/search-field.d.ts +20 -0
- package/state/search-field.js +21 -0
- package/state/select.d.ts +150 -0
- package/state/select.js +187 -0
- package/state/selection.d.ts +3 -0
- package/state/selection.js +5 -0
- package/state/table-column-resize.d.ts +58 -0
- package/state/table-column-resize.js +76 -0
- package/state/table.d.ts +81 -0
- package/state/table.js +114 -0
- package/state/tabs.d.ts +85 -0
- package/state/tabs.js +161 -0
- package/state/time-field.d.ts +32 -0
- package/state/time-field.js +34 -0
- package/state/toast.d.ts +80 -0
- package/state/toast.js +146 -0
- package/state/toggle-group.d.ts +70 -0
- package/state/toggle-group.js +110 -0
- package/state/toggle.d.ts +40 -0
- package/state/toggle.js +39 -0
- package/state/tooltip.d.ts +53 -0
- package/state/tooltip.js +153 -0
- package/stepper/index.d.ts +117 -0
- package/stepper/index.jsx +405 -0
- package/stepper/state.d.ts +200 -0
- package/stepper/state.js +325 -0
- package/switch/behaviour.d.ts +12 -0
- package/switch/behaviour.jsx +9 -0
- package/switch/index.d.ts +150 -0
- package/switch/index.jsx +186 -0
- package/table/behaviour.d.ts +181 -0
- package/table/behaviour.js +334 -0
- package/table/collection.d.ts +49 -0
- package/table/collection.js +259 -0
- package/table/column-resize.d.ts +48 -0
- package/table/column-resize.jsx +247 -0
- package/table/index.d.ts +339 -0
- package/table/index.jsx +982 -0
- package/table/intl.d.ts +2 -0
- package/table/intl.js +36 -0
- package/table/keyboard-delegate.d.ts +21 -0
- package/table/keyboard-delegate.js +166 -0
- package/table/rac-intl.d.ts +2 -0
- package/table/rac-intl.js +36 -0
- package/tabs/behaviour.d.ts +49 -0
- package/tabs/behaviour.js +173 -0
- package/tabs/index.d.ts +248 -0
- package/tabs/index.jsx +577 -0
- package/tabs/keyboard-delegate.d.ts +17 -0
- package/tabs/keyboard-delegate.js +64 -0
- package/tag-group/behaviour.d.ts +59 -0
- package/tag-group/behaviour.js +112 -0
- package/tag-group/index.d.ts +138 -0
- package/tag-group/index.jsx +565 -0
- package/tag-group/intl.d.ts +2 -0
- package/tag-group/intl.js +36 -0
- package/tailwind.css +12 -0
- package/tests-components/app/src/routes/index.d.ts +4 -0
- package/tests-components/app/src/routes/index.jsx +7 -0
- package/text/index.d.ts +15 -0
- package/text/index.jsx +61 -0
- package/text-area/index.d.ts +19 -0
- package/text-area/index.jsx +76 -0
- package/text-field/autosize.d.ts +70 -0
- package/text-field/autosize.js +355 -0
- package/text-field/behaviour.d.ts +140 -0
- package/text-field/behaviour.jsx +260 -0
- package/text-field/fields.d.ts +12 -0
- package/text-field/fields.js +20 -0
- package/text-field/index.d.ts +50 -0
- package/text-field/index.jsx +174 -0
- package/text-field/text-field.css +45 -0
- package/theme.css +1006 -0
- package/time-wheels/behaviour.d.ts +29 -0
- package/time-wheels/behaviour.js +156 -0
- package/time-wheels/index.d.ts +27 -0
- package/time-wheels/index.jsx +91 -0
- package/toast/behaviour.d.ts +51 -0
- package/toast/behaviour.jsx +273 -0
- package/toast/index.d.ts +94 -0
- package/toast/index.jsx +256 -0
- package/toast/intl.d.ts +2 -0
- package/toast/intl.js +36 -0
- package/toggle-button/behaviour.d.ts +15 -0
- package/toggle-button/behaviour.js +37 -0
- package/toggle-button/index.d.ts +59 -0
- package/toggle-button/index.jsx +206 -0
- package/toggle-button-group/behaviour.d.ts +19 -0
- package/toggle-button-group/behaviour.jsx +13 -0
- package/toggle-button-group/context.d.ts +7 -0
- package/toggle-button-group/context.js +9 -0
- package/toggle-button-group/index.d.ts +39 -0
- package/toggle-button-group/index.jsx +85 -0
- package/toggle-button-group/item.d.ts +30 -0
- package/toggle-button-group/item.jsx +37 -0
- package/toolbar/behaviour.d.ts +22 -0
- package/toolbar/behaviour.js +89 -0
- package/toolbar/index.d.ts +16 -0
- package/toolbar/index.jsx +67 -0
- package/tooltip/behaviour.d.ts +93 -0
- package/tooltip/behaviour.jsx +299 -0
- package/tooltip/index.d.ts +59 -0
- package/tooltip/index.jsx +193 -0
- package/tree/behaviour.d.ts +51 -0
- package/tree/behaviour.jsx +51 -0
- package/tree/cdk-index.d.ts +2 -0
- package/tree/cdk-index.js +6 -0
- package/tree/collection.d.ts +16 -0
- package/tree/collection.js +138 -0
- package/tree/control.d.ts +125 -0
- package/tree/control.js +166 -0
- package/tree/index.d.ts +154 -0
- package/tree/index.jsx +815 -0
- package/tree/intl.d.ts +2 -0
- package/tree/intl.js +36 -0
- package/tree/navigation-context.d.ts +44 -0
- package/tree/navigation-context.jsx +63 -0
- package/tree/tree-key-manager.d.ts +149 -0
- package/tree/tree-key-manager.js +336 -0
- package/utils/animation.d.ts +32 -0
- package/utils/animation.jsx +236 -0
- package/utils/data-attrs.d.ts +71 -0
- package/utils/data-attrs.jsx +193 -0
- package/utils/dev-off.d.ts +3 -0
- package/utils/dev-off.js +7 -0
- package/utils/dev-on.d.ts +3 -0
- package/utils/dev-on.js +17 -0
- package/utils/dom-props.d.ts +44 -0
- package/utils/dom-props.js +73 -0
- package/utils/dom.d.ts +85 -0
- package/utils/dom.js +402 -0
- package/utils/id.d.ts +23 -0
- package/utils/id.js +100 -0
- package/utils/index.d.ts +57 -0
- package/utils/index.js +257 -0
- package/utils/links.d.ts +87 -0
- package/utils/links.jsx +152 -0
- package/utils/live-element.d.ts +8 -0
- package/utils/live-element.jsx +76 -0
- package/utils/live.d.ts +53 -0
- package/utils/live.jsx +169 -0
- package/utils/load-more-sentinel.d.ts +28 -0
- package/utils/load-more-sentinel.jsx +52 -0
- package/utils/motion-token.d.ts +4 -0
- package/utils/motion-token.js +48 -0
- package/utils/render.d.ts +19 -0
- package/utils/render.js +18 -0
- package/utils/types.d.ts +111 -0
- package/utils/types.js +1 -0
- package/virtualizer/behaviour.d.ts +98 -0
- package/virtualizer/behaviour.js +315 -0
- package/virtualizer/collection.d.ts +103 -0
- package/virtualizer/collection.js +155 -0
- package/virtualizer/dom.d.ts +50 -0
- package/virtualizer/dom.js +233 -0
- package/virtualizer/engine.d.ts +21 -0
- package/virtualizer/engine.js +21 -0
- package/virtualizer/grid-layout.d.ts +50 -0
- package/virtualizer/grid-layout.js +247 -0
- package/virtualizer/index.d.ts +2 -0
- package/virtualizer/index.jsx +4 -0
- package/virtualizer/layout-info.d.ts +33 -0
- package/virtualizer/layout-info.js +54 -0
- package/virtualizer/layout.d.ts +44 -0
- package/virtualizer/layout.js +30 -0
- package/virtualizer/list-layout.d.ts +103 -0
- package/virtualizer/list-layout.js +508 -0
- package/virtualizer/overscan-manager.d.ts +9 -0
- package/virtualizer/overscan-manager.js +32 -0
- package/virtualizer/point.d.ts +13 -0
- package/virtualizer/point.js +23 -0
- package/virtualizer/rect.d.ts +49 -0
- package/virtualizer/rect.js +105 -0
- package/virtualizer/reusable-view.d.ts +29 -0
- package/virtualizer/reusable-view.js +56 -0
- package/virtualizer/scroll-anchor.d.ts +62 -0
- package/virtualizer/scroll-anchor.js +130 -0
- package/virtualizer/size.d.ts +11 -0
- package/virtualizer/size.js +21 -0
- package/virtualizer/state.d.ts +35 -0
- package/virtualizer/state.js +79 -0
- package/virtualizer/table-collection.d.ts +45 -0
- package/virtualizer/table-collection.js +80 -0
- package/virtualizer/table-column-layout.d.ts +44 -0
- package/virtualizer/table-column-layout.js +210 -0
- package/virtualizer/table-layout.d.ts +55 -0
- package/virtualizer/table-layout.js +482 -0
- package/virtualizer/types.d.ts +63 -0
- package/virtualizer/types.js +1 -0
- package/virtualizer/utils.d.ts +2 -0
- package/virtualizer/utils.js +12 -0
- package/virtualizer/virtualizer-core.d.ts +61 -0
- package/virtualizer/virtualizer-core.js +304 -0
- package/virtualizer/virtualizer.d.ts +62 -0
- package/virtualizer/virtualizer.jsx +88 -0
- package/virtualizer/waterfall-layout.d.ts +41 -0
- package/virtualizer/waterfall-layout.js +227 -0
- package/wheel-picker/behaviour.d.ts +94 -0
- package/wheel-picker/behaviour.js +482 -0
- package/wheel-picker/index.d.ts +33 -0
- package/wheel-picker/index.jsx +66 -0
|
@@ -0,0 +1,1117 @@
|
|
|
1
|
+
import { signal, untrack } from "@rivetjs/reactivity";
|
|
2
|
+
import { CalendarDate, DateFormatter, GregorianCalendar, Time, createCalendar as createAnyCalendar, getLocalTimeZone, now, parseDateValue, stringifyDateValue, toCalendar, toCalendarDate, toCalendarDateTime, toDateValueString, toTime, toZoned, today, } from "@rivetjs/cdk/date";
|
|
3
|
+
import { controllable } from "@rivetjs/cdk/interactions";
|
|
4
|
+
import { createId } from "@rivetjs/cdk/id";
|
|
5
|
+
import { formatString, getDateFormatter, getStringsForLocale, resolveLocale } from "@rivetjs/cdk/i18n";
|
|
6
|
+
import { VALID_VALIDITY_STATE, createFormValidationState, getValidationResult as customValidationResult, runValidate, displayValidation, isEqualValidation, mergeValidation, } from "./form-validation.js";
|
|
7
|
+
import { dateValidationMessages } from "./date-intl.js";
|
|
8
|
+
// ---------------------------------------------------------------------------------------------
|
|
9
|
+
// placeholders.ts
|
|
10
|
+
// These placeholders are based on the strings used by the <input type="date">
|
|
11
|
+
// implementations in Chrome and Firefox. Additional languages are supported
|
|
12
|
+
// here than React Spectrum's typical translations.
|
|
13
|
+
const placeholders = {
|
|
14
|
+
ach: { year: "mwaka", month: "dwe", day: "nino" },
|
|
15
|
+
af: { year: "jjjj", month: "mm", day: "dd" },
|
|
16
|
+
am: { year: "ዓዓዓዓ", month: "ሚሜ", day: "ቀቀ" },
|
|
17
|
+
an: { year: "aaaa", month: "mm", day: "dd" },
|
|
18
|
+
ar: { year: "سنة", month: "شهر", day: "يوم" },
|
|
19
|
+
ast: { year: "aaaa", month: "mm", day: "dd" },
|
|
20
|
+
az: { year: "iiii", month: "aa", day: "gg" },
|
|
21
|
+
be: { year: "гггг", month: "мм", day: "дд" },
|
|
22
|
+
bg: { year: "гггг", month: "мм", day: "дд" },
|
|
23
|
+
bn: { year: "yyyy", month: "মিমি", day: "dd" },
|
|
24
|
+
br: { year: "bbbb", month: "mm", day: "dd" },
|
|
25
|
+
bs: { year: "gggg", month: "mm", day: "dd" },
|
|
26
|
+
ca: { year: "aaaa", month: "mm", day: "dd" },
|
|
27
|
+
cak: { year: "jjjj", month: "ii", day: "q'q'" },
|
|
28
|
+
ckb: { year: "ساڵ", month: "مانگ", day: "ڕۆژ" },
|
|
29
|
+
cs: { year: "rrrr", month: "mm", day: "dd" },
|
|
30
|
+
cy: { year: "bbbb", month: "mm", day: "dd" },
|
|
31
|
+
da: { year: "åååå", month: "mm", day: "dd" },
|
|
32
|
+
de: { year: "jjjj", month: "mm", day: "tt" },
|
|
33
|
+
dsb: { year: "llll", month: "mm", day: "źź" },
|
|
34
|
+
el: { year: "εεεε", month: "μμ", day: "ηη" },
|
|
35
|
+
en: { year: "yyyy", month: "mm", day: "dd" },
|
|
36
|
+
eo: { year: "jjjj", month: "mm", day: "tt" },
|
|
37
|
+
es: { year: "aaaa", month: "mm", day: "dd" },
|
|
38
|
+
et: { year: "aaaa", month: "kk", day: "pp" },
|
|
39
|
+
eu: { year: "uuuu", month: "hh", day: "ee" },
|
|
40
|
+
fa: { year: "سال", month: "ماه", day: "روز" },
|
|
41
|
+
ff: { year: "hhhh", month: "ll", day: "ññ" },
|
|
42
|
+
fi: { year: "vvvv", month: "kk", day: "pp" },
|
|
43
|
+
fr: { year: "aaaa", month: "mm", day: "jj" },
|
|
44
|
+
fy: { year: "jjjj", month: "mm", day: "dd" },
|
|
45
|
+
ga: { year: "bbbb", month: "mm", day: "ll" },
|
|
46
|
+
gd: { year: "bbbb", month: "mm", day: "ll" },
|
|
47
|
+
gl: { year: "aaaa", month: "mm", day: "dd" },
|
|
48
|
+
he: { year: "שנה", month: "חודש", day: "יום" },
|
|
49
|
+
hr: { year: "gggg", month: "mm", day: "dd" },
|
|
50
|
+
hsb: { year: "llll", month: "mm", day: "dd" },
|
|
51
|
+
hu: { year: "éééé", month: "hh", day: "nn" },
|
|
52
|
+
ia: { year: "aaaa", month: "mm", day: "dd" },
|
|
53
|
+
id: { year: "tttt", month: "bb", day: "hh" },
|
|
54
|
+
is: { year: "áááá", month: "mm", day: "dd" },
|
|
55
|
+
it: { year: "aaaa", month: "mm", day: "gg" },
|
|
56
|
+
ja: { year: "年", month: "月", day: "日" },
|
|
57
|
+
ka: { year: "წწწწ", month: "თთ", day: "რრ" },
|
|
58
|
+
kk: { year: "жжжж", month: "аа", day: "кк" },
|
|
59
|
+
kn: { year: "ವವವವ", month: "ಮಿಮೀ", day: "ದಿದಿ" },
|
|
60
|
+
ko: { year: "연도", month: "월", day: "일" },
|
|
61
|
+
lb: { year: "jjjj", month: "mm", day: "dd" },
|
|
62
|
+
lo: { year: "ປປປປ", month: "ດດ", day: "ວວ" },
|
|
63
|
+
lt: { year: "mmmm", month: "mm", day: "dd" },
|
|
64
|
+
lv: { year: "gggg", month: "mm", day: "dd" },
|
|
65
|
+
meh: { year: "aaaa", month: "mm", day: "dd" },
|
|
66
|
+
ml: { year: "വർഷം", month: "മാസം", day: "തീയതി" },
|
|
67
|
+
ms: { year: "tttt", month: "mm", day: "hh" },
|
|
68
|
+
nb: { year: "åååå", month: "mm", day: "dd" },
|
|
69
|
+
nl: { year: "jjjj", month: "mm", day: "dd" },
|
|
70
|
+
nn: { year: "åååå", month: "mm", day: "dd" },
|
|
71
|
+
no: { year: "åååå", month: "mm", day: "dd" },
|
|
72
|
+
oc: { year: "aaaa", month: "mm", day: "jj" },
|
|
73
|
+
pl: { year: "rrrr", month: "mm", day: "dd" },
|
|
74
|
+
pt: { year: "aaaa", month: "mm", day: "dd" },
|
|
75
|
+
rm: { year: "oooo", month: "mm", day: "dd" },
|
|
76
|
+
ro: { year: "aaaa", month: "ll", day: "zz" },
|
|
77
|
+
ru: { year: "гггг", month: "мм", day: "дд" },
|
|
78
|
+
sc: { year: "aaaa", month: "mm", day: "dd" },
|
|
79
|
+
scn: { year: "aaaa", month: "mm", day: "jj" },
|
|
80
|
+
sk: { year: "rrrr", month: "mm", day: "dd" },
|
|
81
|
+
sl: { year: "llll", month: "mm", day: "dd" },
|
|
82
|
+
sr: { year: "гггг", month: "мм", day: "дд" },
|
|
83
|
+
"sr-Latn": { year: "gggg", month: "mm", day: "dd" },
|
|
84
|
+
sv: { year: "åååå", month: "mm", day: "dd" },
|
|
85
|
+
szl: { year: "rrrr", month: "mm", day: "dd" },
|
|
86
|
+
tg: { year: "сссс", month: "мм", day: "рр" },
|
|
87
|
+
th: { year: "ปปปป", month: "ดด", day: "วว" },
|
|
88
|
+
tr: { year: "yyyy", month: "aa", day: "gg" },
|
|
89
|
+
uk: { year: "рррр", month: "мм", day: "дд" },
|
|
90
|
+
"zh-CN": { year: "年", month: "月", day: "日" },
|
|
91
|
+
"zh-TW": { year: "年", month: "月", day: "日" },
|
|
92
|
+
};
|
|
93
|
+
export function getPlaceholder(field, value, locale) {
|
|
94
|
+
// Use the actual placeholder value for the era and day period fields.
|
|
95
|
+
if (field === "era" || field === "dayPeriod")
|
|
96
|
+
return value;
|
|
97
|
+
if (field === "year" || field === "month" || field === "day")
|
|
98
|
+
return getStringsForLocale(placeholders, locale, "en")[field];
|
|
99
|
+
// For time fields (e.g. hour, minute, etc.), use two dashes as the placeholder.
|
|
100
|
+
return "––";
|
|
101
|
+
}
|
|
102
|
+
// ---------------------------------------------------------------------------------------------
|
|
103
|
+
// utils.ts
|
|
104
|
+
function getLocale() {
|
|
105
|
+
// Match browser language setting here, NOT react-aria's I18nProvider, so that we match other browser-provided
|
|
106
|
+
// validation messages, which to not respect our provider's language.
|
|
107
|
+
let locale = (typeof navigator !== "undefined" && navigator.language) || "en-US";
|
|
108
|
+
try {
|
|
109
|
+
Intl.DateTimeFormat.supportedLocalesOf([locale]);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
locale = "en-US";
|
|
113
|
+
}
|
|
114
|
+
return locale;
|
|
115
|
+
}
|
|
116
|
+
export function getValidationResult(value, minValue, maxValue, isDateUnavailable, options) {
|
|
117
|
+
const rangeOverflow = value != null && maxValue != null && value.compare(maxValue) > 0;
|
|
118
|
+
const rangeUnderflow = value != null && minValue != null && value.compare(minValue) < 0;
|
|
119
|
+
const isUnavailable = (value != null && isDateUnavailable?.(value)) || false;
|
|
120
|
+
const isInvalid = rangeOverflow || rangeUnderflow || isUnavailable;
|
|
121
|
+
const errors = [];
|
|
122
|
+
if (isInvalid) {
|
|
123
|
+
const locale = getLocale();
|
|
124
|
+
const strings = getStringsForLocale(dateValidationMessages, locale);
|
|
125
|
+
const dateFormatter = new DateFormatter(locale, getFormatOptions({}, options));
|
|
126
|
+
const timeZone = dateFormatter.resolvedOptions().timeZone;
|
|
127
|
+
if (rangeUnderflow && minValue != null)
|
|
128
|
+
errors.push(formatString(strings.rangeUnderflow, { minValue: dateFormatter.format(minValue.toDate(timeZone)) }));
|
|
129
|
+
if (rangeOverflow && maxValue != null)
|
|
130
|
+
errors.push(formatString(strings.rangeOverflow, { maxValue: dateFormatter.format(maxValue.toDate(timeZone)) }));
|
|
131
|
+
if (isUnavailable)
|
|
132
|
+
errors.push(strings.unavailableDate);
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
isInvalid,
|
|
136
|
+
validationErrors: errors,
|
|
137
|
+
validationDetails: {
|
|
138
|
+
badInput: isUnavailable,
|
|
139
|
+
customError: false,
|
|
140
|
+
patternMismatch: false,
|
|
141
|
+
rangeOverflow,
|
|
142
|
+
rangeUnderflow,
|
|
143
|
+
stepMismatch: false,
|
|
144
|
+
tooLong: false,
|
|
145
|
+
tooShort: false,
|
|
146
|
+
typeMismatch: false,
|
|
147
|
+
valueMissing: false,
|
|
148
|
+
valid: !isInvalid,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
export function getRangeValidationResult(value, minValue, maxValue, isDateUnavailable, options) {
|
|
153
|
+
const startValidation = getValidationResult(value?.start ?? null, minValue, maxValue, isDateUnavailable, options);
|
|
154
|
+
const endValidation = getValidationResult(value?.end ?? null, minValue, maxValue, isDateUnavailable, options);
|
|
155
|
+
let result = mergeValidation(startValidation, endValidation);
|
|
156
|
+
if (value?.end != null && value.start != null && value.end.compare(value.start) < 0) {
|
|
157
|
+
const strings = getStringsForLocale(dateValidationMessages, getLocale());
|
|
158
|
+
result = mergeValidation(result, {
|
|
159
|
+
isInvalid: true,
|
|
160
|
+
validationErrors: [strings.rangeReversed],
|
|
161
|
+
validationDetails: { ...VALID_VALIDITY_STATE, rangeUnderflow: true, rangeOverflow: true, valid: false },
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
const DEFAULT_FIELD_OPTIONS = { year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "2-digit", second: "2-digit" };
|
|
167
|
+
const TWO_DIGIT_FIELD_OPTIONS = { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" };
|
|
168
|
+
export function getFormatOptions(fieldOptions, options) {
|
|
169
|
+
const defaultFieldOptions = options.shouldForceLeadingZeros ? TWO_DIGIT_FIELD_OPTIONS : DEFAULT_FIELD_OPTIONS;
|
|
170
|
+
fieldOptions = { ...defaultFieldOptions, ...fieldOptions };
|
|
171
|
+
const granularity = options.granularity || "minute";
|
|
172
|
+
const keys = Object.keys(fieldOptions);
|
|
173
|
+
let startIdx = keys.indexOf(options.maxGranularity ?? "year");
|
|
174
|
+
if (startIdx < 0)
|
|
175
|
+
startIdx = 0;
|
|
176
|
+
let endIdx = keys.indexOf(granularity);
|
|
177
|
+
if (endIdx < 0)
|
|
178
|
+
endIdx = 2;
|
|
179
|
+
if (startIdx > endIdx)
|
|
180
|
+
throw new Error("maxGranularity must be greater than granularity");
|
|
181
|
+
const opts = keys.slice(startIdx, endIdx + 1).reduce((opts, key) => {
|
|
182
|
+
opts[key] = fieldOptions[key];
|
|
183
|
+
return opts;
|
|
184
|
+
}, {});
|
|
185
|
+
if (options.hourCycle != null)
|
|
186
|
+
opts.hour12 = options.hourCycle === 12;
|
|
187
|
+
opts.timeZone = options.timeZone || "UTC";
|
|
188
|
+
const hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
|
|
189
|
+
if (hasTime && options.timeZone && !options.hideTimeZone)
|
|
190
|
+
opts.timeZoneName = "short";
|
|
191
|
+
if (options.showEra && startIdx === 0)
|
|
192
|
+
opts.era = "short";
|
|
193
|
+
return opts;
|
|
194
|
+
}
|
|
195
|
+
export function getPlaceholderTime(placeholderValue) {
|
|
196
|
+
if (placeholderValue && "hour" in placeholderValue)
|
|
197
|
+
return placeholderValue;
|
|
198
|
+
return new Time();
|
|
199
|
+
}
|
|
200
|
+
export function convertValue(value, calendar) {
|
|
201
|
+
if (value === null)
|
|
202
|
+
return null;
|
|
203
|
+
if (!value)
|
|
204
|
+
return undefined;
|
|
205
|
+
return toCalendar(value, calendar);
|
|
206
|
+
}
|
|
207
|
+
export function createPlaceholderDate(placeholderValue, granularity, calendar, timeZone) {
|
|
208
|
+
if (placeholderValue)
|
|
209
|
+
return convertValue(placeholderValue, calendar);
|
|
210
|
+
const date = toCalendar(now(timeZone ?? getLocalTimeZone()).set({ hour: 0, minute: 0, second: 0, millisecond: 0 }), calendar);
|
|
211
|
+
if (granularity === "year" || granularity === "month" || granularity === "day")
|
|
212
|
+
return toCalendarDate(date);
|
|
213
|
+
if (!timeZone)
|
|
214
|
+
return toCalendarDateTime(date);
|
|
215
|
+
return date;
|
|
216
|
+
}
|
|
217
|
+
/** `useDefaultProps`: default granularity and time zone from the value; when it is null, the last ones. */
|
|
218
|
+
export function defaultProps(v, granularity, last) {
|
|
219
|
+
const defaultTimeZone = v && "timeZone" in v ? v.timeZone : undefined;
|
|
220
|
+
const defaultGranularity = v && "minute" in v ? "minute" : "day";
|
|
221
|
+
// props.granularity must actually exist in the value if one is provided.
|
|
222
|
+
if (v && granularity && !(granularity in v))
|
|
223
|
+
throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
|
|
224
|
+
if (!granularity)
|
|
225
|
+
granularity = v ? defaultGranularity : last.granularity;
|
|
226
|
+
const timeZone = v ? defaultTimeZone : (last.timeZone ?? undefined);
|
|
227
|
+
return [granularity, timeZone];
|
|
228
|
+
}
|
|
229
|
+
/** The `LastFormat` of a non-null value. */
|
|
230
|
+
export const lastFormatOf = (v) => ({ granularity: "minute" in v ? "minute" : "day", timeZone: "timeZone" in v ? v.timeZone : null });
|
|
231
|
+
/** Record the format of `v` (React's `setLastValue` during render). */
|
|
232
|
+
export function noteLast(last, v) {
|
|
233
|
+
if (!v)
|
|
234
|
+
return;
|
|
235
|
+
const next = lastFormatOf(v), prev = untrack(last);
|
|
236
|
+
if (prev.granularity !== next.granularity || prev.timeZone !== next.timeZone)
|
|
237
|
+
last.set(next);
|
|
238
|
+
}
|
|
239
|
+
export const parseValue = (text) => (text ? parseDateValue(text) : null);
|
|
240
|
+
export const parseInput = (value) => value == null ? null : typeof value === "string" ? parseValue(value) : value;
|
|
241
|
+
/**
|
|
242
|
+
* This class represents a date that is incomplete or otherwise invalid as a result of user editing.
|
|
243
|
+
* For example, it can represent temporary dates such as February 31st if the user edits the day
|
|
244
|
+
* before the month. Times are represented according to an hour cycle rather than always in 24 hour
|
|
245
|
+
* time. This enables the user to adjust the day period (e.g. am/pm) independently from the hour.
|
|
246
|
+
*/
|
|
247
|
+
export class IncompleteDate {
|
|
248
|
+
calendar;
|
|
249
|
+
era;
|
|
250
|
+
year;
|
|
251
|
+
month;
|
|
252
|
+
day;
|
|
253
|
+
hour;
|
|
254
|
+
hourCycle;
|
|
255
|
+
dayPeriod;
|
|
256
|
+
minute;
|
|
257
|
+
second;
|
|
258
|
+
millisecond;
|
|
259
|
+
offset;
|
|
260
|
+
constructor(calendar, hourCycle, dateValue) {
|
|
261
|
+
const d = (dateValue ?? {});
|
|
262
|
+
this.era = d.era ?? null;
|
|
263
|
+
this.calendar = calendar;
|
|
264
|
+
this.year = d.year ?? null;
|
|
265
|
+
this.month = d.month ?? null;
|
|
266
|
+
this.day = d.day ?? null;
|
|
267
|
+
this.hour = d.hour ?? null;
|
|
268
|
+
this.hourCycle = hourCycle;
|
|
269
|
+
this.dayPeriod = null;
|
|
270
|
+
this.minute = d.minute ?? null;
|
|
271
|
+
this.second = d.second ?? null;
|
|
272
|
+
this.millisecond = d.millisecond ?? null;
|
|
273
|
+
this.offset = "offset" in (dateValue ?? {}) ? (dateValue.offset ?? null) : null;
|
|
274
|
+
// Convert the hour from 24 hour time to the given hour cycle.
|
|
275
|
+
if (this.hour != null) {
|
|
276
|
+
const [dayPeriod, hour] = toHourCycle(this.hour, hourCycle);
|
|
277
|
+
this.dayPeriod = dayPeriod;
|
|
278
|
+
this.hour = hour;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/** Rivet: restore from plain fields (no hour cycle conversion). */
|
|
282
|
+
static fromFields(calendar, hourCycle, fields) {
|
|
283
|
+
const res = new IncompleteDate(calendar, hourCycle);
|
|
284
|
+
Object.assign(res, fields);
|
|
285
|
+
return res;
|
|
286
|
+
}
|
|
287
|
+
/** Rivet: the plain fields (JSON for the display signal). */
|
|
288
|
+
toFields() {
|
|
289
|
+
const { era, year, month, day, hour, dayPeriod, minute, second, millisecond, offset } = this;
|
|
290
|
+
return { era, year, month, day, hour, dayPeriod, minute, second, millisecond, offset };
|
|
291
|
+
}
|
|
292
|
+
copy() {
|
|
293
|
+
return IncompleteDate.fromFields(this.calendar, this.hourCycle, this.toFields());
|
|
294
|
+
}
|
|
295
|
+
/** Checks whether all the specified segments have a value. */
|
|
296
|
+
isComplete(segments) {
|
|
297
|
+
return segments.every((segment) => this[segment] != null);
|
|
298
|
+
}
|
|
299
|
+
/** Checks whether the given date value matches this value for the specified segments. */
|
|
300
|
+
validate(dt, segments) {
|
|
301
|
+
return segments.every((segment) => {
|
|
302
|
+
if ((segment === "hour" || segment === "dayPeriod") && "hour" in dt) {
|
|
303
|
+
const [dayPeriod, hour] = toHourCycle(dt.hour, this.hourCycle);
|
|
304
|
+
return this.dayPeriod === dayPeriod && this.hour === hour;
|
|
305
|
+
}
|
|
306
|
+
return this[segment] === dt[segment];
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
/** Checks if the date is empty (i.e. all specified segments are null). */
|
|
310
|
+
isCleared(segments) {
|
|
311
|
+
return segments.every((segment) => this[segment] === null);
|
|
312
|
+
}
|
|
313
|
+
/** Sets the given field. */
|
|
314
|
+
set(field, value, placeholder) {
|
|
315
|
+
const result = this.copy();
|
|
316
|
+
result[field] = value;
|
|
317
|
+
if (field === "hour" && result.dayPeriod == null && "hour" in placeholder)
|
|
318
|
+
result.dayPeriod = toHourCycle(placeholder.hour, this.hourCycle)[0];
|
|
319
|
+
if (field === "year" && result.era == null)
|
|
320
|
+
result.era = placeholder.era;
|
|
321
|
+
// clear offset when a date/time field changes since it may no longer be valid
|
|
322
|
+
if (field !== "second" && field !== "literal" && field !== "timeZoneName")
|
|
323
|
+
result.offset = null;
|
|
324
|
+
return result;
|
|
325
|
+
}
|
|
326
|
+
/** Sets the given field to null. */
|
|
327
|
+
clear(field) {
|
|
328
|
+
const result = this.copy();
|
|
329
|
+
result[field] = null;
|
|
330
|
+
if (field === "year")
|
|
331
|
+
result.era = null;
|
|
332
|
+
// clear offset when a field is cleared since it may no longer be valid
|
|
333
|
+
result.offset = null;
|
|
334
|
+
return result;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Increments or decrements the given field. If it is null, then it is set to the placeholder
|
|
338
|
+
* value.
|
|
339
|
+
*/
|
|
340
|
+
cycle(field, amount, placeholder, displaySegments) {
|
|
341
|
+
const res = this.copy();
|
|
342
|
+
// If field is null, default to placeholder.
|
|
343
|
+
if (res[field] == null && field !== "dayPeriod" && field !== "era") {
|
|
344
|
+
if (field === "hour" && "hour" in placeholder) {
|
|
345
|
+
const [dayPeriod, hour] = toHourCycle(placeholder.hour, this.hourCycle);
|
|
346
|
+
res.dayPeriod = dayPeriod;
|
|
347
|
+
res.hour = hour;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
res[field] = placeholder[field];
|
|
351
|
+
}
|
|
352
|
+
if (field === "year" && res.era == null)
|
|
353
|
+
res.era = placeholder.era;
|
|
354
|
+
return res;
|
|
355
|
+
}
|
|
356
|
+
switch (field) {
|
|
357
|
+
case "era": {
|
|
358
|
+
const eras = this.calendar.getEras();
|
|
359
|
+
let index = eras.indexOf(res.era);
|
|
360
|
+
index = cycleValue(index, amount, 0, eras.length - 1);
|
|
361
|
+
res.era = eras[index];
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
case "year": {
|
|
365
|
+
// Use CalendarDate to cycle so that we update the era when going between 1 AD and 1 BC.
|
|
366
|
+
let date = new CalendarDate(this.calendar, this.era ?? placeholder.era, this.year ?? placeholder.year, this.month ?? 1, this.day ?? 1);
|
|
367
|
+
date = date.cycle(field, amount, { round: field === "year" });
|
|
368
|
+
res.era = date.era;
|
|
369
|
+
res.year = date.year;
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
case "month":
|
|
373
|
+
res.month = cycleValue(res.month ?? 1, amount, 1, this.calendar.getMaximumMonthsInYear());
|
|
374
|
+
break;
|
|
375
|
+
case "day":
|
|
376
|
+
// Allow incrementing up to the maximum number of days in any month.
|
|
377
|
+
res.day = cycleValue(res.day ?? 1, amount, 1, this.calendar.getMaximumDaysInMonth());
|
|
378
|
+
break;
|
|
379
|
+
case "hour": {
|
|
380
|
+
// if date is fully defined or it is just a time field, and we have a time zone, use toValue to get a ZonedDateTime to cycle
|
|
381
|
+
// so DST fallback is properly handled
|
|
382
|
+
const hasDateSegements = displaySegments.some((s) => ["year", "month", "day"].includes(s));
|
|
383
|
+
if ("timeZone" in placeholder && (!hasDateSegements || (res.year != null && res.month != null && res.day != null))) {
|
|
384
|
+
let date = this.toValue(placeholder);
|
|
385
|
+
date = date.cycle("hour", amount, { hourCycle: this.hourCycle === "h12" ? 12 : 24, round: false });
|
|
386
|
+
const [dayPeriod, adjustedHour] = toHourCycle(date.hour, this.hourCycle);
|
|
387
|
+
res.hour = adjustedHour;
|
|
388
|
+
res.dayPeriod = dayPeriod;
|
|
389
|
+
res.offset = date.offset;
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
const hours = res.hour ?? 0;
|
|
393
|
+
const limits = this.getSegmentLimits("hour");
|
|
394
|
+
res.hour = cycleValue(hours, amount, limits.minValue, limits.maxValue);
|
|
395
|
+
if (res.dayPeriod == null && "hour" in placeholder)
|
|
396
|
+
res.dayPeriod = toHourCycle(placeholder.hour, this.hourCycle)[0];
|
|
397
|
+
}
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
case "dayPeriod":
|
|
401
|
+
res.dayPeriod = cycleValue(res.dayPeriod ?? 0, amount, 0, 1);
|
|
402
|
+
break;
|
|
403
|
+
case "minute":
|
|
404
|
+
res.minute = cycleValue(res.minute ?? 0, amount, 0, 59, true);
|
|
405
|
+
break;
|
|
406
|
+
case "second":
|
|
407
|
+
res.second = cycleValue(res.second ?? 0, amount, 0, 59, true);
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
return res;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Converts the incomplete date to a full date value, using the provided value for any unset
|
|
414
|
+
* fields.
|
|
415
|
+
*/
|
|
416
|
+
toValue(value) {
|
|
417
|
+
if ("hour" in value) {
|
|
418
|
+
let hour = this.hour;
|
|
419
|
+
if (hour != null)
|
|
420
|
+
hour = fromHourCycle(hour, this.dayPeriod ?? 0, this.hourCycle);
|
|
421
|
+
else if (this.hourCycle === "h12" || this.hourCycle === "h11")
|
|
422
|
+
hour = this.dayPeriod === 1 ? 12 : 0;
|
|
423
|
+
let res = value.set({
|
|
424
|
+
era: this.era ?? value.era,
|
|
425
|
+
year: this.year ?? value.year,
|
|
426
|
+
month: this.month ?? value.month,
|
|
427
|
+
day: this.day ?? value.day,
|
|
428
|
+
hour: hour ?? value.hour,
|
|
429
|
+
minute: this.minute ?? value.minute,
|
|
430
|
+
second: this.second ?? value.second,
|
|
431
|
+
millisecond: this.millisecond ?? value.millisecond,
|
|
432
|
+
});
|
|
433
|
+
if ("offset" in res && this.offset != null && res.offset !== this.offset)
|
|
434
|
+
res = res.add({ milliseconds: res.offset - this.offset });
|
|
435
|
+
return res;
|
|
436
|
+
}
|
|
437
|
+
return value.set({ era: this.era ?? value.era, year: this.year ?? value.year, month: this.month ?? value.month, day: this.day ?? value.day });
|
|
438
|
+
}
|
|
439
|
+
getSegmentLimits(type) {
|
|
440
|
+
switch (type) {
|
|
441
|
+
case "era": {
|
|
442
|
+
const eras = this.calendar.getEras();
|
|
443
|
+
return { value: this.era != null ? eras.indexOf(this.era) : eras.length - 1, minValue: 0, maxValue: eras.length - 1 };
|
|
444
|
+
}
|
|
445
|
+
case "year":
|
|
446
|
+
return { value: this.year, minValue: 1, maxValue: 9999 };
|
|
447
|
+
case "month":
|
|
448
|
+
return { value: this.month, minValue: 1, maxValue: this.calendar.getMaximumMonthsInYear() };
|
|
449
|
+
case "day":
|
|
450
|
+
return { value: this.day, minValue: 1, maxValue: this.calendar.getMaximumDaysInMonth() };
|
|
451
|
+
case "dayPeriod":
|
|
452
|
+
return { value: this.dayPeriod, minValue: 0, maxValue: 1 };
|
|
453
|
+
case "hour": {
|
|
454
|
+
let minValue = 0;
|
|
455
|
+
let maxValue = 23;
|
|
456
|
+
if (this.hourCycle === "h12") {
|
|
457
|
+
minValue = 1;
|
|
458
|
+
maxValue = 12;
|
|
459
|
+
}
|
|
460
|
+
else if (this.hourCycle === "h11") {
|
|
461
|
+
minValue = 0;
|
|
462
|
+
maxValue = 11;
|
|
463
|
+
}
|
|
464
|
+
return { value: this.hour, minValue, maxValue };
|
|
465
|
+
}
|
|
466
|
+
case "minute":
|
|
467
|
+
return { value: this.minute, minValue: 0, maxValue: 59 };
|
|
468
|
+
case "second":
|
|
469
|
+
return { value: this.second, minValue: 0, maxValue: 59 };
|
|
470
|
+
}
|
|
471
|
+
return undefined;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
function cycleValue(value, amount, min, max, round = false) {
|
|
475
|
+
if (round) {
|
|
476
|
+
value += Math.sign(amount);
|
|
477
|
+
if (value < min)
|
|
478
|
+
value = max;
|
|
479
|
+
const div = Math.abs(amount);
|
|
480
|
+
if (amount > 0)
|
|
481
|
+
value = Math.ceil(value / div) * div;
|
|
482
|
+
else
|
|
483
|
+
value = Math.floor(value / div) * div;
|
|
484
|
+
if (value > max)
|
|
485
|
+
value = min;
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
value += amount;
|
|
489
|
+
if (value < min)
|
|
490
|
+
value = max - (min - value - 1);
|
|
491
|
+
else if (value > max)
|
|
492
|
+
value = min + (value - max - 1);
|
|
493
|
+
}
|
|
494
|
+
return value;
|
|
495
|
+
}
|
|
496
|
+
function toHourCycle(hour, hourCycle) {
|
|
497
|
+
let dayPeriod = hour >= 12 ? 1 : 0;
|
|
498
|
+
switch (hourCycle) {
|
|
499
|
+
case "h11":
|
|
500
|
+
// Hours are numbered from 0 to 11. Used in Japan.
|
|
501
|
+
if (hour >= 12)
|
|
502
|
+
hour -= 12;
|
|
503
|
+
break;
|
|
504
|
+
case "h12":
|
|
505
|
+
// Hours are numbered from 12 (representing 0) to 11.
|
|
506
|
+
if (hour === 0)
|
|
507
|
+
hour = 12;
|
|
508
|
+
else if (hour > 12)
|
|
509
|
+
hour -= 12;
|
|
510
|
+
break;
|
|
511
|
+
case "h23":
|
|
512
|
+
// 24 hour time, numbered 0 to 23.
|
|
513
|
+
dayPeriod = null;
|
|
514
|
+
break;
|
|
515
|
+
case "h24":
|
|
516
|
+
// 24 hour time numbered 24 to 23. Unused but supported by Intl.DateTimeFormat.
|
|
517
|
+
hour += 1;
|
|
518
|
+
dayPeriod = null;
|
|
519
|
+
}
|
|
520
|
+
return [dayPeriod, hour];
|
|
521
|
+
}
|
|
522
|
+
function fromHourCycle(hour, dayPeriod, hourCycle) {
|
|
523
|
+
switch (hourCycle) {
|
|
524
|
+
case "h11":
|
|
525
|
+
if (dayPeriod === 1)
|
|
526
|
+
hour += 12;
|
|
527
|
+
break;
|
|
528
|
+
case "h12":
|
|
529
|
+
if (hour === 12)
|
|
530
|
+
hour = 0;
|
|
531
|
+
if (dayPeriod === 1)
|
|
532
|
+
hour += 12;
|
|
533
|
+
break;
|
|
534
|
+
case "h24":
|
|
535
|
+
hour -= 1;
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
return hour;
|
|
539
|
+
}
|
|
540
|
+
/** The effective range (`controlledValue || placeholderValue`; a stale complete placeholder resets). */
|
|
541
|
+
export function rangeValueOf(model) {
|
|
542
|
+
const committed = model.value();
|
|
543
|
+
if (committed)
|
|
544
|
+
return committed;
|
|
545
|
+
const partial = model.partial();
|
|
546
|
+
// Reset the placeholder if the value prop is set to null.
|
|
547
|
+
return partial.start && partial.end ? { start: null, end: null } : partial;
|
|
548
|
+
}
|
|
549
|
+
export const isCompleteRange = (value) => value?.start != null && value.end != null;
|
|
550
|
+
/** A value cell the state may write: a Signal (two-way / internal). A read-only accessor (live controlled `value`) is
|
|
551
|
+
* never written: a change only calls `onChange`. */
|
|
552
|
+
export const isWritable = (cell) => typeof cell.set === "function";
|
|
553
|
+
/** React Stately `useDateRangePickerState` `setValue`: keeps the partial range, commits complete ones. */
|
|
554
|
+
export function writeRange(model, newValue) {
|
|
555
|
+
const value = newValue || { start: null, end: null };
|
|
556
|
+
const partial = { start: stringifyDateValue(value.start), end: stringifyDateValue(value.end) };
|
|
557
|
+
model.partial.set(partial);
|
|
558
|
+
const before = untrack(model.value);
|
|
559
|
+
if (isCompleteRange(value)) {
|
|
560
|
+
const next = partial;
|
|
561
|
+
if (!before || before.start !== next.start || before.end !== next.end) {
|
|
562
|
+
if (isWritable(model.value))
|
|
563
|
+
model.value.set(next);
|
|
564
|
+
model.onChange?.(value);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
else if (before !== null) {
|
|
568
|
+
if (isWritable(model.value))
|
|
569
|
+
model.value.set(null);
|
|
570
|
+
model.onChange?.(null);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
/** Whether the field / picker is disabled now (its live `isDisabled` accessor, else the creation value). Reads. */
|
|
574
|
+
export const ownerDisabled = (owner) => (owner.disabled ? !!owner.disabled() : owner.isDisabled);
|
|
575
|
+
/** Whether the field / picker is read-only now. Reads. */
|
|
576
|
+
export const ownerReadOnly = (owner) => (owner.readOnly ? !!owner.readOnly() : owner.isReadOnly);
|
|
577
|
+
/** Whether the field / picker is required now. Reads. */
|
|
578
|
+
export const ownerRequired = (owner) => (owner.required ? !!owner.required() : owner.isRequired);
|
|
579
|
+
// useTimeFieldState.ts helpers ----------------------------------------------------------------
|
|
580
|
+
const parseTimeValue = (text) => (text ? parseDateValue(text) : null);
|
|
581
|
+
/** useTimeFieldState `convertValue`: a `Time` as the date-time on `date` (default today); date-times unchanged. */
|
|
582
|
+
export function timeAsDateTime(value, date) {
|
|
583
|
+
if (!value)
|
|
584
|
+
return null;
|
|
585
|
+
if ("day" in value)
|
|
586
|
+
return value;
|
|
587
|
+
return toCalendarDateTime(date ?? today(getLocalTimeZone()), value);
|
|
588
|
+
}
|
|
589
|
+
/** The owner's value as a date value string (a TimeField's `Time` becomes today's date-time). Reads. */
|
|
590
|
+
export function ownerValueString(owner) {
|
|
591
|
+
const text = owner.value();
|
|
592
|
+
if (owner.kind !== "time" || !text)
|
|
593
|
+
return text;
|
|
594
|
+
const value = parseTimeValue(text);
|
|
595
|
+
return "day" in value ? text : stringifyDateValue(timeAsDateTime(value));
|
|
596
|
+
}
|
|
597
|
+
/** TimeField: the date of its value (or placeholder) when it has one (useTimeFieldState `day`). */
|
|
598
|
+
function timeDay(owner) {
|
|
599
|
+
const v = parseTimeValue(owner.value()) || parseTimeValue(owner.placeholderValue);
|
|
600
|
+
return v && "day" in v ? v : undefined;
|
|
601
|
+
}
|
|
602
|
+
/** The placeholder date of an owner (TimeField: placeholder time, default midnight, on today, zoned like the value). Reads. */
|
|
603
|
+
export function ownerPlaceholder(owner) {
|
|
604
|
+
if (owner.kind !== "time")
|
|
605
|
+
return parseValue(owner.placeholderValue);
|
|
606
|
+
const v = parseTimeValue(owner.value()) || parseTimeValue(owner.placeholderValue);
|
|
607
|
+
const timeZone = (v && "timeZone" in v ? v.timeZone : undefined) || owner.defaultTimeZone;
|
|
608
|
+
const placeholder = timeAsDateTime(parseTimeValue(owner.placeholderValue) ?? new Time());
|
|
609
|
+
return timeZone ? toZoned(placeholder, timeZone) : placeholder;
|
|
610
|
+
}
|
|
611
|
+
/** min / max of an owner (TimeField: a `Time` bound on the value's date, else today). Reads. */
|
|
612
|
+
function ownerBound(owner, text) {
|
|
613
|
+
if (owner.kind !== "time")
|
|
614
|
+
return parseValue(text);
|
|
615
|
+
return timeAsDateTime(parseTimeValue(text), timeDay(owner));
|
|
616
|
+
}
|
|
617
|
+
/** The value `validate` and `onChange` get: the owner's committed value as date object(s). Reads. */
|
|
618
|
+
function ownerUserValue(owner) {
|
|
619
|
+
if (owner.kind === "range") {
|
|
620
|
+
const range = owner.value();
|
|
621
|
+
return range ? { start: parseValue(range.start), end: parseValue(range.end) } : null;
|
|
622
|
+
}
|
|
623
|
+
return owner.kind === "time" ? parseTimeValue(owner.value()) : parseValue(owner.value());
|
|
624
|
+
}
|
|
625
|
+
/** Formatter options of an owner for its current value (validation messages, `formatValue`). */
|
|
626
|
+
export function ownerFormat(owner) {
|
|
627
|
+
let v, showEra;
|
|
628
|
+
if (owner.kind === "range") {
|
|
629
|
+
const range = rangeValueOf(owner);
|
|
630
|
+
const start = parseValue(range.start), end = parseValue(range.end);
|
|
631
|
+
v = start || end || ownerPlaceholder(owner);
|
|
632
|
+
showEra = (start?.calendar.identifier === "gregory" && start.era === "BC") || (end?.calendar.identifier === "gregory" && end.era === "BC");
|
|
633
|
+
}
|
|
634
|
+
else {
|
|
635
|
+
const value = parseValue(ownerValueString(owner));
|
|
636
|
+
v = value || ownerPlaceholder(owner);
|
|
637
|
+
showEra = value?.calendar.identifier === "gregory" && value.era === "BC";
|
|
638
|
+
}
|
|
639
|
+
const [granularity, timeZone] = defaultProps(v, owner.granularityProp, owner.last());
|
|
640
|
+
return {
|
|
641
|
+
granularity,
|
|
642
|
+
// useDateFieldState formatOpts: a field's maxGranularity (TimeField "hour": messages name the time only); pickers have none.
|
|
643
|
+
...(owner.kind === "picker" || owner.kind === "range" ? {} : { maxGranularity: owner.maxGranularity }),
|
|
644
|
+
timeZone,
|
|
645
|
+
hideTimeZone: owner.hideTimeZone,
|
|
646
|
+
hourCycle: owner.hourCycleProp,
|
|
647
|
+
shouldForceLeadingZeros: owner.shouldForceLeadingZeros,
|
|
648
|
+
showEra,
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
/** Built-in validation of the owner's current value. Reads the value. */
|
|
652
|
+
export function builtinValidation(owner) {
|
|
653
|
+
// useFormValidationState order: client (`validate`) errors win over the built-in ones.
|
|
654
|
+
if (owner.validate) {
|
|
655
|
+
const value = ownerUserValue(owner);
|
|
656
|
+
const custom = value == null ? null : customValidationResult(runValidate(owner.validate, value));
|
|
657
|
+
if (custom)
|
|
658
|
+
return custom;
|
|
659
|
+
}
|
|
660
|
+
const min = ownerBound(owner, owner.minValue), max = ownerBound(owner, owner.maxValue);
|
|
661
|
+
if (owner.kind === "range") {
|
|
662
|
+
const range = rangeValueOf(owner);
|
|
663
|
+
const unavailable = owner.isDateUnavailable;
|
|
664
|
+
return getRangeValidationResult({ start: parseValue(range.start), end: parseValue(range.end) }, min, max, unavailable ? (date) => unavailable(date, null) : undefined, ownerFormat(owner));
|
|
665
|
+
}
|
|
666
|
+
return getValidationResult(parseValue(ownerValueString(owner)), min, max, owner.isDateUnavailable, ownerFormat(owner));
|
|
667
|
+
}
|
|
668
|
+
/** Refresh the built-in validation signal (after a write, or before validity is synced). */
|
|
669
|
+
export function syncBuiltin(owner) {
|
|
670
|
+
const next = untrack(() => builtinValidation(owner));
|
|
671
|
+
if (!isEqualValidation(untrack(owner.builtin), next))
|
|
672
|
+
owner.builtin.set(next);
|
|
673
|
+
}
|
|
674
|
+
/** Owner validation displayed (aria-invalid, data-invalid, error message). Reads. */
|
|
675
|
+
export const ownerDisplayValidation = (owner) => displayValidation(owner.validation);
|
|
676
|
+
// ---------------------------------------------------------------------------------------------
|
|
677
|
+
// useDateFieldState.ts
|
|
678
|
+
const EDITABLE_SEGMENTS = {
|
|
679
|
+
year: true,
|
|
680
|
+
month: true,
|
|
681
|
+
day: true,
|
|
682
|
+
hour: true,
|
|
683
|
+
minute: true,
|
|
684
|
+
second: true,
|
|
685
|
+
dayPeriod: true,
|
|
686
|
+
era: true,
|
|
687
|
+
};
|
|
688
|
+
const PAGE_STEP = { year: 5, month: 2, day: 7, hour: 2, minute: 15, second: 15 };
|
|
689
|
+
const TYPE_MAPPING = {
|
|
690
|
+
// Node seems to convert everything to lowercase...
|
|
691
|
+
dayperiod: "dayPeriod",
|
|
692
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts#named_years
|
|
693
|
+
relatedYear: "year",
|
|
694
|
+
yearName: "literal", // not editable
|
|
695
|
+
unknown: "literal",
|
|
696
|
+
};
|
|
697
|
+
/** A value prop as the state's value signal: the caller's signal (two-way), or one starting at the plain value / default. */
|
|
698
|
+
export function dateValueSignal(value, defaultValue) {
|
|
699
|
+
if (typeof value === "function")
|
|
700
|
+
return controllable(value, null);
|
|
701
|
+
return controllable(undefined, toDateValueString(value !== undefined ? value : defaultValue));
|
|
702
|
+
}
|
|
703
|
+
function resolveCalendar(locale, hourCycle, create) {
|
|
704
|
+
// Resolve default hour cycle and calendar system. Pure per (locale, hour cycle) with the default calendar factory:
|
|
705
|
+
// memoised (an `Intl.DateTimeFormat` per field state was ~3% of a DatePicker mount, HOTPATH 2026-10-09).
|
|
706
|
+
const memo = create === undefined ? locale + "|" + hourCycle : null;
|
|
707
|
+
let resolved = memo === null ? undefined : calendars.get(memo);
|
|
708
|
+
if (resolved === undefined) {
|
|
709
|
+
const formatter = new DateFormatter(locale, { dateStyle: "short", timeStyle: "short", hour12: hourCycle != null ? hourCycle === 12 : undefined });
|
|
710
|
+
const opts = formatter.resolvedOptions();
|
|
711
|
+
resolved = [(create ?? createAnyCalendar)(opts.calendar).identifier, opts.hourCycle];
|
|
712
|
+
if (memo !== null) {
|
|
713
|
+
if (calendars.size >= 256)
|
|
714
|
+
calendars.clear();
|
|
715
|
+
calendars.set(memo, resolved);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return { calendar: resolved[0], hourCycle: resolved[1] };
|
|
719
|
+
}
|
|
720
|
+
const calendars = new Map();
|
|
721
|
+
// `formatter.resolvedOptions()` per formatter (a fresh native object per call; the formatters are cached and their
|
|
722
|
+
// options fixed): read-only callers inside the cdk share one (segments, segment ARIA text / style).
|
|
723
|
+
const resolvedCache = new WeakMap();
|
|
724
|
+
/** @internal Read-only `resolvedOptions()` of a (cached) formatter: never mutate the result. */
|
|
725
|
+
export function resolvedOptionsOf(formatter) {
|
|
726
|
+
let options = resolvedCache.get(formatter);
|
|
727
|
+
if (options === undefined)
|
|
728
|
+
resolvedCache.set(formatter, (options = formatter.resolvedOptions()));
|
|
729
|
+
return options;
|
|
730
|
+
}
|
|
731
|
+
/** Owner fields shared by DateField / DatePicker / DateRangePicker state. */
|
|
732
|
+
export function ownerBase(options, v, locale) {
|
|
733
|
+
const { isDisabled: disabled, isReadOnly: readOnly, isRequired: required } = options;
|
|
734
|
+
return {
|
|
735
|
+
locale,
|
|
736
|
+
minValue: toDateValueString(options.minValue),
|
|
737
|
+
maxValue: toDateValueString(options.maxValue),
|
|
738
|
+
placeholderValue: toDateValueString(options.placeholderValue),
|
|
739
|
+
...(options.granularity ? { granularityProp: options.granularity } : {}),
|
|
740
|
+
...(options.hourCycle ? { hourCycleProp: options.hourCycle } : {}),
|
|
741
|
+
...(options.hideTimeZone ? { hideTimeZone: true } : {}),
|
|
742
|
+
...(options.shouldForceLeadingZeros ? { shouldForceLeadingZeros: true } : {}),
|
|
743
|
+
// Live props: an accessor flag is stored as is (created by the component, resumable) and read at use
|
|
744
|
+
// (`ownerDisabled` / `ownerReadOnly` / `ownerRequired`); `isX` keeps the value at creation.
|
|
745
|
+
isDisabled: typeof disabled === "function" ? !!untrack(disabled) : (disabled ?? false),
|
|
746
|
+
isReadOnly: typeof readOnly === "function" ? !!untrack(readOnly) : (readOnly ?? false),
|
|
747
|
+
isRequired: typeof required === "function" ? !!untrack(required) : (required ?? false),
|
|
748
|
+
...(typeof disabled === "function" ? { disabled } : {}),
|
|
749
|
+
...(typeof readOnly === "function" ? { readOnly } : {}),
|
|
750
|
+
...(typeof required === "function" ? { required } : {}),
|
|
751
|
+
last: signal(v ? lastFormatOf(v) : { granularity: "day", timeZone: null }),
|
|
752
|
+
builtin: signal(VALID_VALIDITY_RESULT),
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
const VALID_VALIDITY_RESULT = { isInvalid: false, validationErrors: [], validationDetails: VALID_VALIDITY_STATE };
|
|
756
|
+
/**
|
|
757
|
+
* `useDateFieldState`: state of a standalone DateField (its own value + validation). Pickers
|
|
758
|
+
* create their fields with `createPickerFieldState`.
|
|
759
|
+
*/
|
|
760
|
+
export function createDateFieldState(options = {}) {
|
|
761
|
+
const value = dateValueSignal(options.value, options.defaultValue);
|
|
762
|
+
return fieldState(options, value, "field");
|
|
763
|
+
}
|
|
764
|
+
/** @internal A standalone field state (DateField, or TimeField with `kind: "time"`) over its value signal. */
|
|
765
|
+
export function fieldState(options, value, kind) {
|
|
766
|
+
const locale = resolveLocale(options.locale);
|
|
767
|
+
const initial = untrack(value);
|
|
768
|
+
const time = kind === "time";
|
|
769
|
+
const parse = (text) => (time ? timeAsDateTime(parseTimeValue(text)) : parseValue(text));
|
|
770
|
+
const v = parse(initial) || parse(toDateValueString(options.defaultValue)) || parse(toDateValueString(options.placeholderValue));
|
|
771
|
+
// props.granularity must actually exist in the value if one is provided.
|
|
772
|
+
defaultProps(v, options.granularity, { granularity: "day", timeZone: null });
|
|
773
|
+
const base = ownerBase(options, v, locale);
|
|
774
|
+
// TimeField (useTimeFieldState): the calendar should not matter for time fields, so it is Gregorian. Rivet: the
|
|
775
|
+
// identifier only (no `createCalendar` function in the state: it would not serialize).
|
|
776
|
+
const { calendar, hourCycle } = resolveCalendar(locale, options.hourCycle, time ? () => new GregorianCalendar() : options.createCalendar);
|
|
777
|
+
const state = {
|
|
778
|
+
...base,
|
|
779
|
+
kind,
|
|
780
|
+
id: options.id ?? createId(),
|
|
781
|
+
calendar,
|
|
782
|
+
...(options.createCalendar ? { createCalendar: options.createCalendar } : {}),
|
|
783
|
+
hourCycle,
|
|
784
|
+
maxGranularity: options.maxGranularity ?? "year",
|
|
785
|
+
value,
|
|
786
|
+
// TimeField: the date-time the field edits (useTimeFieldState `defaultDateTime`).
|
|
787
|
+
defaultValue: time ? stringifyDateValue(parse(toDateValueString(options.defaultValue) ?? initial)) : (toDateValueString(options.defaultValue) ?? initial),
|
|
788
|
+
display: signal(null),
|
|
789
|
+
...(options.defaultTimeZone ? { defaultTimeZone: options.defaultTimeZone } : {}),
|
|
790
|
+
...(options.onChange ? { onChange: options.onChange } : {}),
|
|
791
|
+
...(options.isDateUnavailable ? { isDateUnavailable: options.isDateUnavailable } : {}),
|
|
792
|
+
...(options.validate ? { validate: options.validate } : {}),
|
|
793
|
+
validation: createFormValidationState({
|
|
794
|
+
isInvalid: options.isInvalid,
|
|
795
|
+
validationState: options.validationState,
|
|
796
|
+
validationBehavior: options.validationBehavior ?? "aria",
|
|
797
|
+
name: options.name,
|
|
798
|
+
validationErrors: options.validationErrors,
|
|
799
|
+
builtinValidation: base.builtin,
|
|
800
|
+
value,
|
|
801
|
+
}),
|
|
802
|
+
};
|
|
803
|
+
state.builtin.set(untrack(() => builtinValidation(state)));
|
|
804
|
+
return state;
|
|
805
|
+
}
|
|
806
|
+
/** The field of a DatePicker (`link.owner`) or one end of a DateRangePicker (`link.part`). */
|
|
807
|
+
export function createPickerFieldState(link, options) {
|
|
808
|
+
const { calendar, hourCycle } = resolveCalendar(options.locale, link.owner.hourCycleProp, options.createCalendar);
|
|
809
|
+
return {
|
|
810
|
+
id: options.id,
|
|
811
|
+
locale: options.locale,
|
|
812
|
+
calendar,
|
|
813
|
+
...(options.createCalendar ? { createCalendar: options.createCalendar } : {}),
|
|
814
|
+
hourCycle,
|
|
815
|
+
maxGranularity: options.maxGranularity ?? "year",
|
|
816
|
+
owner: link.owner,
|
|
817
|
+
...("part" in link ? { part: link.part } : {}),
|
|
818
|
+
defaultValue: options.defaultValue,
|
|
819
|
+
display: signal(null),
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
// Accessors ------------------------------------------------------------------------------------
|
|
823
|
+
/** The value owner of a field: its picker, or the (standalone) field itself. */
|
|
824
|
+
export const ownerOf = (state) => state.owner ?? state;
|
|
825
|
+
/** The display calendar system of the field. */
|
|
826
|
+
export function calendarOf(state) {
|
|
827
|
+
return (state.createCalendar ?? createAnyCalendar)(state.calendar);
|
|
828
|
+
}
|
|
829
|
+
/** The field's value (string form; owner calendar). Reads. */
|
|
830
|
+
export function fieldValueString(state) {
|
|
831
|
+
const owner = ownerOf(state);
|
|
832
|
+
if (owner.kind === "range")
|
|
833
|
+
return rangeValueOf(owner)[state.part];
|
|
834
|
+
return ownerValueString(owner);
|
|
835
|
+
}
|
|
836
|
+
/** The value the emitted dates keep the calendar of (`props.value || props.defaultValue || props.placeholderValue`). */
|
|
837
|
+
function originalValue(state) {
|
|
838
|
+
return parseValue(fieldValueString(state)) || parseValue(state.defaultValue) || ownerPlaceholder(ownerOf(state));
|
|
839
|
+
}
|
|
840
|
+
/** `[granularity, defaultTimeZone]` of the field. Reads. */
|
|
841
|
+
function fieldDefaults(state) {
|
|
842
|
+
return defaultProps(originalValue(state), ownerOf(state).granularityProp, ownerOf(state).last());
|
|
843
|
+
}
|
|
844
|
+
/** The granularity for the field, based on the `granularity` prop and current value. Reads. */
|
|
845
|
+
export const fieldGranularity = (state) => fieldDefaults(state)[0];
|
|
846
|
+
/** The current value in the display calendar (React Stately `state.value`). Reads. */
|
|
847
|
+
export function fieldValue(state) {
|
|
848
|
+
return convertValue(parseValue(fieldValueString(state)), calendarOf(state)) ?? null;
|
|
849
|
+
}
|
|
850
|
+
/** The current display value: the editing override when it belongs to the current value, else the value. Reads. */
|
|
851
|
+
export function displayValue(state) {
|
|
852
|
+
const override = state.display(), current = fieldValueString(state);
|
|
853
|
+
if (override && override.base === current)
|
|
854
|
+
return IncompleteDate.fromFields(calendarOf(state), state.hourCycle, override.fields);
|
|
855
|
+
return new IncompleteDate(calendarOf(state), state.hourCycle, fieldValue(state));
|
|
856
|
+
}
|
|
857
|
+
function formatOpts(state, display) {
|
|
858
|
+
const [granularity, defaultTimeZone] = fieldDefaults(state);
|
|
859
|
+
return {
|
|
860
|
+
granularity,
|
|
861
|
+
maxGranularity: state.maxGranularity,
|
|
862
|
+
timeZone: defaultTimeZone,
|
|
863
|
+
hideTimeZone: ownerOf(state).hideTimeZone,
|
|
864
|
+
hourCycle: ownerOf(state).hourCycleProp,
|
|
865
|
+
showEra: state.calendar === "gregory" && display.era === "BC",
|
|
866
|
+
shouldForceLeadingZeros: ownerOf(state).shouldForceLeadingZeros,
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
/** The placeholder date used for unset segments (today at midnight unless `placeholderValue`). Reads. */
|
|
870
|
+
export function placeholderDate(state) {
|
|
871
|
+
const [granularity, defaultTimeZone] = fieldDefaults(state);
|
|
872
|
+
return createPlaceholderDate(ownerPlaceholder(ownerOf(state)), granularity, calendarOf(state), defaultTimeZone);
|
|
873
|
+
}
|
|
874
|
+
/** The segments the field displays (types only), from `maxGranularity` to the granularity. */
|
|
875
|
+
export function displaySegments(state) {
|
|
876
|
+
const granularity = fieldGranularity(state);
|
|
877
|
+
const is12HourClock = state.hourCycle === "h11" || state.hourCycle === "h12";
|
|
878
|
+
const segments = ["era", "year", "month", "day", "hour", ...(is12HourClock ? ["dayPeriod"] : []), "minute", "second"];
|
|
879
|
+
const minIndex = segments.indexOf(state.maxGranularity || "era");
|
|
880
|
+
const maxIndex = segments.indexOf(granularity === "hour" && is12HourClock ? "dayPeriod" : granularity);
|
|
881
|
+
return segments.slice(minIndex, maxIndex + 1);
|
|
882
|
+
}
|
|
883
|
+
/** The date formatter of the field (locale + format options). Reads. */
|
|
884
|
+
export function fieldDateFormatter(state) {
|
|
885
|
+
return getDateFormatter(state.locale, getFormatOptions({}, formatOpts(state, displayValue(state))));
|
|
886
|
+
}
|
|
887
|
+
/** The current value as a native `Date` (placeholder fields fill the unset ones). Reads. */
|
|
888
|
+
export function fieldDateValue(state) {
|
|
889
|
+
const display = displayValue(state);
|
|
890
|
+
const [, defaultTimeZone] = fieldDefaults(state);
|
|
891
|
+
return display.toValue(fieldValue(state) ?? placeholderDate(state)).toDate(defaultTimeZone || "UTC");
|
|
892
|
+
}
|
|
893
|
+
const segmentCache = new WeakMap();
|
|
894
|
+
/** A list of segments for the current value. Reads. */
|
|
895
|
+
export function segments(state) {
|
|
896
|
+
const display = displayValue(state);
|
|
897
|
+
const [granularity, defaultTimeZone] = fieldDefaults(state);
|
|
898
|
+
const key = JSON.stringify([fieldValueString(state), display.toFields(), granularity, defaultTimeZone]);
|
|
899
|
+
const hit = segmentCache.get(state);
|
|
900
|
+
if (hit && hit.key === key)
|
|
901
|
+
return hit.segments;
|
|
902
|
+
const opts = formatOpts(state, display);
|
|
903
|
+
const dateFormatter = getDateFormatter(state.locale, getFormatOptions({}, opts));
|
|
904
|
+
const dateValue = display.toValue(fieldValue(state) ?? placeholderDate(state)).toDate(defaultTimeZone || "UTC");
|
|
905
|
+
const result = processSegments(dateValue, display, dateFormatter, resolvedOptionsOf(dateFormatter), calendarOf(state), state.locale, granularity);
|
|
906
|
+
segmentCache.set(state, { key, segments: result });
|
|
907
|
+
return result;
|
|
908
|
+
}
|
|
909
|
+
const numberFormatters = new Map();
|
|
910
|
+
function numberFormatter(locale, twoDigit) {
|
|
911
|
+
const key = locale + (twoDigit ? "|2" : "");
|
|
912
|
+
let formatter = numberFormatters.get(key);
|
|
913
|
+
if (!formatter)
|
|
914
|
+
numberFormatters.set(key, (formatter = new Intl.NumberFormat(locale, { useGrouping: false, ...(twoDigit ? { minimumIntegerDigits: 2 } : {}) })));
|
|
915
|
+
return formatter;
|
|
916
|
+
}
|
|
917
|
+
function processSegments(dateValue, displayValue, dateFormatter, resolvedOptions, calendar, locale, granularity) {
|
|
918
|
+
const timeValue = ["hour", "minute", "second"];
|
|
919
|
+
const segments = dateFormatter.formatToParts(dateValue);
|
|
920
|
+
// In order to allow formatting temporarily invalid dates during editing (e.g. February 30th),
|
|
921
|
+
// use a NumberFormatter to manually format segments directly from raw numbers.
|
|
922
|
+
// When the user blurs the date field, the invalid segments will be constrained.
|
|
923
|
+
for (const segment of segments) {
|
|
924
|
+
if (segment.type === "year" || segment.type === "month" || segment.type === "day" || segment.type === "hour") {
|
|
925
|
+
const value = displayValue[segment.type] ?? 0;
|
|
926
|
+
segment.value = numberFormatter(locale, resolvedOptions[segment.type] === "2-digit").format(value);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
const processedSegments = [];
|
|
930
|
+
const literal = (text) => ({ type: "literal", text, isPlaceholder: false, placeholder: "", isEditable: false });
|
|
931
|
+
for (const segment of segments) {
|
|
932
|
+
const type = (TYPE_MAPPING[segment.type] || segment.type);
|
|
933
|
+
let isEditable = !!EDITABLE_SEGMENTS[type];
|
|
934
|
+
if (type === "era" && calendar.getEras().length === 1)
|
|
935
|
+
isEditable = false;
|
|
936
|
+
const isPlaceholder = !!EDITABLE_SEGMENTS[type] && displayValue[segment.type] == null;
|
|
937
|
+
const placeholder = EDITABLE_SEGMENTS[type] ? getPlaceholder(type, segment.value, locale) : "";
|
|
938
|
+
const dateSegment = {
|
|
939
|
+
type,
|
|
940
|
+
text: isPlaceholder ? placeholder : segment.value,
|
|
941
|
+
...displayValue.getSegmentLimits(type),
|
|
942
|
+
isPlaceholder,
|
|
943
|
+
placeholder,
|
|
944
|
+
isEditable,
|
|
945
|
+
};
|
|
946
|
+
// There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).
|
|
947
|
+
// To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.
|
|
948
|
+
// These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change.
|
|
949
|
+
if (type === "hour") {
|
|
950
|
+
// This marks the start of the embedded direction change.
|
|
951
|
+
processedSegments.push(literal(""));
|
|
952
|
+
processedSegments.push(dateSegment);
|
|
953
|
+
// This marks the end of the embedded direction change in the case that the granularity it set to "hour".
|
|
954
|
+
if (type === granularity)
|
|
955
|
+
processedSegments.push(literal(""));
|
|
956
|
+
}
|
|
957
|
+
else if (timeValue.includes(type) && type === granularity) {
|
|
958
|
+
processedSegments.push(dateSegment);
|
|
959
|
+
// This marks the end of the embedded direction change.
|
|
960
|
+
processedSegments.push(literal(""));
|
|
961
|
+
}
|
|
962
|
+
else {
|
|
963
|
+
// We only want to "wrap" the unicode around segments that are hour, minute, or second. If they aren't, just process as normal.
|
|
964
|
+
processedSegments.push(dateSegment);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
return processedSegments;
|
|
968
|
+
}
|
|
969
|
+
/** Owner validation displayed for the field. Reads. */
|
|
970
|
+
export const fieldDisplayValidation = (state) => displayValidation(ownerOf(state).validation);
|
|
971
|
+
/** Whether the date field is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. Reads. */
|
|
972
|
+
export const isFieldInvalid = (state) => fieldDisplayValidation(state).isInvalid;
|
|
973
|
+
/** @deprecated Use `isFieldInvalid`. */
|
|
974
|
+
export const fieldValidationState = (state) => (isFieldInvalid(state) ? "invalid" : null);
|
|
975
|
+
// Writes ----------------------------------------------------------------------------------------
|
|
976
|
+
/** Emit `newValue` (owner calendar) to the owner. */
|
|
977
|
+
function setDate(state, newValue) {
|
|
978
|
+
const owner = ownerOf(state);
|
|
979
|
+
if (owner.kind === "range") {
|
|
980
|
+
// useDateRangePicker field `onChange`: state.setDateTime(part, value).
|
|
981
|
+
const range = untrack(() => rangeValueOf(owner));
|
|
982
|
+
const other = parseValue(state.part === "start" ? range.end : range.start);
|
|
983
|
+
writeRange(owner, state.part === "start" ? { start: newValue, end: other } : { start: other, end: newValue });
|
|
984
|
+
}
|
|
985
|
+
else {
|
|
986
|
+
let emitted = newValue;
|
|
987
|
+
// useTimeFieldState onChange: a Time unless the value / placeholder has a date or a time zone.
|
|
988
|
+
if (owner.kind === "time" && newValue && !untrack(() => timeDay(owner)) && !owner.defaultTimeZone)
|
|
989
|
+
emitted = toTime(newValue);
|
|
990
|
+
const text = stringifyDateValue(emitted);
|
|
991
|
+
if (untrack(owner.value) !== text) {
|
|
992
|
+
if (isWritable(owner.value))
|
|
993
|
+
owner.value.set(text);
|
|
994
|
+
owner.onChange?.(emitted);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
noteLast(owner.last, newValue);
|
|
998
|
+
syncBuiltin(owner);
|
|
999
|
+
}
|
|
1000
|
+
const peekDisplay = (state) => untrack(() => displayValue(state));
|
|
1001
|
+
const writeDisplay = (state, display) => {
|
|
1002
|
+
state.display.set(display ? { base: untrack(() => fieldValueString(state)), fields: display.toFields() } : null);
|
|
1003
|
+
};
|
|
1004
|
+
/** Sets the field's value: a date, or an (incomplete) display value while editing. */
|
|
1005
|
+
export function setValue(state, newValue) {
|
|
1006
|
+
const owner = ownerOf(state);
|
|
1007
|
+
if (ownerDisabled(owner) || ownerReadOnly(owner))
|
|
1008
|
+
return;
|
|
1009
|
+
const segmentTypes = untrack(() => displaySegments(state));
|
|
1010
|
+
const original = untrack(() => originalValue(state));
|
|
1011
|
+
if (newValue == null || (newValue instanceof IncompleteDate && newValue.isCleared(segmentTypes))) {
|
|
1012
|
+
writeDisplay(state, null);
|
|
1013
|
+
setDate(state, null);
|
|
1014
|
+
}
|
|
1015
|
+
else if (!(newValue instanceof IncompleteDate)) {
|
|
1016
|
+
// The display calendar should not have any effect on the emitted value.
|
|
1017
|
+
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
|
|
1018
|
+
writeDisplay(state, null);
|
|
1019
|
+
setDate(state, toCalendar(newValue, original?.calendar || new GregorianCalendar()));
|
|
1020
|
+
}
|
|
1021
|
+
else {
|
|
1022
|
+
// If the new value is complete and valid, trigger onChange eagerly.
|
|
1023
|
+
// If it represents an incomplete or invalid value (e.g. February 30th),
|
|
1024
|
+
// wait until the field is blurred to trigger onChange.
|
|
1025
|
+
if (newValue.isComplete(segmentTypes)) {
|
|
1026
|
+
const { calendarValue, placeholder, value } = untrack(() => ({
|
|
1027
|
+
calendarValue: fieldValue(state),
|
|
1028
|
+
placeholder: placeholderDate(state),
|
|
1029
|
+
value: parseValue(fieldValueString(state)),
|
|
1030
|
+
}));
|
|
1031
|
+
const dateValue = newValue.toValue(calendarValue ?? placeholder);
|
|
1032
|
+
if (newValue.validate(dateValue, segmentTypes)) {
|
|
1033
|
+
const newDateValue = toCalendar(dateValue, original?.calendar || new GregorianCalendar());
|
|
1034
|
+
if (!value || newDateValue.compare(value) !== 0) {
|
|
1035
|
+
writeDisplay(state, null); // reset in case prop isn't updated
|
|
1036
|
+
setDate(state, newDateValue);
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
// Incomplete/invalid value. Set temporary display override.
|
|
1042
|
+
writeDisplay(state, newValue);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
function adjustSegment(state, type, amount) {
|
|
1046
|
+
const { display, placeholder, segmentTypes } = untrack(() => ({
|
|
1047
|
+
display: displayValue(state),
|
|
1048
|
+
placeholder: placeholderDate(state),
|
|
1049
|
+
segmentTypes: displaySegments(state),
|
|
1050
|
+
}));
|
|
1051
|
+
setValue(state, display.cycle(type, amount, placeholder, segmentTypes));
|
|
1052
|
+
}
|
|
1053
|
+
/** Increments the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */
|
|
1054
|
+
export const increment = (state, part) => adjustSegment(state, part, 1);
|
|
1055
|
+
/** Decrements the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */
|
|
1056
|
+
export const decrement = (state, part) => adjustSegment(state, part, -1);
|
|
1057
|
+
/** Increments the given segment by a larger amount, rounding it to the nearest increment (15 minutes, 7 days, 5 years …). */
|
|
1058
|
+
export const incrementPage = (state, part) => adjustSegment(state, part, PAGE_STEP[part] || 1);
|
|
1059
|
+
/** Decrements the given segment by a larger amount, rounding it to the nearest increment. */
|
|
1060
|
+
export const decrementPage = (state, part) => adjustSegment(state, part, -(PAGE_STEP[part] || 1));
|
|
1061
|
+
/** Increments the given segment to its maxiumum value. */
|
|
1062
|
+
export function incrementToMax(state, part) {
|
|
1063
|
+
const display = peekDisplay(state);
|
|
1064
|
+
const maxValue = part === "hour" && state.hourCycle === "h12" ? 11 : display.getSegmentLimits(part).maxValue;
|
|
1065
|
+
setValue(state, display.set(part, maxValue, untrack(() => placeholderDate(state))));
|
|
1066
|
+
}
|
|
1067
|
+
/** Decrements the given segment to its minimum value. */
|
|
1068
|
+
export function decrementToMin(state, part) {
|
|
1069
|
+
const display = peekDisplay(state);
|
|
1070
|
+
const minValue = part === "hour" && state.hourCycle === "h12" ? 12 : display.getSegmentLimits(part).minValue;
|
|
1071
|
+
setValue(state, display.set(part, minValue, untrack(() => placeholderDate(state))));
|
|
1072
|
+
}
|
|
1073
|
+
/** Sets the value of the given segment. */
|
|
1074
|
+
export function setSegment(state, part, v) {
|
|
1075
|
+
setValue(state, peekDisplay(state).set(part, v, untrack(() => placeholderDate(state))));
|
|
1076
|
+
}
|
|
1077
|
+
/** Updates the remaining unfilled segments with the placeholder value. */
|
|
1078
|
+
export function confirmPlaceholder(state) {
|
|
1079
|
+
const owner = ownerOf(state);
|
|
1080
|
+
if (ownerDisabled(owner) || ownerReadOnly(owner))
|
|
1081
|
+
return;
|
|
1082
|
+
const display = peekDisplay(state);
|
|
1083
|
+
// If the display value is complete but invalid, we need to constrain it and emit onChange on blur.
|
|
1084
|
+
if (display.isComplete(untrack(() => displaySegments(state)))) {
|
|
1085
|
+
const { calendarValue, placeholder, value, original } = untrack(() => ({
|
|
1086
|
+
calendarValue: fieldValue(state),
|
|
1087
|
+
placeholder: placeholderDate(state),
|
|
1088
|
+
value: parseValue(fieldValueString(state)),
|
|
1089
|
+
original: originalValue(state),
|
|
1090
|
+
}));
|
|
1091
|
+
const dateValue = display.toValue(calendarValue ?? placeholder);
|
|
1092
|
+
const newDateValue = toCalendar(dateValue, original?.calendar || new GregorianCalendar());
|
|
1093
|
+
if (!value || newDateValue.compare(value) !== 0)
|
|
1094
|
+
setDate(state, newDateValue);
|
|
1095
|
+
writeDisplay(state, null);
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
/** Clears the value of the given segment, reverting it to the placeholder. */
|
|
1099
|
+
export function clearSegment(state, part) {
|
|
1100
|
+
let value = peekDisplay(state);
|
|
1101
|
+
if (part !== "timeZoneName" && part !== "literal")
|
|
1102
|
+
value = value.clear(part);
|
|
1103
|
+
setValue(state, value);
|
|
1104
|
+
}
|
|
1105
|
+
/** Formats the current date value using the given options. Reads. */
|
|
1106
|
+
export function formatValue(state, fieldOptions) {
|
|
1107
|
+
if (!fieldValue(state))
|
|
1108
|
+
return "";
|
|
1109
|
+
const formatOptions = getFormatOptions(fieldOptions, formatOpts(state, displayValue(state)));
|
|
1110
|
+
return new DateFormatter(state.locale, formatOptions).format(fieldDateValue(state));
|
|
1111
|
+
}
|
|
1112
|
+
/** Gets a formatter based on state's props. */
|
|
1113
|
+
export function getFieldDateFormatter(state, locale, formatOptions) {
|
|
1114
|
+
const newOptions = { ...untrack(() => formatOpts(state, displayValue(state))), ...formatOptions };
|
|
1115
|
+
return new DateFormatter(locale, getFormatOptions({}, newOptions));
|
|
1116
|
+
}
|
|
1117
|
+
export { CalendarDate };
|