@wordpress/block-editor 15.22.1-next.v.202606191442.0 → 15.22.1
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 +1 -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 +32 -16
- 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/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 +2 -2
- 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/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 +32 -16
- 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/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 +2 -2
- 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/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 +20 -10
- 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/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 +2 -2
- 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/store/test/private-selectors.js +28 -7
- package/src/store/test/reducer.js +61 -10
- 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/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,37 +1,26 @@
|
|
|
1
1
|
// packages/block-editor/src/components/global-styles/color-panel.js
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
__experimentalToolsPanel as ToolsPanel,
|
|
5
|
-
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
6
|
-
__experimentalHStack as HStack,
|
|
7
|
-
__experimentalZStack as ZStack,
|
|
8
|
-
__experimentalDropdownContentWrapper as DropdownContentWrapper,
|
|
9
|
-
ColorIndicator,
|
|
10
|
-
Flex,
|
|
11
|
-
FlexItem,
|
|
12
|
-
Dropdown,
|
|
13
|
-
Button,
|
|
14
|
-
privateApis as componentsPrivateApis
|
|
15
|
-
} from "@wordpress/components";
|
|
16
|
-
import { useMemo, useRef } from "@wordpress/element";
|
|
2
|
+
import { __experimentalToolsPanel as ToolsPanel } from "@wordpress/components";
|
|
3
|
+
import { useCallback, useMemo } from "@wordpress/element";
|
|
17
4
|
import { __ } from "@wordpress/i18n";
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
import ColorGradientDropdownItem from "./color-gradient-dropdown-item.mjs";
|
|
6
|
+
import {
|
|
7
|
+
useColorsPerOrigin,
|
|
8
|
+
useGradientsPerOrigin,
|
|
9
|
+
useColorGradientSettings
|
|
10
|
+
} from "./hooks.mjs";
|
|
22
11
|
import { useToolsPanelDropdownMenuProps } from "./utils.mjs";
|
|
23
12
|
import { setImmutably } from "../../utils/object.mjs";
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
import {
|
|
14
|
+
extractPresetSlug,
|
|
15
|
+
encodeColorValueWithPalette
|
|
16
|
+
} from "../../utils/color-values.mjs";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
27
18
|
function useHasColorPanel(settings) {
|
|
28
|
-
const hasTextPanel = useHasTextPanel(settings);
|
|
29
|
-
const hasBackgroundPanel = useHasBackgroundColorPanel(settings);
|
|
30
19
|
const hasLinkPanel = useHasLinkPanel(settings);
|
|
31
20
|
const hasHeadingPanel = useHasHeadingPanel(settings);
|
|
32
21
|
const hasButtonPanel = useHasButtonPanel(settings);
|
|
33
22
|
const hasCaptionPanel = useHasCaptionPanel(settings);
|
|
34
|
-
return
|
|
23
|
+
return hasLinkPanel || hasHeadingPanel || hasButtonPanel || hasCaptionPanel;
|
|
35
24
|
}
|
|
36
25
|
function useHasTextPanel(settings) {
|
|
37
26
|
const colors = useColorsPerOrigin(settings);
|
|
@@ -89,165 +78,12 @@ function ColorToolsPanel({
|
|
|
89
78
|
}
|
|
90
79
|
);
|
|
91
80
|
}
|
|
92
|
-
function encodeColorValueWithPalette(allColors, colorValue, slug) {
|
|
93
|
-
if (slug) {
|
|
94
|
-
return "var:preset|color|" + slug;
|
|
95
|
-
}
|
|
96
|
-
const colorObject = allColors.find(({ color }) => color === colorValue);
|
|
97
|
-
return colorObject ? "var:preset|color|" + colorObject.slug : colorValue;
|
|
98
|
-
}
|
|
99
81
|
var DEFAULT_CONTROLS = {
|
|
100
|
-
text: true,
|
|
101
|
-
background: true,
|
|
102
82
|
link: true,
|
|
103
83
|
heading: true,
|
|
104
84
|
button: true,
|
|
105
85
|
caption: true
|
|
106
86
|
};
|
|
107
|
-
var popoverProps = {
|
|
108
|
-
placement: "left-start",
|
|
109
|
-
offset: 36,
|
|
110
|
-
shift: true
|
|
111
|
-
};
|
|
112
|
-
var { Tabs } = unlock(componentsPrivateApis);
|
|
113
|
-
var LabeledColorIndicators = ({ indicators, label }) => /* @__PURE__ */ jsxs(HStack, { justify: "flex-start", children: [
|
|
114
|
-
/* @__PURE__ */ jsx(ZStack, { isLayered: false, offset: -8, children: indicators.map((indicator, index) => /* @__PURE__ */ jsx(Flex, { expanded: false, children: /* @__PURE__ */ jsx(ColorIndicator, { colorValue: indicator }) }, index)) }),
|
|
115
|
-
/* @__PURE__ */ jsx(FlexItem, { className: "block-editor-panel-color-gradient-settings__color-name", children: label })
|
|
116
|
-
] });
|
|
117
|
-
function ColorPanelTab({
|
|
118
|
-
isGradient,
|
|
119
|
-
inheritedValue,
|
|
120
|
-
inheritedSlug,
|
|
121
|
-
userValue,
|
|
122
|
-
setValue,
|
|
123
|
-
colorGradientControlSettings
|
|
124
|
-
}) {
|
|
125
|
-
return /* @__PURE__ */ jsx(
|
|
126
|
-
ColorGradientControl,
|
|
127
|
-
{
|
|
128
|
-
...colorGradientControlSettings,
|
|
129
|
-
showTitle: false,
|
|
130
|
-
enableAlpha: true,
|
|
131
|
-
__experimentalIsRenderedInSidebar: true,
|
|
132
|
-
colorValue: isGradient ? void 0 : inheritedValue,
|
|
133
|
-
colorSlug: isGradient ? void 0 : inheritedSlug,
|
|
134
|
-
gradientValue: isGradient ? inheritedValue : void 0,
|
|
135
|
-
onColorChange: isGradient ? void 0 : setValue,
|
|
136
|
-
onGradientChange: isGradient ? setValue : void 0,
|
|
137
|
-
clearable: inheritedValue === userValue,
|
|
138
|
-
headingLevel: 3
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
function ColorPanelDropdown({
|
|
143
|
-
label,
|
|
144
|
-
hasValue,
|
|
145
|
-
resetValue,
|
|
146
|
-
isShownByDefault,
|
|
147
|
-
indicators,
|
|
148
|
-
tabs,
|
|
149
|
-
colorGradientControlSettings,
|
|
150
|
-
panelId,
|
|
151
|
-
className = "block-editor-tools-panel-color-gradient-settings__item"
|
|
152
|
-
}) {
|
|
153
|
-
const currentTab = tabs.find((tab) => tab.userValue !== void 0);
|
|
154
|
-
const { key: firstTabKey, ...firstTab } = tabs[0] ?? {};
|
|
155
|
-
const colorGradientDropdownButtonRef = useRef(void 0);
|
|
156
|
-
return /* @__PURE__ */ jsx(
|
|
157
|
-
ToolsPanelItem,
|
|
158
|
-
{
|
|
159
|
-
className,
|
|
160
|
-
hasValue,
|
|
161
|
-
label,
|
|
162
|
-
onDeselect: resetValue,
|
|
163
|
-
isShownByDefault,
|
|
164
|
-
panelId,
|
|
165
|
-
children: /* @__PURE__ */ jsx(
|
|
166
|
-
Dropdown,
|
|
167
|
-
{
|
|
168
|
-
popoverProps,
|
|
169
|
-
className: "block-editor-tools-panel-color-gradient-settings__dropdown",
|
|
170
|
-
renderToggle: ({ onToggle, isOpen }) => {
|
|
171
|
-
const toggleProps = {
|
|
172
|
-
onClick: onToggle,
|
|
173
|
-
className: clsx(
|
|
174
|
-
"block-editor-panel-color-gradient-settings__dropdown",
|
|
175
|
-
{ "is-open": isOpen }
|
|
176
|
-
),
|
|
177
|
-
"aria-expanded": isOpen,
|
|
178
|
-
ref: colorGradientDropdownButtonRef
|
|
179
|
-
};
|
|
180
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
181
|
-
/* @__PURE__ */ jsx(Button, { ...toggleProps, __next40pxDefaultSize: true, children: /* @__PURE__ */ jsx(
|
|
182
|
-
LabeledColorIndicators,
|
|
183
|
-
{
|
|
184
|
-
indicators,
|
|
185
|
-
label
|
|
186
|
-
}
|
|
187
|
-
) }),
|
|
188
|
-
hasValue() && /* @__PURE__ */ jsx(
|
|
189
|
-
Button,
|
|
190
|
-
{
|
|
191
|
-
__next40pxDefaultSize: true,
|
|
192
|
-
label: __("Reset"),
|
|
193
|
-
className: "block-editor-panel-color-gradient-settings__reset",
|
|
194
|
-
size: "small",
|
|
195
|
-
icon: resetIcon,
|
|
196
|
-
onClick: () => {
|
|
197
|
-
resetValue();
|
|
198
|
-
if (isOpen) {
|
|
199
|
-
onToggle();
|
|
200
|
-
}
|
|
201
|
-
colorGradientDropdownButtonRef.current?.focus();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
)
|
|
205
|
-
] });
|
|
206
|
-
},
|
|
207
|
-
renderContent: () => /* @__PURE__ */ jsx(DropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ jsxs("div", { className: "block-editor-panel-color-gradient-settings__dropdown-content", children: [
|
|
208
|
-
tabs.length === 1 && /* @__PURE__ */ jsx(
|
|
209
|
-
ColorPanelTab,
|
|
210
|
-
{
|
|
211
|
-
...firstTab,
|
|
212
|
-
colorGradientControlSettings
|
|
213
|
-
},
|
|
214
|
-
firstTabKey
|
|
215
|
-
),
|
|
216
|
-
tabs.length > 1 && /* @__PURE__ */ jsxs(Tabs, { defaultTabId: currentTab?.key, children: [
|
|
217
|
-
/* @__PURE__ */ jsx(Tabs.TabList, { children: tabs.map((tab) => /* @__PURE__ */ jsx(
|
|
218
|
-
Tabs.Tab,
|
|
219
|
-
{
|
|
220
|
-
tabId: tab.key,
|
|
221
|
-
children: tab.label
|
|
222
|
-
},
|
|
223
|
-
tab.key
|
|
224
|
-
)) }),
|
|
225
|
-
tabs.map((tab) => {
|
|
226
|
-
const { key: tabKey, ...restTabProps } = tab;
|
|
227
|
-
return /* @__PURE__ */ jsx(
|
|
228
|
-
Tabs.TabPanel,
|
|
229
|
-
{
|
|
230
|
-
tabId: tabKey,
|
|
231
|
-
focusable: false,
|
|
232
|
-
children: /* @__PURE__ */ jsx(
|
|
233
|
-
ColorPanelTab,
|
|
234
|
-
{
|
|
235
|
-
...restTabProps,
|
|
236
|
-
colorGradientControlSettings
|
|
237
|
-
},
|
|
238
|
-
tabKey
|
|
239
|
-
)
|
|
240
|
-
},
|
|
241
|
-
tabKey
|
|
242
|
-
);
|
|
243
|
-
})
|
|
244
|
-
] })
|
|
245
|
-
] }) })
|
|
246
|
-
}
|
|
247
|
-
)
|
|
248
|
-
}
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
87
|
function ColorPanel({
|
|
252
88
|
as: Wrapper = ColorToolsPanel,
|
|
253
89
|
value,
|
|
@@ -257,67 +93,20 @@ function ColorPanel({
|
|
|
257
93
|
panelId,
|
|
258
94
|
defaultControls = DEFAULT_CONTROLS,
|
|
259
95
|
label,
|
|
260
|
-
children
|
|
96
|
+
children,
|
|
97
|
+
contrastWarning
|
|
261
98
|
}) {
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
[colors]
|
|
274
|
-
);
|
|
275
|
-
const encodeGradientValue = (gradientValue) => {
|
|
276
|
-
const allGradients = gradients.flatMap(
|
|
277
|
-
({ gradients: originGradients }) => originGradients
|
|
278
|
-
);
|
|
279
|
-
const gradientObject = allGradients.find(
|
|
280
|
-
({ gradient: gradient2 }) => gradient2 === gradientValue
|
|
281
|
-
);
|
|
282
|
-
return gradientObject ? "var:preset|gradient|" + gradientObject.slug : gradientValue;
|
|
283
|
-
};
|
|
284
|
-
const showBackgroundPanel = useHasBackgroundColorPanel(settings);
|
|
285
|
-
const backgroundColor = decodeValue(inheritedValue?.color?.background);
|
|
286
|
-
const userBackgroundColor = decodeValue(value?.color?.background);
|
|
287
|
-
const gradient = decodeValue(inheritedValue?.color?.gradient);
|
|
288
|
-
const userGradient = decodeValue(value?.color?.gradient);
|
|
289
|
-
const hasBackground = () => !!userBackgroundColor || !hasBackgroundGradientSupport && !!userGradient;
|
|
290
|
-
const setBackgroundColor = (newColor, newSlug) => {
|
|
291
|
-
const newValue = setImmutably(
|
|
292
|
-
value,
|
|
293
|
-
["color", "background"],
|
|
294
|
-
encodeColorValueWithPalette(allColors, newColor, newSlug)
|
|
295
|
-
);
|
|
296
|
-
if (!hasBackgroundGradientSupport) {
|
|
297
|
-
newValue.color.gradient = void 0;
|
|
298
|
-
}
|
|
299
|
-
onChange(newValue);
|
|
300
|
-
};
|
|
301
|
-
const setGradient = (newGradient) => {
|
|
302
|
-
const newValue = setImmutably(
|
|
303
|
-
value,
|
|
304
|
-
["color", "gradient"],
|
|
305
|
-
encodeGradientValue(newGradient)
|
|
306
|
-
);
|
|
307
|
-
newValue.color.background = void 0;
|
|
308
|
-
onChange(newValue);
|
|
309
|
-
};
|
|
310
|
-
const resetBackground = () => {
|
|
311
|
-
const newValue = setImmutably(
|
|
312
|
-
value,
|
|
313
|
-
["color", "background"],
|
|
314
|
-
void 0
|
|
315
|
-
);
|
|
316
|
-
if (!hasBackgroundGradientSupport) {
|
|
317
|
-
newValue.color.gradient = void 0;
|
|
318
|
-
}
|
|
319
|
-
onChange(newValue);
|
|
320
|
-
};
|
|
99
|
+
const {
|
|
100
|
+
colors,
|
|
101
|
+
gradients,
|
|
102
|
+
areCustomSolidsEnabled,
|
|
103
|
+
areCustomGradientsEnabled,
|
|
104
|
+
hasSolidColors,
|
|
105
|
+
hasGradientColors,
|
|
106
|
+
allColors,
|
|
107
|
+
decodeValue,
|
|
108
|
+
encodeGradientValue
|
|
109
|
+
} = useColorGradientSettings(settings);
|
|
321
110
|
const showLinkPanel = useHasLinkPanel(settings);
|
|
322
111
|
const linkColor = decodeValue(
|
|
323
112
|
inheritedValue?.elements?.link?.color?.text
|
|
@@ -361,154 +150,87 @@ function ColorPanel({
|
|
|
361
150
|
);
|
|
362
151
|
onChange(newValue);
|
|
363
152
|
};
|
|
364
|
-
const showTextPanel = useHasTextPanel(settings);
|
|
365
153
|
const showCaptionPanel = useHasCaptionPanel(settings);
|
|
366
154
|
const showButtonPanel = useHasButtonPanel(settings);
|
|
367
155
|
const showHeadingPanel = useHasHeadingPanel(settings);
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
{
|
|
429
|
-
name: "h6",
|
|
430
|
-
label: __("H6"),
|
|
431
|
-
showPanel: showHeadingPanel
|
|
432
|
-
}
|
|
433
|
-
];
|
|
434
|
-
const resetAllFilter = (previousValue) => {
|
|
435
|
-
return {
|
|
436
|
-
...previousValue,
|
|
437
|
-
color: void 0,
|
|
438
|
-
elements: {
|
|
439
|
-
...previousValue?.elements,
|
|
440
|
-
link: {
|
|
441
|
-
...previousValue?.elements?.link,
|
|
442
|
-
color: void 0,
|
|
443
|
-
":hover": {
|
|
444
|
-
color: void 0
|
|
445
|
-
}
|
|
446
|
-
},
|
|
447
|
-
...elements.reduce((acc, element) => {
|
|
448
|
-
return {
|
|
449
|
-
...acc,
|
|
450
|
-
[element.name]: {
|
|
451
|
-
...previousValue?.elements?.[element.name],
|
|
156
|
+
const elements = useMemo(
|
|
157
|
+
() => [
|
|
158
|
+
{
|
|
159
|
+
name: "caption",
|
|
160
|
+
label: __("Captions"),
|
|
161
|
+
showPanel: showCaptionPanel
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "button",
|
|
165
|
+
label: __("Button"),
|
|
166
|
+
showPanel: showButtonPanel
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "heading",
|
|
170
|
+
label: __("Heading"),
|
|
171
|
+
showPanel: showHeadingPanel
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: "h1",
|
|
175
|
+
label: __("H1"),
|
|
176
|
+
showPanel: showHeadingPanel
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "h2",
|
|
180
|
+
label: __("H2"),
|
|
181
|
+
showPanel: showHeadingPanel
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: "h3",
|
|
185
|
+
label: __("H3"),
|
|
186
|
+
showPanel: showHeadingPanel
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "h4",
|
|
190
|
+
label: __("H4"),
|
|
191
|
+
showPanel: showHeadingPanel
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: "h5",
|
|
195
|
+
label: __("H5"),
|
|
196
|
+
showPanel: showHeadingPanel
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "h6",
|
|
200
|
+
label: __("H6"),
|
|
201
|
+
showPanel: showHeadingPanel
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
[showCaptionPanel, showButtonPanel, showHeadingPanel]
|
|
205
|
+
);
|
|
206
|
+
const resetAllFilter = useCallback(
|
|
207
|
+
(previousValue) => {
|
|
208
|
+
return {
|
|
209
|
+
...previousValue,
|
|
210
|
+
elements: {
|
|
211
|
+
...previousValue?.elements,
|
|
212
|
+
link: {
|
|
213
|
+
...previousValue?.elements?.link,
|
|
214
|
+
color: void 0,
|
|
215
|
+
":hover": {
|
|
452
216
|
color: void 0
|
|
453
217
|
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
resetValue: resetTextColor,
|
|
465
|
-
isShownByDefault: defaultControls.text,
|
|
466
|
-
indicators: [textColor],
|
|
467
|
-
tabs: [
|
|
468
|
-
{
|
|
469
|
-
key: "text",
|
|
470
|
-
label: __("Text"),
|
|
471
|
-
inheritedValue: textColor,
|
|
472
|
-
inheritedSlug: extractPresetSlug(
|
|
473
|
-
inheritedValue?.color?.text,
|
|
474
|
-
"color"
|
|
475
|
-
),
|
|
476
|
-
setValue: setTextColor,
|
|
477
|
-
userValue: userTextColor
|
|
478
|
-
}
|
|
479
|
-
]
|
|
480
|
-
},
|
|
481
|
-
showBackgroundPanel && {
|
|
482
|
-
key: "background",
|
|
483
|
-
label: __("Background"),
|
|
484
|
-
hasValue: hasBackground,
|
|
485
|
-
resetValue: resetBackground,
|
|
486
|
-
isShownByDefault: defaultControls.background,
|
|
487
|
-
indicators: [
|
|
488
|
-
(showGradientColors ? gradient : void 0) ?? backgroundColor
|
|
489
|
-
],
|
|
490
|
-
tabs: [
|
|
491
|
-
hasSolidColors && {
|
|
492
|
-
key: "background",
|
|
493
|
-
label: __("Color"),
|
|
494
|
-
inheritedValue: backgroundColor,
|
|
495
|
-
inheritedSlug: extractPresetSlug(
|
|
496
|
-
inheritedValue?.color?.background,
|
|
497
|
-
"color"
|
|
498
|
-
),
|
|
499
|
-
setValue: setBackgroundColor,
|
|
500
|
-
userValue: userBackgroundColor
|
|
501
|
-
},
|
|
502
|
-
showGradientColors && {
|
|
503
|
-
key: "gradient",
|
|
504
|
-
label: __("Gradient"),
|
|
505
|
-
inheritedValue: gradient,
|
|
506
|
-
setValue: setGradient,
|
|
507
|
-
userValue: userGradient,
|
|
508
|
-
isGradient: true
|
|
218
|
+
},
|
|
219
|
+
...elements.reduce((acc, element) => {
|
|
220
|
+
return {
|
|
221
|
+
...acc,
|
|
222
|
+
[element.name]: {
|
|
223
|
+
...previousValue?.elements?.[element.name],
|
|
224
|
+
color: void 0
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}, {})
|
|
509
228
|
}
|
|
510
|
-
|
|
229
|
+
};
|
|
511
230
|
},
|
|
231
|
+
[elements]
|
|
232
|
+
);
|
|
233
|
+
const items = [
|
|
512
234
|
showLinkPanel && {
|
|
513
235
|
key: "link",
|
|
514
236
|
label: __("Link"),
|
|
@@ -516,6 +238,7 @@ function ColorPanel({
|
|
|
516
238
|
resetValue: resetLink,
|
|
517
239
|
isShownByDefault: defaultControls.link,
|
|
518
240
|
indicators: [linkColor, hoverLinkColor],
|
|
241
|
+
contrastWarning,
|
|
519
242
|
tabs: [
|
|
520
243
|
{
|
|
521
244
|
key: "link",
|
|
@@ -610,7 +333,6 @@ function ColorPanel({
|
|
|
610
333
|
newValue.elements[name].color.background = void 0;
|
|
611
334
|
onChange(newValue);
|
|
612
335
|
};
|
|
613
|
-
const supportsTextColor = true;
|
|
614
336
|
const supportsBackground = name !== "caption";
|
|
615
337
|
items.push({
|
|
616
338
|
key: name,
|
|
@@ -618,14 +340,12 @@ function ColorPanel({
|
|
|
618
340
|
hasValue: hasElement,
|
|
619
341
|
resetValue: resetElement,
|
|
620
342
|
isShownByDefault: defaultControls[name],
|
|
621
|
-
indicators:
|
|
343
|
+
indicators: supportsBackground ? [
|
|
622
344
|
elementTextColor,
|
|
623
345
|
elementGradient ?? elementBackgroundColor
|
|
624
|
-
] : [
|
|
625
|
-
supportsTextColor ? elementTextColor : elementGradient ?? elementBackgroundColor
|
|
626
|
-
],
|
|
346
|
+
] : [elementTextColor],
|
|
627
347
|
tabs: [
|
|
628
|
-
hasSolidColors &&
|
|
348
|
+
hasSolidColors && {
|
|
629
349
|
key: "text",
|
|
630
350
|
label: __("Text"),
|
|
631
351
|
inheritedValue: elementTextColor,
|
|
@@ -670,7 +390,7 @@ function ColorPanel({
|
|
|
670
390
|
items.map((item) => {
|
|
671
391
|
const { key, ...restItem } = item;
|
|
672
392
|
return /* @__PURE__ */ jsx(
|
|
673
|
-
|
|
393
|
+
ColorGradientDropdownItem,
|
|
674
394
|
{
|
|
675
395
|
...restItem,
|
|
676
396
|
colorGradientControlSettings: {
|
|
@@ -690,7 +410,6 @@ function ColorPanel({
|
|
|
690
410
|
);
|
|
691
411
|
}
|
|
692
412
|
export {
|
|
693
|
-
ColorPanelDropdown,
|
|
694
413
|
ColorToolsPanel,
|
|
695
414
|
ColorPanel as default,
|
|
696
415
|
useHasBackgroundColorPanel,
|