@wordpress/block-editor 16.2.0 → 17.0.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 +39 -0
- package/build/components/block-inspector/index.cjs +9 -6
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-keyboard-shortcuts/index.cjs +201 -0
- package/build/components/block-keyboard-shortcuts/index.cjs.map +7 -0
- package/build/components/block-list/block.cjs +10 -3
- package/build/components/block-list/block.cjs.map +2 -2
- package/build/components/block-list/index.cjs +6 -1
- package/build/components/block-list/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs +4 -0
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +6 -7
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
- package/build/components/block-parent-selector/index.cjs +98 -29
- package/build/components/block-parent-selector/index.cjs.map +3 -3
- package/build/components/block-popover/inbetween.cjs +2 -2
- package/build/components/block-popover/inbetween.cjs.map +2 -2
- package/build/components/block-preview/index.cjs +0 -4
- package/build/components/block-preview/index.cjs.map +2 -2
- package/build/components/block-styles/index.cjs +77 -33
- package/build/components/block-styles/index.cjs.map +3 -3
- package/build/components/block-visibility/constants.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors/with-colors.cjs +55 -71
- package/build/components/colors/with-colors.cjs.map +2 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +4 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/index.cjs +18 -16
- package/build/components/dimensions-tool/index.cjs.map +2 -2
- package/build/components/dimensions-tool/utils.cjs +61 -0
- package/build/components/dimensions-tool/utils.cjs.map +7 -0
- package/build/components/duotone-control/index.cjs +2 -0
- package/build/components/duotone-control/index.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs.map +3 -3
- package/build/components/global-styles/border-panel.cjs +2 -5
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/color-panel.cjs +14 -2
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +9 -5
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/filters-panel.cjs +12 -8
- package/build/components/global-styles/filters-panel.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs +16 -11
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/utils.cjs +9 -0
- package/build/components/global-styles/utils.cjs.map +2 -2
- package/build/components/inner-blocks/index.cjs +5 -3
- package/build/components/inner-blocks/index.cjs.map +2 -2
- package/build/components/inserter/block-patterns-explorer/index.cjs +39 -22
- package/build/components/inserter/block-patterns-explorer/index.cjs.map +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs +21 -55
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs.map +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-list.cjs +19 -44
- package/build/components/inserter/block-patterns-explorer/pattern-list.cjs.map +3 -3
- package/build/components/inserter/hooks/use-insertion-point.cjs +4 -4
- package/build/components/inserter/hooks/use-insertion-point.cjs.map +2 -2
- package/build/components/inserter/menu.cjs +18 -7
- package/build/components/inserter/menu.cjs.map +2 -2
- package/build/components/inserter/quick-inserter.cjs +30 -27
- package/build/components/inserter/quick-inserter.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/list-view/index.cjs +31 -5
- package/build/components/list-view/index.cjs.map +3 -3
- package/build/components/list-view/utils.cjs +13 -1
- package/build/components/list-view/utils.cjs.map +2 -2
- package/build/components/media-placeholder/index.cjs +1 -1
- package/build/components/media-placeholder/index.cjs.map +3 -3
- package/build/components/provider/index.cjs +5 -1
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/publish-date-time-picker/index.cjs +3 -2
- package/build/components/publish-date-time-picker/index.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/enter.cjs +46 -39
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +7 -5
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/rich-text/multiline.cjs +105 -70
- package/build/components/rich-text/multiline.cjs.map +3 -3
- package/build/components/url-input/index.cjs.map +2 -2
- package/build/components/writing-flow/use-input.cjs +65 -13
- package/build/components/writing-flow/use-input.cjs.map +3 -3
- package/build/hooks/border.cjs +25 -3
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +9 -2
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/duotone.cjs +4 -3
- package/build/hooks/duotone.cjs.map +2 -2
- package/build/hooks/gap.cjs +8 -2
- package/build/hooks/gap.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +35 -13
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +23 -1
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/states.cjs +7 -4
- package/build/hooks/states.cjs.map +2 -2
- package/build/layouts/constrained.cjs +8 -1
- package/build/layouts/constrained.cjs.map +2 -2
- package/build/layouts/flex.cjs +9 -0
- package/build/layouts/flex.cjs.map +2 -2
- package/build/layouts/flow.cjs +4 -1
- package/build/layouts/flow.cjs.map +2 -2
- package/build/layouts/grid.cjs +5 -1
- package/build/layouts/grid.cjs.map +2 -2
- package/build/private-apis.cjs +3 -1
- package/build/private-apis.cjs.map +2 -2
- package/build/store/actions.cjs +1 -1
- package/build/store/actions.cjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +9 -6
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-keyboard-shortcuts/index.mjs +173 -0
- package/build-module/components/block-keyboard-shortcuts/index.mjs.map +7 -0
- package/build-module/components/block-list/block.mjs +10 -3
- package/build-module/components/block-list/block.mjs.map +2 -2
- package/build-module/components/block-list/index.mjs +6 -1
- package/build-module/components/block-list/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs +4 -0
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +6 -7
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
- package/build-module/components/block-parent-selector/index.mjs +101 -32
- package/build-module/components/block-parent-selector/index.mjs.map +2 -2
- package/build-module/components/block-popover/inbetween.mjs +2 -2
- package/build-module/components/block-popover/inbetween.mjs.map +2 -2
- package/build-module/components/block-preview/index.mjs +0 -4
- package/build-module/components/block-preview/index.mjs.map +2 -2
- package/build-module/components/block-styles/index.mjs +79 -35
- package/build-module/components/block-styles/index.mjs.map +2 -2
- package/build-module/components/block-visibility/constants.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +5 -5
- package/build-module/components/child-layout-control/index.mjs.map +1 -1
- package/build-module/components/colors/with-colors.mjs +56 -72
- package/build-module/components/colors/with-colors.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +4 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/index.mjs +19 -17
- package/build-module/components/dimensions-tool/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/utils.mjs +35 -0
- package/build-module/components/dimensions-tool/utils.mjs.map +7 -0
- package/build-module/components/duotone-control/index.mjs +2 -0
- package/build-module/components/duotone-control/index.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +5 -2
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +2 -5
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +14 -2
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +9 -5
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +16 -9
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs +16 -11
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/utils.mjs +8 -0
- package/build-module/components/global-styles/utils.mjs.map +2 -2
- package/build-module/components/inner-blocks/index.mjs +5 -3
- package/build-module/components/inner-blocks/index.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-explorer/index.mjs +39 -22
- package/build-module/components/inserter/block-patterns-explorer/index.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs +22 -56
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs +20 -45
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-insertion-point.mjs +4 -4
- package/build-module/components/inserter/hooks/use-insertion-point.mjs.map +2 -2
- package/build-module/components/inserter/menu.mjs +19 -8
- package/build-module/components/inserter/menu.mjs.map +2 -2
- package/build-module/components/inserter/quick-inserter.mjs +30 -27
- package/build-module/components/inserter/quick-inserter.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/list-view/index.mjs +32 -5
- package/build-module/components/list-view/index.mjs.map +3 -3
- package/build-module/components/list-view/utils.mjs +13 -1
- package/build-module/components/list-view/utils.mjs.map +2 -2
- package/build-module/components/media-placeholder/index.mjs +3 -3
- package/build-module/components/media-placeholder/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +6 -2
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/publish-date-time-picker/index.mjs +3 -2
- package/build-module/components/publish-date-time-picker/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +46 -39
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +7 -5
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/rich-text/multiline.mjs +112 -72
- package/build-module/components/rich-text/multiline.mjs.map +2 -2
- package/build-module/components/url-input/index.mjs +2 -2
- package/build-module/components/url-input/index.mjs.map +1 -1
- package/build-module/components/writing-flow/use-input.mjs +66 -14
- package/build-module/components/writing-flow/use-input.mjs.map +3 -3
- package/build-module/hooks/border.mjs +26 -8
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +9 -2
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/duotone.mjs +8 -4
- package/build-module/hooks/duotone.mjs.map +2 -2
- package/build-module/hooks/gap.mjs +6 -1
- package/build-module/hooks/gap.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +36 -13
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +22 -1
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/states.mjs +8 -5
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +8 -1
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +9 -0
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/flow.mjs +4 -1
- package/build-module/layouts/flow.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +5 -1
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +3 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +1 -1
- package/build-module/store/actions.mjs.map +2 -2
- package/build-style/style-rtl.css +108 -71
- package/build-style/style.css +108 -71
- package/build-types/components/block-visibility/constants.d.ts +4 -3
- package/build-types/components/block-visibility/constants.d.ts.map +1 -1
- package/package.json +43 -43
- package/src/components/background-image-control/README.md +122 -0
- package/src/components/block-edit-visually-button/README.md +39 -0
- package/src/components/block-editing-mode/README.md +72 -0
- package/src/components/block-inspector/index.js +6 -6
- package/src/components/block-keyboard-shortcuts/index.js +256 -0
- package/src/components/block-list/block.js +7 -0
- package/src/components/block-list/index.js +7 -1
- package/src/components/block-list/use-block-props/use-focus-first-element.js +5 -0
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +6 -8
- package/src/components/block-parent-selector/index.js +111 -30
- package/src/components/block-popover/README.md +10 -3
- package/src/components/block-popover/inbetween.js +8 -2
- package/src/components/block-popover/stories/index.story.jsx +143 -0
- package/src/components/block-preview/index.js +0 -2
- package/src/components/block-styles/index.js +95 -43
- package/src/components/block-styles/style.scss +5 -34
- package/src/components/block-tools/style.scss +94 -0
- package/src/components/block-visibility/constants.ts +4 -3
- package/src/components/child-layout-control/index.js +5 -5
- package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -29
- package/src/components/colors/test/with-colors.js +6 -7
- package/src/components/colors/with-colors.js +79 -105
- package/src/components/dimensions-tool/aspect-ratio-tool.js +16 -4
- package/src/components/dimensions-tool/index.js +34 -22
- package/src/components/dimensions-tool/test/index.js +166 -2
- package/src/components/dimensions-tool/test/utils.js +51 -0
- package/src/components/dimensions-tool/utils.js +67 -0
- package/src/components/duotone-control/index.js +2 -0
- package/src/components/duotone-control/test/index.js +100 -0
- package/src/components/global-styles/advanced-panel.js +5 -2
- package/src/components/global-styles/border-panel.js +11 -9
- package/src/components/global-styles/color-panel.js +13 -1
- package/src/components/global-styles/dimensions-panel.js +17 -5
- package/src/components/global-styles/filters-panel.js +24 -10
- package/src/components/global-styles/shadow-panel-components.js +38 -11
- package/src/components/global-styles/test/border-panel.js +230 -0
- package/src/components/global-styles/test/color-panel.js +24 -0
- package/src/components/global-styles/test/dimensions-panel.js +98 -7
- package/src/components/global-styles/test/filters-panel.js +84 -0
- package/src/components/global-styles/test/utils.js +30 -0
- package/src/components/global-styles/utils.js +23 -0
- package/src/components/inner-blocks/index.js +11 -2
- package/src/components/inner-blocks/stories/index.story.jsx +246 -0
- package/src/components/inserter/block-patterns-explorer/index.js +24 -11
- package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +18 -56
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +22 -47
- package/src/components/inserter/hooks/use-insertion-point.js +9 -4
- package/src/components/inserter/menu.js +23 -10
- package/src/components/inserter/quick-inserter.js +15 -13
- package/src/components/inserter/style.scss +44 -62
- package/src/components/inspector-controls-tabs/README.md +92 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -1
- package/src/components/link-control/test/index.js +5 -0
- package/src/components/list-view/index.js +50 -7
- package/src/components/list-view/utils.js +16 -1
- package/src/components/media-placeholder/index.js +9 -4
- package/src/components/plain-text/stories/index.story.jsx +3 -0
- package/src/components/provider/index.js +7 -1
- package/src/components/publish-date-time-picker/README.md +10 -0
- package/src/components/publish-date-time-picker/index.js +17 -14
- package/src/components/rich-text/event-listeners/enter.js +58 -45
- package/src/components/rich-text/index.js +9 -4
- package/src/components/rich-text/multiline.js +126 -86
- package/src/components/url-input/index.js +2 -2
- package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +27 -0
- package/src/components/url-input/test/index.js +5 -0
- package/src/components/url-popover/README.md +7 -0
- package/src/components/url-popover/stories/index.story.jsx +133 -47
- package/src/components/writing-flow/use-input.js +105 -15
- package/src/hooks/border.js +27 -8
- package/src/hooks/dimensions.js +8 -1
- package/src/hooks/duotone.js +23 -7
- package/src/hooks/gap.js +16 -0
- package/src/hooks/layout-child.js +41 -9
- package/src/hooks/layout.js +117 -71
- package/src/hooks/states.js +8 -5
- package/src/hooks/test/gap.js +31 -1
- package/src/hooks/test/layout-child.js +60 -1
- package/src/hooks/test/layout.js +27 -0
- package/src/layouts/constrained.js +9 -1
- package/src/layouts/flex.js +15 -0
- package/src/layouts/flow.js +4 -1
- package/src/layouts/grid.js +9 -1
- package/src/layouts/test/constrained.js +26 -0
- package/src/layouts/test/flow.js +26 -0
- package/src/layouts/test/grid.js +46 -0
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +14 -1
- package/build/components/floating-toolbar/nav-up-icon.cjs +0 -52
- package/build/components/floating-toolbar/nav-up-icon.cjs.map +0 -7
- package/build/components/gradients/with-gradient.cjs +0 -36
- package/build/components/gradients/with-gradient.cjs.map +0 -7
- package/build/components/inserter-button/sparkles.cjs +0 -36
- package/build/components/inserter-button/sparkles.cjs.map +0 -7
- package/build-module/components/floating-toolbar/nav-up-icon.mjs +0 -31
- package/build-module/components/floating-toolbar/nav-up-icon.mjs.map +0 -7
- package/build-module/components/gradients/with-gradient.mjs +0 -11
- package/build-module/components/gradients/with-gradient.mjs.map +0 -7
- package/build-module/components/inserter-button/sparkles.mjs +0 -15
- package/build-module/components/inserter-button/sparkles.mjs.map +0 -7
- package/build-style/default-editor-styles-rtl.css +0 -68
- package/build-style/default-editor-styles.css +0 -68
- package/src/components/floating-toolbar/nav-up-icon.js +0 -22
- package/src/components/gradients/with-gradient.js +0 -9
- package/src/components/inserter-button/README.md +0 -62
- package/src/components/inserter-button/sparkles.js +0 -12
- package/src/default-editor-styles.scss +0 -25
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dimensions-tool/aspect-ratio-tool.js"],
|
|
4
|
-
"sourcesContent": ["import { SelectControl } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSettings } from '../use-settings';\nimport { InheritanceToolsPanelItem } from '../global-styles/inheritance';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * @callback AspectRatioToolPropsOnChange\n * @param {string} [value] New aspect ratio value.\n * @return {void} No return.\n */\n\n/**\n * @typedef {Object} AspectRatioToolProps\n * @property {string} [panelId] ID of the panel this tool is associated with.\n * @property {string} [value] Current aspect ratio value.\n * @property {AspectRatioToolPropsOnChange} [onChange] Callback to update the aspect ratio value.\n * @property {SelectControlProps[]} [options] Aspect ratio options.\n * @property {string} [defaultValue] Default aspect ratio value.\n * @property {boolean} [isShownByDefault] Whether the tool is shown by default.\n * @property {string} [className] Additional CSS class on the wrapping panel item.\n * @property {boolean} [isInherited] Whether the control is displaying an inherited Global Styles value.\n * @property {boolean} [hasLocalOverride] Whether a local value is overriding an inherited Global Styles value.\n */\n\nexport default function AspectRatioTool( {\n\tpanelId,\n\tvalue,\n\tonChange = () => {},\n\toptions,\n\tdefaultValue = 'auto',\n\thasValue,\n\tisShownByDefault = true,\n\tclassName,\n\tisInherited,\n\thasLocalOverride,\n} ) {\n\
|
|
5
|
-
"mappings": ";AAAA,SAAS,qBAAqB;AAC9B,SAAS,IAAI,UAAU;AACvB,SAAS,mBAAmB;AAC5B,SAAS,iCAAiC;
|
|
4
|
+
"sourcesContent": ["import { SelectControl } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSettings } from '../use-settings';\nimport { InheritanceToolsPanelItem } from '../global-styles/inheritance';\nimport { findAspectRatioOption } from './utils';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * @callback AspectRatioToolPropsOnChange\n * @param {string} [value] New aspect ratio value.\n * @return {void} No return.\n */\n\n/**\n * @typedef {Object} AspectRatioToolProps\n * @property {string} [panelId] ID of the panel this tool is associated with.\n * @property {string} [value] Current aspect ratio value.\n * @property {AspectRatioToolPropsOnChange} [onChange] Callback to update the aspect ratio value.\n * @property {SelectControlProps[]} [options] Aspect ratio options.\n * @property {string} [defaultValue] Default aspect ratio value.\n * @property {boolean} [isShownByDefault] Whether the tool is shown by default.\n * @property {string} [className] Additional CSS class on the wrapping panel item.\n * @property {boolean} [isInherited] Whether the control is displaying an inherited Global Styles value.\n * @property {boolean} [hasLocalOverride] Whether a local value is overriding an inherited Global Styles value.\n */\n\nexport default function AspectRatioTool( {\n\tpanelId,\n\tvalue,\n\tonChange = () => {},\n\toptions,\n\tdefaultValue = 'auto',\n\thasValue,\n\tisShownByDefault = true,\n\tclassName,\n\tisInherited,\n\thasLocalOverride,\n} ) {\n\tconst [ defaultRatios, themeRatios, showDefaultRatios ] = useSettings(\n\t\t'dimensions.aspectRatios.default',\n\t\t'dimensions.aspectRatios.theme',\n\t\t'dimensions.defaultAspectRatios'\n\t);\n\n\tconst themeOptions = themeRatios?.map( ( { name, ratio } ) => ( {\n\t\tlabel: name,\n\t\tvalue: ratio,\n\t} ) );\n\n\tconst defaultOptions = defaultRatios?.map( ( { name, ratio } ) => ( {\n\t\tlabel: name,\n\t\tvalue: ratio,\n\t} ) );\n\n\tconst aspectRatioOptions = [\n\t\t{\n\t\t\tlabel: _x(\n\t\t\t\t'Original',\n\t\t\t\t'Aspect ratio option for dimensions control'\n\t\t\t),\n\t\t\tvalue: 'auto',\n\t\t},\n\t\t...( showDefaultRatios ? defaultOptions : [] ),\n\t\t...( themeOptions ? themeOptions : [] ),\n\t\t{\n\t\t\tlabel: _x( 'Custom', 'Aspect ratio option for dimensions control' ),\n\t\t\tvalue: 'custom',\n\t\t\tdisabled: true,\n\t\t\thidden: true,\n\t\t},\n\t];\n\n\tconst resolvedOptions = options ?? aspectRatioOptions;\n\n\t// The value is free-form CSS, so it doesn't necessarily match an option as\n\t// written, e.g. '1/1' and '1' describe the same ratio. Resolve it to the\n\t// option that represents it, falling back to 'custom' so that a ratio\n\t// without a matching preset isn't displayed as one of the presets. Values\n\t// that are empty match the CSS default, so if the value is used directly in\n\t// CSS it will look correct in the control.\n\tconst displayValue =\n\t\tvalue === undefined || value === null || value === 'auto'\n\t\t\t? 'auto'\n\t\t\t: findAspectRatioOption( value, resolvedOptions )?.value ??\n\t\t\t 'custom';\n\n\treturn (\n\t\t<InheritanceToolsPanelItem\n\t\t\tclassName={ className }\n\t\t\tisInherited={ isInherited }\n\t\t\thasLocalOverride={ hasLocalOverride }\n\t\t\thasValue={\n\t\t\t\thasValue ? hasValue : () => displayValue !== defaultValue\n\t\t\t}\n\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\tonDeselect={ () => onChange( undefined ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tvalue={ displayValue }\n\t\t\t\toptions={ resolvedOptions }\n\t\t\t\tonChange={ onChange }\n\t\t\t/>\n\t\t</InheritanceToolsPanelItem>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,qBAAqB;AAC9B,SAAS,IAAI,UAAU;AACvB,SAAS,mBAAmB;AAC5B,SAAS,iCAAiC;AAC1C,SAAS,6BAA6B;AAkGnC;AAzEY,SAAR,gBAAkC;AAAA,EACxC;AAAA,EACA;AAAA,EACA,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA,mBAAmB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,CAAE,eAAe,aAAa,iBAAkB,IAAI;AAAA,IACzD;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,QAAM,eAAe,aAAa,IAAK,CAAE,EAAE,MAAM,MAAM,OAAS;AAAA,IAC/D,OAAO;AAAA,IACP,OAAO;AAAA,EACR,EAAI;AAEJ,QAAM,iBAAiB,eAAe,IAAK,CAAE,EAAE,MAAM,MAAM,OAAS;AAAA,IACnE,OAAO;AAAA,IACP,OAAO;AAAA,EACR,EAAI;AAEJ,QAAM,qBAAqB;AAAA,IAC1B;AAAA,MACC,OAAO;AAAA,QACN;AAAA,QACA;AAAA,MACD;AAAA,MACA,OAAO;AAAA,IACR;AAAA,IACA,GAAK,oBAAoB,iBAAiB,CAAC;AAAA,IAC3C,GAAK,eAAe,eAAe,CAAC;AAAA,IACpC;AAAA,MACC,OAAO,GAAI,UAAU,4CAA6C;AAAA,MAClE,OAAO;AAAA,MACP,UAAU;AAAA,MACV,QAAQ;AAAA,IACT;AAAA,EACD;AAEA,QAAM,kBAAkB,WAAW;AAQnC,QAAM,eACL,UAAU,UAAa,UAAU,QAAQ,UAAU,SAChD,SACA,sBAAuB,OAAO,eAAgB,GAAG,SACjD;AAEJ,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UACC,WAAW,WAAW,MAAM,iBAAiB;AAAA,MAE9C,OAAQ,GAAI,cAAe;AAAA,MAC3B,YAAa,MAAM,SAAU,MAAU;AAAA,MACvC;AAAA,MACA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ,GAAI,cAAe;AAAA,UAC3B,OAAQ;AAAA,UACR,SAAU;AAAA,UACV;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/block-editor/src/components/dimensions-tool/index.js
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useRef } from "@wordpress/element";
|
|
3
3
|
import AspectRatioTool from "./aspect-ratio-tool.mjs";
|
|
4
4
|
import ScaleTool from "./scale-tool.mjs";
|
|
5
5
|
import WidthHeightTool from "./width-height-tool.mjs";
|
|
@@ -24,9 +24,19 @@ function DimensionsTool({
|
|
|
24
24
|
const height = value.height === void 0 || value.height === "auto" ? null : value.height;
|
|
25
25
|
const aspectRatio = value.aspectRatio === void 0 || value.aspectRatio === "auto" ? null : value.aspectRatio;
|
|
26
26
|
const scale = value.scale === void 0 ? null : value.scale;
|
|
27
|
-
const [lastScale, setLastScale] = useState(scale);
|
|
28
|
-
const [lastAspectRatio, setLastAspectRatio] = useState(aspectRatio);
|
|
29
27
|
const hasCustomAspectRatio = !!(width && height);
|
|
28
|
+
const lastScaleRef = useRef(scale);
|
|
29
|
+
const lastAspectRatioRef = useRef(aspectRatio);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (scale) {
|
|
32
|
+
lastScaleRef.current = scale;
|
|
33
|
+
}
|
|
34
|
+
}, [scale]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!hasCustomAspectRatio) {
|
|
37
|
+
lastAspectRatioRef.current = aspectRatio;
|
|
38
|
+
}
|
|
39
|
+
}, [aspectRatio, hasCustomAspectRatio]);
|
|
30
40
|
const aspectRatioValue = hasCustomAspectRatio ? "custom" : aspectRatio;
|
|
31
41
|
const showScaleControl = aspectRatio || width && height;
|
|
32
42
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -40,7 +50,6 @@ function DimensionsTool({
|
|
|
40
50
|
onChange: (nextAspectRatio) => {
|
|
41
51
|
const nextValue = { ...value };
|
|
42
52
|
nextAspectRatio = nextAspectRatio === "auto" ? null : nextAspectRatio;
|
|
43
|
-
setLastAspectRatio(nextAspectRatio);
|
|
44
53
|
if (!nextAspectRatio) {
|
|
45
54
|
delete nextValue.aspectRatio;
|
|
46
55
|
} else {
|
|
@@ -48,11 +57,8 @@ function DimensionsTool({
|
|
|
48
57
|
}
|
|
49
58
|
if (!nextAspectRatio) {
|
|
50
59
|
delete nextValue.scale;
|
|
51
|
-
} else if (lastScale) {
|
|
52
|
-
nextValue.scale = lastScale;
|
|
53
60
|
} else {
|
|
54
|
-
nextValue.scale = defaultScale;
|
|
55
|
-
setLastScale(defaultScale);
|
|
61
|
+
nextValue.scale = lastScaleRef.current ?? defaultScale;
|
|
56
62
|
}
|
|
57
63
|
if ("custom" !== nextAspectRatio && width && height) {
|
|
58
64
|
delete nextValue.height;
|
|
@@ -83,17 +89,14 @@ function DimensionsTool({
|
|
|
83
89
|
}
|
|
84
90
|
if (nextWidth && nextHeight) {
|
|
85
91
|
delete nextValue.aspectRatio;
|
|
86
|
-
} else if (
|
|
87
|
-
nextValue.aspectRatio =
|
|
92
|
+
} else if (lastAspectRatioRef.current) {
|
|
93
|
+
nextValue.aspectRatio = lastAspectRatioRef.current;
|
|
88
94
|
} else {
|
|
89
95
|
}
|
|
90
|
-
if (!
|
|
96
|
+
if (!lastAspectRatioRef.current && !!nextWidth !== !!nextHeight) {
|
|
91
97
|
delete nextValue.scale;
|
|
92
|
-
} else if (lastScale) {
|
|
93
|
-
nextValue.scale = lastScale;
|
|
94
98
|
} else {
|
|
95
|
-
nextValue.scale = defaultScale;
|
|
96
|
-
setLastScale(defaultScale);
|
|
99
|
+
nextValue.scale = lastScaleRef.current ?? defaultScale;
|
|
97
100
|
}
|
|
98
101
|
onChange(nextValue);
|
|
99
102
|
}
|
|
@@ -105,10 +108,9 @@ function DimensionsTool({
|
|
|
105
108
|
panelId,
|
|
106
109
|
options: scaleOptions,
|
|
107
110
|
defaultValue: defaultScale,
|
|
108
|
-
value:
|
|
111
|
+
value: scale,
|
|
109
112
|
onChange: (nextScale) => {
|
|
110
113
|
const nextValue = { ...value };
|
|
111
|
-
setLastScale(nextScale);
|
|
112
114
|
if (!nextScale) {
|
|
113
115
|
delete nextValue.scale;
|
|
114
116
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dimensions-tool/index.js"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { useEffect, useRef } from '@wordpress/element';\nimport AspectRatioTool from './aspect-ratio-tool';\nimport ScaleTool from './scale-tool';\nimport WidthHeightTool from './width-height-tool';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * @typedef {import('@wordpress/components/build-types/unit-control/types').WPUnitControlUnit} WPUnitControlUnit\n */\n\n/**\n * @typedef {Object} Dimensions\n * @property {string} [width] CSS width property.\n * @property {string} [height] CSS height property.\n * @property {string} [scale] CSS object-fit property.\n * @property {string} [aspectRatio] CSS aspect-ratio property.\n */\n\n/**\n * @callback DimensionsControlsOnChange\n * @param {Dimensions} nextValue\n * @return {void}\n */\n\n/**\n * @typedef {Object} DimensionsControlsProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {Dimensions} [value] Current dimensions values.\n * @property {DimensionsControlsOnChange} [onChange] Callback to update the dimensions values.\n * @property {SelectControlProps[]} [aspectRatioOptions] Aspect ratio options.\n * @property {SelectControlProps[]} [scaleOptions] Scale options.\n * @property {WPUnitControlUnit[]} [unitsOptions] Units options.\n */\n\n/**\n * Component that renders controls to edit the dimensions of an image or container.\n *\n * @param {DimensionsControlsProps} props The component props.\n *\n * @return {Element} The dimensions controls.\n */\nfunction DimensionsTool( {\n\tpanelId,\n\tvalue = {},\n\tonChange = () => {},\n\taspectRatioOptions, // Default options handled by AspectRatioTool.\n\tdefaultAspectRatio = 'auto', // Match CSS default value for aspect-ratio.\n\tscaleOptions, // Default options handled by ScaleTool.\n\tdefaultScale = 'cover',\n\tunitsOptions, // Default options handled by UnitControl.\n\ttools = [ 'aspectRatio', 'widthHeight', 'scale' ],\n} ) {\n\t// Coerce undefined and CSS default values to be null.\n\tconst width =\n\t\tvalue.width === undefined || value.width === 'auto'\n\t\t\t? null\n\t\t\t: value.width;\n\tconst height =\n\t\tvalue.height === undefined || value.height === 'auto'\n\t\t\t? null\n\t\t\t: value.height;\n\tconst aspectRatio =\n\t\tvalue.aspectRatio === undefined || value.aspectRatio === 'auto'\n\t\t\t? null\n\t\t\t: value.aspectRatio;\n\tconst scale = value.scale === undefined ? null : value.scale;\n\n\tconst hasCustomAspectRatio = !! ( width && height );\n\n\t// Keep track of the previous values, so when a value is cleared by means\n\t// other than directly editing that field, it's easier to restore it. These\n\t// are only ever read while handling a change, so they're kept in refs and\n\t// synced from the value to stay correct when it is updated externally, e.g.\n\t// by undo or by another client.\n\tconst lastScaleRef = useRef( scale );\n\tconst lastAspectRatioRef = useRef( aspectRatio );\n\n\tuseEffect( () => {\n\t\t// Scale is cleared alongside the aspect ratio, so only remember the\n\t\t// values it is actually set to.\n\t\tif ( scale ) {\n\t\t\tlastScaleRef.current = scale;\n\t\t}\n\t}, [ scale ] );\n\n\tuseEffect( () => {\n\t\t// A custom aspect ratio, i.e. both a width and a height, clears the\n\t\t// aspect ratio value. Keep the remembered one so it can be restored\n\t\t// once the custom aspect ratio is removed.\n\t\tif ( ! hasCustomAspectRatio ) {\n\t\t\tlastAspectRatioRef.current = aspectRatio;\n\t\t}\n\t}, [ aspectRatio, hasCustomAspectRatio ] );\n\n\t// 'custom' is not a valid value for CSS aspect-ratio, but it is used in the\n\t// dropdown to indicate that setting both the width and height is the same\n\t// as a custom aspect ratio.\n\tconst aspectRatioValue = hasCustomAspectRatio ? 'custom' : aspectRatio;\n\n\tconst showScaleControl = aspectRatio || ( width && height );\n\n\treturn (\n\t\t<>\n\t\t\t{ tools.includes( 'aspectRatio' ) && (\n\t\t\t\t<AspectRatioTool\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t\toptions={ aspectRatioOptions }\n\t\t\t\t\tdefaultValue={ defaultAspectRatio }\n\t\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\t\tonChange={ ( nextAspectRatio ) => {\n\t\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\t\tnextAspectRatio =\n\t\t\t\t\t\t\tnextAspectRatio === 'auto' ? null : nextAspectRatio;\n\n\t\t\t\t\t\t// Update aspectRatio.\n\t\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.aspectRatio = nextAspectRatio;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.scale =\n\t\t\t\t\t\t\t\tlastScaleRef.current ?? defaultScale;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Auto-update width and height.\n\t\t\t\t\t\tif ( 'custom' !== nextAspectRatio && width && height ) {\n\t\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( nextValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ tools.includes( 'widthHeight' ) && (\n\t\t\t\t<WidthHeightTool\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t\tunits={ unitsOptions }\n\t\t\t\t\tvalue={ { width, height } }\n\t\t\t\t\tonChange={ ( { width: nextWidth, height: nextHeight } ) => {\n\t\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\t\tnextWidth = nextWidth === 'auto' ? null : nextWidth;\n\t\t\t\t\t\tnextHeight = nextHeight === 'auto' ? null : nextHeight;\n\n\t\t\t\t\t\t// Update width.\n\t\t\t\t\t\tif ( ! nextWidth ) {\n\t\t\t\t\t\t\tdelete nextValue.width;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.width = nextWidth;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Update height.\n\t\t\t\t\t\tif ( ! nextHeight ) {\n\t\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.height = nextHeight;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Auto-update aspectRatio.\n\t\t\t\t\t\tif ( nextWidth && nextHeight ) {\n\t\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t\t} else if ( lastAspectRatioRef.current ) {\n\t\t\t\t\t\t\tnextValue.aspectRatio = lastAspectRatioRef.current;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// No setting defaultAspectRatio here, because\n\t\t\t\t\t\t\t// aspectRatio is optional in this scenario,\n\t\t\t\t\t\t\t// unlike scale.\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! lastAspectRatioRef.current &&\n\t\t\t\t\t\t\t!! nextWidth !== !! nextHeight\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.scale =\n\t\t\t\t\t\t\t\tlastScaleRef.current ?? defaultScale;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( nextValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ tools.includes( 'scale' ) && showScaleControl && (\n\t\t\t\t<ScaleTool\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t\toptions={ scaleOptions }\n\t\t\t\t\tdefaultValue={ defaultScale }\n\t\t\t\t\tvalue={ scale }\n\t\t\t\t\tonChange={ ( nextScale ) => {\n\t\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t\t// Update scale.\n\t\t\t\t\t\tif ( ! nextScale ) {\n\t\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.scale = nextScale;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( nextValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default DimensionsTool;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,WAAW,cAAc;AAClC,OAAO,qBAAqB;AAC5B,OAAO,eAAe;AACtB,OAAO,qBAAqB;AAsG1B,mBAEE,KAFF;AA7DF,SAAS,eAAgB;AAAA,EACxB;AAAA,EACA,QAAQ,CAAC;AAAA,EACT,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB;AAAA;AAAA,EACA,qBAAqB;AAAA;AAAA,EACrB;AAAA;AAAA,EACA,eAAe;A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": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// packages/block-editor/src/components/dimensions-tool/utils.js
|
|
2
|
+
function parseAspectRatio(value) {
|
|
3
|
+
if (typeof value !== "string") {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
const parts = value.split("/");
|
|
7
|
+
if (parts.length > 2) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const [width, height = "1"] = parts;
|
|
11
|
+
const numericWidth = Number(width.trim());
|
|
12
|
+
const numericHeight = Number(height.trim());
|
|
13
|
+
if (!Number.isFinite(numericWidth) || !Number.isFinite(numericHeight) || numericWidth <= 0 || numericHeight <= 0) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return numericWidth / numericHeight;
|
|
17
|
+
}
|
|
18
|
+
function findAspectRatioOption(value, options) {
|
|
19
|
+
const exactMatch = options.find((option) => option.value === value);
|
|
20
|
+
if (exactMatch) {
|
|
21
|
+
return exactMatch;
|
|
22
|
+
}
|
|
23
|
+
const ratio = parseAspectRatio(value);
|
|
24
|
+
if (ratio === null) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return options.find(
|
|
28
|
+
(option) => parseAspectRatio(option.value) === ratio
|
|
29
|
+
) ?? null;
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
findAspectRatioOption,
|
|
33
|
+
parseAspectRatio
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/dimensions-tool/utils.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Parses a CSS `aspect-ratio` value into a number so that values that are\n * written differently but describe the same ratio, e.g. `1` and `1/1`, can be\n * compared.\n *\n * @param {string} [value] CSS aspect-ratio value, e.g. '16/9' or '1.5'.\n *\n * @return {?number} The ratio as a number, or null when it cannot be parsed.\n */\nexport function parseAspectRatio( value ) {\n\tif ( typeof value !== 'string' ) {\n\t\treturn null;\n\t}\n\n\tconst parts = value.split( '/' );\n\n\tif ( parts.length > 2 ) {\n\t\treturn null;\n\t}\n\n\tconst [ width, height = '1' ] = parts;\n\tconst numericWidth = Number( width.trim() );\n\tconst numericHeight = Number( height.trim() );\n\n\tif (\n\t\t! Number.isFinite( numericWidth ) ||\n\t\t! Number.isFinite( numericHeight ) ||\n\t\tnumericWidth <= 0 ||\n\t\tnumericHeight <= 0\n\t) {\n\t\treturn null;\n\t}\n\n\treturn numericWidth / numericHeight;\n}\n\n/**\n * Finds the option that represents the given CSS `aspect-ratio` value.\n *\n * Aspect ratio values are free-form CSS, while the options are a fixed list of\n * presets, so an exact string match isn't enough: `1/1` and `1` describe the\n * same ratio but only one of them is a preset value.\n *\n * @param {string} value CSS aspect-ratio value.\n * @param {Object[]} options Aspect ratio options.\n *\n * @return {?Object} The matching option, or null when there is none.\n */\nexport function findAspectRatioOption( value, options ) {\n\tconst exactMatch = options.find( ( option ) => option.value === value );\n\n\tif ( exactMatch ) {\n\t\treturn exactMatch;\n\t}\n\n\tconst ratio = parseAspectRatio( value );\n\n\tif ( ratio === null ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\toptions.find(\n\t\t\t( option ) => parseAspectRatio( option.value ) === ratio\n\t\t) ?? null\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AASO,SAAS,iBAAkB,OAAQ;AACzC,MAAK,OAAO,UAAU,UAAW;AAChC,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,MAAM,MAAO,GAAI;AAE/B,MAAK,MAAM,SAAS,GAAI;AACvB,WAAO;AAAA,EACR;AAEA,QAAM,CAAE,OAAO,SAAS,GAAI,IAAI;AAChC,QAAM,eAAe,OAAQ,MAAM,KAAK,CAAE;AAC1C,QAAM,gBAAgB,OAAQ,OAAO,KAAK,CAAE;AAE5C,MACC,CAAE,OAAO,SAAU,YAAa,KAChC,CAAE,OAAO,SAAU,aAAc,KACjC,gBAAgB,KAChB,iBAAiB,GAChB;AACD,WAAO;AAAA,EACR;AAEA,SAAO,eAAe;AACvB;AAcO,SAAS,sBAAuB,OAAO,SAAU;AACvD,QAAM,aAAa,QAAQ,KAAM,CAAE,WAAY,OAAO,UAAU,KAAM;AAEtE,MAAK,YAAa;AACjB,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,iBAAkB,KAAM;AAEtC,MAAK,UAAU,MAAO;AACrB,WAAO;AAAA,EACR;AAEA,SACC,QAAQ;AAAA,IACP,CAAE,WAAY,iBAAkB,OAAO,KAAM,MAAM;AAAA,EACpD,KAAK;AAEP;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -19,6 +19,7 @@ function DuotoneControl({
|
|
|
19
19
|
disableCustomColors,
|
|
20
20
|
disableCustomDuotone,
|
|
21
21
|
value,
|
|
22
|
+
selectedSlug,
|
|
22
23
|
onChange
|
|
23
24
|
}) {
|
|
24
25
|
let toolbarIcon;
|
|
@@ -73,6 +74,7 @@ function DuotoneControl({
|
|
|
73
74
|
disableCustomColors,
|
|
74
75
|
disableCustomDuotone,
|
|
75
76
|
value,
|
|
77
|
+
selectedSlug,
|
|
76
78
|
onChange
|
|
77
79
|
}
|
|
78
80
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/duotone-control/index.js"],
|
|
4
|
-
"sourcesContent": ["import {\n\tColorIndicator,\n\tDropdown,\n\tDuotonePicker,\n\tDuotoneSwatch,\n\tMenuGroup,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { DOWN } from '@wordpress/keycodes';\nimport { Icon, filter } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\n\nfunction DuotoneControl( {\n\tid: idProp,\n\tcolorPalette,\n\tduotonePalette,\n\tdisableCustomColors,\n\tdisableCustomDuotone,\n\tvalue,\n\tonChange,\n} ) {\n\tlet toolbarIcon;\n\tif ( value === 'unset' ) {\n\t\ttoolbarIcon = (\n\t\t\t<ColorIndicator className=\"block-editor-duotone-control__unset-indicator\" />\n\t\t);\n\t} else if ( value ) {\n\t\ttoolbarIcon = <DuotoneSwatch values={ value } />;\n\t} else {\n\t\ttoolbarIcon = <Icon icon={ filter } />;\n\t}\n\n\tconst actionLabel = __( 'Apply duotone filter' );\n\tconst id = useInstanceId( DuotoneControl, 'duotone-control', idProp );\n\tconst descriptionId = `${ id }__description`;\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ {\n\t\t\t\tclassName: 'block-editor-duotone-control__popover',\n\t\t\t\theaderTitle: __( 'Duotone' ),\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => {\n\t\t\t\tconst openOnArrowDown = ( event ) => {\n\t\t\t\t\tif ( ! isOpen && event.keyCode === DOWN ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tonToggle();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\treturn (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t\t\tlabel={ actionLabel }\n\t\t\t\t\t\ticon={ toolbarIcon }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} }\n\t\t\trenderContent={ () => (\n\t\t\t\t<MenuGroup label={ __( 'Duotone' ) }>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Create a two-tone color effect without losing your original image.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<DuotonePicker\n\t\t\t\t\t\taria-label={ actionLabel }\n\t\t\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default DuotoneControl;\n"],
|
|
5
|
-
"mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AACnB,SAAS,YAAY;AACrB,SAAS,MAAM,cAAc;AAC7B,SAAS,qBAAqB;
|
|
4
|
+
"sourcesContent": ["import {\n\tColorIndicator,\n\tDropdown,\n\tDuotonePicker,\n\tDuotoneSwatch,\n\tMenuGroup,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { DOWN } from '@wordpress/keycodes';\nimport { Icon, filter } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\n\nfunction DuotoneControl( {\n\tid: idProp,\n\tcolorPalette,\n\tduotonePalette,\n\tdisableCustomColors,\n\tdisableCustomDuotone,\n\tvalue,\n\tselectedSlug,\n\tonChange,\n} ) {\n\tlet toolbarIcon;\n\tif ( value === 'unset' ) {\n\t\ttoolbarIcon = (\n\t\t\t<ColorIndicator className=\"block-editor-duotone-control__unset-indicator\" />\n\t\t);\n\t} else if ( value ) {\n\t\ttoolbarIcon = <DuotoneSwatch values={ value } />;\n\t} else {\n\t\ttoolbarIcon = <Icon icon={ filter } />;\n\t}\n\n\tconst actionLabel = __( 'Apply duotone filter' );\n\tconst id = useInstanceId( DuotoneControl, 'duotone-control', idProp );\n\tconst descriptionId = `${ id }__description`;\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ {\n\t\t\t\tclassName: 'block-editor-duotone-control__popover',\n\t\t\t\theaderTitle: __( 'Duotone' ),\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => {\n\t\t\t\tconst openOnArrowDown = ( event ) => {\n\t\t\t\t\tif ( ! isOpen && event.keyCode === DOWN ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tonToggle();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\treturn (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t\t\tlabel={ actionLabel }\n\t\t\t\t\t\ticon={ toolbarIcon }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} }\n\t\t\trenderContent={ () => (\n\t\t\t\t<MenuGroup label={ __( 'Duotone' ) }>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Create a two-tone color effect without losing your original image.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<DuotonePicker\n\t\t\t\t\t\taria-label={ actionLabel }\n\t\t\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tselectedSlug={ selectedSlug }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default DuotoneControl;\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS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A;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACD;AAAA,SACD;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,0BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// packages/block-editor/src/components/global-styles/advanced-panel.js
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
TextareaControl as WCTextareaControl,
|
|
4
|
+
Notice
|
|
5
|
+
} from "@wordpress/components";
|
|
3
6
|
import { Stack } from "@wordpress/ui";
|
|
4
7
|
import { useState } from "@wordpress/element";
|
|
5
8
|
import { __ } from "@wordpress/i18n";
|
|
@@ -57,7 +60,7 @@ function AdvancedPanel({
|
|
|
57
60
|
children: [
|
|
58
61
|
cssError && /* @__PURE__ */ jsx(Notice, { status: "error", onRemove: () => setCSSError(null), children: cssError }),
|
|
59
62
|
/* @__PURE__ */ jsx(
|
|
60
|
-
|
|
63
|
+
WCTextareaControl,
|
|
61
64
|
{
|
|
62
65
|
label: __("Additional CSS"),
|
|
63
66
|
value: customCSS,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/global-styles/advanced-panel.js"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";AAAA,
|
|
4
|
+
"sourcesContent": ["import {\n\tTextareaControl as WCTextareaControl,\n\tNotice,\n} from '@wordpress/components';\nimport { Stack } from '@wordpress/ui';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { default as transformStyles } from '../../utils/transform-styles';\n\n/**\n * Validates that a CSS string doesn't contain HTML markup.\n * Uses the same validation as the PHP/global styles REST API.\n *\n * @param {string} css The CSS string to validate.\n * @return {boolean} True if the CSS is valid, false otherwise.\n */\nexport function validateCSS( css ) {\n\t// Check for HTML markup.\n\tif ( typeof css === 'string' && /<\\/?\\w/.test( css ) ) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/**\n * Returns the error message string if the CSS contains HTML markup, or null if it is clean.\n *\n * @param {string} css The CSS string to check.\n * @return {string|null} An error message, or null if the CSS is valid.\n */\nfunction getMarkupValidationError( css ) {\n\treturn validateCSS( css )\n\t\t? null\n\t\t: __( 'The custom CSS is invalid. Do not use <> markup.' );\n}\n\n/**\n * Full CSS validation: markup check first (fast), then a CSS parser (slower).\n *\n * @param {string} css The CSS string to validate.\n * @return {string|null} An error message, or null if the CSS is valid.\n */\nfunction getCSSValidationError( css ) {\n\tif ( ! css ) {\n\t\treturn null;\n\t}\n\tconst markupError = getMarkupValidationError( css );\n\tif ( markupError ) {\n\t\treturn markupError;\n\t}\n\tconst [ transformed ] = transformStyles(\n\t\t[ { css } ],\n\t\t'.for-validation-only'\n\t);\n\treturn transformed === null\n\t\t? __( 'There is an error with your CSS structure.' )\n\t\t: null;\n}\n\nexport default function AdvancedPanel( {\n\tvalue,\n\tonChange,\n\tinheritedValue = value,\n\thelp,\n} ) {\n\t// Custom CSS\n\tconst customCSS = inheritedValue?.css;\n\tconst [ cssError, setCSSError ] = useState( () =>\n\t\tgetCSSValidationError( customCSS )\n\t);\n\tfunction handleOnChange( newValue ) {\n\t\tonChange( {\n\t\t\t...value,\n\t\t\tcss: newValue,\n\t\t} );\n\n\t\tsetCSSError( getMarkupValidationError( newValue ) );\n\t}\n\tfunction handleOnBlur( event ) {\n\t\tsetCSSError( getCSSValidationError( event?.target?.value ) );\n\t}\n\n\treturn (\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t\tclassName=\"block-editor-global-styles-advanced-panel\"\n\t\t>\n\t\t\t{ cssError && (\n\t\t\t\t<Notice status=\"error\" onRemove={ () => setCSSError( null ) }>\n\t\t\t\t\t{ cssError }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t\t<WCTextareaControl\n\t\t\t\tlabel={ __( 'Additional CSS' ) }\n\t\t\t\tvalue={ customCSS }\n\t\t\t\tonChange={ ( newValue ) => handleOnChange( newValue ) }\n\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\tclassName=\"block-editor-global-styles-advanced-panel__custom-css-input\"\n\t\t\t\tspellCheck={ false }\n\t\t\t\thelp={ help }\n\t\t\t/>\n\t\t</Stack>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EACC,mBAAmB;AAAA,EACnB;AAAA,OACM;AACP,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,UAAU;AACnB,SAAS,WAAW,uBAAuB;AA4EzC,SAME,KANF;AAnEK,SAAS,YAAa,KAAM;AAElC,MAAK,OAAO,QAAQ,YAAY,SAAS,KAAM,GAAI,GAAI;AACtD,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAQA,SAAS,yBAA0B,KAAM;AACxC,SAAO,YAAa,GAAI,IACrB,OACA,GAAI,kDAAmD;AAC3D;AAQA,SAAS,sBAAuB,KAAM;AACrC,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AACA,QAAM,cAAc,yBAA0B,GAAI;AAClD,MAAK,aAAc;AAClB,WAAO;AAAA,EACR;AACA,QAAM,CAAE,WAAY,IAAI;AAAA,IACvB,CAAE,EAAE,IAAI,CAAE;AAAA,IACV;AAAA,EACD;AACA,SAAO,gBAAgB,OACpB,GAAI,4CAA6C,IACjD;AACJ;AAEe,SAAR,cAAgC;AAAA,EACtC;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB;AACD,GAAI;AAEH,QAAM,YAAY,gBAAgB;AAClC,QAAM,CAAE,UAAU,WAAY,IAAI;AAAA,IAAU,MAC3C,sBAAuB,SAAU;AAAA,EAClC;AACA,WAAS,eAAgB,UAAW;AACnC,aAAU;AAAA,MACT,GAAG;AAAA,MACH,KAAK;AAAA,IACN,CAAE;AAEF,gBAAa,yBAA0B,QAAS,CAAE;AAAA,EACnD;AACA,WAAS,aAAc,OAAQ;AAC9B,gBAAa,sBAAuB,OAAO,QAAQ,KAAM,CAAE;AAAA,EAC5D;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,KAAI;AAAA,MACJ,WAAU;AAAA,MAER;AAAA,oBACD,oBAAC,UAAO,QAAO,SAAQ,UAAW,MAAM,YAAa,IAAK,GACvD,oBACH;AAAA,QAED;AAAA,UAAC;AAAA;AAAA,YACA,OAAQ,GAAI,gBAAiB;AAAA,YAC7B,OAAQ;AAAA,YACR,UAAW,CAAE,aAAc,eAAgB,QAAS;AAAA,YACpD,QAAS;AAAA,YACT,WAAU;AAAA,YACV,YAAa;AAAA,YACb;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -88,7 +88,6 @@ function BorderPanel({
|
|
|
88
88
|
inheritedValue = value,
|
|
89
89
|
settings,
|
|
90
90
|
panelId,
|
|
91
|
-
name,
|
|
92
91
|
defaultControls = DEFAULT_CONTROLS,
|
|
93
92
|
showInheritanceLabelIndicators = isGlobalStylesInheritanceEnabled()
|
|
94
93
|
}) {
|
|
@@ -204,10 +203,9 @@ function BorderPanel({
|
|
|
204
203
|
const inheritedShadow = decodeValue(inheritedValue?.shadow);
|
|
205
204
|
const isShadowPlaceholder = localShadow === void 0 && inheritedShadow !== void 0 && inheritedShadow !== "";
|
|
206
205
|
const shadow = isShadowPlaceholder ? inheritedShadow : localShadow;
|
|
207
|
-
const shadowPresets = settings
|
|
208
|
-
const mergedShadowPresets = shadowPresets.custom ?? shadowPresets.theme ?? shadowPresets.default ?? [];
|
|
206
|
+
const shadowPresets = useShadowPresets(settings);
|
|
209
207
|
const setShadow = (newValue) => {
|
|
210
|
-
const slug =
|
|
208
|
+
const slug = shadowPresets.findLast(
|
|
211
209
|
({ shadow: shadowName }) => shadowName === newValue
|
|
212
210
|
)?.slug;
|
|
213
211
|
onChange(
|
|
@@ -263,7 +261,6 @@ function BorderPanel({
|
|
|
263
261
|
const showBorderByDefault = defaultControls?.color || defaultControls?.width;
|
|
264
262
|
const hasBorderControl = showBorderColor || showBorderStyle || showBorderWidth || showBorderRadius;
|
|
265
263
|
const label = useBorderPanelLabel({
|
|
266
|
-
blockName: name,
|
|
267
264
|
hasShadowControl,
|
|
268
265
|
hasBorderControl
|
|
269
266
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/global-styles/border-panel.js"],
|
|
4
|
-
"sourcesContent": ["import {\n\tBorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\tBaseControl,\n} from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getValueFromVariable } from '@wordpress/global-styles-engine';\nimport BorderRadiusControl from '../border-radius-control';\nimport { useColorsPerOrigin } from './hooks';\nimport { useToolsPanelDropdownMenuProps } from './utils';\nimport { setImmutably } from '../../utils/object';\nimport { useBorderPanelLabel } from '../../hooks/border';\nimport { ShadowPopover, useShadowPresets } from './shadow-panel-components';\nimport {\n\tgetInheritanceProps,\n\tInheritanceToolsPanelItem,\n\tisGlobalStylesInheritanceEnabled,\n} from './inheritance';\n\nexport function useHasBorderPanel( settings ) {\n\tconst controls = Object.values( useHasBorderPanelControls( settings ) );\n\treturn controls.some( Boolean );\n}\n\nexport function useHasBorderPanelControls( settings ) {\n\tconst controls = {\n\t\thasBorderColor: useHasBorderColorControl( settings ),\n\t\thasBorderRadius: useHasBorderRadiusControl( settings ),\n\t\thasBorderStyle: useHasBorderStyleControl( settings ),\n\t\thasBorderWidth: useHasBorderWidthControl( settings ),\n\t\thasShadow: useHasShadowControl( settings ),\n\t};\n\n\treturn controls;\n}\n\nfunction useHasBorderColorControl( settings ) {\n\treturn settings?.border?.color;\n}\n\nfunction useHasBorderRadiusControl( settings ) {\n\treturn settings?.border?.radius;\n}\n\nfunction useHasBorderStyleControl( settings ) {\n\treturn settings?.border?.style;\n}\n\nfunction useHasBorderWidthControl( settings ) {\n\treturn settings?.border?.width;\n}\n\nfunction useHasShadowControl( settings ) {\n\tconst shadows = useShadowPresets( settings );\n\treturn !! settings?.shadow && shadows.length > 0;\n}\n\nfunction BorderToolsPanel( {\n\tresetAllFilter,\n\tonChange,\n\tvalue,\n\tpanelId,\n\tchildren,\n\tlabel,\n} ) {\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst resetAll = () => {\n\t\tconst updatedValue = resetAllFilter( value );\n\t\tonChange( updatedValue );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ label }\n\t\t\tresetAll={ resetAll }\n\t\t\tpanelId={ panelId }\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanel>\n\t);\n}\n\nconst DEFAULT_CONTROLS = {\n\tradius: true,\n\tcolor: true,\n\twidth: true,\n\tshadow: true,\n};\n\nexport default function BorderPanel( {\n\tas: Wrapper = BorderToolsPanel,\n\tvalue,\n\tonChange,\n\tinheritedValue = value,\n\tsettings,\n\tpanelId,\n\tname,\n\tdefaultControls = DEFAULT_CONTROLS,\n\tshowInheritanceLabelIndicators = isGlobalStylesInheritanceEnabled(),\n} ) {\n\tconst colors = useColorsPerOrigin( settings );\n\tconst areCustomSolidsEnabled = settings?.color?.custom;\n\tconst decodeValue = useCallback(\n\t\t( rawValue ) => getValueFromVariable( { settings }, '', rawValue ),\n\t\t[ settings ]\n\t);\n\t// Always keep the layout className (e.g. `single-column`); only the\n\t// inheritance treatment is gated on `showInheritanceLabelIndicators`.\n\tconst inheritanceProps = ( isInherited, hasLocalOverride, className ) =>\n\t\tgetInheritanceProps(\n\t\t\tshowInheritanceLabelIndicators && isInherited,\n\t\t\tshowInheritanceLabelIndicators && hasLocalOverride,\n\t\t\tclassName\n\t\t);\n\tconst encodeColorValue = ( colorValue ) => {\n\t\tconst allColors = colors.flatMap(\n\t\t\t( { colors: originColors } ) => originColors\n\t\t);\n\t\tconst colorObject = allColors.find(\n\t\t\t( { color } ) => color === colorValue\n\t\t);\n\t\treturn colorObject\n\t\t\t? 'var:preset|color|' + colorObject.slug\n\t\t\t: colorValue;\n\t};\n\t// Decode a `border` sub-tree (handles split borders + flat shape).\n\tconst decodeBorder = useCallback(\n\t\t( source ) => {\n\t\t\tif ( ! source ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif ( hasSplitBorders( source ) ) {\n\t\t\t\tconst out = { ...source };\n\t\t\t\t[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {\n\t\t\t\t\tout[ side ] = {\n\t\t\t\t\t\t...out[ side ],\n\t\t\t\t\t\tcolor: decodeValue( out[ side ]?.color ),\n\t\t\t\t\t};\n\t\t\t\t} );\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...source,\n\t\t\t\tcolor: source.color ? decodeValue( source.color ) : undefined,\n\t\t\t};\n\t\t},\n\t\t[ decodeValue ]\n\t);\n\t// Local-then-inherited: prefer the user's locally-set border (whether\n\t// flat or split) when defined, otherwise fall back to the inherited\n\t// Global Styles border. The merge happens at the sub-tree root, not\n\t// at the leaf level — borders are commonly authored as a single\n\t// affordance in the inspector, so partial leaf merges would be\n\t// surprising.\n\tconst localBorder = useMemo(\n\t\t() => decodeBorder( value?.border ),\n\t\t[ value?.border, decodeBorder ]\n\t);\n\tconst inheritedBorder = useMemo(\n\t\t() => decodeBorder( inheritedValue?.border ),\n\t\t[ inheritedValue?.border, decodeBorder ]\n\t);\n\tconst isBorderPlaceholder =\n\t\t! isDefinedBorder( value?.border ) &&\n\t\t!! inheritedBorder &&\n\t\tisDefinedBorder( inheritedBorder );\n\tconst border = isBorderPlaceholder ? inheritedBorder : localBorder;\n\tconst setBorder = ( newBorder ) =>\n\t\tonChange( { ...value, border: newBorder } );\n\tconst showBorderColor = useHasBorderColorControl( settings );\n\tconst showBorderStyle = useHasBorderStyleControl( settings );\n\tconst showBorderWidth = useHasBorderWidthControl( settings );\n\n\t// Border radius. Display inherited values through the control's `values`\n\t// prop when local values are empty so UnitControl can parse the numeric\n\t// quantity and selected unit normally (e.g. `2.5em` -> `2.5` + `em`).\n\t// `hasBorderRadius` remains local-only, so displaying the inherited value\n\t// does not mark the ToolsPanel item as customised or commit on mount.\n\tconst showBorderRadius = useHasBorderRadiusControl( settings );\n\tconst localBorderRadius = useMemo( () => {\n\t\tif ( typeof value?.border?.radius !== 'object' ) {\n\t\t\treturn decodeValue( value?.border?.radius );\n\t\t}\n\t\treturn {\n\t\t\ttopLeft: decodeValue( value?.border?.radius?.topLeft ),\n\t\t\ttopRight: decodeValue( value?.border?.radius?.topRight ),\n\t\t\tbottomLeft: decodeValue( value?.border?.radius?.bottomLeft ),\n\t\t\tbottomRight: decodeValue( value?.border?.radius?.bottomRight ),\n\t\t};\n\t}, [ value?.border?.radius, decodeValue ] );\n\tconst inheritedBorderRadius = useMemo( () => {\n\t\tconst rawRadius = inheritedValue?.border?.radius;\n\t\tif ( typeof rawRadius !== 'object' ) {\n\t\t\treturn decodeValue( rawRadius );\n\t\t}\n\t\treturn {\n\t\t\ttopLeft: decodeValue( rawRadius?.topLeft ),\n\t\t\ttopRight: decodeValue( rawRadius?.topRight ),\n\t\t\tbottomLeft: decodeValue( rawRadius?.bottomLeft ),\n\t\t\tbottomRight: decodeValue( rawRadius?.bottomRight ),\n\t\t};\n\t}, [ inheritedValue?.border?.radius, decodeValue ] );\n\t// Spread the local border, not the merged display value, or setting a\n\t// radius bakes the inherited border into the local override. Mirror of\n\t// the guard in `onBorderChange`.\n\tconst setBorderRadius = ( newBorderRadius ) =>\n\t\tsetBorder( { ...value?.border, radius: newBorderRadius } );\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = value?.border?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( ( [ , v ] ) => !! v );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\tconst isBorderRadiusPlaceholder =\n\t\t! hasBorderRadius() &&\n\t\tinheritedBorderRadius !== undefined &&\n\t\tinheritedBorderRadius !== '';\n\t// Build an object value so unlinked-mode shows per-corner inherited\n\t// values. The control accepts either a string or an object; passing the\n\t// object form is correct in both modes (the control collapses to the\n\t// `all`/first corner in linked mode).\n\tconst borderRadius = useMemo( () => {\n\t\tif ( ! isBorderRadiusPlaceholder ) {\n\t\t\treturn localBorderRadius;\n\t\t}\n\t\tif ( typeof inheritedBorderRadius === 'string' ) {\n\t\t\treturn inheritedBorderRadius;\n\t\t}\n\t\tconst obj = inheritedBorderRadius;\n\t\tif ( ! obj ) {\n\t\t\treturn localBorderRadius;\n\t\t}\n\t\tconst all =\n\t\t\tobj.topLeft &&\n\t\t\tobj.topLeft === obj.topRight &&\n\t\t\tobj.topLeft === obj.bottomLeft &&\n\t\t\tobj.topLeft === obj.bottomRight\n\t\t\t\t? obj.topLeft\n\t\t\t\t: undefined;\n\t\treturn { all, ...obj };\n\t}, [\n\t\tisBorderRadiusPlaceholder,\n\t\tlocalBorderRadius,\n\t\tinheritedBorderRadius,\n\t] );\n\tconst hasShadowControl = useHasShadowControl( settings );\n\n\t// Shadow. At rest, the popover toggle button uses the placeholder\n\t// treatment, and the popover preset list pre-selects the inherited shadow.\n\t// The interceptor below recognises the user's \"accept inherited\" click as\n\t// an explicit commit, mirroring the ToggleGroup pattern in the typography\n\t// panel.\n\tconst localShadow = decodeValue( value?.shadow );\n\tconst inheritedShadow = decodeValue( inheritedValue?.shadow );\n\tconst isShadowPlaceholder =\n\t\tlocalShadow === undefined &&\n\t\tinheritedShadow !== undefined &&\n\t\tinheritedShadow !== '';\n\tconst shadow = isShadowPlaceholder ? inheritedShadow : localShadow;\n\tconst shadowPresets = settings?.shadow?.presets ?? {};\n\tconst mergedShadowPresets =\n\t\tshadowPresets.custom ??\n\t\tshadowPresets.theme ??\n\t\tshadowPresets.default ??\n\t\t[];\n\tconst setShadow = ( newValue ) => {\n\t\tconst slug = mergedShadowPresets?.find(\n\t\t\t( { shadow: shadowName } ) => shadowName === newValue\n\t\t)?.slug;\n\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'shadow' ],\n\t\t\t\tslug ? `var:preset|shadow|${ slug }` : newValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\t// Display-without-commit interceptor for the shadow preset list. When the\n\t// user is at the at-rest preselect (local is undefined, inherited is the\n\t// active shadow), `ShadowPresets`' default toggle-off behaviour would\n\t// interpret the click on the highlighted preset as `undefined` (clear).\n\t// Re-route it to an explicit commit of the inherited value, so clicking\n\t// the visible preselected preset is the user's \"accept this inherited\n\t// value\" affordance.\n\tconst setShadowWithInheritedCommit = ( newValue ) => {\n\t\tif ( isShadowPlaceholder && newValue === undefined ) {\n\t\t\tsetShadow( inheritedShadow );\n\t\t\treturn;\n\t\t}\n\t\tsetShadow( newValue );\n\t};\n\tconst hasShadow = () => !! value?.shadow;\n\tconst resetShadow = () => setShadow( undefined );\n\t// A local override exists when the user has set a shadow that shadows an\n\t// inherited one. Only then does the toggle render the blue-dot reset\n\t// affordance (mirroring the color/gradient controls); a merely-inherited\n\t// value at rest shows no reset button.\n\tconst hasShadowLocalOverride =\n\t\tshowInheritanceLabelIndicators &&\n\t\thasShadow() &&\n\t\tinheritedShadow !== undefined;\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: value?.border?.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst onBorderChange = ( newBorder ) => {\n\t\t// Ensure we have a visible border style when a border width or\n\t\t// color is being selected.\n\t\tconst updatedBorder = { ...newBorder };\n\n\t\tif ( hasSplitBorders( updatedBorder ) ) {\n\t\t\t[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {\n\t\t\t\tif ( updatedBorder[ side ] ) {\n\t\t\t\t\tupdatedBorder[ side ] = {\n\t\t\t\t\t\t...updatedBorder[ side ],\n\t\t\t\t\t\tcolor: encodeColorValue( updatedBorder[ side ]?.color ),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t} else if ( updatedBorder ) {\n\t\t\tupdatedBorder.color = encodeColorValue( updatedBorder.color );\n\t\t}\n\n\t\t// As radius is maintained separately to color, style, and width\n\t\t// maintain its value. Read from `value` (local-only) rather than\n\t\t// `border` (the merged display value), otherwise an inherited\n\t\t// radius gets baked into the local override every time the\n\t\t// user touches color/style/width — which both pollutes the\n\t\t// stored attribute and causes the radius `ToolsPanelItem` to\n\t\t// flip into the `has-local-override-from-global-styles` state\n\t\t// even though the user never customised the radius. The\n\t\t// `radius` key must come after the spread so it wins over any\n\t\t// `radius` field forwarded by `BorderBoxControl`'s inner\n\t\t// `BorderControl`, which merges its incoming `value` with the\n\t\t// changed prop. Undefined values here will be cleaned when\n\t\t// global styles are saved.\n\t\tsetBorder( {\n\t\t\t...updatedBorder,\n\t\t\tradius: value?.border?.radius,\n\t\t} );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tborder: undefined,\n\t\t\tshadow: undefined,\n\t\t};\n\t}, [] );\n\n\tconst showBorderByDefault =\n\t\tdefaultControls?.color || defaultControls?.width;\n\n\tconst hasBorderControl =\n\t\tshowBorderColor ||\n\t\tshowBorderStyle ||\n\t\tshowBorderWidth ||\n\t\tshowBorderRadius;\n\n\tconst label = useBorderPanelLabel( {\n\t\tblockName: name,\n\t\thasShadowControl,\n\t\thasBorderControl,\n\t} );\n\n\treturn (\n\t\t<Wrapper\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tpanelId={ panelId }\n\t\t\tlabel={ label }\n\t\t>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<InheritanceToolsPanelItem\n\t\t\t\t\t{ ...inheritanceProps(\n\t\t\t\t\t\tisBorderPlaceholder,\n\t\t\t\t\t\tisDefinedBorder( value?.border ) &&\n\t\t\t\t\t\t\t!! inheritedBorder &&\n\t\t\t\t\t\t\tisDefinedBorder( inheritedBorder )\n\t\t\t\t\t) }\n\t\t\t\t\thasValue={ () => isDefinedBorder( value?.border ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ showBorderByDefault }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t{ ( showInheritanceLabelIndicators ||\n\t\t\t\t\t\thasShadowControl ) && (\n\t\t\t\t\t\t// Render the visible label as `BaseControl.VisualLabel`\n\t\t\t\t\t\t// (which produces `.components-base-control__label`)\n\t\t\t\t\t\t// rather than passing `label` to `BorderBoxControl`,\n\t\t\t\t\t\t// whose internal `<StyledLabel>` carries no stable\n\t\t\t\t\t\t// className. The inheritance treatment and the\n\t\t\t\t\t\t// local-override reset affordance both target\n\t\t\t\t\t\t// `.components-base-control__label`, so the visible\n\t\t\t\t\t\t// \"Border\" label has to be a `BaseControl` label to\n\t\t\t\t\t\t// receive them.\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// Render it whenever a Shadow control is also present so\n\t\t\t\t\t\t// the two controls stay disambiguated (mirrors the\n\t\t\t\t\t\t// Shadow label's `hasBorderControl` guard below, and\n\t\t\t\t\t\t// trunk's `hideLabelFromVision={ ! hasShadowControl }`),\n\t\t\t\t\t\t// even when inheritance indicators are off (e.g. in\n\t\t\t\t\t\t// Global Styles).\n\t\t\t\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t\t\t\t{ __( 'Border' ) }\n\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t) }\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tdisableCustomColors={ ! areCustomSolidsEnabled }\n\t\t\t\t\t\tenableAlpha\n\t\t\t\t\t\tenableStyle={ showBorderStyle }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t/>\n\t\t\t\t</InheritanceToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<InheritanceToolsPanelItem\n\t\t\t\t\t{ ...inheritanceProps(\n\t\t\t\t\t\tisBorderRadiusPlaceholder,\n\t\t\t\t\t\thasBorderRadius() && inheritedBorderRadius !== undefined\n\t\t\t\t\t) }\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\thasInlineEndToggle\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ defaultControls.radius }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tpresets={ settings?.border?.radiusSizes }\n\t\t\t\t\t\tvalues={ borderRadius }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetBorderRadius( newValue || undefined );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</InheritanceToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasShadowControl && (\n\t\t\t\t<InheritanceToolsPanelItem\n\t\t\t\t\t{ ...inheritanceProps(\n\t\t\t\t\t\tisShadowPlaceholder,\n\t\t\t\t\t\thasShadow() && inheritedShadow !== undefined\n\t\t\t\t\t) }\n\t\t\t\t\tlabel={ __( 'Shadow' ) }\n\t\t\t\t\thasValue={ hasShadow }\n\t\t\t\t\tonDeselect={ resetShadow }\n\t\t\t\t\tisShownByDefault={ defaultControls.shadow }\n\t\t\t\t\t// The shadow toggle renders its own reset affordance (blue\n\t\t\t\t\t// dot for a local override, default reset otherwise) inside\n\t\t\t\t\t// the control, mirroring the color/gradient controls, so the\n\t\t\t\t\t// panel item must not render a second sibling reset dot.\n\t\t\t\t\tshowLocalOverrideActionsInLabel={ false }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t{ hasBorderControl ? (\n\t\t\t\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t\t\t\t{ __( 'Shadow' ) }\n\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t) : null }\n\n\t\t\t\t\t<ShadowPopover\n\t\t\t\t\t\tshadow={ shadow }\n\t\t\t\t\t\tonShadowChange={ setShadowWithInheritedCommit }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\thasLocalValue={ hasShadow() }\n\t\t\t\t\t\thasLocalOverride={ hasShadowLocalOverride }\n\t\t\t\t\t\tonReset={ resetShadow }\n\t\t\t\t\t/>\n\t\t\t\t</InheritanceToolsPanelItem>\n\t\t\t) }\n\t\t</Wrapper>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAAA;AAAA,EACC;AAAA,EACA,iCAAiC;AAAA,EACjC,iCAAiC;AAAA,EACjC,4BAA4B;AAAA,EAC5B;AAAA,OACM;AACP,SAAS,aAAa,eAAe;AACrC,SAAS,UAAU;AACnB,SAAS,4BAA4B;AACrC,OAAO,yBAAyB;AAChC,SAAS,0BAA0B;AACnC,SAAS,sCAAsC;AAC/C,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AACpC,SAAS,eAAe,wBAAwB;AAChD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAuDL,
|
|
4
|
+
"sourcesContent": ["import {\n\tBorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\tBaseControl,\n} from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getValueFromVariable } from '@wordpress/global-styles-engine';\nimport BorderRadiusControl from '../border-radius-control';\nimport { useColorsPerOrigin } from './hooks';\nimport { useToolsPanelDropdownMenuProps } from './utils';\nimport { setImmutably } from '../../utils/object';\nimport { useBorderPanelLabel } from '../../hooks/border';\nimport { ShadowPopover, useShadowPresets } from './shadow-panel-components';\nimport {\n\tgetInheritanceProps,\n\tInheritanceToolsPanelItem,\n\tisGlobalStylesInheritanceEnabled,\n} from './inheritance';\n\nexport function useHasBorderPanel( settings ) {\n\tconst controls = Object.values( useHasBorderPanelControls( settings ) );\n\treturn controls.some( Boolean );\n}\n\nexport function useHasBorderPanelControls( settings ) {\n\tconst controls = {\n\t\thasBorderColor: useHasBorderColorControl( settings ),\n\t\thasBorderRadius: useHasBorderRadiusControl( settings ),\n\t\thasBorderStyle: useHasBorderStyleControl( settings ),\n\t\thasBorderWidth: useHasBorderWidthControl( settings ),\n\t\thasShadow: useHasShadowControl( settings ),\n\t};\n\n\treturn controls;\n}\n\nfunction useHasBorderColorControl( settings ) {\n\treturn settings?.border?.color;\n}\n\nfunction useHasBorderRadiusControl( settings ) {\n\treturn settings?.border?.radius;\n}\n\nfunction useHasBorderStyleControl( settings ) {\n\treturn settings?.border?.style;\n}\n\nfunction useHasBorderWidthControl( settings ) {\n\treturn settings?.border?.width;\n}\n\nfunction useHasShadowControl( settings ) {\n\tconst shadows = useShadowPresets( settings );\n\treturn !! settings?.shadow && shadows.length > 0;\n}\n\nfunction BorderToolsPanel( {\n\tresetAllFilter,\n\tonChange,\n\tvalue,\n\tpanelId,\n\tchildren,\n\tlabel,\n} ) {\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst resetAll = () => {\n\t\tconst updatedValue = resetAllFilter( value );\n\t\tonChange( updatedValue );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ label }\n\t\t\tresetAll={ resetAll }\n\t\t\tpanelId={ panelId }\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanel>\n\t);\n}\n\nconst DEFAULT_CONTROLS = {\n\tradius: true,\n\tcolor: true,\n\twidth: true,\n\tshadow: true,\n};\n\nexport default function BorderPanel( {\n\tas: Wrapper = BorderToolsPanel,\n\tvalue,\n\tonChange,\n\tinheritedValue = value,\n\tsettings,\n\tpanelId,\n\tdefaultControls = DEFAULT_CONTROLS,\n\tshowInheritanceLabelIndicators = isGlobalStylesInheritanceEnabled(),\n} ) {\n\tconst colors = useColorsPerOrigin( settings );\n\tconst areCustomSolidsEnabled = settings?.color?.custom;\n\tconst decodeValue = useCallback(\n\t\t( rawValue ) => getValueFromVariable( { settings }, '', rawValue ),\n\t\t[ settings ]\n\t);\n\t// Always keep the layout className (e.g. `single-column`); only the\n\t// inheritance treatment is gated on `showInheritanceLabelIndicators`.\n\tconst inheritanceProps = ( isInherited, hasLocalOverride, className ) =>\n\t\tgetInheritanceProps(\n\t\t\tshowInheritanceLabelIndicators && isInherited,\n\t\t\tshowInheritanceLabelIndicators && hasLocalOverride,\n\t\t\tclassName\n\t\t);\n\tconst encodeColorValue = ( colorValue ) => {\n\t\tconst allColors = colors.flatMap(\n\t\t\t( { colors: originColors } ) => originColors\n\t\t);\n\t\tconst colorObject = allColors.find(\n\t\t\t( { color } ) => color === colorValue\n\t\t);\n\t\treturn colorObject\n\t\t\t? 'var:preset|color|' + colorObject.slug\n\t\t\t: colorValue;\n\t};\n\t// Decode a `border` sub-tree (handles split borders + flat shape).\n\tconst decodeBorder = useCallback(\n\t\t( source ) => {\n\t\t\tif ( ! source ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif ( hasSplitBorders( source ) ) {\n\t\t\t\tconst out = { ...source };\n\t\t\t\t[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {\n\t\t\t\t\tout[ side ] = {\n\t\t\t\t\t\t...out[ side ],\n\t\t\t\t\t\tcolor: decodeValue( out[ side ]?.color ),\n\t\t\t\t\t};\n\t\t\t\t} );\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...source,\n\t\t\t\tcolor: source.color ? decodeValue( source.color ) : undefined,\n\t\t\t};\n\t\t},\n\t\t[ decodeValue ]\n\t);\n\t// Local-then-inherited: prefer the user's locally-set border (whether\n\t// flat or split) when defined, otherwise fall back to the inherited\n\t// Global Styles border. The merge happens at the sub-tree root, not\n\t// at the leaf level — borders are commonly authored as a single\n\t// affordance in the inspector, so partial leaf merges would be\n\t// surprising.\n\tconst localBorder = useMemo(\n\t\t() => decodeBorder( value?.border ),\n\t\t[ value?.border, decodeBorder ]\n\t);\n\tconst inheritedBorder = useMemo(\n\t\t() => decodeBorder( inheritedValue?.border ),\n\t\t[ inheritedValue?.border, decodeBorder ]\n\t);\n\tconst isBorderPlaceholder =\n\t\t! isDefinedBorder( value?.border ) &&\n\t\t!! inheritedBorder &&\n\t\tisDefinedBorder( inheritedBorder );\n\tconst border = isBorderPlaceholder ? inheritedBorder : localBorder;\n\tconst setBorder = ( newBorder ) =>\n\t\tonChange( { ...value, border: newBorder } );\n\tconst showBorderColor = useHasBorderColorControl( settings );\n\tconst showBorderStyle = useHasBorderStyleControl( settings );\n\tconst showBorderWidth = useHasBorderWidthControl( settings );\n\n\t// Border radius. Display inherited values through the control's `values`\n\t// prop when local values are empty so UnitControl can parse the numeric\n\t// quantity and selected unit normally (e.g. `2.5em` -> `2.5` + `em`).\n\t// `hasBorderRadius` remains local-only, so displaying the inherited value\n\t// does not mark the ToolsPanel item as customised or commit on mount.\n\tconst showBorderRadius = useHasBorderRadiusControl( settings );\n\tconst localBorderRadius = useMemo( () => {\n\t\tif ( typeof value?.border?.radius !== 'object' ) {\n\t\t\treturn decodeValue( value?.border?.radius );\n\t\t}\n\t\treturn {\n\t\t\ttopLeft: decodeValue( value?.border?.radius?.topLeft ),\n\t\t\ttopRight: decodeValue( value?.border?.radius?.topRight ),\n\t\t\tbottomLeft: decodeValue( value?.border?.radius?.bottomLeft ),\n\t\t\tbottomRight: decodeValue( value?.border?.radius?.bottomRight ),\n\t\t};\n\t}, [ value?.border?.radius, decodeValue ] );\n\tconst inheritedBorderRadius = useMemo( () => {\n\t\tconst rawRadius = inheritedValue?.border?.radius;\n\t\tif ( typeof rawRadius !== 'object' ) {\n\t\t\treturn decodeValue( rawRadius );\n\t\t}\n\t\treturn {\n\t\t\ttopLeft: decodeValue( rawRadius?.topLeft ),\n\t\t\ttopRight: decodeValue( rawRadius?.topRight ),\n\t\t\tbottomLeft: decodeValue( rawRadius?.bottomLeft ),\n\t\t\tbottomRight: decodeValue( rawRadius?.bottomRight ),\n\t\t};\n\t}, [ inheritedValue?.border?.radius, decodeValue ] );\n\t// Spread the local border, not the merged display value, or setting a\n\t// radius bakes the inherited border into the local override. Mirror of\n\t// the guard in `onBorderChange`.\n\tconst setBorderRadius = ( newBorderRadius ) =>\n\t\tsetBorder( { ...value?.border, radius: newBorderRadius } );\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = value?.border?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( ( [ , v ] ) => !! v );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\tconst isBorderRadiusPlaceholder =\n\t\t! hasBorderRadius() &&\n\t\tinheritedBorderRadius !== undefined &&\n\t\tinheritedBorderRadius !== '';\n\t// Build an object value so unlinked-mode shows per-corner inherited\n\t// values. The control accepts either a string or an object; passing the\n\t// object form is correct in both modes (the control collapses to the\n\t// `all`/first corner in linked mode).\n\tconst borderRadius = useMemo( () => {\n\t\tif ( ! isBorderRadiusPlaceholder ) {\n\t\t\treturn localBorderRadius;\n\t\t}\n\t\tif ( typeof inheritedBorderRadius === 'string' ) {\n\t\t\treturn inheritedBorderRadius;\n\t\t}\n\t\tconst obj = inheritedBorderRadius;\n\t\tif ( ! obj ) {\n\t\t\treturn localBorderRadius;\n\t\t}\n\t\tconst all =\n\t\t\tobj.topLeft &&\n\t\t\tobj.topLeft === obj.topRight &&\n\t\t\tobj.topLeft === obj.bottomLeft &&\n\t\t\tobj.topLeft === obj.bottomRight\n\t\t\t\t? obj.topLeft\n\t\t\t\t: undefined;\n\t\treturn { all, ...obj };\n\t}, [\n\t\tisBorderRadiusPlaceholder,\n\t\tlocalBorderRadius,\n\t\tinheritedBorderRadius,\n\t] );\n\tconst hasShadowControl = useHasShadowControl( settings );\n\n\t// Shadow. At rest, the popover toggle button uses the placeholder\n\t// treatment, and the popover preset list pre-selects the inherited shadow.\n\t// The interceptor below recognises the user's \"accept inherited\" click as\n\t// an explicit commit, mirroring the ToggleGroup pattern in the typography\n\t// panel.\n\tconst localShadow = decodeValue( value?.shadow );\n\tconst inheritedShadow = decodeValue( inheritedValue?.shadow );\n\tconst isShadowPlaceholder =\n\t\tlocalShadow === undefined &&\n\t\tinheritedShadow !== undefined &&\n\t\tinheritedShadow !== '';\n\tconst shadow = isShadowPlaceholder ? inheritedShadow : localShadow;\n\t// The presets the popover offers, from every origin. A preset the user\n\t// picked has to be stored as a reference to its CSS variable rather than as\n\t// the value it resolves to today, otherwise it stops tracking later edits\n\t// to the preset. Reading the same list the popover renders is what keeps\n\t// the two in step.\n\tconst shadowPresets = useShadowPresets( settings );\n\tconst setShadow = ( newValue ) => {\n\t\t// The list runs default, theme, custom, so searching backwards picks\n\t\t// the most specific origin when more than one defines the same shadow\n\t\t// value — a newly added custom preset starts out identical to the\n\t\t// `natural` default one, and it is the custom slug the user means.\n\t\tconst slug = shadowPresets.findLast(\n\t\t\t( { shadow: shadowName } ) => shadowName === newValue\n\t\t)?.slug;\n\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'shadow' ],\n\t\t\t\tslug ? `var:preset|shadow|${ slug }` : newValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\t// Display-without-commit interceptor for the shadow preset list. When the\n\t// user is at the at-rest preselect (local is undefined, inherited is the\n\t// active shadow), `ShadowPresets`' default toggle-off behaviour would\n\t// interpret the click on the highlighted preset as `undefined` (clear).\n\t// Re-route it to an explicit commit of the inherited value, so clicking\n\t// the visible preselected preset is the user's \"accept this inherited\n\t// value\" affordance.\n\tconst setShadowWithInheritedCommit = ( newValue ) => {\n\t\tif ( isShadowPlaceholder && newValue === undefined ) {\n\t\t\tsetShadow( inheritedShadow );\n\t\t\treturn;\n\t\t}\n\t\tsetShadow( newValue );\n\t};\n\tconst hasShadow = () => !! value?.shadow;\n\tconst resetShadow = () => setShadow( undefined );\n\t// A local override exists when the user has set a shadow that shadows an\n\t// inherited one. Only then does the toggle render the blue-dot reset\n\t// affordance (mirroring the color/gradient controls); a merely-inherited\n\t// value at rest shows no reset button.\n\tconst hasShadowLocalOverride =\n\t\tshowInheritanceLabelIndicators &&\n\t\thasShadow() &&\n\t\tinheritedShadow !== undefined;\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: value?.border?.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst onBorderChange = ( newBorder ) => {\n\t\t// Ensure we have a visible border style when a border width or\n\t\t// color is being selected.\n\t\tconst updatedBorder = { ...newBorder };\n\n\t\tif ( hasSplitBorders( updatedBorder ) ) {\n\t\t\t[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {\n\t\t\t\tif ( updatedBorder[ side ] ) {\n\t\t\t\t\tupdatedBorder[ side ] = {\n\t\t\t\t\t\t...updatedBorder[ side ],\n\t\t\t\t\t\tcolor: encodeColorValue( updatedBorder[ side ]?.color ),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t} else if ( updatedBorder ) {\n\t\t\tupdatedBorder.color = encodeColorValue( updatedBorder.color );\n\t\t}\n\n\t\t// As radius is maintained separately to color, style, and width\n\t\t// maintain its value. Read from `value` (local-only) rather than\n\t\t// `border` (the merged display value), otherwise an inherited\n\t\t// radius gets baked into the local override every time the\n\t\t// user touches color/style/width — which both pollutes the\n\t\t// stored attribute and causes the radius `ToolsPanelItem` to\n\t\t// flip into the `has-local-override-from-global-styles` state\n\t\t// even though the user never customised the radius. The\n\t\t// `radius` key must come after the spread so it wins over any\n\t\t// `radius` field forwarded by `BorderBoxControl`'s inner\n\t\t// `BorderControl`, which merges its incoming `value` with the\n\t\t// changed prop. Undefined values here will be cleaned when\n\t\t// global styles are saved.\n\t\tsetBorder( {\n\t\t\t...updatedBorder,\n\t\t\tradius: value?.border?.radius,\n\t\t} );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tborder: undefined,\n\t\t\tshadow: undefined,\n\t\t};\n\t}, [] );\n\n\tconst showBorderByDefault =\n\t\tdefaultControls?.color || defaultControls?.width;\n\n\tconst hasBorderControl =\n\t\tshowBorderColor ||\n\t\tshowBorderStyle ||\n\t\tshowBorderWidth ||\n\t\tshowBorderRadius;\n\n\tconst label = useBorderPanelLabel( {\n\t\thasShadowControl,\n\t\thasBorderControl,\n\t} );\n\n\treturn (\n\t\t<Wrapper\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tpanelId={ panelId }\n\t\t\tlabel={ label }\n\t\t>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<InheritanceToolsPanelItem\n\t\t\t\t\t{ ...inheritanceProps(\n\t\t\t\t\t\tisBorderPlaceholder,\n\t\t\t\t\t\tisDefinedBorder( value?.border ) &&\n\t\t\t\t\t\t\t!! inheritedBorder &&\n\t\t\t\t\t\t\tisDefinedBorder( inheritedBorder )\n\t\t\t\t\t) }\n\t\t\t\t\thasValue={ () => isDefinedBorder( value?.border ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ showBorderByDefault }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t{ ( showInheritanceLabelIndicators ||\n\t\t\t\t\t\thasShadowControl ) && (\n\t\t\t\t\t\t// Render the visible label as `BaseControl.VisualLabel`\n\t\t\t\t\t\t// (which produces `.components-base-control__label`)\n\t\t\t\t\t\t// rather than passing `label` to `BorderBoxControl`,\n\t\t\t\t\t\t// whose internal `<StyledLabel>` carries no stable\n\t\t\t\t\t\t// className. The inheritance treatment and the\n\t\t\t\t\t\t// local-override reset affordance both target\n\t\t\t\t\t\t// `.components-base-control__label`, so the visible\n\t\t\t\t\t\t// \"Border\" label has to be a `BaseControl` label to\n\t\t\t\t\t\t// receive them.\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// Render it whenever a Shadow control is also present so\n\t\t\t\t\t\t// the two controls stay disambiguated (mirrors the\n\t\t\t\t\t\t// Shadow label's `hasBorderControl` guard below, and\n\t\t\t\t\t\t// trunk's `hideLabelFromVision={ ! hasShadowControl }`),\n\t\t\t\t\t\t// even when inheritance indicators are off (e.g. in\n\t\t\t\t\t\t// Global Styles).\n\t\t\t\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t\t\t\t{ __( 'Border' ) }\n\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t) }\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tdisableCustomColors={ ! areCustomSolidsEnabled }\n\t\t\t\t\t\tenableAlpha\n\t\t\t\t\t\tenableStyle={ showBorderStyle }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t/>\n\t\t\t\t</InheritanceToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<InheritanceToolsPanelItem\n\t\t\t\t\t{ ...inheritanceProps(\n\t\t\t\t\t\tisBorderRadiusPlaceholder,\n\t\t\t\t\t\thasBorderRadius() && inheritedBorderRadius !== undefined\n\t\t\t\t\t) }\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\thasInlineEndToggle\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ defaultControls.radius }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tpresets={ settings?.border?.radiusSizes }\n\t\t\t\t\t\tvalues={ borderRadius }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetBorderRadius( newValue || undefined );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</InheritanceToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasShadowControl && (\n\t\t\t\t<InheritanceToolsPanelItem\n\t\t\t\t\t{ ...inheritanceProps(\n\t\t\t\t\t\tisShadowPlaceholder,\n\t\t\t\t\t\thasShadow() && inheritedShadow !== undefined\n\t\t\t\t\t) }\n\t\t\t\t\tlabel={ __( 'Shadow' ) }\n\t\t\t\t\thasValue={ hasShadow }\n\t\t\t\t\tonDeselect={ resetShadow }\n\t\t\t\t\tisShownByDefault={ defaultControls.shadow }\n\t\t\t\t\t// The shadow toggle renders its own reset affordance (blue\n\t\t\t\t\t// dot for a local override, default reset otherwise) inside\n\t\t\t\t\t// the control, mirroring the color/gradient controls, so the\n\t\t\t\t\t// panel item must not render a second sibling reset dot.\n\t\t\t\t\tshowLocalOverrideActionsInLabel={ false }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t{ hasBorderControl ? (\n\t\t\t\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t\t\t\t{ __( 'Shadow' ) }\n\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t) : null }\n\n\t\t\t\t\t<ShadowPopover\n\t\t\t\t\t\tshadow={ shadow }\n\t\t\t\t\t\tonShadowChange={ setShadowWithInheritedCommit }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\thasLocalValue={ hasShadow() }\n\t\t\t\t\t\thasLocalOverride={ hasShadowLocalOverride }\n\t\t\t\t\t\tonReset={ resetShadow }\n\t\t\t\t\t/>\n\t\t\t\t</InheritanceToolsPanelItem>\n\t\t\t) }\n\t\t</Wrapper>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EACC;AAAA,EACA,iCAAiC;AAAA,EACjC,iCAAiC;AAAA,EACjC,4BAA4B;AAAA,EAC5B;AAAA,OACM;AACP,SAAS,aAAa,eAAe;AACrC,SAAS,UAAU;AACnB,SAAS,4BAA4B;AACrC,OAAO,yBAAyB;AAChC,SAAS,0BAA0B;AACnC,SAAS,sCAAsC;AAC/C,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AACpC,SAAS,eAAe,wBAAwB;AAChD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAuDL,cAwTE,YAxTF;AArDK,SAAS,kBAAmB,UAAW;AAC7C,QAAM,WAAW,OAAO,OAAQ,0BAA2B,QAAS,CAAE;AACtE,SAAO,SAAS,KAAM,OAAQ;AAC/B;AAEO,SAAS,0BAA2B,UAAW;AACrD,QAAM,WAAW;AAAA,IAChB,gBAAgB,yBAA0B,QAAS;AAAA,IACnD,iBAAiB,0BAA2B,QAAS;AAAA,IACrD,gBAAgB,yBAA0B,QAAS;AAAA,IACnD,gBAAgB,yBAA0B,QAAS;AAAA,IACnD,WAAW,oBAAqB,QAAS;AAAA,EAC1C;AAEA,SAAO;AACR;AAEA,SAAS,yBAA0B,UAAW;AAC7C,SAAO,UAAU,QAAQ;AAC1B;AAEA,SAAS,0BAA2B,UAAW;AAC9C,SAAO,UAAU,QAAQ;AAC1B;AAEA,SAAS,yBAA0B,UAAW;AAC7C,SAAO,UA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ACD;AAAA;AAAA;AAAA,EAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -97,6 +97,7 @@ function ColorPanel({
|
|
|
97
97
|
label,
|
|
98
98
|
children,
|
|
99
99
|
contrastWarning,
|
|
100
|
+
additionalElements,
|
|
100
101
|
showInheritanceLabelIndicators = isGlobalStylesInheritanceEnabled()
|
|
101
102
|
}) {
|
|
102
103
|
const {
|
|
@@ -203,9 +204,20 @@ function ColorPanel({
|
|
|
203
204
|
name: "h6",
|
|
204
205
|
label: __("H6"),
|
|
205
206
|
showPanel: showHeadingPanel
|
|
206
|
-
}
|
|
207
|
+
},
|
|
208
|
+
...additionalElements?.map((element) => ({
|
|
209
|
+
...element,
|
|
210
|
+
showPanel: hasSolidColors || hasGradientColors
|
|
211
|
+
})) ?? []
|
|
207
212
|
],
|
|
208
|
-
[
|
|
213
|
+
[
|
|
214
|
+
additionalElements,
|
|
215
|
+
hasGradientColors,
|
|
216
|
+
hasSolidColors,
|
|
217
|
+
showCaptionPanel,
|
|
218
|
+
showButtonPanel,
|
|
219
|
+
showHeadingPanel
|
|
220
|
+
]
|
|
209
221
|
);
|
|
210
222
|
const resetAllFilter = useCallback(
|
|
211
223
|
(previousValue) => {
|