snowy-designer
Version:
基于Epic-Designer-Pro版本的设计器,可视化开发页面表单
2 lines (1 loc) • 4.74 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("vue"),I=require("../common/component.cjs");require("lodash");require("monaco-editor");require("../request/index.cjs");require("@vueuse/core");require("../../../hooks/src/store/index.cjs");const de=require("../../../hooks/src/plugin/useBuiltInRequests.cjs"),fe=require("../../../hooks/src/plugin/useDict.cjs"),he=require("../../../hooks/src/plugin/useFormSchema.cjs"),ge=require("../../../hooks/src/plugin/usePanel.cjs"),ye=require("../../../hooks/src/plugin/useState.cjs"),Se=require("../../../repl/src/useDynamicComponent.cjs");function P(){const y=x.ref(!1),a={},G=[{componentProps:{colon:!0,labelAlign:"right",labelCol:{span:5},labelLayout:"fixed",labelPlacement:"left",labelWidth:100,layout:"horizontal",name:"default",wrapperCol:{span:19}},id:"root",label:"表单",type:"form",children:[]}],s={"epic-slot":{component:()=>null,config:{},defaultSchema:{type:"epic-slot"},editConstraints:{locked:!0},icon:""}};let p=[];const h=x.ref([]),{formSchema:A,setFormSchema:B}=he.useFormSchema();let u=[],m={},c=["表单","布局"];const{getActivitybars:F,getRightSidebars:N,hideActivitybar:R,hideRightSidebar:D,registerActivitybar:L,registerRightSidebar:M,showActivitybar:k,showRightSidebar:w,viewsContainers:j}=ge.usePanel(),g={},{removeProperty:O,setProperty:T,state:z}=ye.useState({axiosConfig:{baseURL:"",headers:{},params:{},timeout:1e4},uploadFile:"https://examples.epicjs.cn/epic-mock/common/upload",uploadImage:"https://examples.epicjs.cn/epic-mock/common/upload"}),{dictItems:E,dictList:V,loadDictItem:H,loadDictList:U,setFetchDictItemsFn:W,setFetchDictListFn:$}=fe.useDict(),d=de.useBuiltInRequests();function S(e,t){if(typeof t=="function"&&(t=I.loadAsyncComponent(t)),typeof t=="string"){const n=Se.parseComponent(t);t=I.loadAsyncComponent(()=>n)}a[e]=t}function J(e){S(e.defaultSchema.type,e.component),e.defaultSchema.input&&(e.config.action||(e.config.action=[]),e.config.action.unshift({argsConfigs:[{...e.defaultSchema,field:"0",label:"设置数据"}],description:"设置值",type:"setValue"},{description:"获取值",type:"getValue"})),s[e.defaultSchema.type]=e,i()}function b(e){delete s[e],delete a[e]}function C(e){p=e}function K(e){p.push(e)}function Q(){p.forEach(e=>{b(e)}),C([]),i()}function X(){return a}function Y(e){return a[e]}function Z(e){var t;return((t=f(e))==null?void 0:t.defaultSchema.label)??""}function _(e){var t;return((t=f(e))==null?void 0:t.icon)??""}function ee(e){var t,n;return(n=(t=f(e))==null?void 0:t.editConstraints)==null?void 0:n.locked}function te(){return s}function f(e){return s[e]}function i(){const e=[];Object.values(s).forEach(t=>{if(!u.includes(t.defaultSchema.type)&&t.groupName){const n=m[t.groupName]??t.groupName;let o=e.findIndex(l=>l.title===n);o===-1&&(e.push({title:n,list:[]}),o=e.length-1);const r=e[o].list.findIndex(l=>l.type===t.defaultSchema.type);r===-1?e[o].list.push(t.defaultSchema):e[o].list[r]=t.defaultSchema}}),e.sort((t,n)=>{const o=c.indexOf(t.title),r=c.indexOf(n.title);return o===-1?1:r===-1?-1:o-r}),e.forEach(t=>{t.list.sort((n,o)=>{var q,v;const r=((q=s[n.type])==null?void 0:q.sort)??1e3,l=((v=s[o.type])==null?void 0:v.sort)??1e3;return r-l})}),h.value=e}function ne(){return h}function oe(e,t){m[e]=t}function se(){m={}}function ie(e){c=e,i()}function re(){c=[],i()}function ue(e){u.push(e),i()}function ae(e){u=u.filter(t=>t!==e),i()}function ce(e){u=e,i()}function le(e){y.value=e}function pe(e){const t=e.methodName??e.name,n=e.method??e.handler;g[t]={...e,handler:n,name:t}}function me(e){delete g[e]}return{addBaseComponentType:K,addPublicMethod:pe,baseComponentTypes:p,clearComponentGroupNameMap:se,clearSortedGroups:re,component:S,componentConfigs:s,componentGroupNameMap:m,components:a,componentSchemaGroups:h,dictItems:E,dictList:V,formSchema:A,formSchemas:G,getActivitybars:F,getComponent:Y,getComponentConfingByType:f,getComponentConfings:te,getComponents:X,getComponentSchemaGroups:ne,getIcon:_,getLabel:Z,getLocked:ee,getRightSidebars:N,global:z,hiddenComponents:u,hideActivitybar:R,hideComponent:ue,hideRightSidebar:D,initialized:y,loadDictItem:H,loadDictList:U,publicMethods:g,registerActivitybar:L,registerComponent:J,registerRightSidebar:M,removeBaseComponents:Q,removeComponent:b,removeProperty:O,removePublicMethod:me,request:{clear:d.clear,execute:d.execute,register:d.register,requests:d.requests},setBaseComponentTypes:C,setComponentGroupNameMap:oe,setFetchDictItemsFn:W,setFetchDictListFn:$,setFormSchema:B,setHideComponents:ce,setInitialized:le,setProperty:T,setSortedGroups:ie,showActivitybar:k,showComponent:ae,showRightSidebar:w,sortedGroups:c,viewsContainers:j}}const be=P();exports.pluginManager=be;exports.usePluginManager=P;