@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 @@
|
|
|
1
|
+
{"version":3,"file":"create-single-select-list-state.js","names":[],"sources":["../../src/list/create-single-select-list-state.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/list/useSingleSelectListState.ts.\n * Modified for Solid Aria: adapted imports, collection descriptors, and reactive state APIs for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport type {\n CollectionStateBase,\n Key,\n Node,\n Selection,\n SingleSelection,\n} from \"@solid2-aria/types-shared\";\nimport { merge, untrack } from \"solid-js\";\n\nimport { createControlledSignal } from \"../utils/create-controlled-signal\";\nimport { createListState } from \"./create-list-state\";\nimport type { ListState } from \"./create-list-state\";\n\nexport interface SingleSelectListProps<T>\n extends\n CollectionStateBase<T>,\n Omit<SingleSelection, \"disallowEmptySelection\"> {\n /** Filter function to generate a filtered list of nodes. */\n filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>;\n /** @private */\n suppressTextValueWarning?: boolean;\n}\n\nexport interface SingleSelectListState<T> extends ListState<T> {\n /** The key for the currently selected item. */\n readonly selectedKey: Key | null;\n /** Sets the selected key. */\n setSelectedKey: (key: Key | null) => void;\n /** The value of the currently selected item. */\n readonly selectedItem: Node<T> | null;\n}\n\n/**\n * Provides state management for list-like components with single selection.\n * Handles building a collection of items from props, and manages selection state.\n */\nexport function createSingleSelectListState<T extends object>(\n props: SingleSelectListProps<T>\n): SingleSelectListState<T> {\n const [selectedKey, setSelectedKey] = createControlledSignal(\n () => props.selectedKey,\n untrack(() => props.defaultSelectedKey ?? null),\n (key) => props.onSelectionChange?.(key)\n );\n\n const state = createListState(\n merge(props, {\n allowDuplicateSelectionEvents: true,\n disallowEmptySelection: true,\n onSelectionChange(keys: Selection) {\n if (keys === \"all\") {\n return;\n }\n\n const key = keys.values().next().value ?? null;\n\n if (key === selectedKey()) {\n props.onSelectionChange?.(key);\n }\n\n setSelectedKey(key);\n },\n get selectedKeys() {\n const key = selectedKey();\n\n return key === null || key === undefined ? [] : [key];\n },\n selectionMode: \"single\" as const,\n })\n );\n\n return merge(state, {\n get selectedItem() {\n const key = selectedKey();\n\n return key === null || key === undefined\n ? null\n : state.collection.getItem(key);\n },\n get selectedKey() {\n return selectedKey();\n },\n setSelectedKey,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqDA,SAAgB,4BACd,OAC0B;CAC1B,MAAM,CAAC,aAAa,kBAAkB,6BAC9B,MAAM,aACZ,cAAc,MAAM,sBAAsB,IAAI,IAC7C,QAAQ,MAAM,oBAAoB,GAAG,CACxC;CAEA,MAAM,QAAQ,gBACZ,MAAM,OAAO;EACX,+BAA+B;EAC/B,wBAAwB;EACxB,kBAAkB,MAAiB;GACjC,IAAI,SAAS,OACX;GAGF,MAAM,MAAM,KAAK,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS;GAE1C,IAAI,QAAQ,YAAY,GACtB,MAAM,oBAAoB,GAAG;GAG/B,eAAe,GAAG;EACpB;EACA,IAAI,eAAe;GACjB,MAAM,MAAM,YAAY;GAExB,OAAO,QAAQ,QAAQ,QAAQ,KAAA,IAAY,CAAC,IAAI,CAAC,GAAG;EACtD;EACA,eAAe;CACjB,CAAC,CACH;CAEA,OAAO,MAAM,OAAO;EAClB,IAAI,eAAe;GACjB,MAAM,MAAM,YAAY;GAExB,OAAO,QAAQ,QAAQ,QAAQ,KAAA,IAC3B,OACA,MAAM,WAAW,QAAQ,GAAG;EAClC;EACA,IAAI,cAAc;GAChB,OAAO,YAAY;EACrB;EACA;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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/list/ListCollection.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted reactive state, getters, imports, and APIs for Solid 2.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
import { Collection, Key, Node } from "@solid2-aria/types-shared";
|
|
18
|
+
export declare class ListCollection<T> implements Collection<Node<T>> {
|
|
19
|
+
private readonly keyMap;
|
|
20
|
+
private readonly iterable;
|
|
21
|
+
private readonly firstKey;
|
|
22
|
+
private readonly lastKey;
|
|
23
|
+
private readonly _size;
|
|
24
|
+
constructor(nodes: Iterable<Node<T>>);
|
|
25
|
+
[Symbol.iterator](): IterableIterator<Node<T>>;
|
|
26
|
+
get size(): number;
|
|
27
|
+
getKeys(): IterableIterator<Key>;
|
|
28
|
+
getKeyBefore(key: Key): Key | null;
|
|
29
|
+
getKeyAfter(key: Key): Key | null;
|
|
30
|
+
getFirstKey(): Key | null;
|
|
31
|
+
getLastKey(): Key | null;
|
|
32
|
+
getItem(key: Key): Node<T> | null;
|
|
33
|
+
at(idx: number): Node<T> | null;
|
|
34
|
+
getChildren(key: Key): Iterable<Node<T>>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=list-collection.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
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/list/ListCollection.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted reactive state, getters, imports, and APIs for Solid 2.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
import { getNodeChildren } from "../collections/get-child-nodes.js";
|
|
18
|
+
// src/list/list-collection.ts
|
|
19
|
+
var ListCollection = class {
|
|
20
|
+
keyMap = /* @__PURE__ */ new Map();
|
|
21
|
+
iterable;
|
|
22
|
+
firstKey = null;
|
|
23
|
+
lastKey = null;
|
|
24
|
+
_size;
|
|
25
|
+
constructor(nodes) {
|
|
26
|
+
this.iterable = nodes;
|
|
27
|
+
const visit = (node) => {
|
|
28
|
+
this.keyMap.set(node.key, node);
|
|
29
|
+
if (node.type === "section") for (const child of getNodeChildren(node)) visit(child);
|
|
30
|
+
};
|
|
31
|
+
for (const node of nodes) visit(node);
|
|
32
|
+
let last = null;
|
|
33
|
+
let index = 0;
|
|
34
|
+
let size = 0;
|
|
35
|
+
for (const [key, node] of this.keyMap) {
|
|
36
|
+
if (last) {
|
|
37
|
+
last.nextKey = key;
|
|
38
|
+
node.prevKey = last.key;
|
|
39
|
+
} else {
|
|
40
|
+
this.firstKey = key;
|
|
41
|
+
node.prevKey = void 0;
|
|
42
|
+
}
|
|
43
|
+
if (node.type === "item") {
|
|
44
|
+
node.index = index;
|
|
45
|
+
index += 1;
|
|
46
|
+
}
|
|
47
|
+
if (node.type === "section" || node.type === "item") size += 1;
|
|
48
|
+
last = node;
|
|
49
|
+
last.nextKey = void 0;
|
|
50
|
+
}
|
|
51
|
+
this._size = size;
|
|
52
|
+
this.lastKey = last?.key ?? null;
|
|
53
|
+
}
|
|
54
|
+
*[Symbol.iterator]() {
|
|
55
|
+
yield* this.iterable;
|
|
56
|
+
}
|
|
57
|
+
get size() {
|
|
58
|
+
return this._size;
|
|
59
|
+
}
|
|
60
|
+
getKeys() {
|
|
61
|
+
return this.keyMap.keys();
|
|
62
|
+
}
|
|
63
|
+
getKeyBefore(key) {
|
|
64
|
+
const node = this.keyMap.get(key);
|
|
65
|
+
return node ? node.prevKey ?? null : null;
|
|
66
|
+
}
|
|
67
|
+
getKeyAfter(key) {
|
|
68
|
+
const node = this.keyMap.get(key);
|
|
69
|
+
return node ? node.nextKey ?? null : null;
|
|
70
|
+
}
|
|
71
|
+
getFirstKey() {
|
|
72
|
+
return this.firstKey;
|
|
73
|
+
}
|
|
74
|
+
getLastKey() {
|
|
75
|
+
return this.lastKey;
|
|
76
|
+
}
|
|
77
|
+
getItem(key) {
|
|
78
|
+
return this.keyMap.get(key) ?? null;
|
|
79
|
+
}
|
|
80
|
+
at(idx) {
|
|
81
|
+
const key = [...this.getKeys()][idx];
|
|
82
|
+
return key === null || key === void 0 ? null : this.getItem(key);
|
|
83
|
+
}
|
|
84
|
+
getChildren(key) {
|
|
85
|
+
const node = this.keyMap.get(key);
|
|
86
|
+
return node ? getNodeChildren(node) : [];
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
export { ListCollection };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=list-collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-collection.js","names":[],"sources":["../../src/list/list-collection.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/list/ListCollection.ts.\n * Modified for Solid Aria: adapted reactive state, getters, imports, and APIs for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport type { Collection, Key, Node } from \"@solid2-aria/types-shared\";\n\nimport { getNodeChildren } from \"../collections/get-child-nodes\";\n\nexport class ListCollection<T> implements Collection<Node<T>> {\n private readonly keyMap = new Map<Key, Node<T>>();\n private readonly iterable: Iterable<Node<T>>;\n private readonly firstKey: Key | null = null;\n private readonly lastKey: Key | null = null;\n private readonly _size: number;\n constructor(nodes: Iterable<Node<T>>) {\n this.iterable = nodes;\n\n const visit = (node: Node<T>) => {\n this.keyMap.set(node.key, node);\n\n if (node.type === \"section\") {\n for (const child of getNodeChildren(node)) {\n visit(child);\n }\n }\n };\n\n for (const node of nodes) {\n visit(node);\n }\n\n let last: Node<T> | null = null;\n let index = 0;\n let size = 0;\n\n for (const [key, node] of this.keyMap) {\n if (last) {\n last.nextKey = key;\n node.prevKey = last.key;\n } else {\n this.firstKey = key;\n node.prevKey = undefined;\n }\n\n if (node.type === \"item\") {\n node.index = index;\n index += 1;\n }\n\n // Only count sections and items when determining size so that\n // loaders and separators in RAC/S2 don't influence the emptyState determination\n if (node.type === \"section\" || node.type === \"item\") {\n size += 1;\n }\n\n last = node;\n // Set nextKey as undefined since this might be the last node\n // If it isn't the last node, last.nextKey will properly set at start of new loop\n last.nextKey = undefined;\n }\n\n this._size = size;\n this.lastKey = last?.key ?? null;\n }\n *[Symbol.iterator](): IterableIterator<Node<T>> {\n yield* this.iterable;\n }\n get size(): number {\n return this._size;\n }\n getKeys(): IterableIterator<Key> {\n return this.keyMap.keys();\n }\n getKeyBefore(key: Key): Key | null {\n const node = this.keyMap.get(key);\n\n return node ? (node.prevKey ?? null) : null;\n }\n getKeyAfter(key: Key): Key | null {\n const node = this.keyMap.get(key);\n\n return node ? (node.nextKey ?? null) : null;\n }\n getFirstKey(): Key | null {\n return this.firstKey;\n }\n getLastKey(): Key | null {\n return this.lastKey;\n }\n getItem(key: Key): Node<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n at(idx: number): Node<T> | null {\n const keys = [...this.getKeys()];\n const key = keys[idx];\n\n return key === null || key === undefined ? null : this.getItem(key);\n }\n getChildren(key: Key): Iterable<Node<T>> {\n const node = this.keyMap.get(key);\n\n return node ? getNodeChildren(node) : [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,IAAa,iBAAb,MAA8D;CAC5D,yBAA0B,IAAI,IAAkB;CAChD;CACA,WAAwC;CACxC,UAAuC;CACvC;CACA,YAAY,OAA0B;EACpC,KAAK,WAAW;EAEhB,MAAM,SAAS,SAAkB;GAC/B,KAAK,OAAO,IAAI,KAAK,KAAK,IAAI;GAE9B,IAAI,KAAK,SAAS,WAChB,KAAK,MAAM,SAAS,gBAAgB,IAAI,GACtC,MAAM,KAAK;EAGjB;EAEA,KAAK,MAAM,QAAQ,OACjB,MAAM,IAAI;EAGZ,IAAI,OAAuB;EAC3B,IAAI,QAAQ;EACZ,IAAI,OAAO;EAEX,KAAK,MAAM,CAAC,KAAK,SAAS,KAAK,QAAQ;GACrC,IAAI,MAAM;IACR,KAAK,UAAU;IACf,KAAK,UAAU,KAAK;GACtB,OAAO;IACL,KAAK,WAAW;IAChB,KAAK,UAAU,KAAA;GACjB;GAEA,IAAI,KAAK,SAAS,QAAQ;IACxB,KAAK,QAAQ;IACb,SAAS;GACX;GAIA,IAAI,KAAK,SAAS,aAAa,KAAK,SAAS,QAC3C,QAAQ;GAGV,OAAO;GAGP,KAAK,UAAU,KAAA;EACjB;EAEA,KAAK,QAAQ;EACb,KAAK,UAAU,MAAM,OAAO;CAC9B;CACA,EAAE,OAAO,YAAuC;EAC9C,OAAO,KAAK;CACd;CACA,IAAI,OAAe;EACjB,OAAO,KAAK;CACd;CACA,UAAiC;EAC/B,OAAO,KAAK,OAAO,KAAK;CAC1B;CACA,aAAa,KAAsB;EACjC,MAAM,OAAO,KAAK,OAAO,IAAI,GAAG;EAEhC,OAAO,OAAQ,KAAK,WAAW,OAAQ;CACzC;CACA,YAAY,KAAsB;EAChC,MAAM,OAAO,KAAK,OAAO,IAAI,GAAG;EAEhC,OAAO,OAAQ,KAAK,WAAW,OAAQ;CACzC;CACA,cAA0B;EACxB,OAAO,KAAK;CACd;CACA,aAAyB;EACvB,OAAO,KAAK;CACd;CACA,QAAQ,KAA0B;EAChC,OAAO,KAAK,OAAO,IAAI,GAAG,KAAK;CACjC;CACA,GAAG,KAA6B;EAE9B,MAAM,MAAM,CADE,GAAG,KAAK,QAAQ,CACf,CAAC,CAAC;EAEjB,OAAO,QAAQ,QAAQ,QAAQ,KAAA,IAAY,OAAO,KAAK,QAAQ,GAAG;CACpE;CACA,YAAY,KAA6B;EACvC,MAAM,OAAO,KAAK,OAAO,IAAI,GAAG;EAEhC,OAAO,OAAO,gBAAgB,IAAI,IAAI,CAAC;CACzC;AACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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/menu/useMenuTriggerState.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted imports, collection descriptors, and reactive state APIs for Solid 2.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
import { OverlayTriggerProps, OverlayTriggerState } from "../overlays/create-overlay-trigger-state.js";
|
|
18
|
+
import { FocusStrategy, Key } from "@solid2-aria/types-shared";
|
|
19
|
+
export type MenuTriggerType = "press" | "longPress" | "contextMenu";
|
|
20
|
+
export interface MenuTriggerProps extends OverlayTriggerProps {
|
|
21
|
+
/**
|
|
22
|
+
* How the menu is triggered.
|
|
23
|
+
*
|
|
24
|
+
* @default 'press'
|
|
25
|
+
*/
|
|
26
|
+
trigger?: MenuTriggerType;
|
|
27
|
+
}
|
|
28
|
+
export interface MenuTriggerState extends OverlayTriggerState {
|
|
29
|
+
/** Controls which item will be auto focused when the menu opens. */
|
|
30
|
+
readonly focusStrategy: FocusStrategy | null;
|
|
31
|
+
/** Opens the menu. */
|
|
32
|
+
open: (focusStrategy?: FocusStrategy | null) => void;
|
|
33
|
+
/** Toggles the menu. */
|
|
34
|
+
toggle: (focusStrategy?: FocusStrategy | null) => void;
|
|
35
|
+
}
|
|
36
|
+
export interface RootMenuTriggerState extends MenuTriggerState {
|
|
37
|
+
/** Opens a specific submenu tied to a specific menu item at a specific level. */
|
|
38
|
+
openSubmenu: (triggerKey: Key, level: number) => void;
|
|
39
|
+
/** Closes a specific submenu tied to a specific menu item at a specific level. */
|
|
40
|
+
closeSubmenu: (triggerKey: Key, level: number) => void;
|
|
41
|
+
/**
|
|
42
|
+
* An array of open submenu trigger keys within the menu tree.
|
|
43
|
+
* The index of key within array matches the submenu level in the tree.
|
|
44
|
+
*/
|
|
45
|
+
expandedKeysStack: Key[];
|
|
46
|
+
/** Closes the menu and all submenus in the menu tree. */
|
|
47
|
+
close: () => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Manages state for a menu trigger. Tracks whether the menu is currently open,
|
|
51
|
+
* and controls which item will receive focus when it opens. Also tracks the open submenus within
|
|
52
|
+
* the menu tree via their trigger keys.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createMenuTriggerState(props: MenuTriggerProps): RootMenuTriggerState;
|
|
55
|
+
//# sourceMappingURL=create-menu-trigger-state.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
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/menu/useMenuTriggerState.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted imports, collection descriptors, and reactive state APIs for Solid 2.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
import { createOverlayTriggerState } from "../overlays/create-overlay-trigger-state.js";
|
|
18
|
+
import { createSignal, merge } from "solid-js";
|
|
19
|
+
// src/menu/create-menu-trigger-state.ts
|
|
20
|
+
/**
|
|
21
|
+
* Manages state for a menu trigger. Tracks whether the menu is currently open,
|
|
22
|
+
* and controls which item will receive focus when it opens. Also tracks the open submenus within
|
|
23
|
+
* the menu tree via their trigger keys.
|
|
24
|
+
*/
|
|
25
|
+
function createMenuTriggerState(props) {
|
|
26
|
+
const overlay = createOverlayTriggerState(props);
|
|
27
|
+
const [focusStrategy, setFocusStrategy] = createSignal(null, { ownedWrite: true });
|
|
28
|
+
const [expandedKeysStack, setExpandedKeysStack] = createSignal([], { ownedWrite: true });
|
|
29
|
+
return merge(overlay, {
|
|
30
|
+
close() {
|
|
31
|
+
setExpandedKeysStack([]);
|
|
32
|
+
overlay.close();
|
|
33
|
+
},
|
|
34
|
+
closeSubmenu(key, level) {
|
|
35
|
+
setExpandedKeysStack((stack) => stack[level] === key ? stack.slice(0, level) : stack);
|
|
36
|
+
},
|
|
37
|
+
get expandedKeysStack() {
|
|
38
|
+
return expandedKeysStack();
|
|
39
|
+
},
|
|
40
|
+
get focusStrategy() {
|
|
41
|
+
return focusStrategy();
|
|
42
|
+
},
|
|
43
|
+
open(strategy = null) {
|
|
44
|
+
setFocusStrategy(strategy);
|
|
45
|
+
overlay.open();
|
|
46
|
+
},
|
|
47
|
+
openSubmenu(key, level) {
|
|
48
|
+
setExpandedKeysStack((stack) => level > stack.length ? stack : [...stack.slice(0, level), key]);
|
|
49
|
+
},
|
|
50
|
+
toggle(strategy = null) {
|
|
51
|
+
setFocusStrategy(strategy);
|
|
52
|
+
overlay.toggle();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export { createMenuTriggerState };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=create-menu-trigger-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-menu-trigger-state.js","names":[],"sources":["../../src/menu/create-menu-trigger-state.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/menu/useMenuTriggerState.ts.\n * Modified for Solid Aria: adapted imports, collection descriptors, and reactive state APIs for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport type { FocusStrategy, Key } from \"@solid2-aria/types-shared\";\nimport { createSignal, merge } from \"solid-js\";\n\nimport { createOverlayTriggerState } from \"../overlays/create-overlay-trigger-state\";\nimport type {\n OverlayTriggerProps,\n OverlayTriggerState,\n} from \"../overlays/create-overlay-trigger-state\";\n\nexport type MenuTriggerType = \"press\" | \"longPress\" | \"contextMenu\";\n\nexport interface MenuTriggerProps extends OverlayTriggerProps {\n /**\n * How the menu is triggered.\n *\n * @default 'press'\n */\n trigger?: MenuTriggerType;\n}\n\nexport interface MenuTriggerState extends OverlayTriggerState {\n /** Controls which item will be auto focused when the menu opens. */\n readonly focusStrategy: FocusStrategy | null;\n /** Opens the menu. */\n open: (focusStrategy?: FocusStrategy | null) => void;\n /** Toggles the menu. */\n toggle: (focusStrategy?: FocusStrategy | null) => void;\n}\n\nexport interface RootMenuTriggerState extends MenuTriggerState {\n /** Opens a specific submenu tied to a specific menu item at a specific level. */\n openSubmenu: (triggerKey: Key, level: number) => void;\n /** Closes a specific submenu tied to a specific menu item at a specific level. */\n closeSubmenu: (triggerKey: Key, level: number) => void;\n /**\n * An array of open submenu trigger keys within the menu tree.\n * The index of key within array matches the submenu level in the tree.\n */\n expandedKeysStack: Key[];\n /** Closes the menu and all submenus in the menu tree. */\n close: () => void;\n}\n\n/**\n * Manages state for a menu trigger. Tracks whether the menu is currently open,\n * and controls which item will receive focus when it opens. Also tracks the open submenus within\n * the menu tree via their trigger keys.\n */\nexport function createMenuTriggerState(\n props: MenuTriggerProps\n): RootMenuTriggerState {\n const overlay = createOverlayTriggerState(props);\n\n const [focusStrategy, setFocusStrategy] = createSignal<FocusStrategy | null>(\n null,\n { ownedWrite: true }\n );\n\n const [expandedKeysStack, setExpandedKeysStack] = createSignal<Key[]>([], {\n ownedWrite: true,\n });\n\n return merge(overlay, {\n close() {\n setExpandedKeysStack([]);\n overlay.close();\n },\n closeSubmenu(key: Key, level: number) {\n setExpandedKeysStack((stack) =>\n stack[level] === key ? stack.slice(0, level) : stack\n );\n },\n get expandedKeysStack() {\n return expandedKeysStack();\n },\n get focusStrategy() {\n return focusStrategy();\n },\n open(strategy: FocusStrategy | null = null) {\n setFocusStrategy(strategy);\n overlay.open();\n },\n openSubmenu(key: Key, level: number) {\n setExpandedKeysStack((stack) =>\n level > stack.length ? stack : [...stack.slice(0, level), key]\n );\n },\n toggle(strategy: FocusStrategy | null = null) {\n setFocusStrategy(strategy);\n overlay.toggle();\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,uBACd,OACsB;CACtB,MAAM,UAAU,0BAA0B,KAAK;CAE/C,MAAM,CAAC,eAAe,oBAAoB,aACxC,MACA,EAAE,YAAY,KAAK,CACrB;CAEA,MAAM,CAAC,mBAAmB,wBAAwB,aAAoB,CAAC,GAAG,EACxE,YAAY,KACd,CAAC;CAED,OAAO,MAAM,SAAS;EACpB,QAAQ;GACN,qBAAqB,CAAC,CAAC;GACvB,QAAQ,MAAM;EAChB;EACA,aAAa,KAAU,OAAe;GACpC,sBAAsB,UACpB,MAAM,WAAW,MAAM,MAAM,MAAM,GAAG,KAAK,IAAI,KACjD;EACF;EACA,IAAI,oBAAoB;GACtB,OAAO,kBAAkB;EAC3B;EACA,IAAI,gBAAgB;GAClB,OAAO,cAAc;EACvB;EACA,KAAK,WAAiC,MAAM;GAC1C,iBAAiB,QAAQ;GACzB,QAAQ,KAAK;EACf;EACA,YAAY,KAAU,OAAe;GACnC,sBAAsB,UACpB,QAAQ,MAAM,SAAS,QAAQ,CAAC,GAAG,MAAM,MAAM,GAAG,KAAK,GAAG,GAAG,CAC/D;EACF;EACA,OAAO,WAAiC,MAAM;GAC5C,iBAAiB,QAAQ;GACzB,QAAQ,OAAO;EACjB;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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/menu/useSubmenuTriggerState.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted imports, collection descriptors, and reactive state APIs for Solid 2.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
import { OverlayTriggerState } from "../overlays/create-overlay-trigger-state.js";
|
|
18
|
+
import { RootMenuTriggerState } from "./create-menu-trigger-state.js";
|
|
19
|
+
import { FocusStrategy, Key } from "@solid2-aria/types-shared";
|
|
20
|
+
export interface SubmenuTriggerProps {
|
|
21
|
+
/** Key of the trigger item. */
|
|
22
|
+
triggerKey: Key;
|
|
23
|
+
}
|
|
24
|
+
export interface SubmenuTriggerState extends OverlayTriggerState {
|
|
25
|
+
/** Whether the submenu is currently open. */
|
|
26
|
+
isOpen: boolean;
|
|
27
|
+
/** Controls which item will be auto focused when the submenu opens. */
|
|
28
|
+
focusStrategy: FocusStrategy | null;
|
|
29
|
+
/** Opens the submenu. */
|
|
30
|
+
open: (focusStrategy?: FocusStrategy | null) => void;
|
|
31
|
+
/** Closes the submenu. */
|
|
32
|
+
close: () => void;
|
|
33
|
+
/** Closes all menus and submenus in the menu tree. */
|
|
34
|
+
closeAll: () => void;
|
|
35
|
+
/** The level of the submenu. */
|
|
36
|
+
submenuLevel: number;
|
|
37
|
+
/** Toggles the submenu. */
|
|
38
|
+
toggle: (focusStrategy?: FocusStrategy | null) => void;
|
|
39
|
+
/** @private */
|
|
40
|
+
setOpen: () => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Manages state for a submenu trigger. Tracks whether the submenu is currently open, the level of
|
|
44
|
+
* the submenu, and controls which item will receive focus when it opens.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createSubmenuTriggerState(props: SubmenuTriggerProps, state: RootMenuTriggerState): SubmenuTriggerState;
|
|
47
|
+
//# sourceMappingURL=create-submenu-trigger-state.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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/menu/useSubmenuTriggerState.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted imports, collection descriptors, and reactive state APIs for Solid 2.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
import { createSignal, untrack } from "solid-js";
|
|
18
|
+
// src/menu/create-submenu-trigger-state.ts
|
|
19
|
+
/**
|
|
20
|
+
* Manages state for a submenu trigger. Tracks whether the submenu is currently open, the level of
|
|
21
|
+
* the submenu, and controls which item will receive focus when it opens.
|
|
22
|
+
*/
|
|
23
|
+
function createSubmenuTriggerState(props, state) {
|
|
24
|
+
const submenuLevel = untrack(() => state.expandedKeysStack.length);
|
|
25
|
+
const [focusStrategy, setFocusStrategy] = createSignal(null, { ownedWrite: true });
|
|
26
|
+
const isOpen = () => state.expandedKeysStack[submenuLevel] === props.triggerKey;
|
|
27
|
+
function open(strategy = null) {
|
|
28
|
+
setFocusStrategy(strategy);
|
|
29
|
+
state.openSubmenu(props.triggerKey, submenuLevel);
|
|
30
|
+
}
|
|
31
|
+
function close() {
|
|
32
|
+
setFocusStrategy(null);
|
|
33
|
+
state.closeSubmenu(props.triggerKey, submenuLevel);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
close,
|
|
37
|
+
closeAll: () => {
|
|
38
|
+
state.close();
|
|
39
|
+
},
|
|
40
|
+
get focusStrategy() {
|
|
41
|
+
return focusStrategy();
|
|
42
|
+
},
|
|
43
|
+
get isOpen() {
|
|
44
|
+
return isOpen();
|
|
45
|
+
},
|
|
46
|
+
open,
|
|
47
|
+
point: null,
|
|
48
|
+
setOpen: () => {},
|
|
49
|
+
setPoint: () => {},
|
|
50
|
+
submenuLevel,
|
|
51
|
+
toggle(strategy) {
|
|
52
|
+
if (isOpen()) close();
|
|
53
|
+
else open(strategy);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export { createSubmenuTriggerState };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=create-submenu-trigger-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-submenu-trigger-state.js","names":[],"sources":["../../src/menu/create-submenu-trigger-state.ts"],"sourcesContent":["/*\n * Copyright 2023 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/menu/useSubmenuTriggerState.ts.\n * Modified for Solid Aria: adapted imports, collection descriptors, and reactive state APIs for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport type { FocusStrategy, Key } from \"@solid2-aria/types-shared\";\nimport { createSignal, untrack } from \"solid-js\";\n\nimport type { OverlayTriggerState } from \"../overlays/create-overlay-trigger-state\";\nimport type { RootMenuTriggerState } from \"./create-menu-trigger-state\";\n\nexport interface SubmenuTriggerProps {\n /** Key of the trigger item. */\n triggerKey: Key;\n}\n\nexport interface SubmenuTriggerState extends OverlayTriggerState {\n /** Whether the submenu is currently open. */\n isOpen: boolean;\n /** Controls which item will be auto focused when the submenu opens. */\n focusStrategy: FocusStrategy | null;\n /** Opens the submenu. */\n open: (focusStrategy?: FocusStrategy | null) => void;\n /** Closes the submenu. */\n close: () => void;\n /** Closes all menus and submenus in the menu tree. */\n closeAll: () => void;\n /** The level of the submenu. */\n submenuLevel: number;\n /** Toggles the submenu. */\n toggle: (focusStrategy?: FocusStrategy | null) => void;\n /** @private */\n setOpen: () => void;\n}\n\n/**\n * Manages state for a submenu trigger. Tracks whether the submenu is currently open, the level of\n * the submenu, and controls which item will receive focus when it opens.\n */\nexport function createSubmenuTriggerState(\n props: SubmenuTriggerProps,\n state: RootMenuTriggerState\n): SubmenuTriggerState {\n const submenuLevel = untrack(() => state.expandedKeysStack.length);\n\n const [focusStrategy, setFocusStrategy] = createSignal<FocusStrategy | null>(\n null,\n { ownedWrite: true }\n );\n\n const isOpen = () =>\n state.expandedKeysStack[submenuLevel] === props.triggerKey;\n\n function open(strategy: FocusStrategy | null = null) {\n setFocusStrategy(strategy);\n state.openSubmenu(props.triggerKey, submenuLevel);\n }\n\n function close() {\n setFocusStrategy(null);\n state.closeSubmenu(props.triggerKey, submenuLevel);\n }\n\n return {\n close,\n closeAll: () => {\n state.close();\n },\n get focusStrategy() {\n return focusStrategy();\n },\n get isOpen() {\n return isOpen();\n },\n open,\n point: null,\n setOpen: () => {\n /* Synchronization is performed in the tracked phase. */\n },\n setPoint: () => {\n /* Synchronization is performed in the tracked phase. */\n },\n submenuLevel,\n toggle(strategy) {\n if (isOpen()) {\n close();\n } else {\n open(strategy);\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,0BACd,OACA,OACqB;CACrB,MAAM,eAAe,cAAc,MAAM,kBAAkB,MAAM;CAEjE,MAAM,CAAC,eAAe,oBAAoB,aACxC,MACA,EAAE,YAAY,KAAK,CACrB;CAEA,MAAM,eACJ,MAAM,kBAAkB,kBAAkB,MAAM;CAElD,SAAS,KAAK,WAAiC,MAAM;EACnD,iBAAiB,QAAQ;EACzB,MAAM,YAAY,MAAM,YAAY,YAAY;CAClD;CAEA,SAAS,QAAQ;EACf,iBAAiB,IAAI;EACrB,MAAM,aAAa,MAAM,YAAY,YAAY;CACnD;CAEA,OAAO;EACL;EACA,gBAAgB;GACd,MAAM,MAAM;EACd;EACA,IAAI,gBAAgB;GAClB,OAAO,cAAc;EACvB;EACA,IAAI,SAAS;GACX,OAAO,OAAO;EAChB;EACA;EACA,OAAO;EACP,eAAe,CAEf;EACA,gBAAgB,CAEhB;EACA;EACA,OAAO,UAAU;GACf,IAAI,OAAO,GACT,MAAM;QAEN,KAAK,QAAQ;EAEjB;CACF;AACF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
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/numberfield/useNumberFieldState.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted state handling, APIs, or formatting for Solid 2.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
import { FormValidationState } from "../form/create-form-validation-state.js";
|
|
18
|
+
import { FocusableProps, HelpTextProps, InputBase, LabelableProps, RangeInputBase, TextInputBase, Validation, ValueBase } from "@solid2-aria/types-shared";
|
|
19
|
+
export interface NumberFieldProps extends InputBase, Validation<number>, FocusableProps, TextInputBase, ValueBase<number>, RangeInputBase<number>, LabelableProps, HelpTextProps {
|
|
20
|
+
/**
|
|
21
|
+
* Formatting options for the value displayed in the number field.
|
|
22
|
+
* This also affects what characters are allowed to be typed by the user.
|
|
23
|
+
*/
|
|
24
|
+
formatOptions?: Intl.NumberFormatOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Controls the behavior of the number field when the user blurs the field after editing. 'snap'
|
|
27
|
+
* will clamp the value to the min/max values, and snap to the nearest step value. 'validate' will
|
|
28
|
+
* not clamp the value, and will validate that the value is within the min/max range and on a
|
|
29
|
+
* valid step.
|
|
30
|
+
*
|
|
31
|
+
* @default 'snap'
|
|
32
|
+
*/
|
|
33
|
+
commitBehavior?: "snap" | "validate";
|
|
34
|
+
}
|
|
35
|
+
export interface NumberFieldState extends FormValidationState {
|
|
36
|
+
/**
|
|
37
|
+
* The current text value of the input. Updated as the user types,
|
|
38
|
+
* and formatted according to `formatOptions` on blur.
|
|
39
|
+
*/
|
|
40
|
+
inputValue: string;
|
|
41
|
+
/**
|
|
42
|
+
* The currently parsed number value, or Number.NaN if a valid number could not be parsed.
|
|
43
|
+
* Updated based on the `inputValue` as the user types.
|
|
44
|
+
*/
|
|
45
|
+
numberValue: number;
|
|
46
|
+
/** The default value of the input. */
|
|
47
|
+
defaultNumberValue: number;
|
|
48
|
+
/** The minimum value of the number field. */
|
|
49
|
+
minValue?: number;
|
|
50
|
+
/** The maximum value of the number field. */
|
|
51
|
+
maxValue?: number;
|
|
52
|
+
/** Whether the current value can be incremented according to the maximum value and step. */
|
|
53
|
+
canIncrement: boolean;
|
|
54
|
+
/** Whether the current value can be decremented according to the minimum value and step. */
|
|
55
|
+
canDecrement: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Validates a user input string according to the current locale and format options. Values can be
|
|
58
|
+
* partially entered, and may be valid even if they cannot currently be parsed to a number. Can be
|
|
59
|
+
* used to implement validation as a user types.
|
|
60
|
+
*/
|
|
61
|
+
validate: (value: string) => boolean;
|
|
62
|
+
/** Sets the current text value of the input. */
|
|
63
|
+
setInputValue: (val: string) => void;
|
|
64
|
+
/** Sets the number value. */
|
|
65
|
+
setNumberValue: (val: number) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Commits the current input value. The value is parsed to a number, clamped according to the
|
|
68
|
+
* minimum and maximum values of the field, and snapped to the nearest step value. This will fire
|
|
69
|
+
* the `onChange` prop with the new value, and if uncontrolled, update the `numberValue`.
|
|
70
|
+
* Typically this is called when the field is blurred.
|
|
71
|
+
*
|
|
72
|
+
* @param value - The value to commit. If not provided, the current input value is used.
|
|
73
|
+
*/
|
|
74
|
+
commit: (value?: string) => void;
|
|
75
|
+
/** Increments the current input value to the next step boundary, and fires `onChange`. */
|
|
76
|
+
increment: () => void;
|
|
77
|
+
/** Decrements the current input value to the next step boundary, and fires `onChange`. */
|
|
78
|
+
decrement: () => void;
|
|
79
|
+
/** Sets the current value to the `maxValue` if any, and fires `onChange`. */
|
|
80
|
+
incrementToMax: () => void;
|
|
81
|
+
/** Sets the current value to the `minValue` if any, and fires `onChange`. */
|
|
82
|
+
decrementToMin: () => void;
|
|
83
|
+
}
|
|
84
|
+
export interface NumberFieldStateOptions extends NumberFieldProps {
|
|
85
|
+
/**
|
|
86
|
+
* The locale that should be used for parsing.
|
|
87
|
+
*
|
|
88
|
+
* @default 'en-US'
|
|
89
|
+
*/
|
|
90
|
+
locale: string;
|
|
91
|
+
}
|
|
92
|
+
export declare function createNumberFieldState(props: NumberFieldStateOptions): NumberFieldState;
|
|
93
|
+
//# sourceMappingURL=create-number-field-state.d.ts.map
|
|
@@ -0,0 +1,139 @@
|
|
|
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/numberfield/useNumberFieldState.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted state handling, APIs, or formatting for Solid 2.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
import { createControlledSignal } from "../utils/create-controlled-signal.js";
|
|
18
|
+
import { createFormValidationState } from "../form/create-form-validation-state.js";
|
|
19
|
+
import { clamp, snapValueToStep } from "../utils/number.js";
|
|
20
|
+
import { createMemo, createRenderEffect, createSignal, merge, untrack } from "solid-js";
|
|
21
|
+
import { NumberFormatter, NumberParser } from "@internationalized/number";
|
|
22
|
+
// src/numberfield/create-number-field-state.ts
|
|
23
|
+
function createNumberFieldState(props) {
|
|
24
|
+
const snap = (v) => props.step === void 0 || Number.isNaN(props.step) ? clamp(v, props.minValue, props.maxValue) : snapValueToStep(v, props.minValue, props.maxValue, props.step);
|
|
25
|
+
const normalize = (v) => props.commitBehavior === "validate" || Number.isNaN(v) ? v : snap(v);
|
|
26
|
+
const defaults = () => normalize(props.defaultValue ?? NaN);
|
|
27
|
+
const [numberValue, setNumberValue] = createControlledSignal(() => props.value === void 0 ? void 0 : normalize(props.value), untrack(defaults), (v) => props.onChange?.(v));
|
|
28
|
+
const initial = untrack(numberValue);
|
|
29
|
+
const parser = createMemo(() => new NumberParser(props.locale, props.formatOptions));
|
|
30
|
+
const [inputValue, setInputValue] = createSignal(untrack(() => Number.isNaN(initial) ? "" : new NumberFormatter(props.locale, props.formatOptions).format(initial)), { ownedWrite: true });
|
|
31
|
+
const formatter = createMemo(() => new NumberFormatter(props.locale, {
|
|
32
|
+
...props.formatOptions,
|
|
33
|
+
numberingSystem: parser().getNumberingSystem(inputValue())
|
|
34
|
+
}));
|
|
35
|
+
const format = (v) => Number.isNaN(v) ? "" : formatter().format(v);
|
|
36
|
+
let previous = initial;
|
|
37
|
+
let previousLocale = untrack(() => props.locale);
|
|
38
|
+
let previousOptions = JSON.stringify(untrack(() => props.formatOptions));
|
|
39
|
+
createRenderEffect(() => ({
|
|
40
|
+
formatted: format(numberValue()),
|
|
41
|
+
locale: props.locale,
|
|
42
|
+
options: JSON.stringify(props.formatOptions),
|
|
43
|
+
v: numberValue()
|
|
44
|
+
}), (current) => {
|
|
45
|
+
if (!Object.is(previous, current.v) || previousLocale !== current.locale || previousOptions !== current.options) {
|
|
46
|
+
previous = current.v;
|
|
47
|
+
previousLocale = current.locale;
|
|
48
|
+
previousOptions = current.options;
|
|
49
|
+
setInputValue(current.formatted);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const parsed = createMemo(() => inputValue().length === 0 ? NaN : parser().parse(inputValue()));
|
|
53
|
+
const validation = createFormValidationState(merge(props, { get value() {
|
|
54
|
+
return numberValue();
|
|
55
|
+
} }));
|
|
56
|
+
const step = () => {
|
|
57
|
+
if (props.step !== void 0 && !Number.isNaN(props.step)) return props.step;
|
|
58
|
+
return formatter().resolvedOptions().style === "percent" ? .01 : 1;
|
|
59
|
+
};
|
|
60
|
+
const nextStep = (direction) => {
|
|
61
|
+
const v = parsed();
|
|
62
|
+
if (Number.isNaN(v)) return snapValueToStep((direction === 1 ? props.minValue : props.maxValue) ?? 0, props.minValue, props.maxValue, step());
|
|
63
|
+
const n = snapValueToStep(v, props.minValue, props.maxValue, step());
|
|
64
|
+
return direction * (n - v) > 0 ? n : snapValueToStep(Number((v + direction * step()).toPrecision(15)), props.minValue, props.maxValue, step());
|
|
65
|
+
};
|
|
66
|
+
const move = (direction) => {
|
|
67
|
+
const v = nextStep(direction);
|
|
68
|
+
if (v === numberValue()) setInputValue(format(v));
|
|
69
|
+
setNumberValue(v);
|
|
70
|
+
validation.commitValidation();
|
|
71
|
+
};
|
|
72
|
+
return merge(validation, {
|
|
73
|
+
get canDecrement() {
|
|
74
|
+
return props.isDisabled !== true && props.isReadOnly !== true && (Number.isNaN(parsed()) || props.minValue === void 0 || Number.isNaN(props.minValue) || nextStep(-1) < parsed());
|
|
75
|
+
},
|
|
76
|
+
get canIncrement() {
|
|
77
|
+
return props.isDisabled !== true && props.isReadOnly !== true && (Number.isNaN(parsed()) || props.maxValue === void 0 || Number.isNaN(props.maxValue) || nextStep(1) > parsed());
|
|
78
|
+
},
|
|
79
|
+
commit(override) {
|
|
80
|
+
const text = override ?? inputValue();
|
|
81
|
+
if (!text.length) {
|
|
82
|
+
setNumberValue(NaN);
|
|
83
|
+
setInputValue(props.value === void 0 ? "" : format(numberValue()));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const v = parser().parse(text);
|
|
87
|
+
if (Number.isNaN(v)) {
|
|
88
|
+
setInputValue(format(numberValue()));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const n = parser().parse(format(normalize(v)));
|
|
92
|
+
const changed = n !== numberValue();
|
|
93
|
+
setNumberValue(n);
|
|
94
|
+
setInputValue(format(props.value === void 0 ? n : numberValue()));
|
|
95
|
+
if (changed) validation.commitValidation();
|
|
96
|
+
},
|
|
97
|
+
decrement() {
|
|
98
|
+
move(-1);
|
|
99
|
+
},
|
|
100
|
+
decrementToMin() {
|
|
101
|
+
if (props.minValue !== void 0) {
|
|
102
|
+
setNumberValue(props.minValue);
|
|
103
|
+
validation.commitValidation();
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
get defaultNumberValue() {
|
|
107
|
+
return Number.isNaN(defaults()) ? initial : defaults();
|
|
108
|
+
},
|
|
109
|
+
increment() {
|
|
110
|
+
move(1);
|
|
111
|
+
},
|
|
112
|
+
incrementToMax() {
|
|
113
|
+
if (props.maxValue !== void 0) {
|
|
114
|
+
setNumberValue(snapValueToStep(props.maxValue, props.minValue, props.maxValue, step()));
|
|
115
|
+
validation.commitValidation();
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
get inputValue() {
|
|
119
|
+
return inputValue();
|
|
120
|
+
},
|
|
121
|
+
get maxValue() {
|
|
122
|
+
return props.maxValue;
|
|
123
|
+
},
|
|
124
|
+
get minValue() {
|
|
125
|
+
return props.minValue;
|
|
126
|
+
},
|
|
127
|
+
get numberValue() {
|
|
128
|
+
return parsed();
|
|
129
|
+
},
|
|
130
|
+
setInputValue,
|
|
131
|
+
setNumberValue,
|
|
132
|
+
validate(v) {
|
|
133
|
+
return parser().isValidPartialNumber(v, props.minValue, props.maxValue);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
export { createNumberFieldState };
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=create-number-field-state.js.map
|