@proyecto-viviana/solid-stately 0.2.7 → 0.3.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.
Files changed (242) hide show
  1. package/README.md +30 -283
  2. package/dist/autocomplete/createAutocompleteState.d.ts +2 -2
  3. package/dist/autocomplete/index.d.ts +1 -1
  4. package/dist/calendar/createCalendarState.d.ts +22 -7
  5. package/dist/calendar/createDateFieldState.d.ts +30 -7
  6. package/dist/calendar/createDatePickerState.d.ts +60 -0
  7. package/dist/calendar/createRangeCalendarState.d.ts +27 -8
  8. package/dist/calendar/createTimeFieldState.d.ts +34 -7
  9. package/dist/calendar/index.d.ts +7 -6
  10. package/dist/checkbox/createCheckboxGroupState.d.ts +6 -6
  11. package/dist/checkbox/index.d.ts +1 -1
  12. package/dist/collections/ListCollection.d.ts +1 -1
  13. package/dist/collections/createListState.d.ts +8 -8
  14. package/dist/collections/createMenuState.d.ts +7 -7
  15. package/dist/collections/createSelectionState.d.ts +5 -5
  16. package/dist/collections/index.d.ts +5 -5
  17. package/dist/collections/types.d.ts +12 -12
  18. package/dist/color/Color.d.ts +1 -1
  19. package/dist/color/createColorAreaState.d.ts +4 -2
  20. package/dist/color/createColorFieldState.d.ts +38 -12
  21. package/dist/color/createColorSliderState.d.ts +9 -2
  22. package/dist/color/createColorWheelState.d.ts +13 -2
  23. package/dist/color/getColorChannels.d.ts +1 -1
  24. package/dist/color/index.d.ts +6 -6
  25. package/dist/color/types.d.ts +4 -4
  26. package/dist/combobox/createComboBoxState.d.ts +27 -13
  27. package/dist/combobox/index.d.ts +1 -1
  28. package/dist/data/createAsyncList.d.ts +4 -4
  29. package/dist/data/createListData.d.ts +2 -2
  30. package/dist/data/createTreeData.d.ts +6 -2
  31. package/dist/data/index.d.ts +3 -3
  32. package/dist/datepicker/index.d.ts +2 -4
  33. package/dist/disclosure/createDisclosureState.d.ts +2 -2
  34. package/dist/disclosure/index.d.ts +1 -1
  35. package/dist/dnd/createDragState.d.ts +2 -2
  36. package/dist/dnd/createDraggableCollectionState.d.ts +2 -2
  37. package/dist/dnd/createDropState.d.ts +2 -2
  38. package/dist/dnd/createDroppableCollectionState.d.ts +3 -3
  39. package/dist/dnd/index.d.ts +5 -5
  40. package/dist/dnd/types.d.ts +16 -16
  41. package/dist/form/createFormValidationState.d.ts +3 -3
  42. package/dist/form/index.d.ts +1 -1
  43. package/dist/grid/createGridState.d.ts +2 -2
  44. package/dist/grid/index.d.ts +2 -2
  45. package/dist/grid/types.d.ts +13 -11
  46. package/dist/index.d.ts +31 -30
  47. package/dist/index.js +7924 -7238
  48. package/dist/index.js.map +1 -1
  49. package/dist/menu/index.d.ts +2 -2
  50. package/dist/numberfield/createNumberFieldState.d.ts +2 -2
  51. package/dist/numberfield/index.d.ts +1 -1
  52. package/dist/overlays/createOverlayTriggerState.d.ts +2 -2
  53. package/dist/overlays/index.d.ts +1 -1
  54. package/dist/radio/createRadioGroupState.d.ts +7 -7
  55. package/dist/radio/index.d.ts +1 -1
  56. package/dist/searchfield/createSearchFieldState.d.ts +2 -2
  57. package/dist/searchfield/index.d.ts +2 -2
  58. package/dist/select/createSelectState.d.ts +8 -8
  59. package/dist/select/index.d.ts +1 -1
  60. package/dist/selection/index.d.ts +5 -5
  61. package/dist/slider/createSliderState.d.ts +3 -3
  62. package/dist/slider/index.d.ts +2 -2
  63. package/dist/steplist/createStepListState.d.ts +48 -0
  64. package/dist/steplist/index.d.ts +1 -0
  65. package/dist/table/TableCollection.d.ts +3 -3
  66. package/dist/table/createTableColumnResizeState.d.ts +54 -0
  67. package/dist/table/createTableState.d.ts +2 -2
  68. package/dist/table/index.d.ts +5 -3
  69. package/dist/table/types.d.ts +10 -10
  70. package/dist/tabs/createTabListState.d.ts +5 -5
  71. package/dist/tabs/index.d.ts +1 -1
  72. package/dist/textfield/createTextFieldState.d.ts +2 -2
  73. package/dist/textfield/index.d.ts +1 -1
  74. package/dist/toast/createToastState.d.ts +8 -2
  75. package/dist/toast/index.d.ts +1 -1
  76. package/dist/toggle/createToggleGroupState.d.ts +4 -4
  77. package/dist/toggle/createToggleState.d.ts +2 -2
  78. package/dist/toggle/index.d.ts +2 -2
  79. package/dist/tooltip/createTooltipTriggerState.d.ts +2 -2
  80. package/dist/tooltip/index.d.ts +1 -1
  81. package/dist/tree/TreeCollection.d.ts +2 -2
  82. package/dist/tree/createTreeState.d.ts +2 -2
  83. package/dist/tree/index.d.ts +3 -3
  84. package/dist/tree/types.d.ts +19 -13
  85. package/dist/utils/index.d.ts +1 -1
  86. package/dist/utils/reactivity.d.ts +1 -1
  87. package/package.json +29 -30
  88. package/src/autocomplete/createAutocompleteState.d.ts +19 -17
  89. package/src/autocomplete/createAutocompleteState.ts +24 -30
  90. package/src/autocomplete/index.d.ts +6 -2
  91. package/src/autocomplete/index.ts +1 -1
  92. package/src/calendar/createCalendarState.d.ts +139 -117
  93. package/src/calendar/createCalendarState.ts +221 -74
  94. package/src/calendar/createDateFieldState.d.ts +130 -95
  95. package/src/calendar/createDateFieldState.ts +263 -151
  96. package/src/calendar/createDatePickerState.ts +347 -0
  97. package/src/calendar/createRangeCalendarState.d.ts +154 -129
  98. package/src/calendar/createRangeCalendarState.ts +293 -79
  99. package/src/calendar/createTimeFieldState.d.ts +81 -79
  100. package/src/calendar/createTimeFieldState.ts +187 -108
  101. package/src/calendar/index.d.ts +80 -7
  102. package/src/calendar/index.ts +21 -12
  103. package/src/checkbox/createCheckboxGroupState.d.ts +57 -55
  104. package/src/checkbox/createCheckboxGroupState.ts +20 -29
  105. package/src/checkbox/index.d.ts +6 -2
  106. package/src/checkbox/index.ts +1 -1
  107. package/src/collections/ListCollection.d.ts +25 -22
  108. package/src/collections/ListCollection.ts +6 -6
  109. package/src/collections/createListState.d.ts +73 -58
  110. package/src/collections/createListState.ts +19 -18
  111. package/src/collections/createMenuState.d.ts +36 -31
  112. package/src/collections/createMenuState.ts +18 -12
  113. package/src/collections/createSelectionState.d.ts +78 -65
  114. package/src/collections/createSelectionState.ts +36 -32
  115. package/src/collections/index.d.ts +38 -6
  116. package/src/collections/index.ts +5 -10
  117. package/src/collections/types.d.ts +101 -101
  118. package/src/collections/types.ts +12 -12
  119. package/src/color/Color.d.ts +20 -5
  120. package/src/color/Color.ts +357 -254
  121. package/src/color/createColorAreaState.d.ts +67 -65
  122. package/src/color/createColorAreaState.ts +21 -13
  123. package/src/color/createColorFieldState.d.ts +46 -44
  124. package/src/color/createColorFieldState.ts +285 -149
  125. package/src/color/createColorSliderState.d.ts +58 -56
  126. package/src/color/createColorSliderState.ts +45 -14
  127. package/src/color/createColorWheelState.d.ts +42 -40
  128. package/src/color/createColorWheelState.ts +101 -64
  129. package/src/color/getColorChannels.ts +7 -5
  130. package/src/color/index.d.ts +36 -7
  131. package/src/color/index.ts +6 -9
  132. package/src/color/types.d.ts +68 -63
  133. package/src/color/types.ts +11 -19
  134. package/src/combobox/createComboBoxState.d.ts +107 -105
  135. package/src/combobox/createComboBoxState.ts +176 -89
  136. package/src/combobox/index.d.ts +10 -2
  137. package/src/combobox/index.ts +1 -1
  138. package/src/data/createAsyncList.ts +89 -63
  139. package/src/data/createListData.ts +67 -67
  140. package/src/data/createTreeData.ts +304 -91
  141. package/src/data/index.ts +3 -3
  142. package/src/datepicker/index.ts +6 -10
  143. package/src/disclosure/createDisclosureState.d.ts +47 -43
  144. package/src/disclosure/createDisclosureState.ts +7 -21
  145. package/src/disclosure/index.d.ts +10 -2
  146. package/src/disclosure/index.ts +1 -1
  147. package/src/dnd/createDragState.d.ts +51 -42
  148. package/src/dnd/createDragState.ts +12 -14
  149. package/src/dnd/createDraggableCollectionState.d.ts +52 -41
  150. package/src/dnd/createDraggableCollectionState.ts +14 -21
  151. package/src/dnd/createDropState.d.ts +64 -45
  152. package/src/dnd/createDropState.ts +22 -32
  153. package/src/dnd/createDroppableCollectionState.d.ts +88 -59
  154. package/src/dnd/createDroppableCollectionState.ts +40 -43
  155. package/src/dnd/index.d.ts +54 -6
  156. package/src/dnd/index.ts +5 -18
  157. package/src/dnd/types.d.ts +167 -156
  158. package/src/dnd/types.ts +20 -21
  159. package/src/form/createFormValidationState.d.ts +47 -45
  160. package/src/form/createFormValidationState.ts +30 -63
  161. package/src/form/index.d.ts +16 -2
  162. package/src/form/index.ts +1 -1
  163. package/src/grid/createGridState.d.ts +7 -4
  164. package/src/grid/createGridState.ts +44 -51
  165. package/src/grid/index.d.ts +3 -3
  166. package/src/grid/index.ts +2 -8
  167. package/src/grid/types.d.ts +136 -129
  168. package/src/grid/types.ts +20 -18
  169. package/src/index.d.ts +310 -26
  170. package/src/index.ts +48 -89
  171. package/src/menu/index.ts +2 -4
  172. package/src/numberfield/createNumberFieldState.d.ts +56 -54
  173. package/src/numberfield/createNumberFieldState.ts +26 -31
  174. package/src/numberfield/index.d.ts +6 -2
  175. package/src/numberfield/index.ts +1 -1
  176. package/src/overlays/createOverlayTriggerState.d.ts +22 -20
  177. package/src/overlays/createOverlayTriggerState.ts +3 -4
  178. package/src/overlays/index.d.ts +6 -2
  179. package/src/overlays/index.ts +1 -1
  180. package/src/radio/createRadioGroupState.d.ts +54 -52
  181. package/src/radio/createRadioGroupState.ts +27 -29
  182. package/src/radio/index.d.ts +7 -2
  183. package/src/radio/index.ts +1 -1
  184. package/src/searchfield/createSearchFieldState.d.ts +16 -14
  185. package/src/searchfield/createSearchFieldState.ts +5 -11
  186. package/src/searchfield/index.d.ts +3 -3
  187. package/src/searchfield/index.ts +2 -5
  188. package/src/select/createSelectState.d.ts +63 -61
  189. package/src/select/createSelectState.ts +27 -27
  190. package/src/select/index.d.ts +2 -2
  191. package/src/select/index.ts +1 -5
  192. package/src/selection/index.ts +6 -7
  193. package/src/slider/createSliderState.d.ts +60 -60
  194. package/src/slider/createSliderState.ts +55 -33
  195. package/src/slider/index.d.ts +3 -3
  196. package/src/slider/index.ts +2 -6
  197. package/src/ssr/index.d.ts +1 -1
  198. package/src/ssr/index.ts +2 -2
  199. package/src/steplist/createStepListState.ts +191 -0
  200. package/src/steplist/index.ts +5 -0
  201. package/src/table/TableCollection.d.ts +42 -40
  202. package/src/table/TableCollection.ts +61 -64
  203. package/src/table/createTableColumnResizeState.ts +242 -0
  204. package/src/table/createTableState.d.ts +7 -4
  205. package/src/table/createTableState.ts +10 -7
  206. package/src/table/index.d.ts +14 -4
  207. package/src/table/index.ts +10 -3
  208. package/src/table/types.d.ts +98 -92
  209. package/src/table/types.ts +17 -13
  210. package/src/tabs/createTabListState.d.ts +59 -57
  211. package/src/tabs/createTabListState.ts +24 -31
  212. package/src/tabs/index.d.ts +8 -2
  213. package/src/tabs/index.ts +1 -1
  214. package/src/textfield/createTextFieldState.d.ts +16 -14
  215. package/src/textfield/createTextFieldState.ts +7 -18
  216. package/src/textfield/index.d.ts +6 -2
  217. package/src/textfield/index.ts +1 -1
  218. package/src/toast/createToastState.d.ts +92 -86
  219. package/src/toast/createToastState.ts +48 -43
  220. package/src/toast/index.d.ts +12 -2
  221. package/src/toast/index.ts +1 -1
  222. package/src/toggle/createToggleGroupState.ts +11 -21
  223. package/src/toggle/createToggleState.d.ts +19 -19
  224. package/src/toggle/createToggleState.ts +2 -16
  225. package/src/toggle/index.d.ts +2 -2
  226. package/src/toggle/index.ts +2 -6
  227. package/src/tooltip/createTooltipTriggerState.d.ts +17 -17
  228. package/src/tooltip/createTooltipTriggerState.ts +12 -11
  229. package/src/tooltip/index.d.ts +7 -2
  230. package/src/tooltip/index.ts +1 -1
  231. package/src/tree/TreeCollection.d.ts +26 -23
  232. package/src/tree/TreeCollection.ts +29 -22
  233. package/src/tree/createTreeState.d.ts +7 -4
  234. package/src/tree/createTreeState.ts +39 -41
  235. package/src/tree/index.d.ts +10 -4
  236. package/src/tree/index.ts +3 -3
  237. package/src/tree/types.d.ts +131 -126
  238. package/src/tree/types.ts +22 -13
  239. package/src/utils/index.d.ts +2 -2
  240. package/src/utils/index.ts +1 -1
  241. package/src/utils/reactivity.d.ts +2 -2
  242. 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 'solid-js';
6
- import type { Color, ColorChannel } from './types';
5
+ import { type Accessor } from "solid-js";
6
+ import type { Color, ColorChannel } from "./types";
7
7
  export interface ColorAreaStateOptions {
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;
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
- /** 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;
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(options: Accessor<ColorAreaStateOptions>): ColorAreaState;
76
- //# sourceMappingURL=createColorAreaState.d.ts.map
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 'solid-js';
7
- import type { Color, ColorChannel, ColorAxes } from './types';
8
- import { normalizeColor } from './Color';
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 normalizeColor(opts.defaultValue);
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 normalizeColor(opts.value);
114
+ return normalizeValue(opts.value);
109
115
  }
110
- return internalValue() ?? normalizeColor('#ff0000');
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?.(newColor);
151
+ opts.onChange?.(nextColor);
144
152
  return;
145
153
  }
146
154
 
147
155
  // Uncontrolled mode
148
- setInternalValue(newColor);
149
- opts.onChange?.(newColor);
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('alpha', 1);
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 'solid-js';
6
- import type { Color, ColorChannel, ColorFormat } from './types';
5
+ import { type Accessor } from "solid-js";
6
+ import type { Color, ColorChannel, ColorFormat } from "./types";
7
7
  export interface ColorFieldStateOptions {
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;
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
- /** 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;
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(options: Accessor<ColorFieldStateOptions>): ColorFieldState;
55
- //# sourceMappingURL=createColorFieldState.d.ts.map
54
+ export declare function createColorFieldState(
55
+ options: Accessor<ColorFieldStateOptions>,
56
+ ): ColorFieldState;
57
+ //# sourceMappingURL=createColorFieldState.d.ts.map