form-designer-xinyi 1.5.5 → 1.5.6

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.
@@ -13,8 +13,10 @@ declare function validate(formName?: string): Promise<FormDataModel | boolean>;
13
13
  /**
14
14
  * 设置表单数据
15
15
  * @param data
16
+ * @param formName
17
+ * @returns Promise<void>
16
18
  */
17
- declare function setData(data: FormDataModel, formName?: string): false | undefined;
19
+ declare function setData(data: FormDataModel, formName?: string): Promise<void>;
18
20
  /**
19
21
  * 获取表单实例的异步函数
20
22
  * @param {string} formName - 表单名称,默认为 'default'
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("./index-eB0GTk5O.cjs"),e=require("vue"),t=require("./revoke-Bbm2vFx2.cjs");function R(){const{isDark:n}=x(),l=M.useToggle(n);return{isDark:n,toggleDark:l}}function I(){const n=e.ref(!1);return e.onMounted(()=>{A(n),q(n)}),e.watch(()=>n.value,()=>{n.value?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")}),{isDark:n}}function A(n){var l=document.documentElement;l&&(l.classList.contains("dark")?n.value=!0:n.value=!1)}function q(n){var l=document.querySelector("html"),a=new MutationObserver(function(c){for(var i of c)if(i.type==="attributes"&&i.attributeName==="class"){const p=i.target;new Array(...p.classList).includes("dark")?n.value=!0:n.value=!1}});a.observe(l,{attributes:!0,attributeFilter:["class"]}),e.onUnmounted(()=>{a.disconnect()})}function T(){const n=e.ref(1),l=e.ref(!1),{isDark:a}=I(),{pressSpace:c,pressShift:i,pressCtrl:p}=P();return{canvasScale:n,pressSpace:c,pressShift:i,pressCtrl:p,disabledZoom:l,isDark:a}}const x=M.createSharedComposable(T);function P(){const n=e.ref(!1),l=e.ref(!1),a=e.ref(!1);return M.onKeyDown(" ",c=>{var i=c.target;["INPUT","TEXTAREA"].includes(i.tagName)||c.preventDefault(),n.value=!0}),M.onKeyUp(" ",()=>{n.value=!1}),M.onKeyDown("Shift",c=>{c.preventDefault(),l.value=!0}),M.onKeyUp("Shift",()=>{l.value=!1}),M.onKeyDown("Control",c=>{c.preventDefault(),a.value=!0}),M.onKeyUp("Control",()=>{a.value=!1}),{pressSpace:n,pressShift:l,pressCtrl:a}}function U(n){const{pressSpace:l}=x();let a=0,c=0;function i(d){var f;a=d.x,c=d.y,(f=d.dataTransfer)==null||f.setDragImage(document.createElement("div"),0,0)}function p(d){if(d.preventDefault(),!d.x||!d.y||!l.value)return;const f=d.x-a,h=d.y-c;a=d.x,c=d.y,n.value&&(n.value.scrollTop-=h,n.value.scrollLeft-=f)}function g(){l.value=!1}return{handleElementDragStart:i,handleElementDrag:p,handleElementDragEnd:g}}function K(n){const{pressCtrl:l,canvasScale:a,disabledZoom:c}=x();function i(p){if(!l.value||c.value)return;p.preventDefault();let g=0;p.deltaY<0?g=a.value+.05:g=a.value-.05,!(g>150||g<.5)&&(a.value=g)}return e.watch(()=>a.value,p=>{n.value&&!c.value&&(n.value.style.transform=`scale(${p})`)}),{handleZoom:i,canvasScale:a}}function H(n,l=16.66){let a;function c(){i(),a=window.setInterval(n,l)}function i(){window.clearInterval(a)}return{startTimedQuery:c,stopTimedQuery:i}}function L(n,l){let a=null;return(...c)=>{a&&clearTimeout(a),a=setTimeout(()=>{n.apply(this,c)},l)}}function N(){const n=e.ref({}),l=e.ref({}),a=e.ref(!1),c=e.ref([]);function i(o){return n.value[o]}function p(o,r){n.value[o]=r}function g(o){delete n.value[o]}function d(o,r=!1){const m=Object.entries(t.pluginManager.publicMethods).reduce((v,[y,s])=>(v[y]=s.handler,v),{});try{new Function(`const epic = this;${o}`).bind({...m,getComponent:i,find:i,defineExpose:f,publicMethods:m,pluginManager:t.pluginManager})()}catch(v){r&&console.error("[epic-desinger:自定义函数]异常:",v)}}function f(o){o!=null&&(l.value=o)}function h(o,...r){o==null||o.forEach(m=>{var v,y,s;if(m.type==="public"&&((v=t.pluginManager.publicMethods[m.methodName])==null||v.handler(...r)),m.type==="custom"&&((s=(y=l.value)[m.methodName])==null||s.call(y,...r)),m.type==="component"){(m.componentId!=null&&i(m.componentId))[m.methodName](...m.args?JSON.parse(m.args):r);return}})}function k(o=!0){a.value=o}function D(o){const r=t.findSchemas(o,()=>!0);c.value=r.map(m=>m.id)}return{componentInstances:n,funcs:l,isDesignMode:a,defaultComponentIds:c,getComponentInstance:i,find:i,addComponentInstance:p,removeComponentInstance:g,setMethods:d,doActions:h,setDesignMode:k,setDefaultComponentIds:D}}const O={key:0,class:"epic-loading-box"},Z={class:"epic-builder-main"},z={class:"epic-loading-box"},$=e.defineComponent({__name:"builder",props:{pageSchema:{},disabled:{type:Boolean}},emits:["ready"],setup(n,{expose:l,emit:a}){const c=t.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-Da6i5WD2.cjs"))),i=N(),p=a,g=e.useSlots(),d=e.ref({}),f=e.ref(!1),h=n,k=e.reactive({schemas:[]});e.watch(()=>h.pageSchema,s=>{t.deepCompareAndModify(k,s)},{immediate:!0,deep:!0}),e.watch(()=>k.script,s=>{s&&s!==""&&i.setMethods(s,!0)},{immediate:!0}),e.provide("slots",g),e.provide("pageManager",i),e.provide("forms",d),e.provide("pageSchema",k),e.provide("disabled",e.computed(()=>h.disabled));function D(s="default"){return new Promise(async(S,C)=>{var E;if(!f.value){const _=e.watch(f,async()=>{_(),S(await D(s))});return}const w=(E=d.value)==null?void 0:E[s];if(!w)return C(`表单 [name=${s}] 不存在`),!1;const b=t.deepClone(await w.getData());S(b)})}function o(s="default"){return new Promise(async(S,C)=>{var b;if(!f.value){const E=e.watch(f,async()=>{E(),S(await o(s))});return}const w=(b=d.value)==null?void 0:b[s];if(!w)return C(`表单 [name=${s}] 不存在`),!1;try{await w.validate();const E=await w.getData();S(E)}catch(E){C(E)}})}function r(s,S="default"){var w;if(!f.value){const b=e.watch(f,()=>{b(),r(s,S)});return}const C=(w=d.value)==null?void 0:w[S];if(!C)return console.error(`表单 [name=${S}] 不存在`),!1;C.setData(s)}function m(s="default"){return new Promise(async(S,C)=>{var b;if(!f.value){const E=e.watch(f,async()=>{E(),S(await m(s))});return}const w=(b=d.value)==null?void 0:b[s];if(!w)return C(`表单 [name=${s}] 不存在`),!1;S(w)})}const{proxy:v}=e.getCurrentInstance();function y(){e.nextTick(()=>{f.value=!0,p("ready",i),v&&i.addComponentInstance("builder",v)})}return l({ready:f,getData:D,setData:r,validate:o,getFormInstance:m}),(s,S)=>e.unref(t.pluginManager).initialized.value?(e.openBlock(),e.createBlock(e.Suspense,{key:1,onResolve:y},{default:e.withCtx(()=>[e.createElementVNode("div",Z,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.schemas,(C,w)=>(e.openBlock(),e.createBlock(e.unref(M._sfc_main),{key:w,componentSchema:C},null,8,["componentSchema"]))),128))])]),fallback:e.withCtx(()=>[e.createElementVNode("div",z,[e.createVNode(e.unref(c))])]),_:1})):(e.openBlock(),e.createElementBlock("div",O))}}),Q={class:"min-w-750px rounded"},X={class:"h-full rounded"},Y=e.defineComponent({__name:"index",setup(n,{expose:l}){const a=t.pluginManager.getComponent("monacoEditor"),c=t.pluginManager.getComponent("modal"),i=e.ref(null),p=e.ref(!1),g=e.ref(!1),d=e.ref({}),f=e.inject("pageSchema"),h=e.ref(null),k=e.ref("");function D(){g.value=!1}function o(){p.value=!1}function r(){p.value=!0,k.value=t.getUUID()}async function m(){try{const v=await h.value.validate();console.log("表单结果为:",v),d.value=JSON.stringify(v,null,2),e.nextTick(()=>{var y;(y=i.value)==null||y.setValue(d.value)}),g.value=!0}catch(v){typeof v=="string"&&alert(v+`\r
2
- 请添加表单组件后再尝试!`),console.error(v)}}return l({handleOpen:r}),(v,y)=>(e.openBlock(),e.createBlock(e.unref(c),{modelValue:p.value,"onUpdate:modelValue":y[1]||(y[1]=s=>p.value=s),title:"预览",class:"w-900px",width:"900px",onClose:o,onOk:m,okText:"输出结果"},{default:e.withCtx(()=>[e.createElementVNode("div",Q,[(e.openBlock(),e.createBlock(e.unref($),{key:k.value,ref_key:"kb",ref:h,"page-schema":e.unref(f)},null,8,["page-schema"])),e.createVNode(e.unref(c),{modelValue:g.value,"onUpdate:modelValue":y[0]||(y[0]=s=>g.value=s),title:"表单数据",class:"w-860px",width:"860px",onClose:D,onOk:D},{default:e.withCtx(()=>[e.createElementVNode("div",X,[e.createVNode(e.unref(a),{ref_key:"monacoEditorRef",ref:i,autoToggleTheme:"",class:"h-full editor","model-value":d.value},null,8,["model-value"])])]),_:1},8,["modelValue"])])]),_:1},8,["modelValue"]))}}),j={key:0,class:"epic-loading-box"},J={class:"epic-designer-main"},G={class:"epic-header-container"},W={class:"epic-loading-box"},ee=e.defineComponent({__name:"designer",props:{disabledZoom:{type:Boolean,default:!1},hiddenHeader:{type:Boolean,default:!1},lockDefaultSchemaEdit:{type:Boolean,default:!1},title:{default:"EpicDesigner默认项目"},defaultSchema:{default:()=>({schemas:[{type:"page",id:"root",label:"页面",children:[],componentProps:{style:{padding:"16px"}}}],script:`const { defineExpose, find } = epic;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("./index-eB0GTk5O.cjs"),e=require("vue"),t=require("./revoke-Bbm2vFx2.cjs");function R(){const{isDark:n}=_(),r=M.useToggle(n);return{isDark:n,toggleDark:r}}function A(){const n=e.ref(!1);return e.onMounted(()=>{T(n),q(n)}),e.watch(()=>n.value,()=>{n.value?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")}),{isDark:n}}function T(n){var r=document.documentElement;r&&(r.classList.contains("dark")?n.value=!0:n.value=!1)}function q(n){var r=document.querySelector("html"),a=new MutationObserver(function(s){for(var c of s)if(c.type==="attributes"&&c.attributeName==="class"){const p=c.target;new Array(...p.classList).includes("dark")?n.value=!0:n.value=!1}});a.observe(r,{attributes:!0,attributeFilter:["class"]}),e.onUnmounted(()=>{a.disconnect()})}function P(){const n=e.ref(1),r=e.ref(!1),{isDark:a}=A(),{pressSpace:s,pressShift:c,pressCtrl:p}=$();return{canvasScale:n,pressSpace:s,pressShift:c,pressCtrl:p,disabledZoom:r,isDark:a}}const _=M.createSharedComposable(P);function $(){const n=e.ref(!1),r=e.ref(!1),a=e.ref(!1);return M.onKeyDown(" ",s=>{var c=s.target;["INPUT","TEXTAREA"].includes(c.tagName)||s.preventDefault(),n.value=!0}),M.onKeyUp(" ",()=>{n.value=!1}),M.onKeyDown("Shift",s=>{s.preventDefault(),r.value=!0}),M.onKeyUp("Shift",()=>{r.value=!1}),M.onKeyDown("Control",s=>{s.preventDefault(),a.value=!0}),M.onKeyUp("Control",()=>{a.value=!1}),{pressSpace:n,pressShift:r,pressCtrl:a}}function U(n){const{pressSpace:r}=_();let a=0,s=0;function c(d){var f;a=d.x,s=d.y,(f=d.dataTransfer)==null||f.setDragImage(document.createElement("div"),0,0)}function p(d){if(d.preventDefault(),!d.x||!d.y||!r.value)return;const f=d.x-a,h=d.y-s;a=d.x,s=d.y,n.value&&(n.value.scrollTop-=h,n.value.scrollLeft-=f)}function y(){r.value=!1}return{handleElementDragStart:c,handleElementDrag:p,handleElementDragEnd:y}}function K(n){const{pressCtrl:r,canvasScale:a,disabledZoom:s}=_();function c(p){if(!r.value||s.value)return;p.preventDefault();let y=0;p.deltaY<0?y=a.value+.05:y=a.value-.05,!(y>150||y<.5)&&(a.value=y)}return e.watch(()=>a.value,p=>{n.value&&!s.value&&(n.value.style.transform=`scale(${p})`)}),{handleZoom:c,canvasScale:a}}function H(n,r=16.66){let a;function s(){c(),a=window.setInterval(n,r)}function c(){window.clearInterval(a)}return{startTimedQuery:s,stopTimedQuery:c}}function L(n,r){let a=null;return(...s)=>{a&&clearTimeout(a),a=setTimeout(()=>{n.apply(this,s)},r)}}function V(){const n=e.ref({}),r=e.ref({}),a=e.ref(!1),s=e.ref([]);function c(o){return n.value[o]}function p(o,l){n.value[o]=l}function y(o){delete n.value[o]}function d(o,l=!1){const m=Object.entries(t.pluginManager.publicMethods).reduce((v,[g,E])=>(v[g]=E.handler,v),{});try{new Function(`const epic = this;${o}`).bind({...m,getComponent:c,find:c,defineExpose:f,publicMethods:m,pluginManager:t.pluginManager})()}catch(v){l&&console.error("[epic-desinger:自定义函数]异常:",v)}}function f(o){o!=null&&(r.value=o)}function h(o,...l){o==null||o.forEach(m=>{var v,g,E;if(m.type==="public"&&((v=t.pluginManager.publicMethods[m.methodName])==null||v.handler(...l)),m.type==="custom"&&((E=(g=r.value)[m.methodName])==null||E.call(g,...l)),m.type==="component"){(m.componentId!=null&&c(m.componentId))[m.methodName](...m.args?JSON.parse(m.args):l);return}})}function C(o=!0){a.value=o}function D(o){const l=t.findSchemas(o,()=>!0);s.value=l.map(m=>m.id)}return{componentInstances:n,funcs:r,isDesignMode:a,defaultComponentIds:s,getComponentInstance:c,find:c,addComponentInstance:p,removeComponentInstance:y,setMethods:d,doActions:h,setDesignMode:C,setDefaultComponentIds:D}}const O={key:0,class:"epic-loading-box"},Z={class:"epic-builder-main"},z={class:"epic-loading-box"},F=e.defineComponent({__name:"builder",props:{pageSchema:{},disabled:{type:Boolean}},emits:["ready"],setup(n,{expose:r,emit:a}){const s=t.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-Da6i5WD2.cjs"))),c=V(),p=a,y=e.useSlots(),d=e.ref({}),f=e.ref(!1),h=n,C=e.reactive({schemas:[]});e.watch(()=>h.pageSchema,u=>{t.deepCompareAndModify(C,u)},{immediate:!0,deep:!0}),e.watch(()=>C.script,u=>{u&&u!==""&&c.setMethods(u,!0)},{immediate:!0}),e.provide("slots",y),e.provide("pageManager",c),e.provide("forms",d),e.provide("pageSchema",C),e.provide("disabled",e.computed(()=>h.disabled));function D(u="default"){return new Promise(async(w,k)=>{var b;if(!f.value){const B=e.watch(f,async()=>{B(),w(await D(u))});return}const S=(b=d.value)==null?void 0:b[u];if(!S)return k(`表单 [name=${u}] 不存在`),!1;const x=t.deepClone(await S.getData());w(x)})}function o(u="default"){return new Promise(async(w,k)=>{var x;if(!f.value){const b=e.watch(f,async()=>{b(),w(await o(u))});return}const S=(x=d.value)==null?void 0:x[u];if(!S)return k(`表单 [name=${u}] 不存在`),!1;try{await S.validate();const b=await S.getData();w(b)}catch(b){k(b)}})}function l(u,w="default"){return new Promise(k=>{if(!f.value){const S=e.watch(f,()=>{S(),e.nextTick(()=>{m(u,w),k()})});return}e.nextTick(()=>{m(u,w),k()})})}function m(u,w="default"){var S;const k=(S=d.value)==null?void 0:S[w];if(!k)return console.error(`表单 [name=${w}] 不存在`),!1;k.setData(u)}function v(u="default"){return new Promise(async(w,k)=>{var x;if(!f.value){const b=e.watch(f,async()=>{b(),w(await v(u))});return}const S=(x=d.value)==null?void 0:x[u];if(!S)return k(`表单 [name=${u}] 不存在`),!1;w(S)})}const{proxy:g}=e.getCurrentInstance();function E(){e.nextTick(()=>{f.value=!0,p("ready",c),g&&c.addComponentInstance("builder",g)})}return r({ready:f,getData:D,setData:l,validate:o,getFormInstance:v}),(u,w)=>e.unref(t.pluginManager).initialized.value?(e.openBlock(),e.createBlock(e.Suspense,{key:1,onResolve:E},{default:e.withCtx(()=>[e.createElementVNode("div",Z,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.schemas,(k,S)=>(e.openBlock(),e.createBlock(e.unref(M._sfc_main),{key:S,componentSchema:k},null,8,["componentSchema"]))),128))])]),fallback:e.withCtx(()=>[e.createElementVNode("div",z,[e.createVNode(e.unref(s))])]),_:1})):(e.openBlock(),e.createElementBlock("div",O))}}),Q={class:"min-w-750px rounded"},X={class:"h-full rounded"},Y=e.defineComponent({__name:"index",setup(n,{expose:r}){const a=t.pluginManager.getComponent("monacoEditor"),s=t.pluginManager.getComponent("modal"),c=e.ref(null),p=e.ref(!1),y=e.ref(!1),d=e.ref({}),f=e.inject("pageSchema"),h=e.ref(null),C=e.ref("");function D(){y.value=!1}function o(){p.value=!1}function l(){p.value=!0,C.value=t.getUUID()}async function m(){try{const v=await h.value.validate();console.log("表单结果为:",v),d.value=JSON.stringify(v,null,2),e.nextTick(()=>{var g;(g=c.value)==null||g.setValue(d.value)}),y.value=!0}catch(v){typeof v=="string"&&alert(v+`\r
2
+ 请添加表单组件后再尝试!`),console.error(v)}}return r({handleOpen:l}),(v,g)=>(e.openBlock(),e.createBlock(e.unref(s),{modelValue:p.value,"onUpdate:modelValue":g[1]||(g[1]=E=>p.value=E),title:"预览",class:"w-900px",width:"900px",onClose:o,onOk:m,okText:"输出结果"},{default:e.withCtx(()=>[e.createElementVNode("div",Q,[(e.openBlock(),e.createBlock(e.unref(F),{key:C.value,ref_key:"kb",ref:h,"page-schema":e.unref(f)},null,8,["page-schema"])),e.createVNode(e.unref(s),{modelValue:y.value,"onUpdate:modelValue":g[0]||(g[0]=E=>y.value=E),title:"表单数据",class:"w-860px",width:"860px",onClose:D,onOk:D},{default:e.withCtx(()=>[e.createElementVNode("div",X,[e.createVNode(e.unref(a),{ref_key:"monacoEditorRef",ref:c,autoToggleTheme:"",class:"h-full editor","model-value":d.value},null,8,["model-value"])])]),_:1},8,["modelValue"])])]),_:1},8,["modelValue"]))}}),j={key:0,class:"epic-loading-box"},J={class:"epic-designer-main"},G={class:"epic-header-container"},W={class:"epic-loading-box"},ee=e.defineComponent({__name:"designer",props:{disabledZoom:{type:Boolean,default:!1},hiddenHeader:{type:Boolean,default:!1},lockDefaultSchemaEdit:{type:Boolean,default:!1},title:{default:"EpicDesigner默认项目"},defaultSchema:{default:()=>({schemas:[{type:"page",id:"root",label:"页面",children:[],componentProps:{style:{padding:"16px"}}}],script:`const { defineExpose, find } = epic;
3
3
 
4
4
  function test (){
5
5
  console.log('test')
@@ -8,4 +8,4 @@ function test (){
8
8
  // 通过defineExpose暴露的函数或者属性
9
9
  defineExpose({
10
10
  test
11
- })`})}},emits:["ready","save","reset","toggleDeviceMode"],setup(n,{expose:l,emit:a}){const c=t.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-n2IR3pLH.cjs"))),i=t.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-fsDcHxrd.cjs"))),p=t.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-Bcut6lHO.cjs"))),g=t.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-BsH-8kV3.cjs"))),d=t.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-Da6i5WD2.cjs"))),f=N(),h=n;f.setDesignMode(),f.setDefaultComponentIds(h.defaultSchema.schemas);const k=a,D=e.ref(null),o=e.reactive({checkedNode:null,hoverNode:null,disableHover:!1,matched:[]}),r=e.reactive({schemas:[],script:h.defaultSchema.script}),{disabledZoom:m}=x();e.watch(()=>h.disabledZoom,u=>{m.value=u},{immediate:!0}),e.watch(()=>r.script,u=>{u&&u!==""&&f.setMethods(u)},{immediate:!0}),e.provide("pageSchema",r),e.provide("pageManager",f),e.provide("designerProps",e.computed(()=>h)),e.provide("designer",{setCheckedNode:y,setHoverNode:s,setDisableHover:C,handleToggleDeviceMode:F,reset:E,state:o});function v(){r.schemas=t.deepClone(h.defaultSchema.schemas),y(r.schemas[0]),t.revoke.push(r.schemas,"初始化撤销功能")}async function y(u=r.schemas[0]){o.checkedNode=u,o.matched=t.getMatchedById(r.schemas,u.id)}async function s(u=null){var B;if(!u||o.disableHover)return o.hoverNode=null,!1;if((u==null?void 0:u.id)===((B=o.hoverNode)==null?void 0:B.id))return!1;o.hoverNode=u}function S(){e.nextTick(()=>{k("ready",{pageManager:f})})}async function C(u=!1){o.disableHover=u}function w(u){t.deepCompareAndModify(r,u)}function b(){return e.toRaw(r)}function E(){t.deepEqual(r.schemas,h.defaultSchema.schemas)&&r.script===h.defaultSchema.script||(t.deepCompareAndModify(r.schemas,h.defaultSchema.schemas),r.script=h.defaultSchema.script,y(r.schemas[0]),t.revoke.push(r.schemas,"重置操作"),k("reset",r))}function _(){k("save",e.toRaw(r))}function F(u){k("toggleDeviceMode",u)}function V(){D.value.handleOpen()}return v(),l({setData:w,getData:b,reset:E,preview:V}),(u,B)=>e.unref(t.pluginManager).initialized.value?(e.openBlock(),e.createBlock(e.Suspense,{key:1,onResolve:S},{default:e.withCtx(()=>[e.createElementVNode("div",J,[e.createElementVNode("div",G,[e.renderSlot(u.$slots,"header",{},()=>[h.hiddenHeader?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(c),{key:0,onPreview:V,onSave:_},{header:e.withCtx(()=>[e.renderSlot(u.$slots,"header-prefix")]),prefix:e.withCtx(()=>[e.renderSlot(u.$slots,"header-prefix")]),title:e.withCtx(()=>[e.renderSlot(u.$slots,"header-title")]),"right-prefix":e.withCtx(()=>[e.renderSlot(u.$slots,"header-right-prefix")]),"right-action":e.withCtx(()=>[e.renderSlot(u.$slots,"header-right-action")]),"right-suffix":e.withCtx(()=>[e.renderSlot(u.$slots,"header-right-suffix")]),_:3}))])]),e.createElementVNode("div",{class:e.normalizeClass(["epic-split-view-container",{"hidden-header":u.hiddenHeader}])},[e.createVNode(e.unref(i)),e.createVNode(e.unref(p)),e.createVNode(e.unref(g))],2),e.createVNode(Y,{ref_key:"previewRef",ref:D},null,512)])]),fallback:e.withCtx(()=>[e.createElementVNode("div",W,[e.createVNode(e.unref(d))])]),_:3})):(e.openBlock(),e.createElementBlock("div",j))}});exports.ENode=M._sfc_main;exports.PluginManager=t.PluginManager;exports.capitalizeFirstLetter=t.capitalizeFirstLetter;exports.convertKFormData=t.convertKFormData;exports.deepClone=t.deepClone;exports.deepCompareAndModify=t.deepCompareAndModify;exports.deepEqual=t.deepEqual;exports.findSchemaById=t.findSchemaById;exports.findSchemaInfoById=t.findSchemaInfoById;exports.findSchemas=t.findSchemas;exports.generateNewSchema=t.generateNewSchema;exports.getAttributeValue=t.getAttributeValue;exports.getFormFields=t.getFormFields;exports.getFormSchemas=t.getFormSchemas;exports.getMatchedById=t.getMatchedById;exports.getUUID=t.getUUID;exports.loadAsyncComponent=t.loadAsyncComponent;exports.mapSchemas=t.mapSchemas;exports.pluginManager=t.pluginManager;exports.recursionConvertedNode=t.recursionConvertedNode;exports.revoke=t.revoke;exports.setAttributeValue=t.setAttributeValue;exports.useRevoke=t.useRevoke;exports.EBuilder=$;exports.EDesigner=ee;exports.debounce=L;exports.getDarkState=A;exports.useDark=I;exports.useElementDrag=U;exports.useElementZoom=K;exports.useKeyPress=P;exports.usePageManager=N;exports.useShareStore=x;exports.useStore=T;exports.useTheme=R;exports.useTimedQuery=H;
11
+ })`})}},emits:["ready","save","reset","toggleDeviceMode"],setup(n,{expose:r,emit:a}){const s=t.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-n2IR3pLH.cjs"))),c=t.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-fsDcHxrd.cjs"))),p=t.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-Bcut6lHO.cjs"))),y=t.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-BsH-8kV3.cjs"))),d=t.loadAsyncComponent(()=>Promise.resolve().then(()=>require("./index-Da6i5WD2.cjs"))),f=V(),h=n;f.setDesignMode(),f.setDefaultComponentIds(h.defaultSchema.schemas);const C=a,D=e.ref(null),o=e.reactive({checkedNode:null,hoverNode:null,disableHover:!1,matched:[]}),l=e.reactive({schemas:[],script:h.defaultSchema.script}),{disabledZoom:m}=_();e.watch(()=>h.disabledZoom,i=>{m.value=i},{immediate:!0}),e.watch(()=>l.script,i=>{i&&i!==""&&f.setMethods(i)},{immediate:!0}),e.provide("pageSchema",l),e.provide("pageManager",f),e.provide("designerProps",e.computed(()=>h)),e.provide("designer",{setCheckedNode:g,setHoverNode:E,setDisableHover:w,handleToggleDeviceMode:B,reset:x,state:o});function v(){l.schemas=t.deepClone(h.defaultSchema.schemas),g(l.schemas[0]),t.revoke.push(l.schemas,"初始化撤销功能")}async function g(i=l.schemas[0]){o.checkedNode=i,o.matched=t.getMatchedById(l.schemas,i.id)}async function E(i=null){var N;if(!i||o.disableHover)return o.hoverNode=null,!1;if((i==null?void 0:i.id)===((N=o.hoverNode)==null?void 0:N.id))return!1;o.hoverNode=i}function u(){e.nextTick(()=>{C("ready",{pageManager:f})})}async function w(i=!1){o.disableHover=i}function k(i){t.deepCompareAndModify(l,i)}function S(){return e.toRaw(l)}function x(){t.deepEqual(l.schemas,h.defaultSchema.schemas)&&l.script===h.defaultSchema.script||(t.deepCompareAndModify(l.schemas,h.defaultSchema.schemas),l.script=h.defaultSchema.script,g(l.schemas[0]),t.revoke.push(l.schemas,"重置操作"),C("reset",l))}function b(){C("save",e.toRaw(l))}function B(i){C("toggleDeviceMode",i)}function I(){D.value.handleOpen()}return v(),r({setData:k,getData:S,reset:x,preview:I}),(i,N)=>e.unref(t.pluginManager).initialized.value?(e.openBlock(),e.createBlock(e.Suspense,{key:1,onResolve:u},{default:e.withCtx(()=>[e.createElementVNode("div",J,[e.createElementVNode("div",G,[e.renderSlot(i.$slots,"header",{},()=>[h.hiddenHeader?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(s),{key:0,onPreview:I,onSave:b},{header:e.withCtx(()=>[e.renderSlot(i.$slots,"header-prefix")]),prefix:e.withCtx(()=>[e.renderSlot(i.$slots,"header-prefix")]),title:e.withCtx(()=>[e.renderSlot(i.$slots,"header-title")]),"right-prefix":e.withCtx(()=>[e.renderSlot(i.$slots,"header-right-prefix")]),"right-action":e.withCtx(()=>[e.renderSlot(i.$slots,"header-right-action")]),"right-suffix":e.withCtx(()=>[e.renderSlot(i.$slots,"header-right-suffix")]),_:3}))])]),e.createElementVNode("div",{class:e.normalizeClass(["epic-split-view-container",{"hidden-header":i.hiddenHeader}])},[e.createVNode(e.unref(c)),e.createVNode(e.unref(p)),e.createVNode(e.unref(y))],2),e.createVNode(Y,{ref_key:"previewRef",ref:D},null,512)])]),fallback:e.withCtx(()=>[e.createElementVNode("div",W,[e.createVNode(e.unref(d))])]),_:3})):(e.openBlock(),e.createElementBlock("div",j))}});exports.ENode=M._sfc_main;exports.PluginManager=t.PluginManager;exports.capitalizeFirstLetter=t.capitalizeFirstLetter;exports.convertKFormData=t.convertKFormData;exports.deepClone=t.deepClone;exports.deepCompareAndModify=t.deepCompareAndModify;exports.deepEqual=t.deepEqual;exports.findSchemaById=t.findSchemaById;exports.findSchemaInfoById=t.findSchemaInfoById;exports.findSchemas=t.findSchemas;exports.generateNewSchema=t.generateNewSchema;exports.getAttributeValue=t.getAttributeValue;exports.getFormFields=t.getFormFields;exports.getFormSchemas=t.getFormSchemas;exports.getMatchedById=t.getMatchedById;exports.getUUID=t.getUUID;exports.loadAsyncComponent=t.loadAsyncComponent;exports.mapSchemas=t.mapSchemas;exports.pluginManager=t.pluginManager;exports.recursionConvertedNode=t.recursionConvertedNode;exports.revoke=t.revoke;exports.setAttributeValue=t.setAttributeValue;exports.useRevoke=t.useRevoke;exports.EBuilder=F;exports.EDesigner=ee;exports.debounce=L;exports.getDarkState=T;exports.useDark=A;exports.useElementDrag=U;exports.useElementZoom=K;exports.useKeyPress=$;exports.usePageManager=V;exports.useShareStore=_;exports.useStore=P;exports.useTheme=R;exports.useTimedQuery=H;
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import { u as ee, c as te, o as F, a as L, _ as ae } from "./index-DcCbSncC.js";
2
- import { ref as h, onMounted as ne, watch as C, onUnmounted as se, defineComponent as K, useSlots as oe, reactive as O, provide as M, computed as Y, getCurrentInstance as re, unref as D, openBlock as I, createElementBlock as U, createBlock as P, Suspense as j, withCtx as _, createElementVNode as T, Fragment as le, renderList as ie, createVNode as $, nextTick as z, inject as ce, renderSlot as N, createCommentVNode as ue, normalizeClass as de, toRaw as Q } from "vue";
3
- import { p as V, f as fe, l as B, d as Z, a as J, g as me, b as pe, c as he, r as X } from "./revoke-iScTU0eW.js";
1
+ import { u as ee, c as te, o as O, a as U, _ as ae } from "./index-DcCbSncC.js";
2
+ import { ref as v, onMounted as ne, watch as M, onUnmounted as se, defineComponent as q, useSlots as oe, reactive as Z, provide as I, computed as j, getCurrentInstance as re, unref as w, openBlock as $, createElementBlock as K, createBlock as R, Suspense as J, withCtx as E, createElementVNode as N, Fragment as le, renderList as ie, createVNode as T, nextTick as A, inject as ce, renderSlot as V, createCommentVNode as ue, normalizeClass as de, toRaw as X } from "vue";
3
+ import { p as B, f as fe, l as P, d as z, a as G, g as me, b as pe, c as he, r as Y } from "./revoke-iScTU0eW.js";
4
4
  import { P as Ze, t as Ke, o as ze, k as qe, n as Qe, e as Xe, h as Ye, i as je, j as Je, m as Ge, q as We, s as et, u as tt } from "./revoke-iScTU0eW.js";
5
5
  function Pe() {
6
- const { isDark: e } = R(), o = ee(e);
6
+ const { isDark: e } = H(), n = ee(e);
7
7
  return {
8
8
  isDark: e,
9
- toggleDark: o
9
+ toggleDark: n
10
10
  };
11
11
  }
12
12
  function ve() {
13
- const e = h(!1);
13
+ const e = v(!1);
14
14
  return ne(() => {
15
15
  ge(e), ye(e);
16
- }), C(
16
+ }), M(
17
17
  () => e.value,
18
18
  () => {
19
19
  e.value ? document.documentElement.classList.add("dark") : document.documentElement.classList.remove("dark");
@@ -23,18 +23,18 @@ function ve() {
23
23
  };
24
24
  }
25
25
  function ge(e) {
26
- var o = document.documentElement;
27
- o && (o.classList.contains("dark") ? e.value = !0 : e.value = !1);
26
+ var n = document.documentElement;
27
+ n && (n.classList.contains("dark") ? e.value = !0 : e.value = !1);
28
28
  }
29
29
  function ye(e) {
30
- var o = document.querySelector("html"), t = new MutationObserver(function(r) {
31
- for (var l of r)
32
- if (l.type === "attributes" && l.attributeName === "class") {
33
- const f = l.target;
30
+ var n = document.querySelector("html"), t = new MutationObserver(function(s) {
31
+ for (var r of s)
32
+ if (r.type === "attributes" && r.attributeName === "class") {
33
+ const f = r.target;
34
34
  new Array(...f.classList).includes("dark") ? e.value = !0 : e.value = !1;
35
35
  }
36
36
  });
37
- t.observe(o, {
37
+ t.observe(n, {
38
38
  attributes: !0,
39
39
  attributeFilter: ["class"]
40
40
  }), se(() => {
@@ -42,305 +42,314 @@ function ye(e) {
42
42
  });
43
43
  }
44
44
  function Se() {
45
- const e = h(1), o = h(!1), { isDark: t } = ve(), { pressSpace: r, pressShift: l, pressCtrl: f } = be();
45
+ const e = v(1), n = v(!1), { isDark: t } = ve(), { pressSpace: s, pressShift: r, pressCtrl: f } = be();
46
46
  return {
47
47
  canvasScale: e,
48
- pressSpace: r,
49
- pressShift: l,
48
+ pressSpace: s,
49
+ pressShift: r,
50
50
  pressCtrl: f,
51
- disabledZoom: o,
51
+ disabledZoom: n,
52
52
  isDark: t
53
53
  };
54
54
  }
55
- const R = te(Se);
55
+ const H = te(Se);
56
56
  function be() {
57
- const e = h(!1), o = h(!1), t = h(!1);
58
- return F(" ", (r) => {
59
- var l = r.target;
60
- ["INPUT", "TEXTAREA"].includes(l.tagName) || r.preventDefault(), e.value = !0;
61
- }), L(" ", () => {
57
+ const e = v(!1), n = v(!1), t = v(!1);
58
+ return O(" ", (s) => {
59
+ var r = s.target;
60
+ ["INPUT", "TEXTAREA"].includes(r.tagName) || s.preventDefault(), e.value = !0;
61
+ }), U(" ", () => {
62
62
  e.value = !1;
63
- }), F("Shift", (r) => {
64
- r.preventDefault(), o.value = !0;
65
- }), L("Shift", () => {
66
- o.value = !1;
67
- }), F("Control", (r) => {
68
- r.preventDefault(), t.value = !0;
69
- }), L("Control", () => {
63
+ }), O("Shift", (s) => {
64
+ s.preventDefault(), n.value = !0;
65
+ }), U("Shift", () => {
66
+ n.value = !1;
67
+ }), O("Control", (s) => {
68
+ s.preventDefault(), t.value = !0;
69
+ }), U("Control", () => {
70
70
  t.value = !1;
71
- }), { pressSpace: e, pressShift: o, pressCtrl: t };
71
+ }), { pressSpace: e, pressShift: n, pressCtrl: t };
72
72
  }
73
73
  function Re(e) {
74
- const { pressSpace: o } = R();
75
- let t = 0, r = 0;
76
- function l(c) {
74
+ const { pressSpace: n } = H();
75
+ let t = 0, s = 0;
76
+ function r(c) {
77
77
  var u;
78
- t = c.x, r = c.y, (u = c.dataTransfer) == null || u.setDragImage(document.createElement("div"), 0, 0);
78
+ t = c.x, s = c.y, (u = c.dataTransfer) == null || u.setDragImage(document.createElement("div"), 0, 0);
79
79
  }
80
80
  function f(c) {
81
- if (c.preventDefault(), !c.x || !c.y || !o.value)
81
+ if (c.preventDefault(), !c.x || !c.y || !n.value)
82
82
  return;
83
- const u = c.x - t, m = c.y - r;
84
- t = c.x, r = c.y, e.value && (e.value.scrollTop -= m, e.value.scrollLeft -= u);
83
+ const u = c.x - t, m = c.y - s;
84
+ t = c.x, s = c.y, e.value && (e.value.scrollTop -= m, e.value.scrollLeft -= u);
85
85
  }
86
- function v() {
87
- o.value = !1;
86
+ function g() {
87
+ n.value = !1;
88
88
  }
89
- return { handleElementDragStart: l, handleElementDrag: f, handleElementDragEnd: v };
89
+ return { handleElementDragStart: r, handleElementDrag: f, handleElementDragEnd: g };
90
90
  }
91
91
  function Ae(e) {
92
- const { pressCtrl: o, canvasScale: t, disabledZoom: r } = R();
93
- function l(f) {
94
- if (!o.value || r.value)
92
+ const { pressCtrl: n, canvasScale: t, disabledZoom: s } = H();
93
+ function r(f) {
94
+ if (!n.value || s.value)
95
95
  return;
96
96
  f.preventDefault();
97
- let v = 0;
98
- f.deltaY < 0 ? v = t.value + 0.05 : v = t.value - 0.05, !(v > 150 || v < 0.5) && (t.value = v);
97
+ let g = 0;
98
+ f.deltaY < 0 ? g = t.value + 0.05 : g = t.value - 0.05, !(g > 150 || g < 0.5) && (t.value = g);
99
99
  }
100
- return C(
100
+ return M(
101
101
  () => t.value,
102
102
  (f) => {
103
- e.value && !r.value && (e.value.style.transform = `scale(${f})`);
103
+ e.value && !s.value && (e.value.style.transform = `scale(${f})`);
104
104
  }
105
- ), { handleZoom: l, canvasScale: t };
105
+ ), { handleZoom: r, canvasScale: t };
106
106
  }
107
- function He(e, o = 16.66) {
107
+ function He(e, n = 16.66) {
108
108
  let t;
109
- function r() {
110
- l(), t = window.setInterval(e, o);
109
+ function s() {
110
+ r(), t = window.setInterval(e, n);
111
111
  }
112
- function l() {
112
+ function r() {
113
113
  window.clearInterval(t);
114
114
  }
115
115
  return {
116
- startTimedQuery: r,
117
- stopTimedQuery: l
116
+ startTimedQuery: s,
117
+ stopTimedQuery: r
118
118
  };
119
119
  }
120
- function Fe(e, o) {
120
+ function Fe(e, n) {
121
121
  let t = null;
122
- return (...r) => {
122
+ return (...s) => {
123
123
  t && clearTimeout(t), t = setTimeout(() => {
124
- e.apply(this, r);
125
- }, o);
124
+ e.apply(this, s);
125
+ }, n);
126
126
  };
127
127
  }
128
- function G() {
129
- const e = h({}), o = h({}), t = h(!1), r = h([]);
130
- function l(a) {
128
+ function W() {
129
+ const e = v({}), n = v({}), t = v(!1), s = v([]);
130
+ function r(a) {
131
131
  return e.value[a];
132
132
  }
133
- function f(a, n) {
134
- e.value[a] = n;
133
+ function f(a, o) {
134
+ e.value[a] = o;
135
135
  }
136
- function v(a) {
136
+ function g(a) {
137
137
  delete e.value[a];
138
138
  }
139
- function c(a, n = !1) {
139
+ function c(a, o = !1) {
140
140
  const d = Object.entries(
141
- V.publicMethods
142
- ).reduce((p, [g, s]) => (p[g] = s.handler, p), {});
141
+ B.publicMethods
142
+ ).reduce((p, [h, k]) => (p[h] = k.handler, p), {});
143
143
  try {
144
144
  new Function(`const epic = this;${a}`).bind({
145
145
  ...d,
146
- getComponent: l,
147
- find: l,
146
+ getComponent: r,
147
+ find: r,
148
148
  defineExpose: u,
149
149
  publicMethods: d,
150
- pluginManager: V
150
+ pluginManager: B
151
151
  })();
152
152
  } catch (p) {
153
- n && console.error("[epic-desinger:自定义函数]异常:", p);
153
+ o && console.error("[epic-desinger:自定义函数]异常:", p);
154
154
  }
155
155
  }
156
156
  function u(a) {
157
- a != null && (o.value = a);
157
+ a != null && (n.value = a);
158
158
  }
159
- function m(a, ...n) {
159
+ function m(a, ...o) {
160
160
  a == null || a.forEach((d) => {
161
- var p, g, s;
162
- if (d.type === "public" && ((p = V.publicMethods[d.methodName]) == null || p.handler(...n)), d.type === "custom" && ((s = (g = o.value)[d.methodName]) == null || s.call(g, ...n)), d.type === "component") {
163
- (d.componentId != null && l(d.componentId))[d.methodName](
164
- ...d.args ? JSON.parse(d.args) : n
161
+ var p, h, k;
162
+ if (d.type === "public" && ((p = B.publicMethods[d.methodName]) == null || p.handler(...o)), d.type === "custom" && ((k = (h = n.value)[d.methodName]) == null || k.call(h, ...o)), d.type === "component") {
163
+ (d.componentId != null && r(d.componentId))[d.methodName](
164
+ ...d.args ? JSON.parse(d.args) : o
165
165
  );
166
166
  return;
167
167
  }
168
168
  });
169
169
  }
170
- function b(a = !0) {
170
+ function D(a = !0) {
171
171
  t.value = a;
172
172
  }
173
173
  function x(a) {
174
- const n = fe(a, () => !0);
175
- r.value = n.map((d) => d.id);
174
+ const o = fe(a, () => !0);
175
+ s.value = o.map((d) => d.id);
176
176
  }
177
177
  return {
178
178
  componentInstances: e,
179
- funcs: o,
179
+ funcs: n,
180
180
  isDesignMode: t,
181
- defaultComponentIds: r,
182
- getComponentInstance: l,
181
+ defaultComponentIds: s,
182
+ getComponentInstance: r,
183
183
  // 简化查询函数, 推荐使用
184
- find: l,
184
+ find: r,
185
185
  addComponentInstance: f,
186
- removeComponentInstance: v,
186
+ removeComponentInstance: g,
187
187
  setMethods: c,
188
188
  doActions: m,
189
- setDesignMode: b,
189
+ setDesignMode: D,
190
190
  setDefaultComponentIds: x
191
191
  };
192
192
  }
193
193
  const De = {
194
194
  key: 0,
195
195
  class: "epic-loading-box"
196
- }, we = { class: "epic-builder-main" }, ke = { class: "epic-loading-box" }, _e = /* @__PURE__ */ K({
196
+ }, we = { class: "epic-builder-main" }, ke = { class: "epic-loading-box" }, _e = /* @__PURE__ */ q({
197
197
  __name: "builder",
198
198
  props: {
199
199
  pageSchema: {},
200
200
  disabled: { type: Boolean }
201
201
  },
202
202
  emits: ["ready"],
203
- setup(e, { expose: o, emit: t }) {
204
- const r = B(() => import("./index-B4P9zbh-.js")), l = G(), f = t, v = oe(), c = h({}), u = h(!1), m = e, b = O({
203
+ setup(e, { expose: n, emit: t }) {
204
+ const s = P(() => import("./index-B4P9zbh-.js")), r = W(), f = t, g = oe(), c = v({}), u = v(!1), m = e, D = Z({
205
205
  schemas: []
206
206
  });
207
- C(() => m.pageSchema, (s) => {
208
- Z(b, s);
207
+ M(() => m.pageSchema, (i) => {
208
+ z(D, i);
209
209
  }, {
210
210
  immediate: !0,
211
211
  deep: !0
212
- }), C(() => b.script, (s) => {
213
- s && s !== "" && l.setMethods(s, !0);
212
+ }), M(() => D.script, (i) => {
213
+ i && i !== "" && r.setMethods(i, !0);
214
214
  }, {
215
215
  immediate: !0
216
- }), M("slots", v), M("pageManager", l), M("forms", c), M("pageSchema", b), M("disabled", Y(() => m.disabled));
217
- function x(s = "default") {
218
- return new Promise(async (y, w) => {
219
- var k;
216
+ }), I("slots", g), I("pageManager", r), I("forms", c), I("pageSchema", D), I("disabled", j(() => m.disabled));
217
+ function x(i = "default") {
218
+ return new Promise(async (S, b) => {
219
+ var _;
220
220
  if (!u.value) {
221
- const A = C(u, async () => {
222
- A(), y(await x(s));
221
+ const F = M(u, async () => {
222
+ F(), S(await x(i));
223
223
  });
224
224
  return;
225
225
  }
226
- const S = (k = c.value) == null ? void 0 : k[s];
227
- if (!S)
228
- return w(`表单 [name=${s}] 不存在`), !1;
229
- const E = J(await S.getData());
230
- y(E);
226
+ const y = (_ = c.value) == null ? void 0 : _[i];
227
+ if (!y)
228
+ return b(`表单 [name=${i}] 不存在`), !1;
229
+ const C = G(await y.getData());
230
+ S(C);
231
231
  });
232
232
  }
233
- function a(s = "default") {
234
- return new Promise(async (y, w) => {
235
- var E;
233
+ function a(i = "default") {
234
+ return new Promise(async (S, b) => {
235
+ var C;
236
236
  if (!u.value) {
237
- const k = C(u, async () => {
238
- k(), y(await a(s));
237
+ const _ = M(u, async () => {
238
+ _(), S(await a(i));
239
239
  });
240
240
  return;
241
241
  }
242
- const S = (E = c.value) == null ? void 0 : E[s];
243
- if (!S)
244
- return w(`表单 [name=${s}] 不存在`), !1;
242
+ const y = (C = c.value) == null ? void 0 : C[i];
243
+ if (!y)
244
+ return b(`表单 [name=${i}] 不存在`), !1;
245
245
  try {
246
- await S.validate();
247
- const k = await S.getData();
248
- y(k);
249
- } catch (k) {
250
- w(k);
246
+ await y.validate();
247
+ const _ = await y.getData();
248
+ S(_);
249
+ } catch (_) {
250
+ b(_);
251
251
  }
252
252
  });
253
253
  }
254
- function n(s, y = "default") {
255
- var S;
256
- if (!u.value) {
257
- const E = C(u, () => {
258
- E(), n(s, y);
254
+ function o(i, S = "default") {
255
+ return new Promise((b) => {
256
+ if (!u.value) {
257
+ const y = M(u, () => {
258
+ y(), A(() => {
259
+ d(i, S), b();
260
+ });
261
+ });
262
+ return;
263
+ }
264
+ A(() => {
265
+ d(i, S), b();
259
266
  });
260
- return;
261
- }
262
- const w = (S = c.value) == null ? void 0 : S[y];
263
- if (!w)
264
- return console.error(`表单 [name=${y}] 不存在`), !1;
265
- w.setData(s);
267
+ });
266
268
  }
267
- function d(s = "default") {
268
- return new Promise(async (y, w) => {
269
- var E;
269
+ function d(i, S = "default") {
270
+ var y;
271
+ const b = (y = c.value) == null ? void 0 : y[S];
272
+ if (!b)
273
+ return console.error(`表单 [name=${S}] 不存在`), !1;
274
+ b.setData(i);
275
+ }
276
+ function p(i = "default") {
277
+ return new Promise(async (S, b) => {
278
+ var C;
270
279
  if (!u.value) {
271
- const k = C(u, async () => {
272
- k(), y(await d(s));
280
+ const _ = M(u, async () => {
281
+ _(), S(await p(i));
273
282
  });
274
283
  return;
275
284
  }
276
- const S = (E = c.value) == null ? void 0 : E[s];
277
- if (!S)
278
- return w(`表单 [name=${s}] 不存在`), !1;
279
- y(S);
285
+ const y = (C = c.value) == null ? void 0 : C[i];
286
+ if (!y)
287
+ return b(`表单 [name=${i}] 不存在`), !1;
288
+ S(y);
280
289
  });
281
290
  }
282
- const { proxy: p } = re();
283
- function g() {
284
- z(() => {
285
- u.value = !0, f("ready", l), p && l.addComponentInstance("builder", p);
291
+ const { proxy: h } = re();
292
+ function k() {
293
+ A(() => {
294
+ u.value = !0, f("ready", r), h && r.addComponentInstance("builder", h);
286
295
  });
287
296
  }
288
- return o({
297
+ return n({
289
298
  ready: u,
290
299
  getData: x,
291
- setData: n,
300
+ setData: o,
292
301
  validate: a,
293
- getFormInstance: d
294
- }), (s, y) => D(V).initialized.value ? (I(), P(j, {
302
+ getFormInstance: p
303
+ }), (i, S) => w(B).initialized.value ? ($(), R(J, {
295
304
  key: 1,
296
- onResolve: g
305
+ onResolve: k
297
306
  }, {
298
- default: _(() => [
299
- T("div", we, [
300
- (I(!0), U(le, null, ie(b.schemas, (w, S) => (I(), P(D(ae), {
301
- key: S,
302
- componentSchema: w
307
+ default: E(() => [
308
+ N("div", we, [
309
+ ($(!0), K(le, null, ie(D.schemas, (b, y) => ($(), R(w(ae), {
310
+ key: y,
311
+ componentSchema: b
303
312
  }, null, 8, ["componentSchema"]))), 128))
304
313
  ])
305
314
  ]),
306
- fallback: _(() => [
307
- T("div", ke, [
308
- $(D(r))
315
+ fallback: E(() => [
316
+ N("div", ke, [
317
+ T(w(s))
309
318
  ])
310
319
  ]),
311
320
  _: 1
312
- })) : (I(), U("div", De));
321
+ })) : ($(), K("div", De));
313
322
  }
314
- }), Ee = { class: "min-w-750px rounded" }, xe = { class: "h-full rounded" }, Ce = /* @__PURE__ */ K({
323
+ }), Ee = { class: "min-w-750px rounded" }, xe = { class: "h-full rounded" }, Ce = /* @__PURE__ */ q({
315
324
  __name: "index",
316
- setup(e, { expose: o }) {
317
- const t = V.getComponent("monacoEditor"), r = V.getComponent("modal"), l = h(null), f = h(!1), v = h(!1), c = h({}), u = ce("pageSchema"), m = h(null), b = h("");
325
+ setup(e, { expose: n }) {
326
+ const t = B.getComponent("monacoEditor"), s = B.getComponent("modal"), r = v(null), f = v(!1), g = v(!1), c = v({}), u = ce("pageSchema"), m = v(null), D = v("");
318
327
  function x() {
319
- v.value = !1;
328
+ g.value = !1;
320
329
  }
321
330
  function a() {
322
331
  f.value = !1;
323
332
  }
324
- function n() {
325
- f.value = !0, b.value = me();
333
+ function o() {
334
+ f.value = !0, D.value = me();
326
335
  }
327
336
  async function d() {
328
337
  try {
329
338
  const p = await m.value.validate();
330
- console.log("表单结果为:", p), c.value = JSON.stringify(p, null, 2), z(() => {
331
- var g;
332
- (g = l.value) == null || g.setValue(c.value);
333
- }), v.value = !0;
339
+ console.log("表单结果为:", p), c.value = JSON.stringify(p, null, 2), A(() => {
340
+ var h;
341
+ (h = r.value) == null || h.setValue(c.value);
342
+ }), g.value = !0;
334
343
  } catch (p) {
335
344
  typeof p == "string" && alert(p + `\r
336
345
  请添加表单组件后再尝试!`), console.error(p);
337
346
  }
338
347
  }
339
- return o({
340
- handleOpen: n
341
- }), (p, g) => (I(), P(D(r), {
348
+ return n({
349
+ handleOpen: o
350
+ }), (p, h) => ($(), R(w(s), {
342
351
  modelValue: f.value,
343
- "onUpdate:modelValue": g[1] || (g[1] = (s) => f.value = s),
352
+ "onUpdate:modelValue": h[1] || (h[1] = (k) => f.value = k),
344
353
  title: "预览",
345
354
  class: "w-900px",
346
355
  width: "900px",
@@ -348,28 +357,28 @@ const De = {
348
357
  onOk: d,
349
358
  okText: "输出结果"
350
359
  }, {
351
- default: _(() => [
352
- T("div", Ee, [
353
- (I(), P(D(_e), {
354
- key: b.value,
360
+ default: E(() => [
361
+ N("div", Ee, [
362
+ ($(), R(w(_e), {
363
+ key: D.value,
355
364
  ref_key: "kb",
356
365
  ref: m,
357
- "page-schema": D(u)
366
+ "page-schema": w(u)
358
367
  }, null, 8, ["page-schema"])),
359
- $(D(r), {
360
- modelValue: v.value,
361
- "onUpdate:modelValue": g[0] || (g[0] = (s) => v.value = s),
368
+ T(w(s), {
369
+ modelValue: g.value,
370
+ "onUpdate:modelValue": h[0] || (h[0] = (k) => g.value = k),
362
371
  title: "表单数据",
363
372
  class: "w-860px",
364
373
  width: "860px",
365
374
  onClose: x,
366
375
  onOk: x
367
376
  }, {
368
- default: _(() => [
369
- T("div", xe, [
370
- $(D(t), {
377
+ default: E(() => [
378
+ N("div", xe, [
379
+ T(w(t), {
371
380
  ref_key: "monacoEditorRef",
372
- ref: l,
381
+ ref: r,
373
382
  autoToggleTheme: "",
374
383
  class: "h-full editor",
375
384
  "model-value": c.value
@@ -386,7 +395,7 @@ const De = {
386
395
  }), Me = {
387
396
  key: 0,
388
397
  class: "epic-loading-box"
389
- }, Ie = { class: "epic-designer-main" }, $e = { class: "epic-header-container" }, Te = { class: "epic-loading-box" }, Le = /* @__PURE__ */ K({
398
+ }, Ie = { class: "epic-designer-main" }, $e = { class: "epic-header-container" }, Te = { class: "epic-loading-box" }, Le = /* @__PURE__ */ q({
390
399
  __name: "designer",
391
400
  props: {
392
401
  disabledZoom: { type: Boolean, default: !1 },
@@ -418,134 +427,134 @@ defineExpose({
418
427
  }) }
419
428
  },
420
429
  emits: ["ready", "save", "reset", "toggleDeviceMode"],
421
- setup(e, { expose: o, emit: t }) {
422
- const r = B(() => import("./index-DHI4gLFF.js")), l = B(() => import("./index-H4zzFoVP.js")), f = B(() => import("./index-C6uorzgq.js")), v = B(() => import("./index-DWCjsALD.js")), c = B(() => import("./index-B4P9zbh-.js")), u = G(), m = e;
430
+ setup(e, { expose: n, emit: t }) {
431
+ const s = P(() => import("./index-DHI4gLFF.js")), r = P(() => import("./index-H4zzFoVP.js")), f = P(() => import("./index-C6uorzgq.js")), g = P(() => import("./index-DWCjsALD.js")), c = P(() => import("./index-B4P9zbh-.js")), u = W(), m = e;
423
432
  u.setDesignMode(), u.setDefaultComponentIds(m.defaultSchema.schemas);
424
- const b = t, x = h(null), a = O({
433
+ const D = t, x = v(null), a = Z({
425
434
  checkedNode: null,
426
435
  hoverNode: null,
427
436
  disableHover: !1,
428
437
  matched: []
429
- }), n = O({
438
+ }), o = Z({
430
439
  schemas: [],
431
440
  script: m.defaultSchema.script
432
- }), { disabledZoom: d } = R();
433
- C(() => m.disabledZoom, (i) => {
434
- d.value = i;
441
+ }), { disabledZoom: d } = H();
442
+ M(() => m.disabledZoom, (l) => {
443
+ d.value = l;
435
444
  }, {
436
445
  immediate: !0
437
- }), C(() => n.script, (i) => {
438
- i && i !== "" && u.setMethods(i);
446
+ }), M(() => o.script, (l) => {
447
+ l && l !== "" && u.setMethods(l);
439
448
  }, {
440
449
  immediate: !0
441
- }), M("pageSchema", n), M("pageManager", u), M("designerProps", Y(() => m)), M("designer", {
442
- setCheckedNode: g,
443
- setHoverNode: s,
444
- setDisableHover: w,
445
- handleToggleDeviceMode: W,
446
- reset: k,
450
+ }), I("pageSchema", o), I("pageManager", u), I("designerProps", j(() => m)), I("designer", {
451
+ setCheckedNode: h,
452
+ setHoverNode: k,
453
+ setDisableHover: S,
454
+ handleToggleDeviceMode: F,
455
+ reset: C,
447
456
  state: a
448
457
  });
449
458
  function p() {
450
- n.schemas = J(m.defaultSchema.schemas), g(n.schemas[0]), X.push(n.schemas, "初始化撤销功能");
459
+ o.schemas = G(m.defaultSchema.schemas), h(o.schemas[0]), Y.push(o.schemas, "初始化撤销功能");
451
460
  }
452
- async function g(i = n.schemas[0]) {
453
- a.checkedNode = i, a.matched = pe(n.schemas, i.id);
461
+ async function h(l = o.schemas[0]) {
462
+ a.checkedNode = l, a.matched = pe(o.schemas, l.id);
454
463
  }
455
- async function s(i = null) {
456
- var H;
457
- if (!i || a.disableHover)
464
+ async function k(l = null) {
465
+ var L;
466
+ if (!l || a.disableHover)
458
467
  return a.hoverNode = null, !1;
459
- if ((i == null ? void 0 : i.id) === ((H = a.hoverNode) == null ? void 0 : H.id))
468
+ if ((l == null ? void 0 : l.id) === ((L = a.hoverNode) == null ? void 0 : L.id))
460
469
  return !1;
461
- a.hoverNode = i;
470
+ a.hoverNode = l;
462
471
  }
463
- function y() {
464
- z(() => {
465
- b("ready", { pageManager: u });
472
+ function i() {
473
+ A(() => {
474
+ D("ready", { pageManager: u });
466
475
  });
467
476
  }
468
- async function w(i = !1) {
469
- a.disableHover = i;
477
+ async function S(l = !1) {
478
+ a.disableHover = l;
470
479
  }
471
- function S(i) {
472
- Z(n, i);
480
+ function b(l) {
481
+ z(o, l);
473
482
  }
474
- function E() {
475
- return Q(n);
483
+ function y() {
484
+ return X(o);
476
485
  }
477
- function k() {
478
- he(n.schemas, m.defaultSchema.schemas) && n.script === m.defaultSchema.script || (Z(n.schemas, m.defaultSchema.schemas), n.script = m.defaultSchema.script, g(n.schemas[0]), X.push(n.schemas, "重置操作"), b("reset", n));
486
+ function C() {
487
+ he(o.schemas, m.defaultSchema.schemas) && o.script === m.defaultSchema.script || (z(o.schemas, m.defaultSchema.schemas), o.script = m.defaultSchema.script, h(o.schemas[0]), Y.push(o.schemas, "重置操作"), D("reset", o));
479
488
  }
480
- function A() {
481
- b("save", Q(n));
489
+ function _() {
490
+ D("save", X(o));
482
491
  }
483
- function W(i) {
484
- b("toggleDeviceMode", i);
492
+ function F(l) {
493
+ D("toggleDeviceMode", l);
485
494
  }
486
- function q() {
495
+ function Q() {
487
496
  x.value.handleOpen();
488
497
  }
489
- return p(), o({
490
- setData: S,
491
- getData: E,
492
- reset: k,
493
- preview: q
494
- }), (i, H) => D(V).initialized.value ? (I(), P(j, {
498
+ return p(), n({
499
+ setData: b,
500
+ getData: y,
501
+ reset: C,
502
+ preview: Q
503
+ }), (l, L) => w(B).initialized.value ? ($(), R(J, {
495
504
  key: 1,
496
- onResolve: y
505
+ onResolve: i
497
506
  }, {
498
- default: _(() => [
499
- T("div", Ie, [
500
- T("div", $e, [
501
- N(i.$slots, "header", {}, () => [
502
- m.hiddenHeader ? ue("", !0) : (I(), P(D(r), {
507
+ default: E(() => [
508
+ N("div", Ie, [
509
+ N("div", $e, [
510
+ V(l.$slots, "header", {}, () => [
511
+ m.hiddenHeader ? ue("", !0) : ($(), R(w(s), {
503
512
  key: 0,
504
- onPreview: q,
505
- onSave: A
513
+ onPreview: Q,
514
+ onSave: _
506
515
  }, {
507
- header: _(() => [
508
- N(i.$slots, "header-prefix")
516
+ header: E(() => [
517
+ V(l.$slots, "header-prefix")
509
518
  ]),
510
- prefix: _(() => [
511
- N(i.$slots, "header-prefix")
519
+ prefix: E(() => [
520
+ V(l.$slots, "header-prefix")
512
521
  ]),
513
- title: _(() => [
514
- N(i.$slots, "header-title")
522
+ title: E(() => [
523
+ V(l.$slots, "header-title")
515
524
  ]),
516
- "right-prefix": _(() => [
517
- N(i.$slots, "header-right-prefix")
525
+ "right-prefix": E(() => [
526
+ V(l.$slots, "header-right-prefix")
518
527
  ]),
519
- "right-action": _(() => [
520
- N(i.$slots, "header-right-action")
528
+ "right-action": E(() => [
529
+ V(l.$slots, "header-right-action")
521
530
  ]),
522
- "right-suffix": _(() => [
523
- N(i.$slots, "header-right-suffix")
531
+ "right-suffix": E(() => [
532
+ V(l.$slots, "header-right-suffix")
524
533
  ]),
525
534
  _: 3
526
535
  }))
527
536
  ])
528
537
  ]),
529
- T("div", {
530
- class: de(["epic-split-view-container", { "hidden-header": i.hiddenHeader }])
538
+ N("div", {
539
+ class: de(["epic-split-view-container", { "hidden-header": l.hiddenHeader }])
531
540
  }, [
532
- $(D(l)),
533
- $(D(f)),
534
- $(D(v))
541
+ T(w(r)),
542
+ T(w(f)),
543
+ T(w(g))
535
544
  ], 2),
536
- $(Ce, {
545
+ T(Ce, {
537
546
  ref_key: "previewRef",
538
547
  ref: x
539
548
  }, null, 512)
540
549
  ])
541
550
  ]),
542
- fallback: _(() => [
543
- T("div", Te, [
544
- $(D(c))
551
+ fallback: E(() => [
552
+ N("div", Te, [
553
+ T(w(c))
545
554
  ])
546
555
  ]),
547
556
  _: 3
548
- })) : (I(), U("div", Me));
557
+ })) : ($(), K("div", Me));
549
558
  }
550
559
  });
551
560
  export {
@@ -556,8 +565,8 @@ export {
556
565
  Ke as capitalizeFirstLetter,
557
566
  ze as convertKFormData,
558
567
  Fe as debounce,
559
- J as deepClone,
560
- Z as deepCompareAndModify,
568
+ G as deepClone,
569
+ z as deepCompareAndModify,
561
570
  he as deepEqual,
562
571
  qe as findSchemaById,
563
572
  Qe as findSchemaInfoById,
@@ -569,19 +578,19 @@ export {
569
578
  Je as getFormSchemas,
570
579
  pe as getMatchedById,
571
580
  me as getUUID,
572
- B as loadAsyncComponent,
581
+ P as loadAsyncComponent,
573
582
  Ge as mapSchemas,
574
- V as pluginManager,
583
+ B as pluginManager,
575
584
  We as recursionConvertedNode,
576
- X as revoke,
585
+ Y as revoke,
577
586
  et as setAttributeValue,
578
587
  ve as useDark,
579
588
  Re as useElementDrag,
580
589
  Ae as useElementZoom,
581
590
  be as useKeyPress,
582
- G as usePageManager,
591
+ W as usePageManager,
583
592
  tt as useRevoke,
584
- R as useShareStore,
593
+ H as useShareStore,
585
594
  Se as useStore,
586
595
  Pe as useTheme,
587
596
  He as useTimedQuery
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "form-designer-xinyi",
3
3
  "private": false,
4
- "version": "1.5.5",
4
+ "version": "1.5.6",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",