@automattic/vip-design-system 2.18.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/preview-head.html +1 -0
- package/build/system/Badge/Badge.js +2 -1
- package/build/system/DescriptionList/DescriptionList.js +0 -1
- package/build/system/Form/Label.d.ts +1 -3
- package/build/system/Form/Label.js +1 -3
- package/build/system/Form/RadioBoxGroup.jsx +12 -1
- package/build/system/Form/RadioBoxGroup.stories.jsx +6 -1
- package/build/system/Heading/Heading.js +2 -3
- package/build/system/Heading/Heading.stories.js +15 -2
- package/build/system/Nav/styles/variants/menu.js +1 -2
- package/build/system/Notice/Notice.js +1 -1
- package/build/system/Pagination/Pagination.d.ts +10 -20
- package/build/system/Pagination/Pagination.js +50 -68
- package/build/system/Pagination/Pagination.stories.js +13 -11
- package/build/system/Pagination/Pagination.test.js +4 -4
- package/build/system/Pagination/PaginationLayout.d.ts +27 -0
- package/build/system/Pagination/PaginationLayout.js +63 -0
- package/build/system/Pagination/SimplePagination.d.ts +26 -0
- package/build/system/Pagination/SimplePagination.js +76 -0
- package/build/system/Pagination/SimplePagination.stories.d.ts +13 -0
- package/build/system/Pagination/SimplePagination.stories.js +130 -0
- package/build/system/Pagination/SimplePagination.test.d.ts +2 -0
- package/build/system/Pagination/SimplePagination.test.js +171 -0
- package/build/system/Pagination/index.d.ts +3 -1
- package/build/system/Pagination/index.js +2 -1
- package/build/system/Pagination/styles.js +1 -4
- package/build/system/Table/TableCell.js +1 -1
- package/build/system/Text/Text.js +0 -1
- package/build/system/Text/Text.stories.js +16 -13
- package/build/system/Toolbar/Logo.js +22 -6
- package/build/system/Wizard/Wizard.stories.js +11 -11
- package/build/system/Wizard/WizardStep.js +0 -2
- package/build/system/index.d.ts +2 -2
- package/build/system/index.js +2 -2
- package/build/system/theme/generated/valet-theme-dark.json +224 -227
- package/build/system/theme/generated/valet-theme-light.json +224 -227
- package/build/system/theme/getPropValue.js +3 -7
- package/build/system/theme/index.d.ts +20 -12
- package/build/system/theme/index.js +27 -20
- package/docs/SETUP.md +1 -1
- package/package.json +1 -1
- package/src/system/Badge/Badge.tsx +2 -1
- package/src/system/DescriptionList/DescriptionList.tsx +0 -1
- package/src/system/Form/Label.tsx +1 -3
- package/src/system/Form/RadioBoxGroup.jsx +12 -1
- package/src/system/Form/RadioBoxGroup.stories.jsx +6 -1
- package/src/system/Heading/Heading.stories.tsx +10 -1
- package/src/system/Heading/Heading.tsx +1 -2
- package/src/system/Nav/styles/variants/menu.ts +1 -2
- package/src/system/Notice/Notice.tsx +1 -1
- package/src/system/Pagination/Pagination.stories.tsx +13 -10
- package/src/system/Pagination/Pagination.test.tsx +4 -6
- package/src/system/Pagination/Pagination.tsx +36 -71
- package/src/system/Pagination/PaginationLayout.tsx +93 -0
- package/src/system/Pagination/SimplePagination.stories.tsx +127 -0
- package/src/system/Pagination/SimplePagination.test.tsx +120 -0
- package/src/system/Pagination/SimplePagination.tsx +97 -0
- package/src/system/Pagination/index.ts +3 -1
- package/src/system/Pagination/styles.ts +1 -4
- package/src/system/Table/TableCell.tsx +1 -1
- package/src/system/Text/Text.stories.tsx +7 -4
- package/src/system/Text/Text.tsx +0 -1
- package/src/system/Toolbar/Logo.tsx +19 -2
- package/src/system/Wizard/Wizard.stories.tsx +11 -11
- package/src/system/Wizard/WizardStep.tsx +0 -2
- package/src/system/index.ts +2 -1
- package/src/system/theme/generated/valet-theme-dark.json +224 -227
- package/src/system/theme/generated/valet-theme-light.json +224 -227
- package/src/system/theme/getPropValue.ts +1 -8
- package/src/system/theme/index.ts +33 -18
- package/tokens/valet-core/valet-core.json +39 -9
- package/tokens/valet-core/wpvip-product-core.json +88 -125
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var _excluded = ["hasNextPage", "hasPreviousPage", "nextParam", "previousParam", "onNavigate", "displayItemsPerPageSelector", "itemsPerPage", "pageSizeOptions", "onItemsPerPageChange", "className", "sx", "children"];
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
+
/** @jsxImportSource theme-ui */
|
|
5
|
+
|
|
6
|
+
import { forwardRef } from 'react';
|
|
7
|
+
import { MdChevronLeft, MdChevronRight } from 'react-icons/md';
|
|
8
|
+
import { Flex } from 'theme-ui';
|
|
9
|
+
import { PaginationLayout } from './PaginationLayout';
|
|
10
|
+
import { navigationStyles, arrowButtonStyles } from './styles';
|
|
11
|
+
import { Box } from '../Box';
|
|
12
|
+
import { Button } from '../Button';
|
|
13
|
+
|
|
14
|
+
/** A navigation parameter for SimplePagination. */
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
16
|
+
/**
|
|
17
|
+
* A pagination control with only previous/next arrow buttons.
|
|
18
|
+
* Designed for cursor-based pagination APIs with custom param names (e.g., `after`/`before`).
|
|
19
|
+
*/
|
|
20
|
+
export var SimplePagination = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
21
|
+
var hasNextPage = _ref.hasNextPage,
|
|
22
|
+
hasPreviousPage = _ref.hasPreviousPage,
|
|
23
|
+
nextParam = _ref.nextParam,
|
|
24
|
+
previousParam = _ref.previousParam,
|
|
25
|
+
onNavigate = _ref.onNavigate,
|
|
26
|
+
displayItemsPerPageSelector = _ref.displayItemsPerPageSelector,
|
|
27
|
+
itemsPerPage = _ref.itemsPerPage,
|
|
28
|
+
pageSizeOptions = _ref.pageSizeOptions,
|
|
29
|
+
onItemsPerPageChange = _ref.onItemsPerPageChange,
|
|
30
|
+
className = _ref.className,
|
|
31
|
+
sx = _ref.sx,
|
|
32
|
+
children = _ref.children,
|
|
33
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
34
|
+
var isPrevDisabled = !hasPreviousPage || !(previousParam != null && previousParam.value);
|
|
35
|
+
var isNextDisabled = !hasNextPage || !(nextParam != null && nextParam.value);
|
|
36
|
+
return _jsxs(PaginationLayout, _extends({
|
|
37
|
+
ref: ref,
|
|
38
|
+
displayItemsPerPageSelector: displayItemsPerPageSelector,
|
|
39
|
+
itemsPerPage: itemsPerPage,
|
|
40
|
+
pageSizeOptions: pageSizeOptions,
|
|
41
|
+
onItemsPerPageChange: onItemsPerPageChange,
|
|
42
|
+
className: className,
|
|
43
|
+
sx: sx
|
|
44
|
+
}, rest, {
|
|
45
|
+
children: [_jsx(Box, {
|
|
46
|
+
sx: {
|
|
47
|
+
flex: 1
|
|
48
|
+
},
|
|
49
|
+
children: children
|
|
50
|
+
}), _jsxs(Flex, {
|
|
51
|
+
sx: navigationStyles,
|
|
52
|
+
children: [_jsx(Button, {
|
|
53
|
+
"aria-label": "Previous page",
|
|
54
|
+
disabled: isPrevDisabled,
|
|
55
|
+
onClick: function onClick() {
|
|
56
|
+
return previousParam && onNavigate(previousParam.param, previousParam.value);
|
|
57
|
+
},
|
|
58
|
+
sx: arrowButtonStyles,
|
|
59
|
+
children: _jsx(MdChevronLeft, {
|
|
60
|
+
size: 20
|
|
61
|
+
})
|
|
62
|
+
}), _jsx(Button, {
|
|
63
|
+
"aria-label": "Next page",
|
|
64
|
+
disabled: isNextDisabled,
|
|
65
|
+
onClick: function onClick() {
|
|
66
|
+
return nextParam && onNavigate(nextParam.param, nextParam.value);
|
|
67
|
+
},
|
|
68
|
+
sx: arrowButtonStyles,
|
|
69
|
+
children: _jsx(MdChevronRight, {
|
|
70
|
+
size: 20
|
|
71
|
+
})
|
|
72
|
+
})]
|
|
73
|
+
})]
|
|
74
|
+
}));
|
|
75
|
+
});
|
|
76
|
+
SimplePagination.displayName = 'SimplePagination';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
/**
|
|
3
|
+
* Internal dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { SimplePagination } from './SimplePagination';
|
|
6
|
+
import type { StoryObj, Meta } from '@storybook/react-vite';
|
|
7
|
+
declare const meta: Meta<typeof SimplePagination>;
|
|
8
|
+
export default meta;
|
|
9
|
+
type Story = StoryObj<typeof SimplePagination>;
|
|
10
|
+
export declare const Default: Story;
|
|
11
|
+
export declare const FirstPage: Story;
|
|
12
|
+
export declare const LastPage: Story;
|
|
13
|
+
export declare const WithPageSize: Story;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import { SimplePagination } from './SimplePagination';
|
|
9
|
+
import { Badge } from '../Badge';
|
|
10
|
+
import { Flex } from '../Flex';
|
|
11
|
+
import { Text } from '../Text';
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
13
|
+
var meta = {
|
|
14
|
+
title: 'SimplePagination',
|
|
15
|
+
component: SimplePagination,
|
|
16
|
+
parameters: {
|
|
17
|
+
docs: {
|
|
18
|
+
description: {
|
|
19
|
+
component: "\nA pagination control with only previous/next arrow buttons.\nDesigned for cursor-based pagination APIs with custom param names (e.g., `after`/`before`).\n\nFor page-number based pagination, see `Pagination`.\n\n## Component Properties\n"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export default meta;
|
|
25
|
+
var pageTokens = ['start', 'abc123', 'def456', 'ghi789', 'jkl012', 'end'];
|
|
26
|
+
var SimplePaginationWithState = function SimplePaginationWithState(_ref) {
|
|
27
|
+
var _ref$initialIndex = _ref.initialIndex,
|
|
28
|
+
initialIndex = _ref$initialIndex === void 0 ? 0 : _ref$initialIndex,
|
|
29
|
+
_ref$displayItemsPerP = _ref.displayItemsPerPageSelector,
|
|
30
|
+
displayItemsPerPageSelector = _ref$displayItemsPerP === void 0 ? false : _ref$displayItemsPerP;
|
|
31
|
+
var _useState = useState(initialIndex),
|
|
32
|
+
index = _useState[0],
|
|
33
|
+
setIndex = _useState[1];
|
|
34
|
+
var _useState2 = useState(20),
|
|
35
|
+
itemsPerPage = _useState2[0],
|
|
36
|
+
setItemsPerPage = _useState2[1];
|
|
37
|
+
var hasPreviousPage = index > 0;
|
|
38
|
+
var hasNextPage = index < pageTokens.length - 1;
|
|
39
|
+
return _jsx(SimplePagination, {
|
|
40
|
+
hasNextPage: hasNextPage,
|
|
41
|
+
hasPreviousPage: hasPreviousPage,
|
|
42
|
+
nextParam: hasNextPage ? {
|
|
43
|
+
param: 'after',
|
|
44
|
+
value: pageTokens[index + 1]
|
|
45
|
+
} : undefined,
|
|
46
|
+
previousParam: hasPreviousPage ? {
|
|
47
|
+
param: 'before',
|
|
48
|
+
value: pageTokens[index]
|
|
49
|
+
} : undefined,
|
|
50
|
+
onNavigate: function onNavigate(param) {
|
|
51
|
+
if (param === 'after') {
|
|
52
|
+
setIndex(function (i) {
|
|
53
|
+
return i + 1;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (param === 'before') {
|
|
57
|
+
setIndex(function (i) {
|
|
58
|
+
return i - 1;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
displayItemsPerPageSelector: displayItemsPerPageSelector,
|
|
63
|
+
itemsPerPage: displayItemsPerPageSelector ? itemsPerPage : undefined,
|
|
64
|
+
onItemsPerPageChange: displayItemsPerPageSelector ? function (size) {
|
|
65
|
+
setItemsPerPage(size);
|
|
66
|
+
setIndex(0);
|
|
67
|
+
} : undefined,
|
|
68
|
+
children: _jsxs(Flex, {
|
|
69
|
+
sx: {
|
|
70
|
+
justifyContent: 'center',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
verticalAlign: 'middle'
|
|
73
|
+
},
|
|
74
|
+
children: [_jsx(Badge, {
|
|
75
|
+
variant: "gold",
|
|
76
|
+
sx: {
|
|
77
|
+
mr: 2
|
|
78
|
+
},
|
|
79
|
+
children: "DEBUG"
|
|
80
|
+
}), _jsxs(Text, {
|
|
81
|
+
children: ["Index: ", index, " \u2014 token: ", pageTokens[index]]
|
|
82
|
+
})]
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
export var Default = {
|
|
87
|
+
render: function render() {
|
|
88
|
+
return _jsx(SimplePaginationWithState, {});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
export var FirstPage = {
|
|
92
|
+
render: function render() {
|
|
93
|
+
return _jsx(SimplePaginationWithState, {});
|
|
94
|
+
},
|
|
95
|
+
parameters: {
|
|
96
|
+
docs: {
|
|
97
|
+
description: {
|
|
98
|
+
story: 'On the first page — Previous button is disabled.'
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
export var LastPage = {
|
|
104
|
+
render: function render() {
|
|
105
|
+
return _jsx(SimplePaginationWithState, {
|
|
106
|
+
initialIndex: pageTokens.length - 1
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
parameters: {
|
|
110
|
+
docs: {
|
|
111
|
+
description: {
|
|
112
|
+
story: 'On the last page — Next button is disabled.'
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
export var WithPageSize = {
|
|
118
|
+
render: function render() {
|
|
119
|
+
return _jsx(SimplePaginationWithState, {
|
|
120
|
+
displayItemsPerPageSelector: true
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
parameters: {
|
|
124
|
+
docs: {
|
|
125
|
+
description: {
|
|
126
|
+
story: 'With an items-per-page selector.'
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
2
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
3
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
4
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
5
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
6
|
+
/** @jsxImportSource theme-ui */
|
|
7
|
+
|
|
8
|
+
import { render, screen } from '@testing-library/react';
|
|
9
|
+
import userEvent from '@testing-library/user-event';
|
|
10
|
+
import { axe } from 'jest-axe';
|
|
11
|
+
import '@testing-library/jest-dom';
|
|
12
|
+
import { SimplePagination } from './SimplePagination';
|
|
13
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
14
|
+
var defaultProps = {
|
|
15
|
+
hasNextPage: true,
|
|
16
|
+
hasPreviousPage: true,
|
|
17
|
+
nextParam: {
|
|
18
|
+
param: 'after',
|
|
19
|
+
value: 'cursor_abc'
|
|
20
|
+
},
|
|
21
|
+
previousParam: {
|
|
22
|
+
param: 'before',
|
|
23
|
+
value: 'cursor_xyz'
|
|
24
|
+
},
|
|
25
|
+
onNavigate: jest.fn()
|
|
26
|
+
};
|
|
27
|
+
describe('<SimplePagination />', function () {
|
|
28
|
+
beforeEach(function () {
|
|
29
|
+
jest.clearAllMocks();
|
|
30
|
+
});
|
|
31
|
+
it('renders a nav landmark with aria-label', function () {
|
|
32
|
+
render(_jsx(SimplePagination, _extends({}, defaultProps)));
|
|
33
|
+
expect(screen.getByRole('navigation', {
|
|
34
|
+
name: 'Pagination'
|
|
35
|
+
})).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
it('renders prev and next arrow buttons', function () {
|
|
38
|
+
render(_jsx(SimplePagination, _extends({}, defaultProps)));
|
|
39
|
+
expect(screen.getByRole('button', {
|
|
40
|
+
name: 'Previous page'
|
|
41
|
+
})).toBeInTheDocument();
|
|
42
|
+
expect(screen.getByRole('button', {
|
|
43
|
+
name: 'Next page'
|
|
44
|
+
})).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
it('does not render page number buttons', function () {
|
|
47
|
+
render(_jsx(SimplePagination, _extends({}, defaultProps)));
|
|
48
|
+
expect(screen.queryByRole('button', {
|
|
49
|
+
name: /Go to page/
|
|
50
|
+
})).not.toBeInTheDocument();
|
|
51
|
+
});
|
|
52
|
+
it('disables previous button when hasPreviousPage is false', function () {
|
|
53
|
+
render(_jsx(SimplePagination, _extends({}, defaultProps, {
|
|
54
|
+
hasPreviousPage: false
|
|
55
|
+
})));
|
|
56
|
+
expect(screen.getByRole('button', {
|
|
57
|
+
name: 'Previous page'
|
|
58
|
+
})).toBeDisabled();
|
|
59
|
+
});
|
|
60
|
+
it('disables next button when hasNextPage is false', function () {
|
|
61
|
+
render(_jsx(SimplePagination, _extends({}, defaultProps, {
|
|
62
|
+
hasNextPage: false
|
|
63
|
+
})));
|
|
64
|
+
expect(screen.getByRole('button', {
|
|
65
|
+
name: 'Next page'
|
|
66
|
+
})).toBeDisabled();
|
|
67
|
+
});
|
|
68
|
+
it('disables previous button when previousParam is undefined', function () {
|
|
69
|
+
render(_jsx(SimplePagination, _extends({}, defaultProps, {
|
|
70
|
+
previousParam: undefined
|
|
71
|
+
})));
|
|
72
|
+
expect(screen.getByRole('button', {
|
|
73
|
+
name: 'Previous page'
|
|
74
|
+
})).toBeDisabled();
|
|
75
|
+
});
|
|
76
|
+
it('disables next button when nextParam is undefined', function () {
|
|
77
|
+
render(_jsx(SimplePagination, _extends({}, defaultProps, {
|
|
78
|
+
nextParam: undefined
|
|
79
|
+
})));
|
|
80
|
+
expect(screen.getByRole('button', {
|
|
81
|
+
name: 'Next page'
|
|
82
|
+
})).toBeDisabled();
|
|
83
|
+
});
|
|
84
|
+
it('calls onNavigate with correct param and value when clicking next', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
85
|
+
var user;
|
|
86
|
+
return _regenerator().w(function (_context) {
|
|
87
|
+
while (1) switch (_context.n) {
|
|
88
|
+
case 0:
|
|
89
|
+
user = userEvent.setup();
|
|
90
|
+
render(_jsx(SimplePagination, _extends({}, defaultProps)));
|
|
91
|
+
_context.n = 1;
|
|
92
|
+
return user.click(screen.getByRole('button', {
|
|
93
|
+
name: 'Next page'
|
|
94
|
+
}));
|
|
95
|
+
case 1:
|
|
96
|
+
expect(defaultProps.onNavigate).toHaveBeenCalledWith('after', 'cursor_abc');
|
|
97
|
+
case 2:
|
|
98
|
+
return _context.a(2);
|
|
99
|
+
}
|
|
100
|
+
}, _callee);
|
|
101
|
+
})));
|
|
102
|
+
it('calls onNavigate with correct param and value when clicking previous', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
103
|
+
var user;
|
|
104
|
+
return _regenerator().w(function (_context2) {
|
|
105
|
+
while (1) switch (_context2.n) {
|
|
106
|
+
case 0:
|
|
107
|
+
user = userEvent.setup();
|
|
108
|
+
render(_jsx(SimplePagination, _extends({}, defaultProps)));
|
|
109
|
+
_context2.n = 1;
|
|
110
|
+
return user.click(screen.getByRole('button', {
|
|
111
|
+
name: 'Previous page'
|
|
112
|
+
}));
|
|
113
|
+
case 1:
|
|
114
|
+
expect(defaultProps.onNavigate).toHaveBeenCalledWith('before', 'cursor_xyz');
|
|
115
|
+
case 2:
|
|
116
|
+
return _context2.a(2);
|
|
117
|
+
}
|
|
118
|
+
}, _callee2);
|
|
119
|
+
})));
|
|
120
|
+
it('renders children content', function () {
|
|
121
|
+
render(_jsx(SimplePagination, _extends({}, defaultProps, {
|
|
122
|
+
children: _jsx("span", {
|
|
123
|
+
children: "Showing results"
|
|
124
|
+
})
|
|
125
|
+
})));
|
|
126
|
+
expect(screen.getByText('Showing results')).toBeInTheDocument();
|
|
127
|
+
});
|
|
128
|
+
it('renders items-per-page selector when enabled', function () {
|
|
129
|
+
render(_jsx(SimplePagination, _extends({}, defaultProps, {
|
|
130
|
+
displayItemsPerPageSelector: true,
|
|
131
|
+
itemsPerPage: 20,
|
|
132
|
+
onItemsPerPageChange: jest.fn()
|
|
133
|
+
})));
|
|
134
|
+
expect(screen.getByRole('combobox')).toBeInTheDocument();
|
|
135
|
+
});
|
|
136
|
+
it('has no accessibility violations', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
137
|
+
var _render, container, _t;
|
|
138
|
+
return _regenerator().w(function (_context3) {
|
|
139
|
+
while (1) switch (_context3.n) {
|
|
140
|
+
case 0:
|
|
141
|
+
_render = render(_jsx(SimplePagination, _extends({}, defaultProps))), container = _render.container;
|
|
142
|
+
_t = expect;
|
|
143
|
+
_context3.n = 1;
|
|
144
|
+
return axe(container);
|
|
145
|
+
case 1:
|
|
146
|
+
_t(_context3.v).toHaveNoViolations();
|
|
147
|
+
case 2:
|
|
148
|
+
return _context3.a(2);
|
|
149
|
+
}
|
|
150
|
+
}, _callee3);
|
|
151
|
+
})));
|
|
152
|
+
it('has no accessibility violations with both buttons disabled', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
153
|
+
var _render2, container, _t2;
|
|
154
|
+
return _regenerator().w(function (_context4) {
|
|
155
|
+
while (1) switch (_context4.n) {
|
|
156
|
+
case 0:
|
|
157
|
+
_render2 = render(_jsx(SimplePagination, _extends({}, defaultProps, {
|
|
158
|
+
hasNextPage: false,
|
|
159
|
+
hasPreviousPage: false
|
|
160
|
+
}))), container = _render2.container;
|
|
161
|
+
_t2 = expect;
|
|
162
|
+
_context4.n = 1;
|
|
163
|
+
return axe(container);
|
|
164
|
+
case 1:
|
|
165
|
+
_t2(_context4.v).toHaveNoViolations();
|
|
166
|
+
case 2:
|
|
167
|
+
return _context4.a(2);
|
|
168
|
+
}
|
|
169
|
+
}, _callee4);
|
|
170
|
+
})));
|
|
171
|
+
});
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { Pagination, getPageNumbers } from './Pagination';
|
|
2
|
-
export
|
|
2
|
+
export { SimplePagination } from './SimplePagination';
|
|
3
|
+
export type { PaginationProps, PageNumberItem } from './Pagination';
|
|
4
|
+
export type { SimplePaginationProps, SimpleNavigationParam } from './SimplePagination';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { Pagination, getPageNumbers } from './Pagination';
|
|
1
|
+
export { Pagination, getPageNumbers } from './Pagination';
|
|
2
|
+
export { SimplePagination } from './SimplePagination';
|
|
@@ -23,8 +23,7 @@ export var pageButtonStyles = {
|
|
|
23
23
|
bg: 'transparent',
|
|
24
24
|
color: 'heading',
|
|
25
25
|
cursor: 'pointer',
|
|
26
|
-
|
|
27
|
-
fontFamily: 'body',
|
|
26
|
+
variant: 'text.default',
|
|
28
27
|
px: 2,
|
|
29
28
|
borderBottom: '3px solid',
|
|
30
29
|
borderColor: 'transparent',
|
|
@@ -79,8 +78,6 @@ export var compactTriggerStyles = {
|
|
|
79
78
|
bg: 'transparent',
|
|
80
79
|
color: 'heading',
|
|
81
80
|
cursor: 'pointer',
|
|
82
|
-
fontSize: 2,
|
|
83
|
-
fontFamily: 'body',
|
|
84
81
|
fontWeight: 'bold',
|
|
85
82
|
px: 2,
|
|
86
83
|
borderRadius: 1,
|
|
@@ -27,7 +27,7 @@ export var TableCell = function TableCell(_ref) {
|
|
|
27
27
|
borderTop: head ? '1px solid' : 'none',
|
|
28
28
|
// borderColor should come after borderTop so it can override it
|
|
29
29
|
borderColor: 'table.border',
|
|
30
|
-
|
|
30
|
+
variant: 'text.default',
|
|
31
31
|
px: 3,
|
|
32
32
|
py: 2,
|
|
33
33
|
textAlign: 'left'
|
|
@@ -20,6 +20,21 @@ export var Default = {
|
|
|
20
20
|
return _jsxs(_Fragment, {
|
|
21
21
|
children: [_jsxs(Text, {
|
|
22
22
|
children: ["Apparently we had reached a great height in the atmosphere, for the sky was a dead black, and the stars had ceased to twinkle. By the same illusion which lifts the horizon of the sea to the level of the spectator on a hillside, the sable cloud beneath was dished out, and the car seemed to float in the middle of an immense dark sphere, whose upper half was strewn with silver.", ' ']
|
|
23
|
+
}), _jsx(Text, {
|
|
24
|
+
variant: "default",
|
|
25
|
+
children: "Body Default"
|
|
26
|
+
}), _jsx(Text, {
|
|
27
|
+
variant: "small",
|
|
28
|
+
children: "Body Small"
|
|
29
|
+
}), _jsx(Text, {
|
|
30
|
+
variant: "large",
|
|
31
|
+
children: "Body Large"
|
|
32
|
+
}), _jsx(Text, {
|
|
33
|
+
variant: "mono",
|
|
34
|
+
children: "Body Mono"
|
|
35
|
+
}), _jsx(Text, {
|
|
36
|
+
variant: "mono-bold",
|
|
37
|
+
children: "Body Mono Bold"
|
|
23
38
|
}), _jsx(Text, {
|
|
24
39
|
sx: {
|
|
25
40
|
color: 'texts.accent'
|
|
@@ -33,13 +48,7 @@ export var Default = {
|
|
|
33
48
|
}), _jsx(Text, {
|
|
34
49
|
sx: {
|
|
35
50
|
color: 'texts.helper',
|
|
36
|
-
fontWeight: '
|
|
37
|
-
},
|
|
38
|
-
children: "Text Helper"
|
|
39
|
-
}), _jsx(Text, {
|
|
40
|
-
sx: {
|
|
41
|
-
color: 'texts.helper',
|
|
42
|
-
fontWeight: 'heading'
|
|
51
|
+
fontWeight: 'light'
|
|
43
52
|
},
|
|
44
53
|
children: "Text Helper"
|
|
45
54
|
}), _jsx(Text, {
|
|
@@ -60,12 +69,6 @@ export var Default = {
|
|
|
60
69
|
fontWeight: 'bold'
|
|
61
70
|
},
|
|
62
71
|
children: "Text Helper"
|
|
63
|
-
}), _jsx(Text, {
|
|
64
|
-
sx: {
|
|
65
|
-
color: 'texts.helper',
|
|
66
|
-
fontWeight: 'light'
|
|
67
|
-
},
|
|
68
|
-
children: "Text Helper"
|
|
69
72
|
}), _jsx(Text, {
|
|
70
73
|
sx: {
|
|
71
74
|
color: 'texts.secondary'
|
|
@@ -10,7 +10,7 @@ import { Link } from 'theme-ui';
|
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
|
-
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
14
14
|
var VIP_LOGO = 'vip-logo-component';
|
|
15
15
|
/**
|
|
16
16
|
* The WordPress VIP logo rendered as an SVG inside a themed link.
|
|
@@ -29,15 +29,31 @@ export var Logo = function Logo(_ref) {
|
|
|
29
29
|
},
|
|
30
30
|
href: href,
|
|
31
31
|
as: as,
|
|
32
|
-
children:
|
|
32
|
+
children: _jsxs("svg", {
|
|
33
33
|
className: classNames(VIP_LOGO, className),
|
|
34
34
|
xmlns: "http://www.w3.org/2000/svg",
|
|
35
|
-
viewBox: "0 0
|
|
35
|
+
viewBox: "0 0 393.6 176.6",
|
|
36
36
|
role: "img",
|
|
37
37
|
"aria-label": "WordPress VIP Logo",
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
sx: {
|
|
39
|
+
display: 'block',
|
|
40
|
+
width: '100%',
|
|
41
|
+
height: 'auto'
|
|
42
|
+
},
|
|
43
|
+
children: [_jsx("path", {
|
|
44
|
+
fill: "currentColor",
|
|
45
|
+
d: "m88.3,0C39.6,0,0,39.6,0,88.3s39.6,88.3,88.3,88.3,88.3-39.5,88.3-88.3S137.1,0,88.3,0ZM8.8,88.3c0-11.5,2.5-22.5,6.8-32.4l37.8,103.8c-26-13-44.6-39.9-44.6-71.4Zm79.5,79.5c-7.7,0-15.3-1.1-22.5-3.2l23.7-69.2,24.4,66.9c.2.4.4.7.5,1.1-8.1,2.8-16.7,4.4-26.1,4.4Zm11-116.8c4.8-.4,9-.7,9-.7,4.1-.5,3.8-6.8-.5-6.5,0,0-13,.9-21.2.9-7.7,0-20.9-.9-20.9-.9-4.1-.4-4.8,6.3-.5,6.5,0,0,4.1.5,8.3.7l12.2,34-17.2,52-28.6-86c4.8-.4,9-.7,9-.7,4.1-.5,3.8-6.8-.5-6.5,0,0-13,.9-21.2.9-1.6,0-3.2,0-5.2-.2C36.1,23,60.5,8.8,88.2,8.8c20.7,0,39.5,7.9,53.6,20.9h-1.1c-7.7,0-13.3,6.8-13.3,14.2,0,6.5,3.8,12.2,7.7,18.7,2.9,5.2,6.5,12.2,6.5,21.9,0,6.8-2,15.5-6.1,25.7l-7.9,26.3-28.3-85.5Zm29.2,106l24.3-70.1c4.5-11.3,6.1-20.3,6.1-28.4,0-2.9-.2-5.5-.5-8.1,6.3,11.3,9.7,24.3,9.7,38.1-.3,29.1-16.3,54.8-39.6,68.5Z"
|
|
46
|
+
}), _jsx("path", {
|
|
47
|
+
fill: "currentColor",
|
|
48
|
+
d: "m323.7,39.2h33.4c7.2,0,13.1.9,17.8,2.5,4.7,1.6,8.5,3.8,11.1,6.5,2.9,2.7,4.7,5.8,5.8,9.3,1.1,3.4,1.8,7.2,1.8,11,0,4.1-.5,8.1-1.8,11.9-1.1,3.8-3.1,7-5.8,10.1-2.7,2.9-6.5,5.1-11,6.6-4.5,1.6-10.4,2.5-17.5,2.5h-14.7v33.4h-19.2V39.2h.1Zm33.3,44.1c3.4,0,6.3-.4,8.5-1.1,2.4-.7,4.1-1.6,5.4-2.9,1.3-1.3,2.1-2.7,2.7-4.5.5-1.8.7-3.8.7-5.9s-.2-4.1-.7-5.8c-.5-1.6-1.4-3.1-2.7-4.1-1.3-1.1-3.1-2-5.4-2.7-2.1-.5-5.1-.9-8.5-.9h-14v27.8h14v.1Z"
|
|
49
|
+
}), _jsx("path", {
|
|
50
|
+
fill: "currentColor",
|
|
51
|
+
d: "m197.5,39.2h21.9l22.8,66.3,23.4-66.3h21l-35.3,93.9h-18.5l-35.3-93.9Z"
|
|
52
|
+
}), _jsx("path", {
|
|
53
|
+
fill: "currentColor",
|
|
54
|
+
fillRule: "evenodd",
|
|
55
|
+
d: "m311,39.2h-13.3l-6.3,16.9v76.9h19.6V39.2Z"
|
|
56
|
+
})]
|
|
41
57
|
})
|
|
42
58
|
});
|
|
43
59
|
};
|
|
@@ -24,16 +24,16 @@ export var Primary = {
|
|
|
24
24
|
summaryAs: 'dl',
|
|
25
25
|
steps: [{
|
|
26
26
|
title: 'Step One',
|
|
27
|
-
titleVariant: '
|
|
27
|
+
titleVariant: 'h3',
|
|
28
28
|
subTitle: 'First step description.',
|
|
29
29
|
children: 'Step one content'
|
|
30
30
|
}, {
|
|
31
31
|
title: 'Step Two',
|
|
32
|
-
titleVariant: '
|
|
32
|
+
titleVariant: 'h3',
|
|
33
33
|
subTitle: 'Second step description.'
|
|
34
34
|
}, {
|
|
35
35
|
title: 'Step Three',
|
|
36
|
-
titleVariant: '
|
|
36
|
+
titleVariant: 'h3'
|
|
37
37
|
}]
|
|
38
38
|
}
|
|
39
39
|
};
|
|
@@ -41,7 +41,7 @@ export var Default = {
|
|
|
41
41
|
render: function render() {
|
|
42
42
|
var steps = [{
|
|
43
43
|
title: 'Choose Domain',
|
|
44
|
-
titleVariant: '
|
|
44
|
+
titleVariant: 'h3',
|
|
45
45
|
subTitle: 'You can bring a domain name you already own, or buy a new one.',
|
|
46
46
|
children: _jsxs(Box, {
|
|
47
47
|
children: [_jsx(Label, {
|
|
@@ -57,14 +57,14 @@ export var Default = {
|
|
|
57
57
|
})
|
|
58
58
|
}, {
|
|
59
59
|
title: 'Configure DNS',
|
|
60
|
-
titleVariant: '
|
|
60
|
+
titleVariant: 'h3',
|
|
61
61
|
summaryTitle: 'Summary of Configure DNS'
|
|
62
62
|
}, {
|
|
63
63
|
title: 'Configure Certificate',
|
|
64
|
-
titleVariant: '
|
|
64
|
+
titleVariant: 'h3'
|
|
65
65
|
}, {
|
|
66
66
|
title: 'Verify Domain',
|
|
67
|
-
titleVariant: '
|
|
67
|
+
titleVariant: 'h3'
|
|
68
68
|
}];
|
|
69
69
|
return _jsx(React.Fragment, {
|
|
70
70
|
children: _jsx(Box, {
|
|
@@ -90,7 +90,7 @@ export var WithTitleAutoFocus = {
|
|
|
90
90
|
setAutoFocus = _React$useState2[1];
|
|
91
91
|
var steps = [{
|
|
92
92
|
title: 'Choose Domain',
|
|
93
|
-
titleVariant: '
|
|
93
|
+
titleVariant: 'h3',
|
|
94
94
|
summary: [{
|
|
95
95
|
label: 'Demo Label',
|
|
96
96
|
value: 'Demo value'
|
|
@@ -115,7 +115,7 @@ export var WithTitleAutoFocus = {
|
|
|
115
115
|
})
|
|
116
116
|
}, {
|
|
117
117
|
title: 'Configure DNS',
|
|
118
|
-
titleVariant: '
|
|
118
|
+
titleVariant: 'h3',
|
|
119
119
|
onChange: function onChange() {
|
|
120
120
|
return setActiveStep(1);
|
|
121
121
|
},
|
|
@@ -137,7 +137,7 @@ export var WithTitleAutoFocus = {
|
|
|
137
137
|
})
|
|
138
138
|
}, {
|
|
139
139
|
title: 'Certificate',
|
|
140
|
-
titleVariant: '
|
|
140
|
+
titleVariant: 'h3',
|
|
141
141
|
summary: [{
|
|
142
142
|
label: 'Certificate status',
|
|
143
143
|
value: 'Not found'
|
|
@@ -202,7 +202,7 @@ export var HideStepText = {
|
|
|
202
202
|
setActiveStep = _React$useState3[1];
|
|
203
203
|
var steps = [{
|
|
204
204
|
title: 'Included Logs',
|
|
205
|
-
titleVariant: '
|
|
205
|
+
titleVariant: 'h3',
|
|
206
206
|
subTitle: '',
|
|
207
207
|
children: _jsx(Text, {
|
|
208
208
|
sx: {
|
package/build/system/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ import * as Form from './NewForm';
|
|
|
31
31
|
import { NewTooltip } from './NewTooltip';
|
|
32
32
|
import { Notice } from './Notice';
|
|
33
33
|
import { OptionRow } from './OptionRow';
|
|
34
|
-
import { Pagination } from './Pagination';
|
|
34
|
+
import { SimplePagination, Pagination } from './Pagination';
|
|
35
35
|
import { Progress } from './Progress';
|
|
36
36
|
import { ScreenReaderText } from './ScreenReaderText';
|
|
37
37
|
import { Skeleton } from './Skeleton';
|
|
@@ -44,4 +44,4 @@ import { Toolbar } from './Toolbar';
|
|
|
44
44
|
import { Tooltip } from './Tooltip';
|
|
45
45
|
import { Wizard, WizardStep } from './Wizard';
|
|
46
46
|
import theme from './theme';
|
|
47
|
-
export { Accordion, Avatar, Badge, Box, Breadcrumbs, Button, ButtonSubmit, ButtonVariant, Card, Checkbox, Code, Dialog, NewDialog, Form, Drawer, Dropdown, DialogButton, DialogMenu, DialogMenuItem, DialogDivider, DialogContent, DialogTrigger, DescriptionList, ConfirmationDialog, MobileMenu, MobileMenuTrigger, MobileMenuWrapper, NewConfirmationDialog, NewTooltip, Grid, FilterDropdown, Flex, Notice, OptionRow, Pagination, Heading, Hr, Input, Label, ScreenReaderText, Spinner, Table, TableRow, TableCell, Tooltip, Link, LinkExternal, Radio, RadioBoxGroup, RadioGroupChip, Textarea, Progress, Text, Tabs, Nav, NavItem, Skeleton, TabsTrigger, TabsContent, TabsList, Toggle, ToggleRow, Toolbar, Snackbar, Validation, Wizard, WizardStep, theme, };
|
|
47
|
+
export { Accordion, Avatar, Badge, Box, Breadcrumbs, Button, ButtonSubmit, ButtonVariant, Card, Checkbox, Code, Dialog, NewDialog, Form, Drawer, Dropdown, DialogButton, DialogMenu, DialogMenuItem, DialogDivider, DialogContent, DialogTrigger, DescriptionList, ConfirmationDialog, MobileMenu, MobileMenuTrigger, MobileMenuWrapper, NewConfirmationDialog, NewTooltip, Grid, FilterDropdown, Flex, Notice, OptionRow, SimplePagination, Pagination, Heading, Hr, Input, Label, ScreenReaderText, Spinner, Table, TableRow, TableCell, Tooltip, Link, LinkExternal, Radio, RadioBoxGroup, RadioGroupChip, Textarea, Progress, Text, Tabs, Nav, NavItem, Skeleton, TabsTrigger, TabsContent, TabsList, Toggle, ToggleRow, Toolbar, Snackbar, Validation, Wizard, WizardStep, theme, };
|