forked from vmware-archive/clarity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
focus-trap.base.ts
35 lines (29 loc) · 894 Bytes
/
focus-trap.base.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* Copyright (c) 2016-2020 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
import { html, LitElement } from 'lit-element';
import { FocusTrap } from '../utils/focus-trap.js';
import { property } from '../decorators/property.js';
export class CdsBaseFocusTrap extends LitElement {
protected focusTrap: FocusTrap;
@property({ type: Boolean })
private __demoMode = false;
connectedCallback() {
super.connectedCallback();
if (!this.__demoMode) {
this.focusTrap = new FocusTrap(this);
this.focusTrap.enableFocusTrap();
}
}
disconnectedCallback() {
super.disconnectedCallback();
if (!this.__demoMode) {
this.focusTrap.removeFocusTrap();
}
}
protected render() {
return html`<slot></slot>`;
}
}