@spectrum-web-components/overlay 1.0.0 → 1.0.1-color-testing
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.
- package/package.json +7 -7
- package/src/Overlay.d.ts +349 -19
- package/src/Overlay.dev.js +276 -16
- package/src/Overlay.dev.js.map +2 -2
- package/src/Overlay.js +4 -4
- package/src/Overlay.js.map +3 -3
- package/src/OverlayDialog.dev.js +1 -0
- package/src/OverlayDialog.dev.js.map +2 -2
- package/src/OverlayDialog.js +1 -1
- package/src/OverlayDialog.js.map +2 -2
- package/src/OverlayPopover.dev.js +3 -3
- package/src/OverlayPopover.dev.js.map +2 -2
- package/src/OverlayPopover.js +1 -1
- package/src/OverlayPopover.js.map +2 -2
- package/src/OverlayStack.d.ts +2 -2
- package/src/OverlayStack.dev.js +8 -5
- package/src/OverlayStack.dev.js.map +2 -2
- package/src/OverlayStack.js +1 -1
- package/src/OverlayStack.js.map +3 -3
- package/src/PlacementController.d.ts +118 -1
- package/src/PlacementController.dev.js +75 -0
- package/src/PlacementController.dev.js.map +2 -2
- package/src/PlacementController.js.map +2 -2
- package/stories/index.js +9 -1
- package/stories/index.js.map +2 -2
- package/test/overlay-element.test.js +2 -4
- package/test/overlay-element.test.js.map +2 -2
- package/custom-elements.json +0 -3345
package/src/Overlay.dev.js
CHANGED
|
@@ -41,14 +41,14 @@ import {
|
|
|
41
41
|
SlottableRequestEvent
|
|
42
42
|
} from "./slottable-request-event.dev.js";
|
|
43
43
|
import styles from "./overlay.css.js";
|
|
44
|
-
const
|
|
45
|
-
let
|
|
46
|
-
if (
|
|
47
|
-
|
|
44
|
+
const browserSupportsPopover = "showPopover" in document.createElement("div");
|
|
45
|
+
let ComputedOverlayBase = OverlayDialog(AbstractOverlay);
|
|
46
|
+
if (browserSupportsPopover) {
|
|
47
|
+
ComputedOverlayBase = OverlayPopover(ComputedOverlayBase);
|
|
48
48
|
} else {
|
|
49
|
-
|
|
49
|
+
ComputedOverlayBase = OverlayNoPopover(ComputedOverlayBase);
|
|
50
50
|
}
|
|
51
|
-
const _Overlay = class _Overlay extends
|
|
51
|
+
const _Overlay = class _Overlay extends ComputedOverlayBase {
|
|
52
52
|
constructor() {
|
|
53
53
|
super(...arguments);
|
|
54
54
|
this._delayed = false;
|
|
@@ -57,14 +57,34 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
57
57
|
this._open = false;
|
|
58
58
|
/**
|
|
59
59
|
* The state in which the last `request-slottable` event was dispatched.
|
|
60
|
-
*
|
|
60
|
+
*
|
|
61
|
+
* This property ensures that overlays do not dispatch the same state twice in a row.
|
|
62
|
+
*
|
|
63
|
+
* @type {boolean}
|
|
64
|
+
* @default false
|
|
61
65
|
*/
|
|
62
66
|
this.lastRequestSlottableState = false;
|
|
63
67
|
this.receivesFocus = "auto";
|
|
64
68
|
this._state = "closed";
|
|
65
69
|
this.triggerElement = null;
|
|
66
70
|
this.type = "auto";
|
|
71
|
+
/**
|
|
72
|
+
* Tracks whether the overlay was previously open.
|
|
73
|
+
* This is used to restore the open state when re-enabling the overlay.
|
|
74
|
+
*
|
|
75
|
+
* @type {boolean}
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
67
78
|
this.wasOpen = false;
|
|
79
|
+
/**
|
|
80
|
+
* Handles the focus out event to close the overlay if the focus moves outside of it.
|
|
81
|
+
*
|
|
82
|
+
* This method ensures that the overlay is closed when the focus moves to an element
|
|
83
|
+
* outside of the overlay, unless the focus is moved to a related element.
|
|
84
|
+
*
|
|
85
|
+
* @private
|
|
86
|
+
* @param {FocusEvent} event - The focus out event.
|
|
87
|
+
*/
|
|
68
88
|
this.closeOnFocusOut = (event) => {
|
|
69
89
|
if (!event.relatedTarget) {
|
|
70
90
|
return;
|
|
@@ -107,9 +127,24 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
107
127
|
this.wasOpen = false;
|
|
108
128
|
}
|
|
109
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Determines if the overlay has a non-virtual trigger element.
|
|
132
|
+
*
|
|
133
|
+
* @returns {boolean} `true` if the trigger element is not a virtual trigger, otherwise `false`.
|
|
134
|
+
*/
|
|
110
135
|
get hasNonVirtualTrigger() {
|
|
111
136
|
return !!this.triggerElement && !(this.triggerElement instanceof VirtualTrigger);
|
|
112
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Provides an instance of the `PlacementController` for managing the positioning
|
|
140
|
+
* of the overlay relative to its trigger element.
|
|
141
|
+
*
|
|
142
|
+
* If the `PlacementController` instance does not already exist, it is created and
|
|
143
|
+
* assigned to the `_placementController` property.
|
|
144
|
+
*
|
|
145
|
+
* @protected
|
|
146
|
+
* @returns {PlacementController} The `PlacementController` instance.
|
|
147
|
+
*/
|
|
113
148
|
get placementController() {
|
|
114
149
|
if (!this._placementController) {
|
|
115
150
|
this._placementController = new PlacementController(this);
|
|
@@ -146,15 +181,36 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
146
181
|
}
|
|
147
182
|
this.requestUpdate("state", oldState);
|
|
148
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Provides an instance of the `ElementResolutionController` for managing the element
|
|
186
|
+
* that the overlay should be associated with. If the instance does not already exist,
|
|
187
|
+
* it is created and assigned to the `_elementResolver` property.
|
|
188
|
+
*
|
|
189
|
+
* @protected
|
|
190
|
+
* @returns {ElementResolutionController} The `ElementResolutionController` instance.
|
|
191
|
+
*/
|
|
149
192
|
get elementResolver() {
|
|
150
193
|
if (!this._elementResolver) {
|
|
151
194
|
this._elementResolver = new ElementResolutionController(this);
|
|
152
195
|
}
|
|
153
196
|
return this._elementResolver;
|
|
154
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Determines if the overlay uses a dialog.
|
|
200
|
+
* Returns `true` if the overlay type is "modal" or "page".
|
|
201
|
+
*
|
|
202
|
+
* @private
|
|
203
|
+
* @returns {boolean} `true` if the overlay uses a dialog, otherwise `false`.
|
|
204
|
+
*/
|
|
155
205
|
get usesDialog() {
|
|
156
206
|
return this.type === "modal" || this.type === "page";
|
|
157
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Determines the value for the popover attribute based on the overlay type.
|
|
210
|
+
*
|
|
211
|
+
* @private
|
|
212
|
+
* @returns {'auto' | 'manual' | undefined} The popover value or undefined if not applicable.
|
|
213
|
+
*/
|
|
158
214
|
get popoverValue() {
|
|
159
215
|
const hasPopoverAttribute = "popover" in this;
|
|
160
216
|
if (!hasPopoverAttribute) {
|
|
@@ -170,14 +226,30 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
170
226
|
return this.type;
|
|
171
227
|
}
|
|
172
228
|
}
|
|
173
|
-
|
|
229
|
+
/**
|
|
230
|
+
* Determines if the overlay requires positioning based on its type and state.
|
|
231
|
+
*
|
|
232
|
+
* @protected
|
|
233
|
+
* @returns {boolean} True if the overlay requires positioning, otherwise false.
|
|
234
|
+
*/
|
|
235
|
+
get requiresPositioning() {
|
|
174
236
|
if (this.type === "page" || !this.open) return false;
|
|
175
237
|
if (!this.triggerElement || !this.placement && this.type !== "hint")
|
|
176
238
|
return false;
|
|
177
239
|
return true;
|
|
178
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Manages the positioning of the overlay relative to its trigger element.
|
|
243
|
+
*
|
|
244
|
+
* This method calculates the necessary parameters for positioning the overlay,
|
|
245
|
+
* such as offset, placement, and tip padding, and then delegates the actual
|
|
246
|
+
* positioning to the `PlacementController`.
|
|
247
|
+
*
|
|
248
|
+
* @protected
|
|
249
|
+
* @override
|
|
250
|
+
*/
|
|
179
251
|
managePosition() {
|
|
180
|
-
if (!this.
|
|
252
|
+
if (!this.requiresPositioning || !this.open) return;
|
|
181
253
|
const offset = this.offset || 0;
|
|
182
254
|
const trigger = this.triggerElement;
|
|
183
255
|
const placement = this.placement || "right";
|
|
@@ -190,6 +262,16 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
190
262
|
type: this.type
|
|
191
263
|
});
|
|
192
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* Manages the process of opening the popover.
|
|
267
|
+
*
|
|
268
|
+
* This method handles the necessary steps to open the popover, including managing delays,
|
|
269
|
+
* ensuring the popover is in the DOM, making transitions, and applying focus.
|
|
270
|
+
*
|
|
271
|
+
* @protected
|
|
272
|
+
* @override
|
|
273
|
+
* @returns {Promise<void>} A promise that resolves when the popover has been fully opened.
|
|
274
|
+
*/
|
|
193
275
|
async managePopoverOpen() {
|
|
194
276
|
super.managePopoverOpen();
|
|
195
277
|
const targetOpenState = this.open;
|
|
@@ -210,6 +292,18 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
210
292
|
}
|
|
211
293
|
await this.applyFocus(targetOpenState, focusEl);
|
|
212
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Applies focus to the appropriate element after the popover has been opened.
|
|
297
|
+
*
|
|
298
|
+
* This method handles the focus management for the overlay, ensuring that the correct
|
|
299
|
+
* element receives focus based on the overlay's type and state.
|
|
300
|
+
*
|
|
301
|
+
* @protected
|
|
302
|
+
* @override
|
|
303
|
+
* @param {boolean} targetOpenState - The target open state of the overlay.
|
|
304
|
+
* @param {HTMLElement | null} focusEl - The element to focus after opening the popover.
|
|
305
|
+
* @returns {Promise<void>} A promise that resolves when the focus has been applied.
|
|
306
|
+
*/
|
|
213
307
|
async applyFocus(targetOpenState, focusEl) {
|
|
214
308
|
if (this.receivesFocus === "false" || this.type === "hint") {
|
|
215
309
|
return;
|
|
@@ -224,6 +318,15 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
224
318
|
}
|
|
225
319
|
focusEl == null ? void 0 : focusEl.focus();
|
|
226
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Returns focus to the trigger element if the overlay is closed.
|
|
323
|
+
*
|
|
324
|
+
* This method ensures that focus is returned to the trigger element when the overlay is closed,
|
|
325
|
+
* unless the overlay is of type "hint" or the focus is already outside the overlay.
|
|
326
|
+
*
|
|
327
|
+
* @protected
|
|
328
|
+
* @override
|
|
329
|
+
*/
|
|
227
330
|
returnFocus() {
|
|
228
331
|
var _a;
|
|
229
332
|
if (this.open || this.type === "hint") return;
|
|
@@ -248,6 +351,16 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
248
351
|
this.triggerElement.focus();
|
|
249
352
|
}
|
|
250
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Manages the process of opening or closing the overlay.
|
|
356
|
+
*
|
|
357
|
+
* This method handles the necessary steps to open or close the overlay, including updating the state,
|
|
358
|
+
* managing the overlay stack, and handling focus events.
|
|
359
|
+
*
|
|
360
|
+
* @protected
|
|
361
|
+
* @param {boolean} oldOpen - The previous open state of the overlay.
|
|
362
|
+
* @returns {Promise<void>} A promise that resolves when the overlay has been fully managed.
|
|
363
|
+
*/
|
|
251
364
|
async manageOpen(oldOpen) {
|
|
252
365
|
if (!this.isConnected && this.open) return;
|
|
253
366
|
if (!this.hasUpdated) {
|
|
@@ -305,6 +418,14 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
305
418
|
}
|
|
306
419
|
}
|
|
307
420
|
}
|
|
421
|
+
/**
|
|
422
|
+
* Binds event handling strategies to the overlay based on the specified trigger interaction.
|
|
423
|
+
*
|
|
424
|
+
* This method sets up the appropriate event handling strategy for the overlay, ensuring that
|
|
425
|
+
* it responds correctly to user interactions such as clicks, hovers, or long presses.
|
|
426
|
+
*
|
|
427
|
+
* @protected
|
|
428
|
+
*/
|
|
308
429
|
bindEvents() {
|
|
309
430
|
var _a;
|
|
310
431
|
(_a = this.strategy) == null ? void 0 : _a.abort();
|
|
@@ -318,24 +439,60 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
318
439
|
}
|
|
319
440
|
);
|
|
320
441
|
}
|
|
442
|
+
/**
|
|
443
|
+
* Handles the `beforetoggle` event to manage the overlay's state.
|
|
444
|
+
*
|
|
445
|
+
* This method checks the new state of the event and calls `handleBrowserClose`
|
|
446
|
+
* if the new state is not 'open'.
|
|
447
|
+
*
|
|
448
|
+
* @protected
|
|
449
|
+
* @param {Event & { newState: string }} event - The `beforetoggle` event with the new state.
|
|
450
|
+
*/
|
|
321
451
|
handleBeforetoggle(event) {
|
|
322
452
|
if (event.newState !== "open") {
|
|
323
|
-
this.handleBrowserClose();
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
453
|
+
this.handleBrowserClose(event);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Handles the browser's close event to manage the overlay's state.
|
|
458
|
+
*
|
|
459
|
+
* This method stops the propagation of the event and closes the overlay if it is not
|
|
460
|
+
* actively opening. If the overlay is actively opening, it calls `manuallyKeepOpen`.
|
|
461
|
+
*
|
|
462
|
+
* @protected
|
|
463
|
+
* @param {Event} event - The browser's close event.
|
|
464
|
+
*/
|
|
465
|
+
handleBrowserClose(event) {
|
|
327
466
|
var _a;
|
|
467
|
+
event.stopPropagation();
|
|
328
468
|
if (!((_a = this.strategy) == null ? void 0 : _a.activelyOpening)) {
|
|
329
469
|
this.open = false;
|
|
330
470
|
return;
|
|
331
471
|
}
|
|
332
472
|
this.manuallyKeepOpen();
|
|
333
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* Manually keeps the overlay open.
|
|
476
|
+
*
|
|
477
|
+
* This method sets the overlay to open, allows placement updates, and manages the open state.
|
|
478
|
+
*
|
|
479
|
+
* @public
|
|
480
|
+
* @override
|
|
481
|
+
*/
|
|
334
482
|
manuallyKeepOpen() {
|
|
335
483
|
this.open = true;
|
|
336
484
|
this.placementController.allowPlacementUpdate = true;
|
|
337
485
|
this.manageOpen(false);
|
|
338
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* Handles the `slotchange` event to manage the overlay's state.
|
|
489
|
+
*
|
|
490
|
+
* This method checks if there are any elements in the slot. If there are no elements,
|
|
491
|
+
* it releases the description from the strategy. If there are elements and the trigger
|
|
492
|
+
* is non-virtual, it prepares the description for the trigger element.
|
|
493
|
+
*
|
|
494
|
+
* @protected
|
|
495
|
+
*/
|
|
339
496
|
handleSlotchange() {
|
|
340
497
|
var _a, _b;
|
|
341
498
|
if (!this.elements.length) {
|
|
@@ -346,11 +503,30 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
346
503
|
);
|
|
347
504
|
}
|
|
348
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* Determines whether the overlay should prevent closing.
|
|
508
|
+
*
|
|
509
|
+
* This method checks the `willPreventClose` flag and resets it to `false`.
|
|
510
|
+
* It returns the value of the `willPreventClose` flag.
|
|
511
|
+
*
|
|
512
|
+
* @public
|
|
513
|
+
* @returns {boolean} `true` if the overlay should prevent closing, otherwise `false`.
|
|
514
|
+
*/
|
|
349
515
|
shouldPreventClose() {
|
|
350
516
|
const shouldPreventClose = this.willPreventClose;
|
|
351
517
|
this.willPreventClose = false;
|
|
352
518
|
return shouldPreventClose;
|
|
353
519
|
}
|
|
520
|
+
/**
|
|
521
|
+
* Requests slottable content for the overlay.
|
|
522
|
+
*
|
|
523
|
+
* This method dispatches a `SlottableRequestEvent` to request or remove slottable content
|
|
524
|
+
* based on the current open state of the overlay. It ensures that the same state is not
|
|
525
|
+
* dispatched twice in a row.
|
|
526
|
+
*
|
|
527
|
+
* @protected
|
|
528
|
+
* @override
|
|
529
|
+
*/
|
|
354
530
|
requestSlottable() {
|
|
355
531
|
if (this.lastRequestSlottableState === this.open) {
|
|
356
532
|
return;
|
|
@@ -366,6 +542,15 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
366
542
|
);
|
|
367
543
|
this.lastRequestSlottableState = this.open;
|
|
368
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* Lifecycle method called before the component updates.
|
|
547
|
+
*
|
|
548
|
+
* This method handles various tasks before the component updates, such as setting an ID,
|
|
549
|
+
* managing the open state, resolving the trigger element, and binding events.
|
|
550
|
+
*
|
|
551
|
+
* @override
|
|
552
|
+
* @param {PropertyValues} changes - The properties that have changed.
|
|
553
|
+
*/
|
|
369
554
|
willUpdate(changes) {
|
|
370
555
|
var _a;
|
|
371
556
|
if (!this.hasAttribute("id")) {
|
|
@@ -394,6 +579,15 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
394
579
|
this.bindEvents();
|
|
395
580
|
}
|
|
396
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* Lifecycle method called after the component updates.
|
|
584
|
+
*
|
|
585
|
+
* This method handles various tasks after the component updates, such as updating the placement
|
|
586
|
+
* attribute, resetting the overlay position, and clearing the overlay position based on the state.
|
|
587
|
+
*
|
|
588
|
+
* @override
|
|
589
|
+
* @param {PropertyValues} changes - The properties that have changed.
|
|
590
|
+
*/
|
|
397
591
|
updated(changes) {
|
|
398
592
|
super.updated(changes);
|
|
399
593
|
if (changes.has("placement")) {
|
|
@@ -410,23 +604,50 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
410
604
|
this.placementController.clearOverlayPosition();
|
|
411
605
|
}
|
|
412
606
|
}
|
|
607
|
+
/**
|
|
608
|
+
* Renders the content of the overlay.
|
|
609
|
+
*
|
|
610
|
+
* This method returns a template result containing a slot element. The slot element
|
|
611
|
+
* listens for the `slotchange` event to manage the overlay's state.
|
|
612
|
+
*
|
|
613
|
+
* @protected
|
|
614
|
+
* @returns {TemplateResult} The template result containing the slot element.
|
|
615
|
+
*/
|
|
413
616
|
renderContent() {
|
|
414
617
|
return html`
|
|
415
618
|
<slot @slotchange=${this.handleSlotchange}></slot>
|
|
416
619
|
`;
|
|
417
620
|
}
|
|
621
|
+
/**
|
|
622
|
+
* Generates a style map for the dialog element.
|
|
623
|
+
*
|
|
624
|
+
* This method returns an object containing CSS custom properties for the dialog element.
|
|
625
|
+
* The `--swc-overlay-open-count` custom property is set to the current open count of overlays.
|
|
626
|
+
*
|
|
627
|
+
* @private
|
|
628
|
+
* @returns {StyleInfo} The style map for the dialog element.
|
|
629
|
+
*/
|
|
418
630
|
get dialogStyleMap() {
|
|
419
631
|
return {
|
|
420
632
|
"--swc-overlay-open-count": _Overlay.openCount.toString()
|
|
421
633
|
};
|
|
422
634
|
}
|
|
635
|
+
/**
|
|
636
|
+
* Renders the dialog element for the overlay.
|
|
637
|
+
*
|
|
638
|
+
* This method returns a template result containing a dialog element. The dialog element
|
|
639
|
+
* includes various attributes and event listeners to manage the overlay's state and behavior.
|
|
640
|
+
*
|
|
641
|
+
* @protected
|
|
642
|
+
* @returns {TemplateResult} The template result containing the dialog element.
|
|
643
|
+
*/
|
|
423
644
|
renderDialog() {
|
|
424
645
|
return html`
|
|
425
646
|
<dialog
|
|
426
647
|
class="dialog"
|
|
427
648
|
part="dialog"
|
|
428
649
|
placement=${ifDefined(
|
|
429
|
-
this.
|
|
650
|
+
this.requiresPositioning ? this.placement || "right" : void 0
|
|
430
651
|
)}
|
|
431
652
|
style=${styleMap(this.dialogStyleMap)}
|
|
432
653
|
@close=${this.handleBrowserClose}
|
|
@@ -438,13 +659,22 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
438
659
|
</dialog>
|
|
439
660
|
`;
|
|
440
661
|
}
|
|
662
|
+
/**
|
|
663
|
+
* Renders the popover element for the overlay.
|
|
664
|
+
*
|
|
665
|
+
* This method returns a template result containing a div element styled as a popover.
|
|
666
|
+
* The popover element includes various attributes and event listeners to manage the overlay's state and behavior.
|
|
667
|
+
*
|
|
668
|
+
* @protected
|
|
669
|
+
* @returns {TemplateResult} The template result containing the popover element.
|
|
670
|
+
*/
|
|
441
671
|
renderPopover() {
|
|
442
672
|
return html`
|
|
443
673
|
<div
|
|
444
674
|
class="dialog"
|
|
445
675
|
part="dialog"
|
|
446
676
|
placement=${ifDefined(
|
|
447
|
-
this.
|
|
677
|
+
this.requiresPositioning ? this.placement || "right" : void 0
|
|
448
678
|
)}
|
|
449
679
|
popover=${ifDefined(this.popoverValue)}
|
|
450
680
|
style=${styleMap(this.dialogStyleMap)}
|
|
@@ -456,6 +686,15 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
456
686
|
</div>
|
|
457
687
|
`;
|
|
458
688
|
}
|
|
689
|
+
/**
|
|
690
|
+
* Renders the overlay component.
|
|
691
|
+
*
|
|
692
|
+
* This method returns a template result containing either a dialog or popover element
|
|
693
|
+
* based on the overlay type. It also includes a slot for longpress descriptors.
|
|
694
|
+
*
|
|
695
|
+
* @override
|
|
696
|
+
* @returns {TemplateResult} The template result containing the overlay content.
|
|
697
|
+
*/
|
|
459
698
|
render() {
|
|
460
699
|
const isDialog = this.type === "modal" || this.type === "page";
|
|
461
700
|
return html`
|
|
@@ -463,6 +702,13 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
463
702
|
<slot name="longpress-describedby-descriptor"></slot>
|
|
464
703
|
`;
|
|
465
704
|
}
|
|
705
|
+
/**
|
|
706
|
+
* Lifecycle method called when the component is added to the DOM.
|
|
707
|
+
*
|
|
708
|
+
* This method sets up event listeners and binds events if the component has already updated.
|
|
709
|
+
*
|
|
710
|
+
* @override
|
|
711
|
+
*/
|
|
466
712
|
connectedCallback() {
|
|
467
713
|
super.connectedCallback();
|
|
468
714
|
this.addEventListener("close", () => {
|
|
@@ -472,6 +718,13 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
472
718
|
this.bindEvents();
|
|
473
719
|
}
|
|
474
720
|
}
|
|
721
|
+
/**
|
|
722
|
+
* Lifecycle method called when the component is removed from the DOM.
|
|
723
|
+
*
|
|
724
|
+
* This method releases the description from the strategy and updates the 'open' property.
|
|
725
|
+
*
|
|
726
|
+
* @override
|
|
727
|
+
*/
|
|
475
728
|
disconnectedCallback() {
|
|
476
729
|
var _a;
|
|
477
730
|
(_a = this.strategy) == null ? void 0 : _a.releaseDescription();
|
|
@@ -480,6 +733,14 @@ const _Overlay = class _Overlay extends OverlayFeatures {
|
|
|
480
733
|
}
|
|
481
734
|
};
|
|
482
735
|
_Overlay.styles = [styles];
|
|
736
|
+
/**
|
|
737
|
+
* Tracks the number of overlays that have been opened.
|
|
738
|
+
*
|
|
739
|
+
* This static property is used to manage the stacking context of multiple overlays.
|
|
740
|
+
*
|
|
741
|
+
* @type {number}
|
|
742
|
+
* @default 1
|
|
743
|
+
*/
|
|
483
744
|
_Overlay.openCount = 1;
|
|
484
745
|
__decorateClass([
|
|
485
746
|
property({ type: Boolean })
|
|
@@ -494,7 +755,6 @@ __decorateClass([
|
|
|
494
755
|
queryAssignedElements({
|
|
495
756
|
flatten: true,
|
|
496
757
|
selector: ':not([slot="longpress-describedby-descriptor"], slot)'
|
|
497
|
-
// gather only elements slotted into the default slot
|
|
498
758
|
})
|
|
499
759
|
], _Overlay.prototype, "elements", 2);
|
|
500
760
|
__decorateClass([
|