newspack-components 3.0.0 → 4.0.0

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 (197) hide show
  1. package/colors/colors.module.scss +277 -0
  2. package/copy-styles.js +8 -1
  3. package/dist/cjs/action-card/action-card.d.js +5 -0
  4. package/dist/cjs/action-card/index.js +282 -186
  5. package/dist/cjs/action-card/style.scss +142 -44
  6. package/dist/cjs/autocomplete-tokenfield/index.js +6 -2
  7. package/dist/cjs/box-contrast/index.js +49 -0
  8. package/dist/cjs/button/index.js +1 -1
  9. package/dist/cjs/button-props/button-props.js +41 -0
  10. package/dist/cjs/button-props/index.js +13 -0
  11. package/dist/cjs/color-picker/index.js +11 -0
  12. package/dist/cjs/custom-select-control/style.scss +7 -12
  13. package/dist/cjs/footer/index.js +17 -24
  14. package/dist/cjs/footer/style.scss +0 -36
  15. package/dist/cjs/handoff-message/index.js +0 -3
  16. package/dist/cjs/hooks/useObjectState.js +9 -0
  17. package/dist/cjs/hooks/useObjectState.test.js +6 -6
  18. package/dist/cjs/image-upload/index.test.js +2 -2
  19. package/dist/cjs/index.js +7 -21
  20. package/dist/cjs/modal/index.js +16 -18
  21. package/dist/cjs/modal/style.scss +18 -7
  22. package/dist/cjs/newspack-icon/index.js +2 -2
  23. package/dist/cjs/newspack-icon/style.scss +3 -5
  24. package/dist/cjs/notice/index.js +1 -2
  25. package/dist/cjs/notice/style.scss +11 -9
  26. package/dist/cjs/plugin-installer/index.js +3 -3
  27. package/dist/cjs/plugin-settings/SettingsSection.js +2 -0
  28. package/dist/cjs/plugin-settings/index.js +4 -1
  29. package/dist/cjs/plugin-toggle/index.js +2 -0
  30. package/dist/cjs/popover/style.scss +5 -6
  31. package/dist/cjs/progress-bar/index.test.js +8 -9
  32. package/dist/cjs/progress-bar/style.scss +1 -2
  33. package/dist/cjs/proxied-imports/router.js +1 -2
  34. package/dist/cjs/radio-control/style.scss +8 -11
  35. package/dist/cjs/section-header/index.js +21 -1
  36. package/dist/cjs/select-control/ButtonGroupControl.js +2 -0
  37. package/dist/cjs/settings/SettingsCard.js +2 -6
  38. package/dist/cjs/sortable-newsletter-list-control/index.js +7 -5
  39. package/dist/cjs/sortable-newsletter-list-control/style.scss +11 -1
  40. package/dist/cjs/steps-list/style.scss +0 -3
  41. package/dist/cjs/steps-list-item/style.scss +1 -2
  42. package/dist/cjs/style-card/index.js +1 -0
  43. package/dist/cjs/style-card/style.scss +4 -5
  44. package/dist/cjs/style.scss +15 -0
  45. package/dist/cjs/tabbed-navigation/index.js +17 -7
  46. package/dist/cjs/tabbed-navigation/style.scss +2 -6
  47. package/dist/cjs/utils/color.js +35 -0
  48. package/dist/cjs/web-preview/index.js +1 -1
  49. package/dist/cjs/web-preview/style.scss +11 -11
  50. package/dist/cjs/with-wizard/index.js +80 -3
  51. package/dist/cjs/with-wizard/style.scss +34 -13
  52. package/dist/cjs/with-wizard-screen/index.js +3 -3
  53. package/dist/cjs/with-wizard-screen/style.scss +9 -9
  54. package/dist/cjs/wizard/index.js +38 -13
  55. package/dist/cjs/wizard/store/index.js +13 -5
  56. package/dist/cjs/wizard/store/utils.js +3 -1
  57. package/dist/esm/action-card/action-card.d.js +1 -0
  58. package/dist/esm/action-card/index.js +286 -188
  59. package/dist/esm/action-card/style.scss +142 -44
  60. package/dist/esm/autocomplete-tokenfield/index.js +6 -2
  61. package/dist/esm/box-contrast/index.js +44 -0
  62. package/dist/esm/button/index.js +1 -1
  63. package/dist/esm/button-props/button-props.js +34 -0
  64. package/dist/esm/button-props/index.js +1 -0
  65. package/dist/esm/color-picker/index.js +11 -0
  66. package/dist/esm/custom-select-control/style.scss +7 -12
  67. package/dist/esm/footer/index.js +18 -25
  68. package/dist/esm/footer/style.scss +0 -36
  69. package/dist/esm/handoff-message/index.js +0 -3
  70. package/dist/esm/hooks/useObjectState.js +12 -2
  71. package/dist/esm/hooks/useObjectState.test.js +7 -7
  72. package/dist/esm/hooks/usePrompt.js +2 -2
  73. package/dist/esm/image-upload/index.test.js +2 -2
  74. package/dist/esm/index.js +1 -3
  75. package/dist/esm/modal/index.js +17 -19
  76. package/dist/esm/modal/style.scss +18 -7
  77. package/dist/esm/newspack-icon/index.js +2 -2
  78. package/dist/esm/newspack-icon/style.scss +3 -5
  79. package/dist/esm/notice/index.js +1 -2
  80. package/dist/esm/notice/style.scss +11 -9
  81. package/dist/esm/plugin-installer/index.js +3 -3
  82. package/dist/esm/plugin-settings/SettingsSection.js +2 -0
  83. package/dist/esm/plugin-settings/index.js +4 -1
  84. package/dist/esm/plugin-toggle/index.js +2 -0
  85. package/dist/esm/popover/style.scss +5 -6
  86. package/dist/esm/progress-bar/index.test.js +7 -7
  87. package/dist/esm/progress-bar/style.scss +1 -2
  88. package/dist/esm/radio-control/style.scss +8 -11
  89. package/dist/esm/section-header/index.js +22 -0
  90. package/dist/esm/select-control/ButtonGroupControl.js +2 -0
  91. package/dist/esm/settings/SettingsCard.js +2 -6
  92. package/dist/esm/sortable-newsletter-list-control/index.js +8 -6
  93. package/dist/esm/sortable-newsletter-list-control/style.scss +11 -1
  94. package/dist/esm/steps-list/style.scss +0 -3
  95. package/dist/esm/steps-list-item/style.scss +1 -2
  96. package/dist/esm/style-card/index.js +1 -0
  97. package/dist/esm/style-card/style.scss +4 -5
  98. package/dist/esm/style.scss +15 -0
  99. package/dist/esm/tabbed-navigation/index.js +17 -7
  100. package/dist/esm/tabbed-navigation/style.scss +2 -6
  101. package/dist/esm/utils/color.js +29 -0
  102. package/dist/esm/web-preview/index.js +1 -1
  103. package/dist/esm/web-preview/style.scss +11 -11
  104. package/dist/esm/with-wizard/index.js +81 -4
  105. package/dist/esm/with-wizard/style.scss +34 -13
  106. package/dist/esm/with-wizard-screen/index.js +1 -1
  107. package/dist/esm/with-wizard-screen/style.scss +9 -9
  108. package/dist/esm/wizard/index.js +39 -13
  109. package/dist/esm/wizard/store/index.js +14 -6
  110. package/dist/esm/wizard/store/utils.js +3 -1
  111. package/package.json +2 -2
  112. package/src/accordion/index.js +1 -3
  113. package/src/action-card/action-card.d.ts +40 -0
  114. package/src/action-card/index.js +284 -201
  115. package/src/action-card/style.scss +142 -44
  116. package/src/autocomplete-tokenfield/index.js +3 -2
  117. package/src/autocomplete-with-suggestions/index.js +52 -63
  118. package/src/box-contrast/index.tsx +44 -0
  119. package/src/button/index.tsx +1 -1
  120. package/src/button-card/index.js +1 -12
  121. package/src/card/index.js +1 -11
  122. package/src/category-autocomplete/index.js +4 -19
  123. package/src/color-picker/index.js +11 -7
  124. package/src/custom-select-control/style.scss +7 -12
  125. package/src/footer/index.js +6 -18
  126. package/src/footer/style.scss +0 -36
  127. package/src/form-token-field/index.js +1 -2
  128. package/src/grid/index.tsx +1 -8
  129. package/src/handoff/index.js +4 -11
  130. package/src/handoff-message/index.js +0 -3
  131. package/src/hooks/useObjectState.js +10 -2
  132. package/src/hooks/useObjectState.test.js +14 -14
  133. package/src/image-upload/index.js +3 -23
  134. package/src/index.js +1 -3
  135. package/src/modal/index.js +11 -17
  136. package/src/modal/style.scss +18 -7
  137. package/src/newspack-icon/index.js +3 -14
  138. package/src/newspack-icon/style.scss +3 -5
  139. package/src/notice/index.js +0 -2
  140. package/src/notice/style.scss +11 -9
  141. package/src/plugin-installer/index.js +8 -17
  142. package/src/plugin-settings/SettingsSection.js +3 -7
  143. package/src/plugin-settings/index.js +7 -14
  144. package/src/plugin-toggle/README.md +3 -3
  145. package/src/plugin-toggle/index.js +10 -13
  146. package/src/popover/index.js +1 -5
  147. package/src/popover/style.scss +5 -6
  148. package/src/position-control/index.js +65 -75
  149. package/src/progress-bar/index.js +2 -9
  150. package/src/progress-bar/index.test.js +4 -13
  151. package/src/progress-bar/style.scss +1 -2
  152. package/src/radio-control/style.scss +8 -11
  153. package/src/section-header/index.js +20 -0
  154. package/src/select-control/ButtonGroupControl.js +2 -9
  155. package/src/select-control/GroupedSelectControl.js +1 -9
  156. package/src/select-control/index.js +1 -5
  157. package/src/settings/MinMaxSetting.js +2 -14
  158. package/src/settings/SettingsCard.js +2 -11
  159. package/src/sortable-newsletter-list-control/index.js +10 -26
  160. package/src/sortable-newsletter-list-control/style.scss +11 -1
  161. package/src/steps-list/style.scss +0 -3
  162. package/src/steps-list-item/index.js +1 -4
  163. package/src/steps-list-item/style.scss +1 -2
  164. package/src/style-card/index.js +6 -21
  165. package/src/style-card/style.scss +4 -5
  166. package/src/style.scss +15 -0
  167. package/src/tabbed-navigation/index.js +19 -7
  168. package/src/tabbed-navigation/style.scss +2 -6
  169. package/src/text-control/index.tsx +2 -12
  170. package/src/utils/color.ts +32 -0
  171. package/src/web-preview/style.scss +11 -11
  172. package/src/with-wizard/index.js +67 -16
  173. package/src/with-wizard/style.scss +34 -13
  174. package/src/with-wizard-screen/index.js +1 -1
  175. package/src/with-wizard-screen/style.scss +9 -9
  176. package/src/wizard/components/WizardError.js +2 -7
  177. package/src/wizard/index.js +64 -62
  178. package/src/wizard/store/index.js +8 -10
  179. package/src/wizard/store/utils.js +3 -4
  180. package/dist/cjs/date-range-picker/index.js +0 -39
  181. package/dist/cjs/date-range-picker/style.scss +0 -148
  182. package/dist/cjs/newspack-logo/index.js +0 -54
  183. package/dist/cjs/newspack-logo/style.scss +0 -30
  184. package/dist/cjs/patrons-logo/index.js +0 -77
  185. package/dist/esm/date-range-picker/index.js +0 -31
  186. package/dist/esm/date-range-picker/style.scss +0 -148
  187. package/dist/esm/newspack-logo/index.js +0 -46
  188. package/dist/esm/newspack-logo/style.scss +0 -30
  189. package/dist/esm/patrons-logo/index.js +0 -70
  190. package/shared/scss/_colors.scss +0 -27
  191. package/src/date-range-picker/index.js +0 -31
  192. package/src/date-range-picker/style.scss +0 -148
  193. package/src/newspack-logo/index.js +0 -45
  194. package/src/newspack-logo/style.scss +0 -30
  195. package/src/patrons-logo/index.js +0 -76
  196. /package/{shared/js → src/button-props}/button-props.js +0 -0
  197. /package/{shared/js → src/button-props}/index.js +0 -0
@@ -13,11 +13,9 @@ var _icons = require("@wordpress/icons");
13
13
  var _ = require("../");
14
14
  var _router = _interopRequireDefault(require("../proxied-imports/router"));
15
15
  var _store = _interopRequireWildcard(require("./store"));
16
- var _utils = require("./store/utils");
17
16
  var _WizardError = _interopRequireDefault(require("./components/WizardError"));
18
17
  var _jsxRuntime = require("react/jsx-runtime");
19
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ 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); }
21
19
  /**
22
20
  * External dependencies.
23
21
  */
@@ -37,22 +35,45 @@ const {
37
35
  Route,
38
36
  Switch
39
37
  } = _router.default;
38
+
39
+ /**
40
+ * @typedef {Object} WizardProps
41
+ * @property {string} headerText The header text.
42
+ * @property {string} [subHeaderText] The sub-header text, optional.
43
+ * @property {string} [apiSlug] The API slug, optional.
44
+ * @property {string} [className] CSS classes, optional.
45
+ * @property {any[]} sections Array of sections.
46
+ * @property {boolean} [hasSimpleFooter] Indicates if a simple footer is used, optional.
47
+ * @property {() => void} [renderAboveSections] Function to render content above sections, optional.
48
+ * @property {string[]} [requiredPlugins] Array of required plugin strings, optional.
49
+ * @property {boolean} [isInitialFetchTriggered] Indicates if the initial fetch should be triggered, optional.
50
+ */
51
+
52
+ /**
53
+ * Wizard Component
54
+ *
55
+ * Provides a tabbed UI with history.
56
+ *
57
+ * @param {WizardProps} props
58
+ * @return {JSX.Element} Wizard component
59
+ */
40
60
  const Wizard = ({
41
61
  sections = [],
42
- apiSlug,
43
62
  headerText,
63
+ apiSlug,
44
64
  subHeaderText,
45
65
  hasSimpleFooter,
46
66
  className,
47
67
  renderAboveSections,
48
- requiredPlugins = []
49
- }) => {
68
+ requiredPlugins = [],
69
+ isInitialFetchTriggered = true
70
+ }, ref) => {
50
71
  const isLoading = (0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).isLoading());
51
72
  const isQuietLoading = (0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).isQuietLoading());
52
73
 
53
74
  // Trigger initial data fetch. Some sections might not use the wizard data,
54
75
  // but for consistency, fetching is triggered regardless of the section.
55
- (0, _data.useSelect)(select => select(_store.WIZARD_STORE_NAMESPACE).getWizardAPIData(apiSlug));
76
+ (0, _data.useSelect)(select => isInitialFetchTriggered && select(_store.WIZARD_STORE_NAMESPACE).getWizardAPIData(apiSlug));
56
77
  let displayedSections = sections.filter(section => !section.isHidden);
57
78
  const [pluginRequirementsSatisfied, setPluginRequirementsSatisfied] = (0, _element.useState)(requiredPlugins.length === 0);
58
79
  if (!pluginRequirementsSatisfied) {
@@ -67,7 +88,9 @@ const Wizard = ({
67
88
  })
68
89
  }];
69
90
  }
70
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
91
+ const urlWithoutHash = window.location.href.split('#')[0];
92
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
93
+ ref: ref,
71
94
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
72
95
  className: (0, _classnames.default)(isLoading ? 'newspack-wizard__is-loading' : 'newspack-wizard__is-loaded', {
73
96
  'newspack-wizard__is-loading-quiet': isQuietLoading
@@ -82,7 +105,7 @@ const Wizard = ({
82
105
  className: "newspack-wizard__header__inner",
83
106
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
84
107
  className: "newspack-wizard__title",
85
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
108
+ children: [newspack_urls.dashboard !== urlWithoutHash ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
86
109
  isLink: true,
87
110
  href: newspack_urls.dashboard,
88
111
  label: (0, _i18n.__)('Return to Dashboard', 'newspack-plugin'),
@@ -92,6 +115,8 @@ const Wizard = ({
92
115
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.NewspackIcon, {
93
116
  size: 36
94
117
  })
118
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_.NewspackIcon, {
119
+ size: 36
95
120
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
96
121
  children: [headerText && /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
97
122
  children: headerText
@@ -106,11 +131,13 @@ const Wizard = ({
106
131
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_WizardError.default, {})
107
132
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_.HandoffMessage, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Switch, {
108
133
  children: [displayedSections.map((section, index) => {
134
+ var _section$exact;
109
135
  const SectionComponent = section.render;
110
136
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Route, {
137
+ exact: (_section$exact = section.exact) !== null && _section$exact !== void 0 ? _section$exact : false,
111
138
  path: section.path,
112
139
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
113
- className: (0, _classnames.default)('newspack-wizard newspack-wizard__content', className),
140
+ className: (0, _classnames.default)('newspack-wizard__content', className),
114
141
  children: ['function' === typeof renderAboveSections ? renderAboveSections() : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(SectionComponent, {})]
115
142
  })
116
143
  }, index);
@@ -124,6 +151,4 @@ const Wizard = ({
124
151
  })]
125
152
  });
126
153
  };
127
- Wizard.useWizardData = _utils.useWizardData;
128
- Wizard.STORE_NAMESPACE = _store.WIZARD_STORE_NAMESPACE;
129
- var _default = exports.default = Wizard;
154
+ var _default = exports.default = (0, _element.forwardRef)(Wizard);
@@ -21,7 +21,7 @@ var _utils = require("./utils.js");
21
21
 
22
22
  const WIZARD_STORE_NAMESPACE = exports.WIZARD_STORE_NAMESPACE = 'newspack/wizards';
23
23
  const DEFAULT_STATE = {
24
- isLoading: true,
24
+ isLoading: false,
25
25
  isQuietLoading: false,
26
26
  apiData: {},
27
27
  error: null
@@ -120,6 +120,10 @@ const selectors = {
120
120
  isLoading: state => state.isLoading,
121
121
  isQuietLoading: state => state.isQuietLoading,
122
122
  getWizardAPIData: (state, slug) => state.apiData[slug] || {},
123
+ getWizardData: (state, slug) => {
124
+ var _state$apiData$slug;
125
+ return (_state$apiData$slug = state.apiData[slug]) !== null && _state$apiData$slug !== void 0 ? _state$apiData$slug : {};
126
+ },
123
127
  getError: state => state.error
124
128
  };
125
129
  const store = (0, _data.createReduxStore)(WIZARD_STORE_NAMESPACE, {
@@ -128,17 +132,21 @@ const store = (0, _data.createReduxStore)(WIZARD_STORE_NAMESPACE, {
128
132
  selectors,
129
133
  controls: {
130
134
  FETCH_FROM_API: action => {
135
+ const {
136
+ isLocalError = false,
137
+ isQuietFetch = false
138
+ } = action.payload;
131
139
  (0, _data.dispatch)(WIZARD_STORE_NAMESPACE).startLoadingData({
132
- isQuietLoading: Boolean(action.payload.isQuietFetch)
140
+ isQuietLoading: Boolean(isQuietFetch)
133
141
  });
134
142
  return (0, _apiFetch.default)(action.payload).then(data => {
135
143
  (0, _data.dispatch)(WIZARD_STORE_NAMESPACE).setError(null);
136
144
  return data;
137
145
  }).catch(error => {
146
+ if (isLocalError) {
147
+ throw error;
148
+ }
138
149
  (0, _data.dispatch)(WIZARD_STORE_NAMESPACE).setError(error);
139
- return {
140
- error
141
- };
142
150
  }).finally(result => {
143
151
  (0, _data.dispatch)(WIZARD_STORE_NAMESPACE).finishLoadingData();
144
152
  return result;
@@ -19,5 +19,7 @@ const createAction = type => payload => ({
19
19
  payload
20
20
  });
21
21
  exports.createAction = createAction;
22
- const useWizardData = (wizardName, defaultValue = {}) => (0, _data.useSelect)(select => select(_.WIZARD_STORE_NAMESPACE).getWizardAPIData(`newspack-${wizardName}-wizard`)) || defaultValue;
22
+ const useWizardData = (wizardName, defaultValue = {}) => {
23
+ return (0, _data.useSelect)(select => select(_.WIZARD_STORE_NAMESPACE).getWizardAPIData(wizardName)) || defaultValue;
24
+ };
23
25
  exports.useWizardData = useWizardData;
@@ -0,0 +1 @@
1
+ export {};