: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
colorGradientControlSettings,
const currentTab = tabs.find(tab => tab.userValue !== undefined);
} = (_tabs$ = tabs[0]) !== null && _tabs$ !== void 0 ? _tabs$ : {};
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
className: "block-editor-tools-panel-color-gradient-settings__item",
isShownByDefault: isShownByDefault,
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
popoverProps: popoverProps,
className: "block-editor-tools-panel-color-gradient-settings__dropdown",
className: dist_clsx('block-editor-panel-color-gradient-settings__dropdown', {
'aria-label': (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s is the type of color property, e.g., "background" */
(0,external_wp_i18n_namespaceObject.__)('Color %s styles'), label)
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LabeledColorIndicators, {
renderContent: () => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalDropdownContentWrapper, {
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
className: "block-editor-panel-color-gradient-settings__dropdown-content",
children: [tabs.length === 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ColorPanelTab, {
colorGradientControlSettings: colorGradientControlSettings
}, firstTabKey), tabs.length > 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(color_panel_Tabs, {
defaultTabId: currentTab?.key,
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(color_panel_Tabs.TabList, {
children: tabs.map(tab => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(color_panel_Tabs.Tab, {
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(color_panel_Tabs.TabPanel, {
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ColorPanelTab, {
colorGradientControlSettings: colorGradientControlSettings
as: Wrapper = ColorToolsPanel,
defaultControls = color_panel_DEFAULT_CONTROLS,
const colors = useColorsPerOrigin(settings);
const gradients = useGradientsPerOrigin(settings);
const areCustomSolidsEnabled = settings?.color?.custom;
const areCustomGradientsEnabled = settings?.color?.customGradient;
const hasSolidColors = colors.length > 0 || areCustomSolidsEnabled;
const hasGradientColors = gradients.length > 0 || areCustomGradientsEnabled;
const decodeValue = rawValue => getValueFromVariable({
const encodeColorValue = colorValue => {
const allColors = colors.flatMap(({
const colorObject = allColors.find(({
}) => color === colorValue);
return colorObject ? 'var:preset|color|' + colorObject.slug : colorValue;
const encodeGradientValue = gradientValue => {
const allGradients = gradients.flatMap(({
gradients: originGradients
const gradientObject = allGradients.find(({
}) => gradient === gradientValue);
return gradientObject ? 'var:preset|gradient|' + gradientObject.slug : gradientValue;
const showBackgroundPanel = color_panel_useHasBackgroundPanel(settings);
const backgroundColor = decodeValue(inheritedValue?.color?.background);
const userBackgroundColor = decodeValue(value?.color?.background);
const gradient = decodeValue(inheritedValue?.color?.gradient);
const userGradient = decodeValue(value?.color?.gradient);
const hasBackground = () => !!userBackgroundColor || !!userGradient;
const setBackgroundColor = newColor => {
const newValue = setImmutably(value, ['color', 'background'], encodeColorValue(newColor));
newValue.color.gradient = undefined;
const setGradient = newGradient => {
const newValue = setImmutably(value, ['color', 'gradient'], encodeGradientValue(newGradient));
newValue.color.background = undefined;
const resetBackground = () => {
const newValue = setImmutably(value, ['color', 'background'], undefined);
newValue.color.gradient = undefined;
const showLinkPanel = useHasLinkPanel(settings);
const linkColor = decodeValue(inheritedValue?.elements?.link?.color?.text);
const userLinkColor = decodeValue(value?.elements?.link?.color?.text);
const setLinkColor = newColor => {
onChange(setImmutably(value, ['elements', 'link', 'color', 'text'], encodeColorValue(newColor)));
const hoverLinkColor = decodeValue(inheritedValue?.elements?.link?.[':hover']?.color?.text);
const userHoverLinkColor = decodeValue(value?.elements?.link?.[':hover']?.color?.text);
const setHoverLinkColor = newColor => {
onChange(setImmutably(value, ['elements', 'link', ':hover', 'color', 'text'], encodeColorValue(newColor)));
const hasLink = () => !!userLinkColor || !!userHoverLinkColor;
const resetLink = () => {
let newValue = setImmutably(value, ['elements', 'link', ':hover', 'color', 'text'], undefined);
newValue = setImmutably(newValue, ['elements', 'link', 'color', 'text'], undefined);
const showTextPanel = useHasTextPanel(settings);
const textColor = decodeValue(inheritedValue?.color?.text);
const userTextColor = decodeValue(value?.color?.text);
const hasTextColor = () => !!userTextColor;
const setTextColor = newColor => {
let changedObject = setImmutably(value, ['color', 'text'], encodeColorValue(newColor));
if (textColor === linkColor) {
changedObject = setImmutably(changedObject, ['elements', 'link', 'color', 'text'], encodeColorValue(newColor));
const resetTextColor = () => setTextColor(undefined);
label: (0,external_wp_i18n_namespaceObject.__)('Captions'),
showPanel: useHasCaptionPanel(settings)
label: (0,external_wp_i18n_namespaceObject.__)('Button'),
showPanel: useHasButtonPanel(settings)
label: (0,external_wp_i18n_namespaceObject.__)('Heading'),
showPanel: useHasHeadingPanel(settings)
label: (0,external_wp_i18n_namespaceObject.__)('H1'),
showPanel: useHasHeadingPanel(settings)
label: (0,external_wp_i18n_namespaceObject.__)('H2'),
showPanel: useHasHeadingPanel(settings)
label: (0,external_wp_i18n_namespaceObject.__)('H3'),
showPanel: useHasHeadingPanel(settings)
label: (0,external_wp_i18n_namespaceObject.__)('H4'),
showPanel: useHasHeadingPanel(settings)
label: (0,external_wp_i18n_namespaceObject.__)('H5'),
showPanel: useHasHeadingPanel(settings)
label: (0,external_wp_i18n_namespaceObject.__)('H6'),
showPanel: useHasHeadingPanel(settings)
const resetAllFilter = (0,external_wp_element_namespaceObject.useCallback)(previousValue => {
...previousValue?.elements,
...previousValue?.elements?.link,
...elements.reduce((acc, element) => {
...previousValue?.elements?.[element.name],
const items = [showTextPanel && {
label: (0,external_wp_i18n_namespaceObject.__)('Text'),
resetValue: resetTextColor,
isShownByDefault: defaultControls.text,
label: (0,external_wp_i18n_namespaceObject.__)('Text'),
inheritedValue: textColor,
}, showBackgroundPanel && {
label: (0,external_wp_i18n_namespaceObject.__)('Background'),
resetValue: resetBackground,
isShownByDefault: defaultControls.background,
indicators: [gradient !== null && gradient !== void 0 ? gradient : backgroundColor],
tabs: [hasSolidColors && {
label: (0,external_wp_i18n_namespaceObject.__)('Color'),
inheritedValue: backgroundColor,
setValue: setBackgroundColor,
userValue: userBackgroundColor
}, hasGradientColors && {
label: (0,external_wp_i18n_namespaceObject.__)('Gradient'),
inheritedValue: gradient,
label: (0,external_wp_i18n_namespaceObject.__)('Link'),
isShownByDefault: defaultControls.link,
indicators: [linkColor, hoverLinkColor],
label: (0,external_wp_i18n_namespaceObject.__)('Default'),
inheritedValue: linkColor,
label: (0,external_wp_i18n_namespaceObject.__)('Hover'),
inheritedValue: hoverLinkColor,
setValue: setHoverLinkColor,
userValue: userHoverLinkColor
const elementBackgroundColor = decodeValue(inheritedValue?.elements?.[name]?.color?.background);
const elementGradient = decodeValue(inheritedValue?.elements?.[name]?.color?.gradient);
const elementTextColor = decodeValue(inheritedValue?.elements?.[name]?.color?.text);
const elementBackgroundUserColor = decodeValue(value?.elements?.[name]?.color?.background);
const elementGradientUserColor = decodeValue(value?.elements?.[name]?.color?.gradient);
const elementTextUserColor = decodeValue(value?.elements?.[name]?.color?.text);
const hasElement = () => !!(elementTextUserColor || elementBackgroundUserColor || elementGradientUserColor);
const resetElement = () => {
const newValue = setImmutably(value, ['elements', name, 'color', 'background'], undefined);
newValue.elements[name].color.gradient = undefined;
newValue.elements[name].color.text = undefined;
const setElementTextColor = newTextColor => {
onChange(setImmutably(value, ['elements', name, 'color', 'text'], encodeColorValue(newTextColor)));
const setElementBackgroundColor = newBackgroundColor => {
const newValue = setImmutably(value, ['elements', name, 'color', 'background'], encodeColorValue(newBackgroundColor));
newValue.elements[name].color.gradient = undefined;
const setElementGradient = newGradient => {
const newValue = setImmutably(value, ['elements', name, 'color', 'gradient'], encodeGradientValue(newGradient));
newValue.elements[name].color.background = undefined;
const supportsTextColor = true;
// Background color is not supported for `caption`
// as there isn't yet a way to set padding for the element.
const supportsBackground = name !== 'caption';
resetValue: resetElement,
isShownByDefault: defaultControls[name],
indicators: supportsTextColor && supportsBackground ? [elementTextColor, elementGradient !== null && elementGradient !== void 0 ? elementGradient : elementBackgroundColor] : [supportsTextColor ? elementTextColor : elementGradient !== null && elementGradient !== void 0 ? elementGradient : elementBackgroundColor],
tabs: [hasSolidColors && supportsTextColor && {
label: (0,external_wp_i18n_namespaceObject.__)('Text'),
inheritedValue: elementTextColor,
setValue: setElementTextColor,
userValue: elementTextUserColor
}, hasSolidColors && supportsBackground && {
label: (0,external_wp_i18n_namespaceObject.__)('Background'),
inheritedValue: elementBackgroundColor,
setValue: setElementBackgroundColor,
userValue: elementBackgroundUserColor
}, hasGradientColors && supportsBackground && {
label: (0,external_wp_i18n_namespaceObject.__)('Gradient'),
inheritedValue: elementGradient,
setValue: setElementGradient,
userValue: elementGradientUserColor,
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Wrapper, {
resetAllFilter: resetAllFilter,
children: [items.map(item => {
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ColorPanelDropdown, {
colorGradientControlSettings: {
disableCustomColors: !areCustomSolidsEnabled,
disableCustomGradients: !areCustomGradientsEnabled
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/contrast-checker/index.js
function ContrastChecker({
// Font size value in pixels.
enableAlphaChecker = false
const currentBackgroundColor = backgroundColor || fallbackBackgroundColor;
// Must have a background color.
if (!currentBackgroundColor) {
const currentTextColor = textColor || fallbackTextColor;
const currentLinkColor = linkColor || fallbackLinkColor;
// Must have at least one text color.
if (!currentTextColor && !currentLinkColor) {
description: (0,external_wp_i18n_namespaceObject.__)('text color')
description: (0,external_wp_i18n_namespaceObject.__)('link color')
const colordBackgroundColor = w(currentBackgroundColor);
const backgroundColorHasTransparency = colordBackgroundColor.alpha() < 1;
const backgroundColorBrightness = colordBackgroundColor.brightness();
const isReadableOptions = {
size: isLargeText || isLargeText !== false && fontSize >= 24 ? 'large' : 'small'
for (const item of textColors) {
// If there is no color, go no further.
const colordTextColor = w(item.color);
const isColordTextReadable = colordTextColor.isReadable(colordBackgroundColor, isReadableOptions);
const textHasTransparency = colordTextColor.alpha() < 1;
// If the contrast is not readable.
if (!isColordTextReadable) {
// Don't show the message if the background or text is transparent.
if (backgroundColorHasTransparency || textHasTransparency) {
message = backgroundColorBrightness < colordTextColor.brightness() ? (0,external_wp_i18n_namespaceObject.sprintf)(
// translators: %s is a type of text color, e.g., "text color" or "link color".
(0,external_wp_i18n_namespaceObject.__)('This color combination may be hard for people to read. Try using a darker background color and/or a brighter %s.'), item.description) : (0,external_wp_i18n_namespaceObject.sprintf)(
// translators: %s is a type of text color, e.g., "text color" or "link color".
(0,external_wp_i18n_namespaceObject.__)('This color combination may be hard for people to read. Try using a brighter background color and/or a darker %s.'), item.description);
speakMessage = (0,external_wp_i18n_namespaceObject.__)('This color combination may be hard for people to read.');
// Break from the loop when we have a contrast warning.
// These messages take priority over the transparency warning.
// If there is no contrast warning and the text is transparent,
// show the transparent warning if alpha check is enabled.
if (textHasTransparency && enableAlphaChecker) {
message = (0,external_wp_i18n_namespaceObject.__)('Transparent text may be hard for people to read.');
speakMessage = (0,external_wp_i18n_namespaceObject.__)('Transparent text may be hard for people to read.');
// Note: The `Notice` component can speak messages via its `spokenMessage`
// prop, but the contrast checker requires granular control over when the
// announcements are made. Notably, the message will be re-announced if a
// new color combination is selected and the contrast is still insufficient.
(0,external_wp_a11y_namespaceObject.speak)(speakMessage);
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
className: "block-editor-contrast-checker",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/contrast-checker/README.md
/* harmony default export */ const contrast_checker = (ContrastChecker);
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/contrast-checker.js