@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,449 @@
|
|
|
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/datepicker/useDateFieldState.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted reactive state, getters, imports, and APIs for Solid 2.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
import { createControlledSignal } from "../utils/create-controlled-signal.js";
|
|
18
|
+
import { getLegacyValidationState } from "../utils/legacy-props.js";
|
|
19
|
+
import { parseCalendarIdentifier } from "../utils/parse-calendar-identifier.js";
|
|
20
|
+
import { createFormValidationState } from "../form/create-form-validation-state.js";
|
|
21
|
+
import { requireValue } from "../utils/require-value.js";
|
|
22
|
+
import { IncompleteDate } from "./incomplete-date.js";
|
|
23
|
+
import { getPlaceholder } from "./placeholders.js";
|
|
24
|
+
import { convertValue, createDefaultProps, createPlaceholderDate, getFormatOptions, getValidationResult } from "./utils.js";
|
|
25
|
+
import { createMemo, createRenderEffect, createSignal, merge, untrack } from "solid-js";
|
|
26
|
+
import { DateFormatter, GregorianCalendar, isEqualCalendar, toCalendar } from "@internationalized/date";
|
|
27
|
+
import { NumberFormatter } from "@internationalized/number";
|
|
28
|
+
// src/datepicker/create-date-field-state.ts
|
|
29
|
+
const EDITABLE_SEGMENTS = {
|
|
30
|
+
day: true,
|
|
31
|
+
dayPeriod: true,
|
|
32
|
+
era: true,
|
|
33
|
+
hour: true,
|
|
34
|
+
minute: true,
|
|
35
|
+
month: true,
|
|
36
|
+
second: true,
|
|
37
|
+
year: true
|
|
38
|
+
};
|
|
39
|
+
const PAGE_STEP = {
|
|
40
|
+
day: 7,
|
|
41
|
+
hour: 2,
|
|
42
|
+
minute: 15,
|
|
43
|
+
month: 2,
|
|
44
|
+
second: 15,
|
|
45
|
+
year: 5
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Provides state management for a date field component.
|
|
49
|
+
* A date field allows users to enter and edit date and time values using a keyboard.
|
|
50
|
+
* Each part of a date value is displayed in an individually editable segment.
|
|
51
|
+
*/
|
|
52
|
+
function createDateFieldState(props) {
|
|
53
|
+
const locale = createMemo(() => props.locale);
|
|
54
|
+
const createCalendar = createMemo(() => props.createCalendar);
|
|
55
|
+
const hideTimeZone = createMemo(() => props.hideTimeZone);
|
|
56
|
+
const isDisabled = createMemo(() => props.isDisabled ?? false);
|
|
57
|
+
const isReadOnly = createMemo(() => props.isReadOnly ?? false);
|
|
58
|
+
const isRequired = createMemo(() => props.isRequired ?? false);
|
|
59
|
+
const minValue = createMemo(() => props.minValue);
|
|
60
|
+
const maxValue = createMemo(() => props.maxValue);
|
|
61
|
+
const isDateUnavailable = createMemo(() => props.isDateUnavailable);
|
|
62
|
+
const v = createMemo(() => props.value ?? props.defaultValue ?? props.placeholderValue ?? null);
|
|
63
|
+
const derived1 = createDefaultProps(v, () => props.granularity);
|
|
64
|
+
const granularity = createMemo(() => {
|
|
65
|
+
const [currentGranularity] = derived1();
|
|
66
|
+
const currentValue = v();
|
|
67
|
+
if (currentValue && !(currentGranularity in currentValue)) throw new Error(`Invalid granularity ${currentGranularity} for value ${currentValue.toString()}`);
|
|
68
|
+
return currentGranularity;
|
|
69
|
+
});
|
|
70
|
+
const defaultTimeZone = createMemo(() => {
|
|
71
|
+
return derived1()[1];
|
|
72
|
+
});
|
|
73
|
+
const timeZone = createMemo(() => {
|
|
74
|
+
return defaultTimeZone() ?? "UTC";
|
|
75
|
+
});
|
|
76
|
+
const derived2 = createMemo(() => {
|
|
77
|
+
const currentLocale = locale();
|
|
78
|
+
const currentCreateCalendar = createCalendar();
|
|
79
|
+
const opts = new DateFormatter(currentLocale, {
|
|
80
|
+
dateStyle: "short",
|
|
81
|
+
hour12: props.hourCycle !== null && props.hourCycle !== void 0 ? props.hourCycle === 12 : void 0,
|
|
82
|
+
timeStyle: "short"
|
|
83
|
+
}).resolvedOptions();
|
|
84
|
+
return [currentCreateCalendar(parseCalendarIdentifier(opts.calendar)), opts.hourCycle];
|
|
85
|
+
});
|
|
86
|
+
const calendar = createMemo(() => {
|
|
87
|
+
return derived2()[0];
|
|
88
|
+
});
|
|
89
|
+
const hourCycle = createMemo(() => {
|
|
90
|
+
return derived2()[1];
|
|
91
|
+
});
|
|
92
|
+
const [value, setDate] = createControlledSignal(() => props.value, untrack(() => props.defaultValue ?? null), (localValue) => props.onChange?.(localValue));
|
|
93
|
+
const initialValue = untrack(() => value());
|
|
94
|
+
const calendarValue = createMemo(() => {
|
|
95
|
+
const currentValue = value();
|
|
96
|
+
const currentCalendar = calendar();
|
|
97
|
+
return convertValue(currentValue, currentCalendar) ?? null;
|
|
98
|
+
});
|
|
99
|
+
const [displayValue, setDisplayValue] = createSignal(untrack(() => (() => {
|
|
100
|
+
const currentCalendar = calendar();
|
|
101
|
+
const currentHourCycle = hourCycle();
|
|
102
|
+
const currentCalendarValue = calendarValue();
|
|
103
|
+
return new IncompleteDate(currentCalendar, currentHourCycle ?? "h23", currentCalendarValue);
|
|
104
|
+
})()), { ownedWrite: true });
|
|
105
|
+
const showEra = createMemo(() => {
|
|
106
|
+
const currentCalendar = calendar();
|
|
107
|
+
const currentDisplayValue = displayValue();
|
|
108
|
+
return currentCalendar.identifier === "gregory" && currentDisplayValue.era === "BC";
|
|
109
|
+
});
|
|
110
|
+
const formatOpts = createMemo(() => {
|
|
111
|
+
const currentGranularity = granularity();
|
|
112
|
+
const currentDefaultTimeZone = defaultTimeZone();
|
|
113
|
+
const currentHideTimeZone = hideTimeZone();
|
|
114
|
+
const currentShowEra = showEra();
|
|
115
|
+
return {
|
|
116
|
+
granularity: currentGranularity,
|
|
117
|
+
hideTimeZone: currentHideTimeZone,
|
|
118
|
+
hourCycle: props.hourCycle,
|
|
119
|
+
maxGranularity: props.maxGranularity ?? "year",
|
|
120
|
+
shouldForceLeadingZeros: props.shouldForceLeadingZeros,
|
|
121
|
+
showEra: currentShowEra,
|
|
122
|
+
timeZone: currentDefaultTimeZone
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
const opts = createMemo(() => {
|
|
126
|
+
const currentFormatOpts = formatOpts();
|
|
127
|
+
return getFormatOptions({}, currentFormatOpts);
|
|
128
|
+
});
|
|
129
|
+
const dateFormatter = createMemo(() => {
|
|
130
|
+
const currentLocale = locale();
|
|
131
|
+
const currentOpts = opts();
|
|
132
|
+
return new DateFormatter(currentLocale, currentOpts);
|
|
133
|
+
});
|
|
134
|
+
const resolvedOptions = createMemo(() => {
|
|
135
|
+
return dateFormatter().resolvedOptions();
|
|
136
|
+
});
|
|
137
|
+
const placeholder = createMemo(() => {
|
|
138
|
+
const currentGranularity = granularity();
|
|
139
|
+
const currentCalendar = calendar();
|
|
140
|
+
const currentDefaultTimeZone = defaultTimeZone();
|
|
141
|
+
return createPlaceholderDate(props.placeholderValue, currentGranularity, currentCalendar, currentDefaultTimeZone);
|
|
142
|
+
});
|
|
143
|
+
const displaySegments = createMemo(() => {
|
|
144
|
+
const currentHourCycle = hourCycle();
|
|
145
|
+
const currentGranularity = granularity();
|
|
146
|
+
const is12HourClock = currentHourCycle === "h11" || currentHourCycle === "h12";
|
|
147
|
+
const segments = [
|
|
148
|
+
"era",
|
|
149
|
+
"year",
|
|
150
|
+
"month",
|
|
151
|
+
"day",
|
|
152
|
+
"hour",
|
|
153
|
+
...is12HourClock ? ["dayPeriod"] : [],
|
|
154
|
+
"minute",
|
|
155
|
+
"second"
|
|
156
|
+
];
|
|
157
|
+
const minIndex = segments.indexOf(props.maxGranularity ?? "era");
|
|
158
|
+
const maxIndex = segments.indexOf(currentGranularity === "hour" && is12HourClock ? "dayPeriod" : currentGranularity);
|
|
159
|
+
return segments.slice(minIndex, maxIndex + 1);
|
|
160
|
+
});
|
|
161
|
+
const [lastValue, setLastValue] = createSignal(untrack(() => calendarValue()), { ownedWrite: true });
|
|
162
|
+
const [lastCalendar, setLastCalendar] = createSignal(untrack(() => calendar()), { ownedWrite: true });
|
|
163
|
+
const [lastHourCycle, setLastHourCycle] = createSignal(untrack(() => hourCycle()), { ownedWrite: true });
|
|
164
|
+
createRenderEffect(() => ({
|
|
165
|
+
currentCalendar: calendar(),
|
|
166
|
+
currentCalendarValue: calendarValue(),
|
|
167
|
+
currentHourCycle: hourCycle(),
|
|
168
|
+
currentLastCalendar: lastCalendar(),
|
|
169
|
+
currentLastHourCycle: lastHourCycle(),
|
|
170
|
+
currentLastValue: lastValue()
|
|
171
|
+
}), ({ currentCalendarValue, currentLastValue, currentHourCycle, currentLastHourCycle, currentCalendar, currentLastCalendar }) => {
|
|
172
|
+
if (currentCalendarValue !== currentLastValue || currentHourCycle !== currentLastHourCycle || !isEqualCalendar(currentCalendar, currentLastCalendar)) {
|
|
173
|
+
setDisplayValue(new IncompleteDate(currentCalendar, currentHourCycle ?? "h23", currentCalendarValue));
|
|
174
|
+
setLastValue(currentCalendarValue);
|
|
175
|
+
setLastCalendar(currentCalendar);
|
|
176
|
+
setLastHourCycle(currentHourCycle);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
const setValue = (initialNewValue) => {
|
|
180
|
+
let newValue = initialNewValue;
|
|
181
|
+
const currentDisplaySegments = displaySegments();
|
|
182
|
+
const currentCalendar = calendar();
|
|
183
|
+
const currentHourCycle = hourCycle();
|
|
184
|
+
const currentCalendarValue = calendarValue();
|
|
185
|
+
const currentV = v();
|
|
186
|
+
const currentPlaceholder = placeholder();
|
|
187
|
+
const currentValue = value();
|
|
188
|
+
if (props.isDisabled === true || props.isReadOnly === true) return;
|
|
189
|
+
if (newValue === null || newValue === void 0 || newValue instanceof IncompleteDate && newValue.isCleared(currentDisplaySegments)) {
|
|
190
|
+
setDisplayValue(new IncompleteDate(currentCalendar, currentHourCycle ?? "h23", currentCalendarValue));
|
|
191
|
+
setDate(null);
|
|
192
|
+
} else if (newValue instanceof IncompleteDate) {
|
|
193
|
+
if (newValue.isComplete(currentDisplaySegments)) {
|
|
194
|
+
const dateValue = newValue.toValue(currentCalendarValue ?? currentPlaceholder);
|
|
195
|
+
if (newValue.validate(dateValue, currentDisplaySegments)) {
|
|
196
|
+
const newDateValue = toCalendar(dateValue, currentV?.calendar ?? new GregorianCalendar());
|
|
197
|
+
if (!currentValue || newDateValue.compare(currentValue) !== 0) {
|
|
198
|
+
setDisplayValue(new IncompleteDate(currentCalendar, currentHourCycle ?? "h23", currentCalendarValue));
|
|
199
|
+
setDate(newDateValue);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
setDisplayValue(newValue);
|
|
205
|
+
} else {
|
|
206
|
+
newValue = toCalendar(newValue, currentV?.calendar ?? new GregorianCalendar());
|
|
207
|
+
setDisplayValue(new IncompleteDate(currentCalendar, currentHourCycle ?? "h23", currentCalendarValue));
|
|
208
|
+
setDate(newValue);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const dateValue = createMemo(() => {
|
|
212
|
+
const currentDisplayValue = displayValue();
|
|
213
|
+
const currentCalendarValue = calendarValue();
|
|
214
|
+
const currentPlaceholder = placeholder();
|
|
215
|
+
const currentTimeZone = timeZone();
|
|
216
|
+
return currentDisplayValue.toValue(currentCalendarValue ?? currentPlaceholder).toDate(currentTimeZone);
|
|
217
|
+
});
|
|
218
|
+
const segments = createMemo(() => {
|
|
219
|
+
return processSegments(dateValue(), displayValue(), dateFormatter(), resolvedOptions(), calendar(), locale(), granularity());
|
|
220
|
+
});
|
|
221
|
+
const adjustSegment = (type, amount) => {
|
|
222
|
+
const currentDisplayValue = displayValue();
|
|
223
|
+
const currentPlaceholder = placeholder();
|
|
224
|
+
const currentDisplaySegments = displaySegments();
|
|
225
|
+
setValue(currentDisplayValue.cycle(type, amount, currentPlaceholder, currentDisplaySegments));
|
|
226
|
+
};
|
|
227
|
+
const builtinValidation = createMemo(() => {
|
|
228
|
+
const currentValue = value();
|
|
229
|
+
const currentMinValue = minValue();
|
|
230
|
+
const currentMaxValue = maxValue();
|
|
231
|
+
const currentIsDateUnavailable = isDateUnavailable();
|
|
232
|
+
const currentFormatOpts = formatOpts();
|
|
233
|
+
return getValidationResult(currentValue, currentMinValue, currentMaxValue, currentIsDateUnavailable, currentFormatOpts);
|
|
234
|
+
});
|
|
235
|
+
const validation = createFormValidationState(merge(props, {
|
|
236
|
+
get builtinValidation() {
|
|
237
|
+
return builtinValidation();
|
|
238
|
+
},
|
|
239
|
+
validate: (localValue) => props.validate?.(localValue),
|
|
240
|
+
get value() {
|
|
241
|
+
return value();
|
|
242
|
+
}
|
|
243
|
+
}));
|
|
244
|
+
const isValueInvalid = createMemo(() => validation.displayValidation.isInvalid);
|
|
245
|
+
const validationState = createMemo(() => {
|
|
246
|
+
const currentIsValueInvalid = isValueInvalid();
|
|
247
|
+
return getLegacyValidationState(props) ?? (currentIsValueInvalid ? "invalid" : null);
|
|
248
|
+
});
|
|
249
|
+
return merge(validation, {
|
|
250
|
+
get calendar() {
|
|
251
|
+
return calendar();
|
|
252
|
+
},
|
|
253
|
+
clearSegment(part) {
|
|
254
|
+
const currentDisplayValue = displayValue();
|
|
255
|
+
let localValue = currentDisplayValue;
|
|
256
|
+
if (part !== "timeZoneName" && part !== "literal") localValue = currentDisplayValue.clear(part);
|
|
257
|
+
setValue(localValue);
|
|
258
|
+
},
|
|
259
|
+
confirmPlaceholder() {
|
|
260
|
+
const currentDisplayValue = displayValue();
|
|
261
|
+
const currentDisplaySegments = displaySegments();
|
|
262
|
+
const currentCalendarValue = calendarValue();
|
|
263
|
+
const currentPlaceholder = placeholder();
|
|
264
|
+
const currentV = v();
|
|
265
|
+
const currentValue = value();
|
|
266
|
+
const currentCalendar = calendar();
|
|
267
|
+
const currentHourCycle = hourCycle();
|
|
268
|
+
if (props.isDisabled === true || props.isReadOnly === true) return;
|
|
269
|
+
if (currentDisplayValue.isComplete(currentDisplaySegments)) {
|
|
270
|
+
const localDateValue = currentDisplayValue.toValue(currentCalendarValue ?? currentPlaceholder);
|
|
271
|
+
const newDateValue = toCalendar(localDateValue, currentV?.calendar ?? new GregorianCalendar());
|
|
272
|
+
if (!currentValue || newDateValue.compare(currentValue) !== 0) setDate(newDateValue);
|
|
273
|
+
setDisplayValue(new IncompleteDate(currentCalendar, currentHourCycle ?? "h23", currentCalendarValue));
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
get dateFormatter() {
|
|
277
|
+
return dateFormatter();
|
|
278
|
+
},
|
|
279
|
+
get dateValue() {
|
|
280
|
+
return dateValue();
|
|
281
|
+
},
|
|
282
|
+
decrement(part) {
|
|
283
|
+
adjustSegment(part, -1);
|
|
284
|
+
},
|
|
285
|
+
decrementPage(part) {
|
|
286
|
+
adjustSegment(part, -(PAGE_STEP[part] ?? 1));
|
|
287
|
+
},
|
|
288
|
+
decrementToMin(part) {
|
|
289
|
+
const currentHourCycle = hourCycle();
|
|
290
|
+
const currentDisplayValue = displayValue();
|
|
291
|
+
const currentPlaceholder = placeholder();
|
|
292
|
+
const localMinValue = part === "hour" && currentHourCycle === "h12" ? 12 : requireValue(currentDisplayValue.getSegmentLimits(part), "Expected currentDisplayValue.getSegmentLimits(part) to exist.").minValue;
|
|
293
|
+
setValue(currentDisplayValue.set(part, localMinValue, currentPlaceholder));
|
|
294
|
+
},
|
|
295
|
+
get defaultValue() {
|
|
296
|
+
return props.defaultValue ?? initialValue;
|
|
297
|
+
},
|
|
298
|
+
formatValue(fieldOptions) {
|
|
299
|
+
const currentCalendarValue = calendarValue();
|
|
300
|
+
const currentFormatOpts = formatOpts();
|
|
301
|
+
const currentLocale = locale();
|
|
302
|
+
const currentDateValue = dateValue();
|
|
303
|
+
if (!currentCalendarValue) return "";
|
|
304
|
+
const formatOptions = getFormatOptions(fieldOptions, currentFormatOpts);
|
|
305
|
+
return new DateFormatter(currentLocale, formatOptions).format(currentDateValue);
|
|
306
|
+
},
|
|
307
|
+
getDateFormatter(localLocale, formatOptions) {
|
|
308
|
+
const newOptions = {
|
|
309
|
+
...formatOpts(),
|
|
310
|
+
...formatOptions
|
|
311
|
+
};
|
|
312
|
+
const newFormatOptions = getFormatOptions({}, newOptions);
|
|
313
|
+
return new DateFormatter(localLocale, newFormatOptions);
|
|
314
|
+
},
|
|
315
|
+
get granularity() {
|
|
316
|
+
return granularity();
|
|
317
|
+
},
|
|
318
|
+
increment(part) {
|
|
319
|
+
adjustSegment(part, 1);
|
|
320
|
+
},
|
|
321
|
+
incrementPage(part) {
|
|
322
|
+
adjustSegment(part, PAGE_STEP[part] ?? 1);
|
|
323
|
+
},
|
|
324
|
+
incrementToMax(part) {
|
|
325
|
+
const currentHourCycle = hourCycle();
|
|
326
|
+
const currentDisplayValue = displayValue();
|
|
327
|
+
const currentPlaceholder = placeholder();
|
|
328
|
+
const localMaxValue = part === "hour" && currentHourCycle === "h12" ? 11 : requireValue(currentDisplayValue.getSegmentLimits(part), "Expected currentDisplayValue.getSegmentLimits(part) to exist.").maxValue;
|
|
329
|
+
setValue(currentDisplayValue.set(part, localMaxValue, currentPlaceholder));
|
|
330
|
+
},
|
|
331
|
+
get isDisabled() {
|
|
332
|
+
return isDisabled();
|
|
333
|
+
},
|
|
334
|
+
get isInvalid() {
|
|
335
|
+
return isValueInvalid();
|
|
336
|
+
},
|
|
337
|
+
get isReadOnly() {
|
|
338
|
+
return isReadOnly();
|
|
339
|
+
},
|
|
340
|
+
get isRequired() {
|
|
341
|
+
return isRequired();
|
|
342
|
+
},
|
|
343
|
+
get maxGranularity() {
|
|
344
|
+
return props.maxGranularity ?? "year";
|
|
345
|
+
},
|
|
346
|
+
get segments() {
|
|
347
|
+
return segments();
|
|
348
|
+
},
|
|
349
|
+
setSegment(part, localV) {
|
|
350
|
+
const currentDisplayValue = displayValue();
|
|
351
|
+
const currentPlaceholder = placeholder();
|
|
352
|
+
setValue(currentDisplayValue.set(part, localV, currentPlaceholder));
|
|
353
|
+
},
|
|
354
|
+
setValue,
|
|
355
|
+
get validationState() {
|
|
356
|
+
return validationState();
|
|
357
|
+
},
|
|
358
|
+
get value() {
|
|
359
|
+
return calendarValue();
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function processSegments(dateValue, displayValue, dateFormatter, resolvedOptions, calendar, locale, granularity) {
|
|
364
|
+
const timeValue = /* @__PURE__ */ new Set([
|
|
365
|
+
"hour",
|
|
366
|
+
"minute",
|
|
367
|
+
"second"
|
|
368
|
+
]);
|
|
369
|
+
const segments = dateFormatter.formatToParts(dateValue);
|
|
370
|
+
formatNumericSegments(segments, displayValue, resolvedOptions, locale);
|
|
371
|
+
const processedSegments = [];
|
|
372
|
+
for (const segment of segments) {
|
|
373
|
+
const mapped = mapDateSegmentType(segment.type);
|
|
374
|
+
const type = isDateSegmentType(mapped) ? mapped : "literal";
|
|
375
|
+
let isEditable = type in EDITABLE_SEGMENTS;
|
|
376
|
+
if (type === "era" && calendar.getEras().length === 1) isEditable = false;
|
|
377
|
+
const isPlaceholder = type !== "literal" && type !== "timeZoneName" && (displayValue[type] === null || displayValue[type] === void 0);
|
|
378
|
+
const placeholder = type in EDITABLE_SEGMENTS ? getPlaceholder(type, segment.value, locale) : null;
|
|
379
|
+
const dateSegment = {
|
|
380
|
+
text: isPlaceholder ? placeholder ?? "" : segment.value,
|
|
381
|
+
type,
|
|
382
|
+
...displayValue.getSegmentLimits(type),
|
|
383
|
+
isEditable,
|
|
384
|
+
isPlaceholder,
|
|
385
|
+
placeholder: placeholder ?? ""
|
|
386
|
+
};
|
|
387
|
+
if (type === "hour") {
|
|
388
|
+
processedSegments.push({
|
|
389
|
+
isEditable: false,
|
|
390
|
+
isPlaceholder: false,
|
|
391
|
+
placeholder: "",
|
|
392
|
+
text: "",
|
|
393
|
+
type: "literal"
|
|
394
|
+
}, dateSegment);
|
|
395
|
+
if (type === granularity) processedSegments.push({
|
|
396
|
+
isEditable: false,
|
|
397
|
+
isPlaceholder: false,
|
|
398
|
+
placeholder: "",
|
|
399
|
+
text: "",
|
|
400
|
+
type: "literal"
|
|
401
|
+
});
|
|
402
|
+
} else if (timeValue.has(type) && type === granularity) processedSegments.push(dateSegment, {
|
|
403
|
+
isEditable: false,
|
|
404
|
+
isPlaceholder: false,
|
|
405
|
+
placeholder: "",
|
|
406
|
+
text: "",
|
|
407
|
+
type: "literal"
|
|
408
|
+
});
|
|
409
|
+
else processedSegments.push(dateSegment);
|
|
410
|
+
}
|
|
411
|
+
return processedSegments;
|
|
412
|
+
}
|
|
413
|
+
function isDateSegmentType(value) {
|
|
414
|
+
return [
|
|
415
|
+
"era",
|
|
416
|
+
"year",
|
|
417
|
+
"month",
|
|
418
|
+
"day",
|
|
419
|
+
"hour",
|
|
420
|
+
"minute",
|
|
421
|
+
"second",
|
|
422
|
+
"dayPeriod",
|
|
423
|
+
"timeZoneName",
|
|
424
|
+
"literal"
|
|
425
|
+
].includes(value);
|
|
426
|
+
}
|
|
427
|
+
function mapDateSegmentType(type) {
|
|
428
|
+
switch (type) {
|
|
429
|
+
case "dayperiod": return "dayPeriod";
|
|
430
|
+
case "relatedYear":
|
|
431
|
+
case "yearName": return "year";
|
|
432
|
+
case "unknown": return "literal";
|
|
433
|
+
default: return type;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function formatNumericSegments(segments, displayValue, resolvedOptions, locale) {
|
|
437
|
+
const numberFormatter = new NumberFormatter(locale, { useGrouping: false });
|
|
438
|
+
const twoDigitFormatter = new NumberFormatter(locale, {
|
|
439
|
+
minimumIntegerDigits: 2,
|
|
440
|
+
useGrouping: false
|
|
441
|
+
});
|
|
442
|
+
for (const segment of segments) if (segment.type === "year" || segment.type === "month" || segment.type === "day" || segment.type === "hour") {
|
|
443
|
+
const value = displayValue[segment.type] ?? 0;
|
|
444
|
+
segment.value = resolvedOptions[segment.type] === "2-digit" ? twoDigitFormatter.format(value) : numberFormatter.format(value);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
export { createDateFieldState };
|
|
448
|
+
|
|
449
|
+
//# sourceMappingURL=create-date-field-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-date-field-state.js","names":[],"sources":["../../src/datepicker/create-date-field-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/datepicker/useDateFieldState.ts.\n * Modified for Solid Aria: adapted reactive state, getters, imports, and APIs for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport {\n DateFormatter,\n GregorianCalendar,\n isEqualCalendar,\n toCalendar,\n} from \"@internationalized/date\";\nimport type { Calendar, CalendarIdentifier } from \"@internationalized/date\";\nimport { NumberFormatter } from \"@internationalized/number\";\nimport type { ValidationState } from \"@solid2-aria/types-shared\";\nimport {\n createMemo,\n createSignal,\n createRenderEffect,\n untrack,\n merge,\n} from \"solid-js\";\n\nimport { createFormValidationState } 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\";\nimport { parseCalendarIdentifier } from \"../utils/parse-calendar-identifier\";\nimport { requireValue } from \"../utils/require-value\";\nimport { IncompleteDate } from \"./incomplete-date\";\nimport { getPlaceholder } from \"./placeholders\";\nimport type {\n DatePickerProps,\n DateValue,\n Granularity,\n MappedDateValue,\n} from \"./types\";\nimport {\n convertValue,\n createPlaceholderDate,\n getFormatOptions,\n getValidationResult,\n createDefaultProps,\n} from \"./utils\";\nimport type { FieldOptions, FormatterOptions } from \"./utils\";\n\nexport type DateSegmentType =\n | \"era\"\n | \"year\"\n | \"month\"\n | \"day\"\n | \"hour\"\n | \"minute\"\n | \"second\"\n | \"dayPeriod\"\n | \"literal\"\n | \"timeZoneName\";\n\nexport interface DateSegment {\n /** The type of segment. */\n type: DateSegmentType;\n /** The formatted text for the segment. */\n text: string;\n /** The numeric value for the segment, if applicable. */\n value?: number | null;\n /** The minimum numeric value for the segment, if applicable. */\n minValue?: number;\n /** The maximum numeric value for the segment, if applicable. */\n maxValue?: number;\n /** Whether the value is a placeholder. */\n isPlaceholder: boolean;\n /** A placeholder string for the segment. */\n placeholder: string;\n /** Whether the segment is editable. */\n isEditable: boolean;\n}\n\nexport interface DateFieldState extends FormValidationState {\n /** The current field value. */\n value: DateValue | null;\n /** The default field value. */\n defaultValue: DateValue | null;\n /** The current value, converted to a native JavaScript `Date` object. */\n dateValue: Date;\n /** The calendar system currently in use. */\n calendar: Calendar;\n /** Sets the field's value. */\n setValue: (value: DateValue | null) => void;\n /** A list of segments for the current value. */\n segments: DateSegment[];\n /** A date formatter configured for the current locale and format. */\n dateFormatter: DateFormatter;\n /**\n * The current validation state of the date field, based on the `validationState`, `minValue`, and\n * `maxValue` props.\n *\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null;\n /** Whether the date field is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean;\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity;\n /** The maximum date or time unit that is displayed in the field. */\n maxGranularity: \"year\" | \"month\" | Granularity;\n /** Whether the field is disabled. */\n isDisabled: boolean;\n /** Whether the field is read only. */\n isReadOnly: boolean;\n /** Whether the field is required. */\n isRequired: boolean;\n /**\n * Increments the given segment. Upon reaching the minimum or maximum value, the value wraps\n * around to the opposite limit.\n */\n increment: (type: DateSegmentType) => void;\n /**\n * Decrements the given segment. Upon reaching the minimum or maximum value, the value wraps\n * around to the opposite limit.\n */\n decrement: (type: DateSegmentType) => void;\n /**\n * Increments the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n incrementPage: (type: DateSegmentType) => void;\n /**\n * Decrements the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to decrement by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n decrementPage: (type: DateSegmentType) => void;\n /** Increments the given segment to its maxiumum value. */\n incrementToMax: (type: DateSegmentType) => void;\n /** Decrements the given segment to its minimum value. */\n decrementToMin: (type: DateSegmentType) => void;\n /** Sets the value of the given segment. */\n setSegment: {\n (type: \"era\", value: string): void;\n (type: DateSegmentType, value: number): void;\n };\n /** Updates the remaining unfilled segments with the placeholder value. */\n confirmPlaceholder: () => void;\n /** Clears the value of the given segment, reverting it to the placeholder. */\n clearSegment: (type: DateSegmentType) => void;\n /** Formats the current date value using the given options. */\n formatValue: (fieldOptions: FieldOptions) => string;\n /** Gets a formatter based on state's props. */\n getDateFormatter: (\n locale: string,\n formatOptions: FormatterOptions\n ) => DateFormatter;\n}\n\nconst EDITABLE_SEGMENTS = {\n day: true,\n dayPeriod: true,\n era: true,\n hour: true,\n minute: true,\n month: true,\n second: true,\n year: true,\n};\n\nconst PAGE_STEP: Partial<Record<DateSegmentType, number>> = {\n day: 7,\n hour: 2,\n minute: 15,\n month: 2,\n second: 15,\n year: 5,\n};\n\nexport interface DateFieldStateOptions<\n T extends DateValue = DateValue,\n> extends DatePickerProps<T> {\n /**\n * The maximum unit to display in the date field.\n *\n * @default 'year'\n */\n maxGranularity?: \"year\" | \"month\" | Granularity;\n /** The locale to display and edit the value according to. */\n locale: string;\n /**\n * A function that creates a [Calendar](../internationalized/date/Calendar.html)\n * object for a given calendar identifier. Such a function may be imported from the\n * `@internationalized/date` package, or manually implemented to include support for\n * only certain calendars.\n */\n createCalendar: (name: CalendarIdentifier) => Calendar;\n}\n\n/**\n * Provides state management for a date field component.\n * A date field allows users to enter and edit date and time values using a keyboard.\n * Each part of a date value is displayed in an individually editable segment.\n */\nexport function createDateFieldState<T extends DateValue = DateValue>(\n props: DateFieldStateOptions<T>\n): DateFieldState {\n const locale = createMemo(() => props.locale);\n const createCalendar = createMemo(() => props.createCalendar);\n const hideTimeZone = createMemo(() => props.hideTimeZone);\n const isDisabled = createMemo(() => props.isDisabled ?? false);\n const isReadOnly = createMemo(() => props.isReadOnly ?? false);\n const isRequired = createMemo(() => props.isRequired ?? false);\n const minValue = createMemo(() => props.minValue);\n const maxValue = createMemo(() => props.maxValue);\n const isDateUnavailable = createMemo(() => props.isDateUnavailable);\n\n const v = createMemo(\n () => props.value ?? props.defaultValue ?? props.placeholderValue ?? null\n );\n\n const derived1 = createDefaultProps(v, () => props.granularity);\n\n const granularity = createMemo(() => {\n const [currentGranularity] = derived1();\n const currentValue = v();\n\n if (currentValue && !(currentGranularity in currentValue)) {\n throw new Error(\n `Invalid granularity ${currentGranularity} for value ${currentValue.toString()}`\n );\n }\n\n return currentGranularity;\n });\n\n const defaultTimeZone = createMemo(() => {\n const currentDerived1 = derived1();\n\n return currentDerived1[1];\n });\n\n const timeZone = createMemo(() => {\n const currentDefaultTimeZone = defaultTimeZone();\n\n return currentDefaultTimeZone ?? \"UTC\";\n });\n\n // Resolve default hour cycle and calendar system.\n const derived2 = createMemo(() => {\n const currentLocale = locale();\n const currentCreateCalendar = createCalendar();\n\n const formatter = new DateFormatter(currentLocale, {\n dateStyle: \"short\",\n hour12:\n props.hourCycle !== null && props.hourCycle !== undefined\n ? props.hourCycle === 12\n : undefined,\n timeStyle: \"short\",\n });\n\n const opts = formatter.resolvedOptions();\n\n const calendar = currentCreateCalendar(\n parseCalendarIdentifier(opts.calendar)\n );\n\n return [calendar, opts.hourCycle] as const;\n });\n\n // Resolve default hour cycle and calendar system.\n const calendar = createMemo(() => {\n const currentDerived2 = derived2();\n\n return currentDerived2[0];\n });\n\n // Resolve default hour cycle and calendar system.\n const hourCycle = createMemo(() => {\n const currentDerived2 = derived2();\n\n return currentDerived2[1];\n });\n\n const [value, setDate] = createControlledSignal<DateValue | null>(\n () => props.value,\n untrack(() => props.defaultValue ?? null),\n // SAFETY: Date edits preserve the input date/time class; the mapped generic callback widens subclasses to that class.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n (localValue) => props.onChange?.(localValue as MappedDateValue<T> | null)\n );\n\n const initialValue = untrack(() => value());\n\n const calendarValue = createMemo(() => {\n const currentValue = value();\n const currentCalendar = calendar();\n\n return convertValue(currentValue, currentCalendar) ?? null;\n });\n\n const [displayValue, setDisplayValue] = createSignal(\n untrack(() =>\n (() => {\n const currentCalendar = calendar();\n const currentHourCycle = hourCycle();\n const currentCalendarValue = calendarValue();\n\n return new IncompleteDate(\n currentCalendar,\n currentHourCycle ?? \"h23\",\n currentCalendarValue\n );\n })()\n ),\n { ownedWrite: true }\n );\n\n const showEra = createMemo(() => {\n const currentCalendar = calendar();\n const currentDisplayValue = displayValue();\n\n return (\n currentCalendar.identifier === \"gregory\" &&\n currentDisplayValue.era === \"BC\"\n );\n });\n\n const formatOpts = createMemo(() => {\n const currentGranularity = granularity();\n const currentDefaultTimeZone = defaultTimeZone();\n const currentHideTimeZone = hideTimeZone();\n const currentShowEra = showEra();\n\n return {\n granularity: currentGranularity,\n hideTimeZone: currentHideTimeZone,\n hourCycle: props.hourCycle,\n maxGranularity: props.maxGranularity ?? \"year\",\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n showEra: currentShowEra,\n timeZone: currentDefaultTimeZone,\n };\n });\n\n const opts = createMemo(() => {\n const currentFormatOpts = formatOpts();\n\n return getFormatOptions({}, currentFormatOpts);\n });\n\n const dateFormatter = createMemo(() => {\n const currentLocale = locale();\n const currentOpts = opts();\n\n return new DateFormatter(currentLocale, currentOpts);\n });\n\n const resolvedOptions = createMemo(() => {\n const currentDateFormatter = dateFormatter();\n\n return currentDateFormatter.resolvedOptions();\n });\n\n const placeholder = createMemo(() => {\n const currentGranularity = granularity();\n const currentCalendar = calendar();\n const currentDefaultTimeZone = defaultTimeZone();\n\n return createPlaceholderDate(\n props.placeholderValue,\n currentGranularity,\n currentCalendar,\n currentDefaultTimeZone\n );\n });\n\n const displaySegments = createMemo(() => {\n const currentHourCycle = hourCycle();\n const currentGranularity = granularity();\n\n const is12HourClock =\n currentHourCycle === \"h11\" || currentHourCycle === \"h12\";\n\n const segments: DateSegmentType[] = [\n \"era\",\n \"year\",\n \"month\",\n \"day\",\n \"hour\",\n ...(is12HourClock ? [\"dayPeriod\" as const] : []),\n \"minute\",\n \"second\",\n ];\n\n const minIndex = segments.indexOf(props.maxGranularity ?? \"era\");\n\n const maxIndex = segments.indexOf(\n currentGranularity === \"hour\" && is12HourClock\n ? \"dayPeriod\"\n : currentGranularity\n );\n\n return segments.slice(minIndex, maxIndex + 1);\n });\n\n const [lastValue, setLastValue] = createSignal(\n untrack(() => calendarValue()),\n { ownedWrite: true }\n );\n\n const [lastCalendar, setLastCalendar] = createSignal(\n untrack(() => calendar()),\n { ownedWrite: true }\n );\n\n const [lastHourCycle, setLastHourCycle] = createSignal(\n untrack(() => hourCycle()),\n { ownedWrite: true }\n );\n\n createRenderEffect(\n () => ({\n currentCalendar: calendar(),\n currentCalendarValue: calendarValue(),\n currentHourCycle: hourCycle(),\n currentLastCalendar: lastCalendar(),\n currentLastHourCycle: lastHourCycle(),\n currentLastValue: lastValue(),\n }),\n ({\n currentCalendarValue,\n currentLastValue,\n currentHourCycle,\n currentLastHourCycle,\n currentCalendar,\n currentLastCalendar,\n }) => {\n if (\n currentCalendarValue !== currentLastValue ||\n currentHourCycle !== currentLastHourCycle ||\n !isEqualCalendar(currentCalendar, currentLastCalendar)\n ) {\n setDisplayValue(\n new IncompleteDate(\n currentCalendar,\n currentHourCycle ?? \"h23\",\n currentCalendarValue\n )\n );\n setLastValue(currentCalendarValue);\n setLastCalendar(currentCalendar);\n setLastHourCycle(currentHourCycle);\n }\n }\n );\n\n const setValue = (initialNewValue: DateValue | IncompleteDate | null) => {\n let newValue = initialNewValue;\n\n const currentDisplaySegments = displaySegments();\n const currentCalendar = calendar();\n const currentHourCycle = hourCycle();\n const currentCalendarValue = calendarValue();\n const currentV = v();\n const currentPlaceholder = placeholder();\n const currentValue = value();\n\n if (props.isDisabled === true || props.isReadOnly === true) {\n return;\n }\n\n if (\n newValue === null ||\n newValue === undefined ||\n (newValue instanceof IncompleteDate &&\n newValue.isCleared(currentDisplaySegments))\n ) {\n setDisplayValue(\n new IncompleteDate(\n currentCalendar,\n currentHourCycle ?? \"h23\",\n currentCalendarValue\n )\n );\n setDate(null);\n } else if (newValue instanceof IncompleteDate) {\n // If the new value is complete and valid, trigger onChange eagerly.\n // If it represents an incomplete or invalid value (e.g. February 30th),\n // wait until the field is blurred to trigger onChange.\n if (newValue.isComplete(currentDisplaySegments)) {\n const dateValue = newValue.toValue(\n currentCalendarValue ?? currentPlaceholder\n );\n\n if (newValue.validate(dateValue, currentDisplaySegments)) {\n const newDateValue = toCalendar(\n dateValue,\n currentV?.calendar ?? new GregorianCalendar()\n );\n\n if (!currentValue || newDateValue.compare(currentValue) !== 0) {\n setDisplayValue(\n new IncompleteDate(\n currentCalendar,\n currentHourCycle ?? \"h23\",\n currentCalendarValue\n )\n // reset in case prop isn't updated\n );\n setDate(newDateValue);\n\n return;\n }\n }\n }\n\n // Incomplete/invalid value. Set temporary display override.\n setDisplayValue(newValue);\n } else {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(\n newValue,\n currentV?.calendar ?? new GregorianCalendar()\n );\n setDisplayValue(\n new IncompleteDate(\n currentCalendar,\n currentHourCycle ?? \"h23\",\n currentCalendarValue\n )\n );\n setDate(newValue);\n }\n };\n\n const dateValue = createMemo(() => {\n const currentDisplayValue = displayValue();\n const currentCalendarValue = calendarValue();\n const currentPlaceholder = placeholder();\n const currentTimeZone = timeZone();\n\n const localV = currentDisplayValue.toValue(\n currentCalendarValue ?? currentPlaceholder\n );\n\n return localV.toDate(currentTimeZone);\n });\n\n const segments = createMemo(() => {\n const currentDateValue = dateValue();\n const currentDisplayValue = displayValue();\n const currentDateFormatter = dateFormatter();\n const currentResolvedOptions = resolvedOptions();\n const currentCalendar = calendar();\n const currentLocale = locale();\n const currentGranularity = granularity();\n\n return processSegments(\n currentDateValue,\n currentDisplayValue,\n currentDateFormatter,\n currentResolvedOptions,\n currentCalendar,\n currentLocale,\n currentGranularity\n );\n });\n\n const adjustSegment = (type: DateSegmentType, amount: number) => {\n const currentDisplayValue = displayValue();\n const currentPlaceholder = placeholder();\n const currentDisplaySegments = displaySegments();\n setValue(\n currentDisplayValue.cycle(\n type,\n amount,\n currentPlaceholder,\n currentDisplaySegments\n )\n );\n };\n\n const builtinValidation = createMemo(() => {\n const currentValue = value();\n const currentMinValue = minValue();\n const currentMaxValue = maxValue();\n const currentIsDateUnavailable = isDateUnavailable();\n const currentFormatOpts = formatOpts();\n\n return getValidationResult(\n currentValue,\n currentMinValue,\n currentMaxValue,\n currentIsDateUnavailable,\n currentFormatOpts\n );\n });\n\n const validation = createFormValidationState<DateValue>(\n merge(props, {\n get builtinValidation() {\n return builtinValidation();\n },\n validate: (localValue: DateValue) =>\n // SAFETY: Date edits preserve the input date/time class; the mapped generic callback widens subclasses to that class.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n props.validate?.(localValue as MappedDateValue<T>),\n get value() {\n return value();\n },\n })\n );\n\n const isValueInvalid = createMemo(\n () => validation.displayValidation.isInvalid\n );\n\n const validationState = createMemo(() => {\n const currentIsValueInvalid = isValueInvalid();\n\n return (\n getLegacyValidationState(props) ??\n (currentIsValueInvalid ? \"invalid\" : null)\n );\n });\n\n return merge(validation, {\n get calendar() {\n return calendar();\n },\n clearSegment(part) {\n const currentDisplayValue = displayValue();\n let localValue = currentDisplayValue;\n\n if (part !== \"timeZoneName\" && part !== \"literal\") {\n localValue = currentDisplayValue.clear(part);\n }\n\n setValue(localValue);\n },\n confirmPlaceholder() {\n const currentDisplayValue = displayValue();\n const currentDisplaySegments = displaySegments();\n const currentCalendarValue = calendarValue();\n const currentPlaceholder = placeholder();\n const currentV = v();\n const currentValue = value();\n const currentCalendar = calendar();\n const currentHourCycle = hourCycle();\n\n if (props.isDisabled === true || props.isReadOnly === true) {\n return;\n }\n\n // If the display value is complete but invalid, we need to constrain it and emit onChange on blur.\n if (currentDisplayValue.isComplete(currentDisplaySegments)) {\n const localDateValue = currentDisplayValue.toValue(\n currentCalendarValue ?? currentPlaceholder\n );\n\n const newDateValue = toCalendar(\n localDateValue,\n currentV?.calendar ?? new GregorianCalendar()\n );\n\n if (!currentValue || newDateValue.compare(currentValue) !== 0) {\n setDate(newDateValue);\n }\n\n setDisplayValue(\n new IncompleteDate(\n currentCalendar,\n currentHourCycle ?? \"h23\",\n currentCalendarValue\n )\n );\n }\n },\n get dateFormatter() {\n return dateFormatter();\n },\n get dateValue() {\n return dateValue();\n },\n decrement(part) {\n adjustSegment(part, -1);\n },\n decrementPage(part) {\n adjustSegment(part, -(PAGE_STEP[part] ?? 1));\n },\n decrementToMin(part) {\n const currentHourCycle = hourCycle();\n const currentDisplayValue = displayValue();\n const currentPlaceholder = placeholder();\n\n const localMinValue =\n part === \"hour\" && currentHourCycle === \"h12\"\n ? 12\n : requireValue(\n currentDisplayValue.getSegmentLimits(part),\n \"Expected currentDisplayValue.getSegmentLimits(part) to exist.\"\n ).minValue;\n\n setValue(\n currentDisplayValue.set(part, localMinValue, currentPlaceholder)\n );\n },\n get defaultValue() {\n return props.defaultValue ?? initialValue;\n },\n formatValue(fieldOptions: FieldOptions) {\n const currentCalendarValue = calendarValue();\n const currentFormatOpts = formatOpts();\n const currentLocale = locale();\n const currentDateValue = dateValue();\n\n if (!currentCalendarValue) {\n return \"\";\n }\n\n const formatOptions = getFormatOptions(fieldOptions, currentFormatOpts);\n const formatter = new DateFormatter(currentLocale, formatOptions);\n\n return formatter.format(currentDateValue);\n },\n getDateFormatter(localLocale, formatOptions: FormatterOptions) {\n const currentFormatOpts = formatOpts();\n const newOptions = { ...currentFormatOpts, ...formatOptions };\n const newFormatOptions = getFormatOptions({}, newOptions);\n\n return new DateFormatter(localLocale, newFormatOptions);\n },\n get granularity() {\n return granularity();\n },\n increment(part) {\n adjustSegment(part, 1);\n },\n incrementPage(part) {\n adjustSegment(part, PAGE_STEP[part] ?? 1);\n },\n incrementToMax(part) {\n const currentHourCycle = hourCycle();\n const currentDisplayValue = displayValue();\n const currentPlaceholder = placeholder();\n\n const localMaxValue =\n part === \"hour\" && currentHourCycle === \"h12\"\n ? 11\n : requireValue(\n currentDisplayValue.getSegmentLimits(part),\n \"Expected currentDisplayValue.getSegmentLimits(part) to exist.\"\n ).maxValue;\n\n setValue(\n currentDisplayValue.set(part, localMaxValue, currentPlaceholder)\n );\n },\n get isDisabled() {\n return isDisabled();\n },\n get isInvalid() {\n return isValueInvalid();\n },\n get isReadOnly() {\n return isReadOnly();\n },\n get isRequired() {\n return isRequired();\n },\n get maxGranularity() {\n return props.maxGranularity ?? \"year\";\n },\n get segments() {\n return segments();\n },\n setSegment(part, localV: string | number) {\n const currentDisplayValue = displayValue();\n const currentPlaceholder = placeholder();\n setValue(currentDisplayValue.set(part, localV, currentPlaceholder));\n },\n setValue,\n // oxlint-disable-next-line typescript/no-deprecated -- Expose the legacy output alias for existing consumers; internal state uses its modern replacement.\n get validationState() {\n return validationState();\n },\n get value() {\n return calendarValue();\n },\n } satisfies Partial<DateFieldState>);\n}\n\nfunction processSegments(\n dateValue: Date,\n displayValue: IncompleteDate,\n dateFormatter: Intl.DateTimeFormat,\n resolvedOptions: Intl.ResolvedDateTimeFormatOptions,\n calendar: Calendar,\n locale: string,\n granularity: Granularity\n): DateSegment[] {\n const timeValue = new Set([\"hour\", \"minute\", \"second\"]);\n const segments = dateFormatter.formatToParts(dateValue);\n formatNumericSegments(segments, displayValue, resolvedOptions, locale);\n const processedSegments: DateSegment[] = [];\n\n for (const segment of segments) {\n const mapped = mapDateSegmentType(segment.type);\n\n const type = isDateSegmentType(mapped) ? mapped : \"literal\";\n let isEditable = type in EDITABLE_SEGMENTS;\n\n if (type === \"era\" && calendar.getEras().length === 1) {\n isEditable = false;\n }\n\n const isPlaceholder =\n type !== \"literal\" &&\n type !== \"timeZoneName\" &&\n (displayValue[type] === null || displayValue[type] === undefined);\n\n const placeholder =\n type in EDITABLE_SEGMENTS\n ? getPlaceholder(type, segment.value, locale)\n : null;\n\n const dateSegment: DateSegment = {\n text: isPlaceholder ? (placeholder ?? \"\") : segment.value,\n type,\n ...displayValue.getSegmentLimits(type),\n isEditable,\n isPlaceholder,\n placeholder: placeholder ?? \"\",\n };\n\n // There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).\n // To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.\n // These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change.\n if (type === \"hour\") {\n // This marks the start of the embedded direction change.\n processedSegments.push(\n {\n isEditable: false,\n isPlaceholder: false,\n placeholder: \"\",\n text: \"\\u2066\",\n type: \"literal\",\n },\n dateSegment\n );\n\n // This marks the end of the embedded direction change in the case that the granularity it set to \"hour\".\n if (type === granularity) {\n processedSegments.push({\n isEditable: false,\n isPlaceholder: false,\n placeholder: \"\",\n text: \"\\u2069\",\n type: \"literal\",\n });\n }\n } else if (timeValue.has(type) && type === granularity) {\n // This marks the end of the embedded direction change.\n processedSegments.push(dateSegment, {\n isEditable: false,\n isPlaceholder: false,\n placeholder: \"\",\n text: \"\\u2069\",\n type: \"literal\",\n });\n } else {\n // We only want to \"wrap\" the unicode around segments that are hour, minute, or second. If they aren't, just process as normal.\n processedSegments.push(dateSegment);\n }\n }\n\n return processedSegments;\n}\n\nfunction isDateSegmentType(value: string): value is DateSegmentType {\n return [\n \"era\",\n \"year\",\n \"month\",\n \"day\",\n \"hour\",\n \"minute\",\n \"second\",\n \"dayPeriod\",\n \"timeZoneName\",\n \"literal\",\n ].includes(value);\n}\n\nfunction mapDateSegmentType(type: string): string {\n switch (type) {\n case \"dayperiod\": {\n return \"dayPeriod\";\n }\n\n case \"relatedYear\":\n case \"yearName\": {\n return \"year\";\n }\n\n case \"unknown\": {\n return \"literal\";\n }\n\n default: {\n return type;\n }\n }\n}\n\nfunction formatNumericSegments(\n segments: Intl.DateTimeFormatPart[],\n displayValue: IncompleteDate,\n resolvedOptions: Intl.ResolvedDateTimeFormatOptions,\n locale: string\n): void {\n // In order to allow formatting temporarily invalid dates during editing (e.g. February 30th),\n // use a NumberFormatter to manually format segments directly from raw numbers.\n // When the user blurs the date field, the invalid segments will be constrained.\n const numberFormatter = new NumberFormatter(locale, { useGrouping: false });\n\n const twoDigitFormatter = new NumberFormatter(locale, {\n minimumIntegerDigits: 2,\n useGrouping: false,\n });\n\n for (const segment of segments) {\n if (\n segment.type === \"year\" ||\n segment.type === \"month\" ||\n segment.type === \"day\" ||\n segment.type === \"hour\"\n ) {\n const value = displayValue[segment.type] ?? 0;\n\n segment.value =\n resolvedOptions[segment.type] === \"2-digit\"\n ? twoDigitFormatter.format(value)\n : numberFormatter.format(value);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsKA,MAAM,oBAAoB;CACxB,KAAK;CACL,WAAW;CACX,KAAK;CACL,MAAM;CACN,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,MAAM;AACR;AAEA,MAAM,YAAsD;CAC1D,KAAK;CACL,MAAM;CACN,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,MAAM;AACR;;;;;;AA2BA,SAAgB,qBACd,OACgB;CAChB,MAAM,SAAS,iBAAiB,MAAM,MAAM;CAC5C,MAAM,iBAAiB,iBAAiB,MAAM,cAAc;CAC5D,MAAM,eAAe,iBAAiB,MAAM,YAAY;C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,aAAa,MAAM,CAAC;CAE1E,MAAM,oBAAoB,IAAI,gBAAgB,QAAQ;EACpD,sBAAsB;EACtB,aAAa;CACf,CAAC;CAED,KAAK,MAAM,WAAW,UACpB,IACE,QAAQ,SAAS,UACjB,QAAQ,SAAS,WACjB,QAAQ,SAAS,SACjB,QAAQ,SAAS,QACjB;EACA,MAAM,QAAQ,aAAa,QAAQ,SAAS;EAE5C,QAAQ,QACN,gBAAgB,QAAQ,UAAU,YAC9B,kBAAkB,OAAO,KAAK,IAC9B,gBAAgB,OAAO,KAAK;CACpC;AAEJ"}
|
|
@@ -0,0 +1,82 @@
|
|
|
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/datepicker/useDatePickerState.ts.
|
|
14
|
+
* Modified for Solid Aria: adapted reactive state, getters, imports, and APIs for Solid 2.
|
|
15
|
+
* Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
|
|
16
|
+
*/
|
|
17
|
+
import { FormValidationState } from "../form/create-form-validation-state.js";
|
|
18
|
+
import { OverlayTriggerState } from "../overlays/create-overlay-trigger-state.js";
|
|
19
|
+
import { DatePickerProps, DateValue, Granularity, TimeValue } from "./types.js";
|
|
20
|
+
import { FieldOptions, FormatterOptions } from "./utils.js";
|
|
21
|
+
import { DateFormatter } from "@internationalized/date";
|
|
22
|
+
import { ValidationState } from "@solid2-aria/types-shared";
|
|
23
|
+
export interface DatePickerStateOptions<T extends DateValue> extends DatePickerProps<T> {
|
|
24
|
+
/**
|
|
25
|
+
* Determines whether the date picker popover should close automatically when a date is selected.
|
|
26
|
+
*
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
shouldCloseOnSelect?: boolean | (() => boolean);
|
|
30
|
+
}
|
|
31
|
+
export interface DatePickerState extends OverlayTriggerState, FormValidationState {
|
|
32
|
+
/** The currently selected date. */
|
|
33
|
+
value: DateValue | null;
|
|
34
|
+
/** The default date. */
|
|
35
|
+
defaultValue: DateValue | null;
|
|
36
|
+
/** Sets the selected date. */
|
|
37
|
+
setValue: (value: DateValue | null) => void;
|
|
38
|
+
/**
|
|
39
|
+
* The date portion of the value. This may be set prior to `value` if the user has
|
|
40
|
+
* selected a date but has not yet selected a time.
|
|
41
|
+
*/
|
|
42
|
+
dateValue: DateValue | null;
|
|
43
|
+
/** Sets the date portion of the value. */
|
|
44
|
+
setDateValue: (value: DateValue) => void;
|
|
45
|
+
/**
|
|
46
|
+
* The time portion of the value. This may be set prior to `value` if the user has
|
|
47
|
+
* selected a time but has not yet selected a date.
|
|
48
|
+
*/
|
|
49
|
+
timeValue: TimeValue | null;
|
|
50
|
+
/** Sets the time portion of the value. */
|
|
51
|
+
setTimeValue: (value: TimeValue) => void;
|
|
52
|
+
/** The granularity for the field, based on the `granularity` prop and current value. */
|
|
53
|
+
granularity: Granularity;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the date picker supports selecting a time, according to the `granularity` prop and
|
|
56
|
+
* current value.
|
|
57
|
+
*/
|
|
58
|
+
hasTime: boolean;
|
|
59
|
+
/** Whether the calendar popover is currently open. */
|
|
60
|
+
isOpen: boolean;
|
|
61
|
+
/** Sets whether the calendar popover is open. */
|
|
62
|
+
setOpen: (isOpen: boolean) => void;
|
|
63
|
+
/**
|
|
64
|
+
* The current validation state of the date picker, based on the `validationState`, `minValue`,
|
|
65
|
+
* and `maxValue` props.
|
|
66
|
+
*
|
|
67
|
+
* @deprecated Use `isInvalid` instead.
|
|
68
|
+
*/
|
|
69
|
+
validationState: ValidationState | null;
|
|
70
|
+
/** Whether the date picker is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */
|
|
71
|
+
isInvalid: boolean;
|
|
72
|
+
/** Formats the selected value using the given options. */
|
|
73
|
+
formatValue: (locale: string, fieldOptions: FieldOptions) => string;
|
|
74
|
+
/** Gets a formatter based on state's props. */
|
|
75
|
+
getDateFormatter: (locale: string, formatOptions: FormatterOptions) => DateFormatter;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Provides state management for a date picker component. A date picker combines a DateField and a
|
|
79
|
+
* Calendar popover to allow users to enter or select a date and time value.
|
|
80
|
+
*/
|
|
81
|
+
export declare function createDatePickerState<T extends DateValue = DateValue>(props: DatePickerStateOptions<T>): DatePickerState;
|
|
82
|
+
//# sourceMappingURL=create-date-picker-state.d.ts.map
|