{"version":3,"sources":["components/alert.js"],"names":["dmx","Component","initialData","visible","attributes","show","type","Boolean","default","String","enum","closable","methods","toggle","this","_toggle","_show","hide","_hide","setType","style","_setType","setTextContent","text","_setTextContent","init","node","_transitionendHandler","bind","_closeButton","document","createElement","setAttribute","className","addEventListener","classList","add","props","appendChild","set","setProperty","performUpdate","updatedProps","has","$node","$closeButton","remove","removeEventListener","removeProperty","offsetWidth","contains","once","types","map","apply","textContent"],"mappings":";;;;;;AAAAA,IAAAC,UAAA,YAAA,CAEAC,YAAA,CACAC,SAAA,GAGAC,WAAA,CACAC,KAAA,CACAC,KAAAC,QACAC,SAAA,GAGAF,KAAA,CACAA,KAAAG,OACAD,QAAA,UACAE,KAAA,CAAA,UAAA,YAAA,UAAA,SAAA,UAAA,OAAA,QAAA,SAGAC,SAAA,CACAL,KAAAC,QACAC,SAAA,IAIAI,QAAA,CACAC,SACAC,KAAAC,SACA,EAEAV,OACAS,KAAAE,OACA,EAEAC,OACAH,KAAAI,OACA,EAEAC,QAAAC,GACAN,KAAAO,SAAAD,EACA,EAEAE,eAAAC,GACAT,KAAAU,gBAAAD,EACA,GAGAE,KAAAC,GACAZ,KAAAa,sBAAAb,KAAAa,sBAAAC,KAAAd,MAEAA,KAAAe,aAAAC,SAAAC,cAAA,UACAjB,KAAAe,aAAAG,aAAA,OAAA,UACAlB,KAAAe,aAAAG,aAAA,aAAA,SACAlB,KAAAe,aAAAI,UAAA,YACAnB,KAAAe,aAAAK,iBAAA,QAAApB,KAAAI,MAAAU,KAAAd,OAEAY,EAAAM,aAAA,OAAA,SACAN,EAAAS,UAAAC,IAAA,SAEAtB,KAAAuB,MAAA1B,WACAe,EAAAY,YAAAxB,KAAAe,cACAH,EAAAS,UAAAC,IAAA,sBAGAtB,KAAAuB,MAAAhC,MACAqB,EAAAS,UAAAC,IAAA,QACAtB,KAAAyB,IAAA,WAAA,IAEAb,EAAAN,MAAAoB,YAAA,UAAA,QAGA1B,KAAAO,SAAAP,KAAAuB,MA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8B,MAAAN,YAAAxB,KAAAe,aAEA","file":"dmxBootstrap5Alert.js","sourcesContent":["dmx.Component('bs5-alert', {\r\n\r\n initialData: {\r\n visible: false,\r\n },\r\n\r\n attributes: {\r\n show: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n\r\n type: {\r\n type: String,\r\n default: 'primary',\r\n enum: ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark']\r\n },\r\n\r\n closable: {\r\n type: Boolean,\r\n default: false,\r\n }\r\n },\r\n\r\n methods: {\r\n toggle () {\r\n this._toggle();\r\n },\r\n\r\n show () {\r\n this._show();\r\n },\r\n\r\n hide () {\r\n this._hide();\r\n },\r\n\r\n setType (style) {\r\n this._setType(style);\r\n },\r\n\r\n setTextContent (text) {\r\n this._setTextContent(text)\r\n }\r\n },\r\n\r\n init (node) {\r\n this._transitionendHandler = this._transitionendHandler.bind(this);\r\n\r\n this._closeButton = document.createElement('button');\r\n this._closeButton.setAttribute('type', 'button');\r\n this._closeButton.setAttribute('aria-label', 'Close');\r\n this._closeButton.className = 'btn-close';\r\n this._closeButton.addEventListener('click', this._hide.bind(this));\r\n \r\n node.setAttribute('role', 'alert');\r\n node.classList.add('alert');\r\n\r\n if (this.props.closable) {\r\n node.appendChild(this._closeButton);\r\n node.classList.add('alert-dismissible');\r\n }\r\n\r\n if (this.props.show) {\r\n node.classList.add('show');\r\n this.set('visible', true);\r\n } else {\r\n node.style.setProperty('display', 'none');\r\n }\r\n\r\n this._setType(this.props.type);\r\n },\r\n\r\n performUpdate (updatedProps) {\r\n if (updatedProps.has('type')) {\r\n this._setType(this.props.type);\r\n }\r\n\r\n if (updatedProps.has('show')) {\r\n this[this.props.show ? '_show' : '_hide']();\r\n }\r\n\r\n if (updatedProps.has('closable')) {\r\n if (this.props.closable) {\r\n this.$node.appendChild(this._closeButton);\r\n this.$node.classList.add('alert-dismissible');\r\n } else {\r\n this.$closeButton.remove();\r\n this.$node.classList.remove('alert-dismissible');\r\n }\r\n }\r\n },\r\n\r\n _show: function () {\r\n this.$node.removeEventListener('transitionend', this._transitionendHandler);\r\n this.$node.style.removeProperty('display');\r\n this.$node.offsetWidth;\r\n this.$node.classList.add('show');\r\n this.set('visible', true);\r\n },\r\n\r\n _hide: function () {\r\n this.$node.removeEventListener('transitionend', this._transitionendHandler);\r\n if (this.$node.classList.contains('fade')) {\r\n this.$node.addEventListener('transitionend', this._transitionendHandler, { once: true });\r\n } else {\r\n this.$node.style.setProperty('display', 'none');\r\n }\r\n this.$node.classList.remove('show');\r\n this.set('visible', false);\r\n },\r\n\r\n _transitionendHandler: function () {\r\n this.$node.style.setProperty('display', 'none');\r\n },\r\n\r\n _setType: function (type) {\r\n var types = ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].map(function (type) { return 'alert-' + type });\r\n this.$node.classList.remove.apply(this.$node.classList, types);\r\n this.$node.classList.add('alert-' + type);\r\n },\r\n\r\n _setTextContent: function (text) {\r\n this._closeButton.remove();\r\n this.$node.textContent = text;\r\n if (this.props.closable) {\r\n this.$node.appendChild(this._closeButton);\r\n }\r\n }\r\n\r\n});\r\n"]}