@harbor-design/proform 1.3.1 → 1.3.2

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
- var Te = Object.defineProperty;
2
- var ze = (t, e, r) => e in t ? Te(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
1
+ var Ue = Object.defineProperty;
2
+ var ze = (t, e, r) => e in t ? Ue(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var u = (t, e, r) => (ze(t, typeof e != "symbol" ? e + "" : e, r), r);
4
- import { ref as z, readonly as _e, nextTick as P, isRef as q, watch as _, isReactive as U, toRaw as E, reactive as Pe, createVNode as y, mergeProps as N, withDirectives as Le, vShow as De, createTextVNode as Ge, isVNode as Be, defineComponent as ke } from "vue";
4
+ import { ref as z, readonly as _e, nextTick as P, isRef as T, watch as _, isReactive as q, toRaw as E, reactive as Pe, createVNode as g, mergeProps as N, withDirectives as Le, vShow as De, createTextVNode as Ge, isVNode as Be, defineComponent as ke } from "vue";
5
5
  class o {
6
6
  static typeChecker(e) {
7
7
  return {}.toString.call(e);
@@ -145,7 +145,7 @@ class He {
145
145
  P(() => {
146
146
  this.runtimeCore.hydrateEffect.trackEffect(
147
147
  () => {
148
- q(e) ? _(
148
+ T(e) ? _(
149
149
  () => e.value,
150
150
  () => {
151
151
  h(this.runtimeCore.model.value, e.value);
@@ -154,7 +154,7 @@ class He {
154
154
  deep: !0,
155
155
  immediate: !0
156
156
  }
157
- ) : U(e) ? _(
157
+ ) : q(e) ? _(
158
158
  () => e,
159
159
  () => {
160
160
  h(this.runtimeCore.model.value, e);
@@ -173,7 +173,7 @@ class He {
173
173
  }
174
174
  share(e) {
175
175
  P(() => {
176
- if (q(e)) {
176
+ if (T(e)) {
177
177
  const r = _(
178
178
  () => e.value,
179
179
  () => {
@@ -186,7 +186,7 @@ class He {
186
186
  immediate: !0
187
187
  }
188
188
  );
189
- } else if (U(e)) {
189
+ } else if (q(e)) {
190
190
  const r = _(
191
191
  () => e,
192
192
  () => {
@@ -321,13 +321,13 @@ function ht(t) {
321
321
  }
322
322
  return "";
323
323
  }
324
- var mt = /[\\^$.*+?()[\]{}|]/g, yt = /^\[object .+?Constructor\]$/, gt = Function.prototype, bt = Object.prototype, vt = gt.toString, _t = bt.hasOwnProperty, Pt = RegExp(
324
+ var mt = /[\\^$.*+?()[\]{}|]/g, gt = /^\[object .+?Constructor\]$/, yt = Function.prototype, bt = Object.prototype, vt = yt.toString, _t = bt.hasOwnProperty, Pt = RegExp(
325
325
  "^" + vt.call(_t).replace(mt, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
326
326
  );
327
327
  function Ct(t) {
328
328
  if (!G(t) || ft(t))
329
329
  return !1;
330
- var e = ct(t) ? Pt : yt;
330
+ var e = ct(t) ? Pt : gt;
331
331
  return e.test(ht(t));
332
332
  }
333
333
  function It(t, e) {
@@ -371,32 +371,32 @@ function $t(t, e) {
371
371
  var r = typeof t;
372
372
  return r == "number" || r == "symbol" || r == "boolean" || t == null || J(t) ? !0 : Rt.test(t) || !xt.test(t) || e != null && t in Object(e);
373
373
  }
374
- var T = A(Object, "create");
374
+ var U = A(Object, "create");
375
375
  function Vt() {
376
- this.__data__ = T ? T(null) : {}, this.size = 0;
376
+ this.__data__ = U ? U(null) : {}, this.size = 0;
377
377
  }
378
378
  function Nt(t) {
379
379
  var e = this.has(t) && delete this.__data__[t];
380
380
  return this.size -= e ? 1 : 0, e;
381
381
  }
382
- var qt = "__lodash_hash_undefined__", Ut = Object.prototype, Tt = Ut.hasOwnProperty;
382
+ var Tt = "__lodash_hash_undefined__", qt = Object.prototype, Ut = qt.hasOwnProperty;
383
383
  function zt(t) {
384
384
  var e = this.__data__;
385
- if (T) {
385
+ if (U) {
386
386
  var r = e[t];
387
- return r === qt ? void 0 : r;
387
+ return r === Tt ? void 0 : r;
388
388
  }
389
- return Tt.call(e, t) ? e[t] : void 0;
389
+ return Ut.call(e, t) ? e[t] : void 0;
390
390
  }
391
391
  var Lt = Object.prototype, Dt = Lt.hasOwnProperty;
392
392
  function Gt(t) {
393
393
  var e = this.__data__;
394
- return T ? e[t] !== void 0 : Dt.call(e, t);
394
+ return U ? e[t] !== void 0 : Dt.call(e, t);
395
395
  }
396
396
  var Bt = "__lodash_hash_undefined__";
397
397
  function kt(t, e) {
398
398
  var r = this.__data__;
399
- return this.size += this.has(t) ? 0 : 1, r[t] = T && e === void 0 ? Bt : e, this;
399
+ return this.size += this.has(t) ? 0 : 1, r[t] = U && e === void 0 ? Bt : e, this;
400
400
  }
401
401
  function F(t) {
402
402
  var e = -1, r = t == null ? 0 : t.length;
@@ -578,10 +578,13 @@ class mr {
578
578
  u(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
579
579
  u(this, "baseDefaultValueFunctionsLength");
580
580
  u(this, "isModelInitialized", !0);
581
+ u(this, "modelTriggerTimer");
581
582
  this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), _(
582
583
  () => this.processedModel.value,
583
584
  () => {
584
- this.schemaEffect.triggerEffects();
585
+ this.modelTriggerTimer && clearTimeout(this.modelTriggerTimer), this.modelTriggerTimer = setTimeout(() => {
586
+ this.schemaEffect.triggerEffects();
587
+ }, 0);
585
588
  },
586
589
  {
587
590
  deep: !0
@@ -649,11 +652,11 @@ class mr {
649
652
  const m = s.parseStable(l.stable), b = i == null ? void 0 : i.index, S = i == null ? void 0 : i.key;
650
653
  let v = m;
651
654
  if (o.isProcessInprogress(v) || (n[p] = !0), i) {
652
- const g = s.processedSchemas.value[b][S][c][d];
653
- g && o.isObject(g) && d !== "component" && (v = h(g, v)), s.processedSchemas.value[b][S][c][d] = v, s.stableUpdater(n);
655
+ const y = s.processedSchemas.value[b][S][c][d];
656
+ y && o.isObject(y) && d !== "component" && (v = h(y, v)), s.processedSchemas.value[b][S][c][d] = v, s.stableUpdater(n);
654
657
  } else {
655
- const g = s.processedSchemas.value[c][d];
656
- g && o.isObject(g) && d !== "component" && (v = h(g, v)), s.processedSchemas.value[c][d] = v, s.stableUpdater(n);
658
+ const y = s.processedSchemas.value[c][d];
659
+ y && o.isObject(y) && d !== "component" && (v = h(y, v)), s.processedSchemas.value[c][d] = v, s.stableUpdater(n);
657
660
  }
658
661
  }
659
662
  }
@@ -788,7 +791,7 @@ class mr {
788
791
  e.name.startsWith("__proform_onetime_") && (e.__proform_cached_result = n), this.promiseFieldParser(n, r, s, i);
789
792
  }
790
793
  else
791
- q(e) ? _(
794
+ T(e) ? _(
792
795
  () => e.value,
793
796
  () => {
794
797
  o.isUndefined(e.value) || (s && o.isObject(e.value) && !o.isNativeObject(e.value) ? this.objectParser({
@@ -802,7 +805,7 @@ class mr {
802
805
  immediate: !0,
803
806
  deep: !0
804
807
  }
805
- ) : U(e) ? _(
808
+ ) : q(e) ? (console.log("root", e), _(
806
809
  () => e,
807
810
  () => {
808
811
  o.isUndefined(e) || (s && o.isObject(e) && !o.isNativeObject(e) ? this.objectParser({
@@ -816,7 +819,7 @@ class mr {
816
819
  immediate: !0,
817
820
  deep: !0
818
821
  }
819
- ) : s && o.isObject(e) && !o.isNativeObject(e) ? this.objectParser({
822
+ )) : s && o.isObject(e) && !o.isNativeObject(e) ? this.objectParser({
820
823
  data: e,
821
824
  updater: r,
822
825
  index: i.rootIndex,
@@ -868,7 +871,7 @@ class w {
868
871
  return f.presets.uiPresets[e ?? f.presets.ui].container.ListItem;
869
872
  }
870
873
  }
871
- class yr {
874
+ class gr {
872
875
  constructor(e) {
873
876
  this.ui = e;
874
877
  }
@@ -902,7 +905,7 @@ class yr {
902
905
  return (r == null ? void 0 : r.clearValidate(e)) ?? (i == null ? void 0 : i.clearValidate(e));
903
906
  }
904
907
  }
905
- function gr(t) {
908
+ function yr(t) {
906
909
  return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !Be(t);
907
910
  }
908
911
  class br {
@@ -932,7 +935,7 @@ class br {
932
935
  u(this, "shared", {});
933
936
  this.setup = e, this.processor = new mr(this);
934
937
  const r = this.setup(this);
935
- if (this.ui = r.ui ?? f.presets.ui, this.runtimeAdapter = new yr(this.ui), Object.assign(this.globalNativeFormOverride, this.runtimeAdapter.getRuntimeNative()), q(r.schemas))
938
+ if (this.ui = r.ui ?? f.presets.ui, this.runtimeAdapter = new gr(this.ui), Object.assign(this.globalNativeFormOverride, this.runtimeAdapter.getRuntimeNative()), T(r.schemas))
936
939
  _(
937
940
  // @ts-expect-error
938
941
  () => r.schemas.value,
@@ -943,7 +946,7 @@ class br {
943
946
  deep: !0
944
947
  }
945
948
  );
946
- else if (U(r.schemas)) {
949
+ else if (q(r.schemas)) {
947
950
  const i = _(() => r.schemas, () => {
948
951
  this.processor.parseSchemas(r.schemas), P(() => {
949
952
  i();
@@ -961,7 +964,7 @@ class br {
961
964
  shared: this.shared,
962
965
  // share 增加防抖,当开发者在过程中进行 share 时避免频繁触发爆栈
963
966
  share: (r) => {
964
- if (q(r)) {
967
+ if (T(r)) {
965
968
  const i = _(() => r.value, () => {
966
969
  h(this.shared, r.value), P(() => {
967
970
  i();
@@ -970,7 +973,7 @@ class br {
970
973
  deep: !0,
971
974
  immediate: !0
972
975
  });
973
- } else if (U(r)) {
976
+ } else if (q(r)) {
974
977
  const i = _(() => r, () => {
975
978
  h(this.shared, r), P(() => {
976
979
  i();
@@ -985,7 +988,7 @@ class br {
985
988
  };
986
989
  }
987
990
  runtimeItemProcessor(e, r, i = this.model.value, s) {
988
- var re, ie, se, ne, oe, ae, le, ue, ce, fe, de, pe, he, me, ye, ge, be;
991
+ var re, ie, se, ne, oe, ae, le, ue, ce, fe, de, pe, he, me, ge, ye, be;
989
992
  const n = E(e.component);
990
993
  if (!n)
991
994
  return;
@@ -994,41 +997,41 @@ class br {
994
997
  display: "grid",
995
998
  gridColumn: "1 / -1",
996
999
  ...e.grid
997
- }, c = h(C((me = (he = this.native) == null ? void 0 : he.props) == null ? void 0 : me.FormItem) ?? {}, (ge = (ye = e.native) == null ? void 0 : ye.props) == null ? void 0 : ge.FormItem), d = this.runtimeAdapter.getRuntimeField({
1000
+ }, c = h(C((me = (he = this.native) == null ? void 0 : he.props) == null ? void 0 : me.FormItem) ?? {}, (ye = (ge = e.native) == null ? void 0 : ge.props) == null ? void 0 : ye.FormItem), d = this.runtimeAdapter.getRuntimeField({
998
1001
  schema: e,
999
1002
  parentSchema: s,
1000
1003
  index: r
1001
1004
  }), p = n.name, m = e.componentProps ?? {}, b = I.placeholderPresetByComponentName;
1002
1005
  let S = e.placeholder, v = e.show;
1003
1006
  v === void 0 && (v = !0);
1004
- let g = e.label ?? "", O;
1005
- if (e.runtime ? O = e.runtime : O = (s == null ? void 0 : s.runtime) ?? this.runtime, !o.isUndefined(r) && !o.isObjectEmpty(O) && (g = K((be = O == null ? void 0 : O.customizeListItemLabel) == null ? void 0 : be.call(O, e.label ?? "", r + 1), "")), !S) {
1007
+ let y = e.label ?? "", O;
1008
+ if (e.runtime ? O = e.runtime : O = (s == null ? void 0 : s.runtime) ?? this.runtime, !o.isUndefined(r) && !o.isObjectEmpty(O) && (y = K((be = O == null ? void 0 : O.customizeListItemLabel) == null ? void 0 : be.call(O, e.label ?? "", r + 1), "")), !S) {
1006
1009
  let $ = "请输入";
1007
- o.isUndefined(p) ? S = `${$}${g}` : /* @ts-expect-error */ b[p.toLowerCase()] ? ($ = // @ts-expect-error
1008
- b[p.toLowerCase()], S = `${$}${g}`) : (Object.keys(b).forEach((ve) => {
1010
+ o.isUndefined(p) ? S = `${$}${y}` : /* @ts-expect-error */ b[p.toLowerCase()] ? ($ = // @ts-expect-error
1011
+ b[p.toLowerCase()], S = `${$}${y}`) : (Object.keys(b).forEach((ve) => {
1009
1012
  p.toLowerCase().includes(ve.toLowerCase()) && ($ = b[ve]);
1010
- }), S = `${$}${g}`);
1013
+ }), S = `${$}${y}`);
1011
1014
  }
1012
1015
  const $e = this.runtimeAdapter.getRuntimeRequired({
1013
1016
  ...e,
1014
- label: g
1015
- }), Ve = w.getItemContainer(this), Ne = w.getFormItemContainer(this), qe = this, Ue = e.componentSlots;
1016
- return y("div", {
1017
+ label: y
1018
+ }), Ve = w.getItemContainer(this), Ne = w.getFormItemContainer(this), Te = this, qe = e.componentSlots;
1019
+ return g("div", {
1017
1020
  style: l
1018
- }, [y(Ve, {
1021
+ }, [g(Ve, {
1019
1022
  show: v
1020
1023
  }, {
1021
1024
  default() {
1022
- return v && y(Ne, N(c, {
1023
- label: `${g ? `${g}:` : ""}`
1025
+ return v && g(Ne, N(c, {
1026
+ label: `${y ? `${y}:` : ""}`
1024
1027
  }, d, $e), {
1025
1028
  default() {
1026
- return qe.runtimeAdapter.formComponentRenderer({
1029
+ return Te.runtimeAdapter.formComponentRenderer({
1027
1030
  Component: n,
1028
1031
  schema: e,
1029
1032
  baseModel: i,
1030
1033
  placeholder: S,
1031
- componentSlots: Ue,
1034
+ componentSlots: qe,
1032
1035
  props: m
1033
1036
  });
1034
1037
  },
@@ -1045,11 +1048,11 @@ class br {
1045
1048
  ...e.grid
1046
1049
  }, s = w.getGroupContainer(this);
1047
1050
  let n = e.show;
1048
- return n === void 0 && (n = !0), y("div", {
1051
+ return n === void 0 && (n = !0), g("div", {
1049
1052
  style: i
1050
- }, [n && y(s, {
1053
+ }, [n && g(s, {
1051
1054
  schema: e
1052
- }, gr(r = e.children.map((a) => this.runtimeItemProcessor(a))) ? r : {
1055
+ }, yr(r = e.children.map((a) => this.runtimeItemProcessor(a))) ? r : {
1053
1056
  default: () => [r]
1054
1057
  })]);
1055
1058
  }
@@ -1075,13 +1078,13 @@ class br {
1075
1078
  let s = e.show;
1076
1079
  s === void 0 && (s = !0);
1077
1080
  const n = w.getListContainer(this), a = w.getListItemContainer(this);
1078
- return y("div", {
1081
+ return g("div", {
1079
1082
  style: r
1080
- }, [s && y(n, {
1083
+ }, [s && g(n, {
1081
1084
  schema: e
1082
1085
  }, {
1083
1086
  default() {
1084
- return i.model.value[e.field].map((l, c) => y(a, null, {
1087
+ return i.model.value[e.field].map((l, c) => g(a, null, {
1085
1088
  default() {
1086
1089
  return e.children.map((d) => i.runtimeItemProcessor(d, c, l, e));
1087
1090
  },
@@ -1089,8 +1092,8 @@ class br {
1089
1092
  container: d
1090
1093
  } = {}) {
1091
1094
  var m;
1092
- const p = d ?? y("button", null, null);
1093
- return Le(y(p, {
1095
+ const p = d ?? g("button", null, null);
1096
+ return Le(g(p, {
1094
1097
  onClick: () => i.deleteListItem(e, c)
1095
1098
  }, null), [[De, ((m = i.model.value[e.field]) == null ? void 0 : m.length) > 1]]);
1096
1099
  }
@@ -1099,8 +1102,8 @@ class br {
1099
1102
  add({
1100
1103
  container: l
1101
1104
  } = {}) {
1102
- const c = l ?? y("button", null, [Ge("添加")]);
1103
- return y(c, {
1105
+ const c = l ?? g("button", null, [Ge("添加")]);
1106
+ return g(c, {
1104
1107
  onClick: () => i.addListItem(e)
1105
1108
  }, null);
1106
1109
  }
@@ -1117,13 +1120,13 @@ class br {
1117
1120
  gridAutoColumns: "1fr",
1118
1121
  ...this.grid
1119
1122
  }, r = this, i = h(this.globalNativeFormOverride.props.Form, C((c = (l = this.native) == null ? void 0 : l.props) == null ? void 0 : c.Form) ?? {}), s = h(this.globalNativeFormOverride.slots.Form, C((p = (d = this.native) == null ? void 0 : d.slots) == null ? void 0 : p.Form) ?? {}), n = w.getFormContainer(this), a = this.runtimeAdapter.getFormModelPropName();
1120
- return y(n, N(i, {
1123
+ return g(n, N(i, {
1121
1124
  ref: this.formRef
1122
1125
  }, {
1123
1126
  [a]: this.model.value
1124
1127
  }), {
1125
1128
  default() {
1126
- return y("div", {
1129
+ return g("div", {
1127
1130
  style: e
1128
1131
  }, [r.runtimeProcessor(r.schemas.value)]);
1129
1132
  },
@@ -1197,7 +1200,7 @@ const vr = {
1197
1200
  props: n
1198
1201
  }) {
1199
1202
  let a;
1200
- return o.isFunction(r.field) ? a = L(e, r.field()) : a = e[r.field], y(t, N({
1203
+ return o.isFunction(r.field) ? a = L(e, r.field()) : a = e[r.field], g(t, N({
1201
1204
  modelValue: a,
1202
1205
  "onUpdate:modelValue": (l) => {
1203
1206
  o.isFunction(r.field) ? D(e, r.field(), l) : e[r.field] = l;
@@ -1265,7 +1268,7 @@ const vr = {
1265
1268
  props: n
1266
1269
  }) {
1267
1270
  let a;
1268
- return o.isFunction(r.field) ? a = L(e, r.field()) : a = e[r.field], y(t, N({
1271
+ return o.isFunction(r.field) ? a = L(e, r.field()) : a = e[r.field], g(t, N({
1269
1272
  modelValue: a,
1270
1273
  "onUpdate:modelValue": (l) => {
1271
1274
  o.isFunction(r.field) ? D(e, r.field(), l) : e[r.field] = l;
@@ -1340,7 +1343,7 @@ const vr = {
1340
1343
  props: n
1341
1344
  }) {
1342
1345
  let a;
1343
- return o.isFunction(r.field) ? a = L(e, r.field()) : a = e[r.field], y(t, N({
1346
+ return o.isFunction(r.field) ? a = L(e, r.field()) : a = e[r.field], g(t, N({
1344
1347
  value: a,
1345
1348
  "onUpdate:value": (l) => {
1346
1349
  o.isFunction(r.field) ? D(e, r.field(), l) : e[r.field] = l;
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { Ref } from "vue";
2
3
  import { AnyObject, Schema, ProxyedSchema, AnyFunction, ObjectParserRoot } from "../../types";
3
4
  import { RuntimeCore } from "..";
@@ -22,6 +23,7 @@ export default class Processor {
22
23
  defaultValueInprogressMap: Map<any, any>;
23
24
  baseDefaultValueFunctionsLength: number;
24
25
  isModelInitialized: boolean;
26
+ modelTriggerTimer: NodeJS.Timeout;
25
27
  constructor(runtimeCore: RuntimeCore);
26
28
  parse<T extends object = any>(data: T[], parentMeta?: AnyObject): void;
27
29
  initSchemas(schemas: AnyObject[]): AnyObject[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harbor-design/proform",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",