: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
} = useContextSystem(dropdownMenuProps, 'DropdownMenu');
if (!controls?.length && !dropdown_menu_isFunction(children)) {
// Normalize controls to nested array of objects (sets of controls)
// @ts-expect-error The check below is needed because `DropdownMenus`
// rendered by `ToolBarGroup` receive controls as a nested array.
if (!Array.isArray(controlSets[0])) {
// This is not ideal, but at this point we know that `controls` is
// not a nested array, even if TypeScript doesn't.
controlSets = [controls];
const mergedPopoverProps = dropdown_menu_mergeProps({
className: 'components-dropdown-menu__popover',
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(dropdown, {
popoverProps: mergedPopoverProps,
var _toggleProps$showTool;
const openOnArrowDown = event => {
if (disableOpenOnArrowDown) {
if (!isOpen && event.code === 'ArrowDown') {
as: Toggle = build_module_button,
} = toggleProps !== null && toggleProps !== void 0 ? toggleProps : {};
const mergedToggleProps = dropdown_menu_mergeProps({
className: dist_clsx('components-dropdown-menu__toggle', {
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Toggle, {
if (mergedToggleProps.onClick) {
mergedToggleProps.onClick(event);
if (mergedToggleProps.onKeyDown) {
mergedToggleProps.onKeyDown(event);
showTooltip: (_toggleProps$showTool = toggleProps?.showTooltip) !== null && _toggleProps$showTool !== void 0 ? _toggleProps$showTool : true,
children: mergedToggleProps.children
renderContent: props => {
const mergedMenuProps = dropdown_menu_mergeProps({
className: dist_clsx('components-dropdown-menu__menu', {
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(navigable_container_menu, {
children: [dropdown_menu_isFunction(children) ? children(props) : null, controlSets?.flatMap((controlSet, indexOfSet) => controlSet.map((control, indexOfControl) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(build_module_button, {
className: dist_clsx('components-dropdown-menu__menu-item', {
'has-separator': indexOfSet > 0 && indexOfControl === 0,
'is-active': control.isActive,
'is-icon-only': !control.title
"aria-checked": control.role === 'menuitemcheckbox' || control.role === 'menuitemradio' ? control.isActive : undefined,
role: control.role === 'menuitemcheckbox' || control.role === 'menuitemradio' ? control.role : 'menuitem',
disabled: control.isDisabled,
}, [indexOfSet, indexOfControl].join())))]
defaultOpen: defaultOpen,
* The DropdownMenu displays a list of actions (each contained in a MenuItem,
* MenuItemsChoice, or MenuGroup) in a compact way. It appears in a Popover
* after the user has interacted with an element (a button or icon) or when
* they perform a specific action.
* Render a Dropdown Menu with a set of controls:
* import { DropdownMenu } from '@wordpress/components';
* } from '@wordpress/icons';
* const MyDropdownMenu = () => (
* label="Select a direction"
* onClick: () => console.log( 'up' ),
* onClick: () => console.log( 'right' ),
* onClick: () => console.log( 'down' ),
* onClick: () => console.log( 'left' ),
* Alternatively, specify a `children` function which returns elements valid for
* use in a DropdownMenu: `MenuItem`, `MenuItemsChoice`, or `MenuGroup`.
* import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
* import { more, arrowUp, arrowDown, trash } from '@wordpress/icons';
* const MyDropdownMenu = () => (
* <DropdownMenu icon={ more } label="Select a direction">
* <MenuItem icon={ arrowUp } onClick={ onClose }>
* <MenuItem icon={ arrowDown } onClick={ onClose }>
* <MenuItem icon={ trash } onClick={ onClose }>
const DropdownMenu = contextConnectWithoutRef(UnconnectedDropdownMenu, 'DropdownMenu');
/* harmony default export */ const dropdown_menu = (DropdownMenu);
;// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/palette-edit/styles.js
function palette_edit_styles_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
const IndicatorStyled = /*#__PURE__*/emotion_styled_base_browser_esm(color_indicator, true ? {
} : 0)("&&{flex-shrink:0;width:", space(6), ";height:", space(6), ";}" + ( true ? "" : 0));
const NameInputControl = /*#__PURE__*/emotion_styled_base_browser_esm(input_control, true ? {
} : 0)(Container, "{background:", COLORS.gray[100], ";border-radius:", config_values.controlBorderRadius, ";", Input, Input, Input, Input, "{height:", space(8), ";}", BackdropUI, BackdropUI, BackdropUI, "{border-color:transparent;box-shadow:none;}}" + ( true ? "" : 0));
const buttonStyleReset = ({
return /*#__PURE__*/emotion_react_browser_esm_css("display:flex;align-items:center;width:100%;appearance:none;background:transparent;border:none;border-radius:0;padding:0;cursor:pointer;&:hover{color:", COLORS.theme.accent, ";}" + ( true ? "" : 0), true ? "" : 0);
const PaletteItem = /*#__PURE__*/emotion_styled_base_browser_esm(component, true ? {
} : 0)(buttonStyleReset, " padding-block:3px;padding-inline-start:", space(3), ";border:1px solid ", config_values.surfaceBorderColor, ";border-bottom-color:transparent;font-size:", font('default.fontSize'), ";&:focus-visible{border-color:transparent;box-shadow:0 0 0 var( --wp-admin-border-width-focus ) ", COLORS.theme.accent, ";outline:2px solid transparent;outline-offset:0;}border-top-left-radius:", config_values.controlBorderRadius, ";border-top-right-radius:", config_values.controlBorderRadius, ";&+&{border-top-left-radius:0;border-top-right-radius:0;}&:last-child{border-bottom-left-radius:", config_values.controlBorderRadius, ";border-bottom-right-radius:", config_values.controlBorderRadius, ";border-bottom-color:", config_values.surfaceBorderColor, ";}&.is-selected+&{border-top-color:transparent;}&.is-selected{border-color:", COLORS.theme.accent, ";}" + ( true ? "" : 0));
const NameContainer = /*#__PURE__*/emotion_styled_base_browser_esm("div", true ? {
} : 0)("line-height:", space(8), ";margin-left:", space(2), ";margin-right:", space(2), ";white-space:nowrap;overflow:hidden;" + ( true ? "" : 0));
const PaletteHeading = /*#__PURE__*/emotion_styled_base_browser_esm(heading_component, true ? {
} : 0)("text-transform:uppercase;line-height:", space(6), ";font-weight:500;&&&{font-size:11px;margin-bottom:0;}" + ( true ? "" : 0));
const PaletteActionsContainer = /*#__PURE__*/emotion_styled_base_browser_esm(component, true ? {
} : 0)("height:", space(6), ";display:flex;" + ( true ? "" : 0));
const PaletteEditContents = /*#__PURE__*/emotion_styled_base_browser_esm(component, true ? {
} : 0)("margin-top:", space(2), ";" + ( true ? "" : 0));
const PaletteEditStyles = /*#__PURE__*/emotion_styled_base_browser_esm(component, true ? {
styles: "&&&{.components-button.has-icon{min-width:0;padding:0;}}"
const DoneButton = /*#__PURE__*/emotion_styled_base_browser_esm(build_module_button, true ? {
} : 0)("&&{color:", COLORS.theme.accent, ";}" + ( true ? "" : 0));
const RemoveButton = /*#__PURE__*/emotion_styled_base_browser_esm(build_module_button, true ? {
} : 0)("&&{margin-top:", space(1), ";}" + ( true ? "" : 0));
;// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/palette-edit/index.js
const DEFAULT_COLOR = '#000';
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NameInputControl, {
hideLabelFromVision: true,
* Returns a name and slug for a palette item. The name takes the format "Color + id".
* To ensure there are no duplicate ids, this function checks all slugs.
* It expects slugs to be in the format: slugPrefix + color- + number.
* It then sets the id component of the new name based on the incremented id of the highest existing slug id.
* @param elements An array of color palette items.
* @param slugPrefix The slug prefix used to match the element slug.
* @return A name and slug for the new palette item.
function getNameAndSlugForPosition(elements, slugPrefix) {
const nameRegex = new RegExp(`^${slugPrefix}color-([\\d]+)$`);
const position = elements.reduce((previousValue, currentValue) => {
if (typeof currentValue?.slug === 'string') {
const matches = currentValue?.slug.match(nameRegex);
const id = parseInt(matches[1], 10);
if (id >= previousValue) {
name: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: is an id for a custom color */
(0,external_wp_i18n_namespaceObject.__)('Color %s'), position),
slug: `${slugPrefix}color-${position}`
function ColorPickerPopover({
popoverProps: receivedPopoverProps,
const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
// Disabling resize as it would otherwise cause the popover to show
// scrollbars while dragging the color picker's handle close to the
className: dist_clsx('components-palette-edit__popover', receivedPopoverProps?.className)
}), [receivedPopoverProps]);
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(popover, {
children: [!isGradient && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LegacyAdapter, {
}), isGradient && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
className: "components-palette-edit__popover-gradient-picker",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(custom_gradient_picker, {
__experimentalIsRenderedInSidebar: true,
onChange: newGradient => {
function palette_edit_Option({
popoverProps: receivedPopoverProps,
const value = isGradient ? element.gradient : element.color;
const [isEditingColor, setIsEditingColor] = (0,external_wp_element_namespaceObject.useState)(false);
// Use internal state instead of a ref to make sure that the component
// re-renders when the popover's anchor updates.
const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
// Use the custom palette color item as the popover anchor.
}), [popoverAnchor, receivedPopoverProps]);
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PaletteItem, {
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(h_stack_component, {
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(build_module_button, {
"aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
// translators: %s is a color or gradient name, e.g. "Red".
(0,external_wp_i18n_namespaceObject.__)('Edit: %s'), element.name.trim().length ? element.name : value),
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(IndicatorStyled, {
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(flex_item_component, {
children: !canOnlyChangeValues ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NameInput, {
label: isGradient ? (0,external_wp_i18n_namespaceObject.__)('Gradient name') : (0,external_wp_i18n_namespaceObject.__)('Color name'),
onChange: nextName => onChange({
slug: slugPrefix + kebabCase(nextName !== null && nextName !== void 0 ? nextName : '')
}) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NameContainer, {
children: element.name.trim().length ? element.name : /* Fall back to non-breaking space to maintain height */
}), !canOnlyChangeValues && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(flex_item_component, {
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RemoveButton, {
label: (0,external_wp_i18n_namespaceObject.sprintf)(
// translators: %s is a color or gradient name, e.g. "Red".
(0,external_wp_i18n_namespaceObject.__)('Remove color: %s'), element.name.trim().length ? element.name : value),
}), isEditingColor && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ColorPickerPopover, {
popoverProps: popoverProps,
onClose: () => setIsEditingColor(false)
function PaletteEditListView({
// When unmounting the component if there are empty elements (the user did not complete the insertion) clean them.
const elementsReference = (0,external_wp_element_namespaceObject.useRef)();
(0,external_wp_element_namespaceObject.useEffect)(() => {
elementsReference.current = elements;
const debounceOnChange = (0,external_wp_compose_namespaceObject.useDebounce)(onChange, 100);
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(v_stack_component, {
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(item_group_component, {
children: elements.map((element, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(palette_edit_Option, {
canOnlyChangeValues: canOnlyChangeValues,
onChange: newElement => {
debounceOnChange(elements.map((currentElement, currentIndex) => {
if (currentIndex === index) {
const newElements = elements.filter((_currentElement, currentIndex) => {
if (currentIndex === index) {
onChange(newElements.length ? newElements : undefined);
addColorRef.current?.focus();
popoverProps: popoverProps
* Allows editing a palette of colors or gradients.