@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":"utils.js","names":[],"sources":["../../src/calendar/utils.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/calendar/utils.ts.\n * Modified for Solid Aria: adapted state, collection descriptors, 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 {\n maxDate,\n minDate,\n startOfMonth,\n startOfWeek,\n startOfYear,\n toCalendarDate,\n} from \"@internationalized/date\";\nimport type { CalendarDate, DateDuration } from \"@internationalized/date\";\n\nimport type { DateValue } from \"./types\";\n\nexport function isInvalid(\n date: DateValue,\n minValue?: DateValue | null,\n maxValue?: DateValue | null\n): boolean {\n return (\n (minValue !== null &&\n minValue !== undefined &&\n date.compare(minValue) < 0) ||\n (maxValue !== null && maxValue !== undefined && date.compare(maxValue) > 0)\n );\n}\n\nexport function alignCenter(\n date: CalendarDate,\n duration: DateDuration,\n locale: string,\n minValue?: DateValue | null,\n maxValue?: DateValue | null\n): CalendarDate {\n const halfDuration: DateDuration = {};\n\n for (const key of [\"years\", \"months\", \"weeks\", \"days\"] as const) {\n halfDuration[key] = Math.floor((duration[key] ?? 0) / 2);\n\n if (halfDuration[key] > 0 && (duration[key] ?? 0) % 2 === 0) {\n halfDuration[key] -= 1;\n }\n }\n\n const aligned = alignStart(date, duration, locale).subtract(halfDuration);\n\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function alignStart(\n date: CalendarDate,\n duration: DateDuration,\n locale: string,\n minValue?: DateValue | null,\n maxValue?: DateValue | null\n): CalendarDate {\n // align to the start of the largest unit\n let aligned = date;\n\n if (\n duration.years !== undefined &&\n duration.years !== 0 &&\n !Number.isNaN(duration.years)\n ) {\n aligned = startOfYear(date);\n } else if (\n duration.months !== undefined &&\n duration.months !== 0 &&\n !Number.isNaN(duration.months)\n ) {\n aligned = startOfMonth(date);\n } else if (\n (duration.weeks !== undefined &&\n duration.weeks !== 0 &&\n !Number.isNaN(duration.weeks)) ||\n (duration.days !== undefined &&\n duration.days !== 0 &&\n !Number.isNaN(duration.days) &&\n duration.days > 7)\n ) {\n aligned = startOfWeek(date, locale);\n }\n\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function alignEnd(\n date: CalendarDate,\n duration: DateDuration,\n locale: string,\n minValue?: DateValue | null,\n maxValue?: DateValue | null\n): CalendarDate {\n const d = { ...duration };\n\n // subtract 1 from the smallest unit\n if (d.days !== undefined && d.days !== 0 && !Number.isNaN(d.days)) {\n d.days -= 1;\n } else if (d.weeks !== undefined && d.weeks !== 0 && !Number.isNaN(d.weeks)) {\n d.weeks -= 1;\n } else if (\n d.months !== undefined &&\n d.months !== 0 &&\n !Number.isNaN(d.months)\n ) {\n d.months -= 1;\n } else if (d.years !== undefined && d.years !== 0 && !Number.isNaN(d.years)) {\n d.years -= 1;\n }\n\n const aligned = alignStart(date, duration, locale).subtract(d);\n\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function constrainStart(\n date: CalendarDate,\n initialAligned: CalendarDate,\n duration: DateDuration,\n locale: string,\n minValue?: DateValue | null,\n maxValue?: DateValue | null\n): CalendarDate {\n let aligned = initialAligned;\n\n if (minValue && date.compare(minValue) >= 0) {\n const newDate = maxDate(\n aligned,\n alignStart(toCalendarDate(minValue), duration, locale)\n );\n\n if (newDate) {\n aligned = newDate;\n }\n }\n\n if (maxValue && date.compare(maxValue) <= 0) {\n const newDate = minDate(\n aligned,\n alignEnd(toCalendarDate(maxValue), duration, locale)\n );\n\n aligned = newDate;\n }\n\n return aligned;\n}\n\nexport function constrainValue(\n initialDate: CalendarDate,\n minValue?: DateValue | null,\n maxValue?: DateValue | null\n): CalendarDate {\n let date = initialDate;\n\n if (minValue) {\n const newDate = maxDate(date, toCalendarDate(minValue));\n\n if (newDate) {\n date = newDate;\n }\n }\n\n if (maxValue) {\n const newDate = minDate(date, toCalendarDate(maxValue));\n\n date = newDate;\n }\n\n return date;\n}\n\nexport function previousAvailableDate(\n initialDate: CalendarDate,\n minValue: DateValue,\n isDateUnavailable?: (date: CalendarDate) => boolean\n): CalendarDate | null {\n let date = initialDate;\n\n if (!isDateUnavailable) {\n return date;\n }\n\n while (date.compare(minValue) >= 0 && isDateUnavailable(date)) {\n date = date.subtract({ days: 1 });\n }\n\n if (date.compare(minValue) >= 0) {\n return date;\n }\n\n return null;\n}\n\nexport function isEqualDuration(a: DateDuration, b: DateDuration): boolean {\n if (a === b) {\n return true;\n }\n\n return (\n a.days === b.days &&\n a.weeks === b.weeks &&\n a.months === b.months &&\n a.years === b.years\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,SAAgB,UACd,MACA,UACA,UACS;CACT,OACG,aAAa,QACZ,aAAa,KAAA,KACb,KAAK,QAAQ,QAAQ,IAAI,KAC1B,aAAa,QAAQ,aAAa,KAAA,KAAa,KAAK,QAAQ,QAAQ,IAAI;AAE7E;AAEA,SAAgB,YACd,MACA,UACA,QACA,UACA,UACc;CACd,MAAM,eAA6B,CAAC;CAEpC,KAAK,MAAM,OAAO;EAAC;EAAS;EAAU;EAAS;CAAM,GAAY;EAC/D,aAAa,OAAO,KAAK,OAAO,SAAS,QAAQ,KAAK,CAAC;EAEvD,IAAI,aAAa,OAAO,MAAM,SAAS,QAAQ,KAAK,MAAM,GACxD,aAAa,QAAQ;CAEzB;CAIA,OAAO,eAAe,MAFN,WAAW,MAAM,UAAU,MAAM,CAAC,CAAC,SAAS,YAE1B,GAAG,UAAU,QAAQ,UAAU,QAAQ;AAC3E;AAEA,SAAgB,WACd,MACA,UACA,QACA,UACA,UACc;CAEd,IAAI,UAAU;CAEd,IACE,SAAS,UAAU,KAAA,KACnB,SAAS,UAAU,KACnB,CAAC,OAAO,MAAM,SAAS,KAAK,GAE5B,UAAU,YAAY,IAAI;MACrB,IACL,SAAS,WAAW,KAAA,KACpB,SAAS,WAAW,KACpB,CAAC,OAAO,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,MAAM,CAGrC;CAGlB,OAAO;AACT;AAEA,SAAgB,eACd,aACA,UACA,UACc;CACd,IAAI,OAAO;CAEX,IAAI,UAAU;EACZ,MAAM,UAAU,QAAQ,MAAM,eAAe,QAAQ,CAAC;EAEtD,IAAI,SACF,OAAO;CAEX;CAEA,IAAI,UAGF,OAFgB,QAAQ,MAAM,eAAe,QAAQ,CAExC;CAGf,OAAO;AACT;AAEA,SAAgB,sBACd,aACA,UACA,mBACqB;CACrB,IAAI,OAAO;CAEX,IAAI,CAAC,mBACH,OAAO;CAGT,OAAO,KAAK,QAAQ,QAAQ,KAAK,KAAK,kBAAkB,IAAI,GAC1D,OAAO,KAAK,SAAS,EAAE,MAAM,EAAE,CAAC;CAGlC,IAAI,KAAK,QAAQ,QAAQ,KAAK,GAC5B,OAAO;CAGT,OAAO;AACT;AAEA,SAAgB,gBAAgB,GAAiB,GAA0B;CACzE,IAAI,MAAM,GACR,OAAO;CAGT,OACE,EAAE,SAAS,EAAE,QACb,EAAE,UAAU,EAAE,SACd,EAAE,WAAW,EAAE,UACf,EAAE,UAAU,EAAE;AAElB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
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/checkbox/useCheckboxGroupState.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted state, collection descriptors, 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 { FormValidationState } from "../form/create-form-validation-state.js";
|
|
18
|
+
import { HelpTextProps, InputBase, InputDOMProps, LabelableProps, Validation, ValidationResult, ValidationState, ValueBase } from "@solid2-aria/types-shared";
|
|
19
|
+
export interface CheckboxGroupProps extends ValueBase<string[]>, Pick<InputDOMProps, "name">, InputBase, LabelableProps, HelpTextProps, Validation<string[]> {}
|
|
20
|
+
export interface CheckboxGroupState extends FormValidationState {
|
|
21
|
+
/** Current selected values. */
|
|
22
|
+
readonly value: readonly string[];
|
|
23
|
+
/** Default selected values. */
|
|
24
|
+
readonly defaultValue: readonly string[];
|
|
25
|
+
/** Whether the checkbox group is disabled. */
|
|
26
|
+
readonly isDisabled: boolean;
|
|
27
|
+
/** Whether the checkbox group is read only. */
|
|
28
|
+
readonly isReadOnly: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The current validation state of the checkbox group.
|
|
31
|
+
*
|
|
32
|
+
* @deprecated Use `isInvalid` instead.
|
|
33
|
+
*/
|
|
34
|
+
readonly validationState: ValidationState | null;
|
|
35
|
+
/** Whether the checkbox group is invalid. */
|
|
36
|
+
readonly isInvalid: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the checkboxes in the group are required.
|
|
39
|
+
* This changes to false once at least one item is selected.
|
|
40
|
+
*/
|
|
41
|
+
readonly isRequired: boolean;
|
|
42
|
+
/** Returns whether the given value is selected. */
|
|
43
|
+
isSelected: (value: string) => boolean;
|
|
44
|
+
/** Sets the selected values. */
|
|
45
|
+
setValue: (value: string[]) => void;
|
|
46
|
+
/** Adds a value to the set of selected values. */
|
|
47
|
+
addValue: (value: string) => void;
|
|
48
|
+
/** Removes a value from the set of selected values. */
|
|
49
|
+
removeValue: (value: string) => void;
|
|
50
|
+
/** Toggles a value in the set of selected values. */
|
|
51
|
+
toggleValue: (value: string) => void;
|
|
52
|
+
/** Sets whether one of the checkboxes is invalid. */
|
|
53
|
+
setInvalid: (value: string, validation: ValidationResult) => void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Provides state management for a checkbox group component. Provides a name for the group,
|
|
57
|
+
* and manages selection and focus state.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createCheckboxGroupState(props?: CheckboxGroupProps): CheckboxGroupState;
|
|
60
|
+
//# sourceMappingURL=create-checkbox-group-state.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
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/checkbox/useCheckboxGroupState.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted state, collection descriptors, 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 { createControlledSignal } from "../utils/create-controlled-signal.js";
|
|
18
|
+
import { getLegacyValidationState } from "../utils/legacy-props.js";
|
|
19
|
+
import { createFormValidationState, mergeValidation } from "../form/create-form-validation-state.js";
|
|
20
|
+
import { merge, untrack } from "solid-js";
|
|
21
|
+
// src/checkbox/create-checkbox-group-state.ts
|
|
22
|
+
/**
|
|
23
|
+
* Provides state management for a checkbox group component. Provides a name for the group,
|
|
24
|
+
* and manages selection and focus state.
|
|
25
|
+
*/
|
|
26
|
+
function createCheckboxGroupState(props = {}) {
|
|
27
|
+
const [selectedValues, setValue] = createControlledSignal(() => props.value, untrack(() => props.defaultValue) ?? [], (v) => props.onChange?.(v));
|
|
28
|
+
const initialValues = untrack(selectedValues);
|
|
29
|
+
let invalidValues = /* @__PURE__ */ new Map();
|
|
30
|
+
const validation = createFormValidationState(merge(props, { get value() {
|
|
31
|
+
return selectedValues();
|
|
32
|
+
} }));
|
|
33
|
+
return merge(validation, {
|
|
34
|
+
addValue(value) {
|
|
35
|
+
if (props.isReadOnly === true || props.isDisabled === true) return;
|
|
36
|
+
setValue((localSelectedValues) => {
|
|
37
|
+
if (!localSelectedValues.includes(value)) return [...localSelectedValues, value];
|
|
38
|
+
return localSelectedValues;
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
get defaultValue() {
|
|
42
|
+
return props.defaultValue ?? initialValues;
|
|
43
|
+
},
|
|
44
|
+
get isDisabled() {
|
|
45
|
+
return props.isDisabled === true || false;
|
|
46
|
+
},
|
|
47
|
+
get isInvalid() {
|
|
48
|
+
return validation.displayValidation.isInvalid;
|
|
49
|
+
},
|
|
50
|
+
get isReadOnly() {
|
|
51
|
+
return props.isReadOnly === true || false;
|
|
52
|
+
},
|
|
53
|
+
get isRequired() {
|
|
54
|
+
return props.isRequired === true && selectedValues().length === 0;
|
|
55
|
+
},
|
|
56
|
+
isSelected(value) {
|
|
57
|
+
return selectedValues().includes(value);
|
|
58
|
+
},
|
|
59
|
+
removeValue(value) {
|
|
60
|
+
if (props.isReadOnly === true || props.isDisabled === true) return;
|
|
61
|
+
setValue((currentValues) => currentValues.includes(value) ? currentValues.filter((existingValue) => existingValue !== value) : currentValues);
|
|
62
|
+
},
|
|
63
|
+
setInvalid(value, v) {
|
|
64
|
+
const s = new Map(invalidValues);
|
|
65
|
+
if (v.isInvalid) s.set(value, v);
|
|
66
|
+
else s.delete(value);
|
|
67
|
+
invalidValues = s;
|
|
68
|
+
validation.updateValidation(mergeValidation(...s.values()));
|
|
69
|
+
},
|
|
70
|
+
setValue(value) {
|
|
71
|
+
if (props.isReadOnly === true || props.isDisabled === true) return;
|
|
72
|
+
setValue(value);
|
|
73
|
+
},
|
|
74
|
+
toggleValue(value) {
|
|
75
|
+
if (props.isReadOnly === true || props.isDisabled === true) return;
|
|
76
|
+
setValue((current) => current.includes(value) ? current.filter((v) => v !== value) : [...current, value]);
|
|
77
|
+
},
|
|
78
|
+
get validationState() {
|
|
79
|
+
return getLegacyValidationState(props) ?? (validation.displayValidation.isInvalid ? "invalid" : null);
|
|
80
|
+
},
|
|
81
|
+
get value() {
|
|
82
|
+
return selectedValues();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
export { createCheckboxGroupState };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=create-checkbox-group-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-checkbox-group-state.js","names":[],"sources":["../../src/checkbox/create-checkbox-group-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/checkbox/useCheckboxGroupState.ts.\n * Modified for Solid Aria: adapted state, collection descriptors, 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 {\n HelpTextProps,\n InputBase,\n InputDOMProps,\n LabelableProps,\n Validation,\n ValidationResult,\n ValidationState,\n ValueBase,\n} from \"@solid2-aria/types-shared\";\nimport { merge, untrack } from \"solid-js\";\n\nimport {\n mergeValidation,\n createFormValidationState,\n} from \"../form/create-form-validation-state\";\nimport type { FormValidationState } from \"../form/create-form-validation-state\";\nimport { createControlledSignal } from \"../utils/create-controlled-signal\";\nimport { getLegacyValidationState } from \"../utils/legacy-props\";\n\nexport interface CheckboxGroupProps\n extends\n ValueBase<string[]>,\n Pick<InputDOMProps, \"name\">,\n InputBase,\n LabelableProps,\n HelpTextProps,\n Validation<string[]> {}\n\nexport interface CheckboxGroupState extends FormValidationState {\n /** Current selected values. */\n readonly value: readonly string[];\n /** Default selected values. */\n readonly defaultValue: readonly string[];\n /** Whether the checkbox group is disabled. */\n readonly isDisabled: boolean;\n /** Whether the checkbox group is read only. */\n readonly isReadOnly: boolean;\n /**\n * The current validation state of the checkbox group.\n *\n * @deprecated Use `isInvalid` instead.\n */\n readonly validationState: ValidationState | null;\n /** Whether the checkbox group is invalid. */\n readonly isInvalid: boolean;\n /**\n * Whether the checkboxes in the group are required.\n * This changes to false once at least one item is selected.\n */\n readonly isRequired: boolean;\n /** Returns whether the given value is selected. */\n isSelected: (value: string) => boolean;\n /** Sets the selected values. */\n setValue: (value: string[]) => void;\n /** Adds a value to the set of selected values. */\n addValue: (value: string) => void;\n /** Removes a value from the set of selected values. */\n removeValue: (value: string) => void;\n /** Toggles a value in the set of selected values. */\n toggleValue: (value: string) => void;\n /** Sets whether one of the checkboxes is invalid. */\n setInvalid: (value: string, validation: ValidationResult) => void;\n}\n\n/**\n * Provides state management for a checkbox group component. Provides a name for the group,\n * and manages selection and focus state.\n */\nexport function createCheckboxGroupState(\n props: CheckboxGroupProps = {}\n): CheckboxGroupState {\n const [selectedValues, setValue] = createControlledSignal(\n () => props.value,\n untrack(() => props.defaultValue) ?? [],\n (v) => props.onChange?.(v)\n );\n\n const initialValues = untrack(selectedValues);\n let invalidValues = new Map<string, ValidationResult>();\n\n const validation = createFormValidationState(\n merge(props, {\n get value() {\n return selectedValues();\n },\n })\n );\n\n const state: CheckboxGroupState = merge(validation, {\n addValue(value: string) {\n if (props.isReadOnly === true || props.isDisabled === true) {\n return;\n }\n\n setValue((localSelectedValues) => {\n if (!localSelectedValues.includes(value)) {\n return [...localSelectedValues, value];\n }\n\n return localSelectedValues;\n });\n },\n get defaultValue() {\n return props.defaultValue ?? initialValues;\n },\n get isDisabled() {\n return props.isDisabled === true || false;\n },\n get isInvalid() {\n return validation.displayValidation.isInvalid;\n },\n get isReadOnly() {\n return props.isReadOnly === true || false;\n },\n get isRequired() {\n return props.isRequired === true && selectedValues().length === 0;\n },\n isSelected(value: string) {\n return selectedValues().includes(value);\n },\n removeValue(value: string) {\n if (props.isReadOnly === true || props.isDisabled === true) {\n return;\n }\n\n setValue((currentValues) =>\n currentValues.includes(value)\n ? currentValues.filter((existingValue) => existingValue !== value)\n : currentValues\n );\n },\n setInvalid(value: string, v: ValidationResult) {\n const s = new Map(invalidValues);\n\n if (v.isInvalid) {\n s.set(value, v);\n } else {\n s.delete(value);\n }\n\n invalidValues = s;\n validation.updateValidation(mergeValidation(...s.values()));\n },\n setValue(value: string[]) {\n if (props.isReadOnly === true || props.isDisabled === true) {\n return;\n }\n\n setValue(value);\n },\n toggleValue(value: string) {\n if (props.isReadOnly === true || props.isDisabled === true) {\n return;\n }\n\n setValue((current) =>\n current.includes(value)\n ? current.filter((v) => v !== value)\n : [...current, value]\n );\n },\n get validationState() {\n return (\n getLegacyValidationState(props) ??\n (validation.displayValidation.isInvalid ? \"invalid\" : null)\n );\n },\n get value() {\n return selectedValues();\n },\n });\n\n return state;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,SAAgB,yBACd,QAA4B,CAAC,GACT;CACpB,MAAM,CAAC,gBAAgB,YAAY,6BAC3B,MAAM,OACZ,cAAc,MAAM,YAAY,KAAK,CAAC,IACrC,MAAM,MAAM,WAAW,CAAC,CAC3B;CAEA,MAAM,gBAAgB,QAAQ,cAAc;CAC5C,IA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U,YACR,QAAQ,SAAS,KAAK,IAClB,QAAQ,QAAQ,MAAM,MAAM,KAAK,IACjC,CAAC,GAAG,SAAS,KAAK,CACxB;EACF;EACA,IAAI,kBAAkB;GACpB,OACE,yBAAyB,KAAK,MAC7B,WAAW,kBAAkB,YAAY,YAAY;EAE1D;EACA,IAAI,QAAQ;GACV,OAAO,eAAe;EACxB;CACF,CAEW;AACb"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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/collections/CollectionBuilder.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted state, collection descriptors, 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 { CollectionContext } from "./types.js";
|
|
18
|
+
import { CollectionBase, Node } from "@solid2-aria/types-shared";
|
|
19
|
+
export declare class CollectionBuilder<T extends object> {
|
|
20
|
+
private context?;
|
|
21
|
+
private readonly cache;
|
|
22
|
+
build(props: Partial<CollectionBase<T>>, context?: CollectionContext): Iterable<Node<T>>;
|
|
23
|
+
private iterateCollection;
|
|
24
|
+
private static getKey;
|
|
25
|
+
private static getChildState;
|
|
26
|
+
private getFullNode;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=collection-builder.d.ts.map
|
|
@@ -0,0 +1,164 @@
|
|
|
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/collections/CollectionBuilder.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted state, collection descriptors, 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 { hasContent } from "../utils/has-content.js";
|
|
18
|
+
import { collectionChildren, isCollectionElement } from "./types.js";
|
|
19
|
+
import { untrack } from "solid-js";
|
|
20
|
+
// src/collections/collection-builder.ts
|
|
21
|
+
var CollectionBuilder = class CollectionBuilder {
|
|
22
|
+
context;
|
|
23
|
+
cache = /* @__PURE__ */ new WeakMap();
|
|
24
|
+
build(props, context) {
|
|
25
|
+
this.context = context;
|
|
26
|
+
return iterable(() => this.iterateCollection(props));
|
|
27
|
+
}
|
|
28
|
+
*iterateCollection(props) {
|
|
29
|
+
const { children, items } = untrack(() => props);
|
|
30
|
+
if (typeof children === "function") {
|
|
31
|
+
if (!items) throw new Error("props.children was a function but props.items is missing");
|
|
32
|
+
let index = 0;
|
|
33
|
+
for (const item of items) {
|
|
34
|
+
yield* this.getFullNode({
|
|
35
|
+
index,
|
|
36
|
+
value: item
|
|
37
|
+
}, { renderer: children });
|
|
38
|
+
index += 1;
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
const localItems = collectionChildren(children);
|
|
42
|
+
let index = 0;
|
|
43
|
+
for (const item of localItems) {
|
|
44
|
+
const nodes = this.getFullNode({
|
|
45
|
+
element: item,
|
|
46
|
+
index
|
|
47
|
+
}, {});
|
|
48
|
+
for (const node of nodes) {
|
|
49
|
+
index += 1;
|
|
50
|
+
yield node;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
static getKey(item, partialNode, state, parentKey) {
|
|
56
|
+
if (item.key !== null && item.key !== void 0) return item.key;
|
|
57
|
+
if (partialNode.type === "cell" && partialNode.key !== null && partialNode.key !== void 0) return `${parentKey}${partialNode.key}`;
|
|
58
|
+
const v = partialNode.value;
|
|
59
|
+
if (v !== null && v !== void 0) {
|
|
60
|
+
const key = ("key" in v ? v.key : void 0) ?? ("id" in v ? v.id : void 0);
|
|
61
|
+
if (typeof key !== "string" && typeof key !== "number") throw new TypeError("No key found for item");
|
|
62
|
+
return key;
|
|
63
|
+
}
|
|
64
|
+
return parentKey !== null && parentKey !== void 0 ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;
|
|
65
|
+
}
|
|
66
|
+
static getChildState(state, partialNode) {
|
|
67
|
+
return { renderer: partialNode.renderer ?? state.renderer };
|
|
68
|
+
}
|
|
69
|
+
*getFullNode(partialNode, state, parentKey, parentNode) {
|
|
70
|
+
let { element } = partialNode;
|
|
71
|
+
if (!hasContent(element) && partialNode.value !== void 0 && state.renderer) {
|
|
72
|
+
const cached = this.cache.get(partialNode.value);
|
|
73
|
+
if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {
|
|
74
|
+
cached.index = partialNode.index;
|
|
75
|
+
cached.parentKey = parentNode ? parentNode.key : null;
|
|
76
|
+
yield cached;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
element = state.renderer(partialNode.value);
|
|
80
|
+
}
|
|
81
|
+
if (isCollectionElement(element)) {
|
|
82
|
+
const childNodes = element.getCollectionNode(this.context);
|
|
83
|
+
let index = partialNode.index ?? 0;
|
|
84
|
+
let result = childNodes.next();
|
|
85
|
+
while (!(result.done === true) && Boolean(result.value)) {
|
|
86
|
+
const childNode = result.value;
|
|
87
|
+
partialNode.index = index;
|
|
88
|
+
let nodeKey = childNode.key ?? null;
|
|
89
|
+
nodeKey ??= hasContent(childNode.element) ? null : CollectionBuilder.getKey(element, partialNode, state, parentKey);
|
|
90
|
+
const children = [...this.getFullNode({
|
|
91
|
+
...childNode,
|
|
92
|
+
index,
|
|
93
|
+
key: nodeKey,
|
|
94
|
+
wrapper: compose(partialNode.wrapper, childNode.wrapper)
|
|
95
|
+
}, CollectionBuilder.getChildState(state, childNode), parentKey !== null && parentKey !== void 0 ? `${parentKey}${element.key ?? ""}` : element.key, parentNode)];
|
|
96
|
+
for (const node of children) {
|
|
97
|
+
node.value = childNode.value ?? partialNode.value ?? null;
|
|
98
|
+
if (node.value) this.cache.set(node.value, node);
|
|
99
|
+
if (partialNode.type !== void 0 && partialNode.type !== "" && node.type !== partialNode.type) throw new Error(`Unsupported type <${capitalize(node.type)}> in <${capitalize(parentNode?.type ?? "unknown parent type")}>. Only <${capitalize(partialNode.type)}> is supported.`);
|
|
100
|
+
index += 1;
|
|
101
|
+
yield node;
|
|
102
|
+
}
|
|
103
|
+
result = childNodes.next(children);
|
|
104
|
+
}
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (partialNode.key === null || partialNode.key === void 0 || partialNode.type === null || partialNode.type === void 0) return;
|
|
108
|
+
const buildChild = this.getFullNode.bind(this);
|
|
109
|
+
const node = {
|
|
110
|
+
"aria-label": partialNode["aria-label"],
|
|
111
|
+
childNodes: iterable(function* childNodes() {
|
|
112
|
+
if (!(partialNode.hasChildNodes === true) || !partialNode.childNodes) return;
|
|
113
|
+
let index = 0;
|
|
114
|
+
for (const child of partialNode.childNodes()) {
|
|
115
|
+
if (child.key !== null && child.key !== void 0) child.key = `${node.key}${child.key}`;
|
|
116
|
+
const nodes = buildChild({
|
|
117
|
+
...child,
|
|
118
|
+
index
|
|
119
|
+
}, CollectionBuilder.getChildState(state, child), node.key, node);
|
|
120
|
+
for (const localNode of nodes) {
|
|
121
|
+
index += 1;
|
|
122
|
+
yield localNode;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}),
|
|
126
|
+
hasChildNodes: partialNode.hasChildNodes === true || false,
|
|
127
|
+
index: partialNode.index,
|
|
128
|
+
key: partialNode.key,
|
|
129
|
+
level: (parentNode?.level ?? 0) + (parentNode?.type === "item" ? 1 : 0),
|
|
130
|
+
parentKey: parentNode ? parentNode.key : null,
|
|
131
|
+
props: partialNode.props,
|
|
132
|
+
rendered: partialNode.rendered,
|
|
133
|
+
shouldInvalidate: partialNode.shouldInvalidate,
|
|
134
|
+
textValue: partialNode.textValue ?? "",
|
|
135
|
+
type: partialNode.type,
|
|
136
|
+
value: partialNode.value ?? null,
|
|
137
|
+
wrapper: partialNode.wrapper
|
|
138
|
+
};
|
|
139
|
+
yield node;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
function iterable(iterator) {
|
|
143
|
+
const cache = [];
|
|
144
|
+
let localIterable = null;
|
|
145
|
+
return { *[Symbol.iterator]() {
|
|
146
|
+
for (const item of cache) yield item;
|
|
147
|
+
localIterable ??= iterator();
|
|
148
|
+
for (const item of localIterable) {
|
|
149
|
+
cache.push(item);
|
|
150
|
+
yield item;
|
|
151
|
+
}
|
|
152
|
+
} };
|
|
153
|
+
}
|
|
154
|
+
function compose(outer, inner) {
|
|
155
|
+
if (outer && inner) return (element) => outer(inner(element));
|
|
156
|
+
if (outer) return outer;
|
|
157
|
+
if (inner) return inner;
|
|
158
|
+
}
|
|
159
|
+
function capitalize(str) {
|
|
160
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
161
|
+
}
|
|
162
|
+
export { CollectionBuilder };
|
|
163
|
+
|
|
164
|
+
//# sourceMappingURL=collection-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-builder.js","names":[],"sources":["../../src/collections/collection-builder.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/collections/CollectionBuilder.ts.\n * Modified for Solid Aria: adapted state, collection descriptors, 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 { CollectionBase, Key, Node } from \"@solid2-aria/types-shared\";\nimport { untrack } from \"solid-js\";\nimport type { Element as SolidElement } from \"solid-js\";\n\nimport { hasContent } from \"../utils/has-content\";\nimport type {\n CollectionContext,\n PartialNode,\n CollectionElement,\n} from \"./types\";\nimport { collectionChildren, isCollectionElement } from \"./types\";\n\ninterface CollectionBuilderState<T> {\n renderer?: (value: T) => SolidElement | null;\n}\n\nexport class CollectionBuilder<T extends object> {\n private context?: CollectionContext;\n private readonly cache = new WeakMap<T, Node<T>>();\n build(\n props: Partial<CollectionBase<T>>,\n context?: CollectionContext\n ): Iterable<Node<T>> {\n this.context = context;\n\n return iterable(() => this.iterateCollection(props));\n }\n private *iterateCollection(\n props: Partial<CollectionBase<T>>\n ): Generator<Node<T>> {\n const { children, items } = untrack(() => props);\n\n if (typeof children === \"function\") {\n if (!items) {\n throw new Error(\n \"props.children was a function but props.items is missing\"\n );\n }\n\n let index = 0;\n\n for (const item of items) {\n yield* this.getFullNode(\n {\n index,\n value: item,\n },\n { renderer: children }\n );\n index += 1;\n }\n } else {\n const localItems = collectionChildren(children);\n let index = 0;\n\n for (const item of localItems) {\n const nodes = this.getFullNode(\n {\n element: item,\n index,\n },\n {}\n );\n\n for (const node of nodes) {\n index += 1;\n yield node;\n }\n }\n }\n }\n private static getKey<T extends object>(\n item: CollectionElement<T>,\n partialNode: PartialNode<T>,\n state: CollectionBuilderState<T>,\n parentKey?: Key | null\n ): Key {\n if (item.key !== null && item.key !== undefined) {\n return item.key;\n }\n\n if (\n partialNode.type === \"cell\" &&\n partialNode.key !== null &&\n partialNode.key !== undefined\n ) {\n return `${parentKey}${partialNode.key}`;\n }\n\n const v = partialNode.value;\n\n if (v !== null && v !== undefined) {\n const key =\n (\"key\" in v ? v.key : undefined) ?? (\"id\" in v ? v.id : undefined);\n\n if (typeof key !== \"string\" && typeof key !== \"number\") {\n throw new TypeError(\"No key found for item\");\n }\n\n return key;\n }\n\n return parentKey !== null && parentKey !== undefined\n ? `${parentKey}.${partialNode.index}`\n : `$.${partialNode.index}`;\n }\n private static getChildState<T>(\n state: CollectionBuilderState<T>,\n partialNode: PartialNode<T>\n ) {\n return {\n renderer: partialNode.renderer ?? state.renderer,\n };\n }\n // oxlint-disable-next-line eslint/complexity -- Retain the upstream recursive generator protocol and its node caching together.\n private *getFullNode(\n partialNode: PartialNode<T> & {\n index: number;\n },\n state: CollectionBuilderState<T>,\n parentKey?: Key | null,\n parentNode?: Node<T>\n ): Generator<Node<T>> {\n // If there's a value instead of an element on the node, and a parent renderer function is available,\n // use it to render an element for the value.\n let { element } = partialNode;\n\n if (\n !hasContent(element) &&\n partialNode.value !== undefined &&\n state.renderer\n ) {\n const cached = this.cache.get(partialNode.value);\n\n if (\n cached &&\n (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))\n ) {\n cached.index = partialNode.index;\n cached.parentKey = parentNode ? parentNode.key : null;\n yield cached;\n\n return;\n }\n\n element = state.renderer(partialNode.value);\n }\n\n // If there's an element with a getCollectionNode function on its type, then it's a supported component.\n // Call this function to get a partial node, and recursively build a full node from there.\n if (isCollectionElement<T>(element)) {\n const childNodes = element.getCollectionNode(this.context);\n let index = partialNode.index ?? 0;\n let result = childNodes.next();\n\n while (!(result.done === true) && Boolean(result.value)) {\n const childNode = result.value;\n partialNode.index = index;\n let nodeKey = childNode.key ?? null;\n\n nodeKey ??= hasContent(childNode.element)\n ? null\n : CollectionBuilder.getKey(element, partialNode, state, parentKey);\n\n const nodes = this.getFullNode(\n {\n ...childNode,\n index,\n key: nodeKey,\n wrapper: compose(partialNode.wrapper, childNode.wrapper),\n },\n CollectionBuilder.getChildState(state, childNode),\n parentKey !== null && parentKey !== undefined\n ? `${parentKey}${element.key ?? \"\"}`\n : element.key,\n parentNode\n );\n\n const children = [...nodes];\n\n for (const node of children) {\n // Cache the node based on its value\n node.value = childNode.value ?? partialNode.value ?? null;\n\n if (node.value) {\n this.cache.set(node.value, node);\n }\n\n // The partial node may have specified a type for the child in order to specify a constraint.\n // Verify that the full node that was built recursively matches this type.\n if (\n partialNode.type !== undefined &&\n partialNode.type !== \"\" &&\n node.type !== partialNode.type\n ) {\n throw new Error(\n `Unsupported type <${capitalize(node.type)}> in <${capitalize(parentNode?.type ?? \"unknown parent type\")}>. Only <${capitalize(partialNode.type)}> is supported.`\n );\n }\n\n index += 1;\n yield node;\n }\n\n result = childNodes.next(children);\n }\n\n return;\n }\n\n // Ignore invalid elements\n if (\n partialNode.key === null ||\n partialNode.key === undefined ||\n partialNode.type === null ||\n partialNode.type === undefined\n ) {\n return;\n }\n\n // Create full node\n const buildChild = this.getFullNode.bind(this);\n\n const node: Node<T> = {\n \"aria-label\": partialNode[\"aria-label\"],\n // oxlint-disable-next-line typescript/no-deprecated -- Preserve and test the upstream compatibility API.\n childNodes: iterable(function* childNodes() {\n if (!(partialNode.hasChildNodes === true) || !partialNode.childNodes) {\n return;\n }\n\n let index = 0;\n\n for (const child of partialNode.childNodes()) {\n // Ensure child keys are globally unique by prepending the parent node's key\n if (child.key !== null && child.key !== undefined) {\n // Upstream plans to remove this line and enforce that users always provide unique keys.\n // Currently this line will have issues when a parent has a key `a` and a child with key `bc`\n // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both\n // children having a key of `abc`.\n child.key = `${node.key}${child.key}`;\n }\n\n const nodes = buildChild(\n { ...child, index },\n CollectionBuilder.getChildState(state, child),\n node.key,\n node\n );\n\n for (const localNode of nodes) {\n index += 1;\n yield localNode;\n }\n }\n }),\n hasChildNodes: partialNode.hasChildNodes === true || false,\n index: partialNode.index,\n key: partialNode.key,\n level: (parentNode?.level ?? 0) + (parentNode?.type === \"item\" ? 1 : 0),\n parentKey: parentNode ? parentNode.key : null,\n props: partialNode.props,\n rendered: partialNode.rendered,\n shouldInvalidate: partialNode.shouldInvalidate,\n textValue: partialNode.textValue ?? \"\",\n type: partialNode.type,\n value: partialNode.value ?? null,\n wrapper: partialNode.wrapper,\n };\n\n yield node;\n }\n}\n\n// Wraps an iterator function as an iterable object, and caches the results.\nfunction iterable<T>(\n iterator: () => IterableIterator<Node<T>>\n): Iterable<Node<T>> {\n const cache: Node<T>[] = [];\n let localIterable: null | IterableIterator<Node<T>> = null;\n\n return {\n *[Symbol.iterator]() {\n for (const item of cache) {\n yield item;\n }\n\n localIterable ??= iterator();\n\n for (const item of localIterable) {\n cache.push(item);\n yield item;\n }\n },\n };\n}\n\ntype Wrapper = (element: SolidElement) => SolidElement;\n\nfunction compose(\n outer: Wrapper | undefined,\n inner: Wrapper | undefined\n): Wrapper | undefined {\n if (outer && inner) {\n return (element) => outer(inner(element));\n }\n\n if (outer) {\n return outer;\n }\n\n if (inner) {\n return inner;\n }\n\n return undefined;\n}\n\nfunction capitalize(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCA,IAAa,oBAAb,MAAa,kBAAoC;CAC/C;CACA,wBAAyB,IAAI,QAAoB;CACjD,MACE,OACA,SACmB;EACnB,KAAK,UA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AS;EAE3B,KAAK,MAAM,QAAQ,eAAe;GAChC,MAAM,KAAK,IAAI;GACf,MAAM;EACR;CACF,EACF;AACF;AAIA,SAAS,QACP,OACA,OACqB;CACrB,IAAI,SAAS,OACX,QAAQ,YAAY,MAAM,MAAM,OAAO,CAAC;CAG1C,IAAI,OACF,OAAO;CAGT,IAAI,OACF,OAAO;AAIX;AAEA,SAAS,WAAW,KAAa;CAC/B,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,IAAI,MAAM,CAAC;AAClD"}
|
|
@@ -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/collections/useCollection.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted state, collection descriptors, 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 { CollectionContext } from "./types.js";
|
|
18
|
+
import { Accessor } from "solid-js";
|
|
19
|
+
import { Collection, CollectionStateBase, Node } from "@solid2-aria/types-shared";
|
|
20
|
+
export type CollectionOptions<T, C extends Collection<Node<T>>> = CollectionStateBase<T, C>;
|
|
21
|
+
export type CollectionFactory<T, C extends Collection<Node<T>>> = (nodes: Iterable<Node<T>>) => C;
|
|
22
|
+
/** Returns an accessor so collection replacement remains reactive. */
|
|
23
|
+
export declare function createCollection<T extends object, C extends Collection<Node<T>> = Collection<Node<T>>>(props: CollectionOptions<T, C>, factory: CollectionFactory<T, C>, context?: CollectionContext): Accessor<C>;
|
|
24
|
+
//# sourceMappingURL=create-collection.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
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/collections/useCollection.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted state, collection descriptors, 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 { CollectionBuilder } from "./collection-builder.js";
|
|
18
|
+
import { createMemo } from "solid-js";
|
|
19
|
+
// src/collections/create-collection.ts
|
|
20
|
+
function isContextProvider(context) {
|
|
21
|
+
return typeof context === "function";
|
|
22
|
+
}
|
|
23
|
+
/** Returns an accessor so collection replacement remains reactive. */
|
|
24
|
+
function createCollection(props, factory, context) {
|
|
25
|
+
return createMemo(() => {
|
|
26
|
+
if (props.collection) return props.collection;
|
|
27
|
+
return factory(new CollectionBuilder().build({
|
|
28
|
+
children: props.children,
|
|
29
|
+
items: props.items
|
|
30
|
+
}, isContextProvider(context) ? context() : context));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export { createCollection };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=create-collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-collection.js","names":[],"sources":["../../src/collections/create-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/collections/useCollection.ts.\n * Modified for Solid Aria: adapted state, collection descriptors, 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 {\n Collection,\n CollectionStateBase,\n Node,\n} from \"@solid2-aria/types-shared\";\nimport { createMemo } from \"solid-js\";\nimport type { Accessor } from \"solid-js\";\n\nimport { CollectionBuilder } from \"./collection-builder\";\nimport type { CollectionContext } from \"./types\";\n\nexport type CollectionOptions<\n T,\n C extends Collection<Node<T>>,\n> = CollectionStateBase<T, C>;\n\nexport type CollectionFactory<T, C extends Collection<Node<T>>> = (\n nodes: Iterable<Node<T>>\n) => C;\n\nfunction isContextProvider(\n context: CollectionContext\n): context is Accessor<CollectionContext> {\n return typeof context === \"function\";\n}\n\n/** Returns an accessor so collection replacement remains reactive. */\nexport function createCollection<\n T extends object,\n C extends Collection<Node<T>> = Collection<Node<T>>,\n>(\n props: CollectionOptions<T, C>,\n factory: CollectionFactory<T, C>,\n context?: CollectionContext\n): Accessor<C> {\n return createMemo(() => {\n if (props.collection) {\n return props.collection;\n }\n\n // Each snapshot owns its lazy iterators and cache. Retained snapshots never observe a later build.\n const builder = new CollectionBuilder<T>();\n\n return factory(\n builder.build(\n { children: props.children, items: props.items },\n isContextProvider(context) ? context() : context\n )\n );\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,SAAS,kBACP,SACwC;CACxC,OAAO,OAAO,YAAY;AAC5B;;AAGA,SAAgB,iBAId,OACA,SACA,SACa;CACb,OAAO,iBAAiB;EACtB,IAAI,MAAM,YACR,OAAO,MAAM;EAMf,OAAO,QACL,IAHkB,kBAGZ,CAAC,CAAC,MACN;GAAE,UAAU,MAAM;GAAU,OAAO,MAAM;EAAM,GAC/C,kBAAkB,OAAO,IAAI,QAAQ,IAAI,OAC3C,CACF;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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/collections/getChildNodes.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted state, collection descriptors, 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, Node } from "@solid2-aria/types-shared";
|
|
18
|
+
/** Reads children while constructing node-backed collections, before a collection delegate exists. */
|
|
19
|
+
export declare function getNodeChildren<T>(node: Pick<Node<T>, "childNodes">): Iterable<Node<T>>;
|
|
20
|
+
export declare function getChildNodes<T>(node: Node<T>, collection: Collection<Node<T>>): Iterable<Node<T>>;
|
|
21
|
+
export declare function getFirstItem<T>(iterable: Iterable<T>): T | undefined;
|
|
22
|
+
export declare function getNthItem<T>(iterable: Iterable<T>, index: number): T | undefined;
|
|
23
|
+
export declare function getLastItem<T>(iterable: Iterable<T>): T | undefined;
|
|
24
|
+
export declare function compareNodeOrder<T>(collection: Collection<Node<T>>, a: Node<T>, b: Node<T>): number;
|
|
25
|
+
//# sourceMappingURL=get-child-nodes.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
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/collections/getChildNodes.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted state, collection descriptors, 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
|
+
// src/collections/get-child-nodes.ts
|
|
18
|
+
/** Reads children while constructing node-backed collections, before a collection delegate exists. */
|
|
19
|
+
function getNodeChildren(node) {
|
|
20
|
+
return node.childNodes;
|
|
21
|
+
}
|
|
22
|
+
function getChildNodes(node, collection) {
|
|
23
|
+
if (typeof collection.getChildren === "function") return collection.getChildren(node.key);
|
|
24
|
+
return getNodeChildren(node);
|
|
25
|
+
}
|
|
26
|
+
function getFirstItem(iterable) {
|
|
27
|
+
return getNthItem(iterable, 0);
|
|
28
|
+
}
|
|
29
|
+
function getNthItem(iterable, index) {
|
|
30
|
+
if (index < 0) return;
|
|
31
|
+
let i = 0;
|
|
32
|
+
for (const item of iterable) {
|
|
33
|
+
if (i === index) return item;
|
|
34
|
+
i += 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function getLastItem(iterable) {
|
|
38
|
+
let lastItem = void 0;
|
|
39
|
+
for (const value of iterable) lastItem = value;
|
|
40
|
+
return lastItem;
|
|
41
|
+
}
|
|
42
|
+
function compareNodeOrder(collection, a, b) {
|
|
43
|
+
if (a.parentKey === b.parentKey) return a.index - b.index;
|
|
44
|
+
const aAncestors = [...getAncestors(collection, a), a];
|
|
45
|
+
const bAncestors = [...getAncestors(collection, b), b];
|
|
46
|
+
const firstNonMatchingAncestor = aAncestors.slice(0, bAncestors.length).findIndex((localA, i) => localA !== bAncestors[i]);
|
|
47
|
+
if (firstNonMatchingAncestor !== -1) {
|
|
48
|
+
const left = aAncestors[firstNonMatchingAncestor];
|
|
49
|
+
const right = bAncestors[firstNonMatchingAncestor];
|
|
50
|
+
if (left && right) return left.index - right.index;
|
|
51
|
+
}
|
|
52
|
+
if (aAncestors.includes(b)) return 1;
|
|
53
|
+
else if (bAncestors.includes(a)) return -1;
|
|
54
|
+
return -1;
|
|
55
|
+
}
|
|
56
|
+
function getAncestors(collection, node) {
|
|
57
|
+
const parents = [];
|
|
58
|
+
let currNode = node;
|
|
59
|
+
while (currNode && currNode.parentKey !== null && currNode.parentKey !== void 0) {
|
|
60
|
+
currNode = collection.getItem(currNode.parentKey);
|
|
61
|
+
if (currNode) parents.unshift(currNode);
|
|
62
|
+
}
|
|
63
|
+
return parents;
|
|
64
|
+
}
|
|
65
|
+
export { compareNodeOrder, getChildNodes, getFirstItem, getLastItem, getNodeChildren, getNthItem };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=get-child-nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-child-nodes.js","names":[],"sources":["../../src/collections/get-child-nodes.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/collections/getChildNodes.ts.\n * Modified for Solid Aria: adapted state, collection descriptors, 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, Node } from \"@solid2-aria/types-shared\";\n\n/** Reads children while constructing node-backed collections, before a collection delegate exists. */\nexport function getNodeChildren<T>(\n node: Pick<Node<T>, \"childNodes\">\n): Iterable<Node<T>> {\n // oxlint-disable-next-line typescript/no-deprecated -- Node-backed builders still receive upstream childNodes; isolate this compatibility read here.\n return node.childNodes;\n}\n\nexport function getChildNodes<T>(\n node: Node<T>,\n collection: Collection<Node<T>>\n): Iterable<Node<T>> {\n // New API: call collection.getChildren with the node key.\n if (typeof collection.getChildren === \"function\") {\n return collection.getChildren(node.key);\n }\n\n return getNodeChildren(node);\n}\n\nexport function getFirstItem<T>(iterable: Iterable<T>): T | undefined {\n return getNthItem(iterable, 0);\n}\n\nexport function getNthItem<T>(\n iterable: Iterable<T>,\n index: number\n): T | undefined {\n if (index < 0) {\n return undefined;\n }\n\n let i = 0;\n\n for (const item of iterable) {\n if (i === index) {\n return item;\n }\n\n i += 1;\n }\n\n return undefined;\n}\n\nexport function getLastItem<T>(iterable: Iterable<T>): T | undefined {\n let lastItem: T | undefined = undefined;\n\n for (const value of iterable) {\n lastItem = value;\n }\n\n return lastItem;\n}\n\nexport function compareNodeOrder<T>(\n collection: Collection<Node<T>>,\n a: Node<T>,\n b: Node<T>\n): number {\n // If the two nodes have the same parent, compare their indices.\n if (a.parentKey === b.parentKey) {\n return a.index - b.index;\n }\n\n // Otherwise, collect all of the ancestors from each node, and find the first one that doesn't match starting from the root.\n // Include the base nodes in case we are comparing nodes of different levels so that we can compare the higher node to the lower level node's\n // ancestor of the same level\n const aAncestors = [...getAncestors(collection, a), a];\n const bAncestors = [...getAncestors(collection, b), b];\n\n const firstNonMatchingAncestor = aAncestors\n .slice(0, bAncestors.length)\n .findIndex((localA, i) => localA !== bAncestors[i]);\n\n if (firstNonMatchingAncestor !== -1) {\n // Compare the indices of two children within the common ancestor.\n const left = aAncestors[firstNonMatchingAncestor];\n const right = bAncestors[firstNonMatchingAncestor];\n\n if (left && right) {\n return left.index - right.index;\n }\n }\n\n // If there isn't a non matching ancestor, we might be in a case where one of the nodes is the ancestor of the other.\n if (aAncestors.includes(b)) {\n return 1;\n } else if (bAncestors.includes(a)) {\n return -1;\n }\n\n // 🤷\n return -1;\n}\n\nfunction getAncestors<T>(\n collection: Collection<Node<T>>,\n node: Node<T>\n): Node<T>[] {\n const parents: Node<T>[] = [];\n let currNode: Node<T> | null = node;\n\n while (\n currNode &&\n currNode.parentKey !== null &&\n currNode.parentKey !== undefined\n ) {\n currNode = collection.getItem(currNode.parentKey);\n\n if (currNode) {\n parents.unshift(currNode);\n }\n }\n\n return parents;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,SAAgB,gBACd,MACmB;CAEnB,OAAO,KAAK;AACd;AAEA,SAAgB,cACd,MACA,YACmB;CAEnB,IAAI,OAAO,WAAW,gBAAgB,YACpC,OAAO,WAAW,YAAY,KAAK,GAAG;CAGxC,OAAO,gBAAgB,IAAI;AAC7B;AAEA,SAAgB,aAAgB,UAAsC;CACpE,OAAO,WAAW,UAAU,CAAC;AAC/B;AAEA,SAAgB,WACd,UACA,OACe;CACf,IAAI,QAAQ,GACV;CAGF,IAAI,IAAI;CAER,KAAK,MAAM,QAAQ,UAAU;EAC3B,IAAI,MAAM,OACR,OAAO;EAGT,KAAK;CACP;AAGF;AAEA,SAAgB,YAAe,UAAsC;CACnE,IAAI,WAA0B,KAAA;CAE9B,KAAK,MAAM,SAAS,UAClB,WAAW;CAGb,OAAO;AACT;AAEA,SAAgB,iBACd,YACA,GACA,GACQ;CAER,IAAI,EAAE,cAAc,EAAE,WACpB,OAAO,EAAE,QAAQ,EAAE;CAMrB,MAAM,aAAa,CAAC,GAAG,aAAa,YAAY,CAAC,GAAG,CAAC;CACrD,MAAM,aAAa,CAAC,GAAG,aAAa,YAAY,CAAC,GAAG,CAAC;CAErD,MAAM,2BAA2B,WAC9B,MAAM,GAAG,WAAW,MAAM,CAAC,CAC3B,WAAW,QAAQ,MAAM,WAAW,WAAW,EAAE;CAEpD,IAAI,6BAA6B,IAAI;EAEnC,MAAM,OAAO,WAAW;EACxB,MAAM,QAAQ,WAAW;EAEzB,IAAI,QAAQ,OACV,OAAO,KAAK,QAAQ,MAAM;CAE9B;CAGA,IAAI,WAAW,SAAS,CAAC,GACvB,OAAO;MACF,IAAI,WAAW,SAAS,CAAC,GAC9B,OAAO;CAIT,OAAO;AACT;AAEA,SAAS,aACP,YACA,MACW;CACX,MAAM,UAAqB,CAAC;CAC5B,IAAI,WAA2B;CAE/B,OACE,YACA,SAAS,cAAc,QACvB,SAAS,cAAc,KAAA,GACvB;EACA,WAAW,WAAW,QAAQ,SAAS,SAAS;EAEhD,IAAI,UACF,QAAQ,QAAQ,QAAQ;CAE5B;CAEA,OAAO;AACT"}
|
|
@@ -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/collections/getItemCount.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted state, collection descriptors, 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, Node } from "@solid2-aria/types-shared";
|
|
18
|
+
export declare function getItemCount<T>(collection: Collection<Node<T>>): number;
|
|
19
|
+
//# sourceMappingURL=get-item-count.d.ts.map
|