Outlook_Addin_LLM/node_modules/@fluentui/utilities/lib-commonjs/setFocusVisibility.js

38 lines
1.9 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setFocusVisibility = exports.IsFocusHiddenClassName = exports.IsFocusVisibleClassName = void 0;
var getWindow_1 = require("./dom/getWindow");
exports.IsFocusVisibleClassName = 'ms-Fabric--isFocusVisible';
exports.IsFocusHiddenClassName = 'ms-Fabric--isFocusHidden';
function updateClassList(el, enabled) {
if (el) {
el.classList.add(enabled ? exports.IsFocusVisibleClassName : exports.IsFocusHiddenClassName);
el.classList.remove(enabled ? exports.IsFocusHiddenClassName : exports.IsFocusVisibleClassName);
}
}
/**
* Sets the visibility of focus styling.
*
* By default, focus styles (the box surrounding a focused Button, for example) only show up when navigational
* keypresses occur (through Tab, arrows, PgUp/PgDn, Home and End), and are hidden when mouse interactions occur.
* This API provides an imperative way to turn them on/off.
*
* A use case might be when you have a keypress like ctrl-f6 navigate to a particular region on the page,
* and want focus to show up.
*
* @param enabled - Whether to turn focus visibility on or off.
* @param target - Optional target from which to get window in case no `providerElem` has been specified.
* @param registeredProviders - Array of provider refs that are associated with a FocusRectsProvider. If no array
* is passed in, the classnames are attached to the document body that contains `target`.
*/
function setFocusVisibility(enabled, target, registeredProviders) {
var _a;
if (registeredProviders) {
registeredProviders.forEach(function (ref) { return updateClassList(ref.current, enabled); });
}
else {
updateClassList((_a = (0, getWindow_1.getWindow)(target)) === null || _a === void 0 ? void 0 : _a.document.body, enabled);
}
}
exports.setFocusVisibility = setFocusVisibility;
//# sourceMappingURL=setFocusVisibility.js.map