newspack-components 3.0.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 -186
- 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 +6 -6
- package/dist/cjs/image-upload/index.test.js +2 -2
- package/dist/cjs/index.js +7 -21
- package/dist/cjs/modal/index.js +16 -18
- 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 +8 -9
- 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 +8 -11
- 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/index.js +1 -1
- 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 -188
- 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 +12 -2
- package/dist/esm/hooks/useObjectState.test.js +7 -7
- package/dist/esm/hooks/usePrompt.js +2 -2
- package/dist/esm/image-upload/index.test.js +2 -2
- package/dist/esm/index.js +1 -3
- package/dist/esm/modal/index.js +17 -19
- 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/index.test.js +7 -7
- package/dist/esm/progress-bar/style.scss +1 -2
- package/dist/esm/radio-control/style.scss +8 -11
- 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/index.js +1 -1
- 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 +14 -6
- package/dist/esm/wizard/store/utils.js +3 -1
- package/package.json +2 -2
- package/src/accordion/index.js +1 -3
- package/src/action-card/action-card.d.ts +40 -0
- package/src/action-card/index.js +284 -201
- 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 +11 -17
- 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 +8 -11
- 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
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
margin-bottom: 8px;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
button {
|
|
14
14
|
border-color: wp-colors.$gray-700;
|
|
15
15
|
border-radius: 2px;
|
|
16
16
|
color: wp-colors.$gray-900;
|
|
@@ -41,6 +41,10 @@
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
button + div {
|
|
45
|
+
min-width: 200px;
|
|
46
|
+
}
|
|
47
|
+
|
|
44
48
|
.components-custom-select-control__menu {
|
|
45
49
|
border-color: wp-colors.$gray-700;
|
|
46
50
|
border-radius: 2px;
|
|
@@ -54,7 +58,6 @@
|
|
|
54
58
|
cursor: pointer;
|
|
55
59
|
display: flex;
|
|
56
60
|
line-height: inherit;
|
|
57
|
-
margin: 0 0 0 28px;
|
|
58
61
|
padding: 6px 8px;
|
|
59
62
|
transition: color 125ms ease-in-out;
|
|
60
63
|
|
|
@@ -77,16 +80,8 @@
|
|
|
77
80
|
|
|
78
81
|
&.is-selected {
|
|
79
82
|
margin-left: 0;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
background:
|
|
83
|
-
url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cGF0aCBkPSJNMTguMyA1LjZMOS45IDE2LjlsLTQuNi0zLjQtLjkgMS4yIDUuOCA0LjMgOS4zLTEyLjZ6IiBmaWxsPSIjMzM2NmZmIj48L3BhdGg+PC9zdmc+Cg==")
|
|
84
|
-
0 0 no-repeat;
|
|
85
|
-
content: "";
|
|
86
|
-
display: block;
|
|
87
|
-
height: 24px;
|
|
88
|
-
margin: 0 4px 0 0;
|
|
89
|
-
width: 24px;
|
|
83
|
+
span svg {
|
|
84
|
+
fill: var(--wp-admin-theme-color);
|
|
90
85
|
}
|
|
91
86
|
}
|
|
92
87
|
}
|
package/src/footer/index.js
CHANGED
|
@@ -11,10 +11,9 @@ import { ExternalLink } from '@wordpress/components';
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies.
|
|
13
13
|
*/
|
|
14
|
-
import { PatronsLogo } from '../';
|
|
15
14
|
import './style.scss';
|
|
16
15
|
|
|
17
|
-
const Footer = ( { simple } ) => {
|
|
16
|
+
const Footer = ( { simple = undefined } ) => {
|
|
18
17
|
const {
|
|
19
18
|
components_demo: componentsDemo = false,
|
|
20
19
|
support = false,
|
|
@@ -75,23 +74,12 @@ const Footer = ( { simple } ) => {
|
|
|
75
74
|
return (
|
|
76
75
|
<div className="newspack-footer">
|
|
77
76
|
{ ! simple && (
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<ExternalLink href={ url }>{ label }</ExternalLink>
|
|
84
|
-
) : (
|
|
85
|
-
<a href={ url }>{ label }</a>
|
|
86
|
-
) }
|
|
87
|
-
</li>
|
|
88
|
-
) ) }
|
|
89
|
-
</ul>
|
|
90
|
-
</div>
|
|
77
|
+
<ul>
|
|
78
|
+
{ footerElements.map( ( { url, label, external }, index ) => (
|
|
79
|
+
<li key={ index }>{ external ? <ExternalLink href={ url }>{ label }</ExternalLink> : <a href={ url }>{ label }</a> }</li>
|
|
80
|
+
) ) }
|
|
81
|
+
</ul>
|
|
91
82
|
) }
|
|
92
|
-
<div className="newspack-footer__logo">
|
|
93
|
-
<PatronsLogo />
|
|
94
|
-
</div>
|
|
95
83
|
</div>
|
|
96
84
|
);
|
|
97
85
|
};
|
package/src/footer/style.scss
CHANGED
|
@@ -5,16 +5,13 @@
|
|
|
5
5
|
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
6
6
|
|
|
7
7
|
.newspack-footer {
|
|
8
|
-
align-items: stretch;
|
|
9
8
|
background: white;
|
|
10
9
|
border: 0 solid wp-colors.$gray-300;
|
|
11
10
|
border-width: 1px 0;
|
|
12
11
|
bottom: 0;
|
|
13
12
|
color: wp-colors.$gray-700;
|
|
14
13
|
display: flex;
|
|
15
|
-
flex-wrap: wrap;
|
|
16
14
|
font-size: 12px;
|
|
17
|
-
justify-content: space-between;
|
|
18
15
|
left: 0;
|
|
19
16
|
line-height: 16px;
|
|
20
17
|
position: absolute;
|
|
@@ -22,17 +19,6 @@
|
|
|
22
19
|
|
|
23
20
|
@media screen and ( min-width: 783px ) {
|
|
24
21
|
bottom: 40px;
|
|
25
|
-
flex-wrap: nowrap;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&__inner {
|
|
29
|
-
align-items: center;
|
|
30
|
-
display: flex;
|
|
31
|
-
flex: 0 0 100%;
|
|
32
|
-
|
|
33
|
-
@media screen and ( min-width: 783px ) {
|
|
34
|
-
flex: 1 1 auto;
|
|
35
|
-
}
|
|
36
22
|
}
|
|
37
23
|
|
|
38
24
|
ul {
|
|
@@ -57,26 +43,4 @@
|
|
|
57
43
|
}
|
|
58
44
|
}
|
|
59
45
|
}
|
|
60
|
-
|
|
61
|
-
&__logo {
|
|
62
|
-
align-items: center;
|
|
63
|
-
background: wp-colors.$gray-900;
|
|
64
|
-
display: flex;
|
|
65
|
-
margin: 0 0 -1px;
|
|
66
|
-
padding: 16px;
|
|
67
|
-
width: 100%;
|
|
68
|
-
|
|
69
|
-
@media screen and ( min-width: 783px ) {
|
|
70
|
-
margin: -1px 0 -1px 8px;
|
|
71
|
-
max-width: 33.33%;
|
|
72
|
-
width: auto;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.patrons-logo {
|
|
76
|
-
display: block;
|
|
77
|
-
fill: white;
|
|
78
|
-
max-height: 16px;
|
|
79
|
-
width: auto;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
46
|
}
|
|
@@ -23,8 +23,7 @@ class FormTokenField extends Component {
|
|
|
23
23
|
* Render.
|
|
24
24
|
*/
|
|
25
25
|
render() {
|
|
26
|
-
const { className, description, hideHelpFromVision, hideLabelFromVision, ...otherProps } =
|
|
27
|
-
this.props;
|
|
26
|
+
const { className, description, hideHelpFromVision, hideLabelFromVision, ...otherProps } = this.props;
|
|
28
27
|
const classes = classnames( 'newspack-form-token-field__input-container', className );
|
|
29
28
|
return (
|
|
30
29
|
<div
|
package/src/grid/index.tsx
CHANGED
|
@@ -12,14 +12,7 @@ import './style.scss';
|
|
|
12
12
|
*/
|
|
13
13
|
import classnames from 'classnames';
|
|
14
14
|
|
|
15
|
-
const Grid = ( {
|
|
16
|
-
className = '',
|
|
17
|
-
columns = 2,
|
|
18
|
-
gutter = 32,
|
|
19
|
-
noMargin = false,
|
|
20
|
-
rowGap = 0,
|
|
21
|
-
...otherProps
|
|
22
|
-
} ) => {
|
|
15
|
+
const Grid = ( { className = '', columns = 2, gutter = 32, noMargin = false, rowGap = 0, ...otherProps } ) => {
|
|
23
16
|
const classes = classnames(
|
|
24
17
|
'newspack-grid',
|
|
25
18
|
noMargin && 'newspack-grid--no-margin',
|
package/src/handoff/index.js
CHANGED
|
@@ -53,8 +53,7 @@ class Handoff extends Component {
|
|
|
53
53
|
const defaults = {
|
|
54
54
|
modalBody: null,
|
|
55
55
|
modalTitle: pluginInfo.Name && `${ __( 'Manage', 'newspack-plugin' ) } ${ pluginInfo.Name }`,
|
|
56
|
-
primaryButton:
|
|
57
|
-
pluginInfo.Name && `${ __( 'Manage', 'newspack-plugin' ) } ${ pluginInfo.Name }`,
|
|
56
|
+
primaryButton: pluginInfo.Name && `${ __( 'Manage', 'newspack-plugin' ) } ${ pluginInfo.Name }`,
|
|
58
57
|
primaryModalButton: __( 'Manage', 'newspack-plugin' ),
|
|
59
58
|
dismissModalButton: __( 'Dismiss', 'newspack-plugin' ),
|
|
60
59
|
};
|
|
@@ -96,8 +95,7 @@ class Handoff extends Component {
|
|
|
96
95
|
...otherProps
|
|
97
96
|
} = this.props;
|
|
98
97
|
const { pluginInfo, showModal } = this.state;
|
|
99
|
-
const { modalBody, modalTitle, primaryButton, primaryModalButton, dismissModalButton } =
|
|
100
|
-
this.textForPlugin( pluginInfo );
|
|
98
|
+
const { modalBody, modalTitle, primaryButton, primaryModalButton, dismissModalButton } = this.textForPlugin( pluginInfo );
|
|
101
99
|
const { Configured, Name, Slug, Status } = pluginInfo;
|
|
102
100
|
const classes = classnames( Configured && 'is-configured', className );
|
|
103
101
|
return (
|
|
@@ -107,9 +105,7 @@ class Handoff extends Component {
|
|
|
107
105
|
className={ classes }
|
|
108
106
|
isSecondary={ ! otherProps.isPrimary && ! otherProps.isTertiary && ! otherProps.isLink }
|
|
109
107
|
{ ...otherProps }
|
|
110
|
-
onClick={ () =>
|
|
111
|
-
useModal ? this.setState( { showModal: true } ) : this.goToPlugin( Slug )
|
|
112
|
-
}
|
|
108
|
+
onClick={ () => ( useModal ? this.setState( { showModal: true } ) : this.goToPlugin( Slug ) ) }
|
|
113
109
|
>
|
|
114
110
|
{ children ? children : primaryButton }
|
|
115
111
|
</Button>
|
|
@@ -132,10 +128,7 @@ class Handoff extends Component {
|
|
|
132
128
|
</Button>
|
|
133
129
|
) }
|
|
134
130
|
{ showModal && (
|
|
135
|
-
<Modal
|
|
136
|
-
title={ modalTitle }
|
|
137
|
-
onRequestClose={ () => this.setState( { showModal: false } ) }
|
|
138
|
-
>
|
|
131
|
+
<Modal title={ modalTitle } onRequestClose={ () => this.setState( { showModal: false } ) }>
|
|
139
132
|
<p>{ modalBody }</p>
|
|
140
133
|
<Card buttonsCard noBorder className="justify-end">
|
|
141
134
|
<Button variant="secondary" onClick={ () => this.setState( { showModal: false } ) }>
|
|
@@ -30,9 +30,6 @@ export default function HandoffMessage() {
|
|
|
30
30
|
setHandoffMessage( false );
|
|
31
31
|
}
|
|
32
32
|
}, 100 );
|
|
33
|
-
|
|
34
|
-
// Clean up the notification when unmounting.
|
|
35
|
-
return () => window.localStorage.removeItem( HANDOFF_KEY );
|
|
36
33
|
}, [] );
|
|
37
34
|
if ( ! handoffMessage ) {
|
|
38
35
|
return null;
|
|
@@ -6,6 +6,11 @@ import { useState } from '@wordpress/element';
|
|
|
6
6
|
import isArray from 'lodash/isArray';
|
|
7
7
|
import mergeWith from 'lodash/mergeWith';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} StateObjectUpdate
|
|
11
|
+
* @property {Object.<string, any>} [update] The update object with key-value pairs to merge into the state.
|
|
12
|
+
*/
|
|
13
|
+
|
|
9
14
|
const mergeCustomizer = ( objValue, srcValue ) => {
|
|
10
15
|
if ( isArray( objValue ) ) {
|
|
11
16
|
// If it's an array, replace it (instead of concatenating).
|
|
@@ -16,12 +21,15 @@ const mergeCustomizer = ( objValue, srcValue ) => {
|
|
|
16
21
|
/**
|
|
17
22
|
* A useState for an object.
|
|
18
23
|
* Nested objects will be nested, but arrays replaced.
|
|
24
|
+
*
|
|
25
|
+
* @template T
|
|
26
|
+
* @param {T} initial Initial state object.
|
|
27
|
+
* @return {[T, (keyOrUpdate: string | Partial<T>) => (value?: any) => void]} The state object and a function to update it.
|
|
19
28
|
*/
|
|
20
29
|
export default ( initial = {} ) => {
|
|
21
30
|
const [ stateObject, setStateObject ] = useState( initial );
|
|
22
31
|
|
|
23
|
-
const runUpdate = update =>
|
|
24
|
-
setStateObject( _stateObject => mergeWith( {}, _stateObject, update, mergeCustomizer ) );
|
|
32
|
+
const runUpdate = update => setStateObject( _stateObject => mergeWith( {}, _stateObject, update, mergeCustomizer ) );
|
|
25
33
|
|
|
26
34
|
const updateStateObject = keyOrUpdate => {
|
|
27
35
|
if ( typeof keyOrUpdate === 'string' ) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
2
|
+
import { render, screen, fireEvent, act } from '@testing-library/react';
|
|
3
3
|
|
|
4
4
|
import useObjectState from './useObjectState';
|
|
5
5
|
|
|
@@ -12,19 +12,13 @@ const TestComponent = () => {
|
|
|
12
12
|
<button onClick={ () => updateState( { widgets: [] } ) }>Remove widgets</button>
|
|
13
13
|
<button onClick={ () => updateState( { widgets: [ 1 ] } ) }>Add widget</button>
|
|
14
14
|
<button onClick={ () => updateState( { attributes: { bar: 2 } } ) }>Nested update</button>
|
|
15
|
-
<input
|
|
16
|
-
type="text"
|
|
17
|
-
value={ state.name }
|
|
18
|
-
onChange={ e => updateState( { name: e.target.value } ) }
|
|
19
|
-
placeholder="name"
|
|
20
|
-
/>
|
|
15
|
+
<input type="text" value={ state.name } onChange={ e => updateState( { name: e.target.value } ) } placeholder="name" />
|
|
21
16
|
</div>
|
|
22
17
|
);
|
|
23
18
|
};
|
|
24
19
|
|
|
25
20
|
describe( 'useObjectState', () => {
|
|
26
|
-
const getState = () =>
|
|
27
|
-
JSON.parse( screen.getByPlaceholderText( 'state' ).getAttribute( 'value' ) );
|
|
21
|
+
const getState = () => JSON.parse( screen.getByPlaceholderText( 'state' ).getAttribute( 'value' ) );
|
|
28
22
|
|
|
29
23
|
beforeEach( () => {
|
|
30
24
|
render( <TestComponent /> );
|
|
@@ -32,17 +26,23 @@ describe( 'useObjectState', () => {
|
|
|
32
26
|
|
|
33
27
|
it( 'updates arrays', () => {
|
|
34
28
|
expect( getState() ).toStrictEqual( INIT_STATE );
|
|
35
|
-
screen.getByText( 'Remove widgets' ).click();
|
|
29
|
+
act( () => screen.getByText( 'Remove widgets' ).click() );
|
|
36
30
|
expect( getState() ).toMatchObject( { widgets: [] } );
|
|
37
|
-
screen.getByText( 'Add widget' ).click();
|
|
31
|
+
act( () => screen.getByText( 'Add widget' ).click() );
|
|
38
32
|
expect( getState() ).toMatchObject( { widgets: [ 1 ] } );
|
|
39
33
|
} );
|
|
40
34
|
it( 'updates a simple value', () => {
|
|
41
|
-
|
|
35
|
+
act( () =>
|
|
36
|
+
fireEvent.change( screen.getByPlaceholderText( 'name' ), {
|
|
37
|
+
target: { value: 'Ramon' },
|
|
38
|
+
} )
|
|
39
|
+
);
|
|
42
40
|
expect( getState() ).toMatchObject( { name: 'Ramon' } );
|
|
43
41
|
} );
|
|
44
42
|
it( 'updates a nested object', () => {
|
|
45
|
-
screen.getByText( 'Nested update' ).click();
|
|
46
|
-
expect( getState() ).toMatchObject( {
|
|
43
|
+
act( () => screen.getByText( 'Nested update' ).click() );
|
|
44
|
+
expect( getState() ).toMatchObject( {
|
|
45
|
+
attributes: { bar: 2, baz: 1 },
|
|
46
|
+
} );
|
|
47
47
|
} );
|
|
48
48
|
} );
|
|
@@ -72,18 +72,7 @@ class ImageUpload extends Component {
|
|
|
72
72
|
* Render.
|
|
73
73
|
*/
|
|
74
74
|
render = () => {
|
|
75
|
-
const {
|
|
76
|
-
buttonLabel,
|
|
77
|
-
className,
|
|
78
|
-
disabled,
|
|
79
|
-
help,
|
|
80
|
-
image,
|
|
81
|
-
info,
|
|
82
|
-
isCovering,
|
|
83
|
-
label,
|
|
84
|
-
onChange,
|
|
85
|
-
style = {},
|
|
86
|
-
} = this.props;
|
|
75
|
+
const { buttonLabel, className, disabled, help, image, info, isCovering, label, onChange, style = {} } = this.props;
|
|
87
76
|
const classes = classnames(
|
|
88
77
|
'newspack-image-upload__image',
|
|
89
78
|
{ 'newspack-image-upload__image--has-image': image },
|
|
@@ -99,22 +88,13 @@ class ImageUpload extends Component {
|
|
|
99
88
|
<div className={ classes } style={ { ...style } }>
|
|
100
89
|
{ image?.url ? (
|
|
101
90
|
<>
|
|
102
|
-
<img
|
|
103
|
-
data-testid="image-upload"
|
|
104
|
-
src={ image.url }
|
|
105
|
-
alt={ __( 'Image preview', 'newspack-plugin' ) }
|
|
106
|
-
/>
|
|
91
|
+
<img data-testid="image-upload" src={ image.url } alt={ __( 'Image preview', 'newspack-plugin' ) } />
|
|
107
92
|
<div className="newspack-image-upload__controls">
|
|
108
93
|
<Button disabled={ disabled } onClick={ this.openModal } isLink>
|
|
109
94
|
{ __( 'Replace', 'newspack-plugin' ) }
|
|
110
95
|
</Button>
|
|
111
96
|
<span className="sep" />
|
|
112
|
-
<Button
|
|
113
|
-
disabled={ disabled }
|
|
114
|
-
onClick={ () => onChange( null ) }
|
|
115
|
-
isLink
|
|
116
|
-
isDestructive
|
|
117
|
-
>
|
|
97
|
+
<Button disabled={ disabled } onClick={ () => onChange( null ) } isLink isDestructive>
|
|
118
98
|
{ __( 'Remove', 'newspack-plugin' ) }
|
|
119
99
|
</Button>
|
|
120
100
|
</div>
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { default as AutocompleteTokenField } from './autocomplete-tokenfield';
|
|
|
4
4
|
export { default as AutocompleteWithSuggestions } from './autocomplete-with-suggestions';
|
|
5
5
|
export { default as Button } from './button';
|
|
6
6
|
export { default as ButtonCard } from './button-card';
|
|
7
|
+
export { default as BoxContrast } from './box-contrast';
|
|
7
8
|
export { default as Card } from './card';
|
|
8
9
|
export { default as CategoryAutocomplete } from './category-autocomplete';
|
|
9
10
|
export { default as ColorPicker } from './color-picker';
|
|
@@ -18,9 +19,7 @@ export { default as GlobalNotices } from './global-notices';
|
|
|
18
19
|
export { default as Grid } from './grid';
|
|
19
20
|
export { default as Modal } from './modal';
|
|
20
21
|
export { default as NewspackIcon } from './newspack-icon';
|
|
21
|
-
export { default as NewspackLogo } from './newspack-logo';
|
|
22
22
|
export { default as Notice } from './notice';
|
|
23
|
-
export { default as PatronsLogo } from './patrons-logo';
|
|
24
23
|
export { default as PluginInstaller } from './plugin-installer';
|
|
25
24
|
export { default as PluginSettings } from './plugin-settings';
|
|
26
25
|
export { default as PluginToggle } from './plugin-toggle';
|
|
@@ -29,7 +28,6 @@ export { default as ProgressBar } from './progress-bar';
|
|
|
29
28
|
export { default as RadioControl } from './radio-control';
|
|
30
29
|
export { default as SectionHeader } from './section-header';
|
|
31
30
|
export { default as SelectControl } from './select-control';
|
|
32
|
-
export { default as DateRangePicker } from './date-range-picker';
|
|
33
31
|
export { default as Settings } from './settings';
|
|
34
32
|
export { default as StepsList } from './steps-list';
|
|
35
33
|
export { default as StepsListItem } from './steps-list-item';
|
package/src/modal/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* WordPress dependencies.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { forwardRef } from '@wordpress/element';
|
|
9
9
|
import { Modal as BaseComponent } from '@wordpress/components';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -18,21 +18,15 @@ import './style.scss';
|
|
|
18
18
|
*/
|
|
19
19
|
import classnames from 'classnames';
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
isWide && 'newspack-modal--wide',
|
|
30
|
-
isNarrow && 'newspack-modal--narrow',
|
|
31
|
-
className
|
|
32
|
-
);
|
|
21
|
+
function Modal( { className, isWide, isNarrow, hideTitle, ...otherProps }, ref ) {
|
|
22
|
+
const classes = classnames(
|
|
23
|
+
'newspack-modal',
|
|
24
|
+
isWide && 'newspack-modal--wide',
|
|
25
|
+
isNarrow && 'newspack-modal--narrow',
|
|
26
|
+
hideTitle && 'newspack-modal--hide-title', // Note: also hides the X close button.
|
|
27
|
+
className
|
|
28
|
+
);
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
}
|
|
30
|
+
return <BaseComponent className={ classes } { ...otherProps } ref={ ref } />;
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
export default Modal;
|
|
32
|
+
export default forwardRef( Modal );
|
package/src/modal/style.scss
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Modal
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
@use "../../../
|
|
5
|
+
@use "../../../colors/colors.module" as colors;
|
|
6
6
|
|
|
7
7
|
.newspack-modal {
|
|
8
8
|
// Color
|
|
9
|
-
--wp-admin-theme-color: #{colors.$primary-
|
|
10
|
-
--wp-admin-theme-color--rgb: #{colors.$primary-
|
|
11
|
-
--wp-admin-theme-color-darker-10: #{colors.$primary-
|
|
12
|
-
--wp-admin-theme-color-darker-10--rgb: #{colors.$primary-
|
|
13
|
-
--wp-admin-theme-color-darker-20: #{colors.$primary-
|
|
14
|
-
--wp-admin-theme-color-darker-20--rgb: #{colors.$primary-
|
|
9
|
+
--wp-admin-theme-color: #{colors.$primary-600};
|
|
10
|
+
--wp-admin-theme-color--rgb: #{colors.$primary-600--rgb};
|
|
11
|
+
--wp-admin-theme-color-darker-10: #{colors.$primary-700};
|
|
12
|
+
--wp-admin-theme-color-darker-10--rgb: #{colors.$primary-700--rgb};
|
|
13
|
+
--wp-admin-theme-color-darker-20: #{colors.$primary-800};
|
|
14
|
+
--wp-admin-theme-color-darker-20--rgb: #{colors.$primary-800--rgb};
|
|
15
15
|
|
|
16
16
|
@media screen and ( min-width: 744px ) {
|
|
17
17
|
max-width: 680px;
|
|
@@ -28,6 +28,17 @@
|
|
|
28
28
|
width: 360px;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
&--hide-title {
|
|
32
|
+
.components-modal__header {
|
|
33
|
+
display: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.components-modal__content {
|
|
37
|
+
margin-top: 0;
|
|
38
|
+
padding-top: 32px;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
31
42
|
@media screen and ( min-width: 960px ) {
|
|
32
43
|
max-height: calc(100% - 128px);
|
|
33
44
|
}
|
|
@@ -24,24 +24,13 @@ class NewspackIcon extends Component {
|
|
|
24
24
|
*/
|
|
25
25
|
render() {
|
|
26
26
|
const { className, simple, size, white } = this.props;
|
|
27
|
-
const classes = classnames(
|
|
28
|
-
'newspack-icon',
|
|
29
|
-
simple && 'newspack-icon--simple',
|
|
30
|
-
white && 'newspack-icon--white',
|
|
31
|
-
className
|
|
32
|
-
);
|
|
27
|
+
const classes = classnames( 'newspack-icon', simple && 'newspack-icon--simple', white && 'newspack-icon--white', className );
|
|
33
28
|
return (
|
|
34
|
-
<SVG
|
|
35
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
36
|
-
height={ size }
|
|
37
|
-
width={ size }
|
|
38
|
-
viewBox="0 0 32 32"
|
|
39
|
-
className={ classes }
|
|
40
|
-
>
|
|
29
|
+
<SVG xmlns="http://www.w3.org/2000/svg" height={ size } width={ size } viewBox="0 0 24 24" className={ classes }>
|
|
41
30
|
<Path
|
|
42
31
|
fillRule="evenodd"
|
|
43
32
|
clipRule="evenodd"
|
|
44
|
-
d="
|
|
33
|
+
d="M24 12C24 18.6271 18.6271 24 12 24C5.37213 24 0 18.6271 0 12C0 5.3729 5.3729 0 12 0C18.6271 0 24 5.3729 24 12ZM17.4545 17.4546L6.54545 6.54545V17.4545H8.72727V11.8182L14.3636 17.4546H17.4545ZM11.2727 8.18182H17.4545V6.54545H9.63636L11.2727 8.18182ZM17.4545 11.2727H14.3636L12.7273 9.63636H17.4545V11.2727ZM17.4545 12.7273V14.3636L15.8182 12.7273H17.4545Z"
|
|
45
34
|
/>
|
|
46
35
|
</SVG>
|
|
47
36
|
);
|
|
@@ -2,21 +2,19 @@
|
|
|
2
2
|
* Newspack Icon
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
@use "../../../shared/scss/colors";
|
|
6
|
-
|
|
7
5
|
.newspack-icon {
|
|
8
|
-
background:
|
|
6
|
+
background: var(--wp-admin-theme-color);
|
|
9
7
|
fill: white;
|
|
10
8
|
padding: 12px;
|
|
11
9
|
|
|
12
10
|
&--white {
|
|
13
11
|
background: white;
|
|
14
|
-
fill:
|
|
12
|
+
fill: var(--wp-admin-theme-color);
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
&--simple {
|
|
18
16
|
background: none;
|
|
19
|
-
fill:
|
|
17
|
+
fill: var(--wp-admin-theme-color);
|
|
20
18
|
padding: 0;
|
|
21
19
|
}
|
|
22
20
|
|
package/src/notice/index.js
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Component, RawHTML } from '@wordpress/element';
|
|
9
9
|
import { Icon, bug, check, help, info } from '@wordpress/icons';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Internal dependencies.
|
|
@@ -62,7 +61,6 @@ class Notice extends Component {
|
|
|
62
61
|
{ <Icon icon={ noticeIcon } /> }
|
|
63
62
|
<div className="newspack-notice__content">
|
|
64
63
|
{ rawHTML ? <RawHTML>{ noticeText }</RawHTML> : noticeText }
|
|
65
|
-
{ debugMode && __( 'Debug Mode', 'newspack-plugin' ) }
|
|
66
64
|
{ children || null }
|
|
67
65
|
</div>
|
|
68
66
|
</div>
|
package/src/notice/style.scss
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
@use "sass:color";
|
|
6
6
|
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
7
|
-
@use "../../../
|
|
7
|
+
@use "../../../colors/colors.module" as colors;
|
|
8
8
|
|
|
9
9
|
.newspack-notice {
|
|
10
10
|
align-items: center;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
display: flex;
|
|
14
14
|
justify-content: flex-start;
|
|
15
15
|
margin: 32px 0;
|
|
16
|
-
padding:
|
|
16
|
+
padding: 8px 12px;
|
|
17
17
|
|
|
18
18
|
> svg {
|
|
19
19
|
display: block;
|
|
@@ -23,24 +23,26 @@
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
&__is-debug {
|
|
26
|
-
background: colors.$primary-
|
|
27
|
-
border-radius:
|
|
26
|
+
background: colors.$primary-600;
|
|
27
|
+
border-radius: 50%;
|
|
28
28
|
bottom: 16px;
|
|
29
29
|
box-shadow: 0 0 8px 4px rgba(black, 0.08);
|
|
30
30
|
color: white;
|
|
31
31
|
font-weight: bold;
|
|
32
32
|
margin: 0 16px;
|
|
33
|
+
padding: 6px;
|
|
33
34
|
position: fixed;
|
|
34
35
|
text-transform: uppercase;
|
|
35
36
|
z-index: 9997;
|
|
36
37
|
|
|
37
38
|
> svg {
|
|
38
39
|
fill: white;
|
|
40
|
+
margin: 0;
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
&__is-error {
|
|
43
|
-
background: color.adjust(wp-colors.$alert-red, $lightness:
|
|
45
|
+
background: color.adjust(wp-colors.$alert-red, $lightness: 35%);
|
|
44
46
|
|
|
45
47
|
> svg {
|
|
46
48
|
fill: wp-colors.$alert-red;
|
|
@@ -49,7 +51,7 @@
|
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
&__is-handoff {
|
|
52
|
-
background: color.adjust(wp-colors.$alert-yellow, $lightness:
|
|
54
|
+
background: color.adjust(wp-colors.$alert-yellow, $lightness: 35%);
|
|
53
55
|
margin-top: 0;
|
|
54
56
|
position: sticky;
|
|
55
57
|
top: 46px;
|
|
@@ -64,12 +66,12 @@
|
|
|
64
66
|
background: colors.$primary-050;
|
|
65
67
|
|
|
66
68
|
> svg {
|
|
67
|
-
fill:
|
|
69
|
+
fill: var(--wp-admin-theme-color);
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
&__is-success {
|
|
72
|
-
background: color.adjust(wp-colors.$alert-green, $lightness:
|
|
74
|
+
background: color.adjust(wp-colors.$alert-green, $lightness: 45%);
|
|
73
75
|
|
|
74
76
|
> svg {
|
|
75
77
|
fill: wp-colors.$alert-green;
|
|
@@ -77,7 +79,7 @@
|
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
&__is-warning {
|
|
80
|
-
background: color.adjust(wp-colors.$alert-yellow, $lightness:
|
|
82
|
+
background: color.adjust(wp-colors.$alert-yellow, $lightness: 35%);
|
|
81
83
|
|
|
82
84
|
> svg {
|
|
83
85
|
fill: wp-colors.$alert-yellow;
|