@zanichelli/albe-web-components 18.6.3 → 18.6.4
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/CHANGELOG.md +2 -0
- package/dist/cjs/{index-c48948bf.js → index-0d3de93e.js} +2 -2
- package/dist/cjs/{index-c48948bf.js.map → index-0d3de93e.js.map} +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{utils-93961cb6.js → utils-3dc316f8.js} +56 -1
- package/dist/cjs/utils-3dc316f8.js.map +1 -0
- package/dist/cjs/web-components-library.cjs.js +1 -1
- package/dist/cjs/z-anchor-navigation.cjs.entry.js +1 -1
- package/dist/cjs/z-anchor-navigation.cjs.entry.js.map +1 -1
- package/dist/cjs/z-app-header_12.cjs.entry.js +2 -2
- package/dist/cjs/z-app-header_12.cjs.entry.js.map +1 -1
- package/dist/cjs/z-book-card-deprecated.cjs.entry.js +1 -1
- package/dist/cjs/z-breadcrumb.cjs.entry.js +1 -1
- package/dist/cjs/z-card.cjs.entry.js +1 -1
- package/dist/cjs/z-card.cjs.entry.js.map +1 -1
- package/dist/cjs/z-combobox.cjs.entry.js +1 -1
- package/dist/cjs/z-menu.cjs.entry.js +1 -1
- package/dist/cjs/z-myz-card-info.cjs.entry.js +1 -1
- package/dist/cjs/z-myz-list-item.cjs.entry.js +1 -1
- package/dist/cjs/z-popover.cjs.entry.js +232 -264
- package/dist/cjs/z-popover.cjs.entry.js.map +1 -1
- package/dist/cjs/z-select.cjs.entry.js +5 -7
- package/dist/cjs/z-select.cjs.entry.js.map +1 -1
- package/dist/cjs/z-skip-to-content.cjs.entry.js +1 -1
- package/dist/cjs/z-slideshow.cjs.entry.js +1 -1
- package/dist/cjs/z-table.cjs.entry.js +2 -2
- package/dist/cjs/z-toggle-switch.cjs.entry.js +1 -1
- package/dist/cjs/z-tr.cjs.entry.js +2 -2
- package/dist/collection/components/list/z-list-element/styles.css +2 -4
- package/dist/collection/components/z-anchor-navigation/index.js +1 -1
- package/dist/collection/components/z-anchor-navigation/index.js.map +1 -1
- package/dist/collection/components/z-card/styles.css +4 -0
- package/dist/collection/components/z-popover/index.js +236 -268
- package/dist/collection/components/z-popover/index.js.map +1 -1
- package/dist/collection/components/z-popover/index.stories.js +92 -45
- package/dist/collection/components/z-popover/index.stories.js.map +1 -1
- package/dist/collection/components/z-popover/styles.css +4 -14
- package/dist/collection/components/z-select/index.js +4 -6
- package/dist/collection/components/z-select/index.js.map +1 -1
- package/dist/collection/components/z-select/styles.css +2 -6
- package/dist/collection/utils/utils.js +53 -0
- package/dist/collection/utils/utils.js.map +1 -1
- package/dist/components/index14.js +1 -1
- package/dist/components/index14.js.map +1 -1
- package/dist/components/index23.js +234 -266
- package/dist/components/index23.js.map +1 -1
- package/dist/components/index24.js +1 -1
- package/dist/components/utils.js +55 -2
- package/dist/components/utils.js.map +1 -1
- package/dist/components/z-anchor-navigation.js +1 -1
- package/dist/components/z-anchor-navigation.js.map +1 -1
- package/dist/components/z-card.js +1 -1
- package/dist/components/z-card.js.map +1 -1
- package/dist/components/z-select.js +5 -7
- package/dist/components/z-select.js.map +1 -1
- package/dist/esm/{index-10473b87.js → index-328b69a7.js} +2 -2
- package/dist/esm/{index-10473b87.js.map → index-328b69a7.js.map} +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{utils-c8abef2f.js → utils-6e2be2b6.js} +55 -2
- package/dist/esm/utils-6e2be2b6.js.map +1 -0
- package/dist/esm/web-components-library.js +1 -1
- package/dist/esm/z-anchor-navigation.entry.js +1 -1
- package/dist/esm/z-anchor-navigation.entry.js.map +1 -1
- package/dist/esm/z-app-header_12.entry.js +2 -2
- package/dist/esm/z-app-header_12.entry.js.map +1 -1
- package/dist/esm/z-book-card-deprecated.entry.js +1 -1
- package/dist/esm/z-breadcrumb.entry.js +1 -1
- package/dist/esm/z-card.entry.js +1 -1
- package/dist/esm/z-card.entry.js.map +1 -1
- package/dist/esm/z-combobox.entry.js +1 -1
- package/dist/esm/z-menu.entry.js +1 -1
- package/dist/esm/z-myz-card-info.entry.js +1 -1
- package/dist/esm/z-myz-list-item.entry.js +1 -1
- package/dist/esm/z-popover.entry.js +233 -265
- package/dist/esm/z-popover.entry.js.map +1 -1
- package/dist/esm/z-select.entry.js +5 -7
- package/dist/esm/z-select.entry.js.map +1 -1
- package/dist/esm/z-skip-to-content.entry.js +1 -1
- package/dist/esm/z-slideshow.entry.js +1 -1
- package/dist/esm/z-table.entry.js +2 -2
- package/dist/esm/z-toggle-switch.entry.js +1 -1
- package/dist/esm/z-tr.entry.js +2 -2
- package/dist/types/components/z-popover/index.d.ts +47 -45
- package/dist/types/components/z-popover/index.stories.d.ts +18 -7
- package/dist/types/components.d.ts +13 -17
- package/dist/types/utils/utils.d.ts +17 -0
- package/dist/web-components-library/index.esm.js +1 -1
- package/dist/web-components-library/{p-8b93bc6d.entry.js → p-01302e57.entry.js} +2 -2
- package/dist/web-components-library/{p-14f0bdf4.entry.js → p-1ad8810a.entry.js} +2 -2
- package/{www/build/p-c2ba8a6c.entry.js → dist/web-components-library/p-2e0923bd.entry.js} +2 -2
- package/dist/web-components-library/p-3284e37b.entry.js +2 -0
- package/dist/web-components-library/{p-61f76cab.js → p-43bc482a.js} +2 -2
- package/{www/build/p-2fb52cd0.entry.js → dist/web-components-library/p-539f99db.entry.js} +2 -2
- package/dist/web-components-library/p-625e2cee.js +2 -0
- package/dist/web-components-library/p-625e2cee.js.map +1 -0
- package/dist/web-components-library/p-62e1d867.entry.js +2 -0
- package/dist/web-components-library/p-62e1d867.entry.js.map +1 -0
- package/dist/web-components-library/p-63d220da.entry.js +2 -0
- package/dist/web-components-library/{p-8d5e3396.entry.js.map → p-63d220da.entry.js.map} +1 -1
- package/dist/web-components-library/{p-25935be3.entry.js → p-6d0fa7c1.entry.js} +2 -2
- package/dist/web-components-library/{p-25935be3.entry.js.map → p-6d0fa7c1.entry.js.map} +1 -1
- package/dist/web-components-library/{p-c8814ae1.entry.js → p-7916e0f7.entry.js} +2 -2
- package/{www/build/p-f5efb3fc.entry.js → dist/web-components-library/p-8bd4a2aa.entry.js} +2 -2
- package/dist/web-components-library/{p-c962e854.entry.js → p-8dec332e.entry.js} +2 -2
- package/dist/web-components-library/{p-72a7eb26.entry.js → p-966cbf03.entry.js} +2 -2
- package/{www/build/p-30575221.entry.js → dist/web-components-library/p-a0ed0c63.entry.js} +2 -2
- package/{www/build/p-e41442e0.entry.js → dist/web-components-library/p-b7b972c0.entry.js} +2 -2
- package/{www/build/p-e41442e0.entry.js.map → dist/web-components-library/p-b7b972c0.entry.js.map} +1 -1
- package/dist/web-components-library/p-b96ca9a0.entry.js +2 -0
- package/dist/web-components-library/p-b96ca9a0.entry.js.map +1 -0
- package/dist/web-components-library/{p-57b8bd19.entry.js → p-db9b7eb5.entry.js} +2 -2
- package/dist/web-components-library/p-db9b7eb5.entry.js.map +1 -0
- package/dist/web-components-library/web-components-library.esm.js +1 -1
- package/dist/web-components-library/web-components-library.esm.js.map +1 -1
- package/package.json +1 -1
- package/www/build/index.esm.js +1 -1
- package/www/build/{p-8b93bc6d.entry.js → p-01302e57.entry.js} +2 -2
- package/www/build/{p-14f0bdf4.entry.js → p-1ad8810a.entry.js} +2 -2
- package/{dist/web-components-library/p-c2ba8a6c.entry.js → www/build/p-2e0923bd.entry.js} +2 -2
- package/www/build/p-3284e37b.entry.js +2 -0
- package/www/build/{p-61f76cab.js → p-43bc482a.js} +2 -2
- package/{dist/web-components-library/p-2fb52cd0.entry.js → www/build/p-539f99db.entry.js} +2 -2
- package/www/build/p-625e2cee.js +2 -0
- package/www/build/p-625e2cee.js.map +1 -0
- package/www/build/p-62e1d867.entry.js +2 -0
- package/www/build/p-62e1d867.entry.js.map +1 -0
- package/www/build/p-63d220da.entry.js +2 -0
- package/www/build/{p-8d5e3396.entry.js.map → p-63d220da.entry.js.map} +1 -1
- package/www/build/{p-2870add3.js → p-6c6208e6.js} +1 -1
- package/www/build/{p-25935be3.entry.js → p-6d0fa7c1.entry.js} +2 -2
- package/www/build/{p-25935be3.entry.js.map → p-6d0fa7c1.entry.js.map} +1 -1
- package/www/build/{p-c8814ae1.entry.js → p-7916e0f7.entry.js} +2 -2
- package/{dist/web-components-library/p-f5efb3fc.entry.js → www/build/p-8bd4a2aa.entry.js} +2 -2
- package/www/build/{p-c962e854.entry.js → p-8dec332e.entry.js} +2 -2
- package/www/build/{p-72a7eb26.entry.js → p-966cbf03.entry.js} +2 -2
- package/{dist/web-components-library/p-30575221.entry.js → www/build/p-a0ed0c63.entry.js} +2 -2
- package/{dist/web-components-library/p-e41442e0.entry.js → www/build/p-b7b972c0.entry.js} +2 -2
- package/{dist/web-components-library/p-e41442e0.entry.js.map → www/build/p-b7b972c0.entry.js.map} +1 -1
- package/www/build/p-b96ca9a0.entry.js +2 -0
- package/www/build/p-b96ca9a0.entry.js.map +1 -0
- package/www/build/{p-57b8bd19.entry.js → p-db9b7eb5.entry.js} +2 -2
- package/www/build/p-db9b7eb5.entry.js.map +1 -0
- package/www/build/web-components-library.esm.js +1 -1
- package/www/build/web-components-library.esm.js.map +1 -1
- package/www/index.html +1 -1
- package/dist/cjs/utils-93961cb6.js.map +0 -1
- package/dist/esm/utils-c8abef2f.js.map +0 -1
- package/dist/web-components-library/p-37f271c8.entry.js +0 -2
- package/dist/web-components-library/p-37f271c8.entry.js.map +0 -1
- package/dist/web-components-library/p-57b8bd19.entry.js.map +0 -1
- package/dist/web-components-library/p-69a1a67a.entry.js +0 -2
- package/dist/web-components-library/p-8d5e3396.entry.js +0 -2
- package/dist/web-components-library/p-a06fbbc0.js +0 -2
- package/dist/web-components-library/p-a06fbbc0.js.map +0 -1
- package/dist/web-components-library/p-da30a6cb.entry.js +0 -2
- package/dist/web-components-library/p-da30a6cb.entry.js.map +0 -1
- package/www/build/p-37f271c8.entry.js +0 -2
- package/www/build/p-37f271c8.entry.js.map +0 -1
- package/www/build/p-57b8bd19.entry.js.map +0 -1
- package/www/build/p-69a1a67a.entry.js +0 -2
- package/www/build/p-8d5e3396.entry.js +0 -2
- package/www/build/p-a06fbbc0.js +0 -2
- package/www/build/p-a06fbbc0.js.map +0 -1
- package/www/build/p-da30a6cb.entry.js +0 -2
- package/www/build/p-da30a6cb.entry.js.map +0 -1
- /package/dist/web-components-library/{p-8b93bc6d.entry.js.map → p-01302e57.entry.js.map} +0 -0
- /package/dist/web-components-library/{p-14f0bdf4.entry.js.map → p-1ad8810a.entry.js.map} +0 -0
- /package/dist/web-components-library/{p-c2ba8a6c.entry.js.map → p-2e0923bd.entry.js.map} +0 -0
- /package/dist/web-components-library/{p-69a1a67a.entry.js.map → p-3284e37b.entry.js.map} +0 -0
- /package/dist/web-components-library/{p-61f76cab.js.map → p-43bc482a.js.map} +0 -0
- /package/dist/web-components-library/{p-2fb52cd0.entry.js.map → p-539f99db.entry.js.map} +0 -0
- /package/dist/web-components-library/{p-c8814ae1.entry.js.map → p-7916e0f7.entry.js.map} +0 -0
- /package/dist/web-components-library/{p-f5efb3fc.entry.js.map → p-8bd4a2aa.entry.js.map} +0 -0
- /package/dist/web-components-library/{p-c962e854.entry.js.map → p-8dec332e.entry.js.map} +0 -0
- /package/dist/web-components-library/{p-72a7eb26.entry.js.map → p-966cbf03.entry.js.map} +0 -0
- /package/dist/web-components-library/{p-30575221.entry.js.map → p-a0ed0c63.entry.js.map} +0 -0
- /package/www/build/{p-8b93bc6d.entry.js.map → p-01302e57.entry.js.map} +0 -0
- /package/www/build/{p-14f0bdf4.entry.js.map → p-1ad8810a.entry.js.map} +0 -0
- /package/www/build/{p-c2ba8a6c.entry.js.map → p-2e0923bd.entry.js.map} +0 -0
- /package/www/build/{p-69a1a67a.entry.js.map → p-3284e37b.entry.js.map} +0 -0
- /package/www/build/{p-61f76cab.js.map → p-43bc482a.js.map} +0 -0
- /package/www/build/{p-2fb52cd0.entry.js.map → p-539f99db.entry.js.map} +0 -0
- /package/www/build/{p-c8814ae1.entry.js.map → p-7916e0f7.entry.js.map} +0 -0
- /package/www/build/{p-f5efb3fc.entry.js.map → p-8bd4a2aa.entry.js.map} +0 -0
- /package/www/build/{p-c962e854.entry.js.map → p-8dec332e.entry.js.map} +0 -0
- /package/www/build/{p-72a7eb26.entry.js.map → p-966cbf03.entry.js.map} +0 -0
- /package/www/build/{p-30575221.entry.js.map → p-a0ed0c63.entry.js.map} +0 -0
|
@@ -4,101 +4,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-96af6326.js');
|
|
6
6
|
const index$1 = require('./index-97a4c18d.js');
|
|
7
|
+
const utils = require('./utils-3dc316f8.js');
|
|
8
|
+
require('./breakpoints-8a1e87e0.js');
|
|
7
9
|
|
|
8
|
-
const stylesCss = ":host{position:
|
|
10
|
+
const stylesCss = ":host{position:fixed;display:none;max-width:calc(100% - var(--grid-margin) * 2);max-height:calc(100% - var(--grid-margin) * 2);padding:var(--z-popover-padding, 0);background:var(--z-popover-theme--surface, var(--color-surface01));border-radius:var(--border-radius-small);color:var(--z-popover-theme--text, var(--color-default-text));fill:currentcolor;filter:var(--z-popover-shadow-filter, drop-shadow(0 1px 2px var(--shadow-color-base)));text-align:center}:host([open]:not([current-position])){visibility:hidden}:host([open][current-position]),:host([open=\"true\"][current-position]){display:block}:host([center][current-position=\"top\"]),:host([center][current-position=\"bottom\"]){transform:translateX(-50%)}:host([center][current-position=\"right\"]),:host([center][current-position=\"left\"]){transform:translateY(-50%)}:host([current-position^=\"top\"]){margin:0 0 var(--space-unit)}:host([current-position^=\"bottom\"]){margin:var(--space-unit) 0 0}:host([current-position^=\"left\"]){margin:0 var(--space-unit) 0 0}:host([current-position^=\"right\"]){margin:0 0 0 var(--space-unit)}:host([current-position])::before{--arrow-size:6px;--arrow-edge-offset:calc(100% - var(--space-unit) - (var(--arrow-size) / 2));--arrow-center-x-offset:calc(50% - (var(--arrow-size) / 2));--arrow-center-y-offset:calc(100% - (var(--arrow-size) / 2));position:absolute;display:block;width:var(--arrow-size);height:var(--arrow-size);background:var(--z-popover-theme--surface, var(--color-surface01));content:\"\";transform:rotate(45deg)}:host([show-arrow=\"false\"])::before,:host(:not([show-arrow]))::before{display:none}:host([current-position^=\"top\"])::before{top:var(--arrow-center-y-offset)}:host([current-position^=\"bottom\"])::before{bottom:var(--arrow-center-y-offset)}:host([current-position=\"top\"])::before,:host([current-position=\"bottom\"])::before{right:var(--arrow-edge-offset)}:host([current-position=\"right\"])::before,:host([current-position=\"left\"])::before{bottom:var(--arrow-edge-offset)}:host([current-position=\"right\"])::before{right:var(--arrow-center-y-offset)}:host([current-position=\"left\"])::before{left:var(--arrow-center-y-offset)}:host([current-position=\"top_right\"])::before,:host([current-position=\"bottom_right\"])::before{right:var(--arrow-edge-offset)}:host([current-position=\"top_left\"])::before,:host([current-position=\"bottom_left\"])::before{left:var(--arrow-edge-offset)}:host([current-position=\"right_top\"])::before,:host([current-position=\"left_top\"])::before{top:var(--arrow-edge-offset)}:host([current-position=\"right_top\"])::before,:host([current-position=\"right_bottom\"])::before{right:var(--arrow-center-y-offset)}:host([current-position=\"left_top\"])::before,:host([current-position=\"left_bottom\"])::before{left:var(--arrow-center-y-offset)}:host([current-position=\"right_bottom\"])::before,:host([current-position=\"left_bottom\"])::before{bottom:var(--arrow-edge-offset)}:host([center][current-position=\"top\"])::before,:host([center][current-position=\"bottom\"])::before{right:auto;left:var(--arrow-center-x-offset)}:host([center][current-position=\"right\"])::before,:host([center][current-position=\"left\"])::before{top:var(--arrow-center-x-offset);bottom:auto}";
|
|
9
11
|
const ZPopoverStyle0 = stylesCss;
|
|
10
12
|
|
|
11
|
-
const DOCUMENT_ELEMENT = document.documentElement;
|
|
12
|
-
function getParentElement(element) {
|
|
13
|
-
if (element.parentNode === element.shadowRoot) {
|
|
14
|
-
return element.shadowRoot.host;
|
|
15
|
-
}
|
|
16
|
-
return element.parentElement;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Find the closest scrollable parent of a node.
|
|
20
|
-
*
|
|
21
|
-
* @param {Element} element The node
|
|
22
|
-
*/
|
|
23
|
-
function findScrollableParent(element) {
|
|
24
|
-
let parent = getParentElement(element);
|
|
25
|
-
while (parent && parent !== DOCUMENT_ELEMENT) {
|
|
26
|
-
const style = window.getComputedStyle(parent);
|
|
27
|
-
const { overflow, overflowX, overflowY } = style;
|
|
28
|
-
// Check for hidden overflow first (early return)
|
|
29
|
-
if (overflow === "hidden" || overflowY === "hidden" || overflowX === "hidden") {
|
|
30
|
-
return parent;
|
|
31
|
-
}
|
|
32
|
-
// Only check scrollable if overflow is not visible
|
|
33
|
-
const isOverflowNotVisible = overflow !== "visible";
|
|
34
|
-
const isOverflowYNotVisible = overflowY !== "visible";
|
|
35
|
-
const isOverflowXNotVisible = overflowX !== "visible";
|
|
36
|
-
if ((parent.scrollHeight > parent.clientHeight && isOverflowNotVisible && isOverflowYNotVisible) ||
|
|
37
|
-
(parent.scrollWidth > parent.clientWidth && isOverflowNotVisible && isOverflowXNotVisible)) {
|
|
38
|
-
return parent;
|
|
39
|
-
}
|
|
40
|
-
parent = getParentElement(parent);
|
|
41
|
-
}
|
|
42
|
-
return DOCUMENT_ELEMENT;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Calculate computed offset.
|
|
46
|
-
* It includes matrix transformations.
|
|
47
|
-
* @param element The target element.
|
|
48
|
-
* @param targetParentOffset The relative offset parent.
|
|
49
|
-
*/
|
|
50
|
-
function computeOffset(element, targetParentOffset) {
|
|
51
|
-
const rect = element.getBoundingClientRect();
|
|
52
|
-
const { width, height } = rect;
|
|
53
|
-
let top = 0;
|
|
54
|
-
let left = 0;
|
|
55
|
-
let offsetParent = element;
|
|
56
|
-
while (offsetParent && offsetParent !== targetParentOffset) {
|
|
57
|
-
left += offsetParent.offsetLeft;
|
|
58
|
-
// document.body sometimes has offsetTop == 0 but still has an offset because of children margins!
|
|
59
|
-
if (offsetParent === document.body) {
|
|
60
|
-
top += offsetParent.getBoundingClientRect().top + window.scrollY;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
top += offsetParent.offsetTop;
|
|
64
|
-
}
|
|
65
|
-
// Handle CSS transforms only when DOMMatrix is available
|
|
66
|
-
if (window.DOMMatrix) {
|
|
67
|
-
const style = window.getComputedStyle(offsetParent);
|
|
68
|
-
const { transform } = style;
|
|
69
|
-
if (transform && transform !== "none") {
|
|
70
|
-
const domMatrix = new DOMMatrix(transform);
|
|
71
|
-
left += domMatrix.m41;
|
|
72
|
-
if (offsetParent !== document.body) {
|
|
73
|
-
top += domMatrix.m42;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (!offsetParent.offsetParent) {
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
offsetParent = offsetParent.offsetParent;
|
|
81
|
-
}
|
|
82
|
-
let parentWidth;
|
|
83
|
-
let parentHeight;
|
|
84
|
-
if (offsetParent === document.body) {
|
|
85
|
-
parentWidth = window.innerWidth;
|
|
86
|
-
parentHeight = window.innerHeight;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
parentWidth = offsetParent.offsetWidth;
|
|
90
|
-
parentHeight = offsetParent.offsetHeight;
|
|
91
|
-
}
|
|
92
|
-
const right = parentWidth - left - width;
|
|
93
|
-
const bottom = parentHeight - top - height;
|
|
94
|
-
return { top, right, bottom, left, width, height };
|
|
95
|
-
}
|
|
96
13
|
const ZPopover = class {
|
|
97
14
|
constructor(hostRef) {
|
|
98
15
|
index.registerInstance(this, hostRef);
|
|
99
16
|
this.positionChange = index.createEvent(this, "positionChange", 7);
|
|
100
17
|
this.openChange = index.createEvent(this, "openChange", 7);
|
|
101
|
-
|
|
18
|
+
/** space tolerance for space calculations */
|
|
19
|
+
this.spaceTolerance = 3;
|
|
102
20
|
this.position = index$1.PopoverPosition.TOP;
|
|
103
21
|
this.open = false;
|
|
104
22
|
this.bindTo = undefined;
|
|
@@ -116,71 +34,97 @@ const ZPopover = class {
|
|
|
116
34
|
* Close the popover when clicking outside of its content.
|
|
117
35
|
* Stop event propagation if the click was fired by popover's trigger element,
|
|
118
36
|
* to prevent close and reopen glitches.
|
|
119
|
-
* @param {MouseEvent} e
|
|
120
37
|
*/
|
|
121
38
|
handleOutsideClick(e) {
|
|
122
|
-
|
|
39
|
+
const target = e.target;
|
|
40
|
+
if (!this.closable || !this.open || utils.containsElement(this.host, target)) {
|
|
123
41
|
return;
|
|
124
42
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
let triggerElemClicked = false;
|
|
129
|
-
if (typeof this.bindTo === "string") {
|
|
130
|
-
triggerElemClicked = !!target.closest(this.bindTo);
|
|
131
|
-
}
|
|
132
|
-
else if (this.bindTo) {
|
|
133
|
-
triggerElemClicked = this.bindTo.contains(target);
|
|
134
|
-
}
|
|
135
|
-
if (triggerElemClicked) {
|
|
136
|
-
// stop propagation if the click was on the trigger element to prevent close and reopen glitches
|
|
137
|
-
e.stopPropagation();
|
|
138
|
-
}
|
|
139
|
-
this.open = false;
|
|
140
|
-
this.positionChange.emit({ position: this.currentPosition });
|
|
43
|
+
if (utils.containsElement(this.boundElement, target)) {
|
|
44
|
+
// stop propagation if the click was on the trigger element to prevent close and reopen glitches
|
|
45
|
+
e.stopPropagation();
|
|
141
46
|
}
|
|
47
|
+
this.open = false;
|
|
142
48
|
}
|
|
143
49
|
validatePosition(newValue) {
|
|
144
50
|
if (!Object.values(index$1.PopoverPosition).includes(newValue) || newValue === index$1.PopoverPosition.AUTO) {
|
|
145
51
|
newValue = index$1.PopoverPosition.TOP;
|
|
52
|
+
this.position = newValue;
|
|
146
53
|
}
|
|
147
|
-
this.position = newValue;
|
|
148
54
|
this.currentPosition = newValue;
|
|
149
|
-
|
|
150
|
-
|
|
55
|
+
if (this.open) {
|
|
56
|
+
this.setPosition();
|
|
57
|
+
}
|
|
151
58
|
}
|
|
152
|
-
/**
|
|
153
|
-
* Setup popover behaviors on opening.
|
|
154
|
-
*/
|
|
59
|
+
/** Setup popover behaviors when `open` changes. */
|
|
155
60
|
onOpen() {
|
|
156
61
|
cancelAnimationFrame(this.animationFrameRequestId);
|
|
157
|
-
if (this.open) {
|
|
158
|
-
const setPosition = () => {
|
|
159
|
-
if (this.open) {
|
|
160
|
-
this.setPosition();
|
|
161
|
-
this.animationFrameRequestId = requestAnimationFrame(setPosition);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
// call `setPosition` after a tick to ensure the DOM is ready and sizes are available
|
|
165
|
-
setTimeout(() => {
|
|
166
|
-
setPosition();
|
|
167
|
-
}, 0);
|
|
168
|
-
}
|
|
169
62
|
this.openChange.emit({ open: this.open });
|
|
63
|
+
if (!this.open) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const updatePositionLoop = () => {
|
|
67
|
+
if (!this.open) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.setPosition();
|
|
71
|
+
this.animationFrameRequestId = requestAnimationFrame(updatePositionLoop);
|
|
72
|
+
};
|
|
73
|
+
// call `setPosition` after a tick to ensure the DOM is ready and sizes are available
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
updatePositionLoop();
|
|
76
|
+
}, 0);
|
|
77
|
+
}
|
|
78
|
+
onBindingChange() {
|
|
79
|
+
this.findBoundElement();
|
|
80
|
+
}
|
|
81
|
+
/** Returns the offset modifier to use in calculations to align the popover with the bound element. */
|
|
82
|
+
get offsetModifier() {
|
|
83
|
+
return this.center ? 0.5 : 0;
|
|
84
|
+
}
|
|
85
|
+
findBoundElement() {
|
|
86
|
+
if (typeof this.bindTo === "string") {
|
|
87
|
+
this.boundElement = this.host.ownerDocument.querySelector(this.bindTo);
|
|
88
|
+
}
|
|
89
|
+
else if (this.bindTo) {
|
|
90
|
+
this.boundElement = this.bindTo;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.boundElement = this.host.parentElement;
|
|
94
|
+
}
|
|
170
95
|
}
|
|
171
96
|
/**
|
|
172
|
-
*
|
|
97
|
+
* Check if element has enough space to the right and left to be centered.
|
|
98
|
+
* Used for `TOP` and `BOTTOM` position.
|
|
99
|
+
* When `center` is not enabled, only one side needs to be checked and `RIGHT` is the default.
|
|
173
100
|
*/
|
|
174
|
-
hasCenteredHorizontalSpace(availableLeft, availableRight, hostWidth,
|
|
175
|
-
const
|
|
176
|
-
|
|
101
|
+
hasCenteredHorizontalSpace(availableLeft, availableRight, hostWidth, boundElementWidth) {
|
|
102
|
+
const requiredSideSpace = (hostWidth - boundElementWidth) * (1 - this.offsetModifier);
|
|
103
|
+
if (!this.center) {
|
|
104
|
+
return availableRight >= requiredSideSpace - this.spaceTolerance;
|
|
105
|
+
}
|
|
106
|
+
return (availableRight >= requiredSideSpace - this.spaceTolerance &&
|
|
107
|
+
availableLeft >= requiredSideSpace - this.spaceTolerance);
|
|
177
108
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Check if element has enough space to the top and bottom to be centered.
|
|
111
|
+
* Used for `RIGHT` and `LEFT` position.
|
|
112
|
+
* When `center` is not enabled, only one side needs to be checked and `BOTTOM` is the default.
|
|
113
|
+
*/
|
|
114
|
+
hasCenteredVerticalSpace(availableTop, availableBottom, hostHeight, boundElementHeight) {
|
|
115
|
+
const requiredSideSpace = (hostHeight - boundElementHeight) * (1 - this.offsetModifier);
|
|
116
|
+
if (!this.center) {
|
|
117
|
+
return availableBottom >= requiredSideSpace - this.spaceTolerance;
|
|
118
|
+
}
|
|
119
|
+
return (availableTop >= requiredSideSpace - this.spaceTolerance &&
|
|
120
|
+
availableBottom >= requiredSideSpace - this.spaceTolerance);
|
|
181
121
|
}
|
|
182
|
-
|
|
183
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Check if there is enough space in the given direction to fit the popover.
|
|
124
|
+
* Used for composed positions like TOP_RIGHT, LEFT_BOTTOM, etc.
|
|
125
|
+
*/
|
|
126
|
+
hasEnoughSideSpace(availableSpace, hostSize, boundElementSize, offsetModifier) {
|
|
127
|
+
return availableSpace >= hostSize - boundElementSize * (1 - offsetModifier) - this.spaceTolerance;
|
|
184
128
|
}
|
|
185
129
|
/**
|
|
186
130
|
* Given a desired position and available space around the bound element, returns the best position
|
|
@@ -188,51 +132,52 @@ const ZPopover = class {
|
|
|
188
132
|
* Takes into account offsetModifier for centering.
|
|
189
133
|
* @param desiredPosition The desired position of the popover.
|
|
190
134
|
* @param availableSpace The available space around the bound element.
|
|
191
|
-
* @param boundElemSizes The sizes of the bound element.
|
|
192
|
-
* @param offsetModifier The modifier to apply to the offset for centering.
|
|
193
135
|
*/
|
|
194
|
-
getOptimalPopoverPosition(desiredPosition, availableSpace
|
|
136
|
+
getOptimalPopoverPosition(desiredPosition, availableSpace) {
|
|
195
137
|
const hostWidth = this.host.offsetWidth;
|
|
196
138
|
const hostHeight = this.host.offsetHeight;
|
|
197
|
-
|
|
139
|
+
const boundElementWidth = this.boundElement.getBoundingClientRect().width;
|
|
140
|
+
const boundElementHeight = this.boundElement.getBoundingClientRect().height;
|
|
141
|
+
const offsetModifier = this.offsetModifier;
|
|
142
|
+
/** Check if there is enough space to fit the popover in the desired position */
|
|
198
143
|
const fits = (pos) => {
|
|
199
144
|
switch (pos) {
|
|
200
145
|
case index$1.PopoverPosition.TOP:
|
|
201
|
-
return (availableSpace.top >= hostHeight &&
|
|
202
|
-
this.hasCenteredHorizontalSpace(availableSpace.left, availableSpace.right, hostWidth,
|
|
146
|
+
return (availableSpace.top >= hostHeight - this.spaceTolerance &&
|
|
147
|
+
this.hasCenteredHorizontalSpace(availableSpace.left, availableSpace.right, hostWidth, boundElementWidth));
|
|
203
148
|
case index$1.PopoverPosition.TOP_RIGHT:
|
|
204
149
|
return (availableSpace.top >= hostHeight &&
|
|
205
|
-
this.
|
|
150
|
+
this.hasEnoughSideSpace(availableSpace.right, hostWidth, boundElementWidth, offsetModifier));
|
|
206
151
|
case index$1.PopoverPosition.TOP_LEFT:
|
|
207
152
|
return (availableSpace.top >= hostHeight &&
|
|
208
|
-
this.
|
|
153
|
+
this.hasEnoughSideSpace(availableSpace.left, hostWidth, boundElementWidth, offsetModifier));
|
|
209
154
|
case index$1.PopoverPosition.RIGHT:
|
|
210
155
|
return (availableSpace.right >= hostWidth &&
|
|
211
|
-
this.hasCenteredVerticalSpace(availableSpace.top, availableSpace.bottom, hostHeight,
|
|
156
|
+
this.hasCenteredVerticalSpace(availableSpace.top, availableSpace.bottom, hostHeight, boundElementHeight));
|
|
212
157
|
case index$1.PopoverPosition.RIGHT_BOTTOM:
|
|
213
158
|
return (availableSpace.right >= hostWidth &&
|
|
214
|
-
this.
|
|
159
|
+
this.hasEnoughSideSpace(availableSpace.bottom, hostHeight, boundElementHeight, offsetModifier));
|
|
215
160
|
case index$1.PopoverPosition.RIGHT_TOP:
|
|
216
161
|
return (availableSpace.right >= hostWidth &&
|
|
217
|
-
this.
|
|
162
|
+
this.hasEnoughSideSpace(availableSpace.top, hostHeight, boundElementHeight, offsetModifier));
|
|
218
163
|
case index$1.PopoverPosition.BOTTOM:
|
|
219
164
|
return (availableSpace.bottom >= hostHeight &&
|
|
220
|
-
this.hasCenteredHorizontalSpace(availableSpace.left, availableSpace.right, hostWidth,
|
|
165
|
+
this.hasCenteredHorizontalSpace(availableSpace.left, availableSpace.right, hostWidth, boundElementWidth));
|
|
221
166
|
case index$1.PopoverPosition.BOTTOM_LEFT:
|
|
222
167
|
return (availableSpace.bottom >= hostHeight &&
|
|
223
|
-
this.
|
|
168
|
+
this.hasEnoughSideSpace(availableSpace.left, hostWidth, boundElementWidth, offsetModifier));
|
|
224
169
|
case index$1.PopoverPosition.BOTTOM_RIGHT:
|
|
225
170
|
return (availableSpace.bottom >= hostHeight &&
|
|
226
|
-
this.
|
|
171
|
+
this.hasEnoughSideSpace(availableSpace.right, hostWidth, boundElementWidth, offsetModifier));
|
|
227
172
|
case index$1.PopoverPosition.LEFT:
|
|
228
173
|
return (availableSpace.left >= hostWidth &&
|
|
229
|
-
this.hasCenteredVerticalSpace(availableSpace.top, availableSpace.bottom, hostHeight,
|
|
174
|
+
this.hasCenteredVerticalSpace(availableSpace.top, availableSpace.bottom, hostHeight, boundElementHeight));
|
|
230
175
|
case index$1.PopoverPosition.LEFT_TOP:
|
|
231
176
|
return (availableSpace.left >= hostWidth &&
|
|
232
|
-
this.
|
|
177
|
+
this.hasEnoughSideSpace(availableSpace.top, hostHeight, boundElementHeight, offsetModifier));
|
|
233
178
|
case index$1.PopoverPosition.LEFT_BOTTOM:
|
|
234
179
|
return (availableSpace.left >= hostWidth &&
|
|
235
|
-
this.
|
|
180
|
+
this.hasEnoughSideSpace(availableSpace.bottom, hostHeight, boundElementHeight, offsetModifier));
|
|
236
181
|
default:
|
|
237
182
|
return false;
|
|
238
183
|
}
|
|
@@ -258,27 +203,25 @@ const ZPopover = class {
|
|
|
258
203
|
// If no position fits, find the best fallback based on available space
|
|
259
204
|
return this.findBestFallbackPosition(availableSpace);
|
|
260
205
|
}
|
|
261
|
-
/**
|
|
262
|
-
* Find the best fallback position based on available space when no position fits perfectly
|
|
263
|
-
*/
|
|
206
|
+
/** Find the best fallback position based on available space when no position fits perfectly. */
|
|
264
207
|
findBestFallbackPosition(availableSpace) {
|
|
265
|
-
// Determine
|
|
208
|
+
// Determine which horizontal and vertical direction has the most available space
|
|
266
209
|
const bestHorizontalDirection = availableSpace.right >= availableSpace.left ? index$1.PopoverPosition.RIGHT : index$1.PopoverPosition.LEFT;
|
|
267
210
|
const bestVerticalDirection = availableSpace.bottom >= availableSpace.top ? index$1.PopoverPosition.BOTTOM : index$1.PopoverPosition.TOP;
|
|
268
|
-
// Choose the main direction based on which has more space
|
|
211
|
+
// Choose the main direction based on which axis has more space overall
|
|
269
212
|
const maxHorizontalSpace = Math.max(availableSpace.right, availableSpace.left);
|
|
270
213
|
const maxVerticalSpace = Math.max(availableSpace.bottom, availableSpace.top);
|
|
271
214
|
const mainDirection = maxVerticalSpace >= maxHorizontalSpace ? bestVerticalDirection : bestHorizontalDirection;
|
|
272
|
-
//
|
|
273
|
-
// Only add secondary direction if the difference between min and max in that
|
|
215
|
+
// Decide if a secondary direction is needed
|
|
216
|
+
// Only add a secondary direction if the difference between min and max in that axis is at least double
|
|
274
217
|
let needsSecondaryDirection = false;
|
|
275
218
|
if (mainDirection === bestVerticalDirection) {
|
|
276
|
-
//
|
|
219
|
+
// If main direction is vertical, check horizontal space difference
|
|
277
220
|
const minHorizontalSpace = Math.min(availableSpace.right, availableSpace.left);
|
|
278
221
|
needsSecondaryDirection = maxHorizontalSpace >= minHorizontalSpace * 2;
|
|
279
222
|
}
|
|
280
223
|
else {
|
|
281
|
-
//
|
|
224
|
+
// If main direction is horizontal, check vertical space difference
|
|
282
225
|
const minVerticalSpace = Math.min(availableSpace.bottom, availableSpace.top);
|
|
283
226
|
needsSecondaryDirection = maxVerticalSpace >= minVerticalSpace * 2;
|
|
284
227
|
}
|
|
@@ -286,184 +229,209 @@ const ZPopover = class {
|
|
|
286
229
|
return mainDirection;
|
|
287
230
|
}
|
|
288
231
|
const secondaryDirection = mainDirection === bestVerticalDirection ? bestHorizontalDirection : bestVerticalDirection;
|
|
289
|
-
//
|
|
232
|
+
// Return a combined position (e.g., "bottom_right")
|
|
290
233
|
return `${mainDirection}_${secondaryDirection}`;
|
|
291
234
|
}
|
|
292
235
|
/**
|
|
293
|
-
* Calculate available space around the bound
|
|
236
|
+
* Calculate available space around the element bound with the popover, based on its nearest scrollable ancestor.
|
|
237
|
+
*
|
|
238
|
+
* Calculations for `right` and `bottom` can be a little bit confusing because `boundingRect.right` and `bottom` may not be what you expect...
|
|
239
|
+
* For more information see the explanation in the docs.
|
|
240
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#return_value
|
|
294
241
|
*/
|
|
295
|
-
calculateAvailableSpace(
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
242
|
+
calculateAvailableSpace() {
|
|
243
|
+
const boundElementRect = this.boundElement.getBoundingClientRect();
|
|
244
|
+
if (this.lastBoundRect &&
|
|
245
|
+
this.lastBoundRect.x === boundElementRect.x &&
|
|
246
|
+
this.lastBoundRect.y === boundElementRect.y &&
|
|
247
|
+
this.lastBoundRect.width === boundElementRect.width &&
|
|
248
|
+
this.lastBoundRect.height === boundElementRect.height &&
|
|
249
|
+
this.cachedAvailableSpace) {
|
|
250
|
+
// If the bound element's rect hasn't changed, return the cached rect
|
|
251
|
+
return this.cachedAvailableSpace;
|
|
252
|
+
}
|
|
253
|
+
this.lastBoundRect = boundElementRect;
|
|
254
|
+
const scrollableParent = utils.findScrollableParent(this.boundElement);
|
|
255
|
+
const scrollableParentRect = scrollableParent.getBoundingClientRect();
|
|
256
|
+
const hasNestedScrollableParent = scrollableParent !== this.boundElement.ownerDocument.documentElement;
|
|
257
|
+
const documentWidth = this.boundElement.ownerDocument.documentElement.clientWidth;
|
|
258
|
+
const documentHeight = this.boundElement.ownerDocument.documentElement.clientHeight;
|
|
259
|
+
const safeSpace = 8; // extra space to avoid popover being too close to the edges
|
|
260
|
+
// These deltas represent the offset between the scrollable parent and the viewport.
|
|
261
|
+
// They are used to adjust the available space calculations when the scrollable parent is not the document or body,
|
|
262
|
+
// to try to fit the popover inside the scrollable parent.
|
|
263
|
+
const deltaTop = hasNestedScrollableParent ? scrollableParentRect.top : 0;
|
|
264
|
+
const deltaRight = hasNestedScrollableParent ? documentWidth - scrollableParentRect.right : 0;
|
|
265
|
+
const deltaBottom = hasNestedScrollableParent ? documentHeight - scrollableParentRect.bottom : 0;
|
|
266
|
+
const deltaLeft = hasNestedScrollableParent ? scrollableParentRect.left : 0;
|
|
267
|
+
this.cachedAvailableSpace = {
|
|
268
|
+
top: boundElementRect.top - deltaTop - safeSpace,
|
|
269
|
+
right: documentWidth - boundElementRect.right - deltaRight - safeSpace,
|
|
270
|
+
bottom: documentHeight - boundElementRect.bottom - deltaBottom - safeSpace,
|
|
271
|
+
left: boundElementRect.left - deltaLeft - safeSpace,
|
|
307
272
|
};
|
|
273
|
+
return this.cachedAvailableSpace;
|
|
308
274
|
}
|
|
309
|
-
/**
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
275
|
+
/** Calculate the space around an element relative to the viewport. */
|
|
276
|
+
calculateElementOffsets(element) {
|
|
277
|
+
const elementRect = element.getBoundingClientRect();
|
|
278
|
+
const viewportWidth = element.ownerDocument.documentElement.clientWidth;
|
|
279
|
+
const viewportHeight = element.ownerDocument.documentElement.clientHeight;
|
|
313
280
|
return {
|
|
314
|
-
top:
|
|
315
|
-
right:
|
|
316
|
-
bottom:
|
|
317
|
-
left:
|
|
281
|
+
top: elementRect.top,
|
|
282
|
+
right: viewportWidth - elementRect.right,
|
|
283
|
+
bottom: viewportHeight - elementRect.bottom,
|
|
284
|
+
left: elementRect.left,
|
|
318
285
|
};
|
|
319
286
|
}
|
|
320
|
-
/**
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
287
|
+
/** Apply positioning styles based on passed position. */
|
|
288
|
+
applyPositionStyles(position, availableSpace) {
|
|
289
|
+
const boundElementWidth = this.boundElement.offsetWidth;
|
|
290
|
+
const boundElementHeight = this.boundElement.offsetHeight;
|
|
291
|
+
/** Distance between the popover and the bound element */
|
|
292
|
+
const distanceFromBound = 8;
|
|
293
|
+
const offsetModifier = this.offsetModifier;
|
|
294
|
+
/** Distance between the arrow center and the popover edge. Needed to align the center of the arrow with the center of the bound element when `showArrow` and `center` are enabled. */
|
|
295
|
+
const arrowModifier = this.showArrow && this.center ? 8 : 0;
|
|
296
|
+
const hostStyle = this.host.style;
|
|
297
|
+
const boundElementOffsets = this.calculateElementOffsets(this.boundElement);
|
|
298
|
+
let maxWidth;
|
|
299
|
+
let maxHeight;
|
|
332
300
|
switch (position) {
|
|
333
301
|
case index$1.PopoverPosition.TOP:
|
|
334
302
|
case index$1.PopoverPosition.TOP_RIGHT:
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
303
|
+
hostStyle.bottom = `${boundElementOffsets.bottom + boundElementHeight}px`;
|
|
304
|
+
hostStyle.left = `${boundElementOffsets.left + boundElementWidth * offsetModifier - (position === index$1.PopoverPosition.TOP_RIGHT ? arrowModifier : 0)}px`;
|
|
305
|
+
maxHeight = availableSpace.top - distanceFromBound;
|
|
338
306
|
if (position === index$1.PopoverPosition.TOP_RIGHT) {
|
|
339
|
-
|
|
307
|
+
maxWidth = availableSpace.right + boundElementWidth * offsetModifier;
|
|
340
308
|
}
|
|
341
309
|
break;
|
|
342
310
|
case index$1.PopoverPosition.TOP_LEFT:
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
311
|
+
hostStyle.right = `${boundElementOffsets.right + boundElementWidth * offsetModifier - arrowModifier}px`;
|
|
312
|
+
hostStyle.bottom = `${boundElementOffsets.bottom + boundElementHeight}px`;
|
|
313
|
+
maxWidth = availableSpace.left + boundElementWidth * offsetModifier;
|
|
314
|
+
maxHeight = availableSpace.top - distanceFromBound;
|
|
347
315
|
break;
|
|
348
316
|
case index$1.PopoverPosition.BOTTOM:
|
|
349
317
|
case index$1.PopoverPosition.BOTTOM_RIGHT:
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
318
|
+
hostStyle.top = `${boundElementOffsets.top + boundElementHeight}px`;
|
|
319
|
+
hostStyle.left = `${boundElementOffsets.left + boundElementWidth * offsetModifier - (position === index$1.PopoverPosition.BOTTOM_RIGHT ? arrowModifier : 0)}px`;
|
|
320
|
+
maxHeight = availableSpace.bottom - distanceFromBound;
|
|
353
321
|
if (position === index$1.PopoverPosition.BOTTOM_RIGHT) {
|
|
354
|
-
|
|
322
|
+
maxWidth = availableSpace.right + boundElementWidth * offsetModifier;
|
|
355
323
|
}
|
|
356
324
|
break;
|
|
357
325
|
case index$1.PopoverPosition.BOTTOM_LEFT:
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
326
|
+
hostStyle.top = `${boundElementOffsets.top + boundElementHeight}px`;
|
|
327
|
+
hostStyle.right = `${boundElementOffsets.right + boundElementWidth * offsetModifier - arrowModifier}px`;
|
|
328
|
+
maxWidth = availableSpace.left + boundElementWidth * offsetModifier;
|
|
329
|
+
maxHeight = availableSpace.bottom - distanceFromBound;
|
|
362
330
|
break;
|
|
363
331
|
case index$1.PopoverPosition.RIGHT:
|
|
364
332
|
case index$1.PopoverPosition.RIGHT_BOTTOM:
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
333
|
+
hostStyle.top = `${boundElementOffsets.top + boundElementHeight * offsetModifier - (position === index$1.PopoverPosition.RIGHT_BOTTOM ? arrowModifier : 0)}px`;
|
|
334
|
+
hostStyle.left = `${boundElementOffsets.left + boundElementWidth}px`;
|
|
335
|
+
maxWidth = availableSpace.right - distanceFromBound;
|
|
368
336
|
if (position === index$1.PopoverPosition.RIGHT) {
|
|
369
|
-
|
|
337
|
+
maxHeight = availableSpace.top + availableSpace.bottom + boundElementHeight;
|
|
370
338
|
}
|
|
371
339
|
else {
|
|
372
|
-
|
|
340
|
+
maxHeight = availableSpace.bottom + boundElementHeight * offsetModifier;
|
|
373
341
|
}
|
|
374
342
|
break;
|
|
375
343
|
case index$1.PopoverPosition.RIGHT_TOP:
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
style.maxHeight = `${availableSpace.top + boundElementSizes.height * offsetModifier}px`;
|
|
381
|
-
}
|
|
344
|
+
hostStyle.bottom = `${boundElementOffsets.bottom + boundElementHeight * offsetModifier - arrowModifier}px`;
|
|
345
|
+
hostStyle.left = `${boundElementOffsets.left + boundElementWidth}px`;
|
|
346
|
+
maxWidth = availableSpace.right - distanceFromBound;
|
|
347
|
+
maxHeight = availableSpace.top + boundElementHeight * offsetModifier;
|
|
382
348
|
break;
|
|
383
349
|
case index$1.PopoverPosition.LEFT:
|
|
384
350
|
case index$1.PopoverPosition.LEFT_BOTTOM:
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
351
|
+
hostStyle.top = `${boundElementOffsets.top + boundElementHeight * offsetModifier - (position === index$1.PopoverPosition.LEFT_BOTTOM ? arrowModifier : 0)}px`;
|
|
352
|
+
hostStyle.right = `${boundElementOffsets.right + boundElementWidth}px`;
|
|
353
|
+
maxWidth = availableSpace.left - distanceFromBound;
|
|
388
354
|
if (position === index$1.PopoverPosition.LEFT_BOTTOM) {
|
|
389
|
-
|
|
355
|
+
maxHeight = availableSpace.bottom + boundElementHeight * offsetModifier;
|
|
390
356
|
}
|
|
391
357
|
break;
|
|
392
358
|
case index$1.PopoverPosition.LEFT_TOP:
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
style.maxHeight = `${availableSpace.top + boundElementSizes.height * offsetModifier}px`;
|
|
398
|
-
}
|
|
359
|
+
hostStyle.right = `${boundElementOffsets.right + boundElementWidth}px`;
|
|
360
|
+
hostStyle.bottom = `${boundElementOffsets.bottom + boundElementHeight * offsetModifier - arrowModifier}px`;
|
|
361
|
+
maxWidth = availableSpace.left - distanceFromBound;
|
|
362
|
+
maxHeight = availableSpace.top + boundElementHeight * offsetModifier;
|
|
399
363
|
break;
|
|
400
364
|
}
|
|
365
|
+
if (utils.getDevice() !== index$1.Device.MOBILE) {
|
|
366
|
+
// Only force max sizes on non-mobile viewports
|
|
367
|
+
hostStyle.maxWidth = maxWidth ? `${maxWidth}px` : "";
|
|
368
|
+
hostStyle.maxHeight = maxHeight ? `${maxHeight}px` : "";
|
|
369
|
+
}
|
|
401
370
|
}
|
|
402
|
-
/**
|
|
403
|
-
* Set the position of the popover.
|
|
404
|
-
*/
|
|
371
|
+
/** Set the position of the popover. */
|
|
405
372
|
setPosition() {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
boundElement = this.host.ownerDocument.querySelector(this.bindTo);
|
|
409
|
-
}
|
|
410
|
-
else if (this.bindTo) {
|
|
411
|
-
boundElement = this.bindTo;
|
|
412
|
-
}
|
|
413
|
-
else {
|
|
414
|
-
boundElement = this.host.parentElement;
|
|
373
|
+
if (!this.boundElement) {
|
|
374
|
+
return;
|
|
415
375
|
}
|
|
416
|
-
if (!boundElement) {
|
|
376
|
+
if (!utils.isElementVisibleInContainer(this.boundElement, utils.findScrollableParent(this.boundElement))) {
|
|
377
|
+
// If the bound element is not visible, hide the popover too
|
|
378
|
+
this.open = false;
|
|
417
379
|
return;
|
|
418
380
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
:
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
const
|
|
432
|
-
this.applyPositionStyles(position,
|
|
381
|
+
Object.assign(this.host.style, {
|
|
382
|
+
// Reset all positioning properties
|
|
383
|
+
top: "auto",
|
|
384
|
+
right: "auto",
|
|
385
|
+
bottom: "auto",
|
|
386
|
+
left: "auto",
|
|
387
|
+
maxWidth: "",
|
|
388
|
+
maxHeight: "",
|
|
389
|
+
// Set initial visibility to hidden while calculating position...
|
|
390
|
+
visibility: "hidden",
|
|
391
|
+
});
|
|
392
|
+
const availableSpace = this.calculateAvailableSpace();
|
|
393
|
+
const position = this.getOptimalPopoverPosition(this.position, availableSpace);
|
|
394
|
+
this.applyPositionStyles(position, availableSpace);
|
|
433
395
|
this.currentPosition = position;
|
|
396
|
+
this.positionChange.emit({ position: this.currentPosition });
|
|
397
|
+
// ...then restore the visibility
|
|
398
|
+
this.host.style.visibility = "visible";
|
|
434
399
|
}
|
|
435
400
|
componentWillLoad() {
|
|
436
401
|
this.validatePosition(this.position);
|
|
437
|
-
this.onOpen();
|
|
438
402
|
}
|
|
439
403
|
componentDidLoad() {
|
|
440
|
-
this.
|
|
404
|
+
this.findBoundElement();
|
|
405
|
+
if (this.open) {
|
|
406
|
+
this.onOpen();
|
|
407
|
+
}
|
|
441
408
|
}
|
|
442
409
|
disconnectedCallback() {
|
|
443
410
|
cancelAnimationFrame(this.animationFrameRequestId);
|
|
444
411
|
}
|
|
445
412
|
render() {
|
|
446
|
-
return (index.h(index.Host, { key: '
|
|
413
|
+
return (index.h(index.Host, { key: '1eafd1bd08aa31a81378354542b0e74edc4cb0ce', "current-position": this.currentPosition }, index.h("slot", { key: '2ad916cf0e13766e2e5f92f4f964a4fe909cdc7a' })));
|
|
447
414
|
}
|
|
448
415
|
get host() { return index.getElement(this); }
|
|
449
416
|
static get watchers() { return {
|
|
450
417
|
"position": ["validatePosition"],
|
|
451
|
-
"open": ["onOpen"]
|
|
418
|
+
"open": ["onOpen"],
|
|
419
|
+
"bindTo": ["onBindingChange"]
|
|
452
420
|
}; }
|
|
453
421
|
};
|
|
454
422
|
// Clockwise order of positions.
|
|
455
423
|
ZPopover.positionOrder = [
|
|
456
|
-
index$1.PopoverPosition.TOP_RIGHT,
|
|
457
424
|
index$1.PopoverPosition.TOP,
|
|
425
|
+
index$1.PopoverPosition.TOP_RIGHT,
|
|
458
426
|
index$1.PopoverPosition.TOP_LEFT,
|
|
459
|
-
index$1.PopoverPosition.RIGHT_BOTTOM,
|
|
460
427
|
index$1.PopoverPosition.RIGHT,
|
|
428
|
+
index$1.PopoverPosition.RIGHT_BOTTOM,
|
|
461
429
|
index$1.PopoverPosition.RIGHT_TOP,
|
|
462
|
-
index$1.PopoverPosition.BOTTOM_LEFT,
|
|
463
430
|
index$1.PopoverPosition.BOTTOM,
|
|
431
|
+
index$1.PopoverPosition.BOTTOM_LEFT,
|
|
464
432
|
index$1.PopoverPosition.BOTTOM_RIGHT,
|
|
465
|
-
index$1.PopoverPosition.LEFT_TOP,
|
|
466
433
|
index$1.PopoverPosition.LEFT,
|
|
434
|
+
index$1.PopoverPosition.LEFT_TOP,
|
|
467
435
|
index$1.PopoverPosition.LEFT_BOTTOM,
|
|
468
436
|
];
|
|
469
437
|
ZPopover.style = ZPopoverStyle0;
|