@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
4 lines • 3.08 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import{proxyCustomElement,HTMLElement,h,Host}from"@stencil/core/internal/client";import{w as watchHeadingLevel}from"./validation.js";import{K as KolAlertFc}from"./Alert.js";import{v as validateHasCloser}from"./has-closer.js";import{c as watchBoolean,s as setState,w as watchValidator}from"./prop.validators.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.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=1,this._on=void 0,this._type="default",this._variant="msg",this.state={_level:1}}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(Host,{key:"93a18daf255ec95713c85ec926081163cb70df4a"},h(KolAlertFc,Object.assign({key:"dcfb772612cbe77e683b839474ce1e6e56e22dc4"},o),h("slot",{key:"daaca45ea2680f9f458dd24c41947214f391d8b2"})))}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)}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};