@proyecto-viviana/solid-stately 0.2.7 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/README.md +30 -283
  2. package/dist/autocomplete/createAutocompleteState.d.ts +2 -2
  3. package/dist/autocomplete/index.d.ts +1 -1
  4. package/dist/calendar/IncompleteDate.d.ts +61 -0
  5. package/dist/calendar/createCalendarState.d.ts +41 -16
  6. package/dist/calendar/createDateFieldState.d.ts +39 -9
  7. package/dist/calendar/createDatePickerState.d.ts +60 -0
  8. package/dist/calendar/createRangeCalendarState.d.ts +37 -10
  9. package/dist/calendar/createTimeFieldState.d.ts +34 -7
  10. package/dist/calendar/index.d.ts +7 -6
  11. package/dist/checkbox/createCheckboxGroupState.d.ts +6 -6
  12. package/dist/checkbox/index.d.ts +1 -1
  13. package/dist/collections/ListCollection.d.ts +1 -1
  14. package/dist/collections/createListState.d.ts +11 -8
  15. package/dist/collections/createMenuState.d.ts +7 -7
  16. package/dist/collections/createSelectionState.d.ts +22 -10
  17. package/dist/collections/getChildNodes.d.ts +11 -0
  18. package/dist/collections/index.d.ts +6 -5
  19. package/dist/collections/types.d.ts +12 -12
  20. package/dist/color/Color.d.ts +1 -1
  21. package/dist/color/createColorAreaState.d.ts +4 -2
  22. package/dist/color/createColorFieldState.d.ts +38 -12
  23. package/dist/color/createColorSliderState.d.ts +9 -2
  24. package/dist/color/createColorWheelState.d.ts +13 -2
  25. package/dist/color/getColorChannels.d.ts +1 -1
  26. package/dist/color/index.d.ts +6 -6
  27. package/dist/color/types.d.ts +4 -4
  28. package/dist/combobox/createComboBoxState.d.ts +34 -13
  29. package/dist/combobox/index.d.ts +1 -1
  30. package/dist/data/createAsyncList.d.ts +4 -4
  31. package/dist/data/createListData.d.ts +2 -2
  32. package/dist/data/createTreeData.d.ts +6 -2
  33. package/dist/data/index.d.ts +3 -3
  34. package/dist/datepicker/index.d.ts +2 -4
  35. package/dist/disclosure/createDisclosureState.d.ts +2 -2
  36. package/dist/disclosure/index.d.ts +1 -1
  37. package/dist/dnd/createDragState.d.ts +2 -2
  38. package/dist/dnd/createDraggableCollectionState.d.ts +2 -2
  39. package/dist/dnd/createDropState.d.ts +2 -2
  40. package/dist/dnd/createDroppableCollectionState.d.ts +3 -3
  41. package/dist/dnd/index.d.ts +5 -5
  42. package/dist/dnd/types.d.ts +19 -17
  43. package/dist/form/createFormValidationState.d.ts +3 -3
  44. package/dist/form/index.d.ts +1 -1
  45. package/dist/grid/createGridState.d.ts +2 -2
  46. package/dist/grid/index.d.ts +2 -2
  47. package/dist/grid/types.d.ts +27 -11
  48. package/dist/index.d.ts +31 -30
  49. package/dist/index.js +9077 -7246
  50. package/dist/index.js.map +1 -1
  51. package/dist/menu/index.d.ts +2 -2
  52. package/dist/numberfield/createNumberFieldState.d.ts +2 -2
  53. package/dist/numberfield/index.d.ts +1 -1
  54. package/dist/overlays/createOverlayTriggerState.d.ts +2 -2
  55. package/dist/overlays/index.d.ts +1 -1
  56. package/dist/radio/createRadioGroupState.d.ts +7 -7
  57. package/dist/radio/index.d.ts +1 -1
  58. package/dist/searchfield/createSearchFieldState.d.ts +2 -2
  59. package/dist/searchfield/index.d.ts +2 -2
  60. package/dist/select/createSelectState.d.ts +14 -8
  61. package/dist/select/index.d.ts +1 -1
  62. package/dist/selection/Selection.d.ts +16 -0
  63. package/dist/selection/SelectionManager.d.ts +110 -0
  64. package/dist/selection/createMultipleSelectionState.d.ts +59 -0
  65. package/dist/selection/index.d.ts +6 -5
  66. package/dist/slider/createSliderState.d.ts +3 -3
  67. package/dist/slider/index.d.ts +2 -2
  68. package/dist/steplist/createStepListState.d.ts +48 -0
  69. package/dist/steplist/index.d.ts +1 -0
  70. package/dist/table/TableCollection.d.ts +33 -3
  71. package/dist/table/createTableColumnResizeState.d.ts +54 -0
  72. package/dist/table/createTableState.d.ts +2 -2
  73. package/dist/table/createTreeGridState.d.ts +15 -0
  74. package/dist/table/index.d.ts +6 -3
  75. package/dist/table/types.d.ts +68 -10
  76. package/dist/tabs/createTabListState.d.ts +5 -5
  77. package/dist/tabs/index.d.ts +1 -1
  78. package/dist/textfield/createTextFieldState.d.ts +2 -2
  79. package/dist/textfield/index.d.ts +1 -1
  80. package/dist/toast/createToastState.d.ts +24 -2
  81. package/dist/toast/index.d.ts +1 -1
  82. package/dist/toggle/createToggleGroupState.d.ts +4 -4
  83. package/dist/toggle/createToggleState.d.ts +2 -2
  84. package/dist/toggle/index.d.ts +2 -2
  85. package/dist/tooltip/createTooltipTriggerState.d.ts +2 -2
  86. package/dist/tooltip/index.d.ts +1 -1
  87. package/dist/tree/TreeCollection.d.ts +2 -2
  88. package/dist/tree/createTreeState.d.ts +2 -2
  89. package/dist/tree/index.d.ts +3 -3
  90. package/dist/tree/types.d.ts +27 -13
  91. package/dist/utils/index.d.ts +1 -1
  92. package/dist/utils/reactivity.d.ts +1 -1
  93. package/package.json +29 -30
  94. package/src/autocomplete/createAutocompleteState.d.ts +19 -17
  95. package/src/autocomplete/createAutocompleteState.ts +24 -30
  96. package/src/autocomplete/index.d.ts +6 -2
  97. package/src/autocomplete/index.ts +1 -1
  98. package/src/calendar/IncompleteDate.ts +430 -0
  99. package/src/calendar/createCalendarState.d.ts +139 -117
  100. package/src/calendar/createCalendarState.ts +308 -94
  101. package/src/calendar/createDateFieldState.d.ts +130 -95
  102. package/src/calendar/createDateFieldState.ts +447 -334
  103. package/src/calendar/createDatePickerState.ts +347 -0
  104. package/src/calendar/createRangeCalendarState.d.ts +154 -129
  105. package/src/calendar/createRangeCalendarState.ts +411 -85
  106. package/src/calendar/createTimeFieldState.d.ts +81 -79
  107. package/src/calendar/createTimeFieldState.ts +187 -108
  108. package/src/calendar/index.d.ts +80 -7
  109. package/src/calendar/index.ts +23 -12
  110. package/src/checkbox/createCheckboxGroupState.d.ts +57 -55
  111. package/src/checkbox/createCheckboxGroupState.ts +20 -29
  112. package/src/checkbox/index.d.ts +6 -2
  113. package/src/checkbox/index.ts +1 -1
  114. package/src/collections/ListCollection.d.ts +25 -22
  115. package/src/collections/ListCollection.ts +6 -6
  116. package/src/collections/createListState.d.ts +73 -58
  117. package/src/collections/createListState.ts +67 -35
  118. package/src/collections/createMenuState.d.ts +36 -31
  119. package/src/collections/createMenuState.ts +21 -12
  120. package/src/collections/createSelectionState.d.ts +78 -65
  121. package/src/collections/createSelectionState.ts +66 -52
  122. package/src/collections/getChildNodes.ts +98 -0
  123. package/src/collections/index.d.ts +38 -6
  124. package/src/collections/index.ts +14 -10
  125. package/src/collections/types.d.ts +101 -101
  126. package/src/collections/types.ts +12 -12
  127. package/src/color/Color.d.ts +20 -5
  128. package/src/color/Color.ts +357 -254
  129. package/src/color/createColorAreaState.d.ts +67 -65
  130. package/src/color/createColorAreaState.ts +21 -13
  131. package/src/color/createColorFieldState.d.ts +46 -44
  132. package/src/color/createColorFieldState.ts +285 -149
  133. package/src/color/createColorSliderState.d.ts +58 -56
  134. package/src/color/createColorSliderState.ts +45 -14
  135. package/src/color/createColorWheelState.d.ts +42 -40
  136. package/src/color/createColorWheelState.ts +101 -64
  137. package/src/color/getColorChannels.ts +7 -5
  138. package/src/color/index.d.ts +36 -7
  139. package/src/color/index.ts +6 -9
  140. package/src/color/types.d.ts +68 -63
  141. package/src/color/types.ts +11 -19
  142. package/src/combobox/createComboBoxState.d.ts +107 -105
  143. package/src/combobox/createComboBoxState.ts +184 -89
  144. package/src/combobox/index.d.ts +10 -2
  145. package/src/combobox/index.ts +1 -1
  146. package/src/data/createAsyncList.ts +89 -63
  147. package/src/data/createListData.ts +67 -67
  148. package/src/data/createTreeData.ts +304 -91
  149. package/src/data/index.ts +3 -3
  150. package/src/datepicker/index.ts +6 -10
  151. package/src/disclosure/createDisclosureState.d.ts +47 -43
  152. package/src/disclosure/createDisclosureState.ts +7 -21
  153. package/src/disclosure/index.d.ts +10 -2
  154. package/src/disclosure/index.ts +1 -1
  155. package/src/dnd/createDragState.d.ts +51 -42
  156. package/src/dnd/createDragState.ts +12 -14
  157. package/src/dnd/createDraggableCollectionState.d.ts +52 -41
  158. package/src/dnd/createDraggableCollectionState.ts +14 -21
  159. package/src/dnd/createDropState.d.ts +64 -45
  160. package/src/dnd/createDropState.ts +22 -32
  161. package/src/dnd/createDroppableCollectionState.d.ts +88 -59
  162. package/src/dnd/createDroppableCollectionState.ts +40 -43
  163. package/src/dnd/index.d.ts +55 -6
  164. package/src/dnd/index.ts +6 -18
  165. package/src/dnd/types.d.ts +170 -157
  166. package/src/dnd/types.ts +24 -22
  167. package/src/form/createFormValidationState.d.ts +47 -45
  168. package/src/form/createFormValidationState.ts +30 -63
  169. package/src/form/index.d.ts +16 -2
  170. package/src/form/index.ts +1 -1
  171. package/src/grid/createGridState.d.ts +7 -4
  172. package/src/grid/createGridState.ts +78 -51
  173. package/src/grid/index.d.ts +3 -3
  174. package/src/grid/index.ts +2 -8
  175. package/src/grid/types.d.ts +136 -129
  176. package/src/grid/types.ts +34 -18
  177. package/src/index.d.ts +311 -26
  178. package/src/index.ts +59 -89
  179. package/src/menu/index.ts +2 -4
  180. package/src/numberfield/createNumberFieldState.d.ts +56 -54
  181. package/src/numberfield/createNumberFieldState.ts +26 -31
  182. package/src/numberfield/index.d.ts +6 -2
  183. package/src/numberfield/index.ts +1 -1
  184. package/src/overlays/createOverlayTriggerState.d.ts +22 -20
  185. package/src/overlays/createOverlayTriggerState.ts +3 -4
  186. package/src/overlays/index.d.ts +6 -2
  187. package/src/overlays/index.ts +1 -1
  188. package/src/radio/createRadioGroupState.d.ts +54 -52
  189. package/src/radio/createRadioGroupState.ts +27 -29
  190. package/src/radio/index.d.ts +7 -2
  191. package/src/radio/index.ts +1 -1
  192. package/src/searchfield/createSearchFieldState.d.ts +16 -14
  193. package/src/searchfield/createSearchFieldState.ts +5 -11
  194. package/src/searchfield/index.d.ts +3 -3
  195. package/src/searchfield/index.ts +2 -5
  196. package/src/select/createSelectState.d.ts +63 -61
  197. package/src/select/createSelectState.ts +42 -29
  198. package/src/select/index.d.ts +2 -2
  199. package/src/select/index.ts +1 -5
  200. package/src/selection/Selection.ts +28 -0
  201. package/src/selection/SelectionManager.ts +526 -0
  202. package/src/selection/createMultipleSelectionState.ts +247 -0
  203. package/src/selection/index.ts +12 -7
  204. package/src/slider/createSliderState.d.ts +60 -60
  205. package/src/slider/createSliderState.ts +55 -33
  206. package/src/slider/index.d.ts +3 -3
  207. package/src/slider/index.ts +2 -6
  208. package/src/ssr/index.d.ts +1 -1
  209. package/src/ssr/index.ts +2 -2
  210. package/src/steplist/createStepListState.ts +191 -0
  211. package/src/steplist/index.ts +5 -0
  212. package/src/table/TableCollection.d.ts +42 -40
  213. package/src/table/TableCollection.ts +266 -99
  214. package/src/table/createTableColumnResizeState.ts +242 -0
  215. package/src/table/createTableState.d.ts +7 -4
  216. package/src/table/createTableState.ts +30 -7
  217. package/src/table/createTreeGridState.ts +146 -0
  218. package/src/table/index.d.ts +14 -4
  219. package/src/table/index.ts +13 -3
  220. package/src/table/types.d.ts +98 -92
  221. package/src/table/types.ts +83 -13
  222. package/src/tabs/createTabListState.d.ts +59 -57
  223. package/src/tabs/createTabListState.ts +34 -39
  224. package/src/tabs/index.d.ts +8 -2
  225. package/src/tabs/index.ts +1 -1
  226. package/src/textfield/createTextFieldState.d.ts +16 -14
  227. package/src/textfield/createTextFieldState.ts +7 -18
  228. package/src/textfield/index.d.ts +6 -2
  229. package/src/textfield/index.ts +1 -1
  230. package/src/toast/createToastState.d.ts +92 -86
  231. package/src/toast/createToastState.ts +90 -52
  232. package/src/toast/index.d.ts +12 -2
  233. package/src/toast/index.ts +2 -1
  234. package/src/toggle/createToggleGroupState.ts +11 -21
  235. package/src/toggle/createToggleState.d.ts +19 -19
  236. package/src/toggle/createToggleState.ts +2 -16
  237. package/src/toggle/index.d.ts +2 -2
  238. package/src/toggle/index.ts +2 -6
  239. package/src/tooltip/createTooltipTriggerState.d.ts +17 -17
  240. package/src/tooltip/createTooltipTriggerState.ts +12 -11
  241. package/src/tooltip/index.d.ts +7 -2
  242. package/src/tooltip/index.ts +1 -1
  243. package/src/tree/TreeCollection.d.ts +26 -23
  244. package/src/tree/TreeCollection.ts +29 -22
  245. package/src/tree/createTreeState.d.ts +7 -4
  246. package/src/tree/createTreeState.ts +70 -41
  247. package/src/tree/index.d.ts +10 -4
  248. package/src/tree/index.ts +3 -3
  249. package/src/tree/types.d.ts +131 -126
  250. package/src/tree/types.ts +30 -13
  251. package/src/utils/index.d.ts +2 -2
  252. package/src/utils/index.ts +1 -1
  253. package/src/utils/reactivity.d.ts +2 -2
  254. package/src/utils/reactivity.ts +3 -3
@@ -2,156 +2,161 @@
2
2
  * Tree collection types for Tree components.
3
3
  * Based on @react-stately/tree.
4
4
  */
5
- import type { Key, FocusStrategy } from '../collections/types';
6
- import type { GridNode, GridCollection } from '../grid/types';
5
+ import type { Key, FocusStrategy } from "../collections/types";
6
+ import type { GridNode, GridCollection } from "../grid/types";
7
7
  /**
8
8
  * Represents a node in a tree collection.
9
9
  * Extends GridNode with tree-specific properties.
10
10
  */
11
11
  export interface TreeNode<T = unknown> extends GridNode<T> {
12
- /** Whether this node has child nodes that can be expanded. */
13
- hasChildNodes: boolean;
14
- /** Child nodes of this tree item. */
15
- childNodes: TreeNode<T>[];
16
- /** The level of nesting (0 for root items). */
17
- level: number;
18
- /** The key of the parent node, if any. */
19
- parentKey?: Key | null;
20
- /** Whether this node is expandable. */
21
- isExpandable?: boolean;
22
- /** Whether this node is currently expanded (only meaningful if expandable). */
23
- isExpanded?: boolean;
12
+ /** Whether this node has child nodes that can be expanded. */
13
+ hasChildNodes: boolean;
14
+ /** Child nodes of this tree item. */
15
+ childNodes: TreeNode<T>[];
16
+ /** The level of nesting (0 for root items). */
17
+ level: number;
18
+ /** The key of the parent node, if any. */
19
+ parentKey?: Key | null;
20
+ /** Whether this node is expandable. */
21
+ isExpandable?: boolean;
22
+ /** Whether this node is currently expanded (only meaningful if expandable). */
23
+ isExpanded?: boolean;
24
24
  }
25
25
  /**
26
26
  * A collection of tree nodes with tree-specific navigation.
27
27
  * Only includes visible nodes (respects expanded state).
28
28
  */
29
- export interface TreeCollection<T = unknown> extends Omit<GridCollection<T>, 'rows' | 'columns' | 'headerRows' | 'columnCount' | 'getCell'> {
30
- /** All visible rows in the tree (respects expanded state). */
31
- readonly rows: TreeNode<T>[];
32
- /** Number of visible rows. */
33
- readonly rowCount: number;
34
- /** Get all keys in the collection (visible only). */
35
- getKeys(): Iterable<Key>;
36
- /** Get a node by its key (any node, visible or not). */
37
- getItem(key: Key): TreeNode<T> | null;
38
- /** Get a node by index (visible nodes only). */
39
- at(index: number): TreeNode<T> | null;
40
- /** Get the key before the given key (visible nodes only). */
41
- getKeyBefore(key: Key): Key | null;
42
- /** Get the key after the given key (visible nodes only). */
43
- getKeyAfter(key: Key): Key | null;
44
- /** Get the first key in the collection. */
45
- getFirstKey(): Key | null;
46
- /** Get the last key in the collection. */
47
- getLastKey(): Key | null;
48
- /** Get the children of a node. */
49
- getChildren(key: Key): Iterable<TreeNode<T>>;
50
- /** Get the text value for a key. */
51
- getTextValue(key: Key): string;
52
- /** Get the parent key for a node. */
53
- getParentKey(key: Key): Key | null;
54
- /** Iterator over visible nodes. */
55
- [Symbol.iterator](): Iterator<TreeNode<T>>;
29
+ export interface TreeCollection<T = unknown> extends Omit<
30
+ GridCollection<T>,
31
+ "rows" | "columns" | "headerRows" | "columnCount" | "getCell"
32
+ > {
33
+ /** All visible rows in the tree (respects expanded state). */
34
+ readonly rows: TreeNode<T>[];
35
+ /** Number of visible rows. */
36
+ readonly rowCount: number;
37
+ /** Get all keys in the collection (visible only). */
38
+ getKeys(): Iterable<Key>;
39
+ /** Get a node by its key (any node, visible or not). */
40
+ getItem(key: Key): TreeNode<T> | null;
41
+ /** Get a node by index (visible nodes only). */
42
+ at(index: number): TreeNode<T> | null;
43
+ /** Get the key before the given key (visible nodes only). */
44
+ getKeyBefore(key: Key): Key | null;
45
+ /** Get the key after the given key (visible nodes only). */
46
+ getKeyAfter(key: Key): Key | null;
47
+ /** Get the first key in the collection. */
48
+ getFirstKey(): Key | null;
49
+ /** Get the last key in the collection. */
50
+ getLastKey(): Key | null;
51
+ /** Get the children of a node. */
52
+ getChildren(key: Key): Iterable<TreeNode<T>>;
53
+ /** Get the text value for a key. */
54
+ getTextValue(key: Key): string;
55
+ /** Get the parent key for a node. */
56
+ getParentKey(key: Key): Key | null;
57
+ /** Iterator over visible nodes. */
58
+ [Symbol.iterator](): Iterator<TreeNode<T>>;
56
59
  }
57
60
  /**
58
61
  * State for a tree component.
59
62
  * Extends grid state with expansion management.
60
63
  */
61
64
  export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
62
- /** The tree collection (only visible nodes). */
63
- readonly collection: C;
64
- /** Keys of disabled items. */
65
- readonly disabledKeys: Set<Key>;
66
- /** Keys of expanded items. */
67
- readonly expandedKeys: Set<Key>;
68
- /** Whether keyboard navigation is disabled. */
69
- readonly isKeyboardNavigationDisabled: boolean;
70
- /** Currently focused key. */
71
- readonly focusedKey: Key | null;
72
- /** Focus strategy for child focus. */
73
- readonly childFocusStrategy: FocusStrategy | null;
74
- /** Whether the tree is focused. */
75
- readonly isFocused: boolean;
76
- /** The selection mode. */
77
- readonly selectionMode: 'none' | 'single' | 'multiple';
78
- /** The currently selected keys. */
79
- readonly selectedKeys: 'all' | Set<Key>;
80
- /** Check if a key is selected. */
81
- isSelected(key: Key): boolean;
82
- /** Check if a key is disabled. */
83
- isDisabled(key: Key): boolean;
84
- /** Check if a key is expanded. */
85
- isExpanded(key: Key): boolean;
86
- /** Set the focused key. */
87
- setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void;
88
- /** Set focused state. */
89
- setFocused(isFocused: boolean): void;
90
- /** Toggle selection for a key. */
91
- toggleSelection(key: Key): void;
92
- /** Replace selection with a key. */
93
- replaceSelection(key: Key): void;
94
- /** Extend selection to a key (shift-click). */
95
- extendSelection(toKey: Key): void;
96
- /** Select all visible items. */
97
- selectAll(): void;
98
- /** Clear selection. */
99
- clearSelection(): void;
100
- /** Toggle select all. */
101
- toggleSelectAll(): void;
102
- /** Toggle expansion for a key. */
103
- toggleKey(key: Key): void;
104
- /** Expand a key. */
105
- expandKey(key: Key): void;
106
- /** Collapse a key. */
107
- collapseKey(key: Key): void;
108
- /** Set the expanded keys. */
109
- setExpandedKeys(keys: Set<Key>): void;
110
- /** Set keyboard navigation disabled. */
111
- setKeyboardNavigationDisabled(isDisabled: boolean): void;
65
+ /** The tree collection (only visible nodes). */
66
+ readonly collection: C;
67
+ /** Keys of disabled items. */
68
+ readonly disabledKeys: Set<Key>;
69
+ /** Keys of expanded items. */
70
+ readonly expandedKeys: Set<Key>;
71
+ /** Whether keyboard navigation is disabled. */
72
+ readonly isKeyboardNavigationDisabled: boolean;
73
+ /** Currently focused key. */
74
+ readonly focusedKey: Key | null;
75
+ /** Focus strategy for child focus. */
76
+ readonly childFocusStrategy: FocusStrategy | null;
77
+ /** Whether the tree is focused. */
78
+ readonly isFocused: boolean;
79
+ /** The selection mode. */
80
+ readonly selectionMode: "none" | "single" | "multiple";
81
+ /** How selection behaves when pressing an item. */
82
+ readonly selectionBehavior: "toggle" | "replace";
83
+ /** The currently selected keys. */
84
+ readonly selectedKeys: "all" | Set<Key>;
85
+ /** Check if a key is selected. */
86
+ isSelected(key: Key): boolean;
87
+ /** Check if a key is disabled. */
88
+ isDisabled(key: Key): boolean;
89
+ /** Check if a key is expanded. */
90
+ isExpanded(key: Key): boolean;
91
+ /** Set the focused key. */
92
+ setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void;
93
+ /** Set focused state. */
94
+ setFocused(isFocused: boolean): void;
95
+ /** Toggle selection for a key. */
96
+ toggleSelection(key: Key): void;
97
+ /** Replace selection with a key. */
98
+ replaceSelection(key: Key): void;
99
+ /** Extend selection to a key (shift-click). */
100
+ extendSelection(toKey: Key): void;
101
+ /** Select all visible items. */
102
+ selectAll(): void;
103
+ /** Clear selection. */
104
+ clearSelection(): void;
105
+ /** Toggle select all. */
106
+ toggleSelectAll(): void;
107
+ /** Toggle expansion for a key. */
108
+ toggleKey(key: Key): void;
109
+ /** Expand a key. */
110
+ expandKey(key: Key): void;
111
+ /** Collapse a key. */
112
+ collapseKey(key: Key): void;
113
+ /** Set the expanded keys. */
114
+ setExpandedKeys(keys: Set<Key>): void;
115
+ /** Set keyboard navigation disabled. */
116
+ setKeyboardNavigationDisabled(isDisabled: boolean): void;
112
117
  }
113
118
  /**
114
119
  * Options for creating tree state.
115
120
  */
116
121
  export interface TreeStateOptions<T, C extends TreeCollection<T> = TreeCollection<T>> {
117
- /** The tree collection builder - receives expanded keys and returns collection. */
118
- collectionFactory: (expandedKeys: Set<Key>) => C;
119
- /** Keys of disabled items. */
120
- disabledKeys?: Iterable<Key>;
121
- /** Disabled behavior: 'selection' only or 'all' interactions. */
122
- disabledBehavior?: 'selection' | 'all';
123
- /** Selection mode. */
124
- selectionMode?: 'none' | 'single' | 'multiple';
125
- /** Selection behavior. */
126
- selectionBehavior?: 'toggle' | 'replace';
127
- /** Whether empty selection is disallowed. */
128
- disallowEmptySelection?: boolean;
129
- /** Currently selected keys (controlled). */
130
- selectedKeys?: 'all' | Iterable<Key>;
131
- /** Default selected keys (uncontrolled). */
132
- defaultSelectedKeys?: 'all' | Iterable<Key>;
133
- /** Handler for selection changes. */
134
- onSelectionChange?: (keys: 'all' | Set<Key>) => void;
135
- /** Currently expanded keys (controlled). */
136
- expandedKeys?: Iterable<Key>;
137
- /** Default expanded keys (uncontrolled). */
138
- defaultExpandedKeys?: Iterable<Key>;
139
- /** Handler for expansion changes. */
140
- onExpandedChange?: (keys: Set<Key>) => void;
122
+ /** The tree collection builder - receives expanded keys and returns collection. */
123
+ collectionFactory: (expandedKeys: Set<Key>) => C;
124
+ /** Keys of disabled items. */
125
+ disabledKeys?: Iterable<Key>;
126
+ /** Disabled behavior: 'selection' only or 'all' interactions. */
127
+ disabledBehavior?: "selection" | "all";
128
+ /** Selection mode. */
129
+ selectionMode?: "none" | "single" | "multiple";
130
+ /** Selection behavior. */
131
+ selectionBehavior?: "toggle" | "replace";
132
+ /** Whether empty selection is disallowed. */
133
+ disallowEmptySelection?: boolean;
134
+ /** Currently selected keys (controlled). */
135
+ selectedKeys?: "all" | Iterable<Key>;
136
+ /** Default selected keys (uncontrolled). */
137
+ defaultSelectedKeys?: "all" | Iterable<Key>;
138
+ /** Handler for selection changes. */
139
+ onSelectionChange?: (keys: "all" | Set<Key>) => void;
140
+ /** Currently expanded keys (controlled). */
141
+ expandedKeys?: Iterable<Key>;
142
+ /** Default expanded keys (uncontrolled). */
143
+ defaultExpandedKeys?: Iterable<Key>;
144
+ /** Handler for expansion changes. */
145
+ onExpandedChange?: (keys: Set<Key>) => void;
141
146
  }
142
147
  /**
143
148
  * Item representation for building tree collections.
144
149
  */
145
150
  export interface TreeItemData<T = unknown> {
146
- /** Unique key for this item. */
147
- key: Key;
148
- /** The data value for this item. */
149
- value: T;
150
- /** Text content for accessibility and search. */
151
- textValue?: string;
152
- /** Child items (makes this item expandable). */
153
- children?: TreeItemData<T>[];
154
- /** Whether this item is disabled. */
155
- isDisabled?: boolean;
151
+ /** Unique key for this item. */
152
+ key: Key;
153
+ /** The data value for this item. */
154
+ value: T;
155
+ /** Text content for accessibility and search. */
156
+ textValue?: string;
157
+ /** Child items (makes this item expandable). */
158
+ children?: TreeItemData<T>[];
159
+ /** Whether this item is disabled. */
160
+ isDisabled?: boolean;
156
161
  }
157
- //# sourceMappingURL=types.d.ts.map
162
+ //# sourceMappingURL=types.d.ts.map
package/src/tree/types.ts CHANGED
@@ -3,8 +3,8 @@
3
3
  * Based on @react-stately/tree.
4
4
  */
5
5
 
6
- import type { Key, FocusStrategy } from '../collections/types';
7
- import type { GridNode, GridCollection } from '../grid/types';
6
+ import type { Key, FocusStrategy, Selection, SelectionBehavior } from "../collections/types";
7
+ import type { GridNode, GridCollection } from "../grid/types";
8
8
 
9
9
  /**
10
10
  * Represents a node in a tree collection.
@@ -29,7 +29,10 @@ export interface TreeNode<T = unknown> extends GridNode<T> {
29
29
  * A collection of tree nodes with tree-specific navigation.
30
30
  * Only includes visible nodes (respects expanded state).
31
31
  */
32
- export interface TreeCollection<T = unknown> extends Omit<GridCollection<T>, 'rows' | 'columns' | 'headerRows' | 'columnCount' | 'getCell'> {
32
+ export interface TreeCollection<T = unknown> extends Omit<
33
+ GridCollection<T>,
34
+ "rows" | "columns" | "headerRows" | "columnCount" | "getCell"
35
+ > {
33
36
  /** All visible rows in the tree (respects expanded state). */
34
37
  readonly rows: TreeNode<T>[];
35
38
  /** Number of visible rows. */
@@ -78,6 +81,8 @@ export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
78
81
  readonly collection: C;
79
82
  /** Keys of disabled items. */
80
83
  readonly disabledKeys: Set<Key>;
84
+ /** Whether `disabledKeys` applies to all interactions, or only selection. */
85
+ readonly disabledBehavior: "selection" | "all";
81
86
  /** Keys of expanded items. */
82
87
  readonly expandedKeys: Set<Key>;
83
88
  /** Whether keyboard navigation is disabled. */
@@ -89,9 +94,13 @@ export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
89
94
  /** Whether the tree is focused. */
90
95
  readonly isFocused: boolean;
91
96
  /** The selection mode. */
92
- readonly selectionMode: 'none' | 'single' | 'multiple';
97
+ readonly selectionMode: "none" | "single" | "multiple";
98
+ /** How selection behaves when pressing an item. */
99
+ readonly selectionBehavior: SelectionBehavior;
100
+ /** Whether empty selection is disallowed. */
101
+ readonly disallowEmptySelection: boolean;
93
102
  /** The currently selected keys. */
94
- readonly selectedKeys: 'all' | Set<Key>;
103
+ readonly selectedKeys: Selection;
95
104
 
96
105
  /** Check if a key is selected. */
97
106
  isSelected(key: Key): boolean;
@@ -107,6 +116,10 @@ export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
107
116
  toggleSelection(key: Key): void;
108
117
  /** Replace selection with a key. */
109
118
  replaceSelection(key: Key): void;
119
+ /** Set the selected keys directly. */
120
+ setSelectedKeys(keys: Selection | Iterable<Key>): void;
121
+ /** Set how selection behaves when pressing an item. */
122
+ setSelectionBehavior(behavior: SelectionBehavior): void;
110
123
  /** Extend selection to a key (shift-click). */
111
124
  extendSelection(toKey: Key): void;
112
125
  /** Select all visible items. */
@@ -136,19 +149,19 @@ export interface TreeStateOptions<T, C extends TreeCollection<T> = TreeCollectio
136
149
  /** Keys of disabled items. */
137
150
  disabledKeys?: Iterable<Key>;
138
151
  /** Disabled behavior: 'selection' only or 'all' interactions. */
139
- disabledBehavior?: 'selection' | 'all';
152
+ disabledBehavior?: "selection" | "all";
140
153
  /** Selection mode. */
141
- selectionMode?: 'none' | 'single' | 'multiple';
154
+ selectionMode?: "none" | "single" | "multiple";
142
155
  /** Selection behavior. */
143
- selectionBehavior?: 'toggle' | 'replace';
156
+ selectionBehavior?: SelectionBehavior;
144
157
  /** Whether empty selection is disallowed. */
145
158
  disallowEmptySelection?: boolean;
146
159
  /** Currently selected keys (controlled). */
147
- selectedKeys?: 'all' | Iterable<Key>;
160
+ selectedKeys?: Selection | Iterable<Key>;
148
161
  /** Default selected keys (uncontrolled). */
149
- defaultSelectedKeys?: 'all' | Iterable<Key>;
162
+ defaultSelectedKeys?: Selection | Iterable<Key>;
150
163
  /** Handler for selection changes. */
151
- onSelectionChange?: (keys: 'all' | Set<Key>) => void;
164
+ onSelectionChange?: (keys: "all" | Set<Key>) => void;
152
165
  /** Currently expanded keys (controlled). */
153
166
  expandedKeys?: Iterable<Key>;
154
167
  /** Default expanded keys (uncontrolled). */
@@ -162,13 +175,17 @@ export interface TreeStateOptions<T, C extends TreeCollection<T> = TreeCollectio
162
175
  */
163
176
  export interface TreeItemData<T = unknown> {
164
177
  /** Unique key for this item. */
165
- key: Key;
178
+ key?: Key;
179
+ /** S2/React Aria-compatible unique id alias. */
180
+ id?: Key;
166
181
  /** The data value for this item. */
167
- value: T;
182
+ value?: T;
168
183
  /** Text content for accessibility and search. */
169
184
  textValue?: string;
170
185
  /** Child items (makes this item expandable). */
171
186
  children?: TreeItemData<T>[];
187
+ /** Whether this item has children that may not be loaded yet. */
188
+ hasChildItems?: boolean;
172
189
  /** Whether this item is disabled. */
173
190
  isDisabled?: boolean;
174
191
  }
@@ -1,2 +1,2 @@
1
- export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from './reactivity';
2
- //# sourceMappingURL=index.d.ts.map
1
+ export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from "./reactivity";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from './reactivity';
1
+ export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from "./reactivity";
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Provides type-safe utilities for working with SolidJS reactivity patterns.
5
5
  */
6
- import { Accessor } from 'solid-js';
6
+ import { Accessor } from "solid-js";
7
7
  /**
8
8
  * A value that may be either a raw value or an accessor function.
9
9
  * This is a common pattern in SolidJS for props that may be reactive.
@@ -25,4 +25,4 @@ export type MaybeAccessorValue<T> = T | undefined | Accessor<T | undefined>;
25
25
  * Checks if a value is an accessor function.
26
26
  */
27
27
  export declare function isAccessor<T>(value: MaybeAccessor<T>): value is Accessor<T>;
28
- //# sourceMappingURL=reactivity.d.ts.map
28
+ //# sourceMappingURL=reactivity.d.ts.map
@@ -4,7 +4,7 @@
4
4
  * Provides type-safe utilities for working with SolidJS reactivity patterns.
5
5
  */
6
6
 
7
- import { Accessor } from 'solid-js';
7
+ import { Accessor } from "solid-js";
8
8
 
9
9
  /**
10
10
  * A value that may be either a raw value or an accessor function.
@@ -20,7 +20,7 @@ export type MaybeAccessor<T> = T | Accessor<T>;
20
20
  * @param value - The value or accessor to unwrap.
21
21
  */
22
22
  export function access<T>(value: MaybeAccessor<T>): T {
23
- return typeof value === 'function' ? (value as Accessor<T>)() : value;
23
+ return typeof value === "function" ? (value as Accessor<T>)() : value;
24
24
  }
25
25
 
26
26
  /**
@@ -32,5 +32,5 @@ export type MaybeAccessorValue<T> = T | undefined | Accessor<T | undefined>;
32
32
  * Checks if a value is an accessor function.
33
33
  */
34
34
  export function isAccessor<T>(value: MaybeAccessor<T>): value is Accessor<T> {
35
- return typeof value === 'function';
35
+ return typeof value === "function";
36
36
  }