@solid2-aria/stately 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +45 -2
- package/dist/LICENSES/Apache-2.0.txt +201 -0
- package/dist/LICENSES/react-spectrum-NOTICE.txt +242 -0
- package/dist/NOTICE.txt +636 -0
- package/dist/autocomplete/create-autocomplete-state.d.ts +46 -0
- package/dist/autocomplete/create-autocomplete-state.js +41 -0
- package/dist/autocomplete/create-autocomplete-state.js.map +1 -0
- package/dist/calendar/create-calendar-state.d.ts +62 -0
- package/dist/calendar/create-calendar-state.js +357 -0
- package/dist/calendar/create-calendar-state.js.map +1 -0
- package/dist/calendar/create-range-calendar-state.d.ts +63 -0
- package/dist/calendar/create-range-calendar-state.js +204 -0
- package/dist/calendar/create-range-calendar-state.js.map +1 -0
- package/dist/calendar/types.d.ts +222 -0
- package/dist/calendar/types.js +16 -0
- package/dist/calendar/utils.d.ts +27 -0
- package/dist/calendar/utils.js +81 -0
- package/dist/calendar/utils.js.map +1 -0
- package/dist/checkbox/create-checkbox-group-state.d.ts +60 -0
- package/dist/checkbox/create-checkbox-group-state.js +88 -0
- package/dist/checkbox/create-checkbox-group-state.js.map +1 -0
- package/dist/collections/collection-builder.d.ts +28 -0
- package/dist/collections/collection-builder.js +164 -0
- package/dist/collections/collection-builder.js.map +1 -0
- package/dist/collections/create-collection.d.ts +24 -0
- package/dist/collections/create-collection.js +35 -0
- package/dist/collections/create-collection.js.map +1 -0
- package/dist/collections/get-child-nodes.d.ts +25 -0
- package/dist/collections/get-child-nodes.js +67 -0
- package/dist/collections/get-child-nodes.js.map +1 -0
- package/dist/collections/get-item-count.d.ts +19 -0
- package/dist/collections/get-item-count.js +34 -0
- package/dist/collections/get-item-count.js.map +1 -0
- package/dist/collections/item.d.ts +29 -0
- package/dist/collections/item.js +68 -0
- package/dist/collections/item.js.map +1 -0
- package/dist/collections/section.d.ts +29 -0
- package/dist/collections/section.js +60 -0
- package/dist/collections/section.js.map +1 -0
- package/dist/collections/types.d.ts +46 -0
- package/dist/collections/types.js +29 -0
- package/dist/collections/types.js.map +1 -0
- package/dist/color/color/base-color.d.ts +40 -0
- package/dist/color/color/base-color.js +122 -0
- package/dist/color/color/base-color.js.map +1 -0
- package/dist/color/color/color-classes.d.ts +27 -0
- package/dist/color/color/color-classes.js +29 -0
- package/dist/color/color/color-classes.js.map +1 -0
- package/dist/color/color/color-constructors.d.ts +23 -0
- package/dist/color/color/color-constructors.js +16 -0
- package/dist/color/color/color.d.ts +3 -0
- package/dist/color/color/color.js +2 -0
- package/dist/color/color/hsb-color.d.ts +24 -0
- package/dist/color/color/hsb-color.js +183 -0
- package/dist/color/color/hsb-color.js.map +1 -0
- package/dist/color/color/hsl-color.d.ts +24 -0
- package/dist/color/color/hsl-color.js +184 -0
- package/dist/color/color/hsl-color.js.map +1 -0
- package/dist/color/color/normalize-hue.d.ts +18 -0
- package/dist/color/color/normalize-hue.js +24 -0
- package/dist/color/color/normalize-hue.js.map +1 -0
- package/dist/color/color/oklch.d.ts +19 -0
- package/dist/color/color/oklch.js +97 -0
- package/dist/color/color/oklch.js.map +1 -0
- package/dist/color/color/rgb-color.d.ts +24 -0
- package/dist/color/color/rgb-color.js +230 -0
- package/dist/color/color/rgb-color.js.map +1 -0
- package/dist/color/color.d.ts +25 -0
- package/dist/color/color.js +41 -0
- package/dist/color/color.js.map +1 -0
- package/dist/color/create-color-area-state.d.ts +105 -0
- package/dist/color/create-color-area-state.js +138 -0
- package/dist/color/create-color-area-state.js.map +1 -0
- package/dist/color/create-color-channel-field-state.d.ts +29 -0
- package/dist/color/create-color-channel-field-state.js +69 -0
- package/dist/color/create-color-channel-field-state.js.map +1 -0
- package/dist/color/create-color-field-state.d.ts +61 -0
- package/dist/color/create-color-field-state.js +113 -0
- package/dist/color/create-color-field-state.js.map +1 -0
- package/dist/color/create-color-picker-state.d.ts +16 -0
- package/dist/color/create-color-picker-state.js +26 -0
- package/dist/color/create-color-picker-state.js.map +1 -0
- package/dist/color/create-color-slider-state.d.ts +50 -0
- package/dist/color/create-color-slider-state.js +93 -0
- package/dist/color/create-color-slider-state.js.map +1 -0
- package/dist/color/create-color-wheel-state.d.ts +76 -0
- package/dist/color/create-color-wheel-state.js +130 -0
- package/dist/color/create-color-wheel-state.js.map +1 -0
- package/dist/color/create-color.d.ts +20 -0
- package/dist/color/create-color.js +33 -0
- package/dist/color/create-color.js.map +1 -0
- package/dist/color/types.d.ts +87 -0
- package/dist/color/types.js +5 -0
- package/dist/combobox/create-combo-box-state.d.ts +157 -0
- package/dist/combobox/create-combo-box-state.js +450 -0
- package/dist/combobox/create-combo-box-state.js.map +1 -0
- package/dist/data/create-async-list.d.ts +88 -0
- package/dist/data/create-async-list.js +276 -0
- package/dist/data/create-async-list.js.map +1 -0
- package/dist/data/create-list-data.d.ts +140 -0
- package/dist/data/create-list-data.js +250 -0
- package/dist/data/create-list-data.js.map +1 -0
- package/dist/data/create-tree-data.d.ts +134 -0
- package/dist/data/create-tree-data.js +364 -0
- package/dist/data/create-tree-data.js.map +1 -0
- package/dist/datepicker/create-date-field-state.d.ts +138 -0
- package/dist/datepicker/create-date-field-state.js +449 -0
- package/dist/datepicker/create-date-field-state.js.map +1 -0
- package/dist/datepicker/create-date-picker-state.d.ts +82 -0
- package/dist/datepicker/create-date-picker-state.js +191 -0
- package/dist/datepicker/create-date-picker-state.js.map +1 -0
- package/dist/datepicker/create-date-range-picker-state.d.ts +97 -0
- package/dist/datepicker/create-date-range-picker-state.js +305 -0
- package/dist/datepicker/create-date-range-picker-state.js.map +1 -0
- package/dist/datepicker/create-time-field-state.d.ts +34 -0
- package/dist/datepicker/create-time-field-state.js +128 -0
- package/dist/datepicker/create-time-field-state.js.map +1 -0
- package/dist/datepicker/incomplete-date.d.ts +71 -0
- package/dist/datepicker/incomplete-date.js +324 -0
- package/dist/datepicker/incomplete-date.js.map +1 -0
- package/dist/datepicker/placeholders.d.ts +18 -0
- package/dist/datepicker/placeholders.js +418 -0
- package/dist/datepicker/placeholders.js.map +1 -0
- package/dist/datepicker/types.d.ts +131 -0
- package/dist/datepicker/types.js +16 -0
- package/dist/datepicker/utils.d.ts +37 -0
- package/dist/datepicker/utils.js +168 -0
- package/dist/datepicker/utils.js.map +1 -0
- package/dist/disclosure/create-disclosure-group-state.d.ts +47 -0
- package/dist/disclosure/create-disclosure-group-state.js +62 -0
- package/dist/disclosure/create-disclosure-group-state.js.map +1 -0
- package/dist/disclosure/create-disclosure-state.d.ts +42 -0
- package/dist/disclosure/create-disclosure-state.js +49 -0
- package/dist/disclosure/create-disclosure-state.js.map +1 -0
- package/dist/dnd/create-draggable-collection-state.d.ts +63 -0
- package/dist/dnd/create-draggable-collection-state.js +136 -0
- package/dist/dnd/create-draggable-collection-state.js.map +1 -0
- package/dist/dnd/create-droppable-collection-state.d.ts +55 -0
- package/dist/dnd/create-droppable-collection-state.js +155 -0
- package/dist/dnd/create-droppable-collection-state.js.map +1 -0
- package/dist/flags/flags.d.ts +21 -0
- package/dist/flags/flags.js +34 -0
- package/dist/flags/flags.js.map +1 -0
- package/dist/form/create-form-validation-state.d.ts +37 -0
- package/dist/form/create-form-validation-state.js +152 -0
- package/dist/form/create-form-validation-state.js.map +1 -0
- package/dist/grid/create-grid-state.d.ts +38 -0
- package/dist/grid/create-grid-state.js +85 -0
- package/dist/grid/create-grid-state.js.map +1 -0
- package/dist/grid/grid-collection.d.ts +68 -0
- package/dist/grid/grid-collection.js +133 -0
- package/dist/grid/grid-collection.js.map +1 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +86 -0
- package/dist/intl/color/ar-AE.js +44 -0
- package/dist/intl/color/ar-AE.js.map +1 -0
- package/dist/intl/color/bg-BG.js +44 -0
- package/dist/intl/color/bg-BG.js.map +1 -0
- package/dist/intl/color/cs-CZ.js +44 -0
- package/dist/intl/color/cs-CZ.js.map +1 -0
- package/dist/intl/color/da-DK.js +44 -0
- package/dist/intl/color/da-DK.js.map +1 -0
- package/dist/intl/color/de-DE.js +44 -0
- package/dist/intl/color/de-DE.js.map +1 -0
- package/dist/intl/color/el-GR.js +44 -0
- package/dist/intl/color/el-GR.js.map +1 -0
- package/dist/intl/color/en-US.js +44 -0
- package/dist/intl/color/en-US.js.map +1 -0
- package/dist/intl/color/es-ES.js +44 -0
- package/dist/intl/color/es-ES.js.map +1 -0
- package/dist/intl/color/et-EE.js +44 -0
- package/dist/intl/color/et-EE.js.map +1 -0
- package/dist/intl/color/fi-FI.js +44 -0
- package/dist/intl/color/fi-FI.js.map +1 -0
- package/dist/intl/color/fr-FR.js +44 -0
- package/dist/intl/color/fr-FR.js.map +1 -0
- package/dist/intl/color/he-IL.js +44 -0
- package/dist/intl/color/he-IL.js.map +1 -0
- package/dist/intl/color/hr-HR.js +44 -0
- package/dist/intl/color/hr-HR.js.map +1 -0
- package/dist/intl/color/hu-HU.js +44 -0
- package/dist/intl/color/hu-HU.js.map +1 -0
- package/dist/intl/color/index.js +75 -0
- package/dist/intl/color/index.js.map +1 -0
- package/dist/intl/color/it-IT.js +44 -0
- package/dist/intl/color/it-IT.js.map +1 -0
- package/dist/intl/color/ja-JP.js +44 -0
- package/dist/intl/color/ja-JP.js.map +1 -0
- package/dist/intl/color/ko-KR.js +44 -0
- package/dist/intl/color/ko-KR.js.map +1 -0
- package/dist/intl/color/lt-LT.js +44 -0
- package/dist/intl/color/lt-LT.js.map +1 -0
- package/dist/intl/color/lv-LV.js +44 -0
- package/dist/intl/color/lv-LV.js.map +1 -0
- package/dist/intl/color/nb-NO.js +44 -0
- package/dist/intl/color/nb-NO.js.map +1 -0
- package/dist/intl/color/nl-NL.js +44 -0
- package/dist/intl/color/nl-NL.js.map +1 -0
- package/dist/intl/color/pl-PL.js +44 -0
- package/dist/intl/color/pl-PL.js.map +1 -0
- package/dist/intl/color/pt-BR.js +44 -0
- package/dist/intl/color/pt-BR.js.map +1 -0
- package/dist/intl/color/pt-PT.js +44 -0
- package/dist/intl/color/pt-PT.js.map +1 -0
- package/dist/intl/color/ro-RO.js +44 -0
- package/dist/intl/color/ro-RO.js.map +1 -0
- package/dist/intl/color/ru-RU.js +44 -0
- package/dist/intl/color/ru-RU.js.map +1 -0
- package/dist/intl/color/sk-SK.js +44 -0
- package/dist/intl/color/sk-SK.js.map +1 -0
- package/dist/intl/color/sl-SI.js +44 -0
- package/dist/intl/color/sl-SI.js.map +1 -0
- package/dist/intl/color/sr-SP.js +44 -0
- package/dist/intl/color/sr-SP.js.map +1 -0
- package/dist/intl/color/sv-SE.js +44 -0
- package/dist/intl/color/sv-SE.js.map +1 -0
- package/dist/intl/color/tr-TR.js +44 -0
- package/dist/intl/color/tr-TR.js.map +1 -0
- package/dist/intl/color/uk-UA.js +44 -0
- package/dist/intl/color/uk-UA.js.map +1 -0
- package/dist/intl/color/zh-CN.js +44 -0
- package/dist/intl/color/zh-CN.js.map +1 -0
- package/dist/intl/color/zh-TW.js +44 -0
- package/dist/intl/color/zh-TW.js.map +1 -0
- package/dist/intl/datepicker/ar-AE.js +11 -0
- package/dist/intl/datepicker/ar-AE.js.map +1 -0
- package/dist/intl/datepicker/bg-BG.js +11 -0
- package/dist/intl/datepicker/bg-BG.js.map +1 -0
- package/dist/intl/datepicker/cs-CZ.js +11 -0
- package/dist/intl/datepicker/cs-CZ.js.map +1 -0
- package/dist/intl/datepicker/da-DK.js +11 -0
- package/dist/intl/datepicker/da-DK.js.map +1 -0
- package/dist/intl/datepicker/de-DE.js +11 -0
- package/dist/intl/datepicker/de-DE.js.map +1 -0
- package/dist/intl/datepicker/el-GR.js +11 -0
- package/dist/intl/datepicker/el-GR.js.map +1 -0
- package/dist/intl/datepicker/en-US.js +11 -0
- package/dist/intl/datepicker/en-US.js.map +1 -0
- package/dist/intl/datepicker/es-ES.js +11 -0
- package/dist/intl/datepicker/es-ES.js.map +1 -0
- package/dist/intl/datepicker/et-EE.js +11 -0
- package/dist/intl/datepicker/et-EE.js.map +1 -0
- package/dist/intl/datepicker/fi-FI.js +11 -0
- package/dist/intl/datepicker/fi-FI.js.map +1 -0
- package/dist/intl/datepicker/fr-FR.js +11 -0
- package/dist/intl/datepicker/fr-FR.js.map +1 -0
- package/dist/intl/datepicker/he-IL.js +11 -0
- package/dist/intl/datepicker/he-IL.js.map +1 -0
- package/dist/intl/datepicker/hr-HR.js +11 -0
- package/dist/intl/datepicker/hr-HR.js.map +1 -0
- package/dist/intl/datepicker/hu-HU.js +11 -0
- package/dist/intl/datepicker/hu-HU.js.map +1 -0
- package/dist/intl/datepicker/index.js +75 -0
- package/dist/intl/datepicker/index.js.map +1 -0
- package/dist/intl/datepicker/it-IT.js +11 -0
- package/dist/intl/datepicker/it-IT.js.map +1 -0
- package/dist/intl/datepicker/ja-JP.js +11 -0
- package/dist/intl/datepicker/ja-JP.js.map +1 -0
- package/dist/intl/datepicker/ko-KR.js +11 -0
- package/dist/intl/datepicker/ko-KR.js.map +1 -0
- package/dist/intl/datepicker/lt-LT.js +11 -0
- package/dist/intl/datepicker/lt-LT.js.map +1 -0
- package/dist/intl/datepicker/lv-LV.js +11 -0
- package/dist/intl/datepicker/lv-LV.js.map +1 -0
- package/dist/intl/datepicker/nb-NO.js +11 -0
- package/dist/intl/datepicker/nb-NO.js.map +1 -0
- package/dist/intl/datepicker/nl-NL.js +11 -0
- package/dist/intl/datepicker/nl-NL.js.map +1 -0
- package/dist/intl/datepicker/pl-PL.js +11 -0
- package/dist/intl/datepicker/pl-PL.js.map +1 -0
- package/dist/intl/datepicker/pt-BR.js +11 -0
- package/dist/intl/datepicker/pt-BR.js.map +1 -0
- package/dist/intl/datepicker/pt-PT.js +11 -0
- package/dist/intl/datepicker/pt-PT.js.map +1 -0
- package/dist/intl/datepicker/ro-RO.js +11 -0
- package/dist/intl/datepicker/ro-RO.js.map +1 -0
- package/dist/intl/datepicker/ru-RU.js +11 -0
- package/dist/intl/datepicker/ru-RU.js.map +1 -0
- package/dist/intl/datepicker/sk-SK.js +11 -0
- package/dist/intl/datepicker/sk-SK.js.map +1 -0
- package/dist/intl/datepicker/sl-SI.js +11 -0
- package/dist/intl/datepicker/sl-SI.js.map +1 -0
- package/dist/intl/datepicker/sr-SP.js +11 -0
- package/dist/intl/datepicker/sr-SP.js.map +1 -0
- package/dist/intl/datepicker/sv-SE.js +11 -0
- package/dist/intl/datepicker/sv-SE.js.map +1 -0
- package/dist/intl/datepicker/tr-TR.js +11 -0
- package/dist/intl/datepicker/tr-TR.js.map +1 -0
- package/dist/intl/datepicker/uk-UA.js +11 -0
- package/dist/intl/datepicker/uk-UA.js.map +1 -0
- package/dist/intl/datepicker/zh-CN.js +11 -0
- package/dist/intl/datepicker/zh-CN.js.map +1 -0
- package/dist/intl/datepicker/zh-TW.js +11 -0
- package/dist/intl/datepicker/zh-TW.js.map +1 -0
- package/dist/layout/grid-layout.d.ts +107 -0
- package/dist/layout/grid-layout.js +253 -0
- package/dist/layout/grid-layout.js.map +1 -0
- package/dist/layout/list-layout.d.ts +187 -0
- package/dist/layout/list-layout.js +488 -0
- package/dist/layout/list-layout.js.map +1 -0
- package/dist/layout/table-layout.d.ts +98 -0
- package/dist/layout/table-layout.js +476 -0
- package/dist/layout/table-layout.js.map +1 -0
- package/dist/layout/waterfall-layout.d.ts +85 -0
- package/dist/layout/waterfall-layout.js +225 -0
- package/dist/layout/waterfall-layout.js.map +1 -0
- package/dist/list/create-list-state.d.ts +48 -0
- package/dist/list/create-list-state.js +123 -0
- package/dist/list/create-list-state.js.map +1 -0
- package/dist/list/create-single-select-list-state.d.ts +38 -0
- package/dist/list/create-single-select-list-state.js +55 -0
- package/dist/list/create-single-select-list-state.js.map +1 -0
- package/dist/list/list-collection.d.ts +36 -0
- package/dist/list/list-collection.js +91 -0
- package/dist/list/list-collection.js.map +1 -0
- package/dist/menu/create-menu-trigger-state.d.ts +55 -0
- package/dist/menu/create-menu-trigger-state.js +58 -0
- package/dist/menu/create-menu-trigger-state.js.map +1 -0
- package/dist/menu/create-submenu-trigger-state.d.ts +47 -0
- package/dist/menu/create-submenu-trigger-state.js +59 -0
- package/dist/menu/create-submenu-trigger-state.js.map +1 -0
- package/dist/numberfield/create-number-field-state.d.ts +93 -0
- package/dist/numberfield/create-number-field-state.js +139 -0
- package/dist/numberfield/create-number-field-state.js.map +1 -0
- package/dist/overlays/create-overlay-trigger-state.d.ts +51 -0
- package/dist/overlays/create-overlay-trigger-state.js +56 -0
- package/dist/overlays/create-overlay-trigger-state.js.map +1 -0
- package/dist/radio/create-radio-group-state.d.ts +61 -0
- package/dist/radio/create-radio-group-state.js +71 -0
- package/dist/radio/create-radio-group-state.js.map +1 -0
- package/dist/searchfield/create-search-field-state.d.ts +35 -0
- package/dist/searchfield/create-search-field-state.js +34 -0
- package/dist/searchfield/create-search-field-state.js.map +1 -0
- package/dist/select/create-select-state.d.ts +116 -0
- package/dist/select/create-select-state.js +151 -0
- package/dist/select/create-select-state.js.map +1 -0
- package/dist/selection/create-multiple-selection-state.d.ts +39 -0
- package/dist/selection/create-multiple-selection-state.js +114 -0
- package/dist/selection/create-multiple-selection-state.js.map +1 -0
- package/dist/selection/selection-manager.d.ts +139 -0
- package/dist/selection/selection-manager.js +334 -0
- package/dist/selection/selection-manager.js.map +1 -0
- package/dist/selection/selection.d.ts +27 -0
- package/dist/selection/selection.js +38 -0
- package/dist/selection/selection.js.map +1 -0
- package/dist/selection/types.d.ts +116 -0
- package/dist/selection/types.js +16 -0
- package/dist/slider/create-slider-state.d.ts +182 -0
- package/dist/slider/create-slider-state.js +131 -0
- package/dist/slider/create-slider-state.js.map +1 -0
- package/dist/steplist/create-step-list-state.d.ts +40 -0
- package/dist/steplist/create-step-list-state.js +132 -0
- package/dist/steplist/create-step-list-state.js.map +1 -0
- package/dist/table/cell.d.ts +37 -0
- package/dist/table/cell.js +47 -0
- package/dist/table/cell.js.map +1 -0
- package/dist/table/collection-context.d.ts +4 -0
- package/dist/table/collection-context.js +8 -0
- package/dist/table/collection-context.js.map +1 -0
- package/dist/table/column.d.ts +66 -0
- package/dist/table/column.js +71 -0
- package/dist/table/column.js.map +1 -0
- package/dist/table/create-table-column-resize-state.d.ts +65 -0
- package/dist/table/create-table-column-resize-state.js +100 -0
- package/dist/table/create-table-column-resize-state.js.map +1 -0
- package/dist/table/create-table-state.d.ts +112 -0
- package/dist/table/create-table-state.js +122 -0
- package/dist/table/create-table-state.js.map +1 -0
- package/dist/table/create-tree-grid-state.d.ts +44 -0
- package/dist/table/create-tree-grid-state.js +145 -0
- package/dist/table/create-tree-grid-state.js.map +1 -0
- package/dist/table/row.d.ts +44 -0
- package/dist/table/row.js +91 -0
- package/dist/table/row.js.map +1 -0
- package/dist/table/table-body.d.ts +36 -0
- package/dist/table/table-body.js +57 -0
- package/dist/table/table-body.js.map +1 -0
- package/dist/table/table-collection.d.ts +62 -0
- package/dist/table/table-collection.js +274 -0
- package/dist/table/table-collection.js.map +1 -0
- package/dist/table/table-column-layout.d.ts +47 -0
- package/dist/table/table-column-layout.js +94 -0
- package/dist/table/table-column-layout.js.map +1 -0
- package/dist/table/table-header.d.ts +37 -0
- package/dist/table/table-header.js +52 -0
- package/dist/table/table-header.js.map +1 -0
- package/dist/table/table-utils.d.ts +60 -0
- package/dist/table/table-utils.js +203 -0
- package/dist/table/table-utils.js.map +1 -0
- package/dist/tabs/create-tab-list-state.d.ts +42 -0
- package/dist/tabs/create-tab-list-state.js +78 -0
- package/dist/tabs/create-tab-list-state.js.map +1 -0
- package/dist/toast/create-toast-state.d.ts +97 -0
- package/dist/toast/create-toast-state.js +166 -0
- package/dist/toast/create-toast-state.js.map +1 -0
- package/dist/toggle/create-toggle-group-state.d.ts +55 -0
- package/dist/toggle/create-toggle-group-state.js +62 -0
- package/dist/toggle/create-toggle-group-state.js.map +1 -0
- package/dist/toggle/create-toggle-state.d.ts +58 -0
- package/dist/toggle/create-toggle-state.js +43 -0
- package/dist/toggle/create-toggle-state.js.map +1 -0
- package/dist/tokenfield/create-token-field-state.d.ts +39 -0
- package/dist/tokenfield/create-token-field-state.js +44 -0
- package/dist/tokenfield/create-token-field-state.js.map +1 -0
- package/dist/tokenfield/token-field-value.d.ts +111 -0
- package/dist/tokenfield/token-field-value.js +327 -0
- package/dist/tokenfield/token-field-value.js.map +1 -0
- package/dist/tooltip/create-tooltip-trigger-state.d.ts +73 -0
- package/dist/tooltip/create-tooltip-trigger-state.js +136 -0
- package/dist/tooltip/create-tooltip-trigger-state.js.map +1 -0
- package/dist/tree/create-tree-state.d.ts +42 -0
- package/dist/tree/create-tree-state.js +75 -0
- package/dist/tree/create-tree-state.js.map +1 -0
- package/dist/tree/tree-collection.d.ts +36 -0
- package/dist/tree/tree-collection.js +84 -0
- package/dist/tree/tree-collection.js.map +1 -0
- package/dist/utils/create-controlled-signal.d.ts +23 -0
- package/dist/utils/create-controlled-signal.js +54 -0
- package/dist/utils/create-controlled-signal.js.map +1 -0
- package/dist/utils/get-item-key.d.ts +5 -0
- package/dist/utils/get-item-key.js +12 -0
- package/dist/utils/get-item-key.js.map +1 -0
- package/dist/utils/get-node-props.d.ts +23 -0
- package/dist/utils/get-node-props.js +38 -0
- package/dist/utils/get-node-props.js.map +1 -0
- package/dist/utils/has-content.d.ts +5 -0
- package/dist/utils/has-content.js +7 -0
- package/dist/utils/has-content.js.map +1 -0
- package/dist/utils/legacy-props.d.ts +10 -0
- package/dist/utils/legacy-props.js +17 -0
- package/dist/utils/legacy-props.js.map +1 -0
- package/dist/utils/number.d.ts +25 -0
- package/dist/utils/number.js +59 -0
- package/dist/utils/number.js.map +1 -0
- package/dist/utils/parse-calendar-identifier.d.ts +5 -0
- package/dist/utils/parse-calendar-identifier.js +31 -0
- package/dist/utils/parse-calendar-identifier.js.map +1 -0
- package/dist/utils/require-value.d.ts +4 -0
- package/dist/utils/require-value.js +10 -0
- package/dist/utils/require-value.js.map +1 -0
- package/dist/virtualizer/create-virtualizer-state.d.ts +44 -0
- package/dist/virtualizer/create-virtualizer-state.js +92 -0
- package/dist/virtualizer/create-virtualizer-state.js.map +1 -0
- package/dist/virtualizer/layout-info.d.ts +94 -0
- package/dist/virtualizer/layout-info.js +118 -0
- package/dist/virtualizer/layout-info.js.map +1 -0
- package/dist/virtualizer/layout.d.ts +91 -0
- package/dist/virtualizer/layout.js +71 -0
- package/dist/virtualizer/layout.js.map +1 -0
- package/dist/virtualizer/overscan-manager.d.ts +25 -0
- package/dist/virtualizer/overscan-manager.js +46 -0
- package/dist/virtualizer/overscan-manager.js.map +1 -0
- package/dist/virtualizer/point.d.ts +36 -0
- package/dist/virtualizer/point.js +48 -0
- package/dist/virtualizer/point.js.map +1 -0
- package/dist/virtualizer/rect.d.ts +103 -0
- package/dist/virtualizer/rect.js +156 -0
- package/dist/virtualizer/rect.js.map +1 -0
- package/dist/virtualizer/reusable-view.d.ts +51 -0
- package/dist/virtualizer/reusable-view.js +81 -0
- package/dist/virtualizer/reusable-view.js.map +1 -0
- package/dist/virtualizer/scroll-anchor.d.ts +98 -0
- package/dist/virtualizer/scroll-anchor.js +150 -0
- package/dist/virtualizer/scroll-anchor.js.map +1 -0
- package/dist/virtualizer/size.d.ts +34 -0
- package/dist/virtualizer/size.js +46 -0
- package/dist/virtualizer/size.js.map +1 -0
- package/dist/virtualizer/types.d.ts +47 -0
- package/dist/virtualizer/types.js +16 -0
- package/dist/virtualizer/utils.d.ts +19 -0
- package/dist/virtualizer/utils.js +27 -0
- package/dist/virtualizer/utils.js.map +1 -0
- package/dist/virtualizer/virtualizer.d.ts +99 -0
- package/dist/virtualizer/virtualizer.js +314 -0
- package/dist/virtualizer/virtualizer.js.map +1 -0
- package/package.json +174 -4
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/*
|
|
13
|
+
* Derived from Adobe React Spectrum: packages/react-stately/src/color/Color.ts.
|
|
14
|
+
* Modified for Solid Aria: reorganized color code, type declarations, imports, and formatting;
|
|
15
|
+
* added explicit constructor types for declaration emission.
|
|
16
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
17
|
+
*/
|
|
18
|
+
import { Color } from "../types.js";
|
|
19
|
+
import { ColorConstructors } from "./color-constructors.js";
|
|
20
|
+
export declare function createHSBColorClass(getColorClasses: () => ColorConstructors): ColorConstructors["HSBColor"] & {
|
|
21
|
+
colorChannels: ReturnType<Color["getColorChannels"]>;
|
|
22
|
+
parse: (value: string) => Color | undefined;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=hsb-color.d.ts.map
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/*
|
|
13
|
+
* Derived from Adobe React Spectrum: packages/react-stately/src/color/Color.ts.
|
|
14
|
+
* Modified for Solid Aria: reorganized color code, type declarations, imports, and formatting;
|
|
15
|
+
* added explicit constructor types for declaration emission.
|
|
16
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
17
|
+
*/
|
|
18
|
+
import { clamp, toFixedNumber } from "../../utils/number.js";
|
|
19
|
+
import { Color } from "./base-color.js";
|
|
20
|
+
import { normalizeHue } from "./normalize-hue.js";
|
|
21
|
+
import { NumberFormatter } from "@internationalized/number";
|
|
22
|
+
// src/color/color/hsb-color.ts
|
|
23
|
+
const HSB_REGEX = /^hsb(?<alphaMarker>a)?\((?<hue>[-+]?\d+(?:\.\d+)?)\s*,\s*(?<saturation>[-+]?\d+(?:\.\d+)?)%\s*,\s*(?<third>[-+]?\d+(?:\.\d+)?)%(?:\s*,\s*(?<alpha>[-+]?\d+(?:\.\d+)?))?\)$/u;
|
|
24
|
+
function createHSBColorClass(getColorClasses) {
|
|
25
|
+
return class HSBColor extends Color {
|
|
26
|
+
hue;
|
|
27
|
+
saturation;
|
|
28
|
+
brightness;
|
|
29
|
+
alpha;
|
|
30
|
+
constructor(hue, saturation, brightness, alpha) {
|
|
31
|
+
super();
|
|
32
|
+
this.hue = hue;
|
|
33
|
+
this.saturation = saturation;
|
|
34
|
+
this.brightness = brightness;
|
|
35
|
+
this.alpha = alpha;
|
|
36
|
+
}
|
|
37
|
+
static parse(value) {
|
|
38
|
+
const groups = HSB_REGEX.exec(value)?.groups;
|
|
39
|
+
if (!groups) return;
|
|
40
|
+
const { hue, saturation, third, alpha, alphaMarker } = groups;
|
|
41
|
+
if (hue === void 0 || saturation === void 0 || third === void 0 || alphaMarker === void 0 !== (alpha === void 0)) return;
|
|
42
|
+
return new HSBColor(normalizeHue(Number(hue)), clamp(Number(saturation), 0, 100), clamp(Number(third), 0, 100), clamp(Number(alpha ?? 1), 0, 1));
|
|
43
|
+
}
|
|
44
|
+
toString(format = "css") {
|
|
45
|
+
switch (format) {
|
|
46
|
+
case "css": return this.toHSL().toString("css");
|
|
47
|
+
case "hex": return this.toRGB().toString("hex");
|
|
48
|
+
case "hexa": return this.toRGB().toString("hexa");
|
|
49
|
+
case "hsb": return `hsb(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%)`;
|
|
50
|
+
case "hsba": return `hsba(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%, ${this.alpha})`;
|
|
51
|
+
case "rgb":
|
|
52
|
+
case "rgba":
|
|
53
|
+
case "hsl":
|
|
54
|
+
case "hsla": return this.toFormat(format).toString(format);
|
|
55
|
+
default: throw new Error("Unsupported color format");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
toFormat(format) {
|
|
59
|
+
switch (format) {
|
|
60
|
+
case "hsb":
|
|
61
|
+
case "hsba": return this;
|
|
62
|
+
case "hsl":
|
|
63
|
+
case "hsla": return this.toHSL();
|
|
64
|
+
case "rgb":
|
|
65
|
+
case "rgba": return this.toRGB();
|
|
66
|
+
case "hex":
|
|
67
|
+
case "hexa": throw new Error(`Unsupported color conversion: hsb -> ${format}`);
|
|
68
|
+
default: throw new Error("Unsupported color format");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Converts a HSB color to HSL.
|
|
73
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.
|
|
74
|
+
*
|
|
75
|
+
* @returns An HSLColor object.
|
|
76
|
+
*/
|
|
77
|
+
toHSL() {
|
|
78
|
+
let saturation = this.saturation / 100;
|
|
79
|
+
const brightness = this.brightness / 100;
|
|
80
|
+
const lightness = brightness * (1 - saturation / 2);
|
|
81
|
+
saturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness);
|
|
82
|
+
return new (getColorClasses()).HSLColor(toFixedNumber(this.hue, 2), toFixedNumber(saturation * 100, 2), toFixedNumber(lightness * 100, 2), this.alpha);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Converts a HSV color value to RGB. Conversion formula adapted from
|
|
86
|
+
* https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.
|
|
87
|
+
*
|
|
88
|
+
* @returns An RGBColor object.
|
|
89
|
+
*/
|
|
90
|
+
toRGB() {
|
|
91
|
+
const { hue } = this;
|
|
92
|
+
const saturation = this.saturation / 100;
|
|
93
|
+
const brightness = this.brightness / 100;
|
|
94
|
+
const fn = (n, k = (n + hue / 60) % 6) => brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0);
|
|
95
|
+
return new (getColorClasses()).RGBColor(Math.round(fn(5) * 255), Math.round(fn(3) * 255), Math.round(fn(1) * 255), this.alpha);
|
|
96
|
+
}
|
|
97
|
+
getChannelValue(channel) {
|
|
98
|
+
const value = {
|
|
99
|
+
alpha: this.alpha,
|
|
100
|
+
brightness: this.brightness,
|
|
101
|
+
hue: this.hue,
|
|
102
|
+
saturation: this.saturation
|
|
103
|
+
}[channel];
|
|
104
|
+
if (value === void 0) throw new Error(`Unsupported color channel: ${channel}`);
|
|
105
|
+
return value;
|
|
106
|
+
}
|
|
107
|
+
withChannelValue(channel, value) {
|
|
108
|
+
this.getChannelValue(channel);
|
|
109
|
+
return new HSBColor(channel === "hue" ? value : this.hue, channel === "saturation" ? value : this.saturation, channel === "brightness" ? value : this.brightness, channel === "alpha" ? value : this.alpha);
|
|
110
|
+
}
|
|
111
|
+
clone() {
|
|
112
|
+
return new HSBColor(this.hue, this.saturation, this.brightness, this.alpha);
|
|
113
|
+
}
|
|
114
|
+
channelRanges = {
|
|
115
|
+
alpha: {
|
|
116
|
+
maxValue: 1,
|
|
117
|
+
minValue: 0,
|
|
118
|
+
pageSize: .1,
|
|
119
|
+
step: .01
|
|
120
|
+
},
|
|
121
|
+
brightness: {
|
|
122
|
+
maxValue: 100,
|
|
123
|
+
minValue: 0,
|
|
124
|
+
pageSize: 10,
|
|
125
|
+
step: 1
|
|
126
|
+
},
|
|
127
|
+
hue: {
|
|
128
|
+
maxValue: 360,
|
|
129
|
+
minValue: 0,
|
|
130
|
+
pageSize: 15,
|
|
131
|
+
step: 1
|
|
132
|
+
},
|
|
133
|
+
saturation: {
|
|
134
|
+
maxValue: 100,
|
|
135
|
+
minValue: 0,
|
|
136
|
+
pageSize: 10,
|
|
137
|
+
step: 1
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
getChannelRange(channel) {
|
|
141
|
+
const value = this.channelRanges[channel];
|
|
142
|
+
if (value === void 0) throw new Error(`Unknown color channel: ${channel}`);
|
|
143
|
+
return value;
|
|
144
|
+
}
|
|
145
|
+
channelFormatOptions = {
|
|
146
|
+
alpha: { style: "percent" },
|
|
147
|
+
brightness: { style: "percent" },
|
|
148
|
+
hue: {
|
|
149
|
+
style: "unit",
|
|
150
|
+
unit: "degree",
|
|
151
|
+
unitDisplay: "narrow"
|
|
152
|
+
},
|
|
153
|
+
saturation: { style: "percent" }
|
|
154
|
+
};
|
|
155
|
+
getChannelFormatOptions(channel) {
|
|
156
|
+
const value = this.channelFormatOptions[channel];
|
|
157
|
+
if (value === void 0) throw new Error(`Unknown color channel: ${channel}`);
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
formatChannelValue(channel, locale) {
|
|
161
|
+
const options = this.getChannelFormatOptions(channel);
|
|
162
|
+
let value = this.getChannelValue(channel);
|
|
163
|
+
if (channel === "saturation" || channel === "brightness") value /= 100;
|
|
164
|
+
return new NumberFormatter(locale, options).format(value);
|
|
165
|
+
}
|
|
166
|
+
colorSpace = "hsb";
|
|
167
|
+
getColorSpace() {
|
|
168
|
+
return this.colorSpace;
|
|
169
|
+
}
|
|
170
|
+
static colorChannels = [
|
|
171
|
+
"hue",
|
|
172
|
+
"saturation",
|
|
173
|
+
"brightness"
|
|
174
|
+
];
|
|
175
|
+
colorChannels = HSBColor.colorChannels;
|
|
176
|
+
getColorChannels() {
|
|
177
|
+
return this.colorChannels;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
export { createHSBColorClass };
|
|
182
|
+
|
|
183
|
+
//# sourceMappingURL=hsb-color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hsb-color.js","names":[],"sources":["../../../src/color/color/hsb-color.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-stately/src/color/Color.ts.\n * Modified for Solid Aria: reorganized color code, type declarations, imports, and formatting;\n * added explicit constructor types for declaration emission.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { NumberFormatter } from \"@internationalized/number\";\n\nimport { clamp, toFixedNumber } from \"../../utils/number\";\nimport type {\n ColorChannel,\n ColorChannelRange,\n ColorFormat,\n ColorSpace,\n Color as IColor,\n} from \"../types\";\nimport { Color } from \"./base-color\";\nimport type { ColorConstructors } from \"./color-constructors\";\nimport { normalizeHue } from \"./normalize-hue\";\n\n// X = <negative/positive number with/without decimal places>\n// before/after a comma, 0 or more whitespaces are allowed\n// - hsb(X, X%, X%)\n// - hsba(X, X%, X%, X)\nconst HSB_REGEX =\n /^hsb(?<alphaMarker>a)?\\((?<hue>[-+]?\\d+(?:\\.\\d+)?)\\s*,\\s*(?<saturation>[-+]?\\d+(?:\\.\\d+)?)%\\s*,\\s*(?<third>[-+]?\\d+(?:\\.\\d+)?)%(?:\\s*,\\s*(?<alpha>[-+]?\\d+(?:\\.\\d+)?))?\\)$/u;\n\nexport function createHSBColorClass(\n getColorClasses: () => ColorConstructors\n): ColorConstructors[\"HSBColor\"] & {\n colorChannels: ReturnType<IColor[\"getColorChannels\"]>;\n parse: (value: string) => IColor | undefined;\n} {\n return class HSBColor extends Color {\n private readonly hue: number;\n private readonly saturation: number;\n private readonly brightness: number;\n private readonly alpha: number;\n\n constructor(\n hue: number,\n saturation: number,\n brightness: number,\n alpha: number\n ) {\n super();\n this.hue = hue;\n this.saturation = saturation;\n this.brightness = brightness;\n this.alpha = alpha;\n }\n\n static parse(value: string): HSBColor | undefined {\n const groups = HSB_REGEX.exec(value)?.groups;\n\n if (!groups) {\n return undefined;\n }\n\n const { hue, saturation, third, alpha, alphaMarker } = groups;\n\n if (\n hue === undefined ||\n saturation === undefined ||\n third === undefined ||\n (alphaMarker === undefined) !== (alpha === undefined)\n ) {\n return undefined;\n }\n\n return new HSBColor(\n normalizeHue(Number(hue)),\n clamp(Number(saturation), 0, 100),\n clamp(Number(third), 0, 100),\n clamp(Number(alpha ?? 1), 0, 1)\n );\n }\n\n toString(format: ColorFormat | \"css\" = \"css\") {\n switch (format) {\n case \"css\": {\n return this.toHSL().toString(\"css\");\n }\n\n case \"hex\": {\n return this.toRGB().toString(\"hex\");\n }\n\n case \"hexa\": {\n return this.toRGB().toString(\"hexa\");\n }\n\n case \"hsb\": {\n return `hsb(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%)`;\n }\n\n case \"hsba\": {\n return `hsba(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%, ${this.alpha})`;\n }\n\n case \"rgb\":\n case \"rgba\":\n case \"hsl\":\n case \"hsla\": {\n return this.toFormat(format).toString(format);\n }\n\n default: {\n throw new Error(\"Unsupported color format\");\n }\n }\n }\n\n toFormat(format: ColorFormat): IColor {\n switch (format) {\n case \"hsb\":\n case \"hsba\": {\n return this;\n }\n\n case \"hsl\":\n case \"hsla\": {\n return this.toHSL();\n }\n\n case \"rgb\":\n case \"rgba\": {\n return this.toRGB();\n }\n\n case \"hex\":\n case \"hexa\": {\n throw new Error(`Unsupported color conversion: hsb -> ${format}`);\n }\n\n default: {\n throw new Error(\"Unsupported color format\");\n }\n }\n }\n\n /**\n * Converts a HSB color to HSL.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.\n *\n * @returns An HSLColor object.\n */\n private toHSL(): IColor {\n let saturation = this.saturation / 100;\n const brightness = this.brightness / 100;\n const lightness = brightness * (1 - saturation / 2);\n saturation =\n lightness === 0 || lightness === 1\n ? 0\n : (brightness - lightness) / Math.min(lightness, 1 - lightness);\n\n return new (getColorClasses().HSLColor)(\n toFixedNumber(this.hue, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(lightness * 100, 2),\n this.alpha\n );\n }\n\n /**\n * Converts a HSV color value to RGB. Conversion formula adapted from\n * https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.\n *\n * @returns An RGBColor object.\n */\n private toRGB(): IColor {\n const { hue } = this;\n const saturation = this.saturation / 100;\n const brightness = this.brightness / 100;\n\n const fn = (n: number, k = (n + hue / 60) % 6) =>\n brightness -\n saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0);\n\n return new (getColorClasses().RGBColor)(\n Math.round(fn(5) * 255),\n Math.round(fn(3) * 255),\n Math.round(fn(1) * 255),\n this.alpha\n );\n }\n\n getChannelValue(channel: ColorChannel): number {\n const values: Partial<Record<ColorChannel, number>> = {\n alpha: this.alpha,\n brightness: this.brightness,\n hue: this.hue,\n saturation: this.saturation,\n };\n\n const value = values[channel];\n\n if (value === undefined) {\n throw new Error(`Unsupported color channel: ${channel}`);\n }\n\n return value;\n }\n\n withChannelValue(channel: ColorChannel, value: number): IColor {\n this.getChannelValue(channel);\n\n return new HSBColor(\n channel === \"hue\" ? value : this.hue,\n channel === \"saturation\" ? value : this.saturation,\n channel === \"brightness\" ? value : this.brightness,\n channel === \"alpha\" ? value : this.alpha\n );\n }\n\n clone(): IColor {\n return new HSBColor(\n this.hue,\n this.saturation,\n this.brightness,\n this.alpha\n );\n }\n\n private readonly channelRanges: Partial<\n Record<ColorChannel, ColorChannelRange>\n > = {\n alpha: { maxValue: 1, minValue: 0, pageSize: 0.1, step: 0.01 },\n brightness: { maxValue: 100, minValue: 0, pageSize: 10, step: 1 },\n hue: { maxValue: 360, minValue: 0, pageSize: 15, step: 1 },\n saturation: { maxValue: 100, minValue: 0, pageSize: 10, step: 1 },\n };\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n const value = this.channelRanges[channel];\n\n if (value === undefined) {\n throw new Error(`Unknown color channel: ${channel}`);\n }\n\n return value;\n }\n\n private readonly channelFormatOptions: Partial<\n Record<ColorChannel, Intl.NumberFormatOptions>\n > = {\n alpha: { style: \"percent\" },\n brightness: { style: \"percent\" },\n hue: { style: \"unit\", unit: \"degree\", unitDisplay: \"narrow\" },\n saturation: { style: \"percent\" },\n };\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n const value = this.channelFormatOptions[channel];\n\n if (value === undefined) {\n throw new Error(`Unknown color channel: ${channel}`);\n }\n\n return value;\n }\n\n formatChannelValue(channel: ColorChannel, locale: string) {\n const options = this.getChannelFormatOptions(channel);\n let value = this.getChannelValue(channel);\n\n if (channel === \"saturation\" || channel === \"brightness\") {\n value /= 100;\n }\n\n return new NumberFormatter(locale, options).format(value);\n }\n\n private readonly colorSpace: ColorSpace = \"hsb\";\n\n getColorSpace(): ColorSpace {\n return this.colorSpace;\n }\n\n static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\n \"hue\",\n \"saturation\",\n \"brightness\",\n ];\n private readonly colorChannels = HSBColor.colorChannels;\n\n getColorChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return this.colorChannels;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,YACJ;AAEF,SAAgB,oBACd,iBAIA;CACA,OAAO,MAAM,iBAAiB,MAAM;EAClC;EACA;EACA;EACA;EAEA,YACE,KACA,YACA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C1B,OAAO,KAAK;EACd;EAEA,OAAO,gBAA4D;GACjE;GACA;GACA;EACF;EACA,gBAAiC,SAAS;EAE1C,mBAA+D;GAC7D,OAAO,KAAK;EACd;CACF;AACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/*
|
|
13
|
+
* Derived from Adobe React Spectrum: packages/react-stately/src/color/Color.ts.
|
|
14
|
+
* Modified for Solid Aria: reorganized color code, type declarations, imports, and formatting;
|
|
15
|
+
* added explicit constructor types for declaration emission.
|
|
16
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
17
|
+
*/
|
|
18
|
+
import { Color } from "../types.js";
|
|
19
|
+
import { ColorConstructors } from "./color-constructors.js";
|
|
20
|
+
export declare function createHSLColorClass(getColorClasses: () => ColorConstructors): ColorConstructors["HSLColor"] & {
|
|
21
|
+
colorChannels: ReturnType<Color["getColorChannels"]>;
|
|
22
|
+
parse: (value: string) => Color | undefined;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=hsl-color.d.ts.map
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/*
|
|
13
|
+
* Derived from Adobe React Spectrum: packages/react-stately/src/color/Color.ts.
|
|
14
|
+
* Modified for Solid Aria: reorganized color code, type declarations, imports, and formatting;
|
|
15
|
+
* added explicit constructor types for declaration emission.
|
|
16
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
17
|
+
*/
|
|
18
|
+
import { clamp, toFixedNumber } from "../../utils/number.js";
|
|
19
|
+
import { Color } from "./base-color.js";
|
|
20
|
+
import { normalizeHue } from "./normalize-hue.js";
|
|
21
|
+
import { NumberFormatter } from "@internationalized/number";
|
|
22
|
+
// src/color/color/hsl-color.ts
|
|
23
|
+
const HSL_REGEX = /^hsl(?<alphaMarker>a)?\((?<hue>[-+]?\d+(?:\.\d+)?)\s*,\s*(?<saturation>[-+]?\d+(?:\.\d+)?)%\s*,\s*(?<third>[-+]?\d+(?:\.\d+)?)%(?:\s*,\s*(?<alpha>[-+]?\d+(?:\.\d+)?))?\)$/u;
|
|
24
|
+
function createHSLColorClass(getColorClasses) {
|
|
25
|
+
return class HSLColor extends Color {
|
|
26
|
+
hue;
|
|
27
|
+
saturation;
|
|
28
|
+
lightness;
|
|
29
|
+
alpha;
|
|
30
|
+
constructor(hue, saturation, lightness, alpha) {
|
|
31
|
+
super();
|
|
32
|
+
this.hue = hue;
|
|
33
|
+
this.saturation = saturation;
|
|
34
|
+
this.lightness = lightness;
|
|
35
|
+
this.alpha = alpha;
|
|
36
|
+
}
|
|
37
|
+
static parse(value) {
|
|
38
|
+
const groups = HSL_REGEX.exec(value)?.groups;
|
|
39
|
+
if (!groups) return;
|
|
40
|
+
const { hue, saturation, third, alpha, alphaMarker } = groups;
|
|
41
|
+
if (hue === void 0 || saturation === void 0 || third === void 0 || alphaMarker === void 0 !== (alpha === void 0)) return;
|
|
42
|
+
return new HSLColor(normalizeHue(Number(hue)), clamp(Number(saturation), 0, 100), clamp(Number(third), 0, 100), clamp(Number(alpha ?? 1), 0, 1));
|
|
43
|
+
}
|
|
44
|
+
toString(format = "css") {
|
|
45
|
+
switch (format) {
|
|
46
|
+
case "hex": return this.toRGB().toString("hex");
|
|
47
|
+
case "hexa": return this.toRGB().toString("hexa");
|
|
48
|
+
case "hsl": return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`;
|
|
49
|
+
case "css":
|
|
50
|
+
case "hsla": return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${this.alpha})`;
|
|
51
|
+
case "rgb":
|
|
52
|
+
case "rgba":
|
|
53
|
+
case "hsb":
|
|
54
|
+
case "hsba": return this.toFormat(format).toString(format);
|
|
55
|
+
default: throw new Error("Unsupported color format");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
toFormat(format) {
|
|
59
|
+
switch (format) {
|
|
60
|
+
case "hsl":
|
|
61
|
+
case "hsla": return this;
|
|
62
|
+
case "hsb":
|
|
63
|
+
case "hsba": return this.toHSB();
|
|
64
|
+
case "rgb":
|
|
65
|
+
case "rgba": return this.toRGB();
|
|
66
|
+
case "hex":
|
|
67
|
+
case "hexa": throw new Error(`Unsupported color conversion: hsl -> ${format}`);
|
|
68
|
+
default: throw new Error("Unsupported color format");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Converts a HSL color to HSB.
|
|
73
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.
|
|
74
|
+
*
|
|
75
|
+
* @returns An HSBColor object.
|
|
76
|
+
*/
|
|
77
|
+
toHSB() {
|
|
78
|
+
let saturation = this.saturation / 100;
|
|
79
|
+
const lightness = this.lightness / 100;
|
|
80
|
+
const brightness = lightness + saturation * Math.min(lightness, 1 - lightness);
|
|
81
|
+
saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness);
|
|
82
|
+
return new (getColorClasses()).HSBColor(toFixedNumber(this.hue, 2), toFixedNumber(saturation * 100, 2), toFixedNumber(brightness * 100, 2), this.alpha);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Converts a HSL color to RGB. Conversion formula adapted from
|
|
86
|
+
* https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.
|
|
87
|
+
*
|
|
88
|
+
* @returns An RGBColor object.
|
|
89
|
+
*/
|
|
90
|
+
toRGB() {
|
|
91
|
+
const { hue } = this;
|
|
92
|
+
const saturation = this.saturation / 100;
|
|
93
|
+
const lightness = this.lightness / 100;
|
|
94
|
+
const a = saturation * Math.min(lightness, 1 - lightness);
|
|
95
|
+
const fn = (n, k = (n + hue / 30) % 12) => lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
96
|
+
return new (getColorClasses()).RGBColor(Math.round(fn(0) * 255), Math.round(fn(8) * 255), Math.round(fn(4) * 255), this.alpha);
|
|
97
|
+
}
|
|
98
|
+
getChannelValue(channel) {
|
|
99
|
+
const value = {
|
|
100
|
+
alpha: this.alpha,
|
|
101
|
+
hue: this.hue,
|
|
102
|
+
lightness: this.lightness,
|
|
103
|
+
saturation: this.saturation
|
|
104
|
+
}[channel];
|
|
105
|
+
if (value === void 0) throw new Error(`Unsupported color channel: ${channel}`);
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
withChannelValue(channel, value) {
|
|
109
|
+
this.getChannelValue(channel);
|
|
110
|
+
return new HSLColor(channel === "hue" ? value : this.hue, channel === "saturation" ? value : this.saturation, channel === "lightness" ? value : this.lightness, channel === "alpha" ? value : this.alpha);
|
|
111
|
+
}
|
|
112
|
+
clone() {
|
|
113
|
+
return new HSLColor(this.hue, this.saturation, this.lightness, this.alpha);
|
|
114
|
+
}
|
|
115
|
+
channelRanges = {
|
|
116
|
+
alpha: {
|
|
117
|
+
maxValue: 1,
|
|
118
|
+
minValue: 0,
|
|
119
|
+
pageSize: .1,
|
|
120
|
+
step: .01
|
|
121
|
+
},
|
|
122
|
+
hue: {
|
|
123
|
+
maxValue: 360,
|
|
124
|
+
minValue: 0,
|
|
125
|
+
pageSize: 15,
|
|
126
|
+
step: 1
|
|
127
|
+
},
|
|
128
|
+
lightness: {
|
|
129
|
+
maxValue: 100,
|
|
130
|
+
minValue: 0,
|
|
131
|
+
pageSize: 10,
|
|
132
|
+
step: 1
|
|
133
|
+
},
|
|
134
|
+
saturation: {
|
|
135
|
+
maxValue: 100,
|
|
136
|
+
minValue: 0,
|
|
137
|
+
pageSize: 10,
|
|
138
|
+
step: 1
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
getChannelRange(channel) {
|
|
142
|
+
const value = this.channelRanges[channel];
|
|
143
|
+
if (value === void 0) throw new Error(`Unknown color channel: ${channel}`);
|
|
144
|
+
return value;
|
|
145
|
+
}
|
|
146
|
+
channelFormatOptions = {
|
|
147
|
+
alpha: { style: "percent" },
|
|
148
|
+
hue: {
|
|
149
|
+
style: "unit",
|
|
150
|
+
unit: "degree",
|
|
151
|
+
unitDisplay: "narrow"
|
|
152
|
+
},
|
|
153
|
+
lightness: { style: "percent" },
|
|
154
|
+
saturation: { style: "percent" }
|
|
155
|
+
};
|
|
156
|
+
getChannelFormatOptions(channel) {
|
|
157
|
+
const value = this.channelFormatOptions[channel];
|
|
158
|
+
if (value === void 0) throw new Error(`Unknown color channel: ${channel}`);
|
|
159
|
+
return value;
|
|
160
|
+
}
|
|
161
|
+
formatChannelValue(channel, locale) {
|
|
162
|
+
const options = this.getChannelFormatOptions(channel);
|
|
163
|
+
let value = this.getChannelValue(channel);
|
|
164
|
+
if (channel === "saturation" || channel === "lightness") value /= 100;
|
|
165
|
+
return new NumberFormatter(locale, options).format(value);
|
|
166
|
+
}
|
|
167
|
+
colorSpace = "hsl";
|
|
168
|
+
getColorSpace() {
|
|
169
|
+
return this.colorSpace;
|
|
170
|
+
}
|
|
171
|
+
static colorChannels = [
|
|
172
|
+
"hue",
|
|
173
|
+
"saturation",
|
|
174
|
+
"lightness"
|
|
175
|
+
];
|
|
176
|
+
colorChannels = HSLColor.colorChannels;
|
|
177
|
+
getColorChannels() {
|
|
178
|
+
return this.colorChannels;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
export { createHSLColorClass };
|
|
183
|
+
|
|
184
|
+
//# sourceMappingURL=hsl-color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hsl-color.js","names":[],"sources":["../../../src/color/color/hsl-color.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-stately/src/color/Color.ts.\n * Modified for Solid Aria: reorganized color code, type declarations, imports, and formatting;\n * added explicit constructor types for declaration emission.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { NumberFormatter } from \"@internationalized/number\";\n\nimport { clamp, toFixedNumber } from \"../../utils/number\";\nimport type {\n ColorChannel,\n ColorChannelRange,\n ColorFormat,\n ColorSpace,\n Color as IColor,\n} from \"../types\";\nimport { Color } from \"./base-color\";\nimport type { ColorConstructors } from \"./color-constructors\";\nimport { normalizeHue } from \"./normalize-hue\";\n\n// X = <negative/positive number with/without decimal places>\n// before/after a comma, 0 or more whitespaces are allowed\n// - hsl(X, X%, X%)\n// - hsla(X, X%, X%, X)\nconst HSL_REGEX =\n /^hsl(?<alphaMarker>a)?\\((?<hue>[-+]?\\d+(?:\\.\\d+)?)\\s*,\\s*(?<saturation>[-+]?\\d+(?:\\.\\d+)?)%\\s*,\\s*(?<third>[-+]?\\d+(?:\\.\\d+)?)%(?:\\s*,\\s*(?<alpha>[-+]?\\d+(?:\\.\\d+)?))?\\)$/u;\n\nexport function createHSLColorClass(\n getColorClasses: () => ColorConstructors\n): ColorConstructors[\"HSLColor\"] & {\n colorChannels: ReturnType<IColor[\"getColorChannels\"]>;\n parse: (value: string) => IColor | undefined;\n} {\n return class HSLColor extends Color {\n private readonly hue: number;\n private readonly saturation: number;\n private readonly lightness: number;\n private readonly alpha: number;\n\n constructor(\n hue: number,\n saturation: number,\n lightness: number,\n alpha: number\n ) {\n super();\n this.hue = hue;\n this.saturation = saturation;\n this.lightness = lightness;\n this.alpha = alpha;\n }\n\n static parse(value: string): HSLColor | undefined {\n const groups = HSL_REGEX.exec(value)?.groups;\n\n if (!groups) {\n return undefined;\n }\n\n const { hue, saturation, third, alpha, alphaMarker } = groups;\n\n if (\n hue === undefined ||\n saturation === undefined ||\n third === undefined ||\n (alphaMarker === undefined) !== (alpha === undefined)\n ) {\n return undefined;\n }\n\n return new HSLColor(\n normalizeHue(Number(hue)),\n clamp(Number(saturation), 0, 100),\n clamp(Number(third), 0, 100),\n clamp(Number(alpha ?? 1), 0, 1)\n );\n }\n\n toString(format: ColorFormat | \"css\" = \"css\") {\n switch (format) {\n case \"hex\": {\n return this.toRGB().toString(\"hex\");\n }\n\n case \"hexa\": {\n return this.toRGB().toString(\"hexa\");\n }\n\n case \"hsl\": {\n return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`;\n }\n\n case \"css\":\n case \"hsla\": {\n return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${this.alpha})`;\n }\n\n case \"rgb\":\n case \"rgba\":\n case \"hsb\":\n case \"hsba\": {\n return this.toFormat(format).toString(format);\n }\n\n default: {\n throw new Error(\"Unsupported color format\");\n }\n }\n }\n toFormat(format: ColorFormat): IColor {\n switch (format) {\n case \"hsl\":\n case \"hsla\": {\n return this;\n }\n\n case \"hsb\":\n case \"hsba\": {\n return this.toHSB();\n }\n\n case \"rgb\":\n case \"rgba\": {\n return this.toRGB();\n }\n\n case \"hex\":\n case \"hexa\": {\n throw new Error(`Unsupported color conversion: hsl -> ${format}`);\n }\n\n default: {\n throw new Error(\"Unsupported color format\");\n }\n }\n }\n\n /**\n * Converts a HSL color to HSB.\n * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.\n *\n * @returns An HSBColor object.\n */\n private toHSB(): IColor {\n let saturation = this.saturation / 100;\n const lightness = this.lightness / 100;\n\n const brightness =\n lightness + saturation * Math.min(lightness, 1 - lightness);\n\n saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness);\n\n return new (getColorClasses().HSBColor)(\n toFixedNumber(this.hue, 2),\n toFixedNumber(saturation * 100, 2),\n toFixedNumber(brightness * 100, 2),\n this.alpha\n );\n }\n\n /**\n * Converts a HSL color to RGB. Conversion formula adapted from\n * https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.\n *\n * @returns An RGBColor object.\n */\n private toRGB(): IColor {\n const { hue } = this;\n const saturation = this.saturation / 100;\n const lightness = this.lightness / 100;\n const a = saturation * Math.min(lightness, 1 - lightness);\n\n const fn = (n: number, k = (n + hue / 30) % 12) =>\n lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);\n\n return new (getColorClasses().RGBColor)(\n Math.round(fn(0) * 255),\n Math.round(fn(8) * 255),\n Math.round(fn(4) * 255),\n this.alpha\n );\n }\n\n getChannelValue(channel: ColorChannel): number {\n const values: Partial<Record<ColorChannel, number>> = {\n alpha: this.alpha,\n hue: this.hue,\n lightness: this.lightness,\n saturation: this.saturation,\n };\n\n const value = values[channel];\n\n if (value === undefined) {\n throw new Error(`Unsupported color channel: ${channel}`);\n }\n\n return value;\n }\n\n withChannelValue(channel: ColorChannel, value: number): IColor {\n this.getChannelValue(channel);\n\n return new HSLColor(\n channel === \"hue\" ? value : this.hue,\n channel === \"saturation\" ? value : this.saturation,\n channel === \"lightness\" ? value : this.lightness,\n channel === \"alpha\" ? value : this.alpha\n );\n }\n\n clone(): IColor {\n return new HSLColor(\n this.hue,\n this.saturation,\n this.lightness,\n this.alpha\n );\n }\n\n private readonly channelRanges: Partial<\n Record<ColorChannel, ColorChannelRange>\n > = {\n alpha: { maxValue: 1, minValue: 0, pageSize: 0.1, step: 0.01 },\n hue: { maxValue: 360, minValue: 0, pageSize: 15, step: 1 },\n lightness: { maxValue: 100, minValue: 0, pageSize: 10, step: 1 },\n saturation: { maxValue: 100, minValue: 0, pageSize: 10, step: 1 },\n };\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n const value = this.channelRanges[channel];\n\n if (value === undefined) {\n throw new Error(`Unknown color channel: ${channel}`);\n }\n\n return value;\n }\n\n private readonly channelFormatOptions: Partial<\n Record<ColorChannel, Intl.NumberFormatOptions>\n > = {\n alpha: { style: \"percent\" },\n hue: { style: \"unit\", unit: \"degree\", unitDisplay: \"narrow\" },\n lightness: { style: \"percent\" },\n saturation: { style: \"percent\" },\n };\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n const value = this.channelFormatOptions[channel];\n\n if (value === undefined) {\n throw new Error(`Unknown color channel: ${channel}`);\n }\n\n return value;\n }\n\n formatChannelValue(channel: ColorChannel, locale: string) {\n const options = this.getChannelFormatOptions(channel);\n let value = this.getChannelValue(channel);\n\n if (channel === \"saturation\" || channel === \"lightness\") {\n value /= 100;\n }\n\n return new NumberFormatter(locale, options).format(value);\n }\n\n private readonly colorSpace: ColorSpace = \"hsl\";\n\n getColorSpace(): ColorSpace {\n return this.colorSpace;\n }\n\n static colorChannels: [ColorChannel, ColorChannel, ColorChannel] = [\n \"hue\",\n \"saturation\",\n \"lightness\",\n ];\n private readonly colorChannels = HSLColor.colorChannels;\n\n getColorChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return this.colorChannels;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,YACJ;AAEF,SAAgB,oBACd,iBAIA;CACA,OAAO,MAAM,iBAAiB,MAAM;EAClC;EACA;EACA;EACA;EAEA,YACE,KACA,YACA,WACA,OACA;GACA,MAAM;GACN,KAAK,MAAM;GACX,KAAK,aAAa;GAClB,KAAK,YAAY;GACjB,KAAK,QAAQ;EACf;EAEA,OAAO,MAAM,OAAqC;GAChD,MAAM,SAAS,UAAU,KAAK,KAAK,CAAC,EAAE;GAEtC,IAAI,CAAC,QACH;GAGF,MAAM,EAAE,KAAK,YAAY,OAAO,OAAO,gBAAgB;GAEvD,IACE,QAAQ,KAAA,KACR,eAAe,KAAA,KACf,UAAU,KAAA,KACT,gBAAgB,KAAA,OAAgB,UAAU,KAAA,IAE3C;GAGF,OAAO,IAAI,SACT,aAAa,OAAO,GAAG,CAAC,GACxB,MAAM,OAAO,UAAU,GAAG,GAAG,GAAG,GAChC,MAAM,OAAO,KAAK,GAAG,GAAG,GAAG,GAC3B,MAAM,OAAO,SAAS,CAAC,GAAG,GAAG,CAAC,CAChC;EACF;EAEA,SAAS,SAA8B,OAAO;GAC5C,QAAQ,QAAR;IACE,KAAK,OACH,OAAO,KAAK,MAAM,CAAC,CAAC,SAAS,KAAK;IAGpC,KAAK,QACH,OAAO,KAAK,MAAM,CAAC,CAAC,SAAS,MAAM;IAGrC,KAAK,OACH,OAAO,OAAO,KAAK,IAAI,IAAI,cAAc,KAAK,YAAY,CAAC,EAAE,KAAK,cAAc,KAAK,WAAW,CAAC,EAAE;IAGrG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,UAAU;EACjC;EAEA,wBAAwB,SAAiD;GACvE,MAAM,QAAQ,KAAK,qBAAqB;GAExC,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MAAM,0BAA0B,SAAS;GAGrD,OAAO;EACT;EAEA,mBAAmB,SAAuB,QAAgB;GACxD,MAAM,UAAU,KAAK,wBAAwB,OAAO;GACpD,IAAI,QAAQ,KAAK,gBAAgB,OAAO;GAExC,IAAI,YAAY,gBAAgB,YAAY,aAC1C,SAAS;GAGX,OAAO,IAAI,gBAAgB,QAAQ,OAAO,CAAC,CAAC,OAAO,KAAK;EAC1D;EAEA,aAA0C;EAE1C,gBAA4B;GAC1B,OAAO,KAAK;EACd;EAEA,OAAO,gBAA4D;GACjE;GACA;GACA;EACF;EACA,gBAAiC,SAAS;EAE1C,mBAA+D;GAC7D,OAAO,KAAK;EACd;CACF;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/*
|
|
13
|
+
* Derived from Adobe React Spectrum: packages/react-stately/src/color/Color.ts.
|
|
14
|
+
* Modified for Solid Aria: reorganized color code, type declarations, imports, and formatting.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeHue(hue: number): number;
|
|
18
|
+
//# sourceMappingURL=normalize-hue.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/*
|
|
13
|
+
* Derived from Adobe React Spectrum: packages/react-stately/src/color/Color.ts.
|
|
14
|
+
* Modified for Solid Aria: reorganized color code, type declarations, imports, and formatting.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
// src/color/color/normalize-hue.ts
|
|
18
|
+
function normalizeHue(hue) {
|
|
19
|
+
if (hue === 360) return hue;
|
|
20
|
+
return (hue % 360 + 360) % 360;
|
|
21
|
+
}
|
|
22
|
+
export { normalizeHue };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=normalize-hue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-hue.js","names":[],"sources":["../../../src/color/color/normalize-hue.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-stately/src/color/Color.ts.\n * Modified for Solid Aria: reorganized color code, type declarations, imports, and formatting.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nexport function normalizeHue(hue: number): number {\n if (hue === 360) {\n return hue;\n }\n\n return ((hue % 360) + 360) % 360;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAgB,aAAa,KAAqB;CAChD,IAAI,QAAQ,KACV,OAAO;CAGT,QAAS,MAAM,MAAO,OAAO;AAC/B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/*
|
|
13
|
+
* Derived from Adobe React Spectrum: packages/react-stately/src/color/Color.ts.
|
|
14
|
+
* Modified for Solid Aria: reorganized color code, type declarations, imports, and formatting.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
import { Color } from "../types.js";
|
|
18
|
+
export declare function toOKLCH(color: Pick<Color, "toFormat">): [number, number, number];
|
|
19
|
+
//# sourceMappingURL=oklch.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/*
|
|
13
|
+
* Derived from Adobe React Spectrum: packages/react-stately/src/color/Color.ts.
|
|
14
|
+
* Modified for Solid Aria: reorganized color code, type declarations, imports, and formatting.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
// src/color/color/oklch.ts
|
|
18
|
+
function multiplyMatrix(m, x, y, z) {
|
|
19
|
+
return [
|
|
20
|
+
m[0] * x + m[1] * y + m[2] * z,
|
|
21
|
+
m[3] * x + m[4] * y + m[5] * z,
|
|
22
|
+
m[6] * x + m[7] * y + m[8] * z
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
function lin_sRGB_component(val) {
|
|
26
|
+
const sign = val < 0 ? -1 : 1;
|
|
27
|
+
const abs = Math.abs(val);
|
|
28
|
+
if (abs <= .04045) return val / 12.92;
|
|
29
|
+
return sign * ((abs + .055) / 1.055) ** 2.4;
|
|
30
|
+
}
|
|
31
|
+
function lin_sRGB(r, g, b) {
|
|
32
|
+
return [
|
|
33
|
+
lin_sRGB_component(r),
|
|
34
|
+
lin_sRGB_component(g),
|
|
35
|
+
lin_sRGB_component(b)
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
function lin_sRGB_to_XYZ(r, g, b) {
|
|
39
|
+
return multiplyMatrix([
|
|
40
|
+
506752 / 1228815,
|
|
41
|
+
87881 / 245763,
|
|
42
|
+
12673 / 70218,
|
|
43
|
+
87098 / 409605,
|
|
44
|
+
175762 / 245763,
|
|
45
|
+
12673 / 175545,
|
|
46
|
+
7918 / 409605,
|
|
47
|
+
87881 / 737289,
|
|
48
|
+
1001167 / 1053270
|
|
49
|
+
], r, g, b);
|
|
50
|
+
}
|
|
51
|
+
function XYZ_to_OKLab(x, y, z) {
|
|
52
|
+
const XYZtoLMS = [
|
|
53
|
+
.819022437996703,
|
|
54
|
+
.3619062600528904,
|
|
55
|
+
-.1288737815209879,
|
|
56
|
+
.0329836539323885,
|
|
57
|
+
.9292868615863434,
|
|
58
|
+
.0361446663506424,
|
|
59
|
+
.0481771893596242,
|
|
60
|
+
.2642395317527308,
|
|
61
|
+
.6335478284694309
|
|
62
|
+
];
|
|
63
|
+
const LMStoOKLab = [
|
|
64
|
+
.210454268309314,
|
|
65
|
+
.7936177747023054,
|
|
66
|
+
-.0040720430116193,
|
|
67
|
+
1.9779985324311684,
|
|
68
|
+
-2.42859224204858,
|
|
69
|
+
.450593709617411,
|
|
70
|
+
.0259040424655478,
|
|
71
|
+
.7827717124575296,
|
|
72
|
+
-.8086757549230774
|
|
73
|
+
];
|
|
74
|
+
const [a, b, c] = multiplyMatrix(XYZtoLMS, x, y, z);
|
|
75
|
+
return multiplyMatrix(LMStoOKLab, Math.cbrt(a), Math.cbrt(b), Math.cbrt(c));
|
|
76
|
+
}
|
|
77
|
+
function OKLab_to_OKLCH(l, a, b) {
|
|
78
|
+
const hue = Math.atan2(b, a) * 180 / Math.PI;
|
|
79
|
+
return [
|
|
80
|
+
l,
|
|
81
|
+
Math.hypot(a, b),
|
|
82
|
+
hue >= 0 ? hue : hue + 360
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
function toOKLCH(color) {
|
|
86
|
+
const rgb = color.toFormat("rgb");
|
|
87
|
+
let red = rgb.getChannelValue("red") / 255;
|
|
88
|
+
let green = rgb.getChannelValue("green") / 255;
|
|
89
|
+
let blue = rgb.getChannelValue("blue") / 255;
|
|
90
|
+
[red, green, blue] = lin_sRGB(red, green, blue);
|
|
91
|
+
const [x, y, z] = lin_sRGB_to_XYZ(red, green, blue);
|
|
92
|
+
const [l, a, b] = XYZ_to_OKLab(x, y, z);
|
|
93
|
+
return OKLab_to_OKLCH(l, a, b);
|
|
94
|
+
}
|
|
95
|
+
export { toOKLCH };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=oklch.js.map
|