@proyecto-viviana/solidaria-components 0.3.2 → 0.4.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.
- package/dist/ActionBar.js +184 -0
- package/dist/ActionBar.js.map +1 -0
- package/dist/ActionBar.jsx +128 -0
- package/dist/ActionBar.jsx.map +1 -0
- package/dist/ActionGroup.js +179 -0
- package/dist/ActionGroup.js.map +1 -0
- package/dist/ActionGroup.jsx +129 -0
- package/dist/ActionGroup.jsx.map +1 -0
- package/dist/Alert.js +111 -0
- package/dist/Alert.js.map +1 -0
- package/dist/Alert.jsx +82 -0
- package/dist/Alert.jsx.map +1 -0
- package/dist/Autocomplete.js +130 -0
- package/dist/Autocomplete.js.map +1 -0
- package/dist/Autocomplete.jsx +116 -0
- package/dist/Autocomplete.jsx.map +1 -0
- package/dist/Breadcrumbs.d.ts.map +1 -1
- package/dist/Breadcrumbs.js +334 -0
- package/dist/Breadcrumbs.js.map +1 -0
- package/dist/Breadcrumbs.jsx +266 -0
- package/dist/Breadcrumbs.jsx.map +1 -0
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js +348 -0
- package/dist/Button.js.map +1 -0
- package/dist/Button.jsx +314 -0
- package/dist/Button.jsx.map +1 -0
- package/dist/Calendar.d.ts +4 -4
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/Calendar.js +538 -0
- package/dist/Calendar.js.map +1 -0
- package/dist/Calendar.jsx +333 -0
- package/dist/Calendar.jsx.map +1 -0
- package/dist/CalendarPicker.d.ts +33 -0
- package/dist/CalendarPicker.d.ts.map +1 -0
- package/dist/CalendarPicker.js +44 -0
- package/dist/CalendarPicker.js.map +1 -0
- package/dist/CalendarPicker.jsx +44 -0
- package/dist/CalendarPicker.jsx.map +1 -0
- package/dist/Checkbox.d.ts +83 -4
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox.js +923 -0
- package/dist/Checkbox.js.map +1 -0
- package/dist/Checkbox.jsx +707 -0
- package/dist/Checkbox.jsx.map +1 -0
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +202 -0
- package/dist/Collection.js.map +1 -0
- package/dist/Collection.jsx +152 -0
- package/dist/Collection.jsx.map +1 -0
- package/dist/Color.d.ts.map +1 -1
- package/dist/Color.js +1720 -0
- package/dist/Color.js.map +1 -0
- package/dist/Color.jsx +1344 -0
- package/dist/Color.jsx.map +1 -0
- package/dist/ColorEditor.js +208 -0
- package/dist/ColorEditor.js.map +1 -0
- package/dist/ColorEditor.jsx +120 -0
- package/dist/ColorEditor.jsx.map +1 -0
- package/dist/ComboBox.d.ts +4 -4
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/ComboBox.js +992 -0
- package/dist/ComboBox.js.map +1 -0
- package/dist/ComboBox.jsx +714 -0
- package/dist/ComboBox.jsx.map +1 -0
- package/dist/ContextualHelpTrigger.js +146 -0
- package/dist/ContextualHelpTrigger.js.map +1 -0
- package/dist/ContextualHelpTrigger.jsx +109 -0
- package/dist/ContextualHelpTrigger.jsx.map +1 -0
- package/dist/DateField.d.ts +3 -3
- package/dist/DateField.d.ts.map +1 -1
- package/dist/DateField.js +4 -0
- package/dist/DateField.jsx +4 -0
- package/dist/DateField2.js +499 -0
- package/dist/DateField2.js.map +1 -0
- package/dist/DateField2.jsx +317 -0
- package/dist/DateField2.jsx.map +1 -0
- package/dist/DatePicker.d.ts +4 -4
- package/dist/DatePicker.d.ts.map +1 -1
- package/dist/DatePicker.js +991 -0
- package/dist/DatePicker.js.map +1 -0
- package/dist/DatePicker.jsx +682 -0
- package/dist/DatePicker.jsx.map +1 -0
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Dialog.js +337 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/Dialog.jsx +192 -0
- package/dist/Dialog.jsx.map +1 -0
- package/dist/Disclosure.d.ts.map +1 -1
- package/dist/Disclosure.js +328 -0
- package/dist/Disclosure.js.map +1 -0
- package/dist/Disclosure.jsx +230 -0
- package/dist/Disclosure.jsx.map +1 -0
- package/dist/DragAndDrop.d.ts.map +1 -1
- package/dist/DragAndDrop.js +176 -0
- package/dist/DragAndDrop.js.map +1 -0
- package/dist/DragAndDrop.jsx +160 -0
- package/dist/DragAndDrop.jsx.map +1 -0
- package/dist/DropZone.d.ts.map +1 -1
- package/dist/DropZone.js +189 -0
- package/dist/DropZone.js.map +1 -0
- package/dist/DropZone.jsx +144 -0
- package/dist/DropZone.jsx.map +1 -0
- package/dist/FieldError.js +66 -0
- package/dist/FieldError.js.map +1 -0
- package/dist/FieldError.jsx +47 -0
- package/dist/FieldError.jsx.map +1 -0
- package/dist/FileTrigger.js +79 -0
- package/dist/FileTrigger.js.map +1 -0
- package/dist/FileTrigger.jsx +49 -0
- package/dist/FileTrigger.jsx.map +1 -0
- package/dist/Focusable.js +70 -0
- package/dist/Focusable.js.map +1 -0
- package/dist/Focusable.jsx +69 -0
- package/dist/Focusable.jsx.map +1 -0
- package/dist/Form.js +99 -0
- package/dist/Form.js.map +1 -0
- package/dist/Form.jsx +73 -0
- package/dist/Form.jsx.map +1 -0
- package/dist/GridList.d.ts +34 -2
- package/dist/GridList.d.ts.map +1 -1
- package/dist/GridList.js +723 -0
- package/dist/GridList.js.map +1 -0
- package/dist/GridList.jsx +552 -0
- package/dist/GridList.jsx.map +1 -0
- package/dist/HiddenTimeInput.js +104 -0
- package/dist/HiddenTimeInput.js.map +1 -0
- package/dist/HiddenTimeInput.jsx +69 -0
- package/dist/HiddenTimeInput.jsx.map +1 -0
- package/dist/Icon.d.ts.map +1 -1
- package/dist/Icon.js +127 -0
- package/dist/Icon.js.map +1 -0
- package/dist/Icon.jsx +72 -0
- package/dist/Icon.jsx.map +1 -0
- package/dist/Keyboard.js +30 -0
- package/dist/Keyboard.js.map +1 -0
- package/dist/Keyboard.jsx +24 -0
- package/dist/Keyboard.jsx.map +1 -0
- package/dist/Landmark.js +134 -0
- package/dist/Landmark.js.map +1 -0
- package/dist/Landmark.jsx +118 -0
- package/dist/Landmark.jsx.map +1 -0
- package/dist/Link.d.ts.map +1 -1
- package/dist/Link.js +219 -0
- package/dist/Link.js.map +1 -0
- package/dist/Link.jsx +189 -0
- package/dist/Link.jsx.map +1 -0
- package/dist/ListBox.d.ts.map +1 -1
- package/dist/ListBox.js +670 -0
- package/dist/ListBox.js.map +1 -0
- package/dist/ListBox.jsx +508 -0
- package/dist/ListBox.jsx.map +1 -0
- package/dist/Menu.d.ts +27 -9
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Menu.js +1254 -0
- package/dist/Menu.js.map +1 -0
- package/dist/Menu.jsx +1042 -0
- package/dist/Menu.jsx.map +1 -0
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Meter.js +123 -0
- package/dist/Meter.js.map +1 -0
- package/dist/Meter.jsx +107 -0
- package/dist/Meter.jsx.map +1 -0
- package/dist/Modal.d.ts.map +1 -1
- package/dist/Modal.js +380 -0
- package/dist/Modal.js.map +1 -0
- package/dist/Modal.jsx +314 -0
- package/dist/Modal.jsx.map +1 -0
- package/dist/NumberField.d.ts +3 -3
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/NumberField.js +573 -0
- package/dist/NumberField.js.map +1 -0
- package/dist/NumberField.jsx +443 -0
- package/dist/NumberField.jsx.map +1 -0
- package/dist/Popover.d.ts +10 -2
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Popover.js +464 -0
- package/dist/Popover.js.map +1 -0
- package/dist/Popover.jsx +333 -0
- package/dist/Popover.jsx.map +1 -0
- package/dist/Pressable.js +69 -0
- package/dist/Pressable.js.map +1 -0
- package/dist/Pressable.jsx +68 -0
- package/dist/Pressable.jsx.map +1 -0
- package/dist/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar.js +130 -0
- package/dist/ProgressBar.js.map +1 -0
- package/dist/ProgressBar.jsx +114 -0
- package/dist/ProgressBar.jsx.map +1 -0
- package/dist/RadioGroup.d.ts +82 -4
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RadioGroup.js +931 -0
- package/dist/RadioGroup.js.map +1 -0
- package/dist/RadioGroup.jsx +681 -0
- package/dist/RadioGroup.jsx.map +1 -0
- package/dist/RangeCalendar.d.ts.map +1 -1
- package/dist/RangeCalendar.js +410 -0
- package/dist/RangeCalendar.js.map +1 -0
- package/dist/RangeCalendar.jsx +253 -0
- package/dist/RangeCalendar.jsx.map +1 -0
- package/dist/RouterProvider.js +118 -0
- package/dist/RouterProvider.js.map +1 -0
- package/dist/RouterProvider.jsx +112 -0
- package/dist/RouterProvider.jsx.map +1 -0
- package/dist/SearchField.d.ts +2 -2
- package/dist/SearchField.d.ts.map +1 -1
- package/dist/SearchField.js +643 -0
- package/dist/SearchField.js.map +1 -0
- package/dist/SearchField.jsx +526 -0
- package/dist/SearchField.jsx.map +1 -0
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +1031 -0
- package/dist/Select.js.map +1 -0
- package/dist/Select.jsx +744 -0
- package/dist/Select.jsx.map +1 -0
- package/dist/SelectionIndicator.d.ts.map +1 -1
- package/dist/SelectionIndicator.js +86 -0
- package/dist/SelectionIndicator.js.map +1 -0
- package/dist/SelectionIndicator.jsx +50 -0
- package/dist/SelectionIndicator.jsx.map +1 -0
- package/dist/Separator.js +97 -0
- package/dist/Separator.js.map +1 -0
- package/dist/Separator.jsx +85 -0
- package/dist/Separator.jsx.map +1 -0
- package/dist/SharedElementTransition.d.ts.map +1 -1
- package/dist/SharedElementTransition.js +165 -0
- package/dist/SharedElementTransition.js.map +1 -0
- package/dist/SharedElementTransition.jsx +138 -0
- package/dist/SharedElementTransition.jsx.map +1 -0
- package/dist/Slider.d.ts +33 -1
- package/dist/Slider.d.ts.map +1 -1
- package/dist/Slider.js +515 -0
- package/dist/Slider.js.map +1 -0
- package/dist/Slider.jsx +403 -0
- package/dist/Slider.jsx.map +1 -0
- package/dist/StepList.js +198 -0
- package/dist/StepList.js.map +1 -0
- package/dist/StepList.jsx +141 -0
- package/dist/StepList.jsx.map +1 -0
- package/dist/Switch.d.ts +65 -2
- package/dist/Switch.d.ts.map +1 -1
- package/dist/Switch.js +534 -0
- package/dist/Switch.js.map +1 -0
- package/dist/Switch.jsx +393 -0
- package/dist/Switch.jsx.map +1 -0
- package/dist/Table.d.ts +48 -0
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +1759 -0
- package/dist/Table.js.map +1 -0
- package/dist/Table.jsx +1348 -0
- package/dist/Table.jsx.map +1 -0
- package/dist/Tabs.d.ts +0 -4
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/Tabs.js +595 -0
- package/dist/Tabs.js.map +1 -0
- package/dist/Tabs.jsx +367 -0
- package/dist/Tabs.jsx.map +1 -0
- package/dist/TagGroup.d.ts.map +1 -1
- package/dist/TagGroup.js +378 -0
- package/dist/TagGroup.js.map +1 -0
- package/dist/TagGroup.jsx +270 -0
- package/dist/TagGroup.jsx.map +1 -0
- package/dist/Text.d.ts +18 -6
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +42 -0
- package/dist/Text.js.map +1 -0
- package/dist/Text.jsx +35 -0
- package/dist/Text.jsx.map +1 -0
- package/dist/TextField.d.ts +6 -6
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TextField.js +436 -0
- package/dist/TextField.js.map +1 -0
- package/dist/TextField.jsx +403 -0
- package/dist/TextField.jsx.map +1 -0
- package/dist/TimeField.d.ts +3 -3
- package/dist/TimeField.d.ts.map +1 -1
- package/dist/TimeField.js +372 -0
- package/dist/TimeField.js.map +1 -0
- package/dist/TimeField.jsx +224 -0
- package/dist/TimeField.jsx.map +1 -0
- package/dist/Toast.d.ts +14 -0
- package/dist/Toast.d.ts.map +1 -1
- package/dist/Toast.js +551 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Toast.jsx +361 -0
- package/dist/Toast.jsx.map +1 -0
- package/dist/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButton.js +123 -0
- package/dist/ToggleButton.js.map +1 -0
- package/dist/ToggleButton.jsx +88 -0
- package/dist/ToggleButton.jsx.map +1 -0
- package/dist/ToggleButtonGroup.d.ts.map +1 -1
- package/dist/ToggleButtonGroup.js +114 -0
- package/dist/ToggleButtonGroup.js.map +1 -0
- package/dist/ToggleButtonGroup.jsx +85 -0
- package/dist/ToggleButtonGroup.jsx.map +1 -0
- package/dist/Toolbar.js +112 -0
- package/dist/Toolbar.js.map +1 -0
- package/dist/Toolbar.jsx +92 -0
- package/dist/Toolbar.jsx.map +1 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip.js +539 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/Tooltip.jsx +465 -0
- package/dist/Tooltip.jsx.map +1 -0
- package/dist/Tree.d.ts +14 -2
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Tree.js +1424 -0
- package/dist/Tree.js.map +1 -0
- package/dist/Tree.jsx +1172 -0
- package/dist/Tree.jsx.map +1 -0
- package/dist/Virtualizer.d.ts +16 -2
- package/dist/Virtualizer.d.ts.map +1 -1
- package/dist/Virtualizer.js +2 -0
- package/dist/Virtualizer.jsx +2 -0
- package/dist/Virtualizer2.js +751 -0
- package/dist/Virtualizer2.js.map +1 -0
- package/dist/Virtualizer2.jsx +730 -0
- package/dist/Virtualizer2.jsx.map +1 -0
- package/dist/VirtualizerLayouts.d.ts +18 -0
- package/dist/VirtualizerLayouts.d.ts.map +1 -1
- package/dist/VisuallyHidden.js +42 -0
- package/dist/VisuallyHidden.js.map +1 -0
- package/dist/VisuallyHidden.jsx +35 -0
- package/dist/VisuallyHidden.jsx.map +1 -0
- package/dist/contexts.js +33 -0
- package/dist/contexts.js.map +1 -0
- package/dist/contexts.jsx +33 -0
- package/dist/contexts.jsx.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +70 -23932
- package/dist/index.jsx +70 -18337
- package/dist/useDragAndDrop.js +2 -0
- package/dist/useDragAndDrop.jsx +2 -0
- package/dist/useDragAndDrop2.js +395 -0
- package/dist/useDragAndDrop2.js.map +1 -0
- package/dist/useDragAndDrop2.jsx +395 -0
- package/dist/useDragAndDrop2.jsx.map +1 -0
- package/dist/utils.d.ts +83 -11
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +285 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.jsx +277 -0
- package/dist/utils.jsx.map +1 -0
- package/dist/virtualizer/Layout.js +144 -0
- package/dist/virtualizer/Layout.js.map +1 -0
- package/dist/virtualizer/Layout.jsx +144 -0
- package/dist/virtualizer/Layout.jsx.map +1 -0
- package/package.json +401 -4
- package/src/Breadcrumbs.tsx +3 -1
- package/src/Button.tsx +22 -2
- package/src/Calendar.tsx +27 -10
- package/src/CalendarPicker.tsx +73 -0
- package/src/Checkbox.tsx +539 -3
- package/src/Collection.tsx +9 -3
- package/src/Color.tsx +42 -14
- package/src/ComboBox.tsx +50 -6
- package/src/DateField.tsx +20 -2
- package/src/DatePicker.tsx +57 -5
- package/src/Dialog.tsx +13 -5
- package/src/Disclosure.tsx +3 -1
- package/src/DragAndDrop.tsx +3 -1
- package/src/DropZone.tsx +3 -1
- package/src/GridList.tsx +125 -24
- package/src/Icon.tsx +3 -1
- package/src/Link.tsx +3 -1
- package/src/ListBox.tsx +31 -4
- package/src/Menu.tsx +252 -128
- package/src/Meter.tsx +3 -1
- package/src/Modal.tsx +100 -52
- package/src/NumberField.tsx +51 -8
- package/src/Popover.tsx +40 -10
- package/src/ProgressBar.tsx +3 -1
- package/src/RadioGroup.tsx +468 -4
- package/src/RangeCalendar.tsx +3 -1
- package/src/SearchField.tsx +27 -3
- package/src/Select.tsx +22 -7
- package/src/SelectionIndicator.tsx +3 -1
- package/src/SharedElementTransition.tsx +3 -1
- package/src/Slider.tsx +159 -13
- package/src/Switch.tsx +395 -2
- package/src/Table.tsx +409 -95
- package/src/Tabs.tsx +16 -45
- package/src/TagGroup.tsx +3 -1
- package/src/Text.tsx +31 -10
- package/src/TextField.tsx +43 -5
- package/src/TimeField.tsx +20 -2
- package/src/Toast.tsx +79 -14
- package/src/ToggleButton.tsx +3 -1
- package/src/ToggleButtonGroup.tsx +3 -1
- package/src/Tooltip.tsx +3 -1
- package/src/Tree.tsx +77 -9
- package/src/Virtualizer.tsx +180 -31
- package/src/VirtualizerLayouts.ts +45 -10
- package/src/index.ts +50 -0
- package/src/utils.tsx +243 -27
- package/dist/index.js.map +0 -1
- package/dist/index.jsx.map +0 -1
package/src/Checkbox.tsx
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
type JSX,
|
|
10
|
+
type Context,
|
|
10
11
|
type Accessor,
|
|
11
12
|
createContext,
|
|
12
13
|
useContext,
|
|
@@ -29,7 +30,9 @@ import {
|
|
|
29
30
|
import {
|
|
30
31
|
createToggleState,
|
|
31
32
|
createCheckboxGroupState,
|
|
33
|
+
VALID_VALIDITY_STATE,
|
|
32
34
|
type CheckboxGroupState,
|
|
35
|
+
type ValidationResult,
|
|
33
36
|
} from "@proyecto-viviana/solid-stately";
|
|
34
37
|
import { VisuallyHidden } from "./VisuallyHidden";
|
|
35
38
|
import {
|
|
@@ -37,10 +40,13 @@ import {
|
|
|
37
40
|
type ClassNameOrFunction,
|
|
38
41
|
type StyleOrFunction,
|
|
39
42
|
type SlotProps,
|
|
43
|
+
Provider,
|
|
40
44
|
useRenderProps,
|
|
41
45
|
filterDOMProps,
|
|
42
46
|
} from "./utils";
|
|
43
47
|
import { FormContext, type FormProps } from "./Form";
|
|
48
|
+
import { FieldErrorContext, type FieldErrorContextValue } from "./FieldError";
|
|
49
|
+
import { TextContext } from "./Text";
|
|
44
50
|
|
|
45
51
|
type RefLike<T> = ((el: T) => void) | { current?: T | null } | undefined;
|
|
46
52
|
|
|
@@ -99,6 +105,17 @@ export interface CheckboxGroupProps
|
|
|
99
105
|
style?: StyleOrFunction<CheckboxGroupRenderProps>;
|
|
100
106
|
/** Ref for the checkbox group root element. */
|
|
101
107
|
ref?: RefLike<HTMLDivElement>;
|
|
108
|
+
/**
|
|
109
|
+
* Whether this component renders its own description/error-message elements.
|
|
110
|
+
* A styled layer (e.g. solid-spectrum) that renders its own HelpText via a
|
|
111
|
+
* `<Text slot>` sets this to `false`: the wiring stays here — the single source
|
|
112
|
+
* of truth that mints the description/error ids and threads them onto the group
|
|
113
|
+
* and every item's `aria-describedby` — while the visible node is owned by the
|
|
114
|
+
* styled layer. Mirrors RAC, where the group provides a `TextContext` slot and
|
|
115
|
+
* never renders its own description node.
|
|
116
|
+
* @default true
|
|
117
|
+
*/
|
|
118
|
+
renderHelpText?: boolean;
|
|
102
119
|
}
|
|
103
120
|
|
|
104
121
|
export interface CheckboxProps extends Omit<AriaCheckboxProps, "children">, SlotProps {
|
|
@@ -213,6 +230,7 @@ export function CheckboxGroup(props: CheckboxGroupProps): JSX.Element {
|
|
|
213
230
|
"ref",
|
|
214
231
|
"description",
|
|
215
232
|
"errorMessage",
|
|
233
|
+
"renderHelpText",
|
|
216
234
|
"children",
|
|
217
235
|
]);
|
|
218
236
|
|
|
@@ -250,7 +268,9 @@ export function CheckboxGroup(props: CheckboxGroupProps): JSX.Element {
|
|
|
250
268
|
|
|
251
269
|
const renderProps = useRenderProps(
|
|
252
270
|
{
|
|
253
|
-
children
|
|
271
|
+
get children() {
|
|
272
|
+
return local.children;
|
|
273
|
+
},
|
|
254
274
|
class: local.class,
|
|
255
275
|
style: local.style,
|
|
256
276
|
defaultClassName: "solidaria-CheckboxGroup",
|
|
@@ -326,12 +346,15 @@ export function CheckboxGroup(props: CheckboxGroupProps): JSX.Element {
|
|
|
326
346
|
data-invalid={groupAria.isInvalid || undefined}
|
|
327
347
|
>
|
|
328
348
|
<GroupChildren />
|
|
329
|
-
|
|
349
|
+
{/* A styled layer can own the visible HelpText (renderHelpText={false});
|
|
350
|
+
the id wiring above still runs so the group and its items stay
|
|
351
|
+
associated. Default true keeps the bare headless self-sufficient. */}
|
|
352
|
+
<Show when={(local.renderHelpText ?? true) && local.description}>
|
|
330
353
|
<div {...(groupAria.descriptionProps as unknown as JSX.HTMLAttributes<HTMLDivElement>)}>
|
|
331
354
|
{local.description}
|
|
332
355
|
</div>
|
|
333
356
|
</Show>
|
|
334
|
-
<Show when={groupAria.isInvalid && local.errorMessage}>
|
|
357
|
+
<Show when={(local.renderHelpText ?? true) && groupAria.isInvalid && local.errorMessage}>
|
|
335
358
|
<div {...(groupAria.errorMessageProps as unknown as JSX.HTMLAttributes<HTMLDivElement>)}>
|
|
336
359
|
{local.errorMessage}
|
|
337
360
|
</div>
|
|
@@ -676,3 +699,516 @@ export function Checkbox(props: CheckboxProps): JSX.Element {
|
|
|
676
699
|
</label>
|
|
677
700
|
);
|
|
678
701
|
}
|
|
702
|
+
|
|
703
|
+
// ============================================================================
|
|
704
|
+
// CheckboxField + CheckboxButton — the RAC form-field split (RAC 1.19)
|
|
705
|
+
// ----------------------------------------------------------------------------
|
|
706
|
+
// Upstream split the monolithic Checkbox into a CheckboxField wrapper (owns
|
|
707
|
+
// state, validation, and help text) containing a CheckboxButton control (the
|
|
708
|
+
// clickable indicator + label). Mirrors react-aria-components/src/Checkbox.tsx.
|
|
709
|
+
// The legacy `Checkbox` above stays as the deprecated monolith for back-compat.
|
|
710
|
+
//
|
|
711
|
+
// Help text wiring mirrors upstream exactly: CheckboxField has NO description /
|
|
712
|
+
// errorMessage props. createCheckbox (via createToggle) mints descriptionProps /
|
|
713
|
+
// errorMessageProps (slot ids) and bakes the combined aria-describedby into
|
|
714
|
+
// inputProps; the field provides those ids through TextContext slots. Consumers
|
|
715
|
+
// render the help text themselves with `<Text slot="description">` / `<FieldError>`.
|
|
716
|
+
// The field/button handoff still uses a native InternalCheckboxContext (read inside
|
|
717
|
+
// the provider via `Show … keyed`), but the slot wiring is now faithful.
|
|
718
|
+
// ============================================================================
|
|
719
|
+
|
|
720
|
+
export interface CheckboxFieldRenderProps {
|
|
721
|
+
/** Whether the checkbox is selected. */
|
|
722
|
+
isSelected: boolean;
|
|
723
|
+
/** Whether the checkbox is indeterminate. */
|
|
724
|
+
isIndeterminate: boolean;
|
|
725
|
+
/** Whether the checkbox is disabled. */
|
|
726
|
+
isDisabled: boolean;
|
|
727
|
+
/** Whether the checkbox is read only. */
|
|
728
|
+
isReadOnly: boolean;
|
|
729
|
+
/** Whether the checkbox is invalid. */
|
|
730
|
+
isInvalid: boolean;
|
|
731
|
+
/** Whether the checkbox is required. */
|
|
732
|
+
isRequired: boolean;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
export interface CheckboxButtonRenderProps extends CheckboxRenderProps {}
|
|
736
|
+
|
|
737
|
+
export interface CheckboxFieldProps
|
|
738
|
+
extends Omit<AriaCheckboxProps, "children" | "validationState">, SlotProps {
|
|
739
|
+
/** The children of the component (typically a `CheckboxButton`). A function may receive render props. */
|
|
740
|
+
children?: RenderChildren<CheckboxFieldRenderProps>;
|
|
741
|
+
/** The CSS className for the element. */
|
|
742
|
+
class?: ClassNameOrFunction<CheckboxFieldRenderProps>;
|
|
743
|
+
/** The inline style for the element. */
|
|
744
|
+
style?: StyleOrFunction<CheckboxFieldRenderProps>;
|
|
745
|
+
/** Whether the checkbox is indeterminate. */
|
|
746
|
+
isIndeterminate?: boolean;
|
|
747
|
+
/** Ref for the checkbox field root element. */
|
|
748
|
+
ref?: RefLike<HTMLDivElement>;
|
|
749
|
+
/** Ref for the underlying input element. */
|
|
750
|
+
inputRef?: RefLike<HTMLInputElement>;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
export interface CheckboxButtonProps extends SlotProps {
|
|
754
|
+
/** The children of the component. A function may receive render props. */
|
|
755
|
+
children?: RenderChildren<CheckboxButtonRenderProps>;
|
|
756
|
+
/** The CSS className for the element. */
|
|
757
|
+
class?: ClassNameOrFunction<CheckboxButtonRenderProps>;
|
|
758
|
+
/** The inline style for the element. */
|
|
759
|
+
style?: StyleOrFunction<CheckboxButtonRenderProps>;
|
|
760
|
+
/** Ref for the outer label element. */
|
|
761
|
+
ref?: RefLike<HTMLLabelElement>;
|
|
762
|
+
/** Handler called when hover starts. */
|
|
763
|
+
onHoverStart?: () => void;
|
|
764
|
+
/** Handler called when hover ends. */
|
|
765
|
+
onHoverEnd?: () => void;
|
|
766
|
+
/** Handler called when hover state changes. */
|
|
767
|
+
onHoverChange?: (isHovered: boolean) => void;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
export interface CheckboxFieldContextValue extends CheckboxFieldProps {
|
|
771
|
+
slots?: Record<string, CheckboxFieldProps>;
|
|
772
|
+
}
|
|
773
|
+
export const CheckboxFieldContext = createContext<CheckboxFieldContextValue | null>(null);
|
|
774
|
+
|
|
775
|
+
/** Carries the checkbox aria + state from a CheckboxField/Checkbox wrapper to its CheckboxButton. */
|
|
776
|
+
interface InternalCheckboxContextValue {
|
|
777
|
+
isSelected: Accessor<boolean>;
|
|
778
|
+
isPressed: Accessor<boolean>;
|
|
779
|
+
isDisabled: Accessor<boolean>;
|
|
780
|
+
isReadOnly: Accessor<boolean>;
|
|
781
|
+
isInvalid: Accessor<boolean>;
|
|
782
|
+
isIndeterminate: Accessor<boolean>;
|
|
783
|
+
isRequired: Accessor<boolean>;
|
|
784
|
+
labelProps: () => JSX.LabelHTMLAttributes<HTMLLabelElement>;
|
|
785
|
+
inputProps: () => JSX.InputHTMLAttributes<HTMLInputElement>;
|
|
786
|
+
setInputRef: (el: HTMLInputElement) => void;
|
|
787
|
+
defaultClassName: string;
|
|
788
|
+
}
|
|
789
|
+
const InternalCheckboxContext = createContext<InternalCheckboxContextValue | null>(null);
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* A checkbox allows a user to select an item, with support for validation and help text.
|
|
793
|
+
* Wraps a `CheckboxButton` and provides description/error wiring.
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
* ```tsx
|
|
797
|
+
* <CheckboxField>
|
|
798
|
+
* <CheckboxButton>Accept terms</CheckboxButton>
|
|
799
|
+
* <Text slot="description">Required to continue</Text>
|
|
800
|
+
* </CheckboxField>
|
|
801
|
+
* ```
|
|
802
|
+
*/
|
|
803
|
+
export function CheckboxField(props: CheckboxFieldProps): JSX.Element {
|
|
804
|
+
const [inputElement, setInputElement] = createSignal<HTMLInputElement | null>(null);
|
|
805
|
+
const formContext = useContext(FormContext);
|
|
806
|
+
const contextProps = useContext(CheckboxFieldContext);
|
|
807
|
+
const contextSlotProps = contextProps?.slots?.[props.slot ?? "default"];
|
|
808
|
+
const contextBaseProps = createMemo<CheckboxFieldProps>(() => {
|
|
809
|
+
if (!contextProps) return {};
|
|
810
|
+
const { slots: _slots, ...rest } = contextProps;
|
|
811
|
+
return rest;
|
|
812
|
+
});
|
|
813
|
+
const mergedProps = contextProps
|
|
814
|
+
? (mergeProps(contextBaseProps(), contextSlotProps ?? {}, props) as CheckboxFieldProps)
|
|
815
|
+
: props;
|
|
816
|
+
const propsWithFormBehavior = withFormValidationBehavior(mergedProps, formContext);
|
|
817
|
+
const inputRefs = createMemo(
|
|
818
|
+
() =>
|
|
819
|
+
[contextBaseProps().inputRef, contextSlotProps?.inputRef, props.inputRef].filter(
|
|
820
|
+
Boolean,
|
|
821
|
+
) as RefLike<HTMLInputElement>[],
|
|
822
|
+
);
|
|
823
|
+
|
|
824
|
+
// `children` is split out of ariaProps so neither the inputAriaProps key-copy
|
|
825
|
+
// loop nor the hook accessor spread eagerly reads it — reading a Solid
|
|
826
|
+
// `children` getter instantiates the nested CheckboxButton, and doing so
|
|
827
|
+
// OUTSIDE InternalCheckboxContext both breaks its binding and recurses.
|
|
828
|
+
const [local, ariaProps] = splitProps(propsWithFormBehavior, [
|
|
829
|
+
"class",
|
|
830
|
+
"style",
|
|
831
|
+
"ref",
|
|
832
|
+
"inputRef",
|
|
833
|
+
"slot",
|
|
834
|
+
"isIndeterminate",
|
|
835
|
+
"children",
|
|
836
|
+
]);
|
|
837
|
+
|
|
838
|
+
const inputAriaProps = createMemo(() => {
|
|
839
|
+
const clean: Record<string, unknown> = {};
|
|
840
|
+
for (const key in ariaProps as Record<string, unknown>) {
|
|
841
|
+
if (!key.startsWith("data-")) {
|
|
842
|
+
clean[key] = (ariaProps as Record<string, unknown>)[key];
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return clean as typeof ariaProps;
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
const groupState = useContext(CheckboxGroupStateContext);
|
|
849
|
+
|
|
850
|
+
let isSelected: Accessor<boolean>;
|
|
851
|
+
let isPressed: Accessor<boolean>;
|
|
852
|
+
let labelProps: JSX.LabelHTMLAttributes<HTMLLabelElement>;
|
|
853
|
+
let inputProps: () => JSX.InputHTMLAttributes<HTMLInputElement>;
|
|
854
|
+
let getDescriptionProps: () => JSX.HTMLAttributes<HTMLElement>;
|
|
855
|
+
let getErrorMessageProps: () => JSX.HTMLAttributes<HTMLElement>;
|
|
856
|
+
|
|
857
|
+
if (groupState) {
|
|
858
|
+
const itemAria = createCheckboxGroupItem(
|
|
859
|
+
() => ({
|
|
860
|
+
...inputAriaProps(),
|
|
861
|
+
value: inputAriaProps().value ?? "",
|
|
862
|
+
// The hook reads `children` only to decide if an aria-label is needed;
|
|
863
|
+
// the visible label lives in the CheckboxButton, so report presence.
|
|
864
|
+
children: true,
|
|
865
|
+
}),
|
|
866
|
+
groupState,
|
|
867
|
+
inputElement,
|
|
868
|
+
);
|
|
869
|
+
isSelected = itemAria.isSelected;
|
|
870
|
+
isPressed = itemAria.isPressed;
|
|
871
|
+
labelProps = itemAria.labelProps;
|
|
872
|
+
inputProps = () => itemAria.inputProps;
|
|
873
|
+
getDescriptionProps = () => itemAria.descriptionProps;
|
|
874
|
+
getErrorMessageProps = () => itemAria.errorMessageProps;
|
|
875
|
+
} else {
|
|
876
|
+
const state = createToggleState(() => ({
|
|
877
|
+
isSelected: ariaProps.isSelected,
|
|
878
|
+
defaultSelected: ariaProps.defaultSelected,
|
|
879
|
+
onChange: ariaProps.onChange,
|
|
880
|
+
isReadOnly: ariaProps.isReadOnly,
|
|
881
|
+
}));
|
|
882
|
+
|
|
883
|
+
const checkboxAria = createCheckbox(
|
|
884
|
+
() => ({
|
|
885
|
+
...inputAriaProps(),
|
|
886
|
+
isIndeterminate: local.isIndeterminate,
|
|
887
|
+
children: true,
|
|
888
|
+
}),
|
|
889
|
+
state,
|
|
890
|
+
inputElement,
|
|
891
|
+
);
|
|
892
|
+
isSelected = checkboxAria.isSelected;
|
|
893
|
+
isPressed = checkboxAria.isPressed;
|
|
894
|
+
labelProps = checkboxAria.labelProps;
|
|
895
|
+
inputProps = () => checkboxAria.inputProps;
|
|
896
|
+
getDescriptionProps = () => checkboxAria.descriptionProps;
|
|
897
|
+
getErrorMessageProps = () => checkboxAria.errorMessageProps;
|
|
898
|
+
}
|
|
899
|
+
const isDisabled = () => inputProps().disabled === true;
|
|
900
|
+
const isReadOnly = () => inputProps()["aria-readonly"] === true;
|
|
901
|
+
const isInvalid = () => inputProps()["aria-invalid"] === true;
|
|
902
|
+
const isIndeterminate = () => local.isIndeterminate ?? false;
|
|
903
|
+
const isRequired = () => ariaProps.isRequired ?? false;
|
|
904
|
+
|
|
905
|
+
const setInputRef = (el: HTMLInputElement) => {
|
|
906
|
+
setInputElement(el);
|
|
907
|
+
for (const ref of inputRefs()) {
|
|
908
|
+
assignRef(ref, el);
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
const setFieldRef = (el: HTMLDivElement) => {
|
|
912
|
+
assignRef(local.ref, el);
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
const internalContext: InternalCheckboxContextValue = {
|
|
916
|
+
isSelected,
|
|
917
|
+
isPressed,
|
|
918
|
+
isDisabled,
|
|
919
|
+
isReadOnly,
|
|
920
|
+
isInvalid,
|
|
921
|
+
isIndeterminate,
|
|
922
|
+
isRequired,
|
|
923
|
+
labelProps: () => labelProps,
|
|
924
|
+
inputProps,
|
|
925
|
+
setInputRef,
|
|
926
|
+
defaultClassName: "solidaria-CheckboxButton",
|
|
927
|
+
};
|
|
928
|
+
|
|
929
|
+
// Slot the description/error message ids onto a TextContext so a child
|
|
930
|
+
// `<Text slot="description">` / `<FieldError>` resolves the id the input's
|
|
931
|
+
// baked aria-describedby references — mirrors upstream CheckboxField.
|
|
932
|
+
const textSlots = {
|
|
933
|
+
slots: {
|
|
934
|
+
get description() {
|
|
935
|
+
return getDescriptionProps();
|
|
936
|
+
},
|
|
937
|
+
get errorMessage() {
|
|
938
|
+
return getErrorMessageProps();
|
|
939
|
+
},
|
|
940
|
+
},
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
const renderValues = createMemo<CheckboxFieldRenderProps>(() => ({
|
|
944
|
+
isSelected: isSelected(),
|
|
945
|
+
isIndeterminate: isIndeterminate(),
|
|
946
|
+
isDisabled: isDisabled(),
|
|
947
|
+
isReadOnly: isReadOnly(),
|
|
948
|
+
isInvalid: isInvalid(),
|
|
949
|
+
isRequired: isRequired(),
|
|
950
|
+
}));
|
|
951
|
+
|
|
952
|
+
const renderProps = useRenderProps(
|
|
953
|
+
{
|
|
954
|
+
children: mergedProps.children,
|
|
955
|
+
class: local.class,
|
|
956
|
+
style: local.style,
|
|
957
|
+
defaultClassName: "solidaria-CheckboxField",
|
|
958
|
+
},
|
|
959
|
+
renderValues,
|
|
960
|
+
);
|
|
961
|
+
|
|
962
|
+
// In a CheckboxGroup, validation is handled at the group level — mirror
|
|
963
|
+
// upstream and provide no per-field FieldErrorContext there.
|
|
964
|
+
const fieldErrorContext: FieldErrorContextValue | null = groupState
|
|
965
|
+
? null
|
|
966
|
+
: {
|
|
967
|
+
get validation(): ValidationResult {
|
|
968
|
+
return {
|
|
969
|
+
isInvalid: isInvalid(),
|
|
970
|
+
validationDetails: VALID_VALIDITY_STATE,
|
|
971
|
+
validationErrors: [],
|
|
972
|
+
};
|
|
973
|
+
},
|
|
974
|
+
get errorMessageProps() {
|
|
975
|
+
return getErrorMessageProps() as JSX.HTMLAttributes<HTMLElement>;
|
|
976
|
+
},
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
const domProps = createMemo(() => {
|
|
980
|
+
const filtered = filterDOMProps(ariaProps, { global: true });
|
|
981
|
+
delete (filtered as Record<string, unknown>).id;
|
|
982
|
+
delete (filtered as Record<string, unknown>).onClick;
|
|
983
|
+
return filtered;
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
// Children are accessed inside the providers (component-execution owner) so a
|
|
987
|
+
// nested CheckboxButton's useContext binds to InternalCheckboxContext.
|
|
988
|
+
const FieldChildren = () => {
|
|
989
|
+
const childRenderValues: CheckboxFieldRenderProps = {
|
|
990
|
+
get isSelected() {
|
|
991
|
+
return isSelected();
|
|
992
|
+
},
|
|
993
|
+
get isIndeterminate() {
|
|
994
|
+
return isIndeterminate();
|
|
995
|
+
},
|
|
996
|
+
get isDisabled() {
|
|
997
|
+
return isDisabled();
|
|
998
|
+
},
|
|
999
|
+
get isReadOnly() {
|
|
1000
|
+
return isReadOnly();
|
|
1001
|
+
},
|
|
1002
|
+
get isInvalid() {
|
|
1003
|
+
return isInvalid();
|
|
1004
|
+
},
|
|
1005
|
+
get isRequired() {
|
|
1006
|
+
return isRequired();
|
|
1007
|
+
},
|
|
1008
|
+
};
|
|
1009
|
+
const renderedChildren = createMemo(() => {
|
|
1010
|
+
const children = mergedProps.children;
|
|
1011
|
+
return typeof children === "function" ? children(childRenderValues) : children;
|
|
1012
|
+
});
|
|
1013
|
+
return <>{renderedChildren()}</>;
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
const fieldDiv = (
|
|
1017
|
+
<div
|
|
1018
|
+
{...domProps()}
|
|
1019
|
+
ref={setFieldRef}
|
|
1020
|
+
class={renderProps.class()}
|
|
1021
|
+
style={renderProps.style()}
|
|
1022
|
+
slot={local.slot}
|
|
1023
|
+
data-selected={isSelected() || undefined}
|
|
1024
|
+
data-indeterminate={isIndeterminate() || undefined}
|
|
1025
|
+
data-disabled={isDisabled() || undefined}
|
|
1026
|
+
data-readonly={isReadOnly() || undefined}
|
|
1027
|
+
data-invalid={isInvalid() || undefined}
|
|
1028
|
+
data-required={isRequired() || undefined}
|
|
1029
|
+
>
|
|
1030
|
+
<InternalCheckboxContext.Provider value={internalContext}>
|
|
1031
|
+
<Provider values={[[TextContext, textSlots]] as Array<[Context<unknown>, unknown]>}>
|
|
1032
|
+
<Show when={fieldErrorContext} fallback={<FieldChildren />} keyed>
|
|
1033
|
+
{(ctx) => (
|
|
1034
|
+
<FieldErrorContext.Provider value={ctx}>
|
|
1035
|
+
<FieldChildren />
|
|
1036
|
+
</FieldErrorContext.Provider>
|
|
1037
|
+
)}
|
|
1038
|
+
</Show>
|
|
1039
|
+
</Provider>
|
|
1040
|
+
</InternalCheckboxContext.Provider>
|
|
1041
|
+
</div>
|
|
1042
|
+
);
|
|
1043
|
+
|
|
1044
|
+
return fieldDiv;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* A checkbox button is the clickable area of a checkbox, including the indicator and label.
|
|
1049
|
+
* Must be rendered inside a `CheckboxField` (or the legacy `Checkbox`).
|
|
1050
|
+
*/
|
|
1051
|
+
export function CheckboxButton(props: CheckboxButtonProps): JSX.Element {
|
|
1052
|
+
const getCtx = createMemo(() => useContext(InternalCheckboxContext));
|
|
1053
|
+
return (
|
|
1054
|
+
<Show when={getCtx()} fallback={null} keyed>
|
|
1055
|
+
{(ctx) => <CheckboxButtonImpl buttonProps={props} ctx={ctx} />}
|
|
1056
|
+
</Show>
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
function CheckboxButtonImpl(props: {
|
|
1061
|
+
buttonProps: CheckboxButtonProps;
|
|
1062
|
+
ctx: InternalCheckboxContextValue;
|
|
1063
|
+
}): JSX.Element {
|
|
1064
|
+
const { ctx } = props;
|
|
1065
|
+
|
|
1066
|
+
const { isFocused, isFocusVisible, focusProps } = createFocusRing();
|
|
1067
|
+
const { isHovered, hoverProps } = createHover({
|
|
1068
|
+
get isDisabled() {
|
|
1069
|
+
return ctx.isDisabled() || ctx.isReadOnly();
|
|
1070
|
+
},
|
|
1071
|
+
onHoverStart: props.buttonProps.onHoverStart,
|
|
1072
|
+
onHoverEnd: props.buttonProps.onHoverEnd,
|
|
1073
|
+
onHoverChange: props.buttonProps.onHoverChange,
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
const renderValues = createMemo<CheckboxButtonRenderProps>(() => ({
|
|
1077
|
+
isSelected: ctx.isSelected(),
|
|
1078
|
+
isIndeterminate: ctx.isIndeterminate(),
|
|
1079
|
+
isHovered: isHovered(),
|
|
1080
|
+
isPressed: ctx.isPressed(),
|
|
1081
|
+
isFocused: isFocused(),
|
|
1082
|
+
isFocusVisible: isFocusVisible(),
|
|
1083
|
+
isDisabled: ctx.isDisabled(),
|
|
1084
|
+
isReadOnly: ctx.isReadOnly(),
|
|
1085
|
+
isInvalid: ctx.isInvalid(),
|
|
1086
|
+
isRequired: ctx.isRequired(),
|
|
1087
|
+
}));
|
|
1088
|
+
|
|
1089
|
+
const renderProps = useRenderProps(
|
|
1090
|
+
{
|
|
1091
|
+
children: props.buttonProps.children,
|
|
1092
|
+
class: props.buttonProps.class,
|
|
1093
|
+
style: props.buttonProps.style,
|
|
1094
|
+
defaultClassName: ctx.defaultClassName,
|
|
1095
|
+
},
|
|
1096
|
+
renderValues,
|
|
1097
|
+
);
|
|
1098
|
+
|
|
1099
|
+
const childRenderValues: CheckboxButtonRenderProps = {
|
|
1100
|
+
get isSelected() {
|
|
1101
|
+
return ctx.isSelected();
|
|
1102
|
+
},
|
|
1103
|
+
get isIndeterminate() {
|
|
1104
|
+
return ctx.isIndeterminate();
|
|
1105
|
+
},
|
|
1106
|
+
get isHovered() {
|
|
1107
|
+
return isHovered();
|
|
1108
|
+
},
|
|
1109
|
+
get isPressed() {
|
|
1110
|
+
return ctx.isPressed();
|
|
1111
|
+
},
|
|
1112
|
+
get isFocused() {
|
|
1113
|
+
return isFocused();
|
|
1114
|
+
},
|
|
1115
|
+
get isFocusVisible() {
|
|
1116
|
+
return isFocusVisible();
|
|
1117
|
+
},
|
|
1118
|
+
get isDisabled() {
|
|
1119
|
+
return ctx.isDisabled();
|
|
1120
|
+
},
|
|
1121
|
+
get isReadOnly() {
|
|
1122
|
+
return ctx.isReadOnly();
|
|
1123
|
+
},
|
|
1124
|
+
get isInvalid() {
|
|
1125
|
+
return ctx.isInvalid();
|
|
1126
|
+
},
|
|
1127
|
+
get isRequired() {
|
|
1128
|
+
return ctx.isRequired();
|
|
1129
|
+
},
|
|
1130
|
+
};
|
|
1131
|
+
|
|
1132
|
+
const cleanLabelProps = () => {
|
|
1133
|
+
const { ref: _ref1, ...rest } = ctx.labelProps() as Record<string, unknown>;
|
|
1134
|
+
return rest;
|
|
1135
|
+
};
|
|
1136
|
+
const cleanHoverProps = () => {
|
|
1137
|
+
const { ref: _ref2, ...rest } = hoverProps as Record<string, unknown>;
|
|
1138
|
+
return rest;
|
|
1139
|
+
};
|
|
1140
|
+
const cleanInputProps = () => {
|
|
1141
|
+
const {
|
|
1142
|
+
ref: _ref3,
|
|
1143
|
+
onFocus: _onFocus,
|
|
1144
|
+
onBlur: _onBlur,
|
|
1145
|
+
...rest
|
|
1146
|
+
} = ctx.inputProps() as Record<string, unknown>;
|
|
1147
|
+
return rest;
|
|
1148
|
+
};
|
|
1149
|
+
const cleanFocusProps = () => {
|
|
1150
|
+
const {
|
|
1151
|
+
ref: _ref4,
|
|
1152
|
+
onFocus: _onFocus,
|
|
1153
|
+
onBlur: _onBlur,
|
|
1154
|
+
...rest
|
|
1155
|
+
} = focusProps as Record<string, unknown>;
|
|
1156
|
+
return rest;
|
|
1157
|
+
};
|
|
1158
|
+
const handleInputFocus: JSX.EventHandler<HTMLInputElement, FocusEvent> = (event) => {
|
|
1159
|
+
(
|
|
1160
|
+
ctx.inputProps() as unknown as { onFocus?: JSX.EventHandler<HTMLInputElement, FocusEvent> }
|
|
1161
|
+
).onFocus?.(event);
|
|
1162
|
+
(
|
|
1163
|
+
focusProps as unknown as { onFocus?: JSX.EventHandler<HTMLInputElement, FocusEvent> }
|
|
1164
|
+
).onFocus?.(event);
|
|
1165
|
+
};
|
|
1166
|
+
const handleInputBlur: JSX.EventHandler<HTMLInputElement, FocusEvent> = (event) => {
|
|
1167
|
+
(
|
|
1168
|
+
ctx.inputProps() as unknown as { onBlur?: JSX.EventHandler<HTMLInputElement, FocusEvent> }
|
|
1169
|
+
).onBlur?.(event);
|
|
1170
|
+
(focusProps as unknown as { onBlur?: JSX.EventHandler<HTMLInputElement, FocusEvent> }).onBlur?.(
|
|
1171
|
+
event,
|
|
1172
|
+
);
|
|
1173
|
+
};
|
|
1174
|
+
const setButtonRef = (el: HTMLLabelElement) => {
|
|
1175
|
+
assignRef(props.buttonProps.ref, el);
|
|
1176
|
+
};
|
|
1177
|
+
|
|
1178
|
+
const buttonChildren = () => {
|
|
1179
|
+
const children = props.buttonProps.children;
|
|
1180
|
+
return typeof children === "function" ? children(childRenderValues) : children;
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
return (
|
|
1184
|
+
<label
|
|
1185
|
+
{...cleanLabelProps()}
|
|
1186
|
+
{...cleanHoverProps()}
|
|
1187
|
+
ref={setButtonRef}
|
|
1188
|
+
class={renderProps.class()}
|
|
1189
|
+
style={renderProps.style()}
|
|
1190
|
+
slot={props.buttonProps.slot}
|
|
1191
|
+
data-selected={ctx.isSelected() || undefined}
|
|
1192
|
+
data-indeterminate={ctx.isIndeterminate() || undefined}
|
|
1193
|
+
data-pressed={ctx.isPressed() || undefined}
|
|
1194
|
+
data-hovered={isHovered() || undefined}
|
|
1195
|
+
data-focused={isFocused() || undefined}
|
|
1196
|
+
data-focus-visible={isFocusVisible() || undefined}
|
|
1197
|
+
data-disabled={ctx.isDisabled() || undefined}
|
|
1198
|
+
data-readonly={ctx.isReadOnly() || undefined}
|
|
1199
|
+
data-invalid={ctx.isInvalid() || undefined}
|
|
1200
|
+
data-required={ctx.isRequired() || undefined}
|
|
1201
|
+
>
|
|
1202
|
+
<VisuallyHidden>
|
|
1203
|
+
<input
|
|
1204
|
+
ref={ctx.setInputRef}
|
|
1205
|
+
{...cleanInputProps()}
|
|
1206
|
+
{...cleanFocusProps()}
|
|
1207
|
+
onFocus={handleInputFocus}
|
|
1208
|
+
onBlur={handleInputBlur}
|
|
1209
|
+
/>
|
|
1210
|
+
</VisuallyHidden>
|
|
1211
|
+
{buttonChildren()}
|
|
1212
|
+
</label>
|
|
1213
|
+
);
|
|
1214
|
+
}
|
package/src/Collection.tsx
CHANGED
|
@@ -253,7 +253,9 @@ export function Section(props: SectionProps): JSX.Element {
|
|
|
253
253
|
|
|
254
254
|
const renderProps = useRenderProps(
|
|
255
255
|
{
|
|
256
|
-
children
|
|
256
|
+
get children() {
|
|
257
|
+
return local.children;
|
|
258
|
+
},
|
|
257
259
|
class: local.class,
|
|
258
260
|
style: local.style,
|
|
259
261
|
defaultClassName: "solidaria-Section",
|
|
@@ -289,7 +291,9 @@ export function Header(props: HeaderProps): JSX.Element {
|
|
|
289
291
|
|
|
290
292
|
const renderProps = useRenderProps(
|
|
291
293
|
{
|
|
292
|
-
children
|
|
294
|
+
get children() {
|
|
295
|
+
return local.children;
|
|
296
|
+
},
|
|
293
297
|
class: local.class,
|
|
294
298
|
style: local.style,
|
|
295
299
|
defaultClassName: "solidaria-Header",
|
|
@@ -325,7 +329,9 @@ export function Group(props: GroupProps): JSX.Element {
|
|
|
325
329
|
|
|
326
330
|
const renderProps = useRenderProps(
|
|
327
331
|
{
|
|
328
|
-
children
|
|
332
|
+
get children() {
|
|
333
|
+
return local.children;
|
|
334
|
+
},
|
|
329
335
|
class: local.class,
|
|
330
336
|
style: local.style,
|
|
331
337
|
defaultClassName: "solidaria-Group",
|