2 lines
2.9 KiB
JavaScript
2 lines
2.9 KiB
JavaScript
import{t as g,n as c,F as h,cF as x,j as b,e6 as F,z as p,x as B,D as v,Q as P,T as f,l as W,E as A,ce as C,L}from"./index-CEmnTf-r.js";function R(s,t,e){var r=e.type,i=e.labelField,a=i===void 0?"label":i,n=e.options,o=n===void 0?[]:n,l=e.enableNodePath,d=e.hideNodePathLabel,u=e.pathSeparator,N=u===void 0?"/":u,y=e.labelTpl;if(l||r==="nested-select"&&!d){var m=C(o,s,!0);return"".concat(m?m.map(function(E){return"".concat(E[a||"label"])}).join(" ".concat(N," ")):s[a||"label"])}var _=y?L(y,s):x(s[a])||"选项".concat(t);return _}var T=function(s){g(t,s);function t(){var e=s!==null&&s.apply(this,arguments)||this;return e.state={isExpend:!1},e}return t.prototype.toggleExpend=function(){this.setState({isExpend:!this.state.isExpend})},t.prototype.getLimit=function(e){var r=this.props.limit;return r??(Array.isArray(e)?10:200)},t.prototype.renderContent=function(e){var r=this.props,i=r.delimiter,a=r.inTag,n=r.classnames;if(!Array.isArray(e))return e;if(!a){var o=e.length-1;return e.map(function(l,d){return c(h,{children:[x(l),d===o?"":i||", "]})})}return e.map(function(l,d){return b(F,{...p({key:d,label:l,className:"mb-1"},typeof a=="object"?p(p({},a),{className:n(a.className)}):void 0)})})},t.prototype.renderAll=function(e,r){r===void 0&&(r=!1);var i=this.props,a=i.collapseButtonText,n=a===void 0?"收起":a,o=i.collapseButton,l=i.render;return c(h,{children:[this.renderContent(e),r?l("collapseBtn",{type:"button",level:"link",className:"ml-1 v-baseline"},p(p({onClick:this.toggleExpend},o),{label:n})):null]})},t.prototype.renderPart=function(e){var r=this.props,i=r.expendButtonText,a=i===void 0?"展开":i,n=r.expendButton,o=r.render,l=this.getLimit(e),d=Array.isArray(e)?e.slice(0,l):e.toString().slice(0,l);return c(h,{children:[this.renderContent(d)," ...",o("collapseBtn",{type:"button",level:"link",className:"ml-1 v-baseline"},p(p({onClick:this.toggleExpend},n),{label:a}))]})},t.prototype.getWords=function(){var e=this,r=this.props,i=r.selectedOptions,a=i===void 0?[]:i,n=r.words,o=r.data,l;return typeof n=="string"&&(l=B(n,o,"| raw")),l||((a==null?void 0:a.length)>0?a.map(function(d,u){return R(d,u,e.props)}):null)},t.prototype.render=function(){var e=this.props,r=e.classnames,i=e.className,a=e.style,n=this.getWords();if(!n)return null;var o=this.getLimit(n),l;return!o||Array.isArray(n)&&n.length<=o||!Array.isArray(n)&&n.toString().length<=o?l=this.renderAll(n):l=this.state.isExpend?this.renderAll(n,!0):this.renderPart(n),b("div",{className:r("Words-field",i),style:a,children:l})},t.defaultProps={inTag:!1},v([P,f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",void 0)],t.prototype,"toggleExpend",null),t}(W.Component),j=function(s){g(t,s);function t(){return s!==null&&s.apply(this,arguments)||this}return t=v([A({type:"words"})],t),t}(T),k=function(s){g(t,s);function t(){return s!==null&&s.apply(this,arguments)||this}return t.defaultProps={inTag:!0},t=v([A({type:"tags"})],t),t}(T);export{k as TagsRenderer,T as WordsField,j as WordsRenderer};
|