@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
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.BorderRadiusEdit = BorderRadiusEdit;
|
|
9
|
-
exports.hasBorderRadiusValue = hasBorderRadiusValue;
|
|
10
|
-
exports.resetBorderRadius = resetBorderRadius;
|
|
11
|
-
|
|
12
|
-
var _element = require("@wordpress/element");
|
|
13
|
-
|
|
14
|
-
var _borderRadiusControl = _interopRequireDefault(require("../components/border-radius-control"));
|
|
15
|
-
|
|
16
|
-
var _utils = require("./utils");
|
|
17
|
-
|
|
18
|
-
var _border = require("./border");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Inspector control panel containing the border radius related configuration.
|
|
26
|
-
*
|
|
27
|
-
* @param {Object} props Block properties.
|
|
28
|
-
*
|
|
29
|
-
* @return {WPElement} Border radius edit element.
|
|
30
|
-
*/
|
|
31
|
-
function BorderRadiusEdit(props) {
|
|
32
|
-
var _style$border;
|
|
33
|
-
|
|
34
|
-
const {
|
|
35
|
-
attributes: {
|
|
36
|
-
style
|
|
37
|
-
},
|
|
38
|
-
setAttributes
|
|
39
|
-
} = props;
|
|
40
|
-
|
|
41
|
-
const onChange = newRadius => {
|
|
42
|
-
const newStyle = (0, _utils.cleanEmptyObject)({ ...style,
|
|
43
|
-
border: { ...(style === null || style === void 0 ? void 0 : style.border),
|
|
44
|
-
radius: newRadius
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
setAttributes({
|
|
48
|
-
style: newStyle
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return (0, _element.createElement)(_borderRadiusControl.default, {
|
|
53
|
-
values: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius,
|
|
54
|
-
onChange: onChange
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Checks if there is a current value in the border radius block support
|
|
59
|
-
* attributes.
|
|
60
|
-
*
|
|
61
|
-
* @param {Object} props Block props.
|
|
62
|
-
* @return {boolean} Whether or not the block has a border radius value set.
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
function hasBorderRadiusValue(props) {
|
|
67
|
-
var _props$attributes$sty, _props$attributes$sty2;
|
|
68
|
-
|
|
69
|
-
const borderRadius = (_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.border) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.radius;
|
|
70
|
-
|
|
71
|
-
if (typeof borderRadius === 'object') {
|
|
72
|
-
return Object.entries(borderRadius).some(Boolean);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return !!borderRadius;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Resets the border radius block support attributes. This can be used when
|
|
79
|
-
* disabling the border radius support controls for a block via a progressive
|
|
80
|
-
* discovery panel.
|
|
81
|
-
*
|
|
82
|
-
* @param {Object} props Block props.
|
|
83
|
-
* @param {Object} props.attributes Block's attributes.
|
|
84
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
function resetBorderRadius(_ref) {
|
|
89
|
-
let {
|
|
90
|
-
attributes = {},
|
|
91
|
-
setAttributes
|
|
92
|
-
} = _ref;
|
|
93
|
-
const {
|
|
94
|
-
style
|
|
95
|
-
} = attributes;
|
|
96
|
-
setAttributes({
|
|
97
|
-
style: (0, _border.removeBorderAttribute)(style, 'radius')
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=border-radius.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/border-radius.js"],"names":["BorderRadiusEdit","props","attributes","style","setAttributes","onChange","newRadius","newStyle","border","radius","hasBorderRadiusValue","borderRadius","Object","entries","some","Boolean","resetBorderRadius"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,KAA3B,EAAmC;AAAA;;AACzC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,QAAMI,QAAQ,GAAKC,SAAF,IAAiB;AACjC,UAAMC,QAAQ,GAAG,6BAAkB,EAClC,GAAGJ,KAD+B;AAElCK,MAAAA,MAAM,EAAE,EACP,IAAGL,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEK,MAAV,CADO;AAEPC,QAAAA,MAAM,EAAEH;AAFD;AAF0B,KAAlB,CAAjB;AAQAF,IAAAA,aAAa,CAAE;AAAED,MAAAA,KAAK,EAAEI;AAAT,KAAF,CAAb;AACA,GAVD;;AAYA,SACC,4BAAC,4BAAD;AACC,IAAA,MAAM,EAAGJ,KAAH,aAAGA,KAAH,wCAAGA,KAAK,CAAEK,MAAV,kDAAG,cAAeC,MADzB;AAEC,IAAA,QAAQ,EAAGJ;AAFZ,IADD;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,oBAAT,CAA+BT,KAA/B,EAAuC;AAAA;;AAC7C,QAAMU,YAAY,4BAAGV,KAAK,CAACC,UAAN,CAAiBC,KAApB,oFAAG,sBAAwBK,MAA3B,2DAAG,uBAAgCC,MAArD;;AAEA,MAAK,OAAOE,YAAP,KAAwB,QAA7B,EAAwC;AACvC,WAAOC,MAAM,CAACC,OAAP,CAAgBF,YAAhB,EAA+BG,IAA/B,CAAqCC,OAArC,CAAP;AACA;;AAED,SAAO,CAAC,CAAEJ,YAAV;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,iBAAT,OAAiE;AAAA,MAArC;AAAEd,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACvE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AACAE,EAAAA,aAAa,CAAE;AAAED,IAAAA,KAAK,EAAE,mCAAuBA,KAAvB,EAA8B,QAA9B;AAAT,GAAF,CAAb;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport BorderRadiusControl from '../components/border-radius-control';\nimport { cleanEmptyObject } from './utils';\nimport { removeBorderAttribute } from './border';\n\n/**\n * Inspector control panel containing the border radius related configuration.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border radius edit element.\n */\nexport function BorderRadiusEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newRadius ) => {\n\t\tconst newStyle = cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tradius: newRadius,\n\t\t\t},\n\t\t} );\n\n\t\tsetAttributes( { style: newStyle } );\n\t};\n\n\treturn (\n\t\t<BorderRadiusControl\n\t\t\tvalues={ style?.border?.radius }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if there is a current value in the border radius block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border radius value set.\n */\nexport function hasBorderRadiusValue( props ) {\n\tconst borderRadius = props.attributes.style?.border?.radius;\n\n\tif ( typeof borderRadius === 'object' ) {\n\t\treturn Object.entries( borderRadius ).some( Boolean );\n\t}\n\n\treturn !! borderRadius;\n}\n\n/**\n * Resets the border radius block support attributes. This can be used when\n * disabling the border radius support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBorderRadius( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\tsetAttributes( { style: removeBorderAttribute( style, 'radius' ) } );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/color-panel.js"],"names":["getComputedStyle","node","ownerDocument","defaultView","ColorPanel","enableAlpha","settings","clientId","enableContrastChecking","detectedBackgroundColor","setDetectedBackgroundColor","detectedColor","setDetectedColor","detectedLinkColor","setDetectedLinkColor","ref","definedColors","filter","setting","colorValue","length","current","color","firstLinkElement","querySelector","innerText","backgroundColorNode","backgroundColor","parentNode","nodeType","ELEMENT_NODE","colorGradientSettings"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';\nimport ContrastChecker from '../components/contrast-checker';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';\n\nfunction getComputedStyle( node ) {\n\treturn node.ownerDocument.defaultView.getComputedStyle( node );\n}\n\nexport default function ColorPanel( {\n\tenableAlpha = false,\n\tsettings,\n\tclientId,\n\tenableContrastChecking = true,\n} ) {\n\tconst [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();\n\tconst [ detectedColor, setDetectedColor ] = useState();\n\tconst [ detectedLinkColor, setDetectedLinkColor ] = useState();\n\tconst ref = useBlockRef( clientId );\n\tconst definedColors = settings.filter( ( setting ) => setting?.colorValue );\n\n\tuseEffect( () => {\n\t\tif ( ! enableContrastChecking ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( ! definedColors.length ) {\n\t\t\tif ( detectedBackgroundColor ) {\n\t\t\t\tsetDetectedBackgroundColor();\n\t\t\t}\n\t\t\tif ( detectedColor ) {\n\t\t\t\tsetDetectedColor();\n\t\t\t}\n\t\t\tif ( detectedLinkColor ) {\n\t\t\t\tsetDetectedColor();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\t\tsetDetectedColor( getComputedStyle( ref.current ).color );\n\n\t\tconst firstLinkElement = ref.current?.querySelector( 'a' );\n\t\tif ( firstLinkElement && !! firstLinkElement.innerText ) {\n\t\t\tsetDetectedLinkColor( getComputedStyle( firstLinkElement ).color );\n\t\t}\n\n\t\tlet backgroundColorNode = ref.current;\n\t\tlet backgroundColor =\n\t\t\tgetComputedStyle( backgroundColorNode ).backgroundColor;\n\t\twhile (\n\t\t\tbackgroundColor === 'rgba(0, 0, 0, 0)' &&\n\t\t\tbackgroundColorNode.parentNode &&\n\t\t\tbackgroundColorNode.parentNode.nodeType ===\n\t\t\t\tbackgroundColorNode.parentNode.ELEMENT_NODE\n\t\t) {\n\t\t\tbackgroundColorNode = backgroundColorNode.parentNode;\n\t\t\tbackgroundColor =\n\t\t\t\tgetComputedStyle( backgroundColorNode ).backgroundColor;\n\t\t}\n\n\t\tsetDetectedBackgroundColor( backgroundColor );\n\t} );\n\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\n\treturn (\n\t\t<InspectorControls group=\"color\">\n\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\tpanelId={ clientId }\n\t\t\t\tsettings={ settings }\n\t\t\t\t__experimentalIsItemGroup={ false }\n\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t{ ...colorGradientSettings }\n\t\t\t/>\n\t\t\t{ enableContrastChecking && (\n\t\t\t\t<ContrastChecker\n\t\t\t\t\tbackgroundColor={ detectedBackgroundColor }\n\t\t\t\t\ttextColor={ detectedColor }\n\t\t\t\t\tenableAlphaChecker={ enableAlpha }\n\t\t\t\t\tlinkColor={ detectedLinkColor }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n"]}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Internal dependencies
|
|
5
|
-
*/
|
|
6
|
-
import BorderRadiusControl from '../components/border-radius-control';
|
|
7
|
-
import { cleanEmptyObject } from './utils';
|
|
8
|
-
import { removeBorderAttribute } from './border';
|
|
9
|
-
/**
|
|
10
|
-
* Inspector control panel containing the border radius related configuration.
|
|
11
|
-
*
|
|
12
|
-
* @param {Object} props Block properties.
|
|
13
|
-
*
|
|
14
|
-
* @return {WPElement} Border radius edit element.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export function BorderRadiusEdit(props) {
|
|
18
|
-
var _style$border;
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
attributes: {
|
|
22
|
-
style
|
|
23
|
-
},
|
|
24
|
-
setAttributes
|
|
25
|
-
} = props;
|
|
26
|
-
|
|
27
|
-
const onChange = newRadius => {
|
|
28
|
-
const newStyle = cleanEmptyObject({ ...style,
|
|
29
|
-
border: { ...(style === null || style === void 0 ? void 0 : style.border),
|
|
30
|
-
radius: newRadius
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
setAttributes({
|
|
34
|
-
style: newStyle
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return createElement(BorderRadiusControl, {
|
|
39
|
-
values: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius,
|
|
40
|
-
onChange: onChange
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Checks if there is a current value in the border radius block support
|
|
45
|
-
* attributes.
|
|
46
|
-
*
|
|
47
|
-
* @param {Object} props Block props.
|
|
48
|
-
* @return {boolean} Whether or not the block has a border radius value set.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
export function hasBorderRadiusValue(props) {
|
|
52
|
-
var _props$attributes$sty, _props$attributes$sty2;
|
|
53
|
-
|
|
54
|
-
const borderRadius = (_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.border) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.radius;
|
|
55
|
-
|
|
56
|
-
if (typeof borderRadius === 'object') {
|
|
57
|
-
return Object.entries(borderRadius).some(Boolean);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return !!borderRadius;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Resets the border radius block support attributes. This can be used when
|
|
64
|
-
* disabling the border radius support controls for a block via a progressive
|
|
65
|
-
* discovery panel.
|
|
66
|
-
*
|
|
67
|
-
* @param {Object} props Block props.
|
|
68
|
-
* @param {Object} props.attributes Block's attributes.
|
|
69
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
export function resetBorderRadius(_ref) {
|
|
73
|
-
let {
|
|
74
|
-
attributes = {},
|
|
75
|
-
setAttributes
|
|
76
|
-
} = _ref;
|
|
77
|
-
const {
|
|
78
|
-
style
|
|
79
|
-
} = attributes;
|
|
80
|
-
setAttributes({
|
|
81
|
-
style: removeBorderAttribute(style, 'radius')
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=border-radius.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/border-radius.js"],"names":["BorderRadiusControl","cleanEmptyObject","removeBorderAttribute","BorderRadiusEdit","props","attributes","style","setAttributes","onChange","newRadius","newStyle","border","radius","hasBorderRadiusValue","borderRadius","Object","entries","some","Boolean","resetBorderRadius"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,mBAAP,MAAgC,qCAAhC;AACA,SAASC,gBAAT,QAAiC,SAAjC;AACA,SAASC,qBAAT,QAAsC,UAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,gBAAT,CAA2BC,KAA3B,EAAmC;AAAA;;AACzC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,QAAMI,QAAQ,GAAKC,SAAF,IAAiB;AACjC,UAAMC,QAAQ,GAAGT,gBAAgB,CAAE,EAClC,GAAGK,KAD+B;AAElCK,MAAAA,MAAM,EAAE,EACP,IAAGL,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEK,MAAV,CADO;AAEPC,QAAAA,MAAM,EAAEH;AAFD;AAF0B,KAAF,CAAjC;AAQAF,IAAAA,aAAa,CAAE;AAAED,MAAAA,KAAK,EAAEI;AAAT,KAAF,CAAb;AACA,GAVD;;AAYA,SACC,cAAC,mBAAD;AACC,IAAA,MAAM,EAAGJ,KAAH,aAAGA,KAAH,wCAAGA,KAAK,CAAEK,MAAV,kDAAG,cAAeC,MADzB;AAEC,IAAA,QAAQ,EAAGJ;AAFZ,IADD;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,oBAAT,CAA+BT,KAA/B,EAAuC;AAAA;;AAC7C,QAAMU,YAAY,4BAAGV,KAAK,CAACC,UAAN,CAAiBC,KAApB,oFAAG,sBAAwBK,MAA3B,2DAAG,uBAAgCC,MAArD;;AAEA,MAAK,OAAOE,YAAP,KAAwB,QAA7B,EAAwC;AACvC,WAAOC,MAAM,CAACC,OAAP,CAAgBF,YAAhB,EAA+BG,IAA/B,CAAqCC,OAArC,CAAP;AACA;;AAED,SAAO,CAAC,CAAEJ,YAAV;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,iBAAT,OAAiE;AAAA,MAArC;AAAEd,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACvE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AACAE,EAAAA,aAAa,CAAE;AAAED,IAAAA,KAAK,EAAEJ,qBAAqB,CAAEI,KAAF,EAAS,QAAT;AAA9B,GAAF,CAAb;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport BorderRadiusControl from '../components/border-radius-control';\nimport { cleanEmptyObject } from './utils';\nimport { removeBorderAttribute } from './border';\n\n/**\n * Inspector control panel containing the border radius related configuration.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border radius edit element.\n */\nexport function BorderRadiusEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newRadius ) => {\n\t\tconst newStyle = cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tradius: newRadius,\n\t\t\t},\n\t\t} );\n\n\t\tsetAttributes( { style: newStyle } );\n\t};\n\n\treturn (\n\t\t<BorderRadiusControl\n\t\t\tvalues={ style?.border?.radius }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if there is a current value in the border radius block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border radius value set.\n */\nexport function hasBorderRadiusValue( props ) {\n\tconst borderRadius = props.attributes.style?.border?.radius;\n\n\tif ( typeof borderRadius === 'object' ) {\n\t\treturn Object.entries( borderRadius ).some( Boolean );\n\t}\n\n\treturn !! borderRadius;\n}\n\n/**\n * Resets the border radius block support attributes. This can be used when\n * disabling the border radius support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBorderRadius( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\tsetAttributes( { style: removeBorderAttribute( style, 'radius' ) } );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/color-panel.js"],"names":["useState","useEffect","ColorGradientSettingsDropdown","ContrastChecker","InspectorControls","useMultipleOriginColorsAndGradients","__unstableUseBlockRef","useBlockRef","getComputedStyle","node","ownerDocument","defaultView","ColorPanel","enableAlpha","settings","clientId","enableContrastChecking","detectedBackgroundColor","setDetectedBackgroundColor","detectedColor","setDetectedColor","detectedLinkColor","setDetectedLinkColor","ref","definedColors","filter","setting","colorValue","length","current","color","firstLinkElement","querySelector","innerText","backgroundColorNode","backgroundColor","parentNode","nodeType","ELEMENT_NODE","colorGradientSettings"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';\nimport ContrastChecker from '../components/contrast-checker';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';\n\nfunction getComputedStyle( node ) {\n\treturn node.ownerDocument.defaultView.getComputedStyle( node );\n}\n\nexport default function ColorPanel( {\n\tenableAlpha = false,\n\tsettings,\n\tclientId,\n\tenableContrastChecking = true,\n} ) {\n\tconst [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();\n\tconst [ detectedColor, setDetectedColor ] = useState();\n\tconst [ detectedLinkColor, setDetectedLinkColor ] = useState();\n\tconst ref = useBlockRef( clientId );\n\tconst definedColors = settings.filter( ( setting ) => setting?.colorValue );\n\n\tuseEffect( () => {\n\t\tif ( ! enableContrastChecking ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( ! definedColors.length ) {\n\t\t\tif ( detectedBackgroundColor ) {\n\t\t\t\tsetDetectedBackgroundColor();\n\t\t\t}\n\t\t\tif ( detectedColor ) {\n\t\t\t\tsetDetectedColor();\n\t\t\t}\n\t\t\tif ( detectedLinkColor ) {\n\t\t\t\tsetDetectedColor();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\t\tsetDetectedColor( getComputedStyle( ref.current ).color );\n\n\t\tconst firstLinkElement = ref.current?.querySelector( 'a' );\n\t\tif ( firstLinkElement && !! firstLinkElement.innerText ) {\n\t\t\tsetDetectedLinkColor( getComputedStyle( firstLinkElement ).color );\n\t\t}\n\n\t\tlet backgroundColorNode = ref.current;\n\t\tlet backgroundColor =\n\t\t\tgetComputedStyle( backgroundColorNode ).backgroundColor;\n\t\twhile (\n\t\t\tbackgroundColor === 'rgba(0, 0, 0, 0)' &&\n\t\t\tbackgroundColorNode.parentNode &&\n\t\t\tbackgroundColorNode.parentNode.nodeType ===\n\t\t\t\tbackgroundColorNode.parentNode.ELEMENT_NODE\n\t\t) {\n\t\t\tbackgroundColorNode = backgroundColorNode.parentNode;\n\t\t\tbackgroundColor =\n\t\t\t\tgetComputedStyle( backgroundColorNode ).backgroundColor;\n\t\t}\n\n\t\tsetDetectedBackgroundColor( backgroundColor );\n\t} );\n\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\n\treturn (\n\t\t<InspectorControls group=\"color\">\n\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\tpanelId={ clientId }\n\t\t\t\tsettings={ settings }\n\t\t\t\t__experimentalIsItemGroup={ false }\n\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t{ ...colorGradientSettings }\n\t\t\t/>\n\t\t\t{ enableContrastChecking && (\n\t\t\t\t<ContrastChecker\n\t\t\t\t\tbackgroundColor={ detectedBackgroundColor }\n\t\t\t\t\ttextColor={ detectedColor }\n\t\t\t\t\tenableAlphaChecker={ enableAlpha }\n\t\t\t\t\tlinkColor={ detectedLinkColor }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n"]}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import BorderRadiusControl from '../components/border-radius-control';
|
|
5
|
-
import { cleanEmptyObject } from './utils';
|
|
6
|
-
import { removeBorderAttribute } from './border';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Inspector control panel containing the border radius related configuration.
|
|
10
|
-
*
|
|
11
|
-
* @param {Object} props Block properties.
|
|
12
|
-
*
|
|
13
|
-
* @return {WPElement} Border radius edit element.
|
|
14
|
-
*/
|
|
15
|
-
export function BorderRadiusEdit( props ) {
|
|
16
|
-
const {
|
|
17
|
-
attributes: { style },
|
|
18
|
-
setAttributes,
|
|
19
|
-
} = props;
|
|
20
|
-
|
|
21
|
-
const onChange = ( newRadius ) => {
|
|
22
|
-
const newStyle = cleanEmptyObject( {
|
|
23
|
-
...style,
|
|
24
|
-
border: {
|
|
25
|
-
...style?.border,
|
|
26
|
-
radius: newRadius,
|
|
27
|
-
},
|
|
28
|
-
} );
|
|
29
|
-
|
|
30
|
-
setAttributes( { style: newStyle } );
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<BorderRadiusControl
|
|
35
|
-
values={ style?.border?.radius }
|
|
36
|
-
onChange={ onChange }
|
|
37
|
-
/>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Checks if there is a current value in the border radius block support
|
|
43
|
-
* attributes.
|
|
44
|
-
*
|
|
45
|
-
* @param {Object} props Block props.
|
|
46
|
-
* @return {boolean} Whether or not the block has a border radius value set.
|
|
47
|
-
*/
|
|
48
|
-
export function hasBorderRadiusValue( props ) {
|
|
49
|
-
const borderRadius = props.attributes.style?.border?.radius;
|
|
50
|
-
|
|
51
|
-
if ( typeof borderRadius === 'object' ) {
|
|
52
|
-
return Object.entries( borderRadius ).some( Boolean );
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return !! borderRadius;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Resets the border radius block support attributes. This can be used when
|
|
60
|
-
* disabling the border radius support controls for a block via a progressive
|
|
61
|
-
* discovery panel.
|
|
62
|
-
*
|
|
63
|
-
* @param {Object} props Block props.
|
|
64
|
-
* @param {Object} props.attributes Block's attributes.
|
|
65
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
66
|
-
*/
|
|
67
|
-
export function resetBorderRadius( { attributes = {}, setAttributes } ) {
|
|
68
|
-
const { style } = attributes;
|
|
69
|
-
setAttributes( { style: removeBorderAttribute( style, 'radius' ) } );
|
|
70
|
-
}
|