newspack-components 3.1.0 → 4.0.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 +277 -0
- package/copy-styles.js +8 -1
- package/dist/cjs/action-card/action-card.d.js +5 -0
- package/dist/cjs/action-card/index.js +282 -187
- package/dist/cjs/action-card/style.scss +142 -44
- package/dist/cjs/autocomplete-tokenfield/index.js +6 -2
- package/dist/cjs/box-contrast/index.js +49 -0
- package/dist/cjs/button/index.js +1 -1
- package/dist/cjs/button-props/button-props.js +41 -0
- package/dist/cjs/button-props/index.js +13 -0
- package/dist/cjs/color-picker/index.js +11 -0
- package/dist/cjs/custom-select-control/style.scss +7 -12
- package/dist/cjs/footer/index.js +17 -24
- package/dist/cjs/footer/style.scss +0 -36
- package/dist/cjs/handoff-message/index.js +0 -3
- package/dist/cjs/hooks/useObjectState.js +9 -0
- package/dist/cjs/hooks/useObjectState.test.js +5 -5
- package/dist/cjs/index.js +7 -21
- package/dist/cjs/modal/index.js +4 -1
- package/dist/cjs/modal/style.scss +18 -7
- package/dist/cjs/newspack-icon/index.js +2 -2
- package/dist/cjs/newspack-icon/style.scss +3 -5
- package/dist/cjs/notice/index.js +1 -2
- package/dist/cjs/notice/style.scss +11 -9
- package/dist/cjs/plugin-installer/index.js +3 -3
- package/dist/cjs/plugin-settings/SettingsSection.js +2 -0
- package/dist/cjs/plugin-settings/index.js +4 -1
- package/dist/cjs/plugin-toggle/index.js +2 -0
- package/dist/cjs/popover/style.scss +5 -6
- package/dist/cjs/progress-bar/index.test.js +1 -2
- package/dist/cjs/progress-bar/style.scss +1 -2
- package/dist/cjs/proxied-imports/router.js +1 -2
- package/dist/cjs/radio-control/style.scss +4 -10
- package/dist/cjs/section-header/index.js +21 -1
- package/dist/cjs/select-control/ButtonGroupControl.js +2 -0
- package/dist/cjs/settings/SettingsCard.js +2 -6
- package/dist/cjs/sortable-newsletter-list-control/index.js +7 -5
- package/dist/cjs/sortable-newsletter-list-control/style.scss +11 -1
- package/dist/cjs/steps-list/style.scss +0 -3
- package/dist/cjs/steps-list-item/style.scss +1 -2
- package/dist/cjs/style-card/index.js +1 -0
- package/dist/cjs/style-card/style.scss +4 -5
- package/dist/cjs/style.scss +15 -0
- package/dist/cjs/tabbed-navigation/index.js +17 -7
- package/dist/cjs/tabbed-navigation/style.scss +2 -6
- package/dist/cjs/utils/color.js +35 -0
- package/dist/cjs/web-preview/style.scss +11 -11
- package/dist/cjs/with-wizard/index.js +80 -3
- package/dist/cjs/with-wizard/style.scss +34 -13
- package/dist/cjs/with-wizard-screen/index.js +3 -3
- package/dist/cjs/with-wizard-screen/style.scss +9 -9
- package/dist/cjs/wizard/index.js +38 -13
- package/dist/cjs/wizard/store/index.js +13 -5
- package/dist/cjs/wizard/store/utils.js +3 -1
- package/dist/esm/action-card/action-card.d.js +1 -0
- package/dist/esm/action-card/index.js +286 -189
- package/dist/esm/action-card/style.scss +142 -44
- package/dist/esm/autocomplete-tokenfield/index.js +6 -2
- package/dist/esm/box-contrast/index.js +44 -0
- package/dist/esm/button/index.js +1 -1
- package/dist/esm/button-props/button-props.js +34 -0
- package/dist/esm/button-props/index.js +1 -0
- package/dist/esm/color-picker/index.js +11 -0
- package/dist/esm/custom-select-control/style.scss +7 -12
- package/dist/esm/footer/index.js +18 -25
- package/dist/esm/footer/style.scss +0 -36
- package/dist/esm/handoff-message/index.js +0 -3
- package/dist/esm/hooks/useObjectState.js +10 -0
- package/dist/esm/hooks/useObjectState.test.js +6 -6
- package/dist/esm/index.js +1 -3
- package/dist/esm/modal/index.js +4 -1
- package/dist/esm/modal/style.scss +18 -7
- package/dist/esm/newspack-icon/index.js +2 -2
- package/dist/esm/newspack-icon/style.scss +3 -5
- package/dist/esm/notice/index.js +1 -2
- package/dist/esm/notice/style.scss +11 -9
- package/dist/esm/plugin-installer/index.js +3 -3
- package/dist/esm/plugin-settings/SettingsSection.js +2 -0
- package/dist/esm/plugin-settings/index.js +4 -1
- package/dist/esm/plugin-toggle/index.js +2 -0
- package/dist/esm/popover/style.scss +5 -6
- package/dist/esm/progress-bar/style.scss +1 -2
- package/dist/esm/radio-control/style.scss +4 -10
- package/dist/esm/section-header/index.js +22 -0
- package/dist/esm/select-control/ButtonGroupControl.js +2 -0
- package/dist/esm/settings/SettingsCard.js +2 -6
- package/dist/esm/sortable-newsletter-list-control/index.js +8 -6
- package/dist/esm/sortable-newsletter-list-control/style.scss +11 -1
- package/dist/esm/steps-list/style.scss +0 -3
- package/dist/esm/steps-list-item/style.scss +1 -2
- package/dist/esm/style-card/index.js +1 -0
- package/dist/esm/style-card/style.scss +4 -5
- package/dist/esm/style.scss +15 -0
- package/dist/esm/tabbed-navigation/index.js +17 -7
- package/dist/esm/tabbed-navigation/style.scss +2 -6
- package/dist/esm/utils/color.js +29 -0
- package/dist/esm/web-preview/style.scss +11 -11
- package/dist/esm/with-wizard/index.js +81 -4
- package/dist/esm/with-wizard/style.scss +34 -13
- package/dist/esm/with-wizard-screen/index.js +1 -1
- package/dist/esm/with-wizard-screen/style.scss +9 -9
- package/dist/esm/wizard/index.js +39 -13
- package/dist/esm/wizard/store/index.js +13 -5
- package/dist/esm/wizard/store/utils.js +3 -1
- package/package.json +1 -1
- package/src/accordion/index.js +1 -3
- package/src/action-card/action-card.d.ts +40 -0
- package/src/action-card/index.js +284 -202
- package/src/action-card/style.scss +142 -44
- package/src/autocomplete-tokenfield/index.js +3 -2
- package/src/autocomplete-with-suggestions/index.js +52 -63
- package/src/box-contrast/index.tsx +44 -0
- package/src/button/index.tsx +1 -1
- package/src/button-card/index.js +1 -12
- package/src/card/index.js +1 -11
- package/src/category-autocomplete/index.js +4 -19
- package/src/color-picker/index.js +11 -7
- package/src/custom-select-control/style.scss +7 -12
- package/src/footer/index.js +6 -18
- package/src/footer/style.scss +0 -36
- package/src/form-token-field/index.js +1 -2
- package/src/grid/index.tsx +1 -8
- package/src/handoff/index.js +4 -11
- package/src/handoff-message/index.js +0 -3
- package/src/hooks/useObjectState.js +10 -2
- package/src/hooks/useObjectState.test.js +14 -14
- package/src/image-upload/index.js +3 -23
- package/src/index.js +1 -3
- package/src/modal/index.js +2 -2
- package/src/modal/style.scss +18 -7
- package/src/newspack-icon/index.js +3 -14
- package/src/newspack-icon/style.scss +3 -5
- package/src/notice/index.js +0 -2
- package/src/notice/style.scss +11 -9
- package/src/plugin-installer/index.js +8 -17
- package/src/plugin-settings/SettingsSection.js +3 -7
- package/src/plugin-settings/index.js +7 -14
- package/src/plugin-toggle/README.md +3 -3
- package/src/plugin-toggle/index.js +10 -13
- package/src/popover/index.js +1 -5
- package/src/popover/style.scss +5 -6
- package/src/position-control/index.js +65 -75
- package/src/progress-bar/index.js +2 -9
- package/src/progress-bar/index.test.js +4 -13
- package/src/progress-bar/style.scss +1 -2
- package/src/radio-control/style.scss +4 -10
- package/src/section-header/index.js +20 -0
- package/src/select-control/ButtonGroupControl.js +2 -9
- package/src/select-control/GroupedSelectControl.js +1 -9
- package/src/select-control/index.js +1 -5
- package/src/settings/MinMaxSetting.js +2 -14
- package/src/settings/SettingsCard.js +2 -11
- package/src/sortable-newsletter-list-control/index.js +10 -26
- package/src/sortable-newsletter-list-control/style.scss +11 -1
- package/src/steps-list/style.scss +0 -3
- package/src/steps-list-item/index.js +1 -4
- package/src/steps-list-item/style.scss +1 -2
- package/src/style-card/index.js +6 -21
- package/src/style-card/style.scss +4 -5
- package/src/style.scss +15 -0
- package/src/tabbed-navigation/index.js +19 -7
- package/src/tabbed-navigation/style.scss +2 -6
- package/src/text-control/index.tsx +2 -12
- package/src/utils/color.ts +32 -0
- package/src/web-preview/style.scss +11 -11
- package/src/with-wizard/index.js +67 -16
- package/src/with-wizard/style.scss +34 -13
- package/src/with-wizard-screen/index.js +1 -1
- package/src/with-wizard-screen/style.scss +9 -9
- package/src/wizard/components/WizardError.js +2 -7
- package/src/wizard/index.js +64 -62
- package/src/wizard/store/index.js +8 -10
- package/src/wizard/store/utils.js +3 -4
- package/dist/cjs/date-range-picker/index.js +0 -39
- package/dist/cjs/date-range-picker/style.scss +0 -148
- package/dist/cjs/newspack-logo/index.js +0 -54
- package/dist/cjs/newspack-logo/style.scss +0 -30
- package/dist/cjs/patrons-logo/index.js +0 -77
- package/dist/esm/date-range-picker/index.js +0 -31
- package/dist/esm/date-range-picker/style.scss +0 -148
- package/dist/esm/newspack-logo/index.js +0 -46
- package/dist/esm/newspack-logo/style.scss +0 -30
- package/dist/esm/patrons-logo/index.js +0 -70
- package/shared/scss/_colors.scss +0 -27
- package/src/date-range-picker/index.js +0 -31
- package/src/date-range-picker/style.scss +0 -148
- package/src/newspack-logo/index.js +0 -45
- package/src/newspack-logo/style.scss +0 -30
- package/src/patrons-logo/index.js +0 -76
- /package/{shared/js → src/button-props}/button-props.js +0 -0
- /package/{shared/js → src/button-props}/index.js +0 -0
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
.newspack__newsletter-list-control {
|
|
2
|
+
grid-column: span 3;
|
|
3
|
+
|
|
2
4
|
&__selected {
|
|
3
5
|
.newspack-card {
|
|
4
6
|
display: flex;
|
|
5
7
|
justify-content: center;
|
|
6
8
|
min-height: 40px;
|
|
7
9
|
flex-direction: row;
|
|
10
|
+
&:first-of-type {
|
|
11
|
+
margin-top: 0 !important;
|
|
12
|
+
}
|
|
8
13
|
.newspack-action-card__region {
|
|
9
14
|
align-items: center;
|
|
10
15
|
display: flex;
|
|
@@ -14,11 +19,16 @@
|
|
|
14
19
|
.newspack-action-card__region-top {
|
|
15
20
|
flex: 1;
|
|
16
21
|
order: 2;
|
|
22
|
+
|
|
23
|
+
.newspack-grid {
|
|
24
|
+
margin: 0;
|
|
25
|
+
}
|
|
17
26
|
}
|
|
18
27
|
.newspack-action-card__region-children {
|
|
19
|
-
padding: 12px;
|
|
28
|
+
padding: 12px !important;
|
|
20
29
|
}
|
|
21
30
|
}
|
|
31
|
+
|
|
22
32
|
}
|
|
23
33
|
&__sort-handle {
|
|
24
34
|
display: flex;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
@use "../../../shared/scss/colors";
|
|
2
1
|
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
3
2
|
|
|
4
3
|
.steps-list-item {
|
|
@@ -35,7 +34,7 @@
|
|
|
35
34
|
background: #fff;
|
|
36
35
|
border: 1px solid currentcolor;
|
|
37
36
|
border-radius: 100%;
|
|
38
|
-
color:
|
|
37
|
+
color: var(--wp-admin-theme-color);
|
|
39
38
|
display: flex;
|
|
40
39
|
height: 28px;
|
|
41
40
|
justify-content: center;
|
|
@@ -51,6 +51,7 @@ class StyleCard extends _element.Component {
|
|
|
51
51
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
52
52
|
className: "newspack-style-card__image",
|
|
53
53
|
children: [imageType === 'html' ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
54
|
+
className: "newspack-style-card__image-html",
|
|
54
55
|
dangerouslySetInnerHTML: image
|
|
55
56
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
56
57
|
src: image,
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Style Card
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
@use "../../../shared/scss/colors";
|
|
6
5
|
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
7
6
|
|
|
8
7
|
.newspack-style-card {
|
|
@@ -15,7 +14,7 @@
|
|
|
15
14
|
text-align: center;
|
|
16
15
|
|
|
17
16
|
.newspack-style-card__is-active & {
|
|
18
|
-
color:
|
|
17
|
+
color: var(--wp-admin-theme-color);
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
|
|
@@ -48,8 +47,8 @@
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
.newspack-style-card__is-active & {
|
|
51
|
-
border-color:
|
|
52
|
-
box-shadow: inset 0 0 0 1px
|
|
50
|
+
border-color: var(--wp-admin-theme-color);
|
|
51
|
+
box-shadow: inset 0 0 0 1px var(--wp-admin-theme-color);
|
|
53
52
|
|
|
54
53
|
img {
|
|
55
54
|
position: relative;
|
|
@@ -88,7 +87,7 @@
|
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
.newspack-style-card__is-active & {
|
|
91
|
-
box-shadow: inset 0 0 0 1px
|
|
90
|
+
box-shadow: inset 0 0 0 1px var(--wp-admin-theme-color);
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
}
|
package/dist/cjs/style.scss
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
2
|
+
@use "../../colors/colors.module" as colors;
|
|
3
|
+
|
|
4
|
+
:root {
|
|
5
|
+
// WP Admin
|
|
6
|
+
--wp-admin-theme-color: #{colors.$primary-600};
|
|
7
|
+
--wp-admin-theme-color--rgb: #{colors.$primary-600--rgb};
|
|
8
|
+
--wp-admin-theme-color-darker-10: #{colors.$primary-700};
|
|
9
|
+
--wp-admin-theme-color-darker-10--rgb: #{colors.$primary-700--rgb};
|
|
10
|
+
--wp-admin-theme-color-darker-20: #{colors.$primary-800};
|
|
11
|
+
--wp-admin-theme-color-darker-20--rgb: #{colors.$primary-800--rgb};
|
|
12
|
+
}
|
|
2
13
|
|
|
3
14
|
// Buttons Card
|
|
4
15
|
|
|
@@ -13,6 +24,10 @@
|
|
|
13
24
|
&:empty {
|
|
14
25
|
display: none;
|
|
15
26
|
}
|
|
27
|
+
|
|
28
|
+
+ .newspack-card {
|
|
29
|
+
margin-top: 64px;
|
|
30
|
+
}
|
|
16
31
|
}
|
|
17
32
|
|
|
18
33
|
// Checkboxes
|
|
@@ -33,6 +33,21 @@ const TabbedNavigation = ({
|
|
|
33
33
|
location
|
|
34
34
|
} = useHistory();
|
|
35
35
|
const currentIndex = (0, _findIndex.default)(displayedItems, ['path', location.pathname]);
|
|
36
|
+
function isActive(item, match, pathname) {
|
|
37
|
+
if (item.path === pathname) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(item?.activeTabPaths)) {
|
|
41
|
+
return item.activeTabPaths.some(path => {
|
|
42
|
+
if (path.endsWith('*')) {
|
|
43
|
+
const basePath = path.slice(0, -1);
|
|
44
|
+
return pathname.startsWith(basePath);
|
|
45
|
+
}
|
|
46
|
+
return item.activeTabPaths.includes(pathname);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return match;
|
|
50
|
+
}
|
|
36
51
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
37
52
|
className: (0, _classnames.default)('newspack-tabbed-navigation', className),
|
|
38
53
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
|
|
@@ -41,13 +56,8 @@ const TabbedNavigation = ({
|
|
|
41
56
|
to: item.path,
|
|
42
57
|
isActive: (match, {
|
|
43
58
|
pathname
|
|
44
|
-
}) =>
|
|
45
|
-
|
|
46
|
-
return item.activeTabPaths.includes(pathname);
|
|
47
|
-
}
|
|
48
|
-
return match;
|
|
49
|
-
},
|
|
50
|
-
exact: true,
|
|
59
|
+
}) => isActive(item, match, pathname),
|
|
60
|
+
exact: item.hasOwnProperty('exact') ? item.exact : true,
|
|
51
61
|
activeClassName: 'selected',
|
|
52
62
|
className: (0, _classnames.default)({
|
|
53
63
|
disabled: disableUpcoming && index > currentIndex
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
display: flex;
|
|
40
40
|
font-weight: bold;
|
|
41
41
|
height: 48px;
|
|
42
|
+
outline: none;
|
|
42
43
|
padding: 12px 15px;
|
|
43
44
|
text-decoration: none;
|
|
44
45
|
|
|
@@ -51,15 +52,10 @@
|
|
|
51
52
|
&:focus,
|
|
52
53
|
&:hover {
|
|
53
54
|
color: var(--wp-admin-theme-color);
|
|
54
|
-
outline: none;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&:focus {
|
|
58
|
-
box-shadow: none;
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
&:focus-visible {
|
|
62
|
-
outline: 2px solid;
|
|
58
|
+
outline: 2px solid var(--wp-admin-theme-color);
|
|
63
59
|
outline-offset: -2px;
|
|
64
60
|
}
|
|
65
61
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getContrast = getContrast;
|
|
7
|
+
/**
|
|
8
|
+
* Determine if black or white should be used based on a contrast ratio.
|
|
9
|
+
*
|
|
10
|
+
* @param hexcolor Hex code for determining contrast
|
|
11
|
+
* @return black or white string
|
|
12
|
+
*/
|
|
13
|
+
function getContrast(hexcolor) {
|
|
14
|
+
if (hexcolor.charAt(0) === '#') {
|
|
15
|
+
hexcolor = hexcolor.slice(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Normalize to 6 character hex code if needed
|
|
19
|
+
if (hexcolor.length === 3) {
|
|
20
|
+
hexcolor = hexcolor.split('').map(function (hex) {
|
|
21
|
+
return hex + hex;
|
|
22
|
+
}).join('');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Convert to RGB value
|
|
26
|
+
const r = parseInt(hexcolor.substring(0, 2), 16);
|
|
27
|
+
const g = parseInt(hexcolor.substring(2, 4), 16);
|
|
28
|
+
const b = parseInt(hexcolor.substring(4), 16);
|
|
29
|
+
|
|
30
|
+
// Get YIQ ratio
|
|
31
|
+
const yiq = (r * 299 + g * 587 + b * 114) / 1000;
|
|
32
|
+
|
|
33
|
+
// Check contrast
|
|
34
|
+
return yiq >= 128 ? 'black' : 'white';
|
|
35
|
+
}
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* Web Preview
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
@use "../../../shared/scss/colors";
|
|
6
5
|
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
6
|
+
@use "../../../colors/colors.module" as colors;
|
|
7
7
|
|
|
8
8
|
.newspack-web-preview {
|
|
9
9
|
// Color
|
|
10
|
-
--wp-admin-theme-color: #{colors.$primary-
|
|
11
|
-
--wp-admin-theme-color--rgb: #{colors.$primary-
|
|
12
|
-
--wp-admin-theme-color-darker-10: #{colors.$primary-
|
|
13
|
-
--wp-admin-theme-color-darker-10--rgb: #{colors.$primary-
|
|
14
|
-
--wp-admin-theme-color-darker-20: #{colors.$primary-
|
|
15
|
-
--wp-admin-theme-color-darker-20--rgb: #{colors.$primary-
|
|
16
|
-
|
|
17
|
-
background:
|
|
10
|
+
--wp-admin-theme-color: #{colors.$primary-600};
|
|
11
|
+
--wp-admin-theme-color--rgb: #{colors.$primary-600--rgb};
|
|
12
|
+
--wp-admin-theme-color-darker-10: #{colors.$primary-700};
|
|
13
|
+
--wp-admin-theme-color-darker-10--rgb: #{colors.$primary-700--rgb};
|
|
14
|
+
--wp-admin-theme-color-darker-20: #{colors.$primary-800};
|
|
15
|
+
--wp-admin-theme-color-darker-20--rgb: #{colors.$primary-800--rgb};
|
|
16
|
+
|
|
17
|
+
background: #{colors.$neutral-700};
|
|
18
18
|
box-sizing: border-box;
|
|
19
19
|
height: 100%;
|
|
20
20
|
left: 0;
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
padding: 0 !important;
|
|
103
103
|
|
|
104
104
|
&.is-selected {
|
|
105
|
-
background:
|
|
105
|
+
background: var(--wp-admin-theme-color);
|
|
106
106
|
color: white;
|
|
107
107
|
|
|
108
108
|
&:active,
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
&:focus {
|
|
117
|
-
box-shadow: inset 0 0 0 1px
|
|
117
|
+
box-shadow: inset 0 0 0 1px var(--wp-admin-theme-color), inset 0 0 0 3px white !important;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -38,7 +38,8 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
38
38
|
complete: null,
|
|
39
39
|
error: null,
|
|
40
40
|
loading: requiredPlugins && requiredPlugins.length > 0 ? 1 : 0,
|
|
41
|
-
quietLoading: false
|
|
41
|
+
quietLoading: false,
|
|
42
|
+
confirmation: null
|
|
42
43
|
};
|
|
43
44
|
this.wrappedComponentRef = (0, _element.createRef)();
|
|
44
45
|
}
|
|
@@ -259,7 +260,7 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
259
260
|
href: newspack_urls.dashboard,
|
|
260
261
|
label: (0, _i18n.__)('Return to Dashboard', 'newspack-plugin'),
|
|
261
262
|
showTooltip: true,
|
|
262
|
-
icon: _icons.
|
|
263
|
+
icon: _icons.category,
|
|
263
264
|
iconSize: 36,
|
|
264
265
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.NewspackIcon, {
|
|
265
266
|
size: 36
|
|
@@ -281,6 +282,81 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
281
282
|
})
|
|
282
283
|
});
|
|
283
284
|
};
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Build a confirmation modal with the given title & message.
|
|
288
|
+
* Execute {callback} if confirmed.
|
|
289
|
+
*
|
|
290
|
+
* @property {Object} options Options for the confirmation modal.
|
|
291
|
+
* @property {string} options.title The title for the modal component.
|
|
292
|
+
* @property {string} options.message The message for the modal component body.
|
|
293
|
+
* @property {string} options.confirmText The text for the confirmation button.
|
|
294
|
+
* @property {string} options.cancelText The text for the cancel button.
|
|
295
|
+
* @property {Function} options.callback A function to call if the user confirms the action.
|
|
296
|
+
*/
|
|
297
|
+
confirmAction = options => {
|
|
298
|
+
const modalOptions = {
|
|
299
|
+
title: null,
|
|
300
|
+
message: (0, _i18n.__)('Are you sure?', 'newpack-plugin'),
|
|
301
|
+
confirmText: (0, _i18n.__)('OK', 'newspack-plugin'),
|
|
302
|
+
cancelText: (0, _i18n.__)('Cancel', 'newspack-plugin'),
|
|
303
|
+
callback: null,
|
|
304
|
+
...options
|
|
305
|
+
};
|
|
306
|
+
this.setState({
|
|
307
|
+
confirmation: modalOptions
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Show a confirmation modal with the given title & message.
|
|
313
|
+
* Execute {callback} if confirmed.
|
|
314
|
+
*
|
|
315
|
+
* @return {Component} <Modal>
|
|
316
|
+
*/
|
|
317
|
+
getModal = () => {
|
|
318
|
+
if (!this.state.confirmation) {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
const {
|
|
322
|
+
title,
|
|
323
|
+
message,
|
|
324
|
+
confirmText,
|
|
325
|
+
cancelText,
|
|
326
|
+
callback
|
|
327
|
+
} = this.state.confirmation;
|
|
328
|
+
return message && callback && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_.Modal, {
|
|
329
|
+
isNarrow: true,
|
|
330
|
+
hideTitle: !title,
|
|
331
|
+
title: title,
|
|
332
|
+
onRequestClose: () => this.setState({
|
|
333
|
+
confirmation: null
|
|
334
|
+
}),
|
|
335
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
336
|
+
children: message
|
|
337
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_.Card, {
|
|
338
|
+
buttonsCard: true,
|
|
339
|
+
noBorder: true,
|
|
340
|
+
className: "justify-end",
|
|
341
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
|
|
342
|
+
variant: "secondary",
|
|
343
|
+
onClick: () => this.setState({
|
|
344
|
+
confirmation: null
|
|
345
|
+
}),
|
|
346
|
+
children: cancelText
|
|
347
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
|
|
348
|
+
variant: "primary",
|
|
349
|
+
onClick: () => {
|
|
350
|
+
this.setState({
|
|
351
|
+
confirmation: null
|
|
352
|
+
});
|
|
353
|
+
callback();
|
|
354
|
+
},
|
|
355
|
+
children: confirmText
|
|
356
|
+
})]
|
|
357
|
+
})]
|
|
358
|
+
});
|
|
359
|
+
};
|
|
284
360
|
getFallbackURL = () => {
|
|
285
361
|
if (typeof newspack_urls !== 'undefined') {
|
|
286
362
|
return newspack_urls.dashboard;
|
|
@@ -304,9 +380,10 @@ function withWizard(WrappedComponent, requiredPlugins) {
|
|
|
304
380
|
loadingClasses.push('newspack-wizard__is-loading-quiet');
|
|
305
381
|
}
|
|
306
382
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_element.Fragment, {
|
|
307
|
-
children: [this.getError(), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
383
|
+
children: [this.getError(), this.getModal(), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
308
384
|
className: loadingClasses.join(' '),
|
|
309
385
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, {
|
|
386
|
+
confirmAction: this.confirmAction,
|
|
310
387
|
pluginRequirements: requiredPlugins && this.pluginRequirements(),
|
|
311
388
|
clearError: this.clearError,
|
|
312
389
|
getError: this.getError,
|
|
@@ -3,15 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
6
|
-
@use "../../../shared/scss/colors";
|
|
7
6
|
|
|
8
|
-
//
|
|
7
|
+
// Styling for full-page-react Wizards (ignoring admin-header-only wizards).
|
|
8
|
+
body.newspack-wizard-page:not(.newspack-admin-header) {
|
|
9
9
|
|
|
10
|
-
.toplevel_page_newspack:not(.menu-top),
|
|
11
|
-
body[class*="newspack_page_newspack-"],
|
|
12
|
-
body[class*="admin_page_newspack-"] {
|
|
13
10
|
background: white;
|
|
14
11
|
|
|
12
|
+
// Reset Padding
|
|
15
13
|
#wpcontent {
|
|
16
14
|
padding-left: 0;
|
|
17
15
|
}
|
|
@@ -20,6 +18,13 @@ body[class*="admin_page_newspack-"] {
|
|
|
20
18
|
padding-bottom: 220px;
|
|
21
19
|
min-height: 100vh;
|
|
22
20
|
|
|
21
|
+
// For admin notices directly ">" at top of page above the Wizard header.
|
|
22
|
+
// PHP code should hide these notices, but just incase add this style.
|
|
23
|
+
> .notice {
|
|
24
|
+
margin-bottom: 20px;
|
|
25
|
+
margin-left: 22px;
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
@media screen and ( min-width: 783px ) {
|
|
24
29
|
padding-bottom: 202px;
|
|
25
30
|
}
|
|
@@ -30,6 +35,24 @@ body[class*="admin_page_newspack-"] {
|
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
|
|
38
|
+
// Styling for wizards that are admin-header-only.
|
|
39
|
+
body.newspack-wizard-page.newspack-admin-header {
|
|
40
|
+
|
|
41
|
+
// For mobile.
|
|
42
|
+
@media screen and (max-width: 600px) {
|
|
43
|
+
|
|
44
|
+
// The header bar (and tabs) need padding.
|
|
45
|
+
#newspack-wizards-admin-header {
|
|
46
|
+
padding-top: 46px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Since the padding was added to the header bar, remove from body.
|
|
50
|
+
#wpbody {
|
|
51
|
+
padding-top: 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
33
56
|
svg {
|
|
34
57
|
&.newspack--error {
|
|
35
58
|
fill: wp-colors.$alert-red;
|
|
@@ -41,15 +64,14 @@ svg {
|
|
|
41
64
|
}
|
|
42
65
|
|
|
43
66
|
// Blue Screen
|
|
44
|
-
|
|
45
67
|
.newspack-wizard__blue {
|
|
46
68
|
#wpwrap {
|
|
47
|
-
background:
|
|
69
|
+
background: var(--wp-admin-theme-color);
|
|
48
70
|
}
|
|
49
71
|
|
|
50
72
|
.newspack-footer {
|
|
51
|
-
background:
|
|
52
|
-
border-color:
|
|
73
|
+
background: var(--wp-admin-theme-color);
|
|
74
|
+
border-color: var(--wp-admin-theme-color);
|
|
53
75
|
justify-content: center;
|
|
54
76
|
|
|
55
77
|
&__logo {
|
|
@@ -73,7 +95,6 @@ svg {
|
|
|
73
95
|
}
|
|
74
96
|
|
|
75
97
|
// Loading
|
|
76
|
-
|
|
77
98
|
.newspack-wizard__is-loading {
|
|
78
99
|
background: white;
|
|
79
100
|
cursor: wait;
|
|
@@ -92,7 +113,7 @@ svg {
|
|
|
92
113
|
}
|
|
93
114
|
|
|
94
115
|
&::before {
|
|
95
|
-
background:
|
|
116
|
+
background: var(--wp-admin-theme-color);
|
|
96
117
|
box-shadow:
|
|
97
118
|
24px 0 0 white,
|
|
98
119
|
69px 0 0 -15px wp-colors.$gray-900,
|
|
@@ -137,7 +158,7 @@ svg {
|
|
|
137
158
|
|
|
138
159
|
// Blue Screen
|
|
139
160
|
.newspack-wizard__blue & {
|
|
140
|
-
background:
|
|
161
|
+
background: var(--wp-admin-theme-color);
|
|
141
162
|
|
|
142
163
|
&::before {
|
|
143
164
|
animation: loading-quiet 1.25s ease-in-out infinite;
|
|
@@ -193,7 +214,7 @@ svg {
|
|
|
193
214
|
|
|
194
215
|
&::before {
|
|
195
216
|
animation: loading-quiet 1.25s ease-in-out infinite;
|
|
196
|
-
background:
|
|
217
|
+
background: var(--wp-admin-theme-color);
|
|
197
218
|
height: 8px;
|
|
198
219
|
right: 100%;
|
|
199
220
|
z-index: 9999;
|
|
@@ -8,7 +8,7 @@ exports.default = withWizardScreen;
|
|
|
8
8
|
var _i18n = require("@wordpress/i18n");
|
|
9
9
|
var _icons = require("@wordpress/icons");
|
|
10
10
|
var _ = require("../");
|
|
11
|
-
var
|
|
11
|
+
var _buttonProps = require("../button-props");
|
|
12
12
|
require("./style.scss");
|
|
13
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -43,8 +43,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
43
43
|
renderAboveContent,
|
|
44
44
|
disableUpcomingInTabbedNavigation
|
|
45
45
|
} = props;
|
|
46
|
-
const retrievedButtonProps = (0,
|
|
47
|
-
const retrievedSecondaryButtonProps = (0,
|
|
46
|
+
const retrievedButtonProps = (0, _buttonProps.buttonProps)(buttonAction);
|
|
47
|
+
const retrievedSecondaryButtonProps = (0, _buttonProps.buttonProps)(secondaryButtonAction);
|
|
48
48
|
const SecondaryCTAComponent = retrievedSecondaryButtonProps.plugin ? _.Handoff : _.Button;
|
|
49
49
|
const shouldRenderPrimaryButton = buttonText && buttonAction;
|
|
50
50
|
const shouldRenderSecondaryButton = secondaryButtonText && secondaryButtonAction;
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
6
|
-
@use "../../../
|
|
6
|
+
@use "../../../colors/colors.module" as colors;
|
|
7
7
|
|
|
8
8
|
.newspack-wizard {
|
|
9
9
|
// Color
|
|
10
|
-
--wp-admin-theme-color: #{colors.$primary-
|
|
11
|
-
--wp-admin-theme-color--rgb: #{colors.$primary-
|
|
12
|
-
--wp-admin-theme-color-darker-10: #{colors.$primary-
|
|
13
|
-
--wp-admin-theme-color-darker-10--rgb: #{colors.$primary-
|
|
14
|
-
--wp-admin-theme-color-darker-20: #{colors.$primary-
|
|
15
|
-
--wp-admin-theme-color-darker-20--rgb: #{colors.$primary-
|
|
10
|
+
--wp-admin-theme-color: #{colors.$primary-600};
|
|
11
|
+
--wp-admin-theme-color--rgb: #{colors.$primary-600--rgb};
|
|
12
|
+
--wp-admin-theme-color-darker-10: #{colors.$primary-700};
|
|
13
|
+
--wp-admin-theme-color-darker-10--rgb: #{colors.$primary-700--rgb};
|
|
14
|
+
--wp-admin-theme-color-darker-20: #{colors.$primary-800};
|
|
15
|
+
--wp-admin-theme-color-darker-20--rgb: #{colors.$primary-800--rgb};
|
|
16
16
|
|
|
17
17
|
color: wp-colors.$gray-900;
|
|
18
18
|
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
&:not(.newspack-icon) {
|
|
86
|
-
background:
|
|
86
|
+
background: var(--wp-admin-theme-color);
|
|
87
87
|
left: 50%;
|
|
88
88
|
margin: -28px 0 0 -28px !important;
|
|
89
89
|
opacity: 0;
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
padding: 0 16px;
|
|
126
126
|
|
|
127
127
|
@media screen and ( min-width: 744px ) {
|
|
128
|
-
padding:
|
|
128
|
+
padding: 40px 84px;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
// Typography
|
package/dist/cjs/wizard/index.js
CHANGED
|
@@ -13,11 +13,9 @@ var _icons = require("@wordpress/icons");
|
|
|
13
13
|
var _ = require("../");
|
|
14
14
|
var _router = _interopRequireDefault(require("../proxied-imports/router"));
|
|
15
15
|
var _store = _interopRequireWildcard(require("./store"));
|
|
16
|
-
var _utils = require("./store/utils");
|
|
17
16
|
var _WizardError = _interopRequireDefault(require("./components/WizardError"));
|
|
18
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
function
|
|
20
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
+
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); }
|
|
21
19
|
/**
|
|
22
20
|
* External dependencies.
|
|
23
21
|
*/
|
|
@@ -37,22 +35,45 @@ const {
|
|
|
37
35
|
Route,
|
|
38
36
|
Switch
|
|
39
37
|
} = _router.default;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {Object} WizardProps
|
|
41
|
+
* @property {string} headerText The header text.
|
|
42
|
+
* @property {string} [subHeaderText] The sub-header text, optional.
|
|
43
|
+
* @property {string} [apiSlug] The API slug, optional.
|
|
44
|
+
* @property {string} [className] CSS classes, optional.
|
|
45
|
+
* @property {any[]} sections Array of sections.
|
|
46
|
+
* @property {boolean} [hasSimpleFooter] Indicates if a simple footer is used, optional.
|
|
47
|
+
* @property {() => void} [renderAboveSections] Function to render content above sections, optional.
|
|
48
|
+
* @property {string[]} [requiredPlugins] Array of required plugin strings, optional.
|
|
49
|
+
* @property {boolean} [isInitialFetchTriggered] Indicates if the initial fetch should be triggered, optional.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Wizard Component
|
|
54
|
+
*
|
|
55
|
+
* Provides a tabbed UI with history.
|
|
56
|
+
*
|
|
57
|
+
* @param {WizardProps} props
|
|
58
|
+
* @return {JSX.Element} Wizard component
|
|
59
|
+
*/
|
|
40
60
|
const Wizard = ({
|
|
41
61
|
sections = [],
|
|
42
|
-
apiSlug,
|
|
43
62
|
headerText,
|
|
63
|
+
apiSlug,
|
|
44
64
|
subHeaderText,
|
|
45
65
|
hasSimpleFooter,
|
|
46
66
|
className,
|
|
47
67
|
renderAboveSections,
|
|
48
|
-
requiredPlugins = []
|
|
49
|
-
|
|
68
|
+
requiredPlugins = [],
|
|
69
|
+
isInitialFetchTriggered = true
|
|
70
|
+
}, ref) => {
|
|
50
71
|
const isLoading = (0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).isLoading());
|
|
51
72
|
const isQuietLoading = (0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).isQuietLoading());
|
|
52
73
|
|
|
53
74
|
// Trigger initial data fetch. Some sections might not use the wizard data,
|
|
54
75
|
// but for consistency, fetching is triggered regardless of the section.
|
|
55
|
-
(0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).getWizardAPIData(apiSlug));
|
|
76
|
+
(0, _data.useSelect)(select => isInitialFetchTriggered && select(_store.WIZARD_STORE_NAMESPACE).getWizardAPIData(apiSlug));
|
|
56
77
|
let displayedSections = sections.filter(section => !section.isHidden);
|
|
57
78
|
const [pluginRequirementsSatisfied, setPluginRequirementsSatisfied] = (0, _element.useState)(requiredPlugins.length === 0);
|
|
58
79
|
if (!pluginRequirementsSatisfied) {
|
|
@@ -67,7 +88,9 @@ const Wizard = ({
|
|
|
67
88
|
})
|
|
68
89
|
}];
|
|
69
90
|
}
|
|
70
|
-
|
|
91
|
+
const urlWithoutHash = window.location.href.split('#')[0];
|
|
92
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
93
|
+
ref: ref,
|
|
71
94
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
72
95
|
className: (0, _classnames.default)(isLoading ? 'newspack-wizard__is-loading' : 'newspack-wizard__is-loaded', {
|
|
73
96
|
'newspack-wizard__is-loading-quiet': isQuietLoading
|
|
@@ -82,7 +105,7 @@ const Wizard = ({
|
|
|
82
105
|
className: "newspack-wizard__header__inner",
|
|
83
106
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
84
107
|
className: "newspack-wizard__title",
|
|
85
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
|
|
108
|
+
children: [newspack_urls.dashboard !== urlWithoutHash ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
|
|
86
109
|
isLink: true,
|
|
87
110
|
href: newspack_urls.dashboard,
|
|
88
111
|
label: (0, _i18n.__)('Return to Dashboard', 'newspack-plugin'),
|
|
@@ -92,6 +115,8 @@ const Wizard = ({
|
|
|
92
115
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.NewspackIcon, {
|
|
93
116
|
size: 36
|
|
94
117
|
})
|
|
118
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_.NewspackIcon, {
|
|
119
|
+
size: 36
|
|
95
120
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
96
121
|
children: [headerText && /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
|
|
97
122
|
children: headerText
|
|
@@ -106,11 +131,13 @@ const Wizard = ({
|
|
|
106
131
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_WizardError.default, {})
|
|
107
132
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_.HandoffMessage, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Switch, {
|
|
108
133
|
children: [displayedSections.map((section, index) => {
|
|
134
|
+
var _section$exact;
|
|
109
135
|
const SectionComponent = section.render;
|
|
110
136
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Route, {
|
|
137
|
+
exact: (_section$exact = section.exact) !== null && _section$exact !== void 0 ? _section$exact : false,
|
|
111
138
|
path: section.path,
|
|
112
139
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
113
|
-
className: (0, _classnames.default)('newspack-
|
|
140
|
+
className: (0, _classnames.default)('newspack-wizard__content', className),
|
|
114
141
|
children: ['function' === typeof renderAboveSections ? renderAboveSections() : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(SectionComponent, {})]
|
|
115
142
|
})
|
|
116
143
|
}, index);
|
|
@@ -124,6 +151,4 @@ const Wizard = ({
|
|
|
124
151
|
})]
|
|
125
152
|
});
|
|
126
153
|
};
|
|
127
|
-
|
|
128
|
-
Wizard.STORE_NAMESPACE = _store.WIZARD_STORE_NAMESPACE;
|
|
129
|
-
var _default = exports.default = Wizard;
|
|
154
|
+
var _default = exports.default = (0, _element.forwardRef)(Wizard);
|