newspack-components 2.0.3 → 2.1.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/action-card/index.js +29 -20
- package/dist/cjs/action-card/style.scss +52 -27
- package/dist/cjs/autocomplete-tokenfield/style.scss +4 -4
- package/dist/cjs/autocomplete-with-suggestions/index.js +3 -2
- package/dist/cjs/autocomplete-with-suggestions/style.scss +19 -20
- package/dist/cjs/button/index.js +2 -13
- package/dist/cjs/button/style.scss +3 -344
- package/dist/cjs/button-card/index.js +11 -6
- package/dist/cjs/button-card/style.scss +60 -30
- package/dist/cjs/card/index.js +3 -1
- package/dist/cjs/card/style.scss +29 -62
- package/dist/cjs/category-autocomplete/index.js +52 -13
- package/dist/cjs/category-autocomplete/style.scss +20 -22
- package/dist/cjs/color-picker/index.js +17 -35
- package/dist/cjs/color-picker/style.scss +20 -160
- package/dist/cjs/custom-select-control/style.scss +12 -42
- package/dist/cjs/footer/index.js +21 -7
- package/dist/cjs/footer/style.scss +9 -10
- package/dist/cjs/form-token-field/index.js +2 -2
- package/dist/cjs/form-token-field/style.scss +8 -103
- package/dist/cjs/global-notices/index.js +2 -1
- package/dist/cjs/grid/style.scss +14 -1
- package/dist/cjs/handoff/index.js +7 -7
- package/dist/cjs/image-upload/index.js +1 -1
- package/dist/cjs/image-upload/style.scss +10 -11
- package/dist/cjs/index.js +7 -53
- package/dist/cjs/modal/index.js +0 -3
- package/dist/cjs/modal/style.scss +19 -131
- package/dist/cjs/newspack-icon/index.js +4 -2
- package/dist/cjs/newspack-icon/style.scss +15 -0
- package/dist/cjs/notice/index.js +8 -9
- package/dist/cjs/notice/style.scss +38 -10
- package/dist/cjs/plugin-installer/index.js +1 -1
- package/dist/cjs/plugin-settings/SettingsSection.js +74 -43
- package/dist/cjs/plugin-settings/index.js +34 -30
- package/dist/cjs/plugin-settings/style.scss +7 -0
- package/dist/cjs/plugin-toggle/index.js +22 -1
- package/dist/cjs/popover/style.scss +2 -2
- package/dist/cjs/radio-control/style.scss +1 -2
- package/dist/cjs/section-header/index.js +18 -5
- package/dist/cjs/section-header/style.scss +22 -1
- package/dist/cjs/select-control/ButtonGroupControl.js +8 -8
- package/dist/cjs/select-control/GroupedSelectControl.js +33 -30
- package/dist/cjs/select-control/index.js +1 -2
- package/dist/cjs/select-control/style.scss +46 -87
- package/dist/cjs/settings/MinMaxSetting.js +4 -2
- package/dist/cjs/settings/SettingsCard.js +6 -1
- package/dist/cjs/settings/SettingsSection.js +4 -4
- package/dist/cjs/settings/style.scss +32 -4
- package/dist/cjs/style-card/index.js +10 -6
- package/dist/cjs/style-card/style.scss +12 -8
- package/dist/cjs/style.scss +44 -0
- package/dist/cjs/tabbed-navigation/index.js +13 -20
- package/dist/cjs/tabbed-navigation/style.scss +56 -34
- package/dist/cjs/text-control/index.js +0 -3
- package/dist/cjs/text-control/style.scss +0 -126
- package/dist/cjs/waiting/index.js +9 -25
- package/dist/cjs/waiting/style.scss +9 -20
- package/dist/cjs/web-preview/index.js +18 -30
- package/dist/cjs/web-preview/style.scss +33 -26
- package/dist/cjs/with-wizard/index.js +4 -2
- package/dist/cjs/with-wizard/style.scss +44 -89
- package/dist/cjs/with-wizard-screen/index.js +17 -21
- package/dist/cjs/with-wizard-screen/style.scss +74 -121
- package/dist/cjs/wizard/components/WizardError.js +86 -0
- package/dist/cjs/wizard/index.js +145 -0
- package/dist/cjs/wizard/store/index.js +178 -0
- package/dist/cjs/wizard/store/utils.js +31 -0
- package/dist/esm/action-card/index.js +30 -21
- package/dist/esm/action-card/style.scss +52 -27
- package/dist/esm/autocomplete-tokenfield/style.scss +4 -4
- package/dist/esm/autocomplete-with-suggestions/index.js +3 -2
- package/dist/esm/autocomplete-with-suggestions/style.scss +19 -20
- package/dist/esm/button/index.js +2 -12
- package/dist/esm/button/style.scss +3 -344
- package/dist/esm/button-card/index.js +10 -6
- package/dist/esm/button-card/style.scss +60 -30
- package/dist/esm/card/index.js +3 -1
- package/dist/esm/card/style.scss +29 -62
- package/dist/esm/category-autocomplete/index.js +54 -14
- package/dist/esm/category-autocomplete/style.scss +20 -22
- package/dist/esm/color-picker/index.js +15 -34
- package/dist/esm/color-picker/style.scss +20 -160
- package/dist/esm/custom-select-control/style.scss +12 -42
- package/dist/esm/footer/index.js +21 -7
- package/dist/esm/footer/style.scss +9 -10
- package/dist/esm/form-token-field/index.js +2 -2
- package/dist/esm/form-token-field/style.scss +8 -103
- package/dist/esm/global-notices/index.js +2 -1
- package/dist/esm/grid/style.scss +14 -1
- package/dist/esm/handoff/index.js +7 -7
- package/dist/esm/image-upload/index.js +1 -1
- package/dist/esm/image-upload/style.scss +10 -11
- package/dist/esm/index.js +3 -8
- package/dist/esm/modal/index.js +0 -3
- package/dist/esm/modal/style.scss +19 -131
- package/dist/esm/newspack-icon/index.js +4 -2
- package/dist/esm/newspack-icon/style.scss +15 -0
- package/dist/esm/notice/index.js +8 -3
- package/dist/esm/notice/style.scss +38 -10
- package/dist/esm/plugin-installer/index.js +2 -1
- package/dist/esm/plugin-settings/SettingsSection.js +72 -44
- package/dist/esm/plugin-settings/index.js +34 -30
- package/dist/esm/plugin-settings/style.scss +7 -0
- package/dist/esm/plugin-toggle/index.js +23 -1
- package/dist/esm/popover/style.scss +2 -2
- package/dist/esm/radio-control/style.scss +1 -2
- package/dist/esm/section-header/index.js +17 -5
- package/dist/esm/section-header/style.scss +22 -1
- package/dist/esm/select-control/ButtonGroupControl.js +8 -8
- package/dist/esm/select-control/GroupedSelectControl.js +33 -30
- package/dist/esm/select-control/index.js +1 -2
- package/dist/esm/select-control/style.scss +46 -87
- package/dist/esm/settings/MinMaxSetting.js +3 -2
- package/dist/esm/settings/SettingsCard.js +6 -1
- package/dist/esm/settings/SettingsSection.js +5 -5
- package/dist/esm/settings/style.scss +32 -4
- package/dist/esm/style-card/index.js +11 -8
- package/dist/esm/style-card/style.scss +12 -8
- package/dist/esm/style.scss +44 -0
- package/dist/esm/tabbed-navigation/index.js +14 -22
- package/dist/esm/tabbed-navigation/style.scss +56 -34
- package/dist/esm/text-control/index.js +0 -3
- package/dist/esm/text-control/style.scss +0 -126
- package/dist/esm/waiting/index.js +9 -22
- package/dist/esm/waiting/style.scss +9 -20
- package/dist/esm/web-preview/index.js +12 -25
- package/dist/esm/web-preview/style.scss +33 -26
- package/dist/esm/with-wizard/index.js +4 -2
- package/dist/esm/with-wizard/style.scss +44 -89
- package/dist/esm/with-wizard-screen/index.js +18 -22
- package/dist/esm/with-wizard-screen/style.scss +74 -121
- package/dist/esm/wizard/components/WizardError.js +78 -0
- package/dist/esm/wizard/index.js +128 -0
- package/dist/esm/wizard/store/index.js +161 -0
- package/dist/esm/wizard/store/utils.js +17 -0
- package/package.json +1 -1
- package/shared/scss/_colors.scss +15 -0
- package/src/action-card/index.js +28 -18
- package/src/action-card/style.scss +52 -27
- package/src/autocomplete-tokenfield/style.scss +4 -4
- package/src/autocomplete-with-suggestions/index.js +4 -2
- package/src/autocomplete-with-suggestions/style.scss +19 -20
- 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 +60 -30
- package/src/card/index.js +4 -0
- package/src/card/style.scss +29 -62
- package/src/category-autocomplete/index.js +51 -18
- package/src/category-autocomplete/style.scss +20 -22
- package/src/color-picker/index.js +16 -22
- package/src/color-picker/style.scss +20 -160
- package/src/custom-select-control/style.scss +12 -42
- package/src/footer/index.js +19 -8
- package/src/footer/style.scss +9 -10
- package/src/form-token-field/index.js +1 -1
- package/src/form-token-field/style.scss +8 -103
- package/src/global-notices/index.js +1 -1
- package/src/grid/style.scss +14 -1
- package/src/handoff/index.js +7 -7
- package/src/image-upload/style.scss +10 -11
- package/src/index.js +3 -7
- package/src/modal/index.js +2 -5
- package/src/modal/style.scss +19 -131
- package/src/newspack-icon/index.js +7 -2
- package/src/newspack-icon/style.scss +15 -0
- package/src/notice/index.js +7 -1
- package/src/notice/style.scss +38 -10
- package/src/plugin-installer/index.js +2 -2
- package/src/plugin-settings/SettingsSection.js +64 -26
- package/src/plugin-settings/index.js +23 -7
- package/src/plugin-settings/style.scss +7 -0
- package/src/plugin-toggle/index.js +35 -9
- package/src/popover/style.scss +2 -2
- package/src/radio-control/style.scss +1 -2
- package/src/section-header/index.js +25 -6
- package/src/section-header/style.scss +22 -1
- package/src/select-control/ButtonGroupControl.js +13 -6
- package/src/select-control/GroupedSelectControl.js +26 -24
- package/src/select-control/index.js +1 -2
- package/src/select-control/style.scss +46 -87
- 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/style-card/index.js +14 -16
- package/src/style-card/style.scss +12 -8
- package/src/style.scss +44 -0
- package/src/tabbed-navigation/index.js +12 -24
- package/src/tabbed-navigation/style.scss +56 -34
- package/src/text-control/index.js +1 -2
- package/src/text-control/style.scss +0 -126
- package/src/waiting/index.js +7 -18
- package/src/waiting/style.scss +9 -20
- package/src/web-preview/index.js +12 -33
- package/src/web-preview/style.scss +33 -26
- package/src/with-wizard/index.js +7 -5
- package/src/with-wizard/style.scss +44 -89
- package/src/with-wizard-screen/index.js +14 -17
- package/src/with-wizard-screen/style.scss +74 -121
- package/src/wizard/components/WizardError.js +57 -0
- package/src/wizard/index.js +133 -0
- package/src/wizard/store/index.js +126 -0
- package/src/wizard/store/utils.js +16 -0
- package/dist/cjs/button-group/index.js +0 -57
- package/dist/cjs/button-group/style.scss +0 -73
- package/dist/cjs/checkbox-control/index.js +0 -63
- package/dist/cjs/checkbox-control/style.scss +0 -78
- package/dist/cjs/preview-box/index.js +0 -36
- package/dist/cjs/preview-box/style.scss +0 -18
- package/dist/cjs/textarea-control/index.js +0 -54
- package/dist/cjs/textarea-control/style.scss +0 -76
- package/dist/cjs/toggle-control/index.js +0 -58
- package/dist/cjs/toggle-control/style.scss +0 -74
- package/dist/cjs/toggle-group/index.js +0 -71
- package/dist/cjs/toggle-group/style.scss +0 -28
- package/dist/cjs/wizard-pagination/index.js +0 -71
- package/dist/cjs/wizard-pagination/style.scss +0 -74
- package/dist/esm/button-group/index.js +0 -43
- package/dist/esm/button-group/style.scss +0 -73
- package/dist/esm/checkbox-control/index.js +0 -49
- package/dist/esm/checkbox-control/style.scss +0 -78
- package/dist/esm/preview-box/index.js +0 -30
- package/dist/esm/preview-box/style.scss +0 -18
- package/dist/esm/textarea-control/index.js +0 -40
- package/dist/esm/textarea-control/style.scss +0 -76
- package/dist/esm/toggle-control/index.js +0 -44
- package/dist/esm/toggle-control/style.scss +0 -74
- package/dist/esm/toggle-group/index.js +0 -58
- package/dist/esm/toggle-group/style.scss +0 -28
- 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
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _data = require("@wordpress/data");
|
|
15
|
+
|
|
16
|
+
var _element = require("@wordpress/element");
|
|
17
|
+
|
|
18
|
+
var _i18n = require("@wordpress/i18n");
|
|
19
|
+
|
|
20
|
+
var _icons = require("@wordpress/icons");
|
|
21
|
+
|
|
22
|
+
var _ = require("../");
|
|
23
|
+
|
|
24
|
+
var _router = _interopRequireDefault(require("../proxied-imports/router"));
|
|
25
|
+
|
|
26
|
+
var _store = _interopRequireWildcard(require("./store"));
|
|
27
|
+
|
|
28
|
+
var _utils = require("./store/utils");
|
|
29
|
+
|
|
30
|
+
var _WizardError = _interopRequireDefault(require("./components/WizardError"));
|
|
31
|
+
|
|
32
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* External dependencies.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* WordPress dependencies.
|
|
40
|
+
*/
|
|
41
|
+
const __ = _i18n.__;
|
|
42
|
+
(0, _store.default)();
|
|
43
|
+
const {
|
|
44
|
+
HashRouter,
|
|
45
|
+
Redirect,
|
|
46
|
+
Route,
|
|
47
|
+
Switch
|
|
48
|
+
} = _router.default;
|
|
49
|
+
|
|
50
|
+
const Wizard = _ref => {
|
|
51
|
+
let {
|
|
52
|
+
sections = [],
|
|
53
|
+
apiSlug,
|
|
54
|
+
headerText,
|
|
55
|
+
subHeaderText,
|
|
56
|
+
hasSimpleFooter,
|
|
57
|
+
className,
|
|
58
|
+
renderAboveSections,
|
|
59
|
+
requiredPlugins = []
|
|
60
|
+
} = _ref;
|
|
61
|
+
const isLoading = (0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).isLoading());
|
|
62
|
+
const isQuietLoading = (0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).isQuietLoading()); // Trigger initial data fetch. Some sections might not use the wizard data,
|
|
63
|
+
// but for consistency, fetching is triggered regardless of the section.
|
|
64
|
+
|
|
65
|
+
(0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).getWizardAPIData(apiSlug));
|
|
66
|
+
let displayedSections = sections.filter(section => !section.isHidden);
|
|
67
|
+
const [pluginRequirementsSatisfied, setPluginRequirementsSatisfied] = (0, _element.useState)(requiredPlugins.length === 0);
|
|
68
|
+
|
|
69
|
+
if (!pluginRequirementsSatisfied) {
|
|
70
|
+
headerText = requiredPlugins.length > 1 ? __('Required plugins', 'newspack') : __('Required plugin', 'newspack');
|
|
71
|
+
displayedSections = [{
|
|
72
|
+
path: '/',
|
|
73
|
+
render: () => (0, _jsxRuntime.jsx)(_.PluginInstaller, {
|
|
74
|
+
plugins: requiredPlugins,
|
|
75
|
+
onStatus: _ref2 => {
|
|
76
|
+
let {
|
|
77
|
+
complete
|
|
78
|
+
} = _ref2;
|
|
79
|
+
return setPluginRequirementsSatisfied(complete);
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
86
|
+
children: [(0, _jsxRuntime.jsx)(_WizardError.default, {}), (0, _jsxRuntime.jsx)("div", {
|
|
87
|
+
className: (0, _classnames.default)(isLoading ? 'newspack-wizard__is-loading' : 'newspack-wizard__is-loaded', {
|
|
88
|
+
'newspack-wizard__is-loading-quiet': isQuietLoading
|
|
89
|
+
}),
|
|
90
|
+
children: (0, _jsxRuntime.jsxs)(HashRouter, {
|
|
91
|
+
hashType: "slash",
|
|
92
|
+
children: [newspack_aux_data.is_debug_mode && (0, _jsxRuntime.jsx)(_.Notice, {
|
|
93
|
+
debugMode: true
|
|
94
|
+
}), (0, _jsxRuntime.jsx)("div", {
|
|
95
|
+
className: "bg-white",
|
|
96
|
+
children: (0, _jsxRuntime.jsx)("div", {
|
|
97
|
+
className: "newspack-wizard__header__inner",
|
|
98
|
+
children: (0, _jsxRuntime.jsxs)("div", {
|
|
99
|
+
className: "newspack-wizard__title",
|
|
100
|
+
children: [(0, _jsxRuntime.jsx)(_.Button, {
|
|
101
|
+
isLink: true,
|
|
102
|
+
href: newspack_urls.dashboard,
|
|
103
|
+
label: __('Return to Dashboard', 'newspack'),
|
|
104
|
+
showTooltip: true,
|
|
105
|
+
icon: _icons.category,
|
|
106
|
+
iconSize: 36,
|
|
107
|
+
children: (0, _jsxRuntime.jsx)(_.NewspackIcon, {
|
|
108
|
+
size: 36
|
|
109
|
+
})
|
|
110
|
+
}), (0, _jsxRuntime.jsxs)("div", {
|
|
111
|
+
children: [headerText && (0, _jsxRuntime.jsx)("h2", {
|
|
112
|
+
children: headerText
|
|
113
|
+
}), subHeaderText && (0, _jsxRuntime.jsx)("span", {
|
|
114
|
+
children: subHeaderText
|
|
115
|
+
})]
|
|
116
|
+
})]
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
}), displayedSections.length > 1 && (0, _jsxRuntime.jsx)(_.TabbedNavigation, {
|
|
120
|
+
items: displayedSections
|
|
121
|
+
}), (0, _jsxRuntime.jsxs)(Switch, {
|
|
122
|
+
children: [displayedSections.map((section, index) => {
|
|
123
|
+
const SectionComponent = section.render;
|
|
124
|
+
return (0, _jsxRuntime.jsx)(Route, {
|
|
125
|
+
path: section.path,
|
|
126
|
+
children: (0, _jsxRuntime.jsxs)("div", {
|
|
127
|
+
className: (0, _classnames.default)('newspack-wizard newspack-wizard__content', className),
|
|
128
|
+
children: ['function' === typeof renderAboveSections ? renderAboveSections() : null, (0, _jsxRuntime.jsx)(SectionComponent, {})]
|
|
129
|
+
})
|
|
130
|
+
}, index);
|
|
131
|
+
}), (0, _jsxRuntime.jsx)(Redirect, {
|
|
132
|
+
to: displayedSections[0].path
|
|
133
|
+
})]
|
|
134
|
+
})]
|
|
135
|
+
})
|
|
136
|
+
}), !isLoading && (0, _jsxRuntime.jsx)(_.Footer, {
|
|
137
|
+
simple: hasSimpleFooter
|
|
138
|
+
})]
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
Wizard.useWizardData = _utils.useWizardData;
|
|
143
|
+
Wizard.STORE_NAMESPACE = _store.WIZARD_STORE_NAMESPACE;
|
|
144
|
+
var _default = Wizard;
|
|
145
|
+
exports.default = _default;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = exports.WIZARD_STORE_NAMESPACE = void 0;
|
|
9
|
+
|
|
10
|
+
var _lodash = require("lodash");
|
|
11
|
+
|
|
12
|
+
var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
13
|
+
|
|
14
|
+
var _data = require("@wordpress/data");
|
|
15
|
+
|
|
16
|
+
var _utils = require("./utils.js");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* External dependencies.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* WordPress dependencies.
|
|
24
|
+
*/
|
|
25
|
+
const WIZARD_STORE_NAMESPACE = 'newspack/wizards';
|
|
26
|
+
exports.WIZARD_STORE_NAMESPACE = WIZARD_STORE_NAMESPACE;
|
|
27
|
+
const DEFAULT_STATE = {
|
|
28
|
+
isLoading: true,
|
|
29
|
+
isQuietLoading: false,
|
|
30
|
+
apiData: {},
|
|
31
|
+
error: null
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* wordpress/data does not trigger a component re-render
|
|
35
|
+
* on deep state change (via lodash's set function)
|
|
36
|
+
* unless the state was cloned first.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
const clone = objectToClone => JSON.parse(JSON.stringify(objectToClone));
|
|
40
|
+
|
|
41
|
+
const reducer = function () {
|
|
42
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_STATE;
|
|
43
|
+
let {
|
|
44
|
+
type,
|
|
45
|
+
payload = {}
|
|
46
|
+
} = arguments.length > 1 ? arguments[1] : undefined;
|
|
47
|
+
|
|
48
|
+
switch (type) {
|
|
49
|
+
case 'START_LOADING_DATA':
|
|
50
|
+
if (payload.isQuietLoading) {
|
|
51
|
+
return { ...state,
|
|
52
|
+
isQuietLoading: true
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return { ...state,
|
|
57
|
+
isLoading: true
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
case 'FINISH_LOADING_DATA':
|
|
61
|
+
return { ...state,
|
|
62
|
+
isLoading: false,
|
|
63
|
+
isQuietLoading: false
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
case 'SET_API_DATA':
|
|
67
|
+
return (0, _lodash.set)(clone(state), ['apiData', payload.slug], payload.data);
|
|
68
|
+
|
|
69
|
+
case 'UPDATE_WIZARD_SETTINGS':
|
|
70
|
+
return (0, _lodash.set)(clone(state), ['apiData', payload.slug, ...payload.path], payload.value);
|
|
71
|
+
|
|
72
|
+
case 'SET_ERROR':
|
|
73
|
+
return { ...state,
|
|
74
|
+
error: payload
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
default:
|
|
78
|
+
return state;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const actions = {
|
|
83
|
+
// Regular actions.
|
|
84
|
+
startLoadingData: (0, _utils.createAction)('START_LOADING_DATA'),
|
|
85
|
+
finishLoadingData: (0, _utils.createAction)('FINISH_LOADING_DATA'),
|
|
86
|
+
fetchFromAPI: (0, _utils.createAction)('FETCH_FROM_API'),
|
|
87
|
+
setAPIDataForWizard: (0, _utils.createAction)('SET_API_DATA'),
|
|
88
|
+
updateWizardSettings: (0, _utils.createAction)('UPDATE_WIZARD_SETTINGS'),
|
|
89
|
+
setError: (0, _utils.createAction)('SET_ERROR'),
|
|
90
|
+
|
|
91
|
+
// Async actions. These will not show up in Redux devtools.
|
|
92
|
+
*saveWizardSettings(_ref) {
|
|
93
|
+
let {
|
|
94
|
+
slug,
|
|
95
|
+
section = '',
|
|
96
|
+
payloadPath = false,
|
|
97
|
+
updatePayload = null
|
|
98
|
+
} = _ref;
|
|
99
|
+
|
|
100
|
+
// Optionally data can be updated before saving - an immediate update case
|
|
101
|
+
// (without an explicit "save" action).
|
|
102
|
+
if (updatePayload) {
|
|
103
|
+
yield actions.updateWizardSettings({
|
|
104
|
+
slug,
|
|
105
|
+
...updatePayload
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const wizardState = (0, _data.select)(WIZARD_STORE_NAMESPACE).getWizardAPIData(slug);
|
|
110
|
+
const updatedData = yield actions.fetchFromAPI({
|
|
111
|
+
path: `/newspack/v1/wizard/${slug}/${section}`,
|
|
112
|
+
method: 'POST',
|
|
113
|
+
data: payloadPath ? (0, _lodash.get)(wizardState, payloadPath) : wizardState,
|
|
114
|
+
isQuietFetch: true
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
if (!(0, _lodash.isEmpty)(updatedData)) {
|
|
118
|
+
return actions.setAPIDataForWizard({
|
|
119
|
+
slug,
|
|
120
|
+
data: updatedData
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
*wizardApiFetch(fetchConfig) {
|
|
126
|
+
// Just a proxy to fetchFromAPI, but it has to be a generator.
|
|
127
|
+
const result = yield actions.fetchFromAPI(fetchConfig);
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
};
|
|
132
|
+
const selectors = {
|
|
133
|
+
isLoading: state => state.isLoading,
|
|
134
|
+
isQuietLoading: state => state.isQuietLoading,
|
|
135
|
+
getWizardAPIData: (state, slug) => state.apiData[slug] || {},
|
|
136
|
+
getError: state => state.error
|
|
137
|
+
};
|
|
138
|
+
const store = (0, _data.createReduxStore)(WIZARD_STORE_NAMESPACE, {
|
|
139
|
+
reducer,
|
|
140
|
+
actions,
|
|
141
|
+
selectors,
|
|
142
|
+
controls: {
|
|
143
|
+
FETCH_FROM_API: action => {
|
|
144
|
+
(0, _data.dispatch)(WIZARD_STORE_NAMESPACE).startLoadingData({
|
|
145
|
+
isQuietLoading: Boolean(action.payload.isQuietFetch)
|
|
146
|
+
});
|
|
147
|
+
return (0, _apiFetch.default)(action.payload).catch(error => {
|
|
148
|
+
(0, _data.dispatch)(WIZARD_STORE_NAMESPACE).setError(error);
|
|
149
|
+
return {
|
|
150
|
+
error
|
|
151
|
+
};
|
|
152
|
+
}).finally(result => {
|
|
153
|
+
(0, _data.dispatch)(WIZARD_STORE_NAMESPACE).finishLoadingData();
|
|
154
|
+
return result;
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
resolvers: {
|
|
159
|
+
*getWizardAPIData(slug) {
|
|
160
|
+
if (slug) {
|
|
161
|
+
const data = yield actions.fetchFromAPI({
|
|
162
|
+
path: `/newspack/v1/wizard/${slug}`
|
|
163
|
+
});
|
|
164
|
+
return actions.setAPIDataForWizard({
|
|
165
|
+
slug,
|
|
166
|
+
data
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return actions.finishLoadingData();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
var _default = () => (0, _data.register)(store);
|
|
177
|
+
|
|
178
|
+
exports.default = _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useWizardData = exports.createAction = void 0;
|
|
7
|
+
|
|
8
|
+
var _data = require("@wordpress/data");
|
|
9
|
+
|
|
10
|
+
var _ = require(".");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
const createAction = type => payload => ({
|
|
20
|
+
type,
|
|
21
|
+
payload
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
exports.createAction = createAction;
|
|
25
|
+
|
|
26
|
+
const useWizardData = function (wizardName) {
|
|
27
|
+
let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28
|
+
return (0, _data.useSelect)(select => select(_.WIZARD_STORE_NAMESPACE).getWizardAPIData(`newspack-${wizardName}-wizard`)) || defaultValue;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.useWizardData = useWizardData;
|
|
@@ -8,13 +8,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { Component } from '@wordpress/element';
|
|
11
|
-
import { ExternalLink } from '@wordpress/components';
|
|
11
|
+
import { ExternalLink, ToggleControl } from '@wordpress/components';
|
|
12
12
|
import { Icon, check } from '@wordpress/icons';
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { Button, Card, Handoff, Notice,
|
|
17
|
+
import { Button, Card, Grid, Handoff, Notice, Waiting } from '../';
|
|
18
18
|
import './style.scss';
|
|
19
19
|
/**
|
|
20
20
|
* External dependencies
|
|
@@ -56,8 +56,10 @@ class ActionCard extends Component {
|
|
|
56
56
|
actionContent,
|
|
57
57
|
actionText,
|
|
58
58
|
secondaryActionText,
|
|
59
|
+
secondaryDestructive,
|
|
59
60
|
image,
|
|
60
61
|
imageLink,
|
|
62
|
+
indent,
|
|
61
63
|
isSmall,
|
|
62
64
|
isMedium,
|
|
63
65
|
simple,
|
|
@@ -67,10 +69,11 @@ class ActionCard extends Component {
|
|
|
67
69
|
titleLink,
|
|
68
70
|
toggleChecked,
|
|
69
71
|
toggleOnChange,
|
|
70
|
-
hasGreyHeader
|
|
72
|
+
hasGreyHeader,
|
|
73
|
+
isPending
|
|
71
74
|
} = this.props;
|
|
72
75
|
const hasChildren = notification || children;
|
|
73
|
-
const classes = classnames('newspack-action-card', simple && 'newspack-card--is-clickable', hasGreyHeader && 'newspack-card--has-grey-header', hasChildren && 'newspack-card--has-children', isSmall && 'is-small', isMedium && 'is-medium', className);
|
|
76
|
+
const classes = classnames('newspack-action-card', simple && 'newspack-card--is-clickable', hasGreyHeader && 'newspack-card--has-grey-header', hasChildren && 'newspack-card--has-children', indent && 'newspack-card--indent', isSmall && 'is-small', isMedium && 'is-medium', className);
|
|
74
77
|
const titleProps = toggleOnChange && !titleLink && !disabled ? {
|
|
75
78
|
onClick: () => toggleOnChange(!toggleChecked),
|
|
76
79
|
tabIndex: '0'
|
|
@@ -99,28 +102,33 @@ class ActionCard extends Component {
|
|
|
99
102
|
}), checkbox && !toggleOnChange && _jsx("div", {
|
|
100
103
|
className: "newspack-action-card__region newspack-action-card__region-left",
|
|
101
104
|
children: _jsx("span", {
|
|
102
|
-
className: classnames('newspack-checkbox-icon', 'is-primary', 'checked' === checkbox && 'newspack-checkbox-icon--checked'),
|
|
105
|
+
className: classnames('newspack-checkbox-icon', 'is-primary', 'checked' === checkbox && 'newspack-checkbox-icon--checked', isPending && 'newspack-checkbox-icon--pending'),
|
|
103
106
|
children: 'checked' === checkbox && _jsx(Icon, {
|
|
104
107
|
icon: check
|
|
105
108
|
})
|
|
106
109
|
})
|
|
107
|
-
}),
|
|
110
|
+
}), _jsx("div", {
|
|
108
111
|
className: "newspack-action-card__region newspack-action-card__region-center",
|
|
109
|
-
children:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
112
|
+
children: _jsxs(Grid, {
|
|
113
|
+
columns: 1,
|
|
114
|
+
gutter: 8,
|
|
115
|
+
noMargin: true,
|
|
116
|
+
children: [_jsxs("h2", {
|
|
117
|
+
children: [_jsx("span", {
|
|
118
|
+
className: "newspack-action-card__title",
|
|
119
|
+
...titleProps,
|
|
120
|
+
children: titleLink ? _jsx("a", {
|
|
121
|
+
href: titleLink,
|
|
122
|
+
children: title
|
|
123
|
+
}) : title
|
|
124
|
+
}), badges?.length && badges.map((badgeText, i) => _jsx("span", {
|
|
125
|
+
className: "newspack-action-card__badge",
|
|
126
|
+
children: badgeText
|
|
127
|
+
}, `badge-${i}`))]
|
|
128
|
+
}), description && _jsxs("p", {
|
|
129
|
+
children: [typeof description === 'string' && description, typeof description === 'function' && description()]
|
|
130
|
+
})]
|
|
131
|
+
})
|
|
124
132
|
}), (actionText || isDisplayingSecondaryAction || actionContent) && _jsxs("div", {
|
|
125
133
|
className: "newspack-action-card__region newspack-action-card__region-right",
|
|
126
134
|
children: [actionContent && actionContent, actionText && (handoff ? _jsx(Handoff, {
|
|
@@ -148,6 +156,7 @@ class ActionCard extends Component {
|
|
|
148
156
|
isLink: true,
|
|
149
157
|
onClick: onSecondaryActionClick,
|
|
150
158
|
className: "newspack-action-card__secondary_button",
|
|
159
|
+
isDestructive: secondaryDestructive,
|
|
151
160
|
children: secondaryActionText
|
|
152
161
|
})]
|
|
153
162
|
})]
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
@import '~@wordpress/base-styles/colors';
|
|
6
|
-
@import '../../../shared/scss/colors';
|
|
7
6
|
|
|
8
7
|
.newspack-card.newspack-action-card {
|
|
9
8
|
padding: 0;
|
|
@@ -34,7 +33,7 @@
|
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
&.newspack-card__is-primary {
|
|
37
|
-
box-shadow: inset 4px 0 0
|
|
36
|
+
box-shadow: inset 4px 0 0 var( --wp-admin-theme-color );
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
&.newspack-card__is-secondary {
|
|
@@ -150,20 +149,49 @@
|
|
|
150
149
|
|
|
151
150
|
&.newspack-card--has-grey-header {
|
|
152
151
|
overflow: hidden;
|
|
152
|
+
|
|
153
153
|
&.newspack-card--has-children {
|
|
154
154
|
.newspack-action-card__region-top {
|
|
155
155
|
border-bottom: 1px solid $gray-300;
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
+
|
|
158
159
|
.newspack-action-card__region-top {
|
|
159
|
-
background-color:
|
|
160
|
+
background-color: rgba( black, 0.025 );
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.newspack-action-card__region-center {
|
|
164
|
+
p {
|
|
165
|
+
color: darken( $gray-700, 0.75% );
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Indent
|
|
171
|
+
|
|
172
|
+
&.newspack-card--indent {
|
|
173
|
+
margin-left: 56px;
|
|
174
|
+
position: relative;
|
|
175
|
+
|
|
176
|
+
&::before {
|
|
177
|
+
border: 0 solid $gray-300;
|
|
178
|
+
border-left-width: 1px;
|
|
179
|
+
border-bottom-width: 1px;
|
|
180
|
+
border-radius: 0 0 0 2px;
|
|
181
|
+
bottom: 50%;
|
|
182
|
+
content: '';
|
|
183
|
+
display: block;
|
|
184
|
+
left: -28px;
|
|
185
|
+
position: absolute;
|
|
186
|
+
right: 100%;
|
|
187
|
+
top: -17px;
|
|
160
188
|
}
|
|
161
189
|
}
|
|
162
190
|
|
|
163
191
|
// Typography
|
|
164
192
|
|
|
165
193
|
h2,
|
|
166
|
-
p {
|
|
194
|
+
p:not( [class*='components-base-control'] ) {
|
|
167
195
|
margin: 0;
|
|
168
196
|
max-width: 100%;
|
|
169
197
|
width: 100%;
|
|
@@ -186,7 +214,7 @@
|
|
|
186
214
|
&:active,
|
|
187
215
|
&:focus,
|
|
188
216
|
&:hover {
|
|
189
|
-
color:
|
|
217
|
+
color: var( --wp-admin-theme-color );
|
|
190
218
|
}
|
|
191
219
|
}
|
|
192
220
|
}
|
|
@@ -270,6 +298,14 @@
|
|
|
270
298
|
align-items: flex-start;
|
|
271
299
|
flex: 1 1 auto;
|
|
272
300
|
flex-wrap: wrap;
|
|
301
|
+
|
|
302
|
+
.newspack-grid {
|
|
303
|
+
width: 100%;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
p {
|
|
307
|
+
color: $gray-700;
|
|
308
|
+
}
|
|
273
309
|
}
|
|
274
310
|
|
|
275
311
|
.newspack-action-card__region-right {
|
|
@@ -289,6 +325,10 @@
|
|
|
289
325
|
> * {
|
|
290
326
|
text-align: inherit;
|
|
291
327
|
}
|
|
328
|
+
|
|
329
|
+
.newspack-action-card__secondary_button {
|
|
330
|
+
margin-top: 8px;
|
|
331
|
+
}
|
|
292
332
|
}
|
|
293
333
|
|
|
294
334
|
// Waiting
|
|
@@ -326,34 +366,19 @@
|
|
|
326
366
|
margin: 0;
|
|
327
367
|
}
|
|
328
368
|
|
|
329
|
-
// Buttons
|
|
330
|
-
|
|
331
|
-
.newspack-button {
|
|
332
|
-
&.newspack-action-card__secondary_button {
|
|
333
|
-
&.is-link {
|
|
334
|
-
color: $alert-red;
|
|
335
|
-
|
|
336
|
-
&:active,
|
|
337
|
-
&:focus,
|
|
338
|
-
&:hover {
|
|
339
|
-
color: darken( $alert-red, 20% );
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
369
|
// Badge
|
|
346
370
|
|
|
347
371
|
.newspack-action-card__badge {
|
|
348
|
-
|
|
349
|
-
border-radius:
|
|
372
|
+
background: $gray-100;
|
|
373
|
+
border-radius: 2px;
|
|
374
|
+
color: $gray-900;
|
|
350
375
|
display: block;
|
|
351
376
|
flex: 0 0 auto;
|
|
352
|
-
font-size:
|
|
377
|
+
font-size: 10px;
|
|
353
378
|
font-weight: bold;
|
|
354
|
-
line-height:
|
|
355
|
-
margin:
|
|
356
|
-
padding:
|
|
379
|
+
line-height: 1.4;
|
|
380
|
+
margin: 0 8px 0 0;
|
|
381
|
+
padding: 2px 8px;
|
|
357
382
|
text-transform: uppercase;
|
|
358
383
|
|
|
359
384
|
+ .newspack-action-card__badge {
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Autocomplete Token Field
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
@import '../../../shared/scss/colors';
|
|
6
5
|
@import '~@wordpress/base-styles/colors';
|
|
7
6
|
|
|
8
7
|
.newspack-autocomplete-tokenfield {
|
|
9
8
|
position: relative;
|
|
10
9
|
|
|
11
10
|
.components-spinner {
|
|
11
|
+
margin: 8px;
|
|
12
12
|
position: absolute;
|
|
13
|
-
right:
|
|
14
|
-
top:
|
|
13
|
+
right: 0;
|
|
14
|
+
top: calc( 1.4em + 8px );
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/* Workaround for hard-coded help text in FormTokenField. */
|
|
@@ -38,6 +38,6 @@
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
.components-button:focus:not( :disabled ) {
|
|
41
|
-
box-shadow: inset 0 0 0
|
|
41
|
+
box-shadow: inset 0 0 0 var( --wp-admin-border-width-focus ) var( --wp-admin-theme-color );
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -144,7 +144,7 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
144
144
|
return posts.reduce((acc, post) => {
|
|
145
145
|
acc.push({
|
|
146
146
|
value: parseInt(post.id),
|
|
147
|
-
label: decodeEntities(post
|
|
147
|
+
label: decodeEntities(post?.title.rendered) || __('(no title)', 'newspack')
|
|
148
148
|
});
|
|
149
149
|
return acc;
|
|
150
150
|
}, []);
|
|
@@ -197,6 +197,7 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
197
197
|
children: [selectedMessage, 1 < selections.length && _x(' – ', 'separator character', 'newspack'), 1 < selections.length && _jsx(Button, {
|
|
198
198
|
onClick: () => onChange([]),
|
|
199
199
|
isLink: true,
|
|
200
|
+
isDestructive: true,
|
|
200
201
|
children: __('Clear all', 'newspack')
|
|
201
202
|
})]
|
|
202
203
|
}), selections.map(selection => _jsx(Button, {
|
|
@@ -234,7 +235,7 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
234
235
|
const renderSuggestion = suggestion => {
|
|
235
236
|
if (multiSelect) {
|
|
236
237
|
const selections = selectedPost ? [...selectedItems, selectedPost] : [...selectedItems];
|
|
237
|
-
const isSelected = !!selections.find(_selection => parseInt(_selection.value) === parseInt(suggestion.value));
|
|
238
|
+
const isSelected = !!selections.find(_selection => parseInt(_selection.value) === parseInt(suggestion.value) && _selection.label === suggestion.label);
|
|
238
239
|
return _jsx(CheckboxControl, {
|
|
239
240
|
checked: isSelected,
|
|
240
241
|
onChange: () => handleOnChange([suggestion]),
|