UNPKG

@public-ui/components

Version:

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

4 lines 3.15 kB
/*! * KoliBri - The accessible HTML-Standard */ import{proxyCustomElement,HTMLElement,h}from"@stencil/core/internal/client";import{i as watchBoolean,k as setState,w as watchValidator}from"./index2.js";import{w as watchHeadingLevel}from"./validation.js";import{K as KolAlertFc}from"./Alert.js";import{d as dispatchDomEvent,K as KolEvent}from"./events.js";import{v as validateHasCloser}from"./has-closer.js";import{v as validateLabel}from"./label.js";const alertTypeOptions=["default","info","success","warning","error"],alertVariantOptions=["card","msg"],KolAlertWc$1=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.close=()=>{var e,t;null===(t=null===(e=this._on)||void 0===e?void 0:e.onClose)||void 0===t||t.call(e,new Event("Close")),this.host&&dispatchDomEvent(this.host,KolEvent.close)},this.handleAlertTimeout=()=>{this.validateAlert(!1)},this.validateOnValue=e=>"object"==typeof e&&null!==e&&"function"==typeof e.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:e,_hasCloser:t,_label:a,_level:l,_type:i,_variant:s}=this.state,o={alert:e,hasCloser:t,label:a,level:l,type:i,variant:s,onCloserClick:this.close,onAlertTimeout:this.handleAlertTimeout};return h(KolAlertFc,Object.assign({key:"9038051f21b86a9c83c8ac5619e723dff5ebcbeb"},o),h("slot",{key:"cfd116176ab783db5232d9d5520f8ae890ca44db"}))}validateAlert(e){watchBoolean(this,"_alert",e)}validateHasCloser(e){validateHasCloser(this,e)}validateLabel(e){validateLabel(this,e)}validateLevel(e){watchHeadingLevel(this,e)}validateOn(e){this.validateOnValue(e)&&setState(this,"_on",{onClose:e.onClose})}validateType(e){watchValidator(this,"_type",(e=>"string"==typeof e&&alertTypeOptions.includes(e)),new Set(`String {${alertTypeOptions.join(", ")}`),e)}validateVariant(e){watchValidator(this,"_variant",(e=>"string"==typeof e&&alertVariantOptions.includes(e)),new Set(`AlertVariant {${alertVariantOptions.join(", ")}`),e)}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 this}static get watchers(){return{_alert:["validateAlert"],_hasCloser:["validateHasCloser"],_label:["validateLabel"],_level:["validateLevel"],_on:["validateOn"],_type:["validateType"],_variant:["validateVariant"]}}},[4,"kol-alert-wc",{_alert:[4],_hasCloser:[4,"_has-closer"],_label:[1],_level:[2],_on:[16],_type:[1],_variant:[1],state:[32]},void 0,{_alert:["validateAlert"],_hasCloser:["validateHasCloser"],_label:["validateLabel"],_level:["validateLevel"],_on:["validateOn"],_type:["validateType"],_variant:["validateVariant"]}]);function defineCustomElement$1(){if("undefined"==typeof customElements)return;["kol-alert-wc"].forEach((e=>{if("kol-alert-wc"===e)customElements.get(e)||customElements.define(e,KolAlertWc$1)}))}const KolAlertWc=KolAlertWc$1,defineCustomElement=defineCustomElement$1;export{KolAlertWc,defineCustomElement};