newspack-components 2.0.3 → 2.2.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/copy-styles.js +1 -1
- package/dist/cjs/accordion/index.js +46 -0
- package/dist/cjs/accordion/style.scss +27 -0
- package/dist/cjs/action-card/index.js +72 -40
- package/dist/cjs/action-card/style.scss +143 -41
- package/dist/cjs/autocomplete-tokenfield/index.js +13 -41
- package/dist/cjs/autocomplete-tokenfield/style.scss +6 -6
- package/dist/cjs/autocomplete-with-suggestions/index.js +33 -53
- package/dist/cjs/autocomplete-with-suggestions/style.scss +27 -27
- package/dist/cjs/button/index.js +1 -20
- package/dist/cjs/button/style.scss +3 -344
- package/dist/cjs/button-card/index.js +11 -15
- package/dist/cjs/button-card/style.scss +65 -35
- package/dist/cjs/card/index.js +4 -9
- package/dist/cjs/card/style.scss +47 -63
- package/dist/cjs/category-autocomplete/index.js +66 -47
- package/dist/cjs/category-autocomplete/style.scss +20 -24
- package/dist/cjs/color-picker/index.js +16 -48
- package/dist/cjs/color-picker/style.scss +20 -163
- package/dist/cjs/consts.js +5 -3
- package/dist/cjs/custom-select-control/index.js +1 -9
- package/dist/cjs/custom-select-control/style.scss +14 -45
- package/dist/cjs/date-range-picker/index.js +1 -10
- package/dist/cjs/date-range-picker/style.scss +12 -12
- package/dist/cjs/footer/index.js +24 -22
- package/dist/cjs/footer/style.scss +13 -14
- package/dist/cjs/form-token-field/index.js +3 -11
- package/dist/cjs/form-token-field/style.scss +9 -105
- package/dist/cjs/global-notices/index.js +3 -9
- package/dist/cjs/grid/index.js +1 -8
- package/dist/cjs/grid/style.scss +19 -6
- package/dist/cjs/handoff/index.js +15 -24
- package/dist/cjs/handoff-message/index.js +50 -0
- package/dist/cjs/hooks/index.js +1 -7
- package/dist/cjs/hooks/useObjectState.js +7 -13
- package/dist/cjs/hooks/useObjectState.test.js +0 -14
- package/dist/cjs/hooks/useOnClickOutside.js +3 -6
- package/dist/cjs/hooks/usePrompt.js +1 -13
- package/dist/cjs/image-upload/index.js +22 -20
- package/dist/cjs/image-upload/index.test.js +0 -5
- package/dist/cjs/image-upload/style.scss +12 -17
- package/dist/cjs/index.js +31 -93
- package/dist/cjs/info-button/index.js +3 -11
- package/dist/cjs/info-button/style.scss +1 -3
- package/dist/cjs/modal/index.js +1 -12
- package/dist/cjs/modal/style.scss +20 -132
- package/dist/cjs/newspack-icon/index.js +5 -11
- package/dist/cjs/newspack-icon/style.scss +17 -2
- package/dist/cjs/newspack-logo/index.js +1 -9
- package/dist/cjs/newspack-logo/style.scss +3 -3
- package/dist/cjs/notice/index.js +8 -16
- package/dist/cjs/notice/style.scss +60 -19
- package/dist/cjs/patrons-logo/index.js +3 -11
- package/dist/cjs/plugin-installer/index.js +37 -37
- package/dist/cjs/plugin-installer/style.scss +5 -5
- package/dist/cjs/plugin-settings/SettingsSection.js +71 -59
- package/dist/cjs/plugin-settings/index.js +71 -50
- package/dist/cjs/plugin-settings/style.scss +7 -0
- package/dist/cjs/plugin-toggle/index.js +60 -32
- package/dist/cjs/plugin-toggle/style.scss +2 -2
- package/dist/cjs/popover/index.js +1 -11
- package/dist/cjs/popover/style.scss +20 -17
- package/dist/cjs/position-control/index.js +113 -0
- package/dist/cjs/position-control/style.scss +66 -0
- package/dist/cjs/progress-bar/index.js +2 -9
- package/dist/cjs/progress-bar/index.test.js +2 -7
- package/dist/cjs/progress-bar/style.scss +4 -4
- package/dist/cjs/proxied-imports/router.js +0 -3
- package/dist/cjs/radio-control/index.js +1 -11
- package/dist/cjs/radio-control/style.scss +10 -11
- package/dist/cjs/section-header/index.js +47 -19
- package/dist/cjs/section-header/style.scss +22 -1
- package/dist/cjs/select-control/ButtonGroupControl.js +11 -20
- package/dist/cjs/select-control/GroupedSelectControl.js +42 -45
- package/dist/cjs/select-control/index.js +6 -14
- package/dist/cjs/select-control/style.scss +47 -88
- package/dist/cjs/settings/MinMaxSetting.js +6 -8
- package/dist/cjs/settings/SettingsCard.js +9 -8
- package/dist/cjs/settings/SettingsSection.js +5 -8
- package/dist/cjs/settings/index.js +0 -6
- package/dist/cjs/settings/style.scss +32 -4
- package/dist/cjs/steps-list/index.js +52 -0
- package/dist/cjs/steps-list/style.scss +11 -0
- package/dist/cjs/steps-list-item/index.js +56 -0
- package/dist/cjs/steps-list-item/style.scss +47 -0
- package/dist/cjs/style-card/index.js +15 -18
- package/dist/cjs/style-card/style.scss +19 -18
- package/dist/cjs/style.scss +43 -0
- package/dist/cjs/tabbed-navigation/index.js +27 -31
- package/dist/cjs/tabbed-navigation/style.scss +58 -37
- package/dist/cjs/text-control/index.js +6 -19
- package/dist/cjs/text-control/style.scss +0 -126
- package/dist/cjs/utils/index.js +10 -5
- package/dist/cjs/waiting/index.js +9 -33
- package/dist/cjs/waiting/style.scss +9 -20
- package/dist/cjs/web-preview/index.js +30 -57
- package/dist/cjs/web-preview/style.scss +41 -34
- package/dist/cjs/with-wizard/index.js +55 -33
- package/dist/cjs/with-wizard/style.scss +77 -124
- package/dist/cjs/with-wizard-screen/index.js +28 -38
- package/dist/cjs/with-wizard-screen/style.scss +75 -125
- package/dist/cjs/wizard/components/WizardError.js +74 -0
- package/dist/cjs/wizard/index.js +131 -0
- package/dist/cjs/wizard/store/index.js +165 -0
- package/dist/cjs/wizard/store/utils.js +26 -0
- package/dist/cjs/wizard/style.scss +148 -0
- package/dist/esm/accordion/index.js +38 -0
- package/dist/esm/accordion/style.scss +27 -0
- package/dist/esm/action-card/index.js +75 -37
- package/dist/esm/action-card/style.scss +143 -41
- package/dist/esm/autocomplete-tokenfield/index.js +14 -37
- package/dist/esm/autocomplete-tokenfield/style.scss +6 -6
- package/dist/esm/autocomplete-with-suggestions/index.js +31 -43
- package/dist/esm/autocomplete-with-suggestions/style.scss +27 -27
- package/dist/esm/button/index.js +2 -14
- package/dist/esm/button/style.scss +3 -344
- package/dist/esm/button-card/index.js +12 -11
- package/dist/esm/button-card/style.scss +65 -35
- package/dist/esm/card/index.js +5 -6
- package/dist/esm/card/style.scss +47 -63
- package/dist/esm/category-autocomplete/index.js +68 -41
- package/dist/esm/category-autocomplete/style.scss +20 -24
- package/dist/esm/color-picker/index.js +17 -38
- package/dist/esm/color-picker/style.scss +20 -163
- package/dist/esm/consts.js +3 -2
- package/dist/esm/custom-select-control/index.js +2 -5
- package/dist/esm/custom-select-control/style.scss +14 -45
- package/dist/esm/date-range-picker/index.js +1 -3
- package/dist/esm/date-range-picker/style.scss +12 -12
- package/dist/esm/footer/index.js +22 -16
- package/dist/esm/footer/style.scss +13 -14
- package/dist/esm/form-token-field/index.js +4 -7
- package/dist/esm/form-token-field/style.scss +9 -105
- package/dist/esm/global-notices/index.js +3 -7
- package/dist/esm/grid/index.js +2 -5
- package/dist/esm/grid/style.scss +19 -6
- package/dist/esm/handoff/index.js +10 -21
- package/dist/esm/handoff-message/index.js +45 -0
- package/dist/esm/hooks/index.js +0 -2
- package/dist/esm/hooks/useObjectState.js +3 -8
- package/dist/esm/hooks/useObjectState.test.js +0 -3
- package/dist/esm/hooks/useOnClickOutside.js +2 -5
- package/dist/esm/hooks/usePrompt.js +1 -8
- package/dist/esm/image-upload/index.js +18 -17
- package/dist/esm/image-upload/style.scss +12 -17
- package/dist/esm/index.js +7 -8
- package/dist/esm/info-button/index.js +4 -6
- package/dist/esm/info-button/style.scss +1 -3
- package/dist/esm/modal/index.js +2 -8
- package/dist/esm/modal/style.scss +20 -132
- package/dist/esm/newspack-icon/index.js +6 -7
- package/dist/esm/newspack-icon/style.scss +17 -2
- package/dist/esm/newspack-logo/index.js +2 -5
- package/dist/esm/newspack-logo/style.scss +3 -3
- package/dist/esm/notice/index.js +11 -10
- package/dist/esm/notice/style.scss +60 -19
- package/dist/esm/patrons-logo/index.js +3 -5
- package/dist/esm/plugin-installer/index.js +37 -40
- package/dist/esm/plugin-installer/style.scss +5 -5
- package/dist/esm/plugin-settings/SettingsSection.js +71 -56
- package/dist/esm/plugin-settings/index.js +70 -52
- package/dist/esm/plugin-settings/style.scss +7 -0
- package/dist/esm/plugin-toggle/index.js +59 -34
- package/dist/esm/plugin-toggle/style.scss +2 -2
- package/dist/esm/popover/index.js +3 -6
- package/dist/esm/popover/style.scss +20 -17
- package/dist/esm/position-control/index.js +109 -0
- package/dist/esm/position-control/style.scss +66 -0
- package/dist/esm/progress-bar/index.js +2 -7
- package/dist/esm/progress-bar/index.test.js +2 -1
- package/dist/esm/progress-bar/style.scss +4 -4
- package/dist/esm/proxied-imports/router.js +1 -0
- package/dist/esm/radio-control/index.js +3 -6
- package/dist/esm/radio-control/style.scss +10 -11
- package/dist/esm/section-header/index.js +47 -16
- package/dist/esm/section-header/style.scss +22 -1
- package/dist/esm/select-control/ButtonGroupControl.js +12 -14
- package/dist/esm/select-control/GroupedSelectControl.js +38 -36
- package/dist/esm/select-control/index.js +7 -8
- package/dist/esm/select-control/style.scss +47 -88
- package/dist/esm/settings/MinMaxSetting.js +4 -5
- package/dist/esm/settings/SettingsCard.js +9 -5
- package/dist/esm/settings/SettingsSection.js +5 -7
- package/dist/esm/settings/style.scss +32 -4
- package/dist/esm/steps-list/index.js +43 -0
- package/dist/esm/steps-list/style.scss +11 -0
- package/dist/esm/steps-list-item/index.js +48 -0
- package/dist/esm/steps-list-item/style.scss +47 -0
- package/dist/esm/style-card/index.js +13 -13
- package/dist/esm/style-card/style.scss +19 -18
- package/dist/esm/style.scss +43 -0
- package/dist/esm/tabbed-navigation/index.js +30 -28
- package/dist/esm/tabbed-navigation/style.scss +58 -37
- package/dist/esm/text-control/index.js +2 -12
- package/dist/esm/text-control/style.scss +0 -126
- package/dist/esm/utils/index.js +9 -3
- package/dist/esm/waiting/index.js +11 -27
- package/dist/esm/waiting/style.scss +9 -20
- package/dist/esm/web-preview/index.js +21 -49
- package/dist/esm/web-preview/style.scss +41 -34
- package/dist/esm/with-wizard/index.js +53 -36
- package/dist/esm/with-wizard/style.scss +77 -124
- package/dist/esm/with-wizard-screen/index.js +26 -32
- package/dist/esm/with-wizard-screen/style.scss +75 -125
- package/dist/esm/wizard/components/WizardError.js +69 -0
- package/dist/esm/wizard/index.js +126 -0
- package/dist/esm/wizard/store/index.js +155 -0
- package/dist/esm/wizard/store/utils.js +17 -0
- package/dist/esm/wizard/style.scss +148 -0
- package/package.json +4 -4
- package/src/accordion/index.js +32 -0
- package/src/accordion/style.scss +27 -0
- package/src/action-card/index.js +70 -25
- package/src/action-card/style.scss +143 -41
- package/src/autocomplete-tokenfield/index.js +1 -1
- package/src/autocomplete-tokenfield/style.scss +6 -6
- package/src/autocomplete-with-suggestions/index.js +4 -2
- package/src/autocomplete-with-suggestions/style.scss +27 -27
- package/src/button/index.js +2 -9
- package/src/button/style.scss +3 -344
- package/src/button-card/index.js +19 -5
- package/src/button-card/style.scss +65 -35
- package/src/card/index.js +4 -0
- package/src/card/style.scss +47 -63
- package/src/category-autocomplete/index.js +53 -18
- package/src/category-autocomplete/style.scss +20 -24
- package/src/color-picker/index.js +16 -22
- package/src/color-picker/style.scss +20 -163
- package/src/consts.js +2 -1
- package/src/custom-select-control/style.scss +14 -45
- package/src/date-range-picker/style.scss +12 -12
- package/src/footer/index.js +20 -9
- package/src/footer/style.scss +13 -14
- package/src/form-token-field/index.js +3 -8
- package/src/form-token-field/style.scss +9 -105
- package/src/global-notices/index.js +1 -1
- package/src/grid/style.scss +19 -6
- package/src/handoff/index.js +10 -15
- package/src/handoff-message/index.js +39 -0
- package/src/hooks/useObjectState.js +2 -1
- package/src/image-upload/index.js +9 -3
- package/src/image-upload/style.scss +12 -17
- package/src/index.js +7 -7
- package/src/info-button/style.scss +1 -3
- package/src/modal/index.js +2 -5
- package/src/modal/style.scss +20 -132
- package/src/newspack-icon/index.js +7 -2
- package/src/newspack-icon/style.scss +17 -2
- package/src/newspack-logo/style.scss +3 -3
- package/src/notice/index.js +9 -1
- package/src/notice/style.scss +60 -19
- package/src/plugin-installer/index.js +17 -4
- package/src/plugin-installer/style.scss +5 -5
- package/src/plugin-settings/SettingsSection.js +59 -27
- package/src/plugin-settings/index.js +29 -8
- package/src/plugin-settings/style.scss +7 -0
- package/src/plugin-toggle/index.js +37 -12
- package/src/plugin-toggle/style.scss +2 -2
- package/src/popover/style.scss +20 -17
- package/src/position-control/index.js +122 -0
- package/src/position-control/style.scss +66 -0
- package/src/progress-bar/style.scss +4 -4
- package/src/radio-control/style.scss +10 -11
- package/src/section-header/index.js +41 -5
- package/src/section-header/style.scss +22 -1
- package/src/select-control/ButtonGroupControl.js +15 -5
- package/src/select-control/GroupedSelectControl.js +28 -25
- package/src/select-control/index.js +6 -3
- package/src/select-control/style.scss +47 -88
- package/src/settings/MinMaxSetting.js +2 -1
- package/src/settings/SettingsCard.js +9 -7
- package/src/settings/SettingsSection.js +4 -4
- package/src/settings/style.scss +32 -4
- package/src/steps-list/index.js +39 -0
- package/src/steps-list/style.scss +11 -0
- package/src/steps-list-item/index.js +40 -0
- package/src/steps-list-item/style.scss +47 -0
- package/src/style-card/index.js +16 -27
- package/src/style-card/style.scss +19 -18
- package/src/style.scss +43 -0
- package/src/tabbed-navigation/index.js +20 -24
- package/src/tabbed-navigation/style.scss +58 -37
- package/src/text-control/index.js +1 -2
- package/src/text-control/style.scss +0 -126
- package/src/utils/index.js +9 -0
- package/src/waiting/index.js +7 -18
- package/src/waiting/style.scss +9 -20
- package/src/web-preview/index.js +13 -34
- package/src/web-preview/style.scss +41 -34
- package/src/with-wizard/index.js +7 -5
- package/src/with-wizard/style.scss +77 -124
- package/src/with-wizard-screen/index.js +17 -17
- package/src/with-wizard-screen/style.scss +75 -125
- package/src/wizard/components/WizardError.js +57 -0
- package/src/wizard/index.js +145 -0
- package/src/wizard/store/index.js +132 -0
- package/src/wizard/store/utils.js +16 -0
- package/dist/cjs/wizard-pagination/index.js +0 -71
- package/dist/cjs/wizard-pagination/style.scss +0 -74
- package/dist/esm/wizard-pagination/index.js +0 -57
- package/dist/esm/wizard-pagination/style.scss +0 -74
- package/src/button-group/index.js +0 -35
- package/src/button-group/style.scss +0 -73
- package/src/checkbox-control/index.js +0 -38
- package/src/checkbox-control/style.scss +0 -78
- package/src/preview-box/index.js +0 -18
- package/src/preview-box/style.scss +0 -18
- package/src/textarea-control/index.js +0 -32
- package/src/textarea-control/style.scss +0 -76
- package/src/toggle-control/index.js +0 -38
- package/src/toggle-control/style.scss +0 -74
- package/src/toggle-group/index.js +0 -43
- package/src/toggle-group/style.scss +0 -28
- package/src/wizard-pagination/index.js +0 -59
- package/src/wizard-pagination/style.scss +0 -74
|
@@ -1,44 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = withWizard;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _element = require("@wordpress/element");
|
|
13
|
-
|
|
14
10
|
var _i18n = require("@wordpress/i18n");
|
|
15
|
-
|
|
16
11
|
var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
17
|
-
|
|
18
12
|
var _icons = require("@wordpress/icons");
|
|
19
|
-
|
|
20
13
|
var _ = require("../");
|
|
21
|
-
|
|
22
14
|
var _router = _interopRequireDefault(require("../proxied-imports/router"));
|
|
23
|
-
|
|
24
15
|
var _footer = _interopRequireDefault(require("../footer"));
|
|
25
|
-
|
|
26
16
|
require("./style.scss");
|
|
27
|
-
|
|
28
17
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
29
|
-
|
|
30
18
|
/**
|
|
31
19
|
* WordPress dependencies.
|
|
32
20
|
*/
|
|
33
21
|
const __ = _i18n.__;
|
|
22
|
+
/**
|
|
23
|
+
* Internal dependencies.
|
|
24
|
+
*/
|
|
34
25
|
const {
|
|
35
26
|
Redirect,
|
|
36
27
|
Route
|
|
37
28
|
} = _router.default;
|
|
29
|
+
|
|
38
30
|
/**
|
|
39
31
|
* Higher-Order Component to provide plugin management and error handling to Newspack Wizards.
|
|
40
32
|
*/
|
|
41
|
-
|
|
42
33
|
function withWizard(WrappedComponent, requiredPlugins) {
|
|
43
34
|
return class WrappedWithWizard extends _element.Component {
|
|
44
35
|
constructor(props) {
|
|
@@ -46,11 +37,16 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
46
37
|
(0, _defineProperty2.default)(this, "componentDidMount", () => {
|
|
47
38
|
// If there are no requiredPlugins, fire onWizardReady as soon as component mounts.
|
|
48
39
|
if (!requiredPlugins) {
|
|
49
|
-
const instance = this.wrappedComponentRef.current;
|
|
50
|
-
|
|
40
|
+
const instance = this.wrappedComponentRef.current;
|
|
41
|
+
// eslint-disable-next-line no-unused-expressions
|
|
51
42
|
instance && instance.onWizardReady && instance.onWizardReady();
|
|
52
43
|
}
|
|
53
44
|
});
|
|
45
|
+
/**
|
|
46
|
+
* Set the error. Called by Wizards when an error occurs.
|
|
47
|
+
*
|
|
48
|
+
* @return {Promise} Resolved after state update
|
|
49
|
+
*/
|
|
54
50
|
(0, _defineProperty2.default)(this, "setError", error => {
|
|
55
51
|
return new Promise(resolve => {
|
|
56
52
|
this.setState({
|
|
@@ -58,26 +54,33 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
58
54
|
}, () => resolve());
|
|
59
55
|
});
|
|
60
56
|
});
|
|
57
|
+
/**
|
|
58
|
+
* Render any errors that need rendering.
|
|
59
|
+
*
|
|
60
|
+
* @return {Component} Error UI
|
|
61
|
+
*/
|
|
61
62
|
(0, _defineProperty2.default)(this, "getError", () => {
|
|
62
63
|
const {
|
|
63
64
|
error
|
|
64
65
|
} = this.state;
|
|
65
|
-
|
|
66
66
|
if (!error) {
|
|
67
67
|
return null;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
69
|
const parsedError = this.parseError(error);
|
|
71
70
|
const {
|
|
72
71
|
level
|
|
73
72
|
} = parsedError;
|
|
74
|
-
|
|
75
73
|
if ('fatal' === level) {
|
|
76
74
|
return this.getFatalError(parsedError);
|
|
77
75
|
}
|
|
78
|
-
|
|
79
76
|
return this.getErrorNotice(parsedError);
|
|
80
77
|
});
|
|
78
|
+
/**
|
|
79
|
+
* Get a notice-level error.
|
|
80
|
+
*
|
|
81
|
+
* @param {Error} error object already parsed by parseError
|
|
82
|
+
* @return {Component} Error notice
|
|
83
|
+
*/
|
|
81
84
|
(0, _defineProperty2.default)(this, "getErrorNotice", error => {
|
|
82
85
|
const {
|
|
83
86
|
message
|
|
@@ -89,13 +92,17 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
89
92
|
rawHTML: true
|
|
90
93
|
});
|
|
91
94
|
});
|
|
95
|
+
/**
|
|
96
|
+
* Get a fatal-level error.
|
|
97
|
+
*
|
|
98
|
+
* @param {Error} error object already parsed by parseError
|
|
99
|
+
* @return {Component} React object
|
|
100
|
+
*/
|
|
92
101
|
(0, _defineProperty2.default)(this, "getFatalError", error => {
|
|
93
102
|
const fallbackURL = this.getFallbackURL();
|
|
94
|
-
|
|
95
103
|
if (!fallbackURL) {
|
|
96
104
|
return null;
|
|
97
105
|
}
|
|
98
|
-
|
|
99
106
|
const {
|
|
100
107
|
message
|
|
101
108
|
} = error;
|
|
@@ -118,6 +125,12 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
118
125
|
})]
|
|
119
126
|
});
|
|
120
127
|
});
|
|
128
|
+
/**
|
|
129
|
+
* Get all the relevant info out of a raw API error response.
|
|
130
|
+
*
|
|
131
|
+
* @param {Object} error error object
|
|
132
|
+
* @return {Object} Error object with relevant fields and defaults
|
|
133
|
+
*/
|
|
121
134
|
(0, _defineProperty2.default)(this, "parseError", error => {
|
|
122
135
|
const {
|
|
123
136
|
data,
|
|
@@ -125,27 +138,26 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
125
138
|
code
|
|
126
139
|
} = error;
|
|
127
140
|
let level = 'fatal';
|
|
128
|
-
|
|
129
141
|
if (!!data && 'level' in data) {
|
|
130
142
|
level = data.level;
|
|
131
143
|
} else if ('rest_invalid_param' === code) {
|
|
132
144
|
level = 'notice';
|
|
133
145
|
}
|
|
134
|
-
|
|
135
146
|
return {
|
|
136
147
|
message,
|
|
137
148
|
level
|
|
138
149
|
};
|
|
139
150
|
});
|
|
151
|
+
/**
|
|
152
|
+
* Called when plugin installation is complete. Updates state and calls onWizardReady on the wrapped component.
|
|
153
|
+
*/
|
|
140
154
|
(0, _defineProperty2.default)(this, "pluginInstallationStatus", _ref => {
|
|
141
155
|
let {
|
|
142
156
|
complete
|
|
143
157
|
} = _ref;
|
|
144
|
-
|
|
145
158
|
if (this.state.loading) {
|
|
146
159
|
this.doneLoading();
|
|
147
160
|
}
|
|
148
|
-
|
|
149
161
|
const instance = this.wrappedComponentRef.current;
|
|
150
162
|
this.setState({
|
|
151
163
|
complete
|
|
@@ -154,6 +166,9 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
154
166
|
complete && instance && instance.onWizardReady && instance.onWizardReady();
|
|
155
167
|
});
|
|
156
168
|
});
|
|
169
|
+
/**
|
|
170
|
+
* Begin loading.
|
|
171
|
+
*/
|
|
157
172
|
(0, _defineProperty2.default)(this, "startLoading", quiet => {
|
|
158
173
|
if (quiet) {
|
|
159
174
|
this.setState(state => ({
|
|
@@ -165,6 +180,9 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
165
180
|
}));
|
|
166
181
|
}
|
|
167
182
|
});
|
|
183
|
+
/**
|
|
184
|
+
* End loading.
|
|
185
|
+
*/
|
|
168
186
|
(0, _defineProperty2.default)(this, "doneLoading", quiet => {
|
|
169
187
|
if (quiet) {
|
|
170
188
|
this.setState(state => ({
|
|
@@ -176,6 +194,9 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
176
194
|
}));
|
|
177
195
|
}
|
|
178
196
|
});
|
|
197
|
+
/**
|
|
198
|
+
* Replacement for core apiFetch that automatically manages wizard loading UI.
|
|
199
|
+
*/
|
|
179
200
|
(0, _defineProperty2.default)(this, "wizardApiFetch", args => {
|
|
180
201
|
const {
|
|
181
202
|
quiet
|
|
@@ -191,19 +212,22 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
191
212
|
});
|
|
192
213
|
});
|
|
193
214
|
});
|
|
215
|
+
/**
|
|
216
|
+
* Render a Route that checks for plugin installation requirements, and redirects to '/' when all are done.
|
|
217
|
+
*
|
|
218
|
+
* @return {void}
|
|
219
|
+
*/
|
|
194
220
|
(0, _defineProperty2.default)(this, "pluginRequirements", () => {
|
|
195
221
|
const {
|
|
196
222
|
complete
|
|
197
223
|
} = this.state;
|
|
198
224
|
/* After all plugins are loaded, redirect to / (this could be configurable) */
|
|
199
|
-
|
|
200
225
|
if (complete) {
|
|
201
226
|
return (0, _jsxRuntime.jsx)(Redirect, {
|
|
202
227
|
from: "/plugin-requirements",
|
|
203
228
|
to: "/"
|
|
204
229
|
});
|
|
205
230
|
}
|
|
206
|
-
|
|
207
231
|
return (0, _jsxRuntime.jsx)(Route, {
|
|
208
232
|
path: "/",
|
|
209
233
|
render: () => (0, _jsxRuntime.jsxs)(_element.Fragment, {
|
|
@@ -223,8 +247,10 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
223
247
|
children: (0, _jsxRuntime.jsx)(_.NewspackIcon, {
|
|
224
248
|
size: 36
|
|
225
249
|
})
|
|
226
|
-
}), (0, _jsxRuntime.jsx)("
|
|
227
|
-
children:
|
|
250
|
+
}), (0, _jsxRuntime.jsx)("div", {
|
|
251
|
+
children: (0, _jsxRuntime.jsx)("h2", {
|
|
252
|
+
children: requiredPlugins.length > 1 ? __('Required plugins', 'newspack') : __('Required plugin', 'newspack')
|
|
253
|
+
})
|
|
228
254
|
})]
|
|
229
255
|
})
|
|
230
256
|
})
|
|
@@ -251,7 +277,6 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
251
277
|
};
|
|
252
278
|
this.wrappedComponentRef = (0, _element.createRef)();
|
|
253
279
|
}
|
|
254
|
-
|
|
255
280
|
/**
|
|
256
281
|
* Render.
|
|
257
282
|
*/
|
|
@@ -265,11 +290,9 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
265
290
|
error
|
|
266
291
|
} = this.state;
|
|
267
292
|
const loadingClasses = [loading ? 'newspack-wizard__is-loading' : 'newspack-wizard__is-loaded'];
|
|
268
|
-
|
|
269
293
|
if (quietLoading) {
|
|
270
294
|
loadingClasses.push('newspack-wizard__is-loading-quiet');
|
|
271
295
|
}
|
|
272
|
-
|
|
273
296
|
return (0, _jsxRuntime.jsxs)(_element.Fragment, {
|
|
274
297
|
children: [this.getError(), (0, _jsxRuntime.jsx)("div", {
|
|
275
298
|
className: loadingClasses.join(' '),
|
|
@@ -291,6 +314,5 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
291
314
|
})]
|
|
292
315
|
});
|
|
293
316
|
}
|
|
294
|
-
|
|
295
317
|
};
|
|
296
318
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* With Wizard
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
@
|
|
6
|
-
@
|
|
5
|
+
@use '~@wordpress/base-styles/colors' as wp-colors;
|
|
6
|
+
@use '../../../shared/scss/colors';
|
|
7
7
|
|
|
8
8
|
// Reset Padding of the Admin Page
|
|
9
9
|
|
|
@@ -32,71 +32,24 @@ body[class*='admin_page_newspack-'] {
|
|
|
32
32
|
|
|
33
33
|
svg {
|
|
34
34
|
&.newspack--error {
|
|
35
|
-
fill:
|
|
35
|
+
fill: wp-colors.$alert-red;
|
|
36
36
|
transform: rotate( 180deg );
|
|
37
37
|
}
|
|
38
38
|
&.newspack--success {
|
|
39
|
-
fill:
|
|
39
|
+
fill: wp-colors.$alert-green;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
//
|
|
43
|
+
// Blue Screen
|
|
44
44
|
|
|
45
|
-
.
|
|
45
|
+
.newspack-wizard__blue {
|
|
46
46
|
#wpwrap {
|
|
47
|
-
background:
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.newspack-wizard__header {
|
|
51
|
-
display: none;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.newspack-card {
|
|
55
|
-
background: white;
|
|
56
|
-
border: 0;
|
|
57
|
-
margin: 0 auto 32px;
|
|
58
|
-
|
|
59
|
-
@media screen and ( min-width: 584px ) {
|
|
60
|
-
max-width: 520px;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&.loading {
|
|
64
|
-
cursor: wait;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
&__footer {
|
|
68
|
-
align-items: center;
|
|
69
|
-
display: flex;
|
|
70
|
-
flex-wrap: wrap;
|
|
71
|
-
justify-content: space-between;
|
|
72
|
-
|
|
73
|
-
.newspack-checkbox-control {
|
|
74
|
-
margin: 12px 16px 12px 0;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
h1 {
|
|
79
|
-
align-items: center;
|
|
80
|
-
display: flex;
|
|
81
|
-
flex-wrap: wrap;
|
|
82
|
-
|
|
83
|
-
svg {
|
|
84
|
-
margin-right: 8px;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.newspack-logo__wrapper {
|
|
90
|
-
margin-bottom: 32px;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.newspack-buttons-card {
|
|
94
|
-
margin: 0;
|
|
47
|
+
background: colors.$primary-500;
|
|
95
48
|
}
|
|
96
49
|
|
|
97
50
|
.newspack-footer {
|
|
98
|
-
background:
|
|
99
|
-
border-color:
|
|
51
|
+
background: colors.$primary-500;
|
|
52
|
+
border-color: colors.$primary-500;
|
|
100
53
|
justify-content: center;
|
|
101
54
|
|
|
102
55
|
&__logo {
|
|
@@ -123,12 +76,9 @@ svg {
|
|
|
123
76
|
|
|
124
77
|
.newspack-wizard__is-loading {
|
|
125
78
|
background: white;
|
|
126
|
-
bottom: 0;
|
|
127
79
|
cursor: wait;
|
|
128
|
-
|
|
80
|
+
inset: 0;
|
|
129
81
|
position: absolute;
|
|
130
|
-
right: 0;
|
|
131
|
-
top: 0;
|
|
132
82
|
|
|
133
83
|
> * {
|
|
134
84
|
display: none !important;
|
|
@@ -142,103 +92,106 @@ svg {
|
|
|
142
92
|
}
|
|
143
93
|
|
|
144
94
|
&::before {
|
|
145
|
-
background:
|
|
146
|
-
box-shadow: 24px 0 0 white, 69px 0 0 -15px
|
|
147
|
-
|
|
95
|
+
background: colors.$primary-500;
|
|
96
|
+
box-shadow: 24px 0 0 white, 69px 0 0 -15px wp-colors.$gray-900,
|
|
97
|
+
99px 0 0 -15px wp-colors.$gray-900, 129px 0 0 -15px wp-colors.$gray-900,
|
|
98
|
+
159px 0 0 -15px wp-colors.$gray-900, 189px 0 0 -15px wp-colors.$gray-900;
|
|
148
99
|
height: 60px;
|
|
149
100
|
width: 60px;
|
|
150
101
|
}
|
|
151
102
|
|
|
152
103
|
&::after {
|
|
153
|
-
background:
|
|
154
|
-
box-shadow: inset -40vw 0 0 0 white, 0 64px 0 0
|
|
155
|
-
0 96px 0 0
|
|
104
|
+
background: wp-colors.$gray-900;
|
|
105
|
+
box-shadow: inset -40vw 0 0 0 white, 0 64px 0 0 wp-colors.$gray-700, 40vw 96px 0 0 white,
|
|
106
|
+
0 96px 0 0 wp-colors.$gray-700;
|
|
156
107
|
height: 24px;
|
|
157
108
|
margin: 68px auto 0;
|
|
158
109
|
max-width: 1040px;
|
|
159
110
|
width: calc( 100% - ( 32px * 2 ) );
|
|
160
111
|
|
|
161
112
|
@media screen and ( min-width: 744px ) {
|
|
162
|
-
box-shadow: inset -400px 0 0 0 white, 0 64px 0 0
|
|
163
|
-
0 96px 0 0
|
|
113
|
+
box-shadow: inset -400px 0 0 0 white, 0 64px 0 0 wp-colors.$gray-700, 200px 96px 0 0 white,
|
|
114
|
+
0 96px 0 0 wp-colors.$gray-700;
|
|
164
115
|
width: calc( 100% - ( 64px * 2 ) );
|
|
165
116
|
}
|
|
166
117
|
|
|
167
118
|
@media screen and ( min-width: 1224px ) {
|
|
168
|
-
box-shadow: inset -600px 0 0 0 white, 0 64px 0 0
|
|
169
|
-
0 96px 0 0
|
|
119
|
+
box-shadow: inset -600px 0 0 0 white, 0 64px 0 0 wp-colors.$gray-700, 512px 96px 0 0 white,
|
|
120
|
+
0 96px 0 0 wp-colors.$gray-700;
|
|
170
121
|
width: calc( 100% - ( 64px * 2 ) );
|
|
171
122
|
}
|
|
172
123
|
}
|
|
173
124
|
|
|
174
|
-
//
|
|
175
|
-
.
|
|
176
|
-
background:
|
|
177
|
-
|
|
178
|
-
&::before,
|
|
179
|
-
&::after {
|
|
180
|
-
left: 50%;
|
|
181
|
-
position: absolute;
|
|
182
|
-
transform: translate( -50% );
|
|
183
|
-
}
|
|
125
|
+
// Blue Screen
|
|
126
|
+
.newspack-wizard__blue & {
|
|
127
|
+
background: colors.$primary-500;
|
|
184
128
|
|
|
185
129
|
&::before {
|
|
186
|
-
|
|
130
|
+
animation: loading-quiet 1.25s ease-in-out infinite;
|
|
187
131
|
background: white;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
132
|
+
border-radius: 0;
|
|
133
|
+
box-shadow: 0;
|
|
134
|
+
height: 8px;
|
|
135
|
+
left: 0;
|
|
136
|
+
margin: 0;
|
|
137
|
+
position: absolute;
|
|
138
|
+
right: 100%;
|
|
139
|
+
top: 0;
|
|
140
|
+
width: auto;
|
|
196
141
|
}
|
|
197
142
|
|
|
198
143
|
&::after {
|
|
199
|
-
|
|
200
|
-
margin: 0;
|
|
201
|
-
max-width: 520px;
|
|
202
|
-
top: 156px;
|
|
203
|
-
width: calc( 100% - ( 64px * 2 ) );
|
|
204
|
-
|
|
205
|
-
@media screen and ( min-width: 600px ) {
|
|
206
|
-
box-shadow: inset -260px 0 0 0 white, 0 64px 0 0 $gray-700, 0 96px 0 0 $gray-700;
|
|
207
|
-
}
|
|
144
|
+
display: none;
|
|
208
145
|
}
|
|
209
146
|
}
|
|
210
147
|
|
|
211
148
|
// Quiet
|
|
212
149
|
&-quiet {
|
|
213
|
-
cursor: wait;
|
|
214
150
|
position: relative;
|
|
215
151
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
&::before {
|
|
221
|
-
animation: loading-quiet 1.25s ease-in-out infinite;
|
|
222
|
-
background: $primary-500;
|
|
152
|
+
&::before,
|
|
153
|
+
&::after {
|
|
223
154
|
content: '';
|
|
155
|
+
cursor: wait;
|
|
224
156
|
display: block;
|
|
225
|
-
height: 8px;
|
|
226
157
|
left: 0;
|
|
227
158
|
position: fixed;
|
|
228
|
-
right: 100%;
|
|
229
159
|
top: 46px;
|
|
230
|
-
z-index: 1;
|
|
231
160
|
|
|
232
161
|
@media screen and ( min-width: 783px ) {
|
|
233
162
|
top: 32px;
|
|
234
163
|
margin-left: 160px;
|
|
235
164
|
|
|
236
|
-
body.auto-fold
|
|
165
|
+
body.auto-fold & {
|
|
166
|
+
margin-left: 36px;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@media screen and ( min-width: 961px ) {
|
|
171
|
+
body.auto-fold & {
|
|
172
|
+
margin-left: 160px;
|
|
173
|
+
}
|
|
174
|
+
|
|
237
175
|
body.folded & {
|
|
238
176
|
margin-left: 36px;
|
|
239
177
|
}
|
|
240
178
|
}
|
|
241
179
|
}
|
|
180
|
+
|
|
181
|
+
&::before {
|
|
182
|
+
animation: loading-quiet 1.25s ease-in-out infinite;
|
|
183
|
+
background: colors.$primary-500;
|
|
184
|
+
height: 8px;
|
|
185
|
+
right: 100%;
|
|
186
|
+
z-index: 9999;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
&::after {
|
|
190
|
+
background: rgba( white, 0.7 );
|
|
191
|
+
bottom: 0;
|
|
192
|
+
right: 0;
|
|
193
|
+
z-index: 9998;
|
|
194
|
+
}
|
|
242
195
|
}
|
|
243
196
|
}
|
|
244
197
|
|
|
@@ -255,42 +208,42 @@ svg {
|
|
|
255
208
|
animation: loading 2s ease-in-out infinite;
|
|
256
209
|
content: '';
|
|
257
210
|
display: block;
|
|
258
|
-
background:
|
|
259
|
-
box-shadow: inset -40vw 0 0 0 white, 0 64px 0 0
|
|
260
|
-
0 96px 0 0
|
|
211
|
+
background: wp-colors.$gray-900;
|
|
212
|
+
box-shadow: inset -40vw 0 0 0 white, 0 64px 0 0 wp-colors.$gray-700, 40vw 96px 0 0 white,
|
|
213
|
+
0 96px 0 0 wp-colors.$gray-700;
|
|
261
214
|
height: 24px;
|
|
262
215
|
margin: 0 auto;
|
|
263
216
|
max-width: 1040px;
|
|
264
217
|
width: 100%;
|
|
265
218
|
|
|
266
219
|
@media screen and ( min-width: 744px ) {
|
|
267
|
-
box-shadow: inset -400px 0 0 0 white, 0 64px 0 0
|
|
268
|
-
0 96px 0 0
|
|
220
|
+
box-shadow: inset -400px 0 0 0 white, 0 64px 0 0 wp-colors.$gray-700, 200px 96px 0 0 white,
|
|
221
|
+
0 96px 0 0 wp-colors.$gray-700;
|
|
269
222
|
}
|
|
270
223
|
|
|
271
224
|
@media screen and ( min-width: 1224px ) {
|
|
272
|
-
box-shadow: inset -600px 0 0 0 white, 0 64px 0 0
|
|
273
|
-
0 96px 0 0
|
|
225
|
+
box-shadow: inset -600px 0 0 0 white, 0 64px 0 0 wp-colors.$gray-700, 520px 96px 0 0 white,
|
|
226
|
+
0 96px 0 0 wp-colors.$gray-700;
|
|
274
227
|
}
|
|
275
228
|
}
|
|
276
229
|
}
|
|
277
230
|
|
|
278
231
|
@keyframes loading {
|
|
279
|
-
|
|
280
|
-
opacity:
|
|
232
|
+
0% {
|
|
233
|
+
opacity: 1;
|
|
281
234
|
}
|
|
282
235
|
|
|
283
236
|
50% {
|
|
284
|
-
opacity:
|
|
237
|
+
opacity: 0.1;
|
|
285
238
|
}
|
|
286
239
|
|
|
287
|
-
|
|
288
|
-
opacity:
|
|
240
|
+
100% {
|
|
241
|
+
opacity: 1;
|
|
289
242
|
}
|
|
290
243
|
}
|
|
291
244
|
|
|
292
245
|
@keyframes loading-quiet {
|
|
293
|
-
|
|
246
|
+
0% {
|
|
294
247
|
left: 0;
|
|
295
248
|
right: 100%;
|
|
296
249
|
}
|
|
@@ -300,7 +253,7 @@ svg {
|
|
|
300
253
|
right: 0;
|
|
301
254
|
}
|
|
302
255
|
|
|
303
|
-
|
|
256
|
+
100% {
|
|
304
257
|
left: 100%;
|
|
305
258
|
right: 0;
|
|
306
259
|
}
|