newspack-components 2.0.3 → 2.2.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 (315) hide show
  1. package/copy-styles.js +1 -1
  2. package/dist/cjs/accordion/index.js +46 -0
  3. package/dist/cjs/accordion/style.scss +27 -0
  4. package/dist/cjs/action-card/index.js +72 -40
  5. package/dist/cjs/action-card/style.scss +143 -41
  6. package/dist/cjs/autocomplete-tokenfield/index.js +13 -41
  7. package/dist/cjs/autocomplete-tokenfield/style.scss +6 -6
  8. package/dist/cjs/autocomplete-with-suggestions/index.js +33 -53
  9. package/dist/cjs/autocomplete-with-suggestions/style.scss +27 -27
  10. package/dist/cjs/button/index.js +1 -20
  11. package/dist/cjs/button/style.scss +3 -344
  12. package/dist/cjs/button-card/index.js +11 -15
  13. package/dist/cjs/button-card/style.scss +65 -35
  14. package/dist/cjs/card/index.js +4 -9
  15. package/dist/cjs/card/style.scss +47 -63
  16. package/dist/cjs/category-autocomplete/index.js +66 -47
  17. package/dist/cjs/category-autocomplete/style.scss +20 -24
  18. package/dist/cjs/color-picker/index.js +16 -48
  19. package/dist/cjs/color-picker/style.scss +20 -163
  20. package/dist/cjs/consts.js +5 -3
  21. package/dist/cjs/custom-select-control/index.js +1 -9
  22. package/dist/cjs/custom-select-control/style.scss +14 -45
  23. package/dist/cjs/date-range-picker/index.js +1 -10
  24. package/dist/cjs/date-range-picker/style.scss +12 -12
  25. package/dist/cjs/footer/index.js +24 -22
  26. package/dist/cjs/footer/style.scss +13 -14
  27. package/dist/cjs/form-token-field/index.js +3 -11
  28. package/dist/cjs/form-token-field/style.scss +9 -105
  29. package/dist/cjs/global-notices/index.js +3 -9
  30. package/dist/cjs/grid/index.js +1 -8
  31. package/dist/cjs/grid/style.scss +19 -6
  32. package/dist/cjs/handoff/index.js +15 -24
  33. package/dist/cjs/handoff-message/index.js +50 -0
  34. package/dist/cjs/hooks/index.js +1 -7
  35. package/dist/cjs/hooks/useObjectState.js +7 -13
  36. package/dist/cjs/hooks/useObjectState.test.js +0 -14
  37. package/dist/cjs/hooks/useOnClickOutside.js +3 -6
  38. package/dist/cjs/hooks/usePrompt.js +1 -13
  39. package/dist/cjs/image-upload/index.js +22 -20
  40. package/dist/cjs/image-upload/index.test.js +0 -5
  41. package/dist/cjs/image-upload/style.scss +12 -17
  42. package/dist/cjs/index.js +31 -93
  43. package/dist/cjs/info-button/index.js +3 -11
  44. package/dist/cjs/info-button/style.scss +1 -3
  45. package/dist/cjs/modal/index.js +1 -12
  46. package/dist/cjs/modal/style.scss +20 -132
  47. package/dist/cjs/newspack-icon/index.js +5 -11
  48. package/dist/cjs/newspack-icon/style.scss +17 -2
  49. package/dist/cjs/newspack-logo/index.js +1 -9
  50. package/dist/cjs/newspack-logo/style.scss +3 -3
  51. package/dist/cjs/notice/index.js +8 -16
  52. package/dist/cjs/notice/style.scss +60 -19
  53. package/dist/cjs/patrons-logo/index.js +3 -11
  54. package/dist/cjs/plugin-installer/index.js +37 -37
  55. package/dist/cjs/plugin-installer/style.scss +5 -5
  56. package/dist/cjs/plugin-settings/SettingsSection.js +71 -59
  57. package/dist/cjs/plugin-settings/index.js +71 -50
  58. package/dist/cjs/plugin-settings/style.scss +7 -0
  59. package/dist/cjs/plugin-toggle/index.js +60 -32
  60. package/dist/cjs/plugin-toggle/style.scss +2 -2
  61. package/dist/cjs/popover/index.js +1 -11
  62. package/dist/cjs/popover/style.scss +20 -17
  63. package/dist/cjs/position-control/index.js +113 -0
  64. package/dist/cjs/position-control/style.scss +66 -0
  65. package/dist/cjs/progress-bar/index.js +2 -9
  66. package/dist/cjs/progress-bar/index.test.js +2 -7
  67. package/dist/cjs/progress-bar/style.scss +4 -4
  68. package/dist/cjs/proxied-imports/router.js +0 -3
  69. package/dist/cjs/radio-control/index.js +1 -11
  70. package/dist/cjs/radio-control/style.scss +10 -11
  71. package/dist/cjs/section-header/index.js +47 -19
  72. package/dist/cjs/section-header/style.scss +22 -1
  73. package/dist/cjs/select-control/ButtonGroupControl.js +11 -20
  74. package/dist/cjs/select-control/GroupedSelectControl.js +42 -45
  75. package/dist/cjs/select-control/index.js +6 -14
  76. package/dist/cjs/select-control/style.scss +47 -88
  77. package/dist/cjs/settings/MinMaxSetting.js +6 -8
  78. package/dist/cjs/settings/SettingsCard.js +9 -8
  79. package/dist/cjs/settings/SettingsSection.js +5 -8
  80. package/dist/cjs/settings/index.js +0 -6
  81. package/dist/cjs/settings/style.scss +32 -4
  82. package/dist/cjs/steps-list/index.js +52 -0
  83. package/dist/cjs/steps-list/style.scss +11 -0
  84. package/dist/cjs/steps-list-item/index.js +56 -0
  85. package/dist/cjs/steps-list-item/style.scss +47 -0
  86. package/dist/cjs/style-card/index.js +15 -18
  87. package/dist/cjs/style-card/style.scss +19 -18
  88. package/dist/cjs/style.scss +43 -0
  89. package/dist/cjs/tabbed-navigation/index.js +27 -31
  90. package/dist/cjs/tabbed-navigation/style.scss +58 -37
  91. package/dist/cjs/text-control/index.js +6 -19
  92. package/dist/cjs/text-control/style.scss +0 -126
  93. package/dist/cjs/utils/index.js +10 -5
  94. package/dist/cjs/waiting/index.js +9 -33
  95. package/dist/cjs/waiting/style.scss +9 -20
  96. package/dist/cjs/web-preview/index.js +30 -57
  97. package/dist/cjs/web-preview/style.scss +41 -34
  98. package/dist/cjs/with-wizard/index.js +55 -33
  99. package/dist/cjs/with-wizard/style.scss +77 -124
  100. package/dist/cjs/with-wizard-screen/index.js +28 -38
  101. package/dist/cjs/with-wizard-screen/style.scss +75 -125
  102. package/dist/cjs/wizard/components/WizardError.js +74 -0
  103. package/dist/cjs/wizard/index.js +131 -0
  104. package/dist/cjs/wizard/store/index.js +165 -0
  105. package/dist/cjs/wizard/store/utils.js +26 -0
  106. package/dist/cjs/wizard/style.scss +148 -0
  107. package/dist/esm/accordion/index.js +38 -0
  108. package/dist/esm/accordion/style.scss +27 -0
  109. package/dist/esm/action-card/index.js +75 -37
  110. package/dist/esm/action-card/style.scss +143 -41
  111. package/dist/esm/autocomplete-tokenfield/index.js +14 -37
  112. package/dist/esm/autocomplete-tokenfield/style.scss +6 -6
  113. package/dist/esm/autocomplete-with-suggestions/index.js +31 -43
  114. package/dist/esm/autocomplete-with-suggestions/style.scss +27 -27
  115. package/dist/esm/button/index.js +2 -14
  116. package/dist/esm/button/style.scss +3 -344
  117. package/dist/esm/button-card/index.js +12 -11
  118. package/dist/esm/button-card/style.scss +65 -35
  119. package/dist/esm/card/index.js +5 -6
  120. package/dist/esm/card/style.scss +47 -63
  121. package/dist/esm/category-autocomplete/index.js +68 -41
  122. package/dist/esm/category-autocomplete/style.scss +20 -24
  123. package/dist/esm/color-picker/index.js +17 -38
  124. package/dist/esm/color-picker/style.scss +20 -163
  125. package/dist/esm/consts.js +3 -2
  126. package/dist/esm/custom-select-control/index.js +2 -5
  127. package/dist/esm/custom-select-control/style.scss +14 -45
  128. package/dist/esm/date-range-picker/index.js +1 -3
  129. package/dist/esm/date-range-picker/style.scss +12 -12
  130. package/dist/esm/footer/index.js +22 -16
  131. package/dist/esm/footer/style.scss +13 -14
  132. package/dist/esm/form-token-field/index.js +4 -7
  133. package/dist/esm/form-token-field/style.scss +9 -105
  134. package/dist/esm/global-notices/index.js +3 -7
  135. package/dist/esm/grid/index.js +2 -5
  136. package/dist/esm/grid/style.scss +19 -6
  137. package/dist/esm/handoff/index.js +10 -21
  138. package/dist/esm/handoff-message/index.js +45 -0
  139. package/dist/esm/hooks/index.js +0 -2
  140. package/dist/esm/hooks/useObjectState.js +3 -8
  141. package/dist/esm/hooks/useObjectState.test.js +0 -3
  142. package/dist/esm/hooks/useOnClickOutside.js +2 -5
  143. package/dist/esm/hooks/usePrompt.js +1 -8
  144. package/dist/esm/image-upload/index.js +18 -17
  145. package/dist/esm/image-upload/style.scss +12 -17
  146. package/dist/esm/index.js +7 -8
  147. package/dist/esm/info-button/index.js +4 -6
  148. package/dist/esm/info-button/style.scss +1 -3
  149. package/dist/esm/modal/index.js +2 -8
  150. package/dist/esm/modal/style.scss +20 -132
  151. package/dist/esm/newspack-icon/index.js +6 -7
  152. package/dist/esm/newspack-icon/style.scss +17 -2
  153. package/dist/esm/newspack-logo/index.js +2 -5
  154. package/dist/esm/newspack-logo/style.scss +3 -3
  155. package/dist/esm/notice/index.js +11 -10
  156. package/dist/esm/notice/style.scss +60 -19
  157. package/dist/esm/patrons-logo/index.js +3 -5
  158. package/dist/esm/plugin-installer/index.js +37 -40
  159. package/dist/esm/plugin-installer/style.scss +5 -5
  160. package/dist/esm/plugin-settings/SettingsSection.js +71 -56
  161. package/dist/esm/plugin-settings/index.js +70 -52
  162. package/dist/esm/plugin-settings/style.scss +7 -0
  163. package/dist/esm/plugin-toggle/index.js +59 -34
  164. package/dist/esm/plugin-toggle/style.scss +2 -2
  165. package/dist/esm/popover/index.js +3 -6
  166. package/dist/esm/popover/style.scss +20 -17
  167. package/dist/esm/position-control/index.js +109 -0
  168. package/dist/esm/position-control/style.scss +66 -0
  169. package/dist/esm/progress-bar/index.js +2 -7
  170. package/dist/esm/progress-bar/index.test.js +2 -1
  171. package/dist/esm/progress-bar/style.scss +4 -4
  172. package/dist/esm/proxied-imports/router.js +1 -0
  173. package/dist/esm/radio-control/index.js +3 -6
  174. package/dist/esm/radio-control/style.scss +10 -11
  175. package/dist/esm/section-header/index.js +47 -16
  176. package/dist/esm/section-header/style.scss +22 -1
  177. package/dist/esm/select-control/ButtonGroupControl.js +12 -14
  178. package/dist/esm/select-control/GroupedSelectControl.js +38 -36
  179. package/dist/esm/select-control/index.js +7 -8
  180. package/dist/esm/select-control/style.scss +47 -88
  181. package/dist/esm/settings/MinMaxSetting.js +4 -5
  182. package/dist/esm/settings/SettingsCard.js +9 -5
  183. package/dist/esm/settings/SettingsSection.js +5 -7
  184. package/dist/esm/settings/style.scss +32 -4
  185. package/dist/esm/steps-list/index.js +43 -0
  186. package/dist/esm/steps-list/style.scss +11 -0
  187. package/dist/esm/steps-list-item/index.js +48 -0
  188. package/dist/esm/steps-list-item/style.scss +47 -0
  189. package/dist/esm/style-card/index.js +13 -13
  190. package/dist/esm/style-card/style.scss +19 -18
  191. package/dist/esm/style.scss +43 -0
  192. package/dist/esm/tabbed-navigation/index.js +30 -28
  193. package/dist/esm/tabbed-navigation/style.scss +58 -37
  194. package/dist/esm/text-control/index.js +2 -12
  195. package/dist/esm/text-control/style.scss +0 -126
  196. package/dist/esm/utils/index.js +9 -3
  197. package/dist/esm/waiting/index.js +11 -27
  198. package/dist/esm/waiting/style.scss +9 -20
  199. package/dist/esm/web-preview/index.js +21 -49
  200. package/dist/esm/web-preview/style.scss +41 -34
  201. package/dist/esm/with-wizard/index.js +53 -36
  202. package/dist/esm/with-wizard/style.scss +77 -124
  203. package/dist/esm/with-wizard-screen/index.js +26 -32
  204. package/dist/esm/with-wizard-screen/style.scss +75 -125
  205. package/dist/esm/wizard/components/WizardError.js +69 -0
  206. package/dist/esm/wizard/index.js +126 -0
  207. package/dist/esm/wizard/store/index.js +155 -0
  208. package/dist/esm/wizard/store/utils.js +17 -0
  209. package/dist/esm/wizard/style.scss +148 -0
  210. package/package.json +4 -4
  211. package/src/accordion/index.js +32 -0
  212. package/src/accordion/style.scss +27 -0
  213. package/src/action-card/index.js +70 -25
  214. package/src/action-card/style.scss +143 -41
  215. package/src/autocomplete-tokenfield/index.js +1 -1
  216. package/src/autocomplete-tokenfield/style.scss +6 -6
  217. package/src/autocomplete-with-suggestions/index.js +4 -2
  218. package/src/autocomplete-with-suggestions/style.scss +27 -27
  219. package/src/button/index.js +2 -9
  220. package/src/button/style.scss +3 -344
  221. package/src/button-card/index.js +19 -5
  222. package/src/button-card/style.scss +65 -35
  223. package/src/card/index.js +4 -0
  224. package/src/card/style.scss +47 -63
  225. package/src/category-autocomplete/index.js +53 -18
  226. package/src/category-autocomplete/style.scss +20 -24
  227. package/src/color-picker/index.js +16 -22
  228. package/src/color-picker/style.scss +20 -163
  229. package/src/consts.js +2 -1
  230. package/src/custom-select-control/style.scss +14 -45
  231. package/src/date-range-picker/style.scss +12 -12
  232. package/src/footer/index.js +20 -9
  233. package/src/footer/style.scss +13 -14
  234. package/src/form-token-field/index.js +3 -8
  235. package/src/form-token-field/style.scss +9 -105
  236. package/src/global-notices/index.js +1 -1
  237. package/src/grid/style.scss +19 -6
  238. package/src/handoff/index.js +10 -15
  239. package/src/handoff-message/index.js +39 -0
  240. package/src/hooks/useObjectState.js +2 -1
  241. package/src/image-upload/index.js +9 -3
  242. package/src/image-upload/style.scss +12 -17
  243. package/src/index.js +7 -7
  244. package/src/info-button/style.scss +1 -3
  245. package/src/modal/index.js +2 -5
  246. package/src/modal/style.scss +20 -132
  247. package/src/newspack-icon/index.js +7 -2
  248. package/src/newspack-icon/style.scss +17 -2
  249. package/src/newspack-logo/style.scss +3 -3
  250. package/src/notice/index.js +9 -1
  251. package/src/notice/style.scss +60 -19
  252. package/src/plugin-installer/index.js +17 -4
  253. package/src/plugin-installer/style.scss +5 -5
  254. package/src/plugin-settings/SettingsSection.js +59 -27
  255. package/src/plugin-settings/index.js +29 -8
  256. package/src/plugin-settings/style.scss +7 -0
  257. package/src/plugin-toggle/index.js +37 -12
  258. package/src/plugin-toggle/style.scss +2 -2
  259. package/src/popover/style.scss +20 -17
  260. package/src/position-control/index.js +122 -0
  261. package/src/position-control/style.scss +66 -0
  262. package/src/progress-bar/style.scss +4 -4
  263. package/src/radio-control/style.scss +10 -11
  264. package/src/section-header/index.js +41 -5
  265. package/src/section-header/style.scss +22 -1
  266. package/src/select-control/ButtonGroupControl.js +15 -5
  267. package/src/select-control/GroupedSelectControl.js +28 -25
  268. package/src/select-control/index.js +6 -3
  269. package/src/select-control/style.scss +47 -88
  270. package/src/settings/MinMaxSetting.js +2 -1
  271. package/src/settings/SettingsCard.js +9 -7
  272. package/src/settings/SettingsSection.js +4 -4
  273. package/src/settings/style.scss +32 -4
  274. package/src/steps-list/index.js +39 -0
  275. package/src/steps-list/style.scss +11 -0
  276. package/src/steps-list-item/index.js +40 -0
  277. package/src/steps-list-item/style.scss +47 -0
  278. package/src/style-card/index.js +16 -27
  279. package/src/style-card/style.scss +19 -18
  280. package/src/style.scss +43 -0
  281. package/src/tabbed-navigation/index.js +20 -24
  282. package/src/tabbed-navigation/style.scss +58 -37
  283. package/src/text-control/index.js +1 -2
  284. package/src/text-control/style.scss +0 -126
  285. package/src/utils/index.js +9 -0
  286. package/src/waiting/index.js +7 -18
  287. package/src/waiting/style.scss +9 -20
  288. package/src/web-preview/index.js +13 -34
  289. package/src/web-preview/style.scss +41 -34
  290. package/src/with-wizard/index.js +7 -5
  291. package/src/with-wizard/style.scss +77 -124
  292. package/src/with-wizard-screen/index.js +17 -17
  293. package/src/with-wizard-screen/style.scss +75 -125
  294. package/src/wizard/components/WizardError.js +57 -0
  295. package/src/wizard/index.js +145 -0
  296. package/src/wizard/store/index.js +132 -0
  297. package/src/wizard/store/utils.js +16 -0
  298. package/dist/cjs/wizard-pagination/index.js +0 -71
  299. package/dist/cjs/wizard-pagination/style.scss +0 -74
  300. package/dist/esm/wizard-pagination/index.js +0 -57
  301. package/dist/esm/wizard-pagination/style.scss +0 -74
  302. package/src/button-group/index.js +0 -35
  303. package/src/button-group/style.scss +0 -73
  304. package/src/checkbox-control/index.js +0 -38
  305. package/src/checkbox-control/style.scss +0 -78
  306. package/src/preview-box/index.js +0 -18
  307. package/src/preview-box/style.scss +0 -18
  308. package/src/textarea-control/index.js +0 -32
  309. package/src/textarea-control/style.scss +0 -76
  310. package/src/toggle-control/index.js +0 -38
  311. package/src/toggle-control/style.scss +0 -74
  312. package/src/toggle-group/index.js +0 -43
  313. package/src/toggle-group/style.scss +0 -28
  314. package/src/wizard-pagination/index.js +0 -59
  315. package/src/wizard-pagination/style.scss +0 -74
@@ -2,65 +2,106 @@
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
- align-items: flex-start;
10
- background: $gray-100;
11
- border-radius: 3px;
12
- color: $gray-900;
10
+ align-items: center;
11
+ background: wp-colors.$gray-100;
12
+ color: wp-colors.$gray-900;
13
13
  display: flex;
14
- font-size: 14px;
15
14
  justify-content: flex-start;
16
- line-height: 24px;
17
15
  margin: 32px 0;
18
16
  padding: 6px 8px;
19
17
 
20
18
  > svg {
21
19
  display: block;
22
- fill: $gray-900;
20
+ fill: wp-colors.$gray-900;
23
21
  flex: 0 0 24px;
24
22
  margin-right: 4px;
25
23
  }
26
24
 
25
+ &__is-debug {
26
+ background: colors.$primary-700;
27
+ border-radius: 2px;
28
+ bottom: 16px;
29
+ box-shadow: 0 0 8px 4px rgba( black, 0.08 );
30
+ color: white;
31
+ font-weight: bold;
32
+ margin: 0 16px;
33
+ position: fixed;
34
+ text-transform: uppercase;
35
+ z-index: 9997;
36
+
37
+ > svg {
38
+ fill: white;
39
+ }
40
+ }
41
+
27
42
  &__is-error {
28
- background: lighten( $alert-red, 54% );
43
+ background: color.adjust( wp-colors.$alert-red, $lightness: 51% );
29
44
 
30
45
  > svg {
31
- fill: $alert-red;
46
+ fill: wp-colors.$alert-red;
32
47
  transform: rotate( 180deg );
33
48
  }
34
49
  }
35
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
+
36
63
  &__is-help {
37
- background: $primary-000;
64
+ background: colors.$primary-050;
38
65
 
39
66
  > svg {
40
- fill: $primary-500;
67
+ fill: colors.$primary-500;
41
68
  }
42
69
  }
43
70
 
44
71
  &__is-success {
45
- background: lighten( $alert-green, 47% );
72
+ background: color.adjust( wp-colors.$alert-green, $lightness: 42% );
46
73
 
47
74
  > svg {
48
- fill: $alert-green;
75
+ fill: wp-colors.$alert-green;
49
76
  }
50
77
  }
51
78
 
52
79
  &__is-warning {
53
- background: lighten( $alert-yellow, 36% );
80
+ background: color.adjust( wp-colors.$alert-yellow, $lightness: 30% );
54
81
 
55
82
  > svg {
56
- fill: $alert-yellow;
83
+ fill: wp-colors.$alert-yellow;
57
84
  transform: rotate( 180deg );
58
85
  }
59
86
  }
60
87
 
61
- &__content {
88
+ & &__content {
62
89
  > div > * {
63
- margin: 0;
90
+ margin: 0 !important;
91
+ }
92
+
93
+ a {
94
+ color: inherit;
95
+
96
+ &:active,
97
+ &:focus,
98
+ &:hover {
99
+ color: inherit;
100
+ }
101
+
102
+ &:focus {
103
+ box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) currentcolor;
104
+ }
64
105
  }
65
106
  }
66
107
 
@@ -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,35 +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
36
  class PluginInstaller extends Component {
38
37
  constructor() {
39
38
  var _this;
40
-
41
39
  super(...arguments);
42
40
  _this = this;
43
-
44
41
  _defineProperty(this, "componentDidMount", () => {
45
42
  const {
46
43
  plugins
@@ -51,7 +48,6 @@ class PluginInstaller extends Component {
51
48
  }
52
49
  });
53
50
  });
54
-
55
51
  _defineProperty(this, "componentDidUpdate", prevProps => {
56
52
  const {
57
53
  autoInstall,
@@ -60,16 +56,13 @@ class PluginInstaller extends Component {
60
56
  const {
61
57
  installationInitialized
62
58
  } = this.state;
63
-
64
59
  if (plugins !== prevProps.plugins) {
65
60
  this.retrievePluginInfo(plugins);
66
61
  }
67
-
68
62
  if (autoInstall && !installationInitialized) {
69
63
  this.installAllPlugins();
70
64
  }
71
65
  });
72
-
73
66
  _defineProperty(this, "retrievePluginInfo", plugins => {
74
67
  return new Promise(resolve => {
75
68
  apiFetch({
@@ -79,8 +72,8 @@ class PluginInstaller extends Component {
79
72
  if (plugins.indexOf(slug) === -1) {
80
73
  return result;
81
74
  }
82
-
83
- result[slug] = { ...response[slug],
75
+ result[slug] = {
76
+ ...response[slug],
84
77
  installationStatus: response[slug].Status === 'active' ? PLUGIN_STATE_ACTIVE : PLUGIN_STATE_NONE
85
78
  };
86
79
  return result;
@@ -89,7 +82,6 @@ class PluginInstaller extends Component {
89
82
  });
90
83
  });
91
84
  });
92
-
93
85
  _defineProperty(this, "installAllPlugins", () => {
94
86
  const {
95
87
  pluginInfo
@@ -100,7 +92,6 @@ class PluginInstaller extends Component {
100
92
  const promises = Object.keys(pluginInfo).filter(slug => 'active' !== pluginInfo[slug].Status).map(slug => () => this.installPlugin(slug));
101
93
  promises.reduce((promise, action) => promise.then(result => action().then(Array.prototype.concat.bind(result))), Promise.resolve([]));
102
94
  });
103
-
104
95
  _defineProperty(this, "installPlugin", slug => {
105
96
  this.setInstallationStatus(slug, PLUGIN_STATE_INSTALLING);
106
97
  const params = {
@@ -112,8 +103,10 @@ class PluginInstaller extends Component {
112
103
  pluginInfo
113
104
  } = this.state;
114
105
  this.props.onInstalled(slug);
115
- this.updatePluginInfo({ ...pluginInfo,
116
- [slug]: { ...response,
106
+ this.updatePluginInfo({
107
+ ...pluginInfo,
108
+ [slug]: {
109
+ ...response,
117
110
  installationStatus: PLUGIN_STATE_ACTIVE
118
111
  }
119
112
  });
@@ -121,32 +114,32 @@ class PluginInstaller extends Component {
121
114
  this.setInstallationStatus(slug, PLUGIN_STATE_ERROR, error.message);
122
115
  });
123
116
  });
124
-
125
117
  _defineProperty(this, "setChecked", (slug, checked) => {
126
118
  const {
127
119
  pluginInfo
128
120
  } = this.state;
129
- this.updatePluginInfo({ ...pluginInfo,
130
- [slug]: { ...pluginInfo[slug],
121
+ this.updatePluginInfo({
122
+ ...pluginInfo,
123
+ [slug]: {
124
+ ...pluginInfo[slug],
131
125
  checked
132
126
  }
133
127
  });
134
128
  });
135
-
136
129
  _defineProperty(this, "setInstallationStatus", function (slug, installationStatus) {
137
130
  let notification = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
138
131
  const {
139
132
  pluginInfo
140
133
  } = _this.state;
141
-
142
- _this.updatePluginInfo({ ...pluginInfo,
143
- [slug]: { ...pluginInfo[slug],
134
+ _this.updatePluginInfo({
135
+ ...pluginInfo,
136
+ [slug]: {
137
+ ...pluginInfo[slug],
144
138
  installationStatus,
145
139
  notification
146
140
  }
147
141
  });
148
142
  });
149
-
150
143
  _defineProperty(this, "updatePluginInfo", pluginInfo => {
151
144
  return new Promise(resolve => {
152
145
  const {
@@ -166,29 +159,23 @@ class PluginInstaller extends Component {
166
159
  });
167
160
  });
168
161
  });
169
-
170
162
  _defineProperty(this, "classForInstallationStatus", status => {
171
163
  switch (status) {
172
164
  case PLUGIN_STATE_ACTIVE:
173
165
  return 'newspack-plugin-installer__status-active';
174
-
175
166
  case PLUGIN_STATE_INSTALLING:
176
167
  return 'newspack-plugin-installer__status-installing';
177
-
178
168
  case PLUGIN_STATE_ERROR:
179
169
  return 'newspack-plugin-installer__status-error';
180
-
181
170
  default:
182
171
  return 'newspack-plugin-installer__status-none';
183
172
  }
184
173
  });
185
-
186
174
  this.state = {
187
175
  pluginInfo: {},
188
176
  installationInitialized: false
189
177
  };
190
178
  }
191
-
192
179
  /**
193
180
  * Render.
194
181
  */
@@ -201,22 +188,26 @@ class PluginInstaller extends Component {
201
188
  const {
202
189
  pluginInfo
203
190
  } = this.state;
204
- 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);
205
195
 
196
+ // Store all plugin status info for installer button text value based on current status.
206
197
  const currentPluginStatuses = [];
207
198
  slugs.forEach(slug => {
208
199
  const plugin = pluginInfo[slug];
209
200
  currentPluginStatuses.push(plugin.Status);
210
- }); // Make sure plugin status falls in either one of these, to handle button text.
201
+ });
211
202
 
203
+ // Make sure plugin status falls in either one of these, to handle button text.
212
204
  const pluginInstalled = currentStatus => currentStatus === 'active' || currentStatus === 'inactive';
213
-
214
205
  const buttonText = currentPluginStatuses.every(pluginInstalled) ? __('Activate', 'newspack') : __('Install', 'newspack');
215
206
  const needsInstall = slugs.some(slug => {
216
207
  const plugin = pluginInfo[slug];
217
208
  return plugin.Status !== 'active' && plugin.installationStatus === PLUGIN_STATE_NONE;
218
209
  });
219
- return _jsxs("div", {
210
+ return _jsxs(_Fragment, {
220
211
  children: [(!pluginInfo || !Object.keys(pluginInfo).length) && _jsxs("div", {
221
212
  className: "newspack-plugin-installer_is-waiting",
222
213
  children: [_jsx(Waiting, {
@@ -227,16 +218,24 @@ class PluginInstaller extends Component {
227
218
  const {
228
219
  Name,
229
220
  Description,
221
+ Download,
230
222
  Status,
231
223
  installationStatus,
232
224
  notification
233
225
  } = plugin;
234
226
  const isWaiting = installationStatus === PLUGIN_STATE_INSTALLING;
235
227
  const isButton = !isWaiting && Status !== 'active';
228
+ const installable = Download || pluginInstalled(Status);
236
229
  let actionText;
237
-
238
230
  if (installationStatus === PLUGIN_STATE_INSTALLING) {
239
- 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
+ });
240
239
  } else if (Status === 'uninstalled') {
241
240
  actionText = _jsxs("span", {
242
241
  className: "newspack-plugin-installer__status",
@@ -262,12 +261,12 @@ class PluginInstaller extends Component {
262
261
  })]
263
262
  });
264
263
  }
265
-
266
264
  const classes = classnames('newspack-action-card__plugin-installer', this.classForInstallationStatus(installationStatus));
267
265
  const onClick = isButton ? () => this.installPlugin(slug) : null;
268
266
  return _jsx(ActionCard, {
269
267
  title: Name,
270
268
  description: Description,
269
+ disabled: !installable,
271
270
  actionText: actionText,
272
271
  isSmall: isSmall,
273
272
  isWaiting: isWaiting,
@@ -288,9 +287,7 @@ class PluginInstaller extends Component {
288
287
  })]
289
288
  });
290
289
  }
291
-
292
290
  }
293
-
294
291
  PluginInstaller.defaultProps = {
295
292
  onStatus: () => {},
296
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,32 +5,34 @@
5
5
  /**
6
6
  * WordPress dependencies
7
7
  */
8
- import { Fragment } from '@wordpress/element';
8
+ import { Fragment, useState } from '@wordpress/element';
9
+ import { applyFilters } from '@wordpress/hooks';
9
10
  import { __ as alias__ } from '@wordpress/i18n';
11
+ const __ = alias__;
12
+ import { CheckboxControl } from '@wordpress/components';
13
+
10
14
  /**
11
15
  * Internal dependencies
12
16
  */
13
-
14
- const __ = alias__;
15
- import { ActionCard, Grid, Button, TextControl, CheckboxControl, SelectControl } from '../';
17
+ import { ActionCard, Button, Grid, Notice, SelectControl, TextControl } from '../';
18
+ import './style.scss';
16
19
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
17
20
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
18
-
21
+ const isSelectControl = setting => {
22
+ return Array.isArray(setting.options) && setting.options.length;
23
+ };
19
24
  const getControlComponent = setting => {
20
- if (Array.isArray(setting.options) && setting.options.length) {
25
+ if (isSelectControl(setting)) {
21
26
  return SelectControl;
22
27
  }
23
-
24
28
  switch (setting.type) {
25
29
  case 'checkbox':
26
30
  case 'boolean':
27
31
  return CheckboxControl;
28
-
29
32
  default:
30
33
  return TextControl;
31
34
  }
32
35
  };
33
-
34
36
  const getControlType = setting => {
35
37
  switch (setting.type) {
36
38
  case 'int':
@@ -38,18 +40,23 @@ const getControlType = setting => {
38
40
  case 'float':
39
41
  case 'number':
40
42
  return 'number';
41
-
42
43
  case 'string':
43
44
  case 'text':
44
45
  return 'text';
45
-
46
+ case 'password':
47
+ return 'password';
48
+ case 'boolean':
49
+ case 'checkbox':
50
+ return 'checkbox';
46
51
  default:
47
52
  return null;
48
53
  }
49
54
  };
50
-
51
- const SettingsSection = _ref => {
52
- let {
55
+ const SettingsSection = props => {
56
+ const [saveDisabled, setSaveDisabled] = useState(true);
57
+ const {
58
+ error,
59
+ sectionKey,
53
60
  active,
54
61
  title,
55
62
  description,
@@ -57,65 +64,73 @@ const SettingsSection = _ref => {
57
64
  disabled,
58
65
  onChange,
59
66
  onUpdate
60
- } = _ref;
61
-
62
- const getControlProps = setting => {
63
- var _setting$options;
64
-
65
- return {
66
- disabled,
67
- name: `${setting.section}_${setting.key}`,
68
- type: getControlType(setting),
69
- label: setting.description,
70
- help: setting.help || null,
71
- options: ((_setting$options = setting.options) === null || _setting$options === void 0 ? void 0 : _setting$options.map(option => ({
72
- value: option.value,
73
- label: option.name
74
- }))) || null,
75
- value: setting.value,
76
- checked: setting.type === 'boolean' ? !!setting.value : null,
77
- onChange: value => {
78
- onChange(setting.key, value);
79
- }
80
- };
67
+ } = props;
68
+ const getControlProps = setting => ({
69
+ disabled,
70
+ name: `${setting.section}_${setting.key}`,
71
+ type: getControlType(setting),
72
+ label: setting.description,
73
+ help: setting.help || null,
74
+ options: setting.options?.map(option => ({
75
+ value: option.value,
76
+ label: option.name || option.label
77
+ })) || null,
78
+ value: setting.value,
79
+ multiple: isSelectControl(setting) && setting.multiple ? true : null,
80
+ checked: setting.type === 'boolean' ? !!setting.value : null,
81
+ onChange: value => {
82
+ onChange(setting.key, value);
83
+ setSaveDisabled(false);
84
+ }
85
+ });
86
+ const createFilter = function (name) {
87
+ let defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
88
+ return applyFilters(`newspack.settingSection.${sectionKey}.${name}`, defaultComponent, props);
81
89
  };
82
-
90
+ let columns = 2;
91
+ if (fields.length % 3 === 0) {
92
+ columns = 3;
93
+ } else if (fields.length === 1) {
94
+ columns = 1;
95
+ }
83
96
  return _jsx(ActionCard, {
84
97
  isMedium: true,
85
98
  disabled: disabled,
86
99
  title: title,
87
100
  description: description,
88
101
  toggleChecked: active,
89
- hasGreyHeader: true,
102
+ hasGreyHeader: active || null === active,
90
103
  toggleOnChange: active !== null ? value => onUpdate({
91
104
  active: value
92
105
  }) : null,
106
+ actionContent: (active || null === active) && createFilter('buttons', _jsx(Button, {
107
+ variant: "primary",
108
+ disabled: disabled || saveDisabled,
109
+ onClick: () => {
110
+ onUpdate();
111
+ setSaveDisabled(true);
112
+ },
113
+ children: __('Save Settings', 'newspack')
114
+ })),
93
115
  children: (active || active === null) && _jsxs(Fragment, {
94
- children: [_jsx(Grid, {
95
- columns: fields.length % 3 === 0 ? 3 : 2,
116
+ children: [error?.message && _jsx(Notice, {
117
+ noticeText: error.message,
118
+ isError: true
119
+ }), createFilter('beforeControls'), _jsx(Grid, {
120
+ columns: columns,
96
121
  gutter: 32,
97
122
  children: fields.map(setting => {
98
123
  const Control = getControlComponent(setting); // eslint-disable-line @wordpress/no-unused-vars-before-return, no-unused-vars
99
-
100
- return _jsx(Control, { ...getControlProps(setting)
101
- }, setting.key);
102
- })
103
- }), _jsx("div", {
104
- className: "newspack-buttons-card",
105
- style: {
106
- margin: '32px 0 0'
107
- },
108
- children: _jsx(Button, {
109
- isPrimary: true,
110
- disabled: disabled,
111
- onClick: () => {
112
- onUpdate();
113
- },
114
- children: __('Save settings', 'newspack')
124
+ return applyFilters(`newspack.settingsSection.${sectionKey}.control`, _jsx(Control, {
125
+ ...getControlProps(setting)
126
+ }, setting.key), {
127
+ sectionKey,
128
+ setting,
129
+ onChange
130
+ });
115
131
  })
116
132
  })]
117
133
  })
118
134
  });
119
135
  };
120
-
121
136
  export default SettingsSection;