@harbor-design/proform 1.2.14 → 1.2.16
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var ae = Object.defineProperty;
|
|
2
2
|
var ue = (r, e, t) => e in r ? ae(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var a = (r, e, t) => (ue(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
import { readonly as ce, isRef as q, watch as v, isReactive as
|
|
4
|
+
import { readonly as ce, isRef as q, watch as v, isReactive as M, nextTick as P, toRaw as w, ref as N, reactive as se, createVNode as p, mergeProps as O, withDirectives as fe, vShow as de, createTextVNode as he, isVNode as pe, defineComponent as me } from "vue";
|
|
5
5
|
class l {
|
|
6
6
|
static typeChecker(e) {
|
|
7
7
|
return {}.toString.call(e);
|
|
@@ -80,7 +80,7 @@ function h(r, ...e) {
|
|
|
80
80
|
t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ? r[s] = h(r[s] || {}, t[s]) : r[s] = t[s]);
|
|
81
81
|
}), r;
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function g(r) {
|
|
84
84
|
const e = /* @__PURE__ */ new WeakMap();
|
|
85
85
|
function t(s) {
|
|
86
86
|
if (s === null || typeof s != "object")
|
|
@@ -138,7 +138,7 @@ class be {
|
|
|
138
138
|
}
|
|
139
139
|
submit() {
|
|
140
140
|
var s;
|
|
141
|
-
const e = (s = u.getPreset(this.runtimeCore.ui)) == null ? void 0 : s.adapter, t =
|
|
141
|
+
const e = (s = u.getPreset(this.runtimeCore.ui)) == null ? void 0 : s.adapter, t = C.adapters[u.getUI(this.runtimeCore.ui)];
|
|
142
142
|
return (e == null ? void 0 : e.validateForm(this)) ?? (t == null ? void 0 : t.validateForm(this));
|
|
143
143
|
}
|
|
144
144
|
hydrate(e) {
|
|
@@ -158,7 +158,7 @@ class be {
|
|
|
158
158
|
deep: !0,
|
|
159
159
|
immediate: !0
|
|
160
160
|
}
|
|
161
|
-
) :
|
|
161
|
+
) : M(e) ? v(
|
|
162
162
|
() => e,
|
|
163
163
|
() => {
|
|
164
164
|
h(this.runtimeCore.model.value, e);
|
|
@@ -179,7 +179,7 @@ class be {
|
|
|
179
179
|
const t = v(
|
|
180
180
|
() => e.value,
|
|
181
181
|
() => {
|
|
182
|
-
h(this.runtimeCore.shared, e.value), this.runtimeCore.processor.schemaEffect.triggerEffects(),
|
|
182
|
+
h(this.runtimeCore.shared, e.value), this.runtimeCore.processor.schemaEffect.triggerEffects(), P(() => {
|
|
183
183
|
t();
|
|
184
184
|
});
|
|
185
185
|
},
|
|
@@ -188,11 +188,11 @@ class be {
|
|
|
188
188
|
immediate: !0
|
|
189
189
|
}
|
|
190
190
|
);
|
|
191
|
-
} else if (
|
|
191
|
+
} else if (M(e)) {
|
|
192
192
|
const t = v(
|
|
193
193
|
() => e,
|
|
194
194
|
() => {
|
|
195
|
-
h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects(),
|
|
195
|
+
h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects(), P(() => {
|
|
196
196
|
t();
|
|
197
197
|
});
|
|
198
198
|
},
|
|
@@ -205,13 +205,13 @@ class be {
|
|
|
205
205
|
h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects();
|
|
206
206
|
}
|
|
207
207
|
subscribeModel(e) {
|
|
208
|
-
|
|
208
|
+
P(() => {
|
|
209
209
|
const t = v(
|
|
210
210
|
() => this.reactiveModel,
|
|
211
211
|
(s) => {
|
|
212
212
|
e(s, {
|
|
213
213
|
stopSubscribe() {
|
|
214
|
-
|
|
214
|
+
P(() => {
|
|
215
215
|
t();
|
|
216
216
|
});
|
|
217
217
|
}
|
|
@@ -224,6 +224,14 @@ class be {
|
|
|
224
224
|
);
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
|
+
resetModel() {
|
|
228
|
+
P(() => {
|
|
229
|
+
var e;
|
|
230
|
+
(e = this.runtimeCore) != null && e.model.value && (this.runtimeCore.model.value = g(
|
|
231
|
+
this.runtimeCore.processor.stableModel
|
|
232
|
+
));
|
|
233
|
+
});
|
|
234
|
+
}
|
|
227
235
|
}
|
|
228
236
|
class L {
|
|
229
237
|
constructor() {
|
|
@@ -249,8 +257,8 @@ class ve {
|
|
|
249
257
|
a(this, "getRuntimeMeta");
|
|
250
258
|
a(this, "stableSchemas", []);
|
|
251
259
|
a(this, "stableModel", {});
|
|
252
|
-
a(this, "schemaPreset",
|
|
253
|
-
a(this, "componentPropsPreset",
|
|
260
|
+
a(this, "schemaPreset", C.schemaPreset);
|
|
261
|
+
a(this, "componentPropsPreset", C.componentPropsPreset);
|
|
254
262
|
a(this, "stableUpdaterProcessProgress");
|
|
255
263
|
a(this, "stableUpdaterTimes", 0);
|
|
256
264
|
a(this, "schemaEffect", new L());
|
|
@@ -296,7 +304,7 @@ class ve {
|
|
|
296
304
|
// 派生过程,用于外部应用
|
|
297
305
|
parseSchemas(e, t) {
|
|
298
306
|
l.isArrayEmpty(this.processedSchemas.value) && (this.baseDefaultValueFunctionsLength = this.countFunctionDefaultValues(
|
|
299
|
-
|
|
307
|
+
g(e)
|
|
300
308
|
), this.processedSchemas.value = this.initSchemas(e)), this.parse(e, t);
|
|
301
309
|
}
|
|
302
310
|
parseStable(e) {
|
|
@@ -326,11 +334,11 @@ class ve {
|
|
|
326
334
|
const c = f.index, d = f.key, y = f.keyIndex;
|
|
327
335
|
if (l.isUndefined(f.stable))
|
|
328
336
|
return;
|
|
329
|
-
const F = i.parseStable(f.stable), E = s == null ? void 0 : s.index,
|
|
337
|
+
const F = i.parseStable(f.stable), E = s == null ? void 0 : s.index, I = s == null ? void 0 : s.key;
|
|
330
338
|
let b = F;
|
|
331
339
|
if (l.isProcessInprogress(b) || (o[y] = !0), s) {
|
|
332
|
-
const m = i.processedSchemas.value[E][
|
|
333
|
-
m && l.isObject(m) && d !== "component" && (b = h(m, b)), i.processedSchemas.value[E][
|
|
340
|
+
const m = i.processedSchemas.value[E][I][c][d];
|
|
341
|
+
m && l.isObject(m) && d !== "component" && (b = h(m, b)), i.processedSchemas.value[E][I][c][d] = b, i.stableUpdater(o);
|
|
334
342
|
} else {
|
|
335
343
|
const m = i.processedSchemas.value[c][d];
|
|
336
344
|
m && l.isObject(m) && d !== "component" && (b = h(m, b)), i.processedSchemas.value[c][d] = b, i.stableUpdater(o);
|
|
@@ -376,13 +384,13 @@ class ve {
|
|
|
376
384
|
return n(c);
|
|
377
385
|
this.defaultValueInprogressMap.set(t[i], c), !l.isProcessInprogress(c) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
|
|
378
386
|
this.defaultValueInprogressMap.values()
|
|
379
|
-
).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(),
|
|
387
|
+
).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), P(() => {
|
|
380
388
|
f();
|
|
381
389
|
})) : n(c);
|
|
382
390
|
}) : this.fieldParser(t[i], (c) => {
|
|
383
391
|
this.defaultValueInprogressMap.set(t[i], c), !l.isProcessInprogress(c) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
|
|
384
392
|
this.defaultValueInprogressMap.values()
|
|
385
|
-
).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(),
|
|
393
|
+
).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), P(() => {
|
|
386
394
|
f();
|
|
387
395
|
})) : n(c);
|
|
388
396
|
});
|
|
@@ -437,7 +445,7 @@ class ve {
|
|
|
437
445
|
immediate: !0,
|
|
438
446
|
deep: !0
|
|
439
447
|
}
|
|
440
|
-
) :
|
|
448
|
+
) : M(e) ? v(
|
|
441
449
|
() => e,
|
|
442
450
|
() => {
|
|
443
451
|
l.isUndefined(e) || (s && l.isObject(e) && !l.isNativeObject(e) ? this.objectParser({
|
|
@@ -457,7 +465,7 @@ class ve {
|
|
|
457
465
|
modelProcessor(e) {
|
|
458
466
|
e.map(
|
|
459
467
|
(t) => this.createModel(t, this.processedModel.value)
|
|
460
|
-
), l.isObjectEmpty(this.stableModel) && this.stableUpdaterProcessProgress.every(Boolean) && this.defaultValueEffect.effects.size === 0 && (this.stableModel =
|
|
468
|
+
), 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());
|
|
461
469
|
}
|
|
462
470
|
createModel(e, t) {
|
|
463
471
|
l.isListSchema(e) && (t[e.field] || (t[e.field] = [{}]), e.children.forEach((s) => {
|
|
@@ -497,27 +505,27 @@ class ye {
|
|
|
497
505
|
}
|
|
498
506
|
getRuntimeField(e) {
|
|
499
507
|
var i;
|
|
500
|
-
const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s =
|
|
508
|
+
const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = C.adapters[u.getUI(this.ui)];
|
|
501
509
|
return (t == null ? void 0 : t.getRuntimeField(e)) ?? (s == null ? void 0 : s.getRuntimeField(e));
|
|
502
510
|
}
|
|
503
511
|
getRuntimeRequired(e) {
|
|
504
512
|
var i;
|
|
505
|
-
const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s =
|
|
513
|
+
const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = C.adapters[u.getUI(this.ui)];
|
|
506
514
|
return (t == null ? void 0 : t.getRuntimeRequired(e)) ?? (s == null ? void 0 : s.getRuntimeRequired(e));
|
|
507
515
|
}
|
|
508
516
|
getFormModelPropName() {
|
|
509
517
|
var s;
|
|
510
|
-
const e = (s = u.presets.uiPresets[this.ui]) == null ? void 0 : s.adapter, t =
|
|
518
|
+
const e = (s = u.presets.uiPresets[this.ui]) == null ? void 0 : s.adapter, t = C.adapters[u.getUI(this.ui)];
|
|
511
519
|
return (e == null ? void 0 : e.getFormModelPropName()) ?? (t == null ? void 0 : t.getFormModelPropName());
|
|
512
520
|
}
|
|
513
521
|
formComponentRenderer(e) {
|
|
514
522
|
var i;
|
|
515
|
-
const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s =
|
|
523
|
+
const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = C.adapters[u.getUI(this.ui)];
|
|
516
524
|
return (t == null ? void 0 : t.formComponentRenderer(e)) ?? (s == null ? void 0 : s.formComponentRenderer(e));
|
|
517
525
|
}
|
|
518
526
|
clearValidate(e) {
|
|
519
527
|
var i;
|
|
520
|
-
const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s =
|
|
528
|
+
const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = C.adapters[u.getUI(this.ui)];
|
|
521
529
|
return (t == null ? void 0 : t.clearValidate(e)) ?? (s == null ? void 0 : s.clearValidate(e));
|
|
522
530
|
}
|
|
523
531
|
}
|
|
@@ -526,14 +534,14 @@ function Pe(r) {
|
|
|
526
534
|
}
|
|
527
535
|
class ge {
|
|
528
536
|
constructor(e) {
|
|
529
|
-
a(this, "schemas",
|
|
530
|
-
a(this, "model",
|
|
537
|
+
a(this, "schemas", N([]));
|
|
538
|
+
a(this, "model", N({}));
|
|
531
539
|
a(this, "processorBySchemaType", {
|
|
532
540
|
item: this.runtimeItemProcessor.bind(this),
|
|
533
541
|
group: this.runtimeGroupProcessor.bind(this),
|
|
534
542
|
list: this.runtimeListProcessor.bind(this)
|
|
535
543
|
});
|
|
536
|
-
a(this, "formRef",
|
|
544
|
+
a(this, "formRef", N(null));
|
|
537
545
|
a(this, "hydrateEffect", new L());
|
|
538
546
|
a(this, "native", se({}));
|
|
539
547
|
a(this, "grid", {});
|
|
@@ -562,9 +570,9 @@ class ge {
|
|
|
562
570
|
deep: !0
|
|
563
571
|
}
|
|
564
572
|
);
|
|
565
|
-
else if (
|
|
573
|
+
else if (M(t.schemas)) {
|
|
566
574
|
const s = v(() => t.schemas, () => {
|
|
567
|
-
this.processor.parseSchemas(t.schemas),
|
|
575
|
+
this.processor.parseSchemas(t.schemas), P(() => {
|
|
568
576
|
s();
|
|
569
577
|
});
|
|
570
578
|
}, {
|
|
@@ -574,7 +582,7 @@ class ge {
|
|
|
574
582
|
this.processor.parseSchemas(t.schemas);
|
|
575
583
|
}
|
|
576
584
|
getRuntimeMeta() {
|
|
577
|
-
const e = w(
|
|
585
|
+
const e = w(g(this.model.value));
|
|
578
586
|
let t;
|
|
579
587
|
return {
|
|
580
588
|
model: e,
|
|
@@ -585,16 +593,16 @@ class ge {
|
|
|
585
593
|
t && clearTimeout(t), t = setTimeout(() => {
|
|
586
594
|
if (q(s)) {
|
|
587
595
|
const i = v(() => s.value, () => {
|
|
588
|
-
h(this.shared, s.value), this.processor.schemaEffect.triggerEffects(),
|
|
596
|
+
h(this.shared, s.value), this.processor.schemaEffect.triggerEffects(), P(() => {
|
|
589
597
|
i();
|
|
590
598
|
});
|
|
591
599
|
}, {
|
|
592
600
|
deep: !0,
|
|
593
601
|
immediate: !0
|
|
594
602
|
});
|
|
595
|
-
} else if (
|
|
603
|
+
} else if (M(s)) {
|
|
596
604
|
const i = v(() => s, () => {
|
|
597
|
-
h(this.shared, s), this.processor.schemaEffect.triggerEffects(),
|
|
605
|
+
h(this.shared, s), this.processor.schemaEffect.triggerEffects(), P(() => {
|
|
598
606
|
i();
|
|
599
607
|
});
|
|
600
608
|
}, {
|
|
@@ -613,25 +621,25 @@ class ge {
|
|
|
613
621
|
if (!o)
|
|
614
622
|
return;
|
|
615
623
|
(z = (_ = e.native) == null ? void 0 : _.props) != null && z.Form && h(this.globalNativeFormOverride.props.Form, (B = (k = e.native) == null ? void 0 : k.props) == null ? void 0 : B.Form), (T = (D = e.native) == null ? void 0 : D.slots) != null && T.Form && h(this.globalNativeFormOverride.slots.Form, (W = (G = e.native) == null ? void 0 : G.slots) == null ? void 0 : W.Form);
|
|
616
|
-
const n = h(
|
|
624
|
+
const n = h(g((H = (K = this.native) == null ? void 0 : K.slots) == null ? void 0 : H.FormItem) ?? {}, (Q = (J = e.native) == null ? void 0 : J.slots) == null ? void 0 : Q.FormItem), f = {
|
|
617
625
|
display: "grid",
|
|
618
626
|
gridColumn: "1 / -1",
|
|
619
627
|
...e.grid
|
|
620
|
-
}, c = h(
|
|
628
|
+
}, c = h(g((Y = (X = this.native) == null ? void 0 : X.props) == null ? void 0 : Y.FormItem) ?? {}, (A = (Z = e.native) == null ? void 0 : Z.props) == null ? void 0 : A.FormItem), d = this.runtimeAdapter.getRuntimeField({
|
|
621
629
|
schema: e,
|
|
622
630
|
parentSchema: i,
|
|
623
631
|
index: t
|
|
624
|
-
}), y = o.name, F = e.componentProps ?? {}, E =
|
|
625
|
-
let
|
|
632
|
+
}), y = o.name, F = e.componentProps ?? {}, E = C.placeholderPresetByComponentName;
|
|
633
|
+
let I = e.placeholder, b = e.show;
|
|
626
634
|
b === void 0 && (b = !0);
|
|
627
635
|
let m = e.label ?? "";
|
|
628
636
|
const j = (i == null ? void 0 : i.runtime) ?? this.runtime;
|
|
629
|
-
if (!l.isUndefined(t) && !l.isObjectEmpty(j) && (m = x((ee = j == null ? void 0 : j.customizeListItemLabel) == null ? void 0 : ee.call(j, e.label ?? "", t + 1), "")), !
|
|
637
|
+
if (!l.isUndefined(t) && !l.isObjectEmpty(j) && (m = x((ee = j == null ? void 0 : j.customizeListItemLabel) == null ? void 0 : ee.call(j, e.label ?? "", t + 1), "")), !I) {
|
|
630
638
|
let R = "请输入";
|
|
631
|
-
l.isUndefined(y) ?
|
|
632
|
-
E[y.toLowerCase()],
|
|
639
|
+
l.isUndefined(y) ? I = `${R}${m}` : /* @ts-expect-error */ E[y.toLowerCase()] ? (R = // @ts-expect-error
|
|
640
|
+
E[y.toLowerCase()], I = `${R}${m}`) : (Object.keys(E).forEach((te) => {
|
|
633
641
|
y.toLowerCase().includes(te.toLowerCase()) && (R = E[te]);
|
|
634
|
-
}),
|
|
642
|
+
}), I = `${R}${m}`);
|
|
635
643
|
}
|
|
636
644
|
const re = this.runtimeAdapter.getRuntimeRequired({
|
|
637
645
|
...e,
|
|
@@ -651,7 +659,7 @@ class ge {
|
|
|
651
659
|
Component: o,
|
|
652
660
|
schema: e,
|
|
653
661
|
baseModel: s,
|
|
654
|
-
placeholder:
|
|
662
|
+
placeholder: I,
|
|
655
663
|
componentSlots: le,
|
|
656
664
|
props: F
|
|
657
665
|
});
|
|
@@ -684,7 +692,7 @@ class ge {
|
|
|
684
692
|
code: "0001",
|
|
685
693
|
message: "异步默认值数据正在处理中,请您耐心等待... "
|
|
686
694
|
});
|
|
687
|
-
(s = this.processor.stableModel[e.field]) != null && s[0] && this.model.value[e.field].push(
|
|
695
|
+
(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);
|
|
688
696
|
}
|
|
689
697
|
deleteListItem(e, t) {
|
|
690
698
|
this.model.value[e.field].splice(t, 1), this.runtimeAdapter.clearValidate(this);
|
|
@@ -740,7 +748,7 @@ class ge {
|
|
|
740
748
|
gridColumn: "1 / -1",
|
|
741
749
|
gridAutoColumns: "1fr",
|
|
742
750
|
...this.grid
|
|
743
|
-
}, t = this, s = h(
|
|
751
|
+
}, t = this, s = h(g((c = (f = this.native) == null ? void 0 : f.props) == null ? void 0 : c.Form) ?? {}, this.globalNativeFormOverride.props.Form), i = h(g((y = (d = this.native) == null ? void 0 : d.slots) == null ? void 0 : y.Form) ?? {}, this.globalNativeFormOverride.slots.Form), o = V.getFormContainer(this), n = this.runtimeAdapter.getFormModelPropName();
|
|
744
752
|
return p(o, O(s, {
|
|
745
753
|
ref: this.formRef
|
|
746
754
|
}, {
|
|
@@ -1026,7 +1034,7 @@ a(S, "schemaPreset", {
|
|
|
1026
1034
|
}), // 基于基本功能提出基本预设
|
|
1027
1035
|
a(S, "placeholderPresetByComponentName", S.getPlaceholderPrefixPresetByComponentName());
|
|
1028
1036
|
let $ = S;
|
|
1029
|
-
const
|
|
1037
|
+
const C = {
|
|
1030
1038
|
...$,
|
|
1031
1039
|
adapters: {
|
|
1032
1040
|
...Ce
|
|
@@ -1051,7 +1059,8 @@ function Ve(r) {
|
|
|
1051
1059
|
submit: e.submit.bind(e),
|
|
1052
1060
|
hydrate: e.hydrate.bind(e),
|
|
1053
1061
|
share: e.share.bind(e),
|
|
1054
|
-
subscribeModel: e.subscribeModel.bind(e)
|
|
1062
|
+
subscribeModel: e.subscribeModel.bind(e),
|
|
1063
|
+
resetModel: e.resetModel.bind(e)
|
|
1055
1064
|
}
|
|
1056
1065
|
];
|
|
1057
1066
|
}
|