newspack-components 4.1.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/colors/colors.module.scss +1 -1
- package/dist/cjs/action-card/index.js +21 -12
- package/dist/cjs/action-card/style.scss +32 -14
- package/dist/cjs/autocomplete-tokenfield/index.js +2 -2
- package/dist/cjs/autocomplete-with-latest-posts/index.js +289 -0
- package/dist/cjs/autocomplete-with-latest-posts/style.scss +150 -0
- package/dist/cjs/badge/index.js +32 -0
- package/dist/cjs/badge/style.scss +36 -0
- package/dist/cjs/button/index.js +2 -0
- package/dist/cjs/card/core-card.js +141 -0
- package/dist/cjs/card/index.js +33 -0
- package/dist/cjs/card/style-core.scss +227 -0
- package/dist/cjs/card/style.scss +2 -2
- package/dist/cjs/card-settings-group/index.js +49 -0
- package/dist/cjs/card-settings-group/style.scss +33 -0
- package/dist/cjs/card-sortable-list/index.js +390 -0
- package/dist/cjs/card-sortable-list/style.scss +48 -0
- package/dist/cjs/confirm-dialog/index.js +59 -0
- package/dist/cjs/divider/index.js +42 -0
- package/dist/cjs/divider/style.scss +51 -0
- package/dist/cjs/form-token-field/style.scss +0 -5
- package/dist/cjs/grid/index.js +2 -1
- package/dist/cjs/grid/style.scss +63 -9
- package/dist/cjs/index.js +42 -0
- package/dist/cjs/modal/index.js +11 -4
- package/dist/cjs/modal/style.scss +43 -13
- package/dist/cjs/newspack-icon/style.scss +5 -3
- package/dist/cjs/popover/style.scss +1 -1
- package/dist/cjs/section-header/index.js +76 -17
- package/dist/cjs/section-header/style.scss +109 -4
- package/dist/cjs/style.scss +2 -0
- package/dist/cjs/waiting/index.js +3 -1
- package/dist/cjs/waiting/style.scss +4 -0
- package/dist/cjs/web-preview/index.js +98 -39
- package/dist/cjs/web-preview/style.scss +20 -53
- package/dist/cjs/with-wizard/index.js +1 -1
- package/dist/cjs/with-wizard/style.scss +24 -6
- package/dist/cjs/with-wizard-screen/style.scss +39 -10
- package/dist/cjs/wizard/components/WizardSnackbar.js +70 -0
- package/dist/cjs/wizard/components/style.scss +48 -0
- package/dist/cjs/wizard/index.js +97 -16
- package/dist/cjs/wizard/store/index.js +46 -0
- package/dist/esm/action-card/index.js +21 -12
- package/dist/esm/action-card/style.scss +32 -14
- package/dist/esm/autocomplete-tokenfield/index.js +2 -2
- package/dist/esm/autocomplete-with-latest-posts/index.js +281 -0
- package/dist/esm/autocomplete-with-latest-posts/style.scss +150 -0
- package/dist/esm/badge/index.js +24 -0
- package/dist/esm/badge/style.scss +36 -0
- package/dist/esm/button/index.js +2 -0
- package/dist/esm/card/core-card.js +133 -0
- package/dist/esm/card/index.js +33 -0
- package/dist/esm/card/style-core.scss +227 -0
- package/dist/esm/card/style.scss +2 -2
- package/dist/esm/card-settings-group/index.js +42 -0
- package/dist/esm/card-settings-group/style.scss +33 -0
- package/dist/esm/card-sortable-list/index.js +381 -0
- package/dist/esm/card-sortable-list/style.scss +48 -0
- package/dist/esm/confirm-dialog/index.js +49 -0
- package/dist/esm/divider/index.js +34 -0
- package/dist/esm/divider/style.scss +51 -0
- package/dist/esm/form-token-field/style.scss +0 -5
- package/dist/esm/grid/index.js +2 -1
- package/dist/esm/grid/style.scss +63 -9
- package/dist/esm/index.js +6 -0
- package/dist/esm/modal/index.js +11 -4
- package/dist/esm/modal/style.scss +43 -13
- package/dist/esm/newspack-icon/style.scss +5 -3
- package/dist/esm/popover/style.scss +1 -1
- package/dist/esm/section-header/index.js +75 -18
- package/dist/esm/section-header/style.scss +109 -4
- package/dist/esm/style.scss +2 -0
- package/dist/esm/waiting/index.js +3 -1
- package/dist/esm/waiting/style.scss +4 -0
- package/dist/esm/web-preview/index.js +101 -42
- package/dist/esm/web-preview/style.scss +20 -53
- package/dist/esm/with-wizard/index.js +1 -1
- package/dist/esm/with-wizard/style.scss +24 -6
- package/dist/esm/with-wizard-screen/style.scss +39 -10
- package/dist/esm/wizard/components/WizardSnackbar.js +64 -0
- package/dist/esm/wizard/components/style.scss +48 -0
- package/dist/esm/wizard/index.js +101 -20
- package/dist/esm/wizard/store/index.js +46 -0
- package/package.json +5 -6
- package/shared/author-context.js +26 -0
- package/shared/hooks/use-coauthors.js +220 -0
- package/shared/hooks/use-coauthors.test.js +624 -0
- package/shared/hooks/use-custom-byline.js +47 -0
- package/shared/hooks/use-custom-byline.test.js +133 -0
- package/shared/scss/_mixins.scss +46 -0
- package/src/action-card/action-card.d.ts +7 -3
- package/src/action-card/index.js +24 -11
- package/src/action-card/style.scss +32 -14
- package/src/autocomplete-tokenfield/index.js +2 -2
- package/src/autocomplete-with-latest-posts/index.js +290 -0
- package/src/autocomplete-with-latest-posts/style.scss +150 -0
- package/src/badge/index.tsx +24 -0
- package/src/badge/style.scss +36 -0
- package/src/button/index.tsx +3 -2
- package/src/card/core-card.js +147 -0
- package/src/card/index.js +39 -1
- package/src/card/style-core.scss +227 -0
- package/src/card/style.scss +2 -2
- package/src/card-settings-group/README.md +43 -0
- package/src/card-settings-group/index.tsx +53 -0
- package/src/card-settings-group/style.scss +33 -0
- package/src/card-sortable-list/README.md +51 -0
- package/src/card-sortable-list/index.tsx +412 -0
- package/src/card-sortable-list/style.scss +48 -0
- package/src/confirm-dialog/index.tsx +64 -0
- package/src/divider/README.md +25 -0
- package/src/divider/index.js +31 -0
- package/src/divider/style.scss +51 -0
- package/src/form-token-field/style.scss +0 -5
- package/src/grid/index.tsx +2 -1
- package/src/grid/style.scss +63 -9
- package/src/index.js +6 -0
- package/src/modal/index.js +12 -3
- package/src/modal/style.scss +43 -13
- package/src/newspack-icon/style.scss +5 -3
- package/src/popover/style.scss +1 -1
- package/src/section-header/index.js +72 -13
- package/src/section-header/style.scss +109 -4
- package/src/style.scss +2 -0
- package/src/waiting/index.js +2 -1
- package/src/waiting/style.scss +4 -0
- package/src/web-preview/index.js +90 -35
- package/src/web-preview/style.scss +20 -53
- package/src/with-wizard/index.js +1 -1
- package/src/with-wizard/style.scss +24 -6
- package/src/with-wizard-screen/style.scss +39 -10
- package/src/wizard/components/WizardSnackbar.js +58 -0
- package/src/wizard/components/style.scss +48 -0
- package/src/wizard/index.js +108 -14
- package/src/wizard/store/index.js +26 -0
package/dist/cjs/wizard/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _components = require("@wordpress/components");
|
|
9
10
|
var _data = require("@wordpress/data");
|
|
10
11
|
var _element = require("@wordpress/element");
|
|
11
12
|
var _i18n = require("@wordpress/i18n");
|
|
@@ -13,6 +14,7 @@ var _icons = require("@wordpress/icons");
|
|
|
13
14
|
var _ = require("../");
|
|
14
15
|
var _router = _interopRequireDefault(require("../proxied-imports/router"));
|
|
15
16
|
var _store = _interopRequireWildcard(require("./store"));
|
|
17
|
+
var _WizardSnackbar = _interopRequireDefault(require("./components/WizardSnackbar"));
|
|
16
18
|
var _WizardError = _interopRequireDefault(require("./components/WizardError"));
|
|
17
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -33,9 +35,24 @@ const {
|
|
|
33
35
|
HashRouter,
|
|
34
36
|
Redirect,
|
|
35
37
|
Route,
|
|
36
|
-
Switch
|
|
38
|
+
Switch,
|
|
39
|
+
useLocation
|
|
37
40
|
} = _router.default;
|
|
38
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Reset the header data when a new section is rendered.
|
|
44
|
+
*/
|
|
45
|
+
const ResetHeaderData = () => {
|
|
46
|
+
const location = useLocation();
|
|
47
|
+
const {
|
|
48
|
+
resetHeaderData
|
|
49
|
+
} = (0, _data.useDispatch)(_store.WIZARD_STORE_NAMESPACE);
|
|
50
|
+
(0, _element.useEffect)(() => {
|
|
51
|
+
resetHeaderData();
|
|
52
|
+
}, [location.pathname, resetHeaderData]);
|
|
53
|
+
return null;
|
|
54
|
+
};
|
|
55
|
+
|
|
39
56
|
/**
|
|
40
57
|
* @typedef {Object} WizardProps
|
|
41
58
|
* @property {string} headerText The header text.
|
|
@@ -61,15 +78,31 @@ const Wizard = ({
|
|
|
61
78
|
sections = [],
|
|
62
79
|
headerText,
|
|
63
80
|
apiSlug,
|
|
81
|
+
sharedProps = {},
|
|
64
82
|
subHeaderText,
|
|
65
83
|
hasSimpleFooter,
|
|
66
84
|
className,
|
|
67
85
|
renderAboveSections,
|
|
68
86
|
requiredPlugins = [],
|
|
69
|
-
isInitialFetchTriggered = true
|
|
87
|
+
isInitialFetchTriggered = true,
|
|
88
|
+
fixedHeader = false
|
|
70
89
|
}, ref) => {
|
|
71
90
|
const isLoading = (0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).isLoading());
|
|
72
91
|
const isQuietLoading = (0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).isQuietLoading());
|
|
92
|
+
const headerData = (0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).getHeaderData());
|
|
93
|
+
const notices = (0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).getNotices());
|
|
94
|
+
const {
|
|
95
|
+
actions,
|
|
96
|
+
backNav,
|
|
97
|
+
badges,
|
|
98
|
+
sectionDescription,
|
|
99
|
+
sectionName,
|
|
100
|
+
sectionTitle,
|
|
101
|
+
sectionPrimaryAction,
|
|
102
|
+
sectionSecondaryAction
|
|
103
|
+
} = headerData;
|
|
104
|
+
const mainActions = actions?.filter(action => action.type === 'primary' || action.type === 'secondary');
|
|
105
|
+
const moreActions = actions?.filter(action => action.type === 'more');
|
|
73
106
|
|
|
74
107
|
// Trigger initial data fetch. Some sections might not use the wizard data,
|
|
75
108
|
// but for consistency, fetching is triggered regardless of the section.
|
|
@@ -91,17 +124,18 @@ const Wizard = ({
|
|
|
91
124
|
const urlWithoutHash = window.location.href.split('#')[0];
|
|
92
125
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
93
126
|
ref: ref,
|
|
94
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.
|
|
127
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
95
128
|
className: (0, _classnames.default)(isLoading ? 'newspack-wizard__is-loading' : 'newspack-wizard__is-loaded', {
|
|
96
|
-
'newspack-wizard__is-loading-quiet': isQuietLoading
|
|
129
|
+
'newspack-wizard__is-loading-quiet': isQuietLoading,
|
|
130
|
+
'newspack-wizard__fixed-header': fixedHeader
|
|
97
131
|
}),
|
|
98
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(HashRouter, {
|
|
132
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(HashRouter, {
|
|
99
133
|
hashType: "slash",
|
|
100
134
|
children: [newspack_aux_data.is_debug_mode && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Notice, {
|
|
101
135
|
debugMode: true
|
|
102
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
103
|
-
className: "
|
|
104
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
136
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
137
|
+
className: "newspack-wizard__header",
|
|
138
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
105
139
|
className: "newspack-wizard__header__inner",
|
|
106
140
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
107
141
|
className: "newspack-wizard__title",
|
|
@@ -118,34 +152,81 @@ const Wizard = ({
|
|
|
118
152
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_.NewspackIcon, {
|
|
119
153
|
size: 36
|
|
120
154
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
121
|
-
children: [headerText && /*#__PURE__*/(0, _jsxRuntime.
|
|
122
|
-
|
|
155
|
+
children: [headerText && /*#__PURE__*/(0, _jsxRuntime.jsxs)("h2", {
|
|
156
|
+
className: "newspack-wizard__header__title",
|
|
157
|
+
children: [headerText, sectionName && /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
158
|
+
className: "newspack-wizard__header__section",
|
|
159
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
160
|
+
className: "newspack-wizard__header__section__separator",
|
|
161
|
+
children: " / "
|
|
162
|
+
}), " ", sectionName]
|
|
163
|
+
})]
|
|
123
164
|
}), subHeaderText && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
124
165
|
children: subHeaderText
|
|
125
166
|
})]
|
|
126
167
|
})]
|
|
127
168
|
})
|
|
128
|
-
})
|
|
169
|
+
}), actions?.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
170
|
+
className: "newspack-wizard__header__actions",
|
|
171
|
+
children: [mainActions.map((action, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
|
|
172
|
+
icon: action.icon,
|
|
173
|
+
variant: action.type,
|
|
174
|
+
onClick: action.action,
|
|
175
|
+
disabled: action.disabled || false,
|
|
176
|
+
isDestructive: action.destructive || false,
|
|
177
|
+
children: action.label
|
|
178
|
+
}, index)), moreActions.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.DropdownMenu, {
|
|
179
|
+
icon: _icons.moreVertical,
|
|
180
|
+
label: (0, _i18n.__)('More', 'newspack-plugin'),
|
|
181
|
+
children: () => moreActions.map((action, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
|
|
182
|
+
icon: action.icon,
|
|
183
|
+
onClick: action.action,
|
|
184
|
+
disabled: action.disabled || false,
|
|
185
|
+
isDestructive: action.destructive || false,
|
|
186
|
+
children: action.label
|
|
187
|
+
}, index))
|
|
188
|
+
})]
|
|
189
|
+
})]
|
|
129
190
|
}), displayedSections.length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.TabbedNavigation, {
|
|
130
191
|
items: displayedSections,
|
|
131
192
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_WizardError.default, {})
|
|
132
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_.HandoffMessage, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Switch, {
|
|
133
|
-
children: [
|
|
193
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_.HandoffMessage, {}), sections.length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(ResetHeaderData, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Switch, {
|
|
194
|
+
children: [sections.map((section, index) => {
|
|
134
195
|
var _section$exact;
|
|
135
196
|
const SectionComponent = section.render;
|
|
197
|
+
const sectionProps = section.props || {};
|
|
136
198
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Route, {
|
|
137
199
|
exact: (_section$exact = section.exact) !== null && _section$exact !== void 0 ? _section$exact : false,
|
|
138
200
|
path: section.path,
|
|
139
|
-
|
|
201
|
+
render: routerProps => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
140
202
|
className: (0, _classnames.default)('newspack-wizard__content', className),
|
|
141
|
-
children: ['function' === typeof renderAboveSections ? renderAboveSections() : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
203
|
+
children: ['function' === typeof renderAboveSections ? renderAboveSections() : null, (sectionTitle || section.title) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.SectionHeader, {
|
|
204
|
+
className: "newspack-wizard__section-header",
|
|
205
|
+
backNav: backNav || section.backNav,
|
|
206
|
+
title: sectionTitle || section.title,
|
|
207
|
+
description: sectionDescription || section.description,
|
|
208
|
+
badges: badges || section.badges,
|
|
209
|
+
primaryAction: sectionPrimaryAction || section.primaryAction,
|
|
210
|
+
secondaryAction: sectionSecondaryAction || section.secondaryAction,
|
|
211
|
+
heading: 1,
|
|
212
|
+
noMargin: true
|
|
213
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(SectionComponent, {
|
|
214
|
+
...routerProps,
|
|
215
|
+
...sectionProps,
|
|
216
|
+
...sharedProps
|
|
217
|
+
})]
|
|
142
218
|
})
|
|
143
219
|
}, index);
|
|
144
220
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Redirect, {
|
|
145
221
|
to: displayedSections[0].path
|
|
146
222
|
})]
|
|
147
223
|
})]
|
|
148
|
-
})
|
|
224
|
+
}), notices?.length > 0 && notices.map((notice, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_WizardSnackbar.default, {
|
|
225
|
+
type: notice.type,
|
|
226
|
+
id: notice.id,
|
|
227
|
+
actions: notice.actions,
|
|
228
|
+
children: notice.message
|
|
229
|
+
}, notice.id || index))]
|
|
149
230
|
}), !isLoading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Footer, {
|
|
150
231
|
simple: hasSimpleFooter
|
|
151
232
|
})]
|
|
@@ -21,9 +21,18 @@ var _utils = require("./utils.js");
|
|
|
21
21
|
|
|
22
22
|
const WIZARD_STORE_NAMESPACE = exports.WIZARD_STORE_NAMESPACE = 'newspack/wizards';
|
|
23
23
|
const DEFAULT_STATE = {
|
|
24
|
+
headerData: {
|
|
25
|
+
actions: [],
|
|
26
|
+
backNav: '',
|
|
27
|
+
badges: [],
|
|
28
|
+
sectionDescription: '',
|
|
29
|
+
sectionName: '',
|
|
30
|
+
sectionTitle: ''
|
|
31
|
+
},
|
|
24
32
|
isLoading: false,
|
|
25
33
|
isQuietLoading: false,
|
|
26
34
|
apiData: {},
|
|
35
|
+
notices: [],
|
|
27
36
|
error: null
|
|
28
37
|
};
|
|
29
38
|
|
|
@@ -38,6 +47,21 @@ const reducer = (state = DEFAULT_STATE, {
|
|
|
38
47
|
payload = {}
|
|
39
48
|
}) => {
|
|
40
49
|
switch (type) {
|
|
50
|
+
case 'SET_HEADER_DATA':
|
|
51
|
+
return {
|
|
52
|
+
...state,
|
|
53
|
+
headerData: {
|
|
54
|
+
...state.headerData,
|
|
55
|
+
...payload
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
case 'RESET_HEADER_DATA':
|
|
59
|
+
return {
|
|
60
|
+
...state,
|
|
61
|
+
headerData: {
|
|
62
|
+
...DEFAULT_STATE.headerData
|
|
63
|
+
}
|
|
64
|
+
};
|
|
41
65
|
case 'START_LOADING_DATA':
|
|
42
66
|
if (payload.isQuietLoading) {
|
|
43
67
|
return {
|
|
@@ -59,22 +83,42 @@ const reducer = (state = DEFAULT_STATE, {
|
|
|
59
83
|
return (0, _set.default)(clone(state), ['apiData', payload.slug], payload.data);
|
|
60
84
|
case 'UPDATE_WIZARD_SETTINGS':
|
|
61
85
|
return (0, _set.default)(clone(state), ['apiData', payload.slug, ...payload.path], payload.value);
|
|
86
|
+
case 'ADD_NOTICE':
|
|
87
|
+
return {
|
|
88
|
+
...state,
|
|
89
|
+
notices: [...state.notices, payload]
|
|
90
|
+
};
|
|
91
|
+
case 'REMOVE_NOTICE':
|
|
92
|
+
return {
|
|
93
|
+
...state,
|
|
94
|
+
notices: state.notices.filter(notice => notice.id !== payload)
|
|
95
|
+
};
|
|
62
96
|
case 'SET_ERROR':
|
|
63
97
|
return {
|
|
64
98
|
...state,
|
|
65
99
|
error: payload
|
|
66
100
|
};
|
|
101
|
+
case 'RESET_NOTICES':
|
|
102
|
+
return {
|
|
103
|
+
...state,
|
|
104
|
+
notices: DEFAULT_STATE.notices
|
|
105
|
+
};
|
|
67
106
|
default:
|
|
68
107
|
return state;
|
|
69
108
|
}
|
|
70
109
|
};
|
|
71
110
|
const actions = {
|
|
72
111
|
// Regular actions.
|
|
112
|
+
setHeaderData: (0, _utils.createAction)('SET_HEADER_DATA'),
|
|
113
|
+
resetHeaderData: (0, _utils.createAction)('RESET_HEADER_DATA'),
|
|
73
114
|
startLoadingData: (0, _utils.createAction)('START_LOADING_DATA'),
|
|
74
115
|
finishLoadingData: (0, _utils.createAction)('FINISH_LOADING_DATA'),
|
|
75
116
|
fetchFromAPI: (0, _utils.createAction)('FETCH_FROM_API'),
|
|
76
117
|
setAPIDataForWizard: (0, _utils.createAction)('SET_API_DATA'),
|
|
77
118
|
updateWizardSettings: (0, _utils.createAction)('UPDATE_WIZARD_SETTINGS'),
|
|
119
|
+
addNotice: (0, _utils.createAction)('ADD_NOTICE'),
|
|
120
|
+
removeNotice: (0, _utils.createAction)('REMOVE_NOTICE'),
|
|
121
|
+
resetNotices: (0, _utils.createAction)('RESET_NOTICES'),
|
|
78
122
|
setError: (0, _utils.createAction)('SET_ERROR'),
|
|
79
123
|
// Async actions. These will not show up in Redux devtools.
|
|
80
124
|
*saveWizardSettings({
|
|
@@ -117,6 +161,7 @@ const actions = {
|
|
|
117
161
|
}
|
|
118
162
|
};
|
|
119
163
|
const selectors = {
|
|
164
|
+
getHeaderData: state => state.headerData,
|
|
120
165
|
isLoading: state => state.isLoading,
|
|
121
166
|
isQuietLoading: state => state.isQuietLoading,
|
|
122
167
|
getWizardAPIData: (state, slug) => state.apiData[slug] || {},
|
|
@@ -124,6 +169,7 @@ const selectors = {
|
|
|
124
169
|
var _state$apiData$slug;
|
|
125
170
|
return (_state$apiData$slug = state.apiData[slug]) !== null && _state$apiData$slug !== void 0 ? _state$apiData$slug : {};
|
|
126
171
|
},
|
|
172
|
+
getNotices: state => state.notices,
|
|
127
173
|
getError: state => state.error
|
|
128
174
|
};
|
|
129
175
|
const store = (0, _data.createReduxStore)(WIZARD_STORE_NAMESPACE, {
|
|
@@ -29,13 +29,14 @@ import classnames from 'classnames';
|
|
|
29
29
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
30
30
|
const ActionCard = ({
|
|
31
31
|
badge,
|
|
32
|
-
badgeLevel
|
|
32
|
+
badgeLevel,
|
|
33
33
|
className,
|
|
34
34
|
checkbox,
|
|
35
35
|
children,
|
|
36
36
|
collapse,
|
|
37
37
|
disabled,
|
|
38
38
|
title,
|
|
39
|
+
heading = 2,
|
|
39
40
|
description,
|
|
40
41
|
handoff,
|
|
41
42
|
editLink,
|
|
@@ -60,11 +61,13 @@ const ActionCard = ({
|
|
|
60
61
|
titleLink,
|
|
61
62
|
toggleChecked = false,
|
|
62
63
|
toggleOnChange,
|
|
64
|
+
togglePosition = 'leading',
|
|
63
65
|
hasGreyHeader,
|
|
64
66
|
hasWhiteHeader,
|
|
65
67
|
noBorder,
|
|
66
68
|
isPending,
|
|
67
69
|
expandable = false,
|
|
70
|
+
isExpanded,
|
|
68
71
|
isButtonEnabled = false,
|
|
69
72
|
// Draggable props. All are required to enable drag sorting.
|
|
70
73
|
draggable = false,
|
|
@@ -72,10 +75,15 @@ const ActionCard = ({
|
|
|
72
75
|
dragWrapperRef,
|
|
73
76
|
onDragCallback
|
|
74
77
|
}) => {
|
|
75
|
-
const [expanded, setExpanded] = useState(
|
|
78
|
+
const [expanded, setExpanded] = useState(Boolean(isExpanded));
|
|
76
79
|
const [dragging, setDragging] = useState(false);
|
|
77
80
|
const [targetIndex, setTargetIndex] = useState(null);
|
|
78
81
|
const [dragRef, setDragRef] = useState(null);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (typeof isExpanded === 'boolean') {
|
|
84
|
+
setExpanded(isExpanded);
|
|
85
|
+
}
|
|
86
|
+
}, [isExpanded]);
|
|
79
87
|
useEffect(() => {
|
|
80
88
|
if (dragWrapperRef && !dragRef) {
|
|
81
89
|
setDragRef(dragWrapperRef);
|
|
@@ -97,16 +105,19 @@ const ActionCard = ({
|
|
|
97
105
|
onClick: () => toggleOnChange(!toggleChecked),
|
|
98
106
|
tabIndex: '0'
|
|
99
107
|
} : {};
|
|
108
|
+
const togglePositionClass = togglePosition === 'trailing' ? 'is-toggle-trailing' : 'is-toggle-leading';
|
|
100
109
|
const hasInternalLink = href && href.indexOf('http') !== 0;
|
|
101
110
|
const isDisplayingSecondaryAction = secondaryActionText && onSecondaryActionClick;
|
|
102
111
|
const badges = !Array.isArray(badge) && badge ? [badge] : badge;
|
|
103
|
-
const
|
|
112
|
+
const HeadingTag = `h${heading}`;
|
|
113
|
+
const cardContent = /*#__PURE__*/_jsxs(_Fragment, {
|
|
104
114
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
105
115
|
className: "newspack-action-card__region newspack-action-card__region-top",
|
|
106
116
|
children: [toggleOnChange && /*#__PURE__*/_jsx(ToggleControl, {
|
|
107
117
|
checked: toggleChecked,
|
|
108
118
|
onChange: toggleOnChange,
|
|
109
|
-
disabled: disabled
|
|
119
|
+
disabled: disabled,
|
|
120
|
+
className: togglePositionClass
|
|
110
121
|
}), image && !toggleOnChange && /*#__PURE__*/_jsx("div", {
|
|
111
122
|
className: "newspack-action-card__region newspack-action-card__region-left",
|
|
112
123
|
children: /*#__PURE__*/_jsx("a", {
|
|
@@ -130,7 +141,7 @@ const ActionCard = ({
|
|
|
130
141
|
columns: 1,
|
|
131
142
|
gutter: 8,
|
|
132
143
|
noMargin: true,
|
|
133
|
-
children: [/*#__PURE__*/_jsxs(
|
|
144
|
+
children: [/*#__PURE__*/_jsxs(HeadingTag, {
|
|
134
145
|
children: [/*#__PURE__*/_jsxs("span", {
|
|
135
146
|
className: "newspack-action-card__title",
|
|
136
147
|
...titleProps,
|
|
@@ -207,10 +218,10 @@ const ActionCard = ({
|
|
|
207
218
|
isWarning: true,
|
|
208
219
|
rawHTML: notificationHTML
|
|
209
220
|
})]
|
|
210
|
-
}), children && (expandable && expanded || !expandable)
|
|
221
|
+
}), children && (expandable && expanded || !expandable) ? /*#__PURE__*/_jsx("div", {
|
|
211
222
|
className: "newspack-action-card__region-children",
|
|
212
223
|
children: children
|
|
213
|
-
})]
|
|
224
|
+
}) : null]
|
|
214
225
|
});
|
|
215
226
|
if (draggable && dragRef?.current && typeof dragIndex === 'number' && onDragCallback && id) {
|
|
216
227
|
let wrapperRect = dragRef.current.getBoundingClientRect();
|
|
@@ -281,9 +292,7 @@ const ActionCard = ({
|
|
|
281
292
|
onDragStart: onDraggableStart,
|
|
282
293
|
onDragEnd: onDraggableEnd,
|
|
283
294
|
children: /*#__PURE__*/_jsx(Icon, {
|
|
284
|
-
icon: dragHandle
|
|
285
|
-
height: 18,
|
|
286
|
-
width: 18
|
|
295
|
+
icon: dragHandle
|
|
287
296
|
})
|
|
288
297
|
}), /*#__PURE__*/_jsxs("div", {
|
|
289
298
|
className: "movers",
|
|
@@ -299,7 +308,7 @@ const ActionCard = ({
|
|
|
299
308
|
label: __('Move one position down', 'newspack-plugin')
|
|
300
309
|
})]
|
|
301
310
|
})]
|
|
302
|
-
}),
|
|
311
|
+
}), cardContent]
|
|
303
312
|
})
|
|
304
313
|
})
|
|
305
314
|
});
|
|
@@ -309,7 +318,7 @@ const ActionCard = ({
|
|
|
309
318
|
onClick: simple && onClick,
|
|
310
319
|
id: id !== null && id !== void 0 ? id : null,
|
|
311
320
|
noBorder: noBorder,
|
|
312
|
-
children:
|
|
321
|
+
children: cardContent
|
|
313
322
|
});
|
|
314
323
|
};
|
|
315
324
|
export default ActionCard;
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
.components-toggle-control {
|
|
56
56
|
margin-bottom: 16px;
|
|
57
57
|
|
|
58
|
-
@media screen and (
|
|
58
|
+
@media screen and (min-width: 744px) {
|
|
59
59
|
margin-bottom: 0;
|
|
60
60
|
margin-right: 16px;
|
|
61
61
|
}
|
|
@@ -77,10 +77,6 @@
|
|
|
77
77
|
padding: 0 4px;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
& + & {
|
|
81
|
-
margin-top: -16px;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
80
|
&.mv0 {
|
|
85
81
|
border-left-color: wp-colors.$gray-300;
|
|
86
82
|
border-radius: 0;
|
|
@@ -122,7 +118,7 @@
|
|
|
122
118
|
.components-toggle-control {
|
|
123
119
|
margin-bottom: 16px;
|
|
124
120
|
|
|
125
|
-
@media screen and (
|
|
121
|
+
@media screen and (min-width: 744px) {
|
|
126
122
|
margin-bottom: 0;
|
|
127
123
|
margin-right: 16px;
|
|
128
124
|
}
|
|
@@ -132,7 +128,7 @@
|
|
|
132
128
|
.newspack-action-card__region-left {
|
|
133
129
|
margin-bottom: 16px;
|
|
134
130
|
|
|
135
|
-
@media screen and (
|
|
131
|
+
@media screen and (min-width: 744px) {
|
|
136
132
|
margin-bottom: 0;
|
|
137
133
|
margin-right: 16px;
|
|
138
134
|
}
|
|
@@ -252,7 +248,7 @@
|
|
|
252
248
|
padding: 24px;
|
|
253
249
|
display: block;
|
|
254
250
|
|
|
255
|
-
@media screen and (
|
|
251
|
+
@media screen and (min-width: 744px) {
|
|
256
252
|
display: flex;
|
|
257
253
|
}
|
|
258
254
|
|
|
@@ -261,9 +257,19 @@
|
|
|
261
257
|
margin-bottom: 24px;
|
|
262
258
|
margin-top: 0;
|
|
263
259
|
|
|
264
|
-
@media screen and (
|
|
260
|
+
@media screen and (min-width: 744px) {
|
|
265
261
|
margin-bottom: 0;
|
|
266
262
|
margin-right: 24px;
|
|
263
|
+
|
|
264
|
+
&.is-toggle-trailing {
|
|
265
|
+
margin-left: 24px;
|
|
266
|
+
margin-right: 0;
|
|
267
|
+
order: 999;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
label {
|
|
272
|
+
display: none;
|
|
267
273
|
}
|
|
268
274
|
|
|
269
275
|
.components-base-control__field {
|
|
@@ -308,7 +314,7 @@
|
|
|
308
314
|
.newspack-action-card__region-left {
|
|
309
315
|
margin-bottom: 24px;
|
|
310
316
|
|
|
311
|
-
@media screen and (
|
|
317
|
+
@media screen and (min-width: 744px) {
|
|
312
318
|
margin-bottom: 0;
|
|
313
319
|
margin-right: 24px;
|
|
314
320
|
}
|
|
@@ -335,7 +341,7 @@
|
|
|
335
341
|
margin-top: 24px;
|
|
336
342
|
text-align: right;
|
|
337
343
|
|
|
338
|
-
@media screen and (
|
|
344
|
+
@media screen and (min-width: 744px) {
|
|
339
345
|
align-items: flex-end;
|
|
340
346
|
flex-direction: column;
|
|
341
347
|
margin-left: 24px;
|
|
@@ -437,13 +443,21 @@
|
|
|
437
443
|
text-decoration: inherit;
|
|
438
444
|
}
|
|
439
445
|
|
|
440
|
-
.newspack-action-card__region-children {
|
|
441
|
-
border-top: 1px solid wp-colors.$gray-
|
|
446
|
+
> .newspack-action-card__region-children {
|
|
447
|
+
border-top: 1px solid wp-colors.$gray-300;
|
|
442
448
|
padding-top: 24px;
|
|
443
449
|
|
|
444
450
|
+ .newspack-action-card__region-children {
|
|
445
451
|
border-top: none;
|
|
446
452
|
}
|
|
453
|
+
|
|
454
|
+
> * + * {
|
|
455
|
+
margin-top: 24px !important;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.newspack-action-card__region-children:has(> div:not(:empty)) {
|
|
459
|
+
margin-top: 16px;
|
|
460
|
+
}
|
|
447
461
|
}
|
|
448
462
|
|
|
449
463
|
&.is-medium .newspack-action-card__region-children {
|
|
@@ -473,6 +487,11 @@
|
|
|
473
487
|
margin-left: 8px;
|
|
474
488
|
}
|
|
475
489
|
}
|
|
490
|
+
|
|
491
|
+
hr:not(.newspack-divider) {
|
|
492
|
+
background: wp-colors.$gray-100;
|
|
493
|
+
margin: 0;
|
|
494
|
+
}
|
|
476
495
|
}
|
|
477
496
|
|
|
478
497
|
.newspack-card {
|
|
@@ -557,7 +576,6 @@
|
|
|
557
576
|
}
|
|
558
577
|
|
|
559
578
|
.newspack-action-card__region-top {
|
|
560
|
-
flex: 1 1 auto;
|
|
561
579
|
padding: 8px 16px 8px 0 !important;
|
|
562
580
|
flex: 1;
|
|
563
581
|
}
|
|
@@ -137,7 +137,7 @@ class AutocompleteTokenField extends Component {
|
|
|
137
137
|
Object.keys(validValues).forEach(key => {
|
|
138
138
|
if (validValues[key] === label) {
|
|
139
139
|
// Preserve numeric or string type of values. Object.keys will convert numbers to strings.
|
|
140
|
-
const value =
|
|
140
|
+
const value = /^\d+$/.test(key.toString()) ? parseInt(key) : key.toString();
|
|
141
141
|
acc.push({
|
|
142
142
|
value,
|
|
143
143
|
label
|
|
@@ -147,7 +147,7 @@ class AutocompleteTokenField extends Component {
|
|
|
147
147
|
return acc;
|
|
148
148
|
}, []);
|
|
149
149
|
}
|
|
150
|
-
return labels.map(label => Object.keys(validValues).map(key =>
|
|
150
|
+
return labels.map(label => Object.keys(validValues).map(key => /^\d+$/.test(key.toString()) ? parseInt(key) : key.toString()).find(key => validValues[key] === label));
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|