@vaadin/overlay 23.3.3 → 24.0.0-alpha10
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/overlay",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "24.0.0-alpha10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/vaadin/web-components.git",
|
|
12
|
-
"directory": "packages/overlay"
|
|
12
|
+
"directory": "packages/vaadin-overlay"
|
|
13
13
|
},
|
|
14
14
|
"author": "Vaadin Ltd",
|
|
15
15
|
"homepage": "https://vaadin.com/components",
|
|
@@ -36,20 +36,16 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
38
|
"@polymer/polymer": "^3.0.0",
|
|
39
|
-
"@vaadin/component-base": "
|
|
40
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
41
|
-
"@vaadin/vaadin-material-styles": "
|
|
42
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
39
|
+
"@vaadin/component-base": "24.0.0-alpha10",
|
|
40
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha10",
|
|
41
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha10",
|
|
42
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha10"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@esm-bundle/chai": "^4.3.4",
|
|
46
|
-
"@polymer/iron-overlay-behavior": "^3.0.0",
|
|
47
|
-
"@vaadin/button": "~23.3.3",
|
|
48
|
-
"@vaadin/radio-group": "~23.3.3",
|
|
49
46
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
50
|
-
"@vaadin/text-field": "~23.3.3",
|
|
51
47
|
"lit": "^2.0.0",
|
|
52
48
|
"sinon": "^13.0.2"
|
|
53
49
|
},
|
|
54
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "2e04534d8b47bcd216f89b5f849bafef1a73b174"
|
|
55
51
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2017 -
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2017 -
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { getAncestorRootNodes } from '@vaadin/component-base/src/dom-utils.js';
|
|
@@ -178,10 +178,6 @@ export const PositionMixin = (superClass) =>
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
get __isRTL() {
|
|
182
|
-
return this.getAttribute('dir') === 'rtl';
|
|
183
|
-
}
|
|
184
|
-
|
|
185
181
|
__positionSettingsChanged() {
|
|
186
182
|
this._updatePosition();
|
|
187
183
|
}
|
|
@@ -205,9 +201,9 @@ export const PositionMixin = (superClass) =>
|
|
|
205
201
|
const shouldAlignStartVertically = this.__shouldAlignStartVertically(targetRect);
|
|
206
202
|
this.style.justifyContent = shouldAlignStartVertically ? 'flex-start' : 'flex-end';
|
|
207
203
|
|
|
208
|
-
const
|
|
209
|
-
const
|
|
210
|
-
|
|
204
|
+
const isRTL = this.__isRTL;
|
|
205
|
+
const shouldAlignStartHorizontally = this.__shouldAlignStartHorizontally(targetRect, isRTL);
|
|
206
|
+
const flexStart = (!isRTL && shouldAlignStartHorizontally) || (isRTL && !shouldAlignStartHorizontally);
|
|
211
207
|
this.style.alignItems = flexStart ? 'flex-start' : 'flex-end';
|
|
212
208
|
|
|
213
209
|
// Get the overlay rect after possible overlay alignment changes
|
package/src/vaadin-overlay.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2017 -
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
@@ -55,13 +55,10 @@ export type OverlayEventMap = HTMLElementEventMap & OverlayCustomEventMap;
|
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* `<vaadin-overlay>` is a Web Component for creating overlays. The content of the overlay
|
|
58
|
-
* can be populated
|
|
59
|
-
* declaratively by using Polymer's Templates.
|
|
58
|
+
* can be populated imperatively by using `renderer` callback function.
|
|
60
59
|
*
|
|
61
60
|
* ### Rendering
|
|
62
61
|
*
|
|
63
|
-
* By default, the overlay uses the content provided by using the renderer callback function.
|
|
64
|
-
*
|
|
65
62
|
* The renderer function provides `root`, `owner`, `model` arguments when applicable.
|
|
66
63
|
* Generate DOM content by using `model` object properties if needed, append it to the `root`
|
|
67
64
|
* element and control the state of the host element by accessing `owner`. Before generating new
|
|
@@ -82,39 +79,9 @@ export type OverlayEventMap = HTMLElementEventMap & OverlayCustomEventMap;
|
|
|
82
79
|
* in the next renderer call and will be provided with the `root` argument.
|
|
83
80
|
* On first call it will be empty.
|
|
84
81
|
*
|
|
85
|
-
* **NOTE:** when the renderer property is defined, the `<template>` content is not used.
|
|
86
|
-
*
|
|
87
|
-
* ### Templating
|
|
88
|
-
*
|
|
89
|
-
* Alternatively, the content can be provided with Polymer Template.
|
|
90
|
-
* Overlay finds the first child template and uses that in case renderer callback function
|
|
91
|
-
* is not provided. You can also set a custom template using the `template` property.
|
|
92
|
-
*
|
|
93
|
-
* After the content from the template is stamped, the `content` property
|
|
94
|
-
* points to the content container.
|
|
95
|
-
*
|
|
96
|
-
* The overlay provides `forwardHostProp` when calling
|
|
97
|
-
* `Polymer.Templatize.templatize` for the template, so that the bindings
|
|
98
|
-
* from the parent scope propagate to the content.
|
|
99
|
-
*
|
|
100
|
-
* ```html
|
|
101
|
-
* <vaadin-overlay>
|
|
102
|
-
* <template>Overlay content</template>
|
|
103
|
-
* </vaadin-overlay>
|
|
104
|
-
* ```
|
|
105
|
-
*
|
|
106
82
|
* ### Styling
|
|
107
83
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* - If the overlay is used in a component, then the component styles
|
|
111
|
-
* apply the overlay content.
|
|
112
|
-
* - If the overlay is used in the global DOM scope, then global styles
|
|
113
|
-
* apply to the overlay content.
|
|
114
|
-
*
|
|
115
|
-
* See examples for styling the overlay content in the live demos.
|
|
116
|
-
*
|
|
117
|
-
* The following Shadow DOM parts are available for styling the overlay component itself:
|
|
84
|
+
* The following Shadow DOM parts are available for styling:
|
|
118
85
|
*
|
|
119
86
|
* Part name | Description
|
|
120
87
|
* -----------|---------------------------------------------------------|
|
|
@@ -165,16 +132,6 @@ declare class Overlay extends ThemableMixin(DirMixin(ControllerMixin(HTMLElement
|
|
|
165
132
|
*/
|
|
166
133
|
renderer: OverlayRenderer | null | undefined;
|
|
167
134
|
|
|
168
|
-
/**
|
|
169
|
-
* The template of the overlay content.
|
|
170
|
-
*/
|
|
171
|
-
template: HTMLTemplateElement | null | undefined;
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* References the content container after the template is stamped.
|
|
175
|
-
*/
|
|
176
|
-
content: HTMLElement | undefined;
|
|
177
|
-
|
|
178
135
|
/**
|
|
179
136
|
* When true the overlay has backdrop on top of content when opened.
|
|
180
137
|
*/
|
package/src/vaadin-overlay.js
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2017 -
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
|
|
7
6
|
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
8
|
-
import { templatize } from '@polymer/polymer/lib/utils/templatize.js';
|
|
9
7
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
10
8
|
import { isIOS } from '@vaadin/component-base/src/browser-utils.js';
|
|
11
9
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
12
10
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
13
11
|
import { FocusTrapController } from '@vaadin/component-base/src/focus-trap-controller.js';
|
|
12
|
+
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
14
13
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
18
16
|
* `<vaadin-overlay>` is a Web Component for creating overlays. The content of the overlay
|
|
19
|
-
* can be populated
|
|
20
|
-
* declaratively by using Polymer's Templates.
|
|
17
|
+
* can be populated imperatively by using `renderer` callback function.
|
|
21
18
|
*
|
|
22
19
|
* ### Rendering
|
|
23
20
|
*
|
|
24
|
-
* By default, the overlay uses the content provided by using the renderer callback function.
|
|
25
|
-
*
|
|
26
21
|
* The renderer function provides `root`, `owner`, `model` arguments when applicable.
|
|
27
22
|
* Generate DOM content by using `model` object properties if needed, append it to the `root`
|
|
28
23
|
* element and control the state of the host element by accessing `owner`. Before generating new
|
|
@@ -43,33 +38,9 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
43
38
|
* in the next renderer call and will be provided with the `root` argument.
|
|
44
39
|
* On first call it will be empty.
|
|
45
40
|
*
|
|
46
|
-
* **NOTE:** when the renderer property is defined, the `<template>` content is not used.
|
|
47
|
-
*
|
|
48
|
-
* ### Templating
|
|
49
|
-
*
|
|
50
|
-
* Alternatively, the content can be provided with Polymer Template.
|
|
51
|
-
* Overlay finds the first child template and uses that in case renderer callback function
|
|
52
|
-
* is not provided. You can also set a custom template using the `template` property.
|
|
53
|
-
*
|
|
54
|
-
* After the content from the template is stamped, the `content` property
|
|
55
|
-
* points to the content container.
|
|
56
|
-
*
|
|
57
|
-
* The overlay provides `forwardHostProp` when calling
|
|
58
|
-
* `Polymer.Templatize.templatize` for the template, so that the bindings
|
|
59
|
-
* from the parent scope propagate to the content.
|
|
60
|
-
*
|
|
61
41
|
* ### Styling
|
|
62
42
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* - If the overlay is used in a component, then the component styles
|
|
66
|
-
* apply the overlay content.
|
|
67
|
-
* - If the overlay is used in the global DOM scope, then global styles
|
|
68
|
-
* apply to the overlay content.
|
|
69
|
-
*
|
|
70
|
-
* See examples for styling the overlay content in the live demos.
|
|
71
|
-
*
|
|
72
|
-
* The following Shadow DOM parts are available for styling the overlay component itself:
|
|
43
|
+
* The following Shadow DOM parts are available for styling:
|
|
73
44
|
*
|
|
74
45
|
* Part name | Description
|
|
75
46
|
* -----------|---------------------------------------------------------|
|
|
@@ -214,24 +185,6 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
214
185
|
*/
|
|
215
186
|
renderer: Function,
|
|
216
187
|
|
|
217
|
-
/**
|
|
218
|
-
* The template of the overlay content.
|
|
219
|
-
* @type {HTMLTemplateElement | null | undefined}
|
|
220
|
-
*/
|
|
221
|
-
template: {
|
|
222
|
-
type: Object,
|
|
223
|
-
notify: true,
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* References the content container after the template is stamped.
|
|
228
|
-
* @type {!HTMLElement | undefined}
|
|
229
|
-
*/
|
|
230
|
-
content: {
|
|
231
|
-
type: Object,
|
|
232
|
-
notify: true,
|
|
233
|
-
},
|
|
234
|
-
|
|
235
188
|
/**
|
|
236
189
|
* When true the overlay has backdrop on top of content when opened.
|
|
237
190
|
* @type {boolean}
|
|
@@ -308,26 +261,12 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
308
261
|
type: Boolean,
|
|
309
262
|
},
|
|
310
263
|
|
|
311
|
-
/** @private */
|
|
312
|
-
_instance: {
|
|
313
|
-
type: Object,
|
|
314
|
-
},
|
|
315
|
-
|
|
316
|
-
/** @private */
|
|
317
|
-
_originalContentPart: Object,
|
|
318
|
-
|
|
319
|
-
/** @private */
|
|
320
|
-
_contentNodes: Array,
|
|
321
|
-
|
|
322
264
|
/** @private */
|
|
323
265
|
_oldOwner: Element,
|
|
324
266
|
|
|
325
267
|
/** @private */
|
|
326
268
|
_oldModel: Object,
|
|
327
269
|
|
|
328
|
-
/** @private */
|
|
329
|
-
_oldTemplate: Object,
|
|
330
|
-
|
|
331
270
|
/** @private */
|
|
332
271
|
_oldRenderer: Object,
|
|
333
272
|
|
|
@@ -337,7 +276,17 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
337
276
|
}
|
|
338
277
|
|
|
339
278
|
static get observers() {
|
|
340
|
-
return ['
|
|
279
|
+
return ['_rendererOrDataChanged(renderer, owner, model, opened)'];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Returns all attached overlays in visual stacking order.
|
|
284
|
+
* @private
|
|
285
|
+
*/
|
|
286
|
+
static get __attachedInstances() {
|
|
287
|
+
return Array.from(document.body.children)
|
|
288
|
+
.filter((el) => el instanceof Overlay && !el.hasAttribute('closing'))
|
|
289
|
+
.sort((a, b) => a.__zIndex - b.__zIndex || 0);
|
|
341
290
|
}
|
|
342
291
|
|
|
343
292
|
constructor() {
|
|
@@ -347,13 +296,6 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
347
296
|
this._boundOutsideClickListener = this._outsideClickListener.bind(this);
|
|
348
297
|
this._boundKeydownListener = this._keydownListener.bind(this);
|
|
349
298
|
|
|
350
|
-
this._observer = new FlattenedNodesObserver(this, (info) => {
|
|
351
|
-
this._setTemplateFromNodes(info.addedNodes);
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
// Listener for preventing closing of the paper-dialog and all components extending `iron-overlay-behavior`.
|
|
355
|
-
this._boundIronOverlayCanceledListener = this._ironOverlayCanceled.bind(this);
|
|
356
|
-
|
|
357
299
|
/* c8 ignore next 3 */
|
|
358
300
|
if (isIOS) {
|
|
359
301
|
this._boundIosResizeListener = () => this._detectIosNavbar();
|
|
@@ -362,12 +304,19 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
362
304
|
this.__focusTrapController = new FocusTrapController(this);
|
|
363
305
|
}
|
|
364
306
|
|
|
307
|
+
/**
|
|
308
|
+
* Returns true if this is the last one in the opened overlays stack
|
|
309
|
+
* @return {boolean}
|
|
310
|
+
* @protected
|
|
311
|
+
*/
|
|
312
|
+
get _last() {
|
|
313
|
+
return this === Overlay.__attachedInstances.pop();
|
|
314
|
+
}
|
|
315
|
+
|
|
365
316
|
/** @protected */
|
|
366
317
|
ready() {
|
|
367
318
|
super.ready();
|
|
368
319
|
|
|
369
|
-
this._observer.flush();
|
|
370
|
-
|
|
371
320
|
// Need to add dummy click listeners to this and the backdrop or else
|
|
372
321
|
// the document click event listener (_outsideClickListener) may never
|
|
373
322
|
// get invoked on iOS Safari (reproducible in <vaadin-dialog>
|
|
@@ -376,6 +325,8 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
376
325
|
this.$.backdrop.addEventListener('click', () => {});
|
|
377
326
|
|
|
378
327
|
this.addController(this.__focusTrapController);
|
|
328
|
+
|
|
329
|
+
processTemplates(this);
|
|
379
330
|
}
|
|
380
331
|
|
|
381
332
|
/** @private */
|
|
@@ -399,14 +350,6 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
399
350
|
}
|
|
400
351
|
}
|
|
401
352
|
|
|
402
|
-
/**
|
|
403
|
-
* @param {!Array<!Element>} nodes
|
|
404
|
-
* @protected
|
|
405
|
-
*/
|
|
406
|
-
_setTemplateFromNodes(nodes) {
|
|
407
|
-
this.template = nodes.find((node) => node.localName && node.localName === 'template') || this.template;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
353
|
/**
|
|
411
354
|
* @param {Event=} sourceEvent
|
|
412
355
|
* @event vaadin-overlay-close
|
|
@@ -453,15 +396,10 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
453
396
|
*/
|
|
454
397
|
requestContentUpdate() {
|
|
455
398
|
if (this.renderer) {
|
|
456
|
-
this.renderer.call(this.owner, this
|
|
399
|
+
this.renderer.call(this.owner, this, this.owner, this.model);
|
|
457
400
|
}
|
|
458
401
|
}
|
|
459
402
|
|
|
460
|
-
/** @private */
|
|
461
|
-
_ironOverlayCanceled(event) {
|
|
462
|
-
event.preventDefault();
|
|
463
|
-
}
|
|
464
|
-
|
|
465
403
|
/** @private */
|
|
466
404
|
_mouseDownListener(event) {
|
|
467
405
|
this._mouseDownInside = event.composedPath().indexOf(this.$.overlay) >= 0;
|
|
@@ -534,11 +472,6 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
534
472
|
}
|
|
535
473
|
}
|
|
536
474
|
|
|
537
|
-
/** @protected */
|
|
538
|
-
_ensureTemplatized() {
|
|
539
|
-
this._setTemplateFromNodes(Array.from(this.children));
|
|
540
|
-
}
|
|
541
|
-
|
|
542
475
|
/**
|
|
543
476
|
* @event vaadin-overlay-open
|
|
544
477
|
* fired after the `vaadin-overlay` is opened.
|
|
@@ -546,10 +479,6 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
546
479
|
* @private
|
|
547
480
|
*/
|
|
548
481
|
_openedChanged(opened, wasOpened) {
|
|
549
|
-
if (!this._instance) {
|
|
550
|
-
this._ensureTemplatized();
|
|
551
|
-
}
|
|
552
|
-
|
|
553
482
|
if (opened) {
|
|
554
483
|
// Store focused node.
|
|
555
484
|
this.__restoreFocusNode = this._getActiveElement();
|
|
@@ -661,13 +590,11 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
661
590
|
|
|
662
591
|
/** @protected */
|
|
663
592
|
_finishOpening() {
|
|
664
|
-
document.addEventListener('iron-overlay-canceled', this._boundIronOverlayCanceledListener);
|
|
665
593
|
this.removeAttribute('opening');
|
|
666
594
|
}
|
|
667
595
|
|
|
668
596
|
/** @protected */
|
|
669
597
|
_finishClosing() {
|
|
670
|
-
document.removeEventListener('iron-overlay-canceled', this._boundIronOverlayCanceledListener);
|
|
671
598
|
this._detachOverlay();
|
|
672
599
|
this.$.overlay.style.removeProperty('pointer-events');
|
|
673
600
|
this.removeAttribute('closing');
|
|
@@ -725,25 +652,6 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
725
652
|
this._placeholder.parentNode.removeChild(this._placeholder);
|
|
726
653
|
}
|
|
727
654
|
|
|
728
|
-
/**
|
|
729
|
-
* Returns all attached overlays in visual stacking order.
|
|
730
|
-
* @private
|
|
731
|
-
*/
|
|
732
|
-
static get __attachedInstances() {
|
|
733
|
-
return Array.from(document.body.children)
|
|
734
|
-
.filter((el) => el instanceof Overlay && !el.hasAttribute('closing'))
|
|
735
|
-
.sort((a, b) => a.__zIndex - b.__zIndex || 0);
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
/**
|
|
739
|
-
* Returns true if this is the last one in the opened overlays stack
|
|
740
|
-
* @return {boolean}
|
|
741
|
-
* @protected
|
|
742
|
-
*/
|
|
743
|
-
get _last() {
|
|
744
|
-
return this === Overlay.__attachedInstances.pop();
|
|
745
|
-
}
|
|
746
|
-
|
|
747
655
|
/** @private */
|
|
748
656
|
_modelessChanged(modeless) {
|
|
749
657
|
if (!modeless) {
|
|
@@ -815,108 +723,12 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
815
723
|
}
|
|
816
724
|
}
|
|
817
725
|
|
|
818
|
-
/** @protected */
|
|
819
|
-
_removeOldContent() {
|
|
820
|
-
if (!this.content || !this._contentNodes) {
|
|
821
|
-
return;
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
this._observer.disconnect();
|
|
825
|
-
|
|
826
|
-
this._contentNodes.forEach((node) => {
|
|
827
|
-
if (node.parentNode === this.content) {
|
|
828
|
-
this.content.removeChild(node);
|
|
829
|
-
}
|
|
830
|
-
});
|
|
831
|
-
|
|
832
|
-
if (this._originalContentPart) {
|
|
833
|
-
// Restore the original <div part="content">
|
|
834
|
-
this.$.content.parentNode.replaceChild(this._originalContentPart, this.$.content);
|
|
835
|
-
this.$.content = this._originalContentPart;
|
|
836
|
-
this._originalContentPart = undefined;
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
this._observer.connect();
|
|
840
|
-
|
|
841
|
-
this._contentNodes = undefined;
|
|
842
|
-
this.content = undefined;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
/**
|
|
846
|
-
* @param {!HTMLTemplateElement} template
|
|
847
|
-
* @protected
|
|
848
|
-
*/
|
|
849
|
-
_stampOverlayTemplate(template) {
|
|
850
|
-
this._removeOldContent();
|
|
851
|
-
|
|
852
|
-
if (!template._Templatizer) {
|
|
853
|
-
template._Templatizer = templatize(template, this, {
|
|
854
|
-
forwardHostProp(prop, value) {
|
|
855
|
-
if (this._instance) {
|
|
856
|
-
this._instance.forwardHostProp(prop, value);
|
|
857
|
-
}
|
|
858
|
-
},
|
|
859
|
-
});
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
this._instance = new template._Templatizer({});
|
|
863
|
-
this._contentNodes = Array.from(this._instance.root.childNodes);
|
|
864
|
-
|
|
865
|
-
const templateRoot = template._templateRoot || (template._templateRoot = template.getRootNode());
|
|
866
|
-
|
|
867
|
-
if (templateRoot !== document) {
|
|
868
|
-
if (!this.$.content.shadowRoot) {
|
|
869
|
-
this.$.content.attachShadow({ mode: 'open' });
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
let scopeCssText = Array.from(templateRoot.querySelectorAll('style')).reduce(
|
|
873
|
-
(result, style) => result + style.textContent,
|
|
874
|
-
'',
|
|
875
|
-
);
|
|
876
|
-
|
|
877
|
-
// The overlay root’s :host styles should not apply inside the overlay
|
|
878
|
-
scopeCssText = scopeCssText.replace(/:host/g, ':host-nomatch');
|
|
879
|
-
|
|
880
|
-
if (scopeCssText) {
|
|
881
|
-
// Append a style to the content shadowRoot
|
|
882
|
-
const style = document.createElement('style');
|
|
883
|
-
style.textContent = scopeCssText;
|
|
884
|
-
this.$.content.shadowRoot.appendChild(style);
|
|
885
|
-
this._contentNodes.unshift(style);
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
this.$.content.shadowRoot.appendChild(this._instance.root);
|
|
889
|
-
this.content = this.$.content.shadowRoot;
|
|
890
|
-
} else {
|
|
891
|
-
this.appendChild(this._instance.root);
|
|
892
|
-
this.content = this;
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
|
|
896
726
|
/** @private */
|
|
897
|
-
|
|
898
|
-
if (template !== oldTemplate) {
|
|
899
|
-
this.template = undefined;
|
|
900
|
-
} else if (renderer !== oldRenderer) {
|
|
901
|
-
this.renderer = undefined;
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
/** @private */
|
|
906
|
-
// eslint-disable-next-line max-params
|
|
907
|
-
_templateOrRendererChanged(template, renderer, owner, model, opened) {
|
|
908
|
-
if (template && renderer) {
|
|
909
|
-
this._removeNewRendererOrTemplate(template, this._oldTemplate, renderer, this._oldRenderer);
|
|
910
|
-
throw new Error('You should only use either a renderer or a template for overlay content');
|
|
911
|
-
}
|
|
912
|
-
|
|
727
|
+
_rendererOrDataChanged(renderer, owner, model, opened) {
|
|
913
728
|
const ownerOrModelChanged = this._oldOwner !== owner || this._oldModel !== model;
|
|
914
729
|
this._oldModel = model;
|
|
915
730
|
this._oldOwner = owner;
|
|
916
731
|
|
|
917
|
-
const templateChanged = this._oldTemplate !== template;
|
|
918
|
-
this._oldTemplate = template;
|
|
919
|
-
|
|
920
732
|
const rendererChanged = this._oldRenderer !== renderer;
|
|
921
733
|
this._oldRenderer = renderer;
|
|
922
734
|
|
|
@@ -924,20 +736,15 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
924
736
|
this._oldOpened = opened;
|
|
925
737
|
|
|
926
738
|
if (rendererChanged) {
|
|
927
|
-
this.
|
|
928
|
-
this.content.innerHTML = '';
|
|
739
|
+
this.innerHTML = '';
|
|
929
740
|
// Whenever a Lit-based renderer is used, it assigns a Lit part to the node it was rendered into.
|
|
930
741
|
// When clearing the rendered content, this part needs to be manually disposed of.
|
|
931
742
|
// Otherwise, using a Lit-based renderer on the same node will throw an exception or render nothing afterward.
|
|
932
|
-
delete this.
|
|
743
|
+
delete this._$litPart$;
|
|
933
744
|
}
|
|
934
745
|
|
|
935
|
-
if (
|
|
936
|
-
this.
|
|
937
|
-
} else if (renderer && (rendererChanged || openedChanged || ownerOrModelChanged)) {
|
|
938
|
-
if (opened) {
|
|
939
|
-
this.requestContentUpdate();
|
|
940
|
-
}
|
|
746
|
+
if (opened && renderer && (rendererChanged || openedChanged || ownerOrModelChanged)) {
|
|
747
|
+
this.requestContentUpdate();
|
|
941
748
|
}
|
|
942
749
|
}
|
|
943
750
|
|