@internetarchive/modal-manager 2.0.4 → 2.0.5-webdev-8155.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/.github/workflows/ci.yml +40 -30
- package/.github/workflows/gh-pages-main.yml +42 -42
- package/.github/workflows/pr-preview.yml +40 -40
- package/.prettierrc +4 -0
- package/.vscode/extensions.json +10 -0
- package/.vscode/tasks.json +12 -0
- package/LICENSE +661 -661
- package/README.md +139 -139
- package/custom-elements.json +170 -170
- package/demo/app-root.ts +366 -0
- package/dist/demo/app-root.d.ts +22 -0
- package/dist/demo/app-root.js +338 -0
- package/dist/demo/app-root.js.map +1 -0
- 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 +23 -24
- package/dist/src/modal-config.js.map +1 -1
- 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-host-bridge.js.map +1 -1
- 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 -137
- package/dist/src/modal-manager.js +243 -249
- package/dist/src/modal-manager.js.map +1 -1
- package/dist/src/modal-template.d.ts +41 -41
- package/dist/src/modal-template.js +119 -118
- package/dist/src/modal-template.js.map +1 -1
- package/dist/src/shoelace/active-elements.d.ts +15 -15
- package/dist/src/shoelace/active-elements.js +28 -27
- package/dist/src/shoelace/active-elements.js.map +1 -1
- package/dist/src/shoelace/modal.d.ts +24 -24
- package/dist/src/shoelace/modal.js +130 -131
- package/dist/src/shoelace/modal.js.map +1 -1
- package/dist/src/shoelace/tabbable.d.ts +9 -9
- package/dist/src/shoelace/tabbable.js +168 -169
- package/dist/src/shoelace/tabbable.js.map +1 -1
- package/dist/test/modal-config.test.d.ts +1 -1
- package/dist/test/modal-config.test.js +68 -69
- package/dist/test/modal-config.test.js.map +1 -1
- package/dist/test/modal-manager.test.d.ts +1 -1
- package/dist/test/modal-manager.test.js +306 -309
- 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 +158 -167
- package/dist/test/modal-template.test.js.map +1 -1
- package/dist/vite.config.d.ts +2 -2
- package/dist/vite.config.js +22 -22
- package/dist/vitest.config.ci.d.ts +2 -0
- package/dist/vitest.config.ci.js +24 -0
- package/dist/vitest.config.ci.js.map +1 -0
- 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/eslint.config.mjs +53 -0
- package/index.html +33 -300
- package/package.json +73 -85
- package/renovate.json +7 -7
- package/src/modal-config.ts +14 -14
- package/src/modal-manager-host-bridge.ts +2 -2
- package/src/modal-manager.ts +305 -305
- package/src/modal-template.ts +4 -2
- package/src/shoelace/LICENSE.md +6 -6
- package/src/shoelace/active-elements.ts +3 -2
- package/src/shoelace/modal.ts +5 -5
- package/src/shoelace/tabbable.ts +4 -3
- package/test/modal-config.test.ts +4 -4
- package/test/modal-manager.test.ts +402 -393
- package/test/modal-template.test.ts +42 -35
- package/tsconfig.json +25 -21
- package/vitest.config.ci.ts +27 -0
- package/.eslintrc.js +0 -14
- package/karma.conf.js +0 -24
package/src/shoelace/modal.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* c8 ignore start */
|
|
2
2
|
import { activeElements, getDeepestActiveElement } from './active-elements.js';
|
|
3
3
|
import { getTabbableElements } from './tabbable.js';
|
|
4
4
|
|
|
@@ -28,7 +28,7 @@ export default class Modal {
|
|
|
28
28
|
|
|
29
29
|
/** Deactivates focus trapping. */
|
|
30
30
|
deactivate() {
|
|
31
|
-
activeModals = activeModals.filter(modal => modal !== this.element);
|
|
31
|
+
activeModals = activeModals.filter((modal) => modal !== this.element);
|
|
32
32
|
this.currentFocus = null;
|
|
33
33
|
document.removeEventListener('focusin', this.handleFocusIn);
|
|
34
34
|
document.removeEventListener('keydown', this.handleKeyDown);
|
|
@@ -75,7 +75,7 @@ export default class Modal {
|
|
|
75
75
|
private possiblyHasTabbableChildren(element: HTMLElement) {
|
|
76
76
|
return (
|
|
77
77
|
this.elementsWithTabbableControls.includes(
|
|
78
|
-
element.tagName.toLowerCase()
|
|
78
|
+
element.tagName.toLowerCase(),
|
|
79
79
|
) || element.hasAttribute('controls')
|
|
80
80
|
// Should we add a data-attribute for people to set just in case they have an element where we don't know if it has possibly tabbable elements?
|
|
81
81
|
);
|
|
@@ -107,14 +107,13 @@ export default class Modal {
|
|
|
107
107
|
const tabbableElements = getTabbableElements(this.element);
|
|
108
108
|
|
|
109
109
|
let currentFocusIndex = tabbableElements.findIndex(
|
|
110
|
-
el => el === currentActiveElement
|
|
110
|
+
(el) => el === currentActiveElement,
|
|
111
111
|
);
|
|
112
112
|
|
|
113
113
|
this.previousFocus = this.currentFocus;
|
|
114
114
|
|
|
115
115
|
const addition = this.tabDirection === 'forward' ? 1 : -1;
|
|
116
116
|
|
|
117
|
-
// eslint-disable-next-line
|
|
118
117
|
while (true) {
|
|
119
118
|
if (currentFocusIndex + addition >= tabbableElements.length) {
|
|
120
119
|
currentFocusIndex = 0;
|
|
@@ -164,3 +163,4 @@ export default class Modal {
|
|
|
164
163
|
this.tabDirection = 'forward';
|
|
165
164
|
};
|
|
166
165
|
}
|
|
166
|
+
/* c8 ignore end */
|
package/src/shoelace/tabbable.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* c8 ignore start */
|
|
2
2
|
// Cached compute style calls. This is specifically for browsers that dont support `checkVisibility()`.
|
|
3
3
|
// computedStyle calls are "live" so they only need to be retrieved once for an element.
|
|
4
4
|
const computedStyleMap = new WeakMap<Element, CSSStyleDeclaration>();
|
|
@@ -160,7 +160,7 @@ export function getTabbableBoundary(root: HTMLElement | ShadowRoot) {
|
|
|
160
160
|
*/
|
|
161
161
|
function getSlottedChildrenOutsideRootElement(
|
|
162
162
|
slotElement: HTMLSlotElement,
|
|
163
|
-
root: HTMLElement | ShadowRoot
|
|
163
|
+
root: HTMLElement | ShadowRoot,
|
|
164
164
|
) {
|
|
165
165
|
return (
|
|
166
166
|
(slotElement.getRootNode({ composed: true }) as ShadowRoot | null)?.host !==
|
|
@@ -195,7 +195,7 @@ export function getTabbableElements(root: HTMLElement | ShadowRoot) {
|
|
|
195
195
|
el.assignedElements({ flatten: true }).forEach(
|
|
196
196
|
(assignedEl: Element) => {
|
|
197
197
|
walk(assignedEl as HTMLElement | ShadowRoot);
|
|
198
|
-
}
|
|
198
|
+
},
|
|
199
199
|
);
|
|
200
200
|
}
|
|
201
201
|
|
|
@@ -221,3 +221,4 @@ export function getTabbableElements(root: HTMLElement | ShadowRoot) {
|
|
|
221
221
|
return bTabindex - aTabindex;
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
|
+
/* c8 ignore end */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { expect } from '
|
|
1
|
+
import { describe, test, expect } from 'vitest';
|
|
2
2
|
import { html } from 'lit';
|
|
3
3
|
|
|
4
4
|
import { ModalConfig } from '../src/modal-config';
|
|
5
5
|
|
|
6
6
|
describe('Modal Config', () => {
|
|
7
|
-
|
|
7
|
+
test('can be instantiated properly', async () => {
|
|
8
8
|
const config = new ModalConfig();
|
|
9
9
|
const title = html`Foo`;
|
|
10
10
|
config.title = title;
|
|
@@ -14,7 +14,7 @@ describe('Modal Config', () => {
|
|
|
14
14
|
expect(config.headerColor).to.equal('green');
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
test('can be instantiated properly with constructor', async () => {
|
|
18
18
|
const title = html`Foo`;
|
|
19
19
|
const subtitle = html`Bar`;
|
|
20
20
|
const headline = html`Baz`;
|
|
@@ -59,7 +59,7 @@ describe('Modal Config', () => {
|
|
|
59
59
|
expect(config.closeOnBackdropClick).to.equal(closeOnBackdropClick);
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
test('instantiates properly with defaults', async () => {
|
|
63
63
|
const config = new ModalConfig();
|
|
64
64
|
expect(config.title).to.equal(undefined);
|
|
65
65
|
expect(config.subtitle).to.equal(undefined);
|