@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,336 +0,0 @@
1
- /**
2
- * Selection state management for collections.
3
- * Based on @react-stately/selection.
4
- */
5
-
6
- import { createSignal, type Accessor } from 'solid-js';
7
- import { access, type MaybeAccessor } from '../utils';
8
- import type {
9
- Collection,
10
- DisabledBehavior,
11
- FocusStrategy,
12
- Key,
13
- Selection,
14
- SelectionBehavior,
15
- SelectionMode,
16
- } from './types';
17
-
18
- export interface SelectionStateProps {
19
- /** The selection mode. */
20
- selectionMode?: SelectionMode;
21
- /** How selection behaves on interaction. */
22
- selectionBehavior?: SelectionBehavior;
23
- /** Whether empty selection is disallowed. */
24
- disallowEmptySelection?: boolean;
25
- /** Currently selected keys (controlled). */
26
- selectedKeys?: 'all' | Iterable<Key>;
27
- /** Default selected keys (uncontrolled). */
28
- defaultSelectedKeys?: 'all' | Iterable<Key>;
29
- /** Handler for selection changes. */
30
- onSelectionChange?: (keys: Selection) => void;
31
- /** Keys of disabled items. */
32
- disabledKeys?: Iterable<Key>;
33
- /** How disabled keys behave. */
34
- disabledBehavior?: DisabledBehavior;
35
- /** Whether to allow duplicate selection events. */
36
- allowDuplicateSelectionEvents?: boolean;
37
- }
38
-
39
- export interface SelectionState {
40
- /** The selection mode. */
41
- readonly selectionMode: Accessor<SelectionMode>;
42
- /** The selection behavior. */
43
- readonly selectionBehavior: Accessor<SelectionBehavior>;
44
- /** Whether empty selection is disallowed. */
45
- readonly disallowEmptySelection: Accessor<boolean>;
46
- /** The currently selected keys. */
47
- readonly selectedKeys: Accessor<Selection>;
48
- /** Set of disabled keys. */
49
- readonly disabledKeys: Accessor<Set<Key>>;
50
- /** How disabled keys behave. */
51
- readonly disabledBehavior: Accessor<DisabledBehavior>;
52
- /** Whether the selection is empty. */
53
- readonly isEmpty: Accessor<boolean>;
54
- /** Whether all items are selected. */
55
- readonly isSelectAll: Accessor<boolean>;
56
- /** Check if a key is selected. */
57
- isSelected(key: Key): boolean;
58
- /** Check if a key is disabled. */
59
- isDisabled(key: Key): boolean;
60
- /** Set the selection behavior. */
61
- setSelectionBehavior(behavior: SelectionBehavior): void;
62
- /** Toggle selection for a key. */
63
- toggleSelection(key: Key): void;
64
- /** Replace selection with a single key. */
65
- replaceSelection(key: Key): void;
66
- /** Set multiple selected keys. */
67
- setSelectedKeys(keys: Iterable<Key>): void;
68
- /** Select all items. */
69
- selectAll(): void;
70
- /** Clear all selection. */
71
- clearSelection(): void;
72
- /** Toggle between select all and clear. */
73
- toggleSelectAll(): void;
74
- /** Extend selection to a key (for shift-click). */
75
- extendSelection(toKey: Key, collection: Collection): void;
76
- /** Select a key based on interaction. */
77
- select(key: Key, e?: { shiftKey?: boolean; ctrlKey?: boolean; metaKey?: boolean }, collection?: Collection): void;
78
- }
79
-
80
- /**
81
- * Creates selection state for a collection.
82
- */
83
- export function createSelectionState(
84
- props: MaybeAccessor<SelectionStateProps> = {}
85
- ): SelectionState {
86
- const getProps = () => access(props);
87
-
88
- // Selection behavior state
89
- const [internalBehavior, setInternalBehavior] = createSignal<SelectionBehavior>('toggle');
90
-
91
- // Internal selection state
92
- const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<Selection>(
93
- getInitialSelection(getProps().defaultSelectedKeys)
94
- );
95
-
96
- // Track anchor for range selection
97
- const [anchorKey, setAnchorKey] = createSignal<Key | null>(null);
98
-
99
- // Computed values
100
- const selectionMode: Accessor<SelectionMode> = () => getProps().selectionMode ?? 'none';
101
-
102
- const selectionBehavior: Accessor<SelectionBehavior> = () => {
103
- return getProps().selectionBehavior ?? internalBehavior();
104
- };
105
-
106
- const disallowEmptySelection: Accessor<boolean> = () => {
107
- return getProps().disallowEmptySelection ?? false;
108
- };
109
-
110
- const selectedKeys: Accessor<Selection> = () => {
111
- const p = getProps();
112
- if (p.selectedKeys !== undefined) {
113
- return normalizeSelection(p.selectedKeys);
114
- }
115
- return internalSelectedKeys();
116
- };
117
-
118
- const disabledKeys: Accessor<Set<Key>> = () => {
119
- const keys = getProps().disabledKeys;
120
- return keys ? new Set(keys) : new Set();
121
- };
122
-
123
- const disabledBehavior: Accessor<DisabledBehavior> = () => {
124
- return getProps().disabledBehavior ?? 'all';
125
- };
126
-
127
- const isEmpty: Accessor<boolean> = () => {
128
- const keys = selectedKeys();
129
- return keys !== 'all' && keys.size === 0;
130
- };
131
-
132
- const isSelectAll: Accessor<boolean> = () => {
133
- return selectedKeys() === 'all';
134
- };
135
-
136
- // Methods
137
- const isSelected = (key: Key): boolean => {
138
- const keys = selectedKeys();
139
- if (keys === 'all') return true;
140
- return keys.has(key);
141
- };
142
-
143
- const isDisabled = (key: Key): boolean => {
144
- return disabledKeys().has(key);
145
- };
146
-
147
- const updateSelection = (newSelection: Selection) => {
148
- const p = getProps();
149
-
150
- // Controlled mode
151
- if (p.selectedKeys !== undefined) {
152
- p.onSelectionChange?.(newSelection);
153
- return;
154
- }
155
-
156
- // Uncontrolled mode
157
- const current = internalSelectedKeys();
158
- const isDifferent =
159
- current === 'all' ||
160
- newSelection === 'all' ||
161
- current.size !== (newSelection as Set<Key>).size ||
162
- ![...current].every((k) => (newSelection as Set<Key>).has(k));
163
-
164
- if (isDifferent || p.allowDuplicateSelectionEvents) {
165
- setInternalSelectedKeys(newSelection);
166
- p.onSelectionChange?.(newSelection);
167
- }
168
- };
169
-
170
- const toggleSelection = (key: Key) => {
171
- if (isDisabled(key)) return;
172
- if (selectionMode() === 'none') return;
173
-
174
- const current = selectedKeys();
175
-
176
- if (selectionMode() === 'single') {
177
- if (isSelected(key) && !disallowEmptySelection()) {
178
- updateSelection(new Set());
179
- } else {
180
- updateSelection(new Set([key]));
181
- }
182
- return;
183
- }
184
-
185
- // Multiple selection
186
- if (current === 'all') {
187
- // Can't toggle when all selected without collection
188
- return;
189
- }
190
-
191
- const newSelection = new Set(current);
192
- if (newSelection.has(key)) {
193
- if (newSelection.size > 1 || !disallowEmptySelection()) {
194
- newSelection.delete(key);
195
- }
196
- } else {
197
- newSelection.add(key);
198
- }
199
-
200
- updateSelection(newSelection);
201
- setAnchorKey(key);
202
- };
203
-
204
- const replaceSelection = (key: Key) => {
205
- if (isDisabled(key)) return;
206
- if (selectionMode() === 'none') return;
207
-
208
- updateSelection(new Set([key]));
209
- setAnchorKey(key);
210
- };
211
-
212
- const setSelectedKeys = (keys: Iterable<Key>) => {
213
- const filtered = [...keys].filter((k) => !isDisabled(k));
214
- updateSelection(new Set(filtered));
215
- };
216
-
217
- const selectAll = () => {
218
- if (selectionMode() !== 'multiple') return;
219
- updateSelection('all');
220
- };
221
-
222
- const clearSelection = () => {
223
- if (disallowEmptySelection()) return;
224
- updateSelection(new Set());
225
- };
226
-
227
- const toggleSelectAll = () => {
228
- if (selectionMode() !== 'multiple') return;
229
-
230
- if (isSelectAll()) {
231
- clearSelection();
232
- } else {
233
- selectAll();
234
- }
235
- };
236
-
237
- const extendSelection = (toKey: Key, collection: Collection) => {
238
- if (isDisabled(toKey)) return;
239
- if (selectionMode() !== 'multiple') {
240
- replaceSelection(toKey);
241
- return;
242
- }
243
-
244
- const anchor = anchorKey();
245
- if (!anchor) {
246
- replaceSelection(toKey);
247
- return;
248
- }
249
-
250
- // Get keys between anchor and toKey
251
- const keys = [...collection.getKeys()];
252
- const anchorIndex = keys.indexOf(anchor);
253
- const toIndex = keys.indexOf(toKey);
254
-
255
- if (anchorIndex === -1 || toIndex === -1) {
256
- replaceSelection(toKey);
257
- return;
258
- }
259
-
260
- const start = Math.min(anchorIndex, toIndex);
261
- const end = Math.max(anchorIndex, toIndex);
262
- const rangeKeys = keys.slice(start, end + 1).filter((k) => !isDisabled(k));
263
-
264
- updateSelection(new Set(rangeKeys));
265
- };
266
-
267
- const select = (
268
- key: Key,
269
- e?: { shiftKey?: boolean; ctrlKey?: boolean; metaKey?: boolean },
270
- collection?: Collection
271
- ) => {
272
- if (isDisabled(key)) return;
273
- if (selectionMode() === 'none') return;
274
-
275
- const mode = selectionMode();
276
- const behavior = selectionBehavior();
277
-
278
- if (mode === 'single') {
279
- if (behavior === 'replace' || !isSelected(key)) {
280
- replaceSelection(key);
281
- } else if (!disallowEmptySelection()) {
282
- clearSelection();
283
- }
284
- return;
285
- }
286
-
287
- // Multiple selection
288
- if (e?.shiftKey && collection) {
289
- extendSelection(key, collection);
290
- return;
291
- }
292
-
293
- if (e?.ctrlKey || e?.metaKey || behavior === 'toggle') {
294
- toggleSelection(key);
295
- } else {
296
- replaceSelection(key);
297
- }
298
- };
299
-
300
- const setSelectionBehavior = (behavior: SelectionBehavior) => {
301
- setInternalBehavior(behavior);
302
- };
303
-
304
- return {
305
- selectionMode,
306
- selectionBehavior,
307
- disallowEmptySelection,
308
- selectedKeys,
309
- disabledKeys,
310
- disabledBehavior,
311
- isEmpty,
312
- isSelectAll,
313
- isSelected,
314
- isDisabled,
315
- setSelectionBehavior,
316
- toggleSelection,
317
- replaceSelection,
318
- setSelectedKeys,
319
- selectAll,
320
- clearSelection,
321
- toggleSelectAll,
322
- extendSelection,
323
- select,
324
- };
325
- }
326
-
327
- // Helper functions
328
- function getInitialSelection(defaultKeys?: 'all' | Iterable<Key>): Selection {
329
- if (defaultKeys === undefined) return new Set();
330
- return normalizeSelection(defaultKeys);
331
- }
332
-
333
- function normalizeSelection(keys: 'all' | Iterable<Key>): Selection {
334
- if (keys === 'all') return 'all';
335
- return new Set(keys);
336
- }
@@ -1,6 +0,0 @@
1
- export type { Key, SelectionMode, SelectionBehavior, Selection, FocusStrategy, DisabledBehavior, CollectionNode, Collection, ItemProps, SectionProps, CollectionBase, SingleSelection, MultipleSelection, } from './types';
2
- export { ListCollection, createListCollection } from './ListCollection';
3
- export { createSelectionState, type SelectionStateProps, type SelectionState, } from './createSelectionState';
4
- export { createListState, createSingleSelectListState, type ListStateProps, type ListState, type SingleSelectListStateProps, type SingleSelectListState, } from './createListState';
5
- export { createMenuState, createMenuTriggerState, type MenuStateProps, type MenuState, type MenuTriggerStateProps, type MenuTriggerState, } from './createMenuState';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,GAAG,EACH,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,SAAS,EACT,YAAY,EACZ,cAAc,EACd,eAAe,EACf,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxE,OAAO,EACL,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,GAC3B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAC"}
@@ -1,46 +0,0 @@
1
- // Types
2
- export type {
3
- Key,
4
- SelectionMode,
5
- SelectionBehavior,
6
- Selection,
7
- FocusStrategy,
8
- DisabledBehavior,
9
- CollectionNode,
10
- Collection,
11
- ItemProps,
12
- SectionProps,
13
- CollectionBase,
14
- SingleSelection,
15
- MultipleSelection,
16
- } from './types';
17
-
18
- // List Collection
19
- export { ListCollection, createListCollection } from './ListCollection';
20
-
21
- // Selection State
22
- export {
23
- createSelectionState,
24
- type SelectionStateProps,
25
- type SelectionState,
26
- } from './createSelectionState';
27
-
28
- // List State
29
- export {
30
- createListState,
31
- createSingleSelectListState,
32
- type ListStateProps,
33
- type ListState,
34
- type SingleSelectListStateProps,
35
- type SingleSelectListState,
36
- } from './createListState';
37
-
38
- // Menu State
39
- export {
40
- createMenuState,
41
- createMenuTriggerState,
42
- type MenuStateProps,
43
- type MenuState,
44
- type MenuTriggerStateProps,
45
- type MenuTriggerState,
46
- } from './createMenuState';
@@ -1,147 +0,0 @@
1
- /**
2
- * Core types for collection state management.
3
- * Simplified from @react-stately/collections for SolidJS.
4
- */
5
- import type { JSX } from 'solid-js';
6
- /** A unique identifier for an item in a collection. */
7
- export type Key = string | number;
8
- /** The type of selection allowed in a collection. */
9
- export type SelectionMode = 'none' | 'single' | 'multiple';
10
- /** How selection behaves when clicking on items. */
11
- export type SelectionBehavior = 'toggle' | 'replace';
12
- /** Represents the current selection state. */
13
- export type Selection = 'all' | Set<Key>;
14
- /** Strategy for focusing first or last item. */
15
- export type FocusStrategy = 'first' | 'last';
16
- /** Whether disabled keys affect selection, actions, or both. */
17
- export type DisabledBehavior = 'selection' | 'all';
18
- /**
19
- * Represents a node in a collection (item or section).
20
- */
21
- export interface CollectionNode<T = unknown> {
22
- /** The type of node: 'item' or 'section'. */
23
- type: 'item' | 'section';
24
- /** A unique key for the node. */
25
- key: Key;
26
- /** The original value/data for this node. */
27
- value: T | null;
28
- /** The text content for accessibility and typeahead. */
29
- textValue: string;
30
- /** The rendered content (JSX). */
31
- rendered: JSX.Element;
32
- /** The level of nesting (0 for top-level). */
33
- level: number;
34
- /** The index within the parent. */
35
- index: number;
36
- /** The key of the parent node, if any. */
37
- parentKey: Key | null;
38
- /** Whether this node has child nodes. */
39
- hasChildNodes: boolean;
40
- /** Child nodes, if any. */
41
- childNodes: CollectionNode<T>[];
42
- /** Whether this item is disabled. */
43
- isDisabled?: boolean;
44
- /** ARIA label for this node. */
45
- 'aria-label'?: string;
46
- /** Additional props for the node. */
47
- props?: Record<string, unknown>;
48
- }
49
- /**
50
- * A collection of nodes with methods to traverse and query.
51
- */
52
- export interface Collection<T = unknown> extends Iterable<CollectionNode<T>> {
53
- /** The number of items in the collection. */
54
- readonly size: number;
55
- /** Get all keys in the collection. */
56
- getKeys(): Iterable<Key>;
57
- /** Get a node by its key. */
58
- getItem(key: Key): CollectionNode<T> | null;
59
- /** Get a node by index. */
60
- at(index: number): CollectionNode<T> | null;
61
- /** Get the key before the given key. */
62
- getKeyBefore(key: Key): Key | null;
63
- /** Get the key after the given key. */
64
- getKeyAfter(key: Key): Key | null;
65
- /** Get the first key in the collection. */
66
- getFirstKey(): Key | null;
67
- /** Get the last key in the collection. */
68
- getLastKey(): Key | null;
69
- /** Get the children of a node. */
70
- getChildren(key: Key): Iterable<CollectionNode<T>>;
71
- /** Get the text value for a key. */
72
- getTextValue(key: Key): string;
73
- }
74
- /**
75
- * Props for items in a collection.
76
- */
77
- export interface ItemProps<T = unknown> {
78
- /** Unique key for the item. Required if items is used for dynamic collections. */
79
- key?: Key;
80
- /** The text value for accessibility and typeahead. If not provided, derived from children. */
81
- textValue?: string;
82
- /** Whether the item is disabled. */
83
- isDisabled?: boolean;
84
- /** The rendered content of the item. */
85
- children?: JSX.Element;
86
- /** ARIA label for the item. */
87
- 'aria-label'?: string;
88
- /** The original value for dynamic collections. */
89
- value?: T;
90
- }
91
- /**
92
- * Props for sections in a collection.
93
- */
94
- export interface SectionProps<T = unknown> {
95
- /** Unique key for the section. */
96
- key?: Key;
97
- /** The section header/title. */
98
- title?: JSX.Element;
99
- /** ARIA label for the section. */
100
- 'aria-label'?: string;
101
- /** The items in this section. */
102
- children?: JSX.Element;
103
- /** Items for dynamic rendering. */
104
- items?: Iterable<T>;
105
- }
106
- /**
107
- * Base props for components that use collections.
108
- */
109
- export interface CollectionBase<T = unknown> {
110
- /** The items in the collection (for dynamic rendering). */
111
- items?: Iterable<T>;
112
- /** The children (static items or render function). */
113
- children?: JSX.Element | ((item: T) => JSX.Element);
114
- /** Keys of disabled items. */
115
- disabledKeys?: Iterable<Key>;
116
- }
117
- /**
118
- * Props for single selection.
119
- */
120
- export interface SingleSelection {
121
- /** Whether empty selection is allowed. */
122
- disallowEmptySelection?: boolean;
123
- /** The currently selected key (controlled). */
124
- selectedKey?: Key | null;
125
- /** The default selected key (uncontrolled). */
126
- defaultSelectedKey?: Key;
127
- /** Handler called when selection changes. */
128
- onSelectionChange?: (key: Key | null) => void;
129
- }
130
- /**
131
- * Props for multiple selection.
132
- */
133
- export interface MultipleSelection {
134
- /** The selection mode. */
135
- selectionMode?: SelectionMode;
136
- /** Whether empty selection is allowed. */
137
- disallowEmptySelection?: boolean;
138
- /** The currently selected keys (controlled). */
139
- selectedKeys?: 'all' | Iterable<Key>;
140
- /** The default selected keys (uncontrolled). */
141
- defaultSelectedKeys?: 'all' | Iterable<Key>;
142
- /** Handler called when selection changes. */
143
- onSelectionChange?: (keys: Selection) => void;
144
- /** Keys of disabled items. */
145
- disabledKeys?: Iterable<Key>;
146
- }
147
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,uDAAuD;AACvD,MAAM,MAAM,GAAG,GAAG,MAAM,GAAG,MAAM,CAAC;AAElC,qDAAqD;AACrD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU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