newspack-components 3.0.0-alpha.1 → 3.0.0-alpha.3

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 (245) hide show
  1. package/babel.config.cjs.js +26 -0
  2. package/babel.config.js +26 -0
  3. package/dist/cjs/accordion/index.js +50 -0
  4. package/dist/cjs/accordion/style.scss +31 -0
  5. package/dist/cjs/action-card/index.js +38 -41
  6. package/dist/cjs/action-card/style.scss +9 -9
  7. package/dist/cjs/autocomplete-tokenfield/index.js +19 -18
  8. package/dist/cjs/autocomplete-tokenfield/style.scss +3 -3
  9. package/dist/cjs/autocomplete-with-suggestions/index.js +29 -29
  10. package/dist/cjs/autocomplete-with-suggestions/style.scss +8 -8
  11. package/dist/cjs/button/style.scss +1 -1
  12. package/dist/cjs/button-card/index.js +8 -8
  13. package/dist/cjs/button-card/style.scss +19 -13
  14. package/dist/cjs/card/index.js +3 -3
  15. package/dist/cjs/card/style.scss +1 -1
  16. package/dist/cjs/category-autocomplete/index.js +50 -48
  17. package/dist/cjs/category-autocomplete/style.scss +2 -2
  18. package/dist/cjs/color-picker/index.js +7 -7
  19. package/dist/cjs/color-picker/style.scss +3 -3
  20. package/dist/cjs/custom-select-control/index.js +3 -3
  21. package/dist/cjs/custom-select-control/style.scss +11 -10
  22. package/dist/cjs/date-range-picker/index.js +39 -0
  23. package/dist/cjs/date-range-picker/style.scss +148 -0
  24. package/dist/cjs/footer/index.js +19 -17
  25. package/dist/cjs/footer/style.scss +1 -1
  26. package/dist/cjs/form-token-field/index.js +5 -5
  27. package/dist/cjs/form-token-field/style.scss +1 -1
  28. package/dist/cjs/global-notices/index.js +3 -3
  29. package/dist/cjs/grid/style.scss +9 -9
  30. package/dist/cjs/handoff/index.js +72 -69
  31. package/dist/cjs/handoff-message/index.js +5 -3
  32. package/dist/cjs/hooks/useObjectState.js +1 -1
  33. package/dist/cjs/hooks/useObjectState.test.js +9 -9
  34. package/dist/cjs/image-upload/index.js +113 -108
  35. package/dist/cjs/image-upload/index.test.js +13 -6
  36. package/dist/cjs/image-upload/style.scss +5 -5
  37. package/dist/cjs/index.js +15 -1
  38. package/dist/cjs/info-button/index.js +5 -5
  39. package/dist/cjs/modal/index.js +3 -3
  40. package/dist/cjs/modal/style.scss +5 -5
  41. package/dist/cjs/newspack-icon/index.js +4 -4
  42. package/dist/cjs/newspack-icon/style.scss +1 -1
  43. package/dist/cjs/newspack-logo/index.js +4 -4
  44. package/dist/cjs/newspack-logo/style.scss +1 -1
  45. package/dist/cjs/notice/index.js +11 -8
  46. package/dist/cjs/notice/style.scss +11 -11
  47. package/dist/cjs/patrons-logo/index.js +58 -62
  48. package/dist/cjs/plugin-installer/index.js +139 -137
  49. package/dist/cjs/plugin-installer/style.scss +1 -1
  50. package/dist/cjs/plugin-settings/SettingsSection.js +11 -9
  51. package/dist/cjs/plugin-settings/index.js +151 -144
  52. package/dist/cjs/plugin-settings/style.scss +1 -1
  53. package/dist/cjs/plugin-toggle/index.js +159 -155
  54. package/dist/cjs/plugin-toggle/style.scss +1 -1
  55. package/dist/cjs/popover/index.js +3 -3
  56. package/dist/cjs/popover/style.scss +7 -7
  57. package/dist/cjs/position-control/index.js +24 -22
  58. package/dist/cjs/position-control/style.scss +8 -8
  59. package/dist/cjs/progress-bar/index.js +8 -8
  60. package/dist/cjs/progress-bar/index.test.js +12 -11
  61. package/dist/cjs/progress-bar/style.scss +2 -2
  62. package/dist/cjs/proxied-imports/router.js +2 -1
  63. package/dist/cjs/radio-control/index.js +3 -3
  64. package/dist/cjs/radio-control/style.scss +3 -3
  65. package/dist/cjs/section-header/index.js +8 -8
  66. package/dist/cjs/section-header/style.scss +1 -1
  67. package/dist/cjs/select-control/ButtonGroupControl.js +7 -7
  68. package/dist/cjs/select-control/GroupedSelectControl.js +15 -14
  69. package/dist/cjs/select-control/index.js +6 -6
  70. package/dist/cjs/select-control/style.scss +4 -4
  71. package/dist/cjs/settings/MinMaxSetting.js +12 -11
  72. package/dist/cjs/settings/SettingsCard.js +4 -4
  73. package/dist/cjs/settings/SettingsSection.js +6 -6
  74. package/dist/cjs/settings/index.js +1 -1
  75. package/dist/cjs/settings/style.scss +1 -1
  76. package/dist/cjs/sortable-newsletter-list-control/index.js +25 -24
  77. package/dist/cjs/steps-list/index.js +4 -4
  78. package/dist/cjs/steps-list/style.scss +2 -2
  79. package/dist/cjs/steps-list-item/index.js +5 -5
  80. package/dist/cjs/steps-list-item/style.scss +5 -5
  81. package/dist/cjs/style-card/index.js +20 -17
  82. package/dist/cjs/style-card/style.scss +4 -4
  83. package/dist/cjs/style.scss +1 -1
  84. package/dist/cjs/tabbed-navigation/index.js +7 -7
  85. package/dist/cjs/tabbed-navigation/style.scss +4 -4
  86. package/dist/cjs/utils/index.js +2 -2
  87. package/dist/cjs/waiting/index.js +3 -3
  88. package/dist/cjs/web-preview/index.js +107 -104
  89. package/dist/cjs/web-preview/style.scss +5 -5
  90. package/dist/cjs/with-wizard/index.js +250 -239
  91. package/dist/cjs/with-wizard/style.scss +44 -22
  92. package/dist/cjs/with-wizard-screen/index.js +24 -23
  93. package/dist/cjs/with-wizard-screen/style.scss +7 -7
  94. package/dist/cjs/wizard/components/WizardError.js +10 -9
  95. package/dist/cjs/wizard/index.js +30 -27
  96. package/dist/cjs/wizard/store/index.js +1 -1
  97. package/dist/esm/accordion/index.js +42 -0
  98. package/dist/esm/accordion/style.scss +31 -0
  99. package/dist/esm/action-card/index.js +37 -40
  100. package/dist/esm/action-card/style.scss +9 -9
  101. package/dist/esm/autocomplete-tokenfield/index.js +18 -17
  102. package/dist/esm/autocomplete-tokenfield/style.scss +3 -3
  103. package/dist/esm/autocomplete-with-suggestions/index.js +17 -19
  104. package/dist/esm/autocomplete-with-suggestions/style.scss +8 -8
  105. package/dist/esm/button/style.scss +1 -1
  106. package/dist/esm/button-card/index.js +7 -7
  107. package/dist/esm/button-card/style.scss +19 -13
  108. package/dist/esm/card/index.js +2 -2
  109. package/dist/esm/card/style.scss +1 -1
  110. package/dist/esm/category-autocomplete/index.js +49 -47
  111. package/dist/esm/category-autocomplete/style.scss +2 -2
  112. package/dist/esm/color-picker/index.js +6 -6
  113. package/dist/esm/color-picker/style.scss +3 -3
  114. package/dist/esm/custom-select-control/index.js +2 -2
  115. package/dist/esm/custom-select-control/style.scss +11 -10
  116. package/dist/esm/date-range-picker/index.js +31 -0
  117. package/dist/esm/date-range-picker/style.scss +148 -0
  118. package/dist/esm/footer/index.js +10 -11
  119. package/dist/esm/footer/style.scss +1 -1
  120. package/dist/esm/form-token-field/index.js +4 -4
  121. package/dist/esm/form-token-field/style.scss +1 -1
  122. package/dist/esm/global-notices/index.js +3 -3
  123. package/dist/esm/grid/style.scss +9 -9
  124. package/dist/esm/handoff/index.js +66 -67
  125. package/dist/esm/handoff-message/index.js +5 -3
  126. package/dist/esm/hooks/useObjectState.test.js +8 -8
  127. package/dist/esm/image-upload/index.js +109 -108
  128. package/dist/esm/image-upload/index.test.js +10 -4
  129. package/dist/esm/image-upload/style.scss +5 -5
  130. package/dist/esm/index.js +2 -0
  131. package/dist/esm/info-button/index.js +4 -4
  132. package/dist/esm/modal/index.js +2 -2
  133. package/dist/esm/modal/style.scss +5 -5
  134. package/dist/esm/newspack-icon/index.js +3 -3
  135. package/dist/esm/newspack-icon/style.scss +1 -1
  136. package/dist/esm/newspack-logo/index.js +3 -3
  137. package/dist/esm/newspack-logo/style.scss +1 -1
  138. package/dist/esm/notice/index.js +6 -7
  139. package/dist/esm/notice/style.scss +11 -11
  140. package/dist/esm/patrons-logo/index.js +57 -62
  141. package/dist/esm/plugin-installer/index.js +133 -134
  142. package/dist/esm/plugin-installer/style.scss +1 -1
  143. package/dist/esm/plugin-settings/SettingsSection.js +8 -9
  144. package/dist/esm/plugin-settings/index.js +147 -143
  145. package/dist/esm/plugin-settings/style.scss +1 -1
  146. package/dist/esm/plugin-toggle/index.js +156 -153
  147. package/dist/esm/plugin-toggle/style.scss +1 -1
  148. package/dist/esm/popover/index.js +2 -2
  149. package/dist/esm/popover/style.scss +7 -7
  150. package/dist/esm/position-control/index.js +8 -9
  151. package/dist/esm/position-control/style.scss +8 -8
  152. package/dist/esm/progress-bar/index.js +8 -8
  153. package/dist/esm/progress-bar/index.test.js +9 -10
  154. package/dist/esm/progress-bar/style.scss +2 -2
  155. package/dist/esm/radio-control/index.js +2 -2
  156. package/dist/esm/radio-control/style.scss +3 -3
  157. package/dist/esm/section-header/index.js +7 -7
  158. package/dist/esm/section-header/style.scss +1 -1
  159. package/dist/esm/select-control/ButtonGroupControl.js +6 -6
  160. package/dist/esm/select-control/GroupedSelectControl.js +10 -11
  161. package/dist/esm/select-control/index.js +5 -5
  162. package/dist/esm/select-control/style.scss +4 -4
  163. package/dist/esm/settings/MinMaxSetting.js +9 -10
  164. package/dist/esm/settings/SettingsCard.js +3 -3
  165. package/dist/esm/settings/SettingsSection.js +6 -6
  166. package/dist/esm/settings/style.scss +1 -1
  167. package/dist/esm/sortable-newsletter-list-control/index.js +19 -20
  168. package/dist/esm/steps-list/index.js +3 -3
  169. package/dist/esm/steps-list/style.scss +2 -2
  170. package/dist/esm/steps-list-item/index.js +4 -4
  171. package/dist/esm/steps-list-item/style.scss +5 -5
  172. package/dist/esm/style-card/index.js +11 -12
  173. package/dist/esm/style-card/style.scss +4 -4
  174. package/dist/esm/style.scss +1 -1
  175. package/dist/esm/tabbed-navigation/index.js +6 -6
  176. package/dist/esm/tabbed-navigation/style.scss +4 -4
  177. package/dist/esm/utils/index.js +2 -2
  178. package/dist/esm/waiting/index.js +2 -2
  179. package/dist/esm/web-preview/index.js +103 -103
  180. package/dist/esm/web-preview/style.scss +5 -5
  181. package/dist/esm/with-wizard/index.js +248 -239
  182. package/dist/esm/with-wizard/style.scss +44 -22
  183. package/dist/esm/with-wizard-screen/index.js +19 -20
  184. package/dist/esm/with-wizard-screen/style.scss +7 -7
  185. package/dist/esm/wizard/components/WizardError.js +7 -8
  186. package/dist/esm/wizard/index.js +23 -24
  187. package/package.json +21 -15
  188. package/shared/scss/_mixins.scss +2 -2
  189. package/src/accordion/index.js +35 -0
  190. package/src/accordion/style.scss +31 -0
  191. package/src/action-card/style.scss +9 -9
  192. package/src/autocomplete-tokenfield/style.scss +3 -3
  193. package/src/autocomplete-with-suggestions/index.js +46 -44
  194. package/src/autocomplete-with-suggestions/style.scss +8 -8
  195. package/src/button/style.scss +1 -1
  196. package/src/button-card/style.scss +19 -13
  197. package/src/card/style.scss +1 -1
  198. package/src/category-autocomplete/style.scss +2 -2
  199. package/src/color-picker/style.scss +3 -3
  200. package/src/custom-select-control/style.scss +11 -10
  201. package/src/date-range-picker/index.js +31 -0
  202. package/src/date-range-picker/style.scss +148 -0
  203. package/src/footer/style.scss +1 -1
  204. package/src/form-token-field/style.scss +1 -1
  205. package/src/grid/style.scss +9 -9
  206. package/src/handoff-message/index.js +3 -1
  207. package/src/image-upload/index.js +1 -1
  208. package/src/image-upload/index.test.js +6 -1
  209. package/src/image-upload/style.scss +5 -5
  210. package/src/index.js +2 -0
  211. package/src/modal/style.scss +5 -5
  212. package/src/newspack-icon/style.scss +1 -1
  213. package/src/newspack-logo/style.scss +1 -1
  214. package/src/notice/style.scss +11 -11
  215. package/src/plugin-installer/style.scss +1 -1
  216. package/src/plugin-settings/style.scss +1 -1
  217. package/src/plugin-toggle/index.js +6 -7
  218. package/src/plugin-toggle/style.scss +1 -1
  219. package/src/popover/style.scss +7 -7
  220. package/src/position-control/index.js +62 -63
  221. package/src/position-control/style.scss +8 -8
  222. package/src/progress-bar/style.scss +2 -2
  223. package/src/radio-control/style.scss +3 -3
  224. package/src/section-header/style.scss +1 -1
  225. package/src/select-control/style.scss +4 -4
  226. package/src/settings/style.scss +1 -1
  227. package/src/steps-list/style.scss +2 -2
  228. package/src/steps-list-item/style.scss +5 -5
  229. package/src/style-card/style.scss +4 -4
  230. package/src/style.scss +1 -1
  231. package/src/tabbed-navigation/index.js +1 -1
  232. package/src/tabbed-navigation/style.scss +4 -4
  233. package/src/web-preview/style.scss +5 -5
  234. package/src/with-wizard/style.scss +44 -22
  235. package/src/with-wizard-screen/style.scss +7 -7
  236. package/dist/cjs/button/index.js +0 -56
  237. package/dist/cjs/grid/index.js +0 -37
  238. package/dist/cjs/hooks/index.js +0 -25
  239. package/dist/cjs/hooks/usePrompt.js +0 -49
  240. package/dist/cjs/text-control/index.js +0 -61
  241. package/dist/esm/button/index.js +0 -48
  242. package/dist/esm/grid/index.js +0 -29
  243. package/dist/esm/hooks/index.js +0 -17
  244. package/dist/esm/hooks/usePrompt.js +0 -40
  245. package/dist/esm/text-control/index.js +0 -57
@@ -1,182 +1,97 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
8
  var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
10
9
  var _element = require("@wordpress/element");
11
10
  var _i18n = require("@wordpress/i18n");
12
11
  var _ = require("../");
13
12
  require("./style.scss");
14
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
13
+ var _jsxRuntime = require("react/jsx-runtime");
15
14
  /**
16
15
  * WordPress dependencies.
17
16
  */
17
+
18
18
  /**
19
19
  * Internal dependencies.
20
20
  */
21
- const __ = _i18n.__;
21
+
22
22
  /**
23
23
  * Plugin toggle group component.
24
- */
25
- class PluginToggle extends _element.Component {
26
- constructor(...args) {
27
- super(...args);
28
- (0, _defineProperty2.default)(this, "state", {
29
- pluginInfo: {}
30
- });
31
- (0, _defineProperty2.default)(this, "componentDidMount", () => {
32
- this.retrievePluginInfo();
33
- });
34
- /**
35
- * Retrieve complete data about Newspack plugins.
36
- */
37
- (0, _defineProperty2.default)(this, "retrievePluginInfo", () => {
38
- return new Promise(() => {
39
- (0, _apiFetch.default)({
40
- path: '/newspack/v1/plugins/'
41
- }).then(pluginInfo => this.setState({
42
- pluginInfo
43
- }));
44
- });
45
- });
46
- /**
47
- * Install/activate or remove a plugin.
48
- */
49
- (0, _defineProperty2.default)(this, "managePlugin", (plugin, value) => {
50
- const {
51
- plugins
52
- } = this.props;
53
- const {
24
+ */class PluginToggle extends _element.Component {
25
+ state = {
26
+ pluginInfo: {}
27
+ };
28
+ componentDidMount = () => {
29
+ this.retrievePluginInfo();
30
+ };
31
+
32
+ /**
33
+ * Retrieve complete data about Newspack plugins.
34
+ */
35
+ retrievePluginInfo = () => {
36
+ return new Promise(() => {
37
+ (0, _apiFetch.default)({
38
+ path: '/newspack/v1/plugins/'
39
+ }).then(pluginInfo => this.setState({
54
40
  pluginInfo
55
- } = this.state;
56
- const action = value ? 'configure' : 'deactivate';
57
- const params = {
58
- path: `/newspack/v1/plugins/${plugin}/${action}/`,
59
- method: 'post'
60
- };
61
- this.setState({
62
- pluginInfo: {
63
- ...pluginInfo,
64
- [plugin]: {
65
- ...pluginInfo[plugin],
66
- inFlight: action
67
- }
41
+ }));
42
+ });
43
+ };
44
+
45
+ /**
46
+ * Install/activate or remove a plugin.
47
+ */
48
+ managePlugin = (plugin, value) => {
49
+ const {
50
+ plugins
51
+ } = this.props;
52
+ const {
53
+ pluginInfo
54
+ } = this.state;
55
+ const action = value ? 'configure' : 'deactivate';
56
+ const params = {
57
+ path: `/newspack/v1/plugins/${plugin}/${action}/`,
58
+ method: 'post'
59
+ };
60
+ this.setState({
61
+ pluginInfo: {
62
+ ...pluginInfo,
63
+ [plugin]: {
64
+ ...pluginInfo[plugin],
65
+ inFlight: action
68
66
  }
69
- }, () => {
70
- (0, _apiFetch.default)(params).then(response => {
71
- const {
72
- shouldRefreshAfterUpdate
73
- } = plugins[plugin];
74
- this.setState(({
75
- pluginInfo: currentPluginInfo
76
- }) => ({
77
- pluginInfo: {
78
- ...currentPluginInfo,
79
- [plugin]: response
80
- }
81
- }), () => shouldRefreshAfterUpdate && location.reload());
82
- }).catch(e => {
83
- this.setState({
84
- pluginInfo: {
85
- ...pluginInfo,
86
- [plugin]: {
87
- ...pluginInfo[plugin],
88
- error: e.message || __('There was an error managing this plugin.', 'newspack-plugin')
89
- }
67
+ }
68
+ }, () => {
69
+ (0, _apiFetch.default)(params).then(response => {
70
+ const {
71
+ shouldRefreshAfterUpdate
72
+ } = plugins[plugin];
73
+ this.setState(({
74
+ pluginInfo: currentPluginInfo
75
+ }) => ({
76
+ pluginInfo: {
77
+ ...currentPluginInfo,
78
+ [plugin]: response
79
+ }
80
+ }), () => shouldRefreshAfterUpdate && location.reload());
81
+ }).catch(e => {
82
+ this.setState({
83
+ pluginInfo: {
84
+ ...pluginInfo,
85
+ [plugin]: {
86
+ ...pluginInfo[plugin],
87
+ error: e.message || (0, _i18n.__)('There was an error managing this plugin.', 'newspack-plugin')
90
88
  }
91
- });
89
+ }
92
90
  });
93
91
  });
94
92
  });
95
- /**
96
- * Prepare plugins data for render. Change all keys to camelCase, merge API-fetched data with prop.
97
- */
98
- (0, _defineProperty2.default)(this, "prepareDataForRender", (pluginsFromProps, pluginsFromAPI) => Object.keys(pluginsFromProps).map(pluginSlug => pluginsFromAPI[pluginSlug] ? Object.keys(pluginsFromAPI[pluginSlug]).reduce((accumulator, key) => ({
99
- ...accumulator,
100
- [key.charAt(0).toLowerCase() + key.slice(1)]: pluginsFromAPI[pluginSlug][key]
101
- }), {}) : {}).map(plugin => Object.assign(plugin, pluginsFromProps[plugin.slug])));
102
- /**
103
- * Generate a classname for the ActionCard based on plugin state. Applies 'in-flight' class if an API is underway and 'loading' if the plugin data is not yet available.
104
- */
105
- (0, _defineProperty2.default)(this, "classNameForPlugin", plugin => {
106
- const {
107
- status,
108
- inFlight
109
- } = plugin;
110
- if (inFlight) {
111
- return 'in-flight';
112
- }
113
- if (!status) {
114
- return 'loading';
115
- }
116
- });
117
- /**
118
- * Generate the ActionCard action text for a plugin.
119
- */
120
- (0, _defineProperty2.default)(this, "actionTextForPlugin", plugin => {
121
- const {
122
- actionText,
123
- editPath,
124
- href,
125
- inFlight,
126
- name
127
- } = plugin;
128
- // Show spinner when plugin data is unavailable, or when an API call is in flight.
129
- if ('configure' === inFlight) {
130
- return (0, _jsxRuntime.jsxs)(_element.Fragment, {
131
- children: [__('Installing…', 'newspack-plugin'), " ", (0, _jsxRuntime.jsx)(_.Waiting, {
132
- isRight: true
133
- })]
134
- });
135
- }
136
- if ('deactivate' === inFlight) {
137
- return (0, _jsxRuntime.jsxs)(_element.Fragment, {
138
- children: [__('Deactivating…', 'newspack-plugin'), " ", (0, _jsxRuntime.jsx)(_.Waiting, {
139
- isRight: true
140
- })]
141
- });
142
- }
143
- if (!name) {
144
- return (0, _jsxRuntime.jsxs)(_element.Fragment, {
145
- children: [__('Loading…', 'newspack-plugin'), " ", (0, _jsxRuntime.jsx)(_.Waiting, {
146
- isRight: true
147
- })]
148
- });
149
- }
150
- // No action button at all if the plugin isn't installed and active.
151
- if (!this.isPluginInstalledAndActive(plugin)) {
152
- return null;
153
- }
154
- if (href || editPath) {
155
- return actionText ? actionText : __('Configure', 'newspack-plugin');
156
- }
157
- });
158
- /**
159
- * Get error message for this plugin.
160
- */
161
- (0, _defineProperty2.default)(this, "errorForPlugin", plugin => {
162
- const {
163
- slug
164
- } = plugin;
165
- const {
166
- pluginInfo
167
- } = this.state;
168
- return pluginInfo[slug]?.error || null;
169
- });
170
- /**
171
- * Get installation/activation status for a plugin.
172
- */
173
- (0, _defineProperty2.default)(this, "isPluginInstalledAndActive", plugin => {
174
- const {
175
- status
176
- } = plugin;
177
- return status === 'active';
178
- });
179
- }
93
+ };
94
+
180
95
  /**
181
96
  * Render.
182
97
  */
@@ -198,7 +113,7 @@ class PluginToggle extends _element.Component {
198
113
  const pluginStatus = this.isPluginInstalledAndActive(plugin);
199
114
  const handoff = !href && pluginStatus && editPath ? slug : null;
200
115
  const error = this.errorForPlugin(plugin);
201
- return (0, _jsxRuntime.jsx)(_.ActionCard, {
116
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_.ActionCard, {
202
117
  className: this.classNameForPlugin(plugin),
203
118
  title: name,
204
119
  description: description,
@@ -214,5 +129,94 @@ class PluginToggle extends _element.Component {
214
129
  }, index);
215
130
  });
216
131
  }
132
+
133
+ /**
134
+ * Prepare plugins data for render. Change all keys to camelCase, merge API-fetched data with prop.
135
+ */
136
+ prepareDataForRender = (pluginsFromProps, pluginsFromAPI) => Object.keys(pluginsFromProps).map(pluginSlug => pluginsFromAPI[pluginSlug] ? Object.keys(pluginsFromAPI[pluginSlug]).reduce((accumulator, key) => ({
137
+ ...accumulator,
138
+ [key.charAt(0).toLowerCase() + key.slice(1)]: pluginsFromAPI[pluginSlug][key]
139
+ }), {}) : {}).map(plugin => Object.assign(plugin, pluginsFromProps[plugin.slug]));
140
+
141
+ /**
142
+ * Generate a classname for the ActionCard based on plugin state. Applies 'in-flight' class if an API is underway and 'loading' if the plugin data is not yet available.
143
+ */
144
+ classNameForPlugin = plugin => {
145
+ const {
146
+ status,
147
+ inFlight
148
+ } = plugin;
149
+ if (inFlight) {
150
+ return 'in-flight';
151
+ }
152
+ if (!status) {
153
+ return 'loading';
154
+ }
155
+ };
156
+
157
+ /**
158
+ * Generate the ActionCard action text for a plugin.
159
+ */
160
+ actionTextForPlugin = plugin => {
161
+ const {
162
+ actionText,
163
+ editPath,
164
+ href,
165
+ inFlight,
166
+ name
167
+ } = plugin;
168
+ // Show spinner when plugin data is unavailable, or when an API call is in flight.
169
+ if ('configure' === inFlight) {
170
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_element.Fragment, {
171
+ children: [(0, _i18n.__)('Installing…', 'newspack-plugin'), " ", /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Waiting, {
172
+ isRight: true
173
+ })]
174
+ });
175
+ }
176
+ if ('deactivate' === inFlight) {
177
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_element.Fragment, {
178
+ children: [(0, _i18n.__)('Deactivating…', 'newspack-plugin'), " ", /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Waiting, {
179
+ isRight: true
180
+ })]
181
+ });
182
+ }
183
+ if (!name) {
184
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_element.Fragment, {
185
+ children: [(0, _i18n.__)('Loading…', 'newspack-plugin'), " ", /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Waiting, {
186
+ isRight: true
187
+ })]
188
+ });
189
+ }
190
+ // No action button at all if the plugin isn't installed and active.
191
+ if (!this.isPluginInstalledAndActive(plugin)) {
192
+ return null;
193
+ }
194
+ if (href || editPath) {
195
+ return actionText ? actionText : (0, _i18n.__)('Configure', 'newspack-plugin');
196
+ }
197
+ };
198
+
199
+ /**
200
+ * Get error message for this plugin.
201
+ */
202
+ errorForPlugin = plugin => {
203
+ const {
204
+ slug
205
+ } = plugin;
206
+ const {
207
+ pluginInfo
208
+ } = this.state;
209
+ return pluginInfo[slug]?.error || null;
210
+ };
211
+
212
+ /**
213
+ * Get installation/activation status for a plugin.
214
+ */
215
+ isPluginInstalledAndActive = plugin => {
216
+ const {
217
+ status
218
+ } = plugin;
219
+ return status === 'active';
220
+ };
217
221
  }
218
222
  var _default = exports.default = PluginToggle;
@@ -2,7 +2,7 @@
2
2
  * Plugin Toggle
3
3
  */
4
4
 
5
- @use '~@wordpress/base-styles/colors' as wp-colors;
5
+ @use "~@wordpress/base-styles/colors" as wp-colors;
6
6
 
7
7
  .newspack-action-card {
8
8
  &.in-flight,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
@@ -9,7 +9,7 @@ var _components = require("@wordpress/components");
9
9
  var _element = require("@wordpress/element");
10
10
  require("./style.scss");
11
11
  var _classnames = _interopRequireDefault(require("classnames"));
12
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
13
  /**
14
14
  * WordPress dependencies
15
15
  */
@@ -35,7 +35,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
35
35
  ...otherProps
36
36
  } = this.props;
37
37
  const classes = (0, _classnames.default)('newspack-popover', padding && 'newspack-popover__padding-' + padding, className);
38
- return (0, _jsxRuntime.jsx)(_components.Popover, {
38
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Popover, {
39
39
  className: classes,
40
40
  ...otherProps
41
41
  });
@@ -2,8 +2,8 @@
2
2
  * Popover
3
3
  */
4
4
 
5
- @use '../../../shared/scss/colors';
6
- @use '~@wordpress/base-styles/colors' as wp-colors;
5
+ @use "../../../shared/scss/colors";
6
+ @use "~@wordpress/base-styles/colors" as wp-colors;
7
7
 
8
8
  .newspack-popover {
9
9
  .components-popover__content {
@@ -23,7 +23,7 @@
23
23
  }
24
24
  }
25
25
 
26
- &:focus:not( :disabled ) {
26
+ &:focus:not(:disabled) {
27
27
  box-shadow: inset 0 0 0 2px colors.$primary-500;
28
28
  position: relative;
29
29
  z-index: 1;
@@ -34,14 +34,14 @@
34
34
  padding: 6px 8px;
35
35
  text-decoration: none;
36
36
 
37
- &:not( .is-destructive ) {
37
+ &:not(.is-destructive) {
38
38
  color: wp-colors.$gray-700;
39
39
 
40
40
  &:active,
41
41
  &:active:enabled,
42
42
  &:focus,
43
43
  &:focus:enabled &:hover,
44
- &:not( :disabled, [aria-disabled='true'], .is-default ):hover {
44
+ &:not(:disabled, [aria-disabled="true"], .is-default):hover {
45
45
  color: colors.$primary-500;
46
46
  }
47
47
  }
@@ -52,7 +52,7 @@
52
52
  }
53
53
  }
54
54
 
55
- &.is-destructive:not( :focus ) {
55
+ &.is-destructive:not(:focus) {
56
56
  box-shadow: none !important;
57
57
  }
58
58
 
@@ -131,7 +131,7 @@
131
131
  }
132
132
  }
133
133
 
134
- &:not( .is-without-arrow )::before {
134
+ &:not(.is-without-arrow)::before {
135
135
  border-color: wp-colors.$gray-300;
136
136
  }
137
137
 
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
@@ -9,17 +9,19 @@ var _i18n = require("@wordpress/i18n");
9
9
  var _components = require("@wordpress/components");
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
  require("./style.scss");
12
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
13
  /**
14
14
  * WordPress dependencies
15
15
  */
16
- const __ = _i18n.__;
16
+
17
17
  /**
18
18
  * External dependencies
19
19
  */
20
+
20
21
  /**
21
22
  * Internal dependencies
22
23
  */
24
+
23
25
  function PositionControl({
24
26
  allowedPositions,
25
27
  value,
@@ -35,64 +37,64 @@ function PositionControl({
35
37
  const options = size === 'full-width' ? [{
36
38
  value: 'top',
37
39
  /* translators: Overlay Position */
38
- label: __('Top', 'newspack-plugin')
40
+ label: (0, _i18n.__)('Top', 'newspack-plugin')
39
41
  }, {
40
42
  value: 'center',
41
43
  /* translators: Overlay Position */
42
- label: __('Center', 'newspack-plugin')
44
+ label: (0, _i18n.__)('Center', 'newspack-plugin')
43
45
  }, {
44
46
  value: 'bottom',
45
47
  /* translators: Overlay Position */
46
- label: __('Bottom', 'newspack-plugin')
48
+ label: (0, _i18n.__)('Bottom', 'newspack-plugin')
47
49
  }] : [{
48
50
  value: 'top_left',
49
51
  /* translators: Overlay Position */
50
- label: __('Top Left', 'newspack-plugin')
52
+ label: (0, _i18n.__)('Top Left', 'newspack-plugin')
51
53
  }, {
52
54
  value: 'top',
53
55
  /* translators: Overlay Position */
54
- label: __('Top Center', 'newspack-plugin')
56
+ label: (0, _i18n.__)('Top Center', 'newspack-plugin')
55
57
  }, {
56
58
  value: 'top_right',
57
59
  /* translators: Overlay Position */
58
- label: __('Top Right', 'newspack-plugin')
60
+ label: (0, _i18n.__)('Top Right', 'newspack-plugin')
59
61
  }, {
60
62
  value: 'center_left',
61
63
  /* translators: Overlay Position */
62
- label: __('Center Left', 'newspack-plugin')
64
+ label: (0, _i18n.__)('Center Left', 'newspack-plugin')
63
65
  }, {
64
66
  value: 'center',
65
67
  /* translators: Overlay Position */
66
- label: __('Center', 'newspack-plugin')
68
+ label: (0, _i18n.__)('Center', 'newspack-plugin')
67
69
  }, {
68
70
  value: 'center_right',
69
71
  /* translators: Overlay Position */
70
- label: __('Center Right', 'newspack-plugin')
72
+ label: (0, _i18n.__)('Center Right', 'newspack-plugin')
71
73
  }, {
72
74
  value: 'bottom_left',
73
75
  /* translators: Overlay Position */
74
- label: __('Bottom Left', 'newspack-plugin')
76
+ label: (0, _i18n.__)('Bottom Left', 'newspack-plugin')
75
77
  }, {
76
78
  value: 'bottom',
77
79
  /* translators: Overlay Position */
78
- label: __('Bottom Center', 'newspack-plugin')
80
+ label: (0, _i18n.__)('Bottom Center', 'newspack-plugin')
79
81
  }, {
80
82
  value: 'bottom_right',
81
83
  /* translators: Overlay Position */
82
- label: __('Bottom Right', 'newspack-plugin')
84
+ label: (0, _i18n.__)('Bottom Right', 'newspack-plugin')
83
85
  }];
84
- return (0, _jsxRuntime.jsxs)("div", {
86
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
85
87
  className: (0, _classnames.default)('newspack-position-placement-control', 'size-' + size),
86
- children: [(0, _jsxRuntime.jsx)("p", {
88
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
87
89
  className: "components-base-control__label",
88
90
  children: label
89
- }), (0, _jsxRuntime.jsx)(_components.ButtonGroup, {
90
- "aria-label": __('Select Position', 'newspack-plugin'),
91
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ButtonGroup, {
92
+ "aria-label": (0, _i18n.__)('Select Position', 'newspack-plugin'),
91
93
  ...props,
92
94
  children: options.map((option, index) => {
93
- return (0, _jsxRuntime.jsx)("div", {
95
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
94
96
  className: option.value === value ? 'is-selected' : null,
95
- children: (0, _jsxRuntime.jsx)(_components.Button, {
97
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
96
98
  isSmall: true,
97
99
  title: option.label,
98
100
  "aria-label": option.label,
@@ -104,7 +106,7 @@ function PositionControl({
104
106
  })
105
107
  }, `newspack-position-placement-item-${index}`);
106
108
  })
107
- }), (0, _jsxRuntime.jsx)("p", {
109
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
108
110
  className: "components-base-control__help",
109
111
  children: help
110
112
  })]
@@ -1,4 +1,4 @@
1
- @use '~@wordpress/base-styles/colors' as wp-colors;
1
+ @use "~@wordpress/base-styles/colors" as wp-colors;
2
2
 
3
3
  .newspack-position-placement-control {
4
4
  margin-bottom: 1em;
@@ -10,8 +10,8 @@
10
10
 
11
11
  .components-button-group {
12
12
  display: grid;
13
- grid-template-columns: repeat( 3, 1fr );
14
- grid-template-rows: repeat( 3, 1fr );
13
+ grid-template-columns: repeat(3, 1fr);
14
+ grid-template-rows: repeat(3, 1fr);
15
15
 
16
16
  div {
17
17
  padding: 1px;
@@ -24,19 +24,19 @@
24
24
  width: 100%;
25
25
  }
26
26
 
27
- div:nth-of-type( 1 ) .components-button {
27
+ div:nth-of-type(1) .components-button {
28
28
  border-radius: 4px 0 0 !important;
29
29
  }
30
30
 
31
- div:nth-of-type( 3 ) .components-button {
31
+ div:nth-of-type(3) .components-button {
32
32
  border-radius: 0 4px 0 0 !important;
33
33
  }
34
34
 
35
- div:nth-last-of-type( 1 ) .components-button {
35
+ div:nth-last-of-type(1) .components-button {
36
36
  border-radius: 0 0 4px !important;
37
37
  }
38
38
 
39
- div:nth-last-of-type( 3 ) .components-button {
39
+ div:nth-last-of-type(3) .components-button {
40
40
  border-radius: 0 0 0 4px !important;
41
41
  }
42
42
  }
@@ -48,7 +48,7 @@
48
48
  border-radius: 4px 4px 0 0 !important;
49
49
  }
50
50
 
51
- div:nth-of-type( 2 ) .components-button {
51
+ div:nth-of-type(2) .components-button {
52
52
  border-radius: 0 !important;
53
53
  }
54
54
 
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _element = require("@wordpress/element");
8
8
  require("./style.scss");
9
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
10
  /**
11
11
  * Progress Bar
12
12
  */
@@ -49,21 +49,21 @@ class ProgressBar extends _element.Component {
49
49
  const barStyle = {
50
50
  width: this.getCompletionPercentage(cleanCompleted, cleanTotal) + '%'
51
51
  };
52
- return (0, _jsxRuntime.jsxs)("div", {
52
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
53
53
  className: "newspack-progress-bar",
54
- children: [(label || displayFraction) && (0, _jsxRuntime.jsxs)("div", {
54
+ children: [(label || displayFraction) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
55
55
  className: "newspack-progress-bar__headings",
56
- children: [label && (0, _jsxRuntime.jsx)("h2", {
56
+ children: [label && /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
57
57
  children: label
58
- }), displayFraction && (0, _jsxRuntime.jsx)("p", {
58
+ }), displayFraction && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
59
59
  className: "is-dark",
60
- children: (0, _jsxRuntime.jsxs)("strong", {
60
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("strong", {
61
61
  children: [cleanCompleted, "/", cleanTotal]
62
62
  })
63
63
  })]
64
- }), (0, _jsxRuntime.jsx)("div", {
64
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
65
65
  className: "newspack-progress-bar__container",
66
- children: (0, _jsxRuntime.jsx)("div", {
66
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
67
67
  className: "newspack-progress-bar__bar",
68
68
  style: barStyle,
69
69
  "data-testid": "progress-bar-indicator"