@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
@@ -4,5 +4,5 @@
4
4
  * Exposes React Stately-like menu hook names while using existing
5
5
  * Solid menu state primitives.
6
6
  */
7
- export { createMenuState, createMenuTriggerState, type MenuStateProps, type MenuState, type MenuTriggerStateProps, type MenuTriggerState, } from '../collections/createMenuState';
8
- export { createMenuTriggerState as useMenuTriggerState, } from '../collections/createMenuState';
7
+ export { createMenuState, createMenuTriggerState, type MenuStateProps, type MenuState, type MenuTriggerStateProps, type MenuTriggerState, } from "../collections/createMenuState";
8
+ export { createMenuTriggerState as useMenuTriggerState } from "../collections/createMenuState";
@@ -2,8 +2,8 @@
2
2
  * State management for NumberField.
3
3
  * Based on @react-stately/numberfield useNumberFieldState.
4
4
  */
5
- import { type Accessor } from 'solid-js';
6
- import { type MaybeAccessor } from '../utils';
5
+ import { type Accessor } from "solid-js";
6
+ import { type MaybeAccessor } from "../utils";
7
7
  export interface NumberFieldStateProps {
8
8
  /** The current value (controlled). */
9
9
  value?: number;
@@ -1 +1 @@
1
- export { createNumberFieldState, type NumberFieldStateProps, type NumberFieldState, } from './createNumberFieldState';
1
+ export { createNumberFieldState, type NumberFieldStateProps, type NumberFieldState, } from "./createNumberFieldState";
@@ -2,8 +2,8 @@
2
2
  * Manages state for an overlay trigger.
3
3
  * Based on @react-stately/overlays useOverlayTriggerState.
4
4
  */
5
- import { type Accessor } from 'solid-js';
6
- import { type MaybeAccessor } from '../utils';
5
+ import { type Accessor } from "solid-js";
6
+ import { type MaybeAccessor } from "../utils";
7
7
  export interface OverlayTriggerProps {
8
8
  /** Whether the overlay is open by default (uncontrolled). */
9
9
  defaultOpen?: boolean;
@@ -1 +1 @@
1
- export { createOverlayTriggerState, type OverlayTriggerProps, type OverlayTriggerState, } from './createOverlayTriggerState';
1
+ export { createOverlayTriggerState, type OverlayTriggerProps, type OverlayTriggerState, } from "./createOverlayTriggerState";
@@ -6,9 +6,9 @@
6
6
  *
7
7
  * This is a 1:1 port of @react-stately/radio's useRadioGroupState.
8
8
  */
9
- import { Accessor } from 'solid-js';
10
- import { type MaybeAccessor } from '../utils';
11
- import { type FormValidationState, type ValidationFunction, type ValidationResult } from '../form';
9
+ import { Accessor } from "solid-js";
10
+ import { type MaybeAccessor } from "../utils";
11
+ import { type FormValidationState, type ValidationFunction, type ValidationResult } from "../form";
12
12
  export interface RadioGroupProps {
13
13
  /** The current selected value (controlled). */
14
14
  value?: string | null;
@@ -31,7 +31,7 @@ export interface RadioGroupProps {
31
31
  /** The label for the radio group. */
32
32
  label?: string;
33
33
  /** Orientation of the radio group. */
34
- orientation?: 'horizontal' | 'vertical';
34
+ orientation?: "horizontal" | "vertical";
35
35
  /** Handler that is called when the radio group receives focus. */
36
36
  onFocus?: (e: FocusEvent) => void;
37
37
  /** Handler that is called when the radio group loses focus. */
@@ -39,13 +39,13 @@ export interface RadioGroupProps {
39
39
  /** Handler that is called when the radio group's focus status changes. */
40
40
  onFocusChange?: (isFocused: boolean) => void;
41
41
  /** Backward-compatible controlled validation state. */
42
- validationState?: 'valid' | 'invalid';
42
+ validationState?: "valid" | "invalid";
43
43
  /** Custom validation function. */
44
44
  validate?: ValidationFunction<string | null>;
45
45
  /** Validation behavior for the radio group. */
46
- validationBehavior?: 'aria' | 'native';
46
+ validationBehavior?: "aria" | "native";
47
47
  }
48
- export interface RadioGroupState extends Pick<FormValidationState, 'realtimeValidation' | 'displayValidation' | 'updateValidation' | 'resetValidation' | 'commitValidation'> {
48
+ export interface RadioGroupState extends Pick<FormValidationState, "realtimeValidation" | "displayValidation" | "updateValidation" | "resetValidation" | "commitValidation"> {
49
49
  /** The name for the group, used for native form submission. */
50
50
  readonly name: string;
51
51
  /** Whether the radio group is disabled. */
@@ -1 +1 @@
1
- export { createRadioGroupState, radioGroupSyncVersion, type RadioGroupProps, type RadioGroupState, } from './createRadioGroupState';
1
+ export { createRadioGroupState, radioGroupSyncVersion, type RadioGroupProps, type RadioGroupState, } from "./createRadioGroupState";
@@ -2,8 +2,8 @@
2
2
  * Creates state for a search field component.
3
3
  * Based on @react-stately/searchfield useSearchFieldState.
4
4
  */
5
- import { type Accessor } from 'solid-js';
6
- import { type MaybeAccessor } from '../utils';
5
+ import { type Accessor } from "solid-js";
6
+ import { type MaybeAccessor } from "../utils";
7
7
  export interface SearchFieldStateProps {
8
8
  /** The current value (controlled). */
9
9
  value?: string;
@@ -1,2 +1,2 @@
1
- export { createSearchFieldState } from './createSearchFieldState';
2
- export type { SearchFieldState, SearchFieldStateProps, } from './createSearchFieldState';
1
+ export { createSearchFieldState } from "./createSearchFieldState";
2
+ export type { SearchFieldState, SearchFieldStateProps } from "./createSearchFieldState";
@@ -2,10 +2,11 @@
2
2
  * State management for select components.
3
3
  * Based on @react-stately/select useSelectState.
4
4
  */
5
- import { type Accessor } from 'solid-js';
6
- import { type MaybeAccessor } from '../utils';
7
- import type { Key, CollectionNode, Collection } from '../collections/types';
8
- import type { SelectionMode, Selection } from '../collections/types';
5
+ import { type Accessor } from "solid-js";
6
+ import { type MaybeAccessor } from "../utils";
7
+ import type { Key, CollectionNode, Collection } from "../collections/types";
8
+ import type { SelectionMode, Selection } from "../collections/types";
9
+ import type { SelectionManager } from "../selection/SelectionManager";
9
10
  export interface SelectStateProps<T = unknown> {
10
11
  /** The items to display in the select. */
11
12
  items: T[];
@@ -22,15 +23,15 @@ export interface SelectStateProps<T = unknown> {
22
23
  /** The default selected key (uncontrolled). */
23
24
  defaultSelectedKey?: Key | null;
24
25
  /** The selected keys (controlled, for multiple selection mode). */
25
- selectedKeys?: 'all' | Iterable<Key>;
26
+ selectedKeys?: "all" | Iterable<Key>;
26
27
  /** Default selected keys (uncontrolled, for multiple selection mode). */
27
- defaultSelectedKeys?: 'all' | Iterable<Key>;
28
+ defaultSelectedKeys?: "all" | Iterable<Key>;
28
29
  /** Handler called when the selection changes. */
29
30
  onSelectionChange?: (key: Key | null) => void;
30
31
  /** Handler called when selected keys change. */
31
32
  onSelectionChangeKeys?: (keys: Selection) => void;
32
33
  /** Selection mode for the select. */
33
- selectionMode?: Extract<SelectionMode, 'single' | 'multiple'>;
34
+ selectionMode?: Extract<SelectionMode, "single" | "multiple">;
34
35
  /** Whether the select is open (controlled). */
35
36
  isOpen?: boolean;
36
37
  /** Whether the select is open by default (uncontrolled). */
@@ -45,6 +46,11 @@ export interface SelectStateProps<T = unknown> {
45
46
  export interface SelectState<T = unknown> {
46
47
  /** The collection of items. */
47
48
  readonly collection: Accessor<Collection<T>>;
49
+ /**
50
+ * The collection-aware selection manager. Mirrors upstream `useSelectState`,
51
+ * which spreads the underlying `useListState` (including its selection manager).
52
+ */
53
+ readonly selectionManager: SelectionManager<T>;
48
54
  /** Whether the select dropdown is open. */
49
55
  readonly isOpen: Accessor<boolean>;
50
56
  /** Open the select dropdown. */
@@ -80,7 +86,7 @@ export interface SelectState<T = unknown> {
80
86
  /** Whether the select is required. */
81
87
  readonly isRequired: boolean;
82
88
  /** The selection mode. */
83
- readonly selectionMode: Accessor<'single' | 'multiple'>;
89
+ readonly selectionMode: Accessor<"single" | "multiple">;
84
90
  }
85
91
  /**
86
92
  * Creates state for a select component.
@@ -1 +1 @@
1
- export { createSelectState, type SelectStateProps, type SelectState, } from './createSelectState';
1
+ export { createSelectState, type SelectStateProps, type SelectState } from "./createSelectState";
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A Selection is a special Set containing Keys, which also has an anchor
3
+ * and current selected key for use when range selecting.
4
+ *
5
+ * Based on @react-stately/selection.
6
+ */
7
+ import type { Key } from "../collections/types";
8
+ /**
9
+ * A Selection is a special Set containing Keys, which also has an anchor
10
+ * and current selected key for use when range selecting.
11
+ */
12
+ export declare class Selection extends Set<Key> {
13
+ anchorKey: Key | null;
14
+ currentKey: Key | null;
15
+ constructor(keys?: Iterable<Key> | Selection, anchorKey?: Key | null, currentKey?: Key | null);
16
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * An interface for reading and updating multiple selection state.
3
+ *
4
+ * The upper of the two selection layers ported from upstream
5
+ * (`@react-stately/selection`'s `SelectionManager`): the collection-aware
6
+ * operations built on top of the raw {@link MultipleSelectionState}.
7
+ *
8
+ * React → Solid adaptations, all faithful to upstream's observable contract:
9
+ * - Upstream re-instantiates `SelectionManager` every render to capture a
10
+ * fresh `collection`. Here the manager is long-lived, so it captures a
11
+ * reactive `collection` accessor and reads it live via `get collection()`.
12
+ * - Upstream caches `_isSelectAll` for the lifetime of one render. A
13
+ * long-lived manager would let that cache go stale, so it is dropped and
14
+ * `isSelectAll` recomputes (it is consulted rarely — only by select-all UI).
15
+ * - Our `CollectionNode` has no `'cell'` type (grids/trees use a separate
16
+ * state engine), so the cell-selection branches are omitted.
17
+ *
18
+ * Based on @react-stately/selection.
19
+ */
20
+ import type { SelectionPressEvent } from "../collections/createSelectionState";
21
+ import type { Collection, DisabledBehavior, FocusStrategy, Key, Selection as SelectionValue, SelectionBehavior, SelectionMode } from "../collections/types";
22
+ import type { MultipleSelectionState } from "./createMultipleSelectionState";
23
+ /** A delegate that can resolve a key range without walking the collection (e.g. a virtualized layout). */
24
+ export interface LayoutDelegate {
25
+ getKeyRange?(from: Key, to: Key): Key[];
26
+ }
27
+ export interface SelectionManagerOptions<T = unknown> {
28
+ layoutDelegate?: LayoutDelegate;
29
+ /**
30
+ * The full (unfiltered) collection, used when materializing the 'all'
31
+ * selection so that filtered-out items (e.g. by Autocomplete) are still
32
+ * included.
33
+ */
34
+ fullCollection?: Collection<T>;
35
+ }
36
+ /**
37
+ * An interface for reading and updating multiple selection state.
38
+ */
39
+ export declare class SelectionManager<T = unknown> {
40
+ private collectionAccessor;
41
+ private state;
42
+ private layoutDelegate;
43
+ private fullCollection;
44
+ constructor(collection: () => Collection<T>, state: MultipleSelectionState, options?: SelectionManagerOptions<T>);
45
+ /** The collection the manager operates over (read live so it stays reactive). */
46
+ get collection(): Collection<T>;
47
+ /** The type of selection that is allowed in the collection. */
48
+ get selectionMode(): SelectionMode;
49
+ /** Whether the collection allows empty selection. */
50
+ get disallowEmptySelection(): boolean;
51
+ /** The selection behavior for the collection. */
52
+ get selectionBehavior(): SelectionBehavior;
53
+ /** Sets the selection behavior for the collection. */
54
+ setSelectionBehavior(selectionBehavior: SelectionBehavior): void;
55
+ /** Whether the collection is currently focused. */
56
+ get isFocused(): boolean;
57
+ /** Sets whether the collection is focused. */
58
+ setFocused(isFocused: boolean): void;
59
+ /** The current focused key in the collection. */
60
+ get focusedKey(): Key | null;
61
+ /** Whether the first or last child of the focused key should receive focus. */
62
+ get childFocusStrategy(): FocusStrategy | null;
63
+ /** Sets the focused key. */
64
+ setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void;
65
+ /** The currently selected keys in the collection (materialized — 'all' is expanded). */
66
+ get selectedKeys(): Set<Key>;
67
+ /** The raw selection value for the collection. Either 'all' for select all, or a set of keys. */
68
+ get rawSelection(): SelectionValue;
69
+ /** Last selection payload emitted through onSelectionChange. @internal */
70
+ get lastSelectionEvent(): SelectionValue | null;
71
+ /** Re-emits a selection payload without recomputing selection. @internal */
72
+ emitDuplicateSelectionEvent(keys?: SelectionValue | null): void;
73
+ /** Returns whether a key is selected. */
74
+ isSelected(key: Key): boolean;
75
+ /** Whether the selection is empty. */
76
+ get isEmpty(): boolean;
77
+ /** Whether all items in the collection are selected. */
78
+ get isSelectAll(): boolean;
79
+ get firstSelectedKey(): Key | null;
80
+ get lastSelectedKey(): Key | null;
81
+ get disabledKeys(): Set<Key>;
82
+ get disabledBehavior(): DisabledBehavior;
83
+ /** Extends the selection to the given key. */
84
+ extendSelection(toKey: Key): void;
85
+ private getKeyRange;
86
+ private getKeyRangeInternal;
87
+ private getKey;
88
+ /** Toggles whether the given key is selected. */
89
+ toggleSelection(key: Key): void;
90
+ /** Replaces the selection with only the given key. */
91
+ replaceSelection(key: Key): void;
92
+ /** Replaces the selection with the given keys. */
93
+ setSelectedKeys(keys: Iterable<Key>): void;
94
+ private getSelectAllKeys;
95
+ /** Selects all items in the collection. */
96
+ selectAll(): void;
97
+ /** Removes all keys from the selection. */
98
+ clearSelection(): void;
99
+ /** Toggles between select all and an empty selection. */
100
+ toggleSelectAll(): void;
101
+ select(key: Key, e?: SelectionPressEvent): void;
102
+ /** Returns whether the current selection is equal to the given selection. */
103
+ isSelectionEqual(selection: Set<Key>): boolean;
104
+ canSelectItem(key: Key): boolean;
105
+ private canSelectItemIn;
106
+ isDisabled(key: Key): boolean;
107
+ isLink(key: Key): boolean;
108
+ getItemProps(key: Key): Record<string, unknown> | undefined;
109
+ withCollection(collection: Collection<T>): SelectionManager<T>;
110
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Raw multiple-selection + focus state for a collection.
3
+ *
4
+ * The lower of the two selection layers ported from upstream
5
+ * (`@react-stately/selection`'s `useMultipleSelectionState`): it owns the
6
+ * selected keys, focus, selection behavior, and disabled keys, but is NOT
7
+ * collection-aware. The collection-aware operations (toggle, extend, select
8
+ * all, range, etc.) live in {@link SelectionManager}, which is built on top of
9
+ * this state.
10
+ *
11
+ * Based on @react-stately/selection.
12
+ */
13
+ import { type Accessor } from "solid-js";
14
+ import { type MaybeAccessor } from "../utils";
15
+ import type { SelectionStateProps } from "../collections/createSelectionState";
16
+ import type { DisabledBehavior, FocusStrategy, Key, Selection, SelectionBehavior, SelectionMode } from "../collections/types";
17
+ /**
18
+ * The raw state consumed by {@link SelectionManager}. Mirrors upstream's
19
+ * `MultipleSelectionState`: property reads (not Solid accessors) so the manager
20
+ * can read `state.selectionMode` etc. exactly as upstream does — the getters
21
+ * read the underlying signals, so reads inside reactive scopes still track.
22
+ */
23
+ export interface MultipleSelectionState {
24
+ /** The type of selection that is allowed in the collection. */
25
+ readonly selectionMode: SelectionMode;
26
+ /** The selection behavior for the collection. */
27
+ readonly selectionBehavior: SelectionBehavior;
28
+ /** Sets the selection behavior for the collection. */
29
+ setSelectionBehavior(selectionBehavior: SelectionBehavior): void;
30
+ /** Whether the collection allows empty selection. */
31
+ readonly disallowEmptySelection: boolean;
32
+ /** Whether the collection is currently focused. */
33
+ readonly isFocused: boolean;
34
+ /** Sets whether the collection is focused. */
35
+ setFocused(isFocused: boolean): void;
36
+ /** The current focused key in the collection. */
37
+ readonly focusedKey: Key | null;
38
+ /** Whether the first or last child of the focused key should receive focus. */
39
+ readonly childFocusStrategy: FocusStrategy | null;
40
+ /** Sets the focused key, and optionally, whether the first or last child of that key should receive focus. */
41
+ setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void;
42
+ /** The currently selected keys in the collection. */
43
+ readonly selectedKeys: Selection;
44
+ /** The last selection payload emitted through onSelectionChange. @internal */
45
+ readonly lastSelectionEvent: Selection | null;
46
+ /** Sets the selected keys in the collection. */
47
+ setSelectedKeys(keys: Selection): void;
48
+ /** Re-emits a selection payload without recomputing or mutating selection. @internal */
49
+ emitDuplicateSelectionEvent(keys?: Selection): void;
50
+ /** The currently disabled keys in the collection. */
51
+ readonly disabledKeys: Set<Key>;
52
+ /** Whether `disabledKeys` applies to all interactions, or only selection. */
53
+ readonly disabledBehavior: DisabledBehavior;
54
+ }
55
+ /**
56
+ * Manages raw state for multiple selection and focus in a collection.
57
+ */
58
+ export declare function createMultipleSelectionState(props?: MaybeAccessor<SelectionStateProps>): MultipleSelectionState;
59
+ export type { Accessor };
@@ -4,8 +4,9 @@
4
4
  * Provides a React Stately-like module entrypoint for selection state while
5
5
  * delegating to the existing Solid collection selection primitives.
6
6
  */
7
- export { createSelectionState, type SelectionStateProps, type SelectionState, } from '../collections/createSelectionState';
8
- export type { Key, Selection, SelectionMode, SelectionBehavior, DisabledBehavior, FocusStrategy, } from '../collections/types';
9
- export type MultipleSelectionStateProps = import('../collections/createSelectionState').SelectionStateProps;
10
- export type MultipleSelectionState = import('../collections/createSelectionState').SelectionState;
11
- export { createSelectionState as useMultipleSelectionState, } from '../collections/createSelectionState';
7
+ export { createSelectionState, type SelectionStateProps, type SelectionState, } from "../collections/createSelectionState";
8
+ export { SelectionManager, type SelectionManagerOptions, type LayoutDelegate, } from "./SelectionManager";
9
+ export type { Key, Selection, SelectionMode, SelectionBehavior, DisabledBehavior, FocusStrategy, } from "../collections/types";
10
+ export type MultipleSelectionStateProps = import("../collections/createSelectionState").SelectionStateProps;
11
+ export type MultipleSelectionState = import("../collections/createSelectionState").SelectionState;
12
+ export { createSelectionState as useMultipleSelectionState } from "../collections/createSelectionState";
@@ -2,9 +2,9 @@
2
2
  * Creates state for a slider component.
3
3
  * Based on @react-stately/slider useSliderState.
4
4
  */
5
- import { type Accessor } from 'solid-js';
6
- import { type MaybeAccessor } from '../utils';
7
- export type SliderOrientation = 'horizontal' | 'vertical';
5
+ import { type Accessor } from "solid-js";
6
+ import { type MaybeAccessor } from "../utils";
7
+ export type SliderOrientation = "horizontal" | "vertical";
8
8
  export interface SliderStateProps {
9
9
  /** The current value (controlled). */
10
10
  value?: number;
@@ -1,2 +1,2 @@
1
- export { createSliderState } from './createSliderState';
2
- export type { SliderState, SliderStateProps, SliderOrientation, } from './createSliderState';
1
+ export { createSliderState } from "./createSliderState";
2
+ export type { SliderState, SliderStateProps, SliderOrientation } from "./createSliderState";
@@ -0,0 +1,48 @@
1
+ /**
2
+ * State management for step list components.
3
+ * Tracks selected step, completion status, and selectability.
4
+ */
5
+ import { type Accessor } from "solid-js";
6
+ import type { Key } from "../collections/types";
7
+ export interface StepListStateProps {
8
+ /** The currently selected step key (controlled). */
9
+ selectedKey?: Key;
10
+ /** The default selected step key (uncontrolled). */
11
+ defaultSelectedKey?: Key;
12
+ /** Called when the selected step changes. */
13
+ onSelectionChange?: (key: Key) => void;
14
+ /** The last completed step key (controlled). */
15
+ lastCompletedStep?: Key;
16
+ /** The default last completed step key (uncontrolled). */
17
+ defaultLastCompletedStep?: Key;
18
+ /** Called when last completed step changes. */
19
+ onLastCompletedStepChange?: (key: Key | null) => void;
20
+ /** Whether all steps are disabled. */
21
+ isDisabled?: boolean;
22
+ /** Whether all steps are read-only. */
23
+ isReadOnly?: boolean;
24
+ /** Keys of individually disabled steps. */
25
+ disabledKeys?: Iterable<Key>;
26
+ /** The step items. */
27
+ items: Array<{
28
+ key: Key;
29
+ [key: string]: any;
30
+ }>;
31
+ }
32
+ export interface StepListState {
33
+ readonly selectedKey: Accessor<Key | null>;
34
+ readonly lastCompletedStep: Accessor<Key | null>;
35
+ readonly items: Accessor<Array<{
36
+ key: Key;
37
+ }>>;
38
+ setSelectedKey(key: Key): void;
39
+ setLastCompletedStep(key: Key): void;
40
+ isCompleted(key: Key): boolean;
41
+ isSelectable(key: Key): boolean;
42
+ isDisabled: Accessor<boolean>;
43
+ isReadOnly: Accessor<boolean>;
44
+ }
45
+ /**
46
+ * Creates state for a step list component.
47
+ */
48
+ export declare function createStepListState(props: StepListStateProps): StepListState;
@@ -0,0 +1 @@
1
+ export { createStepListState, type StepListStateProps, type StepListState, } from "./createStepListState";
@@ -1,10 +1,16 @@
1
1
  /**
2
2
  * TableCollection - A collection class for table data.
3
3
  * Based on @react-stately/table/TableCollection.
4
+ *
5
+ * Supports a plain (flat) table and, when an `expandedKeys` option is supplied, a
6
+ * tree grid: `childRows` are walked recursively, each parent row keeps its full
7
+ * structure (cells followed by every child row), and only rows whose ancestors are
8
+ * all expanded are flattened into the navigable body. Mirrors the structure produced
9
+ * by `@react-stately/table`'s `generateTreeGridCollection`.
4
10
  */
5
- import type { Key } from '../collections/types';
6
- import type { GridNode } from '../grid/types';
7
- import type { TableCollection as ITableCollection, TableCollectionOptions } from './types';
11
+ import type { Key } from "../collections/types";
12
+ import type { GridNode } from "../grid/types";
13
+ import type { TableCollection as ITableCollection, TableCollectionOptions } from "./types";
8
14
  /**
9
15
  * Creates a table collection from column and row definitions.
10
16
  */
@@ -17,12 +23,30 @@ export declare class TableCollection<T = unknown> implements ITableCollection<T>
17
23
  private _keyMap;
18
24
  private _rowHeaderColumnKeys;
19
25
  private _size;
26
+ /** Visible rows in DFS order. Drives size, navigation, iteration and the `rows` list. */
27
+ private _flattenedRows;
28
+ private _treeColumn;
29
+ private _userColumnCount;
20
30
  constructor(options: TableCollectionOptions<T>);
21
31
  private buildColumns;
22
32
  private buildColumnNode;
23
33
  private getDefaultRowHeaderColumnKeys;
34
+ /** Counts the leaf columns supplied by the user (excludes the selection column). */
35
+ private countLeafColumns;
24
36
  private buildHeaderRows;
37
+ /**
38
+ * Builds the cell nodes for one row. Does not register the cells in the key map;
39
+ * the caller registers cells once the owning row is known to be present.
40
+ */
41
+ private buildCells;
25
42
  private buildRows;
43
+ /**
44
+ * Builds the tree-grid rows: every row keeps its full structure (cells then all child
45
+ * rows, expanded or not) while only the rows whose ancestors are all expanded are
46
+ * registered in the key map and pushed into the flattened body. Mirrors
47
+ * `generateTreeGridCollection` upstream.
48
+ */
49
+ private buildTreeRows;
26
50
  private isRowDefinition;
27
51
  get size(): number;
28
52
  get rows(): GridNode<T>[];
@@ -33,6 +57,12 @@ export declare class TableCollection<T = unknown> implements ITableCollection<T>
33
57
  get rowCount(): number;
34
58
  get columnCount(): number;
35
59
  get rowHeaderColumnKeys(): Set<Key>;
60
+ /** The key of the column that renders the tree-grid affordance, or `null` for a flat table. */
61
+ get treeColumn(): Key | null;
62
+ /** The number of leaf columns provided by the user (excludes the selection column). */
63
+ get userColumnCount(): number;
64
+ /** The key map of all present nodes (visible rows, their cells, columns and the body). */
65
+ get keyMap(): Map<Key, GridNode<T>>;
36
66
  getKeys(): Iterable<Key>;
37
67
  getItem(key: Key): GridNode<T> | null;
38
68
  at(index: number): GridNode<T> | null;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Table column resize state management.
3
+ * Based on @react-stately/table/useTableColumnResizeState.
4
+ *
5
+ * Provides column width state management for a table with column resizing.
6
+ * Tracks column widths, the currently resizing column, and handles
7
+ * width distribution and clamping.
8
+ */
9
+ import { type Accessor } from "solid-js";
10
+ import type { Key } from "../collections/types";
11
+ /** Column size: a number (px) or a string ('100px', '50%', '1fr'). */
12
+ export type ColumnSize = number | string;
13
+ export interface ColumnResizeDefinition {
14
+ /** The column key. */
15
+ key: Key;
16
+ /** The width of the column. Numbers are px, strings can be 'Xfr', 'Xpx', or 'X%'. */
17
+ width?: ColumnSize;
18
+ /** Minimum width in pixels. Default: 75. */
19
+ minWidth?: number;
20
+ /** Maximum width in pixels. Default: Infinity. */
21
+ maxWidth?: number;
22
+ }
23
+ export interface TableColumnResizeStateProps {
24
+ /** Current width of the table or table viewport. */
25
+ tableWidth: number;
26
+ /** Column definitions with width/min/max. */
27
+ columns: ColumnResizeDefinition[];
28
+ }
29
+ export interface TableColumnResizeState {
30
+ /** The key of the column currently being resized, or null. */
31
+ readonly resizingColumn: Accessor<Key | null>;
32
+ /** A reactive map of computed column widths in pixels. */
33
+ readonly columnWidths: Accessor<Map<Key, number>>;
34
+ /** Begin a resize operation for the given column. */
35
+ startResize(key: Key): void;
36
+ /** End the current resize operation. */
37
+ endResize(): void;
38
+ /** Update column widths during a resize drag. Returns the new widths map. */
39
+ updateResizedColumns(key: Key, width: number): Map<Key, number>;
40
+ /** Get the current computed width for a column. */
41
+ getColumnWidth(key: Key): number;
42
+ /** Get the minimum width for a column. */
43
+ getColumnMinWidth(key: Key): number;
44
+ /** Get the maximum width for a column. */
45
+ getColumnMaxWidth(key: Key): number;
46
+ }
47
+ /**
48
+ * Creates column resize state for a table component.
49
+ *
50
+ * Builds an initial column width map from column definitions + table width,
51
+ * then tracks resize operations that clamp to min/max and redistribute
52
+ * remaining space among flex columns.
53
+ */
54
+ export declare function createTableColumnResizeState(props: Accessor<TableColumnResizeStateProps>): TableColumnResizeState;
@@ -2,8 +2,8 @@
2
2
  * Table state management for Table components.
3
3
  * Based on @react-stately/table/useTableState.
4
4
  */
5
- import { type Accessor } from 'solid-js';
6
- import type { TableState, TableStateOptions, TableCollection } from './types';
5
+ import { type Accessor } from "solid-js";
6
+ import type { TableState, TableStateOptions, TableCollection } from "./types";
7
7
  /**
8
8
  * Creates state management for a table component.
9
9
  * Extends grid state with sorting and table-specific features.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Tree grid state management for expandable Table rows.
3
+ * Based on @react-stately/table/useTreeGridState (the `UNSTABLE_` tree-grid feature).
4
+ *
5
+ * Owns the expanded-keys signal (controlled or uncontrolled), rebuilds the table
6
+ * collection from it, and layers the expansion API on top of {@link createTableState}.
7
+ */
8
+ import { type Accessor } from "solid-js";
9
+ import { TableCollection } from "./TableCollection";
10
+ import type { TreeGridState, TreeGridStateOptions } from "./types";
11
+ /**
12
+ * Creates state management for a tree grid (a table with expandable rows). Handles the
13
+ * expanded rows in addition to the selection, sort and focus handled by the table state.
14
+ */
15
+ export declare function createTreeGridState<T extends object, C extends TableCollection<T> = TableCollection<T>>(options: Accessor<TreeGridStateOptions<T, C>>): TreeGridState<T, C>;
@@ -2,6 +2,9 @@
2
2
  * Table state management module.
3
3
  * Provides state hooks for Table components.
4
4
  */
5
- export { createTableState } from './createTableState';
6
- export { TableCollection, createTableCollection } from './TableCollection';
7
- export type { TableState, TableStateOptions, TableCollection as ITableCollection, SortDescriptor, SortDirection, Sortable, ColumnDefinition, RowDefinition, TableCollectionOptions, } from './types';
5
+ export { createTableState } from "./createTableState";
6
+ export { createTreeGridState } from "./createTreeGridState";
7
+ export { createTableColumnResizeState } from "./createTableColumnResizeState";
8
+ export { TableCollection, createTableCollection } from "./TableCollection";
9
+ export type { TableState, TableStateOptions, TableCollection as ITableCollection, TreeGridState, TreeGridStateOptions, SortDescriptor, SortDirection, Sortable, ColumnDefinition, RowDefinition, TableCollectionOptions, } from "./types";
10
+ export type { ColumnSize, ColumnResizeDefinition, TableColumnResizeStateProps, TableColumnResizeState, } from "./createTableColumnResizeState";