newspack-components 2.1.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/dist/cjs/accordion/index.js +46 -0
  2. package/dist/cjs/accordion/style.scss +27 -0
  3. package/dist/cjs/action-card/index.js +48 -25
  4. package/dist/cjs/action-card/style.scss +100 -23
  5. package/dist/cjs/autocomplete-tokenfield/index.js +13 -41
  6. package/dist/cjs/autocomplete-tokenfield/style.scss +2 -2
  7. package/dist/cjs/autocomplete-with-suggestions/index.js +30 -51
  8. package/dist/cjs/autocomplete-with-suggestions/style.scss +16 -15
  9. package/dist/cjs/button/index.js +5 -13
  10. package/dist/cjs/button-card/index.js +1 -10
  11. package/dist/cjs/button-card/style.scss +13 -13
  12. package/dist/cjs/card/index.js +1 -8
  13. package/dist/cjs/card/style.scss +25 -8
  14. package/dist/cjs/category-autocomplete/index.js +18 -38
  15. package/dist/cjs/category-autocomplete/style.scss +0 -2
  16. package/dist/cjs/color-picker/index.js +1 -15
  17. package/dist/cjs/color-picker/style.scss +0 -3
  18. package/dist/cjs/consts.js +5 -3
  19. package/dist/cjs/custom-select-control/index.js +1 -9
  20. package/dist/cjs/custom-select-control/style.scss +6 -7
  21. package/dist/cjs/date-range-picker/index.js +1 -10
  22. package/dist/cjs/date-range-picker/style.scss +12 -12
  23. package/dist/cjs/footer/index.js +5 -17
  24. package/dist/cjs/footer/style.scss +5 -5
  25. package/dist/cjs/form-token-field/index.js +1 -9
  26. package/dist/cjs/form-token-field/style.scss +2 -3
  27. package/dist/cjs/global-notices/index.js +1 -8
  28. package/dist/cjs/grid/index.js +1 -8
  29. package/dist/cjs/grid/style.scss +5 -5
  30. package/dist/cjs/handoff/index.js +8 -17
  31. package/dist/cjs/handoff-message/index.js +50 -0
  32. package/dist/cjs/hooks/index.js +1 -7
  33. package/dist/cjs/hooks/useObjectState.js +7 -13
  34. package/dist/cjs/hooks/useObjectState.test.js +0 -14
  35. package/dist/cjs/hooks/useOnClickOutside.js +3 -6
  36. package/dist/cjs/hooks/usePrompt.js +1 -13
  37. package/dist/cjs/image-upload/index.js +21 -19
  38. package/dist/cjs/image-upload/index.test.js +0 -5
  39. package/dist/cjs/image-upload/style.scss +5 -9
  40. package/dist/cjs/index.js +28 -44
  41. package/dist/cjs/info-button/index.js +3 -11
  42. package/dist/cjs/info-button/style.scss +1 -3
  43. package/dist/cjs/modal/index.js +1 -9
  44. package/dist/cjs/modal/style.scss +8 -8
  45. package/dist/cjs/newspack-icon/index.js +1 -9
  46. package/dist/cjs/newspack-icon/style.scss +4 -4
  47. package/dist/cjs/newspack-logo/index.js +1 -9
  48. package/dist/cjs/newspack-logo/style.scss +3 -3
  49. package/dist/cjs/notice/index.js +8 -15
  50. package/dist/cjs/notice/style.scss +28 -15
  51. package/dist/cjs/patrons-logo/index.js +3 -11
  52. package/dist/cjs/plugin-installer/index.js +36 -36
  53. package/dist/cjs/plugin-installer/style.scss +5 -5
  54. package/dist/cjs/plugin-settings/SettingsSection.js +9 -28
  55. package/dist/cjs/plugin-settings/index.js +39 -22
  56. package/dist/cjs/plugin-toggle/index.js +40 -33
  57. package/dist/cjs/plugin-toggle/style.scss +2 -2
  58. package/dist/cjs/popover/index.js +1 -11
  59. package/dist/cjs/popover/style.scss +19 -16
  60. package/dist/cjs/position-control/index.js +113 -0
  61. package/dist/cjs/position-control/style.scss +66 -0
  62. package/dist/cjs/progress-bar/index.js +2 -9
  63. package/dist/cjs/progress-bar/index.test.js +2 -7
  64. package/dist/cjs/progress-bar/style.scss +4 -4
  65. package/dist/cjs/proxied-imports/router.js +0 -3
  66. package/dist/cjs/radio-control/index.js +1 -11
  67. package/dist/cjs/radio-control/style.scss +9 -9
  68. package/dist/cjs/section-header/index.js +44 -29
  69. package/dist/cjs/section-header/style.scss +2 -2
  70. package/dist/cjs/select-control/ButtonGroupControl.js +4 -13
  71. package/dist/cjs/select-control/GroupedSelectControl.js +9 -15
  72. package/dist/cjs/select-control/index.js +5 -12
  73. package/dist/cjs/select-control/style.scss +2 -2
  74. package/dist/cjs/settings/MinMaxSetting.js +3 -7
  75. package/dist/cjs/settings/SettingsCard.js +3 -7
  76. package/dist/cjs/settings/SettingsSection.js +1 -4
  77. package/dist/cjs/settings/index.js +0 -6
  78. package/dist/cjs/settings/style.scss +1 -1
  79. package/dist/cjs/steps-list/index.js +52 -0
  80. package/dist/cjs/steps-list/style.scss +11 -0
  81. package/dist/cjs/steps-list-item/index.js +56 -0
  82. package/dist/cjs/steps-list-item/style.scss +47 -0
  83. package/dist/cjs/style-card/index.js +6 -13
  84. package/dist/cjs/style-card/style.scss +9 -12
  85. package/dist/cjs/style.scss +5 -6
  86. package/dist/cjs/tabbed-navigation/index.js +19 -16
  87. package/dist/cjs/tabbed-navigation/style.scss +3 -4
  88. package/dist/cjs/text-control/index.js +6 -16
  89. package/dist/cjs/utils/index.js +10 -5
  90. package/dist/cjs/waiting/index.js +1 -9
  91. package/dist/cjs/web-preview/index.js +13 -28
  92. package/dist/cjs/web-preview/style.scss +14 -14
  93. package/dist/cjs/with-wizard/index.js +51 -31
  94. package/dist/cjs/with-wizard/style.scss +35 -37
  95. package/dist/cjs/with-wizard-screen/index.js +11 -17
  96. package/dist/cjs/with-wizard-screen/style.scss +14 -17
  97. package/dist/cjs/wizard/components/WizardError.js +3 -15
  98. package/dist/cjs/wizard/index.js +10 -24
  99. package/dist/cjs/wizard/store/index.js +42 -55
  100. package/dist/cjs/wizard/store/utils.js +1 -6
  101. package/dist/esm/accordion/index.js +38 -0
  102. package/dist/esm/accordion/style.scss +27 -0
  103. package/dist/esm/action-card/index.js +50 -21
  104. package/dist/esm/action-card/style.scss +100 -23
  105. package/dist/esm/autocomplete-tokenfield/index.js +14 -37
  106. package/dist/esm/autocomplete-tokenfield/style.scss +2 -2
  107. package/dist/esm/autocomplete-with-suggestions/index.js +28 -41
  108. package/dist/esm/autocomplete-with-suggestions/style.scss +16 -15
  109. package/dist/esm/button/index.js +5 -7
  110. package/dist/esm/button-card/index.js +2 -5
  111. package/dist/esm/button-card/style.scss +13 -13
  112. package/dist/esm/card/index.js +2 -5
  113. package/dist/esm/card/style.scss +25 -8
  114. package/dist/esm/category-autocomplete/index.js +17 -30
  115. package/dist/esm/category-autocomplete/style.scss +0 -2
  116. package/dist/esm/color-picker/index.js +2 -4
  117. package/dist/esm/color-picker/style.scss +0 -3
  118. package/dist/esm/consts.js +3 -2
  119. package/dist/esm/custom-select-control/index.js +2 -5
  120. package/dist/esm/custom-select-control/style.scss +6 -7
  121. package/dist/esm/date-range-picker/index.js +1 -3
  122. package/dist/esm/date-range-picker/style.scss +12 -12
  123. package/dist/esm/footer/index.js +3 -11
  124. package/dist/esm/footer/style.scss +5 -5
  125. package/dist/esm/form-token-field/index.js +2 -5
  126. package/dist/esm/form-token-field/style.scss +2 -3
  127. package/dist/esm/global-notices/index.js +1 -6
  128. package/dist/esm/grid/index.js +2 -5
  129. package/dist/esm/grid/style.scss +5 -5
  130. package/dist/esm/handoff/index.js +3 -14
  131. package/dist/esm/handoff-message/index.js +45 -0
  132. package/dist/esm/hooks/index.js +0 -2
  133. package/dist/esm/hooks/useObjectState.js +3 -8
  134. package/dist/esm/hooks/useObjectState.test.js +0 -3
  135. package/dist/esm/hooks/useOnClickOutside.js +2 -5
  136. package/dist/esm/hooks/usePrompt.js +1 -8
  137. package/dist/esm/image-upload/index.js +17 -16
  138. package/dist/esm/image-upload/style.scss +5 -9
  139. package/dist/esm/index.js +4 -0
  140. package/dist/esm/info-button/index.js +4 -6
  141. package/dist/esm/info-button/style.scss +1 -3
  142. package/dist/esm/modal/index.js +2 -5
  143. package/dist/esm/modal/style.scss +8 -8
  144. package/dist/esm/newspack-icon/index.js +2 -5
  145. package/dist/esm/newspack-icon/style.scss +4 -4
  146. package/dist/esm/newspack-logo/index.js +2 -5
  147. package/dist/esm/newspack-logo/style.scss +3 -3
  148. package/dist/esm/notice/index.js +4 -8
  149. package/dist/esm/notice/style.scss +28 -15
  150. package/dist/esm/patrons-logo/index.js +3 -5
  151. package/dist/esm/plugin-installer/index.js +35 -39
  152. package/dist/esm/plugin-installer/style.scss +5 -5
  153. package/dist/esm/plugin-settings/SettingsSection.js +8 -21
  154. package/dist/esm/plugin-settings/index.js +38 -24
  155. package/dist/esm/plugin-toggle/index.js +39 -36
  156. package/dist/esm/plugin-toggle/style.scss +2 -2
  157. package/dist/esm/popover/index.js +3 -6
  158. package/dist/esm/popover/style.scss +19 -16
  159. package/dist/esm/position-control/index.js +109 -0
  160. package/dist/esm/position-control/style.scss +66 -0
  161. package/dist/esm/progress-bar/index.js +2 -7
  162. package/dist/esm/progress-bar/index.test.js +2 -1
  163. package/dist/esm/progress-bar/style.scss +4 -4
  164. package/dist/esm/proxied-imports/router.js +1 -0
  165. package/dist/esm/radio-control/index.js +3 -6
  166. package/dist/esm/radio-control/style.scss +9 -9
  167. package/dist/esm/section-header/index.js +44 -25
  168. package/dist/esm/section-header/style.scss +2 -2
  169. package/dist/esm/select-control/ButtonGroupControl.js +5 -7
  170. package/dist/esm/select-control/GroupedSelectControl.js +5 -6
  171. package/dist/esm/select-control/index.js +6 -6
  172. package/dist/esm/select-control/style.scss +2 -2
  173. package/dist/esm/settings/MinMaxSetting.js +1 -3
  174. package/dist/esm/settings/SettingsCard.js +3 -4
  175. package/dist/esm/settings/SettingsSection.js +0 -2
  176. package/dist/esm/settings/style.scss +1 -1
  177. package/dist/esm/steps-list/index.js +43 -0
  178. package/dist/esm/steps-list/style.scss +11 -0
  179. package/dist/esm/steps-list-item/index.js +48 -0
  180. package/dist/esm/steps-list-item/style.scss +47 -0
  181. package/dist/esm/style-card/index.js +2 -5
  182. package/dist/esm/style-card/style.scss +9 -12
  183. package/dist/esm/style.scss +5 -6
  184. package/dist/esm/tabbed-navigation/index.js +20 -10
  185. package/dist/esm/tabbed-navigation/style.scss +3 -4
  186. package/dist/esm/text-control/index.js +2 -9
  187. package/dist/esm/utils/index.js +9 -3
  188. package/dist/esm/waiting/index.js +2 -5
  189. package/dist/esm/web-preview/index.js +9 -24
  190. package/dist/esm/web-preview/style.scss +14 -14
  191. package/dist/esm/with-wizard/index.js +49 -34
  192. package/dist/esm/with-wizard/style.scss +35 -37
  193. package/dist/esm/with-wizard-screen/index.js +9 -11
  194. package/dist/esm/with-wizard-screen/style.scss +14 -17
  195. package/dist/esm/wizard/components/WizardError.js +1 -10
  196. package/dist/esm/wizard/index.js +10 -12
  197. package/dist/esm/wizard/store/index.js +40 -46
  198. package/dist/esm/wizard/store/utils.js +1 -1
  199. package/package.json +4 -4
  200. package/shared/js/button-props.js +3 -1
  201. package/shared/scss/_mixins.scss +12 -0
  202. package/src/accordion/index.js +32 -0
  203. package/src/accordion/style.scss +27 -0
  204. package/src/action-card/index.js +43 -8
  205. package/src/action-card/style.scss +100 -23
  206. package/src/autocomplete-tokenfield/index.js +1 -1
  207. package/src/autocomplete-tokenfield/style.scss +2 -2
  208. package/src/autocomplete-with-suggestions/style.scss +16 -15
  209. package/src/button-card/style.scss +13 -13
  210. package/src/card/style.scss +25 -8
  211. package/src/category-autocomplete/index.js +3 -1
  212. package/src/category-autocomplete/style.scss +0 -2
  213. package/src/color-picker/style.scss +0 -3
  214. package/src/consts.js +2 -1
  215. package/src/custom-select-control/style.scss +6 -7
  216. package/src/date-range-picker/style.scss +12 -12
  217. package/src/footer/index.js +2 -2
  218. package/src/footer/style.scss +5 -5
  219. package/src/form-token-field/index.js +2 -7
  220. package/src/form-token-field/style.scss +2 -3
  221. package/src/grid/style.scss +5 -5
  222. package/src/handoff/index.js +3 -8
  223. package/src/handoff-message/index.js +39 -0
  224. package/src/hooks/useObjectState.js +2 -1
  225. package/src/image-upload/index.js +9 -3
  226. package/src/image-upload/style.scss +5 -9
  227. package/src/index.js +4 -0
  228. package/src/info-button/style.scss +1 -3
  229. package/src/modal/style.scss +8 -8
  230. package/src/newspack-icon/style.scss +4 -4
  231. package/src/newspack-logo/style.scss +3 -3
  232. package/src/notice/index.js +2 -0
  233. package/src/notice/style.scss +28 -15
  234. package/src/plugin-installer/index.js +15 -2
  235. package/src/plugin-installer/style.scss +5 -5
  236. package/src/plugin-settings/SettingsSection.js +7 -13
  237. package/src/plugin-settings/index.js +7 -2
  238. package/src/plugin-toggle/index.js +2 -3
  239. package/src/plugin-toggle/style.scss +2 -2
  240. package/src/popover/style.scss +19 -16
  241. package/src/position-control/index.js +122 -0
  242. package/src/position-control/style.scss +66 -0
  243. package/src/progress-bar/style.scss +4 -4
  244. package/src/radio-control/style.scss +9 -9
  245. package/src/section-header/index.js +32 -15
  246. package/src/section-header/style.scss +2 -2
  247. package/src/select-control/ButtonGroupControl.js +3 -0
  248. package/src/select-control/GroupedSelectControl.js +2 -1
  249. package/src/select-control/index.js +6 -2
  250. package/src/select-control/style.scss +2 -2
  251. package/src/settings/style.scss +1 -1
  252. package/src/steps-list/index.js +39 -0
  253. package/src/steps-list/style.scss +11 -0
  254. package/src/steps-list-item/index.js +40 -0
  255. package/src/steps-list-item/style.scss +47 -0
  256. package/src/style-card/index.js +2 -11
  257. package/src/style-card/style.scss +9 -12
  258. package/src/style.scss +5 -6
  259. package/src/tabbed-navigation/index.js +12 -4
  260. package/src/tabbed-navigation/style.scss +3 -4
  261. package/src/utils/index.js +9 -0
  262. package/src/web-preview/index.js +1 -1
  263. package/src/web-preview/style.scss +14 -14
  264. package/src/with-wizard/style.scss +35 -37
  265. package/src/with-wizard-screen/index.js +4 -1
  266. package/src/with-wizard-screen/style.scss +14 -17
  267. package/src/wizard/index.js +15 -3
  268. package/src/wizard/store/index.js +8 -2
@@ -1,5 +1,4 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  /**
4
3
  * Handoff
5
4
  */
@@ -10,25 +9,23 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
9
  import apiFetch from '@wordpress/api-fetch';
11
10
  import { Component, Fragment } from '@wordpress/element';
12
11
  import { __ as alias__ } from '@wordpress/i18n';
12
+
13
13
  /**
14
14
  * Internal dependencies.
15
15
  */
16
-
17
16
  const __ = alias__;
18
17
  import { Button, Card, Modal, Waiting } from '../';
18
+
19
19
  /**
20
20
  * External dependencies.
21
21
  */
22
-
23
- import { assign } from 'lodash';
22
+ import assign from 'lodash/assign';
24
23
  import classnames from 'classnames';
25
24
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
26
25
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
27
-
28
26
  class Handoff extends Component {
29
27
  constructor() {
30
28
  super(...arguments);
31
-
32
29
  _defineProperty(this, "componentDidMount", () => {
33
30
  this._isMounted = true;
34
31
  const {
@@ -36,11 +33,9 @@ class Handoff extends Component {
36
33
  } = this.props;
37
34
  this.retrievePluginInfo(plugin);
38
35
  });
39
-
40
36
  _defineProperty(this, "componentWillUnmount", () => {
41
37
  this._isMounted = false;
42
38
  });
43
-
44
39
  _defineProperty(this, "retrievePluginInfo", plugin => {
45
40
  const {
46
41
  onReady
@@ -56,7 +51,6 @@ class Handoff extends Component {
56
51
  }
57
52
  });
58
53
  });
59
-
60
54
  _defineProperty(this, "textForPlugin", pluginInfo => {
61
55
  const defaults = {
62
56
  modalBody: null,
@@ -67,7 +61,6 @@ class Handoff extends Component {
67
61
  };
68
62
  return assign(defaults, this.props);
69
63
  });
70
-
71
64
  _defineProperty(this, "goToPlugin", plugin => {
72
65
  const {
73
66
  editLink,
@@ -85,13 +78,11 @@ class Handoff extends Component {
85
78
  window.location.href = response.HandoffLink;
86
79
  });
87
80
  });
88
-
89
81
  this.state = {
90
82
  pluginInfo: [],
91
83
  showModal: false
92
84
  };
93
85
  }
94
-
95
86
  /**
96
87
  * Render.
97
88
  */
@@ -179,9 +170,7 @@ class Handoff extends Component {
179
170
  })]
180
171
  });
181
172
  }
182
-
183
173
  }
184
-
185
174
  Handoff.defaultProps = {
186
175
  onReady: () => {}
187
176
  };
@@ -0,0 +1,45 @@
1
+ /**
2
+ * WordPress dependencies.
3
+ */
4
+ import { useEffect, useState } from '@wordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies.
8
+ */
9
+ import { HANDOFF_KEY } from '../consts';
10
+ import { Notice } from '../';
11
+
12
+ /**
13
+ * Handoff Message Component.
14
+ */
15
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
16
+ export default function HandoffMessage() {
17
+ const [handoffMessage, setHandoffMessage] = useState(false);
18
+ useEffect(() => {
19
+ // Slight delay to allow for localStorage to be updated by RAS component.
20
+ setTimeout(() => {
21
+ const handoff = JSON.parse(localStorage.getItem(HANDOFF_KEY));
22
+ if (handoff?.message) {
23
+ setHandoffMessage(handoff.message);
24
+ } else {
25
+ setHandoffMessage(false);
26
+ }
27
+
28
+ // Clean up the notification if navigating away from the relevant page.
29
+ if (handoff?.url && -1 === window.location.href.indexOf(handoff.url)) {
30
+ window.localStorage.removeItem(HANDOFF_KEY);
31
+ setHandoffMessage(false);
32
+ }
33
+ }, 100);
34
+
35
+ // Clean up the notification when unmounting.
36
+ return () => window.localStorage.removeItem(HANDOFF_KEY);
37
+ }, []);
38
+ if (!handoffMessage) return null;
39
+ return _jsx(Notice, {
40
+ isHandoff: true,
41
+ isDismissible: false,
42
+ rawHTML: true,
43
+ noticeText: handoffMessage
44
+ });
45
+ }
@@ -5,12 +5,10 @@ import { useRef } from '@wordpress/element';
5
5
  import usePrompt from './usePrompt';
6
6
  import useObjectState from './useObjectState';
7
7
  import useOnClickOutside from './useOnClickOutside';
8
-
9
8
  const useUniqueId = prefix => {
10
9
  const id = useRef(`${prefix}-${Math.round(Math.random() * 99999)}`);
11
10
  return id.current;
12
11
  };
13
-
14
12
  export default {
15
13
  usePrompt,
16
14
  useObjectState,
@@ -2,35 +2,30 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useState } from '@wordpress/element';
5
- import { mergeWith, isArray } from 'lodash';
6
-
5
+ import isArray from 'lodash/isArray';
6
+ import mergeWith from 'lodash/mergeWith';
7
7
  const mergeCustomizer = (objValue, srcValue) => {
8
8
  if (isArray(objValue)) {
9
9
  // If it's an array, replace it (instead of concatenating).
10
10
  return srcValue;
11
11
  }
12
12
  };
13
+
13
14
  /**
14
15
  * A useState for an object.
15
16
  * Nested objects will be nested, but arrays replaced.
16
17
  */
17
-
18
-
19
18
  export default (function () {
20
19
  let initial = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
21
20
  const [stateObject, setStateObject] = useState(initial);
22
-
23
21
  const runUpdate = update => setStateObject(_stateObject => mergeWith({}, _stateObject, update, mergeCustomizer));
24
-
25
22
  const updateStateObject = keyOrUpdate => {
26
23
  if (typeof keyOrUpdate === 'string') {
27
24
  return value => runUpdate({
28
25
  [keyOrUpdate]: value
29
26
  });
30
27
  }
31
-
32
28
  runUpdate(keyOrUpdate);
33
29
  };
34
-
35
30
  return [stateObject, updateStateObject];
36
31
  });
@@ -11,7 +11,6 @@ const INIT_STATE = {
11
11
  baz: 1
12
12
  }
13
13
  };
14
-
15
14
  const TestComponent = () => {
16
15
  const [state, updateState] = useObjectState(INIT_STATE);
17
16
  return _jsxs("div", {
@@ -46,10 +45,8 @@ const TestComponent = () => {
46
45
  })]
47
46
  });
48
47
  };
49
-
50
48
  describe('useObjectState', () => {
51
49
  const getState = () => JSON.parse(screen.getByPlaceholderText('state').getAttribute('value'));
52
-
53
50
  beforeEach(() => {
54
51
  render(_jsx(TestComponent, {}));
55
52
  });
@@ -4,7 +4,6 @@
4
4
  * External dependencies.
5
5
  */
6
6
  import { useEffect } from '@wordpress/element';
7
-
8
7
  const useOnClickOutside = (ref, handler) => {
9
8
  useEffect(() => {
10
9
  const listener = event => {
@@ -12,17 +11,16 @@ const useOnClickOutside = (ref, handler) => {
12
11
  if (!ref.current || ref.current.contains(event.target)) {
13
12
  return;
14
13
  }
15
-
16
14
  handler(event);
17
15
  };
18
-
19
16
  document.addEventListener('mousedown', listener);
20
17
  document.addEventListener('touchstart', listener);
21
18
  return () => {
22
19
  document.removeEventListener('mousedown', listener);
23
20
  document.removeEventListener('touchstart', listener);
24
21
  };
25
- }, // Add ref and handler to effect dependencies
22
+ },
23
+ // Add ref and handler to effect dependencies
26
24
  // It's worth noting that because passed in handler is a new ...
27
25
  // ... function on every render that will cause this effect ...
28
26
  // ... callback/cleanup to run every render. It's not a big deal ...
@@ -30,5 +28,4 @@ const useOnClickOutside = (ref, handler) => {
30
28
  // ... passing it into this hook.
31
29
  [ref, handler]);
32
30
  };
33
-
34
31
  export default useOnClickOutside;
@@ -4,10 +4,10 @@
4
4
  * External dependencies.
5
5
  */
6
6
  import { useEffect, useRef } from '@wordpress/element';
7
+
7
8
  /**
8
9
  * Internal dependencies.
9
10
  */
10
-
11
11
  import Router from '../proxied-imports/router';
12
12
  const {
13
13
  useHistory
@@ -15,34 +15,27 @@ const {
15
15
  export default ((when, message) => {
16
16
  const history = useHistory();
17
17
  const self = useRef(null);
18
-
19
18
  const onWindowOrTabClose = event => {
20
19
  if (!when) {
21
20
  return;
22
21
  }
23
-
24
22
  if (typeof event === 'undefined') {
25
23
  event = window.event;
26
24
  }
27
-
28
25
  if (event) {
29
26
  event.returnValue = message;
30
27
  }
31
-
32
28
  return message;
33
29
  };
34
-
35
30
  useEffect(() => {
36
31
  if (when) {
37
32
  self.current = history.block(message);
38
33
  window.addEventListener('beforeunload', onWindowOrTabClose);
39
34
  }
40
-
41
35
  return () => {
42
36
  if (self.current) {
43
37
  self.current();
44
38
  }
45
-
46
39
  window.removeEventListener('beforeunload', onWindowOrTabClose);
47
40
  };
48
41
  }, [message, when]);
@@ -1,5 +1,4 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  /**
4
3
  * Image Upload
5
4
  */
@@ -9,35 +8,35 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
8
  */
10
9
  import { Component } from '@wordpress/element';
11
10
  import { __ as alias__ } from '@wordpress/i18n';
11
+
12
12
  /**
13
13
  * Internal dependencies.
14
14
  */
15
-
16
15
  const __ = alias__;
17
16
  import { Button, InfoButton } from '../';
18
17
  import './style.scss';
18
+
19
19
  /**
20
20
  * External dependencies.
21
21
  */
22
-
23
22
  import classnames from 'classnames';
24
23
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
25
24
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
26
25
  import { Fragment as _Fragment } from "@emotion/react/jsx-runtime";
27
-
28
26
  class ImageUpload extends Component {
29
27
  /**
30
28
  * Constructor.
31
29
  */
32
30
  constructor() {
33
31
  super(...arguments);
34
-
32
+ /**
33
+ * Open the WP media modal.
34
+ */
35
35
  _defineProperty(this, "openModal", () => {
36
36
  if (this.state.frame) {
37
37
  this.state.frame.open();
38
38
  return;
39
39
  }
40
-
41
40
  this.setState({
42
41
  frame: wp.media({
43
42
  title: __('Select or upload image'),
@@ -54,7 +53,9 @@ class ImageUpload extends Component {
54
53
  this.state.frame.open();
55
54
  });
56
55
  });
57
-
56
+ /**
57
+ * Update the state when an image is selected from the media modal.
58
+ */
58
59
  _defineProperty(this, "handleImageSelect", () => {
59
60
  const {
60
61
  onChange
@@ -62,11 +63,14 @@ class ImageUpload extends Component {
62
63
  const attachment = this.state.frame.state().get('selection').first().toJSON();
63
64
  onChange(attachment);
64
65
  });
65
-
66
+ /**
67
+ * Render.
68
+ */
66
69
  _defineProperty(this, "render", () => {
67
70
  const {
68
71
  buttonLabel,
69
72
  className,
73
+ disabled,
70
74
  help,
71
75
  image,
72
76
  info,
@@ -92,7 +96,8 @@ class ImageUpload extends Component {
92
96
  })]
93
97
  }), _jsx("div", {
94
98
  className: classes,
95
- style: { ...style
99
+ style: {
100
+ ...style
96
101
  },
97
102
  children: image?.url ? _jsxs(_Fragment, {
98
103
  children: [_jsx("img", {
@@ -102,12 +107,14 @@ class ImageUpload extends Component {
102
107
  }), _jsxs("div", {
103
108
  className: "newspack-image-upload__controls",
104
109
  children: [_jsx(Button, {
110
+ disabled: disabled,
105
111
  onClick: this.openModal,
106
112
  isLink: true,
107
113
  children: __('Replace', 'newspack')
108
114
  }), _jsx("span", {
109
115
  className: "sep"
110
116
  }), _jsx(Button, {
117
+ disabled: disabled,
111
118
  onClick: () => onChange(null),
112
119
  isLink: true,
113
120
  isDestructive: true,
@@ -115,6 +122,7 @@ class ImageUpload extends Component {
115
122
  })]
116
123
  })]
117
124
  }) : _jsx(Button, {
125
+ disabled: disabled,
118
126
  onClick: this.openModal,
119
127
  isLink: true,
120
128
  children: buttonLabel ? buttonLabel : __('Upload', 'newspack')
@@ -125,16 +133,9 @@ class ImageUpload extends Component {
125
133
  })]
126
134
  });
127
135
  });
128
-
129
136
  this.state = {
130
137
  frame: false
131
138
  };
132
139
  }
133
- /**
134
- * Open the WP media modal.
135
- */
136
-
137
-
138
140
  }
139
-
140
141
  export default ImageUpload;
@@ -2,8 +2,7 @@
2
2
  * Image Upload
3
3
  */
4
4
 
5
- @import '../../../shared/scss/colors';
6
- @import '~@wordpress/base-styles/colors';
5
+ @use '~@wordpress/base-styles/colors' as wp-colors;
7
6
 
8
7
  .newspack-image-upload {
9
8
  margin: 32px 0;
@@ -18,7 +17,7 @@
18
17
  background-repeat: no-repeat;
19
18
  background-size: contain;
20
19
  background-position: center;
21
- border: 1px dashed $gray-700;
20
+ border: 1px dashed wp-colors.$gray-700;
22
21
  border-radius: 2px;
23
22
  display: flex;
24
23
  justify-content: center;
@@ -52,12 +51,9 @@
52
51
  &::after {
53
52
  border: 1px solid rgba( black, 0.54 );
54
53
  border-radius: 2px;
55
- bottom: 0;
56
54
  content: '';
57
- left: 0;
55
+ inset: 0;
58
56
  position: absolute;
59
- right: 0;
60
- top: 0;
61
57
  z-index: 0;
62
58
  }
63
59
  button,
@@ -71,7 +67,7 @@
71
67
  }
72
68
  &::after {
73
69
  background: rgba( white, 0.9 );
74
- border-color: $gray-700;
70
+ border-color: wp-colors.$gray-700;
75
71
  }
76
72
  &:focus-within,
77
73
  &:hover {
@@ -94,7 +90,7 @@
94
90
  }
95
91
  }
96
92
  &__image + &__help {
97
- color: $gray-700;
93
+ color: wp-colors.$gray-700;
98
94
  font-size: 12px;
99
95
  margin: 1em 0 0;
100
96
  }
package/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { default as Accordion } from './accordion';
1
2
  export { default as ActionCard } from './action-card';
2
3
  export { default as AutocompleteTokenField } from './autocomplete-tokenfield';
3
4
  export { default as AutocompleteWithSuggestions } from './autocomplete-with-suggestions';
@@ -10,6 +11,7 @@ export { default as CustomSelectControl } from './custom-select-control';
10
11
  export { default as FormTokenField } from './form-token-field';
11
12
  export { default as Footer } from './footer';
12
13
  export { default as Handoff } from './handoff';
14
+ export { default as HandoffMessage } from './handoff-message';
13
15
  export { default as InfoButton } from './info-button';
14
16
  export { default as ImageUpload } from './image-upload';
15
17
  export { default as GlobalNotices } from './global-notices';
@@ -29,6 +31,8 @@ export { default as SectionHeader } from './section-header';
29
31
  export { default as SelectControl } from './select-control';
30
32
  export { default as DateRangePicker } from './date-range-picker';
31
33
  export { default as Settings } from './settings';
34
+ export { default as StepsList } from './steps-list';
35
+ export { default as StepsListItem } from './steps-list-item';
32
36
  export { default as StyleCard } from './style-card';
33
37
  export { default as TabbedNavigation } from './tabbed-navigation';
34
38
  export { default as TextControl } from './text-control';
@@ -8,18 +8,17 @@
8
8
  import { Component } from '@wordpress/element';
9
9
  import { Tooltip } from '@wordpress/components';
10
10
  import { Icon, info } from '@wordpress/icons';
11
+
11
12
  /**
12
13
  * External dependencies.
13
14
  */
14
-
15
15
  import classnames from 'classnames';
16
+
16
17
  /**
17
18
  * Internal dependencies.
18
19
  */
19
-
20
20
  import './style.scss';
21
21
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
22
-
23
22
  class InfoButton extends Component {
24
23
  /**
25
24
  * Render.
@@ -29,7 +28,8 @@ class InfoButton extends Component {
29
28
  className,
30
29
  ...otherProps
31
30
  } = this.props;
32
- return _jsx(Tooltip, { ...otherProps,
31
+ return _jsx(Tooltip, {
32
+ ...otherProps,
33
33
  children: _jsx("span", {
34
34
  className: classnames('newspack-info-button', className),
35
35
  children: _jsx(Icon, {
@@ -38,7 +38,5 @@ class InfoButton extends Component {
38
38
  })
39
39
  });
40
40
  }
41
-
42
41
  }
43
-
44
42
  export default InfoButton;
@@ -2,8 +2,6 @@
2
2
  * Info Button
3
3
  */
4
4
 
5
- @import '~@wordpress/base-styles/colors';
6
-
7
5
  .newspack-info-button {
8
6
  display: inline-block;
9
7
  flex: 0 0 24px;
@@ -15,6 +13,6 @@
15
13
 
16
14
  svg {
17
15
  display: block;
18
- fill: currentColor;
16
+ fill: currentcolor;
19
17
  }
20
18
  }
@@ -7,18 +7,17 @@
7
7
  */
8
8
  import { Component } from '@wordpress/element';
9
9
  import { Modal as BaseComponent } from '@wordpress/components';
10
+
10
11
  /**
11
12
  * Internal dependencies.
12
13
  */
13
-
14
14
  import './style.scss';
15
+
15
16
  /**
16
17
  * External dependencies.
17
18
  */
18
-
19
19
  import classnames from 'classnames';
20
20
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
21
-
22
21
  class Modal extends Component {
23
22
  /**
24
23
  * Render.
@@ -36,7 +35,5 @@ class Modal extends Component {
36
35
  ...otherProps
37
36
  });
38
37
  }
39
-
40
38
  }
41
-
42
39
  export default Modal;
@@ -2,16 +2,16 @@
2
2
  * Modal
3
3
  */
4
4
 
5
- @import '../../../shared/scss/colors';
5
+ @use '../../../shared/scss/colors';
6
6
 
7
7
  .newspack-modal {
8
8
  // Color
9
- --wp-admin-theme-color: #{$primary-500};
10
- --wp-admin-theme-color--rgb: #{$primary-500--rgb};
11
- --wp-admin-theme-color-darker-10: #{$primary-600};
12
- --wp-admin-theme-color-darker-10--rgb: #{$primary-600--rgb};
13
- --wp-admin-theme-color-darker-20: #{$primary-700};
14
- --wp-admin-theme-color-darker-20--rgb: #{$primary-700--rgb};
9
+ --wp-admin-theme-color: #{colors.$primary-500};
10
+ --wp-admin-theme-color--rgb: #{colors.$primary-500--rgb};
11
+ --wp-admin-theme-color-darker-10: #{colors.$primary-600};
12
+ --wp-admin-theme-color-darker-10--rgb: #{colors.$primary-600--rgb};
13
+ --wp-admin-theme-color-darker-20: #{colors.$primary-700};
14
+ --wp-admin-theme-color-darker-20--rgb: #{colors.$primary-700--rgb};
15
15
 
16
16
  @media screen and ( min-width: 744px ) {
17
17
  max-width: 680px;
@@ -50,7 +50,7 @@
50
50
 
51
51
  .components-modal__content {
52
52
  > *:last-child {
53
- margin-bottom: 8px;
53
+ margin-bottom: 0;
54
54
  }
55
55
  }
56
56
  }
@@ -7,18 +7,17 @@
7
7
  */
8
8
  import { Component } from '@wordpress/element';
9
9
  import { Path, SVG } from '@wordpress/components';
10
+
10
11
  /**
11
12
  * External dependencies.
12
13
  */
13
-
14
14
  import classnames from 'classnames';
15
+
15
16
  /**
16
17
  * Internal dependencies.
17
18
  */
18
-
19
19
  import './style.scss';
20
20
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
21
-
22
21
  class NewspackIcon extends Component {
23
22
  /**
24
23
  * Render
@@ -44,9 +43,7 @@ class NewspackIcon extends Component {
44
43
  })
45
44
  });
46
45
  }
47
-
48
46
  }
49
-
50
47
  NewspackIcon.defaultProps = {
51
48
  size: 32
52
49
  };
@@ -2,21 +2,21 @@
2
2
  * Newspack Icon
3
3
  */
4
4
 
5
- @import '../../../shared/scss/colors';
5
+ @use '../../../shared/scss/colors';
6
6
 
7
7
  .newspack-icon {
8
- background: $primary-500;
8
+ background: colors.$primary-500;
9
9
  fill: white;
10
10
  padding: 12px;
11
11
 
12
12
  &--white {
13
13
  background: white;
14
- fill: $primary-500;
14
+ fill: colors.$primary-500;
15
15
  }
16
16
 
17
17
  &--simple {
18
18
  background: none;
19
- fill: $primary-500;
19
+ fill: colors.$primary-500;
20
20
  padding: 0;
21
21
  }
22
22
 
@@ -7,18 +7,17 @@
7
7
  */
8
8
  import { Component } from '@wordpress/element';
9
9
  import { Path, SVG } from '@wordpress/components';
10
+
10
11
  /**
11
12
  * External dependencies.
12
13
  */
13
-
14
14
  import classnames from 'classnames';
15
+
15
16
  /**
16
17
  * Internal dependencies.
17
18
  */
18
-
19
19
  import './style.scss';
20
20
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
21
-
22
21
  class NewspackLogo extends Component {
23
22
  /**
24
23
  * Render
@@ -40,9 +39,7 @@ class NewspackLogo extends Component {
40
39
  })
41
40
  });
42
41
  }
43
-
44
42
  }
45
-
46
43
  NewspackLogo.defaultProps = {
47
44
  height: 56
48
45
  };