@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
4 lines • 5.32 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const index=require("./index-399c8b52.js"),clsx=require("./clsx-dd4d6dd1.js"),i18n=require("./i18n-1d085d07.js"),componentNames=require("./component-names-2c750b1b.js"),reuse=require("./reuse-8cfefa9b.js"),FormFieldMsg=require("./FormFieldMsg-5ce558f2.js");require("./i18n-737701e2.js"),require("./Alert-75d85d8a.js"),require("./tslib.es6-16e4524f.js"),require("./dev.utils-58fde089.js");const KolInputWc=class{constructor(t){index.registerInstance(this,t),this.slotName="input",this.catchInputSlot=t=>{reuse.handleSlotContent(this.host,t,this.slotName)},this._accessKey=void 0,this._alert=!0,this._currentLength=void 0,this._disabled=!1,this._hasCounter=!1,this._hideError=!1,this._hideLabel=!1,this._hint="",this._icons=void 0,this._id=void 0,this._label=void 0,this._maxLength=void 0,this._msg=void 0,this._readOnly=!1,this._renderNoLabel=!1,this._required=!1,this._shortKey=void 0,this._slotName=void 0,this._suggestions=void 0,this._smartButton=void 0,this._tooltipAlign="top",this._touched=!1}componentWillRender(){this.slotName=this._slotName?this._slotName:"input"}getIconStyles(t){return t&&"object"==typeof t&&t.style?t.style:{}}render(){var t,e,i,s,o,n,d,a,l,h,r,c;const _="object"==typeof this._msg&&null!==this._msg&&"string"==typeof(null===(t=this._msg)||void 0===t?void 0:t._description)&&(null===(e=this._msg)||void 0===e?void 0:e._description.length)>0&&(!0===this._touched||"error"!==(null===(i=this._msg)||void 0===i?void 0:i._type)),u=reuse.showExpertSlot(this._label),b="string"==typeof this._hint&&this._hint.length>0,f=!u&&this._hideLabel;return index.h(index.Host,{key:"65e25236006d47c556c287f57522693a775819ef",class:clsx.clsx("kol-input",this.getModifierClassNameByMsgType(_),{disabled:!0===this._disabled,[(null===(s=this._msg)||void 0===s?void 0:s._type)||"error"]:!0===_,"read-only":!0===this._readOnly,required:!0===this._required,touched:!0===this._touched,"hidden-error":!0===this._hideError})},index.h("label",{key:"38b715784bbae9e94589d8a7ed1743de9c92969b",class:"input-label",id:f?void 0:`${this._id}-label`,hidden:f,htmlFor:this._id},index.h("span",{key:"5934f50ab92196658618fcb334af74447b47bcdb",class:"input-label-span"},index.h("slot",{key:"8a39a951858a36ccf7774ce7813e62deea8a2e85",name:"label"}))),b&&index.h("span",{key:"8db0923f2189c5c6e7ea3faf0f6120734e77f1ed",class:"hint",id:`${this._id}-hint`},this._hint),index.h("div",{key:"49a2bfbfcc153b68ca8b323605b9f9cb80f22900",class:{input:!0,"icon-left":"object"==typeof(null===(o=this._icons)||void 0===o?void 0:o.left),"icon-right":"object"==typeof(null===(n=this._icons)||void 0===n?void 0:n.right)}},(null===(d=this._icons)||void 0===d?void 0:d.left)&&index.h(componentNames.KolIconTag,{key:"e7f0db71fab21ae736a66dc02f0c78357e18bf91",_label:"",_icons:(null===(a=this._icons)||void 0===a?void 0:a.left).icon,style:this.getIconStyles(null===(l=this._icons)||void 0===l?void 0:l.left)}),index.h("div",{key:"9669a185c1451fc77642c5e062a4c153e70abaca",ref:this.catchInputSlot,id:this.slotName,class:"input-slot"}),"object"==typeof this._smartButton&&null!==this._smartButton&&index.h(componentNames.KolButtonWcTag,{key:"a3d9e730f5e6b026990e697d02d8cf945af5c11c",_customClass:this._smartButton._customClass,_disabled:this._smartButton._disabled,_icons:this._smartButton._icons,_hideLabel:!0,_id:this._smartButton._id,_label:this._smartButton._label,_on:this._smartButton._on,_tooltipAlign:this._smartButton._tooltipAlign,_variant:this._smartButton._variant}),(null===(h=this._icons)||void 0===h?void 0:h.right)&&index.h(componentNames.KolIconTag,{key:"f6e6042d20148fb236129588c14cbca5b19dd873",_label:"",_icons:(null===(r=this._icons)||void 0===r?void 0:r.right).icon,style:this.getIconStyles(null===(c=this._icons)||void 0===c?void 0:c.right)})),f&&index.h(componentNames.KolTooltipWcTag,{key:"e08bdf1c1ea0f363e3f3824809ee30d75a7868cc","aria-hidden":"true",class:"input-tooltip",_badgeText:this._accessKey||this._shortKey,_align:this._tooltipAlign,_id:this._hideLabel?`${this._id}-label`:void 0,_label:this._label}),_&&index.h(FormFieldMsg.KolFormFieldMsgFc,{key:"4d82ed833659163c1315cd84d644f4022d2fb0ad",_alert:this._alert,_hideError:this._hideError,_msg:this._msg,_id:this._id}),Array.isArray(this._suggestions)&&this._suggestions.length>0&&index.h("datalist",{key:"bf391ca45c04582bc9e1d1083a3b0777c5ef433c",id:`${this._id}-list`},this._suggestions.map((t=>index.h("option",{value:t})))),this._hasCounter&&index.h("span",{key:"f6a3f6d6a14dddc4963c9a9f862899a0d7c3a9ab",class:"counter","aria-atomic":"true","aria-live":"polite","data-testid":"input-counter"},this._currentLength,this._maxLength&&index.h(index.Fragment,null,index.h("span",{key:"6d407c7b633fcb3f2c0fcb6901b37f8659abb808","aria-label":i18n.translate("kol-of"),role:"img"},"/"),this._maxLength)," ",index.h("span",{key:"c1fa9f7a068669b0802b3ad69fb1f4c7927869f1"},i18n.translate("kol-characters"))))}getModifierClassNameByMsgType(t){var e,i;if(t&&(null===(e=this._msg)||void 0===e?void 0:e._type))return{default:"msg-type-default",info:"msg-type-info",success:"msg-type-success",warning:"msg-type-warning",error:"msg-type-error"}[null===(i=this._msg)||void 0===i?void 0:i._type]}get host(){return index.getElement(this)}};exports.kol_input=KolInputWc;