@zanichelli/albe-web-components 9.2.4-beta2 → 9.3.0-rc1
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/dist/cjs/index-e3299e0a.js +4 -12
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/web-components-library.cjs.js +1 -1
- package/dist/cjs/z-app-header_14.cjs.entry.js +2828 -0
- package/dist/cjs/z-dragdrop-area.cjs.entry.js +37 -0
- package/dist/collection/components/modal/z-modal/index.js +18 -17
- package/dist/collection/components/modal/z-modal/styles.css +61 -24
- package/dist/esm/{index-d3dfe710.js → index-5b83b0b1.js} +1 -1
- package/dist/esm/{index-1b2e3e53.js → index-8528dee0.js} +1 -1
- package/dist/esm/index-a2ca4b97.js +4 -12
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{utils-4d2d99d9.js → utils-6c83dfcb.js} +1 -1
- package/dist/esm/web-components-library.js +1 -1
- package/dist/esm/z-app-header_14.entry.js +2811 -0
- package/dist/esm/z-book-card.entry.js +1 -1
- package/dist/esm/z-breadcrumb.entry.js +1 -1
- package/dist/esm/z-chip.entry.js +1 -1
- package/dist/esm/z-combobox.entry.js +1 -1
- package/dist/esm/z-dragdrop-area.entry.js +33 -0
- package/dist/esm/z-file-upload.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-pocket_3.entry.js +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-deprecated.entry.js +2 -2
- package/dist/esm/z-table-header.entry.js +2 -2
- 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/modal/z-modal/index.d.ts +2 -2
- package/dist/types/components.d.ts +4 -4
- package/dist/web-components-library/index.esm.js +1 -1
- package/dist/web-components-library/p-052c06ac.entry.js +1 -0
- package/dist/web-components-library/{p-37e8194f.entry.js → p-13ac8bd3.entry.js} +1 -1
- package/dist/web-components-library/{p-65dd23d7.js → p-327b7b79.js} +1 -1
- package/dist/web-components-library/{p-f2eaa685.entry.js → p-3ee4aa12.entry.js} +1 -1
- package/dist/web-components-library/{p-a6a09ce6.entry.js → p-432a2f5b.entry.js} +1 -1
- package/dist/web-components-library/{p-f3408275.entry.js → p-438f017e.entry.js} +1 -1
- package/dist/web-components-library/p-466c3c0b.entry.js +1 -0
- package/dist/web-components-library/p-76c2c26d.entry.js +1 -0
- package/dist/web-components-library/{p-1cbd8a5f.entry.js → p-7eb6d043.entry.js} +1 -1
- package/{www/build/p-c1f20cec.entry.js → dist/web-components-library/p-7f43e400.entry.js} +1 -1
- package/dist/web-components-library/{p-dd3e0b4e.js → p-91447194.js} +1 -1
- package/dist/web-components-library/{p-8b2bf3b4.entry.js → p-aa8b0c95.entry.js} +1 -1
- package/dist/web-components-library/p-b2420056.entry.js +1 -0
- package/dist/web-components-library/{p-69bde29c.entry.js → p-b3093245.entry.js} +1 -1
- package/dist/web-components-library/{p-fc8f0f1a.entry.js → p-c1de287b.entry.js} +1 -1
- package/dist/web-components-library/{p-cb07de86.entry.js → p-c8bd65d9.entry.js} +1 -1
- package/dist/web-components-library/{p-2d0ac109.entry.js → p-c99acff4.entry.js} +1 -1
- package/dist/web-components-library/{p-2f013f10.entry.js → p-dca0db1b.entry.js} +1 -1
- package/dist/web-components-library/{p-d7668580.js → p-eb9fa72b.js} +1 -1
- package/dist/web-components-library/p-f01f4e9b.entry.js +16 -0
- package/dist/web-components-library/web-components-library.esm.js +1 -1
- package/package.json +1 -1
- package/www/build/index.esm.js +1 -1
- package/www/build/p-052c06ac.entry.js +1 -0
- package/www/build/{p-37e8194f.entry.js → p-13ac8bd3.entry.js} +1 -1
- package/www/build/{p-65dd23d7.js → p-327b7b79.js} +1 -1
- package/www/build/p-39b528a6.js +129 -0
- package/www/build/{p-f2eaa685.entry.js → p-3ee4aa12.entry.js} +1 -1
- package/www/build/{p-a6a09ce6.entry.js → p-432a2f5b.entry.js} +1 -1
- package/www/build/{p-f3408275.entry.js → p-438f017e.entry.js} +1 -1
- package/www/build/p-466c3c0b.entry.js +1 -0
- package/www/build/p-5a0a4f69.css +1653 -0
- package/www/build/p-76c2c26d.entry.js +1 -0
- package/www/build/{p-1cbd8a5f.entry.js → p-7eb6d043.entry.js} +1 -1
- package/{dist/web-components-library/p-c1f20cec.entry.js → www/build/p-7f43e400.entry.js} +1 -1
- package/www/build/{p-dd3e0b4e.js → p-91447194.js} +1 -1
- package/www/build/{p-8b2bf3b4.entry.js → p-aa8b0c95.entry.js} +1 -1
- package/www/build/p-b2420056.entry.js +1 -0
- package/www/build/{p-69bde29c.entry.js → p-b3093245.entry.js} +1 -1
- package/www/build/{p-fc8f0f1a.entry.js → p-c1de287b.entry.js} +1 -1
- package/www/build/{p-cb07de86.entry.js → p-c8bd65d9.entry.js} +1 -1
- package/www/build/{p-2d0ac109.entry.js → p-c99acff4.entry.js} +1 -1
- package/www/build/{p-2f013f10.entry.js → p-dca0db1b.entry.js} +1 -1
- package/www/build/{p-d7668580.js → p-eb9fa72b.js} +1 -1
- package/www/build/p-f01f4e9b.entry.js +16 -0
- package/www/build/web-components-library.esm.js +1 -1
- package/www/index.html +59 -1
- package/dist/cjs/z-app-header_11.cjs.entry.js +0 -1056
- package/dist/cjs/z-date-picker.cjs.entry.js +0 -477
- package/dist/cjs/z-dragdrop-area_2.cjs.entry.js +0 -1015
- package/dist/cjs/z-select.cjs.entry.js +0 -333
- package/dist/esm/z-app-header_11.entry.js +0 -1042
- package/dist/esm/z-date-picker.entry.js +0 -473
- package/dist/esm/z-dragdrop-area_2.entry.js +0 -1010
- package/dist/esm/z-select.entry.js +0 -329
- package/dist/web-components-library/p-06d2f371.entry.js +0 -1
- package/dist/web-components-library/p-09be4e46.entry.js +0 -1
- package/dist/web-components-library/p-2d600a28.entry.js +0 -1
- package/dist/web-components-library/p-386bdb7f.entry.js +0 -1
- package/dist/web-components-library/p-3e61bad0.entry.js +0 -1
- package/dist/web-components-library/p-9829f5bd.entry.js +0 -16
- package/dist/web-components-library/p-ad47fe7d.entry.js +0 -1
- package/www/build/p-06d2f371.entry.js +0 -1
- package/www/build/p-09be4e46.entry.js +0 -1
- package/www/build/p-2d600a28.entry.js +0 -1
- package/www/build/p-386bdb7f.entry.js +0 -1
- package/www/build/p-39ac174d.css +0 -2
- package/www/build/p-3e61bad0.entry.js +0 -1
- package/www/build/p-4392fcb5.js +0 -1
- package/www/build/p-9829f5bd.entry.js +0 -16
- package/www/build/p-ad47fe7d.entry.js +0 -1
|
@@ -0,0 +1,2828 @@
|
|
|
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-e8ce94a1.js');
|
|
7
|
+
const utils = require('./utils-4caf6fab.js');
|
|
8
|
+
const _commonjsHelpers = require('./_commonjsHelpers-537d719a.js');
|
|
9
|
+
const icons = require('./icons-7da210ed.js');
|
|
10
|
+
const utils$1 = require('./utils-4ac02425.js');
|
|
11
|
+
require('./breakpoints-ebe1a437.js');
|
|
12
|
+
|
|
13
|
+
const stylesCss$d = ":host{--app-header-typography-1-size:24px;--app-header-typography-2-size:28px;--app-header-typography-3-size:32px;--app-header-typography-4-size:36px;--app-header-typography-5-size:42px;--app-header-typography-6-size:48px;--app-header-typography-7-size:54px;--app-header-typography-8-size:60px;--app-header-typography-9-size:68px;--app-header-typography-10-size:76px;--app-header-typography-11-size:84px;--app-header-typography-12-size:92px;--app-header-typography-1-lineheight:1.33;--app-header-typography-2-lineheight:1.29;--app-header-typography-3-lineheight:1.25;--app-header-typography-4-lineheight:1.24;--app-header-typography-5-lineheight:1.24;--app-header-typography-6-lineheight:1.25;--app-header-typography-7-lineheight:1.2;--app-header-typography-8-lineheight:1.26;--app-header-typography-9-lineheight:1.24;--app-header-typography-10-lineheight:1.26;--app-header-typography-11-lineheight:1.2;--app-header-typography-12-lineheight:1.2;--app-header-typography-1-tracking:calc(-0.2 / 1em);--app-header-typography-2-tracking:calc(-0.4 / 1em);--app-header-typography-3-tracking:calc(-0.6 / 1em);--app-header-typography-4-tracking:calc(-0.8 / 1em);--app-header-typography-5-tracking:calc(-1 / 1em);--app-header-typography-6-tracking:calc(-1.2 / 1em);--app-header-typography-7-tracking:calc(-1.4 / 1em);--app-header-typography-8-tracking:calc(-1.6 / 1em);--app-header-typography-9-tracking:calc(-1.8 / 1em);--app-header-typography-10-tracking:calc(-2 / 1em);--app-header-typography-11-tracking:calc(-2.2 / 1em);--app-header-typography-12-tracking:calc(-2.4 / 1em);--app-header-content-max-width:100%;--app-header-height:auto;--app-header-top-offset:48px;--app-header-drawer-trigger-size:calc(var(--space-unit) * 4);--app-header-bg:var(--color-surface01);--app-header-stucked-bg:var(--color-surface01);--app-header-text-color:var(--color-text01);--app-header-title-font-size:var(--app-header-typography-3-size);--app-header-title-lineheight:var(--app-header-typography-3-lineheight);--app-header-title-letter-spacing:var(--app-header-typography-3-tracking);--app-header-stucked-text-color:var(--color-text01);position:relative;display:block;height:var(--app-header-height);color:var(--app-header-text-color)}:host,*{box-sizing:border-box}.heading-panel{position:relative;display:flex;width:100%;max-width:var(--app-header-content-max-width);flex-direction:column;flex-grow:0;flex-shrink:0;align-items:baseline;padding:var(--grid-margin);margin:0 auto;background:var(--app-header-bg);gap:calc(var(--space-unit) * 2) calc(var(--space-unit) * 5)}.hero-container+.heading-panel{background:transparent}:host(:empty) .heading-panel{padding:0}.heading-container{position:relative;z-index:1;display:flex;width:100%;max-width:100%;flex:1 auto;flex-direction:column;justify-content:flex-start}.heading-title{display:flex;max-width:100%;flex-direction:row;align-items:flex-start;column-gap:calc(var(--space-unit) * 2)}::slotted([slot=\"title\"]),.heading-stuck .heading-title>*,::slotted([slot=\"stucked-title\"]){margin:0;font-family:\"IBM Plex Serif\", serif;font-weight:var(--font-bd)}::slotted([slot=\"title\"]){font-size:var(--app-header-title-font-size);letter-spacing:var(--app-header-title-letter-spacing);line-height:var(--app-header-title-lineheight)}.heading-stuck .heading-title>*,::slotted([slot=\"stucked-title\"]){font-size:var(--app-header-typography-3-size);letter-spacing:var(--app-header-typography-3-tracking);line-height:var(--app-header-typography-3-lineheight)}:host(:not([menu-length=\"0\"])) .heading-subtitle{padding-left:calc(var(--app-header-drawer-trigger-size) + (var(--space-unit) * 2))}::slotted([slot=\"subtitle\"]){margin:0;font-family:var(--font-family-sans);font-size:20px;font-style:italic;font-weight:500;line-height:26px}.menu-container{display:flex;width:100%;flex:1 auto;flex-flow:row wrap}:host([menu-length=\"0\"]:not([enable-search])) .menu-container,.menu-container:empty{display:none}.menu-container ::slotted([open]){position:relative;z-index:3}z-searchbar{z-index:0;display:flex;width:auto;min-width:calc(var(--space-unit) * 32);flex:1 auto;align-items:center;margin-left:auto}.heading-stuck{position:fixed;z-index:20;top:var(--app-header-top-offset);left:0;width:100%;max-width:100%;animation:slide-stuck-heading-in 250ms ease-out;background:var(--app-header-stucked-bg);box-shadow:var(--shadow-2);color:var(--app-header-stucked-text-color)}.heading-stuck-content{display:flex;max-width:var(--app-header-content-max-width);align-items:center;padding:var(--space-unit) var(--grid-margin);margin:0 auto;column-gap:calc(var(--space-unit) * 2)}.heading-stuck .heading-title>*,.heading-stuck .heading-title ::slotted([slot=\"stucked-title\"]){display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.heading-stuck-content z-button{margin-left:auto}.drawer-trigger{padding:0;border:0;margin:0;appearance:none;background:none;border-radius:0;color:inherit;cursor:pointer}.drawer-trigger z-icon{--z-icon-width:var(--app-header-drawer-trigger-size);--z-icon-height:var(--app-header-drawer-trigger-size);fill:currentcolor}.heading-container :is(.drawer-trigger,z-button.search-page-button){display:flex;height:calc(var(--app-header-title-font-size) * var(--app-header-title-lineheight));align-items:center}.heading-container z-button.search-page-button{margin-left:auto}.drawer-content{display:none}z-offcanvas[open] .drawer-content{display:flex;width:100%;flex:1 auto;flex-direction:column;row-gap:calc(var(--space-unit) * 2.5)}z-offcanvas[open] .drawer-content ::slotted(z-menu){width:100%}.drawer-close{--z-icon-width:var(--app-header-drawer-trigger-size);--z-icon-height:var(--app-header-drawer-trigger-size);padding:0;border:0;margin:var(--space-unit) 0 calc(var(--space-unit) * 2.5);appearance:none;background:transparent;border-radius:0;color:inherit;cursor:pointer;fill:currentcolor;font-size:inherit;outline:none}.drawer-close:focus-visible{box-shadow:var(--shadow-focus-primary)}.hero-container{position:absolute;z-index:0;top:0;left:0;width:100%;height:100%}:host([overlay]) .heading-panel .drawer-trigger z-icon,:host([overlay]) .heading-panel .heading-container,:host([overlay]) .heading-panel .menu-container{color:var(--color-white);fill:var(--color-white)}:host([overlay]) .heading-panel .menu-container ::slotted(z-menu){--z-menu-label-color:var(--color-white)}:host([overlay]) .hero-container::after{position:absolute;z-index:0;top:0;left:0;width:100%;height:100%;background:var(--color-black);content:\"\";opacity:0.5}.hero-container img,.hero-container ::slotted(*){position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover;object-position:top center;-webkit-user-drag:none}@media (min-width: 768px){:host{--app-header-title-font-size:var(--app-header-typography-6-size);--app-header-title-lineheight:var(--app-header-typography-6-lineheight);--app-header-title-letter-spacing:var(--app-header-typography-6-tracking)}.heading-panel{flex-flow:row wrap;align-items:center;padding-bottom:calc(var(--space-unit) * 2)}.heading-container{margin-right:auto}:host(:is([flow=\"offcanvas\"],[menu-length=\"0\"])) :is(.heading-container,.menu-container){width:auto}:host(:not([flow=\"offcanvas\"])) .heading-subtitle{padding-left:0}.menu-container{flex:initial;align-items:center}:host([menu-length=\"0\"]) .menu-container:not(:empty){height:calc(var(--app-header-title-font-size) * var(--app-header-title-lineheight))}:host(:not([flow=\"offcanvas\"])) .menu-container{gap:var(--space-unit) calc(var(--space-unit) * 5)}:host(:not([flow=\"offcanvas\"])) .heading-container .drawer-trigger{display:none}}@media (min-width: 1152px){:host{--app-header-title-font-size:var(--app-header-typography-7-size);--app-header-title-lineheight:var(--app-header-typography-7-lineheight);--app-header-title-letter-spacing:var(--app-header-typography-7-tracking)}.heading-panel{justify-content:flex-start;padding-bottom:calc(var(--space-unit) * 3)}.heading-container,.menu-container{width:auto}:host([flow=\"stack\"]) .heading-panel{flex-flow:column;align-items:flex-start}:host([flow=\"stack\"]) .menu-container{width:100%}:host(:not([flow=\"offcanvas\"],[menu-length=\"0\"])) .heading-panel{row-gap:calc(var(--space-unit) * 3)}z-searchbar{min-width:calc(var(--space-unit) * 45);flex:initial}}@media (min-width: 1366px){:host{--app-header-title-font-size:var(--app-header-typography-9-size);--app-header-title-lineheight:var(--app-header-typography-9-lineheight);--app-header-title-letter-spacing:var(--app-header-typography-9-tracking)}}@keyframes slide-stuck-heading-in{0%{transform:translate3d(0, -100%, 0)}100%{transform:none}}";
|
|
14
|
+
|
|
15
|
+
const SUPPORT_INTERSECTION_OBSERVER = typeof IntersectionObserver !== "undefined";
|
|
16
|
+
const ZAppHeader = class {
|
|
17
|
+
constructor(hostRef) {
|
|
18
|
+
index.registerInstance(this, hostRef);
|
|
19
|
+
this.sticking = index.createEvent(this, "sticking", 7);
|
|
20
|
+
/**
|
|
21
|
+
* Stuck mode for the header.
|
|
22
|
+
* You can programmatically set it using an IntersectionObserver.
|
|
23
|
+
*/
|
|
24
|
+
this.stuck = false;
|
|
25
|
+
/**
|
|
26
|
+
* Should place an overlay over the hero image.
|
|
27
|
+
* Useful for legibility purpose.
|
|
28
|
+
*/
|
|
29
|
+
this.overlay = false;
|
|
30
|
+
/**
|
|
31
|
+
* Control menu bar position in the header.
|
|
32
|
+
* - auto: the menu bar is positioned near the title
|
|
33
|
+
* - stack: the menu bar is positioned below the title
|
|
34
|
+
* - offcanvas: the menu bar is not displayed and a burger icon appears to open the offcanvas menu
|
|
35
|
+
*/
|
|
36
|
+
this.flow = "auto";
|
|
37
|
+
/**
|
|
38
|
+
* The opening state of the drawer.
|
|
39
|
+
*/
|
|
40
|
+
this.drawerOpen = false;
|
|
41
|
+
/**
|
|
42
|
+
* Enable the search bar.
|
|
43
|
+
*/
|
|
44
|
+
this.enableSearch = false;
|
|
45
|
+
/**
|
|
46
|
+
* Placeholder text for the search bar.
|
|
47
|
+
*/
|
|
48
|
+
this.searchPlaceholder = "Cerca";
|
|
49
|
+
/**
|
|
50
|
+
* Search string for the search bar.
|
|
51
|
+
*/
|
|
52
|
+
this.searchString = "";
|
|
53
|
+
/**
|
|
54
|
+
* The stuck state of the bar.
|
|
55
|
+
*/
|
|
56
|
+
this._stuck = false;
|
|
57
|
+
/**
|
|
58
|
+
* Current viewport.
|
|
59
|
+
* Used to change the aspect of the search button (icon only) on mobile and tablet.
|
|
60
|
+
*/
|
|
61
|
+
this.currentViewport = "mobile";
|
|
62
|
+
this.observer = SUPPORT_INTERSECTION_OBSERVER &&
|
|
63
|
+
new IntersectionObserver(([entry]) => {
|
|
64
|
+
this._stuck = !entry.isIntersecting;
|
|
65
|
+
}, {
|
|
66
|
+
threshold: 0.5,
|
|
67
|
+
});
|
|
68
|
+
this.openDrawer = this.openDrawer.bind(this);
|
|
69
|
+
this.closeDrawer = this.closeDrawer.bind(this);
|
|
70
|
+
this.collectMenuElements = this.collectMenuElements.bind(this);
|
|
71
|
+
}
|
|
72
|
+
evaluateViewport() {
|
|
73
|
+
if (window.innerWidth < 768) {
|
|
74
|
+
this.currentViewport = "mobile";
|
|
75
|
+
}
|
|
76
|
+
else if (window.innerWidth >= 768 && window.innerWidth < 1152) {
|
|
77
|
+
this.currentViewport = "tablet";
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.currentViewport = "desktop";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
onStuck() {
|
|
84
|
+
const scrollParent = this.scrollParent;
|
|
85
|
+
if (!scrollParent) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.sticking.emit(this._stuck);
|
|
89
|
+
}
|
|
90
|
+
setMenuFloatingMode() {
|
|
91
|
+
if (this.menuElements.length === 0) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const elements = this.menuElements;
|
|
95
|
+
elements.forEach((element) => {
|
|
96
|
+
element.open = false;
|
|
97
|
+
element.floating = !this.drawerOpen;
|
|
98
|
+
element.verticalContext = this.drawerOpen;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
get title() {
|
|
102
|
+
const titleElement = this.hostElement.querySelector('[slot="title"]');
|
|
103
|
+
if (titleElement === null) {
|
|
104
|
+
return "";
|
|
105
|
+
}
|
|
106
|
+
return titleElement.textContent.trim();
|
|
107
|
+
}
|
|
108
|
+
get scrollParent() {
|
|
109
|
+
const parent = this.hostElement.offsetParent;
|
|
110
|
+
if (parent === document.body || parent === document.documentElement) {
|
|
111
|
+
return window;
|
|
112
|
+
}
|
|
113
|
+
return parent;
|
|
114
|
+
}
|
|
115
|
+
get canShowMenu() {
|
|
116
|
+
return this.flow !== "offcanvas" && this.currentViewport !== "mobile" && !this.drawerOpen;
|
|
117
|
+
}
|
|
118
|
+
get canShowSearchbar() {
|
|
119
|
+
if (!this.enableSearch) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
// Always show the searchbar on desktop, even if a searchPageUrl is set
|
|
123
|
+
if (this.searchPageUrl) {
|
|
124
|
+
return this.currentViewport === "desktop";
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Whether the header has a hero image, either as a prop or as a slot.
|
|
130
|
+
*/
|
|
131
|
+
get hasHero() {
|
|
132
|
+
return !!this.hero || this.hostElement.querySelector("[slot=hero]") !== null;
|
|
133
|
+
}
|
|
134
|
+
openDrawer() {
|
|
135
|
+
this.drawerOpen = true;
|
|
136
|
+
}
|
|
137
|
+
closeDrawer() {
|
|
138
|
+
this.drawerOpen = false;
|
|
139
|
+
}
|
|
140
|
+
collectMenuElements() {
|
|
141
|
+
const menuElements = (this.menuElements = this.hostElement.querySelectorAll('[slot="menu"]'));
|
|
142
|
+
this.menuLength = menuElements.length;
|
|
143
|
+
this.setMenuFloatingMode();
|
|
144
|
+
}
|
|
145
|
+
enableStuckObserver() {
|
|
146
|
+
if (this.observer) {
|
|
147
|
+
this.observer.observe(this.container);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
disableStuckMode() {
|
|
151
|
+
this._stuck = false;
|
|
152
|
+
if (this.observer) {
|
|
153
|
+
this.observer.unobserve(this.container);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
onStuckMode() {
|
|
157
|
+
if (this.stuck) {
|
|
158
|
+
this.enableStuckObserver();
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.disableStuckMode();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
renderSearchLinkButton() {
|
|
165
|
+
if (!this.enableSearch || !this.searchPageUrl || this.currentViewport === "desktop") {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
return (index.h("z-button", { class: "search-page-button", variant: index$1.ButtonVariant.SECONDARY, href: this.searchPageUrl, icon: "search", size: index$1.ControlSize.X_SMALL }));
|
|
169
|
+
}
|
|
170
|
+
renderSeachbar(searchButtonIconOnly) {
|
|
171
|
+
return (index.h("z-searchbar", { value: this.searchString, placeholder: this.searchPlaceholder, showSearchButton: true, searchButtonIconOnly: searchButtonIconOnly, size: index$1.ControlSize.X_SMALL, variant: index$1.ButtonVariant.SECONDARY, preventSubmit: this.searchString.length < 3, onSearchTyping: (e) => (this.searchString = e.detail) }));
|
|
172
|
+
}
|
|
173
|
+
componentDidLoad() {
|
|
174
|
+
this.collectMenuElements();
|
|
175
|
+
this.onStuckMode();
|
|
176
|
+
this.evaluateViewport();
|
|
177
|
+
}
|
|
178
|
+
render() {
|
|
179
|
+
return (index.h(index.Host, { "menu-length": this.menuLength }, this.hasHero && (index.h("div", { class: "hero-container" }, index.h("slot", { name: "hero" }, this.hero && (index.h("img", { alt: "", src: this.hero }))))), index.h("div", { class: "heading-panel", ref: (el) => (this.container = el) }, index.h("div", { class: "heading-container" }, index.h("div", { class: "heading-title" }, this.menuLength > 0 && (index.h("button", { class: "drawer-trigger", "aria-label": "Apri menu", onClick: this.openDrawer }, index.h("z-icon", { name: "burger-menu" }))), index.h("slot", { name: "title" }), this.renderSearchLinkButton()), index.h("div", { class: "heading-subtitle" }, index.h("slot", { name: "subtitle" }))), (this.canShowMenu || this.canShowSearchbar) && (index.h("div", { class: "menu-container" }, this.canShowMenu && (index.h("slot", { name: "menu", onSlotchange: this.collectMenuElements })), this.canShowSearchbar && this.renderSeachbar(this.currentViewport !== "desktop")))), index.h("z-offcanvas", { variant: index$1.OffCanvasVariant.OVERLAY, transitiondirection: index$1.TransitionDirection.RIGHT, open: this.drawerOpen, onCanvasOpenStatusChanged: (ev) => (this.drawerOpen = ev.detail) }, index.h("button", { class: "drawer-close", "aria-label": "Chiudi menu", onClick: this.closeDrawer, slot: "canvasContent" }, index.h("z-icon", { name: "close" })), index.h("div", { class: "drawer-content", slot: "canvasContent", "aria-hidden": !this.drawerOpen }, index.h("slot", { name: "menu", onSlotchange: this.collectMenuElements }))), this._stuck && (index.h("div", { class: "heading-stuck" }, index.h("div", { class: "heading-stuck-content" }, this.menuLength > 0 && (index.h("button", { class: "drawer-trigger", "aria-label": "Apri menu", onClick: this.openDrawer }, index.h("z-icon", { name: "burger-menu" }))), index.h("div", { class: "heading-title" }, index.h("slot", { name: "stucked-title" }, this.title)), this.renderSearchLinkButton(), this.canShowSearchbar && this.currentViewport === "desktop" && this.renderSeachbar(false))))));
|
|
180
|
+
}
|
|
181
|
+
get hostElement() { return index.getElement(this); }
|
|
182
|
+
static get watchers() { return {
|
|
183
|
+
"_stuck": ["onStuck"],
|
|
184
|
+
"drawerOpen": ["setMenuFloatingMode"],
|
|
185
|
+
"stuck": ["onStuckMode"]
|
|
186
|
+
}; }
|
|
187
|
+
};
|
|
188
|
+
ZAppHeader.style = stylesCss$d;
|
|
189
|
+
|
|
190
|
+
const stylesCss$c = ".sc-z-button-h{display:inline-block;--z-icon-width:16px;--z-icon-height:16px;--z-icon-right-margin:0}[disabled].sc-z-button-h:not([disabled=\"false\"]){pointer-events:none}.sc-z-button-h .z-button--container.sc-z-button{display:inline-flex;width:100%;box-sizing:border-box;align-items:center;justify-content:center;padding:0;border-width:var(--border-size-medium);border-style:solid;border-radius:var(--border-radius);cursor:pointer;fill:currentcolor;font-family:var(--font-family-sans);font-size:14px;font-weight:var(--font-sb);letter-spacing:0.3px;line-height:1;outline:none;text-decoration:none;text-transform:uppercase;white-space:nowrap}.sc-z-button-h .z-button--container.sc-z-button:focus:focus-visible{box-shadow:var(--shadow-focus-primary)}.sc-z-button-h .z-button--container.z-button--has-text.sc-z-button{min-width:calc(var(--space-unit) * 8);padding:0 calc(var(--space-unit) * 2)}.sc-z-button-h .z-button--container.z-button--has-text.sc-z-button z-icon.sc-z-button{--z-icon-right-margin:var(--space-unit)}[size=\"big\"].sc-z-button-h .z-button--container.sc-z-button{min-width:44px;height:44px}[size=\"small\"].sc-z-button-h .z-button--container.sc-z-button{min-width:36px;height:36px}[size=\"x-small\"].sc-z-button-h .z-button--container.sc-z-button{min-width:32px;height:32px}[variant=\"primary\"].sc-z-button-h .z-button--container.sc-z-button{border-color:var(--color-primary01);background-color:var(--color-primary01);color:var(--color-text-inverse)}@media (hover: hover){[variant=\"primary\"].sc-z-button-h .z-button--container.sc-z-button:hover{border-color:var(--color-hover-primary);background-color:var(--color-hover-primary);color:var(--color-text-inverse)}}[variant=\"primary\"].sc-z-button-h .z-button--container.sc-z-button:active{border-color:var(--color-pressed-primary);background-color:var(--color-pressed-primary);box-shadow:var(--shadow-2);color:var(--color-text-inverse)}[variant=\"primary\"][disabled].sc-z-button-h:not([disabled=\"false\"]) .z-button--container.sc-z-button{border-color:var(--color-disabled01);background-color:var(--color-disabled01);color:var(--color-disabled02)}[variant=\"secondary\"].sc-z-button-h .z-button--container.sc-z-button{border-color:var(--color-primary01);background-color:var(--color-surface01);color:var(--color-primary01)}@media (hover: hover){[variant=\"secondary\"].sc-z-button-h .z-button--container.sc-z-button:hover{border-color:var(--color-hover-primary);background-color:var(--color-surface01);color:var(--color-hover-primary)}}[variant=\"secondary\"].sc-z-button-h .z-button--container.sc-z-button:active{border-color:var(--color-pressed-primary);background-color:var(--color-surface01);box-shadow:var(--shadow-2);color:var(--color-pressed-primary)}[variant=\"secondary\"][disabled].sc-z-button-h:not([disabled=\"false\"]) .z-button--container.sc-z-button{border-color:var(--color-disabled01);background-color:var(--color-surface01);color:var(--color-disabled02)}[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button{border-color:transparent;background-color:transparent;color:var(--color-primary01)}@media (hover: hover){[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button:hover{border-color:var(--color-primary03);background-color:var(--color-primary03);color:var(--color-hover-primary)}}[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button:focus:focus-visible{border-color:var(--color-surface01);background-color:var(--color-surface01);color:var(--color-primary01)}[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button:active{border-color:var(--color-surface01);background-color:var(--color-surface01);box-shadow:var(--shadow-2);color:var(--color-primary01)}[variant=\"tertiary\"][disabled].sc-z-button-h:not([disabled=\"false\"]) .z-button--container.sc-z-button{border-color:transparent;background-color:transparent;color:var(--color-disabled02)}";
|
|
191
|
+
|
|
192
|
+
const ZButton = class {
|
|
193
|
+
constructor(hostRef) {
|
|
194
|
+
index.registerInstance(this, hostRef);
|
|
195
|
+
/** defines a string value that labels an interactive element, used for accessibility. */
|
|
196
|
+
this.ariaLabel = "";
|
|
197
|
+
/** HTML button disabled attribute. */
|
|
198
|
+
this.disabled = false;
|
|
199
|
+
/** HTML button type attribute. */
|
|
200
|
+
this.type = index$1.ButtonType.BUTTON;
|
|
201
|
+
/** Graphical variant: `primary`, `secondary`, `tertiary`. Defaults to `primary`. */
|
|
202
|
+
this.variant = index$1.ButtonVariant.PRIMARY;
|
|
203
|
+
/** Available sizes: `big`, `small` and `x-small`. Defaults to `big`. */
|
|
204
|
+
this.size = index$1.ControlSize.BIG;
|
|
205
|
+
}
|
|
206
|
+
getAttributes() {
|
|
207
|
+
return {
|
|
208
|
+
id: this.htmlid,
|
|
209
|
+
class: {
|
|
210
|
+
"z-button--container": true,
|
|
211
|
+
"z-button--has-text": !!this.hostElement.textContent.trim(),
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
render() {
|
|
216
|
+
if (this.href) {
|
|
217
|
+
return (index.h("a", Object.assign({}, this.getAttributes(), { "aria-label": this.ariaLabel, href: this.href, target: this.target }), this.icon && (index.h("z-icon", { name: this.icon, width: 16, height: 16 })), index.h("slot", null)));
|
|
218
|
+
}
|
|
219
|
+
return (index.h("button", Object.assign({}, this.getAttributes(), { "aria-label": this.ariaLabel, name: this.name, type: this.type, disabled: this.disabled }), this.icon && (index.h("z-icon", { name: this.icon, width: 16, height: 16 })), index.h("slot", null)));
|
|
220
|
+
}
|
|
221
|
+
get hostElement() { return index.getElement(this); }
|
|
222
|
+
};
|
|
223
|
+
ZButton.style = stylesCss$c;
|
|
224
|
+
|
|
225
|
+
var monthSelect = _commonjsHelpers.createCommonjsModule(function (module, exports) {
|
|
226
|
+
(function (global, factory) {
|
|
227
|
+
module.exports = factory() ;
|
|
228
|
+
}(_commonjsHelpers.commonjsGlobal, (function () {
|
|
229
|
+
/*! *****************************************************************************
|
|
230
|
+
Copyright (c) Microsoft Corporation.
|
|
231
|
+
|
|
232
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
233
|
+
purpose with or without fee is hereby granted.
|
|
234
|
+
|
|
235
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
236
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
237
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
238
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
239
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
240
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
241
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
242
|
+
***************************************************************************** */
|
|
243
|
+
|
|
244
|
+
var __assign = function() {
|
|
245
|
+
__assign = Object.assign || function __assign(t) {
|
|
246
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
247
|
+
s = arguments[i];
|
|
248
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
249
|
+
}
|
|
250
|
+
return t;
|
|
251
|
+
};
|
|
252
|
+
return __assign.apply(this, arguments);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
|
|
256
|
+
|
|
257
|
+
function clearNode(node) {
|
|
258
|
+
while (node.firstChild)
|
|
259
|
+
node.removeChild(node.firstChild);
|
|
260
|
+
}
|
|
261
|
+
function getEventTarget(event) {
|
|
262
|
+
try {
|
|
263
|
+
if (typeof event.composedPath === "function") {
|
|
264
|
+
var path = event.composedPath();
|
|
265
|
+
return path[0];
|
|
266
|
+
}
|
|
267
|
+
return event.target;
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
return event.target;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
var defaultConfig = {
|
|
275
|
+
shorthand: false,
|
|
276
|
+
dateFormat: "F Y",
|
|
277
|
+
altFormat: "F Y",
|
|
278
|
+
theme: "light",
|
|
279
|
+
};
|
|
280
|
+
function monthSelectPlugin(pluginConfig) {
|
|
281
|
+
var config = __assign(__assign({}, defaultConfig), pluginConfig);
|
|
282
|
+
return function (fp) {
|
|
283
|
+
fp.config.dateFormat = config.dateFormat;
|
|
284
|
+
fp.config.altFormat = config.altFormat;
|
|
285
|
+
var self = { monthsContainer: null };
|
|
286
|
+
function clearUnnecessaryDOMElements() {
|
|
287
|
+
if (!fp.rContainer)
|
|
288
|
+
return;
|
|
289
|
+
clearNode(fp.rContainer);
|
|
290
|
+
for (var index = 0; index < fp.monthElements.length; index++) {
|
|
291
|
+
var element = fp.monthElements[index];
|
|
292
|
+
if (!element.parentNode)
|
|
293
|
+
continue;
|
|
294
|
+
element.parentNode.removeChild(element);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function build() {
|
|
298
|
+
if (!fp.rContainer)
|
|
299
|
+
return;
|
|
300
|
+
self.monthsContainer = fp._createElement("div", "flatpickr-monthSelect-months");
|
|
301
|
+
self.monthsContainer.tabIndex = -1;
|
|
302
|
+
buildMonths();
|
|
303
|
+
fp.rContainer.appendChild(self.monthsContainer);
|
|
304
|
+
fp.calendarContainer.classList.add("flatpickr-monthSelect-theme-" + config.theme);
|
|
305
|
+
}
|
|
306
|
+
function buildMonths() {
|
|
307
|
+
if (!self.monthsContainer)
|
|
308
|
+
return;
|
|
309
|
+
clearNode(self.monthsContainer);
|
|
310
|
+
var frag = document.createDocumentFragment();
|
|
311
|
+
for (var i = 0; i < 12; i++) {
|
|
312
|
+
var month = fp.createDay("flatpickr-monthSelect-month", new Date(fp.currentYear, i), 0, i);
|
|
313
|
+
if (month.dateObj.getMonth() === new Date().getMonth() &&
|
|
314
|
+
month.dateObj.getFullYear() === new Date().getFullYear())
|
|
315
|
+
month.classList.add("today");
|
|
316
|
+
month.textContent = monthToStr(i, config.shorthand, fp.l10n);
|
|
317
|
+
month.addEventListener("click", selectMonth);
|
|
318
|
+
frag.appendChild(month);
|
|
319
|
+
}
|
|
320
|
+
self.monthsContainer.appendChild(frag);
|
|
321
|
+
if (fp.config.minDate &&
|
|
322
|
+
fp.currentYear === fp.config.minDate.getFullYear())
|
|
323
|
+
fp.prevMonthNav.classList.add("flatpickr-disabled");
|
|
324
|
+
else
|
|
325
|
+
fp.prevMonthNav.classList.remove("flatpickr-disabled");
|
|
326
|
+
if (fp.config.maxDate &&
|
|
327
|
+
fp.currentYear === fp.config.maxDate.getFullYear())
|
|
328
|
+
fp.nextMonthNav.classList.add("flatpickr-disabled");
|
|
329
|
+
else
|
|
330
|
+
fp.nextMonthNav.classList.remove("flatpickr-disabled");
|
|
331
|
+
}
|
|
332
|
+
function bindEvents() {
|
|
333
|
+
fp._bind(fp.prevMonthNav, "click", function (e) {
|
|
334
|
+
e.preventDefault();
|
|
335
|
+
e.stopPropagation();
|
|
336
|
+
fp.changeYear(fp.currentYear - 1);
|
|
337
|
+
selectYear();
|
|
338
|
+
buildMonths();
|
|
339
|
+
});
|
|
340
|
+
fp._bind(fp.nextMonthNav, "click", function (e) {
|
|
341
|
+
e.preventDefault();
|
|
342
|
+
e.stopPropagation();
|
|
343
|
+
fp.changeYear(fp.currentYear + 1);
|
|
344
|
+
selectYear();
|
|
345
|
+
buildMonths();
|
|
346
|
+
});
|
|
347
|
+
fp._bind(self.monthsContainer, "mouseover", function (e) {
|
|
348
|
+
if (fp.config.mode === "range")
|
|
349
|
+
fp.onMouseOver(getEventTarget(e), "flatpickr-monthSelect-month");
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
function setCurrentlySelected() {
|
|
353
|
+
if (!fp.rContainer)
|
|
354
|
+
return;
|
|
355
|
+
if (!fp.selectedDates.length)
|
|
356
|
+
return;
|
|
357
|
+
var currentlySelected = fp.rContainer.querySelectorAll(".flatpickr-monthSelect-month.selected");
|
|
358
|
+
for (var index = 0; index < currentlySelected.length; index++) {
|
|
359
|
+
currentlySelected[index].classList.remove("selected");
|
|
360
|
+
}
|
|
361
|
+
var targetMonth = fp.selectedDates[0].getMonth();
|
|
362
|
+
var month = fp.rContainer.querySelector(".flatpickr-monthSelect-month:nth-child(" + (targetMonth + 1) + ")");
|
|
363
|
+
if (month) {
|
|
364
|
+
month.classList.add("selected");
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function selectYear() {
|
|
368
|
+
var selectedDate = fp.selectedDates[0];
|
|
369
|
+
if (selectedDate) {
|
|
370
|
+
selectedDate = new Date(selectedDate);
|
|
371
|
+
selectedDate.setFullYear(fp.currentYear);
|
|
372
|
+
if (fp.config.minDate && selectedDate < fp.config.minDate) {
|
|
373
|
+
selectedDate = fp.config.minDate;
|
|
374
|
+
}
|
|
375
|
+
if (fp.config.maxDate && selectedDate > fp.config.maxDate) {
|
|
376
|
+
selectedDate = fp.config.maxDate;
|
|
377
|
+
}
|
|
378
|
+
fp.currentYear = selectedDate.getFullYear();
|
|
379
|
+
}
|
|
380
|
+
fp.currentYearElement.value = String(fp.currentYear);
|
|
381
|
+
if (fp.rContainer) {
|
|
382
|
+
var months = fp.rContainer.querySelectorAll(".flatpickr-monthSelect-month");
|
|
383
|
+
months.forEach(function (month) {
|
|
384
|
+
month.dateObj.setFullYear(fp.currentYear);
|
|
385
|
+
if ((fp.config.minDate && month.dateObj < fp.config.minDate) ||
|
|
386
|
+
(fp.config.maxDate && month.dateObj > fp.config.maxDate)) {
|
|
387
|
+
month.classList.add("flatpickr-disabled");
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
month.classList.remove("flatpickr-disabled");
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
setCurrentlySelected();
|
|
395
|
+
}
|
|
396
|
+
function selectMonth(e) {
|
|
397
|
+
e.preventDefault();
|
|
398
|
+
e.stopPropagation();
|
|
399
|
+
var eventTarget = getEventTarget(e);
|
|
400
|
+
if (!(eventTarget instanceof Element))
|
|
401
|
+
return;
|
|
402
|
+
if (eventTarget.classList.contains("flatpickr-disabled"))
|
|
403
|
+
return;
|
|
404
|
+
if (eventTarget.classList.contains("notAllowed"))
|
|
405
|
+
return; // necessary??
|
|
406
|
+
setMonth(eventTarget.dateObj);
|
|
407
|
+
if (fp.config.closeOnSelect) {
|
|
408
|
+
var single = fp.config.mode === "single";
|
|
409
|
+
var range = fp.config.mode === "range" && fp.selectedDates.length === 2;
|
|
410
|
+
if (single || range)
|
|
411
|
+
fp.close();
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function setMonth(date) {
|
|
415
|
+
var selectedDate = new Date(fp.currentYear, date.getMonth(), date.getDate());
|
|
416
|
+
var selectedDates = [];
|
|
417
|
+
switch (fp.config.mode) {
|
|
418
|
+
case "single":
|
|
419
|
+
selectedDates = [selectedDate];
|
|
420
|
+
break;
|
|
421
|
+
case "multiple":
|
|
422
|
+
selectedDates.push(selectedDate);
|
|
423
|
+
break;
|
|
424
|
+
case "range":
|
|
425
|
+
if (fp.selectedDates.length === 2) {
|
|
426
|
+
selectedDates = [selectedDate];
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
selectedDates = fp.selectedDates.concat([selectedDate]);
|
|
430
|
+
selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
|
|
431
|
+
}
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
fp.setDate(selectedDates, true);
|
|
435
|
+
setCurrentlySelected();
|
|
436
|
+
}
|
|
437
|
+
var shifts = {
|
|
438
|
+
37: -1,
|
|
439
|
+
39: 1,
|
|
440
|
+
40: 3,
|
|
441
|
+
38: -3,
|
|
442
|
+
};
|
|
443
|
+
function onKeyDown(_, __, ___, e) {
|
|
444
|
+
var shouldMove = shifts[e.keyCode] !== undefined;
|
|
445
|
+
if (!shouldMove && e.keyCode !== 13) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
if (!fp.rContainer || !self.monthsContainer)
|
|
449
|
+
return;
|
|
450
|
+
var currentlySelected = fp.rContainer.querySelector(".flatpickr-monthSelect-month.selected");
|
|
451
|
+
var index = Array.prototype.indexOf.call(self.monthsContainer.children, document.activeElement);
|
|
452
|
+
if (index === -1) {
|
|
453
|
+
var target = currentlySelected || self.monthsContainer.firstElementChild;
|
|
454
|
+
target.focus();
|
|
455
|
+
index = target.$i;
|
|
456
|
+
}
|
|
457
|
+
if (shouldMove) {
|
|
458
|
+
self.monthsContainer.children[(12 + index + shifts[e.keyCode]) % 12].focus();
|
|
459
|
+
}
|
|
460
|
+
else if (e.keyCode === 13 &&
|
|
461
|
+
self.monthsContainer.contains(document.activeElement)) {
|
|
462
|
+
setMonth(document.activeElement.dateObj);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
function closeHook() {
|
|
466
|
+
var _a;
|
|
467
|
+
if (((_a = fp.config) === null || _a === void 0 ? void 0 : _a.mode) === "range" && fp.selectedDates.length === 1)
|
|
468
|
+
fp.clear(false);
|
|
469
|
+
if (!fp.selectedDates.length)
|
|
470
|
+
buildMonths();
|
|
471
|
+
}
|
|
472
|
+
// Help the prev/next year nav honor config.minDate (see 3fa5a69)
|
|
473
|
+
function stubCurrentMonth() {
|
|
474
|
+
config._stubbedCurrentMonth = fp._initialDate.getMonth();
|
|
475
|
+
fp._initialDate.setMonth(config._stubbedCurrentMonth);
|
|
476
|
+
fp.currentMonth = config._stubbedCurrentMonth;
|
|
477
|
+
}
|
|
478
|
+
function unstubCurrentMonth() {
|
|
479
|
+
if (!config._stubbedCurrentMonth)
|
|
480
|
+
return;
|
|
481
|
+
fp._initialDate.setMonth(config._stubbedCurrentMonth);
|
|
482
|
+
fp.currentMonth = config._stubbedCurrentMonth;
|
|
483
|
+
delete config._stubbedCurrentMonth;
|
|
484
|
+
}
|
|
485
|
+
function destroyPluginInstance() {
|
|
486
|
+
if (self.monthsContainer !== null) {
|
|
487
|
+
var months = self.monthsContainer.querySelectorAll(".flatpickr-monthSelect-month");
|
|
488
|
+
for (var index = 0; index < months.length; index++) {
|
|
489
|
+
months[index].removeEventListener("click", selectMonth);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return {
|
|
494
|
+
onParseConfig: function () {
|
|
495
|
+
fp.config.enableTime = false;
|
|
496
|
+
},
|
|
497
|
+
onValueUpdate: setCurrentlySelected,
|
|
498
|
+
onKeyDown: onKeyDown,
|
|
499
|
+
onReady: [
|
|
500
|
+
stubCurrentMonth,
|
|
501
|
+
clearUnnecessaryDOMElements,
|
|
502
|
+
build,
|
|
503
|
+
bindEvents,
|
|
504
|
+
setCurrentlySelected,
|
|
505
|
+
function () {
|
|
506
|
+
fp.config.onClose.push(closeHook);
|
|
507
|
+
fp.loadedPlugins.push("monthSelect");
|
|
508
|
+
},
|
|
509
|
+
],
|
|
510
|
+
onDestroy: [
|
|
511
|
+
unstubCurrentMonth,
|
|
512
|
+
destroyPluginInstance,
|
|
513
|
+
function () {
|
|
514
|
+
fp.config.onClose = fp.config.onClose.filter(function (hook) { return hook !== closeHook; });
|
|
515
|
+
},
|
|
516
|
+
],
|
|
517
|
+
};
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return monthSelectPlugin;
|
|
522
|
+
|
|
523
|
+
})));
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
const stylesCss$b = ".flatpickr-calendar{background:transparent;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;background:#fff;-webkit-box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08);box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08)}.flatpickr-calendar.open,.flatpickr-calendar.inline{opacity:1;max-height:640px;visibility:visible}.flatpickr-calendar.open{display:inline-block;z-index:99999}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1);animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1)}.flatpickr-calendar.inline{display:block;position:relative;top:2px}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px)}.flatpickr-calendar.static.open{z-index:999;display:block}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none !important;box-shadow:none !important}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-calendar .hasWeeks .dayContainer,.flatpickr-calendar .hasTime .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0}.flatpickr-calendar.hasTime .flatpickr-time{height:40px;border-top:1px solid #e6e6e6}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto}.flatpickr-calendar:before,.flatpickr-calendar:after{position:absolute;display:block;pointer-events:none;border:solid transparent;content:'';height:0;width:0;left:22px}.flatpickr-calendar.rightMost:before,.flatpickr-calendar.arrowRight:before,.flatpickr-calendar.rightMost:after,.flatpickr-calendar.arrowRight:after{left:auto;right:22px}.flatpickr-calendar.arrowCenter:before,.flatpickr-calendar.arrowCenter:after{left:50%;right:50%}.flatpickr-calendar:before{border-width:5px;margin:0 -5px}.flatpickr-calendar:after{border-width:4px;margin:0 -4px}.flatpickr-calendar.arrowTop:before,.flatpickr-calendar.arrowTop:after{bottom:100%}.flatpickr-calendar.arrowTop:before{border-bottom-color:#e6e6e6}.flatpickr-calendar.arrowTop:after{border-bottom-color:#fff}.flatpickr-calendar.arrowBottom:before,.flatpickr-calendar.arrowBottom:after{top:100%}.flatpickr-calendar.arrowBottom:before{border-top-color:#e6e6e6}.flatpickr-calendar.arrowBottom:after{border-top-color:#fff}.flatpickr-calendar:focus{outline:0}.flatpickr-wrapper{position:relative;display:inline-block}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-months .flatpickr-month{background:transparent;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9);height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9)}.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,.flatpickr-months .flatpickr-next-month.flatpickr-disabled{display:none}.flatpickr-months .flatpickr-prev-month i,.flatpickr-months .flatpickr-next-month i{position:relative}.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,.flatpickr-months .flatpickr-next-month.flatpickr-prev-month{left:0}.flatpickr-months .flatpickr-prev-month.flatpickr-next-month,.flatpickr-months .flatpickr-next-month.flatpickr-next-month{right:0}.flatpickr-months .flatpickr-prev-month:hover,.flatpickr-months .flatpickr-next-month:hover{color:#959ea9}.flatpickr-months .flatpickr-prev-month:hover svg,.flatpickr-months .flatpickr-next-month:hover svg{fill:#f64747}.flatpickr-months .flatpickr-prev-month svg,.flatpickr-months .flatpickr-next-month svg{width:14px;height:14px}.flatpickr-months .flatpickr-prev-month svg path,.flatpickr-months .flatpickr-next-month svg path{-webkit-transition:fill .1s;transition:fill .1s;fill:inherit}.numInputWrapper{position:relative;height:auto}.numInputWrapper input,.numInputWrapper span{display:inline-block}.numInputWrapper input{width:100%}.numInputWrapper input::-ms-clear{display:none}.numInputWrapper input::-webkit-outer-spin-button,.numInputWrapper input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none}.numInputWrapper span{position:absolute;right:0;width:14px;padding:0 4px 0 2px;height:50%;line-height:50%;opacity:0;cursor:pointer;border:1px solid rgba(57,57,57,0.15);-webkit-box-sizing:border-box;box-sizing:border-box}.numInputWrapper span:hover{background:rgba(0,0,0,0.1)}.numInputWrapper span:active{background:rgba(0,0,0,0.2)}.numInputWrapper span:after{display:block;content:\"\";position:absolute}.numInputWrapper span.arrowUp{top:0;border-bottom:0}.numInputWrapper span.arrowUp:after{border-left:4px solid transparent;border-right:4px solid transparent;border-bottom:4px solid rgba(57,57,57,0.6);top:26%}.numInputWrapper span.arrowDown{top:50%}.numInputWrapper span.arrowDown:after{border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid rgba(57,57,57,0.6);top:40%}.numInputWrapper span svg{width:inherit;height:auto}.numInputWrapper span svg path{fill:rgba(0,0,0,0.5)}.numInputWrapper:hover{background:rgba(0,0,0,0.05)}.numInputWrapper:hover span{opacity:1}.flatpickr-current-month{font-size:135%;line-height:inherit;font-weight:300;color:inherit;position:absolute;width:75%;left:12.5%;padding:7.48px 0 0 0;line-height:1;height:34px;display:inline-block;text-align:center;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.flatpickr-current-month span.cur-month{font-family:inherit;font-weight:700;color:inherit;display:inline-block;margin-left:.5ch;padding:0}.flatpickr-current-month span.cur-month:hover{background:rgba(0,0,0,0.05)}.flatpickr-current-month .numInputWrapper{width:6ch;width:7ch\\0;display:inline-block}.flatpickr-current-month .numInputWrapper span.arrowUp:after{border-bottom-color:rgba(0,0,0,0.9)}.flatpickr-current-month .numInputWrapper span.arrowDown:after{border-top-color:rgba(0,0,0,0.9)}.flatpickr-current-month input.cur-year{background:transparent;-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;cursor:text;padding:0 0 0 .5ch;margin:0;display:inline-block;font-size:inherit;font-family:inherit;font-weight:300;line-height:inherit;height:auto;border:0;border-radius:0;vertical-align:initial;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.flatpickr-current-month input.cur-year:focus{outline:0}.flatpickr-current-month input.cur-year[disabled],.flatpickr-current-month input.cur-year[disabled]:hover{font-size:100%;color:rgba(0,0,0,0.5);background:transparent;pointer-events:none}.flatpickr-current-month .flatpickr-monthDropdown-months{appearance:menulist;background:transparent;border:none;border-radius:0;box-sizing:border-box;color:inherit;cursor:pointer;font-size:inherit;font-family:inherit;font-weight:300;height:auto;line-height:inherit;margin:-1px 0 0 0;outline:none;padding:0 0 0 .5ch;position:relative;vertical-align:initial;-webkit-box-sizing:border-box;-webkit-appearance:menulist;-moz-appearance:menulist;width:auto}.flatpickr-current-month .flatpickr-monthDropdown-months:focus,.flatpickr-current-month .flatpickr-monthDropdown-months:active{outline:none}.flatpickr-current-month .flatpickr-monthDropdown-months:hover{background:rgba(0,0,0,0.05)}.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month{background-color:transparent;outline:none;padding:0}.flatpickr-weekdays{background:transparent;text-align:center;overflow:hidden;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;height:28px}.flatpickr-weekdays .flatpickr-weekdaycontainer{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}span.flatpickr-weekday{cursor:default;font-size:90%;background:transparent;color:rgba(0,0,0,0.54);line-height:1;margin:0;text-align:center;display:block;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;font-weight:bolder}.dayContainer,.flatpickr-weeks{padding:1px 0 0 0}.flatpickr-days{position:relative;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;width:307.875px}.flatpickr-days:focus{outline:0}.dayContainer{padding:0;outline:0;text-align:left;width:307.875px;min-width:307.875px;max-width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;display:-ms-flexbox;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-wrap:wrap;-ms-flex-pack:justify;-webkit-justify-content:space-around;justify-content:space-around;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);opacity:1}.dayContainer+.dayContainer{-webkit-box-shadow:-1px 0 0 #e6e6e6;box-shadow:-1px 0 0 #e6e6e6}.flatpickr-day{background:none;border:1px solid transparent;border-radius:150px;-webkit-box-sizing:border-box;box-sizing:border-box;color:#393939;cursor:pointer;font-weight:400;width:14.2857143%;-webkit-flex-basis:14.2857143%;-ms-flex-preferred-size:14.2857143%;flex-basis:14.2857143%;max-width:39px;height:39px;line-height:39px;margin:0;display:inline-block;position:relative;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center}.flatpickr-day.inRange,.flatpickr-day.prevMonthDay.inRange,.flatpickr-day.nextMonthDay.inRange,.flatpickr-day.today.inRange,.flatpickr-day.prevMonthDay.today.inRange,.flatpickr-day.nextMonthDay.today.inRange,.flatpickr-day:hover,.flatpickr-day.prevMonthDay:hover,.flatpickr-day.nextMonthDay:hover,.flatpickr-day:focus,.flatpickr-day.prevMonthDay:focus,.flatpickr-day.nextMonthDay:focus{cursor:pointer;outline:0;background:#e6e6e6;border-color:#e6e6e6}.flatpickr-day.today{border-color:#959ea9}.flatpickr-day.today:hover,.flatpickr-day.today:focus{border-color:#959ea9;background:#959ea9;color:#fff}.flatpickr-day.selected,.flatpickr-day.startRange,.flatpickr-day.endRange,.flatpickr-day.selected.inRange,.flatpickr-day.startRange.inRange,.flatpickr-day.endRange.inRange,.flatpickr-day.selected:focus,.flatpickr-day.startRange:focus,.flatpickr-day.endRange:focus,.flatpickr-day.selected:hover,.flatpickr-day.startRange:hover,.flatpickr-day.endRange:hover,.flatpickr-day.selected.prevMonthDay,.flatpickr-day.startRange.prevMonthDay,.flatpickr-day.endRange.prevMonthDay,.flatpickr-day.selected.nextMonthDay,.flatpickr-day.startRange.nextMonthDay,.flatpickr-day.endRange.nextMonthDay{background:#569ff7;-webkit-box-shadow:none;box-shadow:none;color:#fff;border-color:#569ff7}.flatpickr-day.selected.startRange,.flatpickr-day.startRange.startRange,.flatpickr-day.endRange.startRange{border-radius:50px 0 0 50px}.flatpickr-day.selected.endRange,.flatpickr-day.startRange.endRange,.flatpickr-day.endRange.endRange{border-radius:0 50px 50px 0}.flatpickr-day.selected.startRange+.endRange:not(:nth-child(7n+1)),.flatpickr-day.startRange.startRange+.endRange:not(:nth-child(7n+1)),.flatpickr-day.endRange.startRange+.endRange:not(:nth-child(7n+1)){-webkit-box-shadow:-10px 0 0 #569ff7;box-shadow:-10px 0 0 #569ff7}.flatpickr-day.selected.startRange.endRange,.flatpickr-day.startRange.startRange.endRange,.flatpickr-day.endRange.startRange.endRange{border-radius:50px}.flatpickr-day.inRange{border-radius:0;-webkit-box-shadow:-5px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-5px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover,.flatpickr-day.prevMonthDay,.flatpickr-day.nextMonthDay,.flatpickr-day.notAllowed,.flatpickr-day.notAllowed.prevMonthDay,.flatpickr-day.notAllowed.nextMonthDay{color:rgba(57,57,57,0.3);background:transparent;border-color:transparent;cursor:default}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover{cursor:not-allowed;color:rgba(57,57,57,0.1)}.flatpickr-day.week.selected{border-radius:0;-webkit-box-shadow:-5px 0 0 #569ff7,5px 0 0 #569ff7;box-shadow:-5px 0 0 #569ff7,5px 0 0 #569ff7}.flatpickr-day.hidden{visibility:hidden}.rangeMode .flatpickr-day{margin-top:1px}.flatpickr-weekwrapper{float:left}.flatpickr-weekwrapper .flatpickr-weeks{padding:0 12px;-webkit-box-shadow:1px 0 0 #e6e6e6;box-shadow:1px 0 0 #e6e6e6}.flatpickr-weekwrapper .flatpickr-weekday{float:none;width:100%;line-height:28px}.flatpickr-weekwrapper span.flatpickr-day,.flatpickr-weekwrapper span.flatpickr-day:hover{display:block;width:100%;max-width:none;color:rgba(57,57,57,0.3);background:transparent;cursor:default;border:none}.flatpickr-innerContainer{display:block;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden}.flatpickr-rContainer{display:inline-block;padding:0;-webkit-box-sizing:border-box;box-sizing:border-box}.flatpickr-time{text-align:center;outline:0;display:block;height:0;line-height:40px;max-height:40px;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-time:after{content:\"\";display:table;clear:both}.flatpickr-time .numInputWrapper{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;width:40%;height:40px;float:left}.flatpickr-time .numInputWrapper span.arrowUp:after{border-bottom-color:#393939}.flatpickr-time .numInputWrapper span.arrowDown:after{border-top-color:#393939}.flatpickr-time.hasSeconds .numInputWrapper{width:26%}.flatpickr-time.time24hr .numInputWrapper{width:49%}.flatpickr-time input{background:transparent;-webkit-box-shadow:none;box-shadow:none;border:0;border-radius:0;text-align:center;margin:0;padding:0;height:inherit;line-height:inherit;color:#393939;font-size:14px;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.flatpickr-time input.flatpickr-hour{font-weight:bold}.flatpickr-time input.flatpickr-minute,.flatpickr-time input.flatpickr-second{font-weight:400}.flatpickr-time input:focus{outline:0;border:0}.flatpickr-time .flatpickr-time-separator,.flatpickr-time .flatpickr-am-pm{height:inherit;float:left;line-height:inherit;color:#393939;font-weight:bold;width:2%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-align-self:center;-ms-flex-item-align:center;align-self:center}.flatpickr-time .flatpickr-am-pm{outline:0;width:18%;cursor:pointer;text-align:center;font-weight:400}.flatpickr-time input:hover,.flatpickr-time .flatpickr-am-pm:hover,.flatpickr-time input:focus,.flatpickr-time .flatpickr-am-pm:focus{background:#eee}.flatpickr-input[readonly]{cursor:pointer}@-webkit-keyframes fpFadeInDown{from{opacity:0;-webkit-transform:translate3d(0,-20px,0);transform:translate3d(0,-20px,0)}to{opacity:1;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}}@keyframes fpFadeInDown{from{opacity:0;-webkit-transform:translate3d(0,-20px,0);transform:translate3d(0,-20px,0)}to{opacity:1;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}}.flatpickr-monthSelect-months{margin:10px 1px 3px 1px;flex-wrap:wrap}.flatpickr-monthSelect-month{background:none;border:1px solid transparent;border-radius:4px;-webkit-box-sizing:border-box;box-sizing:border-box;color:#393939;cursor:pointer;display:inline-block;font-weight:400;margin:0.5px;justify-content:center;padding:10px;position:relative;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;text-align:center;width:33%}.flatpickr-monthSelect-month.flatpickr-disabled{color:#eee}.flatpickr-monthSelect-month.flatpickr-disabled:hover,.flatpickr-monthSelect-month.flatpickr-disabled:focus{cursor:not-allowed;background:none !important}.flatpickr-monthSelect-theme-dark{background:#3f4458}.flatpickr-monthSelect-theme-dark .flatpickr-current-month input.cur-year{color:#fff}.flatpickr-monthSelect-theme-dark .flatpickr-months .flatpickr-prev-month,.flatpickr-monthSelect-theme-dark .flatpickr-months .flatpickr-next-month{color:#fff;fill:#fff}.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month{color:rgba(255, 255, 255, 0.95)}.flatpickr-monthSelect-month.today{border-color:#959ea9}.flatpickr-monthSelect-month.inRange,.flatpickr-monthSelect-month.inRange.today,.flatpickr-monthSelect-month:hover,.flatpickr-monthSelect-month:focus{background:#e6e6e6;cursor:pointer;outline:0;border-color:#e6e6e6}.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month.inRange,.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month:hover,.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month:focus{background:#646c8c;border-color:#646c8c}.flatpickr-monthSelect-month.today:hover,.flatpickr-monthSelect-month.today:focus{background:#959ea9;border-color:#959ea9;color:#fff}.flatpickr-monthSelect-month.selected,.flatpickr-monthSelect-month.startRange,.flatpickr-monthSelect-month.endRange{background-color:#569ff7;box-shadow:none;color:#fff;border-color:#569ff7}.flatpickr-monthSelect-month.startRange{border-radius:50px 0 0 50px}.flatpickr-monthSelect-month.endRange{border-radius:0 50px 50px 0}.flatpickr-monthSelect-month.startRange.endRange{border-radius:50px}.flatpickr-monthSelect-month.inRange{border-radius:0;box-shadow:-5px 0 0 #e6e6e6, 5px 0 0 #e6e6e6}.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month.selected,.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month.startRange,.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month.endRange{background:#80cbc4;-webkit-box-shadow:none;box-shadow:none;color:#fff;border-color:#80cbc4}:host{font-family:var(--font-family-sans);font-weight:var(--font-rg);--z-range-picker--toggle-height:0}z-date-picker{position:relative}z-date-picker>div>*{cursor:pointer !important}z-range-picker{position:relative}.flatpickr-toggle-container{width:fit-content}.range-pickers-container>div{position:relative}.hidden-input{position:absolute;bottom:0;width:0;height:0;visibility:hidden !important}.flatpickr-calendar::before,.flatpickr-calendar::after{display:none}.flatpickr-calendar{position:absolute !important;top:var(--z-range-picker--toggle-height) !important;left:0 !important;padding-top:calc(var(--space-unit) * 2);border-radius:2px;box-shadow:var(--shadow-2);font-family:var(--font-family-sans) !important}.months.top>.flatpickr-calendar{top:-288px !important}.date.top>.flatpickr-calendar,.date.top>div>.flatpickr-calendar{top:-401px !important}.date-time.top>.flatpickr-calendar,.date-time.top>div>.flatpickr-calendar{top:-523px !important}.flatpickr-calendar,.flatpickr-innerContainer,.flatpickr-days,.dayContainer,.flatpickr-rContainer,.flatpickr-monthSelect-months{width:calc(var(--space-unit) * 42) !important;max-width:calc(var(--space-unit) * 42) !important}.flatpickr-monthSelect-months{box-sizing:border-box;padding:0 !important;margin:calc(var(--space-unit) * 2) 0 !important}.flatpickr-months{position:relative;height:calc(var(--space-unit) * 6) !important;align-items:center;margin-bottom:var(--space-unit) 0 !important}.flatpickr-month{overflow:visible !important;height:calc(var(--space-unit) * 6) !important}.flatpickr-current-month{left:0 !important;display:flex !important;width:fill-available;height:calc(var(--space-unit) * 6);align-items:baseline;justify-content:space-evenly;padding-top:0}.flatpickr-next-month,.flatpickr-prev-month{position:static !important;display:flex;width:calc(var(--space-unit) * 4) !important;height:calc(var(--space-unit) * 4) !important;align-items:center;justify-content:center;padding:0 !important}.flatpickr-prev-month{margin-left:var(--space-unit)}.flatpickr-next-month{margin-right:var(--space-unit)}.flatpickr-next-month>svg,.flatpickr-prev-month>svg{width:calc(var(--space-unit) * 2) !important;height:calc(var(--space-unit) * 2) !important;fill:var(--color-primary01)}.flatpickr-next-month:hover,.flatpickr-prev-month:hover,.flatpickr-next-month:focus,.flatpickr-prev-month:focus{border:none !important;border-color:var(--color-primary03) !important;background-color:var(--color-primary03) !important;border-radius:var(--border-radius);color:var(--color-hover-primary) !important;outline:none !important}.flatpickr-next-month:hover svg,.flatpickr-prev-month:hover svg{fill:var(--color-hover-primary) !important}.flatpickr-next-month:active,.flatpickr-prev-month:active{border-color:var(--color-surface01) !important;background-color:var(--color-surface01) !important;border-radius:var(--border-radius);box-shadow:var(--shadow-2) !important;color:var(--color-primary01) !important}.flatpickr-next-month:focus svg,.flatpickr-prev-month:focus svg{fill:var(--color-primary01) !important}.flatpickr-monthDropdown-months{width:108px !important;height:calc(var(--space-unit) * 5.5) !important;padding-left:var(--space-unit) !important;background:var(--color-surface01) !important;color:var(--color-text02) !important;font-size:var(--font-size-3) !important;font-weight:var(--font-rg) !important;outline:1px solid black !important}.flatpickr-monthDropdown-months:hover,.flatpickr-monthDropdown-months:focus{outline:1px solid var(--color-primary01) !important}.flatpickr-current-month>.numInputWrapper{display:flex;width:calc(var(--space-unit) * 10);height:calc(var(--space-unit) * 5.5) !important;background:var(--color-surface01) !important;color:var(--color-text02);outline:1px solid black !important}.flatpickr-current-month>.numInputWrapper:hover,.flatpickr-current-month>.numInputWrapper:focus-within{outline:1px solid var(--color-primary01) !important}.flatpickr-current-month>.numInputWrapper>input{padding:0 calc(var(--space-unit) * 3) 0 var(--space-unit);font-size:var(--font-size-3) !important;font-weight:var(--font-rg) !important;text-align:center}.flatpickr-weekdays{height:calc(var(--space-unit) * 6);border-bottom:1px solid var(--color-surface03)}.flatpickr-weekday{font-size:var(--font-size-3) !important;font-weight:var(--font-rg) !important}.flatpickr-day,.flatpickr-monthSelect-month{width:calc(var(--space-unit) * 6) !important;max-width:100% !important;height:calc(var(--space-unit) * 6) !important;border:none;margin:0 !important;border-radius:0 !important;box-shadow:none !important;font-size:var(--font-size-3) !important;line-height:calc(var(--space-unit) * 6) !important}.flatpickr-day{width:calc(var(--space-unit) * 6) !important;border:none;line-height:calc(var(--space-unit) * 6) !important}.flatpickr-monthSelect-month{width:calc(var(--space-unit) * 14) !important;padding:0 !important;border:2px solid var(--color-surface01) !important;line-height:calc(var(--space-unit) * 5) !important}.flatpickr-day:not(.flatpickr-disabled):hover,.flatpickr-day:not(.flatpickr-disabled):active,.flatpickr-day:not(.flatpickr-disabled):focus,.flatpickr-day:not(.flatpickr-disabled).prevMonthDay:hover,.flatpickr-day:not(.flatpickr-disabled).prevMonthDay:active,.flatpickr-day:not(.flatpickr-disabled).prevMonthDay:focus,.flatpickr-day:not(.flatpickr-disabled).selected:hover,.flatpickr-day:not(.flatpickr-disabled).selected:active,.flatpickr-day:not(.flatpickr-disabled).selected:focus,.flatpickr-monthSelect-month:hover,.flatpickr-monthSelect-month:active,.flatpickr-monthSelect-month:focus{border-color:var(--color-hover-primary) !important;background-color:var(--color-hover-primary) !important;color:var(--color-text04) !important}.flatpickr-day.today,.flatpickr-monthSelect-month.today{border:2px solid var(--color-hover-primary) !important}.flatpickr-day.selected:not(.flatpickr-disabled),.flatpickr-monthSelect-month.selected:not(.flatpickr-disabled){border-color:var(--color-primary01) !important;background-color:var(--color-primary01) !important}.flatpickr-weekday:nth-child(6),.flatpickr-weekday:nth-child(7),.flatpickr-day:nth-child(7n+6),.flatpickr-day:nth-child(7n+7){font-weight:var(--font-sb) !important}.flatpickr-time{display:block;height:90px !important;max-height:90px !important;text-align:left}.flatpickr-time::before{display:block;width:100%;padding-left:var(--space-unit);color:var(--color-text02) !important;content:\"Orario\";font-size:var(--font-size-1);font-weight:var(--font-sb);text-transform:uppercase}.flatpickr-time.time24hr{margin:calc(var(--space-unit) * 2) !important}.flatpickr-time.time24hr>.numInputWrapper>input:hover,.flatpickr-time.time24hr>.numInputWrapper>input:focus,.flatpickr-time.time24hr>.numInputWrapper:hover{background-color:var(--color-surface01) !important}.flatpickr-time.time24hr>div{width:calc(var(--space-unit) * 10) !important;height:calc(var(--space-unit) * 5.5) !important;margin-right:var(--space-unit) !important;margin-left:var(--space-unit) !important}.flatpickr-time-separator{display:flex;height:calc(var(--space-unit) * 5.5) !important;align-items:center;justify-content:center;font-weight:unset !important}.flatpickr-minute,.flatpickr-hour{font-size:var(--font-size-3) !important;font-weight:var(--font-rg) !important;outline:1px solid black !important}.numInputWrapper:hover .flatpickr-minute,.numInputWrapper:hover .flatpickr-hour,.flatpickr-minute:focus,.flatpickr-hour:focus{outline:1px solid var(--color-primary01) !important}.arrowUp,.arrowDown{width:calc(var(--space-unit) * 2) !important;height:calc(var(--space-unit) * 2) !important;padding:0 !important;border:none !important;opacity:1 !important}.arrowUp{margin-top:calc(var(--space-unit) / 2) !important;margin-right:calc(var(--space-unit) / 2) !important}.arrowDown{top:auto !important;margin-top:calc(var(--space-unit) * 3) !important;margin-right:calc(var(--space-unit) / 2) !important}.arrowUp:hover,.arrowDown:hover{border-color:var(--color-primary03) !important;background-color:var(--color-primary03) !important;border-radius:var(--border-radius);color:var(--color-hover-primary) !important}.arrowUp:active,.arrowDown:active{border-color:var(--color-surface01) !important;background-color:var(--color-surface01) !important;border-radius:var(--border-radius);box-shadow:var(--shadow-2) !important;color:var(--color-primary01) !important}.arrowUp::after,.arrowDown::after{padding:2.5px !important;border:solid var(--color-primary01) !important;border-width:0 1px 1px 0 !important}.arrowUp::after{top:0 !important;margin-top:6px !important;margin-left:5.5px !important;transform:rotate(-135deg)}.arrowDown::after{top:0 !important;left:5.5px !important;margin-top:4px !important;transform:rotate(45deg)}.flatpickr-day:not(.flatpickr-disabled).inRange:hover,.flatpickr-day:not(.flatpickr-disabled).today.inRange:hover,.flatpickr-day.prevMonthDay:not(.flatpickr-disabled).inRange:hover,.flatpickr-monthSelect-month:not(.flatpickr-disabled).inRange:hover{border-color:var(--color-hover-primary) !important;background-color:var(--color-hover-primary) !important}.flatpickr-day:not(.flatpickr-disabled).inRange,.flatpickr-day:not(.flatpickr-disabled).today.inRange,.flatpickr-day:not(.flatpickr-disabled).prevMonthDay.inRange,.flatpickr-monthSelect-month:not(.flatpickr-disabled).inRange{border-color:var(--color-primary03);background-color:var(--color-primary03)}.flatpickr-day:not(.flatpickr-disabled).startRange,.flatpickr-day:not(.flatpickr-disabled).endRange,.flatpickr-monthSelect-month:not(.flatpickr-disabled).startRange,.flatpickr-monthSelect-month:not(.flatpickr-disabled).endRange{border-color:var(--color-primary01) !important;background-color:var(--color-primary01) !important}.flatpickr-day:not(.flatpickr-disabled).prevMonthDay.selected.startRange,.flatpickr-day:not(.flatpickr-disabled).prevMonthDay.selected.endRange{border-color:var(--color-primary01) !important;background-color:var(--color-primary01) !important}.flatpickr-range.second-input{cursor:pointer}.range-pickers-container{display:flex;gap:16px}";
|
|
527
|
+
|
|
528
|
+
const ZDatePicker = class {
|
|
529
|
+
constructor(hostRef) {
|
|
530
|
+
index.registerInstance(this, hostRef);
|
|
531
|
+
this.dateSelect = index.createEvent(this, "dateSelect", 7);
|
|
532
|
+
/** z-input aria label */
|
|
533
|
+
this.ariaLabel = "";
|
|
534
|
+
/** [Optional] datepicker mode: date, datetime, only months */
|
|
535
|
+
this.mode = index$1.ZDatePickerMode.DATE;
|
|
536
|
+
this.flatpickrPosition = index$1.ZDatePickerPosition.BOTTOM;
|
|
537
|
+
this.inputError = false;
|
|
538
|
+
}
|
|
539
|
+
emitDateSelect(date) {
|
|
540
|
+
this.dateSelect.emit(date);
|
|
541
|
+
}
|
|
542
|
+
handleKeyDown(ev) {
|
|
543
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
544
|
+
if (ev.key === "Escape") {
|
|
545
|
+
(_a = this.picker) === null || _a === void 0 ? void 0 : _a.close();
|
|
546
|
+
}
|
|
547
|
+
if (ev.key === "Enter" || ev.key === " ") {
|
|
548
|
+
!this.hasChildren && ((_b = this.picker) === null || _b === void 0 ? void 0 : _b.open());
|
|
549
|
+
const isCrossIconEntered = document.activeElement.classList.contains("reset-icon");
|
|
550
|
+
if (isCrossIconEntered) {
|
|
551
|
+
this.inputError = false;
|
|
552
|
+
(_c = this.picker) === null || _c === void 0 ? void 0 : _c.setDate([]);
|
|
553
|
+
this.dateSelect.emit(null);
|
|
554
|
+
}
|
|
555
|
+
document.activeElement.classList.contains("flatpickr-day");
|
|
556
|
+
const isPrevArrowEntered = document.activeElement.classList.contains("flatpickr-prev-month");
|
|
557
|
+
const isNextArrowEntered = document.activeElement.classList.contains("flatpickr-next-month");
|
|
558
|
+
const arrowPressed = isPrevArrowEntered || isNextArrowEntered;
|
|
559
|
+
arrowPressed && ev.key === " " && ev.preventDefault();
|
|
560
|
+
if (this.mode === index$1.ZDatePickerMode.MONTHS) {
|
|
561
|
+
isPrevArrowEntered && ((_d = this.picker) === null || _d === void 0 ? void 0 : _d.changeYear(this.picker.currentYear - 1));
|
|
562
|
+
isNextArrowEntered && ((_e = this.picker) === null || _e === void 0 ? void 0 : _e.changeYear(this.picker.currentYear + 1));
|
|
563
|
+
if (arrowPressed) {
|
|
564
|
+
const calendar = this.element.getElementsByClassName("flatpickr-calendar")[0];
|
|
565
|
+
const months = calendar === null || calendar === void 0 ? void 0 : calendar.querySelectorAll(".flatpickr-monthSelect-month");
|
|
566
|
+
months === null || months === void 0 ? void 0 : months.forEach((element) => {
|
|
567
|
+
var _a;
|
|
568
|
+
element.setAttribute("aria-label", `${element.innerHTML} ${(_a = this.picker) === null || _a === void 0 ? void 0 : _a.currentYear}`);
|
|
569
|
+
});
|
|
570
|
+
//Force check of the current day
|
|
571
|
+
months &&
|
|
572
|
+
Array.from(months).forEach((element, index) => {
|
|
573
|
+
var _a;
|
|
574
|
+
const curMonth = new Date().getMonth();
|
|
575
|
+
const curYear = new Date().getFullYear();
|
|
576
|
+
if (index === curMonth) {
|
|
577
|
+
if (((_a = this.picker) === null || _a === void 0 ? void 0 : _a.currentYear) === curYear) {
|
|
578
|
+
element.setAttribute("class", "flatpickr-monthSelect-month today");
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
element.setAttribute("class", "flatpickr-monthSelect-month");
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
isPrevArrowEntered && ((_f = this.picker) === null || _f === void 0 ? void 0 : _f.changeMonth(-1));
|
|
589
|
+
isNextArrowEntered && ((_g = this.picker) === null || _g === void 0 ? void 0 : _g.changeMonth(1));
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
componentWillLoad() {
|
|
594
|
+
const customToggle = this.element.querySelector("[slot=toggle]");
|
|
595
|
+
this.hasChildren = !!customToggle;
|
|
596
|
+
this.hasChildren && customToggle.setAttribute("data-toggle", "data-toggle");
|
|
597
|
+
}
|
|
598
|
+
componentDidLoad() {
|
|
599
|
+
this.setupPickers();
|
|
600
|
+
}
|
|
601
|
+
setupPickers() {
|
|
602
|
+
const classToAppend = this.hasChildren ? `${this.datePickerId}-hidden` : `${this.datePickerId}-container`;
|
|
603
|
+
this.picker = utils.flatpickr(`.${classToAppend}`, {
|
|
604
|
+
appendTo: this.element.children[0],
|
|
605
|
+
enableTime: this.mode === index$1.ZDatePickerMode.DATE_TIME,
|
|
606
|
+
locale: utils.it.Italian,
|
|
607
|
+
allowInput: true,
|
|
608
|
+
dateFormat: this.mode === index$1.ZDatePickerMode.DATE_TIME ? "d-m-Y - H:i" : "d-m-Y",
|
|
609
|
+
ariaDateFormat: this.mode === index$1.ZDatePickerMode.MONTHS ? "F Y" : "d F Y",
|
|
610
|
+
minuteIncrement: 1,
|
|
611
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
612
|
+
time_24hr: true,
|
|
613
|
+
onChange: (_selectedDates, dateStr) => {
|
|
614
|
+
this.emitDateSelect(dateStr);
|
|
615
|
+
},
|
|
616
|
+
onOpen: () => {
|
|
617
|
+
utils.setAriaOptions(this.element, this.mode);
|
|
618
|
+
this.flatpickrPosition = utils.setFlatpickrPosition(this.element, this.mode);
|
|
619
|
+
},
|
|
620
|
+
onKeyDown: () => {
|
|
621
|
+
utils.setAriaOptions(this.element, this.mode);
|
|
622
|
+
},
|
|
623
|
+
wrap: true,
|
|
624
|
+
plugins: this.mode === index$1.ZDatePickerMode.MONTHS && [
|
|
625
|
+
monthSelect({
|
|
626
|
+
dateFormat: "m-Y",
|
|
627
|
+
altFormat: "m-Y",
|
|
628
|
+
}),
|
|
629
|
+
],
|
|
630
|
+
});
|
|
631
|
+
this.element.querySelectorAll(".flatpickr-weekday").forEach((element) => {
|
|
632
|
+
element.innerHTML = element.innerHTML.trim().charAt(0);
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
formatDate(date) {
|
|
636
|
+
if (this.mode === index$1.ZDatePickerMode.DATE) {
|
|
637
|
+
return `${utils.flatpickr.formatDate(date, "d-m-Y")}`;
|
|
638
|
+
}
|
|
639
|
+
else if (this.mode === index$1.ZDatePickerMode.MONTHS) {
|
|
640
|
+
return `${utils.flatpickr.formatDate(date, "m-Y")}`;
|
|
641
|
+
}
|
|
642
|
+
return `${utils.flatpickr.formatDate(date, "d-m-Y - H:i")}`;
|
|
643
|
+
}
|
|
644
|
+
onStopTyping(value) {
|
|
645
|
+
let text = value.detail.value;
|
|
646
|
+
if (this.mode === index$1.ZDatePickerMode.MONTHS) {
|
|
647
|
+
text = "01-".concat(value.detail.value);
|
|
648
|
+
}
|
|
649
|
+
const englishData = text.split("-");
|
|
650
|
+
const time = this.mode === index$1.ZDatePickerMode.DATE_TIME ? `T${englishData[3]}:00` : "";
|
|
651
|
+
const englishParsedData = `${englishData[2]}-${englishData[1]}-${englishData[0]}${time}`.split(" ").join("");
|
|
652
|
+
const isValidDate = utils.validateDate(englishParsedData, this.mode === index$1.ZDatePickerMode.DATE_TIME);
|
|
653
|
+
if (text === "") {
|
|
654
|
+
this.inputError = false;
|
|
655
|
+
this.picker.setDate([]);
|
|
656
|
+
this.dateSelect.emit(null);
|
|
657
|
+
}
|
|
658
|
+
else if (!isValidDate) {
|
|
659
|
+
this.inputError = true;
|
|
660
|
+
this.dateSelect.emit(null);
|
|
661
|
+
}
|
|
662
|
+
else if (isValidDate) {
|
|
663
|
+
this.inputError = false;
|
|
664
|
+
this.picker.setDate([value.detail.value]);
|
|
665
|
+
this.dateSelect.emit(this.formatDate(new Date(englishParsedData)));
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
renderSlottedContent() {
|
|
669
|
+
return (index.h("div", { class: `${this.datePickerId}-hidden` }, index.h("input", { class: "hidden-input", "data-input": true }), index.h("slot", { name: "toggle" })));
|
|
670
|
+
}
|
|
671
|
+
renderZInput() {
|
|
672
|
+
return (index.h("div", { class: `${this.datePickerId}-container` }, index.h("z-input", { "data-input": "data-input", ariaLabel: this.ariaLabel, label: this.label, class: this.datePickerId, type: index$1.InputType.TEXT, icon: "event", message: false, tabindex: "0", value: "", onStopTyping: (value) => {
|
|
673
|
+
this.onStopTyping(value);
|
|
674
|
+
}, onStartTyping: () => {
|
|
675
|
+
this.inputError = false;
|
|
676
|
+
} })));
|
|
677
|
+
}
|
|
678
|
+
render() {
|
|
679
|
+
return (index.h("div", { class: {
|
|
680
|
+
"flatpickr-toggle-container": true,
|
|
681
|
+
[this.flatpickrPosition]: true,
|
|
682
|
+
[this.mode]: true,
|
|
683
|
+
} }, this.hasChildren ? this.renderSlottedContent() : this.renderZInput()));
|
|
684
|
+
}
|
|
685
|
+
get element() { return index.getElement(this); }
|
|
686
|
+
static get watchers() { return {
|
|
687
|
+
"mode": ["setupPickers"]
|
|
688
|
+
}; }
|
|
689
|
+
};
|
|
690
|
+
ZDatePicker.style = stylesCss$b;
|
|
691
|
+
|
|
692
|
+
const stylesCss$a = ".sc-z-divider-h{display:block;padding:0;margin:0}.divider-horizontal.sc-z-divider-h{width:100%}.divider-vertical.sc-z-divider-h{height:100%}.divider-small.divider-horizontal.sc-z-divider-h{height:var(--border-size-small)}.divider-medium.divider-horizontal.sc-z-divider-h{height:var(--border-size-medium)}.divider-large.divider-horizontal.sc-z-divider-h{height:var(--border-size-large)}.divider-small.divider-vertical.sc-z-divider-h{width:var(--border-size-small)}.divider-medium.divider-vertical.sc-z-divider-h{width:var(--border-size-medium)}.divider-large.divider-vertical.sc-z-divider-h{width:var(--border-size-large)}";
|
|
693
|
+
|
|
694
|
+
const ZDivider = class {
|
|
695
|
+
constructor(hostRef) {
|
|
696
|
+
index.registerInstance(this, hostRef);
|
|
697
|
+
/** [optional] Divider size */
|
|
698
|
+
this.size = index$1.DividerSize.SMALL;
|
|
699
|
+
/** [optional] Divider color */
|
|
700
|
+
this.color = "gray200";
|
|
701
|
+
/** [optional] Divider orintation */
|
|
702
|
+
this.orientation = index$1.DividerOrientation.HORIZONTAL;
|
|
703
|
+
}
|
|
704
|
+
render() {
|
|
705
|
+
return (index.h(index.Host, { class: `divider-${this.size} divider-${this.orientation}`, style: { backgroundColor: `var(--${this.color})` } }));
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
ZDivider.style = stylesCss$a;
|
|
709
|
+
|
|
710
|
+
const stylesCss$9 = ":host{margin-right:var(--z-icon-right-margin, 0);margin-left:var(--z-icon-left-margin, 0);line-height:0;vertical-align:middle}:host svg:not([width]){width:var(--z-icon-width, 18px)}:host svg:not([height]){height:var(--z-icon-height, 18px)}";
|
|
711
|
+
|
|
712
|
+
const ZIcon = class {
|
|
713
|
+
constructor(hostRef) {
|
|
714
|
+
index.registerInstance(this, hostRef);
|
|
715
|
+
}
|
|
716
|
+
selectPathOrPolygon(iconValue) {
|
|
717
|
+
if (iconValue === null || iconValue === void 0 ? void 0 : iconValue.startsWith("M")) {
|
|
718
|
+
return index.h("path", { d: icons.ICONS[this.name] });
|
|
719
|
+
}
|
|
720
|
+
return index.h("polygon", { points: icons.ICONS[this.name] });
|
|
721
|
+
}
|
|
722
|
+
render() {
|
|
723
|
+
return (index.h(index.Host, { "aria-hidden": "true" }, index.h("svg", { viewBox: "0 0 1000 1000", width: this.width, height: this.height, id: this.iconid, fill: this.fill ? `var(--${this.fill})` : "" }, this.selectPathOrPolygon(icons.ICONS[this.name]))));
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
ZIcon.style = stylesCss$9;
|
|
727
|
+
|
|
728
|
+
const stylesCss$8 = ".sc-z-input-h{display:inline-block;width:inherit}input.sc-z-input::-ms-clear,input.sc-z-input::-ms-reveal{display:none}.sc-z-input-h input.sc-z-input::-ms-clear,.sc-z-input-h input.sc-z-input::-ms-reveal{display:none}input.sc-z-input,textarea.sc-z-input,.textarea-wrapper.sc-z-input{box-sizing:border-box;border:var(--border-size-small) solid var(--color-surface04);background:var(--color-input-field01);border-radius:var(--border-radius-small);color:var(--color-text01);fill:var(--color-icon02);font-family:var(--font-family-sans);font-size:var(--font-size-3);font-weight:var(--font-rg);outline:none}[size=\"small\"].sc-z-input-h input.sc-z-input,[size=\"small\"].sc-z-input-h textarea.sc-z-input,[size=\"small\"].sc-z-input-h .textarea-wrapper.sc-z-input,[size=\"x-small\"].sc-z-input-h input.sc-z-input,[size=\"x-small\"].sc-z-input-h textarea.sc-z-input,[size=\"x-small\"].sc-z-input-h .textarea-wrapper.sc-z-input{font-size:var(--font-size-2)}.cursor-select.sc-z-input-h input.sc-z-input{cursor:pointer}.sc-z-input-h:not(.active-select) input.sc-z-input:focus:focus-visible,.textarea-wrapper.sc-z-input:focus-within{box-shadow:var(--shadow-focus-primary)}input.sc-z-input:focus:focus-visible,textarea.sc-z-input:focus:focus-visible{color:var(--color-primary02)}.active-select.sc-z-input-h input.sc-z-input{border:var(--border-size-small) solid var(--blue500)}.cursor-select.sc-z-input-h input.sc-z-input:focus:focus-visible{box-shadow:var(--shadow-focus-primary)}.sc-z-input-h input[readonly].sc-z-input:focus:focus-visible{box-shadow:none}.filled.sc-z-input{border-color:var(--color-surface05)}.input-success.sc-z-input{border-color:var(--color-success01);background:var(--color-success-inverse);fill:var(--color-success01)}.input-error.sc-z-input{border-color:var(--color-error01);background:var(--color-error-inverse);fill:var(--color-error01)}.input-warning.sc-z-input{border-color:var(--color-warning01);background:var(--color-warning-inverse);fill:var(--color-warning01)}input.sc-z-input:hover,.textarea-wrapper.sc-z-input:hover{outline:var(--border-size-medium) solid var(--color-surface04);outline-offset:-2px}.sc-z-input-h:not(.active-select) input[readonly].sc-z-input,.readonly.sc-z-input{border-color:var(--color-disabled01);fill:var(--color-disabled01);pointer-events:none}[disabled].sc-z-input-h:not([disabled=\"false\"]) input.sc-z-input,[disabled].sc-z-input-h:not([disabled=\"false\"]) .textarea-wrapper.sc-z-input,[disabled].sc-z-input-h:not([disabled=\"false\"]) z-icon.sc-z-input{border-color:var(--color-disabled01);box-shadow:none;color:var(--color-disabled02);fill:var(--color-disabled01);pointer-events:none}[disabled].sc-z-input-h:not([disabled=\"false\"]) input.sc-z-input:hover{border-width:var(--border-size-small)}input.sc-z-input::placeholder,textarea.sc-z-input::placeholder{color:var(--color-text05)}.sc-z-input::-webkit-textarea-placeholder{color:var(--color-text05)}.sc-z-input:-ms-textarea-placeholder{color:var(--color-text05)}.sc-z-input::placeholder{color:var(--color-text05)}label.input-label.sc-z-input{display:block;padding-bottom:var(--space-unit);color:var(--color-text02);font-family:var(--font-family-sans);font-size:var(--font-size-1);font-weight:var(--font-sb);text-align:left;text-transform:uppercase}[disabled].sc-z-input-h:not([disabled=\"false\"]) label.input-label.sc-z-input{color:var(--color-disabled02)}.text-wrapper.sc-z-input>div.sc-z-input{position:relative;z-index:1;fill:var(--color-icon02)}.text-wrapper.sc-z-input>div.sc-z-input>input.sc-z-input{width:100%;height:calc(var(--space-unit) * 5.5);box-sizing:border-box;padding:0 calc(var(--space-unit) * 1.5);margin:0}[size=\"small\"].sc-z-input-h .text-wrapper.sc-z-input>div.sc-z-input>input.sc-z-input{height:calc(var(--space-unit) * 4.5)}[size=\"x-small\"].sc-z-input-h .text-wrapper.sc-z-input>div.sc-z-input>input.sc-z-input{height:calc(var(--space-unit) * 4)}.text-wrapper.sc-z-input>div.sc-z-input>input.has-icon.sc-z-input,.text-wrapper.sc-z-input>div.sc-z-input>input.has-clear-icon.sc-z-input{padding-right:calc(var(--space-unit) * 5.25)}.text-wrapper.sc-z-input>div.sc-z-input>input.has-icon.has-clear-icon.sc-z-input{padding-right:calc(var(--space-unit) * 8)}.text-wrapper.sc-z-input .icons-wrapper.sc-z-input{position:absolute;z-index:2;top:50%;right:calc(var(--space-unit) * 1.5);display:flex;pointer-events:none;transform:translateY(-50%)}.text-wrapper.sc-z-input .icons-wrapper.sc-z-input>button.icon-button.sc-z-input{padding:0;border:0;background:none;color:inherit;font:inherit;pointer-events:initial}.text-wrapper.sc-z-input .icons-wrapper.sc-z-input>button.icon-button.sc-z-input+button.icon-button.sc-z-input{margin-left:calc(var(--space-unit) * 0.5)}.text-wrapper.sc-z-input .icons-wrapper.sc-z-input>button.icon-button.hidden.sc-z-input{display:none}.text-wrapper.sc-z-input .icons-wrapper.sc-z-input>button.icon-button.reset-icon.sc-z-input,.text-wrapper.sc-z-input .icons-wrapper.sc-z-input>button.icon-button.toggle-password-icon.sc-z-input{cursor:pointer}.text-wrapper.sc-z-input .icons-wrapper.sc-z-input>button.icon-button.sc-z-input>z-icon.sc-z-input{--z-icon-width:18px;--z-icon-height:18px;display:block}.text-wrapper.sc-z-input .icons-wrapper.sc-z-input>button.icon-button.sc-z-input>z-icon.small.sc-z-input,.text-wrapper.sc-z-input .icons-wrapper.sc-z-input>button.icon-button.sc-z-input>z-icon.x-small.sc-z-input{--z-icon-width:16px;--z-icon-height:16px}.text-wrapper.sc-z-input>div.sc-z-input>input.sc-z-input:-webkit-autofill,.text-wrapper.sc-z-input>div.sc-z-input>input.sc-z-input:-webkit-autofill:hover,.text-wrapper.sc-z-input>div.sc-z-input>input.sc-z-input:-webkit-autofill:focus,.text-wrapper.sc-z-input>div.sc-z-input>input.sc-z-input:-webkit-autofill:active{background:var(--color-white) !important;background-clip:text !important;-webkit-transition-delay:99999s !important}.textarea-wrapper.sc-z-input{padding:calc(var(--space-unit) * 1.5);scrollbar-color:var(--color-primary01) transparent}textarea.sc-z-input::-webkit-scrollbar{width:10px;background:linear-gradient(to right, transparent 0 3px, var(--gray200) 3px 7px, transparent 7px 10px);border-radius:var(--border-radius)}textarea.sc-z-input::-webkit-scrollbar-track{background-color:transparent}textarea.sc-z-input::-webkit-scrollbar-thumb{width:10px;background-color:var(--color-primary01);border-radius:var(--border-radius)}textarea.sc-z-input::-webkit-scrollbar-thumb:hover{background-color:var(--color-hover-primary)}textarea.sc-z-input{width:100%;min-height:132px;padding:0;border:none;margin:0;resize:none}.radio-wrapper.sc-z-input,.checkbox-wrapper.sc-z-input{position:relative;display:inline-flex;flex-direction:row;align-items:center;color:var(--color-text01);fill:var(--color-primary01);font-family:var(--font-family-sans)}.radio-wrapper.sc-z-input:hover,.checkbox-wrapper.sc-z-input:hover{color:var(--color-hover-primary);fill:currentcolor}.radio-wrapper.sc-z-input>input.sc-z-input,.checkbox-wrapper.sc-z-input>input.sc-z-input{position:absolute;z-index:-1;opacity:0;pointer-events:none}.radio-wrapper.sc-z-input .radio-label.sc-z-input,.checkbox-wrapper.sc-z-input .checkbox-label.sc-z-input{display:inline-flex;align-items:center;margin:0;color:inherit;font-family:inherit;font-size:inherit;font-weight:inherit;line-height:1;text-transform:inherit}.radio-wrapper.sc-z-input input.sc-z-input:not(:disabled)+.radio-label.sc-z-input,.checkbox-wrapper.sc-z-input input.sc-z-input:not(:disabled)+.checkbox-label.sc-z-input{cursor:pointer}.radio-wrapper.sc-z-input .radio-label.sc-z-input z-icon.sc-z-input,.checkbox-wrapper.sc-z-input .checkbox-label.sc-z-input z-icon.sc-z-input{cursor:pointer;fill:inherit}[size=\"small\"].sc-z-input-h .radio-wrapper.sc-z-input .radio-label.sc-z-input z-icon.sc-z-input,[size=\"small\"].sc-z-input-h .checkbox-wrapper.sc-z-input .checkbox-label.sc-z-input z-icon.sc-z-input{--z-icon-width:16px;--z-icon-height:16px}[size=\"small\"].sc-z-input-h .radio-wrapper.sc-z-input .radio-label.sc-z-input,[size=\"small\"].sc-z-input-h .checkbox-wrapper.sc-z-input .checkbox-label.sc-z-input{font-size:var(--font-size-2)}[size=\"x-small\"].sc-z-input-h .radio-wrapper.sc-z-input .radio-label.sc-z-input z-icon.sc-z-input,[size=\"x-small\"].sc-z-input-h .checkbox-wrapper.sc-z-input .checkbox-label.sc-z-input z-icon.sc-z-input{--z-icon-width:14px;--z-icon-height:14px}[size=\"x-small\"].sc-z-input-h .radio-wrapper.sc-z-input .radio-label.sc-z-input,[size=\"x-small\"].sc-z-input-h .checkbox-wrapper.sc-z-input .checkbox-label.sc-z-input{font-size:var(--font-size-1)}.radio-wrapper.sc-z-input .radio-label.after.sc-z-input,.checkbox-wrapper.sc-z-input .checkbox-label.after.sc-z-input{flex-direction:row}.radio-wrapper.sc-z-input .radio-label.before.sc-z-input,.checkbox-wrapper.sc-z-input .checkbox-label.before.sc-z-input{flex-direction:row-reverse}.radio-wrapper.sc-z-input .radio-label.after.sc-z-input>span.sc-z-input,.checkbox-wrapper.sc-z-input .checkbox-label.after.sc-z-input>span.sc-z-input{margin-left:var(--space-unit)}.radio-wrapper.sc-z-input .radio-label.before.sc-z-input>span.sc-z-input,.checkbox-wrapper.sc-z-input .checkbox-label.before.sc-z-input>span.sc-z-input{margin-right:var(--space-unit)}[size=\"small\"].sc-z-input-h .radio-wrapper.sc-z-input .radio-label.after.sc-z-input>span.sc-z-input,[size=\"small\"].sc-z-input-h .checkbox-wrapper.sc-z-input .checkbox-label.after.sc-z-input>span.sc-z-input,[size=\"x-small\"].sc-z-input-h .radio-wrapper.sc-z-input .radio-label.after.sc-z-input>span.sc-z-input,[size=\"x-small\"].sc-z-input-h .checkbox-wrapper.sc-z-input .checkbox-label.after.sc-z-input>span.sc-z-input{margin-left:calc(var(--space-unit) * 0.5)}[size=\"small\"].sc-z-input-h .radio-wrapper.sc-z-input .radio-label.before.sc-z-input>span.sc-z-input,[size=\"small\"].sc-z-input-h .checkbox-wrapper.sc-z-input .checkbox-label.before.sc-z-input>span.sc-z-input,[size=\"x-small\"].sc-z-input-h .radio-wrapper.sc-z-input .radio-label.before.sc-z-input>span.sc-z-input,[size=\"x-small\"].sc-z-input-h .checkbox-wrapper.sc-z-input .checkbox-label.before.sc-z-input>span.sc-z-input{margin-right:calc(var(--space-unit) * 0.5)}.radio-wrapper.sc-z-input>input.sc-z-input:focus:focus-visible+.radio-label.sc-z-input>z-icon.sc-z-input,.checkbox-wrapper.sc-z-input>input.sc-z-input:focus:focus-visible+.checkbox-label.sc-z-input>z-icon.sc-z-input{border-radius:var(--border-radius-small);box-shadow:var(--shadow-focus-primary)}.radio-wrapper.sc-z-input>input.sc-z-input:disabled+.radio-label.sc-z-input,.checkbox-wrapper.sc-z-input>input.sc-z-input:disabled+.checkbox-label.sc-z-input{color:var(--color-disabled02)}.radio-wrapper.sc-z-input>input.sc-z-input:disabled+.radio-label.sc-z-input>z-icon.sc-z-input,.checkbox-wrapper.sc-z-input>input.sc-z-input:disabled+.checkbox-label.sc-z-input>z-icon.sc-z-input{cursor:default;fill:var(--color-disabled01)}";
|
|
729
|
+
|
|
730
|
+
const ZInput = class {
|
|
731
|
+
constructor(hostRef) {
|
|
732
|
+
index.registerInstance(this, hostRef);
|
|
733
|
+
this.inputChange = index.createEvent(this, "inputChange", 7);
|
|
734
|
+
this.startTyping = index.createEvent(this, "startTyping", 7);
|
|
735
|
+
this.stopTyping = index.createEvent(this, "stopTyping", 7);
|
|
736
|
+
this.inputCheck = index.createEvent(this, "inputCheck", 7);
|
|
737
|
+
/** the id of the input element */
|
|
738
|
+
this.htmlid = `id-${utils$1.randomId()}`;
|
|
739
|
+
/** the input aria-label */
|
|
740
|
+
this.ariaLabel = "";
|
|
741
|
+
/** the input is disabled */
|
|
742
|
+
this.disabled = false;
|
|
743
|
+
/** the input is readonly */
|
|
744
|
+
this.readonly = false;
|
|
745
|
+
/** the input is required (optional): available for text, password, number, email, textarea, checkbox */
|
|
746
|
+
this.required = false;
|
|
747
|
+
/** checked: available for checkbox, radio */
|
|
748
|
+
this.checked = false;
|
|
749
|
+
/** input helper message (optional): available for text, password, number, email, textarea - if set to `false` message won't be displayed */
|
|
750
|
+
this.message = true;
|
|
751
|
+
/** the input label position: available for checkbox, radio */
|
|
752
|
+
this.labelPosition = index$1.LabelPosition.RIGHT;
|
|
753
|
+
/** render clear icon when typing (optional): available for text */
|
|
754
|
+
this.hasclearicon = true;
|
|
755
|
+
/** Available sizes: `big`, `small` and `x-small`. Defaults to `big`. */
|
|
756
|
+
this.size = index$1.ControlSize.BIG;
|
|
757
|
+
this.isTyping = false;
|
|
758
|
+
this.passwordHidden = true;
|
|
759
|
+
this.typingtimeout = 300;
|
|
760
|
+
}
|
|
761
|
+
inputCheckListener(e) {
|
|
762
|
+
const data = e.detail;
|
|
763
|
+
switch (this.type) {
|
|
764
|
+
case index$1.InputType.RADIO:
|
|
765
|
+
if (data.type === index$1.InputType.RADIO && data.name === this.name && data.id !== this.htmlid) {
|
|
766
|
+
this.checked = false;
|
|
767
|
+
}
|
|
768
|
+
break;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
/** get checked status */
|
|
772
|
+
async isChecked() {
|
|
773
|
+
switch (this.type) {
|
|
774
|
+
case index$1.InputType.CHECKBOX:
|
|
775
|
+
case index$1.InputType.RADIO:
|
|
776
|
+
return this.checked;
|
|
777
|
+
default:
|
|
778
|
+
console.warn("`isChecked` method is only available for type `checkbox` and `radio`");
|
|
779
|
+
return false;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
emitInputChange(value) {
|
|
783
|
+
if (!this.isTyping) {
|
|
784
|
+
this.emitStartTyping();
|
|
785
|
+
}
|
|
786
|
+
let validity;
|
|
787
|
+
if (this.type === index$1.InputType.TEXTAREA) {
|
|
788
|
+
validity = this.getValidity("textarea");
|
|
789
|
+
}
|
|
790
|
+
else {
|
|
791
|
+
validity = this.getValidity("input");
|
|
792
|
+
}
|
|
793
|
+
this.value = value;
|
|
794
|
+
this.inputChange.emit({ value, validity });
|
|
795
|
+
clearTimeout(this.timer);
|
|
796
|
+
this.timer = setTimeout(() => {
|
|
797
|
+
this.emitStopTyping(this.value, validity);
|
|
798
|
+
}, this.typingtimeout);
|
|
799
|
+
}
|
|
800
|
+
emitStartTyping() {
|
|
801
|
+
this.isTyping = true;
|
|
802
|
+
this.startTyping.emit();
|
|
803
|
+
}
|
|
804
|
+
emitStopTyping(value, validity) {
|
|
805
|
+
this.isTyping = false;
|
|
806
|
+
this.stopTyping.emit({
|
|
807
|
+
value: value,
|
|
808
|
+
validity: validity,
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
emitInputCheck(checked) {
|
|
812
|
+
this.inputCheck.emit({
|
|
813
|
+
id: this.htmlid,
|
|
814
|
+
checked: checked,
|
|
815
|
+
type: this.type,
|
|
816
|
+
name: this.name,
|
|
817
|
+
value: this.value,
|
|
818
|
+
validity: this.getValidity("input"),
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
getValidity(type) {
|
|
822
|
+
const input = this.hostElement.querySelector(type);
|
|
823
|
+
return input.validity;
|
|
824
|
+
}
|
|
825
|
+
/* START text/password/email/number */
|
|
826
|
+
getTextAttributes() {
|
|
827
|
+
return {
|
|
828
|
+
id: this.htmlid,
|
|
829
|
+
name: this.name,
|
|
830
|
+
placeholder: this.placeholder,
|
|
831
|
+
value: this.value,
|
|
832
|
+
disabled: this.disabled,
|
|
833
|
+
readonly: this.readonly,
|
|
834
|
+
required: this.required,
|
|
835
|
+
title: this.htmltitle,
|
|
836
|
+
class: {
|
|
837
|
+
[`input-${this.status}`]: !!this.status,
|
|
838
|
+
filled: !!this.value,
|
|
839
|
+
},
|
|
840
|
+
autocomplete: this.autocomplete,
|
|
841
|
+
onInput: (e) => this.emitInputChange(e.target.value),
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
getNumberAttributes(type) {
|
|
845
|
+
if (type != index$1.InputType.NUMBER) {
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
return {
|
|
849
|
+
min: this.min,
|
|
850
|
+
max: this.max,
|
|
851
|
+
step: this.step,
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
getPatternAttribute(type) {
|
|
855
|
+
if (type != index$1.InputType.PASSWORD &&
|
|
856
|
+
type != index$1.InputType.TEXT &&
|
|
857
|
+
type != index$1.InputType.TEL &&
|
|
858
|
+
type != index$1.InputType.SEARCH &&
|
|
859
|
+
type != index$1.InputType.URL &&
|
|
860
|
+
type != index$1.InputType.EMAIL) {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
return {
|
|
864
|
+
pattern: this.pattern,
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
renderInputText(type = index$1.InputType.TEXT) {
|
|
868
|
+
const ariaLabel = this.ariaLabel ? { "aria-label": this.ariaLabel } : {};
|
|
869
|
+
const attr = Object.assign(Object.assign(Object.assign(Object.assign({}, this.getTextAttributes()), this.getNumberAttributes(type)), this.getPatternAttribute(type)), ariaLabel);
|
|
870
|
+
if (this.icon || type === index$1.InputType.PASSWORD) {
|
|
871
|
+
Object.assign(attr.class, { "has-icon": true });
|
|
872
|
+
}
|
|
873
|
+
if (this.hasclearicon && type != index$1.InputType.NUMBER) {
|
|
874
|
+
Object.assign(attr.class, { "has-clear-icon": true });
|
|
875
|
+
}
|
|
876
|
+
return (index.h("div", { class: "text-wrapper" }, this.renderLabel(), index.h("div", null, index.h("input", Object.assign({ type: type === index$1.InputType.PASSWORD && !this.passwordHidden ? index$1.InputType.TEXT : type }, attr, { ref: (el) => (this.inputRef = el) })), this.renderIcons()), this.renderMessage()));
|
|
877
|
+
}
|
|
878
|
+
renderLabel() {
|
|
879
|
+
if (!this.label) {
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
return (index.h("label", { class: "input-label body-5-sb", id: `${this.htmlid}_label`, htmlFor: this.htmlid }, this.label));
|
|
883
|
+
}
|
|
884
|
+
renderIcons() {
|
|
885
|
+
return (index.h("span", { class: "icons-wrapper" }, this.renderResetIcon(), this.renderIcon()));
|
|
886
|
+
}
|
|
887
|
+
renderIcon() {
|
|
888
|
+
if (this.type === index$1.InputType.PASSWORD) {
|
|
889
|
+
return this.renderShowHidePassword();
|
|
890
|
+
}
|
|
891
|
+
if (!this.icon) {
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
return (index.h("button", { type: "button", class: "icon-button input-icon", tabIndex: -1 }, index.h("z-icon", { name: this.icon, class: this.size })));
|
|
895
|
+
}
|
|
896
|
+
renderResetIcon() {
|
|
897
|
+
let hidden = false;
|
|
898
|
+
if (!this.hasclearicon || !this.value || this.disabled || this.readonly || this.type == index$1.InputType.NUMBER) {
|
|
899
|
+
hidden = true;
|
|
900
|
+
}
|
|
901
|
+
return (index.h("button", { type: "button", class: `icon-button reset-icon ${hidden ? "hidden" : ""}`, "aria-label": "cancella il contenuto dell'input", onClick: () => {
|
|
902
|
+
this.inputRef.value = "";
|
|
903
|
+
this.emitInputChange("");
|
|
904
|
+
} }, index.h("z-icon", { name: "multiply", class: this.size })));
|
|
905
|
+
}
|
|
906
|
+
renderShowHidePassword() {
|
|
907
|
+
return (index.h("button", { type: "button", class: "icon-button toggle-password-icon", disabled: this.disabled, "aria-label": this.passwordHidden ? "mostra password" : "nascondi password", onClick: () => (this.passwordHidden = !this.passwordHidden) }, index.h("z-icon", { name: this.passwordHidden ? "view-filled" : "view-off-filled", class: this.size })));
|
|
908
|
+
}
|
|
909
|
+
renderMessage() {
|
|
910
|
+
if (utils$1.boolean(this.message) === false) {
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
return (index.h("z-input-message", { message: utils$1.boolean(this.message) === true ? undefined : this.message, status: this.status, class: this.size }));
|
|
914
|
+
}
|
|
915
|
+
/* END text/password/email/number */
|
|
916
|
+
/* START textarea */
|
|
917
|
+
renderTextarea() {
|
|
918
|
+
const attributes = this.getTextAttributes();
|
|
919
|
+
const ariaLabel = this.ariaLabel ? { "aria-label": this.ariaLabel } : {};
|
|
920
|
+
return (index.h("div", { class: "text-wrapper" }, this.renderLabel(), index.h("div", { class: Object.assign(Object.assign({}, attributes.class), { "textarea-wrapper": true, "readonly": attributes.readonly }) }, index.h("textarea", Object.assign({}, attributes, ariaLabel))), this.renderMessage()));
|
|
921
|
+
}
|
|
922
|
+
/* END textarea */
|
|
923
|
+
handleCheck(ev) {
|
|
924
|
+
this.checked = ev.target.checked;
|
|
925
|
+
this.emitInputCheck(this.checked);
|
|
926
|
+
}
|
|
927
|
+
/* START checkbox */
|
|
928
|
+
renderCheckbox() {
|
|
929
|
+
return (index.h("div", { class: "checkbox-wrapper" }, index.h("input", { id: this.htmlid, type: "checkbox", name: this.name, checked: this.checked, disabled: this.disabled, readonly: this.readonly, required: this.required, onChange: this.handleCheck.bind(this), value: this.value }), index.h("label", { htmlFor: this.htmlid, class: {
|
|
930
|
+
"checkbox-label": true,
|
|
931
|
+
"after": this.labelPosition === index$1.LabelPosition.RIGHT,
|
|
932
|
+
"before": this.labelPosition === index$1.LabelPosition.LEFT,
|
|
933
|
+
} }, index.h("z-icon", { name: this.checked ? "checkbox-checked" : "checkbox", "aria-hidden": "true", class: this.size }), this.label && index.h("span", { innerHTML: this.label }))));
|
|
934
|
+
}
|
|
935
|
+
/* END checkbox */
|
|
936
|
+
/* START radio */
|
|
937
|
+
renderRadio() {
|
|
938
|
+
return (index.h("div", { class: "radio-wrapper" }, index.h("input", { id: this.htmlid, type: "radio", name: this.name, checked: this.checked, disabled: this.disabled, readonly: this.readonly, onChange: this.handleCheck.bind(this), value: this.value }), index.h("label", { htmlFor: this.htmlid, class: {
|
|
939
|
+
"radio-label": true,
|
|
940
|
+
"after": this.labelPosition === index$1.LabelPosition.RIGHT,
|
|
941
|
+
"before": this.labelPosition === index$1.LabelPosition.LEFT,
|
|
942
|
+
} }, index.h("z-icon", { name: this.checked ? "radio-button-checked" : "radio-button", "aria-hidden": "true", class: this.size }), this.label && index.h("span", { innerHTML: this.label }))));
|
|
943
|
+
}
|
|
944
|
+
/* END radio */
|
|
945
|
+
render() {
|
|
946
|
+
let input;
|
|
947
|
+
switch (this.type) {
|
|
948
|
+
case index$1.InputType.TEXTAREA:
|
|
949
|
+
input = this.renderTextarea();
|
|
950
|
+
break;
|
|
951
|
+
case index$1.InputType.CHECKBOX:
|
|
952
|
+
input = this.renderCheckbox();
|
|
953
|
+
break;
|
|
954
|
+
case index$1.InputType.RADIO:
|
|
955
|
+
input = this.renderRadio();
|
|
956
|
+
break;
|
|
957
|
+
default:
|
|
958
|
+
input = this.renderInputText(this.type);
|
|
959
|
+
}
|
|
960
|
+
return index.h(index.Host, null, input);
|
|
961
|
+
}
|
|
962
|
+
get hostElement() { return index.getElement(this); }
|
|
963
|
+
};
|
|
964
|
+
ZInput.style = stylesCss$8;
|
|
965
|
+
|
|
966
|
+
const stylesCss$7 = ":host{display:flex;min-height:calc(var(--space-unit) * 2.5);align-items:start;margin-top:var(--space-unit);color:var(--color-text05);fill:currentcolor;font-family:var(--font-family-sans);font-size:var(--font-size-2);letter-spacing:0.16px}:host(.small),:host(.x-small){margin-top:calc(var(--space-unit) * 0.5);font-size:var(--font-size-1)}:host([status=\"success\"]){color:var(--color-text-success)}:host([status=\"error\"]){color:var(--color-text-error)}:host([status=\"warning\"]){color:var(--color-warning02)}:host(:focus){outline:none}:host>z-icon{--z-icon-width:calc(var(--space-unit) * 2);--z-icon-height:calc(var(--space-unit) * 2);--z-icon-right-margin:var(--space-unit);margin-top:calc(var(--space-unit) * 0.25)}:host(.small)>z-icon,:host(.x-small)>z-icon{--z-icon-width:14px;--z-icon-height:14px;--z-icon-right-margin:calc(var(--space-unit) * 0.5)}";
|
|
967
|
+
|
|
968
|
+
const ZInputMessage = class {
|
|
969
|
+
constructor(hostRef) {
|
|
970
|
+
index.registerInstance(this, hostRef);
|
|
971
|
+
this.statusIcons = {
|
|
972
|
+
success: "checkmark-circle",
|
|
973
|
+
error: "multiply-circled",
|
|
974
|
+
warning: "exclamation-circle",
|
|
975
|
+
};
|
|
976
|
+
this.statusRole = {};
|
|
977
|
+
}
|
|
978
|
+
onMessageChange() {
|
|
979
|
+
this.statusRole = this.message && this.status ? { role: "alert" } : {};
|
|
980
|
+
}
|
|
981
|
+
componentWillLoad() {
|
|
982
|
+
this.onMessageChange();
|
|
983
|
+
}
|
|
984
|
+
render() {
|
|
985
|
+
return (index.h(index.Host, Object.assign({}, this.statusRole, { "aria-label": this.message }), this.statusIcons[this.status] && this.message && index.h("z-icon", { name: this.statusIcons[this.status] }), index.h("span", { innerHTML: this.message })));
|
|
986
|
+
}
|
|
987
|
+
static get watchers() { return {
|
|
988
|
+
"message": ["onMessageChange"],
|
|
989
|
+
"status": ["onMessageChange"]
|
|
990
|
+
}; }
|
|
991
|
+
};
|
|
992
|
+
ZInputMessage.style = stylesCss$7;
|
|
993
|
+
|
|
994
|
+
const stylesCss$6 = ":host{display:flex;flex-direction:column;font-family:var(--font-family-sans);font-weight:var(--font-rg)}";
|
|
995
|
+
|
|
996
|
+
const ZList = class {
|
|
997
|
+
constructor(hostRef) {
|
|
998
|
+
index.registerInstance(this, hostRef);
|
|
999
|
+
/**
|
|
1000
|
+
* [optional] Sets size of inside elements.
|
|
1001
|
+
*/
|
|
1002
|
+
this.size = index$1.ListSize.MEDIUM;
|
|
1003
|
+
/**
|
|
1004
|
+
* [optional] type of the list marker for each element
|
|
1005
|
+
*/
|
|
1006
|
+
this.listType = index$1.ListType.NONE;
|
|
1007
|
+
}
|
|
1008
|
+
setChildrenSizeType() {
|
|
1009
|
+
const children = this.host.children;
|
|
1010
|
+
for (let i = 0; i < children.length; i++) {
|
|
1011
|
+
children[i].setAttribute("size", this.size);
|
|
1012
|
+
children[i].setAttribute("list-type", this.listType);
|
|
1013
|
+
children[i].setAttribute("list-element-position", (i + 1).toString());
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
componentDidLoad() {
|
|
1017
|
+
this.setChildrenSizeType();
|
|
1018
|
+
}
|
|
1019
|
+
render() {
|
|
1020
|
+
return (index.h(index.Host, { role: "list" }, index.h("slot", null)));
|
|
1021
|
+
}
|
|
1022
|
+
get host() { return index.getElement(this); }
|
|
1023
|
+
};
|
|
1024
|
+
ZList.style = stylesCss$6;
|
|
1025
|
+
|
|
1026
|
+
const stylesCss$5 = ":host{outline:none}:host>.container,:host>.container-contextual-menu{--background-color-list-element:var(--bg-white);--background-hover-color-list-element:var(--color-surface02);--background-active-color-list-element:var(--color-surface02);display:flex;box-sizing:border-box;flex-direction:column;justify-content:center;font-family:var(--font-family-sans);font-weight:var(--font-rg);outline:none}:host([size=\"small\"])>.container{min-height:calc(var(--space-unit) * 4);padding:calc(var(--space-unit) / 2) 0}:host([size=\"medium\"])>.container{min-height:calc(var(--space-unit) * 5);padding:var(--space-unit) 0}:host([size=\"large\"])>.container{min-height:calc(var(--space-unit) * 7);padding:calc(var(--space-unit) * 2) 0}:host([size=\"x-large\"])>.container{min-height:calc(var(--space-unit) * 9);padding:calc(var(--space-unit) * 3) 0}:host([expandable])>.container,:host([expandable])>.container-contextual-menu,:host([clickable])>.container,:host([clickable])>.container-contextual-menu{cursor:pointer}:host([expandable]:hover)>.container,:host([expandable]:hover)>.container-contextual-menu,:host([clickable]:hover)>.container,:host([clickable]:hover)>.container-contextual-menu{background-color:var(--background-hover-color-list-element)}:host([expandable]:focus:focus-visible)>.container,:host([expandable]:focus:focus-visible)>.container-contextual-menu,:host([clickable]:focus:focus-visible)>.container,:host([clickable]:focus:focus-visible)>.container-contextual-menu{box-shadow:var(--shadow-focus-primary)}:host([clickable]:not([expandable]))>.container.clicked,:host([clickable]:not([expandable]))>.container-contextual-menu.clicked{box-shadow:var(--shadow-focus-primary)}:host([expandable]:active)>.container,:host([expandable]:active)>.container-contextual-menu,:host([clickable]:active)>.container,:host([clickable]:active)>.container-contextual-menu{background-color:var(--background-active-color-list-element)}:host([align-button=\"left\"][expandable])>.container>.z-list-element-container,:host([align-button=\"left\"][expandable])>.container-contextual-menu>.z-list-element-container{display:flex}:host([align-button=\"right\"][expandable])>.container>.z-list-element-container,:host([align-button=\"right\"][expandable])>.container-contextual-menu>.z-list-element-container{display:flex;flex-direction:row-reverse;justify-content:space-between}:host([align-button=\"left\"][expandable])>.container>.z-list-element-container>z-icon,:host([align-button=\"left\"][expandable])>.container-contextual-menu>.z-list-element-container>z-icon{margin-right:var(--space-unit)}:host([align-button=\"right\"][expandable])>.container>.z-list-element-container>z-icon,:host([align-button=\"right\"][expandable])>.container-contextual-menu>.z-list-element-container>z-icon{margin-left:var(--space-unit)}:host>.container>.z-list-element-inner-container,:host>.container-contextual-menu>.z-list-element-inner-container{display:none}:host>.container>.z-list-element-inner-container.expanded,:host>.container-contextual-menu>.z-list-element-inner-container.expanded{display:block}:host([clickable]:hover)>.container-contextual-menu{background-color:var(--color-surface03)}.container-contextual-menu:focus-visible{box-shadow:var(--shadow-focus-primary);outline:none}.z-list-content-container{display:flex;align-items:center}";
|
|
1027
|
+
|
|
1028
|
+
const ZListElement = class {
|
|
1029
|
+
/**
|
|
1030
|
+
* Constructor.
|
|
1031
|
+
*/
|
|
1032
|
+
constructor(hostRef) {
|
|
1033
|
+
index.registerInstance(this, hostRef);
|
|
1034
|
+
this.accessibleFocus = index.createEvent(this, "accessibleFocus", 7);
|
|
1035
|
+
this.clickItem = index.createEvent(this, "clickItem", 7);
|
|
1036
|
+
/**
|
|
1037
|
+
* [optional] Align expandable button left or right.
|
|
1038
|
+
*/
|
|
1039
|
+
this.alignButton = index$1.ExpandableListButtonAlign.LEFT;
|
|
1040
|
+
/**
|
|
1041
|
+
* [optional] Sets element clickable.
|
|
1042
|
+
*/
|
|
1043
|
+
this.clickable = false;
|
|
1044
|
+
/**
|
|
1045
|
+
* [optional] Sets the divider color.
|
|
1046
|
+
*/
|
|
1047
|
+
this.dividerColor = "color-surface03";
|
|
1048
|
+
/**
|
|
1049
|
+
* [optional] Sets the position where to insert the divider.
|
|
1050
|
+
*/
|
|
1051
|
+
this.dividerType = index$1.ListDividerType.NONE;
|
|
1052
|
+
/**
|
|
1053
|
+
* [optional] Sets the divider size.
|
|
1054
|
+
*/
|
|
1055
|
+
this.dividerSize = index$1.DividerSize.SMALL;
|
|
1056
|
+
/**
|
|
1057
|
+
* [optional] Sets element as expandable.
|
|
1058
|
+
*/
|
|
1059
|
+
this.expandable = false;
|
|
1060
|
+
/**
|
|
1061
|
+
* [optional] Sets expandable style to element.
|
|
1062
|
+
*/
|
|
1063
|
+
this.expandableStyle = index$1.ExpandableListStyle.ACCORDION;
|
|
1064
|
+
/**
|
|
1065
|
+
* [optional] Sets size of inside elements.
|
|
1066
|
+
*/
|
|
1067
|
+
this.size = index$1.ListSize.MEDIUM;
|
|
1068
|
+
/**
|
|
1069
|
+
* [optional] Sets text color of the element.
|
|
1070
|
+
*/
|
|
1071
|
+
this.color = "none";
|
|
1072
|
+
/**
|
|
1073
|
+
* [optional] Sets disabled style of the element.
|
|
1074
|
+
*/
|
|
1075
|
+
this.disabled = false;
|
|
1076
|
+
/**
|
|
1077
|
+
* [optional] If is used in ZContextualMenu component
|
|
1078
|
+
*/
|
|
1079
|
+
this.isContextualMenu = false;
|
|
1080
|
+
/**
|
|
1081
|
+
* [optional] position of the list element inside the list or the group
|
|
1082
|
+
*/
|
|
1083
|
+
this.listElementPosition = "0";
|
|
1084
|
+
/**
|
|
1085
|
+
* [optional] type of the list marker for each element
|
|
1086
|
+
*/
|
|
1087
|
+
this.listType = index$1.ListType.NONE;
|
|
1088
|
+
this.showInnerContent = false;
|
|
1089
|
+
this.openElementConfig = {
|
|
1090
|
+
accordion: {
|
|
1091
|
+
open: "minus-circled",
|
|
1092
|
+
close: "plus-circled",
|
|
1093
|
+
},
|
|
1094
|
+
menu: {
|
|
1095
|
+
open: "chevron-up",
|
|
1096
|
+
close: "chevron-down",
|
|
1097
|
+
},
|
|
1098
|
+
};
|
|
1099
|
+
this.handleClick = this.handleClick.bind(this);
|
|
1100
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
1101
|
+
}
|
|
1102
|
+
accessibleFocusHandler(e) {
|
|
1103
|
+
if (this.listElementId === e.detail) {
|
|
1104
|
+
const toFocus = this.host.shadowRoot.getElementById(`z-list-element-id-${e.detail}`);
|
|
1105
|
+
toFocus.focus();
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Handler for click on element. If element is expandable, change state.
|
|
1110
|
+
* @returns void
|
|
1111
|
+
*/
|
|
1112
|
+
handleClick() {
|
|
1113
|
+
this.clickItem.emit(this.listElementId);
|
|
1114
|
+
if (!this.expandable) {
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
this.showInnerContent = !this.showInnerContent;
|
|
1118
|
+
}
|
|
1119
|
+
calculateClass() {
|
|
1120
|
+
if (this.isContextualMenu) {
|
|
1121
|
+
return "container-contextual-menu";
|
|
1122
|
+
}
|
|
1123
|
+
return "container";
|
|
1124
|
+
}
|
|
1125
|
+
handleKeyDown(event) {
|
|
1126
|
+
const expandByKey = event.code === index$1.KeyboardCode.ENTER;
|
|
1127
|
+
switch (event.code) {
|
|
1128
|
+
case index$1.KeyboardCode.ARROW_DOWN:
|
|
1129
|
+
event.preventDefault();
|
|
1130
|
+
this.accessibleFocus.emit(this.listElementId + 1);
|
|
1131
|
+
break;
|
|
1132
|
+
case index$1.KeyboardCode.ARROW_UP:
|
|
1133
|
+
event.preventDefault();
|
|
1134
|
+
this.accessibleFocus.emit(this.listElementId - 1);
|
|
1135
|
+
break;
|
|
1136
|
+
case index$1.KeyboardCode.ENTER:
|
|
1137
|
+
event.preventDefault();
|
|
1138
|
+
this.clickItem.emit(this.listElementId);
|
|
1139
|
+
break;
|
|
1140
|
+
}
|
|
1141
|
+
if (!this.expandable || !expandByKey) {
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
this.showInnerContent = !this.showInnerContent;
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* Renders button to expand element.
|
|
1148
|
+
* @returns expadable button
|
|
1149
|
+
*/
|
|
1150
|
+
renderExpandableButton() {
|
|
1151
|
+
if (!this.expandable) {
|
|
1152
|
+
return null;
|
|
1153
|
+
}
|
|
1154
|
+
return (index.h("z-icon", { name: this.showInnerContent
|
|
1155
|
+
? this.openElementConfig[this.expandableStyle].open
|
|
1156
|
+
: this.openElementConfig[this.expandableStyle].close }));
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Renders expanded content if element is expandable.
|
|
1160
|
+
* @returns expanded content
|
|
1161
|
+
*/
|
|
1162
|
+
renderExpandedContent() {
|
|
1163
|
+
if (!this.expandable) {
|
|
1164
|
+
return null;
|
|
1165
|
+
}
|
|
1166
|
+
return (index.h("div", { class: {
|
|
1167
|
+
"z-list-element-inner-container": true,
|
|
1168
|
+
"expanded": this.showInnerContent,
|
|
1169
|
+
} }, index.h("slot", { name: "inner-content" })));
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Renders content of the z-list-element
|
|
1173
|
+
* @returns list content
|
|
1174
|
+
*/
|
|
1175
|
+
renderContent() {
|
|
1176
|
+
if (this.listType === index$1.ListType.NONE) {
|
|
1177
|
+
return index.h("slot", null);
|
|
1178
|
+
}
|
|
1179
|
+
if (this.listType === index$1.ListType.ORDERED) {
|
|
1180
|
+
return (index.h("div", { class: "z-list-content-container" }, index.h("div", null, this.listElementPosition, ".\u2003"), index.h("slot", null)));
|
|
1181
|
+
}
|
|
1182
|
+
if (this.listType === index$1.ListType.UNORDERED) {
|
|
1183
|
+
return (index.h("div", { class: "z-list-content-container" }, index.h("span", null, "\u2022\u2003"), index.h("slot", null)));
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
render() {
|
|
1187
|
+
return (index.h(index.Host, { role: "listitem", "aria-expanded": this.expandable ? this.showInnerContent : null, onClick: this.handleClick, onKeyDown: this.handleKeyDown, clickable: this.clickable && !this.disabled, tabIndex: !this.isContextualMenu ? "0" : null }, index.h("div", { class: `${this.calculateClass()}`, style: { color: `var(--${this.color})` }, tabindex: this.isContextualMenu ? "0" : "-1", id: `z-list-element-id-${this.listElementId}`, part: "list-item-container" }, index.h("div", { class: "z-list-element-container" }, this.renderExpandableButton(), this.renderContent()), this.renderExpandedContent()), this.dividerType === index$1.ListDividerType.ELEMENT && (index.h("z-divider", { color: this.dividerColor, size: this.dividerSize }))));
|
|
1188
|
+
}
|
|
1189
|
+
get host() { return index.getElement(this); }
|
|
1190
|
+
};
|
|
1191
|
+
ZListElement.style = stylesCss$5;
|
|
1192
|
+
|
|
1193
|
+
const stylesCss$4 = ":host{font-family:var(--font-family-sans);font-weight:var(--font-rg)}:host>.z-list-group-header-container{color:var(--gray700);font-size:var(--font-size-2);font-weight:var(--font-sb) !important;letter-spacing:0.16px;line-height:1.4}:host>.z-list-group-header-container.has-header{padding-top:var(--space-unit);padding-bottom:var(--space-unit)}:host>.z-list-group-header-container.has-header>z-divider{margin-top:var(--space-unit)}";
|
|
1194
|
+
|
|
1195
|
+
const ZListGroup = class {
|
|
1196
|
+
constructor(hostRef) {
|
|
1197
|
+
index.registerInstance(this, hostRef);
|
|
1198
|
+
/**
|
|
1199
|
+
* [optional] Sets size of inside elements.
|
|
1200
|
+
*/
|
|
1201
|
+
this.size = index$1.ListSize.MEDIUM;
|
|
1202
|
+
/**
|
|
1203
|
+
* [optional] Sets the position where to insert the divider.
|
|
1204
|
+
*/
|
|
1205
|
+
this.dividerType = index$1.ListDividerType.NONE;
|
|
1206
|
+
/**
|
|
1207
|
+
* [optional] Sets the divider size.
|
|
1208
|
+
*/
|
|
1209
|
+
this.dividerSize = index$1.DividerSize.SMALL;
|
|
1210
|
+
/**
|
|
1211
|
+
* [optional] Sets the divider color.
|
|
1212
|
+
*/
|
|
1213
|
+
this.dividerColor = "gray200";
|
|
1214
|
+
/**
|
|
1215
|
+
* [optional] type of the list marker for each element
|
|
1216
|
+
*/
|
|
1217
|
+
this.listType = index$1.ListType.NONE;
|
|
1218
|
+
}
|
|
1219
|
+
componentDidLoad() {
|
|
1220
|
+
const children = this.host.children;
|
|
1221
|
+
for (let i = 0; i < children.length; i++) {
|
|
1222
|
+
if (children.length - 1 > i) {
|
|
1223
|
+
children[i].setAttribute("divider-type", this.dividerType);
|
|
1224
|
+
children[i].setAttribute("divider-size", this.dividerSize);
|
|
1225
|
+
children[i].setAttribute("divider-color", this.dividerColor);
|
|
1226
|
+
}
|
|
1227
|
+
children[i].setAttribute("size", this.size);
|
|
1228
|
+
children[i].setAttribute("list-type", this.listType);
|
|
1229
|
+
children[i].setAttribute("list-element-position", i.toString());
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
componentWillLoad() {
|
|
1233
|
+
this.hasHeader = !!this.host.querySelector('[slot="header-title"]');
|
|
1234
|
+
}
|
|
1235
|
+
render() {
|
|
1236
|
+
return (index.h(index.Host, { role: "group" }, index.h("div", { class: {
|
|
1237
|
+
"z-list-group-header-container": true,
|
|
1238
|
+
"has-header": this.hasHeader,
|
|
1239
|
+
} }, index.h("slot", { name: "header-title" }), this.dividerType === index$1.ListDividerType.HEADER && (index.h("z-divider", { color: this.dividerColor, size: this.dividerSize }))), index.h("slot", null)));
|
|
1240
|
+
}
|
|
1241
|
+
get host() { return index.getElement(this); }
|
|
1242
|
+
};
|
|
1243
|
+
ZListGroup.style = stylesCss$4;
|
|
1244
|
+
|
|
1245
|
+
// nb. This is for IE10 and lower _only_.
|
|
1246
|
+
var supportCustomEvent = window.CustomEvent;
|
|
1247
|
+
if (!supportCustomEvent || typeof supportCustomEvent === 'object') {
|
|
1248
|
+
supportCustomEvent = function CustomEvent(event, x) {
|
|
1249
|
+
x = x || {};
|
|
1250
|
+
var ev = document.createEvent('CustomEvent');
|
|
1251
|
+
ev.initCustomEvent(event, !!x.bubbles, !!x.cancelable, x.detail || null);
|
|
1252
|
+
return ev;
|
|
1253
|
+
};
|
|
1254
|
+
supportCustomEvent.prototype = window.Event.prototype;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* Dispatches the passed event to both an "on<type>" handler as well as via the
|
|
1259
|
+
* normal dispatch operation. Does not bubble.
|
|
1260
|
+
*
|
|
1261
|
+
* @param {!EventTarget} target
|
|
1262
|
+
* @param {!Event} event
|
|
1263
|
+
* @return {boolean}
|
|
1264
|
+
*/
|
|
1265
|
+
function safeDispatchEvent(target, event) {
|
|
1266
|
+
var check = 'on' + event.type.toLowerCase();
|
|
1267
|
+
if (typeof target[check] === 'function') {
|
|
1268
|
+
target[check](event);
|
|
1269
|
+
}
|
|
1270
|
+
return target.dispatchEvent(event);
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1274
|
+
* @param {Element} el to check for stacking context
|
|
1275
|
+
* @return {boolean} whether this el or its parents creates a stacking context
|
|
1276
|
+
*/
|
|
1277
|
+
function createsStackingContext(el) {
|
|
1278
|
+
while (el && el !== document.body) {
|
|
1279
|
+
var s = window.getComputedStyle(el);
|
|
1280
|
+
var invalid = function(k, ok) {
|
|
1281
|
+
return !(s[k] === undefined || s[k] === ok);
|
|
1282
|
+
};
|
|
1283
|
+
|
|
1284
|
+
if (s.opacity < 1 ||
|
|
1285
|
+
invalid('zIndex', 'auto') ||
|
|
1286
|
+
invalid('transform', 'none') ||
|
|
1287
|
+
invalid('mixBlendMode', 'normal') ||
|
|
1288
|
+
invalid('filter', 'none') ||
|
|
1289
|
+
invalid('perspective', 'none') ||
|
|
1290
|
+
s['isolation'] === 'isolate' ||
|
|
1291
|
+
s.position === 'fixed' ||
|
|
1292
|
+
s.webkitOverflowScrolling === 'touch') {
|
|
1293
|
+
return true;
|
|
1294
|
+
}
|
|
1295
|
+
el = el.parentElement;
|
|
1296
|
+
}
|
|
1297
|
+
return false;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* Finds the nearest <dialog> from the passed element.
|
|
1302
|
+
*
|
|
1303
|
+
* @param {Element} el to search from
|
|
1304
|
+
* @return {HTMLDialogElement} dialog found
|
|
1305
|
+
*/
|
|
1306
|
+
function findNearestDialog(el) {
|
|
1307
|
+
while (el) {
|
|
1308
|
+
if (el.localName === 'dialog') {
|
|
1309
|
+
return /** @type {HTMLDialogElement} */ (el);
|
|
1310
|
+
}
|
|
1311
|
+
if (el.parentElement) {
|
|
1312
|
+
el = el.parentElement;
|
|
1313
|
+
} else if (el.parentNode) {
|
|
1314
|
+
el = el.parentNode.host;
|
|
1315
|
+
} else {
|
|
1316
|
+
el = null;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
return null;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* Blur the specified element, as long as it's not the HTML body element.
|
|
1324
|
+
* This works around an IE9/10 bug - blurring the body causes Windows to
|
|
1325
|
+
* blur the whole application.
|
|
1326
|
+
*
|
|
1327
|
+
* @param {Element} el to blur
|
|
1328
|
+
*/
|
|
1329
|
+
function safeBlur(el) {
|
|
1330
|
+
// Find the actual focused element when the active element is inside a shadow root
|
|
1331
|
+
while (el && el.shadowRoot && el.shadowRoot.activeElement) {
|
|
1332
|
+
el = el.shadowRoot.activeElement;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
if (el && el.blur && el !== document.body) {
|
|
1336
|
+
el.blur();
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* @param {!NodeList} nodeList to search
|
|
1342
|
+
* @param {Node} node to find
|
|
1343
|
+
* @return {boolean} whether node is inside nodeList
|
|
1344
|
+
*/
|
|
1345
|
+
function inNodeList(nodeList, node) {
|
|
1346
|
+
for (var i = 0; i < nodeList.length; ++i) {
|
|
1347
|
+
if (nodeList[i] === node) {
|
|
1348
|
+
return true;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
return false;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* @param {HTMLFormElement} el to check
|
|
1356
|
+
* @return {boolean} whether this form has method="dialog"
|
|
1357
|
+
*/
|
|
1358
|
+
function isFormMethodDialog(el) {
|
|
1359
|
+
if (!el || !el.hasAttribute('method')) {
|
|
1360
|
+
return false;
|
|
1361
|
+
}
|
|
1362
|
+
return el.getAttribute('method').toLowerCase() === 'dialog';
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* @param {!DocumentFragment|!Element} hostElement
|
|
1367
|
+
* @return {?Element}
|
|
1368
|
+
*/
|
|
1369
|
+
function findFocusableElementWithin(hostElement) {
|
|
1370
|
+
// Note that this is 'any focusable area'. This list is probably not exhaustive, but the
|
|
1371
|
+
// alternative involves stepping through and trying to focus everything.
|
|
1372
|
+
var opts = ['button', 'input', 'keygen', 'select', 'textarea'];
|
|
1373
|
+
var query = opts.map(function(el) {
|
|
1374
|
+
return el + ':not([disabled])';
|
|
1375
|
+
});
|
|
1376
|
+
// TODO(samthor): tabindex values that are not numeric are not focusable.
|
|
1377
|
+
query.push('[tabindex]:not([disabled]):not([tabindex=""])'); // tabindex != "", not disabled
|
|
1378
|
+
var target = hostElement.querySelector(query.join(', '));
|
|
1379
|
+
|
|
1380
|
+
if (!target && 'attachShadow' in Element.prototype) {
|
|
1381
|
+
// If we haven't found a focusable target, see if the host element contains an element
|
|
1382
|
+
// which has a shadowRoot.
|
|
1383
|
+
// Recursively search for the first focusable item in shadow roots.
|
|
1384
|
+
var elems = hostElement.querySelectorAll('*');
|
|
1385
|
+
for (var i = 0; i < elems.length; i++) {
|
|
1386
|
+
if (elems[i].tagName && elems[i].shadowRoot) {
|
|
1387
|
+
target = findFocusableElementWithin(elems[i].shadowRoot);
|
|
1388
|
+
if (target) {
|
|
1389
|
+
break;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
return target;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* Determines if an element is attached to the DOM.
|
|
1399
|
+
* @param {Element} element to check
|
|
1400
|
+
* @return {boolean} whether the element is in DOM
|
|
1401
|
+
*/
|
|
1402
|
+
function isConnected(element) {
|
|
1403
|
+
return element.isConnected || document.body.contains(element);
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* @param {!Event} event
|
|
1408
|
+
* @return {?Element}
|
|
1409
|
+
*/
|
|
1410
|
+
function findFormSubmitter(event) {
|
|
1411
|
+
if (event.submitter) {
|
|
1412
|
+
return event.submitter;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
var form = event.target;
|
|
1416
|
+
if (!(form instanceof HTMLFormElement)) {
|
|
1417
|
+
return null;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
var submitter = dialogPolyfill.formSubmitter;
|
|
1421
|
+
if (!submitter) {
|
|
1422
|
+
var target = event.target;
|
|
1423
|
+
var root = ('getRootNode' in target && target.getRootNode() || document);
|
|
1424
|
+
submitter = root.activeElement;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
if (!submitter || submitter.form !== form) {
|
|
1428
|
+
return null;
|
|
1429
|
+
}
|
|
1430
|
+
return submitter;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* @param {!Event} event
|
|
1435
|
+
*/
|
|
1436
|
+
function maybeHandleSubmit(event) {
|
|
1437
|
+
if (event.defaultPrevented) {
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
var form = /** @type {!HTMLFormElement} */ (event.target);
|
|
1441
|
+
|
|
1442
|
+
// We'd have a value if we clicked on an imagemap.
|
|
1443
|
+
var value = dialogPolyfill.imagemapUseValue;
|
|
1444
|
+
var submitter = findFormSubmitter(event);
|
|
1445
|
+
if (value === null && submitter) {
|
|
1446
|
+
value = submitter.value;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
// There should always be a dialog as this handler is added specifically on them, but check just
|
|
1450
|
+
// in case.
|
|
1451
|
+
var dialog = findNearestDialog(form);
|
|
1452
|
+
if (!dialog) {
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
// Prefer formmethod on the button.
|
|
1457
|
+
var formmethod = submitter && submitter.getAttribute('formmethod') || form.getAttribute('method');
|
|
1458
|
+
if (formmethod !== 'dialog') {
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
event.preventDefault();
|
|
1462
|
+
|
|
1463
|
+
if (value != null) {
|
|
1464
|
+
// nb. we explicitly check against null/undefined
|
|
1465
|
+
dialog.close(value);
|
|
1466
|
+
} else {
|
|
1467
|
+
dialog.close();
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* @param {!HTMLDialogElement} dialog to upgrade
|
|
1473
|
+
* @constructor
|
|
1474
|
+
*/
|
|
1475
|
+
function dialogPolyfillInfo(dialog) {
|
|
1476
|
+
this.dialog_ = dialog;
|
|
1477
|
+
this.replacedStyleTop_ = false;
|
|
1478
|
+
this.openAsModal_ = false;
|
|
1479
|
+
|
|
1480
|
+
// Set a11y role. Browsers that support dialog implicitly know this already.
|
|
1481
|
+
if (!dialog.hasAttribute('role')) {
|
|
1482
|
+
dialog.setAttribute('role', 'dialog');
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
dialog.show = this.show.bind(this);
|
|
1486
|
+
dialog.showModal = this.showModal.bind(this);
|
|
1487
|
+
dialog.close = this.close.bind(this);
|
|
1488
|
+
|
|
1489
|
+
dialog.addEventListener('submit', maybeHandleSubmit, false);
|
|
1490
|
+
|
|
1491
|
+
if (!('returnValue' in dialog)) {
|
|
1492
|
+
dialog.returnValue = '';
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
if ('MutationObserver' in window) {
|
|
1496
|
+
var mo = new MutationObserver(this.maybeHideModal.bind(this));
|
|
1497
|
+
mo.observe(dialog, {attributes: true, attributeFilter: ['open']});
|
|
1498
|
+
} else {
|
|
1499
|
+
// IE10 and below support. Note that DOMNodeRemoved etc fire _before_ removal. They also
|
|
1500
|
+
// seem to fire even if the element was removed as part of a parent removal. Use the removed
|
|
1501
|
+
// events to force downgrade (useful if removed/immediately added).
|
|
1502
|
+
var removed = false;
|
|
1503
|
+
var cb = function() {
|
|
1504
|
+
removed ? this.downgradeModal() : this.maybeHideModal();
|
|
1505
|
+
removed = false;
|
|
1506
|
+
}.bind(this);
|
|
1507
|
+
var timeout;
|
|
1508
|
+
var delayModel = function(ev) {
|
|
1509
|
+
if (ev.target !== dialog) { return; } // not for a child element
|
|
1510
|
+
var cand = 'DOMNodeRemoved';
|
|
1511
|
+
removed |= (ev.type.substr(0, cand.length) === cand);
|
|
1512
|
+
window.clearTimeout(timeout);
|
|
1513
|
+
timeout = window.setTimeout(cb, 0);
|
|
1514
|
+
};
|
|
1515
|
+
['DOMAttrModified', 'DOMNodeRemoved', 'DOMNodeRemovedFromDocument'].forEach(function(name) {
|
|
1516
|
+
dialog.addEventListener(name, delayModel);
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
// Note that the DOM is observed inside DialogManager while any dialog
|
|
1520
|
+
// is being displayed as a modal, to catch modal removal from the DOM.
|
|
1521
|
+
|
|
1522
|
+
Object.defineProperty(dialog, 'open', {
|
|
1523
|
+
set: this.setOpen.bind(this),
|
|
1524
|
+
get: dialog.hasAttribute.bind(dialog, 'open')
|
|
1525
|
+
});
|
|
1526
|
+
|
|
1527
|
+
this.backdrop_ = document.createElement('div');
|
|
1528
|
+
this.backdrop_.className = 'backdrop';
|
|
1529
|
+
this.backdrop_.addEventListener('mouseup' , this.backdropMouseEvent_.bind(this));
|
|
1530
|
+
this.backdrop_.addEventListener('mousedown', this.backdropMouseEvent_.bind(this));
|
|
1531
|
+
this.backdrop_.addEventListener('click' , this.backdropMouseEvent_.bind(this));
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
dialogPolyfillInfo.prototype = /** @type {HTMLDialogElement.prototype} */ ({
|
|
1535
|
+
|
|
1536
|
+
get dialog() {
|
|
1537
|
+
return this.dialog_;
|
|
1538
|
+
},
|
|
1539
|
+
|
|
1540
|
+
/**
|
|
1541
|
+
* Maybe remove this dialog from the modal top layer. This is called when
|
|
1542
|
+
* a modal dialog may no longer be tenable, e.g., when the dialog is no
|
|
1543
|
+
* longer open or is no longer part of the DOM.
|
|
1544
|
+
*/
|
|
1545
|
+
maybeHideModal: function() {
|
|
1546
|
+
if (this.dialog_.hasAttribute('open') && isConnected(this.dialog_)) { return; }
|
|
1547
|
+
this.downgradeModal();
|
|
1548
|
+
},
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* Remove this dialog from the modal top layer, leaving it as a non-modal.
|
|
1552
|
+
*/
|
|
1553
|
+
downgradeModal: function() {
|
|
1554
|
+
if (!this.openAsModal_) { return; }
|
|
1555
|
+
this.openAsModal_ = false;
|
|
1556
|
+
this.dialog_.style.zIndex = '';
|
|
1557
|
+
|
|
1558
|
+
// This won't match the native <dialog> exactly because if the user set top on a centered
|
|
1559
|
+
// polyfill dialog, that top gets thrown away when the dialog is closed. Not sure it's
|
|
1560
|
+
// possible to polyfill this perfectly.
|
|
1561
|
+
if (this.replacedStyleTop_) {
|
|
1562
|
+
this.dialog_.style.top = '';
|
|
1563
|
+
this.replacedStyleTop_ = false;
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
// Clear the backdrop and remove from the manager.
|
|
1567
|
+
this.backdrop_.parentNode && this.backdrop_.parentNode.removeChild(this.backdrop_);
|
|
1568
|
+
dialogPolyfill.dm.removeDialog(this);
|
|
1569
|
+
},
|
|
1570
|
+
|
|
1571
|
+
/**
|
|
1572
|
+
* @param {boolean} value whether to open or close this dialog
|
|
1573
|
+
*/
|
|
1574
|
+
setOpen: function(value) {
|
|
1575
|
+
if (value) {
|
|
1576
|
+
this.dialog_.hasAttribute('open') || this.dialog_.setAttribute('open', '');
|
|
1577
|
+
} else {
|
|
1578
|
+
this.dialog_.removeAttribute('open');
|
|
1579
|
+
this.maybeHideModal(); // nb. redundant with MutationObserver
|
|
1580
|
+
}
|
|
1581
|
+
},
|
|
1582
|
+
|
|
1583
|
+
/**
|
|
1584
|
+
* Handles mouse events ('mouseup', 'mousedown', 'click') on the fake .backdrop element, redirecting them as if
|
|
1585
|
+
* they were on the dialog itself.
|
|
1586
|
+
*
|
|
1587
|
+
* @param {!Event} e to redirect
|
|
1588
|
+
*/
|
|
1589
|
+
backdropMouseEvent_: function(e) {
|
|
1590
|
+
if (!this.dialog_.hasAttribute('tabindex')) {
|
|
1591
|
+
// Clicking on the backdrop should move the implicit cursor, even if dialog cannot be
|
|
1592
|
+
// focused. Create a fake thing to focus on. If the backdrop was _before_ the dialog, this
|
|
1593
|
+
// would not be needed - clicks would move the implicit cursor there.
|
|
1594
|
+
var fake = document.createElement('div');
|
|
1595
|
+
this.dialog_.insertBefore(fake, this.dialog_.firstChild);
|
|
1596
|
+
fake.tabIndex = -1;
|
|
1597
|
+
fake.focus();
|
|
1598
|
+
this.dialog_.removeChild(fake);
|
|
1599
|
+
} else {
|
|
1600
|
+
this.dialog_.focus();
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
var redirectedEvent = document.createEvent('MouseEvents');
|
|
1604
|
+
redirectedEvent.initMouseEvent(e.type, e.bubbles, e.cancelable, window,
|
|
1605
|
+
e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey,
|
|
1606
|
+
e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget);
|
|
1607
|
+
this.dialog_.dispatchEvent(redirectedEvent);
|
|
1608
|
+
e.stopPropagation();
|
|
1609
|
+
},
|
|
1610
|
+
|
|
1611
|
+
/**
|
|
1612
|
+
* Focuses on the first focusable element within the dialog. This will always blur the current
|
|
1613
|
+
* focus, even if nothing within the dialog is found.
|
|
1614
|
+
*/
|
|
1615
|
+
focus_: function() {
|
|
1616
|
+
// Find element with `autofocus` attribute, or fall back to the first form/tabindex control.
|
|
1617
|
+
var target = this.dialog_.querySelector('[autofocus]:not([disabled])');
|
|
1618
|
+
if (!target && this.dialog_.tabIndex >= 0) {
|
|
1619
|
+
target = this.dialog_;
|
|
1620
|
+
}
|
|
1621
|
+
if (!target) {
|
|
1622
|
+
target = findFocusableElementWithin(this.dialog_);
|
|
1623
|
+
}
|
|
1624
|
+
safeBlur(document.activeElement);
|
|
1625
|
+
target && target.focus();
|
|
1626
|
+
},
|
|
1627
|
+
|
|
1628
|
+
/**
|
|
1629
|
+
* Sets the zIndex for the backdrop and dialog.
|
|
1630
|
+
*
|
|
1631
|
+
* @param {number} dialogZ
|
|
1632
|
+
* @param {number} backdropZ
|
|
1633
|
+
*/
|
|
1634
|
+
updateZIndex: function(dialogZ, backdropZ) {
|
|
1635
|
+
if (dialogZ < backdropZ) {
|
|
1636
|
+
throw new Error('dialogZ should never be < backdropZ');
|
|
1637
|
+
}
|
|
1638
|
+
this.dialog_.style.zIndex = dialogZ;
|
|
1639
|
+
this.backdrop_.style.zIndex = backdropZ;
|
|
1640
|
+
},
|
|
1641
|
+
|
|
1642
|
+
/**
|
|
1643
|
+
* Shows the dialog. If the dialog is already open, this does nothing.
|
|
1644
|
+
*/
|
|
1645
|
+
show: function() {
|
|
1646
|
+
if (!this.dialog_.open) {
|
|
1647
|
+
this.setOpen(true);
|
|
1648
|
+
this.focus_();
|
|
1649
|
+
}
|
|
1650
|
+
},
|
|
1651
|
+
|
|
1652
|
+
/**
|
|
1653
|
+
* Show this dialog modally.
|
|
1654
|
+
*/
|
|
1655
|
+
showModal: function() {
|
|
1656
|
+
if (this.dialog_.hasAttribute('open')) {
|
|
1657
|
+
throw new Error('Failed to execute \'showModal\' on dialog: The element is already open, and therefore cannot be opened modally.');
|
|
1658
|
+
}
|
|
1659
|
+
if (!isConnected(this.dialog_)) {
|
|
1660
|
+
throw new Error('Failed to execute \'showModal\' on dialog: The element is not in a Document.');
|
|
1661
|
+
}
|
|
1662
|
+
if (!dialogPolyfill.dm.pushDialog(this)) {
|
|
1663
|
+
throw new Error('Failed to execute \'showModal\' on dialog: There are too many open modal dialogs.');
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
if (createsStackingContext(this.dialog_.parentElement)) {
|
|
1667
|
+
console.warn('A dialog is being shown inside a stacking context. ' +
|
|
1668
|
+
'This may cause it to be unusable. For more information, see this link: ' +
|
|
1669
|
+
'https://github.com/GoogleChrome/dialog-polyfill/#stacking-context');
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
this.setOpen(true);
|
|
1673
|
+
this.openAsModal_ = true;
|
|
1674
|
+
|
|
1675
|
+
// Optionally center vertically, relative to the current viewport.
|
|
1676
|
+
if (dialogPolyfill.needsCentering(this.dialog_)) {
|
|
1677
|
+
dialogPolyfill.reposition(this.dialog_);
|
|
1678
|
+
this.replacedStyleTop_ = true;
|
|
1679
|
+
} else {
|
|
1680
|
+
this.replacedStyleTop_ = false;
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
// Insert backdrop.
|
|
1684
|
+
this.dialog_.parentNode.insertBefore(this.backdrop_, this.dialog_.nextSibling);
|
|
1685
|
+
|
|
1686
|
+
// Focus on whatever inside the dialog.
|
|
1687
|
+
this.focus_();
|
|
1688
|
+
},
|
|
1689
|
+
|
|
1690
|
+
/**
|
|
1691
|
+
* Closes this HTMLDialogElement. This is optional vs clearing the open
|
|
1692
|
+
* attribute, however this fires a 'close' event.
|
|
1693
|
+
*
|
|
1694
|
+
* @param {string=} opt_returnValue to use as the returnValue
|
|
1695
|
+
*/
|
|
1696
|
+
close: function(opt_returnValue) {
|
|
1697
|
+
if (!this.dialog_.hasAttribute('open')) {
|
|
1698
|
+
throw new Error('Failed to execute \'close\' on dialog: The element does not have an \'open\' attribute, and therefore cannot be closed.');
|
|
1699
|
+
}
|
|
1700
|
+
this.setOpen(false);
|
|
1701
|
+
|
|
1702
|
+
// Leave returnValue untouched in case it was set directly on the element
|
|
1703
|
+
if (opt_returnValue !== undefined) {
|
|
1704
|
+
this.dialog_.returnValue = opt_returnValue;
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
// Triggering "close" event for any attached listeners on the <dialog>.
|
|
1708
|
+
var closeEvent = new supportCustomEvent('close', {
|
|
1709
|
+
bubbles: false,
|
|
1710
|
+
cancelable: false
|
|
1711
|
+
});
|
|
1712
|
+
safeDispatchEvent(this.dialog_, closeEvent);
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
});
|
|
1716
|
+
|
|
1717
|
+
var dialogPolyfill = {};
|
|
1718
|
+
|
|
1719
|
+
dialogPolyfill.reposition = function(element) {
|
|
1720
|
+
var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
|
|
1721
|
+
var topValue = scrollTop + (window.innerHeight - element.offsetHeight) / 2;
|
|
1722
|
+
element.style.top = Math.max(scrollTop, topValue) + 'px';
|
|
1723
|
+
};
|
|
1724
|
+
|
|
1725
|
+
dialogPolyfill.isInlinePositionSetByStylesheet = function(element) {
|
|
1726
|
+
for (var i = 0; i < document.styleSheets.length; ++i) {
|
|
1727
|
+
var styleSheet = document.styleSheets[i];
|
|
1728
|
+
var cssRules = null;
|
|
1729
|
+
// Some browsers throw on cssRules.
|
|
1730
|
+
try {
|
|
1731
|
+
cssRules = styleSheet.cssRules;
|
|
1732
|
+
} catch (e) {}
|
|
1733
|
+
if (!cssRules) { continue; }
|
|
1734
|
+
for (var j = 0; j < cssRules.length; ++j) {
|
|
1735
|
+
var rule = cssRules[j];
|
|
1736
|
+
var selectedNodes = null;
|
|
1737
|
+
// Ignore errors on invalid selector texts.
|
|
1738
|
+
try {
|
|
1739
|
+
selectedNodes = document.querySelectorAll(rule.selectorText);
|
|
1740
|
+
} catch(e) {}
|
|
1741
|
+
if (!selectedNodes || !inNodeList(selectedNodes, element)) {
|
|
1742
|
+
continue;
|
|
1743
|
+
}
|
|
1744
|
+
var cssTop = rule.style.getPropertyValue('top');
|
|
1745
|
+
var cssBottom = rule.style.getPropertyValue('bottom');
|
|
1746
|
+
if ((cssTop && cssTop !== 'auto') || (cssBottom && cssBottom !== 'auto')) {
|
|
1747
|
+
return true;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
return false;
|
|
1752
|
+
};
|
|
1753
|
+
|
|
1754
|
+
dialogPolyfill.needsCentering = function(dialog) {
|
|
1755
|
+
var computedStyle = window.getComputedStyle(dialog);
|
|
1756
|
+
if (computedStyle.position !== 'absolute') {
|
|
1757
|
+
return false;
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
// We must determine whether the top/bottom specified value is non-auto. In
|
|
1761
|
+
// WebKit/Blink, checking computedStyle.top == 'auto' is sufficient, but
|
|
1762
|
+
// Firefox returns the used value. So we do this crazy thing instead: check
|
|
1763
|
+
// the inline style and then go through CSS rules.
|
|
1764
|
+
if ((dialog.style.top !== 'auto' && dialog.style.top !== '') ||
|
|
1765
|
+
(dialog.style.bottom !== 'auto' && dialog.style.bottom !== '')) {
|
|
1766
|
+
return false;
|
|
1767
|
+
}
|
|
1768
|
+
return !dialogPolyfill.isInlinePositionSetByStylesheet(dialog);
|
|
1769
|
+
};
|
|
1770
|
+
|
|
1771
|
+
/**
|
|
1772
|
+
* @param {!Element} element to force upgrade
|
|
1773
|
+
*/
|
|
1774
|
+
dialogPolyfill.forceRegisterDialog = function(element) {
|
|
1775
|
+
if (window.HTMLDialogElement || element.showModal) {
|
|
1776
|
+
console.warn('This browser already supports <dialog>, the polyfill ' +
|
|
1777
|
+
'may not work correctly', element);
|
|
1778
|
+
}
|
|
1779
|
+
if (element.localName !== 'dialog') {
|
|
1780
|
+
throw new Error('Failed to register dialog: The element is not a dialog.');
|
|
1781
|
+
}
|
|
1782
|
+
new dialogPolyfillInfo(/** @type {!HTMLDialogElement} */ (element));
|
|
1783
|
+
};
|
|
1784
|
+
|
|
1785
|
+
/**
|
|
1786
|
+
* @param {!Element} element to upgrade, if necessary
|
|
1787
|
+
*/
|
|
1788
|
+
dialogPolyfill.registerDialog = function(element) {
|
|
1789
|
+
if (!element.showModal) {
|
|
1790
|
+
dialogPolyfill.forceRegisterDialog(element);
|
|
1791
|
+
}
|
|
1792
|
+
};
|
|
1793
|
+
|
|
1794
|
+
/**
|
|
1795
|
+
* @constructor
|
|
1796
|
+
*/
|
|
1797
|
+
dialogPolyfill.DialogManager = function() {
|
|
1798
|
+
/** @type {!Array<!dialogPolyfillInfo>} */
|
|
1799
|
+
this.pendingDialogStack = [];
|
|
1800
|
+
|
|
1801
|
+
var checkDOM = this.checkDOM_.bind(this);
|
|
1802
|
+
|
|
1803
|
+
// The overlay is used to simulate how a modal dialog blocks the document.
|
|
1804
|
+
// The blocking dialog is positioned on top of the overlay, and the rest of
|
|
1805
|
+
// the dialogs on the pending dialog stack are positioned below it. In the
|
|
1806
|
+
// actual implementation, the modal dialog stacking is controlled by the
|
|
1807
|
+
// top layer, where z-index has no effect.
|
|
1808
|
+
this.overlay = document.createElement('div');
|
|
1809
|
+
this.overlay.className = '_dialog_overlay';
|
|
1810
|
+
this.overlay.addEventListener('click', function(e) {
|
|
1811
|
+
this.forwardTab_ = undefined;
|
|
1812
|
+
e.stopPropagation();
|
|
1813
|
+
checkDOM([]); // sanity-check DOM
|
|
1814
|
+
}.bind(this));
|
|
1815
|
+
|
|
1816
|
+
this.handleKey_ = this.handleKey_.bind(this);
|
|
1817
|
+
this.handleFocus_ = this.handleFocus_.bind(this);
|
|
1818
|
+
|
|
1819
|
+
this.zIndexLow_ = 100000;
|
|
1820
|
+
this.zIndexHigh_ = 100000 + 150;
|
|
1821
|
+
|
|
1822
|
+
this.forwardTab_ = undefined;
|
|
1823
|
+
|
|
1824
|
+
if ('MutationObserver' in window) {
|
|
1825
|
+
this.mo_ = new MutationObserver(function(records) {
|
|
1826
|
+
var removed = [];
|
|
1827
|
+
records.forEach(function(rec) {
|
|
1828
|
+
for (var i = 0, c; c = rec.removedNodes[i]; ++i) {
|
|
1829
|
+
if (!(c instanceof Element)) {
|
|
1830
|
+
continue;
|
|
1831
|
+
} else if (c.localName === 'dialog') {
|
|
1832
|
+
removed.push(c);
|
|
1833
|
+
}
|
|
1834
|
+
removed = removed.concat(c.querySelectorAll('dialog'));
|
|
1835
|
+
}
|
|
1836
|
+
});
|
|
1837
|
+
removed.length && checkDOM(removed);
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
};
|
|
1841
|
+
|
|
1842
|
+
/**
|
|
1843
|
+
* Called on the first modal dialog being shown. Adds the overlay and related
|
|
1844
|
+
* handlers.
|
|
1845
|
+
*/
|
|
1846
|
+
dialogPolyfill.DialogManager.prototype.blockDocument = function() {
|
|
1847
|
+
document.documentElement.addEventListener('focus', this.handleFocus_, true);
|
|
1848
|
+
document.addEventListener('keydown', this.handleKey_);
|
|
1849
|
+
this.mo_ && this.mo_.observe(document, {childList: true, subtree: true});
|
|
1850
|
+
};
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* Called on the first modal dialog being removed, i.e., when no more modal
|
|
1854
|
+
* dialogs are visible.
|
|
1855
|
+
*/
|
|
1856
|
+
dialogPolyfill.DialogManager.prototype.unblockDocument = function() {
|
|
1857
|
+
document.documentElement.removeEventListener('focus', this.handleFocus_, true);
|
|
1858
|
+
document.removeEventListener('keydown', this.handleKey_);
|
|
1859
|
+
this.mo_ && this.mo_.disconnect();
|
|
1860
|
+
};
|
|
1861
|
+
|
|
1862
|
+
/**
|
|
1863
|
+
* Updates the stacking of all known dialogs.
|
|
1864
|
+
*/
|
|
1865
|
+
dialogPolyfill.DialogManager.prototype.updateStacking = function() {
|
|
1866
|
+
var zIndex = this.zIndexHigh_;
|
|
1867
|
+
|
|
1868
|
+
for (var i = 0, dpi; dpi = this.pendingDialogStack[i]; ++i) {
|
|
1869
|
+
dpi.updateZIndex(--zIndex, --zIndex);
|
|
1870
|
+
if (i === 0) {
|
|
1871
|
+
this.overlay.style.zIndex = --zIndex;
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
// Make the overlay a sibling of the dialog itself.
|
|
1876
|
+
var last = this.pendingDialogStack[0];
|
|
1877
|
+
if (last) {
|
|
1878
|
+
var p = last.dialog.parentNode || document.body;
|
|
1879
|
+
p.appendChild(this.overlay);
|
|
1880
|
+
} else if (this.overlay.parentNode) {
|
|
1881
|
+
this.overlay.parentNode.removeChild(this.overlay);
|
|
1882
|
+
}
|
|
1883
|
+
};
|
|
1884
|
+
|
|
1885
|
+
/**
|
|
1886
|
+
* @param {Element} candidate to check if contained or is the top-most modal dialog
|
|
1887
|
+
* @return {boolean} whether candidate is contained in top dialog
|
|
1888
|
+
*/
|
|
1889
|
+
dialogPolyfill.DialogManager.prototype.containedByTopDialog_ = function(candidate) {
|
|
1890
|
+
while (candidate = findNearestDialog(candidate)) {
|
|
1891
|
+
for (var i = 0, dpi; dpi = this.pendingDialogStack[i]; ++i) {
|
|
1892
|
+
if (dpi.dialog === candidate) {
|
|
1893
|
+
return i === 0; // only valid if top-most
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
candidate = candidate.parentElement;
|
|
1897
|
+
}
|
|
1898
|
+
return false;
|
|
1899
|
+
};
|
|
1900
|
+
|
|
1901
|
+
dialogPolyfill.DialogManager.prototype.handleFocus_ = function(event) {
|
|
1902
|
+
var target = event.composedPath ? event.composedPath()[0] : event.target;
|
|
1903
|
+
|
|
1904
|
+
if (this.containedByTopDialog_(target)) { return; }
|
|
1905
|
+
|
|
1906
|
+
if (document.activeElement === document.documentElement) { return; }
|
|
1907
|
+
|
|
1908
|
+
event.preventDefault();
|
|
1909
|
+
event.stopPropagation();
|
|
1910
|
+
safeBlur(/** @type {Element} */ (target));
|
|
1911
|
+
|
|
1912
|
+
if (this.forwardTab_ === undefined) { return; } // move focus only from a tab key
|
|
1913
|
+
|
|
1914
|
+
var dpi = this.pendingDialogStack[0];
|
|
1915
|
+
var dialog = dpi.dialog;
|
|
1916
|
+
var position = dialog.compareDocumentPosition(target);
|
|
1917
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
1918
|
+
if (this.forwardTab_) {
|
|
1919
|
+
// forward
|
|
1920
|
+
dpi.focus_();
|
|
1921
|
+
} else if (target !== document.documentElement) {
|
|
1922
|
+
// backwards if we're not already focused on <html>
|
|
1923
|
+
document.documentElement.focus();
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
return false;
|
|
1928
|
+
};
|
|
1929
|
+
|
|
1930
|
+
dialogPolyfill.DialogManager.prototype.handleKey_ = function(event) {
|
|
1931
|
+
this.forwardTab_ = undefined;
|
|
1932
|
+
if (event.keyCode === 27) {
|
|
1933
|
+
event.preventDefault();
|
|
1934
|
+
event.stopPropagation();
|
|
1935
|
+
var cancelEvent = new supportCustomEvent('cancel', {
|
|
1936
|
+
bubbles: false,
|
|
1937
|
+
cancelable: true
|
|
1938
|
+
});
|
|
1939
|
+
var dpi = this.pendingDialogStack[0];
|
|
1940
|
+
if (dpi && safeDispatchEvent(dpi.dialog, cancelEvent)) {
|
|
1941
|
+
dpi.dialog.close();
|
|
1942
|
+
}
|
|
1943
|
+
} else if (event.keyCode === 9) {
|
|
1944
|
+
this.forwardTab_ = !event.shiftKey;
|
|
1945
|
+
}
|
|
1946
|
+
};
|
|
1947
|
+
|
|
1948
|
+
/**
|
|
1949
|
+
* Finds and downgrades any known modal dialogs that are no longer displayed. Dialogs that are
|
|
1950
|
+
* removed and immediately readded don't stay modal, they become normal.
|
|
1951
|
+
*
|
|
1952
|
+
* @param {!Array<!HTMLDialogElement>} removed that have definitely been removed
|
|
1953
|
+
*/
|
|
1954
|
+
dialogPolyfill.DialogManager.prototype.checkDOM_ = function(removed) {
|
|
1955
|
+
// This operates on a clone because it may cause it to change. Each change also calls
|
|
1956
|
+
// updateStacking, which only actually needs to happen once. But who removes many modal dialogs
|
|
1957
|
+
// at a time?!
|
|
1958
|
+
var clone = this.pendingDialogStack.slice();
|
|
1959
|
+
clone.forEach(function(dpi) {
|
|
1960
|
+
if (removed.indexOf(dpi.dialog) !== -1) {
|
|
1961
|
+
dpi.downgradeModal();
|
|
1962
|
+
} else {
|
|
1963
|
+
dpi.maybeHideModal();
|
|
1964
|
+
}
|
|
1965
|
+
});
|
|
1966
|
+
};
|
|
1967
|
+
|
|
1968
|
+
/**
|
|
1969
|
+
* @param {!dialogPolyfillInfo} dpi
|
|
1970
|
+
* @return {boolean} whether the dialog was allowed
|
|
1971
|
+
*/
|
|
1972
|
+
dialogPolyfill.DialogManager.prototype.pushDialog = function(dpi) {
|
|
1973
|
+
var allowed = (this.zIndexHigh_ - this.zIndexLow_) / 2 - 1;
|
|
1974
|
+
if (this.pendingDialogStack.length >= allowed) {
|
|
1975
|
+
return false;
|
|
1976
|
+
}
|
|
1977
|
+
if (this.pendingDialogStack.unshift(dpi) === 1) {
|
|
1978
|
+
this.blockDocument();
|
|
1979
|
+
}
|
|
1980
|
+
this.updateStacking();
|
|
1981
|
+
return true;
|
|
1982
|
+
};
|
|
1983
|
+
|
|
1984
|
+
/**
|
|
1985
|
+
* @param {!dialogPolyfillInfo} dpi
|
|
1986
|
+
*/
|
|
1987
|
+
dialogPolyfill.DialogManager.prototype.removeDialog = function(dpi) {
|
|
1988
|
+
var index = this.pendingDialogStack.indexOf(dpi);
|
|
1989
|
+
if (index === -1) { return; }
|
|
1990
|
+
|
|
1991
|
+
this.pendingDialogStack.splice(index, 1);
|
|
1992
|
+
if (this.pendingDialogStack.length === 0) {
|
|
1993
|
+
this.unblockDocument();
|
|
1994
|
+
}
|
|
1995
|
+
this.updateStacking();
|
|
1996
|
+
};
|
|
1997
|
+
|
|
1998
|
+
dialogPolyfill.dm = new dialogPolyfill.DialogManager();
|
|
1999
|
+
dialogPolyfill.formSubmitter = null;
|
|
2000
|
+
dialogPolyfill.imagemapUseValue = null;
|
|
2001
|
+
|
|
2002
|
+
/**
|
|
2003
|
+
* Installs global handlers, such as click listers and native method overrides. These are needed
|
|
2004
|
+
* even if a no dialog is registered, as they deal with <form method="dialog">.
|
|
2005
|
+
*/
|
|
2006
|
+
if (window.HTMLDialogElement === undefined) {
|
|
2007
|
+
|
|
2008
|
+
/**
|
|
2009
|
+
* If HTMLFormElement translates method="DIALOG" into 'get', then replace the descriptor with
|
|
2010
|
+
* one that returns the correct value.
|
|
2011
|
+
*/
|
|
2012
|
+
var testForm = document.createElement('form');
|
|
2013
|
+
testForm.setAttribute('method', 'dialog');
|
|
2014
|
+
if (testForm.method !== 'dialog') {
|
|
2015
|
+
var methodDescriptor = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, 'method');
|
|
2016
|
+
if (methodDescriptor) {
|
|
2017
|
+
// nb. Some older iOS and older PhantomJS fail to return the descriptor. Don't do anything
|
|
2018
|
+
// and don't bother to update the element.
|
|
2019
|
+
var realGet = methodDescriptor.get;
|
|
2020
|
+
methodDescriptor.get = function() {
|
|
2021
|
+
if (isFormMethodDialog(this)) {
|
|
2022
|
+
return 'dialog';
|
|
2023
|
+
}
|
|
2024
|
+
return realGet.call(this);
|
|
2025
|
+
};
|
|
2026
|
+
var realSet = methodDescriptor.set;
|
|
2027
|
+
/** @this {HTMLElement} */
|
|
2028
|
+
methodDescriptor.set = function(v) {
|
|
2029
|
+
if (typeof v === 'string' && v.toLowerCase() === 'dialog') {
|
|
2030
|
+
return this.setAttribute('method', v);
|
|
2031
|
+
}
|
|
2032
|
+
return realSet.call(this, v);
|
|
2033
|
+
};
|
|
2034
|
+
Object.defineProperty(HTMLFormElement.prototype, 'method', methodDescriptor);
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
/**
|
|
2039
|
+
* Global 'click' handler, to capture the <input type="submit"> or <button> element which has
|
|
2040
|
+
* submitted a <form method="dialog">. Needed as Safari and others don't report this inside
|
|
2041
|
+
* document.activeElement.
|
|
2042
|
+
*/
|
|
2043
|
+
document.addEventListener('click', function(ev) {
|
|
2044
|
+
dialogPolyfill.formSubmitter = null;
|
|
2045
|
+
dialogPolyfill.imagemapUseValue = null;
|
|
2046
|
+
if (ev.defaultPrevented) { return; } // e.g. a submit which prevents default submission
|
|
2047
|
+
|
|
2048
|
+
var target = /** @type {Element} */ (ev.target);
|
|
2049
|
+
if ('composedPath' in ev) {
|
|
2050
|
+
var path = ev.composedPath();
|
|
2051
|
+
target = path.shift() || target;
|
|
2052
|
+
}
|
|
2053
|
+
if (!target || !isFormMethodDialog(target.form)) { return; }
|
|
2054
|
+
|
|
2055
|
+
var valid = (target.type === 'submit' && ['button', 'input'].indexOf(target.localName) > -1);
|
|
2056
|
+
if (!valid) {
|
|
2057
|
+
if (!(target.localName === 'input' && target.type === 'image')) { return; }
|
|
2058
|
+
// this is a <input type="image">, which can submit forms
|
|
2059
|
+
dialogPolyfill.imagemapUseValue = ev.offsetX + ',' + ev.offsetY;
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
var dialog = findNearestDialog(target);
|
|
2063
|
+
if (!dialog) { return; }
|
|
2064
|
+
|
|
2065
|
+
dialogPolyfill.formSubmitter = target;
|
|
2066
|
+
|
|
2067
|
+
}, false);
|
|
2068
|
+
|
|
2069
|
+
/**
|
|
2070
|
+
* Global 'submit' handler. This handles submits of `method="dialog"` which are invalid, i.e.,
|
|
2071
|
+
* outside a dialog. They get prevented.
|
|
2072
|
+
*/
|
|
2073
|
+
document.addEventListener('submit', function(ev) {
|
|
2074
|
+
var form = ev.target;
|
|
2075
|
+
var dialog = findNearestDialog(form);
|
|
2076
|
+
if (dialog) {
|
|
2077
|
+
return; // ignore, handle there
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
var submitter = findFormSubmitter(ev);
|
|
2081
|
+
var formmethod = submitter && submitter.getAttribute('formmethod') || form.getAttribute('method');
|
|
2082
|
+
if (formmethod === 'dialog') {
|
|
2083
|
+
ev.preventDefault();
|
|
2084
|
+
}
|
|
2085
|
+
});
|
|
2086
|
+
|
|
2087
|
+
/**
|
|
2088
|
+
* Replace the native HTMLFormElement.submit() method, as it won't fire the
|
|
2089
|
+
* submit event and give us a chance to respond.
|
|
2090
|
+
*/
|
|
2091
|
+
var nativeFormSubmit = HTMLFormElement.prototype.submit;
|
|
2092
|
+
var replacementFormSubmit = function () {
|
|
2093
|
+
if (!isFormMethodDialog(this)) {
|
|
2094
|
+
return nativeFormSubmit.call(this);
|
|
2095
|
+
}
|
|
2096
|
+
var dialog = findNearestDialog(this);
|
|
2097
|
+
dialog && dialog.close();
|
|
2098
|
+
};
|
|
2099
|
+
HTMLFormElement.prototype.submit = replacementFormSubmit;
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
const stylesCss$3 = ":host{font-family:var(--font-family-sans);font-weight:var(--font-rg)}:host>dialog{padding:0;border:none;margin:0;background-color:transparent}:host>dialog:modal{width:100%;max-width:100%;max-height:100%}:host>dialog::backdrop{display:none}:host>dialog+.backdrop{display:none}:host>dialog:not([open]){display:none}:host>dialog[open]{display:block}.modal-container{z-index:1010;display:flex;overflow:-moz-scrollbars-none;width:100%;height:100vh;flex-direction:column}.modal-container>.modal-content-scroll-outside{overflow:auto;background:var(--color-surface01)}.modal-container>header{padding:calc(var(--space-unit) * 2 - 2px) calc(var(--space-unit) * 2);background:var(--color-surface02)}.modal-container>header button{padding:0;border:none;margin:0;margin-left:auto;background:transparent;cursor:pointer}.modal-container>header z-icon{--z-icon-width:calc(var(--space-unit) * 2.5);--z-icon-height:calc(var(--space-unit) * 2.5);display:flex;fill:var(--color-icon01)}.modal-container>header>div{display:flex;width:100%;align-items:center;margin-right:calc(var(--space-unit) * 2)}.modal-container>header h1,.modal-container>header h2{padding:0;margin:0;color:var(--color-text01);font-weight:var(--font-rg)}.modal-container>header h1{font-size:var(--font-size-5);letter-spacing:0;line-height:1.4}.modal-container>header h2{font-size:var(--font-size-3);letter-spacing:0;line-height:1.5}.modal-container>header>div>h1 *:empty{display:none}.modal-container>header h1+h2{margin-top:calc(var(--space-unit) * 0.5)}.modal-container-scroll-inside>.modal-content-scroll-inside{overflow:hidden auto;flex:1 auto;background:var(--color-surface01)}.modal-container-scroll-inside>.modal-content-scroll-inside::-webkit-scrollbar,.modal-container-scroll-outside>.modal-content-scroll-outside::-webkit-scrollbar{width:10px;background:linear-gradient(to right, transparent 0 3px, var(--gray200) 3px 7px, transparent 7px 10px);border-radius:var(--border-radius)}.modal-container-scroll-inside>.modal-content-scroll-inside::-webkit-scrollbar-thumb,.modal-container-scroll-outside>.modal-content-scroll-outside::-webkit-scrollbar-thumb{width:10px;background-color:var(--color-primary01)}.modal-container-scroll-inside>.modal-content-scroll-inside::-webkit-scrollbar-thumb:hover,.modal-container-scroll-outside>.modal-content-scroll-outside::-webkit-scrollbar-thumb:hover{background-color:var(--color-hover-primary)}.modal-container-scroll-inside .modal-content-scroll-inside,.modal-container-scroll-outside .modal-content-scroll-outside{scrollbar-color:var(--color-primary01) transparent}@media only screen and (min-width: 768px){.modal-background{position:fixed;top:0;left:0;overflow:hidden;width:100vw;height:100vh;background-color:var(--gray900);opacity:0.7}.modal-background.modal-background-scroll-outside{position:sticky}.modal-container-scroll-inside{position:fixed;top:calc(var(--space-unit) * 6);left:50%;overflow:hidden;width:auto;min-width:calc(var(--space-unit) * 40);height:auto;min-height:calc(var(--space-unit) * 40);max-height:calc(100vh - calc(var(--space-unit) * 6 * 2));border-radius:var(--border-radius);transform:translateX(-50%)}.modal-container-scroll-outside{position:absolute;top:calc(var(--space-unit) * 6);left:50%;display:block;overflow:initial;width:auto;min-width:calc(var(--space-unit) * 40);height:auto;min-height:calc(var(--space-unit) * 40);max-height:calc(100vh - calc(var(--space-unit) * 6 * 2));transform:translateX(-50%)}.modal-container>.modal-content-scroll-outside{overflow:initial}.modal-container-scroll-outside>header{border-top-left-radius:var(--border-radius);border-top-right-radius:var(--border-radius)}.modal-container-scroll-outside::after{display:block;height:calc(var(--space-unit) * 6);content:\" \"}.modal-dialog{position:fixed;top:0;left:0;height:auto;overflow-x:hidden;overflow-y:auto}.modal-content-scroll-outside{border-bottom-left-radius:var(--border-radius);border-bottom-right-radius:var(--border-radius)}.modal-container-scroll-inside>header{border-top-left-radius:var(--border-radius);border-top-right-radius:var(--border-radius)}.modal-dialog::-webkit-scrollbar{display:none}.modal-container>header z-icon{--z-icon-width:calc(var(--space-unit) * 3);--z-icon-height:calc(var(--space-unit) * 3)}}@media only screen and (min-width: 768px) and (max-width: 1151px){.modal-container>header{padding:calc(var(--space-unit) * 3 - 2px) calc(var(--space-unit) * 3)}}@media only screen and (min-width: 1152px){.modal-container>header{padding:calc(var(--space-unit) * 4 - 4px) calc(var(--space-unit) * 4)}.modal-container>header h1{font-size:var(--font-size-6);letter-spacing:0;line-height:1.33}.modal-container>header h2{font-size:var(--font-size-4);letter-spacing:0;line-height:1.5}.modal-container>header h1+h2{margin-top:0}}";
|
|
2103
|
+
|
|
2104
|
+
const FOCUSABLE_ELEMENTS_SELECTOR = ':is(button, input, select, textarea, [contenteditable=""], [contenteditable="true"], a[href], [tabindex], summary):not([disabled], [disabled=""], [tabindex="-1"], [aria-hidden="true"], [hidden])';
|
|
2105
|
+
const ZModal = class {
|
|
2106
|
+
constructor(hostRef) {
|
|
2107
|
+
index.registerInstance(this, hostRef);
|
|
2108
|
+
this.modalClose = index.createEvent(this, "modalClose", 7);
|
|
2109
|
+
this.modalHeaderActive = index.createEvent(this, "modalHeaderActive", 7);
|
|
2110
|
+
this.modalBackgroundClick = index.createEvent(this, "modalBackgroundClick", 7);
|
|
2111
|
+
/** aria-label for close button (optional) */
|
|
2112
|
+
this.closeButtonLabel = "chiudi modale";
|
|
2113
|
+
/** add role "alertdialog" to dialog (optional, default is false) */
|
|
2114
|
+
this.alertdialog = false;
|
|
2115
|
+
/** if true, the modal is closable (optional, default is true) */
|
|
2116
|
+
this.closable = true;
|
|
2117
|
+
/** if true, the modal can scroll inside, if false the viewport can scroll */
|
|
2118
|
+
this.scrollInside = true;
|
|
2119
|
+
}
|
|
2120
|
+
emitModalClose() {
|
|
2121
|
+
if (this.closable) {
|
|
2122
|
+
this.modalClose.emit({ modalid: this.modalid });
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
emitModalHeaderActive() {
|
|
2126
|
+
this.modalHeaderActive.emit({ modalid: this.modalid });
|
|
2127
|
+
}
|
|
2128
|
+
emitBackgroundClick() {
|
|
2129
|
+
if (this.closable) {
|
|
2130
|
+
this.modalBackgroundClick.emit({ modalid: this.modalid });
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
componentDidLoad() {
|
|
2134
|
+
if (typeof HTMLDialogElement !== "function") {
|
|
2135
|
+
dialogPolyfill.registerDialog(this.dialog);
|
|
2136
|
+
this.dialog.setAttribute("open", "true");
|
|
2137
|
+
}
|
|
2138
|
+
else {
|
|
2139
|
+
this.open();
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
/** open modal */
|
|
2143
|
+
async open() {
|
|
2144
|
+
var _a;
|
|
2145
|
+
(_a = this.dialog) === null || _a === void 0 ? void 0 : _a.showModal();
|
|
2146
|
+
}
|
|
2147
|
+
/** close modal */
|
|
2148
|
+
async close() {
|
|
2149
|
+
var _a;
|
|
2150
|
+
if (this.closable) {
|
|
2151
|
+
(_a = this.dialog) === null || _a === void 0 ? void 0 : _a.close();
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
/**
|
|
2155
|
+
* Get a list of focusable elements in the dialog.
|
|
2156
|
+
* Remove elements with `display: none` from the list, because they're not focusable.
|
|
2157
|
+
*
|
|
2158
|
+
* N.B. The list is built on the assumption that elements inside shadow root are placed ALL before the `modalContent` slot.
|
|
2159
|
+
* Adding focusable elements after the `modalContent` slot would break the order of elements in the list.
|
|
2160
|
+
*/
|
|
2161
|
+
get focusableElements() {
|
|
2162
|
+
return [
|
|
2163
|
+
...Array.from(this.host.shadowRoot.querySelectorAll(FOCUSABLE_ELEMENTS_SELECTOR)),
|
|
2164
|
+
...Array.from(this.host.querySelectorAll(FOCUSABLE_ELEMENTS_SELECTOR)),
|
|
2165
|
+
].filter((element) => getComputedStyle(element).display !== "none");
|
|
2166
|
+
}
|
|
2167
|
+
handleKeyDown(e) {
|
|
2168
|
+
if (e.code !== index$1.KeyboardCode.TAB) {
|
|
2169
|
+
return;
|
|
2170
|
+
}
|
|
2171
|
+
const focusableElements = this.focusableElements;
|
|
2172
|
+
const shadowActiveElement = this.host.shadowRoot.activeElement;
|
|
2173
|
+
const activeElement = this.host.ownerDocument.activeElement;
|
|
2174
|
+
const firstFocusableElement = focusableElements[0];
|
|
2175
|
+
const lastFocusableElement = focusableElements[focusableElements.length - 1];
|
|
2176
|
+
if (e.shiftKey && (shadowActiveElement == firstFocusableElement || activeElement == firstFocusableElement)) {
|
|
2177
|
+
// shift + tab was pressed and current active element is the first focusable element
|
|
2178
|
+
e.preventDefault();
|
|
2179
|
+
lastFocusableElement.focus();
|
|
2180
|
+
}
|
|
2181
|
+
else if (!e.shiftKey && (shadowActiveElement == lastFocusableElement || activeElement == lastFocusableElement)) {
|
|
2182
|
+
// shift + tab was pressed and current active element is the first focusable element
|
|
2183
|
+
e.preventDefault();
|
|
2184
|
+
firstFocusableElement.focus();
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
closeButtonSlot() {
|
|
2188
|
+
if (this.closable) {
|
|
2189
|
+
return (index.h("slot", { name: "modalCloseButton" }, index.h("button", { "aria-label": this.closeButtonLabel, onClick: () => this.close() }, index.h("z-icon", { name: "multiply-circle-filled" }))));
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
handleEscape(e) {
|
|
2193
|
+
if (this.closable) {
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2196
|
+
e.preventDefault();
|
|
2197
|
+
}
|
|
2198
|
+
render() {
|
|
2199
|
+
return (index.h("dialog", { class: {
|
|
2200
|
+
"modal-dialog": !this.scrollInside,
|
|
2201
|
+
}, "aria-labelledby": "modal-title", "aria-describedby": "modal-content", role: this.alertdialog ? "alertdialog" : undefined, ref: (el) => (this.dialog = el), onClose: () => this.emitModalClose(),
|
|
2202
|
+
// @ts-ignore
|
|
2203
|
+
onCancel: (e) => this.handleEscape(e) }, index.h("div", { class: {
|
|
2204
|
+
"modal-container": true,
|
|
2205
|
+
"modal-container-scroll-inside": this.scrollInside,
|
|
2206
|
+
"modal-container-scroll-outside": !this.scrollInside,
|
|
2207
|
+
}, id: this.modalid }, index.h("header", { onClick: this.emitModalHeaderActive.bind(this) }, index.h("div", null, this.modaltitle && index.h("h1", { id: "modal-title" }, this.modaltitle), this.closeButtonSlot()), this.modalsubtitle && index.h("h2", { id: "modal-subtitle" }, this.modalsubtitle)), index.h("div", { class: {
|
|
2208
|
+
"modal-content-scroll-inside": this.scrollInside,
|
|
2209
|
+
"modal-content-scroll-outside": !this.scrollInside,
|
|
2210
|
+
}, id: "modal-content" }, index.h("slot", { name: "modalContent" }))), index.h("div", { class: {
|
|
2211
|
+
"modal-background": true,
|
|
2212
|
+
"modal-background-scroll-outside": !this.scrollInside,
|
|
2213
|
+
}, "data-action": "modalBackground", "data-modal": this.modalid, onClick: () => {
|
|
2214
|
+
this.emitBackgroundClick();
|
|
2215
|
+
this.close();
|
|
2216
|
+
} })));
|
|
2217
|
+
}
|
|
2218
|
+
get host() { return index.getElement(this); }
|
|
2219
|
+
};
|
|
2220
|
+
ZModal.style = stylesCss$3;
|
|
2221
|
+
|
|
2222
|
+
const stylesCss$2 = ".sc-z-offcanvas-h{--z-offcanvas--container-width:375px;--z-offcanvas--top-space:0;min-width:100%;height:100%;font-family:var(--font-family-sans);font-weight:var(--font-rg);visibility:hidden}.canvas-container.sc-z-offcanvas{display:flex;overflow:-moz-scrollbars-none;overflow:hidden;min-width:100%;height:100%;flex-direction:column;background:var(--color-surface01)}[variant=\"pushcontent\"].sc-z-offcanvas-h{display:none}[open].sc-z-offcanvas-h{display:flex;visibility:visible}[variant=\"overlay\"].sc-z-offcanvas-h{position:fixed;z-index:1000;top:var(--z-offcanvas--top-space);right:0;bottom:0;left:0;display:flex;height:calc(100% - var(--z-offcanvas--top-space))}[variant=\"overlay\"][transitiondirection=\"left\"].sc-z-offcanvas-h{justify-content:end}[variant=\"overlay\"].sc-z-offcanvas-h>.canvas-container.sc-z-offcanvas{z-index:1010}[variant=\"overlay\"].sc-z-offcanvas-h .canvas-background.sc-z-offcanvas{position:absolute;left:0;width:100%;height:100%;background-color:var(--gray900);opacity:0.7}.canvas-container.sc-z-offcanvas>.canvas-content.sc-z-offcanvas{overflow:auto;flex:1 auto;padding:0 calc(var(--space-unit) * 2);margin:calc(var(--space-unit) * 2) calc(var(--space-unit) / 2) calc(var(--space-unit) * 2) 0;overflow-x:hidden}[variant=\"overlay\"].sc-z-offcanvas-h>.canvas-container.sc-z-offcanvas>.canvas-content.sc-z-offcanvas{padding:0 calc(var(--space-unit) * 2) calc(var(--space-unit) * 2) calc(var(--space-unit) * 2);margin:calc(var(--space-unit) * 2) calc(var(--space-unit) / 2) 0 0}.canvas-container.sc-z-offcanvas .canvas-content.sc-z-offcanvas::-webkit-scrollbar{width:10px;background:linear-gradient(to right, transparent 0 3px, var(--gray200) 3px 7px, transparent 7px 10px);border-radius:var(--border-radius)}.canvas-container.sc-z-offcanvas .canvas-content.sc-z-offcanvas::-webkit-scrollbar-track{background-color:transparent}.canvas-container.sc-z-offcanvas .canvas-content.sc-z-offcanvas::-webkit-scrollbar-thumb{width:10px;background-color:var(--color-primary01);border-radius:var(--border-radius)}.canvas-container.sc-z-offcanvas .canvas-content.sc-z-offcanvas::-webkit-scrollbar-thumb:hover{background-color:var(--color-hover-primary)}.canvas-container.sc-z-offcanvas .canvas-content.sc-z-offcanvas{scrollbar-color:var(--color-primary01) transparent}@media only screen and (max-width: 768px){[open][transitiondirection=\"left\"].sc-z-offcanvas-h:not(.skip-animation)>.canvas-container.sc-z-offcanvas{animation:enter-right 0.4s ease-out}[open][transitiondirection=\"right\"].sc-z-offcanvas-h:not(.skip-animation)>.canvas-container.sc-z-offcanvas{animation:enter-left 0.4s ease-out}}@media only screen and (min-width: 768px){.sc-z-offcanvas-h{min-width:auto}.canvas-container.sc-z-offcanvas{width:auto;min-width:max(var(--z-offcanvas--container-width), 375px);max-width:max(var(--z-offcanvas--container-width), 375px);height:auto;min-height:calc(var(--space-unit) * 40)}.sc-z-offcanvas-h:not([variant=\"overlay\"])[open]:not(.skip-animation){width:auto;animation:grow 0.4s ease-out}}@keyframes grow{from{width:0}to{width:max(var(--z-offcanvas--container-width), 375px)}}@keyframes enter-left{from{transform:translateX(-100%)}to{transform:translateX(0)}}@keyframes enter-right{from{transform:translateX(100%)}to{transform:translateX(0)}}[open][variant=\"overlay\"][transitiondirection=\"left\"].sc-z-offcanvas-h:not(.skip-animation)>.canvas-container.sc-z-offcanvas{animation:enter-right 0.4s ease-out}[open][transitiondirection=\"right\"].sc-z-offcanvas-h:not(.skip-animation)>.canvas-container.sc-z-offcanvas{animation:enter-left 0.4s ease-out}.sc-z-offcanvas-h:not([open])[variant=\"overlay\"][transitiondirection=\"right\"]>.canvas-container.sc-z-offcanvas{transform:translateX(-100%);transition:visibility 0.4s ease-out, transform 0.4s ease-out}.sc-z-offcanvas-h:not([open])[variant=\"overlay\"][transitiondirection=\"left\"]>.canvas-container.sc-z-offcanvas{transform:translateX(100%);transition:visibility 0.4s ease-out, transform 0.4s ease-out}.sc-z-offcanvas-h:not([open])[variant=\"overlay\"] .canvas-background.sc-z-offcanvas{transition:visibility 0.4s ease-out;visibility:hidden}";
|
|
2223
|
+
|
|
2224
|
+
const ZOffcanvas = class {
|
|
2225
|
+
constructor(hostRef) {
|
|
2226
|
+
index.registerInstance(this, hostRef);
|
|
2227
|
+
this.canvasOpenStatusChanged = index.createEvent(this, "canvasOpenStatusChanged", 7);
|
|
2228
|
+
/**
|
|
2229
|
+
* Offcanvas variant.
|
|
2230
|
+
* Can be one `overlay` or `pushcontent`.
|
|
2231
|
+
* Default variant: pushcontent
|
|
2232
|
+
*/
|
|
2233
|
+
this.variant = index$1.OffCanvasVariant.PUSHCONTENT;
|
|
2234
|
+
/** Whether the offcanvas is open. Default: false */
|
|
2235
|
+
this.open = false;
|
|
2236
|
+
/** open content transitioning in a specified direction left | right. Default: left */
|
|
2237
|
+
this.transitiondirection = index$1.TransitionDirection.LEFT;
|
|
2238
|
+
/**
|
|
2239
|
+
* Whether to skip the initial animation.
|
|
2240
|
+
* Useful when the initial value of the `open` prop is set to `true`.
|
|
2241
|
+
*/
|
|
2242
|
+
this.skipLoadAnimation = false;
|
|
2243
|
+
}
|
|
2244
|
+
onOpenChanged() {
|
|
2245
|
+
if (!this.open && this.skipLoadAnimation) {
|
|
2246
|
+
this.skipLoadAnimation = false;
|
|
2247
|
+
}
|
|
2248
|
+
if (this.open) {
|
|
2249
|
+
this.handlePageOverflow();
|
|
2250
|
+
}
|
|
2251
|
+
this.canvasOpenStatusChanged.emit(this.open);
|
|
2252
|
+
}
|
|
2253
|
+
handlePageOverflow() {
|
|
2254
|
+
const overflow = this.variant === index$1.OffCanvasVariant.OVERLAY ? "overflow-y" : "overflow-x";
|
|
2255
|
+
document.body.style[overflow] = this.open ? "hidden" : "";
|
|
2256
|
+
}
|
|
2257
|
+
render() {
|
|
2258
|
+
return (index.h(index.Host, { class: { "skip-animation": this.skipLoadAnimation } }, index.h("div", { role: "presentation", class: "canvas-container", onTransitionEnd: () => this.handlePageOverflow() }, index.h("div", { role: "presentation", class: "canvas-content" }, index.h("slot", { name: "canvasContent" }))), this.variant == index$1.OffCanvasVariant.OVERLAY && (index.h("div", { class: "canvas-background", "data-action": "canvasBackground", onClick: () => (this.open = false) }))));
|
|
2259
|
+
}
|
|
2260
|
+
static get watchers() { return {
|
|
2261
|
+
"open": ["onOpenChanged"]
|
|
2262
|
+
}; }
|
|
2263
|
+
};
|
|
2264
|
+
ZOffcanvas.style = stylesCss$2;
|
|
2265
|
+
|
|
2266
|
+
const stylesCss$1 = ":host{z-index:10;display:flex;column-gap:calc(var(--space-unit) * 2);font-family:var(--font-family-sans);font-weight:var(--font-rg)}:host,*{box-sizing:border-box}.input-container{position:relative;display:flex;width:100%;flex-direction:column}.results-wrapper{position:absolute;top:calc(100% - 1px);left:0;width:100%;padding:calc(var(--space-unit) / 4);border:var(--border-size-small) solid var(--color-surface03);border-top:none;background:var(--color-surface01)}.results{overflow:auto;max-height:var(--z-searchbar-results-height, 540px);padding:calc(var(--space-unit) / 2) calc(var(--space-unit) * 1.5);scrollbar-color:var(--color-primary01) transparent}.results::-webkit-scrollbar{width:10px;background:linear-gradient(to right, transparent 0 3px, var(--gray200) 3px 7px, transparent 7px 10px);border-radius:var(--border-radius)}.results::-webkit-scrollbar-track{background-color:transparent}.results::-webkit-scrollbar-thumb{width:10px;background-color:var(--color-primary01);border-radius:var(--border-radius)}.results .category-heading{display:block;font-size:var(--font-size-2);font-weight:var(--font-rg);line-height:var(--font-size-3)}.results .category-heading>*{display:block}.results .category-heading>.category{color:var(--color-text05);font-style:italic}.results .category-heading>.subcategory{margin-top:var(--space-unit);color:var(--color-text01);text-transform:uppercase}.results z-list-element{display:block}.results .item{--z-icon-height:12px;--z-icon-width:12px;display:flex;flex-flow:row nowrap;align-items:center;justify-content:flex-start;color:var(--color-text01);column-gap:calc(var(--space-unit) * 1.5);fill:var(--color-icon02);font-size:var(--font-size-2);line-height:var(--font-size-3)}.results .item.ellipsis>.item-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.results .item>.item-label mark{background:var(--color-primary03)}.results .item.has-category{padding-left:calc(var(--space-unit) * 3)}.results .item.item-search{--z-icon-height:16px;--z-icon-width:16px}.results .item-show-all{text-align:center}.results .item-no-results{display:block;font-size:var(--font-size-2);font-style:italic;line-height:var(--font-size-5)}.results .item-no-results>ul{padding-left:calc(var(--space-unit) * 2);margin:var(--space-unit)}@media (min-width: 768px){.results .category-heading{font-size:var(--font-size-3);line-height:var(--font-size-6)}.results .item{font-size:var(--font-size-3);line-height:var(--font-size-6)}.results .item.item-search{--z-icon-height:18px;--z-icon-width:18px}.results .item.ellipsis>.item-label{height:24px}}@media (min-width: 1152px){.results .item{cursor:pointer}.results .item-no-results{cursor:default;font-size:var(--font-size-3);line-height:var(--font-size-6)}}:host([size=\"small\"]) .results :is(.item,.category-heading),:host([size=\"x-small\"]) .results :is(.item,.category-heading){font-size:var(--font-size-2)}:host([size=\"small\"]) .results .item:not(.has-category),:host([size=\"x-small\"]) .results .item:not(.has-category){--z-icon-height:16px;--z-icon-width:16px}:host([size=\"small\"])::part(list-item-container){min-height:calc(var(--space-unit) * 4.5);padding:0}:host([size=\"x-small\"])::part(list-item-container){min-height:calc(var(--space-unit) * 4);padding:0}";
|
|
2267
|
+
|
|
2268
|
+
const ZSearchbar = class {
|
|
2269
|
+
constructor(hostRef) {
|
|
2270
|
+
index.registerInstance(this, hostRef);
|
|
2271
|
+
this.searchSubmit = index.createEvent(this, "searchSubmit", 7);
|
|
2272
|
+
this.searchTyping = index.createEvent(this, "searchTyping", 7);
|
|
2273
|
+
this.searchItemClick = index.createEvent(this, "searchItemClick", 7);
|
|
2274
|
+
/** the id of the searchbar element */
|
|
2275
|
+
this.htmlid = `searchbar-${utils$1.randomId()}`;
|
|
2276
|
+
/** Prevent submit action */
|
|
2277
|
+
this.preventSubmit = false;
|
|
2278
|
+
/** Show autocomplete results */
|
|
2279
|
+
this.autocomplete = false;
|
|
2280
|
+
/** Minimun number of characters to dispatch typing event */
|
|
2281
|
+
this.autocompleteMinChars = 3;
|
|
2282
|
+
/** Truncate results to single row */
|
|
2283
|
+
this.resultsEllipsis = true;
|
|
2284
|
+
/** Search helper text */
|
|
2285
|
+
this.searchHelperLabel = "Cerca {searchString}";
|
|
2286
|
+
/** Sort autocomplete results items */
|
|
2287
|
+
this.sortResultsItems = false;
|
|
2288
|
+
/** Show submit button */
|
|
2289
|
+
this.showSearchButton = false;
|
|
2290
|
+
/** Set button icon without label*/
|
|
2291
|
+
this.searchButtonIconOnly = false;
|
|
2292
|
+
/** Available sizes: `big`, `small` and `x-small`. Defaults to `big`. */
|
|
2293
|
+
this.size = index$1.ControlSize.BIG;
|
|
2294
|
+
/** Graphical variant: `primary`, `secondary`, `tertiary`. Defaults to `primary`. */
|
|
2295
|
+
this.variant = index$1.ButtonVariant.PRIMARY;
|
|
2296
|
+
this.searchString = this.value;
|
|
2297
|
+
this.currResultsCount = 0;
|
|
2298
|
+
this.showResults = false;
|
|
2299
|
+
this.resultsItemsList = null;
|
|
2300
|
+
}
|
|
2301
|
+
emitSearchSubmit() {
|
|
2302
|
+
this.searchSubmit.emit(this.inputRef.value);
|
|
2303
|
+
}
|
|
2304
|
+
emitSearchTyping(search) {
|
|
2305
|
+
this.searchTyping.emit(search);
|
|
2306
|
+
}
|
|
2307
|
+
emitSearchItemClick(item) {
|
|
2308
|
+
this.searchItemClick.emit(item);
|
|
2309
|
+
}
|
|
2310
|
+
watchItems() {
|
|
2311
|
+
this.resultsItemsList = this.getResultsItemsList();
|
|
2312
|
+
}
|
|
2313
|
+
watchResultsCount() {
|
|
2314
|
+
this.currResultsCount = this.resultsCount;
|
|
2315
|
+
}
|
|
2316
|
+
watchValue() {
|
|
2317
|
+
this.searchString = this.value;
|
|
2318
|
+
}
|
|
2319
|
+
watchSearchString() {
|
|
2320
|
+
this.emitSearchTyping(this.searchString);
|
|
2321
|
+
if (!this.searchString) {
|
|
2322
|
+
this.currResultsCount = this.resultsCount;
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
componentWillLoad() {
|
|
2326
|
+
this.resultsItemsList = this.getResultsItemsList();
|
|
2327
|
+
this.currResultsCount = this.resultsCount;
|
|
2328
|
+
}
|
|
2329
|
+
getResultsItemsList() {
|
|
2330
|
+
return typeof this.resultsItems === "string" ? JSON.parse(this.resultsItems) : this.resultsItems;
|
|
2331
|
+
}
|
|
2332
|
+
getGroupedItems(items) {
|
|
2333
|
+
const groupedItems = {};
|
|
2334
|
+
items.forEach((item) => {
|
|
2335
|
+
var _a;
|
|
2336
|
+
const key = `${item === null || item === void 0 ? void 0 : item.category}${item === null || item === void 0 ? void 0 : item.subcategory}`;
|
|
2337
|
+
groupedItems[key] = (_a = groupedItems[key]) !== null && _a !== void 0 ? _a : {
|
|
2338
|
+
category: item === null || item === void 0 ? void 0 : item.category,
|
|
2339
|
+
subcategory: item === null || item === void 0 ? void 0 : item.subcategory,
|
|
2340
|
+
items: [],
|
|
2341
|
+
};
|
|
2342
|
+
groupedItems[key]["items"].push(item);
|
|
2343
|
+
});
|
|
2344
|
+
if (this.sortResultsItems) {
|
|
2345
|
+
return Object.keys(groupedItems)
|
|
2346
|
+
.sort()
|
|
2347
|
+
.reduce((obj, key) => {
|
|
2348
|
+
obj[key] = Object.assign(Object.assign({}, groupedItems[key]), { items: groupedItems[key]["items"].sort((a, b) => {
|
|
2349
|
+
const nameA = a.label.toUpperCase();
|
|
2350
|
+
const nameB = b.label.toUpperCase();
|
|
2351
|
+
if (nameA < nameB) {
|
|
2352
|
+
return -1;
|
|
2353
|
+
}
|
|
2354
|
+
if (nameA > nameB) {
|
|
2355
|
+
return 1;
|
|
2356
|
+
}
|
|
2357
|
+
return 0;
|
|
2358
|
+
}) });
|
|
2359
|
+
return obj;
|
|
2360
|
+
}, {});
|
|
2361
|
+
}
|
|
2362
|
+
return groupedItems;
|
|
2363
|
+
}
|
|
2364
|
+
checkResultsCount(counter) {
|
|
2365
|
+
if (!this.currResultsCount || counter < this.currResultsCount) {
|
|
2366
|
+
return true;
|
|
2367
|
+
}
|
|
2368
|
+
return false;
|
|
2369
|
+
}
|
|
2370
|
+
handleStopTyping(e) {
|
|
2371
|
+
e.stopPropagation();
|
|
2372
|
+
this.searchString = e.detail.value;
|
|
2373
|
+
}
|
|
2374
|
+
handleSubmit() {
|
|
2375
|
+
if (this.preventSubmit) {
|
|
2376
|
+
return;
|
|
2377
|
+
}
|
|
2378
|
+
this.emitSearchSubmit();
|
|
2379
|
+
}
|
|
2380
|
+
handleOutsideClick(e) {
|
|
2381
|
+
const cp = e.composedPath();
|
|
2382
|
+
const searchbar = cp.find((elem) => elem.nodeName === "Z-SEARCHBAR");
|
|
2383
|
+
if (!searchbar || searchbar.htmlid !== this.htmlid) {
|
|
2384
|
+
this.showResults = false;
|
|
2385
|
+
return;
|
|
2386
|
+
}
|
|
2387
|
+
if (cp.find((elem) => { var _a; return (elem === null || elem === void 0 ? void 0 : elem.nodeName) === "Z-INPUT" || ((_a = elem === null || elem === void 0 ? void 0 : elem.classList) === null || _a === void 0 ? void 0 : _a.contains("results")); })) {
|
|
2388
|
+
this.showResults = true;
|
|
2389
|
+
return;
|
|
2390
|
+
}
|
|
2391
|
+
this.showResults = false;
|
|
2392
|
+
}
|
|
2393
|
+
renderInput() {
|
|
2394
|
+
return (index.h("z-input", { ref: (val) => {
|
|
2395
|
+
this.inputRef = val;
|
|
2396
|
+
}, message: false, placeholder: this.placeholder, onStopTyping: (e) => this.handleStopTyping(e), onKeyUp: (e) => utils$1.handleEnterKeydSubmit(e, () => this.handleSubmit()), value: this.value, size: this.size }));
|
|
2397
|
+
}
|
|
2398
|
+
renderButton() {
|
|
2399
|
+
if (!this.showSearchButton) {
|
|
2400
|
+
return null;
|
|
2401
|
+
}
|
|
2402
|
+
const iconProp = this.searchButtonIconOnly ? { icon: "search" } : null;
|
|
2403
|
+
const buttonLabel = this.searchButtonIconOnly ? "" : "CERCA";
|
|
2404
|
+
const defaultProps = Object.assign({ disabled: this.preventSubmit, variant: this.variant, size: this.size, onClick: () => this.handleSubmit() }, iconProp);
|
|
2405
|
+
return index.h("z-button", Object.assign({}, defaultProps), buttonLabel);
|
|
2406
|
+
}
|
|
2407
|
+
renderResults() {
|
|
2408
|
+
if (!this.showResults ||
|
|
2409
|
+
!this.autocomplete ||
|
|
2410
|
+
!this.searchString ||
|
|
2411
|
+
this.searchString.length < this.autocompleteMinChars ||
|
|
2412
|
+
!this.resultsItemsList) {
|
|
2413
|
+
return null;
|
|
2414
|
+
}
|
|
2415
|
+
return (index.h("div", { class: "results-wrapper" }, index.h("div", { class: "results" }, this.renderResultsList())));
|
|
2416
|
+
}
|
|
2417
|
+
renderResultsList() {
|
|
2418
|
+
var _a, _b;
|
|
2419
|
+
if (this.preventSubmit && !((_a = this.resultsItemsList) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
2420
|
+
return (index.h("span", { class: "item item-no-results" }, "Non abbiamo trovato risultati per ", index.h("b", null, this.searchString), index.h("br", null), index.h("br", null), "Cosa puoi fare?", index.h("ul", null, index.h("li", null, "Verificare di aver scritto bene"), index.h("li", null, "Provare a cercare un'altra parola"), index.h("li", null, "Provare a cercare qualcosa di pi\u00F9 generico"))));
|
|
2421
|
+
}
|
|
2422
|
+
return (index.h("z-list", { role: "listbox", id: `list-${this.htmlid}` }, this.renderSearchHelper(!!((_b = this.resultsItemsList) === null || _b === void 0 ? void 0 : _b.length)), this.renderItems(), this.renderShowAllResults()));
|
|
2423
|
+
}
|
|
2424
|
+
renderItems() {
|
|
2425
|
+
var _a;
|
|
2426
|
+
if (!((_a = this.resultsItemsList) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
2427
|
+
return [];
|
|
2428
|
+
}
|
|
2429
|
+
const groupedItems = this.getGroupedItems(this.resultsItemsList);
|
|
2430
|
+
const listGroups = [];
|
|
2431
|
+
let counter = 0;
|
|
2432
|
+
Object.values(groupedItems).forEach((groupItem, index$2, array) => {
|
|
2433
|
+
if (this.checkResultsCount(counter)) {
|
|
2434
|
+
const listGroupsElements = [];
|
|
2435
|
+
groupItem.items.forEach((item, subindex, subarray) => {
|
|
2436
|
+
if (this.checkResultsCount(counter)) {
|
|
2437
|
+
const isLast = index$2 === array.length - 1 && subindex === subarray.length - 1;
|
|
2438
|
+
listGroupsElements.push(this.renderItem(item, subindex, !isLast));
|
|
2439
|
+
}
|
|
2440
|
+
counter++;
|
|
2441
|
+
});
|
|
2442
|
+
if (listGroupsElements.length) {
|
|
2443
|
+
listGroups.push(index.h("z-list-group", { "divider-type": index$1.ListDividerType.ELEMENT }, this.renderItemCategory(groupItem), listGroupsElements));
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
});
|
|
2447
|
+
return listGroups;
|
|
2448
|
+
}
|
|
2449
|
+
renderItem(item, key, divider) {
|
|
2450
|
+
return (index.h("z-list-element", { id: `list-item-${this.htmlid}-${key}`, role: "option", tabindex: 0, dividerType: divider ? index$1.ListDividerType.ELEMENT : undefined, clickable: true, onClickItem: () => this.emitSearchItemClick(item) }, index.h("span", { class: { "item": true, "ellipsis": this.resultsEllipsis, "has-category": !!item.category } }, (item === null || item === void 0 ? void 0 : item.icon) && (index.h("z-icon", { class: "item-icon", name: item.icon })), index.h("span", { class: "item-label", title: item.label, innerHTML: this.renderItemLabel(item.label) }))));
|
|
2451
|
+
}
|
|
2452
|
+
renderItemLabel(label) {
|
|
2453
|
+
if (!this.searchString) {
|
|
2454
|
+
return label;
|
|
2455
|
+
}
|
|
2456
|
+
return label.replace(new RegExp(this.searchString.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "gmi"), (found) => `<mark>${found}</mark>`);
|
|
2457
|
+
}
|
|
2458
|
+
renderItemCategory(groupItem) {
|
|
2459
|
+
if (!(groupItem === null || groupItem === void 0 ? void 0 : groupItem.category)) {
|
|
2460
|
+
return null;
|
|
2461
|
+
}
|
|
2462
|
+
return (index.h("span", { class: "category-heading", slot: "header-title" }, index.h("span", { class: "category" }, groupItem.category), (groupItem === null || groupItem === void 0 ? void 0 : groupItem.subcategory) && index.h("span", { class: "subcategory" }, groupItem.subcategory)));
|
|
2463
|
+
}
|
|
2464
|
+
renderSearchHelper(hasDivider = true) {
|
|
2465
|
+
if (!this.autocomplete || this.preventSubmit || !this.searchString) {
|
|
2466
|
+
return null;
|
|
2467
|
+
}
|
|
2468
|
+
return (index.h("z-list-element", { role: "option", tabindex: 0, dividerType: hasDivider ? index$1.ListDividerType.ELEMENT : undefined, clickable: true, id: `list-item-${this.htmlid}-search`, onClickItem: () => this.emitSearchSubmit() }, index.h("span", { class: "item item-search" }, index.h("z-icon", { class: "search-icon", name: "left-magnifying-glass" }), index.h("span", { class: "item-label", innerHTML: this.searchHelperLabel.replace("{searchString}", `<mark>${this.searchString}</mark>`) }))));
|
|
2469
|
+
}
|
|
2470
|
+
renderShowAllResults() {
|
|
2471
|
+
var _a, _b;
|
|
2472
|
+
if (!this.currResultsCount ||
|
|
2473
|
+
!this.searchString ||
|
|
2474
|
+
!((_a = this.resultsItemsList) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
2475
|
+
this.currResultsCount >= ((_b = this.resultsItemsList) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
2476
|
+
return null;
|
|
2477
|
+
}
|
|
2478
|
+
return (index.h("z-list-element", { role: "option", tabindex: 0, clickable: true, id: `list-item-${this.htmlid}-show-all`, onClickItem: () => (this.currResultsCount = 0), color: "color-primary01" }, index.h("div", { class: "item-show-all" }, "Vedi tutti i risultati")));
|
|
2479
|
+
}
|
|
2480
|
+
render() {
|
|
2481
|
+
return (index.h(index.Host, { onFocus: () => (this.showResults = true), onClick: (e) => this.handleOutsideClick(e), class: { "has-submit": this.showSearchButton, "has-results": this.autocomplete } }, index.h("div", { class: "input-container" }, this.renderInput(), this.renderResults()), this.renderButton()));
|
|
2482
|
+
}
|
|
2483
|
+
static get watchers() { return {
|
|
2484
|
+
"resultsItems": ["watchItems"],
|
|
2485
|
+
"resultsCount": ["watchResultsCount"],
|
|
2486
|
+
"value": ["watchValue"],
|
|
2487
|
+
"searchString": ["watchSearchString"]
|
|
2488
|
+
}; }
|
|
2489
|
+
};
|
|
2490
|
+
ZSearchbar.style = stylesCss$1;
|
|
2491
|
+
|
|
2492
|
+
const stylesCss = ".sc-z-select-h{display:inline-block;width:inherit;color:var(--color-text02);font-family:var(--font-family-sans);font-size:var(--font-size-3);font-weight:var(--font-rg)}[size=\"small\"].sc-z-select-h,[size=\"x-small\"].sc-z-select-h{font-size:var(--font-size-2)}.select-wrapper.sc-z-select>z-input.sc-z-select{width:100%}.select-wrapper.sc-z-select>div.sc-z-select{position:relative}.select-wrapper.sc-z-select>div.closed.sc-z-select{overflow:hidden;height:0}.select-wrapper.sc-z-select .ul-scroll-wrapper.sc-z-select{position:absolute;width:100%;box-sizing:border-box;padding:calc(var(--space-unit) * 0.5) var(--space-unit);border:var(--border-size-small) solid var(--gray200);border-top:none;background:var(--color-surface01);outline:none}.select-wrapper.sc-z-select .closed.sc-z-select .ul-scroll-wrapper.sc-z-select{z-index:10}.select-wrapper.sc-z-select .open.sc-z-select .ul-scroll-wrapper.sc-z-select{z-index:20}.select-wrapper.sc-z-select .ul-scroll-wrapper.fixed.sc-z-select{position:static}.select-wrapper.sc-z-select .ul-scroll-wrapper.sc-z-select>z-list.sc-z-select{position:relative;overflow:auto;max-height:240px;padding:calc(var(--space-unit) * 0.5);outline:none;scrollbar-color:var(--color-primary01) transparent}.select-wrapper.sc-z-select .ul-scroll-wrapper.sc-z-select>z-list.sc-z-select::-webkit-scrollbar{width:10px;background:linear-gradient(to right, transparent 0 3px, var(--gray200) 3px 7px, transparent 7px 10px);border-radius:var(--border-radius)}.select-wrapper.sc-z-select .ul-scroll-wrapper.sc-z-select>z-list.sc-z-select::-webkit-scrollbar-track{background-color:transparent}.select-wrapper.sc-z-select .ul-scroll-wrapper.sc-z-select>z-list.sc-z-select::-webkit-scrollbar-thumb{width:10px;background-color:var(--color-primary01);border-radius:var(--border-radius)}.select-wrapper.sc-z-select .ul-scroll-wrapper.sc-z-select>z-list.sc-z-select::-webkit-scrollbar-thumb:hover{background-color:var(--color-hover-primary)}.select-wrapper.sc-z-select .ul-scroll-wrapper.sc-z-select z-list.sc-z-select z-list-element.sc-z-select .list-element-content.sc-z-select{display:block;padding:calc(var(--space-unit) * 0.5) calc(var(--space-unit) * 1.5)}[size=\"x-small\"].sc-z-select-h .select-wrapper.sc-z-select .ul-scroll-wrapper.sc-z-select z-list.sc-z-select z-list-element.sc-z-select .list-element-content.sc-z-select{padding:0 calc(var(--space-unit) * 1.5)}.select-wrapper.sc-z-select .ul-scroll-wrapper.sc-z-select z-list.sc-z-select z-list-element.sc-z-select .list-element-content.selected.sc-z-select{font-weight:bold}.select-wrapper.sc-z-select .ul-scroll-wrapper.sc-z-select .no-results.sc-z-select z-icon.sc-z-select{margin-right:var(--space-unit)}.z-list-group-title.sc-z-select{color:var(--gray800)}.reset-item.sc-z-select{color:var(--color-primary01);fill:var(--color-primary01)}.reset-item-content.sc-z-select{display:flex;align-items:center}.reset-item.reset-item-margin.sc-z-select .reset-item-content.sc-z-select{margin-left:calc(var(--space-unit))}.reset-item.sc-z-select .reset-item-content.sc-z-select>z-icon.sc-z-select{margin-right:var(--space-unit)}.reset-item.hide.sc-z-select{display:none}";
|
|
2493
|
+
|
|
2494
|
+
const ZSelect = class {
|
|
2495
|
+
constructor(hostRef) {
|
|
2496
|
+
index.registerInstance(this, hostRef);
|
|
2497
|
+
this.optionSelect = index.createEvent(this, "optionSelect", 7);
|
|
2498
|
+
this.resetSelect = index.createEvent(this, "resetSelect", 7);
|
|
2499
|
+
/** the id of the input element */
|
|
2500
|
+
this.htmlid = `id-${utils$1.randomId()}`;
|
|
2501
|
+
/** the input aria-label */
|
|
2502
|
+
this.ariaLabel = "";
|
|
2503
|
+
/** the input is disabled */
|
|
2504
|
+
this.disabled = false;
|
|
2505
|
+
/** the input is readonly */
|
|
2506
|
+
this.readonly = false;
|
|
2507
|
+
/** input helper message (optional) - if set to `false` message won't be displayed */
|
|
2508
|
+
this.message = true;
|
|
2509
|
+
/** the input has autocomplete option */
|
|
2510
|
+
this.autocomplete = false;
|
|
2511
|
+
/** no result text message */
|
|
2512
|
+
this.noresultslabel = "Nessun risultato";
|
|
2513
|
+
/** When fixed, it occupies space and pushes down next elements. */
|
|
2514
|
+
this.isfixed = false;
|
|
2515
|
+
/** Available sizes: `big`, `small` and `x-small`. Defaults to `big`. */
|
|
2516
|
+
this.size = index$1.ControlSize.BIG;
|
|
2517
|
+
this.isOpen = false;
|
|
2518
|
+
this.selectedItem = null;
|
|
2519
|
+
this.itemsList = [];
|
|
2520
|
+
this.toggleSelectUl = this.toggleSelectUl.bind(this);
|
|
2521
|
+
this.selectItem = this.selectItem.bind(this);
|
|
2522
|
+
this.handleSelectFocus = this.handleSelectFocus.bind(this);
|
|
2523
|
+
}
|
|
2524
|
+
watchItems() {
|
|
2525
|
+
this.itemsList = this.getInitialItemsArray();
|
|
2526
|
+
this.selectedItem = this.itemsList.find((item) => item.selected);
|
|
2527
|
+
}
|
|
2528
|
+
/** get the input selected options */
|
|
2529
|
+
async getSelectedItem() {
|
|
2530
|
+
return this.selectedItem;
|
|
2531
|
+
}
|
|
2532
|
+
/** get the input value */
|
|
2533
|
+
async getValue() {
|
|
2534
|
+
return this.getSelectedValue();
|
|
2535
|
+
}
|
|
2536
|
+
/** set the input value */
|
|
2537
|
+
async setValue(value) {
|
|
2538
|
+
let values = [];
|
|
2539
|
+
if (typeof value === "string") {
|
|
2540
|
+
values.push(value);
|
|
2541
|
+
}
|
|
2542
|
+
else {
|
|
2543
|
+
values = value;
|
|
2544
|
+
}
|
|
2545
|
+
this.selectedItem = this.itemsList.find((item) => values.includes(item.id));
|
|
2546
|
+
}
|
|
2547
|
+
emitOptionSelect() {
|
|
2548
|
+
this.optionSelect.emit({
|
|
2549
|
+
id: this.htmlid,
|
|
2550
|
+
selected: this.getSelectedValue(),
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
2553
|
+
emitResetSelect() {
|
|
2554
|
+
this.resetSelect.emit({
|
|
2555
|
+
id: this.htmlid,
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
componentWillLoad() {
|
|
2559
|
+
this.watchItems();
|
|
2560
|
+
}
|
|
2561
|
+
componentWillRender() {
|
|
2562
|
+
this.filterItems(this.searchString);
|
|
2563
|
+
}
|
|
2564
|
+
getInitialItemsArray() {
|
|
2565
|
+
return typeof this.items === "string" ? JSON.parse(this.items) : this.items;
|
|
2566
|
+
}
|
|
2567
|
+
mapSelectedItemToItemsArray() {
|
|
2568
|
+
const initialItemsList = this.getInitialItemsArray();
|
|
2569
|
+
return initialItemsList.map((item) => {
|
|
2570
|
+
var _a;
|
|
2571
|
+
item.selected = item.id === ((_a = this.selectedItem) === null || _a === void 0 ? void 0 : _a.id);
|
|
2572
|
+
return item;
|
|
2573
|
+
});
|
|
2574
|
+
}
|
|
2575
|
+
getSelectedValue() {
|
|
2576
|
+
var _a;
|
|
2577
|
+
return (_a = this.selectedItem) === null || _a === void 0 ? void 0 : _a.id;
|
|
2578
|
+
}
|
|
2579
|
+
filterItems(searchString) {
|
|
2580
|
+
const prevList = this.mapSelectedItemToItemsArray();
|
|
2581
|
+
if (!(searchString === null || searchString === void 0 ? void 0 : searchString.length)) {
|
|
2582
|
+
this.itemsList = prevList;
|
|
2583
|
+
}
|
|
2584
|
+
else {
|
|
2585
|
+
this.itemsList = prevList
|
|
2586
|
+
.filter((item) => {
|
|
2587
|
+
return item.name.toUpperCase().includes(searchString.toUpperCase());
|
|
2588
|
+
})
|
|
2589
|
+
.map((item) => {
|
|
2590
|
+
const start = item.name.toUpperCase().indexOf(searchString.toUpperCase());
|
|
2591
|
+
const end = start + searchString.length;
|
|
2592
|
+
const newName = item.name.substring(0, start) +
|
|
2593
|
+
`<strong>${item.name.substring(start, end)}</strong>` +
|
|
2594
|
+
item.name.substring(end, item.name.length);
|
|
2595
|
+
item.name = newName;
|
|
2596
|
+
return item;
|
|
2597
|
+
});
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
hasAutocomplete() {
|
|
2601
|
+
return utils$1.boolean(this.autocomplete) === true;
|
|
2602
|
+
}
|
|
2603
|
+
handleInputChange(e) {
|
|
2604
|
+
this.searchString = e.detail.value;
|
|
2605
|
+
if (!this.isOpen) {
|
|
2606
|
+
this.toggleSelectUl();
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
selectItem(item, selected) {
|
|
2610
|
+
if (item && item.disabled) {
|
|
2611
|
+
return;
|
|
2612
|
+
}
|
|
2613
|
+
this.itemsList = this.mapSelectedItemToItemsArray();
|
|
2614
|
+
this.itemsList = this.itemsList.map((i) => {
|
|
2615
|
+
i.selected = false;
|
|
2616
|
+
if (i.id === (item === null || item === void 0 ? void 0 : item.id)) {
|
|
2617
|
+
i.selected = selected;
|
|
2618
|
+
}
|
|
2619
|
+
return i;
|
|
2620
|
+
});
|
|
2621
|
+
this.selectedItem = this.itemsList.find((item) => item.selected);
|
|
2622
|
+
this.emitOptionSelect();
|
|
2623
|
+
if (this.searchString) {
|
|
2624
|
+
this.searchString = null;
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
arrowsSelectNav(e, key) {
|
|
2628
|
+
const showResetIcon = this.resetItem && !!this.selectedItem;
|
|
2629
|
+
const arrows = [index$1.KeyboardCode.ARROW_DOWN, index$1.KeyboardCode.ARROW_UP];
|
|
2630
|
+
if (!arrows.includes(e.key)) {
|
|
2631
|
+
return;
|
|
2632
|
+
}
|
|
2633
|
+
e.preventDefault();
|
|
2634
|
+
e.stopPropagation();
|
|
2635
|
+
if (!this.isOpen) {
|
|
2636
|
+
this.toggleSelectUl();
|
|
2637
|
+
}
|
|
2638
|
+
let index;
|
|
2639
|
+
if (this.resetItem) {
|
|
2640
|
+
if (e.key === index$1.KeyboardCode.ARROW_DOWN) {
|
|
2641
|
+
index = key + 1 === this.itemsList.length + 1 ? +!showResetIcon : key + 1;
|
|
2642
|
+
}
|
|
2643
|
+
else if (e.key === index$1.KeyboardCode.ARROW_UP) {
|
|
2644
|
+
index = key <= +!showResetIcon ? this.itemsList.length : key - 1;
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
if (!this.resetItem) {
|
|
2648
|
+
if (e.key === index$1.KeyboardCode.ARROW_DOWN) {
|
|
2649
|
+
index = key + 1 === this.itemsList.length ? 0 : key + 1;
|
|
2650
|
+
}
|
|
2651
|
+
else if (e.key === index$1.KeyboardCode.ARROW_UP) {
|
|
2652
|
+
index = key <= 0 ? this.itemsList.length - 1 : key - 1;
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
this.focusSelectItem(index);
|
|
2656
|
+
}
|
|
2657
|
+
focusSelectItem(index) {
|
|
2658
|
+
const focusElem = this.element.querySelector(`#${this.htmlid}_${index}`);
|
|
2659
|
+
if (focusElem) {
|
|
2660
|
+
focusElem.focus();
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
toggleSelectUl(selfFocusOnClose = false) {
|
|
2664
|
+
if (this.disabled || this.readonly) {
|
|
2665
|
+
return;
|
|
2666
|
+
}
|
|
2667
|
+
if (!this.isOpen) {
|
|
2668
|
+
document.addEventListener("click", this.handleSelectFocus);
|
|
2669
|
+
document.addEventListener("keyup", this.handleSelectFocus);
|
|
2670
|
+
}
|
|
2671
|
+
else {
|
|
2672
|
+
document.removeEventListener("click", this.handleSelectFocus);
|
|
2673
|
+
document.removeEventListener("keyup", this.handleSelectFocus);
|
|
2674
|
+
if (selfFocusOnClose) {
|
|
2675
|
+
this.element.querySelector(`#${this.htmlid}_input`).focus();
|
|
2676
|
+
}
|
|
2677
|
+
}
|
|
2678
|
+
this.isOpen = !this.isOpen;
|
|
2679
|
+
}
|
|
2680
|
+
handleInputClick(e) {
|
|
2681
|
+
const cp = e.composedPath();
|
|
2682
|
+
const clearIcon = cp.find((item) => item.classList && item.classList.contains("reset-icon"));
|
|
2683
|
+
if (clearIcon) {
|
|
2684
|
+
e.stopPropagation();
|
|
2685
|
+
return;
|
|
2686
|
+
}
|
|
2687
|
+
this.toggleSelectUl();
|
|
2688
|
+
}
|
|
2689
|
+
handleSelectFocus(e) {
|
|
2690
|
+
if (e instanceof KeyboardEvent && e.key === index$1.KeyboardCode.ESC) {
|
|
2691
|
+
e.stopPropagation();
|
|
2692
|
+
return this.toggleSelectUl(true);
|
|
2693
|
+
}
|
|
2694
|
+
if (e instanceof KeyboardEvent && e.key !== index$1.KeyboardCode.TAB && e.key !== index$1.KeyboardCode.ENTER) {
|
|
2695
|
+
return;
|
|
2696
|
+
}
|
|
2697
|
+
const tree = utils$1.getElementTree(utils$1.getClickedElement());
|
|
2698
|
+
const parent = tree.find((elem) => {
|
|
2699
|
+
return elem.nodeName.toLowerCase() === "z-input" && elem.id === `${this.htmlid}_input`;
|
|
2700
|
+
});
|
|
2701
|
+
if (!parent) {
|
|
2702
|
+
this.toggleSelectUl(e instanceof MouseEvent ? true : false);
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
scrollToLetter(letter) {
|
|
2706
|
+
const foundItem = this.itemsList.find((item) => item.name.charAt(0) === letter);
|
|
2707
|
+
if (foundItem) {
|
|
2708
|
+
this.focusSelectItem(this.itemsList.indexOf(foundItem));
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
renderInput() {
|
|
2712
|
+
return (index.h("z-input", { class: {
|
|
2713
|
+
"active-select": this.isOpen,
|
|
2714
|
+
"cursor-select": !this.autocomplete,
|
|
2715
|
+
}, id: `${this.htmlid}_input`, htmlid: `${this.htmlid}_input`, placeholder: this.placeholder, value: !this.isOpen && this.selectedItem ? this.selectedItem.name.replace(/<[^>]+>/g, "") : null, label: this.label, "aria-label": this.ariaLabel, icon: this.isOpen ? "caret-up" : "caret-down", hasclearicon: this.hasAutocomplete(), message: false, disabled: this.disabled, readonly: this.readonly || (!this.hasAutocomplete() && this.isOpen), status: this.isOpen ? undefined : this.status, autocomplete: "off", size: this.size, onClick: (e) => {
|
|
2716
|
+
this.handleInputClick(e);
|
|
2717
|
+
}, onKeyUp: (e) => {
|
|
2718
|
+
if (e.keyCode !== 13) {
|
|
2719
|
+
e.preventDefault();
|
|
2720
|
+
}
|
|
2721
|
+
utils$1.handleKeyboardSubmit(e, this.toggleSelectUl);
|
|
2722
|
+
}, onKeyDown: (e) => {
|
|
2723
|
+
return this.arrowsSelectNav(e, this.selectedItem ? this.itemsList.indexOf(this.selectedItem) : this.resetItem ? 0 : -1);
|
|
2724
|
+
}, onInputChange: (e) => {
|
|
2725
|
+
this.handleInputChange(e);
|
|
2726
|
+
}, onKeyPress: (e) => {
|
|
2727
|
+
if (!this.hasAutocomplete()) {
|
|
2728
|
+
e.preventDefault();
|
|
2729
|
+
this.scrollToLetter(String.fromCharCode(e.keyCode));
|
|
2730
|
+
}
|
|
2731
|
+
} }));
|
|
2732
|
+
}
|
|
2733
|
+
renderSelectUl() {
|
|
2734
|
+
var _a;
|
|
2735
|
+
return (index.h("div", { class: this.isOpen ? "open" : "closed", tabindex: "-1" }, index.h("div", { class: {
|
|
2736
|
+
"ul-scroll-wrapper": true,
|
|
2737
|
+
"fixed": this.isfixed,
|
|
2738
|
+
}, tabindex: "-1" }, index.h("z-list", { role: "listbox", tabindex: this.disabled || this.readonly || !this.isOpen ? -1 : 0, id: this.htmlid, "aria-activedescendant": (_a = this.selectedItem) === null || _a === void 0 ? void 0 : _a.id, "aria-multiselectable": false, size: this.listSizeType(), class: {
|
|
2739
|
+
disabled: this.disabled,
|
|
2740
|
+
readonly: this.readonly,
|
|
2741
|
+
filled: !!this.selectedItem,
|
|
2742
|
+
[`input-${this.status}`]: !this.isOpen && !!this.status,
|
|
2743
|
+
} }, this.resetItem && this.renderResetItem(), this.renderSelectUlItems()))));
|
|
2744
|
+
}
|
|
2745
|
+
renderResetItem() {
|
|
2746
|
+
return (index.h("z-list-element", { class: {
|
|
2747
|
+
"hide": !this.selectedItem || !this.resetItem,
|
|
2748
|
+
"reset-item": true,
|
|
2749
|
+
"reset-item-margin": !this.hasGroupItems,
|
|
2750
|
+
}, clickable: true, disabled: false, dividerType: index$1.ListDividerType.ELEMENT, role: "option", tabindex: "0", "aria-selected": "false", id: `${this.htmlid}_${this.resetItem ? "0" : "none"}`, size: this.listSizeType(), onClickItem: () => {
|
|
2751
|
+
this.selectedItem = null;
|
|
2752
|
+
this.searchString = null;
|
|
2753
|
+
this.emitResetSelect();
|
|
2754
|
+
}, onKeyDown: (e) => this.arrowsSelectNav(e, 0) }, index.h("div", { class: "reset-item-content" }, index.h("z-icon", { name: "multiply-circled" }), index.h("span", null, this.resetItem))));
|
|
2755
|
+
}
|
|
2756
|
+
renderItem(item, key, lastItem) {
|
|
2757
|
+
return (index.h("z-list-element", { clickable: !item.disabled, disabled: item.disabled, dividerType: lastItem ? index$1.ListDividerType.HEADER : index$1.ListDividerType.ELEMENT, role: "option", tabindex: item.disabled || !this.isOpen ? -1 : 0, "aria-selected": !!item.selected, id: `${this.htmlid}_${key}`, size: this.listSizeType(), onClickItem: () => this.selectItem(item, true), onKeyDown: (e) => this.arrowsSelectNav(e, key) }, index.h("span", { class: {
|
|
2758
|
+
"selected": !!item.selected,
|
|
2759
|
+
"list-element-content": true,
|
|
2760
|
+
}, innerHTML: item.name })));
|
|
2761
|
+
}
|
|
2762
|
+
listSizeType() {
|
|
2763
|
+
if (this.size === index$1.ControlSize.SMALL || this.size === index$1.ControlSize.X_SMALL) {
|
|
2764
|
+
return index$1.ListSize.SMALL;
|
|
2765
|
+
}
|
|
2766
|
+
return index$1.ListSize.MEDIUM;
|
|
2767
|
+
}
|
|
2768
|
+
renderSelectUlItems() {
|
|
2769
|
+
if (!this.itemsList.length) {
|
|
2770
|
+
return this.renderNoSearchResults();
|
|
2771
|
+
}
|
|
2772
|
+
if (this.hasGroupItems) {
|
|
2773
|
+
return this.renderSelectGroupItems();
|
|
2774
|
+
}
|
|
2775
|
+
return this.itemsList.map((item, key, array) => {
|
|
2776
|
+
const lastItem = array.length === key + 1;
|
|
2777
|
+
const itemKey = this.resetItem ? key + 1 : key;
|
|
2778
|
+
return this.renderItem(item, itemKey, lastItem);
|
|
2779
|
+
});
|
|
2780
|
+
}
|
|
2781
|
+
renderSelectGroupItems() {
|
|
2782
|
+
const newData = this.itemsList.reduce((group, item, index, array) => {
|
|
2783
|
+
var _a;
|
|
2784
|
+
const { category } = item;
|
|
2785
|
+
const lastItem = array.length === index + 1;
|
|
2786
|
+
const itemKey = this.resetItem ? index + 1 : index;
|
|
2787
|
+
const zListItem = this.renderItem(item, itemKey, lastItem);
|
|
2788
|
+
group[category] = (_a = group[category]) !== null && _a !== void 0 ? _a : [];
|
|
2789
|
+
group[category].push(zListItem);
|
|
2790
|
+
return group;
|
|
2791
|
+
}, {});
|
|
2792
|
+
return Object.entries(newData).map(([key, value]) => {
|
|
2793
|
+
return (index.h("z-list-group", { "divider-type": index$1.ListDividerType.ELEMENT }, index.h("span", { class: "body-3-sb z-list-group-title", slot: "header-title" }, key), value.map((item) => item)));
|
|
2794
|
+
});
|
|
2795
|
+
}
|
|
2796
|
+
renderNoSearchResults() {
|
|
2797
|
+
return (index.h("z-list-element", { color: "blue500", class: "no-results", size: this.listSizeType() }, index.h("z-icon", { name: "multiply-circle", fill: "blue500" }), this.noresultslabel));
|
|
2798
|
+
}
|
|
2799
|
+
renderMessage() {
|
|
2800
|
+
if (utils$1.boolean(this.message) === false) {
|
|
2801
|
+
return;
|
|
2802
|
+
}
|
|
2803
|
+
return (index.h("z-input-message", { message: utils$1.boolean(this.message) === true ? undefined : this.message, status: this.status, class: this.size }));
|
|
2804
|
+
}
|
|
2805
|
+
render() {
|
|
2806
|
+
return (index.h("div", { class: "select-wrapper" }, this.renderInput(), this.renderSelectUl(), this.renderMessage()));
|
|
2807
|
+
}
|
|
2808
|
+
get element() { return index.getElement(this); }
|
|
2809
|
+
static get watchers() { return {
|
|
2810
|
+
"items": ["watchItems"]
|
|
2811
|
+
}; }
|
|
2812
|
+
};
|
|
2813
|
+
ZSelect.style = stylesCss;
|
|
2814
|
+
|
|
2815
|
+
exports.z_app_header = ZAppHeader;
|
|
2816
|
+
exports.z_button = ZButton;
|
|
2817
|
+
exports.z_date_picker = ZDatePicker;
|
|
2818
|
+
exports.z_divider = ZDivider;
|
|
2819
|
+
exports.z_icon = ZIcon;
|
|
2820
|
+
exports.z_input = ZInput;
|
|
2821
|
+
exports.z_input_message = ZInputMessage;
|
|
2822
|
+
exports.z_list = ZList;
|
|
2823
|
+
exports.z_list_element = ZListElement;
|
|
2824
|
+
exports.z_list_group = ZListGroup;
|
|
2825
|
+
exports.z_modal = ZModal;
|
|
2826
|
+
exports.z_offcanvas = ZOffcanvas;
|
|
2827
|
+
exports.z_searchbar = ZSearchbar;
|
|
2828
|
+
exports.z_select = ZSelect;
|