UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

4 lines 2.82 kB
/*! * KoliBri - The accessible HTML-Standard */ import{r as registerInstance,h,g as getElement}from"./index-136f59ac.js";import{h as watchBoolean,k as setState,w as watchValidator}from"./index-88dea7b1.js";import{w as watchHeadingLevel}from"./validation-66c33ff5.js";import{K as KolAlertFc}from"./Alert-3c98a2ff.js";import{d as dispatchDomEvent,K as KolEvent}from"./events-5886c68b.js";import{v as validateHasCloser}from"./has-closer-ca9bcd36.js";import{v as validateLabel}from"./label-5982d241.js";import"./tslib.es6-1173d062.js";import"./clsx-09a06a12.js";import"./component-names-799e91e2.js";import"./i18n-01abf777.js";import"./i18n-45224cc3.js";import"./bem-e4c3a2e6.js";import"./browser-f629a56a.js";import"./Heading-bb974fcc.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.host&&dispatchDomEvent(this.host,KolEvent.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=0,this._on=void 0,this._type="default",this._variant="msg",this.state={_level:0}}render(){const{_alert:t,_hasCloser:e,_label:a,_level:l,_type:s,_variant:i}=this.state,o={alert:t,hasCloser:e,label:a,level:l,type:s,variant:i,onCloserClick:this.close,onAlertTimeout:this.handleAlertTimeout};return h(KolAlertFc,Object.assign({key:"9038051f21b86a9c83c8ac5619e723dff5ebcbeb"},o),h("slot",{key:"cfd116176ab783db5232d9d5520f8ae890ca44db"}))}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)}get host(){return getElement(this)}static get watchers(){return{_alert:["validateAlert"],_hasCloser:["validateHasCloser"],_label:["validateLabel"],_level:["validateLevel"],_on:["validateOn"],_type:["validateType"],_variant:["validateVariant"]}}};export{KolAlertWc as kol_alert_wc};