@wordpress/block-editor 15.22.1-next.v.202606191442.0 → 15.23.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 +3 -1
- package/README.md +2 -2
- package/build/components/block-editing-mode/index.cjs +13 -7
- package/build/components/block-editing-mode/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +50 -51
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-rename/modal.cjs +0 -1
- package/build/components/block-rename/modal.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +25 -14
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +4 -1
- package/build/components/colors-gradients/dropdown.cjs.map +3 -3
- package/build/components/contrast-checker/index.cjs +22 -4
- package/build/components/contrast-checker/index.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +153 -25
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
- package/build/components/global-styles/color-panel.cjs +98 -375
- package/build/components/global-styles/color-panel.cjs.map +3 -3
- package/build/components/global-styles/dimensions-panel.cjs +0 -3
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +34 -0
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +82 -10
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/inspector-controls/groups.cjs +2 -0
- package/build/components/inspector-controls/groups.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +75 -31
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/link-control/index.cjs +1 -2
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +1 -10
- package/build/components/list-view/block-select-button.cjs.map +3 -3
- package/build/components/provider/use-block-sync.cjs +3 -1
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/url-popover/image-url-input-ui.cjs +0 -2
- package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -3
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/use-resize-canvas/index.cjs +16 -53
- package/build/components/use-resize-canvas/index.cjs.map +3 -3
- package/build/hooks/anchor.cjs +0 -1
- package/build/hooks/anchor.cjs.map +2 -2
- package/build/hooks/background.cjs +124 -75
- package/build/hooks/background.cjs.map +3 -3
- package/build/hooks/color.cjs +0 -162
- package/build/hooks/color.cjs.map +3 -3
- package/build/hooks/contrast-checker.cjs +31 -28
- package/build/hooks/contrast-checker.cjs.map +3 -3
- package/build/hooks/custom-class-name.cjs +0 -1
- package/build/hooks/custom-class-name.cjs.map +2 -2
- package/build/hooks/elements.cjs +142 -0
- package/build/hooks/elements.cjs.map +7 -0
- package/build/hooks/grid-visualizer.cjs +21 -11
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +38 -8
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +6 -3
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/states.cjs +15 -23
- package/build/hooks/states.cjs.map +2 -2
- package/build/hooks/style.cjs +8 -4
- package/build/hooks/style.cjs.map +2 -2
- package/build/hooks/typography.cjs +62 -10
- package/build/hooks/typography.cjs.map +3 -3
- package/build/layouts/flex.cjs +99 -6
- package/build/layouts/flex.cjs.map +2 -2
- package/build/private-apis.cjs +0 -1
- package/build/private-apis.cjs.map +2 -2
- package/build/store/private-actions.cjs +16 -0
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +0 -3
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/private-selectors.cjs +24 -6
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +19 -3
- package/build/store/reducer.cjs.map +2 -2
- package/build/utils/block-bindings.cjs +9 -9
- package/build/utils/block-bindings.cjs.map +3 -3
- package/build/utils/color-values.cjs +10 -1
- package/build/utils/color-values.cjs.map +3 -3
- package/build/utils/dom.cjs +2 -5
- package/build/utils/dom.cjs.map +3 -3
- package/build/utils/fit-text-frontend.cjs +6 -2
- package/build/utils/fit-text-frontend.cjs.map +3 -3
- package/build/utils/fit-text-utils.cjs +1 -1
- package/build/utils/fit-text-utils.cjs.map +3 -3
- package/build/utils/format-font-style.cjs +1 -1
- package/build/utils/format-font-style.cjs.map +3 -3
- package/build/utils/format-font-weight.cjs +1 -1
- package/build/utils/format-font-weight.cjs.map +3 -3
- package/build/utils/get-editor-region.cjs +4 -2
- package/build/utils/get-editor-region.cjs.map +3 -3
- package/build/utils/get-font-styles-and-weights.cjs +8 -12
- package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
- package/build/utils/get-px-from-css-unit.cjs +1 -1
- package/build/utils/get-px-from-css-unit.cjs.map +1 -1
- package/build/utils/index.cjs +1 -1
- package/build/utils/index.cjs.map +1 -1
- package/build/utils/math.cjs +1 -1
- package/build/utils/math.cjs.map +3 -3
- package/build/utils/object.cjs +8 -8
- package/build/utils/object.cjs.map +3 -3
- package/build/utils/order-inserter-block-items.cjs +1 -1
- package/build/utils/order-inserter-block-items.cjs.map +3 -3
- package/build/utils/pasting.cjs +4 -2
- package/build/utils/pasting.cjs.map +3 -3
- package/build/utils/selection.cjs +2 -1
- package/build/utils/selection.cjs.map +3 -3
- package/build/utils/sorting.cjs +9 -3
- package/build/utils/sorting.cjs.map +3 -3
- package/build/utils/transform-styles/index.cjs +3 -2
- package/build/utils/transform-styles/index.cjs.map +3 -3
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
- package/build/utils/transform-styles/types.cjs +19 -0
- package/build/utils/transform-styles/types.cjs.map +7 -0
- package/build/utils/types.cjs +19 -0
- package/build/utils/types.cjs.map +7 -0
- package/build-module/components/block-editing-mode/index.mjs +14 -8
- package/build-module/components/block-editing-mode/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +50 -51
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-rename/modal.mjs +0 -1
- package/build-module/components/block-rename/modal.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +27 -15
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +4 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/contrast-checker/index.mjs +18 -4
- package/build-module/components/contrast-checker/index.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +155 -27
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
- package/build-module/components/global-styles/color-panel.mjs +106 -387
- package/build-module/components/global-styles/color-panel.mjs.map +3 -3
- package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +33 -0
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +84 -10
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/inspector-controls/groups.mjs +2 -0
- package/build-module/components/inspector-controls/groups.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +75 -31
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs +1 -2
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +2 -17
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs +3 -1
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -3
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/use-resize-canvas/index.mjs +6 -53
- package/build-module/components/use-resize-canvas/index.mjs.map +2 -2
- package/build-module/hooks/anchor.mjs +0 -1
- package/build-module/hooks/anchor.mjs.map +2 -2
- package/build-module/hooks/background.mjs +123 -75
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/color.mjs +2 -175
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/contrast-checker.mjs +32 -19
- package/build-module/hooks/contrast-checker.mjs.map +2 -2
- package/build-module/hooks/custom-class-name.mjs +0 -1
- package/build-module/hooks/custom-class-name.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +115 -0
- package/build-module/hooks/elements.mjs.map +7 -0
- package/build-module/hooks/grid-visualizer.mjs +21 -11
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +41 -8
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +6 -3
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/states.mjs +15 -23
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +9 -5
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +62 -10
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +105 -7
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/private-apis.mjs +0 -2
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +14 -0
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +0 -2
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +22 -6
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +17 -3
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/utils/block-bindings.mjs +9 -9
- package/build-module/utils/block-bindings.mjs.map +3 -3
- package/build-module/utils/color-values.mjs +9 -1
- package/build-module/utils/color-values.mjs.map +3 -3
- package/build-module/utils/dom.mjs +2 -5
- package/build-module/utils/dom.mjs.map +3 -3
- package/build-module/utils/fit-text-frontend.mjs +6 -2
- package/build-module/utils/fit-text-frontend.mjs.map +3 -3
- package/build-module/utils/fit-text-utils.mjs +1 -1
- package/build-module/utils/fit-text-utils.mjs.map +3 -3
- package/build-module/utils/format-font-style.mjs +1 -1
- package/build-module/utils/format-font-style.mjs.map +3 -3
- package/build-module/utils/format-font-weight.mjs +1 -1
- package/build-module/utils/format-font-weight.mjs.map +3 -3
- package/build-module/utils/get-editor-region.mjs +4 -2
- package/build-module/utils/get-editor-region.mjs.map +3 -3
- package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
- package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
- package/build-module/utils/get-px-from-css-unit.mjs +1 -1
- package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
- package/build-module/utils/index.mjs +1 -1
- package/build-module/utils/index.mjs.map +1 -1
- package/build-module/utils/math.mjs +1 -1
- package/build-module/utils/math.mjs.map +3 -3
- package/build-module/utils/object.mjs +8 -8
- package/build-module/utils/object.mjs.map +3 -3
- package/build-module/utils/order-inserter-block-items.mjs +1 -1
- package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
- package/build-module/utils/pasting.mjs +4 -2
- package/build-module/utils/pasting.mjs.map +3 -3
- package/build-module/utils/selection.mjs +2 -1
- package/build-module/utils/selection.mjs.map +3 -3
- package/build-module/utils/sorting.mjs +9 -3
- package/build-module/utils/sorting.mjs.map +3 -3
- package/build-module/utils/transform-styles/index.mjs +3 -2
- package/build-module/utils/transform-styles/index.mjs.map +3 -3
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
- package/build-module/utils/transform-styles/types.mjs +1 -0
- package/build-module/utils/transform-styles/types.mjs.map +7 -0
- package/build-module/utils/types.mjs +1 -0
- package/build-module/utils/types.mjs.map +7 -0
- package/build-style/content-rtl.css +2 -0
- package/build-style/content.css +2 -0
- package/build-style/style-rtl.css +34 -41
- package/build-style/style.css +34 -41
- package/build-types/utils/block-bindings.d.ts +27 -0
- package/build-types/utils/block-bindings.d.ts.map +1 -0
- package/build-types/utils/color-values.d.ts +40 -0
- package/build-types/utils/color-values.d.ts.map +1 -0
- package/build-types/utils/dom.d.ts +19 -19
- package/build-types/utils/dom.d.ts.map +1 -1
- package/build-types/utils/fit-text-frontend.d.ts +7 -0
- package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
- package/build-types/utils/fit-text-utils.d.ts +15 -0
- package/build-types/utils/fit-text-utils.d.ts.map +1 -0
- package/build-types/utils/format-font-style.d.ts +12 -0
- package/build-types/utils/format-font-style.d.ts.map +1 -0
- package/build-types/utils/format-font-weight.d.ts +12 -0
- package/build-types/utils/format-font-weight.d.ts.map +1 -0
- package/build-types/utils/get-editor-region.d.ts +9 -0
- package/build-types/utils/get-editor-region.d.ts.map +1 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
- package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
- package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +3 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/math.d.ts +61 -0
- package/build-types/utils/math.d.ts.map +1 -0
- package/build-types/utils/object.d.ts +39 -0
- package/build-types/utils/object.d.ts.map +1 -0
- package/build-types/utils/order-inserter-block-items.d.ts +13 -0
- package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
- package/build-types/utils/pasting.d.ts +28 -0
- package/build-types/utils/pasting.d.ts.map +1 -0
- package/build-types/utils/selection.d.ts +21 -0
- package/build-types/utils/selection.d.ts.map +1 -0
- package/build-types/utils/sorting.d.ts +17 -0
- package/build-types/utils/sorting.d.ts.map +1 -0
- package/build-types/utils/transform-styles/index.d.ts +15 -0
- package/build-types/utils/transform-styles/index.d.ts.map +1 -0
- package/build-types/utils/transform-styles/types.d.ts +13 -0
- package/build-types/utils/transform-styles/types.d.ts.map +1 -0
- package/build-types/utils/types.d.ts +28 -0
- package/build-types/utils/types.d.ts.map +1 -0
- package/package.json +40 -39
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
- package/src/components/block-editing-mode/index.js +17 -9
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
- package/src/components/block-inspector/index.js +43 -53
- package/src/components/block-rename/modal.js +0 -1
- package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
- package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
- package/src/components/colors-gradients/control.js +29 -12
- package/src/components/colors-gradients/dropdown.js +4 -1
- package/src/components/colors-gradients/style.scss +39 -2
- package/src/components/contrast-checker/README.md +9 -0
- package/src/components/contrast-checker/index.js +42 -3
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/default-block-appender/content.scss +3 -0
- package/src/components/global-styles/background-panel.js +201 -34
- package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
- package/src/components/global-styles/color-panel.js +125 -487
- package/src/components/global-styles/dimensions-panel.js +0 -3
- package/src/components/global-styles/hooks.js +45 -0
- package/src/components/global-styles/test/background-panel.js +56 -0
- package/src/components/global-styles/test/color-panel.js +172 -118
- package/src/components/global-styles/test/typography-panel.js +167 -0
- package/src/components/global-styles/typography-panel.js +100 -11
- package/src/components/inspector-controls/README.md +0 -2
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +74 -28
- package/src/components/link-control/index.js +0 -1
- package/src/components/link-control/test/index.js +2 -3
- package/src/components/list-view/block-select-button.js +2 -17
- package/src/components/provider/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +2 -0
- package/src/components/url-popover/image-url-input-ui.js +0 -2
- package/src/components/use-block-display-information/index.js +15 -2
- package/src/components/use-block-display-information/test/index.js +140 -0
- package/src/components/use-resize-canvas/index.js +10 -71
- package/src/hooks/anchor.js +0 -1
- package/src/hooks/background.js +210 -133
- package/src/hooks/background.scss +0 -35
- package/src/hooks/color.js +2 -205
- package/src/hooks/color.scss +3 -9
- package/src/hooks/contrast-checker.js +60 -17
- package/src/hooks/custom-class-name.js +0 -1
- package/src/hooks/elements.js +140 -0
- package/src/hooks/elements.scss +8 -0
- package/src/hooks/grid-visualizer.js +59 -45
- package/src/hooks/layout-child.js +51 -12
- package/src/hooks/layout.js +6 -3
- package/src/hooks/states.js +32 -28
- package/src/hooks/style.js +11 -7
- package/src/hooks/test/background.js +59 -0
- package/src/hooks/test/block-style-state.js +14 -14
- package/src/hooks/test/layout.js +6 -6
- package/src/hooks/test/style.js +8 -8
- package/src/hooks/typography.js +70 -6
- package/src/layouts/flex.js +118 -15
- package/src/private-apis.js +0 -2
- package/src/store/private-actions.js +31 -0
- package/src/store/private-keys.js +0 -1
- package/src/store/private-selectors.js +43 -7
- package/src/store/reducer.js +37 -2
- package/src/store/test/private-selectors.js +39 -14
- package/src/store/test/reducer.js +91 -12
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.ts +51 -0
- package/src/utils/color-values.ts +63 -0
- package/src/utils/{dom.js → dom.ts} +27 -27
- package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
- package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
- package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
- package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
- package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
- package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
- package/src/utils/{math.js → math.ts} +37 -30
- package/src/utils/object.ts +89 -0
- package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
- package/src/utils/{pasting.js → pasting.ts} +18 -11
- package/src/utils/{selection.js → selection.ts} +11 -4
- package/src/utils/sorting.ts +81 -0
- package/src/utils/test/color-values.js +44 -1
- package/src/utils/transform-styles/{index.js → index.ts} +25 -25
- package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
- package/src/utils/transform-styles/types.ts +13 -0
- package/src/utils/types.ts +29 -0
- package/src/components/use-resize-canvas/README.md +0 -37
- package/src/utils/block-bindings.js +0 -46
- package/src/utils/color-values.js +0 -28
- package/src/utils/object.js +0 -67
- package/src/utils/sorting.js +0 -54
- /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/global-styles/background-panel.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getValueFromVariable } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport BackgroundImageControl from '../background-image-control';\nimport { ColorPanelDropdown } from './color-panel';\nimport { useGradientsPerOrigin } from './hooks';\nimport { useToolsPanelDropdownMenuProps } from './utils';\nimport { setImmutably } from '../../utils/object';\n\nconst DEFAULT_CONTROLS = {\n\tbackgroundImage: true,\n\tgradient: true,\n};\n\n/**\n * Checks site settings to see if the requested feature's control may be used.\n *\n * @param {Object} settings Site settings.\n * @param {string} feature Background feature to check.\n * @return {boolean} Whether site settings has activated background panel.\n */\nexport function useHasBackgroundControl( settings, feature ) {\n\treturn settings?.background?.[ feature ];\n}\n\n/**\n * Checks site settings to see if the background panel may be used.\n * `settings.background.backgroundSize` exists also,\n * but can only be used if settings?.background?.backgroundImage is `true`.\n *\n * @param {Object} settings Site settings\n * @return {boolean} Whether site settings has activated background panel.\n */\nexport function useHasBackgroundPanel( settings ) {\n\tconst { backgroundImage, gradient } = settings?.background || {};\n\treturn backgroundImage || gradient;\n}\n\n/**\n * Checks if there is a current value in the background size block support\n * attributes. Background size values include background size as well\n * as background position.\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether the block has a background size value set.\n */\nexport function hasBackgroundSizeValue( style ) {\n\treturn (\n\t\tstyle?.background?.backgroundPosition !== undefined ||\n\t\tstyle?.background?.backgroundSize !== undefined\n\t);\n}\n\n/**\n * Checks if there is a current value in the background image block support\n * attributes.\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether the block has a background image value set.\n */\nexport function hasBackgroundImageValue( style ) {\n\treturn (\n\t\t!! style?.background?.backgroundImage?.id ||\n\t\t// Supports url() string values in theme.json.\n\t\t'string' === typeof style?.background?.backgroundImage ||\n\t\t!! style?.background?.backgroundImage?.url\n\t);\n}\n\n/**\n * Checks if there is a current value in the background gradient block support\n * attributes.\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether the block has a background gradient value set.\n */\nexport function hasBackgroundGradientValue( style ) {\n\treturn (\n\t\t'string' === typeof style?.background?.gradient &&\n\t\tstyle?.background?.gradient !== ''\n\t);\n}\n\nfunction BackgroundToolsPanel( {\n\tresetAllFilter,\n\tonChange,\n\tvalue,\n\tpanelId,\n\tchildren,\n\theaderLabel,\n} ) {\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst resetAll = () => {\n\t\tconst updatedValue = resetAllFilter( value );\n\t\tonChange( updatedValue );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ headerLabel }\n\t\t\tresetAll={ resetAll }\n\t\t\tpanelId={ panelId }\n\t\t\thasInnerWrapper\n\t\t\tclassName=\"background-block-support-panel\"\n\t\t\t__experimentalFirstVisibleItemClass=\"first\"\n\t\t\t__experimentalLastVisibleItemClass=\"last\"\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t<div className=\"background-block-support-panel__inner-wrapper\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</ToolsPanel>\n\t);\n}\n\nexport default function BackgroundImagePanel( {\n\tas: Wrapper = BackgroundToolsPanel,\n\tvalue,\n\tonChange,\n\tinheritedValue,\n\tsettings,\n\tpanelId,\n\tdefaultControls = DEFAULT_CONTROLS,\n\tdefaultValues = {},\n\theaderLabel = __( 'Background' ),\n} ) {\n\tconst gradients = useGradientsPerOrigin( settings );\n\tconst areCustomGradientsEnabled = settings?.color?.customGradient;\n\tconst hasGradientColors = gradients.length > 0 || areCustomGradientsEnabled;\n\n\tconst hasBackgroundGradientControl = useHasBackgroundControl(\n\t\tsettings,\n\t\t'gradient'\n\t);\n\tconst showBackgroundGradientControl =\n\t\thasGradientColors && hasBackgroundGradientControl;\n\tconst showBackgroundImageControl = useHasBackgroundControl(\n\t\tsettings,\n\t\t'backgroundImage'\n\t);\n\n\tconst resetAllFilter = useCallback(\n\t\t( previousValue ) => {\n\t\t\treturn {\n\t\t\t\t...previousValue,\n\t\t\t\tbackground: {},\n\t\t\t\tcolor: hasBackgroundGradientControl\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...previousValue?.color,\n\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: previousValue?.color,\n\t\t\t};\n\t\t},\n\t\t[ hasBackgroundGradientControl ]\n\t);\n\n\tif ( ! showBackgroundGradientControl && ! showBackgroundImageControl ) {\n\t\treturn null;\n\t}\n\n\tconst decodeValue = ( rawValue ) =>\n\t\tgetValueFromVariable( { settings }, '', rawValue );\n\tconst encodeGradientValue = ( gradientValue ) => {\n\t\tconst allGradients = gradients.flatMap(\n\t\t\t( { gradients: originGradients } ) => originGradients\n\t\t);\n\t\tconst gradientObject = allGradients.find(\n\t\t\t( { gradient } ) => gradient === gradientValue\n\t\t);\n\t\treturn gradientObject\n\t\t\t? 'var:preset|gradient|' + gradientObject.slug\n\t\t\t: gradientValue;\n\t};\n\n\tconst resetBackground = () =>\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'background', 'backgroundImage' ],\n\t\t\t\tundefined\n\t\t\t)\n\t\t);\n\n\tconst resetGradient = () => {\n\t\tlet newValue = setImmutably(\n\t\t\tvalue,\n\t\t\t[ 'background', 'gradient' ],\n\t\t\tundefined\n\t\t);\n\t\tnewValue = setImmutably( newValue, [ 'color', 'gradient' ], undefined );\n\t\tonChange( newValue );\n\t};\n\n\t// Get current gradient value, decoding preset slug references.\n\t// Fall back to color.gradient for legacy blocks that haven't migrated\n\t// to background.gradient yet (mirrors block inspector fallback in\n\t// packages/block-editor/src/hooks/background.js).\n\tconst currentGradient = decodeValue(\n\t\tvalue?.background?.gradient ?? value?.color?.gradient\n\t);\n\tconst inheritedGradient = decodeValue(\n\t\tinheritedValue?.background?.gradient ?? inheritedValue?.color?.gradient\n\t);\n\n\t// Set gradient value, encoding preset matches as slug references.\n\t// Also clear color.gradient to migrate from the legacy location,\n\t// matching the block inspector behavior in hooks/background.js.\n\tconst setGradient = ( newGradient ) => {\n\t\tlet newValue = setImmutably(\n\t\t\tvalue,\n\t\t\t[ 'background', 'gradient' ],\n\t\t\tencodeGradientValue( newGradient )\n\t\t);\n\t\tnewValue = setImmutably( newValue, [ 'color', 'gradient' ], undefined );\n\t\tonChange( newValue );\n\t};\n\n\treturn (\n\t\t<Wrapper\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tpanelId={ panelId }\n\t\t\theaderLabel={ headerLabel }\n\t\t>\n\t\t\t{ showBackgroundImageControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"block-editor-background-panel__item\"\n\t\t\t\t\thasValue={ () => hasBackgroundImageValue( value ) }\n\t\t\t\t\tlabel={ __( 'Image' ) }\n\t\t\t\t\tonDeselect={ resetBackground }\n\t\t\t\t\tisShownByDefault={ defaultControls.backgroundImage }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BackgroundImageControl\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tinheritedValue={ inheritedValue }\n\t\t\t\t\t\tdefaultControls={ defaultControls }\n\t\t\t\t\t\tdefaultValues={ defaultValues }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBackgroundGradientControl && (\n\t\t\t\t<ColorPanelDropdown\n\t\t\t\t\tclassName=\"block-editor-background-panel__item\"\n\t\t\t\t\tlabel={ __( 'Gradient' ) }\n\t\t\t\t\thasValue={ () => hasBackgroundGradientValue( value ) }\n\t\t\t\t\tresetValue={ resetGradient }\n\t\t\t\t\tisShownByDefault={ defaultControls.gradient }\n\t\t\t\t\tindicators={ [ currentGradient ] }\n\t\t\t\t\ttabs={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: 'gradient',\n\t\t\t\t\t\t\tlabel: __( 'Gradient' ),\n\t\t\t\t\t\t\tinheritedValue:\n\t\t\t\t\t\t\t\tcurrentGradient ?? inheritedGradient,\n\t\t\t\t\t\t\tsetValue: setGradient,\n\t\t\t\t\t\t\tuserValue: currentGradient,\n\t\t\t\t\t\t\tisGradient: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t\tcolorGradientControlSettings={ {\n\t\t\t\t\t\tgradients,\n\t\t\t\t\t\tdisableCustomGradients: ! areCustomGradientsEnabled,\n\t\t\t\t\t} }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Wrapper>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,mBAAmB;AAC5B,SAAS,UAAU;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BackgroundImageControl from '../background-image-control';\nimport ColorGradientDropdownItem from './color-gradient-dropdown-item';\nimport { useHasBackgroundColorPanel } from './color-panel';\nimport { useColorGradientSettings } from './hooks';\nimport { useToolsPanelDropdownMenuProps } from './utils';\nimport { setImmutably } from '../../utils/object';\nimport {\n\textractPresetSlug,\n\tencodeColorValueWithPalette,\n} from '../../utils/color-values';\n\nconst DEFAULT_CONTROLS = {\n\tbackgroundImage: true,\n\tbackgroundColor: true,\n\tgradient: true,\n};\n\n/**\n * Checks site settings to see if the requested feature's control may be used.\n *\n * @param {Object} settings Site settings.\n * @param {string} feature Background feature to check.\n * @return {boolean} Whether site settings has activated background panel.\n */\nexport function useHasBackgroundControl( settings, feature ) {\n\treturn settings?.background?.[ feature ];\n}\n\n/**\n * Checks site settings to see if the background panel may be used.\n * `settings.background.backgroundSize` exists also,\n * but can only be used if settings?.background?.backgroundImage is `true`.\n *\n * The panel is also shown when the block has color panel background\n * support (`settings.color.background`), because background color and\n * the legacy `color.gradient` control are rendered here.\n *\n * @param {Object} settings Site settings\n * @return {boolean} Whether site settings has activated background panel.\n */\nexport function useHasBackgroundPanel( settings ) {\n\tconst hasBackgroundColor = useHasBackgroundColorPanel( settings );\n\tconst { backgroundImage, gradient } = settings?.background || {};\n\treturn backgroundImage || gradient || hasBackgroundColor;\n}\n\n/**\n * Checks if there is a current value in the background size block support\n * attributes. Background size values include background size as well\n * as background position.\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether the block has a background size value set.\n */\nexport function hasBackgroundSizeValue( style ) {\n\treturn (\n\t\tstyle?.background?.backgroundPosition !== undefined ||\n\t\tstyle?.background?.backgroundSize !== undefined\n\t);\n}\n\n/**\n * Checks if there is a current value in the background image block support\n * attributes.\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether the block has a background image value set.\n */\nexport function hasBackgroundImageValue( style ) {\n\treturn (\n\t\t!! style?.background?.backgroundImage?.id ||\n\t\t// Supports url() string values in theme.json.\n\t\t'string' === typeof style?.background?.backgroundImage ||\n\t\t!! style?.background?.backgroundImage?.url\n\t);\n}\n\n/**\n * Checks if there is a current value in the background gradient block support\n * attributes.\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether the block has a background gradient value set.\n */\nexport function hasBackgroundGradientValue( style ) {\n\treturn (\n\t\t'string' === typeof style?.background?.gradient &&\n\t\tstyle?.background?.gradient !== ''\n\t);\n}\n\n/**\n * Checks if there is a current value for the background color (written to\n * `color.background`).\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether the block has a background color value set.\n */\nexport function hasBackgroundColorValue( style ) {\n\treturn !! style?.color?.background;\n}\n\n/**\n * Checks if there is a current value in the legacy `color.gradient` location\n * (used by blocks with color panel gradient support that haven't adopted the\n * `background.gradient` block support).\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether the block has a legacy color gradient value set.\n */\nexport function hasLegacyColorGradientValue( style ) {\n\treturn !! style?.color?.gradient;\n}\n\nexport function BackgroundToolsPanel( {\n\tresetAllFilter,\n\tonChange,\n\tvalue,\n\tpanelId,\n\tchildren,\n\theaderLabel,\n} ) {\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst resetAll = () => {\n\t\tconst updatedValue = resetAllFilter( value );\n\t\tonChange( updatedValue );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ headerLabel }\n\t\t\tresetAll={ resetAll }\n\t\t\tpanelId={ panelId }\n\t\t\thasInnerWrapper\n\t\t\tclassName=\"background-block-support-panel\"\n\t\t\t__experimentalFirstVisibleItemClass=\"first\"\n\t\t\t__experimentalLastVisibleItemClass=\"last\"\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t<div className=\"background-block-support-panel__inner-wrapper\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</ToolsPanel>\n\t);\n}\n\nexport default function BackgroundImagePanel( {\n\tas: Wrapper = BackgroundToolsPanel,\n\tvalue,\n\tonChange,\n\tinheritedValue = value,\n\tsettings,\n\tpanelId,\n\tdefaultControls = DEFAULT_CONTROLS,\n\tdefaultValues = {},\n\theaderLabel = __( 'Background' ),\n\tcontrastWarning,\n} ) {\n\tconst {\n\t\tcolors,\n\t\tgradients,\n\t\tallColors,\n\t\tareCustomSolidsEnabled,\n\t\tareCustomGradientsEnabled,\n\t\thasSolidColors,\n\t\thasGradientColors,\n\t\tdecodeValue,\n\t\tencodeGradientValue,\n\t} = useColorGradientSettings( settings );\n\n\tconst hasBackgroundGradientControl = useHasBackgroundControl(\n\t\tsettings,\n\t\t'gradient'\n\t);\n\tconst hasColorPanelBackgroundSupport =\n\t\tuseHasBackgroundColorPanel( settings );\n\tconst showBackgroundColorControl =\n\t\thasColorPanelBackgroundSupport && hasSolidColors;\n\t// New `background.gradient` block support — gradient lives under the\n\t// `background` style path.\n\tconst showBackgroundGradientControl =\n\t\thasGradientColors && hasBackgroundGradientControl;\n\t// Legacy `color.gradient` path — only rendered when the block has\n\t// color panel background support and hasn't adopted the newer\n\t// `background.gradient` support. Keeps the UI consistent for blocks\n\t// that still write gradients to `color.gradient`.\n\tconst showLegacyColorGradientControl =\n\t\thasColorPanelBackgroundSupport &&\n\t\thasGradientColors &&\n\t\t! hasBackgroundGradientControl;\n\tconst showBackgroundImageControl = useHasBackgroundControl(\n\t\tsettings,\n\t\t'backgroundImage'\n\t);\n\n\tconst resetAllFilter = useCallback(\n\t\t( previousValue ) => {\n\t\t\tconst clearsColorBackground = showBackgroundColorControl;\n\t\t\tconst clearsColorGradient =\n\t\t\t\thasBackgroundGradientControl || showLegacyColorGradientControl;\n\t\t\tif ( ! clearsColorBackground && ! clearsColorGradient ) {\n\t\t\t\treturn { ...previousValue, background: {} };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...previousValue,\n\t\t\t\tbackground: {},\n\t\t\t\tcolor: {\n\t\t\t\t\t...previousValue?.color,\n\t\t\t\t\t...( clearsColorBackground && { background: undefined } ),\n\t\t\t\t\t...( clearsColorGradient && { gradient: undefined } ),\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\thasBackgroundGradientControl,\n\t\t\tshowBackgroundColorControl,\n\t\t\tshowLegacyColorGradientControl,\n\t\t]\n\t);\n\n\tif (\n\t\t! showBackgroundImageControl &&\n\t\t! showBackgroundColorControl &&\n\t\t! showBackgroundGradientControl &&\n\t\t! showLegacyColorGradientControl\n\t) {\n\t\treturn null;\n\t}\n\n\tconst resetBackground = () =>\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'background', 'backgroundImage' ],\n\t\t\t\tundefined\n\t\t\t)\n\t\t);\n\n\tconst resetGradient = () => {\n\t\tlet newValue = setImmutably(\n\t\t\tvalue,\n\t\t\t[ 'background', 'gradient' ],\n\t\t\tundefined\n\t\t);\n\t\tnewValue = setImmutably( newValue, [ 'color', 'gradient' ], undefined );\n\t\tonChange( newValue );\n\t};\n\n\t// Background color (written to `color.background`).\n\tconst backgroundColor = decodeValue( inheritedValue?.color?.background );\n\tconst userBackgroundColor = decodeValue( value?.color?.background );\n\tconst setBackgroundColor = ( newColor, newSlug ) => {\n\t\tconst newValue = setImmutably(\n\t\t\tvalue,\n\t\t\t[ 'color', 'background' ],\n\t\t\tencodeColorValueWithPalette( allColors, newColor, newSlug )\n\t\t);\n\t\t// Legacy `color.gradient` is mutually exclusive with\n\t\t// `color.background`. `background.gradient` is independent and\n\t\t// should not be touched.\n\t\tif ( showLegacyColorGradientControl ) {\n\t\t\tnewValue.color.gradient = undefined;\n\t\t}\n\t\tonChange( newValue );\n\t};\n\tconst resetBackgroundColor = () => {\n\t\tconst newValue = setImmutably(\n\t\t\tvalue,\n\t\t\t[ 'color', 'background' ],\n\t\t\tundefined\n\t\t);\n\t\tif ( showLegacyColorGradientControl ) {\n\t\t\tnewValue.color.gradient = undefined;\n\t\t}\n\t\tonChange( newValue );\n\t};\n\n\t// Legacy `color.gradient` setters.\n\tconst legacyColorGradient = decodeValue( inheritedValue?.color?.gradient );\n\tconst userLegacyColorGradient = decodeValue( value?.color?.gradient );\n\tconst setLegacyColorGradient = ( newGradient ) => {\n\t\tconst newValue = setImmutably(\n\t\t\tvalue,\n\t\t\t[ 'color', 'gradient' ],\n\t\t\tencodeGradientValue( newGradient )\n\t\t);\n\t\tnewValue.color.background = undefined;\n\t\tonChange( newValue );\n\t};\n\tconst resetLegacyColorGradient = () =>\n\t\tonChange( setImmutably( value, [ 'color', 'gradient' ], undefined ) );\n\n\t// Get current gradient value, decoding preset slug references.\n\t// Fall back to color.gradient for legacy blocks that haven't migrated\n\t// to background.gradient yet (mirrors block inspector fallback in\n\t// packages/block-editor/src/hooks/background.js).\n\tconst currentGradient = decodeValue(\n\t\tvalue?.background?.gradient ?? value?.color?.gradient\n\t);\n\tconst inheritedGradient = decodeValue(\n\t\tinheritedValue?.background?.gradient ?? inheritedValue?.color?.gradient\n\t);\n\n\t// Set gradient value, encoding preset matches as slug references.\n\t// Also clear color.gradient to migrate from the legacy location,\n\t// matching the block inspector behavior in hooks/background.js.\n\tconst setGradient = ( newGradient ) => {\n\t\tlet newValue = setImmutably(\n\t\t\tvalue,\n\t\t\t[ 'background', 'gradient' ],\n\t\t\tencodeGradientValue( newGradient )\n\t\t);\n\t\tnewValue = setImmutably( newValue, [ 'color', 'gradient' ], undefined );\n\t\tonChange( newValue );\n\t};\n\n\treturn (\n\t\t<Wrapper\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tpanelId={ panelId }\n\t\t\theaderLabel={ headerLabel }\n\t\t>\n\t\t\t{ showBackgroundImageControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"block-editor-color-gradient-item\"\n\t\t\t\t\thasValue={ () => hasBackgroundImageValue( value ) }\n\t\t\t\t\tlabel={ __( 'Image' ) }\n\t\t\t\t\tonDeselect={ resetBackground }\n\t\t\t\t\tisShownByDefault={ defaultControls.backgroundImage }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BackgroundImageControl\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tinheritedValue={ inheritedValue }\n\t\t\t\t\t\tdefaultControls={ defaultControls }\n\t\t\t\t\t\tdefaultValues={ defaultValues }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBackgroundColorControl && (\n\t\t\t\t<ColorGradientDropdownItem\n\t\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\t\thasValue={ () => hasBackgroundColorValue( value ) }\n\t\t\t\t\tresetValue={ resetBackgroundColor }\n\t\t\t\t\tisShownByDefault={ defaultControls.backgroundColor }\n\t\t\t\t\tindicators={ [ userBackgroundColor ?? backgroundColor ] }\n\t\t\t\t\tcontrastWarning={ contrastWarning }\n\t\t\t\t\ttabs={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: 'background',\n\t\t\t\t\t\t\tlabel: __( 'Color' ),\n\t\t\t\t\t\t\tinheritedValue:\n\t\t\t\t\t\t\t\tuserBackgroundColor ?? backgroundColor,\n\t\t\t\t\t\t\t// Resolve the slug from the same source as the\n\t\t\t\t\t\t\t// displayed value (user value first, then the\n\t\t\t\t\t\t\t// inherited fallback). For a block instance the\n\t\t\t\t\t\t\t// selection lives in `value` while `inheritedValue`\n\t\t\t\t\t\t\t// only holds the global styles fallback, so reading\n\t\t\t\t\t\t\t// the slug from `inheritedValue` alone would miss it\n\t\t\t\t\t\t\t// and two same-hex presets would both appear selected.\n\t\t\t\t\t\t\tinheritedSlug:\n\t\t\t\t\t\t\t\textractPresetSlug(\n\t\t\t\t\t\t\t\t\tvalue?.color?.background,\n\t\t\t\t\t\t\t\t\t'color'\n\t\t\t\t\t\t\t\t) ??\n\t\t\t\t\t\t\t\textractPresetSlug(\n\t\t\t\t\t\t\t\t\tinheritedValue?.color?.background,\n\t\t\t\t\t\t\t\t\t'color'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsetValue: setBackgroundColor,\n\t\t\t\t\t\t\tuserValue: userBackgroundColor,\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t\tcolorGradientControlSettings={ {\n\t\t\t\t\t\tcolors,\n\t\t\t\t\t\tdisableCustomColors: ! areCustomSolidsEnabled,\n\t\t\t\t\t} }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showBackgroundGradientControl && (\n\t\t\t\t<ColorGradientDropdownItem\n\t\t\t\t\tlabel={ __( 'Gradient' ) }\n\t\t\t\t\thasValue={ () => hasBackgroundGradientValue( value ) }\n\t\t\t\t\tresetValue={ resetGradient }\n\t\t\t\t\tisShownByDefault={ defaultControls.gradient }\n\t\t\t\t\tindicators={ [ currentGradient ] }\n\t\t\t\t\ttabs={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: 'gradient',\n\t\t\t\t\t\t\tlabel: __( 'Gradient' ),\n\t\t\t\t\t\t\tinheritedValue:\n\t\t\t\t\t\t\t\tcurrentGradient ?? inheritedGradient,\n\t\t\t\t\t\t\tsetValue: setGradient,\n\t\t\t\t\t\t\tuserValue: currentGradient,\n\t\t\t\t\t\t\tisGradient: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t\tcolorGradientControlSettings={ {\n\t\t\t\t\t\tgradients,\n\t\t\t\t\t\tdisableCustomGradients: ! areCustomGradientsEnabled,\n\t\t\t\t\t} }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showLegacyColorGradientControl && (\n\t\t\t\t<ColorGradientDropdownItem\n\t\t\t\t\tlabel={ __( 'Gradient' ) }\n\t\t\t\t\thasValue={ () => hasLegacyColorGradientValue( value ) }\n\t\t\t\t\tresetValue={ resetLegacyColorGradient }\n\t\t\t\t\tisShownByDefault={ defaultControls.gradient }\n\t\t\t\t\tindicators={ [\n\t\t\t\t\t\tuserLegacyColorGradient ?? legacyColorGradient,\n\t\t\t\t\t] }\n\t\t\t\t\ttabs={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: 'gradient',\n\t\t\t\t\t\t\tlabel: __( 'Gradient' ),\n\t\t\t\t\t\t\tinheritedValue:\n\t\t\t\t\t\t\t\tuserLegacyColorGradient ?? legacyColorGradient,\n\t\t\t\t\t\t\tsetValue: setLegacyColorGradient,\n\t\t\t\t\t\t\tuserValue: userLegacyColorGradient,\n\t\t\t\t\t\t\tisGradient: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t\tcolorGradientControlSettings={ {\n\t\t\t\t\t\tgradients,\n\t\t\t\t\t\tdisableCustomGradients: ! areCustomGradientsEnabled,\n\t\t\t\t\t} }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Wrapper>\n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CAAE;AAAA,YAC3B;AAAA,YACA;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// packages/block-editor/src/components/global-styles/color-gradient-dropdown-item.js
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import {
|
|
4
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
5
|
+
__experimentalHStack as HStack,
|
|
6
|
+
__experimentalZStack as ZStack,
|
|
7
|
+
__experimentalDropdownContentWrapper as DropdownContentWrapper,
|
|
8
|
+
ColorIndicator,
|
|
9
|
+
Flex,
|
|
10
|
+
FlexItem,
|
|
11
|
+
Dropdown,
|
|
12
|
+
Button,
|
|
13
|
+
privateApis as componentsPrivateApis
|
|
14
|
+
} from "@wordpress/components";
|
|
15
|
+
import { useRef } from "@wordpress/element";
|
|
16
|
+
import { __ } from "@wordpress/i18n";
|
|
17
|
+
import { reset as resetIcon, caution as cautionIcon } from "@wordpress/icons";
|
|
18
|
+
import ColorGradientControl from "../colors-gradients/control.mjs";
|
|
19
|
+
import { unlock } from "../../lock-unlock.mjs";
|
|
20
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
var { Tabs } = unlock(componentsPrivateApis);
|
|
22
|
+
function DropdownContent({
|
|
23
|
+
tabs,
|
|
24
|
+
colorGradientControlSettings,
|
|
25
|
+
contrastWarning
|
|
26
|
+
}) {
|
|
27
|
+
const { key: firstTabKey, ...firstTab } = tabs[0] ?? {};
|
|
28
|
+
const defaultTabId = tabs.find(
|
|
29
|
+
(tab) => tab.userValue !== void 0
|
|
30
|
+
)?.key;
|
|
31
|
+
return /* @__PURE__ */ jsx(DropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ jsxs("div", { className: "block-editor-panel-color-gradient-settings__dropdown-content", children: [
|
|
32
|
+
tabs.length === 1 && /* @__PURE__ */ jsx(
|
|
33
|
+
ColorGradientTab,
|
|
34
|
+
{
|
|
35
|
+
...firstTab,
|
|
36
|
+
colorGradientControlSettings,
|
|
37
|
+
contrastWarning
|
|
38
|
+
},
|
|
39
|
+
firstTabKey
|
|
40
|
+
),
|
|
41
|
+
tabs.length > 1 && /* @__PURE__ */ jsxs(Tabs, { defaultTabId, children: [
|
|
42
|
+
/* @__PURE__ */ jsx(Tabs.TabList, { children: tabs.map((tab) => /* @__PURE__ */ jsx(Tabs.Tab, { tabId: tab.key, children: tab.label }, tab.key)) }),
|
|
43
|
+
tabs.map((tab) => {
|
|
44
|
+
const { key: tabKey, ...restTabProps } = tab;
|
|
45
|
+
return /* @__PURE__ */ jsx(
|
|
46
|
+
Tabs.TabPanel,
|
|
47
|
+
{
|
|
48
|
+
tabId: tabKey,
|
|
49
|
+
focusable: false,
|
|
50
|
+
children: /* @__PURE__ */ jsx(
|
|
51
|
+
ColorGradientTab,
|
|
52
|
+
{
|
|
53
|
+
...restTabProps,
|
|
54
|
+
colorGradientControlSettings,
|
|
55
|
+
contrastWarning
|
|
56
|
+
},
|
|
57
|
+
tabKey
|
|
58
|
+
)
|
|
59
|
+
},
|
|
60
|
+
tabKey
|
|
61
|
+
);
|
|
62
|
+
})
|
|
63
|
+
] })
|
|
64
|
+
] }) });
|
|
65
|
+
}
|
|
66
|
+
var popoverProps = {
|
|
67
|
+
placement: "left-start",
|
|
68
|
+
offset: 36,
|
|
69
|
+
shift: true
|
|
70
|
+
};
|
|
71
|
+
var LabeledColorIndicators = ({ indicators, label }) => /* @__PURE__ */ jsxs(HStack, { justify: "flex-start", children: [
|
|
72
|
+
/* @__PURE__ */ jsx(ZStack, { isLayered: false, offset: -8, children: indicators.map((indicator, index) => /* @__PURE__ */ jsx(Flex, { expanded: false, children: /* @__PURE__ */ jsx(ColorIndicator, { colorValue: indicator }) }, index)) }),
|
|
73
|
+
/* @__PURE__ */ jsx(FlexItem, { className: "block-editor-panel-color-gradient-settings__color-name", children: label })
|
|
74
|
+
] });
|
|
75
|
+
function ColorGradientTab({
|
|
76
|
+
isGradient,
|
|
77
|
+
inheritedValue,
|
|
78
|
+
inheritedSlug,
|
|
79
|
+
userValue,
|
|
80
|
+
setValue,
|
|
81
|
+
colorGradientControlSettings,
|
|
82
|
+
contrastWarning
|
|
83
|
+
}) {
|
|
84
|
+
return /* @__PURE__ */ jsx(
|
|
85
|
+
ColorGradientControl,
|
|
86
|
+
{
|
|
87
|
+
...colorGradientControlSettings,
|
|
88
|
+
showTitle: false,
|
|
89
|
+
enableAlpha: true,
|
|
90
|
+
__experimentalIsRenderedInSidebar: true,
|
|
91
|
+
colorValue: isGradient ? void 0 : inheritedValue,
|
|
92
|
+
colorSlug: isGradient ? void 0 : inheritedSlug,
|
|
93
|
+
gradientValue: isGradient ? inheritedValue : void 0,
|
|
94
|
+
onColorChange: isGradient ? void 0 : setValue,
|
|
95
|
+
onGradientChange: isGradient ? setValue : void 0,
|
|
96
|
+
clearable: inheritedValue === userValue,
|
|
97
|
+
headingLevel: 3,
|
|
98
|
+
noticeProps: !isGradient && contrastWarning ? {
|
|
99
|
+
children: contrastWarning,
|
|
100
|
+
status: "warning",
|
|
101
|
+
spokenMessage: null,
|
|
102
|
+
className: "block-editor-panel-color-gradient-settings__contrast-notice"
|
|
103
|
+
} : void 0
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
function ColorGradientDropdownItem({
|
|
108
|
+
label,
|
|
109
|
+
hasValue,
|
|
110
|
+
resetValue,
|
|
111
|
+
isShownByDefault,
|
|
112
|
+
indicators,
|
|
113
|
+
tabs,
|
|
114
|
+
colorGradientControlSettings,
|
|
115
|
+
panelId,
|
|
116
|
+
contrastWarning,
|
|
117
|
+
className = "block-editor-tools-panel-color-gradient-settings__item"
|
|
118
|
+
}) {
|
|
119
|
+
const colorGradientDropdownButtonRef = useRef(void 0);
|
|
120
|
+
return /* @__PURE__ */ jsx(
|
|
121
|
+
ToolsPanelItem,
|
|
122
|
+
{
|
|
123
|
+
className: clsx("block-editor-color-gradient-item", className),
|
|
124
|
+
hasValue,
|
|
125
|
+
label,
|
|
126
|
+
onDeselect: resetValue,
|
|
127
|
+
isShownByDefault,
|
|
128
|
+
panelId,
|
|
129
|
+
children: /* @__PURE__ */ jsx(
|
|
130
|
+
Dropdown,
|
|
131
|
+
{
|
|
132
|
+
popoverProps,
|
|
133
|
+
className: "block-editor-tools-panel-color-gradient-settings__dropdown",
|
|
134
|
+
renderToggle: ({ onToggle, isOpen }) => {
|
|
135
|
+
const toggleProps = {
|
|
136
|
+
onClick: onToggle,
|
|
137
|
+
className: clsx(
|
|
138
|
+
"block-editor-panel-color-gradient-settings__dropdown",
|
|
139
|
+
{
|
|
140
|
+
"is-open": isOpen,
|
|
141
|
+
"has-contrast-warning": !!contrastWarning
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
"aria-expanded": isOpen,
|
|
145
|
+
ref: colorGradientDropdownButtonRef
|
|
146
|
+
};
|
|
147
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
148
|
+
/* @__PURE__ */ jsx(Button, { ...toggleProps, __next40pxDefaultSize: true, children: /* @__PURE__ */ jsx(
|
|
149
|
+
LabeledColorIndicators,
|
|
150
|
+
{
|
|
151
|
+
indicators,
|
|
152
|
+
label
|
|
153
|
+
}
|
|
154
|
+
) }),
|
|
155
|
+
hasValue() && /* @__PURE__ */ jsx(
|
|
156
|
+
Button,
|
|
157
|
+
{
|
|
158
|
+
__next40pxDefaultSize: true,
|
|
159
|
+
label: __("Reset"),
|
|
160
|
+
className: "block-editor-panel-color-gradient-settings__reset",
|
|
161
|
+
size: "small",
|
|
162
|
+
icon: resetIcon,
|
|
163
|
+
onClick: () => {
|
|
164
|
+
resetValue();
|
|
165
|
+
if (isOpen) {
|
|
166
|
+
onToggle();
|
|
167
|
+
}
|
|
168
|
+
colorGradientDropdownButtonRef.current?.focus();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
contrastWarning && // An icon-only warning that stays visible while a
|
|
173
|
+
// contrast warning is in effect. It is not a menu;
|
|
174
|
+
// activating it opens the color picker popover where
|
|
175
|
+
// the full warning notice is shown, so the indicator
|
|
176
|
+
// doubles as a shortcut to where the issue is fixed.
|
|
177
|
+
/* @__PURE__ */ jsx(
|
|
178
|
+
Button,
|
|
179
|
+
{
|
|
180
|
+
__next40pxDefaultSize: true,
|
|
181
|
+
size: "small",
|
|
182
|
+
icon: cautionIcon,
|
|
183
|
+
label: __("Low contrast"),
|
|
184
|
+
className: "block-editor-panel-color-gradient-settings__contrast-warning",
|
|
185
|
+
"aria-expanded": isOpen,
|
|
186
|
+
onClick: onToggle
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
] });
|
|
190
|
+
},
|
|
191
|
+
renderContent: () => /* @__PURE__ */ jsx(
|
|
192
|
+
DropdownContent,
|
|
193
|
+
{
|
|
194
|
+
tabs,
|
|
195
|
+
colorGradientControlSettings,
|
|
196
|
+
contrastWarning
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
export {
|
|
205
|
+
ColorGradientDropdownItem as default
|
|
206
|
+
};
|
|
207
|
+
//# sourceMappingURL=color-gradient-dropdown-item.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/global-styles/color-gradient-dropdown-item.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalHStack as HStack,\n\t__experimentalZStack as ZStack,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n\tColorIndicator,\n\tFlex,\n\tFlexItem,\n\tDropdown,\n\tButton,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { reset as resetIcon, caution as cautionIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport ColorGradientControl from '../colors-gradients/control';\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\n/**\n * @typedef {Object} DropdownContentProps\n * @property {Array} tabs Tab configurations to render.\n * @property {Object} colorGradientControlSettings Settings passed to ColorGradientControl.\n * @property {string} [contrastWarning] Contrast warning message for the color value.\n */\n\n/**\n * Renders the dropdown content containing the color/gradient picker tabs.\n *\n * @param {DropdownContentProps} props\n */\nfunction DropdownContent( {\n\ttabs,\n\tcolorGradientControlSettings,\n\tcontrastWarning,\n} ) {\n\tconst { key: firstTabKey, ...firstTab } = tabs[ 0 ] ?? {};\n\tconst defaultTabId = tabs.find(\n\t\t( tab ) => tab.userValue !== undefined\n\t)?.key;\n\treturn (\n\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t<div className=\"block-editor-panel-color-gradient-settings__dropdown-content\">\n\t\t\t\t{ tabs.length === 1 && (\n\t\t\t\t\t<ColorGradientTab\n\t\t\t\t\t\tkey={ firstTabKey }\n\t\t\t\t\t\t{ ...firstTab }\n\t\t\t\t\t\tcolorGradientControlSettings={\n\t\t\t\t\t\t\tcolorGradientControlSettings\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontrastWarning={ contrastWarning }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ tabs.length > 1 && (\n\t\t\t\t\t<Tabs defaultTabId={ defaultTabId }>\n\t\t\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t\t\t<Tabs.Tab key={ tab.key } tabId={ tab.key }>\n\t\t\t\t\t\t\t\t\t{ tab.label }\n\t\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t</Tabs.TabList>\n\n\t\t\t\t\t\t{ tabs.map( ( tab ) => {\n\t\t\t\t\t\t\tconst { key: tabKey, ...restTabProps } = tab;\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\tkey={ tabKey }\n\t\t\t\t\t\t\t\t\ttabId={ tabKey }\n\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<ColorGradientTab\n\t\t\t\t\t\t\t\t\t\tkey={ tabKey }\n\t\t\t\t\t\t\t\t\t\t{ ...restTabProps }\n\t\t\t\t\t\t\t\t\t\tcolorGradientControlSettings={\n\t\t\t\t\t\t\t\t\t\t\tcolorGradientControlSettings\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tcontrastWarning={ contrastWarning }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t</Tabs>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</DropdownContentWrapper>\n\t);\n}\n\nconst popoverProps = {\n\tplacement: 'left-start',\n\toffset: 36,\n\tshift: true,\n};\n\nconst LabeledColorIndicators = ( { indicators, label } ) => (\n\t<HStack justify=\"flex-start\">\n\t\t<ZStack isLayered={ false } offset={ -8 }>\n\t\t\t{ indicators.map( ( indicator, index ) => (\n\t\t\t\t<Flex key={ index } expanded={ false }>\n\t\t\t\t\t<ColorIndicator colorValue={ indicator } />\n\t\t\t\t</Flex>\n\t\t\t) ) }\n\t\t</ZStack>\n\t\t<FlexItem className=\"block-editor-panel-color-gradient-settings__color-name\">\n\t\t\t{ label }\n\t\t</FlexItem>\n\t</HStack>\n);\n\nfunction ColorGradientTab( {\n\tisGradient,\n\tinheritedValue,\n\tinheritedSlug,\n\tuserValue,\n\tsetValue,\n\tcolorGradientControlSettings,\n\tcontrastWarning,\n} ) {\n\treturn (\n\t\t<ColorGradientControl\n\t\t\t{ ...colorGradientControlSettings }\n\t\t\tshowTitle={ false }\n\t\t\tenableAlpha\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t\tcolorValue={ isGradient ? undefined : inheritedValue }\n\t\t\tcolorSlug={ isGradient ? undefined : inheritedSlug }\n\t\t\tgradientValue={ isGradient ? inheritedValue : undefined }\n\t\t\tonColorChange={ isGradient ? undefined : setValue }\n\t\t\tonGradientChange={ isGradient ? setValue : undefined }\n\t\t\tclearable={ inheritedValue === userValue }\n\t\t\theadingLevel={ 3 }\n\t\t\tnoticeProps={\n\t\t\t\t! isGradient && contrastWarning\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tchildren: contrastWarning,\n\t\t\t\t\t\t\tstatus: 'warning',\n\t\t\t\t\t\t\tspokenMessage: null,\n\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t'block-editor-panel-color-gradient-settings__contrast-notice',\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t/>\n\t);\n}\n\n// Renders a ToolsPanelItem that opens a dropdown containing one or more\n// color/gradient pickers. Shared between the Color, Background, and\n// Typography panels for consistent color-style controls.\nexport default function ColorGradientDropdownItem( {\n\tlabel,\n\thasValue,\n\tresetValue,\n\tisShownByDefault,\n\tindicators,\n\ttabs,\n\tcolorGradientControlSettings,\n\tpanelId,\n\tcontrastWarning,\n\tclassName = 'block-editor-tools-panel-color-gradient-settings__item',\n} ) {\n\tconst colorGradientDropdownButtonRef = useRef( undefined );\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tclassName={ clsx( 'block-editor-color-gradient-item', className ) }\n\t\t\thasValue={ hasValue }\n\t\t\tlabel={ label }\n\t\t\tonDeselect={ resetValue }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tclassName=\"block-editor-tools-panel-color-gradient-settings__dropdown\"\n\t\t\t\trenderToggle={ ( { onToggle, isOpen } ) => {\n\t\t\t\t\tconst toggleProps = {\n\t\t\t\t\t\tonClick: onToggle,\n\t\t\t\t\t\tclassName: clsx(\n\t\t\t\t\t\t\t'block-editor-panel-color-gradient-settings__dropdown',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-open': isOpen,\n\t\t\t\t\t\t\t\t'has-contrast-warning': !! contrastWarning,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'aria-expanded': isOpen,\n\t\t\t\t\t\tref: colorGradientDropdownButtonRef,\n\t\t\t\t\t};\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<Button { ...toggleProps } __next40pxDefaultSize>\n\t\t\t\t\t\t\t\t<LabeledColorIndicators\n\t\t\t\t\t\t\t\t\tindicators={ indicators }\n\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t{ hasValue() && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Reset' ) }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-panel-color-gradient-settings__reset\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\ticon={ resetIcon }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tresetValue();\n\t\t\t\t\t\t\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tcolorGradientDropdownButtonRef.current?.focus();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ contrastWarning && (\n\t\t\t\t\t\t\t\t// An icon-only warning that stays visible while a\n\t\t\t\t\t\t\t\t// contrast warning is in effect. It is not a menu;\n\t\t\t\t\t\t\t\t// activating it opens the color picker popover where\n\t\t\t\t\t\t\t\t// the full warning notice is shown, so the indicator\n\t\t\t\t\t\t\t\t// doubles as a shortcut to where the issue is fixed.\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\ticon={ cautionIcon }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Low contrast' ) }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-panel-color-gradient-settings__contrast-warning\"\n\t\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t\trenderContent={ () => (\n\t\t\t\t\t<DropdownContent\n\t\t\t\t\t\ttabs={ tabs }\n\t\t\t\t\t\tcolorGradientControlSettings={\n\t\t\t\t\t\t\tcolorGradientControlSettings\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontrastWarning={ contrastWarning }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</ToolsPanelItem>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC,gCAAgC;AAAA,EAChC,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,wCAAwC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,SAAS,WAAW,WAAW,mBAAmB;AAK3D,OAAO,0BAA0B;AACjC,SAAS,cAAc;AA6BlB,SAkJC,UAlJD,K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