@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,327 +0,0 @@
1
- /**
2
- * Grid state management for Table and GridList components.
3
- * Based on @react-stately/grid/useGridState.
4
- */
5
-
6
- import { createSignal, createEffect, createMemo, on, type Accessor } from 'solid-js';
7
- import type {
8
- GridState,
9
- GridStateOptions,
10
- GridCollection,
11
- GridNode,
12
- } from './types';
13
- import type { Key, FocusStrategy } from '../collections/types';
14
-
15
- /**
16
- * Creates state management for a grid component.
17
- * Handles row selection, focus management, and keyboard navigation state.
18
- */
19
- export function createGridState<T extends object, C extends GridCollection<T> = GridCollection<T>>(
20
- options: Accessor<GridStateOptions<T, C>>
21
- ): GridState<T, C> {
22
- const getOptions = () => options();
23
-
24
- // Disabled keys as a Set
25
- const disabledKeys = createMemo(() => {
26
- const keys = getOptions().disabledKeys;
27
- return keys ? new Set(keys) : new Set<Key>();
28
- });
29
-
30
- // Focus state
31
- const [isFocused, setIsFocused] = createSignal(false);
32
- const [focusedKey, setFocusedKeyInternal] = createSignal<Key | null>(null);
33
- const [childFocusStrategy, setChildFocusStrategy] = createSignal<FocusStrategy | null>(null);
34
- const [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = createSignal(false);
35
-
36
- // Selection state
37
- const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<'all' | Set<Key>>(
38
- getInitialSelection(getOptions().defaultSelectedKeys)
39
- );
40
- const [anchorKey, setAnchorKey] = createSignal<Key | null>(null);
41
-
42
- // Computed selection
43
- const selectedKeys = createMemo(() => {
44
- const opts = getOptions();
45
- if (opts.selectedKeys !== undefined) {
46
- return normalizeSelection(opts.selectedKeys);
47
- }
48
- return internalSelectedKeys();
49
- });
50
-
51
- const selectionMode = createMemo(() => getOptions().selectionMode ?? 'none');
52
- const selectionBehavior = createMemo(() => getOptions().selectionBehavior ?? 'toggle');
53
- const disallowEmptySelection = createMemo(() => getOptions().disallowEmptySelection ?? false);
54
-
55
- // Focus mode handling
56
- const focusMode = createMemo(() => getOptions().focusMode ?? 'row');
57
-
58
- // Set focused key with focus mode awareness
59
- const setFocusedKey = (key: Key | null, strategy: FocusStrategy = 'first') => {
60
- const opts = getOptions();
61
- const collection = opts.collection;
62
-
63
- // If focusMode is cell and an item is focused, focus a child cell instead
64
- if (focusMode() === 'cell' && key != null) {
65
- const item = collection.getItem(key);
66
- if (item?.type === 'item') {
67
- const children = [...collection.getChildren(key)];
68
- if (strategy === 'last') {
69
- key = children[children.length - 1]?.key ?? key;
70
- } else {
71
- key = children[0]?.key ?? key;
72
- }
73
- }
74
- }
75
-
76
- setFocusedKeyInternal(key);
77
- setChildFocusStrategy(strategy);
78
- };
79
-
80
- // Reset focused key if the item is deleted from the collection
81
- let cachedCollection: C | null = null;
82
-
83
- createEffect(
84
- on(
85
- () => getOptions().collection,
86
- (collection) => {
87
- const currentFocusedKey = focusedKey();
88
-
89
- if (currentFocusedKey != null && cachedCollection && !collection.getItem(currentFocusedKey)) {
90
- // The focused item was deleted, find a new one to focus
91
- const node = cachedCollection.getItem(currentFocusedKey);
92
- const parentNode =
93
- node?.parentKey != null &&
94
- (node.type === 'cell' || node.type === 'rowheader' || node.type === 'column')
95
- ? cachedCollection.getItem(node.parentKey)
96
- : node;
97
-
98
- if (!parentNode) {
99
- setFocusedKeyInternal(null);
100
- cachedCollection = collection;
101
- return;
102
- }
103
-
104
- const cachedRows = cachedCollection.rows;
105
- const rows = collection.rows;
106
- const diff = cachedRows.length - rows.length;
107
-
108
- let index = Math.min(
109
- diff > 1 ? Math.max(parentNode.index - diff + 1, 0) : parentNode.index,
110
- rows.length - 1
111
- );
112
-
113
- let newRow: GridNode<T> | null = null;
114
- while (index >= 0) {
115
- const row = rows[index];
116
- if (!disabledKeys().has(row.key) && row.type !== 'headerrow') {
117
- newRow = row;
118
- break;
119
- }
120
- // Find next, not disabled row
121
- if (index < rows.length - 1) {
122
- index++;
123
- } else {
124
- // Otherwise, find previous, not disabled row
125
- if (index > parentNode.index) {
126
- index = parentNode.index;
127
- }
128
- index--;
129
- }
130
- }
131
-
132
- if (newRow) {
133
- const childNodes = newRow.hasChildNodes ? [...collection.getChildren(newRow.key)] : [];
134
- const keyToFocus =
135
- newRow.hasChildNodes &&
136
- parentNode !== node &&
137
- node &&
138
- node.index < childNodes.length
139
- ? childNodes[node.index].key
140
- : newRow.key;
141
- setFocusedKeyInternal(keyToFocus);
142
- } else {
143
- setFocusedKeyInternal(null);
144
- }
145
- }
146
-
147
- cachedCollection = collection;
148
- }
149
- )
150
- );
151
-
152
- // Selection methods
153
- const isSelected = (key: Key): boolean => {
154
- const keys = selectedKeys();
155
- if (keys === 'all') return true;
156
- return keys.has(key);
157
- };
158
-
159
- const isDisabled = (key: Key): boolean => {
160
- return disabledKeys().has(key);
161
- };
162
-
163
- const updateSelection = (newSelection: 'all' | Set<Key>) => {
164
- const opts = getOptions();
165
-
166
- // Controlled mode
167
- if (opts.selectedKeys !== undefined) {
168
- opts.onSelectionChange?.(newSelection);
169
- return;
170
- }
171
-
172
- // Uncontrolled mode
173
- const current = internalSelectedKeys();
174
- const isDifferent =
175
- current === 'all' ||
176
- newSelection === 'all' ||
177
- current.size !== (newSelection as Set<Key>).size ||
178
- ![...current].every((k) => (newSelection as Set<Key>).has(k));
179
-
180
- if (isDifferent) {
181
- setInternalSelectedKeys(newSelection);
182
- opts.onSelectionChange?.(newSelection);
183
- }
184
- };
185
-
186
- const toggleSelection = (key: Key) => {
187
- if (isDisabled(key)) return;
188
- if (selectionMode() === 'none') return;
189
-
190
- const current = selectedKeys();
191
-
192
- if (selectionMode() === 'single') {
193
- if (isSelected(key) && !disallowEmptySelection()) {
194
- updateSelection(new Set());
195
- } else {
196
- updateSelection(new Set([key]));
197
- }
198
- return;
199
- }
200
-
201
- // Multiple selection
202
- if (current === 'all') {
203
- // Can't toggle when all selected without knowing all keys
204
- return;
205
- }
206
-
207
- const newSelection = new Set(current);
208
- if (newSelection.has(key)) {
209
- if (newSelection.size > 1 || !disallowEmptySelection()) {
210
- newSelection.delete(key);
211
- }
212
- } else {
213
- newSelection.add(key);
214
- }
215
-
216
- updateSelection(newSelection);
217
- setAnchorKey(key);
218
- };
219
-
220
- const replaceSelection = (key: Key) => {
221
- if (isDisabled(key)) return;
222
- if (selectionMode() === 'none') return;
223
-
224
- updateSelection(new Set([key]));
225
- setAnchorKey(key);
226
- };
227
-
228
- const extendSelection = (toKey: Key) => {
229
- if (isDisabled(toKey)) return;
230
- if (selectionMode() !== 'multiple') {
231
- replaceSelection(toKey);
232
- return;
233
- }
234
-
235
- const anchor = anchorKey();
236
- if (!anchor) {
237
- replaceSelection(toKey);
238
- return;
239
- }
240
-
241
- const collection = getOptions().collection;
242
- const rows = collection.rows.filter((r) => r.type === 'item');
243
- const keys = rows.map((r) => r.key);
244
- const anchorIndex = keys.indexOf(anchor);
245
- const toIndex = keys.indexOf(toKey);
246
-
247
- if (anchorIndex === -1 || toIndex === -1) {
248
- replaceSelection(toKey);
249
- return;
250
- }
251
-
252
- const start = Math.min(anchorIndex, toIndex);
253
- const end = Math.max(anchorIndex, toIndex);
254
- const rangeKeys = keys.slice(start, end + 1).filter((k) => !isDisabled(k));
255
-
256
- updateSelection(new Set(rangeKeys));
257
- };
258
-
259
- const selectAll = () => {
260
- if (selectionMode() !== 'multiple') return;
261
- updateSelection('all');
262
- };
263
-
264
- const clearSelection = () => {
265
- if (disallowEmptySelection()) return;
266
- updateSelection(new Set());
267
- };
268
-
269
- const toggleSelectAll = () => {
270
- if (selectionMode() !== 'multiple') return;
271
-
272
- if (selectedKeys() === 'all') {
273
- clearSelection();
274
- } else {
275
- selectAll();
276
- }
277
- };
278
-
279
- return {
280
- get collection() {
281
- return getOptions().collection;
282
- },
283
- get disabledKeys() {
284
- return disabledKeys();
285
- },
286
- get isKeyboardNavigationDisabled() {
287
- return isKeyboardNavigationDisabled();
288
- },
289
- get focusedKey() {
290
- return focusedKey();
291
- },
292
- get childFocusStrategy() {
293
- return childFocusStrategy();
294
- },
295
- get isFocused() {
296
- return isFocused();
297
- },
298
- get selectionMode() {
299
- return selectionMode();
300
- },
301
- get selectedKeys() {
302
- return selectedKeys();
303
- },
304
- isSelected,
305
- isDisabled,
306
- setFocusedKey,
307
- setFocused: setIsFocused,
308
- toggleSelection,
309
- replaceSelection,
310
- extendSelection,
311
- selectAll,
312
- clearSelection,
313
- toggleSelectAll,
314
- setKeyboardNavigationDisabled,
315
- };
316
- }
317
-
318
- // Helper functions
319
- function getInitialSelection(defaultKeys?: 'all' | Iterable<Key>): 'all' | Set<Key> {
320
- if (defaultKeys === undefined) return new Set();
321
- return normalizeSelection(defaultKeys);
322
- }
323
-
324
- function normalizeSelection(keys: 'all' | Iterable<Key>): 'all' | Set<Key> {
325
- if (keys === 'all') return 'all';
326
- return new Set(keys);
327
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Grid state management module.
3
- * Provides state hooks for Table and GridList components.
4
- */
5
- export { createGridState } from './createGridState';
6
- export type { GridState, GridStateOptions, GridCollection, GridNode, GridNodeType, } from './types';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,YAAY,GACb,MAAM,SAAS,CAAC"}
package/src/grid/index.ts DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * Grid state management module.
3
- * Provides state hooks for Table and GridList components.
4
- */
5
-
6
- export { createGridState } from './createGridState';
7
- export type {
8
- GridState,
9
- GridStateOptions,
10
- GridCollection,
11
- GridNode,
12
- GridNodeType,
13
- } from './types';
@@ -1,156 +0,0 @@
1
- /**
2
- * Grid collection types for Table and GridList components.
3
- * Based on @react-types/grid.
4
- */
5
- import type { Key, FocusStrategy } from '../collections/types';
6
- /**
7
- * Represents the type of a grid node.
8
- */
9
- export type GridNodeType = 'item' | 'cell' | 'column' | 'rowheader' | 'headerrow' | 'section' | 'placeholder';
10
- /**
11
- * Represents a node in a grid collection.
12
- */
13
- export interface GridNode<T = unknown> {
14
- /** The type of grid node. */
15
- type: GridNodeType;
16
- /** A unique key for the node. */
17
- key: Key;
18
- /** The original value/data for this node. */
19
- value: T | null;
20
- /** The text content for accessibility and typeahead. */
21
- textValue: string;
22
- /** The rendered content (JSX) - optional for programmatic nodes. */
23
- rendered?: unknown;
24
- /** The level of nesting (0 for top-level). */
25
- level: number;
26
- /** The index within the parent. */
27
- index: number;
28
- /** The key of the parent node, if any. */
29
- parentKey?: Key | null;
30
- /** Whether this node has child nodes. */
31
- hasChildNodes: boolean;
32
- /** Child nodes (cells for rows, rows for sections). */
33
- childNodes: GridNode<T>[];
34
- /** Whether this item is disabled. */
35
- isDisabled?: boolean;
36
- /** ARIA label for this node. */
37
- 'aria-label'?: string;
38
- /** Additional props for the node. */
39
- props?: Record<string, unknown>;
40
- /** Column index for cells. */
41
- column?: number;
42
- /** Column span for cells. */
43
- colspan?: number;
44
- /** Row index. */
45
- rowIndex?: number;
46
- /** Whether this row can be expanded (for tree grids). */
47
- isExpandable?: boolean;
48
- /** Whether this row is expanded. */
49
- isExpanded?: boolean;
50
- }
51
- /**
52
- * A collection of grid nodes with grid-specific navigation.
53
- */
54
- export interface GridCollection<T = unknown> {
55
- /** The number of items in the collection. */
56
- readonly size: number;
57
- /** All rows in the grid (including header rows). */
58
- readonly rows: GridNode<T>[];
59
- /** All column definitions. */
60
- readonly columns: GridNode<T>[];
61
- /** Number of header rows. */
62
- readonly headerRows: GridNode<T>[];
63
- /** Number of body rows (excluding headers). */
64
- readonly rowCount: number;
65
- /** Number of columns. */
66
- readonly columnCount: number;
67
- /** Get all keys in the collection. */
68
- getKeys(): Iterable<Key>;
69
- /** Get a node by its key. */
70
- getItem(key: Key): GridNode<T> | null;
71
- /** Get a node by index. */
72
- at(index: number): GridNode<T> | null;
73
- /** Get the key before the given key. */
74
- getKeyBefore(key: Key): Key | null;
75
- /** Get the key after the given key. */
76
- getKeyAfter(key: Key): Key | null;
77
- /** Get the first key in the collection. */
78
- getFirstKey(): Key | null;
79
- /** Get the last key in the collection. */
80
- getLastKey(): Key | null;
81
- /** Get the children of a node. */
82
- getChildren(key: Key): Iterable<GridNode<T>>;
83
- /** Get the text value for a key. */
84
- getTextValue(key: Key): string;
85
- /** Get a cell by row and column key. */
86
- getCell(rowKey: Key, columnKey: Key): GridNode<T> | null;
87
- /** Iterator over all nodes. */
88
- [Symbol.iterator](): Iterator<GridNode<T>>;
89
- }
90
- /**
91
- * State for a grid component.
92
- */
93
- export interface GridState<T, C extends GridCollection<T> = GridCollection<T>> {
94
- /** The grid collection. */
95
- readonly collection: C;
96
- /** Keys of disabled rows. */
97
- readonly disabledKeys: Set<Key>;
98
- /** Whether keyboard navigation is disabled. */
99
- readonly isKeyboardNavigationDisabled: boolean;
100
- /** Currently focused key. */
101
- readonly focusedKey: Key | null;
102
- /** Focus strategy for child focus. */
103
- readonly childFocusStrategy: FocusStrategy | null;
104
- /** Whether the grid is focused. */
105
- readonly isFocused: boolean;
106
- /** The selection mode. */
107
- readonly selectionMode: 'none' | 'single' | 'multiple';
108
- /** The currently selected keys. */
109
- readonly selectedKeys: 'all' | Set<Key>;
110
- /** Check if a key is selected. */
111
- isSelected(key: Key): boolean;
112
- /** Check if a key is disabled. */
113
- isDisabled(key: Key): boolean;
114
- /** Set the focused key. */
115
- setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void;
116
- /** Set focused state. */
117
- setFocused(isFocused: boolean): void;
118
- /** Toggle selection for a key. */
119
- toggleSelection(key: Key): void;
120
- /** Replace selection with a key. */
121
- replaceSelection(key: Key): void;
122
- /** Extend selection to a key (shift-click). */
123
- extendSelection(toKey: Key): void;
124
- /** Select all rows. */
125
- selectAll(): void;
126
- /** Clear selection. */
127
- clearSelection(): void;
128
- /** Toggle select all. */
129
- toggleSelectAll(): void;
130
- /** Set keyboard navigation disabled. */
131
- setKeyboardNavigationDisabled(isDisabled: boolean): void;
132
- }
133
- /**
134
- * Options for creating grid state.
135
- */
136
- export interface GridStateOptions<T, C extends GridCollection<T> = GridCollection<T>> {
137
- /** The grid collection. */
138
- collection: C;
139
- /** Keys of disabled rows. */
140
- disabledKeys?: Iterable<Key>;
141
- /** Focus mode: 'row' or 'cell'. */
142
- focusMode?: 'row' | 'cell';
143
- /** Selection mode. */
144
- selectionMode?: 'none' | 'single' | 'multiple';
145
- /** Selection behavior. */
146
- selectionBehavior?: 'toggle' | 'replace';
147
- /** Whether empty selection is disallowed. */
148
- disallowEmptySelection?: boolean;
149
- /** Currently selected keys (controlled). */
150
- selectedKeys?: 'all' | Iterable<Key>;
151
- /** Default selected keys (uncontrolled). */
152
- defaultSelectedKeys?: 'all' | Iterable<Key>;
153
- /** Handler for selection changes. */
154
- onSelectionChange?: (keys: 'all' | Set<Key>) => void;
155
- }
156
- //# 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,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for Table and GridList components.
3
- * Based on @react-types/grid.
4
- */
5
-
6
- import type { Key, FocusStrategy } from '../collections/types';
7
-
8
- /**
9
- * Represents the type of a grid node.
10
- */
11
- export type GridNodeType =
12
- | 'item' // A selectable row
13
- | 'cell' // A cell within a row
14
- | 'column' // A column header
15
- | 'rowheader' // A cell that acts as a row header
16
- | 'headerrow' // A header row container
17
- | 'section' // A section/group
18
- | 'placeholder'; // A placeholder (e.g., empty row)
19
-
20
- /**
21
- * Represents a node in a grid collection.
22
- */
23
- export interface GridNode<T = unknown> {
24
- /** The type of grid node. */
25
- type: GridNodeType;
26
- /** A unique key for the node. */
27
- key: Key;
28
- /** The original value/data for this node. */
29
- value: T | null;
30
- /** The text content for accessibility and typeahead. */
31
- textValue: string;
32
- /** The rendered content (JSX) - optional for programmatic nodes. */
33
- rendered?: unknown;
34
- /** The level of nesting (0 for top-level). */
35
- level: number;
36
- /** The index within the parent. */
37
- index: number;
38
- /** The key of the parent node, if any. */
39
- parentKey?: Key | null;
40
- /** Whether this node has child nodes. */
41
- hasChildNodes: boolean;
42
- /** Child nodes (cells for rows, rows for sections). */
43
- childNodes: GridNode<T>[];
44
- /** Whether this item is disabled. */
45
- isDisabled?: boolean;
46
- /** ARIA label for this node. */
47
- 'aria-label'?: string;
48
- /** Additional props for the node. */
49
- props?: Record<string, unknown>;
50
- /** Column index for cells. */
51
- column?: number;
52
- /** Column span for cells. */
53
- colspan?: number;
54
- /** Row index. */
55
- rowIndex?: number;
56
- /** Whether this row can be expanded (for tree grids). */
57
- isExpandable?: boolean;
58
- /** Whether this row is expanded. */
59
- isExpanded?: boolean;
60
- }
61
-
62
- /**
63
- * A collection of grid nodes with grid-specific navigation.
64
- */
65
- export interface GridCollection<T = unknown> {
66
- /** The number of items in the collection. */
67
- readonly size: number;
68
- /** All rows in the grid (including header rows). */
69
- readonly rows: GridNode<T>[];
70
- /** All column definitions. */
71
- readonly columns: GridNode<T>[];
72
- /** Number of header rows. */
73
- readonly headerRows: GridNode<T>[];
74
- /** Number of body rows (excluding headers). */
75
- readonly rowCount: number;
76
- /** Number of columns. */
77
- readonly columnCount: number;
78
-
79
- /** Get all keys in the collection. */
80
- getKeys(): Iterable<Key>;
81
-
82
- /** Get a node by its key. */
83
- getItem(key: Key): GridNode<T> | null;
84
-
85
- /** Get a node by index. */
86
- at(index: number): GridNode<T> | null;
87
-
88
- /** Get the key before the given key. */
89
- getKeyBefore(key: Key): Key | null;
90
-
91
- /** Get the key after the given key. */
92
- getKeyAfter(key: Key): Key | null;
93
-
94
- /** Get the first key in the collection. */
95
- getFirstKey(): Key | null;
96
-
97
- /** Get the last key in the collection. */
98
- getLastKey(): Key | null;
99
-
100
- /** Get the children of a node. */
101
- getChildren(key: Key): Iterable<GridNode<T>>;
102
-
103
- /** Get the text value for a key. */
104
- getTextValue(key: Key): string;
105
-
106
- /** Get a cell by row and column key. */
107
- getCell(rowKey: Key, columnKey: Key): GridNode<T> | null;
108
-
109
- /** Iterator over all nodes. */
110
- [Symbol.iterator](): Iterator<GridNode<T>>;
111
- }
112
-
113
- /**
114
- * State for a grid component.
115
- */
116
- export interface GridState<T, C extends GridCollection<T> = GridCollection<T>> {
117
- /** The grid collection. */
118
- readonly collection: C;
119
- /** Keys of disabled rows. */
120
- readonly disabledKeys: Set<Key>;
121
- /** Whether keyboard navigation is disabled. */
122
- readonly isKeyboardNavigationDisabled: boolean;
123
- /** Currently focused key. */
124
- readonly focusedKey: Key | null;
125
- /** Focus strategy for child focus. */
126
- readonly childFocusStrategy: FocusStrategy | null;
127
- /** Whether the grid is focused. */
128
- readonly isFocused: boolean;
129
- /** The selection mode. */
130
- readonly selectionMode: 'none' | 'single' | 'multiple';
131
- /** The currently selected keys. */
132
- readonly selectedKeys: 'all' | Set<Key>;
133
- /** Check if a key is selected. */
134
- isSelected(key: Key): boolean;
135
- /** Check if a key is disabled. */
136
- isDisabled(key: Key): boolean;
137
- /** Set the focused key. */
138
- setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void;
139
- /** Set focused state. */
140
- setFocused(isFocused: boolean): void;
141
- /** Toggle selection for a key. */
142
- toggleSelection(key: Key): void;
143
- /** Replace selection with a key. */
144
- replaceSelection(key: Key): void;
145
- /** Extend selection to a key (shift-click). */
146
- extendSelection(toKey: Key): void;
147
- /** Select all rows. */
148
- selectAll(): void;
149
- /** Clear selection. */
150
- clearSelection(): void;
151
- /** Toggle select all. */
152
- toggleSelectAll(): void;
153
- /** Set keyboard navigation disabled. */
154
- setKeyboardNavigationDisabled(isDisabled: boolean): void;
155
- }
156
-
157
- /**
158
- * Options for creating grid state.
159
- */
160
- export interface GridStateOptions<T, C extends GridCollection<T> = GridCollection<T>> {
161
- /** The grid collection. */
162
- collection: C;
163
- /** Keys of disabled rows. */
164
- disabledKeys?: Iterable<Key>;
165
- /** Focus mode: 'row' or 'cell'. */
166
- focusMode?: 'row' | 'cell';
167
- /** Selection mode. */
168
- selectionMode?: 'none' | 'single' | 'multiple';
169
- /** Selection behavior. */
170
- selectionBehavior?: 'toggle' | 'replace';
171
- /** Whether empty selection is disallowed. */
172
- disallowEmptySelection?: boolean;
173
- /** Currently selected keys (controlled). */
174
- selectedKeys?: 'all' | Iterable<Key>;
175
- /** Default selected keys (uncontrolled). */
176
- defaultSelectedKeys?: 'all' | Iterable<Key>;
177
- /** Handler for selection changes. */
178
- onSelectionChange?: (keys: 'all' | Set<Key>) => void;
179
- }