@proyecto-viviana/solid-stately 0.1.5 → 0.2.1

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 (217) hide show
  1. package/{src → dist}/autocomplete/createAutocompleteState.d.ts +0 -1
  2. package/{src → dist}/autocomplete/index.d.ts +0 -1
  3. package/{src → dist}/calendar/createCalendarState.d.ts +0 -1
  4. package/{src → dist}/calendar/createDateFieldState.d.ts +0 -1
  5. package/{src → dist}/calendar/createRangeCalendarState.d.ts +0 -1
  6. package/{src → dist}/calendar/createTimeFieldState.d.ts +0 -1
  7. package/{src → dist}/calendar/index.d.ts +0 -1
  8. package/{src → dist}/checkbox/createCheckboxGroupState.d.ts +0 -1
  9. package/{src → dist}/checkbox/index.d.ts +0 -1
  10. package/{src → dist}/collections/ListCollection.d.ts +0 -1
  11. package/{src → dist}/collections/createListState.d.ts +0 -1
  12. package/{src → dist}/collections/createMenuState.d.ts +0 -1
  13. package/{src → dist}/collections/createSelectionState.d.ts +0 -1
  14. package/{src → dist}/collections/index.d.ts +0 -1
  15. package/{src → dist}/collections/types.d.ts +0 -1
  16. package/{src → dist}/color/Color.d.ts +0 -1
  17. package/{src → dist}/color/createColorAreaState.d.ts +0 -1
  18. package/{src → dist}/color/createColorFieldState.d.ts +0 -1
  19. package/{src → dist}/color/createColorSliderState.d.ts +0 -1
  20. package/{src → dist}/color/createColorWheelState.d.ts +0 -1
  21. package/{src → dist}/color/index.d.ts +0 -1
  22. package/{src → dist}/color/types.d.ts +0 -1
  23. package/{src → dist}/combobox/createComboBoxState.d.ts +0 -1
  24. package/{src → dist}/combobox/index.d.ts +0 -1
  25. package/{src → dist}/disclosure/createDisclosureState.d.ts +0 -1
  26. package/{src → dist}/disclosure/index.d.ts +0 -1
  27. package/{src → dist}/dnd/createDragState.d.ts +0 -1
  28. package/{src → dist}/dnd/createDraggableCollectionState.d.ts +0 -1
  29. package/{src → dist}/dnd/createDropState.d.ts +0 -1
  30. package/{src → dist}/dnd/createDroppableCollectionState.d.ts +0 -1
  31. package/{src → dist}/dnd/index.d.ts +0 -1
  32. package/{src → dist}/dnd/types.d.ts +0 -1
  33. package/{src → dist}/form/createFormValidationState.d.ts +0 -1
  34. package/{src → dist}/form/index.d.ts +0 -1
  35. package/{src → dist}/grid/createGridState.d.ts +0 -1
  36. package/{src → dist}/grid/index.d.ts +0 -1
  37. package/{src → dist}/grid/types.d.ts +0 -1
  38. package/dist/index.d.ts +25 -3363
  39. package/dist/index.js +2 -2
  40. package/dist/index.js.map +7 -1
  41. package/{src → dist}/numberfield/createNumberFieldState.d.ts +0 -1
  42. package/{src → dist}/numberfield/index.d.ts +0 -1
  43. package/{src → dist}/overlays/createOverlayTriggerState.d.ts +0 -1
  44. package/{src → dist}/overlays/index.d.ts +0 -1
  45. package/{src → dist}/radio/createRadioGroupState.d.ts +0 -1
  46. package/{src → dist}/radio/index.d.ts +0 -1
  47. package/{src → dist}/searchfield/createSearchFieldState.d.ts +0 -1
  48. package/{src → dist}/searchfield/index.d.ts +0 -1
  49. package/{src → dist}/select/createSelectState.d.ts +0 -1
  50. package/{src → dist}/select/index.d.ts +0 -1
  51. package/{src → dist}/slider/createSliderState.d.ts +0 -1
  52. package/{src → dist}/slider/index.d.ts +0 -1
  53. package/{src → dist}/ssr/index.d.ts +0 -1
  54. package/{src → dist}/table/TableCollection.d.ts +0 -1
  55. package/{src → dist}/table/createTableState.d.ts +0 -1
  56. package/{src → dist}/table/index.d.ts +0 -1
  57. package/{src → dist}/table/types.d.ts +0 -1
  58. package/{src → dist}/tabs/createTabListState.d.ts +0 -1
  59. package/{src → dist}/tabs/index.d.ts +0 -1
  60. package/{src → dist}/textfield/createTextFieldState.d.ts +0 -1
  61. package/{src → dist}/textfield/index.d.ts +0 -1
  62. package/{src → dist}/toast/createToastState.d.ts +0 -1
  63. package/{src → dist}/toast/index.d.ts +0 -1
  64. package/{src → dist}/toggle/createToggleState.d.ts +0 -1
  65. package/{src → dist}/toggle/index.d.ts +0 -1
  66. package/{src → dist}/tooltip/createTooltipTriggerState.d.ts +0 -1
  67. package/{src → dist}/tooltip/index.d.ts +0 -1
  68. package/{src → dist}/tree/TreeCollection.d.ts +0 -1
  69. package/{src → dist}/tree/createTreeState.d.ts +0 -1
  70. package/{src → dist}/tree/index.d.ts +0 -1
  71. package/{src → dist}/tree/types.d.ts +0 -1
  72. package/{src → dist}/utils/reactivity.d.ts +0 -1
  73. package/package.json +5 -7
  74. package/src/autocomplete/createAutocompleteState.d.ts.map +0 -1
  75. package/src/autocomplete/createAutocompleteState.ts +0 -90
  76. package/src/autocomplete/index.d.ts.map +0 -1
  77. package/src/autocomplete/index.ts +0 -5
  78. package/src/calendar/createCalendarState.d.ts.map +0 -1
  79. package/src/calendar/createCalendarState.ts +0 -461
  80. package/src/calendar/createDateFieldState.d.ts.map +0 -1
  81. package/src/calendar/createDateFieldState.ts +0 -562
  82. package/src/calendar/createRangeCalendarState.d.ts.map +0 -1
  83. package/src/calendar/createRangeCalendarState.ts +0 -535
  84. package/src/calendar/createTimeFieldState.d.ts.map +0 -1
  85. package/src/calendar/createTimeFieldState.ts +0 -483
  86. package/src/calendar/index.d.ts.map +0 -1
  87. package/src/calendar/index.ts +0 -81
  88. package/src/checkbox/createCheckboxGroupState.d.ts.map +0 -1
  89. package/src/checkbox/createCheckboxGroupState.ts +0 -193
  90. package/src/checkbox/index.d.ts.map +0 -1
  91. package/src/checkbox/index.ts +0 -5
  92. package/src/collections/ListCollection.d.ts.map +0 -1
  93. package/src/collections/ListCollection.ts +0 -146
  94. package/src/collections/createListState.d.ts.map +0 -1
  95. package/src/collections/createListState.ts +0 -264
  96. package/src/collections/createMenuState.d.ts.map +0 -1
  97. package/src/collections/createMenuState.ts +0 -106
  98. package/src/collections/createSelectionState.d.ts.map +0 -1
  99. package/src/collections/createSelectionState.ts +0 -336
  100. package/src/collections/index.d.ts.map +0 -1
  101. package/src/collections/index.ts +0 -46
  102. package/src/collections/types.d.ts.map +0 -1
  103. package/src/collections/types.ts +0 -169
  104. package/src/color/Color.d.ts.map +0 -1
  105. package/src/color/Color.ts +0 -951
  106. package/src/color/createColorAreaState.d.ts.map +0 -1
  107. package/src/color/createColorAreaState.ts +0 -293
  108. package/src/color/createColorFieldState.d.ts.map +0 -1
  109. package/src/color/createColorFieldState.ts +0 -292
  110. package/src/color/createColorSliderState.d.ts.map +0 -1
  111. package/src/color/createColorSliderState.ts +0 -241
  112. package/src/color/createColorWheelState.d.ts.map +0 -1
  113. package/src/color/createColorWheelState.ts +0 -211
  114. package/src/color/index.d.ts.map +0 -1
  115. package/src/color/index.ts +0 -47
  116. package/src/color/types.d.ts.map +0 -1
  117. package/src/color/types.ts +0 -127
  118. package/src/combobox/createComboBoxState.d.ts.map +0 -1
  119. package/src/combobox/createComboBoxState.ts +0 -703
  120. package/src/combobox/index.d.ts.map +0 -1
  121. package/src/combobox/index.ts +0 -13
  122. package/src/disclosure/createDisclosureState.d.ts.map +0 -1
  123. package/src/disclosure/createDisclosureState.ts +0 -193
  124. package/src/disclosure/index.d.ts.map +0 -1
  125. package/src/disclosure/index.ts +0 -9
  126. package/src/dnd/createDragState.d.ts.map +0 -1
  127. package/src/dnd/createDragState.ts +0 -153
  128. package/src/dnd/createDraggableCollectionState.d.ts.map +0 -1
  129. package/src/dnd/createDraggableCollectionState.ts +0 -165
  130. package/src/dnd/createDropState.d.ts.map +0 -1
  131. package/src/dnd/createDropState.ts +0 -212
  132. package/src/dnd/createDroppableCollectionState.d.ts.map +0 -1
  133. package/src/dnd/createDroppableCollectionState.ts +0 -357
  134. package/src/dnd/index.d.ts.map +0 -1
  135. package/src/dnd/index.ts +0 -76
  136. package/src/dnd/types.d.ts.map +0 -1
  137. package/src/dnd/types.ts +0 -317
  138. package/src/form/createFormValidationState.d.ts.map +0 -1
  139. package/src/form/createFormValidationState.ts +0 -389
  140. package/src/form/index.d.ts.map +0 -1
  141. package/src/form/index.ts +0 -15
  142. package/src/grid/createGridState.d.ts.map +0 -1
  143. package/src/grid/createGridState.ts +0 -327
  144. package/src/grid/index.d.ts.map +0 -1
  145. package/src/grid/index.ts +0 -13
  146. package/src/grid/types.d.ts.map +0 -1
  147. package/src/grid/types.ts +0 -179
  148. package/src/index.d.ts +0 -26
  149. package/src/index.d.ts.map +0 -1
  150. package/src/index.ts +0 -383
  151. package/src/numberfield/createNumberFieldState.d.ts.map +0 -1
  152. package/src/numberfield/createNumberFieldState.ts +0 -383
  153. package/src/numberfield/index.d.ts.map +0 -1
  154. package/src/numberfield/index.ts +0 -5
  155. package/src/overlays/createOverlayTriggerState.d.ts.map +0 -1
  156. package/src/overlays/createOverlayTriggerState.ts +0 -67
  157. package/src/overlays/index.d.ts.map +0 -1
  158. package/src/overlays/index.ts +0 -5
  159. package/src/radio/createRadioGroupState.d.ts.map +0 -1
  160. package/src/radio/createRadioGroupState.ts +0 -201
  161. package/src/radio/index.d.ts.map +0 -1
  162. package/src/radio/index.ts +0 -6
  163. package/src/searchfield/createSearchFieldState.d.ts.map +0 -1
  164. package/src/searchfield/createSearchFieldState.ts +0 -62
  165. package/src/searchfield/index.d.ts.map +0 -1
  166. package/src/searchfield/index.ts +0 -5
  167. package/src/select/createSelectState.d.ts.map +0 -1
  168. package/src/select/createSelectState.ts +0 -181
  169. package/src/select/index.d.ts.map +0 -1
  170. package/src/select/index.ts +0 -5
  171. package/src/slider/createSliderState.d.ts.map +0 -1
  172. package/src/slider/createSliderState.ts +0 -211
  173. package/src/slider/index.d.ts.map +0 -1
  174. package/src/slider/index.ts +0 -6
  175. package/src/ssr/index.d.ts.map +0 -1
  176. package/src/ssr/index.ts +0 -41
  177. package/src/table/TableCollection.d.ts.map +0 -1
  178. package/src/table/TableCollection.ts +0 -388
  179. package/src/table/createTableState.d.ts.map +0 -1
  180. package/src/table/createTableState.ts +0 -127
  181. package/src/table/index.d.ts.map +0 -1
  182. package/src/table/index.ts +0 -18
  183. package/src/table/types.d.ts.map +0 -1
  184. package/src/table/types.ts +0 -150
  185. package/src/tabs/createTabListState.d.ts.map +0 -1
  186. package/src/tabs/createTabListState.ts +0 -240
  187. package/src/tabs/index.d.ts.map +0 -1
  188. package/src/tabs/index.ts +0 -7
  189. package/src/textfield/createTextFieldState.d.ts.map +0 -1
  190. package/src/textfield/createTextFieldState.ts +0 -75
  191. package/src/textfield/index.d.ts.map +0 -1
  192. package/src/textfield/index.ts +0 -5
  193. package/src/toast/createToastState.d.ts.map +0 -1
  194. package/src/toast/createToastState.ts +0 -316
  195. package/src/toast/index.d.ts.map +0 -1
  196. package/src/toast/index.ts +0 -11
  197. package/src/toggle/createToggleState.d.ts.map +0 -1
  198. package/src/toggle/createToggleState.ts +0 -94
  199. package/src/toggle/index.d.ts.map +0 -1
  200. package/src/toggle/index.ts +0 -5
  201. package/src/tooltip/createTooltipTriggerState.d.ts.map +0 -1
  202. package/src/tooltip/createTooltipTriggerState.ts +0 -183
  203. package/src/tooltip/index.d.ts.map +0 -1
  204. package/src/tooltip/index.ts +0 -6
  205. package/src/tree/TreeCollection.d.ts.map +0 -1
  206. package/src/tree/TreeCollection.ts +0 -175
  207. package/src/tree/createTreeState.d.ts.map +0 -1
  208. package/src/tree/createTreeState.ts +0 -392
  209. package/src/tree/index.d.ts.map +0 -1
  210. package/src/tree/index.ts +0 -13
  211. package/src/tree/types.d.ts.map +0 -1
  212. package/src/tree/types.ts +0 -174
  213. package/src/utils/index.d.ts +0 -2
  214. package/src/utils/index.d.ts.map +0 -1
  215. package/src/utils/reactivity.d.ts.map +0 -1
  216. package/src/utils/reactivity.ts +0 -36
  217. /package/{src/utils/index.ts → dist/utils/index.d.ts} +0 -0
@@ -1,240 +0,0 @@
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
- }
@@ -1 +0,0 @@
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"}
package/src/tabs/index.ts DELETED
@@ -1,7 +0,0 @@
1
- export {
2
- createTabListState,
3
- type TabListStateProps,
4
- type TabListState,
5
- type KeyboardActivation,
6
- type TabOrientation,
7
- } from './createTabListState';
@@ -1 +0,0 @@
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"}
@@ -1,75 +0,0 @@
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
- }
@@ -1 +0,0 @@
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"}
@@ -1,5 +0,0 @@
1
- export {
2
- createTextFieldState,
3
- type TextFieldStateOptions,
4
- type TextFieldState,
5
- } from './createTextFieldState';
@@ -1 +0,0 @@
1
- {"version":3,"file":"createToastState.d.ts","sourceRoot":"","sources":["createToastState.ts"],"names":[],"mappings":"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"}
@@ -1,316 +0,0 @@
1
- /**
2
- * Toast state management for SolidJS
3
- * Based on @react-stately/toast useToastState
4
- */
5
-
6
- import { createSignal, onCleanup, type Accessor } from 'solid-js';
7
-
8
- // ============================================
9
- // TYPES
10
- // ============================================
11
-
12
- export interface ToastOptions {
13
- /** A timeout to automatically close the toast, in milliseconds. */
14
- timeout?: number;
15
- /** The priority of the toast relative to other toasts. */
16
- priority?: number;
17
- /** Handler called when the toast is closed. */
18
- onClose?: () => void;
19
- }
20
-
21
- export interface QueuedToast<T> {
22
- /** The content of the toast. */
23
- content: T;
24
- /** A unique key for the toast. */
25
- key: string;
26
- /** The timer for the toast. */
27
- timer: Timer | null;
28
- /** Whether the toast should be animated. */
29
- animation?: 'entering' | 'exiting' | 'queued';
30
- /** The priority of the toast. */
31
- priority: number;
32
- /** Handler called when the toast is closed. */
33
- onClose?: () => void;
34
- /** The timeout for the toast. */
35
- timeout?: number;
36
- }
37
-
38
- export interface ToastQueueOptions {
39
- /** The maximum number of toasts to display at once. */
40
- maxVisibleToasts?: number;
41
- /** Whether toasts should stack (true) or queue (false). */
42
- hasExitAnimation?: boolean;
43
- }
44
-
45
- export interface ToastStateProps<T> {
46
- /** The toast queue to use. */
47
- queue: ToastQueue<T>;
48
- }
49
-
50
- export interface ToastState<T> {
51
- /** The currently visible toasts. */
52
- visibleToasts: Accessor<QueuedToast<T>[]>;
53
- /** Adds a toast to the queue. */
54
- add: (content: T, options?: ToastOptions) => string;
55
- /** Closes a toast by key. */
56
- close: (key: string) => void;
57
- /** Pauses all toast timers. */
58
- pauseAll: () => void;
59
- /** Resumes all toast timers. */
60
- resumeAll: () => void;
61
- }
62
-
63
- // ============================================
64
- // TIMER CLASS
65
- // ============================================
66
-
67
- /**
68
- * A Timer that supports pause and resume.
69
- */
70
- export class Timer {
71
- private timerId: number | null = null;
72
- private startTime: number = 0;
73
- private remaining: number;
74
- private callback: () => void;
75
-
76
- constructor(callback: () => void, delay: number) {
77
- this.callback = callback;
78
- this.remaining = delay;
79
- this.resume();
80
- }
81
-
82
- pause() {
83
- if (this.timerId === null) {
84
- return;
85
- }
86
- clearTimeout(this.timerId);
87
- this.timerId = null;
88
- this.remaining -= Date.now() - this.startTime;
89
- }
90
-
91
- resume() {
92
- if (this.timerId !== null) {
93
- return;
94
- }
95
- this.startTime = Date.now();
96
- this.timerId = window.setTimeout(() => {
97
- this.timerId = null;
98
- this.callback();
99
- }, this.remaining);
100
- }
101
-
102
- reset(delay: number) {
103
- this.pause();
104
- this.remaining = delay;
105
- this.resume();
106
- }
107
-
108
- cancel() {
109
- if (this.timerId !== null) {
110
- clearTimeout(this.timerId);
111
- this.timerId = null;
112
- }
113
- }
114
- }
115
-
116
- // ============================================
117
- // TOAST QUEUE CLASS
118
- // ============================================
119
-
120
- type SubscribeCallback<T> = (toasts: QueuedToast<T>[]) => void;
121
-
122
- /**
123
- * A queue that manages toast notifications.
124
- * Can be created once and shared across the app (singleton pattern).
125
- */
126
- export class ToastQueue<T> {
127
- private queue: QueuedToast<T>[] = [];
128
- private subscriptions = new Set<SubscribeCallback<T>>();
129
- private maxVisibleToasts: number;
130
- private hasExitAnimation: boolean;
131
- private keyCounter = 0;
132
-
133
- constructor(options: ToastQueueOptions = {}) {
134
- this.maxVisibleToasts = options.maxVisibleToasts ?? 5;
135
- this.hasExitAnimation = options.hasExitAnimation ?? false;
136
- }
137
-
138
- /**
139
- * Subscribe to queue changes.
140
- */
141
- subscribe(callback: SubscribeCallback<T>): () => void {
142
- this.subscriptions.add(callback);
143
- return () => {
144
- this.subscriptions.delete(callback);
145
- };
146
- }
147
-
148
- /**
149
- * Add a toast to the queue.
150
- */
151
- add(content: T, options: ToastOptions = {}): string {
152
- const key = String(this.keyCounter++);
153
-
154
- const toast: QueuedToast<T> = {
155
- content,
156
- key,
157
- timer: null,
158
- priority: options.priority ?? 0,
159
- onClose: options.onClose,
160
- timeout: options.timeout,
161
- animation: 'entering',
162
- };
163
-
164
- // Find insertion point based on priority
165
- let low = 0;
166
- let high = this.queue.length;
167
- while (low < high) {
168
- const mid = Math.floor((low + high) / 2);
169
- if (toast.priority > this.queue[mid].priority) {
170
- high = mid;
171
- } else {
172
- low = mid + 1;
173
- }
174
- }
175
-
176
- // Insert at the correct position
177
- this.queue = [
178
- ...this.queue.slice(0, low),
179
- toast,
180
- ...this.queue.slice(low),
181
- ];
182
-
183
- // Start timer for visible toasts
184
- this.updateVisibility();
185
-
186
- return key;
187
- }
188
-
189
- /**
190
- * Close a toast by key.
191
- */
192
- close(key: string): void {
193
- const toast = this.queue.find((t) => t.key === key);
194
- if (!toast) return;
195
-
196
- // Cancel any existing timer
197
- toast.timer?.cancel();
198
- toast.timer = null;
199
-
200
- if (this.hasExitAnimation && toast.animation !== 'queued') {
201
- // Mark as exiting for animation
202
- toast.animation = 'exiting';
203
- this.notify();
204
- } else {
205
- // Remove immediately
206
- this.remove(key);
207
- }
208
- }
209
-
210
- /**
211
- * Remove a toast after exit animation completes.
212
- */
213
- remove(key: string): void {
214
- const toast = this.queue.find((t) => t.key === key);
215
- if (toast) {
216
- toast.onClose?.();
217
- toast.timer?.cancel();
218
- }
219
-
220
- this.queue = this.queue.filter((t) => t.key !== key);
221
- this.updateVisibility();
222
- }
223
-
224
- /**
225
- * Pause all toast timers.
226
- */
227
- pauseAll(): void {
228
- for (const toast of this.queue) {
229
- toast.timer?.pause();
230
- }
231
- }
232
-
233
- /**
234
- * Resume all toast timers.
235
- */
236
- resumeAll(): void {
237
- for (const toast of this.queue) {
238
- toast.timer?.resume();
239
- }
240
- }
241
-
242
- private updateVisibility(): void {
243
- // Mark toasts as visible or queued based on maxVisibleToasts
244
- const visibleCount = this.queue.filter(
245
- (t) => t.animation !== 'queued' && t.animation !== 'exiting'
246
- ).length;
247
-
248
- let promoted = 0;
249
- for (const toast of this.queue) {
250
- if (toast.animation === 'queued' && visibleCount + promoted < this.maxVisibleToasts) {
251
- toast.animation = 'entering';
252
- promoted++;
253
- }
254
- if (toast.animation === 'queued') continue;
255
-
256
- // Start timer for visible toasts
257
- if (toast.timeout != null && toast.timer === null && toast.animation !== 'exiting') {
258
- toast.timer = new Timer(() => {
259
- this.close(toast.key);
260
- }, toast.timeout);
261
- }
262
- }
263
-
264
- this.notify();
265
- }
266
-
267
- private notify(): void {
268
- const toasts = [...this.queue];
269
- for (const callback of this.subscriptions) {
270
- callback(toasts);
271
- }
272
- }
273
- }
274
-
275
- // ============================================
276
- // HOOK
277
- // ============================================
278
-
279
- /**
280
- * Creates reactive toast state from a ToastQueue.
281
- * Use this hook to subscribe to toast changes in your component.
282
- */
283
- export function createToastState<T>(props: ToastStateProps<T>): ToastState<T> {
284
- const [visibleToasts, setVisibleToasts] = createSignal<QueuedToast<T>[]>([]);
285
-
286
- // Subscribe to queue changes
287
- const unsubscribe = props.queue.subscribe((toasts) => {
288
- setVisibleToasts(toasts);
289
- });
290
-
291
- onCleanup(() => {
292
- unsubscribe();
293
- });
294
-
295
- return {
296
- visibleToasts,
297
- add: (content, options) => props.queue.add(content, options),
298
- close: (key) => props.queue.close(key),
299
- pauseAll: () => props.queue.pauseAll(),
300
- resumeAll: () => props.queue.resumeAll(),
301
- };
302
- }
303
-
304
- // ============================================
305
- // CONVENIENCE HOOKS
306
- // ============================================
307
-
308
- /**
309
- * Creates a new ToastQueue and returns reactive state.
310
- * Use this if you don't need a global queue.
311
- */
312
- export function createToastQueue<T>(options?: ToastQueueOptions): ToastState<T> & { queue: ToastQueue<T> } {
313
- const queue = new ToastQueue<T>(options);
314
- const state = createToastState({ queue });
315
- return { ...state, queue };
316
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,UAAU,GAChB,MAAM,oBAAoB,CAAC"}
@@ -1,11 +0,0 @@
1
- export {
2
- createToastState,
3
- createToastQueue,
4
- ToastQueue,
5
- Timer,
6
- type ToastOptions,
7
- type QueuedToast,
8
- type ToastQueueOptions,
9
- type ToastStateProps,
10
- type ToastState,
11
- } from './createToastState';
@@ -1 +0,0 @@
1
- {"version":3,"file":"createToggleState.d.ts","sourceRoot":"","sources":["createToggleState.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgB,QAAQ,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,KAAK,aAAa,EAAU,MAAM,UAAU,CAAC;AAMtD,MAAM,WAAW,kBAAkB;IACjC,2DAA2D;IAC3D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wEAAwE;IACxE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACvC,iDAAiD;IACjD,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,+BAA+B;IAC/B,WAAW,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC,kCAAkC;IAClC,MAAM,IAAI,IAAI,CAAC;CAChB;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,GAAE,aAAa,CAAC,kBAAkB,CAAM,GAAG,WAAW,CAiD5F"}