@harbor-design/proform 1.0.18 → 1.0.20
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 +167 -131
- package/dist/types/src/services/Processor.d.ts +0 -1
- package/dist/types/src/services/RuntimeCore.d.ts +3 -1
- package/dist/types/src/types/formCustomizerTypes.d.ts +40 -0
- package/dist/types/src/utils/index.d.ts +1 -0
- package/dist/types/src/utils/replace.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _=Object.defineProperty;var L=(n,e,t)=>e in n?_(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var c=(n,e,t)=>(L(n,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue");class f{static typeChecker(e){return{}.toString.call(e)}static isString(e){return typeof e=="string"}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 d(n,...e){return e.forEach(t=>{if(Array.isArray(t))Array.isArray(n)||(n=[]),t.forEach((s,r)=>{typeof s=="object"&&s!==null?n[r]=d(Array.isArray(s)?[]:{},s):n[r]=s});else for(let s in t)t.hasOwnProperty(s)&&(typeof t[s]=="object"&&t[s]!==null?n[s]=d(n[s]||{},t[s]):n[s]=t[s])}),n}function y(n){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 i=new Map;for(let[l,a]of s)i.set(t(l),t(a));return i}if(s instanceof Set){const i=new Set;for(let l of s)i.add(t(l));return i}if(e.has(s))return e.get(s);if(Array.isArray(s)){const i=[];e.set(s,i);for(let l=0;l<s.length;l++)i[l]=t(s[l]);return i}const r=Object.create(Object.getPrototypeOf(s));e.set(s,r);for(let i in s)s.hasOwnProperty(i)&&(r[i]=t(s[i]));return r}return t(n)}class T{constructor(e){c(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(o.toRaw(this.runtimeCore.processor.processedModel.value))))})}hydrate(e){if(!this.runtimeCore)return Promise.reject({code:"0002",message:"hydrate 使用时机错误,建议将 hydrate 操作放到 onMounted 等页面节点挂载完成的钩子中,或者使用响应式的值来注入数据"});this.runtimeCore.hydrateEffect.trackEffect(()=>{o.isRef(e)?o.watch(()=>e.value,()=>{d(this.runtimeCore.model.value,e.value)},{deep:!0,immediate:!0}):o.isReactive(e)?o.watch(()=>e,()=>{d(this.runtimeCore.model.value,e)},{deep:!0,immediate:!0}):d(this.runtimeCore.model.value,e)},{lazy:!0})}customize(e){Object.assign(this.runtimeCore.customizedOptions,e)}}class I{constructor(){c(this,"effects",new Set)}clearEffects(){this.effects.clear()}triggerEffects(){Array.from(this.effects).forEach(e=>e())}trackEffect(e,t={lazy:!1}){return!t.lazy&&e(),this.effects.add(e),()=>this.effects.delete(e)}}class B{constructor(e){c(this,"runtimeCore");c(this,"processedSchemas");c(this,"processedModel");c(this,"getRuntimeMeta");c(this,"stableSchemas",[]);c(this,"stableModel",{});c(this,"schemaPreset",v.schemaPreset);c(this,"componentPropsPreset",v.componentPropsPreset);c(this,"stableUpdaterProcessProgress");c(this,"stableUpdaterTimes",0);c(this,"schemaEffect",new I);c(this,"defaultValueEffect",new I);c(this,"defaultValueInprogressMap",new Map);c(this,"baseDefaultValueFunctionsLength");this.runtimeCore=e,this.processedSchemas=e.schemas,this.processedModel=e.model,this.getRuntimeMeta=e.getRuntimeMeta.bind(e),o.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})}countFunctionDefaultValues(e){let t=0,s=new Set;function r(i){if(!s.has(i)&&(Array.isArray(i)||i!==null&&typeof i=="object")){s.add(i);for(let l in i)i.hasOwnProperty(l)&&(l==="defaultValue"&&typeof i[l]=="function"&&!i[l].toString().includes("[native code]")&&t++,r(i[l]))}}return r(e),t}parseSchemas(e,t){f.isArrayEmpty(this.processedSchemas.value)&&(this.baseDefaultValueFunctionsLength=this.countFunctionDefaultValues(y(e)),this.processedSchemas.value=this.initSchemas(e)),this.parse(e,t)}parseStable(e){const t={};if(!f.isUndefined(e.stable))t[e.key]=this.parseStable(e.stable);else return e;return t}stableUpdater(e=[]){if(e.every(Boolean)){const t=o.toRaw(this.processedSchemas.value);!f.isProcessInprogress(t)&&f.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,i=Array.from({length:Object.keys(e).filter(a=>a!=="children").length}).fill(!1);this.objectParser({data:e,index:t,updater:l});function l(a){const u=a.index,m=a.key,S=a.keyIndex;if(!a.stable)return;const E=r.parseStable(a.stable),P=s==null?void 0:s.index,j=s==null?void 0:s.key;let p=E;if(f.isProcessInprogress(p)||(i[S]=!0),s){let h=r.processedSchemas.value[P][j][u][m];h&&f.isObject(h)&&m!=="component"&&(p=d(h,p)),r.processedSchemas.value[P][j][u][m]=p,r.stableUpdater(i)}else{let h=r.processedSchemas.value[u][m];h&&f.isObject(h)&&(p=d(h,p)),r.processedSchemas.value[u][m]=p,r.stableUpdater(i)}}}objectParser(e){const t=e.data;Object.keys(t).forEach((r,i)=>{if(r==="children")this.parseSchemas(t[r],{...e,key:r,keyIndex:i});else{const l=a=>{e.updater({...e,key:r,keyIndex:i,stable:a})};f.isFunction(t[r])?r!=="defaultValue"?this.schemaEffect.trackEffect(()=>{if(r==="component"){const a=t[r](this.getRuntimeMeta());this.promiseFieldParser(a,l,!1)}else this.fieldParser(t[r],l)}):this.defaultValueEffect.trackEffect(()=>{const a=this.schemaEffect.trackEffect(()=>{/\{\s*model\s*\}/.test(t[r].toString())?this.fieldParser(t[r],u=>{if(!u)return l(u);this.defaultValueInprogressMap.set(t[r],u),!f.isProcessInprogress(u)&&this.defaultValueInprogressMap.size===this.baseDefaultValueFunctionsLength&&Array.from(this.defaultValueInprogressMap.values()).every(m=>!m.includes("undefined"))?(l(u),this.defaultValueEffect.clearEffects(),o.nextTick(()=>{a()})):l(u)}):this.fieldParser(t[r],u=>{this.defaultValueInprogressMap.set(t[r],u),!f.isProcessInprogress(u)&&this.defaultValueInprogressMap.size===this.baseDefaultValueFunctionsLength&&Array.from(this.defaultValueInprogressMap.values()).every(m=>!m.includes("undefined"))?(l(u),this.defaultValueEffect.clearEffects(),o.nextTick(()=>{a()})):l(u)})})}):r==="component"||r==="slots"?this.promiseFieldParser(t[r],l,!1):this.fieldParser(t[r],l)}})}replaceUndefinedInString(e,t){return e.replace(/undefined/g,t)}promiseFieldParser(e,t,s){f.isPromise(e)?e.then(r=>{s&&f.isObject(r)?this.objectParser({data:r,updater:t}):t(r)}):(f.isString(e)&&(e=this.replaceUndefinedInString(e,"")),s&&f.isObject(e)?this.objectParser({data:e,updater:t}):t(e))}fieldParser(e,t,s=!0){if(f.isFunction(e))if(e.name.startsWith("__proform_raw_"))t(e);else{const r=e(this.getRuntimeMeta());this.promiseFieldParser(r,t,s)}else o.isRef(e)?o.watch(()=>e.value,()=>{f.isUndefined(e.value)||(s&&f.isObject(e.value)?this.objectParser({data:e.value,updater:t}):t(e.value))},{immediate:!0,deep:!0}):o.isReactive(e)?o.watch(()=>e,()=>{f.isUndefined(e)||(s&&f.isObject(e)?this.objectParser({data:e,updater:t}):t(e))},{immediate:!0,deep:!0}):s&&f.isObject(e)?this.objectParser({data:e,updater:t}):t(e)}modelProcessor(e){e.map(t=>this.createModel(t,this.processedModel.value)),f.isObjectEmpty(this.stableModel)&&this.stableUpdaterProcessProgress.every(Boolean)&&this.defaultValueEffect.effects.size===0&&(this.stableModel=y(this.processedModel.value),this.runtimeCore.hydrateEffect.triggerEffects(),this.runtimeCore.hydrateEffect.clearEffects())}createModel(e,t){f.isListSchema(e)&&(t[e.field]||(t[e.field]=[{}]),e.children.forEach(s=>{this.createModel(s,t[e.field][0])})),f.isGroupSchema(e)&&e.children.forEach(s=>{this.createModel(s,t)}),f.isItemSchema(e)&&(t[e.field]=e.defaultValue)}}function q(n){return typeof n=="function"||Object.prototype.toString.call(n)==="[object Object]"&&!o.isVNode(n)}class ${constructor(e){c(this,"schemas",o.ref([]));c(this,"model",o.ref({}));c(this,"processorBySchemaType",{item:this.runtimeItemProcessor.bind(this),group:this.runtimeGroupProcessor.bind(this),list:this.runtimeListProcessor.bind(this)});c(this,"formRef",o.ref(null));c(this,"hydrateEffect",new I);c(this,"customizedOptions",o.reactive({}));c(this,"globalNativeFormOverride",{props:{},slots:{}});this.setup=e,this.processor=new B(this);const t=this.setup(this);this.processor.parseSchemas(t.schemas)}getRuntimeMeta(){return{model:o.toRaw(y(this.model.value))}}runtimeItemProcessor(e,t,s=this.model.value,r){var h,w,O,C,N,A,F,M,R,z,x,D,U;d(this.globalNativeFormOverride.props,(w=(h=e.native)==null?void 0:h.props)==null?void 0:w.Form),d(this.globalNativeFormOverride.slots,(C=(O=e.native)==null?void 0:O.slots)==null?void 0:C.Form);const i=d(y((A=(N=this.customizedOptions.native)==null?void 0:N.props)==null?void 0:A.FormItem)??{},(M=(F=e.native)==null?void 0:F.props)==null?void 0:M.FormItem),l=d(y((z=(R=this.customizedOptions.native)==null?void 0:R.slots)==null?void 0:z.FormItem)??{},(D=(x=e.native)==null?void 0:x.slots)==null?void 0:D.FormItem),a=r?`${r.field}.${t}.${e.field}`:e.field,u=o.toRaw(e.component);if(!u)return;const m=u.name,S=e.componentProps??{},E=v.placeholderPresetByComponentName;let P=e.placeholder;if(P||(P=`${E[m]??"请输入"}${e.label}`),e.required)if(!e.rules)e.rules=[],(U=e.rules)==null||U.push({required:!0,message:`${e.label}是必填项`});else{const V=e.rules.findIndex(k=>!!k.required);e.rules[V].message=`${e.label}是必填项`}let p=e.show;return p===void 0&&(p=!0),p||delete s[e.field],o.createVNode(b.runtimeDoms.Item,null,{default(){return o.withDirectives(o.createVNode(b.runtimeDoms.FormItem,o.mergeProps(i,{label:`${e.label}:`,rules:e.rules,field:a}),{default(){return o.createVNode(u,o.mergeProps({modelValue:s[e.field],"onUpdate:modelValue":V=>s[e.field]=V,placeholder:P},S),null)},...l}),[[o.vShow,p]])}})}runtimeGroupProcessor(e){let t;return o.createVNode(b.runtimeDoms.Group,{schema:e},q(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(y(this.processor.stableModel[e.field][0])),this.formRef.value.clearValidate()}deleteListItem(e,t){this.model.value[e.field].splice(t,1),this.formRef.value.clearValidate()}runtimeListProcessor(e){const t=this;return t.model.value[e.field]||(t.model.value[e.field]=[{}]),o.createVNode(b.runtimeDoms.List,{schema:e},{default(){return t.model.value[e.field].map((s,r)=>o.createVNode(b.runtimeDoms.ListItem,null,{default(){return e.children.map(i=>t.runtimeItemProcessor(i,r,s,e))},delete({container:i}={}){var a;let l=i??o.createVNode("button",null,null);return o.withDirectives(o.createVNode(l,{onClick:()=>t.deleteListItem(e,r)},null),[[o.vShow,((a=t.model.value[e.field])==null?void 0:a.length)>1]])}}))},add({container:s}={}){let r=s??o.createVNode("button",null,[o.createTextVNode("添加")]);return o.createVNode(r,{onClick:()=>t.addListItem(e)},null)}})}runtimeProcessor(e){return e.map(t=>(t.type||(t.type="item"),this.processorBySchemaType[t.type](t)))}exec(){var r,i,l,a;const e=this,t=d(y((i=(r=this.customizedOptions.native)==null?void 0:r.props)==null?void 0:i.Form)??{},this.globalNativeFormOverride.props),s=d(y((a=(l=this.customizedOptions.native)==null?void 0:l.slots)==null?void 0:a.Form)??{},this.globalNativeFormOverride.slots);return o.createVNode(b.runtimeDoms.Form,o.mergeProps(t,{ref:this.formRef,model:this.model.value}),{default(){return e.runtimeProcessor(e.schemas.value)},...s})}}class b{}c(b,"runtimeDoms");const g=class g{static getPlaceholderPrefixPresetByComponentName(){const e={请选择:["Select","Tree","TreeSelect"],请输入:["Input"]},t={};for(let s in e)e[s].forEach(r=>{t[r]=s});return t}};c(g,"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:[]},native:void 0}),c(g,"componentPropsPreset",{options:{defaultValue:[]}}),c(g,"placeholderPresetByComponentName",g.getPlaceholderPrefixPresetByComponentName());let v=g;const G=o.defineComponent({props:{setup:{type:Function,required:!0}},setup(n){const e=new $(n.setup);return()=>e.exec()}});function K(n){const e=new T(n);return[e.setup.bind(e),{submit:e.submit.bind(e),hydrate:e.hydrate.bind(e),customize:e.customize.bind(e)}]}function W(n){return{install(){b.runtimeDoms=n}}}function H(n,e){return e==="raw"&&Object.defineProperty(n,"name",{value:`__proform_raw_${n.name}`,writable:!0}),n}exports.ProForm=G;exports.useForm=K;exports.useFormRenderer=W;exports.useModifiers=H;
|
|
1
|
+
"use strict";var q=Object.defineProperty;var G=(n,e,t)=>e in n?q(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var c=(n,e,t)=>(G(n,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue");class a{static typeChecker(e){return{}.toString.call(e)}static isString(e){return typeof e=="string"}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 p(n,...e){return e.forEach(t=>{if(Array.isArray(t))Array.isArray(n)||(n=[]),t.forEach((s,r)=>{typeof s=="object"&&s!==null?n[r]=p(Array.isArray(s)?[]:{},s):n[r]=s});else for(let s in t)t.hasOwnProperty(s)&&(typeof t[s]=="object"&&t[s]!==null?n[s]=p(n[s]||{},t[s]):n[s]=t[s])}),n}function y(n){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 o=new Map;for(let[l,f]of s)o.set(t(l),t(f));return o}if(s instanceof Set){const o=new Set;for(let l of s)o.add(t(l));return o}if(e.has(s))return e.get(s);if(Array.isArray(s)){const o=[];e.set(s,o);for(let l=0;l<s.length;l++)o[l]=t(s[l]);return o}const r=Object.create(Object.getPrototypeOf(s));e.set(s,r);for(let o in s)s.hasOwnProperty(o)&&(r[o]=t(s[o]));return r}return t(n)}function $(n,e){return n.replace(/undefined/g,e)}class K{constructor(e){c(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,Object.assign(this.runtimeCore.runtimeSetters,this.formCustomization.runtimeSetters),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))))})}hydrate(e){if(!this.runtimeCore)return Promise.reject({code:"0002",message:"hydrate 使用时机错误,建议将 hydrate 操作放到 onMounted 等页面节点挂载完成的钩子中,或者使用响应式的值来注入数据"});this.runtimeCore.hydrateEffect.trackEffect(()=>{i.isRef(e)?i.watch(()=>e.value,()=>{p(this.runtimeCore.model.value,e.value)},{deep:!0,immediate:!0}):i.isReactive(e)?i.watch(()=>e,()=>{p(this.runtimeCore.model.value,e)},{deep:!0,immediate:!0}):p(this.runtimeCore.model.value,e)},{lazy:!0})}customize(e){Object.assign(this.runtimeCore.customizedOptions,e),Object.assign(this.runtimeCore.gridProps,this.formCustomization.gridProps)}}class w{constructor(){c(this,"effects",new Set)}clearEffects(){this.effects.clear()}triggerEffects(){Array.from(this.effects).forEach(e=>e())}trackEffect(e,t={lazy:!1}){return!t.lazy&&e(),this.effects.add(e),()=>this.effects.delete(e)}}class W{constructor(e){c(this,"runtimeCore");c(this,"processedSchemas");c(this,"processedModel");c(this,"getRuntimeMeta");c(this,"stableSchemas",[]);c(this,"stableModel",{});c(this,"schemaPreset",j.schemaPreset);c(this,"componentPropsPreset",j.componentPropsPreset);c(this,"stableUpdaterProcessProgress");c(this,"stableUpdaterTimes",0);c(this,"schemaEffect",new w);c(this,"defaultValueEffect",new w);c(this,"defaultValueInprogressMap",new Map);c(this,"baseDefaultValueFunctionsLength");this.runtimeCore=e,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})}countFunctionDefaultValues(e){let t=0,s=new Set;function r(o){if(!s.has(o)&&(Array.isArray(o)||o!==null&&typeof o=="object")){s.add(o);for(let l in o)o.hasOwnProperty(l)&&(l==="defaultValue"&&typeof o[l]=="function"&&!o[l].toString().includes("[native code]")&&t++,r(o[l]))}}return r(e),t}parseSchemas(e,t){a.isArrayEmpty(this.processedSchemas.value)&&(this.baseDefaultValueFunctionsLength=this.countFunctionDefaultValues(y(e)),this.processedSchemas.value=this.initSchemas(e)),this.parse(e,t)}parseStable(e){const t={};if(!a.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);!a.isProcessInprogress(t)&&a.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,o=Array.from({length:Object.keys(e).filter(f=>f!=="children").length}).fill(!1);this.objectParser({data:e,index:t,updater:l});function l(f){const u=f.index,d=f.key,E=f.keyIndex;if(!f.stable)return;const O=r.parseStable(f.stable),V=s==null?void 0:s.index,g=s==null?void 0:s.key;let h=O;if(a.isProcessInprogress(h)||(o[E]=!0),s){let m=r.processedSchemas.value[V][g][u][d];m&&a.isObject(m)&&d!=="component"&&(h=p(m,h)),r.processedSchemas.value[V][g][u][d]=h,r.stableUpdater(o)}else{let m=r.processedSchemas.value[u][d];m&&a.isObject(m)&&(h=p(m,h)),r.processedSchemas.value[u][d]=h,r.stableUpdater(o)}}}objectParser(e){const t=e.data;Object.keys(t).forEach((r,o)=>{if(r==="children")this.parseSchemas(t[r],{...e,key:r,keyIndex:o});else{const l=f=>{e.updater({...e,key:r,keyIndex:o,stable:f})};a.isFunction(t[r])?r!=="defaultValue"?this.schemaEffect.trackEffect(()=>{if(r==="component"){const f=t[r](this.getRuntimeMeta());this.promiseFieldParser(f,l,!1)}else this.fieldParser(t[r],l)}):this.defaultValueEffect.trackEffect(()=>{const f=this.schemaEffect.trackEffect(()=>{/\{\s*model\s*\}/.test(t[r].toString())?this.fieldParser(t[r],u=>{if(!u)return l(u);this.defaultValueInprogressMap.set(t[r],u),!a.isProcessInprogress(u)&&this.defaultValueInprogressMap.size===this.baseDefaultValueFunctionsLength&&Array.from(this.defaultValueInprogressMap.values()).every(d=>!d.includes("undefined"))?(l(u),this.defaultValueEffect.clearEffects(),i.nextTick(()=>{f()})):l(u)}):this.fieldParser(t[r],u=>{this.defaultValueInprogressMap.set(t[r],u),!a.isProcessInprogress(u)&&this.defaultValueInprogressMap.size===this.baseDefaultValueFunctionsLength&&Array.from(this.defaultValueInprogressMap.values()).every(d=>!d.includes("undefined"))?(l(u),this.defaultValueEffect.clearEffects(),i.nextTick(()=>{f()})):l(u)})})}):r==="component"||r==="slots"||r==="runtimeSetters"?this.promiseFieldParser(t[r],l,!1):this.fieldParser(t[r],l)}})}promiseFieldParser(e,t,s){a.isPromise(e)?e.then(r=>{s&&a.isObject(r)?this.objectParser({data:r,updater:t}):t(r)}):(a.isString(e)&&(e=$(e,"")),s&&a.isObject(e)?this.objectParser({data:e,updater:t}):t(e))}fieldParser(e,t,s=!0){if(a.isFunction(e))if(e.name.startsWith("__proform_raw_"))t(e);else{const r=e(this.getRuntimeMeta());this.promiseFieldParser(r,t,s)}else i.isRef(e)?i.watch(()=>e.value,()=>{a.isUndefined(e.value)||(s&&a.isObject(e.value)?this.objectParser({data:e.value,updater:t}):t(e.value))},{immediate:!0,deep:!0}):i.isReactive(e)?i.watch(()=>e,()=>{a.isUndefined(e)||(s&&a.isObject(e)?this.objectParser({data:e,updater:t}):t(e))},{immediate:!0,deep:!0}):s&&a.isObject(e)?this.objectParser({data:e,updater:t}):t(e)}modelProcessor(e){e.map(t=>this.createModel(t,this.processedModel.value)),a.isObjectEmpty(this.stableModel)&&this.stableUpdaterProcessProgress.every(Boolean)&&this.defaultValueEffect.effects.size===0&&(this.stableModel=y(this.processedModel.value),this.runtimeCore.hydrateEffect.triggerEffects(),this.runtimeCore.hydrateEffect.clearEffects())}createModel(e,t){a.isListSchema(e)&&(t[e.field]||(t[e.field]=[{}]),e.children.forEach(s=>{this.createModel(s,t[e.field][0])})),a.isGroupSchema(e)&&e.children.forEach(s=>{this.createModel(s,t)}),a.isItemSchema(e)&&(t[e.field]=e.defaultValue)}}function H(n){return typeof n=="function"||Object.prototype.toString.call(n)==="[object Object]"&&!i.isVNode(n)}class J{constructor(e){c(this,"schemas",i.ref([]));c(this,"model",i.ref({}));c(this,"processorBySchemaType",{item:this.runtimeItemProcessor.bind(this),group:this.runtimeGroupProcessor.bind(this),list:this.runtimeListProcessor.bind(this)});c(this,"formRef",i.ref(null));c(this,"hydrateEffect",new w);c(this,"customizedOptions",i.reactive({}));c(this,"gridProps",{});c(this,"runtimeSetters",{});c(this,"globalNativeFormOverride",{props:{},slots:{}});this.setup=e,this.processor=new W(this);const t=this.setup(this);this.processor.parseSchemas(t.schemas)}getRuntimeMeta(){return{model:i.toRaw(y(this.model.value))}}runtimeItemProcessor(e,t,s=this.model.value,r){var C,N,A,z,F,M,R,x,D,U,k,_,L,T;p(this.globalNativeFormOverride.props,(N=(C=e.native)==null?void 0:C.props)==null?void 0:N.Form),p(this.globalNativeFormOverride.slots,(z=(A=e.native)==null?void 0:A.slots)==null?void 0:z.Form);const o=p(y((M=(F=this.customizedOptions.native)==null?void 0:F.props)==null?void 0:M.FormItem)??{},(x=(R=e.native)==null?void 0:R.props)==null?void 0:x.FormItem),l=p(y((U=(D=this.customizedOptions.native)==null?void 0:D.slots)==null?void 0:U.FormItem)??{},(_=(k=e.native)==null?void 0:k.slots)==null?void 0:_.FormItem),f={display:"grid",gridColumn:"1 / -1",...e.gridProps},u=r?`${r.field}.${t}.${e.field}`:e.field,d=i.toRaw(e.component);if(!d)return;const E=d.name,O=e.componentProps??{},V=j.placeholderPresetByComponentName;let g=e.placeholder;if(e.required)if(!e.rules)e.rules=[],(L=e.rules)==null||L.push({required:!0,message:`${e.label}是必填项`});else{const S=e.rules.findIndex(B=>!!B.required);e.rules[S].message=`${e.label}是必填项`}let m=e.show;m===void 0&&(m=!0),m||delete s[e.field];let I=e.label;const P=(r==null?void 0:r.runtimeSetters)??this.runtimeSetters;return!a.isUndefined(t)&&P&&(I=$((T=P==null?void 0:P.listItemLabelSetter)==null?void 0:T.call(P,e.label,t+1),""),g=`${V[E]??"请输入"}${I}`),g||(g=`${V[E]??"请输入"}${I}`),i.createVNode("div",{style:f},[i.createVNode(b.runtimeDoms.Item,null,{default(){return i.withDirectives(i.createVNode(b.runtimeDoms.FormItem,i.mergeProps(o,{label:`${I}:`,rules:e.rules,field:u}),{default(){return i.createVNode(d,i.mergeProps({modelValue:s[e.field],"onUpdate:modelValue":S=>s[e.field]=S,placeholder:g},O),null)},...l}),[[i.vShow,m]])}})])}runtimeGroupProcessor(e){let t;const s={display:"grid",gridColumn:"1 / -1",...e.gridProps};return i.createVNode("div",{style:s},[i.createVNode(b.runtimeDoms.Group,{schema:e},H(t=e.children.map(r=>this.runtimeItemProcessor(r)))?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(y(this.processor.stableModel[e.field][0])),this.formRef.value.clearValidate()}deleteListItem(e,t){this.model.value[e.field].splice(t,1),this.formRef.value.clearValidate()}runtimeListProcessor(e){const t={display:"grid",gridColumn:"1 / -1",...e.gridProps},s=this;return s.model.value[e.field]||(s.model.value[e.field]=[{}]),i.createVNode("div",{style:t},[i.createVNode(b.runtimeDoms.List,{schema:e},{default(){return s.model.value[e.field].map((r,o)=>i.createVNode(b.runtimeDoms.ListItem,null,{default(){return e.children.map(l=>s.runtimeItemProcessor(l,o,r,e))},delete({container:l}={}){var u;let f=l??i.createVNode("button",null,null);return i.withDirectives(i.createVNode(f,{onClick:()=>s.deleteListItem(e,o)},null),[[i.vShow,((u=s.model.value[e.field])==null?void 0:u.length)>1]])}}))},add({container:r}={}){let o=r??i.createVNode("button",null,[i.createTextVNode("添加")]);return i.createVNode(o,{onClick:()=>s.addListItem(e)},null)}})])}runtimeProcessor(e){return e.map(t=>(t.type||(t.type="item"),this.processorBySchemaType[t.type](t)))}exec(){var o,l,f,u;const e={display:"grid",gridColumn:"1 / -1",gridAutoColumns:"1fr",...this.gridProps},t=this,s=p(y((l=(o=this.customizedOptions.native)==null?void 0:o.props)==null?void 0:l.Form)??{},this.globalNativeFormOverride.props),r=p(y((u=(f=this.customizedOptions.native)==null?void 0:f.slots)==null?void 0:u.Form)??{},this.globalNativeFormOverride.slots);return i.createVNode(b.runtimeDoms.Form,i.mergeProps(s,{ref:this.formRef,model:this.model.value}),{default(){return i.createVNode("div",{style:e},[t.runtimeProcessor(t.schemas.value)])},...r})}}class b{}c(b,"runtimeDoms");const v=class v{static getPlaceholderPrefixPresetByComponentName(){const e={请选择:["Select","Tree","TreeSelect"],请输入:["Input"]},t={};for(let s in e)e[s].forEach(r=>{t[r]=s});return t}};c(v,"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:[]},native:void 0,gridProps:void 0}),c(v,"componentPropsPreset",{options:{defaultValue:[]}}),c(v,"placeholderPresetByComponentName",v.getPlaceholderPrefixPresetByComponentName());let j=v;const Q=i.defineComponent({props:{setup:{type:Function,required:!0}},setup(n){const e=new J(n.setup);return()=>e.exec()}});function X(n){const e=new K(n);return[e.setup.bind(e),{submit:e.submit.bind(e),hydrate:e.hydrate.bind(e),customize:e.customize.bind(e)}]}function Y(n){return{install(){b.runtimeDoms=n}}}function Z(n,e){return e==="raw"&&Object.defineProperty(n,"name",{value:`__proform_raw_${n.name}`,writable:!0}),n}exports.ProForm=Q;exports.useForm=X;exports.useFormRenderer=Y;exports.useModifiers=Z;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var l = (o, e, t) => (
|
|
4
|
-
import { toRaw as
|
|
5
|
-
class
|
|
1
|
+
var Z = Object.defineProperty;
|
|
2
|
+
var ee = (o, e, t) => e in o ? Z(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var l = (o, e, t) => (ee(o, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { toRaw as V, isRef as J, watch as E, isReactive as Q, nextTick as K, ref as A, reactive as te, createVNode as a, withDirectives as W, mergeProps as z, vShow as H, createTextVNode as se, isVNode as re, defineComponent as ie } from "vue";
|
|
5
|
+
class u {
|
|
6
6
|
static typeChecker(e) {
|
|
7
7
|
return {}.toString.call(e);
|
|
8
8
|
}
|
|
@@ -63,15 +63,15 @@ class a {
|
|
|
63
63
|
return !1;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function p(o, ...e) {
|
|
67
67
|
return e.forEach((t) => {
|
|
68
68
|
if (Array.isArray(t))
|
|
69
69
|
Array.isArray(o) || (o = []), t.forEach((s, r) => {
|
|
70
|
-
typeof s == "object" && s !== null ? o[r] =
|
|
70
|
+
typeof s == "object" && s !== null ? o[r] = p(Array.isArray(s) ? [] : {}, s) : o[r] = s;
|
|
71
71
|
});
|
|
72
72
|
else
|
|
73
73
|
for (let s in t)
|
|
74
|
-
t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ? o[s] =
|
|
74
|
+
t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ? o[s] = p(o[s] || {}, t[s]) : o[s] = t[s]);
|
|
75
75
|
}), o;
|
|
76
76
|
}
|
|
77
77
|
function y(o) {
|
|
@@ -112,7 +112,10 @@ function y(o) {
|
|
|
112
112
|
}
|
|
113
113
|
return t(o);
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
function X(o, e) {
|
|
116
|
+
return o.replace(/undefined/g, e);
|
|
117
|
+
}
|
|
118
|
+
class oe {
|
|
116
119
|
constructor(e) {
|
|
117
120
|
l(this, "runtimeCore");
|
|
118
121
|
this.formCustomization = e;
|
|
@@ -124,13 +127,16 @@ class ee {
|
|
|
124
127
|
})), e;
|
|
125
128
|
}
|
|
126
129
|
setup(e) {
|
|
127
|
-
return this.runtimeCore = e,
|
|
130
|
+
return this.runtimeCore = e, Object.assign(
|
|
131
|
+
this.runtimeCore.runtimeSetters,
|
|
132
|
+
this.formCustomization.runtimeSetters
|
|
133
|
+
), this.formCustomization;
|
|
128
134
|
}
|
|
129
135
|
submit() {
|
|
130
136
|
return new Promise((e, t) => {
|
|
131
137
|
this.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(
|
|
132
138
|
this.cleanFallbackFields(
|
|
133
|
-
|
|
139
|
+
V(this.runtimeCore.processor.processedModel.value)
|
|
134
140
|
)
|
|
135
141
|
));
|
|
136
142
|
});
|
|
@@ -143,25 +149,25 @@ class ee {
|
|
|
143
149
|
});
|
|
144
150
|
this.runtimeCore.hydrateEffect.trackEffect(
|
|
145
151
|
() => {
|
|
146
|
-
|
|
152
|
+
J(e) ? E(
|
|
147
153
|
() => e.value,
|
|
148
154
|
() => {
|
|
149
|
-
|
|
155
|
+
p(this.runtimeCore.model.value, e.value);
|
|
150
156
|
},
|
|
151
157
|
{
|
|
152
158
|
deep: !0,
|
|
153
159
|
immediate: !0
|
|
154
160
|
}
|
|
155
|
-
) :
|
|
161
|
+
) : Q(e) ? E(
|
|
156
162
|
() => e,
|
|
157
163
|
() => {
|
|
158
|
-
|
|
164
|
+
p(this.runtimeCore.model.value, e);
|
|
159
165
|
},
|
|
160
166
|
{
|
|
161
167
|
deep: !0,
|
|
162
168
|
immediate: !0
|
|
163
169
|
}
|
|
164
|
-
) :
|
|
170
|
+
) : p(this.runtimeCore.model.value, e);
|
|
165
171
|
},
|
|
166
172
|
{
|
|
167
173
|
lazy: !0
|
|
@@ -170,10 +176,10 @@ class ee {
|
|
|
170
176
|
}
|
|
171
177
|
// TODO:目前仅用于配制一些基本的如 Form,FormItem 等 UI 库组件的默认属性,但后续会扩展其价值,包括设置统一布局等,都会考虑往内部封装
|
|
172
178
|
customize(e) {
|
|
173
|
-
Object.assign(this.runtimeCore.customizedOptions, e);
|
|
179
|
+
Object.assign(this.runtimeCore.customizedOptions, e), Object.assign(this.runtimeCore.gridProps, this.formCustomization.gridProps);
|
|
174
180
|
}
|
|
175
181
|
}
|
|
176
|
-
class
|
|
182
|
+
class F {
|
|
177
183
|
constructor() {
|
|
178
184
|
l(this, "effects", /* @__PURE__ */ new Set());
|
|
179
185
|
}
|
|
@@ -189,7 +195,7 @@ class A {
|
|
|
189
195
|
return !t.lazy && e(), this.effects.add(e), () => this.effects.delete(e);
|
|
190
196
|
}
|
|
191
197
|
}
|
|
192
|
-
class
|
|
198
|
+
class ne {
|
|
193
199
|
constructor(e) {
|
|
194
200
|
l(this, "runtimeCore");
|
|
195
201
|
l(this, "processedSchemas");
|
|
@@ -197,15 +203,15 @@ class te {
|
|
|
197
203
|
l(this, "getRuntimeMeta");
|
|
198
204
|
l(this, "stableSchemas", []);
|
|
199
205
|
l(this, "stableModel", {});
|
|
200
|
-
l(this, "schemaPreset",
|
|
201
|
-
l(this, "componentPropsPreset",
|
|
206
|
+
l(this, "schemaPreset", I.schemaPreset);
|
|
207
|
+
l(this, "componentPropsPreset", I.componentPropsPreset);
|
|
202
208
|
l(this, "stableUpdaterProcessProgress");
|
|
203
209
|
l(this, "stableUpdaterTimes", 0);
|
|
204
|
-
l(this, "schemaEffect", new
|
|
205
|
-
l(this, "defaultValueEffect", new
|
|
210
|
+
l(this, "schemaEffect", new F());
|
|
211
|
+
l(this, "defaultValueEffect", new F());
|
|
206
212
|
l(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
|
|
207
213
|
l(this, "baseDefaultValueFunctionsLength");
|
|
208
|
-
this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e),
|
|
214
|
+
this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), E(
|
|
209
215
|
() => this.processedModel.value,
|
|
210
216
|
() => {
|
|
211
217
|
this.schemaEffect.triggerEffects();
|
|
@@ -241,13 +247,13 @@ class te {
|
|
|
241
247
|
}
|
|
242
248
|
// 派生过程,用于外部应用
|
|
243
249
|
parseSchemas(e, t) {
|
|
244
|
-
|
|
250
|
+
u.isArrayEmpty(this.processedSchemas.value) && (this.baseDefaultValueFunctionsLength = this.countFunctionDefaultValues(
|
|
245
251
|
y(e)
|
|
246
252
|
), this.processedSchemas.value = this.initSchemas(e)), this.parse(e, t);
|
|
247
253
|
}
|
|
248
254
|
parseStable(e) {
|
|
249
255
|
const t = {};
|
|
250
|
-
if (!
|
|
256
|
+
if (!u.isUndefined(e.stable))
|
|
251
257
|
t[e.key] = this.parseStable(e.stable);
|
|
252
258
|
else
|
|
253
259
|
return e;
|
|
@@ -256,8 +262,8 @@ class te {
|
|
|
256
262
|
// 对于稳定初始化更新的抽象
|
|
257
263
|
stableUpdater(e = []) {
|
|
258
264
|
if (e.every(Boolean)) {
|
|
259
|
-
const t =
|
|
260
|
-
!
|
|
265
|
+
const t = V(this.processedSchemas.value);
|
|
266
|
+
!u.isProcessInprogress(t) && u.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
|
|
261
267
|
length: t.length
|
|
262
268
|
}).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
|
|
263
269
|
}
|
|
@@ -269,17 +275,17 @@ class te {
|
|
|
269
275
|
}).fill(!1);
|
|
270
276
|
this.objectParser({ data: e, index: t, updater: n });
|
|
271
277
|
function n(c) {
|
|
272
|
-
const f = c.index,
|
|
278
|
+
const f = c.index, d = c.key, O = c.keyIndex;
|
|
273
279
|
if (!c.stable)
|
|
274
280
|
return;
|
|
275
|
-
const
|
|
276
|
-
let
|
|
277
|
-
if (
|
|
278
|
-
let
|
|
279
|
-
|
|
281
|
+
const w = r.parseStable(c.stable), S = s == null ? void 0 : s.index, g = s == null ? void 0 : s.key;
|
|
282
|
+
let h = w;
|
|
283
|
+
if (u.isProcessInprogress(h) || (i[O] = !0), s) {
|
|
284
|
+
let m = r.processedSchemas.value[S][g][f][d];
|
|
285
|
+
m && u.isObject(m) && d !== "component" && (h = p(m, h)), r.processedSchemas.value[S][g][f][d] = h, r.stableUpdater(i);
|
|
280
286
|
} else {
|
|
281
|
-
let
|
|
282
|
-
|
|
287
|
+
let m = r.processedSchemas.value[f][d];
|
|
288
|
+
m && u.isObject(m) && (h = p(m, h)), r.processedSchemas.value[f][d] = h, r.stableUpdater(i);
|
|
283
289
|
}
|
|
284
290
|
}
|
|
285
291
|
}
|
|
@@ -302,7 +308,7 @@ class te {
|
|
|
302
308
|
stable: c
|
|
303
309
|
});
|
|
304
310
|
};
|
|
305
|
-
|
|
311
|
+
u.isFunction(t[r]) ? r !== "defaultValue" ? this.schemaEffect.trackEffect(() => {
|
|
306
312
|
if (r === "component") {
|
|
307
313
|
const c = t[r](this.getRuntimeMeta());
|
|
308
314
|
this.promiseFieldParser(c, n, !1);
|
|
@@ -313,40 +319,37 @@ class te {
|
|
|
313
319
|
/\{\s*model\s*\}/.test(t[r].toString()) ? this.fieldParser(t[r], (f) => {
|
|
314
320
|
if (!f)
|
|
315
321
|
return n(f);
|
|
316
|
-
this.defaultValueInprogressMap.set(t[r], f), !
|
|
317
|
-
(
|
|
318
|
-
) ? (n(f), this.defaultValueEffect.clearEffects(),
|
|
322
|
+
this.defaultValueInprogressMap.set(t[r], f), !u.isProcessInprogress(f) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(this.defaultValueInprogressMap.values()).every(
|
|
323
|
+
(d) => !d.includes("undefined")
|
|
324
|
+
) ? (n(f), this.defaultValueEffect.clearEffects(), K(() => {
|
|
319
325
|
c();
|
|
320
326
|
})) : n(f);
|
|
321
327
|
}) : this.fieldParser(t[r], (f) => {
|
|
322
|
-
this.defaultValueInprogressMap.set(t[r], f), !
|
|
323
|
-
(
|
|
324
|
-
) ? (n(f), this.defaultValueEffect.clearEffects(),
|
|
328
|
+
this.defaultValueInprogressMap.set(t[r], f), !u.isProcessInprogress(f) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(this.defaultValueInprogressMap.values()).every(
|
|
329
|
+
(d) => !d.includes("undefined")
|
|
330
|
+
) ? (n(f), this.defaultValueEffect.clearEffects(), K(() => {
|
|
325
331
|
c();
|
|
326
332
|
})) : n(f);
|
|
327
333
|
});
|
|
328
334
|
});
|
|
329
|
-
}) : r === "component" || r === "slots" ? this.promiseFieldParser(t[r], n, !1) : this.fieldParser(t[r], n);
|
|
335
|
+
}) : r === "component" || r === "slots" || r === "runtimeSetters" ? this.promiseFieldParser(t[r], n, !1) : this.fieldParser(t[r], n);
|
|
330
336
|
}
|
|
331
337
|
});
|
|
332
338
|
}
|
|
333
|
-
replaceUndefinedInString(e, t) {
|
|
334
|
-
return e.replace(/undefined/g, t);
|
|
335
|
-
}
|
|
336
339
|
promiseFieldParser(e, t, s) {
|
|
337
|
-
|
|
338
|
-
s &&
|
|
340
|
+
u.isPromise(e) ? e.then((r) => {
|
|
341
|
+
s && u.isObject(r) ? this.objectParser({
|
|
339
342
|
data: r,
|
|
340
343
|
updater: t
|
|
341
344
|
}) : t(r);
|
|
342
|
-
}) : (
|
|
345
|
+
}) : (u.isString(e) && (e = X(e, "")), s && u.isObject(e) ? this.objectParser({
|
|
343
346
|
data: e,
|
|
344
347
|
updater: t
|
|
345
348
|
}) : t(e));
|
|
346
349
|
}
|
|
347
350
|
// 对任意对象中单个字段的 parse: 做基本处理
|
|
348
351
|
fieldParser(e, t, s = !0) {
|
|
349
|
-
if (
|
|
352
|
+
if (u.isFunction(e))
|
|
350
353
|
if (e.name.startsWith("__proform_raw_"))
|
|
351
354
|
t(e);
|
|
352
355
|
else {
|
|
@@ -354,10 +357,10 @@ class te {
|
|
|
354
357
|
this.promiseFieldParser(r, t, s);
|
|
355
358
|
}
|
|
356
359
|
else
|
|
357
|
-
|
|
360
|
+
J(e) ? E(
|
|
358
361
|
() => e.value,
|
|
359
362
|
() => {
|
|
360
|
-
|
|
363
|
+
u.isUndefined(e.value) || (s && u.isObject(e.value) ? this.objectParser({
|
|
361
364
|
data: e.value,
|
|
362
365
|
updater: t
|
|
363
366
|
}) : t(e.value));
|
|
@@ -366,10 +369,10 @@ class te {
|
|
|
366
369
|
immediate: !0,
|
|
367
370
|
deep: !0
|
|
368
371
|
}
|
|
369
|
-
) :
|
|
372
|
+
) : Q(e) ? E(
|
|
370
373
|
() => e,
|
|
371
374
|
() => {
|
|
372
|
-
|
|
375
|
+
u.isUndefined(e) || (s && u.isObject(e) ? this.objectParser({
|
|
373
376
|
data: e,
|
|
374
377
|
updater: t
|
|
375
378
|
}) : t(e));
|
|
@@ -378,7 +381,7 @@ class te {
|
|
|
378
381
|
immediate: !0,
|
|
379
382
|
deep: !0
|
|
380
383
|
}
|
|
381
|
-
) : s &&
|
|
384
|
+
) : s && u.isObject(e) ? this.objectParser({
|
|
382
385
|
data: e,
|
|
383
386
|
updater: t
|
|
384
387
|
}) : t(e);
|
|
@@ -386,90 +389,109 @@ class te {
|
|
|
386
389
|
modelProcessor(e) {
|
|
387
390
|
e.map(
|
|
388
391
|
(t) => this.createModel(t, this.processedModel.value)
|
|
389
|
-
),
|
|
392
|
+
), u.isObjectEmpty(this.stableModel) && this.stableUpdaterProcessProgress.every(Boolean) && this.defaultValueEffect.effects.size === 0 && (this.stableModel = y(this.processedModel.value), this.runtimeCore.hydrateEffect.triggerEffects(), this.runtimeCore.hydrateEffect.clearEffects());
|
|
390
393
|
}
|
|
391
394
|
createModel(e, t) {
|
|
392
|
-
|
|
395
|
+
u.isListSchema(e) && (t[e.field] || (t[e.field] = [{}]), e.children.forEach((s) => {
|
|
393
396
|
this.createModel(s, t[e.field][0]);
|
|
394
|
-
})),
|
|
397
|
+
})), u.isGroupSchema(e) && e.children.forEach((s) => {
|
|
395
398
|
this.createModel(s, t);
|
|
396
|
-
}),
|
|
399
|
+
}), u.isItemSchema(e) && (t[e.field] = e.defaultValue);
|
|
397
400
|
}
|
|
398
401
|
}
|
|
399
|
-
function
|
|
400
|
-
return typeof o == "function" || Object.prototype.toString.call(o) === "[object Object]" && !
|
|
402
|
+
function le(o) {
|
|
403
|
+
return typeof o == "function" || Object.prototype.toString.call(o) === "[object Object]" && !re(o);
|
|
401
404
|
}
|
|
402
|
-
class
|
|
405
|
+
class ue {
|
|
403
406
|
constructor(e) {
|
|
404
|
-
l(this, "schemas",
|
|
405
|
-
l(this, "model",
|
|
407
|
+
l(this, "schemas", A([]));
|
|
408
|
+
l(this, "model", A({}));
|
|
406
409
|
l(this, "processorBySchemaType", {
|
|
407
410
|
item: this.runtimeItemProcessor.bind(this),
|
|
408
411
|
group: this.runtimeGroupProcessor.bind(this),
|
|
409
412
|
list: this.runtimeListProcessor.bind(this)
|
|
410
413
|
});
|
|
411
|
-
l(this, "formRef",
|
|
412
|
-
l(this, "hydrateEffect", new
|
|
413
|
-
l(this, "customizedOptions",
|
|
414
|
+
l(this, "formRef", A(null));
|
|
415
|
+
l(this, "hydrateEffect", new F());
|
|
416
|
+
l(this, "customizedOptions", te({}));
|
|
417
|
+
l(this, "gridProps", {});
|
|
418
|
+
l(this, "runtimeSetters", {});
|
|
414
419
|
l(this, "globalNativeFormOverride", {
|
|
415
420
|
props: {},
|
|
416
421
|
slots: {}
|
|
417
422
|
});
|
|
418
|
-
this.setup = e, this.processor = new
|
|
423
|
+
this.setup = e, this.processor = new ne(this);
|
|
419
424
|
const t = this.setup(this);
|
|
420
425
|
this.processor.parseSchemas(t.schemas);
|
|
421
426
|
}
|
|
422
427
|
getRuntimeMeta() {
|
|
423
428
|
return {
|
|
424
|
-
model:
|
|
429
|
+
model: V(y(this.model.value))
|
|
425
430
|
};
|
|
426
431
|
}
|
|
427
432
|
runtimeItemProcessor(e, t, s = this.model.value, r) {
|
|
428
|
-
var
|
|
429
|
-
|
|
430
|
-
const i =
|
|
431
|
-
|
|
433
|
+
var M, x, U, D, N, R, _, k, L, $, B, T, q, G;
|
|
434
|
+
p(this.globalNativeFormOverride.props, (x = (M = e.native) == null ? void 0 : M.props) == null ? void 0 : x.Form), p(this.globalNativeFormOverride.slots, (D = (U = e.native) == null ? void 0 : U.slots) == null ? void 0 : D.Form);
|
|
435
|
+
const i = p(y((R = (N = this.customizedOptions.native) == null ? void 0 : N.props) == null ? void 0 : R.FormItem) ?? {}, (k = (_ = e.native) == null ? void 0 : _.props) == null ? void 0 : k.FormItem), n = p(y(($ = (L = this.customizedOptions.native) == null ? void 0 : L.slots) == null ? void 0 : $.FormItem) ?? {}, (T = (B = e.native) == null ? void 0 : B.slots) == null ? void 0 : T.FormItem), c = {
|
|
436
|
+
display: "grid",
|
|
437
|
+
gridColumn: "1 / -1",
|
|
438
|
+
...e.gridProps
|
|
439
|
+
}, f = r ? `${r.field}.${t}.${e.field}` : e.field, d = V(e.component);
|
|
440
|
+
if (!d)
|
|
432
441
|
return;
|
|
433
|
-
const
|
|
434
|
-
let
|
|
435
|
-
if (
|
|
436
|
-
V[p] ?? "请输入"}${e.label}`), e.required)
|
|
442
|
+
const O = d.name, w = e.componentProps ?? {}, S = I.placeholderPresetByComponentName;
|
|
443
|
+
let g = e.placeholder;
|
|
444
|
+
if (e.required)
|
|
437
445
|
if (!e.rules)
|
|
438
|
-
e.rules = [], (
|
|
446
|
+
e.rules = [], (q = e.rules) == null || q.push({
|
|
439
447
|
required: !0,
|
|
440
448
|
message: `${e.label}是必填项`
|
|
441
449
|
});
|
|
442
450
|
else {
|
|
443
|
-
const
|
|
444
|
-
e.rules[
|
|
451
|
+
const j = e.rules.findIndex((Y) => !!Y.required);
|
|
452
|
+
e.rules[j].message = `${e.label}是必填项`;
|
|
445
453
|
}
|
|
446
|
-
let
|
|
447
|
-
|
|
454
|
+
let m = e.show;
|
|
455
|
+
m === void 0 && (m = !0), m || delete s[e.field];
|
|
456
|
+
let C = e.label;
|
|
457
|
+
const P = (r == null ? void 0 : r.runtimeSetters) ?? this.runtimeSetters;
|
|
458
|
+
return !u.isUndefined(t) && P && (C = X((G = P == null ? void 0 : P.listItemLabelSetter) == null ? void 0 : G.call(P, e.label, t + 1), ""), g = `${// @ts-expect-error
|
|
459
|
+
S[O] ?? "请输入"}${C}`), g || (g = `${// @ts-expect-error
|
|
460
|
+
S[O] ?? "请输入"}${C}`), a("div", {
|
|
461
|
+
style: c
|
|
462
|
+
}, [a(b.runtimeDoms.Item, null, {
|
|
448
463
|
default() {
|
|
449
|
-
return
|
|
450
|
-
label: `${
|
|
464
|
+
return W(a(b.runtimeDoms.FormItem, z(i, {
|
|
465
|
+
label: `${C}:`,
|
|
451
466
|
rules: e.rules,
|
|
452
|
-
field:
|
|
467
|
+
field: f
|
|
453
468
|
}), {
|
|
454
469
|
default() {
|
|
455
|
-
return
|
|
470
|
+
return a(d, z({
|
|
456
471
|
modelValue: s[e.field],
|
|
457
|
-
"onUpdate:modelValue": (
|
|
458
|
-
placeholder:
|
|
459
|
-
},
|
|
472
|
+
"onUpdate:modelValue": (j) => s[e.field] = j,
|
|
473
|
+
placeholder: g
|
|
474
|
+
}, w), null);
|
|
460
475
|
},
|
|
461
476
|
...n
|
|
462
|
-
}), [[
|
|
477
|
+
}), [[H, m]]);
|
|
463
478
|
}
|
|
464
|
-
});
|
|
479
|
+
})]);
|
|
465
480
|
}
|
|
466
481
|
runtimeGroupProcessor(e) {
|
|
467
482
|
let t;
|
|
468
|
-
|
|
483
|
+
const s = {
|
|
484
|
+
display: "grid",
|
|
485
|
+
gridColumn: "1 / -1",
|
|
486
|
+
...e.gridProps
|
|
487
|
+
};
|
|
488
|
+
return a("div", {
|
|
489
|
+
style: s
|
|
490
|
+
}, [a(b.runtimeDoms.Group, {
|
|
469
491
|
schema: e
|
|
470
|
-
},
|
|
492
|
+
}, le(t = e.children.map((r) => this.runtimeItemProcessor(r))) ? t : {
|
|
471
493
|
default: () => [t]
|
|
472
|
-
});
|
|
494
|
+
})]);
|
|
473
495
|
}
|
|
474
496
|
addListItem(e) {
|
|
475
497
|
var t, s;
|
|
@@ -484,57 +506,70 @@ class re {
|
|
|
484
506
|
this.model.value[e.field].splice(t, 1), this.formRef.value.clearValidate();
|
|
485
507
|
}
|
|
486
508
|
runtimeListProcessor(e) {
|
|
487
|
-
const t =
|
|
488
|
-
|
|
509
|
+
const t = {
|
|
510
|
+
display: "grid",
|
|
511
|
+
gridColumn: "1 / -1",
|
|
512
|
+
...e.gridProps
|
|
513
|
+
}, s = this;
|
|
514
|
+
return s.model.value[e.field] || (s.model.value[e.field] = [{}]), a("div", {
|
|
515
|
+
style: t
|
|
516
|
+
}, [a(b.runtimeDoms.List, {
|
|
489
517
|
schema: e
|
|
490
518
|
}, {
|
|
491
519
|
default() {
|
|
492
|
-
return
|
|
520
|
+
return s.model.value[e.field].map((r, i) => a(b.runtimeDoms.ListItem, null, {
|
|
493
521
|
default() {
|
|
494
|
-
return e.children.map((
|
|
522
|
+
return e.children.map((n) => s.runtimeItemProcessor(n, i, r, e));
|
|
495
523
|
},
|
|
496
524
|
delete({
|
|
497
|
-
container:
|
|
525
|
+
container: n
|
|
498
526
|
} = {}) {
|
|
499
|
-
var
|
|
500
|
-
let
|
|
501
|
-
return
|
|
502
|
-
onClick: () =>
|
|
503
|
-
}, null), [[
|
|
527
|
+
var f;
|
|
528
|
+
let c = n ?? a("button", null, null);
|
|
529
|
+
return W(a(c, {
|
|
530
|
+
onClick: () => s.deleteListItem(e, i)
|
|
531
|
+
}, null), [[H, ((f = s.model.value[e.field]) == null ? void 0 : f.length) > 1]]);
|
|
504
532
|
}
|
|
505
533
|
}));
|
|
506
534
|
},
|
|
507
535
|
add({
|
|
508
|
-
container:
|
|
536
|
+
container: r
|
|
509
537
|
} = {}) {
|
|
510
|
-
let
|
|
511
|
-
return
|
|
512
|
-
onClick: () =>
|
|
538
|
+
let i = r ?? a("button", null, [se("添加")]);
|
|
539
|
+
return a(i, {
|
|
540
|
+
onClick: () => s.addListItem(e)
|
|
513
541
|
}, null);
|
|
514
542
|
}
|
|
515
|
-
});
|
|
543
|
+
})]);
|
|
516
544
|
}
|
|
517
545
|
runtimeProcessor(e) {
|
|
518
546
|
return e.map((t) => (t.type || (t.type = "item"), this.processorBySchemaType[t.type](t)));
|
|
519
547
|
}
|
|
520
548
|
exec() {
|
|
521
|
-
var
|
|
522
|
-
const e =
|
|
523
|
-
|
|
549
|
+
var i, n, c, f;
|
|
550
|
+
const e = {
|
|
551
|
+
display: "grid",
|
|
552
|
+
gridColumn: "1 / -1",
|
|
553
|
+
gridAutoColumns: "1fr",
|
|
554
|
+
...this.gridProps
|
|
555
|
+
}, t = this, s = p(y((n = (i = this.customizedOptions.native) == null ? void 0 : i.props) == null ? void 0 : n.Form) ?? {}, this.globalNativeFormOverride.props), r = p(y((f = (c = this.customizedOptions.native) == null ? void 0 : c.slots) == null ? void 0 : f.Form) ?? {}, this.globalNativeFormOverride.slots);
|
|
556
|
+
return a(b.runtimeDoms.Form, z(s, {
|
|
524
557
|
ref: this.formRef,
|
|
525
558
|
model: this.model.value
|
|
526
559
|
}), {
|
|
527
560
|
default() {
|
|
528
|
-
return
|
|
561
|
+
return a("div", {
|
|
562
|
+
style: e
|
|
563
|
+
}, [t.runtimeProcessor(t.schemas.value)]);
|
|
529
564
|
},
|
|
530
|
-
...
|
|
565
|
+
...r
|
|
531
566
|
});
|
|
532
567
|
}
|
|
533
568
|
}
|
|
534
569
|
class b {
|
|
535
570
|
}
|
|
536
571
|
l(b, "runtimeDoms");
|
|
537
|
-
const
|
|
572
|
+
const v = class v {
|
|
538
573
|
static getPlaceholderPrefixPresetByComponentName() {
|
|
539
574
|
const e = {
|
|
540
575
|
请选择: ["Select", "Tree", "TreeSelect"],
|
|
@@ -547,7 +582,7 @@ const g = class g {
|
|
|
547
582
|
return t;
|
|
548
583
|
}
|
|
549
584
|
};
|
|
550
|
-
l(
|
|
585
|
+
l(v, "schemaPreset", {
|
|
551
586
|
type: {
|
|
552
587
|
defaultValue: "item"
|
|
553
588
|
},
|
|
@@ -581,15 +616,16 @@ l(g, "schemaPreset", {
|
|
|
581
616
|
children: {
|
|
582
617
|
defaultValue: []
|
|
583
618
|
},
|
|
584
|
-
native: void 0
|
|
585
|
-
|
|
619
|
+
native: void 0,
|
|
620
|
+
gridProps: void 0
|
|
621
|
+
}), l(v, "componentPropsPreset", {
|
|
586
622
|
options: {
|
|
587
623
|
defaultValue: []
|
|
588
624
|
}
|
|
589
625
|
}), // 基于基本功能提出基本预设
|
|
590
|
-
l(
|
|
591
|
-
let
|
|
592
|
-
const
|
|
626
|
+
l(v, "placeholderPresetByComponentName", v.getPlaceholderPrefixPresetByComponentName());
|
|
627
|
+
let I = v;
|
|
628
|
+
const ae = /* @__PURE__ */ ie({
|
|
593
629
|
props: {
|
|
594
630
|
setup: {
|
|
595
631
|
type: Function,
|
|
@@ -597,12 +633,12 @@ const ne = /* @__PURE__ */ Z({
|
|
|
597
633
|
}
|
|
598
634
|
},
|
|
599
635
|
setup(o) {
|
|
600
|
-
const e = new
|
|
636
|
+
const e = new ue(o.setup);
|
|
601
637
|
return () => e.exec();
|
|
602
638
|
}
|
|
603
639
|
});
|
|
604
|
-
function
|
|
605
|
-
const e = new
|
|
640
|
+
function de(o) {
|
|
641
|
+
const e = new oe(o);
|
|
606
642
|
return [
|
|
607
643
|
e.setup.bind(e),
|
|
608
644
|
{
|
|
@@ -612,22 +648,22 @@ function le(o) {
|
|
|
612
648
|
}
|
|
613
649
|
];
|
|
614
650
|
}
|
|
615
|
-
function
|
|
651
|
+
function pe(o) {
|
|
616
652
|
return {
|
|
617
653
|
install() {
|
|
618
654
|
b.runtimeDoms = o;
|
|
619
655
|
}
|
|
620
656
|
};
|
|
621
657
|
}
|
|
622
|
-
function
|
|
658
|
+
function me(o, e) {
|
|
623
659
|
return e === "raw" && Object.defineProperty(o, "name", {
|
|
624
660
|
value: `__proform_raw_${o.name}`,
|
|
625
661
|
writable: !0
|
|
626
662
|
}), o;
|
|
627
663
|
}
|
|
628
664
|
export {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
665
|
+
ae as ProForm,
|
|
666
|
+
de as useForm,
|
|
667
|
+
pe as useFormRenderer,
|
|
668
|
+
me as useModifiers
|
|
633
669
|
};
|
|
@@ -30,7 +30,6 @@ export default class Processor {
|
|
|
30
30
|
stableUpdater(parseProcess?: boolean[]): void;
|
|
31
31
|
parseItem(data: AnyObject, index: number, parentMeta?: AnyObject): void;
|
|
32
32
|
objectParser(root: ObjectParserRoot): void;
|
|
33
|
-
replaceUndefinedInString(data: string, replaceTo: string): string;
|
|
34
33
|
promiseFieldParser(rootField: any, updater: AnyFunction, deepProcess: boolean): void;
|
|
35
34
|
fieldParser(rootField: any, updater: AnyFunction, deepProcess?: boolean): void;
|
|
36
35
|
modelProcessor(schemas: Schema[]): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ref } from "vue";
|
|
2
|
-
import { Setup, Schema, AnyObject, ItemSchema, GroupSchema, ListSchema, ProcessorBySchemaType, CustomizationOptions } from "../types";
|
|
2
|
+
import { Setup, Schema, AnyObject, ItemSchema, GroupSchema, ListSchema, ProcessorBySchemaType, CustomizationOptions, RuntimeSetters } from "../types";
|
|
3
3
|
import Processor from "./Processor";
|
|
4
4
|
import Effect from "./Effect";
|
|
5
5
|
export default class RuntimeCore {
|
|
@@ -11,6 +11,8 @@ export default class RuntimeCore {
|
|
|
11
11
|
formRef: Ref<AnyObject>;
|
|
12
12
|
hydrateEffect: Effect;
|
|
13
13
|
customizedOptions: CustomizationOptions;
|
|
14
|
+
gridProps: {};
|
|
15
|
+
runtimeSetters: RuntimeSetters;
|
|
14
16
|
globalNativeFormOverride: {
|
|
15
17
|
props: {};
|
|
16
18
|
slots: {};
|
|
@@ -23,6 +23,35 @@ export type FieldRule<T = any> = {
|
|
|
23
23
|
hasKeys?: string[];
|
|
24
24
|
validator?: (value: T | undefined, callback: (error?: string) => void) => void;
|
|
25
25
|
};
|
|
26
|
+
interface GridStyle {
|
|
27
|
+
gridTemplateColumns?: string;
|
|
28
|
+
gridTemplateRows?: string;
|
|
29
|
+
gridTemplateAreas?: string;
|
|
30
|
+
gridTemplate?: string;
|
|
31
|
+
gridColumnGap?: string;
|
|
32
|
+
gridRowGap?: string;
|
|
33
|
+
gridGap?: string;
|
|
34
|
+
justifyItems?: string;
|
|
35
|
+
alignItems?: string;
|
|
36
|
+
placeItems?: string;
|
|
37
|
+
justifyContent?: string;
|
|
38
|
+
alignContent?: string;
|
|
39
|
+
placeContent?: string;
|
|
40
|
+
gridAutoColumns?: string;
|
|
41
|
+
gridAutoRows?: string;
|
|
42
|
+
gridAutoFlow?: string;
|
|
43
|
+
gridColumnStart?: string;
|
|
44
|
+
gridColumnEnd?: string;
|
|
45
|
+
gridRowStart?: string;
|
|
46
|
+
gridRowEnd?: string;
|
|
47
|
+
gridColumn?: string;
|
|
48
|
+
gridRow?: string;
|
|
49
|
+
gridArea?: string;
|
|
50
|
+
justifySelf?: string;
|
|
51
|
+
alignSelf?: string;
|
|
52
|
+
placeSelf?: string;
|
|
53
|
+
[key: string]: any;
|
|
54
|
+
}
|
|
26
55
|
export interface ItemSchema {
|
|
27
56
|
type?: "item";
|
|
28
57
|
rules?: FieldRule[];
|
|
@@ -30,6 +59,7 @@ export interface ItemSchema {
|
|
|
30
59
|
required?: boolean;
|
|
31
60
|
placeholder?: string;
|
|
32
61
|
native?: NativeCustomizationOptions;
|
|
62
|
+
gridProps?: GridStyle;
|
|
33
63
|
label: string;
|
|
34
64
|
field: string;
|
|
35
65
|
component: DomType;
|
|
@@ -40,12 +70,15 @@ export interface GroupSchema {
|
|
|
40
70
|
type: "group";
|
|
41
71
|
label: string;
|
|
42
72
|
children: ProxyedSchema[];
|
|
73
|
+
gridProps?: GridStyle;
|
|
43
74
|
}
|
|
44
75
|
export interface ListSchema {
|
|
45
76
|
type: "list";
|
|
46
77
|
field: string;
|
|
47
78
|
label: string;
|
|
48
79
|
children: ProxyedSchema[];
|
|
80
|
+
gridProps?: GridStyle;
|
|
81
|
+
runtimeSetters?: RuntimeSetters;
|
|
49
82
|
}
|
|
50
83
|
export type Schema = ItemSchema | GroupSchema | ListSchema;
|
|
51
84
|
export interface runtimeMeta {
|
|
@@ -56,7 +89,13 @@ export type ProFormProxy<T> = {
|
|
|
56
89
|
[K in keyof T]: ProFormProxyRule<T[K]>;
|
|
57
90
|
};
|
|
58
91
|
export type ProxyedSchema = ProFormProxy<ItemSchema | GroupSchema | ListSchema>;
|
|
92
|
+
export interface RuntimeSetters {
|
|
93
|
+
listItemLabelSetter?: (rawLabel: string, rawIndex: number) => any;
|
|
94
|
+
}
|
|
59
95
|
export interface FormCustomization {
|
|
96
|
+
gridProps?: GridStyle;
|
|
97
|
+
native?: NativeCustomizationOptions;
|
|
98
|
+
runtimeSetters?: RuntimeSetters;
|
|
60
99
|
schemas: ProxyedSchema[];
|
|
61
100
|
}
|
|
62
101
|
export type NativeCustomizationOptions = {
|
|
@@ -72,3 +111,4 @@ export type NativeCustomizationOptions = {
|
|
|
72
111
|
export type CustomizationOptions = {
|
|
73
112
|
native?: NativeCustomizationOptions;
|
|
74
113
|
};
|
|
114
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function replaceUndefinedInString(data: string, replaceTo: string): string;
|