@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
4 lines • 2.92 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import{r as registerInstance,h,g as getElement}from"./index-DyUiyxj3.js";import{K as KolAlertFc}from"./Alert-w-XRy_I0.js";import{w as watchValidator,d as watchBoolean,s as setState}from"./common-BXXICkFX.js";import{v as validateHasCloser}from"./has-closer-OxGfsISj.js";import{v as validateLabel}from"./label-Dkj9sxQK.js";import{d as dispatchDomEvent,K as KolEvent}from"./events-DHTi_wtD.js";import{w as watchHeadingLevel}from"./validation-D0gTVdAQ.js";import"./tslib.es6-CxX45GIN.js";import"./clsx-eK3rPvPS.js";import"./component-names-B_kYyA8u.js";import"./i18n-CvQhdUrE.js";import"./i18n-B0tfVPMa.js";import"./bem-De7JANRY.js";import"./browser-DaourpHc.js";import"./Heading-C1x8c7QT.js";const alertTypeOptions=["default","info","success","warning","error"],isAlertTypePropType=t=>"string"==typeof t&&alertTypeOptions.includes(t),validateAlertType=(t,e)=>{watchValidator(t,"_type",isAlertTypePropType,new Set(alertTypeOptions),e)},alertVariantOptions=["card","msg"],isAlertVariantPropType=t=>"string"==typeof t&&alertVariantOptions.includes(t),validateAlertVariant=(t,e)=>{watchValidator(t,"_variant",isAlertVariantPropType,new Set(alertVariantOptions),e)},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._alert=!1,this._hasCloser=!1,this._level=0,this._type="default",this._variant="msg",this.state={_level:0},this.validateOnValue=t=>"object"==typeof t&&null!==t&&"function"==typeof t.onClose}render(){const{_alert:t,_hasCloser:e,_label:a,_level:l,_type:s,_variant:i}=this.state,r={alert:t,hasCloser:e,label:a,level:l,type:s,variant:i,onCloserClick:this.close,onAlertTimeout:this.handleAlertTimeout};return h(KolAlertFc,Object.assign({key:"5db3514131f644ab76a9bddc438cdf0af412e6e8"},r),h("slot",{key:"61ef793542ae680a090596e44fcb98b9f4e55708"}))}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){validateAlertType(this,t)}validateVariant(t){validateAlertVariant(this,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};