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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/babel.config.js +25 -0
  2. package/copy-styles.js +2 -10
  3. package/dist/accordion/index.js +50 -0
  4. package/dist/accordion/style.scss +31 -0
  5. package/dist/{cjs/action-card → action-card}/index.js +38 -41
  6. package/dist/{cjs/action-card → action-card}/style.scss +9 -9
  7. package/dist/{cjs/autocomplete-tokenfield → autocomplete-tokenfield}/index.js +19 -18
  8. package/dist/{esm/autocomplete-tokenfield → autocomplete-tokenfield}/style.scss +3 -3
  9. package/dist/{cjs/autocomplete-with-suggestions → autocomplete-with-suggestions}/index.js +29 -29
  10. package/dist/{cjs/autocomplete-with-suggestions → autocomplete-with-suggestions}/style.scss +8 -8
  11. package/dist/button/index.js +51 -0
  12. package/dist/button/index.tsx +48 -0
  13. package/dist/{cjs/button → button}/style.scss +1 -1
  14. package/dist/{cjs/button-card → button-card}/index.js +8 -8
  15. package/dist/{cjs/button-card → button-card}/style.scss +19 -13
  16. package/dist/{cjs/card → card}/index.js +3 -3
  17. package/dist/{esm/card → card}/style.scss +1 -1
  18. package/dist/{cjs/category-autocomplete → category-autocomplete}/index.js +50 -48
  19. package/dist/{cjs/category-autocomplete → category-autocomplete}/style.scss +2 -2
  20. package/dist/{cjs/color-picker → color-picker}/index.js +7 -7
  21. package/dist/{cjs/color-picker → color-picker}/style.scss +3 -3
  22. package/dist/{cjs/custom-select-control → custom-select-control}/index.js +3 -3
  23. package/dist/{esm/custom-select-control → custom-select-control}/style.scss +11 -10
  24. package/dist/date-range-picker/index.js +39 -0
  25. package/dist/date-range-picker/style.scss +148 -0
  26. package/dist/{cjs/footer → footer}/index.js +19 -17
  27. package/dist/{cjs/footer → footer}/style.scss +1 -1
  28. package/dist/{cjs/form-token-field → form-token-field}/index.js +5 -5
  29. package/dist/{esm/form-token-field → form-token-field}/style.scss +1 -1
  30. package/dist/{cjs/global-notices → global-notices}/index.js +3 -3
  31. package/dist/grid/index.js +44 -0
  32. package/dist/grid/index.tsx +34 -0
  33. package/dist/{esm/grid → grid}/style.scss +9 -9
  34. package/dist/{cjs/handoff → handoff}/index.js +72 -69
  35. package/dist/{cjs/handoff-message → handoff-message}/index.js +5 -3
  36. package/dist/hooks/index.js +29 -0
  37. package/dist/hooks/index.ts +15 -0
  38. package/dist/{cjs/hooks → hooks}/useObjectState.js +1 -1
  39. package/dist/{cjs/hooks → hooks}/useObjectState.test.js +9 -9
  40. package/dist/hooks/usePrompt.js +47 -0
  41. package/dist/hooks/usePrompt.ts +46 -0
  42. package/dist/image-upload/index.js +148 -0
  43. package/dist/{cjs/image-upload → image-upload}/index.test.js +13 -6
  44. package/dist/{cjs/image-upload → image-upload}/style.scss +5 -5
  45. package/dist/{cjs/index.js → index.js} +15 -1
  46. package/dist/{cjs/info-button → info-button}/index.js +5 -5
  47. package/dist/{cjs/modal → modal}/index.js +3 -3
  48. package/dist/{cjs/modal → modal}/style.scss +5 -5
  49. package/dist/{cjs/newspack-icon → newspack-icon}/index.js +4 -4
  50. package/dist/{cjs/newspack-icon → newspack-icon}/style.scss +1 -1
  51. package/dist/{cjs/newspack-logo → newspack-logo}/index.js +4 -4
  52. package/dist/{cjs/newspack-logo → newspack-logo}/style.scss +1 -1
  53. package/dist/{cjs/notice → notice}/index.js +11 -8
  54. package/dist/{cjs/notice → notice}/style.scss +11 -11
  55. package/dist/patrons-logo/index.js +77 -0
  56. package/dist/plugin-installer/index.js +297 -0
  57. package/dist/{esm/plugin-installer → plugin-installer}/style.scss +1 -1
  58. package/dist/{cjs/plugin-settings → plugin-settings}/SettingsSection.js +11 -9
  59. package/dist/plugin-settings/index.js +228 -0
  60. package/dist/{cjs/plugin-settings → plugin-settings}/style.scss +1 -1
  61. package/dist/plugin-toggle/README.md +53 -0
  62. package/dist/plugin-toggle/index.js +222 -0
  63. package/dist/{esm/plugin-toggle → plugin-toggle}/style.scss +1 -1
  64. package/dist/{cjs/popover → popover}/index.js +3 -3
  65. package/dist/{esm/popover → popover}/style.scss +7 -7
  66. package/dist/{cjs/position-control → position-control}/index.js +24 -22
  67. package/dist/{cjs/position-control → position-control}/style.scss +8 -8
  68. package/dist/{cjs/progress-bar → progress-bar}/index.js +8 -8
  69. package/dist/{cjs/progress-bar → progress-bar}/index.test.js +12 -11
  70. package/dist/{esm/progress-bar → progress-bar}/style.scss +2 -2
  71. package/dist/proxied-imports/router.js +15 -0
  72. package/dist/{cjs/radio-control → radio-control}/index.js +3 -3
  73. package/dist/{esm/radio-control → radio-control}/style.scss +3 -3
  74. package/dist/{cjs/section-header → section-header}/index.js +8 -8
  75. package/dist/{cjs/section-header → section-header}/style.scss +1 -1
  76. package/dist/{cjs/select-control → select-control}/ButtonGroupControl.js +7 -7
  77. package/dist/{cjs/select-control → select-control}/GroupedSelectControl.js +15 -14
  78. package/dist/{cjs/select-control → select-control}/index.js +6 -6
  79. package/dist/{esm/select-control → select-control}/style.scss +4 -4
  80. package/dist/{cjs/settings → settings}/MinMaxSetting.js +12 -11
  81. package/dist/{cjs/settings → settings}/SettingsCard.js +4 -4
  82. package/dist/{cjs/settings → settings}/SettingsSection.js +6 -6
  83. package/dist/{cjs/settings → settings}/index.js +1 -1
  84. package/dist/{cjs/settings → settings}/style.scss +1 -1
  85. package/dist/{cjs/sortable-newsletter-list-control → sortable-newsletter-list-control}/index.js +25 -24
  86. package/dist/{cjs/steps-list → steps-list}/index.js +4 -4
  87. package/dist/{esm/steps-list → steps-list}/style.scss +2 -2
  88. package/dist/{cjs/steps-list-item → steps-list-item}/index.js +5 -5
  89. package/dist/{cjs/steps-list-item → steps-list-item}/style.scss +5 -5
  90. package/dist/{cjs/style-card → style-card}/index.js +20 -17
  91. package/dist/{cjs/style-card → style-card}/style.scss +4 -4
  92. package/dist/{esm/style.scss → style.scss} +1 -1
  93. package/dist/{cjs/tabbed-navigation → tabbed-navigation}/index.js +7 -7
  94. package/dist/{cjs/tabbed-navigation → tabbed-navigation}/style.scss +4 -4
  95. package/dist/text-control/index.js +76 -0
  96. package/dist/text-control/index.tsx +71 -0
  97. package/dist/{cjs/utils → utils}/index.js +2 -2
  98. package/dist/{cjs/waiting → waiting}/index.js +3 -3
  99. package/dist/web-preview/index.js +191 -0
  100. package/dist/{esm/web-preview → web-preview}/style.scss +5 -5
  101. package/dist/with-wizard/index.js +328 -0
  102. package/dist/{cjs/with-wizard → with-wizard}/style.scss +44 -22
  103. package/dist/{cjs/with-wizard-screen → with-wizard-screen}/index.js +24 -23
  104. package/dist/{esm/with-wizard-screen → with-wizard-screen}/style.scss +7 -7
  105. package/dist/{cjs/wizard → wizard}/components/WizardError.js +10 -9
  106. package/dist/{cjs/wizard → wizard}/index.js +30 -27
  107. package/dist/{cjs/wizard → wizard}/store/index.js +1 -1
  108. package/package.json +18 -15
  109. package/shared/scss/_mixins.scss +2 -2
  110. package/src/accordion/index.js +35 -0
  111. package/src/accordion/style.scss +31 -0
  112. package/src/action-card/style.scss +9 -9
  113. package/src/autocomplete-tokenfield/style.scss +3 -3
  114. package/src/autocomplete-with-suggestions/index.js +46 -44
  115. package/src/autocomplete-with-suggestions/style.scss +8 -8
  116. package/src/button/style.scss +1 -1
  117. package/src/button-card/style.scss +19 -13
  118. package/src/card/style.scss +1 -1
  119. package/src/category-autocomplete/style.scss +2 -2
  120. package/src/color-picker/style.scss +3 -3
  121. package/src/custom-select-control/style.scss +11 -10
  122. package/src/date-range-picker/index.js +31 -0
  123. package/src/date-range-picker/style.scss +148 -0
  124. package/src/footer/style.scss +1 -1
  125. package/src/form-token-field/style.scss +1 -1
  126. package/src/grid/style.scss +9 -9
  127. package/src/handoff-message/index.js +3 -1
  128. package/src/image-upload/index.js +1 -1
  129. package/src/image-upload/index.test.js +6 -1
  130. package/src/image-upload/style.scss +5 -5
  131. package/src/index.js +2 -0
  132. package/src/modal/style.scss +5 -5
  133. package/src/newspack-icon/style.scss +1 -1
  134. package/src/newspack-logo/style.scss +1 -1
  135. package/src/notice/style.scss +11 -11
  136. package/src/plugin-installer/style.scss +1 -1
  137. package/src/plugin-settings/style.scss +1 -1
  138. package/src/plugin-toggle/index.js +6 -7
  139. package/src/plugin-toggle/style.scss +1 -1
  140. package/src/popover/style.scss +7 -7
  141. package/src/position-control/index.js +62 -63
  142. package/src/position-control/style.scss +8 -8
  143. package/src/progress-bar/style.scss +2 -2
  144. package/src/radio-control/style.scss +3 -3
  145. package/src/section-header/style.scss +1 -1
  146. package/src/select-control/style.scss +4 -4
  147. package/src/settings/style.scss +1 -1
  148. package/src/steps-list/style.scss +2 -2
  149. package/src/steps-list-item/style.scss +5 -5
  150. package/src/style-card/style.scss +4 -4
  151. package/src/style.scss +1 -1
  152. package/src/tabbed-navigation/index.js +1 -1
  153. package/src/tabbed-navigation/style.scss +4 -4
  154. package/src/web-preview/style.scss +5 -5
  155. package/src/with-wizard/style.scss +44 -22
  156. package/src/with-wizard-screen/style.scss +7 -7
  157. package/dist/cjs/autocomplete-tokenfield/style.scss +0 -49
  158. package/dist/cjs/button/index.js +0 -56
  159. package/dist/cjs/card/style.scss +0 -168
  160. package/dist/cjs/custom-select-control/style.scss +0 -92
  161. package/dist/cjs/form-token-field/style.scss +0 -37
  162. package/dist/cjs/grid/index.js +0 -37
  163. package/dist/cjs/grid/style.scss +0 -166
  164. package/dist/cjs/hooks/index.js +0 -25
  165. package/dist/cjs/hooks/usePrompt.js +0 -49
  166. package/dist/cjs/image-upload/index.js +0 -143
  167. package/dist/cjs/patrons-logo/index.js +0 -81
  168. package/dist/cjs/plugin-installer/index.js +0 -295
  169. package/dist/cjs/plugin-installer/style.scss +0 -72
  170. package/dist/cjs/plugin-settings/index.js +0 -221
  171. package/dist/cjs/plugin-toggle/index.js +0 -218
  172. package/dist/cjs/plugin-toggle/style.scss +0 -20
  173. package/dist/cjs/popover/style.scss +0 -161
  174. package/dist/cjs/progress-bar/style.scss +0 -42
  175. package/dist/cjs/proxied-imports/router.js +0 -14
  176. package/dist/cjs/radio-control/style.scss +0 -92
  177. package/dist/cjs/select-control/style.scss +0 -108
  178. package/dist/cjs/steps-list/style.scss +0 -11
  179. package/dist/cjs/style.scss +0 -55
  180. package/dist/cjs/text-control/index.js +0 -61
  181. package/dist/cjs/web-preview/index.js +0 -188
  182. package/dist/cjs/web-preview/style.scss +0 -155
  183. package/dist/cjs/with-wizard/index.js +0 -317
  184. package/dist/cjs/with-wizard-screen/style.scss +0 -160
  185. package/dist/esm/action-card/index.js +0 -221
  186. package/dist/esm/action-card/style.scss +0 -483
  187. package/dist/esm/autocomplete-tokenfield/index.js +0 -260
  188. package/dist/esm/autocomplete-with-suggestions/index.js +0 -276
  189. package/dist/esm/autocomplete-with-suggestions/style.scss +0 -163
  190. package/dist/esm/button/index.js +0 -48
  191. package/dist/esm/button/style.scss +0 -11
  192. package/dist/esm/button-card/index.js +0 -64
  193. package/dist/esm/button-card/style.scss +0 -174
  194. package/dist/esm/card/index.js +0 -43
  195. package/dist/esm/category-autocomplete/index.js +0 -181
  196. package/dist/esm/category-autocomplete/style.scss +0 -34
  197. package/dist/esm/color-picker/index.js +0 -59
  198. package/dist/esm/color-picker/style.scss +0 -37
  199. package/dist/esm/consts.js +0 -1
  200. package/dist/esm/custom-select-control/index.js +0 -37
  201. package/dist/esm/footer/index.js +0 -100
  202. package/dist/esm/footer/style.scss +0 -82
  203. package/dist/esm/form-token-field/index.js +0 -49
  204. package/dist/esm/global-notices/index.js +0 -30
  205. package/dist/esm/grid/index.js +0 -29
  206. package/dist/esm/handoff/index.js +0 -176
  207. package/dist/esm/handoff-message/index.js +0 -45
  208. package/dist/esm/hooks/index.js +0 -17
  209. package/dist/esm/hooks/useObjectState.js +0 -30
  210. package/dist/esm/hooks/useObjectState.test.js +0 -82
  211. package/dist/esm/hooks/useOnClickOutside.js +0 -31
  212. package/dist/esm/hooks/usePrompt.js +0 -40
  213. package/dist/esm/image-upload/index.js +0 -139
  214. package/dist/esm/image-upload/index.test.js +0 -28
  215. package/dist/esm/image-upload/style.scss +0 -103
  216. package/dist/esm/index.js +0 -45
  217. package/dist/esm/info-button/index.js +0 -42
  218. package/dist/esm/info-button/style.scss +0 -18
  219. package/dist/esm/modal/index.js +0 -39
  220. package/dist/esm/modal/style.scss +0 -56
  221. package/dist/esm/newspack-icon/index.js +0 -50
  222. package/dist/esm/newspack-icon/style.scss +0 -26
  223. package/dist/esm/newspack-logo/index.js +0 -46
  224. package/dist/esm/newspack-logo/style.scss +0 -30
  225. package/dist/esm/notice/index.js +0 -66
  226. package/dist/esm/notice/style.scss +0 -111
  227. package/dist/esm/patrons-logo/index.js +0 -75
  228. package/dist/esm/plugin-installer/index.js +0 -290
  229. package/dist/esm/plugin-settings/SettingsSection.js +0 -134
  230. package/dist/esm/plugin-settings/index.js +0 -216
  231. package/dist/esm/plugin-settings/style.scss +0 -7
  232. package/dist/esm/plugin-toggle/index.js +0 -213
  233. package/dist/esm/popover/index.js +0 -41
  234. package/dist/esm/position-control/index.js +0 -107
  235. package/dist/esm/position-control/style.scss +0 -66
  236. package/dist/esm/progress-bar/index.js +0 -68
  237. package/dist/esm/progress-bar/index.test.js +0 -109
  238. package/dist/esm/proxied-imports/router.js +0 -8
  239. package/dist/esm/radio-control/index.js +0 -37
  240. package/dist/esm/section-header/index.js +0 -67
  241. package/dist/esm/section-header/style.scss +0 -45
  242. package/dist/esm/select-control/ButtonGroupControl.js +0 -53
  243. package/dist/esm/select-control/GroupedSelectControl.js +0 -79
  244. package/dist/esm/select-control/index.js +0 -51
  245. package/dist/esm/settings/MinMaxSetting.js +0 -54
  246. package/dist/esm/settings/SettingsCard.js +0 -38
  247. package/dist/esm/settings/SettingsSection.js +0 -26
  248. package/dist/esm/settings/index.js +0 -9
  249. package/dist/esm/settings/style.scss +0 -119
  250. package/dist/esm/sortable-newsletter-list-control/index.js +0 -128
  251. package/dist/esm/sortable-newsletter-list-control/style.scss +0 -45
  252. package/dist/esm/steps-list/index.js +0 -43
  253. package/dist/esm/steps-list-item/index.js +0 -47
  254. package/dist/esm/steps-list-item/style.scss +0 -47
  255. package/dist/esm/style-card/index.js +0 -75
  256. package/dist/esm/style-card/style.scss +0 -94
  257. package/dist/esm/tabbed-navigation/index.js +0 -53
  258. package/dist/esm/tabbed-navigation/style.scss +0 -86
  259. package/dist/esm/text-control/index.js +0 -57
  260. package/dist/esm/text-control/style.scss +0 -32
  261. package/dist/esm/utils/index.js +0 -29
  262. package/dist/esm/waiting/index.js +0 -44
  263. package/dist/esm/waiting/style.scss +0 -27
  264. package/dist/esm/web-preview/index.js +0 -183
  265. package/dist/esm/with-wizard/index.js +0 -311
  266. package/dist/esm/with-wizard/style.scss +0 -260
  267. package/dist/esm/with-wizard-screen/index.js +0 -110
  268. package/dist/esm/wizard/components/WizardError.js +0 -67
  269. package/dist/esm/wizard/index.js +0 -120
  270. package/dist/esm/wizard/store/index.js +0 -155
  271. package/dist/esm/wizard/store/utils.js +0 -14
  272. /package/dist/{cjs/consts.js → consts.js} +0 -0
  273. /package/dist/{cjs/hooks → hooks}/useOnClickOutside.js +0 -0
  274. /package/dist/{cjs/info-button → info-button}/style.scss +0 -0
  275. /package/dist/{cjs/sortable-newsletter-list-control → sortable-newsletter-list-control}/style.scss +0 -0
  276. /package/dist/{cjs/text-control → text-control}/style.scss +0 -0
  277. /package/dist/{cjs/waiting → waiting}/style.scss +0 -0
  278. /package/dist/{cjs/wizard → wizard}/store/utils.js +0 -0
@@ -0,0 +1,328 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = withWizard;
8
+ var _element = require("@wordpress/element");
9
+ var _i18n = require("@wordpress/i18n");
10
+ var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
11
+ var _icons = require("@wordpress/icons");
12
+ var _ = require("../");
13
+ var _router = _interopRequireDefault(require("../proxied-imports/router"));
14
+ var _footer = _interopRequireDefault(require("../footer"));
15
+ require("./style.scss");
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ /**
18
+ * WordPress dependencies.
19
+ */
20
+
21
+ /**
22
+ * Internal dependencies.
23
+ */
24
+
25
+ const {
26
+ Redirect,
27
+ Route
28
+ } = _router.default;
29
+
30
+ /**
31
+ * Higher-Order Component to provide plugin management and error handling to Newspack Wizards.
32
+ */
33
+ function withWizard(WrappedComponent, requiredPlugins) {
34
+ return class WrappedWithWizard extends _element.Component {
35
+ constructor(props) {
36
+ super(props);
37
+ this.state = {
38
+ complete: null,
39
+ error: null,
40
+ loading: requiredPlugins && requiredPlugins.length > 0 ? 1 : 0,
41
+ quietLoading: false
42
+ };
43
+ this.wrappedComponentRef = (0, _element.createRef)();
44
+ }
45
+ componentDidMount = () => {
46
+ // If there are no requiredPlugins, fire onWizardReady as soon as component mounts.
47
+ if (!requiredPlugins) {
48
+ const instance = this.wrappedComponentRef.current;
49
+ // eslint-disable-next-line no-unused-expressions
50
+ instance && instance.onWizardReady && instance.onWizardReady();
51
+ }
52
+ };
53
+
54
+ /**
55
+ * Set the error. Called by Wizards when an error occurs.
56
+ *
57
+ * @return {Promise} Resolved after state update
58
+ */
59
+ setError = error => {
60
+ return new Promise(resolve => {
61
+ this.setState({
62
+ error: error || null
63
+ }, () => resolve());
64
+ });
65
+ };
66
+
67
+ /**
68
+ * Render any errors that need rendering.
69
+ *
70
+ * @return {Component} Error UI
71
+ */
72
+ getError = () => {
73
+ const {
74
+ error
75
+ } = this.state;
76
+ if (!error) {
77
+ return null;
78
+ }
79
+ const parsedError = this.parseError(error);
80
+ const {
81
+ level
82
+ } = parsedError;
83
+ if ('fatal' === level) {
84
+ return this.getFatalError(parsedError);
85
+ }
86
+ return this.getErrorNotice(parsedError);
87
+ };
88
+
89
+ /**
90
+ * Get a notice-level error.
91
+ *
92
+ * @param {Error} error object already parsed by parseError
93
+ * @return {Component} Error notice
94
+ */
95
+ getErrorNotice = error => {
96
+ const {
97
+ message
98
+ } = error;
99
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Notice, {
100
+ isError: true,
101
+ className: "newspack-wizard__above-header",
102
+ noticeText: message,
103
+ rawHTML: true
104
+ });
105
+ };
106
+
107
+ /**
108
+ * Get a fatal-level error.
109
+ *
110
+ * @param {Error} error object already parsed by parseError
111
+ * @return {Component} React object
112
+ */
113
+ getFatalError = error => {
114
+ const fallbackURL = this.getFallbackURL();
115
+ if (!fallbackURL) {
116
+ return null;
117
+ }
118
+ const {
119
+ message
120
+ } = error;
121
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_.Modal, {
122
+ title: (0, _i18n.__)('Unrecoverable error'),
123
+ onRequestClose: () => window.location = fallbackURL,
124
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_.Notice, {
125
+ noticeText: message,
126
+ isError: true,
127
+ rawHTML: true
128
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Card, {
129
+ buttonsCard: true,
130
+ noBorder: true,
131
+ className: "justify-end",
132
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
133
+ isPrimary: true,
134
+ href: fallbackURL,
135
+ children: (0, _i18n.__)('Return to Dashboard', 'newspack-plugin')
136
+ })
137
+ })]
138
+ });
139
+ };
140
+
141
+ /**
142
+ * Get all the relevant info out of a raw API error response.
143
+ *
144
+ * @param {Object} error error object
145
+ * @return {Object} Error object with relevant fields and defaults
146
+ */
147
+ parseError = error => {
148
+ const {
149
+ data,
150
+ message,
151
+ code
152
+ } = error;
153
+ let level = 'fatal';
154
+ if (!!data && 'level' in data) {
155
+ level = data.level;
156
+ } else if ('rest_invalid_param' === code) {
157
+ level = 'notice';
158
+ }
159
+ return {
160
+ message,
161
+ level
162
+ };
163
+ };
164
+
165
+ /**
166
+ * Called when plugin installation is complete. Updates state and calls onWizardReady on the wrapped component.
167
+ */
168
+ pluginInstallationStatus = ({
169
+ complete
170
+ }) => {
171
+ if (this.state.loading) {
172
+ this.doneLoading();
173
+ }
174
+ const instance = this.wrappedComponentRef.current;
175
+ this.setState({
176
+ complete
177
+ }, () => {
178
+ // eslint-disable-next-line no-unused-expressions
179
+ complete && instance && instance.onWizardReady && instance.onWizardReady();
180
+ });
181
+ };
182
+
183
+ /**
184
+ * Begin loading.
185
+ */
186
+ startLoading = quiet => {
187
+ if (quiet) {
188
+ this.setState(state => ({
189
+ quietLoading: state.quietLoading + 1
190
+ }));
191
+ } else {
192
+ this.setState(state => ({
193
+ loading: state.loading + 1
194
+ }));
195
+ }
196
+ };
197
+
198
+ /**
199
+ * End loading.
200
+ */
201
+ doneLoading = quiet => {
202
+ if (quiet) {
203
+ this.setState(state => ({
204
+ quietLoading: state.quietLoading - 1
205
+ }));
206
+ } else {
207
+ this.setState(state => ({
208
+ loading: state.loading - 1
209
+ }));
210
+ }
211
+ };
212
+
213
+ /**
214
+ * Replacement for core apiFetch that automatically manages wizard loading UI.
215
+ */
216
+ wizardApiFetch = args => {
217
+ const {
218
+ quiet
219
+ } = args;
220
+ this.startLoading(quiet);
221
+ return new Promise((resolve, reject) => {
222
+ (0, _apiFetch.default)(args).then(response => {
223
+ this.doneLoading(quiet);
224
+ resolve(response);
225
+ }).catch(error => {
226
+ this.doneLoading(quiet);
227
+ reject(error);
228
+ });
229
+ });
230
+ };
231
+
232
+ /**
233
+ * Render a Route that checks for plugin installation requirements, and redirects to '/' when all are done.
234
+ *
235
+ * @return {void}
236
+ */
237
+ pluginRequirements = () => {
238
+ const {
239
+ complete
240
+ } = this.state;
241
+ /* After all plugins are loaded, redirect to / (this could be configurable) */
242
+ if (complete) {
243
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Redirect, {
244
+ from: "/plugin-requirements",
245
+ to: "/"
246
+ });
247
+ }
248
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Route, {
249
+ path: "/",
250
+ render: () => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_element.Fragment, {
251
+ children: [complete !== null && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
252
+ className: "newspack-wizard__header",
253
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
254
+ className: "newspack-wizard__header__inner",
255
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
256
+ className: "newspack-wizard__title",
257
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
258
+ isLink: true,
259
+ href: newspack_urls.dashboard,
260
+ label: (0, _i18n.__)('Return to Dashboard', 'newspack-plugin'),
261
+ showTooltip: true,
262
+ icon: _icons.home,
263
+ iconSize: 36,
264
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.NewspackIcon, {
265
+ size: 36
266
+ })
267
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
268
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
269
+ children: requiredPlugins.length > 1 ? (0, _i18n.__)('Required plugins', 'newspack-plugin') : (0, _i18n.__)('Required plugin', 'newspack-plugin')
270
+ })
271
+ })]
272
+ })
273
+ })
274
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
275
+ className: "newspack-wizard newspack-wizard__content",
276
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.PluginInstaller, {
277
+ plugins: requiredPlugins,
278
+ onStatus: status => this.pluginInstallationStatus(status)
279
+ })
280
+ })]
281
+ })
282
+ });
283
+ };
284
+ getFallbackURL = () => {
285
+ if (typeof newspack_urls !== 'undefined') {
286
+ return newspack_urls.dashboard;
287
+ }
288
+ };
289
+
290
+ /**
291
+ * Render.
292
+ */
293
+ render() {
294
+ const {
295
+ simpleFooter
296
+ } = this.props;
297
+ const {
298
+ loading,
299
+ quietLoading,
300
+ error
301
+ } = this.state;
302
+ const loadingClasses = [loading ? 'newspack-wizard__is-loading' : 'newspack-wizard__is-loaded'];
303
+ if (quietLoading) {
304
+ loadingClasses.push('newspack-wizard__is-loading-quiet');
305
+ }
306
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_element.Fragment, {
307
+ children: [this.getError(), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
308
+ className: loadingClasses.join(' '),
309
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, {
310
+ pluginRequirements: requiredPlugins && this.pluginRequirements(),
311
+ clearError: this.clearError,
312
+ getError: this.getError,
313
+ errorData: error,
314
+ setError: this.setError,
315
+ isLoading: loading,
316
+ startLoading: this.startLoading,
317
+ doneLoading: this.doneLoading,
318
+ wizardApiFetch: this.wizardApiFetch,
319
+ ref: this.wrappedComponentRef,
320
+ ...this.props
321
+ })
322
+ }), !loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_footer.default, {
323
+ simple: simpleFooter
324
+ })]
325
+ });
326
+ }
327
+ };
328
+ }
@@ -2,14 +2,14 @@
2
2
  * With Wizard
3
3
  */
4
4
 
5
- @use '~@wordpress/base-styles/colors' as wp-colors;
6
- @use '../../../shared/scss/colors';
5
+ @use "~@wordpress/base-styles/colors" as wp-colors;
6
+ @use "../../../shared/scss/colors";
7
7
 
8
8
  // Reset Padding of the Admin Page
9
9
 
10
- .toplevel_page_newspack:not( .menu-top ),
11
- body[class*='newspack_page_newspack-'],
12
- body[class*='admin_page_newspack-'] {
10
+ .toplevel_page_newspack:not(.menu-top),
11
+ body[class*="newspack_page_newspack-"],
12
+ body[class*="admin_page_newspack-"] {
13
13
  background: white;
14
14
 
15
15
  #wpcontent {
@@ -33,7 +33,7 @@ body[class*='admin_page_newspack-'] {
33
33
  svg {
34
34
  &.newspack--error {
35
35
  fill: wp-colors.$alert-red;
36
- transform: rotate( 180deg );
36
+ transform: rotate(180deg);
37
37
  }
38
38
  &.newspack--success {
39
39
  fill: wp-colors.$alert-green;
@@ -87,38 +87,51 @@ svg {
87
87
  &::before,
88
88
  &::after {
89
89
  animation: loading 2s ease-in-out infinite;
90
- content: '';
90
+ content: "";
91
91
  display: block;
92
92
  }
93
93
 
94
94
  &::before {
95
95
  background: colors.$primary-500;
96
- box-shadow: 24px 0 0 white, 69px 0 0 -15px wp-colors.$gray-900,
97
- 99px 0 0 -15px wp-colors.$gray-900, 129px 0 0 -15px wp-colors.$gray-900,
98
- 159px 0 0 -15px wp-colors.$gray-900, 189px 0 0 -15px wp-colors.$gray-900;
96
+ box-shadow:
97
+ 24px 0 0 white,
98
+ 69px 0 0 -15px wp-colors.$gray-900,
99
+ 99px 0 0 -15px wp-colors.$gray-900,
100
+ 129px 0 0 -15px wp-colors.$gray-900,
101
+ 159px 0 0 -15px wp-colors.$gray-900,
102
+ 189px 0 0 -15px wp-colors.$gray-900;
99
103
  height: 60px;
100
104
  width: 60px;
101
105
  }
102
106
 
103
107
  &::after {
104
108
  background: wp-colors.$gray-900;
105
- box-shadow: inset -40vw 0 0 0 white, 0 64px 0 0 wp-colors.$gray-700, 40vw 96px 0 0 white,
109
+ box-shadow:
110
+ inset -40vw 0 0 0 white,
111
+ 0 64px 0 0 wp-colors.$gray-700,
112
+ 40vw 96px 0 0 white,
106
113
  0 96px 0 0 wp-colors.$gray-700;
107
114
  height: 24px;
108
115
  margin: 68px auto 0;
109
116
  max-width: 1040px;
110
- width: calc( 100% - ( 32px * 2 ) );
117
+ width: calc(100% - ( 32px * 2 ));
111
118
 
112
119
  @media screen and ( min-width: 744px ) {
113
- box-shadow: inset -400px 0 0 0 white, 0 64px 0 0 wp-colors.$gray-700, 200px 96px 0 0 white,
120
+ box-shadow:
121
+ inset -400px 0 0 0 white,
122
+ 0 64px 0 0 wp-colors.$gray-700,
123
+ 200px 96px 0 0 white,
114
124
  0 96px 0 0 wp-colors.$gray-700;
115
- width: calc( 100% - ( 64px * 2 ) );
125
+ width: calc(100% - ( 64px * 2 ));
116
126
  }
117
127
 
118
128
  @media screen and ( min-width: 1224px ) {
119
- box-shadow: inset -600px 0 0 0 white, 0 64px 0 0 wp-colors.$gray-700, 512px 96px 0 0 white,
129
+ box-shadow:
130
+ inset -600px 0 0 0 white,
131
+ 0 64px 0 0 wp-colors.$gray-700,
132
+ 512px 96px 0 0 white,
120
133
  0 96px 0 0 wp-colors.$gray-700;
121
- width: calc( 100% - ( 64px * 2 ) );
134
+ width: calc(100% - ( 64px * 2 ));
122
135
  }
123
136
  }
124
137
 
@@ -151,7 +164,7 @@ svg {
151
164
 
152
165
  &::before,
153
166
  &::after {
154
- content: '';
167
+ content: "";
155
168
  cursor: wait;
156
169
  display: block;
157
170
  left: 0;
@@ -187,7 +200,7 @@ svg {
187
200
  }
188
201
 
189
202
  &::after {
190
- background: rgba( white, 0.7 );
203
+ background: rgba(white, 0.7);
191
204
  bottom: 0;
192
205
  right: 0;
193
206
  z-index: 9998;
@@ -206,10 +219,13 @@ svg {
206
219
 
207
220
  &::after {
208
221
  animation: loading 2s ease-in-out infinite;
209
- content: '';
222
+ content: "";
210
223
  display: block;
211
224
  background: wp-colors.$gray-900;
212
- box-shadow: inset -40vw 0 0 0 white, 0 64px 0 0 wp-colors.$gray-700, 40vw 96px 0 0 white,
225
+ box-shadow:
226
+ inset -40vw 0 0 0 white,
227
+ 0 64px 0 0 wp-colors.$gray-700,
228
+ 40vw 96px 0 0 white,
213
229
  0 96px 0 0 wp-colors.$gray-700;
214
230
  height: 24px;
215
231
  margin: 0 auto;
@@ -217,12 +233,18 @@ svg {
217
233
  width: 100%;
218
234
 
219
235
  @media screen and ( min-width: 744px ) {
220
- box-shadow: inset -400px 0 0 0 white, 0 64px 0 0 wp-colors.$gray-700, 200px 96px 0 0 white,
236
+ box-shadow:
237
+ inset -400px 0 0 0 white,
238
+ 0 64px 0 0 wp-colors.$gray-700,
239
+ 200px 96px 0 0 white,
221
240
  0 96px 0 0 wp-colors.$gray-700;
222
241
  }
223
242
 
224
243
  @media screen and ( min-width: 1224px ) {
225
- box-shadow: inset -600px 0 0 0 white, 0 64px 0 0 wp-colors.$gray-700, 520px 96px 0 0 white,
244
+ box-shadow:
245
+ inset -600px 0 0 0 white,
246
+ 0 64px 0 0 wp-colors.$gray-700,
247
+ 520px 96px 0 0 white,
226
248
  0 96px 0 0 wp-colors.$gray-700;
227
249
  }
228
250
  }
@@ -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
  });
@@ -11,21 +11,22 @@ var _ = require("../");
11
11
  var _js = require("../../../shared/js/");
12
12
  require("./style.scss");
13
13
  var _classnames = _interopRequireDefault(require("classnames"));
14
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
15
  /**
16
16
  * WordPress dependencies.
17
17
  */
18
- const __ = _i18n.__;
18
+
19
19
  /**
20
20
  * Internal dependencies
21
21
  */
22
+
22
23
  /**
23
24
  * External dependencies
24
25
  */
26
+
25
27
  /**
26
28
  * Higher-Order Component to provide plugin management and error handling to Newspack Wizards.
27
- */
28
- function withWizardScreen(WrappedComponent, {
29
+ */function withWizardScreen(WrappedComponent, {
29
30
  hidePrimaryButton
30
31
  } = {}) {
31
32
  const WrappedWithWizardScreen = props => {
@@ -47,12 +48,12 @@ function withWizardScreen(WrappedComponent, {
47
48
  const SecondaryCTAComponent = retrievedSecondaryButtonProps.plugin ? _.Handoff : _.Button;
48
49
  const shouldRenderPrimaryButton = buttonText && buttonAction;
49
50
  const shouldRenderSecondaryButton = secondaryButtonText && secondaryButtonAction;
50
- const renderPrimaryButton = (overridingProps = {}) => retrievedButtonProps.plugin ? (0, _jsxRuntime.jsx)(_.Handoff, {
51
+ const renderPrimaryButton = (overridingProps = {}) => retrievedButtonProps.plugin ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Handoff, {
51
52
  isPrimary: true,
52
53
  ...retrievedButtonProps,
53
54
  ...overridingProps,
54
55
  children: buttonText
55
- }) : (0, _jsxRuntime.jsx)(_.Button, {
56
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
56
57
  isPrimary: !buttonDisabled,
57
58
  isSecondary: !!buttonDisabled,
58
59
  disabled: buttonDisabled
@@ -63,45 +64,45 @@ function withWizardScreen(WrappedComponent, {
63
64
  ...retrievedButtonProps,
64
65
  ...overridingProps
65
66
  });
66
- return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
67
- children: [newspack_aux_data.is_debug_mode && (0, _jsxRuntime.jsx)(_.Notice, {
67
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
68
+ children: [newspack_aux_data.is_debug_mode && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Notice, {
68
69
  debugMode: true
69
- }), (0, _jsxRuntime.jsx)("div", {
70
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
70
71
  className: "newspack-wizard__header",
71
- children: (0, _jsxRuntime.jsx)("div", {
72
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
72
73
  className: "newspack-wizard__header__inner",
73
- children: (0, _jsxRuntime.jsxs)("div", {
74
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
74
75
  className: "newspack-wizard__title",
75
- children: [(0, _jsxRuntime.jsx)(_.Button, {
76
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
76
77
  isLink: true,
77
78
  href: newspack_urls.dashboard,
78
- label: __('Return to Dashboard', 'newspack-plugin'),
79
+ label: (0, _i18n.__)('Return to Dashboard', 'newspack-plugin'),
79
80
  showTooltip: true,
80
81
  icon: _icons.category,
81
82
  iconSize: 36,
82
- children: (0, _jsxRuntime.jsx)(_.NewspackIcon, {
83
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.NewspackIcon, {
83
84
  size: 36
84
85
  })
85
- }), (0, _jsxRuntime.jsxs)("div", {
86
- children: [headerText && (0, _jsxRuntime.jsx)("h2", {
86
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
87
+ children: [headerText && /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
87
88
  children: headerText
88
- }), subHeaderText && (0, _jsxRuntime.jsx)("span", {
89
+ }), subHeaderText && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
89
90
  children: subHeaderText
90
91
  })]
91
92
  })]
92
93
  })
93
94
  })
94
- }), tabbedNavigation && (0, _jsxRuntime.jsx)(_.TabbedNavigation, {
95
+ }), tabbedNavigation && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.TabbedNavigation, {
95
96
  disableUpcoming: disableUpcomingInTabbedNavigation,
96
97
  items: tabbedNavigation.filter(item => !item.isHiddenInNav)
97
- }), (0, _jsxRuntime.jsx)(_.HandoffMessage, {}), (0, _jsxRuntime.jsxs)("div", {
98
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_.HandoffMessage, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
98
99
  className: (0, _classnames.default)('newspack-wizard newspack-wizard__content', className),
99
- children: [typeof renderAboveContent === 'function' ? renderAboveContent() : null, (0, _jsxRuntime.jsx)(WrappedComponent, {
100
+ children: [typeof renderAboveContent === 'function' ? renderAboveContent() : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, {
100
101
  ...props,
101
102
  renderPrimaryButton: renderPrimaryButton
102
- }), (shouldRenderPrimaryButton || shouldRenderSecondaryButton) && (0, _jsxRuntime.jsxs)("div", {
103
+ }), (shouldRenderPrimaryButton || shouldRenderSecondaryButton) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
103
104
  className: "newspack-buttons-card",
104
- children: [shouldRenderPrimaryButton && !hidePrimaryButton && renderPrimaryButton(), shouldRenderSecondaryButton && (0, _jsxRuntime.jsx)(SecondaryCTAComponent, {
105
+ children: [shouldRenderPrimaryButton && !hidePrimaryButton && renderPrimaryButton(), shouldRenderSecondaryButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(SecondaryCTAComponent, {
105
106
  isSecondary: true,
106
107
  ...retrievedSecondaryButtonProps,
107
108
  children: secondaryButtonText
@@ -2,8 +2,8 @@
2
2
  * With Wizard Screen
3
3
  */
4
4
 
5
- @use '~@wordpress/base-styles/colors' as wp-colors;
6
- @use '../../../shared/scss/colors';
5
+ @use "~@wordpress/base-styles/colors" as wp-colors;
6
+ @use "../../../shared/scss/colors";
7
7
 
8
8
  .newspack-wizard {
9
9
  // Color
@@ -29,16 +29,16 @@
29
29
 
30
30
  // Links
31
31
  a {
32
- color: var( --wp-admin-theme-color );
32
+ color: var(--wp-admin-theme-color);
33
33
 
34
34
  &:active,
35
35
  &:focus,
36
36
  &:hover {
37
- color: var( --wp-admin-theme-color-darker-10 );
37
+ color: var(--wp-admin-theme-color-darker-10);
38
38
  }
39
39
 
40
40
  &:focus {
41
- box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) var( --wp-admin-theme-color );
41
+ box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
42
42
  outline: 3px solid transparent;
43
43
  }
44
44
  }
@@ -82,7 +82,7 @@
82
82
  margin-bottom: -1px !important;
83
83
  }
84
84
 
85
- &:not( .newspack-icon ) {
85
+ &:not(.newspack-icon) {
86
86
  background: colors.$primary-500;
87
87
  left: 50%;
88
88
  margin: -28px 0 0 -28px !important;
@@ -110,7 +110,7 @@
110
110
  &::before {
111
111
  border: 2px solid white;
112
112
  border-radius: 2px;
113
- content: '';
113
+ content: "";
114
114
  display: block;
115
115
  inset: 6px 6px 5px;
116
116
  position: absolute;
@@ -8,14 +8,15 @@ var _i18n = require("@wordpress/i18n");
8
8
  var _data = require("@wordpress/data");
9
9
  var _ = require("../..");
10
10
  var _store = require("../store");
11
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
12
  /**
13
13
  * WordPress dependencies.
14
14
  */
15
- const __ = _i18n.__;
15
+
16
16
  /**
17
17
  * Internal dependencies.
18
18
  */
19
+
19
20
  const parseError = ({
20
21
  data,
21
22
  message,
@@ -43,26 +44,26 @@ const WizardError = () => {
43
44
  } = parseError(error);
44
45
  if ('fatal' === level) {
45
46
  const fallbackURL = typeof newspack_urls !== 'undefined' && newspack_urls.dashboard;
46
- return (0, _jsxRuntime.jsxs)(_.Modal, {
47
- title: __('Unrecoverable error'),
47
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_.Modal, {
48
+ title: (0, _i18n.__)('Unrecoverable error'),
48
49
  onRequestClose: fallbackURL ? () => window.location = fallbackURL : undefined,
49
- children: [(0, _jsxRuntime.jsx)(_.Notice, {
50
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_.Notice, {
50
51
  noticeText: message,
51
52
  isError: true,
52
53
  rawHTML: true
53
- }), fallbackURL && (0, _jsxRuntime.jsx)(_.Card, {
54
+ }), fallbackURL && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Card, {
54
55
  buttonsCard: true,
55
56
  noBorder: true,
56
57
  className: "justify-end",
57
- children: (0, _jsxRuntime.jsx)(_.Button, {
58
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
58
59
  isPrimary: true,
59
60
  href: fallbackURL,
60
- children: __('Return to Dashboard', 'newspack-plugin')
61
+ children: (0, _i18n.__)('Return to Dashboard', 'newspack-plugin')
61
62
  })
62
63
  })]
63
64
  });
64
65
  }
65
- return (0, _jsxRuntime.jsx)(_.Notice, {
66
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Notice, {
66
67
  isError: true,
67
68
  className: "newspack-wizard__above-header",
68
69
  noticeText: message,