@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
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { fixture,
|
|
1
|
+
import { fixture, oneEvent } from '@open-wc/testing-helpers';
|
|
2
|
+
import { describe, test, expect } from 'vitest';
|
|
2
3
|
import { html } from 'lit';
|
|
3
4
|
import '../src/modal-template';
|
|
4
5
|
import { ModalConfig } from '../src/modal-config';
|
|
6
|
+
import type { ModalTemplate } from '../src/modal-template';
|
|
5
7
|
|
|
6
8
|
describe('Modal Template', () => {
|
|
7
|
-
|
|
8
|
-
const el = await fixture(html`
|
|
9
|
+
test('has correct default configuration', async () => {
|
|
10
|
+
const el = await fixture<ModalTemplate>(html`
|
|
11
|
+
<modal-template></modal-template>
|
|
12
|
+
`);
|
|
9
13
|
|
|
10
14
|
const processingLogo = el.shadowRoot?.querySelector('.processing-logo');
|
|
11
15
|
const headline = el.shadowRoot?.querySelector('.headline');
|
|
@@ -15,15 +19,15 @@ describe('Modal Template', () => {
|
|
|
15
19
|
expect(headline).to.not.exist;
|
|
16
20
|
expect(message).to.not.exist;
|
|
17
21
|
expect(title).to.not.exist;
|
|
18
|
-
|
|
22
|
+
|
|
19
23
|
expect('hidden' in processingLogo!.classList);
|
|
20
24
|
});
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
test('does not show the title if one not provided', async () => {
|
|
23
27
|
const config = new ModalConfig();
|
|
24
28
|
config.title = undefined;
|
|
25
29
|
|
|
26
|
-
const el = await fixture(html`
|
|
30
|
+
const el = await fixture<ModalTemplate>(html`
|
|
27
31
|
<modal-template .config=${config}></modal-template>
|
|
28
32
|
`);
|
|
29
33
|
|
|
@@ -31,21 +35,24 @@ describe('Modal Template', () => {
|
|
|
31
35
|
expect(title).to.not.exist;
|
|
32
36
|
});
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
const el = await fixture(html`
|
|
36
|
-
|
|
38
|
+
test('emits closeButtonPressed event when close button is pressed', async () => {
|
|
39
|
+
const el = await fixture<ModalTemplate>(html`
|
|
40
|
+
<modal-template></modal-template>
|
|
41
|
+
`);
|
|
37
42
|
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
38
43
|
const clickEvent = new MouseEvent('click');
|
|
39
44
|
|
|
40
45
|
setTimeout(() => {
|
|
41
46
|
closeButton?.dispatchEvent(clickEvent);
|
|
42
47
|
});
|
|
43
|
-
const response = await oneEvent(el, 'closeButtonPressed'
|
|
48
|
+
const response = await oneEvent(el, 'closeButtonPressed');
|
|
44
49
|
expect(response).to.exist;
|
|
45
50
|
});
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
const el = await fixture(html`
|
|
52
|
+
test('emits closeButtonPressed event when close button gets spacebar pressed', async () => {
|
|
53
|
+
const el = await fixture<ModalTemplate>(html`
|
|
54
|
+
<modal-template></modal-template>
|
|
55
|
+
`);
|
|
49
56
|
|
|
50
57
|
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
51
58
|
const clickEvent = new KeyboardEvent('keydown', { key: ' ' });
|
|
@@ -53,14 +60,14 @@ describe('Modal Template', () => {
|
|
|
53
60
|
setTimeout(() => {
|
|
54
61
|
closeButton?.dispatchEvent(clickEvent);
|
|
55
62
|
});
|
|
56
|
-
const response = await oneEvent(el, 'closeButtonPressed'
|
|
63
|
+
const response = await oneEvent(el, 'closeButtonPressed');
|
|
57
64
|
expect(response).to.exist;
|
|
58
65
|
});
|
|
59
66
|
|
|
60
|
-
|
|
67
|
+
test('emits leftNavButtonPressed event when left nav button is pressed', async () => {
|
|
61
68
|
const config = new ModalConfig();
|
|
62
69
|
config.showLeftNavButton = true;
|
|
63
|
-
const el = await fixture(html`
|
|
70
|
+
const el = await fixture<ModalTemplate>(html`
|
|
64
71
|
<modal-template .config=${config}></modal-template>
|
|
65
72
|
`);
|
|
66
73
|
|
|
@@ -70,14 +77,14 @@ describe('Modal Template', () => {
|
|
|
70
77
|
setTimeout(() => {
|
|
71
78
|
leftNavButton?.dispatchEvent(clickEvent);
|
|
72
79
|
});
|
|
73
|
-
const response = await oneEvent(el, 'leftNavButtonPressed'
|
|
80
|
+
const response = await oneEvent(el, 'leftNavButtonPressed');
|
|
74
81
|
expect(response).to.exist;
|
|
75
82
|
});
|
|
76
83
|
|
|
77
|
-
|
|
84
|
+
test('emits leftNavButtonPressed event when left nav button gets spacebar pressed', async () => {
|
|
78
85
|
const config = new ModalConfig();
|
|
79
86
|
config.showLeftNavButton = true;
|
|
80
|
-
const el = await fixture(html`
|
|
87
|
+
const el = await fixture<ModalTemplate>(html`
|
|
81
88
|
<modal-template .config=${config}></modal-template>
|
|
82
89
|
`);
|
|
83
90
|
|
|
@@ -87,15 +94,15 @@ describe('Modal Template', () => {
|
|
|
87
94
|
setTimeout(() => {
|
|
88
95
|
leftNavButton?.dispatchEvent(clickEvent);
|
|
89
96
|
});
|
|
90
|
-
const response = await oneEvent(el, 'leftNavButtonPressed'
|
|
97
|
+
const response = await oneEvent(el, 'leftNavButtonPressed');
|
|
91
98
|
expect(response).to.exist;
|
|
92
99
|
});
|
|
93
100
|
|
|
94
|
-
|
|
101
|
+
test('shows the processing indicator if configured to', async () => {
|
|
95
102
|
const config = new ModalConfig();
|
|
96
103
|
config.showProcessingIndicator = true;
|
|
97
104
|
|
|
98
|
-
const el = await fixture(html`
|
|
105
|
+
const el = await fixture<ModalTemplate>(html`
|
|
99
106
|
<modal-template .config=${config}></modal-template>
|
|
100
107
|
`);
|
|
101
108
|
|
|
@@ -104,10 +111,10 @@ describe('Modal Template', () => {
|
|
|
104
111
|
expect('hidden' in classList).to.equal(false);
|
|
105
112
|
});
|
|
106
113
|
|
|
107
|
-
|
|
114
|
+
test('shows the left nav button if configured to', async () => {
|
|
108
115
|
const config = new ModalConfig();
|
|
109
116
|
config.showLeftNavButton = true;
|
|
110
|
-
const el = await fixture(html`
|
|
117
|
+
const el = await fixture<ModalTemplate>(html`
|
|
111
118
|
<modal-template .config=${config}></modal-template>
|
|
112
119
|
`);
|
|
113
120
|
|
|
@@ -115,10 +122,10 @@ describe('Modal Template', () => {
|
|
|
115
122
|
expect(leftNavButton).to.exist;
|
|
116
123
|
});
|
|
117
124
|
|
|
118
|
-
|
|
125
|
+
test('hides the left nav button if configured to', async () => {
|
|
119
126
|
const config = new ModalConfig();
|
|
120
127
|
config.showCloseButton = false;
|
|
121
|
-
const el = await fixture(html`
|
|
128
|
+
const el = await fixture<ModalTemplate>(html`
|
|
122
129
|
<modal-template .config=${config}></modal-template>
|
|
123
130
|
`);
|
|
124
131
|
|
|
@@ -126,11 +133,11 @@ describe('Modal Template', () => {
|
|
|
126
133
|
expect(closeButton).to.not.exist;
|
|
127
134
|
});
|
|
128
135
|
|
|
129
|
-
|
|
136
|
+
test('uses custom text for the left nav button if configured to', async () => {
|
|
130
137
|
const config = new ModalConfig();
|
|
131
138
|
config.showLeftNavButton = true;
|
|
132
139
|
config.leftNavButtonText = 'Previous';
|
|
133
|
-
const el = await fixture(html`
|
|
140
|
+
const el = await fixture<ModalTemplate>(html`
|
|
134
141
|
<modal-template .config=${config}></modal-template>
|
|
135
142
|
`);
|
|
136
143
|
|
|
@@ -140,11 +147,11 @@ describe('Modal Template', () => {
|
|
|
140
147
|
expect(leftNavButton?.innerHTML).to.contain('Previous');
|
|
141
148
|
});
|
|
142
149
|
|
|
143
|
-
|
|
150
|
+
test('does not use any text for the left nav button if not configured to', async () => {
|
|
144
151
|
const config = new ModalConfig();
|
|
145
152
|
config.showLeftNavButton = true;
|
|
146
153
|
|
|
147
|
-
const el = await fixture(html`
|
|
154
|
+
const el = await fixture<ModalTemplate>(html`
|
|
148
155
|
<modal-template .config=${config}></modal-template>
|
|
149
156
|
`);
|
|
150
157
|
|
|
@@ -152,10 +159,10 @@ describe('Modal Template', () => {
|
|
|
152
159
|
expect(leftNavButton?.innerHTML).not.to.contain('Previous');
|
|
153
160
|
});
|
|
154
161
|
|
|
155
|
-
|
|
162
|
+
test('shows the close button if configured to', async () => {
|
|
156
163
|
const config = new ModalConfig();
|
|
157
164
|
config.showCloseButton = true;
|
|
158
|
-
const el = await fixture(html`
|
|
165
|
+
const el = await fixture<ModalTemplate>(html`
|
|
159
166
|
<modal-template .config=${config}></modal-template>
|
|
160
167
|
`);
|
|
161
168
|
|
|
@@ -163,10 +170,10 @@ describe('Modal Template', () => {
|
|
|
163
170
|
expect(closeButton).to.exist;
|
|
164
171
|
});
|
|
165
172
|
|
|
166
|
-
|
|
173
|
+
test('hides the close button if configured to', async () => {
|
|
167
174
|
const config = new ModalConfig();
|
|
168
175
|
config.showCloseButton = false;
|
|
169
|
-
const el = await fixture(html`
|
|
176
|
+
const el = await fixture<ModalTemplate>(html`
|
|
170
177
|
<modal-template .config=${config}></modal-template>
|
|
171
178
|
`);
|
|
172
179
|
|
|
@@ -174,14 +181,14 @@ describe('Modal Template', () => {
|
|
|
174
181
|
expect(closeButton).to.not.exist;
|
|
175
182
|
});
|
|
176
183
|
|
|
177
|
-
|
|
184
|
+
test('shows the properties from the config', async () => {
|
|
178
185
|
const config = new ModalConfig();
|
|
179
186
|
config.title = html`Boop`;
|
|
180
187
|
config.subtitle = html`Bop`;
|
|
181
188
|
config.headline = html`Foo`;
|
|
182
189
|
config.message = html`Bar`;
|
|
183
190
|
|
|
184
|
-
const el = await fixture(html`
|
|
191
|
+
const el = await fixture<ModalTemplate>(html`
|
|
185
192
|
<modal-template .config=${config}></modal-template>
|
|
186
193
|
`);
|
|
187
194
|
|
package/tsconfig.json
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"moduleResolution": "
|
|
6
|
-
"noEmitOnError": true,
|
|
7
|
-
"lib": [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "esnext",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"noEmitOnError": true,
|
|
7
|
+
"lib": [
|
|
8
|
+
"esnext",
|
|
9
|
+
"dom"
|
|
10
|
+
],
|
|
11
|
+
"strict": true,
|
|
12
|
+
"esModuleInterop": false,
|
|
13
|
+
"allowSyntheticDefaultImports": true,
|
|
14
|
+
"experimentalDecorators": true,
|
|
15
|
+
"importHelpers": true,
|
|
16
|
+
"outDir": "dist",
|
|
17
|
+
"sourceMap": true,
|
|
18
|
+
"inlineSources": true,
|
|
19
|
+
"declaration": true,
|
|
20
|
+
"rootDir": "./",
|
|
21
|
+
"skipLibCheck": true,
|
|
22
|
+
"useDefineForClassFields": false,
|
|
23
|
+
},
|
|
24
|
+
"include": ["**/*.ts"]
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
2
|
+
import { defineConfig, mergeConfig } from 'vitest/config';
|
|
3
|
+
import { playwright } from '@vitest/browser-playwright'
|
|
4
|
+
import viteConfig from './vite.config';
|
|
5
|
+
|
|
6
|
+
// https://vitest.dev/config
|
|
7
|
+
export default mergeConfig(
|
|
8
|
+
viteConfig,
|
|
9
|
+
defineConfig({
|
|
10
|
+
server: {
|
|
11
|
+
host: '0.0.0.0',
|
|
12
|
+
port: 8080,
|
|
13
|
+
},
|
|
14
|
+
test: {
|
|
15
|
+
browser: {
|
|
16
|
+
headless: true,
|
|
17
|
+
enabled: true,
|
|
18
|
+
provider: playwright(),
|
|
19
|
+
instances: [{ browser: 'chromium' }],
|
|
20
|
+
},
|
|
21
|
+
watch: false,
|
|
22
|
+
coverage: {
|
|
23
|
+
include: ['src/**/*.ts'],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
);
|
package/.eslintrc.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
parser: '@typescript-eslint/parser',
|
|
4
|
-
plugins: ['@typescript-eslint', 'html'],
|
|
5
|
-
extends: ['plugin:@typescript-eslint/recommended'],
|
|
6
|
-
settings: {
|
|
7
|
-
'import/resolver': {
|
|
8
|
-
node: {
|
|
9
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
10
|
-
moduleDirectory: ['node_modules', 'src', 'demo'],
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
package/karma.conf.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
-
const { createDefaultConfig } = require('@open-wc/testing-karma');
|
|
3
|
-
const merge = require('deepmerge');
|
|
4
|
-
|
|
5
|
-
module.exports = config => {
|
|
6
|
-
config.set(
|
|
7
|
-
merge(createDefaultConfig(config), {
|
|
8
|
-
files: [
|
|
9
|
-
// runs all files ending with .test in the test folder,
|
|
10
|
-
// can be overwritten by passing a --grep flag. examples:
|
|
11
|
-
//
|
|
12
|
-
// npm run test -- --grep test/foo/bar.test.js
|
|
13
|
-
// npm run test -- --grep test/bar/*
|
|
14
|
-
{ pattern: config.grep ? config.grep : 'dist/**/test/**/*.test.js', type: 'module' },
|
|
15
|
-
],
|
|
16
|
-
|
|
17
|
-
esm: {
|
|
18
|
-
nodeResolve: true,
|
|
19
|
-
},
|
|
20
|
-
// you can overwrite/extend the config further
|
|
21
|
-
}),
|
|
22
|
-
);
|
|
23
|
-
return config;
|
|
24
|
-
};
|