newspack-components 3.0.0-alpha.1 → 3.0.0-alpha.2
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.
- package/babel.config.js +25 -0
- package/copy-styles.js +2 -10
- package/dist/accordion/index.js +50 -0
- package/dist/accordion/style.scss +31 -0
- package/dist/{cjs/action-card → action-card}/index.js +38 -41
- package/dist/{cjs/action-card → action-card}/style.scss +9 -9
- package/dist/{cjs/autocomplete-tokenfield → autocomplete-tokenfield}/index.js +19 -18
- package/dist/{esm/autocomplete-tokenfield → autocomplete-tokenfield}/style.scss +3 -3
- package/dist/{cjs/autocomplete-with-suggestions → autocomplete-with-suggestions}/index.js +29 -29
- package/dist/{cjs/autocomplete-with-suggestions → autocomplete-with-suggestions}/style.scss +8 -8
- package/dist/button/index.js +51 -0
- package/dist/button/index.tsx +48 -0
- package/dist/{cjs/button → button}/style.scss +1 -1
- package/dist/{cjs/button-card → button-card}/index.js +8 -8
- package/dist/{cjs/button-card → button-card}/style.scss +19 -13
- package/dist/{cjs/card → card}/index.js +3 -3
- package/dist/{esm/card → card}/style.scss +1 -1
- package/dist/{cjs/category-autocomplete → category-autocomplete}/index.js +50 -48
- package/dist/{cjs/category-autocomplete → category-autocomplete}/style.scss +2 -2
- package/dist/{cjs/color-picker → color-picker}/index.js +7 -7
- package/dist/{cjs/color-picker → color-picker}/style.scss +3 -3
- package/dist/{cjs/custom-select-control → custom-select-control}/index.js +3 -3
- package/dist/{esm/custom-select-control → custom-select-control}/style.scss +11 -10
- package/dist/date-range-picker/index.js +39 -0
- package/dist/date-range-picker/style.scss +148 -0
- package/dist/{cjs/footer → footer}/index.js +19 -17
- package/dist/{cjs/footer → footer}/style.scss +1 -1
- package/dist/{cjs/form-token-field → form-token-field}/index.js +5 -5
- package/dist/{esm/form-token-field → form-token-field}/style.scss +1 -1
- package/dist/{cjs/global-notices → global-notices}/index.js +3 -3
- package/dist/grid/index.js +44 -0
- package/dist/grid/index.tsx +34 -0
- package/dist/{esm/grid → grid}/style.scss +9 -9
- package/dist/{cjs/handoff → handoff}/index.js +72 -69
- package/dist/{cjs/handoff-message → handoff-message}/index.js +5 -3
- package/dist/hooks/index.js +29 -0
- package/dist/hooks/index.ts +15 -0
- package/dist/{cjs/hooks → hooks}/useObjectState.js +1 -1
- package/dist/{cjs/hooks → hooks}/useObjectState.test.js +9 -9
- package/dist/hooks/usePrompt.js +47 -0
- package/dist/hooks/usePrompt.ts +46 -0
- package/dist/image-upload/index.js +148 -0
- package/dist/{cjs/image-upload → image-upload}/index.test.js +13 -6
- package/dist/{cjs/image-upload → image-upload}/style.scss +5 -5
- package/dist/{cjs/index.js → index.js} +15 -1
- package/dist/{cjs/info-button → info-button}/index.js +5 -5
- package/dist/{cjs/modal → modal}/index.js +3 -3
- package/dist/{cjs/modal → modal}/style.scss +5 -5
- package/dist/{cjs/newspack-icon → newspack-icon}/index.js +4 -4
- package/dist/{cjs/newspack-icon → newspack-icon}/style.scss +1 -1
- package/dist/{cjs/newspack-logo → newspack-logo}/index.js +4 -4
- package/dist/{cjs/newspack-logo → newspack-logo}/style.scss +1 -1
- package/dist/{cjs/notice → notice}/index.js +11 -8
- package/dist/{cjs/notice → notice}/style.scss +11 -11
- package/dist/patrons-logo/index.js +77 -0
- package/dist/plugin-installer/index.js +297 -0
- package/dist/{esm/plugin-installer → plugin-installer}/style.scss +1 -1
- package/dist/{cjs/plugin-settings → plugin-settings}/SettingsSection.js +11 -9
- package/dist/plugin-settings/index.js +228 -0
- package/dist/{cjs/plugin-settings → plugin-settings}/style.scss +1 -1
- package/dist/plugin-toggle/README.md +53 -0
- package/dist/plugin-toggle/index.js +222 -0
- package/dist/{esm/plugin-toggle → plugin-toggle}/style.scss +1 -1
- package/dist/{cjs/popover → popover}/index.js +3 -3
- package/dist/{esm/popover → popover}/style.scss +7 -7
- package/dist/{cjs/position-control → position-control}/index.js +24 -22
- package/dist/{cjs/position-control → position-control}/style.scss +8 -8
- package/dist/{cjs/progress-bar → progress-bar}/index.js +8 -8
- package/dist/{cjs/progress-bar → progress-bar}/index.test.js +12 -11
- package/dist/{esm/progress-bar → progress-bar}/style.scss +2 -2
- package/dist/proxied-imports/router.js +15 -0
- package/dist/{cjs/radio-control → radio-control}/index.js +3 -3
- package/dist/{esm/radio-control → radio-control}/style.scss +3 -3
- package/dist/{cjs/section-header → section-header}/index.js +8 -8
- package/dist/{cjs/section-header → section-header}/style.scss +1 -1
- package/dist/{cjs/select-control → select-control}/ButtonGroupControl.js +7 -7
- package/dist/{cjs/select-control → select-control}/GroupedSelectControl.js +15 -14
- package/dist/{cjs/select-control → select-control}/index.js +6 -6
- package/dist/{esm/select-control → select-control}/style.scss +4 -4
- package/dist/{cjs/settings → settings}/MinMaxSetting.js +12 -11
- package/dist/{cjs/settings → settings}/SettingsCard.js +4 -4
- package/dist/{cjs/settings → settings}/SettingsSection.js +6 -6
- package/dist/{cjs/settings → settings}/index.js +1 -1
- package/dist/{cjs/settings → settings}/style.scss +1 -1
- package/dist/{cjs/sortable-newsletter-list-control → sortable-newsletter-list-control}/index.js +25 -24
- package/dist/{cjs/steps-list → steps-list}/index.js +4 -4
- package/dist/{esm/steps-list → steps-list}/style.scss +2 -2
- package/dist/{cjs/steps-list-item → steps-list-item}/index.js +5 -5
- package/dist/{cjs/steps-list-item → steps-list-item}/style.scss +5 -5
- package/dist/{cjs/style-card → style-card}/index.js +20 -17
- package/dist/{cjs/style-card → style-card}/style.scss +4 -4
- package/dist/{esm/style.scss → style.scss} +1 -1
- package/dist/{cjs/tabbed-navigation → tabbed-navigation}/index.js +7 -7
- package/dist/{cjs/tabbed-navigation → tabbed-navigation}/style.scss +4 -4
- package/dist/text-control/index.js +76 -0
- package/dist/text-control/index.tsx +71 -0
- package/dist/{cjs/utils → utils}/index.js +2 -2
- package/dist/{cjs/waiting → waiting}/index.js +3 -3
- package/dist/web-preview/index.js +191 -0
- package/dist/{esm/web-preview → web-preview}/style.scss +5 -5
- package/dist/with-wizard/index.js +328 -0
- package/dist/{cjs/with-wizard → with-wizard}/style.scss +44 -22
- package/dist/{cjs/with-wizard-screen → with-wizard-screen}/index.js +24 -23
- package/dist/{esm/with-wizard-screen → with-wizard-screen}/style.scss +7 -7
- package/dist/{cjs/wizard → wizard}/components/WizardError.js +10 -9
- package/dist/{cjs/wizard → wizard}/index.js +30 -27
- package/dist/{cjs/wizard → wizard}/store/index.js +1 -1
- package/package.json +18 -15
- package/shared/scss/_mixins.scss +2 -2
- package/src/accordion/index.js +35 -0
- package/src/accordion/style.scss +31 -0
- package/src/action-card/style.scss +9 -9
- package/src/autocomplete-tokenfield/style.scss +3 -3
- package/src/autocomplete-with-suggestions/index.js +46 -44
- package/src/autocomplete-with-suggestions/style.scss +8 -8
- package/src/button/style.scss +1 -1
- package/src/button-card/style.scss +19 -13
- package/src/card/style.scss +1 -1
- package/src/category-autocomplete/style.scss +2 -2
- package/src/color-picker/style.scss +3 -3
- package/src/custom-select-control/style.scss +11 -10
- package/src/date-range-picker/index.js +31 -0
- package/src/date-range-picker/style.scss +148 -0
- package/src/footer/style.scss +1 -1
- package/src/form-token-field/style.scss +1 -1
- package/src/grid/style.scss +9 -9
- package/src/handoff-message/index.js +3 -1
- package/src/image-upload/index.js +1 -1
- package/src/image-upload/index.test.js +6 -1
- package/src/image-upload/style.scss +5 -5
- package/src/index.js +2 -0
- package/src/modal/style.scss +5 -5
- package/src/newspack-icon/style.scss +1 -1
- package/src/newspack-logo/style.scss +1 -1
- package/src/notice/style.scss +11 -11
- package/src/plugin-installer/style.scss +1 -1
- package/src/plugin-settings/style.scss +1 -1
- package/src/plugin-toggle/index.js +6 -7
- package/src/plugin-toggle/style.scss +1 -1
- package/src/popover/style.scss +7 -7
- package/src/position-control/index.js +62 -63
- package/src/position-control/style.scss +8 -8
- package/src/progress-bar/style.scss +2 -2
- package/src/radio-control/style.scss +3 -3
- package/src/section-header/style.scss +1 -1
- package/src/select-control/style.scss +4 -4
- package/src/settings/style.scss +1 -1
- package/src/steps-list/style.scss +2 -2
- package/src/steps-list-item/style.scss +5 -5
- package/src/style-card/style.scss +4 -4
- package/src/style.scss +1 -1
- package/src/tabbed-navigation/index.js +1 -1
- package/src/tabbed-navigation/style.scss +4 -4
- package/src/web-preview/style.scss +5 -5
- package/src/with-wizard/style.scss +44 -22
- package/src/with-wizard-screen/style.scss +7 -7
- package/dist/cjs/autocomplete-tokenfield/style.scss +0 -49
- package/dist/cjs/button/index.js +0 -56
- package/dist/cjs/card/style.scss +0 -168
- package/dist/cjs/custom-select-control/style.scss +0 -92
- package/dist/cjs/form-token-field/style.scss +0 -37
- package/dist/cjs/grid/index.js +0 -37
- package/dist/cjs/grid/style.scss +0 -166
- package/dist/cjs/hooks/index.js +0 -25
- package/dist/cjs/hooks/usePrompt.js +0 -49
- package/dist/cjs/image-upload/index.js +0 -143
- package/dist/cjs/patrons-logo/index.js +0 -81
- package/dist/cjs/plugin-installer/index.js +0 -295
- package/dist/cjs/plugin-installer/style.scss +0 -72
- package/dist/cjs/plugin-settings/index.js +0 -221
- package/dist/cjs/plugin-toggle/index.js +0 -218
- package/dist/cjs/plugin-toggle/style.scss +0 -20
- package/dist/cjs/popover/style.scss +0 -161
- package/dist/cjs/progress-bar/style.scss +0 -42
- package/dist/cjs/proxied-imports/router.js +0 -14
- package/dist/cjs/radio-control/style.scss +0 -92
- package/dist/cjs/select-control/style.scss +0 -108
- package/dist/cjs/steps-list/style.scss +0 -11
- package/dist/cjs/style.scss +0 -55
- package/dist/cjs/text-control/index.js +0 -61
- package/dist/cjs/web-preview/index.js +0 -188
- package/dist/cjs/web-preview/style.scss +0 -155
- package/dist/cjs/with-wizard/index.js +0 -317
- package/dist/cjs/with-wizard-screen/style.scss +0 -160
- package/dist/esm/action-card/index.js +0 -221
- package/dist/esm/action-card/style.scss +0 -483
- package/dist/esm/autocomplete-tokenfield/index.js +0 -260
- package/dist/esm/autocomplete-with-suggestions/index.js +0 -276
- package/dist/esm/autocomplete-with-suggestions/style.scss +0 -163
- package/dist/esm/button/index.js +0 -48
- package/dist/esm/button/style.scss +0 -11
- package/dist/esm/button-card/index.js +0 -64
- package/dist/esm/button-card/style.scss +0 -174
- package/dist/esm/card/index.js +0 -43
- package/dist/esm/category-autocomplete/index.js +0 -181
- package/dist/esm/category-autocomplete/style.scss +0 -34
- package/dist/esm/color-picker/index.js +0 -59
- package/dist/esm/color-picker/style.scss +0 -37
- package/dist/esm/consts.js +0 -1
- package/dist/esm/custom-select-control/index.js +0 -37
- package/dist/esm/footer/index.js +0 -100
- package/dist/esm/footer/style.scss +0 -82
- package/dist/esm/form-token-field/index.js +0 -49
- package/dist/esm/global-notices/index.js +0 -30
- package/dist/esm/grid/index.js +0 -29
- package/dist/esm/handoff/index.js +0 -176
- package/dist/esm/handoff-message/index.js +0 -45
- package/dist/esm/hooks/index.js +0 -17
- package/dist/esm/hooks/useObjectState.js +0 -30
- package/dist/esm/hooks/useObjectState.test.js +0 -82
- package/dist/esm/hooks/useOnClickOutside.js +0 -31
- package/dist/esm/hooks/usePrompt.js +0 -40
- package/dist/esm/image-upload/index.js +0 -139
- package/dist/esm/image-upload/index.test.js +0 -28
- package/dist/esm/image-upload/style.scss +0 -103
- package/dist/esm/index.js +0 -45
- package/dist/esm/info-button/index.js +0 -42
- package/dist/esm/info-button/style.scss +0 -18
- package/dist/esm/modal/index.js +0 -39
- package/dist/esm/modal/style.scss +0 -56
- package/dist/esm/newspack-icon/index.js +0 -50
- package/dist/esm/newspack-icon/style.scss +0 -26
- package/dist/esm/newspack-logo/index.js +0 -46
- package/dist/esm/newspack-logo/style.scss +0 -30
- package/dist/esm/notice/index.js +0 -66
- package/dist/esm/notice/style.scss +0 -111
- package/dist/esm/patrons-logo/index.js +0 -75
- package/dist/esm/plugin-installer/index.js +0 -290
- package/dist/esm/plugin-settings/SettingsSection.js +0 -134
- package/dist/esm/plugin-settings/index.js +0 -216
- package/dist/esm/plugin-settings/style.scss +0 -7
- package/dist/esm/plugin-toggle/index.js +0 -213
- package/dist/esm/popover/index.js +0 -41
- package/dist/esm/position-control/index.js +0 -107
- package/dist/esm/position-control/style.scss +0 -66
- package/dist/esm/progress-bar/index.js +0 -68
- package/dist/esm/progress-bar/index.test.js +0 -109
- package/dist/esm/proxied-imports/router.js +0 -8
- package/dist/esm/radio-control/index.js +0 -37
- package/dist/esm/section-header/index.js +0 -67
- package/dist/esm/section-header/style.scss +0 -45
- package/dist/esm/select-control/ButtonGroupControl.js +0 -53
- package/dist/esm/select-control/GroupedSelectControl.js +0 -79
- package/dist/esm/select-control/index.js +0 -51
- package/dist/esm/settings/MinMaxSetting.js +0 -54
- package/dist/esm/settings/SettingsCard.js +0 -38
- package/dist/esm/settings/SettingsSection.js +0 -26
- package/dist/esm/settings/index.js +0 -9
- package/dist/esm/settings/style.scss +0 -119
- package/dist/esm/sortable-newsletter-list-control/index.js +0 -128
- package/dist/esm/sortable-newsletter-list-control/style.scss +0 -45
- package/dist/esm/steps-list/index.js +0 -43
- package/dist/esm/steps-list-item/index.js +0 -47
- package/dist/esm/steps-list-item/style.scss +0 -47
- package/dist/esm/style-card/index.js +0 -75
- package/dist/esm/style-card/style.scss +0 -94
- package/dist/esm/tabbed-navigation/index.js +0 -53
- package/dist/esm/tabbed-navigation/style.scss +0 -86
- package/dist/esm/text-control/index.js +0 -57
- package/dist/esm/text-control/style.scss +0 -32
- package/dist/esm/utils/index.js +0 -29
- package/dist/esm/waiting/index.js +0 -44
- package/dist/esm/waiting/style.scss +0 -27
- package/dist/esm/web-preview/index.js +0 -183
- package/dist/esm/with-wizard/index.js +0 -311
- package/dist/esm/with-wizard/style.scss +0 -260
- package/dist/esm/with-wizard-screen/index.js +0 -110
- package/dist/esm/wizard/components/WizardError.js +0 -67
- package/dist/esm/wizard/index.js +0 -120
- package/dist/esm/wizard/store/index.js +0 -155
- package/dist/esm/wizard/store/utils.js +0 -14
- /package/dist/{cjs/consts.js → consts.js} +0 -0
- /package/dist/{cjs/hooks → hooks}/useOnClickOutside.js +0 -0
- /package/dist/{cjs/info-button → info-button}/style.scss +0 -0
- /package/dist/{cjs/sortable-newsletter-list-control → sortable-newsletter-list-control}/style.scss +0 -0
- /package/dist/{cjs/text-control → text-control}/style.scss +0 -0
- /package/dist/{cjs/waiting → waiting}/style.scss +0 -0
- /package/dist/{cjs/wizard → wizard}/store/utils.js +0 -0
package/babel.config.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports = api => {
|
|
2
|
+
api.cache( true );
|
|
3
|
+
return {
|
|
4
|
+
extends: 'newspack-scripts/config/babel.config.js',
|
|
5
|
+
presets: [
|
|
6
|
+
[
|
|
7
|
+
'@babel/preset-env',
|
|
8
|
+
{
|
|
9
|
+
corejs: 3.6,
|
|
10
|
+
useBuiltIns: 'entry',
|
|
11
|
+
// Exclude transforms that make all code slower, see https://github.com/facebook/create-react-app/pull/5278
|
|
12
|
+
exclude: [ 'transform-typeof-symbol' ],
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
[
|
|
16
|
+
'@babel/preset-react',
|
|
17
|
+
{
|
|
18
|
+
runtime: 'automatic',
|
|
19
|
+
importSource: process.env.IMPORT_SOURCE,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
[ '@babel/preset-typescript', { allowDeclareFields: true } ],
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
};
|
package/copy-styles.js
CHANGED
|
@@ -9,8 +9,7 @@ const rcopy = require( 'recursive-copy' );
|
|
|
9
9
|
const dir = process.cwd();
|
|
10
10
|
|
|
11
11
|
const inputDir = path.join( dir, 'src' );
|
|
12
|
-
const
|
|
13
|
-
const outputDirCommon = path.join( dir, 'dist', 'cjs' );
|
|
12
|
+
const outputDir = path.join( dir, 'dist' );
|
|
14
13
|
|
|
15
14
|
console.log( 'Copying styles %s', dir );
|
|
16
15
|
|
|
@@ -21,14 +20,7 @@ const copyOptions = {
|
|
|
21
20
|
debug: true,
|
|
22
21
|
};
|
|
23
22
|
|
|
24
|
-
rcopy( inputDir,
|
|
25
|
-
.then( results => {
|
|
26
|
-
console.log( 'copied %d files', results.length );
|
|
27
|
-
} )
|
|
28
|
-
.catch( err => {
|
|
29
|
-
console.error( err );
|
|
30
|
-
} );
|
|
31
|
-
rcopy( inputDir, outputDirCommon, copyOptions )
|
|
23
|
+
rcopy( inputDir, outputDir, copyOptions )
|
|
32
24
|
.then( results => {
|
|
33
25
|
console.log( 'copied %d files', results.length );
|
|
34
26
|
} )
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
var _icons = require("@wordpress/icons");
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
require("./style.scss");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
14
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* WordPress dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* External dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const Accordion = ({
|
|
29
|
+
children,
|
|
30
|
+
title
|
|
31
|
+
}) => {
|
|
32
|
+
const [isOpen, setIsOpen] = (0, _element.useState)(false);
|
|
33
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("details", {
|
|
34
|
+
className: (0, _classnames.default)('newspack-accordion', {
|
|
35
|
+
'newspack-accordion--is-open': isOpen
|
|
36
|
+
}),
|
|
37
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("summary", {
|
|
38
|
+
onClick: () => setIsOpen(!isOpen),
|
|
39
|
+
children: [title, /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
|
|
40
|
+
className: "newspack-accordion__icon",
|
|
41
|
+
icon: _icons.chevronRight,
|
|
42
|
+
size: 24
|
|
43
|
+
})]
|
|
44
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
45
|
+
className: "newspack-accordion__content",
|
|
46
|
+
children: children
|
|
47
|
+
})]
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
var _default = exports.default = Accordion;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
2
|
+
|
|
3
|
+
.newspack-accordion {
|
|
4
|
+
border: 1px solid wp-colors.$gray-300;
|
|
5
|
+
|
|
6
|
+
&__icon {
|
|
7
|
+
transition: transform 200ms ease-out;
|
|
8
|
+
transform: rotate(90deg);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&--is-open {
|
|
12
|
+
.newspack-accordion {
|
|
13
|
+
&__icon {
|
|
14
|
+
transform: rotate(-90deg);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
summary {
|
|
19
|
+
padding: 16px 32px;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: space-between;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
font-size: 14px;
|
|
25
|
+
font-weight: bold;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&__content {
|
|
29
|
+
padding: 16px 32px;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
8
|
var _element = require("@wordpress/element");
|
|
10
9
|
var _components = require("@wordpress/components");
|
|
11
10
|
var _icons = require("@wordpress/icons");
|
|
12
11
|
var _ = require("../");
|
|
13
12
|
require("./style.scss");
|
|
14
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
var _jsxRuntime = require("
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
15
|
/**
|
|
17
16
|
* Action Card
|
|
18
17
|
*/
|
|
@@ -30,12 +29,10 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
30
29
|
*/
|
|
31
30
|
|
|
32
31
|
class ActionCard extends _element.Component {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
}
|
|
32
|
+
state = {
|
|
33
|
+
expanded: false
|
|
34
|
+
};
|
|
35
|
+
|
|
39
36
|
/**
|
|
40
37
|
* When the collapse prop is updated to true, collapse the card if already expanded.
|
|
41
38
|
*/
|
|
@@ -103,120 +100,120 @@ class ActionCard extends _element.Component {
|
|
|
103
100
|
const hasInternalLink = href && href.indexOf('http') !== 0;
|
|
104
101
|
const isDisplayingSecondaryAction = secondaryActionText && onSecondaryActionClick;
|
|
105
102
|
const badges = !Array.isArray(badge) && badge ? [badge] : badge;
|
|
106
|
-
return (0, _jsxRuntime.jsxs)(_.Card, {
|
|
103
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_.Card, {
|
|
107
104
|
className: classes,
|
|
108
105
|
onClick: simple && onClick,
|
|
109
|
-
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
106
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
110
107
|
className: "newspack-action-card__region newspack-action-card__region-top",
|
|
111
|
-
children: [toggleOnChange && (0, _jsxRuntime.jsx)(_components.ToggleControl, {
|
|
108
|
+
children: [toggleOnChange && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, {
|
|
112
109
|
checked: toggleChecked,
|
|
113
110
|
onChange: toggleOnChange,
|
|
114
111
|
disabled: disabled
|
|
115
|
-
}), image && !toggleOnChange && (0, _jsxRuntime.jsx)("div", {
|
|
112
|
+
}), image && !toggleOnChange && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
116
113
|
className: "newspack-action-card__region newspack-action-card__region-left",
|
|
117
|
-
children: (0, _jsxRuntime.jsx)("a", {
|
|
114
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
118
115
|
href: imageLink,
|
|
119
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
116
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
120
117
|
className: "newspack-action-card__image",
|
|
121
118
|
style: backgroundImageStyles(image)
|
|
122
119
|
})
|
|
123
120
|
})
|
|
124
|
-
}), checkbox && !toggleOnChange && (0, _jsxRuntime.jsx)("div", {
|
|
121
|
+
}), checkbox && !toggleOnChange && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
125
122
|
className: "newspack-action-card__region newspack-action-card__region-left",
|
|
126
|
-
children: (0, _jsxRuntime.jsx)("span", {
|
|
123
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
127
124
|
className: (0, _classnames.default)('newspack-checkbox-icon', 'is-primary', 'checked' === checkbox && 'newspack-checkbox-icon--checked', isPending && 'newspack-checkbox-icon--pending'),
|
|
128
|
-
children: 'checked' === checkbox && (0, _jsxRuntime.jsx)(_icons.Icon, {
|
|
125
|
+
children: 'checked' === checkbox && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
|
|
129
126
|
icon: _icons.check
|
|
130
127
|
})
|
|
131
128
|
})
|
|
132
|
-
}), (0, _jsxRuntime.jsx)("div", {
|
|
129
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
133
130
|
className: "newspack-action-card__region newspack-action-card__region-center",
|
|
134
|
-
children: (0, _jsxRuntime.jsxs)(_.Grid, {
|
|
131
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_.Grid, {
|
|
135
132
|
columns: 1,
|
|
136
133
|
gutter: 8,
|
|
137
134
|
noMargin: true,
|
|
138
|
-
children: [(0, _jsxRuntime.jsxs)("h2", {
|
|
139
|
-
children: [(0, _jsxRuntime.jsxs)("span", {
|
|
135
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("h2", {
|
|
136
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
140
137
|
className: "newspack-action-card__title",
|
|
141
138
|
...titleProps,
|
|
142
|
-
children: [titleLink && (0, _jsxRuntime.jsx)("a", {
|
|
139
|
+
children: [titleLink && /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
143
140
|
href: titleLink,
|
|
144
141
|
children: title
|
|
145
|
-
}), !titleLink && expandable && (0, _jsxRuntime.jsx)(_.Button, {
|
|
142
|
+
}), !titleLink && expandable && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
|
|
146
143
|
isLink: true,
|
|
147
144
|
onClick: () => this.setState({
|
|
148
145
|
expanded: !expanded
|
|
149
146
|
}),
|
|
150
147
|
children: title
|
|
151
148
|
}), !titleLink && !expandable && title]
|
|
152
|
-
}), badges?.length && badges.map((badgeText, i) => (0, _jsxRuntime.jsx)("span", {
|
|
149
|
+
}), badges?.length && badges.map((badgeText, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
153
150
|
className: "newspack-action-card__badge",
|
|
154
151
|
children: badgeText
|
|
155
152
|
}, `badge-${i}`))]
|
|
156
|
-
}), description && (0, _jsxRuntime.jsxs)("p", {
|
|
153
|
+
}), description && /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
|
|
157
154
|
children: [typeof description === 'string' && description, typeof description === 'function' && description()]
|
|
158
155
|
})]
|
|
159
156
|
})
|
|
160
|
-
}), !expandable && (actionText || isDisplayingSecondaryAction || actionContent) && (0, _jsxRuntime.jsxs)("div", {
|
|
157
|
+
}), !expandable && (actionText || isDisplayingSecondaryAction || actionContent) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
161
158
|
className: "newspack-action-card__region newspack-action-card__region-right",
|
|
162
|
-
children: [actionContent && actionContent, actionText && (handoff ? (0, _jsxRuntime.jsx)(_.Handoff, {
|
|
159
|
+
children: [actionContent && actionContent, actionText && (handoff ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Handoff, {
|
|
163
160
|
plugin: handoff,
|
|
164
161
|
editLink: editLink,
|
|
165
162
|
compact: true,
|
|
166
163
|
isLink: true,
|
|
167
164
|
children: actionText
|
|
168
|
-
}) : onClick || hasInternalLink ? (0, _jsxRuntime.jsx)(_.Button, {
|
|
165
|
+
}) : onClick || hasInternalLink ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
|
|
169
166
|
disabled: disabled,
|
|
170
167
|
isLink: true,
|
|
171
168
|
href: href,
|
|
172
169
|
onClick: onClick,
|
|
173
170
|
className: "newspack-action-card__primary_button",
|
|
174
171
|
children: actionText
|
|
175
|
-
}) : href ? (0, _jsxRuntime.jsx)(_components.ExternalLink, {
|
|
172
|
+
}) : href ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ExternalLink, {
|
|
176
173
|
href: href,
|
|
177
174
|
className: "newspack-action-card__primary_button",
|
|
178
175
|
children: actionText
|
|
179
|
-
}) : (0, _jsxRuntime.jsxs)("div", {
|
|
176
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
180
177
|
className: "newspack-action-card__container",
|
|
181
|
-
children: [actionText, isWaiting && (0, _jsxRuntime.jsx)(_.Waiting, {
|
|
178
|
+
children: [actionText, isWaiting && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Waiting, {
|
|
182
179
|
isRight: true
|
|
183
180
|
})]
|
|
184
|
-
})), isDisplayingSecondaryAction && (0, _jsxRuntime.jsx)(_.Button, {
|
|
181
|
+
})), isDisplayingSecondaryAction && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
|
|
185
182
|
isLink: true,
|
|
186
183
|
onClick: onSecondaryActionClick,
|
|
187
184
|
className: "newspack-action-card__secondary_button",
|
|
188
185
|
isDestructive: secondaryDestructive,
|
|
189
186
|
children: secondaryActionText
|
|
190
187
|
})]
|
|
191
|
-
}), expandable && (0, _jsxRuntime.jsx)(_.Button, {
|
|
188
|
+
}), expandable && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
|
|
192
189
|
onClick: () => this.setState({
|
|
193
190
|
expanded: !expanded
|
|
194
191
|
}),
|
|
195
|
-
children: (0, _jsxRuntime.jsx)(_icons.Icon, {
|
|
192
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
|
|
196
193
|
icon: expanded ? _icons.chevronUp : _icons.chevronDown,
|
|
197
194
|
height: 24,
|
|
198
195
|
width: 24
|
|
199
196
|
})
|
|
200
197
|
})]
|
|
201
|
-
}), notification && (0, _jsxRuntime.jsxs)("div", {
|
|
198
|
+
}), notification && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
202
199
|
className: "newspack-action-card__notification newspack-action-card__region-children",
|
|
203
|
-
children: ['error' === notificationLevel && (0, _jsxRuntime.jsx)(_.Notice, {
|
|
200
|
+
children: ['error' === notificationLevel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Notice, {
|
|
204
201
|
noticeText: notification,
|
|
205
202
|
isError: true,
|
|
206
203
|
rawHTML: notificationHTML
|
|
207
|
-
}), 'info' === notificationLevel && (0, _jsxRuntime.jsx)(_.Notice, {
|
|
204
|
+
}), 'info' === notificationLevel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Notice, {
|
|
208
205
|
noticeText: notification,
|
|
209
206
|
rawHTML: notificationHTML
|
|
210
|
-
}), 'success' === notificationLevel && (0, _jsxRuntime.jsx)(_.Notice, {
|
|
207
|
+
}), 'success' === notificationLevel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Notice, {
|
|
211
208
|
noticeText: notification,
|
|
212
209
|
isSuccess: true,
|
|
213
210
|
rawHTML: notificationHTML
|
|
214
|
-
}), 'warning' === notificationLevel && (0, _jsxRuntime.jsx)(_.Notice, {
|
|
211
|
+
}), 'warning' === notificationLevel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Notice, {
|
|
215
212
|
noticeText: notification,
|
|
216
213
|
isWarning: true,
|
|
217
214
|
rawHTML: notificationHTML
|
|
218
215
|
})]
|
|
219
|
-
}), children && (expandable && expanded || !expandable) && (0, _jsxRuntime.jsx)("div", {
|
|
216
|
+
}), children && (expandable && expanded || !expandable) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
220
217
|
className: "newspack-action-card__region-children",
|
|
221
218
|
children: children
|
|
222
219
|
})]
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Action Card
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
@use
|
|
6
|
-
@use
|
|
5
|
+
@use "sass:color";
|
|
6
|
+
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
7
7
|
|
|
8
8
|
.newspack-card.newspack-action-card {
|
|
9
9
|
padding: 0;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
transition: box-shadow 125ms ease-in-out;
|
|
16
16
|
|
|
17
17
|
&:hover {
|
|
18
|
-
box-shadow: 0 4px 8px rgba(
|
|
18
|
+
box-shadow: 0 4px 8px rgba(black, 0.08);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
&.newspack-card__is-primary {
|
|
37
|
-
box-shadow: inset 4px 0 0 var(
|
|
37
|
+
box-shadow: inset 4px 0 0 var(--wp-admin-theme-color);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
&.newspack-card__is-secondary {
|
|
@@ -181,12 +181,12 @@
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
.newspack-action-card__region-top {
|
|
184
|
-
background-color: rgba(
|
|
184
|
+
background-color: rgba(black, 0.025);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
.newspack-action-card__region-center {
|
|
188
188
|
p {
|
|
189
|
-
color: color.adjust(
|
|
189
|
+
color: color.adjust(wp-colors.$gray-700, $lightness: -0.75%);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -209,7 +209,7 @@
|
|
|
209
209
|
border-left-width: 1px;
|
|
210
210
|
border-bottom-width: 1px;
|
|
211
211
|
border-radius: 0 0 0 2px;
|
|
212
|
-
content:
|
|
212
|
+
content: "";
|
|
213
213
|
display: block;
|
|
214
214
|
position: absolute;
|
|
215
215
|
inset: -17px 100% 50% -28px;
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
// Typography
|
|
220
220
|
|
|
221
221
|
h2,
|
|
222
|
-
p:not(
|
|
222
|
+
p:not([class*="components-base-control"]) {
|
|
223
223
|
margin: 0;
|
|
224
224
|
max-width: 100%;
|
|
225
225
|
width: 100%;
|
|
@@ -242,7 +242,7 @@
|
|
|
242
242
|
&:active,
|
|
243
243
|
&:focus,
|
|
244
244
|
&:hover {
|
|
245
|
-
color: var(
|
|
245
|
+
color: var(--wp-admin-theme-color);
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
8
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
10
9
|
var _element = require("@wordpress/element");
|
|
11
10
|
var _components = require("@wordpress/components");
|
|
12
11
|
require("./style.scss");
|
|
13
|
-
var _jsxRuntime = require("
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
13
|
/**
|
|
15
14
|
* External dependencies
|
|
16
15
|
*/
|
|
@@ -28,16 +27,6 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
28
27
|
*/class AutocompleteTokenField extends _element.Component {
|
|
29
28
|
constructor(props) {
|
|
30
29
|
super(props);
|
|
31
|
-
/**
|
|
32
|
-
* If the component has tokens passed in props, it should fetch info after it mounts.
|
|
33
|
-
*/
|
|
34
|
-
(0, _defineProperty2.default)(this, "isFetchingInfoOnLoad", () => {
|
|
35
|
-
const {
|
|
36
|
-
tokens,
|
|
37
|
-
fetchSavedInfo
|
|
38
|
-
} = this.props;
|
|
39
|
-
return Boolean(tokens.length && fetchSavedInfo);
|
|
40
|
-
});
|
|
41
30
|
this.state = {
|
|
42
31
|
suggestions: [],
|
|
43
32
|
validValues: {},
|
|
@@ -45,6 +34,18 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
45
34
|
};
|
|
46
35
|
this.debouncedUpdateSuggestions = (0, _debounce.default)(this.updateSuggestions, 500);
|
|
47
36
|
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* If the component has tokens passed in props, it should fetch info after it mounts.
|
|
40
|
+
*/
|
|
41
|
+
isFetchingInfoOnLoad = () => {
|
|
42
|
+
const {
|
|
43
|
+
tokens,
|
|
44
|
+
fetchSavedInfo
|
|
45
|
+
} = this.props;
|
|
46
|
+
return Boolean(tokens.length && fetchSavedInfo);
|
|
47
|
+
};
|
|
48
|
+
|
|
48
49
|
/**
|
|
49
50
|
* When the component loads, fetch information about the tokens so we can populate
|
|
50
51
|
* the tokens with the correct labels.
|
|
@@ -243,11 +244,11 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
243
244
|
if (label) {
|
|
244
245
|
classNames.push('has-label');
|
|
245
246
|
}
|
|
246
|
-
return (0, _jsxRuntime.jsxs)("div", {
|
|
247
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
247
248
|
className: "newspack-autocomplete-tokenfield",
|
|
248
|
-
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
249
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
249
250
|
className: classNames.join(' '),
|
|
250
|
-
children: [(0, _jsxRuntime.jsx)(_components.FormTokenField, {
|
|
251
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.FormTokenField, {
|
|
251
252
|
value: this.getTokens(),
|
|
252
253
|
suggestions: suggestions.map(suggestion => suggestion.label),
|
|
253
254
|
onChange: tokens => this.handleOnChange(tokens),
|
|
@@ -255,8 +256,8 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
255
256
|
label: label,
|
|
256
257
|
maxLength: maxLength,
|
|
257
258
|
placeholder: placeholder
|
|
258
|
-
}), loading && (0, _jsxRuntime.jsx)(_components.Spinner, {})]
|
|
259
|
-
}), help && (0, _jsxRuntime.jsx)("p", {
|
|
259
|
+
}), loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {})]
|
|
260
|
+
}), help && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
260
261
|
className: "newspack-autocomplete-tokenfield__help",
|
|
261
262
|
children: help
|
|
262
263
|
})]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Autocomplete Token Field
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
@use
|
|
5
|
+
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
6
6
|
|
|
7
7
|
.newspack-autocomplete-tokenfield {
|
|
8
8
|
.components-spinner {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
padding-left: 0;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
.components-button:focus:not(
|
|
47
|
-
box-shadow: inset 0 0 0 var(
|
|
46
|
+
.components-button:focus:not(:disabled) {
|
|
47
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
@@ -13,24 +13,24 @@ var _i18n = require("@wordpress/i18n");
|
|
|
13
13
|
var _url = require("@wordpress/url");
|
|
14
14
|
var _ = require("../");
|
|
15
15
|
require("./style.scss");
|
|
16
|
-
var _jsxRuntime = require("
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
/**
|
|
18
18
|
* WordPress dependencies
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
_x = _i18n._x;
|
|
20
|
+
|
|
22
21
|
/**
|
|
23
22
|
* External dependencies.
|
|
24
23
|
*/
|
|
24
|
+
|
|
25
25
|
const AutocompleteWithSuggestions = ({
|
|
26
26
|
fetchSavedPosts = false,
|
|
27
27
|
// If passed, will use this function to fetch saved data.
|
|
28
28
|
fetchSuggestions = false,
|
|
29
29
|
// If passed, will use this function to fetch suggestions data.
|
|
30
|
-
help = __('Begin typing search term, click autocomplete result to select.', 'newspack-plugin'),
|
|
30
|
+
help = (0, _i18n.__)('Begin typing search term, click autocomplete result to select.', 'newspack-plugin'),
|
|
31
31
|
hideHelp = false,
|
|
32
32
|
// If true, all help text will be hidden.
|
|
33
|
-
label = __('Search', 'newspack-plugin'),
|
|
33
|
+
label = (0, _i18n.__)('Search', 'newspack-plugin'),
|
|
34
34
|
maxItemsToSuggest = 0,
|
|
35
35
|
// If passed, will be used to determine "load more" state. Necessary if you want "load more" functionality when using a custom `fetchSuggestions` function.
|
|
36
36
|
multiSelect = false,
|
|
@@ -44,9 +44,9 @@ const AutocompleteWithSuggestions = ({
|
|
|
44
44
|
label: 'Post'
|
|
45
45
|
}],
|
|
46
46
|
// If passed, will render a selector to change the post type queried for suggestions.
|
|
47
|
-
postTypeLabel = __('item', 'newspack-plugin'),
|
|
47
|
+
postTypeLabel = (0, _i18n.__)('item', 'newspack-plugin'),
|
|
48
48
|
// String to describe the data being shown.
|
|
49
|
-
postTypeLabelPlural = __('items', 'newspack-plugin'),
|
|
49
|
+
postTypeLabelPlural = (0, _i18n.__)('items', 'newspack-plugin'),
|
|
50
50
|
// Plural string to describe the data being shown.
|
|
51
51
|
selectedItems = [],
|
|
52
52
|
// Array of saved items.
|
|
@@ -108,7 +108,7 @@ const AutocompleteWithSuggestions = ({
|
|
|
108
108
|
});
|
|
109
109
|
return posts.map(post => ({
|
|
110
110
|
value: parseInt(post.id),
|
|
111
|
-
label: (0, _htmlEntities.decodeEntities)(post.title) || __('(no title)', 'newspack-plugin')
|
|
111
|
+
label: (0, _htmlEntities.decodeEntities)(post.title) || (0, _i18n.__)('(no title)', 'newspack-plugin')
|
|
112
112
|
}));
|
|
113
113
|
};
|
|
114
114
|
|
|
@@ -136,7 +136,7 @@ const AutocompleteWithSuggestions = ({
|
|
|
136
136
|
return posts.reduce((acc, post) => {
|
|
137
137
|
acc.push({
|
|
138
138
|
value: parseInt(post.id),
|
|
139
|
-
label: (0, _htmlEntities.decodeEntities)(post?.title.rendered) || __('(no title)', 'newspack-plugin')
|
|
139
|
+
label: (0, _htmlEntities.decodeEntities)(post?.title.rendered) || (0, _i18n.__)('(no title)', 'newspack-plugin')
|
|
140
140
|
});
|
|
141
141
|
return acc;
|
|
142
142
|
}, []);
|
|
@@ -181,20 +181,20 @@ const AutocompleteWithSuggestions = ({
|
|
|
181
181
|
const selections = selectedPost ? [...selectedItems, selectedPost] : selectedItems;
|
|
182
182
|
const selectedMessage = multiSelect ? (0, _i18n.sprintf)(
|
|
183
183
|
// Translators: %1: the length of selections. %2: the selection leabel.
|
|
184
|
-
__('%1$s %2$s selected', 'newspack-plugin'), selections.length, selections.length > 1 ? postTypeLabelPlural : postTypeLabel) :
|
|
184
|
+
(0, _i18n.__)('%1$s %2$s selected', 'newspack-plugin'), selections.length, selections.length > 1 ? postTypeLabelPlural : postTypeLabel) : (0, _i18n.sprintf)(
|
|
185
185
|
// Translators: %s: The label for the selection.
|
|
186
|
-
(0, _i18n.
|
|
187
|
-
return (0, _jsxRuntime.jsxs)("div", {
|
|
186
|
+
(0, _i18n.__)('Selected %s', 'newspack-plugin'), postTypeLabel);
|
|
187
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
188
188
|
className: "newspack-autocomplete-with-suggestions__selected-items",
|
|
189
|
-
children: [(0, _jsxRuntime.jsxs)("p", {
|
|
189
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
|
|
190
190
|
className: "newspack-autocomplete-with-suggestions__label",
|
|
191
|
-
children: [selectedMessage, 1 < selections.length && _x(' – ', 'separator character', 'newspack-plugin'), 1 < selections.length && (0, _jsxRuntime.jsx)(_components.Button, {
|
|
191
|
+
children: [selectedMessage, 1 < selections.length && (0, _i18n._x)(' – ', 'separator character', 'newspack-plugin'), 1 < selections.length && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
192
192
|
onClick: () => onChange([]),
|
|
193
193
|
isLink: true,
|
|
194
194
|
isDestructive: true,
|
|
195
|
-
children: __('Clear all', 'newspack-plugin')
|
|
195
|
+
children: (0, _i18n.__)('Clear all', 'newspack-plugin')
|
|
196
196
|
})]
|
|
197
|
-
}), selections.map(selection => (0, _jsxRuntime.jsx)(_components.Button, {
|
|
197
|
+
}), selections.map(selection => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
198
198
|
className: "newspack-autocomplete-with-suggestions__selected-item-button",
|
|
199
199
|
isTertiary: true,
|
|
200
200
|
onClick: () => onChange(selections.filter(_selection => _selection.value !== selection.value)),
|
|
@@ -207,10 +207,10 @@ const AutocompleteWithSuggestions = ({
|
|
|
207
207
|
* Render post type select dropdown.
|
|
208
208
|
*/
|
|
209
209
|
const renderPostTypeSelect = () => {
|
|
210
|
-
return (0, _jsxRuntime.jsx)(_components.SelectControl, {
|
|
210
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SelectControl, {
|
|
211
211
|
label: (0, _i18n.sprintf)(
|
|
212
212
|
// Translators: %s: The name of the type.
|
|
213
|
-
__('%s type', 'newspack-plugin'), postTypeLabel.charAt(0).toUpperCase() + postTypeLabel.slice(1)),
|
|
213
|
+
(0, _i18n.__)('%s type', 'newspack-plugin'), postTypeLabel.charAt(0).toUpperCase() + postTypeLabel.slice(1)),
|
|
214
214
|
value: postTypeToSearch,
|
|
215
215
|
options: postTypes.map(postTypeOption => ({
|
|
216
216
|
label: postTypeOption.label,
|
|
@@ -229,13 +229,13 @@ const AutocompleteWithSuggestions = ({
|
|
|
229
229
|
if (multiSelect) {
|
|
230
230
|
const selections = selectedPost ? [...selectedItems, selectedPost] : [...selectedItems];
|
|
231
231
|
const isSelected = !!selections.find(_selection => parseInt(_selection.value) === parseInt(suggestion.value) && _selection.label === suggestion.label);
|
|
232
|
-
return (0, _jsxRuntime.jsx)(_components.CheckboxControl, {
|
|
232
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
|
|
233
233
|
checked: isSelected,
|
|
234
234
|
onChange: () => handleOnChange([suggestion]),
|
|
235
235
|
label: suggestion.label
|
|
236
236
|
}, suggestion.value);
|
|
237
237
|
}
|
|
238
|
-
return (0, _jsxRuntime.jsx)(_components.Button, {
|
|
238
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
239
239
|
isLink: true,
|
|
240
240
|
onClick: () => handleOnChange([suggestion]),
|
|
241
241
|
children: suggestion.label
|
|
@@ -250,24 +250,24 @@ const AutocompleteWithSuggestions = ({
|
|
|
250
250
|
return null;
|
|
251
251
|
}
|
|
252
252
|
const className = multiSelect ? 'newspack-autocomplete-with-suggestions__search-suggestions-multiselect' : 'newspack-autocomplete-with-suggestions__search-suggestions';
|
|
253
|
-
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
254
|
-
children: [!hideHelp && (0, _jsxRuntime.jsx)("p", {
|
|
253
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
254
|
+
children: [!hideHelp && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
255
255
|
className: "newspack-autocomplete-with-suggestions__label",
|
|
256
|
-
children: /* Translators: %s: the name of a post type. */(0, _i18n.sprintf)(__('Or, select a recent %s:', 'newspack-plugin'), postTypeLabel)
|
|
257
|
-
}), (0, _jsxRuntime.jsxs)("div", {
|
|
256
|
+
children: /* Translators: %s: the name of a post type. */(0, _i18n.sprintf)((0, _i18n.__)('Or, select a recent %s:', 'newspack-plugin'), postTypeLabel)
|
|
257
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
258
258
|
className: className,
|
|
259
|
-
children: [suggestions.map(renderSuggestion), suggestions.length < (maxItemsToSuggest || maxSuggestions) && (0, _jsxRuntime.jsx)(_components.Button, {
|
|
259
|
+
children: [suggestions.map(renderSuggestion), suggestions.length < (maxItemsToSuggest || maxSuggestions) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
260
260
|
disabled: isLoadingMore,
|
|
261
261
|
isSecondary: true,
|
|
262
262
|
onClick: () => setIsLoadingMore(true),
|
|
263
|
-
children: isLoadingMore ? __('Loading…', 'newspack-plugin') : __('Load more', 'newspack-plugin')
|
|
263
|
+
children: isLoadingMore ? (0, _i18n.__)('Loading…', 'newspack-plugin') : (0, _i18n.__)('Load more', 'newspack-plugin')
|
|
264
264
|
})]
|
|
265
265
|
})]
|
|
266
266
|
});
|
|
267
267
|
};
|
|
268
|
-
return (0, _jsxRuntime.jsxs)("div", {
|
|
268
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
269
269
|
className: classNames.join(' '),
|
|
270
|
-
children: [0 < selectedItems.length && renderSelections(), 1 < postTypes.length && renderPostTypeSelect(), (0, _jsxRuntime.jsx)(_.AutocompleteTokenField, {
|
|
270
|
+
children: [0 < selectedItems.length && renderSelections(), 1 < postTypes.length && renderPostTypeSelect(), /*#__PURE__*/(0, _jsxRuntime.jsx)(_.AutocompleteTokenField, {
|
|
271
271
|
tokens: [],
|
|
272
272
|
onChange: handleOnChange,
|
|
273
273
|
fetchSuggestions: async search => handleFetchSuggestions(search, 0, postTypeToSearch),
|