@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,62 +0,0 @@
1
- /**
2
- * Creates state for a search field component.
3
- * Based on @react-stately/searchfield useSearchFieldState.
4
- */
5
-
6
- import { type Accessor, createSignal, createMemo } from 'solid-js';
7
- import { access, type MaybeAccessor } from '../utils';
8
-
9
- export interface SearchFieldStateProps {
10
- /** The current value (controlled). */
11
- value?: string;
12
- /** The default value (uncontrolled). */
13
- defaultValue?: string;
14
- /** Handler that is called when the value changes. */
15
- onChange?: (value: string) => void;
16
- }
17
-
18
- export interface SearchFieldState {
19
- /** The current value of the search field. */
20
- value: Accessor<string>;
21
- /** Sets the value of the search field. */
22
- setValue: (value: string) => void;
23
- }
24
-
25
- /**
26
- * Provides state management for a search field.
27
- */
28
- export function createSearchFieldState(
29
- props: MaybeAccessor<SearchFieldStateProps>
30
- ): SearchFieldState {
31
- const getProps = () => access(props);
32
-
33
- // Controlled vs uncontrolled
34
- const isControlled = () => getProps().value !== undefined;
35
-
36
- // Internal signal for uncontrolled mode
37
- const [internalValue, setInternalValue] = createSignal(
38
- getProps().defaultValue ?? ''
39
- );
40
-
41
- // Current value accessor
42
- const value = createMemo(() => {
43
- const p = getProps();
44
- return isControlled() ? (p.value ?? '') : internalValue();
45
- });
46
-
47
- // Set value function
48
- const setValue = (newValue: string) => {
49
- const p = getProps();
50
-
51
- if (!isControlled()) {
52
- setInternalValue(newValue);
53
- }
54
-
55
- p.onChange?.(newValue);
56
- };
57
-
58
- return {
59
- value,
60
- setValue,
61
- };
62
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EACV,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC"}
@@ -1,5 +0,0 @@
1
- export { createSearchFieldState } from './createSearchFieldState';
2
- export type {
3
- SearchFieldState,
4
- SearchFieldStateProps,
5
- } from './createSearchFieldState';
@@ -1 +0,0 @@
1
- {"version":3,"file":"createSelectState.d.ts","sourceRoot":"","sources":["createSelectState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAGtD,OAAO,KAAK,EAAE,GAAG,EAAE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IAAI,IAAI,CAAC;IACb,iCAAiC;IACjC,KAAK,IAAI,IAAI,CAAC;IACd,kCAAkC;IAClC,MAAM,IAAI,IAAI,CAAC;IACf,kCAAkC;IAClC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;IAC3C,mCAAmC;IACnC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1D,4BAA4B;IAC5B,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;IACtC,iCAAiC;IACjC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;IAC1C,2BAA2B;IAC3B,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;IACrC,oCAAoC;IACpC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtC,wCAAwC;IACxC,UAAU,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IACrC,0CAA0C;IAC1C,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC;IACjC,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAC3C,KAAK,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GACxC,WAAW,CAAC,CAAC,CAAC,CAqGhB"}
@@ -1,181 +0,0 @@
1
- /**
2
- * State management for select components.
3
- * Based on @react-stately/select useSelectState.
4
- */
5
-
6
- import { createSignal, type Accessor } from 'solid-js';
7
- import { access, type MaybeAccessor } from '../utils';
8
- import { createListState } from '../collections/createListState';
9
- import { createOverlayTriggerState } from '../overlays';
10
- import type { Key, CollectionNode, Collection } from '../collections/types';
11
-
12
- export interface SelectStateProps<T = unknown> {
13
- /** The items to display in the select. */
14
- items: T[];
15
- /** Function to get the key for an item. */
16
- getKey?: (item: T) => Key;
17
- /** Function to get the text value for an item. */
18
- getTextValue?: (item: T) => string;
19
- /** Function to check if an item is disabled. */
20
- getDisabled?: (item: T) => boolean;
21
- /** Keys of disabled items. */
22
- disabledKeys?: Iterable<Key>;
23
- /** The currently selected key (controlled). */
24
- selectedKey?: Key | null;
25
- /** The default selected key (uncontrolled). */
26
- defaultSelectedKey?: Key | null;
27
- /** Handler called when the selection changes. */
28
- onSelectionChange?: (key: Key | null) => void;
29
- /** Whether the select is open (controlled). */
30
- isOpen?: boolean;
31
- /** Whether the select is open by default (uncontrolled). */
32
- defaultOpen?: boolean;
33
- /** Handler called when the open state changes. */
34
- onOpenChange?: (isOpen: boolean) => void;
35
- /** Whether the select is disabled. */
36
- isDisabled?: boolean;
37
- /** Whether the select is required. */
38
- isRequired?: boolean;
39
- }
40
-
41
- export interface SelectState<T = unknown> {
42
- /** The collection of items. */
43
- readonly collection: Accessor<Collection<T>>;
44
- /** Whether the select dropdown is open. */
45
- readonly isOpen: Accessor<boolean>;
46
- /** Open the select dropdown. */
47
- open(): void;
48
- /** Close the select dropdown. */
49
- close(): void;
50
- /** Toggle the select dropdown. */
51
- toggle(): void;
52
- /** The currently selected key. */
53
- readonly selectedKey: Accessor<Key | null>;
54
- /** The currently selected item. */
55
- readonly selectedItem: Accessor<CollectionNode<T> | null>;
56
- /** Set the selected key. */
57
- setSelectedKey(key: Key | null): void;
58
- /** The currently focused key. */
59
- readonly focusedKey: Accessor<Key | null>;
60
- /** Set the focused key. */
61
- setFocusedKey(key: Key | null): void;
62
- /** Whether the select has focus. */
63
- readonly isFocused: Accessor<boolean>;
64
- /** Set whether the select has focus. */
65
- setFocused(isFocused: boolean): void;
66
- /** Whether a specific key is disabled. */
67
- isKeyDisabled(key: Key): boolean;
68
- /** Whether the select is disabled. */
69
- readonly isDisabled: boolean;
70
- /** Whether the select is required. */
71
- readonly isRequired: boolean;
72
- }
73
-
74
- /**
75
- * Creates state for a select component.
76
- * Combines list state with overlay trigger state for dropdown behavior.
77
- */
78
- export function createSelectState<T = unknown>(
79
- props: MaybeAccessor<SelectStateProps<T>>
80
- ): SelectState<T> {
81
- const getProps = () => access(props);
82
-
83
- // Overlay trigger state for open/close
84
- const overlayState = createOverlayTriggerState({
85
- get isOpen() {
86
- return getProps().isOpen;
87
- },
88
- get defaultOpen() {
89
- return getProps().defaultOpen;
90
- },
91
- get onOpenChange() {
92
- return getProps().onOpenChange;
93
- },
94
- });
95
-
96
- // Track selected key
97
- const isControlled = () => getProps().selectedKey !== undefined;
98
- const [internalSelectedKey, setInternalSelectedKey] = createSignal<Key | null>(
99
- getProps().defaultSelectedKey ?? null
100
- );
101
-
102
- const selectedKey: Accessor<Key | null> = () => {
103
- return isControlled() ? (getProps().selectedKey ?? null) : internalSelectedKey();
104
- };
105
-
106
- const setSelectedKey = (key: Key | null) => {
107
- if (!isControlled()) {
108
- setInternalSelectedKey(key);
109
- }
110
- getProps().onSelectionChange?.(key);
111
- };
112
-
113
- // Create list state with single selection
114
- const listState = createListState<T>({
115
- get items() {
116
- return getProps().items;
117
- },
118
- get getKey() {
119
- return getProps().getKey;
120
- },
121
- get getTextValue() {
122
- return getProps().getTextValue;
123
- },
124
- get getDisabled() {
125
- return getProps().getDisabled;
126
- },
127
- get disabledKeys() {
128
- return getProps().disabledKeys;
129
- },
130
- selectionMode: 'single',
131
- disallowEmptySelection: true,
132
- get selectedKeys() {
133
- const key = selectedKey();
134
- return key != null ? [key] : [];
135
- },
136
- onSelectionChange(keys) {
137
- // Get the first (and only) selected key
138
- if (keys === 'all') return; // Not applicable for single select
139
- const key = keys.size > 0 ? Array.from(keys)[0] : null;
140
- setSelectedKey(key);
141
- // Close the dropdown after selection
142
- overlayState.close();
143
- },
144
- });
145
-
146
- // Get the selected item from the collection
147
- const selectedItem: Accessor<CollectionNode<T> | null> = () => {
148
- const key = selectedKey();
149
- if (key == null) return null;
150
- return listState.collection().getItem(key);
151
- };
152
-
153
- return {
154
- // Collection
155
- collection: listState.collection,
156
-
157
- // Focus management
158
- focusedKey: listState.focusedKey,
159
- setFocusedKey: listState.setFocusedKey,
160
- isFocused: listState.isFocused,
161
- setFocused: listState.setFocused,
162
-
163
- // Overlay state
164
- isOpen: overlayState.isOpen,
165
- open: overlayState.open,
166
- close: overlayState.close,
167
- toggle: overlayState.toggle,
168
-
169
- // Select-specific
170
- selectedKey,
171
- selectedItem,
172
- setSelectedKey,
173
- isKeyDisabled: (key: Key) => listState.isDisabled(key),
174
- get isDisabled() {
175
- return getProps().isDisabled ?? false;
176
- },
177
- get isRequired() {
178
- return getProps().isRequired ?? false;
179
- },
180
- };
181
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,GACjB,MAAM,qBAAqB,CAAC"}
@@ -1,5 +0,0 @@
1
- export {
2
- createSelectState,
3
- type SelectStateProps,
4
- type SelectState,
5
- } from './createSelectState';
@@ -1 +0,0 @@
1
- {"version":3,"file":"createSliderState.d.ts","sourceRoot":"","sources":["createSliderState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAA4B,MAAM,UAAU,CAAC;AACnE,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAEtD,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE1D,MAAM,WAAW,gBAAgB;IAC/B,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MA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IACpC,SAAS,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,sCAAsC;IACtC,UAAU,EAAE,OAAO,CAAC;CACrB;AAwBD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,aAAa,CAAC,gBAAgB,CAAC,GACrC,WAAW,CA+Gb"}
@@ -1,211 +0,0 @@
1
- /**
2
- * Creates state for a slider component.
3
- * Based on @react-stately/slider useSliderState.
4
- */
5
-
6
- import { type Accessor, createSignal, createMemo } from 'solid-js';
7
- import { access, type MaybeAccessor } from '../utils';
8
-
9
- export type SliderOrientation = 'horizontal' | 'vertical';
10
-
11
- export interface SliderStateProps {
12
- /** The current value (controlled). */
13
- value?: number;
14
- /** The default value (uncontrolled). */
15
- defaultValue?: number;
16
- /** Handler called when the value changes. */
17
- onChange?: (value: number) => void;
18
- /** Handler called when the user stops dragging. */
19
- onChangeEnd?: (value: number) => void;
20
- /** The minimum value. */
21
- minValue?: number;
22
- /** The maximum value. */
23
- maxValue?: number;
24
- /** The step value. */
25
- step?: number;
26
- /** The orientation of the slider. */
27
- orientation?: SliderOrientation;
28
- /** Whether the slider is disabled. */
29
- isDisabled?: boolean;
30
- /** The locale for number formatting. */
31
- locale?: string;
32
- /** Number format options. */
33
- formatOptions?: Intl.NumberFormatOptions;
34
- }
35
-
36
- export interface SliderState {
37
- /** The current value. */
38
- value: Accessor<number>;
39
- /** Sets the value. */
40
- setValue: (value: number) => void;
41
- /** Sets the value by percent (0-1). */
42
- setValuePercent: (percent: number) => void;
43
- /** Gets the value as a percent (0-1). */
44
- getValuePercent: Accessor<number>;
45
- /** Gets the formatted value string. */
46
- getFormattedValue: Accessor<string>;
47
- /** Whether the thumb is being dragged. */
48
- isDragging: Accessor<boolean>;
49
- /** Sets the dragging state. */
50
- setDragging: (dragging: boolean) => void;
51
- /** Whether the slider is focused. */
52
- isFocused: Accessor<boolean>;
53
- /** Sets the focused state. */
54
- setFocused: (focused: boolean) => void;
55
- /** Increments the value by step. */
56
- increment: (stepMultiplier?: number) => void;
57
- /** Decrements the value by step. */
58
- decrement: (stepMultiplier?: number) => void;
59
- /** The minimum value. */
60
- minValue: number;
61
- /** The maximum value. */
62
- maxValue: number;
63
- /** The step value. */
64
- step: number;
65
- /** The page step (larger step for Page Up/Down). */
66
- pageStep: number;
67
- /** The orientation. */
68
- orientation: SliderOrientation;
69
- /** Whether the slider is disabled. */
70
- isDisabled: boolean;
71
- }
72
-
73
- const DEFAULT_MIN = 0;
74
- const DEFAULT_MAX = 100;
75
- const DEFAULT_STEP = 1;
76
-
77
- /**
78
- * Clamps a value between min and max.
79
- */
80
- function clamp(value: number, min: number, max: number): number {
81
- return Math.min(Math.max(value, min), max);
82
- }
83
-
84
- /**
85
- * Snaps a value to the nearest step.
86
- */
87
- function snapToStep(value: number, min: number, max: number, step: number): number {
88
- const snapped = Math.round((value - min) / step) * step + min;
89
- // Handle floating point precision issues
90
- const decimalPlaces = (step.toString().split('.')[1] || '').length;
91
- const rounded = parseFloat(snapped.toFixed(decimalPlaces));
92
- return clamp(rounded, min, max);
93
- }
94
-
95
- /**
96
- * Provides state management for a slider component.
97
- */
98
- export function createSliderState(
99
- props: MaybeAccessor<SliderStateProps>
100
- ): SliderState {
101
- const getProps = () => access(props);
102
-
103
- // Get static values with defaults
104
- const minValue = getProps().minValue ?? DEFAULT_MIN;
105
- const maxValue = getProps().maxValue ?? DEFAULT_MAX;
106
- const step = getProps().step ?? DEFAULT_STEP;
107
- const orientation = getProps().orientation ?? 'horizontal';
108
- const isDisabled = getProps().isDisabled ?? false;
109
-
110
- // Calculate page step (10% of range, snapped to step)
111
- const pageStep = Math.max(step, snapToStep((maxValue - minValue) / 10, 0, maxValue - minValue, step));
112
-
113
- // Controlled vs uncontrolled
114
- const isControlled = () => getProps().value !== undefined;
115
-
116
- // Internal signal for uncontrolled mode
117
- const [internalValue, setInternalValue] = createSignal(
118
- snapToStep(getProps().defaultValue ?? minValue, minValue, maxValue, step)
119
- );
120
-
121
- // Dragging and focus state
122
- const [isDragging, setIsDragging] = createSignal(false);
123
- const [isFocused, setIsFocused] = createSignal(false);
124
-
125
- // Current value accessor
126
- const value = createMemo(() => {
127
- const p = getProps();
128
- const rawValue = isControlled() ? (p.value ?? minValue) : internalValue();
129
- return snapToStep(rawValue, minValue, maxValue, step);
130
- });
131
-
132
- // Value as percent (0-1)
133
- const getValuePercent = createMemo(() => {
134
- return (value() - minValue) / (maxValue - minValue);
135
- });
136
-
137
- // Formatted value
138
- const getFormattedValue = createMemo(() => {
139
- const p = getProps();
140
- const formatter = new Intl.NumberFormat(p.locale, p.formatOptions);
141
- return formatter.format(value());
142
- });
143
-
144
- // Set value function
145
- const setValue = (newValue: number) => {
146
- if (isDisabled) return;
147
-
148
- const p = getProps();
149
- const snappedValue = snapToStep(newValue, minValue, maxValue, step);
150
-
151
- if (!isControlled()) {
152
- setInternalValue(snappedValue);
153
- }
154
-
155
- p.onChange?.(snappedValue);
156
- };
157
-
158
- // Set value by percent
159
- const setValuePercent = (percent: number) => {
160
- const clampedPercent = clamp(percent, 0, 1);
161
- const newValue = clampedPercent * (maxValue - minValue) + minValue;
162
- setValue(newValue);
163
- };
164
-
165
- // Dragging state management
166
- const setDragging = (dragging: boolean) => {
167
- const wasDragging = isDragging();
168
- setIsDragging(dragging);
169
-
170
- // Call onChangeEnd when dragging stops
171
- if (wasDragging && !dragging) {
172
- getProps().onChangeEnd?.(value());
173
- }
174
- };
175
-
176
- // Increment/decrement
177
- const increment = (stepMultiplier = 1) => {
178
- if (isDisabled) return;
179
- setValue(value() + step * stepMultiplier);
180
- };
181
-
182
- const decrement = (stepMultiplier = 1) => {
183
- if (isDisabled) return;
184
- setValue(value() - step * stepMultiplier);
185
- };
186
-
187
- // Set focused state
188
- const setFocused = (focused: boolean) => {
189
- setIsFocused(focused);
190
- };
191
-
192
- return {
193
- value,
194
- setValue,
195
- setValuePercent,
196
- getValuePercent,
197
- getFormattedValue,
198
- isDragging,
199
- setDragging,
200
- isFocused,
201
- setFocused,
202
- increment,
203
- decrement,
204
- minValue,
205
- maxValue,
206
- step,
207
- pageStep,
208
- orientation,
209
- isDisabled,
210
- };
211
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
@@ -1,6 +0,0 @@
1
- export { createSliderState } from './createSliderState';
2
- export type {
3
- SliderState,
4
- SliderStateProps,
5
- SliderOrientation,
6
- } from './createSliderState';
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;GAEG;AACH,eAAO,MAAM,QAAQ,SAAY,CAAC;AAElC;;;GAGG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAKnD;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,SAAY,CAAC"}
package/src/ssr/index.ts DELETED
@@ -1,41 +0,0 @@
1
- /**
2
- * SSR utilities for Solid Stately
3
- *
4
- * SolidJS has built-in SSR support with `isServer` and `createUniqueId()`.
5
- * These utilities provide a consistent API matching React-Stately's patterns.
6
- */
7
-
8
- import { createUniqueId } from 'solid-js';
9
- import { isServer as _isServer } from 'solid-js/web';
10
-
11
- /**
12
- * Re-export isServer from solid-js/web for convenience.
13
- */
14
- export const isServer = _isServer;
15
-
16
- /**
17
- * Returns whether the component is currently being server side rendered.
18
- * Can be used to delay browser-specific rendering until after hydration.
19
- */
20
- export function createIsSSR(): boolean {
21
- return isServer;
22
- }
23
-
24
- /**
25
- * Generate a unique ID that is stable across server and client.
26
- * Uses SolidJS's built-in createUniqueId which handles SSR correctly.
27
- *
28
- * @param defaultId - Optional default ID to use instead of generating one.
29
- */
30
- export function createId(defaultId?: string): string {
31
- if (defaultId) {
32
- return defaultId;
33
- }
34
- return `solid-stately-${createUniqueId()}`;
35
- }
36
-
37
- /**
38
- * Check if we can use DOM APIs.
39
- * This is useful for code that needs to run only in the browser.
40
- */
41
- export const canUseDOM = !isServer;
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableCollection.d.ts","sourceRoot":"","sources":["TableCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAgB,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EACV,eAAe,IAAI,gBAAgB,EACnC,sBAAsB,EAGvB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,eAAe,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,gBAAgB,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,oBAAoB,CAAW;IACvC,OAAO,CAAC,KAAK,CAAa;gBAEd,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC;IAuD9C,OAAO,CAAC,YAAY;IAmCpB,OAAO,CAAC,eAAe;IA6BvB,OAAO,CAAC,6BAA6B;IAUr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