@proyecto-viviana/solidaria-components 0.2.9 → 0.3.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.
- package/README.md +39 -272
- package/dist/ActionBar.d.ts +21 -13
- package/dist/ActionBar.d.ts.map +1 -1
- package/dist/ActionGroup.d.ts +8 -8
- package/dist/ActionGroup.d.ts.map +1 -1
- package/dist/Alert.d.ts +5 -5
- package/dist/Alert.d.ts.map +1 -1
- package/dist/Autocomplete.d.ts +5 -5
- package/dist/Autocomplete.d.ts.map +1 -1
- package/dist/Breadcrumbs.d.ts +18 -7
- package/dist/Breadcrumbs.d.ts.map +1 -1
- package/dist/Button.d.ts +24 -5
- package/dist/Button.d.ts.map +1 -1
- package/dist/Calendar.d.ts +38 -7
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/Checkbox.d.ts +32 -7
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Collection.d.ts +19 -14
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Color.d.ts +103 -14
- package/dist/Color.d.ts.map +1 -1
- package/dist/ColorEditor.d.ts +6 -6
- package/dist/ColorEditor.d.ts.map +1 -1
- package/dist/ComboBox.d.ts +85 -19
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/ContextualHelpTrigger.d.ts +2 -2
- package/dist/ContextualHelpTrigger.d.ts.map +1 -1
- package/dist/DateField.d.ts +8 -6
- package/dist/DateField.d.ts.map +1 -1
- package/dist/DatePicker.d.ts +53 -22
- package/dist/DatePicker.d.ts.map +1 -1
- package/dist/DateRangePickerContext.d.ts +30 -0
- package/dist/DateRangePickerContext.d.ts.map +1 -0
- package/dist/Dialog.d.ts +5 -5
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Disclosure.d.ts +23 -5
- package/dist/Disclosure.d.ts.map +1 -1
- package/dist/DragAndDrop.d.ts +6 -6
- package/dist/DragAndDrop.d.ts.map +1 -1
- package/dist/DragPreview.d.ts +2 -2
- package/dist/DragPreview.d.ts.map +1 -1
- package/dist/DropZone.d.ts +4 -4
- package/dist/DropZone.d.ts.map +1 -1
- package/dist/FieldError.d.ts +9 -5
- package/dist/FieldError.d.ts.map +1 -1
- package/dist/FileTrigger.d.ts +3 -3
- package/dist/FileTrigger.d.ts.map +1 -1
- package/dist/Focusable.d.ts +2 -2
- package/dist/Focusable.d.ts.map +1 -1
- package/dist/Form.d.ts +18 -4
- package/dist/Form.d.ts.map +1 -1
- package/dist/GridList.d.ts +32 -12
- package/dist/GridList.d.ts.map +1 -1
- package/dist/HiddenDateInput.d.ts +26 -0
- package/dist/HiddenDateInput.d.ts.map +1 -0
- package/dist/HiddenTimeInput.d.ts +25 -0
- package/dist/HiddenTimeInput.d.ts.map +1 -0
- package/dist/Icon.d.ts +5 -5
- package/dist/Icon.d.ts.map +1 -1
- package/dist/Keyboard.d.ts +1 -1
- package/dist/Landmark.d.ts +3 -3
- package/dist/Landmark.d.ts.map +1 -1
- package/dist/Link.d.ts +10 -4
- package/dist/Link.d.ts.map +1 -1
- package/dist/ListBox.d.ts +32 -12
- package/dist/ListBox.d.ts.map +1 -1
- package/dist/ListDropTargetDelegate.d.ts +6 -6
- package/dist/ListDropTargetDelegate.d.ts.map +1 -1
- package/dist/Menu.d.ts +65 -14
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Meter.d.ts +3 -3
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Modal.d.ts +5 -5
- package/dist/Modal.d.ts.map +1 -1
- package/dist/NumberField.d.ts +8 -12
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/Popover.d.ts +28 -5
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Pressable.d.ts +2 -2
- package/dist/Pressable.d.ts.map +1 -1
- package/dist/ProgressBar.d.ts +5 -3
- package/dist/ProgressBar.d.ts.map +1 -1
- package/dist/RadioGroup.d.ts +43 -9
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RangeCalendar.d.ts +34 -7
- package/dist/RangeCalendar.d.ts.map +1 -1
- package/dist/RouterProvider.d.ts +2 -2
- package/dist/RouterProvider.d.ts.map +1 -1
- package/dist/SearchField.d.ts +23 -20
- package/dist/SearchField.d.ts.map +1 -1
- package/dist/Select.d.ts +41 -11
- package/dist/Select.d.ts.map +1 -1
- package/dist/SelectionIndicator.d.ts +3 -3
- package/dist/SelectionIndicator.d.ts.map +1 -1
- package/dist/Separator.d.ts +9 -3
- package/dist/Separator.d.ts.map +1 -1
- package/dist/SharedElementTransition.d.ts +6 -4
- package/dist/SharedElementTransition.d.ts.map +1 -1
- package/dist/Slider.d.ts +12 -8
- package/dist/Slider.d.ts.map +1 -1
- package/dist/StepList.d.ts +90 -0
- package/dist/StepList.d.ts.map +1 -0
- package/dist/Switch.d.ts +11 -5
- package/dist/Switch.d.ts.map +1 -1
- package/dist/Table.d.ts +187 -23
- package/dist/Table.d.ts.map +1 -1
- package/dist/Tabs.d.ts +45 -9
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/TagGroup.d.ts +12 -10
- package/dist/TagGroup.d.ts.map +1 -1
- package/dist/Text.d.ts +2 -2
- package/dist/TextField.d.ts +15 -11
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TimeField.d.ts +6 -6
- package/dist/TimeField.d.ts.map +1 -1
- package/dist/Toast.d.ts +29 -14
- package/dist/Toast.d.ts.map +1 -1
- package/dist/ToggleButton.d.ts +11 -5
- package/dist/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButtonGroup.d.ts +7 -7
- package/dist/ToggleButtonGroup.d.ts.map +1 -1
- package/dist/Toolbar.d.ts +7 -3
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Tooltip.d.ts +50 -8
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tree.d.ts +66 -17
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Virtualizer.d.ts +12 -12
- package/dist/Virtualizer.d.ts.map +1 -1
- package/dist/VirtualizerLayouts.d.ts +2 -2
- package/dist/VirtualizerLayouts.d.ts.map +1 -1
- package/dist/VisuallyHidden.d.ts +1 -1
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/contexts.d.ts +5 -1
- package/dist/contexts.d.ts.map +1 -1
- package/dist/index.d.ts +73 -71
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23253 -18564
- package/dist/index.js.map +1 -1
- package/dist/index.jsx +18116 -0
- package/dist/index.jsx.map +1 -0
- package/dist/useDragAndDrop.d.ts +13 -13
- package/dist/useDragAndDrop.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/virtualizer/Layout.d.ts +1 -1
- package/dist/virtualizer/Layout.d.ts.map +1 -1
- package/package.json +31 -32
- package/src/ActionBar.tsx +75 -72
- package/src/ActionGroup.tsx +53 -61
- package/src/Alert.tsx +17 -42
- package/src/Autocomplete.tsx +39 -44
- package/src/Breadcrumbs.tsx +149 -80
- package/src/Button.tsx +267 -70
- package/src/Calendar.tsx +218 -138
- package/src/Checkbox.tsx +413 -121
- package/src/Collection.tsx +67 -58
- package/src/Color.tsx +803 -380
- package/src/ColorEditor.tsx +131 -149
- package/src/ComboBox.tsx +414 -249
- package/src/ContextualHelpTrigger.tsx +86 -74
- package/src/DateField.tsx +185 -91
- package/src/DatePicker.tsx +524 -213
- package/src/DateRangePickerContext.tsx +44 -0
- package/src/Dialog.tsx +156 -118
- package/src/Disclosure.tsx +127 -80
- package/src/DragAndDrop.tsx +60 -54
- package/src/DragPreview.tsx +13 -11
- package/src/DropZone.tsx +42 -22
- package/src/FieldError.tsx +45 -23
- package/src/FileTrigger.tsx +19 -19
- package/src/Focusable.tsx +21 -24
- package/src/Form.tsx +71 -16
- package/src/GridList.tsx +273 -197
- package/src/HiddenDateInput.tsx +153 -0
- package/src/HiddenTimeInput.tsx +133 -0
- package/src/Icon.tsx +22 -43
- package/src/Keyboard.tsx +3 -3
- package/src/Landmark.tsx +37 -63
- package/src/Link.tsx +125 -75
- package/src/ListBox.tsx +332 -233
- package/src/ListDropTargetDelegate.ts +81 -80
- package/src/Menu.tsx +1023 -274
- package/src/Meter.tsx +38 -56
- package/src/Modal.tsx +251 -176
- package/src/NumberField.tsx +139 -143
- package/src/Popover.tsx +396 -234
- package/src/Pressable.tsx +21 -21
- package/src/ProgressBar.tsx +48 -57
- package/src/RadioGroup.tsx +524 -122
- package/src/RangeCalendar.tsx +157 -90
- package/src/RouterProvider.tsx +30 -47
- package/src/SearchField.tsx +362 -143
- package/src/Select.tsx +656 -233
- package/src/SelectionIndicator.tsx +18 -15
- package/src/Separator.tsx +47 -49
- package/src/SharedElementTransition.tsx +103 -97
- package/src/Slider.tsx +138 -98
- package/src/StepList.tsx +272 -0
- package/src/Switch.tsx +93 -46
- package/src/Table.tsx +1308 -342
- package/src/Tabs.tsx +324 -103
- package/src/TagGroup.tsx +139 -126
- package/src/Text.tsx +3 -3
- package/src/TextField.tsx +389 -79
- package/src/TimeField.tsx +136 -76
- package/src/Toast.tsx +216 -158
- package/src/ToggleButton.tsx +47 -37
- package/src/ToggleButtonGroup.tsx +39 -34
- package/src/Toolbar.tsx +54 -69
- package/src/Tooltip.tsx +387 -119
- package/src/Tree.tsx +651 -368
- package/src/Virtualizer.tsx +208 -180
- package/src/VirtualizerLayouts.ts +45 -30
- package/src/VisuallyHidden.tsx +19 -19
- package/src/contexts.ts +29 -37
- package/src/index.ts +110 -195
- package/src/useDragAndDrop.ts +87 -71
- package/src/utils.tsx +49 -60
- package/src/virtualizer/Layout.ts +14 -22
- package/dist/index.ssr.js +0 -16996
- package/dist/index.ssr.js.map +0 -1
package/src/ToggleButton.tsx
CHANGED
|
@@ -5,13 +5,7 @@
|
|
|
5
5
|
* Port direction: react-aria-components/src/ToggleButton.tsx
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
type JSX,
|
|
10
|
-
createContext,
|
|
11
|
-
createMemo,
|
|
12
|
-
splitProps,
|
|
13
|
-
useContext,
|
|
14
|
-
} from 'solid-js';
|
|
8
|
+
import { type JSX, createContext, createMemo, splitProps, useContext } from "solid-js";
|
|
15
9
|
import {
|
|
16
10
|
createToggleButton,
|
|
17
11
|
createToggleButtonGroupItem,
|
|
@@ -19,8 +13,8 @@ import {
|
|
|
19
13
|
createHover,
|
|
20
14
|
mergeProps,
|
|
21
15
|
type AriaToggleButtonProps,
|
|
22
|
-
} from
|
|
23
|
-
import type { Key } from
|
|
16
|
+
} from "@proyecto-viviana/solidaria";
|
|
17
|
+
import type { Key } from "@proyecto-viviana/solid-stately";
|
|
24
18
|
import {
|
|
25
19
|
type RenderChildren,
|
|
26
20
|
type ClassNameOrFunction,
|
|
@@ -28,8 +22,19 @@ import {
|
|
|
28
22
|
type SlotProps,
|
|
29
23
|
useRenderProps,
|
|
30
24
|
filterDOMProps,
|
|
31
|
-
} from
|
|
32
|
-
import { useToggleButtonGroupStateContext } from
|
|
25
|
+
} from "./utils";
|
|
26
|
+
import { useToggleButtonGroupStateContext } from "./ToggleButtonGroup";
|
|
27
|
+
|
|
28
|
+
type RefLike<T> = ((el: T) => void) | { current?: T | null } | undefined;
|
|
29
|
+
|
|
30
|
+
function assignRef<T>(ref: RefLike<T>, el: T): void {
|
|
31
|
+
if (!ref) return;
|
|
32
|
+
if (typeof ref === "function") {
|
|
33
|
+
ref(el);
|
|
34
|
+
} else {
|
|
35
|
+
ref.current = el;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
33
38
|
|
|
34
39
|
export interface ToggleButtonRenderProps {
|
|
35
40
|
isHovered: boolean;
|
|
@@ -40,9 +45,7 @@ export interface ToggleButtonRenderProps {
|
|
|
40
45
|
isSelected: boolean;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
export interface ToggleButtonProps
|
|
44
|
-
extends Omit<AriaToggleButtonProps, 'children'>,
|
|
45
|
-
SlotProps {
|
|
48
|
+
export interface ToggleButtonProps extends Omit<AriaToggleButtonProps, "children">, SlotProps {
|
|
46
49
|
/** Key used when inside ToggleButtonGroup selection state. */
|
|
47
50
|
toggleKey?: Key;
|
|
48
51
|
/** Preferred group key prop, parity with RAC item id usage. */
|
|
@@ -50,14 +53,14 @@ export interface ToggleButtonProps
|
|
|
50
53
|
children?: RenderChildren<ToggleButtonRenderProps>;
|
|
51
54
|
class?: ClassNameOrFunction<ToggleButtonRenderProps>;
|
|
52
55
|
style?: StyleOrFunction<ToggleButtonRenderProps>;
|
|
56
|
+
/** Ref for the underlying button element. */
|
|
57
|
+
ref?: RefLike<HTMLButtonElement>;
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
export const ToggleButtonContext = createContext<ToggleButtonProps | null>(null);
|
|
56
61
|
|
|
57
|
-
function resolveDisabledValue(
|
|
58
|
-
isDisabled
|
|
59
|
-
): boolean {
|
|
60
|
-
if (typeof isDisabled === 'function') {
|
|
62
|
+
function resolveDisabledValue(isDisabled: AriaToggleButtonProps["isDisabled"]): boolean {
|
|
63
|
+
if (typeof isDisabled === "function") {
|
|
61
64
|
return isDisabled();
|
|
62
65
|
}
|
|
63
66
|
return !!isDisabled;
|
|
@@ -68,28 +71,34 @@ export function ToggleButton(props: ToggleButtonProps): JSX.Element {
|
|
|
68
71
|
const mergedProps = (contextProps ? mergeProps(contextProps, props) : props) as ToggleButtonProps;
|
|
69
72
|
|
|
70
73
|
const [local, ariaProps] = splitProps(mergedProps, [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
"children",
|
|
75
|
+
"class",
|
|
76
|
+
"style",
|
|
77
|
+
"ref",
|
|
78
|
+
"slot",
|
|
79
|
+
"toggleKey",
|
|
80
|
+
"id",
|
|
77
81
|
]);
|
|
78
82
|
const groupState = useToggleButtonGroupStateContext();
|
|
79
83
|
const groupKey = local.id ?? local.toggleKey;
|
|
84
|
+
const standaloneAriaProps = mergeProps<AriaToggleButtonProps>(ariaProps, {
|
|
85
|
+
get id() {
|
|
86
|
+
return local.id;
|
|
87
|
+
},
|
|
88
|
+
});
|
|
80
89
|
|
|
81
|
-
const toggleAria =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
const toggleAria =
|
|
91
|
+
groupState && groupKey != null
|
|
92
|
+
? createToggleButtonGroupItem(
|
|
93
|
+
{
|
|
94
|
+
...ariaProps,
|
|
95
|
+
id: groupKey,
|
|
96
|
+
},
|
|
97
|
+
groupState,
|
|
98
|
+
)
|
|
99
|
+
: createToggleButton(standaloneAriaProps);
|
|
90
100
|
|
|
91
|
-
const isDisabled = () =>
|
|
92
|
-
resolveDisabledValue(ariaProps.isDisabled) || !!groupState?.isDisabled;
|
|
101
|
+
const isDisabled = () => resolveDisabledValue(ariaProps.isDisabled) || !!groupState?.isDisabled;
|
|
93
102
|
|
|
94
103
|
const { isFocused, isFocusVisible, focusProps } = createFocusRing();
|
|
95
104
|
const { isHovered, hoverProps } = createHover({
|
|
@@ -112,9 +121,9 @@ export function ToggleButton(props: ToggleButtonProps): JSX.Element {
|
|
|
112
121
|
children: local.children,
|
|
113
122
|
class: local.class,
|
|
114
123
|
style: local.style,
|
|
115
|
-
defaultClassName:
|
|
124
|
+
defaultClassName: "solidaria-ToggleButton",
|
|
116
125
|
},
|
|
117
|
-
renderValues
|
|
126
|
+
renderValues,
|
|
118
127
|
);
|
|
119
128
|
|
|
120
129
|
const domProps = createMemo(() => {
|
|
@@ -145,6 +154,7 @@ export function ToggleButton(props: ToggleButtonProps): JSX.Element {
|
|
|
145
154
|
{...cleanHoverProps()}
|
|
146
155
|
class={renderProps.class()}
|
|
147
156
|
style={renderProps.style()}
|
|
157
|
+
ref={(el) => assignRef(local.ref, el)}
|
|
148
158
|
slot={local.slot}
|
|
149
159
|
data-pressed={toggleAria.isPressed() || undefined}
|
|
150
160
|
data-hovered={isHovered() || undefined}
|
|
@@ -5,16 +5,13 @@
|
|
|
5
5
|
* Parity target: react-aria-components/src/ToggleButtonGroup.tsx
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { type JSX, createContext, createMemo, splitProps, useContext } from
|
|
9
|
-
import {
|
|
10
|
-
createToggleButtonGroup,
|
|
11
|
-
mergeProps,
|
|
12
|
-
} from '@proyecto-viviana/solidaria';
|
|
8
|
+
import { type JSX, createContext, createMemo, splitProps, useContext } from "solid-js";
|
|
9
|
+
import { createToggleButtonGroup, mergeProps } from "@proyecto-viviana/solidaria";
|
|
13
10
|
import {
|
|
14
11
|
createToggleGroupState,
|
|
15
12
|
type Key,
|
|
16
13
|
type ToggleGroupState,
|
|
17
|
-
} from
|
|
14
|
+
} from "@proyecto-viviana/solid-stately";
|
|
18
15
|
import {
|
|
19
16
|
type ClassNameOrFunction,
|
|
20
17
|
type StyleOrFunction,
|
|
@@ -22,23 +19,24 @@ import {
|
|
|
22
19
|
type SlotProps,
|
|
23
20
|
useRenderProps,
|
|
24
21
|
filterDOMProps,
|
|
25
|
-
} from
|
|
22
|
+
} from "./utils";
|
|
26
23
|
|
|
27
24
|
export interface ToggleButtonGroupRenderProps {
|
|
28
|
-
orientation:
|
|
25
|
+
orientation: "horizontal" | "vertical";
|
|
29
26
|
isDisabled: boolean;
|
|
30
27
|
state: ToggleGroupState;
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
export interface ToggleButtonGroupProps
|
|
34
|
-
extends
|
|
31
|
+
extends
|
|
32
|
+
Omit<JSX.HTMLAttributes<HTMLDivElement>, "children" | "class" | "style" | "onSelectionChange">,
|
|
35
33
|
SlotProps {
|
|
36
|
-
selectionMode?:
|
|
34
|
+
selectionMode?: "single" | "multiple";
|
|
37
35
|
disallowEmptySelection?: boolean;
|
|
38
36
|
selectedKeys?: Iterable<Key>;
|
|
39
37
|
defaultSelectedKeys?: Iterable<Key>;
|
|
40
38
|
onSelectionChange?: (keys: Set<Key>) => void;
|
|
41
|
-
orientation?:
|
|
39
|
+
orientation?: "horizontal" | "vertical";
|
|
42
40
|
isDisabled?: boolean;
|
|
43
41
|
children?: RenderChildren<ToggleButtonGroupRenderProps>;
|
|
44
42
|
class?: ClassNameOrFunction<ToggleButtonGroupRenderProps>;
|
|
@@ -52,19 +50,20 @@ export type ToggleButtonGroupStateContextValue = ToggleGroupState;
|
|
|
52
50
|
|
|
53
51
|
export function ToggleButtonGroup(props: ToggleButtonGroupProps): JSX.Element {
|
|
54
52
|
const [local, domProps] = splitProps(props, [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
53
|
+
"selectionMode",
|
|
54
|
+
"disallowEmptySelection",
|
|
55
|
+
"selectedKeys",
|
|
56
|
+
"defaultSelectedKeys",
|
|
57
|
+
"onSelectionChange",
|
|
58
|
+
"orientation",
|
|
59
|
+
"isDisabled",
|
|
60
|
+
"children",
|
|
61
|
+
"class",
|
|
62
|
+
"style",
|
|
63
|
+
"ref",
|
|
64
|
+
"slot",
|
|
65
|
+
"aria-label",
|
|
66
|
+
"aria-labelledby",
|
|
68
67
|
]);
|
|
69
68
|
|
|
70
69
|
const state = createToggleGroupState(() => ({
|
|
@@ -84,14 +83,14 @@ export function ToggleButtonGroup(props: ToggleButtonGroupProps): JSX.Element {
|
|
|
84
83
|
get isDisabled() {
|
|
85
84
|
return !!local.isDisabled;
|
|
86
85
|
},
|
|
87
|
-
get
|
|
88
|
-
return local[
|
|
86
|
+
get "aria-label"() {
|
|
87
|
+
return local["aria-label"];
|
|
89
88
|
},
|
|
90
|
-
get
|
|
91
|
-
return local[
|
|
89
|
+
get "aria-labelledby"() {
|
|
90
|
+
return local["aria-labelledby"];
|
|
92
91
|
},
|
|
93
92
|
},
|
|
94
|
-
state
|
|
93
|
+
state,
|
|
95
94
|
);
|
|
96
95
|
|
|
97
96
|
const renderProps = useRenderProps(
|
|
@@ -99,18 +98,18 @@ export function ToggleButtonGroup(props: ToggleButtonGroupProps): JSX.Element {
|
|
|
99
98
|
children: local.children,
|
|
100
99
|
class: local.class,
|
|
101
100
|
style: local.style,
|
|
102
|
-
defaultClassName:
|
|
101
|
+
defaultClassName: "solidaria-ToggleButtonGroup",
|
|
103
102
|
},
|
|
104
103
|
() => ({
|
|
105
|
-
orientation: local.orientation ??
|
|
104
|
+
orientation: local.orientation ?? "horizontal",
|
|
106
105
|
isDisabled: !!local.isDisabled,
|
|
107
106
|
state,
|
|
108
|
-
})
|
|
107
|
+
}),
|
|
109
108
|
);
|
|
110
109
|
|
|
111
110
|
const filteredDomProps = createMemo(() => filterDOMProps(domProps, { global: true }));
|
|
112
111
|
const mergedGroupProps = createMemo(() =>
|
|
113
|
-
mergeProps(filteredDomProps(), groupProps as Record<string, unknown>)
|
|
112
|
+
mergeProps(filteredDomProps(), groupProps as Record<string, unknown>),
|
|
114
113
|
);
|
|
115
114
|
|
|
116
115
|
return (
|
|
@@ -119,8 +118,14 @@ export function ToggleButtonGroup(props: ToggleButtonGroupProps): JSX.Element {
|
|
|
119
118
|
class={renderProps.class()}
|
|
120
119
|
style={renderProps.style()}
|
|
121
120
|
slot={local.slot}
|
|
122
|
-
data-orientation={local.orientation ??
|
|
121
|
+
data-orientation={local.orientation ?? "horizontal"}
|
|
123
122
|
data-disabled={local.isDisabled || undefined}
|
|
123
|
+
ref={(el) => {
|
|
124
|
+
if (!local.ref) return;
|
|
125
|
+
if (typeof local.ref === "function") {
|
|
126
|
+
local.ref(el);
|
|
127
|
+
}
|
|
128
|
+
}}
|
|
124
129
|
>
|
|
125
130
|
<ToggleButtonGroupContext.Provider value={props}>
|
|
126
131
|
<ToggleButtonGroupStateContext.Provider value={state}>
|
package/src/Toolbar.tsx
CHANGED
|
@@ -12,53 +12,37 @@ import {
|
|
|
12
12
|
createMemo,
|
|
13
13
|
splitProps,
|
|
14
14
|
useContext,
|
|
15
|
-
} from
|
|
15
|
+
} from "solid-js";
|
|
16
16
|
import {
|
|
17
17
|
createToolbar,
|
|
18
18
|
type AriaToolbarProps,
|
|
19
19
|
type Orientation,
|
|
20
|
-
} from
|
|
21
|
-
import {
|
|
22
|
-
type SlotProps,
|
|
23
|
-
filterDOMProps,
|
|
24
|
-
} from './utils'
|
|
25
|
-
|
|
26
|
-
// ============================================
|
|
27
|
-
// TYPES
|
|
28
|
-
// ============================================
|
|
20
|
+
} from "@proyecto-viviana/solidaria";
|
|
21
|
+
import { type SlotProps, filterDOMProps } from "./utils";
|
|
29
22
|
|
|
30
23
|
export interface ToolbarRenderProps {
|
|
31
24
|
/** The orientation of the toolbar. */
|
|
32
|
-
orientation: Orientation
|
|
25
|
+
orientation: Orientation;
|
|
33
26
|
}
|
|
34
27
|
|
|
35
|
-
export interface ToolbarProps
|
|
36
|
-
extends AriaToolbarProps,
|
|
37
|
-
ParentProps,
|
|
38
|
-
SlotProps {
|
|
28
|
+
export interface ToolbarProps extends AriaToolbarProps, ParentProps, SlotProps {
|
|
39
29
|
/** The CSS className for the element. A function may be provided to receive render props. */
|
|
40
|
-
class?: string | ((renderProps: ToolbarRenderProps) => string)
|
|
30
|
+
class?: string | ((renderProps: ToolbarRenderProps) => string);
|
|
41
31
|
/** The inline style for the element. A function may be provided to receive render props. */
|
|
42
|
-
style?: JSX.CSSProperties | ((renderProps: ToolbarRenderProps) => JSX.CSSProperties)
|
|
32
|
+
style?: JSX.CSSProperties | ((renderProps: ToolbarRenderProps) => JSX.CSSProperties);
|
|
43
33
|
/** Additional data-* attributes. */
|
|
44
|
-
[key: `data-${string}`]: string | undefined
|
|
34
|
+
[key: `data-${string}`]: string | undefined;
|
|
35
|
+
/** Ref for the toolbar element. */
|
|
36
|
+
ref?: ((el: HTMLDivElement) => void) | { current?: HTMLDivElement | null };
|
|
45
37
|
}
|
|
46
38
|
|
|
47
|
-
// ============================================
|
|
48
|
-
// CONTEXT
|
|
49
|
-
// ============================================
|
|
50
|
-
|
|
51
39
|
export interface ToolbarContextValue {
|
|
52
40
|
slots?: {
|
|
53
|
-
[name: string]: Record<string, unknown
|
|
54
|
-
}
|
|
41
|
+
[name: string]: Record<string, unknown>;
|
|
42
|
+
};
|
|
55
43
|
}
|
|
56
44
|
|
|
57
|
-
export const ToolbarContext = createContext<ToolbarContextValue | null>(null)
|
|
58
|
-
|
|
59
|
-
// ============================================
|
|
60
|
-
// TOOLBAR COMPONENT
|
|
61
|
-
// ============================================
|
|
45
|
+
export const ToolbarContext = createContext<ToolbarContextValue | null>(null);
|
|
62
46
|
|
|
63
47
|
/**
|
|
64
48
|
* A toolbar is a container for a set of interactive controls,
|
|
@@ -87,69 +71,62 @@ export const ToolbarContext = createContext<ToolbarContextValue | null>(null)
|
|
|
87
71
|
export function Toolbar(props: ToolbarProps): JSX.Element {
|
|
88
72
|
const [local, ariaProps, domProps] = splitProps(
|
|
89
73
|
props,
|
|
90
|
-
[
|
|
91
|
-
[
|
|
92
|
-
)
|
|
74
|
+
["class", "style", "slot", "children", "ref"],
|
|
75
|
+
["orientation", "aria-label", "aria-labelledby"],
|
|
76
|
+
);
|
|
93
77
|
|
|
94
|
-
|
|
95
|
-
const ctx = useContext(ToolbarContext)
|
|
78
|
+
const ctx = useContext(ToolbarContext);
|
|
96
79
|
const slotProps = () => {
|
|
97
80
|
if (ctx?.slots && local.slot) {
|
|
98
|
-
return ctx.slots[local.slot] || {}
|
|
81
|
+
return ctx.slots[local.slot] || {};
|
|
99
82
|
}
|
|
100
|
-
return {}
|
|
101
|
-
}
|
|
83
|
+
return {};
|
|
84
|
+
};
|
|
102
85
|
|
|
103
|
-
// Create toolbar aria props
|
|
104
86
|
const { toolbarProps, orientation } = createToolbar({
|
|
105
87
|
get orientation() {
|
|
106
|
-
return ariaProps.orientation
|
|
88
|
+
return ariaProps.orientation;
|
|
107
89
|
},
|
|
108
|
-
get
|
|
90
|
+
get "aria-label"() {
|
|
109
91
|
return (
|
|
110
|
-
(ariaProps[
|
|
111
|
-
(slotProps()[
|
|
112
|
-
)
|
|
92
|
+
(ariaProps["aria-label"] as string | undefined) ??
|
|
93
|
+
(slotProps()["aria-label"] as string | undefined)
|
|
94
|
+
);
|
|
113
95
|
},
|
|
114
|
-
get
|
|
115
|
-
return ariaProps[
|
|
96
|
+
get "aria-labelledby"() {
|
|
97
|
+
return ariaProps["aria-labelledby"] as string | undefined;
|
|
116
98
|
},
|
|
117
|
-
})
|
|
99
|
+
});
|
|
118
100
|
|
|
119
|
-
// Render props values
|
|
120
101
|
const renderValues = createMemo<ToolbarRenderProps>(() => ({
|
|
121
102
|
orientation: orientation(),
|
|
122
|
-
}))
|
|
103
|
+
}));
|
|
123
104
|
|
|
124
|
-
// Resolve class
|
|
125
105
|
const resolvedClass = createMemo(() => {
|
|
126
|
-
const cls = local.class
|
|
127
|
-
if (typeof cls ===
|
|
128
|
-
return cls(renderValues())
|
|
106
|
+
const cls = local.class;
|
|
107
|
+
if (typeof cls === "function") {
|
|
108
|
+
return cls(renderValues());
|
|
129
109
|
}
|
|
130
|
-
return cls ??
|
|
131
|
-
})
|
|
110
|
+
return cls ?? "solidaria-Toolbar";
|
|
111
|
+
});
|
|
132
112
|
|
|
133
|
-
// Resolve style
|
|
134
113
|
const resolvedStyle = createMemo(() => {
|
|
135
|
-
const style = local.style
|
|
136
|
-
if (typeof style ===
|
|
137
|
-
return style(renderValues())
|
|
114
|
+
const style = local.style;
|
|
115
|
+
if (typeof style === "function") {
|
|
116
|
+
return style(renderValues());
|
|
138
117
|
}
|
|
139
|
-
return style
|
|
140
|
-
})
|
|
118
|
+
return style;
|
|
119
|
+
});
|
|
141
120
|
|
|
142
|
-
// Resolve children (support render props)
|
|
143
121
|
const resolvedChildren = createMemo(() => {
|
|
144
|
-
const children = props.children
|
|
145
|
-
if (typeof children ===
|
|
146
|
-
return (children as (props: ToolbarRenderProps) => JSX.Element)(renderValues())
|
|
122
|
+
const children = props.children;
|
|
123
|
+
if (typeof children === "function") {
|
|
124
|
+
return (children as (props: ToolbarRenderProps) => JSX.Element)(renderValues());
|
|
147
125
|
}
|
|
148
|
-
return children
|
|
149
|
-
})
|
|
126
|
+
return children;
|
|
127
|
+
});
|
|
150
128
|
|
|
151
|
-
|
|
152
|
-
const filteredDOMProps = createMemo(() => filterDOMProps(domProps, { global: true }))
|
|
129
|
+
const filteredDOMProps = createMemo(() => filterDOMProps(domProps, { global: true }));
|
|
153
130
|
|
|
154
131
|
return (
|
|
155
132
|
<div
|
|
@@ -159,8 +136,16 @@ export function Toolbar(props: ToolbarProps): JSX.Element {
|
|
|
159
136
|
style={resolvedStyle()}
|
|
160
137
|
slot={local.slot}
|
|
161
138
|
data-orientation={orientation()}
|
|
139
|
+
ref={(el) => {
|
|
140
|
+
if (!local.ref) return;
|
|
141
|
+
if (typeof local.ref === "function") {
|
|
142
|
+
local.ref(el);
|
|
143
|
+
} else {
|
|
144
|
+
local.ref.current = el;
|
|
145
|
+
}
|
|
146
|
+
}}
|
|
162
147
|
>
|
|
163
148
|
{resolvedChildren()}
|
|
164
149
|
</div>
|
|
165
|
-
)
|
|
150
|
+
);
|
|
166
151
|
}
|