@automattic/vip-design-system 0.11.0 → 0.13.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/.storybook/decorators/withBoundingBox.jsx +11 -4
- package/.storybook/decorators/withThemeProvider.jsx +4 -6
- package/.storybook/main.js +1 -0
- package/.storybook/preview.js +1 -0
- package/build/system/Form/Toggle.js +53 -72
- package/build/system/Form/Toggle.stories.js +103 -0
- package/build/system/Form/Toggle.test.js +55 -0
- package/build/system/NewDialog/DialogClose.js +75 -0
- package/build/system/NewDialog/DialogClose.test.js +67 -0
- package/build/system/NewDialog/DialogContent.js +26 -0
- package/build/system/NewDialog/DialogDescription.js +54 -0
- package/build/system/NewDialog/DialogDescription.test.js +95 -0
- package/build/system/NewDialog/DialogOverlay.js +48 -0
- package/build/system/NewDialog/DialogOverlay.test.js +63 -0
- package/build/system/NewDialog/DialogTitle.js +50 -0
- package/build/system/NewDialog/DialogTitle.test.js +95 -0
- package/build/system/NewDialog/NewDialog.js +117 -0
- package/build/system/NewDialog/NewDialog.stories.js +159 -0
- package/build/system/NewDialog/index.js +7 -0
- package/build/system/Notice/Notice.js +4 -4
- package/build/system/Table/Table.stories.js +46 -3
- package/build/system/Table/TableCell.js +57 -0
- package/build/system/Table/TableRow.js +12 -57
- package/build/system/Table/index.js +5 -1
- package/build/system/Time/index.js +1 -1
- package/build/system/index.js +5 -0
- package/package.json +8 -4
- package/src/system/Form/Toggle.js +54 -62
- package/src/system/Form/Toggle.stories.jsx +84 -0
- package/src/system/Form/Toggle.test.js +23 -0
- package/src/system/NewDialog/DialogClose.js +45 -0
- package/src/system/NewDialog/DialogClose.test.js +32 -0
- package/src/system/NewDialog/DialogContent.js +17 -0
- package/src/system/NewDialog/DialogDescription.js +36 -0
- package/src/system/NewDialog/DialogDescription.test.js +47 -0
- package/src/system/NewDialog/DialogOverlay.js +31 -0
- package/src/system/NewDialog/DialogOverlay.test.js +27 -0
- package/src/system/NewDialog/DialogTitle.js +27 -0
- package/src/system/NewDialog/DialogTitle.test.js +47 -0
- package/src/system/NewDialog/NewDialog.js +87 -0
- package/src/system/NewDialog/NewDialog.stories.jsx +96 -0
- package/src/system/NewDialog/index.js +7 -0
- package/src/system/Notice/Notice.js +3 -3
- package/src/system/Table/Table.stories.jsx +29 -1
- package/src/system/Table/TableCell.js +48 -0
- package/src/system/Table/TableRow.js +10 -47
- package/src/system/Table/index.js +2 -1
- package/src/system/Time/index.js +1 -1
- package/src/system/index.js +5 -1
- package/build/system/Form/MultiSelect.js +0 -58
- package/build/system/UsageChart/UsageChart.js +0 -62
- package/build/system/UsageChart/UsageChart.stories.js +0 -20
- package/build/system/UsageChart/index.js +0 -7
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
+
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
|
|
11
|
+
var _reactDialog = require("@radix-ui/react-dialog");
|
|
12
|
+
|
|
13
|
+
var _react = require("@testing-library/react");
|
|
14
|
+
|
|
15
|
+
var _jestAxe = require("jest-axe");
|
|
16
|
+
|
|
17
|
+
var _DialogDescription = require("./DialogDescription");
|
|
18
|
+
|
|
19
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* External dependencies
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Internal dependencies
|
|
27
|
+
*/
|
|
28
|
+
// If you render any Dialog child without the `<Dialog />` parent, it will throw an error.
|
|
29
|
+
var Wrapper = function Wrapper(props) {
|
|
30
|
+
return (0, _jsxRuntime.jsx)(_reactDialog.Dialog, (0, _extends2["default"])({
|
|
31
|
+
open: true
|
|
32
|
+
}, props));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var defaultProps = {
|
|
36
|
+
description: 'My Custom Text'
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var getParagraph = function getParagraph() {
|
|
40
|
+
return _react.screen.getByText(defaultProps.description);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
describe('<DialogDescription />', function () {
|
|
44
|
+
it('renders the DialogDescription component', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
45
|
+
var _render, container;
|
|
46
|
+
|
|
47
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
48
|
+
while (1) {
|
|
49
|
+
switch (_context.prev = _context.next) {
|
|
50
|
+
case 0:
|
|
51
|
+
_render = (0, _react.render)((0, _jsxRuntime.jsx)(Wrapper, {
|
|
52
|
+
children: (0, _jsxRuntime.jsx)(_DialogDescription.DialogDescription, (0, _extends2["default"])({}, defaultProps))
|
|
53
|
+
})), container = _render.container;
|
|
54
|
+
expect(getParagraph()).toHaveTextContent(defaultProps.description); // Check for accessibility issues
|
|
55
|
+
|
|
56
|
+
_context.t0 = expect;
|
|
57
|
+
_context.next = 5;
|
|
58
|
+
return (0, _jestAxe.axe)(container);
|
|
59
|
+
|
|
60
|
+
case 5:
|
|
61
|
+
_context.t1 = _context.sent;
|
|
62
|
+
_context.next = 8;
|
|
63
|
+
return (0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
64
|
+
|
|
65
|
+
case 8:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, _callee);
|
|
71
|
+
})));
|
|
72
|
+
it('renders text visually hidden for a11y purposes', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
73
|
+
var _render2, container;
|
|
74
|
+
|
|
75
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
76
|
+
while (1) {
|
|
77
|
+
switch (_context2.prev = _context2.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
_render2 = (0, _react.render)((0, _jsxRuntime.jsx)(Wrapper, {
|
|
80
|
+
children: (0, _jsxRuntime.jsx)(_DialogDescription.DialogDescription, (0, _extends2["default"])({}, defaultProps, {
|
|
81
|
+
hidden: true
|
|
82
|
+
}))
|
|
83
|
+
})), container = _render2.container; // Small check to make sure we are hiding with the css class
|
|
84
|
+
|
|
85
|
+
expect(container.innerHTML).toContain('screen-reader-text');
|
|
86
|
+
expect(getParagraph()).toHaveTextContent(defaultProps.description);
|
|
87
|
+
|
|
88
|
+
case 3:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context2.stop();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, _callee2);
|
|
94
|
+
})));
|
|
95
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.DialogOverlay = void 0;
|
|
7
|
+
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var Dialog = _interopRequireWildcard(require("@radix-ui/react-dialog"));
|
|
13
|
+
|
|
14
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
/** @jsxImportSource theme-ui */
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* External dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Internal dependencies
|
|
28
|
+
*/
|
|
29
|
+
var DialogOverlay = /*#__PURE__*/_react["default"].forwardRef(function (props, forwardedRef) {
|
|
30
|
+
return (0, _jsxRuntime.jsx)(Dialog.Overlay, (0, _extends2["default"])({
|
|
31
|
+
sx: {
|
|
32
|
+
position: 'fixed',
|
|
33
|
+
top: 0,
|
|
34
|
+
left: 0,
|
|
35
|
+
right: 0,
|
|
36
|
+
bottom: 0,
|
|
37
|
+
inset: 0,
|
|
38
|
+
opacity: 0.7,
|
|
39
|
+
background: // eslint-disable-next-line max-len
|
|
40
|
+
'linear-gradient(198.09deg,#E5F0F6 2.01%, rgba(235, 238, 242, 0) 43.18%,rgba(249, 234, 232, 0) 47.86%, #FFE9D1 94.31%), linear-gradient(98.65deg, #FFE8E6 0.58%, rgba(255, 233, 214, 0) 52.45%, rgba(255, 233, 219, 0) 53.76%,#FFE9D1 105.86%), #F5F2F1'
|
|
41
|
+
}
|
|
42
|
+
}, props, {
|
|
43
|
+
ref: forwardedRef
|
|
44
|
+
}));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
exports.DialogOverlay = DialogOverlay;
|
|
48
|
+
DialogOverlay.displayName = 'DialogOverlay';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
+
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
|
|
11
|
+
var _reactDialog = require("@radix-ui/react-dialog");
|
|
12
|
+
|
|
13
|
+
var _react = require("@testing-library/react");
|
|
14
|
+
|
|
15
|
+
var _jestAxe = require("jest-axe");
|
|
16
|
+
|
|
17
|
+
var _DialogOverlay = require("./DialogOverlay");
|
|
18
|
+
|
|
19
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* External dependencies
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Internal dependencies
|
|
27
|
+
*/
|
|
28
|
+
// If you render any Dialog child without the `<Dialog />` parent, it will throw an error.
|
|
29
|
+
var Wrapper = function Wrapper(props) {
|
|
30
|
+
return (0, _jsxRuntime.jsx)(_reactDialog.Dialog, (0, _extends2["default"])({
|
|
31
|
+
open: true
|
|
32
|
+
}, props));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
describe('<DialogOverlay />', function () {
|
|
36
|
+
it('renders the DialogOverlay component', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
37
|
+
var _render, container;
|
|
38
|
+
|
|
39
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
40
|
+
while (1) {
|
|
41
|
+
switch (_context.prev = _context.next) {
|
|
42
|
+
case 0:
|
|
43
|
+
_render = (0, _react.render)((0, _jsxRuntime.jsx)(Wrapper, {
|
|
44
|
+
children: (0, _jsxRuntime.jsx)(_DialogOverlay.DialogOverlay, {})
|
|
45
|
+
})), container = _render.container; // Check for accessibility issues
|
|
46
|
+
|
|
47
|
+
_context.t0 = expect;
|
|
48
|
+
_context.next = 4;
|
|
49
|
+
return (0, _jestAxe.axe)(container);
|
|
50
|
+
|
|
51
|
+
case 4:
|
|
52
|
+
_context.t1 = _context.sent;
|
|
53
|
+
_context.next = 7;
|
|
54
|
+
return (0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
55
|
+
|
|
56
|
+
case 7:
|
|
57
|
+
case "end":
|
|
58
|
+
return _context.stop();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, _callee);
|
|
62
|
+
})));
|
|
63
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.DialogTitle = void 0;
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
var DialogPrimitive = _interopRequireWildcard(require("@radix-ui/react-dialog"));
|
|
11
|
+
|
|
12
|
+
var _ScreenReaderText = _interopRequireDefault(require("../ScreenReaderText/ScreenReaderText"));
|
|
13
|
+
|
|
14
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
/** @jsxImportSource theme-ui */
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* External dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Internal dependencies
|
|
28
|
+
*/
|
|
29
|
+
var DialogTitle = function DialogTitle(_ref) {
|
|
30
|
+
var title = _ref.title,
|
|
31
|
+
_ref$hidden = _ref.hidden,
|
|
32
|
+
hidden = _ref$hidden === void 0 ? false : _ref$hidden;
|
|
33
|
+
var titleNode = title;
|
|
34
|
+
|
|
35
|
+
if (hidden) {
|
|
36
|
+
titleNode = (0, _jsxRuntime.jsx)(_ScreenReaderText["default"], {
|
|
37
|
+
children: titleNode
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (0, _jsxRuntime.jsx)(DialogPrimitive.Title, {
|
|
42
|
+
children: titleNode
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.DialogTitle = DialogTitle;
|
|
47
|
+
DialogTitle.propTypes = {
|
|
48
|
+
title: _propTypes["default"].string,
|
|
49
|
+
hidden: _propTypes["default"].bool
|
|
50
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
+
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
|
|
11
|
+
var _reactDialog = require("@radix-ui/react-dialog");
|
|
12
|
+
|
|
13
|
+
var _react = require("@testing-library/react");
|
|
14
|
+
|
|
15
|
+
var _jestAxe = require("jest-axe");
|
|
16
|
+
|
|
17
|
+
var _DialogTitle = require("./DialogTitle");
|
|
18
|
+
|
|
19
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* External dependencies
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Internal dependencies
|
|
27
|
+
*/
|
|
28
|
+
// If you render any Dialog child without the `<Dialog />` parent, it will throw an error.
|
|
29
|
+
var Wrapper = function Wrapper(props) {
|
|
30
|
+
return (0, _jsxRuntime.jsx)(_reactDialog.Dialog, (0, _extends2["default"])({
|
|
31
|
+
open: true
|
|
32
|
+
}, props));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var defaultProps = {
|
|
36
|
+
title: 'This is a DialogTitle'
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var getTitle = function getTitle() {
|
|
40
|
+
return _react.screen.getByRole('heading');
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
describe('<DialogTitle />', function () {
|
|
44
|
+
it('renders the DialogTitle component', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
45
|
+
var _render, container;
|
|
46
|
+
|
|
47
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
48
|
+
while (1) {
|
|
49
|
+
switch (_context.prev = _context.next) {
|
|
50
|
+
case 0:
|
|
51
|
+
_render = (0, _react.render)((0, _jsxRuntime.jsx)(Wrapper, {
|
|
52
|
+
children: (0, _jsxRuntime.jsx)(_DialogTitle.DialogTitle, (0, _extends2["default"])({}, defaultProps))
|
|
53
|
+
})), container = _render.container;
|
|
54
|
+
expect(getTitle()).toHaveTextContent(defaultProps.title); // Check for accessibility issues
|
|
55
|
+
|
|
56
|
+
_context.t0 = expect;
|
|
57
|
+
_context.next = 5;
|
|
58
|
+
return (0, _jestAxe.axe)(container);
|
|
59
|
+
|
|
60
|
+
case 5:
|
|
61
|
+
_context.t1 = _context.sent;
|
|
62
|
+
_context.next = 8;
|
|
63
|
+
return (0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
64
|
+
|
|
65
|
+
case 8:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, _callee);
|
|
71
|
+
})));
|
|
72
|
+
it('renders text visually hidden for a11y purposes', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
73
|
+
var _render2, container;
|
|
74
|
+
|
|
75
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
76
|
+
while (1) {
|
|
77
|
+
switch (_context2.prev = _context2.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
_render2 = (0, _react.render)((0, _jsxRuntime.jsx)(Wrapper, {
|
|
80
|
+
children: (0, _jsxRuntime.jsx)(_DialogTitle.DialogTitle, (0, _extends2["default"])({}, defaultProps, {
|
|
81
|
+
hidden: true
|
|
82
|
+
}))
|
|
83
|
+
})), container = _render2.container; // Small check to make sure we are hiding with the css class
|
|
84
|
+
|
|
85
|
+
expect(container.innerHTML).toContain('screen-reader-text');
|
|
86
|
+
expect(getTitle()).toHaveTextContent(defaultProps.title);
|
|
87
|
+
|
|
88
|
+
case 3:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context2.stop();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, _callee2);
|
|
94
|
+
})));
|
|
95
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.NewDialog = void 0;
|
|
7
|
+
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var DialogPrimitive = _interopRequireWildcard(require("@radix-ui/react-dialog"));
|
|
13
|
+
|
|
14
|
+
var _DialogOverlay = require("./DialogOverlay");
|
|
15
|
+
|
|
16
|
+
var _DialogClose = require("./DialogClose");
|
|
17
|
+
|
|
18
|
+
var _DialogTitle = require("./DialogTitle");
|
|
19
|
+
|
|
20
|
+
var _DialogDescription = require("./DialogDescription");
|
|
21
|
+
|
|
22
|
+
var _DialogContent = require("./DialogContent");
|
|
23
|
+
|
|
24
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
25
|
+
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
/** @jsxImportSource theme-ui */
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* External dependencies
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Internal dependencies
|
|
38
|
+
*/
|
|
39
|
+
var NewDialog = function NewDialog(_ref) {
|
|
40
|
+
var _ref$trigger = _ref.trigger,
|
|
41
|
+
trigger = _ref$trigger === void 0 ? null : _ref$trigger,
|
|
42
|
+
description = _ref.description,
|
|
43
|
+
title = _ref.title,
|
|
44
|
+
_ref$content = _ref.content,
|
|
45
|
+
content = _ref$content === void 0 ? null : _ref$content,
|
|
46
|
+
_ref$showHeading = _ref.showHeading,
|
|
47
|
+
showHeading = _ref$showHeading === void 0 ? true : _ref$showHeading,
|
|
48
|
+
_ref$disabled = _ref.disabled,
|
|
49
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
50
|
+
extraStyles = _ref.style,
|
|
51
|
+
_ref$defaultOpen = _ref.defaultOpen,
|
|
52
|
+
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
53
|
+
_ref$allowPinchZoom = _ref.allowPinchZoom,
|
|
54
|
+
allowPinchZoom = _ref$allowPinchZoom === void 0 ? false : _ref$allowPinchZoom,
|
|
55
|
+
_ref$onOpenAutoFocus = _ref.onOpenAutoFocus,
|
|
56
|
+
onOpenAutoFocus = _ref$onOpenAutoFocus === void 0 ? null : _ref$onOpenAutoFocus,
|
|
57
|
+
_ref$onCloseAutoFocus = _ref.onCloseAutoFocus,
|
|
58
|
+
onCloseAutoFocus = _ref$onCloseAutoFocus === void 0 ? null : _ref$onCloseAutoFocus,
|
|
59
|
+
_ref$onEscapeKeyDown = _ref.onEscapeKeyDown,
|
|
60
|
+
onEscapeKeyDown = _ref$onEscapeKeyDown === void 0 ? null : _ref$onEscapeKeyDown,
|
|
61
|
+
_ref$onPointerDownOut = _ref.onPointerDownOutside,
|
|
62
|
+
onPointerDownOutside = _ref$onPointerDownOut === void 0 ? null : _ref$onPointerDownOut,
|
|
63
|
+
_ref$onInteractOutsid = _ref.onInteractOutside,
|
|
64
|
+
onInteractOutside = _ref$onInteractOutsid === void 0 ? null : _ref$onInteractOutsid;
|
|
65
|
+
|
|
66
|
+
if (disabled) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (0, _jsxRuntime.jsxs)(DialogPrimitive.Root, {
|
|
71
|
+
defaultOpen: defaultOpen,
|
|
72
|
+
allowPinchZoom: allowPinchZoom,
|
|
73
|
+
children: [trigger && (0, _jsxRuntime.jsx)(DialogPrimitive.Trigger, {
|
|
74
|
+
asChild: true,
|
|
75
|
+
children: trigger
|
|
76
|
+
}), (0, _jsxRuntime.jsxs)(DialogPrimitive.Portal, {
|
|
77
|
+
children: [(0, _jsxRuntime.jsx)(_DialogOverlay.DialogOverlay, {}), (0, _jsxRuntime.jsxs)(DialogPrimitive.Content, {
|
|
78
|
+
className: "vip-dialog-component",
|
|
79
|
+
sx: (0, _extends2["default"])({}, _DialogContent.contentStyles, extraStyles),
|
|
80
|
+
onOpenAutoFocus: onOpenAutoFocus,
|
|
81
|
+
onCloseAutoFocus: onCloseAutoFocus,
|
|
82
|
+
onEscapeKeyDown: onEscapeKeyDown,
|
|
83
|
+
onPointerDownOutside: onPointerDownOutside,
|
|
84
|
+
onInteractOutside: onInteractOutside,
|
|
85
|
+
children: [(0, _jsxRuntime.jsx)(_DialogClose.DialogClose, {}), (0, _jsxRuntime.jsx)(_DialogTitle.DialogTitle, {
|
|
86
|
+
title: title,
|
|
87
|
+
hidden: !showHeading
|
|
88
|
+
}), (0, _jsxRuntime.jsx)(_DialogDescription.DialogDescription, {
|
|
89
|
+
description: description,
|
|
90
|
+
hidden: !showHeading
|
|
91
|
+
}), content]
|
|
92
|
+
})]
|
|
93
|
+
})]
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
exports.NewDialog = NewDialog;
|
|
98
|
+
NewDialog.propTypes = {
|
|
99
|
+
trigger: _propTypes["default"].node.isRequired,
|
|
100
|
+
title: _propTypes["default"].string.isRequired,
|
|
101
|
+
description: _propTypes["default"].string.isRequired,
|
|
102
|
+
content: _propTypes["default"].node,
|
|
103
|
+
showHeading: _propTypes["default"].bool,
|
|
104
|
+
disabled: _propTypes["default"].bool,
|
|
105
|
+
style: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].func]),
|
|
106
|
+
// Radix DialogPrimitive.Root properties
|
|
107
|
+
// https://www.radix-ui.com/docs/primitives/components/dialog#root
|
|
108
|
+
defaultOpen: _propTypes["default"].bool,
|
|
109
|
+
allowPinchZoom: _propTypes["default"].bool,
|
|
110
|
+
// Radix DialogPrimitive.Content properties
|
|
111
|
+
// https://www.radix-ui.com/docs/primitives/components/dialog#content
|
|
112
|
+
onOpenAutoFocus: _propTypes["default"].func,
|
|
113
|
+
onCloseAutoFocus: _propTypes["default"].func,
|
|
114
|
+
onEscapeKeyDown: _propTypes["default"].func,
|
|
115
|
+
onPointerDownOutside: _propTypes["default"].func,
|
|
116
|
+
onInteractOutside: _propTypes["default"].func
|
|
117
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports["default"] = exports.HiddenHeadings = exports.Default = exports.CustomStyling = exports.AutoOpen = void 0;
|
|
7
|
+
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _system = require("../../system");
|
|
11
|
+
|
|
12
|
+
var _ScreenReaderText = _interopRequireDefault(require("../ScreenReaderText/ScreenReaderText"));
|
|
13
|
+
|
|
14
|
+
var _NewDialog = require("./NewDialog");
|
|
15
|
+
|
|
16
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
17
|
+
|
|
18
|
+
/** @jsxImportSource theme-ui */
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
var _default = {
|
|
25
|
+
title: 'NewDialog',
|
|
26
|
+
component: _NewDialog.NewDialog
|
|
27
|
+
};
|
|
28
|
+
exports["default"] = _default;
|
|
29
|
+
var defaultProps = {
|
|
30
|
+
title: 'User settings',
|
|
31
|
+
description: 'Use this form to manage your settings'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
var Default = function Default() {
|
|
35
|
+
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
36
|
+
children: [(0, _jsxRuntime.jsx)(_system.Text, {
|
|
37
|
+
sx: {
|
|
38
|
+
fontSize: 3,
|
|
39
|
+
mb: 3
|
|
40
|
+
},
|
|
41
|
+
children: "Regular Dialog where the title and description are built-in and the content is provided by the user."
|
|
42
|
+
}), (0, _jsxRuntime.jsx)(_NewDialog.NewDialog, (0, _extends2["default"])({}, defaultProps, {
|
|
43
|
+
trigger: (0, _jsxRuntime.jsx)(_system.Button, {
|
|
44
|
+
children: "Trigger Dialog"
|
|
45
|
+
})
|
|
46
|
+
}))]
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.Default = Default;
|
|
51
|
+
|
|
52
|
+
var AutoOpen = function AutoOpen() {
|
|
53
|
+
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
54
|
+
children: [(0, _jsxRuntime.jsx)(_system.Text, {
|
|
55
|
+
sx: {
|
|
56
|
+
fontSize: 3,
|
|
57
|
+
mb: 3
|
|
58
|
+
},
|
|
59
|
+
children: "Auto Opens when rendered. Press escape to close it."
|
|
60
|
+
}), (0, _jsxRuntime.jsx)(_NewDialog.NewDialog, (0, _extends2["default"])({}, defaultProps, {
|
|
61
|
+
defaultOpen: true,
|
|
62
|
+
trigger: (0, _jsxRuntime.jsx)(_ScreenReaderText["default"], {
|
|
63
|
+
children: "hey"
|
|
64
|
+
})
|
|
65
|
+
}))]
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
exports.AutoOpen = AutoOpen;
|
|
70
|
+
|
|
71
|
+
var HiddenHeadings = function HiddenHeadings() {
|
|
72
|
+
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
73
|
+
children: [(0, _jsxRuntime.jsx)(_system.Text, {
|
|
74
|
+
sx: {
|
|
75
|
+
fontSize: 3,
|
|
76
|
+
mb: 3
|
|
77
|
+
},
|
|
78
|
+
children: "Title and description are hidden, but still announced using a screen reader. Activate VoiceOver or any similar screen reader to listen to: Custom dialog title, Description of the dialog content."
|
|
79
|
+
}), (0, _jsxRuntime.jsx)(_NewDialog.NewDialog, (0, _extends2["default"])({}, defaultProps, {
|
|
80
|
+
trigger: (0, _jsxRuntime.jsx)(_system.Button, {
|
|
81
|
+
children: "Trigger Dialog"
|
|
82
|
+
}),
|
|
83
|
+
title: "Custom dialog title",
|
|
84
|
+
showHeading: false,
|
|
85
|
+
content: (0, _jsxRuntime.jsxs)("div", {
|
|
86
|
+
children: [(0, _jsxRuntime.jsx)("h3", {
|
|
87
|
+
children: "My Custom Content"
|
|
88
|
+
}), (0, _jsxRuntime.jsxs)("form", {
|
|
89
|
+
children: [(0, _jsxRuntime.jsx)(_system.Label, {
|
|
90
|
+
htmlFor: "username",
|
|
91
|
+
children: "User name"
|
|
92
|
+
}), (0, _jsxRuntime.jsx)(_system.Input, {
|
|
93
|
+
type: "text",
|
|
94
|
+
name: "username",
|
|
95
|
+
id: "username"
|
|
96
|
+
}), (0, _jsxRuntime.jsx)(_system.Button, {
|
|
97
|
+
type: "submit",
|
|
98
|
+
children: "Submit"
|
|
99
|
+
})]
|
|
100
|
+
})]
|
|
101
|
+
})
|
|
102
|
+
}))]
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
exports.HiddenHeadings = HiddenHeadings;
|
|
107
|
+
|
|
108
|
+
var CustomStyling = function CustomStyling() {
|
|
109
|
+
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
110
|
+
children: [(0, _jsxRuntime.jsx)(_system.Text, {
|
|
111
|
+
sx: {
|
|
112
|
+
fontSize: 3,
|
|
113
|
+
mb: 3
|
|
114
|
+
},
|
|
115
|
+
children: "Custom Styling on Dialog Content"
|
|
116
|
+
}), (0, _jsxRuntime.jsx)(_NewDialog.NewDialog, (0, _extends2["default"])({}, defaultProps, {
|
|
117
|
+
defaultOpen: true,
|
|
118
|
+
trigger: (0, _jsxRuntime.jsx)(_system.Button, {
|
|
119
|
+
children: "Trigger Dialog"
|
|
120
|
+
}),
|
|
121
|
+
title: "Custom dialog title",
|
|
122
|
+
style: {
|
|
123
|
+
background: function background(theme) {
|
|
124
|
+
return "" + theme.colors.primary;
|
|
125
|
+
},
|
|
126
|
+
padding: 5,
|
|
127
|
+
borderRadius: 20,
|
|
128
|
+
h2: {
|
|
129
|
+
fontSize: 4,
|
|
130
|
+
color: function color(theme) {
|
|
131
|
+
return "" + theme.colors.text;
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
h3: {
|
|
135
|
+
fontSize: 3,
|
|
136
|
+
color: function color(theme) {
|
|
137
|
+
return "" + theme.colors.heading;
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
p: {
|
|
141
|
+
color: 'white'
|
|
142
|
+
},
|
|
143
|
+
'button[type="button"]:focus': {
|
|
144
|
+
outlineColor: 'white',
|
|
145
|
+
color: 'white'
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
content: (0, _jsxRuntime.jsxs)("div", {
|
|
149
|
+
children: [(0, _jsxRuntime.jsx)("h3", {
|
|
150
|
+
children: "This is Read because it is Custom"
|
|
151
|
+
}), (0, _jsxRuntime.jsx)("p", {
|
|
152
|
+
children: "This Dialog is styled using the `sx` property."
|
|
153
|
+
})]
|
|
154
|
+
})
|
|
155
|
+
}))]
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
exports.CustomStyling = CustomStyling;
|
|
@@ -42,10 +42,10 @@ var NoticeIcon = function NoticeIcon(_ref) {
|
|
|
42
42
|
|
|
43
43
|
return (0, _jsxRuntime.jsx)(Icon, {
|
|
44
44
|
sx: {
|
|
45
|
-
marginRight: 2,
|
|
46
45
|
color: color,
|
|
47
46
|
flex: '0 0 auto'
|
|
48
|
-
}
|
|
47
|
+
},
|
|
48
|
+
size: 21
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
51
|
|
|
@@ -106,12 +106,12 @@ var Notice = function Notice(_ref2) {
|
|
|
106
106
|
alignItems: 'center'
|
|
107
107
|
},
|
|
108
108
|
children: (0, _jsxRuntime.jsx)(NoticeIcon, {
|
|
109
|
-
color: color + ".
|
|
109
|
+
color: color + ".200",
|
|
110
110
|
variant: variant
|
|
111
111
|
})
|
|
112
112
|
}), (0, _jsxRuntime.jsxs)(_.Box, {
|
|
113
113
|
sx: {
|
|
114
|
-
ml:
|
|
114
|
+
ml: 3
|
|
115
115
|
},
|
|
116
116
|
children: [title && (0, _jsxRuntime.jsx)(_.Heading, {
|
|
117
117
|
variant: "h4",
|