@wordpress/block-editor
Version:
62 lines (60 loc) • 2.1 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// packages/block-editor/src/components/inserter-listbox/group.js
var group_exports = {};
__export(group_exports, {
default: () => group_default
});
module.exports = __toCommonJS(group_exports);
var import_element = require("@wordpress/element");
var import_i18n = require("@wordpress/i18n");
var import_a11y = require("@wordpress/a11y");
var import_jsx_runtime = require("react/jsx-runtime");
function InserterListboxGroup(props, ref) {
const [shouldSpeak, setShouldSpeak] = (0, import_element.useState)(false);
(0, import_element.useEffect)(() => {
if (shouldSpeak) {
(0, import_a11y.speak)(
(0, import_i18n.__)("Use left and right arrow keys to move through blocks")
);
}
}, [shouldSpeak]);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"div",
{
ref,
role: "listbox",
"aria-orientation": "horizontal",
onFocus: () => {
setShouldSpeak(true);
},
onBlur: (event) => {
const focusingOutsideGroup = !event.currentTarget.contains(
event.relatedTarget
);
if (focusingOutsideGroup) {
setShouldSpeak(false);
}
},
...props
}
);
}
var group_default = (0, import_element.forwardRef)(InserterListboxGroup);
//# sourceMappingURL=group.js.map