@spaced-out/ui-design-system 0.1.14 → 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 +21 -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/components/Tooltip/Tooltip.js +6 -5
- package/lib/components/Tooltip/Tooltip.js.flow +12 -7
- package/lib/components/Tooltip/Tooltip.module.css +15 -1
- 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
|
);
|
|
@@ -13,7 +13,6 @@ var _space = require("../../styles/variables/_space");
|
|
|
13
13
|
var _classify = require("../../utils/classify");
|
|
14
14
|
var _mergeRefs = require("../../utils/merge-refs");
|
|
15
15
|
var _string = require("../../utils/string");
|
|
16
|
-
var _Text = require("../Text");
|
|
17
16
|
var _Truncate = require("../Truncate");
|
|
18
17
|
var _TooltipModule = _interopRequireDefault(require("./Tooltip.module.css"));
|
|
19
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -87,12 +86,14 @@ const Tooltip = _ref => {
|
|
|
87
86
|
}
|
|
88
87
|
}, getFloatingProps()), !!title && /*#__PURE__*/React.createElement(_Truncate.Truncate, {
|
|
89
88
|
line: titleMaxLines
|
|
90
|
-
}, /*#__PURE__*/React.createElement(
|
|
91
|
-
|
|
89
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
className: (0, _classify.classify)(_TooltipModule.default.title, classNames?.title)
|
|
92
91
|
}, title)), !!body && /*#__PURE__*/React.createElement(_Truncate.Truncate, {
|
|
93
92
|
line: bodyMaxLines
|
|
94
|
-
}, /*#__PURE__*/React.createElement(
|
|
95
|
-
|
|
93
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: (0, _classify.classify)(_TooltipModule.default.body, {
|
|
95
|
+
[_TooltipModule.default.hasTitle]: !!title
|
|
96
|
+
}, classNames?.body)
|
|
96
97
|
}, body))), bodyRef.current));
|
|
97
98
|
};
|
|
98
99
|
exports.Tooltip = Tooltip;
|
|
@@ -32,13 +32,12 @@ import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
|
|
|
32
32
|
import {classify} from '../../utils/classify';
|
|
33
33
|
import {mergeRefs} from '../../utils/merge-refs';
|
|
34
34
|
import {capitalize} from '../../utils/string';
|
|
35
|
-
import {BodyMedium, SubTitleExtraSmall} from '../Text';
|
|
36
35
|
import {Truncate} from '../Truncate';
|
|
37
36
|
|
|
38
37
|
import css from './Tooltip.module.css';
|
|
39
38
|
|
|
40
39
|
|
|
41
|
-
type ClassNames = $ReadOnly<{tooltip?: string}>;
|
|
40
|
+
type ClassNames = $ReadOnly<{tooltip?: string, title?: string, body?: string}>;
|
|
42
41
|
|
|
43
42
|
export const DELAY_MOTION_DURATION_TYPES = Object.freeze({
|
|
44
43
|
none: 'none',
|
|
@@ -147,19 +146,25 @@ export const Tooltip = ({
|
|
|
147
146
|
>
|
|
148
147
|
{!!title && (
|
|
149
148
|
<Truncate line={titleMaxLines}>
|
|
150
|
-
<
|
|
149
|
+
<div className={classify(css.title, classNames?.title)}>
|
|
151
150
|
{title}
|
|
152
|
-
</
|
|
151
|
+
</div>
|
|
153
152
|
</Truncate>
|
|
154
153
|
)}
|
|
155
154
|
|
|
156
155
|
{!!body && (
|
|
157
156
|
<Truncate line={bodyMaxLines}>
|
|
158
|
-
<
|
|
159
|
-
|
|
157
|
+
<div
|
|
158
|
+
className={classify(
|
|
159
|
+
css.body,
|
|
160
|
+
{
|
|
161
|
+
[css.hasTitle]: !!title,
|
|
162
|
+
},
|
|
163
|
+
classNames?.body,
|
|
164
|
+
)}
|
|
160
165
|
>
|
|
161
166
|
{body}
|
|
162
|
-
</
|
|
167
|
+
</div>
|
|
163
168
|
</Truncate>
|
|
164
169
|
)}
|
|
165
170
|
</div>,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@value (colorTooltipFill) from '../../styles/variables/_color.css';
|
|
1
|
+
@value (colorTooltipFill, colorTextInversePrimary, colorTextInverseSecondary) from '../../styles/variables/_color.css';
|
|
2
2
|
@value (size300) from '../../styles/variables/_size.css';
|
|
3
3
|
@value (spaceXSmall, spaceSmall, spaceXXSmall) from '../../styles/variables/_space.css';
|
|
4
4
|
@value (borderRadiusSmall) from '../../styles/variables/_border.css';
|
|
@@ -17,3 +17,17 @@
|
|
|
17
17
|
word-wrap: break-word;
|
|
18
18
|
z-index: var(--tooltip-elevation);
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
.title {
|
|
22
|
+
composes: subTitleExtraSmall from '../../styles/typography.module.css';
|
|
23
|
+
color: colorTextInversePrimary;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.body {
|
|
27
|
+
composes: bodyMedium from '../../styles/typography.module.css';
|
|
28
|
+
color: colorTextInversePrimary;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.hasTitle {
|
|
32
|
+
color: colorTextInverseSecondary;
|
|
33
|
+
}
|
|
@@ -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,
|