@automattic/vip-design-system 2.10.1 → 2.10.2
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/babel.config.js +23 -19
- package/build/declaration.d.js +0 -1
- package/build/system/Accordion/Accordion.js +28 -33
- package/build/system/Accordion/Accordion.stories.js +34 -35
- package/build/system/Accordion/Accordion.test.js +35 -34
- package/build/system/Accordion/index.js +5 -8
- package/build/system/Avatar/Avatar.js +13 -17
- package/build/system/Avatar/Avatar.stories.js +10 -12
- package/build/system/Avatar/Avatar.test.js +15 -14
- package/build/system/Avatar/index.js +4 -6
- package/build/system/Badge/Badge.js +9 -14
- package/build/system/Badge/Badge.stories.js +23 -23
- package/build/system/Badge/Badge.test.js +15 -14
- package/build/system/Badge/index.js +4 -6
- package/build/system/Box/Box.js +9 -13
- package/build/system/Box/Box.stories.js +5 -8
- package/build/system/Breadcrumbs/Breadcrumbs.js +34 -38
- package/build/system/Breadcrumbs/Breadcrumbs.stories.js +18 -21
- package/build/system/Breadcrumbs/Breadcrumbs.test.js +28 -30
- package/build/system/Breadcrumbs/styles.js +5 -9
- package/build/system/Button/Button.js +11 -17
- package/build/system/Button/Button.stories.js +34 -33
- package/build/system/Button/Button.test.js +17 -16
- package/build/system/Button/ButtonSubmit.js +12 -16
- package/build/system/Button/ButtonSubmit.stories.js +12 -16
- package/build/system/Button/ButtonSubmit.test.js +15 -14
- package/build/system/Button/index.js +5 -8
- package/build/system/Card/Card.js +12 -14
- package/build/system/Card/Card.stories.js +21 -24
- package/build/system/Card/Card.test.js +19 -18
- package/build/system/Card/index.js +4 -6
- package/build/system/Code/Code.js +19 -23
- package/build/system/Code/Code.stories.js +16 -18
- package/build/system/Code/Code.test.js +20 -19
- package/build/system/Code/index.js +4 -6
- package/build/system/Drawer/Drawer.js +25 -30
- package/build/system/Drawer/Drawer.stories.js +38 -39
- package/build/system/Drawer/Drawer.test.js +19 -18
- package/build/system/Drawer/styles.js +9 -11
- package/build/system/Dropdown/Dropdown.js +23 -26
- package/build/system/Dropdown/Dropdown.test.js +16 -18
- package/build/system/Dropdown/DropdownContent.js +14 -20
- package/build/system/Dropdown/DropdownItem.js +19 -25
- package/build/system/Dropdown/DropdownLabel.js +10 -16
- package/build/system/Dropdown/DropdownSeparator.js +10 -16
- package/build/system/Dropdown/index.js +20 -23
- package/build/system/FilterDropdown/FilterDropdown.js +23 -29
- package/build/system/FilterDropdown/FilterDropdown.stories.js +9 -11
- package/build/system/FilterDropdown/FilterDropdown.test.js +7 -10
- package/build/system/Flex/Flex.js +7 -10
- package/build/system/Flex/Flex.stories.js +6 -10
- package/build/system/Flex/index.js +4 -6
- package/build/system/Footer/Footer.d.ts +33 -0
- package/build/system/Footer/Footer.js +82 -0
- package/build/system/Footer/Footer.stories.d.ts +41 -0
- package/build/system/Footer/Footer.stories.js +53 -0
- package/build/system/Footer/Footer.test.d.ts +1 -0
- package/build/system/Footer/Footer.test.js +36 -0
- package/build/system/Form/Checkbox/Checkbox.js +14 -18
- package/build/system/Form/Checkbox/Checkbox.stories.js +47 -48
- package/build/system/Form/Checkbox/Checkbox.test.js +23 -21
- package/build/system/Form/Checkbox/styles.js +7 -10
- package/build/system/Form/Input.js +19 -18
- package/build/system/Form/Input.stories.js +16 -18
- package/build/system/Form/Input.styles.js +5 -9
- package/build/system/Form/Label.js +14 -16
- package/build/system/Form/Label.stories.js +15 -15
- package/build/system/Form/Radio/Radio.js +13 -18
- package/build/system/Form/Radio/Radio.stories.js +43 -43
- package/build/system/Form/Radio/Radio.test.js +19 -18
- package/build/system/Form/Radio/RadioOption.js +22 -23
- package/build/system/Form/Radio/styles.js +7 -10
- package/build/system/Form/RadioGroupChip.js +26 -29
- package/build/system/Form/RadioGroupChip.stories.js +12 -15
- package/build/system/Form/RadioGroupChip.test.js +12 -11
- package/build/system/Form/RequiredLabel.js +3 -7
- package/build/system/Form/Toggle.js +11 -16
- package/build/system/Form/Toggle.stories.js +25 -27
- package/build/system/Form/Toggle.test.js +12 -11
- package/build/system/Form/Validation.js +10 -12
- package/build/system/Grid/Grid.js +7 -10
- package/build/system/Grid/Grid.stories.js +6 -10
- package/build/system/Grid/index.js +4 -6
- package/build/system/Heading/Heading.js +9 -14
- package/build/system/Heading/Heading.stories.js +13 -16
- package/build/system/Hr/Hr.js +3 -7
- package/build/system/Hr/Hr.stories.js +10 -11
- package/build/system/Hr/Hr.test.js +14 -14
- package/build/system/Link/Link.js +11 -14
- package/build/system/Link/Link.stories.js +11 -14
- package/build/system/Link/index.js +4 -6
- package/build/system/LinkExternal/LinkExternal.d.ts +23 -3
- package/build/system/LinkExternal/LinkExternal.js +17 -23
- package/build/system/LinkExternal/LinkExternal.stories.d.ts +1 -8
- package/build/system/LinkExternal/LinkExternal.stories.js +4 -9
- package/build/system/LinkExternal/LinkExternal.test.js +14 -15
- package/build/system/MobileMenu/MobileMenu.js +24 -29
- package/build/system/MobileMenu/MobileMenu.stories.js +66 -67
- package/build/system/MobileMenu/MobileMenu.test.js +21 -22
- package/build/system/Nav/Nav.js +26 -32
- package/build/system/Nav/Nav.stories.js +97 -99
- package/build/system/Nav/Nav.test.js +32 -28
- package/build/system/Nav/NavItem.js +40 -45
- package/build/system/Nav/NavItemGroup.js +34 -39
- package/build/system/Nav/NavItemGroup.test.js +26 -23
- package/build/system/Nav/styles/variants/breadcrumbs.js +4 -7
- package/build/system/Nav/styles/variants/menu.js +8 -12
- package/build/system/Nav/styles/variants/menugroup.js +7 -11
- package/build/system/Nav/styles/variants/primary.js +4 -8
- package/build/system/Nav/styles/variants/tabs.js +3 -7
- package/build/system/Nav/styles/variants/toolbar.js +5 -8
- package/build/system/Nav/styles.js +26 -29
- package/build/system/NewDialog/DialogClose.js +14 -18
- package/build/system/NewDialog/DialogClose.test.js +11 -14
- package/build/system/NewDialog/DialogDescription.js +9 -15
- package/build/system/NewDialog/DialogOverlay.js +11 -13
- package/build/system/NewDialog/DialogTitle.js +7 -15
- package/build/system/NewDialog/NewDialog.js +24 -29
- package/build/system/NewDialog/index.js +7 -11
- package/build/system/NewDialog/styles.js +1 -5
- package/build/system/NewForm/Fieldset.js +13 -17
- package/build/system/NewForm/Form.js +8 -13
- package/build/system/NewForm/FormAutocomplete.js +2 -2
- package/build/system/NewForm/Legend.js +11 -15
- package/build/system/Notice/Notice.js +22 -25
- package/build/system/Notice/Notice.stories.js +41 -43
- package/build/system/Notice/index.js +5 -5
- package/build/system/Page/Page.js +4 -8
- package/build/system/Page/Page.test.js +14 -14
- package/build/system/Progress/Progress.js +21 -24
- package/build/system/Progress/Progress.stories.js +9 -15
- package/build/system/Progress/Progress.test.js +14 -13
- package/build/system/Progress/index.js +4 -6
- package/build/system/ScreenReaderText/ScreenReaderText.js +9 -9
- package/build/system/Spinner/Spinner.js +9 -14
- package/build/system/Spinner/Spinner.stories.js +6 -10
- package/build/system/Spinner/Spinner.test.js +14 -13
- package/build/system/Spinner/index.js +1 -6
- package/build/system/Table/Table.js +20 -22
- package/build/system/Table/Table.stories.js +29 -30
- package/build/system/Table/TableCell.js +9 -11
- package/build/system/Table/TableRow.js +10 -11
- package/build/system/Table/index.js +6 -10
- package/build/system/Text/Text.js +9 -14
- package/build/system/Text/Text.stories.js +24 -25
- package/build/system/Text/index.js +4 -6
- package/build/system/Toolbar/Logo.js +11 -15
- package/build/system/Toolbar/Toolbar.js +12 -17
- package/build/system/Toolbar/Toolbar.stories.js +47 -50
- package/build/system/Toolbar/Toolbar.test.js +26 -24
- package/build/system/Toolbar/ToolbarUtilNav.js +9 -16
- package/build/system/Toolbar/index.js +10 -15
- package/build/system/Tooltip/Tooltip.js +9 -14
- package/build/system/Tooltip/Tooltip.stories.js +29 -31
- package/build/system/Tooltip/index.js +5 -5
- package/build/system/Wizard/Wizard.js +11 -18
- package/build/system/Wizard/Wizard.stories.js +37 -38
- package/build/system/Wizard/WizardStep.js +26 -32
- package/build/system/Wizard/index.js +6 -7
- package/build/system/assets/a8cLogo.d.ts +2 -0
- package/build/system/assets/a8cLogo.js +39 -0
- package/build/system/theme/breakpoints.js +1 -5
- package/build/system/utils/stories/CustomLink.js +7 -13
- package/package.json +1 -1
- package/src/system/Footer/Footer.stories.tsx +46 -0
- package/src/system/Footer/Footer.test.tsx +40 -0
- package/src/system/Footer/Footer.tsx +120 -0
- package/src/system/LinkExternal/LinkExternal.tsx +27 -8
- package/src/system/NewForm/FormAutocomplete.js +2 -2
- package/src/system/assets/a8cLogo.tsx +30 -0
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
var _jestAxe = require("jest-axe");
|
|
5
|
-
var _Code = require("./Code");
|
|
6
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
7
1
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
8
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
9
3
|
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); } }
|
|
10
|
-
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); }); }; }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
/**
|
|
11
6
|
* External dependencies
|
|
12
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
9
|
+
import { axe } from 'jest-axe';
|
|
10
|
+
|
|
11
|
+
/**
|
|
13
12
|
* Internal dependencies
|
|
14
13
|
*/
|
|
14
|
+
import { Code } from './Code';
|
|
15
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
15
16
|
var defaultProps = {
|
|
16
17
|
showCopy: false
|
|
17
18
|
};
|
|
@@ -30,15 +31,15 @@ describe('<Code />', function () {
|
|
|
30
31
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
31
32
|
while (1) switch (_context.prev = _context.next) {
|
|
32
33
|
case 0:
|
|
33
|
-
_render =
|
|
34
|
+
_render = render(_jsx(Code, _extends({}, defaultProps, {
|
|
34
35
|
children: "This is a code"
|
|
35
36
|
}))), container = _render.container;
|
|
36
|
-
expect(
|
|
37
|
+
expect(screen.getByText('This is a code')).toBeInTheDocument();
|
|
37
38
|
|
|
38
39
|
// Check for accessibility issues
|
|
39
40
|
_context.t0 = expect;
|
|
40
41
|
_context.next = 5;
|
|
41
|
-
return
|
|
42
|
+
return axe(container);
|
|
42
43
|
case 5:
|
|
43
44
|
_context.t1 = _context.sent;
|
|
44
45
|
(0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
@@ -56,17 +57,17 @@ describe('<Code />', function () {
|
|
|
56
57
|
props = _extends({}, defaultProps, {
|
|
57
58
|
showCopy: true
|
|
58
59
|
});
|
|
59
|
-
_render2 =
|
|
60
|
+
_render2 = render(_jsx(Code, _extends({}, props, {
|
|
60
61
|
children: "This is a code"
|
|
61
62
|
}))), container = _render2.container;
|
|
62
|
-
expect(
|
|
63
|
+
expect(screen.getByRole('button', {
|
|
63
64
|
name: 'Copy code'
|
|
64
65
|
})).toBeInTheDocument();
|
|
65
66
|
|
|
66
67
|
// Check for accessibility issues
|
|
67
68
|
_context2.t0 = expect;
|
|
68
69
|
_context2.next = 6;
|
|
69
|
-
return
|
|
70
|
+
return axe(container);
|
|
70
71
|
case 6:
|
|
71
72
|
_context2.t1 = _context2.sent;
|
|
72
73
|
(0, _context2.t0)(_context2.t1).toHaveNoViolations();
|
|
@@ -84,25 +85,25 @@ describe('<Code />', function () {
|
|
|
84
85
|
props = _extends({}, defaultProps, {
|
|
85
86
|
showCopy: true
|
|
86
87
|
});
|
|
87
|
-
_render3 =
|
|
88
|
+
_render3 = render(_jsx(Code, _extends({}, props, {
|
|
88
89
|
children: "This is a code"
|
|
89
90
|
}))), container = _render3.container;
|
|
90
|
-
|
|
91
|
+
fireEvent.click(screen.getByRole('button', {
|
|
91
92
|
name: 'Copy code'
|
|
92
93
|
}));
|
|
93
94
|
_context3.next = 5;
|
|
94
|
-
return
|
|
95
|
+
return waitFor(function () {
|
|
95
96
|
return new Promise(function (resolve) {
|
|
96
97
|
return setTimeout(resolve, 0);
|
|
97
98
|
});
|
|
98
99
|
});
|
|
99
100
|
case 5:
|
|
100
|
-
expect(
|
|
101
|
+
expect(screen.getByText('Code copied to clipboard')).toBeInTheDocument();
|
|
101
102
|
|
|
102
103
|
// Check for accessibility issues
|
|
103
104
|
_context3.t0 = expect;
|
|
104
105
|
_context3.next = 9;
|
|
105
|
-
return
|
|
106
|
+
return axe(container);
|
|
106
107
|
case 9:
|
|
107
108
|
_context3.t1 = _context3.sent;
|
|
108
109
|
(0, _context3.t0)(_context3.t1).toHaveNoViolations();
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.Trigger = exports.Root = exports.Drawer = exports.Content = void 0;
|
|
5
|
-
var DialogPrimitive = _interopRequireWildcard(require("@radix-ui/react-dialog"));
|
|
6
|
-
var _react = _interopRequireDefault(require("react"));
|
|
7
|
-
var _styles = require("./styles");
|
|
8
|
-
var _DialogClose = require("../NewDialog/DialogClose");
|
|
9
|
-
var _DialogTitle = require("../NewDialog/DialogTitle");
|
|
10
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
11
1
|
var _excluded = ["children", "variant", "label", "dimensions", "renderClose"],
|
|
12
2
|
_excluded2 = ["children", "dimensions", "variant", "trigger", "label"];
|
|
13
|
-
/** @jsxImportSource theme-ui */
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
16
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
17
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
18
4
|
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; }
|
|
19
|
-
|
|
5
|
+
/** @jsxImportSource theme-ui */
|
|
6
|
+
|
|
7
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { drawerContentStyles, drawerOverlayStyles } from './styles';
|
|
10
|
+
import { DialogClose } from '../NewDialog/DialogClose';
|
|
11
|
+
import { DialogTitle } from '../NewDialog/DialogTitle';
|
|
12
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
14
|
+
export var Content = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
20
15
|
var children = _ref.children,
|
|
21
16
|
_ref$variant = _ref.variant,
|
|
22
17
|
variant = _ref$variant === void 0 ? 'left' : _ref$variant,
|
|
@@ -24,20 +19,20 @@ var Content = exports.Content = /*#__PURE__*/_react["default"].forwardRef(functi
|
|
|
24
19
|
dimensions = _ref.dimensions,
|
|
25
20
|
renderClose = _ref.renderClose,
|
|
26
21
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
27
|
-
return (
|
|
28
|
-
children: [(
|
|
29
|
-
sx:
|
|
30
|
-
}), (
|
|
31
|
-
sx:
|
|
22
|
+
return _jsxs(DialogPrimitive.Portal, {
|
|
23
|
+
children: [_jsx(DialogPrimitive.Overlay, {
|
|
24
|
+
sx: drawerOverlayStyles(variant)
|
|
25
|
+
}), _jsxs(DialogPrimitive.Content, _extends({}, rest, {
|
|
26
|
+
sx: drawerContentStyles(variant, dimensions),
|
|
32
27
|
ref: forwardedRef,
|
|
33
|
-
children: [(
|
|
28
|
+
children: [_jsx(DialogTitle, {
|
|
34
29
|
title: label,
|
|
35
30
|
hidden: true
|
|
36
|
-
}), renderClose ? renderClose() : (
|
|
31
|
+
}), renderClose ? renderClose() : _jsx(DialogClose, {}), children]
|
|
37
32
|
}))]
|
|
38
33
|
});
|
|
39
34
|
});
|
|
40
|
-
var Drawer =
|
|
35
|
+
export var Drawer = /*#__PURE__*/React.forwardRef(function (_ref2, forwardedRef) {
|
|
41
36
|
var children = _ref2.children,
|
|
42
37
|
dimensions = _ref2.dimensions,
|
|
43
38
|
_ref2$variant = _ref2.variant,
|
|
@@ -45,9 +40,9 @@ var Drawer = exports.Drawer = /*#__PURE__*/_react["default"].forwardRef(function
|
|
|
45
40
|
trigger = _ref2.trigger,
|
|
46
41
|
label = _ref2.label,
|
|
47
42
|
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
48
|
-
return (
|
|
43
|
+
return _jsx(Root, {
|
|
49
44
|
trigger: trigger,
|
|
50
|
-
children: (
|
|
45
|
+
children: _jsx(Content, _extends({
|
|
51
46
|
dimensions: dimensions,
|
|
52
47
|
variant: variant,
|
|
53
48
|
label: label,
|
|
@@ -57,18 +52,18 @@ var Drawer = exports.Drawer = /*#__PURE__*/_react["default"].forwardRef(function
|
|
|
57
52
|
}))
|
|
58
53
|
});
|
|
59
54
|
});
|
|
60
|
-
var Trigger =
|
|
55
|
+
export var Trigger = function Trigger(_ref3) {
|
|
61
56
|
var children = _ref3.children;
|
|
62
|
-
return (
|
|
57
|
+
return _jsx(DialogPrimitive.Trigger, {
|
|
63
58
|
asChild: true,
|
|
64
59
|
children: children
|
|
65
60
|
});
|
|
66
61
|
};
|
|
67
|
-
var Root =
|
|
62
|
+
export var Root = function Root(_ref4) {
|
|
68
63
|
var children = _ref4.children,
|
|
69
64
|
trigger = _ref4.trigger;
|
|
70
|
-
return (
|
|
71
|
-
children: [trigger && (
|
|
65
|
+
return _jsxs(DialogPrimitive.Root, {
|
|
66
|
+
children: [trigger && _jsx(Trigger, {
|
|
72
67
|
children: trigger
|
|
73
68
|
}), children]
|
|
74
69
|
});
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports["default"] = exports.Default = exports.ByParts = void 0;
|
|
5
|
-
var _Drawer = require("./Drawer");
|
|
6
|
-
var _ = require("..");
|
|
7
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
8
1
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
9
2
|
// @ts-nocheck
|
|
10
3
|
/** @jsxImportSource theme-ui */
|
|
11
|
-
|
|
4
|
+
|
|
5
|
+
import { Drawer, Root, Trigger, Content } from './Drawer';
|
|
6
|
+
import { Button } from '..';
|
|
7
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
8
|
+
import { Fragment as _Fragment } from "theme-ui/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
10
|
+
export default {
|
|
12
11
|
title: 'Navigation/Drawer',
|
|
13
|
-
component:
|
|
12
|
+
component: Drawer,
|
|
14
13
|
parameters: {
|
|
15
14
|
docs: {
|
|
16
15
|
description: {
|
|
@@ -19,37 +18,37 @@ var _default = exports["default"] = {
|
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
};
|
|
22
|
-
var Default =
|
|
21
|
+
export var Default = {
|
|
23
22
|
render: function render() {
|
|
24
|
-
return (
|
|
25
|
-
children: [(
|
|
23
|
+
return _jsxs(_Fragment, {
|
|
24
|
+
children: [_jsx(Drawer, {
|
|
26
25
|
label: "My XYZ Dialog",
|
|
27
|
-
trigger: (
|
|
26
|
+
trigger: _jsx(Button, {
|
|
28
27
|
children: "Open "
|
|
29
28
|
}),
|
|
30
29
|
dimensions: {
|
|
31
30
|
width: 320
|
|
32
31
|
},
|
|
33
|
-
children: (
|
|
32
|
+
children: _jsx("p", {
|
|
34
33
|
sx: {
|
|
35
34
|
ml: 3
|
|
36
35
|
},
|
|
37
36
|
children: "Hello from default"
|
|
38
37
|
})
|
|
39
|
-
}), (
|
|
40
|
-
trigger: (
|
|
38
|
+
}), _jsx(Drawer, {
|
|
39
|
+
trigger: _jsx(Button, {
|
|
41
40
|
children: "Top"
|
|
42
41
|
}),
|
|
43
42
|
variant: "top",
|
|
44
43
|
label: "Dialog Content",
|
|
45
|
-
children: (
|
|
44
|
+
children: _jsx("p", {
|
|
46
45
|
sx: {
|
|
47
46
|
ml: 3
|
|
48
47
|
},
|
|
49
48
|
children: "Hello from top"
|
|
50
49
|
})
|
|
51
|
-
}), (
|
|
52
|
-
trigger: (
|
|
50
|
+
}), _jsx(Drawer, {
|
|
51
|
+
trigger: _jsx(Button, {
|
|
53
52
|
children: "Right"
|
|
54
53
|
}),
|
|
55
54
|
variant: "right",
|
|
@@ -57,14 +56,14 @@ var Default = exports.Default = {
|
|
|
57
56
|
dimensions: {
|
|
58
57
|
width: 500
|
|
59
58
|
},
|
|
60
|
-
children: (
|
|
59
|
+
children: _jsx("p", {
|
|
61
60
|
sx: {
|
|
62
61
|
ml: 3
|
|
63
62
|
},
|
|
64
63
|
children: "Hello from right width 500px"
|
|
65
64
|
})
|
|
66
|
-
}), (
|
|
67
|
-
trigger: (
|
|
65
|
+
}), _jsx(Drawer, {
|
|
66
|
+
trigger: _jsx(Button, {
|
|
68
67
|
children: "Bottom"
|
|
69
68
|
}),
|
|
70
69
|
variant: "bottom",
|
|
@@ -72,14 +71,14 @@ var Default = exports.Default = {
|
|
|
72
71
|
dimensions: {
|
|
73
72
|
height: 200
|
|
74
73
|
},
|
|
75
|
-
children: (
|
|
74
|
+
children: _jsx("p", {
|
|
76
75
|
sx: {
|
|
77
76
|
ml: 3
|
|
78
77
|
},
|
|
79
78
|
children: "Hello from bottom with 200px"
|
|
80
79
|
})
|
|
81
|
-
}), (
|
|
82
|
-
trigger: (
|
|
80
|
+
}), _jsx(Drawer, {
|
|
81
|
+
trigger: _jsx(Button, {
|
|
83
82
|
children: "Left"
|
|
84
83
|
}),
|
|
85
84
|
variant: "left",
|
|
@@ -87,31 +86,31 @@ var Default = exports.Default = {
|
|
|
87
86
|
dimensions: {
|
|
88
87
|
width: 600
|
|
89
88
|
},
|
|
90
|
-
children: (
|
|
89
|
+
children: _jsx("p", {
|
|
91
90
|
sx: {
|
|
92
91
|
ml: 3
|
|
93
92
|
},
|
|
94
93
|
children: "Hello from left width 600px"
|
|
95
94
|
})
|
|
96
|
-
}), (
|
|
97
|
-
trigger: (
|
|
95
|
+
}), _jsx(Drawer, {
|
|
96
|
+
trigger: _jsx(Button, {
|
|
98
97
|
children: "Left Header"
|
|
99
98
|
}),
|
|
100
99
|
variant: "left-header",
|
|
101
100
|
label: "Dialog",
|
|
102
|
-
children: (
|
|
101
|
+
children: _jsx("p", {
|
|
103
102
|
sx: {
|
|
104
103
|
ml: 3
|
|
105
104
|
},
|
|
106
105
|
children: "Hello from left header (VIP Dashboard needs)"
|
|
107
106
|
})
|
|
108
|
-
}), (
|
|
109
|
-
trigger: (
|
|
107
|
+
}), _jsx(Drawer, {
|
|
108
|
+
trigger: _jsx(Button, {
|
|
110
109
|
children: "Right Header"
|
|
111
110
|
}),
|
|
112
111
|
variant: "left-header",
|
|
113
112
|
label: "Dialog",
|
|
114
|
-
children: (
|
|
113
|
+
children: _jsx("p", {
|
|
115
114
|
sx: {
|
|
116
115
|
ml: 3
|
|
117
116
|
},
|
|
@@ -121,20 +120,20 @@ var Default = exports.Default = {
|
|
|
121
120
|
});
|
|
122
121
|
}
|
|
123
122
|
};
|
|
124
|
-
var ByParts =
|
|
123
|
+
export var ByParts = {
|
|
125
124
|
render: function render() {
|
|
126
|
-
return (
|
|
127
|
-
children: (
|
|
128
|
-
children: [(
|
|
129
|
-
children: (
|
|
125
|
+
return _jsx(_Fragment, {
|
|
126
|
+
children: _jsxs(Root, {
|
|
127
|
+
children: [_jsx(Trigger, {
|
|
128
|
+
children: _jsx(Button, {
|
|
130
129
|
children: "Open "
|
|
131
130
|
})
|
|
132
|
-
}), (
|
|
131
|
+
}), _jsx(Content, {
|
|
133
132
|
dimensions: {
|
|
134
133
|
width: 320
|
|
135
134
|
},
|
|
136
135
|
label: "My XYZ Dialog",
|
|
137
|
-
children: (
|
|
136
|
+
children: _jsx("p", {
|
|
138
137
|
sx: {
|
|
139
138
|
ml: 3
|
|
140
139
|
},
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
var _jestAxe = require("jest-axe");
|
|
5
|
-
var _themeUi = require("theme-ui");
|
|
6
|
-
var _Drawer = require("./Drawer");
|
|
7
|
-
var _ = require("../");
|
|
8
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
9
1
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
10
2
|
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); } }
|
|
11
|
-
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); }); }; }
|
|
3
|
+
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); }); }; }
|
|
4
|
+
/** @jsxImportSource theme-ui */
|
|
5
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
6
|
+
// @ts-nocheck
|
|
7
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
8
|
+
import { axe } from 'jest-axe';
|
|
9
|
+
import { ThemeUIProvider } from 'theme-ui';
|
|
10
|
+
import { Drawer } from './Drawer';
|
|
11
|
+
import { Button, theme } from '../';
|
|
12
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
12
13
|
var renderWithTheme = function renderWithTheme(children) {
|
|
13
|
-
return
|
|
14
|
-
theme:
|
|
14
|
+
return render(_jsx(ThemeUIProvider, {
|
|
15
|
+
theme: theme,
|
|
15
16
|
children: children
|
|
16
17
|
}));
|
|
17
18
|
};
|
|
18
19
|
var renderComponent = function renderComponent() {
|
|
19
|
-
return renderWithTheme((
|
|
20
|
+
return renderWithTheme(_jsx(Drawer, {
|
|
20
21
|
label: "Dialog example",
|
|
21
22
|
sx: {
|
|
22
23
|
width: 320
|
|
23
24
|
},
|
|
24
|
-
trigger: (
|
|
25
|
+
trigger: _jsx(Button, {
|
|
25
26
|
children: "Open Drawer"
|
|
26
27
|
}),
|
|
27
|
-
children: (
|
|
28
|
+
children: _jsx("p", {
|
|
28
29
|
sx: {
|
|
29
30
|
ml: 3
|
|
30
31
|
},
|
|
@@ -50,15 +51,15 @@ describe('<Drawer />', function () {
|
|
|
50
51
|
while (1) switch (_context.prev = _context.next) {
|
|
51
52
|
case 0:
|
|
52
53
|
_renderComponent = renderComponent(), container = _renderComponent.container;
|
|
53
|
-
trigger =
|
|
54
|
+
trigger = screen.getByRole('button', {
|
|
54
55
|
name: 'Open Drawer'
|
|
55
56
|
});
|
|
56
57
|
expect(trigger).toBeInTheDocument();
|
|
57
|
-
|
|
58
|
-
expect(
|
|
58
|
+
fireEvent.click(trigger);
|
|
59
|
+
expect(screen.getByText('Hello from default')).toBeInTheDocument();
|
|
59
60
|
_context.t0 = expect;
|
|
60
61
|
_context.next = 8;
|
|
61
|
-
return
|
|
62
|
+
return axe(container);
|
|
62
63
|
case 8:
|
|
63
64
|
_context.t1 = _context.sent;
|
|
64
65
|
(0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
/** @jsxImportSource theme-ui */
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
exports.drawerOverlayStyles = exports.drawerContentStyles = void 0;
|
|
5
|
-
var _react = require("@emotion/react");
|
|
6
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /** @jsxImportSource theme-ui */
|
|
4
|
+
import { keyframes } from '@emotion/react';
|
|
7
5
|
var slideIn = function slideIn(theme, variant) {
|
|
8
6
|
if (variant && theme.drawer && theme.drawer[variant]) {
|
|
9
|
-
return
|
|
7
|
+
return keyframes({
|
|
10
8
|
from: {
|
|
11
9
|
transform: theme.drawer[variant].transform
|
|
12
10
|
},
|
|
@@ -18,7 +16,7 @@ var slideIn = function slideIn(theme, variant) {
|
|
|
18
16
|
};
|
|
19
17
|
var slideOut = function slideOut(theme, variant) {
|
|
20
18
|
if (variant && theme.drawer && theme.drawer[variant]) {
|
|
21
|
-
return
|
|
19
|
+
return keyframes({
|
|
22
20
|
from: {
|
|
23
21
|
transform: 'translate3d(0,0,0)'
|
|
24
22
|
},
|
|
@@ -28,7 +26,7 @@ var slideOut = function slideOut(theme, variant) {
|
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
};
|
|
31
|
-
var drawerContentStyles =
|
|
29
|
+
export var drawerContentStyles = function drawerContentStyles(variant, dimensions) {
|
|
32
30
|
var width = (dimensions == null ? void 0 : dimensions.width) || ['100%', '100%', '80vw'];
|
|
33
31
|
var height = (dimensions == null ? void 0 : dimensions.height) || '100vh';
|
|
34
32
|
var minWidth = (dimensions == null ? void 0 : dimensions.minWidth) || '16rem';
|
|
@@ -79,7 +77,7 @@ var drawerContentStyles = exports.drawerContentStyles = function drawerContentSt
|
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
79
|
};
|
|
82
|
-
var fadeIn =
|
|
80
|
+
var fadeIn = keyframes({
|
|
83
81
|
from: {
|
|
84
82
|
opacity: '0'
|
|
85
83
|
},
|
|
@@ -87,7 +85,7 @@ var fadeIn = (0, _react.keyframes)({
|
|
|
87
85
|
opacity: '1'
|
|
88
86
|
}
|
|
89
87
|
});
|
|
90
|
-
var fadeOut =
|
|
88
|
+
var fadeOut = keyframes({
|
|
91
89
|
from: {
|
|
92
90
|
opacity: '1'
|
|
93
91
|
},
|
|
@@ -95,7 +93,7 @@ var fadeOut = (0, _react.keyframes)({
|
|
|
95
93
|
opacity: '0'
|
|
96
94
|
}
|
|
97
95
|
});
|
|
98
|
-
var drawerOverlayStyles =
|
|
96
|
+
export var drawerOverlayStyles = function drawerOverlayStyles(variant) {
|
|
99
97
|
var defaultStyles = {
|
|
100
98
|
position: 'fixed',
|
|
101
99
|
top: 0,
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
/** @jsxImportSource theme-ui */
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
11
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
12
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /** @jsxImportSource theme-ui */
|
|
4
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { DropdownContent } from './DropdownContent';
|
|
7
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
13
9
|
var DropdownMenu = DropdownMenuPrimitive.Root;
|
|
14
|
-
var DropdownTrigger =
|
|
15
|
-
var DropdownRadioGroup =
|
|
16
|
-
var DropdownItemIndicator =
|
|
17
|
-
var DropdownLabel =
|
|
18
|
-
var DropdownSeparator =
|
|
19
|
-
var DropdownSub =
|
|
20
|
-
var DropdownSubTrigger =
|
|
21
|
-
var DropdownSubContent =
|
|
22
|
-
var Dropdown =
|
|
10
|
+
var DropdownTrigger = DropdownMenuPrimitive.Trigger;
|
|
11
|
+
var DropdownRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
12
|
+
var DropdownItemIndicator = DropdownMenuPrimitive.DropdownMenuItemIndicator;
|
|
13
|
+
var DropdownLabel = DropdownMenuPrimitive.DropdownMenuLabel;
|
|
14
|
+
var DropdownSeparator = DropdownMenuPrimitive.DropdownMenuSeparator;
|
|
15
|
+
var DropdownSub = DropdownMenuPrimitive.DropdownMenuSub;
|
|
16
|
+
var DropdownSubTrigger = DropdownMenuPrimitive.DropdownMenuSubTrigger;
|
|
17
|
+
var DropdownSubContent = DropdownMenuPrimitive.DropdownMenuSubContent;
|
|
18
|
+
export var Dropdown = function Dropdown(_ref) {
|
|
23
19
|
var trigger = _ref.trigger,
|
|
24
20
|
children = _ref.children,
|
|
25
21
|
_ref$open = _ref.open,
|
|
@@ -36,19 +32,19 @@ var Dropdown = exports.Dropdown = function Dropdown(_ref) {
|
|
|
36
32
|
contentProps = _ref$contentProps === void 0 ? {} : _ref$contentProps,
|
|
37
33
|
_ref$portalProps = _ref.portalProps,
|
|
38
34
|
portalProps = _ref$portalProps === void 0 ? {} : _ref$portalProps;
|
|
39
|
-
return (
|
|
35
|
+
return _jsxs(DropdownMenu, {
|
|
40
36
|
open: open,
|
|
41
37
|
defaultOpen: defaultOpen,
|
|
42
38
|
onOpenChange: onOpenChange,
|
|
43
39
|
modal: modal,
|
|
44
40
|
dir: dir,
|
|
45
|
-
children: [(
|
|
41
|
+
children: [_jsx(DropdownTrigger, {
|
|
46
42
|
className: "vip-dropdown-trigger",
|
|
47
43
|
asChild: true,
|
|
48
44
|
children: trigger
|
|
49
|
-
}), (
|
|
50
|
-
children: (
|
|
51
|
-
children: [children, (
|
|
45
|
+
}), _jsx(DropdownMenuPrimitive.Portal, _extends({}, portalProps, {
|
|
46
|
+
children: _jsxs(DropdownContent, _extends({}, contentProps, {
|
|
47
|
+
children: [children, _jsx(DropdownMenuPrimitive.Arrow, {
|
|
52
48
|
sx: {
|
|
53
49
|
fill: 'background',
|
|
54
50
|
boxShadow: 'high'
|
|
@@ -59,4 +55,5 @@ var Dropdown = exports.Dropdown = function Dropdown(_ref) {
|
|
|
59
55
|
});
|
|
60
56
|
};
|
|
61
57
|
|
|
62
|
-
// Exports
|
|
58
|
+
// Exports
|
|
59
|
+
export { DropdownTrigger, DropdownRadioGroup, DropdownItemIndicator, DropdownLabel, DropdownSeparator, DropdownSub, DropdownSubTrigger, DropdownSubContent };
|