@zanichelli/albe-web-components 7.3.7 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2540 -0
- package/dist/cjs/{breakpoints-88c4fd6c.js → breakpoints-ebe1a437.js} +3 -1
- package/dist/cjs/{index-2dfdb7e2.js → index-b7c319f2.js} +11 -0
- package/dist/cjs/index-e3299e0a.js +2 -6
- package/dist/cjs/index.cjs.js +15 -3
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{utils-b447f1da.js → utils-38f8555a.js} +5 -3
- package/dist/cjs/{utils-f21f9a4f.js → utils-938e5834.js} +1 -1
- 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-app-header_11.cjs.entry.js → z-app-header_13.cjs.entry.js} +572 -23
- package/dist/cjs/z-aria-alert.cjs.entry.js +1 -1
- package/dist/cjs/z-avatar.cjs.entry.js +1 -1
- package/dist/cjs/z-button-sort.cjs.entry.js +1 -1
- package/dist/cjs/z-card.cjs.entry.js +1 -1
- package/dist/cjs/z-carousel.cjs.entry.js +1 -1
- package/dist/cjs/z-chip.cjs.entry.js +4 -4
- package/dist/cjs/z-combobox.cjs.entry.js +3 -3
- package/dist/cjs/z-contextual-menu.cjs.entry.js +1 -1
- package/dist/cjs/z-cover-hero.cjs.entry.js +1 -1
- package/dist/cjs/z-date-picker.cjs.entry.js +2 -2
- package/dist/cjs/z-dragdrop-area_2.cjs.entry.js +1 -1
- package/dist/cjs/z-file-upload.cjs.entry.js +4 -4
- package/dist/cjs/z-file.cjs.entry.js +2 -2
- package/dist/cjs/z-info-reveal.cjs.entry.js +1 -1
- package/dist/cjs/z-messages-pocket.cjs.entry.js +1 -1
- package/dist/cjs/z-myz-card-alert.cjs.entry.js +1 -1
- package/dist/cjs/z-myz-card-dictionary.cjs.entry.js +1 -1
- package/dist/cjs/z-myz-card-footer.cjs.entry.js +1 -1
- package/dist/cjs/z-myz-card-info.cjs.entry.js +3 -3
- package/dist/cjs/z-myz-card_4.cjs.entry.js +1 -1
- package/dist/cjs/z-myz-list-item.cjs.entry.js +3 -3
- package/dist/cjs/z-navigation-tab-link.cjs.entry.js +1 -1
- package/dist/cjs/z-navigation-tab.cjs.entry.js +1 -1
- package/dist/cjs/z-navigation-tabs.cjs.entry.js +1 -1
- package/dist/cjs/z-otp.cjs.entry.js +1 -1
- package/dist/cjs/z-pagination.cjs.entry.js +1 -1
- package/dist/cjs/z-pocket_3.cjs.entry.js +3 -3
- package/dist/cjs/z-range-picker.cjs.entry.js +2 -2
- package/dist/cjs/z-section-title.cjs.entry.js +1 -1
- package/dist/cjs/z-select.cjs.entry.js +3 -3
- package/dist/cjs/z-skip-to-content.cjs.entry.js +3 -3
- package/dist/cjs/z-slideshow.cjs.entry.js +3 -3
- package/dist/cjs/z-table-cell.cjs.entry.js +1 -1
- package/dist/cjs/z-table-header.cjs.entry.js +3 -3
- package/dist/cjs/z-table-row.cjs.entry.js +1 -1
- package/dist/cjs/z-table.cjs.entry.js +2 -2
- package/dist/cjs/z-toast-notification-list.cjs.entry.js +1 -1
- package/dist/cjs/z-toast-notification.cjs.entry.js +2 -2
- package/dist/cjs/z-toggle-switch.cjs.entry.js +3 -3
- package/dist/cjs/z-tooltip.cjs.entry.js +1 -1
- package/dist/collection/beans/index.js +11 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/buttons/z-chip/index.js +1 -1
- package/dist/collection/components/file-upload/z-file-upload/index.js +1 -1
- package/dist/collection/components/z-breadcrumb/index.js +421 -0
- package/dist/collection/components/z-breadcrumb/styles.css +139 -0
- package/dist/collection/constants/breakpoints.js +3 -2
- package/dist/collection/utils/utils.js +4 -2
- package/dist/esm/breakpoints-9b81eb1b.js +5 -0
- package/dist/esm/{index-f3202f58.js → index-7e4df1be.js} +12 -1
- package/dist/esm/index-a2ca4b97.js +2 -6
- package/dist/esm/index.js +3 -3
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{utils-930405dd.js → utils-af924ea4.js} +1 -1
- package/dist/esm/{utils-0cfc97ad.js → utils-b7bdd1bf.js} +6 -4
- package/dist/esm/web-components-library.js +1 -1
- package/dist/esm/z-anchor-navigation.entry.js +1 -1
- package/dist/esm/{z-app-header_11.entry.js → z-app-header_13.entry.js} +571 -24
- package/dist/esm/z-aria-alert.entry.js +1 -1
- package/dist/esm/z-avatar.entry.js +1 -1
- package/dist/esm/z-button-sort.entry.js +1 -1
- package/dist/esm/z-card.entry.js +1 -1
- package/dist/esm/z-carousel.entry.js +1 -1
- package/dist/esm/z-chip.entry.js +4 -4
- package/dist/esm/z-combobox.entry.js +3 -3
- package/dist/esm/z-contextual-menu.entry.js +1 -1
- package/dist/esm/z-cover-hero.entry.js +1 -1
- package/dist/esm/z-date-picker.entry.js +2 -2
- package/dist/esm/z-dragdrop-area_2.entry.js +1 -1
- package/dist/esm/z-file-upload.entry.js +4 -4
- package/dist/esm/z-file.entry.js +2 -2
- package/dist/esm/z-info-reveal.entry.js +1 -1
- package/dist/esm/z-messages-pocket.entry.js +1 -1
- package/dist/esm/z-myz-card-alert.entry.js +1 -1
- package/dist/esm/z-myz-card-dictionary.entry.js +1 -1
- package/dist/esm/z-myz-card-footer.entry.js +1 -1
- package/dist/esm/z-myz-card-info.entry.js +3 -3
- package/dist/esm/z-myz-card_4.entry.js +1 -1
- package/dist/esm/z-myz-list-item.entry.js +3 -3
- package/dist/esm/z-navigation-tab-link.entry.js +1 -1
- package/dist/esm/z-navigation-tab.entry.js +1 -1
- package/dist/esm/z-navigation-tabs.entry.js +1 -1
- package/dist/esm/z-otp.entry.js +1 -1
- package/dist/esm/z-pagination.entry.js +1 -1
- package/dist/esm/z-pocket_3.entry.js +3 -3
- package/dist/esm/z-range-picker.entry.js +2 -2
- package/dist/esm/z-section-title.entry.js +1 -1
- package/dist/esm/z-select.entry.js +3 -3
- package/dist/esm/z-skip-to-content.entry.js +3 -3
- package/dist/esm/z-slideshow.entry.js +3 -3
- package/dist/esm/z-table-cell.entry.js +1 -1
- package/dist/esm/z-table-header.entry.js +3 -3
- package/dist/esm/z-table-row.entry.js +1 -1
- package/dist/esm/z-table.entry.js +2 -2
- package/dist/esm/z-toast-notification-list.entry.js +1 -1
- package/dist/esm/z-toast-notification.entry.js +2 -2
- package/dist/esm/z-toggle-switch.entry.js +3 -3
- package/dist/esm/z-tooltip.entry.js +1 -1
- package/dist/types/beans/index.d.ts +15 -1
- package/dist/types/components/z-breadcrumb/index.d.ts +58 -0
- package/dist/types/components.d.ts +78 -1
- package/dist/types/constants/breakpoints.d.ts +3 -2
- package/dist/web-components-library/index.esm.js +1 -1
- package/dist/web-components-library/p-0235869e.entry.js +1 -0
- package/dist/web-components-library/p-0397366d.js +1 -0
- package/dist/web-components-library/{p-39c52a0d.entry.js → p-0418f9fb.entry.js} +1 -1
- package/dist/web-components-library/{p-b85be817.entry.js → p-079357ba.entry.js} +1 -1
- package/dist/web-components-library/{p-c736b92c.entry.js → p-0b822ad0.entry.js} +1 -1
- package/{www/build/p-cf53ce51.entry.js → dist/web-components-library/p-0c0735e5.entry.js} +1 -1
- package/dist/web-components-library/{p-5449fd41.entry.js → p-10f2be79.entry.js} +1 -1
- package/dist/web-components-library/p-14ab82cd.entry.js +1 -0
- package/dist/web-components-library/{p-6736e894.entry.js → p-14db3f16.entry.js} +1 -1
- package/dist/web-components-library/p-1cc1a418.js +1 -0
- package/dist/web-components-library/{p-93191e1d.entry.js → p-1e7ef8ca.entry.js} +1 -1
- package/dist/web-components-library/{p-74c27fc5.entry.js → p-227667b6.entry.js} +1 -1
- package/dist/web-components-library/{p-daf06f6f.entry.js → p-27100ea1.entry.js} +1 -1
- package/dist/web-components-library/{p-0c07b4f9.entry.js → p-2f547970.entry.js} +1 -1
- package/dist/web-components-library/{p-515b46d9.entry.js → p-4610db36.entry.js} +1 -1
- package/dist/web-components-library/{p-2c871e12.entry.js → p-485bff7b.entry.js} +1 -1
- package/dist/web-components-library/{p-a93e5cad.entry.js → p-4b9882b3.entry.js} +1 -1
- package/dist/web-components-library/p-515c2acf.entry.js +1 -0
- package/dist/web-components-library/p-685ae50d.entry.js +1 -0
- package/dist/web-components-library/{p-4c85652a.entry.js → p-6be6a2f4.entry.js} +1 -1
- package/{www/build/p-82291408.entry.js → dist/web-components-library/p-7ac431a5.entry.js} +1 -1
- package/{www/build/p-c64c5cbb.entry.js → dist/web-components-library/p-8f7680ef.entry.js} +1 -1
- package/dist/web-components-library/{p-562eb005.entry.js → p-910ca14c.entry.js} +1 -1
- package/dist/web-components-library/{p-adce9752.entry.js → p-9fee86aa.entry.js} +1 -1
- package/dist/web-components-library/{p-eb293bba.entry.js → p-a19a70a0.entry.js} +1 -1
- package/{www/build/p-9566edeb.entry.js → dist/web-components-library/p-a250409a.entry.js} +1 -1
- package/dist/web-components-library/p-a4b91a8f.entry.js +1 -0
- package/dist/web-components-library/{p-c085be1d.entry.js → p-ac5dda12.entry.js} +1 -1
- package/dist/web-components-library/{p-84116d2d.entry.js → p-af5103a0.entry.js} +1 -1
- package/dist/web-components-library/p-b497e33e.js +1 -0
- package/{www/build/p-ffc56e80.entry.js → dist/web-components-library/p-bda48953.entry.js} +1 -1
- package/dist/web-components-library/{p-7d8711d1.entry.js → p-c241bab0.entry.js} +1 -1
- package/dist/web-components-library/{p-8d4b2131.entry.js → p-c47d529f.entry.js} +1 -1
- package/dist/web-components-library/{p-1505703f.entry.js → p-c8b36560.entry.js} +1 -1
- package/dist/web-components-library/p-c8bdfb84.entry.js +1 -0
- package/dist/web-components-library/{p-33251591.entry.js → p-cd456854.entry.js} +1 -1
- package/dist/web-components-library/{p-66c4eda8.entry.js → p-cfc9cf52.entry.js} +1 -1
- package/dist/web-components-library/{p-5d651052.entry.js → p-d011d1b5.entry.js} +1 -1
- package/{www/build/p-8539c6f2.entry.js → dist/web-components-library/p-d966a1b9.entry.js} +1 -1
- package/dist/web-components-library/{p-9c3f4437.entry.js → p-d98d3cf1.entry.js} +1 -1
- package/dist/web-components-library/{p-3bd60dc8.entry.js → p-e606b019.entry.js} +1 -1
- package/dist/web-components-library/{p-32c36f6c.entry.js → p-ec5242da.entry.js} +1 -1
- package/dist/web-components-library/{p-e9bf5f75.js → p-ee918c17.js} +1 -1
- package/dist/web-components-library/{p-a4e68d80.entry.js → p-f5a247b9.entry.js} +1 -1
- package/{www/build/p-642d6be4.entry.js → dist/web-components-library/p-fd8eae32.entry.js} +1 -1
- package/dist/web-components-library/{p-c75451cc.entry.js → p-ff838f90.entry.js} +1 -1
- package/dist/web-components-library/web-components-library.esm.js +1 -1
- package/package.json +1 -1
- package/react/components.d.ts +1 -0
- package/react/components.js +3 -2
- package/react/components.js.map +1 -1
- package/src-react/index.ts +1 -0
- package/www/build/index.esm.js +1 -1
- package/www/build/p-0235869e.entry.js +1 -0
- package/www/build/p-0397366d.js +1 -0
- package/www/build/{p-39c52a0d.entry.js → p-0418f9fb.entry.js} +1 -1
- package/www/build/{p-b85be817.entry.js → p-079357ba.entry.js} +1 -1
- package/www/build/{p-c736b92c.entry.js → p-0b822ad0.entry.js} +1 -1
- package/{dist/web-components-library/p-cf53ce51.entry.js → www/build/p-0c0735e5.entry.js} +1 -1
- package/www/build/{p-5449fd41.entry.js → p-10f2be79.entry.js} +1 -1
- package/www/build/p-14ab82cd.entry.js +1 -0
- package/www/build/{p-6736e894.entry.js → p-14db3f16.entry.js} +1 -1
- package/www/build/p-1cc1a418.js +1 -0
- package/www/build/{p-93191e1d.entry.js → p-1e7ef8ca.entry.js} +1 -1
- package/www/build/{p-74c27fc5.entry.js → p-227667b6.entry.js} +1 -1
- package/www/build/{p-daf06f6f.entry.js → p-27100ea1.entry.js} +1 -1
- package/www/build/{p-0c07b4f9.entry.js → p-2f547970.entry.js} +1 -1
- package/www/build/{p-515b46d9.entry.js → p-4610db36.entry.js} +1 -1
- package/www/build/{p-2c871e12.entry.js → p-485bff7b.entry.js} +1 -1
- package/www/build/{p-a93e5cad.entry.js → p-4b9882b3.entry.js} +1 -1
- package/www/build/p-515c2acf.entry.js +1 -0
- package/www/build/p-685ae50d.entry.js +1 -0
- package/www/build/{p-4c85652a.entry.js → p-6be6a2f4.entry.js} +1 -1
- package/{dist/web-components-library/p-82291408.entry.js → www/build/p-7ac431a5.entry.js} +1 -1
- package/{dist/web-components-library/p-c64c5cbb.entry.js → www/build/p-8f7680ef.entry.js} +1 -1
- package/www/build/{p-562eb005.entry.js → p-910ca14c.entry.js} +1 -1
- package/www/build/{p-adce9752.entry.js → p-9fee86aa.entry.js} +1 -1
- package/www/build/{p-eb293bba.entry.js → p-a19a70a0.entry.js} +1 -1
- package/{dist/web-components-library/p-9566edeb.entry.js → www/build/p-a250409a.entry.js} +1 -1
- package/www/build/p-a4b91a8f.entry.js +1 -0
- package/www/build/{p-c085be1d.entry.js → p-ac5dda12.entry.js} +1 -1
- package/www/build/{p-84116d2d.entry.js → p-af5103a0.entry.js} +1 -1
- package/www/build/p-b497e33e.js +1 -0
- package/{dist/web-components-library/p-ffc56e80.entry.js → www/build/p-bda48953.entry.js} +1 -1
- package/www/build/{p-7d8711d1.entry.js → p-c241bab0.entry.js} +1 -1
- package/www/build/{p-8d4b2131.entry.js → p-c47d529f.entry.js} +1 -1
- package/www/build/{p-1505703f.entry.js → p-c8b36560.entry.js} +1 -1
- package/www/build/p-c8bdfb84.entry.js +1 -0
- package/www/build/{p-33251591.entry.js → p-cd456854.entry.js} +1 -1
- package/www/build/{p-66c4eda8.entry.js → p-cfc9cf52.entry.js} +1 -1
- package/www/build/{p-5d651052.entry.js → p-d011d1b5.entry.js} +1 -1
- package/{dist/web-components-library/p-8539c6f2.entry.js → www/build/p-d966a1b9.entry.js} +1 -1
- package/www/build/{p-9c3f4437.entry.js → p-d98d3cf1.entry.js} +1 -1
- package/www/build/p-e35c7022.js +1 -0
- package/www/build/{p-3bd60dc8.entry.js → p-e606b019.entry.js} +1 -1
- package/www/build/{p-32c36f6c.entry.js → p-ec5242da.entry.js} +1 -1
- package/www/build/{p-e9bf5f75.js → p-ee918c17.js} +1 -1
- package/www/build/{p-a4e68d80.entry.js → p-f5a247b9.entry.js} +1 -1
- package/{dist/web-components-library/p-642d6be4.entry.js → www/build/p-fd8eae32.entry.js} +1 -1
- package/www/build/{p-c75451cc.entry.js → p-ff838f90.entry.js} +1 -1
- package/www/build/web-components-library.esm.js +1 -1
- package/www/index.html +127 -1
- package/dist/cjs/z-popover.cjs.entry.js +0 -328
- package/dist/esm/breakpoints-c386984e.js +0 -4
- package/dist/esm/z-popover.entry.js +0 -324
- package/dist/web-components-library/p-06de959d.entry.js +0 -1
- package/dist/web-components-library/p-1b4d5a24.entry.js +0 -1
- package/dist/web-components-library/p-6816cba3.entry.js +0 -1
- package/dist/web-components-library/p-6b454593.js +0 -1
- package/dist/web-components-library/p-7a276150.entry.js +0 -1
- package/dist/web-components-library/p-7c94ae08.entry.js +0 -1
- package/dist/web-components-library/p-98eac308.entry.js +0 -1
- package/dist/web-components-library/p-b1068026.js +0 -1
- package/dist/web-components-library/p-d69e14fb.js +0 -1
- package/dist/web-components-library/p-dcea357f.entry.js +0 -1
- package/www/build/p-06de959d.entry.js +0 -1
- package/www/build/p-1b4d5a24.entry.js +0 -1
- package/www/build/p-6816cba3.entry.js +0 -1
- package/www/build/p-6b454593.js +0 -1
- package/www/build/p-7a276150.entry.js +0 -1
- package/www/build/p-7c94ae08.entry.js +0 -1
- package/www/build/p-98eac308.entry.js +0 -1
- package/www/build/p-b1068026.js +0 -1
- package/www/build/p-d69e14fb.js +0 -1
- package/www/build/p-dcea357f.entry.js +0 -1
- package/www/build/p-f8cba0b0.js +0 -1
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-e3299e0a.js');
|
|
6
|
-
const index$1 = require('./index-2dfdb7e2.js');
|
|
7
|
-
|
|
8
|
-
const stylesCss = ":host{--z-popover-theme--surface:var(--color-surface01);--z-popover-theme--text:var(--color-text01);--z-popover-padding:0;--z-popover-shadow-filter:drop-shadow(0 1px 2px var(--shadow-color-base));position:relative;display:none;min-width:calc(var(--space-unit) * 8);min-height:calc(var(--space-unit) * 4);align-items:center;justify-content:center;padding:var(--z-popover-padding);background:var(--z-popover-theme--surface);border-radius:var(--border-radius-small);color:var(--z-popover-theme--text);fill:currentcolor;filter:var(--z-popover-shadow-filter);font-family:var(--font-family-sans);text-align:center}:host([open][current-position]),:host([open=\"true\"][current-position]){display:flex}: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);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}::slotted(*){overflow:auto;flex:1 auto}";
|
|
9
|
-
|
|
10
|
-
const DOCUMENT_ELEMENT = document.documentElement;
|
|
11
|
-
function getParentElement(element) {
|
|
12
|
-
if (element.parentNode.host) {
|
|
13
|
-
return element.parentNode.host;
|
|
14
|
-
}
|
|
15
|
-
return element.parentNode;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Find the closest scrollable parent of a node.
|
|
19
|
-
*
|
|
20
|
-
* @param {Element} element The node
|
|
21
|
-
*/
|
|
22
|
-
function findScrollableParent(element) {
|
|
23
|
-
let parent = getParentElement(element);
|
|
24
|
-
while (parent && parent !== DOCUMENT_ELEMENT) {
|
|
25
|
-
const { overflow, overflowX, overflowY } = window.getComputedStyle(parent);
|
|
26
|
-
if (overflow === "hidden" || overflowY === "hidden" || overflowX === "hidden") {
|
|
27
|
-
return parent;
|
|
28
|
-
}
|
|
29
|
-
if ((parent.scrollHeight > parent.clientHeight && overflow !== "visible" && overflowY !== "visible") ||
|
|
30
|
-
(parent.scrollWidth > parent.clientWidth && overflow !== "visible" && overflowX !== "visible")) {
|
|
31
|
-
return parent;
|
|
32
|
-
}
|
|
33
|
-
parent = getParentElement(parent);
|
|
34
|
-
}
|
|
35
|
-
return DOCUMENT_ELEMENT;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Calculate computed offset.
|
|
39
|
-
* It includes matrix transformations.
|
|
40
|
-
* @param element The target element.
|
|
41
|
-
* @param targetParentOffset The relative offset parent.
|
|
42
|
-
* @return A client rect object.
|
|
43
|
-
*/
|
|
44
|
-
function computeOffset(element, targetParentOffset) {
|
|
45
|
-
const rect = element.getBoundingClientRect();
|
|
46
|
-
const width = rect.width;
|
|
47
|
-
const height = rect.height;
|
|
48
|
-
let top = 0;
|
|
49
|
-
let left = 0;
|
|
50
|
-
let offsetParent = element;
|
|
51
|
-
while (offsetParent && offsetParent != targetParentOffset) {
|
|
52
|
-
left += offsetParent.offsetLeft;
|
|
53
|
-
// document.body sometimes has offsetTop == 0 but still has an
|
|
54
|
-
// offset because of children margins!
|
|
55
|
-
if (offsetParent === document.body) {
|
|
56
|
-
top += offsetParent.getBoundingClientRect().top + window.scrollY;
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
top += offsetParent.offsetTop;
|
|
60
|
-
}
|
|
61
|
-
if (window.DOMMatrix) {
|
|
62
|
-
const style = window.getComputedStyle(offsetParent);
|
|
63
|
-
const transform = style.transform || style.webkitTransform;
|
|
64
|
-
const domMatrix = new DOMMatrix(transform);
|
|
65
|
-
if (domMatrix) {
|
|
66
|
-
left += domMatrix.m41;
|
|
67
|
-
if (offsetParent !== document.body) {
|
|
68
|
-
top += domMatrix.m42;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (!offsetParent.offsetParent) {
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
offsetParent = offsetParent.offsetParent;
|
|
76
|
-
}
|
|
77
|
-
let parentWidth;
|
|
78
|
-
let parentHeight;
|
|
79
|
-
if (offsetParent === document.body) {
|
|
80
|
-
parentWidth = window.innerWidth;
|
|
81
|
-
parentHeight = window.innerHeight;
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
parentWidth = offsetParent.offsetWidth;
|
|
85
|
-
parentHeight = offsetParent.offsetHeight;
|
|
86
|
-
}
|
|
87
|
-
const right = parentWidth - left - rect.width;
|
|
88
|
-
const bottom = parentHeight - top - rect.height;
|
|
89
|
-
return { top, right, bottom, left, width, height };
|
|
90
|
-
}
|
|
91
|
-
const ZPopover = class {
|
|
92
|
-
constructor(hostRef) {
|
|
93
|
-
index.registerInstance(this, hostRef);
|
|
94
|
-
this.positionChange = index.createEvent(this, "positionChange", 7);
|
|
95
|
-
this.openChange = index.createEvent(this, "openChange", 7);
|
|
96
|
-
/** Popover position. */
|
|
97
|
-
this.position = index$1.PopoverPosition.AUTO;
|
|
98
|
-
/**
|
|
99
|
-
* The open state of the popover.
|
|
100
|
-
*/
|
|
101
|
-
this.open = false;
|
|
102
|
-
/**
|
|
103
|
-
* Whether to show popover's arrow.
|
|
104
|
-
*/
|
|
105
|
-
this.showArrow = false;
|
|
106
|
-
/**
|
|
107
|
-
* Whether to center the popup on the main side (according to "position").
|
|
108
|
-
*/
|
|
109
|
-
this.center = false;
|
|
110
|
-
/**
|
|
111
|
-
* If true, the popover can be closed by clicking outside of it or pressing the escape key.
|
|
112
|
-
* Otherwise, it will be closed only programmatically (by setting `open` to `false`).
|
|
113
|
-
*/
|
|
114
|
-
this.closable = true;
|
|
115
|
-
}
|
|
116
|
-
closePopoverWithKeyboard(e) {
|
|
117
|
-
if (this.closable && e.key === index$1.KeyboardCode.ESC) {
|
|
118
|
-
this.open = false;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Close the popover when clicking outside of its content.
|
|
123
|
-
* Stop event propagation if the click was fired by popover's trigger element,
|
|
124
|
-
* to prevent close and reopen glitches.
|
|
125
|
-
* @param {MouseEvent} e
|
|
126
|
-
*/
|
|
127
|
-
handleOutsideClick(e) {
|
|
128
|
-
if (!this.closable || !this.open) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (!e.composedPath().includes(this.host)) {
|
|
132
|
-
const target = e.target;
|
|
133
|
-
const triggerElemClicked = this.bindTo instanceof HTMLElement ? this.bindTo.contains(target) : target.closest(this.bindTo);
|
|
134
|
-
if (triggerElemClicked) {
|
|
135
|
-
e.stopPropagation();
|
|
136
|
-
}
|
|
137
|
-
this.open = false;
|
|
138
|
-
this.positionChange.emit({ position: this.currentPosition });
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
validatePosition(newValue) {
|
|
142
|
-
if (newValue && !Object.values(index$1.PopoverPosition).includes(newValue)) {
|
|
143
|
-
this.position = index$1.PopoverPosition.AUTO;
|
|
144
|
-
}
|
|
145
|
-
this.currentPosition = this.position;
|
|
146
|
-
this.positionChange.emit({ position: this.currentPosition });
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Setup popover behaviors on opening.
|
|
150
|
-
*/
|
|
151
|
-
onOpen() {
|
|
152
|
-
cancelAnimationFrame(this.animationFrameRequestId);
|
|
153
|
-
if (this.open) {
|
|
154
|
-
const setPosition = () => {
|
|
155
|
-
if (this.open) {
|
|
156
|
-
this.setPosition();
|
|
157
|
-
this.animationFrameRequestId = requestAnimationFrame(setPosition);
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
setPosition();
|
|
161
|
-
}
|
|
162
|
-
else if (this.host.hasAttribute("current-position")) {
|
|
163
|
-
this.host.removeAttribute("current-position");
|
|
164
|
-
this.currentPosition = undefined;
|
|
165
|
-
}
|
|
166
|
-
this.openChange.emit({ open: this.open });
|
|
167
|
-
}
|
|
168
|
-
disconnectedCallback() {
|
|
169
|
-
cancelAnimationFrame(this.animationFrameRequestId);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Set the position of the popover.
|
|
173
|
-
*/
|
|
174
|
-
setPosition() {
|
|
175
|
-
let element;
|
|
176
|
-
if (typeof this.bindTo === "string") {
|
|
177
|
-
element = this.host.ownerDocument.querySelector(this.bindTo);
|
|
178
|
-
}
|
|
179
|
-
else if (this.bindTo) {
|
|
180
|
-
element = this.bindTo;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
element = this.host.parentElement;
|
|
184
|
-
}
|
|
185
|
-
if (!element) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
const scrollContainer = findScrollableParent(element);
|
|
189
|
-
const scrollingBoundingRect = scrollContainer.getBoundingClientRect();
|
|
190
|
-
const offsetContainer = this.host.offsetParent;
|
|
191
|
-
const relativeBoundingRect = offsetContainer
|
|
192
|
-
? computeOffset(offsetContainer, scrollContainer)
|
|
193
|
-
: { top: 0, right: 0, bottom: 0, left: 0 };
|
|
194
|
-
const boundingRect = computeOffset(element, scrollContainer);
|
|
195
|
-
const top = boundingRect.top - scrollContainer.scrollTop;
|
|
196
|
-
const bottom = scrollingBoundingRect.height - (boundingRect.top + boundingRect.height) + scrollContainer.scrollTop;
|
|
197
|
-
const left = boundingRect.left - scrollContainer.scrollLeft;
|
|
198
|
-
const right = scrollingBoundingRect.width - (boundingRect.left + boundingRect.width) + scrollContainer.scrollLeft;
|
|
199
|
-
const overflowBottom = Math.max(0, scrollingBoundingRect.top + scrollingBoundingRect.height - window.innerHeight);
|
|
200
|
-
const overflowRight = Math.max(0, scrollingBoundingRect.left + scrollingBoundingRect.width - window.innerWidth);
|
|
201
|
-
const availableTop = Math.min(top, top + scrollingBoundingRect.top);
|
|
202
|
-
const availableBottom = Math.min(bottom, bottom - overflowBottom);
|
|
203
|
-
const availableLeft = Math.min(left, left + scrollingBoundingRect.left);
|
|
204
|
-
const availableRight = Math.min(right, right - overflowRight);
|
|
205
|
-
const availableHeight = availableTop + availableBottom + boundingRect.height;
|
|
206
|
-
const availableWidth = availableLeft + availableRight + boundingRect.width;
|
|
207
|
-
let position = this.currentPosition;
|
|
208
|
-
const positions = [];
|
|
209
|
-
if (this.position === index$1.PopoverPosition.AUTO) {
|
|
210
|
-
/**
|
|
211
|
-
* The `AUTO` position tries to place the popover in the 'safest' area,
|
|
212
|
-
* where there's more space available.
|
|
213
|
-
*/
|
|
214
|
-
if (availableLeft / availableWidth > 0.6) {
|
|
215
|
-
positions.push(index$1.PopoverPosition.LEFT);
|
|
216
|
-
}
|
|
217
|
-
else if (availableLeft / availableWidth < 0.4) {
|
|
218
|
-
positions.push(index$1.PopoverPosition.RIGHT);
|
|
219
|
-
}
|
|
220
|
-
if (availableTop / availableHeight > 0.9) {
|
|
221
|
-
positions.unshift(index$1.PopoverPosition.TOP);
|
|
222
|
-
}
|
|
223
|
-
else if (availableTop / availableHeight > 0.6) {
|
|
224
|
-
positions.push(index$1.PopoverPosition.TOP);
|
|
225
|
-
}
|
|
226
|
-
else if (availableTop / availableHeight < 0.1) {
|
|
227
|
-
positions.unshift(index$1.PopoverPosition.BOTTOM);
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
positions.push(index$1.PopoverPosition.BOTTOM);
|
|
231
|
-
}
|
|
232
|
-
position = positions.join("_");
|
|
233
|
-
}
|
|
234
|
-
const style = this.host.style;
|
|
235
|
-
style.position = "absolute";
|
|
236
|
-
const offsetTop = boundingRect.top - relativeBoundingRect.top;
|
|
237
|
-
const offsetRight = boundingRect.right - relativeBoundingRect.right;
|
|
238
|
-
const offsetBottom = boundingRect.bottom - relativeBoundingRect.bottom;
|
|
239
|
-
const offsetLeft = boundingRect.left - relativeBoundingRect.left;
|
|
240
|
-
const offsetModifier = this.center ? 0.5 : 0;
|
|
241
|
-
const sizeModifier = this.center ? 0.5 : 0;
|
|
242
|
-
if (position === index$1.PopoverPosition.TOP || position === index$1.PopoverPosition.TOP_RIGHT) {
|
|
243
|
-
style.top = "auto";
|
|
244
|
-
style.right = "auto";
|
|
245
|
-
style.bottom = `${offsetBottom + boundingRect.height}px`;
|
|
246
|
-
style.left = `${offsetLeft + boundingRect.width * offsetModifier}px`;
|
|
247
|
-
style.maxHeight = `${availableTop}px`;
|
|
248
|
-
if (position === index$1.PopoverPosition.TOP_RIGHT) {
|
|
249
|
-
style.maxWidth = `${availableRight + boundingRect.width * sizeModifier}px`;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
else if (position === index$1.PopoverPosition.TOP_LEFT) {
|
|
253
|
-
style.top = "auto";
|
|
254
|
-
style.right = `${offsetRight + boundingRect.width * offsetModifier}px`;
|
|
255
|
-
style.bottom = `${offsetBottom + boundingRect.height}px`;
|
|
256
|
-
style.left = "auto";
|
|
257
|
-
style.maxWidth = `${availableLeft}px`;
|
|
258
|
-
style.maxHeight = `${availableTop}px`;
|
|
259
|
-
}
|
|
260
|
-
else if (position === index$1.PopoverPosition.BOTTOM || position === index$1.PopoverPosition.BOTTOM_RIGHT) {
|
|
261
|
-
style.top = `${offsetTop + boundingRect.height}px`;
|
|
262
|
-
style.right = "auto";
|
|
263
|
-
style.bottom = "auto";
|
|
264
|
-
style.left = `${offsetLeft + boundingRect.width * offsetModifier}px`;
|
|
265
|
-
style.maxHeight = `${availableBottom}px`;
|
|
266
|
-
if (position === index$1.PopoverPosition.BOTTOM_RIGHT) {
|
|
267
|
-
style.maxWidth = `${availableRight + boundingRect.width * sizeModifier}px`;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
else if (position === index$1.PopoverPosition.BOTTOM_LEFT) {
|
|
271
|
-
style.top = `${offsetTop + boundingRect.height}px`;
|
|
272
|
-
style.right = `${offsetRight + boundingRect.width * offsetModifier}px`;
|
|
273
|
-
style.bottom = "auto";
|
|
274
|
-
style.left = "auto";
|
|
275
|
-
style.maxWidth = `${availableLeft}px`;
|
|
276
|
-
style.maxHeight = `${availableBottom}px`;
|
|
277
|
-
}
|
|
278
|
-
else if (position === index$1.PopoverPosition.RIGHT || position === index$1.PopoverPosition.RIGHT_BOTTOM) {
|
|
279
|
-
style.top = `${offsetTop + boundingRect.height * offsetModifier}px`;
|
|
280
|
-
style.right = "auto";
|
|
281
|
-
style.bottom = "auto";
|
|
282
|
-
style.left = `${offsetLeft + boundingRect.width}px`;
|
|
283
|
-
style.maxWidth = `${availableRight}px`;
|
|
284
|
-
style.maxHeight = `${availableBottom + boundingRect.height * sizeModifier}px`;
|
|
285
|
-
}
|
|
286
|
-
else if (position === index$1.PopoverPosition.RIGHT_TOP) {
|
|
287
|
-
style.top = "auto";
|
|
288
|
-
style.right = "auto";
|
|
289
|
-
style.bottom = `${offsetBottom + boundingRect.height * offsetModifier}px`;
|
|
290
|
-
style.left = `${offsetLeft + boundingRect.width}px`;
|
|
291
|
-
style.maxWidth = `${availableRight}px`;
|
|
292
|
-
style.maxHeight = `${availableTop + boundingRect.height * sizeModifier}px`;
|
|
293
|
-
}
|
|
294
|
-
else if (position === index$1.PopoverPosition.LEFT || position === index$1.PopoverPosition.LEFT_BOTTOM) {
|
|
295
|
-
style.top = `${offsetTop + boundingRect.height * offsetModifier}px`;
|
|
296
|
-
style.right = `${offsetRight + boundingRect.width}px`;
|
|
297
|
-
style.bottom = "auto";
|
|
298
|
-
style.left = "auto";
|
|
299
|
-
style.maxWidth = `${availableLeft}px`;
|
|
300
|
-
style.maxHeight = `${availableBottom + boundingRect.height * sizeModifier}px`;
|
|
301
|
-
}
|
|
302
|
-
else if (position === index$1.PopoverPosition.LEFT_TOP) {
|
|
303
|
-
style.top = "auto";
|
|
304
|
-
style.right = `${offsetRight + boundingRect.width}px`;
|
|
305
|
-
style.bottom = `${offsetBottom + boundingRect.height * offsetModifier}px`;
|
|
306
|
-
style.left = "auto";
|
|
307
|
-
style.maxWidth = `${availableLeft}px`;
|
|
308
|
-
style.maxHeight = `${availableTop + boundingRect.height * sizeModifier}px`;
|
|
309
|
-
}
|
|
310
|
-
this.currentPosition = position || this.position;
|
|
311
|
-
this.host.setAttribute("current-position", this.currentPosition);
|
|
312
|
-
}
|
|
313
|
-
componentWillLoad() {
|
|
314
|
-
this.validatePosition(this.position);
|
|
315
|
-
this.onOpen();
|
|
316
|
-
}
|
|
317
|
-
render() {
|
|
318
|
-
return index.h("slot", null);
|
|
319
|
-
}
|
|
320
|
-
get host() { return index.getElement(this); }
|
|
321
|
-
static get watchers() { return {
|
|
322
|
-
"position": ["validatePosition"],
|
|
323
|
-
"open": ["onOpen"]
|
|
324
|
-
}; }
|
|
325
|
-
};
|
|
326
|
-
ZPopover.style = stylesCss;
|
|
327
|
-
|
|
328
|
-
exports.z_popover = ZPopover;
|
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-a2ca4b97.js';
|
|
2
|
-
import { P as PopoverPosition, g as KeyboardCode } from './index-f3202f58.js';
|
|
3
|
-
|
|
4
|
-
const stylesCss = ":host{--z-popover-theme--surface:var(--color-surface01);--z-popover-theme--text:var(--color-text01);--z-popover-padding:0;--z-popover-shadow-filter:drop-shadow(0 1px 2px var(--shadow-color-base));position:relative;display:none;min-width:calc(var(--space-unit) * 8);min-height:calc(var(--space-unit) * 4);align-items:center;justify-content:center;padding:var(--z-popover-padding);background:var(--z-popover-theme--surface);border-radius:var(--border-radius-small);color:var(--z-popover-theme--text);fill:currentcolor;filter:var(--z-popover-shadow-filter);font-family:var(--font-family-sans);text-align:center}:host([open][current-position]),:host([open=\"true\"][current-position]){display:flex}: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);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}::slotted(*){overflow:auto;flex:1 auto}";
|
|
5
|
-
|
|
6
|
-
const DOCUMENT_ELEMENT = document.documentElement;
|
|
7
|
-
function getParentElement(element) {
|
|
8
|
-
if (element.parentNode.host) {
|
|
9
|
-
return element.parentNode.host;
|
|
10
|
-
}
|
|
11
|
-
return element.parentNode;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Find the closest scrollable parent of a node.
|
|
15
|
-
*
|
|
16
|
-
* @param {Element} element The node
|
|
17
|
-
*/
|
|
18
|
-
function findScrollableParent(element) {
|
|
19
|
-
let parent = getParentElement(element);
|
|
20
|
-
while (parent && parent !== DOCUMENT_ELEMENT) {
|
|
21
|
-
const { overflow, overflowX, overflowY } = window.getComputedStyle(parent);
|
|
22
|
-
if (overflow === "hidden" || overflowY === "hidden" || overflowX === "hidden") {
|
|
23
|
-
return parent;
|
|
24
|
-
}
|
|
25
|
-
if ((parent.scrollHeight > parent.clientHeight && overflow !== "visible" && overflowY !== "visible") ||
|
|
26
|
-
(parent.scrollWidth > parent.clientWidth && overflow !== "visible" && overflowX !== "visible")) {
|
|
27
|
-
return parent;
|
|
28
|
-
}
|
|
29
|
-
parent = getParentElement(parent);
|
|
30
|
-
}
|
|
31
|
-
return DOCUMENT_ELEMENT;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Calculate computed offset.
|
|
35
|
-
* It includes matrix transformations.
|
|
36
|
-
* @param element The target element.
|
|
37
|
-
* @param targetParentOffset The relative offset parent.
|
|
38
|
-
* @return A client rect object.
|
|
39
|
-
*/
|
|
40
|
-
function computeOffset(element, targetParentOffset) {
|
|
41
|
-
const rect = element.getBoundingClientRect();
|
|
42
|
-
const width = rect.width;
|
|
43
|
-
const height = rect.height;
|
|
44
|
-
let top = 0;
|
|
45
|
-
let left = 0;
|
|
46
|
-
let offsetParent = element;
|
|
47
|
-
while (offsetParent && offsetParent != targetParentOffset) {
|
|
48
|
-
left += offsetParent.offsetLeft;
|
|
49
|
-
// document.body sometimes has offsetTop == 0 but still has an
|
|
50
|
-
// offset because of children margins!
|
|
51
|
-
if (offsetParent === document.body) {
|
|
52
|
-
top += offsetParent.getBoundingClientRect().top + window.scrollY;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
top += offsetParent.offsetTop;
|
|
56
|
-
}
|
|
57
|
-
if (window.DOMMatrix) {
|
|
58
|
-
const style = window.getComputedStyle(offsetParent);
|
|
59
|
-
const transform = style.transform || style.webkitTransform;
|
|
60
|
-
const domMatrix = new DOMMatrix(transform);
|
|
61
|
-
if (domMatrix) {
|
|
62
|
-
left += domMatrix.m41;
|
|
63
|
-
if (offsetParent !== document.body) {
|
|
64
|
-
top += domMatrix.m42;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (!offsetParent.offsetParent) {
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
offsetParent = offsetParent.offsetParent;
|
|
72
|
-
}
|
|
73
|
-
let parentWidth;
|
|
74
|
-
let parentHeight;
|
|
75
|
-
if (offsetParent === document.body) {
|
|
76
|
-
parentWidth = window.innerWidth;
|
|
77
|
-
parentHeight = window.innerHeight;
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
parentWidth = offsetParent.offsetWidth;
|
|
81
|
-
parentHeight = offsetParent.offsetHeight;
|
|
82
|
-
}
|
|
83
|
-
const right = parentWidth - left - rect.width;
|
|
84
|
-
const bottom = parentHeight - top - rect.height;
|
|
85
|
-
return { top, right, bottom, left, width, height };
|
|
86
|
-
}
|
|
87
|
-
const ZPopover = class {
|
|
88
|
-
constructor(hostRef) {
|
|
89
|
-
registerInstance(this, hostRef);
|
|
90
|
-
this.positionChange = createEvent(this, "positionChange", 7);
|
|
91
|
-
this.openChange = createEvent(this, "openChange", 7);
|
|
92
|
-
/** Popover position. */
|
|
93
|
-
this.position = PopoverPosition.AUTO;
|
|
94
|
-
/**
|
|
95
|
-
* The open state of the popover.
|
|
96
|
-
*/
|
|
97
|
-
this.open = false;
|
|
98
|
-
/**
|
|
99
|
-
* Whether to show popover's arrow.
|
|
100
|
-
*/
|
|
101
|
-
this.showArrow = false;
|
|
102
|
-
/**
|
|
103
|
-
* Whether to center the popup on the main side (according to "position").
|
|
104
|
-
*/
|
|
105
|
-
this.center = false;
|
|
106
|
-
/**
|
|
107
|
-
* If true, the popover can be closed by clicking outside of it or pressing the escape key.
|
|
108
|
-
* Otherwise, it will be closed only programmatically (by setting `open` to `false`).
|
|
109
|
-
*/
|
|
110
|
-
this.closable = true;
|
|
111
|
-
}
|
|
112
|
-
closePopoverWithKeyboard(e) {
|
|
113
|
-
if (this.closable && e.key === KeyboardCode.ESC) {
|
|
114
|
-
this.open = false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Close the popover when clicking outside of its content.
|
|
119
|
-
* Stop event propagation if the click was fired by popover's trigger element,
|
|
120
|
-
* to prevent close and reopen glitches.
|
|
121
|
-
* @param {MouseEvent} e
|
|
122
|
-
*/
|
|
123
|
-
handleOutsideClick(e) {
|
|
124
|
-
if (!this.closable || !this.open) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (!e.composedPath().includes(this.host)) {
|
|
128
|
-
const target = e.target;
|
|
129
|
-
const triggerElemClicked = this.bindTo instanceof HTMLElement ? this.bindTo.contains(target) : target.closest(this.bindTo);
|
|
130
|
-
if (triggerElemClicked) {
|
|
131
|
-
e.stopPropagation();
|
|
132
|
-
}
|
|
133
|
-
this.open = false;
|
|
134
|
-
this.positionChange.emit({ position: this.currentPosition });
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
validatePosition(newValue) {
|
|
138
|
-
if (newValue && !Object.values(PopoverPosition).includes(newValue)) {
|
|
139
|
-
this.position = PopoverPosition.AUTO;
|
|
140
|
-
}
|
|
141
|
-
this.currentPosition = this.position;
|
|
142
|
-
this.positionChange.emit({ position: this.currentPosition });
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Setup popover behaviors on opening.
|
|
146
|
-
*/
|
|
147
|
-
onOpen() {
|
|
148
|
-
cancelAnimationFrame(this.animationFrameRequestId);
|
|
149
|
-
if (this.open) {
|
|
150
|
-
const setPosition = () => {
|
|
151
|
-
if (this.open) {
|
|
152
|
-
this.setPosition();
|
|
153
|
-
this.animationFrameRequestId = requestAnimationFrame(setPosition);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
setPosition();
|
|
157
|
-
}
|
|
158
|
-
else if (this.host.hasAttribute("current-position")) {
|
|
159
|
-
this.host.removeAttribute("current-position");
|
|
160
|
-
this.currentPosition = undefined;
|
|
161
|
-
}
|
|
162
|
-
this.openChange.emit({ open: this.open });
|
|
163
|
-
}
|
|
164
|
-
disconnectedCallback() {
|
|
165
|
-
cancelAnimationFrame(this.animationFrameRequestId);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Set the position of the popover.
|
|
169
|
-
*/
|
|
170
|
-
setPosition() {
|
|
171
|
-
let element;
|
|
172
|
-
if (typeof this.bindTo === "string") {
|
|
173
|
-
element = this.host.ownerDocument.querySelector(this.bindTo);
|
|
174
|
-
}
|
|
175
|
-
else if (this.bindTo) {
|
|
176
|
-
element = this.bindTo;
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
element = this.host.parentElement;
|
|
180
|
-
}
|
|
181
|
-
if (!element) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
const scrollContainer = findScrollableParent(element);
|
|
185
|
-
const scrollingBoundingRect = scrollContainer.getBoundingClientRect();
|
|
186
|
-
const offsetContainer = this.host.offsetParent;
|
|
187
|
-
const relativeBoundingRect = offsetContainer
|
|
188
|
-
? computeOffset(offsetContainer, scrollContainer)
|
|
189
|
-
: { top: 0, right: 0, bottom: 0, left: 0 };
|
|
190
|
-
const boundingRect = computeOffset(element, scrollContainer);
|
|
191
|
-
const top = boundingRect.top - scrollContainer.scrollTop;
|
|
192
|
-
const bottom = scrollingBoundingRect.height - (boundingRect.top + boundingRect.height) + scrollContainer.scrollTop;
|
|
193
|
-
const left = boundingRect.left - scrollContainer.scrollLeft;
|
|
194
|
-
const right = scrollingBoundingRect.width - (boundingRect.left + boundingRect.width) + scrollContainer.scrollLeft;
|
|
195
|
-
const overflowBottom = Math.max(0, scrollingBoundingRect.top + scrollingBoundingRect.height - window.innerHeight);
|
|
196
|
-
const overflowRight = Math.max(0, scrollingBoundingRect.left + scrollingBoundingRect.width - window.innerWidth);
|
|
197
|
-
const availableTop = Math.min(top, top + scrollingBoundingRect.top);
|
|
198
|
-
const availableBottom = Math.min(bottom, bottom - overflowBottom);
|
|
199
|
-
const availableLeft = Math.min(left, left + scrollingBoundingRect.left);
|
|
200
|
-
const availableRight = Math.min(right, right - overflowRight);
|
|
201
|
-
const availableHeight = availableTop + availableBottom + boundingRect.height;
|
|
202
|
-
const availableWidth = availableLeft + availableRight + boundingRect.width;
|
|
203
|
-
let position = this.currentPosition;
|
|
204
|
-
const positions = [];
|
|
205
|
-
if (this.position === PopoverPosition.AUTO) {
|
|
206
|
-
/**
|
|
207
|
-
* The `AUTO` position tries to place the popover in the 'safest' area,
|
|
208
|
-
* where there's more space available.
|
|
209
|
-
*/
|
|
210
|
-
if (availableLeft / availableWidth > 0.6) {
|
|
211
|
-
positions.push(PopoverPosition.LEFT);
|
|
212
|
-
}
|
|
213
|
-
else if (availableLeft / availableWidth < 0.4) {
|
|
214
|
-
positions.push(PopoverPosition.RIGHT);
|
|
215
|
-
}
|
|
216
|
-
if (availableTop / availableHeight > 0.9) {
|
|
217
|
-
positions.unshift(PopoverPosition.TOP);
|
|
218
|
-
}
|
|
219
|
-
else if (availableTop / availableHeight > 0.6) {
|
|
220
|
-
positions.push(PopoverPosition.TOP);
|
|
221
|
-
}
|
|
222
|
-
else if (availableTop / availableHeight < 0.1) {
|
|
223
|
-
positions.unshift(PopoverPosition.BOTTOM);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
positions.push(PopoverPosition.BOTTOM);
|
|
227
|
-
}
|
|
228
|
-
position = positions.join("_");
|
|
229
|
-
}
|
|
230
|
-
const style = this.host.style;
|
|
231
|
-
style.position = "absolute";
|
|
232
|
-
const offsetTop = boundingRect.top - relativeBoundingRect.top;
|
|
233
|
-
const offsetRight = boundingRect.right - relativeBoundingRect.right;
|
|
234
|
-
const offsetBottom = boundingRect.bottom - relativeBoundingRect.bottom;
|
|
235
|
-
const offsetLeft = boundingRect.left - relativeBoundingRect.left;
|
|
236
|
-
const offsetModifier = this.center ? 0.5 : 0;
|
|
237
|
-
const sizeModifier = this.center ? 0.5 : 0;
|
|
238
|
-
if (position === PopoverPosition.TOP || position === PopoverPosition.TOP_RIGHT) {
|
|
239
|
-
style.top = "auto";
|
|
240
|
-
style.right = "auto";
|
|
241
|
-
style.bottom = `${offsetBottom + boundingRect.height}px`;
|
|
242
|
-
style.left = `${offsetLeft + boundingRect.width * offsetModifier}px`;
|
|
243
|
-
style.maxHeight = `${availableTop}px`;
|
|
244
|
-
if (position === PopoverPosition.TOP_RIGHT) {
|
|
245
|
-
style.maxWidth = `${availableRight + boundingRect.width * sizeModifier}px`;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
else if (position === PopoverPosition.TOP_LEFT) {
|
|
249
|
-
style.top = "auto";
|
|
250
|
-
style.right = `${offsetRight + boundingRect.width * offsetModifier}px`;
|
|
251
|
-
style.bottom = `${offsetBottom + boundingRect.height}px`;
|
|
252
|
-
style.left = "auto";
|
|
253
|
-
style.maxWidth = `${availableLeft}px`;
|
|
254
|
-
style.maxHeight = `${availableTop}px`;
|
|
255
|
-
}
|
|
256
|
-
else if (position === PopoverPosition.BOTTOM || position === PopoverPosition.BOTTOM_RIGHT) {
|
|
257
|
-
style.top = `${offsetTop + boundingRect.height}px`;
|
|
258
|
-
style.right = "auto";
|
|
259
|
-
style.bottom = "auto";
|
|
260
|
-
style.left = `${offsetLeft + boundingRect.width * offsetModifier}px`;
|
|
261
|
-
style.maxHeight = `${availableBottom}px`;
|
|
262
|
-
if (position === PopoverPosition.BOTTOM_RIGHT) {
|
|
263
|
-
style.maxWidth = `${availableRight + boundingRect.width * sizeModifier}px`;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
else if (position === PopoverPosition.BOTTOM_LEFT) {
|
|
267
|
-
style.top = `${offsetTop + boundingRect.height}px`;
|
|
268
|
-
style.right = `${offsetRight + boundingRect.width * offsetModifier}px`;
|
|
269
|
-
style.bottom = "auto";
|
|
270
|
-
style.left = "auto";
|
|
271
|
-
style.maxWidth = `${availableLeft}px`;
|
|
272
|
-
style.maxHeight = `${availableBottom}px`;
|
|
273
|
-
}
|
|
274
|
-
else if (position === PopoverPosition.RIGHT || position === PopoverPosition.RIGHT_BOTTOM) {
|
|
275
|
-
style.top = `${offsetTop + boundingRect.height * offsetModifier}px`;
|
|
276
|
-
style.right = "auto";
|
|
277
|
-
style.bottom = "auto";
|
|
278
|
-
style.left = `${offsetLeft + boundingRect.width}px`;
|
|
279
|
-
style.maxWidth = `${availableRight}px`;
|
|
280
|
-
style.maxHeight = `${availableBottom + boundingRect.height * sizeModifier}px`;
|
|
281
|
-
}
|
|
282
|
-
else if (position === PopoverPosition.RIGHT_TOP) {
|
|
283
|
-
style.top = "auto";
|
|
284
|
-
style.right = "auto";
|
|
285
|
-
style.bottom = `${offsetBottom + boundingRect.height * offsetModifier}px`;
|
|
286
|
-
style.left = `${offsetLeft + boundingRect.width}px`;
|
|
287
|
-
style.maxWidth = `${availableRight}px`;
|
|
288
|
-
style.maxHeight = `${availableTop + boundingRect.height * sizeModifier}px`;
|
|
289
|
-
}
|
|
290
|
-
else if (position === PopoverPosition.LEFT || position === PopoverPosition.LEFT_BOTTOM) {
|
|
291
|
-
style.top = `${offsetTop + boundingRect.height * offsetModifier}px`;
|
|
292
|
-
style.right = `${offsetRight + boundingRect.width}px`;
|
|
293
|
-
style.bottom = "auto";
|
|
294
|
-
style.left = "auto";
|
|
295
|
-
style.maxWidth = `${availableLeft}px`;
|
|
296
|
-
style.maxHeight = `${availableBottom + boundingRect.height * sizeModifier}px`;
|
|
297
|
-
}
|
|
298
|
-
else if (position === PopoverPosition.LEFT_TOP) {
|
|
299
|
-
style.top = "auto";
|
|
300
|
-
style.right = `${offsetRight + boundingRect.width}px`;
|
|
301
|
-
style.bottom = `${offsetBottom + boundingRect.height * offsetModifier}px`;
|
|
302
|
-
style.left = "auto";
|
|
303
|
-
style.maxWidth = `${availableLeft}px`;
|
|
304
|
-
style.maxHeight = `${availableTop + boundingRect.height * sizeModifier}px`;
|
|
305
|
-
}
|
|
306
|
-
this.currentPosition = position || this.position;
|
|
307
|
-
this.host.setAttribute("current-position", this.currentPosition);
|
|
308
|
-
}
|
|
309
|
-
componentWillLoad() {
|
|
310
|
-
this.validatePosition(this.position);
|
|
311
|
-
this.onOpen();
|
|
312
|
-
}
|
|
313
|
-
render() {
|
|
314
|
-
return h("slot", null);
|
|
315
|
-
}
|
|
316
|
-
get host() { return getElement(this); }
|
|
317
|
-
static get watchers() { return {
|
|
318
|
-
"position": ["validatePosition"],
|
|
319
|
-
"open": ["onOpen"]
|
|
320
|
-
}; }
|
|
321
|
-
};
|
|
322
|
-
ZPopover.style = stylesCss;
|
|
323
|
-
|
|
324
|
-
export { ZPopover as z_popover };
|