{"version":3,"sources":["components/notifications.js"],"names":["dmx","Component","attributes","position","type","String","default","enum","align","offsetX","Number","offsetY","spacing","opacity","timeout","extendedTimeout","showAnimation","showDuration","hideAnimation","hideDuration","closeAnimation","closeDuration","closeIcon","closable","Boolean","infoBackground","infoColor","infoIcon","successIcon","successBackground","successColor","warningIcon","warningBackground","warningColor","dangerIcon","dangerBackground","dangerColor","methods","clear","this","_clear","msg","message","options","_show","info","Object","assign","icon","props","color","background","success","warning","danger","events","click","CustomEvent","init","_alignMap","left","right","full","start","center","end","stretch","render","node","classList","add","setAttribute","_update","performUpdate","updatedProps","$node","textContent","style","setProperty","_template","tpl","title","_create","template","div","document","createElement","innerHTML","firstChild","notify","addEventListener","dispatchEvent","bind","detail","querySelector","_close","_pause","_continue","timeoutId","setTimeout","_hide","insertBefore","remove","once","clearTimeout"],"mappings":";;;;;;AAAAA,IAAAC,UAAA,gBAAA,CAEAC,WAAA,CACAC,SAAA,CACAC,KAAAC,OACAC,QAAA,MACAC,KAAA,CAAA,MAAA,WAGAC,MAAA,CACAJ,KAAAC,OACAC,QAAA,MACAC,KAAA,CAAA,OAAA,QAAA,OAAA,QAAA,SAAA,MAAA,YAIAE,QAAA,CACAL,KAAAM,OACAJ,QAAA,IAGAK,QAAA,CACAP,KAAAM,OACAJ,QAAA,IAGAM,QAAA,CACAR,KAAAM,OACAJ,QAAA,IAGAO,QAAA,CACAT,KAAAM,OACAJ,QAAA,IAGAQ,QAAA,CACAV,KAAAM,OACAJ,QAAA,KAGAS,gBAAA,CACAX,KAAAM,OACAJ,QAAA,KAGAU,cAAA,CACAZ,KAAAC,OACAC,QAAA,UAGAW,aAAA,CACAb,KAAAM,OACAJ,QAAA,KAGAY,cAAA,CACAd,KAAAC,OACAC,QAAA,WAGAa,aAAA,CACAf,KAAAM,OACAJ,QAAA,KAGAc,eAAA,CACAhB,KAAAC,OACAC,QAAA,WAGAe,cAAA,CACAjB,KAAAM,OACAJ,QAAA,KAGAgB,UAAA,CACAlB,K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BACAqE,EAAAZ,MAAAC,YAAA,qBAAAnC,EAAAtB,cAAA,MACAoE,EAAAC,iBAAA,gBAAA,IAAAD,EAAAa,UAAA,CAAAC,MAAA,KAEAd,EAAAa,QAEA,EAEAN,OAAA,SAAAP,EAAA9C,GACA6D,aAAAf,EAAAS,UACA,EAEAD,UAAA,SAAAR,EAAA9C,IACAA,EAAA7B,SAAA6B,EAAA5B,mBACA0E,EAAAS,UAAAC,WAAA5D,KAAA6D,MAAAR,KAAArD,KAAAkD,EAAA9C,GAAAA,EAAA5B,iBAEA","file":"dmxNotifications.js","sourcesContent":["dmx.Component('notifications', {\r\n\r\n attributes: {\r\n position: {\r\n type: String,\r\n default: 'top',\r\n enum: ['top', 'bottom'],\r\n },\r\n\r\n align: {\r\n type: String,\r\n default: 'end',\r\n enum: ['left', 'right', 'full', 'start', 'center', 'end', 'stretch'],\r\n // start, end, center, stretch are new options, left, right and are deprecated but still supported\r\n },\r\n\r\n offsetX: {\r\n type: Number,\r\n default: 15,\r\n },\r\n\r\n offsetY: {\r\n type: Number,\r\n default: 15,\r\n },\r\n\r\n spacing: {\r\n type: Number,\r\n default: 10,\r\n },\r\n\r\n opacity: {\r\n type: Number,\r\n default: 0.8,\r\n },\r\n\r\n timeout: {\r\n type: Number,\r\n default: 5000, // How long the notify will display without any interaction (0 to make sticky)\r\n },\r\n\r\n extendedTimeout: {\r\n type: Number,\r\n default: 1000,\r\n },\r\n\r\n showAnimation: {\r\n type: String,\r\n default: 'fadeIn',\r\n },\r\n\r\n showDuration: {\r\n type: Number,\r\n default: 400,\r\n },\r\n\r\n hideAnimation: {\r\n type: String,\r\n default: 'fadeOut',\r\n },\r\n\r\n hideDuration: {\r\n type: Number,\r\n default: 400,\r\n },\r\n\r\n closeAnimation: {\r\n type: String,\r\n default: 'fadeOut',\r\n },\r\n\r\n closeDuration: {\r\n type: Number,\r\n default: 400,\r\n },\r\n\r\n closeIcon: {\r\n type: String,\r\n default: 'fa fa-times',\r\n },\r\n\r\n closable: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n\r\n infoBackground: {\r\n type: String,\r\n default: '#2f96b4',\r\n },\r\n\r\n infoColor: {\r\n type: String,\r\n default: '#fff',\r\n },\r\n\r\n infoIcon: {\r\n type: String,\r\n default: 'fa fa-info',\r\n },\r\n\r\n successIcon: {\r\n type: String,\r\n default: 'fa fa-check',\r\n },\r\n\r\n successBackground: {\r\n type: String,\r\n default: '#51a351',\r\n },\r\n\r\n successColor: {\r\n type: String,\r\n default: '#fff',\r\n },\r\n\r\n warningIcon: {\r\n type: String,\r\n default: 'fa fa-exclamation',\r\n },\r\n\r\n warningBackground: {\r\n type: String,\r\n default: '#f89406',\r\n },\r\n\r\n warningColor: {\r\n type: String,\r\n default: '#fff',\r\n },\r\n\r\n dangerIcon: {\r\n type: String,\r\n default: 'fa fa-warning',\r\n },\r\n\r\n dangerBackground: {\r\n type: String,\r\n default: '#bd362f',\r\n },\r\n\r\n dangerColor: {\r\n type: String,\r\n default: '#fff',\r\n },\r\n },\r\n\r\n methods: {\r\n clear () {\r\n this._clear();\r\n },\r\n\r\n msg (message, options) {\r\n this._show('msg', message, options);\r\n },\r\n\r\n info (message, options) {\r\n this._show(\r\n 'info',\r\n message,\r\n Object.assign(\r\n {\r\n icon: this.props.infoIcon,\r\n color: this.props.infoColor,\r\n background: this.props.infoBackground,\r\n },\r\n options\r\n )\r\n );\r\n },\r\n\r\n success (message, options) {\r\n this._show(\r\n 'success',\r\n message,\r\n Object.assign(\r\n {\r\n icon: this.props.successIcon,\r\n color: this.props.successColor,\r\n background: this.props.successBackground,\r\n },\r\n options\r\n )\r\n );\r\n },\r\n\r\n warning (message, options) {\r\n this._show(\r\n 'warning',\r\n message,\r\n Object.assign(\r\n {\r\n icon: this.props.warningIcon,\r\n color: this.props.warningColor,\r\n background: this.props.warningBackground,\r\n },\r\n options\r\n )\r\n );\r\n },\r\n\r\n danger: function (message, options) {\r\n this._show(\r\n 'danger',\r\n message,\r\n Object.assign(\r\n {\r\n icon: this.props.dangerIcon,\r\n color: this.props.dangerColor,\r\n background: this.props.dangerBackground,\r\n },\r\n options\r\n )\r\n );\r\n },\r\n },\r\n\r\n events: {\r\n click: CustomEvent,\r\n },\r\n\r\n init () {\r\n this._alignMap = {\r\n left: 'flex-start',\r\n right: 'flex-end',\r\n full: 'stretch',\r\n start: 'flex-start',\r\n center: 'center',\r\n end: 'flex-end',\r\n stretch: 'stretch',\r\n };\r\n },\r\n\r\n render (node) {\r\n node.classList.add('dmx-notifications');\r\n node.setAttribute('aria-live', 'polite');\r\n node.setAttribute('aria-atomic', 'true');\r\n\r\n this._clear();\r\n this._update();\r\n },\r\n\r\n performUpdate (updatedProps) {\r\n this._update();\r\n },\r\n\r\n _clear: function () {\r\n this.$node.textContent = '';\r\n },\r\n\r\n _update () {\r\n this.$node.style.setProperty('--dmx-notify-offset-x', this.props.offsetX + 'px');\r\n this.$node.style.setProperty('--dmx-notify-offset-y', this.props.offsetY + 'px');\r\n this.$node.style.setProperty('--dmx-notify-align', this._alignMap[this.props.align]);\r\n this.$node.style.setProperty('--dmx-notify-gap', this.props.spacing + 'px');\r\n this.$node.style.setProperty('--dmx-notify-direction', this.props.position == 'top' ? 'column' : 'column-reverse');\r\n },\r\n\r\n _template (options) {\r\n let tpl = `
`;\r\n if (options.icon) tpl += `
`;\r\n tpl += `
`;\r\n if (options.title) tpl += `
${options.title}
`;\r\n if (options.message) tpl += `
${options.message}
`;\r\n tpl += `
`;\r\n if (options.closable) tpl += ``;\r\n tpl += `
`;\r\n\r\n return tpl;\r\n },\r\n\r\n _create: function (options) {\r\n var template = this._template(options);\r\n var div = document.createElement('div');\r\n div.innerHTML = template;\r\n return div.firstChild;\r\n },\r\n\r\n _show: function (type, message, options) {\r\n options = Object.assign(\r\n { type: type, message: message, background: '#eee', color: '#333' },\r\n this.props,\r\n options\r\n );\r\n\r\n var notify = this._create(options);\r\n\r\n notify.style.setProperty('animation-name', options.showAnimation);\r\n notify.style.setProperty('animation-duration', options.showDuration + 'ms');\r\n\r\n notify.addEventListener('click', this.dispatchEvent.bind(this, 'click', { detail: options }));\r\n\r\n if (options.closable) {\r\n notify.querySelector('.dmx-notify-close').addEventListener('click', this._close.bind(this, notify, options));\r\n } else if (!options.timeout) {\r\n // if not closable and not timeout, hide after 5 seconds\r\n options.timeout = 5000;\r\n }\r\n\r\n if (options.timeout) {\r\n notify.addEventListener('mouseenter', this._pause.bind(this, notify, options));\r\n notify.addEventListener('mouseleave', this._continue.bind(this, notify, options));\r\n notify.timeoutId = setTimeout(this._hide.bind(this, notify, options), options.showDuration + options.timeout);\r\n }\r\n\r\n this.$node.insertBefore(notify, this.$node.firstChild);\r\n },\r\n\r\n _hide: function (notify, options) {\r\n if (options.hideAnimation && options.hideDuration) {\r\n notify.style.setProperty('animation-name', options.hideAnimation);\r\n notify.style.setProperty('animation-duration', options.hideDuration + 'ms');\r\n notify.addEventListener('animationend', () => notify.remove(), { once: true });\r\n } else {\r\n notify.remove();\r\n }\r\n },\r\n\r\n _close: function (notify, options) {\r\n if (options.closeAnimation && options.closeDuration) {\r\n notify.style.setProperty('animation-name', options.closeAnimation);\r\n notify.style.setProperty('animation-duration', options.closeDuration + 'ms');\r\n notify.addEventListener('animationend', () => notify.remove(), { once: true });\r\n } else {\r\n notify.remove();\r\n }\r\n },\r\n\r\n _pause: function (notify, options) {\r\n clearTimeout(notify.timeoutId);\r\n },\r\n\r\n _continue: function (notify, options) {\r\n if (options.timeout || options.extendedTimeout) {\r\n notify.timeoutId = setTimeout(this._hide.bind(this, notify, options), options.extendedTimeout);\r\n }\r\n },\r\n});\r\n"]}