@harbor-design/proform 1.0.5 → 1.0.7
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/index.cjs +1 -1
- package/dist/index.js +368 -347
- package/dist/types/src/services/Effect.d.ts +1 -1
- package/dist/types/src/services/Preset.d.ts +9 -0
- package/dist/types/src/services/Processor.d.ts +34 -0
- package/dist/types/src/services/RuntimeCore.d.ts +7 -5
- package/dist/types/src/services/index.d.ts +2 -2
- package/dist/types/src/types/formCustomizerTypes.d.ts +2 -0
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/processorTypes.d.ts +6 -0
- package/dist/types/src/utils/is.d.ts +4 -1
- package/package.json +3 -8
- package/CHANGELOG.md +0 -31
- package/dist/types/src/services/Processors.d.ts +0 -24
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var b=Object.defineProperty;var k=(u,e,t)=>e in u?b(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t;var m=(u,e,t)=>(k(u,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("vue");class R{constructor(e){m(this,"runtimeCore");this.formCustomization=e}cleanFallbackFields(e){return e!==null&&typeof e=="object"&&(delete e.__yiwwhl_async_field_fallback,Object.values(e).forEach(t=>{this.cleanFallbackFields(t)})),e}setup(e){return this.runtimeCore=e,this.formCustomization}submit(){return new Promise((e,t)=>{this.runtimeCore.formRef.value.validate(i=>i?t(i):e(this.cleanFallbackFields(l.toRaw(this.runtimeCore.processors.processedModel.value))))})}}class a{static typeChecker(e){return{}.toString.call(e)}static isArray(e){return this.typeChecker(e)==="[object Array]"}static isFunction(e){return this.typeChecker(e).includes("Function")}static isAsyncFunction(e){let t=!1;return this.typeChecker(e)==="[object AsyncFunction]"&&(t=!0),t}static isUndefined(e){return e===void 0}static isArrayEmpty(e){return(e==null?void 0:e.length)<1}static isObjectEmpty(e){return this.isArrayEmpty(Object.keys(e))}static isListSchema(e){return e.type==="list"}static isGroupSchema(e){return e.type==="group"}static isItemSchema(e){return this.isUndefined(e.type)||e.type==="item"}}function V(u){const e=new WeakMap;function t(i){if(i===null||typeof i!="object")return i;if(i instanceof Date)return new Date(i);if(i instanceof RegExp)return new RegExp(i);if(i instanceof Map){const o=new Map;for(let[s,f]of i)o.set(t(s),t(f));return o}if(i instanceof Set){const o=new Set;for(let s of i)o.add(t(s));return o}if(e.has(i))return e.get(i);if(Array.isArray(i)){const o=[];e.set(i,o);for(let s=0;s<i.length;s++)o[s]=t(i[s]);return o}const c=Object.create(Object.getPrototypeOf(i));e.set(i,c);for(let o in i)i.hasOwnProperty(o)&&(c[o]=t(i[o]));return c}return t(u)}class W{constructor(e,t){m(this,"rawSchemas",[]);m(this,"rawModel",{});m(this,"schemaPreset",{type:{defaultValueWhenAsync:"item"},component:{defaultValueWhenAsync:void 0},componentProps:{defaultValueWhenAsync:void 0},defaultValue:{defaultValueWhenAsync:void 0},label:{defaultValueWhenAsync:""},field:{defaultValueWhenAsync:"__yiwwhl_async_field_fallback"},rules:{defaultValueWhenAsync:[]},show:{defaultValueWhenAsync:!0}});m(this,"componentPropsPreset",{options:{defaultValueWhenAsync:[]}});m(this,"uniqueEffectMap",{});m(this,"schemaEffect",new F);m(this,"modelEffect",new F);m(this,"stopWatchEffect",new F);this.processedSchemas=e,this.processedModel=t,l.watch(()=>this.processedModel.value,()=>{this.schemaEffect.triggerEffects(),this.modelEffect.triggerEffects()},{deep:!0})}schemaAnalyzer(e,t=this.processedSchemas.value,i=this.rawSchemas,c,o){for(let s=0;s<e.length;s++){let f=e[s];this.schemaProcessor(f,s,(p,v,y)=>{y?i[s][y]=p[y]:(t[s]=p,this.modelProcessor(p,c&&this.processedModel.value[c][0]),(!i[s]||v)&&(i[s]=V(p)),this.schemaEffect.triggerEffects(),this.modelEffect.triggerEffects())},o,c)}}schemaProcessor(e,t,i,c,o){const s={},f=this;function p(v=!1){var y,w;if(s.componentProps){const h={};f.propsProcessor(s.componentProps,f.componentPropsPreset,h,E=>{s.componentProps=h,i({...s},E,"componentProps")},t,c);return}if(s.children){f.processedSchemas.value[t]=s,f.rawSchemas[t]=s,i({...s},v),f.schemaAnalyzer(s.children,(y=f.processedSchemas.value[t])==null?void 0:y.children,(w=f.rawSchemas[t])==null?void 0:w.children,s.field,t);return}i({...s},v),f.rawModel=V(f.processedModel.value)}this.propsProcessor(e,this.schemaPreset,s,p,t,c,o)}replaceFunctionsWithUndefined(e){if(typeof e!="object"||e===null)return e;for(let t in e)if(e.hasOwnProperty(t)){let i=e[t];typeof i=="function"||typeof i=="object"&&this.replaceFunctionsWithUndefined(i)}return e}runtimeMeta(){return{model:this.replaceFunctionsWithUndefined(l.toRaw(V(this.processedModel.value)))}}propsProcessor(e,t,i,c,o,s,f){const p=Object.keys(e),v=Array.from({length:p.length}).fill(!1);function y(){return v.every(w=>w)}for(let w=0;w<p.length;w++){const h=p[w],E=e[h];if(a.isFunction(E)){const P=E(this.runtimeMeta());h!=="defaultValue"?this.schemaEffect.trackEffect(()=>{let n=E(this.runtimeMeta());n instanceof Promise?n.then(r=>{s===void 0?a.isFunction(r)||(typeof r=="string"&&r.includes("undefined")&&(r=r.replace(/undefined/g,"")),this.processedSchemas.value[o][h]=r):a.isFunction(r)||(typeof r=="string"&&r.includes("undefined")&&(r=r.replace(/undefined/g,"")),this.processedSchemas.value[s].children[o][h]=r)}):s===void 0?a.isFunction(n)||(typeof n=="string"&&n.includes("undefined")&&(n=n.replace(/undefined/g,"")),this.processedSchemas.value[o][h]=n):a.isFunction(n)||(typeof n=="string"&&n.includes("undefined")&&(n=n.replace(/undefined/g,"")),this.processedSchemas.value[s].children[o][h]=n)}):this.modelEffect.trackEffect(()=>{let n=E(this.runtimeMeta());this.stopWatchEffect.trackEffect(l.watchEffect(()=>{if(n=E(this.runtimeMeta()),n instanceof Promise)n.then(r=>{if(typeof r=="string"&&!r.includes("undefined")?this.stopWatchEffect.triggerEffects():r=r.replace(/undefined/g,""),o===void 0||f===void 0){if(a.isFunction(e.field)){const d=e.field(this.runtimeMeta());d instanceof Promise?d.then(g=>{this.processedModel.value[g]=r}):this.processedModel.value[d]=r;return}this.processedModel.value[e.field]=r}else{if(a.isFunction(e.field)){const d=e.field(this.runtimeMeta());d instanceof Promise?d.then(g=>{this.processedModel.value[f][o][g]=r}):this.processedModel.value[f][o]&&(this.processedModel.value[f][o][d]=r);return}this.processedModel.value[f]&&this.processedModel.value[f].forEach(d=>{d[e.field]=r})}this.rawModel=V(this.processedModel.value),this.modelEffect.clearEffects()});else{if(typeof n=="string"&&!n.includes("undefined")?this.stopWatchEffect.triggerEffects():n=n.replace(/undefined/g,""),a.isFunction(e.field)){const r=e.field(this.runtimeMeta());r instanceof Promise?r.then(d=>{this.processedModel.value[d]=n}):this.processedModel.value[r]=n;return}if(this.processedModel.value[e.field]=n,o===void 0||f===void 0){if(a.isFunction(e.field)){const r=e.field(this.runtimeMeta());r instanceof Promise?r.then(d=>{this.processedModel.value[d]=n}):this.processedModel.value[r]=n;return}this.processedModel.value[e.field]=n}else for(let r=0;r<this.processedModel.value[f].length;r++){const d=this.processedModel.value[f][r];if(!a.isFunction(e.field))d[e.field]=n;else{const g=e.field(this.runtimeMeta());g instanceof Promise?g.then(S=>{d[S]=n}):d[g]=n;return}}this.rawModel=V(this.processedModel.value),this.modelEffect.clearEffects()}}))}),P instanceof Promise?(v[w]=!0,i[h]=t[h].defaultValueWhenAsync,y()&&c(),P.then(n=>{v[w]=!0,i[h]=n,y()&&c(!0)})):(v[w]=!0,i[h]=P,y()&&c())}else v[w]=!0,l.isRef(E)?l.watch(()=>E.value,P=>{i[h]=P,y()&&c()},{immediate:!0,deep:!0}):l.isReactive(E)?l.watch(()=>E,P=>{i[h]=P,y()&&c()},{immediate:!0,deep:!0}):(i[h]=E,y()&&c())}}modelProcessor(e,t=this.processedModel.value){if(a.isListSchema(e)){if(a.isFunction(e.field))return;t[e.field]||(t[e.field]=[{}]),e.children.forEach(i=>{this.modelProcessor(i,t[e.field][0])});return}if(a.isGroupSchema(e)){e.children.forEach(i=>{this.modelProcessor(i,t)});return}if(a.isItemSchema(e)){if(a.isFunction(e.field)||a.isUndefined(e.field)||!Number.isNaN(Number(e.field))||a.isFunction(e.defaultValue))return;t[e.field]=e.defaultValue}}}function A(u){return typeof u=="function"||Object.prototype.toString.call(u)==="[object Object]"&&!l.isVNode(u)}class N{constructor(e){m(this,"schemas",l.ref([]));m(this,"model",l.ref({}));m(this,"processorBySchemaType",{item:this.runtimeItemProcessor.bind(this),group:this.runtimeGroupProcessor.bind(this),list:this.runtimeListProcessor.bind(this)});m(this,"formRef",l.ref(null));this.setup=e,this.processors=new W(this.schemas,this.model),this.analyze(this.setup(this))}analyze(e){this.processors.schemaAnalyzer(e.schemas)}runtimeItemProcessor(e,t,i=this.model.value,c){const o=c?`${c.field}.${t}.${e.field}`:e.field,s=l.toRaw(e.component),f=e.componentProps??{};let p=e.show;return p===void 0&&(p=!0),p||delete i[e.field],l.createVNode(M.runtimeDoms.Item,null,{default(){return l.withDirectives(l.createVNode(M.runtimeDoms.FormItem,{label:`${e.label}:`,rules:e.rules,field:o},{default:()=>[l.createVNode(s,l.mergeProps({modelValue:i[e.field],"onUpdate:modelValue":v=>i[e.field]=v},f),null)]}),[[l.vShow,p]])}})}runtimeGroupProcessor(e){let t;return l.createVNode(M.runtimeDoms.Group,{schema:e},A(t=e.children.map(i=>this.runtimeItemProcessor(i)))?t:{default:()=>[t]})}addListItem(e){var t,i;if(!((t=this.processors.rawModel[e.field])!=null&&t[0]))return Promise.reject({code:"0001",message:"异步默认值数据正在处理中,请您耐心等待... "});(i=this.processors.rawModel[e.field])!=null&&i[0]&&this.model.value[e.field].push(V(this.processors.rawModel[e.field][0]))}deleteListItem(e,t){this.model.value[e.field].splice(t,1)}runtimeListProcessor(e){const t=this;return l.createVNode(M.runtimeDoms.List,{schema:e},{default(){return t.model.value[e.field].map((i,c)=>l.createVNode(M.runtimeDoms.ListItem,null,{default(){return e.children.map((o,s)=>t.runtimeItemProcessor(o,s,i,e))},delete({container:o}={}){var f;let s=o??l.createVNode("button",null,null);return l.withDirectives(l.createVNode(s,{onClick:()=>t.deleteListItem(e,c)},null),[[l.vShow,((f=t.model.value[e.field])==null?void 0:f.length)>1]])}}))},add({container:i}={}){let c=i??l.createVNode("button",null,[l.createTextVNode("添加")]);return l.createVNode(c,{onClick:()=>t.addListItem(e)},null)}})}runtimeProcessor(e){return e.map(t=>(t.type||(t.type="item"),this.processorBySchemaType[t.type](t)))}exec(){let e;return l.createVNode(M.runtimeDoms.Form,{ref:this.formRef,model:this.model.value},A(e=this.runtimeProcessor(this.schemas.value))?e:{default:()=>[e]})}}class M{}m(M,"runtimeDoms");class F{constructor(){m(this,"effects",new Set)}clearEffects(){this.effects.clear()}triggerEffects(){Array.from(this.effects).forEach(e=>e())}trackEffect(e){this.effects.add(e)}}const D=l.defineComponent({props:{setup:{type:Function,required:!0}},setup(u){const e=new N(u.setup);return()=>e.exec()}});function C(u){const e=new R(u);return[e.setup.bind(e),{submit:e.submit.bind(e)}]}function _(u){return{install(){M.runtimeDoms=u}}}exports.ProForm=D;exports.useForm=C;exports.useFormRenderer=_;
|
|
1
|
+
"use strict";var I=Object.defineProperty;var v=(l,e,t)=>e in l?I(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var f=(l,e,t)=>(v(l,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue");class O{constructor(e){f(this,"runtimeCore");this.formCustomization=e}cleanFallbackFields(e){return e!==null&&typeof e=="object"&&(delete e.__yiwwhl_async_field_fallback,Object.values(e).forEach(t=>{this.cleanFallbackFields(t)})),e}setup(e){return this.runtimeCore=e,this.formCustomization}submit(){return new Promise((e,t)=>{this.runtimeCore.formRef.value.validate(s=>s?t(s):e(this.cleanFallbackFields(i.toRaw(this.runtimeCore.processor.processedModel.value))))})}}class u{static typeChecker(e){return{}.toString.call(e)}static isArray(e){return this.typeChecker(e)==="[object Array]"}static isFunction(e){return this.typeChecker(e)==="[object Function]"}static isPromise(e){return e instanceof Promise}static isObject(e){return this.typeChecker(e)==="[object Object]"}static isAsyncFunction(e){return this.typeChecker(e)==="[object AsyncFunction]"}static isUndefined(e){return e===void 0}static isArrayEmpty(e){return(e==null?void 0:e.length)<1}static isObjectEmpty(e){return this.isArrayEmpty(Object.keys(e))}static isListSchema(e){return e.type==="list"}static isGroupSchema(e){return e.type==="group"}static isItemSchema(e){return this.isUndefined(e.type)||e.type==="item"}static isProcessInprogress(e){if(e===void 0)return!0;if(this.isObject(e)){if(e.setup&&this.isFunction(e.setup)&&e.props)return!1;if(this.isObjectEmpty(e))return!0;for(const t in e)if(e.hasOwnProperty(t)&&this.isProcessInprogress(e[t]))return!0}else if(this.isArray(e)){if(this.isArrayEmpty(e))return!0;for(const t of e)if(this.isProcessInprogress(t))return!0}return!1}}function j(l){const e=new WeakMap;function t(s){if(s===null||typeof s!="object")return s;if(s instanceof Date)return new Date(s);if(s instanceof RegExp)return new RegExp(s);if(s instanceof Map){const n=new Map;for(let[o,c]of s)n.set(t(o),t(c));return n}if(s instanceof Set){const n=new Set;for(let o of s)n.add(t(o));return n}if(e.has(s))return e.get(s);if(Array.isArray(s)){const n=[];e.set(s,n);for(let o=0;o<s.length;o++)n[o]=t(s[o]);return n}const r=Object.create(Object.getPrototypeOf(s));e.set(s,r);for(let n in s)s.hasOwnProperty(n)&&(r[n]=t(s[n]));return r}return t(l)}class E{constructor(){f(this,"effects",new Set)}clearEffects(){this.effects.clear()}triggerEffects(){Array.from(this.effects).forEach(e=>e())}trackEffect(e){return e(),this.effects.add(e),()=>this.effects.delete(e)}}class C{constructor(e){f(this,"processedSchemas");f(this,"processedModel");f(this,"getRuntimeMeta");f(this,"stableSchemas",[]);f(this,"stableModel",{});f(this,"schemaPreset",S.schemaPreset);f(this,"componentPropsPreset",S.componentPropsPreset);f(this,"stableUpdaterProcessProgress");f(this,"stableUpdaterTimes",0);f(this,"schemaEffect",new E);f(this,"defaultValueEffect",new E);f(this,"defaultValueInprogressMap",new Map);this.processedSchemas=e.schemas,this.processedModel=e.model,this.getRuntimeMeta=e.getRuntimeMeta.bind(e),i.watch(()=>this.processedModel.value,()=>{this.schemaEffect.triggerEffects()},{deep:!0})}parse(e,t){e.forEach((s,r)=>{this.parseItem(s,r,t)})}initSchemas(e){return e.map(t=>{const s={};return t.children&&(s.children=this.initSchemas(t.children)),s})}parseSchemas(e,t){u.isArrayEmpty(this.processedSchemas.value)&&(this.processedSchemas.value=this.initSchemas(e)),this.parse(e,t)}parseStable(e){const t={};if(!u.isUndefined(e.stable))t[e.key]=this.parseStable(e.stable);else return e;return t}stableUpdater(e=[]){if(e.every(Boolean)){const t=i.toRaw(this.processedSchemas.value);!u.isProcessInprogress(t)&&u.isObjectEmpty(this.stableModel)&&(this.stableUpdaterProcessProgress||(this.stableUpdaterProcessProgress=Array.from({length:t.length}).fill(!1)),this.stableUpdaterProcessProgress[this.stableUpdaterTimes]=!0,this.stableUpdaterTimes++,this.modelProcessor(t))}}parseItem(e,t,s){const r=this,n=Array.from({length:Object.keys(e).filter(c=>c!=="children").length}).fill(!1);this.objectParser({data:e,index:t,updater:o});function o(c){const a=c.index,d=c.key,y=c.keyIndex;if(!c.stable)return;const V=r.parseStable(c.stable),m=s==null?void 0:s.index,g=s==null?void 0:s.key;let p=V;if(u.isProcessInprogress(p)||(n[y]=!0),s){let b=r.processedSchemas.value[m][g][a][d];b&&u.isObject(b)&&d!=="component"&&(p=Object.assign(b,p)),r.processedSchemas.value[m][g][a][d]=p,r.stableUpdater(n)}else{let b=r.processedSchemas.value[a][d];b&&u.isObject(b)&&(p=Object.assign(b,p)),r.processedSchemas.value[a][d]=p,r.stableUpdater(n)}}}objectParser(e){const t=e.data;Object.keys(t).forEach((r,n)=>{if(r==="children")this.parseSchemas(t[r],{...e,key:r,keyIndex:n});else{const o=c=>{e.updater({...e,key:r,keyIndex:n,stable:c})};if(u.isFunction(t[r]))r!=="defaultValue"?this.schemaEffect.trackEffect(()=>{if(r==="component"){const c=t[r](this.getRuntimeMeta());this.promiseFieldParser(c,o,!1)}else this.fieldParser(t[r],o)}):this.defaultValueEffect.trackEffect(()=>{const c=this.schemaEffect.trackEffect(()=>{/\{\s*model\s*\}/.test(t[r].toString())?this.fieldParser(t[r],a=>{if(!a)return o(a);this.defaultValueInprogressMap.set(t[r],a),!u.isProcessInprogress(a)&&Array.from(this.defaultValueInprogressMap.values()).every(d=>!d.includes("undefined"))?(o(a),this.defaultValueEffect.clearEffects(),c()):o(a)}):this.fieldParser(t[r],a=>{!u.isProcessInprogress(a)&&Array.from(this.defaultValueInprogressMap.values()).every(d=>!d.includes("undefined"))?(o(a),this.defaultValueEffect.clearEffects(),c()):o(a)})})});else if(r==="component"){const c=t[r];this.promiseFieldParser(c,o,!1)}else this.fieldParser(t[r],o)}})}promiseFieldParser(e,t,s){u.isPromise(e)?e.then(r=>{s&&u.isObject(r)?this.objectParser({data:r,updater:t}):t(r)}):s&&u.isObject(e)?this.objectParser({data:e,updater:t}):t(e)}fieldParser(e,t,s=!0){if(u.isFunction(e)){const r=e(this.getRuntimeMeta());this.promiseFieldParser(r,t,s)}else i.isRef(e)?i.watch(()=>e.value,()=>{u.isUndefined(e.value)||(s&&u.isObject(e.value)?this.objectParser({data:e.value,updater:t}):t(e.value))},{immediate:!0,deep:!0}):i.isReactive(e)?i.watch(()=>e,()=>{u.isUndefined(e)||(s&&u.isObject(e)?this.objectParser({data:e,updater:t}):t(e))},{immediate:!0,deep:!0}):s&&u.isObject(e)?this.objectParser({data:e,updater:t}):t(e)}modelProcessor(e){e.map(t=>this.createModel(t,this.processedModel.value)),u.isObjectEmpty(this.stableModel)&&this.stableUpdaterProcessProgress.every(Boolean)&&this.defaultValueEffect.effects.size===0&&(this.stableModel=j(this.processedModel.value))}createModel(e,t){u.isListSchema(e)&&(t[e.field]||(t[e.field]=[{}]),e.children.forEach(s=>{this.createModel(s,t[e.field][0])})),u.isGroupSchema(e)&&e.children.forEach(s=>{this.createModel(s,t)}),u.isItemSchema(e)&&(t[e.field]=e.defaultValue)}}function w(l){return typeof l=="function"||Object.prototype.toString.call(l)==="[object Object]"&&!i.isVNode(l)}class R{constructor(e){f(this,"schemas",i.ref([]));f(this,"model",i.ref({}));f(this,"processorBySchemaType",{item:this.runtimeItemProcessor.bind(this),group:this.runtimeGroupProcessor.bind(this),list:this.runtimeListProcessor.bind(this)});f(this,"formRef",i.ref(null));this.setup=e,this.processor=new C(this);const t=this.setup(this);this.processor.parseSchemas(t.schemas)}getRuntimeMeta(){return{model:i.toRaw(j(this.model.value))}}runtimeItemProcessor(e,t,s=this.model.value,r){var g;const n=r?`${r.field}.${t}.${e.field}`:e.field,o=i.toRaw(e.component);if(!o)return;const c=o.name,a=e.componentProps??{},d=S.placeholderPresetByComponentName;let y=e.placeholder;y||(y=`${d[c]??"请输入"}${e.label}`),e.required&&(e.rules||(e.rules=[]),(g=e.rules)==null||g.push({required:!0,message:`${e.label}是必填项`}));let m=e.show;return m===void 0&&(m=!0),m||delete s[e.field],i.createVNode(h.runtimeDoms.Item,null,{default(){return i.withDirectives(i.createVNode(h.runtimeDoms.FormItem,{label:`${e.label}:`,rules:e.rules,field:n},{default:()=>[i.createVNode(o,i.mergeProps({modelValue:s[e.field],"onUpdate:modelValue":p=>s[e.field]=p,placeholder:y},a),null)]}),[[i.vShow,m]])}})}runtimeGroupProcessor(e){let t;return i.createVNode(h.runtimeDoms.Group,{schema:e},w(t=e.children.map(s=>this.runtimeItemProcessor(s)))?t:{default:()=>[t]})}addListItem(e){var t,s;if(!((t=this.processor.stableModel[e.field])!=null&&t[0]))return Promise.reject({code:"0001",message:"异步默认值数据正在处理中,请您耐心等待... "});(s=this.processor.stableModel[e.field])!=null&&s[0]&&this.model.value[e.field].push(j(this.processor.stableModel[e.field][0]))}deleteListItem(e,t){this.model.value[e.field].splice(t,1)}runtimeListProcessor(e){const t=this;return t.model.value[e.field]||(t.model.value[e.field]=[{}]),i.createVNode(h.runtimeDoms.List,{schema:e},{default(){return t.model.value[e.field].map((s,r)=>i.createVNode(h.runtimeDoms.ListItem,null,{default(){return e.children.map((n,o)=>t.runtimeItemProcessor(n,o,s,e))},delete({container:n}={}){var c;let o=n??i.createVNode("button",null,null);return i.withDirectives(i.createVNode(o,{onClick:()=>t.deleteListItem(e,r)},null),[[i.vShow,((c=t.model.value[e.field])==null?void 0:c.length)>1]])}}))},add({container:s}={}){let r=s??i.createVNode("button",null,[i.createTextVNode("添加")]);return i.createVNode(r,{onClick:()=>t.addListItem(e)},null)}})}runtimeProcessor(e){return e.map(t=>(t.type||(t.type="item"),this.processorBySchemaType[t.type](t)))}exec(){let e;return i.createVNode(h.runtimeDoms.Form,{ref:this.formRef,model:this.model.value},w(e=this.runtimeProcessor(this.schemas.value))?e:{default:()=>[e]})}}class h{}f(h,"runtimeDoms");const P=class P{static getPlaceholderPrefixPresetByComponentName(){const e={请选择:["Select","Tree","TreeSelect"],请输入:["Input"]},t={};for(let s in e)e[s].forEach(r=>{t[r]=s});return t}};f(P,"schemaPreset",{type:{defaultValue:"item"},component:{defaultValue:void 0},componentProps:{defaultValue:void 0},defaultValue:{defaultValue:void 0},label:{defaultValue:""},field:{defaultValue:"__yiwwhl_async_field_fallback"},rules:{defaultValue:[]},show:{defaultValue:!0},required:{defaultValue:!1},placeholder:{defaultValue:void 0},children:{defaultValue:[]}}),f(P,"componentPropsPreset",{options:{defaultValue:[]}}),f(P,"placeholderPresetByComponentName",P.getPlaceholderPrefixPresetByComponentName());let S=P;const N=i.defineComponent({props:{setup:{type:Function,required:!0}},setup(l){const e=new R(l.setup);return()=>e.exec()}});function x(l){const e=new O(l);return[e.setup.bind(e),{submit:e.submit.bind(e)}]}function A(l){return{install(){h.runtimeDoms=l}}}exports.ProForm=N;exports.useForm=x;exports.useFormRenderer=A;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { toRaw as S, watch as
|
|
5
|
-
class
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var U = (o, e, t) => e in o ? A(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var c = (o, e, t) => (U(o, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { toRaw as S, watch as E, isRef as R, isReactive as M, ref as I, createVNode as d, withDirectives as O, mergeProps as k, vShow as v, createTextVNode as D, isVNode as B, defineComponent as L } from "vue";
|
|
5
|
+
class N {
|
|
6
6
|
constructor(e) {
|
|
7
|
-
|
|
7
|
+
c(this, "runtimeCore");
|
|
8
8
|
this.formCustomization = e;
|
|
9
9
|
}
|
|
10
10
|
// happy path, 后续可以完善更多的 fallback 处理,fallback 处理是为了不卡住异步时的首次渲染做的优化
|
|
@@ -18,15 +18,15 @@ class B {
|
|
|
18
18
|
}
|
|
19
19
|
submit() {
|
|
20
20
|
return new Promise((e, t) => {
|
|
21
|
-
this.runtimeCore.formRef.value.validate((
|
|
21
|
+
this.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(
|
|
22
22
|
this.cleanFallbackFields(
|
|
23
|
-
S(this.runtimeCore.
|
|
23
|
+
S(this.runtimeCore.processor.processedModel.value)
|
|
24
24
|
)
|
|
25
25
|
));
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
class
|
|
29
|
+
class f {
|
|
30
30
|
static typeChecker(e) {
|
|
31
31
|
return {}.toString.call(e);
|
|
32
32
|
}
|
|
@@ -34,11 +34,16 @@ class d {
|
|
|
34
34
|
return this.typeChecker(e) === "[object Array]";
|
|
35
35
|
}
|
|
36
36
|
static isFunction(e) {
|
|
37
|
-
return this.typeChecker(e)
|
|
37
|
+
return this.typeChecker(e) === "[object Function]";
|
|
38
|
+
}
|
|
39
|
+
static isPromise(e) {
|
|
40
|
+
return e instanceof Promise;
|
|
41
|
+
}
|
|
42
|
+
static isObject(e) {
|
|
43
|
+
return this.typeChecker(e) === "[object Object]";
|
|
38
44
|
}
|
|
39
45
|
static isAsyncFunction(e) {
|
|
40
|
-
|
|
41
|
-
return this.typeChecker(e) === "[object AsyncFunction]" && (t = !0), t;
|
|
46
|
+
return this.typeChecker(e) === "[object AsyncFunction]";
|
|
42
47
|
}
|
|
43
48
|
static isUndefined(e) {
|
|
44
49
|
return e === void 0;
|
|
@@ -58,387 +63,363 @@ class d {
|
|
|
58
63
|
static isItemSchema(e) {
|
|
59
64
|
return this.isUndefined(e.type) || e.type === "item";
|
|
60
65
|
}
|
|
66
|
+
static isProcessInprogress(e) {
|
|
67
|
+
if (e === void 0)
|
|
68
|
+
return !0;
|
|
69
|
+
if (this.isObject(e)) {
|
|
70
|
+
if (e.setup && this.isFunction(e.setup) && e.props)
|
|
71
|
+
return !1;
|
|
72
|
+
if (this.isObjectEmpty(e))
|
|
73
|
+
return !0;
|
|
74
|
+
for (const t in e)
|
|
75
|
+
if (e.hasOwnProperty(t) && this.isProcessInprogress(e[t]))
|
|
76
|
+
return !0;
|
|
77
|
+
} else if (this.isArray(e)) {
|
|
78
|
+
if (this.isArrayEmpty(e))
|
|
79
|
+
return !0;
|
|
80
|
+
for (const t of e)
|
|
81
|
+
if (this.isProcessInprogress(t))
|
|
82
|
+
return !0;
|
|
83
|
+
}
|
|
84
|
+
return !1;
|
|
85
|
+
}
|
|
61
86
|
}
|
|
62
|
-
function
|
|
87
|
+
function V(o) {
|
|
63
88
|
const e = /* @__PURE__ */ new WeakMap();
|
|
64
|
-
function t(
|
|
65
|
-
if (
|
|
66
|
-
return
|
|
67
|
-
if (
|
|
68
|
-
return new Date(
|
|
69
|
-
if (
|
|
70
|
-
return new RegExp(
|
|
71
|
-
if (
|
|
72
|
-
const
|
|
73
|
-
for (let [
|
|
74
|
-
|
|
75
|
-
return
|
|
89
|
+
function t(s) {
|
|
90
|
+
if (s === null || typeof s != "object")
|
|
91
|
+
return s;
|
|
92
|
+
if (s instanceof Date)
|
|
93
|
+
return new Date(s);
|
|
94
|
+
if (s instanceof RegExp)
|
|
95
|
+
return new RegExp(s);
|
|
96
|
+
if (s instanceof Map) {
|
|
97
|
+
const n = /* @__PURE__ */ new Map();
|
|
98
|
+
for (let [i, l] of s)
|
|
99
|
+
n.set(t(i), t(l));
|
|
100
|
+
return n;
|
|
76
101
|
}
|
|
77
|
-
if (
|
|
78
|
-
const
|
|
79
|
-
for (let
|
|
80
|
-
|
|
81
|
-
return
|
|
102
|
+
if (s instanceof Set) {
|
|
103
|
+
const n = /* @__PURE__ */ new Set();
|
|
104
|
+
for (let i of s)
|
|
105
|
+
n.add(t(i));
|
|
106
|
+
return n;
|
|
82
107
|
}
|
|
83
|
-
if (e.has(
|
|
84
|
-
return e.get(
|
|
85
|
-
if (Array.isArray(
|
|
86
|
-
const
|
|
87
|
-
e.set(
|
|
88
|
-
for (let
|
|
89
|
-
|
|
90
|
-
return
|
|
108
|
+
if (e.has(s))
|
|
109
|
+
return e.get(s);
|
|
110
|
+
if (Array.isArray(s)) {
|
|
111
|
+
const n = [];
|
|
112
|
+
e.set(s, n);
|
|
113
|
+
for (let i = 0; i < s.length; i++)
|
|
114
|
+
n[i] = t(s[i]);
|
|
115
|
+
return n;
|
|
91
116
|
}
|
|
92
|
-
const
|
|
93
|
-
e.set(
|
|
94
|
-
for (let
|
|
95
|
-
|
|
96
|
-
return
|
|
117
|
+
const r = Object.create(Object.getPrototypeOf(s));
|
|
118
|
+
e.set(s, r);
|
|
119
|
+
for (let n in s)
|
|
120
|
+
s.hasOwnProperty(n) && (r[n] = t(s[n]));
|
|
121
|
+
return r;
|
|
97
122
|
}
|
|
98
|
-
return t(
|
|
123
|
+
return t(o);
|
|
99
124
|
}
|
|
100
|
-
class
|
|
101
|
-
constructor(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
h(this, "componentPropsPreset", {
|
|
131
|
-
options: {
|
|
132
|
-
defaultValueWhenAsync: []
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
h(this, "uniqueEffectMap", {});
|
|
136
|
-
h(this, "schemaEffect", new k());
|
|
137
|
-
h(this, "modelEffect", new k());
|
|
138
|
-
h(this, "stopWatchEffect", new k());
|
|
139
|
-
this.processedSchemas = e, this.processedModel = t, F(
|
|
125
|
+
class C {
|
|
126
|
+
constructor() {
|
|
127
|
+
c(this, "effects", /* @__PURE__ */ new Set());
|
|
128
|
+
}
|
|
129
|
+
clearEffects() {
|
|
130
|
+
this.effects.clear();
|
|
131
|
+
}
|
|
132
|
+
triggerEffects() {
|
|
133
|
+
Array.from(this.effects).forEach((e) => e());
|
|
134
|
+
}
|
|
135
|
+
trackEffect(e) {
|
|
136
|
+
return e(), this.effects.add(e), () => this.effects.delete(e);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
class T {
|
|
140
|
+
constructor(e) {
|
|
141
|
+
c(this, "processedSchemas");
|
|
142
|
+
c(this, "processedModel");
|
|
143
|
+
c(this, "getRuntimeMeta");
|
|
144
|
+
c(this, "stableSchemas", []);
|
|
145
|
+
c(this, "stableModel", {});
|
|
146
|
+
c(this, "schemaPreset", j.schemaPreset);
|
|
147
|
+
c(this, "componentPropsPreset", j.componentPropsPreset);
|
|
148
|
+
c(this, "stableUpdaterProcessProgress");
|
|
149
|
+
c(this, "stableUpdaterTimes", 0);
|
|
150
|
+
c(this, "schemaEffect", new C());
|
|
151
|
+
c(this, "defaultValueEffect", new C());
|
|
152
|
+
c(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
|
|
153
|
+
this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), E(
|
|
140
154
|
() => this.processedModel.value,
|
|
141
155
|
() => {
|
|
142
|
-
this.schemaEffect.triggerEffects()
|
|
156
|
+
this.schemaEffect.triggerEffects();
|
|
143
157
|
},
|
|
144
158
|
{
|
|
145
159
|
deep: !0
|
|
146
160
|
}
|
|
147
161
|
);
|
|
148
162
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
this.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
// 核心处理过程,接收一个初始的代理数据结构,由其衍生的有 parseSchema
|
|
164
|
+
parse(e, t) {
|
|
165
|
+
e.forEach((s, r) => {
|
|
166
|
+
this.parseItem(s, r, t);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
// 初始化空数据结构,避免后续复杂的 if else
|
|
170
|
+
initSchemas(e) {
|
|
171
|
+
return e.map((t) => {
|
|
172
|
+
const s = {};
|
|
173
|
+
return t.children && (s.children = this.initSchemas(t.children)), s;
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
// 派生过程,用于外部应用
|
|
177
|
+
parseSchemas(e, t) {
|
|
178
|
+
f.isArrayEmpty(this.processedSchemas.value) && (this.processedSchemas.value = this.initSchemas(e)), this.parse(e, t);
|
|
179
|
+
}
|
|
180
|
+
parseStable(e) {
|
|
181
|
+
const t = {};
|
|
182
|
+
if (!f.isUndefined(e.stable))
|
|
183
|
+
t[e.key] = this.parseStable(e.stable);
|
|
184
|
+
else
|
|
185
|
+
return e;
|
|
186
|
+
return t;
|
|
187
|
+
}
|
|
188
|
+
// 对于稳定初始化更新的抽象
|
|
189
|
+
stableUpdater(e = []) {
|
|
190
|
+
if (e.every(Boolean)) {
|
|
191
|
+
const t = S(this.processedSchemas.value);
|
|
192
|
+
!f.isProcessInprogress(t) && f.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
|
|
193
|
+
length: t.length
|
|
194
|
+
}).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
|
|
164
195
|
}
|
|
165
196
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
a,
|
|
176
|
-
(v) => {
|
|
177
|
-
s.componentProps = a, i({ ...s }, v, "componentProps");
|
|
178
|
-
},
|
|
179
|
-
t,
|
|
180
|
-
f
|
|
181
|
-
);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (s.children) {
|
|
185
|
-
l.processedSchemas.value[t] = s, l.rawSchemas[t] = s, i({ ...s }, y), l.schemaAnalyzer(
|
|
186
|
-
s.children,
|
|
187
|
-
// @ts-expect-error 此处已经守卫为非 ItemSchema
|
|
188
|
-
(p = l.processedSchemas.value[t]) == null ? void 0 : p.children,
|
|
189
|
-
// @ts-expect-error 此处已经守卫为非 ItemSchema
|
|
190
|
-
(E = l.rawSchemas[t]) == null ? void 0 : E.children,
|
|
191
|
-
s.field,
|
|
192
|
-
t
|
|
193
|
-
);
|
|
197
|
+
// 核心单 schema 处理过程,接收一个对象键值对的数据结构
|
|
198
|
+
parseItem(e, t, s) {
|
|
199
|
+
const r = this, n = Array.from({
|
|
200
|
+
length: Object.keys(e).filter((l) => l !== "children").length
|
|
201
|
+
}).fill(!1);
|
|
202
|
+
this.objectParser({ data: e, index: t, updater: i });
|
|
203
|
+
function i(l) {
|
|
204
|
+
const u = l.index, a = l.key, y = l.keyIndex;
|
|
205
|
+
if (!l.stable)
|
|
194
206
|
return;
|
|
207
|
+
const w = r.parseStable(l.stable), m = s == null ? void 0 : s.index, g = s == null ? void 0 : s.key;
|
|
208
|
+
let p = w;
|
|
209
|
+
if (f.isProcessInprogress(p) || (n[y] = !0), s) {
|
|
210
|
+
let b = r.processedSchemas.value[m][g][u][a];
|
|
211
|
+
b && f.isObject(b) && a !== "component" && (p = Object.assign(b, p)), r.processedSchemas.value[m][g][u][a] = p, r.stableUpdater(n);
|
|
212
|
+
} else {
|
|
213
|
+
let b = r.processedSchemas.value[u][a];
|
|
214
|
+
b && f.isObject(b) && (p = Object.assign(b, p)), r.processedSchemas.value[u][a] = p, r.stableUpdater(n);
|
|
195
215
|
}
|
|
196
|
-
i({ ...s }, y), l.rawModel = A(l.processedModel.value);
|
|
197
216
|
}
|
|
198
|
-
this.propsProcessor(
|
|
199
|
-
e,
|
|
200
|
-
this.schemaPreset,
|
|
201
|
-
s,
|
|
202
|
-
m,
|
|
203
|
-
t,
|
|
204
|
-
f,
|
|
205
|
-
o
|
|
206
|
-
);
|
|
207
217
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
-
|
|
218
|
+
// 只做基本的对象 parser
|
|
219
|
+
objectParser(e) {
|
|
220
|
+
const t = e.data;
|
|
221
|
+
Object.keys(t).forEach((r, n) => {
|
|
222
|
+
if (r === "children")
|
|
223
|
+
this.parseSchemas(t[r], {
|
|
224
|
+
...e,
|
|
225
|
+
key: r,
|
|
226
|
+
keyIndex: n
|
|
227
|
+
});
|
|
228
|
+
else {
|
|
229
|
+
const i = (l) => {
|
|
230
|
+
e.updater({
|
|
231
|
+
...e,
|
|
232
|
+
key: r,
|
|
233
|
+
keyIndex: n,
|
|
234
|
+
stable: l
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
if (f.isFunction(t[r]))
|
|
238
|
+
r !== "defaultValue" ? this.schemaEffect.trackEffect(() => {
|
|
239
|
+
if (r === "component") {
|
|
240
|
+
const l = t[r](this.getRuntimeMeta());
|
|
241
|
+
this.promiseFieldParser(l, i, !1);
|
|
242
|
+
} else
|
|
243
|
+
this.fieldParser(t[r], i);
|
|
244
|
+
}) : this.defaultValueEffect.trackEffect(() => {
|
|
245
|
+
const l = this.schemaEffect.trackEffect(() => {
|
|
246
|
+
/\{\s*model\s*\}/.test(t[r].toString()) ? this.fieldParser(t[r], (u) => {
|
|
247
|
+
if (!u)
|
|
248
|
+
return i(u);
|
|
249
|
+
this.defaultValueInprogressMap.set(t[r], u), !f.isProcessInprogress(u) && Array.from(this.defaultValueInprogressMap.values()).every(
|
|
250
|
+
(a) => !a.includes("undefined")
|
|
251
|
+
) ? (i(u), this.defaultValueEffect.clearEffects(), l()) : i(u);
|
|
252
|
+
}) : this.fieldParser(t[r], (u) => {
|
|
253
|
+
!f.isProcessInprogress(u) && Array.from(this.defaultValueInprogressMap.values()).every(
|
|
254
|
+
(a) => !a.includes("undefined")
|
|
255
|
+
) ? (i(u), this.defaultValueEffect.clearEffects(), l()) : i(u);
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
else if (r === "component") {
|
|
260
|
+
const l = t[r];
|
|
261
|
+
this.promiseFieldParser(l, i, !1);
|
|
262
|
+
} else
|
|
263
|
+
this.fieldParser(t[r], i);
|
|
215
264
|
}
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
runtimeMeta() {
|
|
219
|
-
return {
|
|
220
|
-
model: this.replaceFunctionsWithUndefined(
|
|
221
|
-
S(A(this.processedModel.value))
|
|
222
|
-
)
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
propsProcessor(e, t, i, f, o, s, l) {
|
|
226
|
-
const m = Object.keys(e), y = Array.from({
|
|
227
|
-
length: m.length
|
|
228
|
-
}).fill(!1);
|
|
229
|
-
function p() {
|
|
230
|
-
return y.every((E) => E);
|
|
231
|
-
}
|
|
232
|
-
for (let E = 0; E < m.length; E++) {
|
|
233
|
-
const a = m[E], v = e[a];
|
|
234
|
-
if (d.isFunction(v)) {
|
|
235
|
-
const P = v(this.runtimeMeta());
|
|
236
|
-
a !== "defaultValue" ? this.schemaEffect.trackEffect(() => {
|
|
237
|
-
let n = v(this.runtimeMeta());
|
|
238
|
-
n instanceof Promise ? n.then((r) => {
|
|
239
|
-
s === void 0 ? d.isFunction(r) || (typeof r == "string" && r.includes("undefined") && (r = r.replace(/undefined/g, "")), this.processedSchemas.value[o][a] = r) : d.isFunction(r) || (typeof r == "string" && r.includes("undefined") && (r = r.replace(/undefined/g, "")), this.processedSchemas.value[s].children[o][a] = r);
|
|
240
|
-
}) : s === void 0 ? d.isFunction(n) || (typeof n == "string" && n.includes("undefined") && (n = n.replace(/undefined/g, "")), this.processedSchemas.value[o][a] = n) : d.isFunction(n) || (typeof n == "string" && n.includes("undefined") && (n = n.replace(/undefined/g, "")), this.processedSchemas.value[s].children[o][a] = n);
|
|
241
|
-
}) : this.modelEffect.trackEffect(() => {
|
|
242
|
-
let n = v(this.runtimeMeta());
|
|
243
|
-
this.stopWatchEffect.trackEffect(
|
|
244
|
-
j(() => {
|
|
245
|
-
if (n = v(this.runtimeMeta()), n instanceof Promise)
|
|
246
|
-
n.then((r) => {
|
|
247
|
-
if (typeof r == "string" && !r.includes("undefined") ? this.stopWatchEffect.triggerEffects() : r = r.replace(/undefined/g, ""), o === void 0 || l === void 0) {
|
|
248
|
-
if (d.isFunction(e.field)) {
|
|
249
|
-
const u = e.field(
|
|
250
|
-
this.runtimeMeta()
|
|
251
|
-
);
|
|
252
|
-
u instanceof Promise ? u.then((g) => {
|
|
253
|
-
this.processedModel.value[g] = r;
|
|
254
|
-
}) : this.processedModel.value[u] = r;
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
this.processedModel.value[e.field] = r;
|
|
258
|
-
} else {
|
|
259
|
-
if (d.isFunction(e.field)) {
|
|
260
|
-
const u = e.field(
|
|
261
|
-
this.runtimeMeta()
|
|
262
|
-
);
|
|
263
|
-
u instanceof Promise ? u.then((g) => {
|
|
264
|
-
this.processedModel.value[l][o][g] = r;
|
|
265
|
-
}) : this.processedModel.value[l][o] && (this.processedModel.value[l][o][u] = r);
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
this.processedModel.value[l] && this.processedModel.value[l].forEach(
|
|
269
|
-
// @ts-expect-error
|
|
270
|
-
(u) => {
|
|
271
|
-
u[e.field] = r;
|
|
272
|
-
}
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
this.rawModel = A(this.processedModel.value), this.modelEffect.clearEffects();
|
|
276
|
-
});
|
|
277
|
-
else {
|
|
278
|
-
if (typeof n == "string" && !n.includes("undefined") ? this.stopWatchEffect.triggerEffects() : n = n.replace(/undefined/g, ""), d.isFunction(e.field)) {
|
|
279
|
-
const r = e.field(this.runtimeMeta());
|
|
280
|
-
r instanceof Promise ? r.then((u) => {
|
|
281
|
-
this.processedModel.value[u] = n;
|
|
282
|
-
}) : this.processedModel.value[r] = n;
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
if (this.processedModel.value[e.field] = n, o === void 0 || l === void 0) {
|
|
286
|
-
if (d.isFunction(e.field)) {
|
|
287
|
-
const r = e.field(this.runtimeMeta());
|
|
288
|
-
r instanceof Promise ? r.then((u) => {
|
|
289
|
-
this.processedModel.value[u] = n;
|
|
290
|
-
}) : this.processedModel.value[r] = n;
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
this.processedModel.value[e.field] = n;
|
|
294
|
-
} else
|
|
295
|
-
for (let r = 0; r < this.processedModel.value[l].length; r++) {
|
|
296
|
-
const u = this.processedModel.value[l][r];
|
|
297
|
-
if (!d.isFunction(e.field))
|
|
298
|
-
u[e.field] = n;
|
|
299
|
-
else {
|
|
300
|
-
const g = e.field(
|
|
301
|
-
this.runtimeMeta()
|
|
302
|
-
);
|
|
303
|
-
g instanceof Promise ? g.then((C) => {
|
|
304
|
-
u[C] = n;
|
|
305
|
-
}) : u[g] = n;
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
this.rawModel = A(this.processedModel.value), this.modelEffect.clearEffects();
|
|
310
|
-
}
|
|
311
|
-
})
|
|
312
|
-
);
|
|
313
|
-
}), P instanceof Promise ? (y[E] = !0, i[a] = t[a].defaultValueWhenAsync, p() && f(), P.then((n) => {
|
|
314
|
-
y[E] = !0, i[a] = n, p() && f(!0);
|
|
315
|
-
})) : (y[E] = !0, i[a] = P, p() && f());
|
|
316
|
-
} else
|
|
317
|
-
y[E] = !0, L(v) ? F(
|
|
318
|
-
() => v.value,
|
|
319
|
-
(P) => {
|
|
320
|
-
i[a] = P, p() && f();
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
immediate: !0,
|
|
324
|
-
deep: !0
|
|
325
|
-
}
|
|
326
|
-
) : z(v) ? F(
|
|
327
|
-
() => v,
|
|
328
|
-
(P) => {
|
|
329
|
-
i[a] = P, p() && f();
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
immediate: !0,
|
|
333
|
-
deep: !0
|
|
334
|
-
}
|
|
335
|
-
) : (i[a] = v, p() && f());
|
|
336
|
-
}
|
|
265
|
+
});
|
|
337
266
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
267
|
+
promiseFieldParser(e, t, s) {
|
|
268
|
+
f.isPromise(e) ? e.then((r) => {
|
|
269
|
+
s && f.isObject(r) ? this.objectParser({
|
|
270
|
+
data: r,
|
|
271
|
+
updater: t
|
|
272
|
+
}) : t(r);
|
|
273
|
+
}) : s && f.isObject(e) ? this.objectParser({
|
|
274
|
+
data: e,
|
|
275
|
+
updater: t
|
|
276
|
+
}) : t(e);
|
|
277
|
+
}
|
|
278
|
+
// 对任意对象中单个字段的 parse: 做基本处理
|
|
279
|
+
fieldParser(e, t, s = !0) {
|
|
280
|
+
if (f.isFunction(e)) {
|
|
281
|
+
const r = e(this.getRuntimeMeta());
|
|
282
|
+
this.promiseFieldParser(r, t, s);
|
|
283
|
+
} else
|
|
284
|
+
R(e) ? E(
|
|
285
|
+
() => e.value,
|
|
286
|
+
() => {
|
|
287
|
+
f.isUndefined(e.value) || (s && f.isObject(e.value) ? this.objectParser({
|
|
288
|
+
data: e.value,
|
|
289
|
+
updater: t
|
|
290
|
+
}) : t(e.value));
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
immediate: !0,
|
|
294
|
+
deep: !0
|
|
295
|
+
}
|
|
296
|
+
) : M(e) ? E(
|
|
297
|
+
() => e,
|
|
298
|
+
() => {
|
|
299
|
+
f.isUndefined(e) || (s && f.isObject(e) ? this.objectParser({
|
|
300
|
+
data: e,
|
|
301
|
+
updater: t
|
|
302
|
+
}) : t(e));
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
immediate: !0,
|
|
306
|
+
deep: !0
|
|
307
|
+
}
|
|
308
|
+
) : s && f.isObject(e) ? this.objectParser({
|
|
309
|
+
data: e,
|
|
310
|
+
updater: t
|
|
311
|
+
}) : t(e);
|
|
312
|
+
}
|
|
313
|
+
modelProcessor(e) {
|
|
314
|
+
e.map(
|
|
315
|
+
(t) => this.createModel(t, this.processedModel.value)
|
|
316
|
+
), f.isObjectEmpty(this.stableModel) && this.stableUpdaterProcessProgress.every(Boolean) && this.defaultValueEffect.effects.size === 0 && (this.stableModel = V(this.processedModel.value));
|
|
317
|
+
}
|
|
318
|
+
createModel(e, t) {
|
|
319
|
+
f.isListSchema(e) && (t[e.field] || (t[e.field] = [{}]), e.children.forEach((s) => {
|
|
320
|
+
this.createModel(s, t[e.field][0]);
|
|
321
|
+
})), f.isGroupSchema(e) && e.children.forEach((s) => {
|
|
322
|
+
this.createModel(s, t);
|
|
323
|
+
}), f.isItemSchema(e) && (t[e.field] = e.defaultValue);
|
|
358
324
|
}
|
|
359
325
|
}
|
|
360
|
-
function
|
|
361
|
-
return typeof
|
|
326
|
+
function x(o) {
|
|
327
|
+
return typeof o == "function" || Object.prototype.toString.call(o) === "[object Object]" && !B(o);
|
|
362
328
|
}
|
|
363
|
-
class
|
|
329
|
+
class _ {
|
|
364
330
|
constructor(e) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
331
|
+
c(this, "schemas", I([]));
|
|
332
|
+
c(this, "model", I({}));
|
|
333
|
+
c(this, "processorBySchemaType", {
|
|
368
334
|
item: this.runtimeItemProcessor.bind(this),
|
|
369
335
|
group: this.runtimeGroupProcessor.bind(this),
|
|
370
336
|
list: this.runtimeListProcessor.bind(this)
|
|
371
337
|
});
|
|
372
|
-
|
|
373
|
-
this.setup = e, this.
|
|
338
|
+
c(this, "formRef", I(null));
|
|
339
|
+
this.setup = e, this.processor = new T(this);
|
|
340
|
+
const t = this.setup(this);
|
|
341
|
+
this.processor.parseSchemas(t.schemas);
|
|
374
342
|
}
|
|
375
|
-
|
|
376
|
-
|
|
343
|
+
getRuntimeMeta() {
|
|
344
|
+
return {
|
|
345
|
+
model: S(V(this.model.value))
|
|
346
|
+
};
|
|
377
347
|
}
|
|
378
|
-
runtimeItemProcessor(e, t,
|
|
379
|
-
|
|
348
|
+
runtimeItemProcessor(e, t, s = this.model.value, r) {
|
|
349
|
+
var g;
|
|
350
|
+
const n = r ? `${r.field}.${t}.${e.field}` : e.field, i = S(e.component);
|
|
351
|
+
if (!i)
|
|
352
|
+
return;
|
|
353
|
+
const l = i.name, u = e.componentProps ?? {}, a = j.placeholderPresetByComponentName;
|
|
354
|
+
let y = e.placeholder;
|
|
355
|
+
y || (y = `${// @ts-expect-error
|
|
356
|
+
a[l] ?? "请输入"}${e.label}`), e.required && (e.rules || (e.rules = []), (g = e.rules) == null || g.push({
|
|
357
|
+
required: !0,
|
|
358
|
+
message: `${e.label}是必填项`
|
|
359
|
+
}));
|
|
380
360
|
let m = e.show;
|
|
381
|
-
return m === void 0 && (m = !0), m || delete
|
|
361
|
+
return m === void 0 && (m = !0), m || delete s[e.field], d(h.runtimeDoms.Item, null, {
|
|
382
362
|
default() {
|
|
383
|
-
return
|
|
363
|
+
return O(d(h.runtimeDoms.FormItem, {
|
|
384
364
|
label: `${e.label}:`,
|
|
385
365
|
rules: e.rules,
|
|
386
|
-
field:
|
|
366
|
+
field: n
|
|
387
367
|
}, {
|
|
388
|
-
default: () => [
|
|
389
|
-
modelValue:
|
|
390
|
-
"onUpdate:modelValue": (
|
|
391
|
-
|
|
392
|
-
|
|
368
|
+
default: () => [d(i, k({
|
|
369
|
+
modelValue: s[e.field],
|
|
370
|
+
"onUpdate:modelValue": (p) => s[e.field] = p,
|
|
371
|
+
placeholder: y
|
|
372
|
+
}, u), null)]
|
|
373
|
+
}), [[v, m]]);
|
|
393
374
|
}
|
|
394
375
|
});
|
|
395
376
|
}
|
|
396
377
|
runtimeGroupProcessor(e) {
|
|
397
378
|
let t;
|
|
398
|
-
return
|
|
379
|
+
return d(h.runtimeDoms.Group, {
|
|
399
380
|
schema: e
|
|
400
|
-
},
|
|
381
|
+
}, x(t = e.children.map((s) => this.runtimeItemProcessor(s))) ? t : {
|
|
401
382
|
default: () => [t]
|
|
402
383
|
});
|
|
403
384
|
}
|
|
404
385
|
addListItem(e) {
|
|
405
|
-
var t,
|
|
406
|
-
if (!((t = this.
|
|
386
|
+
var t, s;
|
|
387
|
+
if (!((t = this.processor.stableModel[e.field]) != null && t[0]))
|
|
407
388
|
return Promise.reject({
|
|
408
389
|
code: "0001",
|
|
409
390
|
message: "异步默认值数据正在处理中,请您耐心等待... "
|
|
410
391
|
});
|
|
411
|
-
(
|
|
392
|
+
(s = this.processor.stableModel[e.field]) != null && s[0] && this.model.value[e.field].push(V(this.processor.stableModel[e.field][0]));
|
|
412
393
|
}
|
|
413
394
|
deleteListItem(e, t) {
|
|
414
395
|
this.model.value[e.field].splice(t, 1);
|
|
415
396
|
}
|
|
416
397
|
runtimeListProcessor(e) {
|
|
417
398
|
const t = this;
|
|
418
|
-
return
|
|
399
|
+
return t.model.value[e.field] || (t.model.value[e.field] = [{}]), d(h.runtimeDoms.List, {
|
|
419
400
|
schema: e
|
|
420
401
|
}, {
|
|
421
402
|
default() {
|
|
422
|
-
return t.model.value[e.field].map((
|
|
403
|
+
return t.model.value[e.field].map((s, r) => d(h.runtimeDoms.ListItem, null, {
|
|
423
404
|
default() {
|
|
424
|
-
return e.children.map((
|
|
405
|
+
return e.children.map((n, i) => t.runtimeItemProcessor(n, i, s, e));
|
|
425
406
|
},
|
|
426
407
|
delete({
|
|
427
|
-
container:
|
|
408
|
+
container: n
|
|
428
409
|
} = {}) {
|
|
429
410
|
var l;
|
|
430
|
-
let
|
|
431
|
-
return
|
|
432
|
-
onClick: () => t.deleteListItem(e,
|
|
433
|
-
}, null), [[
|
|
411
|
+
let i = n ?? d("button", null, null);
|
|
412
|
+
return O(d(i, {
|
|
413
|
+
onClick: () => t.deleteListItem(e, r)
|
|
414
|
+
}, null), [[v, ((l = t.model.value[e.field]) == null ? void 0 : l.length) > 1]]);
|
|
434
415
|
}
|
|
435
416
|
}));
|
|
436
417
|
},
|
|
437
418
|
add({
|
|
438
|
-
container:
|
|
419
|
+
container: s
|
|
439
420
|
} = {}) {
|
|
440
|
-
let
|
|
441
|
-
return
|
|
421
|
+
let r = s ?? d("button", null, [D("添加")]);
|
|
422
|
+
return d(r, {
|
|
442
423
|
onClick: () => t.addListItem(e)
|
|
443
424
|
}, null);
|
|
444
425
|
}
|
|
@@ -449,45 +430,85 @@ class T {
|
|
|
449
430
|
}
|
|
450
431
|
exec() {
|
|
451
432
|
let e;
|
|
452
|
-
return
|
|
433
|
+
return d(h.runtimeDoms.Form, {
|
|
453
434
|
ref: this.formRef,
|
|
454
435
|
model: this.model.value
|
|
455
|
-
},
|
|
436
|
+
}, x(e = this.runtimeProcessor(this.schemas.value)) ? e : {
|
|
456
437
|
default: () => [e]
|
|
457
438
|
});
|
|
458
439
|
}
|
|
459
440
|
}
|
|
460
|
-
class
|
|
441
|
+
class h {
|
|
461
442
|
}
|
|
462
|
-
h
|
|
463
|
-
class
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
443
|
+
c(h, "runtimeDoms");
|
|
444
|
+
const P = class P {
|
|
445
|
+
static getPlaceholderPrefixPresetByComponentName() {
|
|
446
|
+
const e = {
|
|
447
|
+
请选择: ["Select", "Tree", "TreeSelect"],
|
|
448
|
+
请输入: ["Input"]
|
|
449
|
+
}, t = {};
|
|
450
|
+
for (let s in e)
|
|
451
|
+
e[s].forEach((r) => {
|
|
452
|
+
t[r] = s;
|
|
453
|
+
});
|
|
454
|
+
return t;
|
|
469
455
|
}
|
|
470
|
-
|
|
471
|
-
|
|
456
|
+
};
|
|
457
|
+
c(P, "schemaPreset", {
|
|
458
|
+
type: {
|
|
459
|
+
defaultValue: "item"
|
|
460
|
+
},
|
|
461
|
+
component: {
|
|
462
|
+
defaultValue: void 0
|
|
463
|
+
},
|
|
464
|
+
componentProps: {
|
|
465
|
+
defaultValue: void 0
|
|
466
|
+
},
|
|
467
|
+
defaultValue: {
|
|
468
|
+
defaultValue: void 0
|
|
469
|
+
},
|
|
470
|
+
label: {
|
|
471
|
+
defaultValue: ""
|
|
472
|
+
},
|
|
473
|
+
field: {
|
|
474
|
+
defaultValue: "__yiwwhl_async_field_fallback"
|
|
475
|
+
},
|
|
476
|
+
rules: {
|
|
477
|
+
defaultValue: []
|
|
478
|
+
},
|
|
479
|
+
show: {
|
|
480
|
+
defaultValue: !0
|
|
481
|
+
},
|
|
482
|
+
required: {
|
|
483
|
+
defaultValue: !1
|
|
484
|
+
},
|
|
485
|
+
placeholder: {
|
|
486
|
+
defaultValue: void 0
|
|
487
|
+
},
|
|
488
|
+
children: {
|
|
489
|
+
defaultValue: []
|
|
472
490
|
}
|
|
473
|
-
|
|
474
|
-
|
|
491
|
+
}), c(P, "componentPropsPreset", {
|
|
492
|
+
options: {
|
|
493
|
+
defaultValue: []
|
|
475
494
|
}
|
|
476
|
-
}
|
|
477
|
-
|
|
495
|
+
}), // 基于基本功能提出基本预设
|
|
496
|
+
c(P, "placeholderPresetByComponentName", P.getPlaceholderPrefixPresetByComponentName());
|
|
497
|
+
let j = P;
|
|
498
|
+
const z = /* @__PURE__ */ L({
|
|
478
499
|
props: {
|
|
479
500
|
setup: {
|
|
480
501
|
type: Function,
|
|
481
502
|
required: !0
|
|
482
503
|
}
|
|
483
504
|
},
|
|
484
|
-
setup(
|
|
485
|
-
const e = new
|
|
505
|
+
setup(o) {
|
|
506
|
+
const e = new _(o.setup);
|
|
486
507
|
return () => e.exec();
|
|
487
508
|
}
|
|
488
509
|
});
|
|
489
|
-
function
|
|
490
|
-
const e = new
|
|
510
|
+
function F(o) {
|
|
511
|
+
const e = new N(o);
|
|
491
512
|
return [
|
|
492
513
|
e.setup.bind(e),
|
|
493
514
|
{
|
|
@@ -495,15 +516,15 @@ function K(c) {
|
|
|
495
516
|
}
|
|
496
517
|
];
|
|
497
518
|
}
|
|
498
|
-
function
|
|
519
|
+
function G(o) {
|
|
499
520
|
return {
|
|
500
521
|
install() {
|
|
501
|
-
|
|
522
|
+
h.runtimeDoms = o;
|
|
502
523
|
}
|
|
503
524
|
};
|
|
504
525
|
}
|
|
505
526
|
export {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
527
|
+
z as ProForm,
|
|
528
|
+
F as useForm,
|
|
529
|
+
G as useFormRenderer
|
|
509
530
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AnyObject, ItemSchema } from "../types";
|
|
2
|
+
export default class Preset {
|
|
3
|
+
static schemaPreset: Record<keyof ItemSchema, any> & {
|
|
4
|
+
children: any;
|
|
5
|
+
};
|
|
6
|
+
static componentPropsPreset: AnyObject;
|
|
7
|
+
static placeholderPresetByComponentName: {};
|
|
8
|
+
static getPlaceholderPrefixPresetByComponentName(): {};
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Ref } from "vue";
|
|
2
|
+
import { AnyObject, Schema, ProxyedSchema, AnyFunction, ObjectParserRoot } from "../types";
|
|
3
|
+
import { RuntimeCore } from ".";
|
|
4
|
+
import Effect from "./Effect";
|
|
5
|
+
/**
|
|
6
|
+
* 基本描述
|
|
7
|
+
* 对于函数的命名,如果是动词相关,代表对过程的处理,如果是名词,代表一个处理器
|
|
8
|
+
*/
|
|
9
|
+
export default class Processor {
|
|
10
|
+
processedSchemas: Ref<AnyObject[]>;
|
|
11
|
+
processedModel: Ref<AnyObject>;
|
|
12
|
+
getRuntimeMeta: AnyFunction;
|
|
13
|
+
stableSchemas: ProxyedSchema[];
|
|
14
|
+
stableModel: AnyObject;
|
|
15
|
+
schemaPreset: AnyObject;
|
|
16
|
+
componentPropsPreset: AnyObject;
|
|
17
|
+
stableUpdaterProcessProgress: boolean[];
|
|
18
|
+
stableUpdaterTimes: number;
|
|
19
|
+
schemaEffect: Effect;
|
|
20
|
+
defaultValueEffect: Effect;
|
|
21
|
+
defaultValueInprogressMap: Map<any, any>;
|
|
22
|
+
constructor(runtimeCore: RuntimeCore);
|
|
23
|
+
parse<T extends object = any>(data: T[], parentMeta?: AnyObject): void;
|
|
24
|
+
initSchemas(schemas: AnyObject[]): AnyObject[];
|
|
25
|
+
parseSchemas(schemas: ProxyedSchema[], parentMeta?: AnyObject): void;
|
|
26
|
+
parseStable(stable: AnyObject): AnyObject;
|
|
27
|
+
stableUpdater(parseProcess?: boolean[]): void;
|
|
28
|
+
parseItem(data: AnyObject, index: number, parentMeta?: AnyObject): void;
|
|
29
|
+
objectParser(root: ObjectParserRoot): void;
|
|
30
|
+
promiseFieldParser(rootField: any, updater: AnyFunction, deepProcess: boolean): void;
|
|
31
|
+
fieldParser(rootField: any, updater: AnyFunction, deepProcess?: boolean): void;
|
|
32
|
+
modelProcessor(schemas: Schema[]): void;
|
|
33
|
+
createModel(schema: AnyObject, baseModel: AnyObject): void;
|
|
34
|
+
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { Ref } from "vue";
|
|
2
|
-
import { Setup, Schema,
|
|
3
|
-
import
|
|
2
|
+
import { Setup, Schema, AnyObject, ItemSchema, GroupSchema, ListSchema, ProcessorBySchemaType } from "../types";
|
|
3
|
+
import Processor from "./Processor";
|
|
4
4
|
export default class RuntimeCore {
|
|
5
5
|
setup: Setup;
|
|
6
|
-
|
|
6
|
+
processor: Processor;
|
|
7
7
|
schemas: Ref<Schema[]>;
|
|
8
8
|
model: Ref<AnyObject>;
|
|
9
9
|
processorBySchemaType: ProcessorBySchemaType;
|
|
10
10
|
formRef: Ref<AnyObject>;
|
|
11
11
|
constructor(setup: Setup);
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
getRuntimeMeta(): {
|
|
13
|
+
model: AnyObject;
|
|
14
|
+
};
|
|
15
|
+
runtimeItemProcessor(schema: ItemSchema, index?: number, baseModel?: AnyObject, parentSchema?: ListSchema): JSX.Element | undefined;
|
|
14
16
|
runtimeGroupProcessor(schema: GroupSchema): JSX.Element;
|
|
15
17
|
addListItem(schema: AnyObject): Promise<never> | undefined;
|
|
16
18
|
deleteListItem(schema: AnyObject, index: number): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as FormCustomizer } from "./FormCustomizer";
|
|
2
2
|
export { default as RuntimeCore } from "./RuntimeCore";
|
|
3
3
|
export { default as Context } from "./Context";
|
|
4
|
-
export { default as Processors } from "./
|
|
5
|
-
export { default as
|
|
4
|
+
export { default as Processors } from "./Processor";
|
|
5
|
+
export { default as Preset } from "./Preset";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { GroupSchema, ItemSchema, ListSchema } from "../types";
|
|
1
|
+
import { AnyObject, GroupSchema, ItemSchema, ListSchema } from "../types";
|
|
2
2
|
export default class IS {
|
|
3
3
|
private static typeChecker;
|
|
4
4
|
static isArray(data: any): data is any[];
|
|
5
5
|
static isFunction(data: any): data is (...args: any) => any;
|
|
6
|
+
static isPromise(data: any): data is Promise<any>;
|
|
7
|
+
static isObject(data: any): data is AnyObject;
|
|
6
8
|
static isAsyncFunction(data: any): data is (...args: any) => Promise<any>;
|
|
7
9
|
static isUndefined(data: any): data is undefined;
|
|
8
10
|
static isArrayEmpty(data: any[]): boolean;
|
|
@@ -10,4 +12,5 @@ export default class IS {
|
|
|
10
12
|
static isListSchema(data: any): data is ListSchema;
|
|
11
13
|
static isGroupSchema(data: any): data is GroupSchema;
|
|
12
14
|
static isItemSchema(data: any): data is ItemSchema;
|
|
15
|
+
static isProcessInprogress(data: any): boolean;
|
|
13
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harbor-design/proform",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -19,16 +19,11 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"dist/"
|
|
23
|
-
"./LICENSE",
|
|
24
|
-
"./CHANGELOG.md"
|
|
22
|
+
"dist/"
|
|
25
23
|
],
|
|
26
24
|
"author": "yiwwhl<yiwwhl@qq.com>",
|
|
27
25
|
"license": "MIT",
|
|
28
26
|
"scripts": {
|
|
29
|
-
"build": "vue-tsc && vite build"
|
|
30
|
-
"prerelease": "pnpm build",
|
|
31
|
-
"release": "pnpm prerelease && changeset && pnpm postrelease",
|
|
32
|
-
"postrelease": "changeset version && changeset publish && git push --follow-tags"
|
|
27
|
+
"build": "vue-tsc && vite build"
|
|
33
28
|
}
|
|
34
29
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# @harbor-design/proform
|
|
2
|
-
|
|
3
|
-
## 1.0.5
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- update pack sourcecode
|
|
8
|
-
|
|
9
|
-
## 1.0.4
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- remove console
|
|
14
|
-
|
|
15
|
-
## 1.0.3
|
|
16
|
-
|
|
17
|
-
### Patch Changes
|
|
18
|
-
|
|
19
|
-
- fix error dist bug
|
|
20
|
-
|
|
21
|
-
## 1.0.2
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- fix bugs of list item add error
|
|
26
|
-
|
|
27
|
-
## 1.0.1
|
|
28
|
-
|
|
29
|
-
### Patch Changes
|
|
30
|
-
|
|
31
|
-
- ProForm Release 1.0.1
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Ref } from "vue";
|
|
2
|
-
import { AnyObject, Schema, ItemSchema, ProxyedSchema, AnyFunction } from "../types";
|
|
3
|
-
import { Effect } from "../services";
|
|
4
|
-
export default class Processors {
|
|
5
|
-
processedSchemas: Ref<Schema[]>;
|
|
6
|
-
processedModel: Ref<AnyObject>;
|
|
7
|
-
rawSchemas: ProxyedSchema[];
|
|
8
|
-
rawModel: AnyObject;
|
|
9
|
-
schemaPreset: Record<keyof ItemSchema, any>;
|
|
10
|
-
componentPropsPreset: AnyObject;
|
|
11
|
-
uniqueEffectMap: any;
|
|
12
|
-
schemaEffect: Effect;
|
|
13
|
-
modelEffect: Effect;
|
|
14
|
-
stopWatchEffect: Effect;
|
|
15
|
-
constructor(processedSchemas: Ref<Schema[]>, processedModel: Ref<AnyObject>);
|
|
16
|
-
schemaAnalyzer(schemas: ProxyedSchema[], baseSchema?: Schema[], baseRawSchema?: ProxyedSchema[], parentField?: string, schemaIndex?: number): void;
|
|
17
|
-
schemaProcessor(schema: ProxyedSchema, index: number, setter: AnyFunction, schemaIndex?: number, parentField?: string): void;
|
|
18
|
-
replaceFunctionsWithUndefined(obj: AnyObject): AnyObject;
|
|
19
|
-
runtimeMeta(): {
|
|
20
|
-
model: AnyObject;
|
|
21
|
-
};
|
|
22
|
-
propsProcessor<T extends object = any>(pendingProcess: T, preset: Record<keyof T, any>, processed: AnyObject, update: AnyFunction, schemaIndexOrChildrenIndex: number, schemaIndex?: number, parentField?: string): void;
|
|
23
|
-
modelProcessor(schema: ProxyedSchema, baseModel?: AnyObject): void;
|
|
24
|
-
}
|