@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,174 @@
1
+ /**
2
+ * Tree collection types for Tree components.
3
+ * Based on @react-stately/tree.
4
+ */
5
+
6
+ import type { Key, FocusStrategy } from '../collections/types';
7
+ import type { GridNode, GridCollection } from '../grid/types';
8
+
9
+ /**
10
+ * Represents a node in a tree collection.
11
+ * Extends GridNode with tree-specific properties.
12
+ */
13
+ export interface TreeNode<T = unknown> extends GridNode<T> {
14
+ /** Whether this node has child nodes that can be expanded. */
15
+ hasChildNodes: boolean;
16
+ /** Child nodes of this tree item. */
17
+ childNodes: TreeNode<T>[];
18
+ /** The level of nesting (0 for root items). */
19
+ level: number;
20
+ /** The key of the parent node, if any. */
21
+ parentKey?: Key | null;
22
+ /** Whether this node is expandable. */
23
+ isExpandable?: boolean;
24
+ /** Whether this node is currently expanded (only meaningful if expandable). */
25
+ isExpanded?: boolean;
26
+ }
27
+
28
+ /**
29
+ * A collection of tree nodes with tree-specific navigation.
30
+ * Only includes visible nodes (respects expanded state).
31
+ */
32
+ export interface TreeCollection<T = unknown> extends Omit<GridCollection<T>, 'rows' | 'columns' | 'headerRows' | 'columnCount' | 'getCell'> {
33
+ /** All visible rows in the tree (respects expanded state). */
34
+ readonly rows: TreeNode<T>[];
35
+ /** Number of visible rows. */
36
+ readonly rowCount: number;
37
+
38
+ /** Get all keys in the collection (visible only). */
39
+ getKeys(): Iterable<Key>;
40
+
41
+ /** Get a node by its key (any node, visible or not). */
42
+ getItem(key: Key): TreeNode<T> | null;
43
+
44
+ /** Get a node by index (visible nodes only). */
45
+ at(index: number): TreeNode<T> | null;
46
+
47
+ /** Get the key before the given key (visible nodes only). */
48
+ getKeyBefore(key: Key): Key | null;
49
+
50
+ /** Get the key after the given key (visible nodes only). */
51
+ getKeyAfter(key: Key): Key | null;
52
+
53
+ /** Get the first key in the collection. */
54
+ getFirstKey(): Key | null;
55
+
56
+ /** Get the last key in the collection. */
57
+ getLastKey(): Key | null;
58
+
59
+ /** Get the children of a node. */
60
+ getChildren(key: Key): Iterable<TreeNode<T>>;
61
+
62
+ /** Get the text value for a key. */
63
+ getTextValue(key: Key): string;
64
+
65
+ /** Get the parent key for a node. */
66
+ getParentKey(key: Key): Key | null;
67
+
68
+ /** Iterator over visible nodes. */
69
+ [Symbol.iterator](): Iterator<TreeNode<T>>;
70
+ }
71
+
72
+ /**
73
+ * State for a tree component.
74
+ * Extends grid state with expansion management.
75
+ */
76
+ export interface TreeState<T, C extends TreeCollection<T> = TreeCollection<T>> {
77
+ /** The tree collection (only visible nodes). */
78
+ readonly collection: C;
79
+ /** Keys of disabled items. */
80
+ readonly disabledKeys: Set<Key>;
81
+ /** Keys of expanded items. */
82
+ readonly expandedKeys: Set<Key>;
83
+ /** Whether keyboard navigation is disabled. */
84
+ readonly isKeyboardNavigationDisabled: boolean;
85
+ /** Currently focused key. */
86
+ readonly focusedKey: Key | null;
87
+ /** Focus strategy for child focus. */
88
+ readonly childFocusStrategy: FocusStrategy | null;
89
+ /** Whether the tree is focused. */
90
+ readonly isFocused: boolean;
91
+ /** The selection mode. */
92
+ readonly selectionMode: 'none' | 'single' | 'multiple';
93
+ /** The currently selected keys. */
94
+ readonly selectedKeys: 'all' | Set<Key>;
95
+
96
+ /** Check if a key is selected. */
97
+ isSelected(key: Key): boolean;
98
+ /** Check if a key is disabled. */
99
+ isDisabled(key: Key): boolean;
100
+ /** Check if a key is expanded. */
101
+ isExpanded(key: Key): boolean;
102
+ /** Set the focused key. */
103
+ setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void;
104
+ /** Set focused state. */
105
+ setFocused(isFocused: boolean): void;
106
+ /** Toggle selection for a key. */
107
+ toggleSelection(key: Key): void;
108
+ /** Replace selection with a key. */
109
+ replaceSelection(key: Key): void;
110
+ /** Extend selection to a key (shift-click). */
111
+ extendSelection(toKey: Key): void;
112
+ /** Select all visible items. */
113
+ selectAll(): void;
114
+ /** Clear selection. */
115
+ clearSelection(): void;
116
+ /** Toggle select all. */
117
+ toggleSelectAll(): void;
118
+ /** Toggle expansion for a key. */
119
+ toggleKey(key: Key): void;
120
+ /** Expand a key. */
121
+ expandKey(key: Key): void;
122
+ /** Collapse a key. */
123
+ collapseKey(key: Key): void;
124
+ /** Set the expanded keys. */
125
+ setExpandedKeys(keys: Set<Key>): void;
126
+ /** Set keyboard navigation disabled. */
127
+ setKeyboardNavigationDisabled(isDisabled: boolean): void;
128
+ }
129
+
130
+ /**
131
+ * Options for creating tree state.
132
+ */
133
+ export interface TreeStateOptions<T, C extends TreeCollection<T> = TreeCollection<T>> {
134
+ /** The tree collection builder - receives expanded keys and returns collection. */
135
+ collectionFactory: (expandedKeys: Set<Key>) => C;
136
+ /** Keys of disabled items. */
137
+ disabledKeys?: Iterable<Key>;
138
+ /** Disabled behavior: 'selection' only or 'all' interactions. */
139
+ disabledBehavior?: 'selection' | 'all';
140
+ /** Selection mode. */
141
+ selectionMode?: 'none' | 'single' | 'multiple';
142
+ /** Selection behavior. */
143
+ selectionBehavior?: 'toggle' | 'replace';
144
+ /** Whether empty selection is disallowed. */
145
+ disallowEmptySelection?: boolean;
146
+ /** Currently selected keys (controlled). */
147
+ selectedKeys?: 'all' | Iterable<Key>;
148
+ /** Default selected keys (uncontrolled). */
149
+ defaultSelectedKeys?: 'all' | Iterable<Key>;
150
+ /** Handler for selection changes. */
151
+ onSelectionChange?: (keys: 'all' | Set<Key>) => void;
152
+ /** Currently expanded keys (controlled). */
153
+ expandedKeys?: Iterable<Key>;
154
+ /** Default expanded keys (uncontrolled). */
155
+ defaultExpandedKeys?: Iterable<Key>;
156
+ /** Handler for expansion changes. */
157
+ onExpandedChange?: (keys: Set<Key>) => void;
158
+ }
159
+
160
+ /**
161
+ * Item representation for building tree collections.
162
+ */
163
+ export interface TreeItemData<T = unknown> {
164
+ /** Unique key for this item. */
165
+ key: Key;
166
+ /** The data value for this item. */
167
+ value: T;
168
+ /** Text content for accessibility and search. */
169
+ textValue?: string;
170
+ /** Child items (makes this item expandable). */
171
+ children?: TreeItemData<T>[];
172
+ /** Whether this item is disabled. */
173
+ isDisabled?: boolean;
174
+ }
@@ -0,0 +1,2 @@
1
+ export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from './reactivity';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ export { access, isAccessor, type MaybeAccessor, type MaybeAccessorValue } from './reactivity';
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Reactivity utilities for Solid Stately
3
+ *
4
+ * Provides type-safe utilities for working with SolidJS reactivity patterns.
5
+ */
6
+ import { Accessor } from 'solid-js';
7
+ /**
8
+ * A value that may be either a raw value or an accessor function.
9
+ * This is a common pattern in SolidJS for props that may be reactive.
10
+ */
11
+ export type MaybeAccessor<T> = T | Accessor<T>;
12
+ /**
13
+ * Unwraps a MaybeAccessor to get the underlying value.
14
+ * If the input is a function, it calls it to get the value.
15
+ * Otherwise, it returns the value directly.
16
+ *
17
+ * @param value - The value or accessor to unwrap.
18
+ */
19
+ export declare function access<T>(value: MaybeAccessor<T>): T;
20
+ /**
21
+ * A value that may be undefined or an accessor that returns the value or undefined.
22
+ */
23
+ export type MaybeAccessorValue<T> = T | undefined | Accessor<T | undefined>;
24
+ /**
25
+ * Checks if a value is an accessor function.
26
+ */
27
+ export declare function isAccessor<T>(value: MaybeAccessor<T>): value is Accessor<T>;
28
+ //# sourceMappingURL=reactivity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactivity.d.ts","sourceRoot":"","sources":["reactivity.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAEpD;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,GAAG,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;AAE5E;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAE3E"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Reactivity utilities for Solid Stately
3
+ *
4
+ * Provides type-safe utilities for working with SolidJS reactivity patterns.
5
+ */
6
+
7
+ import { Accessor } from 'solid-js';
8
+
9
+ /**
10
+ * A value that may be either a raw value or an accessor function.
11
+ * This is a common pattern in SolidJS for props that may be reactive.
12
+ */
13
+ export type MaybeAccessor<T> = T | Accessor<T>;
14
+
15
+ /**
16
+ * Unwraps a MaybeAccessor to get the underlying value.
17
+ * If the input is a function, it calls it to get the value.
18
+ * Otherwise, it returns the value directly.
19
+ *
20
+ * @param value - The value or accessor to unwrap.
21
+ */
22
+ export function access<T>(value: MaybeAccessor<T>): T {
23
+ return typeof value === 'function' ? (value as Accessor<T>)() : value;
24
+ }
25
+
26
+ /**
27
+ * A value that may be undefined or an accessor that returns the value or undefined.
28
+ */
29
+ export type MaybeAccessorValue<T> = T | undefined | Accessor<T | undefined>;
30
+
31
+ /**
32
+ * Checks if a value is an accessor function.
33
+ */
34
+ export function isAccessor<T>(value: MaybeAccessor<T>): value is Accessor<T> {
35
+ return typeof value === 'function';
36
+ }