@wordpress/customize-widgets 4.15.0 → 4.17.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 +4 -0
- package/build/components/block-appender/index.js +6 -8
- package/build/components/block-appender/index.js.map +1 -1
- package/build/components/block-inspector-button/index.js +3 -9
- package/build/components/block-inspector-button/index.js.map +1 -1
- package/build/components/customize-widgets/index.js +4 -12
- package/build/components/customize-widgets/index.js.map +1 -1
- package/build/components/customize-widgets/use-clear-selected-block.js +12 -15
- package/build/components/customize-widgets/use-clear-selected-block.js.map +1 -1
- package/build/components/error-boundary/index.js +1 -14
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/focus-control/index.js +1 -12
- package/build/components/focus-control/index.js.map +1 -1
- package/build/components/focus-control/use-blocks-focus-control.js +3 -9
- package/build/components/focus-control/use-blocks-focus-control.js.map +1 -1
- package/build/components/header/index.js +7 -18
- package/build/components/header/index.js.map +1 -1
- package/build/components/inserter/index.js +1 -10
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/use-inserter.js +1 -6
- package/build/components/inserter/use-inserter.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +1 -2
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -9
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +4 -20
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +1 -6
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -16
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/more-menu/index.js +2 -15
- package/build/components/more-menu/index.js.map +1 -1
- package/build/components/sidebar-block-editor/index.js +5 -22
- package/build/components/sidebar-block-editor/index.js.map +1 -1
- package/build/components/sidebar-block-editor/sidebar-adapter.js +13 -75
- package/build/components/sidebar-block-editor/sidebar-adapter.js.map +1 -1
- package/build/components/sidebar-block-editor/sidebar-editor-provider.js +1 -8
- package/build/components/sidebar-block-editor/sidebar-editor-provider.js.map +1 -1
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.js +14 -24
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.js.map +1 -1
- package/build/components/sidebar-controls/index.js +1 -5
- package/build/components/sidebar-controls/index.js.map +1 -1
- package/build/components/welcome-guide/index.js +1 -6
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/controls/inserter-outer-section.js +15 -24
- package/build/controls/inserter-outer-section.js.map +1 -1
- package/build/controls/inspector-section.js +0 -12
- package/build/controls/inspector-section.js.map +1 -1
- package/build/controls/sidebar-control.js +1 -12
- package/build/controls/sidebar-control.js.map +1 -1
- package/build/controls/sidebar-section.js +3 -14
- package/build/controls/sidebar-section.js.map +1 -1
- package/build/filters/index.js +0 -2
- package/build/filters/index.js.map +1 -1
- package/build/filters/move-to-sidebar.js +7 -17
- package/build/filters/move-to-sidebar.js.map +1 -1
- package/build/filters/replace-media-upload.js +1 -3
- package/build/filters/replace-media-upload.js.map +1 -1
- package/build/filters/wide-widget-display.js +3 -5
- package/build/filters/wide-widget-display.js.map +1 -1
- package/build/index.js +5 -20
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +1 -2
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +0 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +0 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +1 -10
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +0 -5
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +9 -10
- package/build/store/selectors.js.map +1 -1
- package/build/utils.js +8 -18
- package/build/utils.js.map +1 -1
- package/build-module/components/block-appender/index.js +5 -5
- package/build-module/components/block-appender/index.js.map +1 -1
- package/build-module/components/block-inspector-button/index.js +2 -5
- package/build-module/components/block-inspector-button/index.js.map +1 -1
- package/build-module/components/customize-widgets/index.js +4 -4
- package/build-module/components/customize-widgets/index.js.map +1 -1
- package/build-module/components/customize-widgets/use-clear-selected-block.js +13 -12
- package/build-module/components/customize-widgets/use-clear-selected-block.js.map +1 -1
- package/build-module/components/error-boundary/index.js +0 -8
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/focus-control/index.js +1 -8
- package/build-module/components/focus-control/index.js.map +1 -1
- package/build-module/components/focus-control/use-blocks-focus-control.js +3 -4
- package/build-module/components/focus-control/use-blocks-focus-control.js.map +1 -1
- package/build-module/components/header/index.js +8 -11
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/inserter/index.js +1 -4
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/use-inserter.js +1 -3
- package/build-module/components/inserter/use-inserter.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -6
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +5 -13
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +0 -5
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +0 -9
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/more-menu/index.js +2 -6
- package/build-module/components/more-menu/index.js.map +1 -1
- package/build-module/components/sidebar-block-editor/index.js +5 -9
- package/build-module/components/sidebar-block-editor/index.js.map +1 -1
- package/build-module/components/sidebar-block-editor/sidebar-adapter.js +12 -72
- package/build-module/components/sidebar-block-editor/sidebar-adapter.js.map +1 -1
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js +1 -2
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js.map +1 -1
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js +15 -20
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js.map +1 -1
- package/build-module/components/sidebar-controls/index.js +0 -1
- package/build-module/components/sidebar-controls/index.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +0 -1
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/controls/inserter-outer-section.js +15 -20
- package/build-module/controls/inserter-outer-section.js.map +1 -1
- package/build-module/controls/inspector-section.js +0 -11
- package/build-module/controls/inspector-section.js.map +1 -1
- package/build-module/controls/sidebar-control.js +1 -8
- package/build-module/controls/sidebar-control.js.map +1 -1
- package/build-module/controls/sidebar-section.js +3 -12
- package/build-module/controls/sidebar-section.js.map +1 -1
- package/build-module/filters/index.js.map +1 -1
- package/build-module/filters/move-to-sidebar.js +7 -10
- package/build-module/filters/move-to-sidebar.js.map +1 -1
- package/build-module/filters/replace-media-upload.js +0 -2
- package/build-module/filters/replace-media-upload.js.map +1 -1
- package/build-module/filters/wide-widget-display.js +2 -3
- package/build-module/filters/wide-widget-display.js.map +1 -1
- package/build-module/index.js +5 -10
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js +3 -3
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +1 -3
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +10 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils.js +9 -14
- package/build-module/utils.js.map +1 -1
- package/package.json +22 -22
- package/src/store/selectors.js +10 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["__","Button","ExternalLink","useDispatch","store","preferencesStore","WelcomeGuide","sidebar","toggle","isEntirelyBlockWidgets","getWidgets","every","widget","id","startsWith","createElement","className","srcSet","media","src","width","height","alt","variant","onClick","href"],"sources":["@wordpress/customize-widgets/src/components/welcome-guide/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button, ExternalLink } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nexport default function WelcomeGuide( { sidebar } ) {\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\tconst isEntirelyBlockWidgets = sidebar\n\t\t.getWidgets()\n\t\t.every( ( widget ) => widget.id.startsWith( 'block-' ) );\n\n\treturn (\n\t\t<div className=\"customize-widgets-welcome-guide\">\n\t\t\t<div className=\"customize-widgets-welcome-guide__image__wrapper\">\n\t\t\t\t<picture>\n\t\t\t\t\t<source\n\t\t\t\t\t\tsrcSet=\"https://s.w.org/images/block-editor/welcome-editor.svg\"\n\t\t\t\t\t\tmedia=\"(prefers-reduced-motion: reduce)\"\n\t\t\t\t\t/>\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName=\"customize-widgets-welcome-guide__image\"\n\t\t\t\t\t\tsrc=\"https://s.w.org/images/block-editor/welcome-editor.gif\"\n\t\t\t\t\t\twidth=\"312\"\n\t\t\t\t\t\theight=\"240\"\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t/>\n\t\t\t\t</picture>\n\t\t\t</div>\n\t\t\t<h1 className=\"customize-widgets-welcome-guide__heading\">\n\t\t\t\t{ __( 'Welcome to block Widgets' ) }\n\t\t\t</h1>\n\t\t\t<p className=\"customize-widgets-welcome-guide__text\">\n\t\t\t\t{ isEntirelyBlockWidgets\n\t\t\t\t\t? __(\n\t\t\t\t\t\t\t'Your theme provides different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.'\n\t\t\t\t\t )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.'\n\t\t\t\t\t ) }\n\t\t\t</p>\n\t\t\t<Button\n\t\t\t\tclassName=\"customize-widgets-welcome-guide__button\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ () =>\n\t\t\t\t\ttoggle( 'core/customize-widgets', 'welcomeGuide' )\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ __( 'Got it' ) }\n\t\t\t</Button>\n\t\t\t<hr className=\"customize-widgets-welcome-guide__separator\" />\n\t\t\t{ ! isEntirelyBlockWidgets && (\n\t\t\t\t<p className=\"customize-widgets-welcome-guide__more-info\">\n\t\t\t\t\t{ __( 'Want to stick with the old widgets?' ) }\n\t\t\t\t\t<br />\n\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t'https://wordpress.org/plugins/classic-widgets/'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Get the Classic Widgets plugin.' ) }\n\t\t\t\t\t</ExternalLink>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t<p className=\"customize-widgets-welcome-guide__more-info\">\n\t\t\t\t{ __( 'New to the block editor?' ) }\n\t\t\t\t<br />\n\t\t\t\t<ExternalLink\n\t\t\t\t\thref={ __(\n\t\t\t\t\t\t'https://wordpress.org/documentation/article/wordpress-block-editor/'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ __( \"Here's a detailed guide.\" ) }\n\t\t\t\t</ExternalLink>\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,MAAM,EAAEC,YAAY,QAAQ,uBAAuB;AAC5D,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;AAElE,eAAe,SAASC,YAAYA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACnD,MAAM;IAAEC;EAAO,CAAC,GAAGL,WAAW,CAAEE,gBAAiB,CAAC;E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AClCe,aAAA,WAAK,CAAC,EACNA,aAAA,CAACb,YAAY;IACZuB,IAAI,EAAGzB,EAAE,CACR,qEACD;EAAG,GAEDA,EAAE,CAAE,0BAA2B,CACpB,CACZ,CACC,CAAC;AAER"}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
5
5
|
import { focus } from '@wordpress/dom';
|
|
6
6
|
import { dispatch } from '@wordpress/data';
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
11
|
import { store as customizeWidgetsStore } from '../store';
|
|
12
12
|
export default function getInserterOuterSection() {
|
|
13
13
|
const {
|
|
@@ -15,10 +15,10 @@ export default function getInserterOuterSection() {
|
|
|
15
15
|
customize
|
|
16
16
|
}
|
|
17
17
|
} = window;
|
|
18
|
-
const OuterSection = customize.OuterSection;
|
|
18
|
+
const OuterSection = customize.OuterSection;
|
|
19
|
+
// Override the OuterSection class to handle multiple outer sections.
|
|
19
20
|
// It closes all the other outer sections whenever one is opened.
|
|
20
21
|
// The result is that at most one outer section can be opened at the same time.
|
|
21
|
-
|
|
22
22
|
customize.OuterSection = class extends OuterSection {
|
|
23
23
|
onChangeExpanded(expanded, args) {
|
|
24
24
|
if (expanded) {
|
|
@@ -30,44 +30,44 @@ export default function getInserterOuterSection() {
|
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
|
|
34
33
|
return super.onChangeExpanded(expanded, args);
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
};
|
|
36
|
+
// Handle constructor so that "params.type" can be correctly pointed to "outer".
|
|
39
37
|
customize.sectionConstructor.outer = customize.OuterSection;
|
|
40
38
|
return class InserterOuterSection extends customize.OuterSection {
|
|
41
39
|
constructor(...args) {
|
|
42
|
-
super(...args);
|
|
43
|
-
// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436
|
|
40
|
+
super(...args);
|
|
44
41
|
|
|
42
|
+
// This is necessary since we're creating a new class which is not identical to the original OuterSection.
|
|
43
|
+
// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436
|
|
45
44
|
this.params.type = 'outer';
|
|
46
45
|
this.activeElementBeforeExpanded = null;
|
|
47
|
-
const ownerWindow = this.contentContainer[0].ownerDocument.defaultView;
|
|
46
|
+
const ownerWindow = this.contentContainer[0].ownerDocument.defaultView;
|
|
48
47
|
|
|
48
|
+
// Handle closing the inserter when pressing the Escape key.
|
|
49
49
|
ownerWindow.addEventListener('keydown', event => {
|
|
50
50
|
if (this.expanded() && (event.keyCode === ESCAPE || event.code === 'Escape') && !event.defaultPrevented) {
|
|
51
51
|
event.preventDefault();
|
|
52
52
|
event.stopPropagation();
|
|
53
53
|
dispatch(customizeWidgetsStore).setIsInserterOpened(false);
|
|
54
54
|
}
|
|
55
|
-
},
|
|
55
|
+
},
|
|
56
|
+
// Use capture mode to make this run before other event listeners.
|
|
56
57
|
true);
|
|
57
|
-
this.contentContainer.addClass('widgets-inserter');
|
|
58
|
-
// Don't propagate the event if it's an internal action to prevent infinite loop.
|
|
58
|
+
this.contentContainer.addClass('widgets-inserter');
|
|
59
59
|
|
|
60
|
+
// Set a flag if the state is being changed from open() or close().
|
|
61
|
+
// Don't propagate the event if it's an internal action to prevent infinite loop.
|
|
60
62
|
this.isFromInternalAction = false;
|
|
61
63
|
this.expanded.bind(() => {
|
|
62
64
|
if (!this.isFromInternalAction) {
|
|
63
65
|
// Propagate the event to React to sync the state.
|
|
64
66
|
dispatch(customizeWidgetsStore).setIsInserterOpened(this.expanded());
|
|
65
67
|
}
|
|
66
|
-
|
|
67
68
|
this.isFromInternalAction = false;
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
|
-
|
|
71
71
|
open() {
|
|
72
72
|
if (!this.expanded()) {
|
|
73
73
|
const contentContainer = this.contentContainer[0];
|
|
@@ -79,16 +79,13 @@ export default function getInserterOuterSection() {
|
|
|
79
79
|
// The first one should be the close button,
|
|
80
80
|
// we want to skip it and choose the second one instead, which is the search box.
|
|
81
81
|
const searchBox = focus.tabbable.find(contentContainer)[1];
|
|
82
|
-
|
|
83
82
|
if (searchBox) {
|
|
84
83
|
searchBox.focus();
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
|
-
|
|
88
86
|
});
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
|
-
|
|
92
89
|
close() {
|
|
93
90
|
if (this.expanded()) {
|
|
94
91
|
const contentContainer = this.contentContainer[0];
|
|
@@ -108,11 +105,9 @@ export default function getInserterOuterSection() {
|
|
|
108
105
|
}
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
|
-
|
|
112
108
|
});
|
|
113
109
|
}
|
|
114
110
|
}
|
|
115
|
-
|
|
116
111
|
};
|
|
117
112
|
}
|
|
118
113
|
//# sourceMappingURL=inserter-outer-section.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["ESCAPE","focus","dispatch","store","customizeWidgetsStore","getInserterOuterSection","wp","customize","window","OuterSection","onChangeExpanded","expanded","args","section","each","params","type","id","collapse","sectionConstructor","outer","InserterOuterSection","constructor","activeElementBeforeExpanded","ownerWindow","contentContainer","ownerDocument","defaultView","addEventListener","event","keyCode","code","defaultPrevented","preventDefault","stopPropagation","setIsInserterOpened","addClass","isFromInternalAction","bind","open","activeElement","expand","completeCallback","searchBox","tabbable","find","close","contains"],"sources":["@wordpress/customize-widgets/src/controls/inserter-outer-section.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as customizeWidgetsStore } from '../store';\n\nexport default function getInserterOuterSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\tconst OuterSection = customize.OuterSection;\n\t// Override the OuterSection class to handle multiple outer sections.\n\t// It closes all the other outer sections whenever one is opened.\n\t// The result is that at most one outer section can be opened at the same time.\n\tcustomize.OuterSection = class extends OuterSection {\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tif ( expanded ) {\n\t\t\t\tcustomize.section.each( ( section ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tsection.params.type === 'outer' &&\n\t\t\t\t\t\tsection.id !== this.id\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ( section.expanded() ) {\n\t\t\t\t\t\t\tsection.collapse();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn super.onChangeExpanded( expanded, args );\n\t\t}\n\t};\n\t// Handle constructor so that \"params.type\" can be correctly pointed to \"outer\".\n\tcustomize.sectionConstructor.outer = customize.OuterSection;\n\n\treturn class InserterOuterSection extends customize.OuterSection {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\t// This is necessary since we're creating a new class which is not identical to the original OuterSection.\n\t\t\t// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436\n\t\t\tthis.params.type = 'outer';\n\n\t\t\tthis.activeElementBeforeExpanded = null;\n\n\t\t\tconst ownerWindow =\n\t\t\t\tthis.contentContainer[ 0 ].ownerDocument.defaultView;\n\n\t\t\t// Handle closing the inserter when pressing the Escape key.\n\t\t\townerWindow.addEventListener(\n\t\t\t\t'keydown',\n\t\t\t\t( event ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.expanded() &&\n\t\t\t\t\t\t( event.keyCode === ESCAPE ||\n\t\t\t\t\t\t\tevent.code === 'Escape' ) &&\n\t\t\t\t\t\t! event.defaultPrevented\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t// Use capture mode to make this run before other event listeners.\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tthis.contentContainer.addClass( 'widgets-inserter' );\n\n\t\t\t// Set a flag if the state is being changed from open() or close().\n\t\t\t// Don't propagate the event if it's an internal action to prevent infinite loop.\n\t\t\tthis.isFromInternalAction = false;\n\t\t\tthis.expanded.bind( () => {\n\t\t\t\tif ( ! this.isFromInternalAction ) {\n\t\t\t\t\t// Propagate the event to React to sync the state.\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tthis.expanded()\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.isFromInternalAction = false;\n\t\t\t} );\n\t\t}\n\t\topen() {\n\t\t\tif ( ! this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tthis.activeElementBeforeExpanded =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.expand( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// We have to do this in a \"completeCallback\" or else the elements will not yet be visible/tabbable.\n\t\t\t\t\t\t// The first one should be the close button,\n\t\t\t\t\t\t// we want to skip it and choose the second one instead, which is the search box.\n\t\t\t\t\t\tconst searchBox =\n\t\t\t\t\t\t\tfocus.tabbable.find( contentContainer )[ 1 ];\n\t\t\t\t\t\tif ( searchBox ) {\n\t\t\t\t\t\t\tsearchBox.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t\tclose() {\n\t\t\tif ( this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tconst activeElement =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.collapse( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t// Only do this if the active element which triggers the action is inside the inserter,\n\t\t\t\t\t\t// (the close button for instance). In that case the focus will be lost.\n\t\t\t\t\t\t// Otherwise, we don't hijack the focus when the user is focusing on other elements\n\t\t\t\t\t\t// (like the quick inserter).\n\t\t\t\t\t\tif ( contentContainer.contains( activeElement ) ) {\n\t\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t\tif ( this.activeElementBeforeExpanded ) {\n\t\t\t\t\t\t\t\tthis.activeElementBeforeExpanded.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,QAAQ,QAAQ,iBAAiB;;AAE1C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,qBAAqB,QAAQ,UAAU;AAEzD,eAAe,SAASC,uBAAuBA,CAAA,EAAG;EACjD,MAAM;IACLC,EAAE,EAAE;MAAEC;IAAU;EACjB,CAAC,GAAGC,MAAM;EAEV,MAAMC,YAAY,GAAGF,SAAS,CAACE,YAAY;EAC3C;EACA;EACA;EACAF,SAAS,CAACE,YAAY,GAAG,cAAcA,YAAY,CAAC;IACnDC,gBAAgBA,CAAEC,QAAQ,EAAEC,IAAI,EAAG;MAClC,IAAKD,QAAQ,EAAG;QACfJ,SAAS,CAACM,OAAO,CAACC,IAAI,CAAID,OAAO,IAAM;UACtC,IACCA,OAAO,CAACE,MAAM,CAACC,IAAI,KAAK,OAAO,IAC/BH,OAAO,CAACI,EAA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;QACD,CAAE,CAAC;MACJ;IACD;EACD,CAAC;AACF"}
|
|
@@ -11,27 +11,21 @@ export default function getInspectorSection() {
|
|
|
11
11
|
this.returnFocusWhenClose = null;
|
|
12
12
|
this._isOpen = false;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
14
|
get isOpen() {
|
|
16
15
|
return this._isOpen;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
set isOpen(value) {
|
|
20
18
|
this._isOpen = value;
|
|
21
19
|
this.triggerActiveCallbacks();
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
ready() {
|
|
25
22
|
this.contentContainer[0].classList.add('customize-widgets-layout__inspector');
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
isContextuallyActive() {
|
|
29
25
|
return this.isOpen;
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
onChangeExpanded(expanded, args) {
|
|
33
28
|
super.onChangeExpanded(expanded, args);
|
|
34
|
-
|
|
35
29
|
if (this.parentSection && !args.unchanged) {
|
|
36
30
|
if (expanded) {
|
|
37
31
|
this.parentSection.collapse({
|
|
@@ -50,7 +44,6 @@ export default function getInspectorSection() {
|
|
|
50
44
|
}
|
|
51
45
|
}
|
|
52
46
|
}
|
|
53
|
-
|
|
54
47
|
open({
|
|
55
48
|
returnFocusWhenClose
|
|
56
49
|
} = {}) {
|
|
@@ -60,13 +53,11 @@ export default function getInspectorSection() {
|
|
|
60
53
|
allowMultiple: true
|
|
61
54
|
});
|
|
62
55
|
}
|
|
63
|
-
|
|
64
56
|
close() {
|
|
65
57
|
this.collapse({
|
|
66
58
|
allowMultiple: true
|
|
67
59
|
});
|
|
68
60
|
}
|
|
69
|
-
|
|
70
61
|
collapse(options) {
|
|
71
62
|
// Overridden collapse() function. Mostly call the parent collapse(), but also
|
|
72
63
|
// move our .isOpen to false.
|
|
@@ -80,7 +71,6 @@ export default function getInspectorSection() {
|
|
|
80
71
|
this.isOpen = false;
|
|
81
72
|
super.collapse(options);
|
|
82
73
|
}
|
|
83
|
-
|
|
84
74
|
triggerActiveCallbacks() {
|
|
85
75
|
// Manually fire the callbacks associated with moving this.active
|
|
86
76
|
// from false to true. "active" is always true for this section,
|
|
@@ -96,7 +86,6 @@ export default function getInspectorSection() {
|
|
|
96
86
|
// update its view of our status.
|
|
97
87
|
this.active.callbacks.fireWith(this.active, [false, true]);
|
|
98
88
|
}
|
|
99
|
-
|
|
100
89
|
};
|
|
101
90
|
}
|
|
102
91
|
//# sourceMappingURL=inspector-section.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["getInspectorSection","wp","customize","window","InspectorSection","Section","constructor","id","options","parentSection","returnFocusWhenClose","_isOpen","isOpen","value","triggerActiveCallbacks","ready","contentContainer","classList","add","isContextuallyActive","onChangeExpanded","expanded","args","unchanged","collapse","manualTransition","expand","completeCallback","contains","focus","open","allowMultiple","close","active","callbacks","fireWith"],"sources":["@wordpress/customize-widgets/src/controls/inspector-section.js"],"sourcesContent":["export default function getInspectorSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class InspectorSection extends customize.Section {\n\t\tconstructor( id, options ) {\n\t\t\tsuper( id, options );\n\n\t\t\tthis.parentSection = options.parentSection;\n\n\t\t\tthis.returnFocusWhenClose = null;\n\t\t\tthis._isOpen = false;\n\t\t}\n\t\tget isOpen() {\n\t\t\treturn this._isOpen;\n\t\t}\n\t\tset isOpen( value ) {\n\t\t\tthis._isOpen = value;\n\t\t\tthis.triggerActiveCallbacks();\n\t\t}\n\t\tready() {\n\t\t\tthis.contentContainer[ 0 ].classList.add(\n\t\t\t\t'customize-widgets-layout__inspector'\n\t\t\t);\n\t\t}\n\t\tisContextuallyActive() {\n\t\t\treturn this.isOpen;\n\t\t}\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tsuper.onChangeExpanded( expanded, args );\n\n\t\t\tif ( this.parentSection && ! args.unchanged ) {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tthis.parentSection.collapse( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tthis.parentSection.expand( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t\tcompleteCallback: () => {\n\t\t\t\t\t\t\t// Return focus after finishing the transition.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose &&\n\t\t\t\t\t\t\t\t! this.contentContainer[ 0 ].contains(\n\t\t\t\t\t\t\t\t\tthis.returnFocusWhenClose\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\topen( { returnFocusWhenClose } = {} ) {\n\t\t\tthis.isOpen = true;\n\t\t\tthis.returnFocusWhenClose = returnFocusWhenClose;\n\n\t\t\tthis.expand( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tclose() {\n\t\t\tthis.collapse( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tcollapse( options ) {\n\t\t\t// Overridden collapse() function. Mostly call the parent collapse(), but also\n\t\t\t// move our .isOpen to false.\n\t\t\t// Initially, I tried tracking this with onChangeExpanded(), but it doesn't work\n\t\t\t// because the block settings sidebar is a layer \"on top of\" the G editor sidebar.\n\t\t\t//\n\t\t\t// For example, when closing the block settings sidebar, the G\n\t\t\t// editor sidebar would display, and onChangeExpanded in\n\t\t\t// inspector-section would run with expanded=true, but I want\n\t\t\t// isOpen to be false when the block settings is closed.\n\t\t\tthis.isOpen = false;\n\t\t\tsuper.collapse( options );\n\t\t}\n\t\ttriggerActiveCallbacks() {\n\t\t\t// Manually fire the callbacks associated with moving this.active\n\t\t\t// from false to true. \"active\" is always true for this section,\n\t\t\t// and \"isContextuallyActive\" reflects if the block settings\n\t\t\t// sidebar is currently visible, that is, it has replaced the main\n\t\t\t// Gutenberg view.\n\t\t\t// The WP customizer only checks \".isContextuallyActive()\" when\n\t\t\t// \".active\" changes values. But our \".active\" never changes value.\n\t\t\t// The WP customizer never foresaw a section being used a way we\n\t\t\t// fit the block settings sidebar into a section. By manually\n\t\t\t// triggering the \"this.active\" callbacks, we force the WP\n\t\t\t// customizer to query our .isContextuallyActive() function and\n\t\t\t// update its view of our status.\n\t\t\tthis.active.callbacks.fireWith( this.active, [ false, true ] );\n\t\t}\n\t};\n}\n"],"mappings":"AAAA,eAAe,SAASA,mBAAmBA,CAAA,EAAG;EAC7C,MAAM;IACLC,EAAE,EAAE;MAAEC;IAAU;EACjB,CAAC,GAAGC,MAAM;EAEV,OAAO,MAAMC,gBAAgB,SAASF,SAAS,CAACG,OAAO,CAAC;IACvDC,WAAWA,CAAEC,EAAE,EAAEC,OAAO,EAAG;MAC1B,KAAK,CAAED,EAAE,EAAEC,OAAQ,CAAC;MAEpB,IAAI,CAACC,aAAa,GAAGD,OAAO,CAACC,aAAa;MAE1C,IAAI,CAACC,oBAAoB,GAAG,IAAI;MAChC,IAAI,CAACC,OAAO,GAAG,KAAK;IACrB;IACA,IAAIC,MAAMA,CAAA,EAAG;MACZ,OAAO,IAAI,CAACD,OAAO;IACpB;IACA,IAAIC,MAAMA,CAAEC,KAAK,EAAG;MACnB,IAAI,CAACF,OAAO,GAAGE,KAAK;MACpB,IAAI,CAACC,sBAAsB,CAAC,CAAC;IAC9B;IACAC,KAAKA,CAAA,EAAG;MACP,IAAI,CAACC,gBAAgB,CAAE,CAAC,CAAE,CAACC,SAAS,CAACC,GAAG,CACvC,qCACD,CAAC;IACF;IACAC,oBAAoBA,CAAA,EAAG;MACtB,OAAO,IAAI,CAACP,MAAM;IACnB;IACAQ,gBAAgBA,CAAEC,QAAQ,EAAEC,IAAI,EAAG;MAClC,KAAK,CAACF,gBAAgB,CAAEC,QAAQ,EAAEC,IAAK,CAAC;MA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AAC;AACF"}
|
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { dispatch } from '@wordpress/data';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Internal dependencies
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
9
|
import SidebarAdapter from '../components/sidebar-block-editor/sidebar-adapter';
|
|
10
10
|
import getInserterOuterSection from './inserter-outer-section';
|
|
11
11
|
import { store as customizeWidgetsStore } from '../store';
|
|
12
|
-
|
|
13
12
|
const getInserterId = controlId => `widgets-inserter-${controlId}`;
|
|
14
|
-
|
|
15
13
|
export default function getSidebarControl() {
|
|
16
14
|
const {
|
|
17
15
|
wp: {
|
|
@@ -23,7 +21,6 @@ export default function getSidebarControl() {
|
|
|
23
21
|
super(...args);
|
|
24
22
|
this.subscribers = new Set();
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
ready() {
|
|
28
25
|
const InserterOuterSection = getInserterOuterSection();
|
|
29
26
|
this.inserter = new InserterOuterSection(getInserterId(this.id), {});
|
|
@@ -32,25 +29,21 @@ export default function getSidebarControl() {
|
|
|
32
29
|
this.inspector = this.sectionInstance.inspector;
|
|
33
30
|
this.sidebarAdapter = new SidebarAdapter(this.setting, customize);
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
subscribe(callback) {
|
|
37
33
|
this.subscribers.add(callback);
|
|
38
34
|
return () => {
|
|
39
35
|
this.subscribers.delete(callback);
|
|
40
36
|
};
|
|
41
37
|
}
|
|
42
|
-
|
|
43
38
|
onChangeSectionExpanded(expanded, args) {
|
|
44
39
|
if (!args.unchanged) {
|
|
45
40
|
// Close the inserter when the section collapses.
|
|
46
41
|
if (!expanded) {
|
|
47
42
|
dispatch(customizeWidgetsStore).setIsInserterOpened(false);
|
|
48
43
|
}
|
|
49
|
-
|
|
50
44
|
this.subscribers.forEach(subscriber => subscriber(expanded, args));
|
|
51
45
|
}
|
|
52
46
|
}
|
|
53
|
-
|
|
54
47
|
};
|
|
55
48
|
}
|
|
56
49
|
//# sourceMappingURL=sidebar-control.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["dispatch","SidebarAdapter","getInserterOuterSection","store","customizeWidgetsStore","getInserterId","controlId","getSidebarControl","wp","customize","window","SidebarControl","Control","constructor","args","subscribers","Set","ready","InserterOuterSection","inserter","id","section","add","sectionInstance","inspector","sidebarAdapter","setting","subscribe","callback","delete","onChangeSectionExpanded","expanded","unchanged","setIsInserterOpened","forEach","subscriber"],"sources":["@wordpress/customize-widgets/src/controls/sidebar-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport SidebarAdapter from '../components/sidebar-block-editor/sidebar-adapter';\nimport getInserterOuterSection from './inserter-outer-section';\nimport { store as customizeWidgetsStore } from '../store';\n\nconst getInserterId = ( controlId ) => `widgets-inserter-${ controlId }`;\n\nexport default function getSidebarControl() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class SidebarControl extends customize.Control {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\tthis.subscribers = new Set();\n\t\t}\n\n\t\tready() {\n\t\t\tconst InserterOuterSection = getInserterOuterSection();\n\t\t\tthis.inserter = new InserterOuterSection(\n\t\t\t\tgetInserterId( this.id ),\n\t\t\t\t{}\n\t\t\t);\n\t\t\tcustomize.section.add( this.inserter );\n\n\t\t\tthis.sectionInstance = customize.section( this.section() );\n\n\t\t\tthis.inspector = this.sectionInstance.inspector;\n\n\t\t\tthis.sidebarAdapter = new SidebarAdapter( this.setting, customize );\n\t\t}\n\n\t\tsubscribe( callback ) {\n\t\t\tthis.subscribers.add( callback );\n\n\t\t\treturn () => {\n\t\t\t\tthis.subscribers.delete( callback );\n\t\t\t};\n\t\t}\n\n\t\tonChangeSectionExpanded( expanded, args ) {\n\t\t\tif ( ! args.unchanged ) {\n\t\t\t\t// Close the inserter when the section collapses.\n\t\t\t\tif ( ! expanded ) {\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.subscribers.forEach( ( subscriber ) =>\n\t\t\t\t\tsubscriber( expanded, args )\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,iBAAiB;;AAE1C;AACA;AACA;AACA,OAAOC,cAAc,MAAM,oDAAoD;AAC/E,OAAOC,uBAAuB,MAAM,0BAA0B;AAC9D,SAASC,KAAK,IAAIC,qBAAqB,QAAQ,UAAU;AAEzD,MAAMC,aAAa,GAAKC,SAAS,IAAO,oBAAoBA,SAAW,EAAC;AAExE,eAAe,SAASC,iBAAiBA,CAAA,EAAG;EAC3C,MAAM;IACLC,EAAE,EAAE;MAAEC;IAAU;EACjB,CAAC,GAAGC,MAAM;EAEV,OAAO,MAAMC,cAAc,SAASF,SAAS,CAACG,OAAO,CAAC;IACrDC,WAAWA,CAAE,GAAGC,IAAI,EAAG;MACtB,KAAK,CAAE,GAAGA,IAAK,CAAC;MAEhB,IAAI,CAACC,WAAW,GAAG,IAAIC,GAAG,CAAC,CAAC;IAC7B;IAEAC,KAAKA,CAAA,EAAG;MACP,MAAMC,oBAAoB,GAAGhB,uBAAuB,CAAC,CAAC;MACtD,IAAI,CAACiB,QAAQ,GAAG,IAAID,oBAAoB,CACvCb,aAAa,CAAE,IAAI,CAACe,EAAG,CAAC,EACxB,CAAC,CACF,CAAC;MACDX,SAAS,CAACY,OAAO,CAACC,GAAG,CAAE,IAAI,CAACH,QAAS,CAAC;MAEtC,IAAI,CAACI,eAAe,GAAGd,SAAS,CAACY,OAAO,CAAE,IAAI,CAACA,OAAO,CAAC,CAAE,CAAC;MAE1D,IAAI,CAACG,SAAS,GAAG,IAAI,CAACD,eAAe,CAACC,SAAS;MAE/C,IAAI,CAACC,cAAc,GAAG,IAAIxB,cAAc,CAAE,IAAI,CAACyB,OAAO,EAAEjB,SAAU,CAAC;IACpE;IAEAkB,SAASA,CAAEC,QAAQ,EAAG;MACrB,IAAI,CAACb,WAAW,CAACO,GAAG,CAAEM,QAAS,CAAC;MAEhC,OAAO,MAAM;QACZ,IAAI,CAACb,WAAW,CAACc,MAAM,CAAED,QAAS,CAAC;MACpC,CAAC;IACF;IAEAE,uBAAuBA,CAAEC,QAAQ,EAAEjB,IAAI,EAAG;MACzC,IAAK,CAAEA,IAAI,CAACkB,SAAS,EAAG;QACvB;QACA,IAAK,CAAED,QAAQ,EAAG;UACjB/B,QAAQ,CAAEI,qBAAsB,CAAC,CAAC6B,mBAAmB,CACpD,KACD,CAAC;QACF;QAEA,IAAI,CAAClB,WAAW,CAACmB,OAAO,CAAIC,UAAU,IACrCA,UAAU,CAAEJ,QAAQ,EAAEjB,IAAK,CAC5B,CAAC;MACF;IACD;EACD,CAAC;AACF"}
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Internal dependencies
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
9
|
import getInspectorSection from './inspector-section';
|
|
10
|
-
|
|
11
10
|
const getInspectorSectionId = sidebarId => `widgets-inspector-${sidebarId}`;
|
|
12
|
-
|
|
13
11
|
export default function getSidebarSection() {
|
|
14
12
|
const {
|
|
15
13
|
wp: {
|
|
@@ -32,24 +30,20 @@ export default function getSidebarSection() {
|
|
|
32
30
|
customize.section.add(this.inspector);
|
|
33
31
|
this.contentContainer[0].classList.add('customize-widgets__sidebar-section');
|
|
34
32
|
}
|
|
35
|
-
|
|
36
33
|
hasSubSectionOpened() {
|
|
37
34
|
return this.inspector.expanded();
|
|
38
35
|
}
|
|
39
|
-
|
|
40
36
|
onChangeExpanded(expanded, _args) {
|
|
41
37
|
const controls = this.controls();
|
|
42
|
-
const args = {
|
|
43
|
-
|
|
38
|
+
const args = {
|
|
39
|
+
..._args,
|
|
44
40
|
completeCallback() {
|
|
45
41
|
controls.forEach(control => {
|
|
46
42
|
control.onChangeSectionExpanded?.(expanded, args);
|
|
47
43
|
});
|
|
48
44
|
_args.completeCallback?.();
|
|
49
45
|
}
|
|
50
|
-
|
|
51
46
|
};
|
|
52
|
-
|
|
53
47
|
if (args.manualTransition) {
|
|
54
48
|
if (expanded) {
|
|
55
49
|
this.contentContainer.addClass(['busy', 'open']);
|
|
@@ -60,12 +54,10 @@ export default function getSidebarSection() {
|
|
|
60
54
|
this.contentContainer.closest('.wp-full-overlay').addClass('section-open');
|
|
61
55
|
this.contentContainer.removeClass('open');
|
|
62
56
|
}
|
|
63
|
-
|
|
64
57
|
const handleTransitionEnd = () => {
|
|
65
58
|
this.contentContainer.removeClass('busy');
|
|
66
59
|
args.completeCallback();
|
|
67
60
|
};
|
|
68
|
-
|
|
69
61
|
if (isReducedMotion) {
|
|
70
62
|
handleTransitionEnd();
|
|
71
63
|
} else {
|
|
@@ -75,7 +67,6 @@ export default function getSidebarSection() {
|
|
|
75
67
|
super.onChangeExpanded(expanded, args);
|
|
76
68
|
}
|
|
77
69
|
}
|
|
78
|
-
|
|
79
70
|
};
|
|
80
71
|
}
|
|
81
72
|
//# sourceMappingURL=sidebar-section.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["__","getInspectorSection","getInspectorSectionId","sidebarId","getSidebarSection","wp","customize","window","reduceMotionMediaQuery","matchMedia","isReducedMotion","matches","addEventListener","event","SidebarSection","Section","ready","InspectorSection","inspector","id","title","parentSection","customizeAction","params","join","section","add","contentContainer","classList","hasSubSectionOpened","expanded","onChangeExpanded","_args","controls","args","completeCallback","forEach","control","onChangeSectionExpanded","manualTransition","addClass","removeClass","closest","handleTransitionEnd","one"],"sources":["@wordpress/customize-widgets/src/controls/sidebar-section.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport getInspectorSection from './inspector-section';\n\nconst getInspectorSectionId = ( sidebarId ) =>\n\t`widgets-inspector-${ sidebarId }`;\n\nexport default function getSidebarSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\tconst reduceMotionMediaQuery = window.matchMedia(\n\t\t'(prefers-reduced-motion: reduce)'\n\t);\n\tlet isReducedMotion = reduceMotionMediaQuery.matches;\n\treduceMotionMediaQuery.addEventListener( 'change', ( event ) => {\n\t\tisReducedMotion = event.matches;\n\t} );\n\n\treturn class SidebarSection extends customize.Section {\n\t\tready() {\n\t\t\tconst InspectorSection = getInspectorSection();\n\t\t\tthis.inspector = new InspectorSection(\n\t\t\t\tgetInspectorSectionId( this.id ),\n\t\t\t\t{\n\t\t\t\t\ttitle: __( 'Block Settings' ),\n\t\t\t\t\tparentSection: this,\n\t\t\t\t\tcustomizeAction: [\n\t\t\t\t\t\t__( 'Customizing' ),\n\t\t\t\t\t\t__( 'Widgets' ),\n\t\t\t\t\t\tthis.params.title,\n\t\t\t\t\t].join( ' ▸ ' ),\n\t\t\t\t}\n\t\t\t);\n\t\t\tcustomize.section.add( this.inspector );\n\t\t\tthis.contentContainer[ 0 ].classList.add(\n\t\t\t\t'customize-widgets__sidebar-section'\n\t\t\t);\n\t\t}\n\t\thasSubSectionOpened() {\n\t\t\treturn this.inspector.expanded();\n\t\t}\n\t\tonChangeExpanded( expanded, _args ) {\n\t\t\tconst controls = this.controls();\n\t\t\tconst args = {\n\t\t\t\t..._args,\n\t\t\t\tcompleteCallback() {\n\t\t\t\t\tcontrols.forEach( ( control ) => {\n\t\t\t\t\t\tcontrol.onChangeSectionExpanded?.( expanded, args );\n\t\t\t\t\t} );\n\t\t\t\t\t_args.completeCallback?.();\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tif ( args.manualTransition ) {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tthis.contentContainer.addClass( [ 'busy', 'open' ] );\n\t\t\t\t\tthis.contentContainer.removeClass( 'is-sub-section-open' );\n\t\t\t\t\tthis.contentContainer\n\t\t\t\t\t\t.closest( '.wp-full-overlay' )\n\t\t\t\t\t\t.addClass( 'section-open' );\n\t\t\t\t} else {\n\t\t\t\t\tthis.contentContainer.addClass( [\n\t\t\t\t\t\t'busy',\n\t\t\t\t\t\t'is-sub-section-open',\n\t\t\t\t\t] );\n\t\t\t\t\tthis.contentContainer\n\t\t\t\t\t\t.closest( '.wp-full-overlay' )\n\t\t\t\t\t\t.addClass( 'section-open' );\n\t\t\t\t\tthis.contentContainer.removeClass( 'open' );\n\t\t\t\t}\n\n\t\t\t\tconst handleTransitionEnd = () => {\n\t\t\t\t\tthis.contentContainer.removeClass( 'busy' );\n\t\t\t\t\targs.completeCallback();\n\t\t\t\t};\n\n\t\t\t\tif ( isReducedMotion ) {\n\t\t\t\t\thandleTransitionEnd();\n\t\t\t\t} else {\n\t\t\t\t\tthis.contentContainer.one(\n\t\t\t\t\t\t'transitionend',\n\t\t\t\t\t\thandleTransitionEnd\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsuper.onChangeExpanded( expanded, args );\n\t\t\t}\n\t\t}\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,qBAAqB;AAErD,MAAMC,qBAAqB,GAAKC,SAAS,IACvC,qBAAqBA,SAAW,EAAC;AAEnC,eAAe,SAASC,iBAAiBA,CAAA,EAAG;EAC3C,MAAM;IACLC,EAAE,EAAE;MAAEC;IAAU;EACjB,CAAC,GAAGC,MAAM;EAEV,MAAMC,sBAAsB,GAAGD,MAAM,CAACE,UAAU,CAC/C,kCACD,CAAC;EACD,IAAIC,eAAe,GAAGF,sBAAsB,CAACG,OAAO;EACpDH,sBAAsB,CA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T,QAAQ,EAAG;UACf,IAAI,CAACH,gBAAgB,CAACa,QAAQ,CAAE,CAAE,MAAM,EAAE,MAAM,CAAG,CAAC;UACpD,IAAI,CAACb,gBAAgB,CAACc,WAAW,CAAE,qBAAsB,CAAC;UAC1D,IAAI,CAACd,gBAAgB,CACnBe,OAAO,CAAE,kBAAmB,CAAC,CAC7BF,QAAQ,CAAE,cAAe,CAAC;QAC7B,CAAC,MAAM;UACN,IAAI,CAACb,gBAAgB,CAACa,QAAQ,CAAE,CAC/B,MAAM,EACN,qBAAqB,CACpB,CAAC;UACH,IAAI,CAACb,gBAAgB,CACnBe,OAAO,CAAE,kBAAmB,CAAC,CAC7BF,QAAQ,CAAE,cAAe,CAAC;UAC5B,IAAI,CAACb,gBAAgB,CAACc,WAAW,CAAE,MAAO,CAAC;QAC5C;QAEA,MAAME,mBAAmB,GAAGA,CAAA,KAAM;UACjC,IAAI,CAAChB,gBAAgB,CAACc,WAAW,CAAE,MAAO,CAAC;UAC3CP,IAAI,CAACC,gBAAgB,CAAC,CAAC;QACxB,CAAC;QAED,IAAKzB,eAAe,EAAG;UACtBiC,mBAAmB,CAAC,CAAC;QACtB,CAAC,MAAM;UACN,IAAI,CAAChB,gBAAgB,CAACiB,GAAG,CACxB,eAAe,EACfD,mBACD,CAAC;QACF;MACD,CAAC,MAAM;QACN,KAAK,CAACZ,gBAAgB,CAAED,QAAQ,EAAEI,IAAK,CAAC;MACzC;IACD;EACD,CAAC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/customize-widgets/src/filters/index.js"],"
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/customize-widgets/src/filters/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './move-to-sidebar';\nimport './replace-media-upload';\nimport './wide-widget-display';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,mBAAmB;AAC1B,OAAO,wBAAwB;AAC/B,OAAO,uBAAuB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* WordPress dependencies
|
|
5
4
|
*/
|
|
@@ -8,10 +7,10 @@ import { createHigherOrderComponent } from '@wordpress/compose';
|
|
|
8
7
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
9
8
|
import { addFilter } from '@wordpress/hooks';
|
|
10
9
|
import { MoveToWidgetArea, getWidgetIdFromBlock } from '@wordpress/widgets';
|
|
10
|
+
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
14
|
import { useSidebarControls, useActiveSidebarControl } from '../components/sidebar-controls';
|
|
16
15
|
import { useFocusControl } from '../components/focus-control';
|
|
17
16
|
import { blockToWidget } from '../utils';
|
|
@@ -32,10 +31,8 @@ const withMoveToSidebarToolbarItem = createHigherOrderComponent(BlockEdit => pro
|
|
|
32
31
|
removeBlock
|
|
33
32
|
} = useDispatch(blockEditorStore);
|
|
34
33
|
const [, focusWidget] = useFocusControl();
|
|
35
|
-
|
|
36
34
|
function moveToSidebar(sidebarControlId) {
|
|
37
35
|
const newSidebarControl = sidebarControls.find(sidebarControl => sidebarControl.id === sidebarControlId);
|
|
38
|
-
|
|
39
36
|
if (widgetId) {
|
|
40
37
|
/**
|
|
41
38
|
* If there's a widgetId, move it to the other sidebar.
|
|
@@ -52,16 +49,16 @@ const withMoveToSidebarToolbarItem = createHigherOrderComponent(BlockEdit => pro
|
|
|
52
49
|
*/
|
|
53
50
|
const sidebarAdapter = newSidebarControl.sidebarAdapter;
|
|
54
51
|
removeBlock(clientId);
|
|
55
|
-
const addedWidgetIds = sidebarAdapter.setWidgets([...sidebarAdapter.getWidgets(), blockToWidget(block)]);
|
|
56
|
-
|
|
52
|
+
const addedWidgetIds = sidebarAdapter.setWidgets([...sidebarAdapter.getWidgets(), blockToWidget(block)]);
|
|
53
|
+
// The last non-null id is the added widget's id.
|
|
57
54
|
widgetId = addedWidgetIds.reverse().find(id => !!id);
|
|
58
|
-
}
|
|
59
|
-
|
|
55
|
+
}
|
|
60
56
|
|
|
57
|
+
// Move focus to the moved widget and expand the sidebar.
|
|
61
58
|
focusWidget(widgetId);
|
|
62
59
|
}
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
return createElement(Fragment, null, createElement(BlockEdit, {
|
|
61
|
+
...props
|
|
65
62
|
}), hasMultipleSidebars && canInsertBlockInSidebar && createElement(BlockControls, null, createElement(MoveToWidgetArea, {
|
|
66
63
|
widgetAreas: sidebarControls.map(sidebarControl => ({
|
|
67
64
|
id: sidebarControl.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["BlockControls","store","blockEditorStore","createHigherOrderComponent","useSelect","useDispatch","addFilter","MoveToWidgetArea","getWidgetIdFromBlock","useSidebarControls","useActiveSidebarControl","useFocusControl","blockToWidget","withMoveToSidebarToolbarItem","BlockEdit","props","widgetId","sidebarControls","activeSidebarControl","hasMultipleSidebars","length","blockName","name","clientId","canInsertBlockInSidebar","select","canInsertBlockType","block","getBlock","removeBlock","focusWidget","moveToSidebar","sidebarControlId","newSidebarControl","find","sidebarControl","id","oldSetting","setting","newSetting","filter","sidebarAdapter","addedWidgetIds","setWidgets","getWidgets","reverse","createElement","Fragment","widgetAreas","map","params","label","description","currentWidgetAreaId","onSelect"],"sources":["@wordpress/customize-widgets/src/filters/move-to-sidebar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { MoveToWidgetArea, getWidgetIdFromBlock } from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseSidebarControls,\n\tuseActiveSidebarControl,\n} from '../components/sidebar-controls';\nimport { useFocusControl } from '../components/focus-control';\nimport { blockToWidget } from '../utils';\n\nconst withMoveToSidebarToolbarItem = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tlet widgetId = getWidgetIdFromBlock( props );\n\t\tconst sidebarControls = useSidebarControls();\n\t\tconst activeSidebarControl = useActiveSidebarControl();\n\t\tconst hasMultipleSidebars = sidebarControls?.length > 1;\n\t\tconst blockName = props.name;\n\t\tconst clientId = props.clientId;\n\t\tconst canInsertBlockInSidebar = useSelect(\n\t\t\t( select ) => {\n\t\t\t\t// Use an empty string to represent the root block list, which\n\t\t\t\t// in the customizer editor represents a sidebar/widget area.\n\t\t\t\treturn select( blockEditorStore ).canInsertBlockType(\n\t\t\t\t\tblockName,\n\t\t\t\t\t''\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ blockName ]\n\t\t);\n\t\tconst block = useSelect(\n\t\t\t( select ) => select( blockEditorStore ).getBlock( clientId ),\n\t\t\t[ clientId ]\n\t\t);\n\t\tconst { removeBlock } = useDispatch( blockEditorStore );\n\t\tconst [ , focusWidget ] = useFocusControl();\n\n\t\tfunction moveToSidebar( sidebarControlId ) {\n\t\t\tconst newSidebarControl = sidebarControls.find(\n\t\t\t\t( sidebarControl ) => sidebarControl.id === sidebarControlId\n\t\t\t);\n\n\t\t\tif ( widgetId ) {\n\t\t\t\t/**\n\t\t\t\t * If there's a widgetId, move it to the other sidebar.\n\t\t\t\t */\n\t\t\t\tconst oldSetting = activeSidebarControl.setting;\n\t\t\t\tconst newSetting = newSidebarControl.setting;\n\n\t\t\t\toldSetting( oldSetting().filter( ( id ) => id !== widgetId ) );\n\t\t\t\tnewSetting( [ ...newSetting(), widgetId ] );\n\t\t\t} else {\n\t\t\t\t/**\n\t\t\t\t * If there isn't a widgetId, it's most likely a inner block.\n\t\t\t\t * First, remove the block in the original sidebar,\n\t\t\t\t * then, create a new widget in the new sidebar and get back its widgetId.\n\t\t\t\t */\n\t\t\t\tconst sidebarAdapter = newSidebarControl.sidebarAdapter;\n\n\t\t\t\tremoveBlock( clientId );\n\t\t\t\tconst addedWidgetIds = sidebarAdapter.setWidgets( [\n\t\t\t\t\t...sidebarAdapter.getWidgets(),\n\t\t\t\t\tblockToWidget( block ),\n\t\t\t\t] );\n\t\t\t\t// The last non-null id is the added widget's id.\n\t\t\t\twidgetId = addedWidgetIds.reverse().find( ( id ) => !! id );\n\t\t\t}\n\n\t\t\t// Move focus to the moved widget and expand the sidebar.\n\t\t\tfocusWidget( widgetId );\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ hasMultipleSidebars && canInsertBlockInSidebar && (\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<MoveToWidgetArea\n\t\t\t\t\t\t\twidgetAreas={ sidebarControls.map(\n\t\t\t\t\t\t\t\t( sidebarControl ) => ( {\n\t\t\t\t\t\t\t\t\tid: sidebarControl.id,\n\t\t\t\t\t\t\t\t\tname: sidebarControl.params.label,\n\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\tsidebarControl.params.description,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tcurrentWidgetAreaId={ activeSidebarControl?.id }\n\t\t\t\t\t\t\tonSelect={ moveToSidebar }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\t'withMoveToSidebarToolbarItem'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/customize-widgets/block-edit',\n\twithMoveToSidebarToolbarItem\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,gBAAgB,EA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AAS,CACR,kBAAkB,EAClB,mCAAmC,EACnCO,4BACD,CAAC"}
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { addFilter } from '@wordpress/hooks';
|
|
5
5
|
import { MediaUpload } from '@wordpress/media-utils';
|
|
6
|
-
|
|
7
6
|
const replaceMediaUpload = () => MediaUpload;
|
|
8
|
-
|
|
9
7
|
addFilter('editor.MediaUpload', 'core/edit-widgets/replace-media-upload', replaceMediaUpload);
|
|
10
8
|
//# sourceMappingURL=replace-media-upload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/customize-widgets/src/filters/replace-media-upload.js"],"
|
|
1
|
+
{"version":3,"names":["addFilter","MediaUpload","replaceMediaUpload"],"sources":["@wordpress/customize-widgets/src/filters/replace-media-upload.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { MediaUpload } from '@wordpress/media-utils';\n\nconst replaceMediaUpload = () => MediaUpload;\n\naddFilter(\n\t'editor.MediaUpload',\n\t'core/edit-widgets/replace-media-upload',\n\treplaceMediaUpload\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,WAAW,QAAQ,wBAAwB;AAEpD,MAAMC,kBAAkB,GAAGA,CAAA,KAAMD,WAAW;AAE5CD,SAAS,CACR,oBAAoB,EACpB,wCAAwC,EACxCE,kBACD,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* WordPress dependencies
|
|
5
4
|
*/
|
|
@@ -10,12 +9,12 @@ const {
|
|
|
10
9
|
} = window;
|
|
11
10
|
const withWideWidgetDisplay = createHigherOrderComponent(BlockEdit => props => {
|
|
12
11
|
var _wp$customize$Widgets;
|
|
13
|
-
|
|
14
12
|
const {
|
|
15
13
|
idBase
|
|
16
14
|
} = props.attributes;
|
|
17
15
|
const isWide = (_wp$customize$Widgets = wp.customize.Widgets.data.availableWidgets.find(widget => widget.id_base === idBase)?.is_wide) !== null && _wp$customize$Widgets !== void 0 ? _wp$customize$Widgets : false;
|
|
18
|
-
return createElement(BlockEdit, {
|
|
16
|
+
return createElement(BlockEdit, {
|
|
17
|
+
...props,
|
|
19
18
|
isWide: isWide
|
|
20
19
|
});
|
|
21
20
|
}, 'withWideWidgetDisplay');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["createHigherOrderComponent","addFilter","wp","window","withWideWidgetDisplay","BlockEdit","props","_wp$customize$Widgets","idBase","attributes","isWide","customize","Widgets","data","availableWidgets","find","widget","id_base","is_wide","createElement"],"sources":["@wordpress/customize-widgets/src/filters/wide-widget-display.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\n\nconst { wp } = window;\n\nconst withWideWidgetDisplay = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { idBase } = props.attributes;\n\t\tconst isWide =\n\t\t\twp.customize.Widgets.data.availableWidgets.find(\n\t\t\t\t( widget ) => widget.id_base === idBase\n\t\t\t)?.is_wide ?? false;\n\n\t\treturn <BlockEdit { ...props } isWide={ isWide } />;\n\t},\n\t'withWideWidgetDisplay'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/customize-widgets/wide-widget-display',\n\twithWideWidgetDisplay\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,SAAS,QAAQ,kBAAkB;AAE5C,MAAM;EAAEC;AAAG,CAAC,GAAGC,MAAM;AAErB,MAAMC,qBAAqB,GAAGJ,0BAA0B,CACrDK,SAAS,IAAQC,KAAK,IAAM;EAAA,IAAAC,qBAAA;EAC7B,MAAM;IAAEC;EAAO,CAAC,GAAGF,KAAK,CAACG,UAAU;EACnC,MAAMC,MAAM,IAAAH,qBAAA,GACXL,EAAE,CAACS,SAAS,CAACC,OAAO,CAACC,IAAI,CAACC,gBAAgB,CAACC,IAAI,CAC5CC,MAAM,IAAMA,MAAM,CAACC,OAAO,KAAKT,MAClC,CAAC,EAAEU,OAAO,cAAAX,qBAAA,cAAAA,qBAAA,GAAI,KAAK;EAEpB,OAAOY,aAAA,CAACd,SAAS;IAAA,GAAMC,KAAK;IAAGI,MAAM,EAAGA;EAAQ,CAAE,CAAC;AACpD,CAAC,EACD,uBACD,CAAC;AAEDT,SAAS,CACR,kBAAkB,EAClB,4CAA4C,EAC5CG,qBACD,CAAC"}
|