@zanichelli/albe-web-components 18.3.0 → 18.3.1-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/z-toast-notification.cjs.entry.js +7 -43
- package/dist/cjs/z-toast-notification.cjs.entry.js.map +1 -1
- package/dist/collection/components/z-toast-notification/index.js +7 -43
- package/dist/collection/components/z-toast-notification/index.js.map +1 -1
- package/dist/collection/components/z-toast-notification/index.stories.js +30 -2
- package/dist/collection/components/z-toast-notification/index.stories.js.map +1 -1
- package/dist/collection/components/z-toast-notification/styles.css +25 -34
- package/dist/components/z-toast-notification.js +8 -44
- package/dist/components/z-toast-notification.js.map +1 -1
- package/dist/esm/z-toast-notification.entry.js +8 -44
- package/dist/esm/z-toast-notification.entry.js.map +1 -1
- package/dist/types/components/z-toast-notification/index.d.ts +1 -10
- package/dist/types/components/z-toast-notification/index.stories.d.ts +10 -2
- package/dist/web-components-library/p-1dd6dff4.entry.js +7 -0
- package/dist/web-components-library/p-1dd6dff4.entry.js.map +1 -0
- package/dist/web-components-library/web-components-library.esm.js +1 -1
- package/package.json +1 -1
- package/www/build/p-1dd6dff4.entry.js +7 -0
- package/www/build/p-1dd6dff4.entry.js.map +1 -0
- package/www/build/{p-15ea6e9d.js → p-28efbaa8.js} +1 -1
- package/www/build/web-components-library.esm.js +1 -1
- package/www/index.html +1 -1
- package/dist/web-components-library/p-72c07bbd.entry.js +0 -7
- package/dist/web-components-library/p-72c07bbd.entry.js.map +0 -1
- package/www/build/p-72c07bbd.entry.js +0 -7
- package/www/build/p-72c07bbd.entry.js.map +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
|
-
import { ToastNotificationTransition } from "../../beans";
|
|
3
|
-
import { Breakpoints } from "../../constants/breakpoints";
|
|
2
|
+
import { KeyboardCode, ToastNotificationTransition } from "../../beans";
|
|
4
3
|
import Hammer from "hammerjs";
|
|
5
4
|
export class ZToastNotification {
|
|
6
5
|
constructor() {
|
|
@@ -45,12 +44,10 @@ export class ZToastNotification {
|
|
|
45
44
|
this.toastClose.emit();
|
|
46
45
|
}
|
|
47
46
|
componentWillLoad() {
|
|
48
|
-
this.isMobile = window.innerWidth <= Breakpoints.MOBILE;
|
|
49
47
|
this.validateAutoclose();
|
|
50
48
|
this.percentage = 0;
|
|
51
49
|
}
|
|
52
50
|
componentDidLoad() {
|
|
53
|
-
this.isTextLong = this.detectWrap() || this.toastText.offsetHeight > 20;
|
|
54
51
|
this.startTime = Date.now();
|
|
55
52
|
if (this.autoclose && this.pauseonfocusloss) {
|
|
56
53
|
document.addEventListener("visibilitychange", this.visibilityChangeEventHandler);
|
|
@@ -131,56 +128,23 @@ export class ZToastNotification {
|
|
|
131
128
|
startClosingTimeout(time) {
|
|
132
129
|
this.timeoutHandle = window.setTimeout(() => this.emitToastClose(this.mapSlideOutClass()), time);
|
|
133
130
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
let totalWidth = 0;
|
|
138
|
-
for (let i = 0; i < children.length; i++) {
|
|
139
|
-
totalWidth += children[i].offsetWidth;
|
|
140
|
-
}
|
|
141
|
-
return totalWidth > parentWidth;
|
|
142
|
-
}
|
|
143
|
-
renderText() {
|
|
144
|
-
return (h("div", { id: "text", ref: (el) => (this.toastText = el) }, this.heading && h("span", { class: "title" }, this.heading), h("span", { class: "message" }, this.message)));
|
|
145
|
-
}
|
|
146
|
-
renderButton() {
|
|
147
|
-
return (h("div", { id: "button" }, h("slot", { name: "button" })));
|
|
148
|
-
}
|
|
149
|
-
renderCloseIcon() {
|
|
150
|
-
if (!this.closebutton) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
return (h("div", { id: "icon" }, h("z-icon", { tabIndex: 0, name: "multiply-circled", width: 15, height: 15, onClick: () => this.emitToastClose(this.mapSlideOutClass()), onKeyPress: (e) => {
|
|
154
|
-
if (e.keyCode == 32 || e.keyCode == 13) {
|
|
131
|
+
renderContent() {
|
|
132
|
+
return (h("div", { id: "external-container", tabIndex: 0, class: { [this.type]: !!this.type } }, h("div", { id: "inner-container" }, h("div", { id: "text" }, this.heading && h("span", { class: "title" }, this.heading), h("span", { class: "message" }, this.message)), h("div", { id: "button" }, h("slot", { name: "button" }))), h("div", { id: "icon" }, this.closebutton && (h("z-icon", { tabIndex: 0, name: "multiply-circled", width: 15, height: 15, onClick: () => this.emitToastClose(this.mapSlideOutClass()), onKeyPress: (e) => {
|
|
133
|
+
if (e.code == KeyboardCode.SPACE || e.code == KeyboardCode.ENTER) {
|
|
155
134
|
e.preventDefault();
|
|
156
135
|
this.emitToastClose(this.mapSlideOutClass());
|
|
157
136
|
}
|
|
158
|
-
} })));
|
|
159
|
-
}
|
|
160
|
-
renderContainer() {
|
|
161
|
-
return (h("div", { tabIndex: 0, id: "external-container", class: {
|
|
162
|
-
[this.type]: !!this.type,
|
|
163
|
-
"several-lines-padding": this.isTextLong,
|
|
164
|
-
}, ref: (el) => (this.container = el) }, this.renderText(), this.renderButton(), this.renderCloseIcon()));
|
|
165
|
-
}
|
|
166
|
-
renderMobileContainer() {
|
|
167
|
-
return (h("div", { id: "external-container", class: {
|
|
168
|
-
[this.type]: !!this.type,
|
|
169
|
-
"several-lines-padding": this.isTextLong,
|
|
170
|
-
"mobile-wrapped": this.isTextLong,
|
|
171
|
-
} }, h("div", { id: "flex-container", ref: (el) => (this.container = el) }, this.renderText(), this.renderButton()), this.renderCloseIcon()));
|
|
137
|
+
} })))));
|
|
172
138
|
}
|
|
173
139
|
render() {
|
|
174
|
-
return (h(Host, { key: '
|
|
175
|
-
"--percentuale": `${this.percentage}%`,
|
|
176
|
-
}, class: this.transition ? this.transition : ToastNotificationTransition.SLIDE_IN_DOWN, onAnimationEnd: (e) => {
|
|
140
|
+
return (h(Host, { key: 'f9b4a2fe7d3642b1cbbe6f2e433ddbbde49568fd', style: { "--percentuale": `${this.percentage}%` }, class: this.transition ? this.transition : ToastNotificationTransition.SLIDE_IN_DOWN, onAnimationEnd: (e) => {
|
|
177
141
|
if (this.autoclose && e.animationName.includes("slidein")) {
|
|
178
142
|
this.startClosingTimeout(this.autoclose);
|
|
179
143
|
}
|
|
180
144
|
if (e.animationName.includes("slideout")) {
|
|
181
145
|
this.hostElement.parentNode.removeChild(this.hostElement);
|
|
182
146
|
}
|
|
183
|
-
} }, this.
|
|
147
|
+
} }, this.renderContent()));
|
|
184
148
|
}
|
|
185
149
|
static get is() { return "z-toast-notification"; }
|
|
186
150
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/z-toast-notification/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,MAAM,eAAe,CAAC;AACnG,OAAO,EAAC,iBAAiB,EAAE,2BAA2B,EAAC,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAExD,OAAO,MAAM,MAAM,UAAU,CAAC;AAO9B,MAAM,OAAO,kBAAkB;;QA0DrB,uBAAkB,GAAG,KAAK,CAAC;;;;;gCArCN,IAAI;;2BAQT,IAAI;mCAIG,EAAE;;;;IA4BjC,oBAAoB,CAAC,QAAiB;QACpC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAGD,kBAAkB,CAAC,QAAgB;QACjC,YAAY,CAA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mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBAC3C,CAAC;gBACD,IAAI,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;oBACzC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC,IAEA,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CACjE,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Element, Event, EventEmitter, Host, Prop, State, Watch, h} from \"@stencil/core\";\nimport {ToastNotification, ToastNotificationTransition} from \"../../beans\";\nimport {Breakpoints} from \"../../constants/breakpoints\";\n\nimport Hammer from \"hammerjs\";\n\n@Component({\n tag: \"z-toast-notification\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZToastNotification {\n @Element() hostElement: HTMLZToastNotificationElement;\n\n /** toast notification's title */\n @Prop()\n heading?: string;\n\n /** toast notification's message */\n @Prop()\n message: string;\n\n /** toggles closing button rendering */\n @Prop()\n closebutton: boolean;\n\n /** toast notification closing timeout (ms) */\n @Prop()\n autoclose?: number;\n\n /** toast notification autoclose can be paused */\n @Prop()\n pauseonfocusloss?: boolean = true;\n\n /** toast notification type: dark, light, accent, error, success, warning */\n @Prop()\n type?: ToastNotification;\n\n /** toast notification can be draggable*/\n @Prop()\n isdraggable?: boolean = true;\n\n /** toast notification draggable percentage*/\n @Prop()\n draggablepercentage?: number = 80;\n\n /** toast notification animation type: slide-in-left, slide-in-right, slide-in-down, slide-in-up*/\n @Prop()\n transition?: ToastNotificationTransition;\n\n @State()\n percentage: number;\n\n private isTextLong: boolean;\n\n private container!: HTMLElement;\n\n private toastText!: HTMLElement;\n\n private sliderManager: HammerManager;\n\n private elapsedTime: number;\n\n private timeoutHandle: number;\n\n private startTime: number;\n\n private isMobile: boolean;\n\n private isCloseEventCalled = false;\n\n @Watch(\"isdraggable\")\n watchPropIsdraggable(newValue: boolean): void {\n if (newValue) {\n this.sliderManager.get(\"pan\").set({enable: true});\n } else {\n this.sliderManager.get(\"pan\").set({enable: false});\n }\n }\n\n @Watch(\"autoclose\")\n watchPropAutoclose(newValue: number): void {\n clearTimeout(this.timeoutHandle);\n this.startClosingTimeout(newValue);\n }\n\n @Watch(\"pauseonfocusloss\")\n watchPropPauseonfocusloss(newValue: boolean): void {\n if (this.autoclose) {\n if (newValue) {\n document.addEventListener(\"visibilitychange\", this.visibilityChangeEventHandler);\n } else {\n document.removeEventListener(\"visibilitychange\", this.visibilityChangeEventHandler);\n }\n }\n }\n\n /** notification close event */\n @Event()\n toastClose: EventEmitter;\n\n private emitToastClose(cssClass: string): void {\n this.timeoutHandle = null;\n this.elapsedTime = null;\n this.hostElement.classList.add(cssClass);\n this.toastClose.emit();\n }\n\n componentWillLoad(): void {\n this.isMobile = window.innerWidth <= Breakpoints.MOBILE;\n this.validateAutoclose();\n this.percentage = 0;\n }\n\n componentDidLoad(): void {\n this.isTextLong = this.detectWrap() || this.toastText.offsetHeight > 20;\n this.startTime = Date.now();\n if (this.autoclose && this.pauseonfocusloss) {\n document.addEventListener(\"visibilitychange\", this.visibilityChangeEventHandler);\n }\n\n this.isdraggable && this.handleSlideOutDragAnimation();\n }\n\n private visibilityChangeEventHandler(): void {\n if (document.visibilityState === \"hidden\") {\n this.timeoutHandle && this.onBlur();\n } else {\n this.elapsedTime && this.onFocus();\n }\n }\n\n private validateAutoclose(): void {\n if (!this.autoclose && !this.closebutton) {\n console.error(\"At least one between autoclose and closebutton must be present\");\n }\n }\n\n private mapSlideOutClass(): ToastNotificationTransition {\n switch (this.transition) {\n case ToastNotificationTransition.SLIDE_IN_DOWN:\n return ToastNotificationTransition.SLIDE_OUT_UP;\n case ToastNotificationTransition.SLIDE_IN_UP:\n return ToastNotificationTransition.SLIDE_OUT_DOWN;\n case ToastNotificationTransition.SLIDE_IN_LEFT:\n return ToastNotificationTransition.SLIDE_OUT_RIGHT;\n case ToastNotificationTransition.SLIDE_IN_RIGHT:\n return ToastNotificationTransition.SLIDE_OUT_LEFT;\n }\n }\n\n private calculateDraggedPercentage(e): number {\n const bounding = this.hostElement.getBoundingClientRect();\n\n return Math.round((100 * e.deltaX) / bounding.width);\n }\n\n private handleSlideOutDragAnimation(): void {\n this.sliderManager = new Hammer(this.hostElement);\n this.sliderManager.get(\"pan\").set({\n direction: Hammer.DIRECTION_HORIZONTAL,\n });\n\n this.sliderManager.on(\"pan\", (e) => {\n this.percentage = this.calculateDraggedPercentage(e);\n this.hostElement.style.transition = \"none\";\n this.hostElement.classList.remove(this.transition);\n const translateObj = {\n translate: `translateX(${this.percentage}%)`,\n translateBack: \"translateX(0)\",\n };\n\n this.hostElement.style.opacity = `${100 - Math.abs(this.percentage)}%`;\n if (e.eventType === Hammer.DIRECTION_LEFT || e.eventType === Hammer.DIRECTION_RIGHT) {\n this.hostElement.style.transform = translateObj.translate;\n if (Math.abs(this.percentage) > this.draggablepercentage && !this.isCloseEventCalled) {\n this.isCloseEventCalled = true;\n this.emitToastClose(e.direction === Hammer.DIRECTION_LEFT ? \"slide-out-left\" : \"slide-out-right\");\n }\n }\n\n if (e.isFinal && Math.abs(this.percentage) < this.draggablepercentage) {\n this.hostElement.style.transform = translateObj.translateBack;\n this.hostElement.style.transition = \"all 1s\";\n this.hostElement.style.opacity = \"100%\";\n this.percentage = 0;\n }\n });\n }\n\n private onFocus(): void {\n let time = this.autoclose;\n if (this.elapsedTime) {\n time = this.autoclose - this.elapsedTime;\n }\n if (time > 0) {\n this.startClosingTimeout(time);\n }\n }\n\n private onBlur(): void {\n this.elapsedTime = Date.now() - this.startTime;\n clearTimeout(this.timeoutHandle);\n }\n\n private startClosingTimeout(time: number): void {\n this.timeoutHandle = window.setTimeout(() => this.emitToastClose(this.mapSlideOutClass()), time);\n }\n\n private detectWrap(): boolean {\n const parentWidth = this.container.offsetWidth;\n const children = this.container.children;\n let totalWidth = 0;\n\n for (let i = 0; i < children.length; i++) {\n totalWidth += (children[i] as HTMLElement).offsetWidth;\n }\n\n return totalWidth > parentWidth;\n }\n\n private renderText(): HTMLDivElement {\n return (\n <div\n id=\"text\"\n ref={(el) => (this.toastText = el as HTMLElement)}\n >\n {this.heading && <span class=\"title\">{this.heading}</span>}\n <span class=\"message\">{this.message}</span>\n </div>\n );\n }\n\n private renderButton(): HTMLDivElement {\n return (\n <div id=\"button\">\n <slot name=\"button\" />\n </div>\n );\n }\n\n private renderCloseIcon(): HTMLDivElement {\n if (!this.closebutton) {\n return;\n }\n\n return (\n <div id=\"icon\">\n <z-icon\n tabIndex={0}\n name=\"multiply-circled\"\n width={15}\n height={15}\n onClick={() => this.emitToastClose(this.mapSlideOutClass())}\n onKeyPress={(e) => {\n if (e.keyCode == 32 || e.keyCode == 13) {\n e.preventDefault();\n this.emitToastClose(this.mapSlideOutClass());\n }\n }}\n />\n </div>\n );\n }\n\n private renderContainer(): HTMLDivElement {\n return (\n <div\n tabIndex={0}\n id=\"external-container\"\n class={{\n [this.type]: !!this.type,\n \"several-lines-padding\": this.isTextLong,\n }}\n ref={(el) => (this.container = el as HTMLElement)}\n >\n {this.renderText()}\n {this.renderButton()}\n {this.renderCloseIcon()}\n </div>\n );\n }\n\n private renderMobileContainer(): HTMLDivElement {\n return (\n <div\n id=\"external-container\"\n class={{\n [this.type]: !!this.type,\n \"several-lines-padding\": this.isTextLong,\n \"mobile-wrapped\": this.isTextLong,\n }}\n >\n <div\n id=\"flex-container\"\n ref={(el) => (this.container = el as HTMLElement)}\n >\n {this.renderText()}\n {this.renderButton()}\n </div>\n {this.renderCloseIcon()}\n </div>\n );\n }\n\n render(): HTMLZToastNotificationElement {\n return (\n <Host\n style={{\n \"--percentuale\": `${this.percentage}%`,\n }}\n class={this.transition ? this.transition : ToastNotificationTransition.SLIDE_IN_DOWN}\n onAnimationEnd={(e: AnimationEvent) => {\n if (this.autoclose && e.animationName.includes(\"slidein\")) {\n this.startClosingTimeout(this.autoclose);\n }\n if (e.animationName.includes(\"slideout\")) {\n this.hostElement.parentNode.removeChild(this.hostElement);\n }\n }}\n >\n {this.isMobile ? this.renderMobileContainer() : this.renderContainer()}\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/z-toast-notification/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,MAAM,eAAe,CAAC;AACnG,OAAO,EAAC,YAAY,EAAE,iBAAiB,EAAE,2BAA2B,EAAC,MAAM,aAAa,CAAC;AAEzF,OAAO,MAAM,MAAM,UAAU,CAAC;AAO9B,MAAM,OAAO,kBAAkB;;QAkDrB,uBAAkB,GAAG,KAAK,CAAC;;;;;gCA7BN,IAAI;;2BAQT,IAAI;mCAIG,EAAE;;;;IAoBjC,oBAAoB,CAAC,QAAiB;QACpC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAGD,kBAAk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D,CAAC;YACH,CAAC,IAEA,IAAI,CAAC,aAAa,EAAE,CAChB,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Element, Event, EventEmitter, Host, Prop, State, Watch, h} from \"@stencil/core\";\nimport {KeyboardCode, ToastNotification, ToastNotificationTransition} from \"../../beans\";\n\nimport Hammer from \"hammerjs\";\n\n@Component({\n tag: \"z-toast-notification\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZToastNotification {\n @Element() hostElement: HTMLZToastNotificationElement;\n\n /** toast notification's title */\n @Prop()\n heading?: string;\n\n /** toast notification's message */\n @Prop()\n message: string;\n\n /** toggles closing button rendering */\n @Prop()\n closebutton: boolean;\n\n /** toast notification closing timeout (ms) */\n @Prop()\n autoclose?: number;\n\n /** toast notification autoclose can be paused */\n @Prop()\n pauseonfocusloss?: boolean = true;\n\n /** toast notification type: dark, light, accent, error, success, warning */\n @Prop()\n type?: ToastNotification;\n\n /** toast notification can be draggable*/\n @Prop()\n isdraggable?: boolean = true;\n\n /** toast notification draggable percentage*/\n @Prop()\n draggablepercentage?: number = 80;\n\n /** toast notification animation type: slide-in-left, slide-in-right, slide-in-down, slide-in-up*/\n @Prop()\n transition?: ToastNotificationTransition;\n\n @State()\n percentage: number;\n\n private sliderManager: HammerManager;\n\n private elapsedTime: number;\n\n private timeoutHandle: number;\n\n private startTime: number;\n\n private isCloseEventCalled = false;\n\n @Watch(\"isdraggable\")\n watchPropIsdraggable(newValue: boolean): void {\n if (newValue) {\n this.sliderManager.get(\"pan\").set({enable: true});\n } else {\n this.sliderManager.get(\"pan\").set({enable: false});\n }\n }\n\n @Watch(\"autoclose\")\n watchPropAutoclose(newValue: number): void {\n clearTimeout(this.timeoutHandle);\n this.startClosingTimeout(newValue);\n }\n\n @Watch(\"pauseonfocusloss\")\n watchPropPauseonfocusloss(newValue: boolean): void {\n if (this.autoclose) {\n if (newValue) {\n document.addEventListener(\"visibilitychange\", this.visibilityChangeEventHandler);\n } else {\n document.removeEventListener(\"visibilitychange\", this.visibilityChangeEventHandler);\n }\n }\n }\n\n /** notification close event */\n @Event()\n toastClose: EventEmitter;\n\n private emitToastClose(cssClass: string): void {\n this.timeoutHandle = null;\n this.elapsedTime = null;\n this.hostElement.classList.add(cssClass);\n this.toastClose.emit();\n }\n\n componentWillLoad(): void {\n this.validateAutoclose();\n this.percentage = 0;\n }\n\n componentDidLoad(): void {\n this.startTime = Date.now();\n if (this.autoclose && this.pauseonfocusloss) {\n document.addEventListener(\"visibilitychange\", this.visibilityChangeEventHandler);\n }\n\n this.isdraggable && this.handleSlideOutDragAnimation();\n }\n\n private visibilityChangeEventHandler(): void {\n if (document.visibilityState === \"hidden\") {\n this.timeoutHandle && this.onBlur();\n } else {\n this.elapsedTime && this.onFocus();\n }\n }\n\n private validateAutoclose(): void {\n if (!this.autoclose && !this.closebutton) {\n console.error(\"At least one between autoclose and closebutton must be present\");\n }\n }\n\n private mapSlideOutClass(): ToastNotificationTransition {\n switch (this.transition) {\n case ToastNotificationTransition.SLIDE_IN_DOWN:\n return ToastNotificationTransition.SLIDE_OUT_UP;\n case ToastNotificationTransition.SLIDE_IN_UP:\n return ToastNotificationTransition.SLIDE_OUT_DOWN;\n case ToastNotificationTransition.SLIDE_IN_LEFT:\n return ToastNotificationTransition.SLIDE_OUT_RIGHT;\n case ToastNotificationTransition.SLIDE_IN_RIGHT:\n return ToastNotificationTransition.SLIDE_OUT_LEFT;\n }\n }\n\n private calculateDraggedPercentage(e): number {\n const bounding = this.hostElement.getBoundingClientRect();\n\n return Math.round((100 * e.deltaX) / bounding.width);\n }\n\n private handleSlideOutDragAnimation(): void {\n this.sliderManager = new Hammer(this.hostElement);\n this.sliderManager.get(\"pan\").set({\n direction: Hammer.DIRECTION_HORIZONTAL,\n });\n\n this.sliderManager.on(\"pan\", (e) => {\n this.percentage = this.calculateDraggedPercentage(e);\n this.hostElement.style.transition = \"none\";\n this.hostElement.classList.remove(this.transition);\n const translateObj = {\n translate: `translateX(${this.percentage}%)`,\n translateBack: \"translateX(0)\",\n };\n\n this.hostElement.style.opacity = `${100 - Math.abs(this.percentage)}%`;\n if (e.eventType === Hammer.DIRECTION_LEFT || e.eventType === Hammer.DIRECTION_RIGHT) {\n this.hostElement.style.transform = translateObj.translate;\n if (Math.abs(this.percentage) > this.draggablepercentage && !this.isCloseEventCalled) {\n this.isCloseEventCalled = true;\n this.emitToastClose(e.direction === Hammer.DIRECTION_LEFT ? \"slide-out-left\" : \"slide-out-right\");\n }\n }\n\n if (e.isFinal && Math.abs(this.percentage) < this.draggablepercentage) {\n this.hostElement.style.transform = translateObj.translateBack;\n this.hostElement.style.transition = \"all 1s\";\n this.hostElement.style.opacity = \"100%\";\n this.percentage = 0;\n }\n });\n }\n\n private onFocus(): void {\n let time = this.autoclose;\n if (this.elapsedTime) {\n time = this.autoclose - this.elapsedTime;\n }\n if (time > 0) {\n this.startClosingTimeout(time);\n }\n }\n\n private onBlur(): void {\n this.elapsedTime = Date.now() - this.startTime;\n clearTimeout(this.timeoutHandle);\n }\n\n private startClosingTimeout(time: number): void {\n this.timeoutHandle = window.setTimeout(() => this.emitToastClose(this.mapSlideOutClass()), time);\n }\n\n private renderContent(): HTMLDivElement {\n return (\n <div\n id=\"external-container\"\n tabIndex={0}\n class={{[this.type]: !!this.type}}\n >\n <div id=\"inner-container\">\n <div id=\"text\">\n {this.heading && <span class=\"title\">{this.heading}</span>}\n <span class=\"message\">{this.message}</span>\n </div>\n <div id=\"button\">\n <slot name=\"button\" />\n </div>\n </div>\n <div id=\"icon\">\n {this.closebutton && (\n <z-icon\n tabIndex={0}\n name=\"multiply-circled\"\n width={15}\n height={15}\n onClick={() => this.emitToastClose(this.mapSlideOutClass())}\n onKeyPress={(e) => {\n if (e.code == KeyboardCode.SPACE || e.code == KeyboardCode.ENTER) {\n e.preventDefault();\n this.emitToastClose(this.mapSlideOutClass());\n }\n }}\n />\n )}\n </div>\n </div>\n );\n }\n\n render(): HTMLZToastNotificationElement {\n return (\n <Host\n style={{\"--percentuale\": `${this.percentage}%`}}\n class={this.transition ? this.transition : ToastNotificationTransition.SLIDE_IN_DOWN}\n onAnimationEnd={(e: AnimationEvent) => {\n if (this.autoclose && e.animationName.includes(\"slidein\")) {\n this.startClosingTimeout(this.autoclose);\n }\n if (e.animationName.includes(\"slideout\")) {\n this.hostElement.parentNode.removeChild(this.hostElement);\n }\n }}\n >\n {this.renderContent()}\n </Host>\n );\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { html } from "lit";
|
|
|
2
2
|
import { ToastNotification, ToastNotificationTransition } from "../../beans";
|
|
3
3
|
import "../z-button/index";
|
|
4
4
|
import "./index";
|
|
5
|
+
const longText = "Testo decisamente lungo, che non sta su 1 sola riga. Questo testo occupa varie righe ed è un esempio di come vengono posizionati gli elementi in caso di testo lungo.";
|
|
5
6
|
const template = (args) => html `<div class="toast-container">
|
|
6
7
|
<z-toast-notification
|
|
7
8
|
heading="${args.heading}"
|
|
@@ -52,14 +53,16 @@ export const SlideInLeft = {
|
|
|
52
53
|
transition: ToastNotificationTransition.SLIDE_IN_LEFT,
|
|
53
54
|
},
|
|
54
55
|
};
|
|
55
|
-
export const
|
|
56
|
+
export const SlideInDownNoCloseButton = {
|
|
56
57
|
args: {
|
|
57
58
|
transition: ToastNotificationTransition.SLIDE_IN_DOWN,
|
|
59
|
+
closebutton: false,
|
|
58
60
|
},
|
|
59
61
|
};
|
|
60
|
-
export const
|
|
62
|
+
export const SlideInUpLongText = {
|
|
61
63
|
args: {
|
|
62
64
|
transition: ToastNotificationTransition.SLIDE_IN_UP,
|
|
65
|
+
message: longText,
|
|
63
66
|
},
|
|
64
67
|
};
|
|
65
68
|
export const SlottedButton = {
|
|
@@ -87,4 +90,29 @@ export const SlottedButton = {
|
|
|
87
90
|
</z-toast-notification>
|
|
88
91
|
</div>`,
|
|
89
92
|
};
|
|
93
|
+
export const SlottedButtonLongText = {
|
|
94
|
+
args: {
|
|
95
|
+
transition: ToastNotificationTransition.SLIDE_IN_DOWN,
|
|
96
|
+
},
|
|
97
|
+
render: (args) => html `<div class="toast-container slotted-button">
|
|
98
|
+
<z-toast-notification
|
|
99
|
+
heading="Titolo abbastanza lungo"
|
|
100
|
+
message=${longText}
|
|
101
|
+
closebutton="${args.closebutton}"
|
|
102
|
+
autoclose="${args.autoclose}"
|
|
103
|
+
pauseonfocusloss="${args.pauseonfocusloss}"
|
|
104
|
+
type="${args.type}"
|
|
105
|
+
isdraggable="${args.isdraggable}"
|
|
106
|
+
draggablepercentage="${args.draggablepercentage}"
|
|
107
|
+
transition="${args.transition}"
|
|
108
|
+
>
|
|
109
|
+
<z-button
|
|
110
|
+
slot="button"
|
|
111
|
+
size="small"
|
|
112
|
+
variant="tertiary"
|
|
113
|
+
>button</z-button
|
|
114
|
+
>
|
|
115
|
+
</z-toast-notification>
|
|
116
|
+
</div>`,
|
|
117
|
+
};
|
|
90
118
|
//# sourceMappingURL=index.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.stories.js","sourceRoot":"","sources":["../../../../src/components/z-toast-notification/index.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAsB,MAAM,KAAK,CAAC;AAE9C,OAAO,EAAC,iBAAiB,EAAE,2BAA2B,EAAC,MAAM,aAAa,CAAC;AAC3E,OAAO,mBAAmB,CAAC;AAC3B,OAAO,SAAS,CAAC;AAEjB,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAkB,EAAE,CACxC,IAAI,CAAA;;iBAEW,IAAI,CAAC,OAAO;iBACZ,IAAI,CAAC,OAAO;qBACR,IAAI,CAAC,WAAW;mBAClB,IAAI,CAAC,SAAS;0BACP,IAAI,CAAC,gBAAgB;cACjC,IAAI,CAAC,IAAI;qBACF,IAAI,CAAC,WAAW;6BACR,IAAI,CAAC,mBAAmB;oBACjC,IAAI,CAAC,UAAU;;SAE1B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.stories.js","sourceRoot":"","sources":["../../../../src/components/z-toast-notification/index.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAsB,MAAM,KAAK,CAAC;AAE9C,OAAO,EAAC,iBAAiB,EAAE,2BAA2B,EAAC,MAAM,aAAa,CAAC;AAC3E,OAAO,mBAAmB,CAAC;AAC3B,OAAO,SAAS,CAAC;AAEjB,MAAM,QAAQ,GACZ,uKAAuK,CAAC;AAE1K,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAkB,EAAE,CACxC,IAAI,CAAA;;iBAEW,IAAI,CAAC,OAAO;iBACZ,IAAI,CAAC,OAAO;qBACR,IAAI,CAAC,WAAW;mBAClB,IAAI,CAAC,SAAS;0BACP,IAAI,CAAC,gBAAgB;cACjC,IAAI,CAAC,IAAI;qBACF,IAAI,CAAC,WAAW;6BACR,IAAI,CAAC,mBAAmB;oBACjC,IAAI,CAAC,UAAU;;SAE1B,CAAC;AAEV,MAAM,SAAS,GAAG;IAChB,KAAK,EAAE,oBAAoB;IAC3B,SAAS,EAAE,sBAAsB;IACjC,QAAQ,EAAE;QACR,IAAI,EAAE;YACJ,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;aACf;YACD,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC;SAC1C;QACD,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;aACf;YACD,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAAC;SACpD;KACF;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,iCAAiC;QAC1C,W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2BAA2B,CAAC,aAAa;KACtD;IACD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CACf,IAAI,CAAA;;;kBAGU,QAAQ;uBACH,IAAI,CAAC,WAAW;qBAClB,IAAI,CAAC,SAAS;4BACP,IAAI,CAAC,gBAAgB;gBACjC,IAAI,CAAC,IAAI;uBACF,IAAI,CAAC,WAAW;+BACR,IAAI,CAAC,mBAAmB;sBACjC,IAAI,CAAC,UAAU;;;;;;;;;WAS1B;CACM,CAAC","sourcesContent":["import {Meta, StoryObj} from \"@storybook/web-components\";\nimport {html, type TemplateResult} from \"lit\";\nimport {type ZToastNotification} from \".\";\nimport {ToastNotification, ToastNotificationTransition} from \"../../beans\";\nimport \"../z-button/index\";\nimport \"./index\";\n\nconst longText =\n \"Testo decisamente lungo, che non sta su 1 sola riga. Questo testo occupa varie righe ed è un esempio di come vengono posizionati gli elementi in caso di testo lungo.\";\n\nconst template = (args): TemplateResult =>\n html`<div class=\"toast-container\">\n <z-toast-notification\n heading=\"${args.heading}\"\n message=\"${args.message}\"\n closebutton=\"${args.closebutton}\"\n autoclose=\"${args.autoclose}\"\n pauseonfocusloss=\"${args.pauseonfocusloss}\"\n type=\"${args.type}\"\n isdraggable=\"${args.isdraggable}\"\n draggablepercentage=\"${args.draggablepercentage}\"\n transition=\"${args.transition}\"\n ></z-toast-notification>\n </div>`;\n\nconst StoryMeta = {\n title: \"ZToastNotification\",\n component: \"z-toast-notification\",\n argTypes: {\n type: {\n control: {\n type: \"select\",\n },\n options: Object.values(ToastNotification),\n },\n transition: {\n control: {\n type: \"select\",\n },\n options: Object.values(ToastNotificationTransition),\n },\n },\n args: {\n heading: \"Titolo\",\n message: \"Questo è un messaggio di prova.\",\n closebutton: true,\n autoclose: null,\n pauseonfocusloss: false,\n type: ToastNotification.DARK,\n isdraggable: true,\n draggablepercentage: 80,\n transition: ToastNotificationTransition.SLIDE_IN_RIGHT,\n },\n render: (args) => template(args),\n} satisfies Meta<ZToastNotification>;\n\nexport default StoryMeta;\n\ntype Story = StoryObj<ZToastNotification>;\nexport const SlideInRight = {} satisfies Story;\n\nexport const SlideInLeft = {\n args: {\n transition: ToastNotificationTransition.SLIDE_IN_LEFT,\n },\n} satisfies Story;\n\nexport const SlideInDownNoCloseButton = {\n args: {\n transition: ToastNotificationTransition.SLIDE_IN_DOWN,\n closebutton: false,\n },\n} satisfies Story;\n\nexport const SlideInUpLongText = {\n args: {\n transition: ToastNotificationTransition.SLIDE_IN_UP,\n message: longText,\n },\n} satisfies Story;\n\nexport const SlottedButton = {\n args: {\n transition: ToastNotificationTransition.SLIDE_IN_DOWN,\n },\n render: (args) =>\n html`<div class=\"toast-container slotted-button\">\n <z-toast-notification\n heading=\"${args.heading}\"\n message=\"${args.message}\"\n closebutton=\"${args.closebutton}\"\n autoclose=\"${args.autoclose}\"\n pauseonfocusloss=\"${args.pauseonfocusloss}\"\n type=\"${args.type}\"\n isdraggable=\"${args.isdraggable}\"\n draggablepercentage=\"${args.draggablepercentage}\"\n transition=\"${args.transition}\"\n >\n <z-button\n slot=\"button\"\n size=\"small\"\n variant=\"tertiary\"\n >button</z-button\n >\n </z-toast-notification>\n </div>`,\n} satisfies Story;\n\nexport const SlottedButtonLongText = {\n args: {\n transition: ToastNotificationTransition.SLIDE_IN_DOWN,\n },\n render: (args) =>\n html`<div class=\"toast-container slotted-button\">\n <z-toast-notification\n heading=\"Titolo abbastanza lungo\"\n message=${longText}\n closebutton=\"${args.closebutton}\"\n autoclose=\"${args.autoclose}\"\n pauseonfocusloss=\"${args.pauseonfocusloss}\"\n type=\"${args.type}\"\n isdraggable=\"${args.isdraggable}\"\n draggablepercentage=\"${args.draggablepercentage}\"\n transition=\"${args.transition}\"\n >\n <z-button\n slot=\"button\"\n size=\"small\"\n variant=\"tertiary\"\n >button</z-button\n >\n </z-toast-notification>\n </div>`,\n} satisfies Story;\n"]}
|
|
@@ -142,10 +142,10 @@
|
|
|
142
142
|
|
|
143
143
|
:host > #external-container {
|
|
144
144
|
display: flex;
|
|
145
|
+
min-height: calc(var(--space-unit) * 8.5);
|
|
145
146
|
box-sizing: border-box;
|
|
146
|
-
align-items: flex-start;
|
|
147
147
|
justify-content: space-between;
|
|
148
|
-
padding: calc(var(--space-unit) * 2);
|
|
148
|
+
padding: calc(var(--space-unit) * 2) 14px calc(var(--space-unit) * 2) calc(var(--space-unit) * 2);
|
|
149
149
|
border-radius: var(--border-size-large);
|
|
150
150
|
box-shadow: var(--shadow-3);
|
|
151
151
|
font-family: var(--font-family-sans);
|
|
@@ -154,58 +154,50 @@
|
|
|
154
154
|
letter-spacing: 0.16px;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
:host > #external-container
|
|
158
|
-
align-self: flex-start;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
:host > #external-container.several-lines-padding {
|
|
162
|
-
padding: calc(var(--space-unit) * 2);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
:host > #external-container > #flex-container {
|
|
157
|
+
:host > #external-container > #inner-container {
|
|
166
158
|
display: flex;
|
|
167
159
|
width: 100%;
|
|
168
|
-
flex-
|
|
169
|
-
align-items: center;
|
|
160
|
+
flex-direction: column;
|
|
170
161
|
justify-content: space-between;
|
|
171
162
|
}
|
|
172
163
|
|
|
173
|
-
:host > #external-container #text {
|
|
174
|
-
|
|
164
|
+
:host > #external-container #inner-container #text {
|
|
165
|
+
padding: var(--space-unit) 0;
|
|
175
166
|
color: var(--color-text-inverse);
|
|
176
167
|
letter-spacing: 0.16px;
|
|
177
168
|
line-height: 20px;
|
|
178
|
-
text-align:
|
|
169
|
+
text-align: start;
|
|
179
170
|
}
|
|
180
171
|
|
|
181
|
-
:host > #external-container #text > .title {
|
|
172
|
+
:host > #external-container #inner-container #text > .title {
|
|
182
173
|
margin-right: calc(var(--space-unit) / 2);
|
|
183
|
-
font-weight:
|
|
174
|
+
font-weight: var(--font-sb);
|
|
184
175
|
}
|
|
185
176
|
|
|
186
|
-
:host > #external-container
|
|
187
|
-
margin-top:
|
|
177
|
+
:host > #external-container #inner-container ::slotted([slot="button"]) {
|
|
178
|
+
margin-top: var(--space-unit);
|
|
188
179
|
}
|
|
189
180
|
|
|
190
181
|
:host > #external-container #icon {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
align-items: center;
|
|
194
|
-
margin-left: calc(var(--space-unit) * 2);
|
|
182
|
+
padding-top: var(--space-unit);
|
|
183
|
+
margin: 0 calc(var(--space-unit) / 4);
|
|
195
184
|
cursor: pointer;
|
|
196
185
|
fill: var(--color-inverse-icon);
|
|
197
186
|
}
|
|
198
187
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
188
|
+
:host > #external-container #icon:focus-within {
|
|
189
|
+
margin: 0;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
:host > #external-container #icon z-icon {
|
|
193
|
+
margin: 0 0 0 14px;
|
|
202
194
|
}
|
|
203
195
|
|
|
204
|
-
z-icon:focus {
|
|
196
|
+
:host > #external-container #icon z-icon:focus {
|
|
197
|
+
display: inline-block;
|
|
205
198
|
padding: calc(var(--space-unit) / 4);
|
|
206
199
|
border-radius: 50%;
|
|
207
200
|
box-shadow: var(--shadow-focus-primary);
|
|
208
|
-
outline: none !important;
|
|
209
201
|
}
|
|
210
202
|
|
|
211
203
|
:host > #external-container.dark {
|
|
@@ -252,19 +244,18 @@ z-icon:focus {
|
|
|
252
244
|
max-width: 50vw;
|
|
253
245
|
}
|
|
254
246
|
|
|
255
|
-
:host > #external-container
|
|
256
|
-
flex-
|
|
247
|
+
:host > #external-container #inner-container {
|
|
248
|
+
flex-direction: row;
|
|
257
249
|
}
|
|
258
250
|
|
|
259
|
-
:host > #external-container #
|
|
260
|
-
|
|
251
|
+
:host > #external-container #inner-container ::slotted([slot="button"]) {
|
|
252
|
+
margin: 0 0 0 calc(var(--space-unit) * 2);
|
|
261
253
|
}
|
|
262
254
|
}
|
|
263
255
|
|
|
264
256
|
/* Wide breakpoint */
|
|
265
257
|
@media (min-width: 1366px) {
|
|
266
258
|
:host {
|
|
267
|
-
width: unset;
|
|
268
259
|
max-width: 33vw;
|
|
269
260
|
}
|
|
270
261
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
-
import { r as ToastNotificationTransition } from './index2.js';
|
|
3
|
-
import { B as Breakpoints } from './breakpoints.js';
|
|
2
|
+
import { r as ToastNotificationTransition, g as KeyboardCode } from './index2.js';
|
|
4
3
|
import { d as defineCustomElement$2 } from './index9.js';
|
|
5
4
|
|
|
6
5
|
var hammer = {exports: {}};
|
|
@@ -2653,7 +2652,7 @@ if (typeof undefined$1 === 'function' && undefined$1.amd) {
|
|
|
2653
2652
|
|
|
2654
2653
|
const Hammer = hammer.exports;
|
|
2655
2654
|
|
|
2656
|
-
const stylesCss = ":host{display:inline-block;width:100vw;min-width:200px;--percentuale:0}:host(.slide-in-left){animation:slideinleft 1s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-in-right){animation:slideinright 1s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-in-down){animation:slideindown 1s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-in-up){animation:slideinup 1s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-out-left){animation:slideoutleft 0.5s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-out-right){animation:slideoutright 0.5s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-out-down){animation:slideoutdown 0.5s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-out-up){animation:slideoutup 0.5s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}@keyframes slideinleft{0%{transform:translateX(100%)}100%{transform:translateX(0)}}@keyframes slideinright{0%{transform:translateX(-100%)}100%{transform:translateX(0)}}@keyframes slideinup{0%{opacity:0;transform:translateY(100%)}100%{opacity:1;transform:translateY(0)}}@keyframes slideindown{0%{opacity:0;transform:translateY(-100%)}100%{opacity:1;transform:translateY(0)}}@keyframes slideoutleft{0%{opacity:calc(100% - var(--percentuale));transform:translateX(var(--percentuale))}100%{opacity:0;transform:translateX(-100%)}}@keyframes slideoutright{0%{opacity:calc(100% - var(--percentuale));transform:translateX(var(--percentuale))}100%{opacity:0;transform:translateX(100%)}}@keyframes slideoutup{0%{opacity:1;transform:translateY(var(--percentuale))}100%{opacity:0;transform:translateY(-100%)}}@keyframes slideoutdown{0%{opacity:1;transform:translateY(var(--percentuale))}100%{opacity:0;transform:translateY(100%)}}:host>#external-container{display:flex;box-sizing:border-box;
|
|
2655
|
+
const stylesCss = ":host{display:inline-block;width:100vw;min-width:200px;--percentuale:0}:host(.slide-in-left){animation:slideinleft 1s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-in-right){animation:slideinright 1s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-in-down){animation:slideindown 1s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-in-up){animation:slideinup 1s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-out-left){animation:slideoutleft 0.5s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-out-right){animation:slideoutright 0.5s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-out-down){animation:slideoutdown 0.5s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-out-up){animation:slideoutup 0.5s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}@keyframes slideinleft{0%{transform:translateX(100%)}100%{transform:translateX(0)}}@keyframes slideinright{0%{transform:translateX(-100%)}100%{transform:translateX(0)}}@keyframes slideinup{0%{opacity:0;transform:translateY(100%)}100%{opacity:1;transform:translateY(0)}}@keyframes slideindown{0%{opacity:0;transform:translateY(-100%)}100%{opacity:1;transform:translateY(0)}}@keyframes slideoutleft{0%{opacity:calc(100% - var(--percentuale));transform:translateX(var(--percentuale))}100%{opacity:0;transform:translateX(-100%)}}@keyframes slideoutright{0%{opacity:calc(100% - var(--percentuale));transform:translateX(var(--percentuale))}100%{opacity:0;transform:translateX(100%)}}@keyframes slideoutup{0%{opacity:1;transform:translateY(var(--percentuale))}100%{opacity:0;transform:translateY(-100%)}}@keyframes slideoutdown{0%{opacity:1;transform:translateY(var(--percentuale))}100%{opacity:0;transform:translateY(100%)}}:host>#external-container{display:flex;min-height:calc(var(--space-unit) * 8.5);box-sizing:border-box;justify-content:space-between;padding:calc(var(--space-unit) * 2) 14px calc(var(--space-unit) * 2) calc(var(--space-unit) * 2);border-radius:var(--border-size-large);box-shadow:var(--shadow-3);font-family:var(--font-family-sans);font-size:var(--font-size-2);font-weight:var(--font-rg);letter-spacing:0.16px}:host>#external-container>#inner-container{display:flex;width:100%;flex-direction:column;justify-content:space-between}:host>#external-container #inner-container #text{padding:var(--space-unit) 0;color:var(--color-text-inverse);letter-spacing:0.16px;line-height:20px;text-align:start}:host>#external-container #inner-container #text>.title{margin-right:calc(var(--space-unit) / 2);font-weight:var(--font-sb)}:host>#external-container #inner-container ::slotted([slot=\"button\"]){margin-top:var(--space-unit)}:host>#external-container #icon{padding-top:var(--space-unit);margin:0 calc(var(--space-unit) / 4);cursor:pointer;fill:var(--color-inverse-icon)}:host>#external-container #icon:focus-within{margin:0}:host>#external-container #icon z-icon{margin:0 0 0 14px}:host>#external-container #icon z-icon:focus{display:inline-block;padding:calc(var(--space-unit) / 4);border-radius:50%;box-shadow:var(--shadow-focus-primary)}:host>#external-container.dark{background:var(--color-surface05)}:host>#external-container.light{background:var(--color-surface01)}:host>#external-container.light #icon{fill:var(--color-primary01-icon)}:host>#external-container.light #text,:host>#external-container.warning #text{color:var(--color-default-text)}:host>#external-container.accent{background:var(--color-primary01)}:host>#external-container.error{background:var(--color-default-error)}:host>#external-container.success{background:var(--color-default-success)}:host>#external-container.warning{background:var(--color-default-warning)}:host>#external-container.warning #icon{fill:var(--color-default-icon)}@media (min-width: 768px){:host{width:unset;max-width:50vw}:host>#external-container #inner-container{flex-direction:row}:host>#external-container #inner-container ::slotted([slot=\"button\"]){margin:0 0 0 calc(var(--space-unit) * 2)}}@media (min-width: 1366px){:host{max-width:33vw}}";
|
|
2657
2656
|
const ZToastNotificationStyle0 = stylesCss;
|
|
2658
2657
|
|
|
2659
2658
|
const ZToastNotification$1 = /*@__PURE__*/ proxyCustomElement(class ZToastNotification extends HTMLElement {
|
|
@@ -2703,12 +2702,10 @@ const ZToastNotification$1 = /*@__PURE__*/ proxyCustomElement(class ZToastNotifi
|
|
|
2703
2702
|
this.toastClose.emit();
|
|
2704
2703
|
}
|
|
2705
2704
|
componentWillLoad() {
|
|
2706
|
-
this.isMobile = window.innerWidth <= Breakpoints.MOBILE;
|
|
2707
2705
|
this.validateAutoclose();
|
|
2708
2706
|
this.percentage = 0;
|
|
2709
2707
|
}
|
|
2710
2708
|
componentDidLoad() {
|
|
2711
|
-
this.isTextLong = this.detectWrap() || this.toastText.offsetHeight > 20;
|
|
2712
2709
|
this.startTime = Date.now();
|
|
2713
2710
|
if (this.autoclose && this.pauseonfocusloss) {
|
|
2714
2711
|
document.addEventListener("visibilitychange", this.visibilityChangeEventHandler);
|
|
@@ -2789,56 +2786,23 @@ const ZToastNotification$1 = /*@__PURE__*/ proxyCustomElement(class ZToastNotifi
|
|
|
2789
2786
|
startClosingTimeout(time) {
|
|
2790
2787
|
this.timeoutHandle = window.setTimeout(() => this.emitToastClose(this.mapSlideOutClass()), time);
|
|
2791
2788
|
}
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
let totalWidth = 0;
|
|
2796
|
-
for (let i = 0; i < children.length; i++) {
|
|
2797
|
-
totalWidth += children[i].offsetWidth;
|
|
2798
|
-
}
|
|
2799
|
-
return totalWidth > parentWidth;
|
|
2800
|
-
}
|
|
2801
|
-
renderText() {
|
|
2802
|
-
return (h("div", { id: "text", ref: (el) => (this.toastText = el) }, this.heading && h("span", { class: "title" }, this.heading), h("span", { class: "message" }, this.message)));
|
|
2803
|
-
}
|
|
2804
|
-
renderButton() {
|
|
2805
|
-
return (h("div", { id: "button" }, h("slot", { name: "button" })));
|
|
2806
|
-
}
|
|
2807
|
-
renderCloseIcon() {
|
|
2808
|
-
if (!this.closebutton) {
|
|
2809
|
-
return;
|
|
2810
|
-
}
|
|
2811
|
-
return (h("div", { id: "icon" }, h("z-icon", { tabIndex: 0, name: "multiply-circled", width: 15, height: 15, onClick: () => this.emitToastClose(this.mapSlideOutClass()), onKeyPress: (e) => {
|
|
2812
|
-
if (e.keyCode == 32 || e.keyCode == 13) {
|
|
2789
|
+
renderContent() {
|
|
2790
|
+
return (h("div", { id: "external-container", tabIndex: 0, class: { [this.type]: !!this.type } }, h("div", { id: "inner-container" }, h("div", { id: "text" }, this.heading && h("span", { class: "title" }, this.heading), h("span", { class: "message" }, this.message)), h("div", { id: "button" }, h("slot", { name: "button" }))), h("div", { id: "icon" }, this.closebutton && (h("z-icon", { tabIndex: 0, name: "multiply-circled", width: 15, height: 15, onClick: () => this.emitToastClose(this.mapSlideOutClass()), onKeyPress: (e) => {
|
|
2791
|
+
if (e.code == KeyboardCode.SPACE || e.code == KeyboardCode.ENTER) {
|
|
2813
2792
|
e.preventDefault();
|
|
2814
2793
|
this.emitToastClose(this.mapSlideOutClass());
|
|
2815
2794
|
}
|
|
2816
|
-
} })));
|
|
2817
|
-
}
|
|
2818
|
-
renderContainer() {
|
|
2819
|
-
return (h("div", { tabIndex: 0, id: "external-container", class: {
|
|
2820
|
-
[this.type]: !!this.type,
|
|
2821
|
-
"several-lines-padding": this.isTextLong,
|
|
2822
|
-
}, ref: (el) => (this.container = el) }, this.renderText(), this.renderButton(), this.renderCloseIcon()));
|
|
2823
|
-
}
|
|
2824
|
-
renderMobileContainer() {
|
|
2825
|
-
return (h("div", { id: "external-container", class: {
|
|
2826
|
-
[this.type]: !!this.type,
|
|
2827
|
-
"several-lines-padding": this.isTextLong,
|
|
2828
|
-
"mobile-wrapped": this.isTextLong,
|
|
2829
|
-
} }, h("div", { id: "flex-container", ref: (el) => (this.container = el) }, this.renderText(), this.renderButton()), this.renderCloseIcon()));
|
|
2795
|
+
} })))));
|
|
2830
2796
|
}
|
|
2831
2797
|
render() {
|
|
2832
|
-
return (h(Host, { key: '
|
|
2833
|
-
"--percentuale": `${this.percentage}%`,
|
|
2834
|
-
}, class: this.transition ? this.transition : ToastNotificationTransition.SLIDE_IN_DOWN, onAnimationEnd: (e) => {
|
|
2798
|
+
return (h(Host, { key: 'f9b4a2fe7d3642b1cbbe6f2e433ddbbde49568fd', style: { "--percentuale": `${this.percentage}%` }, class: this.transition ? this.transition : ToastNotificationTransition.SLIDE_IN_DOWN, onAnimationEnd: (e) => {
|
|
2835
2799
|
if (this.autoclose && e.animationName.includes("slidein")) {
|
|
2836
2800
|
this.startClosingTimeout(this.autoclose);
|
|
2837
2801
|
}
|
|
2838
2802
|
if (e.animationName.includes("slideout")) {
|
|
2839
2803
|
this.hostElement.parentNode.removeChild(this.hostElement);
|
|
2840
2804
|
}
|
|
2841
|
-
} }, this.
|
|
2805
|
+
} }, this.renderContent()));
|
|
2842
2806
|
}
|
|
2843
2807
|
get hostElement() { return this; }
|
|
2844
2808
|
static get watchers() { return {
|