newspack-components 2.2.0 → 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/shared/js/button-props.js +3 -1
- package/shared/scss/_colors.scss +15 -0
- package/shared/scss/_mixins.scss +12 -0
- 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/button-group/index.js +0 -57
- package/dist/cjs/button-group/style.scss +0 -73
- package/dist/cjs/checkbox-control/index.js +0 -63
- package/dist/cjs/checkbox-control/style.scss +0 -78
- package/dist/cjs/date-range-picker/index.js +0 -41
- package/dist/cjs/date-range-picker/style.scss +0 -148
- package/dist/cjs/preview-box/index.js +0 -36
- package/dist/cjs/preview-box/style.scss +0 -18
- package/dist/cjs/textarea-control/index.js +0 -54
- package/dist/cjs/textarea-control/style.scss +0 -76
- package/dist/cjs/toggle-control/index.js +0 -58
- package/dist/cjs/toggle-control/style.scss +0 -74
- package/dist/cjs/toggle-group/index.js +0 -71
- package/dist/cjs/toggle-group/style.scss +0 -28
- package/dist/cjs/wizard/style.scss +0 -148
- package/dist/esm/accordion/index.js +0 -38
- package/dist/esm/accordion/style.scss +0 -27
- package/dist/esm/button-group/index.js +0 -43
- package/dist/esm/button-group/style.scss +0 -73
- package/dist/esm/checkbox-control/index.js +0 -49
- package/dist/esm/checkbox-control/style.scss +0 -78
- package/dist/esm/date-range-picker/index.js +0 -32
- package/dist/esm/date-range-picker/style.scss +0 -148
- package/dist/esm/preview-box/index.js +0 -30
- package/dist/esm/preview-box/style.scss +0 -18
- package/dist/esm/textarea-control/index.js +0 -40
- package/dist/esm/textarea-control/style.scss +0 -76
- package/dist/esm/toggle-control/index.js +0 -44
- package/dist/esm/toggle-control/style.scss +0 -74
- package/dist/esm/toggle-group/index.js +0 -58
- package/dist/esm/toggle-group/style.scss +0 -28
- package/dist/esm/wizard/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
|
@@ -30,8 +30,8 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
class ActionCard extends _element.Component {
|
|
33
|
-
constructor() {
|
|
34
|
-
super(...
|
|
33
|
+
constructor(...args) {
|
|
34
|
+
super(...args);
|
|
35
35
|
(0, _defineProperty2.default)(this, "state", {
|
|
36
36
|
expanded: false
|
|
37
37
|
});
|
|
@@ -226,5 +226,4 @@ class ActionCard extends _element.Component {
|
|
|
226
226
|
ActionCard.defaultProps = {
|
|
227
227
|
toggleChecked: false
|
|
228
228
|
};
|
|
229
|
-
var _default = ActionCard;
|
|
230
|
-
exports.default = _default;
|
|
229
|
+
var _default = exports.default = ActionCard;
|
|
@@ -70,6 +70,31 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* When the component updates, fetch information about the tokens so we can populate
|
|
75
|
+
* the tokens with the correct labels.
|
|
76
|
+
*/
|
|
77
|
+
componentDidUpdate(prevProps) {
|
|
78
|
+
const {
|
|
79
|
+
tokens,
|
|
80
|
+
fetchSavedInfo
|
|
81
|
+
} = this.props;
|
|
82
|
+
if (tokens !== prevProps.tokens && this.isFetchingInfoOnLoad()) {
|
|
83
|
+
fetchSavedInfo(tokens).then(results => {
|
|
84
|
+
const {
|
|
85
|
+
validValues
|
|
86
|
+
} = this.state;
|
|
87
|
+
results.forEach(suggestion => {
|
|
88
|
+
validValues[suggestion.value] = suggestion.label;
|
|
89
|
+
});
|
|
90
|
+
this.setState({
|
|
91
|
+
validValues,
|
|
92
|
+
loading: false
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
73
98
|
/**
|
|
74
99
|
* Clean up any unfinished autocomplete api call requests.
|
|
75
100
|
*/
|
|
@@ -116,8 +141,10 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
116
141
|
return labels.reduce((acc, label) => {
|
|
117
142
|
Object.keys(validValues).forEach(key => {
|
|
118
143
|
if (validValues[key] === label) {
|
|
144
|
+
// Preserve numeric or string type of values. Object.keys will convert numbers to strings.
|
|
145
|
+
const value = isNaN(parseInt(key)) ? key.toString() : parseInt(key);
|
|
119
146
|
acc.push({
|
|
120
|
-
value
|
|
147
|
+
value,
|
|
121
148
|
label
|
|
122
149
|
});
|
|
123
150
|
}
|
|
@@ -125,7 +152,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
125
152
|
return acc;
|
|
126
153
|
}, []);
|
|
127
154
|
}
|
|
128
|
-
return labels.map(label => Object.keys(validValues).find(key => validValues[key] === label));
|
|
155
|
+
return labels.map(label => Object.keys(validValues).map(key => isNaN(parseInt(key)) ? key.toString() : parseInt(key)).find(key => validValues[key] === label));
|
|
129
156
|
}
|
|
130
157
|
|
|
131
158
|
/**
|
|
@@ -151,14 +178,16 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
151
178
|
if (this.suggestionsRequest !== request) {
|
|
152
179
|
return;
|
|
153
180
|
}
|
|
181
|
+
const {
|
|
182
|
+
validValues
|
|
183
|
+
} = this.state;
|
|
154
184
|
const currentSuggestions = [...suggestions];
|
|
155
|
-
const currentValidValues = {};
|
|
156
185
|
suggestions.forEach(suggestion => {
|
|
157
|
-
|
|
186
|
+
validValues[suggestion.value] = suggestion.label;
|
|
158
187
|
});
|
|
159
188
|
this.setState({
|
|
160
189
|
suggestions: currentSuggestions,
|
|
161
|
-
validValues
|
|
190
|
+
validValues,
|
|
162
191
|
loading: false
|
|
163
192
|
});
|
|
164
193
|
}).catch(() => {
|
|
@@ -203,27 +232,35 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
203
232
|
const {
|
|
204
233
|
help,
|
|
205
234
|
label = '',
|
|
235
|
+
placeholder = '',
|
|
206
236
|
maxLength
|
|
207
237
|
} = this.props;
|
|
208
238
|
const {
|
|
209
239
|
suggestions,
|
|
210
240
|
loading
|
|
211
241
|
} = this.state;
|
|
242
|
+
const classNames = ['newspack-autocomplete-tokenfield__input-container'];
|
|
243
|
+
if (label) {
|
|
244
|
+
classNames.push('has-label');
|
|
245
|
+
}
|
|
212
246
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
213
247
|
className: "newspack-autocomplete-tokenfield",
|
|
214
|
-
children: [(0, _jsxRuntime.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
248
|
+
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
249
|
+
className: classNames.join(' '),
|
|
250
|
+
children: [(0, _jsxRuntime.jsx)(_components.FormTokenField, {
|
|
251
|
+
value: this.getTokens(),
|
|
252
|
+
suggestions: suggestions.map(suggestion => suggestion.label),
|
|
253
|
+
onChange: tokens => this.handleOnChange(tokens),
|
|
254
|
+
onInputChange: input => this.debouncedUpdateSuggestions(input),
|
|
255
|
+
label: label,
|
|
256
|
+
maxLength: maxLength,
|
|
257
|
+
placeholder: placeholder
|
|
258
|
+
}), loading && (0, _jsxRuntime.jsx)(_components.Spinner, {})]
|
|
259
|
+
}), help && (0, _jsxRuntime.jsx)("p", {
|
|
222
260
|
className: "newspack-autocomplete-tokenfield__help",
|
|
223
261
|
children: help
|
|
224
262
|
})]
|
|
225
263
|
});
|
|
226
264
|
}
|
|
227
265
|
}
|
|
228
|
-
var _default = AutocompleteTokenField;
|
|
229
|
-
exports.default = _default;
|
|
266
|
+
var _default = exports.default = AutocompleteTokenField;
|
|
@@ -5,13 +5,19 @@
|
|
|
5
5
|
@use '~@wordpress/base-styles/colors' as wp-colors;
|
|
6
6
|
|
|
7
7
|
.newspack-autocomplete-tokenfield {
|
|
8
|
-
position: relative;
|
|
9
|
-
|
|
10
8
|
.components-spinner {
|
|
11
|
-
margin:
|
|
9
|
+
margin: 0;
|
|
12
10
|
position: absolute;
|
|
13
|
-
right:
|
|
14
|
-
top:
|
|
11
|
+
right: 8px;
|
|
12
|
+
top: 8px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&__input-container {
|
|
16
|
+
position: relative;
|
|
17
|
+
|
|
18
|
+
&.has-label .components-spinner {
|
|
19
|
+
top: 32px;
|
|
20
|
+
}
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
/* Workaround for hard-coded help text in FormTokenField. */
|
|
@@ -22,39 +22,38 @@ const __ = _i18n.__,
|
|
|
22
22
|
/**
|
|
23
23
|
* External dependencies.
|
|
24
24
|
*/
|
|
25
|
-
const AutocompleteWithSuggestions =
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
} = _ref;
|
|
25
|
+
const AutocompleteWithSuggestions = ({
|
|
26
|
+
fetchSavedPosts = false,
|
|
27
|
+
// If passed, will use this function to fetch saved data.
|
|
28
|
+
fetchSuggestions = false,
|
|
29
|
+
// If passed, will use this function to fetch suggestions data.
|
|
30
|
+
help = __('Begin typing search term, click autocomplete result to select.', 'newspack-plugin'),
|
|
31
|
+
hideHelp = false,
|
|
32
|
+
// If true, all help text will be hidden.
|
|
33
|
+
label = __('Search', 'newspack-plugin'),
|
|
34
|
+
maxItemsToSuggest = 0,
|
|
35
|
+
// If passed, will be used to determine "load more" state. Necessary if you want "load more" functionality when using a custom `fetchSuggestions` function.
|
|
36
|
+
multiSelect = false,
|
|
37
|
+
// If true, component can select multiple values at once.
|
|
38
|
+
onChange = false,
|
|
39
|
+
// Function to call when selections change.
|
|
40
|
+
onPostTypeChange = false,
|
|
41
|
+
// Funciton to call when the post type selector is changed.
|
|
42
|
+
postTypes = [{
|
|
43
|
+
slug: 'post',
|
|
44
|
+
label: 'Post'
|
|
45
|
+
}],
|
|
46
|
+
// If passed, will render a selector to change the post type queried for suggestions.
|
|
47
|
+
postTypeLabel = __('item', 'newspack-plugin'),
|
|
48
|
+
// String to describe the data being shown.
|
|
49
|
+
postTypeLabelPlural = __('items', 'newspack-plugin'),
|
|
50
|
+
// Plural string to describe the data being shown.
|
|
51
|
+
selectedItems = [],
|
|
52
|
+
// Array of saved items.
|
|
53
|
+
selectedPost = 0,
|
|
54
|
+
// Legacy prop when single-select was the only option.
|
|
55
|
+
suggestionsToFetch = 10 // Number of suggestions to fetch per query.
|
|
56
|
+
}) => {
|
|
58
57
|
const [isLoading, setIsLoading] = (0, _element.useState)(true);
|
|
59
58
|
const [isLoadingMore, setIsLoadingMore] = (0, _element.useState)(false);
|
|
60
59
|
const [suggestions, setSuggestions] = (0, _element.useState)([]);
|
|
@@ -96,9 +95,7 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
96
95
|
/**
|
|
97
96
|
* If passed a `fetchSavedPosts` prop, use that, otherwise, build it based on the selected post type.
|
|
98
97
|
*/
|
|
99
|
-
const handleFetchSaved = fetchSavedPosts ? fetchSavedPosts : async
|
|
100
|
-
let postIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
101
|
-
let searchSlug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
98
|
+
const handleFetchSaved = fetchSavedPosts ? fetchSavedPosts : async (postIds = [], searchSlug = null) => {
|
|
102
99
|
const postTypeSlug = searchSlug || postTypeToSearch;
|
|
103
100
|
const endpoint = 'post' === postTypeSlug || 'page' === postTypeSlug ? postTypeSlug + 's' // Default post type endpoints are plural.
|
|
104
101
|
: postTypeSlug; // Custom post type endpoints are singular.
|
|
@@ -111,17 +108,14 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
111
108
|
});
|
|
112
109
|
return posts.map(post => ({
|
|
113
110
|
value: parseInt(post.id),
|
|
114
|
-
label: (0, _htmlEntities.decodeEntities)(post.title) || __('(no title)', 'newspack')
|
|
111
|
+
label: (0, _htmlEntities.decodeEntities)(post.title) || __('(no title)', 'newspack-plugin')
|
|
115
112
|
}));
|
|
116
113
|
};
|
|
117
114
|
|
|
118
115
|
/**
|
|
119
116
|
* If passed a `fetchSuggestions` prop, use that, otherwise, build it based on the selected post type.
|
|
120
117
|
*/
|
|
121
|
-
const handleFetchSuggestions = fetchSuggestions ? fetchSuggestions : async
|
|
122
|
-
let search = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
123
|
-
let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
124
|
-
let searchSlug = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
118
|
+
const handleFetchSuggestions = fetchSuggestions ? fetchSuggestions : async (search = null, offset = 0, searchSlug = null) => {
|
|
125
119
|
const postTypeSlug = searchSlug || postTypeToSearch;
|
|
126
120
|
const endpoint = 'post' === postTypeSlug || 'page' === postTypeSlug ? postTypeSlug + 's' // Default post type endpoints are plural.
|
|
127
121
|
: postTypeSlug; // Custom post type endpoints are singular.
|
|
@@ -142,7 +136,7 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
142
136
|
return posts.reduce((acc, post) => {
|
|
143
137
|
acc.push({
|
|
144
138
|
value: parseInt(post.id),
|
|
145
|
-
label: (0, _htmlEntities.decodeEntities)(post?.title.rendered) || __('(no title)', 'newspack')
|
|
139
|
+
label: (0, _htmlEntities.decodeEntities)(post?.title.rendered) || __('(no title)', 'newspack-plugin')
|
|
146
140
|
});
|
|
147
141
|
return acc;
|
|
148
142
|
}, []);
|
|
@@ -187,18 +181,18 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
187
181
|
const selections = selectedPost ? [...selectedItems, selectedPost] : selectedItems;
|
|
188
182
|
const selectedMessage = multiSelect ? (0, _i18n.sprintf)(
|
|
189
183
|
// Translators: %1: the length of selections. %2: the selection leabel.
|
|
190
|
-
__('%1$s %2$s selected', 'newspack'), selections.length, selections.length > 1 ? postTypeLabelPlural : postTypeLabel) :
|
|
184
|
+
__('%1$s %2$s selected', 'newspack-plugin'), selections.length, selections.length > 1 ? postTypeLabelPlural : postTypeLabel) :
|
|
191
185
|
// Translators: %s: The label for the selection.
|
|
192
|
-
(0, _i18n.sprintf)(__('Selected %s', 'newspack'), postTypeLabel);
|
|
186
|
+
(0, _i18n.sprintf)(__('Selected %s', 'newspack-plugin'), postTypeLabel);
|
|
193
187
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
194
188
|
className: "newspack-autocomplete-with-suggestions__selected-items",
|
|
195
189
|
children: [(0, _jsxRuntime.jsxs)("p", {
|
|
196
190
|
className: "newspack-autocomplete-with-suggestions__label",
|
|
197
|
-
children: [selectedMessage, 1 < selections.length && _x(' – ', 'separator character', 'newspack'), 1 < selections.length && (0, _jsxRuntime.jsx)(_components.Button, {
|
|
191
|
+
children: [selectedMessage, 1 < selections.length && _x(' – ', 'separator character', 'newspack-plugin'), 1 < selections.length && (0, _jsxRuntime.jsx)(_components.Button, {
|
|
198
192
|
onClick: () => onChange([]),
|
|
199
193
|
isLink: true,
|
|
200
194
|
isDestructive: true,
|
|
201
|
-
children: __('Clear all', 'newspack')
|
|
195
|
+
children: __('Clear all', 'newspack-plugin')
|
|
202
196
|
})]
|
|
203
197
|
}), selections.map(selection => (0, _jsxRuntime.jsx)(_components.Button, {
|
|
204
198
|
className: "newspack-autocomplete-with-suggestions__selected-item-button",
|
|
@@ -216,7 +210,7 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
216
210
|
return (0, _jsxRuntime.jsx)(_components.SelectControl, {
|
|
217
211
|
label: (0, _i18n.sprintf)(
|
|
218
212
|
// Translators: %s: The name of the type.
|
|
219
|
-
__('%s type', 'newspack'), postTypeLabel.charAt(0).toUpperCase() + postTypeLabel.slice(1)),
|
|
213
|
+
__('%s type', 'newspack-plugin'), postTypeLabel.charAt(0).toUpperCase() + postTypeLabel.slice(1)),
|
|
220
214
|
value: postTypeToSearch,
|
|
221
215
|
options: postTypes.map(postTypeOption => ({
|
|
222
216
|
label: postTypeOption.label,
|
|
@@ -252,12 +246,6 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
252
246
|
* Render a list of suggestions that can be clicked to select instead of searching by title.
|
|
253
247
|
*/
|
|
254
248
|
const renderSuggestions = () => {
|
|
255
|
-
if (isLoading) {
|
|
256
|
-
return (0, _jsxRuntime.jsx)("div", {
|
|
257
|
-
className: "newspack-autocomplete-with-suggestions__suggestions-spinner",
|
|
258
|
-
children: (0, _jsxRuntime.jsx)(_components.Spinner, {})
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
249
|
if (0 === suggestions.length) {
|
|
262
250
|
return null;
|
|
263
251
|
}
|
|
@@ -265,14 +253,14 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
265
253
|
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
266
254
|
children: [!hideHelp && (0, _jsxRuntime.jsx)("p", {
|
|
267
255
|
className: "newspack-autocomplete-with-suggestions__label",
|
|
268
|
-
children: /* Translators: %s: the name of a post type. */(0, _i18n.sprintf)(__('Or, select a recent %s:', 'newspack'), postTypeLabel)
|
|
256
|
+
children: /* Translators: %s: the name of a post type. */(0, _i18n.sprintf)(__('Or, select a recent %s:', 'newspack-plugin'), postTypeLabel)
|
|
269
257
|
}), (0, _jsxRuntime.jsxs)("div", {
|
|
270
258
|
className: className,
|
|
271
259
|
children: [suggestions.map(renderSuggestion), suggestions.length < (maxItemsToSuggest || maxSuggestions) && (0, _jsxRuntime.jsx)(_components.Button, {
|
|
272
260
|
disabled: isLoadingMore,
|
|
273
261
|
isSecondary: true,
|
|
274
262
|
onClick: () => setIsLoadingMore(true),
|
|
275
|
-
children: isLoadingMore ? __('Loading…', 'newspack') : __('Load more', 'newspack')
|
|
263
|
+
children: isLoadingMore ? __('Loading…', 'newspack-plugin') : __('Load more', 'newspack-plugin')
|
|
276
264
|
})]
|
|
277
265
|
})]
|
|
278
266
|
});
|
|
@@ -285,10 +273,10 @@ const AutocompleteWithSuggestions = _ref => {
|
|
|
285
273
|
fetchSuggestions: async search => handleFetchSuggestions(search, 0, postTypeToSearch),
|
|
286
274
|
fetchSavedInfo: postIds => handleFetchSaved(postIds),
|
|
287
275
|
label: label,
|
|
276
|
+
loading: isLoading,
|
|
288
277
|
help: !hideHelp && help,
|
|
289
278
|
returnFullObjects: true
|
|
290
279
|
}), renderSuggestions()]
|
|
291
280
|
});
|
|
292
281
|
};
|
|
293
|
-
var _default = AutocompleteWithSuggestions;
|
|
294
|
-
exports.default = _default;
|
|
282
|
+
var _default = exports.default = AutocompleteWithSuggestions;
|
|
@@ -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/cjs/button/index.js
CHANGED
|
@@ -25,12 +25,11 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
25
25
|
const {
|
|
26
26
|
useHistory
|
|
27
27
|
} = _router.default;
|
|
28
|
-
const Button =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} = _ref;
|
|
28
|
+
const Button = ({
|
|
29
|
+
href,
|
|
30
|
+
onClick,
|
|
31
|
+
...otherProps
|
|
32
|
+
}) => {
|
|
34
33
|
const history = useHistory();
|
|
35
34
|
const [isAwaitingOnClick, setIsAwaitingOnClick] = (0, _element.useState)(false);
|
|
36
35
|
|
|
@@ -40,7 +39,7 @@ const Button = _ref => {
|
|
|
40
39
|
setIsAwaitingOnClick(true);
|
|
41
40
|
await onClick();
|
|
42
41
|
setIsAwaitingOnClick(false);
|
|
43
|
-
history.push(href.replace('#', ''));
|
|
42
|
+
history.push((href || '').replace('#', ''));
|
|
44
43
|
};
|
|
45
44
|
} else {
|
|
46
45
|
otherProps.href = href;
|
|
@@ -49,9 +48,9 @@ const Button = _ref => {
|
|
|
49
48
|
if (isAwaitingOnClick) {
|
|
50
49
|
otherProps.disabled = true;
|
|
51
50
|
}
|
|
51
|
+
// @ts-ignore - @wordpress/components' Button can only have either href or onClick, not both.
|
|
52
52
|
return (0, _jsxRuntime.jsx)(_components.Button, {
|
|
53
53
|
...otherProps
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
|
-
var _default = Button;
|
|
57
|
-
exports.default = _default;
|
|
56
|
+
var _default = exports.default = Button;
|
package/dist/cjs/card/index.js
CHANGED
|
@@ -77,12 +77,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
77
77
|
}
|
|
78
78
|
return acc;
|
|
79
79
|
}, []);
|
|
80
|
-
const availableSuggestions = (0, _filter.default)(suggestions,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
} = _ref;
|
|
84
|
-
return selectedIds.indexOf(id) === -1;
|
|
85
|
-
});
|
|
80
|
+
const availableSuggestions = (0, _filter.default)(suggestions, ({
|
|
81
|
+
id
|
|
82
|
+
}) => selectedIds.indexOf(id) === -1);
|
|
86
83
|
return availableSuggestions.map(v => v.name);
|
|
87
84
|
});
|
|
88
85
|
this.debouncedUpdateSuggestions = (0, _debounce.default)(this.updateSuggestions, 100);
|
|
@@ -187,5 +184,4 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
187
184
|
CategoryAutocomplete.defaultProps = {
|
|
188
185
|
taxonomy: 'categories'
|
|
189
186
|
};
|
|
190
|
-
var _default = CategoryAutocomplete;
|
|
191
|
-
exports.default = _default;
|
|
187
|
+
var _default = exports.default = CategoryAutocomplete;
|
|
@@ -30,13 +30,12 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
30
30
|
const {
|
|
31
31
|
InteractiveDiv
|
|
32
32
|
} = _utils.default;
|
|
33
|
-
const ColorPicker =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} = _ref;
|
|
33
|
+
const ColorPicker = ({
|
|
34
|
+
label,
|
|
35
|
+
color = '#fff',
|
|
36
|
+
onChange,
|
|
37
|
+
className
|
|
38
|
+
}) => {
|
|
40
39
|
const [isExpanded, setIsExpanded] = (0, _element.useState)(false);
|
|
41
40
|
const ref = (0, _element.useRef)();
|
|
42
41
|
const colordColor = (0, _colord.colord)(color);
|
|
@@ -65,5 +64,4 @@ const ColorPicker = _ref => {
|
|
|
65
64
|
})]
|
|
66
65
|
});
|
|
67
66
|
};
|
|
68
|
-
var _default = ColorPicker;
|
|
69
|
-
exports.default = _default;
|
|
67
|
+
var _default = exports.default = ColorPicker;
|
package/dist/cjs/consts.js
CHANGED
|
@@ -3,10 +3,5 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
8
|
-
exports.NEWSPACK_SITE_URL = NEWSPACK_SITE_URL;
|
|
9
|
-
const NEWSPACK_SUPPORT_URL = `${NEWSPACK_SITE_URL}/support`;
|
|
10
|
-
exports.NEWSPACK_SUPPORT_URL = NEWSPACK_SUPPORT_URL;
|
|
11
|
-
const HANDOFF_KEY = 'newspack_wizard_handoff_message';
|
|
12
|
-
exports.HANDOFF_KEY = HANDOFF_KEY;
|
|
6
|
+
exports.HANDOFF_KEY = void 0;
|
|
7
|
+
const HANDOFF_KEY = exports.HANDOFF_KEY = 'newspack_wizard_handoff_message';
|
package/dist/cjs/footer/index.js
CHANGED
|
@@ -19,10 +19,9 @@ const __ = _i18n.__;
|
|
|
19
19
|
/**
|
|
20
20
|
* Internal dependencies.
|
|
21
21
|
*/
|
|
22
|
-
const Footer =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} = _ref;
|
|
22
|
+
const Footer = ({
|
|
23
|
+
simple
|
|
24
|
+
}) => {
|
|
26
25
|
const {
|
|
27
26
|
components_demo: componentsDemo = false,
|
|
28
27
|
support = false,
|
|
@@ -39,41 +38,41 @@ const Footer = _ref => {
|
|
|
39
38
|
url: 'https://newspack.com/category/release-notes/',
|
|
40
39
|
external: true
|
|
41
40
|
}, {
|
|
42
|
-
label: __('About', 'newspack'),
|
|
41
|
+
label: __('About', 'newspack-plugin'),
|
|
43
42
|
url: 'https://newspack.com/',
|
|
44
43
|
external: true
|
|
45
44
|
}, {
|
|
46
|
-
label: __('Documentation', 'newspack'),
|
|
45
|
+
label: __('Documentation', 'newspack-plugin'),
|
|
47
46
|
url: support,
|
|
48
47
|
external: true
|
|
49
48
|
}];
|
|
50
49
|
if (componentsDemo) {
|
|
51
50
|
footerElements.push({
|
|
52
|
-
label: __('Components Demo', 'newspack'),
|
|
51
|
+
label: __('Components Demo', 'newspack-plugin'),
|
|
53
52
|
url: componentsDemo
|
|
54
53
|
});
|
|
55
54
|
}
|
|
56
55
|
if (setupWizard) {
|
|
57
56
|
footerElements.push({
|
|
58
|
-
label: __('Setup Wizard', 'newspack'),
|
|
57
|
+
label: __('Setup Wizard', 'newspack-plugin'),
|
|
59
58
|
url: setupWizard
|
|
60
59
|
});
|
|
61
60
|
}
|
|
62
61
|
if (resetUrl) {
|
|
63
62
|
footerElements.push({
|
|
64
|
-
label: __('Reset Newspack', 'newspack'),
|
|
63
|
+
label: __('Reset Newspack', 'newspack-plugin'),
|
|
65
64
|
url: resetUrl
|
|
66
65
|
});
|
|
67
66
|
}
|
|
68
67
|
if (removeStarterContent) {
|
|
69
68
|
footerElements.push({
|
|
70
|
-
label: __('Remove Starter Content', 'newspack'),
|
|
69
|
+
label: __('Remove Starter Content', 'newspack-plugin'),
|
|
71
70
|
url: removeStarterContent
|
|
72
71
|
});
|
|
73
72
|
}
|
|
74
73
|
if (supportEmail) {
|
|
75
74
|
footerElements.push({
|
|
76
|
-
label: __('Contact Support', 'newspack'),
|
|
75
|
+
label: __('Contact Support', 'newspack-plugin'),
|
|
77
76
|
url: `mailto:${supportEmail}`
|
|
78
77
|
});
|
|
79
78
|
}
|
|
@@ -82,22 +81,19 @@ const Footer = _ref => {
|
|
|
82
81
|
children: [!simple && (0, _jsxRuntime.jsx)("div", {
|
|
83
82
|
className: "newspack-footer__inner",
|
|
84
83
|
children: (0, _jsxRuntime.jsx)("ul", {
|
|
85
|
-
children: footerElements.map((
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
children:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
})
|
|
99
|
-
}, index);
|
|
100
|
-
})
|
|
84
|
+
children: footerElements.map(({
|
|
85
|
+
url,
|
|
86
|
+
label,
|
|
87
|
+
external
|
|
88
|
+
}, index) => (0, _jsxRuntime.jsx)("li", {
|
|
89
|
+
children: external ? (0, _jsxRuntime.jsx)(_components.ExternalLink, {
|
|
90
|
+
href: url,
|
|
91
|
+
children: label
|
|
92
|
+
}) : (0, _jsxRuntime.jsx)("a", {
|
|
93
|
+
href: url,
|
|
94
|
+
children: label
|
|
95
|
+
})
|
|
96
|
+
}, index))
|
|
101
97
|
})
|
|
102
98
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
103
99
|
className: "newspack-footer__logo",
|
|
@@ -105,5 +101,4 @@ const Footer = _ref => {
|
|
|
105
101
|
})]
|
|
106
102
|
});
|
|
107
103
|
};
|
|
108
|
-
var _default = Footer;
|
|
109
|
-
exports.default = _default;
|
|
104
|
+
var _default = exports.default = Footer;
|