@proyecto-viviana/solid-stately 0.5.1 → 0.6.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE-2.0 +201 -0
- package/NOTICE +91 -0
- package/README.md +59 -29
- package/dist/autocomplete/createAutocompleteState.d.ts +2 -1
- package/dist/autocomplete/createAutocompleteState.d.ts.map +1 -0
- package/dist/autocomplete/index.d.ts +1 -0
- package/dist/autocomplete/index.d.ts.map +1 -0
- package/dist/calendar/IncompleteDate.d.ts +2 -1
- package/dist/calendar/IncompleteDate.d.ts.map +1 -0
- package/dist/calendar/createCalendarState.d.ts +10 -9
- package/dist/calendar/createCalendarState.d.ts.map +1 -0
- package/dist/calendar/createDateFieldState.d.ts +4 -20
- package/dist/calendar/createDateFieldState.d.ts.map +1 -0
- package/dist/calendar/createDatePickerState.d.ts +4 -7
- package/dist/calendar/createDatePickerState.d.ts.map +1 -0
- package/dist/calendar/createRangeCalendarState.d.ts +9 -7
- package/dist/calendar/createRangeCalendarState.d.ts.map +1 -0
- package/dist/calendar/createTimeFieldState.d.ts +5 -24
- package/dist/calendar/createTimeFieldState.d.ts.map +1 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.d.ts.map +1 -0
- package/dist/calendar/intl/index.d.ts +1 -0
- package/dist/calendar/intl/index.d.ts.map +1 -0
- package/dist/checkbox/createCheckboxGroupState.d.ts +3 -0
- package/dist/checkbox/createCheckboxGroupState.d.ts.map +1 -0
- package/dist/checkbox/index.d.ts +1 -0
- package/dist/checkbox/index.d.ts.map +1 -0
- package/dist/collections/ListCollection.d.ts +5 -0
- package/dist/collections/ListCollection.d.ts.map +1 -0
- package/dist/collections/createListState.d.ts +2 -6
- package/dist/collections/createListState.d.ts.map +1 -0
- package/dist/collections/createMenuState.d.ts +74 -13
- package/dist/collections/createMenuState.d.ts.map +1 -0
- package/dist/collections/createSelectionState.d.ts +2 -5
- package/dist/collections/createSelectionState.d.ts.map +1 -0
- package/dist/collections/getChildNodes.d.ts +6 -3
- package/dist/collections/getChildNodes.d.ts.map +1 -0
- package/dist/collections/index.d.ts +2 -1
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/types.d.ts +36 -2
- package/dist/collections/types.d.ts.map +1 -0
- package/dist/color/Color.d.ts +7 -1
- package/dist/color/Color.d.ts.map +1 -0
- package/dist/color/createColorAreaState.d.ts +6 -5
- package/dist/color/createColorAreaState.d.ts.map +1 -0
- package/dist/color/createColorFieldState.d.ts +4 -5
- package/dist/color/createColorFieldState.d.ts.map +1 -0
- package/dist/color/createColorSliderState.d.ts +4 -5
- package/dist/color/createColorSliderState.d.ts.map +1 -0
- package/dist/color/createColorWheelState.d.ts +2 -5
- package/dist/color/createColorWheelState.d.ts.map +1 -0
- package/dist/color/getColorChannels.d.ts +3 -0
- package/dist/color/getColorChannels.d.ts.map +1 -0
- package/dist/color/index.d.ts +2 -1
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/intl/index.d.ts +1 -0
- package/dist/color/intl/index.d.ts.map +1 -0
- package/dist/color/types.d.ts +2 -1
- package/dist/color/types.d.ts.map +1 -0
- package/dist/combobox/createComboBoxState.d.ts +92 -29
- package/dist/combobox/createComboBoxState.d.ts.map +1 -0
- package/dist/combobox/index.d.ts +2 -1
- package/dist/combobox/index.d.ts.map +1 -0
- package/dist/data/createAsyncList.d.ts +1 -7
- package/dist/data/createAsyncList.d.ts.map +1 -0
- package/dist/data/createListData.d.ts +1 -6
- package/dist/data/createListData.d.ts.map +1 -0
- package/dist/data/createTreeData.d.ts +1 -6
- package/dist/data/createTreeData.d.ts.map +1 -0
- package/dist/data/index.d.ts +1 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/datepicker/index.d.ts +1 -0
- package/dist/datepicker/index.d.ts.map +1 -0
- package/dist/disclosure/createDisclosureState.d.ts +2 -5
- package/dist/disclosure/createDisclosureState.d.ts.map +1 -0
- package/dist/disclosure/index.d.ts +1 -0
- package/dist/disclosure/index.d.ts.map +1 -0
- package/dist/dnd/createDragState.d.ts +2 -6
- package/dist/dnd/createDragState.d.ts.map +1 -0
- package/dist/dnd/createDraggableCollectionState.d.ts +44 -11
- package/dist/dnd/createDraggableCollectionState.d.ts.map +1 -0
- package/dist/dnd/createDropState.d.ts +2 -6
- package/dist/dnd/createDropState.d.ts.map +1 -0
- package/dist/dnd/createDroppableCollectionState.d.ts +34 -11
- package/dist/dnd/createDroppableCollectionState.d.ts.map +1 -0
- package/dist/dnd/index.d.ts +3 -2
- package/dist/dnd/index.d.ts.map +1 -0
- package/dist/dnd/types.d.ts +17 -0
- package/dist/dnd/types.d.ts.map +1 -0
- package/dist/form/createFormValidationState.d.ts +2 -9
- package/{src → dist}/form/createFormValidationState.d.ts.map +1 -1
- package/dist/form/index.d.ts +1 -0
- package/dist/form/index.d.ts.map +1 -0
- package/dist/grid/createGridState.d.ts +4 -3
- package/dist/grid/createGridState.d.ts.map +1 -0
- package/dist/grid/index.d.ts +1 -0
- package/dist/grid/index.d.ts.map +1 -0
- package/dist/grid/types.d.ts +23 -1
- package/dist/grid/types.d.ts.map +1 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2947 -969
- package/dist/index.js.map +1 -1
- package/dist/menu/index.d.ts +3 -1
- package/dist/menu/index.d.ts.map +1 -0
- package/dist/numberfield/createNumberFieldState.d.ts +37 -9
- package/dist/numberfield/createNumberFieldState.d.ts.map +1 -0
- package/dist/numberfield/index.d.ts +1 -0
- package/dist/numberfield/index.d.ts.map +1 -0
- package/dist/overlays/createOverlayTriggerState.d.ts +12 -1
- package/dist/overlays/createOverlayTriggerState.d.ts.map +1 -0
- package/dist/overlays/index.d.ts +1 -0
- package/dist/overlays/index.d.ts.map +1 -0
- package/dist/private/flags/flags.d.ts +5 -0
- package/dist/private/flags/flags.d.ts.map +1 -0
- package/dist/private/flags/flags.js +26 -0
- package/dist/private/flags/flags.js.map +1 -0
- package/dist/radio/createRadioGroupState.d.ts +1 -0
- package/dist/radio/createRadioGroupState.d.ts.map +1 -0
- package/dist/radio/index.d.ts +1 -0
- package/dist/radio/index.d.ts.map +1 -0
- package/dist/searchfield/createSearchFieldState.d.ts +2 -5
- package/dist/searchfield/createSearchFieldState.d.ts.map +1 -0
- package/dist/searchfield/index.d.ts +1 -0
- package/dist/searchfield/index.d.ts.map +1 -0
- package/dist/select/createSelectState.d.ts +100 -33
- package/dist/select/createSelectState.d.ts.map +1 -0
- package/dist/select/index.d.ts +2 -1
- package/dist/select/index.d.ts.map +1 -0
- package/dist/selection/Selection.d.ts +2 -1
- package/dist/selection/Selection.d.ts.map +1 -0
- package/dist/selection/SelectionManager.d.ts +1 -19
- package/dist/selection/SelectionManager.d.ts.map +1 -0
- package/dist/selection/createMultipleSelectionState.d.ts +2 -13
- package/dist/selection/createMultipleSelectionState.d.ts.map +1 -0
- package/dist/selection/index.d.ts +1 -0
- package/dist/selection/index.d.ts.map +1 -0
- package/dist/slider/createSliderState.d.ts +37 -14
- package/dist/slider/createSliderState.d.ts.map +1 -0
- package/dist/slider/index.d.ts +1 -0
- package/dist/slider/index.d.ts.map +1 -0
- package/dist/ssr/index.d.ts +2 -13
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/steplist/createStepListState.d.ts +10 -18
- package/dist/steplist/createStepListState.d.ts.map +1 -0
- package/dist/steplist/index.d.ts +1 -0
- package/dist/steplist/index.d.ts.map +1 -0
- package/dist/table/TableCollection.d.ts +1 -0
- package/dist/table/TableCollection.d.ts.map +1 -0
- package/dist/table/createTableColumnResizeState.d.ts +2 -9
- package/dist/table/createTableColumnResizeState.d.ts.map +1 -0
- package/dist/table/createTableState.d.ts +3 -6
- package/dist/table/createTableState.d.ts.map +1 -0
- package/dist/table/createTreeGridState.d.ts +3 -9
- package/dist/table/createTreeGridState.d.ts.map +1 -0
- package/dist/table/index.d.ts +1 -0
- package/dist/table/index.d.ts.map +1 -0
- package/dist/table/types.d.ts +37 -3
- package/dist/table/types.d.ts.map +1 -0
- package/dist/tabs/createTabListState.d.ts +2 -5
- package/dist/tabs/createTabListState.d.ts.map +1 -0
- package/dist/tabs/index.d.ts +1 -0
- package/dist/tabs/index.d.ts.map +1 -0
- package/dist/textfield/createTextFieldState.d.ts +1 -0
- package/dist/textfield/createTextFieldState.d.ts.map +1 -0
- package/dist/textfield/index.d.ts +1 -0
- package/dist/textfield/index.d.ts.map +1 -0
- package/dist/toast/createToastState.d.ts +2 -5
- package/dist/toast/createToastState.d.ts.map +1 -0
- package/dist/toast/index.d.ts +1 -0
- package/dist/toast/index.d.ts.map +1 -0
- package/dist/toggle/createToggleGroupState.d.ts +1 -0
- package/dist/toggle/createToggleGroupState.d.ts.map +1 -0
- package/dist/toggle/createToggleState.d.ts +1 -0
- package/dist/toggle/createToggleState.d.ts.map +1 -0
- package/dist/toggle/index.d.ts +1 -0
- package/dist/toggle/index.d.ts.map +1 -0
- package/dist/tokenfield/TokenFieldValue.d.ts +96 -0
- package/dist/tokenfield/TokenFieldValue.d.ts.map +1 -0
- package/dist/tokenfield/createTokenFieldState.d.ts +33 -0
- package/dist/tokenfield/createTokenFieldState.d.ts.map +1 -0
- package/dist/tokenfield/index.d.ts +3 -0
- package/dist/tokenfield/index.d.ts.map +1 -0
- package/dist/tooltip/createTooltipTriggerState.d.ts +9 -8
- package/dist/tooltip/createTooltipTriggerState.d.ts.map +1 -0
- package/dist/tooltip/index.d.ts +1 -0
- package/dist/tooltip/index.d.ts.map +1 -0
- package/dist/tree/TreeCollection.d.ts +1 -0
- package/dist/tree/TreeCollection.d.ts.map +1 -0
- package/dist/tree/createTreeState.d.ts +3 -8
- package/dist/tree/createTreeState.d.ts.map +1 -0
- package/dist/tree/index.d.ts +1 -0
- package/dist/tree/index.d.ts.map +1 -0
- package/dist/tree/types.d.ts +19 -1
- package/dist/tree/types.d.ts.map +1 -0
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/owner.d.ts +9 -0
- package/dist/utils/owner.d.ts.map +1 -0
- package/dist/utils/reactivity.d.ts +24 -0
- package/dist/utils/reactivity.d.ts.map +1 -0
- package/package.json +21 -9
- package/src/autocomplete/createAutocompleteState.ts +18 -4
- package/src/calendar/IncompleteDate.ts +15 -1
- package/src/calendar/createCalendarState.ts +321 -125
- package/src/calendar/createDateFieldState.ts +45 -31
- package/src/calendar/createDatePickerState.ts +47 -26
- package/src/calendar/createRangeCalendarState.ts +173 -86
- package/src/calendar/createTimeFieldState.ts +26 -7
- package/src/calendar/intl/index.ts +37 -2
- package/src/checkbox/createCheckboxGroupState.ts +45 -13
- package/src/collections/ListCollection.ts +31 -0
- package/src/collections/createListState.ts +27 -10
- package/src/collections/createMenuState.ts +190 -15
- package/src/collections/createSelectionState.ts +33 -13
- package/src/collections/getChildNodes.ts +20 -3
- package/src/collections/index.ts +6 -0
- package/src/collections/types.ts +35 -2
- package/src/color/Color.ts +61 -22
- package/src/color/createColorAreaState.ts +48 -4
- package/src/color/createColorFieldState.ts +114 -38
- package/src/color/createColorSliderState.ts +61 -9
- package/src/color/createColorWheelState.ts +29 -9
- package/src/color/getColorChannels.ts +16 -0
- package/src/color/index.ts +1 -0
- package/src/color/intl/index.ts +38 -3
- package/src/color/types.ts +1 -1
- package/src/combobox/createComboBoxState.ts +530 -297
- package/src/combobox/index.ts +4 -0
- package/src/data/createAsyncList.ts +41 -6
- package/src/data/createListData.ts +27 -4
- package/src/data/createTreeData.ts +30 -6
- package/src/disclosure/createDisclosureState.ts +40 -19
- package/src/dnd/createDragState.ts +22 -4
- package/src/dnd/createDraggableCollectionState.ts +145 -11
- package/src/dnd/createDropState.ts +21 -3
- package/src/dnd/createDroppableCollectionState.ts +127 -11
- package/src/dnd/index.ts +4 -0
- package/src/dnd/types.ts +16 -0
- package/src/form/createFormValidationState.ts +69 -37
- package/src/grid/createGridState.ts +196 -111
- package/src/grid/types.ts +22 -1
- package/src/index.ts +33 -2
- package/src/menu/index.ts +7 -0
- package/src/numberfield/createNumberFieldState.ts +247 -98
- package/src/overlays/createOverlayTriggerState.ts +31 -4
- package/src/private/flags/flags.ts +25 -0
- package/src/radio/createRadioGroupState.ts +23 -6
- package/src/searchfield/createSearchFieldState.ts +18 -3
- package/src/select/createSelectState.ts +317 -130
- package/src/select/index.ts +8 -1
- package/src/selection/Selection.ts +15 -1
- package/src/selection/SelectionManager.ts +17 -1
- package/src/selection/createMultipleSelectionState.ts +45 -26
- package/src/slider/createSliderState.ts +243 -104
- package/src/ssr/index.ts +34 -4
- package/src/steplist/createStepListState.ts +184 -130
- package/src/table/TableCollection.ts +14 -0
- package/src/table/createTableColumnResizeState.ts +71 -14
- package/src/table/createTableState.ts +26 -4
- package/src/table/createTreeGridState.ts +22 -6
- package/src/table/types.ts +38 -5
- package/src/tabs/createTabListState.ts +63 -43
- package/src/textfield/createTextFieldState.ts +17 -3
- package/src/toast/createToastState.ts +28 -3
- package/src/toggle/createToggleGroupState.ts +20 -5
- package/src/toggle/createToggleState.ts +19 -4
- package/src/tokenfield/TokenFieldValue.ts +499 -0
- package/src/tokenfield/createTokenFieldState.ts +88 -0
- package/src/tokenfield/index.ts +15 -0
- package/src/tooltip/createTooltipTriggerState.ts +49 -13
- package/src/tree/TreeCollection.ts +14 -0
- package/src/tree/createTreeState.ts +70 -36
- package/src/tree/types.ts +18 -1
- package/src/utils/index.ts +10 -1
- package/src/utils/owner.ts +20 -0
- package/src/utils/reactivity.ts +53 -1
- package/src/autocomplete/createAutocompleteState.d.ts +0 -48
- package/src/autocomplete/createAutocompleteState.d.ts.map +0 -1
- package/src/autocomplete/index.d.ts +0 -6
- package/src/autocomplete/index.d.ts.map +0 -1
- package/src/calendar/createCalendarState.d.ts +0 -152
- package/src/calendar/createCalendarState.d.ts.map +0 -1
- package/src/calendar/createDateFieldState.d.ts +0 -145
- package/src/calendar/createDateFieldState.d.ts.map +0 -1
- package/src/calendar/createRangeCalendarState.d.ts +0 -171
- package/src/calendar/createRangeCalendarState.d.ts.map +0 -1
- package/src/calendar/createTimeFieldState.d.ts +0 -97
- package/src/calendar/createTimeFieldState.d.ts.map +0 -1
- package/src/calendar/index.d.ts +0 -80
- package/src/calendar/index.d.ts.map +0 -1
- package/src/checkbox/createCheckboxGroupState.d.ts +0 -73
- package/src/checkbox/createCheckboxGroupState.d.ts.map +0 -1
- package/src/checkbox/index.d.ts +0 -6
- package/src/checkbox/index.d.ts.map +0 -1
- package/src/collections/ListCollection.d.ts +0 -40
- package/src/collections/ListCollection.d.ts.map +0 -1
- package/src/collections/createListState.d.ts +0 -94
- package/src/collections/createListState.d.ts.map +0 -1
- package/src/collections/createMenuState.d.ts +0 -55
- package/src/collections/createMenuState.d.ts.map +0 -1
- package/src/collections/createSelectionState.d.ts +0 -89
- package/src/collections/createSelectionState.d.ts.map +0 -1
- package/src/collections/index.d.ts +0 -38
- package/src/collections/index.d.ts.map +0 -1
- package/src/collections/types.d.ts +0 -147
- package/src/collections/types.d.ts.map +0 -1
- package/src/color/Color.d.ts +0 -43
- package/src/color/Color.d.ts.map +0 -1
- package/src/color/createColorAreaState.d.ts +0 -78
- package/src/color/createColorAreaState.d.ts.map +0 -1
- package/src/color/createColorFieldState.d.ts +0 -57
- package/src/color/createColorFieldState.d.ts.map +0 -1
- package/src/color/createColorSliderState.d.ts +0 -69
- package/src/color/createColorSliderState.d.ts.map +0 -1
- package/src/color/createColorWheelState.d.ts +0 -53
- package/src/color/createColorWheelState.d.ts.map +0 -1
- package/src/color/index.d.ts +0 -39
- package/src/color/index.d.ts.map +0 -1
- package/src/color/types.d.ts +0 -111
- package/src/color/types.d.ts.map +0 -1
- package/src/combobox/createComboBoxState.d.ts +0 -127
- package/src/combobox/createComboBoxState.d.ts.map +0 -1
- package/src/combobox/index.d.ts +0 -13
- package/src/combobox/index.d.ts.map +0 -1
- package/src/disclosure/createDisclosureState.d.ts +0 -68
- package/src/disclosure/createDisclosureState.d.ts.map +0 -1
- package/src/disclosure/index.d.ts +0 -10
- package/src/disclosure/index.d.ts.map +0 -1
- package/src/dnd/createDragState.d.ts +0 -68
- package/src/dnd/createDragState.d.ts.map +0 -1
- package/src/dnd/createDraggableCollectionState.d.ts +0 -68
- package/src/dnd/createDraggableCollectionState.d.ts.map +0 -1
- package/src/dnd/createDropState.d.ts +0 -80
- package/src/dnd/createDropState.d.ts.map +0 -1
- package/src/dnd/createDroppableCollectionState.d.ts +0 -107
- package/src/dnd/createDroppableCollectionState.d.ts.map +0 -1
- package/src/dnd/index.d.ts +0 -60
- package/src/dnd/index.d.ts.map +0 -1
- package/src/dnd/types.d.ts +0 -277
- package/src/dnd/types.d.ts.map +0 -1
- package/src/form/createFormValidationState.d.ts +0 -102
- package/src/form/index.d.ts +0 -16
- package/src/form/index.d.ts.map +0 -1
- package/src/grid/createGridState.d.ts +0 -15
- package/src/grid/createGridState.d.ts.map +0 -1
- package/src/grid/index.d.ts +0 -7
- package/src/grid/index.d.ts.map +0 -1
- package/src/grid/types.d.ts +0 -163
- package/src/grid/types.d.ts.map +0 -1
- package/src/index.d.ts +0 -311
- package/src/index.d.ts.map +0 -1
- package/src/numberfield/createNumberFieldState.d.ts +0 -67
- package/src/numberfield/createNumberFieldState.d.ts.map +0 -1
- package/src/numberfield/index.d.ts +0 -6
- package/src/numberfield/index.d.ts.map +0 -1
- package/src/overlays/createOverlayTriggerState.d.ts +0 -34
- package/src/overlays/createOverlayTriggerState.d.ts.map +0 -1
- package/src/overlays/index.d.ts +0 -6
- package/src/overlays/index.d.ts.map +0 -1
- package/src/radio/createRadioGroupState.d.ts +0 -79
- package/src/radio/createRadioGroupState.d.ts.map +0 -1
- package/src/radio/index.d.ts +0 -7
- package/src/radio/index.d.ts.map +0 -1
- package/src/searchfield/createSearchFieldState.d.ts +0 -27
- package/src/searchfield/createSearchFieldState.d.ts.map +0 -1
- package/src/searchfield/index.d.ts +0 -3
- package/src/searchfield/index.d.ts.map +0 -1
- package/src/select/createSelectState.d.ts +0 -75
- package/src/select/createSelectState.d.ts.map +0 -1
- package/src/select/index.d.ts +0 -2
- package/src/select/index.d.ts.map +0 -1
- package/src/slider/createSliderState.d.ts +0 -72
- package/src/slider/createSliderState.d.ts.map +0 -1
- package/src/slider/index.d.ts +0 -3
- package/src/slider/index.d.ts.map +0 -1
- package/src/ssr/index.d.ts +0 -28
- package/src/ssr/index.d.ts.map +0 -1
- package/src/table/TableCollection.d.ts +0 -54
- package/src/table/TableCollection.d.ts.map +0 -1
- package/src/table/createTableState.d.ts +0 -15
- package/src/table/createTableState.d.ts.map +0 -1
- package/src/table/index.d.ts +0 -18
- package/src/table/index.d.ts.map +0 -1
- package/src/table/types.d.ts +0 -145
- package/src/table/types.d.ts.map +0 -1
- package/src/tabs/createTabListState.d.ts +0 -70
- package/src/tabs/createTabListState.d.ts.map +0 -1
- package/src/tabs/index.d.ts +0 -8
- package/src/tabs/index.d.ts.map +0 -1
- package/src/textfield/createTextFieldState.d.ts +0 -32
- package/src/textfield/createTextFieldState.d.ts.map +0 -1
- package/src/textfield/index.d.ts +0 -6
- package/src/textfield/index.d.ts.map +0 -1
- package/src/toast/createToastState.d.ts +0 -129
- package/src/toast/createToastState.d.ts.map +0 -1
- package/src/toast/index.d.ts +0 -12
- package/src/toast/index.d.ts.map +0 -1
- package/src/toggle/createToggleState.d.ts +0 -34
- package/src/toggle/createToggleState.d.ts.map +0 -1
- package/src/toggle/index.d.ts +0 -2
- package/src/toggle/index.d.ts.map +0 -1
- package/src/tooltip/createTooltipTriggerState.d.ts +0 -39
- package/src/tooltip/createTooltipTriggerState.d.ts.map +0 -1
- package/src/tooltip/index.d.ts +0 -7
- package/src/tooltip/index.d.ts.map +0 -1
- package/src/tree/TreeCollection.d.ts +0 -43
- package/src/tree/TreeCollection.d.ts.map +0 -1
- package/src/tree/createTreeState.d.ts +0 -17
- package/src/tree/createTreeState.d.ts.map +0 -1
- package/src/tree/index.d.ts +0 -13
- package/src/tree/index.d.ts.map +0 -1
- package/src/tree/types.d.ts +0 -162
- package/src/tree/types.d.ts.map +0 -1
- package/src/utils/index.d.ts +0 -2
- package/src/utils/index.d.ts.map +0 -1
- package/src/utils/reactivity.d.ts +0 -28
- package/src/utils/reactivity.d.ts.map +0 -1
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,9 +26,6 @@ import type {
|
|
|
12
26
|
ColorChannel,
|
|
13
27
|
ColorChannelRange,
|
|
14
28
|
ColorAxes,
|
|
15
|
-
RGBColor,
|
|
16
|
-
HSLColor,
|
|
17
|
-
HSBColor,
|
|
18
29
|
} from "./types";
|
|
19
30
|
import { getColorStringForLocale, formatColorMessage, type ColorStringKey } from "./intl";
|
|
20
31
|
|
|
@@ -73,6 +84,17 @@ function clamp(value: number, min: number, max: number): number {
|
|
|
73
84
|
return Math.min(Math.max(value, min), max);
|
|
74
85
|
}
|
|
75
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
|
+
|
|
76
98
|
/**
|
|
77
99
|
* Round to fixed decimal places.
|
|
78
100
|
*/
|
|
@@ -563,7 +585,7 @@ class HSLColorImpl implements Color {
|
|
|
563
585
|
constructor(hue: number, saturation: number, lightness: number, alpha: number = 1) {
|
|
564
586
|
// Store raw like upstream HSLColor's constructor — precision comes from the
|
|
565
587
|
// conversion (toFixed(_, 2)); rounding to integers here diverged from S2.
|
|
566
|
-
this.hue = clamp(hue
|
|
588
|
+
this.hue = clamp(normalizeHue(hue), 0, 360);
|
|
567
589
|
this.saturation = clamp(saturation, 0, 100);
|
|
568
590
|
this.lightness = clamp(lightness, 0, 100);
|
|
569
591
|
this.alpha = clamp(toFixed(alpha, 2), 0, 1);
|
|
@@ -583,9 +605,16 @@ class HSLColorImpl implements Color {
|
|
|
583
605
|
}
|
|
584
606
|
case "hsb":
|
|
585
607
|
case "hsba": {
|
|
586
|
-
const
|
|
587
|
-
const
|
|
588
|
-
|
|
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
|
+
);
|
|
589
618
|
}
|
|
590
619
|
default:
|
|
591
620
|
throw new Error(`Unsupported format: ${format}`);
|
|
@@ -688,7 +717,7 @@ class HSLColorImpl implements Color {
|
|
|
688
717
|
return { style: "percent" };
|
|
689
718
|
}
|
|
690
719
|
if (channel === "hue") {
|
|
691
|
-
return { style: "unit", unit: "degree", unitDisplay: "narrow"
|
|
720
|
+
return { style: "unit", unit: "degree", unitDisplay: "narrow" };
|
|
692
721
|
}
|
|
693
722
|
return { style: "percent", maximumFractionDigits: 0 };
|
|
694
723
|
}
|
|
@@ -738,7 +767,7 @@ class HSBColorImpl implements Color {
|
|
|
738
767
|
|
|
739
768
|
constructor(hue: number, saturation: number, brightness: number, alpha: number = 1) {
|
|
740
769
|
// Store raw like upstream HSBColor's constructor (see HSLColorImpl).
|
|
741
|
-
this.hue = clamp(hue
|
|
770
|
+
this.hue = clamp(normalizeHue(hue), 0, 360);
|
|
742
771
|
this.saturation = clamp(saturation, 0, 100);
|
|
743
772
|
this.brightness = clamp(brightness, 0, 100);
|
|
744
773
|
this.alpha = clamp(toFixed(alpha, 2), 0, 1);
|
|
@@ -758,9 +787,19 @@ class HSBColorImpl implements Color {
|
|
|
758
787
|
}
|
|
759
788
|
case "hsl":
|
|
760
789
|
case "hsla": {
|
|
761
|
-
const
|
|
762
|
-
const
|
|
763
|
-
|
|
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
|
+
);
|
|
764
803
|
}
|
|
765
804
|
default:
|
|
766
805
|
throw new Error(`Unsupported format: ${format}`);
|
|
@@ -862,7 +901,7 @@ class HSBColorImpl implements Color {
|
|
|
862
901
|
return { style: "percent" };
|
|
863
902
|
}
|
|
864
903
|
if (channel === "hue") {
|
|
865
|
-
return { style: "unit", unit: "degree", unitDisplay: "narrow"
|
|
904
|
+
return { style: "unit", unit: "degree", unitDisplay: "narrow" };
|
|
866
905
|
}
|
|
867
906
|
return { style: "percent", maximumFractionDigits: 0 };
|
|
868
907
|
}
|
|
@@ -956,24 +995,24 @@ export function parseColor(value: string): Color {
|
|
|
956
995
|
|
|
957
996
|
// HSL/HSLA format
|
|
958
997
|
const hslMatch = trimmed.match(
|
|
959
|
-
/^hsla?\(\s*(
|
|
998
|
+
/^hsla?\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*(?:,\s*([-+]?\d+(?:\.\d+)?))?\s*\)$/,
|
|
960
999
|
);
|
|
961
1000
|
if (hslMatch) {
|
|
962
|
-
const h =
|
|
963
|
-
const s =
|
|
964
|
-
const l =
|
|
1001
|
+
const h = parseFloat(hslMatch[1]);
|
|
1002
|
+
const s = parseFloat(hslMatch[2]);
|
|
1003
|
+
const l = parseFloat(hslMatch[3]);
|
|
965
1004
|
const a = hslMatch[4] !== undefined ? parseFloat(hslMatch[4]) : 1;
|
|
966
1005
|
return new HSLColorImpl(h, s, l, a);
|
|
967
1006
|
}
|
|
968
1007
|
|
|
969
1008
|
// HSB/HSBA format
|
|
970
1009
|
const hsbMatch = trimmed.match(
|
|
971
|
-
/^hsba?\(\s*(
|
|
1010
|
+
/^hsba?\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*(?:,\s*([-+]?\d+(?:\.\d+)?))?\s*\)$/,
|
|
972
1011
|
);
|
|
973
1012
|
if (hsbMatch) {
|
|
974
|
-
const h =
|
|
975
|
-
const s =
|
|
976
|
-
const b =
|
|
1013
|
+
const h = parseFloat(hsbMatch[1]);
|
|
1014
|
+
const s = parseFloat(hsbMatch[2]);
|
|
1015
|
+
const b = parseFloat(hsbMatch[3]);
|
|
977
1016
|
const a = hsbMatch[4] !== undefined ? parseFloat(hsbMatch[4]) : 1;
|
|
978
1017
|
return new HSBColorImpl(h, s, b, a);
|
|
979
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). */
|
|
@@ -29,6 +45,8 @@ export interface ColorAreaStateOptions {
|
|
|
29
45
|
export interface ColorAreaState {
|
|
30
46
|
/** The current color value. */
|
|
31
47
|
readonly value: Color;
|
|
48
|
+
/** The color a native form reset restores. */
|
|
49
|
+
readonly defaultValue: Color;
|
|
32
50
|
/** The X axis channel. */
|
|
33
51
|
readonly xChannel: ColorChannel;
|
|
34
52
|
/** The Y axis channel. */
|
|
@@ -56,6 +74,8 @@ export interface ColorAreaState {
|
|
|
56
74
|
setXValue(value: number): void;
|
|
57
75
|
/** Set the Y channel value. */
|
|
58
76
|
setYValue(value: number): void;
|
|
77
|
+
/** Replace the color. */
|
|
78
|
+
setValue(value: Color | string): void;
|
|
59
79
|
/** Set color from a point (0-1, 0-1). */
|
|
60
80
|
setColorFromPoint(x: number, y: number): void;
|
|
61
81
|
/** Get the thumb position as percentages. */
|
|
@@ -87,8 +107,15 @@ export function createColorAreaState(options: Accessor<ColorAreaStateOptions>):
|
|
|
87
107
|
};
|
|
88
108
|
|
|
89
109
|
// Internal value state
|
|
90
|
-
const [internalValue, setInternalValue] =
|
|
91
|
-
|
|
110
|
+
const [internalValue, setInternalValue] = createInternalSignal<Color | null>(null);
|
|
111
|
+
// Pin useColorAreaState returns the first controlled color as defaultValue
|
|
112
|
+
// so a native form reset restores that color. The built-in red is only the
|
|
113
|
+
// uncontrolled fallback when no defaultValue was passed.
|
|
114
|
+
const firstOptions = getOptions();
|
|
115
|
+
const controlledInitial =
|
|
116
|
+
firstOptions.value !== undefined ? normalizeValue(firstOptions.value) : undefined;
|
|
117
|
+
const initialValue = normalizeValue(firstOptions.defaultValue ?? "#ff0000");
|
|
118
|
+
const [isDragging, setIsDragging] = createInternalSignal(false);
|
|
92
119
|
|
|
93
120
|
// Initialize internal value
|
|
94
121
|
const initValue = () => {
|
|
@@ -141,10 +168,13 @@ export function createColorAreaState(options: Accessor<ColorAreaStateOptions>):
|
|
|
141
168
|
const xChannelPageStep = createMemo(() => xRange().pageSize);
|
|
142
169
|
const yChannelPageStep = createMemo(() => yRange().pageSize);
|
|
143
170
|
|
|
171
|
+
let lastValue: Color | null = internalValue();
|
|
172
|
+
|
|
144
173
|
// Update value
|
|
145
174
|
const updateValue = (newColor: Color) => {
|
|
146
175
|
const opts = getOptions();
|
|
147
176
|
const nextColor = opts.colorSpace ? newColor.toFormat(opts.colorSpace) : newColor;
|
|
177
|
+
lastValue = nextColor;
|
|
148
178
|
|
|
149
179
|
// Controlled mode
|
|
150
180
|
if (opts.value !== undefined) {
|
|
@@ -163,6 +193,10 @@ export function createColorAreaState(options: Accessor<ColorAreaStateOptions>):
|
|
|
163
193
|
// Get Y value
|
|
164
194
|
const getYValue = () => value().getChannelValue(yChannel());
|
|
165
195
|
|
|
196
|
+
const setValue = (newValue: Color | string) => {
|
|
197
|
+
updateValue(normalizeValue(newValue));
|
|
198
|
+
};
|
|
199
|
+
|
|
166
200
|
// Set X value
|
|
167
201
|
const setXValue = (newValue: number) => {
|
|
168
202
|
const range = xRange();
|
|
@@ -245,7 +279,13 @@ export function createColorAreaState(options: Accessor<ColorAreaStateOptions>):
|
|
|
245
279
|
|
|
246
280
|
// Call onChangeEnd when dragging ends
|
|
247
281
|
if (wasDragging && !dragging) {
|
|
248
|
-
getOptions()
|
|
282
|
+
const opts = getOptions();
|
|
283
|
+
const current =
|
|
284
|
+
lastValue ??
|
|
285
|
+
(opts.value !== undefined ? normalizeValue(opts.value) : null) ??
|
|
286
|
+
internalValue() ??
|
|
287
|
+
value();
|
|
288
|
+
opts.onChangeEnd?.(current);
|
|
249
289
|
}
|
|
250
290
|
};
|
|
251
291
|
|
|
@@ -258,6 +298,9 @@ export function createColorAreaState(options: Accessor<ColorAreaStateOptions>):
|
|
|
258
298
|
get value() {
|
|
259
299
|
return value();
|
|
260
300
|
},
|
|
301
|
+
get defaultValue() {
|
|
302
|
+
return controlledInitial ?? initialValue;
|
|
303
|
+
},
|
|
261
304
|
get xChannel() {
|
|
262
305
|
return xChannel();
|
|
263
306
|
},
|
|
@@ -289,6 +332,7 @@ export function createColorAreaState(options: Accessor<ColorAreaStateOptions>):
|
|
|
289
332
|
getYValue,
|
|
290
333
|
setXValue,
|
|
291
334
|
setYValue,
|
|
335
|
+
setValue,
|
|
292
336
|
setColorFromPoint,
|
|
293
337
|
getThumbPosition,
|
|
294
338
|
incrementX,
|
|
@@ -1,11 +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/color/useColorChannelFieldState.ts
|
|
14
|
+
// Ported to SolidJS for Proyecto Viviana; based on packages/react-stately/src/color/useColorFieldState.ts
|
|
15
|
+
|
|
1
16
|
/**
|
|
2
17
|
* ColorField state management.
|
|
3
18
|
* Based on @react-stately/color useColorFieldState and useColorChannelFieldState.
|
|
4
19
|
*/
|
|
5
20
|
|
|
6
|
-
import { createEffect, createMemo
|
|
21
|
+
import { createEffect, createMemo } from "solid-js";
|
|
22
|
+
import type { Accessor } from "solid-js";
|
|
7
23
|
import type { Color, ColorChannel, ColorChannelRange, ColorFormat, ColorSpace } from "./types";
|
|
8
24
|
import { createRGBColor, normalizeColor, parseColor } from "./Color";
|
|
25
|
+
import { createInternalSignal, readNow } from "../utils";
|
|
9
26
|
|
|
10
27
|
const HEX_COLOR_MAX = 0xffffff;
|
|
11
28
|
const PARTIAL_HEX_PATTERN = /^#?[0-9a-f]{0,6}$/i;
|
|
@@ -40,6 +57,8 @@ export interface ColorFieldState {
|
|
|
40
57
|
readonly value: Color | null;
|
|
41
58
|
/** The color used for channel calculations. */
|
|
42
59
|
readonly colorValue: Color;
|
|
60
|
+
/** The color a native form reset restores. */
|
|
61
|
+
readonly defaultColorValue: Color | null;
|
|
43
62
|
/** The current input text. */
|
|
44
63
|
readonly inputValue: string;
|
|
45
64
|
/** The numeric value exposed by channel fields. */
|
|
@@ -145,7 +164,13 @@ function formatColorValue(
|
|
|
145
164
|
return displayColor.formatChannelValue(channel, locale);
|
|
146
165
|
}
|
|
147
166
|
|
|
148
|
-
|
|
167
|
+
const formatted = displayColor.toString(format ?? "hex");
|
|
168
|
+
const resolvedFormat = format ?? "hex";
|
|
169
|
+
if (resolvedFormat === "hex" || resolvedFormat === "hexa") {
|
|
170
|
+
return formatted.toUpperCase();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return formatted;
|
|
149
174
|
}
|
|
150
175
|
|
|
151
176
|
function normalizeHexInput(value: string): string {
|
|
@@ -189,9 +214,18 @@ export function createColorFieldState(options: Accessor<ColorFieldStateOptions>)
|
|
|
189
214
|
const getOptions = () => options();
|
|
190
215
|
const initialOptions = getOptions();
|
|
191
216
|
const initialValue = getDefaultValue(initialOptions);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const
|
|
217
|
+
// Form reset restores the first defaultValue, or the first controlled color
|
|
218
|
+
// when that default was omitted. An explicit null default falls through.
|
|
219
|
+
const initialDefault =
|
|
220
|
+
initialOptions.defaultValue !== undefined
|
|
221
|
+
? normalizeNullableColor(initialOptions.defaultValue)
|
|
222
|
+
: undefined;
|
|
223
|
+
const firstColor =
|
|
224
|
+
initialOptions.value !== undefined ? normalizeNullableColor(initialOptions.value) : undefined;
|
|
225
|
+
const defaultColorValue = initialDefault ?? firstColor ?? null;
|
|
226
|
+
|
|
227
|
+
const [internalValue, setInternalValue] = createInternalSignal<Color | null>(initialValue);
|
|
228
|
+
const [inputValue, setInputValueInternal] = createInternalSignal(
|
|
195
229
|
formatColorValue(
|
|
196
230
|
initialValue,
|
|
197
231
|
initialOptions.channel,
|
|
@@ -200,7 +234,10 @@ export function createColorFieldState(options: Accessor<ColorFieldStateOptions>)
|
|
|
200
234
|
initialOptions.locale ?? "en-US",
|
|
201
235
|
),
|
|
202
236
|
);
|
|
203
|
-
const [invalidInput, setInvalidInput] =
|
|
237
|
+
const [invalidInput, setInvalidInput] = createInternalSignal(false);
|
|
238
|
+
// Formatted channel text may round the accepted number. Only user edits
|
|
239
|
+
// should parse that text back into a new numerical value.
|
|
240
|
+
let isChannelInputEdited = false;
|
|
204
241
|
|
|
205
242
|
const channel = createMemo(() => getOptions().channel);
|
|
206
243
|
const colorSpace = createMemo(() => getOptions().colorSpace);
|
|
@@ -223,10 +260,14 @@ export function createColorFieldState(options: Accessor<ColorFieldStateOptions>)
|
|
|
223
260
|
const formatCurrentValue = (color: Color | null = value()) =>
|
|
224
261
|
formatColorValue(color, channel(), colorSpace(), getOptions().colorFormat, locale());
|
|
225
262
|
|
|
226
|
-
createEffect(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
263
|
+
createEffect(
|
|
264
|
+
() => formatCurrentValue(),
|
|
265
|
+
(formatted) => {
|
|
266
|
+
isChannelInputEdited = false;
|
|
267
|
+
setInputValueInternal(formatted);
|
|
268
|
+
setInvalidInput(false);
|
|
269
|
+
},
|
|
270
|
+
);
|
|
230
271
|
|
|
231
272
|
const updateValue = (newColor: Color | null) => {
|
|
232
273
|
const opts = getOptions();
|
|
@@ -236,11 +277,13 @@ export function createColorFieldState(options: Accessor<ColorFieldStateOptions>)
|
|
|
236
277
|
}
|
|
237
278
|
|
|
238
279
|
opts.onChange?.(newColor);
|
|
280
|
+
isChannelInputEdited = false;
|
|
239
281
|
setInputValueInternal(formatCurrentValue(newColor));
|
|
240
282
|
setInvalidInput(false);
|
|
241
283
|
};
|
|
242
284
|
|
|
243
285
|
const setInputValue = (text: string) => {
|
|
286
|
+
isChannelInputEdited = true;
|
|
244
287
|
setInputValueInternal(text);
|
|
245
288
|
setInvalidInput(false);
|
|
246
289
|
};
|
|
@@ -249,45 +292,74 @@ export function createColorFieldState(options: Accessor<ColorFieldStateOptions>)
|
|
|
249
292
|
updateValue(newColor);
|
|
250
293
|
};
|
|
251
294
|
|
|
295
|
+
// Methods can run before Solid's value memo observes an earlier write.
|
|
296
|
+
const currentValue = () => {
|
|
297
|
+
const opts = getOptions();
|
|
298
|
+
return opts.value !== undefined ? normalizeNullableColor(opts.value) : readNow(internalValue);
|
|
299
|
+
};
|
|
300
|
+
|
|
252
301
|
const commit = () => {
|
|
253
|
-
const text = inputValue
|
|
302
|
+
const text = readNow(inputValue).trim();
|
|
254
303
|
const opts = getOptions();
|
|
255
304
|
const chan = channel();
|
|
305
|
+
const current = currentValue();
|
|
256
306
|
|
|
257
307
|
if (!text) {
|
|
258
|
-
updateValue(null);
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if (chan) {
|
|
263
|
-
const displayColor = colorValue();
|
|
308
|
+
if (current !== null) updateValue(null);
|
|
309
|
+
} else if (chan) {
|
|
310
|
+
const displayColor = getDisplayColor(current, colorSpace());
|
|
264
311
|
const rawValue = parseChannelValue(text, displayColor, chan);
|
|
265
|
-
if (rawValue
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
312
|
+
if (isChannelInputEdited && rawValue !== null) {
|
|
313
|
+
const next = displayColor.withChannelValue(chan, rawValue);
|
|
314
|
+
if (current === null || next.getChannelValue(chan) !== displayColor.getChannelValue(chan)) {
|
|
315
|
+
updateValue(next);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
} else {
|
|
319
|
+
try {
|
|
320
|
+
const next = parseHexValue(text, opts.colorFormat);
|
|
321
|
+
// Whole hex edits compare RGB; hexa also edits alpha. This is not
|
|
322
|
+
// the equality policy for channel edits or the public color setter.
|
|
323
|
+
if (
|
|
324
|
+
current === null ||
|
|
325
|
+
next.toHexInt() !== current.toHexInt() ||
|
|
326
|
+
(opts.colorFormat === "hexa" &&
|
|
327
|
+
next.getChannelValue("alpha") !== current.getChannelValue("alpha"))
|
|
328
|
+
) {
|
|
329
|
+
updateValue(next);
|
|
330
|
+
}
|
|
331
|
+
} catch {
|
|
332
|
+
// Invalid text rolls back to the accepted color below.
|
|
269
333
|
}
|
|
270
|
-
|
|
271
|
-
updateValue(displayColor.withChannelValue(chan, rawValue));
|
|
272
|
-
return;
|
|
273
334
|
}
|
|
274
335
|
|
|
336
|
+
// Read after onChange: a controlled parent may accept or refuse the
|
|
337
|
+
// request. Later signal acceptance is handled by the formatting effect.
|
|
338
|
+
isChannelInputEdited = false;
|
|
339
|
+
setInputValueInternal(formatCurrentValue(currentValue()));
|
|
340
|
+
setInvalidInput(false);
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const incrementHex = (amount: number) => {
|
|
344
|
+
// Step the text being edited. A missing or unparseable hex starts at black,
|
|
345
|
+
// matching useColorFieldState's addColorValue(parsedValue, step).
|
|
346
|
+
const text = readNow(inputValue);
|
|
347
|
+
let parsed: Color | null = null;
|
|
275
348
|
try {
|
|
276
|
-
|
|
349
|
+
parsed = parseColor(text.startsWith("#") ? text : `#${text}`);
|
|
277
350
|
} catch {
|
|
278
|
-
|
|
279
|
-
setInvalidInput(false);
|
|
351
|
+
parsed = null;
|
|
280
352
|
}
|
|
281
|
-
};
|
|
282
353
|
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
|
|
354
|
+
const base = parsed ?? hexIntToColor(0);
|
|
355
|
+
const nextColor = hexIntToColor(base.toFormat("rgb").toHexInt() + amount);
|
|
356
|
+
const current = value();
|
|
357
|
+
if (current && current.toFormat("rgb").toHexInt() === nextColor.toHexInt()) {
|
|
286
358
|
return;
|
|
287
359
|
}
|
|
288
360
|
|
|
289
|
-
const
|
|
290
|
-
updateValue(
|
|
361
|
+
const format = getOptions().colorFormat;
|
|
362
|
+
updateValue(format ? nextColor.toFormat(format) : nextColor);
|
|
291
363
|
};
|
|
292
364
|
|
|
293
365
|
const updateChannel = (amount: number | "min" | "max") => {
|
|
@@ -296,17 +368,20 @@ export function createColorFieldState(options: Accessor<ColorFieldStateOptions>)
|
|
|
296
368
|
return;
|
|
297
369
|
}
|
|
298
370
|
|
|
299
|
-
const
|
|
371
|
+
const current = currentValue();
|
|
372
|
+
const displayColor = getDisplayColor(current, colorSpace());
|
|
300
373
|
const range = displayColor.getChannelRange(chan);
|
|
301
|
-
const
|
|
374
|
+
const currentChannel = displayColor.getChannelValue(chan);
|
|
302
375
|
const nextValue =
|
|
303
376
|
amount === "min"
|
|
304
377
|
? range.minValue
|
|
305
378
|
: amount === "max"
|
|
306
379
|
? range.maxValue
|
|
307
|
-
: Math.min(range.maxValue, Math.max(range.minValue,
|
|
380
|
+
: Math.min(range.maxValue, Math.max(range.minValue, currentChannel + amount));
|
|
308
381
|
|
|
309
|
-
|
|
382
|
+
const next = displayColor.withChannelValue(chan, nextValue);
|
|
383
|
+
if (current !== null && next.getChannelValue(chan) === currentChannel) return;
|
|
384
|
+
updateValue(next);
|
|
310
385
|
};
|
|
311
386
|
|
|
312
387
|
const increment = () => {
|
|
@@ -350,7 +425,7 @@ export function createColorFieldState(options: Accessor<ColorFieldStateOptions>)
|
|
|
350
425
|
};
|
|
351
426
|
|
|
352
427
|
const validate = (candidate?: string) => {
|
|
353
|
-
const text = (candidate ?? inputValue
|
|
428
|
+
const text = (candidate ?? readNow(inputValue)).trim();
|
|
354
429
|
const chan = channel();
|
|
355
430
|
|
|
356
431
|
if (!text) {
|
|
@@ -371,6 +446,7 @@ export function createColorFieldState(options: Accessor<ColorFieldStateOptions>)
|
|
|
371
446
|
get colorValue() {
|
|
372
447
|
return colorValue();
|
|
373
448
|
},
|
|
449
|
+
defaultColorValue,
|
|
374
450
|
get inputValue() {
|
|
375
451
|
return inputValue();
|
|
376
452
|
},
|