@proyecto-viviana/solid-stately 0.2.4 → 0.2.7

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 (82) hide show
  1. package/LICENSE +21 -0
  2. package/dist/autocomplete/createAutocompleteState.d.ts +2 -1
  3. package/dist/checkbox/createCheckboxGroupState.d.ts +10 -1
  4. package/dist/collections/types.d.ts +11 -0
  5. package/dist/color/getColorChannels.d.ts +20 -0
  6. package/dist/data/createAsyncList.d.ts +111 -0
  7. package/dist/data/createListData.d.ts +65 -0
  8. package/dist/data/createTreeData.d.ts +61 -0
  9. package/dist/data/index.d.ts +3 -0
  10. package/dist/datepicker/index.d.ts +10 -0
  11. package/dist/grid/types.d.ts +5 -1
  12. package/dist/index.d.ts +6 -1
  13. package/dist/index.js +3737 -2697
  14. package/dist/index.js.map +1 -7
  15. package/dist/menu/index.d.ts +8 -0
  16. package/dist/radio/createRadioGroupState.d.ts +10 -1
  17. package/dist/select/createSelectState.d.ts +17 -0
  18. package/dist/selection/index.d.ts +11 -0
  19. package/dist/toast/createToastState.d.ts +7 -1
  20. package/dist/toggle/createToggleGroupState.d.ts +45 -0
  21. package/dist/toggle/index.d.ts +1 -0
  22. package/dist/tree/TreeCollection.d.ts +3 -2
  23. package/package.json +6 -5
  24. package/src/autocomplete/createAutocompleteState.ts +10 -11
  25. package/src/calendar/createDateFieldState.ts +24 -1
  26. package/src/checkbox/createCheckboxGroupState.ts +42 -6
  27. package/src/collections/ListCollection.ts +152 -146
  28. package/src/collections/createListState.ts +266 -264
  29. package/src/collections/createMenuState.ts +106 -106
  30. package/src/collections/createSelectionState.ts +336 -336
  31. package/src/collections/index.ts +46 -46
  32. package/src/collections/types.ts +181 -169
  33. package/src/color/Color.ts +951 -951
  34. package/src/color/createColorAreaState.ts +293 -293
  35. package/src/color/createColorFieldState.ts +292 -292
  36. package/src/color/createColorSliderState.ts +241 -241
  37. package/src/color/createColorWheelState.ts +211 -211
  38. package/src/color/getColorChannels.ts +34 -0
  39. package/src/color/index.ts +47 -47
  40. package/src/color/types.ts +127 -127
  41. package/src/combobox/createComboBoxState.ts +703 -703
  42. package/src/combobox/index.ts +13 -13
  43. package/src/data/createAsyncList.ts +377 -0
  44. package/src/data/createListData.ts +298 -0
  45. package/src/data/createTreeData.ts +433 -0
  46. package/src/data/index.ts +25 -0
  47. package/src/datepicker/index.ts +36 -0
  48. package/src/disclosure/createDisclosureState.ts +4 -4
  49. package/src/dnd/createDragState.ts +153 -153
  50. package/src/dnd/createDraggableCollectionState.ts +165 -165
  51. package/src/dnd/createDropState.ts +212 -212
  52. package/src/dnd/createDroppableCollectionState.ts +357 -357
  53. package/src/dnd/index.ts +76 -76
  54. package/src/dnd/types.ts +317 -317
  55. package/src/form/createFormValidationState.ts +389 -389
  56. package/src/form/index.ts +15 -15
  57. package/src/grid/types.ts +5 -0
  58. package/src/index.ts +49 -0
  59. package/src/menu/index.ts +19 -0
  60. package/src/numberfield/createNumberFieldState.ts +427 -383
  61. package/src/numberfield/index.ts +5 -5
  62. package/src/overlays/createOverlayTriggerState.ts +67 -67
  63. package/src/overlays/index.ts +5 -5
  64. package/src/radio/createRadioGroupState.ts +44 -6
  65. package/src/searchfield/createSearchFieldState.ts +62 -62
  66. package/src/searchfield/index.ts +5 -5
  67. package/src/select/createSelectState.ts +290 -181
  68. package/src/select/index.ts +5 -5
  69. package/src/selection/index.ts +28 -0
  70. package/src/slider/createSliderState.ts +211 -211
  71. package/src/slider/index.ts +6 -6
  72. package/src/tabs/createTabListState.ts +37 -11
  73. package/src/toast/createToastState.d.ts +6 -1
  74. package/src/toast/createToastState.ts +8 -1
  75. package/src/toggle/createToggleGroupState.ts +127 -0
  76. package/src/toggle/index.ts +6 -0
  77. package/src/tooltip/createTooltipTriggerState.ts +183 -183
  78. package/src/tooltip/index.ts +6 -6
  79. package/src/tree/TreeCollection.ts +208 -175
  80. package/src/tree/createTreeState.ts +392 -392
  81. package/src/tree/index.ts +13 -13
  82. package/src/tree/types.ts +174 -174
@@ -1,46 +1,46 @@
1
- // Types
2
- export type {
3
- Key,
4
- SelectionMode,
5
- SelectionBehavior,
6
- Selection,
7
- FocusStrategy,
8
- DisabledBehavior,
9
- CollectionNode,
10
- Collection,
11
- ItemProps,
12
- SectionProps,
13
- CollectionBase,
14
- SingleSelection,
15
- MultipleSelection,
16
- } from './types';
17
-
18
- // List Collection
19
- export { ListCollection, createListCollection } from './ListCollection';
20
-
21
- // Selection State
22
- export {
23
- createSelectionState,
24
- type SelectionStateProps,
25
- type SelectionState,
26
- } from './createSelectionState';
27
-
28
- // List State
29
- export {
30
- createListState,
31
- createSingleSelectListState,
32
- type ListStateProps,
33
- type ListState,
34
- type SingleSelectListStateProps,
35
- type SingleSelectListState,
36
- } from './createListState';
37
-
38
- // Menu State
39
- export {
40
- createMenuState,
41
- createMenuTriggerState,
42
- type MenuStateProps,
43
- type MenuState,
44
- type MenuTriggerStateProps,
45
- type MenuTriggerState,
46
- } from './createMenuState';
1
+ // Types
2
+ export type {
3
+ Key,
4
+ SelectionMode,
5
+ SelectionBehavior,
6
+ Selection,
7
+ FocusStrategy,
8
+ DisabledBehavior,
9
+ CollectionNode,
10
+ Collection,
11
+ ItemProps,
12
+ SectionProps,
13
+ CollectionBase,
14
+ SingleSelection,
15
+ MultipleSelection,
16
+ } from './types';
17
+
18
+ // List Collection
19
+ export { ListCollection, createListCollection } from './ListCollection';
20
+
21
+ // Selection State
22
+ export {
23
+ createSelectionState,
24
+ type SelectionStateProps,
25
+ type SelectionState,
26
+ } from './createSelectionState';
27
+
28
+ // List State
29
+ export {
30
+ createListState,
31
+ createSingleSelectListState,
32
+ type ListStateProps,
33
+ type ListState,
34
+ type SingleSelectListStateProps,
35
+ type SingleSelectListState,
36
+ } from './createListState';
37
+
38
+ // Menu State
39
+ export {
40
+ createMenuState,
41
+ createMenuTriggerState,
42
+ type MenuStateProps,
43
+ type MenuState,
44
+ type MenuTriggerStateProps,
45
+ type MenuTriggerState,
46
+ } from './createMenuState';
@@ -1,169 +1,181 @@
1
- /**
2
- * Core types for collection state management.
3
- * Simplified from @react-stately/collections for SolidJS.
4
- */
5
-
6
- import type { JSX } from 'solid-js';
7
-
8
- /** A unique identifier for an item in a collection. */
9
- export type Key = string | number;
10
-
11
- /** The type of selection allowed in a collection. */
12
- export type SelectionMode = 'none' | 'single' | 'multiple';
13
-
14
- /** How selection behaves when clicking on items. */
15
- export type SelectionBehavior = 'toggle' | 'replace';
16
-
17
- /** Represents the current selection state. */
18
- export type Selection = 'all' | Set<Key>;
19
-
20
- /** Strategy for focusing first or last item. */
21
- export type FocusStrategy = 'first' | 'last';
22
-
23
- /** Whether disabled keys affect selection, actions, or both. */
24
- export type DisabledBehavior = 'selection' | 'all';
25
-
26
- /**
27
- * Represents a node in a collection (item or section).
28
- */
29
- export interface CollectionNode<T = unknown> {
30
- /** The type of node: 'item' or 'section'. */
31
- type: 'item' | 'section';
32
- /** A unique key for the node. */
33
- key: Key;
34
- /** The original value/data for this node. */
35
- value: T | null;
36
- /** The text content for accessibility and typeahead. */
37
- textValue: string;
38
- /** The rendered content (JSX). */
39
- rendered: JSX.Element;
40
- /** The level of nesting (0 for top-level). */
41
- level: number;
42
- /** The index within the parent. */
43
- index: number;
44
- /** The key of the parent node, if any. */
45
- parentKey: Key | null;
46
- /** Whether this node has child nodes. */
47
- hasChildNodes: boolean;
48
- /** Child nodes, if any. */
49
- childNodes: CollectionNode<T>[];
50
- /** Whether this item is disabled. */
51
- isDisabled?: boolean;
52
- /** ARIA label for this node. */
53
- 'aria-label'?: string;
54
- /** Additional props for the node. */
55
- props?: Record<string, unknown>;
56
- }
57
-
58
- /**
59
- * A collection of nodes with methods to traverse and query.
60
- */
61
- export interface Collection<T = unknown> extends Iterable<CollectionNode<T>> {
62
- /** The number of items in the collection. */
63
- readonly size: number;
64
-
65
- /** Get all keys in the collection. */
66
- getKeys(): Iterable<Key>;
67
-
68
- /** Get a node by its key. */
69
- getItem(key: Key): CollectionNode<T> | null;
70
-
71
- /** Get a node by index. */
72
- at(index: number): CollectionNode<T> | null;
73
-
74
- /** Get the key before the given key. */
75
- getKeyBefore(key: Key): Key | null;
76
-
77
- /** Get the key after the given key. */
78
- getKeyAfter(key: Key): Key | null;
79
-
80
- /** Get the first key in the collection. */
81
- getFirstKey(): Key | null;
82
-
83
- /** Get the last key in the collection. */
84
- getLastKey(): Key | null;
85
-
86
- /** Get the children of a node. */
87
- getChildren(key: Key): Iterable<CollectionNode<T>>;
88
-
89
- /** Get the text value for a key. */
90
- getTextValue(key: Key): string;
91
- }
92
-
93
- /**
94
- * Props for items in a collection.
95
- */
96
- export interface ItemProps<T = unknown> {
97
- /** Unique key for the item. Required if items is used for dynamic collections. */
98
- key?: Key;
99
- /** The text value for accessibility and typeahead. If not provided, derived from children. */
100
- textValue?: string;
101
- /** Whether the item is disabled. */
102
- isDisabled?: boolean;
103
- /** The rendered content of the item. */
104
- children?: JSX.Element;
105
- /** ARIA label for the item. */
106
- 'aria-label'?: string;
107
- /** The original value for dynamic collections. */
108
- value?: T;
109
- }
110
-
111
- /**
112
- * Props for sections in a collection.
113
- */
114
- export interface SectionProps<T = unknown> {
115
- /** Unique key for the section. */
116
- key?: Key;
117
- /** The section header/title. */
118
- title?: JSX.Element;
119
- /** ARIA label for the section. */
120
- 'aria-label'?: string;
121
- /** The items in this section. */
122
- children?: JSX.Element;
123
- /** Items for dynamic rendering. */
124
- items?: Iterable<T>;
125
- }
126
-
127
- /**
128
- * Base props for components that use collections.
129
- */
130
- export interface CollectionBase<T = unknown> {
131
- /** The items in the collection (for dynamic rendering). */
132
- items?: Iterable<T>;
133
- /** The children (static items or render function). */
134
- children?: JSX.Element | ((item: T) => JSX.Element);
135
- /** Keys of disabled items. */
136
- disabledKeys?: Iterable<Key>;
137
- }
138
-
139
- /**
140
- * Props for single selection.
141
- */
142
- export interface SingleSelection {
143
- /** Whether empty selection is allowed. */
144
- disallowEmptySelection?: boolean;
145
- /** The currently selected key (controlled). */
146
- selectedKey?: Key | null;
147
- /** The default selected key (uncontrolled). */
148
- defaultSelectedKey?: Key;
149
- /** Handler called when selection changes. */
150
- onSelectionChange?: (key: Key | null) => void;
151
- }
152
-
153
- /**
154
- * Props for multiple selection.
155
- */
156
- export interface MultipleSelection {
157
- /** The selection mode. */
158
- selectionMode?: SelectionMode;
159
- /** Whether empty selection is allowed. */
160
- disallowEmptySelection?: boolean;
161
- /** The currently selected keys (controlled). */
162
- selectedKeys?: 'all' | Iterable<Key>;
163
- /** The default selected keys (uncontrolled). */
164
- defaultSelectedKeys?: 'all' | Iterable<Key>;
165
- /** Handler called when selection changes. */
166
- onSelectionChange?: (keys: Selection) => void;
167
- /** Keys of disabled items. */
168
- disabledKeys?: Iterable<Key>;
169
- }
1
+ /**
2
+ * Core types for collection state management.
3
+ * Simplified from @react-stately/collections for SolidJS.
4
+ */
5
+
6
+ import type { JSX } from 'solid-js';
7
+
8
+ /** A unique identifier for an item in a collection. */
9
+ export type Key = string | number;
10
+
11
+ /** The type of selection allowed in a collection. */
12
+ export type SelectionMode = 'none' | 'single' | 'multiple';
13
+
14
+ /** How selection behaves when clicking on items. */
15
+ export type SelectionBehavior = 'toggle' | 'replace';
16
+
17
+ /** Represents the current selection state. */
18
+ export type Selection = 'all' | Set<Key>;
19
+
20
+ /** Strategy for focusing first or last item. */
21
+ export type FocusStrategy = 'first' | 'last';
22
+
23
+ /** Whether disabled keys affect selection, actions, or both. */
24
+ export type DisabledBehavior = 'selection' | 'all';
25
+
26
+ /**
27
+ * Represents a node in a collection (item or section).
28
+ */
29
+ export interface CollectionNode<T = unknown> {
30
+ /** The type of node: 'item' or 'section'. */
31
+ type: 'item' | 'section';
32
+ /** A unique key for the node. */
33
+ key: Key;
34
+ /** The original value/data for this node. */
35
+ value: T | null;
36
+ /** The text content for accessibility and typeahead. */
37
+ textValue: string;
38
+ /** The rendered content (JSX). */
39
+ rendered: JSX.Element;
40
+ /** The level of nesting (0 for top-level). */
41
+ level: number;
42
+ /** The index within the parent. */
43
+ index: number;
44
+ /** The key of the parent node, if any. */
45
+ parentKey: Key | null;
46
+ /** Whether this node has child nodes. */
47
+ hasChildNodes: boolean;
48
+ /** Child nodes, if any. */
49
+ childNodes: CollectionNode<T>[];
50
+ /** Whether this item is disabled. */
51
+ isDisabled?: boolean;
52
+ /** ARIA label for this node. */
53
+ 'aria-label'?: string;
54
+ /** Additional props for the node. */
55
+ props?: Record<string, unknown>;
56
+ }
57
+
58
+ /**
59
+ * A collection of nodes with methods to traverse and query.
60
+ */
61
+ export interface Collection<T = unknown> extends Iterable<CollectionNode<T>> {
62
+ /** The number of items in the collection. */
63
+ readonly size: number;
64
+
65
+ /** Get all keys in the collection. */
66
+ getKeys(): Iterable<Key>;
67
+
68
+ /** Get a node by its key. */
69
+ getItem(key: Key): CollectionNode<T> | null;
70
+
71
+ /** Get a node by index. */
72
+ at(index: number): CollectionNode<T> | null;
73
+
74
+ /** Get the key before the given key. */
75
+ getKeyBefore(key: Key): Key | null;
76
+
77
+ /** Get the key after the given key. */
78
+ getKeyAfter(key: Key): Key | null;
79
+
80
+ /** Get the first key in the collection. */
81
+ getFirstKey(): Key | null;
82
+
83
+ /** Get the last key in the collection. */
84
+ getLastKey(): Key | null;
85
+
86
+ /** Get the children of a node. */
87
+ getChildren(key: Key): Iterable<CollectionNode<T>>;
88
+
89
+ /** Get the text value for a key. */
90
+ getTextValue(key: Key): string;
91
+ }
92
+
93
+ /**
94
+ * Structural shape expected when inferring collection item properties
95
+ * (key, textValue, etc.) from plain objects without explicit getKey/getTextValue/getDisabled.
96
+ */
97
+ export interface CollectionItemLike {
98
+ key?: Key;
99
+ id?: Key;
100
+ textValue?: string;
101
+ label?: string;
102
+ isDisabled?: boolean;
103
+ }
104
+
105
+ /**
106
+ * Props for items in a collection.
107
+ */
108
+ export interface ItemProps<T = unknown> {
109
+ /** Unique key for the item. Required if items is used for dynamic collections. */
110
+ key?: Key;
111
+ /** The text value for accessibility and typeahead. If not provided, derived from children. */
112
+ textValue?: string;
113
+ /** Whether the item is disabled. */
114
+ isDisabled?: boolean;
115
+ /** The rendered content of the item. */
116
+ children?: JSX.Element;
117
+ /** ARIA label for the item. */
118
+ 'aria-label'?: string;
119
+ /** The original value for dynamic collections. */
120
+ value?: T;
121
+ }
122
+
123
+ /**
124
+ * Props for sections in a collection.
125
+ */
126
+ export interface SectionProps<T = unknown> {
127
+ /** Unique key for the section. */
128
+ key?: Key;
129
+ /** The section header/title. */
130
+ title?: JSX.Element;
131
+ /** ARIA label for the section. */
132
+ 'aria-label'?: string;
133
+ /** The items in this section. */
134
+ children?: JSX.Element;
135
+ /** Items for dynamic rendering. */
136
+ items?: Iterable<T>;
137
+ }
138
+
139
+ /**
140
+ * Base props for components that use collections.
141
+ */
142
+ export interface CollectionBase<T = unknown> {
143
+ /** The items in the collection (for dynamic rendering). */
144
+ items?: Iterable<T>;
145
+ /** The children (static items or render function). */
146
+ children?: JSX.Element | ((item: T) => JSX.Element);
147
+ /** Keys of disabled items. */
148
+ disabledKeys?: Iterable<Key>;
149
+ }
150
+
151
+ /**
152
+ * Props for single selection.
153
+ */
154
+ export interface SingleSelection {
155
+ /** Whether empty selection is allowed. */
156
+ disallowEmptySelection?: boolean;
157
+ /** The currently selected key (controlled). */
158
+ selectedKey?: Key | null;
159
+ /** The default selected key (uncontrolled). */
160
+ defaultSelectedKey?: Key;
161
+ /** Handler called when selection changes. */
162
+ onSelectionChange?: (key: Key | null) => void;
163
+ }
164
+
165
+ /**
166
+ * Props for multiple selection.
167
+ */
168
+ export interface MultipleSelection {
169
+ /** The selection mode. */
170
+ selectionMode?: SelectionMode;
171
+ /** Whether empty selection is allowed. */
172
+ disallowEmptySelection?: boolean;
173
+ /** The currently selected keys (controlled). */
174
+ selectedKeys?: 'all' | Iterable<Key>;
175
+ /** The default selected keys (uncontrolled). */
176
+ defaultSelectedKeys?: 'all' | Iterable<Key>;
177
+ /** Handler called when selection changes. */
178
+ onSelectionChange?: (keys: Selection) => void;
179
+ /** Keys of disabled items. */
180
+ disabledKeys?: Iterable<Key>;
181
+ }