@internetarchive/modal-manager 2.0.3 → 2.0.4-alpha-webdev7960.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +29 -29
- package/.eslintrc.js +14 -14
- package/.github/workflows/ci.yml +30 -30
- package/.github/workflows/gh-pages-main.yml +42 -42
- package/.github/workflows/pr-preview.yml +40 -40
- package/LICENSE +661 -661
- package/README.md +139 -139
- package/custom-elements.json +170 -170
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -5
- package/dist/src/assets/arrow-left-icon.d.ts +2 -2
- package/dist/src/assets/arrow-left-icon.js +2 -2
- package/dist/src/assets/ia-logo-icon.d.ts +2 -2
- package/dist/src/assets/ia-logo-icon.js +2 -2
- package/dist/src/modal-config.d.ts +104 -104
- package/dist/src/modal-config.js +24 -24
- package/dist/src/modal-manager-host-bridge-interface.d.ts +12 -12
- package/dist/src/modal-manager-host-bridge-interface.js +1 -1
- package/dist/src/modal-manager-host-bridge.d.ts +34 -34
- package/dist/src/modal-manager-host-bridge.js +62 -62
- package/dist/src/modal-manager-interface.d.ts +27 -27
- package/dist/src/modal-manager-interface.js +1 -1
- package/dist/src/modal-manager-mode.d.ts +10 -10
- package/dist/src/modal-manager-mode.js +11 -11
- package/dist/src/modal-manager.d.ts +137 -127
- package/dist/src/modal-manager.js +212 -197
- package/dist/src/modal-manager.js.map +1 -1
- package/dist/src/modal-template.d.ts +41 -41
- package/dist/src/modal-template.js +115 -115
- package/dist/src/shoelace/active-elements.d.ts +15 -15
- package/dist/src/shoelace/active-elements.js +27 -27
- package/dist/src/shoelace/modal.d.ts +24 -24
- package/dist/src/shoelace/modal.js +131 -131
- package/dist/src/shoelace/tabbable.d.ts +9 -9
- package/dist/src/shoelace/tabbable.js +169 -169
- package/dist/test/modal-config.test.d.ts +1 -1
- package/dist/test/modal-config.test.js +69 -69
- package/dist/test/modal-manager.test.d.ts +1 -1
- package/dist/test/modal-manager.test.js +275 -240
- package/dist/test/modal-manager.test.js.map +1 -1
- package/dist/test/modal-template.test.d.ts +1 -1
- package/dist/test/modal-template.test.js +156 -156
- package/dist/vite.config.d.ts +2 -2
- package/dist/vite.config.js +22 -22
- package/docs/assets/css/main.css +2678 -2678
- package/docs/classes/_src_modal_config_.modalconfig.html +429 -429
- package/docs/classes/_src_modal_manager_.modalmanager.html +7702 -7702
- package/docs/classes/_src_modal_manager_host_bridge_.modalmanagerhostbridge.html +409 -409
- package/docs/classes/_src_modal_template_.modaltemplate.html +7096 -7096
- package/docs/enums/_src_modal_manager_mode_.modalmanagermode.html +196 -196
- package/docs/globals.html +150 -150
- package/docs/index.html +252 -252
- package/docs/interfaces/_src_modal_manager_host_bridge_interface_.modalmanagerhostbridgeinterface.html +210 -210
- package/docs/interfaces/_src_modal_manager_interface_.modalmanagerinterface.html +7095 -7095
- package/docs/modules/_index_.html +208 -208
- package/docs/modules/_src_modal_config_.html +146 -146
- package/docs/modules/_src_modal_manager_.html +146 -146
- package/docs/modules/_src_modal_manager_host_bridge_.html +146 -146
- package/docs/modules/_src_modal_manager_host_bridge_interface_.html +146 -146
- package/docs/modules/_src_modal_manager_interface_.html +146 -146
- package/docs/modules/_src_modal_manager_mode_.html +146 -146
- package/docs/modules/_src_modal_template_.html +146 -146
- package/docs/modules/_test_modal_config_test_.html +106 -106
- package/docs/modules/_test_modal_manager_test_.html +106 -106
- package/docs/modules/_test_modal_template_test_.html +106 -106
- package/index.html +300 -300
- package/karma.conf.js +24 -24
- package/package.json +85 -85
- package/renovate.json +7 -7
- package/src/modal-manager.ts +22 -0
- package/src/shoelace/LICENSE.md +6 -6
- package/test/modal-manager.test.ts +52 -6
- package/tsconfig.json +21 -21
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { LitElement, html, css, nothing } from 'lit';
|
|
3
|
-
import { property, customElement } from 'lit/decorators.js';
|
|
4
|
-
import '@internetarchive/ia-activity-indicator';
|
|
5
|
-
import '@internetarchive/icon-close';
|
|
6
|
-
import { ModalConfig } from './modal-config';
|
|
7
|
-
import IALogoIcon from './assets/ia-logo-icon';
|
|
8
|
-
import arrowLeftIcon from './assets/arrow-left-icon';
|
|
9
|
-
let ModalTemplate = class ModalTemplate extends LitElement {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(...arguments);
|
|
12
|
-
/**
|
|
13
|
-
* The ModalConfig that displayed the template
|
|
14
|
-
*
|
|
15
|
-
* @type {ModalConfig}
|
|
16
|
-
* @memberof ModalTemplate
|
|
17
|
-
*/
|
|
18
|
-
this.config = new ModalConfig();
|
|
19
|
-
}
|
|
20
|
-
/** @inheritdoc */
|
|
21
|
-
render() {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, html, css, nothing } from 'lit';
|
|
3
|
+
import { property, customElement } from 'lit/decorators.js';
|
|
4
|
+
import '@internetarchive/ia-activity-indicator';
|
|
5
|
+
import '@internetarchive/icon-close';
|
|
6
|
+
import { ModalConfig } from './modal-config';
|
|
7
|
+
import IALogoIcon from './assets/ia-logo-icon';
|
|
8
|
+
import arrowLeftIcon from './assets/arrow-left-icon';
|
|
9
|
+
let ModalTemplate = class ModalTemplate extends LitElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
/**
|
|
13
|
+
* The ModalConfig that displayed the template
|
|
14
|
+
*
|
|
15
|
+
* @type {ModalConfig}
|
|
16
|
+
* @memberof ModalTemplate
|
|
17
|
+
*/
|
|
18
|
+
this.config = new ModalConfig();
|
|
19
|
+
}
|
|
20
|
+
/** @inheritdoc */
|
|
21
|
+
render() {
|
|
22
22
|
return html `
|
|
23
23
|
<div class="modal-wrapper">
|
|
24
24
|
<div class="modal-container">
|
|
25
25
|
<header style="background-color: ${this.config.headerColor}">
|
|
26
|
-
${this.config.showLeftNavButton
|
|
27
|
-
? this.leftNavButtonTemplate
|
|
26
|
+
${this.config.showLeftNavButton
|
|
27
|
+
? this.leftNavButtonTemplate
|
|
28
28
|
: nothing}
|
|
29
29
|
${this.config.showCloseButton ? this.closeButtonTemplate : ''}
|
|
30
|
-
${this.config.showHeaderLogo
|
|
31
|
-
? html `<div class="logo-icon">${IALogoIcon}</div>`
|
|
30
|
+
${this.config.showHeaderLogo
|
|
31
|
+
? html `<div class="logo-icon">${IALogoIcon}</div>`
|
|
32
32
|
: nothing}
|
|
33
|
-
${this.config.title
|
|
34
|
-
? html `<h1 class="title">${this.config.title}</h1>`
|
|
33
|
+
${this.config.title
|
|
34
|
+
? html `<h1 class="title">${this.config.title}</h1>`
|
|
35
35
|
: ''}
|
|
36
|
-
${this.config.subtitle
|
|
37
|
-
? html `<h2 class="subtitle">${this.config.subtitle}</h2>`
|
|
36
|
+
${this.config.subtitle
|
|
37
|
+
? html `<h2 class="subtitle">${this.config.subtitle}</h2>`
|
|
38
38
|
: ''}
|
|
39
39
|
</header>
|
|
40
40
|
<section
|
|
@@ -43,19 +43,19 @@ let ModalTemplate = class ModalTemplate extends LitElement {
|
|
|
43
43
|
>
|
|
44
44
|
<div class="content">
|
|
45
45
|
<div
|
|
46
|
-
class="processing-logo ${this.config.showProcessingIndicator
|
|
47
|
-
? ''
|
|
46
|
+
class="processing-logo ${this.config.showProcessingIndicator
|
|
47
|
+
? ''
|
|
48
48
|
: 'hidden'}"
|
|
49
49
|
>
|
|
50
50
|
<ia-activity-indicator
|
|
51
51
|
.mode=${this.config.processingImageMode}
|
|
52
52
|
></ia-activity-indicator>
|
|
53
53
|
</div>
|
|
54
|
-
${this.config.headline
|
|
55
|
-
? html ` <h1 class="headline">${this.config.headline}</h1> `
|
|
54
|
+
${this.config.headline
|
|
55
|
+
? html ` <h1 class="headline">${this.config.headline}</h1> `
|
|
56
56
|
: ''}
|
|
57
|
-
${this.config.message
|
|
58
|
-
? html ` <p class="message">${this.config.message}</p> `
|
|
57
|
+
${this.config.message
|
|
58
|
+
? html ` <p class="message">${this.config.message}</p> `
|
|
59
59
|
: ''}
|
|
60
60
|
|
|
61
61
|
<div class="slot-container">
|
|
@@ -65,49 +65,49 @@ let ModalTemplate = class ModalTemplate extends LitElement {
|
|
|
65
65
|
</section>
|
|
66
66
|
</div>
|
|
67
67
|
</div>
|
|
68
|
-
`;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Dispatch the `closeButtonPressed` event to the consumer
|
|
72
|
-
*
|
|
73
|
-
* @private
|
|
74
|
-
* @memberof ModalTemplate
|
|
75
|
-
*/
|
|
76
|
-
handleCloseButton(e) {
|
|
77
|
-
e.preventDefault();
|
|
78
|
-
if (e.type === 'keydown' &&
|
|
79
|
-
e.key !== ' ' &&
|
|
80
|
-
e.key !== 'Enter') {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const event = new Event('closeButtonPressed');
|
|
84
|
-
this.dispatchEvent(event);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Dispatch the `leftNavButtonPressed` event to the consumer
|
|
88
|
-
*
|
|
89
|
-
* @private
|
|
90
|
-
* @memberof ModalTemplate
|
|
91
|
-
*/
|
|
92
|
-
handleLeftNavButtonPressed(e) {
|
|
93
|
-
e.preventDefault();
|
|
94
|
-
if (e.type === 'keydown' &&
|
|
95
|
-
e.key !== ' ' &&
|
|
96
|
-
e.key !== 'Enter') {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const event = new Event('leftNavButtonPressed');
|
|
100
|
-
this.dispatchEvent(event);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* The close button template
|
|
104
|
-
*
|
|
105
|
-
* @readonly
|
|
106
|
-
* @private
|
|
107
|
-
* @type {TemplateResult}
|
|
108
|
-
* @memberof ModalTemplate
|
|
109
|
-
*/
|
|
110
|
-
get closeButtonTemplate() {
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Dispatch the `closeButtonPressed` event to the consumer
|
|
72
|
+
*
|
|
73
|
+
* @private
|
|
74
|
+
* @memberof ModalTemplate
|
|
75
|
+
*/
|
|
76
|
+
handleCloseButton(e) {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
if (e.type === 'keydown' &&
|
|
79
|
+
e.key !== ' ' &&
|
|
80
|
+
e.key !== 'Enter') {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const event = new Event('closeButtonPressed');
|
|
84
|
+
this.dispatchEvent(event);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Dispatch the `leftNavButtonPressed` event to the consumer
|
|
88
|
+
*
|
|
89
|
+
* @private
|
|
90
|
+
* @memberof ModalTemplate
|
|
91
|
+
*/
|
|
92
|
+
handleLeftNavButtonPressed(e) {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
if (e.type === 'keydown' &&
|
|
95
|
+
e.key !== ' ' &&
|
|
96
|
+
e.key !== 'Enter') {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const event = new Event('leftNavButtonPressed');
|
|
100
|
+
this.dispatchEvent(event);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The close button template
|
|
104
|
+
*
|
|
105
|
+
* @readonly
|
|
106
|
+
* @private
|
|
107
|
+
* @type {TemplateResult}
|
|
108
|
+
* @memberof ModalTemplate
|
|
109
|
+
*/
|
|
110
|
+
get closeButtonTemplate() {
|
|
111
111
|
return html `
|
|
112
112
|
<button
|
|
113
113
|
type="button"
|
|
@@ -117,10 +117,10 @@ let ModalTemplate = class ModalTemplate extends LitElement {
|
|
|
117
117
|
>
|
|
118
118
|
<ia-icon-close></ia-icon-close>
|
|
119
119
|
</button>
|
|
120
|
-
`;
|
|
121
|
-
}
|
|
122
|
-
get leftNavButtonTemplate() {
|
|
123
|
-
var _a;
|
|
120
|
+
`;
|
|
121
|
+
}
|
|
122
|
+
get leftNavButtonTemplate() {
|
|
123
|
+
var _a;
|
|
124
124
|
return html `<button
|
|
125
125
|
type="button"
|
|
126
126
|
class="back-button"
|
|
@@ -128,29 +128,29 @@ let ModalTemplate = class ModalTemplate extends LitElement {
|
|
|
128
128
|
@keydown=${this.handleLeftNavButtonPressed}
|
|
129
129
|
>
|
|
130
130
|
${arrowLeftIcon} ${(_a = this.config.leftNavButtonText) !== null && _a !== void 0 ? _a : ''}
|
|
131
|
-
</button> `;
|
|
132
|
-
}
|
|
133
|
-
/** @inheritdoc */
|
|
134
|
-
static get styles() {
|
|
135
|
-
const modalLogoSize = css `var(--modalLogoSize, 6.5rem)`;
|
|
136
|
-
const processingImageSize = css `var(--processingImageSize, 7.5rem)`;
|
|
137
|
-
const modalCornerRadius = css `var(--modalCornerRadius, 1rem)`;
|
|
138
|
-
const modalBorder = css `var(--modalBorder, 2px solid black)`;
|
|
139
|
-
// if the content of the modal is too big to fit on screen, this sets the bottom margin
|
|
140
|
-
// it's not exact, but a close estimation
|
|
141
|
-
const modalBottomMarginCss = css `var(--modalBottomMargin, 2.5rem)`;
|
|
142
|
-
const modalTopMarginCss = css `var(--modalTopMargin, 5rem)`;
|
|
143
|
-
const modalHeaderBottomPaddingCss = css `var(--modalHeaderBottomPadding, 0.5em)`;
|
|
144
|
-
const modalBottomPadding = css `var(--modalBottomPadding, 2rem)`;
|
|
145
|
-
const scrollOffset = css `var(--modalScrollOffset, 5px)`;
|
|
146
|
-
const titleFontSize = css `var(--modalTitleFontSize, 1.8rem)`;
|
|
147
|
-
const subtitleFontSize = css `var(--modalSubtitleFontSize, 1.4rem)`;
|
|
148
|
-
const headlineFontSize = css `var(--modalHeadlineFontSize, 1.6rem)`;
|
|
149
|
-
const messageFontSize = css `var(--modalMessageFontSize, 1.4rem)`;
|
|
150
|
-
const titleLineHeight = css `var(--modalTitleLineHeight, normal)`;
|
|
151
|
-
const subtitleLineHeight = css `var(--modalSubtitleLineHeight, normal)`;
|
|
152
|
-
const headlineLineHeight = css `var(--modalHeadlineLineHeight, normal)`;
|
|
153
|
-
const messageLineHeight = css `var(--modalMessageLineHeight, normal)`;
|
|
131
|
+
</button> `;
|
|
132
|
+
}
|
|
133
|
+
/** @inheritdoc */
|
|
134
|
+
static get styles() {
|
|
135
|
+
const modalLogoSize = css `var(--modalLogoSize, 6.5rem)`;
|
|
136
|
+
const processingImageSize = css `var(--processingImageSize, 7.5rem)`;
|
|
137
|
+
const modalCornerRadius = css `var(--modalCornerRadius, 1rem)`;
|
|
138
|
+
const modalBorder = css `var(--modalBorder, 2px solid black)`;
|
|
139
|
+
// if the content of the modal is too big to fit on screen, this sets the bottom margin
|
|
140
|
+
// it's not exact, but a close estimation
|
|
141
|
+
const modalBottomMarginCss = css `var(--modalBottomMargin, 2.5rem)`;
|
|
142
|
+
const modalTopMarginCss = css `var(--modalTopMargin, 5rem)`;
|
|
143
|
+
const modalHeaderBottomPaddingCss = css `var(--modalHeaderBottomPadding, 0.5em)`;
|
|
144
|
+
const modalBottomPadding = css `var(--modalBottomPadding, 2rem)`;
|
|
145
|
+
const scrollOffset = css `var(--modalScrollOffset, 5px)`;
|
|
146
|
+
const titleFontSize = css `var(--modalTitleFontSize, 1.8rem)`;
|
|
147
|
+
const subtitleFontSize = css `var(--modalSubtitleFontSize, 1.4rem)`;
|
|
148
|
+
const headlineFontSize = css `var(--modalHeadlineFontSize, 1.6rem)`;
|
|
149
|
+
const messageFontSize = css `var(--modalMessageFontSize, 1.4rem)`;
|
|
150
|
+
const titleLineHeight = css `var(--modalTitleLineHeight, normal)`;
|
|
151
|
+
const subtitleLineHeight = css `var(--modalSubtitleLineHeight, normal)`;
|
|
152
|
+
const headlineLineHeight = css `var(--modalHeadlineLineHeight, normal)`;
|
|
153
|
+
const messageLineHeight = css `var(--modalMessageLineHeight, normal)`;
|
|
154
154
|
return css `
|
|
155
155
|
.processing-logo {
|
|
156
156
|
margin: auto;
|
|
@@ -323,14 +323,14 @@ let ModalTemplate = class ModalTemplate extends LitElement {
|
|
|
323
323
|
clip: rect(0, 0, 0, 0);
|
|
324
324
|
border: 0;
|
|
325
325
|
}
|
|
326
|
-
`;
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
__decorate([
|
|
330
|
-
property({ type: Object })
|
|
331
|
-
], ModalTemplate.prototype, "config", void 0);
|
|
332
|
-
ModalTemplate = __decorate([
|
|
333
|
-
customElement('modal-template')
|
|
334
|
-
], ModalTemplate);
|
|
335
|
-
export { ModalTemplate };
|
|
326
|
+
`;
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
__decorate([
|
|
330
|
+
property({ type: Object })
|
|
331
|
+
], ModalTemplate.prototype, "config", void 0);
|
|
332
|
+
ModalTemplate = __decorate([
|
|
333
|
+
customElement('modal-template')
|
|
334
|
+
], ModalTemplate);
|
|
335
|
+
export { ModalTemplate };
|
|
336
336
|
//# sourceMappingURL=modal-template.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Use a generator so we can iterate and possibly break early.
|
|
3
|
-
* @example
|
|
4
|
-
* // to operate like a regular array. This kinda nullifies generator benefits, but worth knowing if you need the whole array.
|
|
5
|
-
* const allActiveElements = [...activeElements()]
|
|
6
|
-
*
|
|
7
|
-
* // Early return
|
|
8
|
-
* for (const activeElement of activeElements()) {
|
|
9
|
-
* if (<cond>) {
|
|
10
|
-
* break; // Break the loop, dont need to iterate over the whole array or store an array in memory!
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
13
|
-
*/
|
|
14
|
-
export declare function activeElements(activeElement?: Element | null): Generator<Element>;
|
|
15
|
-
export declare function getDeepestActiveElement(): Element | undefined;
|
|
1
|
+
/**
|
|
2
|
+
* Use a generator so we can iterate and possibly break early.
|
|
3
|
+
* @example
|
|
4
|
+
* // to operate like a regular array. This kinda nullifies generator benefits, but worth knowing if you need the whole array.
|
|
5
|
+
* const allActiveElements = [...activeElements()]
|
|
6
|
+
*
|
|
7
|
+
* // Early return
|
|
8
|
+
* for (const activeElement of activeElements()) {
|
|
9
|
+
* if (<cond>) {
|
|
10
|
+
* break; // Break the loop, dont need to iterate over the whole array or store an array in memory!
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
export declare function activeElements(activeElement?: Element | null): Generator<Element>;
|
|
15
|
+
export declare function getDeepestActiveElement(): Element | undefined;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
/**
|
|
3
|
-
* Use a generator so we can iterate and possibly break early.
|
|
4
|
-
* @example
|
|
5
|
-
* // to operate like a regular array. This kinda nullifies generator benefits, but worth knowing if you need the whole array.
|
|
6
|
-
* const allActiveElements = [...activeElements()]
|
|
7
|
-
*
|
|
8
|
-
* // Early return
|
|
9
|
-
* for (const activeElement of activeElements()) {
|
|
10
|
-
* if (<cond>) {
|
|
11
|
-
* break; // Break the loop, dont need to iterate over the whole array or store an array in memory!
|
|
12
|
-
* }
|
|
13
|
-
* }
|
|
14
|
-
*/
|
|
15
|
-
export function* activeElements(activeElement = document.activeElement) {
|
|
16
|
-
if (activeElement === null || activeElement === undefined)
|
|
17
|
-
return;
|
|
18
|
-
yield activeElement;
|
|
19
|
-
if ('shadowRoot' in activeElement &&
|
|
20
|
-
activeElement.shadowRoot &&
|
|
21
|
-
activeElement.shadowRoot.mode !== 'closed') {
|
|
22
|
-
yield* activeElements(activeElement.shadowRoot.activeElement);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export function getDeepestActiveElement() {
|
|
26
|
-
return [...activeElements()].pop();
|
|
27
|
-
}
|
|
1
|
+
/* istanbul ignore file */
|
|
2
|
+
/**
|
|
3
|
+
* Use a generator so we can iterate and possibly break early.
|
|
4
|
+
* @example
|
|
5
|
+
* // to operate like a regular array. This kinda nullifies generator benefits, but worth knowing if you need the whole array.
|
|
6
|
+
* const allActiveElements = [...activeElements()]
|
|
7
|
+
*
|
|
8
|
+
* // Early return
|
|
9
|
+
* for (const activeElement of activeElements()) {
|
|
10
|
+
* if (<cond>) {
|
|
11
|
+
* break; // Break the loop, dont need to iterate over the whole array or store an array in memory!
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export function* activeElements(activeElement = document.activeElement) {
|
|
16
|
+
if (activeElement === null || activeElement === undefined)
|
|
17
|
+
return;
|
|
18
|
+
yield activeElement;
|
|
19
|
+
if ('shadowRoot' in activeElement &&
|
|
20
|
+
activeElement.shadowRoot &&
|
|
21
|
+
activeElement.shadowRoot.mode !== 'closed') {
|
|
22
|
+
yield* activeElements(activeElement.shadowRoot.activeElement);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function getDeepestActiveElement() {
|
|
26
|
+
return [...activeElements()].pop();
|
|
27
|
+
}
|
|
28
28
|
//# sourceMappingURL=active-elements.js.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export default class Modal {
|
|
2
|
-
element: HTMLElement;
|
|
3
|
-
isExternalActivated: boolean;
|
|
4
|
-
tabDirection: 'forward' | 'backward';
|
|
5
|
-
currentFocus: HTMLElement | null;
|
|
6
|
-
previousFocus: HTMLElement | null;
|
|
7
|
-
elementsWithTabbableControls: string[];
|
|
8
|
-
constructor(element: HTMLElement);
|
|
9
|
-
/** Activates focus trapping. */
|
|
10
|
-
activate(): void;
|
|
11
|
-
/** Deactivates focus trapping. */
|
|
12
|
-
deactivate(): void;
|
|
13
|
-
/** Determines if this modal element is currently active or not. */
|
|
14
|
-
isActive(): boolean;
|
|
15
|
-
/** Activates external modal behavior and temporarily disables focus trapping. */
|
|
16
|
-
activateExternal(): void;
|
|
17
|
-
/** Deactivates external modal behavior and re-enables focus trapping. */
|
|
18
|
-
deactivateExternal(): void;
|
|
19
|
-
private checkFocus;
|
|
20
|
-
private handleFocusIn;
|
|
21
|
-
private possiblyHasTabbableChildren;
|
|
22
|
-
private handleKeyDown;
|
|
23
|
-
private handleKeyUp;
|
|
24
|
-
}
|
|
1
|
+
export default class Modal {
|
|
2
|
+
element: HTMLElement;
|
|
3
|
+
isExternalActivated: boolean;
|
|
4
|
+
tabDirection: 'forward' | 'backward';
|
|
5
|
+
currentFocus: HTMLElement | null;
|
|
6
|
+
previousFocus: HTMLElement | null;
|
|
7
|
+
elementsWithTabbableControls: string[];
|
|
8
|
+
constructor(element: HTMLElement);
|
|
9
|
+
/** Activates focus trapping. */
|
|
10
|
+
activate(): void;
|
|
11
|
+
/** Deactivates focus trapping. */
|
|
12
|
+
deactivate(): void;
|
|
13
|
+
/** Determines if this modal element is currently active or not. */
|
|
14
|
+
isActive(): boolean;
|
|
15
|
+
/** Activates external modal behavior and temporarily disables focus trapping. */
|
|
16
|
+
activateExternal(): void;
|
|
17
|
+
/** Deactivates external modal behavior and re-enables focus trapping. */
|
|
18
|
+
deactivateExternal(): void;
|
|
19
|
+
private checkFocus;
|
|
20
|
+
private handleFocusIn;
|
|
21
|
+
private possiblyHasTabbableChildren;
|
|
22
|
+
private handleKeyDown;
|
|
23
|
+
private handleKeyUp;
|
|
24
|
+
}
|