@automattic/vip-design-system 0.20.0 → 0.21.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/.github/workflows/stale.yml +15 -0
- package/build/system/Avatar/Avatar.js +7 -3
- package/build/system/Badge/Badge.js +7 -3
- package/build/system/Box/Box.js +4 -3
- package/build/system/Code/Code.js +10 -4
- package/build/system/Flex/Flex.js +10 -5
- package/build/system/Form/Label.js +12 -4
- package/build/system/Form/Radio.js +7 -3
- package/build/system/Form/RadioBoxGroup.js +7 -3
- package/build/system/Form/Toggle.js +7 -3
- package/build/system/Form/ToggleGroup.js +7 -3
- package/build/system/Link/Link.js +7 -3
- package/build/system/Notice/Notice.js +9 -4
- package/build/system/Notification/Notification.js +6 -2
- package/build/system/OptionRow/OptionRow.js +5 -3
- package/build/system/Spinner/Spinner.js +7 -3
- package/build/system/Tabs/Tabs.js +7 -3
- package/build/system/Text/Text.js +7 -3
- package/build/system/Wizard/Wizard.js +4 -2
- package/build/system/Wizard/WizardStep.js +6 -2
- package/build/system/Wizard/WizardStepHorizontal.js +6 -2
- package/package.json +1 -1
- package/src/system/Avatar/Avatar.js +54 -53
- package/src/system/Badge/Badge.js +24 -19
- package/src/system/Box/Box.js +2 -2
- package/src/system/Code/Code.js +81 -76
- package/src/system/Flex/Flex.js +6 -1
- package/src/system/Form/Label.js +10 -2
- package/src/system/Form/Radio.js +11 -3
- package/src/system/Form/RadioBoxGroup.js +52 -46
- package/src/system/Form/Toggle.js +50 -50
- package/src/system/Form/ToggleGroup.js +49 -43
- package/src/system/Link/Link.js +6 -2
- package/src/system/Notice/Notice.js +55 -54
- package/src/system/Notification/Notification.js +41 -34
- package/src/system/OptionRow/OptionRow.js +86 -78
- package/src/system/Spinner/Spinner.js +6 -2
- package/src/system/Tabs/Tabs.js +6 -2
- package/src/system/Text/Text.js +6 -2
- package/src/system/Wizard/Wizard.js +49 -45
- package/src/system/Wizard/WizardStep.js +63 -57
- package/src/system/Wizard/WizardStepHorizontal.js +6 -2
|
@@ -5,6 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
6
|
exports.WizardStep = void 0;
|
|
7
7
|
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
8
10
|
var _md = require("react-icons/md");
|
|
9
11
|
|
|
10
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -22,7 +24,7 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
|
22
24
|
/**
|
|
23
25
|
* Internal dependencies
|
|
24
26
|
*/
|
|
25
|
-
var WizardStep = function
|
|
27
|
+
var WizardStep = /*#__PURE__*/_react["default"].forwardRef(function (_ref, forwardRef) {
|
|
26
28
|
var title = _ref.title,
|
|
27
29
|
subTitle = _ref.subTitle,
|
|
28
30
|
_ref$complete = _ref.complete,
|
|
@@ -64,6 +66,7 @@ var WizardStep = function WizardStep(_ref) {
|
|
|
64
66
|
},
|
|
65
67
|
"data-step": order,
|
|
66
68
|
"data-active": active || undefined,
|
|
69
|
+
ref: forwardRef,
|
|
67
70
|
children: [typeof title === 'string' ? (0, _jsxRuntime.jsxs)(_.Heading, {
|
|
68
71
|
variant: "h4",
|
|
69
72
|
sx: {
|
|
@@ -96,9 +99,10 @@ var WizardStep = function WizardStep(_ref) {
|
|
|
96
99
|
children: subTitle
|
|
97
100
|
}), active && children]
|
|
98
101
|
});
|
|
99
|
-
};
|
|
102
|
+
});
|
|
100
103
|
|
|
101
104
|
exports.WizardStep = WizardStep;
|
|
105
|
+
WizardStep.displayName = 'WizardStep';
|
|
102
106
|
WizardStep.propTypes = {
|
|
103
107
|
active: _propTypes["default"].bool,
|
|
104
108
|
children: _propTypes["default"].node,
|
|
@@ -5,6 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
6
|
exports.WizardStepHorizontal = void 0;
|
|
7
7
|
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
8
10
|
var _md = require("react-icons/md");
|
|
9
11
|
|
|
10
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -22,7 +24,7 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
|
22
24
|
/**
|
|
23
25
|
* Internal dependencies
|
|
24
26
|
*/
|
|
25
|
-
var WizardStepHorizontal = function
|
|
27
|
+
var WizardStepHorizontal = /*#__PURE__*/_react["default"].forwardRef(function (_ref, forwardRef) {
|
|
26
28
|
var title = _ref.title,
|
|
27
29
|
active = _ref.active,
|
|
28
30
|
order = _ref.order;
|
|
@@ -37,6 +39,7 @@ var WizardStepHorizontal = function WizardStepHorizontal(_ref) {
|
|
|
37
39
|
},
|
|
38
40
|
"data-step": order,
|
|
39
41
|
"data-active": active || undefined,
|
|
42
|
+
ref: forwardRef,
|
|
40
43
|
children: [(0, _jsxRuntime.jsx)(_md.MdCheckCircle, {
|
|
41
44
|
"aria-hidden": "true",
|
|
42
45
|
sx: {
|
|
@@ -55,9 +58,10 @@ var WizardStepHorizontal = function WizardStepHorizontal(_ref) {
|
|
|
55
58
|
}
|
|
56
59
|
}), title]
|
|
57
60
|
});
|
|
58
|
-
};
|
|
61
|
+
});
|
|
59
62
|
|
|
60
63
|
exports.WizardStepHorizontal = WizardStepHorizontal;
|
|
64
|
+
WizardStepHorizontal.displayName = 'WizardStepHorizontal';
|
|
61
65
|
WizardStepHorizontal.propTypes = {
|
|
62
66
|
active: _propTypes["default"].bool,
|
|
63
67
|
order: _propTypes["default"].number.isRequired,
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
6
7
|
import PropTypes from 'prop-types';
|
|
7
8
|
import { Image } from 'theme-ui';
|
|
8
9
|
import classNames from 'classnames';
|
|
@@ -12,61 +13,61 @@ import classNames from 'classnames';
|
|
|
12
13
|
*/
|
|
13
14
|
import { Box, Text } from '..';
|
|
14
15
|
|
|
15
|
-
const Avatar = (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
</Box>
|
|
16
|
+
const Avatar = React.forwardRef(
|
|
17
|
+
(
|
|
18
|
+
{ isVIP = false, name = null, size = 32, src = null, className = null, ...props },
|
|
19
|
+
forwardRef
|
|
20
|
+
) => (
|
|
21
|
+
<Box
|
|
22
|
+
sx={ {
|
|
23
|
+
borderRadius: 9999,
|
|
24
|
+
height: size + 2, // +2 to compensate padding on both sides
|
|
25
|
+
width: size + 2, // +2 to compensate padding on both sides
|
|
26
|
+
border: '2px solid',
|
|
27
|
+
borderColor: isVIP ? 'primary' : 'transparent',
|
|
28
|
+
overflow: 'hidden',
|
|
29
|
+
backgroundColor: 'primary',
|
|
30
|
+
display: 'inline-flex',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
justifyContent: 'center',
|
|
33
|
+
color: 'white',
|
|
34
|
+
padding: '1px',
|
|
35
|
+
textAlign: 'center',
|
|
36
|
+
} }
|
|
37
|
+
className={ classNames( 'vip-avatar-component', className ) }
|
|
38
|
+
aria-hidden="true"
|
|
39
|
+
ref={ forwardRef }
|
|
40
|
+
{ ...props }
|
|
41
|
+
>
|
|
42
|
+
{ src ? (
|
|
43
|
+
<Image
|
|
44
|
+
src={ src }
|
|
45
|
+
alt={ `Avatar image from ${ name }` }
|
|
46
|
+
sx={ {
|
|
47
|
+
borderRadius: 9999,
|
|
48
|
+
width: '100%',
|
|
49
|
+
display: 'block',
|
|
50
|
+
} }
|
|
51
|
+
/>
|
|
52
|
+
) : (
|
|
53
|
+
<Text
|
|
54
|
+
as="span"
|
|
55
|
+
sx={ {
|
|
56
|
+
color: 'white',
|
|
57
|
+
mb: 0,
|
|
58
|
+
fontWeight: 'bold',
|
|
59
|
+
fontSize: 0,
|
|
60
|
+
textTransform: 'uppercase',
|
|
61
|
+
} }
|
|
62
|
+
>
|
|
63
|
+
{ name ? name.charAt( 0 ) : null }
|
|
64
|
+
</Text>
|
|
65
|
+
) }
|
|
66
|
+
</Box>
|
|
67
|
+
)
|
|
68
68
|
);
|
|
69
69
|
|
|
70
|
+
Avatar.displayName = 'Avatar';
|
|
70
71
|
Avatar.propTypes = {
|
|
71
72
|
isVIP: PropTypes.bool,
|
|
72
73
|
size: PropTypes.number,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
9
|
|
|
@@ -11,27 +12,31 @@ import PropTypes from 'prop-types';
|
|
|
11
12
|
*/
|
|
12
13
|
import { Text } from '../';
|
|
13
14
|
|
|
14
|
-
const Badge = (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
const Badge = React.forwardRef(
|
|
16
|
+
( { variant = 'blue', sx, className = null, ...props }, forwardRef ) => (
|
|
17
|
+
<Text
|
|
18
|
+
as="span"
|
|
19
|
+
sx={ {
|
|
20
|
+
fontSize: 0,
|
|
21
|
+
padding: 0,
|
|
22
|
+
bg: `${ variant }.20`,
|
|
23
|
+
color: `${ variant }.100`,
|
|
24
|
+
py: 1,
|
|
25
|
+
verticalAlign: 'middle',
|
|
26
|
+
px: 2,
|
|
27
|
+
display: 'inline-block',
|
|
28
|
+
borderRadius: 1,
|
|
29
|
+
fontWeight: 'heading',
|
|
30
|
+
...sx,
|
|
31
|
+
} }
|
|
32
|
+
className={ classNames( 'vip-badge-component', className ) }
|
|
33
|
+
ref={ forwardRef }
|
|
34
|
+
{ ...props }
|
|
35
|
+
/>
|
|
36
|
+
)
|
|
33
37
|
);
|
|
34
38
|
|
|
39
|
+
Badge.displayName = 'Badge';
|
|
35
40
|
Badge.propTypes = {
|
|
36
41
|
variant: PropTypes.string,
|
|
37
42
|
sx: PropTypes.object,
|
package/src/system/Box/Box.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
6
7
|
import PropTypes from 'prop-types';
|
|
7
8
|
import classNames from 'classnames';
|
|
8
|
-
import { forwardRef } from 'react';
|
|
9
9
|
import { Box as ThemeBox } from 'theme-ui';
|
|
10
10
|
|
|
11
|
-
const Box = forwardRef( ( props, ref ) => (
|
|
11
|
+
const Box = React.forwardRef( ( props, ref ) => (
|
|
12
12
|
<ThemeBox
|
|
13
13
|
ref={ ref }
|
|
14
14
|
className={ classNames( 'vip-box-component', props.className ) }
|
package/src/system/Code/Code.js
CHANGED
|
@@ -3,92 +3,97 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
+
import React, { useRef, useState } from 'react';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
|
-
import { useRef, useState } from 'react';
|
|
9
9
|
import { MdContentCopy } from 'react-icons/md';
|
|
10
10
|
|
|
11
|
-
const Code = (
|
|
12
|
-
|
|
11
|
+
const Code = React.forwardRef(
|
|
12
|
+
( { prompt = false, showCopy = false, onCopy = null, className, ...props }, forwardRef ) => {
|
|
13
|
+
const ref = useRef();
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
const codeDom = (
|
|
16
|
+
<code
|
|
17
|
+
ref={ ref }
|
|
18
|
+
sx={ {
|
|
19
|
+
fontSize: 1,
|
|
20
|
+
display: 'block',
|
|
21
|
+
bg: 'grey.90',
|
|
22
|
+
color: 'grey.10',
|
|
23
|
+
borderRadius: 1,
|
|
24
|
+
py: 2,
|
|
25
|
+
px: 3,
|
|
26
|
+
verticalAlign: 'middle',
|
|
27
|
+
fontFamily: 'monospace',
|
|
28
|
+
'&:before': {
|
|
29
|
+
content: prompt ? '"$"' : 'none',
|
|
30
|
+
marginRight: 2,
|
|
31
|
+
userSelect: 'none',
|
|
32
|
+
},
|
|
33
|
+
} }
|
|
34
|
+
className={ classNames( 'vip-code-component', className ) }
|
|
35
|
+
{ ...props }
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
if ( ! showCopy ) {
|
|
40
|
+
return codeDom;
|
|
41
|
+
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
const [ copied, setCopied ] = useState( false );
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
sx={ {
|
|
48
|
+
position: 'relative',
|
|
49
|
+
} }
|
|
50
|
+
ref={ forwardRef }
|
|
51
|
+
>
|
|
52
|
+
{ codeDom }
|
|
53
|
+
{
|
|
54
|
+
<button
|
|
55
|
+
aria-label="Copy code"
|
|
56
|
+
sx={ {
|
|
57
|
+
bg: 'grey.10',
|
|
58
|
+
borderTopRightRadius: 1,
|
|
59
|
+
borderWidth: 0,
|
|
60
|
+
color: 'muted',
|
|
61
|
+
opacity: 0.8,
|
|
62
|
+
paddingBottom: 1,
|
|
63
|
+
paddingLeft: 2,
|
|
64
|
+
paddingRight: 2,
|
|
65
|
+
paddingTop: 1,
|
|
66
|
+
position: 'absolute',
|
|
67
|
+
right: 0,
|
|
68
|
+
top: '-1px',
|
|
69
|
+
'&:hover': {
|
|
70
|
+
opacity: 1,
|
|
71
|
+
cursor: 'pointer',
|
|
72
|
+
},
|
|
73
|
+
} }
|
|
74
|
+
onClick={ () => {
|
|
75
|
+
window.navigator.clipboard.writeText( ref.current?.innerText );
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
setCopied( true );
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
79
|
+
if ( onCopy ) {
|
|
80
|
+
onCopy();
|
|
81
|
+
}
|
|
82
|
+
} }
|
|
83
|
+
>
|
|
84
|
+
{ copied ? (
|
|
85
|
+
<span role="alert">Code copied to clipboard</span>
|
|
86
|
+
) : (
|
|
87
|
+
<MdContentCopy aria-hidden="true" />
|
|
88
|
+
) }
|
|
89
|
+
</button>
|
|
90
|
+
}
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
Code.displayName = 'Code';
|
|
92
97
|
|
|
93
98
|
Code.propTypes = {
|
|
94
99
|
prompt: PropTypes.bool,
|
package/src/system/Flex/Flex.js
CHANGED
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
6
7
|
import { Flex as ThemeFlex } from 'theme-ui';
|
|
7
8
|
|
|
8
|
-
const Flex =
|
|
9
|
+
const Flex = React.forwardRef( ( props, forwardRef ) => (
|
|
10
|
+
<ThemeFlex ref={ forwardRef } { ...props } />
|
|
11
|
+
) );
|
|
12
|
+
|
|
13
|
+
Flex.displayName = 'Flex';
|
|
9
14
|
|
|
10
15
|
export { Flex };
|
package/src/system/Form/Label.js
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
/** @jsxImportSource theme-ui */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
3
8
|
/**
|
|
4
9
|
* Internal dependencies
|
|
5
10
|
*/
|
|
6
11
|
import { Heading } from '..';
|
|
7
12
|
|
|
8
|
-
const Label = props => (
|
|
13
|
+
const Label = React.forwardRef( ( props, forwardRef ) => (
|
|
9
14
|
<Heading
|
|
10
15
|
variant="h4"
|
|
11
16
|
as="label"
|
|
12
17
|
sx={ { display: 'block', mb: 2, color: 'muted' } }
|
|
18
|
+
ref={ forwardRef }
|
|
13
19
|
{ ...props }
|
|
14
20
|
/>
|
|
15
|
-
);
|
|
21
|
+
) );
|
|
22
|
+
|
|
23
|
+
Label.displayName = 'Label';
|
|
16
24
|
|
|
17
25
|
export { Label };
|
package/src/system/Form/Radio.js
CHANGED
|
@@ -3,12 +3,20 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
6
7
|
import { Radio as ThemeRadio } from 'theme-ui';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
9
|
|
|
9
|
-
const Radio = ( { disabled, ...props } ) => (
|
|
10
|
-
<ThemeRadio
|
|
11
|
-
|
|
10
|
+
const Radio = React.forwardRef( ( { disabled, ...props }, forwardRef ) => (
|
|
11
|
+
<ThemeRadio
|
|
12
|
+
sx={ { opacity: disabled ? 0.4 : 1 } }
|
|
13
|
+
disabled={ disabled }
|
|
14
|
+
ref={ forwardRef }
|
|
15
|
+
{ ...props }
|
|
16
|
+
/>
|
|
17
|
+
) );
|
|
18
|
+
|
|
19
|
+
Radio.displayName = 'Radio';
|
|
12
20
|
|
|
13
21
|
Radio.propTypes = {
|
|
14
22
|
disabled: PropTypes.bool,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
6
7
|
import PropTypes from 'prop-types';
|
|
7
8
|
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
8
9
|
import { MdCheckCircle } from 'react-icons/md';
|
|
@@ -12,54 +13,59 @@ import { MdCheckCircle } from 'react-icons/md';
|
|
|
12
13
|
*/
|
|
13
14
|
import { Heading, Text } from '../';
|
|
14
15
|
|
|
15
|
-
const RadioBoxGroup = (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
16
|
+
const RadioBoxGroup = React.forwardRef(
|
|
17
|
+
( { onChange, groupLabel, value, options, ...props }, forwardRef ) => (
|
|
18
|
+
<RadioGroupPrimitive.Root
|
|
19
|
+
onValueChange={ onChange }
|
|
20
|
+
value={ value }
|
|
21
|
+
aria-label={ groupLabel }
|
|
22
|
+
sx={ {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
gap: 2,
|
|
25
|
+
} }
|
|
26
|
+
ref={ forwardRef }
|
|
27
|
+
{ ...props }
|
|
28
|
+
>
|
|
29
|
+
{ options.map( ( option, index ) => (
|
|
30
|
+
<RadioGroupPrimitive.Item
|
|
31
|
+
key={ option.value }
|
|
32
|
+
value={ option.value }
|
|
33
|
+
id={ `o${ index }` }
|
|
34
|
+
sx={ {
|
|
35
|
+
p: 3,
|
|
36
|
+
background: 'none',
|
|
37
|
+
cursor: 'pointer',
|
|
38
|
+
borderRadius: 2,
|
|
39
|
+
textAlign: 'left',
|
|
40
|
+
border: '1px solid',
|
|
41
|
+
borderColor: 'border',
|
|
42
|
+
position: 'relative',
|
|
43
|
+
'&:hover': {
|
|
44
|
+
borderColor: 'grey.10',
|
|
45
|
+
},
|
|
46
|
+
'&[data-state=checked]': {
|
|
47
|
+
borderColor: 'primary',
|
|
48
|
+
},
|
|
49
|
+
} }
|
|
50
|
+
>
|
|
51
|
+
<RadioGroupPrimitive.Indicator>
|
|
52
|
+
<MdCheckCircle
|
|
53
|
+
size={ 16 }
|
|
54
|
+
sx={ { position: 'absolute', top: 2, right: 2, color: 'primary' } }
|
|
55
|
+
/>
|
|
56
|
+
</RadioGroupPrimitive.Indicator>
|
|
57
|
+
<Heading variant="h4" as="label" htmlFor={ `o${ index }` } sx={ { mb: 0 } }>
|
|
58
|
+
{ option.label }
|
|
59
|
+
</Heading>
|
|
60
|
+
<Text sx={ { color: 'muted', mb: 0, fontSize: 1 } }>{ option.description }</Text>
|
|
61
|
+
</RadioGroupPrimitive.Item>
|
|
62
|
+
) ) }
|
|
63
|
+
</RadioGroupPrimitive.Root>
|
|
64
|
+
)
|
|
61
65
|
);
|
|
62
66
|
|
|
67
|
+
RadioBoxGroup.displayName = 'RadioBoxGroup';
|
|
68
|
+
|
|
63
69
|
RadioBoxGroup.propTypes = {
|
|
64
70
|
onChange: PropTypes.func,
|
|
65
71
|
options: PropTypes.array,
|