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.
Files changed (197) hide show
  1. package/dist/cjs/action-card/index.js +3 -4
  2. package/dist/cjs/autocomplete-tokenfield/index.js +52 -15
  3. package/dist/cjs/autocomplete-tokenfield/style.scss +11 -5
  4. package/dist/cjs/autocomplete-with-suggestions/index.js +45 -57
  5. package/dist/cjs/autocomplete-with-suggestions/style.scss +1 -9
  6. package/dist/cjs/button/index.js +8 -9
  7. package/dist/cjs/button-card/index.js +1 -2
  8. package/dist/cjs/card/index.js +1 -2
  9. package/dist/cjs/category-autocomplete/index.js +4 -8
  10. package/dist/cjs/color-picker/index.js +7 -9
  11. package/dist/cjs/consts.js +2 -7
  12. package/dist/cjs/custom-select-control/index.js +1 -2
  13. package/dist/cjs/footer/index.js +24 -29
  14. package/dist/cjs/form-token-field/index.js +1 -2
  15. package/dist/cjs/global-notices/index.js +1 -2
  16. package/dist/cjs/grid/index.js +14 -31
  17. package/dist/cjs/handoff/index.js +7 -8
  18. package/dist/cjs/hooks/index.js +2 -3
  19. package/dist/cjs/hooks/useObjectState.js +1 -2
  20. package/dist/cjs/hooks/useOnClickOutside.js +1 -2
  21. package/dist/cjs/hooks/usePrompt.js +1 -4
  22. package/dist/cjs/image-upload/index.js +5 -6
  23. package/dist/cjs/index.js +0 -14
  24. package/dist/cjs/info-button/index.js +1 -2
  25. package/dist/cjs/modal/index.js +1 -2
  26. package/dist/cjs/newspack-icon/index.js +1 -2
  27. package/dist/cjs/newspack-logo/index.js +1 -2
  28. package/dist/cjs/notice/index.js +2 -3
  29. package/dist/cjs/patrons-logo/index.js +4 -5
  30. package/dist/cjs/plugin-installer/index.js +9 -13
  31. package/dist/cjs/plugin-settings/SettingsSection.js +2 -4
  32. package/dist/cjs/plugin-settings/index.js +2 -3
  33. package/dist/cjs/plugin-toggle/index.js +16 -20
  34. package/dist/cjs/popover/index.js +1 -2
  35. package/dist/cjs/position-control/index.js +22 -23
  36. package/dist/cjs/progress-bar/index.js +1 -2
  37. package/dist/cjs/progress-bar/index.test.js +4 -5
  38. package/dist/cjs/proxied-imports/router.js +1 -2
  39. package/dist/cjs/radio-control/index.js +1 -2
  40. package/dist/cjs/section-header/index.js +13 -14
  41. package/dist/cjs/section-header/style.scss +4 -0
  42. package/dist/cjs/select-control/ButtonGroupControl.js +10 -12
  43. package/dist/cjs/select-control/GroupedSelectControl.js +21 -25
  44. package/dist/cjs/select-control/index.js +1 -2
  45. package/dist/cjs/settings/MinMaxSetting.js +17 -15
  46. package/dist/cjs/settings/SettingsCard.js +10 -12
  47. package/dist/cjs/settings/SettingsSection.js +20 -24
  48. package/dist/cjs/settings/index.js +2 -3
  49. package/dist/cjs/settings/style.scss +14 -1
  50. package/dist/cjs/sortable-newsletter-list-control/index.js +134 -0
  51. package/dist/cjs/sortable-newsletter-list-control/style.scss +45 -0
  52. package/dist/cjs/steps-list/index.js +1 -2
  53. package/dist/cjs/steps-list-item/index.js +1 -2
  54. package/dist/cjs/style-card/index.js +6 -7
  55. package/dist/cjs/style.scss +13 -1
  56. package/dist/cjs/tabbed-navigation/index.js +11 -14
  57. package/dist/cjs/text-control/index.js +32 -42
  58. package/dist/cjs/utils/index.js +15 -19
  59. package/dist/cjs/waiting/index.js +1 -2
  60. package/dist/cjs/web-preview/index.js +7 -8
  61. package/dist/cjs/with-wizard/index.js +6 -7
  62. package/dist/cjs/with-wizard-screen/index.js +20 -24
  63. package/dist/cjs/wizard/components/WizardError.js +7 -9
  64. package/dist/cjs/wizard/index.js +16 -21
  65. package/dist/cjs/wizard/store/index.js +36 -37
  66. package/dist/cjs/wizard/store/utils.js +1 -4
  67. package/dist/esm/action-card/index.js +3 -4
  68. package/dist/esm/autocomplete-tokenfield/index.js +52 -15
  69. package/dist/esm/autocomplete-tokenfield/style.scss +11 -5
  70. package/dist/esm/autocomplete-with-suggestions/index.js +46 -59
  71. package/dist/esm/autocomplete-with-suggestions/style.scss +1 -9
  72. package/dist/esm/button/index.js +7 -7
  73. package/dist/esm/button-card/index.js +1 -2
  74. package/dist/esm/category-autocomplete/index.js +4 -8
  75. package/dist/esm/color-picker/index.js +7 -9
  76. package/dist/esm/consts.js +0 -2
  77. package/dist/esm/footer/index.js +24 -29
  78. package/dist/esm/form-token-field/index.js +1 -2
  79. package/dist/esm/grid/index.js +13 -29
  80. package/dist/esm/handoff/index.js +7 -8
  81. package/dist/esm/hooks/useObjectState.js +1 -2
  82. package/dist/esm/hooks/useObjectState.test.js +1 -2
  83. package/dist/esm/hooks/usePrompt.js +1 -4
  84. package/dist/esm/image-upload/index.js +5 -7
  85. package/dist/esm/index.js +0 -2
  86. package/dist/esm/notice/index.js +2 -3
  87. package/dist/esm/patrons-logo/index.js +4 -5
  88. package/dist/esm/plugin-installer/index.js +9 -14
  89. package/dist/esm/plugin-settings/SettingsSection.js +2 -4
  90. package/dist/esm/plugin-settings/index.js +2 -3
  91. package/dist/esm/plugin-toggle/index.js +16 -20
  92. package/dist/esm/position-control/index.js +23 -25
  93. package/dist/esm/progress-bar/index.js +1 -2
  94. package/dist/esm/progress-bar/index.test.js +4 -5
  95. package/dist/esm/section-header/index.js +13 -14
  96. package/dist/esm/section-header/style.scss +4 -0
  97. package/dist/esm/select-control/ButtonGroupControl.js +9 -10
  98. package/dist/esm/select-control/GroupedSelectControl.js +22 -27
  99. package/dist/esm/settings/MinMaxSetting.js +17 -16
  100. package/dist/esm/settings/SettingsCard.js +9 -10
  101. package/dist/esm/settings/SettingsSection.js +20 -24
  102. package/dist/esm/settings/style.scss +14 -1
  103. package/dist/esm/sortable-newsletter-list-control/index.js +128 -0
  104. package/dist/esm/sortable-newsletter-list-control/style.scss +45 -0
  105. package/dist/esm/steps-list-item/index.js +1 -2
  106. package/dist/esm/style-card/index.js +6 -7
  107. package/dist/esm/style.scss +13 -1
  108. package/dist/esm/tabbed-navigation/index.js +11 -14
  109. package/dist/esm/text-control/index.js +32 -41
  110. package/dist/esm/utils/index.js +13 -16
  111. package/dist/esm/web-preview/index.js +7 -8
  112. package/dist/esm/with-wizard/index.js +7 -9
  113. package/dist/esm/with-wizard-screen/index.js +21 -27
  114. package/dist/esm/wizard/components/WizardError.js +7 -9
  115. package/dist/esm/wizard/index.js +16 -22
  116. package/dist/esm/wizard/store/index.js +35 -35
  117. package/dist/esm/wizard/store/utils.js +1 -4
  118. package/package.json +7 -8
  119. package/shared/js/button-props.js +3 -1
  120. package/shared/scss/_colors.scss +15 -0
  121. package/shared/scss/_mixins.scss +12 -0
  122. package/src/autocomplete-tokenfield/index.js +48 -15
  123. package/src/autocomplete-tokenfield/style.scss +11 -5
  124. package/src/autocomplete-with-suggestions/index.js +17 -22
  125. package/src/autocomplete-with-suggestions/style.scss +1 -9
  126. package/src/button/{index.js → index.tsx} +12 -5
  127. package/src/consts.js +0 -2
  128. package/src/footer/index.js +7 -7
  129. package/src/grid/index.tsx +34 -0
  130. package/src/handoff/index.js +7 -6
  131. package/src/hooks/{index.js → index.ts} +1 -1
  132. package/src/hooks/{usePrompt.js → usePrompt.ts} +4 -8
  133. package/src/image-upload/index.js +4 -4
  134. package/src/index.js +0 -2
  135. package/src/notice/index.js +1 -1
  136. package/src/patrons-logo/index.js +4 -1
  137. package/src/plugin-installer/index.js +7 -7
  138. package/src/plugin-settings/index.js +1 -1
  139. package/src/plugin-toggle/index.js +7 -5
  140. package/src/position-control/index.js +13 -13
  141. package/src/section-header/index.js +3 -3
  142. package/src/section-header/style.scss +4 -0
  143. package/src/select-control/GroupedSelectControl.js +1 -1
  144. package/src/settings/MinMaxSetting.js +8 -6
  145. package/src/settings/style.scss +14 -1
  146. package/src/sortable-newsletter-list-control/index.js +137 -0
  147. package/src/sortable-newsletter-list-control/style.scss +45 -0
  148. package/src/style-card/index.js +11 -5
  149. package/src/style.scss +13 -1
  150. package/src/tabbed-navigation/index.js +1 -1
  151. package/src/text-control/index.tsx +65 -0
  152. package/src/web-preview/index.js +6 -6
  153. package/src/with-wizard/index.js +4 -4
  154. package/src/with-wizard-screen/index.js +1 -1
  155. package/src/wizard/components/WizardError.js +1 -1
  156. package/src/wizard/index.js +3 -3
  157. package/src/wizard/store/index.js +9 -2
  158. package/dist/cjs/accordion/index.js +0 -46
  159. package/dist/cjs/accordion/style.scss +0 -27
  160. package/dist/cjs/button-group/index.js +0 -57
  161. package/dist/cjs/button-group/style.scss +0 -73
  162. package/dist/cjs/checkbox-control/index.js +0 -63
  163. package/dist/cjs/checkbox-control/style.scss +0 -78
  164. package/dist/cjs/date-range-picker/index.js +0 -41
  165. package/dist/cjs/date-range-picker/style.scss +0 -148
  166. package/dist/cjs/preview-box/index.js +0 -36
  167. package/dist/cjs/preview-box/style.scss +0 -18
  168. package/dist/cjs/textarea-control/index.js +0 -54
  169. package/dist/cjs/textarea-control/style.scss +0 -76
  170. package/dist/cjs/toggle-control/index.js +0 -58
  171. package/dist/cjs/toggle-control/style.scss +0 -74
  172. package/dist/cjs/toggle-group/index.js +0 -71
  173. package/dist/cjs/toggle-group/style.scss +0 -28
  174. package/dist/cjs/wizard/style.scss +0 -148
  175. package/dist/esm/accordion/index.js +0 -38
  176. package/dist/esm/accordion/style.scss +0 -27
  177. package/dist/esm/button-group/index.js +0 -43
  178. package/dist/esm/button-group/style.scss +0 -73
  179. package/dist/esm/checkbox-control/index.js +0 -49
  180. package/dist/esm/checkbox-control/style.scss +0 -78
  181. package/dist/esm/date-range-picker/index.js +0 -32
  182. package/dist/esm/date-range-picker/style.scss +0 -148
  183. package/dist/esm/preview-box/index.js +0 -30
  184. package/dist/esm/preview-box/style.scss +0 -18
  185. package/dist/esm/textarea-control/index.js +0 -40
  186. package/dist/esm/textarea-control/style.scss +0 -76
  187. package/dist/esm/toggle-control/index.js +0 -44
  188. package/dist/esm/toggle-control/style.scss +0 -74
  189. package/dist/esm/toggle-group/index.js +0 -58
  190. package/dist/esm/toggle-group/style.scss +0 -28
  191. package/dist/esm/wizard/style.scss +0 -148
  192. package/src/accordion/index.js +0 -32
  193. package/src/accordion/style.scss +0 -27
  194. package/src/date-range-picker/index.js +0 -31
  195. package/src/date-range-picker/style.scss +0 -148
  196. package/src/grid/index.js +0 -44
  197. 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(...arguments);
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: key,
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
- currentValidValues[suggestion.value] = suggestion.label;
186
+ validValues[suggestion.value] = suggestion.label;
158
187
  });
159
188
  this.setState({
160
189
  suggestions: currentSuggestions,
161
- validValues: currentValidValues,
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.jsx)(_components.FormTokenField, {
215
- value: this.getTokens(),
216
- suggestions: suggestions.map(suggestion => suggestion.label),
217
- onChange: tokens => this.handleOnChange(tokens),
218
- onInputChange: input => this.debouncedUpdateSuggestions(input),
219
- label: label,
220
- maxLength: maxLength
221
- }), loading && (0, _jsxRuntime.jsx)(_components.Spinner, {}), help && (0, _jsxRuntime.jsx)("p", {
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: 8px;
9
+ margin: 0;
12
10
  position: absolute;
13
- right: 0;
14
- top: calc( 1.4em + 8px );
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 = _ref => {
26
- let {
27
- fetchSavedPosts = false,
28
- // If passed, will use this function to fetch saved data.
29
- fetchSuggestions = false,
30
- // If passed, will use this function to fetch suggestions data.
31
- help = __('Begin typing search term, click autocomplete result to select.', 'newspack'),
32
- hideHelp = false,
33
- // If true, all help text will be hidden.
34
- label = __('Search', 'newspack'),
35
- maxItemsToSuggest = 0,
36
- // If passed, will be used to determine "load more" state. Necessary if you want "load more" functionality when using a custom `fetchSuggestions` function.
37
- multiSelect = false,
38
- // If true, component can select multiple values at once.
39
- onChange = false,
40
- // Function to call when selections change.
41
- onPostTypeChange = false,
42
- // Funciton to call when the post type selector is changed.
43
- postTypes = [{
44
- slug: 'post',
45
- label: 'Post'
46
- }],
47
- // If passed, will render a selector to change the post type queried for suggestions.
48
- postTypeLabel = __('item', 'newspack'),
49
- // String to describe the data being shown.
50
- postTypeLabelPlural = __('items', 'newspack'),
51
- // Plural string to describe the data being shown.
52
- selectedItems = [],
53
- // Array of saved items.
54
- selectedPost = 0,
55
- // Legacy prop when single-select was the only option.
56
- suggestionsToFetch = 10 // Number of suggestions to fetch per query.
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 function () {
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 function () {
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-x: visible;
123
- overflow-y: auto;
115
+ overflow: visible auto;
124
116
  padding: 8px 8px 0;
125
117
 
126
118
  .components-button {
@@ -25,12 +25,11 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
25
25
  const {
26
26
  useHistory
27
27
  } = _router.default;
28
- const Button = _ref => {
29
- let {
30
- href,
31
- onClick,
32
- ...otherProps
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;
@@ -69,5 +69,4 @@ class ButtonCard extends _element.Component {
69
69
  });
70
70
  }
71
71
  }
72
- var _default = ButtonCard;
73
- exports.default = _default;
72
+ var _default = exports.default = ButtonCard;
@@ -48,5 +48,4 @@ class Card extends _element.Component {
48
48
  });
49
49
  }
50
50
  }
51
- var _default = Card;
52
- exports.default = _default;
51
+ var _default = exports.default = Card;
@@ -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, _ref => {
81
- let {
82
- id
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 = _ref => {
34
- let {
35
- label,
36
- color = '#fff',
37
- onChange,
38
- className
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;
@@ -3,10 +3,5 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.NEWSPACK_SUPPORT_URL = exports.NEWSPACK_SITE_URL = exports.HANDOFF_KEY = void 0;
7
- const NEWSPACK_SITE_URL = 'https://newspack.com';
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';
@@ -42,5 +42,4 @@ class CustomSelectControl extends _element.Component {
42
42
  });
43
43
  }
44
44
  }
45
- var _default = CustomSelectControl;
46
- exports.default = _default;
45
+ var _default = exports.default = CustomSelectControl;
@@ -19,10 +19,9 @@ const __ = _i18n.__;
19
19
  /**
20
20
  * Internal dependencies.
21
21
  */
22
- const Footer = _ref => {
23
- let {
24
- simple
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((_ref2, index) => {
86
- let {
87
- url,
88
- label,
89
- external
90
- } = _ref2;
91
- return (0, _jsxRuntime.jsx)("li", {
92
- children: external ? (0, _jsxRuntime.jsx)(_components.ExternalLink, {
93
- href: url,
94
- children: label
95
- }) : (0, _jsxRuntime.jsx)("a", {
96
- href: url,
97
- children: label
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;
@@ -54,5 +54,4 @@ class FormTokenField extends _element.Component {
54
54
  });
55
55
  }
56
56
  }
57
- var _default = FormTokenField;
58
- exports.default = _default;
57
+ var _default = exports.default = FormTokenField;
@@ -34,5 +34,4 @@ const GlobalNotices = () => {
34
34
  }, i);
35
35
  });
36
36
  };
37
- var _default = GlobalNotices;
38
- exports.default = _default;
37
+ var _default = exports.default = GlobalNotices;