: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Name of slot in which popover should fill.
const SLOT_NAME = 'Popover';
// An SVG displaying a triangle facing down, filled with a solid
// color and bordered in such a way to create an arrow-like effect.
// Keeping the SVG's viewbox squared simplify the arrow positioning
const ArrowTriangle = () => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
className: "components-popover__triangle",
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
className: "components-popover__triangle-bg",
d: "M 0 0 L 50 50 L 100 0"
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
className: "components-popover__triangle-border",
d: "M 0 0 L 50 50 L 100 0",
vectorEffect: "non-scaling-stroke"
const slotNameContext = (0,external_wp_element_namespaceObject.createContext)(undefined);
const fallbackContainerClassname = 'components-popover__fallback-container';
const getPopoverFallbackContainer = () => {
let container = document.body.querySelector('.' + fallbackContainerClassname);
container = document.createElement('div');
container.className = fallbackContainerClassname;
document.body.append(container);
const UnforwardedPopover = (props, forwardedRef) => {
placement: placementProp = 'bottom-start',
focusOnMount = 'firstElement',
__unstableSlotName = SLOT_NAME,
} = useContextSystem(props, 'Popover');
let computedFlipProp = flip;
let computedResizeProp = resize;
if (__unstableForcePosition !== undefined) {
external_wp_deprecated_default()('`__unstableForcePosition` prop in wp.components.Popover', {
alternative: '`flip={ false }` and `resize={ false }`'
// Back-compat, set the `flip` and `resize` props
// to `false` to replicate `__unstableForcePosition`.
computedFlipProp = !__unstableForcePosition;
computedResizeProp = !__unstableForcePosition;
if (anchorRef !== undefined) {
external_wp_deprecated_default()('`anchorRef` prop in wp.components.Popover', {
alternative: '`anchor` prop'
if (anchorRect !== undefined) {
external_wp_deprecated_default()('`anchorRect` prop in wp.components.Popover', {
alternative: '`anchor` prop'
if (getAnchorRect !== undefined) {
external_wp_deprecated_default()('`getAnchorRect` prop in wp.components.Popover', {
alternative: '`anchor` prop'
const computedVariant = isAlternate ? 'toolbar' : variant;
if (isAlternate !== undefined) {
external_wp_deprecated_default()('`isAlternate` prop in wp.components.Popover', {
alternative: "`variant` prop with the `'toolbar'` value"
const arrowRef = (0,external_wp_element_namespaceObject.useRef)(null);
const [fallbackReferenceElement, setFallbackReferenceElement] = (0,external_wp_element_namespaceObject.useState)(null);
const anchorRefFallback = (0,external_wp_element_namespaceObject.useCallback)(node => {
setFallbackReferenceElement(node);
const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
const isExpanded = expandOnMobile && isMobileViewport;
const hasArrow = !isExpanded && !noArrow;
const normalizedPlacementFromProps = position ? positionToPlacement(position) : placementProp;
const middleware = [...(placementProp === 'overlay' ? overlayMiddlewares() : []), offset(offsetProp), computedFlipProp && floating_ui_dom_flip(), computedResizeProp && floating_ui_dom_size({
var _refs$floating$curren;
} = (_refs$floating$curren = refs.floating.current) !== null && _refs$floating$curren !== void 0 ? _refs$floating$curren : {};
// Only HTMLElement instances have the `style` property.
if (!(firstElementChild instanceof HTMLElement)) {
// Reduce the height of the popover to the available space.
Object.assign(firstElementChild.style, {
maxHeight: `${sizeProps.availableHeight}px`,
}), shift && floating_ui_dom_shift({
limiter: floating_ui_dom_limitShift(),
padding: 1 // Necessary to avoid flickering at the edge of the viewport.
}), floating_ui_react_dom_arrow({
const slotName = (0,external_wp_element_namespaceObject.useContext)(slotNameContext) || __unstableSlotName;
const slot = useSlot(slotName);
if (onClose || onFocusOutside) {
onDialogClose = (type, event) => {
// Ideally the popover should have just a single onClose prop and
// not three props that potentially do the same thing.
if (type === 'focus-outside' && onFocusOutside) {
const [dialogRef, dialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
__unstableOnClose: onDialogClose,
// @ts-expect-error The __unstableOnClose property needs to be deprecated first (see https://github.com/WordPress/gutenberg/pull/27675)
// Positioning coordinates
// Object with "regular" refs to both "reference" and "floating"
// Type of CSS position property to use (absolute or fixed)
placement: computedPlacement,
placement: normalizedPlacementFromProps === 'overlay' ? undefined : normalizedPlacementFromProps,
whileElementsMounted: (referenceParam, floatingParam, updateParam) => autoUpdate(referenceParam, floatingParam, updateParam, {
const arrowCallbackRef = (0,external_wp_element_namespaceObject.useCallback)(node => {
// When any of the possible anchor "sources" change,
// recompute the reference element (real or virtual) and its owner document.
const anchorRefTop = anchorRef?.top;
const anchorRefBottom = anchorRef?.bottom;
const anchorRefStartContainer = anchorRef?.startContainer;
const anchorRefCurrent = anchorRef?.current;
(0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
const resultingReferenceElement = getReferenceElement({
refs.setReference(resultingReferenceElement);
}, [anchor, anchorRef, anchorRefTop, anchorRefBottom, anchorRefStartContainer, anchorRefCurrent, anchorRect, getAnchorRect, fallbackReferenceElement, refs]);
const mergedFloatingRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([refs.setFloating, dialogRef, forwardedRef]);
const style = isExpanded ? undefined : {
// `x` and `y` are framer-motion specific props and are shorthands
// for `translateX` and `translateY`. Currently it is not possible
// to use `translateX` and `translateY` because those values would
// be overridden by the return value of the
// `placementToMotionAnimationProps` function.
x: computePopoverPosition(x),
y: computePopoverPosition(y)
const shouldReduceMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
const shouldAnimate = animate && !isExpanded && !shouldReduceMotion;
const [animationFinished, setAnimationFinished] = (0,external_wp_element_namespaceObject.useState)(false);
style: motionInlineStyles,
} = (0,external_wp_element_namespaceObject.useMemo)(() => placementToMotionAnimationProps(computedPlacement), [computedPlacement]);
const animationProps = shouldAnimate ? {
onAnimationComplete: () => setAnimationFinished(true),
// When Floating UI has finished positioning and Framer Motion has finished animating
// the popover, add the `is-positioned` class to signal that all transitions have finished.
const isPositioned = (!shouldAnimate || animationFinished) && x !== null && y !== null;
let content = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(motion.div, {
className: dist_clsx(className, {
'is-expanded': isExpanded,
'is-positioned': isPositioned,
// Use the 'alternate' classname for 'toolbar' variant for back compat.
[`is-${computedVariant === 'toolbar' ? 'alternate' : computedVariant}`]: computedVariant
children: [isExpanded && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(scroll_lock, {}), isExpanded && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
className: "components-popover__header",
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
className: "components-popover__header-title",
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(build_module_button, {
className: "components-popover__close",
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
className: "components-popover__content",
}), hasArrow && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
className: ['components-popover__arrow', `is-${computedPlacement.split('-')[0]}`].join(' '),
left: typeof arrowData?.x !== 'undefined' && Number.isFinite(arrowData.x) ? `${arrowData.x}px` : '',
top: typeof arrowData?.y !== 'undefined' && Number.isFinite(arrowData.y) ? `${arrowData.y}px` : ''
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ArrowTriangle, {})
const shouldRenderWithinSlot = slot.ref && !inline;
const hasAnchor = anchorRef || anchorRect || anchor;
if (shouldRenderWithinSlot) {
content = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(slot_fill_Fill, {
content = (0,external_wp_element_namespaceObject.createPortal)( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StyleProvider, {
}), getPopoverFallbackContainer());
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
* `Popover` renders its content in a floating modal. If no explicit anchor is passed via props, it anchors to its parent element by default.
* import { Button, Popover } from '@wordpress/components';
* import { useState } from '@wordpress/element';
* const MyPopover = () => {
* const [ isVisible, setIsVisible ] = useState( false );
* const toggleVisible = () => {
* setIsVisible( ( state ) => ! state );
* <Button variant="secondary" onClick={ toggleVisible }>
* { isVisible && <Popover>Popover is toggled!</Popover> }
const popover_Popover = contextConnect(UnforwardedPopover, 'Popover');
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(slot_fill_Slot, {
className: "popover-slot",
// @ts-expect-error For Legacy Reasons
popover_Popover.Slot = (0,external_wp_element_namespaceObject.forwardRef)(PopoverSlot);
// @ts-expect-error For Legacy Reasons
popover_Popover.__unstableSlotNameProvider = slotNameContext.Provider;
/* harmony default export */ const popover = (popover_Popover);
;// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/autocomplete/autocompleter-ui.js
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Component, {
className: "components-autocomplete__results",
children: items.map((option, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(build_module_button, {
id: `components-autocomplete-item-${instanceId}-${option.key}`,
"aria-selected": index === selectedIndex,
disabled: option.isDisabled,
className: dist_clsx('components-autocomplete__result', className, {
'is-selected': index === selectedIndex
onClick: () => onSelect(option),
function getAutoCompleterUI(autocompleter) {
var _autocompleter$useIte;
const useItems = (_autocompleter$useIte = autocompleter.useItems) !== null && _autocompleter$useIte !== void 0 ? _autocompleter$useIte : getDefaultUseItems(autocompleter);
function AutocompleterUI({
const [items] = useItems(filterValue);
const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({
editableContentElement: contentRef.current
const [needsA11yCompat, setNeedsA11yCompat] = (0,external_wp_element_namespaceObject.useState)(false);
const popoverRef = (0,external_wp_element_namespaceObject.useRef)(null);
const popoverRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([popoverRef, (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
if (!contentRef.current) {
// If the popover is rendered in a different document than
// the content, we need to duplicate the options list in the
// content document so that it's available to the screen
// readers, which check the DOM ID based aria-* attributes.
setNeedsA11yCompat(node.ownerDocument !== contentRef.current.ownerDocument);
useOnClickOutside(popoverRef, reset);
const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
function announce(options) {
debouncedSpeak((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of results. */
(0,external_wp_i18n_namespaceObject._n)('%d result found, use up and down arrow keys to navigate.', '%d results found, use up and down arrow keys to navigate.', options.length), options.length), 'assertive');
debouncedSpeak((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of results. */
(0,external_wp_i18n_namespaceObject._n)('Initial %d result loaded. Type to filter all available results. Use up and down arrow keys to navigate.', 'Initial %d results loaded. Type to filter all available results. Use up and down arrow keys to navigate.', options.length), options.length), 'assertive');
debouncedSpeak((0,external_wp_i18n_namespaceObject.__)('No results.'), 'assertive');
(0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
// Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.
// See https://github.com/WordPress/gutenberg/pull/41820
// eslint-disable-next-line react-hooks/exhaustive-deps
if (items.length === 0) {
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(popover, {
className: "components-autocomplete__popover",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ListBox, {
selectedIndex: selectedIndex,
}), contentRef.current && needsA11yCompat && (0,external_ReactDOM_namespaceObject.createPortal)( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ListBox, {
selectedIndex: selectedIndex,
Component: visually_hidden_component
}), contentRef.current.ownerDocument.body)]
function useOnClickOutside(ref, handler) {
(0,external_wp_element_namespaceObject.useEffect)(() => {