newspack-components 4.2.0 → 4.4.0-alpha.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 (316) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/DEVELOPMENT.md +868 -0
  3. package/colors/colors.module.scss +52 -2
  4. package/copy-styles.js +3 -2
  5. package/dist/cjs/accordion/index.js +17 -12
  6. package/dist/cjs/action-card/index.js +186 -140
  7. package/dist/cjs/action-card/style.scss +25 -2
  8. package/dist/cjs/autocomplete-tokenfield/index.js +254 -234
  9. package/dist/cjs/autocomplete-with-latest-posts/index.js +351 -0
  10. package/dist/cjs/autocomplete-with-latest-posts/style.scss +150 -0
  11. package/dist/cjs/autocomplete-with-suggestions/index.js +229 -126
  12. package/dist/cjs/badge/index.js +32 -0
  13. package/dist/cjs/badge/style.scss +36 -0
  14. package/dist/cjs/box-contrast/index.js +19 -15
  15. package/dist/cjs/button/index.js +41 -24
  16. package/dist/cjs/button-props/button-props.js +5 -5
  17. package/dist/cjs/button-props/index.js +2 -2
  18. package/dist/cjs/card/core-card.js +199 -0
  19. package/dist/cjs/card/index.js +75 -35
  20. package/dist/cjs/card/style-core.scss +295 -0
  21. package/dist/cjs/card/style.scss +4 -4
  22. package/dist/cjs/card-feature/index.js +141 -0
  23. package/dist/cjs/card-feature/style.scss +75 -0
  24. package/dist/cjs/card-form/index.js +144 -0
  25. package/dist/cjs/card-form/style.scss +20 -0
  26. package/dist/cjs/card-settings-group/index.js +69 -0
  27. package/dist/cjs/card-settings-group/style.scss +33 -0
  28. package/dist/cjs/card-sortable-list/index.js +426 -0
  29. package/dist/cjs/card-sortable-list/style.scss +48 -0
  30. package/dist/cjs/category-autocomplete/index.js +175 -155
  31. package/dist/cjs/color-picker/index.js +41 -23
  32. package/dist/cjs/color-picker/index.test.js +82 -0
  33. package/dist/cjs/color-picker/style.scss +11 -13
  34. package/dist/cjs/confirm-dialog/index.js +123 -0
  35. package/dist/cjs/consts.js +1 -1
  36. package/dist/cjs/custom-select-control/index.js +39 -28
  37. package/dist/cjs/dataviews/index.js +38 -0
  38. package/dist/cjs/dataviews/style.scss +9 -0
  39. package/dist/cjs/divider/index.js +47 -0
  40. package/dist/cjs/divider/style.scss +51 -0
  41. package/dist/cjs/footer/index.js +36 -30
  42. package/dist/cjs/form-token-field/index.js +51 -40
  43. package/dist/cjs/form-token-field/style.scss +0 -5
  44. package/dist/cjs/global-notices/index.js +5 -5
  45. package/dist/cjs/grid/index.js +25 -18
  46. package/dist/cjs/grid/style.scss +67 -8
  47. package/dist/cjs/handoff/index.js +204 -156
  48. package/dist/cjs/handoff-message/index.js +12 -7
  49. package/dist/cjs/hooks/index.js +10 -8
  50. package/dist/cjs/hooks/use-confirm-dialog.js +79 -0
  51. package/dist/cjs/hooks/use-unsaved-changes-dialog.js +144 -0
  52. package/dist/cjs/hooks/useObjectState.js +21 -12
  53. package/dist/cjs/hooks/useObjectState.test.js +55 -33
  54. package/dist/cjs/hooks/useOnClickOutside.js +6 -6
  55. package/dist/cjs/hooks/usePrompt.js +10 -13
  56. package/dist/cjs/image-upload/index.js +114 -123
  57. package/dist/cjs/image-upload/index.test.js +11 -13
  58. package/dist/cjs/image-upload/style.scss +12 -40
  59. package/dist/cjs/index.js +166 -92
  60. package/dist/cjs/info-button/index.js +43 -32
  61. package/dist/cjs/integration-icons/active-campaign.js +22 -0
  62. package/dist/cjs/integration-icons/constant-contact.js +28 -0
  63. package/dist/cjs/integration-icons/fundraise-up.js +25 -0
  64. package/dist/cjs/integration-icons/index.js +48 -0
  65. package/dist/cjs/integration-icons/mailchimp.js +19 -0
  66. package/dist/cjs/integration-icons/salesforce.js +17 -0
  67. package/dist/cjs/integration-icons/wisepops.js +20 -0
  68. package/dist/cjs/modal/index.js +29 -19
  69. package/dist/cjs/modal/style.scss +47 -13
  70. package/dist/cjs/newspack-icon/index.js +45 -38
  71. package/dist/cjs/newspack-icon/style.scss +5 -3
  72. package/dist/cjs/notice/index.js +64 -55
  73. package/dist/cjs/plugin-installer/index.js +259 -253
  74. package/dist/cjs/plugin-settings/SettingsSection.js +66 -60
  75. package/dist/cjs/plugin-settings/index.js +217 -200
  76. package/dist/cjs/plugin-toggle/index.js +192 -199
  77. package/dist/cjs/popover/index.js +41 -28
  78. package/dist/cjs/position-control/index.js +24 -23
  79. package/dist/cjs/progress-bar/index.js +71 -59
  80. package/dist/cjs/progress-bar/index.test.js +62 -68
  81. package/dist/cjs/proxied-imports/router.js +3 -3
  82. package/dist/cjs/radio-control/index.js +40 -27
  83. package/dist/cjs/section-header/index.js +143 -39
  84. package/dist/cjs/section-header/style.scss +129 -4
  85. package/dist/cjs/select-control/ButtonGroupControl.js +26 -21
  86. package/dist/cjs/select-control/GroupedSelectControl.js +41 -35
  87. package/dist/cjs/select-control/index.js +52 -40
  88. package/dist/cjs/settings/MinMaxSetting.js +30 -20
  89. package/dist/cjs/settings/SettingsCard.js +20 -17
  90. package/dist/cjs/settings/SettingsSection.js +22 -21
  91. package/dist/cjs/settings/index.js +5 -5
  92. package/dist/cjs/sortable-newsletter-list-control/index.js +78 -57
  93. package/dist/cjs/steps-list/index.js +44 -34
  94. package/dist/cjs/steps-list-item/index.js +47 -39
  95. package/dist/cjs/style-card/index.js +70 -63
  96. package/dist/cjs/style.scss +2 -0
  97. package/dist/cjs/tabbed-navigation/index.js +38 -36
  98. package/dist/cjs/text-control/index.js +27 -25
  99. package/dist/cjs/utils/color.js +4 -4
  100. package/dist/cjs/utils/editor-toolbar-back-button.js +61 -0
  101. package/dist/cjs/utils/index.js +31 -19
  102. package/dist/cjs/utils/style.scss +8 -0
  103. package/dist/cjs/waiting/index.js +48 -35
  104. package/dist/cjs/waiting/style.scss +4 -0
  105. package/dist/cjs/web-preview/index.js +219 -154
  106. package/dist/cjs/web-preview/style.scss +20 -53
  107. package/dist/cjs/with-wizard/index.js +362 -364
  108. package/dist/cjs/with-wizard/style.scss +28 -60
  109. package/dist/cjs/with-wizard-screen/index.js +54 -58
  110. package/dist/cjs/with-wizard-screen/style.scss +77 -10
  111. package/dist/cjs/wizard/components/WizardError.js +20 -18
  112. package/dist/cjs/wizard/components/WizardSnackbar.js +73 -0
  113. package/dist/cjs/wizard/components/style.scss +48 -0
  114. package/dist/cjs/wizard/index.js +207 -64
  115. package/dist/cjs/wizard/store/index.js +191 -97
  116. package/dist/cjs/wizard/store/utils.js +13 -8
  117. package/dist/esm/accordion/index.js +14 -9
  118. package/dist/esm/action-card/index.js +178 -124
  119. package/dist/esm/action-card/style.scss +25 -2
  120. package/dist/esm/autocomplete-tokenfield/index.js +248 -222
  121. package/dist/esm/autocomplete-with-latest-posts/index.js +347 -0
  122. package/dist/esm/autocomplete-with-latest-posts/style.scss +150 -0
  123. package/dist/esm/autocomplete-with-suggestions/index.js +226 -119
  124. package/dist/esm/badge/index.js +24 -0
  125. package/dist/esm/badge/style.scss +36 -0
  126. package/dist/esm/box-contrast/index.js +15 -11
  127. package/dist/esm/button/index.js +39 -19
  128. package/dist/esm/button-props/button-props.js +1 -1
  129. package/dist/esm/card/core-card.js +195 -0
  130. package/dist/esm/card/index.js +70 -22
  131. package/dist/esm/card/style-core.scss +295 -0
  132. package/dist/esm/card/style.scss +4 -4
  133. package/dist/esm/card-feature/index.js +131 -0
  134. package/dist/esm/card-feature/style.scss +75 -0
  135. package/dist/esm/card-form/index.js +134 -0
  136. package/dist/esm/card-form/style.scss +20 -0
  137. package/dist/esm/card-settings-group/index.js +61 -0
  138. package/dist/esm/card-settings-group/style.scss +33 -0
  139. package/dist/esm/card-sortable-list/index.js +425 -0
  140. package/dist/esm/card-sortable-list/style.scss +48 -0
  141. package/dist/esm/category-autocomplete/index.js +168 -140
  142. package/dist/esm/color-picker/index.js +39 -21
  143. package/dist/esm/color-picker/index.test.js +78 -0
  144. package/dist/esm/color-picker/style.scss +11 -13
  145. package/dist/esm/confirm-dialog/index.js +116 -0
  146. package/dist/esm/consts.js +1 -1
  147. package/dist/esm/custom-select-control/index.js +34 -15
  148. package/dist/esm/dataviews/index.js +34 -0
  149. package/dist/esm/dataviews/style.scss +9 -0
  150. package/dist/esm/divider/index.js +42 -0
  151. package/dist/esm/divider/style.scss +51 -0
  152. package/dist/esm/footer/index.js +34 -28
  153. package/dist/esm/form-token-field/index.js +46 -27
  154. package/dist/esm/form-token-field/style.scss +0 -5
  155. package/dist/esm/global-notices/index.js +3 -3
  156. package/dist/esm/grid/index.js +23 -13
  157. package/dist/esm/grid/style.scss +67 -8
  158. package/dist/esm/handoff/index.js +199 -143
  159. package/dist/esm/handoff-message/index.js +10 -6
  160. package/dist/esm/hooks/index.js +8 -6
  161. package/dist/esm/hooks/use-confirm-dialog.js +73 -0
  162. package/dist/esm/hooks/use-unsaved-changes-dialog.js +136 -0
  163. package/dist/esm/hooks/useObjectState.js +19 -9
  164. package/dist/esm/hooks/useObjectState.test.js +54 -32
  165. package/dist/esm/hooks/useOnClickOutside.js +4 -4
  166. package/dist/esm/hooks/usePrompt.js +9 -11
  167. package/dist/esm/image-upload/index.js +110 -111
  168. package/dist/esm/image-upload/index.test.js +11 -13
  169. package/dist/esm/image-upload/style.scss +12 -40
  170. package/dist/esm/index.js +13 -1
  171. package/dist/esm/info-button/index.js +38 -19
  172. package/dist/esm/integration-icons/active-campaign.js +16 -0
  173. package/dist/esm/integration-icons/constant-contact.js +22 -0
  174. package/dist/esm/integration-icons/fundraise-up.js +19 -0
  175. package/dist/esm/integration-icons/index.js +6 -0
  176. package/dist/esm/integration-icons/mailchimp.js +13 -0
  177. package/dist/esm/integration-icons/salesforce.js +11 -0
  178. package/dist/esm/integration-icons/wisepops.js +14 -0
  179. package/dist/esm/modal/index.js +27 -13
  180. package/dist/esm/modal/style.scss +47 -13
  181. package/dist/esm/newspack-icon/index.js +40 -25
  182. package/dist/esm/newspack-icon/style.scss +5 -3
  183. package/dist/esm/notice/index.js +59 -42
  184. package/dist/esm/plugin-installer/index.js +255 -243
  185. package/dist/esm/plugin-settings/SettingsSection.js +61 -50
  186. package/dist/esm/plugin-settings/index.js +212 -189
  187. package/dist/esm/plugin-toggle/index.js +187 -190
  188. package/dist/esm/popover/index.js +35 -16
  189. package/dist/esm/position-control/index.js +22 -18
  190. package/dist/esm/progress-bar/index.js +66 -49
  191. package/dist/esm/progress-bar/index.test.js +61 -67
  192. package/dist/esm/radio-control/index.js +34 -15
  193. package/dist/esm/section-header/index.js +140 -38
  194. package/dist/esm/section-header/style.scss +129 -4
  195. package/dist/esm/select-control/ButtonGroupControl.js +23 -18
  196. package/dist/esm/select-control/GroupedSelectControl.js +38 -30
  197. package/dist/esm/select-control/index.js +47 -27
  198. package/dist/esm/settings/MinMaxSetting.js +27 -16
  199. package/dist/esm/settings/SettingsCard.js +18 -13
  200. package/dist/esm/settings/SettingsSection.js +20 -19
  201. package/dist/esm/settings/index.js +3 -3
  202. package/dist/esm/sortable-newsletter-list-control/index.js +74 -53
  203. package/dist/esm/steps-list/index.js +39 -21
  204. package/dist/esm/steps-list-item/index.js +42 -26
  205. package/dist/esm/style-card/index.js +65 -50
  206. package/dist/esm/style.scss +2 -0
  207. package/dist/esm/tabbed-navigation/index.js +35 -33
  208. package/dist/esm/text-control/index.js +25 -19
  209. package/dist/esm/utils/color.js +4 -4
  210. package/dist/esm/utils/editor-toolbar-back-button.js +53 -0
  211. package/dist/esm/utils/index.js +29 -16
  212. package/dist/esm/utils/style.scss +8 -0
  213. package/dist/esm/waiting/index.js +43 -22
  214. package/dist/esm/waiting/style.scss +4 -0
  215. package/dist/esm/web-preview/index.js +218 -147
  216. package/dist/esm/web-preview/style.scss +20 -53
  217. package/dist/esm/with-wizard/index.js +360 -358
  218. package/dist/esm/with-wizard/style.scss +28 -60
  219. package/dist/esm/with-wizard-screen/index.js +48 -46
  220. package/dist/esm/with-wizard-screen/style.scss +77 -10
  221. package/dist/esm/wizard/components/WizardError.js +18 -16
  222. package/dist/esm/wizard/components/WizardSnackbar.js +70 -0
  223. package/dist/esm/wizard/components/style.scss +48 -0
  224. package/dist/esm/wizard/index.js +207 -58
  225. package/dist/esm/wizard/store/index.js +189 -90
  226. package/dist/esm/wizard/store/utils.js +13 -6
  227. package/package.json +30 -17
  228. package/release.config.js +1 -0
  229. package/shared/author-context.js +26 -0
  230. package/shared/hooks/use-coauthors.js +388 -0
  231. package/shared/hooks/use-coauthors.test.js +850 -0
  232. package/shared/hooks/use-custom-byline.js +47 -0
  233. package/shared/hooks/use-custom-byline.test.js +133 -0
  234. package/shared/scss/_mixins.scss +54 -0
  235. package/src/accordion/index.js +8 -7
  236. package/src/action-card/action-card.d.ts +7 -3
  237. package/src/action-card/index.js +39 -12
  238. package/src/action-card/style.scss +25 -2
  239. package/src/autocomplete-tokenfield/index.js +2 -2
  240. package/src/autocomplete-with-latest-posts/index.js +290 -0
  241. package/src/autocomplete-with-latest-posts/style.scss +150 -0
  242. package/src/badge/index.tsx +26 -0
  243. package/src/badge/style.scss +36 -0
  244. package/src/button/index.tsx +3 -2
  245. package/src/card/core-card.js +224 -0
  246. package/src/card/index.js +40 -1
  247. package/src/card/style-core.scss +295 -0
  248. package/src/card/style.scss +4 -4
  249. package/src/card-feature/README.md +188 -0
  250. package/src/card-feature/index.tsx +186 -0
  251. package/src/card-feature/style.scss +75 -0
  252. package/src/card-form/README.md +113 -0
  253. package/src/card-form/index.tsx +128 -0
  254. package/src/card-form/style.scss +20 -0
  255. package/src/card-settings-group/README.md +43 -0
  256. package/src/card-settings-group/index.tsx +78 -0
  257. package/src/card-settings-group/style.scss +33 -0
  258. package/src/card-sortable-list/README.md +51 -0
  259. package/src/card-sortable-list/index.tsx +435 -0
  260. package/src/card-sortable-list/style.scss +48 -0
  261. package/src/color-picker/index.js +15 -8
  262. package/src/color-picker/index.test.js +52 -0
  263. package/src/color-picker/style.scss +11 -13
  264. package/src/confirm-dialog/README.md +128 -0
  265. package/src/confirm-dialog/index.tsx +132 -0
  266. package/src/dataviews/index.tsx +34 -0
  267. package/src/dataviews/style.scss +9 -0
  268. package/src/divider/README.md +25 -0
  269. package/src/divider/index.js +31 -0
  270. package/src/divider/style.scss +51 -0
  271. package/src/form-token-field/style.scss +0 -5
  272. package/src/grid/index.tsx +2 -1
  273. package/src/grid/style.scss +67 -8
  274. package/src/handoff/README.md +93 -0
  275. package/src/handoff/index.js +46 -8
  276. package/src/hooks/index.ts +2 -1
  277. package/src/hooks/use-confirm-dialog.tsx +80 -0
  278. package/src/hooks/use-unsaved-changes-dialog.tsx +140 -0
  279. package/src/image-upload/index.js +10 -15
  280. package/src/image-upload/style.scss +12 -40
  281. package/src/index.js +13 -1
  282. package/src/integration-icons/active-campaign.js +14 -0
  283. package/src/integration-icons/constant-contact.js +22 -0
  284. package/src/integration-icons/fundraise-up.js +18 -0
  285. package/src/integration-icons/index.js +6 -0
  286. package/src/integration-icons/mailchimp.js +10 -0
  287. package/src/integration-icons/salesforce.js +10 -0
  288. package/src/integration-icons/wisepops.js +14 -0
  289. package/src/modal/index.js +12 -3
  290. package/src/modal/style.scss +47 -13
  291. package/src/newspack-icon/style.scss +5 -3
  292. package/src/plugin-installer/index.js +30 -19
  293. package/src/section-header/index.js +105 -14
  294. package/src/section-header/style.scss +129 -4
  295. package/src/select-control/index.js +4 -0
  296. package/src/style.scss +2 -0
  297. package/src/utils/editor-toolbar-back-button.tsx +48 -0
  298. package/src/utils/index.js +6 -0
  299. package/src/utils/style.scss +8 -0
  300. package/src/waiting/index.js +2 -1
  301. package/src/waiting/style.scss +4 -0
  302. package/src/web-preview/index.js +90 -35
  303. package/src/web-preview/style.scss +20 -53
  304. package/src/with-wizard/index.js +1 -1
  305. package/src/with-wizard/style.scss +28 -60
  306. package/src/with-wizard-screen/style.scss +77 -10
  307. package/src/wizard/components/WizardSnackbar.js +58 -0
  308. package/src/wizard/components/style.scss +48 -0
  309. package/src/wizard/index.js +152 -21
  310. package/src/wizard/store/index.js +28 -2
  311. package/dist/cjs/button-card/index.js +0 -72
  312. package/dist/cjs/button-card/style.scss +0 -180
  313. package/dist/esm/button-card/index.js +0 -64
  314. package/dist/esm/button-card/style.scss +0 -180
  315. package/src/button-card/index.js +0 -52
  316. package/src/button-card/style.scss +0 -180
@@ -1,75 +1,87 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- exports.default = void 0;
7
+ exports["default"] = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
11
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
7
13
  var _element = require("@wordpress/element");
8
14
  require("./style.scss");
9
15
  var _jsxRuntime = require("react/jsx-runtime");
10
- /**
16
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
17
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
11
18
  * Progress Bar
12
- */
13
-
14
- /**
19
+ */ /**
15
20
  * WordPress dependencies.
16
- */
17
-
18
- /**
21
+ */ /**
19
22
  * Internal dependencies.
20
23
  */
21
-
22
- class ProgressBar extends _element.Component {
23
- /**
24
- * Get completion as a percentage.
25
- *
26
- * @param {number} completed The number of steps completed.
27
- * @param {number} total The total number of steps.
28
- * @return {number} completion percentage
29
- */
30
- getCompletionPercentage(completed, total) {
31
- if (!total) {
32
- return 100;
33
- }
34
- return Math.max(Math.min(Math.round(completed / total * 100), 100), 0);
24
+ var ProgressBar = /*#__PURE__*/function (_Component) {
25
+ function ProgressBar() {
26
+ (0, _classCallCheck2["default"])(this, ProgressBar);
27
+ return _callSuper(this, ProgressBar, arguments);
35
28
  }
29
+ (0, _inherits2["default"])(ProgressBar, _Component);
30
+ return (0, _createClass2["default"])(ProgressBar, [{
31
+ key: "getCompletionPercentage",
32
+ value:
33
+ /**
34
+ * Get completion as a percentage.
35
+ *
36
+ * @param {number} completed The number of steps completed.
37
+ * @param {number} total The total number of steps.
38
+ * @return {number} completion percentage
39
+ */
40
+ function getCompletionPercentage(completed, total) {
41
+ if (!total) {
42
+ return 100;
43
+ }
44
+ return Math.max(Math.min(Math.round(completed / total * 100), 100), 0);
45
+ }
36
46
 
37
- /**
38
- * Render.
39
- */
40
- render() {
41
- const {
42
- label,
43
- completed,
44
- total,
45
- displayFraction
46
- } = this.props;
47
- const cleanTotal = Math.max(0, parseInt(total) || 0);
48
- const cleanCompleted = Math.max(0, Math.min(parseInt(completed) || 0, parseInt(cleanTotal)));
49
- const barStyle = {
50
- width: this.getCompletionPercentage(cleanCompleted, cleanTotal) + '%'
51
- };
52
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
53
- className: "newspack-progress-bar",
54
- children: [(label || displayFraction) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
55
- className: "newspack-progress-bar__headings",
56
- children: [label && /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
57
- children: label
58
- }), displayFraction && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
59
- className: "is-dark",
60
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("strong", {
61
- children: [cleanCompleted, "/", cleanTotal]
47
+ /**
48
+ * Render.
49
+ */
50
+ }, {
51
+ key: "render",
52
+ value: function render() {
53
+ var _this$props = this.props,
54
+ label = _this$props.label,
55
+ completed = _this$props.completed,
56
+ total = _this$props.total,
57
+ displayFraction = _this$props.displayFraction;
58
+ var cleanTotal = Math.max(0, parseInt(total) || 0);
59
+ var cleanCompleted = Math.max(0, Math.min(parseInt(completed) || 0, parseInt(cleanTotal)));
60
+ var barStyle = {
61
+ width: this.getCompletionPercentage(cleanCompleted, cleanTotal) + '%'
62
+ };
63
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
64
+ className: "newspack-progress-bar",
65
+ children: [(label || displayFraction) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
66
+ className: "newspack-progress-bar__headings",
67
+ children: [label && /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
68
+ children: label
69
+ }), displayFraction && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
70
+ className: "is-dark",
71
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("strong", {
72
+ children: [cleanCompleted, "/", cleanTotal]
73
+ })
74
+ })]
75
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
76
+ className: "newspack-progress-bar__container",
77
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
78
+ className: "newspack-progress-bar__bar",
79
+ style: barStyle,
80
+ "data-testid": "progress-bar-indicator"
62
81
  })
63
82
  })]
64
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
65
- className: "newspack-progress-bar__container",
66
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
67
- className: "newspack-progress-bar__bar",
68
- style: barStyle,
69
- "data-testid": "progress-bar-indicator"
70
- })
71
- })]
72
- });
73
- }
74
- }
75
- var _default = exports.default = ProgressBar;
83
+ });
84
+ }
85
+ }]);
86
+ }(_element.Component);
87
+ var _default = exports["default"] = ProgressBar;
@@ -1,57 +1,56 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
4
5
  var _react = _interopRequireWildcard(require("react"));
5
6
  var _react2 = require("@testing-library/react");
6
7
  var _ = _interopRequireDefault(require("./"));
7
8
  var _jsxRuntime = require("react/jsx-runtime");
8
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
9
- describe('ProgressBar', () => {
10
- it('should render a progress indicator', () => {
11
- const {
12
- getByTestId
13
- } = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.default, {
14
- completed: "1",
15
- total: "2"
16
- }));
17
- const indicator = getByTestId('progress-bar-indicator');
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ describe('ProgressBar', function () {
13
+ it('should render a progress indicator', function () {
14
+ var _render = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
15
+ completed: "1",
16
+ total: "2"
17
+ })),
18
+ getByTestId = _render.getByTestId;
19
+ var indicator = getByTestId('progress-bar-indicator');
18
20
  expect(indicator).toHaveAttribute('style', 'width: 50%;');
19
21
  });
20
- it('should render a label', () => {
21
- const label = 'test label';
22
- const {
23
- getByText
24
- } = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.default, {
25
- completed: "1",
26
- total: "2",
27
- label: label
28
- }));
22
+ it('should render a label', function () {
23
+ var label = 'test label';
24
+ var _render2 = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
25
+ completed: "1",
26
+ total: "2",
27
+ label: label
28
+ })),
29
+ getByText = _render2.getByText;
29
30
  expect(getByText(label)).toBeInTheDocument();
30
31
  });
31
- it('should render progress as a fraction', () => {
32
- const {
33
- getByText
34
- } = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.default, {
35
- completed: "1",
36
- total: "2",
37
- displayFraction: true
38
- }));
32
+ it('should render progress as a fraction', function () {
33
+ var _render3 = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
34
+ completed: "1",
35
+ total: "2",
36
+ displayFraction: true
37
+ })),
38
+ getByText = _render3.getByText;
39
39
  expect(getByText('1/2')).toBeInTheDocument();
40
40
  });
41
- it('should render with both label and fraction', () => {
42
- const label = 'test label';
43
- const {
44
- getByText
45
- } = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.default, {
46
- completed: "1",
47
- total: "2",
48
- label: label,
49
- displayFraction: true
50
- }));
41
+ it('should render with both label and fraction', function () {
42
+ var label = 'test label';
43
+ var _render4 = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
44
+ completed: "1",
45
+ total: "2",
46
+ label: label,
47
+ displayFraction: true
48
+ })),
49
+ getByText = _render4.getByText;
51
50
  expect(getByText(label)).toBeInTheDocument();
52
51
  expect(getByText('1/2')).toBeInTheDocument();
53
52
  });
54
- describe('should calculate progress correctly', () => {
53
+ describe('should calculate progress correctly', function () {
55
54
  [{
56
55
  props: {
57
56
  completed: 1,
@@ -70,42 +69,37 @@ describe('ProgressBar', () => {
70
69
  total: 3
71
70
  },
72
71
  expectedWidth: 100
73
- }].forEach(({
74
- props,
75
- expectedWidth
76
- }) => {
77
- it(`with expected progress of ${expectedWidth}`, () => {
78
- const {
79
- getByTestId
80
- } = (0, _react2.render)(/*#__PURE__*/(0, _react.createElement)(_.default, {
81
- ...props,
82
- key: expectedWidth
83
- }));
84
- expect(getByTestId('progress-bar-indicator')).toHaveAttribute('style', `width: ${expectedWidth}%;`);
72
+ }].forEach(function (_ref) {
73
+ var props = _ref.props,
74
+ expectedWidth = _ref.expectedWidth;
75
+ it("with expected progress of ".concat(expectedWidth), function () {
76
+ var _render5 = (0, _react2.render)(/*#__PURE__*/(0, _react.createElement)(_["default"], _objectSpread(_objectSpread({}, props), {}, {
77
+ key: expectedWidth
78
+ }))),
79
+ getByTestId = _render5.getByTestId;
80
+ expect(getByTestId('progress-bar-indicator')).toHaveAttribute('style', "width: ".concat(expectedWidth, "%;"));
85
81
  });
86
82
  });
87
83
  });
88
- it('should handle non-numeric values in ProgressBar element', () => {
89
- const {
90
- getByText,
91
- getByTestId
92
- } = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.default, {
93
- completed: "cats",
94
- total: "dogs",
95
- displayFraction: true
96
- }));
84
+ it('should handle non-numeric values in ProgressBar element', function () {
85
+ var _render6 = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
86
+ completed: "cats",
87
+ total: "dogs",
88
+ displayFraction: true
89
+ })),
90
+ getByText = _render6.getByText,
91
+ getByTestId = _render6.getByTestId;
97
92
  expect(getByText('0/0')).toBeInTheDocument();
98
93
  expect(getByTestId('progress-bar-indicator')).toHaveAttribute('style', 'width: 100%;');
99
94
  });
100
- it('should handle non-logical values in ProgressBar element', () => {
101
- const {
102
- getByText,
103
- getByTestId
104
- } = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.default, {
105
- completed: "3",
106
- total: "-1",
107
- displayFraction: true
108
- }));
95
+ it('should handle non-logical values in ProgressBar element', function () {
96
+ var _render7 = (0, _react2.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
97
+ completed: "3",
98
+ total: "-1",
99
+ displayFraction: true
100
+ })),
101
+ getByText = _render7.getByText,
102
+ getByTestId = _render7.getByTestId;
109
103
  expect(getByText('0/0')).toBeInTheDocument();
110
104
  expect(getByTestId('progress-bar-indicator')).toHaveAttribute('style', 'width: 100%;');
111
105
  });
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports["default"] = void 0;
7
7
  var ReactRouterDOM = _interopRequireWildcard(require("react-router-dom"));
8
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
8
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
9
9
  /**
10
10
  * A proxy for react-router-dom.
11
11
  * Ensures that both components and the plugin use the same instance of
12
12
  * React Router, even if there are node_modules in components.
13
13
  */
14
- var _default = exports.default = ReactRouterDOM;
14
+ var _default = exports["default"] = ReactRouterDOM;
@@ -4,40 +4,53 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = void 0;
7
+ exports["default"] = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
8
15
  var _components = require("@wordpress/components");
9
16
  var _element = require("@wordpress/element");
10
17
  require("./style.scss");
11
18
  var _classnames = _interopRequireDefault(require("classnames"));
12
19
  var _jsxRuntime = require("react/jsx-runtime");
13
- /**
20
+ var _excluded = ["className"];
21
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
24
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
14
25
  * WordPress dependencies.
15
- */
16
-
17
- /**
26
+ */ /**
18
27
  * Internal dependencies.
19
- */
20
-
21
- /**
28
+ */ /**
22
29
  * External dependencies.
23
- */
24
-
25
- /**
30
+ */ /**
26
31
  * Radio Control.
27
- */class RadioControl extends _element.Component {
28
- /**
29
- * Render.
30
- */
31
- render() {
32
- const {
33
- className,
34
- ...otherProps
35
- } = this.props;
36
- const classes = (0, _classnames.default)('newspack-radio-control', className);
37
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.RadioControl, {
38
- className: classes,
39
- ...otherProps
40
- });
32
+ */
33
+ var RadioControl = /*#__PURE__*/function (_Component) {
34
+ function RadioControl() {
35
+ (0, _classCallCheck2["default"])(this, RadioControl);
36
+ return _callSuper(this, RadioControl, arguments);
41
37
  }
42
- }
43
- var _default = exports.default = RadioControl;
38
+ (0, _inherits2["default"])(RadioControl, _Component);
39
+ return (0, _createClass2["default"])(RadioControl, [{
40
+ key: "render",
41
+ value:
42
+ /**
43
+ * Render.
44
+ */
45
+ function render() {
46
+ var _this$props = this.props,
47
+ className = _this$props.className,
48
+ otherProps = (0, _objectWithoutProperties2["default"])(_this$props, _excluded);
49
+ var classes = (0, _classnames["default"])('newspack-radio-control', className);
50
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.RadioControl, _objectSpread({
51
+ className: classes
52
+ }, otherProps));
53
+ }
54
+ }]);
55
+ }(_element.Component);
56
+ var _default = exports["default"] = RadioControl;
@@ -4,8 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = void 0;
7
+ exports["default"] = void 0;
8
+ var _i18n = require("@wordpress/i18n");
8
9
  var _element = require("@wordpress/element");
10
+ var _components = require("@wordpress/components");
11
+ var _icons = require("@wordpress/icons");
9
12
  var _ = require("..");
10
13
  require("./style.scss");
11
14
  var _classnames = _interopRequireDefault(require("classnames"));
@@ -18,6 +21,8 @@ var _jsxRuntime = require("react/jsx-runtime");
18
21
  * WordPress dependencies
19
22
  */
20
23
 
24
+ // eslint-disable-line @wordpress/no-unsafe-wp-apis
25
+
21
26
  /**
22
27
  * Internal dependencies
23
28
  */
@@ -30,66 +35,165 @@ var _jsxRuntime = require("react/jsx-runtime");
30
35
  * Represents a section header component.
31
36
  *
32
37
  * @typedef {Object} SectionHeaderProps
33
- * @property {boolean} [centered=false] - Indicates if the header is centered.
34
- * @property {?string} [className=null] - Additional CSS class name.
35
- * @property {string|Function|*} [description] - Description of the section.
36
- * @property {number} [heading=2] - HTML heading level, e.g., 1 for h1, 2 for h2, etc.
37
- * @property {boolean} [isWhite=false] - Indicates if the header should use a white theme.
38
- * @property {boolean} [noMargin=false] - Indicates if the header should have no margin.
39
- * @property {string} title - The title of the section.
40
- * @property {?string} [id=null] - Optional ID for the header element.
38
+ * @property {string} [backNav=''] - URL to navigate back to.
39
+ * @property {string|string[]} [badge] - Badge to display in the header.
40
+ * @property {string} [badgeLevel] - Badge level, e.g., 'success', 'info', 'warning', 'error'.
41
+ * @property {boolean} [centered=false] - Indicates if the header is centered.
42
+ * @property {?string} [className=null] - Additional CSS class name.
43
+ * @property {string|Function|*} [description] - Description of the section.
44
+ * @property {number} [heading=2] - HTML heading level, e.g., 1 for h1, 2 for h2, etc.
45
+ * @property {string|Function|*} [icon] - Icon to display in the header.
46
+ * @property {boolean} [isWhite=false] - Indicates if the header should use a white theme.
47
+ * @property {boolean} [noMargin=false] - Indicates if the header should have no margin.
48
+ * @property {boolean} [pageHeader=false] - Indicates if the header is used as a page header.
49
+ * @property {string} title - The title of the section.
50
+ * @property {?string} [id=null] - Optional ID for the header element.
51
+ * @property {?string|Function|*} [children=null] - Optional children to display in the header.
41
52
  */
42
53
 
43
54
  /**
44
55
  * Creates a section header.
45
56
  *
46
57
  * @param {SectionHeaderProps} props - The properties for the section header.
47
- */const SectionHeader = ({
48
- centered = false,
49
- className = null,
50
- description = '',
51
- heading = 2,
52
- isWhite = false,
53
- noMargin = false,
54
- title,
55
- id = null
56
- }) => {
58
+ */var SectionHeader = function SectionHeader(_ref) {
59
+ var _ref$backNav = _ref.backNav,
60
+ backNav = _ref$backNav === void 0 ? '' : _ref$backNav,
61
+ badges = _ref.badges,
62
+ _ref$centered = _ref.centered,
63
+ centered = _ref$centered === void 0 ? false : _ref$centered,
64
+ _ref$className = _ref.className,
65
+ className = _ref$className === void 0 ? null : _ref$className,
66
+ _ref$description = _ref.description,
67
+ description = _ref$description === void 0 ? '' : _ref$description,
68
+ _ref$heading = _ref.heading,
69
+ heading = _ref$heading === void 0 ? 2 : _ref$heading,
70
+ _ref$icon = _ref.icon,
71
+ icon = _ref$icon === void 0 ? null : _ref$icon,
72
+ _ref$isWhite = _ref.isWhite,
73
+ isWhite = _ref$isWhite === void 0 ? false : _ref$isWhite,
74
+ _ref$noMargin = _ref.noMargin,
75
+ noMargin = _ref$noMargin === void 0 ? false : _ref$noMargin,
76
+ _ref$pageHeader = _ref.pageHeader,
77
+ pageHeader = _ref$pageHeader === void 0 ? false : _ref$pageHeader,
78
+ title = _ref.title,
79
+ _ref$id = _ref.id,
80
+ id = _ref$id === void 0 ? null : _ref$id,
81
+ menu = _ref.menu,
82
+ primaryAction = _ref.primaryAction,
83
+ secondaryAction = _ref.secondaryAction,
84
+ _ref$children = _ref.children,
85
+ children = _ref$children === void 0 ? null : _ref$children;
57
86
  // If id is in the URL as a scrollTo param, scroll to it on render.
58
- const ref = (0, _element.useRef)();
59
- (0, _element.useEffect)(() => {
60
- const params = new Proxy(new URLSearchParams(window.location.search), {
61
- get: (searchParams, prop) => searchParams.get(prop)
87
+ var ref = (0, _element.useRef)();
88
+ (0, _element.useEffect)(function () {
89
+ var params = new Proxy(new URLSearchParams(window.location.search), {
90
+ get: function get(searchParams, prop) {
91
+ return searchParams.get(prop);
92
+ }
62
93
  });
63
- const scrollToId = params.scrollTo;
94
+ var scrollToId = params.scrollTo;
64
95
  if (scrollToId && scrollToId === id) {
65
96
  // Let parent scroll action run before running this.
66
- window.setTimeout(() => ref.current.scrollIntoView({
67
- behavior: 'smooth'
68
- }), 250);
97
+ window.setTimeout(function () {
98
+ return ref.current.scrollIntoView({
99
+ behavior: 'smooth'
100
+ });
101
+ }, 250);
69
102
  }
70
103
  }, []);
71
- const classes = (0, _classnames.default)('newspack-section-header', centered && 'newspack-section-header--is-centered', isWhite && 'newspack-section-header--is-white', noMargin && 'newspack-section-header--no-margin', className);
72
- const HeadingTag = `h${heading}`;
73
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
104
+ var classes = (0, _classnames["default"])('newspack-section-header', centered && 'newspack-section-header--is-centered', isWhite && 'newspack-section-header--is-white', noMargin && 'newspack-section-header--no-margin', pageHeader && 'newspack-section-header--page-header');
105
+ var HeadingTag = pageHeader ? 'h1' : "h".concat(heading);
106
+ var titleContent = null;
107
+ if (typeof title === 'string') {
108
+ titleContent = /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
109
+ className: "newspack-section-header__title-container",
110
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(HeadingTag, {
111
+ children: [title, badges !== null && badges !== void 0 && badges.length ? badges.map(function (badge, i) {
112
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Badge, {
113
+ text: badge.label,
114
+ level: badge.level || 'default'
115
+ }, i);
116
+ }) : null]
117
+ }), (menu === null || menu === void 0 ? void 0 : menu.length) > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.DropdownMenu, {
118
+ className: "newspack-section-header__menu",
119
+ icon: _icons.moreVertical,
120
+ label: (0, _i18n.__)('More options', 'newspack-plugin'),
121
+ children: function children() {
122
+ return menu.map(function (item, index) {
123
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
124
+ icon: item.icon,
125
+ href: item.href,
126
+ onClick: item.action,
127
+ disabled: item.disabled || false,
128
+ isDestructive: item.destructive || false,
129
+ children: item.label
130
+ }, index);
131
+ });
132
+ }
133
+ }), secondaryAction && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
134
+ className: "newspack-section-header__secondary-action",
135
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
136
+ variant: "link",
137
+ href: secondaryAction.href,
138
+ onClick: secondaryAction.action,
139
+ children: secondaryAction.label
140
+ })
141
+ })]
142
+ });
143
+ } else if (typeof title === 'function') {
144
+ titleContent = /*#__PURE__*/(0, _jsxRuntime.jsx)(HeadingTag, {
145
+ children: title()
146
+ });
147
+ }
148
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
74
149
  id: id,
75
- className: "newspack-section-header__container",
150
+ className: (0, _classnames["default"])('newspack-section-header__container', backNav && 'newspack-section-header--has-back-nav', primaryAction && 'newspack-section-header--has-primary-action', className),
76
151
  ref: ref,
77
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_.Grid, {
152
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_.Grid, {
78
153
  columns: 1,
79
154
  gutter: 8,
80
155
  className: classes,
81
- children: [typeof title === 'string' && /*#__PURE__*/(0, _jsxRuntime.jsx)(HeadingTag, {
82
- children: title
83
- }), typeof title === 'function' && /*#__PURE__*/(0, _jsxRuntime.jsx)(HeadingTag, {
84
- children: title()
85
- }), description && typeof description === 'string' && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
156
+ children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
157
+ className: "newspack-section-header__icon",
158
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
159
+ icon: icon,
160
+ size: 48
161
+ })
162
+ }), backNav ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
163
+ alignment: "left",
164
+ style: {
165
+ position: 'relative'
166
+ },
167
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
168
+ className: "newspack-section-header__back-nav",
169
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
170
+ text: (0, _i18n.__)('Go back', 'newspack-plugin'),
171
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
172
+ href: backNav,
173
+ icon: _icons.chevronLeft,
174
+ variant: "tertiary"
175
+ })
176
+ })
177
+ }), titleContent]
178
+ }) : titleContent, description && typeof description === 'string' && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
86
179
  children: description
87
180
  }), typeof description === 'function' && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
88
181
  children: description()
89
182
  }), description && typeof description !== 'string' && typeof description !== 'function' && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
90
183
  children: description
184
+ }), children && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
185
+ className: "newspack-section-header__children",
186
+ children: children
91
187
  })]
92
- })
188
+ }), primaryAction && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
189
+ className: "newspack-section-header__primary-action",
190
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
191
+ href: primaryAction.href,
192
+ variant: "primary",
193
+ onClick: primaryAction.action,
194
+ children: primaryAction.label
195
+ })
196
+ })]
93
197
  });
94
198
  };
95
- var _default = exports.default = SectionHeader;
199
+ var _default = exports["default"] = SectionHeader;