Tpl-BUOeAJKc.js 4.2 KB

1
  1. import{s as k,ai as v,E as M,G as F,K as b,d6 as L,f,y as h,ad as O,b0 as j,cp as D,ae as I,z as l,P as d,Q as a,D as R,$ as A,d7 as x}from"./index-DT8qTvyx.js";var B=function(u){k(n,u);function n(e){var t=u.call(this,e)||this;return t.sn=0,t.state={content:t.getContent()},t.mounted=!0,t}return n.prototype.componentDidUpdate=function(e){var t=this,s=["tpl","html","text","raw","data","placeholder"];(s.some(function(r){return!Object.is(e[r],t.props[r])})||!Object.is(v(e),v(this.props)))&&this.updateContent()},n.prototype.componentDidMount=function(){this.updateContent()},n.prototype.componentWillUnmount=function(){this.mounted=!1},n.prototype.updateContent=function(){return M(this,void 0,void 0,function(){var e,t;return F(this,function(s){switch(s.label){case 0:return e=++this.sn,[4,this.getAsyncContent()];case 1:return t=s.sent(),e!==this.sn?[2]:(this.mounted&&this.setState({content:t}),[2])}})})},n.prototype.getContent=function(){var e=this.props,t=e.tpl,s=e.html,r=e.text,o=e.raw,p=e.data,c=e.placeholder,i=v(this.props);return o||(s?b(s,p):t?b(t,p):r?L(b(r,p)):i==null||i===""?'<span class="text-muted">'.concat(c,"</span>"):typeof i=="string"?i:JSON.stringify(i))},n.prototype.getAsyncContent=function(){return M(this,void 0,void 0,function(){var e,t,s,r,o,p,c,i,m;return F(this,function(y){switch(y.label){case 0:return e=this.props,t=e.tpl,s=e.html,r=e.text,o=e.data,p=e.raw,c=e.placeholder,i=v(this.props),p?[2,p]:[3,1];case 1:return s?[2,x(s,o)]:[3,2];case 2:return t?[2,x(t,o)]:[3,3];case 3:return r?(m=L,[4,x(r,o)]):[3,5];case 4:return[2,m.apply(void 0,[y.sent()])];case 5:return[2,i==null||i===""?'<span class="text-muted">'.concat(c,"</span>"):typeof i=="string"?i:JSON.stringify(i)]}})})},n.prototype.getTitle=function(e){var t,s=this.props.showNativeTitle;if(!s)return"";var r=typeof e=="string"?e:"",o=new DOMParser().parseFromString(e,"text/html");return!((t=o==null?void 0:o.body)===null||t===void 0)&&t.textContent&&(r=o.body.textContent),r},n.prototype.handleClick=function(e){var t=this.props,s=t.dispatchEvent,r=t.data;s(e,r)},n.prototype.handleMouseEnter=function(e){var t=this.props,s=t.dispatchEvent,r=t.data;s(e,r)},n.prototype.handleMouseLeave=function(e){var t=this.props,s=t.dispatchEvent,r=t.data;s(e,r)},n.prototype.render=function(){var e,t=this.props,s=t.className,r=t.wrapperComponent,o=t.inline,p=t.classnames,c=t.style,i=t.maxLine,m=t.showNativeTitle,y=t.data,g=t.id,E=t.wrapperCustomStyle,T=t.env,N=t.themeCss,C=t.testIdBuilder,P=r||(o?"span":"div"),S=this.state.content,_={},w="";return i>0&&(w="max-line",_.WebkitLineClamp=+i),f.createElement(P,h({className:p("TplField",s,O(h(h({},this.props),{name:"baseControlClassName",id:g,themeCss:N})),O(h(h({},this.props),{name:"wrapperCustomStyle",id:g,themeCss:E}))),style:j(c,y)},m?{title:this.getTitle(S)}:{},{onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave},(e=C==null?void 0:C.getChild("tpl"))===null||e===void 0?void 0:e.getTestId()),f.createElement("span",{className:w?p(w):void 0,style:D(_)?void 0:_,dangerouslySetInnerHTML:{__html:T.filterHtml(S)}}),f.createElement(I,h({},this.props,{config:{wrapperCustomStyle:E,id:g,themeCss:N,classNames:[{key:"baseControlClassName"}]},env:T})))},n.defaultProps={inline:!0,placeholder:""},l([d,a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],n.prototype,"updateContent",null),l([d,a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",void 0)],n.prototype,"getContent",null),l([d,a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],n.prototype,"getAsyncContent",null),l([d,a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype",void 0)],n.prototype,"getTitle",null),l([d,a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],n.prototype,"handleClick",null),l([d,a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],n.prototype,"handleMouseEnter",null),l([d,a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],n.prototype,"handleMouseLeave",null),n}(f.Component),J=function(u){k(n,u);function n(){return u!==null&&u.apply(this,arguments)||this}return n=l([R({type:"tpl",alias:["html"],name:"tpl"}),A],n),n}(B);export{B as Tpl,J as TplRenderer};