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,317 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = withWizard;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _element = require("@wordpress/element");
10
- var _i18n = require("@wordpress/i18n");
11
- var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
12
- var _icons = require("@wordpress/icons");
13
- var _ = require("../");
14
- var _router = _interopRequireDefault(require("../proxied-imports/router"));
15
- var _footer = _interopRequireDefault(require("../footer"));
16
- require("./style.scss");
17
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
18
- /**
19
- * WordPress dependencies.
20
- */
21
- const __ = _i18n.__;
22
- /**
23
- * Internal dependencies.
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
- (0, _defineProperty2.default)(this, "componentDidMount", () => {
38
- // If there are no requiredPlugins, fire onWizardReady as soon as component mounts.
39
- if (!requiredPlugins) {
40
- const instance = this.wrappedComponentRef.current;
41
- // eslint-disable-next-line no-unused-expressions
42
- instance && instance.onWizardReady && instance.onWizardReady();
43
- }
44
- });
45
- /**
46
- * Set the error. Called by Wizards when an error occurs.
47
- *
48
- * @return {Promise} Resolved after state update
49
- */
50
- (0, _defineProperty2.default)(this, "setError", error => {
51
- return new Promise(resolve => {
52
- this.setState({
53
- error: error || null
54
- }, () => resolve());
55
- });
56
- });
57
- /**
58
- * Render any errors that need rendering.
59
- *
60
- * @return {Component} Error UI
61
- */
62
- (0, _defineProperty2.default)(this, "getError", () => {
63
- const {
64
- error
65
- } = this.state;
66
- if (!error) {
67
- return null;
68
- }
69
- const parsedError = this.parseError(error);
70
- const {
71
- level
72
- } = parsedError;
73
- if ('fatal' === level) {
74
- return this.getFatalError(parsedError);
75
- }
76
- return this.getErrorNotice(parsedError);
77
- });
78
- /**
79
- * Get a notice-level error.
80
- *
81
- * @param {Error} error object already parsed by parseError
82
- * @return {Component} Error notice
83
- */
84
- (0, _defineProperty2.default)(this, "getErrorNotice", error => {
85
- const {
86
- message
87
- } = error;
88
- return (0, _jsxRuntime.jsx)(_.Notice, {
89
- isError: true,
90
- className: "newspack-wizard__above-header",
91
- noticeText: message,
92
- rawHTML: true
93
- });
94
- });
95
- /**
96
- * Get a fatal-level error.
97
- *
98
- * @param {Error} error object already parsed by parseError
99
- * @return {Component} React object
100
- */
101
- (0, _defineProperty2.default)(this, "getFatalError", error => {
102
- const fallbackURL = this.getFallbackURL();
103
- if (!fallbackURL) {
104
- return null;
105
- }
106
- const {
107
- message
108
- } = error;
109
- return (0, _jsxRuntime.jsxs)(_.Modal, {
110
- title: __('Unrecoverable error'),
111
- onRequestClose: () => window.location = fallbackURL,
112
- children: [(0, _jsxRuntime.jsx)(_.Notice, {
113
- noticeText: message,
114
- isError: true,
115
- rawHTML: true
116
- }), (0, _jsxRuntime.jsx)(_.Card, {
117
- buttonsCard: true,
118
- noBorder: true,
119
- className: "justify-end",
120
- children: (0, _jsxRuntime.jsx)(_.Button, {
121
- isPrimary: true,
122
- href: fallbackURL,
123
- children: __('Return to Dashboard', 'newspack-plugin')
124
- })
125
- })]
126
- });
127
- });
128
- /**
129
- * Get all the relevant info out of a raw API error response.
130
- *
131
- * @param {Object} error error object
132
- * @return {Object} Error object with relevant fields and defaults
133
- */
134
- (0, _defineProperty2.default)(this, "parseError", error => {
135
- const {
136
- data,
137
- message,
138
- code
139
- } = error;
140
- let level = 'fatal';
141
- if (!!data && 'level' in data) {
142
- level = data.level;
143
- } else if ('rest_invalid_param' === code) {
144
- level = 'notice';
145
- }
146
- return {
147
- message,
148
- level
149
- };
150
- });
151
- /**
152
- * Called when plugin installation is complete. Updates state and calls onWizardReady on the wrapped component.
153
- */
154
- (0, _defineProperty2.default)(this, "pluginInstallationStatus", ({
155
- complete
156
- }) => {
157
- if (this.state.loading) {
158
- this.doneLoading();
159
- }
160
- const instance = this.wrappedComponentRef.current;
161
- this.setState({
162
- complete
163
- }, () => {
164
- // eslint-disable-next-line no-unused-expressions
165
- complete && instance && instance.onWizardReady && instance.onWizardReady();
166
- });
167
- });
168
- /**
169
- * Begin loading.
170
- */
171
- (0, _defineProperty2.default)(this, "startLoading", quiet => {
172
- if (quiet) {
173
- this.setState(state => ({
174
- quietLoading: state.quietLoading + 1
175
- }));
176
- } else {
177
- this.setState(state => ({
178
- loading: state.loading + 1
179
- }));
180
- }
181
- });
182
- /**
183
- * End loading.
184
- */
185
- (0, _defineProperty2.default)(this, "doneLoading", quiet => {
186
- if (quiet) {
187
- this.setState(state => ({
188
- quietLoading: state.quietLoading - 1
189
- }));
190
- } else {
191
- this.setState(state => ({
192
- loading: state.loading - 1
193
- }));
194
- }
195
- });
196
- /**
197
- * Replacement for core apiFetch that automatically manages wizard loading UI.
198
- */
199
- (0, _defineProperty2.default)(this, "wizardApiFetch", args => {
200
- const {
201
- quiet
202
- } = args;
203
- this.startLoading(quiet);
204
- return new Promise((resolve, reject) => {
205
- (0, _apiFetch.default)(args).then(response => {
206
- this.doneLoading(quiet);
207
- resolve(response);
208
- }).catch(error => {
209
- this.doneLoading(quiet);
210
- reject(error);
211
- });
212
- });
213
- });
214
- /**
215
- * Render a Route that checks for plugin installation requirements, and redirects to '/' when all are done.
216
- *
217
- * @return {void}
218
- */
219
- (0, _defineProperty2.default)(this, "pluginRequirements", () => {
220
- const {
221
- complete
222
- } = this.state;
223
- /* After all plugins are loaded, redirect to / (this could be configurable) */
224
- if (complete) {
225
- return (0, _jsxRuntime.jsx)(Redirect, {
226
- from: "/plugin-requirements",
227
- to: "/"
228
- });
229
- }
230
- return (0, _jsxRuntime.jsx)(Route, {
231
- path: "/",
232
- render: () => (0, _jsxRuntime.jsxs)(_element.Fragment, {
233
- children: [complete !== null && (0, _jsxRuntime.jsx)("div", {
234
- className: "newspack-wizard__header",
235
- children: (0, _jsxRuntime.jsx)("div", {
236
- className: "newspack-wizard__header__inner",
237
- children: (0, _jsxRuntime.jsxs)("div", {
238
- className: "newspack-wizard__title",
239
- children: [(0, _jsxRuntime.jsx)(_.Button, {
240
- isLink: true,
241
- href: newspack_urls.dashboard,
242
- label: __('Return to Dashboard', 'newspack-plugin'),
243
- showTooltip: true,
244
- icon: _icons.home,
245
- iconSize: 36,
246
- children: (0, _jsxRuntime.jsx)(_.NewspackIcon, {
247
- size: 36
248
- })
249
- }), (0, _jsxRuntime.jsx)("div", {
250
- children: (0, _jsxRuntime.jsx)("h2", {
251
- children: requiredPlugins.length > 1 ? __('Required plugins', 'newspack-plugin') : __('Required plugin', 'newspack-plugin')
252
- })
253
- })]
254
- })
255
- })
256
- }), (0, _jsxRuntime.jsx)("div", {
257
- className: "newspack-wizard newspack-wizard__content",
258
- children: (0, _jsxRuntime.jsx)(_.PluginInstaller, {
259
- plugins: requiredPlugins,
260
- onStatus: status => this.pluginInstallationStatus(status)
261
- })
262
- })]
263
- })
264
- });
265
- });
266
- (0, _defineProperty2.default)(this, "getFallbackURL", () => {
267
- if (typeof newspack_urls !== 'undefined') {
268
- return newspack_urls.dashboard;
269
- }
270
- });
271
- this.state = {
272
- complete: null,
273
- error: null,
274
- loading: requiredPlugins && requiredPlugins.length > 0 ? 1 : 0,
275
- quietLoading: false
276
- };
277
- this.wrappedComponentRef = (0, _element.createRef)();
278
- }
279
- /**
280
- * Render.
281
- */
282
- render() {
283
- const {
284
- simpleFooter
285
- } = this.props;
286
- const {
287
- loading,
288
- quietLoading,
289
- error
290
- } = this.state;
291
- const loadingClasses = [loading ? 'newspack-wizard__is-loading' : 'newspack-wizard__is-loaded'];
292
- if (quietLoading) {
293
- loadingClasses.push('newspack-wizard__is-loading-quiet');
294
- }
295
- return (0, _jsxRuntime.jsxs)(_element.Fragment, {
296
- children: [this.getError(), (0, _jsxRuntime.jsx)("div", {
297
- className: loadingClasses.join(' '),
298
- children: (0, _jsxRuntime.jsx)(WrappedComponent, {
299
- pluginRequirements: requiredPlugins && this.pluginRequirements(),
300
- clearError: this.clearError,
301
- getError: this.getError,
302
- errorData: error,
303
- setError: this.setError,
304
- isLoading: loading,
305
- startLoading: this.startLoading,
306
- doneLoading: this.doneLoading,
307
- wizardApiFetch: this.wizardApiFetch,
308
- ref: this.wrappedComponentRef,
309
- ...this.props
310
- })
311
- }), !loading && (0, _jsxRuntime.jsx)(_footer.default, {
312
- simple: simpleFooter
313
- })]
314
- });
315
- }
316
- };
317
- }
@@ -1,160 +0,0 @@
1
- /**
2
- * With Wizard Screen
3
- */
4
-
5
- @use '~@wordpress/base-styles/colors' as wp-colors;
6
- @use '../../../shared/scss/colors';
7
-
8
- .newspack-wizard {
9
- // Color
10
- --wp-admin-theme-color: #{colors.$primary-500};
11
- --wp-admin-theme-color--rgb: #{colors.$primary-500--rgb};
12
- --wp-admin-theme-color-darker-10: #{colors.$primary-600};
13
- --wp-admin-theme-color-darker-10--rgb: #{colors.$primary-600--rgb};
14
- --wp-admin-theme-color-darker-20: #{colors.$primary-700};
15
- --wp-admin-theme-color-darker-20--rgb: #{colors.$primary-700--rgb};
16
-
17
- color: wp-colors.$gray-900;
18
-
19
- // Headings
20
- h1,
21
- h2,
22
- h3 {
23
- color: inherit;
24
- }
25
-
26
- h1 {
27
- line-height: 1.4;
28
- }
29
-
30
- // Links
31
- a {
32
- color: var( --wp-admin-theme-color );
33
-
34
- &:active,
35
- &:focus,
36
- &:hover {
37
- color: var( --wp-admin-theme-color-darker-10 );
38
- }
39
-
40
- &:focus {
41
- box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) var( --wp-admin-theme-color );
42
- outline: 3px solid transparent;
43
- }
44
- }
45
-
46
- &__header {
47
- background: white;
48
- }
49
-
50
- &__title {
51
- align-items: center;
52
- border-bottom: 1px solid wp-colors.$gray-300;
53
- display: flex;
54
-
55
- h2 {
56
- margin: 0;
57
- padding: 0;
58
- }
59
-
60
- > div {
61
- align-items: baseline;
62
- display: flex;
63
- padding: 0 24px;
64
-
65
- span {
66
- color: wp-colors.$gray-700;
67
- display: none;
68
- margin-left: 8px;
69
-
70
- @media screen and ( min-width: 744px ) {
71
- display: block;
72
- }
73
- }
74
- }
75
-
76
- svg {
77
- fill: white;
78
- margin: 0 !important;
79
-
80
- &.newspack-icon {
81
- flex: 0 0 36px;
82
- margin-bottom: -1px !important;
83
- }
84
-
85
- &:not( .newspack-icon ) {
86
- background: colors.$primary-500;
87
- left: 50%;
88
- margin: -28px 0 0 -28px !important;
89
- opacity: 0;
90
- padding: 10px;
91
- position: absolute;
92
- top: 50%;
93
- transition: opacity 125ms ease-in-out;
94
- }
95
- }
96
-
97
- .components-button.has-icon {
98
- padding: 0;
99
- position: relative;
100
-
101
- &:hover {
102
- svg {
103
- opacity: 1;
104
- }
105
- }
106
-
107
- &:focus-visible {
108
- outline: none !important;
109
-
110
- &::before {
111
- border: 2px solid white;
112
- border-radius: 2px;
113
- content: '';
114
- display: block;
115
- inset: 6px 6px 5px;
116
- position: absolute;
117
- }
118
- }
119
- }
120
- }
121
-
122
- &__content {
123
- margin: 0 auto;
124
- max-width: 1208px;
125
- padding: 0 16px;
126
-
127
- @media screen and ( min-width: 744px ) {
128
- padding: 32px 84px;
129
- }
130
-
131
- // Typography
132
-
133
- strong {
134
- font-weight: bold;
135
- }
136
-
137
- small {
138
- font-size: 12px;
139
- line-height: 1.4;
140
- }
141
-
142
- // Thematic Break
143
-
144
- hr {
145
- background: wp-colors.$gray-300;
146
- border: 0;
147
- height: 1px;
148
- margin: 48px 0;
149
-
150
- @media screen and ( min-width: 744px ) {
151
- margin: 64px 0;
152
- }
153
- }
154
- }
155
-
156
- &__above-header {
157
- border-radius: 0;
158
- margin: 0;
159
- }
160
- }
@@ -1,221 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /**
3
- * Action Card
4
- */
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { Component } from '@wordpress/element';
10
- import { ExternalLink, ToggleControl } from '@wordpress/components';
11
- import { Icon, check, chevronDown, chevronUp } from '@wordpress/icons';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
- import { Button, Card, Grid, Handoff, Notice, Waiting } from '../';
17
- import './style.scss';
18
-
19
- /**
20
- * External dependencies
21
- */
22
- import classnames from 'classnames';
23
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
24
- class ActionCard extends Component {
25
- constructor(...args) {
26
- super(...args);
27
- _defineProperty(this, "state", {
28
- expanded: false
29
- });
30
- }
31
- /**
32
- * When the collapse prop is updated to true, collapse the card if already expanded.
33
- */
34
- componentDidUpdate(prevProps) {
35
- if (!prevProps.collapse && this.props.collapse && this.state.expanded) {
36
- this.setState({
37
- expanded: false
38
- });
39
- }
40
- }
41
-
42
- /**
43
- * Render.
44
- */
45
- render() {
46
- const {
47
- badge,
48
- className,
49
- checkbox,
50
- children,
51
- disabled,
52
- title,
53
- description,
54
- handoff,
55
- editLink,
56
- href,
57
- notification,
58
- notificationLevel,
59
- notificationHTML,
60
- actionContent,
61
- actionText,
62
- secondaryActionText,
63
- secondaryDestructive,
64
- image,
65
- imageLink,
66
- indent,
67
- isSmall,
68
- isMedium,
69
- simple,
70
- onClick,
71
- onSecondaryActionClick,
72
- isWaiting,
73
- titleLink,
74
- toggleChecked,
75
- toggleOnChange,
76
- hasGreyHeader,
77
- hasWhiteHeader,
78
- isPending,
79
- expandable = false
80
- } = this.props;
81
- const {
82
- expanded
83
- } = this.state;
84
- const hasChildren = notification || children;
85
- const classes = classnames('newspack-action-card', simple && 'newspack-card--is-clickable', hasGreyHeader && 'newspack-card--has-grey-header', hasWhiteHeader && 'newspack-card--has-white-header', hasChildren && 'newspack-card--has-children', indent && 'newspack-card--indent', isSmall && 'is-small', isMedium && 'is-medium', checkbox && 'has-checkbox', expandable && 'is-expandable', actionContent && 'has-action-content', className);
86
- const backgroundImageStyles = url => {
87
- return url ? {
88
- backgroundImage: `url(${url})`
89
- } : {};
90
- };
91
- const titleProps = toggleOnChange && !titleLink && !disabled ? {
92
- onClick: () => toggleOnChange(!toggleChecked),
93
- tabIndex: '0'
94
- } : {};
95
- const hasInternalLink = href && href.indexOf('http') !== 0;
96
- const isDisplayingSecondaryAction = secondaryActionText && onSecondaryActionClick;
97
- const badges = !Array.isArray(badge) && badge ? [badge] : badge;
98
- return _jsxs(Card, {
99
- className: classes,
100
- onClick: simple && onClick,
101
- children: [_jsxs("div", {
102
- className: "newspack-action-card__region newspack-action-card__region-top",
103
- children: [toggleOnChange && _jsx(ToggleControl, {
104
- checked: toggleChecked,
105
- onChange: toggleOnChange,
106
- disabled: disabled
107
- }), image && !toggleOnChange && _jsx("div", {
108
- className: "newspack-action-card__region newspack-action-card__region-left",
109
- children: _jsx("a", {
110
- href: imageLink,
111
- children: _jsx("div", {
112
- className: "newspack-action-card__image",
113
- style: backgroundImageStyles(image)
114
- })
115
- })
116
- }), checkbox && !toggleOnChange && _jsx("div", {
117
- className: "newspack-action-card__region newspack-action-card__region-left",
118
- children: _jsx("span", {
119
- className: classnames('newspack-checkbox-icon', 'is-primary', 'checked' === checkbox && 'newspack-checkbox-icon--checked', isPending && 'newspack-checkbox-icon--pending'),
120
- children: 'checked' === checkbox && _jsx(Icon, {
121
- icon: check
122
- })
123
- })
124
- }), _jsx("div", {
125
- className: "newspack-action-card__region newspack-action-card__region-center",
126
- children: _jsxs(Grid, {
127
- columns: 1,
128
- gutter: 8,
129
- noMargin: true,
130
- children: [_jsxs("h2", {
131
- children: [_jsxs("span", {
132
- className: "newspack-action-card__title",
133
- ...titleProps,
134
- children: [titleLink && _jsx("a", {
135
- href: titleLink,
136
- children: title
137
- }), !titleLink && expandable && _jsx(Button, {
138
- isLink: true,
139
- onClick: () => this.setState({
140
- expanded: !expanded
141
- }),
142
- children: title
143
- }), !titleLink && !expandable && title]
144
- }), badges?.length && badges.map((badgeText, i) => _jsx("span", {
145
- className: "newspack-action-card__badge",
146
- children: badgeText
147
- }, `badge-${i}`))]
148
- }), description && _jsxs("p", {
149
- children: [typeof description === 'string' && description, typeof description === 'function' && description()]
150
- })]
151
- })
152
- }), !expandable && (actionText || isDisplayingSecondaryAction || actionContent) && _jsxs("div", {
153
- className: "newspack-action-card__region newspack-action-card__region-right",
154
- children: [actionContent && actionContent, actionText && (handoff ? _jsx(Handoff, {
155
- plugin: handoff,
156
- editLink: editLink,
157
- compact: true,
158
- isLink: true,
159
- children: actionText
160
- }) : onClick || hasInternalLink ? _jsx(Button, {
161
- disabled: disabled,
162
- isLink: true,
163
- href: href,
164
- onClick: onClick,
165
- className: "newspack-action-card__primary_button",
166
- children: actionText
167
- }) : href ? _jsx(ExternalLink, {
168
- href: href,
169
- className: "newspack-action-card__primary_button",
170
- children: actionText
171
- }) : _jsxs("div", {
172
- className: "newspack-action-card__container",
173
- children: [actionText, isWaiting && _jsx(Waiting, {
174
- isRight: true
175
- })]
176
- })), isDisplayingSecondaryAction && _jsx(Button, {
177
- isLink: true,
178
- onClick: onSecondaryActionClick,
179
- className: "newspack-action-card__secondary_button",
180
- isDestructive: secondaryDestructive,
181
- children: secondaryActionText
182
- })]
183
- }), expandable && _jsx(Button, {
184
- onClick: () => this.setState({
185
- expanded: !expanded
186
- }),
187
- children: _jsx(Icon, {
188
- icon: expanded ? chevronUp : chevronDown,
189
- height: 24,
190
- width: 24
191
- })
192
- })]
193
- }), notification && _jsxs("div", {
194
- className: "newspack-action-card__notification newspack-action-card__region-children",
195
- children: ['error' === notificationLevel && _jsx(Notice, {
196
- noticeText: notification,
197
- isError: true,
198
- rawHTML: notificationHTML
199
- }), 'info' === notificationLevel && _jsx(Notice, {
200
- noticeText: notification,
201
- rawHTML: notificationHTML
202
- }), 'success' === notificationLevel && _jsx(Notice, {
203
- noticeText: notification,
204
- isSuccess: true,
205
- rawHTML: notificationHTML
206
- }), 'warning' === notificationLevel && _jsx(Notice, {
207
- noticeText: notification,
208
- isWarning: true,
209
- rawHTML: notificationHTML
210
- })]
211
- }), children && (expandable && expanded || !expandable) && _jsx("div", {
212
- className: "newspack-action-card__region-children",
213
- children: children
214
- })]
215
- });
216
- }
217
- }
218
- ActionCard.defaultProps = {
219
- toggleChecked: false
220
- };
221
- export default ActionCard;