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
@@ -1,311 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /**
3
- * WordPress dependencies.
4
- */
5
- import { Component, createRef, Fragment } from '@wordpress/element';
6
- import { __ as alias__ } from '@wordpress/i18n';
7
- const __ = alias__;
8
- import apiFetch from '@wordpress/api-fetch';
9
- import { home } from '@wordpress/icons';
10
-
11
- /**
12
- * Internal dependencies.
13
- */
14
- import { Button, Card, Modal, NewspackIcon, Notice, PluginInstaller } from '../';
15
- import Router from '../proxied-imports/router';
16
- import Footer from '../footer';
17
- import './style.scss';
18
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
19
- const {
20
- Redirect,
21
- Route
22
- } = Router;
23
-
24
- /**
25
- * Higher-Order Component to provide plugin management and error handling to Newspack Wizards.
26
- */
27
- export default function withWizard(WrappedComponent, requiredPlugins) {
28
- return class WrappedWithWizard extends Component {
29
- constructor(props) {
30
- super(props);
31
- _defineProperty(this, "componentDidMount", () => {
32
- // If there are no requiredPlugins, fire onWizardReady as soon as component mounts.
33
- if (!requiredPlugins) {
34
- const instance = this.wrappedComponentRef.current;
35
- // eslint-disable-next-line no-unused-expressions
36
- instance && instance.onWizardReady && instance.onWizardReady();
37
- }
38
- });
39
- /**
40
- * Set the error. Called by Wizards when an error occurs.
41
- *
42
- * @return {Promise} Resolved after state update
43
- */
44
- _defineProperty(this, "setError", error => {
45
- return new Promise(resolve => {
46
- this.setState({
47
- error: error || null
48
- }, () => resolve());
49
- });
50
- });
51
- /**
52
- * Render any errors that need rendering.
53
- *
54
- * @return {Component} Error UI
55
- */
56
- _defineProperty(this, "getError", () => {
57
- const {
58
- error
59
- } = this.state;
60
- if (!error) {
61
- return null;
62
- }
63
- const parsedError = this.parseError(error);
64
- const {
65
- level
66
- } = parsedError;
67
- if ('fatal' === level) {
68
- return this.getFatalError(parsedError);
69
- }
70
- return this.getErrorNotice(parsedError);
71
- });
72
- /**
73
- * Get a notice-level error.
74
- *
75
- * @param {Error} error object already parsed by parseError
76
- * @return {Component} Error notice
77
- */
78
- _defineProperty(this, "getErrorNotice", error => {
79
- const {
80
- message
81
- } = error;
82
- return _jsx(Notice, {
83
- isError: true,
84
- className: "newspack-wizard__above-header",
85
- noticeText: message,
86
- rawHTML: true
87
- });
88
- });
89
- /**
90
- * Get a fatal-level error.
91
- *
92
- * @param {Error} error object already parsed by parseError
93
- * @return {Component} React object
94
- */
95
- _defineProperty(this, "getFatalError", error => {
96
- const fallbackURL = this.getFallbackURL();
97
- if (!fallbackURL) {
98
- return null;
99
- }
100
- const {
101
- message
102
- } = error;
103
- return _jsxs(Modal, {
104
- title: __('Unrecoverable error'),
105
- onRequestClose: () => window.location = fallbackURL,
106
- children: [_jsx(Notice, {
107
- noticeText: message,
108
- isError: true,
109
- rawHTML: true
110
- }), _jsx(Card, {
111
- buttonsCard: true,
112
- noBorder: true,
113
- className: "justify-end",
114
- children: _jsx(Button, {
115
- isPrimary: true,
116
- href: fallbackURL,
117
- children: __('Return to Dashboard', 'newspack-plugin')
118
- })
119
- })]
120
- });
121
- });
122
- /**
123
- * Get all the relevant info out of a raw API error response.
124
- *
125
- * @param {Object} error error object
126
- * @return {Object} Error object with relevant fields and defaults
127
- */
128
- _defineProperty(this, "parseError", error => {
129
- const {
130
- data,
131
- message,
132
- code
133
- } = error;
134
- let level = 'fatal';
135
- if (!!data && 'level' in data) {
136
- level = data.level;
137
- } else if ('rest_invalid_param' === code) {
138
- level = 'notice';
139
- }
140
- return {
141
- message,
142
- level
143
- };
144
- });
145
- /**
146
- * Called when plugin installation is complete. Updates state and calls onWizardReady on the wrapped component.
147
- */
148
- _defineProperty(this, "pluginInstallationStatus", ({
149
- complete
150
- }) => {
151
- if (this.state.loading) {
152
- this.doneLoading();
153
- }
154
- const instance = this.wrappedComponentRef.current;
155
- this.setState({
156
- complete
157
- }, () => {
158
- // eslint-disable-next-line no-unused-expressions
159
- complete && instance && instance.onWizardReady && instance.onWizardReady();
160
- });
161
- });
162
- /**
163
- * Begin loading.
164
- */
165
- _defineProperty(this, "startLoading", quiet => {
166
- if (quiet) {
167
- this.setState(state => ({
168
- quietLoading: state.quietLoading + 1
169
- }));
170
- } else {
171
- this.setState(state => ({
172
- loading: state.loading + 1
173
- }));
174
- }
175
- });
176
- /**
177
- * End loading.
178
- */
179
- _defineProperty(this, "doneLoading", quiet => {
180
- if (quiet) {
181
- this.setState(state => ({
182
- quietLoading: state.quietLoading - 1
183
- }));
184
- } else {
185
- this.setState(state => ({
186
- loading: state.loading - 1
187
- }));
188
- }
189
- });
190
- /**
191
- * Replacement for core apiFetch that automatically manages wizard loading UI.
192
- */
193
- _defineProperty(this, "wizardApiFetch", args => {
194
- const {
195
- quiet
196
- } = args;
197
- this.startLoading(quiet);
198
- return new Promise((resolve, reject) => {
199
- apiFetch(args).then(response => {
200
- this.doneLoading(quiet);
201
- resolve(response);
202
- }).catch(error => {
203
- this.doneLoading(quiet);
204
- reject(error);
205
- });
206
- });
207
- });
208
- /**
209
- * Render a Route that checks for plugin installation requirements, and redirects to '/' when all are done.
210
- *
211
- * @return {void}
212
- */
213
- _defineProperty(this, "pluginRequirements", () => {
214
- const {
215
- complete
216
- } = this.state;
217
- /* After all plugins are loaded, redirect to / (this could be configurable) */
218
- if (complete) {
219
- return _jsx(Redirect, {
220
- from: "/plugin-requirements",
221
- to: "/"
222
- });
223
- }
224
- return _jsx(Route, {
225
- path: "/",
226
- render: () => _jsxs(Fragment, {
227
- children: [complete !== null && _jsx("div", {
228
- className: "newspack-wizard__header",
229
- children: _jsx("div", {
230
- className: "newspack-wizard__header__inner",
231
- children: _jsxs("div", {
232
- className: "newspack-wizard__title",
233
- children: [_jsx(Button, {
234
- isLink: true,
235
- href: newspack_urls.dashboard,
236
- label: __('Return to Dashboard', 'newspack-plugin'),
237
- showTooltip: true,
238
- icon: home,
239
- iconSize: 36,
240
- children: _jsx(NewspackIcon, {
241
- size: 36
242
- })
243
- }), _jsx("div", {
244
- children: _jsx("h2", {
245
- children: requiredPlugins.length > 1 ? __('Required plugins', 'newspack-plugin') : __('Required plugin', 'newspack-plugin')
246
- })
247
- })]
248
- })
249
- })
250
- }), _jsx("div", {
251
- className: "newspack-wizard newspack-wizard__content",
252
- children: _jsx(PluginInstaller, {
253
- plugins: requiredPlugins,
254
- onStatus: status => this.pluginInstallationStatus(status)
255
- })
256
- })]
257
- })
258
- });
259
- });
260
- _defineProperty(this, "getFallbackURL", () => {
261
- if (typeof newspack_urls !== 'undefined') {
262
- return newspack_urls.dashboard;
263
- }
264
- });
265
- this.state = {
266
- complete: null,
267
- error: null,
268
- loading: requiredPlugins && requiredPlugins.length > 0 ? 1 : 0,
269
- quietLoading: false
270
- };
271
- this.wrappedComponentRef = createRef();
272
- }
273
- /**
274
- * Render.
275
- */
276
- render() {
277
- const {
278
- simpleFooter
279
- } = this.props;
280
- const {
281
- loading,
282
- quietLoading,
283
- error
284
- } = this.state;
285
- const loadingClasses = [loading ? 'newspack-wizard__is-loading' : 'newspack-wizard__is-loaded'];
286
- if (quietLoading) {
287
- loadingClasses.push('newspack-wizard__is-loading-quiet');
288
- }
289
- return _jsxs(Fragment, {
290
- children: [this.getError(), _jsx("div", {
291
- className: loadingClasses.join(' '),
292
- children: _jsx(WrappedComponent, {
293
- pluginRequirements: requiredPlugins && this.pluginRequirements(),
294
- clearError: this.clearError,
295
- getError: this.getError,
296
- errorData: error,
297
- setError: this.setError,
298
- isLoading: loading,
299
- startLoading: this.startLoading,
300
- doneLoading: this.doneLoading,
301
- wizardApiFetch: this.wizardApiFetch,
302
- ref: this.wrappedComponentRef,
303
- ...this.props
304
- })
305
- }), !loading && _jsx(Footer, {
306
- simple: simpleFooter
307
- })]
308
- });
309
- }
310
- };
311
- }
@@ -1,260 +0,0 @@
1
- /**
2
- * With Wizard
3
- */
4
-
5
- @use '~@wordpress/base-styles/colors' as wp-colors;
6
- @use '../../../shared/scss/colors';
7
-
8
- // Reset Padding of the Admin Page
9
-
10
- .toplevel_page_newspack:not( .menu-top ),
11
- body[class*='newspack_page_newspack-'],
12
- body[class*='admin_page_newspack-'] {
13
- background: white;
14
-
15
- #wpcontent {
16
- padding-left: 0;
17
- }
18
-
19
- #wpbody-content {
20
- padding-bottom: 220px;
21
- min-height: 100vh;
22
-
23
- @media screen and ( min-width: 783px ) {
24
- padding-bottom: 202px;
25
- }
26
-
27
- @media screen and ( min-width: 1128px ) {
28
- padding-bottom: 168px;
29
- }
30
- }
31
- }
32
-
33
- svg {
34
- &.newspack--error {
35
- fill: wp-colors.$alert-red;
36
- transform: rotate( 180deg );
37
- }
38
- &.newspack--success {
39
- fill: wp-colors.$alert-green;
40
- }
41
- }
42
-
43
- // Blue Screen
44
-
45
- .newspack-wizard__blue {
46
- #wpwrap {
47
- background: colors.$primary-500;
48
- }
49
-
50
- .newspack-footer {
51
- background: colors.$primary-500;
52
- border-color: colors.$primary-500;
53
- justify-content: center;
54
-
55
- &__logo {
56
- background: inherit;
57
- }
58
- }
59
-
60
- #wpfooter {
61
- color: white;
62
-
63
- a {
64
- color: inherit;
65
-
66
- &:active,
67
- &:focus,
68
- &:hover {
69
- opacity: 0.75;
70
- }
71
- }
72
- }
73
- }
74
-
75
- // Loading
76
-
77
- .newspack-wizard__is-loading {
78
- background: white;
79
- cursor: wait;
80
- inset: 0;
81
- position: absolute;
82
-
83
- > * {
84
- display: none !important;
85
- }
86
-
87
- &::before,
88
- &::after {
89
- animation: loading 2s ease-in-out infinite;
90
- content: '';
91
- display: block;
92
- }
93
-
94
- &::before {
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;
99
- height: 60px;
100
- width: 60px;
101
- }
102
-
103
- &::after {
104
- 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,
106
- 0 96px 0 0 wp-colors.$gray-700;
107
- height: 24px;
108
- margin: 68px auto 0;
109
- max-width: 1040px;
110
- width: calc( 100% - ( 32px * 2 ) );
111
-
112
- @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,
114
- 0 96px 0 0 wp-colors.$gray-700;
115
- width: calc( 100% - ( 64px * 2 ) );
116
- }
117
-
118
- @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,
120
- 0 96px 0 0 wp-colors.$gray-700;
121
- width: calc( 100% - ( 64px * 2 ) );
122
- }
123
- }
124
-
125
- // Blue Screen
126
- .newspack-wizard__blue & {
127
- background: colors.$primary-500;
128
-
129
- &::before {
130
- animation: loading-quiet 1.25s ease-in-out infinite;
131
- background: white;
132
- border-radius: 0;
133
- box-shadow: 0;
134
- height: 8px;
135
- left: 0;
136
- margin: 0;
137
- position: absolute;
138
- right: 100%;
139
- top: 0;
140
- width: auto;
141
- }
142
-
143
- &::after {
144
- display: none;
145
- }
146
- }
147
-
148
- // Quiet
149
- &-quiet {
150
- position: relative;
151
-
152
- &::before,
153
- &::after {
154
- content: '';
155
- cursor: wait;
156
- display: block;
157
- left: 0;
158
- position: fixed;
159
- top: 46px;
160
-
161
- @media screen and ( min-width: 783px ) {
162
- top: 32px;
163
- margin-left: 160px;
164
-
165
- body.auto-fold & {
166
- margin-left: 36px;
167
- }
168
- }
169
-
170
- @media screen and ( min-width: 961px ) {
171
- body.auto-fold & {
172
- margin-left: 160px;
173
- }
174
-
175
- body.folded & {
176
- margin-left: 36px;
177
- }
178
- }
179
- }
180
-
181
- &::before {
182
- animation: loading-quiet 1.25s ease-in-out infinite;
183
- background: colors.$primary-500;
184
- height: 8px;
185
- right: 100%;
186
- z-index: 9999;
187
- }
188
-
189
- &::after {
190
- background: rgba( white, 0.7 );
191
- bottom: 0;
192
- right: 0;
193
- z-index: 9998;
194
- }
195
- }
196
- }
197
-
198
- .newspack-wizard-section__is-loading {
199
- background: white;
200
- cursor: wait;
201
- min-height: 150px;
202
-
203
- > * {
204
- display: none !important;
205
- }
206
-
207
- &::after {
208
- animation: loading 2s ease-in-out infinite;
209
- content: '';
210
- display: block;
211
- 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,
213
- 0 96px 0 0 wp-colors.$gray-700;
214
- height: 24px;
215
- margin: 0 auto;
216
- max-width: 1040px;
217
- width: 100%;
218
-
219
- @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,
221
- 0 96px 0 0 wp-colors.$gray-700;
222
- }
223
-
224
- @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,
226
- 0 96px 0 0 wp-colors.$gray-700;
227
- }
228
- }
229
- }
230
-
231
- @keyframes loading {
232
- 0% {
233
- opacity: 1;
234
- }
235
-
236
- 50% {
237
- opacity: 0.1;
238
- }
239
-
240
- 100% {
241
- opacity: 1;
242
- }
243
- }
244
-
245
- @keyframes loading-quiet {
246
- 0% {
247
- left: 0;
248
- right: 100%;
249
- }
250
-
251
- 50% {
252
- left: 0;
253
- right: 0;
254
- }
255
-
256
- 100% {
257
- left: 100%;
258
- right: 0;
259
- }
260
- }
@@ -1,110 +0,0 @@
1
- /**
2
- * WordPress dependencies.
3
- */
4
- import { __ as alias__ } from '@wordpress/i18n';
5
- const __ = alias__;
6
- import { category } from '@wordpress/icons';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
- import { Button, Handoff, NewspackIcon, Notice, HandoffMessage, TabbedNavigation } from '../';
12
- import { buttonProps } from '../../../shared/js/';
13
- import './style.scss';
14
-
15
- /**
16
- * External dependencies
17
- */
18
- import classnames from 'classnames';
19
-
20
- /**
21
- * Higher-Order Component to provide plugin management and error handling to Newspack Wizards.
22
- */
23
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
24
- export default function withWizardScreen(WrappedComponent, {
25
- hidePrimaryButton
26
- } = {}) {
27
- const WrappedWithWizardScreen = props => {
28
- const {
29
- className,
30
- buttonText,
31
- buttonAction,
32
- buttonDisabled,
33
- headerText,
34
- subHeaderText,
35
- tabbedNavigation,
36
- secondaryButtonText,
37
- secondaryButtonAction,
38
- renderAboveContent,
39
- disableUpcomingInTabbedNavigation
40
- } = props;
41
- const retrievedButtonProps = buttonProps(buttonAction);
42
- const retrievedSecondaryButtonProps = buttonProps(secondaryButtonAction);
43
- const SecondaryCTAComponent = retrievedSecondaryButtonProps.plugin ? Handoff : Button;
44
- const shouldRenderPrimaryButton = buttonText && buttonAction;
45
- const shouldRenderSecondaryButton = secondaryButtonText && secondaryButtonAction;
46
- const renderPrimaryButton = (overridingProps = {}) => retrievedButtonProps.plugin ? _jsx(Handoff, {
47
- isPrimary: true,
48
- ...retrievedButtonProps,
49
- ...overridingProps,
50
- children: buttonText
51
- }) : _jsx(Button, {
52
- isPrimary: !buttonDisabled,
53
- isSecondary: !!buttonDisabled,
54
- disabled: buttonDisabled
55
- // Allow overridingProps to set children.
56
- // eslint-disable-next-line react/no-children-prop
57
- ,
58
- children: buttonText,
59
- ...retrievedButtonProps,
60
- ...overridingProps
61
- });
62
- return _jsxs(_Fragment, {
63
- children: [newspack_aux_data.is_debug_mode && _jsx(Notice, {
64
- debugMode: true
65
- }), _jsx("div", {
66
- className: "newspack-wizard__header",
67
- children: _jsx("div", {
68
- className: "newspack-wizard__header__inner",
69
- children: _jsxs("div", {
70
- className: "newspack-wizard__title",
71
- children: [_jsx(Button, {
72
- isLink: true,
73
- href: newspack_urls.dashboard,
74
- label: __('Return to Dashboard', 'newspack-plugin'),
75
- showTooltip: true,
76
- icon: category,
77
- iconSize: 36,
78
- children: _jsx(NewspackIcon, {
79
- size: 36
80
- })
81
- }), _jsxs("div", {
82
- children: [headerText && _jsx("h2", {
83
- children: headerText
84
- }), subHeaderText && _jsx("span", {
85
- children: subHeaderText
86
- })]
87
- })]
88
- })
89
- })
90
- }), tabbedNavigation && _jsx(TabbedNavigation, {
91
- disableUpcoming: disableUpcomingInTabbedNavigation,
92
- items: tabbedNavigation.filter(item => !item.isHiddenInNav)
93
- }), _jsx(HandoffMessage, {}), _jsxs("div", {
94
- className: classnames('newspack-wizard newspack-wizard__content', className),
95
- children: [typeof renderAboveContent === 'function' ? renderAboveContent() : null, _jsx(WrappedComponent, {
96
- ...props,
97
- renderPrimaryButton: renderPrimaryButton
98
- }), (shouldRenderPrimaryButton || shouldRenderSecondaryButton) && _jsxs("div", {
99
- className: "newspack-buttons-card",
100
- children: [shouldRenderPrimaryButton && !hidePrimaryButton && renderPrimaryButton(), shouldRenderSecondaryButton && _jsx(SecondaryCTAComponent, {
101
- isSecondary: true,
102
- ...retrievedSecondaryButtonProps,
103
- children: secondaryButtonText
104
- })]
105
- })]
106
- })]
107
- });
108
- };
109
- return WrappedWithWizardScreen;
110
- }