@automattic/vip-design-system 0.9.4 → 0.10.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/nodejs.yaml +1 -1
- package/README.md +4 -4
- package/build/system/Avatar/Avatar.js +9 -3
- package/build/system/Badge/Badge.js +9 -3
- package/build/system/BlankState/BlankState.js +8 -2
- package/build/system/Box/Box.js +12 -2
- package/build/system/Button/Button.js +6 -2
- package/build/system/Card/Card.js +8 -3
- package/build/system/Code/Code.js +8 -3
- package/build/system/ConfirmationDialog/ConfirmationDialog.js +8 -2
- package/build/system/Dialog/Dialog.js +1 -0
- package/build/system/Form/AsyncSearchSelect.js +38 -0
- package/build/system/Form/SearchSelect.js +47 -11
- package/build/system/Form/Select.js +22 -2
- package/build/system/Form/Select.test.js +52 -0
- package/build/system/Form/Toggle.js +8 -2
- package/build/system/Heading/Heading.js +9 -3
- package/build/system/Notice/Notice.js +9 -3
- package/build/system/Notification/Notification.js +1 -0
- package/build/system/OptionRow/OptionRow.js +13 -3
- package/build/system/OptionRow/OptionRow.test.js +46 -0
- package/build/system/Progress/Progress.js +9 -3
- package/build/system/ResourceList/ResourceList.js +1 -0
- package/build/system/Spinner/Spinner.js +9 -3
- package/build/system/Tabs/TabItem.js +1 -0
- package/build/system/Tabs/Tabs.js +10 -4
- package/build/system/Text/Text.js +9 -3
- package/build/system/Time/index.js +9 -3
- package/build/system/Timeline/Timeline.js +77 -0
- package/build/system/Timeline/index.js +2 -66
- package/build/system/Wizard/Wizard.js +10 -2
- package/build/system/Wizard/WizardStep.js +6 -2
- package/build/system/Wizard/WizardStepHorizontal.js +6 -2
- package/package.json +4 -2
- package/src/system/Avatar/Avatar.js +4 -0
- package/src/system/Badge/Badge.js +4 -1
- package/src/system/BlankState/BlankState.js +4 -1
- package/src/system/Box/Box.js +6 -1
- package/src/system/Button/Button.js +3 -0
- package/src/system/Card/Card.js +4 -1
- package/src/system/Code/Code.js +4 -1
- package/src/system/ConfirmationDialog/ConfirmationDialog.js +4 -2
- package/src/system/Dialog/Dialog.js +1 -1
- package/src/system/Form/AsyncSearchSelect.js +29 -0
- package/src/system/Form/SearchSelect.js +43 -3
- package/src/system/Form/Select.js +16 -3
- package/src/system/Form/Select.stories.js +30 -0
- package/src/system/Form/Select.test.js +37 -0
- package/src/system/Form/Toggle.js +4 -2
- package/src/system/Heading/Heading.js +4 -1
- package/src/system/Notice/Notice.js +4 -1
- package/src/system/Notification/Notification.js +1 -0
- package/src/system/OptionRow/OptionRow.js +7 -0
- package/src/system/OptionRow/OptionRow.stories.js +1 -0
- package/src/system/OptionRow/OptionRow.test.js +27 -0
- package/src/system/Progress/Progress.js +4 -1
- package/src/system/ResourceList/ResourceList.js +1 -1
- package/src/system/Spinner/Spinner.js +4 -1
- package/src/system/Tabs/TabItem.js +1 -0
- package/src/system/Tabs/Tabs.js +5 -2
- package/src/system/Text/Text.js +4 -1
- package/src/system/Time/index.js +4 -1
- package/src/system/Timeline/Timeline.js +48 -0
- package/src/system/Timeline/Timeline.stories.js +34 -0
- package/src/system/Timeline/index.js +2 -41
- package/src/system/Wizard/Wizard.js +6 -2
- package/src/system/Wizard/Wizard.stories.js +1 -1
- package/src/system/Wizard/WizardStep.js +5 -2
- package/src/system/Wizard/WizardStepHorizontal.js +4 -1
package/README.md
CHANGED
|
@@ -43,10 +43,10 @@ Note: it's super useful to run `npm run watch` in another process, so any change
|
|
|
43
43
|
|
|
44
44
|
### Publish NPM Package Instructions
|
|
45
45
|
|
|
46
|
-
Once all the changes needed are merged to
|
|
46
|
+
Once all the changes needed are merged to trunk, and you are ready to release a new version, follow these steps:
|
|
47
47
|
|
|
48
48
|
1. Make sure you have NPM access to our @automattic organization. Ask for #vip-platform-pâtisserie help in case you need it.
|
|
49
|
-
2. Pull all the changes to your local
|
|
49
|
+
2. Pull all the changes to your local trunk. Make sure you have the latest trunk locally.
|
|
50
50
|
3. We follow the [https://semver.org/](https://semver.org/) versioning. You should run the specific version you are trying to publish:
|
|
51
51
|
|
|
52
52
|
```bash
|
|
@@ -67,11 +67,11 @@ npm publish
|
|
|
67
67
|
|
|
68
68
|
Note: You need to have two-factor enabled in your npm account. The publish command will request a two-factor code to complete the publishing process.
|
|
69
69
|
|
|
70
|
-
7. Push the tags to the repository and
|
|
70
|
+
7. Push the tags to the repository and trunk updates.
|
|
71
71
|
|
|
72
72
|
```
|
|
73
73
|
git push --tags
|
|
74
|
-
git push origin
|
|
74
|
+
git push origin trunk
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
8. For major versions or breaking changes, it's recommended to [create a RELEASE](https://github.com/Automattic/vip-design-system/releases) with the published tag.
|
|
@@ -7,11 +7,13 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
7
7
|
|
|
8
8
|
var _themeUi = require("theme-ui");
|
|
9
9
|
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
|
|
10
12
|
var _ = require("..");
|
|
11
13
|
|
|
12
14
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
13
15
|
|
|
14
|
-
var _excluded = ["isVIP", "name", "size", "src"];
|
|
16
|
+
var _excluded = ["isVIP", "name", "size", "src", "className"];
|
|
15
17
|
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
19
|
|
|
@@ -28,6 +30,8 @@ var Avatar = function Avatar(_ref) {
|
|
|
28
30
|
size = _ref$size === void 0 ? 32 : _ref$size,
|
|
29
31
|
_ref$src = _ref.src,
|
|
30
32
|
src = _ref$src === void 0 ? null : _ref$src,
|
|
33
|
+
_ref$className = _ref.className,
|
|
34
|
+
className = _ref$className === void 0 ? null : _ref$className,
|
|
31
35
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
32
36
|
|
|
33
37
|
return (0, _jsxRuntime.jsx)(_.Box, _extends({
|
|
@@ -47,7 +51,8 @@ var Avatar = function Avatar(_ref) {
|
|
|
47
51
|
color: 'white',
|
|
48
52
|
padding: '1px',
|
|
49
53
|
textAlign: 'center'
|
|
50
|
-
}
|
|
54
|
+
},
|
|
55
|
+
className: (0, _classnames["default"])('vip-avatar-component', className)
|
|
51
56
|
}, props, {
|
|
52
57
|
children: src ? (0, _jsxRuntime.jsx)(_themeUi.Image, {
|
|
53
58
|
src: src,
|
|
@@ -76,5 +81,6 @@ Avatar.propTypes = {
|
|
|
76
81
|
isVIP: _propTypes["default"].bool,
|
|
77
82
|
size: _propTypes["default"].number,
|
|
78
83
|
src: _propTypes["default"].string,
|
|
79
|
-
name: _propTypes["default"].string
|
|
84
|
+
name: _propTypes["default"].string,
|
|
85
|
+
className: _propTypes["default"].any
|
|
80
86
|
};
|
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.Badge = void 0;
|
|
5
5
|
|
|
6
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
7
|
+
|
|
6
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
9
|
|
|
8
10
|
var _ = require("../");
|
|
9
11
|
|
|
10
12
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
11
13
|
|
|
12
|
-
var _excluded = ["variant", "sx"];
|
|
14
|
+
var _excluded = ["variant", "sx", "className"];
|
|
13
15
|
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
17
|
|
|
@@ -21,6 +23,8 @@ var Badge = function Badge(_ref) {
|
|
|
21
23
|
var _ref$variant = _ref.variant,
|
|
22
24
|
variant = _ref$variant === void 0 ? 'blue' : _ref$variant,
|
|
23
25
|
sx = _ref.sx,
|
|
26
|
+
_ref$className = _ref.className,
|
|
27
|
+
className = _ref$className === void 0 ? null : _ref$className,
|
|
24
28
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
25
29
|
|
|
26
30
|
return (0, _jsxRuntime.jsx)(_.Text, _extends({
|
|
@@ -36,12 +40,14 @@ var Badge = function Badge(_ref) {
|
|
|
36
40
|
display: 'inline-block',
|
|
37
41
|
borderRadius: 1,
|
|
38
42
|
fontWeight: 'heading'
|
|
39
|
-
}, sx)
|
|
43
|
+
}, sx),
|
|
44
|
+
className: (0, _classnames["default"])('vip-badge-component', className)
|
|
40
45
|
}, props));
|
|
41
46
|
};
|
|
42
47
|
|
|
43
48
|
exports.Badge = Badge;
|
|
44
49
|
Badge.propTypes = {
|
|
45
50
|
variant: _propTypes["default"].string,
|
|
46
|
-
sx: _propTypes["default"].object
|
|
51
|
+
sx: _propTypes["default"].object,
|
|
52
|
+
className: _propTypes["default"].any
|
|
47
53
|
};
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.BlankState = void 0;
|
|
5
5
|
|
|
6
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
7
|
+
|
|
6
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
9
|
|
|
8
10
|
var _ = require("..");
|
|
@@ -27,12 +29,15 @@ var BlankState = function BlankState(_ref) {
|
|
|
27
29
|
image = _ref.image,
|
|
28
30
|
_ref$imageAlt = _ref.imageAlt,
|
|
29
31
|
imageAlt = _ref$imageAlt === void 0 ? 'Image representing the blank state' : _ref$imageAlt,
|
|
30
|
-
title = _ref.title
|
|
32
|
+
title = _ref.title,
|
|
33
|
+
_ref$className = _ref.className,
|
|
34
|
+
className = _ref$className === void 0 ? null : _ref$className;
|
|
31
35
|
return (0, _jsxRuntime.jsxs)(_.Box, {
|
|
32
36
|
sx: {
|
|
33
37
|
textAlign: 'center',
|
|
34
38
|
padding: 5
|
|
35
39
|
},
|
|
40
|
+
className: (0, _classnames["default"])('vip-blank-state-component', className),
|
|
36
41
|
children: [icon ? icon : (0, _jsxRuntime.jsx)("img", {
|
|
37
42
|
src: image,
|
|
38
43
|
sx: {
|
|
@@ -60,5 +65,6 @@ BlankState.propTypes = {
|
|
|
60
65
|
icon: _propTypes["default"].node,
|
|
61
66
|
image: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].string]),
|
|
62
67
|
imageAlt: _propTypes["default"].string,
|
|
63
|
-
title: _propTypes["default"].node
|
|
68
|
+
title: _propTypes["default"].node,
|
|
69
|
+
className: _propTypes["default"].any
|
|
64
70
|
};
|
package/build/system/Box/Box.js
CHANGED
|
@@ -3,18 +3,28 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.Box = void 0;
|
|
5
5
|
|
|
6
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
|
+
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
|
|
6
10
|
var _react = require("react");
|
|
7
11
|
|
|
8
12
|
var _themeUi = require("theme-ui");
|
|
9
13
|
|
|
10
14
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
11
15
|
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
|
|
12
18
|
function _extends() { _extends = Object.assign || 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); }
|
|
13
19
|
|
|
14
20
|
var Box = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
15
21
|
return (0, _jsxRuntime.jsx)(_themeUi.Box, _extends({
|
|
16
|
-
ref: ref
|
|
22
|
+
ref: ref,
|
|
23
|
+
className: (0, _classnames["default"])('vip-box-component', props.className)
|
|
17
24
|
}, props));
|
|
18
25
|
});
|
|
19
26
|
exports.Box = Box;
|
|
20
|
-
Box.displayName = 'Box';
|
|
27
|
+
Box.displayName = 'Box';
|
|
28
|
+
Box.propTypes = {
|
|
29
|
+
className: _propTypes["default"].any
|
|
30
|
+
};
|
|
@@ -7,6 +7,8 @@ var _themeUi = require("theme-ui");
|
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
|
|
10
12
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
11
13
|
|
|
12
14
|
var _excluded = ["sx"];
|
|
@@ -34,11 +36,13 @@ var Button = function Button(_ref) {
|
|
|
34
36
|
cursor: 'not-allowed',
|
|
35
37
|
pointerEvents: 'all'
|
|
36
38
|
}
|
|
37
|
-
}, sx)
|
|
39
|
+
}, sx),
|
|
40
|
+
className: (0, _classnames["default"])('vip-button-component', props.className)
|
|
38
41
|
}, props));
|
|
39
42
|
};
|
|
40
43
|
|
|
41
44
|
exports.Button = Button;
|
|
42
45
|
Button.propTypes = {
|
|
43
|
-
sx: _propTypes["default"].object
|
|
46
|
+
sx: _propTypes["default"].object,
|
|
47
|
+
className: _propTypes["default"].any
|
|
44
48
|
};
|
|
@@ -9,9 +9,11 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
|
|
10
10
|
var _ = require("..");
|
|
11
11
|
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
12
14
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
13
15
|
|
|
14
|
-
var _excluded = ["variant", "sx"];
|
|
16
|
+
var _excluded = ["variant", "sx", "className"];
|
|
15
17
|
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
19
|
|
|
@@ -24,6 +26,7 @@ var Card = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
24
26
|
variant = _ref$variant === void 0 ? 'primary' : _ref$variant,
|
|
25
27
|
_ref$sx = _ref.sx,
|
|
26
28
|
sx = _ref$sx === void 0 ? {} : _ref$sx,
|
|
29
|
+
className = _ref.className,
|
|
27
30
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
28
31
|
|
|
29
32
|
return (0, _jsxRuntime.jsx)(_.Box, _extends({
|
|
@@ -32,13 +35,15 @@ var Card = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
32
35
|
// pass variant prop to sx
|
|
33
36
|
variant: "cards." + variant,
|
|
34
37
|
overflow: 'hidden'
|
|
35
|
-
}, sx)
|
|
38
|
+
}, sx),
|
|
39
|
+
className: (0, _classnames["default"])('vip-card-component', className)
|
|
36
40
|
}, props));
|
|
37
41
|
});
|
|
38
42
|
|
|
39
43
|
exports.Card = Card;
|
|
40
44
|
Card.propTypes = {
|
|
41
45
|
variant: _propTypes["default"].string,
|
|
42
|
-
sx: _propTypes["default"].object
|
|
46
|
+
sx: _propTypes["default"].object,
|
|
47
|
+
className: _propTypes["default"].any
|
|
43
48
|
};
|
|
44
49
|
Card.displayName = 'Card';
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.Code = void 0;
|
|
5
5
|
|
|
6
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
7
|
+
|
|
6
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
9
|
|
|
8
10
|
var _react = require("react");
|
|
@@ -11,7 +13,7 @@ var _md = require("react-icons/md");
|
|
|
11
13
|
|
|
12
14
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
13
15
|
|
|
14
|
-
var _excluded = ["prompt", "showCopy", "onCopy"];
|
|
16
|
+
var _excluded = ["prompt", "showCopy", "onCopy", "className"];
|
|
15
17
|
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
19
|
|
|
@@ -26,6 +28,7 @@ var Code = function Code(_ref) {
|
|
|
26
28
|
showCopy = _ref$showCopy === void 0 ? false : _ref$showCopy,
|
|
27
29
|
_ref$onCopy = _ref.onCopy,
|
|
28
30
|
onCopy = _ref$onCopy === void 0 ? null : _ref$onCopy,
|
|
31
|
+
className = _ref.className,
|
|
29
32
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
30
33
|
|
|
31
34
|
var ref = (0, _react.useRef)();
|
|
@@ -46,7 +49,8 @@ var Code = function Code(_ref) {
|
|
|
46
49
|
marginRight: 2,
|
|
47
50
|
userSelect: 'none'
|
|
48
51
|
}
|
|
49
|
-
}
|
|
52
|
+
},
|
|
53
|
+
className: (0, _classnames["default"])('vip-code-component', className)
|
|
50
54
|
}, props));
|
|
51
55
|
|
|
52
56
|
if (!showCopy) {
|
|
@@ -100,5 +104,6 @@ exports.Code = Code;
|
|
|
100
104
|
Code.propTypes = {
|
|
101
105
|
prompt: _propTypes["default"].bool,
|
|
102
106
|
showCopy: _propTypes["default"].bool,
|
|
103
|
-
onCopy: _propTypes["default"].func
|
|
107
|
+
onCopy: _propTypes["default"].func,
|
|
108
|
+
className: _propTypes["default"].any
|
|
104
109
|
};
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.ConfirmationDialogContent = exports.ConfirmationDialog = void 0;
|
|
5
5
|
|
|
6
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
7
|
+
|
|
6
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
9
|
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -25,9 +27,12 @@ var ConfirmationDialogContent = function ConfirmationDialogContent(_ref) {
|
|
|
25
27
|
onClose = _ref.onClose,
|
|
26
28
|
_ref$label = _ref.label,
|
|
27
29
|
label = _ref$label === void 0 ? 'Confirm' : _ref$label,
|
|
28
|
-
onConfirm = _ref.onConfirm
|
|
30
|
+
onConfirm = _ref.onConfirm,
|
|
31
|
+
_ref$className = _ref.className,
|
|
32
|
+
className = _ref$className === void 0 ? null : _ref$className;
|
|
29
33
|
return (0, _jsxRuntime.jsxs)(_.Box, {
|
|
30
34
|
p: 4,
|
|
35
|
+
className: (0, _classnames["default"])('vip-confirmation-dialog-component', className),
|
|
31
36
|
children: [(0, _jsxRuntime.jsx)(_.Heading, {
|
|
32
37
|
variant: "h3",
|
|
33
38
|
sx: {
|
|
@@ -66,7 +71,8 @@ ConfirmationDialogContent.propTypes = {
|
|
|
66
71
|
body: _propTypes["default"].node,
|
|
67
72
|
label: _propTypes["default"].string,
|
|
68
73
|
onClose: _propTypes["default"].func,
|
|
69
|
-
onConfirm: _propTypes["default"].func
|
|
74
|
+
onConfirm: _propTypes["default"].func,
|
|
75
|
+
className: _propTypes["default"].any
|
|
70
76
|
};
|
|
71
77
|
|
|
72
78
|
var ConfirmationDialog = function ConfirmationDialog(_ref2) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.AsyncSearchSelect = void 0;
|
|
5
|
+
|
|
6
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
|
+
|
|
8
|
+
var _reactSelectAsyncPaginate = require("react-select-async-paginate");
|
|
9
|
+
|
|
10
|
+
var _SearchSelect = require("./SearchSelect");
|
|
11
|
+
|
|
12
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
13
|
+
|
|
14
|
+
var _excluded = ["options"];
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
|
|
18
|
+
function _extends() { _extends = Object.assign || 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); }
|
|
19
|
+
|
|
20
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
21
|
+
|
|
22
|
+
// Asynchronous search select to load paginated results asynchronously
|
|
23
|
+
var CustomAsyncPaginate = (0, _reactSelectAsyncPaginate.withAsyncPaginate)(_SearchSelect.SearchSelect);
|
|
24
|
+
|
|
25
|
+
var AsyncSearchSelect = function AsyncSearchSelect(_ref) {
|
|
26
|
+
var options = _ref.options,
|
|
27
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
28
|
+
|
|
29
|
+
return (0, _jsxRuntime.jsx)(CustomAsyncPaginate, _extends({
|
|
30
|
+
SelectComponent: _SearchSelect.SearchSelect,
|
|
31
|
+
loadOptions: options
|
|
32
|
+
}, props));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.AsyncSearchSelect = AsyncSearchSelect;
|
|
36
|
+
AsyncSearchSelect.propTypes = {
|
|
37
|
+
options: _propTypes["default"].array
|
|
38
|
+
};
|
|
@@ -14,8 +14,9 @@ var _ = require("..");
|
|
|
14
14
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
15
15
|
|
|
16
16
|
var _excluded = ["label", "isSelected"],
|
|
17
|
-
_excluded2 = ["
|
|
18
|
-
_excluded3 = ["
|
|
17
|
+
_excluded2 = ["innerProps", "isFocused", "isDisabled", "clearValue", "cx", "getStyles", "getValue", "hasValue", "isMulti", "isRtl", "options", "selectProps", "setValue", "selectOption", "theme"],
|
|
18
|
+
_excluded3 = ["ref"],
|
|
19
|
+
_excluded4 = ["innerProps"];
|
|
19
20
|
|
|
20
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
22
|
|
|
@@ -27,6 +28,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
27
28
|
|
|
28
29
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
29
30
|
|
|
31
|
+
// Option component
|
|
30
32
|
var Option = function Option(_ref) {
|
|
31
33
|
var label = _ref.label,
|
|
32
34
|
isSelected = _ref.isSelected,
|
|
@@ -65,9 +67,26 @@ exports.Option = Option;
|
|
|
65
67
|
Option.propTypes = {
|
|
66
68
|
label: _propTypes["default"].string,
|
|
67
69
|
isSelected: _propTypes["default"].bool
|
|
68
|
-
};
|
|
70
|
+
}; // DropdownIndicator component
|
|
71
|
+
|
|
72
|
+
var DropdownIndicator = function DropdownIndicator(_ref2) {
|
|
73
|
+
var innerProps = _ref2.innerProps,
|
|
74
|
+
isFocused = _ref2.isFocused,
|
|
75
|
+
isDisabled = _ref2.isDisabled,
|
|
76
|
+
clearValue = _ref2.clearValue,
|
|
77
|
+
cx = _ref2.cx,
|
|
78
|
+
getStyles = _ref2.getStyles,
|
|
79
|
+
getValue = _ref2.getValue,
|
|
80
|
+
hasValue = _ref2.hasValue,
|
|
81
|
+
isMulti = _ref2.isMulti,
|
|
82
|
+
isRtl = _ref2.isRtl,
|
|
83
|
+
options = _ref2.options,
|
|
84
|
+
selectProps = _ref2.selectProps,
|
|
85
|
+
setValue = _ref2.setValue,
|
|
86
|
+
selectOption = _ref2.selectOption,
|
|
87
|
+
theme = _ref2.theme,
|
|
88
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
69
89
|
|
|
70
|
-
var DropdownIndicator = function DropdownIndicator(props) {
|
|
71
90
|
return (0, _jsxRuntime.jsx)(_md.MdExpandMore, _extends({}, props, {
|
|
72
91
|
sx: {
|
|
73
92
|
color: 'text',
|
|
@@ -77,12 +96,29 @@ var DropdownIndicator = function DropdownIndicator(props) {
|
|
|
77
96
|
};
|
|
78
97
|
|
|
79
98
|
exports.DropdownIndicator = DropdownIndicator;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
DropdownIndicator.propTypes = {
|
|
100
|
+
innerProps: _propTypes["default"].object,
|
|
101
|
+
isFocused: _propTypes["default"].bool,
|
|
102
|
+
isDisabled: _propTypes["default"].bool,
|
|
103
|
+
clearValue: _propTypes["default"].func,
|
|
104
|
+
cx: _propTypes["default"].func,
|
|
105
|
+
getStyles: _propTypes["default"].func,
|
|
106
|
+
getValue: _propTypes["default"].func,
|
|
107
|
+
hasValue: _propTypes["default"].bool,
|
|
108
|
+
isMulti: _propTypes["default"].bool,
|
|
109
|
+
isRtl: _propTypes["default"].bool,
|
|
110
|
+
options: _propTypes["default"].array,
|
|
111
|
+
selectProps: _propTypes["default"].object,
|
|
112
|
+
setValue: _propTypes["default"].func,
|
|
113
|
+
selectOption: _propTypes["default"].func,
|
|
114
|
+
theme: _propTypes["default"].object
|
|
115
|
+
}; // ClearIndicator component
|
|
116
|
+
|
|
117
|
+
var ClearIndicator = function ClearIndicator(_ref3) {
|
|
118
|
+
var _ref3$innerProps = _ref3.innerProps,
|
|
119
|
+
ref = _ref3$innerProps.ref,
|
|
120
|
+
restInnerProps = _objectWithoutPropertiesLoose(_ref3$innerProps, _excluded3),
|
|
121
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded4);
|
|
86
122
|
|
|
87
123
|
return (0, _jsxRuntime.jsx)(_md.MdClose, _extends({
|
|
88
124
|
ref: ref
|
|
@@ -96,7 +132,7 @@ var ClearIndicator = function ClearIndicator(_ref2) {
|
|
|
96
132
|
|
|
97
133
|
ClearIndicator.propTypes = {
|
|
98
134
|
innerProps: _propTypes["default"].object
|
|
99
|
-
};
|
|
135
|
+
}; // Parent SearchSelect component
|
|
100
136
|
|
|
101
137
|
var SearchSelect = function SearchSelect(props) {
|
|
102
138
|
return (0, _jsxRuntime.jsx)(_reactSelect["default"], _extends({}, props, {
|
|
@@ -11,9 +11,11 @@ var _SearchSelect = require("./SearchSelect");
|
|
|
11
11
|
|
|
12
12
|
var _InlineSelect = require("./InlineSelect");
|
|
13
13
|
|
|
14
|
+
var _AsyncSearchSelect = require("./AsyncSearchSelect");
|
|
15
|
+
|
|
14
16
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
15
17
|
|
|
16
|
-
var _excluded = ["isMulti", "isInline", "options", "label", "isSearch", "usePortal"];
|
|
18
|
+
var _excluded = ["isMulti", "isInline", "isAsync", "options", "label", "isSearch", "usePortal"];
|
|
17
19
|
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
21
|
|
|
@@ -25,12 +27,15 @@ var Select = function Select(_ref) {
|
|
|
25
27
|
var _ref$isMulti = _ref.isMulti,
|
|
26
28
|
isMulti = _ref$isMulti === void 0 ? false : _ref$isMulti,
|
|
27
29
|
isInline = _ref.isInline,
|
|
30
|
+
isAsync = _ref.isAsync,
|
|
28
31
|
options = _ref.options,
|
|
29
32
|
label = _ref.label,
|
|
30
33
|
isSearch = _ref.isSearch,
|
|
31
34
|
usePortal = _ref.usePortal,
|
|
32
35
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
33
36
|
|
|
37
|
+
var Component;
|
|
38
|
+
|
|
34
39
|
var selectRef = _react["default"].useRef();
|
|
35
40
|
|
|
36
41
|
var portalProps = {};
|
|
@@ -48,9 +53,23 @@ var Select = function Select(_ref) {
|
|
|
48
53
|
};
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
|
|
56
|
+
switch (true) {
|
|
57
|
+
case isInline:
|
|
58
|
+
Component = _InlineSelect.InlineSelect;
|
|
59
|
+
break;
|
|
60
|
+
|
|
61
|
+
case isAsync:
|
|
62
|
+
Component = _AsyncSearchSelect.AsyncSearchSelect;
|
|
63
|
+
break;
|
|
64
|
+
|
|
65
|
+
default:
|
|
66
|
+
Component = _SearchSelect.SearchSelect;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
|
|
52
70
|
return (0, _jsxRuntime.jsx)("div", {
|
|
53
71
|
ref: selectRef,
|
|
72
|
+
className: "vip-select-component",
|
|
54
73
|
children: (0, _jsxRuntime.jsx)(Component, _extends({
|
|
55
74
|
isMulti: isMulti,
|
|
56
75
|
label: label,
|
|
@@ -63,6 +82,7 @@ exports.Select = Select;
|
|
|
63
82
|
Select.propTypes = {
|
|
64
83
|
isInline: _propTypes["default"].bool,
|
|
65
84
|
isMulti: _propTypes["default"].bool,
|
|
85
|
+
isAsync: _propTypes["default"].bool,
|
|
66
86
|
isSearch: _propTypes["default"].bool,
|
|
67
87
|
label: _propTypes["default"].string,
|
|
68
88
|
options: _propTypes["default"].array,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
4
|
+
|
|
5
|
+
var _jestAxe = require("jest-axe");
|
|
6
|
+
|
|
7
|
+
var _Select = require("./Select");
|
|
8
|
+
|
|
9
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
10
|
+
|
|
11
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
|
+
|
|
13
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
14
|
+
|
|
15
|
+
describe('<Select />', function () {
|
|
16
|
+
it('renders the Select component with the specified placeholder', function () {
|
|
17
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_Select.Select, {
|
|
18
|
+
inputId: 'search-select',
|
|
19
|
+
placeholder: 'Search...'
|
|
20
|
+
})); // Can't use `getByPlaceholderText` here since it's not actually being rendered as a placeholder element
|
|
21
|
+
|
|
22
|
+
var placeholder = _react.screen.getByText('Search...');
|
|
23
|
+
|
|
24
|
+
expect(placeholder).toBeInTheDocument();
|
|
25
|
+
});
|
|
26
|
+
it('renders the Select component with accessibility props', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
27
|
+
var _render, container;
|
|
28
|
+
|
|
29
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
30
|
+
while (1) {
|
|
31
|
+
switch (_context.prev = _context.next) {
|
|
32
|
+
case 0:
|
|
33
|
+
_render = (0, _react.render)((0, _jsxRuntime.jsx)(_Select.Select, {
|
|
34
|
+
inputId: 'search-select',
|
|
35
|
+
"aria-label": 'Search or select from the dropdown list'
|
|
36
|
+
})), container = _render.container;
|
|
37
|
+
_context.t0 = expect;
|
|
38
|
+
_context.next = 4;
|
|
39
|
+
return (0, _jestAxe.axe)(container);
|
|
40
|
+
|
|
41
|
+
case 4:
|
|
42
|
+
_context.t1 = _context.sent;
|
|
43
|
+
(0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
44
|
+
|
|
45
|
+
case 6:
|
|
46
|
+
case "end":
|
|
47
|
+
return _context.stop();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, _callee);
|
|
51
|
+
})));
|
|
52
|
+
});
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.Toggle = void 0;
|
|
5
5
|
|
|
6
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
7
|
+
|
|
6
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
9
|
|
|
8
10
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
9
11
|
|
|
10
|
-
var _excluded = ["name"];
|
|
12
|
+
var _excluded = ["name", "className"];
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
15
|
|
|
@@ -18,9 +20,12 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
18
20
|
var Toggle = function Toggle(_ref) {
|
|
19
21
|
var _ref$name = _ref.name,
|
|
20
22
|
name = _ref$name === void 0 ? 'toggle' : _ref$name,
|
|
23
|
+
_ref$className = _ref.className,
|
|
24
|
+
className = _ref$className === void 0 ? null : _ref$className,
|
|
21
25
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
22
26
|
|
|
23
27
|
return (0, _jsxRuntime.jsxs)(CheckBoxWrapper, {
|
|
28
|
+
className: (0, _classnames["default"])('vip-checkbox-component', className),
|
|
24
29
|
children: [(0, _jsxRuntime.jsx)(CheckBox, _extends({
|
|
25
30
|
name: name,
|
|
26
31
|
id: name,
|
|
@@ -33,7 +38,8 @@ var Toggle = function Toggle(_ref) {
|
|
|
33
38
|
|
|
34
39
|
exports.Toggle = Toggle;
|
|
35
40
|
Toggle.propTypes = {
|
|
36
|
-
name: _propTypes["default"].string
|
|
41
|
+
name: _propTypes["default"].string,
|
|
42
|
+
className: _propTypes["default"].any
|
|
37
43
|
};
|
|
38
44
|
|
|
39
45
|
var CheckBoxWrapper = function CheckBoxWrapper(props) {
|
|
@@ -7,9 +7,11 @@ var _themeUi = require("theme-ui");
|
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
|
|
10
12
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
11
13
|
|
|
12
|
-
var _excluded = ["variant", "sx"];
|
|
14
|
+
var _excluded = ["variant", "sx", "className"];
|
|
13
15
|
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
17
|
|
|
@@ -21,6 +23,8 @@ var Heading = function Heading(_ref) {
|
|
|
21
23
|
var _ref$variant = _ref.variant,
|
|
22
24
|
variant = _ref$variant === void 0 ? 'h3' : _ref$variant,
|
|
23
25
|
sx = _ref.sx,
|
|
26
|
+
_ref$className = _ref.className,
|
|
27
|
+
className = _ref$className === void 0 ? null : _ref$className,
|
|
24
28
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
25
29
|
|
|
26
30
|
return (0, _jsxRuntime.jsx)(_themeUi.Heading, _extends({
|
|
@@ -29,12 +33,14 @@ var Heading = function Heading(_ref) {
|
|
|
29
33
|
color: 'heading',
|
|
30
34
|
// pass variant prop to sx
|
|
31
35
|
variant: "text." + variant
|
|
32
|
-
}, sx)
|
|
36
|
+
}, sx),
|
|
37
|
+
className: (0, _classnames["default"])('vip-heading-component', className)
|
|
33
38
|
}, props));
|
|
34
39
|
};
|
|
35
40
|
|
|
36
41
|
exports.Heading = Heading;
|
|
37
42
|
Heading.propTypes = {
|
|
38
43
|
variant: _propTypes["default"].string,
|
|
39
|
-
sx: _propTypes["default"].object
|
|
44
|
+
sx: _propTypes["default"].object,
|
|
45
|
+
className: _propTypes["default"].any
|
|
40
46
|
};
|