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,118 +2,22 @@
2
2
  * Form Token Field
3
3
  */
4
4
 
5
- @import '../../../shared/scss/colors';
6
- @import '~@wordpress/base-styles/colors';
5
+ @use '~@wordpress/base-styles/colors' as wp-colors;
7
6
 
8
7
  .newspack-form-token-field {
9
- color: $gray-700;
10
- font-size: 14px;
11
- line-height: 24px;
12
- margin: 32px 0;
13
8
  width: 100%;
14
9
 
15
- label {
16
- color: $gray-900;
17
- font-size: inherit;
18
- font-weight: bold;
19
- line-height: inherit;
20
- margin: 0;
10
+ .components-form-token-field__input-container {
11
+ padding-bottom: 1px;
12
+ padding-top: 1px;
21
13
  }
22
14
 
23
- .newspack-form-token-field__input-container {
24
- background: white;
25
- border: 1px solid $gray-300;
26
- border-radius: 3px;
27
- box-shadow: none;
28
- box-sizing: border-box;
29
- color: inherit;
30
- font-size: 16px;
31
- line-height: inherit;
32
- margin: 0;
33
- min-height: 48px;
34
- padding: 9px 8px;
35
- transition: border-color 125ms ease-in-out, box-shadow 125ms ease-in-out;
36
- width: 100%;
15
+ // Help
37
16
 
38
- @media screen and ( min-width: 768px ) {
39
- font-size: inherit;
40
- }
41
-
42
- &.is-active {
43
- border-color: $primary-500;
44
- box-shadow: inset 0 0 0 2px $primary-500;
45
- }
46
-
47
- &:disabled,
48
- &.is-disabled {
49
- background: $gray-100;
50
- color: $gray-600;
51
- cursor: not-allowed;
52
- }
53
-
54
- input[type='text'] {
55
- border: 0;
56
- line-height: inherit;
57
- margin: 2px 0;
58
- padding: 0;
59
-
60
- &:focus {
61
- box-shadow: none;
62
- }
63
- }
64
-
65
- .components-form-token-field__token-text {
66
- font-size: inherit;
67
- }
68
-
69
- .components-form-token-field__remove-token {
70
- height: 24px;
71
- }
72
- }
73
-
74
- .components-form-token-field__suggestions-list {
75
- border-top-color: $gray-300;
76
- margin: 12px -8px -11px;
77
- padding: 8px 0 0;
78
-
79
- .components-form-token-field__suggestion {
80
- font-size: inherit;
81
- margin-bottom: 8px;
82
-
83
- &.is-selected {
84
- background: $primary-500;
85
- }
86
- }
87
- }
88
-
89
- // Help Text
90
-
91
- .components-form-token-field__help {
92
- margin: 0;
93
- }
94
-
95
- // Multiple Form Token Field
96
-
97
- & + & {
98
- margin-bottom: 32px;
99
- margin-top: -16px;
100
- }
101
-
102
- // Multiple Controls
103
-
104
- + .newspack-select-control,
105
- + .newspack-textarea-control,
106
- + .newspack-text-control {
107
- margin-bottom: 32px;
108
- margin-top: -16px;
109
- }
110
-
111
- // Reset
112
-
113
- .components-base-control__field,
114
- .components-base-control__label {
115
- display: block;
116
- margin: 0;
17
+ &__help {
18
+ color: wp-colors.$gray-700;
19
+ font-size: 12px;
20
+ margin: 8px 0 0 !important;
117
21
  }
118
22
 
119
23
  // Hidden Elements
@@ -2,33 +2,29 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { parse } from 'qs';
5
+
5
6
  /**
6
7
  * Internal dependencies
7
8
  */
8
-
9
9
  import { Notice } from '../';
10
10
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
11
-
12
11
  const GlobalNotices = () => {
13
12
  const notice = parse(window.location.search)['newspack-notice'];
14
-
15
13
  if (!notice) {
16
14
  return null;
17
15
  }
18
-
19
16
  return notice.split(',').map((text, i) => {
20
17
  if (text.indexOf('_error_') === 0) {
21
18
  return _jsx(Notice, {
22
19
  isError: true,
23
- noticeText: text.replace('_error_', '')
20
+ noticeText: text.replace('_error_', ''),
21
+ rawHTML: true
24
22
  }, i);
25
23
  }
26
-
27
24
  return _jsx(Notice, {
28
25
  isSuccess: true,
29
26
  noticeText: text
30
27
  }, i);
31
28
  });
32
29
  };
33
-
34
30
  export default GlobalNotices;
@@ -6,18 +6,17 @@
6
6
  * WordPress dependencies
7
7
  */
8
8
  import { Component } from '@wordpress/element';
9
+
9
10
  /**
10
11
  * Internal dependencies
11
12
  */
12
-
13
13
  import './style.scss';
14
+
14
15
  /**
15
16
  * External dependencies
16
17
  */
17
-
18
18
  import classnames from 'classnames';
19
19
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
20
-
21
20
  class Grid extends Component {
22
21
  /**
23
22
  * Render
@@ -37,9 +36,7 @@ class Grid extends Component {
37
36
  ...otherProps
38
37
  });
39
38
  }
40
-
41
39
  }
42
-
43
40
  Grid.defaultProps = {
44
41
  columns: 2,
45
42
  gutter: 32,
@@ -2,7 +2,7 @@
2
2
  * Grid
3
3
  */
4
4
 
5
- @import '~@wordpress/base-styles/colors';
5
+ @use '~@wordpress/base-styles/colors' as wp-colors;
6
6
 
7
7
  .newspack-grid {
8
8
  display: grid;
@@ -118,6 +118,19 @@
118
118
  margin-top: 0 !important;
119
119
  }
120
120
 
121
+ .components-base-control {
122
+ &__field,
123
+ &__help {
124
+ margin-bottom: 0;
125
+ }
126
+ }
127
+
128
+ .components-form-token-field {
129
+ &__input-container {
130
+ margin-bottom: 0;
131
+ }
132
+ }
133
+
121
134
  // Cards
122
135
  > .newspack-card {
123
136
  > *:first-child {
@@ -131,10 +144,10 @@
131
144
 
132
145
  // Table-like
133
146
  &__thead {
134
- background: $gray-100;
135
- border-bottom: 1px solid $gray-300;
136
- border-top: 1px solid $gray-300;
137
- color: $gray-900;
147
+ background: rgba( black, 0.025 );
148
+ border-bottom: 1px solid wp-colors.$gray-300;
149
+ border-top: 1px solid wp-colors.$gray-300;
150
+ color: wp-colors.$gray-900;
138
151
 
139
152
  > *:not( .screen-reader-text ) {
140
153
  padding: 8px;
@@ -142,7 +155,7 @@
142
155
  }
143
156
 
144
157
  &__tbody {
145
- border-bottom: 1px solid $gray-300;
158
+ border-bottom: 1px solid wp-colors.$gray-300;
146
159
  padding: 8px 0;
147
160
  }
148
161
 
@@ -1,5 +1,4 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  /**
4
3
  * Handoff
5
4
  */
@@ -10,25 +9,23 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
9
  import apiFetch from '@wordpress/api-fetch';
11
10
  import { Component, Fragment } from '@wordpress/element';
12
11
  import { __ as alias__ } from '@wordpress/i18n';
12
+
13
13
  /**
14
14
  * Internal dependencies.
15
15
  */
16
-
17
16
  const __ = alias__;
18
17
  import { Button, Card, Modal, Waiting } from '../';
18
+
19
19
  /**
20
20
  * External dependencies.
21
21
  */
22
-
23
- import { assign } from 'lodash';
22
+ import assign from 'lodash/assign';
24
23
  import classnames from 'classnames';
25
24
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
26
25
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
27
-
28
26
  class Handoff extends Component {
29
27
  constructor() {
30
28
  super(...arguments);
31
-
32
29
  _defineProperty(this, "componentDidMount", () => {
33
30
  this._isMounted = true;
34
31
  const {
@@ -36,11 +33,9 @@ class Handoff extends Component {
36
33
  } = this.props;
37
34
  this.retrievePluginInfo(plugin);
38
35
  });
39
-
40
36
  _defineProperty(this, "componentWillUnmount", () => {
41
37
  this._isMounted = false;
42
38
  });
43
-
44
39
  _defineProperty(this, "retrievePluginInfo", plugin => {
45
40
  const {
46
41
  onReady
@@ -56,7 +51,6 @@ class Handoff extends Component {
56
51
  }
57
52
  });
58
53
  });
59
-
60
54
  _defineProperty(this, "textForPlugin", pluginInfo => {
61
55
  const defaults = {
62
56
  modalBody: null,
@@ -67,7 +61,6 @@ class Handoff extends Component {
67
61
  };
68
62
  return assign(defaults, this.props);
69
63
  });
70
-
71
64
  _defineProperty(this, "goToPlugin", plugin => {
72
65
  const {
73
66
  editLink,
@@ -85,13 +78,11 @@ class Handoff extends Component {
85
78
  window.location.href = response.HandoffLink;
86
79
  });
87
80
  });
88
-
89
81
  this.state = {
90
82
  pluginInfo: [],
91
83
  showModal: false
92
84
  };
93
85
  }
94
-
95
86
  /**
96
87
  * Render.
97
88
  */
@@ -101,13 +92,13 @@ class Handoff extends Component {
101
92
  children,
102
93
  compact,
103
94
  useModal,
104
- // eslint-disable-next-line no-unused-vars
95
+ // eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
105
96
  modalTitle: _modalTitle,
106
- // eslint-disable-next-line no-unused-vars
97
+ // eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
107
98
  modalBody: _modalBody,
108
- // eslint-disable-next-line no-unused-vars
99
+ // eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
109
100
  onReady,
110
- // eslint-disable-next-line no-unused-vars
101
+ // eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
111
102
  editLink,
112
103
  ...otherProps
113
104
  } = this.props;
@@ -140,7 +131,7 @@ class Handoff extends Component {
140
131
  children: children ? children : primaryButton
141
132
  }), Name && 'active' !== Status && _jsx(Button, {
142
133
  className: classes,
143
- isSecondary: true,
134
+ variant: "secondary",
144
135
  disabled: true,
145
136
  ...otherProps,
146
137
  children: Name + __(' not installed', 'newspack')
@@ -165,13 +156,13 @@ class Handoff extends Component {
165
156
  noBorder: true,
166
157
  className: "justify-end",
167
158
  children: [_jsx(Button, {
168
- isSecondary: true,
159
+ variant: "secondary",
169
160
  onClick: () => this.setState({
170
161
  showModal: false
171
162
  }),
172
163
  children: dismissModalButton
173
164
  }), _jsx(Button, {
174
- isPrimary: true,
165
+ variant: "primary",
175
166
  onClick: () => this.goToPlugin(Slug),
176
167
  children: primaryModalButton
177
168
  })]
@@ -179,9 +170,7 @@ class Handoff extends Component {
179
170
  })]
180
171
  });
181
172
  }
182
-
183
173
  }
184
-
185
174
  Handoff.defaultProps = {
186
175
  onReady: () => {}
187
176
  };
@@ -0,0 +1,45 @@
1
+ /**
2
+ * WordPress dependencies.
3
+ */
4
+ import { useEffect, useState } from '@wordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies.
8
+ */
9
+ import { HANDOFF_KEY } from '../consts';
10
+ import { Notice } from '../';
11
+
12
+ /**
13
+ * Handoff Message Component.
14
+ */
15
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
16
+ export default function HandoffMessage() {
17
+ const [handoffMessage, setHandoffMessage] = useState(false);
18
+ useEffect(() => {
19
+ // Slight delay to allow for localStorage to be updated by RAS component.
20
+ setTimeout(() => {
21
+ const handoff = JSON.parse(localStorage.getItem(HANDOFF_KEY));
22
+ if (handoff?.message) {
23
+ setHandoffMessage(handoff.message);
24
+ } else {
25
+ setHandoffMessage(false);
26
+ }
27
+
28
+ // Clean up the notification if navigating away from the relevant page.
29
+ if (handoff?.url && -1 === window.location.href.indexOf(handoff.url)) {
30
+ window.localStorage.removeItem(HANDOFF_KEY);
31
+ setHandoffMessage(false);
32
+ }
33
+ }, 100);
34
+
35
+ // Clean up the notification when unmounting.
36
+ return () => window.localStorage.removeItem(HANDOFF_KEY);
37
+ }, []);
38
+ if (!handoffMessage) return null;
39
+ return _jsx(Notice, {
40
+ isHandoff: true,
41
+ isDismissible: false,
42
+ rawHTML: true,
43
+ noticeText: handoffMessage
44
+ });
45
+ }
@@ -5,12 +5,10 @@ import { useRef } from '@wordpress/element';
5
5
  import usePrompt from './usePrompt';
6
6
  import useObjectState from './useObjectState';
7
7
  import useOnClickOutside from './useOnClickOutside';
8
-
9
8
  const useUniqueId = prefix => {
10
9
  const id = useRef(`${prefix}-${Math.round(Math.random() * 99999)}`);
11
10
  return id.current;
12
11
  };
13
-
14
12
  export default {
15
13
  usePrompt,
16
14
  useObjectState,
@@ -2,35 +2,30 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useState } from '@wordpress/element';
5
- import { mergeWith, isArray } from 'lodash';
6
-
5
+ import isArray from 'lodash/isArray';
6
+ import mergeWith from 'lodash/mergeWith';
7
7
  const mergeCustomizer = (objValue, srcValue) => {
8
8
  if (isArray(objValue)) {
9
9
  // If it's an array, replace it (instead of concatenating).
10
10
  return srcValue;
11
11
  }
12
12
  };
13
+
13
14
  /**
14
15
  * A useState for an object.
15
16
  * Nested objects will be nested, but arrays replaced.
16
17
  */
17
-
18
-
19
18
  export default (function () {
20
19
  let initial = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
21
20
  const [stateObject, setStateObject] = useState(initial);
22
-
23
21
  const runUpdate = update => setStateObject(_stateObject => mergeWith({}, _stateObject, update, mergeCustomizer));
24
-
25
22
  const updateStateObject = keyOrUpdate => {
26
23
  if (typeof keyOrUpdate === 'string') {
27
24
  return value => runUpdate({
28
25
  [keyOrUpdate]: value
29
26
  });
30
27
  }
31
-
32
28
  runUpdate(keyOrUpdate);
33
29
  };
34
-
35
30
  return [stateObject, updateStateObject];
36
31
  });
@@ -11,7 +11,6 @@ const INIT_STATE = {
11
11
  baz: 1
12
12
  }
13
13
  };
14
-
15
14
  const TestComponent = () => {
16
15
  const [state, updateState] = useObjectState(INIT_STATE);
17
16
  return _jsxs("div", {
@@ -46,10 +45,8 @@ const TestComponent = () => {
46
45
  })]
47
46
  });
48
47
  };
49
-
50
48
  describe('useObjectState', () => {
51
49
  const getState = () => JSON.parse(screen.getByPlaceholderText('state').getAttribute('value'));
52
-
53
50
  beforeEach(() => {
54
51
  render(_jsx(TestComponent, {}));
55
52
  });
@@ -4,7 +4,6 @@
4
4
  * External dependencies.
5
5
  */
6
6
  import { useEffect } from '@wordpress/element';
7
-
8
7
  const useOnClickOutside = (ref, handler) => {
9
8
  useEffect(() => {
10
9
  const listener = event => {
@@ -12,17 +11,16 @@ const useOnClickOutside = (ref, handler) => {
12
11
  if (!ref.current || ref.current.contains(event.target)) {
13
12
  return;
14
13
  }
15
-
16
14
  handler(event);
17
15
  };
18
-
19
16
  document.addEventListener('mousedown', listener);
20
17
  document.addEventListener('touchstart', listener);
21
18
  return () => {
22
19
  document.removeEventListener('mousedown', listener);
23
20
  document.removeEventListener('touchstart', listener);
24
21
  };
25
- }, // Add ref and handler to effect dependencies
22
+ },
23
+ // Add ref and handler to effect dependencies
26
24
  // It's worth noting that because passed in handler is a new ...
27
25
  // ... function on every render that will cause this effect ...
28
26
  // ... callback/cleanup to run every render. It's not a big deal ...
@@ -30,5 +28,4 @@ const useOnClickOutside = (ref, handler) => {
30
28
  // ... passing it into this hook.
31
29
  [ref, handler]);
32
30
  };
33
-
34
31
  export default useOnClickOutside;
@@ -4,10 +4,10 @@
4
4
  * External dependencies.
5
5
  */
6
6
  import { useEffect, useRef } from '@wordpress/element';
7
+
7
8
  /**
8
9
  * Internal dependencies.
9
10
  */
10
-
11
11
  import Router from '../proxied-imports/router';
12
12
  const {
13
13
  useHistory
@@ -15,34 +15,27 @@ const {
15
15
  export default ((when, message) => {
16
16
  const history = useHistory();
17
17
  const self = useRef(null);
18
-
19
18
  const onWindowOrTabClose = event => {
20
19
  if (!when) {
21
20
  return;
22
21
  }
23
-
24
22
  if (typeof event === 'undefined') {
25
23
  event = window.event;
26
24
  }
27
-
28
25
  if (event) {
29
26
  event.returnValue = message;
30
27
  }
31
-
32
28
  return message;
33
29
  };
34
-
35
30
  useEffect(() => {
36
31
  if (when) {
37
32
  self.current = history.block(message);
38
33
  window.addEventListener('beforeunload', onWindowOrTabClose);
39
34
  }
40
-
41
35
  return () => {
42
36
  if (self.current) {
43
37
  self.current();
44
38
  }
45
-
46
39
  window.removeEventListener('beforeunload', onWindowOrTabClose);
47
40
  };
48
41
  }, [message, when]);
@@ -1,5 +1,4 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  /**
4
3
  * Image Upload
5
4
  */
@@ -9,35 +8,35 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
8
  */
10
9
  import { Component } from '@wordpress/element';
11
10
  import { __ as alias__ } from '@wordpress/i18n';
11
+
12
12
  /**
13
13
  * Internal dependencies.
14
14
  */
15
-
16
15
  const __ = alias__;
17
16
  import { Button, InfoButton } from '../';
18
17
  import './style.scss';
18
+
19
19
  /**
20
20
  * External dependencies.
21
21
  */
22
-
23
22
  import classnames from 'classnames';
24
23
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
25
24
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
26
25
  import { Fragment as _Fragment } from "@emotion/react/jsx-runtime";
27
-
28
26
  class ImageUpload extends Component {
29
27
  /**
30
28
  * Constructor.
31
29
  */
32
30
  constructor() {
33
31
  super(...arguments);
34
-
32
+ /**
33
+ * Open the WP media modal.
34
+ */
35
35
  _defineProperty(this, "openModal", () => {
36
36
  if (this.state.frame) {
37
37
  this.state.frame.open();
38
38
  return;
39
39
  }
40
-
41
40
  this.setState({
42
41
  frame: wp.media({
43
42
  title: __('Select or upload image'),
@@ -54,7 +53,9 @@ class ImageUpload extends Component {
54
53
  this.state.frame.open();
55
54
  });
56
55
  });
57
-
56
+ /**
57
+ * Update the state when an image is selected from the media modal.
58
+ */
58
59
  _defineProperty(this, "handleImageSelect", () => {
59
60
  const {
60
61
  onChange
@@ -62,11 +63,14 @@ class ImageUpload extends Component {
62
63
  const attachment = this.state.frame.state().get('selection').first().toJSON();
63
64
  onChange(attachment);
64
65
  });
65
-
66
+ /**
67
+ * Render.
68
+ */
66
69
  _defineProperty(this, "render", () => {
67
70
  const {
68
71
  buttonLabel,
69
72
  className,
73
+ disabled,
70
74
  help,
71
75
  image,
72
76
  info,
@@ -92,9 +96,10 @@ class ImageUpload extends Component {
92
96
  })]
93
97
  }), _jsx("div", {
94
98
  className: classes,
95
- style: { ...style
99
+ style: {
100
+ ...style
96
101
  },
97
- children: image !== null && image !== void 0 && image.url ? _jsxs(_Fragment, {
102
+ children: image?.url ? _jsxs(_Fragment, {
98
103
  children: [_jsx("img", {
99
104
  "data-testid": "image-upload",
100
105
  src: image.url,
@@ -102,12 +107,14 @@ class ImageUpload extends Component {
102
107
  }), _jsxs("div", {
103
108
  className: "newspack-image-upload__controls",
104
109
  children: [_jsx(Button, {
110
+ disabled: disabled,
105
111
  onClick: this.openModal,
106
112
  isLink: true,
107
113
  children: __('Replace', 'newspack')
108
114
  }), _jsx("span", {
109
115
  className: "sep"
110
116
  }), _jsx(Button, {
117
+ disabled: disabled,
111
118
  onClick: () => onChange(null),
112
119
  isLink: true,
113
120
  isDestructive: true,
@@ -115,6 +122,7 @@ class ImageUpload extends Component {
115
122
  })]
116
123
  })]
117
124
  }) : _jsx(Button, {
125
+ disabled: disabled,
118
126
  onClick: this.openModal,
119
127
  isLink: true,
120
128
  children: buttonLabel ? buttonLabel : __('Upload', 'newspack')
@@ -125,16 +133,9 @@ class ImageUpload extends Component {
125
133
  })]
126
134
  });
127
135
  });
128
-
129
136
  this.state = {
130
137
  frame: false
131
138
  };
132
139
  }
133
- /**
134
- * Open the WP media modal.
135
- */
136
-
137
-
138
140
  }
139
-
140
141
  export default ImageUpload;