@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
|
@@ -30,10 +30,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// packages/block-editor/src/components/global-styles/background-panel.js
|
|
31
31
|
var background_panel_exports = {};
|
|
32
32
|
__export(background_panel_exports, {
|
|
33
|
+
BackgroundToolsPanel: () => BackgroundToolsPanel,
|
|
33
34
|
default: () => BackgroundImagePanel,
|
|
35
|
+
hasBackgroundColorValue: () => hasBackgroundColorValue,
|
|
34
36
|
hasBackgroundGradientValue: () => hasBackgroundGradientValue,
|
|
35
37
|
hasBackgroundImageValue: () => hasBackgroundImageValue,
|
|
36
38
|
hasBackgroundSizeValue: () => hasBackgroundSizeValue,
|
|
39
|
+
hasLegacyColorGradientValue: () => hasLegacyColorGradientValue,
|
|
37
40
|
useHasBackgroundControl: () => useHasBackgroundControl,
|
|
38
41
|
useHasBackgroundPanel: () => useHasBackgroundPanel
|
|
39
42
|
});
|
|
@@ -41,23 +44,26 @@ module.exports = __toCommonJS(background_panel_exports);
|
|
|
41
44
|
var import_components = require("@wordpress/components");
|
|
42
45
|
var import_element = require("@wordpress/element");
|
|
43
46
|
var import_i18n = require("@wordpress/i18n");
|
|
44
|
-
var import_global_styles_engine = require("@wordpress/global-styles-engine");
|
|
45
47
|
var import_background_image_control = __toESM(require("../background-image-control/index.cjs"));
|
|
48
|
+
var import_color_gradient_dropdown_item = __toESM(require("./color-gradient-dropdown-item.cjs"));
|
|
46
49
|
var import_color_panel = require("./color-panel.cjs");
|
|
47
50
|
var import_hooks = require("./hooks.cjs");
|
|
48
51
|
var import_utils = require("./utils.cjs");
|
|
49
52
|
var import_object = require("../../utils/object.cjs");
|
|
53
|
+
var import_color_values = require("../../utils/color-values.cjs");
|
|
50
54
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
51
55
|
var DEFAULT_CONTROLS = {
|
|
52
56
|
backgroundImage: true,
|
|
57
|
+
backgroundColor: true,
|
|
53
58
|
gradient: true
|
|
54
59
|
};
|
|
55
60
|
function useHasBackgroundControl(settings, feature) {
|
|
56
61
|
return settings?.background?.[feature];
|
|
57
62
|
}
|
|
58
63
|
function useHasBackgroundPanel(settings) {
|
|
64
|
+
const hasBackgroundColor = (0, import_color_panel.useHasBackgroundColorPanel)(settings);
|
|
59
65
|
const { backgroundImage, gradient } = settings?.background || {};
|
|
60
|
-
return backgroundImage || gradient;
|
|
66
|
+
return backgroundImage || gradient || hasBackgroundColor;
|
|
61
67
|
}
|
|
62
68
|
function hasBackgroundSizeValue(style) {
|
|
63
69
|
return style?.background?.backgroundPosition !== void 0 || style?.background?.backgroundSize !== void 0;
|
|
@@ -69,6 +75,12 @@ function hasBackgroundImageValue(style) {
|
|
|
69
75
|
function hasBackgroundGradientValue(style) {
|
|
70
76
|
return "string" === typeof style?.background?.gradient && style?.background?.gradient !== "";
|
|
71
77
|
}
|
|
78
|
+
function hasBackgroundColorValue(style) {
|
|
79
|
+
return !!style?.color?.background;
|
|
80
|
+
}
|
|
81
|
+
function hasLegacyColorGradientValue(style) {
|
|
82
|
+
return !!style?.color?.gradient;
|
|
83
|
+
}
|
|
72
84
|
function BackgroundToolsPanel({
|
|
73
85
|
resetAllFilter,
|
|
74
86
|
onChange,
|
|
@@ -101,51 +113,63 @@ function BackgroundImagePanel({
|
|
|
101
113
|
as: Wrapper = BackgroundToolsPanel,
|
|
102
114
|
value,
|
|
103
115
|
onChange,
|
|
104
|
-
inheritedValue,
|
|
116
|
+
inheritedValue = value,
|
|
105
117
|
settings,
|
|
106
118
|
panelId,
|
|
107
119
|
defaultControls = DEFAULT_CONTROLS,
|
|
108
120
|
defaultValues = {},
|
|
109
|
-
headerLabel = (0, import_i18n.__)("Background")
|
|
121
|
+
headerLabel = (0, import_i18n.__)("Background"),
|
|
122
|
+
contrastWarning
|
|
110
123
|
}) {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
124
|
+
const {
|
|
125
|
+
colors,
|
|
126
|
+
gradients,
|
|
127
|
+
allColors,
|
|
128
|
+
areCustomSolidsEnabled,
|
|
129
|
+
areCustomGradientsEnabled,
|
|
130
|
+
hasSolidColors,
|
|
131
|
+
hasGradientColors,
|
|
132
|
+
decodeValue,
|
|
133
|
+
encodeGradientValue
|
|
134
|
+
} = (0, import_hooks.useColorGradientSettings)(settings);
|
|
114
135
|
const hasBackgroundGradientControl = useHasBackgroundControl(
|
|
115
136
|
settings,
|
|
116
137
|
"gradient"
|
|
117
138
|
);
|
|
139
|
+
const hasColorPanelBackgroundSupport = (0, import_color_panel.useHasBackgroundColorPanel)(settings);
|
|
140
|
+
const showBackgroundColorControl = hasColorPanelBackgroundSupport && hasSolidColors;
|
|
118
141
|
const showBackgroundGradientControl = hasGradientColors && hasBackgroundGradientControl;
|
|
142
|
+
const showLegacyColorGradientControl = hasColorPanelBackgroundSupport && hasGradientColors && !hasBackgroundGradientControl;
|
|
119
143
|
const showBackgroundImageControl = useHasBackgroundControl(
|
|
120
144
|
settings,
|
|
121
145
|
"backgroundImage"
|
|
122
146
|
);
|
|
123
147
|
const resetAllFilter = (0, import_element.useCallback)(
|
|
124
148
|
(previousValue) => {
|
|
149
|
+
const clearsColorBackground = showBackgroundColorControl;
|
|
150
|
+
const clearsColorGradient = hasBackgroundGradientControl || showLegacyColorGradientControl;
|
|
151
|
+
if (!clearsColorBackground && !clearsColorGradient) {
|
|
152
|
+
return { ...previousValue, background: {} };
|
|
153
|
+
}
|
|
125
154
|
return {
|
|
126
155
|
...previousValue,
|
|
127
156
|
background: {},
|
|
128
|
-
color:
|
|
157
|
+
color: {
|
|
129
158
|
...previousValue?.color,
|
|
130
|
-
|
|
131
|
-
|
|
159
|
+
...clearsColorBackground && { background: void 0 },
|
|
160
|
+
...clearsColorGradient && { gradient: void 0 }
|
|
161
|
+
}
|
|
132
162
|
};
|
|
133
163
|
},
|
|
134
|
-
[
|
|
164
|
+
[
|
|
165
|
+
hasBackgroundGradientControl,
|
|
166
|
+
showBackgroundColorControl,
|
|
167
|
+
showLegacyColorGradientControl
|
|
168
|
+
]
|
|
135
169
|
);
|
|
136
|
-
if (!showBackgroundGradientControl && !
|
|
170
|
+
if (!showBackgroundImageControl && !showBackgroundColorControl && !showBackgroundGradientControl && !showLegacyColorGradientControl) {
|
|
137
171
|
return null;
|
|
138
172
|
}
|
|
139
|
-
const decodeValue = (rawValue) => (0, import_global_styles_engine.getValueFromVariable)({ settings }, "", rawValue);
|
|
140
|
-
const encodeGradientValue = (gradientValue) => {
|
|
141
|
-
const allGradients = gradients.flatMap(
|
|
142
|
-
({ gradients: originGradients }) => originGradients
|
|
143
|
-
);
|
|
144
|
-
const gradientObject = allGradients.find(
|
|
145
|
-
({ gradient }) => gradient === gradientValue
|
|
146
|
-
);
|
|
147
|
-
return gradientObject ? "var:preset|gradient|" + gradientObject.slug : gradientValue;
|
|
148
|
-
};
|
|
149
173
|
const resetBackground = () => onChange(
|
|
150
174
|
(0, import_object.setImmutably)(
|
|
151
175
|
value,
|
|
@@ -162,6 +186,42 @@ function BackgroundImagePanel({
|
|
|
162
186
|
newValue = (0, import_object.setImmutably)(newValue, ["color", "gradient"], void 0);
|
|
163
187
|
onChange(newValue);
|
|
164
188
|
};
|
|
189
|
+
const backgroundColor = decodeValue(inheritedValue?.color?.background);
|
|
190
|
+
const userBackgroundColor = decodeValue(value?.color?.background);
|
|
191
|
+
const setBackgroundColor = (newColor, newSlug) => {
|
|
192
|
+
const newValue = (0, import_object.setImmutably)(
|
|
193
|
+
value,
|
|
194
|
+
["color", "background"],
|
|
195
|
+
(0, import_color_values.encodeColorValueWithPalette)(allColors, newColor, newSlug)
|
|
196
|
+
);
|
|
197
|
+
if (showLegacyColorGradientControl) {
|
|
198
|
+
newValue.color.gradient = void 0;
|
|
199
|
+
}
|
|
200
|
+
onChange(newValue);
|
|
201
|
+
};
|
|
202
|
+
const resetBackgroundColor = () => {
|
|
203
|
+
const newValue = (0, import_object.setImmutably)(
|
|
204
|
+
value,
|
|
205
|
+
["color", "background"],
|
|
206
|
+
void 0
|
|
207
|
+
);
|
|
208
|
+
if (showLegacyColorGradientControl) {
|
|
209
|
+
newValue.color.gradient = void 0;
|
|
210
|
+
}
|
|
211
|
+
onChange(newValue);
|
|
212
|
+
};
|
|
213
|
+
const legacyColorGradient = decodeValue(inheritedValue?.color?.gradient);
|
|
214
|
+
const userLegacyColorGradient = decodeValue(value?.color?.gradient);
|
|
215
|
+
const setLegacyColorGradient = (newGradient) => {
|
|
216
|
+
const newValue = (0, import_object.setImmutably)(
|
|
217
|
+
value,
|
|
218
|
+
["color", "gradient"],
|
|
219
|
+
encodeGradientValue(newGradient)
|
|
220
|
+
);
|
|
221
|
+
newValue.color.background = void 0;
|
|
222
|
+
onChange(newValue);
|
|
223
|
+
};
|
|
224
|
+
const resetLegacyColorGradient = () => onChange((0, import_object.setImmutably)(value, ["color", "gradient"], void 0));
|
|
165
225
|
const currentGradient = decodeValue(
|
|
166
226
|
value?.background?.gradient ?? value?.color?.gradient
|
|
167
227
|
);
|
|
@@ -189,7 +249,7 @@ function BackgroundImagePanel({
|
|
|
189
249
|
showBackgroundImageControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
190
250
|
import_components.__experimentalToolsPanelItem,
|
|
191
251
|
{
|
|
192
|
-
className: "block-editor-
|
|
252
|
+
className: "block-editor-color-gradient-item",
|
|
193
253
|
hasValue: () => hasBackgroundImageValue(value),
|
|
194
254
|
label: (0, import_i18n.__)("Image"),
|
|
195
255
|
onDeselect: resetBackground,
|
|
@@ -208,10 +268,48 @@ function BackgroundImagePanel({
|
|
|
208
268
|
)
|
|
209
269
|
}
|
|
210
270
|
),
|
|
271
|
+
showBackgroundColorControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
272
|
+
import_color_gradient_dropdown_item.default,
|
|
273
|
+
{
|
|
274
|
+
label: (0, import_i18n.__)("Color"),
|
|
275
|
+
hasValue: () => hasBackgroundColorValue(value),
|
|
276
|
+
resetValue: resetBackgroundColor,
|
|
277
|
+
isShownByDefault: defaultControls.backgroundColor,
|
|
278
|
+
indicators: [userBackgroundColor ?? backgroundColor],
|
|
279
|
+
contrastWarning,
|
|
280
|
+
tabs: [
|
|
281
|
+
{
|
|
282
|
+
key: "background",
|
|
283
|
+
label: (0, import_i18n.__)("Color"),
|
|
284
|
+
inheritedValue: userBackgroundColor ?? backgroundColor,
|
|
285
|
+
// Resolve the slug from the same source as the
|
|
286
|
+
// displayed value (user value first, then the
|
|
287
|
+
// inherited fallback). For a block instance the
|
|
288
|
+
// selection lives in `value` while `inheritedValue`
|
|
289
|
+
// only holds the global styles fallback, so reading
|
|
290
|
+
// the slug from `inheritedValue` alone would miss it
|
|
291
|
+
// and two same-hex presets would both appear selected.
|
|
292
|
+
inheritedSlug: (0, import_color_values.extractPresetSlug)(
|
|
293
|
+
value?.color?.background,
|
|
294
|
+
"color"
|
|
295
|
+
) ?? (0, import_color_values.extractPresetSlug)(
|
|
296
|
+
inheritedValue?.color?.background,
|
|
297
|
+
"color"
|
|
298
|
+
),
|
|
299
|
+
setValue: setBackgroundColor,
|
|
300
|
+
userValue: userBackgroundColor
|
|
301
|
+
}
|
|
302
|
+
],
|
|
303
|
+
colorGradientControlSettings: {
|
|
304
|
+
colors,
|
|
305
|
+
disableCustomColors: !areCustomSolidsEnabled
|
|
306
|
+
},
|
|
307
|
+
panelId
|
|
308
|
+
}
|
|
309
|
+
),
|
|
211
310
|
showBackgroundGradientControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
212
|
-
|
|
311
|
+
import_color_gradient_dropdown_item.default,
|
|
213
312
|
{
|
|
214
|
-
className: "block-editor-background-panel__item",
|
|
215
313
|
label: (0, import_i18n.__)("Gradient"),
|
|
216
314
|
hasValue: () => hasBackgroundGradientValue(value),
|
|
217
315
|
resetValue: resetGradient,
|
|
@@ -233,6 +331,33 @@ function BackgroundImagePanel({
|
|
|
233
331
|
},
|
|
234
332
|
panelId
|
|
235
333
|
}
|
|
334
|
+
),
|
|
335
|
+
showLegacyColorGradientControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
336
|
+
import_color_gradient_dropdown_item.default,
|
|
337
|
+
{
|
|
338
|
+
label: (0, import_i18n.__)("Gradient"),
|
|
339
|
+
hasValue: () => hasLegacyColorGradientValue(value),
|
|
340
|
+
resetValue: resetLegacyColorGradient,
|
|
341
|
+
isShownByDefault: defaultControls.gradient,
|
|
342
|
+
indicators: [
|
|
343
|
+
userLegacyColorGradient ?? legacyColorGradient
|
|
344
|
+
],
|
|
345
|
+
tabs: [
|
|
346
|
+
{
|
|
347
|
+
key: "gradient",
|
|
348
|
+
label: (0, import_i18n.__)("Gradient"),
|
|
349
|
+
inheritedValue: userLegacyColorGradient ?? legacyColorGradient,
|
|
350
|
+
setValue: setLegacyColorGradient,
|
|
351
|
+
userValue: userLegacyColorGradient,
|
|
352
|
+
isGradient: true
|
|
353
|
+
}
|
|
354
|
+
],
|
|
355
|
+
colorGradientControlSettings: {
|
|
356
|
+
gradients,
|
|
357
|
+
disableCustomGradients: !areCustomGradientsEnabled
|
|
358
|
+
},
|
|
359
|
+
panelId
|
|
360
|
+
}
|
|
236
361
|
)
|
|
237
362
|
]
|
|
238
363
|
}
|
|
@@ -240,9 +365,12 @@ function BackgroundImagePanel({
|
|
|
240
365
|
}
|
|
241
366
|
// Annotate the CommonJS export names for ESM import in node:
|
|
242
367
|
0 && (module.exports = {
|
|
368
|
+
BackgroundToolsPanel,
|
|
369
|
+
hasBackgroundColorValue,
|
|
243
370
|
hasBackgroundGradientValue,
|
|
244
371
|
hasBackgroundImageValue,
|
|
245
372
|
hasBackgroundSizeValue,
|
|
373
|
+
hasLegacyColorGradientValue,
|
|
246
374
|
useHasBackgroundControl,
|
|
247
375
|
useHasBackgroundPanel
|
|
248
376
|
});
|
|
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAGO;AACP,qBAA4B;AAC5B,kBAAmB;
|
|
6
|
-
"names": ["ToolsPanel", "ToolsPanelItem", "BackgroundImageControl"]
|
|
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\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;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,cAC9B;AAAA,cACA,wBAAwB,CAAE;AAAA,YAC3B;AAAA,YACA;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF;AAEF;",
|
|
6
|
+
"names": ["ToolsPanel", "ToolsPanelItem", "BackgroundImageControl", "ColorGradientDropdownItem"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/block-editor/src/components/global-styles/color-gradient-dropdown-item.js
|
|
31
|
+
var color_gradient_dropdown_item_exports = {};
|
|
32
|
+
__export(color_gradient_dropdown_item_exports, {
|
|
33
|
+
default: () => ColorGradientDropdownItem
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(color_gradient_dropdown_item_exports);
|
|
36
|
+
var import_clsx = __toESM(require("clsx"));
|
|
37
|
+
var import_components = require("@wordpress/components");
|
|
38
|
+
var import_element = require("@wordpress/element");
|
|
39
|
+
var import_i18n = require("@wordpress/i18n");
|
|
40
|
+
var import_icons = require("@wordpress/icons");
|
|
41
|
+
var import_control = __toESM(require("../colors-gradients/control.cjs"));
|
|
42
|
+
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
43
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
+
var { Tabs } = (0, import_lock_unlock.unlock)(import_components.privateApis);
|
|
45
|
+
function DropdownContent({
|
|
46
|
+
tabs,
|
|
47
|
+
colorGradientControlSettings,
|
|
48
|
+
contrastWarning
|
|
49
|
+
}) {
|
|
50
|
+
const { key: firstTabKey, ...firstTab } = tabs[0] ?? {};
|
|
51
|
+
const defaultTabId = tabs.find(
|
|
52
|
+
(tab) => tab.userValue !== void 0
|
|
53
|
+
)?.key;
|
|
54
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "block-editor-panel-color-gradient-settings__dropdown-content", children: [
|
|
55
|
+
tabs.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
56
|
+
ColorGradientTab,
|
|
57
|
+
{
|
|
58
|
+
...firstTab,
|
|
59
|
+
colorGradientControlSettings,
|
|
60
|
+
contrastWarning
|
|
61
|
+
},
|
|
62
|
+
firstTabKey
|
|
63
|
+
),
|
|
64
|
+
tabs.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tabs, { defaultTabId, children: [
|
|
65
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.TabList, { children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.Tab, { tabId: tab.key, children: tab.label }, tab.key)) }),
|
|
66
|
+
tabs.map((tab) => {
|
|
67
|
+
const { key: tabKey, ...restTabProps } = tab;
|
|
68
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
69
|
+
Tabs.TabPanel,
|
|
70
|
+
{
|
|
71
|
+
tabId: tabKey,
|
|
72
|
+
focusable: false,
|
|
73
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
74
|
+
ColorGradientTab,
|
|
75
|
+
{
|
|
76
|
+
...restTabProps,
|
|
77
|
+
colorGradientControlSettings,
|
|
78
|
+
contrastWarning
|
|
79
|
+
},
|
|
80
|
+
tabKey
|
|
81
|
+
)
|
|
82
|
+
},
|
|
83
|
+
tabKey
|
|
84
|
+
);
|
|
85
|
+
})
|
|
86
|
+
] })
|
|
87
|
+
] }) });
|
|
88
|
+
}
|
|
89
|
+
var popoverProps = {
|
|
90
|
+
placement: "left-start",
|
|
91
|
+
offset: 36,
|
|
92
|
+
shift: true
|
|
93
|
+
};
|
|
94
|
+
var LabeledColorIndicators = ({ indicators, label }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { justify: "flex-start", children: [
|
|
95
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalZStack, { isLayered: false, offset: -8, children: indicators.map((indicator, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Flex, { expanded: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ColorIndicator, { colorValue: indicator }) }, index)) }),
|
|
96
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FlexItem, { className: "block-editor-panel-color-gradient-settings__color-name", children: label })
|
|
97
|
+
] });
|
|
98
|
+
function ColorGradientTab({
|
|
99
|
+
isGradient,
|
|
100
|
+
inheritedValue,
|
|
101
|
+
inheritedSlug,
|
|
102
|
+
userValue,
|
|
103
|
+
setValue,
|
|
104
|
+
colorGradientControlSettings,
|
|
105
|
+
contrastWarning
|
|
106
|
+
}) {
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
108
|
+
import_control.default,
|
|
109
|
+
{
|
|
110
|
+
...colorGradientControlSettings,
|
|
111
|
+
showTitle: false,
|
|
112
|
+
enableAlpha: true,
|
|
113
|
+
__experimentalIsRenderedInSidebar: true,
|
|
114
|
+
colorValue: isGradient ? void 0 : inheritedValue,
|
|
115
|
+
colorSlug: isGradient ? void 0 : inheritedSlug,
|
|
116
|
+
gradientValue: isGradient ? inheritedValue : void 0,
|
|
117
|
+
onColorChange: isGradient ? void 0 : setValue,
|
|
118
|
+
onGradientChange: isGradient ? setValue : void 0,
|
|
119
|
+
clearable: inheritedValue === userValue,
|
|
120
|
+
headingLevel: 3,
|
|
121
|
+
noticeProps: !isGradient && contrastWarning ? {
|
|
122
|
+
children: contrastWarning,
|
|
123
|
+
status: "warning",
|
|
124
|
+
spokenMessage: null,
|
|
125
|
+
className: "block-editor-panel-color-gradient-settings__contrast-notice"
|
|
126
|
+
} : void 0
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
function ColorGradientDropdownItem({
|
|
131
|
+
label,
|
|
132
|
+
hasValue,
|
|
133
|
+
resetValue,
|
|
134
|
+
isShownByDefault,
|
|
135
|
+
indicators,
|
|
136
|
+
tabs,
|
|
137
|
+
colorGradientControlSettings,
|
|
138
|
+
panelId,
|
|
139
|
+
contrastWarning,
|
|
140
|
+
className = "block-editor-tools-panel-color-gradient-settings__item"
|
|
141
|
+
}) {
|
|
142
|
+
const colorGradientDropdownButtonRef = (0, import_element.useRef)(void 0);
|
|
143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
|
+
import_components.__experimentalToolsPanelItem,
|
|
145
|
+
{
|
|
146
|
+
className: (0, import_clsx.default)("block-editor-color-gradient-item", className),
|
|
147
|
+
hasValue,
|
|
148
|
+
label,
|
|
149
|
+
onDeselect: resetValue,
|
|
150
|
+
isShownByDefault,
|
|
151
|
+
panelId,
|
|
152
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
153
|
+
import_components.Dropdown,
|
|
154
|
+
{
|
|
155
|
+
popoverProps,
|
|
156
|
+
className: "block-editor-tools-panel-color-gradient-settings__dropdown",
|
|
157
|
+
renderToggle: ({ onToggle, isOpen }) => {
|
|
158
|
+
const toggleProps = {
|
|
159
|
+
onClick: onToggle,
|
|
160
|
+
className: (0, import_clsx.default)(
|
|
161
|
+
"block-editor-panel-color-gradient-settings__dropdown",
|
|
162
|
+
{
|
|
163
|
+
"is-open": isOpen,
|
|
164
|
+
"has-contrast-warning": !!contrastWarning
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
"aria-expanded": isOpen,
|
|
168
|
+
ref: colorGradientDropdownButtonRef
|
|
169
|
+
};
|
|
170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
171
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, { ...toggleProps, __next40pxDefaultSize: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
172
|
+
LabeledColorIndicators,
|
|
173
|
+
{
|
|
174
|
+
indicators,
|
|
175
|
+
label
|
|
176
|
+
}
|
|
177
|
+
) }),
|
|
178
|
+
hasValue() && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
179
|
+
import_components.Button,
|
|
180
|
+
{
|
|
181
|
+
__next40pxDefaultSize: true,
|
|
182
|
+
label: (0, import_i18n.__)("Reset"),
|
|
183
|
+
className: "block-editor-panel-color-gradient-settings__reset",
|
|
184
|
+
size: "small",
|
|
185
|
+
icon: import_icons.reset,
|
|
186
|
+
onClick: () => {
|
|
187
|
+
resetValue();
|
|
188
|
+
if (isOpen) {
|
|
189
|
+
onToggle();
|
|
190
|
+
}
|
|
191
|
+
colorGradientDropdownButtonRef.current?.focus();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
contrastWarning && // An icon-only warning that stays visible while a
|
|
196
|
+
// contrast warning is in effect. It is not a menu;
|
|
197
|
+
// activating it opens the color picker popover where
|
|
198
|
+
// the full warning notice is shown, so the indicator
|
|
199
|
+
// doubles as a shortcut to where the issue is fixed.
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
201
|
+
import_components.Button,
|
|
202
|
+
{
|
|
203
|
+
__next40pxDefaultSize: true,
|
|
204
|
+
size: "small",
|
|
205
|
+
icon: import_icons.caution,
|
|
206
|
+
label: (0, import_i18n.__)("Low contrast"),
|
|
207
|
+
className: "block-editor-panel-color-gradient-settings__contrast-warning",
|
|
208
|
+
"aria-expanded": isOpen,
|
|
209
|
+
onClick: onToggle
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
] });
|
|
213
|
+
},
|
|
214
|
+
renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
215
|
+
DropdownContent,
|
|
216
|
+
{
|
|
217
|
+
tabs,
|
|
218
|
+
colorGradientControlSettings,
|
|
219
|
+
contrastWarning
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=color-gradient-dropdown-item.cjs.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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,wB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O,MAAO;AAC1C,kBAAM,cAAc;AAAA,cACnB,SAAS;AAAA,cACT,eAAW,YAAAA;AAAA,gBACV;AAAA,gBACA;AAAA,kBACC,WAAW;AAAA,kBACX,wBAAwB,CAAC,CAAE;AAAA,gBAC5B;AAAA,cACD;AAAA,cACA,iBAAiB;AAAA,cACjB,KAAK;AAAA,YACN;AAEA,mBACC,4EACC;AAAA,0DAAC,4BAAS,GAAG,aAAc,uBAAqB,MAC/C;AAAA,gBAAC;AAAA;AAAA,kBACA;AAAA,kBACA;AAAA;AAAA,cACD,GACD;AAAA,cACE,SAAS,KACV;AAAA,gBAAC;AAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,WAAQ,gBAAI,OAAQ;AAAA,kBACpB,WAAU;AAAA,kBACV,MAAK;AAAA,kBACL,MAAO,aAAAC;AAAA,kBACP,SAAU,MAAM;AACf,+BAAW;AACX,wBAAK,QAAS;AACb,+BAAS;AAAA,oBACV;AACA,mDAA+B,SAAS,MAAM;AAAA,kBAC/C;AAAA;AAAA,cACD;AAAA,cAEC;AAAA;AAAA;AAAA;AAAA;AAAA,cAMD;AAAA,gBAAC;AAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,MAAK;AAAA,kBACL,MAAO,aAAAC;AAAA,kBACP,WAAQ,gBAAI,cAAe;AAAA,kBAC3B,WAAU;AAAA,kBACV,iBAAgB;AAAA,kBAChB,SAAU;AAAA;AAAA,cACX;AAAA,eAEF;AAAA,UAEF;AAAA,UACA,eAAgB,MACf;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA,cAGA;AAAA;AAAA,UACD;AAAA;AAAA,MAEF;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": ["componentsPrivateApis", "DropdownContentWrapper", "HStack", "ZStack", "ColorGradientControl", "ToolsPanelItem", "clsx", "resetIcon", "cautionIcon"]
|
|
7
|
+
}
|