@harbor-design/proform 1.1.30 → 1.1.32
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.js +134 -103
- package/dist/types/index.d.ts +1 -2
- package/dist/types/src/interactions/useModifiers.d.ts +2 -1
- package/dist/types/src/services/FormCustomizer/index.d.ts +1 -0
- package/dist/types/src/services/RuntimeCore/index.d.ts +2 -0
- package/dist/types/src/types/formCustomizerTypes.d.ts +1 -0
- package/dist/types/src/types/useFormTypes.d.ts +1 -0
- package/dist/types/src/utils/is.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var re = Object.defineProperty;
|
|
2
2
|
var ie = (r, e, t) => e in r ? re(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var a = (r, e, t) => (ie(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
import { isRef as
|
|
4
|
+
import { isRef as O, watch as P, isReactive as q, toRaw as S, nextTick as N, ref as M, reactive as oe, createVNode as p, mergeProps as R, withDirectives as ne, vShow as le, createTextVNode as ae, isVNode as ue, defineComponent as ce } from "vue";
|
|
5
5
|
class l {
|
|
6
6
|
static typeChecker(e) {
|
|
7
7
|
return {}.toString.call(e);
|
|
@@ -62,19 +62,22 @@ class l {
|
|
|
62
62
|
}
|
|
63
63
|
return !1;
|
|
64
64
|
}
|
|
65
|
+
static isNativeObject(e) {
|
|
66
|
+
return !!e.__proform_raw_object;
|
|
67
|
+
}
|
|
65
68
|
}
|
|
66
|
-
function
|
|
69
|
+
function h(r, ...e) {
|
|
67
70
|
return e.forEach((t) => {
|
|
68
71
|
if (Array.isArray(t))
|
|
69
72
|
Array.isArray(r) || (r = []), t.forEach((s, i) => {
|
|
70
|
-
typeof s == "object" && s !== null ? r[i] =
|
|
73
|
+
typeof s == "object" && s !== null ? r[i] = h(Array.isArray(s) ? [] : {}, s) : r[i] = s;
|
|
71
74
|
});
|
|
72
75
|
else
|
|
73
76
|
for (const s in t)
|
|
74
|
-
t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ? r[s] =
|
|
77
|
+
t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ? r[s] = h(r[s] || {}, t[s]) : r[s] = t[s]);
|
|
75
78
|
}), r;
|
|
76
79
|
}
|
|
77
|
-
function
|
|
80
|
+
function C(r) {
|
|
78
81
|
const e = /* @__PURE__ */ new WeakMap();
|
|
79
82
|
function t(s) {
|
|
80
83
|
if (s === null || typeof s != "object")
|
|
@@ -112,7 +115,7 @@ function g(r) {
|
|
|
112
115
|
}
|
|
113
116
|
return t(r);
|
|
114
117
|
}
|
|
115
|
-
function
|
|
118
|
+
function L(r, e) {
|
|
116
119
|
return r.replace(/undefined/g, e);
|
|
117
120
|
}
|
|
118
121
|
class fe {
|
|
@@ -131,7 +134,7 @@ class fe {
|
|
|
131
134
|
}
|
|
132
135
|
submit() {
|
|
133
136
|
var s;
|
|
134
|
-
const e = (s = f.presets.uiPresets[this.runtimeCore.ui]) == null ? void 0 : s.adapter, t =
|
|
137
|
+
const e = (s = f.presets.uiPresets[this.runtimeCore.ui]) == null ? void 0 : s.adapter, t = v.adapters[this.runtimeCore.ui];
|
|
135
138
|
return (e == null ? void 0 : e.validateForm(this)) ?? (t == null ? void 0 : t.validateForm(this));
|
|
136
139
|
}
|
|
137
140
|
hydrate(e) {
|
|
@@ -142,33 +145,54 @@ class fe {
|
|
|
142
145
|
});
|
|
143
146
|
this.runtimeCore.hydrateEffect.trackEffect(
|
|
144
147
|
() => {
|
|
145
|
-
|
|
148
|
+
O(e) ? P(
|
|
146
149
|
() => e.value,
|
|
147
150
|
() => {
|
|
148
|
-
|
|
151
|
+
h(this.runtimeCore.model.value, e.value);
|
|
149
152
|
},
|
|
150
153
|
{
|
|
151
154
|
deep: !0,
|
|
152
155
|
immediate: !0
|
|
153
156
|
}
|
|
154
|
-
) :
|
|
157
|
+
) : q(e) ? P(
|
|
155
158
|
() => e,
|
|
156
159
|
() => {
|
|
157
|
-
|
|
160
|
+
h(this.runtimeCore.model.value, e);
|
|
158
161
|
},
|
|
159
162
|
{
|
|
160
163
|
deep: !0,
|
|
161
164
|
immediate: !0
|
|
162
165
|
}
|
|
163
|
-
) :
|
|
166
|
+
) : h(this.runtimeCore.model.value, e);
|
|
164
167
|
},
|
|
165
168
|
{
|
|
166
169
|
lazy: !0
|
|
167
170
|
}
|
|
168
171
|
);
|
|
169
172
|
}
|
|
173
|
+
share(e) {
|
|
174
|
+
O(e) ? P(
|
|
175
|
+
() => e.value,
|
|
176
|
+
() => {
|
|
177
|
+
h(this.runtimeCore.shared, e.value), this.runtimeCore.processor.schemaEffect.triggerEffects();
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
deep: !0,
|
|
181
|
+
immediate: !0
|
|
182
|
+
}
|
|
183
|
+
) : q(e) ? P(
|
|
184
|
+
() => e,
|
|
185
|
+
() => {
|
|
186
|
+
h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects();
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
deep: !0,
|
|
190
|
+
immediate: !0
|
|
191
|
+
}
|
|
192
|
+
) : (h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects());
|
|
193
|
+
}
|
|
170
194
|
}
|
|
171
|
-
class
|
|
195
|
+
class _ {
|
|
172
196
|
constructor() {
|
|
173
197
|
a(this, "effects", /* @__PURE__ */ new Set());
|
|
174
198
|
}
|
|
@@ -192,16 +216,16 @@ class de {
|
|
|
192
216
|
a(this, "getRuntimeMeta");
|
|
193
217
|
a(this, "stableSchemas", []);
|
|
194
218
|
a(this, "stableModel", {});
|
|
195
|
-
a(this, "schemaPreset",
|
|
196
|
-
a(this, "componentPropsPreset",
|
|
219
|
+
a(this, "schemaPreset", v.schemaPreset);
|
|
220
|
+
a(this, "componentPropsPreset", v.componentPropsPreset);
|
|
197
221
|
a(this, "stableUpdaterProcessProgress");
|
|
198
222
|
a(this, "stableUpdaterTimes", 0);
|
|
199
|
-
a(this, "schemaEffect", new
|
|
200
|
-
a(this, "defaultValueEffect", new
|
|
223
|
+
a(this, "schemaEffect", new _());
|
|
224
|
+
a(this, "defaultValueEffect", new _());
|
|
201
225
|
a(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
|
|
202
226
|
a(this, "baseDefaultValueFunctionsLength");
|
|
203
227
|
a(this, "isModelInitialized", !0);
|
|
204
|
-
this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e),
|
|
228
|
+
this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), P(
|
|
205
229
|
() => this.processedModel.value,
|
|
206
230
|
() => {
|
|
207
231
|
this.schemaEffect.triggerEffects();
|
|
@@ -239,7 +263,7 @@ class de {
|
|
|
239
263
|
// 派生过程,用于外部应用
|
|
240
264
|
parseSchemas(e, t) {
|
|
241
265
|
l.isArrayEmpty(this.processedSchemas.value) && (this.baseDefaultValueFunctionsLength = this.countFunctionDefaultValues(
|
|
242
|
-
|
|
266
|
+
C(e)
|
|
243
267
|
), this.processedSchemas.value = this.initSchemas(e)), this.parse(e, t);
|
|
244
268
|
}
|
|
245
269
|
parseStable(e) {
|
|
@@ -253,7 +277,7 @@ class de {
|
|
|
253
277
|
// 对于稳定初始化更新的抽象
|
|
254
278
|
stableUpdater(e = []) {
|
|
255
279
|
if (e.every(Boolean)) {
|
|
256
|
-
const t =
|
|
280
|
+
const t = S(this.processedSchemas.value);
|
|
257
281
|
!l.isProcessInprogress(t) && l.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
|
|
258
282
|
length: t.length
|
|
259
283
|
}).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
|
|
@@ -266,17 +290,17 @@ class de {
|
|
|
266
290
|
}).fill(!1);
|
|
267
291
|
this.objectParser({ data: e, index: t, updater: n });
|
|
268
292
|
function n(c) {
|
|
269
|
-
const u = c.index, d = c.key,
|
|
293
|
+
const u = c.index, d = c.key, b = c.keyIndex;
|
|
270
294
|
if (l.isUndefined(c.stable))
|
|
271
295
|
return;
|
|
272
|
-
const V = i.parseStable(c.stable),
|
|
273
|
-
let
|
|
274
|
-
if (l.isProcessInprogress(
|
|
275
|
-
const
|
|
276
|
-
|
|
296
|
+
const V = i.parseStable(c.stable), I = s == null ? void 0 : s.index, g = s == null ? void 0 : s.key;
|
|
297
|
+
let y = V;
|
|
298
|
+
if (l.isProcessInprogress(y) || (o[b] = !0), s) {
|
|
299
|
+
const m = i.processedSchemas.value[I][g][u][d];
|
|
300
|
+
m && l.isObject(m) && d !== "component" && (y = h(m, y)), i.processedSchemas.value[I][g][u][d] = y, i.stableUpdater(o);
|
|
277
301
|
} else {
|
|
278
|
-
const
|
|
279
|
-
|
|
302
|
+
const m = i.processedSchemas.value[u][d];
|
|
303
|
+
m && l.isObject(m) && d !== "component" && (y = h(m, y)), i.processedSchemas.value[u][d] = y, i.stableUpdater(o);
|
|
280
304
|
}
|
|
281
305
|
}
|
|
282
306
|
}
|
|
@@ -318,13 +342,13 @@ class de {
|
|
|
318
342
|
return n(u);
|
|
319
343
|
this.defaultValueInprogressMap.set(t[i], u), !l.isProcessInprogress(u) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
|
|
320
344
|
this.defaultValueInprogressMap.values()
|
|
321
|
-
).every((d) => !d.includes("undefined")) ? (n(u), this.defaultValueEffect.clearEffects(),
|
|
345
|
+
).every((d) => !d.includes("undefined")) ? (n(u), this.defaultValueEffect.clearEffects(), N(() => {
|
|
322
346
|
c();
|
|
323
347
|
})) : n(u);
|
|
324
348
|
}) : this.fieldParser(t[i], (u) => {
|
|
325
349
|
this.defaultValueInprogressMap.set(t[i], u), !l.isProcessInprogress(u) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
|
|
326
350
|
this.defaultValueInprogressMap.values()
|
|
327
|
-
).every((d) => !d.includes("undefined")) ? (n(u), this.defaultValueEffect.clearEffects(),
|
|
351
|
+
).every((d) => !d.includes("undefined")) ? (n(u), this.defaultValueEffect.clearEffects(), N(() => {
|
|
328
352
|
c();
|
|
329
353
|
})) : n(u);
|
|
330
354
|
});
|
|
@@ -339,11 +363,11 @@ class de {
|
|
|
339
363
|
}
|
|
340
364
|
promiseFieldParser(e, t, s) {
|
|
341
365
|
l.isPromise(e) ? e.then((i) => {
|
|
342
|
-
l.isString(i) && (i =
|
|
366
|
+
l.isString(i) && (i = L(i, "")), s && l.isObject(i) && !l.isNativeObject(i) ? this.objectParser({
|
|
343
367
|
data: i,
|
|
344
368
|
updater: t
|
|
345
369
|
}) : t(i);
|
|
346
|
-
}) : (l.isString(e) && (e =
|
|
370
|
+
}) : (l.isString(e) && (e = L(e, "")), s && l.isObject(e) && !l.isNativeObject(e) ? this.objectParser({
|
|
347
371
|
data: e,
|
|
348
372
|
updater: t
|
|
349
373
|
}) : t(e));
|
|
@@ -363,10 +387,10 @@ class de {
|
|
|
363
387
|
this.promiseFieldParser(i, t, s);
|
|
364
388
|
}
|
|
365
389
|
else
|
|
366
|
-
|
|
390
|
+
O(e) ? P(
|
|
367
391
|
() => e.value,
|
|
368
392
|
() => {
|
|
369
|
-
l.isUndefined(e.value) || (s && l.isObject(e.value) ? this.objectParser({
|
|
393
|
+
l.isUndefined(e.value) || (s && l.isObject(e.value) && !l.isNativeObject(e.value) ? this.objectParser({
|
|
370
394
|
data: e.value,
|
|
371
395
|
updater: t
|
|
372
396
|
}) : t(e.value));
|
|
@@ -375,10 +399,10 @@ class de {
|
|
|
375
399
|
immediate: !0,
|
|
376
400
|
deep: !0
|
|
377
401
|
}
|
|
378
|
-
) :
|
|
402
|
+
) : q(e) ? P(
|
|
379
403
|
() => e,
|
|
380
404
|
() => {
|
|
381
|
-
l.isUndefined(e) || (s && l.isObject(e) ? this.objectParser({
|
|
405
|
+
l.isUndefined(e) || (s && l.isObject(e) && !l.isNativeObject(e) ? this.objectParser({
|
|
382
406
|
data: e,
|
|
383
407
|
updater: t
|
|
384
408
|
}) : t(e));
|
|
@@ -387,7 +411,7 @@ class de {
|
|
|
387
411
|
immediate: !0,
|
|
388
412
|
deep: !0
|
|
389
413
|
}
|
|
390
|
-
) : s && l.isObject(e) ? this.objectParser({
|
|
414
|
+
) : s && l.isObject(e) && !l.isNativeObject(e) ? this.objectParser({
|
|
391
415
|
data: e,
|
|
392
416
|
updater: t
|
|
393
417
|
}) : t(e);
|
|
@@ -395,7 +419,7 @@ class de {
|
|
|
395
419
|
modelProcessor(e) {
|
|
396
420
|
e.map(
|
|
397
421
|
(t) => this.createModel(t, this.processedModel.value)
|
|
398
|
-
), l.isObjectEmpty(this.stableModel) && this.stableUpdaterProcessProgress.every(Boolean) && this.defaultValueEffect.effects.size === 0 && (this.stableModel =
|
|
422
|
+
), l.isObjectEmpty(this.stableModel) && this.stableUpdaterProcessProgress.every(Boolean) && this.defaultValueEffect.effects.size === 0 && (this.stableModel = C(this.processedModel.value), this.runtimeCore.hydrateEffect.triggerEffects(), this.runtimeCore.hydrateEffect.clearEffects());
|
|
399
423
|
}
|
|
400
424
|
createModel(e, t) {
|
|
401
425
|
l.isListSchema(e) && (t[e.field] || (t[e.field] = [{}]), e.children.forEach((s) => {
|
|
@@ -405,7 +429,7 @@ class de {
|
|
|
405
429
|
}), l.isItemSchema(e) && ("defaultValue" in e ? t[e.field] = e.defaultValue : t[e.field] || (t[e.field] = void 0));
|
|
406
430
|
}
|
|
407
431
|
}
|
|
408
|
-
class
|
|
432
|
+
class E {
|
|
409
433
|
static getFormContainer({ ui: e } = {}) {
|
|
410
434
|
return f.presets.uiPresets[e ?? f.presets.ui].container.Form;
|
|
411
435
|
}
|
|
@@ -431,27 +455,27 @@ class pe {
|
|
|
431
455
|
}
|
|
432
456
|
getRuntimeField(e) {
|
|
433
457
|
var i;
|
|
434
|
-
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s =
|
|
458
|
+
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = v.adapters[this.ui];
|
|
435
459
|
return (t == null ? void 0 : t.getRuntimeField(e)) ?? (s == null ? void 0 : s.getRuntimeField(e));
|
|
436
460
|
}
|
|
437
461
|
getRuntimeRequired(e) {
|
|
438
462
|
var i;
|
|
439
|
-
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s =
|
|
463
|
+
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = v.adapters[this.ui];
|
|
440
464
|
return (t == null ? void 0 : t.getRuntimeRequired(e)) ?? (s == null ? void 0 : s.getRuntimeRequired(e));
|
|
441
465
|
}
|
|
442
466
|
getFormModelPropName() {
|
|
443
467
|
var s;
|
|
444
|
-
const e = (s = f.presets.uiPresets[this.ui]) == null ? void 0 : s.adapter, t =
|
|
468
|
+
const e = (s = f.presets.uiPresets[this.ui]) == null ? void 0 : s.adapter, t = v.adapters[this.ui];
|
|
445
469
|
return (e == null ? void 0 : e.getFormModelPropName()) ?? (t == null ? void 0 : t.getFormModelPropName());
|
|
446
470
|
}
|
|
447
471
|
formComponentRenderer(e) {
|
|
448
472
|
var i;
|
|
449
|
-
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s =
|
|
473
|
+
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = v.adapters[this.ui];
|
|
450
474
|
return (t == null ? void 0 : t.formComponentRenderer(e)) ?? (s == null ? void 0 : s.formComponentRenderer(e));
|
|
451
475
|
}
|
|
452
476
|
clearValidate(e) {
|
|
453
477
|
var i;
|
|
454
|
-
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s =
|
|
478
|
+
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = v.adapters[this.ui];
|
|
455
479
|
return (t == null ? void 0 : t.clearValidate(e)) ?? (s == null ? void 0 : s.clearValidate(e));
|
|
456
480
|
}
|
|
457
481
|
}
|
|
@@ -460,15 +484,15 @@ function he(r) {
|
|
|
460
484
|
}
|
|
461
485
|
class me {
|
|
462
486
|
constructor(e) {
|
|
463
|
-
a(this, "schemas",
|
|
464
|
-
a(this, "model",
|
|
487
|
+
a(this, "schemas", M([]));
|
|
488
|
+
a(this, "model", M({}));
|
|
465
489
|
a(this, "processorBySchemaType", {
|
|
466
490
|
item: this.runtimeItemProcessor.bind(this),
|
|
467
491
|
group: this.runtimeGroupProcessor.bind(this),
|
|
468
492
|
list: this.runtimeListProcessor.bind(this)
|
|
469
493
|
});
|
|
470
|
-
a(this, "formRef",
|
|
471
|
-
a(this, "hydrateEffect", new
|
|
494
|
+
a(this, "formRef", M(null));
|
|
495
|
+
a(this, "hydrateEffect", new _());
|
|
472
496
|
a(this, "native", oe({}));
|
|
473
497
|
a(this, "grid", {});
|
|
474
498
|
a(this, "runtime", {});
|
|
@@ -476,19 +500,20 @@ class me {
|
|
|
476
500
|
props: {},
|
|
477
501
|
slots: {}
|
|
478
502
|
});
|
|
503
|
+
a(this, "shared", {});
|
|
479
504
|
this.setup = e, this.processor = new de(this);
|
|
480
505
|
const t = this.setup(this);
|
|
481
|
-
if (this.ui = t.ui ?? f.presets.ui, this.runtimeAdapter = new pe(this.ui),
|
|
482
|
-
const s =
|
|
483
|
-
this.processor.parseSchemas(t.schemas.value),
|
|
506
|
+
if (this.ui = t.ui ?? f.presets.ui, this.runtimeAdapter = new pe(this.ui), O(t.schemas)) {
|
|
507
|
+
const s = P(() => t.schemas, () => {
|
|
508
|
+
this.processor.parseSchemas(t.schemas.value), N(() => {
|
|
484
509
|
s();
|
|
485
510
|
});
|
|
486
511
|
}, {
|
|
487
512
|
deep: !0
|
|
488
513
|
});
|
|
489
|
-
} else if (
|
|
490
|
-
const s =
|
|
491
|
-
this.processor.parseSchemas(t.schemas),
|
|
514
|
+
} else if (q(t.schemas)) {
|
|
515
|
+
const s = P(() => t.schemas, () => {
|
|
516
|
+
this.processor.parseSchemas(t.schemas), N(() => {
|
|
492
517
|
s();
|
|
493
518
|
});
|
|
494
519
|
}, {
|
|
@@ -499,55 +524,56 @@ class me {
|
|
|
499
524
|
}
|
|
500
525
|
getRuntimeMeta() {
|
|
501
526
|
return {
|
|
502
|
-
model:
|
|
503
|
-
reactiveModel: this.model.value
|
|
527
|
+
model: S(C(this.model.value)),
|
|
528
|
+
reactiveModel: this.model.value,
|
|
529
|
+
shared: this.shared
|
|
504
530
|
};
|
|
505
531
|
}
|
|
506
532
|
runtimeItemProcessor(e, t, s = this.model.value, i) {
|
|
507
|
-
var
|
|
508
|
-
const o =
|
|
533
|
+
var x, z, $, B, D, G, T, K, W, H, J, Q, X;
|
|
534
|
+
const o = S(e.component);
|
|
509
535
|
if (!o)
|
|
510
536
|
return;
|
|
511
|
-
|
|
512
|
-
const n =
|
|
537
|
+
h(this.globalNativeFormOverride.props, (z = (x = e.native) == null ? void 0 : x.props) == null ? void 0 : z.Form), h(this.globalNativeFormOverride.slots, (B = ($ = e.native) == null ? void 0 : $.slots) == null ? void 0 : B.Form);
|
|
538
|
+
const n = h(C((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), c = {
|
|
513
539
|
display: "grid",
|
|
514
540
|
gridColumn: "1 / -1",
|
|
515
541
|
...e.grid
|
|
516
|
-
}, u =
|
|
542
|
+
}, u = h(C((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({
|
|
517
543
|
schema: e,
|
|
518
544
|
parentSchema: i,
|
|
519
545
|
index: t
|
|
520
|
-
}),
|
|
521
|
-
let
|
|
522
|
-
|
|
523
|
-
let
|
|
524
|
-
const
|
|
525
|
-
if (!l.isUndefined(t) && !l.isObjectEmpty(
|
|
526
|
-
let
|
|
527
|
-
l.isUndefined(
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}),
|
|
546
|
+
}), b = o.name, V = e.componentProps ?? {}, I = v.placeholderPresetByComponentName;
|
|
547
|
+
let g = e.placeholder, y = e.show;
|
|
548
|
+
y === void 0 && (y = !0), y || delete s[e.field];
|
|
549
|
+
let m = e.label ?? "";
|
|
550
|
+
const j = (i == null ? void 0 : i.runtime) ?? this.runtime;
|
|
551
|
+
if (!l.isUndefined(t) && !l.isObjectEmpty(j) && (m = L((X = j == null ? void 0 : j.customizeItemLabel) == null ? void 0 : X.call(j, e.label ?? "", t + 1), "")), !g) {
|
|
552
|
+
let F = "请输入";
|
|
553
|
+
l.isUndefined(b) ? g = `${F}${m}` : /* @ts-expect-error */ I[b.toLowerCase()] ? (F = // @ts-expect-error
|
|
554
|
+
I[b.toLowerCase()], g = `${F}${m}`) : (Object.keys(I).forEach((Y) => {
|
|
555
|
+
b.toLowerCase().includes(Y.toLowerCase()) && (F = I[Y]);
|
|
556
|
+
}), g = `${F}${m}`);
|
|
531
557
|
}
|
|
532
558
|
const Z = this.runtimeAdapter.getRuntimeRequired({
|
|
533
559
|
...e,
|
|
534
|
-
label:
|
|
535
|
-
}), A =
|
|
560
|
+
label: m
|
|
561
|
+
}), A = E.getItemContainer(this), ee = E.getFormItemContainer(this), te = this, se = e.componentSlots;
|
|
536
562
|
return p("div", {
|
|
537
563
|
style: c
|
|
538
564
|
}, [p(A, {
|
|
539
|
-
show:
|
|
565
|
+
show: y
|
|
540
566
|
}, {
|
|
541
567
|
default() {
|
|
542
|
-
return
|
|
543
|
-
label: `${
|
|
568
|
+
return y && p(ee, R(u, {
|
|
569
|
+
label: `${m ? `${m}:` : ""}`
|
|
544
570
|
}, d, Z), {
|
|
545
571
|
default() {
|
|
546
572
|
return te.runtimeAdapter.formComponentRenderer({
|
|
547
573
|
Component: o,
|
|
548
574
|
schema: e,
|
|
549
575
|
baseModel: s,
|
|
550
|
-
placeholder:
|
|
576
|
+
placeholder: g,
|
|
551
577
|
componentSlots: se,
|
|
552
578
|
props: V
|
|
553
579
|
});
|
|
@@ -563,7 +589,7 @@ class me {
|
|
|
563
589
|
display: "grid",
|
|
564
590
|
gridColumn: "1 / -1",
|
|
565
591
|
...e.grid
|
|
566
|
-
}, i =
|
|
592
|
+
}, i = E.getGroupContainer(this);
|
|
567
593
|
let o = e.show;
|
|
568
594
|
return o === void 0 && (o = !0), p("div", {
|
|
569
595
|
style: s
|
|
@@ -580,7 +606,7 @@ class me {
|
|
|
580
606
|
code: "0001",
|
|
581
607
|
message: "异步默认值数据正在处理中,请您耐心等待... "
|
|
582
608
|
});
|
|
583
|
-
(s = this.processor.stableModel[e.field]) != null && s[0] && this.model.value[e.field].push(
|
|
609
|
+
(s = this.processor.stableModel[e.field]) != null && s[0] && this.model.value[e.field].push(C(this.processor.stableModel[e.field][0])), this.runtimeAdapter.clearValidate(this);
|
|
584
610
|
}
|
|
585
611
|
deleteListItem(e, t) {
|
|
586
612
|
this.model.value[e.field].splice(t, 1), this.runtimeAdapter.clearValidate(this);
|
|
@@ -594,7 +620,7 @@ class me {
|
|
|
594
620
|
s.model.value[e.field] || (s.model.value[e.field] = [{}]);
|
|
595
621
|
let i = e.show;
|
|
596
622
|
i === void 0 && (i = !0);
|
|
597
|
-
const o =
|
|
623
|
+
const o = E.getListContainer(this), n = E.getListItemContainer(this);
|
|
598
624
|
return p("div", {
|
|
599
625
|
style: t
|
|
600
626
|
}, [i && p(o, {
|
|
@@ -609,8 +635,8 @@ class me {
|
|
|
609
635
|
container: d
|
|
610
636
|
} = {}) {
|
|
611
637
|
var V;
|
|
612
|
-
const
|
|
613
|
-
return ne(p(
|
|
638
|
+
const b = d ?? p("button", null, null);
|
|
639
|
+
return ne(p(b, {
|
|
614
640
|
onClick: () => s.deleteListItem(e, u)
|
|
615
641
|
}, null), [[le, ((V = s.model.value[e.field]) == null ? void 0 : V.length) > 1]]);
|
|
616
642
|
}
|
|
@@ -630,13 +656,13 @@ class me {
|
|
|
630
656
|
return e.map((t) => (t.type || (t.type = "item"), this.processorBySchemaType[t.type](t)));
|
|
631
657
|
}
|
|
632
658
|
exec() {
|
|
633
|
-
var c, u, d,
|
|
659
|
+
var c, u, d, b;
|
|
634
660
|
const e = {
|
|
635
661
|
display: "grid",
|
|
636
662
|
gridColumn: "1 / -1",
|
|
637
663
|
gridAutoColumns: "1fr",
|
|
638
664
|
...this.grid
|
|
639
|
-
}, t = this, s =
|
|
665
|
+
}, t = this, s = h(C((u = (c = this.native) == null ? void 0 : c.props) == null ? void 0 : u.Form) ?? {}, this.globalNativeFormOverride.props), i = h(C((b = (d = this.native) == null ? void 0 : d.slots) == null ? void 0 : b.Form) ?? {}, this.globalNativeFormOverride.slots), o = E.getFormContainer(this), n = this.runtimeAdapter.getFormModelPropName();
|
|
640
666
|
return p(o, R(s, {
|
|
641
667
|
ref: this.formRef
|
|
642
668
|
}, {
|
|
@@ -654,7 +680,7 @@ class me {
|
|
|
654
680
|
class f {
|
|
655
681
|
}
|
|
656
682
|
a(f, "presets");
|
|
657
|
-
function
|
|
683
|
+
function U({
|
|
658
684
|
parentSchema: r,
|
|
659
685
|
schema: e,
|
|
660
686
|
index: t
|
|
@@ -665,7 +691,7 @@ const ye = {
|
|
|
665
691
|
ArcoVue: {
|
|
666
692
|
getRuntimeField(r) {
|
|
667
693
|
return {
|
|
668
|
-
field:
|
|
694
|
+
field: U(r)
|
|
669
695
|
};
|
|
670
696
|
},
|
|
671
697
|
getRuntimeRequired(r) {
|
|
@@ -709,7 +735,7 @@ const ye = {
|
|
|
709
735
|
},
|
|
710
736
|
validateForm(r) {
|
|
711
737
|
return new Promise((e, t) => {
|
|
712
|
-
r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(
|
|
738
|
+
r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(S(r.runtimeCore.processor.processedModel.value))));
|
|
713
739
|
});
|
|
714
740
|
},
|
|
715
741
|
clearValidate(r) {
|
|
@@ -719,7 +745,7 @@ const ye = {
|
|
|
719
745
|
NutUI: {
|
|
720
746
|
getRuntimeField(r) {
|
|
721
747
|
return {
|
|
722
|
-
prop:
|
|
748
|
+
prop: U(r)
|
|
723
749
|
};
|
|
724
750
|
},
|
|
725
751
|
getRuntimeRequired(r) {
|
|
@@ -768,7 +794,7 @@ const ye = {
|
|
|
768
794
|
valid: s,
|
|
769
795
|
errors: i
|
|
770
796
|
}) => {
|
|
771
|
-
s ? e(r.cleanFallbackFields(
|
|
797
|
+
s ? e(r.cleanFallbackFields(S(r.runtimeCore.processor.processedModel.value))) : t(i);
|
|
772
798
|
});
|
|
773
799
|
});
|
|
774
800
|
},
|
|
@@ -779,7 +805,7 @@ const ye = {
|
|
|
779
805
|
NaiveUI: {
|
|
780
806
|
getRuntimeField(r) {
|
|
781
807
|
return {
|
|
782
|
-
path:
|
|
808
|
+
path: U(r)
|
|
783
809
|
};
|
|
784
810
|
},
|
|
785
811
|
getRuntimeRequired(r) {
|
|
@@ -824,14 +850,14 @@ const ye = {
|
|
|
824
850
|
},
|
|
825
851
|
validateForm(r) {
|
|
826
852
|
return new Promise((e, t) => {
|
|
827
|
-
r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(
|
|
853
|
+
r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(S(r.runtimeCore.processor.processedModel.value))));
|
|
828
854
|
});
|
|
829
855
|
},
|
|
830
856
|
clearValidate(r) {
|
|
831
857
|
r.formRef.value.restoreValidation();
|
|
832
858
|
}
|
|
833
859
|
}
|
|
834
|
-
},
|
|
860
|
+
}, w = class w {
|
|
835
861
|
static getPlaceholderPrefixPresetByComponentName() {
|
|
836
862
|
const e = {
|
|
837
863
|
请选择: ["select", "tree"],
|
|
@@ -844,7 +870,7 @@ const ye = {
|
|
|
844
870
|
return t;
|
|
845
871
|
}
|
|
846
872
|
};
|
|
847
|
-
a(
|
|
873
|
+
a(w, "schemaPreset", {
|
|
848
874
|
type: {
|
|
849
875
|
defaultValue: "item"
|
|
850
876
|
},
|
|
@@ -887,15 +913,15 @@ a(j, "schemaPreset", {
|
|
|
887
913
|
grid: {
|
|
888
914
|
default: void 0
|
|
889
915
|
}
|
|
890
|
-
}), a(
|
|
916
|
+
}), a(w, "componentPropsPreset", {
|
|
891
917
|
options: {
|
|
892
918
|
defaultValue: []
|
|
893
919
|
}
|
|
894
920
|
}), // 基于基本功能提出基本预设
|
|
895
|
-
a(
|
|
896
|
-
let
|
|
897
|
-
const
|
|
898
|
-
...
|
|
921
|
+
a(w, "placeholderPresetByComponentName", w.getPlaceholderPrefixPresetByComponentName());
|
|
922
|
+
let k = w;
|
|
923
|
+
const v = {
|
|
924
|
+
...k,
|
|
899
925
|
adapters: {
|
|
900
926
|
...ye
|
|
901
927
|
}
|
|
@@ -917,26 +943,31 @@ function Ce(r) {
|
|
|
917
943
|
e.setup.bind(e),
|
|
918
944
|
{
|
|
919
945
|
submit: e.submit.bind(e),
|
|
920
|
-
hydrate: e.hydrate.bind(e)
|
|
946
|
+
hydrate: e.hydrate.bind(e),
|
|
947
|
+
share: e.share.bind(e)
|
|
921
948
|
}
|
|
922
949
|
];
|
|
923
950
|
}
|
|
924
951
|
function Ie(r) {
|
|
925
952
|
f.presets = r;
|
|
926
953
|
}
|
|
927
|
-
function
|
|
954
|
+
function be(r, e) {
|
|
928
955
|
return e === "native" && Object.defineProperty(r, "name", {
|
|
929
956
|
value: `__proform_raw_${r.name}`,
|
|
930
957
|
writable: !0
|
|
931
958
|
}), r;
|
|
932
959
|
}
|
|
933
960
|
function Ve(r) {
|
|
934
|
-
return
|
|
961
|
+
return be(r, "native");
|
|
962
|
+
}
|
|
963
|
+
function je(r) {
|
|
964
|
+
return r.__proform_raw_object = !0, r;
|
|
935
965
|
}
|
|
936
966
|
export {
|
|
937
967
|
ge as ProForm,
|
|
938
968
|
Ve as markNativeFunction,
|
|
969
|
+
je as markNativeObject,
|
|
939
970
|
Ce as useForm,
|
|
940
971
|
Ie as useFormPresetConfigurer,
|
|
941
|
-
|
|
972
|
+
be as useModifiers
|
|
942
973
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { default as ProForm } from "./src/form/index";
|
|
2
2
|
export { useForm } from "./src/interactions/useForm";
|
|
3
3
|
export { useFormPresetConfigurer } from "./src/interactions/useFormPresetConfigurer";
|
|
4
|
-
export { useModifiers } from "./src/interactions/useModifiers";
|
|
5
|
-
export { markNativeFunction } from "./src/interactions/useModifiers";
|
|
4
|
+
export { useModifiers, markNativeFunction, markNativeObject, } from "./src/interactions/useModifiers";
|
|
6
5
|
export * from "./src/types/index";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { runtimeMeta } from "../types";
|
|
1
|
+
import { AnyObject, runtimeMeta } from "../types";
|
|
2
2
|
type Modifier = "native";
|
|
3
3
|
type FunctionNative = (args: {
|
|
4
4
|
rawArgs: any[];
|
|
5
5
|
} & runtimeMeta) => any;
|
|
6
6
|
export declare function useModifiers(functionNative: FunctionNative, modifier: Modifier): FunctionNative;
|
|
7
7
|
export declare function markNativeFunction(functionNative: FunctionNative): FunctionNative;
|
|
8
|
+
export declare function markNativeObject(objectNative: AnyObject): AnyObject;
|
|
8
9
|
export {};
|
|
@@ -20,10 +20,12 @@ export default class RuntimeCore {
|
|
|
20
20
|
};
|
|
21
21
|
ui: string;
|
|
22
22
|
runtimeAdapter: RuntimeAdpter;
|
|
23
|
+
shared: AnyObject;
|
|
23
24
|
constructor(setup: Setup);
|
|
24
25
|
getRuntimeMeta(): {
|
|
25
26
|
model: AnyObject;
|
|
26
27
|
reactiveModel: AnyObject;
|
|
28
|
+
shared: AnyObject;
|
|
27
29
|
};
|
|
28
30
|
runtimeItemProcessor(schema: ItemSchema, index?: number, baseModel?: AnyObject, parentSchema?: ListSchema): JSX.Element | undefined;
|
|
29
31
|
runtimeGroupProcessor(schema: GroupSchema): JSX.Element;
|
|
@@ -88,6 +88,7 @@ export type Schema = ItemSchema | GroupSchema | ListSchema;
|
|
|
88
88
|
export interface runtimeMeta {
|
|
89
89
|
model: AnyObject;
|
|
90
90
|
reactiveModel: AnyObject;
|
|
91
|
+
shared: AnyObject;
|
|
91
92
|
}
|
|
92
93
|
export type ProFormProxyRule<T> = T | ((runtimeMeta: runtimeMeta) => T) | ((runtimeMeta: runtimeMeta) => Promise<T>);
|
|
93
94
|
export type ProFormProxy<T> = {
|