@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,274 @@
|
|
|
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/table/TableCollection.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 { getFirstItem, getLastItem, getNodeChildren } from "../collections/get-child-nodes.js";
|
|
18
|
+
import { getNodeProps } from "../utils/get-node-props.js";
|
|
19
|
+
import { requireValue } from "../utils/require-value.js";
|
|
20
|
+
import { GridCollection, setColumnSpan } from "../grid/grid-collection.js";
|
|
21
|
+
// src/table/table-collection.ts
|
|
22
|
+
const ROW_HEADER_COLUMN_KEY = `row-header-column-${Math.random().toString(36).slice(2)}`;
|
|
23
|
+
let ROW_HEADER_COLUMN_KEY_DRAG = `row-header-column-${Math.random().toString(36).slice(2)}`;
|
|
24
|
+
while (ROW_HEADER_COLUMN_KEY === ROW_HEADER_COLUMN_KEY_DRAG) ROW_HEADER_COLUMN_KEY_DRAG = `row-header-column-${Math.random().toString(36).slice(2)}`;
|
|
25
|
+
/** @private */
|
|
26
|
+
function buildHeaderRows(keyMap, columnNodes) {
|
|
27
|
+
const columns = [];
|
|
28
|
+
const seen = /* @__PURE__ */ new Map();
|
|
29
|
+
for (const column of columnNodes) {
|
|
30
|
+
let { parentKey } = column;
|
|
31
|
+
const col = [column];
|
|
32
|
+
while (parentKey !== null && parentKey !== void 0) {
|
|
33
|
+
const parent = keyMap.get(parentKey);
|
|
34
|
+
if (!parent) break;
|
|
35
|
+
const seenParent = seen.get(parent);
|
|
36
|
+
if (seenParent) {
|
|
37
|
+
setColumnSpan(parent, (parent.colSpan ?? 0) + 1);
|
|
38
|
+
const { column: localColumn, index } = seenParent;
|
|
39
|
+
if (index > col.length) break;
|
|
40
|
+
for (let i = index; i < col.length; i += 1) localColumn.splice(i, 0, null);
|
|
41
|
+
for (let i = col.length; i < localColumn.length; i += 1) {
|
|
42
|
+
const shifted = localColumn[i];
|
|
43
|
+
const shiftedEntry = shifted ? seen.get(shifted) : void 0;
|
|
44
|
+
if (shiftedEntry) shiftedEntry.index = i;
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
setColumnSpan(parent, 1);
|
|
48
|
+
col.push(parent);
|
|
49
|
+
seen.set(parent, {
|
|
50
|
+
column: col,
|
|
51
|
+
index: col.length - 1
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
({parentKey} = parent);
|
|
55
|
+
}
|
|
56
|
+
columns.push(col);
|
|
57
|
+
column.index = columns.length - 1;
|
|
58
|
+
}
|
|
59
|
+
const maxLength = Math.max(0, ...columns.map((c) => c.length));
|
|
60
|
+
const headerRows = Array.from({ length: maxLength }, () => []);
|
|
61
|
+
let colIndex = 0;
|
|
62
|
+
for (const column of columns) {
|
|
63
|
+
let i = maxLength - 1;
|
|
64
|
+
for (const item of column) {
|
|
65
|
+
if (item) {
|
|
66
|
+
const row = requireValue(headerRows[i], "Missing header row for a column level.");
|
|
67
|
+
const rowLength = row.reduce((p, c) => p + (c.colSpan ?? 1), 0);
|
|
68
|
+
if (rowLength < colIndex) {
|
|
69
|
+
const placeholder = {
|
|
70
|
+
childNodes: [],
|
|
71
|
+
colSpan: colIndex - rowLength,
|
|
72
|
+
colspan: colIndex - rowLength,
|
|
73
|
+
hasChildNodes: false,
|
|
74
|
+
index: rowLength,
|
|
75
|
+
key: `placeholder-${item.key}`,
|
|
76
|
+
level: i,
|
|
77
|
+
rendered: null,
|
|
78
|
+
textValue: "",
|
|
79
|
+
type: "placeholder",
|
|
80
|
+
value: null
|
|
81
|
+
};
|
|
82
|
+
const previous = row.at(-1);
|
|
83
|
+
if (previous) {
|
|
84
|
+
previous.nextKey = placeholder.key;
|
|
85
|
+
placeholder.prevKey = previous.key;
|
|
86
|
+
}
|
|
87
|
+
row.push(placeholder);
|
|
88
|
+
}
|
|
89
|
+
const previous = row.at(-1);
|
|
90
|
+
if (previous) {
|
|
91
|
+
previous.nextKey = item.key;
|
|
92
|
+
item.prevKey = previous.key;
|
|
93
|
+
}
|
|
94
|
+
item.level = i;
|
|
95
|
+
item.colIndex = colIndex;
|
|
96
|
+
row.push(item);
|
|
97
|
+
}
|
|
98
|
+
i -= 1;
|
|
99
|
+
}
|
|
100
|
+
colIndex += 1;
|
|
101
|
+
}
|
|
102
|
+
let i = 0;
|
|
103
|
+
for (const row of headerRows) {
|
|
104
|
+
const rowLength = row.reduce((p, c) => p + (c.colSpan ?? 1), 0);
|
|
105
|
+
if (rowLength < columnNodes.length) {
|
|
106
|
+
const previous = requireValue(row.at(-1), "A header placeholder must follow a column.");
|
|
107
|
+
const placeholder = {
|
|
108
|
+
childNodes: [],
|
|
109
|
+
colSpan: columnNodes.length - rowLength,
|
|
110
|
+
colspan: columnNodes.length - rowLength,
|
|
111
|
+
hasChildNodes: false,
|
|
112
|
+
index: rowLength,
|
|
113
|
+
key: `placeholder-${previous.key}`,
|
|
114
|
+
level: i,
|
|
115
|
+
prevKey: previous.key,
|
|
116
|
+
rendered: null,
|
|
117
|
+
textValue: "",
|
|
118
|
+
type: "placeholder",
|
|
119
|
+
value: null
|
|
120
|
+
};
|
|
121
|
+
row.push(placeholder);
|
|
122
|
+
}
|
|
123
|
+
i += 1;
|
|
124
|
+
}
|
|
125
|
+
return headerRows.map((childNodes, index) => {
|
|
126
|
+
return {
|
|
127
|
+
childNodes,
|
|
128
|
+
hasChildNodes: true,
|
|
129
|
+
index,
|
|
130
|
+
key: `headerrow-${index}`,
|
|
131
|
+
level: 0,
|
|
132
|
+
rendered: null,
|
|
133
|
+
textValue: "",
|
|
134
|
+
type: "headerrow",
|
|
135
|
+
value: null
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
var TableCollection = class extends GridCollection {
|
|
140
|
+
headerRows;
|
|
141
|
+
columns;
|
|
142
|
+
rowHeaderColumnKeys;
|
|
143
|
+
body;
|
|
144
|
+
_size = 0;
|
|
145
|
+
constructor(nodes, prev, opts) {
|
|
146
|
+
const rowHeaderColumnKeys = /* @__PURE__ */ new Set();
|
|
147
|
+
let body = null;
|
|
148
|
+
const columns = [];
|
|
149
|
+
if (opts?.showSelectionCheckboxes === true) {
|
|
150
|
+
const rowHeaderColumn = {
|
|
151
|
+
childNodes: [],
|
|
152
|
+
hasChildNodes: false,
|
|
153
|
+
index: opts?.showDragButtons === true ? 1 : 0,
|
|
154
|
+
key: ROW_HEADER_COLUMN_KEY,
|
|
155
|
+
level: 0,
|
|
156
|
+
props: { isSelectionCell: true },
|
|
157
|
+
rendered: null,
|
|
158
|
+
textValue: "",
|
|
159
|
+
type: "column",
|
|
160
|
+
value: null
|
|
161
|
+
};
|
|
162
|
+
columns.unshift(rowHeaderColumn);
|
|
163
|
+
}
|
|
164
|
+
if (opts?.showDragButtons === true) {
|
|
165
|
+
const rowHeaderColumn = {
|
|
166
|
+
childNodes: [],
|
|
167
|
+
hasChildNodes: false,
|
|
168
|
+
index: 0,
|
|
169
|
+
key: ROW_HEADER_COLUMN_KEY_DRAG,
|
|
170
|
+
level: 0,
|
|
171
|
+
props: { isDragButtonCell: true },
|
|
172
|
+
rendered: null,
|
|
173
|
+
textValue: "",
|
|
174
|
+
type: "column",
|
|
175
|
+
value: null
|
|
176
|
+
};
|
|
177
|
+
columns.unshift(rowHeaderColumn);
|
|
178
|
+
}
|
|
179
|
+
const rows = [];
|
|
180
|
+
const columnKeyMap = /* @__PURE__ */ new Map();
|
|
181
|
+
const visit = (node) => {
|
|
182
|
+
switch (node.type) {
|
|
183
|
+
case "body":
|
|
184
|
+
body = node;
|
|
185
|
+
break;
|
|
186
|
+
case "column":
|
|
187
|
+
columnKeyMap.set(node.key, node);
|
|
188
|
+
if (!node.hasChildNodes) {
|
|
189
|
+
columns.push(node);
|
|
190
|
+
if (getNodeProps(node).isRowHeader) rowHeaderColumnKeys.add(node.key);
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
case "item":
|
|
194
|
+
rows.push(node);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
for (const child of getNodeChildren(node)) visit(child);
|
|
198
|
+
};
|
|
199
|
+
for (const node of nodes) visit(node);
|
|
200
|
+
const headerRows = buildHeaderRows(columnKeyMap, columns);
|
|
201
|
+
for (const [i, row] of headerRows.entries()) rows.splice(i, 0, row);
|
|
202
|
+
super({
|
|
203
|
+
columnCount: columns.length,
|
|
204
|
+
items: rows,
|
|
205
|
+
visitNode: (node) => {
|
|
206
|
+
node.column = columns[node.index];
|
|
207
|
+
return node;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
this.columns = columns;
|
|
211
|
+
this.rowHeaderColumnKeys = rowHeaderColumnKeys;
|
|
212
|
+
this.body = requireValue(body, "Table collections require a body node.");
|
|
213
|
+
this.headerRows = headerRows;
|
|
214
|
+
this._size = [...getNodeChildren(this.body)].length;
|
|
215
|
+
if (this.rowHeaderColumnKeys.size === 0) {
|
|
216
|
+
const col = this.columns.find((column) => !getNodeProps(column).isDragButtonCell && !getNodeProps(column).isSelectionCell);
|
|
217
|
+
if (col) this.rowHeaderColumnKeys.add(col.key);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
*[Symbol.iterator]() {
|
|
221
|
+
yield* getNodeChildren(this.body);
|
|
222
|
+
}
|
|
223
|
+
get size() {
|
|
224
|
+
return this._size;
|
|
225
|
+
}
|
|
226
|
+
getKeys() {
|
|
227
|
+
return this.keyMap.keys();
|
|
228
|
+
}
|
|
229
|
+
getKeyBefore(key) {
|
|
230
|
+
return this.keyMap.get(key)?.prevKey ?? null;
|
|
231
|
+
}
|
|
232
|
+
getKeyAfter(key) {
|
|
233
|
+
return this.keyMap.get(key)?.nextKey ?? null;
|
|
234
|
+
}
|
|
235
|
+
getFirstKey() {
|
|
236
|
+
return getFirstItem(getNodeChildren(this.body))?.key ?? null;
|
|
237
|
+
}
|
|
238
|
+
getLastKey() {
|
|
239
|
+
return getLastItem(getNodeChildren(this.body))?.key ?? null;
|
|
240
|
+
}
|
|
241
|
+
getItem(key) {
|
|
242
|
+
if (key === this.body.key) return this.body;
|
|
243
|
+
return this.keyMap.get(key) ?? null;
|
|
244
|
+
}
|
|
245
|
+
at(idx) {
|
|
246
|
+
const key = [...this.getKeys()][idx];
|
|
247
|
+
return key === void 0 ? null : this.getItem(key);
|
|
248
|
+
}
|
|
249
|
+
getChildren(key) {
|
|
250
|
+
if (key === this.body.key) return getNodeChildren(this.body);
|
|
251
|
+
const node = this.getItem(key);
|
|
252
|
+
if (node?.type === "item") return [...getNodeChildren(node)].filter((n) => n.type === "cell");
|
|
253
|
+
return super.getChildren(key);
|
|
254
|
+
}
|
|
255
|
+
getTextValue(key) {
|
|
256
|
+
const row = this.getItem(key);
|
|
257
|
+
if (!row) return "";
|
|
258
|
+
if (row.textValue) return row.textValue;
|
|
259
|
+
const { rowHeaderColumnKeys } = this;
|
|
260
|
+
const text = [];
|
|
261
|
+
for (const cell of getNodeChildren(row)) {
|
|
262
|
+
const column = this.columns[cell.index];
|
|
263
|
+
if (rowHeaderColumnKeys.has(requireValue(column, "Expected column to exist.").key) && cell.textValue) text.push(cell.textValue);
|
|
264
|
+
if (text.length === rowHeaderColumnKeys.size) break;
|
|
265
|
+
}
|
|
266
|
+
return text.join(" ");
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
function isTableCollection(collection) {
|
|
270
|
+
return "columns" in collection && Array.isArray(collection.columns) && "headerRows" in collection && Array.isArray(collection.headerRows) && "rows" in collection && Array.isArray(collection.rows) && "columnCount" in collection && typeof collection.columnCount === "number" && "rowHeaderColumnKeys" in collection && collection.rowHeaderColumnKeys instanceof Set && "body" in collection && typeof collection.body === "object" && collection.body !== null;
|
|
271
|
+
}
|
|
272
|
+
export { TableCollection, buildHeaderRows, isTableCollection };
|
|
273
|
+
|
|
274
|
+
//# sourceMappingURL=table-collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-collection.js","names":[],"sources":["../../src/table/table-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/table/TableCollection.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 { Collection, Node, Key } from \"@solid2-aria/types-shared\";\n\nimport {\n getFirstItem,\n getLastItem,\n getNodeChildren,\n} from \"../collections/get-child-nodes\";\nimport { GridCollection, setColumnSpan } from \"../grid/grid-collection\";\nimport type { GridNode, IGridCollection } from \"../grid/grid-collection\";\nimport { getNodeProps } from \"../utils/get-node-props\";\nimport { requireValue } from \"../utils/require-value\";\n\nexport interface ITableCollection<T> extends IGridCollection<T> {\n filter?: (\n ...args: Parameters<NonNullable<Collection<GridNode<T>>[\"filter\"]>>\n ) => ITableCollection<T>;\n // perhaps elaborate on this? maybe not clear enough, essentially returns the table header rows (e.g. in a tiered headers table, will return the nodes containing the top tier column, next tier, etc)\n /** A list of header row nodes in the table. */\n headerRows: GridNode<T>[];\n /** A list of column nodes in the table. */\n columns: GridNode<T>[];\n /**\n * A set of column keys that serve as the [row\n * header](https://www.w3.org/TR/wai-aria-1.1/#rowheader).\n */\n rowHeaderColumnKeys: Set<Key>;\n /** The node that makes up the header of the table. */\n head?: GridNode<T>;\n /** The node that makes up the body of the table. */\n body: GridNode<T>;\n}\n\ninterface GridCollectionOptions {\n showSelectionCheckboxes?: boolean;\n showDragButtons?: boolean;\n}\n\nconst ROW_HEADER_COLUMN_KEY = `row-header-column-${Math.random().toString(36).slice(2)}`;\nlet ROW_HEADER_COLUMN_KEY_DRAG = `row-header-column-${Math.random().toString(36).slice(2)}`;\n\nwhile (ROW_HEADER_COLUMN_KEY === ROW_HEADER_COLUMN_KEY_DRAG) {\n ROW_HEADER_COLUMN_KEY_DRAG = `row-header-column-${Math.random().toString(36).slice(2)}`;\n}\n\n/** @private */\nexport function buildHeaderRows<T>(\n keyMap: Map<Key, GridNode<T>>,\n columnNodes: GridNode<T>[]\n): GridNode<T>[] {\n const columns: (GridNode<T> | null)[][] = [];\n\n const seen = new Map<\n GridNode<T>,\n { column: (GridNode<T> | null)[]; index: number }\n >();\n\n for (const column of columnNodes) {\n let { parentKey } = column;\n const col: (GridNode<T> | null)[] = [column];\n\n while (parentKey !== null && parentKey !== undefined) {\n const parent: GridNode<T> | undefined = keyMap.get(parentKey);\n\n if (!parent) {\n break;\n }\n\n // If we've already seen this parent, than it is shared\n // with a previous column. If the current column is taller\n // than the previous column, than we need to shift the parent\n // in the previous column so it's level with the current column.\n const seenParent = seen.get(parent);\n\n if (seenParent) {\n setColumnSpan(parent, (parent.colSpan ?? 0) + 1);\n const { column: localColumn, index } = seenParent;\n\n if (index > col.length) {\n break;\n }\n\n for (let i = index; i < col.length; i += 1) {\n localColumn.splice(i, 0, null);\n }\n\n // Adjust shifted indices\n for (let i = col.length; i < localColumn.length; i += 1) {\n const shifted = localColumn[i];\n const shiftedEntry = shifted ? seen.get(shifted) : undefined;\n\n if (shiftedEntry) {\n shiftedEntry.index = i;\n }\n }\n } else {\n setColumnSpan(parent, 1);\n col.push(parent);\n seen.set(parent, { column: col, index: col.length - 1 });\n }\n\n ({ parentKey } = parent);\n }\n\n columns.push(col);\n column.index = columns.length - 1;\n }\n\n const maxLength = Math.max(0, ...columns.map((c) => c.length));\n\n const headerRows: GridNode<T>[][] = Array.from(\n { length: maxLength },\n () => []\n );\n\n // Convert columns into rows.\n let colIndex = 0;\n\n for (const column of columns) {\n let i = maxLength - 1;\n\n for (const item of column) {\n if (item) {\n // Fill the space up until the current column with a placeholder\n const row = requireValue(\n headerRows[i],\n \"Missing header row for a column level.\"\n );\n\n const rowLength = row.reduce((p, c) => p + (c.colSpan ?? 1), 0);\n\n if (rowLength < colIndex) {\n const placeholder: GridNode<T> = {\n // oxlint-disable-next-line typescript/no-deprecated -- Node-backed collection construction must populate the upstream childNodes output contract.\n childNodes: [],\n colSpan: colIndex - rowLength,\n // oxlint-disable-next-line typescript/no-deprecated -- Expose the legacy output alias for existing consumers; internal state uses its modern replacement.\n colspan: colIndex - rowLength,\n hasChildNodes: false,\n index: rowLength,\n key: `placeholder-${item.key}`,\n level: i,\n rendered: null,\n textValue: \"\",\n type: \"placeholder\",\n value: null,\n };\n\n const previous = row.at(-1);\n\n if (previous) {\n previous.nextKey = placeholder.key;\n placeholder.prevKey = previous.key;\n }\n\n row.push(placeholder);\n }\n\n const previous = row.at(-1);\n\n if (previous) {\n previous.nextKey = item.key;\n item.prevKey = previous.key;\n }\n\n item.level = i;\n item.colIndex = colIndex;\n row.push(item);\n }\n\n i -= 1;\n }\n\n colIndex += 1;\n }\n\n // Add placeholders at the end of each row that is shorter than the maximum\n let i = 0;\n\n for (const row of headerRows) {\n const rowLength = row.reduce((p, c) => p + (c.colSpan ?? 1), 0);\n\n if (rowLength < columnNodes.length) {\n const previous = requireValue(\n row.at(-1),\n \"A header placeholder must follow a column.\"\n );\n\n const placeholder: GridNode<T> = {\n // oxlint-disable-next-line typescript/no-deprecated -- Node-backed collection construction must populate the upstream childNodes output contract.\n childNodes: [],\n colSpan: columnNodes.length - rowLength,\n // oxlint-disable-next-line typescript/no-deprecated -- Expose the legacy output alias for existing consumers; internal state uses its modern replacement.\n colspan: columnNodes.length - rowLength,\n hasChildNodes: false,\n index: rowLength,\n key: `placeholder-${previous.key}`,\n level: i,\n prevKey: previous.key,\n rendered: null,\n textValue: \"\",\n type: \"placeholder\",\n value: null,\n };\n\n row.push(placeholder);\n }\n\n i += 1;\n }\n\n return headerRows.map((childNodes, index) => {\n const row: GridNode<T> = {\n // oxlint-disable-next-line typescript/no-deprecated -- Node-backed collection construction must populate the upstream childNodes output contract.\n childNodes,\n hasChildNodes: true,\n index,\n key: `headerrow-${index}`,\n level: 0,\n rendered: null,\n textValue: \"\",\n type: \"headerrow\",\n value: null,\n };\n\n return row;\n });\n}\n\nexport class TableCollection<T>\n extends GridCollection<T>\n implements ITableCollection<T>\n{\n headerRows: GridNode<T>[];\n columns: GridNode<T>[];\n rowHeaderColumnKeys: Set<Key>;\n body: GridNode<T>;\n _size = 0;\n constructor(\n nodes: Iterable<GridNode<T>>,\n prev?: ITableCollection<T> | null,\n opts?: GridCollectionOptions\n ) {\n const rowHeaderColumnKeys = new Set<Key>();\n let body: GridNode<T> | null = null;\n const columns: GridNode<T>[] = [];\n\n // Add cell for selection checkboxes if needed.\n if (opts?.showSelectionCheckboxes === true) {\n const rowHeaderColumn: GridNode<T> = {\n // oxlint-disable-next-line typescript/no-deprecated -- Node-backed collection construction must populate the upstream childNodes output contract.\n childNodes: [],\n hasChildNodes: false,\n index: opts?.showDragButtons === true ? 1 : 0,\n key: ROW_HEADER_COLUMN_KEY,\n level: 0,\n props: {\n isSelectionCell: true,\n },\n rendered: null,\n textValue: \"\",\n type: \"column\",\n value: null,\n };\n\n columns.unshift(rowHeaderColumn);\n }\n\n // Add cell for drag buttons if needed.\n if (opts?.showDragButtons === true) {\n const rowHeaderColumn: GridNode<T> = {\n // oxlint-disable-next-line typescript/no-deprecated -- Node-backed collection construction must populate the upstream childNodes output contract.\n childNodes: [],\n hasChildNodes: false,\n index: 0,\n key: ROW_HEADER_COLUMN_KEY_DRAG,\n level: 0,\n props: {\n isDragButtonCell: true,\n },\n rendered: null,\n textValue: \"\",\n type: \"column\",\n value: null,\n };\n\n columns.unshift(rowHeaderColumn);\n }\n\n const rows: GridNode<T>[] = [];\n const columnKeyMap = new Map<Key, GridNode<T>>();\n\n const visit = (node: GridNode<T>) => {\n switch (node.type) {\n case \"body\": {\n body = node;\n break;\n }\n\n case \"column\": {\n columnKeyMap.set(node.key, node);\n\n if (!node.hasChildNodes) {\n columns.push(node);\n\n if (getNodeProps(node).isRowHeader) {\n rowHeaderColumnKeys.add(node.key);\n }\n }\n\n break;\n }\n\n case \"item\": {\n rows.push(node);\n\n return;\n // do not go into childNodes\n }\n\n default: {\n break;\n }\n }\n\n for (const child of getNodeChildren(node)) {\n visit(child);\n }\n };\n\n for (const node of nodes) {\n visit(node);\n }\n\n const headerRows = buildHeaderRows(columnKeyMap, columns);\n\n for (const [i, row] of headerRows.entries()) {\n rows.splice(i, 0, row);\n }\n\n super({\n columnCount: columns.length,\n items: rows,\n visitNode: (node) => {\n node.column = columns[node.index];\n\n return node;\n },\n });\n this.columns = columns;\n this.rowHeaderColumnKeys = rowHeaderColumnKeys;\n this.body = requireValue(body, \"Table collections require a body node.\");\n this.headerRows = headerRows;\n this._size = [...getNodeChildren(this.body)].length;\n\n // Default row header column to the first one.\n if (this.rowHeaderColumnKeys.size === 0) {\n const col = this.columns.find(\n (column) =>\n !getNodeProps(column).isDragButtonCell &&\n !getNodeProps(column).isSelectionCell\n );\n\n if (col) {\n this.rowHeaderColumnKeys.add(col.key);\n }\n }\n }\n override *[Symbol.iterator](): IterableIterator<GridNode<T>> {\n yield* getNodeChildren(this.body);\n }\n override get size(): number {\n return this._size;\n }\n override getKeys(): IterableIterator<Key> {\n return this.keyMap.keys();\n }\n override getKeyBefore(key: Key): Key | null {\n const node = this.keyMap.get(key);\n\n return node?.prevKey ?? null;\n }\n override getKeyAfter(key: Key): Key | null {\n const node = this.keyMap.get(key);\n\n return node?.nextKey ?? null;\n }\n override getFirstKey(): Key | null {\n return getFirstItem(getNodeChildren(this.body))?.key ?? null;\n }\n override getLastKey(): Key | null {\n return getLastItem(getNodeChildren(this.body))?.key ?? null;\n }\n override getItem(key: Key): GridNode<T> | null {\n if (key === this.body.key) {\n return this.body;\n }\n\n return this.keyMap.get(key) ?? null;\n }\n override at(idx: number): GridNode<T> | null {\n const keys = [...this.getKeys()];\n const key = keys[idx];\n\n return key === undefined ? null : this.getItem(key);\n }\n override getChildren(key: Key): Iterable<GridNode<T>> {\n if (key === this.body.key) {\n return getNodeChildren(this.body);\n }\n\n const node = this.getItem(key);\n\n if (node?.type === \"item\") {\n return [...getNodeChildren(node)].filter((n) => n.type === \"cell\");\n }\n\n return super.getChildren(key);\n }\n getTextValue(key: Key): string {\n const row = this.getItem(key);\n\n if (!row) {\n return \"\";\n }\n\n // If the row has a textValue, use that.\n if (row.textValue) {\n return row.textValue;\n }\n\n // Otherwise combine the text of each of the row header columns.\n const { rowHeaderColumnKeys } = this;\n\n const text: string[] = [];\n\n for (const cell of getNodeChildren(row)) {\n const column = this.columns[cell.index];\n\n if (\n rowHeaderColumnKeys.has(\n requireValue(column, \"Expected column to exist.\").key\n ) &&\n cell.textValue\n ) {\n text.push(cell.textValue);\n }\n\n if (text.length === rowHeaderColumnKeys.size) {\n break;\n }\n }\n\n return text.join(\" \");\n }\n}\n\nexport function isTableCollection<T>(\n collection: Collection<Node<T>>\n): collection is ITableCollection<T> {\n return (\n \"columns\" in collection &&\n Array.isArray(collection.columns) &&\n \"headerRows\" in collection &&\n Array.isArray(collection.headerRows) &&\n \"rows\" in collection &&\n Array.isArray(collection.rows) &&\n \"columnCount\" in collection &&\n typeof collection.columnCount === \"number\" &&\n \"rowHeaderColumnKeys\" in collection &&\n collection.rowHeaderColumnKeys instanceof Set &&\n \"body\" in collection &&\n typeof collection.body === \"object\" &&\n collection.body !== null\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsDA,MAAM,wBAAwB,qBAAqB,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,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AgB,YAClC,yBAAyB,cACzB,WAAW,+BAA+B,OAC1C,UAAU,cACV,OAAO,WAAW,SAAS,YAC3B,WAAW,SAAS;AAExB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 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/table/TableColumnLayout.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 { GridNode } from "../grid/grid-collection.js";
|
|
18
|
+
import { ITableCollection } from "./table-collection.js";
|
|
19
|
+
import { ColumnSize } from "./column.js";
|
|
20
|
+
import { Key } from "@solid2-aria/types-shared";
|
|
21
|
+
export interface TableColumnLayoutOptions<T> {
|
|
22
|
+
getDefaultWidth?: (column: GridNode<T>) => ColumnSize | null | undefined;
|
|
23
|
+
getDefaultMinWidth?: (column: GridNode<T>) => ColumnSize | null | undefined;
|
|
24
|
+
}
|
|
25
|
+
export declare class TableColumnLayout<T> {
|
|
26
|
+
getDefaultWidth: (column: GridNode<T>) => ColumnSize | null | undefined;
|
|
27
|
+
getDefaultMinWidth: (column: GridNode<T>) => ColumnSize | null | undefined;
|
|
28
|
+
columnWidths: Map<Key, number>;
|
|
29
|
+
columnMinWidths: Map<Key, number>;
|
|
30
|
+
columnMaxWidths: Map<Key, number>;
|
|
31
|
+
constructor(options: TableColumnLayoutOptions<T>);
|
|
32
|
+
/**
|
|
33
|
+
* Takes an array of columns and splits it into 2 maps of columns with controlled and columns with
|
|
34
|
+
* uncontrolled widths.
|
|
35
|
+
*/
|
|
36
|
+
splitColumnsIntoControlledAndUncontrolled(columns: GridNode<T>[]): [Map<Key, GridNode<T>>, Map<Key, GridNode<T>>];
|
|
37
|
+
/** Takes uncontrolled and controlled widths and joins them into a single Map. */
|
|
38
|
+
recombineColumns(columns: GridNode<T>[], uncontrolledWidths: Map<Key, ColumnSize>, uncontrolledColumns: Map<Key, GridNode<T>>, controlledColumns: Map<Key, GridNode<T>>): Map<Key, ColumnSize>;
|
|
39
|
+
/** Used to make an initial Map of the uncontrolled widths based on default widths. */
|
|
40
|
+
getInitialUncontrolledWidths(uncontrolledColumns: Map<Key, GridNode<T>>): Map<Key, ColumnSize>;
|
|
41
|
+
getColumnWidth(key: Key): number;
|
|
42
|
+
getColumnMinWidth(key: Key): number;
|
|
43
|
+
getColumnMaxWidth(key: Key): number;
|
|
44
|
+
resizeColumnWidth(collection: ITableCollection<T>, uncontrolledWidths: Map<Key, ColumnSize>, col: Key, initialWidth: number): Map<Key, ColumnSize>;
|
|
45
|
+
buildColumnWidths(tableWidth: number, collection: ITableCollection<T>, widths: Map<Key, ColumnSize>): Map<Key, number>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=table-column-layout.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 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/table/TableColumnLayout.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 { getNodeProps } from "../utils/get-node-props.js";
|
|
18
|
+
import { requireValue } from "../utils/require-value.js";
|
|
19
|
+
import { calculateColumnSizes, getMaxWidth, getMinWidth } from "./table-utils.js";
|
|
20
|
+
// src/table/table-column-layout.ts
|
|
21
|
+
var TableColumnLayout = class {
|
|
22
|
+
getDefaultWidth;
|
|
23
|
+
getDefaultMinWidth;
|
|
24
|
+
columnWidths = /* @__PURE__ */ new Map();
|
|
25
|
+
columnMinWidths = /* @__PURE__ */ new Map();
|
|
26
|
+
columnMaxWidths = /* @__PURE__ */ new Map();
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.getDefaultWidth = options?.getDefaultWidth ?? (() => "1fr");
|
|
29
|
+
this.getDefaultMinWidth = options?.getDefaultMinWidth ?? (() => 75);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Takes an array of columns and splits it into 2 maps of columns with controlled and columns with
|
|
33
|
+
* uncontrolled widths.
|
|
34
|
+
*/
|
|
35
|
+
splitColumnsIntoControlledAndUncontrolled(columns) {
|
|
36
|
+
const controlled = /* @__PURE__ */ new Map();
|
|
37
|
+
const uncontrolled = /* @__PURE__ */ new Map();
|
|
38
|
+
for (const column of columns) (getNodeProps(column).width === void 0 ? uncontrolled : controlled).set(column.key, column);
|
|
39
|
+
return [controlled, uncontrolled];
|
|
40
|
+
}
|
|
41
|
+
/** Takes uncontrolled and controlled widths and joins them into a single Map. */
|
|
42
|
+
recombineColumns(columns, uncontrolledWidths, uncontrolledColumns, controlledColumns) {
|
|
43
|
+
return new Map(columns.map((col) => {
|
|
44
|
+
if (uncontrolledColumns.has(col.key)) return [col.key, requireValue(uncontrolledWidths.get(col.key), "Missing uncontrolled column width.")];
|
|
45
|
+
return [col.key, requireValue(getNodeProps(controlledColumns.get(col.key)).width, "Missing controlled column width.")];
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
/** Used to make an initial Map of the uncontrolled widths based on default widths. */
|
|
49
|
+
getInitialUncontrolledWidths(uncontrolledColumns) {
|
|
50
|
+
return new Map([...uncontrolledColumns].map(([key, col]) => [key, getNodeProps(col).defaultWidth ?? this.getDefaultWidth?.(col) ?? "1fr"]));
|
|
51
|
+
}
|
|
52
|
+
getColumnWidth(key) {
|
|
53
|
+
return this.columnWidths.get(key) ?? 0;
|
|
54
|
+
}
|
|
55
|
+
getColumnMinWidth(key) {
|
|
56
|
+
return this.columnMinWidths.get(key) ?? 0;
|
|
57
|
+
}
|
|
58
|
+
getColumnMaxWidth(key) {
|
|
59
|
+
return this.columnMaxWidths.get(key) ?? 0;
|
|
60
|
+
}
|
|
61
|
+
resizeColumnWidth(collection, uncontrolledWidths, col, initialWidth) {
|
|
62
|
+
let width = initialWidth;
|
|
63
|
+
const prevColumnWidths = this.columnWidths;
|
|
64
|
+
let freeze = true;
|
|
65
|
+
const newWidths = /* @__PURE__ */ new Map();
|
|
66
|
+
width = Math.max(this.getColumnMinWidth(col), Math.min(this.getColumnMaxWidth(col), Math.floor(width)));
|
|
67
|
+
for (const column of collection.columns) if (column.key === col) {
|
|
68
|
+
newWidths.set(column.key, width);
|
|
69
|
+
freeze = false;
|
|
70
|
+
} else if (freeze) newWidths.set(column.key, prevColumnWidths.get(column.key) ?? 0);
|
|
71
|
+
else newWidths.set(column.key, requireValue(getNodeProps(column).width ?? uncontrolledWidths.get(column.key), "A column must have a controlled or uncontrolled width."));
|
|
72
|
+
return newWidths;
|
|
73
|
+
}
|
|
74
|
+
buildColumnWidths(tableWidth, collection, widths) {
|
|
75
|
+
this.columnWidths = /* @__PURE__ */ new Map();
|
|
76
|
+
this.columnMinWidths = /* @__PURE__ */ new Map();
|
|
77
|
+
this.columnMaxWidths = /* @__PURE__ */ new Map();
|
|
78
|
+
const columnWidths = calculateColumnSizes(tableWidth, collection.columns.map((col) => ({
|
|
79
|
+
...getNodeProps(col),
|
|
80
|
+
key: col.key
|
|
81
|
+
})), widths, (i) => this.getDefaultWidth(requireValue(collection.columns[i], "Expected collection.columns[i] to exist.")), (i) => this.getDefaultMinWidth(requireValue(collection.columns[i], "Expected collection.columns[i] to exist.")));
|
|
82
|
+
for (const [index, width] of columnWidths.entries()) {
|
|
83
|
+
const column = requireValue(collection.columns[index], "Column widths must correspond to collection columns.");
|
|
84
|
+
const { key } = column;
|
|
85
|
+
this.columnWidths.set(key, width);
|
|
86
|
+
this.columnMinWidths.set(key, getMinWidth(getNodeProps(column).minWidth ?? this.getDefaultMinWidth(column), tableWidth));
|
|
87
|
+
this.columnMaxWidths.set(key, getMaxWidth(getNodeProps(column).maxWidth, tableWidth));
|
|
88
|
+
}
|
|
89
|
+
return this.columnWidths;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
export { TableColumnLayout };
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=table-column-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-column-layout.js","names":[],"sources":["../../src/table/table-column-layout.ts"],"sourcesContent":["/*\n * Copyright 2022 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/table/TableColumnLayout.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 { Key } from \"@solid2-aria/types-shared\";\n\nimport type { GridNode } from \"../grid/grid-collection\";\nimport { getNodeProps } from \"../utils/get-node-props\";\nimport { requireValue } from \"../utils/require-value\";\nimport type { ColumnSize } from \"./column\";\nimport type { ITableCollection as TableCollection } from \"./table-collection\";\nimport { calculateColumnSizes, getMaxWidth, getMinWidth } from \"./table-utils\";\n\nexport interface TableColumnLayoutOptions<T> {\n getDefaultWidth?: (column: GridNode<T>) => ColumnSize | null | undefined;\n getDefaultMinWidth?: (column: GridNode<T>) => ColumnSize | null | undefined;\n}\n\nexport class TableColumnLayout<T> {\n getDefaultWidth: (column: GridNode<T>) => ColumnSize | null | undefined;\n getDefaultMinWidth: (column: GridNode<T>) => ColumnSize | null | undefined;\n columnWidths = new Map<Key, number>();\n columnMinWidths = new Map<Key, number>();\n columnMaxWidths = new Map<Key, number>();\n constructor(options: TableColumnLayoutOptions<T>) {\n this.getDefaultWidth = options?.getDefaultWidth ?? (() => \"1fr\");\n this.getDefaultMinWidth = options?.getDefaultMinWidth ?? (() => 75);\n }\n /**\n * Takes an array of columns and splits it into 2 maps of columns with controlled and columns with\n * uncontrolled widths.\n */\n splitColumnsIntoControlledAndUncontrolled(\n columns: GridNode<T>[]\n ): [Map<Key, GridNode<T>>, Map<Key, GridNode<T>>] {\n const controlled = new Map<Key, GridNode<T>>();\n const uncontrolled = new Map<Key, GridNode<T>>();\n\n for (const column of columns) {\n const target =\n getNodeProps(column).width === undefined ? uncontrolled : controlled;\n\n target.set(column.key, column);\n }\n\n return [controlled, uncontrolled];\n }\n /** Takes uncontrolled and controlled widths and joins them into a single Map. */\n recombineColumns(\n columns: GridNode<T>[],\n uncontrolledWidths: Map<Key, ColumnSize>,\n uncontrolledColumns: Map<Key, GridNode<T>>,\n controlledColumns: Map<Key, GridNode<T>>\n ): Map<Key, ColumnSize> {\n return new Map(\n columns.map((col) => {\n if (uncontrolledColumns.has(col.key)) {\n return [\n col.key,\n requireValue(\n uncontrolledWidths.get(col.key),\n \"Missing uncontrolled column width.\"\n ),\n ];\n }\n\n return [\n col.key,\n requireValue(\n getNodeProps(controlledColumns.get(col.key)).width,\n \"Missing controlled column width.\"\n ),\n ];\n })\n );\n }\n /** Used to make an initial Map of the uncontrolled widths based on default widths. */\n getInitialUncontrolledWidths(\n uncontrolledColumns: Map<Key, GridNode<T>>\n ): Map<Key, ColumnSize> {\n return new Map(\n [...uncontrolledColumns].map(([key, col]) => [\n key,\n getNodeProps(col).defaultWidth ?? this.getDefaultWidth?.(col) ?? \"1fr\",\n ])\n );\n }\n getColumnWidth(key: Key): number {\n return this.columnWidths.get(key) ?? 0;\n }\n getColumnMinWidth(key: Key): number {\n return this.columnMinWidths.get(key) ?? 0;\n }\n getColumnMaxWidth(key: Key): number {\n return this.columnMaxWidths.get(key) ?? 0;\n }\n resizeColumnWidth(\n collection: TableCollection<T>,\n uncontrolledWidths: Map<Key, ColumnSize>,\n col: Key,\n initialWidth: number\n ): Map<Key, ColumnSize> {\n let width = initialWidth;\n\n const prevColumnWidths = this.columnWidths;\n let freeze = true;\n const newWidths = new Map<Key, ColumnSize>();\n width = Math.max(\n this.getColumnMinWidth(col),\n Math.min(this.getColumnMaxWidth(col), Math.floor(width))\n );\n\n for (const column of collection.columns) {\n if (column.key === col) {\n newWidths.set(column.key, width);\n freeze = false;\n } else if (freeze) {\n // freeze columns to the left to their previous pixel value\n newWidths.set(column.key, prevColumnWidths.get(column.key) ?? 0);\n } else {\n newWidths.set(\n column.key,\n requireValue(\n getNodeProps(column).width ?? uncontrolledWidths.get(column.key),\n \"A column must have a controlled or uncontrolled width.\"\n )\n );\n }\n }\n\n return newWidths;\n }\n buildColumnWidths(\n tableWidth: number,\n collection: TableCollection<T>,\n widths: Map<Key, ColumnSize>\n ): Map<Key, number> {\n this.columnWidths = new Map();\n this.columnMinWidths = new Map();\n this.columnMaxWidths = new Map();\n\n // initial layout or table/window resizing\n const columnWidths = calculateColumnSizes(\n tableWidth,\n collection.columns.map((col) => ({ ...getNodeProps(col), key: col.key })),\n widths,\n (i) =>\n this.getDefaultWidth(\n requireValue(\n collection.columns[i],\n \"Expected collection.columns[i] to exist.\"\n )\n ),\n (i) =>\n this.getDefaultMinWidth(\n requireValue(\n collection.columns[i],\n \"Expected collection.columns[i] to exist.\"\n )\n )\n );\n\n // columns going in will be the same order as the columns coming out\n for (const [index, width] of columnWidths.entries()) {\n const column = requireValue(\n collection.columns[index],\n \"Column widths must correspond to collection columns.\"\n );\n\n const { key } = column;\n this.columnWidths.set(key, width);\n this.columnMinWidths.set(\n key,\n getMinWidth(\n getNodeProps(column).minWidth ?? this.getDefaultMinWidth(column),\n tableWidth\n )\n );\n this.columnMaxWidths.set(\n key,\n getMaxWidth(getNodeProps(column).maxWidth, tableWidth)\n );\n }\n\n return this.columnWidths;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+BA,IAAa,oBAAb,MAAkC;CAChC;CACA;CACA,+BAAe,IAAI,IAAiB;CACpC,kCAAkB,IAAI,IAAiB;CACvC,kCAAkB,IAAI,IAAiB;CACvC,YAAY,SAAsC;EAChD,KAAK,kBAAkB,SAAS,0BAA0B;EAC1D,KAAK,qBAAqB,SAAS,6BAA6B;CAClE;;;;;CAKA,0CACE,SACgD;EAChD,MAAM,6BAAa,IAAI,IAAsB;EAC7C,MAAM,+BAAe,IAAI,IAAsB;EAE/C,KAAK,MAAM,UAAU,SAInB,CAFE,aAAa,MAAM,CAAC,CAAC,UAAU,KAAA,IAAY,eAAe,WAAA,CAErD,IAAI,OAAO,KAAK,MAAM;EAG/B,OAAO,CAAC,YAAY,YAAY;CAClC;;CAEA,iBACE,SACA,oBACA,qBACA,mB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C/D,wDACF,CACF;EAIJ,OAAO;CACT;CACA,kBACE,YACA,YACA,QACkB;EAClB,KAAK,+BAAe,IAAI,IAAI;EAC5B,KAAK,kCAAkB,IAAI,IAAI;EAC/B,KAAK,kCAAkB,IAAI,IAAI;EAG/B,MAAM,eAAe,qBACnB,YACA,WAAW,QAAQ,KAAK,SAAS;GAAE,GAAG,aAAa,GAAG;GAAG,KAAK,IAAI;EAAI,EAAE,GACxE,SACC,MACC,KAAK,gBACH,aACE,WAAW,QAAQ,IACnB,0CACF,CACF,IACD,MACC,KAAK,mBACH,aACE,WAAW,QAAQ,IACnB,0CACF,CACF,CACJ;EAGA,KAAK,MAAM,CAAC,OAAO,UAAU,aAAa,QAAQ,GAAG;GACnD,MAAM,SAAS,aACb,WAAW,QAAQ,QACnB,sDACF;GAEA,MAAM,EAAE,QAAQ;GAChB,KAAK,aAAa,IAAI,KAAK,KAAK;GAChC,KAAK,gBAAgB,IACnB,KACA,YACE,aAAa,MAAM,CAAC,CAAC,YAAY,KAAK,mBAAmB,MAAM,GAC/D,UACF,CACF;GACA,KAAK,gBAAgB,IACnB,KACA,YAAY,aAAa,MAAM,CAAC,CAAC,UAAU,UAAU,CACvD;EACF;EAEA,OAAO,KAAK;CACd;AACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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/table/TableHeader.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 { CollectionContext, PartialNode } from "../collections/types.js";
|
|
18
|
+
import { ColumnElement, ColumnRenderer } from "./column.js";
|
|
19
|
+
import { Element } from "solid-js";
|
|
20
|
+
import { Key } from "@solid2-aria/types-shared";
|
|
21
|
+
export interface TableHeaderProps<T> {
|
|
22
|
+
key?: Key;
|
|
23
|
+
"aria-label"?: string;
|
|
24
|
+
/** A list of table columns. */
|
|
25
|
+
columns?: readonly T[];
|
|
26
|
+
/**
|
|
27
|
+
* A list of `Column(s)` or a function. If the latter, a list of columns must be provided using
|
|
28
|
+
* the `columns` prop.
|
|
29
|
+
*/
|
|
30
|
+
children: ColumnElement<T> | ColumnElement<T>[] | ColumnRenderer<T>;
|
|
31
|
+
}
|
|
32
|
+
declare function TableHeader<T>(props: TableHeaderProps<T>): Element;
|
|
33
|
+
declare namespace TableHeader {
|
|
34
|
+
var getCollectionNode: <T>(props: TableHeaderProps<T>, context: CollectionContext) => Generator<PartialNode<T>, void>;
|
|
35
|
+
}
|
|
36
|
+
export { TableHeader };
|
|
37
|
+
//# sourceMappingURL=table-header.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
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/table/TableHeader.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 { collectionChildren } from "../collections/types.js";
|
|
18
|
+
import { isTableCollectionContext } from "./collection-context.js";
|
|
19
|
+
// src/table/table-header.ts
|
|
20
|
+
function TableHeader(props) {
|
|
21
|
+
return Object.assign([], {
|
|
22
|
+
getCollectionNode: (context) => TableHeader.getCollectionNode(props, context),
|
|
23
|
+
get key() {
|
|
24
|
+
return props.key;
|
|
25
|
+
},
|
|
26
|
+
props,
|
|
27
|
+
type: TableHeader
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
TableHeader.getCollectionNode = function* getCollectionNode(props, context) {
|
|
31
|
+
if (!isTableCollectionContext(context)) throw new Error("Table collection context is required.");
|
|
32
|
+
const { children, columns } = props;
|
|
33
|
+
context.columns = [];
|
|
34
|
+
if (typeof children === "function") {
|
|
35
|
+
if (!columns) throw new Error("props.children was a function but props.columns is missing");
|
|
36
|
+
for (const column of columns) yield {
|
|
37
|
+
renderer: children,
|
|
38
|
+
type: "column",
|
|
39
|
+
value: column
|
|
40
|
+
};
|
|
41
|
+
} else {
|
|
42
|
+
const localColumns = [];
|
|
43
|
+
for (const column of collectionChildren(children)) localColumns.push({
|
|
44
|
+
element: column,
|
|
45
|
+
type: "column"
|
|
46
|
+
});
|
|
47
|
+
yield* localColumns;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export { TableHeader };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=table-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-header.js","names":[],"sources":["../../src/table/table-header.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/table/TableHeader.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 { Key } from \"@solid2-aria/types-shared\";\nimport type { Element as SolidElement } from \"solid-js\";\n\nimport type { PartialNode, CollectionContext } from \"../collections/types\";\nimport { collectionChildren } from \"../collections/types\";\nimport { isTableCollectionContext } from \"./collection-context\";\nimport type { ColumnElement, ColumnRenderer } from \"./column\";\n\nexport interface TableHeaderProps<T> {\n key?: Key;\n \"aria-label\"?: string;\n /** A list of table columns. */\n columns?: readonly T[];\n /**\n * A list of `Column(s)` or a function. If the latter, a list of columns must be provided using\n * the `columns` prop.\n */\n children: ColumnElement<T> | ColumnElement<T>[] | ColumnRenderer<T>;\n}\n\nfunction TableHeader<T>(props: TableHeaderProps<T>): SolidElement {\n return Object.assign([], {\n getCollectionNode: (context: CollectionContext) =>\n TableHeader.getCollectionNode(props, context),\n get key() {\n return props.key;\n },\n props,\n type: TableHeader,\n });\n}\n\nTableHeader.getCollectionNode = function* getCollectionNode<T>(\n props: TableHeaderProps<T>,\n context: CollectionContext\n): Generator<PartialNode<T>, void> {\n if (!isTableCollectionContext<T>(context)) {\n throw new Error(\"Table collection context is required.\");\n }\n\n const { children, columns } = props;\n // Clear columns so they aren't double added in strict mode.\n context.columns = [];\n\n if (typeof children === \"function\") {\n if (!columns) {\n throw new Error(\n \"props.children was a function but props.columns is missing\"\n );\n }\n\n for (const column of columns) {\n yield {\n renderer: children,\n type: \"column\",\n value: column,\n };\n }\n } else {\n const localColumns: PartialNode<T>[] = [];\n\n for (const column of collectionChildren(children)) {\n localColumns.push({\n element: column,\n type: \"column\",\n });\n }\n\n yield* localColumns;\n }\n};\n\n/**\n * A TableHeader is a container for the Column elements in a Table. Columns can be statically\n * defined as children, or generated dynamically using a function based on the data passed to the\n * `columns` prop.\n */\n// We don't want getCollectionNode to show up in the type definition\nexport { TableHeader };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,SAAS,YAAe,OAA0C;CAChE,OAAO,OAAO,OAAO,CAAC,GAAG;EACvB,oBAAoB,YAClB,YAAY,kBAAkB,OAAO,OAAO;EAC9C,IAAI,MAAM;GACR,OAAO,MAAM;EACf;EACA;EACA,MAAM;CACR,CAAC;AACH;AAEA,YAAY,oBAAoB,UAAU,kBACxC,OACA,SACiC;CACjC,IAAI,CAAC,yBAA4B,OAAO,GACtC,MAAM,IAAI,MAAM,uCAAuC;CAGzD,MAAM,EAAE,UAAU,YAAY;CAE9B,QAAQ,UAAU,CAAC;CAEnB,IAAI,OAAO,aAAa,YAAY;EAClC,IAAI,CAAC,SACH,MAAM,IAAI,MACR,4DACF;EAGF,KAAK,MAAM,UAAU,SACnB,MAAM;GACJ,UAAU;GACV,MAAM;GACN,OAAO;EACT;CAEJ,OAAO;EACL,MAAM,eAAiC,CAAC;EAExC,KAAK,MAAM,UAAU,mBAAmB,QAAQ,GAC9C,aAAa,KAAK;GAChB,SAAS;GACT,MAAM;EACR,CAAC;EAGH,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 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/table/TableUtils.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 { ColumnSize } from "./column.js";
|
|
18
|
+
import { Key } from "@solid2-aria/types-shared";
|
|
19
|
+
export declare function isStatic(width?: string | number | null): boolean;
|
|
20
|
+
export declare function parseFractionalUnit(width?: string | number | null): number;
|
|
21
|
+
export declare function parseStaticWidth(width: number | string, tableWidth: number): number;
|
|
22
|
+
export declare function getMaxWidth(maxWidth: number | string | null | undefined, tableWidth: number): number;
|
|
23
|
+
export declare function getMinWidth(minWidth: number | string | null | undefined, tableWidth: number): number;
|
|
24
|
+
export interface IColumn {
|
|
25
|
+
minWidth?: number | string;
|
|
26
|
+
maxWidth?: number | string;
|
|
27
|
+
width?: number | string;
|
|
28
|
+
defaultWidth?: number | string;
|
|
29
|
+
key: Key;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Implements the flex algorithm described in https://www.w3.org/TR/css-flexbox-1/#layout-algorithm
|
|
33
|
+
* It makes a few constraint/assumptions: 1. All basis values are 0 unless it is a static width,
|
|
34
|
+
* then the basis is the static width 2. All flex grow and shrink values are equal to the FR
|
|
35
|
+
* specified on the column, grow and shrink for the same column are equal 3. We only have one row An
|
|
36
|
+
* example of the setup can be seen here https://jsfiddle.net/snowystinger/wv0ymjaf/61/ where I let
|
|
37
|
+
* the browser figure out the flex of the columns. Note: We differ in one key aspect, all of our
|
|
38
|
+
* column widths must be whole numbers, so we avoid browser sub pixel rounding errors. To do this,
|
|
39
|
+
* we use a cascading rounding algorithm to ensure that the sum of the widths is maintained while
|
|
40
|
+
* distributing the rounding remainder across the columns.
|
|
41
|
+
*
|
|
42
|
+
* As noted in the chrome source code, this algorithm is very accurate, but has the potential to be
|
|
43
|
+
* quadratic. They have deemed this to be acceptable because the number of elements is usually small
|
|
44
|
+
* and the flex factors are usually not high variance. I believe we can make the same assumptions.
|
|
45
|
+
* Particularly once resizing is started, it will convert all columns to the left to static widths,
|
|
46
|
+
* so it will cut down on the number of FR columns.
|
|
47
|
+
*
|
|
48
|
+
* There are likely faster ways to do this, I've chosen to stick to the spec as closely as possible
|
|
49
|
+
* for readability, accuracy, and for the note that this behaving quadratically is unlikely to be a
|
|
50
|
+
* problem.
|
|
51
|
+
*
|
|
52
|
+
* @param availableWidth - The visible width of the table.
|
|
53
|
+
* @param columns - The table defined columns.
|
|
54
|
+
* @param changedColumns - Any columns we want to override, for example, during resizing.
|
|
55
|
+
* @param getDefaultWidth - A function that returns the default width of a column by its index.
|
|
56
|
+
* @param getDefaultMinWidth - A function that returns the default min width of a column by its
|
|
57
|
+
* index.
|
|
58
|
+
*/
|
|
59
|
+
export declare function calculateColumnSizes(initialAvailableWidth: number, columns: IColumn[], changedColumns: Map<Key, ColumnSize>, getDefaultWidth?: (index: number) => ColumnSize | null | undefined, getDefaultMinWidth?: (index: number) => ColumnSize | null | undefined): number[];
|
|
60
|
+
//# sourceMappingURL=table-utils.d.ts.map
|