@internetarchive/modal-manager 2.0.3 → 2.0.4-alpha-webdev7960.0
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/index.js.map +1 -1
- package/dist/src/assets/arrow-left-icon.d.ts +2 -2
- package/dist/src/assets/arrow-left-icon.js +14 -14
- package/dist/src/assets/arrow-left-icon.js.map +1 -1
- package/dist/src/assets/ia-logo-icon.d.ts +2 -2
- package/dist/src/assets/ia-logo-icon.js +29 -29
- package/dist/src/assets/ia-logo-icon.js.map +1 -1
- package/dist/src/modal-config.d.ts +104 -104
- package/dist/src/modal-config.js +24 -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-interface.js.map +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-interface.js.map +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-mode.js.map +1 -1
- package/dist/src/modal-manager.d.ts +137 -127
- package/dist/src/modal-manager.js +247 -234
- package/dist/src/modal-manager.js.map +1 -1
- package/dist/src/modal-template.d.ts +41 -41
- package/dist/src/modal-template.js +335 -335
- 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 +27 -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 +131 -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 +169 -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 +69 -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 +274 -274
- 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 +178 -178
- 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/vite.config.js.map +1 -1
- 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/index.ts +7 -7
- package/karma.conf.js +24 -24
- package/package.json +85 -85
- package/renovate.json +7 -7
- package/src/assets/arrow-left-icon.ts +15 -15
- package/src/assets/ia-logo-icon.ts +30 -30
- package/src/modal-config.ts +133 -133
- package/src/modal-manager-host-bridge-interface.ts +13 -13
- package/src/modal-manager-host-bridge.ts +82 -82
- package/src/modal-manager-interface.ts +30 -30
- package/src/modal-manager-mode.ts +10 -10
- package/src/modal-manager.ts +303 -283
- package/src/modal-template.ts +343 -343
- package/src/shoelace/LICENSE.md +6 -6
- package/src/shoelace/active-elements.ts +33 -33
- package/src/shoelace/modal.ts +166 -166
- package/src/shoelace/tabbable.ts +223 -223
- package/test/modal-config.test.ts +77 -77
- package/test/modal-manager.test.ts +347 -347
- package/test/modal-template.test.ts +206 -206
- package/tsconfig.json +21 -21
- package/vite.config.ts +23 -23
|
@@ -1,206 +1,206 @@
|
|
|
1
|
-
import { fixture, expect, oneEvent } from '@open-wc/testing';
|
|
2
|
-
import { html } from 'lit';
|
|
3
|
-
import '../src/modal-template';
|
|
4
|
-
import { ModalConfig } from '../src/modal-config';
|
|
5
|
-
|
|
6
|
-
describe('Modal Template', () => {
|
|
7
|
-
it('has correct default configuration', async () => {
|
|
8
|
-
const el = await fixture(html` <modal-template></modal-template> `);
|
|
9
|
-
|
|
10
|
-
const processingLogo = el.shadowRoot?.querySelector('.processing-logo');
|
|
11
|
-
const headline = el.shadowRoot?.querySelector('.headline');
|
|
12
|
-
const message = el.shadowRoot?.querySelector('.message');
|
|
13
|
-
const title = el.shadowRoot?.querySelector('h1.title') as HTMLElement;
|
|
14
|
-
|
|
15
|
-
expect(headline).to.not.exist;
|
|
16
|
-
expect(message).to.not.exist;
|
|
17
|
-
expect(title).to.not.exist;
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
19
|
-
expect('hidden' in processingLogo!.classList);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('does not show the title if one not provided', async () => {
|
|
23
|
-
const config = new ModalConfig();
|
|
24
|
-
config.title = undefined;
|
|
25
|
-
|
|
26
|
-
const el = await fixture(html`
|
|
27
|
-
<modal-template .config=${config}></modal-template>
|
|
28
|
-
`);
|
|
29
|
-
|
|
30
|
-
const title = el.shadowRoot?.querySelector('h1.title');
|
|
31
|
-
expect(title).to.not.exist;
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('emits closeButtonPressed event when close button is pressed', async () => {
|
|
35
|
-
const el = await fixture(html` <modal-template></modal-template> `);
|
|
36
|
-
|
|
37
|
-
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
38
|
-
const clickEvent = new MouseEvent('click');
|
|
39
|
-
|
|
40
|
-
setTimeout(() => {
|
|
41
|
-
closeButton?.dispatchEvent(clickEvent);
|
|
42
|
-
});
|
|
43
|
-
const response = await oneEvent(el, 'closeButtonPressed', false);
|
|
44
|
-
expect(response).to.exist;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('emits closeButtonPressed event when close button gets spacebar pressed', async () => {
|
|
48
|
-
const el = await fixture(html` <modal-template></modal-template> `);
|
|
49
|
-
|
|
50
|
-
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
51
|
-
const clickEvent = new KeyboardEvent('keydown', { key: ' ' });
|
|
52
|
-
|
|
53
|
-
setTimeout(() => {
|
|
54
|
-
closeButton?.dispatchEvent(clickEvent);
|
|
55
|
-
});
|
|
56
|
-
const response = await oneEvent(el, 'closeButtonPressed', false);
|
|
57
|
-
expect(response).to.exist;
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('emits leftNavButtonPressed event when left nav button is pressed', async () => {
|
|
61
|
-
const config = new ModalConfig();
|
|
62
|
-
config.showLeftNavButton = true;
|
|
63
|
-
const el = await fixture(html`
|
|
64
|
-
<modal-template .config=${config}></modal-template>
|
|
65
|
-
`);
|
|
66
|
-
|
|
67
|
-
const leftNavButton = el.shadowRoot?.querySelector('.back-button');
|
|
68
|
-
const clickEvent = new MouseEvent('click');
|
|
69
|
-
|
|
70
|
-
setTimeout(() => {
|
|
71
|
-
leftNavButton?.dispatchEvent(clickEvent);
|
|
72
|
-
});
|
|
73
|
-
const response = await oneEvent(el, 'leftNavButtonPressed', false);
|
|
74
|
-
expect(response).to.exist;
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('emits leftNavButtonPressed event when left nav button gets spacebar pressed', async () => {
|
|
78
|
-
const config = new ModalConfig();
|
|
79
|
-
config.showLeftNavButton = true;
|
|
80
|
-
const el = await fixture(html`
|
|
81
|
-
<modal-template .config=${config}></modal-template>
|
|
82
|
-
`);
|
|
83
|
-
|
|
84
|
-
const leftNavButton = el.shadowRoot?.querySelector('.back-button');
|
|
85
|
-
const clickEvent = new KeyboardEvent('keydown', { key: ' ' });
|
|
86
|
-
|
|
87
|
-
setTimeout(() => {
|
|
88
|
-
leftNavButton?.dispatchEvent(clickEvent);
|
|
89
|
-
});
|
|
90
|
-
const response = await oneEvent(el, 'leftNavButtonPressed', false);
|
|
91
|
-
expect(response).to.exist;
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('shows the processing indicator if configured to', async () => {
|
|
95
|
-
const config = new ModalConfig();
|
|
96
|
-
config.showProcessingIndicator = true;
|
|
97
|
-
|
|
98
|
-
const el = await fixture(html`
|
|
99
|
-
<modal-template .config=${config}></modal-template>
|
|
100
|
-
`);
|
|
101
|
-
|
|
102
|
-
const processingLogo = el.shadowRoot?.querySelector('.processing-logo');
|
|
103
|
-
const classList = processingLogo?.classList ?? [];
|
|
104
|
-
expect('hidden' in classList).to.equal(false);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('shows the left nav button if configured to', async () => {
|
|
108
|
-
const config = new ModalConfig();
|
|
109
|
-
config.showLeftNavButton = true;
|
|
110
|
-
const el = await fixture(html`
|
|
111
|
-
<modal-template .config=${config}></modal-template>
|
|
112
|
-
`);
|
|
113
|
-
|
|
114
|
-
const leftNavButton = el.shadowRoot?.querySelector('.back-button');
|
|
115
|
-
expect(leftNavButton).to.exist;
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('hides the left nav button if configured to', async () => {
|
|
119
|
-
const config = new ModalConfig();
|
|
120
|
-
config.showCloseButton = false;
|
|
121
|
-
const el = await fixture(html`
|
|
122
|
-
<modal-template .config=${config}></modal-template>
|
|
123
|
-
`);
|
|
124
|
-
|
|
125
|
-
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
126
|
-
expect(closeButton).to.not.exist;
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('uses custom text for the left nav button if configured to', async () => {
|
|
130
|
-
const config = new ModalConfig();
|
|
131
|
-
config.showLeftNavButton = true;
|
|
132
|
-
config.leftNavButtonText = 'Previous';
|
|
133
|
-
const el = await fixture(html`
|
|
134
|
-
<modal-template .config=${config}></modal-template>
|
|
135
|
-
`);
|
|
136
|
-
|
|
137
|
-
const leftNavButton = el.shadowRoot?.querySelector('.back-button');
|
|
138
|
-
|
|
139
|
-
expect(leftNavButton).to.exist;
|
|
140
|
-
expect(leftNavButton?.innerHTML).to.contain('Previous');
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('does not use any text for the left nav button if not configured to', async () => {
|
|
144
|
-
const config = new ModalConfig();
|
|
145
|
-
config.showLeftNavButton = true;
|
|
146
|
-
|
|
147
|
-
const el = await fixture(html`
|
|
148
|
-
<modal-template .config=${config}></modal-template>
|
|
149
|
-
`);
|
|
150
|
-
|
|
151
|
-
const leftNavButton = el.shadowRoot?.querySelector('.back-button');
|
|
152
|
-
expect(leftNavButton?.innerHTML).not.to.contain('Previous');
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it('shows the close button if configured to', async () => {
|
|
156
|
-
const config = new ModalConfig();
|
|
157
|
-
config.showCloseButton = true;
|
|
158
|
-
const el = await fixture(html`
|
|
159
|
-
<modal-template .config=${config}></modal-template>
|
|
160
|
-
`);
|
|
161
|
-
|
|
162
|
-
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
163
|
-
expect(closeButton).to.exist;
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('hides the close button if configured to', async () => {
|
|
167
|
-
const config = new ModalConfig();
|
|
168
|
-
config.showCloseButton = false;
|
|
169
|
-
const el = await fixture(html`
|
|
170
|
-
<modal-template .config=${config}></modal-template>
|
|
171
|
-
`);
|
|
172
|
-
|
|
173
|
-
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
174
|
-
expect(closeButton).to.not.exist;
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('shows the properties from the config', async () => {
|
|
178
|
-
const config = new ModalConfig();
|
|
179
|
-
config.title = html`Boop`;
|
|
180
|
-
config.subtitle = html`Bop`;
|
|
181
|
-
config.headline = html`Foo`;
|
|
182
|
-
config.message = html`Bar`;
|
|
183
|
-
|
|
184
|
-
const el = await fixture(html`
|
|
185
|
-
<modal-template .config=${config}></modal-template>
|
|
186
|
-
`);
|
|
187
|
-
|
|
188
|
-
const title = el.shadowRoot?.querySelector('h1');
|
|
189
|
-
const subtitle = el.shadowRoot?.querySelector('h2');
|
|
190
|
-
|
|
191
|
-
const headline = el.shadowRoot?.querySelector('.headline');
|
|
192
|
-
const message = el.shadowRoot?.querySelector('.message');
|
|
193
|
-
|
|
194
|
-
expect(title).to.exist;
|
|
195
|
-
expect(title?.innerText).to.equal('Boop');
|
|
196
|
-
|
|
197
|
-
expect(subtitle).to.exist;
|
|
198
|
-
expect(subtitle?.innerText).to.equal('Bop');
|
|
199
|
-
|
|
200
|
-
expect(headline).to.exist;
|
|
201
|
-
expect(headline?.textContent).to.equal('Foo');
|
|
202
|
-
|
|
203
|
-
expect(message).to.exist;
|
|
204
|
-
expect(message?.textContent).to.equal('Bar');
|
|
205
|
-
});
|
|
206
|
-
});
|
|
1
|
+
import { fixture, expect, oneEvent } from '@open-wc/testing';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import '../src/modal-template';
|
|
4
|
+
import { ModalConfig } from '../src/modal-config';
|
|
5
|
+
|
|
6
|
+
describe('Modal Template', () => {
|
|
7
|
+
it('has correct default configuration', async () => {
|
|
8
|
+
const el = await fixture(html` <modal-template></modal-template> `);
|
|
9
|
+
|
|
10
|
+
const processingLogo = el.shadowRoot?.querySelector('.processing-logo');
|
|
11
|
+
const headline = el.shadowRoot?.querySelector('.headline');
|
|
12
|
+
const message = el.shadowRoot?.querySelector('.message');
|
|
13
|
+
const title = el.shadowRoot?.querySelector('h1.title') as HTMLElement;
|
|
14
|
+
|
|
15
|
+
expect(headline).to.not.exist;
|
|
16
|
+
expect(message).to.not.exist;
|
|
17
|
+
expect(title).to.not.exist;
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
19
|
+
expect('hidden' in processingLogo!.classList);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('does not show the title if one not provided', async () => {
|
|
23
|
+
const config = new ModalConfig();
|
|
24
|
+
config.title = undefined;
|
|
25
|
+
|
|
26
|
+
const el = await fixture(html`
|
|
27
|
+
<modal-template .config=${config}></modal-template>
|
|
28
|
+
`);
|
|
29
|
+
|
|
30
|
+
const title = el.shadowRoot?.querySelector('h1.title');
|
|
31
|
+
expect(title).to.not.exist;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('emits closeButtonPressed event when close button is pressed', async () => {
|
|
35
|
+
const el = await fixture(html` <modal-template></modal-template> `);
|
|
36
|
+
|
|
37
|
+
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
38
|
+
const clickEvent = new MouseEvent('click');
|
|
39
|
+
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
closeButton?.dispatchEvent(clickEvent);
|
|
42
|
+
});
|
|
43
|
+
const response = await oneEvent(el, 'closeButtonPressed', false);
|
|
44
|
+
expect(response).to.exist;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('emits closeButtonPressed event when close button gets spacebar pressed', async () => {
|
|
48
|
+
const el = await fixture(html` <modal-template></modal-template> `);
|
|
49
|
+
|
|
50
|
+
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
51
|
+
const clickEvent = new KeyboardEvent('keydown', { key: ' ' });
|
|
52
|
+
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
closeButton?.dispatchEvent(clickEvent);
|
|
55
|
+
});
|
|
56
|
+
const response = await oneEvent(el, 'closeButtonPressed', false);
|
|
57
|
+
expect(response).to.exist;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('emits leftNavButtonPressed event when left nav button is pressed', async () => {
|
|
61
|
+
const config = new ModalConfig();
|
|
62
|
+
config.showLeftNavButton = true;
|
|
63
|
+
const el = await fixture(html`
|
|
64
|
+
<modal-template .config=${config}></modal-template>
|
|
65
|
+
`);
|
|
66
|
+
|
|
67
|
+
const leftNavButton = el.shadowRoot?.querySelector('.back-button');
|
|
68
|
+
const clickEvent = new MouseEvent('click');
|
|
69
|
+
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
leftNavButton?.dispatchEvent(clickEvent);
|
|
72
|
+
});
|
|
73
|
+
const response = await oneEvent(el, 'leftNavButtonPressed', false);
|
|
74
|
+
expect(response).to.exist;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('emits leftNavButtonPressed event when left nav button gets spacebar pressed', async () => {
|
|
78
|
+
const config = new ModalConfig();
|
|
79
|
+
config.showLeftNavButton = true;
|
|
80
|
+
const el = await fixture(html`
|
|
81
|
+
<modal-template .config=${config}></modal-template>
|
|
82
|
+
`);
|
|
83
|
+
|
|
84
|
+
const leftNavButton = el.shadowRoot?.querySelector('.back-button');
|
|
85
|
+
const clickEvent = new KeyboardEvent('keydown', { key: ' ' });
|
|
86
|
+
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
leftNavButton?.dispatchEvent(clickEvent);
|
|
89
|
+
});
|
|
90
|
+
const response = await oneEvent(el, 'leftNavButtonPressed', false);
|
|
91
|
+
expect(response).to.exist;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('shows the processing indicator if configured to', async () => {
|
|
95
|
+
const config = new ModalConfig();
|
|
96
|
+
config.showProcessingIndicator = true;
|
|
97
|
+
|
|
98
|
+
const el = await fixture(html`
|
|
99
|
+
<modal-template .config=${config}></modal-template>
|
|
100
|
+
`);
|
|
101
|
+
|
|
102
|
+
const processingLogo = el.shadowRoot?.querySelector('.processing-logo');
|
|
103
|
+
const classList = processingLogo?.classList ?? [];
|
|
104
|
+
expect('hidden' in classList).to.equal(false);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('shows the left nav button if configured to', async () => {
|
|
108
|
+
const config = new ModalConfig();
|
|
109
|
+
config.showLeftNavButton = true;
|
|
110
|
+
const el = await fixture(html`
|
|
111
|
+
<modal-template .config=${config}></modal-template>
|
|
112
|
+
`);
|
|
113
|
+
|
|
114
|
+
const leftNavButton = el.shadowRoot?.querySelector('.back-button');
|
|
115
|
+
expect(leftNavButton).to.exist;
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('hides the left nav button if configured to', async () => {
|
|
119
|
+
const config = new ModalConfig();
|
|
120
|
+
config.showCloseButton = false;
|
|
121
|
+
const el = await fixture(html`
|
|
122
|
+
<modal-template .config=${config}></modal-template>
|
|
123
|
+
`);
|
|
124
|
+
|
|
125
|
+
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
126
|
+
expect(closeButton).to.not.exist;
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('uses custom text for the left nav button if configured to', async () => {
|
|
130
|
+
const config = new ModalConfig();
|
|
131
|
+
config.showLeftNavButton = true;
|
|
132
|
+
config.leftNavButtonText = 'Previous';
|
|
133
|
+
const el = await fixture(html`
|
|
134
|
+
<modal-template .config=${config}></modal-template>
|
|
135
|
+
`);
|
|
136
|
+
|
|
137
|
+
const leftNavButton = el.shadowRoot?.querySelector('.back-button');
|
|
138
|
+
|
|
139
|
+
expect(leftNavButton).to.exist;
|
|
140
|
+
expect(leftNavButton?.innerHTML).to.contain('Previous');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('does not use any text for the left nav button if not configured to', async () => {
|
|
144
|
+
const config = new ModalConfig();
|
|
145
|
+
config.showLeftNavButton = true;
|
|
146
|
+
|
|
147
|
+
const el = await fixture(html`
|
|
148
|
+
<modal-template .config=${config}></modal-template>
|
|
149
|
+
`);
|
|
150
|
+
|
|
151
|
+
const leftNavButton = el.shadowRoot?.querySelector('.back-button');
|
|
152
|
+
expect(leftNavButton?.innerHTML).not.to.contain('Previous');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('shows the close button if configured to', async () => {
|
|
156
|
+
const config = new ModalConfig();
|
|
157
|
+
config.showCloseButton = true;
|
|
158
|
+
const el = await fixture(html`
|
|
159
|
+
<modal-template .config=${config}></modal-template>
|
|
160
|
+
`);
|
|
161
|
+
|
|
162
|
+
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
163
|
+
expect(closeButton).to.exist;
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('hides the close button if configured to', async () => {
|
|
167
|
+
const config = new ModalConfig();
|
|
168
|
+
config.showCloseButton = false;
|
|
169
|
+
const el = await fixture(html`
|
|
170
|
+
<modal-template .config=${config}></modal-template>
|
|
171
|
+
`);
|
|
172
|
+
|
|
173
|
+
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
174
|
+
expect(closeButton).to.not.exist;
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('shows the properties from the config', async () => {
|
|
178
|
+
const config = new ModalConfig();
|
|
179
|
+
config.title = html`Boop`;
|
|
180
|
+
config.subtitle = html`Bop`;
|
|
181
|
+
config.headline = html`Foo`;
|
|
182
|
+
config.message = html`Bar`;
|
|
183
|
+
|
|
184
|
+
const el = await fixture(html`
|
|
185
|
+
<modal-template .config=${config}></modal-template>
|
|
186
|
+
`);
|
|
187
|
+
|
|
188
|
+
const title = el.shadowRoot?.querySelector('h1');
|
|
189
|
+
const subtitle = el.shadowRoot?.querySelector('h2');
|
|
190
|
+
|
|
191
|
+
const headline = el.shadowRoot?.querySelector('.headline');
|
|
192
|
+
const message = el.shadowRoot?.querySelector('.message');
|
|
193
|
+
|
|
194
|
+
expect(title).to.exist;
|
|
195
|
+
expect(title?.innerText).to.equal('Boop');
|
|
196
|
+
|
|
197
|
+
expect(subtitle).to.exist;
|
|
198
|
+
expect(subtitle?.innerText).to.equal('Bop');
|
|
199
|
+
|
|
200
|
+
expect(headline).to.exist;
|
|
201
|
+
expect(headline?.textContent).to.equal('Foo');
|
|
202
|
+
|
|
203
|
+
expect(message).to.exist;
|
|
204
|
+
expect(message?.textContent).to.equal('Bar');
|
|
205
|
+
});
|
|
206
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es6",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"noEmitOnError": true,
|
|
7
|
-
"lib": ["es2017", "dom"],
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": false,
|
|
10
|
-
"allowSyntheticDefaultImports": true,
|
|
11
|
-
"experimentalDecorators": true,
|
|
12
|
-
"importHelpers": true,
|
|
13
|
-
"outDir": "dist",
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"inlineSources": true,
|
|
16
|
-
"declaration": true,
|
|
17
|
-
"rootDir": "./",
|
|
18
|
-
"skipLibCheck": true
|
|
19
|
-
},
|
|
20
|
-
"include": ["**/*.ts"]
|
|
21
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es6",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"noEmitOnError": true,
|
|
7
|
+
"lib": ["es2017", "dom"],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": false,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"importHelpers": true,
|
|
13
|
+
"outDir": "dist",
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"inlineSources": true,
|
|
16
|
+
"declaration": true,
|
|
17
|
+
"rootDir": "./",
|
|
18
|
+
"skipLibCheck": true
|
|
19
|
+
},
|
|
20
|
+
"include": ["**/*.ts"]
|
|
21
|
+
}
|
package/vite.config.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import { resolve } from 'path';
|
|
3
|
-
|
|
4
|
-
// https://vitejs.dev/config/
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
base: '',
|
|
7
|
-
assetsInclude: ['**/*.jpg'],
|
|
8
|
-
build: {
|
|
9
|
-
outDir: 'ghpages',
|
|
10
|
-
manifest: true,
|
|
11
|
-
rollupOptions: {
|
|
12
|
-
input: {
|
|
13
|
-
main: resolve(__dirname, 'index.html'),
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
server: {
|
|
18
|
-
host: true,
|
|
19
|
-
port: 8080,
|
|
20
|
-
open: true,
|
|
21
|
-
cors: true,
|
|
22
|
-
},
|
|
23
|
-
});
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
|
|
4
|
+
// https://vitejs.dev/config/
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
base: '',
|
|
7
|
+
assetsInclude: ['**/*.jpg'],
|
|
8
|
+
build: {
|
|
9
|
+
outDir: 'ghpages',
|
|
10
|
+
manifest: true,
|
|
11
|
+
rollupOptions: {
|
|
12
|
+
input: {
|
|
13
|
+
main: resolve(__dirname, 'index.html'),
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
server: {
|
|
18
|
+
host: true,
|
|
19
|
+
port: 8080,
|
|
20
|
+
open: true,
|
|
21
|
+
cors: true,
|
|
22
|
+
},
|
|
23
|
+
});
|