@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
4 lines • 2.73 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import{r as registerInstance,h,H as Host}from"./index-299a463b.js";import{w as watchHeadingLevel}from"./validation-16bfc143.js";import{K as KolAlertFc}from"./Alert-06d4d9a4.js";import{b as watchBoolean,s as setState,w as watchValidator}from"./prop.validators-17aec743.js";import{v as validateHasCloser}from"./has-closer-b582e72a.js";import{v as validateLabel}from"./label-90c13388.js";import"./tslib.es6-2e5096f8.js";import"./clsx-09a06a12.js";import"./i18n-5fe08f1c.js";import"./i18n-7ea9f137.js";import"./reuse-32931294.js";import"./component-names-4cb1c62b.js";import"./dev.utils-fab45cbc.js";import"./index-6d801dad.js";const alertTypeOptions=["default","info","success","warning","error"],alertVariantOptions=["card","msg"],KolAlertWc=class{constructor(t){registerInstance(this,t),this.close=()=>{var t,e;null===(e=null===(t=this._on)||void 0===t?void 0:t.onClose)||void 0===e||e.call(t,new Event("Close"))},this.handleAlertTimeout=()=>{this.validateAlert(!1)},this.validateOnValue=t=>"object"==typeof t&&null!==t&&"function"==typeof t.onClose,this._alert=!1,this._hasCloser=!1,this._label=void 0,this._level=1,this._on=void 0,this._type="default",this._variant="msg",this.state={_level:1}}render(){const{_alert:t,_hasCloser:e,_label:a,_level:l,_type:i,_variant:s}=this.state,o={alert:t,hasCloser:e,label:a,level:l,type:i,variant:s,onCloserClick:this.close,onAlertTimeout:this.handleAlertTimeout};return h(Host,{key:"93a18daf255ec95713c85ec926081163cb70df4a"},h(KolAlertFc,Object.assign({key:"dcfb772612cbe77e683b839474ce1e6e56e22dc4"},o),h("slot",{key:"daaca45ea2680f9f458dd24c41947214f391d8b2"})))}validateAlert(t){watchBoolean(this,"_alert",t)}validateHasCloser(t){validateHasCloser(this,t)}validateLabel(t){validateLabel(this,t)}validateLevel(t){watchHeadingLevel(this,t)}validateOn(t){this.validateOnValue(t)&&setState(this,"_on",{onClose:t.onClose})}validateType(t){watchValidator(this,"_type",(t=>"string"==typeof t&&alertTypeOptions.includes(t)),new Set(`String {${alertTypeOptions.join(", ")}`),t)}validateVariant(t){watchValidator(this,"_variant",(t=>"string"==typeof t&&alertVariantOptions.includes(t)),new Set(`AlertVariant {${alertVariantOptions.join(", ")}`),t)}componentWillLoad(){this.validateAlert(this._alert),this.validateHasCloser(this._hasCloser),this.validateLabel(this._label),this.validateLevel(this._level),this.validateOn(this._on),this.validateType(this._type),this.validateVariant(this._variant)}static get watchers(){return{_alert:["validateAlert"],_hasCloser:["validateHasCloser"],_label:["validateLabel"],_level:["validateLevel"],_on:["validateOn"],_type:["validateType"],_variant:["validateVariant"]}}};export{KolAlertWc as kol_alert_wc};