@wordpress/edit-widgets 7.0.0 → 7.1.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/build/blocks/widget-area/edit/index.cjs +106 -116
- package/build/blocks/widget-area/edit/index.cjs.map +1 -7
- package/build/blocks/widget-area/edit/inner-blocks.cjs +44 -62
- package/build/blocks/widget-area/edit/inner-blocks.cjs.map +1 -7
- package/build/blocks/widget-area/edit/use-is-dragging-within.cjs +41 -53
- package/build/blocks/widget-area/edit/use-is-dragging-within.cjs.map +1 -7
- package/build/blocks/widget-area/index.cjs +40 -44
- package/build/blocks/widget-area/index.cjs.map +1 -7
- package/build/components/error-boundary/index.cjs +115 -155
- package/build/components/error-boundary/index.cjs.map +1 -7
- package/build/components/header/document-tools/index.cjs +80 -115
- package/build/components/header/document-tools/index.cjs.map +1 -7
- package/build/components/header/index.cjs +72 -80
- package/build/components/header/index.cjs.map +1 -7
- package/build/components/header/undo-redo/redo.cjs +30 -52
- package/build/components/header/undo-redo/redo.cjs.map +1 -7
- package/build/components/header/undo-redo/undo.cjs +29 -51
- package/build/components/header/undo-redo/undo.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/config.cjs +88 -85
- package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +40 -57
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/index.cjs +94 -161
- package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +37 -75
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -7
- package/build/components/keyboard-shortcuts/index.cjs +107 -140
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -7
- package/build/components/layout/index.cjs +65 -74
- package/build/components/layout/index.cjs.map +1 -7
- package/build/components/layout/interface.cjs +82 -108
- package/build/components/layout/interface.cjs.map +1 -7
- package/build/components/layout/unsaved-changes-warning.cjs +44 -48
- package/build/components/layout/unsaved-changes-warning.cjs.map +1 -7
- package/build/components/more-menu/index.cjs +125 -191
- package/build/components/more-menu/index.cjs.map +1 -7
- package/build/components/more-menu/tools-more-menu-group.cjs +9 -29
- package/build/components/more-menu/tools-more-menu-group.cjs.map +1 -7
- package/build/components/notices/index.cjs +19 -39
- package/build/components/notices/index.cjs.map +1 -7
- package/build/components/save-button/index.cjs +31 -58
- package/build/components/save-button/index.cjs.map +1 -7
- package/build/components/secondary-sidebar/index.cjs +38 -45
- package/build/components/secondary-sidebar/index.cjs.map +1 -7
- package/build/components/secondary-sidebar/inserter-sidebar.cjs +50 -51
- package/build/components/secondary-sidebar/inserter-sidebar.cjs.map +1 -7
- package/build/components/secondary-sidebar/list-view-sidebar.cjs +51 -82
- package/build/components/secondary-sidebar/list-view-sidebar.cjs.map +1 -7
- package/build/components/sidebar/index.cjs +117 -180
- package/build/components/sidebar/index.cjs.map +1 -7
- package/build/components/sidebar/widget-areas.cjs +43 -85
- package/build/components/sidebar/widget-areas.cjs.map +1 -7
- package/build/components/welcome-guide/index.cjs +110 -186
- package/build/components/welcome-guide/index.cjs.map +1 -7
- package/build/components/widget-areas-block-editor-content/index.cjs +59 -64
- package/build/components/widget-areas-block-editor-content/index.cjs.map +1 -7
- package/build/components/widget-areas-block-editor-provider/index.cjs +105 -140
- package/build/components/widget-areas-block-editor-provider/index.cjs.map +1 -7
- package/build/constants.cjs +11 -32
- package/build/constants.cjs.map +1 -7
- package/build/filters/index.cjs +7 -4
- package/build/filters/move-to-widget-area.cjs +38 -53
- package/build/filters/move-to-widget-area.cjs.map +1 -7
- package/build/filters/replace-media-upload.cjs +11 -9
- package/build/filters/replace-media-upload.cjs.map +1 -7
- package/build/hooks/use-last-selected-widget-area.cjs +28 -49
- package/build/hooks/use-last-selected-widget-area.cjs.map +1 -7
- package/build/hooks/use-widget-library-insertion-point.cjs +33 -67
- package/build/hooks/use-widget-library-insertion-point.cjs.map +1 -7
- package/build/index.cjs +96 -97
- package/build/index.cjs.map +1 -7
- package/build/lock-unlock.cjs +10 -35
- package/build/lock-unlock.cjs.map +1 -7
- package/build/store/actions.cjs +269 -278
- package/build/store/actions.cjs.map +1 -7
- package/build/store/constants.cjs +12 -29
- package/build/store/constants.cjs.map +1 -7
- package/build/store/index.cjs +61 -52
- package/build/store/index.cjs.map +1 -7
- package/build/store/private-selectors.cjs +11 -32
- package/build/store/private-selectors.cjs.map +1 -7
- package/build/store/reducer.cjs +107 -88
- package/build/store/reducer.cjs.map +1 -7
- package/build/store/resolvers.cjs +60 -91
- package/build/store/resolvers.cjs.map +1 -7
- package/build/store/selectors.cjs +196 -229
- package/build/store/selectors.cjs.map +1 -7
- package/build/store/transformers.cjs +51 -82
- package/build/store/transformers.cjs.map +1 -7
- package/build/store/utils.cjs +76 -63
- package/build/store/utils.cjs.map +1 -7
- package/build-module/blocks/widget-area/edit/index.mjs +82 -94
- package/build-module/blocks/widget-area/edit/index.mjs.map +1 -7
- package/build-module/blocks/widget-area/edit/inner-blocks.mjs +19 -35
- package/build-module/blocks/widget-area/edit/inner-blocks.mjs.map +1 -7
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs +36 -33
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs.map +1 -7
- package/build-module/blocks/widget-area/index.mjs +12 -15
- package/build-module/blocks/widget-area/index.mjs.map +1 -7
- package/build-module/components/error-boundary/index.mjs +103 -128
- package/build-module/components/error-boundary/index.mjs.map +1 -7
- package/build-module/components/header/document-tools/index.mjs +51 -84
- package/build-module/components/header/document-tools/index.mjs.map +1 -7
- package/build-module/components/header/index.mjs +40 -47
- package/build-module/components/header/index.mjs.map +1 -7
- package/build-module/components/header/undo-redo/redo.mjs +20 -27
- package/build-module/components/header/undo-redo/redo.mjs.map +1 -7
- package/build-module/components/header/undo-redo/undo.mjs +19 -26
- package/build-module/components/header/undo-redo/undo.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs +83 -61
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs +19 -33
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs +67 -136
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +31 -54
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -7
- package/build-module/components/keyboard-shortcuts/index.mjs +99 -119
- package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -7
- package/build-module/components/layout/index.mjs +29 -40
- package/build-module/components/layout/index.mjs.map +1 -7
- package/build-module/components/layout/interface.mjs +53 -82
- package/build-module/components/layout/interface.mjs.map +1 -7
- package/build-module/components/layout/unsaved-changes-warning.mjs +37 -26
- package/build-module/components/layout/unsaved-changes-warning.mjs.map +1 -7
- package/build-module/components/more-menu/index.mjs +95 -162
- package/build-module/components/more-menu/index.mjs.map +1 -7
- package/build-module/components/more-menu/tools-more-menu-group.mjs +5 -9
- package/build-module/components/more-menu/tools-more-menu-group.mjs.map +1 -7
- package/build-module/components/notices/index.mjs +12 -17
- package/build-module/components/notices/index.mjs.map +1 -7
- package/build-module/components/save-button/index.mjs +23 -35
- package/build-module/components/save-button/index.mjs.map +1 -7
- package/build-module/components/secondary-sidebar/index.mjs +15 -20
- package/build-module/components/secondary-sidebar/index.mjs.map +1 -7
- package/build-module/components/secondary-sidebar/inserter-sidebar.mjs +27 -25
- package/build-module/components/secondary-sidebar/inserter-sidebar.mjs.map +1 -7
- package/build-module/components/secondary-sidebar/list-view-sidebar.mjs +39 -55
- package/build-module/components/secondary-sidebar/list-view-sidebar.mjs.map +1 -7
- package/build-module/components/sidebar/index.mjs +96 -162
- package/build-module/components/sidebar/index.mjs.map +1 -7
- package/build-module/components/sidebar/widget-areas.mjs +30 -57
- package/build-module/components/sidebar/widget-areas.mjs.map +1 -7
- package/build-module/components/welcome-guide/index.mjs +103 -164
- package/build-module/components/welcome-guide/index.mjs.map +1 -7
- package/build-module/components/widget-areas-block-editor-content/index.mjs +34 -44
- package/build-module/components/widget-areas-block-editor-content/index.mjs.map +1 -7
- package/build-module/components/widget-areas-block-editor-provider/index.mjs +76 -109
- package/build-module/components/widget-areas-block-editor-provider/index.mjs.map +1 -7
- package/build-module/constants.mjs +5 -7
- package/build-module/constants.mjs.map +1 -7
- package/build-module/filters/index.mjs +0 -2
- package/build-module/filters/move-to-widget-area.mjs +28 -48
- package/build-module/filters/move-to-widget-area.mjs.map +1 -7
- package/build-module/filters/replace-media-upload.mjs +5 -8
- package/build-module/filters/replace-media-upload.mjs.map +1 -7
- package/build-module/hooks/use-last-selected-widget-area.mjs +23 -29
- package/build-module/hooks/use-last-selected-widget-area.mjs.map +1 -7
- package/build-module/hooks/use-widget-library-insertion-point.mjs +28 -47
- package/build-module/hooks/use-widget-library-insertion-point.mjs.map +1 -7
- package/build-module/index.mjs +62 -79
- package/build-module/index.mjs.map +1 -7
- package/build-module/lock-unlock.mjs +5 -10
- package/build-module/lock-unlock.mjs.map +1 -7
- package/build-module/store/actions.mjs +250 -247
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/constants.mjs +7 -5
- package/build-module/store/constants.mjs.map +1 -7
- package/build-module/store/index.mjs +18 -16
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/private-selectors.mjs +5 -7
- package/build-module/store/private-selectors.mjs.map +1 -7
- package/build-module/store/reducer.mjs +95 -58
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/resolvers.mjs +52 -71
- package/build-module/store/resolvers.mjs.map +1 -7
- package/build-module/store/selectors.mjs +178 -199
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/store/transformers.mjs +44 -56
- package/build-module/store/transformers.mjs.map +1 -7
- package/build-module/store/utils.mjs +64 -32
- package/build-module/store/utils.mjs.map +1 -7
- package/package.json +33 -33
- package/src/components/header/index.jsx +2 -2
- package/src/components/sidebar/index.jsx +18 -18
- package/src/components/welcome-guide/index.jsx +4 -2
- package/build/filters/index.cjs.map +0 -7
- package/build-module/filters/index.mjs.map +0 -7
|
@@ -1,120 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
// \0rolldown/runtime.js
|
|
1
7
|
var __create = Object.create;
|
|
2
8
|
var __defProp = Object.defineProperty;
|
|
3
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
13
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
18
22
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
let _wordpress_compose = require("@wordpress/compose");
|
|
28
|
+
let _wordpress_block_editor = require("@wordpress/block-editor");
|
|
29
|
+
let _wordpress_element = require("@wordpress/element");
|
|
30
|
+
let _wordpress_data = require("@wordpress/data");
|
|
31
|
+
let _wordpress_interface = require("@wordpress/interface");
|
|
32
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
33
|
+
let _wordpress_preferences = require("@wordpress/preferences");
|
|
34
|
+
let ___header_index_jsx = require("../header/index.cjs");
|
|
35
|
+
___header_index_jsx = __toESM(___header_index_jsx);
|
|
36
|
+
let ___widget_areas_block_editor_content_index_jsx = require("../widget-areas-block-editor-content/index.cjs");
|
|
37
|
+
___widget_areas_block_editor_content_index_jsx = __toESM(___widget_areas_block_editor_content_index_jsx);
|
|
38
|
+
let ______store_index_js = require("../../store/index.cjs");
|
|
39
|
+
let ___secondary_sidebar_index_jsx = require("../secondary-sidebar/index.cjs");
|
|
40
|
+
___secondary_sidebar_index_jsx = __toESM(___secondary_sidebar_index_jsx);
|
|
41
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
29
42
|
// packages/edit-widgets/src/components/layout/interface.jsx
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var import_compose = require("@wordpress/compose");
|
|
36
|
-
var import_block_editor = require("@wordpress/block-editor");
|
|
37
|
-
var import_element = require("@wordpress/element");
|
|
38
|
-
var import_data = require("@wordpress/data");
|
|
39
|
-
var import_interface = require("@wordpress/interface");
|
|
40
|
-
var import_i18n = require("@wordpress/i18n");
|
|
41
|
-
var import_preferences = require("@wordpress/preferences");
|
|
42
|
-
var import_header = __toESM(require("../header/index.cjs"));
|
|
43
|
-
var import_widget_areas_block_editor_content = __toESM(require("../widget-areas-block-editor-content/index.cjs"));
|
|
44
|
-
var import_store = require("../../store/index.cjs");
|
|
45
|
-
var import_secondary_sidebar = __toESM(require("../secondary-sidebar/index.cjs"));
|
|
46
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
|
-
var interfaceLabels = {
|
|
48
|
-
/* translators: accessibility text for the widgets screen top bar landmark region. */
|
|
49
|
-
header: (0, import_i18n.__)("Widgets top bar"),
|
|
50
|
-
/* translators: accessibility text for the widgets screen content landmark region. */
|
|
51
|
-
body: (0, import_i18n.__)("Widgets and blocks"),
|
|
52
|
-
/* translators: accessibility text for the widgets screen settings landmark region. */
|
|
53
|
-
sidebar: (0, import_i18n.__)("Widgets settings"),
|
|
54
|
-
/* translators: accessibility text for the widgets screen footer landmark region. */
|
|
55
|
-
footer: (0, import_i18n.__)("Widgets footer")
|
|
43
|
+
const interfaceLabels = {
|
|
44
|
+
header: (0, _wordpress_i18n.__)("Widgets top bar"),
|
|
45
|
+
body: (0, _wordpress_i18n.__)("Widgets and blocks"),
|
|
46
|
+
sidebar: (0, _wordpress_i18n.__)("Widgets settings"),
|
|
47
|
+
footer: (0, _wordpress_i18n.__)("Widgets footer")
|
|
56
48
|
};
|
|
57
49
|
function Interface({ blockEditorSettings }) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
header: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_header.default, {}),
|
|
101
|
-
secondarySidebar: hasSecondarySidebar && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_secondary_sidebar.default, {}),
|
|
102
|
-
sidebar: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_interface.ComplementaryArea.Slot, { scope: "core/edit-widgets" }),
|
|
103
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
104
|
-
import_widget_areas_block_editor_content.default,
|
|
105
|
-
{
|
|
106
|
-
blockEditorSettings
|
|
107
|
-
}
|
|
108
|
-
) }),
|
|
109
|
-
footer: hasBlockBreadCrumbsEnabled && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "edit-widgets-layout__footer", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
110
|
-
import_block_editor.BlockBreadcrumb,
|
|
111
|
-
{
|
|
112
|
-
className: "edit-widgets-layout__breadcrumbs",
|
|
113
|
-
rootLabelText: (0, import_i18n.__)("Widgets")
|
|
114
|
-
}
|
|
115
|
-
) })
|
|
116
|
-
}
|
|
117
|
-
);
|
|
50
|
+
const isMobileViewport = (0, _wordpress_compose.useViewportMatch)("medium", "<");
|
|
51
|
+
const isHugeViewport = (0, _wordpress_compose.useViewportMatch)("huge", ">=");
|
|
52
|
+
const { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } = (0, _wordpress_data.useDispatch)(______store_index_js.store);
|
|
53
|
+
const { hasBlockBreadCrumbsEnabled, hasSidebarEnabled, isInserterOpened, isListViewOpened } = (0, _wordpress_data.useSelect)((select) => ({
|
|
54
|
+
hasSidebarEnabled: !!select(_wordpress_interface.store).getActiveComplementaryArea(______store_index_js.store.name),
|
|
55
|
+
isInserterOpened: !!select(______store_index_js.store).isInserterOpened(),
|
|
56
|
+
isListViewOpened: !!select(______store_index_js.store).isListViewOpened(),
|
|
57
|
+
hasBlockBreadCrumbsEnabled: !!select(_wordpress_preferences.store).get("core/edit-widgets", "showBlockBreadcrumbs")
|
|
58
|
+
}), []);
|
|
59
|
+
(0, _wordpress_element.useEffect)(() => {
|
|
60
|
+
if (hasSidebarEnabled && !isHugeViewport) {
|
|
61
|
+
setIsInserterOpened(false);
|
|
62
|
+
setIsListViewOpened(false);
|
|
63
|
+
}
|
|
64
|
+
}, [hasSidebarEnabled, isHugeViewport]);
|
|
65
|
+
(0, _wordpress_element.useEffect)(() => {
|
|
66
|
+
if ((isInserterOpened || isListViewOpened) && !isHugeViewport) closeGeneralSidebar();
|
|
67
|
+
}, [
|
|
68
|
+
isInserterOpened,
|
|
69
|
+
isListViewOpened,
|
|
70
|
+
isHugeViewport
|
|
71
|
+
]);
|
|
72
|
+
const secondarySidebarLabel = isListViewOpened ? (0, _wordpress_i18n.__)("List View") : (0, _wordpress_i18n.__)("Block Library");
|
|
73
|
+
const hasSecondarySidebar = isListViewOpened || isInserterOpened;
|
|
74
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_interface.InterfaceSkeleton, {
|
|
75
|
+
labels: {
|
|
76
|
+
...interfaceLabels,
|
|
77
|
+
secondarySidebar: secondarySidebarLabel
|
|
78
|
+
},
|
|
79
|
+
header: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___header_index_jsx.default, {}),
|
|
80
|
+
secondarySidebar: hasSecondarySidebar && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___secondary_sidebar_index_jsx.default, {}),
|
|
81
|
+
sidebar: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_interface.ComplementaryArea.Slot, { scope: "core/edit-widgets" }),
|
|
82
|
+
content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___widget_areas_block_editor_content_index_jsx.default, { blockEditorSettings }) }),
|
|
83
|
+
footer: hasBlockBreadCrumbsEnabled && !isMobileViewport && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
84
|
+
className: "edit-widgets-layout__footer",
|
|
85
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.BlockBreadcrumb, {
|
|
86
|
+
className: "edit-widgets-layout__breadcrumbs",
|
|
87
|
+
rootLabelText: (0, _wordpress_i18n.__)("Widgets")
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
});
|
|
118
91
|
}
|
|
119
|
-
|
|
120
|
-
|
|
92
|
+
exports.default = Interface;
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=interface.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/layout/interface.jsx"],
|
|
4
|
-
"sourcesContent": ["import { useViewportMatch } from '@wordpress/compose';\nimport { BlockBreadcrumb } from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport Header from '../header';\nimport WidgetAreasBlockEditorContent from '../widget-areas-block-editor-content';\nimport { store as editWidgetsStore } from '../../store';\nimport SecondarySidebar from '../secondary-sidebar';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the widgets screen top bar landmark region. */\n\theader: __( 'Widgets top bar' ),\n\t/* translators: accessibility text for the widgets screen content landmark region. */\n\tbody: __( 'Widgets and blocks' ),\n\t/* translators: accessibility text for the widgets screen settings landmark region. */\n\tsidebar: __( 'Widgets settings' ),\n\t/* translators: accessibility text for the widgets screen footer landmark region. */\n\tfooter: __( 'Widgets footer' ),\n};\n\nfunction Interface( { blockEditorSettings } ) {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isHugeViewport = useViewportMatch( 'huge', '>=' );\n\tconst { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst {\n\t\thasBlockBreadCrumbsEnabled,\n\t\thasSidebarEnabled,\n\t\tisInserterOpened,\n\t\tisListViewOpened,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasSidebarEnabled: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editWidgetsStore.name ),\n\t\t\tisInserterOpened: !! select( editWidgetsStore ).isInserterOpened(),\n\t\t\tisListViewOpened: !! select( editWidgetsStore ).isListViewOpened(),\n\t\t\thasBlockBreadCrumbsEnabled: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Inserter and Sidebars are mutually exclusive\n\tuseEffect( () => {\n\t\tif ( hasSidebarEnabled && ! isHugeViewport ) {\n\t\t\tsetIsInserterOpened( false );\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}, [ hasSidebarEnabled, isHugeViewport ] );\n\n\tuseEffect( () => {\n\t\tif ( ( isInserterOpened || isListViewOpened ) && ! isHugeViewport ) {\n\t\t\tcloseGeneralSidebar();\n\t\t}\n\t}, [ isInserterOpened, isListViewOpened, isHugeViewport ] );\n\n\tconst secondarySidebarLabel = isListViewOpened\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\n\tconst hasSecondarySidebar = isListViewOpened || isInserterOpened;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tlabels={ {\n\t\t\t\t...interfaceLabels,\n\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t} }\n\t\t\theader={ <Header /> }\n\t\t\tsecondarySidebar={ hasSecondarySidebar && <SecondarySidebar /> }\n\t\t\tsidebar={ <ComplementaryArea.Slot scope=\"core/edit-widgets\" /> }\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t<WidgetAreasBlockEditorContent\n\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t}\n\t\t\tfooter={\n\t\t\t\thasBlockBreadCrumbsEnabled &&\n\t\t\t\t! isMobileViewport && (\n\t\t\t\t\t<div className=\"edit-widgets-layout__footer\">\n\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\tclassName=\"edit-widgets-layout__breadcrumbs\"\n\t\t\t\t\t\t\trootLabelText={ __( 'Widgets' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t)\n\t\t\t}\n\t\t/>\n\t);\n}\n\nexport default Interface;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAiC;AACjC,0BAAgC;AAChC,qBAA0B;AAC1B,kBAAuC;AACvC,uBAIO;AACP,kBAAmB;AACnB,yBAA0C;AAC1C,oBAAmB;AACnB,+CAA0C;AAC1C,mBAA0C;AAC1C,+BAA6B;AAgEjB;AA9DZ,IAAM,kBAAkB;AAAA;AAAA,EAEvB,YAAQ,gBAAI,iBAAkB;AAAA;AAAA,EAE9B,UAAM,gBAAI,oBAAqB;AAAA;AAAA,EAE/B,aAAS,gBAAI,kBAAmB;AAAA;AAAA,EAEhC,YAAQ,gBAAI,gBAAiB;AAC9B;AAEA,SAAS,UAAW,EAAE,oBAAoB,GAAI;AAC7C,QAAM,uBAAmB,iCAAkB,UAAU,GAAI;AACzD,QAAM,qBAAiB,iCAAkB,QAAQ,IAAK;AACtD,QAAM,EAAE,qBAAqB,qBAAqB,oBAAoB,QACrE,yBAAa,aAAAA,KAAiB;AAC/B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI;AAAA,IACH,CAAE,YAAc;AAAA,MACf,mBAAmB,CAAC,CAAE;AAAA,QACrB,iBAAAC;AAAA,MACD,EAAE,2BAA4B,aAAAD,MAAiB,IAAK;AAAA,MACpD,kBAAkB,CAAC,CAAE,OAAQ,aAAAA,KAAiB,EAAE,iBAAiB;AAAA,MACjE,kBAAkB,CAAC,CAAE,OAAQ,aAAAA,KAAiB,EAAE,iBAAiB;AAAA,MACjE,4BAA4B,CAAC,CAAE,OAAQ,mBAAAE,KAAiB,EAAE;AAAA,QACzD;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AAGA,gCAAW,MAAM;AAChB,QAAK,qBAAqB,CAAE,gBAAiB;AAC5C,0BAAqB,KAAM;AAC3B,0BAAqB,KAAM;AAAA,IAC5B;AAAA,EACD,GAAG,CAAE,mBAAmB,cAAe,CAAE;AAEzC,gCAAW,MAAM;AAChB,SAAO,oBAAoB,qBAAsB,CAAE,gBAAiB;AACnE,0BAAoB;AAAA,IACrB;AAAA,EACD,GAAG,CAAE,kBAAkB,kBAAkB,cAAe,CAAE;AAE1D,QAAM,wBAAwB,uBAC3B,gBAAI,WAAY,QAChB,gBAAI,eAAgB;AAEvB,QAAM,sBAAsB,oBAAoB;AAEhD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,QAAS;AAAA,QACR,GAAG;AAAA,QACH,kBAAkB;AAAA,MACnB;AAAA,MACA,QAAS,4CAAC,cAAAC,SAAA,EAAO;AAAA,MACjB,kBAAmB,uBAAuB,4CAAC,yBAAAC,SAAA,EAAiB;AAAA,MAC5D,SAAU,4CAAC,mCAAkB,MAAlB,EAAuB,OAAM,qBAAoB;AAAA,MAC5D,SACC,2EACC;AAAA,QAAC,yCAAAC;AAAA,QAAA;AAAA,UACA;AAAA;AAAA,MACD,GACD;AAAA,MAED,QACC,8BACA,CAAE,oBACD,4CAAC,SAAI,WAAU,+BACd;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,mBAAgB,gBAAI,SAAU;AAAA;AAAA,MAC/B,GACD;AAAA;AAAA,EAGH;AAEF;AAEA,IAAO,oBAAQ;",
|
|
6
|
-
"names": ["editWidgetsStore", "interfaceStore", "preferencesStore", "Header", "SecondarySidebar", "WidgetAreasBlockEditorContent"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"interface.cjs","names":["__","useViewportMatch","useDispatch","editWidgetsStore","useSelect","interfaceStore","preferencesStore","InterfaceSkeleton","Header","SecondarySidebar","ComplementaryArea","WidgetAreasBlockEditorContent","BlockBreadcrumb"],"sources":["../../../src/components/layout/interface.jsx"],"sourcesContent":["import { useViewportMatch } from '@wordpress/compose';\nimport { BlockBreadcrumb } from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport Header from '../header';\nimport WidgetAreasBlockEditorContent from '../widget-areas-block-editor-content';\nimport { store as editWidgetsStore } from '../../store';\nimport SecondarySidebar from '../secondary-sidebar';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the widgets screen top bar landmark region. */\n\theader: __( 'Widgets top bar' ),\n\t/* translators: accessibility text for the widgets screen content landmark region. */\n\tbody: __( 'Widgets and blocks' ),\n\t/* translators: accessibility text for the widgets screen settings landmark region. */\n\tsidebar: __( 'Widgets settings' ),\n\t/* translators: accessibility text for the widgets screen footer landmark region. */\n\tfooter: __( 'Widgets footer' ),\n};\n\nfunction Interface( { blockEditorSettings } ) {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isHugeViewport = useViewportMatch( 'huge', '>=' );\n\tconst { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst {\n\t\thasBlockBreadCrumbsEnabled,\n\t\thasSidebarEnabled,\n\t\tisInserterOpened,\n\t\tisListViewOpened,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasSidebarEnabled: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editWidgetsStore.name ),\n\t\t\tisInserterOpened: !! select( editWidgetsStore ).isInserterOpened(),\n\t\t\tisListViewOpened: !! select( editWidgetsStore ).isListViewOpened(),\n\t\t\thasBlockBreadCrumbsEnabled: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Inserter and Sidebars are mutually exclusive\n\tuseEffect( () => {\n\t\tif ( hasSidebarEnabled && ! isHugeViewport ) {\n\t\t\tsetIsInserterOpened( false );\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}, [ hasSidebarEnabled, isHugeViewport ] );\n\n\tuseEffect( () => {\n\t\tif ( ( isInserterOpened || isListViewOpened ) && ! isHugeViewport ) {\n\t\t\tcloseGeneralSidebar();\n\t\t}\n\t}, [ isInserterOpened, isListViewOpened, isHugeViewport ] );\n\n\tconst secondarySidebarLabel = isListViewOpened\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\n\tconst hasSecondarySidebar = isListViewOpened || isInserterOpened;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tlabels={ {\n\t\t\t\t...interfaceLabels,\n\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t} }\n\t\t\theader={ <Header /> }\n\t\t\tsecondarySidebar={ hasSecondarySidebar && <SecondarySidebar /> }\n\t\t\tsidebar={ <ComplementaryArea.Slot scope=\"core/edit-widgets\" /> }\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t<WidgetAreasBlockEditorContent\n\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t}\n\t\t\tfooter={\n\t\t\t\thasBlockBreadCrumbsEnabled &&\n\t\t\t\t! isMobileViewport && (\n\t\t\t\t\t<div className=\"edit-widgets-layout__footer\">\n\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\tclassName=\"edit-widgets-layout__breadcrumbs\"\n\t\t\t\t\t\t\trootLabelText={ __( 'Widgets' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t)\n\t\t\t}\n\t\t/>\n\t);\n}\n\nexport default Interface;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,kBAAkB;CAEvB,SAAA,GAAQA,gBAAAA,GAAAA,CAAI,iBAAkB;CAE9B,OAAA,GAAMA,gBAAAA,GAAAA,CAAI,oBAAqB;CAE/B,UAAA,GAASA,gBAAAA,GAAAA,CAAI,kBAAmB;CAEhC,SAAA,GAAQA,gBAAAA,GAAAA,CAAI,gBAAiB;AAC9B;AAEA,SAAS,UAAW,EAAE,uBAAwB;CAC7C,MAAM,oBAAA,GAAmBC,mBAAAA,iBAAAA,CAAkB,UAAU,GAAI;CACzD,MAAM,kBAAA,GAAiBA,mBAAAA,iBAAAA,CAAkB,QAAQ,IAAK;CACtD,MAAM,EAAE,qBAAqB,qBAAqB,yBAAA,GACjDC,gBAAAA,YAAAA,CAAaC,qBAAAA,KAAiB;CAC/B,MAAM,EACL,4BACA,mBACA,kBACA,sBAAA,GACGC,gBAAAA,UAAAA,EACD,YAAc;EACf,mBAAmB,CAAC,CAAE,OACrBC,qBAAAA,KACD,CAAC,CAAC,2BAA4BF,qBAAAA,MAAiB,IAAK;EACpD,kBAAkB,CAAC,CAAE,OAAQA,qBAAAA,KAAiB,CAAC,CAAC,iBAAiB;EACjE,kBAAkB,CAAC,CAAE,OAAQA,qBAAAA,KAAiB,CAAC,CAAC,iBAAiB;EACjE,4BAA4B,CAAC,CAAE,OAAQG,uBAAAA,KAAiB,CAAC,CAAC,IACzD,qBACA,sBACD;CACD,IACA,CAAC,CACF;CAGA,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,IAAK,qBAAqB,CAAE,gBAAiB;GAC5C,oBAAqB,KAAM;GAC3B,oBAAqB,KAAM;EAC5B;CACD,GAAG,CAAE,mBAAmB,cAAe,CAAE;CAEzC,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,KAAO,oBAAoB,qBAAsB,CAAE,gBAClD,oBAAoB;CAEtB,GAAG;EAAE;EAAkB;EAAkB;CAAe,CAAE;CAE1D,MAAM,wBAAwB,oBAAA,GAC3BN,gBAAAA,GAAAA,CAAI,WAAY,KAAA,GAChBA,gBAAAA,GAAAA,CAAI,eAAgB;CAEvB,MAAM,sBAAsB,oBAAoB;CAEhD,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACO,qBAAAA,mBAAD;EACC,QAAS;GACR,GAAG;GACH,kBAAkB;EACnB;EACA,QAAS,iBAAA,GAAA,kBAAA,IAAA,CAACC,oBAAAA,SAAD,CAAS,CAAA;EAClB,kBAAmB,uBAAuB,iBAAA,GAAA,kBAAA,IAAA,CAACC,+BAAAA,SAAD,CAAmB,CAAA;EAC7D,SAAU,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,kBAAkB,MAAnB,EAAwB,OAAM,oBAAqB,CAAA;EAC7D,SACC,iBAAA,GAAA,kBAAA,IAAA,CAAA,kBAAA,UAAA,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,+CAAAA,SAAD,EACuB,oBACtB,CAAA,EACA,CAAA;EAEH,QACC,8BACA,CAAE,oBACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,WAAU;GACd,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,iBAAD;IACC,WAAU;IACV,gBAAA,GAAgBZ,gBAAAA,GAAAA,CAAI,SAAU;GAC9B,CAAA;EACG,CAAA;CAGP,CAAA;AAEH"}
|
|
@@ -1,51 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/edit-widgets/src/components/layout/unsaved-changes-warning.js
|
|
20
|
-
var unsaved_changes_warning_exports = {};
|
|
21
|
-
__export(unsaved_changes_warning_exports, {
|
|
22
|
-
default: () => UnsavedChangesWarning
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
6
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
7
|
+
let _wordpress_element = require("@wordpress/element");
|
|
8
|
+
let _wordpress_data = require("@wordpress/data");
|
|
9
|
+
let ______store_index_js = require("../../store/index.cjs");
|
|
10
|
+
// packages/edit-widgets/src/components/layout/unsaved-changes-warning.js
|
|
11
|
+
/**
|
|
12
|
+
* Warns the user if there are unsaved changes before leaving the editor.
|
|
13
|
+
*
|
|
14
|
+
* This is a duplicate of the component implemented in the editor package.
|
|
15
|
+
* Duplicated here as edit-widgets doesn't depend on editor.
|
|
16
|
+
*
|
|
17
|
+
* @return {Component} The component.
|
|
18
|
+
*/
|
|
29
19
|
function UnsavedChangesWarning() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
20
|
+
const isDirty = (0, _wordpress_data.useSelect)((select) => {
|
|
21
|
+
const { getEditedWidgetAreas } = select(______store_index_js.store);
|
|
22
|
+
return getEditedWidgetAreas()?.length > 0;
|
|
23
|
+
}, []);
|
|
24
|
+
(0, _wordpress_element.useEffect)(() => {
|
|
25
|
+
/**
|
|
26
|
+
* Warns the user if there are unsaved changes before leaving the editor.
|
|
27
|
+
*
|
|
28
|
+
* @param {Event} event `beforeunload` event.
|
|
29
|
+
*
|
|
30
|
+
* @return {string | undefined} Warning prompt message, if unsaved changes exist.
|
|
31
|
+
*/
|
|
32
|
+
const warnIfUnsavedChanges = (event) => {
|
|
33
|
+
if (isDirty) {
|
|
34
|
+
event.returnValue = (0, _wordpress_i18n.__)("You have unsaved changes. If you proceed, they will be lost.");
|
|
35
|
+
return event.returnValue;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
window.addEventListener("beforeunload", warnIfUnsavedChanges);
|
|
39
|
+
return () => {
|
|
40
|
+
window.removeEventListener("beforeunload", warnIfUnsavedChanges);
|
|
41
|
+
};
|
|
42
|
+
}, [isDirty]);
|
|
43
|
+
return null;
|
|
50
44
|
}
|
|
51
|
-
|
|
45
|
+
exports.default = UnsavedChangesWarning;
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=unsaved-changes-warning.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/layout/unsaved-changes-warning.js"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as editWidgetsStore } from '../../store';\n\n/**\n * Warns the user if there are unsaved changes before leaving the editor.\n *\n * This is a duplicate of the component implemented in the editor package.\n * Duplicated here as edit-widgets doesn't depend on editor.\n *\n * @return {Component} The component.\n */\nexport default function UnsavedChangesWarning() {\n\tconst isDirty = useSelect( ( select ) => {\n\t\tconst { getEditedWidgetAreas } = select( editWidgetsStore );\n\t\tconst editedWidgetAreas = getEditedWidgetAreas();\n\n\t\treturn editedWidgetAreas?.length > 0;\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Warns the user if there are unsaved changes before leaving the editor.\n\t\t *\n\t\t * @param {Event} event `beforeunload` event.\n\t\t *\n\t\t * @return {string | undefined} Warning prompt message, if unsaved changes exist.\n\t\t */\n\t\tconst warnIfUnsavedChanges = ( event ) => {\n\t\t\tif ( isDirty ) {\n\t\t\t\tevent.returnValue = __(\n\t\t\t\t\t'You have unsaved changes. If you proceed, they will be lost.'\n\t\t\t\t);\n\t\t\t\treturn event.returnValue;\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener( 'beforeunload', warnIfUnsavedChanges );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'beforeunload', warnIfUnsavedChanges );\n\t\t};\n\t}, [ isDirty ] );\n\n\treturn null;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,qBAA0B;AAC1B,kBAA0B;AAC1B,mBAA0C;AAU3B,SAAR,wBAAyC;AAC/C,QAAM,cAAU,uBAAW,CAAE,WAAY;AACxC,UAAM,EAAE,qBAAqB,IAAI,OAAQ,aAAAA,KAAiB;AAC1D,UAAM,oBAAoB,qBAAqB;AAE/C,WAAO,mBAAmB,SAAS;AAAA,EACpC,GAAG,CAAC,CAAE;AAEN,gCAAW,MAAM;AAQhB,UAAM,uBAAuB,CAAE,UAAW;AACzC,UAAK,SAAU;AACd,cAAM,kBAAc;AAAA,UACnB;AAAA,QACD;AACA,eAAO,MAAM;AAAA,MACd;AAAA,IACD;AAEA,WAAO,iBAAkB,gBAAgB,oBAAqB;AAE9D,WAAO,MAAM;AACZ,aAAO,oBAAqB,gBAAgB,oBAAqB;AAAA,IAClE;AAAA,EACD,GAAG,CAAE,OAAQ,CAAE;AAEf,SAAO;AACR;",
|
|
6
|
-
"names": ["editWidgetsStore"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"unsaved-changes-warning.cjs","names":["useSelect","editWidgetsStore","__"],"sources":["../../../src/components/layout/unsaved-changes-warning.js"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as editWidgetsStore } from '../../store';\n\n/**\n * Warns the user if there are unsaved changes before leaving the editor.\n *\n * This is a duplicate of the component implemented in the editor package.\n * Duplicated here as edit-widgets doesn't depend on editor.\n *\n * @return {Component} The component.\n */\nexport default function UnsavedChangesWarning() {\n\tconst isDirty = useSelect( ( select ) => {\n\t\tconst { getEditedWidgetAreas } = select( editWidgetsStore );\n\t\tconst editedWidgetAreas = getEditedWidgetAreas();\n\n\t\treturn editedWidgetAreas?.length > 0;\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Warns the user if there are unsaved changes before leaving the editor.\n\t\t *\n\t\t * @param {Event} event `beforeunload` event.\n\t\t *\n\t\t * @return {string | undefined} Warning prompt message, if unsaved changes exist.\n\t\t */\n\t\tconst warnIfUnsavedChanges = ( event ) => {\n\t\t\tif ( isDirty ) {\n\t\t\t\tevent.returnValue = __(\n\t\t\t\t\t'You have unsaved changes. If you proceed, they will be lost.'\n\t\t\t\t);\n\t\t\t\treturn event.returnValue;\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener( 'beforeunload', warnIfUnsavedChanges );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'beforeunload', warnIfUnsavedChanges );\n\t\t};\n\t}, [ isDirty ] );\n\n\treturn null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAaA,SAAwB,wBAAwB;CAC/C,MAAM,WAAA,GAAUA,gBAAAA,UAAAA,EAAa,WAAY;EACxC,MAAM,EAAE,yBAAyB,OAAQC,qBAAAA,KAAiB;EAG1D,OAF0B,qBAEH,CAAC,EAAE,SAAS;CACpC,GAAG,CAAC,CAAE;CAEN,CAAA,GAAA,mBAAA,UAAA,OAAiB;;;;;;;;EAQhB,MAAM,wBAAyB,UAAW;GACzC,IAAK,SAAU;IACd,MAAM,eAAA,GAAcC,gBAAAA,GAAAA,CACnB,8DACD;IACA,OAAO,MAAM;GACd;EACD;EAEA,OAAO,iBAAkB,gBAAgB,oBAAqB;EAE9D,aAAa;GACZ,OAAO,oBAAqB,gBAAgB,oBAAqB;EAClE;CACD,GAAG,CAAE,OAAQ,CAAE;CAEf,OAAO;AACR"}
|