epic-designer-gold
Version:
基于vue3的设计器,可视化开发页面表单
2 lines (1 loc) • 2.06 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("vue");;/* empty css */const v=require("element-plus"),o={label:"label",value:"value",disabled:"disabled",options:"options"},O=100;function i(e){return Array.isArray(e)}function D(e){return i(e)?e.length>0:e!=null&&e!==""}function V(e){return{...o,...e||{}}}function m(e,n){const l=n.options||o.options,t=Array.from(new Set([l,"children","options"]));for(const r of t){const u=e==null?void 0:e[r];if(i(u)&&u.length)return u}return[]}function S(e,n,l=[]){return i(e)&&e.forEach(t=>{const r=m(t,n);if(r.length){S(r,n,l);return}l.push(t)}),l}function b(e,n,l){if(!i(e))return;const t=l.value||o.value;for(const r of e){const u=m(r,l);if(u.length){const a=b(u,n,l);if(a)return a;continue}if((r==null?void 0:r[t])===n)return r}}function g(e,n){return i(e)?e.map(l=>{const t=m(l,n);return t.length?{...l,options:g(t,n)}:l}):[]}function y(e,n){const l=n.label||o.label,t=n.value||o.value;return{...e,label:e==null?void 0:e[l],value:e==null?void 0:e[t]}}function L(e){const n=Number(e);return!Number.isFinite(n)||n<0?O:n}const T=f.defineComponent({emits:["update:modelValue","update:modelValueLabel","update:selectFillData"],setup(e,{emit:n,attrs:l}){const t=f.inject("disabled",{value:!1});function r(u=null){var c;const a=V(l.props),d=l.options;if(i(u)){const s=u.map(h=>{const p=b(d,h,a);return p?y(p,a):{label:h,value:h}});n("update:modelValueLabel",s)}else{const s=b(d,u,a);s?n("update:modelValueLabel",y(s,a)):n("update:modelValueLabel",{label:u,value:u})}n("update:modelValue",u),n("update:selectFillData",{value:u,field:((c=l.componentSchema)==null?void 0:c.field)||"",fillDataSource:l.fillDataSource,fillDataParams:l.fillDataParams})}return D(l.modelValue)&&!l.disabled&&!t.value&&r(l.modelValue),()=>{const u=V(l.props),a=l.options,d=S(a,u).length>=L(l.virtualThreshold),c={...l,key:String(l.multiple),"onUpdate:modelValue":r,disabled:t.value||l.disabled};return d?f.h(v.ElSelectV2,{...c,options:g(a,u)}):f.h(v.ElSelect,c)}}});exports.default=T;