@zanichelli/albe-web-components 12.3.1-RC → 12.4.0-RC
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-195ca522.js +18 -10
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/web-components-library.cjs.js +1 -1
- package/dist/cjs/z-app-header.cjs.entry.js +185 -0
- package/dist/cjs/{z-dragdrop-area_2.cjs.entry.js → z-button_6.cjs.entry.js} +259 -2
- package/dist/cjs/z-chip.cjs.entry.js +1 -1
- package/dist/cjs/z-input_2.cjs.entry.js +289 -0
- package/dist/cjs/z-list_3.cjs.entry.js +270 -0
- package/dist/cjs/z-offcanvas_2.cjs.entry.js +281 -0
- package/dist/collection/components/buttons/z-chip/index.js +1 -1
- package/dist/collection/components/file-upload/z-dragdrop-area/styles.css +1 -0
- package/dist/collection/components/file-upload/z-file-upload/index.js +1 -1
- package/dist/collection/components/file-upload/z-file-upload/styles.css +11 -0
- package/dist/esm/index-4968ce56.js +18 -10
- package/dist/esm/{index-4d1853ea.js → index-df06f147.js} +1 -1
- package/dist/esm/{index-fb19ca57.js → index-e44342f3.js} +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{utils-2a4ef29d.js → utils-3d2372eb.js} +1 -1
- package/dist/esm/web-components-library.js +1 -1
- package/dist/esm/z-app-header.entry.js +181 -0
- package/dist/esm/z-book-card.entry.js +1 -1
- package/dist/esm/z-breadcrumb.entry.js +1 -1
- package/dist/esm/{z-dragdrop-area_2.entry.js → z-button_6.entry.js} +258 -5
- package/dist/esm/z-chip.entry.js +1 -1
- package/dist/esm/z-combobox.entry.js +1 -1
- package/dist/esm/z-input_2.entry.js +284 -0
- package/dist/esm/z-list_3.entry.js +264 -0
- 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-offcanvas_2.entry.js +276 -0
- package/dist/esm/z-pocket_3.entry.js +1 -1
- package/dist/esm/z-select.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/web-components-library/index.esm.js +1 -1
- package/dist/web-components-library/{p-100207d8.entry.js → p-0495fb84.entry.js} +1 -1
- package/dist/web-components-library/p-07854026.entry.js +1 -0
- package/dist/web-components-library/p-13762a32.entry.js +1 -0
- package/dist/web-components-library/{p-cc009af8.entry.js → p-17d4f729.entry.js} +1 -1
- package/dist/web-components-library/p-1b342136.entry.js +1 -0
- package/dist/web-components-library/p-1c541078.entry.js +1 -0
- package/dist/web-components-library/p-207467d2.entry.js +1 -0
- package/dist/web-components-library/p-285ec5fc.entry.js +1 -0
- package/dist/web-components-library/{p-98badafc.js → p-28b2868e.js} +1 -1
- package/dist/web-components-library/{p-5944a8f2.entry.js → p-29377b57.entry.js} +1 -1
- package/dist/web-components-library/p-29d45fe5.entry.js +1 -0
- package/dist/web-components-library/p-49d22e92.entry.js +1 -0
- package/dist/web-components-library/p-570e1a2e.entry.js +1 -0
- package/{www/build/p-485fd3db.entry.js → dist/web-components-library/p-6f281905.entry.js} +1 -1
- package/dist/web-components-library/{p-a1663ab1.entry.js → p-76e7d402.entry.js} +1 -1
- package/dist/web-components-library/p-8aaa0c34.entry.js +1 -0
- package/dist/web-components-library/{p-f5bc7dda.entry.js → p-a6af3c1d.entry.js} +1 -1
- package/dist/web-components-library/{p-f3cc3f27.entry.js → p-b0f9cf23.entry.js} +1 -1
- package/dist/web-components-library/{p-a01baa71.js → p-b921dc8d.js} +1 -1
- package/dist/web-components-library/p-d00d2e95.entry.js +1 -0
- package/dist/web-components-library/{p-cd561d69.js → p-d12d4dcd.js} +1 -1
- package/dist/web-components-library/{p-8c31e60b.entry.js → p-d51d7b44.entry.js} +1 -1
- package/dist/web-components-library/p-dc854830.entry.js +1 -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-100207d8.entry.js → p-0495fb84.entry.js} +1 -1
- package/www/build/p-07854026.entry.js +1 -0
- package/www/build/p-13762a32.entry.js +1 -0
- package/www/build/{p-cc009af8.entry.js → p-17d4f729.entry.js} +1 -1
- package/www/build/p-1b342136.entry.js +1 -0
- package/www/build/p-1c541078.entry.js +1 -0
- package/www/build/p-207467d2.entry.js +1 -0
- package/www/build/p-285ec5fc.entry.js +1 -0
- package/www/build/{p-98badafc.js → p-28b2868e.js} +1 -1
- package/www/build/{p-5944a8f2.entry.js → p-29377b57.entry.js} +1 -1
- package/www/build/p-29d45fe5.entry.js +1 -0
- package/www/build/p-49d22e92.entry.js +1 -0
- package/www/build/p-4a7a94e2.css +1576 -0
- package/www/build/p-570e1a2e.entry.js +1 -0
- package/{dist/web-components-library/p-485fd3db.entry.js → www/build/p-6f281905.entry.js} +1 -1
- package/www/build/{p-a1663ab1.entry.js → p-76e7d402.entry.js} +1 -1
- package/www/build/p-8aaa0c34.entry.js +1 -0
- package/www/build/{p-f5bc7dda.entry.js → p-a6af3c1d.entry.js} +1 -1
- package/www/build/{p-f3cc3f27.entry.js → p-b0f9cf23.entry.js} +1 -1
- package/www/build/{p-a01baa71.js → p-b921dc8d.js} +1 -1
- package/www/build/p-ce656c1c.js +129 -0
- package/www/build/p-d00d2e95.entry.js +1 -0
- package/www/build/{p-cd561d69.js → p-d12d4dcd.js} +1 -1
- package/www/build/{p-8c31e60b.entry.js → p-d51d7b44.entry.js} +1 -1
- package/www/build/p-dc854830.entry.js +1 -0
- package/www/build/web-components-library.esm.js +1 -1
- package/www/index.html +10 -1
- package/dist/cjs/z-app-header_11.cjs.entry.js +0 -1077
- package/dist/cjs/z-file-upload.cjs.entry.js +0 -189
- package/dist/esm/z-app-header_11.entry.js +0 -1063
- package/dist/esm/z-file-upload.entry.js +0 -185
- package/dist/web-components-library/p-03b13390.entry.js +0 -1
- package/dist/web-components-library/p-07d0e902.entry.js +0 -1
- package/dist/web-components-library/p-3327e5f0.entry.js +0 -1
- package/dist/web-components-library/p-51bfa8ba.entry.js +0 -1
- package/dist/web-components-library/p-7907bdf7.entry.js +0 -1
- package/dist/web-components-library/p-7c5ddeb0.entry.js +0 -1
- package/dist/web-components-library/p-9b0bcd43.entry.js +0 -1
- package/dist/web-components-library/p-bbd6cbca.entry.js +0 -1
- package/dist/web-components-library/p-ed42ceca.entry.js +0 -1
- package/dist/web-components-library/p-ff5a6e34.entry.js +0 -1
- package/www/build/p-03b13390.entry.js +0 -1
- package/www/build/p-07d0e902.entry.js +0 -1
- package/www/build/p-21a94605.css +0 -3
- package/www/build/p-3327e5f0.entry.js +0 -1
- package/www/build/p-51bfa8ba.entry.js +0 -1
- package/www/build/p-7907bdf7.entry.js +0 -1
- package/www/build/p-7c5ddeb0.entry.js +0 -1
- package/www/build/p-92d5fd28.js +0 -1
- package/www/build/p-9b0bcd43.entry.js +0 -1
- package/www/build/p-bbd6cbca.entry.js +0 -1
- package/www/build/p-ed42ceca.entry.js +0 -1
- package/www/build/p-ff5a6e34.entry.js +0 -1
|
@@ -4,8 +4,64 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-195ca522.js');
|
|
6
6
|
const index$1 = require('./index-cf9497bc.js');
|
|
7
|
+
const utils = require('./utils-ee86db4f.js');
|
|
8
|
+
const icons = require('./icons-d385b990.js');
|
|
9
|
+
require('./breakpoints-ebe1a437.js');
|
|
7
10
|
|
|
8
|
-
const stylesCss$
|
|
11
|
+
const stylesCss$5 = ".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:var(--color-primary02);background-color:var(--color-primary02);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-primary02);background-color:var(--color-primary02);color:var(--color-primary01)}[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button:active{border-color:var(--color-primary02);background-color:var(--color-primary02);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:var(--color-disabled01);background-color:var(--color-disabled01);color:var(--color-disabled02)}";
|
|
12
|
+
|
|
13
|
+
const ZButton = class {
|
|
14
|
+
constructor(hostRef) {
|
|
15
|
+
index.registerInstance(this, hostRef);
|
|
16
|
+
/** defines a string value that labels an interactive element, used for accessibility. */
|
|
17
|
+
this.ariaLabel = "";
|
|
18
|
+
/** HTML button disabled attribute. */
|
|
19
|
+
this.disabled = false;
|
|
20
|
+
/** HTML button type attribute. */
|
|
21
|
+
this.type = index$1.ButtonType.BUTTON;
|
|
22
|
+
/** Graphical variant: `primary`, `secondary`, `tertiary`. Defaults to `primary`. */
|
|
23
|
+
this.variant = index$1.ButtonVariant.PRIMARY;
|
|
24
|
+
/** Available sizes: `big`, `small` and `x-small`. Defaults to `big`. */
|
|
25
|
+
this.size = index$1.ControlSize.BIG;
|
|
26
|
+
}
|
|
27
|
+
getAttributes() {
|
|
28
|
+
return {
|
|
29
|
+
id: this.htmlid,
|
|
30
|
+
class: {
|
|
31
|
+
"z-button--container": true,
|
|
32
|
+
"z-button--has-text": !!this.hostElement.textContent.trim(),
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
if (this.href) {
|
|
38
|
+
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)));
|
|
39
|
+
}
|
|
40
|
+
return (index.h("button", Object.assign({}, this.getAttributes(), { "aria-label": this.ariaLabel, name: this.name, type: this.type, role: this.role, disabled: this.disabled }), this.icon && (index.h("z-icon", { name: this.icon, width: 16, height: 16 })), index.h("slot", null)));
|
|
41
|
+
}
|
|
42
|
+
get hostElement() { return index.getElement(this); }
|
|
43
|
+
};
|
|
44
|
+
ZButton.style = stylesCss$5;
|
|
45
|
+
|
|
46
|
+
const stylesCss$4 = ".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)}";
|
|
47
|
+
|
|
48
|
+
const ZDivider = class {
|
|
49
|
+
constructor(hostRef) {
|
|
50
|
+
index.registerInstance(this, hostRef);
|
|
51
|
+
/** [optional] Divider size */
|
|
52
|
+
this.size = index$1.DividerSize.SMALL;
|
|
53
|
+
/** [optional] Divider color */
|
|
54
|
+
this.color = "gray200";
|
|
55
|
+
/** [optional] Divider orintation */
|
|
56
|
+
this.orientation = index$1.DividerOrientation.HORIZONTAL;
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
return (index.h(index.Host, { class: `divider-${this.size} divider-${this.orientation}`, style: { backgroundColor: `var(--${this.color})` } }));
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
ZDivider.style = stylesCss$4;
|
|
63
|
+
|
|
64
|
+
const stylesCss$3 = ":host{font-family:var(--font-family-sans);font-weight:var(--font-rg)}:host>.dragdrop{position:relative;display:flex;height:228px;flex-direction:column;padding:calc(var(--space-unit) * 2);border-color:var(--color-surface04);background-color:var(--color-surface02);background-image:url(\"data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='2' ry='2' stroke='%23CACCCEFF' stroke-width='2' stroke-dasharray='15%2c 10%2c 14%2c 11' stroke-dashoffset='3' stroke-linecap='square'/%3e%3c/svg%3e\");border-radius:2px;color:var(--color-text01)}:host>.dragdrop.dragover *{pointer-events:none}:host>.dragdrop .dragover-container{position:absolute;z-index:10;top:0;left:0;display:none;width:100%;height:100%;background-color:var(--color-primary03);box-shadow:var(--shadow-focus-primary)}:host>.dragdrop .dragover-container .dragover-message{padding:10px 28px;background-color:var(--color-link-primary);color:var(--color-text04)}:host>.dragdrop.dragover .dragover-container{display:flex;align-items:center;justify-content:center}";
|
|
9
65
|
|
|
10
66
|
const ZDragdropArea = class {
|
|
11
67
|
constructor(hostRef) {
|
|
@@ -33,7 +89,204 @@ const ZDragdropArea = class {
|
|
|
33
89
|
} }, this.renderOnDragOverMessage(), index.h("slot", null)));
|
|
34
90
|
}
|
|
35
91
|
};
|
|
36
|
-
ZDragdropArea.style = stylesCss$
|
|
92
|
+
ZDragdropArea.style = stylesCss$3;
|
|
93
|
+
|
|
94
|
+
const stylesCss$2 = ":host{color:var(--color-text01);font-family:var(--font-family-sans);font-weight:var(--font-rg)}:host>.container{display:flex;flex-direction:column}:host .modal-wrapper{display:flex;align-items:center;justify-content:center;padding:calc(var(--space-unit) * 2)}:host .modal-wrapper>.files-wrapper{display:flex;flex-direction:column;margin:calc(var(--space-unit) * 4);gap:var(--space-unit)}:host .text-container{display:flex;flex-direction:column;margin:auto}:host .text-container .body-1{text-align:center}:host .text-container .upload-link{color:var(--color-link-primary);cursor:pointer}:host .text-container .upload-link-text{margin-bottom:var(--space-unit)}input#file-elem{display:none}#title{display:inline-block;margin:calc(var(--space-unit) * 2.5) 0 calc(var(--space-unit) * 4);font-size:calc(var(--space-unit) * 3);font-weight:var(--font-sb)}:host>.container>z-button{display:inline-block;margin-top:calc(var(--space-unit) * 3)}:host>.container>.files-container.hidden{display:none}:host>.container>.files-container>.heading-4-sb{display:inline-block;margin:calc(var(--space-unit) * 3) 0;font-size:calc(var(--space-unit) * 2);font-weight:var(--font-sb)}:host([type=\"dragdrop\"])>.container>.files-container>.heading-4-sb{margin-top:0;margin-bottom:calc(var(--space-unit) * 3)}:host>.container>.files-container>.files-wrapper{display:flex;flex-wrap:wrap;column-gap:calc(var(--space-unit) * 2);row-gap:calc(var(--space-unit) * 2)}:host>.container>.files-container>z-divider{margin-top:calc(var(--space-unit) * 3);margin-bottom:0}:host([type=\"dragdrop\"])>.container>.files-container>z-divider{margin:calc(var(--space-unit) * 3) 0}@media only screen and (min-width: 768px){:host>.container>z-button{align-self:flex-start}:host .modal-wrapper{padding:calc(var(--space-unit) * 3)}}@media only screen and (min-width: 1152px){:host .modal-wrapper{padding:calc(var(--space-unit) * 4)}}";
|
|
95
|
+
|
|
96
|
+
const ZFileUpload = class {
|
|
97
|
+
constructor(hostRef) {
|
|
98
|
+
index.registerInstance(this, hostRef);
|
|
99
|
+
this.fileInput = index.createEvent(this, "fileInput", 7);
|
|
100
|
+
/** Prop indicating the file upload type - can be default or dragdrop */
|
|
101
|
+
this.type = index$1.ZFileUploadType.DEFAULT;
|
|
102
|
+
/** Files added by the user */
|
|
103
|
+
this.files = [];
|
|
104
|
+
/** upoload button label */
|
|
105
|
+
this.uploadBtnLabel = "allega";
|
|
106
|
+
/** drag & drop button label */
|
|
107
|
+
this.dragAndDropLabel = "Rilascia i file in questa area per allegarli.";
|
|
108
|
+
this.inputAttributes = {
|
|
109
|
+
type: "file",
|
|
110
|
+
id: "file-elem",
|
|
111
|
+
multiple: true,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** Listen removeFile event sent from z-file component */
|
|
115
|
+
removeFileListener(e) {
|
|
116
|
+
const files = this.files;
|
|
117
|
+
const file = files.find((file) => file.name === e.detail.fileName);
|
|
118
|
+
if (file) {
|
|
119
|
+
const index = files.indexOf(file);
|
|
120
|
+
if (index >= 0) {
|
|
121
|
+
files.splice(index, 1);
|
|
122
|
+
this.files = [...files];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/** Listen fileDropped event sent from z-dragdrop-area component */
|
|
127
|
+
fileDroppedListener(e) {
|
|
128
|
+
this.input.files = e.detail;
|
|
129
|
+
this.fileInputHandler();
|
|
130
|
+
}
|
|
131
|
+
componentDidUpdate() {
|
|
132
|
+
this.handleAccessibility();
|
|
133
|
+
this.invalidFiles.size && this.errorModal.focus();
|
|
134
|
+
}
|
|
135
|
+
componentWillLoad() {
|
|
136
|
+
this.invalidFiles = new Map();
|
|
137
|
+
}
|
|
138
|
+
fileInputHandler() {
|
|
139
|
+
if (this.input.files.length) {
|
|
140
|
+
this.invalidFiles = this.checkFiles(Array.from(this.input.files));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** get array of uploaded files */
|
|
144
|
+
async getFiles() {
|
|
145
|
+
return this.files;
|
|
146
|
+
}
|
|
147
|
+
getType() {
|
|
148
|
+
if (utils.getDevice() !== index$1.Device.DESKTOP && utils.getDevice() !== index$1.Device.DESKTOP_WIDE) {
|
|
149
|
+
return index$1.ZFileUploadType.DEFAULT;
|
|
150
|
+
}
|
|
151
|
+
return this.type;
|
|
152
|
+
}
|
|
153
|
+
handleAccessibility() {
|
|
154
|
+
const lastFile = this.el.querySelector("z-file:last-child z-chip button");
|
|
155
|
+
if (this.files.length > 0 && lastFile) {
|
|
156
|
+
lastFile.focus();
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
this.getType() === index$1.ZFileUploadType.DEFAULT
|
|
160
|
+
? this.button.querySelector("button").focus()
|
|
161
|
+
: this.uploadLink.focus();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
checkFiles(files) {
|
|
165
|
+
const errors = new Map();
|
|
166
|
+
const sizeErrorString = `supera i ${this.fileMaxSize}MB`;
|
|
167
|
+
const formatErrorString = " ha un'estensione non prevista";
|
|
168
|
+
files.forEach((file) => {
|
|
169
|
+
const fileSize = file.size / 1024 / 1024;
|
|
170
|
+
const fileFormatOk = this.acceptedFormat
|
|
171
|
+
.split(",")
|
|
172
|
+
.some((ext) => file.name.toLowerCase().endsWith(ext.trim()));
|
|
173
|
+
const fileSizeOk = fileSize <= this.fileMaxSize;
|
|
174
|
+
if (fileSizeOk && fileFormatOk) {
|
|
175
|
+
if (!this.files.find((f) => f.name === file.name)) {
|
|
176
|
+
this.files.push(file);
|
|
177
|
+
this.fileInput.emit(file);
|
|
178
|
+
this.input.value = "";
|
|
179
|
+
}
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
errors.set(file.name, []);
|
|
183
|
+
if (!fileSizeOk) {
|
|
184
|
+
errors.get(file.name).push(sizeErrorString);
|
|
185
|
+
}
|
|
186
|
+
if (!fileFormatOk) {
|
|
187
|
+
errors.get(file.name).push(formatErrorString);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return errors;
|
|
191
|
+
}
|
|
192
|
+
renderTitle() {
|
|
193
|
+
return index.h("span", { id: "title" }, this.mainTitle);
|
|
194
|
+
}
|
|
195
|
+
renderDescription(cssClass) {
|
|
196
|
+
return index.h("span", { class: cssClass }, this.description);
|
|
197
|
+
}
|
|
198
|
+
renderAllowedFileExtensions() {
|
|
199
|
+
let fileFormatString = "";
|
|
200
|
+
let fileWeightString = "";
|
|
201
|
+
if (this.acceptedFormat) {
|
|
202
|
+
const fileFormat = this.acceptedFormat
|
|
203
|
+
.split(", ")
|
|
204
|
+
.map((string) => string.substring(1).toUpperCase())
|
|
205
|
+
.join(", ");
|
|
206
|
+
fileFormatString = ` nei formati ${fileFormat}`;
|
|
207
|
+
}
|
|
208
|
+
if (this.fileMaxSize) {
|
|
209
|
+
fileWeightString = ` per un massimo di ${this.fileMaxSize}MB di peso`;
|
|
210
|
+
}
|
|
211
|
+
const finalString = `Puoi allegare file${fileFormatString}${fileWeightString}.`;
|
|
212
|
+
return index.h("span", { class: "body-3" }, fileFormatString || fileWeightString ? finalString : null);
|
|
213
|
+
}
|
|
214
|
+
renderFileSection() {
|
|
215
|
+
return (index.h("section", { class: `files-container ${!this.files.length ? "hidden" : ""}` }, index.h("span", { class: "heading-4-sb" }, "File appena caricati"), index.h("div", { class: "files-wrapper" }, index.h("slot", { name: "files" })), index.h("z-divider", { size: index$1.DividerSize.MEDIUM })));
|
|
216
|
+
}
|
|
217
|
+
renderInput() {
|
|
218
|
+
return (index.h("input", Object.assign({}, this.inputAttributes, { onChange: () => this.fileInputHandler(), accept: this.acceptedFormat, ref: (val) => (this.input = val) })));
|
|
219
|
+
}
|
|
220
|
+
renderUploadButton() {
|
|
221
|
+
return [
|
|
222
|
+
this.renderInput(),
|
|
223
|
+
index.h("z-button", { onClick: () => this.input.click(), onKeyPress: (e) => {
|
|
224
|
+
if (e.code == "Space" || e.code == "Enter") {
|
|
225
|
+
e.preventDefault();
|
|
226
|
+
this.input.click();
|
|
227
|
+
}
|
|
228
|
+
}, id: "fileSelect", variant: this.buttonVariant, icon: "upload", ref: (val) => (this.button = val) }, this.uploadBtnLabel),
|
|
229
|
+
];
|
|
230
|
+
}
|
|
231
|
+
renderUploadLink() {
|
|
232
|
+
return [
|
|
233
|
+
this.renderInput(),
|
|
234
|
+
index.h("span", { class: "body-1 upload-link-text" }, "Trascina o", " ", index.h("span", { tabIndex: 0, class: "body-1-sb upload-link", onClick: () => this.input.click(), onKeyPress: (e) => {
|
|
235
|
+
if (e.code == "Space" || e.code == "Enter") {
|
|
236
|
+
e.preventDefault();
|
|
237
|
+
this.input.click();
|
|
238
|
+
}
|
|
239
|
+
}, ref: (val) => (this.uploadLink = val) }, "carica"), " ", "dal tuo computer"),
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
renderDefaultMode() {
|
|
243
|
+
return [
|
|
244
|
+
this.renderDescription("body-3-sb"),
|
|
245
|
+
this.renderAllowedFileExtensions(),
|
|
246
|
+
this.renderFileSection(),
|
|
247
|
+
this.renderUploadButton(),
|
|
248
|
+
];
|
|
249
|
+
}
|
|
250
|
+
renderDragDropMode() {
|
|
251
|
+
return [
|
|
252
|
+
this.renderFileSection(),
|
|
253
|
+
index.h("z-dragdrop-area", { "drag-and-drop-label": this.dragAndDropLabel }, index.h("div", { class: "text-container" }, this.renderDescription("body-1"), this.renderUploadLink(), this.renderAllowedFileExtensions())),
|
|
254
|
+
];
|
|
255
|
+
}
|
|
256
|
+
formatErrorString(key, value) {
|
|
257
|
+
var _a, _b;
|
|
258
|
+
const bothErrors = value[0] && value[1] ? ", " : "";
|
|
259
|
+
return `Il file ${key} ${(_a = value[0]) !== null && _a !== void 0 ? _a : ""}${bothErrors} ${(_b = value[1]) !== null && _b !== void 0 ? _b : ""} e non può quindi essere caricato.`;
|
|
260
|
+
}
|
|
261
|
+
handleErrorModalContent() {
|
|
262
|
+
return (index.h("div", { slot: "modalContent" }, index.h("div", { class: "modal-wrapper" }, index.h("div", { class: "files" }, Array.from(this.invalidFiles).map(([key, value]) => {
|
|
263
|
+
return index.h("span", { class: "body-3" }, this.formatErrorString(key, value));
|
|
264
|
+
})))));
|
|
265
|
+
}
|
|
266
|
+
render() {
|
|
267
|
+
return (index.h(index.Host, null, index.h("div", { tabIndex: 0, class: `container ${this.getType()}` }, this.mainTitle && this.renderTitle(), this.getType() == index$1.ZFileUploadType.DEFAULT ? this.renderDefaultMode() : this.renderDragDropMode()), !!this.invalidFiles.size && (index.h("z-modal", { modalid: `file-upload-${this.type}-error-modal`, tabIndex: 0, ref: (val) => (this.errorModal = val), modaltitle: "Attenzione", onModalClose: () => (this.invalidFiles = new Map()), onModalBackgroundClick: () => (this.invalidFiles = new Map()) }, this.handleErrorModalContent()))));
|
|
268
|
+
}
|
|
269
|
+
get el() { return index.getElement(this); }
|
|
270
|
+
};
|
|
271
|
+
ZFileUpload.style = stylesCss$2;
|
|
272
|
+
|
|
273
|
+
const stylesCss$1 = ":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)}";
|
|
274
|
+
|
|
275
|
+
const ZIcon = class {
|
|
276
|
+
constructor(hostRef) {
|
|
277
|
+
index.registerInstance(this, hostRef);
|
|
278
|
+
}
|
|
279
|
+
selectPathOrPolygon(iconValue) {
|
|
280
|
+
if (iconValue === null || iconValue === void 0 ? void 0 : iconValue.startsWith("M")) {
|
|
281
|
+
return index.h("path", { d: icons.ICONS[this.name] });
|
|
282
|
+
}
|
|
283
|
+
return index.h("polygon", { points: icons.ICONS[this.name] });
|
|
284
|
+
}
|
|
285
|
+
render() {
|
|
286
|
+
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]))));
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
ZIcon.style = stylesCss$1;
|
|
37
290
|
|
|
38
291
|
// nb. This is for IE10 and lower _only_.
|
|
39
292
|
var supportCustomEvent = window.CustomEvent;
|
|
@@ -1012,5 +1265,9 @@ const ZModal = class {
|
|
|
1012
1265
|
};
|
|
1013
1266
|
ZModal.style = stylesCss;
|
|
1014
1267
|
|
|
1268
|
+
exports.z_button = ZButton;
|
|
1269
|
+
exports.z_divider = ZDivider;
|
|
1015
1270
|
exports.z_dragdrop_area = ZDragdropArea;
|
|
1271
|
+
exports.z_file_upload = ZFileUpload;
|
|
1272
|
+
exports.z_icon = ZIcon;
|
|
1016
1273
|
exports.z_modal = ZModal;
|
|
@@ -23,7 +23,7 @@ const ZChip = class {
|
|
|
23
23
|
"z-chip-container": true,
|
|
24
24
|
"z-chip-interactive": !!this.interactiveIcon,
|
|
25
25
|
[this.type]: true,
|
|
26
|
-
}, "aria-disabled": this.disabled }, this.icon && index.h("z-icon", { name: this.icon }), index.h("slot", null), this.interactiveIcon && (index.h("button", { type: "button", onClick: () => this.interactiveIconClick.emit(),
|
|
26
|
+
}, "aria-disabled": this.disabled }, this.icon && index.h("z-icon", { name: this.icon }), index.h("slot", null), this.interactiveIcon && (index.h("button", { type: "button", onClick: () => this.interactiveIconClick.emit(), "aria-label": this.ariaLabel, disabled: this.disabled }, index.h("z-icon", { class: "interactive-icon", name: this.interactiveIcon })))));
|
|
27
27
|
}
|
|
28
28
|
get el() { return index.getElement(this); }
|
|
29
29
|
};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-195ca522.js');
|
|
6
|
+
const index$1 = require('./index-cf9497bc.js');
|
|
7
|
+
const utils = require('./utils-ee86db4f.js');
|
|
8
|
+
require('./breakpoints-ebe1a437.js');
|
|
9
|
+
|
|
10
|
+
const stylesCss$1 = ".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,[readonly=\"false\"].sc-z-input-h .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-input-field02)}.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:not([readonly]):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{-webkit-box-shadow:0 0 0 1000px #fff inset;-webkit-text-fill-color:currentcolor}.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)}";
|
|
11
|
+
|
|
12
|
+
const ZInput = class {
|
|
13
|
+
constructor(hostRef) {
|
|
14
|
+
index.registerInstance(this, hostRef);
|
|
15
|
+
this.inputChange = index.createEvent(this, "inputChange", 7);
|
|
16
|
+
this.startTyping = index.createEvent(this, "startTyping", 7);
|
|
17
|
+
this.stopTyping = index.createEvent(this, "stopTyping", 7);
|
|
18
|
+
this.inputCheck = index.createEvent(this, "inputCheck", 7);
|
|
19
|
+
/** the id of the input element */
|
|
20
|
+
this.htmlid = `id-${utils.randomId()}`;
|
|
21
|
+
/** the input aria-label */
|
|
22
|
+
this.ariaLabel = "";
|
|
23
|
+
/** the input is disabled */
|
|
24
|
+
this.disabled = false;
|
|
25
|
+
/** the input is readonly */
|
|
26
|
+
this.readonly = false;
|
|
27
|
+
/** the input is required (optional): available for text, password, number, email, textarea, checkbox */
|
|
28
|
+
this.required = false;
|
|
29
|
+
/** checked: available for checkbox, radio */
|
|
30
|
+
this.checked = false;
|
|
31
|
+
/** input helper message (optional): available for text, password, number, email, textarea - if set to `false` message won't be displayed */
|
|
32
|
+
this.message = true;
|
|
33
|
+
/** the input label position: available for checkbox, radio */
|
|
34
|
+
this.labelPosition = index$1.LabelPosition.RIGHT;
|
|
35
|
+
/** render clear icon when typing (optional): available for text */
|
|
36
|
+
this.hasclearicon = true;
|
|
37
|
+
/** Available sizes: `big`, `small` and `x-small`. Defaults to `big`. */
|
|
38
|
+
this.size = index$1.ControlSize.BIG;
|
|
39
|
+
this.isTyping = false;
|
|
40
|
+
this.passwordHidden = true;
|
|
41
|
+
this.typingtimeout = 300;
|
|
42
|
+
}
|
|
43
|
+
inputCheckListener(e) {
|
|
44
|
+
const data = e.detail;
|
|
45
|
+
switch (this.type) {
|
|
46
|
+
case index$1.InputType.RADIO:
|
|
47
|
+
if (data.type === index$1.InputType.RADIO && data.name === this.name && data.id !== this.htmlid) {
|
|
48
|
+
this.checked = false;
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** get checked status */
|
|
54
|
+
async isChecked() {
|
|
55
|
+
switch (this.type) {
|
|
56
|
+
case index$1.InputType.CHECKBOX:
|
|
57
|
+
case index$1.InputType.RADIO:
|
|
58
|
+
return this.checked;
|
|
59
|
+
default:
|
|
60
|
+
console.warn("`isChecked` method is only available for type `checkbox` and `radio`");
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
emitInputChange(value) {
|
|
65
|
+
if (!this.isTyping) {
|
|
66
|
+
this.emitStartTyping();
|
|
67
|
+
}
|
|
68
|
+
let validity;
|
|
69
|
+
if (this.type === index$1.InputType.TEXTAREA) {
|
|
70
|
+
validity = this.getValidity("textarea");
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
validity = this.getValidity("input");
|
|
74
|
+
}
|
|
75
|
+
this.value = value;
|
|
76
|
+
this.inputChange.emit({ value, validity });
|
|
77
|
+
clearTimeout(this.timer);
|
|
78
|
+
this.timer = setTimeout(() => {
|
|
79
|
+
this.emitStopTyping(this.value, validity);
|
|
80
|
+
}, this.typingtimeout);
|
|
81
|
+
}
|
|
82
|
+
emitStartTyping() {
|
|
83
|
+
this.isTyping = true;
|
|
84
|
+
this.startTyping.emit();
|
|
85
|
+
}
|
|
86
|
+
emitStopTyping(value, validity) {
|
|
87
|
+
this.isTyping = false;
|
|
88
|
+
this.stopTyping.emit({
|
|
89
|
+
value: value,
|
|
90
|
+
validity: validity,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
emitInputCheck(checked) {
|
|
94
|
+
this.inputCheck.emit({
|
|
95
|
+
id: this.htmlid,
|
|
96
|
+
checked: checked,
|
|
97
|
+
type: this.type,
|
|
98
|
+
name: this.name,
|
|
99
|
+
value: this.value,
|
|
100
|
+
validity: this.getValidity("input"),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
getValidity(type) {
|
|
104
|
+
const input = this.hostElement.querySelector(type);
|
|
105
|
+
return input.validity;
|
|
106
|
+
}
|
|
107
|
+
/* START text/password/email/number */
|
|
108
|
+
getTextAttributes() {
|
|
109
|
+
return {
|
|
110
|
+
id: this.htmlid,
|
|
111
|
+
name: this.name,
|
|
112
|
+
placeholder: this.placeholder,
|
|
113
|
+
value: this.value,
|
|
114
|
+
disabled: this.disabled,
|
|
115
|
+
readonly: this.readonly,
|
|
116
|
+
required: this.required,
|
|
117
|
+
title: this.htmltitle,
|
|
118
|
+
minlength: this.minlength,
|
|
119
|
+
maxlength: this.maxlength,
|
|
120
|
+
class: {
|
|
121
|
+
[`input-${this.status}`]: !!this.status,
|
|
122
|
+
filled: !!this.value,
|
|
123
|
+
},
|
|
124
|
+
autocomplete: this.autocomplete,
|
|
125
|
+
onInput: (e) => this.emitInputChange(e.target.value),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
getNumberAttributes(type) {
|
|
129
|
+
if (type != index$1.InputType.NUMBER) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
min: this.min,
|
|
134
|
+
max: this.max,
|
|
135
|
+
step: this.step,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
getPatternAttribute(type) {
|
|
139
|
+
if (type != index$1.InputType.PASSWORD &&
|
|
140
|
+
type != index$1.InputType.TEXT &&
|
|
141
|
+
type != index$1.InputType.TEL &&
|
|
142
|
+
type != index$1.InputType.SEARCH &&
|
|
143
|
+
type != index$1.InputType.URL &&
|
|
144
|
+
type != index$1.InputType.EMAIL) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
pattern: this.pattern,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
getRoleAttribute() {
|
|
152
|
+
return this.role ? { role: this.role } : {};
|
|
153
|
+
}
|
|
154
|
+
getAriaAttrubutes() {
|
|
155
|
+
const expanded = this.ariaExpanded ? { "aria-expanded": this.ariaExpanded } : {};
|
|
156
|
+
const controls = this.ariaControls ? { "aria-controls": this.ariaControls } : {};
|
|
157
|
+
const autocomplete = this.ariaAutocomplete ? { "aria-autocomplete": this.ariaAutocomplete } : {};
|
|
158
|
+
const activedescendant = this.ariaActivedescendant ? { "aria-activedescendant": this.ariaActivedescendant } : {};
|
|
159
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, expanded), controls), autocomplete), activedescendant);
|
|
160
|
+
}
|
|
161
|
+
renderInputText(type = index$1.InputType.TEXT) {
|
|
162
|
+
const ariaLabel = this.ariaLabel ? { "aria-label": this.ariaLabel } : {};
|
|
163
|
+
const attr = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, this.getTextAttributes()), this.getNumberAttributes(type)), this.getPatternAttribute(type)), ariaLabel), this.getRoleAttribute()), this.getAriaAttrubutes());
|
|
164
|
+
if (this.icon || type === index$1.InputType.PASSWORD) {
|
|
165
|
+
Object.assign(attr.class, { "has-icon": true });
|
|
166
|
+
}
|
|
167
|
+
if (this.hasclearicon && type != index$1.InputType.NUMBER) {
|
|
168
|
+
Object.assign(attr.class, { "has-clear-icon": true });
|
|
169
|
+
}
|
|
170
|
+
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()));
|
|
171
|
+
}
|
|
172
|
+
renderLabel() {
|
|
173
|
+
if (!this.label) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
return (index.h("label", { class: "input-label body-5-sb", id: `${this.htmlid}_label`, htmlFor: this.htmlid }, this.label));
|
|
177
|
+
}
|
|
178
|
+
renderIcons() {
|
|
179
|
+
return (index.h("span", { class: "icons-wrapper" }, this.renderResetIcon(), this.renderIcon()));
|
|
180
|
+
}
|
|
181
|
+
renderIcon() {
|
|
182
|
+
if (this.type === index$1.InputType.PASSWORD) {
|
|
183
|
+
return this.renderShowHidePassword();
|
|
184
|
+
}
|
|
185
|
+
if (!this.icon) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
return (index.h("button", { type: "button", class: "icon-button input-icon", tabIndex: -1, "aria-hidden": "true" }, index.h("z-icon", { name: this.icon, class: this.size })));
|
|
189
|
+
}
|
|
190
|
+
renderResetIcon() {
|
|
191
|
+
let hidden = false;
|
|
192
|
+
if (!this.hasclearicon || !this.value || this.disabled || this.readonly || this.type == index$1.InputType.NUMBER) {
|
|
193
|
+
hidden = true;
|
|
194
|
+
}
|
|
195
|
+
return (index.h("button", { type: "button", class: `icon-button reset-icon ${hidden ? "hidden" : ""}`, "aria-label": "cancella il contenuto dell'input", onClick: () => {
|
|
196
|
+
this.inputRef.value = "";
|
|
197
|
+
this.emitInputChange("");
|
|
198
|
+
} }, index.h("z-icon", { name: "multiply", class: this.size })));
|
|
199
|
+
}
|
|
200
|
+
renderShowHidePassword() {
|
|
201
|
+
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 })));
|
|
202
|
+
}
|
|
203
|
+
renderMessage() {
|
|
204
|
+
if (utils.boolean(this.message) === false) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
return (index.h("z-input-message", { message: utils.boolean(this.message) === true ? undefined : this.message, status: this.status, class: this.size }));
|
|
208
|
+
}
|
|
209
|
+
/* END text/password/email/number */
|
|
210
|
+
/* START textarea */
|
|
211
|
+
renderTextarea() {
|
|
212
|
+
const attributes = this.getTextAttributes();
|
|
213
|
+
const ariaLabel = this.ariaLabel ? { "aria-label": this.ariaLabel } : {};
|
|
214
|
+
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.getRoleAttribute()))), this.renderMessage()));
|
|
215
|
+
}
|
|
216
|
+
/* END textarea */
|
|
217
|
+
handleCheck(ev) {
|
|
218
|
+
this.checked = ev.target.checked;
|
|
219
|
+
this.emitInputCheck(this.checked);
|
|
220
|
+
}
|
|
221
|
+
/* START checkbox */
|
|
222
|
+
renderCheckbox() {
|
|
223
|
+
return (index.h("div", { class: "checkbox-wrapper" }, index.h("input", Object.assign({ 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 }, this.getRoleAttribute())), index.h("label", { htmlFor: this.htmlid, class: {
|
|
224
|
+
"checkbox-label": true,
|
|
225
|
+
"after": this.labelPosition === index$1.LabelPosition.RIGHT,
|
|
226
|
+
"before": this.labelPosition === index$1.LabelPosition.LEFT,
|
|
227
|
+
} }, index.h("z-icon", { name: this.checked ? "checkbox-checked" : "checkbox", "aria-hidden": "true", class: this.size }), this.label && index.h("span", { innerHTML: this.label }))));
|
|
228
|
+
}
|
|
229
|
+
/* END checkbox */
|
|
230
|
+
/* START radio */
|
|
231
|
+
renderRadio() {
|
|
232
|
+
return (index.h("div", { class: "radio-wrapper" }, index.h("input", Object.assign({ 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 }, this.getRoleAttribute())), index.h("label", { htmlFor: this.htmlid, class: {
|
|
233
|
+
"radio-label": true,
|
|
234
|
+
"after": this.labelPosition === index$1.LabelPosition.RIGHT,
|
|
235
|
+
"before": this.labelPosition === index$1.LabelPosition.LEFT,
|
|
236
|
+
} }, 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 }))));
|
|
237
|
+
}
|
|
238
|
+
/* END radio */
|
|
239
|
+
render() {
|
|
240
|
+
let input;
|
|
241
|
+
switch (this.type) {
|
|
242
|
+
case index$1.InputType.TEXTAREA:
|
|
243
|
+
input = this.renderTextarea();
|
|
244
|
+
break;
|
|
245
|
+
case index$1.InputType.CHECKBOX:
|
|
246
|
+
input = this.renderCheckbox();
|
|
247
|
+
break;
|
|
248
|
+
case index$1.InputType.RADIO:
|
|
249
|
+
input = this.renderRadio();
|
|
250
|
+
break;
|
|
251
|
+
default:
|
|
252
|
+
input = this.renderInputText(this.type);
|
|
253
|
+
}
|
|
254
|
+
return index.h(index.Host, null, input);
|
|
255
|
+
}
|
|
256
|
+
get hostElement() { return index.getElement(this); }
|
|
257
|
+
};
|
|
258
|
+
ZInput.style = stylesCss$1;
|
|
259
|
+
|
|
260
|
+
const stylesCss = ":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)}";
|
|
261
|
+
|
|
262
|
+
const ZInputMessage = class {
|
|
263
|
+
constructor(hostRef) {
|
|
264
|
+
index.registerInstance(this, hostRef);
|
|
265
|
+
this.statusIcons = {
|
|
266
|
+
success: "checkmark-circle",
|
|
267
|
+
error: "multiply-circled",
|
|
268
|
+
warning: "exclamation-circle",
|
|
269
|
+
};
|
|
270
|
+
this.statusRole = {};
|
|
271
|
+
}
|
|
272
|
+
onMessageChange() {
|
|
273
|
+
this.statusRole = this.message && this.status ? { role: "alert" } : {};
|
|
274
|
+
}
|
|
275
|
+
componentWillLoad() {
|
|
276
|
+
this.onMessageChange();
|
|
277
|
+
}
|
|
278
|
+
render() {
|
|
279
|
+
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 })));
|
|
280
|
+
}
|
|
281
|
+
static get watchers() { return {
|
|
282
|
+
"message": ["onMessageChange"],
|
|
283
|
+
"status": ["onMessageChange"]
|
|
284
|
+
}; }
|
|
285
|
+
};
|
|
286
|
+
ZInputMessage.style = stylesCss;
|
|
287
|
+
|
|
288
|
+
exports.z_input = ZInput;
|
|
289
|
+
exports.z_input_message = ZInputMessage;
|