newspack-components 2.0.3 → 2.1.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 (248) hide show
  1. package/copy-styles.js +1 -1
  2. package/dist/cjs/action-card/index.js +29 -20
  3. package/dist/cjs/action-card/style.scss +52 -27
  4. package/dist/cjs/autocomplete-tokenfield/style.scss +4 -4
  5. package/dist/cjs/autocomplete-with-suggestions/index.js +3 -2
  6. package/dist/cjs/autocomplete-with-suggestions/style.scss +19 -20
  7. package/dist/cjs/button/index.js +2 -13
  8. package/dist/cjs/button/style.scss +3 -344
  9. package/dist/cjs/button-card/index.js +11 -6
  10. package/dist/cjs/button-card/style.scss +60 -30
  11. package/dist/cjs/card/index.js +3 -1
  12. package/dist/cjs/card/style.scss +29 -62
  13. package/dist/cjs/category-autocomplete/index.js +52 -13
  14. package/dist/cjs/category-autocomplete/style.scss +20 -22
  15. package/dist/cjs/color-picker/index.js +17 -35
  16. package/dist/cjs/color-picker/style.scss +20 -160
  17. package/dist/cjs/custom-select-control/style.scss +12 -42
  18. package/dist/cjs/footer/index.js +21 -7
  19. package/dist/cjs/footer/style.scss +9 -10
  20. package/dist/cjs/form-token-field/index.js +2 -2
  21. package/dist/cjs/form-token-field/style.scss +8 -103
  22. package/dist/cjs/global-notices/index.js +2 -1
  23. package/dist/cjs/grid/style.scss +14 -1
  24. package/dist/cjs/handoff/index.js +7 -7
  25. package/dist/cjs/image-upload/index.js +1 -1
  26. package/dist/cjs/image-upload/style.scss +10 -11
  27. package/dist/cjs/index.js +7 -53
  28. package/dist/cjs/modal/index.js +0 -3
  29. package/dist/cjs/modal/style.scss +19 -131
  30. package/dist/cjs/newspack-icon/index.js +4 -2
  31. package/dist/cjs/newspack-icon/style.scss +15 -0
  32. package/dist/cjs/notice/index.js +8 -9
  33. package/dist/cjs/notice/style.scss +38 -10
  34. package/dist/cjs/plugin-installer/index.js +1 -1
  35. package/dist/cjs/plugin-settings/SettingsSection.js +74 -43
  36. package/dist/cjs/plugin-settings/index.js +34 -30
  37. package/dist/cjs/plugin-settings/style.scss +7 -0
  38. package/dist/cjs/plugin-toggle/index.js +22 -1
  39. package/dist/cjs/popover/style.scss +2 -2
  40. package/dist/cjs/radio-control/style.scss +1 -2
  41. package/dist/cjs/section-header/index.js +18 -5
  42. package/dist/cjs/section-header/style.scss +22 -1
  43. package/dist/cjs/select-control/ButtonGroupControl.js +8 -8
  44. package/dist/cjs/select-control/GroupedSelectControl.js +33 -30
  45. package/dist/cjs/select-control/index.js +1 -2
  46. package/dist/cjs/select-control/style.scss +46 -87
  47. package/dist/cjs/settings/MinMaxSetting.js +4 -2
  48. package/dist/cjs/settings/SettingsCard.js +6 -1
  49. package/dist/cjs/settings/SettingsSection.js +4 -4
  50. package/dist/cjs/settings/style.scss +32 -4
  51. package/dist/cjs/style-card/index.js +10 -6
  52. package/dist/cjs/style-card/style.scss +12 -8
  53. package/dist/cjs/style.scss +44 -0
  54. package/dist/cjs/tabbed-navigation/index.js +13 -20
  55. package/dist/cjs/tabbed-navigation/style.scss +56 -34
  56. package/dist/cjs/text-control/index.js +0 -3
  57. package/dist/cjs/text-control/style.scss +0 -126
  58. package/dist/cjs/waiting/index.js +9 -25
  59. package/dist/cjs/waiting/style.scss +9 -20
  60. package/dist/cjs/web-preview/index.js +18 -30
  61. package/dist/cjs/web-preview/style.scss +33 -26
  62. package/dist/cjs/with-wizard/index.js +4 -2
  63. package/dist/cjs/with-wizard/style.scss +44 -89
  64. package/dist/cjs/with-wizard-screen/index.js +17 -21
  65. package/dist/cjs/with-wizard-screen/style.scss +74 -121
  66. package/dist/cjs/wizard/components/WizardError.js +86 -0
  67. package/dist/cjs/wizard/index.js +145 -0
  68. package/dist/cjs/wizard/store/index.js +178 -0
  69. package/dist/cjs/wizard/store/utils.js +31 -0
  70. package/dist/esm/action-card/index.js +30 -21
  71. package/dist/esm/action-card/style.scss +52 -27
  72. package/dist/esm/autocomplete-tokenfield/style.scss +4 -4
  73. package/dist/esm/autocomplete-with-suggestions/index.js +3 -2
  74. package/dist/esm/autocomplete-with-suggestions/style.scss +19 -20
  75. package/dist/esm/button/index.js +2 -12
  76. package/dist/esm/button/style.scss +3 -344
  77. package/dist/esm/button-card/index.js +10 -6
  78. package/dist/esm/button-card/style.scss +60 -30
  79. package/dist/esm/card/index.js +3 -1
  80. package/dist/esm/card/style.scss +29 -62
  81. package/dist/esm/category-autocomplete/index.js +54 -14
  82. package/dist/esm/category-autocomplete/style.scss +20 -22
  83. package/dist/esm/color-picker/index.js +15 -34
  84. package/dist/esm/color-picker/style.scss +20 -160
  85. package/dist/esm/custom-select-control/style.scss +12 -42
  86. package/dist/esm/footer/index.js +21 -7
  87. package/dist/esm/footer/style.scss +9 -10
  88. package/dist/esm/form-token-field/index.js +2 -2
  89. package/dist/esm/form-token-field/style.scss +8 -103
  90. package/dist/esm/global-notices/index.js +2 -1
  91. package/dist/esm/grid/style.scss +14 -1
  92. package/dist/esm/handoff/index.js +7 -7
  93. package/dist/esm/image-upload/index.js +1 -1
  94. package/dist/esm/image-upload/style.scss +10 -11
  95. package/dist/esm/index.js +3 -8
  96. package/dist/esm/modal/index.js +0 -3
  97. package/dist/esm/modal/style.scss +19 -131
  98. package/dist/esm/newspack-icon/index.js +4 -2
  99. package/dist/esm/newspack-icon/style.scss +15 -0
  100. package/dist/esm/notice/index.js +8 -3
  101. package/dist/esm/notice/style.scss +38 -10
  102. package/dist/esm/plugin-installer/index.js +2 -1
  103. package/dist/esm/plugin-settings/SettingsSection.js +72 -44
  104. package/dist/esm/plugin-settings/index.js +34 -30
  105. package/dist/esm/plugin-settings/style.scss +7 -0
  106. package/dist/esm/plugin-toggle/index.js +23 -1
  107. package/dist/esm/popover/style.scss +2 -2
  108. package/dist/esm/radio-control/style.scss +1 -2
  109. package/dist/esm/section-header/index.js +17 -5
  110. package/dist/esm/section-header/style.scss +22 -1
  111. package/dist/esm/select-control/ButtonGroupControl.js +8 -8
  112. package/dist/esm/select-control/GroupedSelectControl.js +33 -30
  113. package/dist/esm/select-control/index.js +1 -2
  114. package/dist/esm/select-control/style.scss +46 -87
  115. package/dist/esm/settings/MinMaxSetting.js +3 -2
  116. package/dist/esm/settings/SettingsCard.js +6 -1
  117. package/dist/esm/settings/SettingsSection.js +5 -5
  118. package/dist/esm/settings/style.scss +32 -4
  119. package/dist/esm/style-card/index.js +11 -8
  120. package/dist/esm/style-card/style.scss +12 -8
  121. package/dist/esm/style.scss +44 -0
  122. package/dist/esm/tabbed-navigation/index.js +14 -22
  123. package/dist/esm/tabbed-navigation/style.scss +56 -34
  124. package/dist/esm/text-control/index.js +0 -3
  125. package/dist/esm/text-control/style.scss +0 -126
  126. package/dist/esm/waiting/index.js +9 -22
  127. package/dist/esm/waiting/style.scss +9 -20
  128. package/dist/esm/web-preview/index.js +12 -25
  129. package/dist/esm/web-preview/style.scss +33 -26
  130. package/dist/esm/with-wizard/index.js +4 -2
  131. package/dist/esm/with-wizard/style.scss +44 -89
  132. package/dist/esm/with-wizard-screen/index.js +18 -22
  133. package/dist/esm/with-wizard-screen/style.scss +74 -121
  134. package/dist/esm/wizard/components/WizardError.js +78 -0
  135. package/dist/esm/wizard/index.js +128 -0
  136. package/dist/esm/wizard/store/index.js +161 -0
  137. package/dist/esm/wizard/store/utils.js +17 -0
  138. package/package.json +1 -1
  139. package/shared/scss/_colors.scss +15 -0
  140. package/src/action-card/index.js +28 -18
  141. package/src/action-card/style.scss +52 -27
  142. package/src/autocomplete-tokenfield/style.scss +4 -4
  143. package/src/autocomplete-with-suggestions/index.js +4 -2
  144. package/src/autocomplete-with-suggestions/style.scss +19 -20
  145. package/src/button/index.js +2 -9
  146. package/src/button/style.scss +3 -344
  147. package/src/button-card/index.js +19 -5
  148. package/src/button-card/style.scss +60 -30
  149. package/src/card/index.js +4 -0
  150. package/src/card/style.scss +29 -62
  151. package/src/category-autocomplete/index.js +51 -18
  152. package/src/category-autocomplete/style.scss +20 -22
  153. package/src/color-picker/index.js +16 -22
  154. package/src/color-picker/style.scss +20 -160
  155. package/src/custom-select-control/style.scss +12 -42
  156. package/src/footer/index.js +19 -8
  157. package/src/footer/style.scss +9 -10
  158. package/src/form-token-field/index.js +1 -1
  159. package/src/form-token-field/style.scss +8 -103
  160. package/src/global-notices/index.js +1 -1
  161. package/src/grid/style.scss +14 -1
  162. package/src/handoff/index.js +7 -7
  163. package/src/image-upload/style.scss +10 -11
  164. package/src/index.js +3 -7
  165. package/src/modal/index.js +2 -5
  166. package/src/modal/style.scss +19 -131
  167. package/src/newspack-icon/index.js +7 -2
  168. package/src/newspack-icon/style.scss +15 -0
  169. package/src/notice/index.js +7 -1
  170. package/src/notice/style.scss +38 -10
  171. package/src/plugin-installer/index.js +2 -2
  172. package/src/plugin-settings/SettingsSection.js +64 -26
  173. package/src/plugin-settings/index.js +23 -7
  174. package/src/plugin-settings/style.scss +7 -0
  175. package/src/plugin-toggle/index.js +35 -9
  176. package/src/popover/style.scss +2 -2
  177. package/src/radio-control/style.scss +1 -2
  178. package/src/section-header/index.js +25 -6
  179. package/src/section-header/style.scss +22 -1
  180. package/src/select-control/ButtonGroupControl.js +13 -6
  181. package/src/select-control/GroupedSelectControl.js +26 -24
  182. package/src/select-control/index.js +1 -2
  183. package/src/select-control/style.scss +46 -87
  184. package/src/settings/MinMaxSetting.js +2 -1
  185. package/src/settings/SettingsCard.js +9 -7
  186. package/src/settings/SettingsSection.js +4 -4
  187. package/src/settings/style.scss +32 -4
  188. package/src/style-card/index.js +14 -16
  189. package/src/style-card/style.scss +12 -8
  190. package/src/style.scss +44 -0
  191. package/src/tabbed-navigation/index.js +12 -24
  192. package/src/tabbed-navigation/style.scss +56 -34
  193. package/src/text-control/index.js +1 -2
  194. package/src/text-control/style.scss +0 -126
  195. package/src/waiting/index.js +7 -18
  196. package/src/waiting/style.scss +9 -20
  197. package/src/web-preview/index.js +12 -33
  198. package/src/web-preview/style.scss +33 -26
  199. package/src/with-wizard/index.js +7 -5
  200. package/src/with-wizard/style.scss +44 -89
  201. package/src/with-wizard-screen/index.js +14 -17
  202. package/src/with-wizard-screen/style.scss +74 -121
  203. package/src/wizard/components/WizardError.js +57 -0
  204. package/src/wizard/index.js +133 -0
  205. package/src/wizard/store/index.js +126 -0
  206. package/src/wizard/store/utils.js +16 -0
  207. package/dist/cjs/button-group/index.js +0 -57
  208. package/dist/cjs/button-group/style.scss +0 -73
  209. package/dist/cjs/checkbox-control/index.js +0 -63
  210. package/dist/cjs/checkbox-control/style.scss +0 -78
  211. package/dist/cjs/preview-box/index.js +0 -36
  212. package/dist/cjs/preview-box/style.scss +0 -18
  213. package/dist/cjs/textarea-control/index.js +0 -54
  214. package/dist/cjs/textarea-control/style.scss +0 -76
  215. package/dist/cjs/toggle-control/index.js +0 -58
  216. package/dist/cjs/toggle-control/style.scss +0 -74
  217. package/dist/cjs/toggle-group/index.js +0 -71
  218. package/dist/cjs/toggle-group/style.scss +0 -28
  219. package/dist/cjs/wizard-pagination/index.js +0 -71
  220. package/dist/cjs/wizard-pagination/style.scss +0 -74
  221. package/dist/esm/button-group/index.js +0 -43
  222. package/dist/esm/button-group/style.scss +0 -73
  223. package/dist/esm/checkbox-control/index.js +0 -49
  224. package/dist/esm/checkbox-control/style.scss +0 -78
  225. package/dist/esm/preview-box/index.js +0 -30
  226. package/dist/esm/preview-box/style.scss +0 -18
  227. package/dist/esm/textarea-control/index.js +0 -40
  228. package/dist/esm/textarea-control/style.scss +0 -76
  229. package/dist/esm/toggle-control/index.js +0 -44
  230. package/dist/esm/toggle-control/style.scss +0 -74
  231. package/dist/esm/toggle-group/index.js +0 -58
  232. package/dist/esm/toggle-group/style.scss +0 -28
  233. package/dist/esm/wizard-pagination/index.js +0 -57
  234. package/dist/esm/wizard-pagination/style.scss +0 -74
  235. package/src/button-group/index.js +0 -35
  236. package/src/button-group/style.scss +0 -73
  237. package/src/checkbox-control/index.js +0 -38
  238. package/src/checkbox-control/style.scss +0 -78
  239. package/src/preview-box/index.js +0 -18
  240. package/src/preview-box/style.scss +0 -18
  241. package/src/textarea-control/index.js +0 -32
  242. package/src/textarea-control/style.scss +0 -76
  243. package/src/toggle-control/index.js +0 -38
  244. package/src/toggle-control/style.scss +0 -74
  245. package/src/toggle-group/index.js +0 -43
  246. package/src/toggle-group/style.scss +0 -28
  247. package/src/wizard-pagination/index.js +0 -59
  248. package/src/wizard-pagination/style.scss +0 -74
@@ -6,14 +6,11 @@
6
6
  @import '../../../shared/scss/colors';
7
7
 
8
8
  .newspack-notice {
9
- align-items: flex-start;
9
+ align-items: center;
10
10
  background: $gray-100;
11
- border-radius: 3px;
12
11
  color: $gray-900;
13
12
  display: flex;
14
- font-size: 14px;
15
13
  justify-content: flex-start;
16
- line-height: 24px;
17
14
  margin: 32px 0;
18
15
  padding: 6px 8px;
19
16
 
@@ -24,8 +21,25 @@
24
21
  margin-right: 4px;
25
22
  }
26
23
 
24
+ &__is-debug {
25
+ background: $primary-700;
26
+ border-radius: 2px;
27
+ bottom: 16px;
28
+ box-shadow: 0 0 8px 4px rgba( black, 0.08 );
29
+ color: white;
30
+ font-weight: bold;
31
+ margin: 0 16px;
32
+ position: fixed;
33
+ text-transform: uppercase;
34
+ z-index: 9997;
35
+
36
+ > svg {
37
+ fill: white;
38
+ }
39
+ }
40
+
27
41
  &__is-error {
28
- background: lighten( $alert-red, 54% );
42
+ background: lighten( $alert-red, 51% );
29
43
 
30
44
  > svg {
31
45
  fill: $alert-red;
@@ -34,7 +48,7 @@
34
48
  }
35
49
 
36
50
  &__is-help {
37
- background: $primary-000;
51
+ background: $primary-050;
38
52
 
39
53
  > svg {
40
54
  fill: $primary-500;
@@ -42,7 +56,7 @@
42
56
  }
43
57
 
44
58
  &__is-success {
45
- background: lighten( $alert-green, 47% );
59
+ background: lighten( $alert-green, 42% );
46
60
 
47
61
  > svg {
48
62
  fill: $alert-green;
@@ -50,7 +64,7 @@
50
64
  }
51
65
 
52
66
  &__is-warning {
53
- background: lighten( $alert-yellow, 36% );
67
+ background: lighten( $alert-yellow, 30% );
54
68
 
55
69
  > svg {
56
70
  fill: $alert-yellow;
@@ -58,9 +72,23 @@
58
72
  }
59
73
  }
60
74
 
61
- &__content {
75
+ & &__content {
62
76
  > div > * {
63
- margin: 0;
77
+ margin: 0 !important;
78
+ }
79
+
80
+ a {
81
+ color: inherit;
82
+
83
+ &:active,
84
+ &:focus,
85
+ &:hover {
86
+ color: inherit;
87
+ }
88
+
89
+ &:focus {
90
+ box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) currentColor;
91
+ }
64
92
  }
65
93
  }
66
94
 
@@ -216,7 +216,7 @@ class PluginInstaller extends _element.Component {
216
216
  const plugin = pluginInfo[slug];
217
217
  return plugin.Status !== 'active' && plugin.installationStatus === PLUGIN_STATE_NONE;
218
218
  });
219
- return (0, _jsxRuntime.jsxs)("div", {
219
+ return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
220
220
  children: [(!pluginInfo || !Object.keys(pluginInfo).length) && (0, _jsxRuntime.jsxs)("div", {
221
221
  className: "newspack-plugin-installer_is-waiting",
222
222
  children: [(0, _jsxRuntime.jsx)(_.Waiting, {
@@ -7,10 +7,16 @@ exports.default = void 0;
7
7
 
8
8
  var _element = require("@wordpress/element");
9
9
 
10
+ var _hooks = require("@wordpress/hooks");
11
+
10
12
  var _i18n = require("@wordpress/i18n");
11
13
 
14
+ var _components = require("@wordpress/components");
15
+
12
16
  var _ = require("../");
13
17
 
18
+ require("./style.scss");
19
+
14
20
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
21
 
16
22
  /**
@@ -22,15 +28,19 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
22
28
  */
23
29
  const __ = _i18n.__;
24
30
 
31
+ const isSelectControl = setting => {
32
+ return Array.isArray(setting.options) && setting.options.length;
33
+ };
34
+
25
35
  const getControlComponent = setting => {
26
- if (Array.isArray(setting.options) && setting.options.length) {
36
+ if (isSelectControl(setting)) {
27
37
  return _.SelectControl;
28
38
  }
29
39
 
30
40
  switch (setting.type) {
31
41
  case 'checkbox':
32
42
  case 'boolean':
33
- return _.CheckboxControl;
43
+ return _components.CheckboxControl;
34
44
 
35
45
  default:
36
46
  return _.TextControl;
@@ -49,13 +59,22 @@ const getControlType = setting => {
49
59
  case 'text':
50
60
  return 'text';
51
61
 
62
+ case 'password':
63
+ return 'password';
64
+
65
+ case 'boolean':
66
+ case 'checkbox':
67
+ return 'checkbox';
68
+
52
69
  default:
53
70
  return null;
54
71
  }
55
72
  };
56
73
 
57
- const SettingsSection = _ref => {
58
- let {
74
+ const SettingsSection = props => {
75
+ const {
76
+ error,
77
+ sectionKey,
59
78
  active,
60
79
  title,
61
80
  description,
@@ -63,61 +82,73 @@ const SettingsSection = _ref => {
63
82
  disabled,
64
83
  onChange,
65
84
  onUpdate
66
- } = _ref;
67
-
68
- const getControlProps = setting => {
69
- var _setting$options;
70
-
71
- return {
72
- disabled,
73
- name: `${setting.section}_${setting.key}`,
74
- type: getControlType(setting),
75
- label: setting.description,
76
- help: setting.help || null,
77
- options: ((_setting$options = setting.options) === null || _setting$options === void 0 ? void 0 : _setting$options.map(option => ({
78
- value: option.value,
79
- label: option.name
80
- }))) || null,
81
- value: setting.value,
82
- checked: setting.type === 'boolean' ? !!setting.value : null,
83
- onChange: value => {
84
- onChange(setting.key, value);
85
- }
86
- };
85
+ } = props;
86
+
87
+ const getControlProps = setting => ({
88
+ disabled,
89
+ name: `${setting.section}_${setting.key}`,
90
+ type: getControlType(setting),
91
+ label: setting.description,
92
+ help: setting.help || null,
93
+ options: setting.options?.map(option => ({
94
+ value: option.value,
95
+ label: option.name || option.label
96
+ })) || null,
97
+ value: setting.value,
98
+ multiple: isSelectControl(setting) && setting.multiple ? true : null,
99
+ checked: setting.type === 'boolean' ? !!setting.value : null,
100
+ onChange: value => {
101
+ onChange(setting.key, value);
102
+ }
103
+ });
104
+
105
+ const createFilter = function (name) {
106
+ let defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
107
+ return (0, _hooks.applyFilters)(`newspack.settingSection.${sectionKey}.${name}`, defaultComponent, props);
87
108
  };
88
109
 
110
+ let columns = 2;
111
+
112
+ if (fields.length % 3 === 0) {
113
+ columns = 3;
114
+ } else if (fields.length === 1) {
115
+ columns = 1;
116
+ }
117
+
89
118
  return (0, _jsxRuntime.jsx)(_.ActionCard, {
90
119
  isMedium: true,
91
120
  disabled: disabled,
92
121
  title: title,
93
122
  description: description,
94
123
  toggleChecked: active,
95
- hasGreyHeader: true,
124
+ hasGreyHeader: active || null === active,
96
125
  toggleOnChange: active !== null ? value => onUpdate({
97
126
  active: value
98
127
  }) : null,
128
+ actionContent: (active || null === active) && createFilter('buttons', (0, _jsxRuntime.jsx)(_.Button, {
129
+ variant: "primary",
130
+ disabled: disabled,
131
+ onClick: () => {
132
+ onUpdate();
133
+ },
134
+ children: __('Save Settings', 'newspack')
135
+ })),
99
136
  children: (active || active === null) && (0, _jsxRuntime.jsxs)(_element.Fragment, {
100
- children: [(0, _jsxRuntime.jsx)(_.Grid, {
101
- columns: fields.length % 3 === 0 ? 3 : 2,
137
+ children: [error?.message && (0, _jsxRuntime.jsx)(_.Notice, {
138
+ noticeText: error.message,
139
+ isError: true
140
+ }), createFilter('beforeControls'), (0, _jsxRuntime.jsx)(_.Grid, {
141
+ columns: columns,
102
142
  gutter: 32,
103
143
  children: fields.map(setting => {
104
144
  const Control = getControlComponent(setting); // eslint-disable-line @wordpress/no-unused-vars-before-return, no-unused-vars
105
145
 
106
- return (0, _jsxRuntime.jsx)(Control, { ...getControlProps(setting)
107
- }, setting.key);
108
- })
109
- }), (0, _jsxRuntime.jsx)("div", {
110
- className: "newspack-buttons-card",
111
- style: {
112
- margin: '32px 0 0'
113
- },
114
- children: (0, _jsxRuntime.jsx)(_.Button, {
115
- isPrimary: true,
116
- disabled: disabled,
117
- onClick: () => {
118
- onUpdate();
119
- },
120
- children: __('Save settings', 'newspack')
146
+ return (0, _hooks.applyFilters)(`newspack.settingsSection.${sectionKey}.control`, (0, _jsxRuntime.jsx)(Control, { ...getControlProps(setting)
147
+ }, setting.key), {
148
+ sectionKey,
149
+ setting,
150
+ onChange
151
+ });
121
152
  })
122
153
  })]
123
154
  })
@@ -37,18 +37,24 @@ class PluginSettings extends _element.Component {
37
37
  super(...arguments);
38
38
  (0, _defineProperty2.default)(this, "fetchSettings", () => {
39
39
  const {
40
- pluginSlug
40
+ afterFetch,
41
+ pluginSlug,
42
+ isWizard
41
43
  } = this.props;
42
44
  this.setState({
43
45
  inFlight: true
44
46
  });
45
47
  (0, _apiFetch.default)({
46
- path: `/${pluginSlug}/v1/settings`
48
+ path: isWizard ? `/newspack/v1/wizard/${pluginSlug}/settings` : `/${pluginSlug}/v1/settings`
47
49
  }).then(settings => {
48
50
  this.setState({
49
51
  settings,
50
52
  error: null
51
53
  });
54
+
55
+ if ('function' === typeof afterFetch) {
56
+ afterFetch(settings);
57
+ }
52
58
  }).catch(error => {
53
59
  this.setState({
54
60
  error
@@ -60,12 +66,10 @@ class PluginSettings extends _element.Component {
60
66
  });
61
67
  });
62
68
  (0, _defineProperty2.default)(this, "getSettingsValues", sectionKey => {
63
- var _this$state$settings$;
64
-
65
- return ((_this$state$settings$ = this.state.settings[sectionKey]) === null || _this$state$settings$ === void 0 ? void 0 : _this$state$settings$.reduce((map, setting) => {
69
+ return this.state.settings[sectionKey]?.reduce((map, setting) => {
66
70
  map[setting.key] = setting.value;
67
71
  return map;
68
- }, {})) || {};
72
+ }, {}) || {};
69
73
  });
70
74
  (0, _defineProperty2.default)(this, "handleSettingChange", sectionKey => (key, value) => {
71
75
  const sectionSettings = [...this.state.settings[sectionKey]];
@@ -82,13 +86,15 @@ class PluginSettings extends _element.Component {
82
86
  });
83
87
  (0, _defineProperty2.default)(this, "handleSectionUpdate", sectionKey => data => {
84
88
  const {
85
- pluginSlug
89
+ afterUpdate,
90
+ pluginSlug,
91
+ isWizard
86
92
  } = this.props;
87
93
  this.setState({
88
94
  inFlight: true
89
95
  });
90
96
  (0, _apiFetch.default)({
91
- path: `/${pluginSlug}/v1/settings`,
97
+ path: isWizard ? `/newspack/v1/wizard/${pluginSlug}/settings` : `/${pluginSlug}/v1/settings`,
92
98
  method: 'POST',
93
99
  data: {
94
100
  section: sectionKey,
@@ -99,6 +105,10 @@ class PluginSettings extends _element.Component {
99
105
  settings,
100
106
  error: null
101
107
  });
108
+
109
+ if ('function' === typeof afterUpdate) {
110
+ afterUpdate(settings);
111
+ }
102
112
  }).catch(error => {
103
113
  this.setState({
104
114
  error
@@ -110,27 +120,19 @@ class PluginSettings extends _element.Component {
110
120
  });
111
121
  });
112
122
  (0, _defineProperty2.default)(this, "getSectionInfo", sectionKey => {
113
- var _this$state$settings$2;
114
-
115
- return (_this$state$settings$2 = this.state.settings[sectionKey]) === null || _this$state$settings$2 === void 0 ? void 0 : _this$state$settings$2.find(setting => !setting.key || setting.key === 'active');
123
+ return this.state.settings[sectionKey]?.find(setting => !setting.key || setting.key === 'active');
116
124
  });
117
125
  (0, _defineProperty2.default)(this, "getSectionTitle", sectionKey => {
118
- var _this$getSectionInfo;
119
-
120
- return (_this$getSectionInfo = this.getSectionInfo(sectionKey)) === null || _this$getSectionInfo === void 0 ? void 0 : _this$getSectionInfo.description;
126
+ return this.getSectionInfo(sectionKey)?.description;
121
127
  });
122
128
  (0, _defineProperty2.default)(this, "getSectionDescription", sectionKey => {
123
- var _this$getSectionInfo2;
124
-
125
- return (_this$getSectionInfo2 = this.getSectionInfo(sectionKey)) === null || _this$getSectionInfo2 === void 0 ? void 0 : _this$getSectionInfo2.help;
129
+ return this.getSectionInfo(sectionKey)?.help;
126
130
  });
127
131
  (0, _defineProperty2.default)(this, "isSectionActive", sectionKey => {
128
- var _settings$sectionKey;
129
-
130
132
  const {
131
133
  settings
132
134
  } = this.state;
133
- const activation = (_settings$sectionKey = settings[sectionKey]) === null || _settings$sectionKey === void 0 ? void 0 : _settings$sectionKey.find(setting => setting.key === 'active');
135
+ const activation = settings[sectionKey]?.find(setting => setting.key === 'active');
134
136
 
135
137
  if (!activation) {
136
138
  return null;
@@ -139,9 +141,7 @@ class PluginSettings extends _element.Component {
139
141
  return activation.value;
140
142
  });
141
143
  (0, _defineProperty2.default)(this, "getSectionFields", sectionKey => {
142
- var _this$state$settings$3;
143
-
144
- return (_this$state$settings$3 = this.state.settings[sectionKey]) === null || _this$state$settings$3 === void 0 ? void 0 : _this$state$settings$3.filter(setting => setting.key && setting.key !== 'active');
144
+ return this.state.settings[sectionKey]?.filter(setting => setting.key && setting.key !== 'active');
145
145
  });
146
146
  this.state = {
147
147
  inFlight: false,
@@ -160,7 +160,9 @@ class PluginSettings extends _element.Component {
160
160
  render() {
161
161
  const {
162
162
  title,
163
- description
163
+ description,
164
+ hasGreyHeader,
165
+ children
164
166
  } = this.props;
165
167
  const {
166
168
  settings,
@@ -168,25 +170,27 @@ class PluginSettings extends _element.Component {
168
170
  error
169
171
  } = this.state;
170
172
  return (0, _jsxRuntime.jsxs)(_element.Fragment, {
171
- children: [(0, _jsxRuntime.jsx)(_.SectionHeader, {
173
+ children: [title && (0, _jsxRuntime.jsx)(_.SectionHeader, {
172
174
  title: title,
173
175
  description: description
174
176
  }), error && (0, _jsxRuntime.jsx)(_.Notice, {
175
177
  isError: true,
176
178
  noticeText: error.message
177
- }), (0, _jsxRuntime.jsx)("div", {
178
- className: (0, _classnames.default)({
179
+ }), (0, _jsxRuntime.jsxs)("div", {
180
+ className: (0, _classnames.default)('newspack-plugin-settings', {
179
181
  'newspack-wizard-section__is-loading': inFlight && !Object.keys(settings).length
180
182
  }),
181
- children: Object.keys(settings).map(sectionKey => (0, _jsxRuntime.jsx)(_SettingsSection.default, {
183
+ children: [Object.keys(settings).map(sectionKey => (0, _jsxRuntime.jsx)(_SettingsSection.default, {
182
184
  disabled: inFlight,
185
+ sectionKey: sectionKey,
183
186
  title: this.getSectionTitle(sectionKey),
184
187
  description: this.getSectionDescription(sectionKey),
185
188
  active: this.isSectionActive(sectionKey),
186
189
  fields: this.getSectionFields(sectionKey),
187
190
  onChange: this.handleSettingChange(sectionKey),
188
- onUpdate: this.handleSectionUpdate(sectionKey)
189
- }, sectionKey))
191
+ onUpdate: this.handleSectionUpdate(sectionKey),
192
+ hasGreyHeader: hasGreyHeader
193
+ }, sectionKey)), children]
190
194
  })]
191
195
  });
192
196
  }
@@ -0,0 +1,7 @@
1
+ .newspack-card:not( .newspack-settings__no-border ) {
2
+ .newspack-action-card__region-children {
3
+ > .newspack-grid {
4
+ margin: 32px 0 0 !important;
5
+ }
6
+ }
7
+ }
@@ -80,6 +80,14 @@ class PluginToggle extends _element.Component {
80
80
  }
81
81
  };
82
82
  }, () => shouldRefreshAfterUpdate && location.reload());
83
+ }).catch(e => {
84
+ this.setState({
85
+ pluginInfo: { ...pluginInfo,
86
+ [plugin]: { ...pluginInfo[plugin],
87
+ error: e.message || __('There was an error managing this plugin.', 'newspack')
88
+ }
89
+ }
90
+ });
83
91
  });
84
92
  });
85
93
  });
@@ -142,6 +150,15 @@ class PluginToggle extends _element.Component {
142
150
  return actionText ? actionText : __('Configure', 'newspack');
143
151
  }
144
152
  });
153
+ (0, _defineProperty2.default)(this, "errorForPlugin", plugin => {
154
+ const {
155
+ slug
156
+ } = plugin;
157
+ const {
158
+ pluginInfo
159
+ } = this.state;
160
+ return pluginInfo[slug]?.error || null;
161
+ });
145
162
  (0, _defineProperty2.default)(this, "isPluginInstalledAndActive", plugin => {
146
163
  const {
147
164
  status
@@ -170,6 +187,7 @@ class PluginToggle extends _element.Component {
170
187
  } = plugin;
171
188
  const pluginStatus = this.isPluginInstalledAndActive(plugin);
172
189
  const handoff = !href && pluginStatus && editPath ? slug : null;
190
+ const error = this.errorForPlugin(plugin);
173
191
  return (0, _jsxRuntime.jsx)(_.ActionCard, {
174
192
  className: this.classNameForPlugin(plugin),
175
193
  title: name,
@@ -179,7 +197,10 @@ class PluginToggle extends _element.Component {
179
197
  href: href,
180
198
  toggle: true,
181
199
  toggleChecked: this.isPluginInstalledAndActive(plugin),
182
- toggleOnChange: value => this.managePlugin(slug, value)
200
+ toggleOnChange: value => this.managePlugin(slug, value),
201
+ notification: error,
202
+ notificationHTML: error,
203
+ notificationLevel: "error"
183
204
  }, index);
184
205
  });
185
206
  }
@@ -8,7 +8,7 @@
8
8
  .newspack-popover {
9
9
  .components-popover__content {
10
10
  border: 1px solid $gray-300;
11
- border-radius: 3px;
11
+ border-radius: 2px;
12
12
  box-shadow: 0 4px 8px rgba( black, 0.08 );
13
13
  min-width: 238px;
14
14
 
@@ -31,7 +31,7 @@
31
31
  }
32
32
 
33
33
  &.is-link {
34
- border-radius: 3px;
34
+ border-radius: 2px;
35
35
  padding: 6px 8px;
36
36
  text-decoration: none;
37
37
 
@@ -76,8 +76,7 @@
76
76
  // Multiple Controls
77
77
 
78
78
  + .newspack-select-control,
79
- + .newspack-text-control,
80
- + .newspack-textarea-control {
79
+ + .newspack-text-control {
81
80
  margin-bottom: 32px;
82
81
  margin-top: -16px;
83
82
  }
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
+ var _ = require("..");
11
+
10
12
  require("./style.scss");
11
13
 
12
14
  var _classnames = _interopRequireDefault(require("classnames"));
@@ -26,23 +28,34 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
26
28
  */
27
29
  const SectionHeader = _ref => {
28
30
  let {
31
+ centered,
29
32
  className,
30
33
  description,
34
+ heading,
35
+ isWhite,
31
36
  noMargin,
32
37
  title
33
38
  } = _ref;
34
- const classes = (0, _classnames.default)('newspack-section-header', noMargin && 'newspack-section-header--no-margin', className);
35
- return (0, _jsxRuntime.jsxs)("div", {
39
+ 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);
40
+ const HeadingTag = `h${heading}`;
41
+ return (0, _jsxRuntime.jsxs)(_.Grid, {
42
+ columns: 1,
43
+ gutter: 8,
36
44
  className: classes,
37
- children: [(0, _jsxRuntime.jsx)("h2", {
45
+ children: [typeof title === 'string' && (0, _jsxRuntime.jsx)(HeadingTag, {
38
46
  children: title
39
- }), typeof description === 'string' && (0, _jsxRuntime.jsx)("span", {
47
+ }), typeof title === 'function' && (0, _jsxRuntime.jsx)(HeadingTag, {
48
+ children: title()
49
+ }), typeof description === 'string' && (0, _jsxRuntime.jsx)("p", {
40
50
  children: description
41
- }), typeof description === 'function' && (0, _jsxRuntime.jsx)("span", {
51
+ }), typeof description === 'function' && (0, _jsxRuntime.jsx)("p", {
42
52
  children: description()
43
53
  })]
44
54
  });
45
55
  };
46
56
 
57
+ SectionHeader.defaultProps = {
58
+ heading: 2
59
+ };
47
60
  var _default = SectionHeader;
48
61
  exports.default = _default;
@@ -2,18 +2,39 @@
2
2
  * Section Header
3
3
  */
4
4
 
5
+ @import '~@wordpress/base-styles/colors';
6
+
5
7
  .newspack-section-header {
6
8
  margin: 64px 0 32px;
7
9
 
8
10
  &--no-margin,
9
- h2 {
11
+ h1,
12
+ h2,
13
+ h3,
14
+ h4,
15
+ h5,
16
+ h6 {
10
17
  margin: 0 !important;
11
18
  }
12
19
 
20
+ &--is-centered {
21
+ text-align: center;
22
+ }
23
+
13
24
  &:not( #{&}--no-margin ) + *:not( #{&} ) {
14
25
  margin-top: -16px !important;
15
26
  }
16
27
 
28
+ &#{&}--is-white {
29
+ > * {
30
+ color: white;
31
+ }
32
+ }
33
+
34
+ p {
35
+ color: $gray-700;
36
+ }
37
+
17
38
  .newspack-wizard__content &:first-child {
18
39
  margin-top: 32px;
19
40
  }
@@ -31,20 +31,21 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
31
31
  const ButtonGroupControl = _ref => {
32
32
  let {
33
33
  buttonOptions,
34
- onChange,
35
- value,
34
+ className,
35
+ hideLabelFromVision,
36
36
  label,
37
- className
37
+ onChange,
38
+ value
38
39
  } = _ref;
39
40
 
40
41
  const id = _.hooks.useUniqueId('button-group');
41
42
 
42
43
  return (0, _jsxRuntime.jsx)(_components.BaseControl, {
43
44
  label: label,
45
+ hideLabelFromVision: hideLabelFromVision,
44
46
  id: id.current,
45
47
  className: (0, _classnames.default)(className, 'components-select-control'),
46
- children: (0, _jsxRuntime.jsx)(_.ButtonGroup, {
47
- noMargin: true,
48
+ children: (0, _jsxRuntime.jsx)(_components.ButtonGroup, {
48
49
  children: buttonOptions.map(option => {
49
50
  const isSelected = value === option.value;
50
51
 
@@ -57,9 +58,8 @@ const ButtonGroupControl = _ref => {
57
58
  });
58
59
  }
59
60
 
60
- return (0, _jsxRuntime.jsx)(_.Button, {
61
- isSecondary: !isSelected,
62
- isPressed: isSelected,
61
+ return (0, _jsxRuntime.jsx)(_components.Button, {
62
+ variant: isSelected ? 'primary' : null,
63
63
  onClick: () => onChange(option.value),
64
64
  children: (0, _jsxRuntime.jsx)(Label, {})
65
65
  }, option.value);