@internetarchive/modal-manager 2.0.2 → 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.
Files changed (103) hide show
  1. package/.editorconfig +29 -29
  2. package/.eslintrc.js +14 -14
  3. package/.github/workflows/ci.yml +30 -30
  4. package/.github/workflows/gh-pages-main.yml +42 -42
  5. package/.github/workflows/pr-preview.yml +40 -40
  6. package/LICENSE +661 -661
  7. package/README.md +139 -139
  8. package/custom-elements.json +170 -170
  9. package/dist/index.d.ts +7 -7
  10. package/dist/index.js +5 -5
  11. package/dist/index.js.map +1 -1
  12. package/dist/src/assets/arrow-left-icon.d.ts +2 -0
  13. package/dist/src/assets/arrow-left-icon.js +15 -0
  14. package/dist/src/assets/arrow-left-icon.js.map +1 -0
  15. package/dist/src/assets/ia-logo-icon.d.ts +2 -2
  16. package/dist/src/assets/ia-logo-icon.js +29 -29
  17. package/dist/src/assets/ia-logo-icon.js.map +1 -1
  18. package/dist/src/modal-config.d.ts +104 -92
  19. package/dist/src/modal-config.js +24 -22
  20. package/dist/src/modal-config.js.map +1 -1
  21. package/dist/src/modal-manager-host-bridge-interface.d.ts +12 -12
  22. package/dist/src/modal-manager-host-bridge-interface.js +1 -1
  23. package/dist/src/modal-manager-host-bridge-interface.js.map +1 -1
  24. package/dist/src/modal-manager-host-bridge.d.ts +34 -34
  25. package/dist/src/modal-manager-host-bridge.js +62 -62
  26. package/dist/src/modal-manager-host-bridge.js.map +1 -1
  27. package/dist/src/modal-manager-interface.d.ts +27 -25
  28. package/dist/src/modal-manager-interface.js +1 -1
  29. package/dist/src/modal-manager-interface.js.map +1 -1
  30. package/dist/src/modal-manager-mode.d.ts +10 -10
  31. package/dist/src/modal-manager-mode.js +11 -11
  32. package/dist/src/modal-manager-mode.js.map +1 -1
  33. package/dist/src/modal-manager.d.ts +137 -112
  34. package/dist/src/modal-manager.js +247 -218
  35. package/dist/src/modal-manager.js.map +1 -1
  36. package/dist/src/modal-template.d.ts +41 -33
  37. package/dist/src/modal-template.js +335 -282
  38. package/dist/src/modal-template.js.map +1 -1
  39. package/dist/src/shoelace/active-elements.d.ts +15 -15
  40. package/dist/src/shoelace/active-elements.js +27 -27
  41. package/dist/src/shoelace/active-elements.js.map +1 -1
  42. package/dist/src/shoelace/modal.d.ts +24 -24
  43. package/dist/src/shoelace/modal.js +131 -131
  44. package/dist/src/shoelace/modal.js.map +1 -1
  45. package/dist/src/shoelace/tabbable.d.ts +9 -9
  46. package/dist/src/shoelace/tabbable.js +169 -169
  47. package/dist/src/shoelace/tabbable.js.map +1 -1
  48. package/dist/test/modal-config.test.d.ts +1 -1
  49. package/dist/test/modal-config.test.js +69 -61
  50. package/dist/test/modal-config.test.js.map +1 -1
  51. package/dist/test/modal-manager.test.d.ts +1 -1
  52. package/dist/test/modal-manager.test.js +274 -252
  53. package/dist/test/modal-manager.test.js.map +1 -1
  54. package/dist/test/modal-template.test.d.ts +1 -1
  55. package/dist/test/modal-template.test.js +178 -106
  56. package/dist/test/modal-template.test.js.map +1 -1
  57. package/dist/vite.config.d.ts +2 -2
  58. package/dist/vite.config.js +22 -22
  59. package/dist/vite.config.js.map +1 -1
  60. package/docs/assets/css/main.css +2678 -2678
  61. package/docs/classes/_src_modal_config_.modalconfig.html +429 -429
  62. package/docs/classes/_src_modal_manager_.modalmanager.html +7702 -7702
  63. package/docs/classes/_src_modal_manager_host_bridge_.modalmanagerhostbridge.html +409 -409
  64. package/docs/classes/_src_modal_template_.modaltemplate.html +7096 -7096
  65. package/docs/enums/_src_modal_manager_mode_.modalmanagermode.html +196 -196
  66. package/docs/globals.html +150 -150
  67. package/docs/index.html +252 -252
  68. package/docs/interfaces/_src_modal_manager_host_bridge_interface_.modalmanagerhostbridgeinterface.html +210 -210
  69. package/docs/interfaces/_src_modal_manager_interface_.modalmanagerinterface.html +7095 -7095
  70. package/docs/modules/_index_.html +208 -208
  71. package/docs/modules/_src_modal_config_.html +146 -146
  72. package/docs/modules/_src_modal_manager_.html +146 -146
  73. package/docs/modules/_src_modal_manager_host_bridge_.html +146 -146
  74. package/docs/modules/_src_modal_manager_host_bridge_interface_.html +146 -146
  75. package/docs/modules/_src_modal_manager_interface_.html +146 -146
  76. package/docs/modules/_src_modal_manager_mode_.html +146 -146
  77. package/docs/modules/_src_modal_template_.html +146 -146
  78. package/docs/modules/_test_modal_config_test_.html +106 -106
  79. package/docs/modules/_test_modal_manager_test_.html +106 -106
  80. package/docs/modules/_test_modal_template_test_.html +106 -106
  81. package/index.html +300 -282
  82. package/index.ts +7 -7
  83. package/karma.conf.js +24 -24
  84. package/package.json +85 -85
  85. package/renovate.json +7 -7
  86. package/src/assets/arrow-left-icon.ts +15 -0
  87. package/src/assets/ia-logo-icon.ts +30 -30
  88. package/src/modal-config.ts +133 -117
  89. package/src/modal-manager-host-bridge-interface.ts +13 -13
  90. package/src/modal-manager-host-bridge.ts +82 -82
  91. package/src/modal-manager-interface.ts +30 -28
  92. package/src/modal-manager-mode.ts +10 -10
  93. package/src/modal-manager.ts +303 -258
  94. package/src/modal-template.ts +343 -287
  95. package/src/shoelace/LICENSE.md +6 -6
  96. package/src/shoelace/active-elements.ts +33 -33
  97. package/src/shoelace/modal.ts +166 -166
  98. package/src/shoelace/tabbable.ts +223 -223
  99. package/test/modal-config.test.ts +77 -69
  100. package/test/modal-manager.test.ts +347 -319
  101. package/test/modal-template.test.ts +206 -124
  102. package/tsconfig.json +21 -21
  103. package/vite.config.ts +23 -23
@@ -1,124 +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('shows the processing indicator if configured to', async () => {
61
- const config = new ModalConfig();
62
- config.showProcessingIndicator = true;
63
-
64
- const el = await fixture(html`
65
- <modal-template .config=${config}></modal-template>
66
- `);
67
-
68
- const processingLogo = el.shadowRoot?.querySelector('.processing-logo');
69
- const classList = processingLogo?.classList ?? [];
70
- expect('hidden' in classList).to.equal(false);
71
- });
72
-
73
- it('shows the close button if configured to', async () => {
74
- const config = new ModalConfig();
75
- config.showCloseButton = true;
76
- const el = await fixture(html`
77
- <modal-template .config=${config}></modal-template>
78
- `);
79
-
80
- const closeButton = el.shadowRoot?.querySelector('.close-button');
81
- expect(closeButton).to.exist;
82
- });
83
-
84
- it('hides the close button if configured to', async () => {
85
- const config = new ModalConfig();
86
- config.showCloseButton = false;
87
- const el = await fixture(html`
88
- <modal-template .config=${config}></modal-template>
89
- `);
90
-
91
- const closeButton = el.shadowRoot?.querySelector('.close-button');
92
- expect(closeButton).to.not.exist;
93
- });
94
-
95
- it('shows the properties from the config', async () => {
96
- const config = new ModalConfig();
97
- config.title = html`Boop`;
98
- config.subtitle = html`Bop`;
99
- config.headline = html`Foo`;
100
- config.message = html`Bar`;
101
-
102
- const el = await fixture(html`
103
- <modal-template .config=${config}></modal-template>
104
- `);
105
-
106
- const title = el.shadowRoot?.querySelector('h1');
107
- const subtitle = el.shadowRoot?.querySelector('h2');
108
-
109
- const headline = el.shadowRoot?.querySelector('.headline');
110
- const message = el.shadowRoot?.querySelector('.message');
111
-
112
- expect(title).to.exist;
113
- expect(title?.innerText).to.equal('Boop');
114
-
115
- expect(subtitle).to.exist;
116
- expect(subtitle?.innerText).to.equal('Bop');
117
-
118
- expect(headline).to.exist;
119
- expect(headline?.textContent).to.equal('Foo');
120
-
121
- expect(message).to.exist;
122
- expect(message?.textContent).to.equal('Bar');
123
- });
124
- });
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
+ });