@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
@@ -1,305 +1,305 @@
1
- import {
2
- LitElement,
3
- html,
4
- css,
5
- CSSResult,
6
- TemplateResult,
7
- PropertyValues,
8
- } from 'lit';
9
- import { property, customElement, query } from 'lit/decorators.js';
10
-
11
- import Modal from './shoelace/modal';
12
- import { getDeepestActiveElement } from './shoelace/active-elements';
13
-
14
- import './modal-template';
15
- import { ModalTemplate } from './modal-template';
16
- import { ModalConfig } from './modal-config';
17
- import { ModalManagerHostBridge } from './modal-manager-host-bridge';
18
- import { ModalManagerInterface } from './modal-manager-interface';
19
- import { ModalManagerHostBridgeInterface } from './modal-manager-host-bridge-interface';
20
- import { ModalManagerMode } from './modal-manager-mode';
21
-
22
- @customElement('modal-manager')
23
- export class ModalManager extends LitElement implements ModalManagerInterface {
24
- /**
25
- * The current mode of the ModalManager
26
- *
27
- * Current options are `modal` or `closed`
28
- *
29
- * @type {ModalManagerMode}
30
- * @memberof ModalManager
31
- */
32
- @property({ type: String, reflect: true }) mode: ModalManagerMode =
33
- ModalManagerMode.Closed;
34
-
35
- /**
36
- * Custom content to display in the modal's content slot
37
- *
38
- * @type {(TemplateResult | undefined)}
39
- * @memberof ModalManager
40
- */
41
- @property({ type: Object }) customModalContent?: TemplateResult;
42
-
43
- /**
44
- * This hostBridge handles environmental-specific interactions such as adding classes
45
- * to the body tag or event listeners needed to support the modal manager in the host environment.
46
- *
47
- * There is a default `ModalManagerHostBridge`, but consumers can override it with a custom
48
- * `ModalManagerHostBridgeInterface`
49
- *
50
- * @type {ModalManagerHostBridgeInterface}
51
- * @memberof ModalManager
52
- */
53
- @property({ type: Object })
54
- hostBridge: ModalManagerHostBridgeInterface = new ModalManagerHostBridge(
55
- this
56
- );
57
-
58
- /**
59
- * Reference to the ModalTemplate DOM element
60
- *
61
- * @private
62
- * @type {ModalTemplate}
63
- * @memberof ModalManager
64
- */
65
- @query('modal-template') private modalTemplate?: ModalTemplate;
66
-
67
- // Imported tab handling from shoelace
68
- public modal = new Modal(this);
69
-
70
- async firstUpdated(): Promise<void> {
71
- // Give the browser a chance to paint
72
- // eslint-disable-next-line no-promise-executor-return
73
- await new Promise(r => setTimeout(r, 0));
74
-
75
- if (this.closeOnBackdropClick) {
76
- this.addEventListener('keydown', (e: KeyboardEvent) => {
77
- if (e.key === 'Escape') {
78
- this.backdropClicked();
79
- }
80
- });
81
- }
82
- }
83
-
84
- disconnectedCallback() {
85
- super.disconnectedCallback();
86
- this.modal.deactivate();
87
- }
88
-
89
- /** @inheritdoc */
90
- render(): TemplateResult {
91
- return html`
92
- <div class="container">
93
- <div class="backdrop" @click=${this.backdropClicked}></div>
94
- <modal-template
95
- @closeButtonPressed=${this.closeButtonPressed}
96
- @leftNavButtonPressed=${this.callUserPressedLeftNavButtonCallback}
97
- tabindex="-1"
98
- >
99
- ${this.customModalContent}
100
- </modal-template>
101
- </div>
102
- `;
103
- }
104
-
105
- /** @inheritdoc */
106
- getMode(): ModalManagerMode {
107
- return this.mode;
108
- }
109
-
110
- /** @inheritdoc */
111
- closeModal(): void {
112
- this.mode = ModalManagerMode.Closed;
113
- this.customModalContent = undefined;
114
- if (this.modalTemplate) this.modalTemplate.config = new ModalConfig();
115
- this.modal.deactivate();
116
-
117
- // Return focus to the triggering element, if possible
118
- (this.triggeringElement as HTMLElement)?.focus?.();
119
- this.triggeringElement = undefined;
120
- }
121
-
122
- /**
123
- * Whether the modal should close if the user taps on the backdrop
124
- *
125
- * @private
126
- * @memberof ModalManager
127
- */
128
- private closeOnBackdropClick = true;
129
-
130
- /**
131
- * The element that had focus when the modal was opened, so that we can return focus
132
- * to it after the modal closes.
133
- */
134
- private triggeringElement?: Element;
135
-
136
- /**
137
- * A callback if the user closes the modal
138
- *
139
- * @private
140
- * @memberof ModalManager
141
- */
142
- private userClosedModalCallback?: () => void;
143
-
144
- /**
145
- * A callback if the user presses the left nav button
146
- *
147
- * @private
148
- * @memberof ModalManager
149
- */
150
- private userPressedLeftNavButtonCallback?: () => void;
151
-
152
- /**
153
- * Call the userClosedModalCallback and reset it if it exists
154
- *
155
- * @private
156
- * @memberof ModalManager
157
- */
158
- private callUserClosedModalCallback(): void {
159
- // we assign the callback to a temp var and undefine it before calling it
160
- // otherwise, we run into the potential for an infinite loop if the
161
- // callback triggers another `showModal()`, which would execute `userClosedModalCallback`
162
- const callback = this.userClosedModalCallback;
163
- this.userClosedModalCallback = undefined;
164
- if (callback) callback();
165
- }
166
-
167
- /**
168
- * Call the user pressed left nav button callback and reset it if it exists
169
- *
170
- * @private
171
- * @memberof ModalManager
172
- */
173
- private callUserPressedLeftNavButtonCallback(): void {
174
- // avoids an infinite showModal() loop, as above
175
- const callback = this.userPressedLeftNavButtonCallback;
176
- this.userPressedLeftNavButtonCallback = undefined;
177
- if (callback) callback();
178
- }
179
-
180
- /** @inheritdoc */
181
- async showModal(options: {
182
- config: ModalConfig;
183
- customModalContent?: TemplateResult;
184
- userClosedModalCallback?: () => void;
185
- userPressedLeftNavButtonCallback?: () => void;
186
- }): Promise<void> {
187
- // If the dialog is being opened, make note of what element was focused beforehand
188
- if (this.mode === ModalManagerMode.Closed) this.captureFocusedElement();
189
-
190
- this.closeOnBackdropClick = options.config.closeOnBackdropClick;
191
- this.userClosedModalCallback = options.userClosedModalCallback;
192
- this.userPressedLeftNavButtonCallback =
193
- options.userPressedLeftNavButtonCallback;
194
- this.customModalContent = options.customModalContent;
195
- this.mode = ModalManagerMode.Open;
196
- if (this.modalTemplate) {
197
- this.modalTemplate.config = options.config;
198
- await this.modalTemplate.updateComplete;
199
- this.modalTemplate.focus();
200
- }
201
- this.modal.activate();
202
- }
203
-
204
- /**
205
- * Sets the triggering element to the one that is currently focused, as deep
206
- * within Shadow DOM as possible.
207
- */
208
- private captureFocusedElement(): void {
209
- this.triggeringElement = getDeepestActiveElement();
210
- }
211
-
212
- /** @inheritdoc */
213
- updated(changed: PropertyValues): void {
214
- /* istanbul ignore else */
215
- if (changed.has('mode')) {
216
- this.handleModeChange();
217
- }
218
- }
219
-
220
- /**
221
- * Called when the backdrop is clicked
222
- *
223
- * @private
224
- * @memberof ModalManager
225
- */
226
- private backdropClicked(): void {
227
- if (this.closeOnBackdropClick) {
228
- this.closeModal();
229
- this.callUserClosedModalCallback();
230
- }
231
- }
232
-
233
- /**
234
- * Handle the mode change
235
- *
236
- * @private
237
- * @memberof ModalManager
238
- */
239
- private handleModeChange(): void {
240
- this.hostBridge.handleModeChange(this.mode);
241
- this.emitModeChangeEvent();
242
- }
243
-
244
- /**
245
- * Emit a modeChange event
246
- *
247
- * @private
248
- * @memberof ModalManager
249
- */
250
- private emitModeChangeEvent(): void {
251
- const event = new CustomEvent('modeChanged', {
252
- detail: { mode: this.mode },
253
- });
254
- this.dispatchEvent(event);
255
- }
256
-
257
- /**
258
- * Called when the modal close button is pressed. Closes the modal.
259
- *
260
- * @private
261
- * @memberof ModalManager
262
- */
263
- private closeButtonPressed(): void {
264
- this.closeModal();
265
- this.callUserClosedModalCallback();
266
- }
267
-
268
- /** @inheritdoc */
269
- static get styles(): CSSResult {
270
- const modalBackdropColor = css`var(--modalBackdropColor, rgba(10, 10, 10, 0.9))`;
271
- const modalBackdropZindex = css`var(--modalBackdropZindex, 1000)`;
272
-
273
- const modalWidth = css`var(--modalWidth, 32rem)`;
274
- const modalMaxWidth = css`var(--modalMaxWidth, 95%)`;
275
- const modalZindex = css`var(--modalZindex, 2000)`;
276
-
277
- return css`
278
- .container {
279
- width: 100%;
280
- height: 100%;
281
- }
282
-
283
- .backdrop {
284
- position: fixed;
285
- top: 0;
286
- left: 0;
287
- background-color: ${modalBackdropColor};
288
- width: 100%;
289
- height: 100%;
290
- z-index: ${modalBackdropZindex};
291
- }
292
-
293
- modal-template {
294
- outline: 0;
295
- position: fixed;
296
- top: 0;
297
- left: 50%;
298
- transform: translate(-50%, 0);
299
- z-index: ${modalZindex};
300
- width: ${modalWidth};
301
- max-width: ${modalMaxWidth};
302
- }
303
- `;
304
- }
305
- }
1
+ import {
2
+ LitElement,
3
+ html,
4
+ css,
5
+ CSSResult,
6
+ TemplateResult,
7
+ PropertyValues,
8
+ } from 'lit';
9
+ import { property, customElement, query } from 'lit/decorators.js';
10
+
11
+ import Modal from './shoelace/modal';
12
+ import { getDeepestActiveElement } from './shoelace/active-elements';
13
+
14
+ import './modal-template';
15
+ import { ModalTemplate } from './modal-template';
16
+ import { ModalConfig } from './modal-config';
17
+ import { ModalManagerHostBridge } from './modal-manager-host-bridge';
18
+ import { ModalManagerInterface } from './modal-manager-interface';
19
+ import { ModalManagerHostBridgeInterface } from './modal-manager-host-bridge-interface';
20
+ import { ModalManagerMode } from './modal-manager-mode';
21
+
22
+ @customElement('modal-manager')
23
+ export class ModalManager extends LitElement implements ModalManagerInterface {
24
+ /**
25
+ * The current mode of the ModalManager
26
+ *
27
+ * Current options are `modal` or `closed`
28
+ *
29
+ * @type {ModalManagerMode}
30
+ * @memberof ModalManager
31
+ */
32
+ @property({ type: String, reflect: true }) mode: ModalManagerMode =
33
+ ModalManagerMode.Closed;
34
+
35
+ /**
36
+ * Custom content to display in the modal's content slot
37
+ *
38
+ * @type {(TemplateResult | undefined)}
39
+ * @memberof ModalManager
40
+ */
41
+ @property({ type: Object }) customModalContent?: TemplateResult;
42
+
43
+ /**
44
+ * This hostBridge handles environmental-specific interactions such as adding classes
45
+ * to the body tag or event listeners needed to support the modal manager in the host environment.
46
+ *
47
+ * There is a default `ModalManagerHostBridge`, but consumers can override it with a custom
48
+ * `ModalManagerHostBridgeInterface`
49
+ *
50
+ * @type {ModalManagerHostBridgeInterface}
51
+ * @memberof ModalManager
52
+ */
53
+ @property({ type: Object })
54
+ hostBridge: ModalManagerHostBridgeInterface = new ModalManagerHostBridge(
55
+ this,
56
+ );
57
+
58
+ /**
59
+ * Reference to the ModalTemplate DOM element
60
+ *
61
+ * @private
62
+ * @type {ModalTemplate}
63
+ * @memberof ModalManager
64
+ */
65
+ @query('modal-template') private modalTemplate?: ModalTemplate;
66
+
67
+ // Imported tab handling from shoelace
68
+ public modal = new Modal(this);
69
+
70
+ async firstUpdated(): Promise<void> {
71
+ // Give the browser a chance to paint
72
+
73
+ await new Promise((r) => setTimeout(r, 0));
74
+
75
+ if (this.closeOnBackdropClick) {
76
+ this.addEventListener('keydown', (e: KeyboardEvent) => {
77
+ if (e.key === 'Escape') {
78
+ this.backdropClicked();
79
+ }
80
+ });
81
+ }
82
+ }
83
+
84
+ disconnectedCallback() {
85
+ super.disconnectedCallback();
86
+ this.modal.deactivate();
87
+ }
88
+
89
+ /** @inheritdoc */
90
+ render(): TemplateResult {
91
+ return html`
92
+ <div class="container">
93
+ <div class="backdrop" @click=${this.backdropClicked}></div>
94
+ <modal-template
95
+ @closeButtonPressed=${this.closeButtonPressed}
96
+ @leftNavButtonPressed=${this.callUserPressedLeftNavButtonCallback}
97
+ tabindex="-1"
98
+ >
99
+ ${this.customModalContent}
100
+ </modal-template>
101
+ </div>
102
+ `;
103
+ }
104
+
105
+ /** @inheritdoc */
106
+ getMode(): ModalManagerMode {
107
+ return this.mode;
108
+ }
109
+
110
+ /** @inheritdoc */
111
+ closeModal(): void {
112
+ this.mode = ModalManagerMode.Closed;
113
+ this.customModalContent = undefined;
114
+ if (this.modalTemplate) this.modalTemplate.config = new ModalConfig();
115
+ this.modal.deactivate();
116
+
117
+ // Return focus to the triggering element, if possible
118
+ (this.triggeringElement as HTMLElement)?.focus?.();
119
+ this.triggeringElement = undefined;
120
+ }
121
+
122
+ /**
123
+ * Whether the modal should close if the user taps on the backdrop
124
+ *
125
+ * @private
126
+ * @memberof ModalManager
127
+ */
128
+ private closeOnBackdropClick = true;
129
+
130
+ /**
131
+ * The element that had focus when the modal was opened, so that we can return focus
132
+ * to it after the modal closes.
133
+ */
134
+ private triggeringElement?: Element;
135
+
136
+ /**
137
+ * A callback if the user closes the modal
138
+ *
139
+ * @private
140
+ * @memberof ModalManager
141
+ */
142
+ private userClosedModalCallback?: () => void;
143
+
144
+ /**
145
+ * A callback if the user presses the left nav button
146
+ *
147
+ * @private
148
+ * @memberof ModalManager
149
+ */
150
+ private userPressedLeftNavButtonCallback?: () => void;
151
+
152
+ /**
153
+ * Call the userClosedModalCallback and reset it if it exists
154
+ *
155
+ * @private
156
+ * @memberof ModalManager
157
+ */
158
+ private callUserClosedModalCallback(): void {
159
+ // we assign the callback to a temp var and undefine it before calling it
160
+ // otherwise, we run into the potential for an infinite loop if the
161
+ // callback triggers another `showModal()`, which would execute `userClosedModalCallback`
162
+ const callback = this.userClosedModalCallback;
163
+ this.userClosedModalCallback = undefined;
164
+ if (callback) callback();
165
+ }
166
+
167
+ /**
168
+ * Call the user pressed left nav button callback and reset it if it exists
169
+ *
170
+ * @private
171
+ * @memberof ModalManager
172
+ */
173
+ private callUserPressedLeftNavButtonCallback(): void {
174
+ // avoids an infinite showModal() loop, as above
175
+ const callback = this.userPressedLeftNavButtonCallback;
176
+ this.userPressedLeftNavButtonCallback = undefined;
177
+ if (callback) callback();
178
+ }
179
+
180
+ /** @inheritdoc */
181
+ async showModal(options: {
182
+ config: ModalConfig;
183
+ customModalContent?: TemplateResult;
184
+ userClosedModalCallback?: () => void;
185
+ userPressedLeftNavButtonCallback?: () => void;
186
+ }): Promise<void> {
187
+ // If the dialog is being opened, make note of what element was focused beforehand
188
+ if (this.mode === ModalManagerMode.Closed) this.captureFocusedElement();
189
+
190
+ this.closeOnBackdropClick = options.config.closeOnBackdropClick;
191
+ this.userClosedModalCallback = options.userClosedModalCallback;
192
+ this.userPressedLeftNavButtonCallback =
193
+ options.userPressedLeftNavButtonCallback;
194
+ this.customModalContent = options.customModalContent;
195
+ this.mode = ModalManagerMode.Open;
196
+ if (this.modalTemplate) {
197
+ this.modalTemplate.config = options.config;
198
+ await this.modalTemplate.updateComplete;
199
+ this.modalTemplate.focus();
200
+ }
201
+ this.modal.activate();
202
+ }
203
+
204
+ /**
205
+ * Sets the triggering element to the one that is currently focused, as deep
206
+ * within Shadow DOM as possible.
207
+ */
208
+ private captureFocusedElement(): void {
209
+ this.triggeringElement = getDeepestActiveElement();
210
+ }
211
+
212
+ /** @inheritdoc */
213
+ updated(changed: PropertyValues): void {
214
+ /* istanbul ignore else */
215
+ if (changed.has('mode')) {
216
+ this.handleModeChange();
217
+ }
218
+ }
219
+
220
+ /**
221
+ * Called when the backdrop is clicked
222
+ *
223
+ * @private
224
+ * @memberof ModalManager
225
+ */
226
+ private backdropClicked(): void {
227
+ if (this.closeOnBackdropClick) {
228
+ this.closeModal();
229
+ this.callUserClosedModalCallback();
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Handle the mode change
235
+ *
236
+ * @private
237
+ * @memberof ModalManager
238
+ */
239
+ private handleModeChange(): void {
240
+ this.hostBridge.handleModeChange(this.mode);
241
+ this.emitModeChangeEvent();
242
+ }
243
+
244
+ /**
245
+ * Emit a modeChange event
246
+ *
247
+ * @private
248
+ * @memberof ModalManager
249
+ */
250
+ private emitModeChangeEvent(): void {
251
+ const event = new CustomEvent('modeChanged', {
252
+ detail: { mode: this.mode },
253
+ });
254
+ this.dispatchEvent(event);
255
+ }
256
+
257
+ /**
258
+ * Called when the modal close button is pressed. Closes the modal.
259
+ *
260
+ * @private
261
+ * @memberof ModalManager
262
+ */
263
+ private closeButtonPressed(): void {
264
+ this.closeModal();
265
+ this.callUserClosedModalCallback();
266
+ }
267
+
268
+ /** @inheritdoc */
269
+ static get styles(): CSSResult {
270
+ const modalBackdropColor = css`var(--modalBackdropColor, rgba(10, 10, 10, 0.9))`;
271
+ const modalBackdropZindex = css`var(--modalBackdropZindex, 1000)`;
272
+
273
+ const modalWidth = css`var(--modalWidth, 32rem)`;
274
+ const modalMaxWidth = css`var(--modalMaxWidth, 95%)`;
275
+ const modalZindex = css`var(--modalZindex, 2000)`;
276
+
277
+ return css`
278
+ .container {
279
+ width: 100%;
280
+ height: 100%;
281
+ }
282
+
283
+ .backdrop {
284
+ position: fixed;
285
+ top: 0;
286
+ left: 0;
287
+ background-color: ${modalBackdropColor};
288
+ width: 100%;
289
+ height: 100%;
290
+ z-index: ${modalBackdropZindex};
291
+ }
292
+
293
+ modal-template {
294
+ outline: 0;
295
+ position: fixed;
296
+ top: 0;
297
+ left: 50%;
298
+ transform: translate(-50%, 0);
299
+ z-index: ${modalZindex};
300
+ width: ${modalWidth};
301
+ max-width: ${modalMaxWidth};
302
+ }
303
+ `;
304
+ }
305
+ }
@@ -256,7 +256,8 @@ export class ModalTemplate extends LitElement {
256
256
  .logo-icon {
257
257
  border-radius: 100%;
258
258
  border: 3px solid #fff;
259
- box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),
259
+ box-shadow:
260
+ 0 0 0 1px rgba(0, 0, 0, 0.18),
260
261
  0 2px 2px 0 rgba(0, 0, 0, 0.08);
261
262
  width: ${modalLogoSize};
262
263
  height: ${modalLogoSize};
@@ -291,7 +292,8 @@ export class ModalTemplate extends LitElement {
291
292
  padding: 0;
292
293
  cursor: pointer;
293
294
  background-color: white;
294
- box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),
295
+ box-shadow:
296
+ 0 0 0 1px rgba(0, 0, 0, 0.18),
295
297
  0 4px 4px 0 rgba(0, 0, 0, 0.08);
296
298
  }
297
299
 
@@ -1,7 +1,7 @@
1
- Copyright (c) 2020 A Beautiful Site, LLC
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
1
+ Copyright (c) 2020 A Beautiful Site, LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
7
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,4 +1,4 @@
1
- /* istanbul ignore file */
1
+ /* c8 ignore start */
2
2
  /**
3
3
  * Use a generator so we can iterate and possibly break early.
4
4
  * @example
@@ -13,7 +13,7 @@
13
13
  * }
14
14
  */
15
15
  export function* activeElements(
16
- activeElement: Element | null = document.activeElement
16
+ activeElement: Element | null = document.activeElement,
17
17
  ): Generator<Element> {
18
18
  if (activeElement === null || activeElement === undefined) return;
19
19
 
@@ -31,3 +31,4 @@ export function* activeElements(
31
31
  export function getDeepestActiveElement() {
32
32
  return [...activeElements()].pop();
33
33
  }
34
+ /* c8 ignore end */