newspack-components 2.0.1 → 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 (251) hide show
  1. package/copy-styles.js +1 -1
  2. package/dist/cjs/action-card/index.js +32 -22
  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 +69 -35
  11. package/dist/cjs/card/index.js +3 -1
  12. package/dist/cjs/card/style.scss +34 -61
  13. package/dist/cjs/category-autocomplete/index.js +52 -13
  14. package/dist/cjs/category-autocomplete/style.scss +19 -15
  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/index.js +1 -1
  24. package/dist/cjs/grid/style.scss +29 -1
  25. package/dist/cjs/handoff/index.js +7 -7
  26. package/dist/cjs/image-upload/index.js +1 -1
  27. package/dist/cjs/image-upload/style.scss +10 -11
  28. package/dist/cjs/index.js +7 -53
  29. package/dist/cjs/modal/index.js +0 -3
  30. package/dist/cjs/modal/style.scss +19 -131
  31. package/dist/cjs/newspack-icon/index.js +4 -2
  32. package/dist/cjs/newspack-icon/style.scss +15 -0
  33. package/dist/cjs/notice/index.js +8 -9
  34. package/dist/cjs/notice/style.scss +38 -10
  35. package/dist/cjs/plugin-installer/index.js +4 -2
  36. package/dist/cjs/plugin-settings/SettingsSection.js +76 -45
  37. package/dist/cjs/plugin-settings/index.js +49 -34
  38. package/dist/cjs/plugin-settings/style.scss +7 -0
  39. package/dist/cjs/plugin-toggle/index.js +22 -1
  40. package/dist/cjs/popover/style.scss +2 -2
  41. package/dist/cjs/radio-control/style.scss +1 -2
  42. package/dist/cjs/section-header/index.js +18 -5
  43. package/dist/cjs/section-header/style.scss +26 -1
  44. package/dist/cjs/select-control/ButtonGroupControl.js +8 -8
  45. package/dist/cjs/select-control/GroupedSelectControl.js +33 -30
  46. package/dist/cjs/select-control/index.js +1 -2
  47. package/dist/cjs/select-control/style.scss +46 -87
  48. package/dist/cjs/settings/MinMaxSetting.js +4 -2
  49. package/dist/cjs/settings/SettingsCard.js +6 -1
  50. package/dist/cjs/settings/SettingsSection.js +4 -4
  51. package/dist/cjs/settings/style.scss +32 -4
  52. package/dist/cjs/style-card/index.js +10 -6
  53. package/dist/cjs/style-card/style.scss +12 -8
  54. package/dist/cjs/style.scss +44 -0
  55. package/dist/cjs/tabbed-navigation/index.js +13 -20
  56. package/dist/cjs/tabbed-navigation/style.scss +56 -34
  57. package/dist/cjs/text-control/index.js +0 -3
  58. package/dist/cjs/text-control/style.scss +0 -126
  59. package/dist/cjs/waiting/index.js +9 -25
  60. package/dist/cjs/waiting/style.scss +9 -20
  61. package/dist/cjs/web-preview/index.js +18 -30
  62. package/dist/cjs/web-preview/style.scss +33 -26
  63. package/dist/cjs/with-wizard/index.js +4 -2
  64. package/dist/cjs/with-wizard/style.scss +77 -89
  65. package/dist/cjs/with-wizard-screen/index.js +17 -21
  66. package/dist/cjs/with-wizard-screen/style.scss +74 -121
  67. package/dist/cjs/wizard/components/WizardError.js +86 -0
  68. package/dist/cjs/wizard/index.js +145 -0
  69. package/dist/cjs/wizard/store/index.js +178 -0
  70. package/dist/cjs/wizard/store/utils.js +31 -0
  71. package/dist/esm/action-card/index.js +33 -23
  72. package/dist/esm/action-card/style.scss +52 -27
  73. package/dist/esm/autocomplete-tokenfield/style.scss +4 -4
  74. package/dist/esm/autocomplete-with-suggestions/index.js +3 -2
  75. package/dist/esm/autocomplete-with-suggestions/style.scss +19 -20
  76. package/dist/esm/button/index.js +2 -12
  77. package/dist/esm/button/style.scss +3 -344
  78. package/dist/esm/button-card/index.js +10 -6
  79. package/dist/esm/button-card/style.scss +69 -35
  80. package/dist/esm/card/index.js +3 -1
  81. package/dist/esm/card/style.scss +34 -61
  82. package/dist/esm/category-autocomplete/index.js +54 -14
  83. package/dist/esm/category-autocomplete/style.scss +19 -15
  84. package/dist/esm/color-picker/index.js +15 -34
  85. package/dist/esm/color-picker/style.scss +20 -160
  86. package/dist/esm/custom-select-control/style.scss +12 -42
  87. package/dist/esm/footer/index.js +21 -7
  88. package/dist/esm/footer/style.scss +9 -10
  89. package/dist/esm/form-token-field/index.js +2 -2
  90. package/dist/esm/form-token-field/style.scss +8 -103
  91. package/dist/esm/global-notices/index.js +2 -1
  92. package/dist/esm/grid/index.js +1 -1
  93. package/dist/esm/grid/style.scss +29 -1
  94. package/dist/esm/handoff/index.js +7 -7
  95. package/dist/esm/image-upload/index.js +1 -1
  96. package/dist/esm/image-upload/style.scss +10 -11
  97. package/dist/esm/index.js +3 -8
  98. package/dist/esm/modal/index.js +0 -3
  99. package/dist/esm/modal/style.scss +19 -131
  100. package/dist/esm/newspack-icon/index.js +4 -2
  101. package/dist/esm/newspack-icon/style.scss +15 -0
  102. package/dist/esm/notice/index.js +8 -3
  103. package/dist/esm/notice/style.scss +38 -10
  104. package/dist/esm/plugin-installer/index.js +5 -2
  105. package/dist/esm/plugin-settings/SettingsSection.js +74 -46
  106. package/dist/esm/plugin-settings/index.js +48 -34
  107. package/dist/esm/plugin-settings/style.scss +7 -0
  108. package/dist/esm/plugin-toggle/index.js +23 -1
  109. package/dist/esm/popover/style.scss +2 -2
  110. package/dist/esm/radio-control/style.scss +1 -2
  111. package/dist/esm/section-header/index.js +17 -5
  112. package/dist/esm/section-header/style.scss +26 -1
  113. package/dist/esm/select-control/ButtonGroupControl.js +8 -8
  114. package/dist/esm/select-control/GroupedSelectControl.js +33 -30
  115. package/dist/esm/select-control/index.js +1 -2
  116. package/dist/esm/select-control/style.scss +46 -87
  117. package/dist/esm/settings/MinMaxSetting.js +3 -2
  118. package/dist/esm/settings/SettingsCard.js +6 -1
  119. package/dist/esm/settings/SettingsSection.js +5 -5
  120. package/dist/esm/settings/style.scss +32 -4
  121. package/dist/esm/style-card/index.js +11 -8
  122. package/dist/esm/style-card/style.scss +12 -8
  123. package/dist/esm/style.scss +44 -0
  124. package/dist/esm/tabbed-navigation/index.js +14 -22
  125. package/dist/esm/tabbed-navigation/style.scss +56 -34
  126. package/dist/esm/text-control/index.js +0 -3
  127. package/dist/esm/text-control/style.scss +0 -126
  128. package/dist/esm/waiting/index.js +9 -22
  129. package/dist/esm/waiting/style.scss +9 -20
  130. package/dist/esm/web-preview/index.js +12 -25
  131. package/dist/esm/web-preview/style.scss +33 -26
  132. package/dist/esm/with-wizard/index.js +4 -2
  133. package/dist/esm/with-wizard/style.scss +77 -89
  134. package/dist/esm/with-wizard-screen/index.js +18 -22
  135. package/dist/esm/with-wizard-screen/style.scss +74 -121
  136. package/dist/esm/wizard/components/WizardError.js +78 -0
  137. package/dist/esm/wizard/index.js +128 -0
  138. package/dist/esm/wizard/store/index.js +161 -0
  139. package/dist/esm/wizard/store/utils.js +17 -0
  140. package/package.json +2 -1
  141. package/shared/scss/_colors.scss +15 -0
  142. package/src/action-card/index.js +31 -19
  143. package/src/action-card/style.scss +52 -27
  144. package/src/autocomplete-tokenfield/style.scss +4 -4
  145. package/src/autocomplete-with-suggestions/index.js +4 -2
  146. package/src/autocomplete-with-suggestions/style.scss +19 -20
  147. package/src/button/index.js +2 -9
  148. package/src/button/style.scss +3 -344
  149. package/src/button-card/index.js +19 -5
  150. package/src/button-card/style.scss +69 -35
  151. package/src/card/index.js +4 -0
  152. package/src/card/style.scss +34 -61
  153. package/src/category-autocomplete/index.js +51 -18
  154. package/src/category-autocomplete/style.scss +19 -15
  155. package/src/color-picker/index.js +16 -22
  156. package/src/color-picker/style.scss +20 -160
  157. package/src/custom-select-control/style.scss +12 -42
  158. package/src/footer/index.js +19 -8
  159. package/src/footer/style.scss +9 -10
  160. package/src/form-token-field/index.js +1 -1
  161. package/src/form-token-field/style.scss +8 -103
  162. package/src/global-notices/index.js +1 -1
  163. package/src/grid/index.js +1 -1
  164. package/src/grid/style.scss +29 -1
  165. package/src/handoff/index.js +7 -7
  166. package/src/image-upload/style.scss +10 -11
  167. package/src/index.js +3 -7
  168. package/src/modal/index.js +2 -5
  169. package/src/modal/style.scss +19 -131
  170. package/src/newspack-icon/index.js +7 -2
  171. package/src/newspack-icon/style.scss +15 -0
  172. package/src/notice/index.js +7 -1
  173. package/src/notice/style.scss +38 -10
  174. package/src/plugin-installer/index.js +4 -2
  175. package/src/plugin-settings/SettingsSection.js +65 -27
  176. package/src/plugin-settings/index.js +45 -18
  177. package/src/plugin-settings/style.scss +7 -0
  178. package/src/plugin-toggle/index.js +35 -9
  179. package/src/popover/style.scss +2 -2
  180. package/src/radio-control/style.scss +1 -2
  181. package/src/section-header/index.js +25 -6
  182. package/src/section-header/style.scss +26 -1
  183. package/src/select-control/ButtonGroupControl.js +13 -6
  184. package/src/select-control/GroupedSelectControl.js +26 -24
  185. package/src/select-control/index.js +1 -2
  186. package/src/select-control/style.scss +46 -87
  187. package/src/settings/MinMaxSetting.js +2 -1
  188. package/src/settings/SettingsCard.js +9 -7
  189. package/src/settings/SettingsSection.js +4 -4
  190. package/src/settings/style.scss +32 -4
  191. package/src/style-card/index.js +14 -16
  192. package/src/style-card/style.scss +12 -8
  193. package/src/style.scss +44 -0
  194. package/src/tabbed-navigation/index.js +12 -24
  195. package/src/tabbed-navigation/style.scss +56 -34
  196. package/src/text-control/index.js +1 -2
  197. package/src/text-control/style.scss +0 -126
  198. package/src/waiting/index.js +7 -18
  199. package/src/waiting/style.scss +9 -20
  200. package/src/web-preview/index.js +12 -33
  201. package/src/web-preview/style.scss +33 -26
  202. package/src/with-wizard/index.js +7 -5
  203. package/src/with-wizard/style.scss +77 -89
  204. package/src/with-wizard-screen/index.js +14 -17
  205. package/src/with-wizard-screen/style.scss +74 -121
  206. package/src/wizard/components/WizardError.js +57 -0
  207. package/src/wizard/index.js +133 -0
  208. package/src/wizard/store/index.js +126 -0
  209. package/src/wizard/store/utils.js +16 -0
  210. package/dist/cjs/button-group/index.js +0 -57
  211. package/dist/cjs/button-group/style.scss +0 -68
  212. package/dist/cjs/checkbox-control/index.js +0 -63
  213. package/dist/cjs/checkbox-control/style.scss +0 -78
  214. package/dist/cjs/preview-box/index.js +0 -36
  215. package/dist/cjs/preview-box/style.scss +0 -18
  216. package/dist/cjs/textarea-control/index.js +0 -54
  217. package/dist/cjs/textarea-control/style.scss +0 -76
  218. package/dist/cjs/toggle-control/index.js +0 -58
  219. package/dist/cjs/toggle-control/style.scss +0 -74
  220. package/dist/cjs/toggle-group/index.js +0 -71
  221. package/dist/cjs/toggle-group/style.scss +0 -28
  222. package/dist/cjs/wizard-pagination/index.js +0 -71
  223. package/dist/cjs/wizard-pagination/style.scss +0 -74
  224. package/dist/esm/button-group/index.js +0 -43
  225. package/dist/esm/button-group/style.scss +0 -68
  226. package/dist/esm/checkbox-control/index.js +0 -49
  227. package/dist/esm/checkbox-control/style.scss +0 -78
  228. package/dist/esm/preview-box/index.js +0 -30
  229. package/dist/esm/preview-box/style.scss +0 -18
  230. package/dist/esm/textarea-control/index.js +0 -40
  231. package/dist/esm/textarea-control/style.scss +0 -76
  232. package/dist/esm/toggle-control/index.js +0 -44
  233. package/dist/esm/toggle-control/style.scss +0 -74
  234. package/dist/esm/toggle-group/index.js +0 -58
  235. package/dist/esm/toggle-group/style.scss +0 -28
  236. package/dist/esm/wizard-pagination/index.js +0 -57
  237. package/dist/esm/wizard-pagination/style.scss +0 -74
  238. package/src/button-group/index.js +0 -35
  239. package/src/button-group/style.scss +0 -68
  240. package/src/checkbox-control/index.js +0 -38
  241. package/src/checkbox-control/style.scss +0 -78
  242. package/src/preview-box/index.js +0 -18
  243. package/src/preview-box/style.scss +0 -18
  244. package/src/textarea-control/index.js +0 -32
  245. package/src/textarea-control/style.scss +0 -76
  246. package/src/toggle-control/index.js +0 -38
  247. package/src/toggle-control/style.scss +0 -74
  248. package/src/toggle-group/index.js +0 -43
  249. package/src/toggle-group/style.scss +0 -28
  250. package/src/wizard-pagination/index.js +0 -59
  251. package/src/wizard-pagination/style.scss +0 -74
@@ -9,6 +9,8 @@ exports.default = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
12
+ var _classnames = _interopRequireDefault(require("classnames"));
13
+
12
14
  var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
13
15
 
14
16
  var _element = require("@wordpress/element");
@@ -21,6 +23,10 @@ var _SettingsSection = _interopRequireDefault(require("./SettingsSection"));
21
23
 
22
24
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
23
25
 
26
+ /**
27
+ * External dependencies
28
+ */
29
+
24
30
  /**
25
31
  * WordPress dependencies.
26
32
  */
@@ -31,18 +37,24 @@ class PluginSettings extends _element.Component {
31
37
  super(...arguments);
32
38
  (0, _defineProperty2.default)(this, "fetchSettings", () => {
33
39
  const {
34
- pluginSlug
40
+ afterFetch,
41
+ pluginSlug,
42
+ isWizard
35
43
  } = this.props;
36
44
  this.setState({
37
45
  inFlight: true
38
46
  });
39
47
  (0, _apiFetch.default)({
40
- path: `/${pluginSlug}/v1/settings`
48
+ path: isWizard ? `/newspack/v1/wizard/${pluginSlug}/settings` : `/${pluginSlug}/v1/settings`
41
49
  }).then(settings => {
42
50
  this.setState({
43
51
  settings,
44
52
  error: null
45
53
  });
54
+
55
+ if ('function' === typeof afterFetch) {
56
+ afterFetch(settings);
57
+ }
46
58
  }).catch(error => {
47
59
  this.setState({
48
60
  error
@@ -54,12 +66,10 @@ class PluginSettings extends _element.Component {
54
66
  });
55
67
  });
56
68
  (0, _defineProperty2.default)(this, "getSettingsValues", sectionKey => {
57
- var _this$state$settings$;
58
-
59
- 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) => {
60
70
  map[setting.key] = setting.value;
61
71
  return map;
62
- }, {})) || {};
72
+ }, {}) || {};
63
73
  });
64
74
  (0, _defineProperty2.default)(this, "handleSettingChange", sectionKey => (key, value) => {
65
75
  const sectionSettings = [...this.state.settings[sectionKey]];
@@ -76,13 +86,15 @@ class PluginSettings extends _element.Component {
76
86
  });
77
87
  (0, _defineProperty2.default)(this, "handleSectionUpdate", sectionKey => data => {
78
88
  const {
79
- pluginSlug
89
+ afterUpdate,
90
+ pluginSlug,
91
+ isWizard
80
92
  } = this.props;
81
93
  this.setState({
82
94
  inFlight: true
83
95
  });
84
96
  (0, _apiFetch.default)({
85
- path: `/${pluginSlug}/v1/settings`,
97
+ path: isWizard ? `/newspack/v1/wizard/${pluginSlug}/settings` : `/${pluginSlug}/v1/settings`,
86
98
  method: 'POST',
87
99
  data: {
88
100
  section: sectionKey,
@@ -93,6 +105,10 @@ class PluginSettings extends _element.Component {
93
105
  settings,
94
106
  error: null
95
107
  });
108
+
109
+ if ('function' === typeof afterUpdate) {
110
+ afterUpdate(settings);
111
+ }
96
112
  }).catch(error => {
97
113
  this.setState({
98
114
  error
@@ -104,27 +120,19 @@ class PluginSettings extends _element.Component {
104
120
  });
105
121
  });
106
122
  (0, _defineProperty2.default)(this, "getSectionInfo", sectionKey => {
107
- var _this$state$settings$2;
108
-
109
- 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');
110
124
  });
111
125
  (0, _defineProperty2.default)(this, "getSectionTitle", sectionKey => {
112
- var _this$getSectionInfo;
113
-
114
- return (_this$getSectionInfo = this.getSectionInfo(sectionKey)) === null || _this$getSectionInfo === void 0 ? void 0 : _this$getSectionInfo.description;
126
+ return this.getSectionInfo(sectionKey)?.description;
115
127
  });
116
128
  (0, _defineProperty2.default)(this, "getSectionDescription", sectionKey => {
117
- var _this$getSectionInfo2;
118
-
119
- return (_this$getSectionInfo2 = this.getSectionInfo(sectionKey)) === null || _this$getSectionInfo2 === void 0 ? void 0 : _this$getSectionInfo2.help;
129
+ return this.getSectionInfo(sectionKey)?.help;
120
130
  });
121
131
  (0, _defineProperty2.default)(this, "isSectionActive", sectionKey => {
122
- var _settings$sectionKey;
123
-
124
132
  const {
125
133
  settings
126
134
  } = this.state;
127
- 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');
128
136
 
129
137
  if (!activation) {
130
138
  return null;
@@ -133,9 +141,7 @@ class PluginSettings extends _element.Component {
133
141
  return activation.value;
134
142
  });
135
143
  (0, _defineProperty2.default)(this, "getSectionFields", sectionKey => {
136
- var _this$state$settings$3;
137
-
138
- 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');
139
145
  });
140
146
  this.state = {
141
147
  inFlight: false,
@@ -154,7 +160,9 @@ class PluginSettings extends _element.Component {
154
160
  render() {
155
161
  const {
156
162
  title,
157
- description
163
+ description,
164
+ hasGreyHeader,
165
+ children
158
166
  } = this.props;
159
167
  const {
160
168
  settings,
@@ -162,21 +170,28 @@ class PluginSettings extends _element.Component {
162
170
  error
163
171
  } = this.state;
164
172
  return (0, _jsxRuntime.jsxs)(_element.Fragment, {
165
- children: [(0, _jsxRuntime.jsx)(_.SectionHeader, {
173
+ children: [title && (0, _jsxRuntime.jsx)(_.SectionHeader, {
166
174
  title: title,
167
175
  description: description
168
176
  }), error && (0, _jsxRuntime.jsx)(_.Notice, {
169
177
  isError: true,
170
178
  noticeText: error.message
171
- }), Object.keys(settings).map(sectionKey => (0, _jsxRuntime.jsx)(_SettingsSection.default, {
172
- disabled: inFlight,
173
- title: this.getSectionTitle(sectionKey),
174
- description: this.getSectionDescription(sectionKey),
175
- active: this.isSectionActive(sectionKey),
176
- fields: this.getSectionFields(sectionKey),
177
- onChange: this.handleSettingChange(sectionKey),
178
- onUpdate: this.handleSectionUpdate(sectionKey)
179
- }, sectionKey))]
179
+ }), (0, _jsxRuntime.jsxs)("div", {
180
+ className: (0, _classnames.default)('newspack-plugin-settings', {
181
+ 'newspack-wizard-section__is-loading': inFlight && !Object.keys(settings).length
182
+ }),
183
+ children: [Object.keys(settings).map(sectionKey => (0, _jsxRuntime.jsx)(_SettingsSection.default, {
184
+ disabled: inFlight,
185
+ sectionKey: sectionKey,
186
+ title: this.getSectionTitle(sectionKey),
187
+ description: this.getSectionDescription(sectionKey),
188
+ active: this.isSectionActive(sectionKey),
189
+ fields: this.getSectionFields(sectionKey),
190
+ onChange: this.handleSettingChange(sectionKey),
191
+ onUpdate: this.handleSectionUpdate(sectionKey),
192
+ hasGreyHeader: hasGreyHeader
193
+ }, sectionKey)), children]
194
+ })]
180
195
  });
181
196
  }
182
197
 
@@ -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,14 +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
+
24
+ &:not( #{&}--no-margin ) + *:not( #{&} ) {
25
+ margin-top: -16px !important;
26
+ }
27
+
28
+ &#{&}--is-white {
29
+ > * {
30
+ color: white;
31
+ }
32
+ }
33
+
34
+ p {
35
+ color: $gray-700;
36
+ }
37
+
13
38
  .newspack-wizard__content &:first-child {
14
39
  margin-top: 32px;
15
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);
@@ -50,41 +50,44 @@ function GroupedSelectControl(_ref) {
50
50
 
51
51
  const id = _.hooks.useUniqueId('group-select');
52
52
 
53
- return (0, _jsxRuntime.jsxs)(_components.BaseControl, {
53
+ return (0, _jsxRuntime.jsx)(_components.BaseControl, {
54
54
  label: label,
55
55
  hideLabelFromVision: hideLabelFromVision,
56
56
  id: id,
57
57
  help: help,
58
58
  className: (0, _classnames.default)(className, 'components-select-control'),
59
- children: [(0, _jsxRuntime.jsxs)("select", {
60
- id: id,
61
- className: "components-select-control__input",
62
- onChange: onChangeValue,
63
- "aria-describedby": !!help ? `${id}__help` : undefined,
64
- ...props,
65
- children: [(0, _jsxRuntime.jsx)("option", {
66
- value: "",
67
- children: __('-- Select --', 'newspack')
68
- }), optgroups.map((_ref2, optgroupIndex) => {
69
- let {
70
- label: optgroupLabel,
71
- options
72
- } = _ref2;
73
- return (0, _jsxRuntime.jsx)("optgroup", {
74
- label: optgroupLabel,
75
- children: options.map((option, optionIndex) => (0, _jsxRuntime.jsx)("option", {
76
- value: option.value,
77
- disabled: option.disabled,
78
- children: option.label
79
- }, `${option.label}-${option.value}-${optionIndex}`))
80
- }, optgroupIndex);
59
+ children: (0, _jsxRuntime.jsxs)("div", {
60
+ className: "relative",
61
+ children: [(0, _jsxRuntime.jsxs)("select", {
62
+ id: id,
63
+ className: "components-select-control__input",
64
+ onChange: onChangeValue,
65
+ "aria-describedby": !!help ? `${id}__help` : undefined,
66
+ ...props,
67
+ children: [(0, _jsxRuntime.jsx)("option", {
68
+ value: "",
69
+ children: __('-- Select --', 'newspack')
70
+ }), optgroups.map((_ref2, optgroupIndex) => {
71
+ let {
72
+ label: optgroupLabel,
73
+ options
74
+ } = _ref2;
75
+ return (0, _jsxRuntime.jsx)("optgroup", {
76
+ label: optgroupLabel,
77
+ children: options.map((option, optionIndex) => (0, _jsxRuntime.jsx)("option", {
78
+ value: option.value,
79
+ disabled: option.disabled,
80
+ children: option.label
81
+ }, `${option.label}-${option.value}-${optionIndex}`))
82
+ }, optgroupIndex);
83
+ })]
84
+ }), (0, _jsxRuntime.jsx)("div", {
85
+ className: "components-select-control__arrow-wrapper",
86
+ children: (0, _jsxRuntime.jsx)(_icons.Icon, {
87
+ icon: _icons.chevronDown,
88
+ size: 18
89
+ })
81
90
  })]
82
- }), (0, _jsxRuntime.jsx)("div", {
83
- className: "components-select-control__arrow-wrapper",
84
- children: (0, _jsxRuntime.jsx)(_icons.Icon, {
85
- icon: _icons.chevronDown,
86
- size: 18
87
- })
88
- })]
91
+ })
89
92
  });
90
93
  }
@@ -45,10 +45,9 @@ class SelectControl extends _element.Component {
45
45
  className,
46
46
  optgroups,
47
47
  buttonOptions,
48
- isSmall,
49
48
  ...otherProps
50
49
  } = this.props;
51
- const classes = (0, _classnames.default)('newspack-select-control', optgroups && 'newspack-grouped-select-control', buttonOptions && 'newspack-buttons-select-control', isSmall && 'newspack-select-control--small', className);
50
+ const classes = (0, _classnames.default)('newspack-select-control', optgroups && 'newspack-grouped-select-control', buttonOptions && 'newspack-buttons-select-control', className);
52
51
  return (0, _jsxRuntime.jsx)("div", {
53
52
  className: classes,
54
53
  children: optgroups ? (0, _jsxRuntime.jsx)(_GroupedSelectControl.default, {
@@ -2,92 +2,39 @@
2
2
  * Select Control
3
3
  */
4
4
 
5
- @import '../../../shared/scss/colors';
6
5
  @import '~@wordpress/base-styles/colors';
7
6
 
8
- .newspack-select-control {
9
- color: $gray-700;
10
- font-size: 14px;
11
- line-height: 24px;
12
- margin: 32px 0;
7
+ .components-select-control {
8
+ &__input {
9
+ max-width: 100% !important;
13
10
 
14
- .components-base-control__field {
15
- margin: 0;
16
- }
17
- .components-input-control__label,
18
- .components-base-control__label {
19
- color: $gray-900 !important;
20
- display: flex;
21
- font-size: 14px;
22
- font-weight: bold;
23
- line-height: 24px;
24
- padding-bottom: 0 !important;
25
- margin-bottom: 0;
26
- }
27
-
28
- .components-select-control {
29
- border-radius: 3px;
30
- font-size: 14px;
31
- line-height: 24px;
32
-
33
- div.components-input-control__backdrop {
34
- border-color: $gray-300;
35
- }
36
-
37
- select.components-select-control__input {
38
- color: $gray-700;
39
- border-color: $gray-300;
40
- font-size: 16px;
41
- height: 48px;
42
- line-height: 24px;
43
- max-width: 100%;
44
- min-height: 48px;
11
+ &[multiple] {
12
+ height: auto !important;
13
+ min-height: 70px !important;
14
+ padding: 0 !important;
45
15
 
46
- @media screen and ( min-width: 600px ) {
47
- font-size: 16px;
16
+ + .components-input-control__suffix {
17
+ display: none;
48
18
  }
49
19
 
50
- @media screen and ( min-width: 768px ) {
51
- font-size: 14px;
52
- }
20
+ option {
21
+ min-height: 1.4em;
22
+ padding: 8px;
53
23
 
54
- &:focus ~ div.components-input-control__backdrop {
55
- border-color: $primary-500;
56
- box-shadow: inset 0 0 0 2px $primary-500;
24
+ &:checked {
25
+ background: var( --wp-admin-theme-color );
26
+ color: white;
27
+ }
57
28
  }
58
29
  }
59
30
  }
60
31
 
61
- // Help
62
-
63
- .components-base-control__help {
64
- margin-top: 0;
65
- font-style: italic;
66
- }
67
-
68
- // Small
69
-
70
- &--small {
71
- .components-select-control select.components-select-control__input {
72
- height: 36px;
73
- min-height: 36px;
74
- }
75
- }
76
-
77
- // Multiple Select Controls
78
-
79
- & + & {
80
- margin-bottom: 32px;
81
- margin-top: -16px;
32
+ .components-base-control__field {
33
+ width: 100%;
82
34
  }
83
35
 
84
- // Multiple Controls
85
-
86
- + .newspack-category-autocomplete,
87
- + .newspack-text-control,
88
- + .newspack-textarea-control {
89
- margin-bottom: 32px;
90
- margin-top: -16px;
36
+ .components-input-control__label {
37
+ line-height: inherit;
91
38
  }
92
39
  }
93
40
 
@@ -100,29 +47,38 @@
100
47
  &__input {
101
48
  appearance: none;
102
49
  background: transparent;
103
- border-radius: 3px;
50
+ border: 1px solid $gray-700;
51
+ border-radius: 2px;
104
52
  box-shadow: none !important;
105
53
  box-sizing: border-box;
106
54
  display: block;
55
+ font-size: inherit;
107
56
  margin: 0;
57
+ max-width: 100%;
108
58
  outline: none;
109
59
  padding: 0 24px 0 7px;
110
60
  width: 100%;
111
61
 
62
+ &:hover {
63
+ color: inherit;
64
+ }
65
+
112
66
  &:focus {
113
- border-color: $primary-500 !important;
114
- box-shadow: inset 0 0 0 2px $primary-500 !important;
67
+ border-color: var( --wp-admin-theme-color-darker-10 ) !important;
68
+ box-shadow: inset 0 0 0 1px var( --wp-admin-theme-color-darker-10 ) !important;
69
+ color: inherit;
115
70
  }
116
71
  }
117
72
 
118
73
  &__arrow-wrapper {
119
74
  align-items: center;
120
- bottom: 0;
121
75
  display: flex;
122
- height: 48px;
76
+ height: 24px;
123
77
  justify-content: center;
78
+ margin-top: -12px;
124
79
  position: absolute;
125
80
  right: 1px;
81
+ top: 50%;
126
82
  width: 24px;
127
83
  }
128
84
  }
@@ -131,19 +87,22 @@
131
87
  // Buttons
132
88
 
133
89
  .newspack-buttons-select-control {
134
- &.icon-only {
135
- .newspack-button-group {
136
- display: flex;
137
- }
90
+ .components-base-control__label {
91
+ display: inline-flex;
92
+ margin-bottom: 8px;
93
+ }
138
94
 
139
- .newspack-button {
95
+ .components-button-group {
96
+ display: flex;
97
+ }
98
+
99
+ &.icon-only {
100
+ .components-button {
140
101
  align-items: center;
141
- display: flex;
142
- font-size: 17px;
143
- height: 48px;
102
+ height: 36px;
144
103
  justify-content: center;
145
104
  padding: 0 !important;
146
- width: 48px;
105
+ width: 36px;
147
106
  }
148
107
  }
149
108
  }