@wordpress/global-styles-ui
Version:
Global Styles UI components for WordPress.
1 lines • 2.11 kB
Source Map (JSON)
{"version":3,"file":"background-panel.mjs","names":["blockEditorPrivateApis"],"sources":["../src/background-panel.tsx"],"sourcesContent":["import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useStyle, useSetting, useStyleWithResolvedBackground } from './hooks';\nimport { unlock } from './lock-unlock';\n\n// Initial control values where no block style is set.\nconst BACKGROUND_DEFAULT_VALUES = {\n\tbackgroundSize: 'auto',\n};\n\nconst { BackgroundPanel: StylesBackgroundPanel } = unlock(\n\tblockEditorPrivateApis\n);\n\n/**\n * Checks if there is a current value in the background image block support\n * attributes.\n *\n * @param style Style attribute.\n * @return Whether the block has a background image value set.\n */\nexport function hasBackgroundImageValue( style: any ): boolean {\n\treturn (\n\t\t!! style?.background?.backgroundImage?.id ||\n\t\t!! style?.background?.backgroundImage?.url ||\n\t\ttypeof style?.background?.backgroundImage === 'string'\n\t);\n}\n\nexport default function BackgroundPanel() {\n\tconst [ style ] = useStyle( '', undefined, 'user', false );\n\tconst [ inheritedStyle, setStyle ] = useStyle(\n\t\t'',\n\t\tundefined,\n\t\t'merged',\n\t\tfalse\n\t);\n\tconst resolvedInheritedStyle =\n\t\tuseStyleWithResolvedBackground( inheritedStyle );\n\tconst [ settings ] = useSetting( '' );\n\n\treturn (\n\t\t<StylesBackgroundPanel\n\t\t\tinheritedValue={ resolvedInheritedStyle }\n\t\t\tvalue={ style }\n\t\t\tonChange={ setStyle }\n\t\t\tsettings={ settings }\n\t\t\tdefaultValues={ BACKGROUND_DEFAULT_VALUES }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;AAKA,MAAM,4BAA4B,EACjC,gBAAgB,OACjB;AAEA,MAAM,EAAE,iBAAiB,0BAA0B,OAClDA,WACD;;;;;;;;AASA,SAAgB,wBAAyB,OAAsB;CAC9D,OACC,CAAC,CAAE,OAAO,YAAY,iBAAiB,MACvC,CAAC,CAAE,OAAO,YAAY,iBAAiB,OACvC,OAAO,OAAO,YAAY,oBAAoB;AAEhD;AAEA,SAAwB,kBAAkB;CACzC,MAAM,CAAE,SAAU,SAAU,IAAI,KAAA,GAAW,QAAQ,KAAM;CACzD,MAAM,CAAE,gBAAgB,YAAa,SACpC,IACA,KAAA,GACA,UACA,KACD;CACA,MAAM,yBACL,+BAAgC,cAAe;CAChD,MAAM,CAAE,YAAa,WAAY,EAAG;CAEpC,OACC,oBAAC,uBAAD;EACC,gBAAiB;EACjB,OAAQ;EACR,UAAW;EACA;EACX,eAAgB;CAChB,CAAA;AAEH"}