newspack-components 2.2.0 → 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 (197) 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/shared/js/button-props.js +3 -1
  120. package/shared/scss/_colors.scss +15 -0
  121. package/shared/scss/_mixins.scss +12 -0
  122. package/src/autocomplete-tokenfield/index.js +48 -15
  123. package/src/autocomplete-tokenfield/style.scss +11 -5
  124. package/src/autocomplete-with-suggestions/index.js +17 -22
  125. package/src/autocomplete-with-suggestions/style.scss +1 -9
  126. package/src/button/{index.js → index.tsx} +12 -5
  127. package/src/consts.js +0 -2
  128. package/src/footer/index.js +7 -7
  129. package/src/grid/index.tsx +34 -0
  130. package/src/handoff/index.js +7 -6
  131. package/src/hooks/{index.js → index.ts} +1 -1
  132. package/src/hooks/{usePrompt.js → usePrompt.ts} +4 -8
  133. package/src/image-upload/index.js +4 -4
  134. package/src/index.js +0 -2
  135. package/src/notice/index.js +1 -1
  136. package/src/patrons-logo/index.js +4 -1
  137. package/src/plugin-installer/index.js +7 -7
  138. package/src/plugin-settings/index.js +1 -1
  139. package/src/plugin-toggle/index.js +7 -5
  140. package/src/position-control/index.js +13 -13
  141. package/src/section-header/index.js +3 -3
  142. package/src/section-header/style.scss +4 -0
  143. package/src/select-control/GroupedSelectControl.js +1 -1
  144. package/src/settings/MinMaxSetting.js +8 -6
  145. package/src/settings/style.scss +14 -1
  146. package/src/sortable-newsletter-list-control/index.js +137 -0
  147. package/src/sortable-newsletter-list-control/style.scss +45 -0
  148. package/src/style-card/index.js +11 -5
  149. package/src/style.scss +13 -1
  150. package/src/tabbed-navigation/index.js +1 -1
  151. package/src/text-control/index.tsx +65 -0
  152. package/src/web-preview/index.js +6 -6
  153. package/src/with-wizard/index.js +4 -4
  154. package/src/with-wizard-screen/index.js +1 -1
  155. package/src/wizard/components/WizardError.js +1 -1
  156. package/src/wizard/index.js +3 -3
  157. package/src/wizard/store/index.js +9 -2
  158. package/dist/cjs/accordion/index.js +0 -46
  159. package/dist/cjs/accordion/style.scss +0 -27
  160. package/dist/cjs/button-group/index.js +0 -57
  161. package/dist/cjs/button-group/style.scss +0 -73
  162. package/dist/cjs/checkbox-control/index.js +0 -63
  163. package/dist/cjs/checkbox-control/style.scss +0 -78
  164. package/dist/cjs/date-range-picker/index.js +0 -41
  165. package/dist/cjs/date-range-picker/style.scss +0 -148
  166. package/dist/cjs/preview-box/index.js +0 -36
  167. package/dist/cjs/preview-box/style.scss +0 -18
  168. package/dist/cjs/textarea-control/index.js +0 -54
  169. package/dist/cjs/textarea-control/style.scss +0 -76
  170. package/dist/cjs/toggle-control/index.js +0 -58
  171. package/dist/cjs/toggle-control/style.scss +0 -74
  172. package/dist/cjs/toggle-group/index.js +0 -71
  173. package/dist/cjs/toggle-group/style.scss +0 -28
  174. package/dist/cjs/wizard/style.scss +0 -148
  175. package/dist/esm/accordion/index.js +0 -38
  176. package/dist/esm/accordion/style.scss +0 -27
  177. package/dist/esm/button-group/index.js +0 -43
  178. package/dist/esm/button-group/style.scss +0 -73
  179. package/dist/esm/checkbox-control/index.js +0 -49
  180. package/dist/esm/checkbox-control/style.scss +0 -78
  181. package/dist/esm/date-range-picker/index.js +0 -32
  182. package/dist/esm/date-range-picker/style.scss +0 -148
  183. package/dist/esm/preview-box/index.js +0 -30
  184. package/dist/esm/preview-box/style.scss +0 -18
  185. package/dist/esm/textarea-control/index.js +0 -40
  186. package/dist/esm/textarea-control/style.scss +0 -76
  187. package/dist/esm/toggle-control/index.js +0 -44
  188. package/dist/esm/toggle-control/style.scss +0 -74
  189. package/dist/esm/toggle-group/index.js +0 -58
  190. package/dist/esm/toggle-group/style.scss +0 -28
  191. package/dist/esm/wizard/style.scss +0 -148
  192. package/src/accordion/index.js +0 -32
  193. package/src/accordion/style.scss +0 -27
  194. package/src/date-range-picker/index.js +0 -31
  195. package/src/date-range-picker/style.scss +0 -148
  196. package/src/grid/index.js +0 -44
  197. package/src/text-control/index.js +0 -56
@@ -52,10 +52,11 @@ class Handoff extends Component {
52
52
  textForPlugin = pluginInfo => {
53
53
  const defaults = {
54
54
  modalBody: null,
55
- modalTitle: pluginInfo.Name && `${ __( 'Manage', 'newspack' ) } ${ pluginInfo.Name }`,
56
- primaryButton: pluginInfo.Name && `${ __( 'Manage', 'newspack' ) } ${ pluginInfo.Name }`,
57
- primaryModalButton: __( 'Manage', 'newspack' ),
58
- dismissModalButton: __( 'Dismiss', 'newspack' ),
55
+ modalTitle: pluginInfo.Name && `${ __( 'Manage', 'newspack-plugin' ) } ${ pluginInfo.Name }`,
56
+ primaryButton:
57
+ pluginInfo.Name && `${ __( 'Manage', 'newspack-plugin' ) } ${ pluginInfo.Name }`,
58
+ primaryModalButton: __( 'Manage', 'newspack-plugin' ),
59
+ dismissModalButton: __( 'Dismiss', 'newspack-plugin' ),
59
60
  };
60
61
  return assign( defaults, this.props );
61
62
  };
@@ -115,7 +116,7 @@ class Handoff extends Component {
115
116
  ) }
116
117
  { Name && 'active' !== Status && (
117
118
  <Button className={ classes } variant="secondary" disabled { ...otherProps }>
118
- { Name + __( ' not installed', 'newspack' ) }
119
+ { Name + __( ' not installed', 'newspack-plugin' ) }
119
120
  </Button>
120
121
  ) }
121
122
  { ! Name && (
@@ -126,7 +127,7 @@ class Handoff extends Component {
126
127
  >
127
128
  <Fragment>
128
129
  { ! compact && <Waiting isLeft /> }
129
- { __( 'Retrieving Plugin Info', 'newspack' ) }
130
+ { __( 'Retrieving Plugin Info', 'newspack-plugin' ) }
130
131
  </Fragment>
131
132
  </Button>
132
133
  ) }
@@ -7,7 +7,7 @@ import usePrompt from './usePrompt';
7
7
  import useObjectState from './useObjectState';
8
8
  import useOnClickOutside from './useOnClickOutside';
9
9
 
10
- const useUniqueId = prefix => {
10
+ const useUniqueId = ( prefix: string ) => {
11
11
  const id = useRef( `${ prefix }-${ Math.round( Math.random() * 99999 ) }` );
12
12
  return id.current;
13
13
  };
@@ -12,11 +12,11 @@ import Router from '../proxied-imports/router';
12
12
 
13
13
  const { useHistory } = Router;
14
14
 
15
- export default ( when, message ) => {
15
+ export default ( when: boolean, message: string ): ( () => void ) => {
16
16
  const history = useHistory();
17
17
  const self = useRef( null );
18
18
 
19
- const onWindowOrTabClose = event => {
19
+ const onWindowOrTabClose = ( event: Event | undefined ) => {
20
20
  if ( ! when ) {
21
21
  return;
22
22
  }
@@ -25,10 +25,6 @@ export default ( when, message ) => {
25
25
  event = window.event;
26
26
  }
27
27
 
28
- if ( event ) {
29
- event.returnValue = message;
30
- }
31
-
32
28
  return message;
33
29
  };
34
30
 
@@ -40,11 +36,11 @@ export default ( when, message ) => {
40
36
 
41
37
  return () => {
42
38
  if ( self.current ) {
43
- self.current();
39
+ ( self.current as () => void )();
44
40
  }
45
41
  window.removeEventListener( 'beforeunload', onWindowOrTabClose );
46
42
  };
47
43
  }, [ message, when ] );
48
44
 
49
- return self.current;
45
+ return self.current || ( () => {} );
50
46
  };
@@ -102,11 +102,11 @@ class ImageUpload extends Component {
102
102
  <img
103
103
  data-testid="image-upload"
104
104
  src={ image.url }
105
- alt={ __( 'Image preview', 'newspack' ) }
105
+ alt={ __( 'Image preview', 'newspack-plugin' ) }
106
106
  />
107
107
  <div className="newspack-image-upload__controls">
108
108
  <Button disabled={ disabled } onClick={ this.openModal } isLink>
109
- { __( 'Replace', 'newspack' ) }
109
+ { __( 'Replace', 'newspack-plugin' ) }
110
110
  </Button>
111
111
  <span className="sep" />
112
112
  <Button
@@ -115,13 +115,13 @@ class ImageUpload extends Component {
115
115
  isLink
116
116
  isDestructive
117
117
  >
118
- { __( 'Remove', 'newspack' ) }
118
+ { __( 'Remove', 'newspack-plugin' ) }
119
119
  </Button>
120
120
  </div>
121
121
  </>
122
122
  ) : (
123
123
  <Button disabled={ disabled } onClick={ this.openModal } isLink>
124
- { buttonLabel ? buttonLabel : __( 'Upload', 'newspack' ) }
124
+ { buttonLabel ? buttonLabel : __( 'Upload', 'newspack-plugin' ) }
125
125
  </Button>
126
126
  ) }
127
127
  </div>
package/src/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export { default as Accordion } from './accordion';
2
1
  export { default as ActionCard } from './action-card';
3
2
  export { default as AutocompleteTokenField } from './autocomplete-tokenfield';
4
3
  export { default as AutocompleteWithSuggestions } from './autocomplete-with-suggestions';
@@ -29,7 +28,6 @@ export { default as ProgressBar } from './progress-bar';
29
28
  export { default as RadioControl } from './radio-control';
30
29
  export { default as SectionHeader } from './section-header';
31
30
  export { default as SelectControl } from './select-control';
32
- export { default as DateRangePicker } from './date-range-picker';
33
31
  export { default as Settings } from './settings';
34
32
  export { default as StepsList } from './steps-list';
35
33
  export { default as StepsListItem } from './steps-list-item';
@@ -62,7 +62,7 @@ class Notice extends Component {
62
62
  { <Icon icon={ noticeIcon } /> }
63
63
  <div className="newspack-notice__content">
64
64
  { rawHTML ? <RawHTML>{ noticeText }</RawHTML> : noticeText }
65
- { debugMode && __( 'Debug Mode', 'newspack' ) }
65
+ { debugMode && __( 'Debug Mode', 'newspack-plugin' ) }
66
66
  { children || null }
67
67
  </div>
68
68
  </div>
@@ -21,7 +21,10 @@ class PatronsLogo extends Component {
21
21
  height="16"
22
22
  viewBox="0 0 438 32"
23
23
  className="patrons-logo"
24
- aria-label={ __( 'A project of WordPress.com and the Google News Initiative', 'newspack' ) }
24
+ aria-label={ __(
25
+ 'A project of WordPress.com and the Google News Initiative',
26
+ 'newspack-plugin'
27
+ ) }
25
28
  >
26
29
  <Path
27
30
  fillRule="evenodd"
@@ -170,8 +170,8 @@ class PluginInstaller extends Component {
170
170
  currentStatus === 'active' || currentStatus === 'inactive';
171
171
 
172
172
  const buttonText = currentPluginStatuses.every( pluginInstalled )
173
- ? __( 'Activate', 'newspack' )
174
- : __( 'Install', 'newspack' );
173
+ ? __( 'Activate', 'newspack-plugin' )
174
+ : __( 'Install', 'newspack-plugin' );
175
175
 
176
176
  const needsInstall = slugs.some( slug => {
177
177
  const plugin = pluginInfo[ slug ];
@@ -183,7 +183,7 @@ class PluginInstaller extends Component {
183
183
  { ( ! pluginInfo || ! Object.keys( pluginInfo ).length ) && (
184
184
  <div className="newspack-plugin-installer_is-waiting">
185
185
  <Waiting isLeft />
186
- { __( 'Retrieving plugin information…' ) }
186
+ { __( 'Retrieving plugin information…', 'newspack-plugin' ) }
187
187
  </div>
188
188
  ) }
189
189
  { pluginInfo &&
@@ -202,8 +202,8 @@ class PluginInstaller extends Component {
202
202
  actionText = (
203
203
  <span className="newspack-plugin-installer__status">
204
204
  { isAtomic
205
- ? __( 'Contact Newspack support to install', 'newspack' )
206
- : __( 'Plugin must be installed manually', 'newspack' ) }
205
+ ? __( 'Contact Newspack support to install', 'newspack-plugin' )
206
+ : __( 'Plugin must be installed manually', 'newspack-plugin' ) }
207
207
  <span className="newspack-checkbox-icon" />
208
208
  </span>
209
209
  );
@@ -217,14 +217,14 @@ class PluginInstaller extends Component {
217
217
  } else if ( Status === 'inactive' ) {
218
218
  actionText = (
219
219
  <span className="newspack-plugin-installer__status">
220
- { __( 'Activate', 'newspack' ) }
220
+ { __( 'Activate', 'newspack-plugin' ) }
221
221
  <span className="newspack-checkbox-icon" />
222
222
  </span>
223
223
  );
224
224
  } else if ( Status === 'active' ) {
225
225
  actionText = (
226
226
  <span className="newspack-plugin-installer__status">
227
- { __( 'Installed', 'newspack' ) }
227
+ { __( 'Installed', 'newspack-plugin' ) }
228
228
  <span className="newspack-checkbox-icon newspack-checkbox-icon--checked">
229
229
  <Icon icon={ check } />
230
230
  </span>
@@ -205,7 +205,7 @@ class PluginSettings extends Component {
205
205
  }
206
206
 
207
207
  PluginSettings.defaultProps = {
208
- title: __( 'General Settings', 'newspack' ),
208
+ title: __( 'General Settings', 'newspack-plugin' ),
209
209
  };
210
210
 
211
211
  PluginSettings.Section = SettingsSection;
@@ -67,7 +67,9 @@ class PluginToggle extends Component {
67
67
  ...pluginInfo,
68
68
  [ plugin ]: {
69
69
  ...pluginInfo[ plugin ],
70
- error: e.message || __( 'There was an error managing this plugin.', 'newspack' ),
70
+ error:
71
+ e.message ||
72
+ __( 'There was an error managing this plugin.', 'newspack-plugin' ),
71
73
  },
72
74
  },
73
75
  } );
@@ -148,21 +150,21 @@ class PluginToggle extends Component {
148
150
  if ( 'configure' === inFlight ) {
149
151
  return (
150
152
  <Fragment>
151
- { __( 'Installing…', 'newspack' ) } <Waiting isRight />
153
+ { __( 'Installing…', 'newspack-plugin' ) } <Waiting isRight />
152
154
  </Fragment>
153
155
  );
154
156
  }
155
157
  if ( 'deactivate' === inFlight ) {
156
158
  return (
157
159
  <Fragment>
158
- { __( 'Deactivating…', 'newspack' ) } <Waiting isRight />
160
+ { __( 'Deactivating…', 'newspack-plugin' ) } <Waiting isRight />
159
161
  </Fragment>
160
162
  );
161
163
  }
162
164
  if ( ! name ) {
163
165
  return (
164
166
  <Fragment>
165
- { __( 'Loading…', 'newspack' ) } <Waiting isRight />
167
+ { __( 'Loading…', 'newspack-plugin' ) } <Waiting isRight />
166
168
  </Fragment>
167
169
  );
168
170
  }
@@ -171,7 +173,7 @@ class PluginToggle extends Component {
171
173
  return null;
172
174
  }
173
175
  if ( href || editPath ) {
174
- return actionText ? actionText : __( 'Configure', 'newspack' );
176
+ return actionText ? actionText : __( 'Configure', 'newspack-plugin' );
175
177
  }
176
178
  };
177
179
 
@@ -32,70 +32,70 @@ export default function PositionControl( {
32
32
  {
33
33
  value: 'top',
34
34
  /* translators: Overlay Position */
35
- label: __( 'Top', 'newspack' ),
35
+ label: __( 'Top', 'newspack-plugin' ),
36
36
  },
37
37
  {
38
38
  value: 'center',
39
39
  /* translators: Overlay Position */
40
- label: __( 'Center', 'newspack' ),
40
+ label: __( 'Center', 'newspack-plugin' ),
41
41
  },
42
42
  {
43
43
  value: 'bottom',
44
44
  /* translators: Overlay Position */
45
- label: __( 'Bottom', 'newspack' ),
45
+ label: __( 'Bottom', 'newspack-plugin' ),
46
46
  },
47
47
  ]
48
48
  : [
49
49
  {
50
50
  value: 'top_left',
51
51
  /* translators: Overlay Position */
52
- label: __( 'Top Left', 'newspack' ),
52
+ label: __( 'Top Left', 'newspack-plugin' ),
53
53
  },
54
54
  {
55
55
  value: 'top',
56
56
  /* translators: Overlay Position */
57
- label: __( 'Top Center', 'newspack' ),
57
+ label: __( 'Top Center', 'newspack-plugin' ),
58
58
  },
59
59
  {
60
60
  value: 'top_right',
61
61
  /* translators: Overlay Position */
62
- label: __( 'Top Right', 'newspack' ),
62
+ label: __( 'Top Right', 'newspack-plugin' ),
63
63
  },
64
64
  {
65
65
  value: 'center_left',
66
66
  /* translators: Overlay Position */
67
- label: __( 'Center Left', 'newspack' ),
67
+ label: __( 'Center Left', 'newspack-plugin' ),
68
68
  },
69
69
  {
70
70
  value: 'center',
71
71
  /* translators: Overlay Position */
72
- label: __( 'Center', 'newspack' ),
72
+ label: __( 'Center', 'newspack-plugin' ),
73
73
  },
74
74
  {
75
75
  value: 'center_right',
76
76
  /* translators: Overlay Position */
77
- label: __( 'Center Right', 'newspack' ),
77
+ label: __( 'Center Right', 'newspack-plugin' ),
78
78
  },
79
79
  {
80
80
  value: 'bottom_left',
81
81
  /* translators: Overlay Position */
82
- label: __( 'Bottom Left', 'newspack' ),
82
+ label: __( 'Bottom Left', 'newspack-plugin' ),
83
83
  },
84
84
  {
85
85
  value: 'bottom',
86
86
  /* translators: Overlay Position */
87
- label: __( 'Bottom Center', 'newspack' ),
87
+ label: __( 'Bottom Center', 'newspack-plugin' ),
88
88
  },
89
89
  {
90
90
  value: 'bottom_right',
91
91
  /* translators: Overlay Position */
92
- label: __( 'Bottom Right', 'newspack' ),
92
+ label: __( 'Bottom Right', 'newspack-plugin' ),
93
93
  },
94
94
  ];
95
95
  return (
96
96
  <div className={ classnames( 'newspack-position-placement-control', 'size-' + size ) }>
97
97
  <p className="components-base-control__label">{ label }</p>
98
- <ButtonGroup aria-label={ __( 'Select Position', 'newspack' ) } { ...props }>
98
+ <ButtonGroup aria-label={ __( 'Select Position', 'newspack-plugin' ) } { ...props }>
99
99
  { options.map( ( option, index ) => {
100
100
  return (
101
101
  <div
@@ -21,7 +21,7 @@ import classnames from 'classnames';
21
21
  const SectionHeader = ( {
22
22
  centered = false,
23
23
  className = null,
24
- description,
24
+ description = '',
25
25
  heading = 2,
26
26
  isWhite = false,
27
27
  noMargin = false,
@@ -52,11 +52,11 @@ const SectionHeader = ( {
52
52
  const HeadingTag = `h${ heading }`;
53
53
 
54
54
  return (
55
- <div id={ id } ref={ ref }>
55
+ <div id={ id } className="newspack-section-header__container" ref={ ref }>
56
56
  <Grid columns={ 1 } gutter={ 8 } className={ classes }>
57
57
  { typeof title === 'string' && <HeadingTag>{ title }</HeadingTag> }
58
58
  { typeof title === 'function' && <HeadingTag>{ title() }</HeadingTag> }
59
- { typeof description === 'string' && <p>{ description }</p> }
59
+ { description && typeof description === 'string' && <p>{ description }</p> }
60
60
  { typeof description === 'function' && <p>{ description() }</p> }
61
61
  </Grid>
62
62
  </div>
@@ -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,
@@ -52,7 +52,7 @@ export default function GroupedSelectControl( {
52
52
  aria-describedby={ !! help ? `${ id }__help` : undefined }
53
53
  { ...props }
54
54
  >
55
- <option value="">{ __( '-- Select --', 'newspack' ) }</option>
55
+ <option value="">{ __( '-- Select --', 'newspack-plugin' ) }</option>
56
56
  { optgroups.map( ( { label: optgroupLabel, options }, optgroupIndex ) => (
57
57
  <optgroup label={ optgroupLabel } key={ optgroupIndex }>
58
58
  { options.map( ( option, optionIndex ) => (
@@ -16,37 +16,39 @@ const MinMaxSetting = ( {
16
16
  onChangeMax,
17
17
  minPlaceholder,
18
18
  maxPlaceholder,
19
+ ...props
19
20
  } ) => {
20
21
  return (
21
- <>
22
+ <div { ...props }>
22
23
  <div className="newspack-settings__min-max">
23
24
  <CheckboxControl
24
25
  checked={ min > 0 }
25
26
  onChange={ value => onChangeMin( value ? 1 : 0 ) }
26
- label={ __( 'Min', 'newspack' ) }
27
+ label={ __( 'Min', 'newspack-plugin' ) }
27
28
  />
28
29
  <TextControl
29
- data-testid="min-articles-input"
30
+ data-testid="min"
30
31
  type="number"
31
32
  value={ min }
32
33
  placeholder={ minPlaceholder }
33
34
  onChange={ value => onChangeMin( value > 0 ? value : 0 ) }
34
35
  />
35
36
  </div>
36
- <div className="newspack-settings__min-max">
37
+ <div className="newspack-settings__min-max" data-testid="max">
37
38
  <CheckboxControl
38
39
  checked={ max > 0 }
39
40
  onChange={ value => onChangeMax( value ? min || 1 : 0 ) }
40
- label={ __( 'Max', 'newspack' ) }
41
+ label={ __( 'Max', 'newspack-plugin' ) }
41
42
  />
42
43
  <TextControl
44
+ data-testid="max"
43
45
  type="number"
44
46
  value={ max }
45
47
  placeholder={ maxPlaceholder }
46
48
  onChange={ value => onChangeMax( value > 0 ? value : 0 ) }
47
49
  />
48
50
  </div>
49
- </>
51
+ </div>
50
52
  );
51
53
  };
52
54
  export default MinMaxSetting;
@@ -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,137 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { Icon, chevronUp, chevronDown, trash } from '@wordpress/icons';
5
+ import { Notice } from '@wordpress/components';
6
+ import { __ } from '@wordpress/i18n';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import ActionCard from '../action-card';
12
+ import Button from '../button';
13
+ import './style.scss';
14
+
15
+ export default function SortableNewsletterListControl( {
16
+ lists,
17
+ selected = [],
18
+ onChange = () => {},
19
+ } ) {
20
+ if ( ! Array.isArray( lists ) && lists.errors ) {
21
+ return (
22
+ <Notice status="error" isDismissible={ false }>
23
+ { Object.values( lists.errors ).join( ', ' ) }
24
+ </Notice>
25
+ );
26
+ }
27
+ const getList = id => lists.find( list => list.id === id );
28
+ const getAvailableLists = () => {
29
+ return lists.filter( list => list.active && ! selected.find( ( { id } ) => id === list.id ) );
30
+ };
31
+ return (
32
+ <div className="newspack__newsletter-list-control">
33
+ <div className="newspack__newsletter-list-control__selected">
34
+ { selected.map( selectedList => {
35
+ const list = getList( selectedList.id );
36
+ if ( ! list ) {
37
+ return null;
38
+ }
39
+ return (
40
+ <ActionCard
41
+ key={ `selected-${ selectedList.id }` }
42
+ title={ list.name }
43
+ description={ () => (
44
+ <>
45
+ <input
46
+ type="checkbox"
47
+ checked={ selectedList.checked }
48
+ onChange={ () => {
49
+ const index = selected.findIndex( ( { id } ) => id === selectedList.id );
50
+ const newSelected = [ ...selected ];
51
+ newSelected[ index ].checked = ! newSelected[ index ].checked;
52
+ onChange( newSelected );
53
+ } }
54
+ />
55
+ { __( 'Checked by default', 'newspack-plugin' ) }
56
+ </>
57
+ ) }
58
+ isSmall
59
+ actionText={
60
+ <>
61
+ <Button
62
+ onClick={ () =>
63
+ onChange( selected.filter( ( { id } ) => id !== selectedList.id ) )
64
+ }
65
+ label={ __( 'Remove', 'newspack-plugin' ) }
66
+ icon={ trash }
67
+ />
68
+ </>
69
+ }
70
+ >
71
+ { selected.length > 1 && (
72
+ <span className="newspack__newsletter-list-control__sort-handle">
73
+ <button
74
+ onClick={ () => {
75
+ const index = selected.findIndex( ( { id } ) => id === selectedList.id );
76
+ if ( index === 0 ) {
77
+ return;
78
+ }
79
+ const newSelected = [ ...selected ];
80
+ newSelected.splice( index, 1 );
81
+ newSelected.splice( index - 1, 0, selectedList );
82
+ onChange( newSelected );
83
+ } }
84
+ className={
85
+ selected.findIndex( ( { id } ) => id === selectedList.id ) === 0
86
+ ? 'disabled'
87
+ : ''
88
+ }
89
+ >
90
+ <Icon icon={ chevronUp } />
91
+ </button>
92
+ <button
93
+ onClick={ () => {
94
+ const index = selected.findIndex( ( { id } ) => id === selectedList.id );
95
+ const newSelected = [ ...selected ];
96
+ newSelected.splice( index, 1 );
97
+ newSelected.splice( index + 1, 0, selectedList );
98
+ onChange( newSelected );
99
+ } }
100
+ className={
101
+ selected.findIndex( ( { id } ) => id === selectedList.id ) ===
102
+ selected.length - 1
103
+ ? 'disabled'
104
+ : ''
105
+ }
106
+ >
107
+ <Icon icon={ chevronDown } />
108
+ </button>
109
+ </span>
110
+ ) }
111
+ </ActionCard>
112
+ );
113
+ } ) }
114
+ </div>
115
+ { getAvailableLists().length > 0 && (
116
+ <p className="newspack__newsletter-list-control__lists">
117
+ { selected.length > 0 ? (
118
+ <strong>{ __( 'Add more lists:', 'newspack-plugin' ) }</strong>
119
+ ) : (
120
+ <strong>{ __( 'Select lists:', 'newspack-plugin' ) }</strong>
121
+ ) }{ ' ' }
122
+ { getAvailableLists().map( list => {
123
+ return (
124
+ <Button
125
+ key={ list.id }
126
+ variant="secondary"
127
+ onClick={ () => onChange( [ ...selected, { id: list.id, checked: true } ] ) }
128
+ >
129
+ { list.name }
130
+ </Button>
131
+ );
132
+ } ) }
133
+ </p>
134
+ ) }
135
+ </div>
136
+ );
137
+ }
@@ -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
+ }