@wordpress/edit-site 5.7.0 → 5.9.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/add-new-template/new-template.js +2 -1
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/index.js +7 -7
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +6 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +117 -0
- package/build/components/editor-canvas-container/index.js.map +1 -0
- package/build/components/global-styles/border-panel.js +81 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +6 -8
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +11 -1
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +53 -0
- package/build/components/global-styles/effects-panel.js.map +1 -0
- package/build/components/global-styles/filters-panel.js +50 -0
- package/build/components/global-styles/filters-panel.js.map +1 -0
- package/build/components/global-styles/global-styles-provider.js +4 -15
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/preview.js +1 -1
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +14 -8
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-css.js +1 -1
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-effects.js +15 -7
- package/build/components/global-styles/screen-effects.js.map +1 -1
- package/build/components/global-styles/screen-filters.js +2 -2
- package/build/components/global-styles/screen-filters.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +8 -118
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +149 -0
- package/build/components/global-styles/style-variations-container.js.map +1 -0
- package/build/components/global-styles/ui.js +52 -15
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/header-edit-mode/index.js +11 -7
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +1 -1
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +0 -137
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +17 -8
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/table.js +3 -3
- package/build/components/list/table.js.map +1 -1
- package/build/components/preferences-modal/index.js +4 -0
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/sidebar/index.js +4 -0
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +28 -13
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +8 -6
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +58 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-main/index.js +5 -0
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +114 -9
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build/components/site-hub/index.js +40 -17
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/site-icon/index.js +8 -7
- package/build/components/site-icon/index.js.map +1 -1
- package/build/components/start-template-options/index.js +9 -8
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/components/style-book/index.js +9 -41
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -3
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/template-details/index.js +3 -1
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/welcome-guide/styles.js +1 -1
- package/build/components/welcome-guide/styles.js.map +1 -1
- package/build/hooks/commands/index.js +19 -0
- package/build/hooks/commands/index.js.map +1 -0
- package/build/hooks/commands/use-navigation-commands.js +126 -0
- package/build/hooks/commands/use-navigation-commands.js.map +1 -0
- package/build/hooks/commands/use-wp-admin-commands.js +97 -0
- package/build/hooks/commands/use-wp-admin-commands.js.map +1 -0
- package/build/hooks/template-part-edit.js +2 -1
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/store/private-actions.js +19 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +13 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +23 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +2 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +3 -2
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/index.js +6 -6
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +6 -4
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +100 -0
- package/build-module/components/editor-canvas-container/index.js.map +1 -0
- package/build-module/components/global-styles/border-panel.js +81 -1
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +6 -6
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +11 -1
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +43 -0
- package/build-module/components/global-styles/effects-panel.js.map +1 -0
- package/build-module/components/global-styles/filters-panel.js +40 -0
- package/build-module/components/global-styles/filters-panel.js.map +1 -0
- package/build-module/components/global-styles/global-styles-provider.js +5 -16
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/preview.js +1 -1
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +13 -8
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +1 -1
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-effects.js +13 -4
- package/build-module/components/global-styles/screen-effects.js.map +1 -1
- package/build-module/components/global-styles/screen-filters.js +2 -2
- package/build-module/components/global-styles/screen-filters.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +11 -114
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +130 -0
- package/build-module/components/global-styles/style-variations-container.js.map +1 -0
- package/build-module/components/global-styles/ui.js +49 -16
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +10 -7
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -135
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +14 -8
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/table.js +3 -3
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +4 -0
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -0
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +28 -15
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +9 -7
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +41 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-main/index.js +6 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +113 -11
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build-module/components/site-hub/index.js +40 -18
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/site-icon/index.js +8 -7
- package/build-module/components/site-icon/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +9 -8
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/components/style-book/index.js +10 -41
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -3
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/template-details/index.js +3 -1
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/welcome-guide/styles.js +1 -1
- package/build-module/components/welcome-guide/styles.js.map +1 -1
- package/build-module/hooks/commands/index.js +10 -0
- package/build-module/hooks/commands/index.js.map +1 -0
- package/build-module/hooks/commands/use-navigation-commands.js +109 -0
- package/build-module/hooks/commands/use-navigation-commands.js.map +1 -0
- package/build-module/hooks/commands/use-wp-admin-commands.js +81 -0
- package/build-module/hooks/commands/use-wp-admin-commands.js.map +1 -0
- package/build-module/hooks/template-part-edit.js +2 -1
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/private-actions.js +15 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +11 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +23 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +2 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +133 -107
- package/build-style/style.css +133 -107
- package/package.json +34 -32
- package/src/components/add-new-template/new-template.js +3 -0
- package/src/components/block-editor/index.js +8 -8
- package/src/components/editor/index.js +11 -3
- package/src/components/editor-canvas-container/index.js +115 -0
- package/src/components/editor-canvas-container/style.scss +19 -0
- package/src/components/global-styles/border-panel.js +73 -1
- package/src/components/global-styles/context-menu.js +6 -6
- package/src/components/global-styles/dimensions-panel.js +11 -0
- package/src/components/global-styles/effects-panel.js +40 -0
- package/src/components/global-styles/filters-panel.js +39 -0
- package/src/components/global-styles/global-styles-provider.js +4 -18
- package/src/components/global-styles/preview.js +1 -1
- package/src/components/global-styles/screen-block-list.js +9 -5
- package/src/components/global-styles/screen-css.js +1 -1
- package/src/components/global-styles/screen-effects.js +12 -5
- package/src/components/global-styles/screen-filters.js +2 -2
- package/src/components/global-styles/screen-style-variations.js +10 -129
- package/src/components/global-styles/style-variations-container.js +136 -0
- package/src/components/global-styles/style.scss +0 -39
- package/src/components/global-styles/ui.js +54 -8
- package/src/components/header-edit-mode/index.js +14 -5
- package/src/components/header-edit-mode/more-menu/index.js +1 -1
- package/src/components/keyboard-shortcuts/index.js +1 -155
- package/src/components/layout/index.js +13 -16
- package/src/components/layout/style.scss +31 -4
- package/src/components/list/table.js +16 -2
- package/src/components/preferences-modal/index.js +7 -0
- package/src/components/secondary-sidebar/style.scss +23 -5
- package/src/components/sidebar/index.js +4 -0
- package/src/components/sidebar/style.scss +2 -1
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +36 -17
- package/src/components/sidebar-navigation-screen/index.js +10 -5
- package/src/components/sidebar-navigation-screen/style.scss +20 -5
- package/src/components/sidebar-navigation-screen-global-styles/index.js +41 -0
- package/src/components/sidebar-navigation-screen-main/index.js +9 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +134 -9
- package/src/components/site-hub/index.js +51 -23
- package/src/components/site-icon/index.js +6 -11
- package/src/components/site-icon/style.scss +8 -3
- package/src/components/start-template-options/index.js +13 -12
- package/src/components/start-template-options/style.scss +18 -43
- package/src/components/style-book/index.js +7 -51
- package/src/components/style-book/style.scss +0 -18
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +4 -3
- package/src/components/template-details/index.js +1 -0
- package/src/components/welcome-guide/styles.js +1 -1
- package/src/hooks/commands/index.js +10 -0
- package/src/hooks/commands/use-navigation-commands.js +112 -0
- package/src/hooks/commands/use-wp-admin-commands.js +79 -0
- package/src/hooks/template-part-edit.js +1 -0
- package/src/index.js +1 -0
- package/src/store/private-actions.js +14 -0
- package/src/store/private-selectors.js +11 -0
- package/src/store/reducer.js +18 -0
- package/src/store/selectors.js +2 -1
- package/src/style.scss +1 -0
- package/build/components/global-styles/duotone-panel.js +0 -78
- package/build/components/global-styles/duotone-panel.js.map +0 -1
- package/build/components/global-styles/filter-utils.js +0 -17
- package/build/components/global-styles/filter-utils.js.map +0 -1
- package/build/components/global-styles/shadow-panel.js +0 -197
- package/build/components/global-styles/shadow-panel.js.map +0 -1
- package/build-module/components/global-styles/duotone-panel.js +0 -67
- package/build-module/components/global-styles/duotone-panel.js.map +0 -1
- package/build-module/components/global-styles/filter-utils.js +0 -9
- package/build-module/components/global-styles/filter-utils.js.map +0 -1
- package/build-module/components/global-styles/shadow-panel.js +0 -178
- package/build-module/components/global-styles/shadow-panel.js.map +0 -1
- package/src/components/global-styles/duotone-panel.js +0 -82
- package/src/components/global-styles/filter-utils.js +0 -9
- package/src/components/global-styles/shadow-panel.js +0 -178
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { Children, cloneElement, useState, useMemo } from '@wordpress/element';
|
|
7
|
+
import { Button, privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
8
|
+
import { ESCAPE } from '@wordpress/keycodes';
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
|
+
import { closeSmall } from '@wordpress/icons';
|
|
12
|
+
import { useFocusOnMount, useFocusReturn } from '@wordpress/compose';
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { unlock } from '../../private-apis';
|
|
18
|
+
import { store as editSiteStore } from '../../store';
|
|
19
|
+
/**
|
|
20
|
+
* Returns a translated string for the title of the editor canvas container.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} view Editor canvas container view.
|
|
23
|
+
*
|
|
24
|
+
* @return {string} Translated string corresponding to value of view. Default is ''.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export function getEditorCanvasContainerTitle(view) {
|
|
28
|
+
switch (view) {
|
|
29
|
+
case 'style-book':
|
|
30
|
+
return __('Style Book');
|
|
31
|
+
|
|
32
|
+
default:
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
} // Creates a private slot fill.
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
createPrivateSlotFill
|
|
39
|
+
} = unlock(componentsPrivateApis);
|
|
40
|
+
const SLOT_FILL_NAME = 'EditSiteEditorCanvasContainerSlot';
|
|
41
|
+
const {
|
|
42
|
+
Slot: EditorCanvasContainerSlot,
|
|
43
|
+
Fill: EditorCanvasContainerFill
|
|
44
|
+
} = createPrivateSlotFill(SLOT_FILL_NAME);
|
|
45
|
+
|
|
46
|
+
function EditorCanvasContainer(_ref) {
|
|
47
|
+
let {
|
|
48
|
+
children,
|
|
49
|
+
closeButtonLabel,
|
|
50
|
+
onClose = () => {}
|
|
51
|
+
} = _ref;
|
|
52
|
+
const editorCanvasContainerView = useSelect(select => unlock(select(editSiteStore)).getEditorCanvasContainerView(), []);
|
|
53
|
+
const [isClosed, setIsClosed] = useState(false);
|
|
54
|
+
const {
|
|
55
|
+
setEditorCanvasContainerView
|
|
56
|
+
} = unlock(useDispatch(editSiteStore));
|
|
57
|
+
const focusOnMountRef = useFocusOnMount('firstElement');
|
|
58
|
+
const sectionFocusReturnRef = useFocusReturn();
|
|
59
|
+
const title = useMemo(() => getEditorCanvasContainerTitle(editorCanvasContainerView), [editorCanvasContainerView]);
|
|
60
|
+
|
|
61
|
+
function onCloseContainer() {
|
|
62
|
+
onClose();
|
|
63
|
+
setEditorCanvasContainerView(undefined);
|
|
64
|
+
setIsClosed(true);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function closeOnEscape(event) {
|
|
68
|
+
if (event.keyCode === ESCAPE && !event.defaultPrevented) {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
onCloseContainer();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const childrenWithProps = Array.isArray(children) ? Children.map(children, (child, index) => index === 0 ? cloneElement(child, {
|
|
75
|
+
ref: sectionFocusReturnRef
|
|
76
|
+
}) : child) : cloneElement(children, {
|
|
77
|
+
ref: sectionFocusReturnRef
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (isClosed) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return createElement(EditorCanvasContainerFill, null, createElement("section", {
|
|
85
|
+
className: "edit-site-editor-canvas-container",
|
|
86
|
+
ref: focusOnMountRef,
|
|
87
|
+
onKeyDown: closeOnEscape,
|
|
88
|
+
"aria-label": title
|
|
89
|
+
}, createElement(Button, {
|
|
90
|
+
className: "edit-site-editor-canvas-container__close-button",
|
|
91
|
+
icon: closeSmall,
|
|
92
|
+
label: closeButtonLabel || __('Close'),
|
|
93
|
+
onClick: onCloseContainer,
|
|
94
|
+
showTooltip: false
|
|
95
|
+
}), childrenWithProps));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
EditorCanvasContainer.Slot = EditorCanvasContainerSlot;
|
|
99
|
+
export default EditorCanvasContainer;
|
|
100
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/editor-canvas-container/index.js"],"names":["Children","cloneElement","useState","useMemo","Button","privateApis","componentsPrivateApis","ESCAPE","__","useDispatch","useSelect","closeSmall","useFocusOnMount","useFocusReturn","unlock","store","editSiteStore","getEditorCanvasContainerTitle","view","createPrivateSlotFill","SLOT_FILL_NAME","Slot","EditorCanvasContainerSlot","Fill","EditorCanvasContainerFill","EditorCanvasContainer","children","closeButtonLabel","onClose","editorCanvasContainerView","select","getEditorCanvasContainerView","isClosed","setIsClosed","setEditorCanvasContainerView","focusOnMountRef","sectionFocusReturnRef","title","onCloseContainer","undefined","closeOnEscape","event","keyCode","defaultPrevented","preventDefault","childrenWithProps","Array","isArray","map","child","index","ref"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,YAAnB,EAAiCC,QAAjC,EAA2CC,OAA3C,QAA0D,oBAA1D;AACA,SACCC,MADD,EAECC,WAAW,IAAIC,qBAFhB,QAGO,uBAHP;AAIA,SAASC,MAAT,QAAuB,qBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,UAAT,QAA2B,kBAA3B;AACA,SAASC,eAAT,EAA0BC,cAA1B,QAAgD,oBAAhD;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,6BAAT,CAAwCC,IAAxC,EAA+C;AACrD,UAASA,IAAT;AACC,SAAK,YAAL;AACC,aAAOV,EAAE,CAAE,YAAF,CAAT;;AACD;AACC,aAAO,EAAP;AAJF;AAMA,C,CAED;;AACA,MAAM;AAAEW,EAAAA;AAAF,IAA4BL,MAAM,CAAER,qBAAF,CAAxC;AACA,MAAMc,cAAc,GAAG,mCAAvB;AACA,MAAM;AAAEC,EAAAA,IAAI,EAAEC,yBAAR;AAAmCC,EAAAA,IAAI,EAAEC;AAAzC,IACLL,qBAAqB,CAAEC,cAAF,CADtB;;AAGA,SAASK,qBAAT,OAII;AAAA,MAJ4B;AAC/BC,IAAAA,QAD+B;AAE/BC,IAAAA,gBAF+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,GAAZ,CARf;;AAYA,MAAKJ,QAAL,EAAgB;AACf,WAAO,IAAP;AACA;;AAED,SACC,cAAC,yBAAD,QAEC;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,GAAG,EAAGG,eAFP;AAGC,IAAA,SAAS,EAAGK,aAHb;AAIC,kBAAaH;AAJd,KAMC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAG1B,UAFR;AAGC,IAAA,KAAK,EAAGgB,gBAAgB,IAAInB,EAAE,CAAE,OAAF,CAH/B;AAIC,IAAA,OAAO,EAAG8B,gBAJX;AAKC,IAAA,WAAW,EAAG;AALf,IAND,EAaGO,iBAbH,CAFD,CADD;AAoBA;;AAEDpB,qBAAqB,CAACJ,IAAtB,GAA6BC,yBAA7B;AACA,eAAeG,qBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Children, cloneElement, useState, useMemo } from '@wordpress/element';\nimport {\n\tButton,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { closeSmall } from '@wordpress/icons';\nimport { useFocusOnMount, useFocusReturn } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\n\n/**\n * Returns a translated string for the title of the editor canvas container.\n *\n * @param {string} view Editor canvas container view.\n *\n * @return {string} Translated string corresponding to value of view. Default is ''.\n */\nexport function getEditorCanvasContainerTitle( view ) {\n\tswitch ( view ) {\n\t\tcase 'style-book':\n\t\t\treturn __( 'Style Book' );\n\t\tdefault:\n\t\t\treturn '';\n\t}\n}\n\n// Creates a private slot fill.\nconst { createPrivateSlotFill } = unlock( componentsPrivateApis );\nconst SLOT_FILL_NAME = 'EditSiteEditorCanvasContainerSlot';\nconst { Slot: EditorCanvasContainerSlot, Fill: EditorCanvasContainerFill } =\n\tcreatePrivateSlotFill( SLOT_FILL_NAME );\n\nfunction EditorCanvasContainer( {\n\tchildren,\n\tcloseButtonLabel,\n\tonClose = () => {},\n} ) {\n\tconst editorCanvasContainerView = useSelect(\n\t\t( select ) =>\n\t\t\tunlock( select( editSiteStore ) ).getEditorCanvasContainerView(),\n\t\t[]\n\t);\n\tconst [ isClosed, setIsClosed ] = useState( false );\n\tconst { setEditorCanvasContainerView } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\tconst sectionFocusReturnRef = useFocusReturn();\n\tconst title = useMemo(\n\t\t() => getEditorCanvasContainerTitle( editorCanvasContainerView ),\n\t\t[ editorCanvasContainerView ]\n\t);\n\tfunction onCloseContainer() {\n\t\tonClose();\n\t\tsetEditorCanvasContainerView( undefined );\n\t\tsetIsClosed( true );\n\t}\n\n\tfunction closeOnEscape( event ) {\n\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\tevent.preventDefault();\n\t\t\tonCloseContainer();\n\t\t}\n\t}\n\n\tconst childrenWithProps = Array.isArray( children )\n\t\t? Children.map( children, ( child, index ) =>\n\t\t\t\tindex === 0\n\t\t\t\t\t? cloneElement( child, {\n\t\t\t\t\t\t\tref: sectionFocusReturnRef,\n\t\t\t\t\t } )\n\t\t\t\t\t: child\n\t\t )\n\t\t: cloneElement( children, {\n\t\t\t\tref: sectionFocusReturnRef,\n\t\t } );\n\n\tif ( isClosed ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<EditorCanvasContainerFill>\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\n\t\t\t<section\n\t\t\t\tclassName=\"edit-site-editor-canvas-container\"\n\t\t\t\tref={ focusOnMountRef }\n\t\t\t\tonKeyDown={ closeOnEscape }\n\t\t\t\taria-label={ title }\n\t\t\t>\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"edit-site-editor-canvas-container__close-button\"\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ closeButtonLabel || __( 'Close' ) }\n\t\t\t\t\tonClick={ onCloseContainer }\n\t\t\t\t\tshowTooltip={ false }\n\t\t\t\t/>\n\t\t\t\t{ childrenWithProps }\n\t\t\t</section>\n\t\t</EditorCanvasContainerFill>\n\t);\n}\n\nEditorCanvasContainer.Slot = EditorCanvasContainerSlot;\nexport default EditorCanvasContainer;\n"]}
|
|
@@ -4,6 +4,7 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
7
|
+
import { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
9
10
|
*/
|
|
@@ -15,6 +16,44 @@ const {
|
|
|
15
16
|
useSettingsForBlockElement,
|
|
16
17
|
BorderPanel: StylesBorderPanel
|
|
17
18
|
} = unlock(blockEditorPrivateApis);
|
|
19
|
+
|
|
20
|
+
function applyFallbackStyle(border) {
|
|
21
|
+
if (!border) {
|
|
22
|
+
return border;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const hasColorOrWidth = border.color || border.width;
|
|
26
|
+
|
|
27
|
+
if (!border.style && hasColorOrWidth) {
|
|
28
|
+
return { ...border,
|
|
29
|
+
style: 'solid'
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (border.style && !hasColorOrWidth) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return border;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function applyAllFallbackStyles(border) {
|
|
41
|
+
if (!border) {
|
|
42
|
+
return border;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (hasSplitBorders(border)) {
|
|
46
|
+
return {
|
|
47
|
+
top: applyFallbackStyle(border.top),
|
|
48
|
+
right: applyFallbackStyle(border.right),
|
|
49
|
+
bottom: applyFallbackStyle(border.bottom),
|
|
50
|
+
left: applyFallbackStyle(border.left)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return applyFallbackStyle(border);
|
|
55
|
+
}
|
|
56
|
+
|
|
18
57
|
export default function BorderPanel(_ref) {
|
|
19
58
|
let {
|
|
20
59
|
name,
|
|
@@ -33,10 +72,51 @@ export default function BorderPanel(_ref) {
|
|
|
33
72
|
});
|
|
34
73
|
const [rawSettings] = useGlobalSetting('', name);
|
|
35
74
|
const settings = useSettingsForBlockElement(rawSettings, name);
|
|
75
|
+
|
|
76
|
+
const onChange = newStyle => {
|
|
77
|
+
if (!(newStyle !== null && newStyle !== void 0 && newStyle.border)) {
|
|
78
|
+
setStyle(newStyle);
|
|
79
|
+
return;
|
|
80
|
+
} // As Global Styles can't conditionally generate styles based on if
|
|
81
|
+
// other style properties have been set, we need to force split
|
|
82
|
+
// border definitions for user set global border styles. Border
|
|
83
|
+
// radius is derived from the same property i.e. `border.radius` if
|
|
84
|
+
// it is a string that is used. The longhand border radii styles are
|
|
85
|
+
// only generated if that property is an object.
|
|
86
|
+
//
|
|
87
|
+
// For borders (color, style, and width) those are all properties on
|
|
88
|
+
// the `border` style property. This means if the theme.json defined
|
|
89
|
+
// split borders and the user condenses them into a flat border or
|
|
90
|
+
// vice-versa we'd get both sets of styles which would conflict.
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
const {
|
|
94
|
+
radius,
|
|
95
|
+
...newBorder
|
|
96
|
+
} = newStyle.border;
|
|
97
|
+
const border = applyAllFallbackStyles(newBorder);
|
|
98
|
+
const updatedBorder = !hasSplitBorders(border) ? {
|
|
99
|
+
top: border,
|
|
100
|
+
right: border,
|
|
101
|
+
bottom: border,
|
|
102
|
+
left: border
|
|
103
|
+
} : {
|
|
104
|
+
color: null,
|
|
105
|
+
style: null,
|
|
106
|
+
width: null,
|
|
107
|
+
...border
|
|
108
|
+
};
|
|
109
|
+
setStyle({ ...newStyle,
|
|
110
|
+
border: { ...updatedBorder,
|
|
111
|
+
radius
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
36
116
|
return createElement(StylesBorderPanel, {
|
|
37
117
|
inheritedValue: inheritedStyle,
|
|
38
118
|
value: style,
|
|
39
|
-
onChange:
|
|
119
|
+
onChange: onChange,
|
|
40
120
|
settings: settings
|
|
41
121
|
});
|
|
42
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/border-panel.js"],"names":["privateApis","blockEditorPrivateApis","unlock","useGlobalStyle","useGlobalSetting","useSettingsForBlockElement","BorderPanel","StylesBorderPanel","name","variation","prefixParts","concat","prefix","join","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/border-panel.js"],"names":["privateApis","blockEditorPrivateApis","__experimentalHasSplitBorders","hasSplitBorders","unlock","useGlobalStyle","useGlobalSetting","useSettingsForBlockElement","BorderPanel","StylesBorderPanel","applyFallbackStyle","border","hasColorOrWidth","color","width","style","undefined","applyAllFallbackStyles","top","right","bottom","left","name","variation","prefixParts","concat","prefix","join","inheritedStyle","setStyle","shouldDecodeEncode","rawSettings","settings","onChange","newStyle","radius","newBorder","updatedBorder"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AACA,SAASC,6BAA6B,IAAIC,eAA1C,QAAiE,uBAAjE;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,MAAM;AACLC,EAAAA,cADK;AAELC,EAAAA,gBAFK;AAGLC,EAAAA,0BAHK;AAILC,EAAAA,WAAW,EAAEC;AAJR,IAKFL,MAAM,CAAEH,sBAAF,CALV;;AAOA,SAASS,kBAAT,CAA6BC,MAA7B,EAAsC;AACrC,MAAK,CAAEA,MAAP,EAAgB;AACf,WAAOA,MAAP;AAC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K,EAAGb,KAFT;AAGC,IAAA,QAAQ,EAAGkB,QAHZ;AAIC,IAAA,QAAQ,EAAGD;AAJZ,IADD;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst {\n\tuseGlobalStyle,\n\tuseGlobalSetting,\n\tuseSettingsForBlockElement,\n\tBorderPanel: StylesBorderPanel,\n} = unlock( blockEditorPrivateApis );\n\nfunction applyFallbackStyle( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tconst hasColorOrWidth = border.color || border.width;\n\n\tif ( ! border.style && hasColorOrWidth ) {\n\t\treturn { ...border, style: 'solid' };\n\t}\n\n\tif ( border.style && ! hasColorOrWidth ) {\n\t\treturn undefined;\n\t}\n\n\treturn border;\n}\n\nfunction applyAllFallbackStyles( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( hasSplitBorders( border ) ) {\n\t\treturn {\n\t\t\ttop: applyFallbackStyle( border.top ),\n\t\t\tright: applyFallbackStyle( border.right ),\n\t\t\tbottom: applyFallbackStyle( border.bottom ),\n\t\t\tleft: applyFallbackStyle( border.left ),\n\t\t};\n\t}\n\n\treturn applyFallbackStyle( border );\n}\n\nexport default function BorderPanel( { name, variation = '' } ) {\n\tlet prefixParts = [];\n\tif ( variation ) {\n\t\tprefixParts = [ 'variations', variation ].concat( prefixParts );\n\t}\n\tconst prefix = prefixParts.join( '.' );\n\n\tconst [ style ] = useGlobalStyle( prefix, name, 'user', false );\n\tconst [ inheritedStyle, setStyle ] = useGlobalStyle( prefix, name, 'all', {\n\t\tshouldDecodeEncode: false,\n\t} );\n\tconst [ rawSettings ] = useGlobalSetting( '', name );\n\tconst settings = useSettingsForBlockElement( rawSettings, name );\n\n\tconst onChange = ( newStyle ) => {\n\t\tif ( ! newStyle?.border ) {\n\t\t\tsetStyle( newStyle );\n\t\t\treturn;\n\t\t}\n\n\t\t// As Global Styles can't conditionally generate styles based on if\n\t\t// other style properties have been set, we need to force split\n\t\t// border definitions for user set global border styles. Border\n\t\t// radius is derived from the same property i.e. `border.radius` if\n\t\t// it is a string that is used. The longhand border radii styles are\n\t\t// only generated if that property is an object.\n\t\t//\n\t\t// For borders (color, style, and width) those are all properties on\n\t\t// the `border` style property. This means if the theme.json defined\n\t\t// split borders and the user condenses them into a flat border or\n\t\t// vice-versa we'd get both sets of styles which would conflict.\n\t\tconst { radius, ...newBorder } = newStyle.border;\n\t\tconst border = applyAllFallbackStyles( newBorder );\n\t\tconst updatedBorder = ! hasSplitBorders( border )\n\t\t\t? {\n\t\t\t\t\ttop: border,\n\t\t\t\t\tright: border,\n\t\t\t\t\tbottom: border,\n\t\t\t\t\tleft: border,\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\tcolor: null,\n\t\t\t\t\tstyle: null,\n\t\t\t\t\twidth: null,\n\t\t\t\t\t...border,\n\t\t\t };\n\n\t\tsetStyle( { ...newStyle, border: { ...updatedBorder, radius } } );\n\t};\n\n\treturn (\n\t\t<StylesBorderPanel\n\t\t\tinheritedValue={ inheritedStyle }\n\t\t\tvalue={ style }\n\t\t\tonChange={ onChange }\n\t\t\tsettings={ settings }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -13,18 +13,18 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { useHasFilterPanel } from './filter-utils';
|
|
17
16
|
import { useHasVariationsPanel } from './variations-panel';
|
|
18
17
|
import { NavigationButtonAsItem } from './navigation-button';
|
|
19
18
|
import { IconWithCurrentColor } from './icon-with-current-color';
|
|
20
19
|
import { ScreenVariations } from './screen-variations';
|
|
21
|
-
import { useHasShadowControl } from './shadow-panel';
|
|
22
20
|
import { unlock } from '../../private-apis';
|
|
23
21
|
const {
|
|
24
22
|
useHasDimensionsPanel,
|
|
25
23
|
useHasTypographyPanel,
|
|
26
24
|
useHasBorderPanel,
|
|
27
25
|
useHasColorPanel,
|
|
26
|
+
useHasEffectsPanel,
|
|
27
|
+
useHasFiltersPanel,
|
|
28
28
|
useGlobalSetting,
|
|
29
29
|
useSettingsForBlockElement
|
|
30
30
|
} = unlock(blockEditorPrivateApis);
|
|
@@ -39,8 +39,8 @@ function ContextMenu(_ref) {
|
|
|
39
39
|
const hasTypographyPanel = useHasTypographyPanel(settings);
|
|
40
40
|
const hasColorPanel = useHasColorPanel(settings);
|
|
41
41
|
const hasBorderPanel = useHasBorderPanel(settings);
|
|
42
|
-
const hasEffectsPanel =
|
|
43
|
-
const hasFilterPanel =
|
|
42
|
+
const hasEffectsPanel = useHasEffectsPanel(settings);
|
|
43
|
+
const hasFilterPanel = useHasFiltersPanel(settings);
|
|
44
44
|
const hasDimensionsPanel = useHasDimensionsPanel(settings);
|
|
45
45
|
const hasLayoutPanel = hasDimensionsPanel;
|
|
46
46
|
const hasVariationsPanel = useHasVariationsPanel(name, parentMenu);
|
|
@@ -77,8 +77,8 @@ function ContextMenu(_ref) {
|
|
|
77
77
|
}, __('Border')), hasEffectsPanel && createElement(NavigationButtonAsItem, {
|
|
78
78
|
icon: shadow,
|
|
79
79
|
path: parentMenu + '/effects',
|
|
80
|
-
"aria-label": __('
|
|
81
|
-
}, __('
|
|
80
|
+
"aria-label": __('Effects')
|
|
81
|
+
}, __('Effects')), hasFilterPanel && createElement(NavigationButtonAsItem, {
|
|
82
82
|
icon: filter,
|
|
83
83
|
path: parentMenu + '/filters',
|
|
84
84
|
"aria-label": __('Filters styles')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/context-menu.js"],"names":["__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalSpacer","Spacer","FlexItem","CardBody","CardDivider","typography","border","filter","shadow","color","layout","chevronLeft","chevronRight","isRTL","__","useSelect","store","coreStore","privateApis","blockEditorPrivateApis","useHasFilterPanel","useHasVariationsPanel","NavigationButtonAsItem","IconWithCurrentColor","ScreenVariations","useHasShadowControl","unlock","useHasDimensionsPanel","useHasTypographyPanel","useHasBorderPanel","useHasColorPanel","useGlobalSetting","useSettingsForBlockElement","ContextMenu","name","parentMenu","rawSettings","settings","hasTypographyPanel","hasColorPanel","hasBorderPanel","hasEffectsPanel","hasFilterPanel","hasDimensionsPanel","hasLayoutPanel","hasVariationsPanel","canEditCSS","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","globalStylesId","globalStyles","undefined","_links","isBlocksPanel","includes"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,uBAAuB,IAAIC,SAD5B,EAECC,oBAAoB,IAAIC,MAFzB,EAGCC,oBAAoB,IAAIC,MAHzB,EAICC,QAJD,EAKCC,QALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SACCC,UADD,EAECC,MAFD,EAGCC,MAHD,EAICC,MAJD,EAKCC,KALD,EAMCC,MAND,EAOCC,WAPD,EAQCC,YARD,QASO,kBATP;AAUA,SAASC,KAAT,EAAgBC,EAAhB,QAA0B,iBAA1B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,gBAAlC;AACA,SAASC,qBAAT,QAAsC,oBAAtC;AACA,SAASC,sBAAT,QAAuC,qBAAvC;AACA,SAASC,oBAAT,QAAqC,2BAArC;AACA,SAASC,gBAAT,QAAiC,qBAAjC;AACA,SAASC,mBAAT,QAAoC,gBAApC;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,MAAM;AACLC,EAAAA,qBADK;AAELC,EAAAA,qBAFK;AAGLC,EAAAA,iBAHK;AAILC,EAAAA,gBAJK;AAKLC,EAAAA,gBAL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A,EAAE,CAAE,QAAF,CALL,CA/CF,EAuDG+B,kBAAkB,IACnB,cAAC,gBAAD;AAAkB,IAAA,IAAI,EAAGX,IAAzB;AAAgC,IAAA,IAAI,EAAGC;AAAvC,IAxDF,EA0DGmB,aAAa,IAAIR,UAAjB,IACD,8BACC,cAAC,WAAD,OADD,EAEC,cAAC,QAAD,QACC,cAAC,MAAD;AAAQ,IAAA,EAAE,EAAC,GAAX;AAAe,IAAA,UAAU,EAAG,CAA5B;AAAgC,IAAA,YAAY,EAAG;AAA/C,KACGhC,EAAE,CACH,qDADG,CADL,CADD,EAMC,cAAC,SAAD,QACC,cAAC,sBAAD;AACC,IAAA,IAAI,EAAGqB,UAAU,GAAG,MADrB;AAEC,kBAAarB,EAAE,CAAE,sBAAF;AAFhB,KAIC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC;AAAhB,KACC,cAAC,QAAD,QACGA,EAAE,CAAE,sBAAF,CADL,CADD,EAIC,cAAC,oBAAD;AACC,IAAA,IAAI,EACHD,KAAK,KACFF,WADE,GAEFC;AAJL,IAJD,CAJD,CADD,CAND,CAFD,EA4BC,cAAC,WAAD,OA5BD,CA3DF,CADD,CADD;AA+FA;;AAED,eAAeqB,WAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalSpacer as Spacer,\n\tFlexItem,\n\tCardBody,\n\tCardDivider,\n} from '@wordpress/components';\nimport {\n\ttypography,\n\tborder,\n\tfilter,\n\tshadow,\n\tcolor,\n\tlayout,\n\tchevronLeft,\n\tchevronRight,\n} from '@wordpress/icons';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { useHasFilterPanel } from './filter-utils';\nimport { useHasVariationsPanel } from './variations-panel';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport { IconWithCurrentColor } from './icon-with-current-color';\nimport { ScreenVariations } from './screen-variations';\nimport { useHasShadowControl } from './shadow-panel';\nimport { unlock } from '../../private-apis';\n\nconst {\n\tuseHasDimensionsPanel,\n\tuseHasTypographyPanel,\n\tuseHasBorderPanel,\n\tuseHasColorPanel,\n\tuseGlobalSetting,\n\tuseSettingsForBlockElement,\n} = unlock( blockEditorPrivateApis );\n\nfunction ContextMenu( { name, parentMenu = '' } ) {\n\tconst [ rawSettings ] = useGlobalSetting( '', name );\n\tconst settings = useSettingsForBlockElement( rawSettings, name );\n\tconst hasTypographyPanel = useHasTypographyPanel( settings );\n\tconst hasColorPanel = useHasColorPanel( settings );\n\tconst hasBorderPanel = useHasBorderPanel( settings );\n\tconst hasEffectsPanel = useHasShadowControl( name );\n\tconst hasFilterPanel = useHasFilterPanel( name );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( settings );\n\tconst hasLayoutPanel = hasDimensionsPanel;\n\tconst hasVariationsPanel = useHasVariationsPanel( name, parentMenu );\n\n\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\tselect( coreStore );\n\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanEditCSS:\n\t\t\t\t!! globalStyles?._links?.[ 'wp:action-edit-css' ] ?? false,\n\t\t};\n\t}, [] );\n\n\tconst isBlocksPanel =\n\t\tparentMenu.includes( 'blocks' ) &&\n\t\t! parentMenu.includes( 'variations' );\n\n\treturn (\n\t\t<>\n\t\t\t<ItemGroup>\n\t\t\t\t{ hasTypographyPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ typography }\n\t\t\t\t\t\tpath={ parentMenu + '/typography' }\n\t\t\t\t\t\taria-label={ __( 'Typography styles' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Typography' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasColorPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ color }\n\t\t\t\t\t\tpath={ parentMenu + '/colors' }\n\t\t\t\t\t\taria-label={ __( 'Colors styles' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Colors' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasBorderPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ border }\n\t\t\t\t\t\tpath={ parentMenu + '/border' }\n\t\t\t\t\t\taria-label={ __( 'Border' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Border' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasEffectsPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ shadow }\n\t\t\t\t\t\tpath={ parentMenu + '/effects' }\n\t\t\t\t\t\taria-label={ __( 'Shadow' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Shadow' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasFilterPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ filter }\n\t\t\t\t\t\tpath={ parentMenu + '/filters' }\n\t\t\t\t\t\taria-label={ __( 'Filters styles' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Filters' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasLayoutPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ layout }\n\t\t\t\t\t\tpath={ parentMenu + '/layout' }\n\t\t\t\t\t\taria-label={ __( 'Layout styles' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Layout' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasVariationsPanel && (\n\t\t\t\t\t<ScreenVariations name={ name } path={ parentMenu } />\n\t\t\t\t) }\n\t\t\t\t{ isBlocksPanel && canEditCSS && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<CardDivider />\n\t\t\t\t\t\t<CardBody>\n\t\t\t\t\t\t\t<Spacer as=\"p\" paddingTop={ 2 } marginBottom={ 4 }>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Add your own CSS to customize the block appearance.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\t\t\t\tpath={ parentMenu + '/css' }\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Additional block CSS' ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Additional block CSS' ) }\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t<IconWithCurrentColor\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronRight\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t\t</CardBody>\n\t\t\t\t\t\t<CardDivider />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</ItemGroup>\n\t\t</>\n\t);\n}\n\nexport default ContextMenu;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/context-menu.js"],"names":["__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalSpacer","Spacer","FlexItem","CardBody","CardDivider","typography","border","filter","shadow","color","layout","chevronLeft","chevronRight","isRTL","__","useSelect","store","coreStore","privateApis","blockEditorPrivateApis","useHasVariationsPanel","NavigationButtonAsItem","IconWithCurrentColor","ScreenVariations","unlock","useHasDimensionsPanel","useHasTypographyPanel","useHasBorderPanel","useHasColorPanel","useHasEffectsPanel","useHasFiltersPanel","useGlobalSetting","useSettingsForBlockElement","ContextMenu","name","parentMenu","rawSettings","settings","hasTypographyPanel","hasColorPanel","hasBorderPanel","hasEffectsPanel","hasFilterPanel","hasDimensionsPanel","hasLayoutPanel","hasVariationsPanel","canEditCSS","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","globalStylesId","globalStyles","undefined","_links","isBlocksPanel","includes"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,uBAAuB,IAAIC,SAD5B,EAECC,oBAAoB,IAAIC,MAFzB,EAGCC,oBAAoB,IAAIC,MAHzB,EAICC,QAJD,EAKCC,QALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SACCC,UADD,EAECC,MAFD,EAGCC,MAHD,EAICC,MAJD,EAKCC,KALD,EAMCC,MAND,EAOCC,WAPD,EAQCC,YARD,QASO,kBATP;AAUA,SAASC,KAAT,EAAgBC,EAAhB,QAA0B,iBAA1B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AAEA;AACA;AACA;;AACA,SAASC,qBAAT,QAAsC,oBAAtC;AACA,SAASC,sBAAT,QAAuC,qBAAvC;AACA,SAASC,oBAAT,Q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;AAGC,kBAAarB,EAAE,CAAE,gBAAF;AAHhB,KAKGA,EAAE,CAAE,SAAF,CALL,CAtCF,EA8CG8B,cAAc,IACf,cAAC,sBAAD;AACC,IAAA,IAAI,EAAGlC,MADR;AAEC,IAAA,IAAI,EAAGyB,UAAU,GAAG,SAFrB;AAGC,kBAAarB,EAAE,CAAE,eAAF;AAHhB,KAKGA,EAAE,CAAE,QAAF,CALL,CA/CF,EAuDG+B,kBAAkB,IACnB,cAAC,gBAAD;AAAkB,IAAA,IAAI,EAAGX,IAAzB;AAAgC,IAAA,IAAI,EAAGC;AAAvC,IAxDF,EA0DGmB,aAAa,IAAIR,UAAjB,IACD,8BACC,cAAC,WAAD,OADD,EAEC,cAAC,QAAD,QACC,cAAC,MAAD;AAAQ,IAAA,EAAE,EAAC,GAAX;AAAe,IAAA,UAAU,EAAG,CAA5B;AAAgC,IAAA,YAAY,EAAG;AAA/C,KACGhC,EAAE,CACH,qDADG,CADL,CADD,EAMC,cAAC,SAAD,QACC,cAAC,sBAAD;AACC,IAAA,IAAI,EAAGqB,UAAU,GAAG,MADrB;AAEC,kBAAarB,EAAE,CAAE,sBAAF;AAFhB,KAIC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC;AAAhB,KACC,cAAC,QAAD,QACGA,EAAE,CAAE,sBAAF,CADL,CADD,EAIC,cAAC,oBAAD;AACC,IAAA,IAAI,EACHD,KAAK,KACFF,WADE,GAEFC;AAJL,IAJD,CAJD,CADD,CAND,CAFD,EA4BC,cAAC,WAAD,OA5BD,CA3DF,CADD,CADD;AA+FA;;AAED,eAAeqB,WAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalSpacer as Spacer,\n\tFlexItem,\n\tCardBody,\n\tCardDivider,\n} from '@wordpress/components';\nimport {\n\ttypography,\n\tborder,\n\tfilter,\n\tshadow,\n\tcolor,\n\tlayout,\n\tchevronLeft,\n\tchevronRight,\n} from '@wordpress/icons';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { useHasVariationsPanel } from './variations-panel';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport { IconWithCurrentColor } from './icon-with-current-color';\nimport { ScreenVariations } from './screen-variations';\nimport { unlock } from '../../private-apis';\n\nconst {\n\tuseHasDimensionsPanel,\n\tuseHasTypographyPanel,\n\tuseHasBorderPanel,\n\tuseHasColorPanel,\n\tuseHasEffectsPanel,\n\tuseHasFiltersPanel,\n\tuseGlobalSetting,\n\tuseSettingsForBlockElement,\n} = unlock( blockEditorPrivateApis );\n\nfunction ContextMenu( { name, parentMenu = '' } ) {\n\tconst [ rawSettings ] = useGlobalSetting( '', name );\n\tconst settings = useSettingsForBlockElement( rawSettings, name );\n\tconst hasTypographyPanel = useHasTypographyPanel( settings );\n\tconst hasColorPanel = useHasColorPanel( settings );\n\tconst hasBorderPanel = useHasBorderPanel( settings );\n\tconst hasEffectsPanel = useHasEffectsPanel( settings );\n\tconst hasFilterPanel = useHasFiltersPanel( settings );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( settings );\n\tconst hasLayoutPanel = hasDimensionsPanel;\n\tconst hasVariationsPanel = useHasVariationsPanel( name, parentMenu );\n\n\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\tselect( coreStore );\n\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanEditCSS:\n\t\t\t\t!! globalStyles?._links?.[ 'wp:action-edit-css' ] ?? false,\n\t\t};\n\t}, [] );\n\n\tconst isBlocksPanel =\n\t\tparentMenu.includes( 'blocks' ) &&\n\t\t! parentMenu.includes( 'variations' );\n\n\treturn (\n\t\t<>\n\t\t\t<ItemGroup>\n\t\t\t\t{ hasTypographyPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ typography }\n\t\t\t\t\t\tpath={ parentMenu + '/typography' }\n\t\t\t\t\t\taria-label={ __( 'Typography styles' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Typography' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasColorPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ color }\n\t\t\t\t\t\tpath={ parentMenu + '/colors' }\n\t\t\t\t\t\taria-label={ __( 'Colors styles' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Colors' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasBorderPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ border }\n\t\t\t\t\t\tpath={ parentMenu + '/border' }\n\t\t\t\t\t\taria-label={ __( 'Border' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Border' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasEffectsPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ shadow }\n\t\t\t\t\t\tpath={ parentMenu + '/effects' }\n\t\t\t\t\t\taria-label={ __( 'Effects' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Effects' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasFilterPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ filter }\n\t\t\t\t\t\tpath={ parentMenu + '/filters' }\n\t\t\t\t\t\taria-label={ __( 'Filters styles' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Filters' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasLayoutPanel && (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\ticon={ layout }\n\t\t\t\t\t\tpath={ parentMenu + '/layout' }\n\t\t\t\t\t\taria-label={ __( 'Layout styles' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Layout' ) }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t) }\n\t\t\t\t{ hasVariationsPanel && (\n\t\t\t\t\t<ScreenVariations name={ name } path={ parentMenu } />\n\t\t\t\t) }\n\t\t\t\t{ isBlocksPanel && canEditCSS && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<CardDivider />\n\t\t\t\t\t\t<CardBody>\n\t\t\t\t\t\t\t<Spacer as=\"p\" paddingTop={ 2 } marginBottom={ 4 }>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Add your own CSS to customize the block appearance.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\t\t\t\tpath={ parentMenu + '/css' }\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Additional block CSS' ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Additional block CSS' ) }\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t<IconWithCurrentColor\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronRight\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t\t</CardBody>\n\t\t\t\t\t\t<CardDivider />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</ItemGroup>\n\t\t</>\n\t);\n}\n\nexport default ContextMenu;\n"]}
|
|
@@ -16,6 +16,15 @@ const {
|
|
|
16
16
|
useSettingsForBlockElement,
|
|
17
17
|
DimensionsPanel: StylesDimensionsPanel
|
|
18
18
|
} = unlock(blockEditorPrivateApis);
|
|
19
|
+
const DEFAULT_CONTROLS = {
|
|
20
|
+
contentSize: true,
|
|
21
|
+
wideSize: true,
|
|
22
|
+
padding: true,
|
|
23
|
+
margin: true,
|
|
24
|
+
blockGap: true,
|
|
25
|
+
minHeight: true,
|
|
26
|
+
childLayout: false
|
|
27
|
+
};
|
|
19
28
|
export default function DimensionsPanel(_ref) {
|
|
20
29
|
let {
|
|
21
30
|
name,
|
|
@@ -65,7 +74,8 @@ export default function DimensionsPanel(_ref) {
|
|
|
65
74
|
value: styleWithLayout,
|
|
66
75
|
onChange: onChange,
|
|
67
76
|
settings: settings,
|
|
68
|
-
includeLayoutControls: true
|
|
77
|
+
includeLayoutControls: true,
|
|
78
|
+
defaultControls: DEFAULT_CONTROLS
|
|
69
79
|
});
|
|
70
80
|
}
|
|
71
81
|
//# sourceMappingURL=dimensions-panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/dimensions-panel.js"],"names":["privateApis","blockEditorPrivateApis","useMemo","unlock","useGlobalStyle","useGlobalSetting","useSettingsForBlockElement","DimensionsPanel","StylesDimensionsPanel","name","variation","prefixParts","concat","prefix","join","style","inheritedStyle","setStyle","shouldDecodeEncode","rawSettings","setSettings","settings","inheritedStyleWithLayout","layout","styleWithLayout","onChange","newStyle","updatedStyle"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AACA,SAASC,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,MAAM;AACLC,EAAAA,cADK;AAELC,EAAAA,gBAFK;AAGLC,EAAAA,0BAHK;AAILC,EAAAA,eAAe,EAAEC;AAJZ,IAKFL,MAAM,CAAEF,sBAAF,CALV;AAOA,eAAe,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/dimensions-panel.js"],"names":["privateApis","blockEditorPrivateApis","useMemo","unlock","useGlobalStyle","useGlobalSetting","useSettingsForBlockElement","DimensionsPanel","StylesDimensionsPanel","DEFAULT_CONTROLS","contentSize","wideSize","padding","margin","blockGap","minHeight","childLayout","name","variation","prefixParts","concat","prefix","join","style","inheritedStyle","setStyle","shouldDecodeEncode","rawSettings","setSettings","settings","inheritedStyleWithLayout","layout","styleWithLayout","onChange","newStyle","updatedStyle"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AACA,SAASC,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,MAAM;AACLC,EAAAA,cADK;AAELC,EAAAA,gBAFK;AAGLC,EAAAA,0BAHK;AAILC,EAAAA,eAAe,EAAEC;AAJZ,IAKFL,MAAM,CAAEF,sBAAF,CALV;AAOA,MAAMQ,gBAAgB,GAAG;AACxBC,EAAAA,WAAW,EAAE,IADW;AAExBC,EAAAA,QAAQ,EAAE,IAFc;AAGxBC,EAAAA,OAAO,EAAE,IAHe;AAIxBC,EAAAA,MAAM,EAAE,IAJgB;AAKxBC,EAAAA,QAAQ,EAAE,IALc;AAMxBC,EAAAA,SAAS,EAAE,IANa;AAOxBC,EAAAA,WAAW,EAAE;A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C,YAAY,GAAG,EAAE,GAAGD;AAAL,KAArB;AACA,WAAOC,YAAY,CAACJ,MAApB;AACAN,IAAAA,QAAQ,CAAEU,YAAF,CAAR;;AAEA,QAAKD,QAAQ,CAACH,MAAT,KAAoBF,QAAQ,CAACE,MAAlC,EAA2C;AAC1CH,MAAAA,WAAW,CAAE,EACZ,GAAGD,WADS;AAEZI,QAAAA,MAAM,EAAEG,QAAQ,CAACH;AAFL,OAAF,CAAX;AAIA;AACD,GAXD;;AAaA,SACC,cAAC,qBAAD;AACC,IAAA,cAAc,EAAGD,wBADlB;AAEC,IAAA,KAAK,EAAGE,eAFT;AAGC,IAAA,QAAQ,EAAGC,QAHZ;AAIC,IAAA,QAAQ,EAAGJ,QAJZ;AAKC,IAAA,qBAAqB,MALtB;AAMC,IAAA,eAAe,EAAGpB;AANnB,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst {\n\tuseGlobalStyle,\n\tuseGlobalSetting,\n\tuseSettingsForBlockElement,\n\tDimensionsPanel: StylesDimensionsPanel,\n} = unlock( blockEditorPrivateApis );\n\nconst DEFAULT_CONTROLS = {\n\tcontentSize: true,\n\twideSize: true,\n\tpadding: true,\n\tmargin: true,\n\tblockGap: true,\n\tminHeight: true,\n\tchildLayout: false,\n};\n\nexport default function DimensionsPanel( { name, variation = '' } ) {\n\tlet prefixParts = [];\n\tif ( variation ) {\n\t\tprefixParts = [ 'variations', variation ].concat( prefixParts );\n\t}\n\tconst prefix = prefixParts.join( '.' );\n\n\tconst [ style ] = useGlobalStyle( prefix, name, 'user', false );\n\tconst [ inheritedStyle, setStyle ] = useGlobalStyle( prefix, name, 'all', {\n\t\tshouldDecodeEncode: false,\n\t} );\n\tconst [ rawSettings, setSettings ] = useGlobalSetting( '', name );\n\tconst settings = useSettingsForBlockElement( rawSettings, name );\n\n\t// These intermediary objects are needed because the \"layout\" property is stored\n\t// in settings rather than styles.\n\tconst inheritedStyleWithLayout = useMemo( () => {\n\t\treturn {\n\t\t\t...inheritedStyle,\n\t\t\tlayout: settings.layout,\n\t\t};\n\t}, [ inheritedStyle, settings.layout ] );\n\n\tconst styleWithLayout = useMemo( () => {\n\t\treturn {\n\t\t\t...style,\n\t\t\tlayout: settings.layout,\n\t\t};\n\t}, [ style, settings.layout ] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tconst updatedStyle = { ...newStyle };\n\t\tdelete updatedStyle.layout;\n\t\tsetStyle( updatedStyle );\n\n\t\tif ( newStyle.layout !== settings.layout ) {\n\t\t\tsetSettings( {\n\t\t\t\t...rawSettings,\n\t\t\t\tlayout: newStyle.layout,\n\t\t\t} );\n\t\t}\n\t};\n\n\treturn (\n\t\t<StylesDimensionsPanel\n\t\t\tinheritedValue={ inheritedStyleWithLayout }\n\t\t\tvalue={ styleWithLayout }\n\t\t\tonChange={ onChange }\n\t\t\tsettings={ settings }\n\t\t\tincludeLayoutControls\n\t\t\tdefaultControls={ DEFAULT_CONTROLS }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { unlock } from '../../private-apis';
|
|
12
|
+
const {
|
|
13
|
+
useGlobalSetting,
|
|
14
|
+
useGlobalStyle,
|
|
15
|
+
EffectsPanel: StylesEffectsPanel,
|
|
16
|
+
useSettingsForBlockElement
|
|
17
|
+
} = unlock(blockEditorPrivateApis);
|
|
18
|
+
export default function EffectsPanel(_ref) {
|
|
19
|
+
let {
|
|
20
|
+
name,
|
|
21
|
+
variation = ''
|
|
22
|
+
} = _ref;
|
|
23
|
+
let prefixParts = [];
|
|
24
|
+
|
|
25
|
+
if (variation) {
|
|
26
|
+
prefixParts = ['variations', variation].concat(prefixParts);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const prefix = prefixParts.join('.');
|
|
30
|
+
const [style] = useGlobalStyle(prefix, name, 'user', false);
|
|
31
|
+
const [inheritedStyle, setStyle] = useGlobalStyle(prefix, name, 'all', {
|
|
32
|
+
shouldDecodeEncode: false
|
|
33
|
+
});
|
|
34
|
+
const [rawSettings] = useGlobalSetting('', name);
|
|
35
|
+
const settings = useSettingsForBlockElement(rawSettings, name);
|
|
36
|
+
return createElement(StylesEffectsPanel, {
|
|
37
|
+
inheritedValue: inheritedStyle,
|
|
38
|
+
value: style,
|
|
39
|
+
onChange: setStyle,
|
|
40
|
+
settings: settings
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=effects-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/effects-panel.js"],"names":["privateApis","blockEditorPrivateApis","unlock","useGlobalSetting","useGlobalStyle","EffectsPanel","StylesEffectsPanel","useSettingsForBlockElement","name","variation","prefixParts","concat","prefix","join","style","inheritedStyle","setStyle","shouldDecodeEncode","rawSettings","settings"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,MAAM;AACLC,EAAAA,gBADK;AAELC,EAAAA,cAFK;AAGLC,EAAAA,YAAY,EAAEC,kBAHT;AAILC,EAAAA;AAJK,IAKFL,MAAM,CAAED,sBAAF,CALV;AAOA,eAAe,SAASI,YAAT,OAAkD;AAAA,MAA3B;AAAEG,IAAAA,IAAF;AAAQC,IAAAA,SAAS,GAAG;AAApB,GAA2B;AAChE,MAAIC,WAAW,GAAG,EAAlB;;AACA,MAAKD,SAAL,EAAiB;AAChBC,IAAAA,WAAW,GAAG,CAAE,YAAF,EAAgBD,SAAhB,EAA4BE,MAA5B,CAAoCD,WAApC,CAAd;AACA;;AACD,QAAME,MAAM,GAAGF,WAAW,CAACG,IAAZ,CAAkB,GAAlB,CAAf;AAEA,QAAM,CAAEC,KAAF,IAAYV,cAAc,CAAEQ,MAAF,EAAUJ,IAAV,EAAgB,MAAhB,EAAwB,KAAxB,CAAhC;AACA,QAAM,CAAEO,cAAF,EAAkBC,QAAlB,IAA+BZ,cAAc,CAAEQ,MAAF,EAAUJ,IAAV,EAAgB,KAAhB,EAAuB;AACzES,IAAAA,kBAAkB,EAAE;AADqD,GAAvB,CAAnD;AAGA,QAAM,CAAEC,WAAF,IAAkBf,gBAAgB,CAAE,EAAF,EAAMK,IAAN,CAAxC;AACA,QAAMW,QAAQ,GAAGZ,0BAA0B,CAAEW,WAAF,EAAeV,IAAf,CAA3C;AAEA,SACC,cAAC,kBAAD;AACC,IAAA,cAAc,EAAGO,cADlB;AAEC,IAAA,KAAK,EAAGD,KAFT;AAGC,IAAA,QAAQ,EAAGE,QAHZ;AAIC,IAAA,QAAQ,EAAGG;AAJZ,IADD;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst {\n\tuseGlobalSetting,\n\tuseGlobalStyle,\n\tEffectsPanel: StylesEffectsPanel,\n\tuseSettingsForBlockElement,\n} = unlock( blockEditorPrivateApis );\n\nexport default function EffectsPanel( { name, variation = '' } ) {\n\tlet prefixParts = [];\n\tif ( variation ) {\n\t\tprefixParts = [ 'variations', variation ].concat( prefixParts );\n\t}\n\tconst prefix = prefixParts.join( '.' );\n\n\tconst [ style ] = useGlobalStyle( prefix, name, 'user', false );\n\tconst [ inheritedStyle, setStyle ] = useGlobalStyle( prefix, name, 'all', {\n\t\tshouldDecodeEncode: false,\n\t} );\n\tconst [ rawSettings ] = useGlobalSetting( '', name );\n\tconst settings = useSettingsForBlockElement( rawSettings, name );\n\n\treturn (\n\t\t<StylesEffectsPanel\n\t\t\tinheritedValue={ inheritedStyle }\n\t\t\tvalue={ style }\n\t\t\tonChange={ setStyle }\n\t\t\tsettings={ settings }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { unlock } from '../../private-apis';
|
|
12
|
+
const {
|
|
13
|
+
useGlobalStyle,
|
|
14
|
+
useGlobalSetting,
|
|
15
|
+
useSettingsForBlockElement,
|
|
16
|
+
FiltersPanel: StylesFiltersPanel
|
|
17
|
+
} = unlock(blockEditorPrivateApis);
|
|
18
|
+
export default function FiltersPanel(_ref) {
|
|
19
|
+
let {
|
|
20
|
+
name
|
|
21
|
+
} = _ref;
|
|
22
|
+
const [style] = useGlobalStyle('', name, 'user', false);
|
|
23
|
+
const [inheritedStyle, setStyle] = useGlobalStyle('', name, 'all', {
|
|
24
|
+
shouldDecodeEncode: false
|
|
25
|
+
});
|
|
26
|
+
const [rawSettings] = useGlobalSetting('', name);
|
|
27
|
+
const settings = useSettingsForBlockElement(rawSettings, name);
|
|
28
|
+
return createElement(StylesFiltersPanel, {
|
|
29
|
+
inheritedValue: inheritedStyle,
|
|
30
|
+
value: style,
|
|
31
|
+
onChange: setStyle,
|
|
32
|
+
settings: { ...settings,
|
|
33
|
+
color: { ...settings.color,
|
|
34
|
+
customDuotone: false //TO FIX: Custom duotone only works on the block level right now
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=filters-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/filters-panel.js"],"names":["privateApis","blockEditorPrivateApis","unlock","useGlobalStyle","useGlobalSetting","useSettingsForBlockElement","FiltersPanel","StylesFiltersPanel","name","style","inheritedStyle","setStyle","shouldDecodeEncode","rawSettings","settings","color","customDuotone"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,MAAM;AACLC,EAAAA,cADK;AAELC,EAAAA,gBAFK;AAGLC,EAAAA,0BAHK;AAILC,EAAAA,YAAY,EAAEC;AAJT,IAKFL,MAAM,CAAED,sBAAF,CALV;AAOA,eAAe,SAASK,YAAT,OAAkC;AAAA,MAAX;AAAEE,IAAAA;AAAF,GAAW;AAChD,QAAM,CAAEC,KAAF,IAAYN,cAAc,CAAE,EAAF,EAAMK,IAAN,EAAY,MAAZ,EAAoB,KAApB,CAAhC;AACA,QAAM,CAAEE,cAAF,EAAkBC,QAAlB,IAA+BR,cAAc,CAAE,EAAF,EAAMK,IAAN,EAAY,KAAZ,EAAmB;AACrEI,IAAAA,kBAAkB,EAAE;AADiD,GAAnB,CAAnD;AAGA,QAAM,CAAEC,WAAF,IAAkBT,gBAAgB,CAAE,EAAF,EAAMI,IAAN,CAAxC;AACA,QAAMM,QAAQ,GAAGT,0BAA0B,CAAEQ,WAAF,EAAeL,IAAf,CAA3C;AAEA,SACC,cAAC,kBAAD;AACC,IAAA,cAAc,EAAGE,cADlB;AAEC,IAAA,KAAK,EAAGD,KAFT;AAGC,IAAA,QAAQ,EAAGE,QAHZ;AAIC,IAAA,QAAQ,EAAG,EACV,GAAGG,QADO;AAEVC,MAAAA,KAAK,EAAE,EACN,GAAGD,QAAQ,CAACC,KADN;AAENC,QAAAA,aAAa,EAAE,KAFT,CAEgB;;AAFhB;AAFG;AAJZ,IADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nconst {\n\tuseGlobalStyle,\n\tuseGlobalSetting,\n\tuseSettingsForBlockElement,\n\tFiltersPanel: StylesFiltersPanel,\n} = unlock( blockEditorPrivateApis );\n\nexport default function FiltersPanel( { name } ) {\n\tconst [ style ] = useGlobalStyle( '', name, 'user', false );\n\tconst [ inheritedStyle, setStyle ] = useGlobalStyle( '', name, 'all', {\n\t\tshouldDecodeEncode: false,\n\t} );\n\tconst [ rawSettings ] = useGlobalSetting( '', name );\n\tconst settings = useSettingsForBlockElement( rawSettings, name );\n\n\treturn (\n\t\t<StylesFiltersPanel\n\t\t\tinheritedValue={ inheritedStyle }\n\t\t\tvalue={ style }\n\t\t\tonChange={ setStyle }\n\t\t\tsettings={ {\n\t\t\t\t...settings,\n\t\t\t\tcolor: {\n\t\t\t\t\t...settings.color,\n\t\t\t\t\tcustomDuotone: false, //TO FIX: Custom duotone only works on the block level right now\n\t\t\t\t},\n\t\t\t} }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { mergeWith
|
|
6
|
+
import { mergeWith } from 'lodash';
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
@@ -19,7 +19,8 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
|
19
19
|
import CanvasSpinner from '../canvas-spinner';
|
|
20
20
|
import { unlock } from '../../private-apis';
|
|
21
21
|
const {
|
|
22
|
-
GlobalStylesContext
|
|
22
|
+
GlobalStylesContext,
|
|
23
|
+
cleanEmptyObject
|
|
23
24
|
} = unlock(blockEditorPrivateApis);
|
|
24
25
|
|
|
25
26
|
function mergeTreesCustomizer(_, srcValue) {
|
|
@@ -35,18 +36,6 @@ export function mergeBaseAndUserConfigs(base, user) {
|
|
|
35
36
|
return mergeWith({}, base, user, mergeTreesCustomizer);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
const cleanEmptyObject = object => {
|
|
39
|
-
if (object === null || typeof object !== 'object' || Array.isArray(object)) {
|
|
40
|
-
return object;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const cleanedNestedObjects = Object.fromEntries(Object.entries(mapValues(object, cleanEmptyObject)).filter(_ref => {
|
|
44
|
-
let [, value] = _ref;
|
|
45
|
-
return Boolean(value);
|
|
46
|
-
}));
|
|
47
|
-
return isEmpty(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
39
|
function useGlobalStylesUserConfig() {
|
|
51
40
|
const {
|
|
52
41
|
globalStylesId,
|
|
@@ -134,10 +123,10 @@ function useGlobalStylesContext() {
|
|
|
134
123
|
return context;
|
|
135
124
|
}
|
|
136
125
|
|
|
137
|
-
export function GlobalStylesProvider(
|
|
126
|
+
export function GlobalStylesProvider(_ref) {
|
|
138
127
|
let {
|
|
139
128
|
children
|
|
140
|
-
} =
|
|
129
|
+
} = _ref;
|
|
141
130
|
const context = useGlobalStylesContext();
|
|
142
131
|
|
|
143
132
|
if (!context.isReady) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/global-styles-provider.js"],"names":["mergeWith","isEmpty","mapValues","useMemo","useCallback","useSelect","useDispatch","store","coreStore","privateApis","blockEditorPrivateApis","CanvasSpinner","unlock","GlobalStylesContext","mergeTreesCustomizer","_","srcValue","Array","isArray","mergeBaseAndUserConfigs","base","user","cleanEmptyObject","object","cleanedNestedObjects","Object","fromEntries","entries","filter","value","Boolean","undefined","useGlobalStylesUserConfig","globalStylesId","isReady","settings","styles","select","getEditedEntityRecord","hasFinishedResolution","_globalStylesId","__experimentalGetCurrentGlobalStylesId","record","hasResolved","editEntityRecord","config","setConfig","callback","options","currentConfig","updatedConfig","useGlobalStylesBaseConfig","baseConfig","__experimentalGetCurrentThemeBaseGlobalStyles","useGlobalStylesContext","isUserConfigReady","userConfig","setUserConfig","isBaseConfigReady","mergedConfig","context","merged","GlobalStylesProvider","children"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,OAApB,EAA6BC,SAA7B,QAA8C,QAA9C;AAEA;AACA;AACA;;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAA0BD,MAAM,CAAEF,sBAAF,CAAtC;;AAEA,SAASI,oBAAT,CAA+BC,CAA/B,EAAkCC,QAAlC,EAA6C;AAC5C;AACA;AACA;AACA,MAAKC,KAAK,CAACC,OAAN,CAAeF,QAAf,CAAL,EAAiC;AAChC,WAAOA,QAAP;AACA;AACD;;AAED,OAAO,SAASG,uBAAT,CAAkCC,IAAlC,EAAwCC,IAAxC,EAA+C;AACrD,SAAOrB,SAAS,CAAE,EAAF,EAAMoB,IAAN,EAAYC,IAAZ,EAAkBP,oBAAlB,CAAhB;AACA;;AAED,MAAMQ,gBAAgB,GAAKC,MAAF,IAAc;AACtC,MACCA,MAAM,KAAK,IAAX,IACA,OAAOA,MAAP,KAAkB,QADlB,IAEAN,KAAK,CAACC,OAAN,CAAeK,MAAf,CAHD,EAIE;AACD,WAAOA,MAAP;AACA;;AACD,QAAMC,oBAAoB,GAAGC,MAAM,CAACC,WAAP,CAC5BD,MAAM,CA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B;AAA8B,IAAA,KAAK,EAAG0B;AAAtC,KACGG,QADH,CADD;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { mergeWith, isEmpty, mapValues } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CanvasSpinner from '../canvas-spinner';\nimport { unlock } from '../../private-apis';\n\nconst { GlobalStylesContext } = unlock( blockEditorPrivateApis );\n\nfunction mergeTreesCustomizer( _, srcValue ) {\n\t// We only pass as arrays the presets,\n\t// in which case we want the new array of values\n\t// to override the old array (no merging).\n\tif ( Array.isArray( srcValue ) ) {\n\t\treturn srcValue;\n\t}\n}\n\nexport function mergeBaseAndUserConfigs( base, user ) {\n\treturn mergeWith( {}, base, user, mergeTreesCustomizer );\n}\n\nconst cleanEmptyObject = ( object ) => {\n\tif (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = Object.fromEntries(\n\t\tObject.entries( mapValues( object, cleanEmptyObject ) ).filter(\n\t\t\t( [ , value ] ) => Boolean( value )\n\t\t)\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\nfunction useGlobalStylesUserConfig() {\n\tconst { globalStylesId, isReady, settings, styles } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst _globalStylesId =\n\t\t\t\tselect( coreStore ).__experimentalGetCurrentGlobalStylesId();\n\t\t\tconst record = _globalStylesId\n\t\t\t\t? getEditedEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'globalStyles',\n\t\t\t\t\t\t_globalStylesId\n\t\t\t\t )\n\t\t\t\t: undefined;\n\n\t\t\tlet hasResolved = false;\n\t\t\tif (\n\t\t\t\thasFinishedResolution(\n\t\t\t\t\t'__experimentalGetCurrentGlobalStylesId'\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\thasResolved = _globalStylesId\n\t\t\t\t\t? hasFinishedResolution( 'getEditedEntityRecord', [\n\t\t\t\t\t\t\t'root',\n\t\t\t\t\t\t\t'globalStyles',\n\t\t\t\t\t\t\t_globalStylesId,\n\t\t\t\t\t ] )\n\t\t\t\t\t: true;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tglobalStylesId: _globalStylesId,\n\t\t\t\tisReady: hasResolved,\n\t\t\t\tsettings: record?.settings,\n\t\t\t\tstyles: record?.styles,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { getEditedEntityRecord } = useSelect( coreStore );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst config = useMemo( () => {\n\t\treturn {\n\t\t\tsettings: settings ?? {},\n\t\t\tstyles: styles ?? {},\n\t\t};\n\t}, [ settings, styles ] );\n\n\tconst setConfig = useCallback(\n\t\t( callback, options = {} ) => {\n\t\t\tconst record = getEditedEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'globalStyles',\n\t\t\t\tglobalStylesId\n\t\t\t);\n\t\t\tconst currentConfig = {\n\t\t\t\tstyles: record?.styles ?? {},\n\t\t\t\tsettings: record?.settings ?? {},\n\t\t\t};\n\t\t\tconst updatedConfig = callback( currentConfig );\n\t\t\teditEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'globalStyles',\n\t\t\t\tglobalStylesId,\n\t\t\t\t{\n\t\t\t\t\tstyles: cleanEmptyObject( updatedConfig.styles ) || {},\n\t\t\t\t\tsettings: cleanEmptyObject( updatedConfig.settings ) || {},\n\t\t\t\t},\n\t\t\t\toptions\n\t\t\t);\n\t\t},\n\t\t[ globalStylesId ]\n\t);\n\n\treturn [ isReady, config, setConfig ];\n}\n\nfunction useGlobalStylesBaseConfig() {\n\tconst baseConfig = useSelect( ( select ) => {\n\t\treturn select(\n\t\t\tcoreStore\n\t\t).__experimentalGetCurrentThemeBaseGlobalStyles();\n\t}, [] );\n\n\treturn [ !! baseConfig, baseConfig ];\n}\n\nfunction useGlobalStylesContext() {\n\tconst [ isUserConfigReady, userConfig, setUserConfig ] =\n\t\tuseGlobalStylesUserConfig();\n\tconst [ isBaseConfigReady, baseConfig ] = useGlobalStylesBaseConfig();\n\tconst mergedConfig = useMemo( () => {\n\t\tif ( ! baseConfig || ! userConfig ) {\n\t\t\treturn {};\n\t\t}\n\t\treturn mergeBaseAndUserConfigs( baseConfig, userConfig );\n\t}, [ userConfig, baseConfig ] );\n\tconst context = useMemo( () => {\n\t\treturn {\n\t\t\tisReady: isUserConfigReady && isBaseConfigReady,\n\t\t\tuser: userConfig,\n\t\t\tbase: baseConfig,\n\t\t\tmerged: mergedConfig,\n\t\t\tsetUserConfig,\n\t\t};\n\t}, [\n\t\tmergedConfig,\n\t\tuserConfig,\n\t\tbaseConfig,\n\t\tsetUserConfig,\n\t\tisUserConfigReady,\n\t\tisBaseConfigReady,\n\t] );\n\n\treturn context;\n}\n\nexport function GlobalStylesProvider( { children } ) {\n\tconst context = useGlobalStylesContext();\n\tif ( ! context.isReady ) {\n\t\treturn <CanvasSpinner />;\n\t}\n\n\treturn (\n\t\t<GlobalStylesContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</GlobalStylesContext.Provider>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/global-styles-provider.js"],"names":["mergeWith","useMemo","useCallback","useSelect","useDispatch","store","coreStore","privateApis","blockEditorPrivateApis","CanvasSpinner","unlock","GlobalStylesContext","cleanEmptyObject","mergeTreesCustomizer","_","srcValue","Array","isArray","mergeBaseAndUserConfigs","base","user","useGlobalStylesUserConfig","globalStylesId","isReady","settings","styles","select","getEditedEntityRecord","hasFinishedResolution","_globalStylesId","__experimentalGetCurrentGlobalStylesId","record","undefined","hasResolved","editEntityRecord","config","setConfig","callback","options","currentConfig","updatedConfig","useGlobalStylesBaseConfig","baseConfig","__experimentalGetCurrentThemeBaseGlobalStyles","useGlobalStylesContext","isUserConfigReady","userConfig","setUserConfig","isBaseConfigReady","mergedConfig","context","merged","GlobalStylesProvider","children"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,MAAM;AAAEC,EAAAA,mBAAF;AAAuBC,EAAAA;AAAvB,IAA4CF,MAAM,CACvDF,sBADuD,CAAxD;;AAIA,SAASK,oBAAT,CAA+BC,CAA/B,EAAkCC,QAAlC,EAA6C;AAC5C;AACA;AACA;AACA,MAAKC,KAAK,CAACC,OAAN,CAAeF,QAAf,CAAL,EAAiC;AAChC,WAAOA,QAAP;AACA;AACD;;AAED,OAAO,SAASG,uBAAT,CAAkCC,IAAlC,EAAwCC,IAAxC,EAA+C;AACrD,SAAOpB,SAAS,CAAE,EAAF,EAAMmB,IAAN,EAAYC,IAAZ,EAAkBP,oBAAlB,CAAhB;AACA;;AAED,SAASQ,yBAAT,GAAqC;AACpC,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,OAAlB;AAA2BC,IAAAA,QAA3B;AAAqCC,IAAAA;AAArC,MAAgDtB,SAAS,CAC5DuB,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,qBAAF;AAAyBC,MAAAA;AAAzB,QACLF,MAAM,CAAEpB,SAAF,CADP;;AAEA,UAAMuB,eAAe,GACpBH,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AF,EAAcI,UAAd,CAA9B;AACA,GAL2B,EAKzB,CAAEA,UAAF,EAAcJ,UAAd,CALyB,CAA5B;AAMA,QAAMQ,OAAO,GAAGjD,OAAO,CAAE,MAAM;AAC9B,WAAO;AACNsB,MAAAA,OAAO,EAAEsB,iBAAiB,IAAIG,iBADxB;AAEN5B,MAAAA,IAAI,EAAE0B,UAFA;AAGN3B,MAAAA,IAAI,EAAEuB,UAHA;AAINS,MAAAA,MAAM,EAAEF,YAJF;AAKNF,MAAAA;AALM,KAAP;AAOA,GARsB,EAQpB,CACFE,YADE,EAEFH,UAFE,EAGFJ,UAHE,EAIFK,aAJE,EAKFF,iBALE,EAMFG,iBANE,CARoB,CAAvB;AAiBA,SAAOE,OAAP;AACA;;AAED,OAAO,SAASE,oBAAT,OAA8C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACpD,QAAMH,OAAO,GAAGN,sBAAsB,EAAtC;;AACA,MAAK,CAAEM,OAAO,CAAC3B,OAAf,EAAyB;AACxB,WAAO,cAAC,aAAD,OAAP;AACA;;AAED,SACC,cAAC,mBAAD,CAAqB,QAArB;AAA8B,IAAA,KAAK,EAAG2B;AAAtC,KACGG,QADH,CADD;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { mergeWith } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CanvasSpinner from '../canvas-spinner';\nimport { unlock } from '../../private-apis';\n\nconst { GlobalStylesContext, cleanEmptyObject } = unlock(\n\tblockEditorPrivateApis\n);\n\nfunction mergeTreesCustomizer( _, srcValue ) {\n\t// We only pass as arrays the presets,\n\t// in which case we want the new array of values\n\t// to override the old array (no merging).\n\tif ( Array.isArray( srcValue ) ) {\n\t\treturn srcValue;\n\t}\n}\n\nexport function mergeBaseAndUserConfigs( base, user ) {\n\treturn mergeWith( {}, base, user, mergeTreesCustomizer );\n}\n\nfunction useGlobalStylesUserConfig() {\n\tconst { globalStylesId, isReady, settings, styles } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst _globalStylesId =\n\t\t\t\tselect( coreStore ).__experimentalGetCurrentGlobalStylesId();\n\t\t\tconst record = _globalStylesId\n\t\t\t\t? getEditedEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'globalStyles',\n\t\t\t\t\t\t_globalStylesId\n\t\t\t\t )\n\t\t\t\t: undefined;\n\n\t\t\tlet hasResolved = false;\n\t\t\tif (\n\t\t\t\thasFinishedResolution(\n\t\t\t\t\t'__experimentalGetCurrentGlobalStylesId'\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\thasResolved = _globalStylesId\n\t\t\t\t\t? hasFinishedResolution( 'getEditedEntityRecord', [\n\t\t\t\t\t\t\t'root',\n\t\t\t\t\t\t\t'globalStyles',\n\t\t\t\t\t\t\t_globalStylesId,\n\t\t\t\t\t ] )\n\t\t\t\t\t: true;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tglobalStylesId: _globalStylesId,\n\t\t\t\tisReady: hasResolved,\n\t\t\t\tsettings: record?.settings,\n\t\t\t\tstyles: record?.styles,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { getEditedEntityRecord } = useSelect( coreStore );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst config = useMemo( () => {\n\t\treturn {\n\t\t\tsettings: settings ?? {},\n\t\t\tstyles: styles ?? {},\n\t\t};\n\t}, [ settings, styles ] );\n\n\tconst setConfig = useCallback(\n\t\t( callback, options = {} ) => {\n\t\t\tconst record = getEditedEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'globalStyles',\n\t\t\t\tglobalStylesId\n\t\t\t);\n\t\t\tconst currentConfig = {\n\t\t\t\tstyles: record?.styles ?? {},\n\t\t\t\tsettings: record?.settings ?? {},\n\t\t\t};\n\t\t\tconst updatedConfig = callback( currentConfig );\n\t\t\teditEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'globalStyles',\n\t\t\t\tglobalStylesId,\n\t\t\t\t{\n\t\t\t\t\tstyles: cleanEmptyObject( updatedConfig.styles ) || {},\n\t\t\t\t\tsettings: cleanEmptyObject( updatedConfig.settings ) || {},\n\t\t\t\t},\n\t\t\t\toptions\n\t\t\t);\n\t\t},\n\t\t[ globalStylesId ]\n\t);\n\n\treturn [ isReady, config, setConfig ];\n}\n\nfunction useGlobalStylesBaseConfig() {\n\tconst baseConfig = useSelect( ( select ) => {\n\t\treturn select(\n\t\t\tcoreStore\n\t\t).__experimentalGetCurrentThemeBaseGlobalStyles();\n\t}, [] );\n\n\treturn [ !! baseConfig, baseConfig ];\n}\n\nfunction useGlobalStylesContext() {\n\tconst [ isUserConfigReady, userConfig, setUserConfig ] =\n\t\tuseGlobalStylesUserConfig();\n\tconst [ isBaseConfigReady, baseConfig ] = useGlobalStylesBaseConfig();\n\tconst mergedConfig = useMemo( () => {\n\t\tif ( ! baseConfig || ! userConfig ) {\n\t\t\treturn {};\n\t\t}\n\t\treturn mergeBaseAndUserConfigs( baseConfig, userConfig );\n\t}, [ userConfig, baseConfig ] );\n\tconst context = useMemo( () => {\n\t\treturn {\n\t\t\tisReady: isUserConfigReady && isBaseConfigReady,\n\t\t\tuser: userConfig,\n\t\t\tbase: baseConfig,\n\t\t\tmerged: mergedConfig,\n\t\t\tsetUserConfig,\n\t\t};\n\t}, [\n\t\tmergedConfig,\n\t\tuserConfig,\n\t\tbaseConfig,\n\t\tsetUserConfig,\n\t\tisUserConfigReady,\n\t\tisBaseConfigReady,\n\t] );\n\n\treturn context;\n}\n\nexport function GlobalStylesProvider( { children } ) {\n\tconst context = useGlobalStylesContext();\n\tif ( ! context.isReady ) {\n\t\treturn <CanvasSpinner />;\n\t}\n\n\treturn (\n\t\t<GlobalStylesContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</GlobalStylesContext.Provider>\n\t);\n}\n"]}
|
|
@@ -112,7 +112,7 @@ const StylesPreview = _ref => {
|
|
|
112
112
|
height: normalizedHeight * ratio,
|
|
113
113
|
width: '100%',
|
|
114
114
|
background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor,
|
|
115
|
-
cursor: 'pointer'
|
|
115
|
+
cursor: withHoverView ? 'pointer' : undefined
|
|
116
116
|
},
|
|
117
117
|
initial: "start",
|
|
118
118
|
animate: (isHovered || isFocused) && !disableMotion && label ? 'hover' : 'start'
|