@harbor-design/proform 1.1.9 → 1.1.12
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 +464 -253
- package/dist/types/index.d.ts +1 -1
- package/dist/types/src/interactions/useFormPresetConfigurer.d.ts +2 -0
- package/dist/types/src/services/Context/index.d.ts +4 -0
- package/dist/types/src/services/{Effect.d.ts → Effect/index.d.ts} +2 -2
- package/dist/types/src/services/{FormCustomizer.d.ts → FormCustomizer/index.d.ts} +2 -2
- package/dist/types/src/services/Preset/AdapterPreset.d.ts +3 -0
- package/dist/types/src/services/{Preset.d.ts → Preset/RuntimePreset.d.ts} +2 -2
- package/dist/types/src/services/Preset/index.d.ts +14 -0
- package/dist/types/src/services/{Processor.d.ts → Processor/index.d.ts} +3 -3
- package/dist/types/src/services/RuntimeCore/RuntimeAdapter.d.ts +10 -0
- package/dist/types/src/services/RuntimeCore/RuntimeContainer.d.ts +9 -0
- package/dist/types/src/services/{RuntimeCore.d.ts → RuntimeCore/index.d.ts} +8 -5
- package/dist/types/src/types/adapter.d.ts +9 -0
- package/dist/types/src/types/contextTypes.d.ts +17 -7
- package/dist/types/src/types/formCustomizerTypes.d.ts +11 -10
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/runtimeTypes.d.ts +3 -0
- package/package.json +1 -1
- package/dist/types/src/interactions/useFormRenderer.d.ts +0 -4
- package/dist/types/src/services/Context.d.ts +0 -4
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
class
|
|
1
|
+
var ie = Object.defineProperty;
|
|
2
|
+
var oe = (r, e, t) => e in r ? ie(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var a = (r, e, t) => (oe(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { isRef as x, watch as I, isReactive as k, toRaw as E, nextTick as w, ref as q, reactive as ne, createVNode as p, withDirectives as Z, mergeProps as R, vShow as A, createTextVNode as le, isVNode as ae, defineComponent as ue } from "vue";
|
|
5
|
+
class l {
|
|
6
6
|
static typeChecker(e) {
|
|
7
7
|
return {}.toString.call(e);
|
|
8
8
|
}
|
|
@@ -63,18 +63,18 @@ class f {
|
|
|
63
63
|
return !1;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
function m(
|
|
66
|
+
function m(r, ...e) {
|
|
67
67
|
return e.forEach((t) => {
|
|
68
68
|
if (Array.isArray(t))
|
|
69
|
-
Array.isArray(
|
|
70
|
-
typeof s == "object" && s !== null ?
|
|
69
|
+
Array.isArray(r) || (r = []), t.forEach((s, i) => {
|
|
70
|
+
typeof s == "object" && s !== null ? r[i] = m(Array.isArray(s) ? [] : {}, s) : r[i] = s;
|
|
71
71
|
});
|
|
72
72
|
else
|
|
73
73
|
for (let s in t)
|
|
74
|
-
t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ?
|
|
75
|
-
}),
|
|
74
|
+
t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ? r[s] = m(r[s] || {}, t[s]) : r[s] = t[s]);
|
|
75
|
+
}), r;
|
|
76
76
|
}
|
|
77
|
-
function g(
|
|
77
|
+
function g(r) {
|
|
78
78
|
const e = /* @__PURE__ */ new WeakMap();
|
|
79
79
|
function t(s) {
|
|
80
80
|
if (s === null || typeof s != "object")
|
|
@@ -84,40 +84,40 @@ function g(o) {
|
|
|
84
84
|
if (s instanceof RegExp)
|
|
85
85
|
return new RegExp(s);
|
|
86
86
|
if (s instanceof Map) {
|
|
87
|
-
const
|
|
87
|
+
const o = /* @__PURE__ */ new Map();
|
|
88
88
|
for (let [n, u] of s)
|
|
89
|
-
|
|
90
|
-
return
|
|
89
|
+
o.set(t(n), t(u));
|
|
90
|
+
return o;
|
|
91
91
|
}
|
|
92
92
|
if (s instanceof Set) {
|
|
93
|
-
const
|
|
93
|
+
const o = /* @__PURE__ */ new Set();
|
|
94
94
|
for (let n of s)
|
|
95
|
-
|
|
96
|
-
return
|
|
95
|
+
o.add(t(n));
|
|
96
|
+
return o;
|
|
97
97
|
}
|
|
98
98
|
if (e.has(s))
|
|
99
99
|
return e.get(s);
|
|
100
100
|
if (Array.isArray(s)) {
|
|
101
|
-
const
|
|
102
|
-
e.set(s,
|
|
101
|
+
const o = [];
|
|
102
|
+
e.set(s, o);
|
|
103
103
|
for (let n = 0; n < s.length; n++)
|
|
104
|
-
|
|
105
|
-
return
|
|
104
|
+
o[n] = t(s[n]);
|
|
105
|
+
return o;
|
|
106
106
|
}
|
|
107
|
-
const
|
|
108
|
-
e.set(s,
|
|
109
|
-
for (let
|
|
110
|
-
s.hasOwnProperty(
|
|
111
|
-
return
|
|
107
|
+
const i = Object.create(Object.getPrototypeOf(s));
|
|
108
|
+
e.set(s, i);
|
|
109
|
+
for (let o in s)
|
|
110
|
+
s.hasOwnProperty(o) && (i[o] = t(s[o]));
|
|
111
|
+
return i;
|
|
112
112
|
}
|
|
113
|
-
return t(
|
|
113
|
+
return t(r);
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
return
|
|
115
|
+
function N(r, e) {
|
|
116
|
+
return r.replace(/undefined/g, e);
|
|
117
117
|
}
|
|
118
|
-
class
|
|
118
|
+
class ce {
|
|
119
119
|
constructor(e) {
|
|
120
|
-
|
|
120
|
+
a(this, "runtimeCore");
|
|
121
121
|
this.formCustomization = e;
|
|
122
122
|
}
|
|
123
123
|
// happy path, 后续可以完善更多的 fallback 处理,fallback 处理是为了不卡住异步时的首次渲染做的优化
|
|
@@ -127,19 +127,12 @@ class ne {
|
|
|
127
127
|
})), e;
|
|
128
128
|
}
|
|
129
129
|
setup(e) {
|
|
130
|
-
return this.runtimeCore = e, Object.assign(this.runtimeCore.native, this.formCustomization.native), Object.assign(this.runtimeCore.
|
|
131
|
-
this.runtimeCore.runtimeSetters,
|
|
132
|
-
this.formCustomization.runtimeSetters
|
|
133
|
-
), this.formCustomization;
|
|
130
|
+
return this.runtimeCore = e, Object.assign(this.runtimeCore.native, this.formCustomization.native), Object.assign(this.runtimeCore.grid, this.formCustomization.grid), Object.assign(this.runtimeCore.runtime, this.formCustomization.runtime), this.formCustomization.ui && (this.runtimeCore.ui = this.formCustomization.ui), this.formCustomization;
|
|
134
131
|
}
|
|
135
132
|
submit() {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
O(this.runtimeCore.processor.processedModel.value)
|
|
140
|
-
)
|
|
141
|
-
));
|
|
142
|
-
});
|
|
133
|
+
var s;
|
|
134
|
+
const e = (s = f.presets.uiPresets[this.runtimeCore.ui]) == null ? void 0 : s.adapter, t = b.adapters[this.runtimeCore.ui];
|
|
135
|
+
return (e == null ? void 0 : e.validateForm(this)) ?? (t == null ? void 0 : t.validateForm(this));
|
|
143
136
|
}
|
|
144
137
|
hydrate(e) {
|
|
145
138
|
if (!this.runtimeCore)
|
|
@@ -149,7 +142,7 @@ class ne {
|
|
|
149
142
|
});
|
|
150
143
|
this.runtimeCore.hydrateEffect.trackEffect(
|
|
151
144
|
() => {
|
|
152
|
-
|
|
145
|
+
x(e) ? I(
|
|
153
146
|
() => e.value,
|
|
154
147
|
() => {
|
|
155
148
|
m(this.runtimeCore.model.value, e.value);
|
|
@@ -158,7 +151,7 @@ class ne {
|
|
|
158
151
|
deep: !0,
|
|
159
152
|
immediate: !0
|
|
160
153
|
}
|
|
161
|
-
) :
|
|
154
|
+
) : k(e) ? I(
|
|
162
155
|
() => e,
|
|
163
156
|
() => {
|
|
164
157
|
m(this.runtimeCore.model.value, e);
|
|
@@ -175,9 +168,9 @@ class ne {
|
|
|
175
168
|
);
|
|
176
169
|
}
|
|
177
170
|
}
|
|
178
|
-
class
|
|
171
|
+
class U {
|
|
179
172
|
constructor() {
|
|
180
|
-
|
|
173
|
+
a(this, "effects", /* @__PURE__ */ new Set());
|
|
181
174
|
}
|
|
182
175
|
clearEffects() {
|
|
183
176
|
this.effects.clear();
|
|
@@ -191,23 +184,23 @@ class x {
|
|
|
191
184
|
return !t.lazy && e(), this.effects.add(e), () => this.effects.delete(e);
|
|
192
185
|
}
|
|
193
186
|
}
|
|
194
|
-
class
|
|
187
|
+
class fe {
|
|
195
188
|
constructor(e) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e),
|
|
189
|
+
a(this, "runtimeCore");
|
|
190
|
+
a(this, "processedSchemas");
|
|
191
|
+
a(this, "processedModel");
|
|
192
|
+
a(this, "getRuntimeMeta");
|
|
193
|
+
a(this, "stableSchemas", []);
|
|
194
|
+
a(this, "stableModel", {});
|
|
195
|
+
a(this, "schemaPreset", b.schemaPreset);
|
|
196
|
+
a(this, "componentPropsPreset", b.componentPropsPreset);
|
|
197
|
+
a(this, "stableUpdaterProcessProgress");
|
|
198
|
+
a(this, "stableUpdaterTimes", 0);
|
|
199
|
+
a(this, "schemaEffect", new U());
|
|
200
|
+
a(this, "defaultValueEffect", new U());
|
|
201
|
+
a(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
|
|
202
|
+
a(this, "baseDefaultValueFunctionsLength");
|
|
203
|
+
this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), I(
|
|
211
204
|
() => this.processedModel.value,
|
|
212
205
|
() => {
|
|
213
206
|
this.schemaEffect.triggerEffects();
|
|
@@ -219,8 +212,8 @@ class le {
|
|
|
219
212
|
}
|
|
220
213
|
// 核心处理过程,接收一个初始的代理数据结构,由其衍生的有 parseSchema
|
|
221
214
|
parse(e, t) {
|
|
222
|
-
e.forEach((s,
|
|
223
|
-
this.parseItem(s,
|
|
215
|
+
e.forEach((s, i) => {
|
|
216
|
+
this.parseItem(s, i, t);
|
|
224
217
|
});
|
|
225
218
|
}
|
|
226
219
|
// 初始化空数据结构,避免后续复杂的 if else
|
|
@@ -232,24 +225,24 @@ class le {
|
|
|
232
225
|
}
|
|
233
226
|
countFunctionDefaultValues(e) {
|
|
234
227
|
let t = 0, s = /* @__PURE__ */ new Set();
|
|
235
|
-
function
|
|
236
|
-
if (!s.has(
|
|
237
|
-
s.add(
|
|
238
|
-
for (let n in
|
|
239
|
-
|
|
228
|
+
function i(o) {
|
|
229
|
+
if (!s.has(o) && (Array.isArray(o) || o !== null && typeof o == "object")) {
|
|
230
|
+
s.add(o);
|
|
231
|
+
for (let n in o)
|
|
232
|
+
o.hasOwnProperty(n) && (n === "defaultValue" && typeof o[n] == "function" && !o[n].toString().includes("[native code]") && t++, i(o[n]));
|
|
240
233
|
}
|
|
241
234
|
}
|
|
242
|
-
return
|
|
235
|
+
return i(e), t;
|
|
243
236
|
}
|
|
244
237
|
// 派生过程,用于外部应用
|
|
245
238
|
parseSchemas(e, t) {
|
|
246
|
-
|
|
239
|
+
l.isArrayEmpty(this.processedSchemas.value) && (this.baseDefaultValueFunctionsLength = this.countFunctionDefaultValues(
|
|
247
240
|
g(e)
|
|
248
241
|
), this.processedSchemas.value = this.initSchemas(e)), this.parse(e, t);
|
|
249
242
|
}
|
|
250
243
|
parseStable(e) {
|
|
251
244
|
const t = {};
|
|
252
|
-
if (!
|
|
245
|
+
if (!l.isUndefined(e.stable))
|
|
253
246
|
t[e.key] = this.parseStable(e.stable);
|
|
254
247
|
else
|
|
255
248
|
return e;
|
|
@@ -258,110 +251,110 @@ class le {
|
|
|
258
251
|
// 对于稳定初始化更新的抽象
|
|
259
252
|
stableUpdater(e = []) {
|
|
260
253
|
if (e.every(Boolean)) {
|
|
261
|
-
const t =
|
|
262
|
-
!
|
|
254
|
+
const t = E(this.processedSchemas.value);
|
|
255
|
+
!l.isProcessInprogress(t) && l.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
|
|
263
256
|
length: t.length
|
|
264
257
|
}).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
|
|
265
258
|
}
|
|
266
259
|
}
|
|
267
260
|
// 核心单 schema 处理过程,接收一个对象键值对的数据结构
|
|
268
261
|
parseItem(e, t, s) {
|
|
269
|
-
const
|
|
262
|
+
const i = this, o = Array.from({
|
|
270
263
|
length: Object.keys(e).filter((u) => u !== "children").length
|
|
271
264
|
}).fill(!1);
|
|
272
265
|
this.objectParser({ data: e, index: t, updater: n });
|
|
273
266
|
function n(u) {
|
|
274
|
-
const
|
|
275
|
-
if (
|
|
267
|
+
const c = u.index, d = u.key, y = u.keyIndex;
|
|
268
|
+
if (l.isUndefined(u.stable))
|
|
276
269
|
return;
|
|
277
|
-
const
|
|
278
|
-
let
|
|
279
|
-
if (
|
|
280
|
-
let h =
|
|
281
|
-
h &&
|
|
270
|
+
const O = i.parseStable(u.stable), C = s == null ? void 0 : s.index, v = s == null ? void 0 : s.key;
|
|
271
|
+
let P = O;
|
|
272
|
+
if (l.isProcessInprogress(P) || (o[y] = !0), s) {
|
|
273
|
+
let h = i.processedSchemas.value[C][v][c][d];
|
|
274
|
+
h && l.isObject(h) && d !== "component" && (P = m(h, P)), i.processedSchemas.value[C][v][c][d] = P, i.stableUpdater(o);
|
|
282
275
|
} else {
|
|
283
|
-
let h =
|
|
284
|
-
h &&
|
|
276
|
+
let h = i.processedSchemas.value[c][d];
|
|
277
|
+
h && l.isObject(h) && d !== "component" && (P = m(h, P)), i.processedSchemas.value[c][d] = P, i.stableUpdater(o);
|
|
285
278
|
}
|
|
286
279
|
}
|
|
287
280
|
}
|
|
288
281
|
// 只做基本的对象 parser
|
|
289
282
|
objectParser(e) {
|
|
290
283
|
const t = e.data;
|
|
291
|
-
Object.keys(t).forEach((
|
|
292
|
-
if (
|
|
293
|
-
this.parseSchemas(t[
|
|
284
|
+
Object.keys(t).forEach((i, o) => {
|
|
285
|
+
if (i === "children")
|
|
286
|
+
this.parseSchemas(t[i], {
|
|
294
287
|
...e,
|
|
295
|
-
key:
|
|
296
|
-
keyIndex:
|
|
288
|
+
key: i,
|
|
289
|
+
keyIndex: o
|
|
297
290
|
});
|
|
298
291
|
else {
|
|
299
292
|
const n = (u) => {
|
|
300
293
|
e.updater({
|
|
301
294
|
...e,
|
|
302
|
-
key:
|
|
303
|
-
keyIndex:
|
|
295
|
+
key: i,
|
|
296
|
+
keyIndex: o,
|
|
304
297
|
stable: u
|
|
305
298
|
});
|
|
306
299
|
};
|
|
307
|
-
|
|
308
|
-
if (
|
|
309
|
-
const u = t[
|
|
300
|
+
l.isFunction(t[i]) ? i !== "defaultValue" ? this.schemaEffect.trackEffect(() => {
|
|
301
|
+
if (i === "component") {
|
|
302
|
+
const u = t[i](this.getRuntimeMeta());
|
|
310
303
|
this.promiseFieldParser(u, n, !1);
|
|
311
304
|
} else
|
|
312
|
-
this.fieldParser(t[
|
|
305
|
+
this.fieldParser(t[i], n);
|
|
313
306
|
}) : this.defaultValueEffect.trackEffect(() => {
|
|
314
307
|
const u = this.schemaEffect.trackEffect(() => {
|
|
315
|
-
/\{\s*model\s*\}/.test(t[
|
|
316
|
-
if (!
|
|
317
|
-
return n(
|
|
318
|
-
this.defaultValueInprogressMap.set(t[
|
|
308
|
+
/\{\s*model\s*\}/.test(t[i].toString()) ? this.fieldParser(t[i], (c) => {
|
|
309
|
+
if (!c)
|
|
310
|
+
return n(c);
|
|
311
|
+
this.defaultValueInprogressMap.set(t[i], c), !l.isProcessInprogress(c) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(this.defaultValueInprogressMap.values()).every(
|
|
319
312
|
(d) => !d.includes("undefined")
|
|
320
|
-
) ? (n(
|
|
313
|
+
) ? (n(c), this.defaultValueEffect.clearEffects(), w(() => {
|
|
321
314
|
u();
|
|
322
|
-
})) : n(
|
|
323
|
-
}) : this.fieldParser(t[
|
|
324
|
-
this.defaultValueInprogressMap.set(t[
|
|
315
|
+
})) : n(c);
|
|
316
|
+
}) : this.fieldParser(t[i], (c) => {
|
|
317
|
+
this.defaultValueInprogressMap.set(t[i], c), !l.isProcessInprogress(c) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(this.defaultValueInprogressMap.values()).every(
|
|
325
318
|
(d) => !d.includes("undefined")
|
|
326
|
-
) ? (n(
|
|
319
|
+
) ? (n(c), this.defaultValueEffect.clearEffects(), w(() => {
|
|
327
320
|
u();
|
|
328
|
-
})) : n(
|
|
321
|
+
})) : n(c);
|
|
329
322
|
});
|
|
330
323
|
});
|
|
331
|
-
}) :
|
|
324
|
+
}) : i === "component" || i === "slots" || i === "runtime" ? this.promiseFieldParser(t[i], n, !1) : this.fieldParser(t[i], n);
|
|
332
325
|
}
|
|
333
326
|
});
|
|
334
327
|
}
|
|
335
328
|
promiseFieldParser(e, t, s) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
data:
|
|
329
|
+
l.isPromise(e) ? e.then((i) => {
|
|
330
|
+
l.isString(i) && (i = N(i, "")), s && l.isObject(i) ? this.objectParser({
|
|
331
|
+
data: i,
|
|
339
332
|
updater: t
|
|
340
|
-
}) : t(
|
|
341
|
-
}) : (
|
|
333
|
+
}) : t(i);
|
|
334
|
+
}) : (l.isString(e) && (e = N(e, "")), s && l.isObject(e) ? this.objectParser({
|
|
342
335
|
data: e,
|
|
343
336
|
updater: t
|
|
344
337
|
}) : t(e));
|
|
345
338
|
}
|
|
346
339
|
// 对任意对象中单个字段的 parse: 做基本处理
|
|
347
340
|
fieldParser(e, t, s = !0) {
|
|
348
|
-
if (
|
|
341
|
+
if (l.isFunction(e))
|
|
349
342
|
if (e.name.startsWith("__proform_raw_"))
|
|
350
|
-
t((...
|
|
343
|
+
t((...i) => {
|
|
351
344
|
e({
|
|
352
|
-
rawArgs:
|
|
345
|
+
rawArgs: i,
|
|
353
346
|
...this.getRuntimeMeta()
|
|
354
347
|
});
|
|
355
348
|
});
|
|
356
349
|
else {
|
|
357
|
-
const
|
|
358
|
-
this.promiseFieldParser(
|
|
350
|
+
const i = e(this.getRuntimeMeta());
|
|
351
|
+
this.promiseFieldParser(i, t, s);
|
|
359
352
|
}
|
|
360
353
|
else
|
|
361
|
-
|
|
354
|
+
x(e) ? I(
|
|
362
355
|
() => e.value,
|
|
363
356
|
() => {
|
|
364
|
-
|
|
357
|
+
l.isUndefined(e.value) || (s && l.isObject(e.value) ? this.objectParser({
|
|
365
358
|
data: e.value,
|
|
366
359
|
updater: t
|
|
367
360
|
}) : t(e.value));
|
|
@@ -370,10 +363,10 @@ class le {
|
|
|
370
363
|
immediate: !0,
|
|
371
364
|
deep: !0
|
|
372
365
|
}
|
|
373
|
-
) :
|
|
366
|
+
) : k(e) ? I(
|
|
374
367
|
() => e,
|
|
375
368
|
() => {
|
|
376
|
-
|
|
369
|
+
l.isUndefined(e) || (s && l.isObject(e) ? this.objectParser({
|
|
377
370
|
data: e,
|
|
378
371
|
updater: t
|
|
379
372
|
}) : t(e));
|
|
@@ -382,7 +375,7 @@ class le {
|
|
|
382
375
|
immediate: !0,
|
|
383
376
|
deep: !0
|
|
384
377
|
}
|
|
385
|
-
) : s &&
|
|
378
|
+
) : s && l.isObject(e) ? this.objectParser({
|
|
386
379
|
data: e,
|
|
387
380
|
updater: t
|
|
388
381
|
}) : t(e);
|
|
@@ -390,50 +383,100 @@ class le {
|
|
|
390
383
|
modelProcessor(e) {
|
|
391
384
|
e.map(
|
|
392
385
|
(t) => this.createModel(t, this.processedModel.value)
|
|
393
|
-
),
|
|
386
|
+
), l.isObjectEmpty(this.stableModel) && this.stableUpdaterProcessProgress.every(Boolean) && this.defaultValueEffect.effects.size === 0 && (this.stableModel = g(this.processedModel.value), this.runtimeCore.hydrateEffect.triggerEffects(), this.runtimeCore.hydrateEffect.clearEffects());
|
|
394
387
|
}
|
|
395
388
|
createModel(e, t) {
|
|
396
|
-
|
|
389
|
+
l.isListSchema(e) && (t[e.field] || (t[e.field] = [{}]), e.children.forEach((s) => {
|
|
397
390
|
this.createModel(s, t[e.field][0]);
|
|
398
|
-
})),
|
|
391
|
+
})), l.isGroupSchema(e) && e.children.forEach((s) => {
|
|
399
392
|
this.createModel(s, t);
|
|
400
|
-
}),
|
|
393
|
+
}), l.isItemSchema(e) && (t[e.field] = e.defaultValue);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
class F {
|
|
397
|
+
static getFormContainer({ ui: e } = {}) {
|
|
398
|
+
return f.presets.uiPresets[e ?? f.presets.ui].container.Form;
|
|
399
|
+
}
|
|
400
|
+
static getFormItemContainer({ ui: e } = {}) {
|
|
401
|
+
return f.presets.uiPresets[e ?? f.presets.ui].container.FormItem;
|
|
402
|
+
}
|
|
403
|
+
static getItemContainer({ ui: e } = {}) {
|
|
404
|
+
return f.presets.uiPresets[e ?? f.presets.ui].container.Item;
|
|
405
|
+
}
|
|
406
|
+
static getGroupContainer({ ui: e } = {}) {
|
|
407
|
+
return f.presets.uiPresets[e ?? f.presets.ui].container.Group;
|
|
408
|
+
}
|
|
409
|
+
static getListContainer({ ui: e } = {}) {
|
|
410
|
+
return f.presets.uiPresets[e ?? f.presets.ui].container.List;
|
|
411
|
+
}
|
|
412
|
+
static getListItemContainer({ ui: e } = {}) {
|
|
413
|
+
return f.presets.uiPresets[e ?? f.presets.ui].container.ListItem;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
class de {
|
|
417
|
+
constructor(e) {
|
|
418
|
+
this.ui = e;
|
|
419
|
+
}
|
|
420
|
+
getRuntimeField(e) {
|
|
421
|
+
var i;
|
|
422
|
+
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = b.adapters[this.ui];
|
|
423
|
+
return (t == null ? void 0 : t.getRuntimeField(e)) ?? (s == null ? void 0 : s.getRuntimeField(e));
|
|
424
|
+
}
|
|
425
|
+
getRuntimeRequired(e) {
|
|
426
|
+
var i;
|
|
427
|
+
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = b.adapters[this.ui];
|
|
428
|
+
return (t == null ? void 0 : t.getRuntimeRequired(e)) ?? (s == null ? void 0 : s.getRuntimeRequired(e));
|
|
429
|
+
}
|
|
430
|
+
getFormModelPropName() {
|
|
431
|
+
var s;
|
|
432
|
+
const e = (s = f.presets.uiPresets[this.ui]) == null ? void 0 : s.adapter, t = b.adapters[this.ui];
|
|
433
|
+
return (e == null ? void 0 : e.getFormModelPropName()) ?? (t == null ? void 0 : t.getFormModelPropName());
|
|
434
|
+
}
|
|
435
|
+
formComponentRenderer(e) {
|
|
436
|
+
var i;
|
|
437
|
+
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = b.adapters[this.ui];
|
|
438
|
+
return (t == null ? void 0 : t.formComponentRenderer(e)) ?? (s == null ? void 0 : s.formComponentRenderer(e));
|
|
439
|
+
}
|
|
440
|
+
clearValidate(e) {
|
|
441
|
+
var i;
|
|
442
|
+
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = b.adapters[this.ui];
|
|
443
|
+
return (t == null ? void 0 : t.clearValidate(e)) ?? (s == null ? void 0 : s.clearValidate(e));
|
|
401
444
|
}
|
|
402
445
|
}
|
|
403
|
-
function
|
|
404
|
-
return typeof
|
|
446
|
+
function pe(r) {
|
|
447
|
+
return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !ae(r);
|
|
405
448
|
}
|
|
406
|
-
class
|
|
449
|
+
class he {
|
|
407
450
|
constructor(e) {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
451
|
+
a(this, "schemas", q([]));
|
|
452
|
+
a(this, "model", q({}));
|
|
453
|
+
a(this, "processorBySchemaType", {
|
|
411
454
|
item: this.runtimeItemProcessor.bind(this),
|
|
412
455
|
group: this.runtimeGroupProcessor.bind(this),
|
|
413
456
|
list: this.runtimeListProcessor.bind(this)
|
|
414
457
|
});
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
458
|
+
a(this, "formRef", q(null));
|
|
459
|
+
a(this, "hydrateEffect", new U());
|
|
460
|
+
a(this, "native", ne({}));
|
|
461
|
+
a(this, "grid", {});
|
|
462
|
+
a(this, "runtime", {});
|
|
463
|
+
a(this, "globalNativeFormOverride", {
|
|
421
464
|
props: {},
|
|
422
465
|
slots: {}
|
|
423
466
|
});
|
|
424
|
-
this.setup = e, this.processor = new
|
|
467
|
+
this.setup = e, this.processor = new fe(this);
|
|
425
468
|
const t = this.setup(this);
|
|
426
|
-
if (
|
|
427
|
-
const s =
|
|
428
|
-
this.processor.parseSchemas(t.schemas.value),
|
|
469
|
+
if (this.ui = t.ui ?? f.presets.ui, this.runtimeAdapter = new de(this.ui), x(t.schemas)) {
|
|
470
|
+
const s = I(() => t.schemas, () => {
|
|
471
|
+
this.processor.parseSchemas(t.schemas.value), w(() => {
|
|
429
472
|
s();
|
|
430
473
|
});
|
|
431
474
|
}, {
|
|
432
475
|
deep: !0
|
|
433
476
|
});
|
|
434
|
-
} else if (
|
|
435
|
-
const s =
|
|
436
|
-
this.processor.parseSchemas(t.schemas),
|
|
477
|
+
} else if (k(t.schemas)) {
|
|
478
|
+
const s = I(() => t.schemas, () => {
|
|
479
|
+
this.processor.parseSchemas(t.schemas), w(() => {
|
|
437
480
|
s();
|
|
438
481
|
});
|
|
439
482
|
}, {
|
|
@@ -444,65 +487,57 @@ class ae {
|
|
|
444
487
|
}
|
|
445
488
|
getRuntimeMeta() {
|
|
446
489
|
return {
|
|
447
|
-
model:
|
|
490
|
+
model: E(g(this.model.value))
|
|
448
491
|
};
|
|
449
492
|
}
|
|
450
|
-
runtimeItemProcessor(e, t, s = this.model.value,
|
|
451
|
-
var
|
|
452
|
-
|
|
453
|
-
|
|
493
|
+
runtimeItemProcessor(e, t, s = this.model.value, i) {
|
|
494
|
+
var z, $, _, B, D, G, T, K, W, H, J, Q, X;
|
|
495
|
+
const o = E(e.component);
|
|
496
|
+
if (!o)
|
|
497
|
+
return;
|
|
498
|
+
m(this.globalNativeFormOverride.props, ($ = (z = e.native) == null ? void 0 : z.props) == null ? void 0 : $.Form), m(this.globalNativeFormOverride.slots, (B = (_ = e.native) == null ? void 0 : _.slots) == null ? void 0 : B.Form);
|
|
499
|
+
const n = m(g((G = (D = this.native) == null ? void 0 : D.slots) == null ? void 0 : G.FormItem) ?? {}, (K = (T = e.native) == null ? void 0 : T.slots) == null ? void 0 : K.FormItem), u = {
|
|
454
500
|
display: "grid",
|
|
455
501
|
gridColumn: "1 / -1",
|
|
456
|
-
...e.
|
|
457
|
-
},
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}), b = `${p}${S}`);
|
|
502
|
+
...e.grid
|
|
503
|
+
}, c = m(g((H = (W = this.native) == null ? void 0 : W.props) == null ? void 0 : H.FormItem) ?? {}, (Q = (J = e.native) == null ? void 0 : J.props) == null ? void 0 : Q.FormItem), d = this.runtimeAdapter.getRuntimeField({
|
|
504
|
+
schema: e,
|
|
505
|
+
parentSchema: i,
|
|
506
|
+
index: t
|
|
507
|
+
}), y = o.name, O = e.componentProps ?? {}, C = b.placeholderPresetByComponentName;
|
|
508
|
+
let v = e.placeholder, P = e.show;
|
|
509
|
+
P === void 0 && (P = !0), P || delete s[e.field];
|
|
510
|
+
let h = e.label;
|
|
511
|
+
const V = (i == null ? void 0 : i.runtime) ?? this.runtime;
|
|
512
|
+
if (!l.isUndefined(t) && !l.isObjectEmpty(V) && (h = N((X = V == null ? void 0 : V.customizeItemLabel) == null ? void 0 : X.call(V, e.label ?? "", t + 1), "")), !v) {
|
|
513
|
+
let S = "请输入";
|
|
514
|
+
l.isUndefined(y) ? v = `${S}${h}` : /* @ts-expect-error */ C[y.toLowerCase()] ? (S = // @ts-expect-error
|
|
515
|
+
C[y.toLowerCase()], v = `${S}${h}`) : (Object.keys(C).forEach((Y) => {
|
|
516
|
+
y.toLowerCase().includes(Y.toLowerCase()) && (S = C[Y]);
|
|
517
|
+
}), v = `${S}${h}`);
|
|
473
518
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
});
|
|
480
|
-
else {
|
|
481
|
-
const p = e.rules.findIndex((C) => !f.isUndefined(C.required));
|
|
482
|
-
p !== -1 && (e.rules[p].required = !0, e.rules[p].message = `${S}是必填项`);
|
|
483
|
-
}
|
|
484
|
-
else if (e.rules) {
|
|
485
|
-
const p = (X = e.rules) == null ? void 0 : X.findIndex((C) => !!C.required);
|
|
486
|
-
p !== -1 && (e.rules[p].required = !1);
|
|
487
|
-
}
|
|
488
|
-
return c("div", {
|
|
519
|
+
const ee = this.runtimeAdapter.getRuntimeRequired({
|
|
520
|
+
...e,
|
|
521
|
+
label: h
|
|
522
|
+
}), te = F.getItemContainer(this), se = F.getFormItemContainer(this), re = this;
|
|
523
|
+
return p("div", {
|
|
489
524
|
style: u
|
|
490
|
-
}, [
|
|
525
|
+
}, [p(te, null, {
|
|
491
526
|
default() {
|
|
492
|
-
return
|
|
493
|
-
label: `${
|
|
494
|
-
|
|
495
|
-
field: a
|
|
496
|
-
}), {
|
|
527
|
+
return Z(p(se, R(c, {
|
|
528
|
+
label: `${h}:`
|
|
529
|
+
}, d, ee), {
|
|
497
530
|
default() {
|
|
498
|
-
return
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
531
|
+
return re.runtimeAdapter.formComponentRenderer({
|
|
532
|
+
Component: o,
|
|
533
|
+
schema: e,
|
|
534
|
+
baseModel: s,
|
|
535
|
+
placeholder: v,
|
|
536
|
+
props: O
|
|
537
|
+
});
|
|
503
538
|
},
|
|
504
539
|
...n
|
|
505
|
-
}), [[
|
|
540
|
+
}), [[A, P]]);
|
|
506
541
|
}
|
|
507
542
|
})]);
|
|
508
543
|
}
|
|
@@ -511,13 +546,13 @@ class ae {
|
|
|
511
546
|
const s = {
|
|
512
547
|
display: "grid",
|
|
513
548
|
gridColumn: "1 / -1",
|
|
514
|
-
...e.
|
|
515
|
-
};
|
|
516
|
-
return
|
|
549
|
+
...e.grid
|
|
550
|
+
}, i = F.getGroupContainer(this);
|
|
551
|
+
return p("div", {
|
|
517
552
|
style: s
|
|
518
|
-
}, [
|
|
553
|
+
}, [p(i, {
|
|
519
554
|
schema: e
|
|
520
|
-
},
|
|
555
|
+
}, pe(t = e.children.map((o) => this.runtimeItemProcessor(o))) ? t : {
|
|
521
556
|
default: () => [t]
|
|
522
557
|
})]);
|
|
523
558
|
}
|
|
@@ -528,43 +563,45 @@ class ae {
|
|
|
528
563
|
code: "0001",
|
|
529
564
|
message: "异步默认值数据正在处理中,请您耐心等待... "
|
|
530
565
|
});
|
|
531
|
-
(s = this.processor.stableModel[e.field]) != null && s[0] && this.model.value[e.field].push(g(this.processor.stableModel[e.field][0])), this.
|
|
566
|
+
(s = this.processor.stableModel[e.field]) != null && s[0] && this.model.value[e.field].push(g(this.processor.stableModel[e.field][0])), this.runtimeAdapter.clearValidate(this);
|
|
532
567
|
}
|
|
533
568
|
deleteListItem(e, t) {
|
|
534
|
-
this.model.value[e.field].splice(t, 1), this.
|
|
569
|
+
this.model.value[e.field].splice(t, 1), this.runtimeAdapter.clearValidate(this);
|
|
535
570
|
}
|
|
536
571
|
runtimeListProcessor(e) {
|
|
537
572
|
const t = {
|
|
538
573
|
display: "grid",
|
|
539
574
|
gridColumn: "1 / -1",
|
|
540
|
-
...e.
|
|
575
|
+
...e.grid
|
|
541
576
|
}, s = this;
|
|
542
|
-
|
|
577
|
+
s.model.value[e.field] || (s.model.value[e.field] = [{}]);
|
|
578
|
+
const i = F.getListContainer(this), o = F.getListItemContainer(this);
|
|
579
|
+
return p("div", {
|
|
543
580
|
style: t
|
|
544
|
-
}, [
|
|
581
|
+
}, [p(i, {
|
|
545
582
|
schema: e
|
|
546
583
|
}, {
|
|
547
584
|
default() {
|
|
548
|
-
return s.model.value[e.field].map((
|
|
585
|
+
return s.model.value[e.field].map((n, u) => p(o, null, {
|
|
549
586
|
default() {
|
|
550
|
-
return e.children.map((
|
|
587
|
+
return e.children.map((c) => s.runtimeItemProcessor(c, u, n, e));
|
|
551
588
|
},
|
|
552
589
|
delete({
|
|
553
|
-
container:
|
|
590
|
+
container: c
|
|
554
591
|
} = {}) {
|
|
555
|
-
var
|
|
556
|
-
let
|
|
557
|
-
return
|
|
558
|
-
onClick: () => s.deleteListItem(e,
|
|
559
|
-
}, null), [[
|
|
592
|
+
var y;
|
|
593
|
+
let d = c ?? p("button", null, null);
|
|
594
|
+
return Z(p(d, {
|
|
595
|
+
onClick: () => s.deleteListItem(e, u)
|
|
596
|
+
}, null), [[A, ((y = s.model.value[e.field]) == null ? void 0 : y.length) > 1]]);
|
|
560
597
|
}
|
|
561
598
|
}));
|
|
562
599
|
},
|
|
563
600
|
add({
|
|
564
|
-
container:
|
|
601
|
+
container: n
|
|
565
602
|
} = {}) {
|
|
566
|
-
let
|
|
567
|
-
return
|
|
603
|
+
let u = n ?? p("button", null, [le("添加")]);
|
|
604
|
+
return p(u, {
|
|
568
605
|
onClick: () => s.addListItem(e)
|
|
569
606
|
}, null);
|
|
570
607
|
}
|
|
@@ -574,43 +611,212 @@ class ae {
|
|
|
574
611
|
return e.map((t) => (t.type || (t.type = "item"), this.processorBySchemaType[t.type](t)));
|
|
575
612
|
}
|
|
576
613
|
exec() {
|
|
577
|
-
var
|
|
614
|
+
var u, c, d, y;
|
|
578
615
|
const e = {
|
|
579
616
|
display: "grid",
|
|
580
617
|
gridColumn: "1 / -1",
|
|
581
618
|
gridAutoColumns: "1fr",
|
|
582
|
-
...this.
|
|
583
|
-
}, t = this, s = m(g((
|
|
584
|
-
return
|
|
585
|
-
ref: this.formRef
|
|
586
|
-
|
|
619
|
+
...this.grid
|
|
620
|
+
}, t = this, s = m(g((c = (u = this.native) == null ? void 0 : u.props) == null ? void 0 : c.Form) ?? {}, this.globalNativeFormOverride.props), i = m(g((y = (d = this.native) == null ? void 0 : d.slots) == null ? void 0 : y.Form) ?? {}, this.globalNativeFormOverride.slots), o = F.getFormContainer(this), n = this.runtimeAdapter.getFormModelPropName();
|
|
621
|
+
return p(o, R(s, {
|
|
622
|
+
ref: this.formRef
|
|
623
|
+
}, {
|
|
624
|
+
[n]: this.model.value
|
|
587
625
|
}), {
|
|
588
626
|
default() {
|
|
589
|
-
return
|
|
627
|
+
return p("div", {
|
|
590
628
|
style: e
|
|
591
629
|
}, [t.runtimeProcessor(t.schemas.value)]);
|
|
592
630
|
},
|
|
593
|
-
...
|
|
631
|
+
...i
|
|
594
632
|
});
|
|
595
633
|
}
|
|
596
634
|
}
|
|
597
|
-
class
|
|
635
|
+
class f {
|
|
636
|
+
}
|
|
637
|
+
a(f, "presets");
|
|
638
|
+
function M({
|
|
639
|
+
parentSchema: r,
|
|
640
|
+
schema: e,
|
|
641
|
+
index: t
|
|
642
|
+
}) {
|
|
643
|
+
return r ? `${r.field}.${t}.${e.field}` : e.field;
|
|
598
644
|
}
|
|
599
|
-
|
|
600
|
-
|
|
645
|
+
const me = {
|
|
646
|
+
ArcoVue: {
|
|
647
|
+
getRuntimeField(r) {
|
|
648
|
+
return {
|
|
649
|
+
field: M(r)
|
|
650
|
+
};
|
|
651
|
+
},
|
|
652
|
+
getRuntimeRequired(r) {
|
|
653
|
+
var e, t;
|
|
654
|
+
if (r.required)
|
|
655
|
+
if (!r.rules)
|
|
656
|
+
r.rules = [], (e = r.rules) == null || e.push({
|
|
657
|
+
required: !0,
|
|
658
|
+
message: `${r.label}是必填项`
|
|
659
|
+
});
|
|
660
|
+
else {
|
|
661
|
+
const s = r.rules.findIndex((i) => !l.isUndefined(i.required));
|
|
662
|
+
s !== -1 && (r.rules[s].required = !0, r.rules[s].message = `${r.label}是必填项`);
|
|
663
|
+
}
|
|
664
|
+
else if (r.rules) {
|
|
665
|
+
const s = (t = r.rules) == null ? void 0 : t.findIndex((i) => !!i.required);
|
|
666
|
+
s !== -1 && (r.rules[s].required = !1);
|
|
667
|
+
}
|
|
668
|
+
return {
|
|
669
|
+
rules: r.rules
|
|
670
|
+
};
|
|
671
|
+
},
|
|
672
|
+
getFormModelPropName() {
|
|
673
|
+
return "model";
|
|
674
|
+
},
|
|
675
|
+
formComponentRenderer({
|
|
676
|
+
Component: r,
|
|
677
|
+
baseModel: e,
|
|
678
|
+
schema: t,
|
|
679
|
+
placeholder: s,
|
|
680
|
+
props: i
|
|
681
|
+
}) {
|
|
682
|
+
return p(r, R({
|
|
683
|
+
modelValue: e[t.field],
|
|
684
|
+
"onUpdate:modelValue": (o) => e[t.field] = o,
|
|
685
|
+
placeholder: s
|
|
686
|
+
}, i), null);
|
|
687
|
+
},
|
|
688
|
+
validateForm(r) {
|
|
689
|
+
return new Promise((e, t) => {
|
|
690
|
+
r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(E(r.runtimeCore.processor.processedModel.value))));
|
|
691
|
+
});
|
|
692
|
+
},
|
|
693
|
+
clearValidate(r) {
|
|
694
|
+
r.formRef.value.clearValidate();
|
|
695
|
+
}
|
|
696
|
+
},
|
|
697
|
+
NutUI: {
|
|
698
|
+
getRuntimeField(r) {
|
|
699
|
+
return {
|
|
700
|
+
prop: M(r)
|
|
701
|
+
};
|
|
702
|
+
},
|
|
703
|
+
getRuntimeRequired(r) {
|
|
704
|
+
var e, t;
|
|
705
|
+
if (r.required)
|
|
706
|
+
if (!r.rules)
|
|
707
|
+
r.rules = [], (e = r.rules) == null || e.push({
|
|
708
|
+
required: !0,
|
|
709
|
+
message: `${r.label}是必填项`
|
|
710
|
+
});
|
|
711
|
+
else {
|
|
712
|
+
const s = r.rules.findIndex((i) => !l.isUndefined(i.required));
|
|
713
|
+
s !== -1 && (r.rules[s].required = !0, r.rules[s].message = `${r.label}是必填项`);
|
|
714
|
+
}
|
|
715
|
+
else if (r.rules) {
|
|
716
|
+
const s = (t = r.rules) == null ? void 0 : t.findIndex((i) => !!i.required);
|
|
717
|
+
s !== -1 && (r.rules[s].required = !1);
|
|
718
|
+
}
|
|
719
|
+
return {
|
|
720
|
+
rules: r.rules,
|
|
721
|
+
required: r.required
|
|
722
|
+
};
|
|
723
|
+
},
|
|
724
|
+
getFormModelPropName() {
|
|
725
|
+
return "modelValue";
|
|
726
|
+
},
|
|
727
|
+
formComponentRenderer({
|
|
728
|
+
Component: r,
|
|
729
|
+
baseModel: e,
|
|
730
|
+
schema: t,
|
|
731
|
+
placeholder: s,
|
|
732
|
+
props: i
|
|
733
|
+
}) {
|
|
734
|
+
return p(r, R({
|
|
735
|
+
modelValue: e[t.field],
|
|
736
|
+
"onUpdate:modelValue": (o) => e[t.field] = o,
|
|
737
|
+
placeholder: s
|
|
738
|
+
}, i), null);
|
|
739
|
+
},
|
|
740
|
+
validateForm(r) {
|
|
741
|
+
return new Promise((e, t) => {
|
|
742
|
+
r.runtimeCore.formRef.value.validate().then(({
|
|
743
|
+
valid: s,
|
|
744
|
+
errors: i
|
|
745
|
+
}) => {
|
|
746
|
+
s ? e(r.cleanFallbackFields(E(r.runtimeCore.processor.processedModel.value))) : t(i);
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
},
|
|
750
|
+
clearValidate(r) {
|
|
751
|
+
r.formRef.value.reset();
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
NaiveUI: {
|
|
755
|
+
getRuntimeField(r) {
|
|
756
|
+
return {
|
|
757
|
+
path: M(r)
|
|
758
|
+
};
|
|
759
|
+
},
|
|
760
|
+
getRuntimeRequired(r) {
|
|
761
|
+
var e, t;
|
|
762
|
+
if (r.required)
|
|
763
|
+
if (!r.rules)
|
|
764
|
+
r.rules = [], (e = r.rules) == null || e.push({
|
|
765
|
+
required: !0,
|
|
766
|
+
message: `${r.label}是必填项`,
|
|
767
|
+
trigger: ["input", "blur"]
|
|
768
|
+
});
|
|
769
|
+
else {
|
|
770
|
+
const s = r.rules.findIndex((i) => !l.isUndefined(i.required));
|
|
771
|
+
s !== -1 && (r.rules[s].required = !0, r.rules[s].message = `${r.label}是必填项`);
|
|
772
|
+
}
|
|
773
|
+
else if (r.rules) {
|
|
774
|
+
const s = (t = r.rules) == null ? void 0 : t.findIndex((i) => !!i.required);
|
|
775
|
+
s !== -1 && (r.rules[s].required = !1);
|
|
776
|
+
}
|
|
777
|
+
return {
|
|
778
|
+
rule: r.rules
|
|
779
|
+
};
|
|
780
|
+
},
|
|
781
|
+
getFormModelPropName() {
|
|
782
|
+
return "model";
|
|
783
|
+
},
|
|
784
|
+
formComponentRenderer({
|
|
785
|
+
Component: r,
|
|
786
|
+
baseModel: e,
|
|
787
|
+
schema: t,
|
|
788
|
+
placeholder: s,
|
|
789
|
+
props: i
|
|
790
|
+
}) {
|
|
791
|
+
return p(r, R({
|
|
792
|
+
value: e[t.field],
|
|
793
|
+
"onUpdate:value": (o) => e[t.field] = o,
|
|
794
|
+
placeholder: s
|
|
795
|
+
}, i), null);
|
|
796
|
+
},
|
|
797
|
+
validateForm(r) {
|
|
798
|
+
return new Promise((e, t) => {
|
|
799
|
+
r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(E(r.runtimeCore.processor.processedModel.value))));
|
|
800
|
+
});
|
|
801
|
+
},
|
|
802
|
+
clearValidate(r) {
|
|
803
|
+
r.formRef.value.restoreValidation();
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}, j = class j {
|
|
601
807
|
static getPlaceholderPrefixPresetByComponentName() {
|
|
602
808
|
const e = {
|
|
603
|
-
请选择: ["select", "tree"
|
|
809
|
+
请选择: ["select", "tree"],
|
|
604
810
|
请输入: ["input"]
|
|
605
811
|
}, t = {};
|
|
606
812
|
for (let s in e)
|
|
607
|
-
e[s].forEach((
|
|
608
|
-
t[
|
|
813
|
+
e[s].forEach((i) => {
|
|
814
|
+
t[i] = s;
|
|
609
815
|
});
|
|
610
816
|
return t;
|
|
611
817
|
}
|
|
612
818
|
};
|
|
613
|
-
|
|
819
|
+
a(j, "schemaPreset", {
|
|
614
820
|
type: {
|
|
615
821
|
defaultValue: "item"
|
|
616
822
|
},
|
|
@@ -644,29 +850,38 @@ l(V, "schemaPreset", {
|
|
|
644
850
|
children: {
|
|
645
851
|
defaultValue: []
|
|
646
852
|
},
|
|
647
|
-
native:
|
|
648
|
-
|
|
649
|
-
}
|
|
853
|
+
native: {
|
|
854
|
+
defaultValue: void 0
|
|
855
|
+
},
|
|
856
|
+
grid: {
|
|
857
|
+
default: void 0
|
|
858
|
+
}
|
|
859
|
+
}), a(j, "componentPropsPreset", {
|
|
650
860
|
options: {
|
|
651
861
|
defaultValue: []
|
|
652
862
|
}
|
|
653
863
|
}), // 基于基本功能提出基本预设
|
|
654
|
-
|
|
655
|
-
let
|
|
656
|
-
const
|
|
864
|
+
a(j, "placeholderPresetByComponentName", j.getPlaceholderPrefixPresetByComponentName());
|
|
865
|
+
let L = j;
|
|
866
|
+
const b = {
|
|
867
|
+
...L,
|
|
868
|
+
adapters: {
|
|
869
|
+
...me
|
|
870
|
+
}
|
|
871
|
+
}, be = /* @__PURE__ */ ue({
|
|
657
872
|
props: {
|
|
658
873
|
setup: {
|
|
659
874
|
type: Function,
|
|
660
875
|
required: !0
|
|
661
876
|
}
|
|
662
877
|
},
|
|
663
|
-
setup(
|
|
664
|
-
const e = new
|
|
878
|
+
setup(r) {
|
|
879
|
+
const e = new he(r.setup);
|
|
665
880
|
return () => e.exec();
|
|
666
881
|
}
|
|
667
882
|
});
|
|
668
|
-
function
|
|
669
|
-
const e = new
|
|
883
|
+
function ve(r) {
|
|
884
|
+
const e = new ce(r);
|
|
670
885
|
return [
|
|
671
886
|
e.setup.bind(e),
|
|
672
887
|
{
|
|
@@ -675,22 +890,18 @@ function pe(o) {
|
|
|
675
890
|
}
|
|
676
891
|
];
|
|
677
892
|
}
|
|
678
|
-
function
|
|
679
|
-
|
|
680
|
-
install() {
|
|
681
|
-
P.runtimeDoms = o;
|
|
682
|
-
}
|
|
683
|
-
};
|
|
893
|
+
function ge(r) {
|
|
894
|
+
f.presets = r;
|
|
684
895
|
}
|
|
685
|
-
function
|
|
686
|
-
return e === "raw" && Object.defineProperty(
|
|
687
|
-
value: `__proform_raw_${
|
|
896
|
+
function Ce(r, e) {
|
|
897
|
+
return e === "raw" && Object.defineProperty(r, "name", {
|
|
898
|
+
value: `__proform_raw_${r.name}`,
|
|
688
899
|
writable: !0
|
|
689
|
-
}),
|
|
900
|
+
}), r;
|
|
690
901
|
}
|
|
691
902
|
export {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
903
|
+
be as ProForm,
|
|
904
|
+
ve as useForm,
|
|
905
|
+
ge as useFormPresetConfigurer,
|
|
906
|
+
Ce as useModifiers
|
|
696
907
|
};
|