@proyecto-viviana/solid-stately 0.2.1 → 0.2.3

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 (216) hide show
  1. package/dist/index.js +43 -43
  2. package/dist/index.js.map +1 -1
  3. package/package.json +7 -5
  4. package/src/autocomplete/createAutocompleteState.d.ts +46 -0
  5. package/src/autocomplete/createAutocompleteState.d.ts.map +1 -0
  6. package/src/autocomplete/createAutocompleteState.ts +90 -0
  7. package/src/autocomplete/index.d.ts +2 -0
  8. package/src/autocomplete/index.d.ts.map +1 -0
  9. package/src/autocomplete/index.ts +5 -0
  10. package/src/calendar/createCalendarState.d.ts +130 -0
  11. package/src/calendar/createCalendarState.d.ts.map +1 -0
  12. package/src/calendar/createCalendarState.ts +461 -0
  13. package/src/calendar/createDateFieldState.d.ts +110 -0
  14. package/src/calendar/createDateFieldState.d.ts.map +1 -0
  15. package/src/calendar/createDateFieldState.ts +562 -0
  16. package/src/calendar/createRangeCalendarState.d.ts +146 -0
  17. package/src/calendar/createRangeCalendarState.d.ts.map +1 -0
  18. package/src/calendar/createRangeCalendarState.ts +535 -0
  19. package/src/calendar/createTimeFieldState.d.ts +95 -0
  20. package/src/calendar/createTimeFieldState.d.ts.map +1 -0
  21. package/src/calendar/createTimeFieldState.ts +483 -0
  22. package/src/calendar/index.d.ts +7 -0
  23. package/src/calendar/index.d.ts.map +1 -0
  24. package/src/calendar/index.ts +81 -0
  25. package/src/checkbox/createCheckboxGroupState.d.ts +71 -0
  26. package/src/checkbox/createCheckboxGroupState.d.ts.map +1 -0
  27. package/src/checkbox/createCheckboxGroupState.ts +193 -0
  28. package/src/checkbox/index.d.ts +2 -0
  29. package/src/checkbox/index.d.ts.map +1 -0
  30. package/src/checkbox/index.ts +5 -0
  31. package/src/collections/ListCollection.d.ts +37 -0
  32. package/src/collections/ListCollection.d.ts.map +1 -0
  33. package/src/collections/ListCollection.ts +146 -0
  34. package/src/collections/createListState.d.ts +79 -0
  35. package/src/collections/createListState.d.ts.map +1 -0
  36. package/src/collections/createListState.ts +264 -0
  37. package/src/collections/createMenuState.d.ts +50 -0
  38. package/src/collections/createMenuState.d.ts.map +1 -0
  39. package/src/collections/createMenuState.ts +106 -0
  40. package/src/collections/createSelectionState.d.ts +76 -0
  41. package/src/collections/createSelectionState.d.ts.map +1 -0
  42. package/src/collections/createSelectionState.ts +336 -0
  43. package/src/collections/index.d.ts +6 -0
  44. package/src/collections/index.d.ts.map +1 -0
  45. package/src/collections/index.ts +46 -0
  46. package/src/collections/types.d.ts +147 -0
  47. package/src/collections/types.d.ts.map +1 -0
  48. package/src/collections/types.ts +169 -0
  49. package/src/color/Color.d.ts +28 -0
  50. package/src/color/Color.d.ts.map +1 -0
  51. package/src/color/Color.ts +951 -0
  52. package/src/color/createColorAreaState.d.ts +76 -0
  53. package/src/color/createColorAreaState.d.ts.map +1 -0
  54. package/src/color/createColorAreaState.ts +293 -0
  55. package/src/color/createColorFieldState.d.ts +55 -0
  56. package/src/color/createColorFieldState.d.ts.map +1 -0
  57. package/src/color/createColorFieldState.ts +292 -0
  58. package/src/color/createColorSliderState.d.ts +67 -0
  59. package/src/color/createColorSliderState.d.ts.map +1 -0
  60. package/src/color/createColorSliderState.ts +241 -0
  61. package/src/color/createColorWheelState.d.ts +51 -0
  62. package/src/color/createColorWheelState.d.ts.map +1 -0
  63. package/src/color/createColorWheelState.ts +211 -0
  64. package/src/color/index.d.ts +10 -0
  65. package/src/color/index.d.ts.map +1 -0
  66. package/src/color/index.ts +47 -0
  67. package/src/color/types.d.ts +106 -0
  68. package/src/color/types.d.ts.map +1 -0
  69. package/src/color/types.ts +127 -0
  70. package/src/combobox/createComboBoxState.d.ts +125 -0
  71. package/src/combobox/createComboBoxState.d.ts.map +1 -0
  72. package/src/combobox/createComboBoxState.ts +703 -0
  73. package/src/combobox/index.d.ts +5 -0
  74. package/src/combobox/index.d.ts.map +1 -0
  75. package/src/combobox/index.ts +13 -0
  76. package/src/disclosure/createDisclosureState.d.ts +64 -0
  77. package/src/disclosure/createDisclosureState.d.ts.map +1 -0
  78. package/src/disclosure/createDisclosureState.ts +193 -0
  79. package/src/disclosure/index.d.ts +2 -0
  80. package/src/disclosure/index.d.ts.map +1 -0
  81. package/src/disclosure/index.ts +9 -0
  82. package/src/dnd/createDragState.d.ts +59 -0
  83. package/src/dnd/createDragState.d.ts.map +1 -0
  84. package/src/dnd/createDragState.ts +153 -0
  85. package/src/dnd/createDraggableCollectionState.d.ts +57 -0
  86. package/src/dnd/createDraggableCollectionState.d.ts.map +1 -0
  87. package/src/dnd/createDraggableCollectionState.ts +165 -0
  88. package/src/dnd/createDropState.d.ts +61 -0
  89. package/src/dnd/createDropState.d.ts.map +1 -0
  90. package/src/dnd/createDropState.ts +212 -0
  91. package/src/dnd/createDroppableCollectionState.d.ts +78 -0
  92. package/src/dnd/createDroppableCollectionState.d.ts.map +1 -0
  93. package/src/dnd/createDroppableCollectionState.ts +357 -0
  94. package/src/dnd/index.d.ts +11 -0
  95. package/src/dnd/index.d.ts.map +1 -0
  96. package/src/dnd/index.ts +76 -0
  97. package/src/dnd/types.d.ts +264 -0
  98. package/src/dnd/types.d.ts.map +1 -0
  99. package/src/dnd/types.ts +317 -0
  100. package/src/form/createFormValidationState.d.ts +100 -0
  101. package/src/form/createFormValidationState.d.ts.map +1 -0
  102. package/src/form/createFormValidationState.ts +389 -0
  103. package/src/form/index.d.ts +2 -0
  104. package/src/form/index.d.ts.map +1 -0
  105. package/src/form/index.ts +15 -0
  106. package/src/grid/createGridState.d.ts +12 -0
  107. package/src/grid/createGridState.d.ts.map +1 -0
  108. package/src/grid/createGridState.ts +327 -0
  109. package/src/grid/index.d.ts +7 -0
  110. package/src/grid/index.d.ts.map +1 -0
  111. package/src/grid/index.ts +13 -0
  112. package/src/grid/types.d.ts +156 -0
  113. package/src/grid/types.d.ts.map +1 -0
  114. package/src/grid/types.ts +179 -0
  115. package/src/index.d.ts +26 -0
  116. package/src/index.d.ts.map +1 -0
  117. package/src/index.ts +383 -0
  118. package/src/numberfield/createNumberFieldState.d.ts +65 -0
  119. package/src/numberfield/createNumberFieldState.d.ts.map +1 -0
  120. package/src/numberfield/createNumberFieldState.ts +383 -0
  121. package/src/numberfield/index.d.ts +2 -0
  122. package/src/numberfield/index.d.ts.map +1 -0
  123. package/src/numberfield/index.ts +5 -0
  124. package/src/overlays/createOverlayTriggerState.d.ts +32 -0
  125. package/src/overlays/createOverlayTriggerState.d.ts.map +1 -0
  126. package/src/overlays/createOverlayTriggerState.ts +67 -0
  127. package/src/overlays/index.d.ts +2 -0
  128. package/src/overlays/index.d.ts.map +1 -0
  129. package/src/overlays/index.ts +5 -0
  130. package/src/radio/createRadioGroupState.d.ts +77 -0
  131. package/src/radio/createRadioGroupState.d.ts.map +1 -0
  132. package/src/radio/createRadioGroupState.ts +201 -0
  133. package/src/radio/index.d.ts +2 -0
  134. package/src/radio/index.d.ts.map +1 -0
  135. package/src/radio/index.ts +6 -0
  136. package/src/searchfield/createSearchFieldState.d.ts +25 -0
  137. package/src/searchfield/createSearchFieldState.d.ts.map +1 -0
  138. package/src/searchfield/createSearchFieldState.ts +62 -0
  139. package/src/searchfield/index.d.ts +3 -0
  140. package/src/searchfield/index.d.ts.map +1 -0
  141. package/src/searchfield/index.ts +5 -0
  142. package/src/select/createSelectState.d.ts +73 -0
  143. package/src/select/createSelectState.d.ts.map +1 -0
  144. package/src/select/createSelectState.ts +181 -0
  145. package/src/select/index.d.ts +2 -0
  146. package/src/select/index.d.ts.map +1 -0
  147. package/src/select/index.ts +5 -0
  148. package/src/slider/createSliderState.d.ts +72 -0
  149. package/src/slider/createSliderState.d.ts.map +1 -0
  150. package/src/slider/createSliderState.ts +211 -0
  151. package/src/slider/index.d.ts +3 -0
  152. package/src/slider/index.d.ts.map +1 -0
  153. package/src/slider/index.ts +6 -0
  154. package/src/ssr/index.d.ts +28 -0
  155. package/src/ssr/index.d.ts.map +1 -0
  156. package/src/ssr/index.ts +41 -0
  157. package/src/table/TableCollection.d.ts +52 -0
  158. package/src/table/TableCollection.d.ts.map +1 -0
  159. package/src/table/TableCollection.ts +388 -0
  160. package/src/table/createTableState.d.ts +12 -0
  161. package/src/table/createTableState.d.ts.map +1 -0
  162. package/src/table/createTableState.ts +127 -0
  163. package/src/table/index.d.ts +8 -0
  164. package/src/table/index.d.ts.map +1 -0
  165. package/src/table/index.ts +18 -0
  166. package/src/table/types.d.ts +139 -0
  167. package/src/table/types.d.ts.map +1 -0
  168. package/src/table/types.ts +150 -0
  169. package/src/tabs/createTabListState.d.ts +68 -0
  170. package/src/tabs/createTabListState.d.ts.map +1 -0
  171. package/src/tabs/createTabListState.ts +240 -0
  172. package/src/tabs/index.d.ts +2 -0
  173. package/src/tabs/index.d.ts.map +1 -0
  174. package/src/tabs/index.ts +7 -0
  175. package/src/textfield/createTextFieldState.d.ts +30 -0
  176. package/src/textfield/createTextFieldState.d.ts.map +1 -0
  177. package/src/textfield/createTextFieldState.ts +75 -0
  178. package/src/textfield/index.d.ts +2 -0
  179. package/src/textfield/index.d.ts.map +1 -0
  180. package/src/textfield/index.ts +5 -0
  181. package/src/toast/createToastState.d.ts +118 -0
  182. package/src/toast/createToastState.d.ts.map +1 -0
  183. package/src/toast/createToastState.ts +316 -0
  184. package/src/toast/index.d.ts +2 -0
  185. package/src/toast/index.d.ts.map +1 -0
  186. package/src/toast/index.ts +11 -0
  187. package/src/toggle/createToggleState.d.ts +34 -0
  188. package/src/toggle/createToggleState.d.ts.map +1 -0
  189. package/src/toggle/createToggleState.ts +94 -0
  190. package/src/toggle/index.d.ts +2 -0
  191. package/src/toggle/index.d.ts.map +1 -0
  192. package/src/toggle/index.ts +5 -0
  193. package/src/tooltip/createTooltipTriggerState.d.ts +39 -0
  194. package/src/tooltip/createTooltipTriggerState.d.ts.map +1 -0
  195. package/src/tooltip/createTooltipTriggerState.ts +183 -0
  196. package/src/tooltip/index.d.ts +2 -0
  197. package/src/tooltip/index.d.ts.map +1 -0
  198. package/src/tooltip/index.ts +6 -0
  199. package/src/tree/TreeCollection.d.ts +40 -0
  200. package/src/tree/TreeCollection.d.ts.map +1 -0
  201. package/src/tree/TreeCollection.ts +175 -0
  202. package/src/tree/createTreeState.d.ts +14 -0
  203. package/src/tree/createTreeState.d.ts.map +1 -0
  204. package/src/tree/createTreeState.ts +392 -0
  205. package/src/tree/index.d.ts +7 -0
  206. package/src/tree/index.d.ts.map +1 -0
  207. package/src/tree/index.ts +13 -0
  208. package/src/tree/types.d.ts +157 -0
  209. package/src/tree/types.d.ts.map +1 -0
  210. package/src/tree/types.ts +174 -0
  211. package/src/utils/index.d.ts +2 -0
  212. package/src/utils/index.d.ts.map +1 -0
  213. package/src/utils/index.ts +1 -0
  214. package/src/utils/reactivity.d.ts +28 -0
  215. package/src/utils/reactivity.d.ts.map +1 -0
  216. package/src/utils/reactivity.ts +36 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAiB,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAgB,MAAM,eAAe,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,YAAY,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,MAAM,EAAE,GAAG,CAAC;IACZ,gCAAgC;IAChC,SAAS,EAAE,aAAa,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,0EAA0E;IAC1E,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;CACrD;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,cAAc,CAAC,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GAAG,CAAC;IACT,kCAAkC;IAClC,KAAK,EAAE,CAAC,CAAC;IACT,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oCAAoC;IACpC,SAAS,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC,GAAG,OAAO;IACjD,0BAA0B;IAC1B,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/B,qCAAqC;IACrC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IAC/B,gDAAgD;IAChD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC;IAC1B,uDAAuD;IACvD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;IAChE,4CAA4C;IAC5C,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,oDAAoD;IACpD,mBAAmB,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;CAChC"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Table state types for Table components.
3
+ * Based on @react-stately/table and @react-types/table.
4
+ */
5
+
6
+ import type { Key, FocusStrategy } from '../collections/types';
7
+ import type { GridState, GridCollection, GridNode, GridNodeType } from '../grid/types';
8
+
9
+ /**
10
+ * Sort direction for table columns.
11
+ */
12
+ export type SortDirection = 'ascending' | 'descending';
13
+
14
+ /**
15
+ * Describes which column to sort by and in what direction.
16
+ */
17
+ export interface SortDescriptor {
18
+ /** The key of the column to sort by. */
19
+ column: Key;
20
+ /** The direction to sort by. */
21
+ direction: SortDirection;
22
+ }
23
+
24
+ /**
25
+ * Interface for sortable components.
26
+ */
27
+ export interface Sortable {
28
+ /** The current sorted column and direction. */
29
+ sortDescriptor?: SortDescriptor;
30
+ /** Handler that is called when the sorted column or direction changes. */
31
+ onSortChange?: (descriptor: SortDescriptor) => void;
32
+ }
33
+
34
+ /**
35
+ * A collection of table rows and columns.
36
+ * Extends GridCollection with table-specific metadata.
37
+ */
38
+ export interface TableCollection<T = unknown> extends GridCollection<T> {
39
+ /** A list of header row nodes in the table. */
40
+ readonly headerRows: GridNode<T>[];
41
+ /** A list of column nodes in the table. */
42
+ readonly columns: GridNode<T>[];
43
+ /** A set of column keys that serve as the row header. */
44
+ readonly rowHeaderColumnKeys: Set<Key>;
45
+ /** The node that makes up the header of the table. */
46
+ readonly head?: GridNode<T>;
47
+ /** The node that makes up the body of the table. */
48
+ readonly body: GridNode<T>;
49
+ }
50
+
51
+ /**
52
+ * State for a table component.
53
+ * Extends GridState with table-specific functionality.
54
+ */
55
+ export interface TableState<T, C extends TableCollection<T> = TableCollection<T>>
56
+ extends Omit<GridState<T, GridCollection<T>>, 'collection'> {
57
+ /** The table collection. */
58
+ readonly collection: C;
59
+ /** Whether the row selection checkboxes should be displayed. */
60
+ readonly showSelectionCheckboxes: boolean;
61
+ /** The current sorted column and direction. */
62
+ readonly sortDescriptor: SortDescriptor | null;
63
+ /** Sort by the given column and direction. */
64
+ sort(columnKey: Key, direction?: SortDirection): void;
65
+ }
66
+
67
+ /**
68
+ * Options for creating table state.
69
+ */
70
+ export interface TableStateOptions<T, C extends TableCollection<T> = TableCollection<T>>
71
+ extends Sortable {
72
+ /** The table collection. */
73
+ collection: C;
74
+ /** Keys of disabled rows. */
75
+ disabledKeys?: Iterable<Key>;
76
+ /** Focus mode: 'row' or 'cell'. */
77
+ focusMode?: 'row' | 'cell';
78
+ /** Selection mode. */
79
+ selectionMode?: 'none' | 'single' | 'multiple';
80
+ /** Selection behavior. */
81
+ selectionBehavior?: 'toggle' | 'replace';
82
+ /** Whether empty selection is disallowed. */
83
+ disallowEmptySelection?: boolean;
84
+ /** Currently selected keys (controlled). */
85
+ selectedKeys?: 'all' | Iterable<Key>;
86
+ /** Default selected keys (uncontrolled). */
87
+ defaultSelectedKeys?: 'all' | Iterable<Key>;
88
+ /** Handler for selection changes. */
89
+ onSelectionChange?: (keys: 'all' | Set<Key>) => void;
90
+ /** Whether the row selection checkboxes should be displayed. */
91
+ showSelectionCheckboxes?: boolean;
92
+ }
93
+
94
+ /**
95
+ * Column definition for building table collections.
96
+ */
97
+ export interface ColumnDefinition<T = unknown> {
98
+ /** The key for the column. */
99
+ key: Key;
100
+ /** The display name or rendered content. */
101
+ name?: string;
102
+ /** Text value for accessibility. */
103
+ textValue?: string;
104
+ /** Whether this column is a row header. */
105
+ isRowHeader?: boolean;
106
+ /** Whether this column allows sorting. */
107
+ allowsSorting?: boolean;
108
+ /** Child columns (for column groups). */
109
+ children?: ColumnDefinition<T>[];
110
+ /** Width of the column. */
111
+ width?: number | string;
112
+ /** Minimum width of the column. */
113
+ minWidth?: number;
114
+ /** Maximum width of the column. */
115
+ maxWidth?: number;
116
+ }
117
+
118
+ /**
119
+ * Row definition for building table collections.
120
+ */
121
+ export interface RowDefinition<T = unknown> {
122
+ /** The key for the row. */
123
+ key: Key;
124
+ /** The data value for the row. */
125
+ value: T;
126
+ /** Text value for accessibility/search. */
127
+ textValue?: string;
128
+ /** Whether this row has child rows (for tree tables). */
129
+ hasChildRows?: boolean;
130
+ /** Child rows (for tree tables). */
131
+ childRows?: RowDefinition<T>[];
132
+ }
133
+
134
+ /**
135
+ * Options for building a table collection.
136
+ */
137
+ export interface TableCollectionOptions<T = unknown> {
138
+ /** Column definitions. */
139
+ columns: ColumnDefinition<T>[];
140
+ /** Row definitions or data items. */
141
+ rows: RowDefinition<T>[] | T[];
142
+ /** Function to get the key from a data item. */
143
+ getKey?: (item: T) => Key;
144
+ /** Function to get the text value from a data item. */
145
+ getTextValue?: (item: T, column: ColumnDefinition<T>) => string;
146
+ /** Whether to show selection checkboxes. */
147
+ showSelectionCheckboxes?: boolean;
148
+ /** Set of column keys that serve as row headers. */
149
+ rowHeaderColumnKeys?: Set<Key>;
150
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * State management for tab components.
3
+ * Based on @react-stately/tabs.
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';
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;
33
+ }
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>;
63
+ }
64
+ /**
65
+ * Creates state for a tab list component.
66
+ */
67
+ export declare function createTabListState<T = unknown>(props: MaybeAccessor<TabListStateProps<T>>): TabListState<T>;
68
+ //# sourceMappingURL=createTabListState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTabListState.d.ts","sourceRoot":"","sources":["createTabListState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,GAAG,EACH,aAAa,EACd,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,QAAQ,CAAC;AACxD,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,UAAU,CAAC;AAEvD,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO;IAC5C,iCAAiC;IACjC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;IACZ,0CAA0C;IAC1C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC;IAC1B,+CAA+C;IAC/C,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IACnC,gDAAgD;IAChD,WAA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QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1C,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtC,6BAA6B;IAC7B,UAAU,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IACrC,qCAAqC;IACrC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;IAC1C,+BAA+B;IAC/B,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,EAAE,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACpE,gCAAgC;IAChC,QAAQ,CAAC,kBAAkB,EAAE,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;CAC7D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,OAAO,EAC5C,KAAK,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,GACzC,YAAY,CAAC,CAAC,CAAC,CAgKjB"}
@@ -0,0 +1,240 @@
1
+ /**
2
+ * State management for tab components.
3
+ * Based on @react-stately/tabs.
4
+ */
5
+
6
+ import { createSignal, type Accessor } from 'solid-js';
7
+ import { access, type MaybeAccessor } from '../utils';
8
+ import { ListCollection } from '../collections/ListCollection';
9
+ import type {
10
+ Collection,
11
+ CollectionNode,
12
+ Key,
13
+ FocusStrategy,
14
+ } from '../collections/types';
15
+
16
+ export type KeyboardActivation = 'automatic' | 'manual';
17
+ export type TabOrientation = 'horizontal' | 'vertical';
18
+
19
+ export interface TabListStateProps<T = unknown> {
20
+ /** The items in the tab list. */
21
+ items?: T[];
22
+ /** Function to get a key from an item. */
23
+ getKey?: (item: T) => Key;
24
+ /** Function to get text value from an item. */
25
+ getTextValue?: (item: T) => string;
26
+ /** Function to check if an item is disabled. */
27
+ getDisabled?: (item: T) => boolean;
28
+ /** Keys of disabled tabs. */
29
+ disabledKeys?: Iterable<Key>;
30
+ /** The currently selected tab key (controlled). */
31
+ selectedKey?: Key | null;
32
+ /** The default selected tab key (uncontrolled). */
33
+ defaultSelectedKey?: Key;
34
+ /** Handler for tab selection changes. */
35
+ onSelectionChange?: (key: Key) => void;
36
+ /** Whether the entire tab list is disabled. */
37
+ isDisabled?: boolean;
38
+ /** Whether tabs are activated automatically on focus or manually. */
39
+ keyboardActivation?: KeyboardActivation;
40
+ /** The orientation of the tab list. */
41
+ orientation?: TabOrientation;
42
+ }
43
+
44
+ export interface TabListState<T = unknown> {
45
+ /** The collection of tabs. */
46
+ readonly collection: Accessor<Collection<T>>;
47
+ /** The currently selected tab key. */
48
+ readonly selectedKey: Accessor<Key | null>;
49
+ /** Set the selected tab key. */
50
+ setSelectedKey(key: Key): void;
51
+ /** The currently selected tab item. */
52
+ readonly selectedItem: Accessor<CollectionNode<T> | null>;
53
+ /** Whether the tab list is disabled. */
54
+ readonly isDisabled: Accessor<boolean>;
55
+ /** The keyboard activation mode. */
56
+ readonly keyboardActivation: Accessor<KeyboardActivation>;
57
+ /** The orientation of the tab list. */
58
+ readonly orientation: Accessor<TabOrientation>;
59
+ /** Whether a tab key is disabled. */
60
+ isKeyDisabled(key: Key): boolean;
61
+ /** The set of disabled keys. */
62
+ readonly disabledKeys: Accessor<Set<Key>>;
63
+ /** Whether the collection is focused. */
64
+ readonly isFocused: Accessor<boolean>;
65
+ /** Set the focused state. */
66
+ setFocused(isFocused: boolean): void;
67
+ /** The currently focused tab key. */
68
+ readonly focusedKey: Accessor<Key | null>;
69
+ /** Set the focused tab key. */
70
+ setFocusedKey(key: Key | null, childStrategy?: FocusStrategy): void;
71
+ /** The child focus strategy. */
72
+ readonly childFocusStrategy: Accessor<FocusStrategy | null>;
73
+ }
74
+
75
+ /**
76
+ * Creates state for a tab list component.
77
+ */
78
+ export function createTabListState<T = unknown>(
79
+ props: MaybeAccessor<TabListStateProps<T>>
80
+ ): TabListState<T> {
81
+ const getProps = () => access(props);
82
+
83
+ // Build collection from items
84
+ const collection: Accessor<Collection<T>> = () => {
85
+ const p = getProps();
86
+ const items = p.items ?? [];
87
+
88
+ const nodes: CollectionNode<T>[] = items.map((item, index) => {
89
+ const key = p.getKey?.(item) ?? (item as any).key ?? (item as any).id ?? index;
90
+ const textValue =
91
+ p.getTextValue?.(item) ?? (item as any).textValue ?? (item as any).label ?? String(item);
92
+ const isDisabled = p.getDisabled?.(item) ?? (item as any).isDisabled ?? false;
93
+
94
+ return {
95
+ type: 'item' as const,
96
+ key,
97
+ value: item,
98
+ textValue,
99
+ rendered: null as any,
100
+ level: 0,
101
+ index,
102
+ parentKey: null,
103
+ hasChildNodes: false,
104
+ childNodes: [],
105
+ isDisabled,
106
+ };
107
+ });
108
+
109
+ return new ListCollection(nodes);
110
+ };
111
+
112
+ // Compute disabled keys
113
+ const disabledKeys: Accessor<Set<Key>> = () => {
114
+ const p = getProps();
115
+ const result = new Set<Key>(p.disabledKeys ?? []);
116
+
117
+ const coll = collection();
118
+ for (const node of coll) {
119
+ if (node.isDisabled) {
120
+ result.add(node.key);
121
+ }
122
+ }
123
+
124
+ return result;
125
+ };
126
+
127
+ // Check if a key is disabled
128
+ const isKeyDisabled = (key: Key): boolean => {
129
+ const p = getProps();
130
+ if (p.isDisabled) return true;
131
+ return disabledKeys().has(key);
132
+ };
133
+
134
+ // Find the first non-disabled key
135
+ const findFirstNonDisabledKey = (): Key | null => {
136
+ const coll = collection();
137
+ for (const node of coll) {
138
+ if (!isKeyDisabled(node.key)) {
139
+ return node.key;
140
+ }
141
+ }
142
+ return null;
143
+ };
144
+
145
+ // Get initial selected key
146
+ const getInitialSelectedKey = (): Key | null => {
147
+ const p = getProps();
148
+
149
+ // If controlled, use that value
150
+ if (p.selectedKey !== undefined) {
151
+ return p.selectedKey;
152
+ }
153
+
154
+ // If default provided and not disabled, use it
155
+ if (p.defaultSelectedKey !== undefined && !isKeyDisabled(p.defaultSelectedKey)) {
156
+ return p.defaultSelectedKey;
157
+ }
158
+
159
+ // Otherwise, select first non-disabled
160
+ return findFirstNonDisabledKey();
161
+ };
162
+
163
+ // Selection state
164
+ const [selectedKeyInternal, setSelectedKeyInternal] = createSignal<Key | null>(
165
+ getInitialSelectedKey()
166
+ );
167
+
168
+ // Compute actual selected key (controlled vs uncontrolled)
169
+ const selectedKey: Accessor<Key | null> = () => {
170
+ const p = getProps();
171
+ if (p.selectedKey !== undefined) {
172
+ return p.selectedKey;
173
+ }
174
+ return selectedKeyInternal();
175
+ };
176
+
177
+ const setSelectedKey = (key: Key) => {
178
+ // Don't select disabled keys
179
+ if (isKeyDisabled(key)) return;
180
+
181
+ const p = getProps();
182
+ // For uncontrolled mode, update internal state
183
+ if (p.selectedKey === undefined) {
184
+ setSelectedKeyInternal(key);
185
+ }
186
+
187
+ // Always call onChange
188
+ p.onSelectionChange?.(key);
189
+ };
190
+
191
+ // Get selected item
192
+ const selectedItem: Accessor<CollectionNode<T> | null> = () => {
193
+ const key = selectedKey();
194
+ if (key === null) return null;
195
+ return collection().getItem(key);
196
+ };
197
+
198
+ // Is disabled accessor
199
+ const isDisabled: Accessor<boolean> = () => getProps().isDisabled ?? false;
200
+
201
+ // Keyboard activation accessor
202
+ const keyboardActivation: Accessor<KeyboardActivation> = () =>
203
+ getProps().keyboardActivation ?? 'automatic';
204
+
205
+ // Orientation accessor
206
+ const orientation: Accessor<TabOrientation> = () =>
207
+ getProps().orientation ?? 'horizontal';
208
+
209
+ // Focus state
210
+ const [isFocused, setIsFocused] = createSignal(false);
211
+ const [focusedKey, setFocusedKeyInternal] = createSignal<Key | null>(null);
212
+ const [childFocusStrategy, setChildFocusStrategy] = createSignal<FocusStrategy | null>(null);
213
+
214
+ const setFocusedKey = (key: Key | null, childStrategy?: FocusStrategy) => {
215
+ setFocusedKeyInternal(key);
216
+ setChildFocusStrategy(childStrategy ?? null);
217
+
218
+ // In automatic mode, selecting follows focus
219
+ if (keyboardActivation() === 'automatic' && key !== null && !isKeyDisabled(key)) {
220
+ setSelectedKey(key);
221
+ }
222
+ };
223
+
224
+ return {
225
+ collection,
226
+ selectedKey,
227
+ setSelectedKey,
228
+ selectedItem,
229
+ isDisabled,
230
+ keyboardActivation,
231
+ orientation,
232
+ isKeyDisabled,
233
+ disabledKeys,
234
+ isFocused,
235
+ setFocused: setIsFocused,
236
+ focusedKey,
237
+ setFocusedKey,
238
+ childFocusStrategy,
239
+ };
240
+ }
@@ -0,0 +1,2 @@
1
+ export { createTabListState, type TabListStateProps, type TabListState, type KeyboardActivation, type TabOrientation, } from './createTabListState';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,cAAc,GACpB,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export {
2
+ createTabListState,
3
+ type TabListStateProps,
4
+ type TabListState,
5
+ type KeyboardActivation,
6
+ type TabOrientation,
7
+ } from './createTabListState';
@@ -0,0 +1,30 @@
1
+ /**
2
+ * TextField state for Solid Stately
3
+ *
4
+ * Provides state management for text input components.
5
+ *
6
+ * This is a port of @react-stately/utils's useControlledState pattern
7
+ * as used by @react-aria/textfield.
8
+ */
9
+ import { Accessor } from 'solid-js';
10
+ import { type MaybeAccessor } from '../utils';
11
+ export interface TextFieldStateOptions {
12
+ /** The current value (controlled). */
13
+ value?: string;
14
+ /** The default value (uncontrolled). */
15
+ defaultValue?: string;
16
+ /** Handler that is called when the value changes. */
17
+ onChange?: (value: string) => void;
18
+ }
19
+ export interface TextFieldState {
20
+ /** The current value of the text field. */
21
+ readonly value: Accessor<string>;
22
+ /** Sets the value of the text field. */
23
+ setValue(value: string): void;
24
+ }
25
+ /**
26
+ * Provides state management for text input components.
27
+ * Supports both controlled and uncontrolled modes.
28
+ */
29
+ export declare function createTextFieldState(props?: MaybeAccessor<TextFieldStateOptions>): TextFieldState;
30
+ //# sourceMappingURL=createTextFieldState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTextFieldState.d.ts","sourceRoot":"","sources":["createTextFieldState.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAgB,QAAQ,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,KAAK,aAAa,EAAU,MAAM,UAAU,CAAC;AAMtD,MAAM,WAAW,qBAAqB;IACpC,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,wCAAwC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAMD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,GAAE,aAAa,CAAC,qBAAqB,CAAM,GAAG,cAAc,CAkCrG"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * TextField state for Solid Stately
3
+ *
4
+ * Provides state management for text input components.
5
+ *
6
+ * This is a port of @react-stately/utils's useControlledState pattern
7
+ * as used by @react-aria/textfield.
8
+ */
9
+
10
+ import { createSignal, Accessor } from 'solid-js';
11
+ import { type MaybeAccessor, access } from '../utils';
12
+
13
+ // ============================================
14
+ // TYPES
15
+ // ============================================
16
+
17
+ export interface TextFieldStateOptions {
18
+ /** The current value (controlled). */
19
+ value?: string;
20
+ /** The default value (uncontrolled). */
21
+ defaultValue?: string;
22
+ /** Handler that is called when the value changes. */
23
+ onChange?: (value: string) => void;
24
+ }
25
+
26
+ export interface TextFieldState {
27
+ /** The current value of the text field. */
28
+ readonly value: Accessor<string>;
29
+ /** Sets the value of the text field. */
30
+ setValue(value: string): void;
31
+ }
32
+
33
+ // ============================================
34
+ // IMPLEMENTATION
35
+ // ============================================
36
+
37
+ /**
38
+ * Provides state management for text input components.
39
+ * Supports both controlled and uncontrolled modes.
40
+ */
41
+ export function createTextFieldState(props: MaybeAccessor<TextFieldStateOptions> = {}): TextFieldState {
42
+ const getProps = () => access(props);
43
+
44
+ // Get initial value
45
+ const initialProps = getProps();
46
+ const initialValue = initialProps.value ?? initialProps.defaultValue ?? '';
47
+
48
+ // Create internal signal for uncontrolled mode
49
+ const [internalValue, setInternalValue] = createSignal(initialValue);
50
+
51
+ // Determine if controlled
52
+ const isControlled = () => getProps().value !== undefined;
53
+
54
+ // Get current value
55
+ const value: Accessor<string> = () => {
56
+ const p = getProps();
57
+ return isControlled() ? (p.value ?? '') : internalValue();
58
+ };
59
+
60
+ // Update value
61
+ function setValue(newValue: string): void {
62
+ const p = getProps();
63
+
64
+ if (!isControlled()) {
65
+ setInternalValue(newValue);
66
+ }
67
+
68
+ p.onChange?.(newValue);
69
+ }
70
+
71
+ return {
72
+ value,
73
+ setValue,
74
+ };
75
+ }
@@ -0,0 +1,2 @@
1
+ export { createTextFieldState, type TextFieldStateOptions, type TextFieldState, } from './createTextFieldState';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export {
2
+ createTextFieldState,
3
+ type TextFieldStateOptions,
4
+ type TextFieldState,
5
+ } from './createTextFieldState';