@harbor-design/proform 1.2.27 → 1.2.29

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
@@ -246,16 +246,16 @@ class X {
246
246
  return !r.lazy && e(), this.effects.add(e), () => this.effects.delete(e);
247
247
  }
248
248
  }
249
- var We = typeof global == "object" && global && global.Object === Object && global, Ke = typeof self == "object" && self && self.Object === Object && self, Z = We || Ke || Function("return this")(), V = Z.Symbol, Ee = Object.prototype, Xe = Ee.hasOwnProperty, Ye = Ee.toString, M = V ? V.toStringTag : void 0;
249
+ var We = typeof global == "object" && global && global.Object === Object && global, Ke = typeof self == "object" && self && self.Object === Object && self, Z = We || Ke || Function("return this")(), V = Z.Symbol, Ee = Object.prototype, Xe = Ee.hasOwnProperty, Ye = Ee.toString, N = V ? V.toStringTag : void 0;
250
250
  function Ze(t) {
251
- var e = Xe.call(t, M), r = t[M];
251
+ var e = Xe.call(t, N), r = t[N];
252
252
  try {
253
- t[M] = void 0;
253
+ t[N] = void 0;
254
254
  var s = !0;
255
255
  } catch {
256
256
  }
257
257
  var i = Ye.call(t);
258
- return s && (e ? t[M] = r : delete t[M]), i;
258
+ return s && (e ? t[N] = r : delete t[N]), i;
259
259
  }
260
260
  var Je = Object.prototype, Qe = Je.toString;
261
261
  function Ae(t) {
@@ -288,19 +288,19 @@ function we(t) {
288
288
  var e = t + "";
289
289
  return e == "0" && 1 / t == -nt ? "-0" : e;
290
290
  }
291
- function D(t) {
291
+ function G(t) {
292
292
  var e = typeof t;
293
293
  return t != null && (e == "object" || e == "function");
294
294
  }
295
295
  var ot = "[object AsyncFunction]", at = "[object Function]", lt = "[object GeneratorFunction]", ut = "[object Proxy]";
296
296
  function ct(t) {
297
- if (!D(t))
297
+ if (!G(t))
298
298
  return !1;
299
299
  var e = je(t);
300
300
  return e == at || e == lt || e == ot || e == ut;
301
301
  }
302
- var B = Z["__core-js_shared__"], Oe = function() {
303
- var t = /[^.]+$/.exec(B && B.keys && B.keys.IE_PROTO || "");
302
+ var H = Z["__core-js_shared__"], Oe = function() {
303
+ var t = /[^.]+$/.exec(H && H.keys && H.keys.IE_PROTO || "");
304
304
  return t ? "Symbol(src)_1." + t : "";
305
305
  }();
306
306
  function ft(t) {
@@ -320,13 +320,13 @@ function ht(t) {
320
320
  }
321
321
  return "";
322
322
  }
323
- var mt = /[\\^$.*+?()[\]{}|]/g, yt = /^\[object .+?Constructor\]$/, gt = Function.prototype, bt = Object.prototype, vt = gt.toString, _t = bt.hasOwnProperty, Pt = RegExp(
323
+ var mt = /[\\^$.*+?()[\]{}|]/g, gt = /^\[object .+?Constructor\]$/, yt = Function.prototype, bt = Object.prototype, vt = yt.toString, _t = bt.hasOwnProperty, Pt = RegExp(
324
324
  "^" + vt.call(_t).replace(mt, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
325
325
  );
326
326
  function Ct(t) {
327
- if (!D(t) || ft(t))
327
+ if (!G(t) || ft(t))
328
328
  return !1;
329
- var e = ct(t) ? Pt : yt;
329
+ var e = ct(t) ? Pt : gt;
330
330
  return e.test(ht(t));
331
331
  }
332
332
  function It(t, e) {
@@ -364,14 +364,14 @@ function Rt(t, e, r) {
364
364
  (!(wt.call(t, e) && Re(s, r)) || r === void 0 && !(e in t)) && Et(t, e, r);
365
365
  }
366
366
  var Vt = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, $t = /^\w*$/;
367
- function Nt(t, e) {
367
+ function Mt(t, e) {
368
368
  if (Q(t))
369
369
  return !1;
370
370
  var r = typeof t;
371
371
  return r == "number" || r == "symbol" || r == "boolean" || t == null || J(t) ? !0 : $t.test(t) || !Vt.test(t) || e != null && t in Object(e);
372
372
  }
373
373
  var U = A(Object, "create");
374
- function Mt() {
374
+ function Nt() {
375
375
  this.__data__ = U ? U(null) : {}, this.size = 0;
376
376
  }
377
377
  function xt(t) {
@@ -404,7 +404,7 @@ function O(t) {
404
404
  this.set(s[0], s[1]);
405
405
  }
406
406
  }
407
- O.prototype.clear = Mt;
407
+ O.prototype.clear = Nt;
408
408
  O.prototype.delete = xt;
409
409
  O.prototype.get = zt;
410
410
  O.prototype.has = Gt;
@@ -412,7 +412,7 @@ O.prototype.set = Bt;
412
412
  function Ht() {
413
413
  this.__data__ = [], this.size = 0;
414
414
  }
415
- function G(t, e) {
415
+ function k(t, e) {
416
416
  for (var r = t.length; r--; )
417
417
  if (Re(t[r][0], e))
418
418
  return r;
@@ -420,21 +420,21 @@ function G(t, e) {
420
420
  }
421
421
  var Wt = Array.prototype, Kt = Wt.splice;
422
422
  function Xt(t) {
423
- var e = this.__data__, r = G(e, t);
423
+ var e = this.__data__, r = k(e, t);
424
424
  if (r < 0)
425
425
  return !1;
426
426
  var s = e.length - 1;
427
427
  return r == s ? e.pop() : Kt.call(e, r, 1), --this.size, !0;
428
428
  }
429
429
  function Yt(t) {
430
- var e = this.__data__, r = G(e, t);
430
+ var e = this.__data__, r = k(e, t);
431
431
  return r < 0 ? void 0 : e[r][1];
432
432
  }
433
433
  function Zt(t) {
434
- return G(this.__data__, t) > -1;
434
+ return k(this.__data__, t) > -1;
435
435
  }
436
436
  function Jt(t, e) {
437
- var r = this.__data__, s = G(r, t);
437
+ var r = this.__data__, s = k(r, t);
438
438
  return s < 0 ? (++this.size, r.push([t, e])) : r[s][1] = e, this;
439
439
  }
440
440
  function $(t) {
@@ -461,22 +461,22 @@ function er(t) {
461
461
  var e = typeof t;
462
462
  return e == "string" || e == "number" || e == "symbol" || e == "boolean" ? t !== "__proto__" : t === null;
463
463
  }
464
- function k(t, e) {
464
+ function B(t, e) {
465
465
  var r = t.__data__;
466
466
  return er(e) ? r[typeof e == "string" ? "string" : "hash"] : r.map;
467
467
  }
468
468
  function tr(t) {
469
- var e = k(this, t).delete(t);
469
+ var e = B(this, t).delete(t);
470
470
  return this.size -= e ? 1 : 0, e;
471
471
  }
472
472
  function rr(t) {
473
- return k(this, t).get(t);
473
+ return B(this, t).get(t);
474
474
  }
475
475
  function sr(t) {
476
- return k(this, t).has(t);
476
+ return B(this, t).has(t);
477
477
  }
478
478
  function ir(t, e) {
479
- var r = k(this, t), s = r.size;
479
+ var r = B(this, t), s = r.size;
480
480
  return r.set(t, e), this.size += r.size == s ? 0 : 1, this;
481
481
  }
482
482
  function F(t) {
@@ -522,7 +522,7 @@ function fr(t) {
522
522
  return t == null ? "" : we(t);
523
523
  }
524
524
  function Ve(t, e) {
525
- return Q(t) ? t : Nt(t, e) ? [t] : cr(fr(t));
525
+ return Q(t) ? t : Mt(t, e) ? [t] : cr(fr(t));
526
526
  }
527
527
  var dr = 1 / 0;
528
528
  function $e(t) {
@@ -537,12 +537,12 @@ function pr(t, e) {
537
537
  t = t[$e(e[r++])];
538
538
  return r && r == s ? t : void 0;
539
539
  }
540
- function H(t, e, r) {
540
+ function L(t, e, r) {
541
541
  var s = t == null ? void 0 : pr(t, e);
542
542
  return s === void 0 ? r : s;
543
543
  }
544
544
  function hr(t, e, r, s) {
545
- if (!D(t))
545
+ if (!G(t))
546
546
  return t;
547
547
  e = Ve(e, t);
548
548
  for (var i = -1, n = e.length, o = n - 1, l = t; l != null && ++i < n; ) {
@@ -551,13 +551,13 @@ function hr(t, e, r, s) {
551
551
  return t;
552
552
  if (i != o) {
553
553
  var p = l[u];
554
- f = s ? s(p, u, l) : void 0, f === void 0 && (f = D(p) ? p : Ft(e[i + 1]) ? [] : {});
554
+ f = s ? s(p, u, l) : void 0, f === void 0 && (f = G(p) ? p : Ft(e[i + 1]) ? [] : {});
555
555
  }
556
556
  Rt(l, u, f), l = l[u];
557
557
  }
558
558
  return t;
559
559
  }
560
- function L(t, e, r) {
560
+ function D(t, e, r) {
561
561
  return t == null ? t : hr(t, e, r);
562
562
  }
563
563
  class mr {
@@ -577,9 +577,12 @@ class mr {
577
577
  c(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
578
578
  c(this, "baseDefaultValueFunctionsLength");
579
579
  c(this, "isModelInitialized", !0);
580
+ c(this, "createInitialModel", !0);
580
581
  this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), b(
581
582
  () => this.processedModel.value,
582
583
  () => {
584
+ if (this.createInitialModel)
585
+ return this.createInitialModel = !1;
583
586
  this.schemaEffect.triggerEffects();
584
587
  },
585
588
  {
@@ -646,13 +649,13 @@ class mr {
646
649
  if (a.isUndefined(l.stable))
647
650
  return;
648
651
  const E = i.parseStable(l.stable), S = s == null ? void 0 : s.index, C = s == null ? void 0 : s.key;
649
- let g = E;
650
- if (a.isProcessInprogress(g) || (n[p] = !0), s) {
651
- const y = i.processedSchemas.value[S][C][u][f];
652
- y && a.isObject(y) && f !== "component" && (g = h(y, g)), i.processedSchemas.value[S][C][u][f] = g, i.stableUpdater(n);
652
+ let y = E;
653
+ if (a.isProcessInprogress(y) || (n[p] = !0), s) {
654
+ const g = i.processedSchemas.value[S][C][u][f];
655
+ g && a.isObject(g) && f !== "component" && (y = h(g, y)), i.processedSchemas.value[S][C][u][f] = y, i.stableUpdater(n);
653
656
  } else {
654
- const y = i.processedSchemas.value[u][f];
655
- y && a.isObject(y) && f !== "component" && (g = h(y, g)), i.processedSchemas.value[u][f] = g, i.stableUpdater(n);
657
+ const g = i.processedSchemas.value[u][f];
658
+ g && a.isObject(g) && f !== "component" && (y = h(g, y)), i.processedSchemas.value[u][f] = y, i.stableUpdater(n);
656
659
  }
657
660
  }
658
661
  }
@@ -746,13 +749,13 @@ class mr {
746
749
  })
747
750
  );
748
751
  else if (e.name.startsWith("__proform_structured_path_parsing_mark_"))
749
- r(() => e());
750
- else if (e.__proform_async_result) {
751
- const i = e.__proform_async_result;
752
+ r(e);
753
+ else if (e.__proform_cached_result) {
754
+ const i = e.__proform_cached_result;
752
755
  this.promiseFieldParser(i, r, s);
753
756
  } else {
754
757
  const i = e(this.getRuntimeMeta());
755
- e.name.startsWith("__proform_onetime_") && (e.__proform_async_result = i), this.promiseFieldParser(i, r, s);
758
+ e.name.startsWith("__proform_onetime_") && (e.__proform_cached_result = i), this.promiseFieldParser(i, r, s);
756
759
  }
757
760
  else
758
761
  q(e) ? b(
@@ -790,14 +793,23 @@ class mr {
790
793
  ), a.isObjectEmpty(this.stableModel) && this.stableUpdaterProcessProgress.every(Boolean) && this.defaultValueEffect.effects.size === 0 && (this.stableModel = _(this.processedModel.value), this.runtimeCore.hydrateEffect.triggerEffects(), this.runtimeCore.hydrateEffect.clearEffects());
791
794
  }
792
795
  setModel(e, r, s) {
793
- a.isFunction(r) ? L(e, r(), s) : e[r] = s;
796
+ a.isFunction(r) ? D(e, r(), s) : e[r] = s;
794
797
  }
795
798
  createModel(e, r) {
796
- a.isListSchema(e) && (r[e.field] || this.setModel(r, e.field, [{}]), e.children.forEach((s) => {
799
+ if (a.isListSchema(e) && (r[e.field] || this.setModel(r, e.field, [{}]), e.children.forEach((s) => {
797
800
  this.createModel(s, r[e.field][0]);
798
801
  })), a.isGroupSchema(e) && e.children.forEach((s) => {
799
802
  this.createModel(s, r);
800
- }), a.isItemSchema(e) && ("defaultValue" in e ? this.setModel(r, e.field, e.defaultValue) : this.setModel(r, e.field, void 0));
803
+ }), a.isItemSchema(e))
804
+ if ("defaultValue" in e)
805
+ this.setModel(r, e.field, e.defaultValue);
806
+ else {
807
+ if (a.isFunction(e.field) && L(r, e.field()))
808
+ return;
809
+ if (a.isString(e.field) && r[e.field])
810
+ return;
811
+ this.createInitialModel = !0, this.setModel(r, e.field, void 0);
812
+ }
801
813
  }
802
814
  }
803
815
  class j {
@@ -820,7 +832,7 @@ class j {
820
832
  return d.presets.uiPresets[e ?? d.presets.ui].container.ListItem;
821
833
  }
822
834
  }
823
- class yr {
835
+ class gr {
824
836
  constructor(e) {
825
837
  this.ui = e;
826
838
  }
@@ -854,7 +866,7 @@ class yr {
854
866
  return (r == null ? void 0 : r.clearValidate(e)) ?? (s == null ? void 0 : s.clearValidate(e));
855
867
  }
856
868
  }
857
- function gr(t) {
869
+ function yr(t) {
858
870
  return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !ke(t);
859
871
  }
860
872
  class br {
@@ -884,7 +896,7 @@ class br {
884
896
  c(this, "shared", {});
885
897
  this.setup = e, this.processor = new mr(this);
886
898
  const r = this.setup(this);
887
- if (this.ui = r.ui ?? d.presets.ui, this.runtimeAdapter = new yr(this.ui), Object.assign(this.globalNativeFormOverride, this.runtimeAdapter.getRuntimeNative()), q(r.schemas))
899
+ if (this.ui = r.ui ?? d.presets.ui, this.runtimeAdapter = new gr(this.ui), Object.assign(this.globalNativeFormOverride, this.runtimeAdapter.getRuntimeNative()), q(r.schemas))
888
900
  b(
889
901
  // @ts-expect-error
890
902
  () => r.schemas.value,
@@ -941,7 +953,7 @@ class br {
941
953
  };
942
954
  }
943
955
  runtimeItemProcessor(e, r, s = this.model.value, i) {
944
- var re, se, ie, ne, oe, ae, le, ue, ce, fe, de, pe, he, me, ye, ge, be;
956
+ var re, se, ie, ne, oe, ae, le, ue, ce, fe, de, pe, he, me, ge, ye, be;
945
957
  const n = R(e.component);
946
958
  if (!n)
947
959
  return;
@@ -950,34 +962,34 @@ class br {
950
962
  display: "grid",
951
963
  gridColumn: "1 / -1",
952
964
  ...e.grid
953
- }, u = h(_((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), f = this.runtimeAdapter.getRuntimeField({
965
+ }, u = h(_((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), f = this.runtimeAdapter.getRuntimeField({
954
966
  schema: e,
955
967
  parentSchema: i,
956
968
  index: r
957
969
  }), p = n.name, E = e.componentProps ?? {}, S = P.placeholderPresetByComponentName;
958
- let C = e.placeholder, g = e.show;
959
- g === void 0 && (g = !0);
960
- let y = e.label ?? "", I;
961
- if (e.runtime ? I = e.runtime : I = (i == null ? void 0 : i.runtime) ?? this.runtime, !a.isUndefined(r) && !a.isObjectEmpty(I) && (y = K((be = I == null ? void 0 : I.customizeListItemLabel) == null ? void 0 : be.call(I, e.label ?? "", r + 1), "")), !C) {
962
- let N = "请输入";
963
- a.isUndefined(p) ? C = `${N}${y}` : /* @ts-expect-error */ S[p.toLowerCase()] ? (N = // @ts-expect-error
964
- S[p.toLowerCase()], C = `${N}${y}`) : (Object.keys(S).forEach((ve) => {
965
- p.toLowerCase().includes(ve.toLowerCase()) && (N = S[ve]);
966
- }), C = `${N}${y}`);
970
+ let C = e.placeholder, y = e.show;
971
+ y === void 0 && (y = !0);
972
+ let g = e.label ?? "", I;
973
+ if (e.runtime ? I = e.runtime : I = (i == null ? void 0 : i.runtime) ?? this.runtime, !a.isUndefined(r) && !a.isObjectEmpty(I) && (g = K((be = I == null ? void 0 : I.customizeListItemLabel) == null ? void 0 : be.call(I, e.label ?? "", r + 1), "")), !C) {
974
+ let M = "请输入";
975
+ a.isUndefined(p) ? C = `${M}${g}` : /* @ts-expect-error */ S[p.toLowerCase()] ? (M = // @ts-expect-error
976
+ S[p.toLowerCase()], C = `${M}${g}`) : (Object.keys(S).forEach((ve) => {
977
+ p.toLowerCase().includes(ve.toLowerCase()) && (M = S[ve]);
978
+ }), C = `${M}${g}`);
967
979
  }
968
- const Ne = this.runtimeAdapter.getRuntimeRequired({
980
+ const Me = this.runtimeAdapter.getRuntimeRequired({
969
981
  ...e,
970
- label: y
971
- }), Me = j.getItemContainer(this), xe = j.getFormItemContainer(this), qe = this, Te = e.componentSlots;
982
+ label: g
983
+ }), Ne = j.getItemContainer(this), xe = j.getFormItemContainer(this), qe = this, Te = e.componentSlots;
972
984
  return m("div", {
973
985
  style: l
974
- }, [m(Me, {
975
- show: g
986
+ }, [m(Ne, {
987
+ show: y
976
988
  }, {
977
989
  default() {
978
- return g && m(xe, x(u, {
979
- label: `${y ? `${y}:` : ""}`
980
- }, f, Ne), {
990
+ return y && m(xe, x(u, {
991
+ label: `${g ? `${g}:` : ""}`
992
+ }, f, Me), {
981
993
  default() {
982
994
  return qe.runtimeAdapter.formComponentRenderer({
983
995
  Component: n,
@@ -1005,7 +1017,7 @@ class br {
1005
1017
  style: s
1006
1018
  }, [n && m(i, {
1007
1019
  schema: e
1008
- }, gr(r = e.children.map((o) => this.runtimeItemProcessor(o))) ? r : {
1020
+ }, yr(r = e.children.map((o) => this.runtimeItemProcessor(o))) ? r : {
1009
1021
  default: () => [r]
1010
1022
  })]);
1011
1023
  }
@@ -1153,10 +1165,10 @@ const vr = {
1153
1165
  props: n
1154
1166
  }) {
1155
1167
  let o;
1156
- return a.isFunction(r.field) ? o = H(e, r.field()) : o = e[r.field], m(t, x({
1168
+ return a.isFunction(r.field) ? o = L(e, r.field()) : o = e[r.field], m(t, x({
1157
1169
  modelValue: o,
1158
1170
  "onUpdate:modelValue": (l) => {
1159
- a.isFunction(r.field) ? L(e, r.field(), l) : e[r.field] = l;
1171
+ a.isFunction(r.field) ? D(e, r.field(), l) : e[r.field] = l;
1160
1172
  },
1161
1173
  placeholder: s
1162
1174
  }, n), {
@@ -1169,7 +1181,8 @@ const vr = {
1169
1181
  });
1170
1182
  },
1171
1183
  clearValidate(t) {
1172
- t.formRef.value.clearValidate();
1184
+ var e, r;
1185
+ (r = (e = t.formRef.value) == null ? void 0 : e.clearValidate) == null || r.call(e);
1173
1186
  }
1174
1187
  },
1175
1188
  NutUI: {
@@ -1220,10 +1233,10 @@ const vr = {
1220
1233
  props: n
1221
1234
  }) {
1222
1235
  let o;
1223
- return a.isFunction(r.field) ? o = H(e, r.field()) : o = e[r.field], m(t, x({
1236
+ return a.isFunction(r.field) ? o = L(e, r.field()) : o = e[r.field], m(t, x({
1224
1237
  modelValue: o,
1225
1238
  "onUpdate:modelValue": (l) => {
1226
- a.isFunction(r.field) ? L(e, r.field(), l) : e[r.field] = l;
1239
+ a.isFunction(r.field) ? D(e, r.field(), l) : e[r.field] = l;
1227
1240
  },
1228
1241
  placeholder: s
1229
1242
  }, n), {
@@ -1241,7 +1254,8 @@ const vr = {
1241
1254
  });
1242
1255
  },
1243
1256
  clearValidate(t) {
1244
- t.formRef.value.reset();
1257
+ var e, r;
1258
+ (r = (e = t.formRef.value) == null ? void 0 : e.reset) == null || r.call(e);
1245
1259
  }
1246
1260
  },
1247
1261
  NaiveUI: {
@@ -1294,10 +1308,10 @@ const vr = {
1294
1308
  props: n
1295
1309
  }) {
1296
1310
  let o;
1297
- return a.isFunction(r.field) ? o = H(e, r.field()) : o = e[r.field], m(t, x({
1311
+ return a.isFunction(r.field) ? o = L(e, r.field()) : o = e[r.field], m(t, x({
1298
1312
  value: o,
1299
1313
  "onUpdate:value": (l) => {
1300
- a.isFunction(r.field) ? L(e, r.field(), l) : e[r.field] = l;
1314
+ a.isFunction(r.field) ? D(e, r.field(), l) : e[r.field] = l;
1301
1315
  },
1302
1316
  placeholder: s
1303
1317
  }, n), {
@@ -1310,7 +1324,8 @@ const vr = {
1310
1324
  });
1311
1325
  },
1312
1326
  clearValidate(t) {
1313
- t.formRef.value.restoreValidation();
1327
+ var e, r;
1328
+ (r = (e = t.formRef.value) == null ? void 0 : e.restoreValidation) == null || r.call(e);
1314
1329
  }
1315
1330
  }
1316
1331
  }, w = class w {
@@ -22,6 +22,7 @@ export default class Processor {
22
22
  defaultValueInprogressMap: Map<any, any>;
23
23
  baseDefaultValueFunctionsLength: number;
24
24
  isModelInitialized: boolean;
25
+ createInitialModel: boolean;
25
26
  constructor(runtimeCore: RuntimeCore);
26
27
  parse<T extends object = any>(data: T[], parentMeta?: AnyObject): void;
27
28
  initSchemas(schemas: AnyObject[]): AnyObject[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harbor-design/proform",
3
- "version": "1.2.27",
3
+ "version": "1.2.29",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",