@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.
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 -2
  13. package/dist/src/assets/arrow-left-icon.js +14 -14
  14. package/dist/src/assets/arrow-left-icon.js.map +1 -1
  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 -104
  19. package/dist/src/modal-config.js +24 -24
  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 -27
  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 -127
  34. package/dist/src/modal-manager.js +247 -234
  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 +335 -335
  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 -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 +274 -274
  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 -178
  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 -300
  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 -15
  87. package/src/assets/ia-logo-icon.ts +30 -30
  88. package/src/modal-config.ts +133 -133
  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 -30
  92. package/src/modal-manager-mode.ts +10 -10
  93. package/src/modal-manager.ts +303 -283
  94. package/src/modal-template.ts +343 -343
  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 -77
  100. package/test/modal-manager.test.ts +347 -347
  101. package/test/modal-template.test.ts +206 -206
  102. package/tsconfig.json +21 -21
  103. package/vite.config.ts +23 -23
@@ -1,283 +1,303 @@
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
-
13
- import './modal-template';
14
- import { ModalTemplate } from './modal-template';
15
- import { ModalConfig } from './modal-config';
16
- import { ModalManagerHostBridge } from './modal-manager-host-bridge';
17
- import { ModalManagerInterface } from './modal-manager-interface';
18
- import { ModalManagerHostBridgeInterface } from './modal-manager-host-bridge-interface';
19
- import { ModalManagerMode } from './modal-manager-mode';
20
-
21
- @customElement('modal-manager')
22
- export class ModalManager extends LitElement implements ModalManagerInterface {
23
- /**
24
- * The current mode of the ModalManager
25
- *
26
- * Current options are `modal` or `closed`
27
- *
28
- * @type {ModalManagerMode}
29
- * @memberof ModalManager
30
- */
31
- @property({ type: String, reflect: true }) mode: ModalManagerMode =
32
- ModalManagerMode.Closed;
33
-
34
- /**
35
- * Custom content to display in the modal's content slot
36
- *
37
- * @type {(TemplateResult | undefined)}
38
- * @memberof ModalManager
39
- */
40
- @property({ type: Object }) customModalContent?: TemplateResult;
41
-
42
- /**
43
- * This hostBridge handles environmental-specific interactions such as adding classes
44
- * to the body tag or event listeners needed to support the modal manager in the host environment.
45
- *
46
- * There is a default `ModalManagerHostBridge`, but consumers can override it with a custom
47
- * `ModalManagerHostBridgeInterface`
48
- *
49
- * @type {ModalManagerHostBridgeInterface}
50
- * @memberof ModalManager
51
- */
52
- @property({ type: Object })
53
- hostBridge: ModalManagerHostBridgeInterface = new ModalManagerHostBridge(
54
- this
55
- );
56
-
57
- /**
58
- * Reference to the ModalTemplate DOM element
59
- *
60
- * @private
61
- * @type {ModalTemplate}
62
- * @memberof ModalManager
63
- */
64
- @query('modal-template') private modalTemplate?: ModalTemplate;
65
-
66
- // Imported tab handling from shoelace
67
- public modal = new Modal(this);
68
-
69
- async firstUpdated(): Promise<void> {
70
- // Give the browser a chance to paint
71
- // eslint-disable-next-line no-promise-executor-return
72
- await new Promise(r => setTimeout(r, 0));
73
-
74
- if (this.closeOnBackdropClick) {
75
- this.addEventListener('keydown', (e: KeyboardEvent) => {
76
- if (e.key === 'Escape') {
77
- this.backdropClicked();
78
- }
79
- });
80
- }
81
- }
82
-
83
- disconnectedCallback() {
84
- super.disconnectedCallback();
85
- this.modal.deactivate();
86
- }
87
-
88
- /** @inheritdoc */
89
- render(): TemplateResult {
90
- return html`
91
- <div class="container">
92
- <div class="backdrop" @click=${this.backdropClicked}></div>
93
- <modal-template
94
- @closeButtonPressed=${this.closeButtonPressed}
95
- @leftNavButtonPressed=${this.callUserPressedLeftNavButtonCallback}
96
- tabindex="-1"
97
- >
98
- ${this.customModalContent}
99
- </modal-template>
100
- </div>
101
- `;
102
- }
103
-
104
- /** @inheritdoc */
105
- getMode(): ModalManagerMode {
106
- return this.mode;
107
- }
108
-
109
- /** @inheritdoc */
110
- closeModal(): void {
111
- this.mode = ModalManagerMode.Closed;
112
- this.customModalContent = undefined;
113
- if (this.modalTemplate) this.modalTemplate.config = new ModalConfig();
114
- this.modal.deactivate();
115
- }
116
-
117
- /**
118
- * Whether the modal should close if the user taps on the backdrop
119
- *
120
- * @private
121
- * @memberof ModalManager
122
- */
123
- private closeOnBackdropClick = true;
124
-
125
- /**
126
- * A callback if the user closes the modal
127
- *
128
- * @private
129
- * @memberof ModalManager
130
- */
131
- private userClosedModalCallback?: () => void;
132
-
133
- /**
134
- * A callback if the user presses the left nav button
135
- *
136
- * @private
137
- * @memberof ModalManager
138
- */
139
- private userPressedLeftNavButtonCallback?: () => void;
140
-
141
- /**
142
- * Call the userClosedModalCallback and reset it if it exists
143
- *
144
- * @private
145
- * @memberof ModalManager
146
- */
147
- private callUserClosedModalCallback(): void {
148
- // we assign the callback to a temp var and undefine it before calling it
149
- // otherwise, we run into the potential for an infinite loop if the
150
- // callback triggers another `showModal()`, which would execute `userClosedModalCallback`
151
- const callback = this.userClosedModalCallback;
152
- this.userClosedModalCallback = undefined;
153
- if (callback) callback();
154
- }
155
-
156
- /**
157
- * Call the user pressed left nav button callback and reset it if it exists
158
- *
159
- * @private
160
- * @memberof ModalManager
161
- */
162
- private callUserPressedLeftNavButtonCallback(): void {
163
- // avoids an infinite showModal() loop, as above
164
- const callback = this.userPressedLeftNavButtonCallback;
165
- this.userPressedLeftNavButtonCallback = undefined;
166
- if (callback) callback();
167
- }
168
-
169
- /** @inheritdoc */
170
- async showModal(options: {
171
- config: ModalConfig;
172
- customModalContent?: TemplateResult;
173
- userClosedModalCallback?: () => void;
174
- userPressedLeftNavButtonCallback?: () => void;
175
- }): Promise<void> {
176
- this.closeOnBackdropClick = options.config.closeOnBackdropClick;
177
- this.userClosedModalCallback = options.userClosedModalCallback;
178
- this.userPressedLeftNavButtonCallback =
179
- options.userPressedLeftNavButtonCallback;
180
- this.customModalContent = options.customModalContent;
181
- this.mode = ModalManagerMode.Open;
182
- if (this.modalTemplate) {
183
- this.modalTemplate.config = options.config;
184
- await this.modalTemplate.updateComplete;
185
- this.modalTemplate.focus();
186
- }
187
- this.modal.activate();
188
- }
189
-
190
- /** @inheritdoc */
191
- updated(changed: PropertyValues): void {
192
- /* istanbul ignore else */
193
- if (changed.has('mode')) {
194
- this.handleModeChange();
195
- }
196
- }
197
-
198
- /**
199
- * Called when the backdrop is clicked
200
- *
201
- * @private
202
- * @memberof ModalManager
203
- */
204
- private backdropClicked(): void {
205
- if (this.closeOnBackdropClick) {
206
- this.closeModal();
207
- this.callUserClosedModalCallback();
208
- }
209
- }
210
-
211
- /**
212
- * Handle the mode change
213
- *
214
- * @private
215
- * @memberof ModalManager
216
- */
217
- private handleModeChange(): void {
218
- this.hostBridge.handleModeChange(this.mode);
219
- this.emitModeChangeEvent();
220
- }
221
-
222
- /**
223
- * Emit a modeChange event
224
- *
225
- * @private
226
- * @memberof ModalManager
227
- */
228
- private emitModeChangeEvent(): void {
229
- const event = new CustomEvent('modeChanged', {
230
- detail: { mode: this.mode },
231
- });
232
- this.dispatchEvent(event);
233
- }
234
-
235
- /**
236
- * Called when the modal close button is pressed. Closes the modal.
237
- *
238
- * @private
239
- * @memberof ModalManager
240
- */
241
- private closeButtonPressed(): void {
242
- this.closeModal();
243
- this.callUserClosedModalCallback();
244
- }
245
-
246
- /** @inheritdoc */
247
- static get styles(): CSSResult {
248
- const modalBackdropColor = css`var(--modalBackdropColor, rgba(10, 10, 10, 0.9))`;
249
- const modalBackdropZindex = css`var(--modalBackdropZindex, 1000)`;
250
-
251
- const modalWidth = css`var(--modalWidth, 32rem)`;
252
- const modalMaxWidth = css`var(--modalMaxWidth, 95%)`;
253
- const modalZindex = css`var(--modalZindex, 2000)`;
254
-
255
- return css`
256
- .container {
257
- width: 100%;
258
- height: 100%;
259
- }
260
-
261
- .backdrop {
262
- position: fixed;
263
- top: 0;
264
- left: 0;
265
- background-color: ${modalBackdropColor};
266
- width: 100%;
267
- height: 100%;
268
- z-index: ${modalBackdropZindex};
269
- }
270
-
271
- modal-template {
272
- outline: 0;
273
- position: fixed;
274
- top: 0;
275
- left: 50%;
276
- transform: translate(-50%, 0);
277
- z-index: ${modalZindex};
278
- width: ${modalWidth};
279
- max-width: ${modalMaxWidth};
280
- }
281
- `;
282
- }
283
- }
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
+ this.captureTriggeringElement();
188
+ this.closeOnBackdropClick = options.config.closeOnBackdropClick;
189
+ this.userClosedModalCallback = options.userClosedModalCallback;
190
+ this.userPressedLeftNavButtonCallback =
191
+ options.userPressedLeftNavButtonCallback;
192
+ this.customModalContent = options.customModalContent;
193
+ this.mode = ModalManagerMode.Open;
194
+ if (this.modalTemplate) {
195
+ this.modalTemplate.config = options.config;
196
+ await this.modalTemplate.updateComplete;
197
+ this.modalTemplate.focus();
198
+ }
199
+ this.modal.activate();
200
+ }
201
+
202
+ /**
203
+ * Sets the triggering element to the one that is currently focused, as deep
204
+ * within Shadow DOM as possible.
205
+ */
206
+ private captureTriggeringElement(): void {
207
+ this.triggeringElement = getDeepestActiveElement();
208
+ }
209
+
210
+ /** @inheritdoc */
211
+ updated(changed: PropertyValues): void {
212
+ /* istanbul ignore else */
213
+ if (changed.has('mode')) {
214
+ this.handleModeChange();
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Called when the backdrop is clicked
220
+ *
221
+ * @private
222
+ * @memberof ModalManager
223
+ */
224
+ private backdropClicked(): void {
225
+ if (this.closeOnBackdropClick) {
226
+ this.closeModal();
227
+ this.callUserClosedModalCallback();
228
+ }
229
+ }
230
+
231
+ /**
232
+ * Handle the mode change
233
+ *
234
+ * @private
235
+ * @memberof ModalManager
236
+ */
237
+ private handleModeChange(): void {
238
+ this.hostBridge.handleModeChange(this.mode);
239
+ this.emitModeChangeEvent();
240
+ }
241
+
242
+ /**
243
+ * Emit a modeChange event
244
+ *
245
+ * @private
246
+ * @memberof ModalManager
247
+ */
248
+ private emitModeChangeEvent(): void {
249
+ const event = new CustomEvent('modeChanged', {
250
+ detail: { mode: this.mode },
251
+ });
252
+ this.dispatchEvent(event);
253
+ }
254
+
255
+ /**
256
+ * Called when the modal close button is pressed. Closes the modal.
257
+ *
258
+ * @private
259
+ * @memberof ModalManager
260
+ */
261
+ private closeButtonPressed(): void {
262
+ this.closeModal();
263
+ this.callUserClosedModalCallback();
264
+ }
265
+
266
+ /** @inheritdoc */
267
+ static get styles(): CSSResult {
268
+ const modalBackdropColor = css`var(--modalBackdropColor, rgba(10, 10, 10, 0.9))`;
269
+ const modalBackdropZindex = css`var(--modalBackdropZindex, 1000)`;
270
+
271
+ const modalWidth = css`var(--modalWidth, 32rem)`;
272
+ const modalMaxWidth = css`var(--modalMaxWidth, 95%)`;
273
+ const modalZindex = css`var(--modalZindex, 2000)`;
274
+
275
+ return css`
276
+ .container {
277
+ width: 100%;
278
+ height: 100%;
279
+ }
280
+
281
+ .backdrop {
282
+ position: fixed;
283
+ top: 0;
284
+ left: 0;
285
+ background-color: ${modalBackdropColor};
286
+ width: 100%;
287
+ height: 100%;
288
+ z-index: ${modalBackdropZindex};
289
+ }
290
+
291
+ modal-template {
292
+ outline: 0;
293
+ position: fixed;
294
+ top: 0;
295
+ left: 50%;
296
+ transform: translate(-50%, 0);
297
+ z-index: ${modalZindex};
298
+ width: ${modalWidth};
299
+ max-width: ${modalMaxWidth};
300
+ }
301
+ `;
302
+ }
303
+ }