@internetarchive/modal-manager 2.0.4 → 2.0.5-webdev-8155.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 (101) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +40 -30
  3. package/.github/workflows/gh-pages-main.yml +42 -42
  4. package/.github/workflows/pr-preview.yml +40 -40
  5. package/.prettierrc +4 -0
  6. package/.vscode/extensions.json +10 -0
  7. package/.vscode/tasks.json +12 -0
  8. package/LICENSE +661 -661
  9. package/README.md +139 -139
  10. package/custom-elements.json +170 -170
  11. package/demo/app-root.ts +366 -0
  12. package/dist/demo/app-root.d.ts +22 -0
  13. package/dist/demo/app-root.js +338 -0
  14. package/dist/demo/app-root.js.map +1 -0
  15. package/dist/index.d.ts +7 -7
  16. package/dist/index.js +5 -5
  17. package/dist/src/assets/arrow-left-icon.d.ts +2 -2
  18. package/dist/src/assets/arrow-left-icon.js +2 -2
  19. package/dist/src/assets/ia-logo-icon.d.ts +2 -2
  20. package/dist/src/assets/ia-logo-icon.js +2 -2
  21. package/dist/src/modal-config.d.ts +104 -104
  22. package/dist/src/modal-config.js +23 -24
  23. package/dist/src/modal-config.js.map +1 -1
  24. package/dist/src/modal-manager-host-bridge-interface.d.ts +12 -12
  25. package/dist/src/modal-manager-host-bridge-interface.js +1 -1
  26. package/dist/src/modal-manager-host-bridge.d.ts +34 -34
  27. package/dist/src/modal-manager-host-bridge.js +62 -62
  28. package/dist/src/modal-manager-host-bridge.js.map +1 -1
  29. package/dist/src/modal-manager-interface.d.ts +27 -27
  30. package/dist/src/modal-manager-interface.js +1 -1
  31. package/dist/src/modal-manager-mode.d.ts +10 -10
  32. package/dist/src/modal-manager-mode.js +11 -11
  33. package/dist/src/modal-manager.d.ts +137 -137
  34. package/dist/src/modal-manager.js +243 -249
  35. package/dist/src/modal-manager.js.map +1 -1
  36. package/dist/src/modal-template.d.ts +41 -41
  37. package/dist/src/modal-template.js +119 -118
  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 +28 -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 +130 -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 +168 -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 +68 -69
  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 +306 -309
  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 +158 -167
  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/vitest.config.ci.d.ts +2 -0
  60. package/dist/vitest.config.ci.js +24 -0
  61. package/dist/vitest.config.ci.js.map +1 -0
  62. package/docs/assets/css/main.css +2678 -2678
  63. package/docs/classes/_src_modal_config_.modalconfig.html +429 -429
  64. package/docs/classes/_src_modal_manager_.modalmanager.html +7702 -7702
  65. package/docs/classes/_src_modal_manager_host_bridge_.modalmanagerhostbridge.html +409 -409
  66. package/docs/classes/_src_modal_template_.modaltemplate.html +7096 -7096
  67. package/docs/enums/_src_modal_manager_mode_.modalmanagermode.html +196 -196
  68. package/docs/globals.html +150 -150
  69. package/docs/index.html +252 -252
  70. package/docs/interfaces/_src_modal_manager_host_bridge_interface_.modalmanagerhostbridgeinterface.html +210 -210
  71. package/docs/interfaces/_src_modal_manager_interface_.modalmanagerinterface.html +7095 -7095
  72. package/docs/modules/_index_.html +208 -208
  73. package/docs/modules/_src_modal_config_.html +146 -146
  74. package/docs/modules/_src_modal_manager_.html +146 -146
  75. package/docs/modules/_src_modal_manager_host_bridge_.html +146 -146
  76. package/docs/modules/_src_modal_manager_host_bridge_interface_.html +146 -146
  77. package/docs/modules/_src_modal_manager_interface_.html +146 -146
  78. package/docs/modules/_src_modal_manager_mode_.html +146 -146
  79. package/docs/modules/_src_modal_template_.html +146 -146
  80. package/docs/modules/_test_modal_config_test_.html +106 -106
  81. package/docs/modules/_test_modal_manager_test_.html +106 -106
  82. package/docs/modules/_test_modal_template_test_.html +106 -106
  83. package/eslint.config.mjs +53 -0
  84. package/index.html +33 -300
  85. package/package.json +73 -85
  86. package/renovate.json +7 -7
  87. package/src/modal-config.ts +14 -14
  88. package/src/modal-manager-host-bridge.ts +2 -2
  89. package/src/modal-manager.ts +305 -305
  90. package/src/modal-template.ts +4 -2
  91. package/src/shoelace/LICENSE.md +6 -6
  92. package/src/shoelace/active-elements.ts +3 -2
  93. package/src/shoelace/modal.ts +5 -5
  94. package/src/shoelace/tabbable.ts +4 -3
  95. package/test/modal-config.test.ts +4 -4
  96. package/test/modal-manager.test.ts +402 -393
  97. package/test/modal-template.test.ts +42 -35
  98. package/tsconfig.json +25 -21
  99. package/vitest.config.ci.ts +27 -0
  100. package/.eslintrc.js +0 -14
  101. package/karma.conf.js +0 -24
@@ -0,0 +1,366 @@
1
+ import { css, html, LitElement, type CSSResultGroup } from 'lit';
2
+ import { customElement, query } from 'lit/decorators.js';
3
+ import { ModalConfig } from '../src/modal-config';
4
+ import { ModalManager } from '../src/modal-manager';
5
+ import '../src/modal-manager';
6
+
7
+ @customElement('app-root')
8
+ export class AppRoot extends LitElement {
9
+ @query('modal-manager')
10
+ private modalManager!: ModalManager;
11
+
12
+ protected render() {
13
+ return html`
14
+ <modal-manager>
15
+ <div slot="slot-content-demo">
16
+ <p>Slotted Content</p>
17
+ </div>
18
+ </modal-manager>
19
+
20
+ <div class="actions">
21
+ <button @click=${this.showModal}>Modal</button>
22
+ <button @click=${this.showAllFeaturesModal}>All Features</button>
23
+ <button @click=${this.showErrorModal}>Error Modal</button>
24
+ <button @click=${this.showCustomContentModal}>
25
+ Custom Content Modal
26
+ </button>
27
+ <button @click=${this.showSlottedContentModal}>
28
+ Slotted Content Modal
29
+ </button>
30
+ <button @click=${this.showProcessingModal}>Processing Modal</button>
31
+ <button @click=${this.showCompleteModal}>
32
+ Processing Complete Modal
33
+ </button>
34
+ <button @click=${this.showUserClosedModalCallbackModal}>
35
+ Modal Closed Callback
36
+ </button>
37
+ <button @click=${this.showModalUserCannotClose}>
38
+ Unclosable Modal
39
+ </button>
40
+ <button @click=${this.showModalUserCannotClickBackdrop}>
41
+ Unclickable Backdrop
42
+ </button>
43
+ <button @click=${this.showOverflowModal}>Text-heavy Modal</button>
44
+ <button @click=${this.showModalWithoutLogo}>Modal Without Logo</button>
45
+ <button @click=${this.showModalWithLeftNavButton}>
46
+ Modal With Left Nav Button
47
+ </button>
48
+ </div>
49
+
50
+ <h3>Some Content</h3>
51
+
52
+ <img src="./assets/images/200x200.jpg" style="float:right" />
53
+
54
+ <p>
55
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris posuere
56
+ sollicitudin aliquam. Aenean vel felis arcu. Maecenas convallis dolor ac
57
+ tortor tristique, congue scelerisque turpis congue. Vestibulum porttitor
58
+ scelerisque quam, sit amet porta tortor consectetur non. Cras
59
+ sollicitudin sit amet lacus ac egestas. Nam sollicitudin sem at sagittis
60
+ laoreet. Donec nec nisl erat. Curabitur interdum in enim vehicula
61
+ aliquam. Pellentesque habitant morbi tristique senectus et netus et
62
+ malesuada fames ac turpis egestas. Fusce tempus sit amet tortor laoreet
63
+ volutpat. Vivamus non vehicula felis, aliquet hendrerit odio.
64
+ </p>
65
+
66
+ <p>
67
+ In laoreet scelerisque tortor, at convallis nisl efficitur vehicula.
68
+ Donec eu erat a turpis fermentum blandit vitae ut erat. Mauris tincidunt
69
+ erat sit amet ante suscipit porta. Fusce mollis metus sit amet erat
70
+ condimentum, eu maximus lacus aliquam. Sed cursus lacus eget sem commodo
71
+ feugiat. Praesent semper lorem eu sollicitudin blandit. Sed id risus in
72
+ lacus fermentum tristique. In porttitor malesuada sapien non posuere.
73
+ Phasellus mollis mauris ultrices est consectetur, id pulvinar magna
74
+ suscipit. Integer sodales sapien in augue tincidunt, ac tempor ligula
75
+ cursus. Mauris id justo et dui blandit luctus. Morbi mattis id metus id
76
+ maximus. Suspendisse quis lobortis erat, sed dignissim neque. Etiam
77
+ cursus posuere ultricies.
78
+ </p>
79
+
80
+ <p>
81
+ Maecenas porta ac nulla sed vestibulum. Suspendisse aliquam fermentum
82
+ mi, id luctus tortor aliquet gravida. Maecenas sed tincidunt quam.
83
+ Mauris cursus ante sit amet enim egestas, vitae pellentesque metus
84
+ hendrerit. Sed quis tortor id dui mollis blandit quis ac nunc.
85
+ Suspendisse tincidunt nisl quis nunc tincidunt, et finibus ipsum
86
+ elementum. Maecenas congue, neque eget volutpat pulvinar, augue nisl
87
+ interdum elit, et porta mi augue ut sapien.
88
+ </p>
89
+
90
+ <p>
91
+ Fusce vel imperdiet justo. Aenean sollicitudin blandit nunc. Cras vitae
92
+ orci id lorem condimentum tempor. Aliquam ac lectus sed mi suscipit
93
+ sollicitudin at convallis nisl. Sed semper elementum sagittis. Nam
94
+ fermentum nulla velit, non tempor massa fermentum non. Duis id ante eget
95
+ elit gravida semper ac quis ligula. Duis vel libero ligula. Curabitur
96
+ tempor sed velit nec egestas. Vivamus sit amet volutpat purus. Integer
97
+ imperdiet mattis erat, vitae dignissim odio accumsan quis. Fusce
98
+ bibendum lectus quis est molestie, eget scelerisque elit interdum. Etiam
99
+ imperdiet a leo vitae ultricies. Etiam pretium quam eget sem mollis,
100
+ quis elementum libero vulputate. Praesent aliquet dictum augue a luctus.
101
+ </p>
102
+
103
+ <p>
104
+ Maecenas vulputate iaculis mauris nec lobortis. Sed nibh ante, vehicula
105
+ nec varius et, condimentum in massa. Curabitur a turpis porta, auctor
106
+ magna in, iaculis ante. Suspendisse potenti. Donec massa orci,
107
+ sollicitudin in nulla ut, fringilla dignissim elit. Suspendisse
108
+ porttitor lorem nec sem volutpat ullamcorper. Curabitur blandit est
109
+ tristique velit pharetra rhoncus. Aliquam vitae mauris ex.
110
+ </p>
111
+ `;
112
+ }
113
+
114
+ showModal() {
115
+ const config = new ModalConfig();
116
+ config.headline = 'Success';
117
+ config.message = 'Thank you for your support!';
118
+
119
+ this.modalManager.showModal({
120
+ config,
121
+ });
122
+ }
123
+
124
+ showErrorModal() {
125
+ const config = new ModalConfig();
126
+ config.headline = 'Error';
127
+ config.message = 'An error occurred while processing your donation.';
128
+ config.headerColor = '#691916';
129
+ config.bodyColor = '#fff';
130
+
131
+ this.modalManager.showModal({
132
+ config,
133
+ });
134
+ }
135
+
136
+ showBillAlert() {
137
+ alert('Bill <3 You');
138
+ }
139
+
140
+ buttonPress() {
141
+ alert('You pressed a button.');
142
+ }
143
+
144
+ showAllFeaturesModal() {
145
+ const config = new ModalConfig();
146
+ config.title = html`Donation Received`;
147
+ config.subtitle = html`Thanks a bunch!`;
148
+ config.headline = html`A Headline that catches attention and might spill
149
+ over to multiple lines!`;
150
+ config.message = html`A long informative message for your users that let
151
+ them know about something`;
152
+ config.headerColor = 'purple';
153
+ config.showProcessingIndicator = true;
154
+ config.processingImageMode = 'complete';
155
+
156
+ const someContent = html`
157
+ <div style="text-align: center; margin-top: 10px;">
158
+ <button @click=${this.buttonPress}>I'm A Button To Press</button>
159
+ </div>
160
+ `;
161
+
162
+ this.modalManager.showModal({
163
+ config,
164
+ customModalContent: someContent,
165
+ });
166
+ }
167
+
168
+ showCustomContentModal() {
169
+ const config = new ModalConfig();
170
+ config.title = 'Custom Content';
171
+ config.headline = html`<span class="sr-only"
172
+ >Also support screen-reader only</span
173
+ >`;
174
+
175
+ const someContent = html`
176
+ <style>
177
+ a:focus {
178
+ outline: 2px solid blue;
179
+ }
180
+ </style>
181
+ Can contain any markup, including web components. Event listeners also
182
+ work. Try clicking on the picture.
183
+ <span class="sr-only">Also support screen-reader only</span>
184
+ <div style="text-align: center">
185
+ <a href="https://www.billmurraystory.com/" style="display: block;"
186
+ >Bill Murray Stories</a
187
+ >
188
+ <img src="./assets/images/100x100.jpg" @click=${this.showBillAlert} />
189
+ </div>
190
+ `;
191
+
192
+ this.modalManager.showModal({
193
+ config,
194
+ customModalContent: someContent,
195
+ });
196
+ }
197
+
198
+ showSlottedContentModal() {
199
+ const config = new ModalConfig();
200
+ config.title = 'Slotted Content';
201
+
202
+ const someContent = html`
203
+ Can slot content from the top-level:
204
+ <slot name="slot-content-demo"></slot>
205
+ `;
206
+
207
+ this.modalManager.showModal({
208
+ config,
209
+ customModalContent: someContent,
210
+ });
211
+ }
212
+
213
+ showOverflowModal() {
214
+ const config = new ModalConfig();
215
+
216
+ config.title = html`Lorem Ipsum`;
217
+ config.subtitle = html`Subtitle`;
218
+ config.headline = html`Everything Important`;
219
+ config.message = html`
220
+ <p>
221
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris posuere
222
+ sollicitudin aliquam. Aenean vel felis arcu. Maecenas convallis dolor ac
223
+ tortor tristique, congue scelerisque turpis congue. Vestibulum porttitor
224
+ scelerisque quam, sit amet porta tortor consectetur non. Cras
225
+ sollicitudin sit amet lacus ac egestas. Nam sollicitudin sem at sagittis
226
+ laoreet. Donec nec nisl erat. Curabitur interdum in enim vehicula
227
+ aliquam. Pellentesque habitant morbi tristique senectus et netus et
228
+ malesuada fames ac turpis egestas. Fusce tempus sit amet tortor laoreet
229
+ volutpat. Vivamus non vehicula felis, aliquet hendrerit odio.
230
+ </p>
231
+
232
+ <p>
233
+ In laoreet scelerisque tortor, at convallis nisl efficitur vehicula.
234
+ Donec eu erat a turpis fermentum blandit vitae ut erat. Mauris tincidunt
235
+ erat sit amet ante suscipit porta. Fusce mollis metus sit amet erat
236
+ condimentum, eu maximus lacus aliquam. Sed cursus lacus eget sem commodo
237
+ feugiat. Praesent semper lorem eu sollicitudin blandit. Sed id risus in
238
+ lacus fermentum tristique. In porttitor malesuada sapien non posuere.
239
+ Phasellus mollis mauris ultrices est consectetur, id pulvinar magna
240
+ suscipit. Integer sodales sapien in augue tincidunt, ac tempor ligula
241
+ cursus. Mauris id justo et dui blandit luctus. Morbi mattis id metus id
242
+ maximus. Suspendisse quis lobortis erat, sed dignissim neque. Etiam
243
+ cursus posuere ultricies.
244
+ </p>
245
+ `;
246
+
247
+ config.headerColor = '#36A483';
248
+
249
+ this.modalManager.showModal({
250
+ config,
251
+ });
252
+ }
253
+
254
+ showModalWithoutLogo() {
255
+ const config = new ModalConfig();
256
+ config.headline = 'Success';
257
+ config.title = html`Donation Received`;
258
+ config.message = 'Thank you for your support!';
259
+ config.headerColor = '#194880';
260
+ config.showHeaderLogo = false;
261
+ this.modalManager.showModal({
262
+ config,
263
+ });
264
+ }
265
+
266
+ showCompleteModal() {
267
+ const config = new ModalConfig();
268
+ config.showProcessingIndicator = true;
269
+ config.processingImageMode = 'complete';
270
+ this.modalManager.showModal({
271
+ config,
272
+ });
273
+ }
274
+
275
+ showProcessingModal() {
276
+ const config = new ModalConfig();
277
+ config.headerColor = '#497fbf';
278
+ config.showProcessingIndicator = true;
279
+ config.processingImageMode = 'processing';
280
+ config.showCloseButton = false;
281
+ config.closeOnBackdropClick = false;
282
+ this.modalManager.showModal({
283
+ config,
284
+ });
285
+
286
+ setTimeout(this.showCompleteModal.bind(this), 1500);
287
+ }
288
+
289
+ showUserClosedModalCallbackModal() {
290
+ const config = new ModalConfig();
291
+ config.message = 'When you close this modal another will open.';
292
+
293
+ this.modalManager.showModal({
294
+ config,
295
+ userClosedModalCallback: () => {
296
+ const config = new ModalConfig();
297
+ config.message = "I'm another modal";
298
+ config.headerColor = '#497fbf';
299
+ this.modalManager.showModal({ config });
300
+ },
301
+ });
302
+ }
303
+
304
+ showModalUserCannotClose() {
305
+ const config = new ModalConfig();
306
+ config.message =
307
+ 'User cannot close this. Will close automatically in 2 seconds.';
308
+ config.showCloseButton = false;
309
+ config.closeOnBackdropClick = false;
310
+ this.modalManager.showModal({
311
+ config,
312
+ });
313
+
314
+ setTimeout(this.modalManager.closeModal.bind(this.modalManager), 2000);
315
+ }
316
+
317
+ showModalWithLeftNavButton() {
318
+ const config = new ModalConfig();
319
+ config.message = 'This modal has a left nav button.';
320
+ config.showLeftNavButton = true;
321
+ config.leftNavButtonText = 'Back';
322
+
323
+ this.modalManager.showModal({
324
+ config,
325
+ userPressedLeftNavButtonCallback: () => {
326
+ const config = new ModalConfig();
327
+ config.message =
328
+ "I'm the previous modal (or anything else you want to do here)";
329
+ config.headerColor = '#497fbf';
330
+ this.modalManager.showModal({ config });
331
+ },
332
+ });
333
+ }
334
+
335
+ showModalUserCannotClickBackdrop() {
336
+ const config = new ModalConfig();
337
+ config.message = 'Clicking on the backdrop will not close this.';
338
+ config.showCloseButton = true;
339
+ config.closeOnBackdropClick = false;
340
+ this.modalManager.showModal({
341
+ config,
342
+ });
343
+ }
344
+
345
+ static get styles(): CSSResultGroup {
346
+ return css`
347
+ modal-manager {
348
+ display: none;
349
+ --modalTitleLineHeight: 4.5rem;
350
+ }
351
+
352
+ modal-manager[mode='open'] {
353
+ display: block;
354
+ }
355
+
356
+ .actions {
357
+ position: fixed;
358
+ background-color: rgba(255, 255, 255, 0.9);
359
+ border: 1px solid black;
360
+ padding: 10px;
361
+ top: 10px;
362
+ left: 10px;
363
+ }
364
+ `;
365
+ }
366
+ }
@@ -0,0 +1,22 @@
1
+ import { LitElement, type CSSResultGroup } from 'lit';
2
+ import '../src/modal-manager';
3
+ export declare class AppRoot extends LitElement {
4
+ private modalManager;
5
+ protected render(): import("lit-html").TemplateResult<1>;
6
+ showModal(): void;
7
+ showErrorModal(): void;
8
+ showBillAlert(): void;
9
+ buttonPress(): void;
10
+ showAllFeaturesModal(): void;
11
+ showCustomContentModal(): void;
12
+ showSlottedContentModal(): void;
13
+ showOverflowModal(): void;
14
+ showModalWithoutLogo(): void;
15
+ showCompleteModal(): void;
16
+ showProcessingModal(): void;
17
+ showUserClosedModalCallbackModal(): void;
18
+ showModalUserCannotClose(): void;
19
+ showModalWithLeftNavButton(): void;
20
+ showModalUserCannotClickBackdrop(): void;
21
+ static get styles(): CSSResultGroup;
22
+ }