Object(external_wp_element_["useLayoutEffect"])(function () {
return Object(external_wp_element_["createElement"])(popover["a" /* default */], {
className: "components-autocomplete__popover",
}, Object(external_wp_element_["createElement"])("div", {
className: "components-autocomplete__results"
}, Object(external_lodash_["map"])(items, function (option, index) {
return Object(external_wp_element_["createElement"])(build_module_button["a" /* default */], {
id: "components-autocomplete-item-".concat(instanceId, "-").concat(option.key),
"aria-selected": index === selectedIndex,
disabled: option.isDisabled,
className: classnames_default()('components-autocomplete__result', className, {
'is-selected': index === selectedIndex
onClick: function onClick() {
function Autocomplete(_ref2) {
var children = _ref2.children,
isSelected = _ref2.isSelected,
onChange = _ref2.onChange,
onReplace = _ref2.onReplace,
completers = _ref2.completers,
debouncedSpeak = _ref2.debouncedSpeak,
contentRef = _ref2.contentRef;
var instanceId = Object(external_wp_compose_["useInstanceId"])(Autocomplete);
var _useState3 = Object(external_wp_element_["useState"])(0),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
selectedIndex = _useState4[0],
setSelectedIndex = _useState4[1];
var _useState5 = Object(external_wp_element_["useState"])([]),
_useState6 = Object(slicedToArray["a" /* default */])(_useState5, 2),
filteredOptions = _useState6[0],
setFilteredOptions = _useState6[1];
var _useState7 = Object(external_wp_element_["useState"])(''),
_useState8 = Object(slicedToArray["a" /* default */])(_useState7, 2),
filterValue = _useState8[0],
setFilterValue = _useState8[1];
var _useState9 = Object(external_wp_element_["useState"])(null),
_useState10 = Object(slicedToArray["a" /* default */])(_useState9, 2),
autocompleter = _useState10[0],
setAutocompleter = _useState10[1];
var _useState11 = Object(external_wp_element_["useState"])(null),
_useState12 = Object(slicedToArray["a" /* default */])(_useState11, 2),
AutocompleterUI = _useState12[0],
setAutocompleterUI = _useState12[1];
function insertCompletion(replacement) {
var start = end - autocompleter.triggerPrefix.length - filterValue.length;
var toInsert = Object(external_wp_richText_["create"])({
html: Object(external_wp_element_["renderToString"])(replacement)
onChange(Object(external_wp_richText_["insert"])(record, toInsert, start, end));
function select(option) {
var _ref3 = autocompleter || {},
getOptionCompletion = _ref3.getOptionCompletion;
if (getOptionCompletion) {
var completion = getOptionCompletion(option.value, filterValue);
var _ref4 = undefined === completion.action || undefined === completion.value ? {
action: 'insert-at-caret',
if ('replace' === action) {
} else if ('insert-at-caret' === action) {
} // Reset autocomplete state after insertion rather than before
// so insertion events don't cause the completion menu to redisplay.
setAutocompleterUI(null);
function announce(options) {
debouncedSpeak(Object(external_wp_i18n_["sprintf"])(
/* translators: %d: number of results. */
Object(external_wp_i18n_["_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(Object(external_wp_i18n_["__"])('No results.'), 'assertive');
* Load options for an autocompleter.
function onChangeOptions(options) {
setSelectedIndex(options.length === filteredOptions.length ? selectedIndex : 0);
setFilteredOptions(options);
function handleKeyDown(event) {
if (filteredOptions.length === 0) {
case external_wp_keycodes_["UP"]:
setSelectedIndex((selectedIndex === 0 ? filteredOptions.length : selectedIndex) - 1);
case external_wp_keycodes_["DOWN"]:
setSelectedIndex((selectedIndex + 1) % filteredOptions.length);
case external_wp_keycodes_["ESCAPE"]:
setAutocompleterUI(null);
case external_wp_keycodes_["ENTER"]:
select(filteredOptions[selectedIndex]);
case external_wp_keycodes_["LEFT"]:
case external_wp_keycodes_["RIGHT"]:
} // Any handled keycode should prevent original behavior. This relies on
// the early return in the default case.
if (Object(external_wp_richText_["isCollapsed"])(record)) {
textContent = Object(external_wp_richText_["getTextContent"])(Object(external_wp_richText_["slice"])(record, 0));
Object(external_wp_element_["useEffect"])(function () {
var text = Object(external_lodash_["deburr"])(textContent);
var textAfterSelection = Object(external_wp_richText_["getTextContent"])(Object(external_wp_richText_["slice"])(record, undefined, Object(external_wp_richText_["getTextContent"])(record).length));
var completer = Object(external_lodash_["find"])(completers, function (_ref5) {
var triggerPrefix = _ref5.triggerPrefix,
allowContext = _ref5.allowContext;
var index = text.lastIndexOf(triggerPrefix);
if (allowContext && !allowContext(text.slice(0, index), textAfterSelection)) {
return /^\S*$/.test(text.slice(index + triggerPrefix.length));
var safeTrigger = Object(external_lodash_["escapeRegExp"])(completer.triggerPrefix);
var match = text.match(new RegExp("".concat(safeTrigger, "(\\S*)$")));
var query = match && match[1];
setAutocompleter(completer);
setAutocompleterUI(function () {
return completer !== autocompleter ? autocomplete_getAutoCompleterUI(completer) : AutocompleterUI;
var _ref6 = filteredOptions[selectedIndex] || {},
selectedKey = _ref6$key === void 0 ? '' : _ref6$key;
var _ref7 = autocompleter || {},
className = _ref7.className;
var isExpanded = !!autocompleter && filteredOptions.length > 0;
var listBoxId = isExpanded ? "components-autocomplete-listbox-".concat(instanceId) : null;
var activeId = isExpanded ? "components-autocomplete-item-".concat(instanceId, "-").concat(selectedKey) : null;
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, children({
}), isSelected && AutocompleterUI && Object(external_wp_element_["createElement"])(AutocompleterUI, {
filterValue: filterValue,
selectedIndex: selectedIndex,
onChangeOptions: onChangeOptions,
/* harmony default export */ var autocomplete = (with_spoken_messages(Autocomplete));
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/unit-control/styles/unit-control-styles.js
function unit_control_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)."; }
var unit_control_styles_Root = styled_base_browser_esm("div", {
styles: "box-sizing:border-box;position:relative;"
var unit_control_styles_paddingStyles = function paddingStyles(_ref2) {
var disableUnits = _ref2.disableUnits;
var value = disableUnits ? 3 : 24;
return /*#__PURE__*/Object(core_browser_esm["b" /* css */])(rtl_rtl({
})(), ";" + ( true ? "" : undefined));
var unit_control_styles_ref = true ? {
styles: "&::-webkit-outer-spin-button,&::-webkit-inner-spin-button{-webkit-appearance:none;margin:0;}"
var arrowStyles = function arrowStyles(_ref3) {
var disableUnits = _ref3.disableUnits;
if (disableUnits) return '';
return unit_control_styles_ref;
}; // TODO: Resolve need to use &&& to increase specificity
// https://github.com/WordPress/gutenberg/issues/18483
var ValueInput = /*#__PURE__*/styled_base_browser_esm(number_control, {
})("&&&{input{appearance:none;-moz-appearance:textfield;display:block;width:100%;", arrowStyles, ";", unit_control_styles_paddingStyles, ";}}" + ( true ? "" : undefined));
var unit_control_styles_unitSizeStyles = function unitSizeStyles(_ref4) {
return /*#__PURE__*/Object(core_browser_esm["b" /* css */])(sizes[size], true ? "" : undefined);
var unit_control_styles_baseUnitLabelStyles = function baseUnitLabelStyles(props) {
return /*#__PURE__*/Object(core_browser_esm["b" /* css */])("appearance:none;background:transparent;border-radius:2px;border:none;box-sizing:border-box;color:", colors_color('darkGray.500'), ";display:block;font-size:8px;line-height:1;letter-spacing:-0.5px;outline:none;padding:2px 1px;position:absolute;text-align-last:center;text-transform:uppercase;width:20px;", rtl_rtl({
borderBottomLeftRadius: 0
})(), " ", unit_control_styles_unitSizeStyles(props), true ? "" : undefined);
var UnitLabel = styled_base_browser_esm("div", {
})("&&&{pointer-events:none;", unit_control_styles_baseUnitLabelStyles, ";}" + ( true ? "" : undefined));
var UnitSelect = styled_base_browser_esm("select", {
})("&&&{", unit_control_styles_baseUnitLabelStyles, ";cursor:pointer;border:1px solid transparent;&:hover{background-color:", colors_color('lightGray.300'), ";}&:focus{border-color:", colors_color('ui.borderFocus'), ";outline:2px solid transparent;outline-offset:0;}&:disabled{cursor:initial;&:hover{background-color:transparent;}}}" + ( true ? "" : undefined));
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/unit-control/utils.js
var DEFAULT_UNIT = CSS_UNITS[0];
* Handles legacy value + unit handling.
* This component use to manage both incoming value and units separately.
* Moving forward, ideally the value should be a string that contains both
* the value and unit, example: '10px'
* @param {number|string} value Value
* @param {string} unit Unit value
* @param {Array<Object>} units Units to derive from.
* @return {Array<number, string>} The extracted number and unit.
function getParsedValue(value, unit, units) {
var initialValue = unit ? "".concat(value).concat(unit) : value;
return parseUnit(initialValue, units);
* Checks if units are defined.
* @param {any} units Units to check.
* @return {boolean} Whether units are defined.
function utils_hasUnits(units) {
return !Object(external_lodash_["isEmpty"])(units) && units.length > 1 && units !== false;
* Parses a number and unit from a value.
* @param {string} initialValue Value to parse
* @param {Array<Object>} units Units to derive from.
* @return {Array<number, string>} The extracted number and unit.
function parseUnit(initialValue) {
var units = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CSS_UNITS;
var value = String(initialValue).trim();
var num = parseFloat(value, 10);
num = isNaN(num) ? '' : num;
var unitMatch = value.match(/[\d.\-\+]*\s*(.*)/)[1];
var unit = unitMatch !== undefined ? unitMatch : '';
unit = unit.toLowerCase();
if (utils_hasUnits(units)) {
var match = units.find(function (item) {
return item.value === unit;
unit = match === null || match === void 0 ? void 0 : match.value;
unit = DEFAULT_UNIT.value;
* Parses a number and unit from a value. Validates parsed value, using fallback
* @param {number|string} next The next value.
* @param {Array<Object>} units Units to derive from.
* @param {number|string} fallbackValue The fallback value.
* @param {string} fallbackUnit The fallback value.
* @return {Array<number, string>} The extracted number and unit.
function getValidParsedUnit(next, units, fallbackValue, fallbackUnit) {
var _parseUnit = parseUnit(next, units),
_parseUnit2 = Object(slicedToArray["a" /* default */])(_parseUnit, 2),
parsedValue = _parseUnit2[0],
parsedUnit = _parseUnit2[1];
var baseValue = parsedValue;
if (isNaN(parsedValue) || parsedValue === '') {
baseValue = fallbackValue;
baseUnit = parsedUnit || fallbackUnit;
* If no unit is found, attempt to use the first value from the collection
* of units as a default fallback.
if (utils_hasUnits(units) && !baseUnit) {
baseUnit = (_units$ = units[0]) === null || _units$ === void 0 ? void 0 : _units$.value;
return [baseValue, baseUnit];
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/unit-control/unit-select-control.js
* Renders a `select` if there are multiple units.
* Otherwise, renders a non-selectable label.
* @param {Object} props Component props.
* @param {string} [props.className] Class to set on the `select` element.
* @param {boolean} [props.isTabbable=true] Whether the control can be focused via keyboard navigation.