newspack-components 2.2.1 → 3.0.0-alpha.2
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/babel.config.js +25 -0
- package/copy-styles.js +2 -10
- package/dist/{cjs/accordion → accordion}/index.js +17 -13
- package/dist/{cjs/accordion → accordion}/style.scss +7 -3
- package/dist/{cjs/action-card → action-card}/index.js +39 -43
- package/dist/{esm/action-card → action-card}/style.scss +9 -9
- package/dist/{cjs/autocomplete-tokenfield → autocomplete-tokenfield}/index.js +67 -29
- package/dist/{esm/autocomplete-tokenfield → autocomplete-tokenfield}/style.scss +14 -8
- package/dist/{cjs/autocomplete-with-suggestions → autocomplete-with-suggestions}/index.js +61 -73
- package/dist/{esm/autocomplete-with-suggestions → autocomplete-with-suggestions}/style.scss +9 -17
- package/dist/button/index.js +51 -0
- package/{src/button/index.js → dist/button/index.tsx} +12 -5
- package/dist/{cjs/button → button}/style.scss +1 -1
- package/dist/{cjs/button-card → button-card}/index.js +9 -10
- package/dist/{cjs/button-card → button-card}/style.scss +19 -13
- package/dist/{cjs/card → card}/index.js +4 -5
- package/dist/{esm/card → card}/style.scss +1 -1
- package/dist/{cjs/category-autocomplete → category-autocomplete}/index.js +51 -53
- package/dist/{esm/category-autocomplete → category-autocomplete}/style.scss +2 -2
- package/dist/{cjs/color-picker → color-picker}/index.js +14 -16
- package/dist/{cjs/color-picker → color-picker}/style.scss +3 -3
- package/dist/consts.js +7 -0
- package/dist/{cjs/custom-select-control → custom-select-control}/index.js +4 -5
- package/dist/{cjs/custom-select-control → custom-select-control}/style.scss +11 -10
- package/dist/{cjs/date-range-picker → date-range-picker}/index.js +9 -11
- package/dist/{cjs/date-range-picker → date-range-picker}/style.scss +6 -6
- package/dist/{cjs/footer → footer}/index.js +33 -36
- package/dist/{cjs/footer → footer}/style.scss +1 -1
- package/dist/{cjs/form-token-field → form-token-field}/index.js +6 -7
- package/dist/{esm/form-token-field → form-token-field}/style.scss +1 -1
- package/dist/{cjs/global-notices → global-notices}/index.js +4 -5
- package/dist/grid/index.js +44 -0
- package/dist/grid/index.tsx +34 -0
- package/dist/{cjs/grid → grid}/style.scss +9 -9
- package/dist/{cjs/handoff → handoff}/index.js +73 -71
- package/dist/{cjs/handoff-message → handoff-message}/index.js +5 -3
- package/dist/hooks/index.js +29 -0
- package/{src/hooks/index.js → dist/hooks/index.ts} +1 -1
- package/dist/{cjs/hooks → hooks}/useObjectState.js +2 -3
- package/dist/{cjs/hooks → hooks}/useObjectState.test.js +9 -9
- package/dist/{cjs/hooks → hooks}/useOnClickOutside.js +1 -2
- package/dist/hooks/usePrompt.js +47 -0
- package/{src/hooks/usePrompt.js → dist/hooks/usePrompt.ts} +4 -8
- package/dist/image-upload/index.js +148 -0
- package/dist/{cjs/image-upload → image-upload}/index.test.js +13 -6
- package/dist/{esm/image-upload → image-upload}/style.scss +5 -5
- package/dist/{cjs/index.js → index.js} +1 -1
- package/dist/{cjs/info-button → info-button}/index.js +6 -7
- package/dist/{cjs/modal → modal}/index.js +4 -5
- package/dist/{esm/modal → modal}/style.scss +5 -5
- package/dist/{cjs/newspack-icon → newspack-icon}/index.js +5 -6
- package/dist/{cjs/newspack-icon → newspack-icon}/style.scss +1 -1
- package/dist/{cjs/newspack-logo → newspack-logo}/index.js +5 -6
- package/dist/{cjs/newspack-logo → newspack-logo}/style.scss +1 -1
- package/dist/{cjs/notice → notice}/index.js +12 -10
- package/dist/{cjs/notice → notice}/style.scss +11 -11
- package/dist/patrons-logo/index.js +77 -0
- package/dist/plugin-installer/index.js +297 -0
- package/dist/{cjs/plugin-installer → plugin-installer}/style.scss +1 -1
- package/dist/{cjs/plugin-settings → plugin-settings}/SettingsSection.js +13 -13
- package/dist/plugin-settings/index.js +228 -0
- package/dist/{cjs/plugin-settings → plugin-settings}/style.scss +1 -1
- package/dist/plugin-toggle/README.md +53 -0
- package/dist/plugin-toggle/index.js +222 -0
- package/dist/{esm/plugin-toggle → plugin-toggle}/style.scss +1 -1
- package/dist/{cjs/popover → popover}/index.js +4 -5
- package/dist/{cjs/popover → popover}/style.scss +7 -7
- package/dist/{cjs/position-control → position-control}/index.js +33 -32
- package/dist/{cjs/position-control → position-control}/style.scss +8 -8
- package/dist/{cjs/progress-bar → progress-bar}/index.js +9 -10
- package/dist/{cjs/progress-bar → progress-bar}/index.test.js +16 -16
- package/dist/{cjs/progress-bar → progress-bar}/style.scss +2 -2
- package/dist/proxied-imports/router.js +15 -0
- package/dist/{cjs/radio-control → radio-control}/index.js +4 -5
- package/dist/{cjs/radio-control → radio-control}/style.scss +3 -3
- package/dist/{cjs/section-header → section-header}/index.js +20 -21
- package/dist/{esm/section-header → section-header}/style.scss +5 -1
- package/dist/{cjs/select-control → select-control}/ButtonGroupControl.js +17 -19
- package/dist/{cjs/select-control → select-control}/GroupedSelectControl.js +32 -35
- package/dist/{cjs/select-control → select-control}/index.js +7 -8
- package/dist/{cjs/select-control → select-control}/style.scss +4 -4
- package/dist/settings/MinMaxSetting.js +60 -0
- package/dist/{cjs/settings → settings}/SettingsCard.js +14 -16
- package/dist/settings/SettingsSection.js +33 -0
- package/dist/{cjs/settings → settings}/index.js +3 -4
- package/dist/{cjs/settings → settings}/style.scss +15 -2
- package/dist/sortable-newsletter-list-control/index.js +135 -0
- package/dist/sortable-newsletter-list-control/style.scss +45 -0
- package/dist/{cjs/steps-list → steps-list}/index.js +5 -6
- package/dist/{esm/steps-list → steps-list}/style.scss +2 -2
- package/dist/{cjs/steps-list-item → steps-list-item}/index.js +6 -7
- package/dist/{cjs/steps-list-item → steps-list-item}/style.scss +5 -5
- package/dist/{cjs/style-card → style-card}/index.js +21 -19
- package/dist/{esm/style-card → style-card}/style.scss +4 -4
- package/dist/{esm/style.scss → style.scss} +14 -2
- package/dist/{cjs/tabbed-navigation → tabbed-navigation}/index.js +16 -19
- package/dist/{cjs/tabbed-navigation → tabbed-navigation}/style.scss +4 -4
- package/dist/text-control/index.js +76 -0
- package/dist/text-control/index.tsx +71 -0
- package/dist/utils/index.js +36 -0
- package/dist/{cjs/waiting → waiting}/index.js +4 -5
- package/dist/web-preview/index.js +191 -0
- package/dist/{cjs/web-preview → web-preview}/style.scss +5 -5
- package/dist/with-wizard/index.js +328 -0
- package/dist/{esm/with-wizard → with-wizard}/style.scss +44 -22
- package/dist/{cjs/with-wizard-screen → with-wizard-screen}/index.js +40 -43
- package/dist/{esm/with-wizard-screen → with-wizard-screen}/style.scss +7 -7
- package/dist/{cjs/wizard → wizard}/components/WizardError.js +16 -17
- package/dist/{cjs/wizard → wizard}/index.js +44 -46
- package/dist/{cjs/wizard → wizard}/store/index.js +37 -38
- package/dist/{cjs/wizard → wizard}/store/utils.js +1 -4
- package/package.json +16 -14
- package/shared/scss/_mixins.scss +2 -2
- package/src/accordion/index.js +4 -1
- package/src/accordion/style.scss +7 -3
- package/src/action-card/style.scss +9 -9
- package/src/autocomplete-tokenfield/index.js +48 -15
- package/src/autocomplete-tokenfield/style.scss +14 -8
- package/src/autocomplete-with-suggestions/index.js +59 -62
- package/src/autocomplete-with-suggestions/style.scss +9 -17
- package/src/button/index.tsx +48 -0
- package/src/button/style.scss +1 -1
- package/src/button-card/style.scss +19 -13
- package/src/card/style.scss +1 -1
- package/src/category-autocomplete/style.scss +2 -2
- package/src/color-picker/style.scss +3 -3
- package/src/consts.js +0 -2
- package/src/custom-select-control/style.scss +11 -10
- package/src/date-range-picker/style.scss +6 -6
- package/src/footer/index.js +7 -7
- package/src/footer/style.scss +1 -1
- package/src/form-token-field/style.scss +1 -1
- package/src/grid/index.tsx +34 -0
- package/src/grid/style.scss +9 -9
- package/src/handoff/index.js +7 -6
- package/src/handoff-message/index.js +3 -1
- package/src/hooks/index.ts +15 -0
- package/src/hooks/usePrompt.ts +46 -0
- package/src/image-upload/index.js +5 -5
- package/src/image-upload/index.test.js +6 -1
- package/src/image-upload/style.scss +5 -5
- package/src/modal/style.scss +5 -5
- package/src/newspack-icon/style.scss +1 -1
- package/src/newspack-logo/style.scss +1 -1
- package/src/notice/index.js +1 -1
- package/src/notice/style.scss +11 -11
- package/src/patrons-logo/index.js +4 -1
- package/src/plugin-installer/index.js +7 -7
- package/src/plugin-installer/style.scss +1 -1
- package/src/plugin-settings/index.js +1 -1
- package/src/plugin-settings/style.scss +1 -1
- package/src/plugin-toggle/index.js +13 -12
- package/src/plugin-toggle/style.scss +1 -1
- package/src/popover/style.scss +7 -7
- package/src/position-control/index.js +63 -64
- package/src/position-control/style.scss +8 -8
- package/src/progress-bar/style.scss +2 -2
- package/src/radio-control/style.scss +3 -3
- package/src/section-header/index.js +3 -3
- package/src/section-header/style.scss +5 -1
- package/src/select-control/GroupedSelectControl.js +1 -1
- package/src/select-control/style.scss +4 -4
- package/src/settings/MinMaxSetting.js +8 -6
- package/src/settings/style.scss +15 -2
- package/src/sortable-newsletter-list-control/index.js +137 -0
- package/src/sortable-newsletter-list-control/style.scss +45 -0
- package/src/steps-list/style.scss +2 -2
- package/src/steps-list-item/style.scss +5 -5
- package/src/style-card/index.js +11 -5
- package/src/style-card/style.scss +4 -4
- package/src/style.scss +14 -2
- package/src/tabbed-navigation/style.scss +4 -4
- package/src/text-control/index.tsx +65 -0
- package/src/web-preview/index.js +6 -6
- package/src/web-preview/style.scss +5 -5
- package/src/with-wizard/index.js +4 -4
- package/src/with-wizard/style.scss +44 -22
- package/src/with-wizard-screen/index.js +1 -1
- package/src/with-wizard-screen/style.scss +7 -7
- package/src/wizard/components/WizardError.js +1 -1
- package/src/wizard/index.js +3 -3
- package/src/wizard/store/index.js +9 -2
- package/dist/cjs/action-card/style.scss +0 -483
- package/dist/cjs/autocomplete-tokenfield/style.scss +0 -43
- package/dist/cjs/autocomplete-with-suggestions/style.scss +0 -171
- package/dist/cjs/button/index.js +0 -57
- package/dist/cjs/card/style.scss +0 -168
- package/dist/cjs/category-autocomplete/style.scss +0 -34
- package/dist/cjs/consts.js +0 -12
- package/dist/cjs/form-token-field/style.scss +0 -37
- package/dist/cjs/grid/index.js +0 -54
- package/dist/cjs/hooks/index.js +0 -26
- package/dist/cjs/hooks/usePrompt.js +0 -52
- package/dist/cjs/image-upload/index.js +0 -144
- package/dist/cjs/image-upload/style.scss +0 -103
- package/dist/cjs/modal/style.scss +0 -56
- package/dist/cjs/patrons-logo/index.js +0 -82
- package/dist/cjs/plugin-installer/index.js +0 -299
- package/dist/cjs/plugin-settings/index.js +0 -222
- package/dist/cjs/plugin-toggle/index.js +0 -222
- package/dist/cjs/plugin-toggle/style.scss +0 -20
- package/dist/cjs/proxied-imports/router.js +0 -15
- package/dist/cjs/section-header/style.scss +0 -41
- package/dist/cjs/settings/MinMaxSetting.js +0 -57
- package/dist/cjs/settings/SettingsSection.js +0 -37
- package/dist/cjs/steps-list/style.scss +0 -11
- package/dist/cjs/style-card/style.scss +0 -94
- package/dist/cjs/style.scss +0 -43
- package/dist/cjs/text-control/index.js +0 -71
- package/dist/cjs/utils/index.js +0 -40
- package/dist/cjs/web-preview/index.js +0 -189
- package/dist/cjs/with-wizard/index.js +0 -318
- package/dist/cjs/with-wizard/style.scss +0 -260
- package/dist/cjs/with-wizard-screen/style.scss +0 -160
- package/dist/esm/accordion/index.js +0 -38
- package/dist/esm/accordion/style.scss +0 -27
- package/dist/esm/action-card/index.js +0 -222
- package/dist/esm/autocomplete-tokenfield/index.js +0 -223
- package/dist/esm/autocomplete-with-suggestions/index.js +0 -289
- package/dist/esm/button/index.js +0 -48
- package/dist/esm/button/style.scss +0 -11
- package/dist/esm/button-card/index.js +0 -65
- package/dist/esm/button-card/style.scss +0 -174
- package/dist/esm/card/index.js +0 -43
- package/dist/esm/category-autocomplete/index.js +0 -185
- package/dist/esm/color-picker/index.js +0 -61
- package/dist/esm/color-picker/style.scss +0 -37
- package/dist/esm/consts.js +0 -3
- package/dist/esm/custom-select-control/index.js +0 -37
- package/dist/esm/custom-select-control/style.scss +0 -92
- package/dist/esm/date-range-picker/index.js +0 -32
- package/dist/esm/date-range-picker/style.scss +0 -148
- package/dist/esm/footer/index.js +0 -105
- package/dist/esm/footer/style.scss +0 -82
- package/dist/esm/form-token-field/index.js +0 -50
- package/dist/esm/global-notices/index.js +0 -30
- package/dist/esm/grid/index.js +0 -45
- package/dist/esm/grid/style.scss +0 -166
- package/dist/esm/handoff/index.js +0 -177
- package/dist/esm/handoff-message/index.js +0 -45
- package/dist/esm/hooks/index.js +0 -17
- package/dist/esm/hooks/useObjectState.js +0 -31
- package/dist/esm/hooks/useObjectState.test.js +0 -83
- package/dist/esm/hooks/useOnClickOutside.js +0 -31
- package/dist/esm/hooks/usePrompt.js +0 -43
- package/dist/esm/image-upload/index.js +0 -141
- package/dist/esm/image-upload/index.test.js +0 -28
- package/dist/esm/index.js +0 -47
- package/dist/esm/info-button/index.js +0 -42
- package/dist/esm/info-button/style.scss +0 -18
- package/dist/esm/modal/index.js +0 -39
- package/dist/esm/newspack-icon/index.js +0 -50
- package/dist/esm/newspack-icon/style.scss +0 -26
- package/dist/esm/newspack-logo/index.js +0 -46
- package/dist/esm/newspack-logo/style.scss +0 -30
- package/dist/esm/notice/index.js +0 -67
- package/dist/esm/notice/style.scss +0 -111
- package/dist/esm/patrons-logo/index.js +0 -76
- package/dist/esm/plugin-installer/index.js +0 -295
- package/dist/esm/plugin-installer/style.scss +0 -72
- package/dist/esm/plugin-settings/SettingsSection.js +0 -136
- package/dist/esm/plugin-settings/index.js +0 -217
- package/dist/esm/plugin-settings/style.scss +0 -7
- package/dist/esm/plugin-toggle/index.js +0 -217
- package/dist/esm/popover/index.js +0 -41
- package/dist/esm/popover/style.scss +0 -161
- package/dist/esm/position-control/index.js +0 -109
- package/dist/esm/position-control/style.scss +0 -66
- package/dist/esm/progress-bar/index.js +0 -69
- package/dist/esm/progress-bar/index.test.js +0 -110
- package/dist/esm/progress-bar/style.scss +0 -42
- package/dist/esm/proxied-imports/router.js +0 -8
- package/dist/esm/radio-control/index.js +0 -37
- package/dist/esm/radio-control/style.scss +0 -92
- package/dist/esm/section-header/index.js +0 -68
- package/dist/esm/select-control/ButtonGroupControl.js +0 -54
- package/dist/esm/select-control/GroupedSelectControl.js +0 -84
- package/dist/esm/select-control/index.js +0 -51
- package/dist/esm/select-control/style.scss +0 -108
- package/dist/esm/settings/MinMaxSetting.js +0 -53
- package/dist/esm/settings/SettingsCard.js +0 -39
- package/dist/esm/settings/SettingsSection.js +0 -30
- package/dist/esm/settings/index.js +0 -9
- package/dist/esm/settings/style.scss +0 -106
- package/dist/esm/steps-list/index.js +0 -43
- package/dist/esm/steps-list-item/index.js +0 -48
- package/dist/esm/steps-list-item/style.scss +0 -47
- package/dist/esm/style-card/index.js +0 -76
- package/dist/esm/tabbed-navigation/index.js +0 -56
- package/dist/esm/tabbed-navigation/style.scss +0 -86
- package/dist/esm/text-control/index.js +0 -66
- package/dist/esm/text-control/style.scss +0 -32
- package/dist/esm/utils/index.js +0 -32
- package/dist/esm/waiting/index.js +0 -44
- package/dist/esm/waiting/style.scss +0 -27
- package/dist/esm/web-preview/index.js +0 -184
- package/dist/esm/web-preview/style.scss +0 -155
- package/dist/esm/with-wizard/index.js +0 -313
- package/dist/esm/with-wizard-screen/index.js +0 -116
- package/dist/esm/wizard/components/WizardError.js +0 -69
- package/dist/esm/wizard/index.js +0 -126
- package/dist/esm/wizard/store/index.js +0 -155
- package/dist/esm/wizard/store/utils.js +0 -17
- package/src/grid/index.js +0 -44
- package/src/text-control/index.js +0 -56
- /package/dist/{cjs/info-button → info-button}/style.scss +0 -0
- /package/dist/{cjs/text-control → text-control}/style.scss +0 -0
- /package/dist/{cjs/waiting → waiting}/style.scss +0 -0
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
import classnames from 'classnames';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies.
|
|
9
|
-
*/
|
|
10
|
-
import apiFetch from '@wordpress/api-fetch';
|
|
11
|
-
import { Component, Fragment } from '@wordpress/element';
|
|
12
|
-
import { __ as alias__ } from '@wordpress/i18n';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies.
|
|
16
|
-
*/
|
|
17
|
-
const __ = alias__;
|
|
18
|
-
import { SectionHeader, Notice } from '../';
|
|
19
|
-
import SettingsSection from './SettingsSection';
|
|
20
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
21
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
22
|
-
class PluginSettings extends Component {
|
|
23
|
-
constructor() {
|
|
24
|
-
super(...arguments);
|
|
25
|
-
_defineProperty(this, "fetchSettings", () => {
|
|
26
|
-
const {
|
|
27
|
-
afterFetch,
|
|
28
|
-
pluginSlug,
|
|
29
|
-
isWizard
|
|
30
|
-
} = this.props;
|
|
31
|
-
this.setState({
|
|
32
|
-
inFlight: true
|
|
33
|
-
});
|
|
34
|
-
apiFetch({
|
|
35
|
-
path: isWizard ? `/newspack/v1/wizard/${pluginSlug}/settings` : `/${pluginSlug}/v1/settings`
|
|
36
|
-
}).then(settings => {
|
|
37
|
-
this.setState({
|
|
38
|
-
settings,
|
|
39
|
-
error: null
|
|
40
|
-
});
|
|
41
|
-
if ('function' === typeof afterFetch) {
|
|
42
|
-
afterFetch(settings);
|
|
43
|
-
}
|
|
44
|
-
}).catch(error => {
|
|
45
|
-
this.setState({
|
|
46
|
-
error
|
|
47
|
-
});
|
|
48
|
-
}).finally(() => {
|
|
49
|
-
this.setState({
|
|
50
|
-
inFlight: false
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
_defineProperty(this, "getSettingsValues", sectionKey => {
|
|
55
|
-
return this.state.settings[sectionKey]?.reduce((map, setting) => {
|
|
56
|
-
map[setting.key] = setting.value;
|
|
57
|
-
return map;
|
|
58
|
-
}, {}) || {};
|
|
59
|
-
});
|
|
60
|
-
_defineProperty(this, "handleSettingChange", sectionKey => (key, value) => {
|
|
61
|
-
const sectionSettings = [...this.state.settings[sectionKey]];
|
|
62
|
-
sectionSettings.forEach(setting => {
|
|
63
|
-
if (setting.key === key) {
|
|
64
|
-
setting.value = value;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
this.setState({
|
|
68
|
-
settings: {
|
|
69
|
-
...this.state.settings,
|
|
70
|
-
[sectionKey]: sectionSettings
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
_defineProperty(this, "handleSectionUpdate", sectionKey => data => {
|
|
75
|
-
const {
|
|
76
|
-
afterUpdate,
|
|
77
|
-
pluginSlug,
|
|
78
|
-
isWizard
|
|
79
|
-
} = this.props;
|
|
80
|
-
this.setState({
|
|
81
|
-
inFlight: true
|
|
82
|
-
});
|
|
83
|
-
apiFetch({
|
|
84
|
-
path: isWizard ? `/newspack/v1/wizard/${pluginSlug}/settings` : `/${pluginSlug}/v1/settings`,
|
|
85
|
-
method: 'POST',
|
|
86
|
-
data: {
|
|
87
|
-
section: sectionKey,
|
|
88
|
-
settings: data ? data : this.getSettingsValues(sectionKey)
|
|
89
|
-
}
|
|
90
|
-
}).then(settings => {
|
|
91
|
-
this.setState({
|
|
92
|
-
settings: {
|
|
93
|
-
...this.state.settings,
|
|
94
|
-
[sectionKey]: settings[sectionKey]
|
|
95
|
-
},
|
|
96
|
-
error: null
|
|
97
|
-
});
|
|
98
|
-
if ('function' === typeof afterUpdate) {
|
|
99
|
-
afterUpdate(settings);
|
|
100
|
-
}
|
|
101
|
-
}).catch(error => {
|
|
102
|
-
this.setState({
|
|
103
|
-
error
|
|
104
|
-
});
|
|
105
|
-
}).finally(() => {
|
|
106
|
-
this.setState({
|
|
107
|
-
inFlight: false
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
/**
|
|
112
|
-
* Get the section setting containing section information.
|
|
113
|
-
*
|
|
114
|
-
* @param {string} sectionKey The section name.
|
|
115
|
-
* @return {Object} The section setting.
|
|
116
|
-
*/
|
|
117
|
-
_defineProperty(this, "getSectionInfo", sectionKey => {
|
|
118
|
-
return this.state.settings[sectionKey]?.find(setting => !setting.key || setting.key === 'active');
|
|
119
|
-
});
|
|
120
|
-
/**
|
|
121
|
-
* Get the section title.
|
|
122
|
-
*
|
|
123
|
-
* @param {string} sectionKey The section name.
|
|
124
|
-
* @return {string} The section title.
|
|
125
|
-
*/
|
|
126
|
-
_defineProperty(this, "getSectionTitle", sectionKey => {
|
|
127
|
-
return this.getSectionInfo(sectionKey)?.description;
|
|
128
|
-
});
|
|
129
|
-
/**
|
|
130
|
-
* Get the section description.
|
|
131
|
-
*
|
|
132
|
-
* @param {string} sectionKey The section name.
|
|
133
|
-
* @return {string} The section description.
|
|
134
|
-
*/
|
|
135
|
-
_defineProperty(this, "getSectionDescription", sectionKey => {
|
|
136
|
-
return this.getSectionInfo(sectionKey)?.help;
|
|
137
|
-
});
|
|
138
|
-
/**
|
|
139
|
-
* Get whether a section is active.
|
|
140
|
-
*
|
|
141
|
-
* @param {string} sectionKey The section name.
|
|
142
|
-
* @return {?boolean} Whether the section is active or not. Null if the section is not found or does not support activation.
|
|
143
|
-
*/
|
|
144
|
-
_defineProperty(this, "isSectionActive", sectionKey => {
|
|
145
|
-
const {
|
|
146
|
-
settings
|
|
147
|
-
} = this.state;
|
|
148
|
-
const activation = settings[sectionKey]?.find(setting => setting.key === 'active');
|
|
149
|
-
if (!activation) {
|
|
150
|
-
return null;
|
|
151
|
-
}
|
|
152
|
-
return activation.value;
|
|
153
|
-
});
|
|
154
|
-
/**
|
|
155
|
-
* Get list of section field settings.
|
|
156
|
-
*
|
|
157
|
-
* @param {string} sectionKey The section name.
|
|
158
|
-
* @return {?Array} List of section fields.
|
|
159
|
-
*/
|
|
160
|
-
_defineProperty(this, "getSectionFields", sectionKey => {
|
|
161
|
-
return this.state.settings[sectionKey]?.filter(setting => setting.key && setting.key !== 'active');
|
|
162
|
-
});
|
|
163
|
-
this.state = {
|
|
164
|
-
inFlight: false,
|
|
165
|
-
settings: {},
|
|
166
|
-
error: null
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
componentDidMount() {
|
|
170
|
-
this.fetchSettings();
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Render.
|
|
174
|
-
*/
|
|
175
|
-
render() {
|
|
176
|
-
const {
|
|
177
|
-
title,
|
|
178
|
-
description,
|
|
179
|
-
hasGreyHeader,
|
|
180
|
-
children
|
|
181
|
-
} = this.props;
|
|
182
|
-
const {
|
|
183
|
-
settings,
|
|
184
|
-
inFlight,
|
|
185
|
-
error
|
|
186
|
-
} = this.state;
|
|
187
|
-
return _jsxs(Fragment, {
|
|
188
|
-
children: [title && _jsx(SectionHeader, {
|
|
189
|
-
title: title,
|
|
190
|
-
description: description
|
|
191
|
-
}), error && _jsx(Notice, {
|
|
192
|
-
isError: true,
|
|
193
|
-
noticeText: error.message
|
|
194
|
-
}), _jsxs("div", {
|
|
195
|
-
className: classnames('newspack-plugin-settings', {
|
|
196
|
-
'newspack-wizard-section__is-loading': inFlight && !Object.keys(settings).length
|
|
197
|
-
}),
|
|
198
|
-
children: [Object.keys(settings).map(sectionKey => _jsx(SettingsSection, {
|
|
199
|
-
disabled: inFlight,
|
|
200
|
-
sectionKey: sectionKey,
|
|
201
|
-
title: this.getSectionTitle(sectionKey),
|
|
202
|
-
description: this.getSectionDescription(sectionKey),
|
|
203
|
-
active: this.isSectionActive(sectionKey),
|
|
204
|
-
fields: this.getSectionFields(sectionKey),
|
|
205
|
-
onChange: this.handleSettingChange(sectionKey),
|
|
206
|
-
onUpdate: this.handleSectionUpdate(sectionKey),
|
|
207
|
-
hasGreyHeader: hasGreyHeader
|
|
208
|
-
}, sectionKey)), children]
|
|
209
|
-
})]
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
PluginSettings.defaultProps = {
|
|
214
|
-
title: __('General Settings', 'newspack')
|
|
215
|
-
};
|
|
216
|
-
PluginSettings.Section = SettingsSection;
|
|
217
|
-
export default PluginSettings;
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies.
|
|
4
|
-
*/
|
|
5
|
-
import apiFetch from '@wordpress/api-fetch';
|
|
6
|
-
import { Component, Fragment } from '@wordpress/element';
|
|
7
|
-
import { __ as alias__ } from '@wordpress/i18n';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies.
|
|
11
|
-
*/
|
|
12
|
-
const __ = alias__;
|
|
13
|
-
import { ActionCard, Waiting } from '../';
|
|
14
|
-
import './style.scss';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Plugin toggle group component.
|
|
18
|
-
*/
|
|
19
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
20
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
21
|
-
class PluginToggle extends Component {
|
|
22
|
-
constructor() {
|
|
23
|
-
super(...arguments);
|
|
24
|
-
_defineProperty(this, "state", {
|
|
25
|
-
pluginInfo: {}
|
|
26
|
-
});
|
|
27
|
-
_defineProperty(this, "componentDidMount", () => {
|
|
28
|
-
this.retrievePluginInfo();
|
|
29
|
-
});
|
|
30
|
-
/**
|
|
31
|
-
* Retrieve complete data about Newspack plugins.
|
|
32
|
-
*/
|
|
33
|
-
_defineProperty(this, "retrievePluginInfo", () => {
|
|
34
|
-
return new Promise(() => {
|
|
35
|
-
apiFetch({
|
|
36
|
-
path: '/newspack/v1/plugins/'
|
|
37
|
-
}).then(pluginInfo => this.setState({
|
|
38
|
-
pluginInfo
|
|
39
|
-
}));
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
/**
|
|
43
|
-
* Install/activate or remove a plugin.
|
|
44
|
-
*/
|
|
45
|
-
_defineProperty(this, "managePlugin", (plugin, value) => {
|
|
46
|
-
const {
|
|
47
|
-
plugins
|
|
48
|
-
} = this.props;
|
|
49
|
-
const {
|
|
50
|
-
pluginInfo
|
|
51
|
-
} = this.state;
|
|
52
|
-
const action = value ? 'configure' : 'deactivate';
|
|
53
|
-
const params = {
|
|
54
|
-
path: `/newspack/v1/plugins/${plugin}/${action}/`,
|
|
55
|
-
method: 'post'
|
|
56
|
-
};
|
|
57
|
-
this.setState({
|
|
58
|
-
pluginInfo: {
|
|
59
|
-
...pluginInfo,
|
|
60
|
-
[plugin]: {
|
|
61
|
-
...pluginInfo[plugin],
|
|
62
|
-
inFlight: action
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, () => {
|
|
66
|
-
apiFetch(params).then(response => {
|
|
67
|
-
const {
|
|
68
|
-
shouldRefreshAfterUpdate
|
|
69
|
-
} = plugins[plugin];
|
|
70
|
-
this.setState(_ref => {
|
|
71
|
-
let {
|
|
72
|
-
pluginInfo: currentPluginInfo
|
|
73
|
-
} = _ref;
|
|
74
|
-
return {
|
|
75
|
-
pluginInfo: {
|
|
76
|
-
...currentPluginInfo,
|
|
77
|
-
[plugin]: response
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}, () => shouldRefreshAfterUpdate && location.reload());
|
|
81
|
-
}).catch(e => {
|
|
82
|
-
this.setState({
|
|
83
|
-
pluginInfo: {
|
|
84
|
-
...pluginInfo,
|
|
85
|
-
[plugin]: {
|
|
86
|
-
...pluginInfo[plugin],
|
|
87
|
-
error: e.message || __('There was an error managing this plugin.', 'newspack')
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
/**
|
|
95
|
-
* Prepare plugins data for render. Change all keys to camelCase, merge API-fetched data with prop.
|
|
96
|
-
*/
|
|
97
|
-
_defineProperty(this, "prepareDataForRender", (pluginsFromProps, pluginsFromAPI) => Object.keys(pluginsFromProps).map(pluginSlug => pluginsFromAPI[pluginSlug] ? Object.keys(pluginsFromAPI[pluginSlug]).reduce((accumulator, key) => ({
|
|
98
|
-
...accumulator,
|
|
99
|
-
[key.charAt(0).toLowerCase() + key.slice(1)]: pluginsFromAPI[pluginSlug][key]
|
|
100
|
-
}), {}) : {}).map(plugin => Object.assign(plugin, pluginsFromProps[plugin.slug])));
|
|
101
|
-
/**
|
|
102
|
-
* Generate a classname for the ActionCard based on plugin state. Applies 'in-flight' class if an API is underway and 'loading' if the plugin data is not yet available.
|
|
103
|
-
*/
|
|
104
|
-
_defineProperty(this, "classNameForPlugin", plugin => {
|
|
105
|
-
const {
|
|
106
|
-
status,
|
|
107
|
-
inFlight
|
|
108
|
-
} = plugin;
|
|
109
|
-
if (inFlight) {
|
|
110
|
-
return 'in-flight';
|
|
111
|
-
}
|
|
112
|
-
if (!status) {
|
|
113
|
-
return 'loading';
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
/**
|
|
117
|
-
* Generate the ActionCard action text for a plugin.
|
|
118
|
-
*/
|
|
119
|
-
_defineProperty(this, "actionTextForPlugin", plugin => {
|
|
120
|
-
const {
|
|
121
|
-
actionText,
|
|
122
|
-
editPath,
|
|
123
|
-
href,
|
|
124
|
-
inFlight,
|
|
125
|
-
name
|
|
126
|
-
} = plugin;
|
|
127
|
-
// Show spinner when plugin data is unavailable, or when an API call is in flight.
|
|
128
|
-
if ('configure' === inFlight) {
|
|
129
|
-
return _jsxs(Fragment, {
|
|
130
|
-
children: [__('Installing…', 'newspack'), " ", _jsx(Waiting, {
|
|
131
|
-
isRight: true
|
|
132
|
-
})]
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
if ('deactivate' === inFlight) {
|
|
136
|
-
return _jsxs(Fragment, {
|
|
137
|
-
children: [__('Deactivating…', 'newspack'), " ", _jsx(Waiting, {
|
|
138
|
-
isRight: true
|
|
139
|
-
})]
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
if (!name) {
|
|
143
|
-
return _jsxs(Fragment, {
|
|
144
|
-
children: [__('Loading…', 'newspack'), " ", _jsx(Waiting, {
|
|
145
|
-
isRight: true
|
|
146
|
-
})]
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
// No action button at all if the plugin isn't installed and active.
|
|
150
|
-
if (!this.isPluginInstalledAndActive(plugin)) {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
if (href || editPath) {
|
|
154
|
-
return actionText ? actionText : __('Configure', 'newspack');
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
/**
|
|
158
|
-
* Get error message for this plugin.
|
|
159
|
-
*/
|
|
160
|
-
_defineProperty(this, "errorForPlugin", plugin => {
|
|
161
|
-
const {
|
|
162
|
-
slug
|
|
163
|
-
} = plugin;
|
|
164
|
-
const {
|
|
165
|
-
pluginInfo
|
|
166
|
-
} = this.state;
|
|
167
|
-
return pluginInfo[slug]?.error || null;
|
|
168
|
-
});
|
|
169
|
-
/**
|
|
170
|
-
* Get installation/activation status for a plugin.
|
|
171
|
-
*/
|
|
172
|
-
_defineProperty(this, "isPluginInstalledAndActive", plugin => {
|
|
173
|
-
const {
|
|
174
|
-
status
|
|
175
|
-
} = plugin;
|
|
176
|
-
return status === 'active';
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Render.
|
|
181
|
-
*/
|
|
182
|
-
render() {
|
|
183
|
-
const {
|
|
184
|
-
plugins
|
|
185
|
-
} = this.props;
|
|
186
|
-
const {
|
|
187
|
-
pluginInfo
|
|
188
|
-
} = this.state;
|
|
189
|
-
return this.prepareDataForRender(plugins, pluginInfo).map((plugin, index) => {
|
|
190
|
-
const {
|
|
191
|
-
name,
|
|
192
|
-
description,
|
|
193
|
-
href,
|
|
194
|
-
slug,
|
|
195
|
-
editPath
|
|
196
|
-
} = plugin;
|
|
197
|
-
const pluginStatus = this.isPluginInstalledAndActive(plugin);
|
|
198
|
-
const handoff = !href && pluginStatus && editPath ? slug : null;
|
|
199
|
-
const error = this.errorForPlugin(plugin);
|
|
200
|
-
return _jsx(ActionCard, {
|
|
201
|
-
className: this.classNameForPlugin(plugin),
|
|
202
|
-
title: name,
|
|
203
|
-
description: description,
|
|
204
|
-
actionText: this.actionTextForPlugin(plugin),
|
|
205
|
-
handoff: handoff,
|
|
206
|
-
href: href,
|
|
207
|
-
toggle: true,
|
|
208
|
-
toggleChecked: this.isPluginInstalledAndActive(plugin),
|
|
209
|
-
toggleOnChange: value => this.managePlugin(slug, value),
|
|
210
|
-
notification: error,
|
|
211
|
-
notificationHTML: error,
|
|
212
|
-
notificationLevel: "error"
|
|
213
|
-
}, index);
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
export default PluginToggle;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Popover as BaseComponent } from '@wordpress/components';
|
|
5
|
-
import { Component } from '@wordpress/element';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import './style.scss';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* External dependencies
|
|
14
|
-
*/
|
|
15
|
-
import classnames from 'classnames';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Popover
|
|
19
|
-
*/
|
|
20
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
21
|
-
class Popover extends Component {
|
|
22
|
-
/**
|
|
23
|
-
* Render
|
|
24
|
-
*/
|
|
25
|
-
render() {
|
|
26
|
-
const {
|
|
27
|
-
className,
|
|
28
|
-
padding,
|
|
29
|
-
...otherProps
|
|
30
|
-
} = this.props;
|
|
31
|
-
const classes = classnames('newspack-popover', padding && 'newspack-popover__padding-' + padding, className);
|
|
32
|
-
return _jsx(BaseComponent, {
|
|
33
|
-
className: classes,
|
|
34
|
-
...otherProps
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
Popover.defaultProps = {
|
|
39
|
-
padding: false
|
|
40
|
-
};
|
|
41
|
-
export default Popover;
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Popover
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
@use '../../../shared/scss/colors';
|
|
6
|
-
@use '~@wordpress/base-styles/colors' as wp-colors;
|
|
7
|
-
|
|
8
|
-
.newspack-popover {
|
|
9
|
-
.components-popover__content {
|
|
10
|
-
min-width: 238px;
|
|
11
|
-
|
|
12
|
-
.newspack-button {
|
|
13
|
-
color: wp-colors.$gray-700;
|
|
14
|
-
display: flex;
|
|
15
|
-
font-weight: normal;
|
|
16
|
-
padding: 6px 8px;
|
|
17
|
-
|
|
18
|
-
&:hover {
|
|
19
|
-
color: colors.$primary-500;
|
|
20
|
-
|
|
21
|
-
.components-menu-items__item-icon {
|
|
22
|
-
fill: currentcolor;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&:focus:not( :disabled ) {
|
|
27
|
-
box-shadow: inset 0 0 0 2px colors.$primary-500;
|
|
28
|
-
position: relative;
|
|
29
|
-
z-index: 1;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&.is-link {
|
|
33
|
-
border-radius: 2px;
|
|
34
|
-
padding: 6px 8px;
|
|
35
|
-
text-decoration: none;
|
|
36
|
-
|
|
37
|
-
&:not( .is-destructive ) {
|
|
38
|
-
color: wp-colors.$gray-700;
|
|
39
|
-
|
|
40
|
-
&:active,
|
|
41
|
-
&:active:enabled,
|
|
42
|
-
&:focus,
|
|
43
|
-
&:focus:enabled &:hover,
|
|
44
|
-
&:not( :disabled, [aria-disabled='true'], .is-default ):hover {
|
|
45
|
-
color: colors.$primary-500;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
&:focus,
|
|
50
|
-
&:focus:enabled {
|
|
51
|
-
outline: none;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
&.is-destructive:not( :focus ) {
|
|
56
|
-
box-shadow: none !important;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.components-menu-items__item-icon {
|
|
60
|
-
fill: wp-colors.$gray-900;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.components-menu-item__item {
|
|
64
|
-
display: flex;
|
|
65
|
-
width: 100%;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.components-menu-group__label {
|
|
70
|
-
color: wp-colors.$gray-900;
|
|
71
|
-
font-size: 12px;
|
|
72
|
-
font-weight: bold;
|
|
73
|
-
line-height: 16px;
|
|
74
|
-
margin: 0;
|
|
75
|
-
padding: 10px 8px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.screen-reader-text {
|
|
79
|
-
display: flex;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.newspack-select-control {
|
|
83
|
-
margin: 0;
|
|
84
|
-
width: 100%;
|
|
85
|
-
|
|
86
|
-
.components-select-control {
|
|
87
|
-
select.components-select-control__input {
|
|
88
|
-
height: 36px;
|
|
89
|
-
min-height: 36px;
|
|
90
|
-
|
|
91
|
-
&:focus ~ div.components-input-control__backdrop {
|
|
92
|
-
border-color: colors.$primary-500;
|
|
93
|
-
box-shadow: inset 0 0 0 1px colors.$primary-500;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
div.components-input-control__backdrop {
|
|
98
|
-
padding: 0;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.newspack-form-token-field {
|
|
104
|
-
margin: 0;
|
|
105
|
-
text-align: left;
|
|
106
|
-
|
|
107
|
-
.newspack-form-token-field__input-container {
|
|
108
|
-
min-height: 36px;
|
|
109
|
-
padding: 3px 5px;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.components-form-token-field__suggestions-list {
|
|
113
|
-
margin: 5px -3px -11px;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.components-form-token-field__label {
|
|
117
|
-
display: block;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.newspack-toggle-control {
|
|
122
|
-
margin: 0;
|
|
123
|
-
|
|
124
|
-
.components-base-control__field {
|
|
125
|
-
margin: 3px 0;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.components-form-toggle {
|
|
129
|
-
border-top: 0;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
&:not( .is-without-arrow )::before {
|
|
135
|
-
border-color: wp-colors.$gray-300;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
&.is-from-bottom {
|
|
139
|
-
margin-bottom: 2px;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
&.is-from-top {
|
|
143
|
-
margin-top: 2px;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
&.components-animate__appear {
|
|
147
|
-
animation: none;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
&__padding-8 {
|
|
151
|
-
.components-popover__content {
|
|
152
|
-
padding: 8px;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
&__padding-16 {
|
|
157
|
-
.components-popover__content {
|
|
158
|
-
padding: 16px;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|