@proyecto-viviana/solid-stately 0.2.7 → 0.3.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 (242) 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/createCalendarState.d.ts +22 -7
  5. package/dist/calendar/createDateFieldState.d.ts +30 -7
  6. package/dist/calendar/createDatePickerState.d.ts +60 -0
  7. package/dist/calendar/createRangeCalendarState.d.ts +27 -8
  8. package/dist/calendar/createTimeFieldState.d.ts +34 -7
  9. package/dist/calendar/index.d.ts +7 -6
  10. package/dist/checkbox/createCheckboxGroupState.d.ts +6 -6
  11. package/dist/checkbox/index.d.ts +1 -1
  12. package/dist/collections/ListCollection.d.ts +1 -1
  13. package/dist/collections/createListState.d.ts +8 -8
  14. package/dist/collections/createMenuState.d.ts +7 -7
  15. package/dist/collections/createSelectionState.d.ts +5 -5
  16. package/dist/collections/index.d.ts +5 -5
  17. package/dist/collections/types.d.ts +12 -12
  18. package/dist/color/Color.d.ts +1 -1
  19. package/dist/color/createColorAreaState.d.ts +4 -2
  20. package/dist/color/createColorFieldState.d.ts +38 -12
  21. package/dist/color/createColorSliderState.d.ts +9 -2
  22. package/dist/color/createColorWheelState.d.ts +13 -2
  23. package/dist/color/getColorChannels.d.ts +1 -1
  24. package/dist/color/index.d.ts +6 -6
  25. package/dist/color/types.d.ts +4 -4
  26. package/dist/combobox/createComboBoxState.d.ts +27 -13
  27. package/dist/combobox/index.d.ts +1 -1
  28. package/dist/data/createAsyncList.d.ts +4 -4
  29. package/dist/data/createListData.d.ts +2 -2
  30. package/dist/data/createTreeData.d.ts +6 -2
  31. package/dist/data/index.d.ts +3 -3
  32. package/dist/datepicker/index.d.ts +2 -4
  33. package/dist/disclosure/createDisclosureState.d.ts +2 -2
  34. package/dist/disclosure/index.d.ts +1 -1
  35. package/dist/dnd/createDragState.d.ts +2 -2
  36. package/dist/dnd/createDraggableCollectionState.d.ts +2 -2
  37. package/dist/dnd/createDropState.d.ts +2 -2
  38. package/dist/dnd/createDroppableCollectionState.d.ts +3 -3
  39. package/dist/dnd/index.d.ts +5 -5
  40. package/dist/dnd/types.d.ts +16 -16
  41. package/dist/form/createFormValidationState.d.ts +3 -3
  42. package/dist/form/index.d.ts +1 -1
  43. package/dist/grid/createGridState.d.ts +2 -2
  44. package/dist/grid/index.d.ts +2 -2
  45. package/dist/grid/types.d.ts +13 -11
  46. package/dist/index.d.ts +31 -30
  47. package/dist/index.js +7924 -7238
  48. package/dist/index.js.map +1 -1
  49. package/dist/menu/index.d.ts +2 -2
  50. package/dist/numberfield/createNumberFieldState.d.ts +2 -2
  51. package/dist/numberfield/index.d.ts +1 -1
  52. package/dist/overlays/createOverlayTriggerState.d.ts +2 -2
  53. package/dist/overlays/index.d.ts +1 -1
  54. package/dist/radio/createRadioGroupState.d.ts +7 -7
  55. package/dist/radio/index.d.ts +1 -1
  56. package/dist/searchfield/createSearchFieldState.d.ts +2 -2
  57. package/dist/searchfield/index.d.ts +2 -2
  58. package/dist/select/createSelectState.d.ts +8 -8
  59. package/dist/select/index.d.ts +1 -1
  60. package/dist/selection/index.d.ts +5 -5
  61. package/dist/slider/createSliderState.d.ts +3 -3
  62. package/dist/slider/index.d.ts +2 -2
  63. package/dist/steplist/createStepListState.d.ts +48 -0
  64. package/dist/steplist/index.d.ts +1 -0
  65. package/dist/table/TableCollection.d.ts +3 -3
  66. package/dist/table/createTableColumnResizeState.d.ts +54 -0
  67. package/dist/table/createTableState.d.ts +2 -2
  68. package/dist/table/index.d.ts +5 -3
  69. package/dist/table/types.d.ts +10 -10
  70. package/dist/tabs/createTabListState.d.ts +5 -5
  71. package/dist/tabs/index.d.ts +1 -1
  72. package/dist/textfield/createTextFieldState.d.ts +2 -2
  73. package/dist/textfield/index.d.ts +1 -1
  74. package/dist/toast/createToastState.d.ts +8 -2
  75. package/dist/toast/index.d.ts +1 -1
  76. package/dist/toggle/createToggleGroupState.d.ts +4 -4
  77. package/dist/toggle/createToggleState.d.ts +2 -2
  78. package/dist/toggle/index.d.ts +2 -2
  79. package/dist/tooltip/createTooltipTriggerState.d.ts +2 -2
  80. package/dist/tooltip/index.d.ts +1 -1
  81. package/dist/tree/TreeCollection.d.ts +2 -2
  82. package/dist/tree/createTreeState.d.ts +2 -2
  83. package/dist/tree/index.d.ts +3 -3
  84. package/dist/tree/types.d.ts +19 -13
  85. package/dist/utils/index.d.ts +1 -1
  86. package/dist/utils/reactivity.d.ts +1 -1
  87. package/package.json +29 -30
  88. package/src/autocomplete/createAutocompleteState.d.ts +19 -17
  89. package/src/autocomplete/createAutocompleteState.ts +24 -30
  90. package/src/autocomplete/index.d.ts +6 -2
  91. package/src/autocomplete/index.ts +1 -1
  92. package/src/calendar/createCalendarState.d.ts +139 -117
  93. package/src/calendar/createCalendarState.ts +221 -74
  94. package/src/calendar/createDateFieldState.d.ts +130 -95
  95. package/src/calendar/createDateFieldState.ts +263 -151
  96. package/src/calendar/createDatePickerState.ts +347 -0
  97. package/src/calendar/createRangeCalendarState.d.ts +154 -129
  98. package/src/calendar/createRangeCalendarState.ts +293 -79
  99. package/src/calendar/createTimeFieldState.d.ts +81 -79
  100. package/src/calendar/createTimeFieldState.ts +187 -108
  101. package/src/calendar/index.d.ts +80 -7
  102. package/src/calendar/index.ts +21 -12
  103. package/src/checkbox/createCheckboxGroupState.d.ts +57 -55
  104. package/src/checkbox/createCheckboxGroupState.ts +20 -29
  105. package/src/checkbox/index.d.ts +6 -2
  106. package/src/checkbox/index.ts +1 -1
  107. package/src/collections/ListCollection.d.ts +25 -22
  108. package/src/collections/ListCollection.ts +6 -6
  109. package/src/collections/createListState.d.ts +73 -58
  110. package/src/collections/createListState.ts +19 -18
  111. package/src/collections/createMenuState.d.ts +36 -31
  112. package/src/collections/createMenuState.ts +18 -12
  113. package/src/collections/createSelectionState.d.ts +78 -65
  114. package/src/collections/createSelectionState.ts +36 -32
  115. package/src/collections/index.d.ts +38 -6
  116. package/src/collections/index.ts +5 -10
  117. package/src/collections/types.d.ts +101 -101
  118. package/src/collections/types.ts +12 -12
  119. package/src/color/Color.d.ts +20 -5
  120. package/src/color/Color.ts +357 -254
  121. package/src/color/createColorAreaState.d.ts +67 -65
  122. package/src/color/createColorAreaState.ts +21 -13
  123. package/src/color/createColorFieldState.d.ts +46 -44
  124. package/src/color/createColorFieldState.ts +285 -149
  125. package/src/color/createColorSliderState.d.ts +58 -56
  126. package/src/color/createColorSliderState.ts +45 -14
  127. package/src/color/createColorWheelState.d.ts +42 -40
  128. package/src/color/createColorWheelState.ts +101 -64
  129. package/src/color/getColorChannels.ts +7 -5
  130. package/src/color/index.d.ts +36 -7
  131. package/src/color/index.ts +6 -9
  132. package/src/color/types.d.ts +68 -63
  133. package/src/color/types.ts +11 -19
  134. package/src/combobox/createComboBoxState.d.ts +107 -105
  135. package/src/combobox/createComboBoxState.ts +176 -89
  136. package/src/combobox/index.d.ts +10 -2
  137. package/src/combobox/index.ts +1 -1
  138. package/src/data/createAsyncList.ts +89 -63
  139. package/src/data/createListData.ts +67 -67
  140. package/src/data/createTreeData.ts +304 -91
  141. package/src/data/index.ts +3 -3
  142. package/src/datepicker/index.ts +6 -10
  143. package/src/disclosure/createDisclosureState.d.ts +47 -43
  144. package/src/disclosure/createDisclosureState.ts +7 -21
  145. package/src/disclosure/index.d.ts +10 -2
  146. package/src/disclosure/index.ts +1 -1
  147. package/src/dnd/createDragState.d.ts +51 -42
  148. package/src/dnd/createDragState.ts +12 -14
  149. package/src/dnd/createDraggableCollectionState.d.ts +52 -41
  150. package/src/dnd/createDraggableCollectionState.ts +14 -21
  151. package/src/dnd/createDropState.d.ts +64 -45
  152. package/src/dnd/createDropState.ts +22 -32
  153. package/src/dnd/createDroppableCollectionState.d.ts +88 -59
  154. package/src/dnd/createDroppableCollectionState.ts +40 -43
  155. package/src/dnd/index.d.ts +54 -6
  156. package/src/dnd/index.ts +5 -18
  157. package/src/dnd/types.d.ts +167 -156
  158. package/src/dnd/types.ts +20 -21
  159. package/src/form/createFormValidationState.d.ts +47 -45
  160. package/src/form/createFormValidationState.ts +30 -63
  161. package/src/form/index.d.ts +16 -2
  162. package/src/form/index.ts +1 -1
  163. package/src/grid/createGridState.d.ts +7 -4
  164. package/src/grid/createGridState.ts +44 -51
  165. package/src/grid/index.d.ts +3 -3
  166. package/src/grid/index.ts +2 -8
  167. package/src/grid/types.d.ts +136 -129
  168. package/src/grid/types.ts +20 -18
  169. package/src/index.d.ts +310 -26
  170. package/src/index.ts +48 -89
  171. package/src/menu/index.ts +2 -4
  172. package/src/numberfield/createNumberFieldState.d.ts +56 -54
  173. package/src/numberfield/createNumberFieldState.ts +26 -31
  174. package/src/numberfield/index.d.ts +6 -2
  175. package/src/numberfield/index.ts +1 -1
  176. package/src/overlays/createOverlayTriggerState.d.ts +22 -20
  177. package/src/overlays/createOverlayTriggerState.ts +3 -4
  178. package/src/overlays/index.d.ts +6 -2
  179. package/src/overlays/index.ts +1 -1
  180. package/src/radio/createRadioGroupState.d.ts +54 -52
  181. package/src/radio/createRadioGroupState.ts +27 -29
  182. package/src/radio/index.d.ts +7 -2
  183. package/src/radio/index.ts +1 -1
  184. package/src/searchfield/createSearchFieldState.d.ts +16 -14
  185. package/src/searchfield/createSearchFieldState.ts +5 -11
  186. package/src/searchfield/index.d.ts +3 -3
  187. package/src/searchfield/index.ts +2 -5
  188. package/src/select/createSelectState.d.ts +63 -61
  189. package/src/select/createSelectState.ts +27 -27
  190. package/src/select/index.d.ts +2 -2
  191. package/src/select/index.ts +1 -5
  192. package/src/selection/index.ts +6 -7
  193. package/src/slider/createSliderState.d.ts +60 -60
  194. package/src/slider/createSliderState.ts +55 -33
  195. package/src/slider/index.d.ts +3 -3
  196. package/src/slider/index.ts +2 -6
  197. package/src/ssr/index.d.ts +1 -1
  198. package/src/ssr/index.ts +2 -2
  199. package/src/steplist/createStepListState.ts +191 -0
  200. package/src/steplist/index.ts +5 -0
  201. package/src/table/TableCollection.d.ts +42 -40
  202. package/src/table/TableCollection.ts +61 -64
  203. package/src/table/createTableColumnResizeState.ts +242 -0
  204. package/src/table/createTableState.d.ts +7 -4
  205. package/src/table/createTableState.ts +10 -7
  206. package/src/table/index.d.ts +14 -4
  207. package/src/table/index.ts +10 -3
  208. package/src/table/types.d.ts +98 -92
  209. package/src/table/types.ts +17 -13
  210. package/src/tabs/createTabListState.d.ts +59 -57
  211. package/src/tabs/createTabListState.ts +24 -31
  212. package/src/tabs/index.d.ts +8 -2
  213. package/src/tabs/index.ts +1 -1
  214. package/src/textfield/createTextFieldState.d.ts +16 -14
  215. package/src/textfield/createTextFieldState.ts +7 -18
  216. package/src/textfield/index.d.ts +6 -2
  217. package/src/textfield/index.ts +1 -1
  218. package/src/toast/createToastState.d.ts +92 -86
  219. package/src/toast/createToastState.ts +48 -43
  220. package/src/toast/index.d.ts +12 -2
  221. package/src/toast/index.ts +1 -1
  222. package/src/toggle/createToggleGroupState.ts +11 -21
  223. package/src/toggle/createToggleState.d.ts +19 -19
  224. package/src/toggle/createToggleState.ts +2 -16
  225. package/src/toggle/index.d.ts +2 -2
  226. package/src/toggle/index.ts +2 -6
  227. package/src/tooltip/createTooltipTriggerState.d.ts +17 -17
  228. package/src/tooltip/createTooltipTriggerState.ts +12 -11
  229. package/src/tooltip/index.d.ts +7 -2
  230. package/src/tooltip/index.ts +1 -1
  231. package/src/tree/TreeCollection.d.ts +26 -23
  232. package/src/tree/TreeCollection.ts +29 -22
  233. package/src/tree/createTreeState.d.ts +7 -4
  234. package/src/tree/createTreeState.ts +39 -41
  235. package/src/tree/index.d.ts +10 -4
  236. package/src/tree/index.ts +3 -3
  237. package/src/tree/types.d.ts +131 -126
  238. package/src/tree/types.ts +22 -13
  239. package/src/utils/index.d.ts +2 -2
  240. package/src/utils/index.ts +1 -1
  241. package/src/utils/reactivity.d.ts +2 -2
  242. package/src/utils/reactivity.ts +3 -3
@@ -2,138 +2,144 @@
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
  */
14
14
  export interface SortDescriptor {
15
- /** The key of the column to sort by. */
16
- column: Key;
17
- /** The direction to sort by. */
18
- direction: SortDirection;
15
+ /** The key of the column to sort by. */
16
+ column: Key;
17
+ /** The direction to sort by. */
18
+ direction: SortDirection;
19
19
  }
20
20
  /**
21
21
  * Interface for sortable components.
22
22
  */
23
23
  export interface Sortable {
24
- /** The current sorted column and direction. */
25
- sortDescriptor?: SortDescriptor;
26
- /** Handler that is called when the sorted column or direction changes. */
27
- onSortChange?: (descriptor: SortDescriptor) => void;
24
+ /** The current sorted column and direction. */
25
+ sortDescriptor?: SortDescriptor;
26
+ /** Handler that is called when the sorted column or direction changes. */
27
+ onSortChange?: (descriptor: SortDescriptor) => void;
28
28
  }
29
29
  /**
30
30
  * A collection of table rows and columns.
31
31
  * Extends GridCollection with table-specific metadata.
32
32
  */
33
33
  export interface TableCollection<T = unknown> extends GridCollection<T> {
34
- /** A list of header row nodes in the table. */
35
- readonly headerRows: GridNode<T>[];
36
- /** A list of column nodes in the table. */
37
- readonly columns: GridNode<T>[];
38
- /** A set of column keys that serve as the row header. */
39
- readonly rowHeaderColumnKeys: Set<Key>;
40
- /** The node that makes up the header of the table. */
41
- readonly head?: GridNode<T>;
42
- /** The node that makes up the body of the table. */
43
- readonly body: GridNode<T>;
34
+ /** A list of header row nodes in the table. */
35
+ readonly headerRows: GridNode<T>[];
36
+ /** A list of column nodes in the table. */
37
+ readonly columns: GridNode<T>[];
38
+ /** A set of column keys that serve as the row header. */
39
+ readonly rowHeaderColumnKeys: Set<Key>;
40
+ /** The node that makes up the header of the table. */
41
+ readonly head?: GridNode<T>;
42
+ /** The node that makes up the body of the table. */
43
+ readonly body: GridNode<T>;
44
44
  }
45
45
  /**
46
46
  * State for a table component.
47
47
  * Extends GridState with table-specific functionality.
48
48
  */
49
- export interface TableState<T, C extends TableCollection<T> = TableCollection<T>> extends Omit<GridState<T, GridCollection<T>>, 'collection'> {
50
- /** The table collection. */
51
- readonly collection: C;
52
- /** Whether the row selection checkboxes should be displayed. */
53
- readonly showSelectionCheckboxes: boolean;
54
- /** The current sorted column and direction. */
55
- readonly sortDescriptor: SortDescriptor | null;
56
- /** Sort by the given column and direction. */
57
- sort(columnKey: Key, direction?: SortDirection): void;
49
+ export interface TableState<T, C extends TableCollection<T> = TableCollection<T>> extends Omit<
50
+ GridState<T, GridCollection<T>>,
51
+ "collection"
52
+ > {
53
+ /** The table collection. */
54
+ readonly collection: C;
55
+ /** Whether the row selection checkboxes should be displayed. */
56
+ readonly showSelectionCheckboxes: boolean;
57
+ /** The current sorted column and direction. */
58
+ readonly sortDescriptor: SortDescriptor | null;
59
+ /** Sort by the given column and direction. */
60
+ sort(columnKey: Key, direction?: SortDirection): void;
58
61
  }
59
62
  /**
60
63
  * Options for creating table state.
61
64
  */
62
- export interface TableStateOptions<T, C extends TableCollection<T> = TableCollection<T>> extends Sortable {
63
- /** The table collection. */
64
- collection: C;
65
- /** Keys of disabled rows. */
66
- disabledKeys?: Iterable<Key>;
67
- /** Focus mode: 'row' or 'cell'. */
68
- focusMode?: 'row' | 'cell';
69
- /** Selection mode. */
70
- selectionMode?: 'none' | 'single' | 'multiple';
71
- /** Selection behavior. */
72
- selectionBehavior?: 'toggle' | 'replace';
73
- /** Whether empty selection is disallowed. */
74
- disallowEmptySelection?: boolean;
75
- /** Currently selected keys (controlled). */
76
- selectedKeys?: 'all' | Iterable<Key>;
77
- /** Default selected keys (uncontrolled). */
78
- defaultSelectedKeys?: 'all' | Iterable<Key>;
79
- /** Handler for selection changes. */
80
- onSelectionChange?: (keys: 'all' | Set<Key>) => void;
81
- /** Whether the row selection checkboxes should be displayed. */
82
- showSelectionCheckboxes?: boolean;
65
+ export interface TableStateOptions<
66
+ T,
67
+ C extends TableCollection<T> = TableCollection<T>,
68
+ > extends Sortable {
69
+ /** The table collection. */
70
+ collection: C;
71
+ /** Keys of disabled rows. */
72
+ disabledKeys?: Iterable<Key>;
73
+ /** Focus mode: 'row' or 'cell'. */
74
+ focusMode?: "row" | "cell";
75
+ /** Selection mode. */
76
+ selectionMode?: "none" | "single" | "multiple";
77
+ /** Selection behavior. */
78
+ selectionBehavior?: "toggle" | "replace";
79
+ /** Whether empty selection is disallowed. */
80
+ disallowEmptySelection?: boolean;
81
+ /** Currently selected keys (controlled). */
82
+ selectedKeys?: "all" | Iterable<Key>;
83
+ /** Default selected keys (uncontrolled). */
84
+ defaultSelectedKeys?: "all" | Iterable<Key>;
85
+ /** Handler for selection changes. */
86
+ onSelectionChange?: (keys: "all" | Set<Key>) => void;
87
+ /** Whether the row selection checkboxes should be displayed. */
88
+ showSelectionCheckboxes?: boolean;
83
89
  }
84
90
  /**
85
91
  * Column definition for building table collections.
86
92
  */
87
93
  export interface ColumnDefinition<T = unknown> {
88
- /** The key for the column. */
89
- key: Key;
90
- /** The display name or rendered content. */
91
- name?: string;
92
- /** Text value for accessibility. */
93
- textValue?: string;
94
- /** Whether this column is a row header. */
95
- isRowHeader?: boolean;
96
- /** Whether this column allows sorting. */
97
- allowsSorting?: boolean;
98
- /** Child columns (for column groups). */
99
- children?: ColumnDefinition<T>[];
100
- /** Width of the column. */
101
- width?: number | string;
102
- /** Minimum width of the column. */
103
- minWidth?: number;
104
- /** Maximum width of the column. */
105
- maxWidth?: number;
94
+ /** The key for the column. */
95
+ key: Key;
96
+ /** The display name or rendered content. */
97
+ name?: string;
98
+ /** Text value for accessibility. */
99
+ textValue?: string;
100
+ /** Whether this column is a row header. */
101
+ isRowHeader?: boolean;
102
+ /** Whether this column allows sorting. */
103
+ allowsSorting?: boolean;
104
+ /** Child columns (for column groups). */
105
+ children?: ColumnDefinition<T>[];
106
+ /** Width of the column. */
107
+ width?: number | string;
108
+ /** Minimum width of the column. */
109
+ minWidth?: number;
110
+ /** Maximum width of the column. */
111
+ maxWidth?: number;
106
112
  }
107
113
  /**
108
114
  * Row definition for building table collections.
109
115
  */
110
116
  export interface RowDefinition<T = unknown> {
111
- /** The key for the row. */
112
- key: Key;
113
- /** The data value for the row. */
114
- value: T;
115
- /** Text value for accessibility/search. */
116
- textValue?: string;
117
- /** Whether this row has child rows (for tree tables). */
118
- hasChildRows?: boolean;
119
- /** Child rows (for tree tables). */
120
- childRows?: RowDefinition<T>[];
117
+ /** The key for the row. */
118
+ key: Key;
119
+ /** The data value for the row. */
120
+ value: T;
121
+ /** Text value for accessibility/search. */
122
+ textValue?: string;
123
+ /** Whether this row has child rows (for tree tables). */
124
+ hasChildRows?: boolean;
125
+ /** Child rows (for tree tables). */
126
+ childRows?: RowDefinition<T>[];
121
127
  }
122
128
  /**
123
129
  * Options for building a table collection.
124
130
  */
125
131
  export interface TableCollectionOptions<T = unknown> {
126
- /** Column definitions. */
127
- columns: ColumnDefinition<T>[];
128
- /** Row definitions or data items. */
129
- rows: RowDefinition<T>[] | T[];
130
- /** Function to get the key from a data item. */
131
- getKey?: (item: T) => Key;
132
- /** Function to get the text value from a data item. */
133
- getTextValue?: (item: T, column: ColumnDefinition<T>) => string;
134
- /** Whether to show selection checkboxes. */
135
- showSelectionCheckboxes?: boolean;
136
- /** Set of column keys that serve as row headers. */
137
- rowHeaderColumnKeys?: Set<Key>;
132
+ /** Column definitions. */
133
+ columns: ColumnDefinition<T>[];
134
+ /** Row definitions or data items. */
135
+ rows: RowDefinition<T>[] | T[];
136
+ /** Function to get the key from a data item. */
137
+ getKey?: (item: T) => Key;
138
+ /** Function to get the text value from a data item. */
139
+ getTextValue?: (item: T, column: ColumnDefinition<T>) => string;
140
+ /** Whether to show selection checkboxes. */
141
+ showSelectionCheckboxes?: boolean;
142
+ /** Set of column keys that serve as row headers. */
143
+ rowHeaderColumnKeys?: Set<Key>;
138
144
  }
139
- //# sourceMappingURL=types.d.ts.map
145
+ //# sourceMappingURL=types.d.ts.map
@@ -3,13 +3,13 @@
3
3
  * Based on @react-stately/table and @react-types/table.
4
4
  */
5
5
 
6
- import type { Key, FocusStrategy } from '../collections/types';
7
- import type { GridState, GridCollection, GridNode, GridNodeType } from '../grid/types';
6
+ import type { Key, FocusStrategy } from "../collections/types";
7
+ import type { GridState, GridCollection, GridNode, GridNodeType } from "../grid/types";
8
8
 
9
9
  /**
10
10
  * Sort direction for table columns.
11
11
  */
12
- export type SortDirection = 'ascending' | 'descending';
12
+ export type SortDirection = "ascending" | "descending";
13
13
 
14
14
  /**
15
15
  * Describes which column to sort by and in what direction.
@@ -52,8 +52,10 @@ export interface TableCollection<T = unknown> extends GridCollection<T> {
52
52
  * State for a table component.
53
53
  * Extends GridState with table-specific functionality.
54
54
  */
55
- export interface TableState<T, C extends TableCollection<T> = TableCollection<T>>
56
- extends Omit<GridState<T, GridCollection<T>>, 'collection'> {
55
+ export interface TableState<T, C extends TableCollection<T> = TableCollection<T>> extends Omit<
56
+ GridState<T, GridCollection<T>>,
57
+ "collection"
58
+ > {
57
59
  /** The table collection. */
58
60
  readonly collection: C;
59
61
  /** Whether the row selection checkboxes should be displayed. */
@@ -67,26 +69,28 @@ export interface TableState<T, C extends TableCollection<T> = TableCollection<T>
67
69
  /**
68
70
  * Options for creating table state.
69
71
  */
70
- export interface TableStateOptions<T, C extends TableCollection<T> = TableCollection<T>>
71
- extends Sortable {
72
+ export interface TableStateOptions<
73
+ T,
74
+ C extends TableCollection<T> = TableCollection<T>,
75
+ > extends Sortable {
72
76
  /** The table collection. */
73
77
  collection: C;
74
78
  /** Keys of disabled rows. */
75
79
  disabledKeys?: Iterable<Key>;
76
80
  /** Focus mode: 'row' or 'cell'. */
77
- focusMode?: 'row' | 'cell';
81
+ focusMode?: "row" | "cell";
78
82
  /** Selection mode. */
79
- selectionMode?: 'none' | 'single' | 'multiple';
83
+ selectionMode?: "none" | "single" | "multiple";
80
84
  /** Selection behavior. */
81
- selectionBehavior?: 'toggle' | 'replace';
85
+ selectionBehavior?: "toggle" | "replace";
82
86
  /** Whether empty selection is disallowed. */
83
87
  disallowEmptySelection?: boolean;
84
88
  /** Currently selected keys (controlled). */
85
- selectedKeys?: 'all' | Iterable<Key>;
89
+ selectedKeys?: "all" | Iterable<Key>;
86
90
  /** Default selected keys (uncontrolled). */
87
- defaultSelectedKeys?: 'all' | Iterable<Key>;
91
+ defaultSelectedKeys?: "all" | Iterable<Key>;
88
92
  /** Handler for selection changes. */
89
- onSelectionChange?: (keys: 'all' | Set<Key>) => void;
93
+ onSelectionChange?: (keys: "all" | Set<Key>) => void;
90
94
  /** Whether the row selection checkboxes should be displayed. */
91
95
  showSelectionCheckboxes?: boolean;
92
96
  }
@@ -2,67 +2,69 @@
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
- /** The items in the tab list. */
12
- items?: T[];
13
- /** Function to get a key from an item. */
14
- getKey?: (item: T) => Key;
15
- /** Function to get text value from an item. */
16
- getTextValue?: (item: T) => string;
17
- /** Function to check if an item is disabled. */
18
- getDisabled?: (item: T) => boolean;
19
- /** Keys of disabled tabs. */
20
- disabledKeys?: Iterable<Key>;
21
- /** The currently selected tab key (controlled). */
22
- selectedKey?: Key | null;
23
- /** The default selected tab key (uncontrolled). */
24
- defaultSelectedKey?: Key;
25
- /** Handler for tab selection changes. */
26
- onSelectionChange?: (key: Key) => void;
27
- /** Whether the entire tab list is disabled. */
28
- isDisabled?: boolean;
29
- /** Whether tabs are activated automatically on focus or manually. */
30
- keyboardActivation?: KeyboardActivation;
31
- /** The orientation of the tab list. */
32
- orientation?: TabOrientation;
11
+ /** The items in the tab list. */
12
+ items?: T[];
13
+ /** Function to get a key from an item. */
14
+ getKey?: (item: T) => Key;
15
+ /** Function to get text value from an item. */
16
+ getTextValue?: (item: T) => string;
17
+ /** Function to check if an item is disabled. */
18
+ getDisabled?: (item: T) => boolean;
19
+ /** Keys of disabled tabs. */
20
+ disabledKeys?: Iterable<Key>;
21
+ /** The currently selected tab key (controlled). */
22
+ selectedKey?: Key | null;
23
+ /** The default selected tab key (uncontrolled). */
24
+ defaultSelectedKey?: Key;
25
+ /** Handler for tab selection changes. */
26
+ onSelectionChange?: (key: Key) => void;
27
+ /** Whether the entire tab list is disabled. */
28
+ isDisabled?: boolean;
29
+ /** Whether tabs are activated automatically on focus or manually. */
30
+ keyboardActivation?: KeyboardActivation;
31
+ /** The orientation of the tab list. */
32
+ orientation?: TabOrientation;
33
33
  }
34
34
  export interface TabListState<T = unknown> {
35
- /** The collection of tabs. */
36
- readonly collection: Accessor<Collection<T>>;
37
- /** The currently selected tab key. */
38
- readonly selectedKey: Accessor<Key | null>;
39
- /** Set the selected tab key. */
40
- setSelectedKey(key: Key): void;
41
- /** The currently selected tab item. */
42
- readonly selectedItem: Accessor<CollectionNode<T> | null>;
43
- /** Whether the tab list is disabled. */
44
- readonly isDisabled: Accessor<boolean>;
45
- /** The keyboard activation mode. */
46
- readonly keyboardActivation: Accessor<KeyboardActivation>;
47
- /** The orientation of the tab list. */
48
- readonly orientation: Accessor<TabOrientation>;
49
- /** Whether a tab key is disabled. */
50
- isKeyDisabled(key: Key): boolean;
51
- /** The set of disabled keys. */
52
- readonly disabledKeys: Accessor<Set<Key>>;
53
- /** Whether the collection is focused. */
54
- readonly isFocused: Accessor<boolean>;
55
- /** Set the focused state. */
56
- setFocused(isFocused: boolean): void;
57
- /** The currently focused tab key. */
58
- readonly focusedKey: Accessor<Key | null>;
59
- /** Set the focused tab key. */
60
- setFocusedKey(key: Key | null, childStrategy?: FocusStrategy): void;
61
- /** The child focus strategy. */
62
- readonly childFocusStrategy: Accessor<FocusStrategy | null>;
35
+ /** The collection of tabs. */
36
+ readonly collection: Accessor<Collection<T>>;
37
+ /** The currently selected tab key. */
38
+ readonly selectedKey: Accessor<Key | null>;
39
+ /** Set the selected tab key. */
40
+ setSelectedKey(key: Key): void;
41
+ /** The currently selected tab item. */
42
+ readonly selectedItem: Accessor<CollectionNode<T> | null>;
43
+ /** Whether the tab list is disabled. */
44
+ readonly isDisabled: Accessor<boolean>;
45
+ /** The keyboard activation mode. */
46
+ readonly keyboardActivation: Accessor<KeyboardActivation>;
47
+ /** The orientation of the tab list. */
48
+ readonly orientation: Accessor<TabOrientation>;
49
+ /** Whether a tab key is disabled. */
50
+ isKeyDisabled(key: Key): boolean;
51
+ /** The set of disabled keys. */
52
+ readonly disabledKeys: Accessor<Set<Key>>;
53
+ /** Whether the collection is focused. */
54
+ readonly isFocused: Accessor<boolean>;
55
+ /** Set the focused state. */
56
+ setFocused(isFocused: boolean): void;
57
+ /** The currently focused tab key. */
58
+ readonly focusedKey: Accessor<Key | null>;
59
+ /** Set the focused tab key. */
60
+ setFocusedKey(key: Key | null, childStrategy?: FocusStrategy): void;
61
+ /** The child focus strategy. */
62
+ readonly childFocusStrategy: Accessor<FocusStrategy | null>;
63
63
  }
64
64
  /**
65
65
  * Creates state for a tab list component.
66
66
  */
67
- export declare function createTabListState<T = unknown>(props: MaybeAccessor<TabListStateProps<T>>): TabListState<T>;
68
- //# sourceMappingURL=createTabListState.d.ts.map
67
+ export declare function createTabListState<T = unknown>(
68
+ props: MaybeAccessor<TabListStateProps<T>>,
69
+ ): TabListState<T>;
70
+ //# sourceMappingURL=createTabListState.d.ts.map
@@ -3,19 +3,19 @@
3
3
  * Based on @react-stately/tabs.
4
4
  */
5
5
 
6
- import { createComputed, createMemo, createSignal, type Accessor } from 'solid-js';
7
- import { access, type MaybeAccessor } from '../utils';
8
- import { ListCollection } from '../collections/ListCollection';
6
+ import { createComputed, createMemo, createSignal, type Accessor } from "solid-js";
7
+ import { access, type MaybeAccessor } from "../utils";
8
+ import { ListCollection } from "../collections/ListCollection";
9
9
  import type {
10
10
  Collection,
11
11
  CollectionItemLike,
12
12
  CollectionNode,
13
13
  Key,
14
14
  FocusStrategy,
15
- } from '../collections/types';
15
+ } from "../collections/types";
16
16
 
17
- export type KeyboardActivation = 'automatic' | 'manual';
18
- export type TabOrientation = 'horizontal' | 'vertical';
17
+ export type KeyboardActivation = "automatic" | "manual";
18
+ export type TabOrientation = "horizontal" | "vertical";
19
19
 
20
20
  export interface TabListStateProps<T = unknown> {
21
21
  /** The items in the tab list. */
@@ -77,11 +77,10 @@ export interface TabListState<T = unknown> {
77
77
  * Creates state for a tab list component.
78
78
  */
79
79
  export function createTabListState<T = unknown>(
80
- props: MaybeAccessor<TabListStateProps<T>>
80
+ props: MaybeAccessor<TabListStateProps<T>>,
81
81
  ): TabListState<T> {
82
82
  const getProps = () => access(props);
83
83
 
84
- // Build collection from items
85
84
  const collection: Accessor<Collection<T>> = createMemo(() => {
86
85
  const p = getProps();
87
86
  const items = p.items ?? [];
@@ -89,12 +88,11 @@ export function createTabListState<T = unknown>(
89
88
  const nodes: CollectionNode<T>[] = items.map((item, index) => {
90
89
  const o = item as CollectionItemLike;
91
90
  const key = p.getKey?.(item) ?? o.key ?? o.id ?? index;
92
- const textValue =
93
- p.getTextValue?.(item) ?? o.textValue ?? o.label ?? String(item);
91
+ const textValue = p.getTextValue?.(item) ?? o.textValue ?? o.label ?? String(item);
94
92
  const isDisabled = p.getDisabled?.(item) ?? o.isDisabled ?? false;
95
93
 
96
94
  return {
97
- type: 'item' as const,
95
+ type: "item" as const,
98
96
  key,
99
97
  value: item,
100
98
  textValue,
@@ -126,7 +124,6 @@ export function createTabListState<T = unknown>(
126
124
  return result;
127
125
  });
128
126
 
129
- // Check if a key is disabled
130
127
  const isKeyDisabled = (key: Key): boolean => {
131
128
  const p = getProps();
132
129
  if (p.isDisabled) return true;
@@ -144,30 +141,24 @@ export function createTabListState<T = unknown>(
144
141
  return null;
145
142
  };
146
143
 
147
- // Get initial selected key
148
144
  const getInitialSelectedKey = (): Key | null => {
149
145
  const p = getProps();
150
146
 
151
- // If controlled, use that value
152
147
  if (p.selectedKey !== undefined) {
153
148
  return p.selectedKey;
154
149
  }
155
150
 
156
- // If default provided and not disabled, use it
157
151
  if (p.defaultSelectedKey !== undefined && !isKeyDisabled(p.defaultSelectedKey)) {
158
152
  return p.defaultSelectedKey;
159
153
  }
160
154
 
161
- // Otherwise, select first non-disabled
162
155
  return findFirstNonDisabledKey();
163
156
  };
164
157
 
165
- // Selection state
166
158
  const [selectedKeyInternal, setSelectedKeyInternal] = createSignal<Key | null>(
167
- getInitialSelectedKey()
159
+ getInitialSelectedKey(),
168
160
  );
169
161
 
170
- // Compute actual selected key (controlled vs uncontrolled)
171
162
  const selectedKey: Accessor<Key | null> = () => {
172
163
  const p = getProps();
173
164
  if (p.selectedKey !== undefined) {
@@ -177,39 +168,30 @@ export function createTabListState<T = unknown>(
177
168
  };
178
169
 
179
170
  const setSelectedKey = (key: Key) => {
180
- // Don't select disabled keys
181
171
  if (isKeyDisabled(key)) return;
182
172
  if (selectedKey() === key) return;
183
173
 
184
174
  const p = getProps();
185
- // For uncontrolled mode, update internal state
186
175
  if (p.selectedKey === undefined) {
187
176
  setSelectedKeyInternal(key);
188
177
  }
189
178
 
190
- // Always call onChange
191
179
  p.onSelectionChange?.(key);
192
180
  };
193
181
 
194
- // Get selected item
195
182
  const selectedItem: Accessor<CollectionNode<T> | null> = () => {
196
183
  const key = selectedKey();
197
184
  if (key === null) return null;
198
185
  return collection().getItem(key);
199
186
  };
200
187
 
201
- // Is disabled accessor
202
188
  const isDisabled: Accessor<boolean> = () => getProps().isDisabled ?? false;
203
189
 
204
- // Keyboard activation accessor
205
190
  const keyboardActivation: Accessor<KeyboardActivation> = () =>
206
- getProps().keyboardActivation ?? 'automatic';
191
+ getProps().keyboardActivation ?? "automatic";
207
192
 
208
- // Orientation accessor
209
- const orientation: Accessor<TabOrientation> = () =>
210
- getProps().orientation ?? 'horizontal';
193
+ const orientation: Accessor<TabOrientation> = () => getProps().orientation ?? "horizontal";
211
194
 
212
- // Focus state
213
195
  const [isFocused, setIsFocused] = createSignal(false);
214
196
  const [focusedKey, setFocusedKeyInternal] = createSignal<Key | null>(null);
215
197
  const [childFocusStrategy, setChildFocusStrategy] = createSignal<FocusStrategy | null>(null);
@@ -220,7 +202,7 @@ export function createTabListState<T = unknown>(
220
202
 
221
203
  // In automatic mode, selecting follows focus
222
204
  if (
223
- keyboardActivation() === 'automatic' &&
205
+ keyboardActivation() === "automatic" &&
224
206
  key !== null &&
225
207
  key !== selectedKey() &&
226
208
  !isKeyDisabled(key)
@@ -241,6 +223,17 @@ export function createTabListState<T = unknown>(
241
223
 
242
224
  if (currentExists && currentEnabled) return;
243
225
 
226
+ if (
227
+ p.defaultSelectedKey !== undefined &&
228
+ coll.getItem(p.defaultSelectedKey) !== null &&
229
+ !isKeyDisabled(p.defaultSelectedKey)
230
+ ) {
231
+ if (p.defaultSelectedKey !== current) {
232
+ setSelectedKeyInternal(p.defaultSelectedKey);
233
+ }
234
+ return;
235
+ }
236
+
244
237
  const nextKey = findFirstNonDisabledKey();
245
238
  if (nextKey !== current) {
246
239
  setSelectedKeyInternal(nextKey);
@@ -1,2 +1,8 @@
1
- export { createTabListState, type TabListStateProps, type TabListState, type KeyboardActivation, type TabOrientation, } from './createTabListState';
2
- //# sourceMappingURL=index.d.ts.map
1
+ export {
2
+ createTabListState,
3
+ type TabListStateProps,
4
+ type TabListState,
5
+ type KeyboardActivation,
6
+ type TabOrientation,
7
+ } from "./createTabListState";
8
+ //# sourceMappingURL=index.d.ts.map
package/src/tabs/index.ts CHANGED
@@ -4,4 +4,4 @@ export {
4
4
  type TabListState,
5
5
  type KeyboardActivation,
6
6
  type TabOrientation,
7
- } from './createTabListState';
7
+ } from "./createTabListState";