@proyecto-viviana/solid-stately 0.5.0 → 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 +3016 -1579
- 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 +23 -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 +60 -42
- package/src/calendar/createDatePickerState.ts +32 -14
- package/src/calendar/createRangeCalendarState.ts +136 -74
- package/src/calendar/createTimeFieldState.ts +25 -6
- package/src/calendar/intl/index.ts +205 -142
- 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 +66 -29
- 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 +890 -855
- 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,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/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
|
|
24
|
+
import { createMemo, createEffect } from "solid-js";
|
|
25
|
+
import type { Accessor } from "solid-js";
|
|
8
26
|
import { access, type MaybeAccessor } from "../utils";
|
|
9
27
|
import { ListCollection } from "./ListCollection";
|
|
10
28
|
import type { SelectionState, SelectionPressEvent } from "./createSelectionState";
|
|
@@ -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
|
});
|
|
@@ -1,9 +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/menu/useMenuTriggerState.ts
|
|
14
|
+
|
|
1
15
|
/**
|
|
2
16
|
* State management for menu components.
|
|
3
|
-
*
|
|
17
|
+
*
|
|
18
|
+
* createMenuTriggerState is ported from
|
|
19
|
+
* packages/react-stately/src/menu/useMenuTriggerState.ts.
|
|
20
|
+
* createMenuState is a local composition of the separately attributed list state.
|
|
4
21
|
*/
|
|
5
22
|
|
|
6
|
-
import { access, type MaybeAccessor } from "../utils";
|
|
23
|
+
import { access, createInternalSignal, type MaybeAccessor } from "../utils";
|
|
24
|
+
|
|
25
|
+
import { createOverlayTriggerState, type OverlayTriggerProps } from "../overlays";
|
|
7
26
|
import { createListState, type ListState, type ListStateProps } from "./createListState";
|
|
8
27
|
import type { Key } from "./types";
|
|
9
28
|
|
|
@@ -84,32 +103,58 @@ export function createMenuState<T = unknown>(
|
|
|
84
103
|
};
|
|
85
104
|
}
|
|
86
105
|
|
|
87
|
-
export
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
/** Handler called when the open state changes. */
|
|
93
|
-
onOpenChange?: (isOpen: boolean) => void;
|
|
106
|
+
export type MenuTriggerType = "press" | "longPress" | "contextMenu";
|
|
107
|
+
|
|
108
|
+
export interface MenuTriggerProps extends OverlayTriggerProps {
|
|
109
|
+
/** How the menu is triggered. */
|
|
110
|
+
trigger?: MenuTriggerType;
|
|
94
111
|
}
|
|
95
112
|
|
|
113
|
+
/** @deprecated Use `MenuTriggerProps`. */
|
|
114
|
+
export interface MenuTriggerStateProps extends MenuTriggerProps {}
|
|
115
|
+
|
|
96
116
|
export interface MenuTriggerState {
|
|
97
117
|
/** Whether the menu is open. */
|
|
98
118
|
readonly isOpen: () => boolean;
|
|
119
|
+
/** Sets whether the menu is open. */
|
|
120
|
+
setOpen(isOpen: boolean): void;
|
|
99
121
|
/** Open the menu. */
|
|
100
|
-
open(): void;
|
|
122
|
+
open(focusStrategy?: "first" | "last" | null): void;
|
|
101
123
|
/** Close the menu. */
|
|
102
124
|
close(): void;
|
|
103
125
|
/** Toggle the menu. */
|
|
104
|
-
toggle(): void;
|
|
126
|
+
toggle(focusStrategy?: "first" | "last" | null): void;
|
|
105
127
|
/** Focus strategy for when the menu opens. */
|
|
106
128
|
readonly focusStrategy: () => "first" | "last" | null;
|
|
107
129
|
/** Set the focus strategy. */
|
|
108
130
|
setFocusStrategy(strategy: "first" | "last" | null): void;
|
|
131
|
+
/** Cursor position relative to the window viewport. */
|
|
132
|
+
readonly point: () => { x: number; y: number } | null;
|
|
133
|
+
/** Sets the cursor position relative to the window viewport. */
|
|
134
|
+
setPoint(point: { x: number; y: number }): void;
|
|
109
135
|
}
|
|
110
136
|
|
|
111
137
|
/**
|
|
112
|
-
* Creates state for a menu trigger
|
|
113
|
-
*
|
|
138
|
+
* Creates state for a menu trigger. Mirrors `@react-stately/menu` `useMenuTriggerState`:
|
|
139
|
+
* overlay open state plus the focus strategy passed through to `createMenu`.
|
|
114
140
|
*/
|
|
115
|
-
export
|
|
141
|
+
export function createMenuTriggerState(
|
|
142
|
+
props: MaybeAccessor<MenuTriggerProps> = {},
|
|
143
|
+
): MenuTriggerState {
|
|
144
|
+
const overlay = createOverlayTriggerState(props);
|
|
145
|
+
const [focusStrategy, setFocusStrategy] = createInternalSignal<"first" | "last" | null>(null);
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
...overlay,
|
|
149
|
+
focusStrategy,
|
|
150
|
+
setFocusStrategy,
|
|
151
|
+
open(strategy: "first" | "last" | null = null) {
|
|
152
|
+
setFocusStrategy(strategy);
|
|
153
|
+
overlay.open();
|
|
154
|
+
},
|
|
155
|
+
toggle(strategy: "first" | "last" | null = null) {
|
|
156
|
+
setFocusStrategy(strategy);
|
|
157
|
+
overlay.toggle();
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -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 { access, createInternalSignal, 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,
|
|
@@ -103,15 +120,15 @@ export function createSelectionState(
|
|
|
103
120
|
const getProps = () => access(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
package/src/collections/types.ts
CHANGED
|
@@ -1,9 +1,42 @@
|
|
|
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 2024 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-types/shared/src/collections.d.ts
|
|
26
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/@react-types/shared/src/selection.d.ts
|
|
27
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-aria/src/collections/BaseCollection.ts
|
|
28
|
+
|
|
1
29
|
/**
|
|
2
30
|
* Core types for collection state management.
|
|
3
|
-
*
|
|
31
|
+
* Collection state types for SolidJS.
|
|
32
|
+
*
|
|
33
|
+
* Ported from:
|
|
34
|
+
* - packages/@react-types/shared/src/collections.d.ts
|
|
35
|
+
* - packages/@react-types/shared/src/selection.d.ts
|
|
36
|
+
* - packages/react-aria/src/collections/BaseCollection.ts
|
|
4
37
|
*/
|
|
5
38
|
|
|
6
|
-
import type { JSX } from "
|
|
39
|
+
import type { JSX } from "@solidjs/web";
|
|
7
40
|
|
|
8
41
|
/** A unique identifier for an item in a collection. */
|
|
9
42
|
export type Key = string | number;
|
package/src/color/Color.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
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/color/Color.ts
|
|
14
|
+
|
|
1
15
|
/**
|
|
2
16
|
* Color class implementation.
|
|
3
|
-
*
|
|
17
|
+
* Ported from packages/react-stately/src/color/Color.ts.
|
|
4
18
|
*
|
|
5
19
|
* Provides color manipulation, conversion, and formatting.
|
|
6
20
|
*/
|
|
@@ -12,15 +26,8 @@ import type {
|
|
|
12
26
|
ColorChannel,
|
|
13
27
|
ColorChannelRange,
|
|
14
28
|
ColorAxes,
|
|
15
|
-
RGBColor,
|
|
16
|
-
HSLColor,
|
|
17
|
-
HSBColor,
|
|
18
29
|
} from "./types";
|
|
19
|
-
import {
|
|
20
|
-
getColorStringForLocale,
|
|
21
|
-
formatColorMessage,
|
|
22
|
-
type ColorStringKey,
|
|
23
|
-
} from "./intl";
|
|
30
|
+
import { getColorStringForLocale, formatColorMessage, type ColorStringKey } from "./intl";
|
|
24
31
|
|
|
25
32
|
// Channel ranges
|
|
26
33
|
const RGB_CHANNEL_RANGE: ColorChannelRange = {
|
|
@@ -77,6 +84,17 @@ function clamp(value: number, min: number, max: number): number {
|
|
|
77
84
|
return Math.min(Math.max(value, min), max);
|
|
78
85
|
}
|
|
79
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Normalizes a hue value to [0, 360).
|
|
89
|
+
* Preserves 360 so linear hue sliders can reach the end of their track.
|
|
90
|
+
*/
|
|
91
|
+
export function normalizeHue(hue: number): number {
|
|
92
|
+
if (hue === 360) {
|
|
93
|
+
return hue;
|
|
94
|
+
}
|
|
95
|
+
return ((hue % 360) + 360) % 360;
|
|
96
|
+
}
|
|
97
|
+
|
|
80
98
|
/**
|
|
81
99
|
* Round to fixed decimal places.
|
|
82
100
|
*/
|
|
@@ -230,7 +248,7 @@ function getOklchHueName(l: number, c: number, h: number, locale: string): [stri
|
|
|
230
248
|
}
|
|
231
249
|
|
|
232
250
|
const name = getColorStringForLocale(hueName as ColorStringKey, locale).toLocaleLowerCase(
|
|
233
|
-
locale
|
|
251
|
+
locale,
|
|
234
252
|
);
|
|
235
253
|
return [name, l];
|
|
236
254
|
}
|
|
@@ -282,7 +300,9 @@ function getColorNameFromColor(color: Color, locale: string): string {
|
|
|
282
300
|
|
|
283
301
|
const alpha = color.getChannelValue("alpha");
|
|
284
302
|
if (alpha < 1) {
|
|
285
|
-
const percentTransparent = new Intl.NumberFormat(locale, { style: "percent" }).format(
|
|
303
|
+
const percentTransparent = new Intl.NumberFormat(locale, { style: "percent" }).format(
|
|
304
|
+
1 - alpha,
|
|
305
|
+
);
|
|
286
306
|
return formatColorMessage("transparentColorName", locale, {
|
|
287
307
|
lightness,
|
|
288
308
|
chroma,
|
|
@@ -565,7 +585,7 @@ class HSLColorImpl implements Color {
|
|
|
565
585
|
constructor(hue: number, saturation: number, lightness: number, alpha: number = 1) {
|
|
566
586
|
// Store raw like upstream HSLColor's constructor — precision comes from the
|
|
567
587
|
// conversion (toFixed(_, 2)); rounding to integers here diverged from S2.
|
|
568
|
-
this.hue = clamp(hue
|
|
588
|
+
this.hue = clamp(normalizeHue(hue), 0, 360);
|
|
569
589
|
this.saturation = clamp(saturation, 0, 100);
|
|
570
590
|
this.lightness = clamp(lightness, 0, 100);
|
|
571
591
|
this.alpha = clamp(toFixed(alpha, 2), 0, 1);
|
|
@@ -585,9 +605,16 @@ class HSLColorImpl implements Color {
|
|
|
585
605
|
}
|
|
586
606
|
case "hsb":
|
|
587
607
|
case "hsba": {
|
|
588
|
-
const
|
|
589
|
-
const
|
|
590
|
-
|
|
608
|
+
const saturation = this.saturation / 100;
|
|
609
|
+
const lightness = this.lightness / 100;
|
|
610
|
+
const brightness = lightness + saturation * Math.min(lightness, 1 - lightness);
|
|
611
|
+
const hsbSaturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness);
|
|
612
|
+
return new HSBColorImpl(
|
|
613
|
+
toFixed(this.hue, 2),
|
|
614
|
+
toFixed(hsbSaturation * 100, 2),
|
|
615
|
+
toFixed(brightness * 100, 2),
|
|
616
|
+
this.alpha,
|
|
617
|
+
);
|
|
591
618
|
}
|
|
592
619
|
default:
|
|
593
620
|
throw new Error(`Unsupported format: ${format}`);
|
|
@@ -690,7 +717,7 @@ class HSLColorImpl implements Color {
|
|
|
690
717
|
return { style: "percent" };
|
|
691
718
|
}
|
|
692
719
|
if (channel === "hue") {
|
|
693
|
-
return { style: "unit", unit: "degree", unitDisplay: "narrow"
|
|
720
|
+
return { style: "unit", unit: "degree", unitDisplay: "narrow" };
|
|
694
721
|
}
|
|
695
722
|
return { style: "percent", maximumFractionDigits: 0 };
|
|
696
723
|
}
|
|
@@ -740,7 +767,7 @@ class HSBColorImpl implements Color {
|
|
|
740
767
|
|
|
741
768
|
constructor(hue: number, saturation: number, brightness: number, alpha: number = 1) {
|
|
742
769
|
// Store raw like upstream HSBColor's constructor (see HSLColorImpl).
|
|
743
|
-
this.hue = clamp(hue
|
|
770
|
+
this.hue = clamp(normalizeHue(hue), 0, 360);
|
|
744
771
|
this.saturation = clamp(saturation, 0, 100);
|
|
745
772
|
this.brightness = clamp(brightness, 0, 100);
|
|
746
773
|
this.alpha = clamp(toFixed(alpha, 2), 0, 1);
|
|
@@ -760,9 +787,19 @@ class HSBColorImpl implements Color {
|
|
|
760
787
|
}
|
|
761
788
|
case "hsl":
|
|
762
789
|
case "hsla": {
|
|
763
|
-
const
|
|
764
|
-
const
|
|
765
|
-
|
|
790
|
+
const saturation = this.saturation / 100;
|
|
791
|
+
const brightness = this.brightness / 100;
|
|
792
|
+
const lightness = brightness * (1 - saturation / 2);
|
|
793
|
+
const hslSaturation =
|
|
794
|
+
lightness === 0 || lightness === 1
|
|
795
|
+
? 0
|
|
796
|
+
: (brightness - lightness) / Math.min(lightness, 1 - lightness);
|
|
797
|
+
return new HSLColorImpl(
|
|
798
|
+
toFixed(this.hue, 2),
|
|
799
|
+
toFixed(hslSaturation * 100, 2),
|
|
800
|
+
toFixed(lightness * 100, 2),
|
|
801
|
+
this.alpha,
|
|
802
|
+
);
|
|
766
803
|
}
|
|
767
804
|
default:
|
|
768
805
|
throw new Error(`Unsupported format: ${format}`);
|
|
@@ -864,7 +901,7 @@ class HSBColorImpl implements Color {
|
|
|
864
901
|
return { style: "percent" };
|
|
865
902
|
}
|
|
866
903
|
if (channel === "hue") {
|
|
867
|
-
return { style: "unit", unit: "degree", unitDisplay: "narrow"
|
|
904
|
+
return { style: "unit", unit: "degree", unitDisplay: "narrow" };
|
|
868
905
|
}
|
|
869
906
|
return { style: "percent", maximumFractionDigits: 0 };
|
|
870
907
|
}
|
|
@@ -958,24 +995,24 @@ export function parseColor(value: string): Color {
|
|
|
958
995
|
|
|
959
996
|
// HSL/HSLA format
|
|
960
997
|
const hslMatch = trimmed.match(
|
|
961
|
-
/^hsla?\(\s*(
|
|
998
|
+
/^hsla?\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*(?:,\s*([-+]?\d+(?:\.\d+)?))?\s*\)$/,
|
|
962
999
|
);
|
|
963
1000
|
if (hslMatch) {
|
|
964
|
-
const h =
|
|
965
|
-
const s =
|
|
966
|
-
const l =
|
|
1001
|
+
const h = parseFloat(hslMatch[1]);
|
|
1002
|
+
const s = parseFloat(hslMatch[2]);
|
|
1003
|
+
const l = parseFloat(hslMatch[3]);
|
|
967
1004
|
const a = hslMatch[4] !== undefined ? parseFloat(hslMatch[4]) : 1;
|
|
968
1005
|
return new HSLColorImpl(h, s, l, a);
|
|
969
1006
|
}
|
|
970
1007
|
|
|
971
1008
|
// HSB/HSBA format
|
|
972
1009
|
const hsbMatch = trimmed.match(
|
|
973
|
-
/^hsba?\(\s*(
|
|
1010
|
+
/^hsba?\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*(?:,\s*([-+]?\d+(?:\.\d+)?))?\s*\)$/,
|
|
974
1011
|
);
|
|
975
1012
|
if (hsbMatch) {
|
|
976
|
-
const h =
|
|
977
|
-
const s =
|
|
978
|
-
const b =
|
|
1013
|
+
const h = parseFloat(hsbMatch[1]);
|
|
1014
|
+
const s = parseFloat(hsbMatch[2]);
|
|
1015
|
+
const b = parseFloat(hsbMatch[3]);
|
|
979
1016
|
const a = hsbMatch[4] !== undefined ? parseFloat(hsbMatch[4]) : 1;
|
|
980
1017
|
return new HSBColorImpl(h, s, b, a);
|
|
981
1018
|
}
|
|
@@ -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/color/useColorAreaState.ts
|
|
14
|
+
|
|
1
15
|
/**
|
|
2
16
|
* ColorArea state management.
|
|
3
17
|
* Based on @react-stately/color useColorAreaState.
|
|
4
18
|
*/
|
|
5
19
|
|
|
6
|
-
import {
|
|
20
|
+
import { createMemo } from "solid-js";
|
|
21
|
+
import type { Accessor } from "solid-js";
|
|
7
22
|
import type { Color, ColorChannel, ColorAxes, ColorSpace } from "./types";
|
|
8
23
|
import { normalizeColor } from "./Color";
|
|
24
|
+
import { createInternalSignal } from "../utils";
|
|
9
25
|
|
|
10
26
|
export interface ColorAreaStateOptions {
|
|
11
27
|
/** The current color value (controlled). */
|
|
@@ -87,8 +103,8 @@ export function createColorAreaState(options: Accessor<ColorAreaStateOptions>):
|
|
|
87
103
|
};
|
|
88
104
|
|
|
89
105
|
// Internal value state
|
|
90
|
-
const [internalValue, setInternalValue] =
|
|
91
|
-
const [isDragging, setIsDragging] =
|
|
106
|
+
const [internalValue, setInternalValue] = createInternalSignal<Color | null>(null);
|
|
107
|
+
const [isDragging, setIsDragging] = createInternalSignal(false);
|
|
92
108
|
|
|
93
109
|
// Initialize internal value
|
|
94
110
|
const initValue = () => {
|
|
@@ -141,10 +157,13 @@ export function createColorAreaState(options: Accessor<ColorAreaStateOptions>):
|
|
|
141
157
|
const xChannelPageStep = createMemo(() => xRange().pageSize);
|
|
142
158
|
const yChannelPageStep = createMemo(() => yRange().pageSize);
|
|
143
159
|
|
|
160
|
+
let lastValue: Color | null = internalValue();
|
|
161
|
+
|
|
144
162
|
// Update value
|
|
145
163
|
const updateValue = (newColor: Color) => {
|
|
146
164
|
const opts = getOptions();
|
|
147
165
|
const nextColor = opts.colorSpace ? newColor.toFormat(opts.colorSpace) : newColor;
|
|
166
|
+
lastValue = nextColor;
|
|
148
167
|
|
|
149
168
|
// Controlled mode
|
|
150
169
|
if (opts.value !== undefined) {
|
|
@@ -245,7 +264,13 @@ export function createColorAreaState(options: Accessor<ColorAreaStateOptions>):
|
|
|
245
264
|
|
|
246
265
|
// Call onChangeEnd when dragging ends
|
|
247
266
|
if (wasDragging && !dragging) {
|
|
248
|
-
getOptions()
|
|
267
|
+
const opts = getOptions();
|
|
268
|
+
const current =
|
|
269
|
+
lastValue ??
|
|
270
|
+
(opts.value !== undefined ? normalizeValue(opts.value) : null) ??
|
|
271
|
+
internalValue() ??
|
|
272
|
+
value();
|
|
273
|
+
opts.onChangeEnd?.(current);
|
|
249
274
|
}
|
|
250
275
|
};
|
|
251
276
|
|