@harbor-design/proform 1.1.38 → 1.2.0
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 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 N, watch as b, isReactive as q, nextTick as E, toRaw as R, ref as M, reactive as oe, createVNode as p, mergeProps as O, 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);
|
|
@@ -46,13 +46,16 @@ class l {
|
|
|
46
46
|
if (e === void 0)
|
|
47
47
|
return !0;
|
|
48
48
|
if (this.isObject(e)) {
|
|
49
|
-
if (e.setup
|
|
49
|
+
if (e.setup || this.isFunction(e.setup) || e.props)
|
|
50
50
|
return !1;
|
|
51
51
|
if (this.isObjectEmpty(e))
|
|
52
52
|
return !0;
|
|
53
|
-
for (const t in e)
|
|
53
|
+
for (const t in e) {
|
|
54
|
+
if (t === "componentProps")
|
|
55
|
+
return !1;
|
|
54
56
|
if (e.hasOwnProperty(t) && this.isProcessInprogress(e[t]))
|
|
55
57
|
return !0;
|
|
58
|
+
}
|
|
56
59
|
} else if (this.isArray(e)) {
|
|
57
60
|
if (this.isArrayEmpty(e))
|
|
58
61
|
return !0;
|
|
@@ -145,7 +148,7 @@ class fe {
|
|
|
145
148
|
});
|
|
146
149
|
this.runtimeCore.hydrateEffect.trackEffect(
|
|
147
150
|
() => {
|
|
148
|
-
|
|
151
|
+
N(e) ? b(
|
|
149
152
|
() => e.value,
|
|
150
153
|
() => {
|
|
151
154
|
h(this.runtimeCore.model.value, e.value);
|
|
@@ -154,7 +157,7 @@ class fe {
|
|
|
154
157
|
deep: !0,
|
|
155
158
|
immediate: !0
|
|
156
159
|
}
|
|
157
|
-
) :
|
|
160
|
+
) : q(e) ? b(
|
|
158
161
|
() => e,
|
|
159
162
|
() => {
|
|
160
163
|
h(this.runtimeCore.model.value, e);
|
|
@@ -171,8 +174,8 @@ class fe {
|
|
|
171
174
|
);
|
|
172
175
|
}
|
|
173
176
|
share(e) {
|
|
174
|
-
if (
|
|
175
|
-
const t =
|
|
177
|
+
if (N(e)) {
|
|
178
|
+
const t = b(
|
|
176
179
|
() => e.value,
|
|
177
180
|
() => {
|
|
178
181
|
h(this.runtimeCore.shared, e.value), this.runtimeCore.processor.schemaEffect.triggerEffects(), E(() => {
|
|
@@ -184,8 +187,8 @@ class fe {
|
|
|
184
187
|
immediate: !0
|
|
185
188
|
}
|
|
186
189
|
);
|
|
187
|
-
} else if (
|
|
188
|
-
const t =
|
|
190
|
+
} else if (q(e)) {
|
|
191
|
+
const t = b(
|
|
189
192
|
() => e,
|
|
190
193
|
() => {
|
|
191
194
|
h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects(), E(() => {
|
|
@@ -234,7 +237,7 @@ class de {
|
|
|
234
237
|
a(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
|
|
235
238
|
a(this, "baseDefaultValueFunctionsLength");
|
|
236
239
|
a(this, "isModelInitialized", !0);
|
|
237
|
-
this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e),
|
|
240
|
+
this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), b(
|
|
238
241
|
() => this.processedModel.value,
|
|
239
242
|
() => {
|
|
240
243
|
this.schemaEffect.triggerEffects();
|
|
@@ -286,7 +289,7 @@ class de {
|
|
|
286
289
|
// 对于稳定初始化更新的抽象
|
|
287
290
|
stableUpdater(e = []) {
|
|
288
291
|
if (e.every(Boolean)) {
|
|
289
|
-
const t =
|
|
292
|
+
const t = R(this.processedSchemas.value);
|
|
290
293
|
!l.isProcessInprogress(t) && l.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
|
|
291
294
|
length: t.length
|
|
292
295
|
}).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
|
|
@@ -299,12 +302,12 @@ class de {
|
|
|
299
302
|
}).fill(!1);
|
|
300
303
|
this.objectParser({ data: e, index: t, updater: n });
|
|
301
304
|
function n(c) {
|
|
302
|
-
const u = c.index, d = c.key,
|
|
305
|
+
const u = c.index, d = c.key, v = c.keyIndex;
|
|
303
306
|
if (l.isUndefined(c.stable))
|
|
304
307
|
return;
|
|
305
|
-
const
|
|
306
|
-
let y =
|
|
307
|
-
if (l.isProcessInprogress(y) || (o[
|
|
308
|
+
const j = i.parseStable(c.stable), I = s == null ? void 0 : s.index, g = s == null ? void 0 : s.key;
|
|
309
|
+
let y = j;
|
|
310
|
+
if (l.isProcessInprogress(y) || (o[v] = !0), s) {
|
|
308
311
|
const m = i.processedSchemas.value[I][g][u][d];
|
|
309
312
|
m && l.isObject(m) && d !== "component" && (y = h(m, y)), i.processedSchemas.value[I][g][u][d] = y, i.stableUpdater(o);
|
|
310
313
|
} else {
|
|
@@ -401,7 +404,7 @@ class de {
|
|
|
401
404
|
this.promiseFieldParser(i, t, s);
|
|
402
405
|
}
|
|
403
406
|
else
|
|
404
|
-
|
|
407
|
+
N(e) ? b(
|
|
405
408
|
() => e.value,
|
|
406
409
|
() => {
|
|
407
410
|
l.isUndefined(e.value) || (s && l.isObject(e.value) && !l.isNativeObject(e.value) ? this.objectParser({
|
|
@@ -413,7 +416,7 @@ class de {
|
|
|
413
416
|
immediate: !0,
|
|
414
417
|
deep: !0
|
|
415
418
|
}
|
|
416
|
-
) :
|
|
419
|
+
) : q(e) ? b(
|
|
417
420
|
() => e,
|
|
418
421
|
() => {
|
|
419
422
|
l.isUndefined(e) || (s && l.isObject(e) && !l.isNativeObject(e) ? this.objectParser({
|
|
@@ -443,7 +446,7 @@ class de {
|
|
|
443
446
|
}), l.isItemSchema(e) && ("defaultValue" in e ? t[e.field] = e.defaultValue : t[e.field] || (t[e.field] = void 0));
|
|
444
447
|
}
|
|
445
448
|
}
|
|
446
|
-
class
|
|
449
|
+
class F {
|
|
447
450
|
static getFormContainer({ ui: e } = {}) {
|
|
448
451
|
return f.presets.uiPresets[e ?? f.presets.ui].container.Form;
|
|
449
452
|
}
|
|
@@ -467,6 +470,10 @@ class he {
|
|
|
467
470
|
constructor(e) {
|
|
468
471
|
this.ui = e;
|
|
469
472
|
}
|
|
473
|
+
getRuntimeNative() {
|
|
474
|
+
var t;
|
|
475
|
+
return (t = f.presets.uiPresets[this.ui]) == null ? void 0 : t.native;
|
|
476
|
+
}
|
|
470
477
|
getRuntimeField(e) {
|
|
471
478
|
var i;
|
|
472
479
|
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[this.ui];
|
|
@@ -517,8 +524,8 @@ class me {
|
|
|
517
524
|
a(this, "shared", {});
|
|
518
525
|
this.setup = e, this.processor = new de(this);
|
|
519
526
|
const t = this.setup(this);
|
|
520
|
-
if (this.ui = t.ui ?? f.presets.ui, this.runtimeAdapter = new he(this.ui),
|
|
521
|
-
|
|
527
|
+
if (this.ui = t.ui ?? f.presets.ui, this.runtimeAdapter = new he(this.ui), Object.assign(this.globalNativeFormOverride, this.runtimeAdapter.getRuntimeNative()), N(t.schemas))
|
|
528
|
+
b(
|
|
522
529
|
// @ts-expect-error
|
|
523
530
|
() => t.schemas.value,
|
|
524
531
|
() => {
|
|
@@ -528,8 +535,8 @@ class me {
|
|
|
528
535
|
deep: !0
|
|
529
536
|
}
|
|
530
537
|
);
|
|
531
|
-
else if (
|
|
532
|
-
const s =
|
|
538
|
+
else if (q(t.schemas)) {
|
|
539
|
+
const s = b(() => t.schemas, () => {
|
|
533
540
|
this.processor.parseSchemas(t.schemas), E(() => {
|
|
534
541
|
s();
|
|
535
542
|
});
|
|
@@ -541,12 +548,12 @@ class me {
|
|
|
541
548
|
}
|
|
542
549
|
getRuntimeMeta() {
|
|
543
550
|
return {
|
|
544
|
-
model:
|
|
551
|
+
model: R(C(this.model.value)),
|
|
545
552
|
reactiveModel: this.model.value,
|
|
546
553
|
shared: this.shared,
|
|
547
554
|
share: (t) => {
|
|
548
|
-
if (
|
|
549
|
-
const s =
|
|
555
|
+
if (N(t)) {
|
|
556
|
+
const s = b(() => t.value, () => {
|
|
550
557
|
h(this.shared, t.value), this.processor.schemaEffect.triggerEffects(), E(() => {
|
|
551
558
|
s();
|
|
552
559
|
});
|
|
@@ -554,8 +561,8 @@ class me {
|
|
|
554
561
|
deep: !0,
|
|
555
562
|
immediate: !0
|
|
556
563
|
});
|
|
557
|
-
} else if (
|
|
558
|
-
const s =
|
|
564
|
+
} else if (q(t)) {
|
|
565
|
+
const s = b(() => t, () => {
|
|
559
566
|
h(this.shared, t), this.processor.schemaEffect.triggerEffects(), E(() => {
|
|
560
567
|
s();
|
|
561
568
|
});
|
|
@@ -569,11 +576,11 @@ class me {
|
|
|
569
576
|
};
|
|
570
577
|
}
|
|
571
578
|
runtimeItemProcessor(e, t, s = this.model.value, i) {
|
|
572
|
-
var
|
|
573
|
-
const o =
|
|
579
|
+
var z, k, $, B, D, G, T, W, K, H, J, Q, X;
|
|
580
|
+
const o = R(e.component);
|
|
574
581
|
if (!o)
|
|
575
582
|
return;
|
|
576
|
-
h(this.globalNativeFormOverride.props, (
|
|
583
|
+
h(this.globalNativeFormOverride.props, (k = (z = e.native) == null ? void 0 : z.props) == null ? void 0 : k.Form), h(this.globalNativeFormOverride.slots, (B = ($ = e.native) == null ? void 0 : $.slots) == null ? void 0 : B.Form);
|
|
577
584
|
const n = h(C((G = (D = this.native) == null ? void 0 : D.slots) == null ? void 0 : G.FormItem) ?? {}, (W = (T = e.native) == null ? void 0 : T.slots) == null ? void 0 : W.FormItem), c = {
|
|
578
585
|
display: "grid",
|
|
579
586
|
gridColumn: "1 / -1",
|
|
@@ -582,22 +589,22 @@ class me {
|
|
|
582
589
|
schema: e,
|
|
583
590
|
parentSchema: i,
|
|
584
591
|
index: t
|
|
585
|
-
}),
|
|
592
|
+
}), v = o.name, j = e.componentProps ?? {}, I = P.placeholderPresetByComponentName;
|
|
586
593
|
let g = e.placeholder, y = e.show;
|
|
587
594
|
y === void 0 && (y = !0), y || delete s[e.field];
|
|
588
595
|
let m = e.label ?? "";
|
|
589
|
-
const
|
|
590
|
-
if (!l.isUndefined(t) && !l.isObjectEmpty(
|
|
591
|
-
let
|
|
592
|
-
l.isUndefined(
|
|
593
|
-
I[
|
|
594
|
-
|
|
595
|
-
}), g = `${
|
|
596
|
+
const V = (i == null ? void 0 : i.runtime) ?? this.runtime;
|
|
597
|
+
if (!l.isUndefined(t) && !l.isObjectEmpty(V) && (m = L((X = V == null ? void 0 : V.customizeItemLabel) == null ? void 0 : X.call(V, e.label ?? "", t + 1), "")), !g) {
|
|
598
|
+
let S = "请输入";
|
|
599
|
+
l.isUndefined(v) ? g = `${S}${m}` : /* @ts-expect-error */ I[v.toLowerCase()] ? (S = // @ts-expect-error
|
|
600
|
+
I[v.toLowerCase()], g = `${S}${m}`) : (Object.keys(I).forEach((Y) => {
|
|
601
|
+
v.toLowerCase().includes(Y.toLowerCase()) && (S = I[Y]);
|
|
602
|
+
}), g = `${S}${m}`);
|
|
596
603
|
}
|
|
597
604
|
const Z = this.runtimeAdapter.getRuntimeRequired({
|
|
598
605
|
...e,
|
|
599
606
|
label: m
|
|
600
|
-
}), A =
|
|
607
|
+
}), A = F.getItemContainer(this), ee = F.getFormItemContainer(this), te = this, se = e.componentSlots;
|
|
601
608
|
return p("div", {
|
|
602
609
|
style: c
|
|
603
610
|
}, [p(A, {
|
|
@@ -614,7 +621,7 @@ class me {
|
|
|
614
621
|
baseModel: s,
|
|
615
622
|
placeholder: g,
|
|
616
623
|
componentSlots: se,
|
|
617
|
-
props:
|
|
624
|
+
props: j
|
|
618
625
|
});
|
|
619
626
|
},
|
|
620
627
|
...n
|
|
@@ -628,7 +635,7 @@ class me {
|
|
|
628
635
|
display: "grid",
|
|
629
636
|
gridColumn: "1 / -1",
|
|
630
637
|
...e.grid
|
|
631
|
-
}, i =
|
|
638
|
+
}, i = F.getGroupContainer(this);
|
|
632
639
|
let o = e.show;
|
|
633
640
|
return o === void 0 && (o = !0), p("div", {
|
|
634
641
|
style: s
|
|
@@ -659,7 +666,7 @@ class me {
|
|
|
659
666
|
s.model.value[e.field] || (s.model.value[e.field] = [{}]);
|
|
660
667
|
let i = e.show;
|
|
661
668
|
i === void 0 && (i = !0);
|
|
662
|
-
const o =
|
|
669
|
+
const o = F.getListContainer(this), n = F.getListItemContainer(this);
|
|
663
670
|
return p("div", {
|
|
664
671
|
style: t
|
|
665
672
|
}, [i && p(o, {
|
|
@@ -673,11 +680,11 @@ class me {
|
|
|
673
680
|
delete({
|
|
674
681
|
container: d
|
|
675
682
|
} = {}) {
|
|
676
|
-
var
|
|
677
|
-
const
|
|
678
|
-
return ne(p(
|
|
683
|
+
var j;
|
|
684
|
+
const v = d ?? p("button", null, null);
|
|
685
|
+
return ne(p(v, {
|
|
679
686
|
onClick: () => s.deleteListItem(e, u)
|
|
680
|
-
}, null), [[le, ((
|
|
687
|
+
}, null), [[le, ((j = s.model.value[e.field]) == null ? void 0 : j.length) > 1]]);
|
|
681
688
|
}
|
|
682
689
|
}));
|
|
683
690
|
},
|
|
@@ -695,13 +702,21 @@ class me {
|
|
|
695
702
|
return e.map((t) => (t.type || (t.type = "item"), this.processorBySchemaType[t.type](t)));
|
|
696
703
|
}
|
|
697
704
|
exec() {
|
|
698
|
-
var c, u, d,
|
|
705
|
+
var c, u, d, v;
|
|
699
706
|
const e = {
|
|
700
707
|
display: "grid",
|
|
701
708
|
gridColumn: "1 / -1",
|
|
702
709
|
gridAutoColumns: "1fr",
|
|
703
710
|
...this.grid
|
|
704
|
-
}, t = this, s = h(
|
|
711
|
+
}, t = this, s = h(
|
|
712
|
+
C((u = (c = this.native) == null ? void 0 : c.props) == null ? void 0 : u.Form) ?? {},
|
|
713
|
+
// @ts-expect-error
|
|
714
|
+
this.globalNativeFormOverride.props.Form
|
|
715
|
+
), i = h(
|
|
716
|
+
C((v = (d = this.native) == null ? void 0 : d.slots) == null ? void 0 : v.Form) ?? {},
|
|
717
|
+
// @ts-expect-error
|
|
718
|
+
this.globalNativeFormOverride.slots.Form
|
|
719
|
+
), o = F.getFormContainer(this), n = this.runtimeAdapter.getFormModelPropName();
|
|
705
720
|
return p(o, O(s, {
|
|
706
721
|
ref: this.formRef
|
|
707
722
|
}, {
|
|
@@ -774,7 +789,7 @@ const ye = {
|
|
|
774
789
|
},
|
|
775
790
|
validateForm(r) {
|
|
776
791
|
return new Promise((e, t) => {
|
|
777
|
-
r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(
|
|
792
|
+
r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))));
|
|
778
793
|
});
|
|
779
794
|
},
|
|
780
795
|
clearValidate(r) {
|
|
@@ -833,7 +848,7 @@ const ye = {
|
|
|
833
848
|
valid: s,
|
|
834
849
|
errors: i
|
|
835
850
|
}) => {
|
|
836
|
-
s ? e(r.cleanFallbackFields(
|
|
851
|
+
s ? e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))) : t(i);
|
|
837
852
|
});
|
|
838
853
|
});
|
|
839
854
|
},
|
|
@@ -889,14 +904,14 @@ const ye = {
|
|
|
889
904
|
},
|
|
890
905
|
validateForm(r) {
|
|
891
906
|
return new Promise((e, t) => {
|
|
892
|
-
r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(
|
|
907
|
+
r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))));
|
|
893
908
|
});
|
|
894
909
|
},
|
|
895
910
|
clearValidate(r) {
|
|
896
911
|
r.formRef.value.restoreValidation();
|
|
897
912
|
}
|
|
898
913
|
}
|
|
899
|
-
},
|
|
914
|
+
}, w = class w {
|
|
900
915
|
static getPlaceholderPrefixPresetByComponentName() {
|
|
901
916
|
const e = {
|
|
902
917
|
请选择: ["select", "tree"],
|
|
@@ -909,7 +924,7 @@ const ye = {
|
|
|
909
924
|
return t;
|
|
910
925
|
}
|
|
911
926
|
};
|
|
912
|
-
a(
|
|
927
|
+
a(w, "schemaPreset", {
|
|
913
928
|
type: {
|
|
914
929
|
defaultValue: "item"
|
|
915
930
|
},
|
|
@@ -952,15 +967,15 @@ a(S, "schemaPreset", {
|
|
|
952
967
|
grid: {
|
|
953
968
|
default: void 0
|
|
954
969
|
}
|
|
955
|
-
}), a(
|
|
970
|
+
}), a(w, "componentPropsPreset", {
|
|
956
971
|
options: {
|
|
957
972
|
defaultValue: []
|
|
958
973
|
}
|
|
959
974
|
}), // 基于基本功能提出基本预设
|
|
960
|
-
a(
|
|
961
|
-
let
|
|
975
|
+
a(w, "placeholderPresetByComponentName", w.getPlaceholderPrefixPresetByComponentName());
|
|
976
|
+
let x = w;
|
|
962
977
|
const P = {
|
|
963
|
-
...
|
|
978
|
+
...x,
|
|
964
979
|
adapters: {
|
|
965
980
|
...ye
|
|
966
981
|
}
|
|
@@ -990,23 +1005,23 @@ function Ce(r) {
|
|
|
990
1005
|
function Ie(r) {
|
|
991
1006
|
f.presets = r;
|
|
992
1007
|
}
|
|
993
|
-
function
|
|
1008
|
+
function ve(r, e) {
|
|
994
1009
|
return e === "native" && Object.defineProperty(r, "name", {
|
|
995
1010
|
value: `__proform_raw_${r.name}`,
|
|
996
1011
|
writable: !0
|
|
997
1012
|
}), r;
|
|
998
1013
|
}
|
|
999
1014
|
function Ee(r) {
|
|
1000
|
-
return
|
|
1015
|
+
return ve(r, "native");
|
|
1001
1016
|
}
|
|
1002
|
-
function
|
|
1017
|
+
function je(r) {
|
|
1003
1018
|
return r.__proform_raw_object = !0, r;
|
|
1004
1019
|
}
|
|
1005
1020
|
export {
|
|
1006
1021
|
ge as ProForm,
|
|
1007
1022
|
Ee as markNativeFunction,
|
|
1008
|
-
|
|
1023
|
+
je as markNativeObject,
|
|
1009
1024
|
Ce as useForm,
|
|
1010
1025
|
Ie as useFormPresetConfigurer,
|
|
1011
|
-
|
|
1026
|
+
ve as useModifiers
|
|
1012
1027
|
};
|
|
@@ -2,6 +2,7 @@ import { AnyObject } from "../../types";
|
|
|
2
2
|
export default class RuntimeAdpter {
|
|
3
3
|
ui: string;
|
|
4
4
|
constructor(ui: string);
|
|
5
|
+
getRuntimeNative(): import("../../types").NativeCustomizationOptions | undefined;
|
|
5
6
|
getRuntimeField(runtimeArgs: AnyObject): any;
|
|
6
7
|
getRuntimeRequired(runtimeArgs: AnyObject): any;
|
|
7
8
|
getFormModelPropName(): any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdaptedInterface } from ".";
|
|
1
|
+
import { AdaptedInterface, NativeCustomizationOptions } from ".";
|
|
2
2
|
import { AnyObject } from "./utilTypes";
|
|
3
3
|
export type DomType = new (...args: any) => AnyObject & {
|
|
4
4
|
$props: AnyObject;
|
|
@@ -13,6 +13,7 @@ export interface FormPreset {
|
|
|
13
13
|
Group: DomType;
|
|
14
14
|
};
|
|
15
15
|
adapter?: AdaptedInterface;
|
|
16
|
+
native?: NativeCustomizationOptions;
|
|
16
17
|
}
|
|
17
18
|
export type UIName = "ArcoVue" | "NutUI" | "NaiveUI" | (string & {});
|
|
18
19
|
export type AdaptedInterfacePreset = Record<UIName, AdaptedInterface>;
|