@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
@@ -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);
@@ -217,17 +199,19 @@ export function createTabListState<T = unknown>(
217
199
  const setFocusedKey = (key: Key | null, childStrategy?: FocusStrategy) => {
218
200
  setFocusedKeyInternal(key);
219
201
  setChildFocusStrategy(childStrategy ?? null);
202
+ };
220
203
 
221
- // In automatic mode, selecting follows focus
222
- if (
223
- keyboardActivation() === 'automatic' &&
224
- key !== null &&
225
- key !== selectedKey() &&
226
- !isKeyDisabled(key)
227
- ) {
228
- setSelectedKey(key);
204
+ // If the tab list doesn't have focus and the selected key changes, or if there
205
+ // isn't a focused key yet, move the focused key to the selected key so the
206
+ // roving tabIndex stays on the selected tab (mirrors useTabListState's effect).
207
+ let lastSelectedKey: Key | null = selectedKey();
208
+ createComputed(() => {
209
+ const sel = selectedKey();
210
+ if ((sel !== null && focusedKey() === null) || (!isFocused() && sel !== lastSelectedKey)) {
211
+ setFocusedKey(sel);
229
212
  }
230
- };
213
+ lastSelectedKey = sel;
214
+ });
231
215
 
232
216
  // Keep uncontrolled selection valid as items/disabled keys change.
233
217
  createComputed(() => {
@@ -241,6 +225,17 @@ export function createTabListState<T = unknown>(
241
225
 
242
226
  if (currentExists && currentEnabled) return;
243
227
 
228
+ if (
229
+ p.defaultSelectedKey !== undefined &&
230
+ coll.getItem(p.defaultSelectedKey) !== null &&
231
+ !isKeyDisabled(p.defaultSelectedKey)
232
+ ) {
233
+ if (p.defaultSelectedKey !== current) {
234
+ setSelectedKeyInternal(p.defaultSelectedKey);
235
+ }
236
+ return;
237
+ }
238
+
244
239
  const nextKey = findFirstNonDisabledKey();
245
240
  if (nextKey !== current) {
246
241
  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";
@@ -6,25 +6,27 @@
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
- /** 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;
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
18
  }
19
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;
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
24
  }
25
25
  /**
26
26
  * Provides state management for text input components.
27
27
  * Supports both controlled and uncontrolled modes.
28
28
  */
29
- export declare function createTextFieldState(props?: MaybeAccessor<TextFieldStateOptions>): TextFieldState;
30
- //# sourceMappingURL=createTextFieldState.d.ts.map
29
+ export declare function createTextFieldState(
30
+ props?: MaybeAccessor<TextFieldStateOptions>,
31
+ ): TextFieldState;
32
+ //# sourceMappingURL=createTextFieldState.d.ts.map
@@ -7,12 +7,8 @@
7
7
  * as used by @react-aria/textfield.
8
8
  */
9
9
 
10
- import { createSignal, Accessor } from 'solid-js';
11
- import { type MaybeAccessor, access } from '../utils';
12
-
13
- // ============================================
14
- // TYPES
15
- // ============================================
10
+ import { createSignal, Accessor } from "solid-js";
11
+ import { type MaybeAccessor, access } from "../utils";
16
12
 
17
13
  export interface TextFieldStateOptions {
18
14
  /** The current value (controlled). */
@@ -30,34 +26,27 @@ export interface TextFieldState {
30
26
  setValue(value: string): void;
31
27
  }
32
28
 
33
- // ============================================
34
- // IMPLEMENTATION
35
- // ============================================
36
-
37
29
  /**
38
30
  * Provides state management for text input components.
39
31
  * Supports both controlled and uncontrolled modes.
40
32
  */
41
- export function createTextFieldState(props: MaybeAccessor<TextFieldStateOptions> = {}): TextFieldState {
33
+ export function createTextFieldState(
34
+ props: MaybeAccessor<TextFieldStateOptions> = {},
35
+ ): TextFieldState {
42
36
  const getProps = () => access(props);
43
37
 
44
- // Get initial value
45
38
  const initialProps = getProps();
46
- const initialValue = initialProps.value ?? initialProps.defaultValue ?? '';
39
+ const initialValue = initialProps.value ?? initialProps.defaultValue ?? "";
47
40
 
48
- // Create internal signal for uncontrolled mode
49
41
  const [internalValue, setInternalValue] = createSignal(initialValue);
50
42
 
51
- // Determine if controlled
52
43
  const isControlled = () => getProps().value !== undefined;
53
44
 
54
- // Get current value
55
45
  const value: Accessor<string> = () => {
56
46
  const p = getProps();
57
- return isControlled() ? (p.value ?? '') : internalValue();
47
+ return isControlled() ? (p.value ?? "") : internalValue();
58
48
  };
59
49
 
60
- // Update value
61
50
  function setValue(newValue: string): void {
62
51
  const p = getProps();
63
52
 
@@ -1,2 +1,6 @@
1
- export { createTextFieldState, type TextFieldStateOptions, type TextFieldState, } from './createTextFieldState';
2
- //# sourceMappingURL=index.d.ts.map
1
+ export {
2
+ createTextFieldState,
3
+ type TextFieldStateOptions,
4
+ type TextFieldState,
5
+ } from "./createTextFieldState";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -2,4 +2,4 @@ export {
2
2
  createTextFieldState,
3
3
  type TextFieldStateOptions,
4
4
  type TextFieldState,
5
- } from './createTextFieldState';
5
+ } from "./createTextFieldState";
@@ -2,71 +2,73 @@
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
- /** A timeout to automatically close the toast, in milliseconds. */
8
- timeout?: number;
9
- /** The priority of the toast relative to other toasts. */
10
- priority?: number;
11
- /** Handler called when the toast is closed. */
12
- onClose?: () => void;
7
+ /** A timeout to automatically close the toast, in milliseconds. */
8
+ timeout?: number;
9
+ /** The priority of the toast relative to other toasts. */
10
+ priority?: number;
11
+ /** Handler called when the toast is closed. */
12
+ onClose?: () => void;
13
13
  }
14
14
  export interface QueuedToast<T> {
15
- /** The content of the toast. */
16
- content: T;
17
- /** A unique key for the toast. */
18
- key: string;
19
- /** The timer for the toast. */
20
- timer: Timer | null;
21
- /** Whether the toast should be animated. */
22
- animation?: 'entering' | 'exiting' | 'queued';
23
- /** The priority of the toast. */
24
- priority: number;
25
- /** Handler called when the toast is closed. */
26
- onClose?: () => void;
27
- /** The timeout for the toast. */
28
- timeout?: number;
15
+ /** The content of the toast. */
16
+ content: T;
17
+ /** A unique key for the toast. */
18
+ key: string;
19
+ /** The timer for the toast. */
20
+ timer: Timer | null;
21
+ /** Whether the toast should be animated. */
22
+ animation?: "entering" | "exiting" | "queued";
23
+ /** The priority of the toast. */
24
+ priority: number;
25
+ /** Handler called when the toast is closed. */
26
+ onClose?: () => void;
27
+ /** The timeout for the toast. */
28
+ timeout?: number;
29
29
  }
30
30
  export interface ToastQueueOptions {
31
- /** The maximum number of toasts to display at once. */
32
- maxVisibleToasts?: number;
33
- /** Whether toasts should stack (true) or queue (false). */
34
- hasExitAnimation?: boolean;
31
+ /** The maximum number of toasts to display at once. */
32
+ maxVisibleToasts?: number;
33
+ /** Whether toasts should stack (true) or queue (false). */
34
+ hasExitAnimation?: boolean;
35
35
  }
36
36
  export interface ToastStateProps<T> {
37
- /** The toast queue to use. */
38
- queue: ToastQueue<T>;
37
+ /** The toast queue to use. */
38
+ queue: ToastQueue<T>;
39
39
  }
40
40
  export interface ToastState<T> {
41
- /** The currently visible toasts. */
42
- visibleToasts: Accessor<QueuedToast<T>[]>;
43
- /** Adds a toast to the queue. */
44
- add: (content: T, options?: ToastOptions) => string;
45
- /** Closes a toast by key. Starts exit animation if hasExitAnimation is enabled. */
46
- close: (key: string) => void;
47
- /**
48
- * Removes a toast after exit animation completes.
49
- * Call this from the component layer when the CSS exit animation finishes.
50
- */
51
- remove: (key: string) => void;
52
- /** Pauses all toast timers. */
53
- pauseAll: () => void;
54
- /** Resumes all toast timers. */
55
- resumeAll: () => void;
41
+ /** The currently visible toasts. */
42
+ visibleToasts: Accessor<QueuedToast<T>[]>;
43
+ /** Adds a toast to the queue. */
44
+ add: (content: T, options?: ToastOptions) => string;
45
+ /** Closes a toast by key. Starts exit animation if hasExitAnimation is enabled. */
46
+ close: (key: string) => void;
47
+ /**
48
+ * Removes a toast after exit animation completes.
49
+ * Call this from the component layer when the CSS exit animation finishes.
50
+ */
51
+ remove: (key: string) => void;
52
+ /** Clears all queued and visible toasts. */
53
+ clear: () => void;
54
+ /** Pauses all toast timers. */
55
+ pauseAll: () => void;
56
+ /** Resumes all toast timers. */
57
+ resumeAll: () => void;
56
58
  }
57
59
  /**
58
60
  * A Timer that supports pause and resume.
59
61
  */
60
62
  export declare class Timer {
61
- private timerId;
62
- private startTime;
63
- private remaining;
64
- private callback;
65
- constructor(callback: () => void, delay: number);
66
- pause(): void;
67
- resume(): void;
68
- reset(delay: number): void;
69
- cancel(): void;
63
+ private timerId;
64
+ private startTime;
65
+ private remaining;
66
+ private callback;
67
+ constructor(callback: () => void, delay: number);
68
+ pause(): void;
69
+ resume(): void;
70
+ reset(delay: number): void;
71
+ cancel(): void;
70
72
  }
71
73
  type SubscribeCallback<T> = (toasts: QueuedToast<T>[]) => void;
72
74
  /**
@@ -74,38 +76,42 @@ type SubscribeCallback<T> = (toasts: QueuedToast<T>[]) => void;
74
76
  * Can be created once and shared across the app (singleton pattern).
75
77
  */
76
78
  export declare class ToastQueue<T> {
77
- private queue;
78
- private subscriptions;
79
- private maxVisibleToasts;
80
- private hasExitAnimation;
81
- private keyCounter;
82
- constructor(options?: ToastQueueOptions);
83
- /**
84
- * Subscribe to queue changes.
85
- */
86
- subscribe(callback: SubscribeCallback<T>): () => void;
87
- /**
88
- * Add a toast to the queue.
89
- */
90
- add(content: T, options?: ToastOptions): string;
91
- /**
92
- * Close a toast by key.
93
- */
94
- close(key: string): void;
95
- /**
96
- * Remove a toast after exit animation completes.
97
- */
98
- remove(key: string): void;
99
- /**
100
- * Pause all toast timers.
101
- */
102
- pauseAll(): void;
103
- /**
104
- * Resume all toast timers.
105
- */
106
- resumeAll(): void;
107
- private updateVisibility;
108
- private notify;
79
+ private queue;
80
+ private subscriptions;
81
+ private maxVisibleToasts;
82
+ private hasExitAnimation;
83
+ private keyCounter;
84
+ constructor(options?: ToastQueueOptions);
85
+ /**
86
+ * Subscribe to queue changes.
87
+ */
88
+ subscribe(callback: SubscribeCallback<T>): () => void;
89
+ /**
90
+ * Add a toast to the queue.
91
+ */
92
+ add(content: T, options?: ToastOptions): string;
93
+ /**
94
+ * Close a toast by key.
95
+ */
96
+ close(key: string): void;
97
+ /**
98
+ * Remove a toast after exit animation completes.
99
+ */
100
+ remove(key: string): void;
101
+ /**
102
+ * Clear all queued and visible toasts.
103
+ */
104
+ clear(): void;
105
+ /**
106
+ * Pause all toast timers.
107
+ */
108
+ pauseAll(): void;
109
+ /**
110
+ * Resume all toast timers.
111
+ */
112
+ resumeAll(): void;
113
+ private updateVisibility;
114
+ private notify;
109
115
  }
110
116
  /**
111
117
  * Creates reactive toast state from a ToastQueue.
@@ -117,7 +123,7 @@ export declare function createToastState<T>(props: ToastStateProps<T>): ToastSta
117
123
  * Use this if you don't need a global queue.
118
124
  */
119
125
  export declare function createToastQueue<T>(options?: ToastQueueOptions): ToastState<T> & {
120
- queue: ToastQueue<T>;
126
+ queue: ToastQueue<T>;
121
127
  };
122
- export {};
123
- //# sourceMappingURL=createToastState.d.ts.map
128
+
129
+ //# sourceMappingURL=createToastState.d.ts.map