newspack-components 3.1.0 → 4.0.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 (191) hide show
  1. package/colors/colors.module.scss +277 -0
  2. package/copy-styles.js +8 -1
  3. package/dist/cjs/action-card/action-card.d.js +5 -0
  4. package/dist/cjs/action-card/index.js +282 -187
  5. package/dist/cjs/action-card/style.scss +142 -44
  6. package/dist/cjs/autocomplete-tokenfield/index.js +6 -2
  7. package/dist/cjs/box-contrast/index.js +49 -0
  8. package/dist/cjs/button/index.js +1 -1
  9. package/dist/cjs/button-props/button-props.js +41 -0
  10. package/dist/cjs/button-props/index.js +13 -0
  11. package/dist/cjs/color-picker/index.js +11 -0
  12. package/dist/cjs/custom-select-control/style.scss +7 -12
  13. package/dist/cjs/footer/index.js +17 -24
  14. package/dist/cjs/footer/style.scss +0 -36
  15. package/dist/cjs/handoff-message/index.js +0 -3
  16. package/dist/cjs/hooks/useObjectState.js +9 -0
  17. package/dist/cjs/hooks/useObjectState.test.js +5 -5
  18. package/dist/cjs/index.js +7 -21
  19. package/dist/cjs/modal/index.js +4 -1
  20. package/dist/cjs/modal/style.scss +18 -7
  21. package/dist/cjs/newspack-icon/index.js +2 -2
  22. package/dist/cjs/newspack-icon/style.scss +3 -5
  23. package/dist/cjs/notice/index.js +1 -2
  24. package/dist/cjs/notice/style.scss +11 -9
  25. package/dist/cjs/plugin-installer/index.js +3 -3
  26. package/dist/cjs/plugin-settings/SettingsSection.js +2 -0
  27. package/dist/cjs/plugin-settings/index.js +4 -1
  28. package/dist/cjs/plugin-toggle/index.js +2 -0
  29. package/dist/cjs/popover/style.scss +5 -6
  30. package/dist/cjs/progress-bar/index.test.js +1 -2
  31. package/dist/cjs/progress-bar/style.scss +1 -2
  32. package/dist/cjs/proxied-imports/router.js +1 -2
  33. package/dist/cjs/radio-control/style.scss +4 -10
  34. package/dist/cjs/section-header/index.js +21 -1
  35. package/dist/cjs/select-control/ButtonGroupControl.js +2 -0
  36. package/dist/cjs/settings/SettingsCard.js +2 -6
  37. package/dist/cjs/sortable-newsletter-list-control/index.js +7 -5
  38. package/dist/cjs/sortable-newsletter-list-control/style.scss +11 -1
  39. package/dist/cjs/steps-list/style.scss +0 -3
  40. package/dist/cjs/steps-list-item/style.scss +1 -2
  41. package/dist/cjs/style-card/index.js +1 -0
  42. package/dist/cjs/style-card/style.scss +4 -5
  43. package/dist/cjs/style.scss +15 -0
  44. package/dist/cjs/tabbed-navigation/index.js +17 -7
  45. package/dist/cjs/tabbed-navigation/style.scss +2 -6
  46. package/dist/cjs/utils/color.js +35 -0
  47. package/dist/cjs/web-preview/style.scss +11 -11
  48. package/dist/cjs/with-wizard/index.js +80 -3
  49. package/dist/cjs/with-wizard/style.scss +34 -13
  50. package/dist/cjs/with-wizard-screen/index.js +3 -3
  51. package/dist/cjs/with-wizard-screen/style.scss +9 -9
  52. package/dist/cjs/wizard/index.js +38 -13
  53. package/dist/cjs/wizard/store/index.js +13 -5
  54. package/dist/cjs/wizard/store/utils.js +3 -1
  55. package/dist/esm/action-card/action-card.d.js +1 -0
  56. package/dist/esm/action-card/index.js +286 -189
  57. package/dist/esm/action-card/style.scss +142 -44
  58. package/dist/esm/autocomplete-tokenfield/index.js +6 -2
  59. package/dist/esm/box-contrast/index.js +44 -0
  60. package/dist/esm/button/index.js +1 -1
  61. package/dist/esm/button-props/button-props.js +34 -0
  62. package/dist/esm/button-props/index.js +1 -0
  63. package/dist/esm/color-picker/index.js +11 -0
  64. package/dist/esm/custom-select-control/style.scss +7 -12
  65. package/dist/esm/footer/index.js +18 -25
  66. package/dist/esm/footer/style.scss +0 -36
  67. package/dist/esm/handoff-message/index.js +0 -3
  68. package/dist/esm/hooks/useObjectState.js +10 -0
  69. package/dist/esm/hooks/useObjectState.test.js +6 -6
  70. package/dist/esm/index.js +1 -3
  71. package/dist/esm/modal/index.js +4 -1
  72. package/dist/esm/modal/style.scss +18 -7
  73. package/dist/esm/newspack-icon/index.js +2 -2
  74. package/dist/esm/newspack-icon/style.scss +3 -5
  75. package/dist/esm/notice/index.js +1 -2
  76. package/dist/esm/notice/style.scss +11 -9
  77. package/dist/esm/plugin-installer/index.js +3 -3
  78. package/dist/esm/plugin-settings/SettingsSection.js +2 -0
  79. package/dist/esm/plugin-settings/index.js +4 -1
  80. package/dist/esm/plugin-toggle/index.js +2 -0
  81. package/dist/esm/popover/style.scss +5 -6
  82. package/dist/esm/progress-bar/style.scss +1 -2
  83. package/dist/esm/radio-control/style.scss +4 -10
  84. package/dist/esm/section-header/index.js +22 -0
  85. package/dist/esm/select-control/ButtonGroupControl.js +2 -0
  86. package/dist/esm/settings/SettingsCard.js +2 -6
  87. package/dist/esm/sortable-newsletter-list-control/index.js +8 -6
  88. package/dist/esm/sortable-newsletter-list-control/style.scss +11 -1
  89. package/dist/esm/steps-list/style.scss +0 -3
  90. package/dist/esm/steps-list-item/style.scss +1 -2
  91. package/dist/esm/style-card/index.js +1 -0
  92. package/dist/esm/style-card/style.scss +4 -5
  93. package/dist/esm/style.scss +15 -0
  94. package/dist/esm/tabbed-navigation/index.js +17 -7
  95. package/dist/esm/tabbed-navigation/style.scss +2 -6
  96. package/dist/esm/utils/color.js +29 -0
  97. package/dist/esm/web-preview/style.scss +11 -11
  98. package/dist/esm/with-wizard/index.js +81 -4
  99. package/dist/esm/with-wizard/style.scss +34 -13
  100. package/dist/esm/with-wizard-screen/index.js +1 -1
  101. package/dist/esm/with-wizard-screen/style.scss +9 -9
  102. package/dist/esm/wizard/index.js +39 -13
  103. package/dist/esm/wizard/store/index.js +13 -5
  104. package/dist/esm/wizard/store/utils.js +3 -1
  105. package/package.json +1 -1
  106. package/src/accordion/index.js +1 -3
  107. package/src/action-card/action-card.d.ts +40 -0
  108. package/src/action-card/index.js +284 -202
  109. package/src/action-card/style.scss +142 -44
  110. package/src/autocomplete-tokenfield/index.js +3 -2
  111. package/src/autocomplete-with-suggestions/index.js +52 -63
  112. package/src/box-contrast/index.tsx +44 -0
  113. package/src/button/index.tsx +1 -1
  114. package/src/button-card/index.js +1 -12
  115. package/src/card/index.js +1 -11
  116. package/src/category-autocomplete/index.js +4 -19
  117. package/src/color-picker/index.js +11 -7
  118. package/src/custom-select-control/style.scss +7 -12
  119. package/src/footer/index.js +6 -18
  120. package/src/footer/style.scss +0 -36
  121. package/src/form-token-field/index.js +1 -2
  122. package/src/grid/index.tsx +1 -8
  123. package/src/handoff/index.js +4 -11
  124. package/src/handoff-message/index.js +0 -3
  125. package/src/hooks/useObjectState.js +10 -2
  126. package/src/hooks/useObjectState.test.js +14 -14
  127. package/src/image-upload/index.js +3 -23
  128. package/src/index.js +1 -3
  129. package/src/modal/index.js +2 -2
  130. package/src/modal/style.scss +18 -7
  131. package/src/newspack-icon/index.js +3 -14
  132. package/src/newspack-icon/style.scss +3 -5
  133. package/src/notice/index.js +0 -2
  134. package/src/notice/style.scss +11 -9
  135. package/src/plugin-installer/index.js +8 -17
  136. package/src/plugin-settings/SettingsSection.js +3 -7
  137. package/src/plugin-settings/index.js +7 -14
  138. package/src/plugin-toggle/README.md +3 -3
  139. package/src/plugin-toggle/index.js +10 -13
  140. package/src/popover/index.js +1 -5
  141. package/src/popover/style.scss +5 -6
  142. package/src/position-control/index.js +65 -75
  143. package/src/progress-bar/index.js +2 -9
  144. package/src/progress-bar/index.test.js +4 -13
  145. package/src/progress-bar/style.scss +1 -2
  146. package/src/radio-control/style.scss +4 -10
  147. package/src/section-header/index.js +20 -0
  148. package/src/select-control/ButtonGroupControl.js +2 -9
  149. package/src/select-control/GroupedSelectControl.js +1 -9
  150. package/src/select-control/index.js +1 -5
  151. package/src/settings/MinMaxSetting.js +2 -14
  152. package/src/settings/SettingsCard.js +2 -11
  153. package/src/sortable-newsletter-list-control/index.js +10 -26
  154. package/src/sortable-newsletter-list-control/style.scss +11 -1
  155. package/src/steps-list/style.scss +0 -3
  156. package/src/steps-list-item/index.js +1 -4
  157. package/src/steps-list-item/style.scss +1 -2
  158. package/src/style-card/index.js +6 -21
  159. package/src/style-card/style.scss +4 -5
  160. package/src/style.scss +15 -0
  161. package/src/tabbed-navigation/index.js +19 -7
  162. package/src/tabbed-navigation/style.scss +2 -6
  163. package/src/text-control/index.tsx +2 -12
  164. package/src/utils/color.ts +32 -0
  165. package/src/web-preview/style.scss +11 -11
  166. package/src/with-wizard/index.js +67 -16
  167. package/src/with-wizard/style.scss +34 -13
  168. package/src/with-wizard-screen/index.js +1 -1
  169. package/src/with-wizard-screen/style.scss +9 -9
  170. package/src/wizard/components/WizardError.js +2 -7
  171. package/src/wizard/index.js +64 -62
  172. package/src/wizard/store/index.js +8 -10
  173. package/src/wizard/store/utils.js +3 -4
  174. package/dist/cjs/date-range-picker/index.js +0 -39
  175. package/dist/cjs/date-range-picker/style.scss +0 -148
  176. package/dist/cjs/newspack-logo/index.js +0 -54
  177. package/dist/cjs/newspack-logo/style.scss +0 -30
  178. package/dist/cjs/patrons-logo/index.js +0 -77
  179. package/dist/esm/date-range-picker/index.js +0 -31
  180. package/dist/esm/date-range-picker/style.scss +0 -148
  181. package/dist/esm/newspack-logo/index.js +0 -46
  182. package/dist/esm/newspack-logo/style.scss +0 -30
  183. package/dist/esm/patrons-logo/index.js +0 -70
  184. package/shared/scss/_colors.scss +0 -27
  185. package/src/date-range-picker/index.js +0 -31
  186. package/src/date-range-picker/style.scss +0 -148
  187. package/src/newspack-logo/index.js +0 -45
  188. package/src/newspack-logo/style.scss +0 -30
  189. package/src/patrons-logo/index.js +0 -76
  190. /package/{shared/js → src/button-props}/button-props.js +0 -0
  191. /package/{shared/js → src/button-props}/index.js +0 -0
@@ -9,8 +9,7 @@
9
9
  padding: 0;
10
10
  border-color: wp-colors.$gray-300;
11
11
 
12
- // Clickable
13
-
12
+ /* Clickable */
14
13
  &.newspack-card--is-clickable {
15
14
  transition: box-shadow 125ms ease-in-out;
16
15
 
@@ -19,8 +18,7 @@
19
18
  }
20
19
  }
21
20
 
22
- // Status
23
-
21
+ /* Status */
24
22
  &.newspack-card__is-disabled,
25
23
  &.newspack-card__is-primary,
26
24
  &.newspack-card__is-secondary,
@@ -49,7 +47,7 @@
49
47
  box-shadow: inset 4px 0 0 wp-colors.$alert-red;
50
48
  }
51
49
 
52
- // Small
50
+ /* Small */
53
51
  &.is-small {
54
52
  .newspack-action-card__region-top {
55
53
  padding: 8px 16px;
@@ -116,8 +114,7 @@
116
114
  }
117
115
  }
118
116
 
119
- // Medium
120
-
117
+ /* Medium */
121
118
  &.is-medium {
122
119
  .newspack-action-card__region-top {
123
120
  padding: 16px;
@@ -146,8 +143,7 @@
146
143
  }
147
144
  }
148
145
 
149
- // Nested children
150
-
146
+ /* Nested children */
151
147
  &.newspack-card--has-children {
152
148
  .newspack-action-card {
153
149
  &:first-child {
@@ -164,8 +160,7 @@
164
160
  }
165
161
  }
166
162
 
167
- // Has grey header
168
-
163
+ /* Has grey header */
169
164
  &.newspack-card--has-grey-header {
170
165
  overflow: hidden;
171
166
 
@@ -198,8 +193,7 @@
198
193
  }
199
194
  }
200
195
 
201
- // Indent
202
-
196
+ /* Indent */
203
197
  &.newspack-card--indent {
204
198
  margin-left: 56px;
205
199
  position: relative;
@@ -216,8 +210,7 @@
216
210
  }
217
211
  }
218
212
 
219
- // Typography
220
-
213
+ /* Typography */
221
214
  h2,
222
215
  p:not([class*="components-base-control"]) {
223
216
  margin: 0;
@@ -247,8 +240,7 @@
247
240
  }
248
241
  }
249
242
 
250
- // Regions
251
-
243
+ /* Regions */
252
244
  .newspack-action-card__region {
253
245
  align-items: center;
254
246
  display: flex;
@@ -264,7 +256,7 @@
264
256
  display: flex;
265
257
  }
266
258
 
267
- // Toggle Control
259
+ /* Toggle Control */
268
260
  .components-toggle-control {
269
261
  margin-bottom: 24px;
270
262
  margin-top: 0;
@@ -359,14 +351,12 @@
359
351
  }
360
352
  }
361
353
 
362
- // Waiting
363
-
354
+ /* Waiting */
364
355
  .newspack-action-card__container {
365
356
  display: flex;
366
357
  }
367
358
 
368
- // Notifications
369
-
359
+ /* Notifications */
370
360
  .newspack-action-card__notification {
371
361
  .newspack-notice {
372
362
  margin: 0;
@@ -383,8 +373,7 @@
383
373
  }
384
374
  }
385
375
 
386
- // Image
387
-
376
+ /* Image */
388
377
  .newspack-action-card__image {
389
378
  background-position: center;
390
379
  background-repeat: no-repeat;
@@ -394,40 +383,52 @@
394
383
  width: 48px;
395
384
  }
396
385
 
397
- // Icon
398
-
386
+ /* Icon */
399
387
  .newspack_plugin-installer__icon {
400
388
  margin: 0;
401
389
  }
402
390
 
403
- // Badge
404
-
391
+ /* Badge */
405
392
  .newspack-action-card__badge {
406
393
  background: wp-colors.$gray-100;
407
394
  border-radius: 2px;
408
395
  color: wp-colors.$gray-900;
409
396
  display: block;
410
397
  flex: 0 0 auto;
411
- font-size: 10px;
412
- font-weight: bold;
413
- line-height: 1.4;
398
+ font-size: 12px;
399
+ font-weight: 400;
400
+ line-height: 1.333;
414
401
  margin: 0 8px 0 0;
415
- padding: 2px 8px;
416
- text-transform: uppercase;
402
+ padding: 2px 4px;
403
+
404
+ &.newspack-action-card__badge-level-warning {
405
+ background-color: color-mix(in srgb, #fff 90%, wp-colors.$alert-yellow);
406
+ color: color-mix(in srgb, #000 50%, wp-colors.$alert-yellow);
407
+ }
408
+ &.newspack-action-card__badge-level-error {
409
+ background-color: color-mix(in srgb, #fff 90%, wp-colors.$alert-red);
410
+ color: color-mix(in srgb, #000 50%, wp-colors.$alert-red);
411
+ }
412
+ &.newspack-action-card__badge-level-success {
413
+ background-color: color-mix(in srgb, #fff 90%, wp-colors.$alert-green);
414
+ color: color-mix(in srgb, #000 50%, wp-colors.$alert-green);
415
+ }
416
+ &.newspack-action-card__badge-level-brand {
417
+ background-color: color-mix(in srgb, #fff 90%, var(--wp-admin-theme-color));
418
+ color: color-mix(in srgb, #000 50%, var(--wp-admin-theme-color));
419
+ }
417
420
 
418
421
  + .newspack-action-card__badge {
419
422
  margin-left: -4px;
420
423
  }
421
424
  }
422
425
 
423
- // Description Card
424
-
426
+ /* Description Card */
425
427
  &.newspack-description-card {
426
428
  font-style: italic;
427
429
  }
428
430
 
429
- // Expandable card children
430
-
431
+ /* Expandable card children */
431
432
  &.is-expandable {
432
433
  .newspack-action-card__title .components-button.is-link {
433
434
  color: inherit;
@@ -439,6 +440,10 @@
439
440
  .newspack-action-card__region-children {
440
441
  border-top: 1px solid wp-colors.$gray-100;
441
442
  padding-top: 24px;
443
+
444
+ + .newspack-action-card__region-children {
445
+ border-top: none;
446
+ }
442
447
  }
443
448
 
444
449
  &.is-medium .newspack-action-card__region-children {
@@ -460,7 +465,7 @@
460
465
  }
461
466
  }
462
467
 
463
- // Action content with multiple buttons
468
+ /* Action content with multiple buttons */
464
469
  &.has-action-content .newspack-action-card__region-right {
465
470
  flex-direction: row;
466
471
 
@@ -468,16 +473,109 @@
468
473
  margin-left: 8px;
469
474
  }
470
475
  }
476
+ }
471
477
 
472
- // Multiple Cards
478
+ .newspack-card {
479
+ .newspack-card.newspack-action-card {
480
+ &:not(.newspack-card__no-border) {
481
+ border: 1px solid wp-colors.$gray-200;
482
+ }
483
+ &.newspack-card__no-border {
484
+ border: none;
485
+ .newspack-action-card__region-top,
486
+ .newspack-action-card__region-children {
487
+ padding: 0;
488
+ }
489
+ }
490
+ }
491
+ }
492
+
493
+ .newspack-action-card__draggable-wrapper {
494
+ margin: 16px 0;
473
495
 
474
- & + & {
475
- margin-top: -16px;
496
+ &.is-dragging {
497
+ opacity: 0.5;
498
+ }
499
+
500
+ .newspack-card {
501
+ margin: 0;
502
+ }
503
+
504
+ .newspack-action-card {
505
+ display: flex;
506
+ flex-direction: row;
507
+ flex-wrap: wrap;
508
+
509
+ .newspack-action-card__draggable-controls {
510
+ flex: 0 0 50px;
511
+ align-items: center;
512
+ display: flex;
513
+ height: 100%;
514
+ min-height: 100%;
515
+ width: fit-content;
516
+ justify-content: center;
517
+ margin-left: 8px;
518
+ margin-right: 8px;
519
+ padding: 8px 12px 8px 0;
520
+ border-right: 1px solid wp-colors.$gray-300;
521
+
522
+ .drag-handle {
523
+ align-items: center;
524
+ cursor: grab;
525
+ display: flex;
526
+ height: 100%;
527
+ justify-content: flex-end;
528
+ margin-left: -8px;
529
+ width: 32px;
530
+
531
+ .is-dragging & {
532
+ cursor: grabbing;
533
+ }
534
+
535
+ svg {
536
+ padding: 3px;
537
+ }
538
+ }
539
+
540
+ .movers {
541
+ display: flex;
542
+ flex-direction: column;
543
+
544
+ .components-button {
545
+ color: wp-colors.$gray-900;
546
+ display: block;
547
+ height: 24px;
548
+ line-height: 24px;
549
+ min-width: 24px;
550
+ padding: 0;
551
+ width: 24px;
552
+ + .components-button {
553
+ margin-top: -4px;
554
+ }
555
+ }
556
+ }
557
+ }
558
+
559
+ .newspack-action-card__region-top {
560
+ flex: 1 1 auto;
561
+ padding: 8px 16px 8px 0 !important;
562
+ flex: 1;
563
+ }
564
+
565
+ .newspack-action-card__region-children {
566
+ flex: 0 0 100%;
567
+ padding: 0 0 0 16px;
568
+ }
569
+
570
+ &.is-draggable {
571
+ display: flex;
572
+ align-items: center;
573
+ }
476
574
  }
477
575
  }
478
576
 
479
- .newspack-card {
480
- .newspack-card.newspack-action-card {
481
- border: 1px solid wp-colors.$gray-200;
577
+ .components-draggable__clone {
578
+ .newspack-card {
579
+ box-shadow: 0 0 8px 4px rgba(black, 0.08);
482
580
  }
483
581
  }
@@ -228,7 +228,9 @@ class AutocompleteTokenField extends Component {
228
228
  help,
229
229
  label = '',
230
230
  placeholder = '',
231
- maxLength
231
+ maxLength,
232
+ style,
233
+ __next40pxDefaultSize
232
234
  } = this.props;
233
235
  const {
234
236
  suggestions,
@@ -240,6 +242,7 @@ class AutocompleteTokenField extends Component {
240
242
  }
241
243
  return /*#__PURE__*/_jsxs("div", {
242
244
  className: "newspack-autocomplete-tokenfield",
245
+ style: style,
243
246
  children: [/*#__PURE__*/_jsxs("div", {
244
247
  className: classNames.join(' '),
245
248
  children: [/*#__PURE__*/_jsx(FormTokenField, {
@@ -249,7 +252,8 @@ class AutocompleteTokenField extends Component {
249
252
  onInputChange: input => this.debouncedUpdateSuggestions(input),
250
253
  label: label,
251
254
  maxLength: maxLength,
252
- placeholder: placeholder
255
+ placeholder: placeholder,
256
+ __next40pxDefaultSize: __next40pxDefaultSize
253
257
  }), loading && /*#__PURE__*/_jsx(Spinner, {})]
254
258
  }), help && /*#__PURE__*/_jsx("p", {
255
259
  className: "newspack-autocomplete-tokenfield__help",
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Box Contrast
3
+ *
4
+ * can be used to dynamically assign black or white color/background-color based on a hex color.
5
+ * Black/white can be assigned to either text or background-color.
6
+ */
7
+
8
+ /**
9
+ * Dependencies
10
+ */
11
+ import { getContrast } from '../utils/color';
12
+
13
+ /**
14
+ * Box Contrast component
15
+ *
16
+ * @return JSX.Element
17
+ */
18
+ import { jsx as _jsx } from "react/jsx-runtime";
19
+ const BoxContrast = ({
20
+ hexColor,
21
+ isInverted = false,
22
+ children,
23
+ ...props
24
+ }) => {
25
+ let contrastColor;
26
+ if (hexColor === '#f0f0f0') {
27
+ contrastColor = '#1e1e1e';
28
+ } else {
29
+ contrastColor = getContrast(hexColor);
30
+ }
31
+ const style = isInverted ? {
32
+ color: hexColor,
33
+ backgoundColor: contrastColor
34
+ } : {
35
+ backgroundColor: hexColor,
36
+ color: contrastColor
37
+ };
38
+ return /*#__PURE__*/_jsx("div", {
39
+ ...props,
40
+ style: style,
41
+ children: children
42
+ });
43
+ };
44
+ export default BoxContrast;
@@ -40,7 +40,7 @@ const Button = ({
40
40
  if (isAwaitingOnClick) {
41
41
  otherProps.disabled = true;
42
42
  }
43
- // @ts-ignore - @wordpress/components' Button can only have either href or onClick, not both.
43
+ // @ts-expect-error - @wordpress/components' Button can only have either href or onClick, not both.
44
44
  return /*#__PURE__*/_jsx(BaseComponent, {
45
45
  ...otherProps
46
46
  });
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import isFunction from 'lodash/isFunction';
5
+ import isObject from 'lodash/isObject';
6
+ import isString from 'lodash/isString';
7
+
8
+ /**
9
+ * Creates button props based on an action
10
+ */
11
+ export default function buttonProps(action) {
12
+ const props = {};
13
+ if (isFunction(action)) {
14
+ props.onClick = action;
15
+ }
16
+ if (isString(action)) {
17
+ props.href = action;
18
+ }
19
+ if (isObject(action)) {
20
+ if (action.handoff) {
21
+ props.plugin = action.handoff;
22
+ if (action.editLink) {
23
+ props.editLink = action.editLink;
24
+ }
25
+ }
26
+ if (action.onClick) {
27
+ props.onClick = action.onClick;
28
+ }
29
+ if (action.href) {
30
+ props.href = action.href;
31
+ }
32
+ }
33
+ return props;
34
+ }
@@ -0,0 +1 @@
1
+ export { default as buttonProps } from './button-props';
@@ -22,6 +22,17 @@ extend([a11yPlugin]);
22
22
  const {
23
23
  InteractiveDiv
24
24
  } = utils;
25
+
26
+ /**
27
+ * ColorPicker component.
28
+ *
29
+ * @param {Object} props - Component props.
30
+ * @param {JSX.Element|string} props.label - Label for the color picker.
31
+ * @param {string} [props.color] - Default color.
32
+ * @param {Function} props.onChange - Function to call when the color changes.
33
+ * @param {string} [props.className] - Additional class name.
34
+ * @return {JSX.Element} ColorPicker component.
35
+ */
25
36
  const ColorPicker = ({
26
37
  label,
27
38
  color = '#fff',
@@ -10,7 +10,7 @@
10
10
  margin-bottom: 8px;
11
11
  }
12
12
 
13
- .components-custom-select-control__button {
13
+ button {
14
14
  border-color: wp-colors.$gray-700;
15
15
  border-radius: 2px;
16
16
  color: wp-colors.$gray-900;
@@ -41,6 +41,10 @@
41
41
  }
42
42
  }
43
43
 
44
+ button + div {
45
+ min-width: 200px;
46
+ }
47
+
44
48
  .components-custom-select-control__menu {
45
49
  border-color: wp-colors.$gray-700;
46
50
  border-radius: 2px;
@@ -54,7 +58,6 @@
54
58
  cursor: pointer;
55
59
  display: flex;
56
60
  line-height: inherit;
57
- margin: 0 0 0 28px;
58
61
  padding: 6px 8px;
59
62
  transition: color 125ms ease-in-out;
60
63
 
@@ -77,16 +80,8 @@
77
80
 
78
81
  &.is-selected {
79
82
  margin-left: 0;
80
-
81
- &::before {
82
- background:
83
- url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cGF0aCBkPSJNMTguMyA1LjZMOS45IDE2LjlsLTQuNi0zLjQtLjkgMS4yIDUuOCA0LjMgOS4zLTEyLjZ6IiBmaWxsPSIjMzM2NmZmIj48L3BhdGg+PC9zdmc+Cg==")
84
- 0 0 no-repeat;
85
- content: "";
86
- display: block;
87
- height: 24px;
88
- margin: 0 4px 0 0;
89
- width: 24px;
83
+ span svg {
84
+ fill: var(--wp-admin-theme-color);
90
85
  }
91
86
  }
92
87
  }
@@ -11,11 +11,10 @@ import { ExternalLink } from '@wordpress/components';
11
11
  /**
12
12
  * Internal dependencies.
13
13
  */
14
- import { PatronsLogo } from '../';
15
14
  import './style.scss';
16
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
+ import { jsx as _jsx } from "react/jsx-runtime";
17
16
  const Footer = ({
18
- simple
17
+ simple = undefined
19
18
  }) => {
20
19
  const {
21
20
  components_demo: componentsDemo = false,
@@ -71,29 +70,23 @@ const Footer = ({
71
70
  url: `mailto:${supportEmail}`
72
71
  });
73
72
  }
74
- return /*#__PURE__*/_jsxs("div", {
73
+ return /*#__PURE__*/_jsx("div", {
75
74
  className: "newspack-footer",
76
- children: [!simple && /*#__PURE__*/_jsx("div", {
77
- className: "newspack-footer__inner",
78
- children: /*#__PURE__*/_jsx("ul", {
79
- children: footerElements.map(({
80
- url,
81
- label,
82
- external
83
- }, index) => /*#__PURE__*/_jsx("li", {
84
- children: external ? /*#__PURE__*/_jsx(ExternalLink, {
85
- href: url,
86
- children: label
87
- }) : /*#__PURE__*/_jsx("a", {
88
- href: url,
89
- children: label
90
- })
91
- }, index))
92
- })
93
- }), /*#__PURE__*/_jsx("div", {
94
- className: "newspack-footer__logo",
95
- children: /*#__PURE__*/_jsx(PatronsLogo, {})
96
- })]
75
+ children: !simple && /*#__PURE__*/_jsx("ul", {
76
+ children: footerElements.map(({
77
+ url,
78
+ label,
79
+ external
80
+ }, index) => /*#__PURE__*/_jsx("li", {
81
+ children: external ? /*#__PURE__*/_jsx(ExternalLink, {
82
+ href: url,
83
+ children: label
84
+ }) : /*#__PURE__*/_jsx("a", {
85
+ href: url,
86
+ children: label
87
+ })
88
+ }, index))
89
+ })
97
90
  });
98
91
  };
99
92
  export default Footer;
@@ -5,16 +5,13 @@
5
5
  @use "~@wordpress/base-styles/colors" as wp-colors;
6
6
 
7
7
  .newspack-footer {
8
- align-items: stretch;
9
8
  background: white;
10
9
  border: 0 solid wp-colors.$gray-300;
11
10
  border-width: 1px 0;
12
11
  bottom: 0;
13
12
  color: wp-colors.$gray-700;
14
13
  display: flex;
15
- flex-wrap: wrap;
16
14
  font-size: 12px;
17
- justify-content: space-between;
18
15
  left: 0;
19
16
  line-height: 16px;
20
17
  position: absolute;
@@ -22,17 +19,6 @@
22
19
 
23
20
  @media screen and ( min-width: 783px ) {
24
21
  bottom: 40px;
25
- flex-wrap: nowrap;
26
- }
27
-
28
- &__inner {
29
- align-items: center;
30
- display: flex;
31
- flex: 0 0 100%;
32
-
33
- @media screen and ( min-width: 783px ) {
34
- flex: 1 1 auto;
35
- }
36
22
  }
37
23
 
38
24
  ul {
@@ -57,26 +43,4 @@
57
43
  }
58
44
  }
59
45
  }
60
-
61
- &__logo {
62
- align-items: center;
63
- background: wp-colors.$gray-900;
64
- display: flex;
65
- margin: 0 0 -1px;
66
- padding: 16px;
67
- width: 100%;
68
-
69
- @media screen and ( min-width: 783px ) {
70
- margin: -1px 0 -1px 8px;
71
- max-width: 33.33%;
72
- width: auto;
73
- }
74
-
75
- .patrons-logo {
76
- display: block;
77
- fill: white;
78
- max-height: 16px;
79
- width: auto;
80
- }
81
- }
82
46
  }
@@ -31,9 +31,6 @@ export default function HandoffMessage() {
31
31
  setHandoffMessage(false);
32
32
  }
33
33
  }, 100);
34
-
35
- // Clean up the notification when unmounting.
36
- return () => window.localStorage.removeItem(HANDOFF_KEY);
37
34
  }, []);
38
35
  if (!handoffMessage) {
39
36
  return null;
@@ -4,6 +4,12 @@
4
4
  import { useState } from '@wordpress/element';
5
5
  import isArray from 'lodash/isArray';
6
6
  import mergeWith from 'lodash/mergeWith';
7
+
8
+ /**
9
+ * @typedef {Object} StateObjectUpdate
10
+ * @property {Object.<string, any>} [update] The update object with key-value pairs to merge into the state.
11
+ */
12
+
7
13
  const mergeCustomizer = (objValue, srcValue) => {
8
14
  if (isArray(objValue)) {
9
15
  // If it's an array, replace it (instead of concatenating).
@@ -14,6 +20,10 @@ const mergeCustomizer = (objValue, srcValue) => {
14
20
  /**
15
21
  * A useState for an object.
16
22
  * Nested objects will be nested, but arrays replaced.
23
+ *
24
+ * @template T
25
+ * @param {T} initial Initial state object.
26
+ * @return {[T, (keyOrUpdate: string | Partial<T>) => (value?: any) => void]} The state object and a function to update it.
17
27
  */
18
28
  export default (initial = {}) => {
19
29
  const [stateObject, setStateObject] = useState(initial);
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { render, screen, fireEvent } from '@testing-library/react';
2
+ import { render, screen, fireEvent, act } from '@testing-library/react';
3
3
  import useObjectState from './useObjectState';
4
4
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
5
  const INIT_STATE = {
@@ -51,27 +51,27 @@ describe('useObjectState', () => {
51
51
  });
52
52
  it('updates arrays', () => {
53
53
  expect(getState()).toStrictEqual(INIT_STATE);
54
- screen.getByText('Remove widgets').click();
54
+ act(() => screen.getByText('Remove widgets').click());
55
55
  expect(getState()).toMatchObject({
56
56
  widgets: []
57
57
  });
58
- screen.getByText('Add widget').click();
58
+ act(() => screen.getByText('Add widget').click());
59
59
  expect(getState()).toMatchObject({
60
60
  widgets: [1]
61
61
  });
62
62
  });
63
63
  it('updates a simple value', () => {
64
- fireEvent.change(screen.getByPlaceholderText('name'), {
64
+ act(() => fireEvent.change(screen.getByPlaceholderText('name'), {
65
65
  target: {
66
66
  value: 'Ramon'
67
67
  }
68
- });
68
+ }));
69
69
  expect(getState()).toMatchObject({
70
70
  name: 'Ramon'
71
71
  });
72
72
  });
73
73
  it('updates a nested object', () => {
74
- screen.getByText('Nested update').click();
74
+ act(() => screen.getByText('Nested update').click());
75
75
  expect(getState()).toMatchObject({
76
76
  attributes: {
77
77
  bar: 2,