@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
package/color/color.js
ADDED
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
// Ported from react-stately color model (packages/react-stately/src/color/Color.ts, types.ts, useColor.ts;
|
|
2
|
+
// published as @react-stately/color parseColor / getColorChannels), Apache-2.0, © Adobe.
|
|
3
|
+
// Rivet:
|
|
4
|
+
// - Localized strings come from `./intl.ts` (generated from react-stately intl/color/*.json) through
|
|
5
|
+
// `@rivetjs/cdk/i18n` `getStringsForLocale` + `formatString` (the templates are plain `{name}`
|
|
6
|
+
// placeholders, no ICU); `LocalizedStringDictionary.getGlobalDictionaryForPackage` (build-time
|
|
7
|
+
// string extraction) is not ported.
|
|
8
|
+
// - `useColor(value)` → `toColor(value)` (plain function, no memo). Constructor parameter properties →
|
|
9
|
+
// explicit fields (`erasableSyntaxOnly`); `abstract class Color` → `BaseColor` (the interface keeps `Color`).
|
|
10
|
+
// - Added `stringifyColor` / `colorKey`: lossless string form of a color in its own color space; the
|
|
11
|
+
// color states keep this string in their signals (class instances are not serializable for resume).
|
|
12
|
+
import { clamp, toFixedNumber } from "@rivetjs/cdk/utils";
|
|
13
|
+
import { formatString, getStringsForLocale } from "@rivetjs/cdk/i18n";
|
|
14
|
+
import { NumberFormatter } from "../number/NumberFormatter.js";
|
|
15
|
+
import { colorMessages } from "./intl.js";
|
|
16
|
+
/** Localized string `key` for `locale` (react-stately `LocalizedStringDictionary.getStringForLocale`). */
|
|
17
|
+
function getStringForLocale(key, locale) {
|
|
18
|
+
const string = getStringsForLocale(colorMessages, locale)[key];
|
|
19
|
+
if (!string)
|
|
20
|
+
throw new Error(`Could not find intl message ${key} in ${locale} locale`);
|
|
21
|
+
return string;
|
|
22
|
+
}
|
|
23
|
+
/** Parses a color from a string value. Throws an error if the string could not be parsed. */
|
|
24
|
+
export function parseColor(value) {
|
|
25
|
+
const res = RGBColor.parse(value) || HSBColor.parse(value) || HSLColor.parse(value);
|
|
26
|
+
if (res) {
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
29
|
+
throw new Error("Invalid color value: " + value);
|
|
30
|
+
}
|
|
31
|
+
export function normalizeColor(v) {
|
|
32
|
+
if (typeof v === "string") {
|
|
33
|
+
return parseColor(v);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return v;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** react-stately `useColor`: parses a string (invalid → `undefined`), passes a Color / null / undefined through. */
|
|
40
|
+
export function toColor(value) {
|
|
41
|
+
if (typeof value === "string") {
|
|
42
|
+
try {
|
|
43
|
+
return parseColor(value);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
/** Returns a list of color channels for a given color space. */
|
|
52
|
+
export function getColorChannels(colorSpace) {
|
|
53
|
+
switch (colorSpace) {
|
|
54
|
+
case "rgb":
|
|
55
|
+
return RGBColor.colorChannels;
|
|
56
|
+
case "hsl":
|
|
57
|
+
return HSLColor.colorChannels;
|
|
58
|
+
case "hsb":
|
|
59
|
+
return HSBColor.colorChannels;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Returns the hue value normalized to the range of 0 to 360. */
|
|
63
|
+
export function normalizeHue(hue) {
|
|
64
|
+
if (hue === 360) {
|
|
65
|
+
return hue;
|
|
66
|
+
}
|
|
67
|
+
return ((hue % 360) + 360) % 360;
|
|
68
|
+
}
|
|
69
|
+
// Rivet: decimal (never exponent) form, so the hsl / hsb parse regexes read it back.
|
|
70
|
+
function num(n) {
|
|
71
|
+
const s = String(n);
|
|
72
|
+
return s.includes("e") ? n.toFixed(20).replace(/\.?0+$/, "") : s;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Rivet: lossless string form of `color` in its own color space (`rgba(…)`, `hsla(…)`, `hsba(…)` with
|
|
76
|
+
* unrounded channels); `parseColor(stringifyColor(c))` restores the same space and channel values.
|
|
77
|
+
*/
|
|
78
|
+
export function stringifyColor(color) {
|
|
79
|
+
const space = color.getColorSpace();
|
|
80
|
+
const [a, b, c] = color.getColorChannels().map((ch) => num(color.getChannelValue(ch)));
|
|
81
|
+
const alpha = num(color.getChannelValue("alpha"));
|
|
82
|
+
return space === "rgb" ? `rgba(${a}, ${b}, ${c}, ${alpha})` : `${space}a(${a}, ${b}%, ${c}%, ${alpha})`;
|
|
83
|
+
}
|
|
84
|
+
/** Rivet: identity key of a stored color value (string or Color): `stringifyColor` of the parsed value; invalid strings → `undefined`, null / undefined pass through. */
|
|
85
|
+
export function colorKey(value) {
|
|
86
|
+
const color = toColor(value);
|
|
87
|
+
return color == null ? color : stringifyColor(color);
|
|
88
|
+
}
|
|
89
|
+
// Lightness threshold between orange and brown.
|
|
90
|
+
const ORANGE_LIGHTNESS_THRESHOLD = 0.68;
|
|
91
|
+
// Lightness threshold between pure yellow and "yellow green".
|
|
92
|
+
const YELLOW_GREEN_LIGHTNESS_THRESHOLD = 0.85;
|
|
93
|
+
// The maximum lightness considered to be "dark".
|
|
94
|
+
const MAX_DARK_LIGHTNESS = 0.55;
|
|
95
|
+
// The chroma threshold between gray and color.
|
|
96
|
+
const GRAY_THRESHOLD = 0.001;
|
|
97
|
+
const OKLCH_HUES = [
|
|
98
|
+
[0, "pink"],
|
|
99
|
+
[15, "red"],
|
|
100
|
+
[48, "orange"],
|
|
101
|
+
[94, "yellow"],
|
|
102
|
+
[135, "green"],
|
|
103
|
+
[175, "cyan"],
|
|
104
|
+
[264, "blue"],
|
|
105
|
+
[284, "purple"],
|
|
106
|
+
[320, "magenta"],
|
|
107
|
+
[349, "pink"],
|
|
108
|
+
];
|
|
109
|
+
class BaseColor {
|
|
110
|
+
toHexInt() {
|
|
111
|
+
return this.toFormat("rgb").toHexInt();
|
|
112
|
+
}
|
|
113
|
+
getChannelValue(channel) {
|
|
114
|
+
if (channel in this) {
|
|
115
|
+
return this[channel];
|
|
116
|
+
}
|
|
117
|
+
throw new Error("Unsupported color channel: " + channel);
|
|
118
|
+
}
|
|
119
|
+
withChannelValue(channel, value) {
|
|
120
|
+
if (channel in this) {
|
|
121
|
+
const x = this.clone();
|
|
122
|
+
x[channel] = value;
|
|
123
|
+
return x;
|
|
124
|
+
}
|
|
125
|
+
throw new Error("Unsupported color channel: " + channel);
|
|
126
|
+
}
|
|
127
|
+
getChannelName(channel, locale) {
|
|
128
|
+
return getStringForLocale(channel, locale);
|
|
129
|
+
}
|
|
130
|
+
getColorSpaceAxes(xyChannels) {
|
|
131
|
+
const { xChannel, yChannel } = xyChannels;
|
|
132
|
+
const xCh = xChannel || this.getColorChannels().find((c) => c !== yChannel);
|
|
133
|
+
const yCh = yChannel || this.getColorChannels().find((c) => c !== xCh);
|
|
134
|
+
const zCh = this.getColorChannels().find((c) => c !== xCh && c !== yCh);
|
|
135
|
+
return { xChannel: xCh, yChannel: yCh, zChannel: zCh };
|
|
136
|
+
}
|
|
137
|
+
getColorName(locale) {
|
|
138
|
+
// Convert to oklch color space, which has perceptually uniform lightness across all hues.
|
|
139
|
+
let [l, c, h] = toOKLCH(this);
|
|
140
|
+
if (l > 0.999) {
|
|
141
|
+
return getStringForLocale("white", locale);
|
|
142
|
+
}
|
|
143
|
+
if (l < 0.001) {
|
|
144
|
+
return getStringForLocale("black", locale);
|
|
145
|
+
}
|
|
146
|
+
let hue;
|
|
147
|
+
[hue, l] = this.getOklchHue(l, c, h, locale);
|
|
148
|
+
let lightness = "";
|
|
149
|
+
let chroma = "";
|
|
150
|
+
if (c <= 0.1 && c >= GRAY_THRESHOLD) {
|
|
151
|
+
if (l >= 0.7) {
|
|
152
|
+
chroma = "pale";
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
chroma = "grayish";
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else if (c >= 0.15) {
|
|
159
|
+
chroma = "vibrant";
|
|
160
|
+
}
|
|
161
|
+
if (l < 0.3) {
|
|
162
|
+
lightness = "very dark";
|
|
163
|
+
}
|
|
164
|
+
else if (l < MAX_DARK_LIGHTNESS) {
|
|
165
|
+
lightness = "dark";
|
|
166
|
+
}
|
|
167
|
+
else if (l < 0.7) {
|
|
168
|
+
// none
|
|
169
|
+
}
|
|
170
|
+
else if (l < 0.85) {
|
|
171
|
+
lightness = "light";
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
lightness = "very light";
|
|
175
|
+
}
|
|
176
|
+
if (chroma) {
|
|
177
|
+
chroma = getStringForLocale(chroma, locale);
|
|
178
|
+
}
|
|
179
|
+
if (lightness) {
|
|
180
|
+
lightness = getStringForLocale(lightness, locale);
|
|
181
|
+
}
|
|
182
|
+
const alpha = this.getChannelValue("alpha");
|
|
183
|
+
if (alpha < 1) {
|
|
184
|
+
const percentTransparent = new NumberFormatter(locale, { style: "percent" }).format(1 - alpha);
|
|
185
|
+
return formatString(getStringForLocale("transparentColorName", locale), { lightness, chroma, hue, percentTransparent }).replace(/\s+/g, " ").trim();
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
return formatString(getStringForLocale("colorName", locale), { lightness, chroma, hue }).replace(/\s+/g, " ").trim();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
getOklchHue(l, c, h, locale) {
|
|
192
|
+
if (c < GRAY_THRESHOLD) {
|
|
193
|
+
return [getStringForLocale("gray", locale), l];
|
|
194
|
+
}
|
|
195
|
+
for (let i = 0; i < OKLCH_HUES.length; i++) {
|
|
196
|
+
let [hue, hueName] = OKLCH_HUES[i];
|
|
197
|
+
const [nextHue, nextHueName] = OKLCH_HUES[i + 1] || [360, "pink"];
|
|
198
|
+
if (h >= hue && h < nextHue) {
|
|
199
|
+
// Split orange hue into brown/orange depending on lightness.
|
|
200
|
+
if (hueName === "orange") {
|
|
201
|
+
if (l < ORANGE_LIGHTNESS_THRESHOLD) {
|
|
202
|
+
hueName = "brown";
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
// Adjust lightness.
|
|
206
|
+
l = l - ORANGE_LIGHTNESS_THRESHOLD + MAX_DARK_LIGHTNESS;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// If the hue is at least halfway to the next hue, add the next hue name as well.
|
|
210
|
+
if (h > hue + (nextHue - hue) / 2 && hueName !== nextHueName) {
|
|
211
|
+
hueName = `${hueName} ${nextHueName}`;
|
|
212
|
+
}
|
|
213
|
+
else if (hueName === "yellow" && l < YELLOW_GREEN_LIGHTNESS_THRESHOLD) {
|
|
214
|
+
// Yellow shifts toward green at lower lightnesses.
|
|
215
|
+
hueName = "yellow green";
|
|
216
|
+
}
|
|
217
|
+
const name = getStringForLocale(hueName, locale).toLocaleLowerCase(locale);
|
|
218
|
+
return [name, l];
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
throw new Error("Unexpected hue");
|
|
222
|
+
}
|
|
223
|
+
getHueName(locale) {
|
|
224
|
+
const [l, c, h] = toOKLCH(this);
|
|
225
|
+
const [name] = this.getOklchHue(l, c, h, locale);
|
|
226
|
+
return name;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
class RGBColor extends BaseColor {
|
|
230
|
+
red;
|
|
231
|
+
green;
|
|
232
|
+
blue;
|
|
233
|
+
alpha;
|
|
234
|
+
constructor(red, green, blue, alpha) {
|
|
235
|
+
super();
|
|
236
|
+
this.red = red;
|
|
237
|
+
this.green = green;
|
|
238
|
+
this.blue = blue;
|
|
239
|
+
this.alpha = alpha;
|
|
240
|
+
}
|
|
241
|
+
static parse(value) {
|
|
242
|
+
let colors = [];
|
|
243
|
+
// matching #rgb, #rgba, #rrggbb, #rrggbbaa
|
|
244
|
+
if (/^#[\da-f]+$/i.test(value) && [4, 5, 7, 9].includes(value.length)) {
|
|
245
|
+
const values = (value.length < 6 ? value.replace(/[^#]/gi, "$&$&") : value).slice(1).split("");
|
|
246
|
+
while (values.length > 0) {
|
|
247
|
+
colors.push(parseInt(values.splice(0, 2).join(""), 16));
|
|
248
|
+
}
|
|
249
|
+
colors[3] = colors[3] !== undefined ? colors[3] / 255 : undefined;
|
|
250
|
+
}
|
|
251
|
+
// matching rgb(rrr, ggg, bbb), rgba(rrr, ggg, bbb, 0.a)
|
|
252
|
+
const match = value.match(/^rgba?\((.*)\)$/);
|
|
253
|
+
if (match?.[1]) {
|
|
254
|
+
const parts = match[1].split(",").map((value) => value.trim());
|
|
255
|
+
// Number('') is 0 rather than NaN, so empty components need their own check.
|
|
256
|
+
if (parts.some((part) => part === "" || !Number.isFinite(Number(part)))) {
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
colors = parts.map((part, i) => {
|
|
260
|
+
return clamp(Number(part), 0, i < 3 ? 255 : 1);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
if (colors[0] === undefined || colors[1] === undefined || colors[2] === undefined) {
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
return colors.length < 3 ? undefined : new RGBColor(colors[0], colors[1], colors[2], colors[3] ?? 1);
|
|
267
|
+
}
|
|
268
|
+
toString(format = "css") {
|
|
269
|
+
switch (format) {
|
|
270
|
+
case "hex":
|
|
271
|
+
return ("#" + (this.red.toString(16).padStart(2, "0") + this.green.toString(16).padStart(2, "0") + this.blue.toString(16).padStart(2, "0")).toUpperCase());
|
|
272
|
+
case "hexa":
|
|
273
|
+
return ("#" +
|
|
274
|
+
(this.red.toString(16).padStart(2, "0") +
|
|
275
|
+
this.green.toString(16).padStart(2, "0") +
|
|
276
|
+
this.blue.toString(16).padStart(2, "0") +
|
|
277
|
+
Math.round(this.alpha * 255)
|
|
278
|
+
.toString(16)
|
|
279
|
+
.padStart(2, "0")).toUpperCase());
|
|
280
|
+
case "rgb":
|
|
281
|
+
return `rgb(${this.red}, ${this.green}, ${this.blue})`;
|
|
282
|
+
case "css":
|
|
283
|
+
case "rgba":
|
|
284
|
+
return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;
|
|
285
|
+
default:
|
|
286
|
+
return this.toFormat(format).toString(format);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
toFormat(format) {
|
|
290
|
+
switch (format) {
|
|
291
|
+
case "hex":
|
|
292
|
+
case "hexa":
|
|
293
|
+
case "rgb":
|
|
294
|
+
case "rgba":
|
|
295
|
+
return this;
|
|
296
|
+
case "hsb":
|
|
297
|
+
case "hsba":
|
|
298
|
+
return this.toHSB();
|
|
299
|
+
case "hsl":
|
|
300
|
+
case "hsla":
|
|
301
|
+
return this.toHSL();
|
|
302
|
+
default:
|
|
303
|
+
throw new Error("Unsupported color conversion: rgb -> " + format);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
toHexInt() {
|
|
307
|
+
return (this.red << 16) | (this.green << 8) | this.blue;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Converts an RGB color value to HSB.
|
|
311
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
|
|
312
|
+
*
|
|
313
|
+
* @returns An HSBColor object.
|
|
314
|
+
*/
|
|
315
|
+
toHSB() {
|
|
316
|
+
const red = this.red / 255;
|
|
317
|
+
const green = this.green / 255;
|
|
318
|
+
const blue = this.blue / 255;
|
|
319
|
+
const min = Math.min(red, green, blue);
|
|
320
|
+
const brightness = Math.max(red, green, blue);
|
|
321
|
+
const chroma = brightness - min;
|
|
322
|
+
const saturation = brightness === 0 ? 0 : chroma / brightness;
|
|
323
|
+
let hue = 0; // achromatic
|
|
324
|
+
if (chroma !== 0) {
|
|
325
|
+
switch (brightness) {
|
|
326
|
+
case red:
|
|
327
|
+
hue = (green - blue) / chroma + (green < blue ? 6 : 0);
|
|
328
|
+
break;
|
|
329
|
+
case green:
|
|
330
|
+
hue = (blue - red) / chroma + 2;
|
|
331
|
+
break;
|
|
332
|
+
case blue:
|
|
333
|
+
hue = (red - green) / chroma + 4;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
hue /= 6;
|
|
337
|
+
}
|
|
338
|
+
return new HSBColor(toFixedNumber(hue * 360, 2), toFixedNumber(saturation * 100, 2), toFixedNumber(brightness * 100, 2), this.alpha);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Converts an RGB color value to HSL.
|
|
342
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
|
|
343
|
+
*
|
|
344
|
+
* @returns An HSLColor object.
|
|
345
|
+
*/
|
|
346
|
+
toHSL() {
|
|
347
|
+
const red = this.red / 255;
|
|
348
|
+
const green = this.green / 255;
|
|
349
|
+
const blue = this.blue / 255;
|
|
350
|
+
const min = Math.min(red, green, blue);
|
|
351
|
+
const max = Math.max(red, green, blue);
|
|
352
|
+
const lightness = (max + min) / 2;
|
|
353
|
+
const chroma = max - min;
|
|
354
|
+
let hue;
|
|
355
|
+
let saturation;
|
|
356
|
+
if (chroma === 0) {
|
|
357
|
+
hue = saturation = 0; // achromatic
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
saturation = chroma / (lightness < 0.5 ? max + min : 2 - max - min);
|
|
361
|
+
switch (max) {
|
|
362
|
+
case red:
|
|
363
|
+
hue = (green - blue) / chroma + (green < blue ? 6 : 0);
|
|
364
|
+
break;
|
|
365
|
+
case green:
|
|
366
|
+
hue = (blue - red) / chroma + 2;
|
|
367
|
+
break;
|
|
368
|
+
case blue:
|
|
369
|
+
default:
|
|
370
|
+
hue = (red - green) / chroma + 4;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
hue /= 6;
|
|
374
|
+
}
|
|
375
|
+
return new HSLColor(toFixedNumber(hue * 360, 2), toFixedNumber(saturation * 100, 2), toFixedNumber(lightness * 100, 2), this.alpha);
|
|
376
|
+
}
|
|
377
|
+
clone() {
|
|
378
|
+
return new RGBColor(this.red, this.green, this.blue, this.alpha);
|
|
379
|
+
}
|
|
380
|
+
getChannelRange(channel) {
|
|
381
|
+
switch (channel) {
|
|
382
|
+
case "red":
|
|
383
|
+
case "green":
|
|
384
|
+
case "blue":
|
|
385
|
+
return { minValue: 0x0, maxValue: 0xff, step: 0x1, pageSize: 0x11 };
|
|
386
|
+
case "alpha":
|
|
387
|
+
return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 };
|
|
388
|
+
default:
|
|
389
|
+
throw new Error("Unknown color channel: " + channel);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
getChannelFormatOptions(channel) {
|
|
393
|
+
switch (channel) {
|
|
394
|
+
case "red":
|
|
395
|
+
case "green":
|
|
396
|
+
case "blue":
|
|
397
|
+
return { style: "decimal" };
|
|
398
|
+
case "alpha":
|
|
399
|
+
return { style: "percent" };
|
|
400
|
+
default:
|
|
401
|
+
throw new Error("Unknown color channel: " + channel);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
formatChannelValue(channel, locale) {
|
|
405
|
+
const options = this.getChannelFormatOptions(channel);
|
|
406
|
+
const value = this.getChannelValue(channel);
|
|
407
|
+
return new NumberFormatter(locale, options).format(value);
|
|
408
|
+
}
|
|
409
|
+
getColorSpace() {
|
|
410
|
+
return "rgb";
|
|
411
|
+
}
|
|
412
|
+
static colorChannels = ["red", "green", "blue"];
|
|
413
|
+
getColorChannels() {
|
|
414
|
+
return RGBColor.colorChannels;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
// X = <negative/positive number with/without decimal places>
|
|
418
|
+
// before/after a comma, 0 or more whitespaces are allowed
|
|
419
|
+
// - hsb(X, X%, X%)
|
|
420
|
+
// - hsba(X, X%, X%, X)
|
|
421
|
+
const HSB_REGEX = /hsb\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsba\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;
|
|
422
|
+
class HSBColor extends BaseColor {
|
|
423
|
+
hue;
|
|
424
|
+
saturation;
|
|
425
|
+
brightness;
|
|
426
|
+
alpha;
|
|
427
|
+
constructor(hue, saturation, brightness, alpha) {
|
|
428
|
+
super();
|
|
429
|
+
this.hue = hue;
|
|
430
|
+
this.saturation = saturation;
|
|
431
|
+
this.brightness = brightness;
|
|
432
|
+
this.alpha = alpha;
|
|
433
|
+
}
|
|
434
|
+
static parse(value) {
|
|
435
|
+
let m;
|
|
436
|
+
if ((m = value.match(HSB_REGEX))) {
|
|
437
|
+
const [h, s, b, a] = (m[1] ?? m[2]).split(",").map((n) => Number(n.trim().replace("%", "")));
|
|
438
|
+
return new HSBColor(normalizeHue(h), clamp(s, 0, 100), clamp(b, 0, 100), clamp(a ?? 1, 0, 1));
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
toString(format = "css") {
|
|
442
|
+
switch (format) {
|
|
443
|
+
case "css":
|
|
444
|
+
return this.toHSL().toString("css");
|
|
445
|
+
case "hex":
|
|
446
|
+
return this.toRGB().toString("hex");
|
|
447
|
+
case "hexa":
|
|
448
|
+
return this.toRGB().toString("hexa");
|
|
449
|
+
case "hsb":
|
|
450
|
+
return `hsb(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%)`;
|
|
451
|
+
case "hsba":
|
|
452
|
+
return `hsba(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%, ${this.alpha})`;
|
|
453
|
+
default:
|
|
454
|
+
return this.toFormat(format).toString(format);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
toFormat(format) {
|
|
458
|
+
switch (format) {
|
|
459
|
+
case "hsb":
|
|
460
|
+
case "hsba":
|
|
461
|
+
return this;
|
|
462
|
+
case "hsl":
|
|
463
|
+
case "hsla":
|
|
464
|
+
return this.toHSL();
|
|
465
|
+
case "rgb":
|
|
466
|
+
case "rgba":
|
|
467
|
+
return this.toRGB();
|
|
468
|
+
default:
|
|
469
|
+
throw new Error("Unsupported color conversion: hsb -> " + format);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Converts a HSB color to HSL.
|
|
474
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.
|
|
475
|
+
*
|
|
476
|
+
* @returns An HSLColor object.
|
|
477
|
+
*/
|
|
478
|
+
toHSL() {
|
|
479
|
+
let saturation = this.saturation / 100;
|
|
480
|
+
const brightness = this.brightness / 100;
|
|
481
|
+
const lightness = brightness * (1 - saturation / 2);
|
|
482
|
+
saturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness);
|
|
483
|
+
return new HSLColor(toFixedNumber(this.hue, 2), toFixedNumber(saturation * 100, 2), toFixedNumber(lightness * 100, 2), this.alpha);
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Converts a HSV color value to RGB. Conversion formula adapted from
|
|
487
|
+
* https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.
|
|
488
|
+
*
|
|
489
|
+
* @returns An RGBColor object.
|
|
490
|
+
*/
|
|
491
|
+
toRGB() {
|
|
492
|
+
const hue = this.hue;
|
|
493
|
+
const saturation = this.saturation / 100;
|
|
494
|
+
const brightness = this.brightness / 100;
|
|
495
|
+
const fn = (n, k = (n + hue / 60) % 6) => brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0);
|
|
496
|
+
return new RGBColor(Math.round(fn(5) * 255), Math.round(fn(3) * 255), Math.round(fn(1) * 255), this.alpha);
|
|
497
|
+
}
|
|
498
|
+
clone() {
|
|
499
|
+
return new HSBColor(this.hue, this.saturation, this.brightness, this.alpha);
|
|
500
|
+
}
|
|
501
|
+
getChannelRange(channel) {
|
|
502
|
+
switch (channel) {
|
|
503
|
+
case "hue":
|
|
504
|
+
return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 };
|
|
505
|
+
case "saturation":
|
|
506
|
+
case "brightness":
|
|
507
|
+
return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 };
|
|
508
|
+
case "alpha":
|
|
509
|
+
return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 };
|
|
510
|
+
default:
|
|
511
|
+
throw new Error("Unknown color channel: " + channel);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
getChannelFormatOptions(channel) {
|
|
515
|
+
switch (channel) {
|
|
516
|
+
case "hue":
|
|
517
|
+
return { style: "unit", unit: "degree", unitDisplay: "narrow" };
|
|
518
|
+
case "saturation":
|
|
519
|
+
case "brightness":
|
|
520
|
+
case "alpha":
|
|
521
|
+
return { style: "percent" };
|
|
522
|
+
default:
|
|
523
|
+
throw new Error("Unknown color channel: " + channel);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
formatChannelValue(channel, locale) {
|
|
527
|
+
const options = this.getChannelFormatOptions(channel);
|
|
528
|
+
let value = this.getChannelValue(channel);
|
|
529
|
+
if (channel === "saturation" || channel === "brightness") {
|
|
530
|
+
value /= 100;
|
|
531
|
+
}
|
|
532
|
+
return new NumberFormatter(locale, options).format(value);
|
|
533
|
+
}
|
|
534
|
+
getColorSpace() {
|
|
535
|
+
return "hsb";
|
|
536
|
+
}
|
|
537
|
+
static colorChannels = ["hue", "saturation", "brightness"];
|
|
538
|
+
getColorChannels() {
|
|
539
|
+
return HSBColor.colorChannels;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
// X = <negative/positive number with/without decimal places>
|
|
543
|
+
// before/after a comma, 0 or more whitespaces are allowed
|
|
544
|
+
// - hsl(X, X%, X%)
|
|
545
|
+
// - hsla(X, X%, X%, X)
|
|
546
|
+
const HSL_REGEX = /hsl\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsla\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;
|
|
547
|
+
class HSLColor extends BaseColor {
|
|
548
|
+
hue;
|
|
549
|
+
saturation;
|
|
550
|
+
lightness;
|
|
551
|
+
alpha;
|
|
552
|
+
constructor(hue, saturation, lightness, alpha) {
|
|
553
|
+
super();
|
|
554
|
+
this.hue = hue;
|
|
555
|
+
this.saturation = saturation;
|
|
556
|
+
this.lightness = lightness;
|
|
557
|
+
this.alpha = alpha;
|
|
558
|
+
}
|
|
559
|
+
static parse(value) {
|
|
560
|
+
let m;
|
|
561
|
+
if ((m = value.match(HSL_REGEX))) {
|
|
562
|
+
const [h, s, l, a] = (m[1] ?? m[2]).split(",").map((n) => Number(n.trim().replace("%", "")));
|
|
563
|
+
return new HSLColor(normalizeHue(h), clamp(s, 0, 100), clamp(l, 0, 100), clamp(a ?? 1, 0, 1));
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
toString(format = "css") {
|
|
567
|
+
switch (format) {
|
|
568
|
+
case "hex":
|
|
569
|
+
return this.toRGB().toString("hex");
|
|
570
|
+
case "hexa":
|
|
571
|
+
return this.toRGB().toString("hexa");
|
|
572
|
+
case "hsl":
|
|
573
|
+
return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`;
|
|
574
|
+
case "css":
|
|
575
|
+
case "hsla":
|
|
576
|
+
return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${this.alpha})`;
|
|
577
|
+
default:
|
|
578
|
+
return this.toFormat(format).toString(format);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
toFormat(format) {
|
|
582
|
+
switch (format) {
|
|
583
|
+
case "hsl":
|
|
584
|
+
case "hsla":
|
|
585
|
+
return this;
|
|
586
|
+
case "hsb":
|
|
587
|
+
case "hsba":
|
|
588
|
+
return this.toHSB();
|
|
589
|
+
case "rgb":
|
|
590
|
+
case "rgba":
|
|
591
|
+
return this.toRGB();
|
|
592
|
+
default:
|
|
593
|
+
throw new Error("Unsupported color conversion: hsl -> " + format);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Converts a HSL color to HSB.
|
|
598
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.
|
|
599
|
+
*
|
|
600
|
+
* @returns An HSBColor object.
|
|
601
|
+
*/
|
|
602
|
+
toHSB() {
|
|
603
|
+
let saturation = this.saturation / 100;
|
|
604
|
+
const lightness = this.lightness / 100;
|
|
605
|
+
const brightness = lightness + saturation * Math.min(lightness, 1 - lightness);
|
|
606
|
+
saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness);
|
|
607
|
+
return new HSBColor(toFixedNumber(this.hue, 2), toFixedNumber(saturation * 100, 2), toFixedNumber(brightness * 100, 2), this.alpha);
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Converts a HSL color to RGB. Conversion formula adapted from
|
|
611
|
+
* https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.
|
|
612
|
+
*
|
|
613
|
+
* @returns An RGBColor object.
|
|
614
|
+
*/
|
|
615
|
+
toRGB() {
|
|
616
|
+
const hue = this.hue;
|
|
617
|
+
const saturation = this.saturation / 100;
|
|
618
|
+
const lightness = this.lightness / 100;
|
|
619
|
+
const a = saturation * Math.min(lightness, 1 - lightness);
|
|
620
|
+
const fn = (n, k = (n + hue / 30) % 12) => lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
621
|
+
return new RGBColor(Math.round(fn(0) * 255), Math.round(fn(8) * 255), Math.round(fn(4) * 255), this.alpha);
|
|
622
|
+
}
|
|
623
|
+
clone() {
|
|
624
|
+
return new HSLColor(this.hue, this.saturation, this.lightness, this.alpha);
|
|
625
|
+
}
|
|
626
|
+
getChannelRange(channel) {
|
|
627
|
+
switch (channel) {
|
|
628
|
+
case "hue":
|
|
629
|
+
return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 };
|
|
630
|
+
case "saturation":
|
|
631
|
+
case "lightness":
|
|
632
|
+
return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 };
|
|
633
|
+
case "alpha":
|
|
634
|
+
return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 };
|
|
635
|
+
default:
|
|
636
|
+
throw new Error("Unknown color channel: " + channel);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
getChannelFormatOptions(channel) {
|
|
640
|
+
switch (channel) {
|
|
641
|
+
case "hue":
|
|
642
|
+
return { style: "unit", unit: "degree", unitDisplay: "narrow" };
|
|
643
|
+
case "saturation":
|
|
644
|
+
case "lightness":
|
|
645
|
+
case "alpha":
|
|
646
|
+
return { style: "percent" };
|
|
647
|
+
default:
|
|
648
|
+
throw new Error("Unknown color channel: " + channel);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
formatChannelValue(channel, locale) {
|
|
652
|
+
const options = this.getChannelFormatOptions(channel);
|
|
653
|
+
let value = this.getChannelValue(channel);
|
|
654
|
+
if (channel === "saturation" || channel === "lightness") {
|
|
655
|
+
value /= 100;
|
|
656
|
+
}
|
|
657
|
+
return new NumberFormatter(locale, options).format(value);
|
|
658
|
+
}
|
|
659
|
+
getColorSpace() {
|
|
660
|
+
return "hsl";
|
|
661
|
+
}
|
|
662
|
+
static colorChannels = ["hue", "saturation", "lightness"];
|
|
663
|
+
getColorChannels() {
|
|
664
|
+
return HSLColor.colorChannels;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
// https://www.w3.org/TR/css-color-4/#color-conversion-code
|
|
668
|
+
function toOKLCH(color) {
|
|
669
|
+
const rgb = color.toFormat("rgb");
|
|
670
|
+
let red = rgb.getChannelValue("red") / 255;
|
|
671
|
+
let green = rgb.getChannelValue("green") / 255;
|
|
672
|
+
let blue = rgb.getChannelValue("blue") / 255;
|
|
673
|
+
[red, green, blue] = lin_sRGB(red, green, blue);
|
|
674
|
+
const [x, y, z] = lin_sRGB_to_XYZ(red, green, blue);
|
|
675
|
+
const [l, a, b] = XYZ_to_OKLab(x, y, z);
|
|
676
|
+
return OKLab_to_OKLCH(l, a, b);
|
|
677
|
+
}
|
|
678
|
+
function OKLab_to_OKLCH(l, a, b) {
|
|
679
|
+
const hue = (Math.atan2(b, a) * 180) / Math.PI;
|
|
680
|
+
return [
|
|
681
|
+
l,
|
|
682
|
+
Math.sqrt(a ** 2 + b ** 2), // Chroma
|
|
683
|
+
hue >= 0 ? hue : hue + 360, // Hue, in degrees [0 to 360)
|
|
684
|
+
];
|
|
685
|
+
}
|
|
686
|
+
function lin_sRGB(r, g, b) {
|
|
687
|
+
// convert an array of sRGB values
|
|
688
|
+
// where in-gamut values are in the range [0 - 1]
|
|
689
|
+
// to linear light (un-companded) form.
|
|
690
|
+
// https://en.wikipedia.org/wiki/SRGB
|
|
691
|
+
// Extended transfer function:
|
|
692
|
+
// for negative values, linear portion is extended on reflection of axis,
|
|
693
|
+
// then reflected power function is used.
|
|
694
|
+
return [lin_sRGB_component(r), lin_sRGB_component(g), lin_sRGB_component(b)];
|
|
695
|
+
}
|
|
696
|
+
function lin_sRGB_component(val) {
|
|
697
|
+
const sign = val < 0 ? -1 : 1;
|
|
698
|
+
const abs = Math.abs(val);
|
|
699
|
+
if (abs <= 0.04045) {
|
|
700
|
+
return val / 12.92;
|
|
701
|
+
}
|
|
702
|
+
return sign * Math.pow((abs + 0.055) / 1.055, 2.4);
|
|
703
|
+
}
|
|
704
|
+
function lin_sRGB_to_XYZ(r, g, b) {
|
|
705
|
+
// convert an array of linear-light sRGB values to CIE XYZ
|
|
706
|
+
// using sRGB's own white, D65 (no chromatic adaptation)
|
|
707
|
+
const M = [
|
|
708
|
+
506752 / 1228815,
|
|
709
|
+
87881 / 245763,
|
|
710
|
+
12673 / 70218,
|
|
711
|
+
87098 / 409605,
|
|
712
|
+
175762 / 245763,
|
|
713
|
+
12673 / 175545,
|
|
714
|
+
7918 / 409605,
|
|
715
|
+
87881 / 737289,
|
|
716
|
+
1001167 / 1053270,
|
|
717
|
+
];
|
|
718
|
+
return multiplyMatrix(M, r, g, b);
|
|
719
|
+
}
|
|
720
|
+
function XYZ_to_OKLab(x, y, z) {
|
|
721
|
+
// Given XYZ relative to D65, convert to OKLab
|
|
722
|
+
const XYZtoLMS = [
|
|
723
|
+
0.819022437996703, 0.3619062600528904, -0.1288737815209879, 0.0329836539323885, 0.9292868615863434, 0.0361446663506424, 0.0481771893596242,
|
|
724
|
+
0.2642395317527308, 0.6335478284694309,
|
|
725
|
+
];
|
|
726
|
+
const LMStoOKLab = [
|
|
727
|
+
0.210454268309314, 0.7936177747023054, -0.0040720430116193, 1.9779985324311684, -2.4285922420485799, 0.450593709617411, 0.0259040424655478,
|
|
728
|
+
0.7827717124575296, -0.8086757549230774,
|
|
729
|
+
];
|
|
730
|
+
const [a, b, c] = multiplyMatrix(XYZtoLMS, x, y, z);
|
|
731
|
+
return multiplyMatrix(LMStoOKLab, Math.cbrt(a), Math.cbrt(b), Math.cbrt(c));
|
|
732
|
+
}
|
|
733
|
+
function multiplyMatrix(m, x, y, z) {
|
|
734
|
+
const a = m[0] * x + m[1] * y + m[2] * z;
|
|
735
|
+
const b = m[3] * x + m[4] * y + m[5] * z;
|
|
736
|
+
const c = m[6] * x + m[7] * y + m[8] * z;
|
|
737
|
+
return [a, b, c];
|
|
738
|
+
}
|