@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
|
@@ -6,13 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.RadioButton = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
9
|
-
var _Text = require("../Text/Text");
|
|
10
9
|
var _RadioButtonModule = _interopRequireDefault(require("./RadioButton.module.css"));
|
|
11
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
13
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
-
const RadioButton = _ref => {
|
|
14
|
+
const RadioButton = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
|
|
16
15
|
let {
|
|
17
16
|
children,
|
|
18
17
|
disabled = false,
|
|
@@ -22,18 +21,23 @@ const RadioButton = _ref => {
|
|
|
22
21
|
selectedValue,
|
|
23
22
|
onChange,
|
|
24
23
|
align = 'vertical',
|
|
25
|
-
|
|
24
|
+
classNames,
|
|
26
25
|
error = false,
|
|
27
26
|
tabIndex = 0,
|
|
27
|
+
ariaLabel = '',
|
|
28
28
|
...props
|
|
29
29
|
} = _ref;
|
|
30
30
|
const radioInput = /*#__PURE__*/React.createRef();
|
|
31
|
+
React.useImperativeHandle(forwardRef, () => radioInput.current);
|
|
31
32
|
const checked = selectedValue === value;
|
|
32
33
|
React.useEffect(() => {
|
|
33
34
|
if (radioInput.current && focused) {
|
|
34
35
|
radioInput.current.focus();
|
|
35
36
|
}
|
|
36
37
|
}, [focused]);
|
|
38
|
+
const onWrapClickHandler = () => {
|
|
39
|
+
radioInput.current?.click();
|
|
40
|
+
};
|
|
37
41
|
const onChangeHandler = e => {
|
|
38
42
|
if (!disabled) {
|
|
39
43
|
onChange && onChange(e?.target?.value);
|
|
@@ -44,11 +48,12 @@ const RadioButton = _ref => {
|
|
|
44
48
|
onChangeHandler(e);
|
|
45
49
|
}
|
|
46
50
|
};
|
|
47
|
-
return /*#__PURE__*/React.createElement("
|
|
51
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
48
52
|
className: (0, _classify.default)(_RadioButtonModule.default.container, {
|
|
49
53
|
[_RadioButtonModule.default.horizontalRadioButton]: align === 'horizontal-fixed',
|
|
50
54
|
[_RadioButtonModule.default.fluidRadioButton]: align === 'horizontal-fluid'
|
|
51
|
-
},
|
|
55
|
+
}, classNames?.wrapper),
|
|
56
|
+
onClick: onWrapClickHandler
|
|
52
57
|
}, /*#__PURE__*/React.createElement("input", _extends({
|
|
53
58
|
type: "radio",
|
|
54
59
|
checked: checked,
|
|
@@ -64,10 +69,11 @@ const RadioButton = _ref => {
|
|
|
64
69
|
onKeyDown: onKeyDownHandler,
|
|
65
70
|
tabIndex: disabled ? -1 : tabIndex,
|
|
66
71
|
name: name,
|
|
67
|
-
value: value || ''
|
|
68
|
-
|
|
72
|
+
value: value || '',
|
|
73
|
+
"aria-label": ariaLabel || children
|
|
74
|
+
}, props)), React.Children.count(children) > 0 && /*#__PURE__*/React.createElement("div", {
|
|
69
75
|
color: "secondary",
|
|
70
|
-
className: _RadioButtonModule.default.radioLabel
|
|
76
|
+
className: (0, _classify.default)(_RadioButtonModule.default.radioLabel, classNames?.label)
|
|
71
77
|
}, children));
|
|
72
|
-
};
|
|
78
|
+
});
|
|
73
79
|
exports.RadioButton = RadioButton;
|
|
@@ -4,7 +4,6 @@ import * as React from 'react';
|
|
|
4
4
|
|
|
5
5
|
import type {GroupAlign} from '../../types/common';
|
|
6
6
|
import classify from '../../utils/classify';
|
|
7
|
-
import {FormLabelMedium} from '../Text/Text';
|
|
8
7
|
|
|
9
8
|
import css from './RadioButton.module.css';
|
|
10
9
|
|
|
@@ -15,6 +14,8 @@ import css from './RadioButton.module.css';
|
|
|
15
14
|
* nesting labels is a bad idea.
|
|
16
15
|
*/
|
|
17
16
|
|
|
17
|
+
type ClassNames = $ReadOnly<{wrapper?: string, label?: string}>;
|
|
18
|
+
|
|
18
19
|
export type RadioButtonProps = {
|
|
19
20
|
children?: React.Node,
|
|
20
21
|
value?: string,
|
|
@@ -23,82 +24,102 @@ export type RadioButtonProps = {
|
|
|
23
24
|
name?: string,
|
|
24
25
|
selectedValue?: string,
|
|
25
26
|
align?: GroupAlign,
|
|
26
|
-
|
|
27
|
+
classNames?: ClassNames,
|
|
27
28
|
error?: boolean,
|
|
28
29
|
onChange?: (newValue: string) => mixed,
|
|
29
30
|
tabIndex?: number,
|
|
31
|
+
ariaLabel?: string,
|
|
30
32
|
};
|
|
31
33
|
|
|
32
|
-
export const RadioButton
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
export const RadioButton: React$AbstractComponent<
|
|
35
|
+
RadioButtonProps,
|
|
36
|
+
HTMLInputElement,
|
|
37
|
+
> = React.forwardRef<RadioButtonProps, HTMLInputElement>(
|
|
38
|
+
(
|
|
39
|
+
{
|
|
40
|
+
children,
|
|
41
|
+
disabled = false,
|
|
42
|
+
value = '',
|
|
43
|
+
focused = false,
|
|
44
|
+
name = 'radio',
|
|
45
|
+
selectedValue,
|
|
46
|
+
onChange,
|
|
47
|
+
align = 'vertical',
|
|
48
|
+
classNames,
|
|
49
|
+
error = false,
|
|
50
|
+
tabIndex = 0,
|
|
51
|
+
ariaLabel = '',
|
|
52
|
+
...props
|
|
53
|
+
}: RadioButtonProps,
|
|
54
|
+
forwardRef,
|
|
55
|
+
): React.Node => {
|
|
56
|
+
const radioInput = React.createRef<HTMLInputElement>();
|
|
57
|
+
React.useImperativeHandle(forwardRef, () => radioInput.current);
|
|
47
58
|
|
|
48
|
-
|
|
59
|
+
const checked = selectedValue === value;
|
|
49
60
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
if (radioInput.current && focused) {
|
|
63
|
+
radioInput.current.focus();
|
|
64
|
+
}
|
|
65
|
+
}, [focused]);
|
|
55
66
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
};
|
|
67
|
+
const onWrapClickHandler = () => {
|
|
68
|
+
radioInput.current?.click();
|
|
69
|
+
};
|
|
61
70
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
const onChangeHandler = (e) => {
|
|
72
|
+
if (!disabled) {
|
|
73
|
+
onChange && onChange(e?.target?.value);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
67
76
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
className
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
77
|
+
const onKeyDownHandler = (e) => {
|
|
78
|
+
if (e.key === 'Enter') {
|
|
79
|
+
onChangeHandler(e);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div
|
|
85
|
+
className={classify(
|
|
86
|
+
css.container,
|
|
87
|
+
{
|
|
88
|
+
[css.horizontalRadioButton]: align === 'horizontal-fixed',
|
|
89
|
+
[css.fluidRadioButton]: align === 'horizontal-fluid',
|
|
90
|
+
},
|
|
91
|
+
classNames?.wrapper,
|
|
92
|
+
)}
|
|
93
|
+
onClick={onWrapClickHandler}
|
|
94
|
+
>
|
|
95
|
+
<input
|
|
96
|
+
type="radio"
|
|
97
|
+
checked={checked}
|
|
98
|
+
disabled={disabled}
|
|
99
|
+
className={classify(css.radio, {
|
|
100
|
+
[css.unselected]: !checked && !disabled && !error,
|
|
101
|
+
[css.selected]: checked && !disabled && !error,
|
|
102
|
+
[css.disabled]: disabled,
|
|
103
|
+
[css.error]: error && !disabled,
|
|
104
|
+
})}
|
|
105
|
+
ref={radioInput}
|
|
106
|
+
onChange={onChangeHandler}
|
|
107
|
+
onKeyDown={onKeyDownHandler}
|
|
108
|
+
tabIndex={disabled ? -1 : tabIndex}
|
|
109
|
+
name={name}
|
|
110
|
+
value={value || ''}
|
|
111
|
+
aria-label={ariaLabel || children}
|
|
112
|
+
{...props}
|
|
113
|
+
/>
|
|
114
|
+
{React.Children.count(children) > 0 && (
|
|
115
|
+
<div
|
|
116
|
+
color="secondary"
|
|
117
|
+
className={classify(css.radioLabel, classNames?.label)}
|
|
118
|
+
>
|
|
119
|
+
{children}
|
|
120
|
+
</div>
|
|
121
|
+
)}
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
},
|
|
125
|
+
);
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
flex-direction: row;
|
|
36
36
|
gap: spaceSmall;
|
|
37
37
|
cursor: pointer;
|
|
38
|
+
align-items: center;
|
|
39
|
+
cursor: pointer;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
.radio {
|
|
@@ -88,7 +90,8 @@
|
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
.radioLabel {
|
|
91
|
-
composes:
|
|
93
|
+
composes: formLabelMedium from '../../styles/typography.module.css';
|
|
94
|
+
composes: secondary from '../../styles/typography.module.css';
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
.horizontalRadioButton {
|
|
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
14
|
|
|
15
|
-
const RadioGroup = _ref => {
|
|
15
|
+
const RadioGroup = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
|
|
16
16
|
let {
|
|
17
17
|
align = 'vertical',
|
|
18
18
|
name,
|
|
@@ -47,10 +47,11 @@ const RadioGroup = _ref => {
|
|
|
47
47
|
[_RadioGroupModule.default.vertical]: align === 'vertical',
|
|
48
48
|
[_RadioGroupModule.default.horizontal]: align === 'horizontal-fixed',
|
|
49
49
|
[_RadioGroupModule.default.horizontalFluid]: align === 'horizontal-fluid'
|
|
50
|
-
}, classNames?.radioGroup)
|
|
50
|
+
}, classNames?.radioGroup),
|
|
51
|
+
ref: forwardRef
|
|
51
52
|
}, childrenWithProps), error && /*#__PURE__*/React.createElement(_Text.BodySmall, {
|
|
52
53
|
color: "danger",
|
|
53
54
|
className: classNames?.errorText
|
|
54
55
|
}, errorText));
|
|
55
|
-
};
|
|
56
|
+
});
|
|
56
57
|
exports.RadioGroup = RadioGroup;
|
|
@@ -32,54 +32,63 @@ export type RadioGroupProps = {
|
|
|
32
32
|
errorText?: string,
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
export const RadioGroup
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
export const RadioGroup: React$AbstractComponent<
|
|
36
|
+
RadioGroupProps,
|
|
37
|
+
HTMLDivElement,
|
|
38
|
+
> = React.forwardRef<RadioGroupProps, HTMLDivElement>(
|
|
39
|
+
(
|
|
40
|
+
{
|
|
41
|
+
align = 'vertical',
|
|
42
|
+
name,
|
|
43
|
+
value,
|
|
44
|
+
onChange,
|
|
45
|
+
children,
|
|
46
|
+
classNames,
|
|
47
|
+
error = false,
|
|
48
|
+
errorText = '',
|
|
49
|
+
}: RadioGroupProps,
|
|
50
|
+
forwardRef,
|
|
51
|
+
): React.Node => {
|
|
52
|
+
const onChangeHandler = (value) => {
|
|
53
|
+
if (onChange) {
|
|
54
|
+
onChange(value);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
50
57
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
const childrenWithProps = React.Children.map(children, (child) => {
|
|
59
|
+
if (React.isValidElement(child)) {
|
|
60
|
+
return React.cloneElement(child, {
|
|
61
|
+
name,
|
|
62
|
+
selectedValue: value,
|
|
63
|
+
onChange: onChangeHandler,
|
|
64
|
+
align,
|
|
65
|
+
error,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return child;
|
|
69
|
+
});
|
|
63
70
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
return (
|
|
72
|
+
<div className={classify(css.radioGroupContainer, classNames?.wrapper)}>
|
|
73
|
+
<div
|
|
74
|
+
className={classify(
|
|
75
|
+
{
|
|
76
|
+
[css.vertical]: align === 'vertical',
|
|
77
|
+
[css.horizontal]: align === 'horizontal-fixed',
|
|
78
|
+
[css.horizontalFluid]: align === 'horizontal-fluid',
|
|
79
|
+
},
|
|
80
|
+
classNames?.radioGroup,
|
|
81
|
+
)}
|
|
82
|
+
ref={forwardRef}
|
|
83
|
+
>
|
|
84
|
+
{childrenWithProps}
|
|
85
|
+
</div>
|
|
86
|
+
{error && (
|
|
87
|
+
<BodySmall color="danger" className={classNames?.errorText}>
|
|
88
|
+
{errorText}
|
|
89
|
+
</BodySmall>
|
|
74
90
|
)}
|
|
75
|
-
>
|
|
76
|
-
{childrenWithProps}
|
|
77
91
|
</div>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
</BodySmall>
|
|
82
|
-
)}
|
|
83
|
-
</div>
|
|
84
|
-
);
|
|
85
|
-
};
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
);
|
|
@@ -9,6 +9,7 @@ var _reactDomInteractions = require("@floating-ui/react-dom-interactions");
|
|
|
9
9
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
10
10
|
var _Icon = require("../Icon");
|
|
11
11
|
var _Text = require("../Text");
|
|
12
|
+
var _typographyModule = _interopRequireDefault(require("../../styles/typography.module.css"));
|
|
12
13
|
var _ToastModule = _interopRequireDefault(require("./Toast.module.css"));
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -22,13 +23,6 @@ const TOAST_SEMANTIC = Object.freeze({
|
|
|
22
23
|
primary: 'primary'
|
|
23
24
|
});
|
|
24
25
|
exports.TOAST_SEMANTIC = TOAST_SEMANTIC;
|
|
25
|
-
const TOAST_TITLE_COLOR = {
|
|
26
|
-
success: _Text.TEXT_COLORS.success,
|
|
27
|
-
information: _Text.TEXT_COLORS.information,
|
|
28
|
-
warning: _Text.TEXT_COLORS.warning,
|
|
29
|
-
danger: _Text.TEXT_COLORS.danger,
|
|
30
|
-
primary: _Text.TEXT_COLORS.primary
|
|
31
|
-
};
|
|
32
26
|
const ToastIcon = _ref => {
|
|
33
27
|
let {
|
|
34
28
|
semantic
|
|
@@ -75,10 +69,11 @@ const ToastTitle = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
75
69
|
let {
|
|
76
70
|
children,
|
|
77
71
|
semantic = '',
|
|
72
|
+
className,
|
|
78
73
|
...props
|
|
79
74
|
} = _ref2;
|
|
80
|
-
return /*#__PURE__*/React.createElement(
|
|
81
|
-
|
|
75
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
76
|
+
className: (0, _classify.default)(_ToastModule.default.toastTitle, _typographyModule.default[semantic], className)
|
|
82
77
|
}, props, {
|
|
83
78
|
ref: ref
|
|
84
79
|
}), children);
|
|
@@ -88,9 +83,12 @@ ToastTitle.displayName = 'ToastTitle';
|
|
|
88
83
|
const ToastBody = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
89
84
|
let {
|
|
90
85
|
children,
|
|
86
|
+
className,
|
|
91
87
|
...props
|
|
92
88
|
} = _ref3;
|
|
93
|
-
return /*#__PURE__*/React.createElement(
|
|
89
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
90
|
+
className: (0, _classify.default)(_ToastModule.default.toastBody, className)
|
|
91
|
+
}, props, {
|
|
94
92
|
ref: ref
|
|
95
93
|
}), children);
|
|
96
94
|
});
|
|
@@ -8,16 +8,11 @@ import {
|
|
|
8
8
|
useFloating,
|
|
9
9
|
} from '@floating-ui/react-dom-interactions';
|
|
10
10
|
|
|
11
|
-
import type {ColorTypes} from '../../types/typography';
|
|
12
11
|
import classify from '../../utils/classify';
|
|
13
12
|
import {CloseIcon, Icon} from '../Icon';
|
|
14
|
-
import {
|
|
15
|
-
BodyMedium,
|
|
16
|
-
SubTitleExtraSmall,
|
|
17
|
-
SubTitleSmall,
|
|
18
|
-
TEXT_COLORS,
|
|
19
|
-
} from '../Text';
|
|
13
|
+
import {SubTitleExtraSmall, TEXT_COLORS} from '../Text';
|
|
20
14
|
|
|
15
|
+
import typography from '../../styles/typography.module.css';
|
|
21
16
|
import css from './Toast.module.css';
|
|
22
17
|
|
|
23
18
|
|
|
@@ -31,14 +26,6 @@ export const TOAST_SEMANTIC = Object.freeze({
|
|
|
31
26
|
primary: 'primary',
|
|
32
27
|
});
|
|
33
28
|
|
|
34
|
-
const TOAST_TITLE_COLOR = {
|
|
35
|
-
success: TEXT_COLORS.success,
|
|
36
|
-
information: TEXT_COLORS.information,
|
|
37
|
-
warning: TEXT_COLORS.warning,
|
|
38
|
-
danger: TEXT_COLORS.danger,
|
|
39
|
-
primary: TEXT_COLORS.primary,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
29
|
export type ToastSemanticType = $Values<typeof TOAST_SEMANTIC>;
|
|
43
30
|
|
|
44
31
|
export type ToastProps = {
|
|
@@ -109,17 +96,23 @@ export type ToastTitleProps = {
|
|
|
109
96
|
children?: React.Node,
|
|
110
97
|
className?: string,
|
|
111
98
|
semantic?: ToastSemanticType,
|
|
112
|
-
color?: ColorTypes,
|
|
113
99
|
};
|
|
114
100
|
|
|
115
101
|
export const ToastTitle: React$AbstractComponent<
|
|
116
102
|
ToastTitleProps,
|
|
117
|
-
|
|
118
|
-
> = React.forwardRef<ToastTitleProps,
|
|
119
|
-
(
|
|
120
|
-
|
|
103
|
+
HTMLDivElement,
|
|
104
|
+
> = React.forwardRef<ToastTitleProps, HTMLDivElement>(
|
|
105
|
+
(
|
|
106
|
+
{children, semantic = '', className, ...props}: ToastTitleProps,
|
|
107
|
+
ref,
|
|
108
|
+
): React.Node => (
|
|
109
|
+
<div
|
|
110
|
+
className={classify(css.toastTitle, typography[semantic], className)}
|
|
111
|
+
{...props}
|
|
112
|
+
ref={ref}
|
|
113
|
+
>
|
|
121
114
|
{children}
|
|
122
|
-
</
|
|
115
|
+
</div>
|
|
123
116
|
),
|
|
124
117
|
);
|
|
125
118
|
|
|
@@ -128,17 +121,16 @@ ToastTitle.displayName = 'ToastTitle';
|
|
|
128
121
|
export type ToastBodyProps = {
|
|
129
122
|
children?: React.Node,
|
|
130
123
|
className?: string,
|
|
131
|
-
color?: ColorTypes,
|
|
132
124
|
};
|
|
133
125
|
|
|
134
126
|
export const ToastBody: React$AbstractComponent<
|
|
135
127
|
ToastBodyProps,
|
|
136
|
-
|
|
137
|
-
> = React.forwardRef<ToastBodyProps,
|
|
138
|
-
({children, ...props}: ToastBodyProps, ref): React.Node => (
|
|
139
|
-
<
|
|
128
|
+
HTMLDivElement,
|
|
129
|
+
> = React.forwardRef<ToastBodyProps, HTMLDivElement>(
|
|
130
|
+
({children, className, ...props}: ToastBodyProps, ref): React.Node => (
|
|
131
|
+
<div className={classify(css.toastBody, className)} {...props} ref={ref}>
|
|
140
132
|
{children}
|
|
141
|
-
</
|
|
133
|
+
</div>
|
|
142
134
|
),
|
|
143
135
|
);
|
|
144
136
|
|
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
gap: spaceXXSmall;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
.toastBody {
|
|
48
|
+
composes: bodyMedium from '../../styles/typography.module.css';
|
|
49
|
+
}
|
|
50
|
+
|
|
47
51
|
.toastFooterActions {
|
|
48
52
|
display: flex;
|
|
49
53
|
flex-direction: row;
|
|
@@ -54,3 +58,7 @@
|
|
|
54
58
|
.closeIcon {
|
|
55
59
|
margin-left: auto;
|
|
56
60
|
}
|
|
61
|
+
|
|
62
|
+
.toastTitle {
|
|
63
|
+
composes: subTitleSmall from '../../styles/typography.module.css';
|
|
64
|
+
}
|
|
@@ -6,13 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Toggle = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
9
|
-
var _Text = require("../Text/Text");
|
|
10
9
|
var _ToggleModule = _interopRequireDefault(require("./Toggle.module.css"));
|
|
11
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
13
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
-
const Toggle = /*#__PURE__*/React.forwardRef((_ref,
|
|
14
|
+
const Toggle = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
|
|
16
15
|
let {
|
|
17
16
|
name = 'toggle',
|
|
18
17
|
value = '',
|
|
@@ -22,9 +21,11 @@ const Toggle = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
22
21
|
checked,
|
|
23
22
|
focused,
|
|
24
23
|
onChange,
|
|
24
|
+
ariaLabel,
|
|
25
25
|
...props
|
|
26
26
|
} = _ref;
|
|
27
27
|
const toggleInput = /*#__PURE__*/React.createRef();
|
|
28
|
+
React.useImperativeHandle(forwardRef, () => toggleInput.current);
|
|
28
29
|
const handleOnChange = () => {
|
|
29
30
|
if (!disabled) {
|
|
30
31
|
onChange && onChange({
|
|
@@ -33,16 +34,19 @@ const Toggle = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
};
|
|
37
|
+
const onWrapClickHandler = () => {
|
|
38
|
+
toggleInput.current?.click();
|
|
39
|
+
};
|
|
36
40
|
React.useEffect(() => {
|
|
37
41
|
if (toggleInput.current && focused) {
|
|
38
42
|
toggleInput.current.focus();
|
|
39
43
|
}
|
|
40
44
|
}, [focused]);
|
|
41
|
-
return /*#__PURE__*/React.createElement("
|
|
45
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
42
46
|
className: (0, _classify.default)(_ToggleModule.default.container, {
|
|
43
47
|
[_ToggleModule.default.disabled]: disabled
|
|
44
48
|
}, classNames?.wrapper),
|
|
45
|
-
|
|
49
|
+
onClick: onWrapClickHandler
|
|
46
50
|
}, /*#__PURE__*/React.createElement("span", {
|
|
47
51
|
className: _ToggleModule.default.toggleWrap
|
|
48
52
|
}, /*#__PURE__*/React.createElement("input", _extends({
|
|
@@ -52,13 +56,13 @@ const Toggle = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
52
56
|
checked: checked,
|
|
53
57
|
onChange: handleOnChange,
|
|
54
58
|
ref: toggleInput,
|
|
55
|
-
disabled: disabled
|
|
59
|
+
disabled: disabled,
|
|
60
|
+
"aria-label": ariaLabel || children
|
|
56
61
|
}, props)), /*#__PURE__*/React.createElement("span", {
|
|
57
62
|
className: (0, _classify.default)(_ToggleModule.default.toggle, {
|
|
58
63
|
[_ToggleModule.default.disabledButton]: disabled
|
|
59
64
|
})
|
|
60
|
-
})), React.Children.count(children) > 0 && /*#__PURE__*/React.createElement(
|
|
61
|
-
color: "secondary",
|
|
65
|
+
})), React.Children.count(children) > 0 && /*#__PURE__*/React.createElement("div", {
|
|
62
66
|
className: (0, _classify.default)(_ToggleModule.default.toggleLabel, classNames?.label)
|
|
63
67
|
}, children));
|
|
64
68
|
});
|