@harbor-design/proform 1.0.1 → 1.0.2
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/CHANGELOG.md +13 -0
- package/package.json +4 -2
- package/dist/index.cjs +0 -1
- package/dist/index.js +0 -510
- package/dist/types/index.d.ts +0 -3
- package/dist/types/src/form/index.d.ts +0 -14
- package/dist/types/src/interactions/useForm.d.ts +0 -2
- package/dist/types/src/interactions/useFormRenderer.d.ts +0 -4
- package/dist/types/src/services/Context.d.ts +0 -4
- package/dist/types/src/services/Effect.d.ts +0 -8
- package/dist/types/src/services/FormCustomizer.d.ts +0 -10
- package/dist/types/src/services/Processors.d.ts +0 -24
- package/dist/types/src/services/RuntimeCore.d.ts +0 -20
- package/dist/types/src/services/index.d.ts +0 -5
- package/dist/types/src/types/contextTypes.d.ts +0 -12
- package/dist/types/src/types/formCustomizerTypes.d.ts +0 -55
- package/dist/types/src/types/index.d.ts +0 -5
- package/dist/types/src/types/runtimeTypes.d.ts +0 -6
- package/dist/types/src/types/useFormTypes.d.ts +0 -9
- package/dist/types/src/types/utilTypes.d.ts +0 -2
- package/dist/types/src/utils/deep.d.ts +0 -2
- package/dist/types/src/utils/index.d.ts +0 -2
- package/dist/types/src/utils/is.d.ts +0 -13
package/CHANGELOG.md
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harbor-design/proform",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"dist/"
|
|
22
|
+
"dist/",
|
|
23
|
+
"./LICENSE",
|
|
24
|
+
"./CHANGELOG.md"
|
|
23
25
|
],
|
|
24
26
|
"author": "yiwwhl<yiwwhl@qq.com>",
|
|
25
27
|
"license": "MIT",
|
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var b=Object.defineProperty;var k=(u,e,t)=>e in u?b(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t;var m=(u,e,t)=>(k(u,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("vue");class R{constructor(e){m(this,"runtimeCore");this.formCustomization=e}cleanFallbackFields(e){return e!==null&&typeof e=="object"&&(delete e.__yiwwhl_async_field_fallback,Object.values(e).forEach(t=>{this.cleanFallbackFields(t)})),e}setup(e){return this.runtimeCore=e,this.formCustomization}submit(){return new Promise((e,t)=>{this.runtimeCore.formRef.value.validate(i=>i?t(i):e(this.cleanFallbackFields(l.toRaw(this.runtimeCore.processors.processedModel.value))))})}}class a{static typeChecker(e){return{}.toString.call(e)}static isArray(e){return this.typeChecker(e)==="[object Array]"}static isFunction(e){return this.typeChecker(e).includes("Function")}static isAsyncFunction(e){let t=!1;return this.typeChecker(e)==="[object AsyncFunction]"&&(t=!0),t}static isUndefined(e){return e===void 0}static isArrayEmpty(e){return(e==null?void 0:e.length)<1}static isObjectEmpty(e){return this.isArrayEmpty(Object.keys(e))}static isListSchema(e){return e.type==="list"}static isGroupSchema(e){return e.type==="group"}static isItemSchema(e){return this.isUndefined(e.type)||e.type==="item"}}function V(u){const e=new WeakMap;function t(i){if(i===null||typeof i!="object")return i;if(i instanceof Date)return new Date(i);if(i instanceof RegExp)return new RegExp(i);if(i instanceof Map){const o=new Map;for(let[s,f]of i)o.set(t(s),t(f));return o}if(i instanceof Set){const o=new Set;for(let s of i)o.add(t(s));return o}if(e.has(i))return e.get(i);if(Array.isArray(i)){const o=[];e.set(i,o);for(let s=0;s<i.length;s++)o[s]=t(i[s]);return o}const c=Object.create(Object.getPrototypeOf(i));e.set(i,c);for(let o in i)i.hasOwnProperty(o)&&(c[o]=t(i[o]));return c}return t(u)}class W{constructor(e,t){m(this,"rawSchemas",[]);m(this,"rawModel",{});m(this,"schemaPreset",{type:{defaultValueWhenAsync:"item"},component:{defaultValueWhenAsync:void 0},componentProps:{defaultValueWhenAsync:void 0},defaultValue:{defaultValueWhenAsync:void 0},label:{defaultValueWhenAsync:""},field:{defaultValueWhenAsync:"__yiwwhl_async_field_fallback"},rules:{defaultValueWhenAsync:[]},show:{defaultValueWhenAsync:!0}});m(this,"componentPropsPreset",{options:{defaultValueWhenAsync:[]}});m(this,"uniqueEffectMap",{});m(this,"schemaEffect",new F);m(this,"modelEffect",new F);m(this,"stopWatchEffect",new F);this.processedSchemas=e,this.processedModel=t,l.watch(()=>this.processedModel.value,()=>{this.schemaEffect.triggerEffects(),this.modelEffect.triggerEffects()},{deep:!0})}schemaAnalyzer(e,t=this.processedSchemas.value,i=this.rawSchemas,c,o){for(let s=0;s<e.length;s++){let f=e[s];this.schemaProcessor(f,s,(p,v,y)=>{y?i[s][y]=p[y]:(t[s]=p,this.modelProcessor(p,c&&this.processedModel.value[c][0]),(!i[s]||v)&&(i[s]=V(p)),this.schemaEffect.triggerEffects(),this.modelEffect.triggerEffects())},o,c)}}schemaProcessor(e,t,i,c,o){const s={},f=this;function p(v=!1){var y,w;if(s.componentProps){const h={};f.propsProcessor(s.componentProps,f.componentPropsPreset,h,E=>{s.componentProps=h,i({...s},E,"componentProps")},t,c);return}if(s.children){f.processedSchemas.value[t]=s,f.rawSchemas[t]=s,i({...s},v),f.schemaAnalyzer(s.children,(y=f.processedSchemas.value[t])==null?void 0:y.children,(w=f.rawSchemas[t])==null?void 0:w.children,s.field,t);return}i({...s},v)}this.propsProcessor(e,this.schemaPreset,s,p,t,c,o)}replaceFunctionsWithUndefined(e){if(typeof e!="object"||e===null)return e;for(let t in e)if(e.hasOwnProperty(t)){let i=e[t];typeof i=="function"||typeof i=="object"&&this.replaceFunctionsWithUndefined(i)}return e}runtimeMeta(){return{model:this.replaceFunctionsWithUndefined(l.toRaw(V(this.processedModel.value)))}}propsProcessor(e,t,i,c,o,s,f){const p=Object.keys(e),v=Array.from({length:p.length}).fill(!1);function y(){return v.every(w=>w)}for(let w=0;w<p.length;w++){const h=p[w],E=e[h];if(a.isFunction(E)){const P=E(this.runtimeMeta());h!=="defaultValue"?this.schemaEffect.trackEffect(()=>{let n=E(this.runtimeMeta());n instanceof Promise?n.then(r=>{s===void 0?a.isFunction(r)||(typeof r=="string"&&r.includes("undefined")&&(r=r.replace(/undefined/g,"")),this.processedSchemas.value[o][h]=r):a.isFunction(r)||(typeof r=="string"&&r.includes("undefined")&&(r=r.replace(/undefined/g,"")),this.processedSchemas.value[s].children[o][h]=r)}):s===void 0?a.isFunction(n)||(typeof n=="string"&&n.includes("undefined")&&(n=n.replace(/undefined/g,"")),this.processedSchemas.value[o][h]=n):a.isFunction(n)||(typeof n=="string"&&n.includes("undefined")&&(n=n.replace(/undefined/g,"")),this.processedSchemas.value[s].children[o][h]=n)}):this.modelEffect.trackEffect(()=>{let n=E(this.runtimeMeta());this.stopWatchEffect.trackEffect(l.watchEffect(()=>{if(n=E(this.runtimeMeta()),n instanceof Promise)n.then(r=>{if(typeof r=="string"&&!r.includes("undefined")?this.stopWatchEffect.triggerEffects():r=r.replace(/undefined/g,""),o===void 0||f===void 0){if(a.isFunction(e.field)){const d=e.field(this.runtimeMeta());d instanceof Promise?d.then(g=>{this.processedModel.value[g]=r}):this.processedModel.value[d]=r;return}this.processedModel.value[e.field]=r}else{if(a.isFunction(e.field)){const d=e.field(this.runtimeMeta());d instanceof Promise?d.then(g=>{this.processedModel.value[f][o][g]=r}):this.processedModel.value[f][o]&&(this.processedModel.value[f][o][d]=r);return}this.processedModel.value[f]&&this.processedModel.value[f].forEach(d=>{d[e.field]=r})}this.rawModel=V(this.processedModel.value),this.modelEffect.clearEffects()});else{if(typeof n=="string"&&!n.includes("undefined")?this.stopWatchEffect.triggerEffects():n=n.replace(/undefined/g,""),a.isFunction(e.field)){const r=e.field(this.runtimeMeta());r instanceof Promise?r.then(d=>{this.processedModel.value[d]=n}):this.processedModel.value[r]=n;return}if(this.processedModel.value[e.field]=n,o===void 0||f===void 0){if(a.isFunction(e.field)){const r=e.field(this.runtimeMeta());r instanceof Promise?r.then(d=>{this.processedModel.value[d]=n}):this.processedModel.value[r]=n;return}this.processedModel.value[e.field]=n}else for(let r=0;r<this.processedModel.value[f].length;r++){const d=this.processedModel.value[f][r];if(!a.isFunction(e.field))d[e.field]=n;else{const g=e.field(this.runtimeMeta());g instanceof Promise?g.then(S=>{d[S]=n}):d[g]=n;return}}this.rawModel||(this.rawModel=V(this.processedModel.value)),this.modelEffect.clearEffects()}}))}),P instanceof Promise?(v[w]=!0,i[h]=t[h].defaultValueWhenAsync,y()&&c(),P.then(n=>{v[w]=!0,i[h]=n,y()&&c(!0)})):(v[w]=!0,i[h]=P,y()&&c())}else v[w]=!0,l.isRef(E)?(l.watch(()=>E.value,P=>{i[h]=P,y()&&c()},{immediate:!0,deep:!0}),l.watchEffect(()=>{})):l.isReactive(E)?l.watch(()=>E,P=>{i[h]=P,y()&&c()},{immediate:!0,deep:!0}):(i[h]=E,y()&&c())}}modelProcessor(e,t=this.processedModel.value){if(a.isListSchema(e)){if(a.isFunction(e.field))return;t[e.field]||(t[e.field]=[{}]),e.children.forEach(i=>{this.modelProcessor(i,t[e.field][0])});return}if(a.isGroupSchema(e)){e.children.forEach(i=>{this.modelProcessor(i,t)});return}if(a.isItemSchema(e)){if(a.isFunction(e.field)||a.isUndefined(e.field)||!Number.isNaN(Number(e.field))||a.isFunction(e.defaultValue))return;t[e.field]=e.defaultValue}}}function A(u){return typeof u=="function"||Object.prototype.toString.call(u)==="[object Object]"&&!l.isVNode(u)}class N{constructor(e){m(this,"schemas",l.ref([]));m(this,"model",l.ref({}));m(this,"processorBySchemaType",{item:this.runtimeItemProcessor.bind(this),group:this.runtimeGroupProcessor.bind(this),list:this.runtimeListProcessor.bind(this)});m(this,"formRef",l.ref(null));this.setup=e,this.processors=new W(this.schemas,this.model),this.analyze(this.setup(this))}analyze(e){this.processors.schemaAnalyzer(e.schemas)}runtimeItemProcessor(e,t,i=this.model.value,c){const o=c?`${c.field}.${t}.${e.field}`:e.field,s=l.toRaw(e.component),f=e.componentProps??{};let p=e.show;return p===void 0&&(p=!0),p||delete i[e.field],l.createVNode(M.runtimeDoms.Item,null,{default(){return l.withDirectives(l.createVNode(M.runtimeDoms.FormItem,{label:`${e.label}:`,rules:e.rules,field:o},{default:()=>[l.createVNode(s,l.mergeProps({modelValue:i[e.field],"onUpdate:modelValue":v=>i[e.field]=v},f),null)]}),[[l.vShow,p]])}})}runtimeGroupProcessor(e){let t;return l.createVNode(M.runtimeDoms.Group,{schema:e},A(t=e.children.map(i=>this.runtimeItemProcessor(i)))?t:{default:()=>[t]})}addListItem(e){var t,i;if(!((t=this.processors.rawModel[e.field])!=null&&t[0]))return Promise.reject({code:"0001",message:"异步默认值数据正在处理中,请您耐心等待... "});(i=this.processors.rawModel[e.field])!=null&&i[0]&&this.model.value[e.field].push(V(this.processors.rawModel[e.field][0]))}deleteListItem(e,t){this.model.value[e.field].splice(t,1)}runtimeListProcessor(e){const t=this;return l.createVNode(M.runtimeDoms.List,{schema:e},{default(){return t.model.value[e.field].map((i,c)=>l.createVNode(M.runtimeDoms.ListItem,null,{default(){return e.children.map((o,s)=>t.runtimeItemProcessor(o,s,i,e))},delete({container:o}={}){var f;let s=o??l.createVNode("button",null,null);return l.withDirectives(l.createVNode(s,{onClick:()=>t.deleteListItem(e,c)},null),[[l.vShow,((f=t.model.value[e.field])==null?void 0:f.length)>1]])}}))},add({container:i}={}){let c=i??l.createVNode("button",null,[l.createTextVNode("添加")]);return l.createVNode(c,{onClick:()=>t.addListItem(e)},null)}})}runtimeProcessor(e){return e.map(t=>(t.type||(t.type="item"),this.processorBySchemaType[t.type](t)))}exec(){let e;return l.createVNode(M.runtimeDoms.Form,{ref:this.formRef,model:this.model.value},A(e=this.runtimeProcessor(this.schemas.value))?e:{default:()=>[e]})}}class M{}m(M,"runtimeDoms");class F{constructor(){m(this,"effects",new Set)}clearEffects(){this.effects.clear()}triggerEffects(){Array.from(this.effects).forEach(e=>e())}trackEffect(e){this.effects.add(e)}}const D=l.defineComponent({props:{setup:{type:Function,required:!0}},setup(u){const e=new N(u.setup);return()=>e.exec()}});function C(u){const e=new R(u);return[e.setup.bind(e),{submit:e.submit.bind(e)}]}function _(u){return{install(){M.runtimeDoms=u}}}exports.ProForm=D;exports.useForm=C;exports.useFormRenderer=_;
|
package/dist/index.js
DELETED
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
var _ = Object.defineProperty;
|
|
2
|
-
var j = (c, e, t) => e in c ? _(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
|
|
3
|
-
var h = (c, e, t) => (j(c, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
import { toRaw as S, watch as F, watchEffect as V, isRef as L, isReactive as z, ref as b, createVNode as M, withDirectives as W, mergeProps as N, vShow as R, createTextVNode as G, isVNode as U, defineComponent as $ } from "vue";
|
|
5
|
-
class B {
|
|
6
|
-
constructor(e) {
|
|
7
|
-
h(this, "runtimeCore");
|
|
8
|
-
this.formCustomization = e;
|
|
9
|
-
}
|
|
10
|
-
// happy path, 后续可以完善更多的 fallback 处理,fallback 处理是为了不卡住异步时的首次渲染做的优化
|
|
11
|
-
cleanFallbackFields(e) {
|
|
12
|
-
return e !== null && typeof e == "object" && (delete e.__yiwwhl_async_field_fallback, Object.values(e).forEach((t) => {
|
|
13
|
-
this.cleanFallbackFields(t);
|
|
14
|
-
})), e;
|
|
15
|
-
}
|
|
16
|
-
setup(e) {
|
|
17
|
-
return this.runtimeCore = e, this.formCustomization;
|
|
18
|
-
}
|
|
19
|
-
submit() {
|
|
20
|
-
return new Promise((e, t) => {
|
|
21
|
-
this.runtimeCore.formRef.value.validate((i) => i ? t(i) : e(
|
|
22
|
-
this.cleanFallbackFields(
|
|
23
|
-
S(this.runtimeCore.processors.processedModel.value)
|
|
24
|
-
)
|
|
25
|
-
));
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
class d {
|
|
30
|
-
static typeChecker(e) {
|
|
31
|
-
return {}.toString.call(e);
|
|
32
|
-
}
|
|
33
|
-
static isArray(e) {
|
|
34
|
-
return this.typeChecker(e) === "[object Array]";
|
|
35
|
-
}
|
|
36
|
-
static isFunction(e) {
|
|
37
|
-
return this.typeChecker(e).includes("Function");
|
|
38
|
-
}
|
|
39
|
-
static isAsyncFunction(e) {
|
|
40
|
-
let t = !1;
|
|
41
|
-
return this.typeChecker(e) === "[object AsyncFunction]" && (t = !0), t;
|
|
42
|
-
}
|
|
43
|
-
static isUndefined(e) {
|
|
44
|
-
return e === void 0;
|
|
45
|
-
}
|
|
46
|
-
static isArrayEmpty(e) {
|
|
47
|
-
return (e == null ? void 0 : e.length) < 1;
|
|
48
|
-
}
|
|
49
|
-
static isObjectEmpty(e) {
|
|
50
|
-
return this.isArrayEmpty(Object.keys(e));
|
|
51
|
-
}
|
|
52
|
-
static isListSchema(e) {
|
|
53
|
-
return e.type === "list";
|
|
54
|
-
}
|
|
55
|
-
static isGroupSchema(e) {
|
|
56
|
-
return e.type === "group";
|
|
57
|
-
}
|
|
58
|
-
static isItemSchema(e) {
|
|
59
|
-
return this.isUndefined(e.type) || e.type === "item";
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function A(c) {
|
|
63
|
-
const e = /* @__PURE__ */ new WeakMap();
|
|
64
|
-
function t(i) {
|
|
65
|
-
if (i === null || typeof i != "object")
|
|
66
|
-
return i;
|
|
67
|
-
if (i instanceof Date)
|
|
68
|
-
return new Date(i);
|
|
69
|
-
if (i instanceof RegExp)
|
|
70
|
-
return new RegExp(i);
|
|
71
|
-
if (i instanceof Map) {
|
|
72
|
-
const o = /* @__PURE__ */ new Map();
|
|
73
|
-
for (let [s, l] of i)
|
|
74
|
-
o.set(t(s), t(l));
|
|
75
|
-
return o;
|
|
76
|
-
}
|
|
77
|
-
if (i instanceof Set) {
|
|
78
|
-
const o = /* @__PURE__ */ new Set();
|
|
79
|
-
for (let s of i)
|
|
80
|
-
o.add(t(s));
|
|
81
|
-
return o;
|
|
82
|
-
}
|
|
83
|
-
if (e.has(i))
|
|
84
|
-
return e.get(i);
|
|
85
|
-
if (Array.isArray(i)) {
|
|
86
|
-
const o = [];
|
|
87
|
-
e.set(i, o);
|
|
88
|
-
for (let s = 0; s < i.length; s++)
|
|
89
|
-
o[s] = t(i[s]);
|
|
90
|
-
return o;
|
|
91
|
-
}
|
|
92
|
-
const f = Object.create(Object.getPrototypeOf(i));
|
|
93
|
-
e.set(i, f);
|
|
94
|
-
for (let o in i)
|
|
95
|
-
i.hasOwnProperty(o) && (f[o] = t(i[o]));
|
|
96
|
-
return f;
|
|
97
|
-
}
|
|
98
|
-
return t(c);
|
|
99
|
-
}
|
|
100
|
-
class O {
|
|
101
|
-
constructor(e, t) {
|
|
102
|
-
h(this, "rawSchemas", []);
|
|
103
|
-
h(this, "rawModel", {});
|
|
104
|
-
h(this, "schemaPreset", {
|
|
105
|
-
type: {
|
|
106
|
-
defaultValueWhenAsync: "item"
|
|
107
|
-
},
|
|
108
|
-
component: {
|
|
109
|
-
defaultValueWhenAsync: void 0
|
|
110
|
-
},
|
|
111
|
-
componentProps: {
|
|
112
|
-
defaultValueWhenAsync: void 0
|
|
113
|
-
},
|
|
114
|
-
defaultValue: {
|
|
115
|
-
defaultValueWhenAsync: void 0
|
|
116
|
-
},
|
|
117
|
-
label: {
|
|
118
|
-
defaultValueWhenAsync: ""
|
|
119
|
-
},
|
|
120
|
-
field: {
|
|
121
|
-
defaultValueWhenAsync: "__yiwwhl_async_field_fallback"
|
|
122
|
-
},
|
|
123
|
-
rules: {
|
|
124
|
-
defaultValueWhenAsync: []
|
|
125
|
-
},
|
|
126
|
-
show: {
|
|
127
|
-
defaultValueWhenAsync: !0
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
h(this, "componentPropsPreset", {
|
|
131
|
-
options: {
|
|
132
|
-
defaultValueWhenAsync: []
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
h(this, "uniqueEffectMap", {});
|
|
136
|
-
h(this, "schemaEffect", new k());
|
|
137
|
-
h(this, "modelEffect", new k());
|
|
138
|
-
h(this, "stopWatchEffect", new k());
|
|
139
|
-
this.processedSchemas = e, this.processedModel = t, F(
|
|
140
|
-
() => this.processedModel.value,
|
|
141
|
-
() => {
|
|
142
|
-
this.schemaEffect.triggerEffects(), this.modelEffect.triggerEffects();
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
deep: !0
|
|
146
|
-
}
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
schemaAnalyzer(e, t = this.processedSchemas.value, i = this.rawSchemas, f, o) {
|
|
150
|
-
for (let s = 0; s < e.length; s++) {
|
|
151
|
-
let l = e[s];
|
|
152
|
-
this.schemaProcessor(
|
|
153
|
-
l,
|
|
154
|
-
s,
|
|
155
|
-
(m, y, p) => {
|
|
156
|
-
p ? i[s][p] = m[p] : (t[s] = m, this.modelProcessor(
|
|
157
|
-
m,
|
|
158
|
-
f && this.processedModel.value[f][0]
|
|
159
|
-
), (!i[s] || y) && (i[s] = A(m)), this.schemaEffect.triggerEffects(), this.modelEffect.triggerEffects());
|
|
160
|
-
},
|
|
161
|
-
o,
|
|
162
|
-
f
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
schemaProcessor(e, t, i, f, o) {
|
|
167
|
-
const s = {}, l = this;
|
|
168
|
-
function m(y = !1) {
|
|
169
|
-
var p, E;
|
|
170
|
-
if (s.componentProps) {
|
|
171
|
-
const a = {};
|
|
172
|
-
l.propsProcessor(
|
|
173
|
-
s.componentProps,
|
|
174
|
-
l.componentPropsPreset,
|
|
175
|
-
a,
|
|
176
|
-
(v) => {
|
|
177
|
-
s.componentProps = a, i({ ...s }, v, "componentProps");
|
|
178
|
-
},
|
|
179
|
-
t,
|
|
180
|
-
f
|
|
181
|
-
);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (s.children) {
|
|
185
|
-
l.processedSchemas.value[t] = s, l.rawSchemas[t] = s, i({ ...s }, y), l.schemaAnalyzer(
|
|
186
|
-
s.children,
|
|
187
|
-
// @ts-expect-error 此处已经守卫为非 ItemSchema
|
|
188
|
-
(p = l.processedSchemas.value[t]) == null ? void 0 : p.children,
|
|
189
|
-
// @ts-expect-error 此处已经守卫为非 ItemSchema
|
|
190
|
-
(E = l.rawSchemas[t]) == null ? void 0 : E.children,
|
|
191
|
-
s.field,
|
|
192
|
-
t
|
|
193
|
-
);
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
i({ ...s }, y);
|
|
197
|
-
}
|
|
198
|
-
this.propsProcessor(
|
|
199
|
-
e,
|
|
200
|
-
this.schemaPreset,
|
|
201
|
-
s,
|
|
202
|
-
m,
|
|
203
|
-
t,
|
|
204
|
-
f,
|
|
205
|
-
o
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
replaceFunctionsWithUndefined(e) {
|
|
209
|
-
if (typeof e != "object" || e === null)
|
|
210
|
-
return e;
|
|
211
|
-
for (let t in e)
|
|
212
|
-
if (e.hasOwnProperty(t)) {
|
|
213
|
-
let i = e[t];
|
|
214
|
-
typeof i == "function" || typeof i == "object" && this.replaceFunctionsWithUndefined(i);
|
|
215
|
-
}
|
|
216
|
-
return e;
|
|
217
|
-
}
|
|
218
|
-
runtimeMeta() {
|
|
219
|
-
return {
|
|
220
|
-
model: this.replaceFunctionsWithUndefined(
|
|
221
|
-
S(A(this.processedModel.value))
|
|
222
|
-
)
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
propsProcessor(e, t, i, f, o, s, l) {
|
|
226
|
-
const m = Object.keys(e), y = Array.from({
|
|
227
|
-
length: m.length
|
|
228
|
-
}).fill(!1);
|
|
229
|
-
function p() {
|
|
230
|
-
return y.every((E) => E);
|
|
231
|
-
}
|
|
232
|
-
for (let E = 0; E < m.length; E++) {
|
|
233
|
-
const a = m[E], v = e[a];
|
|
234
|
-
if (d.isFunction(v)) {
|
|
235
|
-
const P = v(this.runtimeMeta());
|
|
236
|
-
a !== "defaultValue" ? this.schemaEffect.trackEffect(() => {
|
|
237
|
-
let n = v(this.runtimeMeta());
|
|
238
|
-
n instanceof Promise ? n.then((r) => {
|
|
239
|
-
s === void 0 ? d.isFunction(r) || (typeof r == "string" && r.includes("undefined") && (r = r.replace(/undefined/g, "")), this.processedSchemas.value[o][a] = r) : d.isFunction(r) || (typeof r == "string" && r.includes("undefined") && (r = r.replace(/undefined/g, "")), this.processedSchemas.value[s].children[o][a] = r);
|
|
240
|
-
}) : s === void 0 ? d.isFunction(n) || (typeof n == "string" && n.includes("undefined") && (n = n.replace(/undefined/g, "")), this.processedSchemas.value[o][a] = n) : d.isFunction(n) || (typeof n == "string" && n.includes("undefined") && (n = n.replace(/undefined/g, "")), this.processedSchemas.value[s].children[o][a] = n);
|
|
241
|
-
}) : this.modelEffect.trackEffect(() => {
|
|
242
|
-
let n = v(this.runtimeMeta());
|
|
243
|
-
this.stopWatchEffect.trackEffect(
|
|
244
|
-
V(() => {
|
|
245
|
-
if (n = v(this.runtimeMeta()), n instanceof Promise)
|
|
246
|
-
n.then((r) => {
|
|
247
|
-
if (typeof r == "string" && !r.includes("undefined") ? this.stopWatchEffect.triggerEffects() : r = r.replace(/undefined/g, ""), o === void 0 || l === void 0) {
|
|
248
|
-
if (d.isFunction(e.field)) {
|
|
249
|
-
const u = e.field(
|
|
250
|
-
this.runtimeMeta()
|
|
251
|
-
);
|
|
252
|
-
u instanceof Promise ? u.then((g) => {
|
|
253
|
-
this.processedModel.value[g] = r;
|
|
254
|
-
}) : this.processedModel.value[u] = r;
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
this.processedModel.value[e.field] = r;
|
|
258
|
-
} else {
|
|
259
|
-
if (d.isFunction(e.field)) {
|
|
260
|
-
const u = e.field(
|
|
261
|
-
this.runtimeMeta()
|
|
262
|
-
);
|
|
263
|
-
u instanceof Promise ? u.then((g) => {
|
|
264
|
-
this.processedModel.value[l][o][g] = r;
|
|
265
|
-
}) : this.processedModel.value[l][o] && (this.processedModel.value[l][o][u] = r);
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
this.processedModel.value[l] && this.processedModel.value[l].forEach(
|
|
269
|
-
// @ts-expect-error
|
|
270
|
-
(u) => {
|
|
271
|
-
u[e.field] = r;
|
|
272
|
-
}
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
this.rawModel = A(this.processedModel.value), this.modelEffect.clearEffects();
|
|
276
|
-
});
|
|
277
|
-
else {
|
|
278
|
-
if (typeof n == "string" && !n.includes("undefined") ? this.stopWatchEffect.triggerEffects() : n = n.replace(/undefined/g, ""), d.isFunction(e.field)) {
|
|
279
|
-
const r = e.field(this.runtimeMeta());
|
|
280
|
-
r instanceof Promise ? r.then((u) => {
|
|
281
|
-
this.processedModel.value[u] = n;
|
|
282
|
-
}) : this.processedModel.value[r] = n;
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
if (this.processedModel.value[e.field] = n, o === void 0 || l === void 0) {
|
|
286
|
-
if (d.isFunction(e.field)) {
|
|
287
|
-
const r = e.field(this.runtimeMeta());
|
|
288
|
-
r instanceof Promise ? r.then((u) => {
|
|
289
|
-
this.processedModel.value[u] = n;
|
|
290
|
-
}) : this.processedModel.value[r] = n;
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
this.processedModel.value[e.field] = n;
|
|
294
|
-
} else
|
|
295
|
-
for (let r = 0; r < this.processedModel.value[l].length; r++) {
|
|
296
|
-
const u = this.processedModel.value[l][r];
|
|
297
|
-
if (!d.isFunction(e.field))
|
|
298
|
-
u[e.field] = n;
|
|
299
|
-
else {
|
|
300
|
-
const g = e.field(
|
|
301
|
-
this.runtimeMeta()
|
|
302
|
-
);
|
|
303
|
-
g instanceof Promise ? g.then((D) => {
|
|
304
|
-
u[D] = n;
|
|
305
|
-
}) : u[g] = n;
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
this.rawModel || (this.rawModel = A(this.processedModel.value)), this.modelEffect.clearEffects();
|
|
310
|
-
}
|
|
311
|
-
})
|
|
312
|
-
);
|
|
313
|
-
}), P instanceof Promise ? (y[E] = !0, i[a] = t[a].defaultValueWhenAsync, p() && f(), P.then((n) => {
|
|
314
|
-
y[E] = !0, i[a] = n, p() && f(!0);
|
|
315
|
-
})) : (y[E] = !0, i[a] = P, p() && f());
|
|
316
|
-
} else
|
|
317
|
-
y[E] = !0, L(v) ? (F(
|
|
318
|
-
() => v.value,
|
|
319
|
-
(P) => {
|
|
320
|
-
i[a] = P, p() && f();
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
immediate: !0,
|
|
324
|
-
deep: !0
|
|
325
|
-
}
|
|
326
|
-
), V(() => {
|
|
327
|
-
})) : z(v) ? F(
|
|
328
|
-
() => v,
|
|
329
|
-
(P) => {
|
|
330
|
-
i[a] = P, p() && f();
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
immediate: !0,
|
|
334
|
-
deep: !0
|
|
335
|
-
}
|
|
336
|
-
) : (i[a] = v, p() && f());
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
modelProcessor(e, t = this.processedModel.value) {
|
|
340
|
-
if (d.isListSchema(e)) {
|
|
341
|
-
if (d.isFunction(e.field))
|
|
342
|
-
return;
|
|
343
|
-
t[e.field] || (t[e.field] = [{}]), e.children.forEach((i) => {
|
|
344
|
-
this.modelProcessor(i, t[e.field][0]);
|
|
345
|
-
});
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
if (d.isGroupSchema(e)) {
|
|
349
|
-
e.children.forEach((i) => {
|
|
350
|
-
this.modelProcessor(i, t);
|
|
351
|
-
});
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
if (d.isItemSchema(e)) {
|
|
355
|
-
if (d.isFunction(e.field) || d.isUndefined(e.field) || !Number.isNaN(Number(e.field)) || d.isFunction(e.defaultValue))
|
|
356
|
-
return;
|
|
357
|
-
t[e.field] = e.defaultValue;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
function C(c) {
|
|
362
|
-
return typeof c == "function" || Object.prototype.toString.call(c) === "[object Object]" && !U(c);
|
|
363
|
-
}
|
|
364
|
-
class T {
|
|
365
|
-
constructor(e) {
|
|
366
|
-
h(this, "schemas", b([]));
|
|
367
|
-
h(this, "model", b({}));
|
|
368
|
-
h(this, "processorBySchemaType", {
|
|
369
|
-
item: this.runtimeItemProcessor.bind(this),
|
|
370
|
-
group: this.runtimeGroupProcessor.bind(this),
|
|
371
|
-
list: this.runtimeListProcessor.bind(this)
|
|
372
|
-
});
|
|
373
|
-
h(this, "formRef", b(null));
|
|
374
|
-
this.setup = e, this.processors = new O(this.schemas, this.model), this.analyze(this.setup(this));
|
|
375
|
-
}
|
|
376
|
-
analyze(e) {
|
|
377
|
-
this.processors.schemaAnalyzer(e.schemas);
|
|
378
|
-
}
|
|
379
|
-
runtimeItemProcessor(e, t, i = this.model.value, f) {
|
|
380
|
-
const o = f ? `${f.field}.${t}.${e.field}` : e.field, s = S(e.component), l = e.componentProps ?? {};
|
|
381
|
-
let m = e.show;
|
|
382
|
-
return m === void 0 && (m = !0), m || delete i[e.field], M(w.runtimeDoms.Item, null, {
|
|
383
|
-
default() {
|
|
384
|
-
return W(M(w.runtimeDoms.FormItem, {
|
|
385
|
-
label: `${e.label}:`,
|
|
386
|
-
rules: e.rules,
|
|
387
|
-
field: o
|
|
388
|
-
}, {
|
|
389
|
-
default: () => [M(s, N({
|
|
390
|
-
modelValue: i[e.field],
|
|
391
|
-
"onUpdate:modelValue": (y) => i[e.field] = y
|
|
392
|
-
}, l), null)]
|
|
393
|
-
}), [[R, m]]);
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
runtimeGroupProcessor(e) {
|
|
398
|
-
let t;
|
|
399
|
-
return M(w.runtimeDoms.Group, {
|
|
400
|
-
schema: e
|
|
401
|
-
}, C(t = e.children.map((i) => this.runtimeItemProcessor(i))) ? t : {
|
|
402
|
-
default: () => [t]
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
addListItem(e) {
|
|
406
|
-
var t, i;
|
|
407
|
-
if (!((t = this.processors.rawModel[e.field]) != null && t[0]))
|
|
408
|
-
return Promise.reject({
|
|
409
|
-
code: "0001",
|
|
410
|
-
message: "异步默认值数据正在处理中,请您耐心等待... "
|
|
411
|
-
});
|
|
412
|
-
(i = this.processors.rawModel[e.field]) != null && i[0] && this.model.value[e.field].push(A(this.processors.rawModel[e.field][0]));
|
|
413
|
-
}
|
|
414
|
-
deleteListItem(e, t) {
|
|
415
|
-
this.model.value[e.field].splice(t, 1);
|
|
416
|
-
}
|
|
417
|
-
runtimeListProcessor(e) {
|
|
418
|
-
const t = this;
|
|
419
|
-
return M(w.runtimeDoms.List, {
|
|
420
|
-
schema: e
|
|
421
|
-
}, {
|
|
422
|
-
default() {
|
|
423
|
-
return t.model.value[e.field].map((i, f) => M(w.runtimeDoms.ListItem, null, {
|
|
424
|
-
default() {
|
|
425
|
-
return e.children.map((o, s) => t.runtimeItemProcessor(o, s, i, e));
|
|
426
|
-
},
|
|
427
|
-
delete({
|
|
428
|
-
container: o
|
|
429
|
-
} = {}) {
|
|
430
|
-
var l;
|
|
431
|
-
let s = o ?? M("button", null, null);
|
|
432
|
-
return W(M(s, {
|
|
433
|
-
onClick: () => t.deleteListItem(e, f)
|
|
434
|
-
}, null), [[R, ((l = t.model.value[e.field]) == null ? void 0 : l.length) > 1]]);
|
|
435
|
-
}
|
|
436
|
-
}));
|
|
437
|
-
},
|
|
438
|
-
add({
|
|
439
|
-
container: i
|
|
440
|
-
} = {}) {
|
|
441
|
-
let f = i ?? M("button", null, [G("添加")]);
|
|
442
|
-
return M(f, {
|
|
443
|
-
onClick: () => t.addListItem(e)
|
|
444
|
-
}, null);
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
runtimeProcessor(e) {
|
|
449
|
-
return e.map((t) => (t.type || (t.type = "item"), this.processorBySchemaType[t.type](t)));
|
|
450
|
-
}
|
|
451
|
-
exec() {
|
|
452
|
-
let e;
|
|
453
|
-
return M(w.runtimeDoms.Form, {
|
|
454
|
-
ref: this.formRef,
|
|
455
|
-
model: this.model.value
|
|
456
|
-
}, C(e = this.runtimeProcessor(this.schemas.value)) ? e : {
|
|
457
|
-
default: () => [e]
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
class w {
|
|
462
|
-
}
|
|
463
|
-
h(w, "runtimeDoms");
|
|
464
|
-
class k {
|
|
465
|
-
constructor() {
|
|
466
|
-
h(this, "effects", /* @__PURE__ */ new Set());
|
|
467
|
-
}
|
|
468
|
-
clearEffects() {
|
|
469
|
-
this.effects.clear();
|
|
470
|
-
}
|
|
471
|
-
triggerEffects() {
|
|
472
|
-
Array.from(this.effects).forEach((e) => e());
|
|
473
|
-
}
|
|
474
|
-
trackEffect(e) {
|
|
475
|
-
this.effects.add(e);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
const J = /* @__PURE__ */ $({
|
|
479
|
-
props: {
|
|
480
|
-
setup: {
|
|
481
|
-
type: Function,
|
|
482
|
-
required: !0
|
|
483
|
-
}
|
|
484
|
-
},
|
|
485
|
-
setup(c) {
|
|
486
|
-
const e = new T(c.setup);
|
|
487
|
-
return () => e.exec();
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
function K(c) {
|
|
491
|
-
const e = new B(c);
|
|
492
|
-
return [
|
|
493
|
-
e.setup.bind(e),
|
|
494
|
-
{
|
|
495
|
-
submit: e.submit.bind(e)
|
|
496
|
-
}
|
|
497
|
-
];
|
|
498
|
-
}
|
|
499
|
-
function Q(c) {
|
|
500
|
-
return {
|
|
501
|
-
install() {
|
|
502
|
-
w.runtimeDoms = c;
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
export {
|
|
507
|
-
J as ProForm,
|
|
508
|
-
K as useForm,
|
|
509
|
-
Q as useFormRenderer
|
|
510
|
-
};
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PropType } from "vue";
|
|
2
|
-
import { Setup } from "../types";
|
|
3
|
-
declare const _default: import("vue").DefineComponent<{
|
|
4
|
-
setup: {
|
|
5
|
-
type: PropType<Setup>;
|
|
6
|
-
required: true;
|
|
7
|
-
};
|
|
8
|
-
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
9
|
-
setup: {
|
|
10
|
-
type: PropType<Setup>;
|
|
11
|
-
required: true;
|
|
12
|
-
};
|
|
13
|
-
}>>, {}, {}>;
|
|
14
|
-
export default _default;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AnyObject, FormCustomization } from "../types";
|
|
2
|
-
import { RuntimeCore } from "./index";
|
|
3
|
-
export default class FormCustomizer {
|
|
4
|
-
formCustomization: FormCustomization;
|
|
5
|
-
runtimeCore: RuntimeCore;
|
|
6
|
-
private cleanFallbackFields;
|
|
7
|
-
constructor(formCustomization: FormCustomization);
|
|
8
|
-
setup(_runtimeCore: RuntimeCore): FormCustomization;
|
|
9
|
-
submit(): Promise<AnyObject>;
|
|
10
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Ref } from "vue";
|
|
2
|
-
import { AnyObject, Schema, ItemSchema, ProxyedSchema, AnyFunction } from "../types";
|
|
3
|
-
import { Effect } from "../services";
|
|
4
|
-
export default class Processors {
|
|
5
|
-
processedSchemas: Ref<Schema[]>;
|
|
6
|
-
processedModel: Ref<AnyObject>;
|
|
7
|
-
rawSchemas: ProxyedSchema[];
|
|
8
|
-
rawModel: AnyObject;
|
|
9
|
-
schemaPreset: Record<keyof ItemSchema, any>;
|
|
10
|
-
componentPropsPreset: AnyObject;
|
|
11
|
-
uniqueEffectMap: any;
|
|
12
|
-
schemaEffect: Effect;
|
|
13
|
-
modelEffect: Effect;
|
|
14
|
-
stopWatchEffect: Effect;
|
|
15
|
-
constructor(processedSchemas: Ref<Schema[]>, processedModel: Ref<AnyObject>);
|
|
16
|
-
schemaAnalyzer(schemas: ProxyedSchema[], baseSchema?: Schema[], baseRawSchema?: ProxyedSchema[], parentField?: string, schemaIndex?: number): void;
|
|
17
|
-
schemaProcessor(schema: ProxyedSchema, index: number, setter: AnyFunction, schemaIndex?: number, parentField?: string): void;
|
|
18
|
-
replaceFunctionsWithUndefined(obj: AnyObject): AnyObject;
|
|
19
|
-
runtimeMeta(): {
|
|
20
|
-
model: AnyObject;
|
|
21
|
-
};
|
|
22
|
-
propsProcessor<T extends object = any>(pendingProcess: T, preset: Record<keyof T, any>, processed: AnyObject, update: AnyFunction, schemaIndexOrChildrenIndex: number, schemaIndex?: number, parentField?: string): void;
|
|
23
|
-
modelProcessor(schema: ProxyedSchema, baseModel?: AnyObject): void;
|
|
24
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Ref } from "vue";
|
|
2
|
-
import { Setup, Schema, FormCustomization, AnyObject, ItemSchema, GroupSchema, ListSchema, ProcessorBySchemaType } from "../types";
|
|
3
|
-
import Processors from "./Processors";
|
|
4
|
-
export default class RuntimeCore {
|
|
5
|
-
setup: Setup;
|
|
6
|
-
processors: Processors;
|
|
7
|
-
schemas: Ref<Schema[]>;
|
|
8
|
-
model: Ref<AnyObject>;
|
|
9
|
-
processorBySchemaType: ProcessorBySchemaType;
|
|
10
|
-
formRef: Ref<AnyObject>;
|
|
11
|
-
constructor(setup: Setup);
|
|
12
|
-
analyze(formCustomization: FormCustomization): void;
|
|
13
|
-
runtimeItemProcessor(schema: ItemSchema, index?: number, baseModel?: AnyObject, parentSchema?: ListSchema): JSX.Element;
|
|
14
|
-
runtimeGroupProcessor(schema: GroupSchema): JSX.Element;
|
|
15
|
-
addListItem(schema: AnyObject): Promise<never> | undefined;
|
|
16
|
-
deleteListItem(schema: AnyObject, index: number): void;
|
|
17
|
-
runtimeListProcessor(schema: ListSchema): JSX.Element;
|
|
18
|
-
runtimeProcessor(schemas: Schema[]): any[];
|
|
19
|
-
exec(): JSX.Element;
|
|
20
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { default as FormCustomizer } from "./FormCustomizer";
|
|
2
|
-
export { default as RuntimeCore } from "./RuntimeCore";
|
|
3
|
-
export { default as Context } from "./Context";
|
|
4
|
-
export { default as Processors } from "./Processors";
|
|
5
|
-
export { default as Effect } from "./Effect";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AnyObject } from "./utilTypes";
|
|
2
|
-
export type DomType = new (...args: any) => AnyObject & {
|
|
3
|
-
$props: AnyObject;
|
|
4
|
-
};
|
|
5
|
-
export interface RuntimeDomCustomizer {
|
|
6
|
-
Form: DomType;
|
|
7
|
-
FormItem: DomType;
|
|
8
|
-
Item: DomType;
|
|
9
|
-
List: DomType;
|
|
10
|
-
ListItem: DomType;
|
|
11
|
-
Group: DomType;
|
|
12
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { AnyObject, DomType } from "./index";
|
|
2
|
-
export type SchemaType = "item" | "list" | "group";
|
|
3
|
-
export type FieldRule<T = any> = {
|
|
4
|
-
type?: "string" | "number" | "boolean" | "array" | "object" | "email" | "url" | "ip";
|
|
5
|
-
required?: boolean;
|
|
6
|
-
message?: string;
|
|
7
|
-
length?: number;
|
|
8
|
-
maxLength?: number;
|
|
9
|
-
minLength?: number;
|
|
10
|
-
match?: RegExp;
|
|
11
|
-
uppercase?: boolean;
|
|
12
|
-
lowercase?: boolean;
|
|
13
|
-
min?: number;
|
|
14
|
-
max?: number;
|
|
15
|
-
equal?: number;
|
|
16
|
-
positive?: boolean;
|
|
17
|
-
negative?: boolean;
|
|
18
|
-
true?: boolean;
|
|
19
|
-
false?: boolean;
|
|
20
|
-
includes?: any[];
|
|
21
|
-
deepEqual?: any;
|
|
22
|
-
empty?: boolean;
|
|
23
|
-
hasKeys?: string[];
|
|
24
|
-
validator?: (value: T | undefined, callback: (error?: string) => void) => void;
|
|
25
|
-
};
|
|
26
|
-
export interface ItemSchema {
|
|
27
|
-
type?: "item";
|
|
28
|
-
rules?: FieldRule[];
|
|
29
|
-
show?: boolean;
|
|
30
|
-
label: string;
|
|
31
|
-
field: string;
|
|
32
|
-
component: DomType;
|
|
33
|
-
componentProps?: AnyObject;
|
|
34
|
-
defaultValue?: PropertyKey | object;
|
|
35
|
-
}
|
|
36
|
-
export interface GroupSchema {
|
|
37
|
-
type: "group";
|
|
38
|
-
label: string;
|
|
39
|
-
children: ProxyedSchema[];
|
|
40
|
-
}
|
|
41
|
-
export interface ListSchema {
|
|
42
|
-
type: "list";
|
|
43
|
-
field: string;
|
|
44
|
-
label: string;
|
|
45
|
-
children: ProxyedSchema[];
|
|
46
|
-
}
|
|
47
|
-
export type Schema = ItemSchema | GroupSchema | ListSchema;
|
|
48
|
-
export type ProFormProxyRule<T> = T | ((...args: any) => T) | ((...args: any) => Promise<T>);
|
|
49
|
-
export type ProFormProxy<T> = {
|
|
50
|
-
[K in keyof T]: ProFormProxyRule<T[K]>;
|
|
51
|
-
};
|
|
52
|
-
export type ProxyedSchema = ProFormProxy<ItemSchema | GroupSchema | ListSchema>;
|
|
53
|
-
export interface FormCustomization {
|
|
54
|
-
schemas: ProxyedSchema[];
|
|
55
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { GroupSchema, ItemSchema, ListSchema } from "../types";
|
|
2
|
-
export default class IS {
|
|
3
|
-
private static typeChecker;
|
|
4
|
-
static isArray(data: any): data is any[];
|
|
5
|
-
static isFunction(data: any): data is (...args: any) => any;
|
|
6
|
-
static isAsyncFunction(data: any): data is (...args: any) => Promise<any>;
|
|
7
|
-
static isUndefined(data: any): data is undefined;
|
|
8
|
-
static isArrayEmpty(data: any[]): boolean;
|
|
9
|
-
static isObjectEmpty(data: Record<PropertyKey, any>): boolean;
|
|
10
|
-
static isListSchema(data: any): data is ListSchema;
|
|
11
|
-
static isGroupSchema(data: any): data is GroupSchema;
|
|
12
|
-
static isItemSchema(data: any): data is ItemSchema;
|
|
13
|
-
}
|