@proyecto-viviana/solid-stately 0.5.1 → 0.6.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE-2.0 +201 -0
- package/NOTICE +91 -0
- package/README.md +59 -29
- 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 +10 -9
- 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 +4 -7
- package/dist/calendar/createDatePickerState.d.ts.map +1 -0
- package/dist/calendar/createRangeCalendarState.d.ts +9 -7
- package/dist/calendar/createRangeCalendarState.d.ts.map +1 -0
- package/dist/calendar/createTimeFieldState.d.ts +5 -24
- 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 +3 -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 +74 -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 +6 -5
- package/dist/color/createColorAreaState.d.ts.map +1 -0
- package/dist/color/createColorFieldState.d.ts +4 -5
- package/dist/color/createColorFieldState.d.ts.map +1 -0
- package/dist/color/createColorSliderState.d.ts +4 -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 +92 -29
- package/dist/combobox/createComboBoxState.d.ts.map +1 -0
- package/dist/combobox/index.d.ts +2 -1
- 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 +44 -11
- 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 +34 -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/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 +4 -3
- 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 +7 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2947 -969
- package/dist/index.js.map +1 -1
- package/dist/menu/index.d.ts +3 -1
- package/dist/menu/index.d.ts.map +1 -0
- package/dist/numberfield/createNumberFieldState.d.ts +37 -9
- 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.d.ts +5 -0
- package/dist/private/flags/flags.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 +100 -33
- package/dist/select/createSelectState.d.ts.map +1 -0
- package/dist/select/index.d.ts +2 -1
- 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 +37 -14
- 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 -13
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/steplist/createStepListState.d.ts +10 -18
- 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 +3 -6
- package/dist/table/createTableState.d.ts.map +1 -0
- package/dist/table/createTreeGridState.d.ts +3 -9
- 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 +37 -3
- 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 +96 -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 +3 -8
- package/dist/tree/createTreeState.d.ts.map +1 -0
- 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 +24 -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 +321 -125
- package/src/calendar/createDateFieldState.ts +45 -31
- package/src/calendar/createDatePickerState.ts +47 -26
- package/src/calendar/createRangeCalendarState.ts +173 -86
- package/src/calendar/createTimeFieldState.ts +26 -7
- package/src/calendar/intl/index.ts +37 -2
- package/src/checkbox/createCheckboxGroupState.ts +45 -13
- package/src/collections/ListCollection.ts +31 -0
- package/src/collections/createListState.ts +27 -10
- package/src/collections/createMenuState.ts +190 -15
- package/src/collections/createSelectionState.ts +33 -13
- package/src/collections/getChildNodes.ts +20 -3
- package/src/collections/index.ts +6 -0
- package/src/collections/types.ts +35 -2
- package/src/color/Color.ts +61 -22
- package/src/color/createColorAreaState.ts +48 -4
- package/src/color/createColorFieldState.ts +114 -38
- package/src/color/createColorSliderState.ts +61 -9
- package/src/color/createColorWheelState.ts +29 -9
- 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 +530 -297
- package/src/combobox/index.ts +4 -0
- package/src/data/createAsyncList.ts +41 -6
- package/src/data/createListData.ts +27 -4
- package/src/data/createTreeData.ts +30 -6
- package/src/disclosure/createDisclosureState.ts +40 -19
- package/src/dnd/createDragState.ts +22 -4
- package/src/dnd/createDraggableCollectionState.ts +145 -11
- package/src/dnd/createDropState.ts +21 -3
- package/src/dnd/createDroppableCollectionState.ts +127 -11
- package/src/dnd/index.ts +4 -0
- package/src/dnd/types.ts +16 -0
- package/src/form/createFormValidationState.ts +69 -37
- package/src/grid/createGridState.ts +196 -111
- package/src/grid/types.ts +22 -1
- package/src/index.ts +33 -2
- package/src/menu/index.ts +7 -0
- package/src/numberfield/createNumberFieldState.ts +247 -98
- package/src/overlays/createOverlayTriggerState.ts +31 -4
- package/src/private/flags/flags.ts +25 -0
- package/src/radio/createRadioGroupState.ts +23 -6
- package/src/searchfield/createSearchFieldState.ts +18 -3
- package/src/select/createSelectState.ts +317 -130
- package/src/select/index.ts +8 -1
- package/src/selection/Selection.ts +15 -1
- package/src/selection/SelectionManager.ts +17 -1
- package/src/selection/createMultipleSelectionState.ts +45 -26
- package/src/slider/createSliderState.ts +243 -104
- package/src/ssr/index.ts +34 -4
- package/src/steplist/createStepListState.ts +184 -130
- package/src/table/TableCollection.ts +14 -0
- package/src/table/createTableColumnResizeState.ts +71 -14
- package/src/table/createTableState.ts +26 -4
- package/src/table/createTreeGridState.ts +22 -6
- package/src/table/types.ts +38 -5
- package/src/tabs/createTabListState.ts +63 -43
- 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 +499 -0
- package/src/tokenfield/createTokenFieldState.ts +88 -0
- package/src/tokenfield/index.ts +15 -0
- package/src/tooltip/createTooltipTriggerState.ts +49 -13
- package/src/tree/TreeCollection.ts +14 -0
- package/src/tree/createTreeState.ts +70 -36
- package/src/tree/types.ts +18 -1
- package/src/utils/index.ts +10 -1
- package/src/utils/owner.ts +20 -0
- package/src/utils/reactivity.ts +53 -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/createTreeState.d.ts.map +0 -1
- 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
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/checkbox/useCheckboxGroupState.ts
|
|
14
|
+
|
|
1
15
|
/**
|
|
2
16
|
* Checkbox group state for Solid Stately
|
|
3
17
|
*
|
|
@@ -7,10 +21,11 @@
|
|
|
7
21
|
* This is a 1:1 port of @react-stately/checkbox's useCheckboxGroupState.
|
|
8
22
|
*/
|
|
9
23
|
|
|
10
|
-
import { createMemo,
|
|
11
|
-
import { type MaybeAccessor
|
|
24
|
+
import { createMemo, Accessor } from "solid-js";
|
|
25
|
+
import { access, createInternalSignal, readNow, type MaybeAccessor } from "../utils";
|
|
12
26
|
import {
|
|
13
27
|
createFormValidationState,
|
|
28
|
+
mergeValidation,
|
|
14
29
|
type FormValidationState,
|
|
15
30
|
type ValidationFunction,
|
|
16
31
|
type ValidationResult,
|
|
@@ -84,6 +99,8 @@ export interface CheckboxGroupState extends Pick<
|
|
|
84
99
|
removeValue(value: string): void;
|
|
85
100
|
/** Toggles a value in the set of selected values. */
|
|
86
101
|
toggleValue(value: string): void;
|
|
102
|
+
/** Records one checkbox's validation and merges it into the group. */
|
|
103
|
+
setInvalid(value: string, validation: ValidationResult): void;
|
|
87
104
|
|
|
88
105
|
/** Current display validation result for the group. */
|
|
89
106
|
readonly displayValidation: Accessor<ValidationResult>;
|
|
@@ -101,7 +118,7 @@ export function createCheckboxGroupState(
|
|
|
101
118
|
const initialProps = getProps();
|
|
102
119
|
const initialValue = initialProps.value ?? initialProps.defaultValue ?? [];
|
|
103
120
|
|
|
104
|
-
const [internalValue, setInternalValue] =
|
|
121
|
+
const [internalValue, setInternalValue] = createInternalSignal<readonly string[]>(initialValue);
|
|
105
122
|
|
|
106
123
|
const controlledValue = createMemo<readonly string[] | undefined>(() => getProps().value);
|
|
107
124
|
|
|
@@ -112,6 +129,8 @@ export function createCheckboxGroupState(
|
|
|
112
129
|
return controlled !== undefined ? controlled : internalValue();
|
|
113
130
|
};
|
|
114
131
|
|
|
132
|
+
const liveValue = (): readonly string[] => (isControlled() ? value() : readNow(internalValue));
|
|
133
|
+
|
|
115
134
|
const isRequired: Accessor<boolean> = () => {
|
|
116
135
|
const p = getProps();
|
|
117
136
|
return !!p.isRequired && value().length === 0;
|
|
@@ -161,9 +180,9 @@ export function createCheckboxGroupState(
|
|
|
161
180
|
return;
|
|
162
181
|
}
|
|
163
182
|
|
|
164
|
-
const
|
|
165
|
-
if (!
|
|
166
|
-
setValue([...
|
|
183
|
+
const snapshot = liveValue();
|
|
184
|
+
if (!snapshot.includes(addVal)) {
|
|
185
|
+
setValue([...snapshot, addVal]);
|
|
167
186
|
}
|
|
168
187
|
}
|
|
169
188
|
|
|
@@ -173,23 +192,35 @@ export function createCheckboxGroupState(
|
|
|
173
192
|
return;
|
|
174
193
|
}
|
|
175
194
|
|
|
176
|
-
const
|
|
177
|
-
if (
|
|
178
|
-
setValue(
|
|
195
|
+
const snapshot = liveValue();
|
|
196
|
+
if (snapshot.includes(removeVal)) {
|
|
197
|
+
setValue(snapshot.filter((v) => v !== removeVal));
|
|
179
198
|
}
|
|
180
199
|
}
|
|
181
200
|
|
|
201
|
+
const invalidValues = new Map<string, ValidationResult>();
|
|
202
|
+
|
|
203
|
+
function setInvalid(itemValue: string, result: ValidationResult): void {
|
|
204
|
+
if (result.isInvalid) {
|
|
205
|
+
invalidValues.set(itemValue, result);
|
|
206
|
+
} else {
|
|
207
|
+
invalidValues.delete(itemValue);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
validation.updateValidation(mergeValidation(...invalidValues.values()));
|
|
211
|
+
}
|
|
212
|
+
|
|
182
213
|
function toggleValue(toggleVal: string): void {
|
|
183
214
|
const p = getProps();
|
|
184
215
|
if (p.isReadOnly || p.isDisabled) {
|
|
185
216
|
return;
|
|
186
217
|
}
|
|
187
218
|
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
190
|
-
setValue(
|
|
219
|
+
const snapshot = liveValue();
|
|
220
|
+
if (snapshot.includes(toggleVal)) {
|
|
221
|
+
setValue(snapshot.filter((v) => v !== toggleVal));
|
|
191
222
|
} else {
|
|
192
|
-
setValue([...
|
|
223
|
+
setValue([...snapshot, toggleVal]);
|
|
193
224
|
}
|
|
194
225
|
}
|
|
195
226
|
|
|
@@ -211,6 +242,7 @@ export function createCheckboxGroupState(
|
|
|
211
242
|
addValue,
|
|
212
243
|
removeValue,
|
|
213
244
|
toggleValue,
|
|
245
|
+
setInvalid,
|
|
214
246
|
realtimeValidation: validation.realtimeValidation,
|
|
215
247
|
displayValidation: validation.displayValidation,
|
|
216
248
|
updateValidation: validation.updateValidation,
|
|
@@ -1,6 +1,37 @@
|
|
|
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
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2020 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
|
+
|
|
25
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-aria/src/collections/BaseCollection.ts
|
|
26
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/list/ListCollection.ts
|
|
27
|
+
|
|
1
28
|
/**
|
|
2
29
|
* A simple list collection implementation.
|
|
3
30
|
* Provides a Collection interface over an array of nodes.
|
|
31
|
+
*
|
|
32
|
+
* Ported from:
|
|
33
|
+
* - packages/react-stately/src/list/ListCollection.ts
|
|
34
|
+
* - packages/react-aria/src/collections/BaseCollection.ts
|
|
4
35
|
*/
|
|
5
36
|
|
|
6
37
|
import type { Collection, CollectionItemLike, CollectionNode, Key } from "./types";
|
|
@@ -1,11 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/list/useListState.ts
|
|
14
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/list/useSingleSelectListState.ts
|
|
15
|
+
|
|
1
16
|
/**
|
|
2
17
|
* State management for list-like components.
|
|
3
18
|
* Combines collection and selection state.
|
|
4
|
-
*
|
|
19
|
+
* Ported from:
|
|
20
|
+
* - packages/react-stately/src/list/useListState.ts
|
|
21
|
+
* - packages/react-stately/src/list/useSingleSelectListState.ts
|
|
5
22
|
*/
|
|
6
23
|
|
|
7
|
-
import { createMemo, createEffect
|
|
8
|
-
import {
|
|
24
|
+
import { createMemo, createEffect } from "solid-js";
|
|
25
|
+
import type { Accessor } from "solid-js";
|
|
26
|
+
import { propsAccessor, type MaybeAccessor } from "../utils";
|
|
9
27
|
import { ListCollection } from "./ListCollection";
|
|
10
28
|
import type { SelectionState, SelectionPressEvent } from "./createSelectionState";
|
|
11
29
|
import { createMultipleSelectionState } from "../selection/createMultipleSelectionState";
|
|
@@ -73,7 +91,7 @@ export interface ListState<T = unknown> extends SelectionState {
|
|
|
73
91
|
export function createListState<T = unknown>(
|
|
74
92
|
props: MaybeAccessor<ListStateProps<T>>,
|
|
75
93
|
): ListState<T> {
|
|
76
|
-
const getProps = (
|
|
94
|
+
const getProps = propsAccessor(props);
|
|
77
95
|
|
|
78
96
|
// Build collection from items (memoized to avoid rebuilding on every access)
|
|
79
97
|
const collection: Accessor<Collection<T>> = createMemo(() => {
|
|
@@ -242,9 +260,8 @@ export function createFilteredListState<T = unknown>(
|
|
|
242
260
|
// forward (then backward) through the previous collection to the nearest
|
|
243
261
|
// surviving, enabled item. Mirrors @react-stately's useFocusedKeyReset.
|
|
244
262
|
let cachedCollection: Collection<T> | null = null;
|
|
245
|
-
createEffect(() => {
|
|
246
|
-
const
|
|
247
|
-
const focusedKey = untrack(() => state.focusedKey());
|
|
263
|
+
createEffect(collection, (coll) => {
|
|
264
|
+
const focusedKey = state.focusedKey();
|
|
248
265
|
if (focusedKey != null && !coll.getItem(focusedKey) && cachedCollection) {
|
|
249
266
|
let key = cachedCollection.getKeyAfter(focusedKey);
|
|
250
267
|
let nextFocusedKey: Key | null = null;
|
|
@@ -267,7 +284,7 @@ export function createFilteredListState<T = unknown>(
|
|
|
267
284
|
key = cachedCollection.getKeyBefore(key);
|
|
268
285
|
}
|
|
269
286
|
}
|
|
270
|
-
|
|
287
|
+
state.setFocusedKey(nextFocusedKey);
|
|
271
288
|
}
|
|
272
289
|
cachedCollection = coll;
|
|
273
290
|
});
|
|
@@ -332,7 +349,7 @@ export interface SingleSelectListState<T = unknown> extends ListState<T> {
|
|
|
332
349
|
export function createSingleSelectListState<T = unknown>(
|
|
333
350
|
props: MaybeAccessor<SingleSelectListStateProps<T>>,
|
|
334
351
|
): SingleSelectListState<T> {
|
|
335
|
-
const getProps = (
|
|
352
|
+
const getProps = propsAccessor(props);
|
|
336
353
|
|
|
337
354
|
// Convert single selection props to multiple selection props
|
|
338
355
|
const listState = createListState<T>({
|
|
@@ -359,7 +376,7 @@ export function createSingleSelectListState<T = unknown>(
|
|
|
359
376
|
allowDuplicateSelectionEvents: true,
|
|
360
377
|
get selectedKeys() {
|
|
361
378
|
const key = getProps().selectedKey;
|
|
362
|
-
return key != null ? [key] : [];
|
|
379
|
+
return key !== undefined ? (key != null ? [key] : []) : undefined;
|
|
363
380
|
},
|
|
364
381
|
get defaultSelectedKeys() {
|
|
365
382
|
const key = getProps().defaultSelectedKey;
|
|
@@ -1,9 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2023 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
|
+
|
|
25
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/menu/useMenuTriggerState.ts
|
|
26
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/menu/useSubmenuTriggerState.ts
|
|
27
|
+
|
|
1
28
|
/**
|
|
2
29
|
* State management for menu components.
|
|
3
|
-
*
|
|
30
|
+
*
|
|
31
|
+
* createMenuTriggerState is ported from
|
|
32
|
+
* packages/react-stately/src/menu/useMenuTriggerState.ts.
|
|
33
|
+
* createSubmenuTriggerState is ported from
|
|
34
|
+
* packages/react-stately/src/menu/useSubmenuTriggerState.ts.
|
|
35
|
+
* createMenuState is a local composition of the separately attributed list state.
|
|
4
36
|
*/
|
|
5
37
|
|
|
6
|
-
import {
|
|
38
|
+
import { createInternalSignal, propsAccessor, type MaybeAccessor } from "../utils";
|
|
39
|
+
|
|
40
|
+
import { createOverlayTriggerState, type OverlayTriggerProps } from "../overlays";
|
|
7
41
|
import { createListState, type ListState, type ListStateProps } from "./createListState";
|
|
8
42
|
import type { Key } from "./types";
|
|
9
43
|
|
|
@@ -26,7 +60,7 @@ export interface MenuState<T = unknown> extends ListState<T> {
|
|
|
26
60
|
export function createMenuState<T = unknown>(
|
|
27
61
|
props: MaybeAccessor<MenuStateProps<T>>,
|
|
28
62
|
): MenuState<T> {
|
|
29
|
-
const getProps = (
|
|
63
|
+
const getProps = propsAccessor(props);
|
|
30
64
|
|
|
31
65
|
// Menus default to action-only items, but can opt into single or multiple selection.
|
|
32
66
|
const listState = createListState<T>({
|
|
@@ -84,32 +118,173 @@ export function createMenuState<T = unknown>(
|
|
|
84
118
|
};
|
|
85
119
|
}
|
|
86
120
|
|
|
87
|
-
export
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
/** Handler called when the open state changes. */
|
|
93
|
-
onOpenChange?: (isOpen: boolean) => void;
|
|
121
|
+
export type MenuTriggerType = "press" | "longPress" | "contextMenu";
|
|
122
|
+
|
|
123
|
+
export interface MenuTriggerProps extends OverlayTriggerProps {
|
|
124
|
+
/** How the menu is triggered. */
|
|
125
|
+
trigger?: MenuTriggerType;
|
|
94
126
|
}
|
|
95
127
|
|
|
128
|
+
/** @deprecated Use `MenuTriggerProps`. */
|
|
129
|
+
export interface MenuTriggerStateProps extends MenuTriggerProps {}
|
|
130
|
+
|
|
96
131
|
export interface MenuTriggerState {
|
|
97
132
|
/** Whether the menu is open. */
|
|
98
133
|
readonly isOpen: () => boolean;
|
|
134
|
+
/** Sets whether the menu is open. */
|
|
135
|
+
setOpen(isOpen: boolean): void;
|
|
99
136
|
/** Open the menu. */
|
|
100
|
-
open(): void;
|
|
137
|
+
open(focusStrategy?: "first" | "last" | null): void;
|
|
101
138
|
/** Close the menu. */
|
|
102
139
|
close(): void;
|
|
103
140
|
/** Toggle the menu. */
|
|
104
|
-
toggle(): void;
|
|
141
|
+
toggle(focusStrategy?: "first" | "last" | null): void;
|
|
105
142
|
/** Focus strategy for when the menu opens. */
|
|
106
143
|
readonly focusStrategy: () => "first" | "last" | null;
|
|
107
144
|
/** Set the focus strategy. */
|
|
108
145
|
setFocusStrategy(strategy: "first" | "last" | null): void;
|
|
146
|
+
/** Cursor position relative to the window viewport. */
|
|
147
|
+
readonly point: () => { x: number; y: number } | null;
|
|
148
|
+
/** Sets the cursor position relative to the window viewport. */
|
|
149
|
+
setPoint(point: { x: number; y: number }): void;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface RootMenuTriggerState extends MenuTriggerState {
|
|
153
|
+
/** Opens a submenu tied to a menu item at a level. */
|
|
154
|
+
openSubmenu(triggerKey: Key, level: number): void;
|
|
155
|
+
/** Closes a submenu tied to a menu item at a level. */
|
|
156
|
+
closeSubmenu(triggerKey: Key, level: number): void;
|
|
157
|
+
/**
|
|
158
|
+
* Open submenu trigger keys. The index matches the submenu level.
|
|
159
|
+
*/
|
|
160
|
+
readonly expandedKeysStack: () => Key[];
|
|
109
161
|
}
|
|
110
162
|
|
|
111
163
|
/**
|
|
112
|
-
* Creates state for a menu trigger
|
|
113
|
-
*
|
|
164
|
+
* Creates state for a menu trigger. Mirrors `@react-stately/menu` `useMenuTriggerState`:
|
|
165
|
+
* overlay open state, the focus strategy passed through to `createMenu`, and the
|
|
166
|
+
* expanded submenu stack.
|
|
114
167
|
*/
|
|
115
|
-
export
|
|
168
|
+
export function createMenuTriggerState(
|
|
169
|
+
props: MaybeAccessor<MenuTriggerProps> = {},
|
|
170
|
+
): RootMenuTriggerState {
|
|
171
|
+
const overlay = createOverlayTriggerState(props);
|
|
172
|
+
const [focusStrategy, setFocusStrategy] = createInternalSignal<"first" | "last" | null>(null);
|
|
173
|
+
const [expandedKeysStack, setExpandedKeysStack] = createInternalSignal<Key[]>([]);
|
|
174
|
+
|
|
175
|
+
const openSubmenu = (triggerKey: Key, level: number) => {
|
|
176
|
+
setExpandedKeysStack((oldStack) => {
|
|
177
|
+
if (level > oldStack.length) {
|
|
178
|
+
return oldStack;
|
|
179
|
+
}
|
|
180
|
+
return [...oldStack.slice(0, level), triggerKey];
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const closeSubmenu = (triggerKey: Key, level: number) => {
|
|
185
|
+
setExpandedKeysStack((oldStack) => {
|
|
186
|
+
if (oldStack[level] !== triggerKey) {
|
|
187
|
+
return oldStack;
|
|
188
|
+
}
|
|
189
|
+
return oldStack.slice(0, level);
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const close = () => {
|
|
194
|
+
setExpandedKeysStack([]);
|
|
195
|
+
overlay.close();
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
return {
|
|
199
|
+
...overlay,
|
|
200
|
+
focusStrategy,
|
|
201
|
+
setFocusStrategy,
|
|
202
|
+
open(strategy: "first" | "last" | null = null) {
|
|
203
|
+
setFocusStrategy(strategy);
|
|
204
|
+
overlay.open();
|
|
205
|
+
},
|
|
206
|
+
toggle(strategy: "first" | "last" | null = null) {
|
|
207
|
+
setFocusStrategy(strategy);
|
|
208
|
+
overlay.toggle();
|
|
209
|
+
},
|
|
210
|
+
close,
|
|
211
|
+
expandedKeysStack,
|
|
212
|
+
openSubmenu,
|
|
213
|
+
closeSubmenu,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface SubmenuTriggerProps {
|
|
218
|
+
/** Key of the trigger item. */
|
|
219
|
+
triggerKey: Key;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface SubmenuTriggerState {
|
|
223
|
+
/** Whether the submenu is currently open. */
|
|
224
|
+
readonly isOpen: () => boolean;
|
|
225
|
+
/** Controls which item will be auto focused when the submenu opens. */
|
|
226
|
+
readonly focusStrategy: () => "first" | "last" | null;
|
|
227
|
+
/** The level of the submenu, frozen when the state is created. */
|
|
228
|
+
readonly submenuLevel: number;
|
|
229
|
+
/** Opens the submenu. */
|
|
230
|
+
open(focusStrategy?: "first" | "last" | null): void;
|
|
231
|
+
/** Closes the submenu. */
|
|
232
|
+
close(): void;
|
|
233
|
+
/** Closes the root menu and every submenu in the tree. */
|
|
234
|
+
closeAll(): void;
|
|
235
|
+
/** Toggles the submenu. */
|
|
236
|
+
toggle(focusStrategy?: "first" | "last" | null): void;
|
|
237
|
+
/** @private Placeholder so this state can sit where an overlay trigger state sits. */
|
|
238
|
+
setOpen(): void;
|
|
239
|
+
/** Submenus do not track a cursor point. */
|
|
240
|
+
readonly point: null;
|
|
241
|
+
/** @private */
|
|
242
|
+
setPoint(): void;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Creates state for a submenu trigger. Mirrors `@react-stately/menu`
|
|
247
|
+
* `useSubmenuTriggerState`: open state is the root stack entry at this level.
|
|
248
|
+
*/
|
|
249
|
+
export function createSubmenuTriggerState(
|
|
250
|
+
props: MaybeAccessor<SubmenuTriggerProps>,
|
|
251
|
+
state: RootMenuTriggerState,
|
|
252
|
+
): SubmenuTriggerState {
|
|
253
|
+
const getProps = propsAccessor(props);
|
|
254
|
+
const submenuLevel = state.expandedKeysStack().length;
|
|
255
|
+
const [focusStrategy, setFocusStrategy] = createInternalSignal<"first" | "last" | null>(null);
|
|
256
|
+
|
|
257
|
+
const isOpen = () => state.expandedKeysStack()[submenuLevel] === getProps().triggerKey;
|
|
258
|
+
|
|
259
|
+
const open = (strategy?: "first" | "last" | null) => {
|
|
260
|
+
setFocusStrategy(strategy ?? null);
|
|
261
|
+
state.openSubmenu(getProps().triggerKey, submenuLevel);
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
const close = () => {
|
|
265
|
+
setFocusStrategy(null);
|
|
266
|
+
state.closeSubmenu(getProps().triggerKey, submenuLevel);
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const toggle = (strategy?: "first" | "last" | null) => {
|
|
270
|
+
setFocusStrategy(strategy ?? null);
|
|
271
|
+
if (isOpen()) {
|
|
272
|
+
close();
|
|
273
|
+
} else {
|
|
274
|
+
open(strategy);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
return {
|
|
279
|
+
focusStrategy,
|
|
280
|
+
isOpen,
|
|
281
|
+
open,
|
|
282
|
+
close,
|
|
283
|
+
closeAll: () => state.close(),
|
|
284
|
+
submenuLevel,
|
|
285
|
+
setOpen() {},
|
|
286
|
+
toggle,
|
|
287
|
+
point: null,
|
|
288
|
+
setPoint() {},
|
|
289
|
+
};
|
|
290
|
+
}
|
|
@@ -1,14 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/selection/SelectionManager.ts
|
|
14
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/selection/useMultipleSelectionState.ts
|
|
15
|
+
|
|
1
16
|
/**
|
|
2
17
|
* Selection state management for collections.
|
|
3
|
-
*
|
|
18
|
+
* Ported from:
|
|
19
|
+
* - packages/react-stately/src/selection/useMultipleSelectionState.ts
|
|
20
|
+
* - packages/react-stately/src/selection/SelectionManager.ts
|
|
4
21
|
*/
|
|
5
22
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
23
|
+
import { createMemo } from "solid-js";
|
|
24
|
+
import type { Accessor } from "solid-js";
|
|
25
|
+
import { createInternalSignal, propsAccessor, readNow, type MaybeAccessor } from "../utils";
|
|
8
26
|
import type {
|
|
9
27
|
Collection,
|
|
10
28
|
DisabledBehavior,
|
|
11
|
-
FocusStrategy,
|
|
12
29
|
Key,
|
|
13
30
|
Selection,
|
|
14
31
|
SelectionBehavior,
|
|
@@ -100,18 +117,18 @@ export interface SelectionPressEvent {
|
|
|
100
117
|
export function createSelectionState(
|
|
101
118
|
props: MaybeAccessor<SelectionStateProps> = {},
|
|
102
119
|
): SelectionState {
|
|
103
|
-
const getProps = (
|
|
120
|
+
const getProps = propsAccessor(props);
|
|
104
121
|
|
|
105
122
|
// Selection behavior state
|
|
106
|
-
const [internalBehavior, setInternalBehavior] =
|
|
123
|
+
const [internalBehavior, setInternalBehavior] = createInternalSignal<SelectionBehavior>("toggle");
|
|
107
124
|
|
|
108
125
|
// Internal selection state
|
|
109
|
-
const [internalSelectedKeys, setInternalSelectedKeys] =
|
|
126
|
+
const [internalSelectedKeys, setInternalSelectedKeys] = createInternalSignal<Selection>(
|
|
110
127
|
getInitialSelection(getProps().defaultSelectedKeys),
|
|
111
128
|
);
|
|
112
129
|
|
|
113
130
|
// Track anchor for range selection
|
|
114
|
-
const [anchorKey, setAnchorKey] =
|
|
131
|
+
const [anchorKey, setAnchorKey] = createInternalSignal<Key | null>(null);
|
|
115
132
|
|
|
116
133
|
// Computed values
|
|
117
134
|
const selectionMode: Accessor<SelectionMode> = () => getProps().selectionMode ?? "none";
|
|
@@ -124,13 +141,13 @@ export function createSelectionState(
|
|
|
124
141
|
return getProps().disallowEmptySelection ?? false;
|
|
125
142
|
};
|
|
126
143
|
|
|
127
|
-
const selectedKeys: Accessor<Selection> =
|
|
144
|
+
const selectedKeys: Accessor<Selection> = () => {
|
|
128
145
|
const p = getProps();
|
|
129
146
|
if (p.selectedKeys !== undefined) {
|
|
130
147
|
return normalizeSelection(p.selectedKeys);
|
|
131
148
|
}
|
|
132
149
|
return internalSelectedKeys();
|
|
133
|
-
}
|
|
150
|
+
};
|
|
134
151
|
|
|
135
152
|
const disabledKeys: Accessor<Set<Key>> = createMemo(() => {
|
|
136
153
|
const keys = getProps().disabledKeys;
|
|
@@ -151,8 +168,11 @@ export function createSelectionState(
|
|
|
151
168
|
};
|
|
152
169
|
|
|
153
170
|
// Methods
|
|
171
|
+
const liveSelectedKeys = (): Selection =>
|
|
172
|
+
getProps().selectedKeys !== undefined ? selectedKeys() : readNow(internalSelectedKeys);
|
|
173
|
+
|
|
154
174
|
const isSelected = (key: Key): boolean => {
|
|
155
|
-
const keys =
|
|
175
|
+
const keys = liveSelectedKeys();
|
|
156
176
|
if (keys === "all") return true;
|
|
157
177
|
return keys.has(key);
|
|
158
178
|
};
|
|
@@ -171,7 +191,7 @@ export function createSelectionState(
|
|
|
171
191
|
}
|
|
172
192
|
|
|
173
193
|
// Uncontrolled mode
|
|
174
|
-
const current = internalSelectedKeys
|
|
194
|
+
const current = readNow(internalSelectedKeys);
|
|
175
195
|
const isDifferent =
|
|
176
196
|
current === "all" ||
|
|
177
197
|
newSelection === "all" ||
|
|
@@ -188,7 +208,7 @@ export function createSelectionState(
|
|
|
188
208
|
if (isDisabled(key)) return;
|
|
189
209
|
if (selectionMode() === "none") return;
|
|
190
210
|
|
|
191
|
-
const current =
|
|
211
|
+
const current = liveSelectedKeys();
|
|
192
212
|
|
|
193
213
|
if (selectionMode() === "single") {
|
|
194
214
|
if (isSelected(key) && !disallowEmptySelection()) {
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/collections/getChildNodes.ts
|
|
14
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/collections/getItemCount.ts
|
|
15
|
+
|
|
1
16
|
/**
|
|
2
17
|
* Helpers for traversing collection nodes and comparing their document order.
|
|
3
18
|
*
|
|
4
|
-
*
|
|
19
|
+
* Ported from:
|
|
20
|
+
* - packages/react-stately/src/collections/getChildNodes.ts
|
|
21
|
+
* - packages/react-stately/src/collections/getItemCount.ts
|
|
5
22
|
*/
|
|
6
23
|
|
|
7
24
|
import type { Collection, CollectionNode } from "./types";
|
|
@@ -51,8 +68,8 @@ const itemCountCache = new WeakMap<Collection<unknown>, number>();
|
|
|
51
68
|
|
|
52
69
|
/**
|
|
53
70
|
* Counts the item nodes (recursing into sections, ignoring section headers and
|
|
54
|
-
* other non-item nodes) in a collection.
|
|
55
|
-
*
|
|
71
|
+
* other non-item nodes) in a collection. Ported from
|
|
72
|
+
* packages/react-stately/src/collections/getItemCount.ts; used by createOption to populate
|
|
56
73
|
* `aria-setsize` when the listbox is virtualized. Cached per (immutable)
|
|
57
74
|
* collection identity, exactly like upstream.
|
|
58
75
|
*/
|
package/src/collections/index.ts
CHANGED
|
@@ -46,8 +46,14 @@ export {
|
|
|
46
46
|
export {
|
|
47
47
|
createMenuState,
|
|
48
48
|
createMenuTriggerState,
|
|
49
|
+
createSubmenuTriggerState,
|
|
49
50
|
type MenuStateProps,
|
|
50
51
|
type MenuState,
|
|
52
|
+
type MenuTriggerType,
|
|
53
|
+
type MenuTriggerProps,
|
|
51
54
|
type MenuTriggerStateProps,
|
|
52
55
|
type MenuTriggerState,
|
|
56
|
+
type RootMenuTriggerState,
|
|
57
|
+
type SubmenuTriggerProps,
|
|
58
|
+
type SubmenuTriggerState,
|
|
53
59
|
} from "./createMenuState";
|