epic-designer-gold 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{attributeView-4j---k7X.js → attributeView-BvXOVbk7.js} +1 -1
- package/dist/{attributeView-DOL6IUO8.cjs → attributeView-iVaomUyI.cjs} +1 -1
- package/dist/{index--PWf2Ut2.js → index-B-VAOMev.js} +1 -1
- package/dist/{index-DzC3poxn.js → index-B3keiKRy.js} +1 -1
- package/dist/index-B8Ir-lho.js +4 -0
- package/dist/{index-Cctdx_Vq.js → index-BUloiuNZ.js} +1 -1
- package/dist/{index-Dftp7CV4.cjs → index-BhYl2S9H.cjs} +1 -1
- package/dist/{index-CPkRsFQ7.cjs → index-CXN5JcDN.cjs} +1 -1
- package/dist/{index-BJHU3Dzu.js → index-CXXMKZDX.js} +1 -1
- package/dist/index-CgboTSgt.cjs +10 -0
- package/dist/{index-BBVUGri_.cjs → index-D-MYAFvk.cjs} +1 -1
- package/dist/index-DChr8CfB.js +1422 -0
- package/dist/{index-B4sqskGf.cjs → index-DDxqWsLh.cjs} +1 -1
- package/dist/{index-CYxg6AdN.cjs → index-Dmfk0xI0.cjs} +1 -1
- package/dist/{index-zxyA8Keq.js → index-DqPRxkxh.js} +1 -1
- package/dist/{index-DiQ4ZTF7.js → index-Lc9Y13sl.js} +1 -1
- package/dist/{index-Dz59dUur.cjs → index-QROM92Xw.cjs} +1 -1
- package/dist/{index-DqLjoo13.cjs → index-jgqfPmDS.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{styleView-DLmxP2vS.js → styleView-BAOpKnjx.js} +1 -1
- package/dist/{styleView-CNmD046X.cjs → styleView-rQBBbLFF.cjs} +1 -1
- package/package.json +1 -1
- package/dist/index-CXI_7l7O.js +0 -1422
- package/dist/index-DOZPyH6X.cjs +0 -10
- package/dist/index-JlyEcj-r.js +0 -4
package/dist/index-DOZPyH6X.cjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("vue"),w=require("./pluginManager-DWHAX8kP.cjs"),J=require("./index-BoL2PSBk.cjs"),re=require("./axios-tuVKNgv9.cjs");function he(t,o){let s=null;return(...i)=>{s&&clearTimeout(s),s=setTimeout(()=>{t(...i)},o)}}function ne(){const t=e.ref({}),o=e.ref({}),s=e.ref(!1),i=e.ref([]),u=e.reactive({});function c(m){return t.value[m]}function y(m,b){t.value[m]=b}function v(m){delete t.value[m]}function h(m,b=!1){const _=Object.entries(w.pluginManager.publicMethods).reduce(($,[E,R])=>($[E]=R.handler,$),{});try{new Function(`const epic = this;${m}`).bind({..._,getComponent:c,find:c,defineExpose:M,publicMethods:_,pluginManager:w.pluginManager})()}catch($){b&&console.error("[epic:自定义函数]异常:",$)}}function M(m){m!=null&&(o.value=m)}function I(m,...b){if(!m||m.length===0){console.warn("未提供任何动作");return}m.forEach(_=>{const $=_.args?JSON.parse(_.args):b;switch(_.type){case"public":n(_,$);break;case"custom":O(_,$);break;case"component":d(_,$);break;default:console.warn(`未知的动作类型: ${_.type}`);break}})}function n(m,b){var _;try{(_=w.pluginManager.publicMethods[m.methodName])==null||_.handler(...b)}catch($){console.error(`[Epic:公共函数(${m.methodName})]执行异常:`,$)}}function O(m,b){var _,$;try{($=(_=o.value)[m.methodName])==null||$.call(_,...b)}catch(E){console.error(`[Epic:自定义函数(${m.methodName})]执行异常:`,E)}}function d(m,b){const _=m.componentId!=null&&c(m.componentId);if(!_){console.warn(`[Epic:组件${m.componentId}]未找到`);return}try{_[m.methodName](...b)}catch($){console.error(`[Epic:组件${m.componentId}函数(${m.methodName})]执行异常:`,$)}}function S(m=!0){s.value=m}function g(m){const b=w.findSchemas(m,()=>!0);i.value=b.map(_=>_.id)}function A(m,b="default"){if(u[b]){const _=u[b];w.deepCompareAndModify(m,_)}u[b]=m}function F(m,b="default"){if(u[b]){w.deepCompareAndModify(u[b],m,!1);return}u[b]=m}return{componentInstances:t,funcs:o,isDesignMode:s,defaultComponentIds:i,forms:u,addFormData:A,setFormData:F,getComponentInstance:c,find:c,addComponentInstance:y,removeComponentInstance:v,setMethods:h,doActions:I,setDesignMode:S,setDefaultComponentIds:g}}function se(){const t=e.ref([]),o=e.ref([]),s=e.ref(null);let i=0;function u(h,M="插入组件"){const I=Date.now();i+150>I||(i=I,s.value!=null&&(t.value.push(s.value),o.value.splice(0,o.value.length)),s.value={type:M,componentSchema:JSON.stringify(h)},t.value.length>60&&t.value.unshift())}function c(){if(t.value.length===0)return!1;const h=t.value.pop();return s.value!=null&&o.value.push(s.value),s.value=h,JSON.parse(h.componentSchema)}function y(){if(o.value.length===0)return!1;const h=o.value.pop();return s.value!=null&&t.value.push(s.value),s.value=h,JSON.parse(h.componentSchema)}function v(){t.value=[],o.value=[],s.value=null}return{recordList:t,undoList:o,currentRecord:s,push:u,undo:c,redo:y,reset:v}}const ve=e.defineComponent({__name:"dynamicFormItem",props:{hasFormItem:{type:Boolean},formItemProps:{}},emits:["updateFormItemRef"],setup(t,{emit:o}){const s=w.pluginManager.getComponent("form-item"),i=t,u=o,c=e.ref(),y=()=>{u("updateFormItemRef",c.value)};return(v,h)=>i.hasFormItem?(e.openBlock(),e.createBlock(e.unref(s),e.mergeProps({key:0,ref_key:"formItemRef",ref:c,onVnodeMounted:y},i.formItemProps),{default:e.withCtx(()=>[e.renderSlot(v.$slots,"default")]),_:3},16,["onVnodeMounted"])):e.renderSlot(v.$slots,"default",{key:1})}}),le=e.defineComponent({name:"ENode",__name:"node",props:{componentSchema:{},modelValue:{},ruleField:{},resetFormData:{type:Boolean},name:{},dynamicId:{},sourceDateUrl:{},id:{}},emits:["update:modelValue","change","update:dynamicId"],setup(t,{emit:o}){const{proxy:s}=e.getCurrentInstance(),i=t,u=e.ref(null);let c=e.inject("formData",e.reactive({}));const y=e.inject("slots",{}),v=e.inject("pageManager",{}),h=e.inject("disabled",{value:!1}),M=e.inject("ruleFieldPrefix",null),I=e.inject("resetFormData",!1);let n=e.reactive(w.deepClone(i.componentSchema));S();async function O(r){if(["cascader","checkbox","select","radio"].includes(r.type)&&r.componentProps.dynamicId&&i.sourceDateUrl){const p=(await re.axios({url:i.sourceDateUrl,method:"get",params:{id:r.componentProps.dynamicId},headers:{Authorization:"Bearer "+J.api.get("Admin-Token"),lang:J.api.get("saas-locale")||"zh-CN",zone:Intl.DateTimeFormat().resolvedOptions().timeZone}})).data.data;let B=await re.axios({url:p.url,method:p.method,data:JSON.parse(p.body),params:JSON.parse(p.params),headers:{...JSON.parse(p.headers),Authorization:"Bearer "+J.api.get("Admin-Token"),lang:J.api.get("saas-locale")||"zh-CN",zone:Intl.DateTimeFormat().resolvedOptions().timeZone}});if(p&&(p!=null&&p.dataPath)){const K=p.dataPath.split(".").reduce((W,Q)=>W[Q],B.data);r.componentProps.options=d(K,p.dataKey,p.dataValue)}else r.componentProps.options=d(B.data,p.dataKey,p.dataValue);return r}return r}function d(r,l,C){return r&&Object.prototype.toString.call(r)==="[object Array]"?r.map(p=>p.children&&p.children.length?{label:p[l],value:p[C]+"",children:d(p.children,l,C)}:{label:p[l],value:p[C]+""}):[]}e.watch(()=>i.componentSchema,r=>{w.deepEqual(n,r,["children"])||(w.deepCompareAndModify(n,w.deepClone(r)),S())},{deep:!0});function S(){v.isDesignMode.value&&typeof n.field=="string"&&(n.field+="-design-mode")}(i.resetFormData||I)&&(c={});const g=o,A=e.ref(),F=e.ref(),m=r=>{F.value=r},b=e.useAttrs();Object.keys(b).length&&e.provide("nodeAttrs",b);const _=e.shallowRef(null),$=e.computed(()=>{var r,l;return(r=n.componentProps)!=null&&r.hidden?!1:typeof n.show=="boolean"?n.show:((l=n.show)==null?void 0:l.call(n,{values:c}))??!0}),E=e.computed(()=>{var p;const r=$.value&&((p=n.rules)==null?void 0:p.map(B=>({...B,validator:B.validator&&v.funcs.value[B.validator]})));let l=n.field;i.ruleField?l=i.ruleField:M&&n.field&&(l=w.deepClone(M),l.push(n.field));const C={...n,rules:r,rule:r,field:l};return C.children&&delete C.children,C}),R=e.computed(()=>{var C,p;const r=((C=T.value)==null?void 0:C.bindModel)??"modelValue",l={};return n.on&&Object.keys(n.on).forEach(B=>{l[`on${w.capitalizeFirstLetter(B)}`]=(...U)=>v.doActions(n.on[B],...U)}),{...i,...n.componentProps,disabled:(h==null?void 0:h.value)||((p=n.componentProps)==null?void 0:p.disabled),bindModel:r,...l}}),T=e.computed(()=>w.pluginManager.getComponentConfingByType(n.type)??null);e.watchEffect(()=>{u.value=i.modelValue??c[n.field??""]}),e.watch(()=>u.value,()=>{u.value!==(i.modelValue??c[n.field??""])&&a(u.value)}),e.watch(()=>A.value,()=>{N()},{immediate:!0});function N(){var l;const r=A.value||s;n.id&&r&&((n.input||n.type==="table"&&n.field||n.type==="card"&&n.field&&n.multiple)&&(r.setValue=a,r.getValue=()=>c[n.field]||i.modelValue),r.setAttr=(C,p)=>(n.componentProps||(n.componentProps={}),n.componentProps[C]=p),r.getAttr=C=>n.componentProps[C],v.addComponentInstance(n.id,r),(l=T.value)!=null&&l.defaultSchema.input&&n.noFormItem!==!0&&F.value&&v.addComponentInstance(n.id+"formItem",F.value))}function D(){var r;n.id&&(v.removeComponentInstance(n.id),(r=T.value)!=null&&r.defaultSchema.input&&n.noFormItem!==!0&&v.removeComponentInstance(n.id+"formItem"))}async function q(){var l,C,p;if(n=await O(n),typeof((l=n.componentProps)==null?void 0:l.defaultValue)<"u"){const B=v.isDesignMode.value?(C=n.componentProps)==null?void 0:C.defaultValue:c[n.field]??((p=n.componentProps)==null?void 0:p.defaultValue);a(w.deepClone(B))}if(n.type==="slot"){const B=n.slotName;if(!B)return;_.value=e.defineComponent({setup(){return()=>e.renderSlot(y,B,{componentSchema:n,model:c})}});return}const r=w.pluginManager.getComponent(n.type);if(!r){console.error(`组件${n.type}未注册`);return}if(typeof r=="function"){const B=await r();_.value=B.default??B}else _.value=r}function f(r){Object.prototype.toString.call(r),Object.prototype.toString.call(r)==="[object Array]"?r.forEach(l=>{c[l.value]=l.label}):c[r.value]=r.label,i.id&&w.EventBus.emit("updateformData"+i.id,c)}function a(r){g("update:modelValue",r),g("change",r),n.field&&(c[n.field]=r),i.id&&w.EventBus.emit("updateformData"+i.id,c)}function V(r){g("update:dynamicId",r)}let P=null;return e.watch(()=>n,async r=>{const l=JSON.stringify({...r,children:void 0,componentProps:{...r.componentProps,options:null}});if(l===P)return!1;q(),P=l},{immediate:!0,deep:!0}),e.onUnmounted(D),(r,l)=>{var p;const C=e.resolveComponent("ENode");return _.value&&$.value?(e.openBlock(),e.createBlock(ve,{key:0,hasFormItem:e.unref(n).noFormItem!==!0&&((p=T.value)==null?void 0:p.defaultSchema.input),formItemProps:E.value,onUpdateFormItemRef:m},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(_.value),e.mergeProps({ref_key:"componentInstance",ref:A,onVnodeMounted:N,model:e.unref(c)},{...R.value},{[R.value.bindModel]:u.value,["onUpdate:"+R.value.bindModel]:l[0]||(l[0]=B=>u.value=B),[`onUpdate:${R.value.bindModel}`||""]:a,"onUpdate:modelValueLabel":f,"onUpdate:dynamicId":V}),{node:e.withCtx(B=>[e.createVNode(C,e.mergeProps({id:i.id},B,{sourceDateUrl:i.sourceDateUrl}),null,16,["id","sourceDateUrl"])]),"edit-node":e.withCtx(()=>[e.renderSlot(r.$slots,"edit-node")]),_:3},16,["model"]))]),_:3},8,["hasFormItem","formItemProps"])):e.createCommentVNode("",!0)}}});function ge(){const t=e.ref(!1),o=ne(),s=e.ref({});function i(){return new Promise(d=>{if(t.value)d();else{const S=e.watch(t,()=>{S(),d()})}})}async function u(d="default"){var g;await i();const S=(g=s.value)==null?void 0:g[d];if(!S)throw new Error(`表单 [name=${d}] 不存在`);return S}async function c(d,S){const g=await u(d);return w.deepClone(await S(g))}async function y(d="default"){return await c(d,S=>S.getData())}function v(d,S="default",g=void 0){var A,F;if(g&&Object.keys(g).length){let m=function(E){let R=[];return E.forEach(T=>{T.children&&(R=[...R,...m(T.children)]),R.push(T)}),R},_=function(E){var T;let R=m((T=g==null?void 0:g.schemas[0])==null?void 0:T.children);return Object.keys(E).forEach(N=>{var f,a,V,P,r;const D=R.find(l=>l.field===N),q=["datetimerange","daterange","monthrange","dates"];if((D&&(D==null?void 0:D.type)==="checkbox"||(D==null?void 0:D.type)==="select"&&((f=D==null?void 0:D.componentProps)!=null&&f.multiple)||(D==null?void 0:D.type)==="date"&&q.includes((a=D==null?void 0:D.componentProps)==null?void 0:a.type))&&typeof E[N]=="string")E[N]=(V=E[N])==null?void 0:V.split(",");else if((D==null?void 0:D.type)==="cascader"&&((r=(P=D==null?void 0:D.componentProps)==null?void 0:P.props)!=null&&r.multiple)&&typeof E[N]=="string")E[N].indexOf(";")>-1?E[N]=E[N].split(";").map(l=>l.split(",")):E[N]=E[N].split(","),E[N].indexOf(";")>-1?E[N]=E[N].split(";").map(l=>l.split(",")):E[N]=E[N].split(",");else if(((D==null?void 0:D.type)==="upload-image"||(D==null?void 0:D.type)==="upload-file")&&typeof E[N]=="string"){let l=[];Object.entries(E).forEach(([C,p])=>{E[N]===p&&C!==D.field&&C.indexOf("@")>-1&&C.indexOf(N)>-1&&(l=C.split("@")[1].split(","))}),E[N]=E[N].split(",").map((C,p)=>({url:C,name:l[p]||C}))}else(D==null?void 0:D.type)==="number"||(D==null?void 0:D.type)==="slider"?E[N]=Number(E[N]):(D==null?void 0:D.type)==="switch"&&(E[N]=typeof E[N]=="boolean"?E[N]:E[N].indexOf("true")>-1)}),E}(d);o.setFormData(_,S);const $=(A=s.value)==null?void 0:A[S];$==null||$.clearValidate()}else{o.setFormData(d,S);const m=(F=s.value)==null?void 0:F[S];m==null||m.clearValidate()}}async function h(d="default"){return await c(d,async S=>(await S.validate(),await S.getData()))}async function M(d){await i();const S={};for(const g in s.value){const A=s.value[g];A&&(S[g]=w.deepClone(await d(A)))}return S}async function I(){return await M(d=>d.getData())}function n(d){for(const S in d)v(d[S],S)}async function O(){return await M(async d=>(await d.validate(),await d.getData()))}return{ready:t,pageManager:o,forms:s,getData:y,setData:v,validate:h,getForms:I,setForms:n,validateAll:O,getFormInstance:u}}const ye={key:0,class:"epic-loading-box"},we={class:"epic-builder-main"},Se={class:"epic-loading-box"},ie=e.defineComponent({__name:"builder",props:{pageSchema:{},formData:{},disabled:{type:Boolean},sourceDateUrl:{},id:{}},emits:["change","ready"],setup(t,{expose:o,emit:s}){const i=w.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-Cap7FkuS.cjs"))),u=s,c=e.ref([]),y=e.ref({}),{ready:v,pageManager:h,forms:M,getData:I,setData:n,validate:O,getForms:d,setForms:S,validateAll:g,getFormInstance:A}=ge(),F=t,m=e.reactive({schemas:[]});e.watch(()=>F.pageSchema,f=>{w.deepCompareAndModify(m,f)},{immediate:!0,deep:!0}),e.watch(()=>F.formData,f=>{if(f){let a=T(f);y.value=a,n(a)}},{immediate:!0,deep:!0});function b(f){let a=[];return f.forEach(V=>{V.children&&(a=[...a,...b(V.children)]),a.push(V)}),a}function _(f,a){function V(r){return JSON.parse(JSON.stringify(r))}function P(r,l){if(r.type==="card"&&r.multiple&&r.field&&Array.isArray(l[r.field]))return l[r.field].map(p=>{var U;const B=V({...r,multiple:!0});return B.children=(U=B.children)==null?void 0:U.map(K=>P(K,p)).flat(),B});const C=V(r);return Array.isArray(C.children)&&(C.children=C.children.map(p=>P(p,l)).flat()),C}return f.map(r=>P(r,a)).flat()}function $(f,a="",V={root:0}){const P=a||"root";return a||(V.root=0),V[P]===void 0&&(V[P]=0),f.map(r=>{r.field&&(r.oldField=JSON.parse(JSON.stringify(r.field)));const l={...r};if(r.type==="card"){const C=r.field||"";r.multiple?(l.field=a?`${a}.${C}[${V[P]}]`:`${C}[${V[P]}]`,V[P]++):r.field&&a&&(l.field=`${a}.${C}`);const p=l.field||a;V[p]=0}else r.field&&a&&(l.field=`${a}.${r.field}`);return r.children&&(l.children=$(r.children,l.field||a,V)),l})}function E(f,a,V="",P={}){const r=V||"root";return P[r]===void 0&&(P[r]=0),f.forEach(l=>{const C=l.field||"";let p=V?`${V}.${C}`:`${C}`;l.type==="card"&&l.multiple?(typeof a[p][`${P[r]}`]=="object"?Object.keys(a[p][`${P[r]}`]).forEach(B=>{a[`${p}[${P[r]}].${B}`]=a[p][`${P[r]}`][B]}):a[`${p}[${P[r]}]`]=a[p][`${P[r]}`],l.children&&(l.children=E(l.children,a,`${p}[${P[r]}]`||V,P)),P[r]++):l.children&&(l.children=E(l.children,a,V,P))}),P[r]=0,a}function R(f,a,V){let P=E(w.deepClone(f),w.deepClone(a));return{obj:$(f),dataObj:P}}function T(f){let a=b(F.pageSchema.schemas[0].children);c.value=a.filter(l=>l.type==="card"&&l.multiple);const V=_(F.pageSchema.schemas[0].children,f);let{obj:P,dataObj:r}=R(V,f,c.value);return f=r,console.log("%c [ ]-277","font-size:13px; background:pink; color:#bf2c9f;",P,r),F.pageSchema.schemas[0].children=P,Object.keys(f).forEach(l=>{var C,p,B,U,K,W,Q;if(l.indexOf("@")<0){const x=a.find(k=>k.field===l),me=["datetimerange","daterange","monthrange","dates"];if((x&&(x==null?void 0:x.type)==="checkbox"||(x==null?void 0:x.type)==="select"&&((C=x==null?void 0:x.componentProps)!=null&&C.multiple)||(x==null?void 0:x.type)==="cascader"&&!((B=(p=x==null?void 0:x.componentProps)==null?void 0:p.props)!=null&&B.multiple)||(x==null?void 0:x.type)==="date"&&me.includes((U=x==null?void 0:x.componentProps)==null?void 0:U.type))&&typeof f[l]=="string")f[l]=(K=f[l])==null?void 0:K.split(",");else if((x==null?void 0:x.type)==="cascader"&&((Q=(W=x==null?void 0:x.componentProps)==null?void 0:W.props)!=null&&Q.multiple)&&typeof f[l]=="string")f[l].indexOf(";")>-1?f[l]=f[l].split(";").map(k=>k.split(",")):f[l]=f[l].split(","),f[l].indexOf(";")>-1?f[l]=f[l].split(";").map(k=>k.split(",")):f[l]=f[l].split(",");else if(((x==null?void 0:x.type)==="upload-image"||(x==null?void 0:x.type)==="upload-file")&&typeof f[l]=="string"){let k=[];Object.entries(f).forEach(([L,X])=>{f[l]===X&&L!==x.field&&L.indexOf("@")>-1&&L.indexOf(l)>-1&&(k=L.split("@")[1].split(","))}),f[l]=f[l].split(",").map((L,X)=>({url:L,name:k[X]||L}))}else(x==null?void 0:x.type)==="number"||(x==null?void 0:x.type)==="slider"?f[l]=Number(f[l]):(x==null?void 0:x.type)==="switch"&&(f[l]=typeof f[l]=="boolean"?f[l]:f[l].indexOf("true")>-1)}}),f}e.watch(()=>m.script,f=>{f&&h.setMethods(f,!0)},{immediate:!0}),e.provide("slots",e.useSlots()),e.provide("pageManager",h),e.provide("forms",M),e.provide("pageSchema",m),e.provide("disabled",e.computed(()=>F.disabled));const N=e.getCurrentInstance(),D=N==null?void 0:N.proxy;function q(){e.nextTick(()=>{v.value=!0,u("ready",h),D&&h.addComponentInstance("builder",D)})}return w.EventBus.on("updateformData"+F.id,f=>{F.id&&u("change",f)}),o({ready:v,pageManager:h,getData:I,setData:n,validate:O,getForms:d,setForms:S,validateAll:g,getFormInstance:A}),(f,a)=>e.unref(w.pluginManager).initialized.value?(e.openBlock(),e.createBlock(e.Suspense,{key:1,onResolve:q},{default:e.withCtx(()=>[e.createElementVNode("div",we,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.schemas,(V,P)=>(e.openBlock(),e.createBlock(e.unref(le),{id:F.id,key:P,sourceDateUrl:F.sourceDateUrl,componentSchema:V},null,8,["id","sourceDateUrl","componentSchema"]))),128))])]),fallback:e.withCtx(()=>[e.createElementVNode("div",Se,[e.createVNode(e.unref(i))])]),_:1})):(e.openBlock(),e.createElementBlock("div",ye))}});function oe(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}function Ee(t){let o=0,s,i;const u=()=>{o-=1,i&&o<=0&&(i.stop(),s=void 0,i=void 0)};return(...c)=>(o+=1,i||(i=e.effectScope(!0),s=i.run(()=>t(...c))),oe(u),s)}function H(t){return typeof t=="function"?t():e.unref(t)}const De=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const be=t=>typeof t<"u",xe=Object.prototype.toString,Ce=t=>xe.call(t)==="[object Object]",Ae=()=>{};function Ie(t){return e.getCurrentInstance()}function Oe(t,o=!0,s){Ie()?e.onMounted(t,s):o?t():e.nextTick(t)}function _e(t=!1,o={}){const{truthyValue:s=!0,falsyValue:i=!1}=o,u=e.isRef(t),c=e.ref(t);function y(v){if(arguments.length)return c.value=v,c.value;{const h=H(s);return c.value=c.value===h?H(i):h,c.value}}return u?y:[c,y]}function Ne(t,o,s){const i=e.watch(t,(...u)=>(e.nextTick(()=>i()),o(...u)),s);return i}const Y=De?window:void 0;function z(t){var o;const s=H(t);return(o=s==null?void 0:s.$el)!=null?o:s}function Pe(...t){let o,s,i,u;if(typeof t[0]=="string"||Array.isArray(t[0])?([s,i,u]=t,o=Y):[o,s,i,u]=t,!o)return Ae;Array.isArray(s)||(s=[s]),Array.isArray(i)||(i=[i]);const c=[],y=()=>{c.forEach(I=>I()),c.length=0},v=(I,n,O,d)=>(I.addEventListener(n,O,d),()=>I.removeEventListener(n,O,d)),h=e.watch(()=>[z(o),H(u)],([I,n])=>{if(y(),!I)return;const O=Ce(n)?{...n}:n;c.push(...s.flatMap(d=>i.map(S=>v(I,d,S,O))))},{immediate:!0,flush:"post"}),M=()=>{h(),y()};return oe(M),M}function Me(t){return typeof t=="function"?t:typeof t=="string"?o=>o.key===t:Array.isArray(t)?o=>t.includes(o.key):()=>!0}function ae(...t){let o,s,i={};t.length===3?(o=t[0],s=t[1],i=t[2]):t.length===2?typeof t[1]=="object"?(o=!0,s=t[0],i=t[1]):(o=t[0],s=t[1]):(o=!0,s=t[0]);const{target:u=Y,eventName:c="keydown",passive:y=!1,dedupe:v=!1}=i,h=Me(o);return Pe(u,c,I=>{I.repeat&&H(v)||h(I)&&s(I)},y)}function j(t,o,s={}){return ae(t,o,{...s,eventName:"keydown"})}function ee(t,o,s={}){return ae(t,o,{...s,eventName:"keyup"})}function Ve(){const t=e.ref(!1),o=e.getCurrentInstance();return o&&e.onMounted(()=>{t.value=!0},o),t}function $e(t){const o=Ve();return e.computed(()=>(o.value,!!t()))}function Be(t){return JSON.parse(JSON.stringify(t))}function ce(t,o,s={}){const{window:i=Y,...u}=s;let c;const y=$e(()=>i&&"ResizeObserver"in i),v=()=>{c&&(c.disconnect(),c=void 0)},h=e.computed(()=>{const n=H(t);return Array.isArray(n)?n.map(O=>z(O)):[z(n)]}),M=e.watch(h,n=>{if(v(),y.value&&i){c=new ResizeObserver(o);for(const O of n)O&&c.observe(O,u)}},{immediate:!0,flush:"post"}),I=()=>{v(),M()};return oe(I),{isSupported:y,stop:I}}function Fe(t,o={width:0,height:0},s={}){const{window:i=Y,box:u="content-box"}=s,c=e.computed(()=>{var n,O;return(O=(n=z(t))==null?void 0:n.namespaceURI)==null?void 0:O.includes("svg")}),y=e.ref(o.width),v=e.ref(o.height),{stop:h}=ce(t,([n])=>{const O=u==="border-box"?n.borderBoxSize:u==="content-box"?n.contentBoxSize:n.devicePixelContentBoxSize;if(i&&c.value){const d=z(t);if(d){const S=d.getBoundingClientRect();y.value=S.width,v.value=S.height}}else if(O){const d=Array.isArray(O)?O:[O];y.value=d.reduce((S,{inlineSize:g})=>S+g,0),v.value=d.reduce((S,{blockSize:g})=>S+g,0)}else y.value=n.contentRect.width,v.value=n.contentRect.height},s);Oe(()=>{const n=z(t);n&&(y.value="offsetWidth"in n?n.offsetWidth:o.width,v.value="offsetHeight"in n?n.offsetHeight:o.height)});const M=e.watch(()=>z(t),n=>{y.value=n?o.width:0,v.value=n?o.height:0});function I(){h(),M()}return{width:y,height:v,stop:I}}function Re(t,o,s,i={}){var u,c,y;const{clone:v=!1,passive:h=!1,eventName:M,deep:I=!1,defaultValue:n,shouldEmit:O}=i,d=e.getCurrentInstance(),S=s||(d==null?void 0:d.emit)||((u=d==null?void 0:d.$emit)==null?void 0:u.bind(d))||((y=(c=d==null?void 0:d.proxy)==null?void 0:c.$emit)==null?void 0:y.bind(d==null?void 0:d.proxy));let g=M;o||(o="modelValue"),g=g||`update:${o.toString()}`;const A=b=>v?typeof v=="function"?v(b):Be(b):b,F=()=>be(t[o])?A(t[o]):n,m=b=>{O?O(b)&&S(g,b):S(g,b)};if(h){const b=F(),_=e.ref(b);let $=!1;return e.watch(()=>t[o],E=>{$||($=!0,_.value=A(E),e.nextTick(()=>$=!1))}),e.watch(_,E=>{!$&&(E!==t[o]||I)&&m(E)},{deep:I}),_}else return e.computed({get(){return F()},set(b){m(b)}})}function Te(){const{isDark:t}=Z(),o=_e(t);return{isDark:t,toggleDark:o}}function ue(){const t=e.ref(!1);return e.onMounted(()=>{de(t),Ue(t)}),e.watch(()=>t.value,()=>{t.value?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")}),{isDark:t}}function de(t){var o=document.documentElement;o&&(o.classList.contains("dark")?t.value=!0:t.value=!1)}function Ue(t){var o=document.querySelector("html"),s=new MutationObserver(function(i){for(var u of i)if(u.type==="attributes"&&u.attributeName==="class"){const c=u.target;new Array(...c.classList).includes("dark")?t.value=!0:t.value=!1}});s.observe(o,{attributes:!0,attributeFilter:["class"]}),e.onUnmounted(()=>{s.disconnect()})}function fe(){const t=e.ref(1),o=e.ref(!1),{isDark:s}=ue(),{pressSpace:i,pressShift:u,pressCtrl:c}=pe();return{canvasScale:t,pressSpace:i,pressShift:u,pressCtrl:c,disabledZoom:o,isDark:s}}const Z=Ee(fe);function pe(){const t=e.ref(!1),o=e.ref(!1),s=e.ref(!1);return j(" ",()=>{t.value=!0}),ee(" ",()=>{t.value=!1}),j("Shift",i=>{i.preventDefault(),o.value=!0}),ee("Shift",()=>{o.value=!1}),j("Control",i=>{i.preventDefault(),s.value=!0}),ee("Control",()=>{s.value=!1}),{pressSpace:t,pressShift:o,pressCtrl:s}}function ke(t){const{pressSpace:o}=Z(),s=new Image(1,1);s.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";let i=0,u=0;function c(h){var M;o.value&&(i=h.x,u=h.y,(M=h.dataTransfer)==null||M.setDragImage(document.createElement("div"),0,0))}function y(h){if(h.preventDefault(),!h.x||!h.y||!o.value)return;const M=h.x-i,I=h.y-u;i=h.x,u=h.y,t.value&&(t.value.scrollTop-=I,t.value.scrollLeft-=M)}function v(){o.value=!1}return{handleElementDragStart:c,handleElementDrag:y,handleElementDragEnd:v}}function qe(t){const{pressCtrl:o,canvasScale:s,disabledZoom:i}=Z();function u(c){if(!o.value||i.value)return;c.preventDefault();let y=0;c.deltaY<0?y=s.value+.05:y=s.value-.05,!(y>150||y<.5)&&(s.value=y)}return e.watch(()=>s.value,c=>{t.value&&!i.value&&(t.value.style.transform=`scale(${c})`)}),{handleZoom:u,canvasScale:s}}function Le(t,o=16.66){let s;function i(){u(),s=window.setInterval(t,o)}function u(){window.clearInterval(s)}return{startTimedQuery:i,stopTimedQuery:u}}const Je={class:"min-w-750px rounded"},ze={class:"h-full rounded"},Ke=e.defineComponent({__name:"index",setup(t,{expose:o}){const s=w.pluginManager.getComponent("monacoEditor"),i=w.pluginManager.getComponent("modal"),u=e.ref(null),c=e.ref(!1),y=e.ref(!1),v=e.ref({}),h=e.inject("pageSchema"),M=e.ref(null),I=e.ref("");function n(){y.value=!1}function O(){c.value=!1}function d(){c.value=!0,I.value=w.getUUID()}async function S(){try{let g=await M.value.validateAll();if(!Object.keys(g).length){alert("请添加表单组件后再尝试!");return}Object.keys(g).length===1&&(g=g.default),v.value=JSON.stringify(g,null,2),e.nextTick(()=>{var A;(A=u.value)==null||A.setValue(v.value)}),y.value=!0}catch(g){console.error(g)}}return o({handleOpen:d}),(g,A)=>(e.openBlock(),e.createBlock(e.unref(i),{modelValue:c.value,"onUpdate:modelValue":A[1]||(A[1]=F=>c.value=F),title:"预览",class:"w-900px",width:"900px",onClose:O,onOk:S,okText:"表单数据"},{default:e.withCtx(()=>[e.createElementVNode("div",Je,[(e.openBlock(),e.createBlock(e.unref(ie),{key:I.value,ref_key:"kb",ref:M,"page-schema":e.unref(h)},null,8,["page-schema"])),e.createVNode(e.unref(i),{modelValue:y.value,"onUpdate:modelValue":A[0]||(A[0]=F=>y.value=F),title:"表单数据",class:"w-860px",width:"860px",onClose:n,onOk:n},{default:e.withCtx(()=>[e.createElementVNode("div",ze,[e.createVNode(e.unref(s),{ref_key:"monacoEditorRef",ref:u,autoToggleTheme:"",readOnly:"",class:"h-full editor","model-value":v.value},null,8,["model-value"])])]),_:1},8,["modelValue"])])]),_:1},8,["modelValue"]))}}),He={key:0,class:"epic-loading-box"},Ze={class:"epic-designer-main"},We={class:"epic-header-container"},Qe={class:"epic-loading-box"},Ge=e.defineComponent({__name:"designer",props:{disabledZoom:{type:Boolean,default:!1},hiddenHeader:{type:Boolean,default:!1},lockDefaultSchemaEdit:{type:Boolean,default:!1},formMode:{type:Boolean,default:!1},title:{default:"EpicDesigner默认项目"},defaultSchema:{},sourceCodeReadOnly:{type:Boolean},source:{default:[]},updateSourceId:{}},emits:["ready","save","reset","toggleDeviceMode","saveSourceData","deleteSourceData","updateSourceData"],setup(t,{expose:o,emit:s}){const{t:i}=J.useLocale(),u=w.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-v2u1WTMm.cjs"))),c=w.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-CCCx1tbF.cjs"))),y=w.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-Dz59dUur.cjs"))),v=w.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-R2r9Rw5O.cjs"))),h=w.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-Cap7FkuS.cjs"))),M=ne(),I=se(),n=t;let O={schemas:[{type:"form",id:"root",label:i("page"),children:[],componentProps:{name:i("form"),style:{padding:"16px"}}}],script:`const { defineExpose, find } = epic;
|
|
2
|
-
|
|
3
|
-
function test (){
|
|
4
|
-
console.log('test')
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
// 通过defineExpose暴露的函数或者属性
|
|
8
|
-
defineExpose({
|
|
9
|
-
test
|
|
10
|
-
})`};e.watchEffect(()=>{if(n.defaultSchema){O=n.defaultSchema;return}n.source&&w.pluginManager.setSourceData(n.source),n.formMode&&(O.schemas=w.pluginManager.formSchemas)}),M.setDesignMode(),M.setDefaultComponentIds(O.schemas);const d=s,S=e.ref(null),g=e.reactive({checkedNode:null,hoverNode:null,disableHover:!1,matched:[]}),A=e.reactive({schemas:[],script:O.script}),{disabledZoom:F}=Z();e.watchEffect(()=>{F.value=n.disabledZoom}),e.watchEffect(()=>{const a=A.script;a&&a!==""&&M.setMethods(a)}),e.provide("pageSchema",A),e.provide("revoke",I),e.provide("pageManager",M),e.provide("designerProps",e.computed(()=>n)),e.provide("designer",{setCheckedNode:b,setHoverNode:_,setDisableHover:E,handleToggleDeviceMode:q,reset:N,state:g}),w.EventBus.on("saveSourceData",a=>{d("saveSourceData",a)}),w.EventBus.on("deleteSourceData",a=>{d("deleteSourceData",a)}),w.EventBus.on("updateSourceData",a=>{d("updateSourceData",a)});function m(){A.schemas=w.deepClone(O.schemas),b(A.schemas[0]),I.push(A.schemas,"初始化撤销功能")}async function b(a=A.schemas[0]){g.checkedNode=a,g.matched=w.getMatchedById(A.schemas,a.id)}async function _(a=null){var V;if(!a||g.disableHover)return g.hoverNode=null,!1;if((a==null?void 0:a.id)===((V=g.hoverNode)==null?void 0:V.id))return!1;g.hoverNode=a}function $(){e.nextTick(()=>{d("ready",{pageManager:M})})}async function E(a=!1){g.disableHover=a}function R(a){w.deepCompareAndModify(A,w.deepClone(a))}function T(){return e.toRaw(A)}function N(){w.deepEqual(A.schemas,O.schemas)&&A.script===O.script||(w.deepCompareAndModify(A.schemas,O.schemas),A.script=O.script,b(A.schemas[0]),I.push(A.schemas,"重置操作"),d("reset",A))}function D(){d("save",e.toRaw(A))}function q(a){d("toggleDeviceMode",a)}function f(){S.value.handleOpen()}return m(),o({revoke:I,setData:R,getData:T,reset:N,preview:f}),(a,V)=>e.unref(w.pluginManager).initialized.value?(e.openBlock(),e.createBlock(e.Suspense,{key:1,onResolve:$},{default:e.withCtx(()=>[e.createElementVNode("div",Ze,[e.createElementVNode("div",We,[e.renderSlot(a.$slots,"header",{},()=>[n.hiddenHeader?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(u),{key:0,onPreview:f,onSave:D},{header:e.withCtx(()=>[e.renderSlot(a.$slots,"header-prefix")]),prefix:e.withCtx(()=>[e.renderSlot(a.$slots,"header-prefix")]),title:e.withCtx(()=>[e.renderSlot(a.$slots,"header-title")]),"right-prefix":e.withCtx(()=>[e.renderSlot(a.$slots,"header-right-prefix")]),"right-action":e.withCtx(()=>[e.renderSlot(a.$slots,"header-right-action")]),"right-suffix":e.withCtx(()=>[e.renderSlot(a.$slots,"header-right-suffix")]),_:3}))])]),e.createElementVNode("div",{class:e.normalizeClass(["epic-split-view-container",{"hidden-header":a.hiddenHeader}])},[e.createVNode(e.unref(c)),e.createVNode(e.unref(y)),e.createVNode(e.unref(v))],2),e.createVNode(Ke,{ref_key:"previewRef",ref:S},null,512)])]),fallback:e.withCtx(()=>[e.createElementVNode("div",Qe,[e.createVNode(e.unref(h))])]),_:3})):(e.openBlock(),e.createElementBlock("div",He))}}),Ye={component:async()=>await Promise.resolve().then(()=>require("./index-BBVUGri_.cjs")),defaultSchema:{label:"代码编辑器",type:"monacoEditor",field:"monacoEditor",icon:"epic-icon-write",input:!0},config:{attribute:[{label:"字段名",type:"input",field:"field"},{label:"标题",type:"input",field:"label"},{label:"默认值",type:"monacoEditor",field:"componentProps.defaultValue"}]},bindModel:"model-value"},{t:te}=J.useLocale(),Xe={component:async()=>await Promise.resolve().then(()=>require("./index-Ch9jeYmj.cjs")),defaultSchema:{label:te("page"),type:"page",componentProps:{},children:[]},config:{attribute:[{label:te("pageName"),type:"input",componentProps:{placeholder:te("pleaseEnter")},field:"componentProps.name"}]}},{t:G}=J.useLocale();function je(t){t.component("EInputSize",async()=>await Promise.resolve().then(()=>require("./index-CpevxZqj.cjs"))),t.component("EColEditor",async()=>await Promise.resolve().then(()=>require("./index-FgdbKgb5.cjs"))),t.component("EActionEditor",async()=>await Promise.resolve().then(()=>require("./index-CPkRsFQ7.cjs"))),t.component("ERuleEditor",async()=>await Promise.resolve().then(()=>require("./index-Dftp7CV4.cjs"))),t.component("EOptionsEditor",async()=>await Promise.resolve().then(()=>require("./index-B4sqskGf.cjs"))),t.component("ENode",async()=>await Promise.resolve().then(()=>require("./index-CYxg6AdN.cjs"))),t.component("EDataSource",async()=>await Promise.resolve().then(()=>require("./index-BEUYVwRA.cjs"))),t.component("EColumnEditor",async()=>await Promise.resolve().then(()=>require("./index-DqLjoo13.cjs"))),t.component("PaddingMarginControl",async()=>await Promise.resolve().then(()=>require("./index-DYQi05p8.cjs"))),t.registerActivitybar({id:"component_view",title:G("component"),icon:"icon--epic--extension-outline",component:async()=>await Promise.resolve().then(()=>require("./index-BHZbtFEF.cjs"))}),t.registerActivitybar({id:"outline_view",title:G("outline"),icon:"icon--epic--account-tree-outline-rounded",component:async()=>await Promise.resolve().then(()=>require("./outline-BE98qFHQ.cjs"))}),t.registerRightSidebar({id:"attribute_view",title:G("attribute"),component:async()=>await Promise.resolve().then(()=>require("./attributeView-DOL6IUO8.cjs"))}),t.registerRightSidebar({id:"style_view",title:G("style"),component:async()=>await Promise.resolve().then(()=>require("./styleView-CNmD046X.cjs"))}),t.registerRightSidebar({id:"event_view",title:"事件",component:async()=>await Promise.resolve().then(()=>require("./eventView-5fa6mfSD.cjs"))}),[Ye,Xe].forEach(s=>{t.registerComponent(s)})}je(w.pluginManager);exports._sfc_main=le;exports._sfc_main$1=ie;exports._sfc_main$2=Ge;exports.debounce=he;exports.getDarkState=de;exports.initStore=fe;exports.useDark=ue;exports.useElementDrag=ke;exports.useElementSize=Fe;exports.useElementZoom=qe;exports.useKeyPress=pe;exports.usePageManager=ne;exports.useResizeObserver=ce;exports.useRevoke=se;exports.useStore=Z;exports.useTheme=Te;exports.useTimedQuery=Le;exports.useVModel=Re;exports.watchOnce=Ne;
|
package/dist/index-JlyEcj-r.js
DELETED