@proyecto-viviana/solid-stately 0.1.5 → 0.2.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 (217) hide show
  1. package/dist/index.js +226 -504
  2. package/dist/index.jsx +6407 -0
  3. package/package.json +3 -5
  4. package/dist/index.js.map +0 -1
  5. package/src/autocomplete/createAutocompleteState.d.ts +0 -46
  6. package/src/autocomplete/createAutocompleteState.d.ts.map +0 -1
  7. package/src/autocomplete/createAutocompleteState.ts +0 -90
  8. package/src/autocomplete/index.d.ts +0 -2
  9. package/src/autocomplete/index.d.ts.map +0 -1
  10. package/src/autocomplete/index.ts +0 -5
  11. package/src/calendar/createCalendarState.d.ts +0 -130
  12. package/src/calendar/createCalendarState.d.ts.map +0 -1
  13. package/src/calendar/createCalendarState.ts +0 -461
  14. package/src/calendar/createDateFieldState.d.ts +0 -110
  15. package/src/calendar/createDateFieldState.d.ts.map +0 -1
  16. package/src/calendar/createDateFieldState.ts +0 -562
  17. package/src/calendar/createRangeCalendarState.d.ts +0 -146
  18. package/src/calendar/createRangeCalendarState.d.ts.map +0 -1
  19. package/src/calendar/createRangeCalendarState.ts +0 -535
  20. package/src/calendar/createTimeFieldState.d.ts +0 -95
  21. package/src/calendar/createTimeFieldState.d.ts.map +0 -1
  22. package/src/calendar/createTimeFieldState.ts +0 -483
  23. package/src/calendar/index.d.ts +0 -7
  24. package/src/calendar/index.d.ts.map +0 -1
  25. package/src/calendar/index.ts +0 -81
  26. package/src/checkbox/createCheckboxGroupState.d.ts +0 -71
  27. package/src/checkbox/createCheckboxGroupState.d.ts.map +0 -1
  28. package/src/checkbox/createCheckboxGroupState.ts +0 -193
  29. package/src/checkbox/index.d.ts +0 -2
  30. package/src/checkbox/index.d.ts.map +0 -1
  31. package/src/checkbox/index.ts +0 -5
  32. package/src/collections/ListCollection.d.ts +0 -37
  33. package/src/collections/ListCollection.d.ts.map +0 -1
  34. package/src/collections/ListCollection.ts +0 -146
  35. package/src/collections/createListState.d.ts +0 -79
  36. package/src/collections/createListState.d.ts.map +0 -1
  37. package/src/collections/createListState.ts +0 -264
  38. package/src/collections/createMenuState.d.ts +0 -50
  39. package/src/collections/createMenuState.d.ts.map +0 -1
  40. package/src/collections/createMenuState.ts +0 -106
  41. package/src/collections/createSelectionState.d.ts +0 -76
  42. package/src/collections/createSelectionState.d.ts.map +0 -1
  43. package/src/collections/createSelectionState.ts +0 -336
  44. package/src/collections/index.d.ts +0 -6
  45. package/src/collections/index.d.ts.map +0 -1
  46. package/src/collections/index.ts +0 -46
  47. package/src/collections/types.d.ts +0 -147
  48. package/src/collections/types.d.ts.map +0 -1
  49. package/src/collections/types.ts +0 -169
  50. package/src/color/Color.d.ts +0 -28
  51. package/src/color/Color.d.ts.map +0 -1
  52. package/src/color/Color.ts +0 -951
  53. package/src/color/createColorAreaState.d.ts +0 -76
  54. package/src/color/createColorAreaState.d.ts.map +0 -1
  55. package/src/color/createColorAreaState.ts +0 -293
  56. package/src/color/createColorFieldState.d.ts +0 -55
  57. package/src/color/createColorFieldState.d.ts.map +0 -1
  58. package/src/color/createColorFieldState.ts +0 -292
  59. package/src/color/createColorSliderState.d.ts +0 -67
  60. package/src/color/createColorSliderState.d.ts.map +0 -1
  61. package/src/color/createColorSliderState.ts +0 -241
  62. package/src/color/createColorWheelState.d.ts +0 -51
  63. package/src/color/createColorWheelState.d.ts.map +0 -1
  64. package/src/color/createColorWheelState.ts +0 -211
  65. package/src/color/index.d.ts +0 -10
  66. package/src/color/index.d.ts.map +0 -1
  67. package/src/color/index.ts +0 -47
  68. package/src/color/types.d.ts +0 -106
  69. package/src/color/types.d.ts.map +0 -1
  70. package/src/color/types.ts +0 -127
  71. package/src/combobox/createComboBoxState.d.ts +0 -125
  72. package/src/combobox/createComboBoxState.d.ts.map +0 -1
  73. package/src/combobox/createComboBoxState.ts +0 -703
  74. package/src/combobox/index.d.ts +0 -5
  75. package/src/combobox/index.d.ts.map +0 -1
  76. package/src/combobox/index.ts +0 -13
  77. package/src/disclosure/createDisclosureState.d.ts +0 -64
  78. package/src/disclosure/createDisclosureState.d.ts.map +0 -1
  79. package/src/disclosure/createDisclosureState.ts +0 -193
  80. package/src/disclosure/index.d.ts +0 -2
  81. package/src/disclosure/index.d.ts.map +0 -1
  82. package/src/disclosure/index.ts +0 -9
  83. package/src/dnd/createDragState.d.ts +0 -59
  84. package/src/dnd/createDragState.d.ts.map +0 -1
  85. package/src/dnd/createDragState.ts +0 -153
  86. package/src/dnd/createDraggableCollectionState.d.ts +0 -57
  87. package/src/dnd/createDraggableCollectionState.d.ts.map +0 -1
  88. package/src/dnd/createDraggableCollectionState.ts +0 -165
  89. package/src/dnd/createDropState.d.ts +0 -61
  90. package/src/dnd/createDropState.d.ts.map +0 -1
  91. package/src/dnd/createDropState.ts +0 -212
  92. package/src/dnd/createDroppableCollectionState.d.ts +0 -78
  93. package/src/dnd/createDroppableCollectionState.d.ts.map +0 -1
  94. package/src/dnd/createDroppableCollectionState.ts +0 -357
  95. package/src/dnd/index.d.ts +0 -11
  96. package/src/dnd/index.d.ts.map +0 -1
  97. package/src/dnd/index.ts +0 -76
  98. package/src/dnd/types.d.ts +0 -264
  99. package/src/dnd/types.d.ts.map +0 -1
  100. package/src/dnd/types.ts +0 -317
  101. package/src/form/createFormValidationState.d.ts +0 -100
  102. package/src/form/createFormValidationState.d.ts.map +0 -1
  103. package/src/form/createFormValidationState.ts +0 -389
  104. package/src/form/index.d.ts +0 -2
  105. package/src/form/index.d.ts.map +0 -1
  106. package/src/form/index.ts +0 -15
  107. package/src/grid/createGridState.d.ts +0 -12
  108. package/src/grid/createGridState.d.ts.map +0 -1
  109. package/src/grid/createGridState.ts +0 -327
  110. package/src/grid/index.d.ts +0 -7
  111. package/src/grid/index.d.ts.map +0 -1
  112. package/src/grid/index.ts +0 -13
  113. package/src/grid/types.d.ts +0 -156
  114. package/src/grid/types.d.ts.map +0 -1
  115. package/src/grid/types.ts +0 -179
  116. package/src/index.d.ts +0 -26
  117. package/src/index.d.ts.map +0 -1
  118. package/src/index.ts +0 -383
  119. package/src/numberfield/createNumberFieldState.d.ts +0 -65
  120. package/src/numberfield/createNumberFieldState.d.ts.map +0 -1
  121. package/src/numberfield/createNumberFieldState.ts +0 -383
  122. package/src/numberfield/index.d.ts +0 -2
  123. package/src/numberfield/index.d.ts.map +0 -1
  124. package/src/numberfield/index.ts +0 -5
  125. package/src/overlays/createOverlayTriggerState.d.ts +0 -32
  126. package/src/overlays/createOverlayTriggerState.d.ts.map +0 -1
  127. package/src/overlays/createOverlayTriggerState.ts +0 -67
  128. package/src/overlays/index.d.ts +0 -2
  129. package/src/overlays/index.d.ts.map +0 -1
  130. package/src/overlays/index.ts +0 -5
  131. package/src/radio/createRadioGroupState.d.ts +0 -77
  132. package/src/radio/createRadioGroupState.d.ts.map +0 -1
  133. package/src/radio/createRadioGroupState.ts +0 -201
  134. package/src/radio/index.d.ts +0 -2
  135. package/src/radio/index.d.ts.map +0 -1
  136. package/src/radio/index.ts +0 -6
  137. package/src/searchfield/createSearchFieldState.d.ts +0 -25
  138. package/src/searchfield/createSearchFieldState.d.ts.map +0 -1
  139. package/src/searchfield/createSearchFieldState.ts +0 -62
  140. package/src/searchfield/index.d.ts +0 -3
  141. package/src/searchfield/index.d.ts.map +0 -1
  142. package/src/searchfield/index.ts +0 -5
  143. package/src/select/createSelectState.d.ts +0 -73
  144. package/src/select/createSelectState.d.ts.map +0 -1
  145. package/src/select/createSelectState.ts +0 -181
  146. package/src/select/index.d.ts +0 -2
  147. package/src/select/index.d.ts.map +0 -1
  148. package/src/select/index.ts +0 -5
  149. package/src/slider/createSliderState.d.ts +0 -72
  150. package/src/slider/createSliderState.d.ts.map +0 -1
  151. package/src/slider/createSliderState.ts +0 -211
  152. package/src/slider/index.d.ts +0 -3
  153. package/src/slider/index.d.ts.map +0 -1
  154. package/src/slider/index.ts +0 -6
  155. package/src/ssr/index.d.ts +0 -28
  156. package/src/ssr/index.d.ts.map +0 -1
  157. package/src/ssr/index.ts +0 -41
  158. package/src/table/TableCollection.d.ts +0 -52
  159. package/src/table/TableCollection.d.ts.map +0 -1
  160. package/src/table/TableCollection.ts +0 -388
  161. package/src/table/createTableState.d.ts +0 -12
  162. package/src/table/createTableState.d.ts.map +0 -1
  163. package/src/table/createTableState.ts +0 -127
  164. package/src/table/index.d.ts +0 -8
  165. package/src/table/index.d.ts.map +0 -1
  166. package/src/table/index.ts +0 -18
  167. package/src/table/types.d.ts +0 -139
  168. package/src/table/types.d.ts.map +0 -1
  169. package/src/table/types.ts +0 -150
  170. package/src/tabs/createTabListState.d.ts +0 -68
  171. package/src/tabs/createTabListState.d.ts.map +0 -1
  172. package/src/tabs/createTabListState.ts +0 -240
  173. package/src/tabs/index.d.ts +0 -2
  174. package/src/tabs/index.d.ts.map +0 -1
  175. package/src/tabs/index.ts +0 -7
  176. package/src/textfield/createTextFieldState.d.ts +0 -30
  177. package/src/textfield/createTextFieldState.d.ts.map +0 -1
  178. package/src/textfield/createTextFieldState.ts +0 -75
  179. package/src/textfield/index.d.ts +0 -2
  180. package/src/textfield/index.d.ts.map +0 -1
  181. package/src/textfield/index.ts +0 -5
  182. package/src/toast/createToastState.d.ts +0 -118
  183. package/src/toast/createToastState.d.ts.map +0 -1
  184. package/src/toast/createToastState.ts +0 -316
  185. package/src/toast/index.d.ts +0 -2
  186. package/src/toast/index.d.ts.map +0 -1
  187. package/src/toast/index.ts +0 -11
  188. package/src/toggle/createToggleState.d.ts +0 -34
  189. package/src/toggle/createToggleState.d.ts.map +0 -1
  190. package/src/toggle/createToggleState.ts +0 -94
  191. package/src/toggle/index.d.ts +0 -2
  192. package/src/toggle/index.d.ts.map +0 -1
  193. package/src/toggle/index.ts +0 -5
  194. package/src/tooltip/createTooltipTriggerState.d.ts +0 -39
  195. package/src/tooltip/createTooltipTriggerState.d.ts.map +0 -1
  196. package/src/tooltip/createTooltipTriggerState.ts +0 -183
  197. package/src/tooltip/index.d.ts +0 -2
  198. package/src/tooltip/index.d.ts.map +0 -1
  199. package/src/tooltip/index.ts +0 -6
  200. package/src/tree/TreeCollection.d.ts +0 -40
  201. package/src/tree/TreeCollection.d.ts.map +0 -1
  202. package/src/tree/TreeCollection.ts +0 -175
  203. package/src/tree/createTreeState.d.ts +0 -14
  204. package/src/tree/createTreeState.d.ts.map +0 -1
  205. package/src/tree/createTreeState.ts +0 -392
  206. package/src/tree/index.d.ts +0 -7
  207. package/src/tree/index.d.ts.map +0 -1
  208. package/src/tree/index.ts +0 -13
  209. package/src/tree/types.d.ts +0 -157
  210. package/src/tree/types.d.ts.map +0 -1
  211. package/src/tree/types.ts +0 -174
  212. package/src/utils/index.d.ts +0 -2
  213. package/src/utils/index.d.ts.map +0 -1
  214. package/src/utils/index.ts +0 -1
  215. package/src/utils/reactivity.d.ts +0 -28
  216. package/src/utils/reactivity.d.ts.map +0 -1
  217. package/src/utils/reactivity.ts +0 -36
@@ -1,201 +0,0 @@
1
- /**
2
- * Radio group state for Solid Stately
3
- *
4
- * Provides state management for a radio group component.
5
- * Provides a name for the group, and manages selection and focus state.
6
- *
7
- * This is a 1:1 port of @react-stately/radio's useRadioGroupState.
8
- */
9
-
10
- import { createSignal, Accessor, untrack } from 'solid-js';
11
- import { type MaybeAccessor, access } from '../utils';
12
- import { createId } from '../ssr';
13
-
14
- // ============================================
15
- // TYPES
16
- // ============================================
17
-
18
- export interface RadioGroupProps {
19
- /** The current selected value (controlled). */
20
- value?: string | null;
21
- /** The default selected value (uncontrolled). */
22
- defaultValue?: string | null;
23
- /** Handler that is called when the value changes. */
24
- onChange?: (value: string) => void;
25
- /** Whether the radio group is disabled. */
26
- isDisabled?: boolean;
27
- /** Whether the radio group is read only. */
28
- isReadOnly?: boolean;
29
- /** Whether the radio group is required. */
30
- isRequired?: boolean;
31
- /** Whether the radio group is invalid. */
32
- isInvalid?: boolean;
33
- /** The name of the radio group, used when submitting an HTML form. */
34
- name?: string;
35
- /** The form to associate the radio group with. */
36
- form?: string;
37
- /** The label for the radio group. */
38
- label?: string;
39
- /** Orientation of the radio group. */
40
- orientation?: 'horizontal' | 'vertical';
41
- /** Handler that is called when the radio group receives focus. */
42
- onFocus?: (e: FocusEvent) => void;
43
- /** Handler that is called when the radio group loses focus. */
44
- onBlur?: (e: FocusEvent) => void;
45
- /** Handler that is called when the radio group's focus status changes. */
46
- onFocusChange?: (isFocused: boolean) => void;
47
- }
48
-
49
- export interface RadioGroupState {
50
- /** The name for the group, used for native form submission. */
51
- readonly name: string;
52
-
53
- /** Whether the radio group is disabled. */
54
- readonly isDisabled: boolean;
55
-
56
- /** Whether the radio group is read only. */
57
- readonly isReadOnly: boolean;
58
-
59
- /** Whether the radio group is required. */
60
- readonly isRequired: boolean;
61
-
62
- /** Whether the radio group is invalid. */
63
- readonly isInvalid: boolean;
64
-
65
- /** The currently selected value. */
66
- readonly selectedValue: Accessor<string | null>;
67
-
68
- /** The default selected value. */
69
- readonly defaultSelectedValue: string | null;
70
-
71
- /** Sets the selected value. */
72
- setSelectedValue(value: string | null): void;
73
-
74
- /** The value of the last focused radio. */
75
- readonly lastFocusedValue: Accessor<string | null>;
76
-
77
- /** Sets the last focused value. */
78
- setLastFocusedValue(value: string | null): void;
79
- }
80
-
81
- // ============================================
82
- // INTERNAL: SolidJS-specific sync mechanism
83
- // ============================================
84
-
85
- /**
86
- * Internal WeakMap to store sync version accessors for each radio group state.
87
- * This is used by createRadio to trigger DOM sync when native radio behavior
88
- * causes the DOM checked state to desync from our reactive state.
89
- *
90
- * This is kept separate from RadioGroupState to maintain API parity with React-Stately.
91
- * @internal
92
- */
93
- export const radioGroupSyncVersion: WeakMap<RadioGroupState, Accessor<number>> = new WeakMap();
94
-
95
- // ============================================
96
- // IMPLEMENTATION
97
- // ============================================
98
-
99
- /**
100
- * Provides state management for a radio group component.
101
- * Provides a name for the group, and manages selection and focus state.
102
- */
103
- export function createRadioGroupState(
104
- props: MaybeAccessor<RadioGroupProps> = {}
105
- ): RadioGroupState {
106
- const getProps = () => access(props);
107
-
108
- // Get initial props using untrack to avoid setting up dependencies
109
- // This ensures we capture the initial defaultValue without reactivity issues
110
- const initialProps = untrack(() => getProps());
111
-
112
- // Generate name - preserved for backward compatibility
113
- // React Aria now generates the name instead of stately
114
- const name = initialProps.name || `radio-group-${createId()}`;
115
-
116
- // Create internal signal for uncontrolled mode
117
- // Initialize with defaultValue only (not value, which is for controlled mode)
118
- const [internalValue, setInternalValue] = createSignal<string | null>(
119
- initialProps.defaultValue ?? null
120
- );
121
- const [lastFocusedValue, setLastFocusedValueInternal] = createSignal<string | null>(null);
122
-
123
- // SolidJS-specific: Version counter for triggering DOM sync across all radios
124
- // This handles the case where native radio behavior causes DOM state to desync
125
- // from our reactive state (e.g., clicking a radio unchecks siblings in the DOM)
126
- const [syncVersion, setSyncVersion] = createSignal(0);
127
-
128
- // Determine if controlled - must be reactive to handle dynamic props
129
- const isControlled = () => getProps().value !== undefined;
130
-
131
- // Get current value - reactive for both controlled and uncontrolled modes
132
- const selectedValue: Accessor<string | null> = () => {
133
- const p = getProps();
134
- // In controlled mode, always read from props.value reactively
135
- // In uncontrolled mode, read from internal signal
136
- if (p.value !== undefined) {
137
- return p.value ?? null;
138
- }
139
- return internalValue();
140
- };
141
-
142
- // Check if invalid
143
- const isInvalid = () => {
144
- return getProps().isInvalid ?? false;
145
- };
146
-
147
- // Set value
148
- function setSelectedValue(value: string | null): void {
149
- const p = getProps();
150
- if (p.isReadOnly || p.isDisabled) {
151
- return;
152
- }
153
-
154
- // Always increment syncVersion to trigger DOM sync across all radios
155
- // This is crucial for SolidJS because:
156
- // 1. Native radio behavior unchecks siblings when one is checked
157
- // 2. In controlled mode, isSelected() may not change even though DOM changed
158
- // 3. We need ALL radios to re-sync their checked state after any click
159
- setSyncVersion((v) => v + 1);
160
-
161
- if (!isControlled()) {
162
- setInternalValue(value);
163
- }
164
-
165
- if (value != null) {
166
- p.onChange?.(value);
167
- }
168
- }
169
-
170
- // Set last focused value
171
- function setLastFocusedValue(value: string | null): void {
172
- setLastFocusedValueInternal(value);
173
- }
174
-
175
- const state: RadioGroupState = {
176
- name,
177
- selectedValue,
178
- defaultSelectedValue: initialProps.defaultValue ?? null,
179
- setSelectedValue,
180
- lastFocusedValue,
181
- setLastFocusedValue,
182
- get isDisabled() {
183
- return getProps().isDisabled ?? false;
184
- },
185
- get isReadOnly() {
186
- return getProps().isReadOnly ?? false;
187
- },
188
- get isRequired() {
189
- return getProps().isRequired ?? false;
190
- },
191
- get isInvalid() {
192
- return isInvalid();
193
- },
194
- };
195
-
196
- // Store syncVersion in internal WeakMap (not part of public API)
197
- // This maintains API parity with React-Stately while supporting SolidJS's reactivity needs
198
- radioGroupSyncVersion.set(state, syncVersion);
199
-
200
- return state;
201
- }
@@ -1,2 +0,0 @@
1
- export { createRadioGroupState, radioGroupSyncVersion, type RadioGroupProps, type RadioGroupState, } from './createRadioGroupState';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,yBAAyB,CAAC"}
@@ -1,6 +0,0 @@
1
- export {
2
- createRadioGroupState,
3
- radioGroupSyncVersion,
4
- type RadioGroupProps,
5
- type RadioGroupState,
6
- } from './createRadioGroupState';
@@ -1,25 +0,0 @@
1
- /**
2
- * Creates state for a search field component.
3
- * Based on @react-stately/searchfield useSearchFieldState.
4
- */
5
- import { type Accessor } from 'solid-js';
6
- import { type MaybeAccessor } from '../utils';
7
- export interface SearchFieldStateProps {
8
- /** The current value (controlled). */
9
- value?: string;
10
- /** The default value (uncontrolled). */
11
- defaultValue?: string;
12
- /** Handler that is called when the value changes. */
13
- onChange?: (value: string) => void;
14
- }
15
- export interface SearchFieldState {
16
- /** The current value of the search field. */
17
- value: Accessor<string>;
18
- /** Sets the value of the search field. */
19
- setValue: (value: string) => void;
20
- }
21
- /**
22
- * Provides state management for a search field.
23
- */
24
- export declare function createSearchFieldState(props: MaybeAccessor<SearchFieldStateProps>): SearchFieldState;
25
- //# sourceMappingURL=createSearchFieldState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createSearchFieldState.d.ts","sourceRoot":"","sources":["createSearchFieldState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAA4B,MAAM,UAAU,CAAC;AACnE,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAEtD,MAAM,WAAW,qBAAqB;IACpC,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxB,0CAA0C;IAC1C,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,aAAa,CAAC,qBAAqB,CAAC,GAC1C,gBAAgB,CAgClB"}
@@ -1,62 +0,0 @@
1
- /**
2
- * Creates state for a search field component.
3
- * Based on @react-stately/searchfield useSearchFieldState.
4
- */
5
-
6
- import { type Accessor, createSignal, createMemo } from 'solid-js';
7
- import { access, type MaybeAccessor } from '../utils';
8
-
9
- export interface SearchFieldStateProps {
10
- /** The current value (controlled). */
11
- value?: string;
12
- /** The default value (uncontrolled). */
13
- defaultValue?: string;
14
- /** Handler that is called when the value changes. */
15
- onChange?: (value: string) => void;
16
- }
17
-
18
- export interface SearchFieldState {
19
- /** The current value of the search field. */
20
- value: Accessor<string>;
21
- /** Sets the value of the search field. */
22
- setValue: (value: string) => void;
23
- }
24
-
25
- /**
26
- * Provides state management for a search field.
27
- */
28
- export function createSearchFieldState(
29
- props: MaybeAccessor<SearchFieldStateProps>
30
- ): SearchFieldState {
31
- const getProps = () => access(props);
32
-
33
- // Controlled vs uncontrolled
34
- const isControlled = () => getProps().value !== undefined;
35
-
36
- // Internal signal for uncontrolled mode
37
- const [internalValue, setInternalValue] = createSignal(
38
- getProps().defaultValue ?? ''
39
- );
40
-
41
- // Current value accessor
42
- const value = createMemo(() => {
43
- const p = getProps();
44
- return isControlled() ? (p.value ?? '') : internalValue();
45
- });
46
-
47
- // Set value function
48
- const setValue = (newValue: string) => {
49
- const p = getProps();
50
-
51
- if (!isControlled()) {
52
- setInternalValue(newValue);
53
- }
54
-
55
- p.onChange?.(newValue);
56
- };
57
-
58
- return {
59
- value,
60
- setValue,
61
- };
62
- }
@@ -1,3 +0,0 @@
1
- export { createSearchFieldState } from './createSearchFieldState';
2
- export type { SearchFieldState, SearchFieldStateProps, } from './createSearchFieldState';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EACV,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC"}
@@ -1,5 +0,0 @@
1
- export { createSearchFieldState } from './createSearchFieldState';
2
- export type {
3
- SearchFieldState,
4
- SearchFieldStateProps,
5
- } from './createSearchFieldState';
@@ -1,73 +0,0 @@
1
- /**
2
- * State management for select components.
3
- * Based on @react-stately/select useSelectState.
4
- */
5
- import { type Accessor } from 'solid-js';
6
- import { type MaybeAccessor } from '../utils';
7
- import type { Key, CollectionNode, Collection } from '../collections/types';
8
- export interface SelectStateProps<T = unknown> {
9
- /** The items to display in the select. */
10
- items: T[];
11
- /** Function to get the key for an item. */
12
- getKey?: (item: T) => Key;
13
- /** Function to get the text value for an item. */
14
- getTextValue?: (item: T) => string;
15
- /** Function to check if an item is disabled. */
16
- getDisabled?: (item: T) => boolean;
17
- /** Keys of disabled items. */
18
- disabledKeys?: Iterable<Key>;
19
- /** The currently selected key (controlled). */
20
- selectedKey?: Key | null;
21
- /** The default selected key (uncontrolled). */
22
- defaultSelectedKey?: Key | null;
23
- /** Handler called when the selection changes. */
24
- onSelectionChange?: (key: Key | null) => void;
25
- /** Whether the select is open (controlled). */
26
- isOpen?: boolean;
27
- /** Whether the select is open by default (uncontrolled). */
28
- defaultOpen?: boolean;
29
- /** Handler called when the open state changes. */
30
- onOpenChange?: (isOpen: boolean) => void;
31
- /** Whether the select is disabled. */
32
- isDisabled?: boolean;
33
- /** Whether the select is required. */
34
- isRequired?: boolean;
35
- }
36
- export interface SelectState<T = unknown> {
37
- /** The collection of items. */
38
- readonly collection: Accessor<Collection<T>>;
39
- /** Whether the select dropdown is open. */
40
- readonly isOpen: Accessor<boolean>;
41
- /** Open the select dropdown. */
42
- open(): void;
43
- /** Close the select dropdown. */
44
- close(): void;
45
- /** Toggle the select dropdown. */
46
- toggle(): void;
47
- /** The currently selected key. */
48
- readonly selectedKey: Accessor<Key | null>;
49
- /** The currently selected item. */
50
- readonly selectedItem: Accessor<CollectionNode<T> | null>;
51
- /** Set the selected key. */
52
- setSelectedKey(key: Key | null): void;
53
- /** The currently focused key. */
54
- readonly focusedKey: Accessor<Key | null>;
55
- /** Set the focused key. */
56
- setFocusedKey(key: Key | null): void;
57
- /** Whether the select has focus. */
58
- readonly isFocused: Accessor<boolean>;
59
- /** Set whether the select has focus. */
60
- setFocused(isFocused: boolean): void;
61
- /** Whether a specific key is disabled. */
62
- isKeyDisabled(key: Key): boolean;
63
- /** Whether the select is disabled. */
64
- readonly isDisabled: boolean;
65
- /** Whether the select is required. */
66
- readonly isRequired: boolean;
67
- }
68
- /**
69
- * Creates state for a select component.
70
- * Combines list state with overlay trigger state for dropdown behavior.
71
- */
72
- export declare function createSelectState<T = unknown>(props: MaybeAccessor<SelectStateProps<T>>): SelectState<T>;
73
- //# sourceMappingURL=createSelectState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createSelectState.d.ts","sourceRoot":"","sources":["createSelectState.ts"],"names":[],"mappings":"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"}
@@ -1,181 +0,0 @@
1
- /**
2
- * State management for select components.
3
- * Based on @react-stately/select useSelectState.
4
- */
5
-
6
- import { createSignal, type Accessor } from 'solid-js';
7
- import { access, type MaybeAccessor } from '../utils';
8
- import { createListState } from '../collections/createListState';
9
- import { createOverlayTriggerState } from '../overlays';
10
- import type { Key, CollectionNode, Collection } from '../collections/types';
11
-
12
- export interface SelectStateProps<T = unknown> {
13
- /** The items to display in the select. */
14
- items: T[];
15
- /** Function to get the key for an item. */
16
- getKey?: (item: T) => Key;
17
- /** Function to get the text value for an item. */
18
- getTextValue?: (item: T) => string;
19
- /** Function to check if an item is disabled. */
20
- getDisabled?: (item: T) => boolean;
21
- /** Keys of disabled items. */
22
- disabledKeys?: Iterable<Key>;
23
- /** The currently selected key (controlled). */
24
- selectedKey?: Key | null;
25
- /** The default selected key (uncontrolled). */
26
- defaultSelectedKey?: Key | null;
27
- /** Handler called when the selection changes. */
28
- onSelectionChange?: (key: Key | null) => void;
29
- /** Whether the select is open (controlled). */
30
- isOpen?: boolean;
31
- /** Whether the select is open by default (uncontrolled). */
32
- defaultOpen?: boolean;
33
- /** Handler called when the open state changes. */
34
- onOpenChange?: (isOpen: boolean) => void;
35
- /** Whether the select is disabled. */
36
- isDisabled?: boolean;
37
- /** Whether the select is required. */
38
- isRequired?: boolean;
39
- }
40
-
41
- export interface SelectState<T = unknown> {
42
- /** The collection of items. */
43
- readonly collection: Accessor<Collection<T>>;
44
- /** Whether the select dropdown is open. */
45
- readonly isOpen: Accessor<boolean>;
46
- /** Open the select dropdown. */
47
- open(): void;
48
- /** Close the select dropdown. */
49
- close(): void;
50
- /** Toggle the select dropdown. */
51
- toggle(): void;
52
- /** The currently selected key. */
53
- readonly selectedKey: Accessor<Key | null>;
54
- /** The currently selected item. */
55
- readonly selectedItem: Accessor<CollectionNode<T> | null>;
56
- /** Set the selected key. */
57
- setSelectedKey(key: Key | null): void;
58
- /** The currently focused key. */
59
- readonly focusedKey: Accessor<Key | null>;
60
- /** Set the focused key. */
61
- setFocusedKey(key: Key | null): void;
62
- /** Whether the select has focus. */
63
- readonly isFocused: Accessor<boolean>;
64
- /** Set whether the select has focus. */
65
- setFocused(isFocused: boolean): void;
66
- /** Whether a specific key is disabled. */
67
- isKeyDisabled(key: Key): boolean;
68
- /** Whether the select is disabled. */
69
- readonly isDisabled: boolean;
70
- /** Whether the select is required. */
71
- readonly isRequired: boolean;
72
- }
73
-
74
- /**
75
- * Creates state for a select component.
76
- * Combines list state with overlay trigger state for dropdown behavior.
77
- */
78
- export function createSelectState<T = unknown>(
79
- props: MaybeAccessor<SelectStateProps<T>>
80
- ): SelectState<T> {
81
- const getProps = () => access(props);
82
-
83
- // Overlay trigger state for open/close
84
- const overlayState = createOverlayTriggerState({
85
- get isOpen() {
86
- return getProps().isOpen;
87
- },
88
- get defaultOpen() {
89
- return getProps().defaultOpen;
90
- },
91
- get onOpenChange() {
92
- return getProps().onOpenChange;
93
- },
94
- });
95
-
96
- // Track selected key
97
- const isControlled = () => getProps().selectedKey !== undefined;
98
- const [internalSelectedKey, setInternalSelectedKey] = createSignal<Key | null>(
99
- getProps().defaultSelectedKey ?? null
100
- );
101
-
102
- const selectedKey: Accessor<Key | null> = () => {
103
- return isControlled() ? (getProps().selectedKey ?? null) : internalSelectedKey();
104
- };
105
-
106
- const setSelectedKey = (key: Key | null) => {
107
- if (!isControlled()) {
108
- setInternalSelectedKey(key);
109
- }
110
- getProps().onSelectionChange?.(key);
111
- };
112
-
113
- // Create list state with single selection
114
- const listState = createListState<T>({
115
- get items() {
116
- return getProps().items;
117
- },
118
- get getKey() {
119
- return getProps().getKey;
120
- },
121
- get getTextValue() {
122
- return getProps().getTextValue;
123
- },
124
- get getDisabled() {
125
- return getProps().getDisabled;
126
- },
127
- get disabledKeys() {
128
- return getProps().disabledKeys;
129
- },
130
- selectionMode: 'single',
131
- disallowEmptySelection: true,
132
- get selectedKeys() {
133
- const key = selectedKey();
134
- return key != null ? [key] : [];
135
- },
136
- onSelectionChange(keys) {
137
- // Get the first (and only) selected key
138
- if (keys === 'all') return; // Not applicable for single select
139
- const key = keys.size > 0 ? Array.from(keys)[0] : null;
140
- setSelectedKey(key);
141
- // Close the dropdown after selection
142
- overlayState.close();
143
- },
144
- });
145
-
146
- // Get the selected item from the collection
147
- const selectedItem: Accessor<CollectionNode<T> | null> = () => {
148
- const key = selectedKey();
149
- if (key == null) return null;
150
- return listState.collection().getItem(key);
151
- };
152
-
153
- return {
154
- // Collection
155
- collection: listState.collection,
156
-
157
- // Focus management
158
- focusedKey: listState.focusedKey,
159
- setFocusedKey: listState.setFocusedKey,
160
- isFocused: listState.isFocused,
161
- setFocused: listState.setFocused,
162
-
163
- // Overlay state
164
- isOpen: overlayState.isOpen,
165
- open: overlayState.open,
166
- close: overlayState.close,
167
- toggle: overlayState.toggle,
168
-
169
- // Select-specific
170
- selectedKey,
171
- selectedItem,
172
- setSelectedKey,
173
- isKeyDisabled: (key: Key) => listState.isDisabled(key),
174
- get isDisabled() {
175
- return getProps().isDisabled ?? false;
176
- },
177
- get isRequired() {
178
- return getProps().isRequired ?? false;
179
- },
180
- };
181
- }
@@ -1,2 +0,0 @@
1
- export { createSelectState, type SelectStateProps, type SelectState, } from './createSelectState';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,GACjB,MAAM,qBAAqB,CAAC"}
@@ -1,5 +0,0 @@
1
- export {
2
- createSelectState,
3
- type SelectStateProps,
4
- type SelectState,
5
- } from './createSelectState';
@@ -1,72 +0,0 @@
1
- /**
2
- * Creates state for a slider component.
3
- * Based on @react-stately/slider useSliderState.
4
- */
5
- import { type Accessor } from 'solid-js';
6
- import { type MaybeAccessor } from '../utils';
7
- export type SliderOrientation = 'horizontal' | 'vertical';
8
- export interface SliderStateProps {
9
- /** The current value (controlled). */
10
- value?: number;
11
- /** The default value (uncontrolled). */
12
- defaultValue?: number;
13
- /** Handler called when the value changes. */
14
- onChange?: (value: number) => void;
15
- /** Handler called when the user stops dragging. */
16
- onChangeEnd?: (value: number) => void;
17
- /** The minimum value. */
18
- minValue?: number;
19
- /** The maximum value. */
20
- maxValue?: number;
21
- /** The step value. */
22
- step?: number;
23
- /** The orientation of the slider. */
24
- orientation?: SliderOrientation;
25
- /** Whether the slider is disabled. */
26
- isDisabled?: boolean;
27
- /** The locale for number formatting. */
28
- locale?: string;
29
- /** Number format options. */
30
- formatOptions?: Intl.NumberFormatOptions;
31
- }
32
- export interface SliderState {
33
- /** The current value. */
34
- value: Accessor<number>;
35
- /** Sets the value. */
36
- setValue: (value: number) => void;
37
- /** Sets the value by percent (0-1). */
38
- setValuePercent: (percent: number) => void;
39
- /** Gets the value as a percent (0-1). */
40
- getValuePercent: Accessor<number>;
41
- /** Gets the formatted value string. */
42
- getFormattedValue: Accessor<string>;
43
- /** Whether the thumb is being dragged. */
44
- isDragging: Accessor<boolean>;
45
- /** Sets the dragging state. */
46
- setDragging: (dragging: boolean) => void;
47
- /** Whether the slider is focused. */
48
- isFocused: Accessor<boolean>;
49
- /** Sets the focused state. */
50
- setFocused: (focused: boolean) => void;
51
- /** Increments the value by step. */
52
- increment: (stepMultiplier?: number) => void;
53
- /** Decrements the value by step. */
54
- decrement: (stepMultiplier?: number) => void;
55
- /** The minimum value. */
56
- minValue: number;
57
- /** The maximum value. */
58
- maxValue: number;
59
- /** The step value. */
60
- step: number;
61
- /** The page step (larger step for Page Up/Down). */
62
- pageStep: number;
63
- /** The orientation. */
64
- orientation: SliderOrientation;
65
- /** Whether the slider is disabled. */
66
- isDisabled: boolean;
67
- }
68
- /**
69
- * Provides state management for a slider component.
70
- */
71
- export declare function createSliderState(props: MaybeAccessor<SliderStateProps>): SliderState;
72
- //# sourceMappingURL=createSliderState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createSliderState.d.ts","sourceRoot":"","sources":["createSliderState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAA4B,MAAM,UAAU,CAAC;AACnE,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAEtD,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE1D,MAAM,WAAW,gBAAgB;IAC/B,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,mDAAmD;IACnD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,sCAAsC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,aAAa,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;CAC1C;AAED,MAAM,WAAW,WAAW;IAC1B,yBAAyB;IACzB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxB,sBAAsB;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,uCAAuC;IACvC,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,yCAAyC;IACzC,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAClC,uCAAuC;IACvC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpC,0CAA0C;IAC1C,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9B,+BAA+B;IAC/B,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,qCAAqC;IACrC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7B,8BAA8B;IAC9B,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,oCAAoC;IACpC,SAAS,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,oCAAoC;IACpC,SAAS,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,sCAAsC;IACtC,UAAU,EAAE,OAAO,CAAC;CACrB;AAwBD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,aAAa,CAAC,gBAAgB,CAAC,GACrC,WAAW,CA+Gb"}