@wordpress/global-styles-ui
Version:
Global Styles UI components for WordPress.
39 lines (38 loc) • 1.66 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
let _wordpress_block_editor = require("@wordpress/block-editor");
let __hooks_ts = require("./hooks.cjs");
let __lock_unlock_ts = require("./lock-unlock.cjs");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/global-styles-ui/src/background-panel.tsx
const BACKGROUND_DEFAULT_VALUES = { backgroundSize: "auto" };
const { BackgroundPanel: StylesBackgroundPanel } = (0, __lock_unlock_ts.unlock)(_wordpress_block_editor.privateApis);
/**
* Checks if there is a current value in the background image block support
* attributes.
*
* @param style Style attribute.
* @return Whether the block has a background image value set.
*/
function hasBackgroundImageValue(style) {
return !!style?.background?.backgroundImage?.id || !!style?.background?.backgroundImage?.url || typeof style?.background?.backgroundImage === "string";
}
function BackgroundPanel() {
const [style] = (0, __hooks_ts.useStyle)("", void 0, "user", false);
const [inheritedStyle, setStyle] = (0, __hooks_ts.useStyle)("", void 0, "merged", false);
const resolvedInheritedStyle = (0, __hooks_ts.useStyleWithResolvedBackground)(inheritedStyle);
const [settings] = (0, __hooks_ts.useSetting)("");
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StylesBackgroundPanel, {
inheritedValue: resolvedInheritedStyle,
value: style,
onChange: setStyle,
settings,
defaultValues: BACKGROUND_DEFAULT_VALUES
});
}
exports.default = BackgroundPanel;
exports.hasBackgroundImageValue = hasBackgroundImageValue;
//# sourceMappingURL=background-panel.cjs.map