@spaced-out/ui-design-system 0.1.15 → 0.1.16
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/CHANGELOG.md +8 -0
- package/lib/components/Avatar/Avatar.module.css +8 -2
- package/lib/components/AvatarGroup/AvatarGroup.js +21 -11
- package/lib/components/AvatarGroup/AvatarGroup.js.flow +9 -3
- package/lib/components/Checkbox/Checkbox.js +15 -10
- package/lib/components/Checkbox/Checkbox.js.flow +121 -100
- package/lib/components/Checkbox/Checkbox.module.css +4 -1
- package/lib/components/Checkbox/CheckboxGroup.js +4 -3
- package/lib/components/Checkbox/CheckboxGroup.js.flow +76 -65
- package/lib/components/RadioButton/RadioButton.js +15 -9
- package/lib/components/RadioButton/RadioButton.js.flow +91 -70
- package/lib/components/RadioButton/RadioButton.module.css +4 -1
- package/lib/components/RadioButton/RadioGroup.js +4 -3
- package/lib/components/RadioButton/RadioGroup.js.flow +56 -47
- package/lib/components/Toast/Toast.js +8 -10
- package/lib/components/Toast/Toast.js.flow +19 -27
- package/lib/components/Toast/Toast.module.css +8 -0
- package/lib/components/Toggle/Toggle.js +11 -7
- package/lib/components/Toggle/Toggle.js.flow +16 -12
- package/lib/components/Toggle/Toggle.module.css +2 -0
- package/lib/utils/click-away.js.flow +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
5
|
import classify from '../../utils/classify';
|
|
6
|
-
import {FormLabelMedium} from '../Text/Text';
|
|
7
6
|
|
|
8
7
|
import css from './Toggle.module.css';
|
|
9
8
|
|
|
@@ -25,10 +24,11 @@ export type ToggleProps = {
|
|
|
25
24
|
disabled?: boolean,
|
|
26
25
|
focused?: boolean,
|
|
27
26
|
value?: string,
|
|
27
|
+
ariaLabel?: string,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export const Toggle: React$AbstractComponent<ToggleProps,
|
|
31
|
-
React.forwardRef<ToggleProps,
|
|
30
|
+
export const Toggle: React$AbstractComponent<ToggleProps, HTMLInputElement> =
|
|
31
|
+
React.forwardRef<ToggleProps, HTMLInputElement>(
|
|
32
32
|
(
|
|
33
33
|
{
|
|
34
34
|
name = 'toggle',
|
|
@@ -39,11 +39,13 @@ export const Toggle: React$AbstractComponent<ToggleProps, HTMLLabelElement> =
|
|
|
39
39
|
checked,
|
|
40
40
|
focused,
|
|
41
41
|
onChange,
|
|
42
|
+
ariaLabel,
|
|
42
43
|
...props
|
|
43
44
|
}: ToggleProps,
|
|
44
|
-
|
|
45
|
+
forwardRef,
|
|
45
46
|
): React.Node => {
|
|
46
47
|
const toggleInput = React.createRef<HTMLInputElement>();
|
|
48
|
+
React.useImperativeHandle(forwardRef, () => toggleInput.current);
|
|
47
49
|
const handleOnChange = () => {
|
|
48
50
|
if (!disabled) {
|
|
49
51
|
onChange &&
|
|
@@ -54,13 +56,17 @@ export const Toggle: React$AbstractComponent<ToggleProps, HTMLLabelElement> =
|
|
|
54
56
|
}
|
|
55
57
|
};
|
|
56
58
|
|
|
59
|
+
const onWrapClickHandler = () => {
|
|
60
|
+
toggleInput.current?.click();
|
|
61
|
+
};
|
|
62
|
+
|
|
57
63
|
React.useEffect(() => {
|
|
58
64
|
if (toggleInput.current && focused) {
|
|
59
65
|
toggleInput.current.focus();
|
|
60
66
|
}
|
|
61
67
|
}, [focused]);
|
|
62
68
|
return (
|
|
63
|
-
<
|
|
69
|
+
<div
|
|
64
70
|
className={classify(
|
|
65
71
|
css.container,
|
|
66
72
|
{
|
|
@@ -68,7 +74,7 @@ export const Toggle: React$AbstractComponent<ToggleProps, HTMLLabelElement> =
|
|
|
68
74
|
},
|
|
69
75
|
classNames?.wrapper,
|
|
70
76
|
)}
|
|
71
|
-
|
|
77
|
+
onClick={onWrapClickHandler}
|
|
72
78
|
>
|
|
73
79
|
<span className={css.toggleWrap}>
|
|
74
80
|
<input
|
|
@@ -79,6 +85,7 @@ export const Toggle: React$AbstractComponent<ToggleProps, HTMLLabelElement> =
|
|
|
79
85
|
onChange={handleOnChange}
|
|
80
86
|
ref={toggleInput}
|
|
81
87
|
disabled={disabled}
|
|
88
|
+
aria-label={ariaLabel || children}
|
|
82
89
|
{...props}
|
|
83
90
|
/>
|
|
84
91
|
<span
|
|
@@ -88,14 +95,11 @@ export const Toggle: React$AbstractComponent<ToggleProps, HTMLLabelElement> =
|
|
|
88
95
|
/>
|
|
89
96
|
</span>
|
|
90
97
|
{React.Children.count(children) > 0 && (
|
|
91
|
-
<
|
|
92
|
-
color="secondary"
|
|
93
|
-
className={classify(css.toggleLabel, classNames?.label)}
|
|
94
|
-
>
|
|
98
|
+
<div className={classify(css.toggleLabel, classNames?.label)}>
|
|
95
99
|
{children}
|
|
96
|
-
</
|
|
100
|
+
</div>
|
|
97
101
|
)}
|
|
98
|
-
</
|
|
102
|
+
</div>
|
|
99
103
|
);
|
|
100
104
|
},
|
|
101
105
|
);
|
|
@@ -16,7 +16,7 @@ export type ChildProps = {
|
|
|
16
16
|
anchorRef: (?HTMLElement) => mixed,
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
type ClickAwayProps = {
|
|
19
|
+
export type ClickAwayProps = {
|
|
20
20
|
closeOnEscapeKeypress?: boolean,
|
|
21
21
|
children: (props: ChildProps) => React.Node,
|
|
22
22
|
shouldCancel: (event: MouseEvent) => boolean,
|