@wordpress/block-editor 15.19.1-next.v.202605131032.0 → 15.21.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 +17 -1
- package/build/components/block-card/index.cjs +51 -41
- package/build/components/block-card/index.cjs.map +3 -3
- package/build/components/block-heading-level-dropdown/heading-level-icon.cjs.map +3 -3
- package/build/components/block-icon/index.cjs +7 -1
- package/build/components/block-icon/index.cjs.map +3 -3
- package/build/components/block-inspector/index.cjs +156 -11
- package/build/components/block-inspector/index.cjs.map +3 -3
- package/build/components/block-inspector/inspector-pre-tabs-slot-fill.cjs +38 -0
- package/build/components/block-inspector/inspector-pre-tabs-slot-fill.cjs.map +7 -0
- package/build/components/block-list/use-block-props/use-focus-handler.cjs +3 -4
- package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +3 -3
- package/build/components/block-list/use-block-props/use-is-hovered.cjs +24 -14
- package/build/components/block-list/use-block-props/use-is-hovered.cjs.map +3 -3
- package/build/components/block-lock/modal.cjs.map +3 -3
- package/build/components/block-patterns-list/index.cjs +13 -2
- package/build/components/block-patterns-list/index.cjs.map +2 -2
- package/build/components/block-popover/index.cjs +13 -3
- package/build/components/block-popover/index.cjs.map +2 -2
- package/build/components/block-toolbar/switch-section-style.cjs.map +3 -3
- package/build/components/block-visibility/modal.cjs.map +3 -3
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +3 -3
- package/build/components/child-layout-control/index.cjs +10 -5
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +7 -4
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs +24 -22
- package/build/components/global-styles/advanced-panel.cjs.map +3 -3
- package/build/components/global-styles/color-panel.cjs +95 -58
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +15 -8
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/index.cjs +3 -0
- package/build/components/global-styles/index.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs +38 -26
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/state-control-badges.cjs +69 -0
- package/build/components/global-styles/state-control-badges.cjs.map +7 -0
- package/build/components/global-styles/state-control.cjs +54 -63
- package/build/components/global-styles/state-control.cjs.map +3 -3
- package/build/components/iframe/use-scale-canvas.cjs +4 -1
- package/build/components/iframe/use-scale-canvas.cjs.map +2 -2
- package/build/components/inserter/hooks/use-patterns-state.cjs +4 -6
- package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
- package/build/components/inserter/index.cjs +1 -0
- package/build/components/inserter/index.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-preview.cjs +27 -18
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/panel.cjs.map +3 -3
- package/build/components/inspector-controls/block-support-tools-panel.cjs +10 -2
- package/build/components/inspector-controls/block-support-tools-panel.cjs.map +2 -2
- package/build/components/inspector-controls/fill.cjs +14 -4
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls/groups.cjs +2 -0
- package/build/components/inspector-controls/groups.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs +13 -8
- package/build/components/inspector-controls-tabs/index.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/settings-tab.cjs +1 -4
- package/build/components/inspector-controls-tabs/settings-tab.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs +9 -0
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +11 -5
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +20 -8
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +2 -1
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/preset-input-control/custom-value-controls.cjs +10 -1
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs.map +3 -3
- package/build/components/provider/use-media-upload-settings.cjs +1 -0
- package/build/components/provider/use-media-upload-settings.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/enter.cjs +9 -2
- package/build/components/rich-text/event-listeners/enter.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/paste-handler.cjs +4 -4
- package/build/components/rich-text/event-listeners/paste-handler.cjs.map +3 -3
- package/build/hooks/background.cjs +13 -3
- package/build/hooks/background.cjs.map +2 -2
- package/build/hooks/block-fields/link/index.cjs.map +3 -3
- package/build/hooks/block-fields/media/index.cjs.map +3 -3
- package/build/hooks/block-style-state.cjs +112 -0
- package/build/hooks/block-style-state.cjs.map +7 -0
- package/build/hooks/border.cjs +13 -3
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/color.cjs +28 -9
- package/build/hooks/color.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +15 -6
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +147 -61
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +263 -56
- package/build/hooks/layout.cjs.map +3 -3
- package/build/hooks/state-utils.cjs +94 -0
- package/build/hooks/state-utils.cjs.map +7 -0
- package/build/hooks/states.cjs +124 -0
- package/build/hooks/states.cjs.map +7 -0
- package/build/hooks/style.cjs +304 -17
- package/build/hooks/style.cjs.map +3 -3
- package/build/hooks/typography.cjs +14 -5
- package/build/hooks/typography.cjs.map +2 -2
- package/build/layouts/constrained.cjs +128 -55
- package/build/layouts/constrained.cjs.map +3 -3
- package/build/layouts/flex.cjs +119 -31
- package/build/layouts/flex.cjs.map +3 -3
- package/build/layouts/grid.cjs +103 -40
- package/build/layouts/grid.cjs.map +3 -3
- package/build/private-apis.cjs +2 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/store/private-actions.cjs +18 -0
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +10 -2
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/private-selectors.cjs +32 -2
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +70 -1
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/utils.cjs +1 -1
- package/build/store/utils.cjs.map +2 -2
- package/build/utils/color-values.cjs +44 -0
- package/build/utils/color-values.cjs.map +7 -0
- package/build-module/components/block-card/index.mjs +52 -45
- package/build-module/components/block-card/index.mjs.map +2 -2
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.mjs +2 -2
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.mjs.map +2 -2
- package/build-module/components/block-icon/index.mjs +8 -2
- package/build-module/components/block-icon/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +166 -13
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-inspector/inspector-pre-tabs-slot-fill.mjs +12 -0
- package/build-module/components/block-inspector/inspector-pre-tabs-slot-fill.mjs.map +7 -0
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +7 -5
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-is-hovered.mjs +28 -15
- package/build-module/components/block-list/use-block-props/use-is-hovered.mjs.map +2 -2
- package/build-module/components/block-lock/modal.mjs +4 -4
- package/build-module/components/block-lock/modal.mjs.map +2 -2
- package/build-module/components/block-patterns-list/index.mjs +14 -4
- package/build-module/components/block-patterns-list/index.mjs.map +2 -2
- package/build-module/components/block-popover/index.mjs +13 -3
- package/build-module/components/block-popover/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs +2 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +2 -2
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +10 -5
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +7 -4
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +25 -27
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +96 -59
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +20 -8
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/index.mjs +2 -0
- package/build-module/components/global-styles/index.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs +39 -28
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/state-control-badges.mjs +48 -0
- package/build-module/components/global-styles/state-control-badges.mjs.map +7 -0
- package/build-module/components/global-styles/state-control.mjs +57 -71
- package/build-module/components/global-styles/state-control.mjs.map +2 -2
- package/build-module/components/iframe/use-scale-canvas.mjs +4 -1
- package/build-module/components/iframe/use-scale-canvas.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-patterns-state.mjs +8 -7
- package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
- package/build-module/components/inserter/index.mjs +1 -0
- package/build-module/components/inserter/index.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-preview.mjs +27 -19
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/panel.mjs +2 -2
- package/build-module/components/inserter/panel.mjs.map +2 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.mjs +10 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.mjs.map +2 -2
- package/build-module/components/inspector-controls/fill.mjs +18 -5
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls/groups.mjs +2 -0
- package/build-module/components/inspector-controls/groups.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs +14 -10
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/settings-tab.mjs +1 -4
- package/build-module/components/inspector-controls-tabs/settings-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +9 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +11 -5
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +20 -9
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +2 -1
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/preset-input-control/custom-value-controls.mjs +10 -2
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +2 -2
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/provider/use-media-upload-settings.mjs +1 -0
- package/build-module/components/provider/use-media-upload-settings.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +9 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
- package/build-module/hooks/background.mjs +18 -3
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-fields/link/index.mjs +3 -3
- package/build-module/hooks/block-fields/link/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/media/index.mjs +3 -3
- package/build-module/hooks/block-fields/media/index.mjs.map +2 -2
- package/build-module/hooks/block-style-state.mjs +79 -0
- package/build-module/hooks/block-style-state.mjs.map +7 -0
- package/build-module/hooks/border.mjs +18 -3
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/color.mjs +33 -9
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +20 -6
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +141 -61
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +270 -58
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/state-utils.mjs +64 -0
- package/build-module/hooks/state-utils.mjs.map +7 -0
- package/build-module/hooks/states.mjs +85 -0
- package/build-module/hooks/states.mjs.map +7 -0
- package/build-module/hooks/style.mjs +309 -18
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +19 -5
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +130 -57
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +123 -35
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +105 -42
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +4 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +16 -0
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +7 -1
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +30 -2
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +69 -1
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/utils.mjs +5 -2
- package/build-module/store/utils.mjs.map +2 -2
- package/build-module/utils/color-values.mjs +19 -0
- package/build-module/utils/color-values.mjs.map +7 -0
- package/build-style/content-rtl.css +18 -3
- package/build-style/content.css +18 -3
- package/build-style/style-rtl.css +14 -17
- package/build-style/style.css +14 -17
- package/package.json +39 -39
- package/src/components/audio-player/index.native.js +7 -3
- package/src/components/block-card/index.js +67 -60
- package/src/components/block-heading-level-dropdown/heading-level-icon.js +2 -2
- package/src/components/block-icon/index.js +5 -2
- package/src/components/block-icon/index.native.js +2 -2
- package/src/components/block-inspector/index.js +153 -7
- package/src/components/block-inspector/inspector-pre-tabs-slot-fill.js +11 -0
- package/src/components/block-list/block-selection-button.native.js +3 -3
- package/src/components/block-list/content.scss +0 -6
- package/src/components/block-list/use-block-props/use-focus-handler.js +8 -6
- package/src/components/block-list/use-block-props/use-is-hovered.js +32 -15
- package/src/components/block-lock/modal.js +4 -4
- package/src/components/block-patterns-list/index.js +14 -5
- package/src/components/block-patterns-list/stories/index.story.jsx +2 -0
- package/src/components/block-patterns-list/style.scss +0 -1
- package/src/components/block-popover/index.js +20 -10
- package/src/components/block-toolbar/switch-section-style.js +2 -2
- package/src/components/block-visibility/modal.js +2 -2
- package/src/components/block-visibility/viewport-visibility-info.js +2 -2
- package/src/components/child-layout-control/index.js +15 -8
- package/src/components/child-layout-control/test/index.js +126 -0
- package/src/components/colors-gradients/control.js +10 -8
- package/src/components/colors-gradients/test/control.js +98 -1
- package/src/components/global-styles/advanced-panel.js +44 -39
- package/src/components/global-styles/color-panel.js +133 -60
- package/src/components/global-styles/dimensions-panel.js +29 -8
- package/src/components/global-styles/index.js +1 -0
- package/src/components/global-styles/shadow-panel-components.js +29 -19
- package/src/components/global-styles/state-control-badges.js +58 -0
- package/src/components/global-styles/state-control.js +28 -36
- package/src/components/global-styles/test/color-panel.js +135 -0
- package/src/components/iframe/use-scale-canvas.js +8 -2
- package/src/components/inserter/hooks/use-patterns-state.js +12 -7
- package/src/components/inserter/index.js +1 -0
- package/src/components/inserter/media-tab/media-preview.js +29 -20
- package/src/components/inserter/panel.js +2 -2
- package/src/components/inserter/style.scss +1 -0
- package/src/components/inserter-button/index.native.js +5 -2
- package/src/components/inspector-controls/block-support-tools-panel.js +10 -2
- package/src/components/inspector-controls/fill.js +18 -5
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/index.js +9 -5
- package/src/components/inspector-controls-tabs/settings-tab.js +1 -7
- package/src/components/inspector-controls-tabs/styles-tab.js +6 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +13 -7
- package/src/components/list-view/block-select-button.js +19 -9
- package/src/components/list-view/block.js +6 -1
- package/src/components/media-replace-flow/style.scss +0 -18
- package/src/components/preset-input-control/custom-value-controls.js +13 -6
- package/src/components/preset-input-control/index.js +2 -2
- package/src/components/provider/use-media-upload-settings.js +1 -0
- package/src/components/rich-text/event-listeners/enter.js +14 -2
- package/src/components/rich-text/event-listeners/paste-handler.js +5 -4
- package/src/components/unsupported-block-details/index.native.js +6 -2
- package/src/components/video-player/index.native.js +2 -2
- package/src/components/warning/index.native.js +2 -2
- package/src/hooks/background.js +59 -37
- package/src/hooks/block-fields/link/index.js +3 -3
- package/src/hooks/block-fields/media/index.js +3 -3
- package/src/hooks/block-style-state.js +127 -0
- package/src/hooks/border.js +25 -6
- package/src/hooks/color.js +40 -18
- package/src/hooks/dimensions.js +32 -11
- package/src/hooks/layout-child.js +179 -62
- package/src/hooks/layout.js +349 -75
- package/src/hooks/layout.scss +6 -0
- package/src/hooks/state-utils.js +158 -0
- package/src/hooks/states.js +109 -0
- package/src/hooks/style.js +456 -19
- package/src/hooks/test/block-style-state.js +270 -0
- package/src/hooks/test/layout.js +185 -0
- package/src/hooks/test/state-utils.js +193 -0
- package/src/hooks/test/style.js +301 -1
- package/src/hooks/typography.js +33 -14
- package/src/layouts/constrained.js +182 -95
- package/src/layouts/flex.js +141 -36
- package/src/layouts/grid.js +122 -32
- package/src/layouts/test/flex.js +57 -20
- package/src/private-apis.js +4 -0
- package/src/store/private-actions.js +32 -0
- package/src/store/private-keys.js +4 -0
- package/src/store/private-selectors.js +61 -2
- package/src/store/reducer.js +105 -1
- package/src/store/test/private-actions.js +26 -0
- package/src/store/test/private-selectors.js +143 -0
- package/src/store/test/reducer.js +363 -0
- package/src/store/utils.js +6 -2
- package/src/utils/color-values.js +28 -0
- package/src/utils/test/color-values.js +78 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/list-view/block.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\thasBlockSupport,\n\tswitchToBlockType,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { useInstanceId, useDebounce } from '@wordpress/compose';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\tuseCallback,\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport useListViewScrollIntoView from './use-list-view-scroll-into-view';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport { useListViewContext } from './context';\nimport {\n\tgetBlockPositionDescription,\n\tgetBlockPropertiesDescription,\n\tfocusListItem,\n} from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { useBlockLock } from '../block-lock';\nimport { useBlockRename, BlockRenameModal } from '../block-rename';\nimport AriaReferencedText from './aria-referenced-text';\nimport { unlock } from '../../lock-unlock';\nimport usePasteStyles from '../use-paste-styles';\nimport { getBlockVisibilityLabel } from '../block-visibility';\n\nfunction ListViewBlock( {\n\tblock: { clientId },\n\tdisplacement,\n\tisAfterDraggedBlocks,\n\tisDragged,\n\tisNesting,\n\tisSelected,\n\tisBranchSelected,\n\tselectBlock,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n\tselectedClientIds,\n\tisSyncedBranch,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst rowRef = useRef( null );\n\tconst settingsRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst [ settingsAnchorRect, setSettingsAnchorRect ] = useState();\n\tconst [ isRenameModalOpen, setIsRenameModalOpen ] = useState( false );\n\tconst { isLocked } = useBlockLock( clientId );\n\n\tconst isFirstSelectedBlock =\n\t\tisSelected && selectedClientIds[ 0 ] === clientId;\n\tconst isLastSelectedBlock =\n\t\tisSelected &&\n\t\tselectedClientIds[ selectedClientIds.length - 1 ] === clientId;\n\n\tconst {\n\t\ttoggleBlockHighlight,\n\t\tduplicateBlocks,\n\t\tmultiSelect,\n\t\treplaceBlocks,\n\t\tremoveBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tshowViewportModal,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tconst debouncedToggleBlockHighlight = useDebounce(\n\t\ttoggleBlockHighlight,\n\t\t50\n\t);\n\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetSelectedBlockClientIds,\n\t\tgetPreviousBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockOrder,\n\t\tgetBlockParents,\n\t\tgetBlockEditingMode,\n\t\tgetBlocksByClientId,\n\t\tcanEditBlock,\n\t\tcanMoveBlock,\n\t\tcanRemoveBlocks,\n\t\tisGroupable,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\tconst pasteStyles = usePasteStyles();\n\n\tconst { block, blockName, allowRightClickOverrides } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getBlockName, getSettings } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tblock: getBlock( clientId ),\n\t\t\t\tblockName: getBlockName( clientId ),\n\t\t\t\tallowRightClickOverrides:\n\t\t\t\t\tgetSettings().allowRightClickOverrides,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { canRename } = useBlockRename( blockName );\n\n\tconst showBlockActions =\n\t\t// When a block hides its toolbar it also hides the block settings menu,\n\t\t// since that menu is part of the toolbar in the editor canvas.\n\t\t// List View respects this by also hiding the block settings menu.\n\t\thasBlockSupport( blockName, '__experimentalToolbar', true );\n\tconst instanceId = useInstanceId( ListViewBlock );\n\tconst descriptionId = `list-view-block-select-button__description-${ instanceId }`;\n\n\tconst {\n\t\texpand,\n\t\tcollapse,\n\t\tcollapseAll,\n\t\tBlockSettingsMenu,\n\t\tlistViewInstanceId,\n\t\texpandedState,\n\t\tsetInsertedBlock,\n\t\ttreeGridElementRef,\n\t\trootClientId,\n\t} = useListViewContext();\n\tconst isMatch = useShortcutEventMatch();\n\n\t// Determine which blocks to update:\n\t// If the current (focused) block is part of the block selection, use the whole selection.\n\t// If the focused block is not part of the block selection, only update the focused block.\n\tfunction getBlocksToUpdate() {\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst isUpdatingSelectedBlocks =\n\t\t\tselectedBlockClientIds.includes( clientId );\n\t\tconst firstBlockClientId = isUpdatingSelectedBlocks\n\t\t\t? selectedBlockClientIds[ 0 ]\n\t\t\t: clientId;\n\t\tconst firstBlockRootClientId =\n\t\t\tgetBlockRootClientId( firstBlockClientId );\n\n\t\tconst blocksToUpdate = isUpdatingSelectedBlocks\n\t\t\t? selectedBlockClientIds\n\t\t\t: [ clientId ];\n\n\t\treturn {\n\t\t\tblocksToUpdate,\n\t\t\tfirstBlockClientId,\n\t\t\tfirstBlockRootClientId,\n\t\t\tselectedBlockClientIds,\n\t\t};\n\t}\n\n\t/**\n\t * @param {KeyboardEvent} event\n\t */\n\tasync function onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Do not handle events if it comes from modals;\n\t\t// retain the default behavior for these keys.\n\t\tif ( event.target.closest( '[role=dialog]' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isDeleteKey = [ BACKSPACE, DELETE ].includes( event.keyCode );\n\n\t\t// If multiple blocks are selected, deselect all blocks when the user\n\t\t// presses the escape key.\n\t\tif (\n\t\t\tisMatch( 'core/block-editor/unselect', event ) &&\n\t\t\tselectedClientIds.length > 0\n\t\t) {\n\t\t\tevent.stopPropagation();\n\t\t\tevent.preventDefault();\n\t\t\tselectBlock( event, undefined );\n\t\t} else if (\n\t\t\tisDeleteKey ||\n\t\t\tisMatch( 'core/block-editor/remove', event )\n\t\t) {\n\t\t\tconst {\n\t\t\t\tblocksToUpdate: blocksToDelete,\n\t\t\t\tfirstBlockClientId,\n\t\t\t\tfirstBlockRootClientId,\n\t\t\t\tselectedBlockClientIds,\n\t\t\t} = getBlocksToUpdate();\n\n\t\t\t// Don't update the selection if the blocks cannot be deleted.\n\t\t\tif ( ! canRemoveBlocks( blocksToDelete ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet blockToFocus =\n\t\t\t\tgetPreviousBlockClientId( firstBlockClientId ) ??\n\t\t\t\t// If the previous block is not found (when the first block is deleted),\n\t\t\t\t// fallback to focus the parent block.\n\t\t\t\tfirstBlockRootClientId;\n\n\t\t\tremoveBlocks( blocksToDelete, false );\n\n\t\t\t// Update the selection if the original selection has been removed.\n\t\t\tconst shouldUpdateSelection =\n\t\t\t\tselectedBlockClientIds.length > 0 &&\n\t\t\t\tgetSelectedBlockClientIds().length === 0;\n\n\t\t\t// If there's no previous block nor parent block, focus the first block.\n\t\t\tif ( ! blockToFocus ) {\n\t\t\t\tblockToFocus = getBlockOrder()[ 0 ];\n\t\t\t}\n\n\t\t\tupdateFocusAndSelection( blockToFocus, shouldUpdateSelection );\n\t\t} else if ( isMatch( 'core/block-editor/paste-styles', event ) ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tconst blocks = getBlocksByClientId( blocksToUpdate );\n\n\t\t\tpasteStyles( blocks );\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { blocksToUpdate, firstBlockRootClientId } =\n\t\t\t\tgetBlocksToUpdate();\n\n\t\t\tconst canDuplicate = getBlocksByClientId( blocksToUpdate ).every(\n\t\t\t\t( blockToUpdate ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t!! blockToUpdate &&\n\t\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\t\tblockToUpdate.name,\n\t\t\t\t\t\t\t'multiple',\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tblockToUpdate.name,\n\t\t\t\t\t\t\tfirstBlockRootClientId\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( canDuplicate ) {\n\t\t\t\tconst updatedBlocks = await duplicateBlocks(\n\t\t\t\t\tblocksToUpdate,\n\t\t\t\t\tfalse\n\t\t\t\t);\n\n\t\t\t\tif ( updatedBlocks?.length ) {\n\t\t\t\t\t// If blocks have been duplicated, focus the first duplicated block.\n\t\t\t\t\tupdateFocusAndSelection( updatedBlocks[ 0 ], false );\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tawait insertBeforeBlock( blocksToUpdate[ 0 ] );\n\t\t\tconst newlySelectedBlocks = getSelectedBlockClientIds();\n\n\t\t\t// Focus the first block of the newly inserted blocks, to keep focus within the list view.\n\t\t\tupdateFocusAndSelection( newlySelectedBlocks[ 0 ], false );\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tawait insertAfterBlock( blocksToUpdate.at( -1 ) );\n\t\t\tconst newlySelectedBlocks = getSelectedBlockClientIds();\n\n\t\t\t// Focus the first block of the newly inserted blocks, to keep focus within the list view.\n\t\t\tupdateFocusAndSelection( newlySelectedBlocks[ 0 ], false );\n\t\t} else if ( isMatch( 'core/block-editor/select-all', event ) ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { firstBlockRootClientId, selectedBlockClientIds } =\n\t\t\t\tgetBlocksToUpdate();\n\t\t\tconst blockClientIds = getBlockOrder( firstBlockRootClientId );\n\t\t\tif ( ! blockClientIds.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If we have selected all sibling nested blocks, try selecting up a level.\n\t\t\t// This is a similar implementation to that used by `useSelectAll`.\n\t\t\t// `isShallowEqual` is used for the list view instead of a length check,\n\t\t\t// as the array of siblings of the currently focused block may be a different\n\t\t\t// set of blocks from the current block selection if the user is focused\n\t\t\t// on a different part of the list view from the block selection.\n\t\t\tif ( isShallowEqual( selectedBlockClientIds, blockClientIds ) ) {\n\t\t\t\t// Only select up a level if the first block is not the root block.\n\t\t\t\t// This ensures that the block selection can't break out of the root block\n\t\t\t\t// used by the list view, if the list view is only showing a partial hierarchy.\n\t\t\t\tif (\n\t\t\t\t\tfirstBlockRootClientId &&\n\t\t\t\t\tfirstBlockRootClientId !== rootClientId\n\t\t\t\t) {\n\t\t\t\t\tupdateFocusAndSelection( firstBlockRootClientId, true );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Select all while passing `null` to skip focusing to the editor canvas,\n\t\t\t// and retain focus within the list view.\n\t\t\tmultiSelect(\n\t\t\t\tblockClientIds[ 0 ],\n\t\t\t\tblockClientIds[ blockClientIds.length - 1 ],\n\t\t\t\tnull\n\t\t\t);\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\tevent.preventDefault();\n\t\t\tconst { firstBlockClientId } = getBlocksToUpdate();\n\t\t\tconst blockParents = getBlockParents( firstBlockClientId, false );\n\t\t\t// Collapse all blocks.\n\t\t\tcollapseAll();\n\t\t\t// Expand all parents of the current block.\n\t\t\texpand( blockParents );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tif ( blocksToUpdate.length > 1 && isGroupable( blocksToUpdate ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( blocksToUpdate );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( blocksToUpdate, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t\tconst newlySelectedBlocks = getSelectedBlockClientIds();\n\t\t\t\t// Focus the first block of the newly inserted blocks, to keep focus within the list view.\n\t\t\t\tupdateFocusAndSelection( newlySelectedBlocks[ 0 ], false );\n\t\t\t}\n\t\t} else if (\n\t\t\tisMatch( 'core/block-editor/toggle-block-visibility', event )\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tconst blocks = getBlocksByClientId( blocksToUpdate );\n\t\t\tconst supportsBlockVisibility = blocks.every( ( _block ) =>\n\t\t\t\thasBlockSupport( _block.name, 'visibility', true )\n\t\t\t);\n\n\t\t\tif ( ! supportsBlockVisibility ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Don't allow visibility toggle for blocks that\n\t\t\t// are not in the default editing mode.\n\t\t\tif (\n\t\t\t\tblocksToUpdate.some(\n\t\t\t\t\t( id ) => getBlockEditingMode( id ) !== 'default'\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Open the visibility breakpoints modal.\n\t\t\tshowViewportModal( blocksToUpdate );\n\t\t} else if ( isMatch( 'core/block-editor/rename', event ) ) {\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tconst isContentOnly =\n\t\t\t\tgetBlockEditingMode( blocksToUpdate[ 0 ] ) === 'contentOnly';\n\t\t\tif ( blocksToUpdate.length === 1 && canRename && ! isContentOnly ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsRenameModalOpen( true );\n\t\t\t}\n\t\t}\n\t}\n\n\tconst onMouseEnter = useCallback( () => {\n\t\tsetIsHovered( true );\n\t\tdebouncedToggleBlockHighlight( clientId, true );\n\t}, [ clientId, setIsHovered, debouncedToggleBlockHighlight ] );\n\tconst onMouseLeave = useCallback( () => {\n\t\tsetIsHovered( false );\n\t\tdebouncedToggleBlockHighlight( clientId, false );\n\t}, [ clientId, setIsHovered, debouncedToggleBlockHighlight ] );\n\n\tconst selectEditorBlock = useCallback(\n\t\t( event ) => {\n\t\t\tselectBlock( event, clientId );\n\t\t\tevent.preventDefault();\n\t\t},\n\t\t[ clientId, selectBlock ]\n\t);\n\n\tconst updateFocusAndSelection = useCallback(\n\t\t( focusClientId, shouldSelectBlock ) => {\n\t\t\tif ( shouldSelectBlock ) {\n\t\t\t\tselectBlock( undefined, focusClientId, null, null );\n\t\t\t}\n\n\t\t\tfocusListItem( focusClientId, treeGridElementRef?.current );\n\t\t},\n\t\t[ selectBlock, treeGridElementRef ]\n\t);\n\n\tconst toggleExpanded = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent shift+click from opening link in a new window when toggling.\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\tif ( isExpanded === true ) {\n\t\t\t\tcollapse( clientId );\n\t\t\t} else if ( isExpanded === false ) {\n\t\t\t\texpand( clientId );\n\t\t\t}\n\t\t},\n\t\t[ clientId, expand, collapse, isExpanded ]\n\t);\n\n\t// Allow right-clicking an item in the List View to open up the block settings dropdown.\n\tconst onContextMenu = useCallback(\n\t\t( event ) => {\n\t\t\tconst { ownerDocument } = settingsRef?.current || {};\n\t\t\tif ( ! ownerDocument || ! ownerDocument.hasFocus() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( showBlockActions && allowRightClickOverrides ) {\n\t\t\t\tsettingsRef.current?.click();\n\t\t\t\t// Ensure the position of the settings dropdown is at the cursor.\n\t\t\t\tsetSettingsAnchorRect(\n\t\t\t\t\tnew window.DOMRect( event.clientX, event.clientY, 0, 0 )\n\t\t\t\t);\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\t[ allowRightClickOverrides, settingsRef, showBlockActions ]\n\t);\n\n\tconst onMouseDown = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent right-click from focusing the block,\n\t\t\t// because focus will be handled when opening the block settings dropdown.\n\t\t\tif ( allowRightClickOverrides && event.button === 2 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\t[ allowRightClickOverrides ]\n\t);\n\n\tconst settingsPopoverAnchor = useMemo( () => {\n\t\tconst { ownerDocument } = rowRef?.current || {};\n\n\t\t// If no custom position is set, the settings dropdown will be anchored to the\n\t\t// DropdownMenu toggle button.\n\t\tif ( ! settingsAnchorRect || ! ownerDocument ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Position the settings dropdown at the cursor when right-clicking a block.\n\t\treturn {\n\t\t\townerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\treturn settingsAnchorRect;\n\t\t\t},\n\t\t};\n\t}, [ settingsAnchorRect ] );\n\n\tconst clearSettingsAnchorRect = useCallback( () => {\n\t\t// Clear the custom position for the settings dropdown so that it is restored back\n\t\t// to being anchored to the DropdownMenu toggle button.\n\t\tsetSettingsAnchorRect( undefined );\n\t}, [ setSettingsAnchorRect ] );\n\n\t// Pass in a ref to the row, so that it can be scrolled\n\t// into view when selected. For long lists, the placeholder for the\n\t// selected block is also observed, within ListViewLeafPlaceholder.\n\tuseListViewScrollIntoView( {\n\t\tisSelected,\n\t\trowItemRef: rowRef,\n\t\tselectedClientIds,\n\t} );\n\n\t// When switching between rendering modes (such as template preview and content only),\n\t// it is possible for a block to temporarily be unavailable. In this case, we should not\n\t// render the leaf, to avoid errors further down the tree.\n\tif ( ! block ) {\n\t\treturn null;\n\t}\n\n\tconst blockPositionDescription = getBlockPositionDescription(\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel\n\t);\n\n\tconst blockPropertiesDescription = getBlockPropertiesDescription(\n\t\tblockInformation,\n\t\tisLocked\n\t);\n\n\t// Determine label based on where block is hidden (not when/current viewport)\n\tconst blockVisibilityDescription = getBlockVisibilityLabel(\n\t\tblock?.attributes?.metadata?.blockVisibility\n\t);\n\n\tconst hasSiblings = siblingBlockCount > 0;\n\tconst hasRenderedMovers = showBlockMovers && hasSiblings;\n\tconst moverCellClassName = clsx(\n\t\t'block-editor-list-view-block__mover-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\tconst listViewBlockSettingsClassName = clsx(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isFirstSelectedBlock }\n\t);\n\n\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 2;\n\t} else if ( ! showBlockActions ) {\n\t\tcolSpan = 3;\n\t}\n\n\tconst classes = clsx( {\n\t\t'is-selected': isSelected,\n\t\t'is-first-selected': isFirstSelectedBlock,\n\t\t'is-last-selected': isLastSelectedBlock,\n\t\t'is-branch-selected': isBranchSelected,\n\t\t'is-synced-branch': isSyncedBranch,\n\t\t'is-dragging': isDragged,\n\t\t'has-single-cell': ! showBlockActions,\n\t\t'is-synced': blockInformation?.isSynced,\n\t\t'is-draggable': canMoveBlock,\n\t\t'is-displacement-normal': displacement === 'normal',\n\t\t'is-displacement-up': displacement === 'up',\n\t\t'is-displacement-down': displacement === 'down',\n\t\t'is-after-dragged-blocks': isAfterDraggedBlocks,\n\t\t'is-nesting': isNesting,\n\t} );\n\n\t// Only include all selected blocks if the currently clicked on block\n\t// is one of the selected blocks. This ensures that if a user attempts\n\t// to alter a block that isn't part of the selection, they're still able\n\t// to do so.\n\tconst dropdownClientIds = selectedClientIds.includes( clientId )\n\t\t? selectedClientIds\n\t\t: [ clientId ];\n\n\t// Detect if there is a block in the canvas currently being edited and multi-selection is not happening.\n\tconst currentlyEditingBlockInCanvas =\n\t\tisSelected && selectedClientIds.length === 1;\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\n\t\t\tisDragged={ isDragged }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t\tid={ `list-view-${ listViewInstanceId }-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tdata-expanded={ canEditBlock ? isExpanded : undefined }\n\t\t\tref={ rowRef }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-block__contents-cell\"\n\t\t\t\tcolSpan={ colSpan }\n\t\t\t\tref={ cellRef }\n\t\t\t\taria-selected={ !! isSelected }\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-block__contents-container\">\n\t\t\t\t\t\t<ListViewBlockContents\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={ selectEditorBlock }\n\t\t\t\t\t\t\tonContextMenu={ onContextMenu }\n\t\t\t\t\t\t\tonMouseDown={ onMouseDown }\n\t\t\t\t\t\t\tonToggleExpanded={ toggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\ttabIndex={\n\t\t\t\t\t\t\t\tcurrentlyEditingBlockInCanvas ? 0 : tabIndex\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tisExpanded={ canEditBlock ? isExpanded : undefined }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tariaDescribedBy={ descriptionId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<AriaReferencedText id={ descriptionId }>\n\t\t\t\t\t\t\t{ [\n\t\t\t\t\t\t\t\tblockPositionDescription,\n\t\t\t\t\t\t\t\tblockPropertiesDescription,\n\t\t\t\t\t\t\t\tblockVisibilityDescription,\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t.filter( Boolean )\n\t\t\t\t\t\t\t\t.join( ' ' ) }\n\t\t\t\t\t\t</AriaReferencedText>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t\t{ hasRenderedMovers && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ moverCellClassName }\n\t\t\t\t\t\twithoutGridItem\n\t\t\t\t\t>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ showBlockActions && BlockSettingsMenu && (\n\t\t\t\t<TreeGridCell\n\t\t\t\t\tclassName={ listViewBlockSettingsClassName }\n\t\t\t\t\taria-selected={ !! isSelected }\n\t\t\t\t\tref={ settingsRef }\n\t\t\t\t>\n\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t<BlockSettingsMenu\n\t\t\t\t\t\t\tclientIds={ dropdownClientIds }\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'Options' ) }\n\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\tanchor: settingsPopoverAnchor, // Used to position the settings at the cursor on right-click.\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\tclassName: 'block-editor-list-view-block__menu',\n\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\tonClick: clearSettingsAnchorRect,\n\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t\tsize: 'small',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\texpand={ expand }\n\t\t\t\t\t\t\texpandedState={ expandedState }\n\t\t\t\t\t\t\tsetInsertedBlock={ setInsertedBlock }\n\t\t\t\t\t\t\t__experimentalSelectBlock={\n\t\t\t\t\t\t\t\tupdateFocusAndSelection\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisContentOnlyListView={\n\t\t\t\t\t\t\t\t!! rootClientId &&\n\t\t\t\t\t\t\t\tgetBlockEditingMode( rootClientId ) ===\n\t\t\t\t\t\t\t\t\t'contentOnly'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TreeGridCell>\n\t\t\t) }\n\t\t\t{ isRenameModalOpen && (\n\t\t\t\t<BlockRenameModal\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tonClose={ () => setIsRenameModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n\nexport default memo( ListViewBlock );\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAIO;AACP,wBAGO;AACP,qBAA2C;AAC3C,mBAA6B;AAC7B,qBAMO;AACP,kBAAuC;AACvC,kBAAmB;AACnB,sBAAkC;AAClC,8BAA+B;AAC/B,gCAAyE;AACzE,kBAAsB;AAKtB,kBAAyB;AACzB,4CAAsC;AACtC,oBAGO;AACP,4BAAkC;AAClC,qBAAmC;AACnC,mBAIO;AACP,mBAA0C;AAC1C,2CAAuC;AACvC,wBAA6B;AAC7B,0BAAiD;AACjD,kCAA+B;AAC/B,yBAAuB;AACvB,8BAA2B;AAC3B,8BAAwC;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\thasBlockSupport,\n\tswitchToBlockType,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { useInstanceId, useDebounce } from '@wordpress/compose';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\tuseCallback,\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport useListViewScrollIntoView from './use-list-view-scroll-into-view';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport { useListViewContext } from './context';\nimport {\n\tgetBlockPositionDescription,\n\tgetBlockPropertiesDescription,\n\tfocusListItem,\n} from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { useBlockLock } from '../block-lock';\nimport { useBlockRename, BlockRenameModal } from '../block-rename';\nimport AriaReferencedText from './aria-referenced-text';\nimport { unlock } from '../../lock-unlock';\nimport usePasteStyles from '../use-paste-styles';\nimport { getBlockVisibilityLabel } from '../block-visibility';\n\nfunction ListViewBlock( {\n\tblock: { clientId },\n\tdisplacement,\n\tisAfterDraggedBlocks,\n\tisDragged,\n\tisNesting,\n\tisSelected,\n\tisBranchSelected,\n\tselectBlock,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n\tselectedClientIds,\n\tisSyncedBranch,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst rowRef = useRef( null );\n\tconst settingsRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst [ settingsAnchorRect, setSettingsAnchorRect ] = useState();\n\tconst [ isRenameModalOpen, setIsRenameModalOpen ] = useState( false );\n\tconst { isLocked } = useBlockLock( clientId );\n\n\tconst isFirstSelectedBlock =\n\t\tisSelected && selectedClientIds[ 0 ] === clientId;\n\tconst isLastSelectedBlock =\n\t\tisSelected &&\n\t\tselectedClientIds[ selectedClientIds.length - 1 ] === clientId;\n\n\tconst {\n\t\ttoggleBlockHighlight,\n\t\tduplicateBlocks,\n\t\tmultiSelect,\n\t\treplaceBlocks,\n\t\tremoveBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tshowViewportModal,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tconst debouncedToggleBlockHighlight = useDebounce(\n\t\ttoggleBlockHighlight,\n\t\t50\n\t);\n\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetSelectedBlockClientIds,\n\t\tgetPreviousBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockOrder,\n\t\tgetBlockParents,\n\t\tgetBlockEditingMode,\n\t\tgetBlocksByClientId,\n\t\tcanEditBlock,\n\t\tcanMoveBlock,\n\t\tcanRemoveBlocks,\n\t\tisGroupable,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\tconst pasteStyles = usePasteStyles();\n\n\tconst { block, blockName, allowRightClickOverrides } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getBlockName, getSettings } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tblock: getBlock( clientId ),\n\t\t\t\tblockName: getBlockName( clientId ),\n\t\t\t\tallowRightClickOverrides:\n\t\t\t\t\tgetSettings().allowRightClickOverrides,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { canRename } = useBlockRename( blockName );\n\n\tconst showBlockActions =\n\t\t// When a block hides its toolbar it also hides the block settings menu,\n\t\t// since that menu is part of the toolbar in the editor canvas.\n\t\t// List View respects this by also hiding the block settings menu.\n\t\thasBlockSupport( blockName, '__experimentalToolbar', true );\n\tconst instanceId = useInstanceId( ListViewBlock );\n\tconst descriptionId = `list-view-block-select-button__description-${ instanceId }`;\n\n\tconst {\n\t\texpand,\n\t\tcollapse,\n\t\tcollapseAll,\n\t\tBlockSettingsMenu,\n\t\tlistViewInstanceId,\n\t\texpandedState,\n\t\tsetInsertedBlock,\n\t\ttreeGridElementRef,\n\t\trootClientId,\n\t} = useListViewContext();\n\tconst isMatch = useShortcutEventMatch();\n\n\t// Determine which blocks to update:\n\t// If the current (focused) block is part of the block selection, use the whole selection.\n\t// If the focused block is not part of the block selection, only update the focused block.\n\tfunction getBlocksToUpdate() {\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst isUpdatingSelectedBlocks =\n\t\t\tselectedBlockClientIds.includes( clientId );\n\t\tconst firstBlockClientId = isUpdatingSelectedBlocks\n\t\t\t? selectedBlockClientIds[ 0 ]\n\t\t\t: clientId;\n\t\tconst firstBlockRootClientId =\n\t\t\tgetBlockRootClientId( firstBlockClientId );\n\n\t\tconst blocksToUpdate = isUpdatingSelectedBlocks\n\t\t\t? selectedBlockClientIds\n\t\t\t: [ clientId ];\n\n\t\treturn {\n\t\t\tblocksToUpdate,\n\t\t\tfirstBlockClientId,\n\t\t\tfirstBlockRootClientId,\n\t\t\tselectedBlockClientIds,\n\t\t};\n\t}\n\n\t/**\n\t * @param {KeyboardEvent} event\n\t */\n\tasync function onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Do not handle events if it comes from modals;\n\t\t// retain the default behavior for these keys.\n\t\tif ( event.target.closest( '[role=dialog]' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isDeleteKey = [ BACKSPACE, DELETE ].includes( event.keyCode );\n\n\t\t// If multiple blocks are selected, deselect all blocks when the user\n\t\t// presses the escape key.\n\t\tif (\n\t\t\tisMatch( 'core/block-editor/unselect', event ) &&\n\t\t\tselectedClientIds.length > 0\n\t\t) {\n\t\t\tevent.stopPropagation();\n\t\t\tevent.preventDefault();\n\t\t\tselectBlock( event, undefined );\n\t\t} else if (\n\t\t\tisDeleteKey ||\n\t\t\tisMatch( 'core/block-editor/remove', event )\n\t\t) {\n\t\t\tconst {\n\t\t\t\tblocksToUpdate: blocksToDelete,\n\t\t\t\tfirstBlockClientId,\n\t\t\t\tfirstBlockRootClientId,\n\t\t\t\tselectedBlockClientIds,\n\t\t\t} = getBlocksToUpdate();\n\n\t\t\t// Don't update the selection if the blocks cannot be deleted.\n\t\t\tif ( ! canRemoveBlocks( blocksToDelete ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet blockToFocus =\n\t\t\t\tgetPreviousBlockClientId( firstBlockClientId ) ??\n\t\t\t\t// If the previous block is not found (when the first block is deleted),\n\t\t\t\t// fallback to focus the parent block.\n\t\t\t\tfirstBlockRootClientId;\n\n\t\t\tremoveBlocks( blocksToDelete, false );\n\n\t\t\t// Update the selection if the original selection has been removed.\n\t\t\tconst shouldUpdateSelection =\n\t\t\t\tselectedBlockClientIds.length > 0 &&\n\t\t\t\tgetSelectedBlockClientIds().length === 0;\n\n\t\t\t// If there's no previous block nor parent block, focus the first block.\n\t\t\tif ( ! blockToFocus ) {\n\t\t\t\tblockToFocus = getBlockOrder()[ 0 ];\n\t\t\t}\n\n\t\t\tupdateFocusAndSelection( blockToFocus, shouldUpdateSelection );\n\t\t} else if ( isMatch( 'core/block-editor/paste-styles', event ) ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tconst blocks = getBlocksByClientId( blocksToUpdate );\n\n\t\t\tpasteStyles( blocks );\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { blocksToUpdate, firstBlockRootClientId } =\n\t\t\t\tgetBlocksToUpdate();\n\n\t\t\tconst canDuplicate = getBlocksByClientId( blocksToUpdate ).every(\n\t\t\t\t( blockToUpdate ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t!! blockToUpdate &&\n\t\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\t\tblockToUpdate.name,\n\t\t\t\t\t\t\t'multiple',\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tblockToUpdate.name,\n\t\t\t\t\t\t\tfirstBlockRootClientId\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( canDuplicate ) {\n\t\t\t\tconst updatedBlocks = await duplicateBlocks(\n\t\t\t\t\tblocksToUpdate,\n\t\t\t\t\tfalse\n\t\t\t\t);\n\n\t\t\t\tif ( updatedBlocks?.length ) {\n\t\t\t\t\t// If blocks have been duplicated, focus the first duplicated block.\n\t\t\t\t\tupdateFocusAndSelection( updatedBlocks[ 0 ], false );\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tawait insertBeforeBlock( blocksToUpdate[ 0 ] );\n\t\t\tconst newlySelectedBlocks = getSelectedBlockClientIds();\n\n\t\t\t// Focus the first block of the newly inserted blocks, to keep focus within the list view.\n\t\t\tupdateFocusAndSelection( newlySelectedBlocks[ 0 ], false );\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tawait insertAfterBlock( blocksToUpdate.at( -1 ) );\n\t\t\tconst newlySelectedBlocks = getSelectedBlockClientIds();\n\n\t\t\t// Focus the first block of the newly inserted blocks, to keep focus within the list view.\n\t\t\tupdateFocusAndSelection( newlySelectedBlocks[ 0 ], false );\n\t\t} else if ( isMatch( 'core/block-editor/select-all', event ) ) {\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { firstBlockRootClientId, selectedBlockClientIds } =\n\t\t\t\tgetBlocksToUpdate();\n\t\t\tconst blockClientIds = getBlockOrder( firstBlockRootClientId );\n\t\t\tif ( ! blockClientIds.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If we have selected all sibling nested blocks, try selecting up a level.\n\t\t\t// This is a similar implementation to that used by `useSelectAll`.\n\t\t\t// `isShallowEqual` is used for the list view instead of a length check,\n\t\t\t// as the array of siblings of the currently focused block may be a different\n\t\t\t// set of blocks from the current block selection if the user is focused\n\t\t\t// on a different part of the list view from the block selection.\n\t\t\tif ( isShallowEqual( selectedBlockClientIds, blockClientIds ) ) {\n\t\t\t\t// Only select up a level if the first block is not the root block.\n\t\t\t\t// This ensures that the block selection can't break out of the root block\n\t\t\t\t// used by the list view, if the list view is only showing a partial hierarchy.\n\t\t\t\tif (\n\t\t\t\t\tfirstBlockRootClientId &&\n\t\t\t\t\tfirstBlockRootClientId !== rootClientId\n\t\t\t\t) {\n\t\t\t\t\tupdateFocusAndSelection( firstBlockRootClientId, true );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Select all while passing `null` to skip focusing to the editor canvas,\n\t\t\t// and retain focus within the list view.\n\t\t\tmultiSelect(\n\t\t\t\tblockClientIds[ 0 ],\n\t\t\t\tblockClientIds[ blockClientIds.length - 1 ],\n\t\t\t\tnull\n\t\t\t);\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\tevent.preventDefault();\n\t\t\tconst { firstBlockClientId } = getBlocksToUpdate();\n\t\t\tconst blockParents = getBlockParents( firstBlockClientId, false );\n\t\t\t// Collapse all blocks.\n\t\t\tcollapseAll();\n\t\t\t// Expand all parents of the current block.\n\t\t\texpand( blockParents );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tif ( blocksToUpdate.length > 1 && isGroupable( blocksToUpdate ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( blocksToUpdate );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( blocksToUpdate, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t\tconst newlySelectedBlocks = getSelectedBlockClientIds();\n\t\t\t\t// Focus the first block of the newly inserted blocks, to keep focus within the list view.\n\t\t\t\tupdateFocusAndSelection( newlySelectedBlocks[ 0 ], false );\n\t\t\t}\n\t\t} else if (\n\t\t\tisMatch( 'core/block-editor/toggle-block-visibility', event )\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tconst blocks = getBlocksByClientId( blocksToUpdate );\n\t\t\tconst supportsBlockVisibility = blocks.every( ( _block ) =>\n\t\t\t\thasBlockSupport( _block.name, 'visibility', true )\n\t\t\t);\n\n\t\t\tif ( ! supportsBlockVisibility ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Don't allow visibility toggle for blocks that\n\t\t\t// are not in the default editing mode.\n\t\t\tif (\n\t\t\t\tblocksToUpdate.some(\n\t\t\t\t\t( id ) => getBlockEditingMode( id ) !== 'default'\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Open the visibility breakpoints modal.\n\t\t\tshowViewportModal( blocksToUpdate );\n\t\t} else if ( isMatch( 'core/block-editor/rename', event ) ) {\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tconst isContentOnly =\n\t\t\t\tgetBlockEditingMode( blocksToUpdate[ 0 ] ) === 'contentOnly';\n\t\t\tif ( blocksToUpdate.length === 1 && canRename && ! isContentOnly ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsRenameModalOpen( true );\n\t\t\t}\n\t\t}\n\t}\n\n\tconst onMouseEnter = useCallback( () => {\n\t\tsetIsHovered( true );\n\t\tdebouncedToggleBlockHighlight( clientId, true );\n\t}, [ clientId, setIsHovered, debouncedToggleBlockHighlight ] );\n\tconst onMouseLeave = useCallback( () => {\n\t\tsetIsHovered( false );\n\t\tdebouncedToggleBlockHighlight( clientId, false );\n\t}, [ clientId, setIsHovered, debouncedToggleBlockHighlight ] );\n\n\tconst selectEditorBlock = useCallback(\n\t\t( event ) => {\n\t\t\t// For keyboard activation (Enter/Space on a link), transfer focus\n\t\t\t// to the canvas with the caret at the end of the block.\n\t\t\t// For mouse clicks, keep focus in the list view so that subsequent\n\t\t\t// keyboard operations (arrow navigation, copy/paste) still work.\n\t\t\tconst isKeyboardActivation = event?.detail === 0;\n\t\t\tselectBlock( event, clientId, isKeyboardActivation ? -1 : null );\n\t\t\tevent.preventDefault();\n\t\t},\n\t\t[ clientId, selectBlock ]\n\t);\n\n\tconst updateFocusAndSelection = useCallback(\n\t\t( focusClientId, shouldSelectBlock ) => {\n\t\t\tif ( shouldSelectBlock ) {\n\t\t\t\tselectBlock( undefined, focusClientId, null, null );\n\t\t\t}\n\n\t\t\tfocusListItem( focusClientId, treeGridElementRef?.current );\n\t\t},\n\t\t[ selectBlock, treeGridElementRef ]\n\t);\n\n\tconst toggleExpanded = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent shift+click from opening link in a new window when toggling.\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\tif ( isExpanded === true ) {\n\t\t\t\tcollapse( clientId );\n\t\t\t} else if ( isExpanded === false ) {\n\t\t\t\texpand( clientId );\n\t\t\t}\n\t\t},\n\t\t[ clientId, expand, collapse, isExpanded ]\n\t);\n\n\t// Allow right-clicking an item in the List View to open up the block settings dropdown.\n\tconst onContextMenu = useCallback(\n\t\t( event ) => {\n\t\t\tconst { ownerDocument } = settingsRef?.current || {};\n\t\t\tif ( ! ownerDocument || ! ownerDocument.hasFocus() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( showBlockActions && allowRightClickOverrides ) {\n\t\t\t\tsettingsRef.current?.click();\n\t\t\t\t// Ensure the position of the settings dropdown is at the cursor.\n\t\t\t\tsetSettingsAnchorRect(\n\t\t\t\t\tnew window.DOMRect( event.clientX, event.clientY, 0, 0 )\n\t\t\t\t);\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\t[ allowRightClickOverrides, settingsRef, showBlockActions ]\n\t);\n\n\tconst onMouseDown = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent right-click from focusing the block,\n\t\t\t// because focus will be handled when opening the block settings dropdown.\n\t\t\tif ( allowRightClickOverrides && event.button === 2 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\t[ allowRightClickOverrides ]\n\t);\n\n\tconst settingsPopoverAnchor = useMemo( () => {\n\t\tconst { ownerDocument } = rowRef?.current || {};\n\n\t\t// If no custom position is set, the settings dropdown will be anchored to the\n\t\t// DropdownMenu toggle button.\n\t\tif ( ! settingsAnchorRect || ! ownerDocument ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Position the settings dropdown at the cursor when right-clicking a block.\n\t\treturn {\n\t\t\townerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\treturn settingsAnchorRect;\n\t\t\t},\n\t\t};\n\t}, [ settingsAnchorRect ] );\n\n\tconst clearSettingsAnchorRect = useCallback( () => {\n\t\t// Clear the custom position for the settings dropdown so that it is restored back\n\t\t// to being anchored to the DropdownMenu toggle button.\n\t\tsetSettingsAnchorRect( undefined );\n\t}, [ setSettingsAnchorRect ] );\n\n\t// Pass in a ref to the row, so that it can be scrolled\n\t// into view when selected. For long lists, the placeholder for the\n\t// selected block is also observed, within ListViewLeafPlaceholder.\n\tuseListViewScrollIntoView( {\n\t\tisSelected,\n\t\trowItemRef: rowRef,\n\t\tselectedClientIds,\n\t} );\n\n\t// When switching between rendering modes (such as template preview and content only),\n\t// it is possible for a block to temporarily be unavailable. In this case, we should not\n\t// render the leaf, to avoid errors further down the tree.\n\tif ( ! block ) {\n\t\treturn null;\n\t}\n\n\tconst blockPositionDescription = getBlockPositionDescription(\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel\n\t);\n\n\tconst blockPropertiesDescription = getBlockPropertiesDescription(\n\t\tblockInformation,\n\t\tisLocked\n\t);\n\n\t// Determine label based on where block is hidden (not when/current viewport)\n\tconst blockVisibilityDescription = getBlockVisibilityLabel(\n\t\tblock?.attributes?.metadata?.blockVisibility\n\t);\n\n\tconst hasSiblings = siblingBlockCount > 0;\n\tconst hasRenderedMovers = showBlockMovers && hasSiblings;\n\tconst moverCellClassName = clsx(\n\t\t'block-editor-list-view-block__mover-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\tconst listViewBlockSettingsClassName = clsx(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isFirstSelectedBlock }\n\t);\n\n\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 2;\n\t} else if ( ! showBlockActions ) {\n\t\tcolSpan = 3;\n\t}\n\n\tconst classes = clsx( {\n\t\t'is-selected': isSelected,\n\t\t'is-first-selected': isFirstSelectedBlock,\n\t\t'is-last-selected': isLastSelectedBlock,\n\t\t'is-branch-selected': isBranchSelected,\n\t\t'is-synced-branch': isSyncedBranch,\n\t\t'is-dragging': isDragged,\n\t\t'has-single-cell': ! showBlockActions,\n\t\t'is-synced': blockInformation?.isSynced,\n\t\t'is-draggable': canMoveBlock,\n\t\t'is-displacement-normal': displacement === 'normal',\n\t\t'is-displacement-up': displacement === 'up',\n\t\t'is-displacement-down': displacement === 'down',\n\t\t'is-after-dragged-blocks': isAfterDraggedBlocks,\n\t\t'is-nesting': isNesting,\n\t} );\n\n\t// Only include all selected blocks if the currently clicked on block\n\t// is one of the selected blocks. This ensures that if a user attempts\n\t// to alter a block that isn't part of the selection, they're still able\n\t// to do so.\n\tconst dropdownClientIds = selectedClientIds.includes( clientId )\n\t\t? selectedClientIds\n\t\t: [ clientId ];\n\n\t// Detect if there is a block in the canvas currently being edited and multi-selection is not happening.\n\tconst currentlyEditingBlockInCanvas =\n\t\tisSelected && selectedClientIds.length === 1;\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\n\t\t\tisDragged={ isDragged }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t\tid={ `list-view-${ listViewInstanceId }-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tdata-expanded={ canEditBlock ? isExpanded : undefined }\n\t\t\tref={ rowRef }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-block__contents-cell\"\n\t\t\t\tcolSpan={ colSpan }\n\t\t\t\tref={ cellRef }\n\t\t\t\taria-selected={ !! isSelected }\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-block__contents-container\">\n\t\t\t\t\t\t<ListViewBlockContents\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={ selectEditorBlock }\n\t\t\t\t\t\t\tonContextMenu={ onContextMenu }\n\t\t\t\t\t\t\tonMouseDown={ onMouseDown }\n\t\t\t\t\t\t\tonToggleExpanded={ toggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\ttabIndex={\n\t\t\t\t\t\t\t\tcurrentlyEditingBlockInCanvas ? 0 : tabIndex\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tisExpanded={ canEditBlock ? isExpanded : undefined }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tariaDescribedBy={ descriptionId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<AriaReferencedText id={ descriptionId }>\n\t\t\t\t\t\t\t{ [\n\t\t\t\t\t\t\t\tblockPositionDescription,\n\t\t\t\t\t\t\t\tblockPropertiesDescription,\n\t\t\t\t\t\t\t\tblockVisibilityDescription,\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t.filter( Boolean )\n\t\t\t\t\t\t\t\t.join( ' ' ) }\n\t\t\t\t\t\t</AriaReferencedText>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t\t{ hasRenderedMovers && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ moverCellClassName }\n\t\t\t\t\t\twithoutGridItem\n\t\t\t\t\t>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ showBlockActions && BlockSettingsMenu && (\n\t\t\t\t<TreeGridCell\n\t\t\t\t\tclassName={ listViewBlockSettingsClassName }\n\t\t\t\t\taria-selected={ !! isSelected }\n\t\t\t\t\tref={ settingsRef }\n\t\t\t\t>\n\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t<BlockSettingsMenu\n\t\t\t\t\t\t\tclientIds={ dropdownClientIds }\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'Options' ) }\n\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\tanchor: settingsPopoverAnchor, // Used to position the settings at the cursor on right-click.\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\tclassName: 'block-editor-list-view-block__menu',\n\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\tonClick: clearSettingsAnchorRect,\n\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t\tsize: 'small',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\texpand={ expand }\n\t\t\t\t\t\t\texpandedState={ expandedState }\n\t\t\t\t\t\t\tsetInsertedBlock={ setInsertedBlock }\n\t\t\t\t\t\t\t__experimentalSelectBlock={\n\t\t\t\t\t\t\t\tupdateFocusAndSelection\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisContentOnlyListView={\n\t\t\t\t\t\t\t\t!! rootClientId &&\n\t\t\t\t\t\t\t\tgetBlockEditingMode( rootClientId ) ===\n\t\t\t\t\t\t\t\t\t'contentOnly'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TreeGridCell>\n\t\t\t) }\n\t\t\t{ isRenameModalOpen && (\n\t\t\t\t<BlockRenameModal\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tonClose={ () => setIsRenameModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n\nexport default memo( ListViewBlock );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAIO;AACP,wBAGO;AACP,qBAA2C;AAC3C,mBAA6B;AAC7B,qBAMO;AACP,kBAAuC;AACvC,kBAAmB;AACnB,sBAAkC;AAClC,8BAA+B;AAC/B,gCAAyE;AACzE,kBAAsB;AAKtB,kBAAyB;AACzB,4CAAsC;AACtC,oBAGO;AACP,4BAAkC;AAClC,qBAAmC;AACnC,mBAIO;AACP,mBAA0C;AAC1C,2CAAuC;AACvC,wBAA6B;AAC7B,0BAAiD;AACjD,kCAA+B;AAC/B,yBAAuB;AACvB,8BAA2B;AAC3B,8BAAwC;AA6iBnC;AA3iBL,SAAS,cAAe;AAAA,EACvB,OAAO,EAAE,SAAS;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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A,cACD,GAEF;AAAA;AAAA;AAAA,QACD,GACD;AAAA,QAGC,oBAAoB,qBACrB;AAAA,UAAC,kBAAAH;AAAA,UAAA;AAAA,YACA,WAAY;AAAA,YACZ,iBAAgB,CAAC,CAAE;AAAA,YACnB,KAAM;AAAA,YAEJ,WAAE,EAAE,KAAK,UAAU,QAAQ,MAC5B;AAAA,cAAC;AAAA;AAAA,gBACA,WAAY;AAAA,gBACZ;AAAA,gBACA,MAAO;AAAA,gBACP,WAAQ,gBAAI,SAAU;AAAA,gBACtB,cAAe;AAAA,kBACd,QAAQ;AAAA;AAAA,gBACT;AAAA,gBACA,aAAc;AAAA,kBACb;AAAA,kBACA,WAAW;AAAA,kBACX;AAAA,kBACA,SAAS;AAAA,kBACT;AAAA,kBACA,MAAM;AAAA,gBACP;AAAA,gBACA,wBAAsB;AAAA,gBACtB;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,2BACC;AAAA,gBAED,uBACC,CAAC,CAAE,gBACH,oBAAqB,YAAa,MACjC;AAAA;AAAA,YAEH;AAAA;AAAA,QAEF;AAAA,QAEC,qBACD;AAAA,UAAC;AAAA;AAAA,YACA;AAAA,YACA,SAAU,MAAM,qBAAsB,KAAM;AAAA;AAAA,QAC7C;AAAA;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,oBAAQ,qBAAM,aAAc;",
|
|
6
6
|
"names": ["blockEditorStore", "blocksStore", "useBlockDisplayInformation", "usePasteStyles", "useShortcutEventMatch", "useListViewScrollIntoView", "clsx", "ListViewLeaf", "TreeGridCell", "ListViewBlockContents", "AriaReferencedText", "TreeGridItem"]
|
|
7
7
|
}
|
|
@@ -24,6 +24,7 @@ __export(custom_value_controls_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(custom_value_controls_exports);
|
|
26
26
|
var import_components = require("@wordpress/components");
|
|
27
|
+
var import_ui = require("@wordpress/ui");
|
|
27
28
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
29
|
function CustomValueControls({
|
|
29
30
|
allowNegativeOnDrag,
|
|
@@ -81,7 +82,15 @@ function CustomValueControls({
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
);
|
|
84
|
-
const wrappedUnitControl = showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime.
|
|
85
|
+
const wrappedUnitControl = showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Tooltip.Root, { children: [
|
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
87
|
+
import_ui.Tooltip.Trigger,
|
|
88
|
+
{
|
|
89
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "preset-input-control__tooltip-wrapper", children: unitControl })
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tooltip.Popup, { children: ariaLabel })
|
|
93
|
+
] }) : unitControl;
|
|
85
94
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
86
95
|
wrappedUnitControl,
|
|
87
96
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/preset-input-control/custom-value-controls.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tRangeControl,\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tRangeControl,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\n\n// eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.\nimport { Tooltip } from '@wordpress/ui';\n\n/**\n * CustomValueControls component for handling custom value input.\n *\n * Renders a UnitControl and RangeControl for custom value input mode.\n * Handles conditional tooltip wrapping and drag event coordination.\n *\n * @param {Object} props\n * @param {boolean} props.allowNegativeOnDrag Whether to allow negative values during drag operations.\n * @param {string} props.ariaLabel Accessible label for the controls.\n * @param {string} props.allPlaceholder Placeholder text (e.g., \"Mixed\").\n * @param {number} props.minValue Minimum allowed value.\n * @param {number} props.parsedQuantity The numeric part of the current value.\n * @param {string} props.computedUnit The unit part of the current value.\n * @param {Array} props.units Array of available unit objects.\n * @param {boolean} props.isMixed Whether the current value is mixed.\n * @param {number} props.step Step value for the range control.\n * @param {number} props.max Maximum value for the range control.\n * @param {boolean} props.showTooltip Whether to wrap UnitControl in a tooltip.\n * @param {string} props.value Current value for drag event checks.\n * @param {number} props.minimumCustomValue Minimum custom value for drag end reset.\n * @param {Function} props.onCustomValueChange Callback when UnitControl value changes.\n * @param {Function} props.onCustomValueSliderChange Callback when RangeControl value changes.\n * @param {Function} props.onUnitChange Callback when unit changes.\n * @param {Function} props.onMouseOut Mouse out event handler.\n * @param {Function} props.onMouseOver Mouse over event handler.\n * @param {Function} props.setMinValue Function to set minimum value state.\n *\n * @return {Element} The CustomValueControls component.\n */\nexport default function CustomValueControls( {\n\tallowNegativeOnDrag,\n\tariaLabel,\n\tallPlaceholder,\n\tminValue,\n\tparsedQuantity,\n\tcomputedUnit,\n\tunits,\n\tisMixed,\n\tstep,\n\tmax,\n\tshowTooltip,\n\tvalue,\n\tminimumCustomValue,\n\tonCustomValueChange,\n\tonCustomValueSliderChange,\n\tonUnitChange,\n\tonMouseOut,\n\tonMouseOver,\n\tsetMinValue,\n} ) {\n\tconst unitControl = (\n\t\t<UnitControl\n\t\t\tclassName=\"preset-input-control__unit-control\"\n\t\t\tdisableUnits={ isMixed }\n\t\t\thideLabelFromVision\n\t\t\tlabel={ ariaLabel }\n\t\t\tmin={ minValue }\n\t\t\tonChange={ onCustomValueChange }\n\t\t\tonUnitChange={ onUnitChange }\n\t\t\tonBlur={ onMouseOut }\n\t\t\tonFocus={ onMouseOver }\n\t\t\tonMouseOut={ onMouseOut }\n\t\t\tonMouseOver={ onMouseOver }\n\t\t\tsize=\"__unstable-large\"\n\t\t\tunits={ units }\n\t\t\tvalue={ [ parsedQuantity, computedUnit ].join( '' ) }\n\t\t\tplaceholder={ allPlaceholder }\n\t\t\tonDragStart={ () => {\n\t\t\t\tif ( allowNegativeOnDrag && value?.charAt( 0 ) === '-' ) {\n\t\t\t\t\tsetMinValue( 0 );\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonDrag={ () => {\n\t\t\t\tif ( allowNegativeOnDrag && value?.charAt( 0 ) === '-' ) {\n\t\t\t\t\tsetMinValue( 0 );\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tif ( allowNegativeOnDrag ) {\n\t\t\t\t\tsetMinValue( minimumCustomValue );\n\t\t\t\t}\n\t\t\t} }\n\t\t/>\n\t);\n\n\tconst wrappedUnitControl = showTooltip ? (\n\t\t<Tooltip.Root>\n\t\t\t<Tooltip.Trigger\n\t\t\t\trender={\n\t\t\t\t\t<div className=\"preset-input-control__tooltip-wrapper\">\n\t\t\t\t\t\t{ unitControl }\n\t\t\t\t\t</div>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Tooltip.Popup>{ ariaLabel }</Tooltip.Popup>\n\t\t</Tooltip.Root>\n\t) : (\n\t\tunitControl\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ wrappedUnitControl }\n\t\t\t<RangeControl\n\t\t\t\tclassName=\"preset-input-control__custom-value-range\"\n\t\t\t\thideLabelFromVision\n\t\t\t\tinitialPosition={ 0 }\n\t\t\t\tlabel={ ariaLabel }\n\t\t\t\tmax={ max }\n\t\t\t\tmin={ 0 }\n\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\tonChange={ onCustomValueSliderChange }\n\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\tstep={ step }\n\t\t\t\tvalue={ parsedQuantity }\n\t\t\t\twithInputField={ false }\n\t\t\t\t__next40pxDefaultSize\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAGO;AAGP,gBAAwB;AAqDtB;AAtBa,SAAR,oBAAsC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,cACL;AAAA,IAAC,kBAAAA;AAAA,IAAA;AAAA,MACA,WAAU;AAAA,MACV,cAAe;AAAA,MACf,qBAAmB;AAAA,MACnB,OAAQ;AAAA,MACR,KAAM;AAAA,MACN,UAAW;AAAA,MACX;AAAA,MACA,QAAS;AAAA,MACT,SAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MACL;AAAA,MACA,OAAQ,CAAE,gBAAgB,YAAa,EAAE,KAAM,EAAG;AAAA,MAClD,aAAc;AAAA,MACd,aAAc,MAAM;AACnB,YAAK,uBAAuB,OAAO,OAAQ,CAAE,MAAM,KAAM;AACxD,sBAAa,CAAE;AAAA,QAChB;AAAA,MACD;AAAA,MACA,QAAS,MAAM;AACd,YAAK,uBAAuB,OAAO,OAAQ,CAAE,MAAM,KAAM;AACxD,sBAAa,CAAE;AAAA,QAChB;AAAA,MACD;AAAA,MACA,WAAY,MAAM;AACjB,YAAK,qBAAsB;AAC1B,sBAAa,kBAAmB;AAAA,QACjC;AAAA,MACD;AAAA;AAAA,EACD;AAGD,QAAM,qBAAqB,cAC1B,6CAAC,kBAAQ,MAAR,EACA;AAAA;AAAA,MAAC,kBAAQ;AAAA,MAAR;AAAA,QACA,QACC,4CAAC,SAAI,WAAU,yCACZ,uBACH;AAAA;AAAA,IAEF;AAAA,IACA,4CAAC,kBAAQ,OAAR,EAAgB,qBAAW;AAAA,KAC7B,IAEA;AAGD,SACC,4EACG;AAAA;AAAA,IACF;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,qBAAmB;AAAA,QACnB,iBAAkB;AAAA,QAClB,OAAQ;AAAA,QACR;AAAA,QACA,KAAM;AAAA,QACN,QAAS;AAAA,QACT,UAAW;AAAA,QACX,SAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAQ;AAAA,QACR,gBAAiB;AAAA,QACjB,uBAAqB;AAAA;AAAA,IACtB;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": ["UnitControl"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/preset-input-control/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCustomSelectControl,\n\tIcon,\n\tRangeControl,\n\t__experimentalHStack as HStack,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { usePrevious } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tCUSTOM_VALUE_SETTINGS,\n\tICON_SIZE,\n\tRANGE_CONTROL_MAX_SIZE,\n} from './constants';\nimport {\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tgetSliderValueFromPreset,\n\tisValuePreset,\n} from './utils';\nimport CustomValueControls from './custom-value-controls';\n\n/**\n * PresetInputControl component for selecting preset values or entering custom values.\n *\n * Displays preset values as either a slider (for <= 8 presets) or a select dropdown.\n * Allows toggling to custom value mode with a UnitControl and RangeControl.\n * Handles unit tracking and conversion between preset and custom values.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.allowNegativeOnDrag Whether to allow negative values during drag operations.\n * @param {string} props.ariaLabel Accessible label for the control.\n * @param {string} props.className Optional CSS class name.\n * @param {Object} props.customValueSettings Optional custom value settings for max/steps per unit.\n * @param {boolean} props.disableCustomValues Whether to disable custom value input.\n * @param {Object} props.icon Icon to display alongside the control.\n * @param {boolean} props.isMixed Whether the current value is mixed (multiple values).\n * @param {number} props.minimumCustomValue Minimum allowed custom value.\n * @param {Function} props.onChange Callback when value changes.\n * @param {Function} props.onMouseOut Callback for mouse out events.\n * @param {Function} props.onMouseOver Callback for mouse over events.\n * @param {Function} props.onUnitChange Callback when unit changes.\n * @param {Array} props.presets Array of preset objects with name, slug, and size.\n * @param {string} props.presetType Type of preset (e.g., 'spacing', 'border-radius').\n * @param {string} props.selectedUnit Currently selected unit (e.g., 'px', 'em').\n * @param {boolean} props.showTooltip Whether to show tooltip on custom UnitControl.\n * @param {Array} props.units Array of available unit objects (can include max and step).\n * @param {string} props.value Current value (preset or custom).\n *\n * @return {Element} The PresetInputControl component.\n */\nexport default function PresetInputControl( {\n\tallowNegativeOnDrag = false,\n\tariaLabel,\n\tclassName: classNameProp,\n\tcustomValueSettings = CUSTOM_VALUE_SETTINGS,\n\tdisableCustomValues,\n\ticon,\n\tisMixed,\n\tvalue: valueProp,\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tonUnitChange,\n\tpresets = [],\n\tpresetType,\n\tselectedUnit,\n\tshowTooltip,\n\tunits,\n} ) {\n\tconst value = useMemo(\n\t\t() => getPresetValueFromCustomValue( valueProp, presets, presetType ),\n\t\t[ valueProp, presets, presetType ]\n\t);\n\n\tconst className = classNameProp ?? 'preset-input-control';\n\n\tconst marks = presets\n\t\t.slice( 1, presets.length - 1 )\n\t\t.map( ( _newValue, index ) => ( {\n\t\t\tvalue: index + 1,\n\t\t\tlabel: undefined,\n\t\t} ) );\n\tconst hasPresets = marks.length > 0;\n\tconst showRangeControl = presets.length <= RANGE_CONTROL_MAX_SIZE;\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst [ minValue, setMinValue ] = useState( minimumCustomValue );\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomValues &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValuePreset( value, presetType )\n\t);\n\n\tlet currentValue = null;\n\n\tconst previousValue = usePrevious( value );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t!! value &&\n\t\t\tpreviousValue !== value &&\n\t\t\t! isValuePreset( value, presetType ) &&\n\t\t\tshowCustomValueControl !== true\n\t\t) {\n\t\t\tsetShowCustomValueControl( true );\n\t\t}\n\t}, [ value, previousValue, presetType, showCustomValueControl ] );\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValuePreset( value, presetType ) ||\n\t\t\t( isValuePreset( value, presetType ) && isMixed ) );\n\n\tlet selectListOptions = presets;\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListOptions = [\n\t\t\t...presets,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: %s: A custom measurement, e.g. a number followed by a unit like 12px.\n\t\t\t\t\t sprintf( __( 'Custom (%s)' ), value )\n\t\t\t\t\t: __( 'Mixed' ),\n\t\t\t\tslug: 'custom',\n\t\t\t\tsize: value,\n\t\t\t},\n\t\t];\n\t\tcurrentValue = selectListOptions.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, presets, presetType )\n\t\t\t: getCustomValueFromPreset( value, presets, presetType );\n\t}\n\n\tconst options = selectListOptions.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst resolvedPresetValue = isValuePreset( value, presetType )\n\t\t? getCustomValueFromPreset( value, presets, presetType )\n\t\t: value;\n\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( resolvedPresetValue );\n\n\tconst computedUnit = parsedUnit || selectedUnit || 'px';\n\n\t// Get step and max from units prop, falling back to customValueSettings\n\tconst unitConfig = units?.find( ( item ) => item.value === computedUnit );\n\tconst step =\n\t\tunitConfig?.step ?? customValueSettings[ computedUnit ]?.steps ?? 0.1;\n\tconst max =\n\t\tunitConfig?.max ?? customValueSettings[ computedUnit ]?.max ?? 10;\n\n\tconst handleCustomValueChange = ( newValue ) => {\n\t\t// Treat empty or undefined as an explicit clear and propagate undefined.\n\t\tif ( newValue === undefined || newValue === '' ) {\n\t\t\tonChange( undefined );\n\t\t\treturn;\n\t\t}\n\n\t\t// Ignore non-numeric intermediate input (e.g. just a unit).\n\t\tif ( isNaN( parseFloat( newValue ) ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonChange( newValue );\n\t};\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, computedUnit ].join( '' ) );\n\t};\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : presets[ newValue ]?.name;\n\n\tconst getNewPresetValue = ( next, controlType ) => {\n\t\tconst newValue = parseInt( next, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( newValue === 0 && presets[ 0 ]?.slug === '0' ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t\tif ( newValue === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t} else if ( newValue === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|${ presetType }|${ presets[ next ]?.slug }`;\n\t};\n\n\treturn (\n\t\t<HStack\n\t\t\tclassName={ `preset-input-control__wrapper ${ className }__wrapper` }\n\t\t>\n\t\t\t{ icon && (\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"preset-input-control__icon\"\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ ICON_SIZE }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ( ! hasPresets || showCustomValueControl ) && (\n\t\t\t\t<CustomValueControls\n\t\t\t\t\tallowNegativeOnDrag={ allowNegativeOnDrag }\n\t\t\t\t\tariaLabel={ ariaLabel }\n\t\t\t\t\tallPlaceholder={ allPlaceholder }\n\t\t\t\t\tminValue={ minValue }\n\t\t\t\t\tparsedQuantity={ parsedQuantity }\n\t\t\t\t\tcomputedUnit={ computedUnit }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tisMixed={ isMixed }\n\t\t\t\t\tstep={ step }\n\t\t\t\t\tmax={ max }\n\t\t\t\t\tshowTooltip={ showTooltip }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\t\t\tonCustomValueChange={ handleCustomValueChange }\n\t\t\t\t\tonCustomValueSliderChange={ handleCustomValueSliderChange }\n\t\t\t\t\tonUnitChange={ onUnitChange }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tsetMinValue={ setMinValue }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ presets[ currentValue ]?.name }\n\t\t\t\t\tclassName=\"preset-input-control__preset-range\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tmax={ presets.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newValue ) )\n\t\t\t\t\t}\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t// If mouse down is near start of range set initial value to 0, which\n\t\t\t\t\t\t// prevents the user have to drag right then left to get 0 setting.\n\t\t\t\t\t\tconst nearStart = event?.nativeEvent?.offsetX < 35;\n\t\t\t\t\t\tif ( nearStart && value === undefined ) {\n\t\t\t\t\t\t\tonChange( '0' );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tstep={ 1 }\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"preset-input-control__custom-select-control\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshowCustomValueInSelectList &&\n\t\t\t\t\t\t\tselection.selectedItem.key === options.length - 1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsetShowCustomValueControl( true );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t\t'selectList'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\t// passing empty string as a fallback to continue using the\n\t\t\t\t\t\t// component in controlled mode\n\t\t\t\t\t\toptions.find(\n\t\t\t\t\t\t\t( option ) => option.key === currentValue\n\t\t\t\t\t\t) || ''\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! disableCustomValues && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"preset-input-control__custom-toggle\"\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\ticonSize={ ICON_SIZE }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use preset' )\n\t\t\t\t\t\t\t: __( 'Set custom value' )\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAOO;AACP,qBAA4B;AAC5B,kBAA4B;AAC5B,mBAAyB;AACzB,qBAA6C;AAK7C,uBAIO;AACP,mBAKO;AACP,mCAAgC;AAgL9B;AAjJa,SAAR,mBAAqC;AAAA,EAC3C,sBAAsB;AAAA,EACtB;AAAA,EACA,WAAW;AAAA,EACX,sBAAsB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,YAAQ;AAAA,IACb,UAAM,4CAA+B,WAAW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AW,CAAE,cAAe;AAC3B,kBACC,+BACA,UAAU,aAAa,QAAQ,QAAQ,SAAS,GAC/C;AACD,0CAA2B,IAAK;AAAA,cACjC,OAAO;AACN;AAAA,kBACC;AAAA,oBACC,UAAU,aAAa;AAAA,oBACvB;AAAA,kBACD;AAAA,gBACD;AAAA,cACD;AAAA,YACD;AAAA,YACA,SAAU;AAAA,YACV;AAAA,YACA;AAAA,YACA;AAAA,YACA,MAAK;AAAA,YACL;AAAA;AAAA;AAAA,cAGC,QAAQ;AAAA,gBACP,CAAE,WAAY,OAAO,QAAQ;AAAA,cAC9B,KAAK;AAAA;AAAA;AAAA,QAEP;AAAA,QAEC,cAAc,CAAE,uBACjB;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,MAAO;AAAA,YACP,UAAW;AAAA,YACX,WAAY;AAAA,YACZ,OACC,6BACG,gBAAI,YAAa,QACjB,gBAAI,kBAAmB;AAAA,YAE3B,SAAU,MAAM;AACf,wCAA2B,CAAE,sBAAuB;AAAA,YACrD;AAAA,YACA,MAAK;AAAA;AAAA,QACN;AAAA;AAAA;AAAA,EAEF;AAEF;",
|
|
6
|
-
"names": ["parseQuantityAndUnitFromRawValue", "HStack", "CustomValueControls"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCustomSelectControl,\n\tIcon as WCIcon,\n\tRangeControl,\n\t__experimentalHStack as HStack,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { usePrevious } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tCUSTOM_VALUE_SETTINGS,\n\tICON_SIZE,\n\tRANGE_CONTROL_MAX_SIZE,\n} from './constants';\nimport {\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tgetSliderValueFromPreset,\n\tisValuePreset,\n} from './utils';\nimport CustomValueControls from './custom-value-controls';\n\n/**\n * PresetInputControl component for selecting preset values or entering custom values.\n *\n * Displays preset values as either a slider (for <= 8 presets) or a select dropdown.\n * Allows toggling to custom value mode with a UnitControl and RangeControl.\n * Handles unit tracking and conversion between preset and custom values.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.allowNegativeOnDrag Whether to allow negative values during drag operations.\n * @param {string} props.ariaLabel Accessible label for the control.\n * @param {string} props.className Optional CSS class name.\n * @param {Object} props.customValueSettings Optional custom value settings for max/steps per unit.\n * @param {boolean} props.disableCustomValues Whether to disable custom value input.\n * @param {Object} props.icon Icon to display alongside the control.\n * @param {boolean} props.isMixed Whether the current value is mixed (multiple values).\n * @param {number} props.minimumCustomValue Minimum allowed custom value.\n * @param {Function} props.onChange Callback when value changes.\n * @param {Function} props.onMouseOut Callback for mouse out events.\n * @param {Function} props.onMouseOver Callback for mouse over events.\n * @param {Function} props.onUnitChange Callback when unit changes.\n * @param {Array} props.presets Array of preset objects with name, slug, and size.\n * @param {string} props.presetType Type of preset (e.g., 'spacing', 'border-radius').\n * @param {string} props.selectedUnit Currently selected unit (e.g., 'px', 'em').\n * @param {boolean} props.showTooltip Whether to show tooltip on custom UnitControl.\n * @param {Array} props.units Array of available unit objects (can include max and step).\n * @param {string} props.value Current value (preset or custom).\n *\n * @return {Element} The PresetInputControl component.\n */\nexport default function PresetInputControl( {\n\tallowNegativeOnDrag = false,\n\tariaLabel,\n\tclassName: classNameProp,\n\tcustomValueSettings = CUSTOM_VALUE_SETTINGS,\n\tdisableCustomValues,\n\ticon,\n\tisMixed,\n\tvalue: valueProp,\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tonUnitChange,\n\tpresets = [],\n\tpresetType,\n\tselectedUnit,\n\tshowTooltip,\n\tunits,\n} ) {\n\tconst value = useMemo(\n\t\t() => getPresetValueFromCustomValue( valueProp, presets, presetType ),\n\t\t[ valueProp, presets, presetType ]\n\t);\n\n\tconst className = classNameProp ?? 'preset-input-control';\n\n\tconst marks = presets\n\t\t.slice( 1, presets.length - 1 )\n\t\t.map( ( _newValue, index ) => ( {\n\t\t\tvalue: index + 1,\n\t\t\tlabel: undefined,\n\t\t} ) );\n\tconst hasPresets = marks.length > 0;\n\tconst showRangeControl = presets.length <= RANGE_CONTROL_MAX_SIZE;\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst [ minValue, setMinValue ] = useState( minimumCustomValue );\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomValues &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValuePreset( value, presetType )\n\t);\n\n\tlet currentValue = null;\n\n\tconst previousValue = usePrevious( value );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t!! value &&\n\t\t\tpreviousValue !== value &&\n\t\t\t! isValuePreset( value, presetType ) &&\n\t\t\tshowCustomValueControl !== true\n\t\t) {\n\t\t\tsetShowCustomValueControl( true );\n\t\t}\n\t}, [ value, previousValue, presetType, showCustomValueControl ] );\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValuePreset( value, presetType ) ||\n\t\t\t( isValuePreset( value, presetType ) && isMixed ) );\n\n\tlet selectListOptions = presets;\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListOptions = [\n\t\t\t...presets,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: %s: A custom measurement, e.g. a number followed by a unit like 12px.\n\t\t\t\t\t sprintf( __( 'Custom (%s)' ), value )\n\t\t\t\t\t: __( 'Mixed' ),\n\t\t\t\tslug: 'custom',\n\t\t\t\tsize: value,\n\t\t\t},\n\t\t];\n\t\tcurrentValue = selectListOptions.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, presets, presetType )\n\t\t\t: getCustomValueFromPreset( value, presets, presetType );\n\t}\n\n\tconst options = selectListOptions.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst resolvedPresetValue = isValuePreset( value, presetType )\n\t\t? getCustomValueFromPreset( value, presets, presetType )\n\t\t: value;\n\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( resolvedPresetValue );\n\n\tconst computedUnit = parsedUnit || selectedUnit || 'px';\n\n\t// Get step and max from units prop, falling back to customValueSettings\n\tconst unitConfig = units?.find( ( item ) => item.value === computedUnit );\n\tconst step =\n\t\tunitConfig?.step ?? customValueSettings[ computedUnit ]?.steps ?? 0.1;\n\tconst max =\n\t\tunitConfig?.max ?? customValueSettings[ computedUnit ]?.max ?? 10;\n\n\tconst handleCustomValueChange = ( newValue ) => {\n\t\t// Treat empty or undefined as an explicit clear and propagate undefined.\n\t\tif ( newValue === undefined || newValue === '' ) {\n\t\t\tonChange( undefined );\n\t\t\treturn;\n\t\t}\n\n\t\t// Ignore non-numeric intermediate input (e.g. just a unit).\n\t\tif ( isNaN( parseFloat( newValue ) ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonChange( newValue );\n\t};\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, computedUnit ].join( '' ) );\n\t};\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : presets[ newValue ]?.name;\n\n\tconst getNewPresetValue = ( next, controlType ) => {\n\t\tconst newValue = parseInt( next, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( newValue === 0 && presets[ 0 ]?.slug === '0' ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t\tif ( newValue === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t} else if ( newValue === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|${ presetType }|${ presets[ next ]?.slug }`;\n\t};\n\n\treturn (\n\t\t<HStack\n\t\t\tclassName={ `preset-input-control__wrapper ${ className }__wrapper` }\n\t\t>\n\t\t\t{ icon && (\n\t\t\t\t<WCIcon\n\t\t\t\t\tclassName=\"preset-input-control__icon\"\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ ICON_SIZE }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ( ! hasPresets || showCustomValueControl ) && (\n\t\t\t\t<CustomValueControls\n\t\t\t\t\tallowNegativeOnDrag={ allowNegativeOnDrag }\n\t\t\t\t\tariaLabel={ ariaLabel }\n\t\t\t\t\tallPlaceholder={ allPlaceholder }\n\t\t\t\t\tminValue={ minValue }\n\t\t\t\t\tparsedQuantity={ parsedQuantity }\n\t\t\t\t\tcomputedUnit={ computedUnit }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tisMixed={ isMixed }\n\t\t\t\t\tstep={ step }\n\t\t\t\t\tmax={ max }\n\t\t\t\t\tshowTooltip={ showTooltip }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\t\t\tonCustomValueChange={ handleCustomValueChange }\n\t\t\t\t\tonCustomValueSliderChange={ handleCustomValueSliderChange }\n\t\t\t\t\tonUnitChange={ onUnitChange }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tsetMinValue={ setMinValue }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ presets[ currentValue ]?.name }\n\t\t\t\t\tclassName=\"preset-input-control__preset-range\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tmax={ presets.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newValue ) )\n\t\t\t\t\t}\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t// If mouse down is near start of range set initial value to 0, which\n\t\t\t\t\t\t// prevents the user have to drag right then left to get 0 setting.\n\t\t\t\t\t\tconst nearStart = event?.nativeEvent?.offsetX < 35;\n\t\t\t\t\t\tif ( nearStart && value === undefined ) {\n\t\t\t\t\t\t\tonChange( '0' );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tstep={ 1 }\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"preset-input-control__custom-select-control\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshowCustomValueInSelectList &&\n\t\t\t\t\t\t\tselection.selectedItem.key === options.length - 1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsetShowCustomValueControl( true );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t\t'selectList'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\t// passing empty string as a fallback to continue using the\n\t\t\t\t\t\t// component in controlled mode\n\t\t\t\t\t\toptions.find(\n\t\t\t\t\t\t\t( option ) => option.key === currentValue\n\t\t\t\t\t\t) || ''\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! disableCustomValues && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"preset-input-control__custom-toggle\"\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\ticonSize={ ICON_SIZE }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use preset' )\n\t\t\t\t\t\t\t: __( 'Set custom value' )\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAOO;AACP,qBAA4B;AAC5B,kBAA4B;AAC5B,mBAAyB;AACzB,qBAA6C;AAK7C,uBAIO;AACP,mBAKO;AACP,mCAAgC;AAgL9B;AAjJa,SAAR,mBAAqC;AAAA,EAC3C,sBAAsB;AAAA,EACtB;AAAA,EACA,WAAW;AAAA,EACX,sBAAsB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA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B;AAAA,QAEC,cAAc,CAAE,oBAAoB,CAAE,0BACvC;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,qBAAmB;AAAA,YACnB,OAAQ;AAAA,YACR,QAAS;AAAA,YACT,UAAW,CAAE,cAAe;AAC3B,kBACC,+BACA,UAAU,aAAa,QAAQ,QAAQ,SAAS,GAC/C;AACD,0CAA2B,IAAK;AAAA,cACjC,OAAO;AACN;AAAA,kBACC;AAAA,oBACC,UAAU,aAAa;AAAA,oBACvB;AAAA,kBACD;AAAA,gBACD;AAAA,cACD;AAAA,YACD;AAAA,YACA,SAAU;AAAA,YACV;AAAA,YACA;AAAA,YACA;AAAA,YACA,MAAK;AAAA,YACL;AAAA;AAAA;AAAA,cAGC,QAAQ;AAAA,gBACP,CAAE,WAAY,OAAO,QAAQ;AAAA,cAC9B,KAAK;AAAA;AAAA;AAAA,QAEP;AAAA,QAEC,cAAc,CAAE,uBACjB;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,MAAO;AAAA,YACP,UAAW;AAAA,YACX,WAAY;AAAA,YACZ,OACC,6BACG,gBAAI,YAAa,QACjB,gBAAI,kBAAmB;AAAA,YAE3B,SAAU,MAAM;AACf,wCAA2B,CAAE,sBAAuB;AAAA,YACrD;AAAA,YACA,MAAK;AAAA;AAAA,QACN;AAAA;AAAA;AAAA,EAEF;AAEF;",
|
|
6
|
+
"names": ["parseQuantityAndUnitFromRawValue", "HStack", "WCIcon", "CustomValueControls"]
|
|
7
7
|
}
|
|
@@ -30,6 +30,7 @@ function useMediaUploadSettings(settings = {}) {
|
|
|
30
30
|
mediaUpload: settings.mediaUpload,
|
|
31
31
|
mediaSideload: settings.mediaSideload,
|
|
32
32
|
mediaFinalize: settings.mediaFinalize,
|
|
33
|
+
mediaDelete: settings.mediaDelete,
|
|
33
34
|
maxUploadFileSize: settings.maxUploadFileSize,
|
|
34
35
|
allowedMimeTypes: settings.allowedMimeTypes,
|
|
35
36
|
allImageSizes: settings.allImageSizes,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/provider/use-media-upload-settings.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * React hook used to compute the media upload settings to use in the post editor.\n *\n * @param {Object} settings Media upload settings prop.\n *\n * @return {Object} Media upload settings.\n */\nfunction useMediaUploadSettings( settings = {} ) {\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tmediaUpload: settings.mediaUpload,\n\t\t\tmediaSideload: settings.mediaSideload,\n\t\t\tmediaFinalize: settings.mediaFinalize,\n\t\t\tmaxUploadFileSize: settings.maxUploadFileSize,\n\t\t\tallowedMimeTypes: settings.allowedMimeTypes,\n\t\t\tallImageSizes: settings.allImageSizes,\n\t\t\tbigImageSizeThreshold: settings.bigImageSizeThreshold,\n\t\t} ),\n\t\t[ settings ]\n\t);\n}\n\nexport default useMediaUploadSettings;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AASxB,SAAS,uBAAwB,WAAW,CAAC,GAAI;AAChD,aAAO;AAAA,IACN,OAAQ;AAAA,MACP,aAAa,SAAS;AAAA,MACtB,eAAe,SAAS;AAAA,MACxB,eAAe,SAAS;AAAA,MACxB,mBAAmB,SAAS;AAAA,MAC5B,kBAAkB,SAAS;AAAA,MAC3B,eAAe,SAAS;AAAA,MACxB,uBAAuB,SAAS;AAAA,IACjC;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACD;AAEA,IAAO,oCAAQ;",
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * React hook used to compute the media upload settings to use in the post editor.\n *\n * @param {Object} settings Media upload settings prop.\n *\n * @return {Object} Media upload settings.\n */\nfunction useMediaUploadSettings( settings = {} ) {\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tmediaUpload: settings.mediaUpload,\n\t\t\tmediaSideload: settings.mediaSideload,\n\t\t\tmediaFinalize: settings.mediaFinalize,\n\t\t\tmediaDelete: settings.mediaDelete,\n\t\t\tmaxUploadFileSize: settings.maxUploadFileSize,\n\t\t\tallowedMimeTypes: settings.allowedMimeTypes,\n\t\t\tallImageSizes: settings.allImageSizes,\n\t\t\tbigImageSizeThreshold: settings.bigImageSizeThreshold,\n\t\t} ),\n\t\t[ settings ]\n\t);\n}\n\nexport default useMediaUploadSettings;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AASxB,SAAS,uBAAwB,WAAW,CAAC,GAAI;AAChD,aAAO;AAAA,IACN,OAAQ;AAAA,MACP,aAAa,SAAS;AAAA,MACtB,eAAe,SAAS;AAAA,MACxB,eAAe,SAAS;AAAA,MACxB,aAAa,SAAS;AAAA,MACtB,mBAAmB,SAAS;AAAA,MAC5B,kBAAkB,SAAS;AAAA,MAC3B,eAAe,SAAS;AAAA,MACxB,uBAAuB,SAAS;AAAA,IACjC;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACD;AAEA,IAAO,oCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -25,6 +25,9 @@ __export(enter_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(enter_exports);
|
|
26
26
|
var import_keycodes = require("@wordpress/keycodes");
|
|
27
27
|
var import_rich_text = require("@wordpress/rich-text");
|
|
28
|
+
var import_compose = require("@wordpress/compose");
|
|
29
|
+
var import_lock_unlock = require("../../../lock-unlock.cjs");
|
|
30
|
+
var { subscribeDelegatedListener } = (0, import_lock_unlock.unlock)(import_compose.privateApis);
|
|
28
31
|
var enter_default = (props) => (element) => {
|
|
29
32
|
function onKeyDownDeprecated(event) {
|
|
30
33
|
if (event.keyCode !== import_keycodes.ENTER) {
|
|
@@ -78,10 +81,14 @@ var enter_default = (props) => (element) => {
|
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
const { defaultView } = element.ownerDocument;
|
|
81
|
-
|
|
84
|
+
const unsubscribeKeyDown = subscribeDelegatedListener(
|
|
85
|
+
defaultView,
|
|
86
|
+
"keydown",
|
|
87
|
+
onKeyDown
|
|
88
|
+
);
|
|
82
89
|
element.addEventListener("keydown", onKeyDownDeprecated);
|
|
83
90
|
return () => {
|
|
84
|
-
|
|
91
|
+
unsubscribeKeyDown();
|
|
85
92
|
element.removeEventListener("keydown", onKeyDownDeprecated);
|
|
86
93
|
};
|
|
87
94
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/rich-text/event-listeners/enter.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { ENTER } from '@wordpress/keycodes';\nimport { insert, remove } from '@wordpress/rich-text';\n\nexport default ( props ) => ( element ) => {\n\tfunction onKeyDownDeprecated( event ) {\n\t\tif ( event.keyCode !== ENTER ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { onReplace, onSplit } = props.current;\n\n\t\tif ( onReplace && onSplit ) {\n\t\t\tevent.__deprecatedOnSplit = true;\n\t\t}\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element.\n\t\tif ( event.target !== element ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.keyCode !== ENTER ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst {\n\t\t\tvalue,\n\t\t\tonChange,\n\t\t\tdisableLineBreaks,\n\t\t\tonSplitAtEnd,\n\t\t\tonSplitAtDoubleLineEnd,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\tevent.preventDefault();\n\n\t\tconst { text, start, end } = value;\n\n\t\tif ( event.shiftKey ) {\n\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\tonChange( insert( value, '\\n' ) );\n\t\t\t}\n\t\t} else if ( onSplitAtEnd && start === end && end === text.length ) {\n\t\t\tonSplitAtEnd();\n\t\t} else if (\n\t\t\t// For some blocks it's desirable to split at the end of the\n\t\t\t// block when there are two line breaks at the end of the\n\t\t\t// block, so triple Enter exits the block.\n\t\t\tonSplitAtDoubleLineEnd &&\n\t\t\tstart === end &&\n\t\t\tend === text.length &&\n\t\t\ttext.slice( -2 ) === '\\n\\n'\n\t\t) {\n\t\t\tregistry.batch( () => {\n\t\t\t\tconst _value = { ...value };\n\t\t\t\t_value.start = _value.end - 2;\n\t\t\t\tonChange( remove( _value ) );\n\t\t\t\tonSplitAtDoubleLineEnd();\n\t\t\t} );\n\t\t} else if ( ! disableLineBreaks ) {\n\t\t\tonChange( insert( value, '\\n' ) );\n\t\t}\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\tdefaultView
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAsB;AACtB,uBAA+B;
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { ENTER } from '@wordpress/keycodes';\nimport { insert, remove } from '@wordpress/rich-text';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\nexport default ( props ) => ( element ) => {\n\tfunction onKeyDownDeprecated( event ) {\n\t\tif ( event.keyCode !== ENTER ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { onReplace, onSplit } = props.current;\n\n\t\tif ( onReplace && onSplit ) {\n\t\t\tevent.__deprecatedOnSplit = true;\n\t\t}\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element.\n\t\tif ( event.target !== element ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.keyCode !== ENTER ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst {\n\t\t\tvalue,\n\t\t\tonChange,\n\t\t\tdisableLineBreaks,\n\t\t\tonSplitAtEnd,\n\t\t\tonSplitAtDoubleLineEnd,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\tevent.preventDefault();\n\n\t\tconst { text, start, end } = value;\n\n\t\tif ( event.shiftKey ) {\n\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\tonChange( insert( value, '\\n' ) );\n\t\t\t}\n\t\t} else if ( onSplitAtEnd && start === end && end === text.length ) {\n\t\t\tonSplitAtEnd();\n\t\t} else if (\n\t\t\t// For some blocks it's desirable to split at the end of the\n\t\t\t// block when there are two line breaks at the end of the\n\t\t\t// block, so triple Enter exits the block.\n\t\t\tonSplitAtDoubleLineEnd &&\n\t\t\tstart === end &&\n\t\t\tend === text.length &&\n\t\t\ttext.slice( -2 ) === '\\n\\n'\n\t\t) {\n\t\t\tregistry.batch( () => {\n\t\t\t\tconst _value = { ...value };\n\t\t\t\t_value.start = _value.end - 2;\n\t\t\t\tonChange( remove( _value ) );\n\t\t\t\tonSplitAtDoubleLineEnd();\n\t\t\t} );\n\t\t} else if ( ! disableLineBreaks ) {\n\t\t\tonChange( insert( value, '\\n' ) );\n\t\t}\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\tconst unsubscribeKeyDown = subscribeDelegatedListener(\n\t\tdefaultView,\n\t\t'keydown',\n\t\tonKeyDown\n\t);\n\telement.addEventListener( 'keydown', onKeyDownDeprecated );\n\treturn () => {\n\t\tunsubscribeKeyDown();\n\t\telement.removeEventListener( 'keydown', onKeyDownDeprecated );\n\t};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AE,mBAAoB;AACjC,mBAAU,yBAAQ,OAAO,IAAK,CAAE;AAAA,IACjC;AAAA,EACD;AAEA,QAAM,EAAE,YAAY,IAAI,QAAQ;AAIhC,QAAM,qBAAqB;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,UAAQ,iBAAkB,WAAW,mBAAoB;AACzD,SAAO,MAAM;AACZ,uBAAmB;AACnB,YAAQ,oBAAqB,WAAW,mBAAoB;AAAA,EAC7D;AACD;",
|
|
6
|
+
"names": ["composePrivateApis"]
|
|
7
7
|
}
|
|
@@ -26,9 +26,12 @@ module.exports = __toCommonJS(paste_handler_exports);
|
|
|
26
26
|
var import_blocks = require("@wordpress/blocks");
|
|
27
27
|
var import_rich_text = require("@wordpress/rich-text");
|
|
28
28
|
var import_url = require("@wordpress/url");
|
|
29
|
+
var import_compose = require("@wordpress/compose");
|
|
29
30
|
var import_store = require("../../../store/index.cjs");
|
|
30
31
|
var import_utils = require("../utils.cjs");
|
|
31
32
|
var import_pasting = require("../../../utils/pasting.cjs");
|
|
33
|
+
var import_lock_unlock = require("../../../lock-unlock.cjs");
|
|
34
|
+
var { subscribeDelegatedListener } = (0, import_lock_unlock.unlock)(import_compose.privateApis);
|
|
32
35
|
var paste_handler_default = (props) => (element) => {
|
|
33
36
|
function _onPaste(event) {
|
|
34
37
|
const {
|
|
@@ -114,9 +117,6 @@ var paste_handler_default = (props) => (element) => {
|
|
|
114
117
|
onReplace(content, content.length - 1, -1);
|
|
115
118
|
}
|
|
116
119
|
const { defaultView } = element.ownerDocument;
|
|
117
|
-
defaultView
|
|
118
|
-
return () => {
|
|
119
|
-
defaultView.removeEventListener("paste", _onPaste);
|
|
120
|
-
};
|
|
120
|
+
return subscribeDelegatedListener(defaultView, "paste", _onPaste);
|
|
121
121
|
};
|
|
122
122
|
//# sourceMappingURL=paste-handler.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/rich-text/event-listeners/paste-handler.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { pasteHandler } from '@wordpress/blocks';\nimport { isEmpty, insert, create } from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { addActiveFormats } from '../utils';\nimport { getPasteEventData } from '../../../utils/pasting';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\nexport default ( props ) => ( element ) => {\n\tfunction _onPaste( event ) {\n\t\tconst {\n\t\t\tdisableFormats,\n\t\t\tonChange,\n\t\t\tvalue,\n\t\t\tformatTypes,\n\t\t\ttagName,\n\t\t\tonReplace,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\tpreserveWhiteSpace,\n\t\t\tpastePlainText,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element or inside the element.\n\t\tif ( ! element.contains( event.target ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { plainText, html } = getPasteEventData( event );\n\n\t\tevent.preventDefault();\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\t// `pasteHandler` also logs this, but we're not using `pasteHandler` in\n\t\t// every case.\n\t\twindow.console.log( 'Received HTML (RichText):\\n\\n', html );\n\t\twindow.console.log( 'Received plain text (RichText):\\n\\n', plainText );\n\n\t\tif ( disableFormats ) {\n\t\t\tonChange( insert( value, plainText ) );\n\t\t\treturn;\n\t\t}\n\n\t\tconst isInternal =\n\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\tfunction pasteInline( content ) {\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumulator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumulator === value ) {\n\t\t\t\t\t\taccumulator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t} else {\n\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t}\n\t\t}\n\n\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t// without filtering the data. The filters are only meant for externally\n\t\t// pasted content and remove inline styles.\n\t\tif ( isInternal ) {\n\t\t\tpasteInline( html );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( pastePlainText ) {\n\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\treturn;\n\t\t}\n\n\t\tlet mode = 'INLINE';\n\n\t\tconst trimmedPlainText = plainText.trim();\n\n\t\tif (\n\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\tisEmpty( value ) &&\n\t\t\tisURL( trimmedPlainText ) &&\n\t\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\t\t/^https?:/.test( trimmedPlainText )\n\t\t) {\n\t\t\tmode = 'BLOCKS';\n\t\t}\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode,\n\t\t\ttagName,\n\t\t\tpreserveWhiteSpace,\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tpasteInline( content );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! content.length || ! onReplace || ! isEmpty( value ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Record an intermediate paragraph-with-URL state so a single undo\n\t\t// after the URL \u2192 block transformation restores the pasted link.\n\t\tif ( mode === 'BLOCKS' ) {\n\t\t\tpasteInline( html );\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\t}\n\n\t\tonReplace( content, content.length - 1, -1 );\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA6B;AAC7B,uBAAwC;AACxC,iBAAsB;
|
|
6
|
-
"names": ["content", "blockEditorStore"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { pasteHandler } from '@wordpress/blocks';\nimport { isEmpty, insert, create } from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { addActiveFormats } from '../utils';\nimport { getPasteEventData } from '../../../utils/pasting';\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\nexport default ( props ) => ( element ) => {\n\tfunction _onPaste( event ) {\n\t\tconst {\n\t\t\tdisableFormats,\n\t\t\tonChange,\n\t\t\tvalue,\n\t\t\tformatTypes,\n\t\t\ttagName,\n\t\t\tonReplace,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\tpreserveWhiteSpace,\n\t\t\tpastePlainText,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element or inside the element.\n\t\tif ( ! element.contains( event.target ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { plainText, html } = getPasteEventData( event );\n\n\t\tevent.preventDefault();\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\t// `pasteHandler` also logs this, but we're not using `pasteHandler` in\n\t\t// every case.\n\t\twindow.console.log( 'Received HTML (RichText):\\n\\n', html );\n\t\twindow.console.log( 'Received plain text (RichText):\\n\\n', plainText );\n\n\t\tif ( disableFormats ) {\n\t\t\tonChange( insert( value, plainText ) );\n\t\t\treturn;\n\t\t}\n\n\t\tconst isInternal =\n\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\tfunction pasteInline( content ) {\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumulator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumulator === value ) {\n\t\t\t\t\t\taccumulator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t} else {\n\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t}\n\t\t}\n\n\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t// without filtering the data. The filters are only meant for externally\n\t\t// pasted content and remove inline styles.\n\t\tif ( isInternal ) {\n\t\t\tpasteInline( html );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( pastePlainText ) {\n\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\treturn;\n\t\t}\n\n\t\tlet mode = 'INLINE';\n\n\t\tconst trimmedPlainText = plainText.trim();\n\n\t\tif (\n\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\tisEmpty( value ) &&\n\t\t\tisURL( trimmedPlainText ) &&\n\t\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\t\t/^https?:/.test( trimmedPlainText )\n\t\t) {\n\t\t\tmode = 'BLOCKS';\n\t\t}\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode,\n\t\t\ttagName,\n\t\t\tpreserveWhiteSpace,\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tpasteInline( content );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! content.length || ! onReplace || ! isEmpty( value ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Record an intermediate paragraph-with-URL state so a single undo\n\t\t// after the URL \u2192 block transformation restores the pasted link.\n\t\tif ( mode === 'BLOCKS' ) {\n\t\t\tpasteInline( html );\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\t}\n\n\t\tonReplace( content, content.length - 1, -1 );\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\treturn subscribeDelegatedListener( defaultView, 'paste', _onPaste );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA6B;AAC7B,uBAAwC;AACxC,iBAAsB;AACtB,qBAAkD;AAKlD,mBAA0C;AAC1C,mBAAiC;AACjC,qBAAkC;AAClC,yBAAuB;AAEvB,IAAM,EAAE,2BAA2B,QAAI,2BAAQ,eAAAA,WAAmB;AAIlE,IAAO,wBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,SAAU,OAAQ;AAC1B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,MAAM;AAIV,QAAK,CAAE,QAAQ,SAAU,MAAM,MAAO,GAAI;AACzC;AAAA,IACD;AAEA,QAAK,MAAM,kBAAmB;AAC7B;AAAA,IACD;AA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AAAA,IACD;AAEA,QAAK,CAAE,QAAQ,UAAU,CAAE,aAAa,KAAE,0BAAS,KAAM,GAAI;AAC5D;AAAA,IACD;AAIA,QAAK,SAAS,UAAW;AACxB,kBAAa,IAAK;AAClB,eACE,SAAU,aAAAC,KAAiB,EAC3B,qCAAqC;AAAA,IACxC;AAEA,cAAW,SAAS,QAAQ,SAAS,GAAG,EAAG;AAAA,EAC5C;AAEA,QAAM,EAAE,YAAY,IAAI,QAAQ;AAIhC,SAAO,2BAA4B,aAAa,SAAS,QAAS;AACnE;",
|
|
6
|
+
"names": ["composePrivateApis", "content", "blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -48,6 +48,7 @@ var import_utils = require("./utils.cjs");
|
|
|
48
48
|
var import_store = require("../store/index.cjs");
|
|
49
49
|
var import_background_panel = __toESM(require("../components/global-styles/background-panel.cjs"));
|
|
50
50
|
var import_private_keys = require("../store/private-keys.cjs");
|
|
51
|
+
var import_block_style_state = require("./block-style-state.cjs");
|
|
51
52
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
53
|
var BACKGROUND_SUPPORT_KEY = "background";
|
|
53
54
|
var BACKGROUND_BLOCK_DEFAULT_VALUES = {
|
|
@@ -131,6 +132,7 @@ function BackgroundImagePanel({
|
|
|
131
132
|
setAttributes,
|
|
132
133
|
settings
|
|
133
134
|
}) {
|
|
135
|
+
const selectedState = (0, import_block_style_state.useBlockStyleState)();
|
|
134
136
|
const { style, className, inheritedValue } = (0, import_data.useSelect)(
|
|
135
137
|
(select) => {
|
|
136
138
|
const { getBlockAttributes, getSettings } = select(import_store.store);
|
|
@@ -168,7 +170,12 @@ function BackgroundImagePanel({
|
|
|
168
170
|
if (!(0, import_background_panel.useHasBackgroundPanel)(settings) || !hasBackgroundSupport(name)) {
|
|
169
171
|
return null;
|
|
170
172
|
}
|
|
171
|
-
const
|
|
173
|
+
const isStateSelected = !(0, import_block_style_state.isDefaultBlockStyleState)(selectedState);
|
|
174
|
+
const onChange = isStateSelected ? (newStyle) => {
|
|
175
|
+
setAttributes({
|
|
176
|
+
style: (0, import_block_style_state.setStyleForState)(style, selectedState, newStyle)
|
|
177
|
+
});
|
|
178
|
+
} : (newStyle) => {
|
|
172
179
|
const isMigrating = backgroundGradientSupported && !!style?.color?.gradient;
|
|
173
180
|
const newAttributes = {
|
|
174
181
|
style: (0, import_utils.cleanEmptyObject)(
|
|
@@ -182,7 +189,10 @@ function BackgroundImagePanel({
|
|
|
182
189
|
)
|
|
183
190
|
};
|
|
184
191
|
if (isMigrating && !!newStyle?.background?.gradient) {
|
|
185
|
-
newAttributes.className = (0, import_clsx.default)(
|
|
192
|
+
newAttributes.className = (0, import_clsx.default)(
|
|
193
|
+
className,
|
|
194
|
+
"has-background"
|
|
195
|
+
);
|
|
186
196
|
} else if (!newStyle?.background?.gradient && className?.includes("has-background")) {
|
|
187
197
|
newAttributes.className = className.split(" ").filter((c) => c !== "has-background").join(" ") || void 0;
|
|
188
198
|
}
|
|
@@ -216,7 +226,7 @@ function BackgroundImagePanel({
|
|
|
216
226
|
settings: updatedSettings,
|
|
217
227
|
onChange,
|
|
218
228
|
defaultControls,
|
|
219
|
-
value: styleValue
|
|
229
|
+
value: isStateSelected ? (0, import_block_style_state.getStyleForState)(style, selectedState) : styleValue
|
|
220
230
|
}
|
|
221
231
|
);
|
|
222
232
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/background.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tdefault as StylesBackgroundPanel,\n\tuseHasBackgroundPanel,\n\thasBackgroundImageValue,\n\thasBackgroundGradientValue,\n} from '../components/global-styles/background-panel';\nimport { globalStylesDataKey } from '../store/private-keys';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values.\nexport const BACKGROUND_BLOCK_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n\tbackgroundPosition: '50% 50%', // used only when backgroundSize is 'contain'.\n};\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat ||\n\t\t\t!! support?.gradient\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function setBackgroundStyleDefaults( backgroundStyle ) {\n\tif ( ! backgroundStyle || ! backgroundStyle?.backgroundImage?.url ) {\n\t\treturn;\n\t}\n\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize,\n\t\t};\n\t}\n\n\tif (\n\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t! backgroundStyle?.backgroundPosition\n\t) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundPosition:\n\t\t\t\tBACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition,\n\t\t};\n\t}\n\treturn backgroundStylesWithDefaults;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundStyles = setBackgroundStyleDefaults( style?.background );\n\n\tif ( ! backgroundStyles ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tstyle: {\n\t\t\t...backgroundStyles,\n\t\t},\n\t};\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ||\n\t\thasBackgroundGradientValue( style )\n\t\t? 'has-background'\n\t\t: '';\n}\n\nfunction BackgroundInspectorControl( {\n\tchildren,\n\tbackgroundGradientSupported = false,\n} ) {\n\tconst resetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst updatedClassName = attributes.className?.includes(\n\t\t\t\t'has-background'\n\t\t\t)\n\t\t\t\t? attributes.className\n\t\t\t\t\t\t.split( ' ' )\n\t\t\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t\t\t.join( ' ' ) || undefined\n\t\t\t\t: attributes.className;\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\tclassName: updatedClassName,\n\t\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t\t...attributes.style,\n\t\t\t\t\tbackground: undefined,\n\t\t\t\t\tcolor: backgroundGradientSupported\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...attributes.style?.color,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: attributes.style?.color,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ backgroundGradientSupported ]\n\t);\n\treturn (\n\t\t<InspectorControls group=\"background\" resetAllFilter={ resetAllFilter }>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BackgroundImagePanel( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tsettings,\n} ) {\n\tconst { style, className, inheritedValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst _settings = getSettings();\n\t\t\tconst blockAttributes = getBlockAttributes( clientId );\n\t\t\treturn {\n\t\t\t\tstyle: blockAttributes?.style,\n\t\t\t\tclassName: blockAttributes?.className,\n\t\t\t\t/*\n\t\t\t\t * To ensure we pass down the right inherited values:\n\t\t\t\t * @TODO 1. Pass inherited value down to all block style controls,\n\t\t\t\t * See: packages/block-editor/src/hooks/style.js\n\t\t\t\t * @TODO 2. Add support for block style variations,\n\t\t\t\t * See implementation: packages/block-editor/src/hooks/block-style-variation.js\n\t\t\t\t */\n\t\t\t\tinheritedValue:\n\t\t\t\t\t_settings[ globalStylesDataKey ]?.blocks?.[ name ],\n\t\t\t};\n\t\t},\n\t\t[ clientId, name ]\n\t);\n\n\tconst backgroundGradientSupported = hasBackgroundSupport(\n\t\tname,\n\t\t'gradient'\n\t);\n\n\t// Must be declared before the early return to follow Rules of Hooks.\n\t// Passes backgroundGradientSupported so that \"Reset All\" also clears\n\t// the legacy color.gradient value when background.gradient is supported.\n\tconst as = useCallback(\n\t\t( { children } ) => (\n\t\t\t<BackgroundInspectorControl\n\t\t\t\tbackgroundGradientSupported={ backgroundGradientSupported }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</BackgroundInspectorControl>\n\t\t),\n\t\t[ backgroundGradientSupported ]\n\t);\n\n\tif (\n\t\t! useHasBackgroundPanel( settings ) ||\n\t\t! hasBackgroundSupport( name )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst onChange = ( newStyle ) => {\n\t\tconst isMigrating =\n\t\t\tbackgroundGradientSupported && !! style?.color?.gradient;\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject(\n\t\t\t\tbackgroundGradientSupported\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...newStyle,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...newStyle?.color,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }\n\t\t\t\t\t: newStyle\n\t\t\t),\n\t\t};\n\n\t\t// When migrating from color.gradient to background.gradient, preserve\n\t\t// the has-background class so existing styles relying on it (e.g.\n\t\t// theme padding) are not silently broken. Only add the class when a\n\t\t// gradient value is being set \u2014 not when it is being cleared/reset.\n\t\t// Conversely, if the gradient is cleared and has-background was added\n\t\t// during a previous migration, remove it so it does not linger.\n\t\tif ( isMigrating && !! newStyle?.background?.gradient ) {\n\t\t\tnewAttributes.className = clsx(
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAAgC;AAChC,kBAA0B;AAC1B,qBAA4B;AAK5B,gCAA8B;AAC9B,mBAAiC;AACjC,mBAA0C;AAC1C,8BAKO;AACP,0BAAoC;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tdefault as StylesBackgroundPanel,\n\tuseHasBackgroundPanel,\n\thasBackgroundImageValue,\n\thasBackgroundGradientValue,\n} from '../components/global-styles/background-panel';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values.\nexport const BACKGROUND_BLOCK_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n\tbackgroundPosition: '50% 50%', // used only when backgroundSize is 'contain'.\n};\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat ||\n\t\t\t!! support?.gradient\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function setBackgroundStyleDefaults( backgroundStyle ) {\n\tif ( ! backgroundStyle || ! backgroundStyle?.backgroundImage?.url ) {\n\t\treturn;\n\t}\n\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize,\n\t\t};\n\t}\n\n\tif (\n\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t! backgroundStyle?.backgroundPosition\n\t) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundPosition:\n\t\t\t\tBACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition,\n\t\t};\n\t}\n\treturn backgroundStylesWithDefaults;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundStyles = setBackgroundStyleDefaults( style?.background );\n\n\tif ( ! backgroundStyles ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tstyle: {\n\t\t\t...backgroundStyles,\n\t\t},\n\t};\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ||\n\t\thasBackgroundGradientValue( style )\n\t\t? 'has-background'\n\t\t: '';\n}\n\nfunction BackgroundInspectorControl( {\n\tchildren,\n\tbackgroundGradientSupported = false,\n} ) {\n\tconst resetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst updatedClassName = attributes.className?.includes(\n\t\t\t\t'has-background'\n\t\t\t)\n\t\t\t\t? attributes.className\n\t\t\t\t\t\t.split( ' ' )\n\t\t\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t\t\t.join( ' ' ) || undefined\n\t\t\t\t: attributes.className;\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\tclassName: updatedClassName,\n\t\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t\t...attributes.style,\n\t\t\t\t\tbackground: undefined,\n\t\t\t\t\tcolor: backgroundGradientSupported\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...attributes.style?.color,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: attributes.style?.color,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ backgroundGradientSupported ]\n\t);\n\treturn (\n\t\t<InspectorControls group=\"background\" resetAllFilter={ resetAllFilter }>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BackgroundImagePanel( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tsettings,\n} ) {\n\tconst selectedState = useBlockStyleState();\n\tconst { style, className, inheritedValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst _settings = getSettings();\n\t\t\tconst blockAttributes = getBlockAttributes( clientId );\n\t\t\treturn {\n\t\t\t\tstyle: blockAttributes?.style,\n\t\t\t\tclassName: blockAttributes?.className,\n\t\t\t\t/*\n\t\t\t\t * To ensure we pass down the right inherited values:\n\t\t\t\t * @TODO 1. Pass inherited value down to all block style controls,\n\t\t\t\t * See: packages/block-editor/src/hooks/style.js\n\t\t\t\t * @TODO 2. Add support for block style variations,\n\t\t\t\t * See implementation: packages/block-editor/src/hooks/block-style-variation.js\n\t\t\t\t */\n\t\t\t\tinheritedValue:\n\t\t\t\t\t_settings[ globalStylesDataKey ]?.blocks?.[ name ],\n\t\t\t};\n\t\t},\n\t\t[ clientId, name ]\n\t);\n\n\tconst backgroundGradientSupported = hasBackgroundSupport(\n\t\tname,\n\t\t'gradient'\n\t);\n\n\t// Must be declared before the early return to follow Rules of Hooks.\n\t// Passes backgroundGradientSupported so that \"Reset All\" also clears\n\t// the legacy color.gradient value when background.gradient is supported.\n\tconst as = useCallback(\n\t\t( { children } ) => (\n\t\t\t<BackgroundInspectorControl\n\t\t\t\tbackgroundGradientSupported={ backgroundGradientSupported }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</BackgroundInspectorControl>\n\t\t),\n\t\t[ backgroundGradientSupported ]\n\t);\n\n\tif (\n\t\t! useHasBackgroundPanel( settings ) ||\n\t\t! hasBackgroundSupport( name )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\n\tconst onChange = isStateSelected\n\t\t? ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t\t} );\n\t\t }\n\t\t: ( newStyle ) => {\n\t\t\t\tconst isMigrating =\n\t\t\t\t\tbackgroundGradientSupported && !! style?.color?.gradient;\n\t\t\t\tconst newAttributes = {\n\t\t\t\t\tstyle: cleanEmptyObject(\n\t\t\t\t\t\tbackgroundGradientSupported\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t...newStyle,\n\t\t\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t\t\t...newStyle?.color,\n\t\t\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: newStyle\n\t\t\t\t\t),\n\t\t\t\t};\n\n\t\t\t\t// When migrating from color.gradient to background.gradient, preserve\n\t\t\t\t// the has-background class so existing styles relying on it (e.g.\n\t\t\t\t// theme padding) are not silently broken. Only add the class when a\n\t\t\t\t// gradient value is being set \u2014 not when it is being cleared/reset.\n\t\t\t\t// Conversely, if the gradient is cleared and has-background was added\n\t\t\t\t// during a previous migration, remove it so it does not linger.\n\t\t\t\tif ( isMigrating && !! newStyle?.background?.gradient ) {\n\t\t\t\t\tnewAttributes.className = clsx(\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t'has-background'\n\t\t\t\t\t);\n\t\t\t\t} else if (\n\t\t\t\t\t! newStyle?.background?.gradient &&\n\t\t\t\t\tclassName?.includes( 'has-background' )\n\t\t\t\t) {\n\t\t\t\t\tnewAttributes.className =\n\t\t\t\t\t\tclassName\n\t\t\t\t\t\t\t.split( ' ' )\n\t\t\t\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t\t\t\t.join( ' ' ) || undefined;\n\t\t\t\t}\n\n\t\t\t\tsetAttributes( newAttributes );\n\t\t };\n\n\t// When background.gradient is supported but not yet explicitly set, fall\n\t// back to color.gradient for display. Any write from this panel migrates\n\t// the value to background.gradient and clears color.gradient atomically.\n\tconst styleValue =\n\t\tbackgroundGradientSupported &&\n\t\t! style?.background?.gradient &&\n\t\tstyle?.color?.gradient\n\t\t\t? {\n\t\t\t\t\t...style,\n\t\t\t\t\tbackground: {\n\t\t\t\t\t\t...style?.background,\n\t\t\t\t\t\tgradient: style?.color?.gradient,\n\t\t\t\t\t},\n\t\t\t }\n\t\t\t: style;\n\n\tconst updatedSettings = {\n\t\t...settings,\n\t\tbackground: {\n\t\t\t...settings.background,\n\t\t\tbackgroundSize:\n\t\t\t\tsettings?.background?.backgroundSize &&\n\t\t\t\thasBackgroundSupport( name, 'backgroundSize' ),\n\t\t},\n\t};\n\n\tconst defaultControls = getBlockSupport( name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<StylesBackgroundPanel\n\t\t\tinheritedValue={ inheritedValue }\n\t\t\tas={ as }\n\t\t\tpanelId={ clientId }\n\t\t\tdefaultValues={ BACKGROUND_BLOCK_DEFAULT_VALUES }\n\t\t\tsettings={ updatedSettings }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tvalue={\n\t\t\t\tisStateSelected\n\t\t\t\t\t? getStyleForState( style, selectedState )\n\t\t\t\t\t: styleValue\n\t\t\t}\n\t\t/>\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport: hasBackgroundSupport,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAAgC;AAChC,kBAA0B;AAC1B,qBAA4B;AAK5B,gCAA8B;AAC9B,mBAAiC;AACjC,mBAA0C;AAC1C,8BAKO;AACP,0BAAoC;AACpC,+BAKO;AAkIL;AAhIK,IAAM,yBAAyB;AAG/B,IAAM,kCAAkC;AAAA,EAC9C,gBAAgB;AAAA,EAChB,oBAAoB;AAAA;AACrB;AAUO,SAAS,qBAAsB,WAAW,UAAU,OAAQ;AAClE,QAAM,cAAU,+BAAiB,WAAW,sBAAuB;AAEnE,MAAK,YAAY,MAAO;AACvB,WAAO;AAAA,EACR;AAEA,MAAK,YAAY,OAAQ;AACxB,WACC,CAAC,CAAE,SAAS,mBACZ,CAAC,CAAE,SAAS,kBACZ,CAAC,CAAE,SAAS,oBACZ,CAAC,CAAE,SAAS;AAAA,EAEd;AAEA,SAAO,CAAC,CAAE,UAAW,OAAQ;AAC9B;AAEO,SAAS,2BAA4B,iBAAkB;AAC7D,MAAK,CAAE,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