igniteui-webcomponents
Version:
Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.
34 lines • 991 B
JavaScript
import { createAbortHandle } from '../abort-handler.js';
class KeyboardFocusRingController {
get focused() {
return this._isKeyboardFocused;
}
constructor(host) {
this._abortHandle = createAbortHandle();
this._isKeyboardFocused = false;
this._host = host;
host.addController(this);
}
hostConnected() {
const { signal } = this._abortHandle;
for (const event of KeyboardFocusRingController._events) {
this._host.addEventListener(event, this, { passive: true, signal });
}
}
hostDisconnected() {
this._abortHandle.abort();
}
handleEvent(event) {
this._isKeyboardFocused = event.type === 'keyup';
this._host.requestUpdate();
}
}
KeyboardFocusRingController._events = [
'keyup',
'focusout',
'pointerdown',
];
export function addKeyboardFocusRing(host) {
return new KeyboardFocusRingController(host);
}
//# sourceMappingURL=focus-ring.js.map