@wordpress/block-editor 11.5.0 → 11.7.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 +6 -0
- package/README.md +4 -0
- package/build/components/block-list/block-html.js +1 -3
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block-invalid-warning.js +63 -80
- package/build/components/block-list/block-invalid-warning.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -23
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/editor-styles/index.js +20 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +306 -0
- package/build/components/global-styles/border-panel.js.map +1 -0
- package/build/components/global-styles/color-panel.js +583 -0
- package/build/components/global-styles/color-panel.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +8 -30
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +129 -0
- package/build/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build/components/global-styles/hooks.js +109 -3
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +36 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +66 -45
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +180 -99
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/image-size-control/index.js +8 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inserter/index.js +29 -17
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/menu.js +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -2
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +10 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -1
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +43 -7
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/line-height-control/index.js +15 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-item.js +5 -2
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/list-view/appender.js +105 -0
- package/build/components/list-view/appender.js.map +1 -0
- package/build/components/list-view/block.js +5 -5
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +25 -5
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +37 -13
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -2
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/media-replace-flow/index.js +13 -4
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +28 -3
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +5 -3
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +9 -7
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +0 -1
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/provider/use-block-sync.js +17 -3
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/format-edit.js +2 -30
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +0 -3
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/writing-flow/use-input.js +4 -8
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/hooks/border.js +90 -240
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +92 -229
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +4 -2
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/{color-panel.js → contrast-checker.js} +11 -49
- package/build/hooks/contrast-checker.js.map +1 -0
- package/build/hooks/custom-class-name.js +4 -4
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-class-name.native.js +3 -4
- package/build/hooks/custom-class-name.native.js.map +1 -1
- package/build/hooks/dimensions.js +0 -1
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +3 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/layout.js +19 -22
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +2 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +23 -26
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +7 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +2 -2
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +50 -75
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +6 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +165 -0
- package/build/layouts/grid.js.map +1 -0
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/private-apis.js +7 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +10 -8
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +19 -3
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +76 -0
- package/build/utils/object.js.map +1 -0
- package/build/utils/parse-css-unit-to-px.js +15 -9
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-list/block-html.js +1 -3
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.js +66 -78
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -22
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/editor-styles/index.js +19 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +291 -0
- package/build-module/components/global-styles/border-panel.js.map +1 -0
- package/build-module/components/global-styles/color-panel.js +554 -0
- package/build-module/components/global-styles/color-panel.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +7 -30
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +120 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +104 -3
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +65 -46
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +181 -100
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/image-size-control/index.js +8 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inserter/index.js +28 -16
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/menu.js +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +4 -2
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +10 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -1
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +42 -7
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/line-height-control/index.js +15 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +4 -2
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/list-view/appender.js +88 -0
- package/build-module/components/list-view/appender.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -4
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +22 -5
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +32 -12
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -2
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +12 -4
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +28 -4
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +5 -3
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +9 -7
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +0 -1
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +17 -3
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +3 -31
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +0 -3
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +4 -8
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/hooks/border.js +92 -240
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +90 -232
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +4 -2
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/{color-panel.js → contrast-checker.js} +10 -44
- package/build-module/hooks/contrast-checker.js.map +1 -0
- package/build-module/hooks/custom-class-name.js +4 -4
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-class-name.native.js +3 -4
- package/build-module/hooks/custom-class-name.native.js.map +1 -1
- package/build-module/hooks/dimensions.js +0 -1
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -2
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/layout.js +19 -22
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +3 -3
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +23 -26
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +7 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +2 -2
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +48 -72
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +6 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +151 -0
- package/build-module/layouts/grid.js.map +1 -0
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/private-apis.js +5 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +10 -8
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +17 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +69 -0
- package/build-module/utils/object.js.map +1 -0
- package/build-module/utils/parse-css-unit-to-px.js +15 -9
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +32 -12
- package/build-style/style.css +32 -12
- package/package.json +31 -31
- package/src/components/block-draggable/content.scss +1 -1
- package/src/components/block-inspector/style.scss +3 -0
- package/src/components/block-list/block-html.js +1 -1
- package/src/components/block-list/block-invalid-warning.js +72 -64
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +20 -2
- package/src/components/block-preview/auto.js +2 -17
- package/src/components/block-preview/test/index.js +0 -2
- package/src/components/block-settings-menu-controls/index.js +2 -1
- package/src/components/block-styles/style.scss +2 -2
- package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +16 -14
- package/src/components/colors-gradients/style.scss +8 -8
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
- package/src/components/editor-styles/index.js +29 -1
- package/src/components/global-styles/border-panel.js +285 -0
- package/src/components/global-styles/color-panel.js +706 -0
- package/src/components/global-styles/dimensions-panel.js +13 -42
- package/src/components/global-styles/get-block-css-selector.js +129 -0
- package/src/components/global-styles/hooks.js +154 -1
- package/src/components/global-styles/index.js +3 -0
- package/src/components/global-styles/test/use-global-styles-output.js +31 -2
- package/src/components/global-styles/typography-panel.js +67 -45
- package/src/components/global-styles/use-global-styles-output.js +176 -93
- package/src/components/global-styles/utils.js +3 -0
- package/src/components/image-size-control/index.js +4 -3
- package/src/components/image-size-control/test/index.js +2 -2
- package/src/components/inner-blocks/README.md +1 -1
- package/src/components/inserter/index.js +30 -11
- package/src/components/inserter/menu.js +0 -1
- package/src/components/inserter/quick-inserter.js +2 -0
- package/src/components/inserter/search-results.js +7 -1
- package/src/components/inserter/style.scss +3 -0
- package/src/components/inserter/tabs.js +1 -9
- package/src/components/inspector-controls-tabs/position-controls-panel.js +40 -9
- package/src/components/line-height-control/index.js +10 -1
- package/src/components/link-control/index.js +1 -1
- package/src/components/link-control/search-item.js +3 -1
- package/src/components/link-control/style.scss +0 -4
- package/src/components/link-control/test/index.js +0 -2
- package/src/components/list-view/appender.js +101 -0
- package/src/components/list-view/block.js +5 -4
- package/src/components/list-view/branch.js +30 -1
- package/src/components/list-view/index.js +43 -10
- package/src/components/list-view/style.scss +19 -0
- package/src/components/list-view/use-block-selection.js +0 -2
- package/src/components/media-replace-flow/index.js +36 -24
- package/src/components/media-replace-flow/style.scss +5 -2
- package/src/components/off-canvas-editor/appender.js +31 -5
- package/src/components/off-canvas-editor/branch.js +3 -1
- package/src/components/off-canvas-editor/index.js +7 -7
- package/src/components/off-canvas-editor/link-ui.js +0 -1
- package/src/components/provider/use-block-sync.js +21 -4
- package/src/components/rich-text/format-edit.js +2 -32
- package/src/components/rich-text/format-toolbar-container.js +1 -7
- package/src/components/url-popover/test/index.js +0 -2
- package/src/components/writing-flow/use-input.js +4 -5
- package/src/hooks/border.js +93 -225
- package/src/hooks/color.js +120 -296
- package/src/hooks/content-lock-ui.js +6 -2
- package/src/hooks/{color-panel.js → contrast-checker.js} +10 -46
- package/src/hooks/custom-class-name.js +4 -4
- package/src/hooks/custom-class-name.native.js +3 -4
- package/src/hooks/dimensions.js +0 -1
- package/src/hooks/duotone.js +8 -5
- package/src/hooks/layout.js +19 -16
- package/src/hooks/position.js +3 -3
- package/src/hooks/style.js +29 -28
- package/src/hooks/supports.js +6 -0
- package/src/hooks/test/style.js +2 -1
- package/src/hooks/test/use-typography-props.js +2 -0
- package/src/hooks/test/utils.js +0 -104
- package/src/hooks/typography.js +2 -1
- package/src/hooks/utils.js +63 -70
- package/src/layouts/constrained.js +23 -17
- package/src/layouts/grid.js +172 -0
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/grid.js +21 -0
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +10 -8
- package/src/store/selectors.js +20 -3
- package/src/utils/object.js +69 -0
- package/src/utils/parse-css-unit-to-px.js +14 -9
- package/src/utils/test/object.js +107 -0
- package/src/utils/test/parse-css-unit-to-px.js +1 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/border-radius.js +0 -100
- package/build/hooks/border-radius.js.map +0 -1
- package/build/hooks/color-panel.js.map +0 -1
- package/build-module/hooks/border-radius.js +0 -84
- package/build-module/hooks/border-radius.js.map +0 -1
- package/build-module/hooks/color-panel.js.map +0 -1
- package/src/hooks/border-radius.js +0 -70
|
@@ -10,66 +10,20 @@ import classnames from 'classnames';
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
13
|
-
import {
|
|
13
|
+
import { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';
|
|
14
14
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
15
|
-
import { Platform } from '@wordpress/element';
|
|
15
|
+
import { Platform, useCallback, useMemo } from '@wordpress/element';
|
|
16
16
|
import { addFilter } from '@wordpress/hooks';
|
|
17
|
-
import { __ } from '@wordpress/i18n';
|
|
18
17
|
/**
|
|
19
18
|
* Internal dependencies
|
|
20
19
|
*/
|
|
21
20
|
|
|
22
|
-
import { BorderRadiusEdit, hasBorderRadiusValue, resetBorderRadius } from './border-radius';
|
|
23
21
|
import { getColorClassName } from '../components/colors';
|
|
24
22
|
import InspectorControls from '../components/inspector-controls';
|
|
25
23
|
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
26
|
-
import
|
|
27
|
-
import {
|
|
24
|
+
import { cleanEmptyObject, shouldSkipSerialization, useBlockSettings } from './utils';
|
|
25
|
+
import { useHasBorderPanel, BorderPanel as StylesBorderPanel } from '../components/global-styles';
|
|
28
26
|
export const BORDER_SUPPORT_KEY = '__experimentalBorder';
|
|
29
|
-
const borderSides = ['top', 'right', 'bottom', 'left'];
|
|
30
|
-
|
|
31
|
-
const hasBorderValue = props => {
|
|
32
|
-
const {
|
|
33
|
-
borderColor,
|
|
34
|
-
style
|
|
35
|
-
} = props.attributes;
|
|
36
|
-
return isDefinedBorder(style === null || style === void 0 ? void 0 : style.border) || !!borderColor;
|
|
37
|
-
}; // The border color, style, and width are omitted so they get undefined. The
|
|
38
|
-
// border radius is separate and must retain its selection.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const resetBorder = _ref => {
|
|
42
|
-
var _style$border;
|
|
43
|
-
|
|
44
|
-
let {
|
|
45
|
-
attributes = {},
|
|
46
|
-
setAttributes
|
|
47
|
-
} = _ref;
|
|
48
|
-
const {
|
|
49
|
-
style
|
|
50
|
-
} = attributes;
|
|
51
|
-
setAttributes({
|
|
52
|
-
borderColor: undefined,
|
|
53
|
-
style: { ...style,
|
|
54
|
-
border: cleanEmptyObject({
|
|
55
|
-
radius: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const resetBorderFilter = newAttributes => {
|
|
62
|
-
var _newAttributes$style, _newAttributes$style$;
|
|
63
|
-
|
|
64
|
-
return { ...newAttributes,
|
|
65
|
-
borderColor: undefined,
|
|
66
|
-
style: { ...newAttributes.style,
|
|
67
|
-
border: {
|
|
68
|
-
radius: (_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : (_newAttributes$style$ = _newAttributes$style.border) === null || _newAttributes$style$ === void 0 ? void 0 : _newAttributes$style$.radius
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
27
|
|
|
74
28
|
const getColorByProperty = (colors, property, value) => {
|
|
75
29
|
let matchedColor;
|
|
@@ -84,12 +38,12 @@ const getColorByProperty = (colors, property, value) => {
|
|
|
84
38
|
return matchedColor;
|
|
85
39
|
};
|
|
86
40
|
|
|
87
|
-
export const getMultiOriginColor =
|
|
41
|
+
export const getMultiOriginColor = _ref => {
|
|
88
42
|
let {
|
|
89
43
|
colors,
|
|
90
44
|
namedColor,
|
|
91
45
|
customColor
|
|
92
|
-
} =
|
|
46
|
+
} = _ref;
|
|
93
47
|
|
|
94
48
|
// Search each origin (default, theme, or user) for matching color by name.
|
|
95
49
|
if (namedColor) {
|
|
@@ -114,60 +68,6 @@ export const getMultiOriginColor = _ref2 => {
|
|
|
114
68
|
};
|
|
115
69
|
};
|
|
116
70
|
|
|
117
|
-
const getBorderObject = (attributes, colors) => {
|
|
118
|
-
const {
|
|
119
|
-
borderColor,
|
|
120
|
-
style
|
|
121
|
-
} = attributes;
|
|
122
|
-
const {
|
|
123
|
-
border: borderStyles
|
|
124
|
-
} = style || {}; // If we have a named color for a flat border. Fetch that color object and
|
|
125
|
-
// apply that color's value to the color property within the style object.
|
|
126
|
-
|
|
127
|
-
if (borderColor) {
|
|
128
|
-
const {
|
|
129
|
-
color
|
|
130
|
-
} = getMultiOriginColor({
|
|
131
|
-
colors,
|
|
132
|
-
namedColor: borderColor
|
|
133
|
-
});
|
|
134
|
-
return color ? { ...borderStyles,
|
|
135
|
-
color
|
|
136
|
-
} : borderStyles;
|
|
137
|
-
} // Individual side border color slugs are stored within the border style
|
|
138
|
-
// object. If we don't have a border styles object we have nothing further
|
|
139
|
-
// to hydrate.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (!borderStyles) {
|
|
143
|
-
return borderStyles;
|
|
144
|
-
} // If we have named colors for the individual side borders, retrieve their
|
|
145
|
-
// related color objects and apply the real color values to the split
|
|
146
|
-
// border objects.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const hydratedBorderStyles = { ...borderStyles
|
|
150
|
-
};
|
|
151
|
-
borderSides.forEach(side => {
|
|
152
|
-
var _hydratedBorderStyles;
|
|
153
|
-
|
|
154
|
-
const colorSlug = getColorSlugFromVariable((_hydratedBorderStyles = hydratedBorderStyles[side]) === null || _hydratedBorderStyles === void 0 ? void 0 : _hydratedBorderStyles.color);
|
|
155
|
-
|
|
156
|
-
if (colorSlug) {
|
|
157
|
-
const {
|
|
158
|
-
color
|
|
159
|
-
} = getMultiOriginColor({
|
|
160
|
-
colors,
|
|
161
|
-
namedColor: colorSlug
|
|
162
|
-
});
|
|
163
|
-
hydratedBorderStyles[side] = { ...hydratedBorderStyles[side],
|
|
164
|
-
color
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
return hydratedBorderStyles;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
71
|
function getColorSlugFromVariable(value) {
|
|
172
72
|
const namedColor = /var:preset\|color\|(.+)/.exec(value);
|
|
173
73
|
|
|
@@ -178,142 +78,94 @@ function getColorSlugFromVariable(value) {
|
|
|
178
78
|
return null;
|
|
179
79
|
}
|
|
180
80
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
} = attributes;
|
|
190
|
-
const {
|
|
191
|
-
colors
|
|
192
|
-
} = useMultipleOriginColorsAndGradients();
|
|
193
|
-
const isSupported = hasBorderSupport(props.name);
|
|
194
|
-
const isColorSupported = useSetting('border.color') && hasBorderSupport(props.name, 'color');
|
|
195
|
-
const isRadiusSupported = useSetting('border.radius') && hasBorderSupport(props.name, 'radius');
|
|
196
|
-
const isStyleSupported = useSetting('border.style') && hasBorderSupport(props.name, 'style');
|
|
197
|
-
const isWidthSupported = useSetting('border.width') && hasBorderSupport(props.name, 'width');
|
|
198
|
-
const isDisabled = [!isColorSupported, !isRadiusSupported, !isStyleSupported, !isWidthSupported].every(Boolean);
|
|
199
|
-
|
|
200
|
-
if (isDisabled || !isSupported) {
|
|
201
|
-
return null;
|
|
81
|
+
function styleToAttributes(style) {
|
|
82
|
+
var _style$border;
|
|
83
|
+
|
|
84
|
+
if (hasSplitBorders(style === null || style === void 0 ? void 0 : style.border)) {
|
|
85
|
+
return {
|
|
86
|
+
style,
|
|
87
|
+
borderColor: undefined
|
|
88
|
+
};
|
|
202
89
|
}
|
|
203
90
|
|
|
204
|
-
const
|
|
205
|
-
const
|
|
91
|
+
const borderColorValue = style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color;
|
|
92
|
+
const borderColorSlug = borderColorValue !== null && borderColorValue !== void 0 && borderColorValue.startsWith('var:preset|color|') ? borderColorSlug.substring('var:preset|color|'.length) : undefined;
|
|
93
|
+
const updatedStyle = { ...style
|
|
94
|
+
};
|
|
95
|
+
updatedStyle.border = { ...updatedStyle.border,
|
|
96
|
+
color: borderColorSlug ? undefined : borderColorValue
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
style: cleanEmptyObject(updatedStyle),
|
|
100
|
+
borderColor: borderColorSlug
|
|
101
|
+
};
|
|
102
|
+
}
|
|
206
103
|
|
|
207
|
-
|
|
208
|
-
|
|
104
|
+
function attributesToStyle(attributes) {
|
|
105
|
+
var _attributes$style, _attributes$style2, _attributes$style3, _attributes$style3$bo;
|
|
209
106
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
// we update the color property.
|
|
221
|
-
//
|
|
222
|
-
// This deliberately overwrites `newBorderStyles` to avoid mutating
|
|
223
|
-
// the passed object which causes problems otherwise.
|
|
224
|
-
newBorderStyles = {
|
|
225
|
-
top: { ...newBorder.top
|
|
226
|
-
},
|
|
227
|
-
right: { ...newBorder.right
|
|
228
|
-
},
|
|
229
|
-
bottom: { ...newBorder.bottom
|
|
230
|
-
},
|
|
231
|
-
left: { ...newBorder.left
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
borderSides.forEach(side => {
|
|
235
|
-
var _newBorder$side;
|
|
236
|
-
|
|
237
|
-
if ((_newBorder$side = newBorder[side]) !== null && _newBorder$side !== void 0 && _newBorder$side.color) {
|
|
238
|
-
var _newBorder$side2;
|
|
239
|
-
|
|
240
|
-
const colorObject = getMultiOriginColor({
|
|
241
|
-
colors,
|
|
242
|
-
customColor: (_newBorder$side2 = newBorder[side]) === null || _newBorder$side2 === void 0 ? void 0 : _newBorder$side2.color
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
if (colorObject.slug) {
|
|
246
|
-
newBorderStyles[side].color = `var:preset|color|${colorObject.slug}`;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
} else if (newBorder !== null && newBorder !== void 0 && newBorder.color) {
|
|
251
|
-
// We have a flat border configuration. Apply named color slug to
|
|
252
|
-
// `borderColor` attribute and clear color style property if found.
|
|
253
|
-
const customColor = newBorder === null || newBorder === void 0 ? void 0 : newBorder.color;
|
|
254
|
-
const colorObject = getMultiOriginColor({
|
|
255
|
-
colors,
|
|
256
|
-
customColor
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
if (colorObject.slug) {
|
|
260
|
-
newBorderColor = colorObject.slug;
|
|
261
|
-
newBorderStyles.color = undefined;
|
|
262
|
-
}
|
|
263
|
-
} // Ensure previous border radius styles are maintained and clean
|
|
264
|
-
// overall result for empty objects or properties.
|
|
107
|
+
if (hasSplitBorders((_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.border)) {
|
|
108
|
+
return attributes.style;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return { ...attributes.style,
|
|
112
|
+
border: { ...((_attributes$style2 = attributes.style) === null || _attributes$style2 === void 0 ? void 0 : _attributes$style2.border),
|
|
113
|
+
color: attributes.borderColor ? 'var:preset|color|' + attributes.borderColor : (_attributes$style3 = attributes.style) === null || _attributes$style3 === void 0 ? void 0 : (_attributes$style3$bo = _attributes$style3.border) === null || _attributes$style3$bo === void 0 ? void 0 : _attributes$style3$bo.color
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
265
117
|
|
|
118
|
+
function BordersInspectorControl(_ref2) {
|
|
119
|
+
let {
|
|
120
|
+
children,
|
|
121
|
+
resetAllFilter
|
|
122
|
+
} = _ref2;
|
|
123
|
+
const attributesResetAllFilter = useCallback(attributes => {
|
|
124
|
+
const existingStyle = attributesToStyle(attributes);
|
|
125
|
+
const updatedStyle = resetAllFilter(existingStyle);
|
|
126
|
+
return { ...attributes,
|
|
127
|
+
...styleToAttributes(updatedStyle)
|
|
128
|
+
};
|
|
129
|
+
}, [resetAllFilter]);
|
|
130
|
+
return createElement(InspectorControls, {
|
|
131
|
+
group: "border",
|
|
132
|
+
resetAllFilter: attributesResetAllFilter
|
|
133
|
+
}, children);
|
|
134
|
+
}
|
|
266
135
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
136
|
+
export function BorderPanel(props) {
|
|
137
|
+
const {
|
|
138
|
+
clientId,
|
|
139
|
+
name,
|
|
140
|
+
attributes,
|
|
141
|
+
setAttributes
|
|
142
|
+
} = props;
|
|
143
|
+
const settings = useBlockSettings(name);
|
|
144
|
+
const isEnabled = useHasBorderPanel(settings);
|
|
145
|
+
const value = useMemo(() => {
|
|
146
|
+
return attributesToStyle({
|
|
147
|
+
style: attributes.style,
|
|
148
|
+
borderColor: attributes.borderColor
|
|
276
149
|
});
|
|
150
|
+
}, [attributes.style, attributes.borderColor]);
|
|
151
|
+
|
|
152
|
+
const onChange = newStyle => {
|
|
153
|
+
setAttributes(styleToAttributes(newStyle));
|
|
277
154
|
};
|
|
278
155
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
enableStyle: isStyleSupported,
|
|
293
|
-
onChange: onBorderChange,
|
|
294
|
-
popoverOffset: 40,
|
|
295
|
-
popoverPlacement: "left-start",
|
|
296
|
-
size: "__unstable-large",
|
|
297
|
-
value: hydratedBorder,
|
|
298
|
-
__experimentalIsRenderedInSidebar: true
|
|
299
|
-
})), isRadiusSupported && createElement(ToolsPanelItem, {
|
|
300
|
-
hasValue: () => hasBorderRadiusValue(props),
|
|
301
|
-
label: __('Radius'),
|
|
302
|
-
onDeselect: () => resetBorderRadius(props),
|
|
303
|
-
isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.radius,
|
|
304
|
-
resetAllFilter: newAttributes => {
|
|
305
|
-
var _newAttributes$style2;
|
|
306
|
-
|
|
307
|
-
return { ...newAttributes,
|
|
308
|
-
style: { ...newAttributes.style,
|
|
309
|
-
border: { ...((_newAttributes$style2 = newAttributes.style) === null || _newAttributes$style2 === void 0 ? void 0 : _newAttributes$style2.border),
|
|
310
|
-
radius: undefined
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
},
|
|
315
|
-
panelId: clientId
|
|
316
|
-
}, createElement(BorderRadiusEdit, props)));
|
|
156
|
+
if (!isEnabled) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const defaultControls = getBlockSupport(props.name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']);
|
|
161
|
+
return createElement(StylesBorderPanel, {
|
|
162
|
+
as: BordersInspectorControl,
|
|
163
|
+
panelId: clientId,
|
|
164
|
+
settings: settings,
|
|
165
|
+
value: value,
|
|
166
|
+
onChange: onChange,
|
|
167
|
+
defaultControls: defaultControls
|
|
168
|
+
});
|
|
317
169
|
}
|
|
318
170
|
/**
|
|
319
171
|
* Determine whether there is block support for border properties.
|
|
@@ -422,7 +274,7 @@ function addSaveProps(props, blockType, attributes) {
|
|
|
422
274
|
|
|
423
275
|
|
|
424
276
|
export function getBorderClasses(attributes) {
|
|
425
|
-
var _style$
|
|
277
|
+
var _style$border2;
|
|
426
278
|
|
|
427
279
|
const {
|
|
428
280
|
borderColor,
|
|
@@ -430,7 +282,7 @@ export function getBorderClasses(attributes) {
|
|
|
430
282
|
} = attributes;
|
|
431
283
|
const borderColorClass = getColorClassName('border-color', borderColor);
|
|
432
284
|
return classnames({
|
|
433
|
-
'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$
|
|
285
|
+
'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.color),
|
|
434
286
|
[borderColorClass]: !!borderColorClass
|
|
435
287
|
});
|
|
436
288
|
}
|
|
@@ -473,7 +325,7 @@ function addEditProps(settings) {
|
|
|
473
325
|
|
|
474
326
|
|
|
475
327
|
export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockListBlock => props => {
|
|
476
|
-
var _style$
|
|
328
|
+
var _style$border3, _style$border3$top, _style$border4, _style$border4$right, _style$border5, _style$border5$bottom, _style$border6, _style$border6$left, _props$wrapperProps;
|
|
477
329
|
|
|
478
330
|
const {
|
|
479
331
|
name,
|
|
@@ -501,25 +353,25 @@ export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockList
|
|
|
501
353
|
color: borderTopColor
|
|
502
354
|
} = getMultiOriginColor({
|
|
503
355
|
colors,
|
|
504
|
-
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$
|
|
356
|
+
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border3 = style.border) === null || _style$border3 === void 0 ? void 0 : (_style$border3$top = _style$border3.top) === null || _style$border3$top === void 0 ? void 0 : _style$border3$top.color)
|
|
505
357
|
});
|
|
506
358
|
const {
|
|
507
359
|
color: borderRightColor
|
|
508
360
|
} = getMultiOriginColor({
|
|
509
361
|
colors,
|
|
510
|
-
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$
|
|
362
|
+
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border4 = style.border) === null || _style$border4 === void 0 ? void 0 : (_style$border4$right = _style$border4.right) === null || _style$border4$right === void 0 ? void 0 : _style$border4$right.color)
|
|
511
363
|
});
|
|
512
364
|
const {
|
|
513
365
|
color: borderBottomColor
|
|
514
366
|
} = getMultiOriginColor({
|
|
515
367
|
colors,
|
|
516
|
-
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$
|
|
368
|
+
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border5 = style.border) === null || _style$border5 === void 0 ? void 0 : (_style$border5$bottom = _style$border5.bottom) === null || _style$border5$bottom === void 0 ? void 0 : _style$border5$bottom.color)
|
|
517
369
|
});
|
|
518
370
|
const {
|
|
519
371
|
color: borderLeftColor
|
|
520
372
|
} = getMultiOriginColor({
|
|
521
373
|
colors,
|
|
522
|
-
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$
|
|
374
|
+
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border6 = style.border) === null || _style$border6 === void 0 ? void 0 : (_style$border6$left = _style$border6.left) === null || _style$border6$left === void 0 ? void 0 : _style$border6$left.color)
|
|
523
375
|
});
|
|
524
376
|
const extraStyles = {
|
|
525
377
|
borderTopColor: borderTopColor || borderColorValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["classnames","getBlockSupport","__experimentalBorderBoxControl","BorderBoxControl","__experimentalHasSplitBorders","hasSplitBorders","__experimentalIsDefinedBorder","isDefinedBorder","__experimentalToolsPanelItem","ToolsPanelItem","createHigherOrderComponent","Platform","addFilter","__","BorderRadiusEdit","hasBorderRadiusValue","resetBorderRadius","getColorClassName","InspectorControls","useMultipleOriginColorsAndGradients","useSetting","cleanEmptyObject","shouldSkipSerialization","BORDER_SUPPORT_KEY","borderSides","hasBorderValue","props","borderColor","style","attributes","border","resetBorder","setAttributes","undefined","radius","resetBorderFilter","newAttributes","getColorByProperty","colors","property","value","matchedColor","some","origin","color","getMultiOriginColor","namedColor","customColor","colorObject","getBorderObject","borderStyles","hydratedBorderStyles","forEach","side","colorSlug","getColorSlugFromVariable","exec","BorderPanel","clientId","isSupported","hasBorderSupport","name","isColorSupported","isRadiusSupported","isStyleSupported","isWidthSupported","isDisabled","every","Boolean","defaultBorderControls","showBorderByDefault","width","onBorderChange","newBorder","newBorderStyles","newBorderColor","top","right","bottom","left","slug","newStyle","hydratedBorder","blockName","feature","OS","support","removeBorderAttribute","attribute","addAttributes","settings","type","addSaveProps","blockType","borderClasses","getBorderClasses","newClassName","className","borderColorClass","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","borderColorValue","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","extraStyles","wrapperProps"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SACCC,8BAA8B,IAAIC,gBADnC,EAECC,6BAA6B,IAAIC,eAFlC,EAGCC,6BAA6B,IAAIC,eAHlC,EAICC,4BAA4B,IAAIC,cAJjC,QAKO,uBALP;AAMA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SACCC,gBADD,EAECC,oBAFD,EAGCC,iBAHD,QAIO,iBAJP;AAKA,SAASC,iBAAT,QAAkC,sBAAlC;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,OAAOC,mCAAP,MAAgD,yEAAhD;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,gBAAT,EAA2BC,uBAA3B,QAA0D,SAA1D;AAEA,OAAO,MAAMC,kBAAkB,GAAG,sBAA3B;AAEP,MAAMC,WAAW,GAAG,CAAE,K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AxD;AAMA,QAAM;AAAEA,IAAAA,KAAK,EAAEgE;AAAT,MAA6B/D,mBAAmB,CAAE;AACvDP,IAAAA,MADuD;AAEvDQ,IAAAA,UAAU,EAAES,wBAAwB,CAAE3B,KAAF,aAAEA,KAAF,yCAAEA,KAAK,CAAEE,MAAT,0EAAE,eAAeiD,IAAjB,wDAAE,oBAAqBnC,KAAvB;AAFmB,GAAF,CAAtD;AAKA,QAAMiE,WAAW,GAAG;AACnBJ,IAAAA,cAAc,EAAEA,cAAc,IAAID,gBADf;AAEnBE,IAAAA,gBAAgB,EAAEA,gBAAgB,IAAIF,gBAFnB;AAGnBG,IAAAA,iBAAiB,EAAEA,iBAAiB,IAAIH,gBAHrB;AAInBI,IAAAA,eAAe,EAAEA,eAAe,IAAIJ;AAJjB,GAApB;AAOA,MAAIM,YAAY,GAAGpF,KAAK,CAACoF,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAGpF,KAAK,CAACoF,YADK;AAEdlF,IAAAA,KAAK,EAAE,EACN,2BAAGF,KAAK,CAACoF,YAAT,wDAAG,oBAAoBlF,KAAvB,CADM;AAEN,SAAGiF;AAFG;AAFO,GAAf;AAQA,SAAO,cAAC,cAAD,eAAqBnF,KAArB;AAA6B,IAAA,YAAY,EAAGoF;AAA5C,KAAP;AACA,CAtDoE,CAA/D;AAyDPlG,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGR6E,aAHQ,CAAT;AAMA7E,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGRgF,YAHQ,CAAT;AAMAhF,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRuF,YAHQ,CAAT;AAMAvF,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGR0F,4BAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBorderRadiusEdit,\n\thasBorderRadiusValue,\n\tresetBorderRadius,\n} from './border-radius';\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject, shouldSkipSerialization } from './utils';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\n\nconst borderSides = [ 'top', 'right', 'bottom', 'left' ];\n\nconst hasBorderValue = ( props ) => {\n\tconst { borderColor, style } = props.attributes;\n\treturn isDefinedBorder( style?.border ) || !! borderColor;\n};\n\n// The border color, style, and width are omitted so they get undefined. The\n// border radius is separate and must retain its selection.\nconst resetBorder = ( { attributes = {}, setAttributes } ) => {\n\tconst { style } = attributes;\n\tsetAttributes( {\n\t\tborderColor: undefined,\n\t\tstyle: {\n\t\t\t...style,\n\t\t\tborder: cleanEmptyObject( {\n\t\t\t\tradius: style?.border?.radius,\n\t\t\t} ),\n\t\t},\n\t} );\n};\n\nconst resetBorderFilter = ( newAttributes ) => ( {\n\t...newAttributes,\n\tborderColor: undefined,\n\tstyle: {\n\t\t...newAttributes.style,\n\t\tborder: {\n\t\t\tradius: newAttributes.style?.border?.radius,\n\t\t},\n\t},\n} );\n\nconst getColorByProperty = ( colors, property, value ) => {\n\tlet matchedColor;\n\n\tcolors.some( ( origin ) =>\n\t\torigin.colors.some( ( color ) => {\n\t\t\tif ( color[ property ] === value ) {\n\t\t\t\tmatchedColor = color;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} )\n\t);\n\n\treturn matchedColor;\n};\n\nexport const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {\n\t// Search each origin (default, theme, or user) for matching color by name.\n\tif ( namedColor ) {\n\t\tconst colorObject = getColorByProperty( colors, 'slug', namedColor );\n\t\tif ( colorObject ) {\n\t\t\treturn colorObject;\n\t\t}\n\t}\n\n\t// Skip if no custom color or matching named color.\n\tif ( ! customColor ) {\n\t\treturn { color: undefined };\n\t}\n\n\t// Attempt to find color via custom color value or build new object.\n\tconst colorObject = getColorByProperty( colors, 'color', customColor );\n\treturn colorObject ? colorObject : { color: customColor };\n};\n\nconst getBorderObject = ( attributes, colors ) => {\n\tconst { borderColor, style } = attributes;\n\tconst { border: borderStyles } = style || {};\n\n\t// If we have a named color for a flat border. Fetch that color object and\n\t// apply that color's value to the color property within the style object.\n\tif ( borderColor ) {\n\t\tconst { color } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: borderColor,\n\t\t} );\n\n\t\treturn color ? { ...borderStyles, color } : borderStyles;\n\t}\n\n\t// Individual side border color slugs are stored within the border style\n\t// object. If we don't have a border styles object we have nothing further\n\t// to hydrate.\n\tif ( ! borderStyles ) {\n\t\treturn borderStyles;\n\t}\n\n\t// If we have named colors for the individual side borders, retrieve their\n\t// related color objects and apply the real color values to the split\n\t// border objects.\n\tconst hydratedBorderStyles = { ...borderStyles };\n\tborderSides.forEach( ( side ) => {\n\t\tconst colorSlug = getColorSlugFromVariable(\n\t\t\thydratedBorderStyles[ side ]?.color\n\t\t);\n\t\tif ( colorSlug ) {\n\t\t\tconst { color } = getMultiOriginColor( {\n\t\t\t\tcolors,\n\t\t\t\tnamedColor: colorSlug,\n\t\t\t} );\n\t\t\thydratedBorderStyles[ side ] = {\n\t\t\t\t...hydratedBorderStyles[ side ],\n\t\t\t\tcolor,\n\t\t\t};\n\t\t}\n\t} );\n\n\treturn hydratedBorderStyles;\n};\n\nfunction getColorSlugFromVariable( value ) {\n\tconst namedColor = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( namedColor && namedColor[ 1 ] ) {\n\t\treturn namedColor[ 1 ];\n\t}\n\treturn null;\n}\n\nexport function BorderPanel( props ) {\n\tconst { attributes, clientId, setAttributes } = props;\n\tconst { style } = attributes;\n\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\tconst isSupported = hasBorderSupport( props.name );\n\tconst isColorSupported =\n\t\tuseSetting( 'border.color' ) && hasBorderSupport( props.name, 'color' );\n\tconst isRadiusSupported =\n\t\tuseSetting( 'border.radius' ) &&\n\t\thasBorderSupport( props.name, 'radius' );\n\tconst isStyleSupported =\n\t\tuseSetting( 'border.style' ) && hasBorderSupport( props.name, 'style' );\n\tconst isWidthSupported =\n\t\tuseSetting( 'border.width' ) && hasBorderSupport( props.name, 'width' );\n\n\tconst isDisabled = [\n\t\t! isColorSupported,\n\t\t! isRadiusSupported,\n\t\t! isStyleSupported,\n\t\t! isWidthSupported,\n\t].every( Boolean );\n\n\tif ( isDisabled || ! isSupported ) {\n\t\treturn null;\n\t}\n\n\tconst defaultBorderControls = getBlockSupport( props.name, [\n\t\tBORDER_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst showBorderByDefault =\n\t\tdefaultBorderControls?.color || defaultBorderControls?.width;\n\n\tconst onBorderChange = ( newBorder ) => {\n\t\t// Filter out named colors and apply them to appropriate block\n\t\t// attributes so that CSS classes can be used to apply those colors.\n\t\t// e.g. has-primary-border-top-color.\n\n\t\tlet newBorderStyles = { ...newBorder };\n\t\tlet newBorderColor;\n\n\t\tif ( hasSplitBorders( newBorder ) ) {\n\t\t\t// For each side check if the side has a color value set\n\t\t\t// If so, determine if it belongs to a named color, in which case\n\t\t\t// we update the color property.\n\t\t\t//\n\t\t\t// This deliberately overwrites `newBorderStyles` to avoid mutating\n\t\t\t// the passed object which causes problems otherwise.\n\t\t\tnewBorderStyles = {\n\t\t\t\ttop: { ...newBorder.top },\n\t\t\t\tright: { ...newBorder.right },\n\t\t\t\tbottom: { ...newBorder.bottom },\n\t\t\t\tleft: { ...newBorder.left },\n\t\t\t};\n\n\t\t\tborderSides.forEach( ( side ) => {\n\t\t\t\tif ( newBorder[ side ]?.color ) {\n\t\t\t\t\tconst colorObject = getMultiOriginColor( {\n\t\t\t\t\t\tcolors,\n\t\t\t\t\t\tcustomColor: newBorder[ side ]?.color,\n\t\t\t\t\t} );\n\n\t\t\t\t\tif ( colorObject.slug ) {\n\t\t\t\t\t\tnewBorderStyles[\n\t\t\t\t\t\t\tside\n\t\t\t\t\t\t].color = `var:preset|color|${ colorObject.slug }`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t} else if ( newBorder?.color ) {\n\t\t\t// We have a flat border configuration. Apply named color slug to\n\t\t\t// `borderColor` attribute and clear color style property if found.\n\t\t\tconst customColor = newBorder?.color;\n\t\t\tconst colorObject = getMultiOriginColor( { colors, customColor } );\n\n\t\t\tif ( colorObject.slug ) {\n\t\t\t\tnewBorderColor = colorObject.slug;\n\t\t\t\tnewBorderStyles.color = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Ensure previous border radius styles are maintained and clean\n\t\t// overall result for empty objects or properties.\n\t\tconst newStyle = cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tborder: { radius: style?.border?.radius, ...newBorderStyles },\n\t\t} );\n\n\t\tsetAttributes( {\n\t\t\tstyle: newStyle,\n\t\t\tborderColor: newBorderColor,\n\t\t} );\n\t};\n\n\tconst hydratedBorder = getBorderObject( attributes, colors );\n\n\treturn (\n\t\t<InspectorControls group=\"border\">\n\t\t\t{ ( isWidthSupported || isColorSupported ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasBorderValue( props ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder( props ) }\n\t\t\t\t\tisShownByDefault={ showBorderByDefault }\n\t\t\t\t\tresetAllFilter={ resetBorderFilter }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tenableStyle={ isStyleSupported }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\tvalue={ hydratedBorder }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ isRadiusSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasBorderRadiusValue( props ) }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderRadius( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.radius }\n\t\t\t\t\tresetAllFilter={ ( newAttributes ) => ( {\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...newAttributes.style,\n\t\t\t\t\t\t\tborder: {\n\t\t\t\t\t\t\t\t...newAttributes.style?.border,\n\t\t\t\t\t\t\t\tradius: undefined,\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\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = classnames( props.className, borderClasses );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Generates a CSS class name consisting of all the applicable border color\n * classes given the current block attributes.\n *\n * @param {Object} attributes Block's attributes.\n *\n * @return {string} CSS class name.\n */\nexport function getBorderClasses( attributes ) {\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\treturn classnames( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor, style } = attributes;\n\t\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: borderColor,\n\t\t} );\n\t\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t\t} );\n\t\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t\t} );\n\n\t\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable(\n\t\t\t\tstyle?.border?.bottom?.color\n\t\t\t),\n\t\t} );\n\t\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t\t} );\n\n\t\tconst extraStyles = {\n\t\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t\t...extraStyles,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["classnames","getBlockSupport","__experimentalHasSplitBorders","hasSplitBorders","createHigherOrderComponent","Platform","useCallback","useMemo","addFilter","getColorClassName","InspectorControls","useMultipleOriginColorsAndGradients","cleanEmptyObject","shouldSkipSerialization","useBlockSettings","useHasBorderPanel","BorderPanel","StylesBorderPanel","BORDER_SUPPORT_KEY","getColorByProperty","colors","property","value","matchedColor","some","origin","color","getMultiOriginColor","namedColor","customColor","colorObject","undefined","getColorSlugFromVariable","exec","styleToAttributes","style","border","borderColor","borderColorValue","borderColorSlug","startsWith","substring","length","updatedStyle","attributesToStyle","attributes","BordersInspectorControl","children","resetAllFilter","attributesResetAllFilter","existingStyle","props","clientId","name","setAttributes","settings","isEnabled","onChange","newStyle","defaultControls","hasBorderSupport","blockName","feature","OS","support","radius","width","removeBorderAttribute","attribute","addAttributes","type","addSaveProps","blockType","borderClasses","getBorderClasses","newClassName","className","borderColorClass","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","borderTopColor","top","borderRightColor","right","borderBottomColor","bottom","borderLeftColor","left","extraStyles","wrapperProps"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,6BAA6B,IAAIC,eAA1C,QAAiE,uBAAjE;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,EAAmBC,WAAnB,EAAgCC,OAAhC,QAA+C,oBAA/C;AACA,SAASC,SAAT,QAA0B,kBAA1B;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,sBAAlC;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,OAAOC,mCAAP,MAAgD,yEAAhD;AACA,SACCC,gBADD,EAECC,uBAFD,EAGCC,gBAHD,QAIO,SAJP;AAKA,SACCC,iBADD,EAECC,WAAW,IAAIC,iBAFhB,QAGO,6BAHP;AAKA,OAAO,MAAMC,kBAAkB,GAAG,sBAA3B;;AAEP,MAAMC,kB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MAAT,0EAAE,eAAesD,IAAjB,wDAAE,oBAAqBhE,KAAvB;AAFmB,GAAF,CAAtD;AAKA,QAAMiE,WAAW,GAAG;AACnBR,IAAAA,cAAc,EAAEA,cAAc,IAAI7C,gBADf;AAEnB+C,IAAAA,gBAAgB,EAAEA,gBAAgB,IAAI/C,gBAFnB;AAGnBiD,IAAAA,iBAAiB,EAAEA,iBAAiB,IAAIjD,gBAHrB;AAInBmD,IAAAA,eAAe,EAAEA,eAAe,IAAInD;AAJjB,GAApB;AAOA,MAAIsD,YAAY,GAAGzC,KAAK,CAACyC,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAGzC,KAAK,CAACyC,YADK;AAEdzD,IAAAA,KAAK,EAAE,EACN,2BAAGgB,KAAK,CAACyC,YAAT,wDAAG,oBAAoBzD,KAAvB,CADM;AAEN,SAAGwD;AAFG;AAFO,GAAf;AAQA,SAAO,cAAC,cAAD,eAAqBxC,KAArB;AAA6B,IAAA,YAAY,EAAGyC;AAA5C,KAAP;AACA,CAtDoE,CAA/D;AAyDPpF,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGR6D,aAHQ,CAAT;AAMA7D,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGR+D,YAHQ,CAAT;AAMA/D,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRsE,YAHQ,CAAT;AAMAtE,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGRyE,4BAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform, useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tcleanEmptyObject,\n\tshouldSkipSerialization,\n\tuseBlockSettings,\n} from './utils';\nimport {\n\tuseHasBorderPanel,\n\tBorderPanel as StylesBorderPanel,\n} from '../components/global-styles';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\n\nconst getColorByProperty = ( colors, property, value ) => {\n\tlet matchedColor;\n\n\tcolors.some( ( origin ) =>\n\t\torigin.colors.some( ( color ) => {\n\t\t\tif ( color[ property ] === value ) {\n\t\t\t\tmatchedColor = color;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} )\n\t);\n\n\treturn matchedColor;\n};\n\nexport const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {\n\t// Search each origin (default, theme, or user) for matching color by name.\n\tif ( namedColor ) {\n\t\tconst colorObject = getColorByProperty( colors, 'slug', namedColor );\n\t\tif ( colorObject ) {\n\t\t\treturn colorObject;\n\t\t}\n\t}\n\n\t// Skip if no custom color or matching named color.\n\tif ( ! customColor ) {\n\t\treturn { color: undefined };\n\t}\n\n\t// Attempt to find color via custom color value or build new object.\n\tconst colorObject = getColorByProperty( colors, 'color', customColor );\n\treturn colorObject ? colorObject : { color: customColor };\n};\n\nfunction getColorSlugFromVariable( value ) {\n\tconst namedColor = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( namedColor && namedColor[ 1 ] ) {\n\t\treturn namedColor[ 1 ];\n\t}\n\treturn null;\n}\n\nfunction styleToAttributes( style ) {\n\tif ( hasSplitBorders( style?.border ) ) {\n\t\treturn {\n\t\t\tstyle,\n\t\t\tborderColor: undefined,\n\t\t};\n\t}\n\n\tconst borderColorValue = style?.border?.color;\n\tconst borderColorSlug = borderColorValue?.startsWith( 'var:preset|color|' )\n\t\t? borderColorSlug.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst updatedStyle = { ...style };\n\tupdatedStyle.border = {\n\t\t...updatedStyle.border,\n\t\tcolor: borderColorSlug ? undefined : borderColorValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\tborderColor: borderColorSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\tif ( hasSplitBorders( attributes.style?.border ) ) {\n\t\treturn attributes.style;\n\t}\n\treturn {\n\t\t...attributes.style,\n\t\tborder: {\n\t\t\t...attributes.style?.border,\n\t\t\tcolor: attributes.borderColor\n\t\t\t\t? 'var:preset|color|' + attributes.borderColor\n\t\t\t\t: attributes.style?.border?.color,\n\t\t},\n\t};\n}\n\nfunction BordersInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"border\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BorderPanel( props ) {\n\tconst { clientId, name, attributes, setAttributes } = props;\n\tconst settings = useBlockSettings( name );\n\tconst isEnabled = useHasBorderPanel( settings );\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( {\n\t\t\tstyle: attributes.style,\n\t\t\tborderColor: attributes.borderColor,\n\t\t} );\n\t}, [ attributes.style, attributes.borderColor ] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tBORDER_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<StylesBorderPanel\n\t\t\tas={ BordersInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t/>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = classnames( props.className, borderClasses );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Generates a CSS class name consisting of all the applicable border color\n * classes given the current block attributes.\n *\n * @param {Object} attributes Block's attributes.\n *\n * @return {string} CSS class name.\n */\nexport function getBorderClasses( attributes ) {\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\treturn classnames( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor, style } = attributes;\n\t\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: borderColor,\n\t\t} );\n\t\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t\t} );\n\t\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t\t} );\n\n\t\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable(\n\t\t\t\tstyle?.border?.bottom?.color\n\t\t\t),\n\t\t} );\n\t\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t\t} );\n\n\t\tconst extraStyles = {\n\t\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t\t...extraStyles,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
|