newspack-components 2.2.1 → 3.0.0-alpha.1
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/dist/cjs/action-card/index.js +3 -4
- package/dist/cjs/autocomplete-tokenfield/index.js +52 -15
- package/dist/cjs/autocomplete-tokenfield/style.scss +11 -5
- package/dist/cjs/autocomplete-with-suggestions/index.js +45 -57
- package/dist/cjs/autocomplete-with-suggestions/style.scss +1 -9
- package/dist/cjs/button/index.js +8 -9
- package/dist/cjs/button-card/index.js +1 -2
- package/dist/cjs/card/index.js +1 -2
- package/dist/cjs/category-autocomplete/index.js +4 -8
- package/dist/cjs/color-picker/index.js +7 -9
- package/dist/cjs/consts.js +2 -7
- package/dist/cjs/custom-select-control/index.js +1 -2
- package/dist/cjs/footer/index.js +24 -29
- package/dist/cjs/form-token-field/index.js +1 -2
- package/dist/cjs/global-notices/index.js +1 -2
- package/dist/cjs/grid/index.js +14 -31
- package/dist/cjs/handoff/index.js +7 -8
- package/dist/cjs/hooks/index.js +2 -3
- package/dist/cjs/hooks/useObjectState.js +1 -2
- package/dist/cjs/hooks/useOnClickOutside.js +1 -2
- package/dist/cjs/hooks/usePrompt.js +1 -4
- package/dist/cjs/image-upload/index.js +5 -6
- package/dist/cjs/index.js +0 -14
- package/dist/cjs/info-button/index.js +1 -2
- package/dist/cjs/modal/index.js +1 -2
- package/dist/cjs/newspack-icon/index.js +1 -2
- package/dist/cjs/newspack-logo/index.js +1 -2
- package/dist/cjs/notice/index.js +2 -3
- package/dist/cjs/patrons-logo/index.js +4 -5
- package/dist/cjs/plugin-installer/index.js +9 -13
- package/dist/cjs/plugin-settings/SettingsSection.js +2 -4
- package/dist/cjs/plugin-settings/index.js +2 -3
- package/dist/cjs/plugin-toggle/index.js +16 -20
- package/dist/cjs/popover/index.js +1 -2
- package/dist/cjs/position-control/index.js +22 -23
- package/dist/cjs/progress-bar/index.js +1 -2
- package/dist/cjs/progress-bar/index.test.js +4 -5
- package/dist/cjs/proxied-imports/router.js +1 -2
- package/dist/cjs/radio-control/index.js +1 -2
- package/dist/cjs/section-header/index.js +13 -14
- package/dist/cjs/section-header/style.scss +4 -0
- package/dist/cjs/select-control/ButtonGroupControl.js +10 -12
- package/dist/cjs/select-control/GroupedSelectControl.js +21 -25
- package/dist/cjs/select-control/index.js +1 -2
- package/dist/cjs/settings/MinMaxSetting.js +17 -15
- package/dist/cjs/settings/SettingsCard.js +10 -12
- package/dist/cjs/settings/SettingsSection.js +20 -24
- package/dist/cjs/settings/index.js +2 -3
- package/dist/cjs/settings/style.scss +14 -1
- package/dist/cjs/sortable-newsletter-list-control/index.js +134 -0
- package/dist/cjs/sortable-newsletter-list-control/style.scss +45 -0
- package/dist/cjs/steps-list/index.js +1 -2
- package/dist/cjs/steps-list-item/index.js +1 -2
- package/dist/cjs/style-card/index.js +6 -7
- package/dist/cjs/style.scss +13 -1
- package/dist/cjs/tabbed-navigation/index.js +11 -14
- package/dist/cjs/text-control/index.js +32 -42
- package/dist/cjs/utils/index.js +15 -19
- package/dist/cjs/waiting/index.js +1 -2
- package/dist/cjs/web-preview/index.js +7 -8
- package/dist/cjs/with-wizard/index.js +6 -7
- package/dist/cjs/with-wizard-screen/index.js +20 -24
- package/dist/cjs/wizard/components/WizardError.js +7 -9
- package/dist/cjs/wizard/index.js +16 -21
- package/dist/cjs/wizard/store/index.js +36 -37
- package/dist/cjs/wizard/store/utils.js +1 -4
- package/dist/esm/action-card/index.js +3 -4
- package/dist/esm/autocomplete-tokenfield/index.js +52 -15
- package/dist/esm/autocomplete-tokenfield/style.scss +11 -5
- package/dist/esm/autocomplete-with-suggestions/index.js +46 -59
- package/dist/esm/autocomplete-with-suggestions/style.scss +1 -9
- package/dist/esm/button/index.js +7 -7
- package/dist/esm/button-card/index.js +1 -2
- package/dist/esm/category-autocomplete/index.js +4 -8
- package/dist/esm/color-picker/index.js +7 -9
- package/dist/esm/consts.js +0 -2
- package/dist/esm/footer/index.js +24 -29
- package/dist/esm/form-token-field/index.js +1 -2
- package/dist/esm/grid/index.js +13 -29
- package/dist/esm/handoff/index.js +7 -8
- package/dist/esm/hooks/useObjectState.js +1 -2
- package/dist/esm/hooks/useObjectState.test.js +1 -2
- package/dist/esm/hooks/usePrompt.js +1 -4
- package/dist/esm/image-upload/index.js +5 -7
- package/dist/esm/index.js +0 -2
- package/dist/esm/notice/index.js +2 -3
- package/dist/esm/patrons-logo/index.js +4 -5
- package/dist/esm/plugin-installer/index.js +9 -14
- package/dist/esm/plugin-settings/SettingsSection.js +2 -4
- package/dist/esm/plugin-settings/index.js +2 -3
- package/dist/esm/plugin-toggle/index.js +16 -20
- package/dist/esm/position-control/index.js +23 -25
- package/dist/esm/progress-bar/index.js +1 -2
- package/dist/esm/progress-bar/index.test.js +4 -5
- package/dist/esm/section-header/index.js +13 -14
- package/dist/esm/section-header/style.scss +4 -0
- package/dist/esm/select-control/ButtonGroupControl.js +9 -10
- package/dist/esm/select-control/GroupedSelectControl.js +22 -27
- package/dist/esm/settings/MinMaxSetting.js +17 -16
- package/dist/esm/settings/SettingsCard.js +9 -10
- package/dist/esm/settings/SettingsSection.js +20 -24
- package/dist/esm/settings/style.scss +14 -1
- package/dist/esm/sortable-newsletter-list-control/index.js +128 -0
- package/dist/esm/sortable-newsletter-list-control/style.scss +45 -0
- package/dist/esm/steps-list-item/index.js +1 -2
- package/dist/esm/style-card/index.js +6 -7
- package/dist/esm/style.scss +13 -1
- package/dist/esm/tabbed-navigation/index.js +11 -14
- package/dist/esm/text-control/index.js +32 -41
- package/dist/esm/utils/index.js +13 -16
- package/dist/esm/web-preview/index.js +7 -8
- package/dist/esm/with-wizard/index.js +7 -9
- package/dist/esm/with-wizard-screen/index.js +21 -27
- package/dist/esm/wizard/components/WizardError.js +7 -9
- package/dist/esm/wizard/index.js +16 -22
- package/dist/esm/wizard/store/index.js +35 -35
- package/dist/esm/wizard/store/utils.js +1 -4
- package/package.json +7 -8
- package/src/autocomplete-tokenfield/index.js +48 -15
- package/src/autocomplete-tokenfield/style.scss +11 -5
- package/src/autocomplete-with-suggestions/index.js +17 -22
- package/src/autocomplete-with-suggestions/style.scss +1 -9
- package/src/button/{index.js → index.tsx} +12 -5
- package/src/consts.js +0 -2
- package/src/footer/index.js +7 -7
- package/src/grid/index.tsx +34 -0
- package/src/handoff/index.js +7 -6
- package/src/hooks/{index.js → index.ts} +1 -1
- package/src/hooks/{usePrompt.js → usePrompt.ts} +4 -8
- package/src/image-upload/index.js +4 -4
- package/src/index.js +0 -2
- package/src/notice/index.js +1 -1
- package/src/patrons-logo/index.js +4 -1
- package/src/plugin-installer/index.js +7 -7
- package/src/plugin-settings/index.js +1 -1
- package/src/plugin-toggle/index.js +7 -5
- package/src/position-control/index.js +13 -13
- package/src/section-header/index.js +3 -3
- package/src/section-header/style.scss +4 -0
- package/src/select-control/GroupedSelectControl.js +1 -1
- package/src/settings/MinMaxSetting.js +8 -6
- package/src/settings/style.scss +14 -1
- package/src/sortable-newsletter-list-control/index.js +137 -0
- package/src/sortable-newsletter-list-control/style.scss +45 -0
- package/src/style-card/index.js +11 -5
- package/src/style.scss +13 -1
- package/src/tabbed-navigation/index.js +1 -1
- package/src/text-control/index.tsx +65 -0
- package/src/web-preview/index.js +6 -6
- package/src/with-wizard/index.js +4 -4
- package/src/with-wizard-screen/index.js +1 -1
- 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/accordion/index.js +0 -46
- package/dist/cjs/accordion/style.scss +0 -27
- package/dist/cjs/date-range-picker/index.js +0 -41
- package/dist/cjs/date-range-picker/style.scss +0 -148
- package/dist/esm/accordion/index.js +0 -38
- package/dist/esm/accordion/style.scss +0 -27
- package/dist/esm/date-range-picker/index.js +0 -32
- package/dist/esm/date-range-picker/style.scss +0 -148
- package/src/accordion/index.js +0 -32
- package/src/accordion/style.scss +0 -27
- package/src/date-range-picker/index.js +0 -31
- package/src/date-range-picker/style.scss +0 -148
- package/src/grid/index.js +0 -44
- package/src/text-control/index.js +0 -56
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import apiFetch from '@wordpress/api-fetch';
|
|
5
|
-
import { Button, CheckboxControl, SelectControl
|
|
5
|
+
import { Button, CheckboxControl, SelectControl } from '@wordpress/components';
|
|
6
6
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
7
7
|
import { useEffect, useState } from '@wordpress/element';
|
|
8
8
|
import { __ as alias__, _x as alias_x, sprintf } from '@wordpress/i18n';
|
|
@@ -15,42 +15,39 @@ import { addQueryArgs } from '@wordpress/url';
|
|
|
15
15
|
*/
|
|
16
16
|
import { AutocompleteTokenField } from '../';
|
|
17
17
|
import './style.scss';
|
|
18
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// Legacy prop when single-select was the only option.
|
|
52
|
-
suggestionsToFetch = 10 // Number of suggestions to fetch per query.
|
|
53
|
-
} = _ref;
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
19
|
+
const AutocompleteWithSuggestions = ({
|
|
20
|
+
fetchSavedPosts = false,
|
|
21
|
+
// If passed, will use this function to fetch saved data.
|
|
22
|
+
fetchSuggestions = false,
|
|
23
|
+
// If passed, will use this function to fetch suggestions data.
|
|
24
|
+
help = __('Begin typing search term, click autocomplete result to select.', 'newspack-plugin'),
|
|
25
|
+
hideHelp = false,
|
|
26
|
+
// If true, all help text will be hidden.
|
|
27
|
+
label = __('Search', 'newspack-plugin'),
|
|
28
|
+
maxItemsToSuggest = 0,
|
|
29
|
+
// If passed, will be used to determine "load more" state. Necessary if you want "load more" functionality when using a custom `fetchSuggestions` function.
|
|
30
|
+
multiSelect = false,
|
|
31
|
+
// If true, component can select multiple values at once.
|
|
32
|
+
onChange = false,
|
|
33
|
+
// Function to call when selections change.
|
|
34
|
+
onPostTypeChange = false,
|
|
35
|
+
// Funciton to call when the post type selector is changed.
|
|
36
|
+
postTypes = [{
|
|
37
|
+
slug: 'post',
|
|
38
|
+
label: 'Post'
|
|
39
|
+
}],
|
|
40
|
+
// If passed, will render a selector to change the post type queried for suggestions.
|
|
41
|
+
postTypeLabel = __('item', 'newspack-plugin'),
|
|
42
|
+
// String to describe the data being shown.
|
|
43
|
+
postTypeLabelPlural = __('items', 'newspack-plugin'),
|
|
44
|
+
// Plural string to describe the data being shown.
|
|
45
|
+
selectedItems = [],
|
|
46
|
+
// Array of saved items.
|
|
47
|
+
selectedPost = 0,
|
|
48
|
+
// Legacy prop when single-select was the only option.
|
|
49
|
+
suggestionsToFetch = 10 // Number of suggestions to fetch per query.
|
|
50
|
+
}) => {
|
|
54
51
|
const [isLoading, setIsLoading] = useState(true);
|
|
55
52
|
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
56
53
|
const [suggestions, setSuggestions] = useState([]);
|
|
@@ -92,9 +89,7 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
92
89
|
/**
|
|
93
90
|
* If passed a `fetchSavedPosts` prop, use that, otherwise, build it based on the selected post type.
|
|
94
91
|
*/
|
|
95
|
-
const handleFetchSaved = fetchSavedPosts ? fetchSavedPosts : async
|
|
96
|
-
let postIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
97
|
-
let searchSlug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
92
|
+
const handleFetchSaved = fetchSavedPosts ? fetchSavedPosts : async (postIds = [], searchSlug = null) => {
|
|
98
93
|
const postTypeSlug = searchSlug || postTypeToSearch;
|
|
99
94
|
const endpoint = 'post' === postTypeSlug || 'page' === postTypeSlug ? postTypeSlug + 's' // Default post type endpoints are plural.
|
|
100
95
|
: postTypeSlug; // Custom post type endpoints are singular.
|
|
@@ -107,17 +102,14 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
107
102
|
});
|
|
108
103
|
return posts.map(post => ({
|
|
109
104
|
value: parseInt(post.id),
|
|
110
|
-
label: decodeEntities(post.title) || __('(no title)', 'newspack')
|
|
105
|
+
label: decodeEntities(post.title) || __('(no title)', 'newspack-plugin')
|
|
111
106
|
}));
|
|
112
107
|
};
|
|
113
108
|
|
|
114
109
|
/**
|
|
115
110
|
* If passed a `fetchSuggestions` prop, use that, otherwise, build it based on the selected post type.
|
|
116
111
|
*/
|
|
117
|
-
const handleFetchSuggestions = fetchSuggestions ? fetchSuggestions : async
|
|
118
|
-
let search = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
119
|
-
let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
120
|
-
let searchSlug = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
112
|
+
const handleFetchSuggestions = fetchSuggestions ? fetchSuggestions : async (search = null, offset = 0, searchSlug = null) => {
|
|
121
113
|
const postTypeSlug = searchSlug || postTypeToSearch;
|
|
122
114
|
const endpoint = 'post' === postTypeSlug || 'page' === postTypeSlug ? postTypeSlug + 's' // Default post type endpoints are plural.
|
|
123
115
|
: postTypeSlug; // Custom post type endpoints are singular.
|
|
@@ -138,7 +130,7 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
138
130
|
return posts.reduce((acc, post) => {
|
|
139
131
|
acc.push({
|
|
140
132
|
value: parseInt(post.id),
|
|
141
|
-
label: decodeEntities(post?.title.rendered) || __('(no title)', 'newspack')
|
|
133
|
+
label: decodeEntities(post?.title.rendered) || __('(no title)', 'newspack-plugin')
|
|
142
134
|
});
|
|
143
135
|
return acc;
|
|
144
136
|
}, []);
|
|
@@ -183,18 +175,18 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
183
175
|
const selections = selectedPost ? [...selectedItems, selectedPost] : selectedItems;
|
|
184
176
|
const selectedMessage = multiSelect ? sprintf(
|
|
185
177
|
// Translators: %1: the length of selections. %2: the selection leabel.
|
|
186
|
-
__('%1$s %2$s selected', 'newspack'), selections.length, selections.length > 1 ? postTypeLabelPlural : postTypeLabel) :
|
|
178
|
+
__('%1$s %2$s selected', 'newspack-plugin'), selections.length, selections.length > 1 ? postTypeLabelPlural : postTypeLabel) :
|
|
187
179
|
// Translators: %s: The label for the selection.
|
|
188
|
-
sprintf(__('Selected %s', 'newspack'), postTypeLabel);
|
|
180
|
+
sprintf(__('Selected %s', 'newspack-plugin'), postTypeLabel);
|
|
189
181
|
return _jsxs("div", {
|
|
190
182
|
className: "newspack-autocomplete-with-suggestions__selected-items",
|
|
191
183
|
children: [_jsxs("p", {
|
|
192
184
|
className: "newspack-autocomplete-with-suggestions__label",
|
|
193
|
-
children: [selectedMessage, 1 < selections.length && _x(' – ', 'separator character', 'newspack'), 1 < selections.length && _jsx(Button, {
|
|
185
|
+
children: [selectedMessage, 1 < selections.length && _x(' – ', 'separator character', 'newspack-plugin'), 1 < selections.length && _jsx(Button, {
|
|
194
186
|
onClick: () => onChange([]),
|
|
195
187
|
isLink: true,
|
|
196
188
|
isDestructive: true,
|
|
197
|
-
children: __('Clear all', 'newspack')
|
|
189
|
+
children: __('Clear all', 'newspack-plugin')
|
|
198
190
|
})]
|
|
199
191
|
}), selections.map(selection => _jsx(Button, {
|
|
200
192
|
className: "newspack-autocomplete-with-suggestions__selected-item-button",
|
|
@@ -212,7 +204,7 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
212
204
|
return _jsx(SelectControl, {
|
|
213
205
|
label: sprintf(
|
|
214
206
|
// Translators: %s: The name of the type.
|
|
215
|
-
__('%s type', 'newspack'), postTypeLabel.charAt(0).toUpperCase() + postTypeLabel.slice(1)),
|
|
207
|
+
__('%s type', 'newspack-plugin'), postTypeLabel.charAt(0).toUpperCase() + postTypeLabel.slice(1)),
|
|
216
208
|
value: postTypeToSearch,
|
|
217
209
|
options: postTypes.map(postTypeOption => ({
|
|
218
210
|
label: postTypeOption.label,
|
|
@@ -248,12 +240,6 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
248
240
|
* Render a list of suggestions that can be clicked to select instead of searching by title.
|
|
249
241
|
*/
|
|
250
242
|
const renderSuggestions = () => {
|
|
251
|
-
if (isLoading) {
|
|
252
|
-
return _jsx("div", {
|
|
253
|
-
className: "newspack-autocomplete-with-suggestions__suggestions-spinner",
|
|
254
|
-
children: _jsx(Spinner, {})
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
243
|
if (0 === suggestions.length) {
|
|
258
244
|
return null;
|
|
259
245
|
}
|
|
@@ -261,14 +247,14 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
261
247
|
return _jsxs(_Fragment, {
|
|
262
248
|
children: [!hideHelp && _jsx("p", {
|
|
263
249
|
className: "newspack-autocomplete-with-suggestions__label",
|
|
264
|
-
children: /* Translators: %s: the name of a post type. */sprintf(__('Or, select a recent %s:', 'newspack'), postTypeLabel)
|
|
250
|
+
children: /* Translators: %s: the name of a post type. */sprintf(__('Or, select a recent %s:', 'newspack-plugin'), postTypeLabel)
|
|
265
251
|
}), _jsxs("div", {
|
|
266
252
|
className: className,
|
|
267
253
|
children: [suggestions.map(renderSuggestion), suggestions.length < (maxItemsToSuggest || maxSuggestions) && _jsx(Button, {
|
|
268
254
|
disabled: isLoadingMore,
|
|
269
255
|
isSecondary: true,
|
|
270
256
|
onClick: () => setIsLoadingMore(true),
|
|
271
|
-
children: isLoadingMore ? __('Loading…', 'newspack') : __('Load more', 'newspack')
|
|
257
|
+
children: isLoadingMore ? __('Loading…', 'newspack-plugin') : __('Load more', 'newspack-plugin')
|
|
272
258
|
})]
|
|
273
259
|
})]
|
|
274
260
|
});
|
|
@@ -281,6 +267,7 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
281
267
|
fetchSuggestions: async search => handleFetchSuggestions(search, 0, postTypeToSearch),
|
|
282
268
|
fetchSavedInfo: postIds => handleFetchSaved(postIds),
|
|
283
269
|
label: label,
|
|
270
|
+
loading: isLoading,
|
|
284
271
|
help: !hideHelp && help,
|
|
285
272
|
returnFullObjects: true
|
|
286
273
|
}), renderSuggestions()]
|
|
@@ -15,13 +15,6 @@
|
|
|
15
15
|
margin-top: 16px;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
.components-spinner {
|
|
20
|
-
margin: 8px;
|
|
21
|
-
right: 0;
|
|
22
|
-
top: calc( 1.4em + 8px );
|
|
23
|
-
}
|
|
24
|
-
|
|
25
18
|
.components-select-control__input {
|
|
26
19
|
max-width: none;
|
|
27
20
|
}
|
|
@@ -119,8 +112,7 @@
|
|
|
119
112
|
border-radius: 2px;
|
|
120
113
|
border: 1px solid wp-colors.$gray-700;
|
|
121
114
|
max-height: 178px;
|
|
122
|
-
overflow
|
|
123
|
-
overflow-y: auto;
|
|
115
|
+
overflow: visible auto;
|
|
124
116
|
padding: 8px 8px 0;
|
|
125
117
|
|
|
126
118
|
.components-button {
|
package/dist/esm/button/index.js
CHANGED
|
@@ -17,12 +17,11 @@ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
|
17
17
|
const {
|
|
18
18
|
useHistory
|
|
19
19
|
} = Router;
|
|
20
|
-
const Button =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} = _ref;
|
|
20
|
+
const Button = ({
|
|
21
|
+
href,
|
|
22
|
+
onClick,
|
|
23
|
+
...otherProps
|
|
24
|
+
}) => {
|
|
26
25
|
const history = useHistory();
|
|
27
26
|
const [isAwaitingOnClick, setIsAwaitingOnClick] = useState(false);
|
|
28
27
|
|
|
@@ -32,7 +31,7 @@ const Button = _ref => {
|
|
|
32
31
|
setIsAwaitingOnClick(true);
|
|
33
32
|
await onClick();
|
|
34
33
|
setIsAwaitingOnClick(false);
|
|
35
|
-
history.push(href.replace('#', ''));
|
|
34
|
+
history.push((href || '').replace('#', ''));
|
|
36
35
|
};
|
|
37
36
|
} else {
|
|
38
37
|
otherProps.href = href;
|
|
@@ -41,6 +40,7 @@ const Button = _ref => {
|
|
|
41
40
|
if (isAwaitingOnClick) {
|
|
42
41
|
otherProps.disabled = true;
|
|
43
42
|
}
|
|
43
|
+
// @ts-ignore - @wordpress/components' Button can only have either href or onClick, not both.
|
|
44
44
|
return _jsx(BaseComponent, {
|
|
45
45
|
...otherProps
|
|
46
46
|
});
|
|
@@ -18,8 +18,7 @@ import './style.scss';
|
|
|
18
18
|
* External dependencies
|
|
19
19
|
*/
|
|
20
20
|
import classnames from 'classnames';
|
|
21
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
22
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
23
22
|
class ButtonCard extends Component {
|
|
24
23
|
/**
|
|
25
24
|
* Render
|
|
@@ -28,8 +28,7 @@ import classnames from 'classnames';
|
|
|
28
28
|
/**
|
|
29
29
|
* Category autocomplete field component.
|
|
30
30
|
*/
|
|
31
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
31
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
33
32
|
class CategoryAutocomplete extends Component {
|
|
34
33
|
/**
|
|
35
34
|
* Class constructor.
|
|
@@ -72,12 +71,9 @@ class CategoryAutocomplete extends Component {
|
|
|
72
71
|
}
|
|
73
72
|
return acc;
|
|
74
73
|
}, []);
|
|
75
|
-
const availableSuggestions = filter(suggestions,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
} = _ref;
|
|
79
|
-
return selectedIds.indexOf(id) === -1;
|
|
80
|
-
});
|
|
74
|
+
const availableSuggestions = filter(suggestions, ({
|
|
75
|
+
id
|
|
76
|
+
}) => selectedIds.indexOf(id) === -1);
|
|
81
77
|
return availableSuggestions.map(v => v.name);
|
|
82
78
|
});
|
|
83
79
|
this.debouncedUpdateSuggestions = debounce(this.updateSuggestions, 100);
|
|
@@ -17,19 +17,17 @@ import a11yPlugin from 'colord/plugins/a11y';
|
|
|
17
17
|
import hooks from '../hooks';
|
|
18
18
|
import utils from '../utils';
|
|
19
19
|
import './style.scss';
|
|
20
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
21
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
20
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
22
21
|
extend([a11yPlugin]);
|
|
23
22
|
const {
|
|
24
23
|
InteractiveDiv
|
|
25
24
|
} = utils;
|
|
26
|
-
const ColorPicker =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} = _ref;
|
|
25
|
+
const ColorPicker = ({
|
|
26
|
+
label,
|
|
27
|
+
color = '#fff',
|
|
28
|
+
onChange,
|
|
29
|
+
className
|
|
30
|
+
}) => {
|
|
33
31
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
34
32
|
const ref = useRef();
|
|
35
33
|
const colordColor = colord(color);
|
package/dist/esm/consts.js
CHANGED
package/dist/esm/footer/index.js
CHANGED
|
@@ -14,12 +14,10 @@ import { ExternalLink } from '@wordpress/components';
|
|
|
14
14
|
*/
|
|
15
15
|
import { PatronsLogo } from '../';
|
|
16
16
|
import './style.scss';
|
|
17
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
simple
|
|
22
|
-
} = _ref;
|
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
18
|
+
const Footer = ({
|
|
19
|
+
simple
|
|
20
|
+
}) => {
|
|
23
21
|
const {
|
|
24
22
|
components_demo: componentsDemo = false,
|
|
25
23
|
support = false,
|
|
@@ -36,41 +34,41 @@ const Footer = _ref => {
|
|
|
36
34
|
url: 'https://newspack.com/category/release-notes/',
|
|
37
35
|
external: true
|
|
38
36
|
}, {
|
|
39
|
-
label: __('About', 'newspack'),
|
|
37
|
+
label: __('About', 'newspack-plugin'),
|
|
40
38
|
url: 'https://newspack.com/',
|
|
41
39
|
external: true
|
|
42
40
|
}, {
|
|
43
|
-
label: __('Documentation', 'newspack'),
|
|
41
|
+
label: __('Documentation', 'newspack-plugin'),
|
|
44
42
|
url: support,
|
|
45
43
|
external: true
|
|
46
44
|
}];
|
|
47
45
|
if (componentsDemo) {
|
|
48
46
|
footerElements.push({
|
|
49
|
-
label: __('Components Demo', 'newspack'),
|
|
47
|
+
label: __('Components Demo', 'newspack-plugin'),
|
|
50
48
|
url: componentsDemo
|
|
51
49
|
});
|
|
52
50
|
}
|
|
53
51
|
if (setupWizard) {
|
|
54
52
|
footerElements.push({
|
|
55
|
-
label: __('Setup Wizard', 'newspack'),
|
|
53
|
+
label: __('Setup Wizard', 'newspack-plugin'),
|
|
56
54
|
url: setupWizard
|
|
57
55
|
});
|
|
58
56
|
}
|
|
59
57
|
if (resetUrl) {
|
|
60
58
|
footerElements.push({
|
|
61
|
-
label: __('Reset Newspack', 'newspack'),
|
|
59
|
+
label: __('Reset Newspack', 'newspack-plugin'),
|
|
62
60
|
url: resetUrl
|
|
63
61
|
});
|
|
64
62
|
}
|
|
65
63
|
if (removeStarterContent) {
|
|
66
64
|
footerElements.push({
|
|
67
|
-
label: __('Remove Starter Content', 'newspack'),
|
|
65
|
+
label: __('Remove Starter Content', 'newspack-plugin'),
|
|
68
66
|
url: removeStarterContent
|
|
69
67
|
});
|
|
70
68
|
}
|
|
71
69
|
if (supportEmail) {
|
|
72
70
|
footerElements.push({
|
|
73
|
-
label: __('Contact Support', 'newspack'),
|
|
71
|
+
label: __('Contact Support', 'newspack-plugin'),
|
|
74
72
|
url: `mailto:${supportEmail}`
|
|
75
73
|
});
|
|
76
74
|
}
|
|
@@ -79,22 +77,19 @@ const Footer = _ref => {
|
|
|
79
77
|
children: [!simple && _jsx("div", {
|
|
80
78
|
className: "newspack-footer__inner",
|
|
81
79
|
children: _jsx("ul", {
|
|
82
|
-
children: footerElements.map((
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
children:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
})
|
|
96
|
-
}, index);
|
|
97
|
-
})
|
|
80
|
+
children: footerElements.map(({
|
|
81
|
+
url,
|
|
82
|
+
label,
|
|
83
|
+
external
|
|
84
|
+
}, index) => _jsx("li", {
|
|
85
|
+
children: external ? _jsx(ExternalLink, {
|
|
86
|
+
href: url,
|
|
87
|
+
children: label
|
|
88
|
+
}) : _jsx("a", {
|
|
89
|
+
href: url,
|
|
90
|
+
children: label
|
|
91
|
+
})
|
|
92
|
+
}, index))
|
|
98
93
|
})
|
|
99
94
|
}), _jsx("div", {
|
|
100
95
|
className: "newspack-footer__logo",
|
|
@@ -17,8 +17,7 @@ import './style.scss';
|
|
|
17
17
|
* External dependencies.
|
|
18
18
|
*/
|
|
19
19
|
import classnames from 'classnames';
|
|
20
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
21
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
20
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
22
21
|
class FormTokenField extends Component {
|
|
23
22
|
/**
|
|
24
23
|
* Render.
|
package/dist/esm/grid/index.js
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* Grid
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* WordPress dependencies
|
|
7
|
-
*/
|
|
8
|
-
import { Component } from '@wordpress/element';
|
|
9
|
-
|
|
10
5
|
/**
|
|
11
6
|
* Internal dependencies
|
|
12
7
|
*/
|
|
@@ -17,29 +12,18 @@ import './style.scss';
|
|
|
17
12
|
*/
|
|
18
13
|
import classnames from 'classnames';
|
|
19
14
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const classes = classnames('newspack-grid', noMargin && 'newspack-grid--no-margin', columns && 'newspack-grid__columns-' + columns, gutter && 'newspack-grid__gutter-' + gutter, rowGap && 'newspack-grid__row-gap-' + rowGap, className);
|
|
34
|
-
return _jsx("div", {
|
|
35
|
-
className: classes,
|
|
36
|
-
...otherProps
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
Grid.defaultProps = {
|
|
41
|
-
columns: 2,
|
|
42
|
-
gutter: 32,
|
|
43
|
-
rowGap: null
|
|
15
|
+
const Grid = ({
|
|
16
|
+
className = '',
|
|
17
|
+
columns = 2,
|
|
18
|
+
gutter = 32,
|
|
19
|
+
noMargin = false,
|
|
20
|
+
rowGap = 0,
|
|
21
|
+
...otherProps
|
|
22
|
+
}) => {
|
|
23
|
+
const classes = classnames('newspack-grid', noMargin && 'newspack-grid--no-margin', columns && 'newspack-grid__columns-' + columns, gutter && 'newspack-grid__gutter-' + gutter, rowGap && 'newspack-grid__row-gap-' + rowGap, className);
|
|
24
|
+
return _jsx("div", {
|
|
25
|
+
className: classes,
|
|
26
|
+
...otherProps
|
|
27
|
+
});
|
|
44
28
|
};
|
|
45
29
|
export default Grid;
|
|
@@ -21,8 +21,7 @@ import { Button, Card, Modal, Waiting } from '../';
|
|
|
21
21
|
*/
|
|
22
22
|
import assign from 'lodash/assign';
|
|
23
23
|
import classnames from 'classnames';
|
|
24
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
25
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
24
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
26
25
|
class Handoff extends Component {
|
|
27
26
|
constructor() {
|
|
28
27
|
super(...arguments);
|
|
@@ -54,10 +53,10 @@ class Handoff extends Component {
|
|
|
54
53
|
_defineProperty(this, "textForPlugin", pluginInfo => {
|
|
55
54
|
const defaults = {
|
|
56
55
|
modalBody: null,
|
|
57
|
-
modalTitle: pluginInfo.Name && `${__('Manage', 'newspack')} ${pluginInfo.Name}`,
|
|
58
|
-
primaryButton: pluginInfo.Name && `${__('Manage', 'newspack')} ${pluginInfo.Name}`,
|
|
59
|
-
primaryModalButton: __('Manage', 'newspack'),
|
|
60
|
-
dismissModalButton: __('Dismiss', 'newspack')
|
|
56
|
+
modalTitle: pluginInfo.Name && `${__('Manage', 'newspack-plugin')} ${pluginInfo.Name}`,
|
|
57
|
+
primaryButton: pluginInfo.Name && `${__('Manage', 'newspack-plugin')} ${pluginInfo.Name}`,
|
|
58
|
+
primaryModalButton: __('Manage', 'newspack-plugin'),
|
|
59
|
+
dismissModalButton: __('Dismiss', 'newspack-plugin')
|
|
61
60
|
};
|
|
62
61
|
return assign(defaults, this.props);
|
|
63
62
|
});
|
|
@@ -134,7 +133,7 @@ class Handoff extends Component {
|
|
|
134
133
|
variant: "secondary",
|
|
135
134
|
disabled: true,
|
|
136
135
|
...otherProps,
|
|
137
|
-
children: Name + __(' not installed', 'newspack')
|
|
136
|
+
children: Name + __(' not installed', 'newspack-plugin')
|
|
138
137
|
}), !Name && _jsx(Button, {
|
|
139
138
|
className: classes,
|
|
140
139
|
isSecondary: !otherProps.isPrimary && !otherProps.isTertiary && !otherProps.isLink,
|
|
@@ -142,7 +141,7 @@ class Handoff extends Component {
|
|
|
142
141
|
children: _jsxs(Fragment, {
|
|
143
142
|
children: [!compact && _jsx(Waiting, {
|
|
144
143
|
isLeft: true
|
|
145
|
-
}), __('Retrieving Plugin Info', 'newspack')]
|
|
144
|
+
}), __('Retrieving Plugin Info', 'newspack-plugin')]
|
|
146
145
|
})
|
|
147
146
|
}), showModal && _jsxs(Modal, {
|
|
148
147
|
title: modalTitle,
|
|
@@ -15,8 +15,7 @@ const mergeCustomizer = (objValue, srcValue) => {
|
|
|
15
15
|
* A useState for an object.
|
|
16
16
|
* Nested objects will be nested, but arrays replaced.
|
|
17
17
|
*/
|
|
18
|
-
export default (
|
|
19
|
-
let initial = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18
|
+
export default ((initial = {}) => {
|
|
20
19
|
const [stateObject, setStateObject] = useState(initial);
|
|
21
20
|
const runUpdate = update => setStateObject(_stateObject => mergeWith({}, _stateObject, update, mergeCustomizer));
|
|
22
21
|
const updateStateObject = keyOrUpdate => {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
3
|
import useObjectState from './useObjectState';
|
|
4
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
5
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
6
5
|
const INIT_STATE = {
|
|
7
6
|
name: 'Foo',
|
|
8
7
|
widgets: [1],
|
|
@@ -22,9 +22,6 @@ export default ((when, message) => {
|
|
|
22
22
|
if (typeof event === 'undefined') {
|
|
23
23
|
event = window.event;
|
|
24
24
|
}
|
|
25
|
-
if (event) {
|
|
26
|
-
event.returnValue = message;
|
|
27
|
-
}
|
|
28
25
|
return message;
|
|
29
26
|
};
|
|
30
27
|
useEffect(() => {
|
|
@@ -39,5 +36,5 @@ export default ((when, message) => {
|
|
|
39
36
|
window.removeEventListener('beforeunload', onWindowOrTabClose);
|
|
40
37
|
};
|
|
41
38
|
}, [message, when]);
|
|
42
|
-
return self.current;
|
|
39
|
+
return self.current || (() => {});
|
|
43
40
|
});
|
|
@@ -20,9 +20,7 @@ import './style.scss';
|
|
|
20
20
|
* External dependencies.
|
|
21
21
|
*/
|
|
22
22
|
import classnames from 'classnames';
|
|
23
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
24
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
25
|
-
import { Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
26
24
|
class ImageUpload extends Component {
|
|
27
25
|
/**
|
|
28
26
|
* Constructor.
|
|
@@ -103,14 +101,14 @@ class ImageUpload extends Component {
|
|
|
103
101
|
children: [_jsx("img", {
|
|
104
102
|
"data-testid": "image-upload",
|
|
105
103
|
src: image.url,
|
|
106
|
-
alt: __('Image preview', 'newspack')
|
|
104
|
+
alt: __('Image preview', 'newspack-plugin')
|
|
107
105
|
}), _jsxs("div", {
|
|
108
106
|
className: "newspack-image-upload__controls",
|
|
109
107
|
children: [_jsx(Button, {
|
|
110
108
|
disabled: disabled,
|
|
111
109
|
onClick: this.openModal,
|
|
112
110
|
isLink: true,
|
|
113
|
-
children: __('Replace', 'newspack')
|
|
111
|
+
children: __('Replace', 'newspack-plugin')
|
|
114
112
|
}), _jsx("span", {
|
|
115
113
|
className: "sep"
|
|
116
114
|
}), _jsx(Button, {
|
|
@@ -118,14 +116,14 @@ class ImageUpload extends Component {
|
|
|
118
116
|
onClick: () => onChange(null),
|
|
119
117
|
isLink: true,
|
|
120
118
|
isDestructive: true,
|
|
121
|
-
children: __('Remove', 'newspack')
|
|
119
|
+
children: __('Remove', 'newspack-plugin')
|
|
122
120
|
})]
|
|
123
121
|
})]
|
|
124
122
|
}) : _jsx(Button, {
|
|
125
123
|
disabled: disabled,
|
|
126
124
|
onClick: this.openModal,
|
|
127
125
|
isLink: true,
|
|
128
|
-
children: buttonLabel ? buttonLabel : __('Upload', 'newspack')
|
|
126
|
+
children: buttonLabel ? buttonLabel : __('Upload', 'newspack-plugin')
|
|
129
127
|
})
|
|
130
128
|
}), help && _jsx("p", {
|
|
131
129
|
className: "newspack-image-upload__help",
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { default as Accordion } from './accordion';
|
|
2
1
|
export { default as ActionCard } from './action-card';
|
|
3
2
|
export { default as AutocompleteTokenField } from './autocomplete-tokenfield';
|
|
4
3
|
export { default as AutocompleteWithSuggestions } from './autocomplete-with-suggestions';
|
|
@@ -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/dist/esm/notice/index.js
CHANGED
|
@@ -19,8 +19,7 @@ import './style.scss';
|
|
|
19
19
|
* External dependencies.
|
|
20
20
|
*/
|
|
21
21
|
import classnames from 'classnames';
|
|
22
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
23
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
22
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
24
23
|
class Notice extends Component {
|
|
25
24
|
/**
|
|
26
25
|
* Render
|
|
@@ -59,7 +58,7 @@ class Notice extends Component {
|
|
|
59
58
|
className: "newspack-notice__content",
|
|
60
59
|
children: [rawHTML ? _jsx(RawHTML, {
|
|
61
60
|
children: noticeText
|
|
62
|
-
}) : noticeText, debugMode && __('Debug Mode', 'newspack'), children || null]
|
|
61
|
+
}) : noticeText, debugMode && __('Debug Mode', 'newspack-plugin'), children || null]
|
|
63
62
|
})]
|
|
64
63
|
});
|
|
65
64
|
}
|