@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
4 lines • 4.9 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import{r as i,h as t,F as s,H as e,g as a}from"./index-299a463b.js";import{c as d}from"./clsx-09a06a12.js";import{t as l}from"./i18n-5fe08f1c.js";import{a as o,g as n,c as h}from"./component-names-4cb1c62b.js";import{h as c,s as f}from"./reuse-32931294.js";import{K as r}from"./FormFieldMsg-d60b80f2.js";import"./i18n-7ea9f137.js";import"./Alert-06d4d9a4.js";import"./tslib.es6-2e5096f8.js";import"./dev.utils-fab45cbc.js";const u=class{constructor(t){i(this,t),this.slotName="input",this.catchInputSlot=t=>{c(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 i,a,c,_,b,u,m,p,g,y,v,k;const j="object"==typeof this._msg&&null!==this._msg&&"string"==typeof(null===(i=this._msg)||void 0===i?void 0:i._description)&&(null===(a=this._msg)||void 0===a?void 0:a._description.length)>0&&(!0===this._touched||"error"!==(null===(c=this._msg)||void 0===c?void 0:c._type)),B=f(this._label),L="string"==typeof this._hint&&this._hint.length>0,N=!B&&this._hideLabel;return t(e,{key:"65e25236006d47c556c287f57522693a775819ef",class:d("kol-input",this.getModifierClassNameByMsgType(j),{disabled:!0===this._disabled,[(null===(_=this._msg)||void 0===_?void 0:_._type)||"error"]:!0===j,"read-only":!0===this._readOnly,required:!0===this._required,touched:!0===this._touched,"hidden-error":!0===this._hideError})},t("label",{key:"38b715784bbae9e94589d8a7ed1743de9c92969b",class:"input-label",id:N?void 0:`${this._id}-label`,hidden:N,htmlFor:this._id},t("span",{key:"5934f50ab92196658618fcb334af74447b47bcdb",class:"input-label-span"},t("slot",{key:"8a39a951858a36ccf7774ce7813e62deea8a2e85",name:"label"}))),L&&t("span",{key:"8db0923f2189c5c6e7ea3faf0f6120734e77f1ed",class:"hint",id:`${this._id}-hint`},this._hint),t("div",{key:"49a2bfbfcc153b68ca8b323605b9f9cb80f22900",class:{input:!0,"icon-left":"object"==typeof(null===(b=this._icons)||void 0===b?void 0:b.left),"icon-right":"object"==typeof(null===(u=this._icons)||void 0===u?void 0:u.right)}},(null===(m=this._icons)||void 0===m?void 0:m.left)&&t(n,{key:"e7f0db71fab21ae736a66dc02f0c78357e18bf91",_label:"",_icons:(null===(p=this._icons)||void 0===p?void 0:p.left).icon,style:this.getIconStyles(null===(g=this._icons)||void 0===g?void 0:g.left)}),t("div",{key:"9669a185c1451fc77642c5e062a4c153e70abaca",ref:this.catchInputSlot,id:this.slotName,class:"input-slot"}),"object"==typeof this._smartButton&&null!==this._smartButton&&t(h,{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===(y=this._icons)||void 0===y?void 0:y.right)&&t(n,{key:"f6e6042d20148fb236129588c14cbca5b19dd873",_label:"",_icons:(null===(v=this._icons)||void 0===v?void 0:v.right).icon,style:this.getIconStyles(null===(k=this._icons)||void 0===k?void 0:k.right)})),N&&t(o,{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}),j&&t(r,{key:"4d82ed833659163c1315cd84d644f4022d2fb0ad",_alert:this._alert,_hideError:this._hideError,_msg:this._msg,_id:this._id}),Array.isArray(this._suggestions)&&this._suggestions.length>0&&t("datalist",{key:"bf391ca45c04582bc9e1d1083a3b0777c5ef433c",id:`${this._id}-list`},this._suggestions.map((i=>t("option",{value:i})))),this._hasCounter&&t("span",{key:"f6a3f6d6a14dddc4963c9a9f862899a0d7c3a9ab",class:"counter","aria-atomic":"true","aria-live":"polite","data-testid":"input-counter"},this._currentLength,this._maxLength&&t(s,null,t("span",{key:"6d407c7b633fcb3f2c0fcb6901b37f8659abb808","aria-label":l("kol-of"),role:"img"},"/"),this._maxLength)," ",t("span",{key:"c1fa9f7a068669b0802b3ad69fb1f4c7927869f1"},l("kol-characters"))))}getModifierClassNameByMsgType(t){var i,s;if(t&&(null===(i=this._msg)||void 0===i?void 0:i._type))return{default:"msg-type-default",info:"msg-type-info",success:"msg-type-success",warning:"msg-type-warning",error:"msg-type-error"}[null===(s=this._msg)||void 0===s?void 0:s._type]}get host(){return a(this)}};export{u as kol_input};