@automattic/vip-design-system 0.20.1 → 0.22.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/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 +2 -1
- package/build/system/Notification/Notification.js +6 -2
- package/build/system/OptionRow/OptionRow.js +5 -3
- package/build/system/ScreenReaderText/ScreenReaderText.js +16 -13
- package/build/system/Spinner/Spinner.js +7 -3
- package/build/system/Table/Table.js +22 -4
- package/build/system/Table/Table.stories.js +5 -1
- 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 +1 -1
- package/src/system/Notification/Notification.js +41 -34
- package/src/system/OptionRow/OptionRow.js +86 -78
- package/src/system/ScreenReaderText/ScreenReaderText.js +14 -17
- package/src/system/Spinner/Spinner.js +6 -2
- package/src/system/Table/Table.js +25 -10
- package/src/system/Table/Table.stories.jsx +4 -1
- 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
|
@@ -9,6 +9,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
|
|
10
10
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
11
|
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
12
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
15
|
|
|
14
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -19,7 +21,7 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
|
19
21
|
|
|
20
22
|
var _excluded = ["className", "sx"];
|
|
21
23
|
|
|
22
|
-
var Tabs = function
|
|
24
|
+
var Tabs = /*#__PURE__*/_react["default"].forwardRef(function (_ref, forwardRef) {
|
|
23
25
|
var _ref$className = _ref.className,
|
|
24
26
|
className = _ref$className === void 0 ? null : _ref$className,
|
|
25
27
|
sx = _ref.sx,
|
|
@@ -32,11 +34,13 @@ var Tabs = function Tabs(_ref) {
|
|
|
32
34
|
listStyleType: 'none',
|
|
33
35
|
margin: 0,
|
|
34
36
|
padding: 0
|
|
35
|
-
}, sx)
|
|
37
|
+
}, sx),
|
|
38
|
+
ref: forwardRef
|
|
36
39
|
}, props));
|
|
37
|
-
};
|
|
40
|
+
});
|
|
38
41
|
|
|
39
42
|
exports.Tabs = Tabs;
|
|
43
|
+
Tabs.displayName = 'Tabs';
|
|
40
44
|
Tabs.propTypes = {
|
|
41
45
|
className: _propTypes["default"].any,
|
|
42
46
|
sx: _propTypes["default"].object,
|
|
@@ -9,6 +9,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
|
|
10
10
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
11
|
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
12
14
|
var _themeUi = require("theme-ui");
|
|
13
15
|
|
|
14
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -19,7 +21,7 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
|
19
21
|
|
|
20
22
|
var _excluded = ["sx", "className"];
|
|
21
23
|
|
|
22
|
-
var Text = function
|
|
24
|
+
var Text = /*#__PURE__*/_react["default"].forwardRef(function (_ref, forwardRef) {
|
|
23
25
|
var sx = _ref.sx,
|
|
24
26
|
_ref$className = _ref.className,
|
|
25
27
|
className = _ref$className === void 0 ? null : _ref$className,
|
|
@@ -30,11 +32,13 @@ var Text = function Text(_ref) {
|
|
|
30
32
|
lineHeight: 1.5,
|
|
31
33
|
marginBottom: 2
|
|
32
34
|
}, sx),
|
|
33
|
-
className: (0, _classnames["default"])('vip-text-component', className)
|
|
35
|
+
className: (0, _classnames["default"])('vip-text-component', className),
|
|
36
|
+
ref: forwardRef
|
|
34
37
|
}, props));
|
|
35
|
-
};
|
|
38
|
+
});
|
|
36
39
|
|
|
37
40
|
exports.Text = Text;
|
|
41
|
+
Text.displayName = 'Text';
|
|
38
42
|
Text.propTypes = {
|
|
39
43
|
sx: _propTypes["default"].object,
|
|
40
44
|
className: _propTypes["default"].any
|
|
@@ -23,7 +23,7 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
|
23
23
|
|
|
24
24
|
var _excluded = ["steps", "activeStep", "variant", "completed", "className"];
|
|
25
25
|
|
|
26
|
-
var Wizard = function
|
|
26
|
+
var Wizard = /*#__PURE__*/_react["default"].forwardRef(function (_ref, forwardRef) {
|
|
27
27
|
var steps = _ref.steps,
|
|
28
28
|
activeStep = _ref.activeStep,
|
|
29
29
|
variant = _ref.variant,
|
|
@@ -34,6 +34,7 @@ var Wizard = function Wizard(_ref) {
|
|
|
34
34
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
35
35
|
return (0, _jsxRuntime.jsx)(_.Box, {
|
|
36
36
|
className: (0, _classnames["default"])('vip-wizard-component', className),
|
|
37
|
+
ref: forwardRef,
|
|
37
38
|
children: variant === 'horizontal' ? (0, _jsxRuntime.jsxs)(_.Box, {
|
|
38
39
|
children: [(0, _jsxRuntime.jsx)(_.Flex, (0, _extends2["default"])({
|
|
39
40
|
sx: {
|
|
@@ -74,9 +75,10 @@ var Wizard = function Wizard(_ref) {
|
|
|
74
75
|
}, index);
|
|
75
76
|
})
|
|
76
77
|
});
|
|
77
|
-
};
|
|
78
|
+
});
|
|
78
79
|
|
|
79
80
|
exports.Wizard = Wizard;
|
|
81
|
+
Wizard.displayName = 'Wizard';
|
|
80
82
|
Wizard.propTypes = {
|
|
81
83
|
steps: _propTypes["default"].array,
|
|
82
84
|
activeStep: _propTypes["default"].number,
|
|
@@ -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,
|