@proyecto-viviana/solid-stately 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -283
  3. package/dist/autocomplete/createAutocompleteState.d.ts +3 -2
  4. package/dist/autocomplete/index.d.ts +1 -1
  5. package/dist/calendar/createCalendarState.d.ts +22 -7
  6. package/dist/calendar/createDateFieldState.d.ts +30 -7
  7. package/dist/calendar/createDatePickerState.d.ts +60 -0
  8. package/dist/calendar/createRangeCalendarState.d.ts +27 -8
  9. package/dist/calendar/createTimeFieldState.d.ts +34 -7
  10. package/dist/calendar/index.d.ts +7 -6
  11. package/dist/checkbox/createCheckboxGroupState.d.ts +12 -3
  12. package/dist/checkbox/index.d.ts +1 -1
  13. package/dist/collections/ListCollection.d.ts +1 -1
  14. package/dist/collections/createListState.d.ts +8 -8
  15. package/dist/collections/createMenuState.d.ts +7 -7
  16. package/dist/collections/createSelectionState.d.ts +5 -5
  17. package/dist/collections/index.d.ts +5 -5
  18. package/dist/collections/types.d.ts +23 -12
  19. package/dist/color/Color.d.ts +1 -1
  20. package/dist/color/createColorAreaState.d.ts +4 -2
  21. package/dist/color/createColorFieldState.d.ts +38 -12
  22. package/dist/color/createColorSliderState.d.ts +9 -2
  23. package/dist/color/createColorWheelState.d.ts +13 -2
  24. package/dist/color/getColorChannels.d.ts +20 -0
  25. package/dist/color/index.d.ts +6 -6
  26. package/dist/color/types.d.ts +4 -4
  27. package/dist/combobox/createComboBoxState.d.ts +27 -13
  28. package/dist/combobox/index.d.ts +1 -1
  29. package/dist/data/createAsyncList.d.ts +111 -0
  30. package/dist/data/createListData.d.ts +65 -0
  31. package/dist/data/createTreeData.d.ts +65 -0
  32. package/dist/data/index.d.ts +3 -0
  33. package/dist/datepicker/index.d.ts +8 -0
  34. package/dist/disclosure/createDisclosureState.d.ts +2 -2
  35. package/dist/disclosure/index.d.ts +1 -1
  36. package/dist/dnd/createDragState.d.ts +2 -2
  37. package/dist/dnd/createDraggableCollectionState.d.ts +2 -2
  38. package/dist/dnd/createDropState.d.ts +2 -2
  39. package/dist/dnd/createDroppableCollectionState.d.ts +3 -3
  40. package/dist/dnd/index.d.ts +5 -5
  41. package/dist/dnd/types.d.ts +16 -16
  42. package/dist/form/createFormValidationState.d.ts +3 -3
  43. package/dist/form/index.d.ts +1 -1
  44. package/dist/grid/createGridState.d.ts +2 -2
  45. package/dist/grid/index.d.ts +2 -2
  46. package/dist/grid/types.d.ts +17 -11
  47. package/dist/index.d.ts +31 -25
  48. package/dist/index.js +7990 -6264
  49. package/dist/index.js.map +1 -7
  50. package/dist/menu/index.d.ts +8 -0
  51. package/dist/numberfield/createNumberFieldState.d.ts +2 -2
  52. package/dist/numberfield/index.d.ts +1 -1
  53. package/dist/overlays/createOverlayTriggerState.d.ts +2 -2
  54. package/dist/overlays/index.d.ts +1 -1
  55. package/dist/radio/createRadioGroupState.d.ts +13 -4
  56. package/dist/radio/index.d.ts +1 -1
  57. package/dist/searchfield/createSearchFieldState.d.ts +2 -2
  58. package/dist/searchfield/index.d.ts +2 -2
  59. package/dist/select/createSelectState.d.ts +20 -3
  60. package/dist/select/index.d.ts +1 -1
  61. package/dist/selection/index.d.ts +11 -0
  62. package/dist/slider/createSliderState.d.ts +3 -3
  63. package/dist/slider/index.d.ts +2 -2
  64. package/dist/steplist/createStepListState.d.ts +48 -0
  65. package/dist/steplist/index.d.ts +1 -0
  66. package/dist/table/TableCollection.d.ts +3 -3
  67. package/dist/table/createTableColumnResizeState.d.ts +54 -0
  68. package/dist/table/createTableState.d.ts +2 -2
  69. package/dist/table/index.d.ts +5 -3
  70. package/dist/table/types.d.ts +10 -10
  71. package/dist/tabs/createTabListState.d.ts +5 -5
  72. package/dist/tabs/index.d.ts +1 -1
  73. package/dist/textfield/createTextFieldState.d.ts +2 -2
  74. package/dist/textfield/index.d.ts +1 -1
  75. package/dist/toast/createToastState.d.ts +15 -3
  76. package/dist/toast/index.d.ts +1 -1
  77. package/dist/toggle/createToggleGroupState.d.ts +45 -0
  78. package/dist/toggle/createToggleState.d.ts +2 -2
  79. package/dist/toggle/index.d.ts +2 -1
  80. package/dist/tooltip/createTooltipTriggerState.d.ts +2 -2
  81. package/dist/tooltip/index.d.ts +1 -1
  82. package/dist/tree/TreeCollection.d.ts +5 -4
  83. package/dist/tree/createTreeState.d.ts +2 -2
  84. package/dist/tree/index.d.ts +3 -3
  85. package/dist/tree/types.d.ts +19 -13
  86. package/dist/utils/index.d.ts +1 -1
  87. package/dist/utils/reactivity.d.ts +1 -1
  88. package/package.json +30 -30
  89. package/src/autocomplete/createAutocompleteState.d.ts +19 -17
  90. package/src/autocomplete/createAutocompleteState.ts +25 -32
  91. package/src/autocomplete/index.d.ts +6 -2
  92. package/src/autocomplete/index.ts +1 -1
  93. package/src/calendar/createCalendarState.d.ts +139 -117
  94. package/src/calendar/createCalendarState.ts +221 -74
  95. package/src/calendar/createDateFieldState.d.ts +130 -95
  96. package/src/calendar/createDateFieldState.ts +286 -151
  97. package/src/calendar/createDatePickerState.ts +347 -0
  98. package/src/calendar/createRangeCalendarState.d.ts +154 -129
  99. package/src/calendar/createRangeCalendarState.ts +293 -79
  100. package/src/calendar/createTimeFieldState.d.ts +81 -79
  101. package/src/calendar/createTimeFieldState.ts +187 -108
  102. package/src/calendar/index.d.ts +80 -7
  103. package/src/calendar/index.ts +21 -12
  104. package/src/checkbox/createCheckboxGroupState.d.ts +57 -55
  105. package/src/checkbox/createCheckboxGroupState.ts +57 -30
  106. package/src/checkbox/index.d.ts +6 -2
  107. package/src/checkbox/index.ts +1 -1
  108. package/src/collections/ListCollection.d.ts +25 -22
  109. package/src/collections/ListCollection.ts +152 -146
  110. package/src/collections/createListState.d.ts +73 -58
  111. package/src/collections/createListState.ts +267 -264
  112. package/src/collections/createMenuState.d.ts +36 -31
  113. package/src/collections/createMenuState.ts +112 -106
  114. package/src/collections/createSelectionState.d.ts +78 -65
  115. package/src/collections/createSelectionState.ts +340 -336
  116. package/src/collections/index.d.ts +38 -6
  117. package/src/collections/index.ts +41 -46
  118. package/src/collections/types.d.ts +101 -101
  119. package/src/collections/types.ts +181 -169
  120. package/src/color/Color.d.ts +20 -5
  121. package/src/color/Color.ts +1054 -951
  122. package/src/color/createColorAreaState.d.ts +67 -65
  123. package/src/color/createColorAreaState.ts +301 -293
  124. package/src/color/createColorFieldState.d.ts +46 -44
  125. package/src/color/createColorFieldState.ts +428 -292
  126. package/src/color/createColorSliderState.d.ts +58 -56
  127. package/src/color/createColorSliderState.ts +272 -241
  128. package/src/color/createColorWheelState.d.ts +42 -40
  129. package/src/color/createColorWheelState.ts +248 -211
  130. package/src/color/getColorChannels.ts +36 -0
  131. package/src/color/index.d.ts +36 -7
  132. package/src/color/index.ts +44 -47
  133. package/src/color/types.d.ts +68 -63
  134. package/src/color/types.ts +119 -127
  135. package/src/combobox/createComboBoxState.d.ts +107 -105
  136. package/src/combobox/createComboBoxState.ts +790 -703
  137. package/src/combobox/index.d.ts +10 -2
  138. package/src/combobox/index.ts +13 -13
  139. package/src/data/createAsyncList.ts +403 -0
  140. package/src/data/createListData.ts +298 -0
  141. package/src/data/createTreeData.ts +646 -0
  142. package/src/data/index.ts +25 -0
  143. package/src/datepicker/index.ts +32 -0
  144. package/src/disclosure/createDisclosureState.d.ts +47 -43
  145. package/src/disclosure/createDisclosureState.ts +9 -23
  146. package/src/disclosure/index.d.ts +10 -2
  147. package/src/disclosure/index.ts +1 -1
  148. package/src/dnd/createDragState.d.ts +51 -42
  149. package/src/dnd/createDragState.ts +151 -153
  150. package/src/dnd/createDraggableCollectionState.d.ts +52 -41
  151. package/src/dnd/createDraggableCollectionState.ts +158 -165
  152. package/src/dnd/createDropState.d.ts +64 -45
  153. package/src/dnd/createDropState.ts +202 -212
  154. package/src/dnd/createDroppableCollectionState.d.ts +88 -59
  155. package/src/dnd/createDroppableCollectionState.ts +354 -357
  156. package/src/dnd/index.d.ts +54 -6
  157. package/src/dnd/index.ts +63 -76
  158. package/src/dnd/types.d.ts +167 -156
  159. package/src/dnd/types.ts +316 -317
  160. package/src/form/createFormValidationState.d.ts +47 -45
  161. package/src/form/createFormValidationState.ts +356 -389
  162. package/src/form/index.d.ts +16 -2
  163. package/src/form/index.ts +15 -15
  164. package/src/grid/createGridState.d.ts +7 -4
  165. package/src/grid/createGridState.ts +44 -51
  166. package/src/grid/index.d.ts +3 -3
  167. package/src/grid/index.ts +2 -8
  168. package/src/grid/types.d.ts +136 -129
  169. package/src/grid/types.ts +24 -17
  170. package/src/index.d.ts +310 -26
  171. package/src/index.ts +87 -79
  172. package/src/menu/index.ts +17 -0
  173. package/src/numberfield/createNumberFieldState.d.ts +56 -54
  174. package/src/numberfield/createNumberFieldState.ts +422 -383
  175. package/src/numberfield/index.d.ts +6 -2
  176. package/src/numberfield/index.ts +5 -5
  177. package/src/overlays/createOverlayTriggerState.d.ts +22 -20
  178. package/src/overlays/createOverlayTriggerState.ts +66 -67
  179. package/src/overlays/index.d.ts +6 -2
  180. package/src/overlays/index.ts +5 -5
  181. package/src/radio/createRadioGroupState.d.ts +54 -52
  182. package/src/radio/createRadioGroupState.ts +66 -30
  183. package/src/radio/index.d.ts +7 -2
  184. package/src/radio/index.ts +1 -1
  185. package/src/searchfield/createSearchFieldState.d.ts +16 -14
  186. package/src/searchfield/createSearchFieldState.ts +56 -62
  187. package/src/searchfield/index.d.ts +3 -3
  188. package/src/searchfield/index.ts +2 -5
  189. package/src/select/createSelectState.d.ts +63 -61
  190. package/src/select/createSelectState.ts +290 -181
  191. package/src/select/index.d.ts +2 -2
  192. package/src/select/index.ts +1 -5
  193. package/src/selection/index.ts +27 -0
  194. package/src/slider/createSliderState.d.ts +60 -60
  195. package/src/slider/createSliderState.ts +233 -211
  196. package/src/slider/index.d.ts +3 -3
  197. package/src/slider/index.ts +2 -6
  198. package/src/ssr/index.d.ts +1 -1
  199. package/src/ssr/index.ts +2 -2
  200. package/src/steplist/createStepListState.ts +191 -0
  201. package/src/steplist/index.ts +5 -0
  202. package/src/table/TableCollection.d.ts +42 -40
  203. package/src/table/TableCollection.ts +61 -64
  204. package/src/table/createTableColumnResizeState.ts +242 -0
  205. package/src/table/createTableState.d.ts +7 -4
  206. package/src/table/createTableState.ts +10 -7
  207. package/src/table/index.d.ts +14 -4
  208. package/src/table/index.ts +10 -3
  209. package/src/table/types.d.ts +98 -92
  210. package/src/table/types.ts +17 -13
  211. package/src/tabs/createTabListState.d.ts +59 -57
  212. package/src/tabs/createTabListState.ts +58 -39
  213. package/src/tabs/index.d.ts +8 -2
  214. package/src/tabs/index.ts +1 -1
  215. package/src/textfield/createTextFieldState.d.ts +16 -14
  216. package/src/textfield/createTextFieldState.ts +7 -18
  217. package/src/textfield/index.d.ts +6 -2
  218. package/src/textfield/index.ts +1 -1
  219. package/src/toast/createToastState.d.ts +92 -81
  220. package/src/toast/createToastState.ts +56 -44
  221. package/src/toast/index.d.ts +12 -2
  222. package/src/toast/index.ts +1 -1
  223. package/src/toggle/createToggleGroupState.ts +117 -0
  224. package/src/toggle/createToggleState.d.ts +19 -19
  225. package/src/toggle/createToggleState.ts +2 -16
  226. package/src/toggle/index.d.ts +2 -2
  227. package/src/toggle/index.ts +6 -4
  228. package/src/tooltip/createTooltipTriggerState.d.ts +17 -17
  229. package/src/tooltip/createTooltipTriggerState.ts +184 -183
  230. package/src/tooltip/index.d.ts +7 -2
  231. package/src/tooltip/index.ts +6 -6
  232. package/src/tree/TreeCollection.d.ts +26 -23
  233. package/src/tree/TreeCollection.ts +215 -175
  234. package/src/tree/createTreeState.d.ts +7 -4
  235. package/src/tree/createTreeState.ts +390 -392
  236. package/src/tree/index.d.ts +10 -4
  237. package/src/tree/index.ts +13 -13
  238. package/src/tree/types.d.ts +131 -126
  239. package/src/tree/types.ts +183 -174
  240. package/src/utils/index.d.ts +2 -2
  241. package/src/utils/index.ts +1 -1
  242. package/src/utils/reactivity.d.ts +2 -2
  243. package/src/utils/reactivity.ts +3 -3
@@ -6,66 +6,68 @@
6
6
  *
7
7
  * This is a 1:1 port of @react-stately/checkbox's useCheckboxGroupState.
8
8
  */
9
- import { Accessor } from 'solid-js';
10
- import { type MaybeAccessor } from '../utils';
9
+ import { Accessor } from "solid-js";
10
+ import { type MaybeAccessor } from "../utils";
11
11
  export interface CheckboxGroupProps {
12
- /** The current selected values (controlled). */
13
- value?: string[];
14
- /** The default selected values (uncontrolled). */
15
- defaultValue?: string[];
16
- /** Handler that is called when the value changes. */
17
- onChange?: (value: string[]) => void;
18
- /** Whether the checkbox group is disabled. */
19
- isDisabled?: boolean;
20
- /** Whether the checkbox group is read only. */
21
- isReadOnly?: boolean;
22
- /** Whether the checkbox group is required. */
23
- isRequired?: boolean;
24
- /** Whether the checkbox group is invalid. */
25
- isInvalid?: boolean;
26
- /** The name of the checkbox group, used when submitting an HTML form. */
27
- name?: string;
28
- /** The form to associate the checkbox group with. */
29
- form?: string;
30
- /** The label for the checkbox group. */
31
- label?: string;
32
- /** Handler that is called when the checkbox group receives focus. */
33
- onFocus?: (e: FocusEvent) => void;
34
- /** Handler that is called when the checkbox group loses focus. */
35
- onBlur?: (e: FocusEvent) => void;
36
- /** Handler that is called when the checkbox group's focus status changes. */
37
- onFocusChange?: (isFocused: boolean) => void;
12
+ /** The current selected values (controlled). */
13
+ value?: string[];
14
+ /** The default selected values (uncontrolled). */
15
+ defaultValue?: string[];
16
+ /** Handler that is called when the value changes. */
17
+ onChange?: (value: string[]) => void;
18
+ /** Whether the checkbox group is disabled. */
19
+ isDisabled?: boolean;
20
+ /** Whether the checkbox group is read only. */
21
+ isReadOnly?: boolean;
22
+ /** Whether the checkbox group is required. */
23
+ isRequired?: boolean;
24
+ /** Whether the checkbox group is invalid. */
25
+ isInvalid?: boolean;
26
+ /** The name of the checkbox group, used when submitting an HTML form. */
27
+ name?: string;
28
+ /** The form to associate the checkbox group with. */
29
+ form?: string;
30
+ /** The label for the checkbox group. */
31
+ label?: string;
32
+ /** Handler that is called when the checkbox group receives focus. */
33
+ onFocus?: (e: FocusEvent) => void;
34
+ /** Handler that is called when the checkbox group loses focus. */
35
+ onBlur?: (e: FocusEvent) => void;
36
+ /** Handler that is called when the checkbox group's focus status changes. */
37
+ onFocusChange?: (isFocused: boolean) => void;
38
38
  }
39
39
  export interface CheckboxGroupState {
40
- /** Current selected values. */
41
- readonly value: Accessor<readonly string[]>;
42
- /** Default selected values. */
43
- readonly defaultValue: readonly string[];
44
- /** Whether the checkbox group is disabled. */
45
- readonly isDisabled: boolean;
46
- /** Whether the checkbox group is read only. */
47
- readonly isReadOnly: boolean;
48
- /** Whether the checkbox group is invalid. */
49
- readonly isInvalid: boolean;
50
- /**
51
- * Whether the checkboxes in the group are required.
52
- * This changes to false once at least one item is selected.
53
- */
54
- readonly isRequired: Accessor<boolean>;
55
- /** Returns whether the given value is selected. */
56
- isSelected(value: string): boolean;
57
- /** Sets the selected values. */
58
- setValue(value: string[]): void;
59
- /** Adds a value to the set of selected values. */
60
- addValue(value: string): void;
61
- /** Removes a value from the set of selected values. */
62
- removeValue(value: string): void;
63
- /** Toggles a value in the set of selected values. */
64
- toggleValue(value: string): void;
40
+ /** Current selected values. */
41
+ readonly value: Accessor<readonly string[]>;
42
+ /** Default selected values. */
43
+ readonly defaultValue: readonly string[];
44
+ /** Whether the checkbox group is disabled. */
45
+ readonly isDisabled: boolean;
46
+ /** Whether the checkbox group is read only. */
47
+ readonly isReadOnly: boolean;
48
+ /** Whether the checkbox group is invalid. */
49
+ readonly isInvalid: boolean;
50
+ /**
51
+ * Whether the checkboxes in the group are required.
52
+ * This changes to false once at least one item is selected.
53
+ */
54
+ readonly isRequired: Accessor<boolean>;
55
+ /** Returns whether the given value is selected. */
56
+ isSelected(value: string): boolean;
57
+ /** Sets the selected values. */
58
+ setValue(value: string[]): void;
59
+ /** Adds a value to the set of selected values. */
60
+ addValue(value: string): void;
61
+ /** Removes a value from the set of selected values. */
62
+ removeValue(value: string): void;
63
+ /** Toggles a value in the set of selected values. */
64
+ toggleValue(value: string): void;
65
65
  }
66
66
  /**
67
67
  * Provides state management for a checkbox group component.
68
68
  * Provides a name for the group, and manages selection and focus state.
69
69
  */
70
- export declare function createCheckboxGroupState(props?: MaybeAccessor<CheckboxGroupProps>): CheckboxGroupState;
71
- //# sourceMappingURL=createCheckboxGroupState.d.ts.map
70
+ export declare function createCheckboxGroupState(
71
+ props?: MaybeAccessor<CheckboxGroupProps>,
72
+ ): CheckboxGroupState;
73
+ //# sourceMappingURL=createCheckboxGroupState.d.ts.map
@@ -7,12 +7,14 @@
7
7
  * This is a 1:1 port of @react-stately/checkbox's useCheckboxGroupState.
8
8
  */
9
9
 
10
- import { createSignal, Accessor } from 'solid-js';
11
- import { type MaybeAccessor, access } from '../utils';
12
-
13
- // ============================================
14
- // TYPES
15
- // ============================================
10
+ import { createMemo, createSignal, Accessor } from "solid-js";
11
+ import { type MaybeAccessor, access } from "../utils";
12
+ import {
13
+ createFormValidationState,
14
+ type FormValidationState,
15
+ type ValidationFunction,
16
+ type ValidationResult,
17
+ } from "../form";
16
18
 
17
19
  export interface CheckboxGroupProps {
18
20
  /** The current selected values (controlled). */
@@ -41,9 +43,22 @@ export interface CheckboxGroupProps {
41
43
  onBlur?: (e: FocusEvent) => void;
42
44
  /** Handler that is called when the checkbox group's focus status changes. */
43
45
  onFocusChange?: (isFocused: boolean) => void;
46
+ /** Backward-compatible controlled validation state. */
47
+ validationState?: "valid" | "invalid";
48
+ /** Custom validation function. */
49
+ validate?: ValidationFunction<readonly string[]>;
50
+ /** Validation behavior for the checkbox group. */
51
+ validationBehavior?: "aria" | "native";
44
52
  }
45
53
 
46
- export interface CheckboxGroupState {
54
+ export interface CheckboxGroupState extends Pick<
55
+ FormValidationState,
56
+ | "realtimeValidation"
57
+ | "displayValidation"
58
+ | "updateValidation"
59
+ | "resetValidation"
60
+ | "commitValidation"
61
+ > {
47
62
  /** Current selected values. */
48
63
  readonly value: Accessor<readonly string[]>;
49
64
  /** Default selected values. */
@@ -69,49 +84,60 @@ export interface CheckboxGroupState {
69
84
  removeValue(value: string): void;
70
85
  /** Toggles a value in the set of selected values. */
71
86
  toggleValue(value: string): void;
72
- }
73
87
 
74
- // ============================================
75
- // IMPLEMENTATION
76
- // ============================================
88
+ /** Current display validation result for the group. */
89
+ readonly displayValidation: Accessor<ValidationResult>;
90
+ }
77
91
 
78
92
  /**
79
93
  * Provides state management for a checkbox group component.
80
94
  * Provides a name for the group, and manages selection and focus state.
81
95
  */
82
96
  export function createCheckboxGroupState(
83
- props: MaybeAccessor<CheckboxGroupProps> = {}
97
+ props: MaybeAccessor<CheckboxGroupProps> = {},
84
98
  ): CheckboxGroupState {
85
99
  const getProps = () => access(props);
86
100
 
87
- // Get initial values
88
101
  const initialProps = getProps();
89
102
  const initialValue = initialProps.value ?? initialProps.defaultValue ?? [];
90
103
 
91
- // Create internal signal for uncontrolled mode
92
104
  const [internalValue, setInternalValue] = createSignal<readonly string[]>(initialValue);
93
105
 
94
- // Determine if controlled
95
- const isControlled = () => getProps().value !== undefined;
106
+ const controlledValue = createMemo<readonly string[] | undefined>(() => getProps().value);
107
+
108
+ const isControlled = () => controlledValue() !== undefined;
96
109
 
97
- // Get current value
98
110
  const value: Accessor<readonly string[]> = () => {
99
- const p = getProps();
100
- return isControlled() ? (p.value ?? []) : internalValue();
111
+ const controlled = controlledValue();
112
+ return controlled !== undefined ? controlled : internalValue();
101
113
  };
102
114
 
103
- // Check if required (true if isRequired and no items selected)
104
115
  const isRequired: Accessor<boolean> = () => {
105
116
  const p = getProps();
106
117
  return !!p.isRequired && value().length === 0;
107
118
  };
108
119
 
109
- // Check if invalid
110
- const isInvalid = () => {
111
- return getProps().isInvalid ?? false;
112
- };
120
+ const validation = createFormValidationState<readonly string[]>({
121
+ get value() {
122
+ return value();
123
+ },
124
+ get isInvalid() {
125
+ return getProps().isInvalid;
126
+ },
127
+ get validationState() {
128
+ return getProps().validationState;
129
+ },
130
+ get validate() {
131
+ return getProps().validate;
132
+ },
133
+ get validationBehavior() {
134
+ return getProps().validationBehavior ?? "native";
135
+ },
136
+ get name() {
137
+ return getProps().name;
138
+ },
139
+ });
113
140
 
114
- // Set value
115
141
  function setValue(newValue: string[]): void {
116
142
  const p = getProps();
117
143
  if (p.isReadOnly || p.isDisabled) {
@@ -125,12 +151,10 @@ export function createCheckboxGroupState(
125
151
  p.onChange?.(newValue);
126
152
  }
127
153
 
128
- // Check if value is selected
129
154
  function isSelected(checkValue: string): boolean {
130
155
  return value().includes(checkValue);
131
156
  }
132
157
 
133
- // Add value
134
158
  function addValue(addVal: string): void {
135
159
  const p = getProps();
136
160
  if (p.isReadOnly || p.isDisabled) {
@@ -143,7 +167,6 @@ export function createCheckboxGroupState(
143
167
  }
144
168
  }
145
169
 
146
- // Remove value
147
170
  function removeValue(removeVal: string): void {
148
171
  const p = getProps();
149
172
  if (p.isReadOnly || p.isDisabled) {
@@ -156,7 +179,6 @@ export function createCheckboxGroupState(
156
179
  }
157
180
  }
158
181
 
159
- // Toggle value
160
182
  function toggleValue(toggleVal: string): void {
161
183
  const p = getProps();
162
184
  if (p.isReadOnly || p.isDisabled) {
@@ -181,7 +203,7 @@ export function createCheckboxGroupState(
181
203
  return getProps().isReadOnly ?? false;
182
204
  },
183
205
  get isInvalid() {
184
- return isInvalid();
206
+ return validation.displayValidation().isInvalid;
185
207
  },
186
208
  isRequired,
187
209
  isSelected,
@@ -189,5 +211,10 @@ export function createCheckboxGroupState(
189
211
  addValue,
190
212
  removeValue,
191
213
  toggleValue,
214
+ realtimeValidation: validation.realtimeValidation,
215
+ displayValidation: validation.displayValidation,
216
+ updateValidation: validation.updateValidation,
217
+ resetValidation: validation.resetValidation,
218
+ commitValidation: validation.commitValidation,
192
219
  };
193
220
  }
@@ -1,2 +1,6 @@
1
- export { createCheckboxGroupState, type CheckboxGroupProps, type CheckboxGroupState, } from './createCheckboxGroupState';
2
- //# sourceMappingURL=index.d.ts.map
1
+ export {
2
+ createCheckboxGroupState,
3
+ type CheckboxGroupProps,
4
+ type CheckboxGroupState,
5
+ } from "./createCheckboxGroupState";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -2,4 +2,4 @@ export {
2
2
  createCheckboxGroupState,
3
3
  type CheckboxGroupProps,
4
4
  type CheckboxGroupState,
5
- } from './createCheckboxGroupState';
5
+ } from "./createCheckboxGroupState";
@@ -2,36 +2,39 @@
2
2
  * A simple list collection implementation.
3
3
  * Provides a Collection interface over an array of nodes.
4
4
  */
5
- import type { Collection, CollectionNode, Key } from './types';
5
+ import type { Collection, CollectionNode, Key } from "./types";
6
6
  /**
7
7
  * A basic implementation of Collection for list-based components.
8
8
  */
9
9
  export declare class ListCollection<T = unknown> implements Collection<T> {
10
- private nodes;
11
- private keyMap;
12
- constructor(nodes: CollectionNode<T>[]);
13
- get size(): number;
14
- [Symbol.iterator](): Iterator<CollectionNode<T>>;
15
- getKeys(): Iterable<Key>;
16
- getItem(key: Key): CollectionNode<T> | null;
17
- at(index: number): CollectionNode<T> | null;
18
- getKeyBefore(key: Key): Key | null;
19
- getKeyAfter(key: Key): Key | null;
20
- getFirstKey(): Key | null;
21
- getLastKey(): Key | null;
22
- getChildren(key: Key): Iterable<CollectionNode<T>>;
23
- getTextValue(key: Key): string;
24
- /**
25
- * Get all items (excluding sections, including items within sections).
26
- */
27
- private getAllItems;
10
+ private nodes;
11
+ private keyMap;
12
+ constructor(nodes: CollectionNode<T>[]);
13
+ get size(): number;
14
+ [Symbol.iterator](): Iterator<CollectionNode<T>>;
15
+ getKeys(): Iterable<Key>;
16
+ getItem(key: Key): CollectionNode<T> | null;
17
+ at(index: number): CollectionNode<T> | null;
18
+ getKeyBefore(key: Key): Key | null;
19
+ getKeyAfter(key: Key): Key | null;
20
+ getFirstKey(): Key | null;
21
+ getLastKey(): Key | null;
22
+ getChildren(key: Key): Iterable<CollectionNode<T>>;
23
+ getTextValue(key: Key): string;
24
+ /**
25
+ * Get all items (excluding sections, including items within sections).
26
+ */
27
+ private getAllItems;
28
28
  }
29
29
  /**
30
30
  * Create a collection from an array of items.
31
31
  */
32
- export declare function createListCollection<T>(items: T[], options?: {
32
+ export declare function createListCollection<T>(
33
+ items: T[],
34
+ options?: {
33
35
  getKey?: (item: T, index: number) => Key;
34
36
  getTextValue?: (item: T) => string;
35
37
  getDisabled?: (item: T) => boolean;
36
- }): ListCollection<T>;
37
- //# sourceMappingURL=ListCollection.d.ts.map
38
+ },
39
+ ): ListCollection<T>;
40
+ //# sourceMappingURL=ListCollection.d.ts.map
@@ -1,146 +1,152 @@
1
- /**
2
- * A simple list collection implementation.
3
- * Provides a Collection interface over an array of nodes.
4
- */
5
-
6
- import type { Collection, CollectionNode, Key } from './types';
7
-
8
- /**
9
- * A basic implementation of Collection for list-based components.
10
- */
11
- export class ListCollection<T = unknown> implements Collection<T> {
12
- private nodes: CollectionNode<T>[];
13
- private keyMap: Map<Key, CollectionNode<T>>;
14
-
15
- constructor(nodes: CollectionNode<T>[]) {
16
- this.nodes = nodes;
17
- this.keyMap = new Map();
18
-
19
- // Build key map for O(1) lookups
20
- const addToMap = (node: CollectionNode<T>) => {
21
- this.keyMap.set(node.key, node);
22
- if (node.childNodes) {
23
- for (const child of node.childNodes) {
24
- addToMap(child);
25
- }
26
- }
27
- };
28
-
29
- for (const node of nodes) {
30
- addToMap(node);
31
- }
32
- }
33
-
34
- get size(): number {
35
- return this.keyMap.size;
36
- }
37
-
38
- *[Symbol.iterator](): Iterator<CollectionNode<T>> {
39
- yield* this.nodes;
40
- }
41
-
42
- *getKeys(): Iterable<Key> {
43
- for (const node of this.keyMap.values()) {
44
- yield node.key;
45
- }
46
- }
47
-
48
- getItem(key: Key): CollectionNode<T> | null {
49
- return this.keyMap.get(key) ?? null;
50
- }
51
-
52
- at(index: number): CollectionNode<T> | null {
53
- // Flatten all items for indexing
54
- const items = this.getAllItems();
55
- return items[index] ?? null;
56
- }
57
-
58
- getKeyBefore(key: Key): Key | null {
59
- const items = this.getAllItems();
60
- const index = items.findIndex((item) => item.key === key);
61
- if (index <= 0) return null;
62
- return items[index - 1].key;
63
- }
64
-
65
- getKeyAfter(key: Key): Key | null {
66
- const items = this.getAllItems();
67
- const index = items.findIndex((item) => item.key === key);
68
- if (index < 0 || index >= items.length - 1) return null;
69
- return items[index + 1].key;
70
- }
71
-
72
- getFirstKey(): Key | null {
73
- const items = this.getAllItems();
74
- return items[0]?.key ?? null;
75
- }
76
-
77
- getLastKey(): Key | null {
78
- const items = this.getAllItems();
79
- return items[items.length - 1]?.key ?? null;
80
- }
81
-
82
- *getChildren(key: Key): Iterable<CollectionNode<T>> {
83
- const node = this.getItem(key);
84
- if (node?.childNodes) {
85
- yield* node.childNodes;
86
- }
87
- }
88
-
89
- getTextValue(key: Key): string {
90
- return this.getItem(key)?.textValue ?? '';
91
- }
92
-
93
- /**
94
- * Get all items (excluding sections, including items within sections).
95
- */
96
- private getAllItems(): CollectionNode<T>[] {
97
- const items: CollectionNode<T>[] = [];
98
-
99
- const addItems = (nodes: CollectionNode<T>[]) => {
100
- for (const node of nodes) {
101
- if (node.type === 'item') {
102
- items.push(node);
103
- } else if (node.type === 'section' && node.childNodes) {
104
- addItems(node.childNodes);
105
- }
106
- }
107
- };
108
-
109
- addItems(this.nodes);
110
- return items;
111
- }
112
- }
113
-
114
- /**
115
- * Create a collection from an array of items.
116
- */
117
- export function createListCollection<T>(
118
- items: T[],
119
- options: {
120
- getKey?: (item: T, index: number) => Key;
121
- getTextValue?: (item: T) => string;
122
- getDisabled?: (item: T) => boolean;
123
- } = {}
124
- ): ListCollection<T> {
125
- const {
126
- getKey = (item: T, index: number) => (item as any).key ?? (item as any).id ?? index,
127
- getTextValue = (item: T) => (item as any).textValue ?? (item as any).label ?? String(item),
128
- getDisabled = (item: T) => (item as any).isDisabled ?? false,
129
- } = options;
130
-
131
- const nodes: CollectionNode<T>[] = items.map((item, index) => ({
132
- type: 'item' as const,
133
- key: getKey(item, index),
134
- value: item,
135
- textValue: getTextValue(item),
136
- rendered: null as any, // Will be set by component
137
- level: 0,
138
- index,
139
- parentKey: null,
140
- hasChildNodes: false,
141
- childNodes: [],
142
- isDisabled: getDisabled(item),
143
- }));
144
-
145
- return new ListCollection(nodes);
146
- }
1
+ /**
2
+ * A simple list collection implementation.
3
+ * Provides a Collection interface over an array of nodes.
4
+ */
5
+
6
+ import type { Collection, CollectionItemLike, CollectionNode, Key } from "./types";
7
+
8
+ /**
9
+ * A basic implementation of Collection for list-based components.
10
+ */
11
+ export class ListCollection<T = unknown> implements Collection<T> {
12
+ private nodes: CollectionNode<T>[];
13
+ private keyMap: Map<Key, CollectionNode<T>>;
14
+
15
+ constructor(nodes: CollectionNode<T>[]) {
16
+ this.nodes = nodes;
17
+ this.keyMap = new Map();
18
+
19
+ // Build key map for O(1) lookups
20
+ const addToMap = (node: CollectionNode<T>) => {
21
+ this.keyMap.set(node.key, node);
22
+ if (node.childNodes) {
23
+ for (const child of node.childNodes) {
24
+ addToMap(child);
25
+ }
26
+ }
27
+ };
28
+
29
+ for (const node of nodes) {
30
+ addToMap(node);
31
+ }
32
+ }
33
+
34
+ get size(): number {
35
+ return this.keyMap.size;
36
+ }
37
+
38
+ *[Symbol.iterator](): Iterator<CollectionNode<T>> {
39
+ yield* this.nodes;
40
+ }
41
+
42
+ *getKeys(): Iterable<Key> {
43
+ for (const node of this.keyMap.values()) {
44
+ yield node.key;
45
+ }
46
+ }
47
+
48
+ getItem(key: Key): CollectionNode<T> | null {
49
+ return this.keyMap.get(key) ?? null;
50
+ }
51
+
52
+ at(index: number): CollectionNode<T> | null {
53
+ // Flatten all items for indexing
54
+ const items = this.getAllItems();
55
+ return items[index] ?? null;
56
+ }
57
+
58
+ getKeyBefore(key: Key): Key | null {
59
+ const items = this.getAllItems();
60
+ const index = items.findIndex((item) => item.key === key);
61
+ if (index <= 0) return null;
62
+ return items[index - 1].key;
63
+ }
64
+
65
+ getKeyAfter(key: Key): Key | null {
66
+ const items = this.getAllItems();
67
+ const index = items.findIndex((item) => item.key === key);
68
+ if (index < 0 || index >= items.length - 1) return null;
69
+ return items[index + 1].key;
70
+ }
71
+
72
+ getFirstKey(): Key | null {
73
+ const items = this.getAllItems();
74
+ return items[0]?.key ?? null;
75
+ }
76
+
77
+ getLastKey(): Key | null {
78
+ const items = this.getAllItems();
79
+ return items[items.length - 1]?.key ?? null;
80
+ }
81
+
82
+ *getChildren(key: Key): Iterable<CollectionNode<T>> {
83
+ const node = this.getItem(key);
84
+ if (node?.childNodes) {
85
+ yield* node.childNodes;
86
+ }
87
+ }
88
+
89
+ getTextValue(key: Key): string {
90
+ return this.getItem(key)?.textValue ?? "";
91
+ }
92
+
93
+ /**
94
+ * Get all items (excluding sections, including items within sections).
95
+ */
96
+ private getAllItems(): CollectionNode<T>[] {
97
+ const items: CollectionNode<T>[] = [];
98
+
99
+ const addItems = (nodes: CollectionNode<T>[]) => {
100
+ for (const node of nodes) {
101
+ if (node.type === "item") {
102
+ items.push(node);
103
+ } else if (node.type === "section" && node.childNodes) {
104
+ addItems(node.childNodes);
105
+ }
106
+ }
107
+ };
108
+
109
+ addItems(this.nodes);
110
+ return items;
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Create a collection from an array of items.
116
+ */
117
+ export function createListCollection<T>(
118
+ items: T[],
119
+ options: {
120
+ getKey?: (item: T, index: number) => Key;
121
+ getTextValue?: (item: T) => string;
122
+ getDisabled?: (item: T) => boolean;
123
+ } = {},
124
+ ): ListCollection<T> {
125
+ const {
126
+ getKey = (item: T, index: number) => {
127
+ const o = item as CollectionItemLike;
128
+ return o.key ?? o.id ?? index;
129
+ },
130
+ getTextValue = (item: T) => {
131
+ const o = item as CollectionItemLike;
132
+ return o.textValue ?? o.label ?? String(item);
133
+ },
134
+ getDisabled = (item: T) => (item as CollectionItemLike).isDisabled ?? false,
135
+ } = options;
136
+
137
+ const nodes: CollectionNode<T>[] = items.map((item, index) => ({
138
+ type: "item" as const,
139
+ key: getKey(item, index),
140
+ value: item,
141
+ textValue: getTextValue(item),
142
+ rendered: null!, // Will be set by component
143
+ level: 0,
144
+ index,
145
+ parentKey: null,
146
+ hasChildNodes: false,
147
+ childNodes: [],
148
+ isDisabled: getDisabled(item),
149
+ }));
150
+
151
+ return new ListCollection(nodes);
152
+ }