@internetarchive/modal-manager 2.0.5-webdev-8155.8 → 2.0.5
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/.github/workflows/ci.yml +2 -2
- package/.vscode/extensions.json +2 -1
- package/demo/app-root.ts +15 -15
- package/dist/demo/app-root.d.ts +15 -15
- package/dist/demo/app-root.js.map +1 -1
- package/dist/src/modal-manager.js.map +1 -1
- package/dist/test/modal-config.test.js +4 -4
- package/dist/test/modal-config.test.js.map +1 -1
- package/dist/test/modal-manager.test.js +19 -19
- package/dist/test/modal-manager.test.js.map +1 -1
- package/dist/test/modal-template.test.js +15 -15
- package/dist/test/modal-template.test.js.map +1 -1
- package/dist/vitest.config.ci.js +1 -1
- package/dist/vitest.config.ci.js.map +1 -1
- package/eslint.config.mjs +7 -27
- package/package.json +9 -10
- package/src/modal-manager.ts +0 -1
- package/test/modal-config.test.ts +4 -4
- package/test/modal-manager.test.ts +19 -19
- package/test/modal-template.test.ts +15 -15
- package/tsconfig.json +4 -4
- package/vitest.config.ci.ts +2 -2
- package/.vscode/tasks.json +0 -12
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
nextFrame,
|
|
6
6
|
fixtureCleanup,
|
|
7
7
|
} from '@open-wc/testing-helpers';
|
|
8
|
-
import { describe,
|
|
8
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
9
9
|
import { TemplateResult, html } from 'lit';
|
|
10
10
|
|
|
11
11
|
import '../src/modal-manager';
|
|
@@ -21,7 +21,7 @@ describe('Modal Manager', () => {
|
|
|
21
21
|
fixtureCleanup();
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
it('defaults to closed', async () => {
|
|
25
25
|
const el = (await fixture(html`
|
|
26
26
|
<modal-manager></modal-manager>
|
|
27
27
|
`)) as ModalManager;
|
|
@@ -29,7 +29,7 @@ describe('Modal Manager', () => {
|
|
|
29
29
|
expect(el.mode).to.equal('closed');
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
it('can be closed by calling closeModal', async () => {
|
|
33
33
|
const el = (await fixture(html`
|
|
34
34
|
<modal-manager .mode=${ModalManagerMode.Open}></modal-manager>
|
|
35
35
|
`)) as ModalManager;
|
|
@@ -45,7 +45,7 @@ describe('Modal Manager', () => {
|
|
|
45
45
|
expect(el.customModalContent).to.equal(undefined);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
it('can be closed by clicking on the backdrop', async () => {
|
|
49
49
|
const el = (await fixture(html`
|
|
50
50
|
<modal-manager .mode=${ModalManagerMode.Open}></modal-manager>
|
|
51
51
|
`)) as ModalManager;
|
|
@@ -59,7 +59,7 @@ describe('Modal Manager', () => {
|
|
|
59
59
|
expect(el.mode).to.equal('closed');
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
it('emits a modeChanged event when opening', async () => {
|
|
63
63
|
const el = (await fixture(html`
|
|
64
64
|
<modal-manager></modal-manager>
|
|
65
65
|
`)) as ModalManager;
|
|
@@ -73,7 +73,7 @@ describe('Modal Manager', () => {
|
|
|
73
73
|
expect(response.detail.mode).to.equal(ModalManagerMode.Open);
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
it('emits a modeChanged event when closing', async () => {
|
|
77
77
|
const el = (await fixture(html`
|
|
78
78
|
<modal-manager></modal-manager>
|
|
79
79
|
`)) as ModalManager;
|
|
@@ -90,7 +90,7 @@ describe('Modal Manager', () => {
|
|
|
90
90
|
expect(response.detail.mode).to.equal(ModalManagerMode.Closed);
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
it('can show a modal', async () => {
|
|
94
94
|
const el = (await fixture(html`
|
|
95
95
|
<modal-manager></modal-manager>
|
|
96
96
|
`)) as ModalManager;
|
|
@@ -101,7 +101,7 @@ describe('Modal Manager', () => {
|
|
|
101
101
|
expect(el.mode).to.equal(ModalManagerMode.Open);
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
it('sets the --containerHeight CSS property when the window resizes', async () => {
|
|
105
105
|
const el = (await fixture(html`
|
|
106
106
|
<modal-manager></modal-manager>
|
|
107
107
|
`)) as ModalManager;
|
|
@@ -118,7 +118,7 @@ describe('Modal Manager', () => {
|
|
|
118
118
|
expect(propAfter).to.not.equal('');
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
it('calls the userClosedModalCallback when the user taps the backdrop', async () => {
|
|
122
122
|
const el = (await fixture(html`
|
|
123
123
|
<modal-manager></modal-manager>
|
|
124
124
|
`)) as ModalManager;
|
|
@@ -143,7 +143,7 @@ describe('Modal Manager', () => {
|
|
|
143
143
|
expect(callbackCalled).to.equal(true);
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
it('does not call the userClosedModalCallback when the modal just closes', async () => {
|
|
147
147
|
const el = (await fixture(html`
|
|
148
148
|
<modal-manager></modal-manager>
|
|
149
149
|
`)) as ModalManager;
|
|
@@ -163,7 +163,7 @@ describe('Modal Manager', () => {
|
|
|
163
163
|
expect(callbackCalled).to.equal(false);
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
it('calls the userPressedLeftNavButtonCallback when the user clicks the left nav button', async () => {
|
|
167
167
|
const el = (await fixture(html`
|
|
168
168
|
<modal-manager></modal-manager>
|
|
169
169
|
`)) as ModalManager;
|
|
@@ -191,7 +191,7 @@ describe('Modal Manager', () => {
|
|
|
191
191
|
expect(callbackCalled).to.equal(true);
|
|
192
192
|
});
|
|
193
193
|
|
|
194
|
-
|
|
194
|
+
it('mode is set to closed when close button is pressed', async () => {
|
|
195
195
|
const el = (await fixture(html`
|
|
196
196
|
<modal-manager></modal-manager>
|
|
197
197
|
`)) as ModalManager;
|
|
@@ -212,7 +212,7 @@ describe('Modal Manager', () => {
|
|
|
212
212
|
expect(el.mode).to.equal('closed');
|
|
213
213
|
});
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
it('mode is set to closed when close button gets spacebar pressed', async () => {
|
|
216
216
|
const el = (await fixture(html`
|
|
217
217
|
<modal-manager></modal-manager>
|
|
218
218
|
`)) as ModalManager;
|
|
@@ -235,7 +235,7 @@ describe('Modal Manager', () => {
|
|
|
235
235
|
expect(el.mode).to.equal('closed');
|
|
236
236
|
});
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
it('mode remains open when close button gets non-button keypress', async () => {
|
|
239
239
|
const el = (await fixture(html`
|
|
240
240
|
<modal-manager></modal-manager>
|
|
241
241
|
`)) as ModalManager;
|
|
@@ -258,7 +258,7 @@ describe('Modal Manager', () => {
|
|
|
258
258
|
expect(el.mode).to.equal('open');
|
|
259
259
|
});
|
|
260
260
|
|
|
261
|
-
|
|
261
|
+
it('allows the user to close by clicking on the backdrop if configured to', async () => {
|
|
262
262
|
const el = (await fixture(html`
|
|
263
263
|
<modal-manager></modal-manager>
|
|
264
264
|
`)) as ModalManager;
|
|
@@ -277,7 +277,7 @@ describe('Modal Manager', () => {
|
|
|
277
277
|
expect(el.mode).to.equal('closed');
|
|
278
278
|
});
|
|
279
279
|
|
|
280
|
-
|
|
280
|
+
it("doesn't allow the user to close by clicking on the backdrop if configured to", async () => {
|
|
281
281
|
const el = (await fixture(html`
|
|
282
282
|
<modal-manager></modal-manager>
|
|
283
283
|
`)) as ModalManagerInterface;
|
|
@@ -296,7 +296,7 @@ describe('Modal Manager', () => {
|
|
|
296
296
|
expect(el.getMode()).to.equal('open');
|
|
297
297
|
});
|
|
298
298
|
|
|
299
|
-
|
|
299
|
+
it('ia logo should not visible on modal', async () => {
|
|
300
300
|
const el = (await fixture(html`
|
|
301
301
|
<modal-manager></modal-manager>
|
|
302
302
|
`)) as ModalManagerInterface;
|
|
@@ -310,7 +310,7 @@ describe('Modal Manager', () => {
|
|
|
310
310
|
expect(logoIcon).to.not.exist;
|
|
311
311
|
});
|
|
312
312
|
|
|
313
|
-
|
|
313
|
+
it('should trap Tab key', async () => {
|
|
314
314
|
const el = (await fixture(html`
|
|
315
315
|
<modal-manager></modal-manager>
|
|
316
316
|
`)) as ModalManager;
|
|
@@ -358,7 +358,7 @@ describe('Modal Manager', () => {
|
|
|
358
358
|
expect(modal?.shadowRoot?.activeElement).to.equal(closeButton);
|
|
359
359
|
});
|
|
360
360
|
|
|
361
|
-
|
|
361
|
+
it('returns keyboard focus to the triggering element on close', async () => {
|
|
362
362
|
const config = new ModalConfig();
|
|
363
363
|
const el = (await fixture(html`
|
|
364
364
|
<div>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { fixture, oneEvent } from '@open-wc/testing-helpers';
|
|
2
|
-
import { describe,
|
|
2
|
+
import { describe, it, expect } from 'vitest';
|
|
3
3
|
import { html } from 'lit';
|
|
4
4
|
import '../src/modal-template';
|
|
5
5
|
import { ModalConfig } from '../src/modal-config';
|
|
6
6
|
import type { ModalTemplate } from '../src/modal-template';
|
|
7
7
|
|
|
8
8
|
describe('Modal Template', () => {
|
|
9
|
-
|
|
9
|
+
it('has correct default configuration', async () => {
|
|
10
10
|
const el = await fixture<ModalTemplate>(html`
|
|
11
11
|
<modal-template></modal-template>
|
|
12
12
|
`);
|
|
@@ -23,7 +23,7 @@ describe('Modal Template', () => {
|
|
|
23
23
|
expect('hidden' in processingLogo!.classList);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
it('does not show the title if one not provided', async () => {
|
|
27
27
|
const config = new ModalConfig();
|
|
28
28
|
config.title = undefined;
|
|
29
29
|
|
|
@@ -35,7 +35,7 @@ describe('Modal Template', () => {
|
|
|
35
35
|
expect(title).to.not.exist;
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
it('emits closeButtonPressed event when close button is pressed', async () => {
|
|
39
39
|
const el = await fixture<ModalTemplate>(html`
|
|
40
40
|
<modal-template></modal-template>
|
|
41
41
|
`);
|
|
@@ -49,7 +49,7 @@ describe('Modal Template', () => {
|
|
|
49
49
|
expect(response).to.exist;
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
it('emits closeButtonPressed event when close button gets spacebar pressed', async () => {
|
|
53
53
|
const el = await fixture<ModalTemplate>(html`
|
|
54
54
|
<modal-template></modal-template>
|
|
55
55
|
`);
|
|
@@ -64,7 +64,7 @@ describe('Modal Template', () => {
|
|
|
64
64
|
expect(response).to.exist;
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
it('emits leftNavButtonPressed event when left nav button is pressed', async () => {
|
|
68
68
|
const config = new ModalConfig();
|
|
69
69
|
config.showLeftNavButton = true;
|
|
70
70
|
const el = await fixture<ModalTemplate>(html`
|
|
@@ -81,7 +81,7 @@ describe('Modal Template', () => {
|
|
|
81
81
|
expect(response).to.exist;
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
it('emits leftNavButtonPressed event when left nav button gets spacebar pressed', async () => {
|
|
85
85
|
const config = new ModalConfig();
|
|
86
86
|
config.showLeftNavButton = true;
|
|
87
87
|
const el = await fixture<ModalTemplate>(html`
|
|
@@ -98,7 +98,7 @@ describe('Modal Template', () => {
|
|
|
98
98
|
expect(response).to.exist;
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
it('shows the processing indicator if configured to', async () => {
|
|
102
102
|
const config = new ModalConfig();
|
|
103
103
|
config.showProcessingIndicator = true;
|
|
104
104
|
|
|
@@ -111,7 +111,7 @@ describe('Modal Template', () => {
|
|
|
111
111
|
expect('hidden' in classList).to.equal(false);
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
it('shows the left nav button if configured to', async () => {
|
|
115
115
|
const config = new ModalConfig();
|
|
116
116
|
config.showLeftNavButton = true;
|
|
117
117
|
const el = await fixture<ModalTemplate>(html`
|
|
@@ -122,7 +122,7 @@ describe('Modal Template', () => {
|
|
|
122
122
|
expect(leftNavButton).to.exist;
|
|
123
123
|
});
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
it('hides the left nav button if configured to', async () => {
|
|
126
126
|
const config = new ModalConfig();
|
|
127
127
|
config.showCloseButton = false;
|
|
128
128
|
const el = await fixture<ModalTemplate>(html`
|
|
@@ -133,7 +133,7 @@ describe('Modal Template', () => {
|
|
|
133
133
|
expect(closeButton).to.not.exist;
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
it('uses custom text for the left nav button if configured to', async () => {
|
|
137
137
|
const config = new ModalConfig();
|
|
138
138
|
config.showLeftNavButton = true;
|
|
139
139
|
config.leftNavButtonText = 'Previous';
|
|
@@ -147,7 +147,7 @@ describe('Modal Template', () => {
|
|
|
147
147
|
expect(leftNavButton?.innerHTML).to.contain('Previous');
|
|
148
148
|
});
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
it('does not use any text for the left nav button if not configured to', async () => {
|
|
151
151
|
const config = new ModalConfig();
|
|
152
152
|
config.showLeftNavButton = true;
|
|
153
153
|
|
|
@@ -159,7 +159,7 @@ describe('Modal Template', () => {
|
|
|
159
159
|
expect(leftNavButton?.innerHTML).not.to.contain('Previous');
|
|
160
160
|
});
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
it('shows the close button if configured to', async () => {
|
|
163
163
|
const config = new ModalConfig();
|
|
164
164
|
config.showCloseButton = true;
|
|
165
165
|
const el = await fixture<ModalTemplate>(html`
|
|
@@ -170,7 +170,7 @@ describe('Modal Template', () => {
|
|
|
170
170
|
expect(closeButton).to.exist;
|
|
171
171
|
});
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
it('hides the close button if configured to', async () => {
|
|
174
174
|
const config = new ModalConfig();
|
|
175
175
|
config.showCloseButton = false;
|
|
176
176
|
const el = await fixture<ModalTemplate>(html`
|
|
@@ -181,7 +181,7 @@ describe('Modal Template', () => {
|
|
|
181
181
|
expect(closeButton).to.not.exist;
|
|
182
182
|
});
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
it('shows the properties from the config', async () => {
|
|
185
185
|
const config = new ModalConfig();
|
|
186
186
|
config.title = html`Boop`;
|
|
187
187
|
config.subtitle = html`Bop`;
|
package/tsconfig.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"module": "
|
|
3
|
+
"target": "es2022",
|
|
4
|
+
"module": "es2022",
|
|
5
5
|
"moduleResolution": "bundler",
|
|
6
6
|
"noEmitOnError": true,
|
|
7
7
|
"lib": [
|
|
8
|
-
"
|
|
8
|
+
"es2022",
|
|
9
9
|
"dom"
|
|
10
10
|
],
|
|
11
11
|
"strict": true,
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"declaration": true,
|
|
20
20
|
"rootDir": "./",
|
|
21
21
|
"skipLibCheck": true,
|
|
22
|
-
"useDefineForClassFields": false
|
|
22
|
+
"useDefineForClassFields": false
|
|
23
23
|
},
|
|
24
24
|
"include": ["**/*.ts"]
|
|
25
25
|
}
|
package/vitest.config.ci.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="vitest" />
|
|
2
2
|
import { defineConfig, mergeConfig } from 'vitest/config';
|
|
3
|
-
import { playwright } from '@vitest/browser-playwright'
|
|
3
|
+
import { playwright } from '@vitest/browser-playwright';
|
|
4
4
|
import viteConfig from './vite.config';
|
|
5
5
|
|
|
6
6
|
// https://vitest.dev/config
|
|
@@ -8,7 +8,7 @@ export default mergeConfig(
|
|
|
8
8
|
viteConfig,
|
|
9
9
|
defineConfig({
|
|
10
10
|
server: {
|
|
11
|
-
host: '
|
|
11
|
+
host: '127.0.0.1',
|
|
12
12
|
port: 8080,
|
|
13
13
|
},
|
|
14
14
|
test: {
|