@internetarchive/modal-manager 0.2.8 → 0.2.9-alpha.2

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.
Files changed (73) hide show
  1. package/.editorconfig +29 -29
  2. package/.eslintrc.js +14 -14
  3. package/.github/workflows/ci.yml +26 -26
  4. package/LICENSE +661 -661
  5. package/README.md +139 -139
  6. package/custom-elements.json +170 -170
  7. package/demo/index.html +278 -278
  8. package/dist/index.d.ts +7 -7
  9. package/dist/index.js +5 -5
  10. package/dist/index.js.map +1 -1
  11. package/dist/src/modal-config.d.ts +92 -92
  12. package/dist/src/modal-config.js +22 -22
  13. package/dist/src/modal-config.js.map +1 -1
  14. package/dist/src/modal-manager-host-bridge-interface.d.ts +12 -12
  15. package/dist/src/modal-manager-host-bridge-interface.js.map +1 -1
  16. package/dist/src/modal-manager-host-bridge.d.ts +34 -34
  17. package/dist/src/modal-manager-host-bridge.js +62 -62
  18. package/dist/src/modal-manager-host-bridge.js.map +1 -1
  19. package/dist/src/modal-manager-interface.d.ts +25 -25
  20. package/dist/src/modal-manager-interface.js.map +1 -1
  21. package/dist/src/modal-manager-mode.d.ts +10 -10
  22. package/dist/src/modal-manager-mode.js +11 -11
  23. package/dist/src/modal-manager-mode.js.map +1 -1
  24. package/dist/src/modal-manager.d.ts +108 -108
  25. package/dist/src/modal-manager.js +189 -189
  26. package/dist/src/modal-manager.js.map +1 -1
  27. package/dist/src/modal-template.d.ts +32 -32
  28. package/dist/src/modal-template.js +276 -276
  29. package/dist/src/modal-template.js.map +1 -1
  30. package/dist/test/modal-config.test.d.ts +1 -1
  31. package/dist/test/modal-config.test.js +61 -61
  32. package/dist/test/modal-config.test.js.map +1 -1
  33. package/dist/test/modal-manager.test.d.ts +1 -1
  34. package/dist/test/modal-manager.test.js +200 -200
  35. package/dist/test/modal-manager.test.js.map +1 -1
  36. package/dist/test/modal-template.test.d.ts +1 -1
  37. package/dist/test/modal-template.test.js +95 -95
  38. package/dist/test/modal-template.test.js.map +1 -1
  39. package/docs/assets/css/main.css +2678 -2678
  40. package/docs/classes/_src_modal_config_.modalconfig.html +429 -429
  41. package/docs/classes/_src_modal_manager_.modalmanager.html +7702 -7702
  42. package/docs/classes/_src_modal_manager_host_bridge_.modalmanagerhostbridge.html +409 -409
  43. package/docs/classes/_src_modal_template_.modaltemplate.html +7096 -7096
  44. package/docs/enums/_src_modal_manager_mode_.modalmanagermode.html +196 -196
  45. package/docs/globals.html +150 -150
  46. package/docs/index.html +252 -252
  47. package/docs/interfaces/_src_modal_manager_host_bridge_interface_.modalmanagerhostbridgeinterface.html +210 -210
  48. package/docs/interfaces/_src_modal_manager_interface_.modalmanagerinterface.html +7095 -7095
  49. package/docs/modules/_index_.html +208 -208
  50. package/docs/modules/_src_modal_config_.html +146 -146
  51. package/docs/modules/_src_modal_manager_.html +146 -146
  52. package/docs/modules/_src_modal_manager_host_bridge_.html +146 -146
  53. package/docs/modules/_src_modal_manager_host_bridge_interface_.html +146 -146
  54. package/docs/modules/_src_modal_manager_interface_.html +146 -146
  55. package/docs/modules/_src_modal_manager_mode_.html +146 -146
  56. package/docs/modules/_src_modal_template_.html +146 -146
  57. package/docs/modules/_test_modal_config_test_.html +106 -106
  58. package/docs/modules/_test_modal_manager_test_.html +106 -106
  59. package/docs/modules/_test_modal_template_test_.html +106 -106
  60. package/index.ts +7 -7
  61. package/karma.conf.js +24 -24
  62. package/package.json +82 -82
  63. package/src/modal-config.ts +117 -117
  64. package/src/modal-manager-host-bridge-interface.ts +13 -13
  65. package/src/modal-manager-host-bridge.ts +82 -82
  66. package/src/modal-manager-interface.ts +28 -28
  67. package/src/modal-manager-mode.ts +10 -10
  68. package/src/modal-manager.ts +228 -228
  69. package/src/modal-template.ts +279 -279
  70. package/test/modal-config.test.ts +69 -69
  71. package/test/modal-manager.test.ts +245 -245
  72. package/test/modal-template.test.ts +111 -111
  73. package/tsconfig.json +20 -20
@@ -1,69 +1,69 @@
1
- import { expect } from '@open-wc/testing';
2
- import { html } from 'lit';
3
-
4
- import { ModalConfig } from '../src/modal-config';
5
-
6
- describe('Modal Config', () => {
7
- it('can be instantiated properly', async () => {
8
- const config = new ModalConfig();
9
- const title = html`Foo`;
10
- config.title = title;
11
- config.headerColor = 'green';
12
-
13
- expect(config.title).to.equal(title);
14
- expect(config.headerColor).to.equal('green');
15
- });
16
-
17
- it('can be instantiated properly with constructor', async () => {
18
- const title = html`Foo`;
19
- const subtitle = html`Bar`;
20
- const headline = html`Baz`;
21
- const message = html`Boop`;
22
-
23
- const headerColor = 'blue';
24
- const showProcessingIndicator = true;
25
- const processingImageMode = 'processing';
26
- const showCloseButton = false;
27
- const showHeaderLogo = false;
28
- const closeOnBackdropClick = false;
29
-
30
- const config = new ModalConfig({
31
- title: title,
32
- subtitle: subtitle,
33
- headline: headline,
34
- message: message,
35
- headerColor: headerColor,
36
- showProcessingIndicator: showProcessingIndicator,
37
- processingImageMode: processingImageMode,
38
- showCloseButton: showCloseButton,
39
- showHeaderLogo: showHeaderLogo,
40
- closeOnBackdropClick: closeOnBackdropClick,
41
- });
42
-
43
- expect(config.title).to.equal(title);
44
- expect(config.subtitle).to.equal(subtitle);
45
- expect(config.headline).to.equal(headline);
46
- expect(config.message).to.equal(message);
47
-
48
- expect(config.headerColor).to.equal(headerColor);
49
- expect(config.showProcessingIndicator).to.equal(showProcessingIndicator);
50
- expect(config.processingImageMode).to.equal(processingImageMode);
51
- expect(config.showCloseButton).to.equal(showCloseButton);
52
- expect(config.showHeaderLogo).to.equal(showHeaderLogo);
53
- expect(config.closeOnBackdropClick).to.equal(closeOnBackdropClick);
54
- });
55
-
56
- it('instantiates properly with defaults', async () => {
57
- const config = new ModalConfig();
58
- expect(config.title).to.equal(undefined);
59
- expect(config.subtitle).to.equal(undefined);
60
- expect(config.headline).to.equal(undefined);
61
- expect(config.message).to.equal(undefined);
62
- expect(config.headerColor).to.equal('#55A183');
63
- expect(config.showProcessingIndicator).to.equal(false);
64
- expect(config.processingImageMode).to.equal('complete');
65
- expect(config.showCloseButton).to.equal(true);
66
- expect(config.showHeaderLogo).to.equal(true);
67
- expect(config.closeOnBackdropClick).to.equal(true);
68
- });
69
- });
1
+ import { expect } from '@open-wc/testing';
2
+ import { html } from 'lit';
3
+
4
+ import { ModalConfig } from '../src/modal-config';
5
+
6
+ describe('Modal Config', () => {
7
+ it('can be instantiated properly', async () => {
8
+ const config = new ModalConfig();
9
+ const title = html`Foo`;
10
+ config.title = title;
11
+ config.headerColor = 'green';
12
+
13
+ expect(config.title).to.equal(title);
14
+ expect(config.headerColor).to.equal('green');
15
+ });
16
+
17
+ it('can be instantiated properly with constructor', async () => {
18
+ const title = html`Foo`;
19
+ const subtitle = html`Bar`;
20
+ const headline = html`Baz`;
21
+ const message = html`Boop`;
22
+
23
+ const headerColor = 'blue';
24
+ const showProcessingIndicator = true;
25
+ const processingImageMode = 'processing';
26
+ const showCloseButton = false;
27
+ const showHeaderLogo = false;
28
+ const closeOnBackdropClick = false;
29
+
30
+ const config = new ModalConfig({
31
+ title: title,
32
+ subtitle: subtitle,
33
+ headline: headline,
34
+ message: message,
35
+ headerColor: headerColor,
36
+ showProcessingIndicator: showProcessingIndicator,
37
+ processingImageMode: processingImageMode,
38
+ showCloseButton: showCloseButton,
39
+ showHeaderLogo: showHeaderLogo,
40
+ closeOnBackdropClick: closeOnBackdropClick,
41
+ });
42
+
43
+ expect(config.title).to.equal(title);
44
+ expect(config.subtitle).to.equal(subtitle);
45
+ expect(config.headline).to.equal(headline);
46
+ expect(config.message).to.equal(message);
47
+
48
+ expect(config.headerColor).to.equal(headerColor);
49
+ expect(config.showProcessingIndicator).to.equal(showProcessingIndicator);
50
+ expect(config.processingImageMode).to.equal(processingImageMode);
51
+ expect(config.showCloseButton).to.equal(showCloseButton);
52
+ expect(config.showHeaderLogo).to.equal(showHeaderLogo);
53
+ expect(config.closeOnBackdropClick).to.equal(closeOnBackdropClick);
54
+ });
55
+
56
+ it('instantiates properly with defaults', async () => {
57
+ const config = new ModalConfig();
58
+ expect(config.title).to.equal(undefined);
59
+ expect(config.subtitle).to.equal(undefined);
60
+ expect(config.headline).to.equal(undefined);
61
+ expect(config.message).to.equal(undefined);
62
+ expect(config.headerColor).to.equal('#55A183');
63
+ expect(config.showProcessingIndicator).to.equal(false);
64
+ expect(config.processingImageMode).to.equal('complete');
65
+ expect(config.showCloseButton).to.equal(true);
66
+ expect(config.showHeaderLogo).to.equal(true);
67
+ expect(config.closeOnBackdropClick).to.equal(true);
68
+ });
69
+ });
@@ -1,245 +1,245 @@
1
- import { fixture, expect, oneEvent, elementUpdated } from '@open-wc/testing';
2
- import { html } from 'lit';
3
-
4
- import '../src/modal-manager';
5
- import { ModalConfig } from '../src/modal-config';
6
- import { ModalManager } from '../src/modal-manager';
7
- import { ModalManagerMode } from '../src/modal-manager-mode';
8
- import { ModalManagerInterface } from '../src/modal-manager-interface';
9
-
10
- describe('Modal Manager', () => {
11
- it('defaults to closed', async () => {
12
- const el = (await fixture(html`
13
- <modal-manager></modal-manager>
14
- `)) as ModalManager;
15
-
16
- expect(el.mode).to.equal('closed');
17
- });
18
-
19
- it('can be closed by calling closeModal', async () => {
20
- const el = (await fixture(html`
21
- <modal-manager .mode=${ModalManagerMode.Open}></modal-manager>
22
- `)) as ModalManager;
23
-
24
- el.closeModal();
25
- await elementUpdated(el);
26
-
27
- expect(el.mode).to.equal('closed');
28
- });
29
-
30
- it('can be closed by clicking on the backdrop', async () => {
31
- const el = (await fixture(html`
32
- <modal-manager .mode=${ModalManagerMode.Open}></modal-manager>
33
- `)) as ModalManager;
34
-
35
- const backdrop = el.shadowRoot?.querySelector('.backdrop');
36
- const clickEvent = new MouseEvent('click');
37
-
38
- backdrop?.dispatchEvent(clickEvent);
39
- await elementUpdated(el);
40
-
41
- expect(el.mode).to.equal('closed');
42
- });
43
-
44
- it('emits a modeChanged event when opening', async () => {
45
- const el = (await fixture(html`
46
- <modal-manager></modal-manager>
47
- `)) as ModalManager;
48
-
49
- const config = new ModalConfig();
50
-
51
- setTimeout(() => {
52
- el.showModal({ config });
53
- });
54
- const response = await oneEvent(el, 'modeChanged');
55
- expect(response.detail.mode).to.equal(ModalManagerMode.Open);
56
- });
57
-
58
- it('emits a modeChanged event when closing', async () => {
59
- const el = (await fixture(html`
60
- <modal-manager></modal-manager>
61
- `)) as ModalManager;
62
-
63
- const config = new ModalConfig();
64
- el.showModal({ config });
65
- await elementUpdated(el);
66
-
67
- setTimeout(() => {
68
- el.closeModal();
69
- });
70
- const response = await oneEvent(el, 'modeChanged');
71
- expect(response.detail.mode).to.equal(ModalManagerMode.Closed);
72
- });
73
-
74
- it('can show a modal', async () => {
75
- const el = (await fixture(html`
76
- <modal-manager></modal-manager>
77
- `)) as ModalManager;
78
-
79
- const config = new ModalConfig();
80
- el.showModal({ config });
81
- await elementUpdated(el);
82
- expect(el.mode).to.equal(ModalManagerMode.Open);
83
- });
84
-
85
- it('sets the --containerHeight CSS property when the window resizes', async () => {
86
- const el = (await fixture(html`
87
- <modal-manager></modal-manager>
88
- `)) as ModalManager;
89
-
90
- const config = new ModalConfig();
91
- el.showModal({ config });
92
- await elementUpdated(el);
93
- const event = new Event('resize');
94
- const propBefore = el.style.getPropertyValue('--containerHeight');
95
- expect(propBefore).to.equal('');
96
- window.dispatchEvent(event);
97
- await elementUpdated(el);
98
- const propAfter = el.style.getPropertyValue('--containerHeight');
99
- expect(propAfter).to.not.equal('');
100
- });
101
-
102
- it('calls the userClosedModalCallback when the user taps the backdrop', async () => {
103
- const el = (await fixture(html`
104
- <modal-manager></modal-manager>
105
- `)) as ModalManager;
106
-
107
- const config = new ModalConfig();
108
- let callbackCalled = false;
109
- const callback = (): void => {
110
- callbackCalled = true;
111
- };
112
- el.showModal({
113
- config,
114
- userClosedModalCallback: callback,
115
- });
116
- await elementUpdated(el);
117
-
118
- const backdrop = el.shadowRoot?.querySelector('.backdrop');
119
- const clickEvent = new MouseEvent('click');
120
- backdrop?.dispatchEvent(clickEvent);
121
-
122
- await elementUpdated(el);
123
-
124
- expect(callbackCalled).to.equal(true);
125
- });
126
-
127
- it('does not call the userClosedModalCallback when the modal just closes', async () => {
128
- const el = (await fixture(html`
129
- <modal-manager></modal-manager>
130
- `)) as ModalManager;
131
-
132
- const config = new ModalConfig();
133
- let callbackCalled = false;
134
- const callback = (): void => {
135
- callbackCalled = true;
136
- };
137
- el.showModal({
138
- config,
139
- userClosedModalCallback: callback,
140
- });
141
- await elementUpdated(el);
142
- el.closeModal();
143
- await elementUpdated(el);
144
- expect(callbackCalled).to.equal(false);
145
- });
146
-
147
- it('calls the userClosedModalCallback when the user taps the backdrop', async () => {
148
- const el = (await fixture(html`
149
- <modal-manager></modal-manager>
150
- `)) as ModalManager;
151
-
152
- const config = new ModalConfig();
153
- let callbackCalled = false;
154
- const callback = (): void => {
155
- callbackCalled = true;
156
- };
157
- el.showModal({
158
- config,
159
- userClosedModalCallback: callback,
160
- });
161
- await elementUpdated(el);
162
-
163
- const modal = el.shadowRoot?.querySelector('modal-template');
164
- const closeButton = modal?.shadowRoot?.querySelector('.close-button');
165
- const clickEvent = new MouseEvent('click');
166
- closeButton?.dispatchEvent(clickEvent);
167
-
168
- await elementUpdated(el);
169
-
170
- expect(callbackCalled).to.equal(true);
171
- });
172
-
173
- it('mode is set to closed when close button is pressed', async () => {
174
- const el = (await fixture(html`
175
- <modal-manager></modal-manager>
176
- `)) as ModalManager;
177
-
178
- const config = new ModalConfig();
179
- el.showModal({ config });
180
- await elementUpdated(el);
181
-
182
- expect(el.mode).to.equal('open');
183
-
184
- const modal = el.shadowRoot?.querySelector('modal-template');
185
- const closeButton = modal?.shadowRoot?.querySelector('.close-button');
186
- const clickEvent = new MouseEvent('click');
187
- closeButton?.dispatchEvent(clickEvent);
188
-
189
- await elementUpdated(el);
190
-
191
- expect(el.mode).to.equal('closed');
192
- });
193
-
194
- it('allows the user to close by clicking on the backdrop if configured to', async () => {
195
- const el = (await fixture(html`
196
- <modal-manager></modal-manager>
197
- `)) as ModalManager;
198
-
199
- const config = new ModalConfig();
200
- config.closeOnBackdropClick = true;
201
- el.showModal({ config });
202
- await elementUpdated(el);
203
-
204
- const backdrop = el.shadowRoot?.querySelector('.backdrop');
205
- const clickEvent = new MouseEvent('click');
206
- backdrop?.dispatchEvent(clickEvent);
207
-
208
- await elementUpdated(el);
209
-
210
- expect(el.mode).to.equal('closed');
211
- });
212
-
213
- it("dont't allow the user to close by clicking on the backdrop if configured to", async () => {
214
- const el = (await fixture(html`
215
- <modal-manager></modal-manager>
216
- `)) as ModalManagerInterface;
217
-
218
- const config = new ModalConfig();
219
- config.closeOnBackdropClick = false;
220
- el.showModal({ config });
221
- await elementUpdated(el);
222
-
223
- const backdrop = el.shadowRoot?.querySelector('.backdrop');
224
- const clickEvent = new MouseEvent('click');
225
- backdrop?.dispatchEvent(clickEvent);
226
-
227
- await elementUpdated(el);
228
-
229
- expect(el.getMode()).to.equal('open');
230
- });
231
-
232
- it('ia logo should not visible on modal', async () => {
233
- const el = (await fixture(html`
234
- <modal-manager></modal-manager>
235
- `)) as ModalManagerInterface;
236
-
237
- const config = new ModalConfig();
238
- config.showHeaderLogo = false;
239
- el.showModal({ config });
240
- await elementUpdated(el);
241
-
242
- const logoIcon = el.shadowRoot?.querySelector('.logo-icon');
243
- expect(logoIcon).to.not.exist;
244
- });
245
- });
1
+ import { fixture, expect, oneEvent, elementUpdated } from '@open-wc/testing';
2
+ import { html } from 'lit';
3
+
4
+ import '../src/modal-manager';
5
+ import { ModalConfig } from '../src/modal-config';
6
+ import { ModalManager } from '../src/modal-manager';
7
+ import { ModalManagerMode } from '../src/modal-manager-mode';
8
+ import { ModalManagerInterface } from '../src/modal-manager-interface';
9
+
10
+ describe('Modal Manager', () => {
11
+ it('defaults to closed', async () => {
12
+ const el = (await fixture(html`
13
+ <modal-manager></modal-manager>
14
+ `)) as ModalManager;
15
+
16
+ expect(el.mode).to.equal('closed');
17
+ });
18
+
19
+ it('can be closed by calling closeModal', async () => {
20
+ const el = (await fixture(html`
21
+ <modal-manager .mode=${ModalManagerMode.Open}></modal-manager>
22
+ `)) as ModalManager;
23
+
24
+ el.closeModal();
25
+ await elementUpdated(el);
26
+
27
+ expect(el.mode).to.equal('closed');
28
+ });
29
+
30
+ it('can be closed by clicking on the backdrop', async () => {
31
+ const el = (await fixture(html`
32
+ <modal-manager .mode=${ModalManagerMode.Open}></modal-manager>
33
+ `)) as ModalManager;
34
+
35
+ const backdrop = el.shadowRoot?.querySelector('.backdrop');
36
+ const clickEvent = new MouseEvent('click');
37
+
38
+ backdrop?.dispatchEvent(clickEvent);
39
+ await elementUpdated(el);
40
+
41
+ expect(el.mode).to.equal('closed');
42
+ });
43
+
44
+ it('emits a modeChanged event when opening', async () => {
45
+ const el = (await fixture(html`
46
+ <modal-manager></modal-manager>
47
+ `)) as ModalManager;
48
+
49
+ const config = new ModalConfig();
50
+
51
+ setTimeout(() => {
52
+ el.showModal({ config });
53
+ });
54
+ const response = await oneEvent(el, 'modeChanged');
55
+ expect(response.detail.mode).to.equal(ModalManagerMode.Open);
56
+ });
57
+
58
+ it('emits a modeChanged event when closing', async () => {
59
+ const el = (await fixture(html`
60
+ <modal-manager></modal-manager>
61
+ `)) as ModalManager;
62
+
63
+ const config = new ModalConfig();
64
+ el.showModal({ config });
65
+ await elementUpdated(el);
66
+
67
+ setTimeout(() => {
68
+ el.closeModal();
69
+ });
70
+ const response = await oneEvent(el, 'modeChanged');
71
+ expect(response.detail.mode).to.equal(ModalManagerMode.Closed);
72
+ });
73
+
74
+ it('can show a modal', async () => {
75
+ const el = (await fixture(html`
76
+ <modal-manager></modal-manager>
77
+ `)) as ModalManager;
78
+
79
+ const config = new ModalConfig();
80
+ el.showModal({ config });
81
+ await elementUpdated(el);
82
+ expect(el.mode).to.equal(ModalManagerMode.Open);
83
+ });
84
+
85
+ it('sets the --containerHeight CSS property when the window resizes', async () => {
86
+ const el = (await fixture(html`
87
+ <modal-manager></modal-manager>
88
+ `)) as ModalManager;
89
+
90
+ const config = new ModalConfig();
91
+ el.showModal({ config });
92
+ await elementUpdated(el);
93
+ const event = new Event('resize');
94
+ const propBefore = el.style.getPropertyValue('--containerHeight');
95
+ expect(propBefore).to.equal('');
96
+ window.dispatchEvent(event);
97
+ await elementUpdated(el);
98
+ const propAfter = el.style.getPropertyValue('--containerHeight');
99
+ expect(propAfter).to.not.equal('');
100
+ });
101
+
102
+ it('calls the userClosedModalCallback when the user taps the backdrop', async () => {
103
+ const el = (await fixture(html`
104
+ <modal-manager></modal-manager>
105
+ `)) as ModalManager;
106
+
107
+ const config = new ModalConfig();
108
+ let callbackCalled = false;
109
+ const callback = (): void => {
110
+ callbackCalled = true;
111
+ };
112
+ el.showModal({
113
+ config,
114
+ userClosedModalCallback: callback,
115
+ });
116
+ await elementUpdated(el);
117
+
118
+ const backdrop = el.shadowRoot?.querySelector('.backdrop');
119
+ const clickEvent = new MouseEvent('click');
120
+ backdrop?.dispatchEvent(clickEvent);
121
+
122
+ await elementUpdated(el);
123
+
124
+ expect(callbackCalled).to.equal(true);
125
+ });
126
+
127
+ it('does not call the userClosedModalCallback when the modal just closes', async () => {
128
+ const el = (await fixture(html`
129
+ <modal-manager></modal-manager>
130
+ `)) as ModalManager;
131
+
132
+ const config = new ModalConfig();
133
+ let callbackCalled = false;
134
+ const callback = (): void => {
135
+ callbackCalled = true;
136
+ };
137
+ el.showModal({
138
+ config,
139
+ userClosedModalCallback: callback,
140
+ });
141
+ await elementUpdated(el);
142
+ el.closeModal();
143
+ await elementUpdated(el);
144
+ expect(callbackCalled).to.equal(false);
145
+ });
146
+
147
+ it('calls the userClosedModalCallback when the user taps the backdrop', async () => {
148
+ const el = (await fixture(html`
149
+ <modal-manager></modal-manager>
150
+ `)) as ModalManager;
151
+
152
+ const config = new ModalConfig();
153
+ let callbackCalled = false;
154
+ const callback = (): void => {
155
+ callbackCalled = true;
156
+ };
157
+ el.showModal({
158
+ config,
159
+ userClosedModalCallback: callback,
160
+ });
161
+ await elementUpdated(el);
162
+
163
+ const modal = el.shadowRoot?.querySelector('modal-template');
164
+ const closeButton = modal?.shadowRoot?.querySelector('.close-button');
165
+ const clickEvent = new MouseEvent('click');
166
+ closeButton?.dispatchEvent(clickEvent);
167
+
168
+ await elementUpdated(el);
169
+
170
+ expect(callbackCalled).to.equal(true);
171
+ });
172
+
173
+ it('mode is set to closed when close button is pressed', async () => {
174
+ const el = (await fixture(html`
175
+ <modal-manager></modal-manager>
176
+ `)) as ModalManager;
177
+
178
+ const config = new ModalConfig();
179
+ el.showModal({ config });
180
+ await elementUpdated(el);
181
+
182
+ expect(el.mode).to.equal('open');
183
+
184
+ const modal = el.shadowRoot?.querySelector('modal-template');
185
+ const closeButton = modal?.shadowRoot?.querySelector('.close-button');
186
+ const clickEvent = new MouseEvent('click');
187
+ closeButton?.dispatchEvent(clickEvent);
188
+
189
+ await elementUpdated(el);
190
+
191
+ expect(el.mode).to.equal('closed');
192
+ });
193
+
194
+ it('allows the user to close by clicking on the backdrop if configured to', async () => {
195
+ const el = (await fixture(html`
196
+ <modal-manager></modal-manager>
197
+ `)) as ModalManager;
198
+
199
+ const config = new ModalConfig();
200
+ config.closeOnBackdropClick = true;
201
+ el.showModal({ config });
202
+ await elementUpdated(el);
203
+
204
+ const backdrop = el.shadowRoot?.querySelector('.backdrop');
205
+ const clickEvent = new MouseEvent('click');
206
+ backdrop?.dispatchEvent(clickEvent);
207
+
208
+ await elementUpdated(el);
209
+
210
+ expect(el.mode).to.equal('closed');
211
+ });
212
+
213
+ it("dont't allow the user to close by clicking on the backdrop if configured to", async () => {
214
+ const el = (await fixture(html`
215
+ <modal-manager></modal-manager>
216
+ `)) as ModalManagerInterface;
217
+
218
+ const config = new ModalConfig();
219
+ config.closeOnBackdropClick = false;
220
+ el.showModal({ config });
221
+ await elementUpdated(el);
222
+
223
+ const backdrop = el.shadowRoot?.querySelector('.backdrop');
224
+ const clickEvent = new MouseEvent('click');
225
+ backdrop?.dispatchEvent(clickEvent);
226
+
227
+ await elementUpdated(el);
228
+
229
+ expect(el.getMode()).to.equal('open');
230
+ });
231
+
232
+ it('ia logo should not visible on modal', async () => {
233
+ const el = (await fixture(html`
234
+ <modal-manager></modal-manager>
235
+ `)) as ModalManagerInterface;
236
+
237
+ const config = new ModalConfig();
238
+ config.showHeaderLogo = false;
239
+ el.showModal({ config });
240
+ await elementUpdated(el);
241
+
242
+ const logoIcon = el.shadowRoot?.querySelector('.logo-icon');
243
+ expect(logoIcon).to.not.exist;
244
+ });
245
+ });