@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,22 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = useSidebarBlockEditor;
|
|
9
|
-
|
|
10
8
|
var _es = _interopRequireDefault(require("fast-deep-equal/es6"));
|
|
11
|
-
|
|
12
9
|
var _element = require("@wordpress/element");
|
|
13
|
-
|
|
14
10
|
var _isShallowEqual = _interopRequireDefault(require("@wordpress/is-shallow-equal"));
|
|
15
|
-
|
|
16
11
|
var _widgets = require("@wordpress/widgets");
|
|
17
|
-
|
|
18
12
|
var _utils = require("../../utils");
|
|
19
|
-
|
|
20
13
|
/**
|
|
21
14
|
* External dependencies
|
|
22
15
|
*/
|
|
@@ -28,10 +21,10 @@ var _utils = require("../../utils");
|
|
|
28
21
|
/**
|
|
29
22
|
* Internal dependencies
|
|
30
23
|
*/
|
|
24
|
+
|
|
31
25
|
function widgetsToBlocks(widgets) {
|
|
32
26
|
return widgets.map(widget => (0, _utils.widgetToBlock)(widget));
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
function useSidebarBlockEditor(sidebar) {
|
|
36
29
|
const [blocks, setBlocks] = (0, _element.useState)(() => widgetsToBlocks(sidebar.getWidgets()));
|
|
37
30
|
(0, _element.useEffect)(() => {
|
|
@@ -40,19 +33,19 @@ function useSidebarBlockEditor(sidebar) {
|
|
|
40
33
|
const prevWidgetsMap = new Map(prevWidgets.map(widget => [widget.id, widget]));
|
|
41
34
|
const prevBlocksMap = new Map(prevBlocks.map(block => [(0, _widgets.getWidgetIdFromBlock)(block), block]));
|
|
42
35
|
const nextBlocks = nextWidgets.map(nextWidget => {
|
|
43
|
-
const prevWidget = prevWidgetsMap.get(nextWidget.id);
|
|
36
|
+
const prevWidget = prevWidgetsMap.get(nextWidget.id);
|
|
44
37
|
|
|
38
|
+
// Bail out updates.
|
|
45
39
|
if (prevWidget && prevWidget === nextWidget) {
|
|
46
40
|
return prevBlocksMap.get(nextWidget.id);
|
|
47
41
|
}
|
|
48
|
-
|
|
49
42
|
return (0, _utils.widgetToBlock)(nextWidget);
|
|
50
|
-
});
|
|
43
|
+
});
|
|
51
44
|
|
|
45
|
+
// Bail out updates.
|
|
52
46
|
if ((0, _isShallowEqual.default)(prevBlocks, nextBlocks)) {
|
|
53
47
|
return prevBlocks;
|
|
54
48
|
}
|
|
55
|
-
|
|
56
49
|
return nextBlocks;
|
|
57
50
|
});
|
|
58
51
|
});
|
|
@@ -62,45 +55,42 @@ function useSidebarBlockEditor(sidebar) {
|
|
|
62
55
|
if ((0, _isShallowEqual.default)(prevBlocks, nextBlocks)) {
|
|
63
56
|
return prevBlocks;
|
|
64
57
|
}
|
|
65
|
-
|
|
66
58
|
const prevBlocksMap = new Map(prevBlocks.map(block => [(0, _widgets.getWidgetIdFromBlock)(block), block]));
|
|
67
59
|
const nextWidgets = nextBlocks.map(nextBlock => {
|
|
68
|
-
const widgetId = (0, _widgets.getWidgetIdFromBlock)(nextBlock);
|
|
60
|
+
const widgetId = (0, _widgets.getWidgetIdFromBlock)(nextBlock);
|
|
69
61
|
|
|
62
|
+
// Update existing widgets.
|
|
70
63
|
if (widgetId && prevBlocksMap.has(widgetId)) {
|
|
71
64
|
const prevBlock = prevBlocksMap.get(widgetId);
|
|
72
|
-
const prevWidget = sidebar.getWidget(widgetId);
|
|
73
|
-
// Deep equality is necessary until the block editor's internals changes.
|
|
65
|
+
const prevWidget = sidebar.getWidget(widgetId);
|
|
74
66
|
|
|
67
|
+
// Bail out updates by returning the previous widgets.
|
|
68
|
+
// Deep equality is necessary until the block editor's internals changes.
|
|
75
69
|
if ((0, _es.default)(nextBlock, prevBlock) && prevWidget) {
|
|
76
70
|
return prevWidget;
|
|
77
71
|
}
|
|
78
|
-
|
|
79
72
|
return (0, _utils.blockToWidget)(nextBlock, prevWidget);
|
|
80
|
-
}
|
|
81
|
-
|
|
73
|
+
}
|
|
82
74
|
|
|
75
|
+
// Add a new widget.
|
|
83
76
|
return (0, _utils.blockToWidget)(nextBlock);
|
|
84
|
-
});
|
|
77
|
+
});
|
|
85
78
|
|
|
79
|
+
// Bail out updates if the updated widgets are the same.
|
|
86
80
|
if ((0, _isShallowEqual.default)(sidebar.getWidgets(), nextWidgets)) {
|
|
87
81
|
return prevBlocks;
|
|
88
82
|
}
|
|
89
|
-
|
|
90
83
|
const addedWidgetIds = sidebar.setWidgets(nextWidgets);
|
|
91
84
|
return nextBlocks.reduce((updatedNextBlocks, nextBlock, index) => {
|
|
92
85
|
const addedWidgetId = addedWidgetIds[index];
|
|
93
|
-
|
|
94
86
|
if (addedWidgetId !== null) {
|
|
95
87
|
// Only create a new instance if necessary to prevent
|
|
96
88
|
// the whole editor from re-rendering on every edit.
|
|
97
89
|
if (updatedNextBlocks === nextBlocks) {
|
|
98
90
|
updatedNextBlocks = nextBlocks.slice();
|
|
99
91
|
}
|
|
100
|
-
|
|
101
92
|
updatedNextBlocks[index] = (0, _widgets.addWidgetIdToBlock)(nextBlock, addedWidgetId);
|
|
102
93
|
}
|
|
103
|
-
|
|
104
94
|
return updatedNextBlocks;
|
|
105
95
|
}, nextBlocks);
|
|
106
96
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_es","_interopRequireDefault","require","_element","_isShallowEqual","_widgets","_utils","widgetsToBlocks","widgets","map","widget","widgetToBlock","useSidebarBlockEditor","sidebar","blocks","setBlocks","useState","getWidgets","useEffect","subscribe","prevWidgets","nextWidgets","prevBlocks","prevWidgetsMap","Map","id","prevBlocksMap","block","getWidgetIdFromBlock","nextBlocks","nextWidget","prevWidget","get","isShallowEqual","onChangeBlocks","useCallback","nextBlock","widgetId","has","prevBlock","getWidget","fastDeepEqual","blockToWidget","addedWidgetIds","setWidgets","reduce","updatedNextBlocks","index","addedWidgetId","slice","addWidgetIdToBlock"],"sources":["@wordpress/customize-widgets/src/components/sidebar-block-editor/use-sidebar-block-editor.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { getWidgetIdFromBlock, addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport { blockToWidget, widgetToBlock } from '../../utils';\n\nfunction widgetsToBlocks( widgets ) {\n\treturn widgets.map( ( widget ) => widgetToBlock( widget ) );\n}\n\nexport default function useSidebarBlockEditor( sidebar ) {\n\tconst [ blocks, setBlocks ] = useState( () =>\n\t\twidgetsToBlocks( sidebar.getWidgets() )\n\t);\n\n\tuseEffect( () => {\n\t\treturn sidebar.subscribe( ( prevWidgets, nextWidgets ) => {\n\t\t\tsetBlocks( ( prevBlocks ) => {\n\t\t\t\tconst prevWidgetsMap = new Map(\n\t\t\t\t\tprevWidgets.map( ( widget ) => [ widget.id, widget ] )\n\t\t\t\t);\n\t\t\t\tconst prevBlocksMap = new Map(\n\t\t\t\t\tprevBlocks.map( ( block ) => [\n\t\t\t\t\t\tgetWidgetIdFromBlock( block ),\n\t\t\t\t\t\tblock,\n\t\t\t\t\t] )\n\t\t\t\t);\n\n\t\t\t\tconst nextBlocks = nextWidgets.map( ( nextWidget ) => {\n\t\t\t\t\tconst prevWidget = prevWidgetsMap.get( nextWidget.id );\n\n\t\t\t\t\t// Bail out updates.\n\t\t\t\t\tif ( prevWidget && prevWidget === nextWidget ) {\n\t\t\t\t\t\treturn prevBlocksMap.get( nextWidget.id );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn widgetToBlock( nextWidget );\n\t\t\t\t} );\n\n\t\t\t\t// Bail out updates.\n\t\t\t\tif ( isShallowEqual( prevBlocks, nextBlocks ) ) {\n\t\t\t\t\treturn prevBlocks;\n\t\t\t\t}\n\n\t\t\t\treturn nextBlocks;\n\t\t\t} );\n\t\t} );\n\t}, [ sidebar ] );\n\n\tconst onChangeBlocks = useCallback(\n\t\t( nextBlocks ) => {\n\t\t\tsetBlocks( ( prevBlocks ) => {\n\t\t\t\tif ( isShallowEqual( prevBlocks, nextBlocks ) ) {\n\t\t\t\t\treturn prevBlocks;\n\t\t\t\t}\n\n\t\t\t\tconst prevBlocksMap = new Map(\n\t\t\t\t\tprevBlocks.map( ( block ) => [\n\t\t\t\t\t\tgetWidgetIdFromBlock( block ),\n\t\t\t\t\t\tblock,\n\t\t\t\t\t] )\n\t\t\t\t);\n\n\t\t\t\tconst nextWidgets = nextBlocks.map( ( nextBlock ) => {\n\t\t\t\t\tconst widgetId = getWidgetIdFromBlock( nextBlock );\n\n\t\t\t\t\t// Update existing widgets.\n\t\t\t\t\tif ( widgetId && prevBlocksMap.has( widgetId ) ) {\n\t\t\t\t\t\tconst prevBlock = prevBlocksMap.get( widgetId );\n\t\t\t\t\t\tconst prevWidget = sidebar.getWidget( widgetId );\n\n\t\t\t\t\t\t// Bail out updates by returning the previous widgets.\n\t\t\t\t\t\t// Deep equality is necessary until the block editor's internals changes.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tfastDeepEqual( nextBlock, prevBlock ) &&\n\t\t\t\t\t\t\tprevWidget\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn prevWidget;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn blockToWidget( nextBlock, prevWidget );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Add a new widget.\n\t\t\t\t\treturn blockToWidget( nextBlock );\n\t\t\t\t} );\n\n\t\t\t\t// Bail out updates if the updated widgets are the same.\n\t\t\t\tif ( isShallowEqual( sidebar.getWidgets(), nextWidgets ) ) {\n\t\t\t\t\treturn prevBlocks;\n\t\t\t\t}\n\n\t\t\t\tconst addedWidgetIds = sidebar.setWidgets( nextWidgets );\n\n\t\t\t\treturn nextBlocks.reduce(\n\t\t\t\t\t( updatedNextBlocks, nextBlock, index ) => {\n\t\t\t\t\t\tconst addedWidgetId = addedWidgetIds[ index ];\n\n\t\t\t\t\t\tif ( addedWidgetId !== null ) {\n\t\t\t\t\t\t\t// Only create a new instance if necessary to prevent\n\t\t\t\t\t\t\t// the whole editor from re-rendering on every edit.\n\t\t\t\t\t\t\tif ( updatedNextBlocks === nextBlocks ) {\n\t\t\t\t\t\t\t\tupdatedNextBlocks = nextBlocks.slice();\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tupdatedNextBlocks[ index ] = addWidgetIdToBlock(\n\t\t\t\t\t\t\t\tnextBlock,\n\t\t\t\t\t\t\t\taddedWidgetId\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn updatedNextBlocks;\n\t\t\t\t\t},\n\t\t\t\t\tnextBlocks\n\t\t\t\t);\n\t\t\t} );\n\t\t},\n\t\t[ sidebar ]\n\t);\n\n\treturn [ blocks, onChangeBlocks, onChangeBlocks ];\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,SAASK,eAAeA,CAAEC,OAAO,EAAG;EACnC,OAAOA,OAAO,CAACC,GAAG,CAAIC,MAAM,IAAM,IAAAC,oBAAa,EAAED,MAAO,CAAE,CAAC;AAC5D;AAEe,SAASE,qBAAqBA,CAAEC,OAAO,EAAG;EACxD,MAAM,CAAEC,MAAM,EAAEC,SAAS,CAAE,GAAG,IAAAC,iBAAQ,EAAE,MACvCT,eAAe,CAAEM,OAAO,CAACI,UAAU,CAAC,CAAE,CACvC,CAAC;EAED,IAAAC,kBAAS,EAAE,MAAM;IAChB,OAAOL,OAAO,CAACM,SAAS,CAAE,CAAEC,WAAW,EAAEC,WAAW,KAAM;MACzDN,SAAS,CAAIO,UAAU,IAAM;QAC5B,MAAMC,cAAc,GAAG,IAAIC,GAAG,CAC7BJ,WAAW,CAACX,GAAG,CAAIC,MAAM,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ports.SidebarControlsContext = void 0;
|
|
|
7
7
|
exports.default = SidebarControls;
|
|
8
8
|
exports.useActiveSidebarControl = useActiveSidebarControl;
|
|
9
9
|
exports.useSidebarControls = useSidebarControls;
|
|
10
|
-
|
|
11
10
|
var _element = require("@wordpress/element");
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
12
|
* WordPress dependencies
|
|
15
13
|
*/
|
|
14
|
+
|
|
16
15
|
const SidebarControlsContext = (0, _element.createContext)();
|
|
17
16
|
exports.SidebarControlsContext = SidebarControlsContext;
|
|
18
|
-
|
|
19
17
|
function SidebarControls({
|
|
20
18
|
sidebarControls,
|
|
21
19
|
activeSidebarControl,
|
|
@@ -29,14 +27,12 @@ function SidebarControls({
|
|
|
29
27
|
value: context
|
|
30
28
|
}, children);
|
|
31
29
|
}
|
|
32
|
-
|
|
33
30
|
function useSidebarControls() {
|
|
34
31
|
const {
|
|
35
32
|
sidebarControls
|
|
36
33
|
} = (0, _element.useContext)(SidebarControlsContext);
|
|
37
34
|
return sidebarControls;
|
|
38
35
|
}
|
|
39
|
-
|
|
40
36
|
function useActiveSidebarControl() {
|
|
41
37
|
const {
|
|
42
38
|
activeSidebarControl
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","SidebarControlsContext","createContext","exports","SidebarControls","sidebarControls","activeSidebarControl","children","context","useMemo","createElement","Provider","value","useSidebarControls","useContext","useActiveSidebarControl"],"sources":["@wordpress/customize-widgets/src/components/sidebar-controls/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useMemo, useContext } from '@wordpress/element';\n\nexport const SidebarControlsContext = createContext();\n\nexport default function SidebarControls( {\n\tsidebarControls,\n\tactiveSidebarControl,\n\tchildren,\n} ) {\n\tconst context = useMemo(\n\t\t() => ( {\n\t\t\tsidebarControls,\n\t\t\tactiveSidebarControl,\n\t\t} ),\n\t\t[ sidebarControls, activeSidebarControl ]\n\t);\n\n\treturn (\n\t\t<SidebarControlsContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</SidebarControlsContext.Provider>\n\t);\n}\n\nexport function useSidebarControls() {\n\tconst { sidebarControls } = useContext( SidebarControlsContext );\n\n\treturn sidebarControls;\n}\n\nexport function useActiveSidebarControl() {\n\tconst { activeSidebarControl } = useContext( SidebarControlsContext );\n\n\treturn activeSidebarControl;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAMC,sBAAsB,GAAG,IAAAC,sBAAa,EAAC,CAAC;AAACC,OAAA,CAAAF,sBAAA,GAAAA,sBAAA;AAEvC,SAASG,eAAeA,CAAE;EACxCC,eAAe;EACfC,oBAAoB;EACpBC;AACD,CAAC,EAAG;EACH,MAAMC,OAAO,GAAG,IAAAC,gBAAO,EACtB,OAAQ;IACPJ,eAAe;IACfC;EACD,CAAC,CAAE,EACH,CAAED,eAAe,EAAEC,oBAAoB,CACxC,CAAC;EAED,OACC,IAAAP,QAAA,CAAAW,aAAA,EAACT,sBAAsB,CAACU,QAAQ;IAACC,KAAK,EAAGJ;EAAS,GAC/CD,QAC8B,CAAC;AAEpC;AAEO,SAASM,kBAAkBA,CAAA,EAAG;EACpC,MAAM;IAAER;EAAgB,CAAC,GAAG,IAAAS,mBAAU,EAAEb,sBAAuB,CAAC;EAEhE,OAAOI,eAAe;AACvB;AAEO,SAASU,uBAAuBA,CAAA,EAAG;EACzC,MAAM;IAAET;EAAqB,CAAC,GAAG,IAAAQ,mBAAU,EAAEb,sBAAuB,CAAC;EAErE,OAAOK,oBAAoB;AAC5B"}
|
|
@@ -4,20 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = WelcomeGuide;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _i18n = require("@wordpress/i18n");
|
|
11
|
-
|
|
12
9
|
var _components = require("@wordpress/components");
|
|
13
|
-
|
|
14
10
|
var _data = require("@wordpress/data");
|
|
15
|
-
|
|
16
11
|
var _preferences = require("@wordpress/preferences");
|
|
17
|
-
|
|
18
12
|
/**
|
|
19
13
|
* WordPress dependencies
|
|
20
14
|
*/
|
|
15
|
+
|
|
21
16
|
function WelcomeGuide({
|
|
22
17
|
sidebar
|
|
23
18
|
}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_data","_preferences","WelcomeGuide","sidebar","toggle","useDispatch","preferencesStore","isEntirelyBlockWidgets","getWidgets","every","widget","id","startsWith","_element","createElement","className","srcSet","media","src","width","height","alt","__","Button","variant","onClick","ExternalLink","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/'\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F,yHACA,CACD,CAAC,EACJ,IAAAT,QAAA,CAAAC,aAAA,EAACf,WAAA,CAAAwB,MAAM;IACNR,SAAS,EAAC,yCAAyC;IACnDS,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAGA,CAAA,KACTrB,MAAM,CAAE,wBAAwB,EAAE,cAAe;EACjD,GAEC,IAAAkB,QAAE,EAAE,QAAS,CACR,CAAC,EACT,IAAAT,QAAA,CAAAC,aAAA;IAAIC,SAAS,EAAC;EAA4C,CAAE,CAAC,EAC3D,CAAER,sBAAsB,IACzB,IAAAM,QAAA,CAAAC,aAAA;IAAGC,SAAS,EAAC;EAA4C,GACtD,IAAAO,QAAE,EAAE,qCAAsC,CAAC,EAC7C,IAAAT,QAAA,CAAAC,aAAA,YAAK,CAAC,EACN,IAAAD,QAAA,CAAAC,aAAA,EAACf,WAAA,CAAA2B,YAAY;IACZC,IAAI,EAAG,IAAAL,QAAE,EACR,gDACD;EAAG,GAED,IAAAA,QAAE,EAAE,iCAAkC,CAC3B,CACZ,CACH,EACD,IAAAT,QAAA,CAAAC,aAAA;IAAGC,SAAS,EAAC;EAA4C,GACtD,IAAAO,QAAE,EAAE,0BAA2B,CAAC,EAClC,IAAAT,QAAA,CAAAC,aAAA,YAAK,CAAC,EACN,IAAAD,QAAA,CAAAC,aAAA,EAACf,WAAA,CAAA2B,YAAY;IACZC,IAAI,EAAG,IAAAL,QAAE,EACR,qEACD;EAAG,GAED,IAAAA,QAAE,EAAE,0BAA2B,CACpB,CACZ,CACC,CAAC;AAER"}
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = getInserterOuterSection;
|
|
7
|
-
|
|
8
7
|
var _keycodes = require("@wordpress/keycodes");
|
|
9
|
-
|
|
10
8
|
var _dom = require("@wordpress/dom");
|
|
11
|
-
|
|
12
9
|
var _data = require("@wordpress/data");
|
|
13
|
-
|
|
14
10
|
var _store = require("../store");
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* WordPress dependencies
|
|
18
13
|
*/
|
|
@@ -20,16 +15,17 @@ var _store = require("../store");
|
|
|
20
15
|
/**
|
|
21
16
|
* Internal dependencies
|
|
22
17
|
*/
|
|
18
|
+
|
|
23
19
|
function getInserterOuterSection() {
|
|
24
20
|
const {
|
|
25
21
|
wp: {
|
|
26
22
|
customize
|
|
27
23
|
}
|
|
28
24
|
} = window;
|
|
29
|
-
const OuterSection = customize.OuterSection;
|
|
25
|
+
const OuterSection = customize.OuterSection;
|
|
26
|
+
// Override the OuterSection class to handle multiple outer sections.
|
|
30
27
|
// It closes all the other outer sections whenever one is opened.
|
|
31
28
|
// The result is that at most one outer section can be opened at the same time.
|
|
32
|
-
|
|
33
29
|
customize.OuterSection = class extends OuterSection {
|
|
34
30
|
onChangeExpanded(expanded, args) {
|
|
35
31
|
if (expanded) {
|
|
@@ -41,44 +37,44 @@ function getInserterOuterSection() {
|
|
|
41
37
|
}
|
|
42
38
|
});
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
return super.onChangeExpanded(expanded, args);
|
|
46
41
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
};
|
|
43
|
+
// Handle constructor so that "params.type" can be correctly pointed to "outer".
|
|
50
44
|
customize.sectionConstructor.outer = customize.OuterSection;
|
|
51
45
|
return class InserterOuterSection extends customize.OuterSection {
|
|
52
46
|
constructor(...args) {
|
|
53
|
-
super(...args);
|
|
54
|
-
// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436
|
|
47
|
+
super(...args);
|
|
55
48
|
|
|
49
|
+
// This is necessary since we're creating a new class which is not identical to the original OuterSection.
|
|
50
|
+
// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436
|
|
56
51
|
this.params.type = 'outer';
|
|
57
52
|
this.activeElementBeforeExpanded = null;
|
|
58
|
-
const ownerWindow = this.contentContainer[0].ownerDocument.defaultView;
|
|
53
|
+
const ownerWindow = this.contentContainer[0].ownerDocument.defaultView;
|
|
59
54
|
|
|
55
|
+
// Handle closing the inserter when pressing the Escape key.
|
|
60
56
|
ownerWindow.addEventListener('keydown', event => {
|
|
61
57
|
if (this.expanded() && (event.keyCode === _keycodes.ESCAPE || event.code === 'Escape') && !event.defaultPrevented) {
|
|
62
58
|
event.preventDefault();
|
|
63
59
|
event.stopPropagation();
|
|
64
60
|
(0, _data.dispatch)(_store.store).setIsInserterOpened(false);
|
|
65
61
|
}
|
|
66
|
-
},
|
|
62
|
+
},
|
|
63
|
+
// Use capture mode to make this run before other event listeners.
|
|
67
64
|
true);
|
|
68
|
-
this.contentContainer.addClass('widgets-inserter');
|
|
69
|
-
// Don't propagate the event if it's an internal action to prevent infinite loop.
|
|
65
|
+
this.contentContainer.addClass('widgets-inserter');
|
|
70
66
|
|
|
67
|
+
// Set a flag if the state is being changed from open() or close().
|
|
68
|
+
// Don't propagate the event if it's an internal action to prevent infinite loop.
|
|
71
69
|
this.isFromInternalAction = false;
|
|
72
70
|
this.expanded.bind(() => {
|
|
73
71
|
if (!this.isFromInternalAction) {
|
|
74
72
|
// Propagate the event to React to sync the state.
|
|
75
73
|
(0, _data.dispatch)(_store.store).setIsInserterOpened(this.expanded());
|
|
76
74
|
}
|
|
77
|
-
|
|
78
75
|
this.isFromInternalAction = false;
|
|
79
76
|
});
|
|
80
77
|
}
|
|
81
|
-
|
|
82
78
|
open() {
|
|
83
79
|
if (!this.expanded()) {
|
|
84
80
|
const contentContainer = this.contentContainer[0];
|
|
@@ -90,16 +86,13 @@ function getInserterOuterSection() {
|
|
|
90
86
|
// The first one should be the close button,
|
|
91
87
|
// we want to skip it and choose the second one instead, which is the search box.
|
|
92
88
|
const searchBox = _dom.focus.tabbable.find(contentContainer)[1];
|
|
93
|
-
|
|
94
89
|
if (searchBox) {
|
|
95
90
|
searchBox.focus();
|
|
96
91
|
}
|
|
97
92
|
}
|
|
98
|
-
|
|
99
93
|
});
|
|
100
94
|
}
|
|
101
95
|
}
|
|
102
|
-
|
|
103
96
|
close() {
|
|
104
97
|
if (this.expanded()) {
|
|
105
98
|
const contentContainer = this.contentContainer[0];
|
|
@@ -119,11 +112,9 @@ function getInserterOuterSection() {
|
|
|
119
112
|
}
|
|
120
113
|
}
|
|
121
114
|
}
|
|
122
|
-
|
|
123
115
|
});
|
|
124
116
|
}
|
|
125
117
|
}
|
|
126
|
-
|
|
127
118
|
};
|
|
128
119
|
}
|
|
129
120
|
//# sourceMappingURL=inserter-outer-section.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_keycodes","require","_dom","_data","_store","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","ESCAPE","code","defaultPrevented","preventDefault","stopPropagation","dispatch","customizeWidgetsStore","setIsInserterOpened","addClass","isFromInternalAction","bind","open","activeElement","expand","completeCallback","searchBox","focus","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":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGe,SAASI,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,EAAE,KAAK,IAAI,CAACA,EAAE,EACrB;YACD,IAAKJ,OAAO,CAACF,QAAQ,CAAC,CAAC,EAAG;cACzBE,OAAO,CAACK,QAAQ,CAAC,CAAC;YACnB;UACD;QACD,CAAE,CAAC;MACJ;MAEA,OAAO,KAAK,CAACR,gBAAgB,CAAEC,QAAQ,EAAEC,IAAK,CAAC;IAChD;EACD,CAAC;EACD;EACAL,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AC/B,QAAQ,CAAC,CAAC,EAAG;QACxB,MAAMc,gBAAgB,GAAG,IAAI,CAACA,gBAAgB,CAAE,CAAC,CAAE;QACnD,IAAI,CAACF,2BAA2B,GAC/BE,gBAAgB,CAACC,aAAa,CAACiB,aAAa;QAE7C,IAAI,CAACH,oBAAoB,GAAG,IAAI;QAEhC,IAAI,CAACI,MAAM,CAAE;UACZC,gBAAgBA,CAAA,EAAG;YAClB;YACA;YACA;YACA,MAAMC,SAAS,GACdC,UAAK,CAACC,QAAQ,CAACC,IAAI,CAAExB,gBAAiB,CAAC,CAAE,CAAC,CAAE;YAC7C,IAAKqB,SAAS,EAAG;cAChBA,SAAS,CAACC,KAAK,CAAC,CAAC;YAClB;UACD;QACD,CAAE,CAAC;MACJ;IACD;IACAG,KAAKA,CAAA,EAAG;MACP,IAAK,IAAI,CAACvC,QAAQ,CAAC,CAAC,EAAG;QACtB,MAAMc,gBAAgB,GAAG,IAAI,CAACA,gBAAgB,CAAE,CAAC,CAAE;QACnD,MAAMkB,aAAa,GAClBlB,gBAAgB,CAACC,aAAa,CAACiB,aAAa;QAE7C,IAAI,CAACH,oBAAoB,GAAG,IAAI;QAEhC,IAAI,CAACtB,QAAQ,CAAE;UACd2B,gBAAgBA,CAAA,EAAG;YAClB;YACA;YACA;YACA;YACA;YACA,IAAKpB,gBAAgB,CAAC0B,QAAQ,CAAER,aAAc,CAAC,EAAG;cACjD;cACA,IAAK,IAAI,CAACpB,2BAA2B,EAAG;gBACvC,IAAI,CAACA,2BAA2B,CAACwB,KAAK,CAAC,CAAC;cACzC;YACD;UACD;QACD,CAAE,CAAC;MACJ;IACD;EACD,CAAC;AACF"}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = getInspectorSection;
|
|
7
|
-
|
|
8
7
|
function getInspectorSection() {
|
|
9
8
|
const {
|
|
10
9
|
wp: {
|
|
@@ -18,27 +17,21 @@ function getInspectorSection() {
|
|
|
18
17
|
this.returnFocusWhenClose = null;
|
|
19
18
|
this._isOpen = false;
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
get isOpen() {
|
|
23
21
|
return this._isOpen;
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
set isOpen(value) {
|
|
27
24
|
this._isOpen = value;
|
|
28
25
|
this.triggerActiveCallbacks();
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
ready() {
|
|
32
28
|
this.contentContainer[0].classList.add('customize-widgets-layout__inspector');
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
isContextuallyActive() {
|
|
36
31
|
return this.isOpen;
|
|
37
32
|
}
|
|
38
|
-
|
|
39
33
|
onChangeExpanded(expanded, args) {
|
|
40
34
|
super.onChangeExpanded(expanded, args);
|
|
41
|
-
|
|
42
35
|
if (this.parentSection && !args.unchanged) {
|
|
43
36
|
if (expanded) {
|
|
44
37
|
this.parentSection.collapse({
|
|
@@ -57,7 +50,6 @@ function getInspectorSection() {
|
|
|
57
50
|
}
|
|
58
51
|
}
|
|
59
52
|
}
|
|
60
|
-
|
|
61
53
|
open({
|
|
62
54
|
returnFocusWhenClose
|
|
63
55
|
} = {}) {
|
|
@@ -67,13 +59,11 @@ function getInspectorSection() {
|
|
|
67
59
|
allowMultiple: true
|
|
68
60
|
});
|
|
69
61
|
}
|
|
70
|
-
|
|
71
62
|
close() {
|
|
72
63
|
this.collapse({
|
|
73
64
|
allowMultiple: true
|
|
74
65
|
});
|
|
75
66
|
}
|
|
76
|
-
|
|
77
67
|
collapse(options) {
|
|
78
68
|
// Overridden collapse() function. Mostly call the parent collapse(), but also
|
|
79
69
|
// move our .isOpen to false.
|
|
@@ -87,7 +77,6 @@ function getInspectorSection() {
|
|
|
87
77
|
this.isOpen = false;
|
|
88
78
|
super.collapse(options);
|
|
89
79
|
}
|
|
90
|
-
|
|
91
80
|
triggerActiveCallbacks() {
|
|
92
81
|
// Manually fire the callbacks associated with moving this.active
|
|
93
82
|
// from false to true. "active" is always true for this section,
|
|
@@ -103,7 +92,6 @@ function getInspectorSection() {
|
|
|
103
92
|
// update its view of our status.
|
|
104
93
|
this.active.callbacks.fireWith(this.active, [false, true]);
|
|
105
94
|
}
|
|
106
|
-
|
|
107
95
|
};
|
|
108
96
|
}
|
|
109
97
|
//# 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":";;;;;;AAAe,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;MAExC,IAAK,IAAI,CAACb,aAAa,IAAI,CAAEa,IAAI,CAACC,SAAS,EAAG;QAC7C,IAAKF,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|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = getSidebarControl;
|
|
9
|
-
|
|
10
8
|
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
9
|
var _sidebarAdapter = _interopRequireDefault(require("../components/sidebar-block-editor/sidebar-adapter"));
|
|
13
|
-
|
|
14
10
|
var _inserterOuterSection = _interopRequireDefault(require("./inserter-outer-section"));
|
|
15
|
-
|
|
16
11
|
var _store = require("../store");
|
|
17
|
-
|
|
18
12
|
/**
|
|
19
13
|
* WordPress dependencies
|
|
20
14
|
*/
|
|
@@ -22,8 +16,8 @@ var _store = require("../store");
|
|
|
22
16
|
/**
|
|
23
17
|
* Internal dependencies
|
|
24
18
|
*/
|
|
25
|
-
const getInserterId = controlId => `widgets-inserter-${controlId}`;
|
|
26
19
|
|
|
20
|
+
const getInserterId = controlId => `widgets-inserter-${controlId}`;
|
|
27
21
|
function getSidebarControl() {
|
|
28
22
|
const {
|
|
29
23
|
wp: {
|
|
@@ -35,7 +29,6 @@ function getSidebarControl() {
|
|
|
35
29
|
super(...args);
|
|
36
30
|
this.subscribers = new Set();
|
|
37
31
|
}
|
|
38
|
-
|
|
39
32
|
ready() {
|
|
40
33
|
const InserterOuterSection = (0, _inserterOuterSection.default)();
|
|
41
34
|
this.inserter = new InserterOuterSection(getInserterId(this.id), {});
|
|
@@ -44,25 +37,21 @@ function getSidebarControl() {
|
|
|
44
37
|
this.inspector = this.sectionInstance.inspector;
|
|
45
38
|
this.sidebarAdapter = new _sidebarAdapter.default(this.setting, customize);
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
subscribe(callback) {
|
|
49
41
|
this.subscribers.add(callback);
|
|
50
42
|
return () => {
|
|
51
43
|
this.subscribers.delete(callback);
|
|
52
44
|
};
|
|
53
45
|
}
|
|
54
|
-
|
|
55
46
|
onChangeSectionExpanded(expanded, args) {
|
|
56
47
|
if (!args.unchanged) {
|
|
57
48
|
// Close the inserter when the section collapses.
|
|
58
49
|
if (!expanded) {
|
|
59
50
|
(0, _data.dispatch)(_store.store).setIsInserterOpened(false);
|
|
60
51
|
}
|
|
61
|
-
|
|
62
52
|
this.subscribers.forEach(subscriber => subscriber(expanded, args));
|
|
63
53
|
}
|
|
64
54
|
}
|
|
65
|
-
|
|
66
55
|
};
|
|
67
56
|
}
|
|
68
57
|
//# sourceMappingURL=sidebar-control.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_data","require","_sidebarAdapter","_interopRequireDefault","_inserterOuterSection","_store","getInserterId","controlId","getSidebarControl","wp","customize","window","SidebarControl","Control","constructor","args","subscribers","Set","ready","InserterOuterSection","getInserterOuterSection","inserter","id","section","add","sectionInstance","inspector","sidebarAdapter","SidebarAdapter","setting","subscribe","callback","delete","onChangeSectionExpanded","expanded","unchanged","dispatch","customizeWidgetsStore","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":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA,MAAMK,aAAa,GAAKC,SAAS,IAAO,oBAAoBA,SAAW,EAAC;AAEzD,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,GAAG,IAAAC,6BAAuB,EAAC,CAAC;MACtD,IAAI,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