@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
|
@@ -1,11 +1,27 @@
|
|
|
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/data/useTreeData.ts
|
|
14
|
+
|
|
1
15
|
/**
|
|
2
16
|
* createTreeData - SolidJS port of React Spectrum's useTreeData
|
|
3
17
|
*
|
|
4
18
|
* Manages state for an immutable tree data structure, and provides
|
|
5
19
|
* convenience methods to update the data over time.
|
|
20
|
+
*
|
|
21
|
+
* Ported from packages/react-stately/src/data/useTreeData.ts.
|
|
6
22
|
*/
|
|
7
23
|
|
|
8
|
-
import {
|
|
24
|
+
import { createInternalSignal } from "../utils";
|
|
9
25
|
|
|
10
26
|
export type Key = string | number;
|
|
11
27
|
export type Selection = "all" | Set<Key>;
|
|
@@ -94,8 +110,8 @@ export function createTreeData<T>(options: TreeOptions<T>): TreeData<T> {
|
|
|
94
110
|
// Build initial tree
|
|
95
111
|
const initialTree = buildTree(initialItems, new Map(), null, getKey, getChildren);
|
|
96
112
|
|
|
97
|
-
const [treeState, setTreeState] =
|
|
98
|
-
const [selectedKeys, setSelectedKeys] =
|
|
113
|
+
const [treeState, setTreeState] = createInternalSignal<TreeDataState<T>>(initialTree);
|
|
114
|
+
const [selectedKeys, setSelectedKeys] = createInternalSignal<Selection>(
|
|
99
115
|
initialSelectedKeys === "all" ? "all" : new Set(initialSelectedKeys || []),
|
|
100
116
|
);
|
|
101
117
|
|
|
@@ -1,10 +1,26 @@
|
|
|
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
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/disclosure/useDisclosureGroupState.ts
|
|
14
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/disclosure/useDisclosureState.ts
|
|
15
|
+
|
|
1
16
|
/**
|
|
2
17
|
* Disclosure state management for SolidJS
|
|
3
18
|
* Based on @react-stately/disclosure useDisclosureState and useDisclosureGroupState
|
|
4
19
|
*/
|
|
5
20
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
21
|
+
import { createEffect, createMemo } from "solid-js";
|
|
22
|
+
import type { Accessor } from "solid-js";
|
|
23
|
+
import { access, createInternalSignal, readNow, type MaybeAccessor } from "../utils";
|
|
8
24
|
|
|
9
25
|
export interface DisclosureStateProps {
|
|
10
26
|
/** Whether the disclosure is expanded (controlled). */
|
|
@@ -37,7 +53,7 @@ export function createDisclosureState(
|
|
|
37
53
|
): DisclosureState {
|
|
38
54
|
const propsAccessor = () => access(props);
|
|
39
55
|
|
|
40
|
-
const [internalExpanded, setInternalExpanded] =
|
|
56
|
+
const [internalExpanded, setInternalExpanded] = createInternalSignal(
|
|
41
57
|
propsAccessor().defaultExpanded ?? false,
|
|
42
58
|
);
|
|
43
59
|
|
|
@@ -106,7 +122,7 @@ export function createDisclosureGroupState(
|
|
|
106
122
|
): DisclosureGroupState {
|
|
107
123
|
const propsAccessor = () => access(props);
|
|
108
124
|
|
|
109
|
-
const [internalKeys, setInternalKeys] =
|
|
125
|
+
const [internalKeys, setInternalKeys] = createInternalSignal<Set<Key>>(
|
|
110
126
|
new Set(propsAccessor().defaultExpandedKeys ?? []),
|
|
111
127
|
);
|
|
112
128
|
|
|
@@ -124,26 +140,31 @@ export function createDisclosureGroupState(
|
|
|
124
140
|
};
|
|
125
141
|
|
|
126
142
|
// Ensure only one item is expanded if allowsMultipleExpanded is false.
|
|
127
|
-
createEffect(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
143
|
+
createEffect(
|
|
144
|
+
() => {
|
|
145
|
+
const p = propsAccessor();
|
|
146
|
+
return {
|
|
147
|
+
allowsMultiple: p.allowsMultipleExpanded ?? false,
|
|
148
|
+
keys: expandedKeys(),
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
({ allowsMultiple, keys }) => {
|
|
152
|
+
if (!allowsMultiple && keys.size > 1) {
|
|
153
|
+
// Defer the update to avoid an infinite effect loop
|
|
154
|
+
const firstKey = keys.values().next().value;
|
|
155
|
+
if (firstKey != null) {
|
|
156
|
+
queueMicrotask(() => {
|
|
157
|
+
setExpandedKeys(new Set([firstKey]));
|
|
158
|
+
});
|
|
159
|
+
}
|
|
139
160
|
}
|
|
140
|
-
}
|
|
141
|
-
|
|
161
|
+
},
|
|
162
|
+
);
|
|
142
163
|
|
|
143
164
|
const toggleKey = (key: Key) => {
|
|
144
165
|
const p = propsAccessor();
|
|
145
166
|
const allowsMultiple = p.allowsMultipleExpanded ?? false;
|
|
146
|
-
const currentKeys = expandedKeys();
|
|
167
|
+
const currentKeys = p.expandedKeys !== undefined ? expandedKeys() : readNow(internalKeys);
|
|
147
168
|
|
|
148
169
|
let newKeys: Set<Key>;
|
|
149
170
|
if (allowsMultiple) {
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-aria/src/dnd/useDrag.ts
|
|
14
|
+
|
|
1
15
|
/**
|
|
2
16
|
* Drag state management for solid-stately.
|
|
3
17
|
*
|
|
4
18
|
* Provides reactive state for drag operations.
|
|
19
|
+
*
|
|
20
|
+
* Ported from packages/react-aria/src/dnd/useDrag.ts.
|
|
5
21
|
*/
|
|
6
22
|
|
|
7
|
-
import {
|
|
23
|
+
import { createMemo } from "solid-js";
|
|
24
|
+
import type { Accessor } from "solid-js";
|
|
25
|
+
import { createInternalSignal, readNow } from "../utils";
|
|
8
26
|
import type {
|
|
9
27
|
DragItem,
|
|
10
28
|
DragStartEvent,
|
|
@@ -65,7 +83,7 @@ export interface DragState {
|
|
|
65
83
|
export function createDragState(props: Accessor<DragStateOptions>): DragState {
|
|
66
84
|
const getProps = createMemo(() => props());
|
|
67
85
|
|
|
68
|
-
const [isDragging, setIsDragging] =
|
|
86
|
+
const [isDragging, setIsDragging] = createInternalSignal(false);
|
|
69
87
|
|
|
70
88
|
const startDrag = (x: number, y: number) => {
|
|
71
89
|
const p = getProps();
|
|
@@ -84,7 +102,7 @@ export function createDragState(props: Accessor<DragStateOptions>): DragState {
|
|
|
84
102
|
|
|
85
103
|
const moveDrag = (x: number, y: number) => {
|
|
86
104
|
const p = getProps();
|
|
87
|
-
if (!isDragging
|
|
105
|
+
if (!readNow(isDragging) || p.isDisabled) return;
|
|
88
106
|
|
|
89
107
|
if (typeof p.onDragMove === "function") {
|
|
90
108
|
p.onDragMove({
|
|
@@ -97,7 +115,7 @@ export function createDragState(props: Accessor<DragStateOptions>): DragState {
|
|
|
97
115
|
|
|
98
116
|
const endDrag = (x: number, y: number, dropOperation: DropOperation) => {
|
|
99
117
|
const p = getProps();
|
|
100
|
-
if (!isDragging
|
|
118
|
+
if (!readNow(isDragging)) return;
|
|
101
119
|
|
|
102
120
|
setIsDragging(false);
|
|
103
121
|
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/dnd/useDraggableCollectionState.ts
|
|
14
|
+
|
|
1
15
|
/**
|
|
2
16
|
* Draggable collection state management for solid-stately.
|
|
3
17
|
*
|
|
4
18
|
* Provides reactive state for dragging items from a collection.
|
|
19
|
+
*
|
|
20
|
+
* Ported from packages/react-stately/src/dnd/useDraggableCollectionState.ts.
|
|
5
21
|
*/
|
|
6
22
|
|
|
7
|
-
import {
|
|
23
|
+
import { createMemo } from "solid-js";
|
|
24
|
+
import type { Accessor } from "solid-js";
|
|
25
|
+
import { createInternalSignal, readNow } from "../utils";
|
|
8
26
|
import type {
|
|
9
27
|
DragItem,
|
|
10
28
|
DraggableCollectionStartEvent,
|
|
@@ -14,9 +32,20 @@ import type {
|
|
|
14
32
|
DragPreviewRenderer,
|
|
15
33
|
} from "./types";
|
|
16
34
|
|
|
35
|
+
type DragKey = string | number;
|
|
36
|
+
|
|
37
|
+
export interface DraggableCollectionNode {
|
|
38
|
+
parentKey?: DragKey | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface DraggableCollectionLike {
|
|
42
|
+
getItem(key: DragKey): DraggableCollectionNode | null | undefined;
|
|
43
|
+
getKeys?(): Iterable<DragKey>;
|
|
44
|
+
}
|
|
45
|
+
|
|
17
46
|
export interface DraggableCollectionStateOptions<T = object> {
|
|
18
47
|
/** A function that returns the items being dragged. */
|
|
19
|
-
getItems: (keys: Set<
|
|
48
|
+
getItems: (keys: Set<DragKey>) => DragItem[];
|
|
20
49
|
/** Function that returns the allowed drop operations. */
|
|
21
50
|
getAllowedDropOperations?: () => DropOperation[];
|
|
22
51
|
/** Handler that is called when a drag operation is started. */
|
|
@@ -29,17 +58,23 @@ export interface DraggableCollectionStateOptions<T = object> {
|
|
|
29
58
|
isDisabled?: boolean;
|
|
30
59
|
/** Preview renderer function ref. */
|
|
31
60
|
preview?: { current: DragPreviewRenderer | null };
|
|
61
|
+
/** Collection used to drop selected children whose ancestors are also dragging. */
|
|
62
|
+
collection?: DraggableCollectionLike;
|
|
63
|
+
/** Currently selected keys. `"all"` drags every collection key. */
|
|
64
|
+
selectedKeys?: "all" | Iterable<DragKey>;
|
|
65
|
+
/** Returns whether `key` is selected. */
|
|
66
|
+
isSelected?: (key: DragKey) => boolean;
|
|
32
67
|
}
|
|
33
68
|
|
|
34
69
|
export interface DraggableCollectionState {
|
|
35
70
|
/** Whether items are currently being dragged. */
|
|
36
71
|
readonly isDragging: boolean;
|
|
37
72
|
/** The keys of the items being dragged. */
|
|
38
|
-
readonly draggingKeys: Set<
|
|
73
|
+
readonly draggingKeys: Set<DragKey>;
|
|
39
74
|
/** Whether dragging is disabled. */
|
|
40
75
|
readonly isDisabled: boolean;
|
|
41
76
|
/** Start a drag operation with the given keys. */
|
|
42
|
-
startDrag(keys: Set<
|
|
77
|
+
startDrag(keys: Set<DragKey>, x: number, y: number): void;
|
|
43
78
|
/** Update drag position. */
|
|
44
79
|
moveDrag(x: number, y: number): void;
|
|
45
80
|
/** End a drag operation. */
|
|
@@ -47,11 +82,87 @@ export interface DraggableCollectionState {
|
|
|
47
82
|
/** Cancel a drag operation. */
|
|
48
83
|
cancelDrag(): void;
|
|
49
84
|
/** Get the items being dragged for the given keys. */
|
|
50
|
-
getItems(keys: Set<
|
|
85
|
+
getItems(keys: Set<DragKey>): DragItem[];
|
|
51
86
|
/** Get allowed drop operations. */
|
|
52
87
|
getAllowedDropOperations(): DropOperation[];
|
|
53
88
|
/** Preview renderer. */
|
|
54
89
|
readonly preview: { current: DragPreviewRenderer | null } | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Keys that will be dragged with `key`. Mirrors RAC
|
|
92
|
+
* `useDraggableCollectionState.getKeys`: the clicked item, plus every other
|
|
93
|
+
* selected item that is not a descendant of another selected item.
|
|
94
|
+
*/
|
|
95
|
+
getKeysForDrag(key: DragKey): Set<DragKey>;
|
|
96
|
+
/** Returns whether `key` is selected. */
|
|
97
|
+
isSelected(key: DragKey): boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function selectedKeySet(
|
|
101
|
+
selectedKeys: "all" | Iterable<DragKey> | undefined,
|
|
102
|
+
collection: DraggableCollectionLike | undefined,
|
|
103
|
+
): Set<DragKey> | "all" {
|
|
104
|
+
if (selectedKeys === "all") {
|
|
105
|
+
if (!collection?.getKeys) {
|
|
106
|
+
return "all";
|
|
107
|
+
}
|
|
108
|
+
return new Set(collection.getKeys());
|
|
109
|
+
}
|
|
110
|
+
return new Set(selectedKeys ?? []);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* RAC `useDraggableCollectionState.ts` `getKeys`. The clicked item always
|
|
115
|
+
* drags. If it is selected, every selected item that is not a child of another
|
|
116
|
+
* selected item is included.
|
|
117
|
+
*/
|
|
118
|
+
export function getKeysForDrag(
|
|
119
|
+
key: DragKey,
|
|
120
|
+
options: {
|
|
121
|
+
collection?: DraggableCollectionLike;
|
|
122
|
+
selectedKeys?: "all" | Iterable<DragKey>;
|
|
123
|
+
isSelected?: (key: DragKey) => boolean;
|
|
124
|
+
},
|
|
125
|
+
): Set<DragKey> {
|
|
126
|
+
const selected = selectedKeySet(options.selectedKeys, options.collection);
|
|
127
|
+
const isSelected = options.isSelected?.(key) ?? (selected === "all" ? true : selected.has(key));
|
|
128
|
+
if (!isSelected) {
|
|
129
|
+
return new Set([key]);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const keys = new Set<DragKey>();
|
|
133
|
+
const selectedKeys = selected === "all" ? options.collection?.getKeys?.() : selected;
|
|
134
|
+
if (!selectedKeys) {
|
|
135
|
+
keys.add(key);
|
|
136
|
+
return keys;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
for (const currentKey of selectedKeys) {
|
|
140
|
+
const node = options.collection?.getItem(currentKey);
|
|
141
|
+
if (!node) {
|
|
142
|
+
keys.add(currentKey);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
let isChild = false;
|
|
146
|
+
let parentKey = node.parentKey;
|
|
147
|
+
while (parentKey != null) {
|
|
148
|
+
const parentSelected =
|
|
149
|
+
options.isSelected?.(parentKey) ?? (selected === "all" ? true : selected.has(parentKey));
|
|
150
|
+
if (parentSelected) {
|
|
151
|
+
isChild = true;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
const parentNode = options.collection?.getItem(parentKey);
|
|
155
|
+
parentKey = parentNode ? parentNode.parentKey : null;
|
|
156
|
+
}
|
|
157
|
+
if (!isChild) {
|
|
158
|
+
keys.add(currentKey);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (keys.size === 0) {
|
|
163
|
+
keys.add(key);
|
|
164
|
+
}
|
|
165
|
+
return keys;
|
|
55
166
|
}
|
|
56
167
|
|
|
57
168
|
/**
|
|
@@ -65,8 +176,8 @@ export function createDraggableCollectionState<T = object>(
|
|
|
65
176
|
): DraggableCollectionState {
|
|
66
177
|
const getProps = createMemo(() => props());
|
|
67
178
|
|
|
68
|
-
const [isDragging, setIsDragging] =
|
|
69
|
-
const [draggingKeys, setDraggingKeys] =
|
|
179
|
+
const [isDragging, setIsDragging] = createInternalSignal(false);
|
|
180
|
+
const [draggingKeys, setDraggingKeys] = createInternalSignal<Set<string | number>>(new Set());
|
|
70
181
|
|
|
71
182
|
const startDrag = (keys: Set<string | number>, x: number, y: number) => {
|
|
72
183
|
const p = getProps();
|
|
@@ -87,21 +198,21 @@ export function createDraggableCollectionState<T = object>(
|
|
|
87
198
|
|
|
88
199
|
const moveDrag = (x: number, y: number) => {
|
|
89
200
|
const p = getProps();
|
|
90
|
-
if (!isDragging
|
|
201
|
+
if (!readNow(isDragging) || p.isDisabled) return;
|
|
91
202
|
|
|
92
203
|
if (typeof p.onDragMove === "function") {
|
|
93
204
|
p.onDragMove({
|
|
94
205
|
type: "dragmove",
|
|
95
206
|
x,
|
|
96
207
|
y,
|
|
97
|
-
keys: draggingKeys
|
|
208
|
+
keys: readNow(draggingKeys),
|
|
98
209
|
});
|
|
99
210
|
}
|
|
100
211
|
};
|
|
101
212
|
|
|
102
213
|
const endDrag = (x: number, y: number, dropOperation: DropOperation, isInternal: boolean) => {
|
|
103
214
|
const p = getProps();
|
|
104
|
-
const keys = draggingKeys
|
|
215
|
+
const keys = readNow(draggingKeys);
|
|
105
216
|
|
|
106
217
|
setIsDragging(false);
|
|
107
218
|
setDraggingKeys(new Set<string | number>());
|
|
@@ -154,5 +265,21 @@ export function createDraggableCollectionState<T = object>(
|
|
|
154
265
|
cancelDrag,
|
|
155
266
|
getItems,
|
|
156
267
|
getAllowedDropOperations,
|
|
268
|
+
getKeysForDrag: (key: DragKey) => {
|
|
269
|
+
const p = getProps();
|
|
270
|
+
return getKeysForDrag(key, {
|
|
271
|
+
collection: p.collection,
|
|
272
|
+
selectedKeys: p.selectedKeys,
|
|
273
|
+
isSelected: p.isSelected,
|
|
274
|
+
});
|
|
275
|
+
},
|
|
276
|
+
isSelected: (key: DragKey) => {
|
|
277
|
+
const p = getProps();
|
|
278
|
+
if (p.isSelected) {
|
|
279
|
+
return p.isSelected(key);
|
|
280
|
+
}
|
|
281
|
+
const selected = selectedKeySet(p.selectedKeys, p.collection);
|
|
282
|
+
return selected === "all" ? true : selected.has(key);
|
|
283
|
+
},
|
|
157
284
|
};
|
|
158
285
|
}
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-aria/src/dnd/useDrop.ts
|
|
14
|
+
|
|
1
15
|
/**
|
|
2
16
|
* Drop state management for solid-stately.
|
|
3
17
|
*
|
|
4
18
|
* Provides reactive state for drop target operations.
|
|
19
|
+
*
|
|
20
|
+
* Ported from packages/react-aria/src/dnd/useDrop.ts.
|
|
5
21
|
*/
|
|
6
22
|
|
|
7
|
-
import {
|
|
23
|
+
import { createMemo } from "solid-js";
|
|
24
|
+
import type { Accessor } from "solid-js";
|
|
25
|
+
import { createInternalSignal, readNow } from "../utils";
|
|
8
26
|
import type {
|
|
9
27
|
DropItem,
|
|
10
28
|
DropEnterEvent,
|
|
@@ -83,7 +101,7 @@ export interface DropState {
|
|
|
83
101
|
export function createDropState(props: Accessor<DropStateOptions>): DropState {
|
|
84
102
|
const getProps = createMemo(() => props());
|
|
85
103
|
|
|
86
|
-
const [isDropTarget, setIsDropTarget] =
|
|
104
|
+
const [isDropTarget, setIsDropTarget] = createInternalSignal(false);
|
|
87
105
|
|
|
88
106
|
const enterTarget = (x: number, y: number) => {
|
|
89
107
|
const p = getProps();
|
|
@@ -102,7 +120,7 @@ export function createDropState(props: Accessor<DropStateOptions>): DropState {
|
|
|
102
120
|
|
|
103
121
|
const moveInTarget = (x: number, y: number) => {
|
|
104
122
|
const p = getProps();
|
|
105
|
-
if (!isDropTarget
|
|
123
|
+
if (!readNow(isDropTarget) || p.isDisabled) return;
|
|
106
124
|
|
|
107
125
|
if (typeof p.onDropMove === "function") {
|
|
108
126
|
p.onDropMove({
|
|
@@ -1,17 +1,33 @@
|
|
|
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/dnd/useDroppableCollectionState.ts
|
|
14
|
+
|
|
1
15
|
/**
|
|
2
16
|
* Droppable collection state management for solid-stately.
|
|
3
17
|
*
|
|
4
18
|
* Provides reactive state for accepting drops onto a collection.
|
|
19
|
+
*
|
|
20
|
+
* Ported from packages/react-stately/src/dnd/useDroppableCollectionState.ts.
|
|
5
21
|
*/
|
|
6
22
|
|
|
7
|
-
import {
|
|
23
|
+
import { createMemo } from "solid-js";
|
|
24
|
+
import type { Accessor } from "solid-js";
|
|
8
25
|
import type {
|
|
9
26
|
DropItem,
|
|
10
27
|
DropTarget,
|
|
11
28
|
DropOperation,
|
|
12
29
|
DragTypes,
|
|
13
30
|
DroppableCollectionEnterEvent,
|
|
14
|
-
DroppableCollectionMoveEvent,
|
|
15
31
|
DroppableCollectionActivateEvent,
|
|
16
32
|
DroppableCollectionExitEvent,
|
|
17
33
|
DroppableCollectionDropEvent,
|
|
@@ -21,7 +37,19 @@ import type {
|
|
|
21
37
|
DroppableCollectionReorderEvent,
|
|
22
38
|
ItemDropTarget,
|
|
23
39
|
} from "./types";
|
|
24
|
-
import type {
|
|
40
|
+
import type { Key } from "../collections/types";
|
|
41
|
+
import { createInternalSignal } from "../utils";
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The slice of a host collection drop-target state needs: neighbor walk and
|
|
45
|
+
* parent-key identity. Grid/Table/Tree collections are not `CollectionNode`
|
|
46
|
+
* lists (cells exist), so this stays structural instead of `Collection<unknown>`.
|
|
47
|
+
*/
|
|
48
|
+
export interface DroppableCollectionLike {
|
|
49
|
+
getItem(key: Key): { type?: string; parentKey?: Key | null } | null;
|
|
50
|
+
getKeyBefore(key: Key): Key | null;
|
|
51
|
+
getKeyAfter(key: Key): Key | null;
|
|
52
|
+
}
|
|
25
53
|
|
|
26
54
|
export interface DroppableCollectionStateOptions {
|
|
27
55
|
/**
|
|
@@ -59,12 +87,13 @@ export interface DroppableCollectionStateOptions {
|
|
|
59
87
|
shouldAcceptItemDrop?: (target: ItemDropTarget, types: DragTypes) => boolean;
|
|
60
88
|
/**
|
|
61
89
|
* The host collection. Used by the default drop-operation feature detection to
|
|
62
|
-
* confirm a reorder stays within the same parent
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* faithful for
|
|
90
|
+
* confirm a reorder stays within the same parent, to prevent dropping an item
|
|
91
|
+
* onto itself or a descendant, and to treat after(item)/before(next) as one
|
|
92
|
+
* gap. Optional: a flat collection (e.g. a plain ListBox) is always "within
|
|
93
|
+
* parent" and has no descendants, so omitting it is faithful for those hosts
|
|
94
|
+
* except opposite-gap matching.
|
|
66
95
|
*/
|
|
67
|
-
collection?:
|
|
96
|
+
collection?: DroppableCollectionLike;
|
|
68
97
|
/** Whether the droppable collection is disabled. */
|
|
69
98
|
isDisabled?: boolean;
|
|
70
99
|
}
|
|
@@ -111,6 +140,13 @@ export interface DroppableCollectionState {
|
|
|
111
140
|
): DropOperation;
|
|
112
141
|
/** Check if an item drop should be accepted. */
|
|
113
142
|
shouldAcceptItemDrop(target: ItemDropTarget, types: DragTypes): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* RAC `isDropTarget(target)`: whether `target` is the current drop target,
|
|
145
|
+
* including the before/after pair that names the same gap between two items.
|
|
146
|
+
* Named `isDropTargetFor` because `isDropTarget` is already the collection-
|
|
147
|
+
* level boolean on this port.
|
|
148
|
+
*/
|
|
149
|
+
isDropTargetFor(target: DropTarget | null): boolean;
|
|
114
150
|
}
|
|
115
151
|
|
|
116
152
|
/**
|
|
@@ -129,8 +165,8 @@ export function createDroppableCollectionState(
|
|
|
129
165
|
): DroppableCollectionState {
|
|
130
166
|
const getProps = createMemo(() => props());
|
|
131
167
|
|
|
132
|
-
const [isDropTarget, setIsDropTarget] =
|
|
133
|
-
const [target, setTarget] =
|
|
168
|
+
const [isDropTarget, setIsDropTarget] = createInternalSignal(false);
|
|
169
|
+
const [target, setTarget] = createInternalSignal<DropTarget | null>(null);
|
|
134
170
|
|
|
135
171
|
const isAccepted = (types: DragTypes): boolean => {
|
|
136
172
|
const p = getProps();
|
|
@@ -438,6 +474,37 @@ export function createDroppableCollectionState(
|
|
|
438
474
|
return true;
|
|
439
475
|
};
|
|
440
476
|
|
|
477
|
+
const isDropTargetFor = (dropTarget: DropTarget | null): boolean => {
|
|
478
|
+
const current = target();
|
|
479
|
+
if (!current || !dropTarget) return false;
|
|
480
|
+
if (targetsEqual(current, dropTarget)) return true;
|
|
481
|
+
|
|
482
|
+
// RAC `useDroppableCollectionState.ts:216-228`: after(item) and
|
|
483
|
+
// before(next) name the same gap. Collection only mounts one of them.
|
|
484
|
+
if (
|
|
485
|
+
dropTarget.type !== "item" ||
|
|
486
|
+
current.type !== "item" ||
|
|
487
|
+
dropTarget.key === current.key ||
|
|
488
|
+
dropTarget.dropPosition === current.dropPosition ||
|
|
489
|
+
dropTarget.dropPosition === "on" ||
|
|
490
|
+
current.dropPosition === "on"
|
|
491
|
+
) {
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const collection = getProps().collection;
|
|
496
|
+
if (!collection) return false;
|
|
497
|
+
return (
|
|
498
|
+
dropTargetsEqual(getOppositeTarget(collection, dropTarget), current) ||
|
|
499
|
+
dropTargetsEqual(dropTarget, getOppositeTarget(collection, current))
|
|
500
|
+
);
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
const assignTarget = (newTarget: DropTarget | null) => {
|
|
504
|
+
if (isDropTargetFor(newTarget)) return;
|
|
505
|
+
setTarget(newTarget);
|
|
506
|
+
};
|
|
507
|
+
|
|
441
508
|
return {
|
|
442
509
|
get isDropTarget() {
|
|
443
510
|
return isDropTarget();
|
|
@@ -448,7 +515,7 @@ export function createDroppableCollectionState(
|
|
|
448
515
|
get isDisabled() {
|
|
449
516
|
return getProps().isDisabled ?? false;
|
|
450
517
|
},
|
|
451
|
-
setTarget,
|
|
518
|
+
setTarget: assignTarget,
|
|
452
519
|
isAccepted,
|
|
453
520
|
enterTarget,
|
|
454
521
|
moveToTarget,
|
|
@@ -457,6 +524,7 @@ export function createDroppableCollectionState(
|
|
|
457
524
|
drop,
|
|
458
525
|
getDropOperation,
|
|
459
526
|
shouldAcceptItemDrop,
|
|
527
|
+
isDropTargetFor,
|
|
460
528
|
};
|
|
461
529
|
}
|
|
462
530
|
|
|
@@ -464,6 +532,14 @@ export function createDroppableCollectionState(
|
|
|
464
532
|
* Check if two drop targets are equal.
|
|
465
533
|
*/
|
|
466
534
|
function targetsEqual(a: DropTarget, b: DropTarget): boolean {
|
|
535
|
+
return dropTargetsEqual(a, b);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function dropTargetsEqual(
|
|
539
|
+
a: DropTarget | null | undefined,
|
|
540
|
+
b: DropTarget | null | undefined,
|
|
541
|
+
): boolean {
|
|
542
|
+
if (!a || !b) return false;
|
|
467
543
|
if (a.type !== b.type) return false;
|
|
468
544
|
if (a.type === "root" && b.type === "root") return true;
|
|
469
545
|
if (a.type === "item" && b.type === "item") {
|
|
@@ -471,3 +547,33 @@ function targetsEqual(a: DropTarget, b: DropTarget): boolean {
|
|
|
471
547
|
}
|
|
472
548
|
return false;
|
|
473
549
|
}
|
|
550
|
+
|
|
551
|
+
function nextItemKey(
|
|
552
|
+
collection: DroppableCollectionLike,
|
|
553
|
+
fromKey: Key,
|
|
554
|
+
direction: "before" | "after",
|
|
555
|
+
) {
|
|
556
|
+
let key =
|
|
557
|
+
direction === "before" ? collection.getKeyBefore(fromKey) : collection.getKeyAfter(fromKey);
|
|
558
|
+
while (key != null) {
|
|
559
|
+
const node = collection.getItem(key);
|
|
560
|
+
if (node?.type === "item") return key;
|
|
561
|
+
key = direction === "before" ? collection.getKeyBefore(key) : collection.getKeyAfter(key);
|
|
562
|
+
}
|
|
563
|
+
return null;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function getOppositeTarget(
|
|
567
|
+
collection: DroppableCollectionLike,
|
|
568
|
+
target: ItemDropTarget,
|
|
569
|
+
): ItemDropTarget | null {
|
|
570
|
+
if (target.dropPosition === "before") {
|
|
571
|
+
const prevKey = nextItemKey(collection, target.key, "before");
|
|
572
|
+
return prevKey != null ? { type: "item", key: prevKey, dropPosition: "after" } : null;
|
|
573
|
+
}
|
|
574
|
+
if (target.dropPosition === "after") {
|
|
575
|
+
const nextKey = nextItemKey(collection, target.key, "after");
|
|
576
|
+
return nextKey != null ? { type: "item", key: nextKey, dropPosition: "before" } : null;
|
|
577
|
+
}
|
|
578
|
+
return null;
|
|
579
|
+
}
|
package/src/dnd/index.ts
CHANGED
|
@@ -52,8 +52,11 @@ export { createDropState, type DropStateOptions, type DropState } from "./create
|
|
|
52
52
|
|
|
53
53
|
export {
|
|
54
54
|
createDraggableCollectionState,
|
|
55
|
+
getKeysForDrag,
|
|
55
56
|
type DraggableCollectionStateOptions,
|
|
56
57
|
type DraggableCollectionState,
|
|
58
|
+
type DraggableCollectionLike,
|
|
59
|
+
type DraggableCollectionNode,
|
|
57
60
|
} from "./createDraggableCollectionState";
|
|
58
61
|
|
|
59
62
|
export {
|
|
@@ -61,4 +64,5 @@ export {
|
|
|
61
64
|
DIRECTORY_DRAG_TYPE,
|
|
62
65
|
type DroppableCollectionStateOptions,
|
|
63
66
|
type DroppableCollectionState,
|
|
67
|
+
type DroppableCollectionLike,
|
|
64
68
|
} from "./createDroppableCollectionState";
|