@harbor-design/proform 1.1.39 → 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);
|
|
@@ -148,7 +148,7 @@ class fe {
|
|
|
148
148
|
});
|
|
149
149
|
this.runtimeCore.hydrateEffect.trackEffect(
|
|
150
150
|
() => {
|
|
151
|
-
|
|
151
|
+
N(e) ? b(
|
|
152
152
|
() => e.value,
|
|
153
153
|
() => {
|
|
154
154
|
h(this.runtimeCore.model.value, e.value);
|
|
@@ -157,7 +157,7 @@ class fe {
|
|
|
157
157
|
deep: !0,
|
|
158
158
|
immediate: !0
|
|
159
159
|
}
|
|
160
|
-
) :
|
|
160
|
+
) : q(e) ? b(
|
|
161
161
|
() => e,
|
|
162
162
|
() => {
|
|
163
163
|
h(this.runtimeCore.model.value, e);
|
|
@@ -174,8 +174,8 @@ class fe {
|
|
|
174
174
|
);
|
|
175
175
|
}
|
|
176
176
|
share(e) {
|
|
177
|
-
if (
|
|
178
|
-
const t =
|
|
177
|
+
if (N(e)) {
|
|
178
|
+
const t = b(
|
|
179
179
|
() => e.value,
|
|
180
180
|
() => {
|
|
181
181
|
h(this.runtimeCore.shared, e.value), this.runtimeCore.processor.schemaEffect.triggerEffects(), E(() => {
|
|
@@ -187,8 +187,8 @@ class fe {
|
|
|
187
187
|
immediate: !0
|
|
188
188
|
}
|
|
189
189
|
);
|
|
190
|
-
} else if (
|
|
191
|
-
const t =
|
|
190
|
+
} else if (q(e)) {
|
|
191
|
+
const t = b(
|
|
192
192
|
() => e,
|
|
193
193
|
() => {
|
|
194
194
|
h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects(), E(() => {
|
|
@@ -237,7 +237,7 @@ class de {
|
|
|
237
237
|
a(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
|
|
238
238
|
a(this, "baseDefaultValueFunctionsLength");
|
|
239
239
|
a(this, "isModelInitialized", !0);
|
|
240
|
-
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(
|
|
241
241
|
() => this.processedModel.value,
|
|
242
242
|
() => {
|
|
243
243
|
this.schemaEffect.triggerEffects();
|
|
@@ -289,7 +289,7 @@ class de {
|
|
|
289
289
|
// 对于稳定初始化更新的抽象
|
|
290
290
|
stableUpdater(e = []) {
|
|
291
291
|
if (e.every(Boolean)) {
|
|
292
|
-
const t =
|
|
292
|
+
const t = R(this.processedSchemas.value);
|
|
293
293
|
!l.isProcessInprogress(t) && l.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
|
|
294
294
|
length: t.length
|
|
295
295
|
}).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
|
|
@@ -302,12 +302,12 @@ class de {
|
|
|
302
302
|
}).fill(!1);
|
|
303
303
|
this.objectParser({ data: e, index: t, updater: n });
|
|
304
304
|
function n(c) {
|
|
305
|
-
const u = c.index, d = c.key,
|
|
305
|
+
const u = c.index, d = c.key, v = c.keyIndex;
|
|
306
306
|
if (l.isUndefined(c.stable))
|
|
307
307
|
return;
|
|
308
|
-
const
|
|
309
|
-
let y =
|
|
310
|
-
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) {
|
|
311
311
|
const m = i.processedSchemas.value[I][g][u][d];
|
|
312
312
|
m && l.isObject(m) && d !== "component" && (y = h(m, y)), i.processedSchemas.value[I][g][u][d] = y, i.stableUpdater(o);
|
|
313
313
|
} else {
|
|
@@ -404,7 +404,7 @@ class de {
|
|
|
404
404
|
this.promiseFieldParser(i, t, s);
|
|
405
405
|
}
|
|
406
406
|
else
|
|
407
|
-
|
|
407
|
+
N(e) ? b(
|
|
408
408
|
() => e.value,
|
|
409
409
|
() => {
|
|
410
410
|
l.isUndefined(e.value) || (s && l.isObject(e.value) && !l.isNativeObject(e.value) ? this.objectParser({
|
|
@@ -416,7 +416,7 @@ class de {
|
|
|
416
416
|
immediate: !0,
|
|
417
417
|
deep: !0
|
|
418
418
|
}
|
|
419
|
-
) :
|
|
419
|
+
) : q(e) ? b(
|
|
420
420
|
() => e,
|
|
421
421
|
() => {
|
|
422
422
|
l.isUndefined(e) || (s && l.isObject(e) && !l.isNativeObject(e) ? this.objectParser({
|
|
@@ -446,7 +446,7 @@ class de {
|
|
|
446
446
|
}), l.isItemSchema(e) && ("defaultValue" in e ? t[e.field] = e.defaultValue : t[e.field] || (t[e.field] = void 0));
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
|
-
class
|
|
449
|
+
class F {
|
|
450
450
|
static getFormContainer({ ui: e } = {}) {
|
|
451
451
|
return f.presets.uiPresets[e ?? f.presets.ui].container.Form;
|
|
452
452
|
}
|
|
@@ -470,6 +470,10 @@ class he {
|
|
|
470
470
|
constructor(e) {
|
|
471
471
|
this.ui = e;
|
|
472
472
|
}
|
|
473
|
+
getRuntimeNative() {
|
|
474
|
+
var t;
|
|
475
|
+
return (t = f.presets.uiPresets[this.ui]) == null ? void 0 : t.native;
|
|
476
|
+
}
|
|
473
477
|
getRuntimeField(e) {
|
|
474
478
|
var i;
|
|
475
479
|
const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[this.ui];
|
|
@@ -520,8 +524,8 @@ class me {
|
|
|
520
524
|
a(this, "shared", {});
|
|
521
525
|
this.setup = e, this.processor = new de(this);
|
|
522
526
|
const t = this.setup(this);
|
|
523
|
-
if (this.ui = t.ui ?? f.presets.ui, this.runtimeAdapter = new he(this.ui),
|
|
524
|
-
|
|
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(
|
|
525
529
|
// @ts-expect-error
|
|
526
530
|
() => t.schemas.value,
|
|
527
531
|
() => {
|
|
@@ -531,8 +535,8 @@ class me {
|
|
|
531
535
|
deep: !0
|
|
532
536
|
}
|
|
533
537
|
);
|
|
534
|
-
else if (
|
|
535
|
-
const s =
|
|
538
|
+
else if (q(t.schemas)) {
|
|
539
|
+
const s = b(() => t.schemas, () => {
|
|
536
540
|
this.processor.parseSchemas(t.schemas), E(() => {
|
|
537
541
|
s();
|
|
538
542
|
});
|
|
@@ -544,12 +548,12 @@ class me {
|
|
|
544
548
|
}
|
|
545
549
|
getRuntimeMeta() {
|
|
546
550
|
return {
|
|
547
|
-
model:
|
|
551
|
+
model: R(C(this.model.value)),
|
|
548
552
|
reactiveModel: this.model.value,
|
|
549
553
|
shared: this.shared,
|
|
550
554
|
share: (t) => {
|
|
551
|
-
if (
|
|
552
|
-
const s =
|
|
555
|
+
if (N(t)) {
|
|
556
|
+
const s = b(() => t.value, () => {
|
|
553
557
|
h(this.shared, t.value), this.processor.schemaEffect.triggerEffects(), E(() => {
|
|
554
558
|
s();
|
|
555
559
|
});
|
|
@@ -557,8 +561,8 @@ class me {
|
|
|
557
561
|
deep: !0,
|
|
558
562
|
immediate: !0
|
|
559
563
|
});
|
|
560
|
-
} else if (
|
|
561
|
-
const s =
|
|
564
|
+
} else if (q(t)) {
|
|
565
|
+
const s = b(() => t, () => {
|
|
562
566
|
h(this.shared, t), this.processor.schemaEffect.triggerEffects(), E(() => {
|
|
563
567
|
s();
|
|
564
568
|
});
|
|
@@ -572,11 +576,11 @@ class me {
|
|
|
572
576
|
};
|
|
573
577
|
}
|
|
574
578
|
runtimeItemProcessor(e, t, s = this.model.value, i) {
|
|
575
|
-
var
|
|
576
|
-
const o =
|
|
579
|
+
var z, k, $, B, D, G, T, W, K, H, J, Q, X;
|
|
580
|
+
const o = R(e.component);
|
|
577
581
|
if (!o)
|
|
578
582
|
return;
|
|
579
|
-
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);
|
|
580
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 = {
|
|
581
585
|
display: "grid",
|
|
582
586
|
gridColumn: "1 / -1",
|
|
@@ -585,22 +589,22 @@ class me {
|
|
|
585
589
|
schema: e,
|
|
586
590
|
parentSchema: i,
|
|
587
591
|
index: t
|
|
588
|
-
}),
|
|
592
|
+
}), v = o.name, j = e.componentProps ?? {}, I = P.placeholderPresetByComponentName;
|
|
589
593
|
let g = e.placeholder, y = e.show;
|
|
590
594
|
y === void 0 && (y = !0), y || delete s[e.field];
|
|
591
595
|
let m = e.label ?? "";
|
|
592
|
-
const
|
|
593
|
-
if (!l.isUndefined(t) && !l.isObjectEmpty(
|
|
594
|
-
let
|
|
595
|
-
l.isUndefined(
|
|
596
|
-
I[
|
|
597
|
-
|
|
598
|
-
}), 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}`);
|
|
599
603
|
}
|
|
600
604
|
const Z = this.runtimeAdapter.getRuntimeRequired({
|
|
601
605
|
...e,
|
|
602
606
|
label: m
|
|
603
|
-
}), A =
|
|
607
|
+
}), A = F.getItemContainer(this), ee = F.getFormItemContainer(this), te = this, se = e.componentSlots;
|
|
604
608
|
return p("div", {
|
|
605
609
|
style: c
|
|
606
610
|
}, [p(A, {
|
|
@@ -617,7 +621,7 @@ class me {
|
|
|
617
621
|
baseModel: s,
|
|
618
622
|
placeholder: g,
|
|
619
623
|
componentSlots: se,
|
|
620
|
-
props:
|
|
624
|
+
props: j
|
|
621
625
|
});
|
|
622
626
|
},
|
|
623
627
|
...n
|
|
@@ -631,7 +635,7 @@ class me {
|
|
|
631
635
|
display: "grid",
|
|
632
636
|
gridColumn: "1 / -1",
|
|
633
637
|
...e.grid
|
|
634
|
-
}, i =
|
|
638
|
+
}, i = F.getGroupContainer(this);
|
|
635
639
|
let o = e.show;
|
|
636
640
|
return o === void 0 && (o = !0), p("div", {
|
|
637
641
|
style: s
|
|
@@ -662,7 +666,7 @@ class me {
|
|
|
662
666
|
s.model.value[e.field] || (s.model.value[e.field] = [{}]);
|
|
663
667
|
let i = e.show;
|
|
664
668
|
i === void 0 && (i = !0);
|
|
665
|
-
const o =
|
|
669
|
+
const o = F.getListContainer(this), n = F.getListItemContainer(this);
|
|
666
670
|
return p("div", {
|
|
667
671
|
style: t
|
|
668
672
|
}, [i && p(o, {
|
|
@@ -676,11 +680,11 @@ class me {
|
|
|
676
680
|
delete({
|
|
677
681
|
container: d
|
|
678
682
|
} = {}) {
|
|
679
|
-
var
|
|
680
|
-
const
|
|
681
|
-
return ne(p(
|
|
683
|
+
var j;
|
|
684
|
+
const v = d ?? p("button", null, null);
|
|
685
|
+
return ne(p(v, {
|
|
682
686
|
onClick: () => s.deleteListItem(e, u)
|
|
683
|
-
}, null), [[le, ((
|
|
687
|
+
}, null), [[le, ((j = s.model.value[e.field]) == null ? void 0 : j.length) > 1]]);
|
|
684
688
|
}
|
|
685
689
|
}));
|
|
686
690
|
},
|
|
@@ -698,13 +702,21 @@ class me {
|
|
|
698
702
|
return e.map((t) => (t.type || (t.type = "item"), this.processorBySchemaType[t.type](t)));
|
|
699
703
|
}
|
|
700
704
|
exec() {
|
|
701
|
-
var c, u, d,
|
|
705
|
+
var c, u, d, v;
|
|
702
706
|
const e = {
|
|
703
707
|
display: "grid",
|
|
704
708
|
gridColumn: "1 / -1",
|
|
705
709
|
gridAutoColumns: "1fr",
|
|
706
710
|
...this.grid
|
|
707
|
-
}, 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();
|
|
708
720
|
return p(o, O(s, {
|
|
709
721
|
ref: this.formRef
|
|
710
722
|
}, {
|
|
@@ -777,7 +789,7 @@ const ye = {
|
|
|
777
789
|
},
|
|
778
790
|
validateForm(r) {
|
|
779
791
|
return new Promise((e, t) => {
|
|
780
|
-
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))));
|
|
781
793
|
});
|
|
782
794
|
},
|
|
783
795
|
clearValidate(r) {
|
|
@@ -836,7 +848,7 @@ const ye = {
|
|
|
836
848
|
valid: s,
|
|
837
849
|
errors: i
|
|
838
850
|
}) => {
|
|
839
|
-
s ? e(r.cleanFallbackFields(
|
|
851
|
+
s ? e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))) : t(i);
|
|
840
852
|
});
|
|
841
853
|
});
|
|
842
854
|
},
|
|
@@ -892,14 +904,14 @@ const ye = {
|
|
|
892
904
|
},
|
|
893
905
|
validateForm(r) {
|
|
894
906
|
return new Promise((e, t) => {
|
|
895
|
-
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))));
|
|
896
908
|
});
|
|
897
909
|
},
|
|
898
910
|
clearValidate(r) {
|
|
899
911
|
r.formRef.value.restoreValidation();
|
|
900
912
|
}
|
|
901
913
|
}
|
|
902
|
-
},
|
|
914
|
+
}, w = class w {
|
|
903
915
|
static getPlaceholderPrefixPresetByComponentName() {
|
|
904
916
|
const e = {
|
|
905
917
|
请选择: ["select", "tree"],
|
|
@@ -912,7 +924,7 @@ const ye = {
|
|
|
912
924
|
return t;
|
|
913
925
|
}
|
|
914
926
|
};
|
|
915
|
-
a(
|
|
927
|
+
a(w, "schemaPreset", {
|
|
916
928
|
type: {
|
|
917
929
|
defaultValue: "item"
|
|
918
930
|
},
|
|
@@ -955,15 +967,15 @@ a(S, "schemaPreset", {
|
|
|
955
967
|
grid: {
|
|
956
968
|
default: void 0
|
|
957
969
|
}
|
|
958
|
-
}), a(
|
|
970
|
+
}), a(w, "componentPropsPreset", {
|
|
959
971
|
options: {
|
|
960
972
|
defaultValue: []
|
|
961
973
|
}
|
|
962
974
|
}), // 基于基本功能提出基本预设
|
|
963
|
-
a(
|
|
964
|
-
let
|
|
975
|
+
a(w, "placeholderPresetByComponentName", w.getPlaceholderPrefixPresetByComponentName());
|
|
976
|
+
let x = w;
|
|
965
977
|
const P = {
|
|
966
|
-
...
|
|
978
|
+
...x,
|
|
967
979
|
adapters: {
|
|
968
980
|
...ye
|
|
969
981
|
}
|
|
@@ -993,23 +1005,23 @@ function Ce(r) {
|
|
|
993
1005
|
function Ie(r) {
|
|
994
1006
|
f.presets = r;
|
|
995
1007
|
}
|
|
996
|
-
function
|
|
1008
|
+
function ve(r, e) {
|
|
997
1009
|
return e === "native" && Object.defineProperty(r, "name", {
|
|
998
1010
|
value: `__proform_raw_${r.name}`,
|
|
999
1011
|
writable: !0
|
|
1000
1012
|
}), r;
|
|
1001
1013
|
}
|
|
1002
1014
|
function Ee(r) {
|
|
1003
|
-
return
|
|
1015
|
+
return ve(r, "native");
|
|
1004
1016
|
}
|
|
1005
|
-
function
|
|
1017
|
+
function je(r) {
|
|
1006
1018
|
return r.__proform_raw_object = !0, r;
|
|
1007
1019
|
}
|
|
1008
1020
|
export {
|
|
1009
1021
|
ge as ProForm,
|
|
1010
1022
|
Ee as markNativeFunction,
|
|
1011
|
-
|
|
1023
|
+
je as markNativeObject,
|
|
1012
1024
|
Ce as useForm,
|
|
1013
1025
|
Ie as useFormPresetConfigurer,
|
|
1014
|
-
|
|
1026
|
+
ve as useModifiers
|
|
1015
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>;
|