@harbor-design/proform 1.0.13 → 1.0.15

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 CHANGED
@@ -1 +1 @@
1
- "use strict";var I=Object.defineProperty;var O=(n,e,t)=>e in n?I(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var c=(n,e,t)=>(O(n,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue");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)==="[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 E(n,...e){return e.forEach(t=>{for(let s in t)t.hasOwnProperty(s)&&(typeof t[s]=="object"&&t[s]!==null?(n[s]=n[s]||{},E(n[s],t[s])):n[s]=t[s])}),n}function S(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,f]of s)i.set(t(l),t(f));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 C{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){this.runtimeCore.hydrateEffect.trackEffect(()=>{o.isRef(e)?o.watch(()=>e.value,()=>{E(this.runtimeCore.model.value,e.value)},{deep:!0,immediate:!0}):o.isReactive(e)?o.watch(()=>e,()=>{E(this.runtimeCore.model.value,e)},{deep:!0,immediate:!0}):E(this.runtimeCore.model.value,e)},{lazy:!0})}}class j{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 M{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 j);c(this,"defaultValueEffect",new j);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){a.isArrayEmpty(this.processedSchemas.value)&&(this.baseDefaultValueFunctionsLength=this.countFunctionDefaultValues(S(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=o.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,i=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,h=f.key,P=f.keyIndex;if(!f.stable)return;const w=r.parseStable(f.stable),b=s==null?void 0:s.index,g=s==null?void 0:s.key;let d=w;if(a.isProcessInprogress(d)||(i[P]=!0),s){let p=r.processedSchemas.value[b][g][u][h];p&&a.isObject(p)&&h!=="component"&&(d=Object.assign(p,d)),r.processedSchemas.value[b][g][u][h]=d,r.stableUpdater(i)}else{let p=r.processedSchemas.value[u][h];p&&a.isObject(p)&&(d=Object.assign(p,d)),r.processedSchemas.value[u][h]=d,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=f=>{e.updater({...e,key:r,keyIndex:i,stable:f})};if(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(h=>!h.includes("undefined"))?(l(u),this.defaultValueEffect.clearEffects(),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(h=>!h.includes("undefined"))?(l(u),this.defaultValueEffect.clearEffects(),f()):l(u)})})});else if(r==="component"){const f=t[r];this.promiseFieldParser(f,l,!1)}else 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)}):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 o.isRef(e)?o.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}):o.isReactive(e)?o.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=S(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 v(n){return typeof n=="function"||Object.prototype.toString.call(n)==="[object Object]"&&!o.isVNode(n)}class R{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 j);this.setup=e,this.processor=new M(this);const t=this.setup(this);this.processor.parseSchemas(t.schemas)}getRuntimeMeta(){return{model:o.toRaw(S(this.model.value))}}runtimeItemProcessor(e,t,s=this.model.value,r){var g;const i=r?`${r.field}.${t}.${e.field}`:e.field,l=o.toRaw(e.component);if(!l)return;const f=l.name,u=e.componentProps??{},h=V.placeholderPresetByComponentName;let P=e.placeholder;if(P||(P=`${h[f]??"请输入"}${e.label}`),e.required)if(!e.rules)e.rules=[],(g=e.rules)==null||g.push({required:!0,message:`${e.label}是必填项`});else{const d=e.rules.findIndex(p=>!!p.required);e.rules[d].message=`${e.label}是必填项`}let b=e.show;return b===void 0&&(b=!0),b||delete s[e.field],o.createVNode(m.runtimeDoms.Item,null,{default(){return o.withDirectives(o.createVNode(m.runtimeDoms.FormItem,{label:`${e.label}:`,rules:e.rules,field:i},{default:()=>[o.createVNode(l,o.mergeProps({modelValue:s[e.field],"onUpdate:modelValue":d=>s[e.field]=d,placeholder:P},u),null)]}),[[o.vShow,b]])}})}runtimeGroupProcessor(e){let t;return o.createVNode(m.runtimeDoms.Group,{schema:e},v(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(S(this.processor.stableModel[e.field][0]))}deleteListItem(e,t){this.model.value[e.field].splice(t,1);const s=e.children.map(({field:r})=>`${e.field}.${t}.${r}`);this.formRef.value.clearValidate(s)}runtimeListProcessor(e){const t=this;return t.model.value[e.field]||(t.model.value[e.field]=[{}]),o.createVNode(m.runtimeDoms.List,{schema:e},{default(){return t.model.value[e.field].map((s,r)=>o.createVNode(m.runtimeDoms.ListItem,null,{default(){return e.children.map(i=>t.runtimeItemProcessor(i,r,s,e))},delete({container:i}={}){var f;let l=i??o.createVNode("button",null,null);return o.withDirectives(o.createVNode(l,{onClick:()=>t.deleteListItem(e,r)},null),[[o.vShow,((f=t.model.value[e.field])==null?void 0:f.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(){let e;return o.createVNode(m.runtimeDoms.Form,{ref:this.formRef,model:this.model.value},v(e=this.runtimeProcessor(this.schemas.value))?e:{default:()=>[e]})}}class m{}c(m,"runtimeDoms");const y=class y{static getPlaceholderPrefixPresetByComponentName(){const e={请选择:["Select","Tree","TreeSelect"],请输入:["Input"]},t={};for(let s in e)e[s].forEach(r=>{t[r]=s});return t}};c(y,"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:[]}}),c(y,"componentPropsPreset",{options:{defaultValue:[]}}),c(y,"placeholderPresetByComponentName",y.getPlaceholderPrefixPresetByComponentName());let V=y;const A=o.defineComponent({props:{setup:{type:Function,required:!0}},setup(n){const e=new R(n.setup);return()=>e.exec()}});function D(n){const e=new C(n);return[e.setup.bind(e),{submit:e.submit.bind(e),hydrate:e.hydrate.bind(e)}]}function N(n){return{install(){m.runtimeDoms=n}}}function x(n,e){return e==="raw"&&Object.defineProperty(n,"name",{value:`__proform_raw_${n.name}`,writable:!0}),n}exports.ProForm=A;exports.useForm=D;exports.useFormRenderer=N;exports.useModifiers=x;
1
+ "use strict";var I=Object.defineProperty;var O=(o,e,t)=>e in o?I(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var c=(o,e,t)=>(O(o,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=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 S(o,...e){return e.forEach(t=>{for(let s in t)t.hasOwnProperty(s)&&(typeof t[s]=="object"&&t[s]!==null?(o[s]=o[s]||{},S(o[s],t[s])):o[s]=t[s])}),o}function E(o){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(o)}class C{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(n.toRaw(this.runtimeCore.processor.processedModel.value))))})}hydrate(e){this.runtimeCore.hydrateEffect.trackEffect(()=>{n.isRef(e)?n.watch(()=>e.value,()=>{S(this.runtimeCore.model.value,e.value)},{deep:!0,immediate:!0}):n.isReactive(e)?n.watch(()=>e,()=>{S(this.runtimeCore.model.value,e)},{deep:!0,immediate:!0}):S(this.runtimeCore.model.value,e)},{lazy:!0})}}class j{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 R{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 j);c(this,"defaultValueEffect",new j);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),n.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(E(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=n.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,h=a.key,P=a.keyIndex;if(!a.stable)return;const v=r.parseStable(a.stable),y=s==null?void 0:s.index,g=s==null?void 0:s.key;let d=v;if(f.isProcessInprogress(d)||(i[P]=!0),s){let p=r.processedSchemas.value[y][g][u][h];p&&f.isObject(p)&&h!=="component"&&(d=Object.assign(p,d)),r.processedSchemas.value[y][g][u][h]=d,r.stableUpdater(i)}else{let p=r.processedSchemas.value[u][h];p&&f.isObject(p)&&(d=Object.assign(p,d)),r.processedSchemas.value[u][h]=d,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})};if(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(h=>!h.includes("undefined"))?(l(u),this.defaultValueEffect.clearEffects(),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(h=>!h.includes("undefined"))?(l(u),this.defaultValueEffect.clearEffects(),a()):l(u)})})});else if(r==="component"){const a=t[r];this.promiseFieldParser(a,l,!1)}else 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 n.isRef(e)?n.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}):n.isReactive(e)?n.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=E(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 w(o){return typeof o=="function"||Object.prototype.toString.call(o)==="[object Object]"&&!n.isVNode(o)}class M{constructor(e){c(this,"schemas",n.ref([]));c(this,"model",n.ref({}));c(this,"processorBySchemaType",{item:this.runtimeItemProcessor.bind(this),group:this.runtimeGroupProcessor.bind(this),list:this.runtimeListProcessor.bind(this)});c(this,"formRef",n.ref(null));c(this,"hydrateEffect",new j);this.setup=e,this.processor=new R(this);const t=this.setup(this);this.processor.parseSchemas(t.schemas)}getRuntimeMeta(){return{model:n.toRaw(E(this.model.value))}}runtimeItemProcessor(e,t,s=this.model.value,r){var g;const i=r?`${r.field}.${t}.${e.field}`:e.field,l=n.toRaw(e.component);if(!l)return;const a=l.name,u=e.componentProps??{},h=V.placeholderPresetByComponentName;let P=e.placeholder;if(P||(P=`${h[a]??"请输入"}${e.label}`),e.required)if(!e.rules)e.rules=[],(g=e.rules)==null||g.push({required:!0,message:`${e.label}是必填项`});else{const d=e.rules.findIndex(p=>!!p.required);e.rules[d].message=`${e.label}是必填项`}let y=e.show;return y===void 0&&(y=!0),y||delete s[e.field],n.createVNode(m.runtimeDoms.Item,null,{default(){return n.withDirectives(n.createVNode(m.runtimeDoms.FormItem,{label:`${e.label}:`,rules:e.rules,field:i},{default:()=>[n.createVNode(l,n.mergeProps({modelValue:s[e.field],"onUpdate:modelValue":d=>s[e.field]=d,placeholder:P},u),null)]}),[[n.vShow,y]])}})}runtimeGroupProcessor(e){let t;return n.createVNode(m.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(E(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]=[{}]),n.createVNode(m.runtimeDoms.List,{schema:e},{default(){return t.model.value[e.field].map((s,r)=>n.createVNode(m.runtimeDoms.ListItem,null,{default(){return e.children.map(i=>t.runtimeItemProcessor(i,r,s,e))},delete({container:i}={}){var a;let l=i??n.createVNode("button",null,null);return n.withDirectives(n.createVNode(l,{onClick:()=>t.deleteListItem(e,r)},null),[[n.vShow,((a=t.model.value[e.field])==null?void 0:a.length)>1]])}}))},add({container:s}={}){let r=s??n.createVNode("button",null,[n.createTextVNode("添加")]);return n.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 n.createVNode(m.runtimeDoms.Form,{ref:this.formRef,model:this.model.value},w(e=this.runtimeProcessor(this.schemas.value))?e:{default:()=>[e]})}}class m{}c(m,"runtimeDoms");const b=class b{static getPlaceholderPrefixPresetByComponentName(){const e={请选择:["Select","Tree","TreeSelect"],请输入:["Input"]},t={};for(let s in e)e[s].forEach(r=>{t[r]=s});return t}};c(b,"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:[]}}),c(b,"componentPropsPreset",{options:{defaultValue:[]}}),c(b,"placeholderPresetByComponentName",b.getPlaceholderPrefixPresetByComponentName());let V=b;const A=n.defineComponent({props:{setup:{type:Function,required:!0}},setup(o){const e=new M(o.setup);return()=>e.exec()}});function D(o){const e=new C(o);return[e.setup.bind(e),{submit:e.submit.bind(e),hydrate:e.hydrate.bind(e)}]}function N(o){return{install(){m.runtimeDoms=o}}}function U(o,e){return e==="raw"&&Object.defineProperty(o,"name",{value:`__proform_raw_${o.name}`,writable:!0}),o}exports.ProForm=A;exports.useForm=D;exports.useFormRenderer=N;exports.useModifiers=U;
package/dist/index.js CHANGED
@@ -1,11 +1,14 @@
1
- var U = Object.defineProperty;
2
- var _ = (n, e, t) => e in n ? U(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
1
+ var D = Object.defineProperty;
2
+ var _ = (n, e, t) => e in n ? D(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var o = (n, e, t) => (_(n, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { toRaw as V, isRef as x, watch as E, isReactive as D, ref as I, createVNode as h, withDirectives as O, mergeProps as k, vShow as A, createTextVNode as R, isVNode as L, defineComponent as $ } from "vue";
5
- class f {
4
+ import { toRaw as V, isRef as M, watch as S, isReactive as U, ref as I, createVNode as h, withDirectives as O, mergeProps as k, vShow as A, createTextVNode as R, isVNode as L, defineComponent as z } from "vue";
5
+ class c {
6
6
  static typeChecker(e) {
7
7
  return {}.toString.call(e);
8
8
  }
9
+ static isString(e) {
10
+ return typeof e == "string";
11
+ }
9
12
  static isArray(e) {
10
13
  return this.typeChecker(e) === "[object Array]";
11
14
  }
@@ -60,10 +63,10 @@ class f {
60
63
  return !1;
61
64
  }
62
65
  }
63
- function S(n, ...e) {
66
+ function j(n, ...e) {
64
67
  return e.forEach((t) => {
65
68
  for (let s in t)
66
- t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ? (n[s] = n[s] || {}, S(n[s], t[s])) : n[s] = t[s]);
69
+ t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ? (n[s] = n[s] || {}, j(n[s], t[s])) : n[s] = t[s]);
67
70
  }), n;
68
71
  }
69
72
  function v(n) {
@@ -77,8 +80,8 @@ function v(n) {
77
80
  return new RegExp(s);
78
81
  if (s instanceof Map) {
79
82
  const i = /* @__PURE__ */ new Map();
80
- for (let [l, c] of s)
81
- i.set(t(l), t(c));
83
+ for (let [l, f] of s)
84
+ i.set(t(l), t(f));
82
85
  return i;
83
86
  }
84
87
  if (s instanceof Set) {
@@ -104,7 +107,7 @@ function v(n) {
104
107
  }
105
108
  return t(n);
106
109
  }
107
- class z {
110
+ class B {
108
111
  constructor(e) {
109
112
  o(this, "runtimeCore");
110
113
  this.formCustomization = e;
@@ -130,25 +133,25 @@ class z {
130
133
  hydrate(e) {
131
134
  this.runtimeCore.hydrateEffect.trackEffect(
132
135
  () => {
133
- x(e) ? E(
136
+ M(e) ? S(
134
137
  () => e.value,
135
138
  () => {
136
- S(this.runtimeCore.model.value, e.value);
139
+ j(this.runtimeCore.model.value, e.value);
137
140
  },
138
141
  {
139
142
  deep: !0,
140
143
  immediate: !0
141
144
  }
142
- ) : D(e) ? E(
145
+ ) : U(e) ? S(
143
146
  () => e,
144
147
  () => {
145
- S(this.runtimeCore.model.value, e);
148
+ j(this.runtimeCore.model.value, e);
146
149
  },
147
150
  {
148
151
  deep: !0,
149
152
  immediate: !0
150
153
  }
151
- ) : S(this.runtimeCore.model.value, e);
154
+ ) : j(this.runtimeCore.model.value, e);
152
155
  },
153
156
  {
154
157
  lazy: !0
@@ -172,7 +175,7 @@ class w {
172
175
  return !t.lazy && e(), this.effects.add(e), () => this.effects.delete(e);
173
176
  }
174
177
  }
175
- class B {
178
+ class N {
176
179
  constructor(e) {
177
180
  o(this, "runtimeCore");
178
181
  o(this, "processedSchemas");
@@ -180,15 +183,15 @@ class B {
180
183
  o(this, "getRuntimeMeta");
181
184
  o(this, "stableSchemas", []);
182
185
  o(this, "stableModel", {});
183
- o(this, "schemaPreset", j.schemaPreset);
184
- o(this, "componentPropsPreset", j.componentPropsPreset);
186
+ o(this, "schemaPreset", E.schemaPreset);
187
+ o(this, "componentPropsPreset", E.componentPropsPreset);
185
188
  o(this, "stableUpdaterProcessProgress");
186
189
  o(this, "stableUpdaterTimes", 0);
187
190
  o(this, "schemaEffect", new w());
188
191
  o(this, "defaultValueEffect", new w());
189
192
  o(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
190
193
  o(this, "baseDefaultValueFunctionsLength");
191
- this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), E(
194
+ this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), S(
192
195
  () => this.processedModel.value,
193
196
  () => {
194
197
  this.schemaEffect.triggerEffects();
@@ -224,13 +227,13 @@ class B {
224
227
  }
225
228
  // 派生过程,用于外部应用
226
229
  parseSchemas(e, t) {
227
- f.isArrayEmpty(this.processedSchemas.value) && (this.baseDefaultValueFunctionsLength = this.countFunctionDefaultValues(
230
+ c.isArrayEmpty(this.processedSchemas.value) && (this.baseDefaultValueFunctionsLength = this.countFunctionDefaultValues(
228
231
  v(e)
229
232
  ), this.processedSchemas.value = this.initSchemas(e)), this.parse(e, t);
230
233
  }
231
234
  parseStable(e) {
232
235
  const t = {};
233
- if (!f.isUndefined(e.stable))
236
+ if (!c.isUndefined(e.stable))
234
237
  t[e.key] = this.parseStable(e.stable);
235
238
  else
236
239
  return e;
@@ -240,7 +243,7 @@ class B {
240
243
  stableUpdater(e = []) {
241
244
  if (e.every(Boolean)) {
242
245
  const t = V(this.processedSchemas.value);
243
- !f.isProcessInprogress(t) && f.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
246
+ !c.isProcessInprogress(t) && c.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
244
247
  length: t.length
245
248
  }).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
246
249
  }
@@ -248,21 +251,21 @@ class B {
248
251
  // 核心单 schema 处理过程,接收一个对象键值对的数据结构
249
252
  parseItem(e, t, s) {
250
253
  const r = this, i = Array.from({
251
- length: Object.keys(e).filter((c) => c !== "children").length
254
+ length: Object.keys(e).filter((f) => f !== "children").length
252
255
  }).fill(!1);
253
256
  this.objectParser({ data: e, index: t, updater: l });
254
- function l(c) {
255
- const u = c.index, d = c.key, P = c.keyIndex;
256
- if (!c.stable)
257
+ function l(f) {
258
+ const u = f.index, d = f.key, P = f.keyIndex;
259
+ if (!f.stable)
257
260
  return;
258
- const C = r.parseStable(c.stable), b = s == null ? void 0 : s.index, g = s == null ? void 0 : s.key;
261
+ const C = r.parseStable(f.stable), y = s == null ? void 0 : s.index, g = s == null ? void 0 : s.key;
259
262
  let a = C;
260
- if (f.isProcessInprogress(a) || (i[P] = !0), s) {
261
- let p = r.processedSchemas.value[b][g][u][d];
262
- p && f.isObject(p) && d !== "component" && (a = Object.assign(p, a)), r.processedSchemas.value[b][g][u][d] = a, r.stableUpdater(i);
263
+ if (c.isProcessInprogress(a) || (i[P] = !0), s) {
264
+ let p = r.processedSchemas.value[y][g][u][d];
265
+ p && c.isObject(p) && d !== "component" && (a = Object.assign(p, a)), r.processedSchemas.value[y][g][u][d] = a, r.stableUpdater(i);
263
266
  } else {
264
267
  let p = r.processedSchemas.value[u][d];
265
- p && f.isObject(p) && (a = Object.assign(p, a)), r.processedSchemas.value[u][d] = a, r.stableUpdater(i);
268
+ p && c.isObject(p) && (a = Object.assign(p, a)), r.processedSchemas.value[u][d] = a, r.stableUpdater(i);
266
269
  }
267
270
  }
268
271
  }
@@ -277,58 +280,61 @@ class B {
277
280
  keyIndex: i
278
281
  });
279
282
  else {
280
- const l = (c) => {
283
+ const l = (f) => {
281
284
  e.updater({
282
285
  ...e,
283
286
  key: r,
284
287
  keyIndex: i,
285
- stable: c
288
+ stable: f
286
289
  });
287
290
  };
288
- if (f.isFunction(t[r]))
291
+ if (c.isFunction(t[r]))
289
292
  r !== "defaultValue" ? this.schemaEffect.trackEffect(() => {
290
293
  if (r === "component") {
291
- const c = t[r](this.getRuntimeMeta());
292
- this.promiseFieldParser(c, l, !1);
294
+ const f = t[r](this.getRuntimeMeta());
295
+ this.promiseFieldParser(f, l, !1);
293
296
  } else
294
297
  this.fieldParser(t[r], l);
295
298
  }) : this.defaultValueEffect.trackEffect(() => {
296
- const c = this.schemaEffect.trackEffect(() => {
299
+ const f = this.schemaEffect.trackEffect(() => {
297
300
  /\{\s*model\s*\}/.test(t[r].toString()) ? this.fieldParser(t[r], (u) => {
298
301
  if (!u)
299
302
  return l(u);
300
- this.defaultValueInprogressMap.set(t[r], u), !f.isProcessInprogress(u) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(this.defaultValueInprogressMap.values()).every(
303
+ this.defaultValueInprogressMap.set(t[r], u), !c.isProcessInprogress(u) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(this.defaultValueInprogressMap.values()).every(
301
304
  (d) => !d.includes("undefined")
302
- ) ? (l(u), this.defaultValueEffect.clearEffects(), c()) : l(u);
305
+ ) ? (l(u), this.defaultValueEffect.clearEffects(), f()) : l(u);
303
306
  }) : this.fieldParser(t[r], (u) => {
304
- this.defaultValueInprogressMap.set(t[r], u), !f.isProcessInprogress(u) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(this.defaultValueInprogressMap.values()).every(
307
+ this.defaultValueInprogressMap.set(t[r], u), !c.isProcessInprogress(u) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(this.defaultValueInprogressMap.values()).every(
305
308
  (d) => !d.includes("undefined")
306
- ) ? (l(u), this.defaultValueEffect.clearEffects(), c()) : l(u);
309
+ ) ? (l(u), this.defaultValueEffect.clearEffects(), f()) : l(u);
307
310
  });
308
311
  });
309
312
  });
310
313
  else if (r === "component") {
311
- const c = t[r];
312
- this.promiseFieldParser(c, l, !1);
314
+ const f = t[r];
315
+ this.promiseFieldParser(f, l, !1);
313
316
  } else
314
317
  this.fieldParser(t[r], l);
315
318
  }
316
319
  });
317
320
  }
321
+ replaceUndefinedInString(e, t) {
322
+ return e.replace(/undefined/g, t);
323
+ }
318
324
  promiseFieldParser(e, t, s) {
319
- f.isPromise(e) ? e.then((r) => {
320
- s && f.isObject(r) ? this.objectParser({
325
+ c.isPromise(e) ? e.then((r) => {
326
+ s && c.isObject(r) ? this.objectParser({
321
327
  data: r,
322
328
  updater: t
323
329
  }) : t(r);
324
- }) : s && f.isObject(e) ? this.objectParser({
330
+ }) : (c.isString(e) && (e = this.replaceUndefinedInString(e, "")), s && c.isObject(e) ? this.objectParser({
325
331
  data: e,
326
332
  updater: t
327
- }) : t(e);
333
+ }) : t(e));
328
334
  }
329
335
  // 对任意对象中单个字段的 parse: 做基本处理
330
336
  fieldParser(e, t, s = !0) {
331
- if (f.isFunction(e))
337
+ if (c.isFunction(e))
332
338
  if (e.name.startsWith("__proform_raw_"))
333
339
  t(e);
334
340
  else {
@@ -336,10 +342,10 @@ class B {
336
342
  this.promiseFieldParser(r, t, s);
337
343
  }
338
344
  else
339
- x(e) ? E(
345
+ M(e) ? S(
340
346
  () => e.value,
341
347
  () => {
342
- f.isUndefined(e.value) || (s && f.isObject(e.value) ? this.objectParser({
348
+ c.isUndefined(e.value) || (s && c.isObject(e.value) ? this.objectParser({
343
349
  data: e.value,
344
350
  updater: t
345
351
  }) : t(e.value));
@@ -348,10 +354,10 @@ class B {
348
354
  immediate: !0,
349
355
  deep: !0
350
356
  }
351
- ) : D(e) ? E(
357
+ ) : U(e) ? S(
352
358
  () => e,
353
359
  () => {
354
- f.isUndefined(e) || (s && f.isObject(e) ? this.objectParser({
360
+ c.isUndefined(e) || (s && c.isObject(e) ? this.objectParser({
355
361
  data: e,
356
362
  updater: t
357
363
  }) : t(e));
@@ -360,7 +366,7 @@ class B {
360
366
  immediate: !0,
361
367
  deep: !0
362
368
  }
363
- ) : s && f.isObject(e) ? this.objectParser({
369
+ ) : s && c.isObject(e) ? this.objectParser({
364
370
  data: e,
365
371
  updater: t
366
372
  }) : t(e);
@@ -368,20 +374,20 @@ class B {
368
374
  modelProcessor(e) {
369
375
  e.map(
370
376
  (t) => this.createModel(t, this.processedModel.value)
371
- ), f.isObjectEmpty(this.stableModel) && this.stableUpdaterProcessProgress.every(Boolean) && this.defaultValueEffect.effects.size === 0 && (this.stableModel = v(this.processedModel.value), this.runtimeCore.hydrateEffect.triggerEffects(), this.runtimeCore.hydrateEffect.clearEffects());
377
+ ), c.isObjectEmpty(this.stableModel) && this.stableUpdaterProcessProgress.every(Boolean) && this.defaultValueEffect.effects.size === 0 && (this.stableModel = v(this.processedModel.value), this.runtimeCore.hydrateEffect.triggerEffects(), this.runtimeCore.hydrateEffect.clearEffects());
372
378
  }
373
379
  createModel(e, t) {
374
- f.isListSchema(e) && (t[e.field] || (t[e.field] = [{}]), e.children.forEach((s) => {
380
+ c.isListSchema(e) && (t[e.field] || (t[e.field] = [{}]), e.children.forEach((s) => {
375
381
  this.createModel(s, t[e.field][0]);
376
- })), f.isGroupSchema(e) && e.children.forEach((s) => {
382
+ })), c.isGroupSchema(e) && e.children.forEach((s) => {
377
383
  this.createModel(s, t);
378
- }), f.isItemSchema(e) && (t[e.field] = e.defaultValue);
384
+ }), c.isItemSchema(e) && (t[e.field] = e.defaultValue);
379
385
  }
380
386
  }
381
- function M(n) {
387
+ function x(n) {
382
388
  return typeof n == "function" || Object.prototype.toString.call(n) === "[object Object]" && !L(n);
383
389
  }
384
- class F {
390
+ class T {
385
391
  constructor(e) {
386
392
  o(this, "schemas", I([]));
387
393
  o(this, "model", I({}));
@@ -392,7 +398,7 @@ class F {
392
398
  });
393
399
  o(this, "formRef", I(null));
394
400
  o(this, "hydrateEffect", new w());
395
- this.setup = e, this.processor = new B(this);
401
+ this.setup = e, this.processor = new N(this);
396
402
  const t = this.setup(this);
397
403
  this.processor.parseSchemas(t.schemas);
398
404
  }
@@ -406,10 +412,10 @@ class F {
406
412
  const i = r ? `${r.field}.${t}.${e.field}` : e.field, l = V(e.component);
407
413
  if (!l)
408
414
  return;
409
- const c = l.name, u = e.componentProps ?? {}, d = j.placeholderPresetByComponentName;
415
+ const f = l.name, u = e.componentProps ?? {}, d = E.placeholderPresetByComponentName;
410
416
  let P = e.placeholder;
411
417
  if (P || (P = `${// @ts-expect-error
412
- d[c] ?? "请输入"}${e.label}`), e.required)
418
+ d[f] ?? "请输入"}${e.label}`), e.required)
413
419
  if (!e.rules)
414
420
  e.rules = [], (g = e.rules) == null || g.push({
415
421
  required: !0,
@@ -419,8 +425,8 @@ class F {
419
425
  const a = e.rules.findIndex((p) => !!p.required);
420
426
  e.rules[a].message = `${e.label}是必填项`;
421
427
  }
422
- let b = e.show;
423
- return b === void 0 && (b = !0), b || delete s[e.field], h(m.runtimeDoms.Item, null, {
428
+ let y = e.show;
429
+ return y === void 0 && (y = !0), y || delete s[e.field], h(m.runtimeDoms.Item, null, {
424
430
  default() {
425
431
  return O(h(m.runtimeDoms.FormItem, {
426
432
  label: `${e.label}:`,
@@ -432,7 +438,7 @@ class F {
432
438
  "onUpdate:modelValue": (a) => s[e.field] = a,
433
439
  placeholder: P
434
440
  }, u), null)]
435
- }), [[A, b]]);
441
+ }), [[A, y]]);
436
442
  }
437
443
  });
438
444
  }
@@ -440,7 +446,7 @@ class F {
440
446
  let t;
441
447
  return h(m.runtimeDoms.Group, {
442
448
  schema: e
443
- }, M(t = e.children.map((s) => this.runtimeItemProcessor(s))) ? t : {
449
+ }, x(t = e.children.map((s) => this.runtimeItemProcessor(s))) ? t : {
444
450
  default: () => [t]
445
451
  });
446
452
  }
@@ -451,14 +457,10 @@ class F {
451
457
  code: "0001",
452
458
  message: "异步默认值数据正在处理中,请您耐心等待... "
453
459
  });
454
- (s = this.processor.stableModel[e.field]) != null && s[0] && this.model.value[e.field].push(v(this.processor.stableModel[e.field][0]));
460
+ (s = this.processor.stableModel[e.field]) != null && s[0] && this.model.value[e.field].push(v(this.processor.stableModel[e.field][0])), this.formRef.value.clearValidate();
455
461
  }
456
462
  deleteListItem(e, t) {
457
- this.model.value[e.field].splice(t, 1);
458
- const s = e.children.map(({
459
- field: r
460
- }) => `${e.field}.${t}.${r}`);
461
- this.formRef.value.clearValidate(s);
463
+ this.model.value[e.field].splice(t, 1), this.formRef.value.clearValidate();
462
464
  }
463
465
  runtimeListProcessor(e) {
464
466
  const t = this;
@@ -473,11 +475,11 @@ class F {
473
475
  delete({
474
476
  container: i
475
477
  } = {}) {
476
- var c;
478
+ var f;
477
479
  let l = i ?? h("button", null, null);
478
480
  return O(h(l, {
479
481
  onClick: () => t.deleteListItem(e, r)
480
- }, null), [[A, ((c = t.model.value[e.field]) == null ? void 0 : c.length) > 1]]);
482
+ }, null), [[A, ((f = t.model.value[e.field]) == null ? void 0 : f.length) > 1]]);
481
483
  }
482
484
  }));
483
485
  },
@@ -499,7 +501,7 @@ class F {
499
501
  return h(m.runtimeDoms.Form, {
500
502
  ref: this.formRef,
501
503
  model: this.model.value
502
- }, M(e = this.runtimeProcessor(this.schemas.value)) ? e : {
504
+ }, x(e = this.runtimeProcessor(this.schemas.value)) ? e : {
503
505
  default: () => [e]
504
506
  });
505
507
  }
@@ -507,7 +509,7 @@ class F {
507
509
  class m {
508
510
  }
509
511
  o(m, "runtimeDoms");
510
- const y = class y {
512
+ const b = class b {
511
513
  static getPlaceholderPrefixPresetByComponentName() {
512
514
  const e = {
513
515
  请选择: ["Select", "Tree", "TreeSelect"],
@@ -520,7 +522,7 @@ const y = class y {
520
522
  return t;
521
523
  }
522
524
  };
523
- o(y, "schemaPreset", {
525
+ o(b, "schemaPreset", {
524
526
  type: {
525
527
  defaultValue: "item"
526
528
  },
@@ -554,14 +556,14 @@ o(y, "schemaPreset", {
554
556
  children: {
555
557
  defaultValue: []
556
558
  }
557
- }), o(y, "componentPropsPreset", {
559
+ }), o(b, "componentPropsPreset", {
558
560
  options: {
559
561
  defaultValue: []
560
562
  }
561
563
  }), // 基于基本功能提出基本预设
562
- o(y, "placeholderPresetByComponentName", y.getPlaceholderPrefixPresetByComponentName());
563
- let j = y;
564
- const q = /* @__PURE__ */ $({
564
+ o(b, "placeholderPresetByComponentName", b.getPlaceholderPrefixPresetByComponentName());
565
+ let E = b;
566
+ const F = /* @__PURE__ */ z({
565
567
  props: {
566
568
  setup: {
567
569
  type: Function,
@@ -569,12 +571,12 @@ const q = /* @__PURE__ */ $({
569
571
  }
570
572
  },
571
573
  setup(n) {
572
- const e = new F(n.setup);
574
+ const e = new T(n.setup);
573
575
  return () => e.exec();
574
576
  }
575
577
  });
576
578
  function G(n) {
577
- const e = new z(n);
579
+ const e = new B(n);
578
580
  return [
579
581
  e.setup.bind(e),
580
582
  {
@@ -597,7 +599,7 @@ function W(n, e) {
597
599
  }), n;
598
600
  }
599
601
  export {
600
- q as ProForm,
602
+ F as ProForm,
601
603
  G as useForm,
602
604
  K as useFormRenderer,
603
605
  W as useModifiers
@@ -30,6 +30,7 @@ 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;
33
34
  promiseFieldParser(rootField: any, updater: AnyFunction, deepProcess: boolean): void;
34
35
  fieldParser(rootField: any, updater: AnyFunction, deepProcess?: boolean): void;
35
36
  modelProcessor(schemas: Schema[]): void;
@@ -1,6 +1,7 @@
1
1
  import { AnyObject, GroupSchema, ItemSchema, ListSchema } from "../types";
2
2
  export default class IS {
3
3
  private static typeChecker;
4
+ static isString(data: any): data is string;
4
5
  static isArray(data: any): data is any[];
5
6
  static isFunction(data: any): data is (...args: any) => any;
6
7
  static isPromise(data: any): data is Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harbor-design/proform",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",