@automattic/vip-design-system 2.1.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.
Files changed (101) hide show
  1. package/.eslintrc.js +3 -0
  2. package/build/system/Accordion/Accordion.test.d.ts +0 -1
  3. package/build/system/Accordion/Accordion.test.js +23 -12
  4. package/build/system/Avatar/Avatar.d.ts +0 -1
  5. package/build/system/Avatar/Avatar.js +9 -17
  6. package/build/system/Avatar/Avatar.stories.d.ts +2 -1
  7. package/build/system/Avatar/Avatar.stories.js +19 -2
  8. package/build/system/Button/Button.d.ts +2 -0
  9. package/build/system/Button/Button.js +6 -15
  10. package/build/system/Button/Button.stories.js +86 -67
  11. package/build/system/Card/Card.js +1 -2
  12. package/build/system/Drawer/Drawer.d.ts +12 -3
  13. package/build/system/Drawer/Drawer.js +8 -9
  14. package/build/system/Drawer/Drawer.stories.d.ts +0 -1
  15. package/build/system/Drawer/Drawer.stories.js +19 -225
  16. package/build/system/Drawer/styles.d.ts +2 -2
  17. package/build/system/Drawer/styles.js +13 -9
  18. package/build/system/Form/Checkbox/Checkbox.js +0 -3
  19. package/build/system/Form/Checkbox/Checkbox.stories.js +2 -2
  20. package/build/system/Form/Checkbox/styles.js +16 -11
  21. package/build/system/Form/Radio/Radio.stories.js +1 -1
  22. package/build/system/Form/Toggle.d.ts +14 -2
  23. package/build/system/Form/Toggle.js +68 -69
  24. package/build/system/Form/Toggle.stories.d.ts +29 -18
  25. package/build/system/Form/Toggle.stories.js +99 -0
  26. package/build/system/Form/Toggle.test.js +36 -19
  27. package/build/system/Link/Link.d.ts +1 -1
  28. package/build/system/Link/Link.js +5 -20
  29. package/build/system/Link/Link.stories.d.ts +3 -1
  30. package/build/system/Link/Link.stories.js +18 -1
  31. package/build/system/MobileMenu/MobileMenu.d.ts +16 -0
  32. package/build/system/MobileMenu/MobileMenu.js +112 -0
  33. package/build/system/MobileMenu/MobileMenu.stories.d.ts +19 -0
  34. package/build/system/MobileMenu/MobileMenu.stories.js +173 -0
  35. package/build/system/MobileMenu/MobileMenu.test.d.ts +1 -0
  36. package/build/system/MobileMenu/MobileMenu.test.js +81 -0
  37. package/build/system/Nav/NavItem.js +4 -5
  38. package/build/system/Nav/NavItemGroup.d.ts +3 -0
  39. package/build/system/Nav/NavItemGroup.js +18 -6
  40. package/build/system/Nav/styles/variants/menu.js +15 -9
  41. package/build/system/Nav/styles/variants/menugroup.js +9 -5
  42. package/build/system/Nav/styles/variants/toolbar.js +1 -2
  43. package/build/system/Nav/styles.js +1 -0
  44. package/build/system/NewDialog/DialogClose.d.ts +7 -2
  45. package/build/system/NewDialog/DialogClose.js +25 -15
  46. package/build/system/NewDialog/index.d.ts +2 -1
  47. package/build/system/NewDialog/index.js +2 -1
  48. package/build/system/NewForm/FormAutocomplete.css +1 -3
  49. package/build/system/Table/Table.js +1 -0
  50. package/build/system/Toolbar/Toolbar.js +1 -1
  51. package/build/system/Toolbar/Toolbar.stories.d.ts +3 -0
  52. package/build/system/Toolbar/Toolbar.stories.js +62 -6
  53. package/build/system/Toolbar/ToolbarUtilNav.d.ts +3 -0
  54. package/build/system/Toolbar/ToolbarUtilNav.js +21 -3
  55. package/build/system/Toolbar/index.d.ts +3 -0
  56. package/build/system/Toolbar/index.js +2 -1
  57. package/build/system/index.d.ts +4 -1
  58. package/build/system/index.js +4 -0
  59. package/build/system/theme/index.d.ts +70 -35
  60. package/build/system/theme/index.js +47 -18
  61. package/package.json +2 -1
  62. package/src/system/Accordion/Accordion.test.tsx +15 -8
  63. package/src/system/Avatar/Avatar.stories.tsx +15 -1
  64. package/src/system/Avatar/Avatar.tsx +8 -12
  65. package/src/system/Button/Button.stories.tsx +40 -31
  66. package/src/system/Button/Button.tsx +6 -15
  67. package/src/system/Card/Card.tsx +0 -1
  68. package/src/system/Drawer/Drawer.stories.tsx +28 -197
  69. package/src/system/Drawer/Drawer.tsx +31 -18
  70. package/src/system/Drawer/styles.ts +15 -5
  71. package/src/system/Form/Checkbox/Checkbox.stories.tsx +2 -2
  72. package/src/system/Form/Checkbox/Checkbox.tsx +0 -3
  73. package/src/system/Form/Checkbox/styles.ts +57 -46
  74. package/src/system/Form/Radio/Radio.stories.tsx +1 -1
  75. package/src/system/Form/Toggle.stories.tsx +122 -0
  76. package/src/system/Form/{Toggle.test.js → Toggle.test.tsx} +1 -1
  77. package/src/system/Form/Toggle.tsx +77 -0
  78. package/src/system/Link/Link.stories.tsx +21 -0
  79. package/src/system/Link/Link.tsx +10 -17
  80. package/src/system/MobileMenu/MobileMenu.stories.tsx +171 -0
  81. package/src/system/MobileMenu/MobileMenu.test.tsx +50 -0
  82. package/src/system/MobileMenu/MobileMenu.tsx +116 -0
  83. package/src/system/Nav/NavItem.tsx +3 -3
  84. package/src/system/Nav/NavItemGroup.tsx +18 -2
  85. package/src/system/Nav/styles/variants/menu.ts +15 -9
  86. package/src/system/Nav/styles/variants/menugroup.ts +7 -3
  87. package/src/system/Nav/styles/variants/toolbar.ts +1 -2
  88. package/src/system/Nav/styles.ts +1 -0
  89. package/src/system/NewDialog/DialogClose.tsx +36 -23
  90. package/src/system/NewDialog/index.ts +3 -2
  91. package/src/system/NewForm/FormAutocomplete.css +1 -3
  92. package/src/system/Table/Table.tsx +1 -1
  93. package/src/system/Toolbar/Toolbar.stories.tsx +50 -3
  94. package/src/system/Toolbar/Toolbar.tsx +1 -1
  95. package/src/system/Toolbar/ToolbarUtilNav.tsx +19 -2
  96. package/src/system/Toolbar/index.tsx +6 -1
  97. package/src/system/index.js +4 -0
  98. package/src/system/theme/index.js +47 -18
  99. package/build/system/Form/Toggle.stories.jsx +0 -96
  100. package/src/system/Form/Toggle.js +0 -74
  101. package/src/system/Form/Toggle.stories.jsx +0 -96
@@ -1,19 +1,30 @@
1
- declare namespace _default {
2
- export let title: string;
3
- export { Toggle as component };
4
- export namespace argTypes {
5
- namespace checked {
6
- export let options: boolean[];
7
- let _default: boolean;
8
- export { _default as default };
9
- export namespace control {
10
- let type: string;
11
- }
12
- }
13
- }
14
- }
15
- export default _default;
16
- export function Primary(args: any): import("react").JSX.Element;
17
- export function ExternalLabel(args: any): import("react").JSX.Element;
18
- export function CustomStyle(args: any): import("react").JSX.Element;
1
+ /// <reference types="react" />
2
+ /** @jsxImportSource theme-ui */
3
+ import { StoryObj } from '@storybook/react';
19
4
  import { Toggle } from '..';
5
+ declare const _default: {
6
+ title: string;
7
+ component: {
8
+ ({ name, onChange, className, variant, ...rest }: import("./Toggle").ToggleProps): import("react").JSX.Element;
9
+ displayName: string;
10
+ };
11
+ argTypes: {
12
+ checked: {
13
+ control: {
14
+ type: string;
15
+ };
16
+ };
17
+ };
18
+ parameters: {
19
+ docs: {
20
+ description: {
21
+ component: string;
22
+ };
23
+ };
24
+ };
25
+ };
26
+ export default _default;
27
+ type Story = StoryObj<typeof Toggle>;
28
+ export declare const Default: Story;
29
+ export declare const WithLabel: Story;
30
+ export declare const CustomStyling: Story;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = exports.WithLabel = exports.Default = exports.CustomStyling = void 0;
5
+ var _ = require("..");
6
+ var _jsxRuntime = require("theme-ui/jsx-runtime");
7
+ /** @jsxImportSource theme-ui */
8
+ var _default = exports["default"] = {
9
+ title: 'Toggle',
10
+ component: _.Toggle,
11
+ argTypes: {
12
+ checked: {
13
+ control: {
14
+ type: 'boolean'
15
+ }
16
+ }
17
+ },
18
+ parameters: {
19
+ docs: {
20
+ description: {
21
+ component: "\nThe Toggle component is two-state switch that can be toggled on or off. It is used to activate or deactivate a feature.\n\n## Guidance\n\n### When to use the Toggle component\n\n- Use the Toggle component to allow users to switch between two states, such as on/off, true/false, or yes/no.\n\n### When to consider something else\n\n- If you need to select from more than two states, use a [Radio](/docs/radio--docs), or a [Select](/docs/form-select--docs) component instead.\n\n## Accessibility Considerations guidance\n\n- The Toggle component is based on the Radix Toggle primitive, so it contains all the accessibility features from the primitive.\n\n## Using the component\n\n- Available variants: Primary, Success, Disabled.\n\n## Component Properties\n"
22
+ }
23
+ }
24
+ }
25
+ };
26
+ var Default = exports.Default = {
27
+ render: function render(args) {
28
+ return (0, _jsxRuntime.jsxs)("form", {
29
+ children: [(0, _jsxRuntime.jsx)(_.Toggle, {
30
+ checked: args.checked,
31
+ defaultChecked: true,
32
+ "aria-label": "Feature flag"
33
+ }), (0, _jsxRuntime.jsx)("br", {}), (0, _jsxRuntime.jsx)("br", {}), (0, _jsxRuntime.jsx)(_.Toggle, {
34
+ checked: args.checked,
35
+ defaultChecked: false,
36
+ "aria-label": "Feature flag 2"
37
+ }), (0, _jsxRuntime.jsx)("br", {}), (0, _jsxRuntime.jsx)("br", {}), (0, _jsxRuntime.jsx)(_.Toggle, {
38
+ "aria-label": "Feature Disabled",
39
+ disabled: true,
40
+ defaultChecked: false
41
+ })]
42
+ });
43
+ }
44
+ };
45
+ var WithLabel = exports.WithLabel = {
46
+ render: function render(args) {
47
+ return (0, _jsxRuntime.jsxs)("form", {
48
+ children: [(0, _jsxRuntime.jsx)(_.Label, {
49
+ htmlFor: "custom-label-input",
50
+ children: "Custom Label here"
51
+ }), (0, _jsxRuntime.jsx)(_.Toggle, {
52
+ id: "custom-label-input",
53
+ defaultChecked: true,
54
+ checked: args.checked,
55
+ "aria-label": "Feature flag"
56
+ })]
57
+ });
58
+ }
59
+ };
60
+ var CustomStyling = exports.CustomStyling = {
61
+ render: function render(args) {
62
+ return (0, _jsxRuntime.jsxs)("form", {
63
+ children: [(0, _jsxRuntime.jsxs)(_.Label, {
64
+ htmlFor: "custom-label-input",
65
+ children: ["Custom Styling.", ' ', (0, _jsxRuntime.jsx)("strong", {
66
+ children: "We currently only recommend using Primary, Disabled, and Success variants."
67
+ })]
68
+ }), (0, _jsxRuntime.jsxs)("div", {
69
+ children: [(0, _jsxRuntime.jsx)(_.Toggle, {
70
+ id: "custom-label-input",
71
+ defaultChecked: true,
72
+ checked: args.checked,
73
+ "aria-label": "Feature flag",
74
+ variant: "success"
75
+ }), ' ', (0, _jsxRuntime.jsx)("h2", {
76
+ children: "Not recommended"
77
+ }), (0, _jsxRuntime.jsx)(_.Toggle, {
78
+ id: "custom-label-input-error",
79
+ defaultChecked: true,
80
+ checked: args.checked,
81
+ "aria-label": "Error flag",
82
+ variant: "error"
83
+ }), ' ', (0, _jsxRuntime.jsx)(_.Toggle, {
84
+ id: "custom-label-input-warning",
85
+ defaultChecked: true,
86
+ checked: args.checked,
87
+ "aria-label": "Warning flag",
88
+ variant: "warning"
89
+ }), ' ', (0, _jsxRuntime.jsx)(_.Toggle, {
90
+ id: "custom-label-input-info",
91
+ defaultChecked: true,
92
+ checked: args.checked,
93
+ "aria-label": "info flag",
94
+ variant: "info"
95
+ })]
96
+ })]
97
+ });
98
+ }
99
+ };
@@ -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
- import { Toggle } from './Toggle';
11
-
12
- describe( '<Toggle />', () => {
13
- it( 'renders the Toggle component', async () => {
14
- const { container } = render(
15
- <Toggle aria-label="Dinner room Light" defaultChecked name="my-toggle" />
16
- );
17
-
18
- expect( screen.getByRole( 'switch' ) ).toBeInTheDocument();
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
- // Check for accessibility issues
21
- await expect( await axe( container ) ).toHaveNoViolations();
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
- active?: boolean;
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 = ["active", "sx"];
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$active = _ref.active,
36
- active = _ref$active === void 0 ? false : _ref$active,
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
- sx: _extends({}, defaultLinkComponentStyle, {
41
- color: active ? 'links.active' : 'link'
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<import("./Link").LinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
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 {};