newspack-components 4.11.0 → 4.12.0-alpha.1
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/CHANGELOG.md +18 -0
- package/DEVELOPMENT.md +79 -38
- package/dist/cjs/breadcrumbs/index.js +1 -0
- package/dist/cjs/breadcrumbs/style.scss +3 -10
- package/dist/cjs/card/style-core.scss +1 -1
- package/dist/cjs/card-sortable-list/index.js +17 -9
- package/dist/cjs/drawer/body.js +4 -6
- package/dist/cjs/drawer/content.js +7 -37
- package/dist/cjs/drawer/footer.js +10 -1
- package/dist/cjs/drawer/header.js +9 -1
- package/dist/cjs/drawer/index.test.js +3 -4
- package/dist/cjs/drawer/slots.test.js +25 -67
- package/dist/cjs/drawer/style.scss +0 -18
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/page/index.js +10 -2
- package/dist/cjs/page/style.scss +24 -2
- package/dist/cjs/tabbed-navigation/style.scss +5 -0
- package/dist/cjs/tooltip-badge/index.js +50 -0
- package/dist/cjs/tooltip-badge/index.test.js +30 -0
- package/dist/cjs/wizard/index.js +21 -8
- package/dist/cjs/wizard/index.test.js +78 -0
- package/dist/cjs/wizard/store/index.js +2 -1
- package/dist/esm/breadcrumbs/index.js +1 -0
- package/dist/esm/breadcrumbs/style.scss +3 -10
- package/dist/esm/card/style-core.scss +1 -1
- package/dist/esm/card-sortable-list/index.js +20 -11
- package/dist/esm/drawer/body.js +4 -5
- package/dist/esm/drawer/content.js +7 -36
- package/dist/esm/drawer/footer.js +10 -1
- package/dist/esm/drawer/header.js +9 -1
- package/dist/esm/drawer/index.test.js +3 -4
- package/dist/esm/drawer/slots.test.js +25 -67
- package/dist/esm/drawer/style.scss +0 -18
- package/dist/esm/index.js +1 -0
- package/dist/esm/page/index.js +10 -2
- package/dist/esm/page/style.scss +24 -2
- package/dist/esm/tabbed-navigation/style.scss +5 -0
- package/dist/esm/tooltip-badge/index.js +43 -0
- package/dist/esm/tooltip-badge/index.test.js +26 -0
- package/dist/esm/wizard/index.js +23 -12
- package/dist/esm/wizard/index.test.js +78 -0
- package/dist/esm/wizard/store/index.js +2 -1
- package/package.json +2 -2
- package/src/breadcrumbs/index.js +1 -1
- package/src/breadcrumbs/style.scss +3 -10
- package/src/card/style-core.scss +1 -1
- package/src/card-form/README.md +2 -2
- package/src/card-sortable-list/index.tsx +27 -11
- package/src/drawer/README.md +10 -16
- package/src/drawer/body.tsx +4 -5
- package/src/drawer/content.tsx +7 -33
- package/src/drawer/footer.tsx +8 -1
- package/src/drawer/header.tsx +8 -1
- package/src/drawer/index.test.js +3 -4
- package/src/drawer/slots.test.js +14 -48
- package/src/drawer/style.scss +0 -18
- package/src/drawer/types.ts +8 -3
- package/src/index.js +1 -0
- package/src/page/index.js +7 -3
- package/src/page/style.scss +24 -2
- package/src/tabbed-navigation/style.scss +5 -0
- package/src/tooltip-badge/index.test.js +24 -0
- package/src/tooltip-badge/index.tsx +40 -0
- package/src/wizard/index.js +25 -14
- package/src/wizard/index.test.js +38 -0
- package/src/wizard/store/index.js +1 -0
|
@@ -132,86 +132,35 @@ describe('Drawer.Content', function () {
|
|
|
132
132
|
container = _render2.container;
|
|
133
133
|
expect(sectionOf(container).style.getPropertyValue('--newspack-drawer-content-padding')).toBe('0px');
|
|
134
134
|
});
|
|
135
|
-
it('
|
|
135
|
+
it('spaces its children by the lg gap token, and by the gap prop', function () {
|
|
136
136
|
var _render3 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_content["default"], {
|
|
137
137
|
children: "stacked"
|
|
138
138
|
})),
|
|
139
|
-
container = _render3.container
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// VStack emits its spacing as a `calc()` on the 4px base, not as pixels.
|
|
144
|
-
it('spaces its children by 16px, and by the gap prop', function () {
|
|
145
|
-
var _render4 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_content["default"], {
|
|
146
|
-
children: "stacked"
|
|
147
|
-
})),
|
|
148
|
-
container = _render4.container,
|
|
149
|
-
rerender = _render4.rerender;
|
|
150
|
-
expect(window.getComputedStyle(sectionOf(container)).gap).toBe('calc(4px * 4)');
|
|
139
|
+
container = _render3.container,
|
|
140
|
+
rerender = _render3.rerender;
|
|
141
|
+
expect(sectionOf(container).style.gap).toContain('gap-lg');
|
|
151
142
|
rerender(/*#__PURE__*/(0, _jsxRuntime.jsx)(_content["default"], {
|
|
152
|
-
gap:
|
|
143
|
+
gap: "sm",
|
|
153
144
|
children: "stacked"
|
|
154
145
|
}));
|
|
155
|
-
expect(
|
|
146
|
+
expect(sectionOf(container).style.gap).toContain('gap-sm');
|
|
156
147
|
});
|
|
157
|
-
|
|
158
|
-
// VStack keeps only elements, so these would otherwise vanish without warning.
|
|
159
148
|
it('keeps plain text sitting beside an element', function () {
|
|
160
|
-
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsxs)(_content["default"], {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}));
|
|
165
|
-
expect(_react.screen.getByText('Lead text')).toBeInTheDocument();
|
|
166
|
-
expect(_react.screen.getByText('an element')).toBeInTheDocument();
|
|
167
|
-
expect(_react.screen.getByText('42')).toBeInTheDocument();
|
|
168
|
-
});
|
|
169
|
-
it('keeps a run of text and interpolations on one row', function () {
|
|
170
|
-
var _render5 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsxs)(_content["default"], {
|
|
171
|
-
children: ["Edited by ", 'Ada', " just now"]
|
|
172
|
-
})),
|
|
173
|
-
container = _render5.container;
|
|
174
|
-
var rows = sectionOf(container).children;
|
|
175
|
-
expect(rows).toHaveLength(1);
|
|
176
|
-
expect(rows[0]).toHaveTextContent('Edited by Ada just now');
|
|
177
|
-
});
|
|
178
|
-
it('starts a new row either side of an element', function () {
|
|
179
|
-
var _render6 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsxs)(_content["default"], {
|
|
180
|
-
children: ["before", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
181
|
-
children: "middle"
|
|
182
|
-
}), "after"]
|
|
183
|
-
})),
|
|
184
|
-
container = _render6.container;
|
|
185
|
-
expect(Array.from(sectionOf(container).children).map(function (row) {
|
|
186
|
-
return row.textContent;
|
|
187
|
-
})).toEqual(['before', 'middle', 'after']);
|
|
188
|
-
});
|
|
189
|
-
it('emits no row for whitespace or empty text between elements', function () {
|
|
190
|
-
var _render7 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsxs)(_content["default"], {
|
|
191
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
192
|
-
children: "one"
|
|
193
|
-
}), " ", '', /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
194
|
-
children: "two"
|
|
195
|
-
})]
|
|
149
|
+
var _render4 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsxs)(_content["default"], {
|
|
150
|
+
children: ["Lead text", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
151
|
+
children: "an element"
|
|
152
|
+
}), 42]
|
|
196
153
|
})),
|
|
197
|
-
container =
|
|
198
|
-
expect(
|
|
199
|
-
return row.textContent;
|
|
200
|
-
})).toEqual(['one', 'two']);
|
|
201
|
-
});
|
|
202
|
-
it('keeps a lone string', function () {
|
|
203
|
-
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_content["default"], {
|
|
204
|
-
children: "on its own"
|
|
205
|
-
}));
|
|
206
|
-
expect(_react.screen.getByText('on its own')).toBeInTheDocument();
|
|
154
|
+
container = _render4.container;
|
|
155
|
+
expect(sectionOf(container)).toHaveTextContent('Lead textan element42');
|
|
207
156
|
});
|
|
208
157
|
});
|
|
209
158
|
describe('Drawer.Divider', function () {
|
|
210
159
|
it('renders a separator, merging className', function () {
|
|
211
|
-
var
|
|
160
|
+
var _render5 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_divider["default"], {
|
|
212
161
|
className: "custom"
|
|
213
162
|
})),
|
|
214
|
-
container =
|
|
163
|
+
container = _render5.container;
|
|
215
164
|
var divider = container.querySelector('hr');
|
|
216
165
|
expect(divider).toHaveClass('newspack-drawer__divider', 'custom');
|
|
217
166
|
expect(_react.screen.getByRole('separator')).toBe(divider);
|
|
@@ -224,8 +173,17 @@ describe('Drawer.Footer', function () {
|
|
|
224
173
|
}));
|
|
225
174
|
expect(_react.screen.getByText('actions')).toHaveClass('newspack-drawer__footer');
|
|
226
175
|
});
|
|
176
|
+
it('lays its actions out in one end-aligned row that wraps', function () {
|
|
177
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_footer["default"], {
|
|
178
|
+
children: "actions"
|
|
179
|
+
}));
|
|
180
|
+
var footer = _react.screen.getByText('actions');
|
|
181
|
+
expect(footer.style.flexDirection).toBe('row');
|
|
182
|
+
expect(footer.style.justifyContent).toBe('flex-end');
|
|
183
|
+
expect(footer.style.flexWrap).toBe('wrap');
|
|
184
|
+
});
|
|
227
185
|
it('renders its actions as direct children', function () {
|
|
228
|
-
var
|
|
186
|
+
var _render6 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsxs)(_footer["default"], {
|
|
229
187
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_action["default"], {
|
|
230
188
|
children: "One"
|
|
231
189
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_action["default"], {
|
|
@@ -234,7 +192,7 @@ describe('Drawer.Footer', function () {
|
|
|
234
192
|
children: "Three"
|
|
235
193
|
})]
|
|
236
194
|
})),
|
|
237
|
-
container =
|
|
195
|
+
container = _render6.container;
|
|
238
196
|
var footer = container.querySelector('.newspack-drawer__footer');
|
|
239
197
|
expect(Array.from(footer.children)).toEqual([_react.screen.getByRole('button', {
|
|
240
198
|
name: 'One'
|
|
@@ -80,10 +80,7 @@ $drawer-size-x-large: 640px;
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
.newspack-drawer__header {
|
|
83
|
-
align-items: center;
|
|
84
|
-
display: flex;
|
|
85
83
|
flex: 0 0 auto;
|
|
86
|
-
gap: wp-vars.$grid-unit-10;
|
|
87
84
|
padding: wp-vars.$grid-unit-30 wp-vars.$grid-unit-30 wp-vars.$grid-unit-20;
|
|
88
85
|
}
|
|
89
86
|
|
|
@@ -139,23 +136,8 @@ $drawer-size-x-large: 640px;
|
|
|
139
136
|
|
|
140
137
|
.newspack-drawer__footer {
|
|
141
138
|
background: wp-colors.$white;
|
|
142
|
-
display: flex;
|
|
143
139
|
flex: 0 0 auto;
|
|
144
|
-
gap: wp-vars.$grid-unit-10;
|
|
145
140
|
padding: wp-vars.$grid-unit-20 wp-vars.$grid-unit-30 wp-vars.$grid-unit-30;
|
|
146
|
-
|
|
147
|
-
> .components-button {
|
|
148
|
-
flex: 1;
|
|
149
|
-
justify-content: center;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
&:has(> :nth-child(3)) {
|
|
153
|
-
flex-direction: column;
|
|
154
|
-
|
|
155
|
-
> .components-button {
|
|
156
|
-
flex: 0 0 auto;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
141
|
}
|
|
160
142
|
|
|
161
143
|
@keyframes newspack-drawer-slide-in {
|
package/dist/cjs/index.js
CHANGED
|
@@ -334,6 +334,12 @@ Object.defineProperty(exports, "TextControl", {
|
|
|
334
334
|
return _textControl["default"];
|
|
335
335
|
}
|
|
336
336
|
});
|
|
337
|
+
Object.defineProperty(exports, "TooltipBadge", {
|
|
338
|
+
enumerable: true,
|
|
339
|
+
get: function get() {
|
|
340
|
+
return _tooltipBadge["default"];
|
|
341
|
+
}
|
|
342
|
+
});
|
|
337
343
|
Object.defineProperty(exports, "Waiting", {
|
|
338
344
|
enumerable: true,
|
|
339
345
|
get: function get() {
|
|
@@ -454,6 +460,7 @@ var _styleCard = _interopRequireDefault(require("./style-card"));
|
|
|
454
460
|
var _tabbedNavigation = _interopRequireDefault(require("./tabbed-navigation"));
|
|
455
461
|
var _tableCard = _interopRequireDefault(require("./table-card"));
|
|
456
462
|
var _textControl = _interopRequireDefault(require("./text-control"));
|
|
463
|
+
var _tooltipBadge = _interopRequireDefault(require("./tooltip-badge"));
|
|
457
464
|
var _waiting = _interopRequireDefault(require("./waiting"));
|
|
458
465
|
var _webPreview = _interopRequireDefault(require("./web-preview"));
|
|
459
466
|
var _wizard = _interopRequireWildcard(require("./wizard"));
|
package/dist/cjs/page/index.js
CHANGED
|
@@ -74,11 +74,13 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
74
74
|
direction: "row",
|
|
75
75
|
gap: "sm",
|
|
76
76
|
justify: "space-between",
|
|
77
|
+
wrap: "wrap",
|
|
77
78
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_ui.Stack, {
|
|
78
79
|
direction: "row",
|
|
79
80
|
gap: "sm",
|
|
80
|
-
align: "
|
|
81
|
+
align: "start",
|
|
81
82
|
justify: "start",
|
|
83
|
+
className: "newspack-page__header-title",
|
|
82
84
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
83
85
|
className: "newspack-page__header-visual",
|
|
84
86
|
"aria-hidden": "true",
|
|
@@ -91,7 +93,13 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
91
93
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_breadcrumbs["default"], {
|
|
92
94
|
items: breadcrumbItems
|
|
93
95
|
})
|
|
94
|
-
}), badges
|
|
96
|
+
}), badges && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.Stack, {
|
|
97
|
+
direction: "row",
|
|
98
|
+
gap: "sm",
|
|
99
|
+
align: "center",
|
|
100
|
+
className: "newspack-page__header-badges",
|
|
101
|
+
children: badges
|
|
102
|
+
})]
|
|
95
103
|
}), actions && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.Stack, {
|
|
96
104
|
direction: "row",
|
|
97
105
|
gap: "sm",
|
package/dist/cjs/page/style.scss
CHANGED
|
@@ -56,8 +56,29 @@
|
|
|
56
56
|
padding: var(--wpds-dimension-padding-lg) var(--wpds-dimension-padding-2xl);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
.newspack-page__header-title {
|
|
60
|
+
min-width: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
.newspack-page__header-actions {
|
|
64
|
+
flex-basis: 100%;
|
|
65
|
+
flex-shrink: 0;
|
|
66
|
+
justify-content: flex-end;
|
|
67
|
+
margin-inline-start: auto;
|
|
68
|
+
|
|
69
|
+
@include wp-mixins.break-medium {
|
|
70
|
+
flex-basis: auto;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:empty,
|
|
74
|
+
&:has(> :only-child:empty) {
|
|
75
|
+
display: none;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.newspack-page__header-badges {
|
|
60
80
|
flex-shrink: 0;
|
|
81
|
+
min-height: wp-vars.$button-size;
|
|
61
82
|
}
|
|
62
83
|
|
|
63
84
|
.newspack-page__header-subtitle {
|
|
@@ -68,7 +89,7 @@
|
|
|
68
89
|
.newspack-page__header-visual {
|
|
69
90
|
display: grid;
|
|
70
91
|
flex-shrink: 0;
|
|
71
|
-
height:
|
|
92
|
+
height: wp-vars.$button-size;
|
|
72
93
|
place-items: center;
|
|
73
94
|
width: 24px;
|
|
74
95
|
|
|
@@ -80,5 +101,6 @@
|
|
|
80
101
|
}
|
|
81
102
|
|
|
82
103
|
.newspack-page__breadcrumbs {
|
|
83
|
-
min-
|
|
104
|
+
min-width: 0;
|
|
105
|
+
padding-block: calc((#{wp-vars.$button-size} - var(--wpds-typography-line-height-md)) / 2);
|
|
84
106
|
}
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
/* stylelint-disable-next-line plugin-wpds/no-setting-wpds-custom-properties -- deliberate Newspack brand override of the indicator token. */
|
|
22
22
|
--wpds-color-stroke-interactive-neutral-strong: #{np-colors.$primary-600};
|
|
23
23
|
|
|
24
|
+
[role="tablist"] {
|
|
25
|
+
max-width: 100%;
|
|
26
|
+
overflow-x: auto;
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
a[role="tab"] {
|
|
25
30
|
text-decoration: none;
|
|
26
31
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _compose = require("@wordpress/compose");
|
|
8
|
+
var _ui = require("@wordpress/ui");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
/**
|
|
11
|
+
* WordPress dependencies
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A badge whose tooltip explains it. The tooltip serves mouse and keyboard users;
|
|
20
|
+
* screen readers get the same text as the trigger's description, which keeps it
|
|
21
|
+
* out of the accessible name of a heading the badge sits in.
|
|
22
|
+
*/
|
|
23
|
+
var _TooltipBadge = function TooltipBadge(_ref) {
|
|
24
|
+
var label = _ref.label,
|
|
25
|
+
tooltip = _ref.tooltip,
|
|
26
|
+
_ref$intent = _ref.intent,
|
|
27
|
+
intent = _ref$intent === void 0 ? 'none' : _ref$intent;
|
|
28
|
+
var descriptionId = (0, _compose.useInstanceId)(_TooltipBadge, 'newspack-tooltip-badge');
|
|
29
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
30
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_ui.Tooltip.Root, {
|
|
31
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.Tooltip.Trigger, {
|
|
32
|
+
render: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
33
|
+
tabIndex: 0,
|
|
34
|
+
"aria-describedby": descriptionId
|
|
35
|
+
}),
|
|
36
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.Badge, {
|
|
37
|
+
intent: intent,
|
|
38
|
+
children: label
|
|
39
|
+
})
|
|
40
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.Tooltip.Popup, {
|
|
41
|
+
children: tooltip
|
|
42
|
+
})]
|
|
43
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
44
|
+
id: descriptionId,
|
|
45
|
+
hidden: true,
|
|
46
|
+
children: tooltip
|
|
47
|
+
})]
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
var _default = exports["default"] = _TooltipBadge;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _react = require("@testing-library/react");
|
|
5
|
+
var _ = _interopRequireDefault(require("./"));
|
|
6
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
|
+
/**
|
|
8
|
+
* External dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
describe('TooltipBadge', function () {
|
|
16
|
+
it('describes its focusable trigger with the tooltip text, keeping it out of a surrounding heading name', function () {
|
|
17
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsxs)("h3", {
|
|
18
|
+
children: ["Registration wall", /*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
|
|
19
|
+
label: "Overrides paid access",
|
|
20
|
+
tooltip: "This grants registered readers access.",
|
|
21
|
+
intent: "low"
|
|
22
|
+
})]
|
|
23
|
+
}));
|
|
24
|
+
expect(_react.screen.getByRole('heading', {
|
|
25
|
+
name: 'Registration wall Overrides paid access'
|
|
26
|
+
})).toBeInTheDocument();
|
|
27
|
+
var trigger = _react.screen.getByText('Overrides paid access').closest('[tabindex="0"]');
|
|
28
|
+
expect(trigger).toHaveAccessibleDescription('This grants registered readers access.');
|
|
29
|
+
});
|
|
30
|
+
});
|
package/dist/cjs/wizard/index.js
CHANGED
|
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
11
|
var _components = require("@wordpress/components");
|
|
12
|
+
var _ui = require("@wordpress/ui");
|
|
12
13
|
var _data = require("@wordpress/data");
|
|
13
14
|
var _element = require("@wordpress/element");
|
|
14
15
|
var _i18n = require("@wordpress/i18n");
|
|
@@ -114,12 +115,13 @@ var ResetHeaderData = function ResetHeaderData() {
|
|
|
114
115
|
* can read the current route and derive the active-tab breadcrumb.
|
|
115
116
|
*/
|
|
116
117
|
var WizardHeaderRegion = function WizardHeaderRegion(_ref) {
|
|
117
|
-
var _activeSection;
|
|
118
|
+
var _activeSection, _activeSection2;
|
|
118
119
|
var hideHeader = _ref.hideHeader,
|
|
119
120
|
headerText = _ref.headerText,
|
|
120
121
|
sections = _ref.sections,
|
|
121
122
|
sectionName = _ref.sectionName,
|
|
122
123
|
subTitle = _ref.subTitle,
|
|
124
|
+
headerSubTitle = _ref.headerSubTitle,
|
|
123
125
|
actions = _ref.actions,
|
|
124
126
|
wizardTabbedNavigation = _ref.tabbedNavigation,
|
|
125
127
|
children = _ref.children;
|
|
@@ -149,11 +151,19 @@ var WizardHeaderRegion = function WizardHeaderRegion(_ref) {
|
|
|
149
151
|
break;
|
|
150
152
|
}
|
|
151
153
|
}
|
|
154
|
+
|
|
155
|
+
// WizardError normally mounts inside the tab bar, so a route without one renders it itself.
|
|
152
156
|
} catch (err) {
|
|
153
157
|
_iterator.e(err);
|
|
154
158
|
} finally {
|
|
155
159
|
_iterator.f();
|
|
156
160
|
}
|
|
161
|
+
if ((_activeSection = (0, _breadcrumbsSelect.activeSection)(sections, pathname)) !== null && _activeSection !== void 0 && _activeSection.hideTabbedNavigation && tabbedNavigation) {
|
|
162
|
+
tabbedNavigation = null;
|
|
163
|
+
children = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
164
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_WizardError["default"], {}), children]
|
|
165
|
+
});
|
|
166
|
+
}
|
|
157
167
|
if (hideHeader) {
|
|
158
168
|
// Without the Page shell the tabs still own the content: it renders
|
|
159
169
|
// inside the active tab's panel.
|
|
@@ -173,10 +183,10 @@ var WizardHeaderRegion = function WizardHeaderRegion(_ref) {
|
|
|
173
183
|
// Append any render-time leaf crumb(s) the section supplied via
|
|
174
184
|
// headerData.sectionName (deduped against the current trailing label).
|
|
175
185
|
breadcrumbItems = (0, _breadcrumbsSelect.appendSectionName)(breadcrumbItems, sectionName);
|
|
176
|
-
var sectionSubTitle = (
|
|
186
|
+
var sectionSubTitle = (_activeSection2 = (0, _breadcrumbsSelect.activeSection)(sections, pathname)) === null || _activeSection2 === void 0 ? void 0 : _activeSection2.subHeaderText;
|
|
177
187
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Page, {
|
|
178
188
|
breadcrumbItems: breadcrumbItems,
|
|
179
|
-
subTitle: sectionSubTitle !== null && sectionSubTitle !== void 0 ? sectionSubTitle : subTitle,
|
|
189
|
+
subTitle: headerSubTitle || (sectionSubTitle !== null && sectionSubTitle !== void 0 ? sectionSubTitle : subTitle),
|
|
180
190
|
actions: actions,
|
|
181
191
|
tabbedNavigation: tabbedNavigation,
|
|
182
192
|
children: children
|
|
@@ -189,7 +199,7 @@ var WizardHeaderRegion = function WizardHeaderRegion(_ref) {
|
|
|
189
199
|
* @property {string} [subHeaderText] The sub-header text, optional.
|
|
190
200
|
* @property {string} [apiSlug] The API slug, optional.
|
|
191
201
|
* @property {string} [className] CSS classes, optional.
|
|
192
|
-
* @property {any[]} sections Array of sections. A section's own `subHeaderText` replaces the wizard's while it is active.
|
|
202
|
+
* @property {any[]} sections Array of sections. A section's own `subHeaderText` replaces the wizard's while it is active, and `hideTabbedNavigation` hides the tab bar on its route.
|
|
193
203
|
* Its optional `tabbedNavigation( params )` returns the tab items shown while its route matches.
|
|
194
204
|
* @property {boolean} [hasSimpleFooter] Indicates if a simple footer is used, optional.
|
|
195
205
|
* @property {() => void} [renderAboveSections] Function to render content above sections, optional.
|
|
@@ -247,7 +257,8 @@ var Wizard = function Wizard(_ref2, ref) {
|
|
|
247
257
|
sectionSize = headerData.sectionSize,
|
|
248
258
|
sectionTitle = headerData.sectionTitle,
|
|
249
259
|
sectionPrimaryAction = headerData.sectionPrimaryAction,
|
|
250
|
-
sectionSecondaryAction = headerData.sectionSecondaryAction
|
|
260
|
+
sectionSecondaryAction = headerData.sectionSecondaryAction,
|
|
261
|
+
headerSubTitle = headerData.subTitle;
|
|
251
262
|
var mainActions = actions === null || actions === void 0 ? void 0 : actions.filter(function (action) {
|
|
252
263
|
return action.type === 'primary' || action.type === 'secondary';
|
|
253
264
|
});
|
|
@@ -310,9 +321,10 @@ var Wizard = function Wizard(_ref2, ref) {
|
|
|
310
321
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
311
322
|
children: [!pluginRequirementsKnown && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
312
323
|
className: "newspack-wizard__loader",
|
|
313
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
314
|
-
|
|
315
|
-
|
|
324
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ui.Stack, {
|
|
325
|
+
direction: "column",
|
|
326
|
+
align: "center",
|
|
327
|
+
gap: "sm",
|
|
316
328
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_.Waiting, {
|
|
317
329
|
noMargin: true
|
|
318
330
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
@@ -466,6 +478,7 @@ var Wizard = function Wizard(_ref2, ref) {
|
|
|
466
478
|
sections: routedSections,
|
|
467
479
|
sectionName: sectionName,
|
|
468
480
|
subTitle: subHeaderText,
|
|
481
|
+
headerSubTitle: headerSubTitle,
|
|
469
482
|
actions: headerActions,
|
|
470
483
|
tabbedNavigation: tabbedNavigation,
|
|
471
484
|
children: content
|
|
@@ -548,4 +548,82 @@ describe('Wizard section subtitle', function () {
|
|
|
548
548
|
}
|
|
549
549
|
}, _callee1);
|
|
550
550
|
})));
|
|
551
|
+
});
|
|
552
|
+
describe('Wizard tab bar on hidden routes', function () {
|
|
553
|
+
beforeEach(function () {
|
|
554
|
+
_apiFetch["default"].mockReset();
|
|
555
|
+
_apiFetch["default"].mockResolvedValue({});
|
|
556
|
+
});
|
|
557
|
+
it('hides the tab bar on a hideTabbedNavigation route and restores it on a tab route', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
558
|
+
var _t10, _t11, _t12;
|
|
559
|
+
return _regenerator().w(function (_context10) {
|
|
560
|
+
while (1) switch (_context10.n) {
|
|
561
|
+
case 0:
|
|
562
|
+
window.location.hash = '#/list';
|
|
563
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
|
|
564
|
+
headerText: "Test wizard",
|
|
565
|
+
sections: [{
|
|
566
|
+
label: 'List',
|
|
567
|
+
path: '/list',
|
|
568
|
+
exact: true,
|
|
569
|
+
render: function render() {
|
|
570
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
571
|
+
children: "List view"
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
}, {
|
|
575
|
+
label: 'Other',
|
|
576
|
+
path: '/other',
|
|
577
|
+
exact: true,
|
|
578
|
+
render: function render() {
|
|
579
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
580
|
+
children: "Other view"
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
}, {
|
|
584
|
+
path: '/list/:id',
|
|
585
|
+
isHidden: true,
|
|
586
|
+
hideTabbedNavigation: true,
|
|
587
|
+
render: function render() {
|
|
588
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
589
|
+
children: "Item view"
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
}]
|
|
593
|
+
}));
|
|
594
|
+
_t10 = expect;
|
|
595
|
+
_context10.n = 1;
|
|
596
|
+
return _react.screen.findByText('List view');
|
|
597
|
+
case 1:
|
|
598
|
+
_t10(_context10.v).toBeInTheDocument();
|
|
599
|
+
expect(_react.screen.getByRole('tab', {
|
|
600
|
+
name: 'Other'
|
|
601
|
+
})).toBeInTheDocument();
|
|
602
|
+
(0, _react.act)(function () {
|
|
603
|
+
window.location.hash = '#/list/esp';
|
|
604
|
+
window.dispatchEvent(new HashChangeEvent('hashchange'));
|
|
605
|
+
});
|
|
606
|
+
_t11 = expect;
|
|
607
|
+
_context10.n = 2;
|
|
608
|
+
return _react.screen.findByText('Item view');
|
|
609
|
+
case 2:
|
|
610
|
+
_t11(_context10.v).toBeInTheDocument();
|
|
611
|
+
expect(_react.screen.queryByRole('tab')).not.toBeInTheDocument();
|
|
612
|
+
(0, _react.act)(function () {
|
|
613
|
+
window.location.hash = '#/list';
|
|
614
|
+
window.dispatchEvent(new HashChangeEvent('hashchange'));
|
|
615
|
+
});
|
|
616
|
+
_t12 = expect;
|
|
617
|
+
_context10.n = 3;
|
|
618
|
+
return _react.screen.findByText('List view');
|
|
619
|
+
case 3:
|
|
620
|
+
_t12(_context10.v).toBeInTheDocument();
|
|
621
|
+
expect(_react.screen.getByRole('tab', {
|
|
622
|
+
name: 'Other'
|
|
623
|
+
})).toBeInTheDocument();
|
|
624
|
+
case 4:
|
|
625
|
+
return _context10.a(2);
|
|
626
|
+
}
|
|
627
|
+
}, _callee10);
|
|
628
|
+
})));
|
|
551
629
|
});
|
|
@@ -92,6 +92,7 @@ var Breadcrumbs = function Breadcrumbs(_ref3) {
|
|
|
92
92
|
render: /*#__PURE__*/_jsx("ul", {}),
|
|
93
93
|
direction: "row",
|
|
94
94
|
align: "center",
|
|
95
|
+
wrap: "wrap",
|
|
95
96
|
className: "newspack-breadcrumbs__list",
|
|
96
97
|
children: [preceding.map(function (item, index) {
|
|
97
98
|
return /*#__PURE__*/_jsxs("li", {
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
padding: 0;
|
|
8
8
|
|
|
9
9
|
> li {
|
|
10
|
-
flex-shrink: 0;
|
|
11
10
|
margin: 0;
|
|
11
|
+
min-width: 0;
|
|
12
12
|
|
|
13
13
|
a {
|
|
14
14
|
color: wp-colors.$gray-900;
|
|
@@ -20,11 +20,6 @@
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
> li:last-child {
|
|
25
|
-
flex-shrink: 1;
|
|
26
|
-
min-width: 0;
|
|
27
|
-
}
|
|
28
23
|
}
|
|
29
24
|
|
|
30
25
|
.newspack-breadcrumbs__count {
|
|
@@ -39,9 +34,7 @@
|
|
|
39
34
|
}
|
|
40
35
|
|
|
41
36
|
.newspack-breadcrumbs__list h1.newspack-breadcrumbs__current {
|
|
42
|
-
overflow:
|
|
43
|
-
text-overflow: ellipsis;
|
|
44
|
-
white-space: nowrap;
|
|
37
|
+
overflow-wrap: break-word;
|
|
45
38
|
padding: 0;
|
|
46
|
-
line-height:
|
|
39
|
+
line-height: var(--wpds-typography-line-height-md, #{wp-vars.$grid-unit-30});
|
|
47
40
|
}
|