@wordpress/edit-post 6.4.0 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/secondary-sidebar/list-view-sidebar.js +1 -5
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/post-visibility/index.js +16 -1
- package/build/components/sidebar/post-visibility/index.js.map +1 -1
- package/build/components/start-page-options/index.js +0 -5
- package/build/components/start-page-options/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -5
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/post-visibility/index.js +17 -1
- package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
- package/build-module/components/start-page-options/index.js +0 -5
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-style/style-rtl.css +15 -70
- package/build-style/style.css +15 -70
- package/package.json +27 -27
- package/src/components/block-manager/style.scss +0 -4
- package/src/components/header/style.scss +12 -32
- package/src/components/secondary-sidebar/list-view-sidebar.js +1 -5
- package/src/components/sidebar/post-visibility/index.js +12 -2
- package/src/components/sidebar/post-visibility/style.scss +2 -30
- package/src/components/start-page-options/index.js +0 -5
- package/src/test/editor.native.js +8 -1
- package/build/components/admin-notices/index.js +0 -129
- package/build/components/admin-notices/index.js.map +0 -1
- package/build/components/block-manager/show-all.js +0 -39
- package/build/components/block-manager/show-all.js.map +0 -1
- package/build/components/editor-initialization/utils.js +0 -38
- package/build/components/editor-initialization/utils.js.map +0 -1
- package/build-module/components/admin-notices/index.js +0 -114
- package/build-module/components/admin-notices/index.js.map +0 -1
- package/build-module/components/block-manager/show-all.js +0 -29
- package/build-module/components/block-manager/show-all.js.map +0 -1
- package/build-module/components/editor-initialization/utils.js +0 -29
- package/build-module/components/editor-initialization/utils.js.map +0 -1
- package/src/components/admin-notices/index.js +0 -110
- package/src/components/admin-notices/test/index.js +0 -63
- package/src/components/block-manager/show-all.js +0 -30
- package/src/components/editor-initialization/utils.js +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-post",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"description": "Edit Post module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,31 +27,31 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/a11y": "^3.
|
|
31
|
-
"@wordpress/api-fetch": "^6.
|
|
32
|
-
"@wordpress/block-editor": "^
|
|
33
|
-
"@wordpress/block-library": "^7.
|
|
34
|
-
"@wordpress/blocks": "^11.
|
|
35
|
-
"@wordpress/components": "^19.
|
|
36
|
-
"@wordpress/compose": "^5.
|
|
37
|
-
"@wordpress/core-data": "^4.
|
|
38
|
-
"@wordpress/data": "^6.
|
|
39
|
-
"@wordpress/deprecated": "^3.
|
|
40
|
-
"@wordpress/editor": "^12.
|
|
41
|
-
"@wordpress/element": "^4.
|
|
42
|
-
"@wordpress/hooks": "^3.
|
|
43
|
-
"@wordpress/i18n": "^4.
|
|
44
|
-
"@wordpress/icons": "^8.
|
|
45
|
-
"@wordpress/interface": "^4.
|
|
46
|
-
"@wordpress/keyboard-shortcuts": "^3.
|
|
47
|
-
"@wordpress/keycodes": "^3.
|
|
48
|
-
"@wordpress/media-utils": "^3.
|
|
49
|
-
"@wordpress/notices": "^3.
|
|
50
|
-
"@wordpress/plugins": "^4.
|
|
51
|
-
"@wordpress/preferences": "^
|
|
52
|
-
"@wordpress/url": "^3.
|
|
53
|
-
"@wordpress/viewport": "^4.
|
|
54
|
-
"@wordpress/warning": "^2.
|
|
30
|
+
"@wordpress/a11y": "^3.8.0",
|
|
31
|
+
"@wordpress/api-fetch": "^6.5.0",
|
|
32
|
+
"@wordpress/block-editor": "^9.0.0",
|
|
33
|
+
"@wordpress/block-library": "^7.5.0",
|
|
34
|
+
"@wordpress/blocks": "^11.7.0",
|
|
35
|
+
"@wordpress/components": "^19.10.0",
|
|
36
|
+
"@wordpress/compose": "^5.6.0",
|
|
37
|
+
"@wordpress/core-data": "^4.6.0",
|
|
38
|
+
"@wordpress/data": "^6.8.0",
|
|
39
|
+
"@wordpress/deprecated": "^3.8.0",
|
|
40
|
+
"@wordpress/editor": "^12.7.0",
|
|
41
|
+
"@wordpress/element": "^4.6.0",
|
|
42
|
+
"@wordpress/hooks": "^3.8.0",
|
|
43
|
+
"@wordpress/i18n": "^4.8.0",
|
|
44
|
+
"@wordpress/icons": "^8.4.0",
|
|
45
|
+
"@wordpress/interface": "^4.7.0",
|
|
46
|
+
"@wordpress/keyboard-shortcuts": "^3.6.0",
|
|
47
|
+
"@wordpress/keycodes": "^3.8.0",
|
|
48
|
+
"@wordpress/media-utils": "^3.6.0",
|
|
49
|
+
"@wordpress/notices": "^3.8.0",
|
|
50
|
+
"@wordpress/plugins": "^4.6.0",
|
|
51
|
+
"@wordpress/preferences": "^2.0.0",
|
|
52
|
+
"@wordpress/url": "^3.9.0",
|
|
53
|
+
"@wordpress/viewport": "^4.6.0",
|
|
54
|
+
"@wordpress/warning": "^2.8.0",
|
|
55
55
|
"classnames": "^2.3.1",
|
|
56
56
|
"lodash": "^4.17.21",
|
|
57
57
|
"memize": "^1.1.0",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "4631d515033397fcfeda77e5755960253caef9bf"
|
|
68
68
|
}
|
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Buttons on the right side
|
|
49
|
+
*/
|
|
50
|
+
|
|
47
51
|
.edit-post-header__settings {
|
|
48
52
|
display: inline-flex;
|
|
49
53
|
align-items: center;
|
|
@@ -51,31 +55,13 @@
|
|
|
51
55
|
padding-right: $grid-unit-05;
|
|
52
56
|
|
|
53
57
|
@include break-small () {
|
|
54
|
-
padding-right: $grid-unit-20;
|
|
58
|
+
padding-right: $grid-unit-20 - ($grid-unit-15 * 0.5);
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
* Buttons in the Toolbar
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
// Adjust button paddings to scale better to mobile.
|
|
62
|
-
.editor-post-saved-state,
|
|
63
|
-
.components-button.components-button {
|
|
64
|
-
margin-right: $grid-unit-05;
|
|
61
|
+
gap: $grid-unit-05;
|
|
65
62
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.editor-post-saved-state,
|
|
72
|
-
.components-button.is-tertiary {
|
|
73
|
-
padding: 0 #{ $grid-unit-15 * 0.5 };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.interface-more-menu-dropdown .components-button,
|
|
77
|
-
.interface-pinned-items .components-button {
|
|
78
|
-
margin-right: 0;
|
|
63
|
+
@include break-small() {
|
|
64
|
+
gap: $grid-unit-10;
|
|
79
65
|
}
|
|
80
66
|
}
|
|
81
67
|
|
|
@@ -104,6 +90,10 @@
|
|
|
104
90
|
}
|
|
105
91
|
}
|
|
106
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Show icon labels.
|
|
95
|
+
*/
|
|
96
|
+
|
|
107
97
|
.show-icon-labels.interface-pinned-items,
|
|
108
98
|
.show-icon-labels .edit-post-header,
|
|
109
99
|
.edit-post-header__dropdown {
|
|
@@ -157,17 +147,7 @@
|
|
|
157
147
|
padding-right: $grid-unit-15;
|
|
158
148
|
}
|
|
159
149
|
}
|
|
160
|
-
.components-dropdown-menu__toggle {
|
|
161
|
-
margin-left: $grid-unit;
|
|
162
|
-
padding-left: $grid-unit;
|
|
163
|
-
padding-right: $grid-unit;
|
|
164
150
|
|
|
165
|
-
@include break-small {
|
|
166
|
-
margin-left: $grid-unit-15;
|
|
167
|
-
padding-left: $grid-unit-15;
|
|
168
|
-
padding-right: $grid-unit-15;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
151
|
// The inserter has a custom label, different from its aria-label, so we don't want to display both.
|
|
172
152
|
.edit-post-header-toolbar__inserter-toggle.edit-post-header-toolbar__inserter-toggle {
|
|
173
153
|
&::after {
|
|
@@ -8,12 +8,14 @@ import {
|
|
|
8
8
|
PostVisibilityLabel,
|
|
9
9
|
PostVisibilityCheck,
|
|
10
10
|
} from '@wordpress/editor';
|
|
11
|
+
import { useRef } from '@wordpress/element';
|
|
11
12
|
|
|
12
13
|
export function PostVisibility() {
|
|
14
|
+
const rowRef = useRef();
|
|
13
15
|
return (
|
|
14
16
|
<PostVisibilityCheck
|
|
15
17
|
render={ ( { canEdit } ) => (
|
|
16
|
-
<PanelRow className="edit-post-post-visibility">
|
|
18
|
+
<PanelRow ref={ rowRef } className="edit-post-post-visibility">
|
|
17
19
|
<span>{ __( 'Visibility' ) }</span>
|
|
18
20
|
{ ! canEdit && (
|
|
19
21
|
<span>
|
|
@@ -24,6 +26,12 @@ export function PostVisibility() {
|
|
|
24
26
|
<Dropdown
|
|
25
27
|
position="bottom left"
|
|
26
28
|
contentClassName="edit-post-post-visibility__dialog"
|
|
29
|
+
popoverProps={ {
|
|
30
|
+
// Anchor the popover to the middle of the
|
|
31
|
+
// entire row so that it doesn't move around
|
|
32
|
+
// when the label changes.
|
|
33
|
+
anchorRef: rowRef.current,
|
|
34
|
+
} }
|
|
27
35
|
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
28
36
|
<Button
|
|
29
37
|
aria-expanded={ isOpen }
|
|
@@ -34,7 +42,9 @@ export function PostVisibility() {
|
|
|
34
42
|
<PostVisibilityLabel />
|
|
35
43
|
</Button>
|
|
36
44
|
) }
|
|
37
|
-
renderContent={ () =>
|
|
45
|
+
renderContent={ ( { onClose } ) => (
|
|
46
|
+
<PostVisibilityForm onClose={ onClose } />
|
|
47
|
+
) }
|
|
38
48
|
/>
|
|
39
49
|
) }
|
|
40
50
|
</PanelRow>
|
|
@@ -9,34 +9,6 @@
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.edit-post-post-visibility__dialog .components-popover__content {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
width: 257px;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.edit-post-post-visibility__dialog-legend {
|
|
19
|
-
font-weight: 600;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.edit-post-post-visibility__choice {
|
|
23
|
-
margin: 10px 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.edit-post-post-visibility__dialog-radio,
|
|
27
|
-
.edit-post-post-visibility__dialog-label {
|
|
28
|
-
vertical-align: top;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.edit-post-post-visibility__dialog-password-input {
|
|
32
|
-
width: calc(100% - 20px);
|
|
33
|
-
margin-left: 20px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.edit-post-post-visibility__dialog-info {
|
|
37
|
-
color: $gray-700;
|
|
38
|
-
padding-left: 20px;
|
|
39
|
-
font-style: italic;
|
|
40
|
-
margin: 4px 0 0;
|
|
41
|
-
line-height: 1.4;
|
|
12
|
+
// sidebar width - padding - horizontal borders
|
|
13
|
+
width: $sidebar-width - $grid-unit-20 - $border-width * 2;
|
|
42
14
|
}
|
|
@@ -30,11 +30,6 @@ function PatternSelection( { onChoosePattern } ) {
|
|
|
30
30
|
}, [] );
|
|
31
31
|
const shownBlockPatterns = useAsyncList( blockPatterns );
|
|
32
32
|
const { resetEditorBlocks } = useDispatch( editorStore );
|
|
33
|
-
useEffect( () => {
|
|
34
|
-
if ( blockPatterns.length <= 1 ) {
|
|
35
|
-
onChoosePattern();
|
|
36
|
-
}
|
|
37
|
-
}, [ blockPatterns.length ] );
|
|
38
33
|
return (
|
|
39
34
|
<BlockPatternsList
|
|
40
35
|
blockPatterns={ blockPatterns }
|
|
@@ -25,7 +25,14 @@ const unsupportedBlock = `
|
|
|
25
25
|
<!-- /wp:notablock -->
|
|
26
26
|
`;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
beforeAll( () => {
|
|
29
|
+
jest.useFakeTimers( 'legacy' );
|
|
30
|
+
} );
|
|
31
|
+
|
|
32
|
+
afterAll( () => {
|
|
33
|
+
jest.runOnlyPendingTimers();
|
|
34
|
+
jest.useRealTimers();
|
|
35
|
+
} );
|
|
29
36
|
|
|
30
37
|
describe( 'Editor', () => {
|
|
31
38
|
beforeAll( () => {
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.AdminNotices = void 0;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
|
-
var _notices = require("@wordpress/notices");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* WordPress dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Mapping of server-supported notice class names to an equivalent notices
|
|
20
|
-
* module status.
|
|
21
|
-
*
|
|
22
|
-
* @type {Map}
|
|
23
|
-
*/
|
|
24
|
-
const NOTICE_CLASS_STATUSES = {
|
|
25
|
-
'notice-success': 'success',
|
|
26
|
-
updated: 'success',
|
|
27
|
-
'notice-warning': 'warning',
|
|
28
|
-
'notice-error': 'error',
|
|
29
|
-
error: 'error',
|
|
30
|
-
'notice-info': 'info'
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Returns an array of admin notice Elements.
|
|
34
|
-
*
|
|
35
|
-
* @return {Element[]} Admin notice elements.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
function getAdminNotices() {
|
|
39
|
-
// The order is reversed to match expectations of rendered order, since a
|
|
40
|
-
// NoticesList is itself rendered in reverse order (newest to oldest).
|
|
41
|
-
return Array.from(document.querySelectorAll('#wpbody-content > .notice')).reverse();
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Given an admin notice Element, returns the relevant notice content HTML.
|
|
45
|
-
*
|
|
46
|
-
* @param {Element} element Admin notice element.
|
|
47
|
-
*
|
|
48
|
-
* @return {Element} Upgraded notice HTML.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
function getNoticeHTML(element) {
|
|
53
|
-
const fragments = [];
|
|
54
|
-
|
|
55
|
-
for (const child of element.childNodes) {
|
|
56
|
-
if (child.nodeType !== child.ELEMENT_NODE) {
|
|
57
|
-
const value = child.nodeValue.trim();
|
|
58
|
-
|
|
59
|
-
if (value) {
|
|
60
|
-
fragments.push(child.nodeValue);
|
|
61
|
-
}
|
|
62
|
-
} else if (!child.classList.contains('notice-dismiss')) {
|
|
63
|
-
fragments.push(child.outerHTML);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return fragments.join('');
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Given an admin notice Element, returns the upgraded status type, or
|
|
71
|
-
* undefined if one cannot be determined (i.e. one is not assigned).
|
|
72
|
-
*
|
|
73
|
-
* @param {Element} element Admin notice element.
|
|
74
|
-
*
|
|
75
|
-
* @return {?string} Upgraded status type.
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
function getNoticeStatus(element) {
|
|
80
|
-
for (const className of element.classList) {
|
|
81
|
-
if (NOTICE_CLASS_STATUSES.hasOwnProperty(className)) {
|
|
82
|
-
return NOTICE_CLASS_STATUSES[className];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
class AdminNotices extends _element.Component {
|
|
88
|
-
componentDidMount() {
|
|
89
|
-
this.convertNotices();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
convertNotices() {
|
|
93
|
-
const {
|
|
94
|
-
createNotice
|
|
95
|
-
} = this.props;
|
|
96
|
-
getAdminNotices().forEach(element => {
|
|
97
|
-
// Convert and create.
|
|
98
|
-
const status = getNoticeStatus(element);
|
|
99
|
-
const content = getNoticeHTML(element);
|
|
100
|
-
const isDismissible = element.classList.contains('is-dismissible');
|
|
101
|
-
createNotice(status, content, {
|
|
102
|
-
speak: false,
|
|
103
|
-
__unstableHTML: true,
|
|
104
|
-
isDismissible
|
|
105
|
-
}); // Remove (now-redundant) admin notice element.
|
|
106
|
-
|
|
107
|
-
element.parentNode.removeChild(element);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
render() {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
exports.AdminNotices = AdminNotices;
|
|
118
|
-
|
|
119
|
-
var _default = (0, _data.withDispatch)(dispatch => {
|
|
120
|
-
const {
|
|
121
|
-
createNotice
|
|
122
|
-
} = dispatch(_notices.store);
|
|
123
|
-
return {
|
|
124
|
-
createNotice
|
|
125
|
-
};
|
|
126
|
-
})(AdminNotices);
|
|
127
|
-
|
|
128
|
-
exports.default = _default;
|
|
129
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/admin-notices/index.js"],"names":["NOTICE_CLASS_STATUSES","updated","error","getAdminNotices","Array","from","document","querySelectorAll","reverse","getNoticeHTML","element","fragments","child","childNodes","nodeType","ELEMENT_NODE","value","nodeValue","trim","push","classList","contains","outerHTML","join","getNoticeStatus","className","hasOwnProperty","AdminNotices","Component","componentDidMount","convertNotices","createNotice","props","forEach","status","content","isDismissible","speak","__unstableHTML","parentNode","removeChild","render","dispatch","noticesStore"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,qBAAqB,GAAG;AAC7B,oBAAkB,SADW;AAE7BC,EAAAA,OAAO,EAAE,SAFoB;AAG7B,oBAAkB,SAHW;AAI7B,kBAAgB,OAJa;AAK7BC,EAAAA,KAAK,EAAE,OALsB;AAM7B,iBAAe;AANc,CAA9B;AASA;AACA;AACA;AACA;AACA;;AACA,SAASC,eAAT,GAA2B;AAC1B;AACA;AACA,SAAOC,KAAK,CAACC,IAAN,CACNC,QAAQ,CAACC,gBAAT,CAA2B,2BAA3B,CADM,EAELC,OAFK,EAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,aAAT,CAAwBC,OAAxB,EAAkC;AACjC,QAAMC,SAAS,GAAG,EAAlB;;AAEA,OAAM,MAAMC,KAAZ,IAAqBF,OAAO,CAACG,UAA7B,EAA0C;AACzC,QAAKD,KAAK,CAACE,QAAN,KAAmBF,KAAK,CAACG,YAA9B,EAA6C;AAC5C,YAAMC,KAAK,GAAGJ,KAAK,CAACK,SAAN,CAAgBC,IAAhB,EAAd;;AACA,UAAKF,KAAL,EAAa;AACZL,QAAAA,SAAS,CAACQ,IAAV,CAAgBP,KAAK,CAACK,SAAtB;AACA;AACD,KALD,MAKO,IAAK,CAAEL,KAAK,CAACQ,SAAN,CAAgBC,QAAhB,CAA0B,gBAA1B,CAAP,EAAsD;AAC5DV,MAAAA,SAAS,CAACQ,IAAV,CAAgBP,KAAK,CAACU,SAAtB;AACA;AACD;;AAED,SAAOX,SAAS,CAACY,IAAV,CAAgB,EAAhB,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,eAAT,CAA0Bd,OAA1B,EAAoC;AACnC,OAAM,MAAMe,SAAZ,IAAyBf,OAAO,CAACU,SAAjC,EAA6C;AAC5C,QAAKpB,qBAAqB,CAAC0B,cAAtB,CAAsCD,SAAtC,CAAL,EAAyD;AACxD,aAAOzB,qBAAqB,CAAEyB,SAAF,CAA5B;AACA;AACD;AACD;;AAEM,MAAME,YAAN,SAA2BC,kBAA3B,CAAqC;AAC3CC,EAAAA,iBAAiB,GAAG;AACnB,SAAKC,cAAL;AACA;;AAEDA,EAAAA,cAAc,GAAG;AAChB,UAAM;AAAEC,MAAAA;AAAF,QAAmB,KAAKC,KAA9B;AACA7B,IAAAA,eAAe,GAAG8B,OAAlB,CAA6BvB,OAAF,IAAe;AACzC;AACA,YAAMwB,MAAM,GAAGV,eAAe,CAAEd,OAAF,CAA9B;AACA,YAAMyB,OAAO,GAAG1B,aAAa,CAAEC,OAAF,CAA7B;AACA,YAAM0B,aAAa,GAAG1B,OAAO,CAACU,SAAR,CAAkBC,QAAlB,CACrB,gBADqB,CAAtB;AAGAU,MAAAA,YAAY,CAAEG,MAAF,EAAUC,OAAV,EAAmB;AAC9BE,QAAAA,KAAK,EAAE,KADuB;AAE9BC,QAAAA,cAAc,EAAE,IAFc;AAG9BF,QAAAA;AAH8B,OAAnB,CAAZ,CAPyC,CAazC;;AACA1B,MAAAA,OAAO,CAAC6B,UAAR,CAAmBC,WAAnB,CAAgC9B,OAAhC;AACA,KAfD;AAgBA;;AAED+B,EAAAA,MAAM,GAAG;AACR,WAAO,IAAP;AACA;;AA3B0C;;;;eA8B7B,wBAAgBC,QAAF,IAAgB;AAC5C,QAAM;AAAEX,IAAAA;AAAF,MAAmBW,QAAQ,CAAEC,cAAF,CAAjC;AAEA,SAAO;AAAEZ,IAAAA;AAAF,GAAP;AACA,CAJc,EAIVJ,YAJU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { withDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Mapping of server-supported notice class names to an equivalent notices\n * module status.\n *\n * @type {Map}\n */\nconst NOTICE_CLASS_STATUSES = {\n\t'notice-success': 'success',\n\tupdated: 'success',\n\t'notice-warning': 'warning',\n\t'notice-error': 'error',\n\terror: 'error',\n\t'notice-info': 'info',\n};\n\n/**\n * Returns an array of admin notice Elements.\n *\n * @return {Element[]} Admin notice elements.\n */\nfunction getAdminNotices() {\n\t// The order is reversed to match expectations of rendered order, since a\n\t// NoticesList is itself rendered in reverse order (newest to oldest).\n\treturn Array.from(\n\t\tdocument.querySelectorAll( '#wpbody-content > .notice' )\n\t).reverse();\n}\n\n/**\n * Given an admin notice Element, returns the relevant notice content HTML.\n *\n * @param {Element} element Admin notice element.\n *\n * @return {Element} Upgraded notice HTML.\n */\nfunction getNoticeHTML( element ) {\n\tconst fragments = [];\n\n\tfor ( const child of element.childNodes ) {\n\t\tif ( child.nodeType !== child.ELEMENT_NODE ) {\n\t\t\tconst value = child.nodeValue.trim();\n\t\t\tif ( value ) {\n\t\t\t\tfragments.push( child.nodeValue );\n\t\t\t}\n\t\t} else if ( ! child.classList.contains( 'notice-dismiss' ) ) {\n\t\t\tfragments.push( child.outerHTML );\n\t\t}\n\t}\n\n\treturn fragments.join( '' );\n}\n\n/**\n * Given an admin notice Element, returns the upgraded status type, or\n * undefined if one cannot be determined (i.e. one is not assigned).\n *\n * @param {Element} element Admin notice element.\n *\n * @return {?string} Upgraded status type.\n */\nfunction getNoticeStatus( element ) {\n\tfor ( const className of element.classList ) {\n\t\tif ( NOTICE_CLASS_STATUSES.hasOwnProperty( className ) ) {\n\t\t\treturn NOTICE_CLASS_STATUSES[ className ];\n\t\t}\n\t}\n}\n\nexport class AdminNotices extends Component {\n\tcomponentDidMount() {\n\t\tthis.convertNotices();\n\t}\n\n\tconvertNotices() {\n\t\tconst { createNotice } = this.props;\n\t\tgetAdminNotices().forEach( ( element ) => {\n\t\t\t// Convert and create.\n\t\t\tconst status = getNoticeStatus( element );\n\t\t\tconst content = getNoticeHTML( element );\n\t\t\tconst isDismissible = element.classList.contains(\n\t\t\t\t'is-dismissible'\n\t\t\t);\n\t\t\tcreateNotice( status, content, {\n\t\t\t\tspeak: false,\n\t\t\t\t__unstableHTML: true,\n\t\t\t\tisDismissible,\n\t\t\t} );\n\n\t\t\t// Remove (now-redundant) admin notice element.\n\t\t\telement.parentNode.removeChild( element );\n\t\t} );\n\t}\n\n\trender() {\n\t\treturn null;\n\t}\n}\n\nexport default withDispatch( ( dispatch ) => {\n\tconst { createNotice } = dispatch( noticesStore );\n\n\treturn { createNotice };\n} )( AdminNotices );\n"]}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = BlockManagerShowAll;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _compose = require("@wordpress/compose");
|
|
11
|
-
|
|
12
|
-
var _components = require("@wordpress/components");
|
|
13
|
-
|
|
14
|
-
var _i18n = require("@wordpress/i18n");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
function BlockManagerShowAll(_ref) {
|
|
20
|
-
let {
|
|
21
|
-
checked,
|
|
22
|
-
onChange
|
|
23
|
-
} = _ref;
|
|
24
|
-
const instanceId = (0, _compose.useInstanceId)(BlockManagerShowAll);
|
|
25
|
-
const id = 'edit-post-block-manager__show-all-' + instanceId;
|
|
26
|
-
return (0, _element.createElement)("div", {
|
|
27
|
-
className: "edit-post-block-manager__show-all"
|
|
28
|
-
}, (0, _element.createElement)("label", {
|
|
29
|
-
htmlFor: id,
|
|
30
|
-
className: "edit-post-block-manager__show-all-label"
|
|
31
|
-
},
|
|
32
|
-
/* translators: Checkbox toggle label */
|
|
33
|
-
(0, _i18n.__)('Show section')), (0, _element.createElement)(_components.FormToggle, {
|
|
34
|
-
id: id,
|
|
35
|
-
checked: checked,
|
|
36
|
-
onChange: event => onChange(event.target.checked)
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=show-all.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/block-manager/show-all.js"],"names":["BlockManagerShowAll","checked","onChange","instanceId","id","event","target"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKe,SAASA,mBAAT,OAAsD;AAAA,MAAxB;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,GAAwB;AACpE,QAAMC,UAAU,GAAG,4BAAeH,mBAAf,CAAnB;AACA,QAAMI,EAAE,GAAG,uCAAuCD,UAAlD;AAEA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AACC,IAAA,OAAO,EAAGC,EADX;AAEC,IAAA,SAAS,EAAC;AAFX;AAKE;AACA,gBAAI,cAAJ,CANF,CADD,EAUC,4BAAC,sBAAD;AACC,IAAA,EAAE,EAAGA,EADN;AAEC,IAAA,OAAO,EAAGH,OAFX;AAGC,IAAA,QAAQ,EAAKI,KAAF,IAAaH,QAAQ,CAAEG,KAAK,CAACC,MAAN,CAAaL,OAAf;AAHjC,IAVD,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { FormToggle } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nexport default function BlockManagerShowAll( { checked, onChange } ) {\n\tconst instanceId = useInstanceId( BlockManagerShowAll );\n\tconst id = 'edit-post-block-manager__show-all-' + instanceId;\n\n\treturn (\n\t\t<div className=\"edit-post-block-manager__show-all\">\n\t\t\t<label\n\t\t\t\thtmlFor={ id }\n\t\t\t\tclassName=\"edit-post-block-manager__show-all-label\"\n\t\t\t>\n\t\t\t\t{\n\t\t\t\t\t/* translators: Checkbox toggle label */\n\t\t\t\t\t__( 'Show section' )\n\t\t\t\t}\n\t\t\t</label>\n\t\t\t<FormToggle\n\t\t\t\tid={ id }\n\t\t\t\tchecked={ checked }\n\t\t\t\tonChange={ ( event ) => onChange( event.target.checked ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.onChangeListener = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Given a selector returns a functions that returns the listener only
|
|
10
|
-
* if the returned value from the selector changes.
|
|
11
|
-
*
|
|
12
|
-
* @param {Function} selector Selector.
|
|
13
|
-
* @param {Function} listener Listener.
|
|
14
|
-
* @param {boolean} initial Flags whether listener should be invoked on
|
|
15
|
-
* initial call.
|
|
16
|
-
*
|
|
17
|
-
* @return {Function} Listener creator.
|
|
18
|
-
*/
|
|
19
|
-
const onChangeListener = function (selector, listener) {
|
|
20
|
-
let initial = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
21
|
-
let previousValue = selector();
|
|
22
|
-
|
|
23
|
-
if (initial) {
|
|
24
|
-
listener(selector());
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return () => {
|
|
28
|
-
const selectedValue = selector();
|
|
29
|
-
|
|
30
|
-
if (selectedValue !== previousValue) {
|
|
31
|
-
previousValue = selectedValue;
|
|
32
|
-
listener(selectedValue);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
exports.onChangeListener = onChangeListener;
|
|
38
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/editor-initialization/utils.js"],"names":["onChangeListener","selector","listener","initial","previousValue","selectedValue"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAG,UAAEC,QAAF,EAAYC,QAAZ,EAA2C;AAAA,MAArBC,OAAqB,uEAAX,KAAW;AAC1E,MAAIC,aAAa,GAAGH,QAAQ,EAA5B;;AACA,MAAKE,OAAL,EAAe;AACdD,IAAAA,QAAQ,CAAED,QAAQ,EAAV,CAAR;AACA;;AACD,SAAO,MAAM;AACZ,UAAMI,aAAa,GAAGJ,QAAQ,EAA9B;;AACA,QAAKI,aAAa,KAAKD,aAAvB,EAAuC;AACtCA,MAAAA,aAAa,GAAGC,aAAhB;AACAH,MAAAA,QAAQ,CAAEG,aAAF,CAAR;AACA;AACD,GAND;AAOA,CAZM","sourcesContent":["/**\n * Given a selector returns a functions that returns the listener only\n * if the returned value from the selector changes.\n *\n * @param {Function} selector Selector.\n * @param {Function} listener Listener.\n * @param {boolean} initial Flags whether listener should be invoked on\n * initial call.\n *\n * @return {Function} Listener creator.\n */\nexport const onChangeListener = ( selector, listener, initial = false ) => {\n\tlet previousValue = selector();\n\tif ( initial ) {\n\t\tlistener( selector() );\n\t}\n\treturn () => {\n\t\tconst selectedValue = selector();\n\t\tif ( selectedValue !== previousValue ) {\n\t\t\tpreviousValue = selectedValue;\n\t\t\tlistener( selectedValue );\n\t\t}\n\t};\n};\n"]}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Component } from '@wordpress/element';
|
|
5
|
-
import { withDispatch } from '@wordpress/data';
|
|
6
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
7
|
-
/**
|
|
8
|
-
* Mapping of server-supported notice class names to an equivalent notices
|
|
9
|
-
* module status.
|
|
10
|
-
*
|
|
11
|
-
* @type {Map}
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const NOTICE_CLASS_STATUSES = {
|
|
15
|
-
'notice-success': 'success',
|
|
16
|
-
updated: 'success',
|
|
17
|
-
'notice-warning': 'warning',
|
|
18
|
-
'notice-error': 'error',
|
|
19
|
-
error: 'error',
|
|
20
|
-
'notice-info': 'info'
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Returns an array of admin notice Elements.
|
|
24
|
-
*
|
|
25
|
-
* @return {Element[]} Admin notice elements.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
function getAdminNotices() {
|
|
29
|
-
// The order is reversed to match expectations of rendered order, since a
|
|
30
|
-
// NoticesList is itself rendered in reverse order (newest to oldest).
|
|
31
|
-
return Array.from(document.querySelectorAll('#wpbody-content > .notice')).reverse();
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Given an admin notice Element, returns the relevant notice content HTML.
|
|
35
|
-
*
|
|
36
|
-
* @param {Element} element Admin notice element.
|
|
37
|
-
*
|
|
38
|
-
* @return {Element} Upgraded notice HTML.
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function getNoticeHTML(element) {
|
|
43
|
-
const fragments = [];
|
|
44
|
-
|
|
45
|
-
for (const child of element.childNodes) {
|
|
46
|
-
if (child.nodeType !== child.ELEMENT_NODE) {
|
|
47
|
-
const value = child.nodeValue.trim();
|
|
48
|
-
|
|
49
|
-
if (value) {
|
|
50
|
-
fragments.push(child.nodeValue);
|
|
51
|
-
}
|
|
52
|
-
} else if (!child.classList.contains('notice-dismiss')) {
|
|
53
|
-
fragments.push(child.outerHTML);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return fragments.join('');
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Given an admin notice Element, returns the upgraded status type, or
|
|
61
|
-
* undefined if one cannot be determined (i.e. one is not assigned).
|
|
62
|
-
*
|
|
63
|
-
* @param {Element} element Admin notice element.
|
|
64
|
-
*
|
|
65
|
-
* @return {?string} Upgraded status type.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
function getNoticeStatus(element) {
|
|
70
|
-
for (const className of element.classList) {
|
|
71
|
-
if (NOTICE_CLASS_STATUSES.hasOwnProperty(className)) {
|
|
72
|
-
return NOTICE_CLASS_STATUSES[className];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export class AdminNotices extends Component {
|
|
78
|
-
componentDidMount() {
|
|
79
|
-
this.convertNotices();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
convertNotices() {
|
|
83
|
-
const {
|
|
84
|
-
createNotice
|
|
85
|
-
} = this.props;
|
|
86
|
-
getAdminNotices().forEach(element => {
|
|
87
|
-
// Convert and create.
|
|
88
|
-
const status = getNoticeStatus(element);
|
|
89
|
-
const content = getNoticeHTML(element);
|
|
90
|
-
const isDismissible = element.classList.contains('is-dismissible');
|
|
91
|
-
createNotice(status, content, {
|
|
92
|
-
speak: false,
|
|
93
|
-
__unstableHTML: true,
|
|
94
|
-
isDismissible
|
|
95
|
-
}); // Remove (now-redundant) admin notice element.
|
|
96
|
-
|
|
97
|
-
element.parentNode.removeChild(element);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
render() {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
export default withDispatch(dispatch => {
|
|
107
|
-
const {
|
|
108
|
-
createNotice
|
|
109
|
-
} = dispatch(noticesStore);
|
|
110
|
-
return {
|
|
111
|
-
createNotice
|
|
112
|
-
};
|
|
113
|
-
})(AdminNotices);
|
|
114
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/admin-notices/index.js"],"names":["Component","withDispatch","store","noticesStore","NOTICE_CLASS_STATUSES","updated","error","getAdminNotices","Array","from","document","querySelectorAll","reverse","getNoticeHTML","element","fragments","child","childNodes","nodeType","ELEMENT_NODE","value","nodeValue","trim","push","classList","contains","outerHTML","join","getNoticeStatus","className","hasOwnProperty","AdminNotices","componentDidMount","convertNotices","createNotice","props","forEach","status","content","isDismissible","speak","__unstableHTML","parentNode","removeChild","render","dispatch"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { withDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Mapping of server-supported notice class names to an equivalent notices\n * module status.\n *\n * @type {Map}\n */\nconst NOTICE_CLASS_STATUSES = {\n\t'notice-success': 'success',\n\tupdated: 'success',\n\t'notice-warning': 'warning',\n\t'notice-error': 'error',\n\terror: 'error',\n\t'notice-info': 'info',\n};\n\n/**\n * Returns an array of admin notice Elements.\n *\n * @return {Element[]} Admin notice elements.\n */\nfunction getAdminNotices() {\n\t// The order is reversed to match expectations of rendered order, since a\n\t// NoticesList is itself rendered in reverse order (newest to oldest).\n\treturn Array.from(\n\t\tdocument.querySelectorAll( '#wpbody-content > .notice' )\n\t).reverse();\n}\n\n/**\n * Given an admin notice Element, returns the relevant notice content HTML.\n *\n * @param {Element} element Admin notice element.\n *\n * @return {Element} Upgraded notice HTML.\n */\nfunction getNoticeHTML( element ) {\n\tconst fragments = [];\n\n\tfor ( const child of element.childNodes ) {\n\t\tif ( child.nodeType !== child.ELEMENT_NODE ) {\n\t\t\tconst value = child.nodeValue.trim();\n\t\t\tif ( value ) {\n\t\t\t\tfragments.push( child.nodeValue );\n\t\t\t}\n\t\t} else if ( ! child.classList.contains( 'notice-dismiss' ) ) {\n\t\t\tfragments.push( child.outerHTML );\n\t\t}\n\t}\n\n\treturn fragments.join( '' );\n}\n\n/**\n * Given an admin notice Element, returns the upgraded status type, or\n * undefined if one cannot be determined (i.e. one is not assigned).\n *\n * @param {Element} element Admin notice element.\n *\n * @return {?string} Upgraded status type.\n */\nfunction getNoticeStatus( element ) {\n\tfor ( const className of element.classList ) {\n\t\tif ( NOTICE_CLASS_STATUSES.hasOwnProperty( className ) ) {\n\t\t\treturn NOTICE_CLASS_STATUSES[ className ];\n\t\t}\n\t}\n}\n\nexport class AdminNotices extends Component {\n\tcomponentDidMount() {\n\t\tthis.convertNotices();\n\t}\n\n\tconvertNotices() {\n\t\tconst { createNotice } = this.props;\n\t\tgetAdminNotices().forEach( ( element ) => {\n\t\t\t// Convert and create.\n\t\t\tconst status = getNoticeStatus( element );\n\t\t\tconst content = getNoticeHTML( element );\n\t\t\tconst isDismissible = element.classList.contains(\n\t\t\t\t'is-dismissible'\n\t\t\t);\n\t\t\tcreateNotice( status, content, {\n\t\t\t\tspeak: false,\n\t\t\t\t__unstableHTML: true,\n\t\t\t\tisDismissible,\n\t\t\t} );\n\n\t\t\t// Remove (now-redundant) admin notice element.\n\t\t\telement.parentNode.removeChild( element );\n\t\t} );\n\t}\n\n\trender() {\n\t\treturn null;\n\t}\n}\n\nexport default withDispatch( ( dispatch ) => {\n\tconst { createNotice } = dispatch( noticesStore );\n\n\treturn { createNotice };\n} )( AdminNotices );\n"]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { useInstanceId } from '@wordpress/compose';
|
|
7
|
-
import { FormToggle } from '@wordpress/components';
|
|
8
|
-
import { __ } from '@wordpress/i18n';
|
|
9
|
-
export default function BlockManagerShowAll(_ref) {
|
|
10
|
-
let {
|
|
11
|
-
checked,
|
|
12
|
-
onChange
|
|
13
|
-
} = _ref;
|
|
14
|
-
const instanceId = useInstanceId(BlockManagerShowAll);
|
|
15
|
-
const id = 'edit-post-block-manager__show-all-' + instanceId;
|
|
16
|
-
return createElement("div", {
|
|
17
|
-
className: "edit-post-block-manager__show-all"
|
|
18
|
-
}, createElement("label", {
|
|
19
|
-
htmlFor: id,
|
|
20
|
-
className: "edit-post-block-manager__show-all-label"
|
|
21
|
-
},
|
|
22
|
-
/* translators: Checkbox toggle label */
|
|
23
|
-
__('Show section')), createElement(FormToggle, {
|
|
24
|
-
id: id,
|
|
25
|
-
checked: checked,
|
|
26
|
-
onChange: event => onChange(event.target.checked)
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=show-all.js.map
|