@proyecto-viviana/solid-stately 0.5.1 → 0.6.0-rc.0
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-APACHE-2.0 +201 -0
- package/NOTICE +91 -0
- package/dist/autocomplete/createAutocompleteState.d.ts +2 -1
- package/dist/autocomplete/createAutocompleteState.d.ts.map +1 -0
- package/dist/autocomplete/index.d.ts +1 -0
- package/dist/autocomplete/index.d.ts.map +1 -0
- package/dist/calendar/IncompleteDate.d.ts +2 -1
- package/dist/calendar/IncompleteDate.d.ts.map +1 -0
- package/dist/calendar/createCalendarState.d.ts +7 -8
- package/dist/calendar/createCalendarState.d.ts.map +1 -0
- package/dist/calendar/createDateFieldState.d.ts +4 -20
- package/dist/calendar/createDateFieldState.d.ts.map +1 -0
- package/dist/calendar/createDatePickerState.d.ts +2 -7
- package/dist/calendar/createDatePickerState.d.ts.map +1 -0
- package/dist/calendar/createRangeCalendarState.d.ts +7 -7
- package/dist/calendar/createRangeCalendarState.d.ts.map +1 -0
- package/dist/calendar/createTimeFieldState.d.ts +4 -23
- package/dist/calendar/createTimeFieldState.d.ts.map +1 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.d.ts.map +1 -0
- package/dist/calendar/intl/index.d.ts +1 -0
- package/dist/calendar/intl/index.d.ts.map +1 -0
- package/dist/checkbox/createCheckboxGroupState.d.ts +1 -0
- package/dist/checkbox/createCheckboxGroupState.d.ts.map +1 -0
- package/dist/checkbox/index.d.ts +1 -0
- package/dist/checkbox/index.d.ts.map +1 -0
- package/dist/collections/ListCollection.d.ts +5 -0
- package/dist/collections/ListCollection.d.ts.map +1 -0
- package/dist/collections/createListState.d.ts +2 -6
- package/dist/collections/createListState.d.ts.map +1 -0
- package/dist/collections/createMenuState.d.ts +30 -13
- package/dist/collections/createMenuState.d.ts.map +1 -0
- package/dist/collections/createSelectionState.d.ts +2 -5
- package/dist/collections/createSelectionState.d.ts.map +1 -0
- package/dist/collections/getChildNodes.d.ts +6 -3
- package/dist/collections/getChildNodes.d.ts.map +1 -0
- package/dist/collections/index.d.ts +2 -1
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/types.d.ts +36 -2
- package/dist/collections/types.d.ts.map +1 -0
- package/dist/color/Color.d.ts +7 -1
- package/dist/color/Color.d.ts.map +1 -0
- package/dist/color/createColorAreaState.d.ts +2 -5
- package/dist/color/createColorAreaState.d.ts.map +1 -0
- package/dist/color/createColorFieldState.d.ts +2 -5
- package/dist/color/createColorFieldState.d.ts.map +1 -0
- package/dist/color/createColorSliderState.d.ts +2 -5
- package/dist/color/createColorSliderState.d.ts.map +1 -0
- package/dist/color/createColorWheelState.d.ts +2 -5
- package/dist/color/createColorWheelState.d.ts.map +1 -0
- package/dist/color/getColorChannels.d.ts +3 -0
- package/dist/color/getColorChannels.d.ts.map +1 -0
- package/dist/color/index.d.ts +2 -1
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/intl/index.d.ts +1 -0
- package/dist/color/intl/index.d.ts.map +1 -0
- package/dist/color/types.d.ts +2 -1
- package/dist/color/types.d.ts.map +1 -0
- package/dist/combobox/createComboBoxState.d.ts +4 -8
- package/dist/combobox/createComboBoxState.d.ts.map +1 -0
- package/dist/combobox/index.d.ts +1 -0
- package/dist/combobox/index.d.ts.map +1 -0
- package/dist/data/createAsyncList.d.ts +1 -7
- package/dist/data/createAsyncList.d.ts.map +1 -0
- package/dist/data/createListData.d.ts +1 -6
- package/dist/data/createListData.d.ts.map +1 -0
- package/dist/data/createTreeData.d.ts +1 -6
- package/dist/data/createTreeData.d.ts.map +1 -0
- package/dist/data/index.d.ts +1 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/datepicker/index.d.ts +1 -0
- package/dist/datepicker/index.d.ts.map +1 -0
- package/dist/disclosure/createDisclosureState.d.ts +2 -5
- package/dist/disclosure/createDisclosureState.d.ts.map +1 -0
- package/dist/disclosure/index.d.ts +1 -0
- package/dist/disclosure/index.d.ts.map +1 -0
- package/dist/dnd/createDragState.d.ts +2 -6
- package/dist/dnd/createDragState.d.ts.map +1 -0
- package/dist/dnd/createDraggableCollectionState.d.ts +39 -10
- package/dist/dnd/createDraggableCollectionState.d.ts.map +1 -0
- package/dist/dnd/createDropState.d.ts +2 -6
- package/dist/dnd/createDropState.d.ts.map +1 -0
- package/dist/dnd/createDroppableCollectionState.d.ts +28 -11
- package/dist/dnd/createDroppableCollectionState.d.ts.map +1 -0
- package/dist/dnd/index.d.ts +3 -2
- package/dist/dnd/index.d.ts.map +1 -0
- package/dist/dnd/types.d.ts +17 -0
- package/dist/dnd/types.d.ts.map +1 -0
- package/dist/flags/flags.d.ts +5 -0
- package/dist/flags/flags.d.ts.map +1 -0
- package/dist/form/createFormValidationState.d.ts +2 -9
- package/{src → dist}/form/createFormValidationState.d.ts.map +1 -1
- package/dist/form/index.d.ts +1 -0
- package/dist/form/index.d.ts.map +1 -0
- package/dist/grid/createGridState.d.ts +3 -2
- package/dist/grid/createGridState.d.ts.map +1 -0
- package/dist/grid/index.d.ts +1 -0
- package/dist/grid/index.d.ts.map +1 -0
- package/dist/grid/types.d.ts +23 -1
- package/dist/grid/types.d.ts.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2030 -593
- package/dist/index.js.map +1 -1
- package/dist/menu/index.d.ts +2 -1
- package/dist/menu/index.d.ts.map +1 -0
- package/dist/numberfield/createNumberFieldState.d.ts +31 -6
- package/dist/numberfield/createNumberFieldState.d.ts.map +1 -0
- package/dist/numberfield/index.d.ts +1 -0
- package/dist/numberfield/index.d.ts.map +1 -0
- package/dist/overlays/createOverlayTriggerState.d.ts +12 -1
- package/dist/overlays/createOverlayTriggerState.d.ts.map +1 -0
- package/dist/overlays/index.d.ts +1 -0
- package/dist/overlays/index.d.ts.map +1 -0
- package/dist/private/flags/flags.js +26 -0
- package/dist/private/flags/flags.js.map +1 -0
- package/dist/radio/createRadioGroupState.d.ts +1 -0
- package/dist/radio/createRadioGroupState.d.ts.map +1 -0
- package/dist/radio/index.d.ts +1 -0
- package/dist/radio/index.d.ts.map +1 -0
- package/dist/searchfield/createSearchFieldState.d.ts +2 -5
- package/dist/searchfield/createSearchFieldState.d.ts.map +1 -0
- package/dist/searchfield/index.d.ts +1 -0
- package/dist/searchfield/index.d.ts.map +1 -0
- package/dist/select/createSelectState.d.ts +17 -6
- package/dist/select/createSelectState.d.ts.map +1 -0
- package/dist/select/index.d.ts +1 -0
- package/dist/select/index.d.ts.map +1 -0
- package/dist/selection/Selection.d.ts +2 -1
- package/dist/selection/Selection.d.ts.map +1 -0
- package/dist/selection/SelectionManager.d.ts +1 -19
- package/dist/selection/SelectionManager.d.ts.map +1 -0
- package/dist/selection/createMultipleSelectionState.d.ts +2 -13
- package/dist/selection/createMultipleSelectionState.d.ts.map +1 -0
- package/dist/selection/index.d.ts +1 -0
- package/dist/selection/index.d.ts.map +1 -0
- package/dist/slider/createSliderState.d.ts +2 -5
- package/dist/slider/createSliderState.d.ts.map +1 -0
- package/dist/slider/index.d.ts +1 -0
- package/dist/slider/index.d.ts.map +1 -0
- package/dist/ssr/index.d.ts +2 -7
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/steplist/createStepListState.d.ts +2 -5
- package/dist/steplist/createStepListState.d.ts.map +1 -0
- package/dist/steplist/index.d.ts +1 -0
- package/dist/steplist/index.d.ts.map +1 -0
- package/dist/table/TableCollection.d.ts +1 -0
- package/dist/table/TableCollection.d.ts.map +1 -0
- package/dist/table/createTableColumnResizeState.d.ts +2 -9
- package/dist/table/createTableColumnResizeState.d.ts.map +1 -0
- package/dist/table/createTableState.d.ts +2 -5
- package/dist/table/createTableState.d.ts.map +1 -0
- package/dist/table/createTreeGridState.d.ts +2 -8
- package/dist/table/createTreeGridState.d.ts.map +1 -0
- package/dist/table/index.d.ts +1 -0
- package/dist/table/index.d.ts.map +1 -0
- package/dist/table/types.d.ts +35 -1
- package/dist/table/types.d.ts.map +1 -0
- package/dist/tabs/createTabListState.d.ts +2 -5
- package/dist/tabs/createTabListState.d.ts.map +1 -0
- package/dist/tabs/index.d.ts +1 -0
- package/dist/tabs/index.d.ts.map +1 -0
- package/dist/textfield/createTextFieldState.d.ts +1 -0
- package/dist/textfield/createTextFieldState.d.ts.map +1 -0
- package/dist/textfield/index.d.ts +1 -0
- package/dist/textfield/index.d.ts.map +1 -0
- package/dist/toast/createToastState.d.ts +2 -5
- package/dist/toast/createToastState.d.ts.map +1 -0
- package/dist/toast/index.d.ts +1 -0
- package/dist/toast/index.d.ts.map +1 -0
- package/dist/toggle/createToggleGroupState.d.ts +1 -0
- package/dist/toggle/createToggleGroupState.d.ts.map +1 -0
- package/dist/toggle/createToggleState.d.ts +1 -0
- package/dist/toggle/createToggleState.d.ts.map +1 -0
- package/dist/toggle/index.d.ts +1 -0
- package/dist/toggle/index.d.ts.map +1 -0
- package/dist/tokenfield/TokenFieldValue.d.ts +72 -0
- package/dist/tokenfield/TokenFieldValue.d.ts.map +1 -0
- package/dist/tokenfield/createTokenFieldState.d.ts +33 -0
- package/dist/tokenfield/createTokenFieldState.d.ts.map +1 -0
- package/dist/tokenfield/index.d.ts +3 -0
- package/dist/tokenfield/index.d.ts.map +1 -0
- package/dist/tooltip/createTooltipTriggerState.d.ts +9 -8
- package/dist/tooltip/createTooltipTriggerState.d.ts.map +1 -0
- package/dist/tooltip/index.d.ts +1 -0
- package/dist/tooltip/index.d.ts.map +1 -0
- package/dist/tree/TreeCollection.d.ts +1 -0
- package/dist/tree/TreeCollection.d.ts.map +1 -0
- package/dist/tree/createTreeState.d.ts +2 -7
- package/{src → dist}/tree/createTreeState.d.ts.map +1 -1
- package/dist/tree/index.d.ts +1 -0
- package/dist/tree/index.d.ts.map +1 -0
- package/dist/tree/types.d.ts +19 -1
- package/dist/tree/types.d.ts.map +1 -0
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/owner.d.ts +9 -0
- package/dist/utils/owner.d.ts.map +1 -0
- package/dist/utils/reactivity.d.ts +19 -0
- package/dist/utils/reactivity.d.ts.map +1 -0
- package/package.json +21 -9
- package/src/autocomplete/createAutocompleteState.ts +18 -4
- package/src/calendar/IncompleteDate.ts +15 -1
- package/src/calendar/createCalendarState.ts +194 -79
- package/src/calendar/createDateFieldState.ts +45 -31
- package/src/calendar/createDatePickerState.ts +32 -14
- package/src/calendar/createRangeCalendarState.ts +134 -73
- package/src/calendar/createTimeFieldState.ts +25 -6
- package/src/calendar/intl/index.ts +37 -2
- package/src/checkbox/createCheckboxGroupState.ts +29 -13
- package/src/collections/ListCollection.ts +31 -0
- package/src/collections/createListState.ts +23 -6
- package/src/collections/createMenuState.ts +59 -14
- package/src/collections/createSelectionState.ts +32 -12
- package/src/collections/getChildNodes.ts +20 -3
- package/src/collections/index.ts +2 -0
- package/src/collections/types.ts +35 -2
- package/src/color/Color.ts +61 -22
- package/src/color/createColorAreaState.ts +29 -4
- package/src/color/createColorFieldState.ts +37 -11
- package/src/color/createColorSliderState.ts +36 -7
- package/src/color/createColorWheelState.ts +20 -4
- package/src/color/getColorChannels.ts +16 -0
- package/src/color/index.ts +1 -0
- package/src/color/intl/index.ts +38 -3
- package/src/color/types.ts +1 -1
- package/src/combobox/createComboBoxState.ts +178 -195
- package/src/data/createAsyncList.ts +22 -2
- package/src/data/createListData.ts +19 -2
- package/src/data/createTreeData.ts +19 -3
- package/src/disclosure/createDisclosureState.ts +40 -19
- package/src/dnd/createDragState.ts +22 -4
- package/src/dnd/createDraggableCollectionState.ts +137 -10
- package/src/dnd/createDropState.ts +21 -3
- package/src/dnd/createDroppableCollectionState.ts +117 -11
- package/src/dnd/index.ts +4 -0
- package/src/dnd/types.ts +16 -0
- package/src/flags/flags.ts +25 -0
- package/src/form/createFormValidationState.ts +54 -36
- package/src/grid/createGridState.ts +187 -109
- package/src/grid/types.ts +22 -1
- package/src/index.ts +15 -0
- package/src/menu/index.ts +2 -0
- package/src/numberfield/createNumberFieldState.ts +153 -66
- package/src/overlays/createOverlayTriggerState.ts +31 -4
- package/src/radio/createRadioGroupState.ts +19 -5
- package/src/searchfield/createSearchFieldState.ts +18 -3
- package/src/select/createSelectState.ts +73 -8
- package/src/selection/Selection.ts +15 -1
- package/src/selection/SelectionManager.ts +14 -0
- package/src/selection/createMultipleSelectionState.ts +44 -25
- package/src/slider/createSliderState.ts +20 -5
- package/src/ssr/index.ts +27 -4
- package/src/steplist/createStepListState.ts +38 -17
- package/src/table/TableCollection.ts +14 -0
- package/src/table/createTableColumnResizeState.ts +20 -3
- package/src/table/createTableState.ts +22 -1
- package/src/table/createTreeGridState.ts +21 -4
- package/src/table/types.ts +36 -3
- package/src/tabs/createTabListState.ts +77 -34
- package/src/textfield/createTextFieldState.ts +17 -3
- package/src/toast/createToastState.ts +28 -3
- package/src/toggle/createToggleGroupState.ts +20 -5
- package/src/toggle/createToggleState.ts +19 -4
- package/src/tokenfield/TokenFieldValue.ts +440 -0
- package/src/tokenfield/createTokenFieldState.ts +88 -0
- package/src/tokenfield/index.ts +14 -0
- package/src/tooltip/createTooltipTriggerState.ts +49 -13
- package/src/tree/TreeCollection.ts +14 -0
- package/src/tree/createTreeState.ts +62 -35
- package/src/tree/types.ts +18 -1
- package/src/utils/index.ts +9 -1
- package/src/utils/owner.ts +20 -0
- package/src/utils/reactivity.ts +45 -1
- package/src/autocomplete/createAutocompleteState.d.ts +0 -48
- package/src/autocomplete/createAutocompleteState.d.ts.map +0 -1
- package/src/autocomplete/index.d.ts +0 -6
- package/src/autocomplete/index.d.ts.map +0 -1
- package/src/calendar/createCalendarState.d.ts +0 -152
- package/src/calendar/createCalendarState.d.ts.map +0 -1
- package/src/calendar/createDateFieldState.d.ts +0 -145
- package/src/calendar/createDateFieldState.d.ts.map +0 -1
- package/src/calendar/createRangeCalendarState.d.ts +0 -171
- package/src/calendar/createRangeCalendarState.d.ts.map +0 -1
- package/src/calendar/createTimeFieldState.d.ts +0 -97
- package/src/calendar/createTimeFieldState.d.ts.map +0 -1
- package/src/calendar/index.d.ts +0 -80
- package/src/calendar/index.d.ts.map +0 -1
- package/src/checkbox/createCheckboxGroupState.d.ts +0 -73
- package/src/checkbox/createCheckboxGroupState.d.ts.map +0 -1
- package/src/checkbox/index.d.ts +0 -6
- package/src/checkbox/index.d.ts.map +0 -1
- package/src/collections/ListCollection.d.ts +0 -40
- package/src/collections/ListCollection.d.ts.map +0 -1
- package/src/collections/createListState.d.ts +0 -94
- package/src/collections/createListState.d.ts.map +0 -1
- package/src/collections/createMenuState.d.ts +0 -55
- package/src/collections/createMenuState.d.ts.map +0 -1
- package/src/collections/createSelectionState.d.ts +0 -89
- package/src/collections/createSelectionState.d.ts.map +0 -1
- package/src/collections/index.d.ts +0 -38
- package/src/collections/index.d.ts.map +0 -1
- package/src/collections/types.d.ts +0 -147
- package/src/collections/types.d.ts.map +0 -1
- package/src/color/Color.d.ts +0 -43
- package/src/color/Color.d.ts.map +0 -1
- package/src/color/createColorAreaState.d.ts +0 -78
- package/src/color/createColorAreaState.d.ts.map +0 -1
- package/src/color/createColorFieldState.d.ts +0 -57
- package/src/color/createColorFieldState.d.ts.map +0 -1
- package/src/color/createColorSliderState.d.ts +0 -69
- package/src/color/createColorSliderState.d.ts.map +0 -1
- package/src/color/createColorWheelState.d.ts +0 -53
- package/src/color/createColorWheelState.d.ts.map +0 -1
- package/src/color/index.d.ts +0 -39
- package/src/color/index.d.ts.map +0 -1
- package/src/color/types.d.ts +0 -111
- package/src/color/types.d.ts.map +0 -1
- package/src/combobox/createComboBoxState.d.ts +0 -127
- package/src/combobox/createComboBoxState.d.ts.map +0 -1
- package/src/combobox/index.d.ts +0 -13
- package/src/combobox/index.d.ts.map +0 -1
- package/src/disclosure/createDisclosureState.d.ts +0 -68
- package/src/disclosure/createDisclosureState.d.ts.map +0 -1
- package/src/disclosure/index.d.ts +0 -10
- package/src/disclosure/index.d.ts.map +0 -1
- package/src/dnd/createDragState.d.ts +0 -68
- package/src/dnd/createDragState.d.ts.map +0 -1
- package/src/dnd/createDraggableCollectionState.d.ts +0 -68
- package/src/dnd/createDraggableCollectionState.d.ts.map +0 -1
- package/src/dnd/createDropState.d.ts +0 -80
- package/src/dnd/createDropState.d.ts.map +0 -1
- package/src/dnd/createDroppableCollectionState.d.ts +0 -107
- package/src/dnd/createDroppableCollectionState.d.ts.map +0 -1
- package/src/dnd/index.d.ts +0 -60
- package/src/dnd/index.d.ts.map +0 -1
- package/src/dnd/types.d.ts +0 -277
- package/src/dnd/types.d.ts.map +0 -1
- package/src/form/createFormValidationState.d.ts +0 -102
- package/src/form/index.d.ts +0 -16
- package/src/form/index.d.ts.map +0 -1
- package/src/grid/createGridState.d.ts +0 -15
- package/src/grid/createGridState.d.ts.map +0 -1
- package/src/grid/index.d.ts +0 -7
- package/src/grid/index.d.ts.map +0 -1
- package/src/grid/types.d.ts +0 -163
- package/src/grid/types.d.ts.map +0 -1
- package/src/index.d.ts +0 -311
- package/src/index.d.ts.map +0 -1
- package/src/numberfield/createNumberFieldState.d.ts +0 -67
- package/src/numberfield/createNumberFieldState.d.ts.map +0 -1
- package/src/numberfield/index.d.ts +0 -6
- package/src/numberfield/index.d.ts.map +0 -1
- package/src/overlays/createOverlayTriggerState.d.ts +0 -34
- package/src/overlays/createOverlayTriggerState.d.ts.map +0 -1
- package/src/overlays/index.d.ts +0 -6
- package/src/overlays/index.d.ts.map +0 -1
- package/src/radio/createRadioGroupState.d.ts +0 -79
- package/src/radio/createRadioGroupState.d.ts.map +0 -1
- package/src/radio/index.d.ts +0 -7
- package/src/radio/index.d.ts.map +0 -1
- package/src/searchfield/createSearchFieldState.d.ts +0 -27
- package/src/searchfield/createSearchFieldState.d.ts.map +0 -1
- package/src/searchfield/index.d.ts +0 -3
- package/src/searchfield/index.d.ts.map +0 -1
- package/src/select/createSelectState.d.ts +0 -75
- package/src/select/createSelectState.d.ts.map +0 -1
- package/src/select/index.d.ts +0 -2
- package/src/select/index.d.ts.map +0 -1
- package/src/slider/createSliderState.d.ts +0 -72
- package/src/slider/createSliderState.d.ts.map +0 -1
- package/src/slider/index.d.ts +0 -3
- package/src/slider/index.d.ts.map +0 -1
- package/src/ssr/index.d.ts +0 -28
- package/src/ssr/index.d.ts.map +0 -1
- package/src/table/TableCollection.d.ts +0 -54
- package/src/table/TableCollection.d.ts.map +0 -1
- package/src/table/createTableState.d.ts +0 -15
- package/src/table/createTableState.d.ts.map +0 -1
- package/src/table/index.d.ts +0 -18
- package/src/table/index.d.ts.map +0 -1
- package/src/table/types.d.ts +0 -145
- package/src/table/types.d.ts.map +0 -1
- package/src/tabs/createTabListState.d.ts +0 -70
- package/src/tabs/createTabListState.d.ts.map +0 -1
- package/src/tabs/index.d.ts +0 -8
- package/src/tabs/index.d.ts.map +0 -1
- package/src/textfield/createTextFieldState.d.ts +0 -32
- package/src/textfield/createTextFieldState.d.ts.map +0 -1
- package/src/textfield/index.d.ts +0 -6
- package/src/textfield/index.d.ts.map +0 -1
- package/src/toast/createToastState.d.ts +0 -129
- package/src/toast/createToastState.d.ts.map +0 -1
- package/src/toast/index.d.ts +0 -12
- package/src/toast/index.d.ts.map +0 -1
- package/src/toggle/createToggleState.d.ts +0 -34
- package/src/toggle/createToggleState.d.ts.map +0 -1
- package/src/toggle/index.d.ts +0 -2
- package/src/toggle/index.d.ts.map +0 -1
- package/src/tooltip/createTooltipTriggerState.d.ts +0 -39
- package/src/tooltip/createTooltipTriggerState.d.ts.map +0 -1
- package/src/tooltip/index.d.ts +0 -7
- package/src/tooltip/index.d.ts.map +0 -1
- package/src/tree/TreeCollection.d.ts +0 -43
- package/src/tree/TreeCollection.d.ts.map +0 -1
- package/src/tree/createTreeState.d.ts +0 -17
- package/src/tree/index.d.ts +0 -13
- package/src/tree/index.d.ts.map +0 -1
- package/src/tree/types.d.ts +0 -162
- package/src/tree/types.d.ts.map +0 -1
- package/src/utils/index.d.ts +0 -2
- package/src/utils/index.d.ts.map +0 -1
- package/src/utils/reactivity.d.ts +0 -28
- package/src/utils/reactivity.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,672 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/autocomplete/useAutocompleteState.ts
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
15
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
17
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
20
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
21
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
22
|
+
* governing permissions and limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/datepicker/IncompleteDate.ts
|
|
25
|
+
/*
|
|
26
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
27
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
28
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
29
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
*
|
|
31
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
32
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
33
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
34
|
+
* governing permissions and limitations under the License.
|
|
35
|
+
*/
|
|
36
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/calendar/useCalendarState.ts
|
|
37
|
+
/*
|
|
38
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
39
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
40
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
41
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
42
|
+
*
|
|
43
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
44
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
45
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
46
|
+
* governing permissions and limitations under the License.
|
|
47
|
+
*/
|
|
48
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/datepicker/useDateFieldState.ts
|
|
49
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/datepicker/utils.ts
|
|
50
|
+
/*
|
|
51
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
52
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
53
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
54
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
55
|
+
*
|
|
56
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
57
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
58
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
59
|
+
* governing permissions and limitations under the License.
|
|
60
|
+
*/
|
|
61
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/datepicker/useDatePickerState.ts
|
|
62
|
+
/*
|
|
63
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
64
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
65
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
66
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
67
|
+
*
|
|
68
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
69
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
70
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
71
|
+
* governing permissions and limitations under the License.
|
|
72
|
+
*/
|
|
73
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/calendar/useCalendarState.ts
|
|
74
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/calendar/useRangeCalendarState.ts
|
|
75
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/calendar/utils.ts
|
|
76
|
+
/*
|
|
77
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
78
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the 'License');
|
|
79
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
80
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
81
|
+
*
|
|
82
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
83
|
+
* the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
84
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
85
|
+
* governing permissions and limitations under the License.
|
|
86
|
+
*/
|
|
87
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/datepicker/useTimeFieldState.ts
|
|
88
|
+
/*
|
|
89
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
90
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
91
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
92
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
93
|
+
*
|
|
94
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
95
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
96
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
97
|
+
* governing permissions and limitations under the License.
|
|
98
|
+
*/
|
|
99
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/checkbox/useCheckboxGroupState.ts
|
|
100
|
+
/*
|
|
101
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
102
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
103
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
104
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
105
|
+
*
|
|
106
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
107
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
108
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
109
|
+
* governing permissions and limitations under the License.
|
|
110
|
+
*/
|
|
111
|
+
/*
|
|
112
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
113
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
114
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
115
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
116
|
+
*
|
|
117
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
118
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
119
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
120
|
+
* governing permissions and limitations under the License.
|
|
121
|
+
*/
|
|
122
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-aria/src/collections/BaseCollection.ts
|
|
123
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/list/ListCollection.ts
|
|
124
|
+
/*
|
|
125
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
126
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
127
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
128
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
129
|
+
*
|
|
130
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
131
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
132
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
133
|
+
* governing permissions and limitations under the License.
|
|
134
|
+
*/
|
|
135
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/list/useListState.ts
|
|
136
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/list/useSingleSelectListState.ts
|
|
137
|
+
/*
|
|
138
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
139
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
140
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
141
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
142
|
+
*
|
|
143
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
144
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
145
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
146
|
+
* governing permissions and limitations under the License.
|
|
147
|
+
*/
|
|
148
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/menu/useMenuTriggerState.ts
|
|
149
|
+
/*
|
|
150
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
151
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
152
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
153
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
154
|
+
*
|
|
155
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
156
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
157
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
158
|
+
* governing permissions and limitations under the License.
|
|
159
|
+
*/
|
|
160
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/selection/SelectionManager.ts
|
|
161
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/selection/useMultipleSelectionState.ts
|
|
162
|
+
/*
|
|
163
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
164
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
165
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
166
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
167
|
+
*
|
|
168
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
169
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
170
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
171
|
+
* governing permissions and limitations under the License.
|
|
172
|
+
*/
|
|
173
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/collections/getChildNodes.ts
|
|
174
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/collections/getItemCount.ts
|
|
175
|
+
/*
|
|
176
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
177
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
178
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
179
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
180
|
+
*
|
|
181
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
182
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
183
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
184
|
+
* governing permissions and limitations under the License.
|
|
185
|
+
*/
|
|
186
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/color/Color.ts
|
|
187
|
+
/*
|
|
188
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
189
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
190
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
191
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
192
|
+
*
|
|
193
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
194
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
195
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
196
|
+
* governing permissions and limitations under the License.
|
|
197
|
+
*/
|
|
198
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/color/useColorAreaState.ts
|
|
199
|
+
/*
|
|
200
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
201
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
202
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
203
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
204
|
+
*
|
|
205
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
206
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
207
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
208
|
+
* governing permissions and limitations under the License.
|
|
209
|
+
*/
|
|
210
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/color/useColorChannelFieldState.ts
|
|
211
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/color/useColorFieldState.ts
|
|
212
|
+
/*
|
|
213
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
214
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
215
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
216
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
217
|
+
*
|
|
218
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
219
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
220
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
221
|
+
* governing permissions and limitations under the License.
|
|
222
|
+
*/
|
|
223
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/color/useColorSliderState.ts
|
|
224
|
+
/*
|
|
225
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
226
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
227
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
228
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
229
|
+
*
|
|
230
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
231
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
232
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
233
|
+
* governing permissions and limitations under the License.
|
|
234
|
+
*/
|
|
235
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/color/useColorWheelState.ts
|
|
236
|
+
/*
|
|
237
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
238
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
239
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
240
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
241
|
+
*
|
|
242
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
243
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
244
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
245
|
+
* governing permissions and limitations under the License.
|
|
246
|
+
*/
|
|
247
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/combobox/useComboBoxState.ts
|
|
248
|
+
/*
|
|
249
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
250
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
251
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
252
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
253
|
+
*
|
|
254
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
255
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
256
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
257
|
+
* governing permissions and limitations under the License.
|
|
258
|
+
*/
|
|
259
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/data/useAsyncList.ts
|
|
260
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/data/useListData.ts
|
|
261
|
+
/*
|
|
262
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
263
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
264
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
265
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
266
|
+
*
|
|
267
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
268
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
269
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
270
|
+
* governing permissions and limitations under the License.
|
|
271
|
+
*/
|
|
272
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/data/useListData.ts
|
|
273
|
+
/*
|
|
274
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
275
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
276
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
277
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
278
|
+
*
|
|
279
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
280
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
281
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
282
|
+
* governing permissions and limitations under the License.
|
|
283
|
+
*/
|
|
284
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/data/useTreeData.ts
|
|
285
|
+
/*
|
|
286
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
287
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
288
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
289
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
290
|
+
*
|
|
291
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
292
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
293
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
294
|
+
* governing permissions and limitations under the License.
|
|
295
|
+
*/
|
|
296
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/disclosure/useDisclosureGroupState.ts
|
|
297
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/disclosure/useDisclosureState.ts
|
|
298
|
+
/*
|
|
299
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
300
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
301
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
302
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
303
|
+
*
|
|
304
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
305
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
306
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
307
|
+
* governing permissions and limitations under the License.
|
|
308
|
+
*/
|
|
309
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-aria/src/dnd/useDrag.ts
|
|
310
|
+
/*
|
|
311
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
312
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
313
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
314
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
315
|
+
*
|
|
316
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
317
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
318
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
319
|
+
* governing permissions and limitations under the License.
|
|
320
|
+
*/
|
|
321
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/dnd/useDraggableCollectionState.ts
|
|
322
|
+
/*
|
|
323
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
324
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
325
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
326
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
327
|
+
*
|
|
328
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
329
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
330
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
331
|
+
* governing permissions and limitations under the License.
|
|
332
|
+
*/
|
|
333
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-aria/src/dnd/useDrop.ts
|
|
334
|
+
/*
|
|
335
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
336
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
337
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
338
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
339
|
+
*
|
|
340
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
341
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
342
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
343
|
+
* governing permissions and limitations under the License.
|
|
344
|
+
*/
|
|
345
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/dnd/useDroppableCollectionState.ts
|
|
346
|
+
/*
|
|
347
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
348
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
349
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
350
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
351
|
+
*
|
|
352
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
353
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
354
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
355
|
+
* governing permissions and limitations under the License.
|
|
356
|
+
*/
|
|
357
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/form/useFormValidationState.ts
|
|
358
|
+
/*
|
|
359
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
360
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
361
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
362
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
363
|
+
*
|
|
364
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
365
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
366
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
367
|
+
* governing permissions and limitations under the License.
|
|
368
|
+
*/
|
|
369
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/numberfield/useNumberFieldState.ts
|
|
370
|
+
/*
|
|
371
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
372
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
373
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
374
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
375
|
+
*
|
|
376
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
377
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
378
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
379
|
+
* governing permissions and limitations under the License.
|
|
380
|
+
*/
|
|
381
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/overlays/useOverlayTriggerState.ts
|
|
382
|
+
/*
|
|
383
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
384
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
385
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
386
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
387
|
+
*
|
|
388
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
389
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
390
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
391
|
+
* governing permissions and limitations under the License.
|
|
392
|
+
*/
|
|
393
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/radio/useRadioGroupState.ts
|
|
394
|
+
/*
|
|
395
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
396
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
397
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
398
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
399
|
+
*
|
|
400
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
401
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
402
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
403
|
+
* governing permissions and limitations under the License.
|
|
404
|
+
*/
|
|
405
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/searchfield/useSearchFieldState.ts
|
|
406
|
+
/*
|
|
407
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
408
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
409
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
410
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
411
|
+
*
|
|
412
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
413
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
414
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
415
|
+
* governing permissions and limitations under the License.
|
|
416
|
+
*/
|
|
417
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/select/useSelectState.ts
|
|
418
|
+
/*
|
|
419
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
420
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
421
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
422
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
423
|
+
*
|
|
424
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
425
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
426
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
427
|
+
* governing permissions and limitations under the License.
|
|
428
|
+
*/
|
|
429
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/selection/Selection.ts
|
|
430
|
+
/*
|
|
431
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
432
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
433
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
434
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
435
|
+
*
|
|
436
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
437
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
438
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
439
|
+
* governing permissions and limitations under the License.
|
|
440
|
+
*/
|
|
441
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/selection/SelectionManager.ts
|
|
442
|
+
/*
|
|
443
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
444
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
445
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
446
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
447
|
+
*
|
|
448
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
449
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
450
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
451
|
+
* governing permissions and limitations under the License.
|
|
452
|
+
*/
|
|
453
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/selection/useMultipleSelectionState.ts
|
|
454
|
+
/*
|
|
455
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
456
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
457
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
458
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
459
|
+
*
|
|
460
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
461
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
462
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
463
|
+
* governing permissions and limitations under the License.
|
|
464
|
+
*/
|
|
465
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/slider/useSliderState.ts
|
|
466
|
+
/*
|
|
467
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
468
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
469
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
470
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
471
|
+
*
|
|
472
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
473
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
474
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
475
|
+
* governing permissions and limitations under the License.
|
|
476
|
+
*/
|
|
477
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-aria/src/ssr/SSRProvider.tsx
|
|
478
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-aria/src/utils/useId.ts
|
|
479
|
+
/*
|
|
480
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
481
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
482
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
483
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
484
|
+
*
|
|
485
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
486
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
487
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
488
|
+
* governing permissions and limitations under the License.
|
|
489
|
+
*/
|
|
490
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/steplist/useStepListState.ts
|
|
491
|
+
/*
|
|
492
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
493
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
494
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
495
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
496
|
+
*
|
|
497
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
498
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
499
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
500
|
+
* governing permissions and limitations under the License.
|
|
501
|
+
*/
|
|
502
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/table/TableCollection.ts
|
|
503
|
+
/*
|
|
504
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
505
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
506
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
507
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
508
|
+
*
|
|
509
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
510
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
511
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
512
|
+
* governing permissions and limitations under the License.
|
|
513
|
+
*/
|
|
514
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/table/useTableColumnResizeState.ts
|
|
515
|
+
/*
|
|
516
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
517
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
518
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
519
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
520
|
+
*
|
|
521
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
522
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
523
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
524
|
+
* governing permissions and limitations under the License.
|
|
525
|
+
*/
|
|
526
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/table/useTableState.ts
|
|
527
|
+
/*
|
|
528
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
529
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
530
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
531
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
532
|
+
*
|
|
533
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
534
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
535
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
536
|
+
* governing permissions and limitations under the License.
|
|
537
|
+
*/
|
|
538
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/table/useTreeGridState.ts
|
|
539
|
+
/*
|
|
540
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
541
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
542
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
543
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
544
|
+
*
|
|
545
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
546
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
547
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
548
|
+
* governing permissions and limitations under the License.
|
|
549
|
+
*/
|
|
550
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/tabs/useTabListState.ts
|
|
551
|
+
/*
|
|
552
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
553
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
554
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
555
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
556
|
+
*
|
|
557
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
558
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
559
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
560
|
+
* governing permissions and limitations under the License.
|
|
561
|
+
*/
|
|
562
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/utils/useControlledState.ts
|
|
563
|
+
/*
|
|
564
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
565
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
566
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
567
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
568
|
+
*
|
|
569
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
570
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
571
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
572
|
+
* governing permissions and limitations under the License.
|
|
573
|
+
*/
|
|
574
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/toast/useToastState.ts
|
|
575
|
+
/*
|
|
576
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
577
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
578
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
579
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
580
|
+
*
|
|
581
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
582
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
583
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
584
|
+
* governing permissions and limitations under the License.
|
|
585
|
+
*/
|
|
586
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/toggle/useToggleGroupState.ts
|
|
587
|
+
/*
|
|
588
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
589
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
590
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
591
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
592
|
+
*
|
|
593
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
594
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
595
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
596
|
+
* governing permissions and limitations under the License.
|
|
597
|
+
*/
|
|
598
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/toggle/useToggleState.ts
|
|
599
|
+
/*
|
|
600
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
601
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
602
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
603
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
604
|
+
*
|
|
605
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
606
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
607
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
608
|
+
* governing permissions and limitations under the License.
|
|
609
|
+
*/
|
|
610
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/tokenfield/TokenFieldValue.ts
|
|
611
|
+
/*
|
|
612
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
613
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
614
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
615
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
616
|
+
*
|
|
617
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
618
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
619
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
620
|
+
* governing permissions and limitations under the License.
|
|
621
|
+
*/
|
|
622
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/tokenfield/useTokenFieldState.ts
|
|
623
|
+
/*
|
|
624
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
625
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
626
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
627
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
628
|
+
*
|
|
629
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
630
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
631
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
632
|
+
* governing permissions and limitations under the License.
|
|
633
|
+
*/
|
|
634
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/tooltip/useTooltipTriggerState.ts
|
|
635
|
+
/*
|
|
636
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
637
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
638
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
639
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
640
|
+
*
|
|
641
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
642
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
643
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
644
|
+
* governing permissions and limitations under the License.
|
|
645
|
+
*/
|
|
646
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/tree/TreeCollection.ts
|
|
647
|
+
/*
|
|
648
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
649
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
650
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
651
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
652
|
+
*
|
|
653
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
654
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
655
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
656
|
+
* governing permissions and limitations under the License.
|
|
657
|
+
*/
|
|
658
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/tree/useTreeState.ts
|
|
659
|
+
import { createContext, createEffect, createMemo, createSignal, createUniqueId, flush, getObserver, getOwner, onCleanup, untrack, useContext } from "solid-js";
|
|
660
|
+
import { isServer as isServer$1 } from "@solidjs/web";
|
|
3
661
|
import { CalendarDate, CalendarDate as CalendarDateClass, CalendarDateTime as CalendarDateTimeClass, DateFormatter, DateFormatter as DateFormatter$1, GregorianCalendar, GregorianCalendar as GregorianCalendar$1, Time, Time as TimeClass, ZonedDateTime as ZonedDateTimeClass, createCalendar, createCalendar as createCalendar$1, endOfMonth, endOfMonth as endOfMonth$1, endOfWeek, endOfYear, getDayOfWeek, getLocalTimeZone, getLocalTimeZone as getLocalTimeZone$1, getWeeksInMonth, getWeeksInMonth as getWeeksInMonth$1, isEqualCalendar, isSameDay, isSameDay as isSameDay$1, isSameMonth, isSameMonth as isSameMonth$1, isSameYear, isToday, isWeekend, maxDate, maxDate as maxDate$1, minDate, minDate as minDate$1, now, now as now$1, parseAbsolute, parseAbsoluteToLocal, parseDate, parseDateTime, parseTime, parseZonedDateTime, startOfMonth, startOfMonth as startOfMonth$1, startOfWeek, startOfWeek as startOfWeek$1, startOfYear, toCalendar, toCalendar as toCalendar$1, toCalendarDate, toCalendarDate as toCalendarDate$1, toCalendarDateTime, toCalendarDateTime as toCalendarDateTime$1, toTime, toTime as toTime$1, toZoned, toZoned as toZoned$1, today, today as today$1 } from "@internationalized/date";
|
|
662
|
+
import { NumberFormatter, NumberParser } from "@internationalized/number";
|
|
4
663
|
//#region src/utils/reactivity.ts
|
|
5
664
|
/**
|
|
665
|
+
* Reactivity utilities for Solid Stately
|
|
666
|
+
*
|
|
667
|
+
* Provides type-safe utilities for working with SolidJS reactivity patterns.
|
|
668
|
+
*/
|
|
669
|
+
/**
|
|
6
670
|
* Unwraps a MaybeAccessor to get the underlying value.
|
|
7
671
|
* If the input is a function, it calls it to get the value.
|
|
8
672
|
* Otherwise, it returns the value directly.
|
|
@@ -18,15 +682,60 @@ function access(value) {
|
|
|
18
682
|
function isAccessor(value) {
|
|
19
683
|
return typeof value === "function";
|
|
20
684
|
}
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/toggle/createToggleState.ts
|
|
23
685
|
/**
|
|
24
|
-
*
|
|
686
|
+
* Headless state is written from factory setup and from public setters that
|
|
687
|
+
* tests (and some call sites) invoke inside `createRoot` / a component body.
|
|
688
|
+
* Solid 2 throws on those writes unless the signal opts into `ownedWrite`.
|
|
25
689
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
690
|
+
* Solid 2 also hides unflushed writes from both default reads (unowned /
|
|
691
|
+
* committed snapshot) and `latest()` (A28: flush first to read your own
|
|
692
|
+
* write). Headless methods chain read-then-write in the same turn, so the
|
|
693
|
+
* getter returns a live mirror and still reads the signal for tracking.
|
|
694
|
+
*/
|
|
695
|
+
function createInternalSignal(value, options) {
|
|
696
|
+
let live = value;
|
|
697
|
+
const [get, set] = createSignal(value, {
|
|
698
|
+
...options,
|
|
699
|
+
ownedWrite: true
|
|
700
|
+
});
|
|
701
|
+
const read = (() => {
|
|
702
|
+
if (getObserver()) get();
|
|
703
|
+
return live;
|
|
704
|
+
});
|
|
705
|
+
const write = ((next) => {
|
|
706
|
+
const resolved = typeof next === "function" ? next(live) : next;
|
|
707
|
+
live = resolved;
|
|
708
|
+
set(resolved);
|
|
709
|
+
return resolved;
|
|
710
|
+
});
|
|
711
|
+
return [read, write];
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Same-turn read of a headless accessor. `createInternalSignal` getters
|
|
715
|
+
* already return the live mirror; this is for call sites that used to wrap
|
|
716
|
+
* `latest()` (which does not see unflushed writes in Solid 2 rc.9).
|
|
29
717
|
*/
|
|
718
|
+
function readNow(accessor) {
|
|
719
|
+
return accessor();
|
|
720
|
+
}
|
|
721
|
+
//#endregion
|
|
722
|
+
//#region src/utils/owner.ts
|
|
723
|
+
/**
|
|
724
|
+
* Solid 2 owner guards. `useContext` throws when there is no reactive root,
|
|
725
|
+
* even if the context has a default — hook factories (and tests) call
|
|
726
|
+
* `createFormValidationState` outside a component.
|
|
727
|
+
*/
|
|
728
|
+
/** Read context, or the context default, when called with no owner. */
|
|
729
|
+
function useContextOptional(context) {
|
|
730
|
+
if (!getOwner()) return context.defaultValue;
|
|
731
|
+
try {
|
|
732
|
+
return useContext(context);
|
|
733
|
+
} catch {
|
|
734
|
+
return context.defaultValue;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
//#endregion
|
|
738
|
+
//#region src/toggle/createToggleState.ts
|
|
30
739
|
/**
|
|
31
740
|
* Provides state management for toggle components like checkboxes and switches.
|
|
32
741
|
*/
|
|
@@ -34,7 +743,7 @@ function createToggleState(props = {}) {
|
|
|
34
743
|
const getProps = () => access(props);
|
|
35
744
|
const initialProps = getProps();
|
|
36
745
|
const initialSelected = initialProps.isSelected ?? initialProps.defaultSelected ?? false;
|
|
37
|
-
const [internalSelected, setInternalSelected] =
|
|
746
|
+
const [internalSelected, setInternalSelected] = createInternalSignal(initialSelected);
|
|
38
747
|
const isControlled = () => getProps().isSelected !== void 0;
|
|
39
748
|
const isSelected = () => {
|
|
40
749
|
const p = getProps();
|
|
@@ -47,8 +756,9 @@ function createToggleState(props = {}) {
|
|
|
47
756
|
p.onChange?.(value);
|
|
48
757
|
}
|
|
49
758
|
function toggle() {
|
|
50
|
-
|
|
51
|
-
|
|
759
|
+
const p = getProps();
|
|
760
|
+
if (p.isReadOnly) return;
|
|
761
|
+
setSelected(!(isControlled() ? p.isSelected ?? false : readNow(internalSelected)));
|
|
52
762
|
}
|
|
53
763
|
return {
|
|
54
764
|
isSelected,
|
|
@@ -59,14 +769,6 @@ function createToggleState(props = {}) {
|
|
|
59
769
|
}
|
|
60
770
|
//#endregion
|
|
61
771
|
//#region src/toggle/createToggleGroupState.ts
|
|
62
|
-
/**
|
|
63
|
-
* Toggle group state for Solid Stately
|
|
64
|
-
*
|
|
65
|
-
* Provides state management for groups of toggle buttons with
|
|
66
|
-
* single or multiple selection.
|
|
67
|
-
*
|
|
68
|
-
* This is a port of @react-stately/toggle's useToggleGroupState.
|
|
69
|
-
*/
|
|
70
772
|
function toKeySet(keys) {
|
|
71
773
|
return new Set(keys ? Array.from(keys) : []);
|
|
72
774
|
}
|
|
@@ -75,7 +777,7 @@ function toKeySet(keys) {
|
|
|
75
777
|
*/
|
|
76
778
|
function createToggleGroupState(props = {}) {
|
|
77
779
|
const getProps = () => access(props);
|
|
78
|
-
const [internalSelectedKeys, setInternalSelectedKeys] =
|
|
780
|
+
const [internalSelectedKeys, setInternalSelectedKeys] = createInternalSignal(toKeySet(getProps().defaultSelectedKeys));
|
|
79
781
|
const isControlled = () => getProps().selectedKeys !== void 0;
|
|
80
782
|
const selectedKeys = () => isControlled() ? toKeySet(getProps().selectedKeys) : internalSelectedKeys();
|
|
81
783
|
function setSelectedKeys(keys) {
|
|
@@ -87,7 +789,7 @@ function createToggleGroupState(props = {}) {
|
|
|
87
789
|
const props = getProps();
|
|
88
790
|
const mode = props.selectionMode ?? "single";
|
|
89
791
|
const disallowEmptySelection = props.disallowEmptySelection ?? false;
|
|
90
|
-
const currentKeys = selectedKeys();
|
|
792
|
+
const currentKeys = isControlled() ? toKeySet(props.selectedKeys) : readNow(internalSelectedKeys);
|
|
91
793
|
let nextKeys;
|
|
92
794
|
if (mode === "multiple") {
|
|
93
795
|
nextKeys = new Set(currentKeys);
|
|
@@ -107,7 +809,7 @@ function createToggleGroupState(props = {}) {
|
|
|
107
809
|
return getProps().isDisabled ?? false;
|
|
108
810
|
},
|
|
109
811
|
get selectedKeys() {
|
|
110
|
-
return new Set(selectedKeys());
|
|
812
|
+
return new Set(isControlled() ? selectedKeys() : readNow(internalSelectedKeys));
|
|
111
813
|
},
|
|
112
814
|
toggleKey,
|
|
113
815
|
setSelected,
|
|
@@ -117,11 +819,6 @@ function createToggleGroupState(props = {}) {
|
|
|
117
819
|
//#endregion
|
|
118
820
|
//#region src/autocomplete/createAutocompleteState.ts
|
|
119
821
|
/**
|
|
120
|
-
* createAutocompleteState - State management for autocomplete components
|
|
121
|
-
*
|
|
122
|
-
* Based on @react-stately/autocomplete useAutocompleteState.
|
|
123
|
-
*/
|
|
124
|
-
/**
|
|
125
822
|
* Provides state management for an autocomplete component.
|
|
126
823
|
*
|
|
127
824
|
* @example
|
|
@@ -143,9 +840,9 @@ function createToggleGroupState(props = {}) {
|
|
|
143
840
|
*/
|
|
144
841
|
function createAutocompleteState(props = {}) {
|
|
145
842
|
const getProps = () => access(props);
|
|
146
|
-
const [focusedNodeId, setFocusedNodeId] =
|
|
843
|
+
const [focusedNodeId, setFocusedNodeId] = createInternalSignal(null);
|
|
147
844
|
const isControlled = () => getProps().inputValue !== void 0;
|
|
148
|
-
const [uncontrolledValue, setUncontrolledValue] =
|
|
845
|
+
const [uncontrolledValue, setUncontrolledValue] = createInternalSignal(getProps().defaultInputValue ?? "");
|
|
149
846
|
const inputValue = () => {
|
|
150
847
|
const p = getProps();
|
|
151
848
|
return isControlled() ? p.inputValue ?? "" : uncontrolledValue();
|
|
@@ -165,21 +862,13 @@ function createAutocompleteState(props = {}) {
|
|
|
165
862
|
//#endregion
|
|
166
863
|
//#region src/textfield/createTextFieldState.ts
|
|
167
864
|
/**
|
|
168
|
-
* TextField state for Solid Stately
|
|
169
|
-
*
|
|
170
|
-
* Provides state management for text input components.
|
|
171
|
-
*
|
|
172
|
-
* This is a port of @react-stately/utils's useControlledState pattern
|
|
173
|
-
* as used by @react-aria/textfield.
|
|
174
|
-
*/
|
|
175
|
-
/**
|
|
176
865
|
* Provides state management for text input components.
|
|
177
866
|
* Supports both controlled and uncontrolled modes.
|
|
178
867
|
*/
|
|
179
868
|
function createTextFieldState(props = {}) {
|
|
180
869
|
const getProps = () => access(props);
|
|
181
870
|
const initialProps = getProps();
|
|
182
|
-
const [internalValue, setInternalValue] =
|
|
871
|
+
const [internalValue, setInternalValue] = createInternalSignal(initialProps.value ?? initialProps.defaultValue ?? "");
|
|
183
872
|
const isControlled = () => getProps().value !== void 0;
|
|
184
873
|
const value = () => {
|
|
185
874
|
const p = getProps();
|
|
@@ -196,6 +885,297 @@ function createTextFieldState(props = {}) {
|
|
|
196
885
|
};
|
|
197
886
|
}
|
|
198
887
|
//#endregion
|
|
888
|
+
//#region src/tokenfield/TokenFieldValue.ts
|
|
889
|
+
var Direction = /* @__PURE__ */ function(Direction) {
|
|
890
|
+
Direction[Direction["Forward"] = 1] = "Forward";
|
|
891
|
+
Direction[Direction["Backward"] = -1] = "Backward";
|
|
892
|
+
return Direction;
|
|
893
|
+
}(Direction || {});
|
|
894
|
+
/**
|
|
895
|
+
* A list of segments containing editable text and non-editable tokens.
|
|
896
|
+
*/
|
|
897
|
+
var TokenFieldValue = class {
|
|
898
|
+
static Direction = Direction;
|
|
899
|
+
/** The text and token segments in the list. */
|
|
900
|
+
segments;
|
|
901
|
+
/** The caret position. */
|
|
902
|
+
caretPosition = {
|
|
903
|
+
index: 0,
|
|
904
|
+
offset: 0
|
|
905
|
+
};
|
|
906
|
+
previous = null;
|
|
907
|
+
next = null;
|
|
908
|
+
isCoalescing = true;
|
|
909
|
+
/** Create a new list with the given segments. */
|
|
910
|
+
constructor(tokens, options) {
|
|
911
|
+
this.segments = tokens;
|
|
912
|
+
this.caretPosition = options?.caretPosition ?? {
|
|
913
|
+
index: 0,
|
|
914
|
+
offset: 0
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
createFieldValue(segments) {
|
|
918
|
+
const Constructor = this.constructor;
|
|
919
|
+
return new Constructor(segments);
|
|
920
|
+
}
|
|
921
|
+
/** Create a new list with the caret position set to the given position. */
|
|
922
|
+
withCaretPosition(caretPosition) {
|
|
923
|
+
if (this.caretPosition.index === caretPosition.index && this.caretPosition.offset === caretPosition.offset) return this;
|
|
924
|
+
let result = this.createFieldValue(this.segments);
|
|
925
|
+
result.caretPosition = caretPosition;
|
|
926
|
+
result.previous = this.previous;
|
|
927
|
+
result.next = this.next;
|
|
928
|
+
result.isCoalescing = this.isCoalescing;
|
|
929
|
+
return result;
|
|
930
|
+
}
|
|
931
|
+
splitSegment(segment, offset) {
|
|
932
|
+
if (!segment) {
|
|
933
|
+
let empty = this.createTextSegment("");
|
|
934
|
+
return [offset > 0 ? empty : null, offset > 0 ? null : empty];
|
|
935
|
+
}
|
|
936
|
+
if (segment.type === "token") return [offset > 0 ? { ...segment } : null, offset > 0 ? null : { ...segment }];
|
|
937
|
+
return [offset > 0 ? {
|
|
938
|
+
type: "text",
|
|
939
|
+
text: segment.text.slice(0, offset)
|
|
940
|
+
} : null, offset < segment.text.length ? this.createTextSegment(segment.text.slice(offset)) : null];
|
|
941
|
+
}
|
|
942
|
+
createTextSegment(text) {
|
|
943
|
+
return {
|
|
944
|
+
type: "text",
|
|
945
|
+
text
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
tokenize(text) {
|
|
949
|
+
return [this.createTextSegment(text)];
|
|
950
|
+
}
|
|
951
|
+
clampPosition(position) {
|
|
952
|
+
if (this.segments.length > 0 && position.index >= this.segments.length) return {
|
|
953
|
+
index: this.segments.length - 1,
|
|
954
|
+
offset: this.segments[this.segments.length - 1].text.length
|
|
955
|
+
};
|
|
956
|
+
if (position.index < 0) return {
|
|
957
|
+
index: 0,
|
|
958
|
+
offset: 0
|
|
959
|
+
};
|
|
960
|
+
return position;
|
|
961
|
+
}
|
|
962
|
+
/** Replace the text between two positions with new text. */
|
|
963
|
+
replaceRange(start, end, text, coalesce = true) {
|
|
964
|
+
return this.replaceRangeWithSegments(start, end, text.length > 0 ? [this.createTextSegment(text)] : [], coalesce);
|
|
965
|
+
}
|
|
966
|
+
/** Replace the text between two positions with new segments. */
|
|
967
|
+
replaceRangeWithSegments(start, end, insert, coalesce = true) {
|
|
968
|
+
start = this.clampPosition(start);
|
|
969
|
+
end = this.clampPosition(end);
|
|
970
|
+
let startSegment = this.segments[start.index];
|
|
971
|
+
let endSegment = this.segments[end.index];
|
|
972
|
+
let [startSplit] = this.splitSegment(startSegment, start.offset);
|
|
973
|
+
let [, endSplit] = this.splitSegment(endSegment, end.offset);
|
|
974
|
+
let newSegments = this.segments.slice(0, start.index);
|
|
975
|
+
if (startSplit) appendSegments(newSegments, [startSplit]);
|
|
976
|
+
if (insert.length) appendSegments(newSegments, insert, (text) => this.tokenize(text));
|
|
977
|
+
let lastSegment = newSegments[newSegments.length - 1];
|
|
978
|
+
let lastIsText = lastSegment && lastSegment.type === "text";
|
|
979
|
+
let caret = {
|
|
980
|
+
index: lastIsText ? newSegments.length - 1 : newSegments.length,
|
|
981
|
+
offset: lastIsText ? lastSegment.text.length : 0
|
|
982
|
+
};
|
|
983
|
+
if (endSplit) appendSegments(newSegments, [endSplit]);
|
|
984
|
+
appendSegments(newSegments, this.segments.slice(end.index + 1));
|
|
985
|
+
let segments = this.createFieldValue(newSegments);
|
|
986
|
+
segments.caretPosition = caret;
|
|
987
|
+
segments.isCoalescing = coalesce;
|
|
988
|
+
if (this.isCoalescing && coalesce && this.previous) {
|
|
989
|
+
segments.previous = this.previous;
|
|
990
|
+
segments.previous.next = segments;
|
|
991
|
+
} else {
|
|
992
|
+
segments.previous = this;
|
|
993
|
+
this.caretPosition = end;
|
|
994
|
+
this.next = segments;
|
|
995
|
+
}
|
|
996
|
+
return segments;
|
|
997
|
+
}
|
|
998
|
+
/** Find the boundary before or after a position using an Intl.Segmenter. */
|
|
999
|
+
findBoundaryWithSegmenter(position, segmenter, direction) {
|
|
1000
|
+
position = this.clampPosition(position);
|
|
1001
|
+
for (let i = position.index; i >= 0 && i < this.segments.length; i += direction) {
|
|
1002
|
+
let segment = this.segments[i];
|
|
1003
|
+
switch (segment.type) {
|
|
1004
|
+
case "token":
|
|
1005
|
+
if (i !== position.index || (direction === -1 ? position.offset > 0 : position.offset === 0)) {
|
|
1006
|
+
let index = i + direction;
|
|
1007
|
+
return {
|
|
1008
|
+
index: index >= 0 ? index : 0,
|
|
1009
|
+
offset: direction === -1 && index >= 0 ? this.segments[index].text.length : 0
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
continue;
|
|
1013
|
+
case "text": {
|
|
1014
|
+
let offset = direction === -1 ? segment.text.length : 0;
|
|
1015
|
+
if (i === position.index) offset = position.offset;
|
|
1016
|
+
if (direction === -1) offset--;
|
|
1017
|
+
if (offset < 0 || offset >= segment.text.length) continue;
|
|
1018
|
+
let part = segmenter.segment(segment.text).containing(offset);
|
|
1019
|
+
while (part && part.isWordLike === false) {
|
|
1020
|
+
offset += direction;
|
|
1021
|
+
part = segmenter.segment(segment.text).containing(offset);
|
|
1022
|
+
}
|
|
1023
|
+
if (part) return {
|
|
1024
|
+
index: i,
|
|
1025
|
+
offset: direction === -1 ? part.index : part.index + part.segment.length
|
|
1026
|
+
};
|
|
1027
|
+
continue;
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
return null;
|
|
1032
|
+
}
|
|
1033
|
+
/** Find a line boundary before or after a position. */
|
|
1034
|
+
findLineBoundary(position, direction) {
|
|
1035
|
+
let res = this.findText(position, direction, "\n");
|
|
1036
|
+
if (res) return res;
|
|
1037
|
+
return direction === -1 ? {
|
|
1038
|
+
index: 0,
|
|
1039
|
+
offset: 0
|
|
1040
|
+
} : {
|
|
1041
|
+
index: this.segments.length - 1,
|
|
1042
|
+
offset: this.segments[this.segments.length - 1].text.length
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
/** Find a string or regular expression match before or after a position. */
|
|
1046
|
+
findText(position, direction, search) {
|
|
1047
|
+
if (this.segments.length === 0) return null;
|
|
1048
|
+
for (let i = position.index; i >= 0 && i < this.segments.length; i += direction) {
|
|
1049
|
+
let segment = this.segments[i];
|
|
1050
|
+
if (segment.type !== "text") continue;
|
|
1051
|
+
let offset = findInText(segment.text, search, direction, i === position.index ? position.offset : void 0);
|
|
1052
|
+
if (offset >= 0) return {
|
|
1053
|
+
index: i,
|
|
1054
|
+
offset
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
return null;
|
|
1058
|
+
}
|
|
1059
|
+
/** Delete text at a position using a segmenter. */
|
|
1060
|
+
delete(position, segmenter, direction, coalesce = true) {
|
|
1061
|
+
let boundary = this.findBoundaryWithSegmenter(position, segmenter, direction);
|
|
1062
|
+
if (boundary) return this.replaceRange(direction === -1 ? boundary : position, direction === -1 ? position : boundary, "", coalesce);
|
|
1063
|
+
this.caretPosition = position;
|
|
1064
|
+
return this;
|
|
1065
|
+
}
|
|
1066
|
+
/** Delete text to the next or previous line break. */
|
|
1067
|
+
deleteLine(position, direction, coalesce = true) {
|
|
1068
|
+
if (this.segments.length === 0) return this;
|
|
1069
|
+
let boundary = this.findLineBoundary(position, direction);
|
|
1070
|
+
if (boundary) return this.replaceRange(direction === -1 ? boundary : position, direction === -1 ? position : boundary, "", coalesce);
|
|
1071
|
+
return this;
|
|
1072
|
+
}
|
|
1073
|
+
/** Create a new list containing a subset of the segments. */
|
|
1074
|
+
slice(start, end) {
|
|
1075
|
+
start = this.clampPosition(start);
|
|
1076
|
+
end = this.clampPosition(end);
|
|
1077
|
+
if (start.index === end.index && start.offset === end.offset) return this.createFieldValue([]);
|
|
1078
|
+
if (start.index === end.index) {
|
|
1079
|
+
let segment = this.segments[start.index];
|
|
1080
|
+
if (segment.type === "text") return this.createFieldValue([{
|
|
1081
|
+
type: "text",
|
|
1082
|
+
text: segment.text.slice(start.offset, end.offset)
|
|
1083
|
+
}]);
|
|
1084
|
+
return this.createFieldValue([segment]);
|
|
1085
|
+
}
|
|
1086
|
+
let startSegment = this.segments[start.index];
|
|
1087
|
+
let endSegment = this.segments[end.index];
|
|
1088
|
+
let [, startSplit] = this.splitSegment(startSegment, start.offset);
|
|
1089
|
+
let [endSplit] = this.splitSegment(endSegment, end.offset);
|
|
1090
|
+
let result = [];
|
|
1091
|
+
if (startSplit) result.push(startSplit);
|
|
1092
|
+
result.push(...this.segments.slice(start.index + 1, end.index));
|
|
1093
|
+
if (endSplit) result.push(endSplit);
|
|
1094
|
+
return this.createFieldValue(result);
|
|
1095
|
+
}
|
|
1096
|
+
/** Convert the list to a string. */
|
|
1097
|
+
toString() {
|
|
1098
|
+
return this.segments.map((seg) => seg.text).join("");
|
|
1099
|
+
}
|
|
1100
|
+
/** Returns the previous list in the undo history. */
|
|
1101
|
+
undo() {
|
|
1102
|
+
return this.previous ?? this;
|
|
1103
|
+
}
|
|
1104
|
+
/** Returns the next list in the redo history. */
|
|
1105
|
+
redo() {
|
|
1106
|
+
return this.next ?? this;
|
|
1107
|
+
}
|
|
1108
|
+
/** End coalescing undo/redo history. */
|
|
1109
|
+
endCoalescing() {
|
|
1110
|
+
this.isCoalescing = false;
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
function findInText(text, search, direction, fromOffset) {
|
|
1114
|
+
if (typeof search === "string") {
|
|
1115
|
+
if (direction === -1) return text.lastIndexOf(search, fromOffset !== void 0 ? fromOffset - 1 : text.length - 1);
|
|
1116
|
+
return text.indexOf(search, fromOffset ?? 0);
|
|
1117
|
+
}
|
|
1118
|
+
if (direction === 1) {
|
|
1119
|
+
let start = fromOffset ?? 0;
|
|
1120
|
+
let index = text.slice(start).search(search);
|
|
1121
|
+
return index >= 0 ? start + index : -1;
|
|
1122
|
+
}
|
|
1123
|
+
let limit = fromOffset !== void 0 ? fromOffset : text.length;
|
|
1124
|
+
if (limit < 0) return -1;
|
|
1125
|
+
let re = search.flags.includes("g") ? search : new RegExp(search.source, search.flags + "g");
|
|
1126
|
+
return Array.from(text.slice(0, limit).matchAll(re)).at(-1)?.index ?? -1;
|
|
1127
|
+
}
|
|
1128
|
+
function appendSegments(segments, insert, tokenize) {
|
|
1129
|
+
for (let segment of insert) {
|
|
1130
|
+
if (segment.type === "text" && segment.text.length === 0) continue;
|
|
1131
|
+
let last = segments[segments.length - 1];
|
|
1132
|
+
if (last && last.type === "text" && segment.type === "text") {
|
|
1133
|
+
if (tokenize) {
|
|
1134
|
+
let tokenized = tokenize(last.text + segment.text);
|
|
1135
|
+
segments.splice(segments.length - 1, 1, ...tokenized);
|
|
1136
|
+
} else segments[segments.length - 1] = {
|
|
1137
|
+
type: "text",
|
|
1138
|
+
text: last.text + segment.text
|
|
1139
|
+
};
|
|
1140
|
+
} else if (tokenize && segment.type === "text") {
|
|
1141
|
+
let tokenized = tokenize(segment.text);
|
|
1142
|
+
segments.push(...tokenized);
|
|
1143
|
+
} else segments.push(segment);
|
|
1144
|
+
}
|
|
1145
|
+
return segments;
|
|
1146
|
+
}
|
|
1147
|
+
//#endregion
|
|
1148
|
+
//#region src/tokenfield/createTokenFieldState.ts
|
|
1149
|
+
/**
|
|
1150
|
+
* Provides state management for a token field. Tracks the field value and the
|
|
1151
|
+
* composition state.
|
|
1152
|
+
*/
|
|
1153
|
+
function createTokenFieldState(props = {}) {
|
|
1154
|
+
const getProps = () => access(props);
|
|
1155
|
+
const initialProps = getProps();
|
|
1156
|
+
const initialValue = initialProps.value ?? initialProps.defaultValue ?? new TokenFieldValue([]);
|
|
1157
|
+
const [internalValue, setInternalValue] = createInternalSignal(initialValue);
|
|
1158
|
+
const [isComposing, setComposing] = createInternalSignal(false);
|
|
1159
|
+
const isControlled = () => getProps().value !== void 0;
|
|
1160
|
+
const value = () => {
|
|
1161
|
+
const p = getProps();
|
|
1162
|
+
return isControlled() ? p.value ?? initialValue : internalValue();
|
|
1163
|
+
};
|
|
1164
|
+
function setValue(fn) {
|
|
1165
|
+
const p = getProps();
|
|
1166
|
+
const current = value();
|
|
1167
|
+
const next = typeof fn === "function" ? fn(current) : fn;
|
|
1168
|
+
if (!isControlled()) setInternalValue(() => next);
|
|
1169
|
+
p.onChange?.(next);
|
|
1170
|
+
}
|
|
1171
|
+
return {
|
|
1172
|
+
value,
|
|
1173
|
+
setValue,
|
|
1174
|
+
isComposing,
|
|
1175
|
+
setComposing
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
//#endregion
|
|
199
1179
|
//#region src/form/createFormValidationState.ts
|
|
200
1180
|
/**
|
|
201
1181
|
* createFormValidationState for solid-stately
|
|
@@ -285,39 +1265,45 @@ function createFormValidationState(props) {
|
|
|
285
1265
|
validationErrors: [],
|
|
286
1266
|
validationDetails: CUSTOM_VALIDITY_STATE
|
|
287
1267
|
} : null);
|
|
288
|
-
const
|
|
1268
|
+
const computeClientError = () => {
|
|
289
1269
|
const validate = props.validate;
|
|
290
1270
|
if (!validate || props.value == null) return null;
|
|
291
1271
|
return getValidationResult$1(runValidate(validate, props.value));
|
|
292
|
-
}
|
|
1272
|
+
};
|
|
1273
|
+
const clientError = createMemo(computeClientError);
|
|
293
1274
|
const builtinValidation = createMemo(() => {
|
|
294
1275
|
const builtinValidationProp = props.builtinValidation;
|
|
295
1276
|
if (builtinValidationProp?.validationDetails.valid) return;
|
|
296
1277
|
return builtinValidationProp;
|
|
297
1278
|
});
|
|
298
|
-
const serverErrors =
|
|
1279
|
+
const serverErrors = useContextOptional(FormValidationContext) ?? {};
|
|
299
1280
|
const serverErrorMessages = createMemo(() => {
|
|
300
1281
|
const name = props.name;
|
|
301
1282
|
if (name) return Array.isArray(name) ? name.flatMap((n) => asArray(serverErrors[n])) : asArray(serverErrors[name]);
|
|
302
1283
|
return [];
|
|
303
1284
|
});
|
|
304
|
-
const [lastServerErrors, setLastServerErrors] =
|
|
305
|
-
const [isServerErrorCleared, setServerErrorCleared] =
|
|
306
|
-
createEffect(() => {
|
|
307
|
-
|
|
308
|
-
|
|
1285
|
+
const [lastServerErrors, setLastServerErrors] = createInternalSignal(serverErrors);
|
|
1286
|
+
const [isServerErrorCleared, setServerErrorCleared] = createInternalSignal(false);
|
|
1287
|
+
createEffect(() => ({
|
|
1288
|
+
errors: serverErrors,
|
|
1289
|
+
last: lastServerErrors()
|
|
1290
|
+
}), ({ errors, last }) => {
|
|
1291
|
+
if (errors !== last) {
|
|
1292
|
+
setLastServerErrors(errors);
|
|
309
1293
|
setServerErrorCleared(false);
|
|
310
1294
|
}
|
|
311
1295
|
});
|
|
312
1296
|
const serverError = createMemo(() => getValidationResult$1(isServerErrorCleared() ? [] : serverErrorMessages()));
|
|
313
|
-
const [currentValidity, setCurrentValidity] =
|
|
314
|
-
const [commitQueued, setCommitQueued] =
|
|
1297
|
+
const [currentValidity, setCurrentValidity] = createInternalSignal(DEFAULT_VALIDATION_RESULT);
|
|
1298
|
+
const [commitQueued, setCommitQueued] = createInternalSignal(false);
|
|
315
1299
|
let nextValidation = DEFAULT_VALIDATION_RESULT;
|
|
316
1300
|
let lastError = DEFAULT_VALIDATION_RESULT;
|
|
317
|
-
createEffect(() => {
|
|
318
|
-
|
|
1301
|
+
createEffect(() => ({
|
|
1302
|
+
queued: commitQueued(),
|
|
1303
|
+
error: clientError() || builtinValidation() || nextValidation
|
|
1304
|
+
}), ({ queued, error }) => {
|
|
1305
|
+
if (!queued) return;
|
|
319
1306
|
setCommitQueued(false);
|
|
320
|
-
const error = clientError() || builtinValidation() || nextValidation;
|
|
321
1307
|
if (!isEqualValidation(error, lastError)) {
|
|
322
1308
|
lastError = error;
|
|
323
1309
|
setCurrentValidity(error);
|
|
@@ -344,7 +1330,7 @@ function createFormValidationState(props) {
|
|
|
344
1330
|
},
|
|
345
1331
|
commitValidation() {
|
|
346
1332
|
if (validationBehavior() === "native") {
|
|
347
|
-
const error =
|
|
1333
|
+
const error = computeClientError() || builtinValidation() || nextValidation;
|
|
348
1334
|
if (!isEqualValidation(error, lastError)) {
|
|
349
1335
|
lastError = error;
|
|
350
1336
|
setCurrentValidity(error);
|
|
@@ -395,13 +1381,14 @@ function createCheckboxGroupState(props = {}) {
|
|
|
395
1381
|
const getProps = () => access(props);
|
|
396
1382
|
const initialProps = getProps();
|
|
397
1383
|
const initialValue = initialProps.value ?? initialProps.defaultValue ?? [];
|
|
398
|
-
const [internalValue, setInternalValue] =
|
|
1384
|
+
const [internalValue, setInternalValue] = createInternalSignal(initialValue);
|
|
399
1385
|
const controlledValue = createMemo(() => getProps().value);
|
|
400
1386
|
const isControlled = () => controlledValue() !== void 0;
|
|
401
1387
|
const value = () => {
|
|
402
1388
|
const controlled = controlledValue();
|
|
403
1389
|
return controlled !== void 0 ? controlled : internalValue();
|
|
404
1390
|
};
|
|
1391
|
+
const liveValue = () => isControlled() ? value() : readNow(internalValue);
|
|
405
1392
|
const isRequired = () => {
|
|
406
1393
|
return !!getProps().isRequired && value().length === 0;
|
|
407
1394
|
};
|
|
@@ -437,21 +1424,21 @@ function createCheckboxGroupState(props = {}) {
|
|
|
437
1424
|
function addValue(addVal) {
|
|
438
1425
|
const p = getProps();
|
|
439
1426
|
if (p.isReadOnly || p.isDisabled) return;
|
|
440
|
-
const
|
|
441
|
-
if (!
|
|
1427
|
+
const snapshot = liveValue();
|
|
1428
|
+
if (!snapshot.includes(addVal)) setValue([...snapshot, addVal]);
|
|
442
1429
|
}
|
|
443
1430
|
function removeValue(removeVal) {
|
|
444
1431
|
const p = getProps();
|
|
445
1432
|
if (p.isReadOnly || p.isDisabled) return;
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
1433
|
+
const snapshot = liveValue();
|
|
1434
|
+
if (snapshot.includes(removeVal)) setValue(snapshot.filter((v) => v !== removeVal));
|
|
448
1435
|
}
|
|
449
1436
|
function toggleValue(toggleVal) {
|
|
450
1437
|
const p = getProps();
|
|
451
1438
|
if (p.isReadOnly || p.isDisabled) return;
|
|
452
|
-
const
|
|
453
|
-
if (
|
|
454
|
-
else setValue([...
|
|
1439
|
+
const snapshot = liveValue();
|
|
1440
|
+
if (snapshot.includes(toggleVal)) setValue(snapshot.filter((v) => v !== toggleVal));
|
|
1441
|
+
else setValue([...snapshot, toggleVal]);
|
|
455
1442
|
}
|
|
456
1443
|
return {
|
|
457
1444
|
value,
|
|
@@ -484,10 +1471,14 @@ function createCheckboxGroupState(props = {}) {
|
|
|
484
1471
|
* SSR utilities for Solid Stately
|
|
485
1472
|
*
|
|
486
1473
|
* SolidJS has built-in SSR support with `isServer` and `createUniqueId()`.
|
|
487
|
-
* These utilities provide a consistent
|
|
1474
|
+
* These utilities provide a consistent port of the upstream SSR API.
|
|
1475
|
+
*
|
|
1476
|
+
* Ported from:
|
|
1477
|
+
* - packages/react-aria/src/ssr/SSRProvider.tsx
|
|
1478
|
+
* - packages/react-aria/src/utils/useId.ts
|
|
488
1479
|
*/
|
|
489
1480
|
/**
|
|
490
|
-
* Re-export isServer from
|
|
1481
|
+
* Re-export isServer from @solidjs/web for convenience.
|
|
491
1482
|
*/
|
|
492
1483
|
const isServer = isServer$1;
|
|
493
1484
|
/**
|
|
@@ -504,8 +1495,9 @@ function createIsSSR() {
|
|
|
504
1495
|
* @param defaultId - Optional default ID to use instead of generating one.
|
|
505
1496
|
*/
|
|
506
1497
|
function createId(defaultId) {
|
|
1498
|
+
const uniqueId = createUniqueId();
|
|
507
1499
|
if (defaultId) return defaultId;
|
|
508
|
-
return `solid-stately-${
|
|
1500
|
+
return `solid-stately-${uniqueId}`;
|
|
509
1501
|
}
|
|
510
1502
|
/**
|
|
511
1503
|
* Check if we can use DOM APIs.
|
|
@@ -539,9 +1531,9 @@ function createRadioGroupState(props = {}) {
|
|
|
539
1531
|
const getProps = () => access(props);
|
|
540
1532
|
const initialProps = untrack(() => getProps());
|
|
541
1533
|
const name = initialProps.name || `radio-group-${createId()}`;
|
|
542
|
-
const [internalValue, setInternalValue] =
|
|
543
|
-
const [lastFocusedValue, setLastFocusedValueInternal] =
|
|
544
|
-
const [syncVersion, setSyncVersion] =
|
|
1534
|
+
const [internalValue, setInternalValue] = createInternalSignal(initialProps.defaultValue ?? null);
|
|
1535
|
+
const [lastFocusedValue, setLastFocusedValueInternal] = createInternalSignal(null);
|
|
1536
|
+
const [syncVersion, setSyncVersion] = createInternalSignal(0);
|
|
545
1537
|
const controlledValue = createMemo(() => {
|
|
546
1538
|
const value = getProps().value;
|
|
547
1539
|
return value === void 0 ? void 0 : value ?? null;
|
|
@@ -614,16 +1606,13 @@ function createRadioGroupState(props = {}) {
|
|
|
614
1606
|
//#endregion
|
|
615
1607
|
//#region src/overlays/createOverlayTriggerState.ts
|
|
616
1608
|
/**
|
|
617
|
-
* Manages state for an overlay trigger.
|
|
618
|
-
* Based on @react-stately/overlays useOverlayTriggerState.
|
|
619
|
-
*/
|
|
620
|
-
/**
|
|
621
1609
|
* Manages state for an overlay trigger. Tracks whether the overlay is open, and provides
|
|
622
1610
|
* methods to toggle this state.
|
|
623
1611
|
*/
|
|
624
1612
|
function createOverlayTriggerState(props = {}) {
|
|
625
1613
|
const propsAccessor = () => access(props);
|
|
626
|
-
const [internalOpen, setInternalOpen] =
|
|
1614
|
+
const [internalOpen, setInternalOpen] = createInternalSignal(propsAccessor().defaultOpen ?? false);
|
|
1615
|
+
const [point, setPoint] = createInternalSignal(null);
|
|
627
1616
|
const isOpen = () => {
|
|
628
1617
|
const p = propsAccessor();
|
|
629
1618
|
return p.isOpen !== void 0 ? p.isOpen : internalOpen();
|
|
@@ -635,13 +1624,19 @@ function createOverlayTriggerState(props = {}) {
|
|
|
635
1624
|
};
|
|
636
1625
|
const open = () => setOpen(true);
|
|
637
1626
|
const close = () => setOpen(false);
|
|
638
|
-
const toggle = () =>
|
|
1627
|
+
const toggle = () => {
|
|
1628
|
+
const p = propsAccessor();
|
|
1629
|
+
const open = p.isOpen !== void 0 ? p.isOpen : readNow(internalOpen);
|
|
1630
|
+
setOpen(!open);
|
|
1631
|
+
};
|
|
639
1632
|
return {
|
|
640
1633
|
isOpen,
|
|
641
1634
|
setOpen,
|
|
642
1635
|
open,
|
|
643
1636
|
close,
|
|
644
|
-
toggle
|
|
1637
|
+
toggle,
|
|
1638
|
+
point,
|
|
1639
|
+
setPoint
|
|
645
1640
|
};
|
|
646
1641
|
}
|
|
647
1642
|
//#endregion
|
|
@@ -784,8 +1779,8 @@ function getNthItem(iterable, index) {
|
|
|
784
1779
|
const itemCountCache = /* @__PURE__ */ new WeakMap();
|
|
785
1780
|
/**
|
|
786
1781
|
* Counts the item nodes (recursing into sections, ignoring section headers and
|
|
787
|
-
* other non-item nodes) in a collection.
|
|
788
|
-
*
|
|
1782
|
+
* other non-item nodes) in a collection. Ported from
|
|
1783
|
+
* packages/react-stately/src/collections/getItemCount.ts; used by createOption to populate
|
|
789
1784
|
* `aria-setsize` when the listbox is virtualized. Cached per (immutable)
|
|
790
1785
|
* collection identity, exactly like upstream.
|
|
791
1786
|
*/
|
|
@@ -828,16 +1823,18 @@ function getAncestors(collection, node) {
|
|
|
828
1823
|
//#region src/collections/createSelectionState.ts
|
|
829
1824
|
/**
|
|
830
1825
|
* Selection state management for collections.
|
|
831
|
-
*
|
|
1826
|
+
* Ported from:
|
|
1827
|
+
* - packages/react-stately/src/selection/useMultipleSelectionState.ts
|
|
1828
|
+
* - packages/react-stately/src/selection/SelectionManager.ts
|
|
832
1829
|
*/
|
|
833
1830
|
/**
|
|
834
1831
|
* Creates selection state for a collection.
|
|
835
1832
|
*/
|
|
836
1833
|
function createSelectionState(props = {}) {
|
|
837
1834
|
const getProps = () => access(props);
|
|
838
|
-
const [internalBehavior, setInternalBehavior] =
|
|
839
|
-
const [internalSelectedKeys, setInternalSelectedKeys] =
|
|
840
|
-
const [anchorKey, setAnchorKey] =
|
|
1835
|
+
const [internalBehavior, setInternalBehavior] = createInternalSignal("toggle");
|
|
1836
|
+
const [internalSelectedKeys, setInternalSelectedKeys] = createInternalSignal(getInitialSelection$2(getProps().defaultSelectedKeys));
|
|
1837
|
+
const [anchorKey, setAnchorKey] = createInternalSignal(null);
|
|
841
1838
|
const selectionMode = () => getProps().selectionMode ?? "none";
|
|
842
1839
|
const selectionBehavior = () => {
|
|
843
1840
|
return getProps().selectionBehavior ?? internalBehavior();
|
|
@@ -845,11 +1842,11 @@ function createSelectionState(props = {}) {
|
|
|
845
1842
|
const disallowEmptySelection = () => {
|
|
846
1843
|
return getProps().disallowEmptySelection ?? false;
|
|
847
1844
|
};
|
|
848
|
-
const selectedKeys =
|
|
1845
|
+
const selectedKeys = () => {
|
|
849
1846
|
const p = getProps();
|
|
850
1847
|
if (p.selectedKeys !== void 0) return normalizeSelection$2(p.selectedKeys);
|
|
851
1848
|
return internalSelectedKeys();
|
|
852
|
-
}
|
|
1849
|
+
};
|
|
853
1850
|
const disabledKeys = createMemo(() => {
|
|
854
1851
|
const keys = getProps().disabledKeys;
|
|
855
1852
|
return keys ? new Set(keys) : /* @__PURE__ */ new Set();
|
|
@@ -864,8 +1861,9 @@ function createSelectionState(props = {}) {
|
|
|
864
1861
|
const isSelectAll = () => {
|
|
865
1862
|
return selectedKeys() === "all";
|
|
866
1863
|
};
|
|
1864
|
+
const liveSelectedKeys = () => getProps().selectedKeys !== void 0 ? selectedKeys() : readNow(internalSelectedKeys);
|
|
867
1865
|
const isSelected = (key) => {
|
|
868
|
-
const keys =
|
|
1866
|
+
const keys = liveSelectedKeys();
|
|
869
1867
|
if (keys === "all") return true;
|
|
870
1868
|
return keys.has(key);
|
|
871
1869
|
};
|
|
@@ -878,7 +1876,7 @@ function createSelectionState(props = {}) {
|
|
|
878
1876
|
p.onSelectionChange?.(newSelection);
|
|
879
1877
|
return;
|
|
880
1878
|
}
|
|
881
|
-
const current = internalSelectedKeys
|
|
1879
|
+
const current = readNow(internalSelectedKeys);
|
|
882
1880
|
if (current === "all" || newSelection === "all" || current.size !== newSelection.size || ![...current].every((k) => newSelection.has(k)) || p.allowDuplicateSelectionEvents) {
|
|
883
1881
|
setInternalSelectedKeys(newSelection);
|
|
884
1882
|
p.onSelectionChange?.(newSelection);
|
|
@@ -887,10 +1885,10 @@ function createSelectionState(props = {}) {
|
|
|
887
1885
|
const toggleSelection = (key) => {
|
|
888
1886
|
if (isDisabled(key)) return;
|
|
889
1887
|
if (selectionMode() === "none") return;
|
|
890
|
-
const current =
|
|
1888
|
+
const current = liveSelectedKeys();
|
|
891
1889
|
if (selectionMode() === "single") {
|
|
892
1890
|
if (isSelected(key) && !disallowEmptySelection()) updateSelection(/* @__PURE__ */ new Set());
|
|
893
|
-
else updateSelection(new Set([key]));
|
|
1891
|
+
else updateSelection(/* @__PURE__ */ new Set([key]));
|
|
894
1892
|
return;
|
|
895
1893
|
}
|
|
896
1894
|
if (current === "all") return;
|
|
@@ -904,7 +1902,7 @@ function createSelectionState(props = {}) {
|
|
|
904
1902
|
const replaceSelection = (key) => {
|
|
905
1903
|
if (isDisabled(key)) return;
|
|
906
1904
|
if (selectionMode() === "none") return;
|
|
907
|
-
updateSelection(new Set([key]));
|
|
1905
|
+
updateSelection(/* @__PURE__ */ new Set([key]));
|
|
908
1906
|
setAnchorKey(key);
|
|
909
1907
|
};
|
|
910
1908
|
const setSelectedKeys = (keys) => {
|
|
@@ -949,9 +1947,10 @@ function createSelectionState(props = {}) {
|
|
|
949
1947
|
};
|
|
950
1948
|
const select = (key, e) => {
|
|
951
1949
|
if (selectionMode() === "none") return;
|
|
952
|
-
if (selectionMode() === "single")
|
|
953
|
-
|
|
954
|
-
|
|
1950
|
+
if (selectionMode() === "single") {
|
|
1951
|
+
if (isSelected(key) && !disallowEmptySelection()) toggleSelection(key);
|
|
1952
|
+
else replaceSelection(key);
|
|
1953
|
+
} else if (selectionBehavior() === "toggle" || e != null && (e.pointerType === "touch" || e.pointerType === "virtual")) toggleSelection(key);
|
|
955
1954
|
else replaceSelection(key);
|
|
956
1955
|
};
|
|
957
1956
|
const setSelectionBehavior = (behavior) => {
|
|
@@ -1013,13 +2012,11 @@ var Selection = class Selection extends Set {
|
|
|
1013
2012
|
* Raw multiple-selection + focus state for a collection.
|
|
1014
2013
|
*
|
|
1015
2014
|
* The lower of the two selection layers ported from upstream
|
|
1016
|
-
* (
|
|
2015
|
+
* (`packages/react-stately/src/selection/useMultipleSelectionState.ts`): it owns the
|
|
1017
2016
|
* selected keys, focus, selection behavior, and disabled keys, but is NOT
|
|
1018
2017
|
* collection-aware. The collection-aware operations (toggle, extend, select
|
|
1019
2018
|
* all, range, etc.) live in {@link SelectionManager}, which is built on top of
|
|
1020
2019
|
* this state.
|
|
1021
|
-
*
|
|
1022
|
-
* Based on @react-stately/selection.
|
|
1023
2020
|
*/
|
|
1024
2021
|
function equalSets(setA, setB) {
|
|
1025
2022
|
if (setA.size !== setB.size) return false;
|
|
@@ -1035,24 +2032,25 @@ function convertSelection(selection, defaultValue) {
|
|
|
1035
2032
|
*/
|
|
1036
2033
|
function createMultipleSelectionState(props = {}) {
|
|
1037
2034
|
const getProps = () => access(props);
|
|
1038
|
-
const [isFocused, setIsFocused] =
|
|
1039
|
-
const [focusedKey, setFocusedKeySignal] =
|
|
1040
|
-
const [childFocusStrategy, setChildFocusStrategy] =
|
|
1041
|
-
const [uncontrolledSelectedKeys, setUncontrolledSelectedKeys] =
|
|
2035
|
+
const [isFocused, setIsFocused] = createInternalSignal(false);
|
|
2036
|
+
const [focusedKey, setFocusedKeySignal] = createInternalSignal(null);
|
|
2037
|
+
const [childFocusStrategy, setChildFocusStrategy] = createInternalSignal(null);
|
|
2038
|
+
const [uncontrolledSelectedKeys, setUncontrolledSelectedKeys] = createInternalSignal(convertSelection(getProps().defaultSelectedKeys, new Selection()));
|
|
1042
2039
|
const selectedKeys = createMemo(() => {
|
|
1043
2040
|
const p = getProps();
|
|
1044
2041
|
if (p.selectedKeys !== void 0) return convertSelection(p.selectedKeys, new Selection());
|
|
1045
2042
|
return uncontrolledSelectedKeys();
|
|
1046
2043
|
});
|
|
1047
2044
|
const selectionBehaviorProp = () => getProps().selectionBehavior ?? "toggle";
|
|
1048
|
-
const [selectionBehavior, setSelectionBehaviorState] =
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
2045
|
+
const [selectionBehavior, setSelectionBehaviorState] = createInternalSignal(selectionBehaviorProp());
|
|
2046
|
+
createEffect(() => ({
|
|
2047
|
+
keys: selectedKeys(),
|
|
2048
|
+
prop: selectionBehaviorProp()
|
|
2049
|
+
}), ({ keys, prop }) => {
|
|
2050
|
+
if (prop === "replace" && selectionBehavior() === "toggle" && typeof keys === "object" && keys.size === 0) setSelectionBehaviorState("replace");
|
|
1052
2051
|
});
|
|
1053
2052
|
let lastSelectionBehavior = selectionBehaviorProp();
|
|
1054
|
-
|
|
1055
|
-
const prop = selectionBehaviorProp();
|
|
2053
|
+
createEffect(selectionBehaviorProp, (prop) => {
|
|
1056
2054
|
if (prop !== lastSelectionBehavior) {
|
|
1057
2055
|
setSelectionBehaviorState(prop);
|
|
1058
2056
|
lastSelectionBehavior = prop;
|
|
@@ -1067,9 +2065,10 @@ function createMultipleSelectionState(props = {}) {
|
|
|
1067
2065
|
lastSelectionEvent = keys;
|
|
1068
2066
|
getProps().onSelectionChange?.(keys);
|
|
1069
2067
|
};
|
|
2068
|
+
const liveSelectedKeys = () => getProps().selectedKeys !== void 0 ? selectedKeys() : readNow(uncontrolledSelectedKeys);
|
|
1070
2069
|
const setSelectedKeys = (keys) => {
|
|
1071
2070
|
const p = getProps();
|
|
1072
|
-
const current =
|
|
2071
|
+
const current = liveSelectedKeys();
|
|
1073
2072
|
if (!(p.allowDuplicateSelectionEvents || keys === "all" || current === "all" || !equalSets(keys, current))) return;
|
|
1074
2073
|
if (p.selectedKeys === void 0) setUncontrolledSelectedKeys(keys);
|
|
1075
2074
|
emitSelectionEvent(keys);
|
|
@@ -1109,7 +2108,7 @@ function createMultipleSelectionState(props = {}) {
|
|
|
1109
2108
|
setChildFocusStrategy(strategy);
|
|
1110
2109
|
},
|
|
1111
2110
|
get selectedKeys() {
|
|
1112
|
-
return
|
|
2111
|
+
return liveSelectedKeys();
|
|
1113
2112
|
},
|
|
1114
2113
|
get lastSelectionEvent() {
|
|
1115
2114
|
return lastSelectionEvent;
|
|
@@ -1378,9 +2377,10 @@ var SelectionManager = class SelectionManager {
|
|
|
1378
2377
|
}
|
|
1379
2378
|
select(key, e) {
|
|
1380
2379
|
if (this.selectionMode === "none") return;
|
|
1381
|
-
if (this.selectionMode === "single")
|
|
1382
|
-
|
|
1383
|
-
|
|
2380
|
+
if (this.selectionMode === "single") {
|
|
2381
|
+
if (this.isSelected(key) && !this.disallowEmptySelection) this.toggleSelection(key);
|
|
2382
|
+
else this.replaceSelection(key);
|
|
2383
|
+
} else if (this.selectionBehavior === "toggle" || e && (e.pointerType === "touch" || e.pointerType === "virtual")) this.toggleSelection(key);
|
|
1384
2384
|
else this.replaceSelection(key);
|
|
1385
2385
|
}
|
|
1386
2386
|
/** Returns whether the current selection is equal to the given selection. */
|
|
@@ -1437,7 +2437,9 @@ var SelectionManager = class SelectionManager {
|
|
|
1437
2437
|
/**
|
|
1438
2438
|
* State management for list-like components.
|
|
1439
2439
|
* Combines collection and selection state.
|
|
1440
|
-
*
|
|
2440
|
+
* Ported from:
|
|
2441
|
+
* - packages/react-stately/src/list/useListState.ts
|
|
2442
|
+
* - packages/react-stately/src/list/useSingleSelectListState.ts
|
|
1441
2443
|
*/
|
|
1442
2444
|
/**
|
|
1443
2445
|
* Creates state for a list component with selection.
|
|
@@ -1470,7 +2472,7 @@ function createListState(props) {
|
|
|
1470
2472
|
const itemDisabled = [];
|
|
1471
2473
|
const coll = collection();
|
|
1472
2474
|
for (const node of coll) if (node.isDisabled) itemDisabled.push(node.key);
|
|
1473
|
-
return [
|
|
2475
|
+
return [.../* @__PURE__ */ new Set([...propsDisabled, ...itemDisabled])];
|
|
1474
2476
|
});
|
|
1475
2477
|
const state = createMultipleSelectionState({
|
|
1476
2478
|
get selectionMode() {
|
|
@@ -1548,9 +2550,8 @@ function createFilteredListState(state, filterFn) {
|
|
|
1548
2550
|
});
|
|
1549
2551
|
const selectionManager = state.selectionManager.withCollectionAccessor(() => collection());
|
|
1550
2552
|
let cachedCollection = null;
|
|
1551
|
-
createEffect(() => {
|
|
1552
|
-
const
|
|
1553
|
-
const focusedKey = untrack(() => state.focusedKey());
|
|
2553
|
+
createEffect(collection, (coll) => {
|
|
2554
|
+
const focusedKey = state.focusedKey();
|
|
1554
2555
|
if (focusedKey != null && !coll.getItem(focusedKey) && cachedCollection) {
|
|
1555
2556
|
let key = cachedCollection.getKeyAfter(focusedKey);
|
|
1556
2557
|
let nextFocusedKey = null;
|
|
@@ -1573,7 +2574,7 @@ function createFilteredListState(state, filterFn) {
|
|
|
1573
2574
|
key = cachedCollection.getKeyBefore(key);
|
|
1574
2575
|
}
|
|
1575
2576
|
}
|
|
1576
|
-
|
|
2577
|
+
state.setFocusedKey(nextFocusedKey);
|
|
1577
2578
|
}
|
|
1578
2579
|
cachedCollection = coll;
|
|
1579
2580
|
});
|
|
@@ -1667,7 +2668,10 @@ function createSingleSelectListState(props) {
|
|
|
1667
2668
|
//#region src/collections/createMenuState.ts
|
|
1668
2669
|
/**
|
|
1669
2670
|
* State management for menu components.
|
|
1670
|
-
*
|
|
2671
|
+
*
|
|
2672
|
+
* createMenuTriggerState is ported from
|
|
2673
|
+
* packages/react-stately/src/menu/useMenuTriggerState.ts.
|
|
2674
|
+
* createMenuState is a local composition of the separately attributed list state.
|
|
1671
2675
|
*/
|
|
1672
2676
|
/**
|
|
1673
2677
|
* Creates state for a menu component.
|
|
@@ -1727,6 +2731,27 @@ function createMenuState(props) {
|
|
|
1727
2731
|
close
|
|
1728
2732
|
};
|
|
1729
2733
|
}
|
|
2734
|
+
/**
|
|
2735
|
+
* Creates state for a menu trigger. Mirrors `@react-stately/menu` `useMenuTriggerState`:
|
|
2736
|
+
* overlay open state plus the focus strategy passed through to `createMenu`.
|
|
2737
|
+
*/
|
|
2738
|
+
function createMenuTriggerState(props = {}) {
|
|
2739
|
+
const overlay = createOverlayTriggerState(props);
|
|
2740
|
+
const [focusStrategy, setFocusStrategy] = createInternalSignal(null);
|
|
2741
|
+
return {
|
|
2742
|
+
...overlay,
|
|
2743
|
+
focusStrategy,
|
|
2744
|
+
setFocusStrategy,
|
|
2745
|
+
open(strategy = null) {
|
|
2746
|
+
setFocusStrategy(strategy);
|
|
2747
|
+
overlay.open();
|
|
2748
|
+
},
|
|
2749
|
+
toggle(strategy = null) {
|
|
2750
|
+
setFocusStrategy(strategy);
|
|
2751
|
+
overlay.toggle();
|
|
2752
|
+
}
|
|
2753
|
+
};
|
|
2754
|
+
}
|
|
1730
2755
|
//#endregion
|
|
1731
2756
|
//#region src/calendar/createCalendarState.ts
|
|
1732
2757
|
/**
|
|
@@ -1755,16 +2780,16 @@ function createCalendarState(props = {}) {
|
|
|
1755
2780
|
const selectionMode = createMemo(() => access(props.selectionMode) ?? "single");
|
|
1756
2781
|
const resolvedOptions = createMemo(() => new DateFormatter$1(locale()).resolvedOptions());
|
|
1757
2782
|
const calendar = createMemo(() => (props.createCalendar ?? createCalendar$1)(resolvedOptions().calendar));
|
|
1758
|
-
const visibleMonths = props.visibleMonths ?? 1;
|
|
2783
|
+
const visibleMonths = createMemo(() => Math.max(1, Number(access(props.visibleMonths) ?? 1)));
|
|
1759
2784
|
const firstDayOfWeekName = () => props.firstDayOfWeek == null ? void 0 : dayOfWeekNames$1[props.firstDayOfWeek];
|
|
1760
2785
|
const toDisplayCalendarDate = (date) => toCalendar$1(toCalendarDate$3(date), calendar());
|
|
1761
2786
|
const selectionAlignmentOffset = () => {
|
|
1762
2787
|
switch (props.selectionAlignment) {
|
|
1763
2788
|
case "start": return 0;
|
|
1764
|
-
case "end": return Math.max(visibleMonths - 1, 0);
|
|
2789
|
+
case "end": return Math.max(visibleMonths() - 1, 0);
|
|
1765
2790
|
default: {
|
|
1766
|
-
let halfDuration = Math.floor(visibleMonths / 2);
|
|
1767
|
-
if (halfDuration > 0 && visibleMonths % 2 === 0) halfDuration--;
|
|
2791
|
+
let halfDuration = Math.floor(visibleMonths() / 2);
|
|
2792
|
+
if (halfDuration > 0 && visibleMonths() % 2 === 0) halfDuration--;
|
|
1768
2793
|
return halfDuration;
|
|
1769
2794
|
}
|
|
1770
2795
|
}
|
|
@@ -1775,7 +2800,7 @@ function createCalendarState(props = {}) {
|
|
|
1775
2800
|
};
|
|
1776
2801
|
const visibleRangeEnd = (start) => {
|
|
1777
2802
|
let end = endOfMonth$1(start);
|
|
1778
|
-
for (let i = 1; i < visibleMonths; i++) end = endOfMonth$1(end.add({ months: 1 }));
|
|
2803
|
+
for (let i = 1; i < visibleMonths(); i++) end = endOfMonth$1(end.add({ months: 1 }));
|
|
1779
2804
|
return end;
|
|
1780
2805
|
};
|
|
1781
2806
|
const constrainDate = (date) => {
|
|
@@ -1798,11 +2823,11 @@ function createCalendarState(props = {}) {
|
|
|
1798
2823
|
return toCalendar$1(today$1(timeZone), calendar());
|
|
1799
2824
|
};
|
|
1800
2825
|
const initialFocusedDate = constrainDate(getInitialFocusedDate());
|
|
1801
|
-
const [internalValue, setInternalValue] =
|
|
1802
|
-
const [focusedDate, setFocusedDateInternal] =
|
|
1803
|
-
const [visibleRangeStart, setVisibleRangeStart] =
|
|
1804
|
-
const [isFocused, setFocused] =
|
|
1805
|
-
const [isPaginating, setIsPaginating] =
|
|
2826
|
+
const [internalValue, setInternalValue] = createInternalSignal(props.defaultValue ?? null);
|
|
2827
|
+
const [focusedDate, setFocusedDateInternal] = createInternalSignal(initialFocusedDate);
|
|
2828
|
+
const [visibleRangeStart, setVisibleRangeStart] = createInternalSignal(alignVisibleRangeStart(initialFocusedDate));
|
|
2829
|
+
const [isFocused, setFocused] = createInternalSignal(props.autoFocus ?? false);
|
|
2830
|
+
const [isPaginating, setIsPaginating] = createInternalSignal(false);
|
|
1806
2831
|
const sourceValue = createMemo(() => {
|
|
1807
2832
|
const controlled = access(props.value);
|
|
1808
2833
|
return controlled !== void 0 ? controlled : internalValue();
|
|
@@ -1816,41 +2841,61 @@ function createCalendarState(props = {}) {
|
|
|
1816
2841
|
const isReadOnly = createMemo(() => access(props.isReadOnly) ?? false);
|
|
1817
2842
|
const validationState = createMemo(() => access(props.validationState));
|
|
1818
2843
|
const isValueInvalid = createMemo(() => validationState() === "invalid");
|
|
1819
|
-
const visibleRange =
|
|
2844
|
+
const visibleRange = () => {
|
|
1820
2845
|
const start = visibleRangeStart();
|
|
1821
2846
|
return {
|
|
1822
2847
|
start,
|
|
1823
2848
|
end: visibleRangeEnd(start)
|
|
1824
2849
|
};
|
|
1825
|
-
}
|
|
1826
|
-
const syncVisibleRangeForFocusedDate = (nextFocusedDate) => {
|
|
1827
|
-
|
|
1828
|
-
if (nextFocusedDate.compare(range.start) < 0) setVisibleRangeStart(startOfMonth$1(nextFocusedDate.subtract({ months: visibleMonths - 1 })));
|
|
2850
|
+
};
|
|
2851
|
+
const syncVisibleRangeForFocusedDate = (nextFocusedDate, range, months) => {
|
|
2852
|
+
if (nextFocusedDate.compare(range.start) < 0) setVisibleRangeStart(startOfMonth$1(nextFocusedDate.subtract({ months: months - 1 })));
|
|
1829
2853
|
else if (nextFocusedDate.compare(range.end) > 0) setVisibleRangeStart(startOfMonth$1(nextFocusedDate));
|
|
1830
2854
|
};
|
|
1831
2855
|
createEffect(() => {
|
|
1832
2856
|
const controlledFocused = access(props.focusedValue);
|
|
1833
|
-
if (!controlledFocused) return;
|
|
1834
|
-
|
|
1835
|
-
|
|
2857
|
+
if (!controlledFocused) return null;
|
|
2858
|
+
return {
|
|
2859
|
+
nextFocusedDate: constrainDate(toDisplayCalendarDate(controlledFocused)),
|
|
2860
|
+
currentFocusedDate: focusedDate(),
|
|
2861
|
+
range: visibleRange(),
|
|
2862
|
+
months: visibleMonths()
|
|
2863
|
+
};
|
|
2864
|
+
}, (data) => {
|
|
2865
|
+
if (!data) return;
|
|
2866
|
+
const { nextFocusedDate, currentFocusedDate, range, months } = data;
|
|
1836
2867
|
if (nextFocusedDate.compare(currentFocusedDate) !== 0 || !isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)) setFocusedDateInternal(nextFocusedDate);
|
|
1837
|
-
syncVisibleRangeForFocusedDate(nextFocusedDate);
|
|
2868
|
+
syncVisibleRangeForFocusedDate(nextFocusedDate, range, months);
|
|
1838
2869
|
});
|
|
1839
2870
|
createEffect(() => {
|
|
1840
|
-
if (access(props.focusedValue)) return;
|
|
2871
|
+
if (access(props.focusedValue)) return null;
|
|
1841
2872
|
const currentFocusedDate = focusedDate();
|
|
1842
2873
|
const nextFocusedDate = constrainDate(currentFocusedDate);
|
|
1843
|
-
if (nextFocusedDate.compare(currentFocusedDate) === 0 && isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)) return;
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
2874
|
+
if (nextFocusedDate.compare(currentFocusedDate) === 0 && isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)) return null;
|
|
2875
|
+
return {
|
|
2876
|
+
currentFocusedDate,
|
|
2877
|
+
nextFocusedDate,
|
|
2878
|
+
range: visibleRange(),
|
|
2879
|
+
months: visibleMonths()
|
|
2880
|
+
};
|
|
2881
|
+
}, (data) => {
|
|
2882
|
+
if (!data) return;
|
|
2883
|
+
syncVisibleRangeForFocusedDate(data.nextFocusedDate, data.range, data.months);
|
|
2884
|
+
setFocusedDateInternal(data.nextFocusedDate);
|
|
2885
|
+
props.onFocusChange?.(data.nextFocusedDate);
|
|
1847
2886
|
});
|
|
1848
2887
|
createEffect(() => {
|
|
1849
2888
|
const currentFocusedDate = focusedDate();
|
|
1850
2889
|
const nextFocusedDate = toDisplayCalendarDate(currentFocusedDate);
|
|
1851
|
-
if (isEqualCalendar(currentFocusedDate.calendar, nextFocusedDate.calendar)) return;
|
|
1852
|
-
|
|
1853
|
-
|
|
2890
|
+
if (isEqualCalendar(currentFocusedDate.calendar, nextFocusedDate.calendar)) return null;
|
|
2891
|
+
return {
|
|
2892
|
+
nextFocusedDate,
|
|
2893
|
+
alignedStart: alignVisibleRangeStart(nextFocusedDate)
|
|
2894
|
+
};
|
|
2895
|
+
}, (data) => {
|
|
2896
|
+
if (!data) return;
|
|
2897
|
+
setFocusedDateInternal(data.nextFocusedDate);
|
|
2898
|
+
setVisibleRangeStart(data.alignedStart);
|
|
1854
2899
|
});
|
|
1855
2900
|
const weekDays = createMemo(() => {
|
|
1856
2901
|
const formatter = new DateFormatter$1(locale(), { weekday: "narrow" });
|
|
@@ -1872,21 +2917,32 @@ function createCalendarState(props = {}) {
|
|
|
1872
2917
|
const formattableMonth = date.calendar.getFormattableMonth?.(date) ?? date;
|
|
1873
2918
|
return formatter.format(formattableMonth.toDate(timeZone));
|
|
1874
2919
|
});
|
|
2920
|
+
const normalizeValue = (newValue) => {
|
|
2921
|
+
const constrained = constrainDate(newValue);
|
|
2922
|
+
const minBound = access(props.minValue);
|
|
2923
|
+
const prev = previousAvailableDate$1(constrained, minBound != null ? toDisplayCalendarDate(minBound) : minDate$1(constrained, visibleRange().start) ?? constrained, props.isDateUnavailable);
|
|
2924
|
+
if (!prev) return null;
|
|
2925
|
+
const oldValue = sourceValue();
|
|
2926
|
+
return convertValue$3(prev, Array.isArray(oldValue) ? oldValue[0] ?? null : oldValue);
|
|
2927
|
+
};
|
|
1875
2928
|
const setValue = (newValue) => {
|
|
1876
2929
|
if (isDisabled() || isReadOnly()) return;
|
|
1877
2930
|
const oldValue = sourceValue();
|
|
1878
|
-
const referenceValue = Array.isArray(oldValue) ? oldValue[0] ?? null : oldValue;
|
|
1879
2931
|
let nextValue;
|
|
1880
2932
|
if (newValue == null) nextValue = selectionMode() === "multiple" ? [] : null;
|
|
1881
|
-
else if (Array.isArray(newValue)) nextValue = newValue.map((v) =>
|
|
1882
|
-
else
|
|
2933
|
+
else if (Array.isArray(newValue)) nextValue = newValue.map((v) => normalizeValue(toDisplayCalendarDate(v))).filter((v) => v != null);
|
|
2934
|
+
else {
|
|
2935
|
+
const localValue = normalizeValue(toDisplayCalendarDate(newValue));
|
|
2936
|
+
if (!localValue) return;
|
|
2937
|
+
nextValue = localValue;
|
|
2938
|
+
}
|
|
1883
2939
|
if (access(props.value) === void 0) setInternalValue(() => nextValue);
|
|
1884
2940
|
if (!Object.is(oldValue, nextValue) && props.onChange) props.onChange(nextValue);
|
|
1885
2941
|
};
|
|
1886
2942
|
const setFocusedDate = (date) => {
|
|
1887
2943
|
const constrained = constrainDate(date);
|
|
1888
2944
|
if (Object.is(constrained, focusedDate())) return;
|
|
1889
|
-
syncVisibleRangeForFocusedDate(constrained);
|
|
2945
|
+
syncVisibleRangeForFocusedDate(constrained, visibleRange(), visibleMonths());
|
|
1890
2946
|
setFocusedDateInternal(constrained);
|
|
1891
2947
|
props.onFocusChange?.(constrained);
|
|
1892
2948
|
};
|
|
@@ -1924,9 +2980,27 @@ function createCalendarState(props = {}) {
|
|
|
1924
2980
|
const isInvalid = (date) => {
|
|
1925
2981
|
return isCellDisabled(date) || isCellUnavailable(date);
|
|
1926
2982
|
};
|
|
2983
|
+
const isDateOutsideAllowedRange = (date) => {
|
|
2984
|
+
const min = minValueState();
|
|
2985
|
+
const max = maxValueState();
|
|
2986
|
+
const calDate = toDisplayCalendarDate(date);
|
|
2987
|
+
if (min && calDate.compare(toDisplayCalendarDate(min)) < 0) return true;
|
|
2988
|
+
if (max && calDate.compare(toDisplayCalendarDate(max)) > 0) return true;
|
|
2989
|
+
return false;
|
|
2990
|
+
};
|
|
2991
|
+
const isPreviousVisibleRangeInvalid = () => {
|
|
2992
|
+
const start = visibleRange().start;
|
|
2993
|
+
const previous = start.subtract({ days: 1 });
|
|
2994
|
+
return isSameDay$1(previous, start) || isDateOutsideAllowedRange(previous);
|
|
2995
|
+
};
|
|
2996
|
+
const isNextVisibleRangeInvalid = () => {
|
|
2997
|
+
const end = visibleRange().end;
|
|
2998
|
+
const next = end.add({ days: 1 });
|
|
2999
|
+
return isSameDay$1(next, end) || isDateOutsideAllowedRange(next);
|
|
3000
|
+
};
|
|
1927
3001
|
const focusPreviousPage = () => {
|
|
1928
3002
|
setIsPaginating(true);
|
|
1929
|
-
const pageMonths = props.pageBehavior === "single" ? 1 : visibleMonths;
|
|
3003
|
+
const pageMonths = props.pageBehavior === "single" ? 1 : visibleMonths();
|
|
1930
3004
|
const nextFocusedDate = constrainDate(focusedDate().subtract({ months: pageMonths }));
|
|
1931
3005
|
setFocusedDateInternal(nextFocusedDate);
|
|
1932
3006
|
setVisibleRangeStart(startOfMonth$1(visibleRangeStart().subtract({ months: pageMonths })));
|
|
@@ -1935,7 +3009,7 @@ function createCalendarState(props = {}) {
|
|
|
1935
3009
|
};
|
|
1936
3010
|
const focusNextPage = () => {
|
|
1937
3011
|
setIsPaginating(true);
|
|
1938
|
-
const pageMonths = props.pageBehavior === "single" ? 1 : visibleMonths;
|
|
3012
|
+
const pageMonths = props.pageBehavior === "single" ? 1 : visibleMonths();
|
|
1939
3013
|
const nextFocusedDate = constrainDate(focusedDate().add({ months: pageMonths }));
|
|
1940
3014
|
setFocusedDateInternal(nextFocusedDate);
|
|
1941
3015
|
setVisibleRangeStart(startOfMonth$1(visibleRangeStart().add({ months: pageMonths })));
|
|
@@ -1974,17 +3048,19 @@ function createCalendarState(props = {}) {
|
|
|
1974
3048
|
const selectDate = (date) => {
|
|
1975
3049
|
if (isReadOnly() || isDisabled()) return;
|
|
1976
3050
|
if (selectionMode() === "multiple") {
|
|
1977
|
-
const current = value();
|
|
3051
|
+
const current = access(props.value) !== void 0 ? value() : readNow(internalValue);
|
|
1978
3052
|
const base = Array.isArray(current) ? current.map((v) => toDisplayCalendarDate(v)) : current != null ? [toDisplayCalendarDate(current)] : [];
|
|
1979
3053
|
const target = toDisplayCalendarDate(date);
|
|
1980
3054
|
const index = base.findIndex((d) => isSameDay$1(d, target));
|
|
1981
|
-
|
|
3055
|
+
const nextValue = index >= 0 ? [...base.slice(0, index), ...base.slice(index + 1)] : [...base, target];
|
|
3056
|
+
setValue(nextValue);
|
|
1982
3057
|
} else setValue(date);
|
|
1983
3058
|
setFocusedDate(date);
|
|
1984
3059
|
};
|
|
1985
3060
|
const getDatesInWeek = (weekIndex, monthStartDate) => {
|
|
1986
3061
|
const startDate = monthStartDate ?? visibleRange().start;
|
|
1987
|
-
const
|
|
3062
|
+
const monthStart = startOfMonth$1(startDate);
|
|
3063
|
+
const weekStart = startOfWeek$1(monthStart, locale(), firstDayOfWeekName());
|
|
1988
3064
|
const week = [];
|
|
1989
3065
|
const firstDayOfWeek = weekStart.add({ weeks: weekIndex });
|
|
1990
3066
|
for (let i = 0; i < 7; i++) {
|
|
@@ -1995,7 +3071,8 @@ function createCalendarState(props = {}) {
|
|
|
1995
3071
|
return week;
|
|
1996
3072
|
};
|
|
1997
3073
|
const getWeeksInMonthFn = (date) => {
|
|
1998
|
-
|
|
3074
|
+
const monthDate = date ?? focusedDate();
|
|
3075
|
+
return getWeeksInMonth$1(monthDate, locale(), firstDayOfWeekName());
|
|
1999
3076
|
};
|
|
2000
3077
|
return {
|
|
2001
3078
|
selectionMode,
|
|
@@ -2019,6 +3096,8 @@ function createCalendarState(props = {}) {
|
|
|
2019
3096
|
isCellDisabled,
|
|
2020
3097
|
isOutsideVisibleRange,
|
|
2021
3098
|
isInvalid,
|
|
3099
|
+
isPreviousVisibleRangeInvalid,
|
|
3100
|
+
isNextVisibleRangeInvalid,
|
|
2022
3101
|
focusPreviousPage,
|
|
2023
3102
|
focusNextPage,
|
|
2024
3103
|
focusPreviousSection,
|
|
@@ -2037,7 +3116,9 @@ function createCalendarState(props = {}) {
|
|
|
2037
3116
|
getWeeksInMonth: getWeeksInMonthFn,
|
|
2038
3117
|
weekDays,
|
|
2039
3118
|
title,
|
|
2040
|
-
visibleMonths
|
|
3119
|
+
get visibleMonths() {
|
|
3120
|
+
return visibleMonths();
|
|
3121
|
+
},
|
|
2041
3122
|
isPaginating
|
|
2042
3123
|
};
|
|
2043
3124
|
}
|
|
@@ -2052,6 +3133,16 @@ function convertValue$3(newValue, oldValue) {
|
|
|
2052
3133
|
if (oldValue && "hour" in oldValue) return oldValue.set(localValue);
|
|
2053
3134
|
return localValue;
|
|
2054
3135
|
}
|
|
3136
|
+
/**
|
|
3137
|
+
* Walks backward from `date` while it is unavailable and still at/after `minValue`.
|
|
3138
|
+
* Mirrors @react-stately/calendar previousAvailableDate.
|
|
3139
|
+
*/
|
|
3140
|
+
function previousAvailableDate$1(date, minValue, isDateUnavailable) {
|
|
3141
|
+
if (!isDateUnavailable) return date;
|
|
3142
|
+
while (date.compare(minValue) >= 0 && isDateUnavailable(date)) date = date.subtract({ days: 1 });
|
|
3143
|
+
if (date.compare(minValue) >= 0) return date;
|
|
3144
|
+
return null;
|
|
3145
|
+
}
|
|
2055
3146
|
//#endregion
|
|
2056
3147
|
//#region src/calendar/IncompleteDate.ts
|
|
2057
3148
|
/**
|
|
@@ -2062,7 +3153,7 @@ function convertValue$3(newValue, oldValue) {
|
|
|
2062
3153
|
* This lets a date field hold an invalid intermediate value while typing and
|
|
2063
3154
|
* only constrain it on blur, matching upstream behavior.
|
|
2064
3155
|
*
|
|
2065
|
-
*
|
|
3156
|
+
* Ported from packages/react-stately/src/datepicker/IncompleteDate.ts.
|
|
2066
3157
|
*/
|
|
2067
3158
|
/**
|
|
2068
3159
|
* This class represents a date that is incomplete or otherwise invalid as a result of user editing.
|
|
@@ -2217,9 +3308,7 @@ var IncompleteDate = class IncompleteDate {
|
|
|
2217
3308
|
case "minute":
|
|
2218
3309
|
res.minute = cycleValue(res.minute ?? 0, amount, 0, 59, true);
|
|
2219
3310
|
break;
|
|
2220
|
-
case "second":
|
|
2221
|
-
res.second = cycleValue(res.second ?? 0, amount, 0, 59, true);
|
|
2222
|
-
break;
|
|
3311
|
+
case "second": res.second = cycleValue(res.second ?? 0, amount, 0, 59, true);
|
|
2223
3312
|
}
|
|
2224
3313
|
return res;
|
|
2225
3314
|
}
|
|
@@ -2353,9 +3442,7 @@ function fromHourCycle(hour, dayPeriod, hourCycle) {
|
|
|
2353
3442
|
if (hour === 12) hour = 0;
|
|
2354
3443
|
if (dayPeriod === 1) hour += 12;
|
|
2355
3444
|
break;
|
|
2356
|
-
case "h24":
|
|
2357
|
-
hour -= 1;
|
|
2358
|
-
break;
|
|
3445
|
+
case "h24": hour -= 1;
|
|
2359
3446
|
}
|
|
2360
3447
|
return hour;
|
|
2361
3448
|
}
|
|
@@ -3006,8 +4093,8 @@ function getPlaceholder(field, value, locale) {
|
|
|
3006
4093
|
*
|
|
3007
4094
|
* The upstream "derived state during render" resync (which re-mints the display
|
|
3008
4095
|
* value when the committed value / calendar / hour cycle changes) is ported to a
|
|
3009
|
-
*
|
|
3010
|
-
*
|
|
4096
|
+
* split `createEffect`. Compute tracks the committed value; apply writes the
|
|
4097
|
+
* display override. Solid 2 has no `createComputed`.
|
|
3011
4098
|
*/
|
|
3012
4099
|
const EDITABLE_SEGMENTS = {
|
|
3013
4100
|
year: true,
|
|
@@ -3037,26 +4124,26 @@ const TYPE_MAPPING = {
|
|
|
3037
4124
|
* Provides state management for a date field component.
|
|
3038
4125
|
*/
|
|
3039
4126
|
function createDateFieldState(props = {}) {
|
|
3040
|
-
const locale = () => props.locale ?? "en-US";
|
|
4127
|
+
const locale = createMemo(() => access(props.locale) ?? "en-US");
|
|
3041
4128
|
const createCalendarFn = (name) => (props.createCalendar ?? createCalendar$1)(name);
|
|
3042
4129
|
const v0 = () => access(props.value) ?? props.defaultValue ?? props.placeholderValue ?? null;
|
|
3043
|
-
const
|
|
4130
|
+
const initialDefaults = untrack(() => {
|
|
3044
4131
|
const v = v0();
|
|
3045
4132
|
return {
|
|
3046
4133
|
granularity: v && "minute" in v ? "minute" : "day",
|
|
3047
4134
|
timeZone: v && "timeZone" in v ? v.timeZone : void 0
|
|
3048
4135
|
};
|
|
3049
|
-
})
|
|
3050
|
-
|
|
4136
|
+
});
|
|
4137
|
+
const lastDefaults = createMemo((prev = initialDefaults) => {
|
|
3051
4138
|
const v = v0();
|
|
3052
|
-
if (!v) return;
|
|
4139
|
+
if (!v) return prev;
|
|
3053
4140
|
const defaultGranularity = "minute" in v ? "minute" : "day";
|
|
3054
4141
|
const defaultTimeZone = "timeZone" in v ? v.timeZone : void 0;
|
|
3055
|
-
|
|
3056
|
-
if (last.granularity !== defaultGranularity || last.timeZone !== defaultTimeZone) setLastDefaults({
|
|
4142
|
+
if (prev.granularity !== defaultGranularity || prev.timeZone !== defaultTimeZone) return {
|
|
3057
4143
|
granularity: defaultGranularity,
|
|
3058
4144
|
timeZone: defaultTimeZone
|
|
3059
|
-
}
|
|
4145
|
+
};
|
|
4146
|
+
return prev;
|
|
3060
4147
|
});
|
|
3061
4148
|
const granularity = () => {
|
|
3062
4149
|
if (props.granularity) return props.granularity;
|
|
@@ -3079,7 +4166,7 @@ function createDateFieldState(props = {}) {
|
|
|
3079
4166
|
});
|
|
3080
4167
|
const calendar = () => calendarAndHourCycle()[0];
|
|
3081
4168
|
const hourCycle = () => calendarAndHourCycle()[1];
|
|
3082
|
-
const [internalValue, setInternalValue] =
|
|
4169
|
+
const [internalValue, setInternalValue] = createInternalSignal(props.defaultValue ?? null);
|
|
3083
4170
|
const rawValue = createMemo(() => {
|
|
3084
4171
|
const controlled = access(props.value);
|
|
3085
4172
|
return controlled !== void 0 ? controlled : internalValue();
|
|
@@ -3090,14 +4177,15 @@ function createDateFieldState(props = {}) {
|
|
|
3090
4177
|
};
|
|
3091
4178
|
const calendarValue = createMemo(() => convertValue$2(rawValue(), calendar()) ?? null);
|
|
3092
4179
|
const initialValue = untrack(calendarValue);
|
|
3093
|
-
const [displayValue, setDisplayValue] =
|
|
4180
|
+
const [displayValue, setDisplayValue] = createInternalSignal(untrack(() => new IncompleteDate(calendar(), hourCycle(), untrack(calendarValue))));
|
|
3094
4181
|
let lastValue = untrack(calendarValue);
|
|
3095
4182
|
let lastCalendar = untrack(calendar);
|
|
3096
4183
|
let lastHourCycle = untrack(hourCycle);
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
4184
|
+
createEffect(() => ({
|
|
4185
|
+
cv: calendarValue(),
|
|
4186
|
+
cal: calendar(),
|
|
4187
|
+
hc: hourCycle()
|
|
4188
|
+
}), ({ cv, cal, hc }) => {
|
|
3101
4189
|
if (cv !== lastValue || hc !== lastHourCycle || !isEqualCalendar(cal, lastCalendar)) {
|
|
3102
4190
|
lastValue = cv;
|
|
3103
4191
|
lastCalendar = cal;
|
|
@@ -3251,7 +4339,9 @@ function createDateFieldState(props = {}) {
|
|
|
3251
4339
|
if (access(props.isDisabled) || access(props.isReadOnly)) return;
|
|
3252
4340
|
if (displayValue().isComplete(displaySegments())) {
|
|
3253
4341
|
const cv = calendarValue();
|
|
3254
|
-
const
|
|
4342
|
+
const dv = displayValue().toValue(cv ?? placeholderDate());
|
|
4343
|
+
const v = v0();
|
|
4344
|
+
const newDateValue = toCalendar$1(dv, v?.calendar || new GregorianCalendar$1());
|
|
3255
4345
|
const committed = rawValue();
|
|
3256
4346
|
if (!committed || newDateValue.compare(committed) !== 0) setDate(newDateValue);
|
|
3257
4347
|
setDisplayValue(new IncompleteDate(calendar(), hourCycle(), cv));
|
|
@@ -3268,10 +4358,11 @@ function createDateFieldState(props = {}) {
|
|
|
3268
4358
|
return new DateFormatter$1(locale(), formatOptions).format(dateValue());
|
|
3269
4359
|
},
|
|
3270
4360
|
getDateFormatter(loc, formatOptions) {
|
|
3271
|
-
|
|
4361
|
+
const newFormatOptions = getFormatOptions({}, {
|
|
3272
4362
|
...formatOpts(),
|
|
3273
4363
|
...formatOptions
|
|
3274
|
-
})
|
|
4364
|
+
});
|
|
4365
|
+
return new DateFormatter$1(loc, newFormatOptions);
|
|
3275
4366
|
},
|
|
3276
4367
|
get locale() {
|
|
3277
4368
|
return locale();
|
|
@@ -3447,7 +4538,10 @@ function formatError(locale, key, args) {
|
|
|
3447
4538
|
* RangeCalendarState for Solid-Stately
|
|
3448
4539
|
*
|
|
3449
4540
|
* Provides state management for range calendar components.
|
|
3450
|
-
*
|
|
4541
|
+
* Ported from:
|
|
4542
|
+
* - packages/react-stately/src/calendar/useRangeCalendarState.ts
|
|
4543
|
+
* - packages/react-stately/src/calendar/useCalendarState.ts
|
|
4544
|
+
* - packages/react-stately/src/calendar/utils.ts
|
|
3451
4545
|
*/
|
|
3452
4546
|
const dayOfWeekNames = [
|
|
3453
4547
|
"sun",
|
|
@@ -3468,16 +4562,16 @@ function createRangeCalendarState(props = {}) {
|
|
|
3468
4562
|
const maxValueState = createMemo(() => access(props.maxValue) ?? null);
|
|
3469
4563
|
const resolvedOptions = createMemo(() => new DateFormatter$1(locale()).resolvedOptions());
|
|
3470
4564
|
const calendar = createMemo(() => (props.createCalendar ?? createCalendar$1)(resolvedOptions().calendar));
|
|
3471
|
-
const visibleMonths = Math.max(1, Number(access(props.visibleMonths) ?? 1));
|
|
4565
|
+
const visibleMonths = createMemo(() => Math.max(1, Number(access(props.visibleMonths) ?? 1)));
|
|
3472
4566
|
const firstDayOfWeekName = () => props.firstDayOfWeek == null ? void 0 : dayOfWeekNames[props.firstDayOfWeek];
|
|
3473
4567
|
const toDisplayCalendarDate = (date) => toCalendar$1(toCalendarDate$2(date), calendar());
|
|
3474
|
-
const [anchorDate, setAnchorDate] =
|
|
4568
|
+
const [anchorDate, setAnchorDate] = createInternalSignal(null);
|
|
3475
4569
|
const getAvailableRange = (anchor) => {
|
|
3476
4570
|
if (anchor && props.isDateUnavailable && !props.allowsNonContiguousRanges) {
|
|
3477
4571
|
const predicate = (date) => props.isDateUnavailable(date, anchor);
|
|
3478
4572
|
return {
|
|
3479
|
-
start: nextUnavailableDate(anchor, predicate, visibleMonths, -1),
|
|
3480
|
-
end: nextUnavailableDate(anchor, predicate, visibleMonths, 1)
|
|
4573
|
+
start: nextUnavailableDate(anchor, predicate, visibleMonths(), -1),
|
|
4574
|
+
end: nextUnavailableDate(anchor, predicate, visibleMonths(), 1)
|
|
3481
4575
|
};
|
|
3482
4576
|
}
|
|
3483
4577
|
return null;
|
|
@@ -3485,11 +4579,13 @@ function createRangeCalendarState(props = {}) {
|
|
|
3485
4579
|
const availableRange = createMemo(() => getAvailableRange(anchorDate()));
|
|
3486
4580
|
const effectiveMinValue = createMemo(() => {
|
|
3487
4581
|
const min = access(props.minValue);
|
|
3488
|
-
|
|
4582
|
+
const minCal = min != null ? toDisplayCalendarDate(min) : void 0;
|
|
4583
|
+
return maxDate$1(minCal, availableRange()?.start) ?? null;
|
|
3489
4584
|
});
|
|
3490
4585
|
const effectiveMaxValue = createMemo(() => {
|
|
3491
4586
|
const max = access(props.maxValue);
|
|
3492
|
-
|
|
4587
|
+
const maxCal = max != null ? toDisplayCalendarDate(max) : void 0;
|
|
4588
|
+
return minDate$1(maxCal, availableRange()?.end) ?? null;
|
|
3493
4589
|
});
|
|
3494
4590
|
const constrainDate = (date) => {
|
|
3495
4591
|
const min = effectiveMinValue();
|
|
@@ -3501,11 +4597,11 @@ function createRangeCalendarState(props = {}) {
|
|
|
3501
4597
|
};
|
|
3502
4598
|
const visibleRangeEndFromStart = (start) => {
|
|
3503
4599
|
let end = endOfMonth$1(start);
|
|
3504
|
-
for (let i = 1; i < visibleMonths; i++) end = endOfMonth$1(end.add({ months: 1 }));
|
|
4600
|
+
for (let i = 1; i < visibleMonths(); i++) end = endOfMonth$1(end.add({ months: 1 }));
|
|
3505
4601
|
return end;
|
|
3506
4602
|
};
|
|
3507
4603
|
const rawAlignStart = (date) => startOfMonth$1(date);
|
|
3508
|
-
const rawAlignEnd = (date) => startOfMonth$1(date).subtract({ months: Math.max(visibleMonths - 1, 0) });
|
|
4604
|
+
const rawAlignEnd = (date) => startOfMonth$1(date).subtract({ months: Math.max(visibleMonths() - 1, 0) });
|
|
3509
4605
|
const constrainVisibleRangeStart = (date, aligned) => {
|
|
3510
4606
|
const minValue = access(props.minValue);
|
|
3511
4607
|
const maxValue = access(props.maxValue);
|
|
@@ -3523,14 +4619,15 @@ function createRangeCalendarState(props = {}) {
|
|
|
3523
4619
|
const alignStart = (date) => constrainVisibleRangeStart(date, rawAlignStart(date));
|
|
3524
4620
|
const alignEnd = (date) => constrainVisibleRangeStart(date, rawAlignEnd(date));
|
|
3525
4621
|
const alignCenter = (date) => {
|
|
3526
|
-
let offset = Math.floor(visibleMonths / 2);
|
|
3527
|
-
if (offset > 0 && visibleMonths % 2 === 0) offset--;
|
|
4622
|
+
let offset = Math.floor(visibleMonths() / 2);
|
|
4623
|
+
if (offset > 0 && visibleMonths() % 2 === 0) offset--;
|
|
3528
4624
|
return constrainVisibleRangeStart(date, rawAlignStart(date).subtract({ months: offset }));
|
|
3529
4625
|
};
|
|
3530
4626
|
const defaultSelectionAlignment = () => {
|
|
3531
4627
|
const currentValue = access(props.value) ?? props.defaultValue;
|
|
3532
4628
|
if (!currentValue?.start || !currentValue?.end) return "center";
|
|
3533
|
-
const
|
|
4629
|
+
const start = alignCenter(toDisplayCalendarDate(currentValue.start));
|
|
4630
|
+
const end = visibleRangeEndFromStart(start);
|
|
3534
4631
|
return toDisplayCalendarDate(currentValue.end).compare(end) > 0 ? "start" : "center";
|
|
3535
4632
|
};
|
|
3536
4633
|
const alignVisibleRangeStart = (date) => {
|
|
@@ -3549,12 +4646,12 @@ function createRangeCalendarState(props = {}) {
|
|
|
3549
4646
|
if (props.defaultValue?.start) return toDisplayCalendarDate(props.defaultValue.start);
|
|
3550
4647
|
return toCalendar$1(today$1(timeZone), calendar());
|
|
3551
4648
|
};
|
|
3552
|
-
const [internalValue, setInternalValue] =
|
|
4649
|
+
const [internalValue, setInternalValue] = createInternalSignal(props.defaultValue ?? null);
|
|
3553
4650
|
const initialFocusedDate = constrainDate(getInitialFocusedDate());
|
|
3554
|
-
const [focusedDate, setFocusedDateInternal] =
|
|
3555
|
-
const [visibleRangeStart, setVisibleRangeStart] =
|
|
3556
|
-
const [isFocused, setFocused] =
|
|
3557
|
-
const [isDragging, setDragging] =
|
|
4651
|
+
const [focusedDate, setFocusedDateInternal] = createInternalSignal(initialFocusedDate);
|
|
4652
|
+
const [visibleRangeStart, setVisibleRangeStart] = createInternalSignal(alignVisibleRangeStart(initialFocusedDate));
|
|
4653
|
+
const [isFocused, setFocused] = createInternalSignal(false);
|
|
4654
|
+
const [isDragging, setDragging] = createInternalSignal(false);
|
|
3558
4655
|
const sourceValue = createMemo(() => {
|
|
3559
4656
|
const controlled = access(props.value);
|
|
3560
4657
|
return controlled !== void 0 ? controlled : internalValue();
|
|
@@ -3608,36 +4705,54 @@ function createRangeCalendarState(props = {}) {
|
|
|
3608
4705
|
end: visibleRangeEndFromStart(start)
|
|
3609
4706
|
};
|
|
3610
4707
|
});
|
|
3611
|
-
const syncVisibleRangeForFocusedDate = (nextFocusedDate) => {
|
|
3612
|
-
const range = visibleRange();
|
|
4708
|
+
const syncVisibleRangeForFocusedDate = (nextFocusedDate, range) => {
|
|
3613
4709
|
if (nextFocusedDate.compare(range.start) < 0) setVisibleRangeStart(alignEnd(nextFocusedDate));
|
|
3614
4710
|
else if (nextFocusedDate.compare(range.end) > 0) setVisibleRangeStart(alignStart(nextFocusedDate));
|
|
3615
4711
|
};
|
|
3616
4712
|
createEffect(() => {
|
|
3617
4713
|
const controlledFocused = access(props.focusedValue);
|
|
3618
|
-
if (!controlledFocused) return;
|
|
4714
|
+
if (!controlledFocused) return null;
|
|
3619
4715
|
const nextFocusedDate = constrainDate(toDisplayCalendarDate(controlledFocused));
|
|
3620
|
-
|
|
4716
|
+
return {
|
|
4717
|
+
nextFocusedDate,
|
|
4718
|
+
currentFocusedDate: focusedDate(),
|
|
4719
|
+
alignedStart: alignVisibleRangeStart(nextFocusedDate)
|
|
4720
|
+
};
|
|
4721
|
+
}, (data) => {
|
|
4722
|
+
if (!data) return;
|
|
4723
|
+
const { nextFocusedDate, currentFocusedDate, alignedStart } = data;
|
|
3621
4724
|
if (nextFocusedDate.compare(currentFocusedDate) !== 0 || !isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)) {
|
|
3622
4725
|
setFocusedDateInternal(nextFocusedDate);
|
|
3623
|
-
setVisibleRangeStart(
|
|
4726
|
+
setVisibleRangeStart(alignedStart);
|
|
3624
4727
|
}
|
|
3625
4728
|
});
|
|
3626
4729
|
createEffect(() => {
|
|
3627
|
-
if (access(props.focusedValue)) return;
|
|
4730
|
+
if (access(props.focusedValue)) return null;
|
|
3628
4731
|
const currentFocusedDate = focusedDate();
|
|
3629
4732
|
const nextFocusedDate = constrainDate(currentFocusedDate);
|
|
3630
|
-
if (nextFocusedDate.compare(currentFocusedDate) === 0 && isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)) return;
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
4733
|
+
if (nextFocusedDate.compare(currentFocusedDate) === 0 && isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)) return null;
|
|
4734
|
+
return {
|
|
4735
|
+
nextFocusedDate,
|
|
4736
|
+
alignedStart: alignVisibleRangeStart(nextFocusedDate)
|
|
4737
|
+
};
|
|
4738
|
+
}, (data) => {
|
|
4739
|
+
if (!data) return;
|
|
4740
|
+
setFocusedDateInternal(data.nextFocusedDate);
|
|
4741
|
+
setVisibleRangeStart(data.alignedStart);
|
|
4742
|
+
props.onFocusChange?.(data.nextFocusedDate);
|
|
3634
4743
|
});
|
|
3635
4744
|
createEffect(() => {
|
|
3636
4745
|
const currentFocusedDate = focusedDate();
|
|
3637
4746
|
const nextFocusedDate = toDisplayCalendarDate(currentFocusedDate);
|
|
3638
|
-
if (isEqualCalendar(currentFocusedDate.calendar, nextFocusedDate.calendar)) return;
|
|
3639
|
-
|
|
3640
|
-
|
|
4747
|
+
if (isEqualCalendar(currentFocusedDate.calendar, nextFocusedDate.calendar)) return null;
|
|
4748
|
+
return {
|
|
4749
|
+
nextFocusedDate,
|
|
4750
|
+
alignedStart: alignVisibleRangeStart(nextFocusedDate)
|
|
4751
|
+
};
|
|
4752
|
+
}, (data) => {
|
|
4753
|
+
if (!data) return;
|
|
4754
|
+
setFocusedDateInternal(data.nextFocusedDate);
|
|
4755
|
+
setVisibleRangeStart(data.alignedStart);
|
|
3641
4756
|
});
|
|
3642
4757
|
const weekDays = createMemo(() => {
|
|
3643
4758
|
const formatter = new DateFormatter$1(locale(), { weekday: "narrow" });
|
|
@@ -3672,7 +4787,7 @@ function createRangeCalendarState(props = {}) {
|
|
|
3672
4787
|
const setFocusedDate = (date) => {
|
|
3673
4788
|
const constrained = constrainDate(date);
|
|
3674
4789
|
if (Object.is(constrained, focusedDate())) return;
|
|
3675
|
-
syncVisibleRangeForFocusedDate(constrained);
|
|
4790
|
+
syncVisibleRangeForFocusedDate(constrained, visibleRange());
|
|
3676
4791
|
setFocusedDateInternal(constrained);
|
|
3677
4792
|
props.onFocusChange?.(constrained);
|
|
3678
4793
|
};
|
|
@@ -3728,14 +4843,14 @@ function createRangeCalendarState(props = {}) {
|
|
|
3728
4843
|
return isCellDisabled(date) || isCellUnavailable(date);
|
|
3729
4844
|
};
|
|
3730
4845
|
const focusPreviousPage = () => {
|
|
3731
|
-
const pageMonths = access(props.pageBehavior) === "single" ? 1 : visibleMonths;
|
|
4846
|
+
const pageMonths = access(props.pageBehavior) === "single" ? 1 : visibleMonths();
|
|
3732
4847
|
const nextFocusedDate = constrainDate(focusedDate().subtract({ months: pageMonths }));
|
|
3733
4848
|
setFocusedDateInternal(nextFocusedDate);
|
|
3734
4849
|
setVisibleRangeStart(startOfMonth$1(visibleRangeStart().subtract({ months: pageMonths })));
|
|
3735
4850
|
props.onFocusChange?.(nextFocusedDate);
|
|
3736
4851
|
};
|
|
3737
4852
|
const focusNextPage = () => {
|
|
3738
|
-
const pageMonths = access(props.pageBehavior) === "single" ? 1 : visibleMonths;
|
|
4853
|
+
const pageMonths = access(props.pageBehavior) === "single" ? 1 : visibleMonths();
|
|
3739
4854
|
const nextFocusedDate = constrainDate(focusedDate().add({ months: pageMonths }));
|
|
3740
4855
|
setFocusedDateInternal(nextFocusedDate);
|
|
3741
4856
|
setVisibleRangeStart(startOfMonth$1(visibleRangeStart().add({ months: pageMonths })));
|
|
@@ -3785,7 +4900,7 @@ function createRangeCalendarState(props = {}) {
|
|
|
3785
4900
|
const predicate = props.isDateUnavailable ? (d) => props.isDateUnavailable(d, anchorDate()) : void 0;
|
|
3786
4901
|
const selectableDate = previousAvailableDate(constrainedDate, toDisplayCalendarDate(visibleRange().start), predicate);
|
|
3787
4902
|
if (!selectableDate) return;
|
|
3788
|
-
const anchor = anchorDate
|
|
4903
|
+
const anchor = readNow(anchorDate);
|
|
3789
4904
|
if (!anchor) {
|
|
3790
4905
|
setAnchorDate(selectableDate);
|
|
3791
4906
|
setDragging(true);
|
|
@@ -3809,7 +4924,9 @@ function createRangeCalendarState(props = {}) {
|
|
|
3809
4924
|
setFocusedDate(selectableDate);
|
|
3810
4925
|
};
|
|
3811
4926
|
const getDatesInWeek = (weekIndex, monthStartDate) => {
|
|
3812
|
-
const
|
|
4927
|
+
const startDate = monthStartDate ?? visibleRange().start;
|
|
4928
|
+
const monthStart = startOfMonth$1(startDate);
|
|
4929
|
+
const weekStart = startOfWeek$1(monthStart, locale(), firstDayOfWeekName());
|
|
3813
4930
|
const week = [];
|
|
3814
4931
|
const firstDayOfWeek = weekStart.add({ weeks: weekIndex });
|
|
3815
4932
|
for (let i = 0; i < 7; i++) {
|
|
@@ -3818,8 +4935,18 @@ function createRangeCalendarState(props = {}) {
|
|
|
3818
4935
|
}
|
|
3819
4936
|
return week;
|
|
3820
4937
|
};
|
|
4938
|
+
const focusNearestAvailableDate = (anchor) => {
|
|
4939
|
+
const isDateInvalid = (candidate) => isInvalid(candidate) || isDateOutsideAllowedRange(candidate);
|
|
4940
|
+
let nextDay = anchor.add({ days: 1 });
|
|
4941
|
+
if (isDateInvalid(nextDay)) nextDay = anchor.subtract({ days: 1 });
|
|
4942
|
+
if (!isDateInvalid(nextDay)) {
|
|
4943
|
+
setFocusedDate(nextDay);
|
|
4944
|
+
setFocused(true);
|
|
4945
|
+
}
|
|
4946
|
+
};
|
|
3821
4947
|
const getWeeksInMonthFn = (date) => {
|
|
3822
|
-
|
|
4948
|
+
const monthDate = date ?? focusedDate();
|
|
4949
|
+
return getWeeksInMonth$1(monthDate, locale(), firstDayOfWeekName());
|
|
3823
4950
|
};
|
|
3824
4951
|
const formatValue = (locale2, fieldOptions) => {
|
|
3825
4952
|
const v = value();
|
|
@@ -3858,10 +4985,13 @@ function createRangeCalendarState(props = {}) {
|
|
|
3858
4985
|
};
|
|
3859
4986
|
} catch {}
|
|
3860
4987
|
endFormatter = startFormatter;
|
|
3861
|
-
} else
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
4988
|
+
} else {
|
|
4989
|
+
const endOptions = getFormatOptions(fieldOptions, {
|
|
4990
|
+
granularity: endGranularity,
|
|
4991
|
+
timeZone: endTimeZone
|
|
4992
|
+
});
|
|
4993
|
+
endFormatter = new DateFormatter$1(locale2, endOptions);
|
|
4994
|
+
}
|
|
3865
4995
|
return {
|
|
3866
4996
|
start: startFormatter.format(startDate),
|
|
3867
4997
|
end: endFormatter.format(endDate)
|
|
@@ -3907,13 +5037,16 @@ function createRangeCalendarState(props = {}) {
|
|
|
3907
5037
|
focusPageEnd,
|
|
3908
5038
|
selectFocusedDate,
|
|
3909
5039
|
selectDate,
|
|
5040
|
+
focusNearestAvailableDate,
|
|
3910
5041
|
isFocused,
|
|
3911
5042
|
setFocused,
|
|
3912
5043
|
getDatesInWeek,
|
|
3913
5044
|
getWeeksInMonth: getWeeksInMonthFn,
|
|
3914
5045
|
weekDays,
|
|
3915
5046
|
title,
|
|
3916
|
-
visibleMonths
|
|
5047
|
+
get visibleMonths() {
|
|
5048
|
+
return visibleMonths();
|
|
5049
|
+
},
|
|
3917
5050
|
isDragging,
|
|
3918
5051
|
setDragging,
|
|
3919
5052
|
formatValue
|
|
@@ -3966,8 +5099,9 @@ function nextUnavailableDate(anchorDate, isDateUnavailable, visibleMonths, dir)
|
|
|
3966
5099
|
/**
|
|
3967
5100
|
* TimeFieldState for Solid-Stately
|
|
3968
5101
|
*
|
|
3969
|
-
* Faithful port of
|
|
3970
|
-
*
|
|
5102
|
+
* Faithful port of
|
|
5103
|
+
* `packages/react-stately/src/datepicker/useTimeFieldState.ts`, which is a thin
|
|
5104
|
+
* wrapper over `useDateFieldState`: a time-only `Time` value is converted
|
|
3971
5105
|
* to a `CalendarDateTime` (anchored on today's date, or a zoned date when the
|
|
3972
5106
|
* value/default carries a time zone) and fed to the date-field state machine
|
|
3973
5107
|
* with `maxGranularity: 'hour'` so the date segments drop away and only
|
|
@@ -3998,7 +5132,7 @@ function convertValue(value, date = today$1(getLocalTimeZone$1())) {
|
|
|
3998
5132
|
*/
|
|
3999
5133
|
function createTimeFieldState(props = {}) {
|
|
4000
5134
|
const placeholderValue = props.placeholderValue ?? new Time();
|
|
4001
|
-
const [internalValue, setInternalValue] =
|
|
5135
|
+
const [internalValue, setInternalValue] = createInternalSignal(props.defaultValue ?? null);
|
|
4002
5136
|
const value = () => {
|
|
4003
5137
|
const controlled = access(props.value);
|
|
4004
5138
|
return controlled !== void 0 ? controlled : internalValue();
|
|
@@ -4115,14 +5249,14 @@ function createTimeFieldState(props = {}) {
|
|
|
4115
5249
|
*/
|
|
4116
5250
|
function createDatePickerState(props = {}) {
|
|
4117
5251
|
const timeZone = getLocalTimeZone$1();
|
|
4118
|
-
const [internalValue, setInternalValue] =
|
|
4119
|
-
const [internalOpen, setInternalOpen] =
|
|
4120
|
-
const [selectedDate, setSelectedDate] =
|
|
4121
|
-
const [selectedTime, setSelectedTime] =
|
|
4122
|
-
const value =
|
|
5252
|
+
const [internalValue, setInternalValue] = createInternalSignal(props.defaultValue ?? null);
|
|
5253
|
+
const [internalOpen, setInternalOpen] = createInternalSignal(props.defaultOpen ?? false);
|
|
5254
|
+
const [selectedDate, setSelectedDate] = createInternalSignal(null);
|
|
5255
|
+
const [selectedTime, setSelectedTime] = createInternalSignal(null);
|
|
5256
|
+
const value = () => {
|
|
4123
5257
|
const controlled = access(props.value);
|
|
4124
5258
|
return controlled !== void 0 ? controlled : internalValue();
|
|
4125
|
-
}
|
|
5259
|
+
};
|
|
4126
5260
|
const granularity = createMemo(() => {
|
|
4127
5261
|
if (props.granularity) return props.granularity;
|
|
4128
5262
|
const v = value();
|
|
@@ -4139,7 +5273,7 @@ function createDatePickerState(props = {}) {
|
|
|
4139
5273
|
const isDisabled = createMemo(() => access(props.isDisabled) ?? false);
|
|
4140
5274
|
const isReadOnly = createMemo(() => access(props.isReadOnly) ?? false);
|
|
4141
5275
|
const validationState = createMemo(() => access(props.validationState));
|
|
4142
|
-
const isOpen = () => access(props.isOpen) ?? internalOpen
|
|
5276
|
+
const isOpen = () => access(props.isOpen) ?? readNow(internalOpen);
|
|
4143
5277
|
const dateValue = createMemo(() => {
|
|
4144
5278
|
const v = value();
|
|
4145
5279
|
if (!v) return null;
|
|
@@ -4176,11 +5310,12 @@ function createDatePickerState(props = {}) {
|
|
|
4176
5310
|
};
|
|
4177
5311
|
const setDateValue = (date) => {
|
|
4178
5312
|
if (isDisabled() || isReadOnly()) return;
|
|
4179
|
-
const currentTime = selectedTime
|
|
5313
|
+
const currentTime = readNow(selectedTime);
|
|
4180
5314
|
const currentValue = value();
|
|
4181
5315
|
const shouldClose = typeof props.shouldCloseOnSelect === "function" ? props.shouldCloseOnSelect() : props.shouldCloseOnSelect ?? true;
|
|
4182
5316
|
if (hasTime() && (currentTime || shouldClose)) {
|
|
4183
|
-
|
|
5317
|
+
const timePart = currentTime ?? (currentValue && "hour" in currentValue ? currentValue : null) ?? getPlaceholderTime();
|
|
5318
|
+
commitValue(date, timePart);
|
|
4184
5319
|
if (shouldClose) setOpen(false);
|
|
4185
5320
|
} else if (hasTime()) setSelectedDate(date);
|
|
4186
5321
|
else {
|
|
@@ -4190,11 +5325,13 @@ function createDatePickerState(props = {}) {
|
|
|
4190
5325
|
};
|
|
4191
5326
|
const setTimeValue = (time) => {
|
|
4192
5327
|
if (isDisabled() || isReadOnly()) return;
|
|
4193
|
-
const currentDate = selectedDate
|
|
5328
|
+
const currentDate = readNow(selectedDate);
|
|
4194
5329
|
const currentValue = value();
|
|
4195
5330
|
if (currentDate) commitValue(currentDate, time);
|
|
4196
|
-
else if (currentValue && hasTime())
|
|
4197
|
-
|
|
5331
|
+
else if (currentValue && hasTime()) {
|
|
5332
|
+
const datePart = toCalendarDate$1(currentValue);
|
|
5333
|
+
commitValue(datePart, time);
|
|
5334
|
+
} else setSelectedTime(time);
|
|
4198
5335
|
};
|
|
4199
5336
|
const open = () => setOpen(true);
|
|
4200
5337
|
const close = () => setOpen(false);
|
|
@@ -4204,8 +5341,8 @@ function createDatePickerState(props = {}) {
|
|
|
4204
5341
|
props.onOpenChange?.(true);
|
|
4205
5342
|
} else {
|
|
4206
5343
|
const currentValue = value();
|
|
4207
|
-
const currentDate = selectedDate
|
|
4208
|
-
const currentTime = selectedTime
|
|
5344
|
+
const currentDate = readNow(selectedDate);
|
|
5345
|
+
const currentTime = readNow(selectedTime);
|
|
4209
5346
|
if (!currentValue && currentDate && hasTime() && currentTime) commitValue(currentDate, currentTime);
|
|
4210
5347
|
setSelectedDate(null);
|
|
4211
5348
|
setSelectedTime(null);
|
|
@@ -4292,8 +5429,8 @@ function createSelectState(props) {
|
|
|
4292
5429
|
});
|
|
4293
5430
|
const isControlledSingle = () => getProps().selectedKey !== void 0;
|
|
4294
5431
|
const isControlledMultiple = () => getProps().selectedKeys !== void 0;
|
|
4295
|
-
const [internalSelectedKey, setInternalSelectedKey] =
|
|
4296
|
-
const [internalSelectedKeys, setInternalSelectedKeys] =
|
|
5432
|
+
const [internalSelectedKey, setInternalSelectedKey] = createInternalSignal(getProps().defaultSelectedKey ?? null);
|
|
5433
|
+
const [internalSelectedKeys, setInternalSelectedKeys] = createInternalSignal(getProps().defaultSelectedKeys === "all" ? "all" : new Set(getProps().defaultSelectedKeys ?? []));
|
|
4297
5434
|
const selectedKey = () => {
|
|
4298
5435
|
if (selectionMode() === "multiple") {
|
|
4299
5436
|
const keys = selectedKeys();
|
|
@@ -4309,7 +5446,7 @@ function createSelectState(props) {
|
|
|
4309
5446
|
getProps().onSelectionChangeKeys?.(/* @__PURE__ */ new Set());
|
|
4310
5447
|
getProps().onSelectionChange?.(null);
|
|
4311
5448
|
} else {
|
|
4312
|
-
const next = new Set([key]);
|
|
5449
|
+
const next = /* @__PURE__ */ new Set([key]);
|
|
4313
5450
|
if (!isControlledMultiple()) setInternalSelectedKeys(next);
|
|
4314
5451
|
getProps().onSelectionChangeKeys?.(next);
|
|
4315
5452
|
getProps().onSelectionChange?.(key);
|
|
@@ -4318,7 +5455,7 @@ function createSelectState(props) {
|
|
|
4318
5455
|
}
|
|
4319
5456
|
if (!isControlledSingle()) setInternalSelectedKey(key);
|
|
4320
5457
|
getProps().onSelectionChange?.(key);
|
|
4321
|
-
getProps().onSelectionChangeKeys?.(key != null ? new Set([key]) : /* @__PURE__ */ new Set());
|
|
5458
|
+
getProps().onSelectionChangeKeys?.(key != null ? /* @__PURE__ */ new Set([key]) : /* @__PURE__ */ new Set());
|
|
4322
5459
|
};
|
|
4323
5460
|
const selectedKeys = createMemo(() => {
|
|
4324
5461
|
if (selectionMode() === "multiple") {
|
|
@@ -4329,7 +5466,7 @@ function createSelectState(props) {
|
|
|
4329
5466
|
return internalSelectedKeys();
|
|
4330
5467
|
}
|
|
4331
5468
|
const key = selectedKey();
|
|
4332
|
-
return key != null ? new Set([key]) : /* @__PURE__ */ new Set();
|
|
5469
|
+
return key != null ? /* @__PURE__ */ new Set([key]) : /* @__PURE__ */ new Set();
|
|
4333
5470
|
});
|
|
4334
5471
|
const setSelectedKeys = (keys) => {
|
|
4335
5472
|
const next = new Set(keys);
|
|
@@ -4339,8 +5476,29 @@ function createSelectState(props) {
|
|
|
4339
5476
|
getProps().onSelectionChange?.(next.size > 0 ? Array.from(next)[0] : null);
|
|
4340
5477
|
return;
|
|
4341
5478
|
}
|
|
4342
|
-
|
|
5479
|
+
const key = next.size > 0 ? Array.from(next)[0] : null;
|
|
5480
|
+
setSelectedKey(key);
|
|
4343
5481
|
};
|
|
5482
|
+
const validation = createFormValidationState({
|
|
5483
|
+
get value() {
|
|
5484
|
+
return selectionMode() === "multiple" ? selectedKeys() : selectedKey();
|
|
5485
|
+
},
|
|
5486
|
+
get isInvalid() {
|
|
5487
|
+
return getProps().isInvalid;
|
|
5488
|
+
},
|
|
5489
|
+
get validationState() {
|
|
5490
|
+
return getProps().validationState;
|
|
5491
|
+
},
|
|
5492
|
+
get validate() {
|
|
5493
|
+
return getProps().validate;
|
|
5494
|
+
},
|
|
5495
|
+
get name() {
|
|
5496
|
+
return getProps().name;
|
|
5497
|
+
},
|
|
5498
|
+
get validationBehavior() {
|
|
5499
|
+
return getProps().validationBehavior ?? "native";
|
|
5500
|
+
}
|
|
5501
|
+
});
|
|
4344
5502
|
const listState = createListState({
|
|
4345
5503
|
get items() {
|
|
4346
5504
|
return getProps().items;
|
|
@@ -4360,7 +5518,10 @@ function createSelectState(props) {
|
|
|
4360
5518
|
get selectionMode() {
|
|
4361
5519
|
return selectionMode();
|
|
4362
5520
|
},
|
|
4363
|
-
disallowEmptySelection
|
|
5521
|
+
get disallowEmptySelection() {
|
|
5522
|
+
return selectionMode() === "single";
|
|
5523
|
+
},
|
|
5524
|
+
allowDuplicateSelectionEvents: true,
|
|
4364
5525
|
get selectedKeys() {
|
|
4365
5526
|
const keys = selectedKeys();
|
|
4366
5527
|
if (keys === "all") return "all";
|
|
@@ -4371,14 +5532,17 @@ function createSelectState(props) {
|
|
|
4371
5532
|
if (!isControlledMultiple()) setInternalSelectedKeys(keys);
|
|
4372
5533
|
getProps().onSelectionChangeKeys?.(keys);
|
|
4373
5534
|
if (keys !== "all") getProps().onSelectionChange?.(keys.size > 0 ? Array.from(keys)[0] : null);
|
|
5535
|
+
validation.commitValidation();
|
|
4374
5536
|
return;
|
|
4375
5537
|
}
|
|
4376
5538
|
if (keys === "all") return;
|
|
4377
|
-
|
|
5539
|
+
const key = keys.size > 0 ? Array.from(keys)[0] : null;
|
|
5540
|
+
setSelectedKey(key);
|
|
4378
5541
|
overlayState.close();
|
|
5542
|
+
validation.commitValidation();
|
|
4379
5543
|
}
|
|
4380
5544
|
});
|
|
4381
|
-
const [isFocused, setFocused] =
|
|
5545
|
+
const [isFocused, setFocused] = createInternalSignal(false);
|
|
4382
5546
|
const selectedItem = createMemo(() => {
|
|
4383
5547
|
const key = selectedKey();
|
|
4384
5548
|
if (key == null) return null;
|
|
@@ -4395,6 +5559,11 @@ function createSelectState(props) {
|
|
|
4395
5559
|
return items;
|
|
4396
5560
|
});
|
|
4397
5561
|
return {
|
|
5562
|
+
realtimeValidation: validation.realtimeValidation,
|
|
5563
|
+
displayValidation: validation.displayValidation,
|
|
5564
|
+
updateValidation: validation.updateValidation,
|
|
5565
|
+
resetValidation: validation.resetValidation,
|
|
5566
|
+
commitValidation: validation.commitValidation,
|
|
4398
5567
|
collection: listState.collection,
|
|
4399
5568
|
selectionManager: listState.selectionManager,
|
|
4400
5569
|
focusedKey: listState.focusedKey,
|
|
@@ -4447,11 +5616,11 @@ function createComboBoxState(props) {
|
|
|
4447
5616
|
const allowsCustomValue = () => getProps().allowsCustomValue ?? false;
|
|
4448
5617
|
const shouldCloseOnBlur = () => getProps().shouldCloseOnBlur ?? true;
|
|
4449
5618
|
const isMultiple = () => getProps().selectionMode === "multiple";
|
|
4450
|
-
const [focusStrategy, setFocusStrategy] =
|
|
4451
|
-
const [showAllItems, setShowAllItems] =
|
|
5619
|
+
const [focusStrategy, setFocusStrategy] = createInternalSignal(null);
|
|
5620
|
+
const [showAllItems, setShowAllItems] = createInternalSignal(false);
|
|
4452
5621
|
let menuOpenTrigger = "focus";
|
|
4453
5622
|
const isMultiSelectionControlled = () => getProps().selectedKeys !== void 0;
|
|
4454
|
-
const [internalSelectedKeys, setInternalSelectedKeys] =
|
|
5623
|
+
const [internalSelectedKeys, setInternalSelectedKeys] = createInternalSignal(new Set(getProps().defaultSelectedKeys ?? []));
|
|
4455
5624
|
const selectedKeys = () => {
|
|
4456
5625
|
return isMultiSelectionControlled() ? new Set(getProps().selectedKeys ?? []) : internalSelectedKeys();
|
|
4457
5626
|
};
|
|
@@ -4460,9 +5629,9 @@ function createComboBoxState(props) {
|
|
|
4460
5629
|
getProps().onSelectionChangeMultiple?.(keys);
|
|
4461
5630
|
};
|
|
4462
5631
|
const isSelectionControlled = () => getProps().selectedKey !== void 0;
|
|
4463
|
-
const [internalSelectedKey, setInternalSelectedKey] =
|
|
5632
|
+
const [internalSelectedKey, setInternalSelectedKey] = createInternalSignal(getProps().defaultSelectedKey ?? null);
|
|
4464
5633
|
const isInputControlled = () => getProps().inputValue !== void 0;
|
|
4465
|
-
const [internalInputValue, setInternalInputValue] =
|
|
5634
|
+
const [internalInputValue, setInternalInputValue] = createInternalSignal(getProps().defaultInputValue ?? "");
|
|
4466
5635
|
let inputInitialized = false;
|
|
4467
5636
|
const inputValue = () => {
|
|
4468
5637
|
return isInputControlled() ? getProps().inputValue ?? "" : internalInputValue();
|
|
@@ -4471,7 +5640,7 @@ function createComboBoxState(props) {
|
|
|
4471
5640
|
if (!isInputControlled()) setInternalInputValue(value);
|
|
4472
5641
|
getProps().onInputChange?.(value);
|
|
4473
5642
|
};
|
|
4474
|
-
const [lastValue, setLastValue] =
|
|
5643
|
+
const [lastValue, setLastValue] = createInternalSignal(inputValue());
|
|
4475
5644
|
const selectedKey = () => {
|
|
4476
5645
|
return isSelectionControlled() ? getProps().selectedKey ?? null : internalSelectedKey();
|
|
4477
5646
|
};
|
|
@@ -4479,6 +5648,7 @@ function createComboBoxState(props) {
|
|
|
4479
5648
|
if (!isSelectionControlled()) setInternalSelectedKey(key);
|
|
4480
5649
|
getProps().onSelectionChange?.(key);
|
|
4481
5650
|
};
|
|
5651
|
+
let listState;
|
|
4482
5652
|
const overlayState = createOverlayTriggerState({
|
|
4483
5653
|
get isOpen() {
|
|
4484
5654
|
return getProps().isOpen;
|
|
@@ -4488,9 +5658,11 @@ function createComboBoxState(props) {
|
|
|
4488
5658
|
},
|
|
4489
5659
|
onOpenChange(isOpen) {
|
|
4490
5660
|
getProps().onOpenChange?.(isOpen, isOpen ? menuOpenTrigger : void 0);
|
|
5661
|
+
listState?.setFocused(isOpen);
|
|
5662
|
+
if (!isOpen) listState?.setFocusedKey(null);
|
|
4491
5663
|
}
|
|
4492
5664
|
});
|
|
4493
|
-
|
|
5665
|
+
listState = createListState({
|
|
4494
5666
|
get items() {
|
|
4495
5667
|
return getProps().items ?? getProps().defaultItems ?? [];
|
|
4496
5668
|
},
|
|
@@ -4518,7 +5690,8 @@ function createComboBoxState(props) {
|
|
|
4518
5690
|
onSelectionChange(keys) {
|
|
4519
5691
|
if (keys === "all") return;
|
|
4520
5692
|
if (isMultiple()) {
|
|
4521
|
-
|
|
5693
|
+
const newKeys = new Set(keys);
|
|
5694
|
+
setSelectedKeys(newKeys);
|
|
4522
5695
|
return;
|
|
4523
5696
|
}
|
|
4524
5697
|
const key = keys.size > 0 ? Array.from(keys)[0] : null;
|
|
@@ -4533,10 +5706,9 @@ function createComboBoxState(props) {
|
|
|
4533
5706
|
const originalCollection = listState.collection;
|
|
4534
5707
|
const filteredCollection = createMemo(() => {
|
|
4535
5708
|
const collection = originalCollection();
|
|
4536
|
-
const input = inputValue();
|
|
4537
5709
|
const filter = getProps().defaultFilter;
|
|
4538
|
-
if (!filter) return collection;
|
|
4539
|
-
return filterCollection(collection,
|
|
5710
|
+
if (getProps().items != null || !filter) return collection;
|
|
5711
|
+
return filterCollection(collection, inputValue(), filter);
|
|
4540
5712
|
});
|
|
4541
5713
|
const displayedCollection = createMemo(() => {
|
|
4542
5714
|
return showAllItems() ? originalCollection() : filteredCollection();
|
|
@@ -4585,8 +5757,9 @@ function createComboBoxState(props) {
|
|
|
4585
5757
|
const displayAll = trigger === "manual" || trigger === "focus" && menuTrigger() === "focus";
|
|
4586
5758
|
const filtered = filteredCollection();
|
|
4587
5759
|
const original = originalCollection();
|
|
4588
|
-
|
|
4589
|
-
if (displayAll &&
|
|
5760
|
+
const items = getProps().items;
|
|
5761
|
+
if (!(allowsEmptyCollection() || filtered.size > 0 || displayAll && original.size > 0 || items != null)) return;
|
|
5762
|
+
if (displayAll && !overlayState.isOpen() && items === void 0) setShowAllItems(true);
|
|
4590
5763
|
menuOpenTrigger = trigger ?? "focus";
|
|
4591
5764
|
setFocusStrategy(strategy);
|
|
4592
5765
|
if (!overlayState.isOpen()) applyOpenFocus(strategy);
|
|
@@ -4596,9 +5769,10 @@ function createComboBoxState(props) {
|
|
|
4596
5769
|
const displayAll = trigger === "manual" || trigger === "focus" && menuTrigger() === "focus";
|
|
4597
5770
|
const filtered = filteredCollection();
|
|
4598
5771
|
const original = originalCollection();
|
|
4599
|
-
|
|
5772
|
+
const items = getProps().items;
|
|
5773
|
+
if (!(allowsEmptyCollection() || filtered.size > 0 || displayAll && original.size > 0 || items != null) && !overlayState.isOpen()) return;
|
|
4600
5774
|
const willOpen = !overlayState.isOpen();
|
|
4601
|
-
if (displayAll && willOpen) setShowAllItems(true);
|
|
5775
|
+
if (displayAll && willOpen && items === void 0) setShowAllItems(true);
|
|
4602
5776
|
if (willOpen) menuOpenTrigger = trigger ?? "focus";
|
|
4603
5777
|
setFocusStrategy(strategy);
|
|
4604
5778
|
if (willOpen) applyOpenFocus(strategy);
|
|
@@ -4611,7 +5785,8 @@ function createComboBoxState(props) {
|
|
|
4611
5785
|
const commitSelection = () => {
|
|
4612
5786
|
if (isSelectionControlled() && isInputControlled()) {
|
|
4613
5787
|
getProps().onSelectionChange?.(selectedKey());
|
|
4614
|
-
|
|
5788
|
+
const item = selectedItem();
|
|
5789
|
+
setLastValue(item?.textValue ?? "");
|
|
4615
5790
|
closeMenu();
|
|
4616
5791
|
} else {
|
|
4617
5792
|
resetInputValue();
|
|
@@ -4631,56 +5806,66 @@ function createComboBoxState(props) {
|
|
|
4631
5806
|
if (overlayState.isOpen() && focusedKey != null) select(focusedKey);
|
|
4632
5807
|
return;
|
|
4633
5808
|
}
|
|
4634
|
-
if (overlayState.isOpen() && focusedKey != null)
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
}
|
|
4639
|
-
else commitValue();
|
|
5809
|
+
if (overlayState.isOpen() && focusedKey != null) {
|
|
5810
|
+
if (selectedKey() === focusedKey) commitSelection();
|
|
5811
|
+
else listState.selectionManager.select(focusedKey);
|
|
5812
|
+
} else commitValue();
|
|
4640
5813
|
};
|
|
4641
5814
|
const revert = () => {
|
|
4642
5815
|
if (allowsCustomValue() && selectedKey() == null) commitCustomValue();
|
|
4643
5816
|
else commitSelection();
|
|
4644
5817
|
};
|
|
4645
|
-
const [isFocused, setIsFocused] =
|
|
5818
|
+
const [isFocused, setIsFocused] = createInternalSignal(false);
|
|
4646
5819
|
const setFocused = (focused) => {
|
|
4647
5820
|
if (focused) {
|
|
4648
|
-
inputValue();
|
|
4649
5821
|
if (menuTrigger() === "focus" && !getProps().isReadOnly) open(null, "focus");
|
|
4650
5822
|
} else if (shouldCloseOnBlur()) commitValue();
|
|
4651
5823
|
setIsFocused(focused);
|
|
4652
5824
|
};
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
5825
|
+
let lastDisplayValue = untrack(selectedKey);
|
|
5826
|
+
createEffect(() => ({
|
|
5827
|
+
input: inputValue(),
|
|
5828
|
+
filtered: filteredCollection(),
|
|
5829
|
+
isOpen: overlayState.isOpen(),
|
|
5830
|
+
last: lastValue(),
|
|
5831
|
+
focused: isFocused(),
|
|
5832
|
+
key: isMultiple() ? null : selectedKey(),
|
|
5833
|
+
allowsEmpty: allowsEmptyCollection(),
|
|
5834
|
+
trigger: menuTrigger(),
|
|
5835
|
+
showingAll: showAllItems(),
|
|
5836
|
+
inputControlled: isInputControlled(),
|
|
5837
|
+
selectionControlled: isSelectionControlled()
|
|
5838
|
+
}), ({ input, filtered, isOpen, last, focused, key, allowsEmpty, trigger, showingAll, inputControlled, selectionControlled }) => {
|
|
5839
|
+
if (focused && (filtered.size > 0 || allowsEmpty) && !isOpen && input !== last && trigger !== "manual") open(null, "input");
|
|
5840
|
+
if (!showingAll && !allowsEmpty && isOpen && filtered.size === 0) closeMenu();
|
|
5841
|
+
if (key != null && key !== lastDisplayValue) closeMenu();
|
|
4660
5842
|
if (input !== last) {
|
|
4661
5843
|
listState.setFocusedKey(null);
|
|
4662
5844
|
setShowAllItems(false);
|
|
4663
|
-
if (input === "" && (!
|
|
5845
|
+
if (input === "" && (!inputControlled || !selectionControlled)) setSelectedKey(null);
|
|
4664
5846
|
setLastValue(input);
|
|
4665
5847
|
}
|
|
5848
|
+
lastDisplayValue = key;
|
|
4666
5849
|
});
|
|
4667
5850
|
createEffect(() => {
|
|
4668
|
-
if (isMultiple()) return;
|
|
5851
|
+
if (isMultiple()) return null;
|
|
4669
5852
|
const key = selectedKey();
|
|
4670
|
-
|
|
4671
|
-
|
|
5853
|
+
return {
|
|
5854
|
+
key,
|
|
5855
|
+
textValue: (key != null ? originalCollection().getItem(key) : null)?.textValue ?? "",
|
|
5856
|
+
inputControlled: isInputControlled(),
|
|
5857
|
+
selectionControlled: isSelectionControlled()
|
|
5858
|
+
};
|
|
5859
|
+
}, (data) => {
|
|
5860
|
+
if (!data) return;
|
|
5861
|
+
const { key, textValue, inputControlled, selectionControlled } = data;
|
|
5862
|
+
if (!inputControlled || !selectionControlled) {
|
|
4672
5863
|
if (key != null && textValue !== untrack(inputValue)) {
|
|
4673
5864
|
setInputValue(textValue);
|
|
4674
5865
|
setLastValue(textValue);
|
|
4675
5866
|
}
|
|
4676
5867
|
}
|
|
4677
5868
|
});
|
|
4678
|
-
createEffect((prevKey) => {
|
|
4679
|
-
if (isMultiple()) return void 0;
|
|
4680
|
-
const key = selectedKey();
|
|
4681
|
-
if (key != null && key !== prevKey) closeMenu();
|
|
4682
|
-
return key;
|
|
4683
|
-
}, void 0);
|
|
4684
5869
|
const select = (key) => {
|
|
4685
5870
|
if (isMultiple()) {
|
|
4686
5871
|
const current = new Set(selectedKeys());
|
|
@@ -4715,6 +5900,7 @@ function createComboBoxState(props) {
|
|
|
4715
5900
|
selectedItem,
|
|
4716
5901
|
setSelectedKey,
|
|
4717
5902
|
selectedKeys,
|
|
5903
|
+
setSelectedKeys,
|
|
4718
5904
|
selectedItems,
|
|
4719
5905
|
removeSelectedKey,
|
|
4720
5906
|
inputValue,
|
|
@@ -4745,101 +5931,39 @@ function createComboBoxState(props) {
|
|
|
4745
5931
|
}
|
|
4746
5932
|
/**
|
|
4747
5933
|
* Filter a collection based on input value.
|
|
5934
|
+
* RAC `useComboBoxState.ts:644-672` copies nodes into a new `ListCollection`,
|
|
5935
|
+
* which reassigns `index` (ListCollection.ts:51-53). Keeping the original
|
|
5936
|
+
* `index` makes virtualized `aria-posinset` report the unfiltered position.
|
|
4748
5937
|
*/
|
|
4749
5938
|
function filterCollection(collection, inputValue, filter) {
|
|
4750
5939
|
if (!inputValue) return collection;
|
|
4751
5940
|
const filteredItems = [];
|
|
5941
|
+
let index = 0;
|
|
4752
5942
|
for (const item of collection) if (item.type === "section") {
|
|
4753
5943
|
const filteredChildren = [];
|
|
4754
5944
|
if (item.childNodes) {
|
|
4755
|
-
for (const child of item.childNodes) if (child.type === "item" && filter(child.textValue, inputValue)) filteredChildren.push(
|
|
5945
|
+
for (const child of item.childNodes) if (child.type === "item" && filter(child.textValue, inputValue)) filteredChildren.push({
|
|
5946
|
+
...child,
|
|
5947
|
+
index: index++
|
|
5948
|
+
});
|
|
4756
5949
|
}
|
|
4757
5950
|
if (filteredChildren.length > 0) filteredItems.push({
|
|
4758
5951
|
...item,
|
|
4759
5952
|
childNodes: filteredChildren
|
|
4760
5953
|
});
|
|
4761
5954
|
} else if (item.type === "item") {
|
|
4762
|
-
if (filter(item.textValue, inputValue)) filteredItems.push(
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
}
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
*/
|
|
4769
|
-
function createFilteredCollection(items, original) {
|
|
4770
|
-
const itemMap = /* @__PURE__ */ new Map();
|
|
4771
|
-
for (const item of items) {
|
|
4772
|
-
itemMap.set(item.key, item);
|
|
4773
|
-
if (item.childNodes) for (const child of item.childNodes) itemMap.set(child.key, child);
|
|
4774
|
-
}
|
|
4775
|
-
return {
|
|
4776
|
-
get size() {
|
|
4777
|
-
let count = 0;
|
|
4778
|
-
for (const item of items) if (item.type === "item") count++;
|
|
4779
|
-
else if (item.childNodes) count += Array.from(item.childNodes).filter((c) => c.type === "item").length;
|
|
4780
|
-
return count;
|
|
4781
|
-
},
|
|
4782
|
-
getItem(key) {
|
|
4783
|
-
return itemMap.get(key) ?? null;
|
|
4784
|
-
},
|
|
4785
|
-
getKeys() {
|
|
4786
|
-
return itemMap.keys();
|
|
4787
|
-
},
|
|
4788
|
-
getFirstKey() {
|
|
4789
|
-
for (const item of items) {
|
|
4790
|
-
if (item.type === "item") return item.key;
|
|
4791
|
-
if (item.childNodes) {
|
|
4792
|
-
for (const child of item.childNodes) if (child.type === "item") return child.key;
|
|
4793
|
-
}
|
|
4794
|
-
}
|
|
4795
|
-
return null;
|
|
4796
|
-
},
|
|
4797
|
-
getLastKey() {
|
|
4798
|
-
for (let i = items.length - 1; i >= 0; i--) {
|
|
4799
|
-
const item = items[i];
|
|
4800
|
-
if (item.type === "item") return item.key;
|
|
4801
|
-
if (item.childNodes) {
|
|
4802
|
-
const children = Array.from(item.childNodes);
|
|
4803
|
-
for (let j = children.length - 1; j >= 0; j--) if (children[j].type === "item") return children[j].key;
|
|
4804
|
-
}
|
|
4805
|
-
}
|
|
4806
|
-
return null;
|
|
4807
|
-
},
|
|
4808
|
-
getKeyBefore(key) {
|
|
4809
|
-
return original.getKeyBefore(key);
|
|
4810
|
-
},
|
|
4811
|
-
getKeyAfter(key) {
|
|
4812
|
-
return original.getKeyAfter(key);
|
|
4813
|
-
},
|
|
4814
|
-
at(index) {
|
|
4815
|
-
let currentIndex = 0;
|
|
4816
|
-
for (const item of items) if (item.type === "item") {
|
|
4817
|
-
if (currentIndex === index) return item;
|
|
4818
|
-
currentIndex++;
|
|
4819
|
-
} else if (item.childNodes) {
|
|
4820
|
-
for (const child of item.childNodes) if (child.type === "item") {
|
|
4821
|
-
if (currentIndex === index) return child;
|
|
4822
|
-
currentIndex++;
|
|
4823
|
-
}
|
|
4824
|
-
}
|
|
4825
|
-
return null;
|
|
4826
|
-
},
|
|
4827
|
-
getChildren(key) {
|
|
4828
|
-
return itemMap.get(key)?.childNodes ?? [];
|
|
4829
|
-
},
|
|
4830
|
-
getTextValue(key) {
|
|
4831
|
-
return itemMap.get(key)?.textValue ?? "";
|
|
4832
|
-
},
|
|
4833
|
-
[Symbol.iterator]() {
|
|
4834
|
-
return items[Symbol.iterator]();
|
|
4835
|
-
}
|
|
4836
|
-
};
|
|
5955
|
+
if (filter(item.textValue, inputValue)) filteredItems.push({
|
|
5956
|
+
...item,
|
|
5957
|
+
index: index++
|
|
5958
|
+
});
|
|
5959
|
+
} else filteredItems.push({ ...item });
|
|
5960
|
+
return new ListCollection(filteredItems);
|
|
4837
5961
|
}
|
|
4838
5962
|
//#endregion
|
|
4839
5963
|
//#region src/tabs/createTabListState.ts
|
|
4840
5964
|
/**
|
|
4841
5965
|
* State management for tab components.
|
|
4842
|
-
*
|
|
5966
|
+
* Ported from packages/react-stately/src/tabs/useTabListState.ts.
|
|
4843
5967
|
*/
|
|
4844
5968
|
/**
|
|
4845
5969
|
* Creates state for a tab list component.
|
|
@@ -4888,7 +6012,7 @@ function createTabListState(props) {
|
|
|
4888
6012
|
if (p.defaultSelectedKey !== void 0 && !isKeyDisabled(p.defaultSelectedKey)) return p.defaultSelectedKey;
|
|
4889
6013
|
return findFirstNonDisabledKey();
|
|
4890
6014
|
};
|
|
4891
|
-
const [selectedKeyInternal, setSelectedKeyInternal] =
|
|
6015
|
+
const [selectedKeyInternal, setSelectedKeyInternal] = createInternalSignal(getInitialSelectedKey());
|
|
4892
6016
|
const selectedKey = () => {
|
|
4893
6017
|
const p = getProps();
|
|
4894
6018
|
if (p.selectedKey !== void 0) return p.selectedKey;
|
|
@@ -4909,33 +6033,55 @@ function createTabListState(props) {
|
|
|
4909
6033
|
const isDisabled = () => getProps().isDisabled ?? false;
|
|
4910
6034
|
const keyboardActivation = () => getProps().keyboardActivation ?? "automatic";
|
|
4911
6035
|
const orientation = () => getProps().orientation ?? "horizontal";
|
|
4912
|
-
const [isFocused, setIsFocused] =
|
|
4913
|
-
const [focusedKey, setFocusedKeyInternal] =
|
|
4914
|
-
const [childFocusStrategy, setChildFocusStrategy] =
|
|
6036
|
+
const [isFocused, setIsFocused] = createInternalSignal(false);
|
|
6037
|
+
const [focusedKey, setFocusedKeyInternal] = createInternalSignal(null);
|
|
6038
|
+
const [childFocusStrategy, setChildFocusStrategy] = createInternalSignal(null);
|
|
4915
6039
|
const setFocusedKey = (key, childStrategy) => {
|
|
4916
6040
|
setFocusedKeyInternal(key);
|
|
4917
6041
|
setChildFocusStrategy(childStrategy ?? null);
|
|
4918
6042
|
};
|
|
4919
6043
|
let lastSelectedKey = selectedKey();
|
|
4920
|
-
|
|
6044
|
+
let selectedToFocusedFrame = null;
|
|
6045
|
+
const copySelectedToFocusedKey = () => {
|
|
6046
|
+
selectedToFocusedFrame = null;
|
|
4921
6047
|
const sel = selectedKey();
|
|
4922
6048
|
if (sel !== null && focusedKey() === null || !isFocused() && sel !== lastSelectedKey) setFocusedKey(sel);
|
|
4923
6049
|
lastSelectedKey = sel;
|
|
6050
|
+
};
|
|
6051
|
+
createEffect(() => ({
|
|
6052
|
+
sel: selectedKey(),
|
|
6053
|
+
foc: focusedKey(),
|
|
6054
|
+
focused: isFocused()
|
|
6055
|
+
}), ({ sel, foc, focused }) => {
|
|
6056
|
+
if (sel !== null && foc === null) {
|
|
6057
|
+
setFocusedKey(sel);
|
|
6058
|
+
lastSelectedKey = sel;
|
|
6059
|
+
return;
|
|
6060
|
+
}
|
|
6061
|
+
if (!focused && sel !== lastSelectedKey) {
|
|
6062
|
+
if (selectedToFocusedFrame != null) return;
|
|
6063
|
+
selectedToFocusedFrame = requestAnimationFrame(copySelectedToFocusedKey);
|
|
6064
|
+
}
|
|
6065
|
+
});
|
|
6066
|
+
onCleanup(() => {
|
|
6067
|
+
if (selectedToFocusedFrame == null) return;
|
|
6068
|
+
cancelAnimationFrame(selectedToFocusedFrame);
|
|
6069
|
+
selectedToFocusedFrame = null;
|
|
4924
6070
|
});
|
|
4925
|
-
|
|
6071
|
+
createEffect(() => {
|
|
4926
6072
|
const p = getProps();
|
|
4927
|
-
if (p.selectedKey !== void 0) return;
|
|
6073
|
+
if (p.selectedKey !== void 0) return void 0;
|
|
4928
6074
|
const coll = collection();
|
|
6075
|
+
if (coll.size === 0) return void 0;
|
|
4929
6076
|
const current = selectedKeyInternal();
|
|
4930
6077
|
const currentExists = current !== null && coll.getItem(current) !== null;
|
|
4931
6078
|
const currentEnabled = current !== null && !isKeyDisabled(current);
|
|
4932
|
-
if (currentExists && currentEnabled) return;
|
|
4933
|
-
if (p.defaultSelectedKey !== void 0 && coll.getItem(p.defaultSelectedKey) !== null && !isKeyDisabled(p.defaultSelectedKey))
|
|
4934
|
-
if (p.defaultSelectedKey !== current) setSelectedKeyInternal(p.defaultSelectedKey);
|
|
4935
|
-
return;
|
|
4936
|
-
}
|
|
6079
|
+
if (currentExists && currentEnabled) return void 0;
|
|
6080
|
+
if (p.defaultSelectedKey !== void 0 && coll.getItem(p.defaultSelectedKey) !== null && !isKeyDisabled(p.defaultSelectedKey)) return p.defaultSelectedKey !== current ? p.defaultSelectedKey : void 0;
|
|
4937
6081
|
const nextKey = findFirstNonDisabledKey();
|
|
4938
|
-
|
|
6082
|
+
return nextKey !== current ? nextKey : void 0;
|
|
6083
|
+
}, (nextKey) => {
|
|
6084
|
+
if (nextKey !== void 0) setSelectedKeyInternal(nextKey);
|
|
4939
6085
|
});
|
|
4940
6086
|
return {
|
|
4941
6087
|
collection,
|
|
@@ -5000,50 +6146,60 @@ function isValidStep(step) {
|
|
|
5000
6146
|
*/
|
|
5001
6147
|
function createNumberFieldState(props) {
|
|
5002
6148
|
const getProps = () => access(props);
|
|
6149
|
+
const [inputValue, setInputValueInternal] = createInternalSignal("");
|
|
6150
|
+
const [numberValue, setNumberValue] = createInternalSignal(NaN);
|
|
5003
6151
|
const locale = () => getProps().locale ?? "en-US";
|
|
5004
6152
|
const formatOptions = () => getProps().formatOptions ?? {};
|
|
6153
|
+
const numberParser = createMemo(() => {
|
|
6154
|
+
return new NumberParser(locale(), formatOptions());
|
|
6155
|
+
});
|
|
6156
|
+
const numberingSystem = createMemo(() => {
|
|
6157
|
+
return numberParser().getNumberingSystem(inputValue());
|
|
6158
|
+
});
|
|
5005
6159
|
const formatter = createMemo(() => {
|
|
5006
|
-
return new
|
|
6160
|
+
return new NumberFormatter(locale(), {
|
|
6161
|
+
...formatOptions(),
|
|
6162
|
+
numberingSystem: numberingSystem()
|
|
6163
|
+
});
|
|
5007
6164
|
});
|
|
5008
6165
|
const parseNumber = (value) => {
|
|
5009
|
-
|
|
5010
|
-
const opts = formatOptions();
|
|
5011
|
-
const decimalSeparator = formatter().format(1.1).charAt(1);
|
|
5012
|
-
let normalized = value;
|
|
5013
|
-
if (decimalSeparator !== ".") normalized = normalized.replace(decimalSeparator, ".");
|
|
5014
|
-
normalized = normalized.replace(/[^\d.-]/g, "");
|
|
5015
|
-
const parsed = parseFloat(normalized);
|
|
5016
|
-
if (isNaN(parsed)) return parsed;
|
|
5017
|
-
if (opts.style === "percent") return parsed / 100;
|
|
5018
|
-
return parsed;
|
|
6166
|
+
return numberParser().parse(value);
|
|
5019
6167
|
};
|
|
5020
6168
|
const formatNumber = (value) => {
|
|
5021
|
-
if (isNaN(value)) return "";
|
|
6169
|
+
if (isNaN(value) || value === null) return "";
|
|
5022
6170
|
return formatter().format(value);
|
|
5023
6171
|
};
|
|
5024
6172
|
const hasCustomStep = createMemo(() => isValidStep(getProps().step));
|
|
6173
|
+
const shouldSnap = () => (getProps().commitBehavior ?? "snap") === "snap";
|
|
5025
6174
|
const step = createMemo(() => {
|
|
5026
6175
|
const p = getProps();
|
|
5027
6176
|
if (hasCustomStep()) return p.step;
|
|
5028
|
-
if (
|
|
6177
|
+
if (formatter().resolvedOptions().style === "percent") return .01;
|
|
5029
6178
|
return 1;
|
|
5030
6179
|
});
|
|
5031
|
-
const [inputValue, setInputValueInternal] = createSignal("");
|
|
5032
|
-
const [numberValue, setNumberValue] = createSignal(NaN);
|
|
5033
6180
|
const applyConstraints = (value) => {
|
|
5034
6181
|
const p = getProps();
|
|
5035
6182
|
if (isNaN(value)) return NaN;
|
|
5036
6183
|
if (hasCustomStep()) return clamp$2(snapToStep$1(value, step(), p.minValue), p.minValue, p.maxValue);
|
|
5037
6184
|
return clamp$2(value, p.minValue, p.maxValue);
|
|
5038
6185
|
};
|
|
6186
|
+
let initialNumberValue = NaN;
|
|
6187
|
+
let capturedDefaultNumberValue = NaN;
|
|
6188
|
+
const constrainForCommit = (value) => {
|
|
6189
|
+
if (!shouldSnap()) return value;
|
|
6190
|
+
return applyConstraints(value);
|
|
6191
|
+
};
|
|
5039
6192
|
const initValue = () => {
|
|
5040
6193
|
const p = getProps();
|
|
5041
6194
|
const initial = p.value ?? p.defaultValue;
|
|
5042
|
-
if (initial != null) {
|
|
5043
|
-
const
|
|
5044
|
-
setNumberValue(
|
|
5045
|
-
setInputValueInternal(formatNumber(
|
|
5046
|
-
|
|
6195
|
+
if (initial != null && !isNaN(initial)) {
|
|
6196
|
+
const next = constrainForCommit(initial);
|
|
6197
|
+
setNumberValue(next);
|
|
6198
|
+
setInputValueInternal(formatNumber(next));
|
|
6199
|
+
initialNumberValue = next;
|
|
6200
|
+
} else initialNumberValue = NaN;
|
|
6201
|
+
const defaultValue = p.defaultValue ?? NaN;
|
|
6202
|
+
capturedDefaultNumberValue = isNaN(defaultValue) ? initialNumberValue : constrainForCommit(defaultValue);
|
|
5047
6203
|
};
|
|
5048
6204
|
let initialized = false;
|
|
5049
6205
|
const ensureInitialized = () => {
|
|
@@ -5055,7 +6211,7 @@ function createNumberFieldState(props) {
|
|
|
5055
6211
|
const actualNumberValue = createMemo(() => {
|
|
5056
6212
|
ensureInitialized();
|
|
5057
6213
|
const p = getProps();
|
|
5058
|
-
if (p.value !== void 0) return
|
|
6214
|
+
if (p.value !== void 0) return constrainForCommit(p.value);
|
|
5059
6215
|
return numberValue();
|
|
5060
6216
|
});
|
|
5061
6217
|
let lastControlledValue = void 0;
|
|
@@ -5065,23 +6221,41 @@ function createNumberFieldState(props) {
|
|
|
5065
6221
|
lastControlledValue = void 0;
|
|
5066
6222
|
return;
|
|
5067
6223
|
}
|
|
5068
|
-
const
|
|
5069
|
-
if (lastControlledValue === void 0 || !Object.is(lastControlledValue,
|
|
5070
|
-
lastControlledValue =
|
|
5071
|
-
setNumberValue(
|
|
5072
|
-
setInputValueInternal(formatNumber(
|
|
6224
|
+
const next = constrainForCommit(p.value);
|
|
6225
|
+
if (lastControlledValue === void 0 || !Object.is(lastControlledValue, next)) {
|
|
6226
|
+
lastControlledValue = next;
|
|
6227
|
+
setNumberValue(next);
|
|
6228
|
+
setInputValueInternal(formatNumber(next));
|
|
5073
6229
|
}
|
|
5074
6230
|
};
|
|
5075
6231
|
const parsedInputValue = () => {
|
|
5076
6232
|
ensureInitialized();
|
|
5077
6233
|
syncControlledValue();
|
|
5078
|
-
return parseNumber(inputValue
|
|
6234
|
+
return parseNumber(readNow(inputValue));
|
|
5079
6235
|
};
|
|
6236
|
+
const validation = createFormValidationState({
|
|
6237
|
+
get value() {
|
|
6238
|
+
ensureInitialized();
|
|
6239
|
+
return actualNumberValue();
|
|
6240
|
+
},
|
|
6241
|
+
get isInvalid() {
|
|
6242
|
+
return getProps().isInvalid;
|
|
6243
|
+
},
|
|
6244
|
+
get validationState() {
|
|
6245
|
+
return getProps().validationState;
|
|
6246
|
+
},
|
|
6247
|
+
get validate() {
|
|
6248
|
+
return getProps().validate;
|
|
6249
|
+
},
|
|
6250
|
+
get name() {
|
|
6251
|
+
return getProps().name;
|
|
6252
|
+
},
|
|
6253
|
+
get validationBehavior() {
|
|
6254
|
+
return getProps().validationBehavior ?? "native";
|
|
6255
|
+
}
|
|
6256
|
+
});
|
|
5080
6257
|
const validate = (value) => {
|
|
5081
|
-
|
|
5082
|
-
formatOptions();
|
|
5083
|
-
const decimalSeparator = formatter().format(1.1).charAt(1);
|
|
5084
|
-
return new RegExp(`^-?\\d*${decimalSeparator === "." ? "\\." : decimalSeparator}?\\d*$`).test(value);
|
|
6258
|
+
return numberParser().isValidPartialNumber(value, getProps().minValue, getProps().maxValue);
|
|
5085
6259
|
};
|
|
5086
6260
|
const setInputValue = (value) => {
|
|
5087
6261
|
ensureInitialized();
|
|
@@ -5091,22 +6265,26 @@ function createNumberFieldState(props) {
|
|
|
5091
6265
|
const commit = () => {
|
|
5092
6266
|
ensureInitialized();
|
|
5093
6267
|
const p = getProps();
|
|
5094
|
-
const input = inputValue
|
|
6268
|
+
const input = readNow(inputValue);
|
|
5095
6269
|
if (input === "" || input === "-") {
|
|
5096
6270
|
setNumberValue(NaN);
|
|
5097
|
-
setInputValueInternal(p.value === void 0 ? "" : formatNumber(actualNumberValue
|
|
6271
|
+
setInputValueInternal(p.value === void 0 ? "" : formatNumber(readNow(actualNumberValue)));
|
|
5098
6272
|
p.onChange?.(NaN);
|
|
6273
|
+
validation.commitValidation();
|
|
5099
6274
|
return;
|
|
5100
6275
|
}
|
|
5101
6276
|
let parsed = parseNumber(input);
|
|
5102
6277
|
if (isNaN(parsed)) {
|
|
5103
|
-
setInputValueInternal(formatNumber(actualNumberValue
|
|
6278
|
+
setInputValueInternal(formatNumber(readNow(actualNumberValue)));
|
|
5104
6279
|
return;
|
|
5105
6280
|
}
|
|
5106
|
-
|
|
6281
|
+
const previous = readNow(actualNumberValue);
|
|
6282
|
+
parsed = constrainForCommit(parsed);
|
|
6283
|
+
parsed = numberParser().parse(formatNumber(parsed));
|
|
5107
6284
|
setNumberValue(parsed);
|
|
5108
6285
|
setInputValueInternal(formatNumber(parsed));
|
|
5109
6286
|
p.onChange?.(parsed);
|
|
6287
|
+
if (parsed !== previous) validation.commitValidation();
|
|
5110
6288
|
};
|
|
5111
6289
|
const canIncrement = createMemo(() => {
|
|
5112
6290
|
ensureInitialized();
|
|
@@ -5143,6 +6321,7 @@ function createNumberFieldState(props) {
|
|
|
5143
6321
|
setNumberValue(current);
|
|
5144
6322
|
setInputValueInternal(formatNumber(current));
|
|
5145
6323
|
p.onChange?.(current);
|
|
6324
|
+
validation.commitValidation();
|
|
5146
6325
|
};
|
|
5147
6326
|
const decrement = () => {
|
|
5148
6327
|
ensureInitialized();
|
|
@@ -5153,6 +6332,7 @@ function createNumberFieldState(props) {
|
|
|
5153
6332
|
setNumberValue(current);
|
|
5154
6333
|
setInputValueInternal(formatNumber(current));
|
|
5155
6334
|
p.onChange?.(current);
|
|
6335
|
+
validation.commitValidation();
|
|
5156
6336
|
};
|
|
5157
6337
|
const incrementToMax = () => {
|
|
5158
6338
|
ensureInitialized();
|
|
@@ -5164,6 +6344,7 @@ function createNumberFieldState(props) {
|
|
|
5164
6344
|
setNumberValue(snapped);
|
|
5165
6345
|
setInputValueInternal(formatNumber(snapped));
|
|
5166
6346
|
p.onChange?.(snapped);
|
|
6347
|
+
validation.commitValidation();
|
|
5167
6348
|
};
|
|
5168
6349
|
const decrementToMin = () => {
|
|
5169
6350
|
ensureInitialized();
|
|
@@ -5174,8 +6355,20 @@ function createNumberFieldState(props) {
|
|
|
5174
6355
|
setNumberValue(p.minValue);
|
|
5175
6356
|
setInputValueInternal(formatNumber(p.minValue));
|
|
5176
6357
|
p.onChange?.(p.minValue);
|
|
6358
|
+
validation.commitValidation();
|
|
6359
|
+
};
|
|
6360
|
+
const setNumberValuePublic = (value) => {
|
|
6361
|
+
ensureInitialized();
|
|
6362
|
+
setNumberValue(value);
|
|
6363
|
+
setInputValueInternal(formatNumber(value));
|
|
6364
|
+
getProps().onChange?.(value);
|
|
5177
6365
|
};
|
|
5178
6366
|
return {
|
|
6367
|
+
realtimeValidation: validation.realtimeValidation,
|
|
6368
|
+
displayValidation: validation.displayValidation,
|
|
6369
|
+
updateValidation: validation.updateValidation,
|
|
6370
|
+
resetValidation: validation.resetValidation,
|
|
6371
|
+
commitValidation: validation.commitValidation,
|
|
5179
6372
|
get inputValue() {
|
|
5180
6373
|
ensureInitialized();
|
|
5181
6374
|
syncControlledValue();
|
|
@@ -5190,6 +6383,12 @@ function createNumberFieldState(props) {
|
|
|
5190
6383
|
isReadOnly: () => getProps().isReadOnly ?? false,
|
|
5191
6384
|
minValue: () => getProps().minValue,
|
|
5192
6385
|
maxValue: () => getProps().maxValue,
|
|
6386
|
+
step: () => getProps().step,
|
|
6387
|
+
get defaultNumberValue() {
|
|
6388
|
+
ensureInitialized();
|
|
6389
|
+
return capturedDefaultNumberValue;
|
|
6390
|
+
},
|
|
6391
|
+
setNumberValue: setNumberValuePublic,
|
|
5193
6392
|
setInputValue,
|
|
5194
6393
|
validate,
|
|
5195
6394
|
commit,
|
|
@@ -5211,7 +6410,7 @@ function createNumberFieldState(props) {
|
|
|
5211
6410
|
function createSearchFieldState(props) {
|
|
5212
6411
|
const getProps = () => access(props);
|
|
5213
6412
|
const isControlled = () => getProps().value !== void 0;
|
|
5214
|
-
const [internalValue, setInternalValue] =
|
|
6413
|
+
const [internalValue, setInternalValue] = createInternalSignal(getProps().defaultValue ?? "");
|
|
5215
6414
|
const value = createMemo(() => {
|
|
5216
6415
|
const p = getProps();
|
|
5217
6416
|
return isControlled() ? p.value ?? "" : internalValue();
|
|
@@ -5265,9 +6464,9 @@ function createSliderState(props) {
|
|
|
5265
6464
|
const isDisabled = createMemo(() => getProps().isDisabled ?? false);
|
|
5266
6465
|
const pageStep = createMemo(() => Math.max(step(), snapToStep((maxValue() - minValue()) / 10, 0, maxValue() - minValue(), step())));
|
|
5267
6466
|
const isControlled = () => getProps().value !== void 0;
|
|
5268
|
-
const [internalValue, setInternalValue] =
|
|
5269
|
-
const [isDragging, setIsDragging] =
|
|
5270
|
-
const [isFocused, setIsFocused] =
|
|
6467
|
+
const [internalValue, setInternalValue] = createInternalSignal(snapToStep(initialProps.defaultValue ?? initialMinValue, initialMinValue, initialMaxValue, initialStep));
|
|
6468
|
+
const [isDragging, setIsDragging] = createInternalSignal(false);
|
|
6469
|
+
const [isFocused, setIsFocused] = createInternalSignal(false);
|
|
5271
6470
|
const value = createMemo(() => {
|
|
5272
6471
|
const p = getProps();
|
|
5273
6472
|
return snapToStep(isControlled() ? p.value ?? minValue() : internalValue(), minValue(), maxValue(), step());
|
|
@@ -5287,7 +6486,8 @@ function createSliderState(props) {
|
|
|
5287
6486
|
p.onChange?.(snappedValue);
|
|
5288
6487
|
};
|
|
5289
6488
|
const setValuePercent = (percent) => {
|
|
5290
|
-
|
|
6489
|
+
const newValue = clamp$1(percent, 0, 1) * (maxValue() - minValue()) + minValue();
|
|
6490
|
+
setValue(newValue);
|
|
5291
6491
|
};
|
|
5292
6492
|
const setDragging = (dragging) => {
|
|
5293
6493
|
const wasDragging = isDragging();
|
|
@@ -5380,26 +6580,31 @@ function createTooltipTriggerState(props = {}) {
|
|
|
5380
6580
|
const closeDelay = () => props.closeDelay ?? TOOLTIP_COOLDOWN;
|
|
5381
6581
|
const overlayState = createOverlayTriggerState(props);
|
|
5382
6582
|
const id = `tooltip-${++tooltipId}`;
|
|
6583
|
+
const [shouldSkipAnimation, setShouldSkipAnimation] = createInternalSignal(false);
|
|
5383
6584
|
let closeTimeout = null;
|
|
5384
|
-
|
|
6585
|
+
let closeFn = overlayState.close;
|
|
5385
6586
|
const ensureTooltipEntry = () => {
|
|
5386
6587
|
tooltips[id] = hideTooltip;
|
|
5387
6588
|
};
|
|
5388
6589
|
const closeOpenTooltips = () => {
|
|
5389
6590
|
for (const hideTooltipId in tooltips) if (hideTooltipId !== id) {
|
|
5390
|
-
tooltips[hideTooltipId](true);
|
|
6591
|
+
tooltips[hideTooltipId](true, true);
|
|
5391
6592
|
delete tooltips[hideTooltipId];
|
|
5392
6593
|
}
|
|
5393
6594
|
};
|
|
5394
|
-
const showTooltip = () => {
|
|
6595
|
+
const showTooltip = (instant) => {
|
|
5395
6596
|
if (closeTimeout) {
|
|
5396
6597
|
clearTimeout(closeTimeout);
|
|
5397
6598
|
closeTimeout = null;
|
|
5398
6599
|
}
|
|
5399
6600
|
closeOpenTooltips();
|
|
5400
6601
|
ensureTooltipEntry();
|
|
6602
|
+
setShouldSkipAnimation(!!instant);
|
|
5401
6603
|
globalWarmedUp = true;
|
|
5402
6604
|
overlayState.open();
|
|
6605
|
+
try {
|
|
6606
|
+
flush();
|
|
6607
|
+
} catch {}
|
|
5403
6608
|
if (globalWarmUpTimeout) {
|
|
5404
6609
|
clearTimeout(globalWarmUpTimeout);
|
|
5405
6610
|
globalWarmUpTimeout = null;
|
|
@@ -5409,16 +6614,17 @@ function createTooltipTriggerState(props = {}) {
|
|
|
5409
6614
|
globalCooldownTimeout = null;
|
|
5410
6615
|
}
|
|
5411
6616
|
};
|
|
5412
|
-
const hideTooltip = (immediate) => {
|
|
6617
|
+
const hideTooltip = (immediate, instant) => {
|
|
6618
|
+
setShouldSkipAnimation(!!instant);
|
|
5413
6619
|
if (immediate || closeDelay() <= 0) {
|
|
5414
6620
|
if (closeTimeout) {
|
|
5415
6621
|
clearTimeout(closeTimeout);
|
|
5416
6622
|
closeTimeout = null;
|
|
5417
6623
|
}
|
|
5418
|
-
|
|
6624
|
+
closeFn();
|
|
5419
6625
|
} else if (!closeTimeout) closeTimeout = setTimeout(() => {
|
|
5420
6626
|
closeTimeout = null;
|
|
5421
|
-
|
|
6627
|
+
closeFn();
|
|
5422
6628
|
}, closeDelay());
|
|
5423
6629
|
if (globalWarmUpTimeout) {
|
|
5424
6630
|
clearTimeout(globalWarmUpTimeout);
|
|
@@ -5439,21 +6645,22 @@ function createTooltipTriggerState(props = {}) {
|
|
|
5439
6645
|
if (!overlayState.isOpen() && !globalWarmUpTimeout && !globalWarmedUp) globalWarmUpTimeout = setTimeout(() => {
|
|
5440
6646
|
globalWarmUpTimeout = null;
|
|
5441
6647
|
globalWarmedUp = true;
|
|
5442
|
-
showTooltip();
|
|
6648
|
+
showTooltip(false);
|
|
5443
6649
|
}, delay());
|
|
5444
|
-
else if (!overlayState.isOpen()) showTooltip();
|
|
6650
|
+
else if (!overlayState.isOpen()) showTooltip(true);
|
|
5445
6651
|
};
|
|
5446
|
-
|
|
6652
|
+
closeFn = overlayState.close;
|
|
5447
6653
|
onCleanup(() => {
|
|
5448
6654
|
if (closeTimeout) clearTimeout(closeTimeout);
|
|
5449
6655
|
if (tooltips[id]) delete tooltips[id];
|
|
5450
6656
|
});
|
|
5451
6657
|
return {
|
|
5452
6658
|
isOpen: overlayState.isOpen,
|
|
6659
|
+
shouldSkipAnimation,
|
|
5453
6660
|
open: (immediate) => {
|
|
5454
6661
|
if (isServer) return;
|
|
5455
6662
|
if (!immediate && delay() > 0 && !closeTimeout) warmupTooltip();
|
|
5456
|
-
else showTooltip();
|
|
6663
|
+
else showTooltip(true);
|
|
5457
6664
|
},
|
|
5458
6665
|
close: hideTooltip
|
|
5459
6666
|
};
|
|
@@ -5652,15 +6859,18 @@ var ToastQueue = class {
|
|
|
5652
6859
|
* Use this hook to subscribe to toast changes in your component.
|
|
5653
6860
|
*/
|
|
5654
6861
|
function createToastState(props) {
|
|
5655
|
-
const [visibleToasts, setVisibleToasts] =
|
|
6862
|
+
const [visibleToasts, setVisibleToasts] = createInternalSignal([]);
|
|
5656
6863
|
const unsubscribe = props.queue.subscribe((toasts) => {
|
|
5657
6864
|
setVisibleToasts(toasts);
|
|
6865
|
+
try {
|
|
6866
|
+
flush();
|
|
6867
|
+
} catch {}
|
|
5658
6868
|
});
|
|
5659
6869
|
onCleanup(() => {
|
|
5660
6870
|
unsubscribe();
|
|
5661
6871
|
});
|
|
5662
6872
|
return {
|
|
5663
|
-
visibleToasts,
|
|
6873
|
+
visibleToasts: () => readNow(visibleToasts),
|
|
5664
6874
|
add: (content, options) => props.queue.add(content, options),
|
|
5665
6875
|
close: (key) => props.queue.close(key),
|
|
5666
6876
|
remove: (key) => props.queue.remove(key),
|
|
@@ -5692,7 +6902,7 @@ function createToastQueue(options) {
|
|
|
5692
6902
|
*/
|
|
5693
6903
|
function createDisclosureState(props = {}) {
|
|
5694
6904
|
const propsAccessor = () => access(props);
|
|
5695
|
-
const [internalExpanded, setInternalExpanded] =
|
|
6905
|
+
const [internalExpanded, setInternalExpanded] = createInternalSignal(propsAccessor().defaultExpanded ?? false);
|
|
5696
6906
|
const isExpanded = () => {
|
|
5697
6907
|
const p = propsAccessor();
|
|
5698
6908
|
return p.isExpanded !== void 0 ? p.isExpanded : internalExpanded();
|
|
@@ -5719,7 +6929,7 @@ function createDisclosureState(props = {}) {
|
|
|
5719
6929
|
*/
|
|
5720
6930
|
function createDisclosureGroupState(props = {}) {
|
|
5721
6931
|
const propsAccessor = () => access(props);
|
|
5722
|
-
const [internalKeys, setInternalKeys] =
|
|
6932
|
+
const [internalKeys, setInternalKeys] = createInternalSignal(new Set(propsAccessor().defaultExpandedKeys ?? []));
|
|
5723
6933
|
const expandedKeys = createMemo(() => {
|
|
5724
6934
|
const p = propsAccessor();
|
|
5725
6935
|
return p.expandedKeys !== void 0 ? new Set(p.expandedKeys) : internalKeys();
|
|
@@ -5730,18 +6940,22 @@ function createDisclosureGroupState(props = {}) {
|
|
|
5730
6940
|
p.onExpandedChange?.(keys);
|
|
5731
6941
|
};
|
|
5732
6942
|
createEffect(() => {
|
|
5733
|
-
|
|
5734
|
-
|
|
6943
|
+
return {
|
|
6944
|
+
allowsMultiple: propsAccessor().allowsMultipleExpanded ?? false,
|
|
6945
|
+
keys: expandedKeys()
|
|
6946
|
+
};
|
|
6947
|
+
}, ({ allowsMultiple, keys }) => {
|
|
5735
6948
|
if (!allowsMultiple && keys.size > 1) {
|
|
5736
6949
|
const firstKey = keys.values().next().value;
|
|
5737
6950
|
if (firstKey != null) queueMicrotask(() => {
|
|
5738
|
-
setExpandedKeys(new Set([firstKey]));
|
|
6951
|
+
setExpandedKeys(/* @__PURE__ */ new Set([firstKey]));
|
|
5739
6952
|
});
|
|
5740
6953
|
}
|
|
5741
6954
|
});
|
|
5742
6955
|
const toggleKey = (key) => {
|
|
5743
|
-
const
|
|
5744
|
-
const
|
|
6956
|
+
const p = propsAccessor();
|
|
6957
|
+
const allowsMultiple = p.allowsMultipleExpanded ?? false;
|
|
6958
|
+
const currentKeys = p.expandedKeys !== void 0 ? expandedKeys() : readNow(internalKeys);
|
|
5745
6959
|
let newKeys;
|
|
5746
6960
|
if (allowsMultiple) {
|
|
5747
6961
|
newKeys = new Set(currentKeys);
|
|
@@ -5770,7 +6984,7 @@ function createDisclosureGroupState(props = {}) {
|
|
|
5770
6984
|
//#region src/grid/createGridState.ts
|
|
5771
6985
|
/**
|
|
5772
6986
|
* Grid state management for Table and GridList components.
|
|
5773
|
-
* Based on
|
|
6987
|
+
* Based on packages/react-stately/src/grid/useGridState.ts.
|
|
5774
6988
|
*/
|
|
5775
6989
|
/**
|
|
5776
6990
|
* Creates state management for a grid component.
|
|
@@ -5782,30 +6996,33 @@ function createGridState(options) {
|
|
|
5782
6996
|
const keys = getOptions().disabledKeys;
|
|
5783
6997
|
return keys ? new Set(keys) : /* @__PURE__ */ new Set();
|
|
5784
6998
|
});
|
|
5785
|
-
const [isFocused, setIsFocused] =
|
|
5786
|
-
const [focusedKey, setFocusedKeyInternal] =
|
|
5787
|
-
const [childFocusStrategy, setChildFocusStrategy] =
|
|
5788
|
-
const [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] =
|
|
5789
|
-
const [internalSelectedKeys, setInternalSelectedKeys] =
|
|
5790
|
-
const [anchorKey, setAnchorKey] =
|
|
5791
|
-
const selectedKeys =
|
|
6999
|
+
const [isFocused, setIsFocused] = createInternalSignal(false);
|
|
7000
|
+
const [focusedKey, setFocusedKeyInternal] = createInternalSignal(null);
|
|
7001
|
+
const [childFocusStrategy, setChildFocusStrategy] = createInternalSignal(null);
|
|
7002
|
+
const [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = createInternalSignal(false);
|
|
7003
|
+
const [internalSelectedKeys, setInternalSelectedKeys] = createInternalSignal(getInitialSelection$1(getOptions().defaultSelectedKeys));
|
|
7004
|
+
const [anchorKey, setAnchorKey] = createInternalSignal(null);
|
|
7005
|
+
const selectedKeys = () => {
|
|
5792
7006
|
const opts = getOptions();
|
|
5793
7007
|
if (opts.selectedKeys !== void 0) return normalizeSelection$1(opts.selectedKeys);
|
|
5794
7008
|
return internalSelectedKeys();
|
|
5795
|
-
}
|
|
7009
|
+
};
|
|
5796
7010
|
const selectionMode = createMemo(() => getOptions().selectionMode ?? "none");
|
|
5797
7011
|
const selectionBehaviorProp = () => getOptions().selectionBehavior ?? "toggle";
|
|
5798
|
-
const [selectionBehaviorState, setSelectionBehaviorState] =
|
|
7012
|
+
const [selectionBehaviorState, setSelectionBehaviorState] = createInternalSignal(selectionBehaviorProp());
|
|
5799
7013
|
const selectionBehavior = createMemo(() => selectionBehaviorState());
|
|
5800
7014
|
const disallowEmptySelection = createMemo(() => getOptions().disallowEmptySelection ?? false);
|
|
5801
7015
|
const disabledBehavior = createMemo(() => getOptions().disabledBehavior ?? "all");
|
|
5802
7016
|
const focusMode = createMemo(() => getOptions().focusMode ?? "row");
|
|
5803
|
-
createEffect(
|
|
7017
|
+
createEffect(selectionBehaviorProp, (behavior) => {
|
|
5804
7018
|
setSelectionBehaviorState(behavior);
|
|
5805
|
-
})
|
|
5806
|
-
createEffect(() => {
|
|
5807
|
-
|
|
5808
|
-
|
|
7019
|
+
});
|
|
7020
|
+
createEffect(() => ({
|
|
7021
|
+
prop: selectionBehaviorProp(),
|
|
7022
|
+
state: selectionBehaviorState(),
|
|
7023
|
+
keys: selectedKeys()
|
|
7024
|
+
}), ({ prop, state, keys }) => {
|
|
7025
|
+
if (prop === "replace" && state === "toggle" && keys !== "all" && keys.size === 0) setSelectionBehaviorState("replace");
|
|
5809
7026
|
});
|
|
5810
7027
|
const setFocusedKey = (key, strategy = "first") => {
|
|
5811
7028
|
const collection = getOptions().collection;
|
|
@@ -5819,9 +7036,12 @@ function createGridState(options) {
|
|
|
5819
7036
|
setFocusedKeyInternal(key);
|
|
5820
7037
|
setChildFocusStrategy(strategy);
|
|
5821
7038
|
};
|
|
5822
|
-
let cachedCollection =
|
|
5823
|
-
createEffect(
|
|
5824
|
-
|
|
7039
|
+
let cachedCollection = getOptions().collection;
|
|
7040
|
+
createEffect(() => ({
|
|
7041
|
+
collection: getOptions().collection,
|
|
7042
|
+
currentFocusedKey: focusedKey(),
|
|
7043
|
+
disabled: disabledKeys()
|
|
7044
|
+
}), ({ collection, currentFocusedKey, disabled }) => {
|
|
5825
7045
|
if (currentFocusedKey != null && cachedCollection && !collection.getItem(currentFocusedKey)) {
|
|
5826
7046
|
const node = cachedCollection.getItem(currentFocusedKey);
|
|
5827
7047
|
const parentNode = node?.parentKey != null && (node.type === "cell" || node.type === "rowheader" || node.type === "column") ? cachedCollection.getItem(node.parentKey) : node;
|
|
@@ -5835,29 +7055,60 @@ function createGridState(options) {
|
|
|
5835
7055
|
const diff = cachedRows.length - rows.length;
|
|
5836
7056
|
let index = Math.min(diff > 1 ? Math.max(parentNode.index - diff + 1, 0) : parentNode.index, rows.length - 1);
|
|
5837
7057
|
let newRow = null;
|
|
5838
|
-
|
|
5839
|
-
const row = rows[
|
|
5840
|
-
if (!
|
|
7058
|
+
for (let i = Math.max(0, index); i < rows.length; i++) {
|
|
7059
|
+
const row = rows[i];
|
|
7060
|
+
if (!disabled.has(row.key) && row.type !== "headerrow") {
|
|
5841
7061
|
newRow = row;
|
|
5842
7062
|
break;
|
|
5843
7063
|
}
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
7064
|
+
}
|
|
7065
|
+
if (newRow === null) for (let i = index - 1; i >= 0; i--) {
|
|
7066
|
+
const row = rows[i];
|
|
7067
|
+
if (!disabled.has(row.key) && row.type !== "headerrow") {
|
|
7068
|
+
newRow = row;
|
|
7069
|
+
break;
|
|
5848
7070
|
}
|
|
5849
7071
|
}
|
|
5850
7072
|
if (newRow) {
|
|
5851
7073
|
const childNodes = newRow.hasChildNodes ? [...collection.getChildren(newRow.key)] : [];
|
|
5852
|
-
|
|
7074
|
+
const keyToFocus = newRow.hasChildNodes && parentNode !== node && node && node.index < childNodes.length ? childNodes[node.index].key : newRow.key;
|
|
7075
|
+
setFocusedKeyInternal(keyToFocus);
|
|
5853
7076
|
} else setFocusedKeyInternal(null);
|
|
5854
7077
|
}
|
|
5855
7078
|
cachedCollection = collection;
|
|
5856
|
-
})
|
|
5857
|
-
const
|
|
7079
|
+
});
|
|
7080
|
+
const getSelectionKey = (key) => {
|
|
7081
|
+
const collection = getOptions().collection;
|
|
7082
|
+
let item = collection.getItem(key);
|
|
7083
|
+
if (!item) return key;
|
|
7084
|
+
while (item && item.type !== "item" && item.parentKey != null) item = collection.getItem(item.parentKey);
|
|
7085
|
+
return item?.type === "item" ? item.key : null;
|
|
7086
|
+
};
|
|
7087
|
+
const canSelectItem = (key) => {
|
|
7088
|
+
if (selectionMode() === "none" || disabledKeys().has(key)) return false;
|
|
7089
|
+
const item = getOptions().collection.getItem(key);
|
|
7090
|
+
return !!item && item.type === "item" && !item.isDisabled && !item.props?.isDisabled;
|
|
7091
|
+
};
|
|
7092
|
+
const getSelectAllKeys = () => {
|
|
7093
|
+
return getOptions().collection.rows.filter((row) => row.type === "item" && canSelectItem(row.key)).map((row) => row.key);
|
|
7094
|
+
};
|
|
7095
|
+
const isEmpty = createMemo(() => {
|
|
7096
|
+
const keys = selectedKeys();
|
|
7097
|
+
return keys !== "all" && keys.size === 0;
|
|
7098
|
+
});
|
|
7099
|
+
const isSelectAll = createMemo(() => {
|
|
5858
7100
|
const keys = selectedKeys();
|
|
7101
|
+
if (isEmpty()) return false;
|
|
5859
7102
|
if (keys === "all") return true;
|
|
5860
|
-
return keys.has(key);
|
|
7103
|
+
return getSelectAllKeys().every((key) => keys.has(key));
|
|
7104
|
+
});
|
|
7105
|
+
const isSelected = (key) => {
|
|
7106
|
+
if (selectionMode() === "none") return false;
|
|
7107
|
+
const selectionKey = getSelectionKey(key);
|
|
7108
|
+
if (selectionKey == null) return false;
|
|
7109
|
+
const keys = selectedKeys();
|
|
7110
|
+
if (keys === "all") return canSelectItem(selectionKey);
|
|
7111
|
+
return keys.has(selectionKey);
|
|
5861
7112
|
};
|
|
5862
7113
|
const isDisabled = (key) => {
|
|
5863
7114
|
return disabledKeys().has(key);
|
|
@@ -5875,30 +7126,44 @@ function createGridState(options) {
|
|
|
5875
7126
|
}
|
|
5876
7127
|
};
|
|
5877
7128
|
const toggleSelection = (key) => {
|
|
5878
|
-
if (isDisabled(key)) return;
|
|
5879
7129
|
if (selectionMode() === "none") return;
|
|
7130
|
+
const selectionKey = getSelectionKey(key);
|
|
7131
|
+
if (selectionKey == null) return;
|
|
5880
7132
|
const current = selectedKeys();
|
|
5881
7133
|
if (selectionMode() === "single") {
|
|
5882
|
-
if (isSelected(
|
|
5883
|
-
else updateSelection(new Set([
|
|
7134
|
+
if (isSelected(selectionKey) && !disallowEmptySelection()) updateSelection(/* @__PURE__ */ new Set());
|
|
7135
|
+
else if (canSelectItem(selectionKey)) updateSelection(/* @__PURE__ */ new Set([selectionKey]));
|
|
5884
7136
|
return;
|
|
5885
7137
|
}
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
} else newSelection.add(key);
|
|
7138
|
+
const newSelection = new Set(current === "all" ? getSelectAllKeys() : current);
|
|
7139
|
+
if (newSelection.has(selectionKey)) {
|
|
7140
|
+
if (newSelection.size > 1 || !disallowEmptySelection()) newSelection.delete(selectionKey);
|
|
7141
|
+
} else if (canSelectItem(selectionKey)) newSelection.add(selectionKey);
|
|
5891
7142
|
updateSelection(newSelection);
|
|
5892
|
-
setAnchorKey(
|
|
7143
|
+
setAnchorKey(selectionKey);
|
|
5893
7144
|
};
|
|
5894
7145
|
const replaceSelection = (key) => {
|
|
5895
|
-
if (isDisabled(key)) return;
|
|
5896
7146
|
if (selectionMode() === "none") return;
|
|
5897
|
-
|
|
5898
|
-
|
|
7147
|
+
const selectionKey = getSelectionKey(key);
|
|
7148
|
+
if (selectionKey == null) return;
|
|
7149
|
+
updateSelection(canSelectItem(selectionKey) ? /* @__PURE__ */ new Set([selectionKey]) : /* @__PURE__ */ new Set());
|
|
7150
|
+
setAnchorKey(selectionKey);
|
|
5899
7151
|
};
|
|
5900
7152
|
const setSelectedKeys = (keys) => {
|
|
5901
|
-
|
|
7153
|
+
if (selectionMode() === "none") return;
|
|
7154
|
+
if (keys === "all") {
|
|
7155
|
+
updateSelection("all");
|
|
7156
|
+
return;
|
|
7157
|
+
}
|
|
7158
|
+
const selection = /* @__PURE__ */ new Set();
|
|
7159
|
+
for (const key of keys) {
|
|
7160
|
+
const selectionKey = getSelectionKey(key);
|
|
7161
|
+
if (selectionKey != null) {
|
|
7162
|
+
selection.add(selectionKey);
|
|
7163
|
+
if (selectionMode() === "single") break;
|
|
7164
|
+
}
|
|
7165
|
+
}
|
|
7166
|
+
updateSelection(selection);
|
|
5902
7167
|
};
|
|
5903
7168
|
const extendSelection = (toKey) => {
|
|
5904
7169
|
if (isDisabled(toKey)) return;
|
|
@@ -5906,7 +7171,7 @@ function createGridState(options) {
|
|
|
5906
7171
|
replaceSelection(toKey);
|
|
5907
7172
|
return;
|
|
5908
7173
|
}
|
|
5909
|
-
const anchor = anchorKey();
|
|
7174
|
+
const anchor = anchorKey() ?? focusedKey();
|
|
5910
7175
|
if (!anchor) {
|
|
5911
7176
|
replaceSelection(toKey);
|
|
5912
7177
|
return;
|
|
@@ -5925,7 +7190,7 @@ function createGridState(options) {
|
|
|
5925
7190
|
};
|
|
5926
7191
|
const selectAll = () => {
|
|
5927
7192
|
if (selectionMode() !== "multiple") return;
|
|
5928
|
-
updateSelection("all");
|
|
7193
|
+
if (!isSelectAll()) updateSelection("all");
|
|
5929
7194
|
};
|
|
5930
7195
|
const clearSelection = () => {
|
|
5931
7196
|
if (disallowEmptySelection()) return;
|
|
@@ -5933,7 +7198,7 @@ function createGridState(options) {
|
|
|
5933
7198
|
};
|
|
5934
7199
|
const toggleSelectAll = () => {
|
|
5935
7200
|
if (selectionMode() !== "multiple") return;
|
|
5936
|
-
if (
|
|
7201
|
+
if (isSelectAll()) clearSelection();
|
|
5937
7202
|
else selectAll();
|
|
5938
7203
|
};
|
|
5939
7204
|
return {
|
|
@@ -5970,6 +7235,12 @@ function createGridState(options) {
|
|
|
5970
7235
|
get selectedKeys() {
|
|
5971
7236
|
return selectedKeys();
|
|
5972
7237
|
},
|
|
7238
|
+
get isEmpty() {
|
|
7239
|
+
return isEmpty();
|
|
7240
|
+
},
|
|
7241
|
+
get isSelectAll() {
|
|
7242
|
+
return isSelectAll();
|
|
7243
|
+
},
|
|
5973
7244
|
isSelected,
|
|
5974
7245
|
isDisabled,
|
|
5975
7246
|
setFocusedKey,
|
|
@@ -6073,6 +7344,12 @@ function createTableState(options) {
|
|
|
6073
7344
|
get selectedKeys() {
|
|
6074
7345
|
return gridState.selectedKeys;
|
|
6075
7346
|
},
|
|
7347
|
+
get isEmpty() {
|
|
7348
|
+
return gridState.isEmpty;
|
|
7349
|
+
},
|
|
7350
|
+
get isSelectAll() {
|
|
7351
|
+
return gridState.isSelectAll;
|
|
7352
|
+
},
|
|
6076
7353
|
isSelected: gridState.isSelected,
|
|
6077
7354
|
isDisabled: gridState.isDisabled,
|
|
6078
7355
|
setFocusedKey: gridState.setFocusedKey,
|
|
@@ -6229,7 +7506,7 @@ var TableCollection = class {
|
|
|
6229
7506
|
return !!(col.props?.columnDefinition)?.isRowHeader;
|
|
6230
7507
|
}).map((col) => col.key);
|
|
6231
7508
|
if (explicitRowHeaderKeys.length > 0) return new Set(explicitRowHeaderKeys);
|
|
6232
|
-
for (const col of this._columns) if (col.key !== "__selection__") return new Set([col.key]);
|
|
7509
|
+
for (const col of this._columns) if (col.key !== "__selection__") return /* @__PURE__ */ new Set([col.key]);
|
|
6233
7510
|
return /* @__PURE__ */ new Set();
|
|
6234
7511
|
}
|
|
6235
7512
|
/** Counts the leaf columns supplied by the user (excludes the selection column). */
|
|
@@ -6483,12 +7760,12 @@ function createTableCollection(options) {
|
|
|
6483
7760
|
*/
|
|
6484
7761
|
function createTreeGridState(options) {
|
|
6485
7762
|
const getOptions = () => options();
|
|
6486
|
-
const [internalExpandedKeys, setInternalExpandedKeys] =
|
|
6487
|
-
const expandedKeys =
|
|
7763
|
+
const [internalExpandedKeys, setInternalExpandedKeys] = createInternalSignal(getInitialExpanded(getOptions().UNSTABLE_defaultExpandedKeys));
|
|
7764
|
+
const expandedKeys = () => {
|
|
6488
7765
|
const controlled = getOptions().UNSTABLE_expandedKeys;
|
|
6489
7766
|
if (controlled !== void 0) return convertExpanded(controlled);
|
|
6490
7767
|
return internalExpandedKeys();
|
|
6491
|
-
}
|
|
7768
|
+
};
|
|
6492
7769
|
const collection = createMemo(() => createTableCollection({
|
|
6493
7770
|
columns: getOptions().columns,
|
|
6494
7771
|
rows: getOptions().rows,
|
|
@@ -6661,8 +7938,8 @@ function distributeWidths(columns, tableWidth) {
|
|
|
6661
7938
|
function createTableColumnResizeState(props) {
|
|
6662
7939
|
const getProps = () => props();
|
|
6663
7940
|
const initialWidths = createMemo(() => distributeWidths(getProps().columns, getProps().tableWidth));
|
|
6664
|
-
const [overrides, setOverrides] =
|
|
6665
|
-
const [resizingColumn, setResizingColumn] =
|
|
7941
|
+
const [overrides, setOverrides] = createInternalSignal(/* @__PURE__ */ new Map());
|
|
7942
|
+
const [resizingColumn, setResizingColumn] = createInternalSignal(null);
|
|
6666
7943
|
const columnWidths = createMemo(() => {
|
|
6667
7944
|
const base = initialWidths();
|
|
6668
7945
|
const over = overrides();
|
|
@@ -6737,44 +8014,52 @@ function createTreeState(options) {
|
|
|
6737
8014
|
const keys = getOptions().disabledKeys;
|
|
6738
8015
|
return keys ? new Set(keys) : /* @__PURE__ */ new Set();
|
|
6739
8016
|
});
|
|
6740
|
-
const [internalExpandedKeys, setInternalExpandedKeys] =
|
|
6741
|
-
const expandedKeys =
|
|
8017
|
+
const [internalExpandedKeys, setInternalExpandedKeys] = createInternalSignal(getInitialExpandedKeys(getOptions().defaultExpandedKeys));
|
|
8018
|
+
const expandedKeys = () => {
|
|
6742
8019
|
const opts = getOptions();
|
|
6743
8020
|
if (opts.expandedKeys !== void 0) return new Set(opts.expandedKeys);
|
|
6744
8021
|
return internalExpandedKeys();
|
|
6745
|
-
}
|
|
8022
|
+
};
|
|
6746
8023
|
const collection = createMemo(() => {
|
|
6747
8024
|
return getOptions().collectionFactory(expandedKeys());
|
|
6748
8025
|
});
|
|
6749
|
-
const [isFocused, setIsFocused] =
|
|
6750
|
-
const [focusedKey, setFocusedKeyInternal] =
|
|
6751
|
-
const [childFocusStrategy, setChildFocusStrategy] =
|
|
6752
|
-
const [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] =
|
|
6753
|
-
const [internalSelectedKeys, setInternalSelectedKeys] =
|
|
6754
|
-
const [anchorKey, setAnchorKey] =
|
|
6755
|
-
const selectedKeys =
|
|
8026
|
+
const [isFocused, setIsFocused] = createInternalSignal(false);
|
|
8027
|
+
const [focusedKey, setFocusedKeyInternal] = createInternalSignal(null);
|
|
8028
|
+
const [childFocusStrategy, setChildFocusStrategy] = createInternalSignal(null);
|
|
8029
|
+
const [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = createInternalSignal(false);
|
|
8030
|
+
const [internalSelectedKeys, setInternalSelectedKeys] = createInternalSignal(getInitialSelection(getOptions().defaultSelectedKeys));
|
|
8031
|
+
const [anchorKey, setAnchorKey] = createInternalSignal(null);
|
|
8032
|
+
const selectedKeys = () => {
|
|
6756
8033
|
const opts = getOptions();
|
|
6757
8034
|
if (opts.selectedKeys !== void 0) return normalizeSelection(opts.selectedKeys);
|
|
6758
8035
|
return internalSelectedKeys();
|
|
6759
|
-
}
|
|
8036
|
+
};
|
|
6760
8037
|
const selectionMode = createMemo(() => getOptions().selectionMode ?? "none");
|
|
6761
8038
|
const selectionBehaviorProp = () => getOptions().selectionBehavior ?? "toggle";
|
|
6762
|
-
const [selectionBehaviorState, setSelectionBehaviorState] =
|
|
8039
|
+
const [selectionBehaviorState, setSelectionBehaviorState] = createInternalSignal(selectionBehaviorProp());
|
|
6763
8040
|
const selectionBehavior = createMemo(() => selectionBehaviorState());
|
|
6764
8041
|
const disallowEmptySelection = createMemo(() => getOptions().disallowEmptySelection ?? false);
|
|
6765
8042
|
const disabledBehavior = createMemo(() => getOptions().disabledBehavior ?? "all");
|
|
6766
|
-
createEffect(
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
8043
|
+
createEffect(selectionBehaviorProp, (behavior) => {
|
|
8044
|
+
setSelectionBehaviorState(behavior);
|
|
8045
|
+
});
|
|
8046
|
+
createEffect(() => ({
|
|
8047
|
+
prop: selectionBehaviorProp(),
|
|
8048
|
+
state: selectionBehaviorState(),
|
|
8049
|
+
keys: selectedKeys()
|
|
8050
|
+
}), ({ prop, state, keys }) => {
|
|
8051
|
+
if (prop === "replace" && state === "toggle" && keys !== "all" && keys.size === 0) setSelectionBehaviorState("replace");
|
|
6770
8052
|
});
|
|
6771
8053
|
const setFocusedKey = (key, strategy = "first") => {
|
|
6772
8054
|
setFocusedKeyInternal(key);
|
|
6773
8055
|
setChildFocusStrategy(strategy);
|
|
6774
8056
|
};
|
|
6775
|
-
let cachedCollection =
|
|
6776
|
-
createEffect(
|
|
6777
|
-
|
|
8057
|
+
let cachedCollection = collection();
|
|
8058
|
+
createEffect(() => ({
|
|
8059
|
+
coll: collection(),
|
|
8060
|
+
currentFocusedKey: focusedKey(),
|
|
8061
|
+
disabled: disabledKeys()
|
|
8062
|
+
}), ({ coll, currentFocusedKey, disabled }) => {
|
|
6778
8063
|
if (currentFocusedKey != null && cachedCollection) {
|
|
6779
8064
|
const visibleKeys = [...coll.getKeys()];
|
|
6780
8065
|
if (!visibleKeys.includes(currentFocusedKey)) {
|
|
@@ -6792,13 +8077,13 @@ function createTreeState(options) {
|
|
|
6792
8077
|
const cachedNode = cachedCollection.getItem(currentFocusedKey);
|
|
6793
8078
|
if (cachedNode?.rowIndex !== void 0) {
|
|
6794
8079
|
const newNode = rows[Math.min(cachedNode.rowIndex, rows.length - 1)];
|
|
6795
|
-
if (newNode && !
|
|
8080
|
+
if (newNode && !disabled.has(newNode.key)) {
|
|
6796
8081
|
setFocusedKeyInternal(newNode.key);
|
|
6797
8082
|
cachedCollection = coll;
|
|
6798
8083
|
return;
|
|
6799
8084
|
}
|
|
6800
8085
|
}
|
|
6801
|
-
for (const row of rows) if (!
|
|
8086
|
+
for (const row of rows) if (!disabled.has(row.key)) {
|
|
6802
8087
|
setFocusedKeyInternal(row.key);
|
|
6803
8088
|
break;
|
|
6804
8089
|
}
|
|
@@ -6806,7 +8091,7 @@ function createTreeState(options) {
|
|
|
6806
8091
|
}
|
|
6807
8092
|
}
|
|
6808
8093
|
cachedCollection = coll;
|
|
6809
|
-
})
|
|
8094
|
+
});
|
|
6810
8095
|
const isSelected = (key) => {
|
|
6811
8096
|
const keys = selectedKeys();
|
|
6812
8097
|
if (keys === "all") return true;
|
|
@@ -6836,7 +8121,7 @@ function createTreeState(options) {
|
|
|
6836
8121
|
const current = selectedKeys();
|
|
6837
8122
|
if (selectionMode() === "single") {
|
|
6838
8123
|
if (isSelected(key) && !disallowEmptySelection()) updateSelection(/* @__PURE__ */ new Set());
|
|
6839
|
-
else updateSelection(new Set([key]));
|
|
8124
|
+
else updateSelection(/* @__PURE__ */ new Set([key]));
|
|
6840
8125
|
return;
|
|
6841
8126
|
}
|
|
6842
8127
|
if (current === "all") return;
|
|
@@ -6850,7 +8135,7 @@ function createTreeState(options) {
|
|
|
6850
8135
|
const replaceSelection = (key) => {
|
|
6851
8136
|
if (isDisabled(key)) return;
|
|
6852
8137
|
if (selectionMode() === "none") return;
|
|
6853
|
-
updateSelection(new Set([key]));
|
|
8138
|
+
updateSelection(/* @__PURE__ */ new Set([key]));
|
|
6854
8139
|
setAnchorKey(key);
|
|
6855
8140
|
};
|
|
6856
8141
|
const setSelectedKeys = (keys) => {
|
|
@@ -6862,7 +8147,7 @@ function createTreeState(options) {
|
|
|
6862
8147
|
replaceSelection(toKey);
|
|
6863
8148
|
return;
|
|
6864
8149
|
}
|
|
6865
|
-
const anchor = anchorKey();
|
|
8150
|
+
const anchor = anchorKey() ?? focusedKey();
|
|
6866
8151
|
if (!anchor) {
|
|
6867
8152
|
replaceSelection(toKey);
|
|
6868
8153
|
return;
|
|
@@ -8544,6 +9829,14 @@ function clamp(value, min, max) {
|
|
|
8544
9829
|
return Math.min(Math.max(value, min), max);
|
|
8545
9830
|
}
|
|
8546
9831
|
/**
|
|
9832
|
+
* Normalizes a hue value to [0, 360).
|
|
9833
|
+
* Preserves 360 so linear hue sliders can reach the end of their track.
|
|
9834
|
+
*/
|
|
9835
|
+
function normalizeHue(hue) {
|
|
9836
|
+
if (hue === 360) return hue;
|
|
9837
|
+
return (hue % 360 + 360) % 360;
|
|
9838
|
+
}
|
|
9839
|
+
/**
|
|
8547
9840
|
* Round to fixed decimal places.
|
|
8548
9841
|
*/
|
|
8549
9842
|
function toFixed(value, decimals) {
|
|
@@ -8571,9 +9864,7 @@ function rgbToHsl(r, g, b) {
|
|
|
8571
9864
|
case g:
|
|
8572
9865
|
h = ((b - r) / d + 2) / 6;
|
|
8573
9866
|
break;
|
|
8574
|
-
case b:
|
|
8575
|
-
h = ((r - g) / d + 4) / 6;
|
|
8576
|
-
break;
|
|
9867
|
+
case b: h = ((r - g) / d + 4) / 6;
|
|
8577
9868
|
}
|
|
8578
9869
|
}
|
|
8579
9870
|
return {
|
|
@@ -8622,9 +9913,7 @@ function rgbToHsb(r, g, b) {
|
|
|
8622
9913
|
case g:
|
|
8623
9914
|
h = ((b - r) / d + 2) / 6;
|
|
8624
9915
|
break;
|
|
8625
|
-
case b:
|
|
8626
|
-
h = ((r - g) / d + 4) / 6;
|
|
8627
|
-
break;
|
|
9916
|
+
case b: h = ((r - g) / d + 4) / 6;
|
|
8628
9917
|
}
|
|
8629
9918
|
return {
|
|
8630
9919
|
h: toFixed(h * 360, 2),
|
|
@@ -8656,8 +9945,10 @@ function getOklchHueName(l, c, h, locale) {
|
|
|
8656
9945
|
let [hue, hueName] = OKLCH_HUES[i];
|
|
8657
9946
|
const [nextHue, nextHueName] = OKLCH_HUES[i + 1] || [360, "pink"];
|
|
8658
9947
|
if (h >= hue && h < nextHue) {
|
|
8659
|
-
if (hueName === "orange")
|
|
8660
|
-
|
|
9948
|
+
if (hueName === "orange") {
|
|
9949
|
+
if (l < ORANGE_LIGHTNESS_THRESHOLD) hueName = "brown";
|
|
9950
|
+
else l = l - ORANGE_LIGHTNESS_THRESHOLD + MAX_DARK_LIGHTNESS;
|
|
9951
|
+
}
|
|
8661
9952
|
if (h > hue + (nextHue - hue) / 2 && hueName !== nextHueName) hueName = `${hueName} ${nextHueName}`;
|
|
8662
9953
|
else if (hueName === "yellow" && l < YELLOW_GREEN_LIGHTNESS_THRESHOLD) hueName = "yellow green";
|
|
8663
9954
|
return [getColorStringForLocale(hueName, locale).toLocaleLowerCase(locale), l];
|
|
@@ -8920,7 +10211,7 @@ var HSLColorImpl = class HSLColorImpl {
|
|
|
8920
10211
|
lightness;
|
|
8921
10212
|
alpha;
|
|
8922
10213
|
constructor(hue, saturation, lightness, alpha = 1) {
|
|
8923
|
-
this.hue = clamp(hue
|
|
10214
|
+
this.hue = clamp(normalizeHue(hue), 0, 360);
|
|
8924
10215
|
this.saturation = clamp(saturation, 0, 100);
|
|
8925
10216
|
this.lightness = clamp(lightness, 0, 100);
|
|
8926
10217
|
this.alpha = clamp(toFixed(alpha, 2), 0, 1);
|
|
@@ -8938,9 +10229,11 @@ var HSLColorImpl = class HSLColorImpl {
|
|
|
8938
10229
|
}
|
|
8939
10230
|
case "hsb":
|
|
8940
10231
|
case "hsba": {
|
|
8941
|
-
const
|
|
8942
|
-
const
|
|
8943
|
-
|
|
10232
|
+
const saturation = this.saturation / 100;
|
|
10233
|
+
const lightness = this.lightness / 100;
|
|
10234
|
+
const brightness = lightness + saturation * Math.min(lightness, 1 - lightness);
|
|
10235
|
+
const hsbSaturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness);
|
|
10236
|
+
return new HSBColorImpl(toFixed(this.hue, 2), toFixed(hsbSaturation * 100, 2), toFixed(brightness * 100, 2), this.alpha);
|
|
8944
10237
|
}
|
|
8945
10238
|
default: throw new Error(`Unsupported format: ${format}`);
|
|
8946
10239
|
}
|
|
@@ -9007,8 +10300,7 @@ var HSLColorImpl = class HSLColorImpl {
|
|
|
9007
10300
|
if (channel === "hue") return {
|
|
9008
10301
|
style: "unit",
|
|
9009
10302
|
unit: "degree",
|
|
9010
|
-
unitDisplay: "narrow"
|
|
9011
|
-
maximumFractionDigits: 0
|
|
10303
|
+
unitDisplay: "narrow"
|
|
9012
10304
|
};
|
|
9013
10305
|
return {
|
|
9014
10306
|
style: "percent",
|
|
@@ -9060,7 +10352,7 @@ var HSBColorImpl = class HSBColorImpl {
|
|
|
9060
10352
|
brightness;
|
|
9061
10353
|
alpha;
|
|
9062
10354
|
constructor(hue, saturation, brightness, alpha = 1) {
|
|
9063
|
-
this.hue = clamp(hue
|
|
10355
|
+
this.hue = clamp(normalizeHue(hue), 0, 360);
|
|
9064
10356
|
this.saturation = clamp(saturation, 0, 100);
|
|
9065
10357
|
this.brightness = clamp(brightness, 0, 100);
|
|
9066
10358
|
this.alpha = clamp(toFixed(alpha, 2), 0, 1);
|
|
@@ -9078,9 +10370,11 @@ var HSBColorImpl = class HSBColorImpl {
|
|
|
9078
10370
|
}
|
|
9079
10371
|
case "hsl":
|
|
9080
10372
|
case "hsla": {
|
|
9081
|
-
const
|
|
9082
|
-
const
|
|
9083
|
-
|
|
10373
|
+
const saturation = this.saturation / 100;
|
|
10374
|
+
const brightness = this.brightness / 100;
|
|
10375
|
+
const lightness = brightness * (1 - saturation / 2);
|
|
10376
|
+
const hslSaturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness);
|
|
10377
|
+
return new HSLColorImpl(toFixed(this.hue, 2), toFixed(hslSaturation * 100, 2), toFixed(lightness * 100, 2), this.alpha);
|
|
9084
10378
|
}
|
|
9085
10379
|
default: throw new Error(`Unsupported format: ${format}`);
|
|
9086
10380
|
}
|
|
@@ -9147,8 +10441,7 @@ var HSBColorImpl = class HSBColorImpl {
|
|
|
9147
10441
|
if (channel === "hue") return {
|
|
9148
10442
|
style: "unit",
|
|
9149
10443
|
unit: "degree",
|
|
9150
|
-
unitDisplay: "narrow"
|
|
9151
|
-
maximumFractionDigits: 0
|
|
10444
|
+
unitDisplay: "narrow"
|
|
9152
10445
|
};
|
|
9153
10446
|
return {
|
|
9154
10447
|
style: "percent",
|
|
@@ -9207,10 +10500,10 @@ function parseColor(value) {
|
|
|
9207
10500
|
}
|
|
9208
10501
|
const rgbMatch = trimmed.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)$/);
|
|
9209
10502
|
if (rgbMatch) return new RGBColorImpl(parseInt(rgbMatch[1], 10), parseInt(rgbMatch[2], 10), parseInt(rgbMatch[3], 10), rgbMatch[4] !== void 0 ? parseFloat(rgbMatch[4]) : 1);
|
|
9210
|
-
const hslMatch = trimmed.match(/^hsla?\(\s*(
|
|
9211
|
-
if (hslMatch) return new HSLColorImpl(
|
|
9212
|
-
const hsbMatch = trimmed.match(/^hsba?\(\s*(
|
|
9213
|
-
if (hsbMatch) return new HSBColorImpl(
|
|
10503
|
+
const hslMatch = trimmed.match(/^hsla?\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*(?:,\s*([-+]?\d+(?:\.\d+)?))?\s*\)$/);
|
|
10504
|
+
if (hslMatch) return new HSLColorImpl(parseFloat(hslMatch[1]), parseFloat(hslMatch[2]), parseFloat(hslMatch[3]), hslMatch[4] !== void 0 ? parseFloat(hslMatch[4]) : 1);
|
|
10505
|
+
const hsbMatch = trimmed.match(/^hsba?\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*(?:,\s*([-+]?\d+(?:\.\d+)?))?\s*\)$/);
|
|
10506
|
+
if (hsbMatch) return new HSBColorImpl(parseFloat(hsbMatch[1]), parseFloat(hsbMatch[2]), parseFloat(hsbMatch[3]), hsbMatch[4] !== void 0 ? parseFloat(hsbMatch[4]) : 1);
|
|
9214
10507
|
throw new Error(`Invalid color format: ${value}`);
|
|
9215
10508
|
}
|
|
9216
10509
|
/**
|
|
@@ -9254,8 +10547,8 @@ function createColorSliderState(options) {
|
|
|
9254
10547
|
const colorSpace = getOptions().colorSpace;
|
|
9255
10548
|
return colorSpace ? color.toFormat(colorSpace) : color;
|
|
9256
10549
|
};
|
|
9257
|
-
const [internalValue, setInternalValue] =
|
|
9258
|
-
const [isDragging, setIsDragging] =
|
|
10550
|
+
const [internalValue, setInternalValue] = createInternalSignal(null);
|
|
10551
|
+
const [isDragging, setIsDragging] = createInternalSignal(false);
|
|
9259
10552
|
const initValue = () => {
|
|
9260
10553
|
const opts = getOptions();
|
|
9261
10554
|
if (opts.defaultValue) return normalizeValue(opts.defaultValue);
|
|
@@ -9280,9 +10573,11 @@ function createColorSliderState(options) {
|
|
|
9280
10573
|
const pageSize = createMemo(() => channelRange().pageSize);
|
|
9281
10574
|
const minValue = createMemo(() => channelRange().minValue);
|
|
9282
10575
|
const maxValue = createMemo(() => channelRange().maxValue);
|
|
10576
|
+
let lastValue = internalValue();
|
|
9283
10577
|
const updateValue = (newColor) => {
|
|
9284
10578
|
const opts = getOptions();
|
|
9285
10579
|
const nextColor = opts.colorSpace ? newColor.toFormat(opts.colorSpace) : newColor;
|
|
10580
|
+
lastValue = nextColor;
|
|
9286
10581
|
if (opts.value !== void 0) {
|
|
9287
10582
|
opts.onChange?.(nextColor);
|
|
9288
10583
|
return;
|
|
@@ -9290,8 +10585,9 @@ function createColorSliderState(options) {
|
|
|
9290
10585
|
setInternalValue(nextColor);
|
|
9291
10586
|
opts.onChange?.(nextColor);
|
|
9292
10587
|
};
|
|
10588
|
+
const liveColor = () => lastValue ?? internalValue() ?? value();
|
|
9293
10589
|
const getThumbValue = () => {
|
|
9294
|
-
return
|
|
10590
|
+
return liveColor().getChannelValue(channel());
|
|
9295
10591
|
};
|
|
9296
10592
|
const getThumbMinValue = () => minValue();
|
|
9297
10593
|
const getThumbMaxValue = () => maxValue();
|
|
@@ -9308,11 +10604,13 @@ function createColorSliderState(options) {
|
|
|
9308
10604
|
const clamped = Math.max(min, Math.min(max, newValue));
|
|
9309
10605
|
const precision = `${stepValue}`.split(".")[1]?.length ?? 0;
|
|
9310
10606
|
const rounded = Number((Math.round((clamped - min) / stepValue) * stepValue + min).toFixed(precision));
|
|
9311
|
-
|
|
10607
|
+
const newColor = liveColor().withChannelValue(channel(), rounded);
|
|
10608
|
+
updateValue(newColor);
|
|
9312
10609
|
};
|
|
9313
10610
|
const setThumbPercent = (percent) => {
|
|
9314
10611
|
const min = minValue();
|
|
9315
|
-
|
|
10612
|
+
const val = min + (maxValue() - min) * percent;
|
|
10613
|
+
setThumbValue(val);
|
|
9316
10614
|
};
|
|
9317
10615
|
const incrementThumb = (stepSize) => {
|
|
9318
10616
|
const s = stepSize ?? step();
|
|
@@ -9323,9 +10621,13 @@ function createColorSliderState(options) {
|
|
|
9323
10621
|
setThumbValue(getThumbValue() - s);
|
|
9324
10622
|
};
|
|
9325
10623
|
const setDraggingState = (dragging) => {
|
|
9326
|
-
const wasDragging = isDragging
|
|
10624
|
+
const wasDragging = readNow(isDragging);
|
|
9327
10625
|
setIsDragging(dragging);
|
|
9328
|
-
if (wasDragging && !dragging)
|
|
10626
|
+
if (wasDragging && !dragging) {
|
|
10627
|
+
const opts = getOptions();
|
|
10628
|
+
const current = lastValue ?? (opts.value !== void 0 ? normalizeValue(opts.value) : null) ?? internalValue() ?? value();
|
|
10629
|
+
opts.onChangeEnd?.(current);
|
|
10630
|
+
}
|
|
9329
10631
|
};
|
|
9330
10632
|
const getDisplayColor = () => {
|
|
9331
10633
|
const v = value();
|
|
@@ -9395,8 +10697,8 @@ function createColorAreaState(options) {
|
|
|
9395
10697
|
const colorSpace = getOptions().colorSpace;
|
|
9396
10698
|
return colorSpace ? color.toFormat(colorSpace) : color;
|
|
9397
10699
|
};
|
|
9398
|
-
const [internalValue, setInternalValue] =
|
|
9399
|
-
const [isDragging, setIsDragging] =
|
|
10700
|
+
const [internalValue, setInternalValue] = createInternalSignal(null);
|
|
10701
|
+
const [isDragging, setIsDragging] = createInternalSignal(false);
|
|
9400
10702
|
const initValue = () => {
|
|
9401
10703
|
const opts = getOptions();
|
|
9402
10704
|
if (opts.defaultValue) return normalizeValue(opts.defaultValue);
|
|
@@ -9429,9 +10731,11 @@ function createColorAreaState(options) {
|
|
|
9429
10731
|
const yChannelStep = createMemo(() => yRange().step);
|
|
9430
10732
|
const xChannelPageStep = createMemo(() => xRange().pageSize);
|
|
9431
10733
|
const yChannelPageStep = createMemo(() => yRange().pageSize);
|
|
10734
|
+
let lastValue = internalValue();
|
|
9432
10735
|
const updateValue = (newColor) => {
|
|
9433
10736
|
const opts = getOptions();
|
|
9434
10737
|
const nextColor = opts.colorSpace ? newColor.toFormat(opts.colorSpace) : newColor;
|
|
10738
|
+
lastValue = nextColor;
|
|
9435
10739
|
if (opts.value !== void 0) {
|
|
9436
10740
|
opts.onChange?.(nextColor);
|
|
9437
10741
|
return;
|
|
@@ -9445,13 +10749,15 @@ function createColorAreaState(options) {
|
|
|
9445
10749
|
const range = xRange();
|
|
9446
10750
|
const clamped = Math.max(range.minValue, Math.min(range.maxValue, newValue));
|
|
9447
10751
|
const rounded = Math.round(clamped / range.step) * range.step;
|
|
9448
|
-
|
|
10752
|
+
const newColor = value().withChannelValue(xChannel(), rounded);
|
|
10753
|
+
updateValue(newColor);
|
|
9449
10754
|
};
|
|
9450
10755
|
const setYValue = (newValue) => {
|
|
9451
10756
|
const range = yRange();
|
|
9452
10757
|
const clamped = Math.max(range.minValue, Math.min(range.maxValue, newValue));
|
|
9453
10758
|
const rounded = Math.round(clamped / range.step) * range.step;
|
|
9454
|
-
|
|
10759
|
+
const newColor = value().withChannelValue(yChannel(), rounded);
|
|
10760
|
+
updateValue(newColor);
|
|
9455
10761
|
};
|
|
9456
10762
|
const setColorFromPoint = (x, y) => {
|
|
9457
10763
|
const xR = xRange();
|
|
@@ -9462,7 +10768,8 @@ function createColorAreaState(options) {
|
|
|
9462
10768
|
const yClamped = Math.max(yR.minValue, Math.min(yR.maxValue, yVal));
|
|
9463
10769
|
const xRounded = Math.round(xClamped / xR.step) * xR.step;
|
|
9464
10770
|
const yRounded = Math.round(yClamped / yR.step) * yR.step;
|
|
9465
|
-
|
|
10771
|
+
const newColor = value().withChannelValue(xChannel(), xRounded).withChannelValue(yChannel(), yRounded);
|
|
10772
|
+
updateValue(newColor);
|
|
9466
10773
|
};
|
|
9467
10774
|
const getThumbPosition = () => {
|
|
9468
10775
|
const xR = xRange();
|
|
@@ -9493,7 +10800,11 @@ function createColorAreaState(options) {
|
|
|
9493
10800
|
const setDraggingState = (dragging) => {
|
|
9494
10801
|
const wasDragging = isDragging();
|
|
9495
10802
|
setIsDragging(dragging);
|
|
9496
|
-
if (wasDragging && !dragging)
|
|
10803
|
+
if (wasDragging && !dragging) {
|
|
10804
|
+
const opts = getOptions();
|
|
10805
|
+
const current = lastValue ?? (opts.value !== void 0 ? normalizeValue(opts.value) : null) ?? internalValue() ?? value();
|
|
10806
|
+
opts.onChangeEnd?.(current);
|
|
10807
|
+
}
|
|
9497
10808
|
};
|
|
9498
10809
|
const getDisplayColor = () => {
|
|
9499
10810
|
return value().withChannelValue("alpha", 1);
|
|
@@ -9560,8 +10871,8 @@ function createColorWheelState(options) {
|
|
|
9560
10871
|
return value.toFormat(value.getColorSpace() === "hsb" ? "hsb" : "hsl");
|
|
9561
10872
|
};
|
|
9562
10873
|
const initialValue = normalizeWheelValue(getOptions().defaultValue ?? defaultColor);
|
|
9563
|
-
const [internalValue, setInternalValue] =
|
|
9564
|
-
const [isDragging, setIsDragging] =
|
|
10874
|
+
const [internalValue, setInternalValue] = createInternalSignal(initialValue);
|
|
10875
|
+
const [isDragging, setIsDragging] = createInternalSignal(false);
|
|
9565
10876
|
let valueRef = initialValue;
|
|
9566
10877
|
const value = createMemo(() => {
|
|
9567
10878
|
const opts = getOptions();
|
|
@@ -9612,9 +10923,11 @@ function createColorWheelState(options) {
|
|
|
9612
10923
|
const setHue = (newValue) => {
|
|
9613
10924
|
const currentHue = getHue();
|
|
9614
10925
|
const range = hueRange();
|
|
9615
|
-
const
|
|
10926
|
+
const hue = newValue > range.maxValue ? range.minValue : newValue;
|
|
10927
|
+
const rounded = roundToStep(mod(hue, range.maxValue), range.step);
|
|
9616
10928
|
if (rounded === currentHue) return;
|
|
9617
|
-
|
|
10929
|
+
const newColor = value().withChannelValue("hue", rounded);
|
|
10930
|
+
updateValue(newColor);
|
|
9618
10931
|
};
|
|
9619
10932
|
const setHueFromAngle = (angle) => {
|
|
9620
10933
|
setHue(mod(360 - radToDeg(angle), 360));
|
|
@@ -9648,7 +10961,7 @@ function createColorWheelState(options) {
|
|
|
9648
10961
|
setHue(roundToStep(mod(getHue() - s, range.maxValue), s));
|
|
9649
10962
|
};
|
|
9650
10963
|
const setDraggingState = (dragging) => {
|
|
9651
|
-
const wasDragging = isDragging
|
|
10964
|
+
const wasDragging = readNow(isDragging);
|
|
9652
10965
|
setIsDragging(dragging);
|
|
9653
10966
|
if (wasDragging && !dragging) getOptions().onChangeEnd?.(valueRef);
|
|
9654
10967
|
};
|
|
@@ -9728,7 +11041,10 @@ function formatColorValue(color, channel, colorSpace, format, locale) {
|
|
|
9728
11041
|
if (!color) return "";
|
|
9729
11042
|
const displayColor = getDisplayColor(color, colorSpace);
|
|
9730
11043
|
if (channel) return displayColor.formatChannelValue(channel, locale);
|
|
9731
|
-
|
|
11044
|
+
const formatted = displayColor.toString(format ?? "hex");
|
|
11045
|
+
const resolvedFormat = format ?? "hex";
|
|
11046
|
+
if (resolvedFormat === "hex" || resolvedFormat === "hexa") return formatted.toUpperCase();
|
|
11047
|
+
return formatted;
|
|
9732
11048
|
}
|
|
9733
11049
|
function normalizeHexInput(value) {
|
|
9734
11050
|
return value.startsWith("#") ? value : `#${value}`;
|
|
@@ -9759,9 +11075,9 @@ function createColorFieldState(options) {
|
|
|
9759
11075
|
const getOptions = () => options();
|
|
9760
11076
|
const initialOptions = getOptions();
|
|
9761
11077
|
const initialValue = getDefaultValue(initialOptions);
|
|
9762
|
-
const [internalValue, setInternalValue] =
|
|
9763
|
-
const [inputValue, setInputValueInternal] =
|
|
9764
|
-
const [invalidInput, setInvalidInput] =
|
|
11078
|
+
const [internalValue, setInternalValue] = createInternalSignal(initialValue);
|
|
11079
|
+
const [inputValue, setInputValueInternal] = createInternalSignal(formatColorValue(initialValue, initialOptions.channel, initialOptions.colorSpace, initialOptions.colorFormat, initialOptions.locale ?? "en-US"));
|
|
11080
|
+
const [invalidInput, setInvalidInput] = createInternalSignal(false);
|
|
9765
11081
|
const channel = createMemo(() => getOptions().channel);
|
|
9766
11082
|
const colorSpace = createMemo(() => getOptions().colorSpace);
|
|
9767
11083
|
const locale = createMemo(() => getOptions().locale ?? "en-US");
|
|
@@ -9776,8 +11092,8 @@ function createColorFieldState(options) {
|
|
|
9776
11092
|
const isRequired = createMemo(() => getOptions().isRequired ?? false);
|
|
9777
11093
|
const isInvalid = createMemo(() => (getOptions().isInvalid ?? false) || invalidInput());
|
|
9778
11094
|
const formatCurrentValue = (color = value()) => formatColorValue(color, channel(), colorSpace(), getOptions().colorFormat, locale());
|
|
9779
|
-
createEffect(() => {
|
|
9780
|
-
setInputValueInternal(
|
|
11095
|
+
createEffect(() => formatCurrentValue(), (formatted) => {
|
|
11096
|
+
setInputValueInternal(formatted);
|
|
9781
11097
|
setInvalidInput(false);
|
|
9782
11098
|
});
|
|
9783
11099
|
const updateValue = (newColor) => {
|
|
@@ -9795,7 +11111,7 @@ function createColorFieldState(options) {
|
|
|
9795
11111
|
updateValue(newColor);
|
|
9796
11112
|
};
|
|
9797
11113
|
const commit = () => {
|
|
9798
|
-
const text = inputValue
|
|
11114
|
+
const text = readNow(inputValue).trim();
|
|
9799
11115
|
const opts = getOptions();
|
|
9800
11116
|
const chan = channel();
|
|
9801
11117
|
if (!text) {
|
|
@@ -9866,7 +11182,7 @@ function createColorFieldState(options) {
|
|
|
9866
11182
|
updateChannel("min");
|
|
9867
11183
|
};
|
|
9868
11184
|
const validate = (candidate) => {
|
|
9869
|
-
const text = (candidate ?? inputValue
|
|
11185
|
+
const text = (candidate ?? readNow(inputValue)).trim();
|
|
9870
11186
|
const chan = channel();
|
|
9871
11187
|
if (!text) return true;
|
|
9872
11188
|
if (chan) return parseChannelValue(text, colorValue(), chan) != null;
|
|
@@ -9938,6 +11254,8 @@ function createColorFieldState(options) {
|
|
|
9938
11254
|
* Drag state management for solid-stately.
|
|
9939
11255
|
*
|
|
9940
11256
|
* Provides reactive state for drag operations.
|
|
11257
|
+
*
|
|
11258
|
+
* Ported from packages/react-aria/src/dnd/useDrag.ts.
|
|
9941
11259
|
*/
|
|
9942
11260
|
/**
|
|
9943
11261
|
* Creates drag state for managing drag operations.
|
|
@@ -9947,7 +11265,7 @@ function createColorFieldState(options) {
|
|
|
9947
11265
|
*/
|
|
9948
11266
|
function createDragState(props) {
|
|
9949
11267
|
const getProps = createMemo(() => props());
|
|
9950
|
-
const [isDragging, setIsDragging] =
|
|
11268
|
+
const [isDragging, setIsDragging] = createInternalSignal(false);
|
|
9951
11269
|
const startDrag = (x, y) => {
|
|
9952
11270
|
const p = getProps();
|
|
9953
11271
|
if (p.isDisabled) return;
|
|
@@ -9960,7 +11278,7 @@ function createDragState(props) {
|
|
|
9960
11278
|
};
|
|
9961
11279
|
const moveDrag = (x, y) => {
|
|
9962
11280
|
const p = getProps();
|
|
9963
|
-
if (!isDragging
|
|
11281
|
+
if (!readNow(isDragging) || p.isDisabled) return;
|
|
9964
11282
|
if (typeof p.onDragMove === "function") p.onDragMove({
|
|
9965
11283
|
type: "dragmove",
|
|
9966
11284
|
x,
|
|
@@ -9969,7 +11287,7 @@ function createDragState(props) {
|
|
|
9969
11287
|
};
|
|
9970
11288
|
const endDrag = (x, y, dropOperation) => {
|
|
9971
11289
|
const p = getProps();
|
|
9972
|
-
if (!isDragging
|
|
11290
|
+
if (!readNow(isDragging)) return;
|
|
9973
11291
|
setIsDragging(false);
|
|
9974
11292
|
if (typeof p.onDragEnd === "function") p.onDragEnd({
|
|
9975
11293
|
type: "dragend",
|
|
@@ -10020,6 +11338,8 @@ function createDragState(props) {
|
|
|
10020
11338
|
* Drop state management for solid-stately.
|
|
10021
11339
|
*
|
|
10022
11340
|
* Provides reactive state for drop target operations.
|
|
11341
|
+
*
|
|
11342
|
+
* Ported from packages/react-aria/src/dnd/useDrop.ts.
|
|
10023
11343
|
*/
|
|
10024
11344
|
/**
|
|
10025
11345
|
* Creates drop state for managing drop target operations.
|
|
@@ -10029,7 +11349,7 @@ function createDragState(props) {
|
|
|
10029
11349
|
*/
|
|
10030
11350
|
function createDropState(props) {
|
|
10031
11351
|
const getProps = createMemo(() => props());
|
|
10032
|
-
const [isDropTarget, setIsDropTarget] =
|
|
11352
|
+
const [isDropTarget, setIsDropTarget] = createInternalSignal(false);
|
|
10033
11353
|
const enterTarget = (x, y) => {
|
|
10034
11354
|
const p = getProps();
|
|
10035
11355
|
if (p.isDisabled) return;
|
|
@@ -10042,7 +11362,7 @@ function createDropState(props) {
|
|
|
10042
11362
|
};
|
|
10043
11363
|
const moveInTarget = (x, y) => {
|
|
10044
11364
|
const p = getProps();
|
|
10045
|
-
if (!isDropTarget
|
|
11365
|
+
if (!readNow(isDropTarget) || p.isDisabled) return;
|
|
10046
11366
|
if (typeof p.onDropMove === "function") p.onDropMove({
|
|
10047
11367
|
type: "dropmove",
|
|
10048
11368
|
x,
|
|
@@ -10114,7 +11434,51 @@ function createDropState(props) {
|
|
|
10114
11434
|
* Draggable collection state management for solid-stately.
|
|
10115
11435
|
*
|
|
10116
11436
|
* Provides reactive state for dragging items from a collection.
|
|
11437
|
+
*
|
|
11438
|
+
* Ported from packages/react-stately/src/dnd/useDraggableCollectionState.ts.
|
|
11439
|
+
*/
|
|
11440
|
+
function selectedKeySet(selectedKeys, collection) {
|
|
11441
|
+
if (selectedKeys === "all") {
|
|
11442
|
+
if (!collection?.getKeys) return "all";
|
|
11443
|
+
return new Set(collection.getKeys());
|
|
11444
|
+
}
|
|
11445
|
+
return new Set(selectedKeys ?? []);
|
|
11446
|
+
}
|
|
11447
|
+
/**
|
|
11448
|
+
* RAC `useDraggableCollectionState.ts` `getKeys`. The clicked item always
|
|
11449
|
+
* drags. If it is selected, every selected item that is not a child of another
|
|
11450
|
+
* selected item is included.
|
|
10117
11451
|
*/
|
|
11452
|
+
function getKeysForDrag(key, options) {
|
|
11453
|
+
const selected = selectedKeySet(options.selectedKeys, options.collection);
|
|
11454
|
+
if (!(options.isSelected?.(key) ?? (selected === "all" ? true : selected.has(key)))) return /* @__PURE__ */ new Set([key]);
|
|
11455
|
+
const keys = /* @__PURE__ */ new Set();
|
|
11456
|
+
const selectedKeys = selected === "all" ? options.collection?.getKeys?.() : selected;
|
|
11457
|
+
if (!selectedKeys) {
|
|
11458
|
+
keys.add(key);
|
|
11459
|
+
return keys;
|
|
11460
|
+
}
|
|
11461
|
+
for (const currentKey of selectedKeys) {
|
|
11462
|
+
const node = options.collection?.getItem(currentKey);
|
|
11463
|
+
if (!node) {
|
|
11464
|
+
keys.add(currentKey);
|
|
11465
|
+
continue;
|
|
11466
|
+
}
|
|
11467
|
+
let isChild = false;
|
|
11468
|
+
let parentKey = node.parentKey;
|
|
11469
|
+
while (parentKey != null) {
|
|
11470
|
+
if (options.isSelected?.(parentKey) ?? (selected === "all" ? true : selected.has(parentKey))) {
|
|
11471
|
+
isChild = true;
|
|
11472
|
+
break;
|
|
11473
|
+
}
|
|
11474
|
+
const parentNode = options.collection?.getItem(parentKey);
|
|
11475
|
+
parentKey = parentNode ? parentNode.parentKey : null;
|
|
11476
|
+
}
|
|
11477
|
+
if (!isChild) keys.add(currentKey);
|
|
11478
|
+
}
|
|
11479
|
+
if (keys.size === 0) keys.add(key);
|
|
11480
|
+
return keys;
|
|
11481
|
+
}
|
|
10118
11482
|
/**
|
|
10119
11483
|
* Creates state for dragging items from a collection.
|
|
10120
11484
|
*
|
|
@@ -10123,8 +11487,8 @@ function createDropState(props) {
|
|
|
10123
11487
|
*/
|
|
10124
11488
|
function createDraggableCollectionState(props) {
|
|
10125
11489
|
const getProps = createMemo(() => props());
|
|
10126
|
-
const [isDragging, setIsDragging] =
|
|
10127
|
-
const [draggingKeys, setDraggingKeys] =
|
|
11490
|
+
const [isDragging, setIsDragging] = createInternalSignal(false);
|
|
11491
|
+
const [draggingKeys, setDraggingKeys] = createInternalSignal(/* @__PURE__ */ new Set());
|
|
10128
11492
|
const startDrag = (keys, x, y) => {
|
|
10129
11493
|
const p = getProps();
|
|
10130
11494
|
if (p.isDisabled) return;
|
|
@@ -10139,17 +11503,17 @@ function createDraggableCollectionState(props) {
|
|
|
10139
11503
|
};
|
|
10140
11504
|
const moveDrag = (x, y) => {
|
|
10141
11505
|
const p = getProps();
|
|
10142
|
-
if (!isDragging
|
|
11506
|
+
if (!readNow(isDragging) || p.isDisabled) return;
|
|
10143
11507
|
if (typeof p.onDragMove === "function") p.onDragMove({
|
|
10144
11508
|
type: "dragmove",
|
|
10145
11509
|
x,
|
|
10146
11510
|
y,
|
|
10147
|
-
keys: draggingKeys
|
|
11511
|
+
keys: readNow(draggingKeys)
|
|
10148
11512
|
});
|
|
10149
11513
|
};
|
|
10150
11514
|
const endDrag = (x, y, dropOperation, isInternal) => {
|
|
10151
11515
|
const p = getProps();
|
|
10152
|
-
const keys = draggingKeys
|
|
11516
|
+
const keys = readNow(draggingKeys);
|
|
10153
11517
|
setIsDragging(false);
|
|
10154
11518
|
setDraggingKeys(/* @__PURE__ */ new Set());
|
|
10155
11519
|
if (typeof p.onDragEnd === "function") p.onDragEnd({
|
|
@@ -10194,7 +11558,21 @@ function createDraggableCollectionState(props) {
|
|
|
10194
11558
|
endDrag,
|
|
10195
11559
|
cancelDrag,
|
|
10196
11560
|
getItems,
|
|
10197
|
-
getAllowedDropOperations
|
|
11561
|
+
getAllowedDropOperations,
|
|
11562
|
+
getKeysForDrag: (key) => {
|
|
11563
|
+
const p = getProps();
|
|
11564
|
+
return getKeysForDrag(key, {
|
|
11565
|
+
collection: p.collection,
|
|
11566
|
+
selectedKeys: p.selectedKeys,
|
|
11567
|
+
isSelected: p.isSelected
|
|
11568
|
+
});
|
|
11569
|
+
},
|
|
11570
|
+
isSelected: (key) => {
|
|
11571
|
+
const p = getProps();
|
|
11572
|
+
if (p.isSelected) return p.isSelected(key);
|
|
11573
|
+
const selected = selectedKeySet(p.selectedKeys, p.collection);
|
|
11574
|
+
return selected === "all" ? true : selected.has(key);
|
|
11575
|
+
}
|
|
10198
11576
|
};
|
|
10199
11577
|
}
|
|
10200
11578
|
//#endregion
|
|
@@ -10203,6 +11581,8 @@ function createDraggableCollectionState(props) {
|
|
|
10203
11581
|
* Droppable collection state management for solid-stately.
|
|
10204
11582
|
*
|
|
10205
11583
|
* Provides reactive state for accepting drops onto a collection.
|
|
11584
|
+
*
|
|
11585
|
+
* Ported from packages/react-stately/src/dnd/useDroppableCollectionState.ts.
|
|
10206
11586
|
*/
|
|
10207
11587
|
/**
|
|
10208
11588
|
* Symbol for directory drag type.
|
|
@@ -10216,8 +11596,8 @@ const DIRECTORY_DRAG_TYPE = Symbol("directory");
|
|
|
10216
11596
|
*/
|
|
10217
11597
|
function createDroppableCollectionState(props) {
|
|
10218
11598
|
const getProps = createMemo(() => props());
|
|
10219
|
-
const [isDropTarget, setIsDropTarget] =
|
|
10220
|
-
const [target, setTarget] =
|
|
11599
|
+
const [isDropTarget, setIsDropTarget] = createInternalSignal(false);
|
|
11600
|
+
const [target, setTarget] = createInternalSignal(null);
|
|
10221
11601
|
const isAccepted = (types) => {
|
|
10222
11602
|
const acceptedTypes = getProps().acceptedDragTypes ?? "all";
|
|
10223
11603
|
if (acceptedTypes === "all") return true;
|
|
@@ -10369,6 +11749,19 @@ function createDroppableCollectionState(props) {
|
|
|
10369
11749
|
if (typeof p.shouldAcceptItemDrop === "function") return p.shouldAcceptItemDrop(dropTarget, types);
|
|
10370
11750
|
return true;
|
|
10371
11751
|
};
|
|
11752
|
+
const isDropTargetFor = (dropTarget) => {
|
|
11753
|
+
const current = target();
|
|
11754
|
+
if (!current || !dropTarget) return false;
|
|
11755
|
+
if (targetsEqual(current, dropTarget)) return true;
|
|
11756
|
+
if (dropTarget.type !== "item" || current.type !== "item" || dropTarget.key === current.key || dropTarget.dropPosition === current.dropPosition || dropTarget.dropPosition === "on" || current.dropPosition === "on") return false;
|
|
11757
|
+
const collection = getProps().collection;
|
|
11758
|
+
if (!collection) return false;
|
|
11759
|
+
return dropTargetsEqual(getOppositeTarget(collection, dropTarget), current) || dropTargetsEqual(dropTarget, getOppositeTarget(collection, current));
|
|
11760
|
+
};
|
|
11761
|
+
const assignTarget = (newTarget) => {
|
|
11762
|
+
if (isDropTargetFor(newTarget)) return;
|
|
11763
|
+
setTarget(newTarget);
|
|
11764
|
+
};
|
|
10372
11765
|
return {
|
|
10373
11766
|
get isDropTarget() {
|
|
10374
11767
|
return isDropTarget();
|
|
@@ -10379,7 +11772,7 @@ function createDroppableCollectionState(props) {
|
|
|
10379
11772
|
get isDisabled() {
|
|
10380
11773
|
return getProps().isDisabled ?? false;
|
|
10381
11774
|
},
|
|
10382
|
-
setTarget,
|
|
11775
|
+
setTarget: assignTarget,
|
|
10383
11776
|
isAccepted,
|
|
10384
11777
|
enterTarget,
|
|
10385
11778
|
moveToTarget,
|
|
@@ -10387,18 +11780,50 @@ function createDroppableCollectionState(props) {
|
|
|
10387
11780
|
activateTarget,
|
|
10388
11781
|
drop,
|
|
10389
11782
|
getDropOperation,
|
|
10390
|
-
shouldAcceptItemDrop
|
|
11783
|
+
shouldAcceptItemDrop,
|
|
11784
|
+
isDropTargetFor
|
|
10391
11785
|
};
|
|
10392
11786
|
}
|
|
10393
11787
|
/**
|
|
10394
11788
|
* Check if two drop targets are equal.
|
|
10395
11789
|
*/
|
|
10396
11790
|
function targetsEqual(a, b) {
|
|
11791
|
+
return dropTargetsEqual(a, b);
|
|
11792
|
+
}
|
|
11793
|
+
function dropTargetsEqual(a, b) {
|
|
11794
|
+
if (!a || !b) return false;
|
|
10397
11795
|
if (a.type !== b.type) return false;
|
|
10398
11796
|
if (a.type === "root" && b.type === "root") return true;
|
|
10399
11797
|
if (a.type === "item" && b.type === "item") return a.key === b.key && a.dropPosition === b.dropPosition;
|
|
10400
11798
|
return false;
|
|
10401
11799
|
}
|
|
11800
|
+
function nextItemKey(collection, fromKey, direction) {
|
|
11801
|
+
let key = direction === "before" ? collection.getKeyBefore(fromKey) : collection.getKeyAfter(fromKey);
|
|
11802
|
+
while (key != null) {
|
|
11803
|
+
if (collection.getItem(key)?.type === "item") return key;
|
|
11804
|
+
key = direction === "before" ? collection.getKeyBefore(key) : collection.getKeyAfter(key);
|
|
11805
|
+
}
|
|
11806
|
+
return null;
|
|
11807
|
+
}
|
|
11808
|
+
function getOppositeTarget(collection, target) {
|
|
11809
|
+
if (target.dropPosition === "before") {
|
|
11810
|
+
const prevKey = nextItemKey(collection, target.key, "before");
|
|
11811
|
+
return prevKey != null ? {
|
|
11812
|
+
type: "item",
|
|
11813
|
+
key: prevKey,
|
|
11814
|
+
dropPosition: "after"
|
|
11815
|
+
} : null;
|
|
11816
|
+
}
|
|
11817
|
+
if (target.dropPosition === "after") {
|
|
11818
|
+
const nextKey = nextItemKey(collection, target.key, "after");
|
|
11819
|
+
return nextKey != null ? {
|
|
11820
|
+
type: "item",
|
|
11821
|
+
key: nextKey,
|
|
11822
|
+
dropPosition: "before"
|
|
11823
|
+
} : null;
|
|
11824
|
+
}
|
|
11825
|
+
return null;
|
|
11826
|
+
}
|
|
10402
11827
|
//#endregion
|
|
10403
11828
|
//#region src/data/createListData.ts
|
|
10404
11829
|
/**
|
|
@@ -10406,6 +11831,8 @@ function targetsEqual(a, b) {
|
|
|
10406
11831
|
*
|
|
10407
11832
|
* Manages state for an immutable list data structure, and provides
|
|
10408
11833
|
* convenience methods to update the data over time.
|
|
11834
|
+
*
|
|
11835
|
+
* Ported from packages/react-stately/src/data/useListData.ts.
|
|
10409
11836
|
*/
|
|
10410
11837
|
/**
|
|
10411
11838
|
* Manages state for an immutable list data structure, and provides
|
|
@@ -10417,7 +11844,7 @@ function createListData(options) {
|
|
|
10417
11844
|
return candidate.id ?? candidate.key ?? String(item);
|
|
10418
11845
|
};
|
|
10419
11846
|
const { initialItems = [], initialSelectedKeys, getKey = defaultGetKey, filter, initialFilterText = "" } = options;
|
|
10420
|
-
const [state, setState] =
|
|
11847
|
+
const [state, setState] = createInternalSignal({
|
|
10421
11848
|
items: initialItems,
|
|
10422
11849
|
selectedKeys: initialSelectedKeys === "all" ? "all" : new Set(initialSelectedKeys || []),
|
|
10423
11850
|
filterText: initialFilterText
|
|
@@ -10451,7 +11878,7 @@ function createListData(options) {
|
|
|
10451
11878
|
};
|
|
10452
11879
|
return {
|
|
10453
11880
|
...s,
|
|
10454
|
-
selectedKeys: new Set([...s.selectedKeys, ...selectedKeys])
|
|
11881
|
+
selectedKeys: /* @__PURE__ */ new Set([...s.selectedKeys, ...selectedKeys])
|
|
10455
11882
|
};
|
|
10456
11883
|
});
|
|
10457
11884
|
},
|
|
@@ -10491,8 +11918,10 @@ function createListData(options) {
|
|
|
10491
11918
|
insertAfter(key, ...values) {
|
|
10492
11919
|
setState((s) => {
|
|
10493
11920
|
let index = s.items.findIndex((item) => getKey(item) === key);
|
|
10494
|
-
if (index === -1)
|
|
10495
|
-
|
|
11921
|
+
if (index === -1) {
|
|
11922
|
+
if (s.items.length === 0) index = 0;
|
|
11923
|
+
else return s;
|
|
11924
|
+
}
|
|
10496
11925
|
return insertItems(s, index + 1, ...values);
|
|
10497
11926
|
});
|
|
10498
11927
|
},
|
|
@@ -10624,6 +12053,8 @@ function moveItems$1(state, indices, toIndex) {
|
|
|
10624
12053
|
*
|
|
10625
12054
|
* Manages state for an immutable tree data structure, and provides
|
|
10626
12055
|
* convenience methods to update the data over time.
|
|
12056
|
+
*
|
|
12057
|
+
* Ported from packages/react-stately/src/data/useTreeData.ts.
|
|
10627
12058
|
*/
|
|
10628
12059
|
/**
|
|
10629
12060
|
* Manages state for an immutable tree data structure, and provides
|
|
@@ -10638,8 +12069,8 @@ function createTreeData(options) {
|
|
|
10638
12069
|
return item.children ?? [];
|
|
10639
12070
|
};
|
|
10640
12071
|
const { initialItems = [], initialSelectedKeys, getKey = defaultGetKey, getChildren = defaultGetChildren } = options;
|
|
10641
|
-
const [treeState, setTreeState] =
|
|
10642
|
-
const [selectedKeys, setSelectedKeys] =
|
|
12072
|
+
const [treeState, setTreeState] = createInternalSignal(buildTree(initialItems, /* @__PURE__ */ new Map(), null, getKey, getChildren));
|
|
12073
|
+
const [selectedKeys, setSelectedKeys] = createInternalSignal(initialSelectedKeys === "all" ? "all" : new Set(initialSelectedKeys || []));
|
|
10643
12074
|
function updateTree(items, key, update, originalMap) {
|
|
10644
12075
|
let node = key != null ? originalMap.get(key) : null;
|
|
10645
12076
|
if (key != null && !node) return {
|
|
@@ -11040,6 +12471,10 @@ function moveItems(state, keys, toParent, toIndex, updateTreeFn, addNodeFn) {
|
|
|
11040
12471
|
* Manages state for an immutable async loaded list data structure, and provides
|
|
11041
12472
|
* convenience methods to update the data over time. Manages loading and error
|
|
11042
12473
|
* states, pagination, and sorting.
|
|
12474
|
+
*
|
|
12475
|
+
* Ported from:
|
|
12476
|
+
* - packages/react-stately/src/data/useAsyncList.ts
|
|
12477
|
+
* - packages/react-stately/src/data/useListData.ts
|
|
11043
12478
|
*/
|
|
11044
12479
|
/**
|
|
11045
12480
|
* Manages state for an immutable async loaded list data structure, and provides
|
|
@@ -11052,7 +12487,7 @@ function createAsyncList(options) {
|
|
|
11052
12487
|
return candidate.id ?? candidate.key ?? String(item);
|
|
11053
12488
|
};
|
|
11054
12489
|
const { load, sort: sortFn, initialSelectedKeys, initialSortDescriptor, getKey = defaultGetKey, initialFilterText = "" } = options;
|
|
11055
|
-
const [state, setState] =
|
|
12490
|
+
const [state, setState] = createInternalSignal({
|
|
11056
12491
|
loadingState: "idle",
|
|
11057
12492
|
items: [],
|
|
11058
12493
|
selectedKeys: initialSelectedKeys === "all" ? "all" : new Set(initialSelectedKeys || []),
|
|
@@ -11089,7 +12524,7 @@ function createAsyncList(options) {
|
|
|
11089
12524
|
const newItems = [...response.items ?? []];
|
|
11090
12525
|
const items = type === "loadingMore" ? [...s.items, ...newItems] : newItems;
|
|
11091
12526
|
let selectedKeys;
|
|
11092
|
-
if (type === "loadingMore") selectedKeys = s.selectedKeys === "all" || response.selectedKeys === "all" ? "all" : new Set([...s.selectedKeys, ...response.selectedKeys ?? []]);
|
|
12527
|
+
if (type === "loadingMore") selectedKeys = s.selectedKeys === "all" || response.selectedKeys === "all" ? "all" : /* @__PURE__ */ new Set([...s.selectedKeys, ...response.selectedKeys ?? []]);
|
|
11093
12528
|
else selectedKeys = response.selectedKeys ? response.selectedKeys === "all" ? "all" : new Set(response.selectedKeys) : s.selectedKeys;
|
|
11094
12529
|
return {
|
|
11095
12530
|
...s,
|
|
@@ -11317,6 +12752,8 @@ function getColorChannels(colorSpace) {
|
|
|
11317
12752
|
/**
|
|
11318
12753
|
* State management for step list components.
|
|
11319
12754
|
* Tracks selected step, completion status, and selectability.
|
|
12755
|
+
*
|
|
12756
|
+
* Ported from packages/react-stately/src/steplist/useStepListState.ts.
|
|
11320
12757
|
*/
|
|
11321
12758
|
/**
|
|
11322
12759
|
* Creates state for a step list component.
|
|
@@ -11332,7 +12769,7 @@ function createStepListState(props) {
|
|
|
11332
12769
|
const disabledKeysSet = createMemo(() => new Set(props.disabledKeys ?? []));
|
|
11333
12770
|
const isDisabled = () => props.isDisabled ?? false;
|
|
11334
12771
|
const isReadOnly = () => props.isReadOnly ?? false;
|
|
11335
|
-
const [lastCompletedStepInternal, setLastCompletedStepInternal] =
|
|
12772
|
+
const [lastCompletedStepInternal, setLastCompletedStepInternal] = createInternalSignal(props.defaultLastCompletedStep ?? null);
|
|
11336
12773
|
const lastCompletedStep = () => {
|
|
11337
12774
|
if (props.lastCompletedStep !== void 0) return props.lastCompletedStep;
|
|
11338
12775
|
return lastCompletedStepInternal();
|
|
@@ -11375,7 +12812,7 @@ function createStepListState(props) {
|
|
|
11375
12812
|
for (const item of currentItems) if (!isStepDisabled(item.key)) return item.key;
|
|
11376
12813
|
return currentItems.length > 0 ? currentItems[0].key : null;
|
|
11377
12814
|
};
|
|
11378
|
-
const [selectedKeyInternal, setSelectedKeyInternal] =
|
|
12815
|
+
const [selectedKeyInternal, setSelectedKeyInternal] = createInternalSignal(props.defaultSelectedKey ?? findDefaultSelectedKey());
|
|
11379
12816
|
const selectedKey = () => {
|
|
11380
12817
|
if (props.selectedKey !== void 0) return props.selectedKey;
|
|
11381
12818
|
return selectedKeyInternal();
|
|
@@ -11394,14 +12831,14 @@ function createStepListState(props) {
|
|
|
11394
12831
|
};
|
|
11395
12832
|
createEffect(() => {
|
|
11396
12833
|
const selKey = selectedKey();
|
|
11397
|
-
if (selKey === null) return;
|
|
12834
|
+
if (selKey === null) return null;
|
|
11398
12835
|
const selIdx = indexMap().get(selKey);
|
|
11399
|
-
if (selIdx === void 0 || selIdx <= 0) return;
|
|
12836
|
+
if (selIdx === void 0 || selIdx <= 0) return null;
|
|
11400
12837
|
const completed = lastCompletedStep();
|
|
11401
|
-
if (selIdx
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
|
|
12838
|
+
if (selIdx <= (completed !== null ? indexMap().get(completed) ?? -1 : -1) + 1) return null;
|
|
12839
|
+
return items()[selIdx - 1]?.key;
|
|
12840
|
+
}, (prevKey) => {
|
|
12841
|
+
if (prevKey !== void 0 && prevKey !== null) setLastCompletedStep(prevKey);
|
|
11405
12842
|
});
|
|
11406
12843
|
return {
|
|
11407
12844
|
selectedKey,
|
|
@@ -11416,6 +12853,6 @@ function createStepListState(props) {
|
|
|
11416
12853
|
};
|
|
11417
12854
|
}
|
|
11418
12855
|
//#endregion
|
|
11419
|
-
export { CalendarDateClass, CalendarDateTimeClass, DEFAULT_VALIDATION_RESULT, DIRECTORY_DRAG_TYPE, DateFormatter, FormValidationContext, GregorianCalendar, ListCollection, SelectionManager, TableCollection, TimeClass, Timer, ToastQueue, TreeCollection, VALID_VALIDITY_STATE, ZonedDateTimeClass, access, canUseDOM, createAsyncList, createAutocompleteState, createCalendar, createCalendarState, createCheckboxGroupState, createColorAreaState, createColorFieldState, createColorSliderState, createColorWheelState, createComboBoxState, createDateFieldState, createDateFieldState as useDateFieldState, createDatePickerState, createDatePickerState as useDatePickerState, createDisclosureGroupState, createDisclosureState, createDragState, createDraggableCollectionState, createDropState, createDroppableCollectionState, createFilteredListState, createFormValidationState, createGridState, createHSBColor, createHSLColor, createId, createIsSSR, createListCollection, createListData, createListState, createMenuState,
|
|
12856
|
+
export { CalendarDateClass, CalendarDateTimeClass, DEFAULT_VALIDATION_RESULT, DIRECTORY_DRAG_TYPE, DateFormatter, FormValidationContext, GregorianCalendar, ListCollection, SelectionManager, TableCollection, TimeClass, Timer, ToastQueue, TokenFieldValue, TreeCollection, VALID_VALIDITY_STATE, ZonedDateTimeClass, access, canUseDOM, createAsyncList, createAutocompleteState, createCalendar, createCalendarState, createCheckboxGroupState, createColorAreaState, createColorFieldState, createColorSliderState, createColorWheelState, createComboBoxState, createDateFieldState, createDateFieldState as useDateFieldState, createDatePickerState, createDatePickerState as useDatePickerState, createDisclosureGroupState, createDisclosureState, createDragState, createDraggableCollectionState, createDropState, createDroppableCollectionState, createFilteredListState, createFormValidationState, createGridState, createHSBColor, createHSLColor, createId, createIsSSR, createListCollection, createListData, createListState, createMenuState, createMenuTriggerState, createMenuTriggerState as useMenuTriggerState, createNumberFieldState, createOverlayTriggerState, createRGBColor, createRadioGroupState, createRangeCalendarState, createRangeCalendarState as useDateRangePickerState, createSearchFieldState, createSelectState, createSelectionState, createSelectionState as useMultipleSelectionState, createSingleSelectListState, createSliderState, createStepListState, createTabListState, createTableCollection, createTableColumnResizeState, createTableState, createTextFieldState, createTimeFieldState, createTimeFieldState as useTimeFieldState, createToastQueue, createToastState, createToggleGroupState, createToggleState, createTokenFieldState, createTooltipTriggerState, createTreeCollection, createTreeData, createTreeGridState, createTreeState, defaultContainsFilter, endOfMonth, endOfWeek, endOfYear, getColorChannels, getDayOfWeek, getItemCount, getKeysForDrag, getLocalTimeZone, getWeeksInMonth, isAccessor, isSameDay, isSameMonth, isSameYear, isServer, isToday, isWeekend, maxDate, mergeValidation, minDate, normalizeColor, now, parseAbsolute, parseAbsoluteToLocal, parseColor, parseDate, parseDateTime, parseTime, parseZonedDateTime, privateValidationStateProp, radioGroupSyncVersion, resetTooltipState, startOfMonth, startOfWeek, startOfYear, toCalendar, toCalendarDate, toCalendarDateTime, toTime, toZoned, today };
|
|
11420
12857
|
|
|
11421
12858
|
//# sourceMappingURL=index.js.map
|