import { CocoComponent } from "@js/coco"; export default CocoComponent("appAlert", () => { return { alert: null, dismissed: false, forceMultiLine: false, dismissDuration: 300, dismiss() { if (this.$options.dismissable) { this.$dispatch("alert:dismiss", { alert: this, duration: this.dismissDuration, }); this.dismissed = true; setTimeout(() => this.remove(), this.dismissDuration); } }, remove() { this.$nextTick(() => this.$dispatch("alert:removed", { alert: this })); this.$root.remove(); }, checkSingleLineWrap({ height }) { this.forceMultiLine = false; this.$nextTick(() => { this.forceMultiLine = height > 24 && this.$options.singleLine; }); }, root: { "x-options": '["dismissable", "singleLine"]', ":class": "{'force-multi-line': forceMultiLine}", }, }; });