@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,12 +2,12 @@
2
2
  * Table state types for Table components.
3
3
  * Based on @react-stately/table and @react-types/table.
4
4
  */
5
- import type { Key } from '../collections/types';
6
- import type { GridState, GridCollection, GridNode } from '../grid/types';
5
+ import type { Key } from "../collections/types";
6
+ import type { GridState, GridCollection, GridNode } from "../grid/types";
7
7
  /**
8
8
  * Sort direction for table columns.
9
9
  */
10
- export type SortDirection = 'ascending' | 'descending';
10
+ export type SortDirection = "ascending" | "descending";
11
11
  /**
12
12
  * Describes which column to sort by and in what direction.
13
13
  */
@@ -41,12 +41,14 @@ export interface TableCollection<T = unknown> extends GridCollection<T> {
41
41
  readonly head?: GridNode<T>;
42
42
  /** The node that makes up the body of the table. */
43
43
  readonly body: GridNode<T>;
44
+ /** The key of the column that renders the tree-grid expand/collapse affordance, if any. */
45
+ readonly treeColumn?: Key | null;
44
46
  }
45
47
  /**
46
48
  * State for a table component.
47
49
  * Extends GridState with table-specific functionality.
48
50
  */
49
- export interface TableState<T, C extends TableCollection<T> = TableCollection<T>> extends Omit<GridState<T, GridCollection<T>>, 'collection'> {
51
+ export interface TableState<T, C extends TableCollection<T> = TableCollection<T>> extends Omit<GridState<T, GridCollection<T>>, "collection"> {
50
52
  /** The table collection. */
51
53
  readonly collection: C;
52
54
  /** Whether the row selection checkboxes should be displayed. */
@@ -55,6 +57,51 @@ export interface TableState<T, C extends TableCollection<T> = TableCollection<T>
55
57
  readonly sortDescriptor: SortDescriptor | null;
56
58
  /** Sort by the given column and direction. */
57
59
  sort(columnKey: Key, direction?: SortDirection): void;
60
+ /**
61
+ * The set of expanded row keys for tree grids. A plain table reports an empty set.
62
+ */
63
+ readonly expandedKeys: "all" | Set<Key>;
64
+ /**
65
+ * The key of the column that renders the expand/collapse affordance, or `null` for a
66
+ * plain (non-tree) table.
67
+ */
68
+ readonly treeColumn: Key | null;
69
+ /** Toggles the expanded state of a row by its key (no-op for a plain table). */
70
+ toggleKey(key: Key): void;
71
+ }
72
+ /**
73
+ * State for a tree grid (expandable rows). Mirrors `@react-stately/table`'s
74
+ * `UNSTABLE_useTreeGridState` return value.
75
+ */
76
+ export interface TreeGridState<T, C extends TableCollection<T> = TableCollection<T>> extends TableState<T, C> {
77
+ /** A set of keys for rows that are expanded. */
78
+ readonly expandedKeys: "all" | Set<Key>;
79
+ /** The key map containing nodes representing the collection's tree grid structure. */
80
+ readonly keyMap: Map<Key, GridNode<T>>;
81
+ /** The number of leaf columns provided by the user (excludes selection/drag columns). */
82
+ readonly userColumnCount: number;
83
+ }
84
+ /**
85
+ * Options for creating tree grid state. Mirrors `TreeGridStateProps` upstream; the
86
+ * expansion props keep the `UNSTABLE_` prefix while the feature is unstable.
87
+ */
88
+ export interface TreeGridStateOptions<T, C extends TableCollection<T> = TableCollection<T>> extends Omit<TableStateOptions<T, C>, "collection"> {
89
+ /** Column definitions. */
90
+ columns: ColumnDefinition<T>[];
91
+ /** Row definitions (may contain `childRows` for nested rows). */
92
+ rows: RowDefinition<T>[];
93
+ /** Function to get the key from a data item. */
94
+ getKey?: (item: T) => Key;
95
+ /** Function to get the text value from a data item. */
96
+ getTextValue?: (item: T, column: ColumnDefinition<T>) => string;
97
+ /** Set of column keys that serve as row headers. */
98
+ rowHeaderColumnKeys?: Set<Key>;
99
+ /** The currently expanded keys in the collection (controlled). */
100
+ UNSTABLE_expandedKeys?: "all" | Iterable<Key>;
101
+ /** The initial expanded keys in the collection (uncontrolled). */
102
+ UNSTABLE_defaultExpandedKeys?: "all" | Iterable<Key>;
103
+ /** Handler that is called when rows are expanded or collapsed. */
104
+ UNSTABLE_onExpandedChange?: (keys: Set<Key>) => void;
58
105
  }
59
106
  /**
60
107
  * Options for creating table state.
@@ -64,20 +111,22 @@ export interface TableStateOptions<T, C extends TableCollection<T> = TableCollec
64
111
  collection: C;
65
112
  /** Keys of disabled rows. */
66
113
  disabledKeys?: Iterable<Key>;
114
+ /** Whether `disabledKeys` applies to all interactions, or only selection. @default "all" */
115
+ disabledBehavior?: "selection" | "all";
67
116
  /** Focus mode: 'row' or 'cell'. */
68
- focusMode?: 'row' | 'cell';
117
+ focusMode?: "row" | "cell";
69
118
  /** Selection mode. */
70
- selectionMode?: 'none' | 'single' | 'multiple';
119
+ selectionMode?: "none" | "single" | "multiple";
71
120
  /** Selection behavior. */
72
- selectionBehavior?: 'toggle' | 'replace';
121
+ selectionBehavior?: "toggle" | "replace";
73
122
  /** Whether empty selection is disallowed. */
74
123
  disallowEmptySelection?: boolean;
75
124
  /** Currently selected keys (controlled). */
76
- selectedKeys?: 'all' | Iterable<Key>;
125
+ selectedKeys?: "all" | Iterable<Key>;
77
126
  /** Default selected keys (uncontrolled). */
78
- defaultSelectedKeys?: 'all' | Iterable<Key>;
127
+ defaultSelectedKeys?: "all" | Iterable<Key>;
79
128
  /** Handler for selection changes. */
80
- onSelectionChange?: (keys: 'all' | Set<Key>) => void;
129
+ onSelectionChange?: (keys: "all" | Set<Key>) => void;
81
130
  /** Whether the row selection checkboxes should be displayed. */
82
131
  showSelectionCheckboxes?: boolean;
83
132
  }
@@ -135,4 +184,13 @@ export interface TableCollectionOptions<T = unknown> {
135
184
  showSelectionCheckboxes?: boolean;
136
185
  /** Set of column keys that serve as row headers. */
137
186
  rowHeaderColumnKeys?: Set<Key>;
187
+ /**
188
+ * The set of expanded row keys. Passing this (even an empty set) builds the collection
189
+ * in tree-grid mode: `childRows` are walked recursively, only rows whose ancestors are
190
+ * all expanded are flattened into the navigable body, and {@link TableCollection.treeColumn}
191
+ * resolves to a real column. Omit it for a plain (non-tree) table.
192
+ */
193
+ expandedKeys?: "all" | Set<Key>;
194
+ /** Explicit tree column key. Defaults to the first row-header column in tree-grid mode. */
195
+ treeColumn?: Key | null;
138
196
  }
@@ -2,11 +2,11 @@
2
2
  * State management for tab components.
3
3
  * Based on @react-stately/tabs.
4
4
  */
5
- import { type Accessor } from 'solid-js';
6
- import { type MaybeAccessor } from '../utils';
7
- import type { Collection, CollectionNode, Key, FocusStrategy } from '../collections/types';
8
- export type KeyboardActivation = 'automatic' | 'manual';
9
- export type TabOrientation = 'horizontal' | 'vertical';
5
+ import { type Accessor } from "solid-js";
6
+ import { type MaybeAccessor } from "../utils";
7
+ import type { Collection, CollectionNode, Key, FocusStrategy } from "../collections/types";
8
+ export type KeyboardActivation = "automatic" | "manual";
9
+ export type TabOrientation = "horizontal" | "vertical";
10
10
  export interface TabListStateProps<T = unknown> {
11
11
  /** The items in the tab list. */
12
12
  items?: T[];
@@ -1 +1 @@
1
- export { createTabListState, type TabListStateProps, type TabListState, type KeyboardActivation, type TabOrientation, } from './createTabListState';
1
+ export { createTabListState, type TabListStateProps, type TabListState, type KeyboardActivation, type TabOrientation, } from "./createTabListState";
@@ -6,8 +6,8 @@
6
6
  * This is a port of @react-stately/utils's useControlledState pattern
7
7
  * as used by @react-aria/textfield.
8
8
  */
9
- import { Accessor } from 'solid-js';
10
- import { type MaybeAccessor } from '../utils';
9
+ import { Accessor } from "solid-js";
10
+ import { type MaybeAccessor } from "../utils";
11
11
  export interface TextFieldStateOptions {
12
12
  /** The current value (controlled). */
13
13
  value?: string;
@@ -1 +1 @@
1
- export { createTextFieldState, type TextFieldStateOptions, type TextFieldState, } from './createTextFieldState';
1
+ export { createTextFieldState, type TextFieldStateOptions, type TextFieldState, } from "./createTextFieldState";
@@ -2,7 +2,7 @@
2
2
  * Toast state management for SolidJS
3
3
  * Based on @react-stately/toast useToastState
4
4
  */
5
- import { type Accessor } from 'solid-js';
5
+ import { type Accessor } from "solid-js";
6
6
  export interface ToastOptions {
7
7
  /** A timeout to automatically close the toast, in milliseconds. */
8
8
  timeout?: number;
@@ -19,7 +19,7 @@ export interface QueuedToast<T> {
19
19
  /** The timer for the toast. */
20
20
  timer: Timer | null;
21
21
  /** Whether the toast should be animated. */
22
- animation?: 'entering' | 'exiting' | 'queued';
22
+ animation?: "entering" | "exiting" | "queued";
23
23
  /** The priority of the toast. */
24
24
  priority: number;
25
25
  /** Handler called when the toast is closed. */
@@ -27,11 +27,19 @@ export interface QueuedToast<T> {
27
27
  /** The timeout for the toast. */
28
28
  timeout?: number;
29
29
  }
30
+ /** The kind of queue mutation that triggered a notification, passed to `wrapUpdate`. */
31
+ export type ToastAction = "add" | "remove" | "clear";
30
32
  export interface ToastQueueOptions {
31
33
  /** The maximum number of toasts to display at once. */
32
34
  maxVisibleToasts?: number;
33
35
  /** Whether toasts should stack (true) or queue (false). */
34
36
  hasExitAnimation?: boolean;
37
+ /**
38
+ * Wraps each update to the visible toasts (e.g. in `document.startViewTransition()`),
39
+ * so the resulting re-render can be animated. Receives the action that triggered the
40
+ * update. Mirrors `@react-stately/toast`'s `wrapUpdate`.
41
+ */
42
+ wrapUpdate?: (fn: () => void, action: ToastAction) => void;
35
43
  }
36
44
  export interface ToastStateProps<T> {
37
45
  /** The toast queue to use. */
@@ -50,6 +58,8 @@ export interface ToastState<T> {
50
58
  * If hasExitAnimation is false, close() removes immediately and this is not needed.
51
59
  */
52
60
  remove: (key: string) => void;
61
+ /** Clears all queued and visible toasts. */
62
+ clear: () => void;
53
63
  /** Pauses all toast timers. */
54
64
  pauseAll: () => void;
55
65
  /** Resumes all toast timers. */
@@ -80,7 +90,15 @@ export declare class ToastQueue<T> {
80
90
  private maxVisibleToasts;
81
91
  private hasExitAnimation;
82
92
  private keyCounter;
93
+ private wrapUpdate?;
83
94
  constructor(options?: ToastQueueOptions);
95
+ /**
96
+ * Installs (or clears) the function that wraps visible-toast updates, so the
97
+ * resulting re-render can be animated. Used to attach `document.startViewTransition`
98
+ * to a shared queue (e.g. the global queue) after construction.
99
+ */
100
+ setWrapUpdate(wrapUpdate?: (fn: () => void, action: ToastAction) => void): void;
101
+ private runWithWrapUpdate;
84
102
  /**
85
103
  * Subscribe to queue changes.
86
104
  */
@@ -97,6 +115,10 @@ export declare class ToastQueue<T> {
97
115
  * Remove a toast after exit animation completes.
98
116
  */
99
117
  remove(key: string): void;
118
+ /**
119
+ * Clear all queued and visible toasts.
120
+ */
121
+ clear(): void;
100
122
  /**
101
123
  * Pause all toast timers.
102
124
  */
@@ -1 +1 @@
1
- export { createToastState, createToastQueue, ToastQueue, Timer, type ToastOptions, type QueuedToast, type ToastQueueOptions, type ToastStateProps, type ToastState, } from './createToastState';
1
+ export { createToastState, createToastQueue, ToastQueue, Timer, type ToastOptions, type QueuedToast, type ToastQueueOptions, type ToastAction, type ToastStateProps, type ToastState, } from "./createToastState";
@@ -6,14 +6,14 @@
6
6
  *
7
7
  * This is a port of @react-stately/toggle's useToggleGroupState.
8
8
  */
9
- import type { Key } from '../collections';
10
- import { type MaybeAccessor } from '../utils';
9
+ import type { Key } from "../collections";
10
+ import { type MaybeAccessor } from "../utils";
11
11
  export interface ToggleGroupProps {
12
12
  /**
13
13
  * Whether single or multiple selection is enabled.
14
14
  * @default 'single'
15
15
  */
16
- selectionMode?: 'single' | 'multiple';
16
+ selectionMode?: "single" | "multiple";
17
17
  /** Whether empty selection is disallowed. */
18
18
  disallowEmptySelection?: boolean;
19
19
  /** Controlled selected keys. */
@@ -27,7 +27,7 @@ export interface ToggleGroupProps {
27
27
  }
28
28
  export interface ToggleGroupState {
29
29
  /** Whether single or multiple selection is enabled. */
30
- readonly selectionMode: 'single' | 'multiple';
30
+ readonly selectionMode: "single" | "multiple";
31
31
  /** Whether all items are disabled. */
32
32
  readonly isDisabled: boolean;
33
33
  /** Current selected keys. */
@@ -5,8 +5,8 @@
5
5
  *
6
6
  * This is a 1:1 port of @react-stately/toggle's useToggleState.
7
7
  */
8
- import { Accessor } from 'solid-js';
9
- import { type MaybeAccessor } from '../utils';
8
+ import { Accessor } from "solid-js";
9
+ import { type MaybeAccessor } from "../utils";
10
10
  export interface ToggleStateOptions {
11
11
  /** Whether the element should be selected (controlled). */
12
12
  isSelected?: boolean;
@@ -1,2 +1,2 @@
1
- export { createToggleState, type ToggleStateOptions, type ToggleState, } from './createToggleState';
2
- export { createToggleGroupState, type ToggleGroupProps, type ToggleGroupState, } from './createToggleGroupState';
1
+ export { createToggleState, type ToggleStateOptions, type ToggleState } from "./createToggleState";
2
+ export { createToggleGroupState, type ToggleGroupProps, type ToggleGroupState, } from "./createToggleGroupState";
@@ -5,8 +5,8 @@
5
5
  * Tracks whether the tooltip is open, and provides methods to toggle this state.
6
6
  * Ensures only one tooltip is open at a time and controls the delay for showing a tooltip.
7
7
  */
8
- import { type Accessor } from 'solid-js';
9
- import { type OverlayTriggerProps } from '../overlays';
8
+ import { type Accessor } from "solid-js";
9
+ import { type OverlayTriggerProps } from "../overlays";
10
10
  export interface TooltipTriggerProps extends OverlayTriggerProps {
11
11
  /** The delay time in milliseconds for the tooltip to show up. */
12
12
  delay?: number;
@@ -1 +1 @@
1
- export { createTooltipTriggerState, resetTooltipState, type TooltipTriggerProps, type TooltipTriggerState, } from './createTooltipTriggerState';
1
+ export { createTooltipTriggerState, resetTooltipState, type TooltipTriggerProps, type TooltipTriggerState, } from "./createTooltipTriggerState";
@@ -5,8 +5,8 @@
5
5
  * A flattened view of tree nodes that respects expanded state.
6
6
  * Only visible nodes (root + expanded children) are included in iteration.
7
7
  */
8
- import type { Key } from '../collections/types';
9
- import type { TreeCollection as ITreeCollection, TreeNode, TreeItemData } from './types';
8
+ import type { Key } from "../collections/types";
9
+ import type { TreeCollection as ITreeCollection, TreeNode, TreeItemData } from "./types";
10
10
  /**
11
11
  * Creates a TreeCollection from hierarchical data.
12
12
  * The collection is flattened based on expanded keys.
@@ -4,8 +4,8 @@
4
4
  *
5
5
  * Manages expansion state, selection, and focus for hierarchical tree data.
6
6
  */
7
- import { type Accessor } from 'solid-js';
8
- import type { TreeState, TreeStateOptions, TreeCollection } from './types';
7
+ import { type Accessor } from "solid-js";
8
+ import type { TreeState, TreeStateOptions, TreeCollection } from "./types";
9
9
  /**
10
10
  * Creates state management for a tree component.
11
11
  * Handles expansion, selection, focus management, and keyboard navigation state.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Tree state management exports.
3
3
  */
4
- export { createTreeState } from './createTreeState';
5
- export { TreeCollection, createTreeCollection } from './TreeCollection';
6
- export type { TreeState, TreeStateOptions, TreeCollection as TreeCollectionInterface, TreeNode, TreeItemData, } from './types';
4
+ export { createTreeState } from "./createTreeState";
5
+ export { TreeCollection, createTreeCollection } from "./TreeCollection";
6
+ export type { TreeState, TreeStateOptions, TreeCollection as TreeCollectionInterface, TreeNode, TreeItemData, } from "./types";
@@ -2,8 +2,8 @@
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, Selection, SelectionBehavior } 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.
@@ -26,7 +26,7 @@ export interface TreeNode<T = unknown> extends GridNode<T> {
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'> {
29
+ export interface TreeCollection<T = unknown> extends Omit<GridCollection<T>, "rows" | "columns" | "headerRows" | "columnCount" | "getCell"> {
30
30
  /** All visible rows in the tree (respects expanded state). */
31
31
  readonly rows: TreeNode<T>[];
32
32
  /** Number of visible rows. */
@@ -63,6 +63,8 @@ export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
63
63
  readonly collection: C;
64
64
  /** Keys of disabled items. */
65
65
  readonly disabledKeys: Set<Key>;
66
+ /** Whether `disabledKeys` applies to all interactions, or only selection. */
67
+ readonly disabledBehavior: "selection" | "all";
66
68
  /** Keys of expanded items. */
67
69
  readonly expandedKeys: Set<Key>;
68
70
  /** Whether keyboard navigation is disabled. */
@@ -74,9 +76,13 @@ export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
74
76
  /** Whether the tree is focused. */
75
77
  readonly isFocused: boolean;
76
78
  /** The selection mode. */
77
- readonly selectionMode: 'none' | 'single' | 'multiple';
79
+ readonly selectionMode: "none" | "single" | "multiple";
80
+ /** How selection behaves when pressing an item. */
81
+ readonly selectionBehavior: SelectionBehavior;
82
+ /** Whether empty selection is disallowed. */
83
+ readonly disallowEmptySelection: boolean;
78
84
  /** The currently selected keys. */
79
- readonly selectedKeys: 'all' | Set<Key>;
85
+ readonly selectedKeys: Selection;
80
86
  /** Check if a key is selected. */
81
87
  isSelected(key: Key): boolean;
82
88
  /** Check if a key is disabled. */
@@ -91,6 +97,10 @@ export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
91
97
  toggleSelection(key: Key): void;
92
98
  /** Replace selection with a key. */
93
99
  replaceSelection(key: Key): void;
100
+ /** Set the selected keys directly. */
101
+ setSelectedKeys(keys: Selection | Iterable<Key>): void;
102
+ /** Set how selection behaves when pressing an item. */
103
+ setSelectionBehavior(behavior: SelectionBehavior): void;
94
104
  /** Extend selection to a key (shift-click). */
95
105
  extendSelection(toKey: Key): void;
96
106
  /** Select all visible items. */
@@ -119,19 +129,19 @@ export interface TreeStateOptions<T, C extends TreeCollection<T> = TreeCollectio
119
129
  /** Keys of disabled items. */
120
130
  disabledKeys?: Iterable<Key>;
121
131
  /** Disabled behavior: 'selection' only or 'all' interactions. */
122
- disabledBehavior?: 'selection' | 'all';
132
+ disabledBehavior?: "selection" | "all";
123
133
  /** Selection mode. */
124
- selectionMode?: 'none' | 'single' | 'multiple';
134
+ selectionMode?: "none" | "single" | "multiple";
125
135
  /** Selection behavior. */
126
- selectionBehavior?: 'toggle' | 'replace';
136
+ selectionBehavior?: SelectionBehavior;
127
137
  /** Whether empty selection is disallowed. */
128
138
  disallowEmptySelection?: boolean;
129
139
  /** Currently selected keys (controlled). */
130
- selectedKeys?: 'all' | Iterable<Key>;
140
+ selectedKeys?: Selection | Iterable<Key>;
131
141
  /** Default selected keys (uncontrolled). */
132
- defaultSelectedKeys?: 'all' | Iterable<Key>;
142
+ defaultSelectedKeys?: Selection | Iterable<Key>;
133
143
  /** Handler for selection changes. */
134
- onSelectionChange?: (keys: 'all' | Set<Key>) => void;
144
+ onSelectionChange?: (keys: "all" | Set<Key>) => void;
135
145
  /** Currently expanded keys (controlled). */
136
146
  expandedKeys?: Iterable<Key>;
137
147
  /** Default expanded keys (uncontrolled). */
@@ -144,13 +154,17 @@ export interface TreeStateOptions<T, C extends TreeCollection<T> = TreeCollectio
144
154
  */
145
155
  export interface TreeItemData<T = unknown> {
146
156
  /** Unique key for this item. */
147
- key: Key;
157
+ key?: Key;
158
+ /** S2/React Aria-compatible unique id alias. */
159
+ id?: Key;
148
160
  /** The data value for this item. */
149
- value: T;
161
+ value?: T;
150
162
  /** Text content for accessibility and search. */
151
163
  textValue?: string;
152
164
  /** Child items (makes this item expandable). */
153
165
  children?: TreeItemData<T>[];
166
+ /** Whether this item has children that may not be loaded yet. */
167
+ hasChildItems?: boolean;
154
168
  /** Whether this item is disabled. */
155
169
  isDisabled?: boolean;
156
170
  }
@@ -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.
package/package.json CHANGED
@@ -1,31 +1,40 @@
1
1
  {
2
2
  "name": "@proyecto-viviana/solid-stately",
3
- "version": "0.2.7",
3
+ "version": "0.4.0",
4
4
  "description": "A 1-1 SolidJS port of React Stately - headless state management for UI components",
5
+ "keywords": [
6
+ "headless",
7
+ "react-stately",
8
+ "solid",
9
+ "solidjs",
10
+ "state",
11
+ "stately"
12
+ ],
13
+ "license": "MIT",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/proyecto-viviana/ui.git",
17
+ "directory": "packages/solid-stately"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "src"
22
+ ],
5
23
  "type": "module",
24
+ "sideEffects": false,
6
25
  "main": "./dist/index.js",
7
26
  "module": "./dist/index.js",
8
27
  "types": "./dist/index.d.ts",
9
28
  "exports": {
10
29
  ".": {
11
30
  "types": "./dist/index.d.ts",
12
- "solid": "./src/index.ts",
31
+ "solid": "./dist/index.js",
13
32
  "import": "./dist/index.js",
14
33
  "default": "./dist/index.js"
15
34
  }
16
35
  },
17
- "files": [
18
- "dist",
19
- "src"
20
- ],
21
- "sideEffects": false,
22
- "scripts": {
23
- "build": "tsup && rm -f tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json",
24
- "dev": "tsup --watch",
25
- "prepublishOnly": "echo 'Use the root Changesets npm release workflow'"
26
- },
27
- "peerDependencies": {
28
- "solid-js": "^1.9.0"
36
+ "publishConfig": {
37
+ "access": "public"
29
38
  },
30
39
  "dependencies": {
31
40
  "@internationalized/date": "^3.8.0"
@@ -33,21 +42,11 @@
33
42
  "devDependencies": {
34
43
  "solid-js": "^1.9.11"
35
44
  },
36
- "keywords": [
37
- "solid",
38
- "solidjs",
39
- "stately",
40
- "state",
41
- "headless",
42
- "react-stately"
43
- ],
44
- "license": "MIT",
45
- "repository": {
46
- "type": "git",
47
- "url": "git+https://github.com/proyecto-viviana/proyecto-viviana.git",
48
- "directory": "packages/solid-stately"
45
+ "peerDependencies": {
46
+ "solid-js": "^1.9.0"
49
47
  },
50
- "publishConfig": {
51
- "access": "public"
48
+ "scripts": {
49
+ "build": "rm -rf dist && tsdown && rm -f tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json",
50
+ "dev": "tsup --watch"
52
51
  }
53
- }
52
+ }
@@ -3,24 +3,24 @@
3
3
  *
4
4
  * Based on @react-stately/autocomplete useAutocompleteState.
5
5
  */
6
- import { type Accessor } from 'solid-js';
6
+ import { type Accessor } from "solid-js";
7
7
  export interface AutocompleteState {
8
- /** The current value of the autocomplete input. */
9
- inputValue: Accessor<string>;
10
- /** Sets the value of the autocomplete input. */
11
- setInputValue(value: string): void;
12
- /** The id of the current aria-activedescendant of the autocomplete input. */
13
- focusedNodeId: Accessor<string | null>;
14
- /** Sets the id of the current aria-activedescendant of the autocomplete input. */
15
- setFocusedNodeId(value: string | null): void;
8
+ /** The current value of the autocomplete input. */
9
+ inputValue: Accessor<string>;
10
+ /** Sets the value of the autocomplete input. */
11
+ setInputValue(value: string): void;
12
+ /** The id of the current aria-activedescendant of the autocomplete input. */
13
+ focusedNodeId: Accessor<string | null>;
14
+ /** Sets the id of the current aria-activedescendant of the autocomplete input. */
15
+ setFocusedNodeId(value: string | null): void;
16
16
  }
17
17
  export interface AutocompleteStateOptions {
18
- /** The value of the autocomplete input (controlled). */
19
- inputValue?: string;
20
- /** The default value of the autocomplete input (uncontrolled). */
21
- defaultInputValue?: string;
22
- /** Handler that is called when the autocomplete input value changes. */
23
- onInputChange?: (value: string) => void;
18
+ /** The value of the autocomplete input (controlled). */
19
+ inputValue?: string;
20
+ /** The default value of the autocomplete input (uncontrolled). */
21
+ defaultInputValue?: string;
22
+ /** Handler that is called when the autocomplete input value changes. */
23
+ onInputChange?: (value: string) => void;
24
24
  }
25
25
  /**
26
26
  * Provides state management for an autocomplete component.
@@ -42,5 +42,7 @@ export interface AutocompleteStateOptions {
42
42
  * state.setFocusedNodeId('item-1');
43
43
  * ```
44
44
  */
45
- export declare function createAutocompleteState(props?: AutocompleteStateOptions): AutocompleteState;
46
- //# sourceMappingURL=createAutocompleteState.d.ts.map
45
+ export declare function createAutocompleteState(
46
+ props?: AutocompleteStateOptions,
47
+ ): AutocompleteState;
48
+ //# sourceMappingURL=createAutocompleteState.d.ts.map