@automattic/vip-design-system 2.2.0 → 2.3.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/.eslintrc.js +3 -0
- package/build/system/Accordion/Accordion.test.d.ts +0 -1
- package/build/system/Accordion/Accordion.test.js +23 -12
- package/build/system/Button/Button.d.ts +2 -0
- package/build/system/Button/Button.js +6 -15
- package/build/system/Button/Button.stories.js +86 -67
- package/build/system/Card/Card.js +1 -2
- package/build/system/Drawer/Drawer.d.ts +12 -3
- package/build/system/Drawer/Drawer.js +8 -9
- package/build/system/Drawer/Drawer.stories.d.ts +0 -1
- package/build/system/Drawer/Drawer.stories.js +19 -225
- package/build/system/Drawer/styles.d.ts +2 -2
- package/build/system/Drawer/styles.js +13 -9
- package/build/system/Form/Toggle.d.ts +14 -2
- package/build/system/Form/Toggle.js +68 -69
- package/build/system/Form/Toggle.stories.d.ts +29 -18
- package/build/system/Form/Toggle.stories.js +99 -0
- package/build/system/Form/Toggle.test.js +36 -19
- package/build/system/Link/Link.d.ts +1 -1
- package/build/system/Link/Link.js +5 -20
- package/build/system/Link/Link.stories.d.ts +3 -1
- package/build/system/Link/Link.stories.js +18 -1
- package/build/system/MobileMenu/MobileMenu.d.ts +16 -0
- package/build/system/MobileMenu/MobileMenu.js +112 -0
- package/build/system/MobileMenu/MobileMenu.stories.d.ts +19 -0
- package/build/system/MobileMenu/MobileMenu.stories.js +173 -0
- package/build/system/MobileMenu/MobileMenu.test.d.ts +1 -0
- package/build/system/MobileMenu/MobileMenu.test.js +81 -0
- package/build/system/Nav/NavItem.js +4 -5
- package/build/system/Nav/NavItemGroup.d.ts +3 -0
- package/build/system/Nav/NavItemGroup.js +18 -6
- package/build/system/Nav/styles/variants/menu.js +15 -9
- package/build/system/Nav/styles/variants/menugroup.js +9 -5
- package/build/system/Nav/styles/variants/toolbar.js +1 -2
- package/build/system/Nav/styles.js +1 -0
- package/build/system/NewDialog/DialogClose.d.ts +7 -2
- package/build/system/NewDialog/DialogClose.js +25 -15
- package/build/system/NewDialog/index.d.ts +2 -1
- package/build/system/NewDialog/index.js +2 -1
- package/build/system/NewForm/FormAutocomplete.css +1 -3
- package/build/system/Table/Table.js +1 -0
- package/build/system/Toolbar/Toolbar.js +1 -1
- package/build/system/Toolbar/Toolbar.stories.d.ts +3 -0
- package/build/system/Toolbar/Toolbar.stories.js +62 -5
- package/build/system/Toolbar/ToolbarUtilNav.d.ts +3 -0
- package/build/system/Toolbar/ToolbarUtilNav.js +21 -3
- package/build/system/Toolbar/index.d.ts +3 -0
- package/build/system/Toolbar/index.js +2 -1
- package/build/system/index.d.ts +4 -1
- package/build/system/index.js +4 -0
- package/build/system/theme/index.d.ts +70 -35
- package/build/system/theme/index.js +47 -18
- package/package.json +2 -1
- package/src/system/Accordion/Accordion.test.tsx +15 -8
- package/src/system/Button/Button.stories.tsx +40 -31
- package/src/system/Button/Button.tsx +6 -15
- package/src/system/Card/Card.tsx +0 -1
- package/src/system/Drawer/Drawer.stories.tsx +28 -197
- package/src/system/Drawer/Drawer.tsx +31 -18
- package/src/system/Drawer/styles.ts +15 -5
- package/src/system/Form/Toggle.stories.tsx +122 -0
- package/src/system/Form/{Toggle.test.js → Toggle.test.tsx} +1 -1
- package/src/system/Form/Toggle.tsx +77 -0
- package/src/system/Link/Link.stories.tsx +21 -0
- package/src/system/Link/Link.tsx +10 -17
- package/src/system/MobileMenu/MobileMenu.stories.tsx +171 -0
- package/src/system/MobileMenu/MobileMenu.test.tsx +50 -0
- package/src/system/MobileMenu/MobileMenu.tsx +116 -0
- package/src/system/Nav/NavItem.tsx +3 -3
- package/src/system/Nav/NavItemGroup.tsx +18 -2
- package/src/system/Nav/styles/variants/menu.ts +15 -9
- package/src/system/Nav/styles/variants/menugroup.ts +7 -3
- package/src/system/Nav/styles/variants/toolbar.ts +1 -2
- package/src/system/Nav/styles.ts +1 -0
- package/src/system/NewDialog/DialogClose.tsx +36 -23
- package/src/system/NewDialog/index.ts +3 -2
- package/src/system/NewForm/FormAutocomplete.css +1 -3
- package/src/system/Table/Table.tsx +1 -1
- package/src/system/Toolbar/Toolbar.stories.tsx +49 -2
- package/src/system/Toolbar/Toolbar.tsx +1 -1
- package/src/system/Toolbar/ToolbarUtilNav.tsx +19 -2
- package/src/system/Toolbar/index.tsx +6 -1
- package/src/system/index.js +4 -0
- package/src/system/theme/index.js +47 -18
- package/build/system/Form/Toggle.stories.jsx +0 -96
- package/src/system/Form/Toggle.js +0 -74
- package/src/system/Form/Toggle.stories.jsx +0 -96
|
@@ -1,23 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { render, screen } from '@testing-library/react';
|
|
5
|
-
import { axe } from 'jest-axe';
|
|
1
|
+
"use strict";
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
4
|
+
var _jestAxe = require("jest-axe");
|
|
5
|
+
var _Toggle = require("./Toggle");
|
|
6
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
7
|
+
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
|
+
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); } }
|
|
9
|
+
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); }); }; } /**
|
|
10
|
+
* External dependencies
|
|
11
|
+
*/ /**
|
|
8
12
|
* Internal dependencies
|
|
9
13
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
describe('<Toggle />', function () {
|
|
15
|
+
it('renders the Toggle component', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
16
|
+
var _render, container;
|
|
17
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18
|
+
while (1) switch (_context.prev = _context.next) {
|
|
19
|
+
case 0:
|
|
20
|
+
_render = (0, _react.render)((0, _jsxRuntime.jsx)(_Toggle.Toggle, {
|
|
21
|
+
"aria-label": "Dinner room Light",
|
|
22
|
+
defaultChecked: true,
|
|
23
|
+
name: "my-toggle"
|
|
24
|
+
})), container = _render.container;
|
|
25
|
+
expect(_react.screen.getByRole('switch')).toBeInTheDocument();
|
|
19
26
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
// Check for accessibility issues
|
|
28
|
+
_context.t0 = expect;
|
|
29
|
+
_context.next = 5;
|
|
30
|
+
return (0, _jestAxe.axe)(container);
|
|
31
|
+
case 5:
|
|
32
|
+
_context.t1 = _context.sent;
|
|
33
|
+
(0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
34
|
+
case 7:
|
|
35
|
+
case "end":
|
|
36
|
+
return _context.stop();
|
|
37
|
+
}
|
|
38
|
+
}, _callee);
|
|
39
|
+
})));
|
|
40
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { LinkProps as ThemeLinkProps, ThemeUIStyleObject } from 'theme-ui';
|
|
3
3
|
export interface LinkProps extends ThemeLinkProps {
|
|
4
|
-
|
|
4
|
+
variant?: 'primary' | 'button-primary' | 'button-secondary' | 'button-tertiary' | 'button-ghost' | 'button-display' | 'button-danger';
|
|
5
5
|
}
|
|
6
6
|
export declare const defaultLinkComponentStyle: ThemeUIStyleObject;
|
|
7
7
|
export declare const Link: import("react").ForwardRefExoticComponent<Omit<LinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
@@ -5,7 +5,7 @@ exports.defaultLinkComponentStyle = exports.Link = void 0;
|
|
|
5
5
|
var _react = require("react");
|
|
6
6
|
var _themeUi = require("theme-ui");
|
|
7
7
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
8
|
-
var _excluded = ["
|
|
8
|
+
var _excluded = ["variant", "sx"];
|
|
9
9
|
/**
|
|
10
10
|
* External dependencies
|
|
11
11
|
*/
|
|
@@ -13,33 +13,18 @@ var _excluded = ["active", "sx"];
|
|
|
13
13
|
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); }
|
|
14
14
|
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; }
|
|
15
15
|
var defaultLinkComponentStyle = exports.defaultLinkComponentStyle = {
|
|
16
|
-
color: 'link',
|
|
17
|
-
textDecorationThickness: '0.1em',
|
|
18
|
-
textUnderlineOffset: '0.1em',
|
|
19
|
-
'&:visited': {
|
|
20
|
-
color: 'links.visited'
|
|
21
|
-
},
|
|
22
|
-
'&:active': {
|
|
23
|
-
color: 'links.active'
|
|
24
|
-
},
|
|
25
|
-
'&:hover, &:focus': {
|
|
26
|
-
color: 'links.hover',
|
|
27
|
-
textDecorationLine: 'underline',
|
|
28
|
-
textDecorationThickness: '2px'
|
|
29
|
-
},
|
|
30
16
|
'&:focus-visible': function focusVisible(theme) {
|
|
31
17
|
return theme.outline;
|
|
32
18
|
}
|
|
33
19
|
};
|
|
34
20
|
var Link = exports.Link = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
35
|
-
var _ref$
|
|
36
|
-
|
|
21
|
+
var _ref$variant = _ref.variant,
|
|
22
|
+
variant = _ref$variant === void 0 ? 'primary' : _ref$variant,
|
|
37
23
|
sx = _ref.sx,
|
|
38
24
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
39
25
|
return (0, _jsxRuntime.jsx)(_themeUi.Link, _extends({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, sx),
|
|
26
|
+
variant: variant,
|
|
27
|
+
sx: _extends({}, defaultLinkComponentStyle, sx),
|
|
43
28
|
ref: ref
|
|
44
29
|
}, props));
|
|
45
30
|
});
|
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
* External dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { Link } from '..';
|
|
6
|
+
import type { LinkProps } from './Link';
|
|
6
7
|
import type { StoryObj } from '@storybook/react';
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
9
10
|
*/
|
|
10
11
|
declare const _default: {
|
|
11
12
|
title: string;
|
|
12
|
-
component: import("react").ForwardRefExoticComponent<Omit<
|
|
13
|
+
component: import("react").ForwardRefExoticComponent<Omit<LinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
13
14
|
};
|
|
14
15
|
export default _default;
|
|
15
16
|
type Story = StoryObj<typeof Link>;
|
|
16
17
|
export declare const Default: Story;
|
|
18
|
+
export declare const ButtonVariants: () => import("react").JSX.Element;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports["default"] = exports.Default = void 0;
|
|
4
|
+
exports["default"] = exports.Default = exports.ButtonVariants = void 0;
|
|
5
5
|
var _ = require("..");
|
|
6
|
+
var _Flex = require("../Flex/Flex");
|
|
7
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
6
8
|
/**
|
|
7
9
|
* External dependencies
|
|
8
10
|
*/
|
|
@@ -18,4 +20,19 @@ var Default = exports.Default = {
|
|
|
18
20
|
children: 'Hello',
|
|
19
21
|
href: '#!'
|
|
20
22
|
}
|
|
23
|
+
};
|
|
24
|
+
var buttonTypes = ['button-primary', 'button-secondary', 'button-tertiary', 'button-danger', 'button-display', 'button-ghost'];
|
|
25
|
+
var ButtonVariants = exports.ButtonVariants = function ButtonVariants() {
|
|
26
|
+
return (0, _jsxRuntime.jsx)(_Flex.Flex, {
|
|
27
|
+
sx: {
|
|
28
|
+
gap: 2
|
|
29
|
+
},
|
|
30
|
+
children: buttonTypes.map(function (variant, index) {
|
|
31
|
+
return (0, _jsxRuntime.jsx)(_.Link, {
|
|
32
|
+
href: "#!",
|
|
33
|
+
variant: variant,
|
|
34
|
+
children: "Hello"
|
|
35
|
+
}, index);
|
|
36
|
+
})
|
|
37
|
+
});
|
|
21
38
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface MobileMenuProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
toolbarItems?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const MobileMenu: React.ForwardRefExoticComponent<MobileMenuProps & React.RefAttributes<HTMLDivElement>>;
|
|
8
|
+
export declare const MobileMenuWrapper: ({ children }: MobileMenuProps) => React.JSX.Element;
|
|
9
|
+
type MobileMenuTriggerDisplayProp = 'none' | 'flex';
|
|
10
|
+
type MobileMenuTriggerProps = {
|
|
11
|
+
label: string;
|
|
12
|
+
variant?: 'primary' | 'inverse';
|
|
13
|
+
display?: MobileMenuTriggerDisplayProp[];
|
|
14
|
+
};
|
|
15
|
+
export declare const MobileMenuTrigger: ({ label, variant, display, }: MobileMenuTriggerProps) => React.JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.MobileMenuWrapper = exports.MobileMenuTrigger = exports.MobileMenu = void 0;
|
|
5
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
6
|
+
var _bi = require("react-icons/bi");
|
|
7
|
+
var Drawer = _interopRequireWildcard(require("../Drawer/Drawer"));
|
|
8
|
+
var _DialogClose = require("../NewDialog/DialogClose");
|
|
9
|
+
var _Logo = require("../Toolbar/Logo");
|
|
10
|
+
var _index = require("../index");
|
|
11
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
/** @jsxImportSource theme-ui */
|
|
15
|
+
|
|
16
|
+
var MobileMenu = exports.MobileMenu = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
17
|
+
var children = _ref.children,
|
|
18
|
+
toolbarItems = _ref.toolbarItems;
|
|
19
|
+
return (0, _jsxRuntime.jsx)(Drawer.Content, {
|
|
20
|
+
variant: "left",
|
|
21
|
+
label: "Main Navigation Items",
|
|
22
|
+
ref: ref,
|
|
23
|
+
renderClose: function renderClose() {
|
|
24
|
+
return (0, _jsxRuntime.jsx)(_DialogClose.DialogCloseDefault, {
|
|
25
|
+
variant: "inverse"
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
children: (0, _jsxRuntime.jsxs)(_index.Box, {
|
|
29
|
+
sx: {
|
|
30
|
+
backgroundColor: 'toolbar.background',
|
|
31
|
+
boxShadow: 'none',
|
|
32
|
+
gap: 4
|
|
33
|
+
},
|
|
34
|
+
children: [(0, _jsxRuntime.jsx)(_index.Flex, {
|
|
35
|
+
sx: {
|
|
36
|
+
flexWrap: 'wrap',
|
|
37
|
+
height: 64,
|
|
38
|
+
width: '100%',
|
|
39
|
+
py: 0,
|
|
40
|
+
px: 5,
|
|
41
|
+
gap: 7,
|
|
42
|
+
alignItems: 'center'
|
|
43
|
+
},
|
|
44
|
+
children: (0, _jsxRuntime.jsx)(_Logo.Logo, {})
|
|
45
|
+
}), (0, _jsxRuntime.jsx)("div", {
|
|
46
|
+
sx: {
|
|
47
|
+
overflowX: 'hidden',
|
|
48
|
+
overflowY: 'auto',
|
|
49
|
+
height: 'calc(100vh - 64px)',
|
|
50
|
+
display: 'flex',
|
|
51
|
+
flex: 1
|
|
52
|
+
},
|
|
53
|
+
children: (0, _jsxRuntime.jsxs)(_index.Flex, {
|
|
54
|
+
sx: {
|
|
55
|
+
width: '100%',
|
|
56
|
+
flexDirection: 'column'
|
|
57
|
+
},
|
|
58
|
+
children: [toolbarItems && (0, _jsxRuntime.jsx)(_index.Nav.Primary, {
|
|
59
|
+
label: "Main Links",
|
|
60
|
+
orientation: "vertical",
|
|
61
|
+
children: toolbarItems
|
|
62
|
+
}), (0, _jsxRuntime.jsx)(_index.Box, {
|
|
63
|
+
sx: {
|
|
64
|
+
alignSelf: 'stretch',
|
|
65
|
+
backgroundColor: 'layer.1',
|
|
66
|
+
minHeight: "calc(100vh - 64px)",
|
|
67
|
+
gap: 4,
|
|
68
|
+
width: '100%',
|
|
69
|
+
a: {
|
|
70
|
+
border: 'none'
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
children: children
|
|
74
|
+
})]
|
|
75
|
+
})
|
|
76
|
+
})]
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
var MobileMenuWrapper = exports.MobileMenuWrapper = function MobileMenuWrapper(_ref2) {
|
|
81
|
+
var children = _ref2.children;
|
|
82
|
+
return (0, _jsxRuntime.jsx)(Drawer.Root, {
|
|
83
|
+
children: children
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
var MobileMenuTrigger = exports.MobileMenuTrigger = function MobileMenuTrigger(_ref3) {
|
|
87
|
+
var _ref3$label = _ref3.label,
|
|
88
|
+
label = _ref3$label === void 0 ? 'Menu' : _ref3$label,
|
|
89
|
+
_ref3$variant = _ref3.variant,
|
|
90
|
+
variant = _ref3$variant === void 0 ? 'primary' : _ref3$variant,
|
|
91
|
+
_ref3$display = _ref3.display,
|
|
92
|
+
display = _ref3$display === void 0 ? ['none', 'flex', 'flex', 'none'] : _ref3$display;
|
|
93
|
+
return (0, _jsxRuntime.jsx)(Drawer.Trigger, {
|
|
94
|
+
children: (0, _jsxRuntime.jsx)(_index.Button, {
|
|
95
|
+
type: "button",
|
|
96
|
+
variant: "tertiary",
|
|
97
|
+
sx: {
|
|
98
|
+
display: display,
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
color: variant === 'inverse' ? 'button.primary.label.default' : 'button.tertiary.label.default',
|
|
101
|
+
width: 38,
|
|
102
|
+
height: 38,
|
|
103
|
+
p: 0
|
|
104
|
+
},
|
|
105
|
+
"aria-label": label,
|
|
106
|
+
children: (0, _jsxRuntime.jsx)(_bi.BiMenu, {
|
|
107
|
+
size: 16,
|
|
108
|
+
role: "presentation"
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
import { MobileMenu } from './MobileMenu';
|
|
4
|
+
import type { StoryObj } from '@storybook/react';
|
|
5
|
+
declare const _default: {
|
|
6
|
+
title: string;
|
|
7
|
+
component: import("react").ForwardRefExoticComponent<import("./MobileMenu").MobileMenuProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
17
|
+
type Story = StoryObj<typeof MobileMenu>;
|
|
18
|
+
export declare const MobileMenuExample: () => import("react").JSX.Element;
|
|
19
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.MobileMenuExample = exports.Default = void 0;
|
|
5
|
+
var _ai = require("react-icons/ai");
|
|
6
|
+
var _bi = require("react-icons/bi");
|
|
7
|
+
var _md = require("react-icons/md");
|
|
8
|
+
var _MobileMenu = require("./MobileMenu");
|
|
9
|
+
var _ = require("..");
|
|
10
|
+
var _CustomLink = require("../utils/stories/CustomLink");
|
|
11
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
12
|
+
/** @jsxImportSource theme-ui */
|
|
13
|
+
var _default = exports["default"] = {
|
|
14
|
+
title: 'Navigation/MobileMenu',
|
|
15
|
+
component: _MobileMenu.MobileMenu,
|
|
16
|
+
parameters: {
|
|
17
|
+
docs: {
|
|
18
|
+
description: {
|
|
19
|
+
component: "\nThe MobileMenu component is a navigation component that is hidden by default and can be toggled open and closed. It opens a panel that can contain any content. The base of this component is a Drawer.\n\n## Guidance\n\n### When to use the Drawer component\n\n- Use the MobileMenu component to displaying a drawer with mobile content.\n\n### When to consider something else\n\n- If you need something that is not a menu on a mobile view, consider using another component.\n\n## Accessibility Considerations guidance\n\n- The MobileMenu is based on the Drawer component and inherits all of its accessibility considerations.\n\n## Using the component\n\n- Look at the examples below to see how the MobileMenu component is used.\n- You can use the `toolbarItems` prop to pass the content that will be in the header\n- You can pass `display` prop to the MobileMenuTrigger to control the display of the trigger. The array must match the ThemeUI breakpoints.\n\n## Component Properties\n"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var MobileMenuExample = exports.MobileMenuExample = function MobileMenuExample() {
|
|
25
|
+
return (0, _jsxRuntime.jsxs)(_MobileMenu.MobileMenuWrapper, {
|
|
26
|
+
children: [(0, _jsxRuntime.jsx)(_MobileMenu.MobileMenuTrigger, {
|
|
27
|
+
label: "Menu",
|
|
28
|
+
variant: "primary",
|
|
29
|
+
display: ['flex', 'flex', 'flex']
|
|
30
|
+
}), (0, _jsxRuntime.jsx)(_MobileMenu.MobileMenu, {
|
|
31
|
+
toolbarItems: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
32
|
+
children: [(0, _jsxRuntime.jsx)(_.NavItem.MenuInverse, {
|
|
33
|
+
href: "/apps",
|
|
34
|
+
active: true,
|
|
35
|
+
as: _CustomLink.CustomLink,
|
|
36
|
+
children: "My Applications"
|
|
37
|
+
}), (0, _jsxRuntime.jsx)(_.NavItem.MenuInverse, {
|
|
38
|
+
href: "/orgs",
|
|
39
|
+
as: _CustomLink.CustomLink,
|
|
40
|
+
children: "My Organizations"
|
|
41
|
+
})]
|
|
42
|
+
}),
|
|
43
|
+
children: (0, _jsxRuntime.jsxs)(_.Nav.Menu, {
|
|
44
|
+
sx: {
|
|
45
|
+
mb: 4
|
|
46
|
+
},
|
|
47
|
+
label: "Nav Menu",
|
|
48
|
+
children: [(0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
49
|
+
href: "https://wordpress.com",
|
|
50
|
+
renderIcon: function renderIcon(size) {
|
|
51
|
+
return (0, _jsxRuntime.jsx)(_bi.BiGridAlt, {
|
|
52
|
+
size: size
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
as: _CustomLink.CustomLink,
|
|
56
|
+
children: "Overview"
|
|
57
|
+
}), (0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
58
|
+
as: _CustomLink.CustomLink,
|
|
59
|
+
href: "https://random-website.com/",
|
|
60
|
+
renderIcon: function renderIcon(size) {
|
|
61
|
+
return (0, _jsxRuntime.jsx)(_bi.BiWindows, {
|
|
62
|
+
size: size
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
children: "Network Sites"
|
|
66
|
+
}), (0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
67
|
+
as: _CustomLink.CustomLink,
|
|
68
|
+
href: "https://random-website.com/",
|
|
69
|
+
renderIcon: function renderIcon(size) {
|
|
70
|
+
return (0, _jsxRuntime.jsx)(_ai.AiOutlineLock, {
|
|
71
|
+
size: size
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
children: "Domains & TLS"
|
|
75
|
+
}), (0, _jsxRuntime.jsxs)(_.NavItem.MenuGroup, {
|
|
76
|
+
active: true,
|
|
77
|
+
label: "Logs",
|
|
78
|
+
renderIcon: function renderIcon(size) {
|
|
79
|
+
return (0, _jsxRuntime.jsx)(_bi.BiHistory, {
|
|
80
|
+
size: size
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
children: [(0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
84
|
+
as: _CustomLink.CustomLink,
|
|
85
|
+
href: "https://google.com/",
|
|
86
|
+
children: "Audit"
|
|
87
|
+
}), (0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
88
|
+
active: true,
|
|
89
|
+
as: _CustomLink.CustomLink,
|
|
90
|
+
href: "https://wpvip.com/",
|
|
91
|
+
children: "Runtime"
|
|
92
|
+
}), (0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
93
|
+
as: _CustomLink.CustomLink,
|
|
94
|
+
href: "https://dashboard.wpvip.com/",
|
|
95
|
+
children: "Slow Query"
|
|
96
|
+
})]
|
|
97
|
+
}), (0, _jsxRuntime.jsxs)(_.NavItem.MenuGroup, {
|
|
98
|
+
label: "Performance",
|
|
99
|
+
renderIcon: function renderIcon(size) {
|
|
100
|
+
return (0, _jsxRuntime.jsx)(_bi.BiTachometer, {
|
|
101
|
+
size: size
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
children: [(0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
105
|
+
as: _CustomLink.CustomLink,
|
|
106
|
+
href: "https://random-website.com/",
|
|
107
|
+
children: "Metrics"
|
|
108
|
+
}), (0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
109
|
+
as: _CustomLink.CustomLink,
|
|
110
|
+
href: "https://random-website.com/",
|
|
111
|
+
children: "Monitor"
|
|
112
|
+
}), (0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
113
|
+
as: _CustomLink.CustomLink,
|
|
114
|
+
href: "https://random-website.com/",
|
|
115
|
+
children: "Cache"
|
|
116
|
+
})]
|
|
117
|
+
}), (0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
118
|
+
as: _CustomLink.CustomLink,
|
|
119
|
+
href: "https://random-website.com/",
|
|
120
|
+
renderIcon: function renderIcon(size) {
|
|
121
|
+
return (0, _jsxRuntime.jsx)(_bi.BiCodeAlt, {
|
|
122
|
+
size: size
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
children: "Code [v]"
|
|
126
|
+
}), (0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
127
|
+
as: _CustomLink.CustomLink,
|
|
128
|
+
href: "https://random-website.com/",
|
|
129
|
+
renderIcon: function renderIcon(size) {
|
|
130
|
+
return (0, _jsxRuntime.jsx)(_bi.BiData, {
|
|
131
|
+
size: size
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
children: "Database [v]"
|
|
135
|
+
}), (0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
136
|
+
as: _CustomLink.CustomLink,
|
|
137
|
+
href: "https://random-website.com/",
|
|
138
|
+
renderIcon: function renderIcon(size) {
|
|
139
|
+
return (0, _jsxRuntime.jsx)(_md.MdOutlinePhotoLibrary, {
|
|
140
|
+
size: size
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
children: "Media [v]"
|
|
144
|
+
}), (0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
145
|
+
as: _CustomLink.CustomLink,
|
|
146
|
+
href: "https://random-website.com/",
|
|
147
|
+
renderIcon: function renderIcon(size) {
|
|
148
|
+
return (0, _jsxRuntime.jsx)(_bi.BiBell, {
|
|
149
|
+
size: size
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
children: "Notifications"
|
|
153
|
+
}), (0, _jsxRuntime.jsx)(_.NavItem.Menu, {
|
|
154
|
+
as: _CustomLink.CustomLink,
|
|
155
|
+
href: "https://random-website.com/",
|
|
156
|
+
renderIcon: function renderIcon(size) {
|
|
157
|
+
return (0, _jsxRuntime.jsx)(_bi.BiBulb, {
|
|
158
|
+
size: size
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
children: "Features"
|
|
162
|
+
})]
|
|
163
|
+
})
|
|
164
|
+
})]
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
var Default = exports.Default = {
|
|
168
|
+
render: function render() {
|
|
169
|
+
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
170
|
+
children: (0, _jsxRuntime.jsx)(MobileMenuExample, {})
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
4
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
5
|
+
var _jestAxe = require("jest-axe");
|
|
6
|
+
var _themeUi = require("theme-ui");
|
|
7
|
+
var _MobileMenu = require("./MobileMenu.stories");
|
|
8
|
+
var _ = require("../");
|
|
9
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
+
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; }
|
|
12
|
+
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); } }
|
|
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); }); }; } /* eslint-disable @typescript-eslint/ban-ts-comment */ // @ts-nocheck
|
|
14
|
+
/** @jsxImportSource theme-ui */
|
|
15
|
+
var renderWithTheme = function renderWithTheme(children) {
|
|
16
|
+
return (0, _react.render)((0, _jsxRuntime.jsx)(_themeUi.ThemeUIProvider, {
|
|
17
|
+
theme: _.theme,
|
|
18
|
+
children: children
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
var renderComponent = function renderComponent() {
|
|
22
|
+
return renderWithTheme((0, _jsxRuntime.jsx)(_MobileMenu.MobileMenuExample, {}));
|
|
23
|
+
};
|
|
24
|
+
function getMenuTrigger() {
|
|
25
|
+
return _react.screen.getByRole('button', {
|
|
26
|
+
name: 'Menu'
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
describe('<MobileMenu />', function () {
|
|
30
|
+
it('renders the MobileMenu trigger', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
31
|
+
var _renderComponent, container;
|
|
32
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
33
|
+
while (1) switch (_context.prev = _context.next) {
|
|
34
|
+
case 0:
|
|
35
|
+
_renderComponent = renderComponent(), container = _renderComponent.container; // Should find the trigger
|
|
36
|
+
expect(getMenuTrigger()).toBeInTheDocument();
|
|
37
|
+
expect(getMenuTrigger()).toHaveAttribute('data-state', 'closed');
|
|
38
|
+
|
|
39
|
+
// Check for accessibility issues
|
|
40
|
+
_context.t0 = expect;
|
|
41
|
+
_context.next = 6;
|
|
42
|
+
return (0, _jestAxe.axe)(container);
|
|
43
|
+
case 6:
|
|
44
|
+
_context.t1 = _context.sent;
|
|
45
|
+
(0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
46
|
+
case 8:
|
|
47
|
+
case "end":
|
|
48
|
+
return _context.stop();
|
|
49
|
+
}
|
|
50
|
+
}, _callee);
|
|
51
|
+
})));
|
|
52
|
+
it('opens MobileMenu and check for items', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
53
|
+
var user, _renderComponent2, container;
|
|
54
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
55
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
56
|
+
case 0:
|
|
57
|
+
user = _userEvent["default"].setup();
|
|
58
|
+
_renderComponent2 = renderComponent(), container = _renderComponent2.container;
|
|
59
|
+
_context2.next = 4;
|
|
60
|
+
return user.click(getMenuTrigger());
|
|
61
|
+
case 4:
|
|
62
|
+
// Should find the open content
|
|
63
|
+
expect(_react.screen.getByText('My Applications')).toBeVisible(); // First menu
|
|
64
|
+
expect(_react.screen.getByText('My Organizations')).toBeVisible();
|
|
65
|
+
expect(_react.screen.getByText('Performance')).toBeVisible();
|
|
66
|
+
expect(_react.screen.getByText('Features')).toBeVisible(); // Last Menu
|
|
67
|
+
|
|
68
|
+
// Check for accessibility issues
|
|
69
|
+
_context2.t0 = expect;
|
|
70
|
+
_context2.next = 11;
|
|
71
|
+
return (0, _jestAxe.axe)(container);
|
|
72
|
+
case 11:
|
|
73
|
+
_context2.t1 = _context2.sent;
|
|
74
|
+
(0, _context2.t0)(_context2.t1).toHaveNoViolations();
|
|
75
|
+
case 13:
|
|
76
|
+
case "end":
|
|
77
|
+
return _context2.stop();
|
|
78
|
+
}
|
|
79
|
+
}, _callee2);
|
|
80
|
+
})));
|
|
81
|
+
});
|
|
@@ -70,10 +70,7 @@ var NavLink = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
|
70
70
|
var children = _ref3.children,
|
|
71
71
|
_ref3$as = _ref3.as,
|
|
72
72
|
LinkComponent = _ref3$as === void 0 ? NavRawLink : _ref3$as,
|
|
73
|
-
|
|
74
|
-
renderIcon = _ref3$renderIcon === void 0 ? function () {
|
|
75
|
-
return null;
|
|
76
|
-
} : _ref3$renderIcon,
|
|
73
|
+
renderIcon = _ref3.renderIcon,
|
|
77
74
|
href = _ref3.href,
|
|
78
75
|
active = _ref3.active,
|
|
79
76
|
disabled = _ref3.disabled,
|
|
@@ -93,7 +90,9 @@ var NavLink = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
|
93
90
|
asChild: true
|
|
94
91
|
}, rest, {
|
|
95
92
|
children: (0, _jsxRuntime.jsxs)(LinkComponent, {
|
|
96
|
-
children: [renderIcon(
|
|
93
|
+
children: [renderIcon ? (0, _jsxRuntime.jsx)(_NavItemGroup.IconContainer, {
|
|
94
|
+
children: renderIcon(NAV_ITEM_ICON_SIZE)
|
|
95
|
+
}) : null, children]
|
|
97
96
|
})
|
|
98
97
|
}));
|
|
99
98
|
});
|
|
@@ -5,4 +5,7 @@ export interface NavItemGroupProps extends NavItemBaseProps {
|
|
|
5
5
|
renderIcon?: NavItemRenderIconProp;
|
|
6
6
|
label: string;
|
|
7
7
|
}
|
|
8
|
+
export declare const IconContainer: ({ children }: {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}) => import("react").JSX.Element;
|
|
8
11
|
export declare const ItemGroupMenu: import("react").ForwardRefExoticComponent<NavItemGroupProps & import("react").RefAttributes<HTMLLIElement>>;
|