newspack-components 2.2.1 → 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/dist/cjs/action-card/index.js +3 -4
  2. package/dist/cjs/autocomplete-tokenfield/index.js +52 -15
  3. package/dist/cjs/autocomplete-tokenfield/style.scss +11 -5
  4. package/dist/cjs/autocomplete-with-suggestions/index.js +45 -57
  5. package/dist/cjs/autocomplete-with-suggestions/style.scss +1 -9
  6. package/dist/cjs/button/index.js +8 -9
  7. package/dist/cjs/button-card/index.js +1 -2
  8. package/dist/cjs/card/index.js +1 -2
  9. package/dist/cjs/category-autocomplete/index.js +4 -8
  10. package/dist/cjs/color-picker/index.js +7 -9
  11. package/dist/cjs/consts.js +2 -7
  12. package/dist/cjs/custom-select-control/index.js +1 -2
  13. package/dist/cjs/footer/index.js +24 -29
  14. package/dist/cjs/form-token-field/index.js +1 -2
  15. package/dist/cjs/global-notices/index.js +1 -2
  16. package/dist/cjs/grid/index.js +14 -31
  17. package/dist/cjs/handoff/index.js +7 -8
  18. package/dist/cjs/hooks/index.js +2 -3
  19. package/dist/cjs/hooks/useObjectState.js +1 -2
  20. package/dist/cjs/hooks/useOnClickOutside.js +1 -2
  21. package/dist/cjs/hooks/usePrompt.js +1 -4
  22. package/dist/cjs/image-upload/index.js +5 -6
  23. package/dist/cjs/index.js +0 -14
  24. package/dist/cjs/info-button/index.js +1 -2
  25. package/dist/cjs/modal/index.js +1 -2
  26. package/dist/cjs/newspack-icon/index.js +1 -2
  27. package/dist/cjs/newspack-logo/index.js +1 -2
  28. package/dist/cjs/notice/index.js +2 -3
  29. package/dist/cjs/patrons-logo/index.js +4 -5
  30. package/dist/cjs/plugin-installer/index.js +9 -13
  31. package/dist/cjs/plugin-settings/SettingsSection.js +2 -4
  32. package/dist/cjs/plugin-settings/index.js +2 -3
  33. package/dist/cjs/plugin-toggle/index.js +16 -20
  34. package/dist/cjs/popover/index.js +1 -2
  35. package/dist/cjs/position-control/index.js +22 -23
  36. package/dist/cjs/progress-bar/index.js +1 -2
  37. package/dist/cjs/progress-bar/index.test.js +4 -5
  38. package/dist/cjs/proxied-imports/router.js +1 -2
  39. package/dist/cjs/radio-control/index.js +1 -2
  40. package/dist/cjs/section-header/index.js +13 -14
  41. package/dist/cjs/section-header/style.scss +4 -0
  42. package/dist/cjs/select-control/ButtonGroupControl.js +10 -12
  43. package/dist/cjs/select-control/GroupedSelectControl.js +21 -25
  44. package/dist/cjs/select-control/index.js +1 -2
  45. package/dist/cjs/settings/MinMaxSetting.js +17 -15
  46. package/dist/cjs/settings/SettingsCard.js +10 -12
  47. package/dist/cjs/settings/SettingsSection.js +20 -24
  48. package/dist/cjs/settings/index.js +2 -3
  49. package/dist/cjs/settings/style.scss +14 -1
  50. package/dist/cjs/sortable-newsletter-list-control/index.js +134 -0
  51. package/dist/cjs/sortable-newsletter-list-control/style.scss +45 -0
  52. package/dist/cjs/steps-list/index.js +1 -2
  53. package/dist/cjs/steps-list-item/index.js +1 -2
  54. package/dist/cjs/style-card/index.js +6 -7
  55. package/dist/cjs/style.scss +13 -1
  56. package/dist/cjs/tabbed-navigation/index.js +11 -14
  57. package/dist/cjs/text-control/index.js +32 -42
  58. package/dist/cjs/utils/index.js +15 -19
  59. package/dist/cjs/waiting/index.js +1 -2
  60. package/dist/cjs/web-preview/index.js +7 -8
  61. package/dist/cjs/with-wizard/index.js +6 -7
  62. package/dist/cjs/with-wizard-screen/index.js +20 -24
  63. package/dist/cjs/wizard/components/WizardError.js +7 -9
  64. package/dist/cjs/wizard/index.js +16 -21
  65. package/dist/cjs/wizard/store/index.js +36 -37
  66. package/dist/cjs/wizard/store/utils.js +1 -4
  67. package/dist/esm/action-card/index.js +3 -4
  68. package/dist/esm/autocomplete-tokenfield/index.js +52 -15
  69. package/dist/esm/autocomplete-tokenfield/style.scss +11 -5
  70. package/dist/esm/autocomplete-with-suggestions/index.js +46 -59
  71. package/dist/esm/autocomplete-with-suggestions/style.scss +1 -9
  72. package/dist/esm/button/index.js +7 -7
  73. package/dist/esm/button-card/index.js +1 -2
  74. package/dist/esm/category-autocomplete/index.js +4 -8
  75. package/dist/esm/color-picker/index.js +7 -9
  76. package/dist/esm/consts.js +0 -2
  77. package/dist/esm/footer/index.js +24 -29
  78. package/dist/esm/form-token-field/index.js +1 -2
  79. package/dist/esm/grid/index.js +13 -29
  80. package/dist/esm/handoff/index.js +7 -8
  81. package/dist/esm/hooks/useObjectState.js +1 -2
  82. package/dist/esm/hooks/useObjectState.test.js +1 -2
  83. package/dist/esm/hooks/usePrompt.js +1 -4
  84. package/dist/esm/image-upload/index.js +5 -7
  85. package/dist/esm/index.js +0 -2
  86. package/dist/esm/notice/index.js +2 -3
  87. package/dist/esm/patrons-logo/index.js +4 -5
  88. package/dist/esm/plugin-installer/index.js +9 -14
  89. package/dist/esm/plugin-settings/SettingsSection.js +2 -4
  90. package/dist/esm/plugin-settings/index.js +2 -3
  91. package/dist/esm/plugin-toggle/index.js +16 -20
  92. package/dist/esm/position-control/index.js +23 -25
  93. package/dist/esm/progress-bar/index.js +1 -2
  94. package/dist/esm/progress-bar/index.test.js +4 -5
  95. package/dist/esm/section-header/index.js +13 -14
  96. package/dist/esm/section-header/style.scss +4 -0
  97. package/dist/esm/select-control/ButtonGroupControl.js +9 -10
  98. package/dist/esm/select-control/GroupedSelectControl.js +22 -27
  99. package/dist/esm/settings/MinMaxSetting.js +17 -16
  100. package/dist/esm/settings/SettingsCard.js +9 -10
  101. package/dist/esm/settings/SettingsSection.js +20 -24
  102. package/dist/esm/settings/style.scss +14 -1
  103. package/dist/esm/sortable-newsletter-list-control/index.js +128 -0
  104. package/dist/esm/sortable-newsletter-list-control/style.scss +45 -0
  105. package/dist/esm/steps-list-item/index.js +1 -2
  106. package/dist/esm/style-card/index.js +6 -7
  107. package/dist/esm/style.scss +13 -1
  108. package/dist/esm/tabbed-navigation/index.js +11 -14
  109. package/dist/esm/text-control/index.js +32 -41
  110. package/dist/esm/utils/index.js +13 -16
  111. package/dist/esm/web-preview/index.js +7 -8
  112. package/dist/esm/with-wizard/index.js +7 -9
  113. package/dist/esm/with-wizard-screen/index.js +21 -27
  114. package/dist/esm/wizard/components/WizardError.js +7 -9
  115. package/dist/esm/wizard/index.js +16 -22
  116. package/dist/esm/wizard/store/index.js +35 -35
  117. package/dist/esm/wizard/store/utils.js +1 -4
  118. package/package.json +7 -8
  119. package/src/autocomplete-tokenfield/index.js +48 -15
  120. package/src/autocomplete-tokenfield/style.scss +11 -5
  121. package/src/autocomplete-with-suggestions/index.js +17 -22
  122. package/src/autocomplete-with-suggestions/style.scss +1 -9
  123. package/src/button/{index.js → index.tsx} +12 -5
  124. package/src/consts.js +0 -2
  125. package/src/footer/index.js +7 -7
  126. package/src/grid/index.tsx +34 -0
  127. package/src/handoff/index.js +7 -6
  128. package/src/hooks/{index.js → index.ts} +1 -1
  129. package/src/hooks/{usePrompt.js → usePrompt.ts} +4 -8
  130. package/src/image-upload/index.js +4 -4
  131. package/src/index.js +0 -2
  132. package/src/notice/index.js +1 -1
  133. package/src/patrons-logo/index.js +4 -1
  134. package/src/plugin-installer/index.js +7 -7
  135. package/src/plugin-settings/index.js +1 -1
  136. package/src/plugin-toggle/index.js +7 -5
  137. package/src/position-control/index.js +13 -13
  138. package/src/section-header/index.js +3 -3
  139. package/src/section-header/style.scss +4 -0
  140. package/src/select-control/GroupedSelectControl.js +1 -1
  141. package/src/settings/MinMaxSetting.js +8 -6
  142. package/src/settings/style.scss +14 -1
  143. package/src/sortable-newsletter-list-control/index.js +137 -0
  144. package/src/sortable-newsletter-list-control/style.scss +45 -0
  145. package/src/style-card/index.js +11 -5
  146. package/src/style.scss +13 -1
  147. package/src/tabbed-navigation/index.js +1 -1
  148. package/src/text-control/index.tsx +65 -0
  149. package/src/web-preview/index.js +6 -6
  150. package/src/with-wizard/index.js +4 -4
  151. package/src/with-wizard-screen/index.js +1 -1
  152. package/src/wizard/components/WizardError.js +1 -1
  153. package/src/wizard/index.js +3 -3
  154. package/src/wizard/store/index.js +9 -2
  155. package/dist/cjs/accordion/index.js +0 -46
  156. package/dist/cjs/accordion/style.scss +0 -27
  157. package/dist/cjs/date-range-picker/index.js +0 -41
  158. package/dist/cjs/date-range-picker/style.scss +0 -148
  159. package/dist/esm/accordion/index.js +0 -38
  160. package/dist/esm/accordion/style.scss +0 -27
  161. package/dist/esm/date-range-picker/index.js +0 -32
  162. package/dist/esm/date-range-picker/style.scss +0 -148
  163. package/src/accordion/index.js +0 -32
  164. package/src/accordion/style.scss +0 -27
  165. package/src/date-range-picker/index.js +0 -31
  166. package/src/date-range-picker/style.scss +0 -148
  167. package/src/grid/index.js +0 -44
  168. package/src/text-control/index.js +0 -56
@@ -26,17 +26,16 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
26
26
  * External dependencies
27
27
  */
28
28
 
29
- const SectionHeader = _ref => {
30
- let {
31
- centered = false,
32
- className = null,
33
- description,
34
- heading = 2,
35
- isWhite = false,
36
- noMargin = false,
37
- title,
38
- id = null
39
- } = _ref;
29
+ const SectionHeader = ({
30
+ centered = false,
31
+ className = null,
32
+ description = '',
33
+ heading = 2,
34
+ isWhite = false,
35
+ noMargin = false,
36
+ title,
37
+ id = null
38
+ }) => {
40
39
  // If id is in the URL as a scrollTo param, scroll to it on render.
41
40
  const ref = (0, _element.useRef)();
42
41
  (0, _element.useEffect)(() => {
@@ -55,6 +54,7 @@ const SectionHeader = _ref => {
55
54
  const HeadingTag = `h${heading}`;
56
55
  return (0, _jsxRuntime.jsx)("div", {
57
56
  id: id,
57
+ className: "newspack-section-header__container",
58
58
  ref: ref,
59
59
  children: (0, _jsxRuntime.jsxs)(_.Grid, {
60
60
  columns: 1,
@@ -64,7 +64,7 @@ const SectionHeader = _ref => {
64
64
  children: title
65
65
  }), typeof title === 'function' && (0, _jsxRuntime.jsx)(HeadingTag, {
66
66
  children: title()
67
- }), typeof description === 'string' && (0, _jsxRuntime.jsx)("p", {
67
+ }), description && typeof description === 'string' && (0, _jsxRuntime.jsx)("p", {
68
68
  children: description
69
69
  }), typeof description === 'function' && (0, _jsxRuntime.jsx)("p", {
70
70
  children: description()
@@ -72,5 +72,4 @@ const SectionHeader = _ref => {
72
72
  })
73
73
  });
74
74
  };
75
- var _default = SectionHeader;
76
- exports.default = _default;
75
+ var _default = exports.default = SectionHeader;
@@ -7,6 +7,10 @@
7
7
  .newspack-section-header {
8
8
  margin: 64px 0 32px;
9
9
 
10
+ &__container:not(:first-child) {
11
+ margin-top: 48px;
12
+ }
13
+
10
14
  &--no-margin,
11
15
  h1,
12
16
  h2,
@@ -22,16 +22,15 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
22
22
  * Internal dependencies
23
23
  */
24
24
 
25
- const ButtonGroupControl = _ref => {
26
- let {
27
- buttonOptions,
28
- buttonSmall,
29
- className,
30
- hideLabelFromVision,
31
- label,
32
- onChange,
33
- value
34
- } = _ref;
25
+ const ButtonGroupControl = ({
26
+ buttonOptions,
27
+ buttonSmall,
28
+ className,
29
+ hideLabelFromVision,
30
+ label,
31
+ onChange,
32
+ value
33
+ }) => {
35
34
  const id = _.hooks.useUniqueId('button-group');
36
35
  return (0, _jsxRuntime.jsx)(_components.BaseControl, {
37
36
  label: label,
@@ -59,5 +58,4 @@ const ButtonGroupControl = _ref => {
59
58
  })
60
59
  });
61
60
  };
62
- var _default = ButtonGroupControl;
63
- exports.default = _default;
61
+ var _default = exports.default = ButtonGroupControl;
@@ -26,16 +26,15 @@ const __ = _i18n.__;
26
26
  /**
27
27
  * SelectControl with optgroup support
28
28
  */
29
- function GroupedSelectControl(_ref) {
30
- let {
31
- help,
32
- label,
33
- onChange,
34
- optgroups = [],
35
- className,
36
- hideLabelFromVision,
37
- ...props
38
- } = _ref;
29
+ function GroupedSelectControl({
30
+ help,
31
+ label,
32
+ onChange,
33
+ optgroups = [],
34
+ className,
35
+ hideLabelFromVision,
36
+ ...props
37
+ }) {
39
38
  const onChangeValue = event => {
40
39
  const {
41
40
  value
@@ -60,21 +59,18 @@ function GroupedSelectControl(_ref) {
60
59
  ...props,
61
60
  children: [(0, _jsxRuntime.jsx)("option", {
62
61
  value: "",
63
- children: __('-- Select --', 'newspack')
64
- }), optgroups.map((_ref2, optgroupIndex) => {
65
- let {
66
- label: optgroupLabel,
67
- options
68
- } = _ref2;
69
- return (0, _jsxRuntime.jsx)("optgroup", {
70
- label: optgroupLabel,
71
- children: options.map((option, optionIndex) => (0, _jsxRuntime.jsx)("option", {
72
- value: option.value,
73
- disabled: option.disabled,
74
- children: option.label
75
- }, `${option.label}-${option.value}-${optionIndex}`))
76
- }, optgroupIndex);
77
- })]
62
+ children: __('-- Select --', 'newspack-plugin')
63
+ }), optgroups.map(({
64
+ label: optgroupLabel,
65
+ options
66
+ }, optgroupIndex) => (0, _jsxRuntime.jsx)("optgroup", {
67
+ label: optgroupLabel,
68
+ children: options.map((option, optionIndex) => (0, _jsxRuntime.jsx)("option", {
69
+ value: option.value,
70
+ disabled: option.disabled,
71
+ children: option.label
72
+ }, `${option.label}-${option.value}-${optionIndex}`))
73
+ }, optgroupIndex))]
78
74
  }), (0, _jsxRuntime.jsx)("div", {
79
75
  className: "components-select-control__arrow-wrapper",
80
76
  children: (0, _jsxRuntime.jsx)(_icons.Icon, {
@@ -56,5 +56,4 @@ class SelectControl extends _element.Component {
56
56
  });
57
57
  }
58
58
  }
59
- var _default = SelectControl;
60
- exports.default = _default;
59
+ var _default = exports.default = SelectControl;
@@ -15,24 +15,25 @@ const __ = _i18n.__;
15
15
  /**
16
16
  * Internal dependencies.
17
17
  */
18
- const MinMaxSetting = _ref => {
19
- let {
20
- min,
21
- max,
22
- onChangeMin,
23
- onChangeMax,
24
- minPlaceholder,
25
- maxPlaceholder
26
- } = _ref;
27
- return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
18
+ const MinMaxSetting = ({
19
+ min,
20
+ max,
21
+ onChangeMin,
22
+ onChangeMax,
23
+ minPlaceholder,
24
+ maxPlaceholder,
25
+ ...props
26
+ }) => {
27
+ return (0, _jsxRuntime.jsxs)("div", {
28
+ ...props,
28
29
  children: [(0, _jsxRuntime.jsxs)("div", {
29
30
  className: "newspack-settings__min-max",
30
31
  children: [(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
31
32
  checked: min > 0,
32
33
  onChange: value => onChangeMin(value ? 1 : 0),
33
- label: __('Min', 'newspack')
34
+ label: __('Min', 'newspack-plugin')
34
35
  }), (0, _jsxRuntime.jsx)(_.TextControl, {
35
- "data-testid": "min-articles-input",
36
+ "data-testid": "min",
36
37
  type: "number",
37
38
  value: min,
38
39
  placeholder: minPlaceholder,
@@ -40,11 +41,13 @@ const MinMaxSetting = _ref => {
40
41
  })]
41
42
  }), (0, _jsxRuntime.jsxs)("div", {
42
43
  className: "newspack-settings__min-max",
44
+ "data-testid": "max",
43
45
  children: [(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
44
46
  checked: max > 0,
45
47
  onChange: value => onChangeMax(value ? min || 1 : 0),
46
- label: __('Max', 'newspack')
48
+ label: __('Max', 'newspack-plugin')
47
49
  }), (0, _jsxRuntime.jsx)(_.TextControl, {
50
+ "data-testid": "max",
48
51
  type: "number",
49
52
  value: max,
50
53
  placeholder: maxPlaceholder,
@@ -53,5 +56,4 @@ const MinMaxSetting = _ref => {
53
56
  })]
54
57
  });
55
58
  };
56
- var _default = MinMaxSetting;
57
- exports.default = _default;
59
+ var _default = exports.default = MinMaxSetting;
@@ -16,16 +16,15 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
16
16
  * Internal dependencies.
17
17
  */
18
18
 
19
- const SettingsCard = _ref => {
20
- let {
21
- children,
22
- className,
23
- columns,
24
- gutter,
25
- noBorder,
26
- rowGap,
27
- ...props
28
- } = _ref;
19
+ const SettingsCard = ({
20
+ children,
21
+ className,
22
+ columns,
23
+ gutter,
24
+ noBorder,
25
+ rowGap,
26
+ ...props
27
+ }) => {
29
28
  const classes = (0, _classnames.default)('newspack-settings__card', noBorder && 'newspack-settings__no-border', className);
30
29
  return (0, _jsxRuntime.jsx)(_.ActionCard, {
31
30
  ...props,
@@ -44,5 +43,4 @@ SettingsCard.defaultProps = {
44
43
  columns: 3,
45
44
  gutter: 32
46
45
  };
47
- var _default = SettingsCard;
48
- exports.default = _default;
46
+ var _default = exports.default = SettingsCard;
@@ -10,28 +10,24 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
10
  * Internal dependencies.
11
11
  */
12
12
 
13
- const SettingSection = _ref => {
14
- let {
15
- title,
16
- description,
17
- children
18
- } = _ref;
19
- return (0, _jsxRuntime.jsxs)(_.Grid, {
20
- columns: 1,
21
- gutter: 8,
22
- className: "newspack-settings__section",
23
- children: [(0, _jsxRuntime.jsxs)("div", {
24
- className: "newspack-settings__section__title",
25
- children: [(0, _jsxRuntime.jsx)("span", {
26
- children: title
27
- }), description && (0, _jsxRuntime.jsx)(_.InfoButton, {
28
- text: description
29
- })]
30
- }), (0, _jsxRuntime.jsx)("div", {
31
- className: "newspack-settings__section__content",
32
- children: children
13
+ const SettingSection = ({
14
+ title,
15
+ description,
16
+ children
17
+ }) => (0, _jsxRuntime.jsxs)(_.Grid, {
18
+ columns: 1,
19
+ gutter: 8,
20
+ className: "newspack-settings__section",
21
+ children: [(0, _jsxRuntime.jsxs)("div", {
22
+ className: "newspack-settings__section__title",
23
+ children: [(0, _jsxRuntime.jsx)("span", {
24
+ children: title
25
+ }), description && (0, _jsxRuntime.jsx)(_.InfoButton, {
26
+ text: description
33
27
  })]
34
- });
35
- };
36
- var _default = SettingSection;
37
- exports.default = _default;
28
+ }), (0, _jsxRuntime.jsx)("div", {
29
+ className: "newspack-settings__section__content",
30
+ children: children
31
+ })]
32
+ });
33
+ var _default = exports.default = SettingSection;
@@ -9,9 +9,8 @@ var _SettingsCard = _interopRequireDefault(require("./SettingsCard"));
9
9
  var _SettingsSection = _interopRequireDefault(require("./SettingsSection"));
10
10
  var _MinMaxSetting = _interopRequireDefault(require("./MinMaxSetting"));
11
11
  require("./style.scss");
12
- var _default = {
12
+ var _default = exports.default = {
13
13
  SettingsCard: _SettingsCard.default,
14
14
  SettingsSection: _SettingsSection.default,
15
15
  MinMaxSetting: _MinMaxSetting.default
16
- };
17
- exports.default = _default;
16
+ };
@@ -37,7 +37,8 @@
37
37
  }
38
38
  }
39
39
  &__content {
40
- > div {
40
+ > div,
41
+ .newspack-settings__min-max {
41
42
  margin: 0;
42
43
  display: flex;
43
44
  align-items: center;
@@ -47,6 +48,18 @@
47
48
  margin: 0;
48
49
  }
49
50
  }
51
+ .newspack-autocomplete-tokenfield,
52
+ .newspack-settings__min-max {
53
+ width: 100%;
54
+ }
55
+ .newspack-autocomplete-tokenfield {
56
+ display: block;
57
+ margin: 0;
58
+
59
+ label:empty {
60
+ display: none;
61
+ }
62
+ }
50
63
  .newspack-text-control,
51
64
  .newspack-checkbox-control {
52
65
  margin: 0 !important;
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = SortableNewsletterListControl;
8
+ var _icons = require("@wordpress/icons");
9
+ var _components = require("@wordpress/components");
10
+ var _i18n = require("@wordpress/i18n");
11
+ var _actionCard = _interopRequireDefault(require("../action-card"));
12
+ var _button = _interopRequireDefault(require("../button"));
13
+ require("./style.scss");
14
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
+ /**
16
+ * WordPress dependencies
17
+ */
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ const __ = _i18n.__;
22
+ function SortableNewsletterListControl({
23
+ lists,
24
+ selected = [],
25
+ onChange = () => {}
26
+ }) {
27
+ if (!Array.isArray(lists) && lists.errors) {
28
+ return (0, _jsxRuntime.jsx)(_components.Notice, {
29
+ status: "error",
30
+ isDismissible: false,
31
+ children: Object.values(lists.errors).join(', ')
32
+ });
33
+ }
34
+ const getList = id => lists.find(list => list.id === id);
35
+ const getAvailableLists = () => {
36
+ return lists.filter(list => list.active && !selected.find(({
37
+ id
38
+ }) => id === list.id));
39
+ };
40
+ return (0, _jsxRuntime.jsxs)("div", {
41
+ className: "newspack__newsletter-list-control",
42
+ children: [(0, _jsxRuntime.jsx)("div", {
43
+ className: "newspack__newsletter-list-control__selected",
44
+ children: selected.map(selectedList => {
45
+ const list = getList(selectedList.id);
46
+ if (!list) {
47
+ return null;
48
+ }
49
+ return (0, _jsxRuntime.jsx)(_actionCard.default, {
50
+ title: list.name,
51
+ description: () => (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
52
+ children: [(0, _jsxRuntime.jsx)("input", {
53
+ type: "checkbox",
54
+ checked: selectedList.checked,
55
+ onChange: () => {
56
+ const index = selected.findIndex(({
57
+ id
58
+ }) => id === selectedList.id);
59
+ const newSelected = [...selected];
60
+ newSelected[index].checked = !newSelected[index].checked;
61
+ onChange(newSelected);
62
+ }
63
+ }), __('Checked by default', 'newspack-plugin')]
64
+ }),
65
+ isSmall: true,
66
+ actionText: (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
67
+ children: (0, _jsxRuntime.jsx)(_button.default, {
68
+ onClick: () => onChange(selected.filter(({
69
+ id
70
+ }) => id !== selectedList.id)),
71
+ label: __('Remove', 'newspack-plugin'),
72
+ icon: _icons.trash
73
+ })
74
+ }),
75
+ children: selected.length > 1 && (0, _jsxRuntime.jsxs)("span", {
76
+ className: "newspack__newsletter-list-control__sort-handle",
77
+ children: [(0, _jsxRuntime.jsx)("button", {
78
+ onClick: () => {
79
+ const index = selected.findIndex(({
80
+ id
81
+ }) => id === selectedList.id);
82
+ if (index === 0) {
83
+ return;
84
+ }
85
+ const newSelected = [...selected];
86
+ newSelected.splice(index, 1);
87
+ newSelected.splice(index - 1, 0, selectedList);
88
+ onChange(newSelected);
89
+ },
90
+ className: selected.findIndex(({
91
+ id
92
+ }) => id === selectedList.id) === 0 ? 'disabled' : '',
93
+ children: (0, _jsxRuntime.jsx)(_icons.Icon, {
94
+ icon: _icons.chevronUp
95
+ })
96
+ }), (0, _jsxRuntime.jsx)("button", {
97
+ onClick: () => {
98
+ const index = selected.findIndex(({
99
+ id
100
+ }) => id === selectedList.id);
101
+ const newSelected = [...selected];
102
+ newSelected.splice(index, 1);
103
+ newSelected.splice(index + 1, 0, selectedList);
104
+ onChange(newSelected);
105
+ },
106
+ className: selected.findIndex(({
107
+ id
108
+ }) => id === selectedList.id) === selected.length - 1 ? 'disabled' : '',
109
+ children: (0, _jsxRuntime.jsx)(_icons.Icon, {
110
+ icon: _icons.chevronDown
111
+ })
112
+ })]
113
+ })
114
+ }, `selected-${selectedList.id}`);
115
+ })
116
+ }), getAvailableLists().length > 0 && (0, _jsxRuntime.jsxs)("p", {
117
+ className: "newspack__newsletter-list-control__lists",
118
+ children: [selected.length > 0 ? (0, _jsxRuntime.jsx)("strong", {
119
+ children: __('Add more lists:', 'newspack-plugin')
120
+ }) : (0, _jsxRuntime.jsx)("strong", {
121
+ children: __('Select lists:', 'newspack-plugin')
122
+ }), ' ', getAvailableLists().map(list => {
123
+ return (0, _jsxRuntime.jsx)(_button.default, {
124
+ variant: "secondary",
125
+ onClick: () => onChange([...selected, {
126
+ id: list.id,
127
+ checked: true
128
+ }]),
129
+ children: list.name
130
+ }, list.id);
131
+ })]
132
+ })]
133
+ });
134
+ }
@@ -0,0 +1,45 @@
1
+ .newspack__newsletter-list-control {
2
+ &__selected {
3
+ .newspack-card {
4
+ display: flex;
5
+ justify-content: center;
6
+ min-height: 40px;
7
+ flex-direction: row;
8
+ .newspack-action-card__region {
9
+ align-items: center;
10
+ display: flex;
11
+ justify-content: space-between;
12
+ margin: 0;
13
+ }
14
+ .newspack-action-card__region-top {
15
+ flex: 1;
16
+ order: 2;
17
+ }
18
+ .newspack-action-card__region-children {
19
+ padding: 12px;
20
+ }
21
+ }
22
+ }
23
+ &__sort-handle {
24
+ display: flex;
25
+ flex-direction: column;
26
+ justify-content: center;
27
+ align-items: center;
28
+ button {
29
+ background: transparent;
30
+ border: none;
31
+ margin: 0;
32
+ padding: 0;
33
+ height: 20px;
34
+ &.disabled {
35
+ cursor: default;
36
+ opacity: 0.3;
37
+ }
38
+ }
39
+ }
40
+ &__lists {
41
+ button {
42
+ margin-right: 0.5rem;
43
+ }
44
+ }
45
+ }
@@ -48,5 +48,4 @@ class StepsList extends _element.Component {
48
48
  });
49
49
  }
50
50
  }
51
- var _default = StepsList;
52
- exports.default = _default;
51
+ var _default = exports.default = StepsList;
@@ -52,5 +52,4 @@ class StepsListItem extends _element.Component {
52
52
  });
53
53
  }
54
54
  }
55
- var _default = StepsListItem;
56
- exports.default = _default;
55
+ var _default = exports.default = StepsListItem;
@@ -51,21 +51,21 @@ class StyleCard extends _element.Component {
51
51
  dangerouslySetInnerHTML: image
52
52
  }) : (0, _jsxRuntime.jsx)("img", {
53
53
  src: image,
54
- alt: cardTitle + ' ' + __('Thumbnail', 'newspack')
54
+ alt: cardTitle + ' ' + __('Thumbnail', 'newspack-plugin')
55
55
  }), (0, _jsxRuntime.jsxs)("div", {
56
56
  className: "newspack-style-card__actions",
57
57
  children: [isActive ? (0, _jsxRuntime.jsx)("span", {
58
58
  className: "newspack-style-card__actions__badge",
59
- children: __('Selected', 'newspack')
59
+ children: __('Selected', 'newspack-plugin')
60
60
  }) : (0, _jsxRuntime.jsx)(_components.Button, {
61
61
  variant: "link",
62
62
  onClick: onClick,
63
- "aria-label": ariaLabel ? ariaLabel : __('Select', 'newspack') + ' ' + cardTitle,
63
+ "aria-label": ariaLabel ? ariaLabel : __('Select', 'newspack-plugin') + ' ' + cardTitle,
64
64
  tabIndex: "0",
65
- children: __('Select', 'newspack')
65
+ children: __('Select', 'newspack-plugin')
66
66
  }), url && (0, _jsxRuntime.jsx)(_.WebPreview, {
67
67
  url: url,
68
- label: __('View Demo', 'newspack'),
68
+ label: __('View Demo', 'newspack-plugin'),
69
69
  variant: "link"
70
70
  })]
71
71
  })]
@@ -76,5 +76,4 @@ class StyleCard extends _element.Component {
76
76
  });
77
77
  }
78
78
  }
79
- var _default = StyleCard;
80
- exports.default = _default;
79
+ var _default = exports.default = StyleCard;
@@ -15,8 +15,20 @@
15
15
  }
16
16
  }
17
17
 
18
- // Checkbox Icon
18
+ // Checkboxes
19
+ .newspack-checkbox-control {
20
+ margin-top: 0 !important;
21
+ .components-checkbox-control__label {
22
+ font-weight: 600;
23
+ }
24
+
25
+ .components-base-control__help {
26
+ margin-left: 32px;
27
+ margin-top: 0;
28
+ }
29
+ }
19
30
 
31
+ // Checkbox Icon
20
32
  .newspack-checkbox-icon {
21
33
  background: white;
22
34
  border-radius: 50%;
@@ -22,13 +22,12 @@ const {
22
22
  NavLink,
23
23
  useHistory
24
24
  } = _router.default;
25
- const TabbedNavigation = _ref => {
26
- let {
27
- items,
28
- className,
29
- disableUpcoming,
30
- children = null
31
- } = _ref;
25
+ const TabbedNavigation = ({
26
+ items,
27
+ className,
28
+ disableUpcoming,
29
+ children = null
30
+ }) => {
32
31
  const displayedItems = items.filter(item => !item.isHiddenInTabbedNavigation);
33
32
  const {
34
33
  location
@@ -40,14 +39,13 @@ const TabbedNavigation = _ref => {
40
39
  children: displayedItems.map((item, index) => (0, _jsxRuntime.jsx)("li", {
41
40
  children: (0, _jsxRuntime.jsx)(NavLink, {
42
41
  to: item.path,
43
- isActive: (match, _ref2) => {
44
- let {
45
- pathname
46
- } = _ref2;
42
+ isActive: (match, {
43
+ pathname
44
+ }) => {
47
45
  if (item.activeTabPaths) {
48
46
  return item.activeTabPaths.includes(pathname);
49
47
  }
50
- return match;
48
+ return pathname === item.path;
51
49
  },
52
50
  exact: true,
53
51
  activeClassName: 'selected',
@@ -60,5 +58,4 @@ const TabbedNavigation = _ref => {
60
58
  }), children]
61
59
  });
62
60
  };
63
- var _default = TabbedNavigation;
64
- exports.default = _default;
61
+ var _default = exports.default = TabbedNavigation;