newspack-components 3.0.0-alpha.2 → 3.0.0-alpha.4

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 (227) hide show
  1. package/babel.config.cjs.js +26 -0
  2. package/babel.config.js +1 -0
  3. package/copy-styles.js +10 -2
  4. package/dist/cjs/button/index.js +56 -0
  5. package/dist/cjs/grid/index.js +37 -0
  6. package/dist/cjs/hooks/index.js +25 -0
  7. package/dist/cjs/hooks/usePrompt.js +49 -0
  8. package/dist/cjs/text-control/index.js +64 -0
  9. package/dist/esm/accordion/index.js +42 -0
  10. package/dist/esm/accordion/style.scss +31 -0
  11. package/dist/esm/action-card/index.js +218 -0
  12. package/dist/esm/action-card/style.scss +483 -0
  13. package/dist/esm/autocomplete-tokenfield/index.js +261 -0
  14. package/dist/esm/autocomplete-tokenfield/style.scss +49 -0
  15. package/dist/esm/autocomplete-with-suggestions/index.js +274 -0
  16. package/dist/esm/autocomplete-with-suggestions/style.scss +163 -0
  17. package/dist/esm/button/index.js +48 -0
  18. package/dist/esm/button/style.scss +11 -0
  19. package/dist/esm/button-card/index.js +64 -0
  20. package/dist/esm/button-card/style.scss +180 -0
  21. package/dist/esm/card/index.js +43 -0
  22. package/dist/esm/card/style.scss +168 -0
  23. package/dist/esm/category-autocomplete/index.js +183 -0
  24. package/dist/esm/category-autocomplete/style.scss +34 -0
  25. package/dist/esm/color-picker/index.js +59 -0
  26. package/dist/esm/color-picker/style.scss +37 -0
  27. package/dist/esm/consts.js +1 -0
  28. package/dist/esm/custom-select-control/index.js +37 -0
  29. package/dist/esm/custom-select-control/style.scss +93 -0
  30. package/dist/esm/date-range-picker/index.js +31 -0
  31. package/dist/esm/date-range-picker/style.scss +148 -0
  32. package/dist/esm/footer/index.js +99 -0
  33. package/dist/esm/footer/style.scss +82 -0
  34. package/dist/esm/form-token-field/index.js +49 -0
  35. package/dist/esm/form-token-field/style.scss +37 -0
  36. package/dist/esm/global-notices/index.js +30 -0
  37. package/dist/esm/grid/index.js +29 -0
  38. package/dist/esm/grid/style.scss +166 -0
  39. package/dist/esm/handoff/index.js +175 -0
  40. package/dist/esm/handoff-message/index.js +47 -0
  41. package/dist/esm/hooks/index.js +17 -0
  42. package/dist/esm/hooks/useObjectState.js +30 -0
  43. package/dist/esm/hooks/useObjectState.test.js +82 -0
  44. package/dist/esm/hooks/useOnClickOutside.js +31 -0
  45. package/dist/esm/hooks/usePrompt.js +40 -0
  46. package/dist/esm/image-upload/index.js +140 -0
  47. package/dist/esm/image-upload/index.test.js +34 -0
  48. package/dist/esm/image-upload/style.scss +103 -0
  49. package/dist/esm/index.js +47 -0
  50. package/dist/esm/info-button/index.js +42 -0
  51. package/dist/esm/info-button/style.scss +18 -0
  52. package/dist/esm/modal/index.js +39 -0
  53. package/dist/esm/modal/style.scss +56 -0
  54. package/dist/esm/newspack-icon/index.js +50 -0
  55. package/dist/esm/newspack-icon/style.scss +26 -0
  56. package/dist/esm/newspack-logo/index.js +46 -0
  57. package/dist/esm/newspack-logo/style.scss +30 -0
  58. package/dist/esm/notice/index.js +65 -0
  59. package/dist/esm/notice/style.scss +111 -0
  60. package/dist/esm/patrons-logo/index.js +70 -0
  61. package/dist/esm/plugin-installer/index.js +289 -0
  62. package/dist/esm/plugin-installer/style.scss +72 -0
  63. package/dist/esm/plugin-settings/SettingsSection.js +133 -0
  64. package/dist/esm/plugin-settings/index.js +220 -0
  65. package/dist/esm/plugin-settings/style.scss +7 -0
  66. package/dist/esm/plugin-toggle/index.js +216 -0
  67. package/dist/esm/plugin-toggle/style.scss +20 -0
  68. package/dist/esm/popover/index.js +41 -0
  69. package/dist/esm/popover/style.scss +161 -0
  70. package/dist/esm/position-control/index.js +106 -0
  71. package/dist/esm/position-control/style.scss +66 -0
  72. package/dist/esm/progress-bar/index.js +68 -0
  73. package/dist/esm/progress-bar/index.test.js +108 -0
  74. package/dist/esm/progress-bar/style.scss +42 -0
  75. package/dist/esm/proxied-imports/router.js +8 -0
  76. package/dist/esm/radio-control/index.js +37 -0
  77. package/dist/esm/radio-control/style.scss +92 -0
  78. package/dist/esm/section-header/index.js +67 -0
  79. package/dist/esm/section-header/style.scss +45 -0
  80. package/dist/esm/select-control/ButtonGroupControl.js +53 -0
  81. package/dist/esm/select-control/GroupedSelectControl.js +78 -0
  82. package/dist/esm/select-control/index.js +51 -0
  83. package/dist/esm/select-control/style.scss +108 -0
  84. package/dist/esm/settings/MinMaxSetting.js +53 -0
  85. package/dist/esm/settings/SettingsCard.js +38 -0
  86. package/dist/esm/settings/SettingsSection.js +26 -0
  87. package/dist/esm/settings/index.js +9 -0
  88. package/dist/esm/settings/style.scss +119 -0
  89. package/dist/esm/sortable-newsletter-list-control/index.js +127 -0
  90. package/dist/esm/sortable-newsletter-list-control/style.scss +45 -0
  91. package/dist/esm/steps-list/index.js +43 -0
  92. package/dist/esm/steps-list/style.scss +11 -0
  93. package/dist/esm/steps-list-item/index.js +47 -0
  94. package/dist/esm/steps-list-item/style.scss +47 -0
  95. package/dist/esm/style-card/index.js +74 -0
  96. package/dist/esm/style-card/style.scss +94 -0
  97. package/dist/esm/style.scss +55 -0
  98. package/dist/esm/tabbed-navigation/index.js +53 -0
  99. package/dist/esm/tabbed-navigation/style.scss +86 -0
  100. package/dist/esm/text-control/index.js +56 -0
  101. package/dist/esm/text-control/style.scss +32 -0
  102. package/dist/esm/utils/index.js +29 -0
  103. package/dist/esm/waiting/index.js +44 -0
  104. package/dist/esm/waiting/style.scss +27 -0
  105. package/dist/esm/web-preview/index.js +183 -0
  106. package/dist/esm/web-preview/style.scss +155 -0
  107. package/dist/esm/with-wizard/index.js +320 -0
  108. package/dist/esm/with-wizard/style.scss +282 -0
  109. package/dist/esm/with-wizard-screen/index.js +109 -0
  110. package/dist/esm/with-wizard-screen/style.scss +160 -0
  111. package/dist/esm/wizard/components/WizardError.js +66 -0
  112. package/dist/esm/wizard/index.js +119 -0
  113. package/dist/esm/wizard/store/index.js +155 -0
  114. package/dist/esm/wizard/store/utils.js +14 -0
  115. package/package.json +8 -4
  116. package/dist/button/index.js +0 -51
  117. package/dist/button/index.tsx +0 -48
  118. package/dist/grid/index.js +0 -44
  119. package/dist/grid/index.tsx +0 -34
  120. package/dist/hooks/index.js +0 -29
  121. package/dist/hooks/index.ts +0 -15
  122. package/dist/hooks/usePrompt.js +0 -47
  123. package/dist/hooks/usePrompt.ts +0 -46
  124. package/dist/plugin-toggle/README.md +0 -53
  125. package/dist/text-control/index.js +0 -76
  126. package/dist/text-control/index.tsx +0 -71
  127. /package/dist/{accordion → cjs/accordion}/index.js +0 -0
  128. /package/dist/{accordion → cjs/accordion}/style.scss +0 -0
  129. /package/dist/{action-card → cjs/action-card}/index.js +0 -0
  130. /package/dist/{action-card → cjs/action-card}/style.scss +0 -0
  131. /package/dist/{autocomplete-tokenfield → cjs/autocomplete-tokenfield}/index.js +0 -0
  132. /package/dist/{autocomplete-tokenfield → cjs/autocomplete-tokenfield}/style.scss +0 -0
  133. /package/dist/{autocomplete-with-suggestions → cjs/autocomplete-with-suggestions}/index.js +0 -0
  134. /package/dist/{autocomplete-with-suggestions → cjs/autocomplete-with-suggestions}/style.scss +0 -0
  135. /package/dist/{button → cjs/button}/style.scss +0 -0
  136. /package/dist/{button-card → cjs/button-card}/index.js +0 -0
  137. /package/dist/{button-card → cjs/button-card}/style.scss +0 -0
  138. /package/dist/{card → cjs/card}/index.js +0 -0
  139. /package/dist/{card → cjs/card}/style.scss +0 -0
  140. /package/dist/{category-autocomplete → cjs/category-autocomplete}/index.js +0 -0
  141. /package/dist/{category-autocomplete → cjs/category-autocomplete}/style.scss +0 -0
  142. /package/dist/{color-picker → cjs/color-picker}/index.js +0 -0
  143. /package/dist/{color-picker → cjs/color-picker}/style.scss +0 -0
  144. /package/dist/{consts.js → cjs/consts.js} +0 -0
  145. /package/dist/{custom-select-control → cjs/custom-select-control}/index.js +0 -0
  146. /package/dist/{custom-select-control → cjs/custom-select-control}/style.scss +0 -0
  147. /package/dist/{date-range-picker → cjs/date-range-picker}/index.js +0 -0
  148. /package/dist/{date-range-picker → cjs/date-range-picker}/style.scss +0 -0
  149. /package/dist/{footer → cjs/footer}/index.js +0 -0
  150. /package/dist/{footer → cjs/footer}/style.scss +0 -0
  151. /package/dist/{form-token-field → cjs/form-token-field}/index.js +0 -0
  152. /package/dist/{form-token-field → cjs/form-token-field}/style.scss +0 -0
  153. /package/dist/{global-notices → cjs/global-notices}/index.js +0 -0
  154. /package/dist/{grid → cjs/grid}/style.scss +0 -0
  155. /package/dist/{handoff → cjs/handoff}/index.js +0 -0
  156. /package/dist/{handoff-message → cjs/handoff-message}/index.js +0 -0
  157. /package/dist/{hooks → cjs/hooks}/useObjectState.js +0 -0
  158. /package/dist/{hooks → cjs/hooks}/useObjectState.test.js +0 -0
  159. /package/dist/{hooks → cjs/hooks}/useOnClickOutside.js +0 -0
  160. /package/dist/{image-upload → cjs/image-upload}/index.js +0 -0
  161. /package/dist/{image-upload → cjs/image-upload}/index.test.js +0 -0
  162. /package/dist/{image-upload → cjs/image-upload}/style.scss +0 -0
  163. /package/dist/{index.js → cjs/index.js} +0 -0
  164. /package/dist/{info-button → cjs/info-button}/index.js +0 -0
  165. /package/dist/{info-button → cjs/info-button}/style.scss +0 -0
  166. /package/dist/{modal → cjs/modal}/index.js +0 -0
  167. /package/dist/{modal → cjs/modal}/style.scss +0 -0
  168. /package/dist/{newspack-icon → cjs/newspack-icon}/index.js +0 -0
  169. /package/dist/{newspack-icon → cjs/newspack-icon}/style.scss +0 -0
  170. /package/dist/{newspack-logo → cjs/newspack-logo}/index.js +0 -0
  171. /package/dist/{newspack-logo → cjs/newspack-logo}/style.scss +0 -0
  172. /package/dist/{notice → cjs/notice}/index.js +0 -0
  173. /package/dist/{notice → cjs/notice}/style.scss +0 -0
  174. /package/dist/{patrons-logo → cjs/patrons-logo}/index.js +0 -0
  175. /package/dist/{plugin-installer → cjs/plugin-installer}/index.js +0 -0
  176. /package/dist/{plugin-installer → cjs/plugin-installer}/style.scss +0 -0
  177. /package/dist/{plugin-settings → cjs/plugin-settings}/SettingsSection.js +0 -0
  178. /package/dist/{plugin-settings → cjs/plugin-settings}/index.js +0 -0
  179. /package/dist/{plugin-settings → cjs/plugin-settings}/style.scss +0 -0
  180. /package/dist/{plugin-toggle → cjs/plugin-toggle}/index.js +0 -0
  181. /package/dist/{plugin-toggle → cjs/plugin-toggle}/style.scss +0 -0
  182. /package/dist/{popover → cjs/popover}/index.js +0 -0
  183. /package/dist/{popover → cjs/popover}/style.scss +0 -0
  184. /package/dist/{position-control → cjs/position-control}/index.js +0 -0
  185. /package/dist/{position-control → cjs/position-control}/style.scss +0 -0
  186. /package/dist/{progress-bar → cjs/progress-bar}/index.js +0 -0
  187. /package/dist/{progress-bar → cjs/progress-bar}/index.test.js +0 -0
  188. /package/dist/{progress-bar → cjs/progress-bar}/style.scss +0 -0
  189. /package/dist/{proxied-imports → cjs/proxied-imports}/router.js +0 -0
  190. /package/dist/{radio-control → cjs/radio-control}/index.js +0 -0
  191. /package/dist/{radio-control → cjs/radio-control}/style.scss +0 -0
  192. /package/dist/{section-header → cjs/section-header}/index.js +0 -0
  193. /package/dist/{section-header → cjs/section-header}/style.scss +0 -0
  194. /package/dist/{select-control → cjs/select-control}/ButtonGroupControl.js +0 -0
  195. /package/dist/{select-control → cjs/select-control}/GroupedSelectControl.js +0 -0
  196. /package/dist/{select-control → cjs/select-control}/index.js +0 -0
  197. /package/dist/{select-control → cjs/select-control}/style.scss +0 -0
  198. /package/dist/{settings → cjs/settings}/MinMaxSetting.js +0 -0
  199. /package/dist/{settings → cjs/settings}/SettingsCard.js +0 -0
  200. /package/dist/{settings → cjs/settings}/SettingsSection.js +0 -0
  201. /package/dist/{settings → cjs/settings}/index.js +0 -0
  202. /package/dist/{settings → cjs/settings}/style.scss +0 -0
  203. /package/dist/{sortable-newsletter-list-control → cjs/sortable-newsletter-list-control}/index.js +0 -0
  204. /package/dist/{sortable-newsletter-list-control → cjs/sortable-newsletter-list-control}/style.scss +0 -0
  205. /package/dist/{steps-list → cjs/steps-list}/index.js +0 -0
  206. /package/dist/{steps-list → cjs/steps-list}/style.scss +0 -0
  207. /package/dist/{steps-list-item → cjs/steps-list-item}/index.js +0 -0
  208. /package/dist/{steps-list-item → cjs/steps-list-item}/style.scss +0 -0
  209. /package/dist/{style-card → cjs/style-card}/index.js +0 -0
  210. /package/dist/{style-card → cjs/style-card}/style.scss +0 -0
  211. /package/dist/{style.scss → cjs/style.scss} +0 -0
  212. /package/dist/{tabbed-navigation → cjs/tabbed-navigation}/index.js +0 -0
  213. /package/dist/{tabbed-navigation → cjs/tabbed-navigation}/style.scss +0 -0
  214. /package/dist/{text-control → cjs/text-control}/style.scss +0 -0
  215. /package/dist/{utils → cjs/utils}/index.js +0 -0
  216. /package/dist/{waiting → cjs/waiting}/index.js +0 -0
  217. /package/dist/{waiting → cjs/waiting}/style.scss +0 -0
  218. /package/dist/{web-preview → cjs/web-preview}/index.js +0 -0
  219. /package/dist/{web-preview → cjs/web-preview}/style.scss +0 -0
  220. /package/dist/{with-wizard → cjs/with-wizard}/index.js +0 -0
  221. /package/dist/{with-wizard → cjs/with-wizard}/style.scss +0 -0
  222. /package/dist/{with-wizard-screen → cjs/with-wizard-screen}/index.js +0 -0
  223. /package/dist/{with-wizard-screen → cjs/with-wizard-screen}/style.scss +0 -0
  224. /package/dist/{wizard → cjs/wizard}/components/WizardError.js +0 -0
  225. /package/dist/{wizard → cjs/wizard}/index.js +0 -0
  226. /package/dist/{wizard → cjs/wizard}/store/index.js +0 -0
  227. /package/dist/{wizard → cjs/wizard}/store/utils.js +0 -0
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Section Header
3
+ */
4
+
5
+ /**
6
+ * WordPress dependencies
7
+ */
8
+ import { useEffect, useRef } from '@wordpress/element';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import { Grid } from '..';
14
+ import './style.scss';
15
+
16
+ /**
17
+ * External dependencies
18
+ */
19
+ import classnames from 'classnames';
20
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
21
+ const SectionHeader = ({
22
+ centered = false,
23
+ className = null,
24
+ description = '',
25
+ heading = 2,
26
+ isWhite = false,
27
+ noMargin = false,
28
+ title,
29
+ id = null
30
+ }) => {
31
+ // If id is in the URL as a scrollTo param, scroll to it on render.
32
+ const ref = useRef();
33
+ useEffect(() => {
34
+ const params = new Proxy(new URLSearchParams(window.location.search), {
35
+ get: (searchParams, prop) => searchParams.get(prop)
36
+ });
37
+ const scrollToId = params.scrollTo;
38
+ if (scrollToId && scrollToId === id) {
39
+ // Let parent scroll action run before running this.
40
+ window.setTimeout(() => ref.current.scrollIntoView({
41
+ behavior: 'smooth'
42
+ }), 250);
43
+ }
44
+ }, []);
45
+ const classes = classnames('newspack-section-header', centered && 'newspack-section-header--is-centered', isWhite && 'newspack-section-header--is-white', noMargin && 'newspack-section-header--no-margin', className);
46
+ const HeadingTag = `h${heading}`;
47
+ return /*#__PURE__*/_jsx("div", {
48
+ id: id,
49
+ className: "newspack-section-header__container",
50
+ ref: ref,
51
+ children: /*#__PURE__*/_jsxs(Grid, {
52
+ columns: 1,
53
+ gutter: 8,
54
+ className: classes,
55
+ children: [typeof title === 'string' && /*#__PURE__*/_jsx(HeadingTag, {
56
+ children: title
57
+ }), typeof title === 'function' && /*#__PURE__*/_jsx(HeadingTag, {
58
+ children: title()
59
+ }), description && typeof description === 'string' && /*#__PURE__*/_jsx("p", {
60
+ children: description
61
+ }), typeof description === 'function' && /*#__PURE__*/_jsx("p", {
62
+ children: description()
63
+ })]
64
+ })
65
+ });
66
+ };
67
+ export default SectionHeader;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Section Header
3
+ */
4
+
5
+ @use "~@wordpress/base-styles/colors" as wp-colors;
6
+
7
+ .newspack-section-header {
8
+ margin: 64px 0 32px;
9
+
10
+ &__container:not(:first-child) {
11
+ margin-top: 48px;
12
+ }
13
+
14
+ &--no-margin,
15
+ h1,
16
+ h2,
17
+ h3,
18
+ h4,
19
+ h5,
20
+ h6 {
21
+ margin: 0 !important;
22
+ }
23
+
24
+ &--is-centered {
25
+ text-align: center;
26
+ }
27
+
28
+ &:not( #{&}--no-margin ) + *:not( #{&} ) {
29
+ margin-top: -16px !important;
30
+ }
31
+
32
+ &#{&}--is-white {
33
+ > * {
34
+ color: white;
35
+ }
36
+ }
37
+
38
+ p {
39
+ color: wp-colors.$gray-700;
40
+ }
41
+
42
+ .newspack-wizard__content &:first-child {
43
+ margin-top: 32px;
44
+ }
45
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { Icon } from '@wordpress/icons';
10
+ import { BaseControl, Button, ButtonGroup } from '@wordpress/components';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { hooks } from '..';
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ const ButtonGroupControl = ({
18
+ buttonOptions,
19
+ buttonSmall,
20
+ className,
21
+ hideLabelFromVision,
22
+ label,
23
+ onChange,
24
+ value
25
+ }) => {
26
+ const id = hooks.useUniqueId('button-group');
27
+ return /*#__PURE__*/_jsx(BaseControl, {
28
+ label: label,
29
+ hideLabelFromVision: hideLabelFromVision,
30
+ id: id.current,
31
+ className: classnames(className, 'components-select-control'),
32
+ children: /*#__PURE__*/_jsx(ButtonGroup, {
33
+ children: buttonOptions.map(option => {
34
+ const isSelected = value === option.value;
35
+ let Label = () => option.label;
36
+ if (option.icon) {
37
+ // eslint-disable-next-line react/display-name
38
+ Label = () => /*#__PURE__*/_jsx(Icon, {
39
+ icon: option.icon
40
+ });
41
+ }
42
+ return /*#__PURE__*/_jsx(Button, {
43
+ variant: isSelected ? 'primary' : null,
44
+ isPressed: isSelected,
45
+ onClick: () => onChange(option.value),
46
+ isSmall: buttonSmall,
47
+ children: /*#__PURE__*/_jsx(Label, {})
48
+ }, option.value);
49
+ })
50
+ })
51
+ });
52
+ };
53
+ export default ButtonGroupControl;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { BaseControl } from '@wordpress/components';
5
+ import { __ } from '@wordpress/i18n';
6
+ import { Icon, chevronDown } from '@wordpress/icons';
7
+
8
+ /**
9
+ * External dependencies
10
+ */
11
+ import classnames from 'classnames';
12
+ import find from 'lodash/find';
13
+ import some from 'lodash/some';
14
+
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+ import { hooks } from '..';
19
+
20
+ /**
21
+ * SelectControl with optgroup support
22
+ */
23
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
+ export default function GroupedSelectControl({
25
+ help,
26
+ label,
27
+ onChange,
28
+ optgroups = [],
29
+ className,
30
+ hideLabelFromVision,
31
+ ...props
32
+ }) {
33
+ const onChangeValue = event => {
34
+ const {
35
+ value
36
+ } = event.target;
37
+ const optgroup = find(optgroups, group => some(group.options, ['value', value]));
38
+ onChange(value, optgroup);
39
+ };
40
+ const id = hooks.useUniqueId('group-select');
41
+ return /*#__PURE__*/_jsx(BaseControl, {
42
+ label: label,
43
+ hideLabelFromVision: hideLabelFromVision,
44
+ id: id,
45
+ help: help,
46
+ className: classnames(className, 'components-select-control'),
47
+ children: /*#__PURE__*/_jsxs("div", {
48
+ className: "relative",
49
+ children: [/*#__PURE__*/_jsxs("select", {
50
+ id: id,
51
+ className: "components-select-control__input",
52
+ onChange: onChangeValue,
53
+ "aria-describedby": !!help ? `${id}__help` : undefined,
54
+ ...props,
55
+ children: [/*#__PURE__*/_jsx("option", {
56
+ value: "",
57
+ children: __('-- Select --', 'newspack-plugin')
58
+ }), optgroups.map(({
59
+ label: optgroupLabel,
60
+ options
61
+ }, optgroupIndex) => /*#__PURE__*/_jsx("optgroup", {
62
+ label: optgroupLabel,
63
+ children: options.map((option, optionIndex) => /*#__PURE__*/_jsx("option", {
64
+ value: option.value,
65
+ disabled: option.disabled,
66
+ children: option.label
67
+ }, `${option.label}-${option.value}-${optionIndex}`))
68
+ }, optgroupIndex))]
69
+ }), /*#__PURE__*/_jsx("div", {
70
+ className: "components-select-control__arrow-wrapper",
71
+ children: /*#__PURE__*/_jsx(Icon, {
72
+ icon: chevronDown,
73
+ size: 18
74
+ })
75
+ })]
76
+ })
77
+ });
78
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Select Control
3
+ */
4
+
5
+ /**
6
+ * WordPress dependencies
7
+ */
8
+ import { SelectControl as BaseComponent } from '@wordpress/components';
9
+ import { Component } from '@wordpress/element';
10
+
11
+ /**
12
+ * External dependencies
13
+ */
14
+ import classNames from 'classnames';
15
+
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+ import './style.scss';
20
+ import GroupedSelectControl from './GroupedSelectControl';
21
+ import ButtonGroupControl from './ButtonGroupControl';
22
+ import { jsx as _jsx } from "react/jsx-runtime";
23
+ class SelectControl extends Component {
24
+ /**
25
+ * Render.
26
+ */
27
+ render() {
28
+ const {
29
+ className,
30
+ optgroups,
31
+ buttonOptions,
32
+ buttonSmall,
33
+ ...otherProps
34
+ } = this.props;
35
+ const classes = classNames('newspack-select-control', optgroups && 'newspack-grouped-select-control', buttonOptions && 'newspack-buttons-select-control', className);
36
+ return /*#__PURE__*/_jsx("div", {
37
+ className: classes,
38
+ children: optgroups ? /*#__PURE__*/_jsx(GroupedSelectControl, {
39
+ optgroups: optgroups,
40
+ ...otherProps
41
+ }) : buttonOptions ? /*#__PURE__*/_jsx(ButtonGroupControl, {
42
+ buttonOptions: buttonOptions,
43
+ buttonSmall: buttonSmall,
44
+ ...otherProps
45
+ }) : /*#__PURE__*/_jsx(BaseComponent, {
46
+ ...otherProps
47
+ })
48
+ });
49
+ }
50
+ }
51
+ export default SelectControl;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Select Control
3
+ */
4
+
5
+ @use "~@wordpress/base-styles/colors" as wp-colors;
6
+
7
+ .components-select-control {
8
+ &__input {
9
+ max-width: 100% !important;
10
+
11
+ &[multiple] {
12
+ height: auto !important;
13
+ min-height: 70px !important;
14
+ padding: 0 !important;
15
+
16
+ + .components-input-control__suffix {
17
+ display: none;
18
+ }
19
+
20
+ option {
21
+ min-height: 1.4em;
22
+ padding: 8px;
23
+
24
+ &:checked {
25
+ background: var(--wp-admin-theme-color);
26
+ color: white;
27
+ }
28
+ }
29
+ }
30
+ }
31
+
32
+ .components-base-control__field {
33
+ width: 100%;
34
+ }
35
+
36
+ .components-input-control__label {
37
+ line-height: inherit;
38
+ }
39
+ }
40
+
41
+ // Grouped
42
+
43
+ .newspack-grouped-select-control {
44
+ position: relative;
45
+
46
+ .components-select-control {
47
+ &__input {
48
+ appearance: none;
49
+ background: transparent;
50
+ border: 1px solid wp-colors.$gray-700;
51
+ border-radius: 2px;
52
+ box-shadow: none !important;
53
+ box-sizing: border-box;
54
+ display: block;
55
+ font-size: inherit;
56
+ margin: 0;
57
+ max-width: 100%;
58
+ outline: none;
59
+ padding: 0 24px 0 7px;
60
+ width: 100%;
61
+
62
+ &:hover {
63
+ color: inherit;
64
+ }
65
+
66
+ &:focus {
67
+ border-color: var(--wp-admin-theme-color-darker-10) !important;
68
+ box-shadow: inset 0 0 0 1px var(--wp-admin-theme-color-darker-10) !important;
69
+ color: inherit;
70
+ }
71
+ }
72
+
73
+ &__arrow-wrapper {
74
+ align-items: center;
75
+ display: flex;
76
+ height: 24px;
77
+ justify-content: center;
78
+ margin-top: -12px;
79
+ position: absolute;
80
+ right: 1px;
81
+ top: 50%;
82
+ width: 24px;
83
+ }
84
+ }
85
+ }
86
+
87
+ // Buttons
88
+
89
+ .newspack-buttons-select-control {
90
+ .components-base-control__label {
91
+ display: inline-flex;
92
+ margin-bottom: 8px;
93
+ }
94
+
95
+ .components-button-group {
96
+ display: flex;
97
+ }
98
+
99
+ &.icon-only {
100
+ .components-button {
101
+ align-items: center;
102
+ height: 36px;
103
+ justify-content: center;
104
+ padding: 0 !important;
105
+ width: 36px;
106
+ }
107
+ }
108
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * WordPress dependencies.
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { CheckboxControl } from '@wordpress/components';
6
+
7
+ /**
8
+ * Internal dependencies.
9
+ */
10
+ import { TextControl } from '../';
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ const MinMaxSetting = ({
13
+ min,
14
+ max,
15
+ onChangeMin,
16
+ onChangeMax,
17
+ minPlaceholder,
18
+ maxPlaceholder,
19
+ ...props
20
+ }) => {
21
+ return /*#__PURE__*/_jsxs("div", {
22
+ ...props,
23
+ children: [/*#__PURE__*/_jsxs("div", {
24
+ className: "newspack-settings__min-max",
25
+ children: [/*#__PURE__*/_jsx(CheckboxControl, {
26
+ checked: min > 0,
27
+ onChange: value => onChangeMin(value ? 1 : 0),
28
+ label: __('Min', 'newspack-plugin')
29
+ }), /*#__PURE__*/_jsx(TextControl, {
30
+ "data-testid": "min",
31
+ type: "number",
32
+ value: min,
33
+ placeholder: minPlaceholder,
34
+ onChange: value => onChangeMin(value > 0 ? value : 0)
35
+ })]
36
+ }), /*#__PURE__*/_jsxs("div", {
37
+ className: "newspack-settings__min-max",
38
+ "data-testid": "max",
39
+ children: [/*#__PURE__*/_jsx(CheckboxControl, {
40
+ checked: max > 0,
41
+ onChange: value => onChangeMax(value ? min || 1 : 0),
42
+ label: __('Max', 'newspack-plugin')
43
+ }), /*#__PURE__*/_jsx(TextControl, {
44
+ "data-testid": "max",
45
+ type: "number",
46
+ value: max,
47
+ placeholder: maxPlaceholder,
48
+ onChange: value => onChangeMax(value > 0 ? value : 0)
49
+ })]
50
+ })]
51
+ });
52
+ };
53
+ export default MinMaxSetting;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * External dependencies.
3
+ */
4
+ import classnames from 'classnames';
5
+
6
+ /**
7
+ * Internal dependencies.
8
+ */
9
+ import { Grid, ActionCard } from '../';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ const SettingsCard = ({
12
+ children,
13
+ className,
14
+ columns,
15
+ gutter,
16
+ noBorder,
17
+ rowGap,
18
+ ...props
19
+ }) => {
20
+ const classes = classnames('newspack-settings__card', noBorder && 'newspack-settings__no-border', className);
21
+ return /*#__PURE__*/_jsx(ActionCard, {
22
+ ...props,
23
+ className: classes,
24
+ notificationLevel: "info",
25
+ noBorder: noBorder,
26
+ children: /*#__PURE__*/_jsx(Grid, {
27
+ columns: columns,
28
+ gutter: gutter,
29
+ rowGap: rowGap,
30
+ children: children
31
+ })
32
+ });
33
+ };
34
+ SettingsCard.defaultProps = {
35
+ columns: 3,
36
+ gutter: 32
37
+ };
38
+ export default SettingsCard;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Internal dependencies.
3
+ */
4
+ import { Grid, InfoButton } from '../';
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ const SettingSection = ({
7
+ title,
8
+ description,
9
+ children
10
+ }) => /*#__PURE__*/_jsxs(Grid, {
11
+ columns: 1,
12
+ gutter: 8,
13
+ className: "newspack-settings__section",
14
+ children: [/*#__PURE__*/_jsxs("div", {
15
+ className: "newspack-settings__section__title",
16
+ children: [/*#__PURE__*/_jsx("span", {
17
+ children: title
18
+ }), description && /*#__PURE__*/_jsx(InfoButton, {
19
+ text: description
20
+ })]
21
+ }), /*#__PURE__*/_jsx("div", {
22
+ className: "newspack-settings__section__content",
23
+ children: children
24
+ })]
25
+ });
26
+ export default SettingSection;
@@ -0,0 +1,9 @@
1
+ import SettingsCard from './SettingsCard';
2
+ import SettingsSection from './SettingsSection';
3
+ import MinMaxSetting from './MinMaxSetting';
4
+ import './style.scss';
5
+ export default {
6
+ SettingsCard,
7
+ SettingsSection,
8
+ MinMaxSetting
9
+ };
@@ -0,0 +1,119 @@
1
+ .newspack-settings {
2
+ &__card {
3
+ &.newspack-card.newspack-action-card {
4
+ .newspack-action-card__region-top {
5
+ padding: 32px 32px 16px;
6
+ }
7
+
8
+ .newspack-action-card__region-children {
9
+ padding: 0 32px 32px;
10
+
11
+ > .newspack-grid {
12
+ margin: 0;
13
+ }
14
+ }
15
+
16
+ .newspack-action-card__notification {
17
+ padding-bottom: 16px;
18
+ }
19
+ }
20
+
21
+ .newspack-form-token-field {
22
+ margin: 0;
23
+
24
+ .components-form-token-field {
25
+ width: 100%;
26
+ }
27
+ }
28
+
29
+ .newspack-settings__section {
30
+ &__title {
31
+ align-items: center;
32
+ display: flex;
33
+ margin: 0;
34
+
35
+ span {
36
+ line-height: 24px;
37
+ }
38
+ }
39
+ &__content {
40
+ > div,
41
+ .newspack-settings__min-max {
42
+ margin: 0;
43
+ display: flex;
44
+ align-items: center;
45
+ justify-content: space-between;
46
+ flex-wrap: wrap;
47
+ > *:not([class*="help"], [class*="label"]) {
48
+ margin: 0;
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
+ }
63
+ .newspack-text-control,
64
+ .newspack-checkbox-control {
65
+ margin: 0 !important;
66
+ }
67
+ .newspack-select-control {
68
+ .components-base-control {
69
+ width: 100%;
70
+ }
71
+ }
72
+ }
73
+ }
74
+ .newspack-settings__min-max {
75
+ gap: 8px;
76
+
77
+ .newspack-checkbox-control {
78
+ flex: 0 0 auto;
79
+ }
80
+
81
+ .newspack-text-control {
82
+ flex: 1 1 auto;
83
+
84
+ .components-text-control__input {
85
+ text-align: right;
86
+ }
87
+ }
88
+
89
+ + .newspack-settings__min-max {
90
+ margin-top: 16px !important;
91
+ }
92
+ }
93
+ }
94
+
95
+ &__no-border {
96
+ &.newspack-card.newspack-action-card {
97
+ border: 0;
98
+
99
+ .newspack-action-card__region-top,
100
+ .newspack-action-card__region-children {
101
+ padding-left: 0;
102
+ padding-right: 0;
103
+ padding-top: 0;
104
+ }
105
+
106
+ .newspack-action-card__region-children {
107
+ padding-bottom: 0;
108
+ }
109
+
110
+ .newspack-action-card__notification {
111
+ padding-bottom: 16px;
112
+ }
113
+
114
+ & + & {
115
+ margin-top: 64px;
116
+ }
117
+ }
118
+ }
119
+ }