@proyecto-viviana/solid-stately 0.2.7 → 0.4.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/README.md +30 -283
- package/dist/autocomplete/createAutocompleteState.d.ts +2 -2
- package/dist/autocomplete/index.d.ts +1 -1
- package/dist/calendar/IncompleteDate.d.ts +61 -0
- package/dist/calendar/createCalendarState.d.ts +41 -16
- package/dist/calendar/createDateFieldState.d.ts +39 -9
- package/dist/calendar/createDatePickerState.d.ts +60 -0
- package/dist/calendar/createRangeCalendarState.d.ts +37 -10
- package/dist/calendar/createTimeFieldState.d.ts +34 -7
- package/dist/calendar/index.d.ts +7 -6
- package/dist/checkbox/createCheckboxGroupState.d.ts +6 -6
- package/dist/checkbox/index.d.ts +1 -1
- package/dist/collections/ListCollection.d.ts +1 -1
- package/dist/collections/createListState.d.ts +11 -8
- package/dist/collections/createMenuState.d.ts +7 -7
- package/dist/collections/createSelectionState.d.ts +22 -10
- package/dist/collections/getChildNodes.d.ts +11 -0
- package/dist/collections/index.d.ts +6 -5
- package/dist/collections/types.d.ts +12 -12
- package/dist/color/Color.d.ts +1 -1
- package/dist/color/createColorAreaState.d.ts +4 -2
- package/dist/color/createColorFieldState.d.ts +38 -12
- package/dist/color/createColorSliderState.d.ts +9 -2
- package/dist/color/createColorWheelState.d.ts +13 -2
- package/dist/color/getColorChannels.d.ts +1 -1
- package/dist/color/index.d.ts +6 -6
- package/dist/color/types.d.ts +4 -4
- package/dist/combobox/createComboBoxState.d.ts +34 -13
- package/dist/combobox/index.d.ts +1 -1
- package/dist/data/createAsyncList.d.ts +4 -4
- package/dist/data/createListData.d.ts +2 -2
- package/dist/data/createTreeData.d.ts +6 -2
- package/dist/data/index.d.ts +3 -3
- package/dist/datepicker/index.d.ts +2 -4
- package/dist/disclosure/createDisclosureState.d.ts +2 -2
- package/dist/disclosure/index.d.ts +1 -1
- package/dist/dnd/createDragState.d.ts +2 -2
- package/dist/dnd/createDraggableCollectionState.d.ts +2 -2
- package/dist/dnd/createDropState.d.ts +2 -2
- package/dist/dnd/createDroppableCollectionState.d.ts +3 -3
- package/dist/dnd/index.d.ts +5 -5
- package/dist/dnd/types.d.ts +19 -17
- package/dist/form/createFormValidationState.d.ts +3 -3
- package/dist/form/index.d.ts +1 -1
- package/dist/grid/createGridState.d.ts +2 -2
- package/dist/grid/index.d.ts +2 -2
- package/dist/grid/types.d.ts +27 -11
- package/dist/index.d.ts +31 -30
- package/dist/index.js +9077 -7246
- package/dist/index.js.map +1 -1
- package/dist/menu/index.d.ts +2 -2
- package/dist/numberfield/createNumberFieldState.d.ts +2 -2
- package/dist/numberfield/index.d.ts +1 -1
- package/dist/overlays/createOverlayTriggerState.d.ts +2 -2
- package/dist/overlays/index.d.ts +1 -1
- package/dist/radio/createRadioGroupState.d.ts +7 -7
- package/dist/radio/index.d.ts +1 -1
- package/dist/searchfield/createSearchFieldState.d.ts +2 -2
- package/dist/searchfield/index.d.ts +2 -2
- package/dist/select/createSelectState.d.ts +14 -8
- package/dist/select/index.d.ts +1 -1
- package/dist/selection/Selection.d.ts +16 -0
- package/dist/selection/SelectionManager.d.ts +110 -0
- package/dist/selection/createMultipleSelectionState.d.ts +59 -0
- package/dist/selection/index.d.ts +6 -5
- package/dist/slider/createSliderState.d.ts +3 -3
- package/dist/slider/index.d.ts +2 -2
- package/dist/steplist/createStepListState.d.ts +48 -0
- package/dist/steplist/index.d.ts +1 -0
- package/dist/table/TableCollection.d.ts +33 -3
- package/dist/table/createTableColumnResizeState.d.ts +54 -0
- package/dist/table/createTableState.d.ts +2 -2
- package/dist/table/createTreeGridState.d.ts +15 -0
- package/dist/table/index.d.ts +6 -3
- package/dist/table/types.d.ts +68 -10
- package/dist/tabs/createTabListState.d.ts +5 -5
- package/dist/tabs/index.d.ts +1 -1
- package/dist/textfield/createTextFieldState.d.ts +2 -2
- package/dist/textfield/index.d.ts +1 -1
- package/dist/toast/createToastState.d.ts +24 -2
- package/dist/toast/index.d.ts +1 -1
- package/dist/toggle/createToggleGroupState.d.ts +4 -4
- package/dist/toggle/createToggleState.d.ts +2 -2
- package/dist/toggle/index.d.ts +2 -2
- package/dist/tooltip/createTooltipTriggerState.d.ts +2 -2
- package/dist/tooltip/index.d.ts +1 -1
- package/dist/tree/TreeCollection.d.ts +2 -2
- package/dist/tree/createTreeState.d.ts +2 -2
- package/dist/tree/index.d.ts +3 -3
- package/dist/tree/types.d.ts +27 -13
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/reactivity.d.ts +1 -1
- package/package.json +29 -30
- package/src/autocomplete/createAutocompleteState.d.ts +19 -17
- package/src/autocomplete/createAutocompleteState.ts +24 -30
- package/src/autocomplete/index.d.ts +6 -2
- package/src/autocomplete/index.ts +1 -1
- package/src/calendar/IncompleteDate.ts +430 -0
- package/src/calendar/createCalendarState.d.ts +139 -117
- package/src/calendar/createCalendarState.ts +308 -94
- package/src/calendar/createDateFieldState.d.ts +130 -95
- package/src/calendar/createDateFieldState.ts +447 -334
- package/src/calendar/createDatePickerState.ts +347 -0
- package/src/calendar/createRangeCalendarState.d.ts +154 -129
- package/src/calendar/createRangeCalendarState.ts +411 -85
- package/src/calendar/createTimeFieldState.d.ts +81 -79
- package/src/calendar/createTimeFieldState.ts +187 -108
- package/src/calendar/index.d.ts +80 -7
- package/src/calendar/index.ts +23 -12
- package/src/checkbox/createCheckboxGroupState.d.ts +57 -55
- package/src/checkbox/createCheckboxGroupState.ts +20 -29
- package/src/checkbox/index.d.ts +6 -2
- package/src/checkbox/index.ts +1 -1
- package/src/collections/ListCollection.d.ts +25 -22
- package/src/collections/ListCollection.ts +6 -6
- package/src/collections/createListState.d.ts +73 -58
- package/src/collections/createListState.ts +67 -35
- package/src/collections/createMenuState.d.ts +36 -31
- package/src/collections/createMenuState.ts +21 -12
- package/src/collections/createSelectionState.d.ts +78 -65
- package/src/collections/createSelectionState.ts +66 -52
- package/src/collections/getChildNodes.ts +98 -0
- package/src/collections/index.d.ts +38 -6
- package/src/collections/index.ts +14 -10
- package/src/collections/types.d.ts +101 -101
- package/src/collections/types.ts +12 -12
- package/src/color/Color.d.ts +20 -5
- package/src/color/Color.ts +357 -254
- package/src/color/createColorAreaState.d.ts +67 -65
- package/src/color/createColorAreaState.ts +21 -13
- package/src/color/createColorFieldState.d.ts +46 -44
- package/src/color/createColorFieldState.ts +285 -149
- package/src/color/createColorSliderState.d.ts +58 -56
- package/src/color/createColorSliderState.ts +45 -14
- package/src/color/createColorWheelState.d.ts +42 -40
- package/src/color/createColorWheelState.ts +101 -64
- package/src/color/getColorChannels.ts +7 -5
- package/src/color/index.d.ts +36 -7
- package/src/color/index.ts +6 -9
- package/src/color/types.d.ts +68 -63
- package/src/color/types.ts +11 -19
- package/src/combobox/createComboBoxState.d.ts +107 -105
- package/src/combobox/createComboBoxState.ts +184 -89
- package/src/combobox/index.d.ts +10 -2
- package/src/combobox/index.ts +1 -1
- package/src/data/createAsyncList.ts +89 -63
- package/src/data/createListData.ts +67 -67
- package/src/data/createTreeData.ts +304 -91
- package/src/data/index.ts +3 -3
- package/src/datepicker/index.ts +6 -10
- package/src/disclosure/createDisclosureState.d.ts +47 -43
- package/src/disclosure/createDisclosureState.ts +7 -21
- package/src/disclosure/index.d.ts +10 -2
- package/src/disclosure/index.ts +1 -1
- package/src/dnd/createDragState.d.ts +51 -42
- package/src/dnd/createDragState.ts +12 -14
- package/src/dnd/createDraggableCollectionState.d.ts +52 -41
- package/src/dnd/createDraggableCollectionState.ts +14 -21
- package/src/dnd/createDropState.d.ts +64 -45
- package/src/dnd/createDropState.ts +22 -32
- package/src/dnd/createDroppableCollectionState.d.ts +88 -59
- package/src/dnd/createDroppableCollectionState.ts +40 -43
- package/src/dnd/index.d.ts +55 -6
- package/src/dnd/index.ts +6 -18
- package/src/dnd/types.d.ts +170 -157
- package/src/dnd/types.ts +24 -22
- package/src/form/createFormValidationState.d.ts +47 -45
- package/src/form/createFormValidationState.ts +30 -63
- package/src/form/index.d.ts +16 -2
- package/src/form/index.ts +1 -1
- package/src/grid/createGridState.d.ts +7 -4
- package/src/grid/createGridState.ts +78 -51
- package/src/grid/index.d.ts +3 -3
- package/src/grid/index.ts +2 -8
- package/src/grid/types.d.ts +136 -129
- package/src/grid/types.ts +34 -18
- package/src/index.d.ts +311 -26
- package/src/index.ts +59 -89
- package/src/menu/index.ts +2 -4
- package/src/numberfield/createNumberFieldState.d.ts +56 -54
- package/src/numberfield/createNumberFieldState.ts +26 -31
- package/src/numberfield/index.d.ts +6 -2
- package/src/numberfield/index.ts +1 -1
- package/src/overlays/createOverlayTriggerState.d.ts +22 -20
- package/src/overlays/createOverlayTriggerState.ts +3 -4
- package/src/overlays/index.d.ts +6 -2
- package/src/overlays/index.ts +1 -1
- package/src/radio/createRadioGroupState.d.ts +54 -52
- package/src/radio/createRadioGroupState.ts +27 -29
- package/src/radio/index.d.ts +7 -2
- package/src/radio/index.ts +1 -1
- package/src/searchfield/createSearchFieldState.d.ts +16 -14
- package/src/searchfield/createSearchFieldState.ts +5 -11
- package/src/searchfield/index.d.ts +3 -3
- package/src/searchfield/index.ts +2 -5
- package/src/select/createSelectState.d.ts +63 -61
- package/src/select/createSelectState.ts +42 -29
- package/src/select/index.d.ts +2 -2
- package/src/select/index.ts +1 -5
- package/src/selection/Selection.ts +28 -0
- package/src/selection/SelectionManager.ts +526 -0
- package/src/selection/createMultipleSelectionState.ts +247 -0
- package/src/selection/index.ts +12 -7
- package/src/slider/createSliderState.d.ts +60 -60
- package/src/slider/createSliderState.ts +55 -33
- package/src/slider/index.d.ts +3 -3
- package/src/slider/index.ts +2 -6
- package/src/ssr/index.d.ts +1 -1
- package/src/ssr/index.ts +2 -2
- package/src/steplist/createStepListState.ts +191 -0
- package/src/steplist/index.ts +5 -0
- package/src/table/TableCollection.d.ts +42 -40
- package/src/table/TableCollection.ts +266 -99
- package/src/table/createTableColumnResizeState.ts +242 -0
- package/src/table/createTableState.d.ts +7 -4
- package/src/table/createTableState.ts +30 -7
- package/src/table/createTreeGridState.ts +146 -0
- package/src/table/index.d.ts +14 -4
- package/src/table/index.ts +13 -3
- package/src/table/types.d.ts +98 -92
- package/src/table/types.ts +83 -13
- package/src/tabs/createTabListState.d.ts +59 -57
- package/src/tabs/createTabListState.ts +34 -39
- package/src/tabs/index.d.ts +8 -2
- package/src/tabs/index.ts +1 -1
- package/src/textfield/createTextFieldState.d.ts +16 -14
- package/src/textfield/createTextFieldState.ts +7 -18
- package/src/textfield/index.d.ts +6 -2
- package/src/textfield/index.ts +1 -1
- package/src/toast/createToastState.d.ts +92 -86
- package/src/toast/createToastState.ts +90 -52
- package/src/toast/index.d.ts +12 -2
- package/src/toast/index.ts +2 -1
- package/src/toggle/createToggleGroupState.ts +11 -21
- package/src/toggle/createToggleState.d.ts +19 -19
- package/src/toggle/createToggleState.ts +2 -16
- package/src/toggle/index.d.ts +2 -2
- package/src/toggle/index.ts +2 -6
- package/src/tooltip/createTooltipTriggerState.d.ts +17 -17
- package/src/tooltip/createTooltipTriggerState.ts +12 -11
- package/src/tooltip/index.d.ts +7 -2
- package/src/tooltip/index.ts +1 -1
- package/src/tree/TreeCollection.d.ts +26 -23
- package/src/tree/TreeCollection.ts +29 -22
- package/src/tree/createTreeState.d.ts +7 -4
- package/src/tree/createTreeState.ts +70 -41
- package/src/tree/index.d.ts +10 -4
- package/src/tree/index.ts +3 -3
- package/src/tree/types.d.ts +131 -126
- package/src/tree/types.ts +30 -13
- package/src/utils/index.d.ts +2 -2
- package/src/utils/index.ts +1 -1
- package/src/utils/reactivity.d.ts +2 -2
- package/src/utils/reactivity.ts +3 -3
|
@@ -2,75 +2,77 @@
|
|
|
2
2
|
* ColorArea state management.
|
|
3
3
|
* Based on @react-stately/color useColorAreaState.
|
|
4
4
|
*/
|
|
5
|
-
import { type Accessor } from
|
|
6
|
-
import type { Color, ColorChannel } from
|
|
5
|
+
import { type Accessor } from "solid-js";
|
|
6
|
+
import type { Color, ColorChannel } from "./types";
|
|
7
7
|
export interface ColorAreaStateOptions {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
/** The current color value (controlled). */
|
|
9
|
+
value?: Color | string;
|
|
10
|
+
/** The default color value (uncontrolled). */
|
|
11
|
+
defaultValue?: Color | string;
|
|
12
|
+
/** Handler called when the color changes. */
|
|
13
|
+
onChange?: (color: Color) => void;
|
|
14
|
+
/** Handler called when dragging ends. */
|
|
15
|
+
onChangeEnd?: (color: Color) => void;
|
|
16
|
+
/** The color channel for the X axis. */
|
|
17
|
+
xChannel?: ColorChannel;
|
|
18
|
+
/** The color channel for the Y axis. */
|
|
19
|
+
yChannel?: ColorChannel;
|
|
20
|
+
/** Whether the area is disabled. */
|
|
21
|
+
isDisabled?: boolean;
|
|
22
22
|
}
|
|
23
23
|
export interface ColorAreaState {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
24
|
+
/** The current color value. */
|
|
25
|
+
readonly value: Color;
|
|
26
|
+
/** The X axis channel. */
|
|
27
|
+
readonly xChannel: ColorChannel;
|
|
28
|
+
/** The Y axis channel. */
|
|
29
|
+
readonly yChannel: ColorChannel;
|
|
30
|
+
/** The Z axis channel (the third channel). */
|
|
31
|
+
readonly zChannel: ColorChannel;
|
|
32
|
+
/** Whether the area is being dragged. */
|
|
33
|
+
readonly isDragging: boolean;
|
|
34
|
+
/** Whether the area is disabled. */
|
|
35
|
+
readonly isDisabled: boolean;
|
|
36
|
+
/** Step for X channel. */
|
|
37
|
+
readonly xChannelStep: number;
|
|
38
|
+
/** Step for Y channel. */
|
|
39
|
+
readonly yChannelStep: number;
|
|
40
|
+
/** Page step for X channel. */
|
|
41
|
+
readonly xChannelPageStep: number;
|
|
42
|
+
/** Page step for Y channel. */
|
|
43
|
+
readonly yChannelPageStep: number;
|
|
44
|
+
/** Get the X channel value. */
|
|
45
|
+
getXValue(): number;
|
|
46
|
+
/** Get the Y channel value. */
|
|
47
|
+
getYValue(): number;
|
|
48
|
+
/** Set the X channel value. */
|
|
49
|
+
setXValue(value: number): void;
|
|
50
|
+
/** Set the Y channel value. */
|
|
51
|
+
setYValue(value: number): void;
|
|
52
|
+
/** Set color from a point (0-1, 0-1). */
|
|
53
|
+
setColorFromPoint(x: number, y: number): void;
|
|
54
|
+
/** Get the thumb position as percentages. */
|
|
55
|
+
getThumbPosition(): {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
};
|
|
59
|
+
/** Increment X value. */
|
|
60
|
+
incrementX(stepSize?: number): void;
|
|
61
|
+
/** Decrement X value. */
|
|
62
|
+
decrementX(stepSize?: number): void;
|
|
63
|
+
/** Increment Y value. */
|
|
64
|
+
incrementY(stepSize?: number): void;
|
|
65
|
+
/** Decrement Y value. */
|
|
66
|
+
decrementY(stepSize?: number): void;
|
|
67
|
+
/** Set the dragging state. */
|
|
68
|
+
setDragging(isDragging: boolean): void;
|
|
69
|
+
/** Get the display color (with alpha = 1). */
|
|
70
|
+
getDisplayColor(): Color;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Creates state for a color area (2D color picker).
|
|
74
74
|
*/
|
|
75
|
-
export declare function createColorAreaState(
|
|
76
|
-
|
|
75
|
+
export declare function createColorAreaState(
|
|
76
|
+
options: Accessor<ColorAreaStateOptions>,
|
|
77
|
+
): ColorAreaState;
|
|
78
|
+
//# sourceMappingURL=createColorAreaState.d.ts.map
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Based on @react-stately/color useColorAreaState.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { createSignal, createMemo, type Accessor } from
|
|
7
|
-
import type { Color, ColorChannel, ColorAxes } from
|
|
8
|
-
import { normalizeColor } from
|
|
6
|
+
import { createSignal, createMemo, type Accessor } from "solid-js";
|
|
7
|
+
import type { Color, ColorChannel, ColorAxes, ColorSpace } from "./types";
|
|
8
|
+
import { normalizeColor } from "./Color";
|
|
9
9
|
|
|
10
10
|
export interface ColorAreaStateOptions {
|
|
11
11
|
/** The current color value (controlled). */
|
|
@@ -20,6 +20,8 @@ export interface ColorAreaStateOptions {
|
|
|
20
20
|
xChannel?: ColorChannel;
|
|
21
21
|
/** The color channel for the Y axis. */
|
|
22
22
|
yChannel?: ColorChannel;
|
|
23
|
+
/** The color space to use for the color area. */
|
|
24
|
+
colorSpace?: ColorSpace;
|
|
23
25
|
/** Whether the area is disabled. */
|
|
24
26
|
isDisabled?: boolean;
|
|
25
27
|
}
|
|
@@ -75,11 +77,15 @@ export interface ColorAreaState {
|
|
|
75
77
|
/**
|
|
76
78
|
* Creates state for a color area (2D color picker).
|
|
77
79
|
*/
|
|
78
|
-
export function createColorAreaState(
|
|
79
|
-
options: Accessor<ColorAreaStateOptions>
|
|
80
|
-
): ColorAreaState {
|
|
80
|
+
export function createColorAreaState(options: Accessor<ColorAreaStateOptions>): ColorAreaState {
|
|
81
81
|
const getOptions = () => options();
|
|
82
82
|
|
|
83
|
+
const normalizeValue = (value: Color | string) => {
|
|
84
|
+
const color = normalizeColor(value);
|
|
85
|
+
const colorSpace = getOptions().colorSpace;
|
|
86
|
+
return colorSpace ? color.toFormat(colorSpace) : color;
|
|
87
|
+
};
|
|
88
|
+
|
|
83
89
|
// Internal value state
|
|
84
90
|
const [internalValue, setInternalValue] = createSignal<Color | null>(null);
|
|
85
91
|
const [isDragging, setIsDragging] = createSignal(false);
|
|
@@ -88,7 +94,7 @@ export function createColorAreaState(
|
|
|
88
94
|
const initValue = () => {
|
|
89
95
|
const opts = getOptions();
|
|
90
96
|
if (opts.defaultValue) {
|
|
91
|
-
return
|
|
97
|
+
return normalizeValue(opts.defaultValue);
|
|
92
98
|
}
|
|
93
99
|
return null;
|
|
94
100
|
};
|
|
@@ -105,9 +111,10 @@ export function createColorAreaState(
|
|
|
105
111
|
const value = createMemo(() => {
|
|
106
112
|
const opts = getOptions();
|
|
107
113
|
if (opts.value !== undefined) {
|
|
108
|
-
return
|
|
114
|
+
return normalizeValue(opts.value);
|
|
109
115
|
}
|
|
110
|
-
|
|
116
|
+
const fallback = internalValue() ?? normalizeValue("#ff0000");
|
|
117
|
+
return opts.colorSpace ? fallback.toFormat(opts.colorSpace) : fallback;
|
|
111
118
|
});
|
|
112
119
|
|
|
113
120
|
const isDisabled = createMemo(() => getOptions().isDisabled ?? false);
|
|
@@ -137,16 +144,17 @@ export function createColorAreaState(
|
|
|
137
144
|
// Update value
|
|
138
145
|
const updateValue = (newColor: Color) => {
|
|
139
146
|
const opts = getOptions();
|
|
147
|
+
const nextColor = opts.colorSpace ? newColor.toFormat(opts.colorSpace) : newColor;
|
|
140
148
|
|
|
141
149
|
// Controlled mode
|
|
142
150
|
if (opts.value !== undefined) {
|
|
143
|
-
opts.onChange?.(
|
|
151
|
+
opts.onChange?.(nextColor);
|
|
144
152
|
return;
|
|
145
153
|
}
|
|
146
154
|
|
|
147
155
|
// Uncontrolled mode
|
|
148
|
-
setInternalValue(
|
|
149
|
-
opts.onChange?.(
|
|
156
|
+
setInternalValue(nextColor);
|
|
157
|
+
opts.onChange?.(nextColor);
|
|
150
158
|
};
|
|
151
159
|
|
|
152
160
|
// Get X value
|
|
@@ -243,7 +251,7 @@ export function createColorAreaState(
|
|
|
243
251
|
|
|
244
252
|
// Get display color (alpha = 1)
|
|
245
253
|
const getDisplayColor = () => {
|
|
246
|
-
return value().withChannelValue(
|
|
254
|
+
return value().withChannelValue("alpha", 1);
|
|
247
255
|
};
|
|
248
256
|
|
|
249
257
|
return {
|
|
@@ -2,54 +2,56 @@
|
|
|
2
2
|
* ColorField state management.
|
|
3
3
|
* Based on @react-stately/color useColorFieldState.
|
|
4
4
|
*/
|
|
5
|
-
import { type Accessor } from
|
|
6
|
-
import type { Color, ColorChannel, ColorFormat } from
|
|
5
|
+
import { type Accessor } from "solid-js";
|
|
6
|
+
import type { Color, ColorChannel, ColorFormat } from "./types";
|
|
7
7
|
export interface ColorFieldStateOptions {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
/** The current color value (controlled). */
|
|
9
|
+
value?: Color | string | null;
|
|
10
|
+
/** The default color value (uncontrolled). */
|
|
11
|
+
defaultValue?: Color | string;
|
|
12
|
+
/** Handler called when the color changes. */
|
|
13
|
+
onChange?: (color: Color | null) => void;
|
|
14
|
+
/** The color channel to edit (for single channel mode). */
|
|
15
|
+
channel?: ColorChannel;
|
|
16
|
+
/** The color format for parsing/displaying. */
|
|
17
|
+
colorFormat?: ColorFormat;
|
|
18
|
+
/** Whether the field is disabled. */
|
|
19
|
+
isDisabled?: boolean;
|
|
20
|
+
/** Whether the field is read-only. */
|
|
21
|
+
isReadOnly?: boolean;
|
|
22
22
|
}
|
|
23
23
|
export interface ColorFieldState {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
24
|
+
/** The current color value (null if invalid). */
|
|
25
|
+
readonly value: Color | null;
|
|
26
|
+
/** The current input text. */
|
|
27
|
+
readonly inputValue: string;
|
|
28
|
+
/** Whether the input is invalid. */
|
|
29
|
+
readonly isInvalid: boolean;
|
|
30
|
+
/** Whether the field is disabled. */
|
|
31
|
+
readonly isDisabled: boolean;
|
|
32
|
+
/** Whether the field is read-only. */
|
|
33
|
+
readonly isReadOnly: boolean;
|
|
34
|
+
/** The color channel being edited (if single channel mode). */
|
|
35
|
+
readonly channel: ColorChannel | undefined;
|
|
36
|
+
/** Set the input text value. */
|
|
37
|
+
setInputValue(value: string): void;
|
|
38
|
+
/** Commit the current input value. */
|
|
39
|
+
commit(): void;
|
|
40
|
+
/** Increment the color channel value. */
|
|
41
|
+
increment(): void;
|
|
42
|
+
/** Decrement the color channel value. */
|
|
43
|
+
decrement(): void;
|
|
44
|
+
/** Increment by page size. */
|
|
45
|
+
incrementToMax(): void;
|
|
46
|
+
/** Decrement to minimum. */
|
|
47
|
+
decrementToMin(): void;
|
|
48
|
+
/** Validate the current input. */
|
|
49
|
+
validate(): boolean;
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Creates state for a color field (text input for color values).
|
|
53
53
|
*/
|
|
54
|
-
export declare function createColorFieldState(
|
|
55
|
-
|
|
54
|
+
export declare function createColorFieldState(
|
|
55
|
+
options: Accessor<ColorFieldStateOptions>,
|
|
56
|
+
): ColorFieldState;
|
|
57
|
+
//# sourceMappingURL=createColorFieldState.d.ts.map
|