newspack-components 2.1.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/dist/cjs/accordion/index.js +46 -0
  2. package/dist/cjs/accordion/style.scss +27 -0
  3. package/dist/cjs/action-card/index.js +48 -25
  4. package/dist/cjs/action-card/style.scss +100 -23
  5. package/dist/cjs/autocomplete-tokenfield/index.js +13 -41
  6. package/dist/cjs/autocomplete-tokenfield/style.scss +2 -2
  7. package/dist/cjs/autocomplete-with-suggestions/index.js +30 -51
  8. package/dist/cjs/autocomplete-with-suggestions/style.scss +16 -15
  9. package/dist/cjs/button/index.js +5 -13
  10. package/dist/cjs/button-card/index.js +1 -10
  11. package/dist/cjs/button-card/style.scss +13 -13
  12. package/dist/cjs/card/index.js +1 -8
  13. package/dist/cjs/card/style.scss +25 -8
  14. package/dist/cjs/category-autocomplete/index.js +18 -38
  15. package/dist/cjs/category-autocomplete/style.scss +0 -2
  16. package/dist/cjs/color-picker/index.js +1 -15
  17. package/dist/cjs/color-picker/style.scss +0 -3
  18. package/dist/cjs/consts.js +5 -3
  19. package/dist/cjs/custom-select-control/index.js +1 -9
  20. package/dist/cjs/custom-select-control/style.scss +6 -7
  21. package/dist/cjs/date-range-picker/index.js +1 -10
  22. package/dist/cjs/date-range-picker/style.scss +12 -12
  23. package/dist/cjs/footer/index.js +5 -17
  24. package/dist/cjs/footer/style.scss +5 -5
  25. package/dist/cjs/form-token-field/index.js +1 -9
  26. package/dist/cjs/form-token-field/style.scss +2 -3
  27. package/dist/cjs/global-notices/index.js +1 -8
  28. package/dist/cjs/grid/index.js +1 -8
  29. package/dist/cjs/grid/style.scss +5 -5
  30. package/dist/cjs/handoff/index.js +8 -17
  31. package/dist/cjs/handoff-message/index.js +50 -0
  32. package/dist/cjs/hooks/index.js +1 -7
  33. package/dist/cjs/hooks/useObjectState.js +7 -13
  34. package/dist/cjs/hooks/useObjectState.test.js +0 -14
  35. package/dist/cjs/hooks/useOnClickOutside.js +3 -6
  36. package/dist/cjs/hooks/usePrompt.js +1 -13
  37. package/dist/cjs/image-upload/index.js +21 -19
  38. package/dist/cjs/image-upload/index.test.js +0 -5
  39. package/dist/cjs/image-upload/style.scss +5 -9
  40. package/dist/cjs/index.js +28 -44
  41. package/dist/cjs/info-button/index.js +3 -11
  42. package/dist/cjs/info-button/style.scss +1 -3
  43. package/dist/cjs/modal/index.js +1 -9
  44. package/dist/cjs/modal/style.scss +8 -8
  45. package/dist/cjs/newspack-icon/index.js +1 -9
  46. package/dist/cjs/newspack-icon/style.scss +4 -4
  47. package/dist/cjs/newspack-logo/index.js +1 -9
  48. package/dist/cjs/newspack-logo/style.scss +3 -3
  49. package/dist/cjs/notice/index.js +8 -15
  50. package/dist/cjs/notice/style.scss +28 -15
  51. package/dist/cjs/patrons-logo/index.js +3 -11
  52. package/dist/cjs/plugin-installer/index.js +36 -36
  53. package/dist/cjs/plugin-installer/style.scss +5 -5
  54. package/dist/cjs/plugin-settings/SettingsSection.js +9 -28
  55. package/dist/cjs/plugin-settings/index.js +39 -22
  56. package/dist/cjs/plugin-toggle/index.js +40 -33
  57. package/dist/cjs/plugin-toggle/style.scss +2 -2
  58. package/dist/cjs/popover/index.js +1 -11
  59. package/dist/cjs/popover/style.scss +19 -16
  60. package/dist/cjs/position-control/index.js +113 -0
  61. package/dist/cjs/position-control/style.scss +66 -0
  62. package/dist/cjs/progress-bar/index.js +2 -9
  63. package/dist/cjs/progress-bar/index.test.js +2 -7
  64. package/dist/cjs/progress-bar/style.scss +4 -4
  65. package/dist/cjs/proxied-imports/router.js +0 -3
  66. package/dist/cjs/radio-control/index.js +1 -11
  67. package/dist/cjs/radio-control/style.scss +9 -9
  68. package/dist/cjs/section-header/index.js +44 -29
  69. package/dist/cjs/section-header/style.scss +2 -2
  70. package/dist/cjs/select-control/ButtonGroupControl.js +4 -13
  71. package/dist/cjs/select-control/GroupedSelectControl.js +9 -15
  72. package/dist/cjs/select-control/index.js +5 -12
  73. package/dist/cjs/select-control/style.scss +2 -2
  74. package/dist/cjs/settings/MinMaxSetting.js +3 -7
  75. package/dist/cjs/settings/SettingsCard.js +3 -7
  76. package/dist/cjs/settings/SettingsSection.js +1 -4
  77. package/dist/cjs/settings/index.js +0 -6
  78. package/dist/cjs/settings/style.scss +1 -1
  79. package/dist/cjs/steps-list/index.js +52 -0
  80. package/dist/cjs/steps-list/style.scss +11 -0
  81. package/dist/cjs/steps-list-item/index.js +56 -0
  82. package/dist/cjs/steps-list-item/style.scss +47 -0
  83. package/dist/cjs/style-card/index.js +6 -13
  84. package/dist/cjs/style-card/style.scss +9 -12
  85. package/dist/cjs/style.scss +5 -6
  86. package/dist/cjs/tabbed-navigation/index.js +19 -16
  87. package/dist/cjs/tabbed-navigation/style.scss +3 -4
  88. package/dist/cjs/text-control/index.js +6 -16
  89. package/dist/cjs/utils/index.js +10 -5
  90. package/dist/cjs/waiting/index.js +1 -9
  91. package/dist/cjs/web-preview/index.js +13 -28
  92. package/dist/cjs/web-preview/style.scss +14 -14
  93. package/dist/cjs/with-wizard/index.js +51 -31
  94. package/dist/cjs/with-wizard/style.scss +35 -37
  95. package/dist/cjs/with-wizard-screen/index.js +11 -17
  96. package/dist/cjs/with-wizard-screen/style.scss +14 -17
  97. package/dist/cjs/wizard/components/WizardError.js +3 -15
  98. package/dist/cjs/wizard/index.js +10 -24
  99. package/dist/cjs/wizard/store/index.js +42 -55
  100. package/dist/cjs/wizard/store/utils.js +1 -6
  101. package/dist/esm/accordion/index.js +38 -0
  102. package/dist/esm/accordion/style.scss +27 -0
  103. package/dist/esm/action-card/index.js +50 -21
  104. package/dist/esm/action-card/style.scss +100 -23
  105. package/dist/esm/autocomplete-tokenfield/index.js +14 -37
  106. package/dist/esm/autocomplete-tokenfield/style.scss +2 -2
  107. package/dist/esm/autocomplete-with-suggestions/index.js +28 -41
  108. package/dist/esm/autocomplete-with-suggestions/style.scss +16 -15
  109. package/dist/esm/button/index.js +5 -7
  110. package/dist/esm/button-card/index.js +2 -5
  111. package/dist/esm/button-card/style.scss +13 -13
  112. package/dist/esm/card/index.js +2 -5
  113. package/dist/esm/card/style.scss +25 -8
  114. package/dist/esm/category-autocomplete/index.js +17 -30
  115. package/dist/esm/category-autocomplete/style.scss +0 -2
  116. package/dist/esm/color-picker/index.js +2 -4
  117. package/dist/esm/color-picker/style.scss +0 -3
  118. package/dist/esm/consts.js +3 -2
  119. package/dist/esm/custom-select-control/index.js +2 -5
  120. package/dist/esm/custom-select-control/style.scss +6 -7
  121. package/dist/esm/date-range-picker/index.js +1 -3
  122. package/dist/esm/date-range-picker/style.scss +12 -12
  123. package/dist/esm/footer/index.js +3 -11
  124. package/dist/esm/footer/style.scss +5 -5
  125. package/dist/esm/form-token-field/index.js +2 -5
  126. package/dist/esm/form-token-field/style.scss +2 -3
  127. package/dist/esm/global-notices/index.js +1 -6
  128. package/dist/esm/grid/index.js +2 -5
  129. package/dist/esm/grid/style.scss +5 -5
  130. package/dist/esm/handoff/index.js +3 -14
  131. package/dist/esm/handoff-message/index.js +45 -0
  132. package/dist/esm/hooks/index.js +0 -2
  133. package/dist/esm/hooks/useObjectState.js +3 -8
  134. package/dist/esm/hooks/useObjectState.test.js +0 -3
  135. package/dist/esm/hooks/useOnClickOutside.js +2 -5
  136. package/dist/esm/hooks/usePrompt.js +1 -8
  137. package/dist/esm/image-upload/index.js +17 -16
  138. package/dist/esm/image-upload/style.scss +5 -9
  139. package/dist/esm/index.js +4 -0
  140. package/dist/esm/info-button/index.js +4 -6
  141. package/dist/esm/info-button/style.scss +1 -3
  142. package/dist/esm/modal/index.js +2 -5
  143. package/dist/esm/modal/style.scss +8 -8
  144. package/dist/esm/newspack-icon/index.js +2 -5
  145. package/dist/esm/newspack-icon/style.scss +4 -4
  146. package/dist/esm/newspack-logo/index.js +2 -5
  147. package/dist/esm/newspack-logo/style.scss +3 -3
  148. package/dist/esm/notice/index.js +4 -8
  149. package/dist/esm/notice/style.scss +28 -15
  150. package/dist/esm/patrons-logo/index.js +3 -5
  151. package/dist/esm/plugin-installer/index.js +35 -39
  152. package/dist/esm/plugin-installer/style.scss +5 -5
  153. package/dist/esm/plugin-settings/SettingsSection.js +8 -21
  154. package/dist/esm/plugin-settings/index.js +38 -24
  155. package/dist/esm/plugin-toggle/index.js +39 -36
  156. package/dist/esm/plugin-toggle/style.scss +2 -2
  157. package/dist/esm/popover/index.js +3 -6
  158. package/dist/esm/popover/style.scss +19 -16
  159. package/dist/esm/position-control/index.js +109 -0
  160. package/dist/esm/position-control/style.scss +66 -0
  161. package/dist/esm/progress-bar/index.js +2 -7
  162. package/dist/esm/progress-bar/index.test.js +2 -1
  163. package/dist/esm/progress-bar/style.scss +4 -4
  164. package/dist/esm/proxied-imports/router.js +1 -0
  165. package/dist/esm/radio-control/index.js +3 -6
  166. package/dist/esm/radio-control/style.scss +9 -9
  167. package/dist/esm/section-header/index.js +44 -25
  168. package/dist/esm/section-header/style.scss +2 -2
  169. package/dist/esm/select-control/ButtonGroupControl.js +5 -7
  170. package/dist/esm/select-control/GroupedSelectControl.js +5 -6
  171. package/dist/esm/select-control/index.js +6 -6
  172. package/dist/esm/select-control/style.scss +2 -2
  173. package/dist/esm/settings/MinMaxSetting.js +1 -3
  174. package/dist/esm/settings/SettingsCard.js +3 -4
  175. package/dist/esm/settings/SettingsSection.js +0 -2
  176. package/dist/esm/settings/style.scss +1 -1
  177. package/dist/esm/steps-list/index.js +43 -0
  178. package/dist/esm/steps-list/style.scss +11 -0
  179. package/dist/esm/steps-list-item/index.js +48 -0
  180. package/dist/esm/steps-list-item/style.scss +47 -0
  181. package/dist/esm/style-card/index.js +2 -5
  182. package/dist/esm/style-card/style.scss +9 -12
  183. package/dist/esm/style.scss +5 -6
  184. package/dist/esm/tabbed-navigation/index.js +20 -10
  185. package/dist/esm/tabbed-navigation/style.scss +3 -4
  186. package/dist/esm/text-control/index.js +2 -9
  187. package/dist/esm/utils/index.js +9 -3
  188. package/dist/esm/waiting/index.js +2 -5
  189. package/dist/esm/web-preview/index.js +9 -24
  190. package/dist/esm/web-preview/style.scss +14 -14
  191. package/dist/esm/with-wizard/index.js +49 -34
  192. package/dist/esm/with-wizard/style.scss +35 -37
  193. package/dist/esm/with-wizard-screen/index.js +9 -11
  194. package/dist/esm/with-wizard-screen/style.scss +14 -17
  195. package/dist/esm/wizard/components/WizardError.js +1 -10
  196. package/dist/esm/wizard/index.js +10 -12
  197. package/dist/esm/wizard/store/index.js +40 -46
  198. package/dist/esm/wizard/store/utils.js +1 -1
  199. package/package.json +4 -4
  200. package/shared/js/button-props.js +3 -1
  201. package/shared/scss/_mixins.scss +12 -0
  202. package/src/accordion/index.js +32 -0
  203. package/src/accordion/style.scss +27 -0
  204. package/src/action-card/index.js +43 -8
  205. package/src/action-card/style.scss +100 -23
  206. package/src/autocomplete-tokenfield/index.js +1 -1
  207. package/src/autocomplete-tokenfield/style.scss +2 -2
  208. package/src/autocomplete-with-suggestions/style.scss +16 -15
  209. package/src/button-card/style.scss +13 -13
  210. package/src/card/style.scss +25 -8
  211. package/src/category-autocomplete/index.js +3 -1
  212. package/src/category-autocomplete/style.scss +0 -2
  213. package/src/color-picker/style.scss +0 -3
  214. package/src/consts.js +2 -1
  215. package/src/custom-select-control/style.scss +6 -7
  216. package/src/date-range-picker/style.scss +12 -12
  217. package/src/footer/index.js +2 -2
  218. package/src/footer/style.scss +5 -5
  219. package/src/form-token-field/index.js +2 -7
  220. package/src/form-token-field/style.scss +2 -3
  221. package/src/grid/style.scss +5 -5
  222. package/src/handoff/index.js +3 -8
  223. package/src/handoff-message/index.js +39 -0
  224. package/src/hooks/useObjectState.js +2 -1
  225. package/src/image-upload/index.js +9 -3
  226. package/src/image-upload/style.scss +5 -9
  227. package/src/index.js +4 -0
  228. package/src/info-button/style.scss +1 -3
  229. package/src/modal/style.scss +8 -8
  230. package/src/newspack-icon/style.scss +4 -4
  231. package/src/newspack-logo/style.scss +3 -3
  232. package/src/notice/index.js +2 -0
  233. package/src/notice/style.scss +28 -15
  234. package/src/plugin-installer/index.js +15 -2
  235. package/src/plugin-installer/style.scss +5 -5
  236. package/src/plugin-settings/SettingsSection.js +7 -13
  237. package/src/plugin-settings/index.js +7 -2
  238. package/src/plugin-toggle/index.js +2 -3
  239. package/src/plugin-toggle/style.scss +2 -2
  240. package/src/popover/style.scss +19 -16
  241. package/src/position-control/index.js +122 -0
  242. package/src/position-control/style.scss +66 -0
  243. package/src/progress-bar/style.scss +4 -4
  244. package/src/radio-control/style.scss +9 -9
  245. package/src/section-header/index.js +32 -15
  246. package/src/section-header/style.scss +2 -2
  247. package/src/select-control/ButtonGroupControl.js +3 -0
  248. package/src/select-control/GroupedSelectControl.js +2 -1
  249. package/src/select-control/index.js +6 -2
  250. package/src/select-control/style.scss +2 -2
  251. package/src/settings/style.scss +1 -1
  252. package/src/steps-list/index.js +39 -0
  253. package/src/steps-list/style.scss +11 -0
  254. package/src/steps-list-item/index.js +40 -0
  255. package/src/steps-list-item/style.scss +47 -0
  256. package/src/style-card/index.js +2 -11
  257. package/src/style-card/style.scss +9 -12
  258. package/src/style.scss +5 -6
  259. package/src/tabbed-navigation/index.js +12 -4
  260. package/src/tabbed-navigation/style.scss +3 -4
  261. package/src/utils/index.js +9 -0
  262. package/src/web-preview/index.js +1 -1
  263. package/src/web-preview/style.scss +14 -14
  264. package/src/with-wizard/style.scss +35 -37
  265. package/src/with-wizard-screen/index.js +4 -1
  266. package/src/with-wizard-screen/style.scss +14 -17
  267. package/src/wizard/index.js +15 -3
  268. package/src/wizard/store/index.js +8 -2
@@ -2,12 +2,12 @@
2
2
  * Newspack Logo
3
3
  */
4
4
 
5
- @import '../../../shared/scss/colors';
5
+ @use '../../../shared/scss/colors';
6
6
 
7
7
  .newspack-logo {
8
8
  &__svg {
9
9
  display: block;
10
- fill: currentColor;
10
+ fill: currentcolor;
11
11
  margin: 0;
12
12
  padding-bottom: 32px;
13
13
  width: auto;
@@ -19,7 +19,7 @@
19
19
  }
20
20
 
21
21
  &__wrapper {
22
- background: $primary-500;
22
+ background: colors.$primary-500;
23
23
  color: white;
24
24
  position: relative;
25
25
 
@@ -8,20 +8,19 @@
8
8
  import { Component, RawHTML } from '@wordpress/element';
9
9
  import { Icon, bug, check, help, info } from '@wordpress/icons';
10
10
  import { __ as alias__ } from '@wordpress/i18n';
11
+
11
12
  /**
12
13
  * Internal dependencies.
13
14
  */
14
-
15
15
  const __ = alias__;
16
16
  import './style.scss';
17
+
17
18
  /**
18
19
  * External dependencies.
19
20
  */
20
-
21
21
  import classnames from 'classnames';
22
22
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
23
23
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
24
-
25
24
  class Notice extends Component {
26
25
  /**
27
26
  * Render
@@ -31,6 +30,7 @@ class Notice extends Component {
31
30
  className,
32
31
  debugMode,
33
32
  isError,
33
+ isHandoff,
34
34
  isHelp,
35
35
  isSuccess,
36
36
  isWarning,
@@ -39,9 +39,8 @@ class Notice extends Component {
39
39
  style = {},
40
40
  children = null
41
41
  } = this.props;
42
- const classes = classnames('newspack-notice', className, debugMode && 'newspack-notice__is-debug', isError && 'newspack-notice__is-error', isHelp && 'newspack-notice__is-help', isSuccess && 'newspack-notice__is-success', isWarning && 'newspack-notice__is-warning');
42
+ const classes = classnames('newspack-notice', className, debugMode && 'newspack-notice__is-debug', isError && 'newspack-notice__is-error', isHandoff && 'newspack-notice__is-handoff', isHelp && 'newspack-notice__is-help', isSuccess && 'newspack-notice__is-success', isWarning && 'newspack-notice__is-warning');
43
43
  let noticeIcon;
44
-
45
44
  if (isHelp) {
46
45
  noticeIcon = help;
47
46
  } else if (isSuccess) {
@@ -51,7 +50,6 @@ class Notice extends Component {
51
50
  } else {
52
51
  noticeIcon = info;
53
52
  }
54
-
55
53
  return _jsxs("div", {
56
54
  className: classes,
57
55
  style: style,
@@ -65,7 +63,5 @@ class Notice extends Component {
65
63
  })]
66
64
  });
67
65
  }
68
-
69
66
  }
70
-
71
67
  export default Notice;
@@ -2,13 +2,14 @@
2
2
  * Notice
3
3
  */
4
4
 
5
- @import '~@wordpress/base-styles/colors';
6
- @import '../../../shared/scss/colors';
5
+ @use 'sass:color';
6
+ @use '~@wordpress/base-styles/colors' as wp-colors;
7
+ @use '../../../shared/scss/colors';
7
8
 
8
9
  .newspack-notice {
9
10
  align-items: center;
10
- background: $gray-100;
11
- color: $gray-900;
11
+ background: wp-colors.$gray-100;
12
+ color: wp-colors.$gray-900;
12
13
  display: flex;
13
14
  justify-content: flex-start;
14
15
  margin: 32px 0;
@@ -16,13 +17,13 @@
16
17
 
17
18
  > svg {
18
19
  display: block;
19
- fill: $gray-900;
20
+ fill: wp-colors.$gray-900;
20
21
  flex: 0 0 24px;
21
22
  margin-right: 4px;
22
23
  }
23
24
 
24
25
  &__is-debug {
25
- background: $primary-700;
26
+ background: colors.$primary-700;
26
27
  border-radius: 2px;
27
28
  bottom: 16px;
28
29
  box-shadow: 0 0 8px 4px rgba( black, 0.08 );
@@ -39,35 +40,47 @@
39
40
  }
40
41
 
41
42
  &__is-error {
42
- background: lighten( $alert-red, 51% );
43
+ background: color.adjust( wp-colors.$alert-red, $lightness: 51% );
43
44
 
44
45
  > svg {
45
- fill: $alert-red;
46
+ fill: wp-colors.$alert-red;
46
47
  transform: rotate( 180deg );
47
48
  }
48
49
  }
49
50
 
51
+ &__is-handoff {
52
+ background: color.adjust( wp-colors.$alert-yellow, $lightness: 30% );
53
+ margin-top: 0;
54
+ position: sticky;
55
+ top: 46px;
56
+ z-index: 100;
57
+
58
+ @media ( min-width: 782px ) {
59
+ top: 32px;
60
+ }
61
+ }
62
+
50
63
  &__is-help {
51
- background: $primary-050;
64
+ background: colors.$primary-050;
52
65
 
53
66
  > svg {
54
- fill: $primary-500;
67
+ fill: colors.$primary-500;
55
68
  }
56
69
  }
57
70
 
58
71
  &__is-success {
59
- background: lighten( $alert-green, 42% );
72
+ background: color.adjust( wp-colors.$alert-green, $lightness: 42% );
60
73
 
61
74
  > svg {
62
- fill: $alert-green;
75
+ fill: wp-colors.$alert-green;
63
76
  }
64
77
  }
65
78
 
66
79
  &__is-warning {
67
- background: lighten( $alert-yellow, 30% );
80
+ background: color.adjust( wp-colors.$alert-yellow, $lightness: 30% );
68
81
 
69
82
  > svg {
70
- fill: $alert-yellow;
83
+ fill: wp-colors.$alert-yellow;
71
84
  transform: rotate( 180deg );
72
85
  }
73
86
  }
@@ -87,7 +100,7 @@
87
100
  }
88
101
 
89
102
  &:focus {
90
- box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) currentColor;
103
+ box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) currentcolor;
91
104
  }
92
105
  }
93
106
  }
@@ -1,5 +1,4 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  /**
4
3
  * WordPress.com and Google News Initiative Logos.
5
4
  */
@@ -13,11 +12,12 @@ import { __ as alias__ } from '@wordpress/i18n';
13
12
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
14
13
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
15
14
  const __ = alias__;
16
-
17
15
  class PatronsLogo extends Component {
18
16
  constructor() {
19
17
  super(...arguments);
20
-
18
+ /**
19
+ * Render.
20
+ */
21
21
  _defineProperty(this, "render", () => {
22
22
  return _jsxs(SVG, {
23
23
  xmlns: "http://www.w3.org/2000/svg",
@@ -72,7 +72,5 @@ class PatronsLogo extends Component {
72
72
  });
73
73
  });
74
74
  }
75
-
76
75
  }
77
-
78
76
  export default PatronsLogo;
@@ -1,5 +1,4 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  /**
4
3
  * Plugin Installer
5
4
  */
@@ -12,36 +11,33 @@ import { Component } from '@wordpress/element';
12
11
  import { __ as alias__ } from '@wordpress/i18n';
13
12
  const __ = alias__;
14
13
  import { Icon, check } from '@wordpress/icons';
14
+
15
15
  /**
16
16
  * Internal dependencies.
17
17
  */
18
-
19
18
  import { ActionCard, Button, Waiting } from '../';
20
19
  import './style.scss';
21
20
  const PLUGIN_STATE_NONE = 0;
22
21
  const PLUGIN_STATE_ACTIVE = 1;
23
22
  const PLUGIN_STATE_INSTALLING = 2;
24
23
  const PLUGIN_STATE_ERROR = 3;
24
+
25
25
  /**
26
26
  * External dependencies.
27
27
  */
28
-
29
28
  import classnames from 'classnames';
29
+
30
30
  /**
31
31
  * Plugin installer.
32
32
  */
33
-
34
33
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
35
34
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
36
35
  import { Fragment as _Fragment } from "@emotion/react/jsx-runtime";
37
-
38
36
  class PluginInstaller extends Component {
39
37
  constructor() {
40
38
  var _this;
41
-
42
39
  super(...arguments);
43
40
  _this = this;
44
-
45
41
  _defineProperty(this, "componentDidMount", () => {
46
42
  const {
47
43
  plugins
@@ -52,7 +48,6 @@ class PluginInstaller extends Component {
52
48
  }
53
49
  });
54
50
  });
55
-
56
51
  _defineProperty(this, "componentDidUpdate", prevProps => {
57
52
  const {
58
53
  autoInstall,
@@ -61,16 +56,13 @@ class PluginInstaller extends Component {
61
56
  const {
62
57
  installationInitialized
63
58
  } = this.state;
64
-
65
59
  if (plugins !== prevProps.plugins) {
66
60
  this.retrievePluginInfo(plugins);
67
61
  }
68
-
69
62
  if (autoInstall && !installationInitialized) {
70
63
  this.installAllPlugins();
71
64
  }
72
65
  });
73
-
74
66
  _defineProperty(this, "retrievePluginInfo", plugins => {
75
67
  return new Promise(resolve => {
76
68
  apiFetch({
@@ -80,8 +72,8 @@ class PluginInstaller extends Component {
80
72
  if (plugins.indexOf(slug) === -1) {
81
73
  return result;
82
74
  }
83
-
84
- result[slug] = { ...response[slug],
75
+ result[slug] = {
76
+ ...response[slug],
85
77
  installationStatus: response[slug].Status === 'active' ? PLUGIN_STATE_ACTIVE : PLUGIN_STATE_NONE
86
78
  };
87
79
  return result;
@@ -90,7 +82,6 @@ class PluginInstaller extends Component {
90
82
  });
91
83
  });
92
84
  });
93
-
94
85
  _defineProperty(this, "installAllPlugins", () => {
95
86
  const {
96
87
  pluginInfo
@@ -101,7 +92,6 @@ class PluginInstaller extends Component {
101
92
  const promises = Object.keys(pluginInfo).filter(slug => 'active' !== pluginInfo[slug].Status).map(slug => () => this.installPlugin(slug));
102
93
  promises.reduce((promise, action) => promise.then(result => action().then(Array.prototype.concat.bind(result))), Promise.resolve([]));
103
94
  });
104
-
105
95
  _defineProperty(this, "installPlugin", slug => {
106
96
  this.setInstallationStatus(slug, PLUGIN_STATE_INSTALLING);
107
97
  const params = {
@@ -113,8 +103,10 @@ class PluginInstaller extends Component {
113
103
  pluginInfo
114
104
  } = this.state;
115
105
  this.props.onInstalled(slug);
116
- this.updatePluginInfo({ ...pluginInfo,
117
- [slug]: { ...response,
106
+ this.updatePluginInfo({
107
+ ...pluginInfo,
108
+ [slug]: {
109
+ ...response,
118
110
  installationStatus: PLUGIN_STATE_ACTIVE
119
111
  }
120
112
  });
@@ -122,32 +114,32 @@ class PluginInstaller extends Component {
122
114
  this.setInstallationStatus(slug, PLUGIN_STATE_ERROR, error.message);
123
115
  });
124
116
  });
125
-
126
117
  _defineProperty(this, "setChecked", (slug, checked) => {
127
118
  const {
128
119
  pluginInfo
129
120
  } = this.state;
130
- this.updatePluginInfo({ ...pluginInfo,
131
- [slug]: { ...pluginInfo[slug],
121
+ this.updatePluginInfo({
122
+ ...pluginInfo,
123
+ [slug]: {
124
+ ...pluginInfo[slug],
132
125
  checked
133
126
  }
134
127
  });
135
128
  });
136
-
137
129
  _defineProperty(this, "setInstallationStatus", function (slug, installationStatus) {
138
130
  let notification = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
139
131
  const {
140
132
  pluginInfo
141
133
  } = _this.state;
142
-
143
- _this.updatePluginInfo({ ...pluginInfo,
144
- [slug]: { ...pluginInfo[slug],
134
+ _this.updatePluginInfo({
135
+ ...pluginInfo,
136
+ [slug]: {
137
+ ...pluginInfo[slug],
145
138
  installationStatus,
146
139
  notification
147
140
  }
148
141
  });
149
142
  });
150
-
151
143
  _defineProperty(this, "updatePluginInfo", pluginInfo => {
152
144
  return new Promise(resolve => {
153
145
  const {
@@ -167,29 +159,23 @@ class PluginInstaller extends Component {
167
159
  });
168
160
  });
169
161
  });
170
-
171
162
  _defineProperty(this, "classForInstallationStatus", status => {
172
163
  switch (status) {
173
164
  case PLUGIN_STATE_ACTIVE:
174
165
  return 'newspack-plugin-installer__status-active';
175
-
176
166
  case PLUGIN_STATE_INSTALLING:
177
167
  return 'newspack-plugin-installer__status-installing';
178
-
179
168
  case PLUGIN_STATE_ERROR:
180
169
  return 'newspack-plugin-installer__status-error';
181
-
182
170
  default:
183
171
  return 'newspack-plugin-installer__status-none';
184
172
  }
185
173
  });
186
-
187
174
  this.state = {
188
175
  pluginInfo: {},
189
176
  installationInitialized: false
190
177
  };
191
178
  }
192
-
193
179
  /**
194
180
  * Render.
195
181
  */
@@ -202,16 +188,20 @@ class PluginInstaller extends Component {
202
188
  const {
203
189
  pluginInfo
204
190
  } = this.state;
205
- const slugs = Object.keys(pluginInfo); // Store all plugin status info for installer button text value based on current status.
191
+ const {
192
+ is_atomic: isAtomic
193
+ } = window;
194
+ const slugs = Object.keys(pluginInfo);
206
195
 
196
+ // Store all plugin status info for installer button text value based on current status.
207
197
  const currentPluginStatuses = [];
208
198
  slugs.forEach(slug => {
209
199
  const plugin = pluginInfo[slug];
210
200
  currentPluginStatuses.push(plugin.Status);
211
- }); // Make sure plugin status falls in either one of these, to handle button text.
201
+ });
212
202
 
203
+ // Make sure plugin status falls in either one of these, to handle button text.
213
204
  const pluginInstalled = currentStatus => currentStatus === 'active' || currentStatus === 'inactive';
214
-
215
205
  const buttonText = currentPluginStatuses.every(pluginInstalled) ? __('Activate', 'newspack') : __('Install', 'newspack');
216
206
  const needsInstall = slugs.some(slug => {
217
207
  const plugin = pluginInfo[slug];
@@ -228,16 +218,24 @@ class PluginInstaller extends Component {
228
218
  const {
229
219
  Name,
230
220
  Description,
221
+ Download,
231
222
  Status,
232
223
  installationStatus,
233
224
  notification
234
225
  } = plugin;
235
226
  const isWaiting = installationStatus === PLUGIN_STATE_INSTALLING;
236
227
  const isButton = !isWaiting && Status !== 'active';
228
+ const installable = Download || pluginInstalled(Status);
237
229
  let actionText;
238
-
239
230
  if (installationStatus === PLUGIN_STATE_INSTALLING) {
240
- actionText = __('Installing…');
231
+ actionText = 'inactive' === Status ? __('Activating…') : __('Installing…');
232
+ } else if (!installable) {
233
+ actionText = _jsxs("span", {
234
+ className: "newspack-plugin-installer__status",
235
+ children: [isAtomic ? __('Contact Newspack support to install', 'newspack') : __('Plugin must be installed manually', 'newspack'), _jsx("span", {
236
+ className: "newspack-checkbox-icon"
237
+ })]
238
+ });
241
239
  } else if (Status === 'uninstalled') {
242
240
  actionText = _jsxs("span", {
243
241
  className: "newspack-plugin-installer__status",
@@ -263,12 +261,12 @@ class PluginInstaller extends Component {
263
261
  })]
264
262
  });
265
263
  }
266
-
267
264
  const classes = classnames('newspack-action-card__plugin-installer', this.classForInstallationStatus(installationStatus));
268
265
  const onClick = isButton ? () => this.installPlugin(slug) : null;
269
266
  return _jsx(ActionCard, {
270
267
  title: Name,
271
268
  description: Description,
269
+ disabled: !installable,
272
270
  actionText: actionText,
273
271
  isSmall: isSmall,
274
272
  isWaiting: isWaiting,
@@ -289,9 +287,7 @@ class PluginInstaller extends Component {
289
287
  })]
290
288
  });
291
289
  }
292
-
293
290
  }
294
-
295
291
  PluginInstaller.defaultProps = {
296
292
  onStatus: () => {},
297
293
  onInstalled: () => {}
@@ -2,7 +2,7 @@
2
2
  * Plugin Installer
3
3
  */
4
4
 
5
- @import '~@wordpress/base-styles/colors';
5
+ @use '~@wordpress/base-styles/colors' as wp-colors;
6
6
 
7
7
  .newspack-card {
8
8
  .newspack-plugin-installer__status {
@@ -35,10 +35,10 @@
35
35
  }
36
36
 
37
37
  &.newspack-plugin-installer__status-active {
38
- box-shadow: inset 4px 0 0 $alert-green;
38
+ box-shadow: inset 4px 0 0 wp-colors.$alert-green;
39
39
 
40
40
  .newspack-plugin-installer__checkbox {
41
- background: $alert-green;
41
+ background: wp-colors.$alert-green;
42
42
  box-shadow: none;
43
43
  }
44
44
 
@@ -48,12 +48,12 @@
48
48
  }
49
49
 
50
50
  &.newspack-plugin-installer__status-error {
51
- box-shadow: inset 4px 0 0 $alert-red;
51
+ box-shadow: inset 4px 0 0 wp-colors.$alert-red;
52
52
  }
53
53
 
54
54
  &.newspack-plugin-installer__status-installing,
55
55
  &.newspack-plugin-installer__status-none {
56
- box-shadow: inset 4px 0 0 $gray-100;
56
+ box-shadow: inset 4px 0 0 wp-colors.$gray-100;
57
57
  }
58
58
 
59
59
  // Is Small
@@ -5,39 +5,34 @@
5
5
  /**
6
6
  * WordPress dependencies
7
7
  */
8
- import { Fragment } from '@wordpress/element';
8
+ import { Fragment, useState } from '@wordpress/element';
9
9
  import { applyFilters } from '@wordpress/hooks';
10
10
  import { __ as alias__ } from '@wordpress/i18n';
11
11
  const __ = alias__;
12
12
  import { CheckboxControl } from '@wordpress/components';
13
+
13
14
  /**
14
15
  * Internal dependencies
15
16
  */
16
-
17
17
  import { ActionCard, Button, Grid, Notice, SelectControl, TextControl } from '../';
18
18
  import './style.scss';
19
19
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
20
20
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
21
-
22
21
  const isSelectControl = setting => {
23
22
  return Array.isArray(setting.options) && setting.options.length;
24
23
  };
25
-
26
24
  const getControlComponent = setting => {
27
25
  if (isSelectControl(setting)) {
28
26
  return SelectControl;
29
27
  }
30
-
31
28
  switch (setting.type) {
32
29
  case 'checkbox':
33
30
  case 'boolean':
34
31
  return CheckboxControl;
35
-
36
32
  default:
37
33
  return TextControl;
38
34
  }
39
35
  };
40
-
41
36
  const getControlType = setting => {
42
37
  switch (setting.type) {
43
38
  case 'int':
@@ -45,24 +40,20 @@ const getControlType = setting => {
45
40
  case 'float':
46
41
  case 'number':
47
42
  return 'number';
48
-
49
43
  case 'string':
50
44
  case 'text':
51
45
  return 'text';
52
-
53
46
  case 'password':
54
47
  return 'password';
55
-
56
48
  case 'boolean':
57
49
  case 'checkbox':
58
50
  return 'checkbox';
59
-
60
51
  default:
61
52
  return null;
62
53
  }
63
54
  };
64
-
65
55
  const SettingsSection = props => {
56
+ const [saveDisabled, setSaveDisabled] = useState(true);
66
57
  const {
67
58
  error,
68
59
  sectionKey,
@@ -74,7 +65,6 @@ const SettingsSection = props => {
74
65
  onChange,
75
66
  onUpdate
76
67
  } = props;
77
-
78
68
  const getControlProps = setting => ({
79
69
  disabled,
80
70
  name: `${setting.section}_${setting.key}`,
@@ -90,22 +80,19 @@ const SettingsSection = props => {
90
80
  checked: setting.type === 'boolean' ? !!setting.value : null,
91
81
  onChange: value => {
92
82
  onChange(setting.key, value);
83
+ setSaveDisabled(false);
93
84
  }
94
85
  });
95
-
96
86
  const createFilter = function (name) {
97
87
  let defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
98
88
  return applyFilters(`newspack.settingSection.${sectionKey}.${name}`, defaultComponent, props);
99
89
  };
100
-
101
90
  let columns = 2;
102
-
103
91
  if (fields.length % 3 === 0) {
104
92
  columns = 3;
105
93
  } else if (fields.length === 1) {
106
94
  columns = 1;
107
95
  }
108
-
109
96
  return _jsx(ActionCard, {
110
97
  isMedium: true,
111
98
  disabled: disabled,
@@ -118,9 +105,10 @@ const SettingsSection = props => {
118
105
  }) : null,
119
106
  actionContent: (active || null === active) && createFilter('buttons', _jsx(Button, {
120
107
  variant: "primary",
121
- disabled: disabled,
108
+ disabled: disabled || saveDisabled,
122
109
  onClick: () => {
123
110
  onUpdate();
111
+ setSaveDisabled(true);
124
112
  },
125
113
  children: __('Save Settings', 'newspack')
126
114
  })),
@@ -133,8 +121,8 @@ const SettingsSection = props => {
133
121
  gutter: 32,
134
122
  children: fields.map(setting => {
135
123
  const Control = getControlComponent(setting); // eslint-disable-line @wordpress/no-unused-vars-before-return, no-unused-vars
136
-
137
- return applyFilters(`newspack.settingsSection.${sectionKey}.control`, _jsx(Control, { ...getControlProps(setting)
124
+ return applyFilters(`newspack.settingsSection.${sectionKey}.control`, _jsx(Control, {
125
+ ...getControlProps(setting)
138
126
  }, setting.key), {
139
127
  sectionKey,
140
128
  setting,
@@ -145,5 +133,4 @@ const SettingsSection = props => {
145
133
  })
146
134
  });
147
135
  };
148
-
149
136
  export default SettingsSection;