@harbor-design/proform 1.2.9 → 1.2.11

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.
Files changed (2) hide show
  1. package/dist/index.js +91 -71
  2. package/package.json +1 -1
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 { isRef as N, watch as P, isReactive as q, nextTick as E, toRaw as R, ref as U, reactive as se, createVNode as p, mergeProps as O, withDirectives as ce, vShow as fe, createTextVNode as de, isVNode as he, defineComponent as pe } from "vue";
4
+ import { isRef as q, watch as y, isReactive as N, nextTick as E, toRaw as R, ref as U, reactive as se, createVNode as p, mergeProps as O, withDirectives as ce, vShow as fe, createTextVNode as de, isVNode as he, defineComponent as pe } from "vue";
5
5
  class l {
6
6
  static typeChecker(e) {
7
7
  return {}.toString.call(e);
@@ -137,7 +137,7 @@ class me {
137
137
  }
138
138
  submit() {
139
139
  var s;
140
- const e = (s = u.getPreset(this.runtimeCore.ui)) == null ? void 0 : s.adapter, t = b.adapters[u.getUI(this.runtimeCore.ui)];
140
+ const e = (s = u.getPreset(this.runtimeCore.ui)) == null ? void 0 : s.adapter, t = P.adapters[u.getUI(this.runtimeCore.ui)];
141
141
  return (e == null ? void 0 : e.validateForm(this)) ?? (t == null ? void 0 : t.validateForm(this));
142
142
  }
143
143
  hydrate(e) {
@@ -148,7 +148,7 @@ class me {
148
148
  });
149
149
  this.runtimeCore.hydrateEffect.trackEffect(
150
150
  () => {
151
- N(e) ? P(
151
+ q(e) ? y(
152
152
  () => e.value,
153
153
  () => {
154
154
  h(this.runtimeCore.model.value, e.value);
@@ -157,7 +157,7 @@ class me {
157
157
  deep: !0,
158
158
  immediate: !0
159
159
  }
160
- ) : q(e) ? P(
160
+ ) : N(e) ? y(
161
161
  () => e,
162
162
  () => {
163
163
  h(this.runtimeCore.model.value, e);
@@ -174,8 +174,8 @@ class me {
174
174
  );
175
175
  }
176
176
  share(e) {
177
- if (N(e)) {
178
- const t = P(
177
+ if (q(e)) {
178
+ const t = y(
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 me {
187
187
  immediate: !0
188
188
  }
189
189
  );
190
- } else if (q(e)) {
191
- const t = P(
190
+ } else if (N(e)) {
191
+ const t = y(
192
192
  () => e,
193
193
  () => {
194
194
  h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects(), E(() => {
@@ -220,7 +220,7 @@ class L {
220
220
  return !t.lazy && e(), this.effects.add(e), () => this.effects.delete(e);
221
221
  }
222
222
  }
223
- class ve {
223
+ class be {
224
224
  constructor(e) {
225
225
  a(this, "runtimeCore");
226
226
  a(this, "processedSchemas");
@@ -228,8 +228,8 @@ class ve {
228
228
  a(this, "getRuntimeMeta");
229
229
  a(this, "stableSchemas", []);
230
230
  a(this, "stableModel", {});
231
- a(this, "schemaPreset", b.schemaPreset);
232
- a(this, "componentPropsPreset", b.componentPropsPreset);
231
+ a(this, "schemaPreset", P.schemaPreset);
232
+ a(this, "componentPropsPreset", P.componentPropsPreset);
233
233
  a(this, "stableUpdaterProcessProgress");
234
234
  a(this, "stableUpdaterTimes", 0);
235
235
  a(this, "schemaEffect", new L());
@@ -237,7 +237,7 @@ class ve {
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), P(
240
+ this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), y(
241
241
  () => this.processedModel.value,
242
242
  () => {
243
243
  this.schemaEffect.triggerEffects();
@@ -302,17 +302,17 @@ class ve {
302
302
  }).fill(!1);
303
303
  this.objectParser({ data: e, index: t, updater: n });
304
304
  function n(f) {
305
- const c = f.index, d = f.key, y = f.keyIndex;
305
+ const c = f.index, d = f.key, v = f.keyIndex;
306
306
  if (l.isUndefined(f.stable))
307
307
  return;
308
308
  const F = i.parseStable(f.stable), I = s == null ? void 0 : s.index, g = s == null ? void 0 : s.key;
309
- let v = F;
310
- if (l.isProcessInprogress(v) || (o[y] = !0), s) {
309
+ let b = F;
310
+ if (l.isProcessInprogress(b) || (o[v] = !0), s) {
311
311
  const m = i.processedSchemas.value[I][g][c][d];
312
- m && l.isObject(m) && d !== "component" && (v = h(m, v)), i.processedSchemas.value[I][g][c][d] = v, i.stableUpdater(o);
312
+ m && l.isObject(m) && d !== "component" && (b = h(m, b)), i.processedSchemas.value[I][g][c][d] = b, i.stableUpdater(o);
313
313
  } else {
314
314
  const m = i.processedSchemas.value[c][d];
315
- m && l.isObject(m) && d !== "component" && (v = h(m, v)), i.processedSchemas.value[c][d] = v, i.stableUpdater(o);
315
+ m && l.isObject(m) && d !== "component" && (b = h(m, b)), i.processedSchemas.value[c][d] = b, i.stableUpdater(o);
316
316
  }
317
317
  }
318
318
  }
@@ -404,7 +404,7 @@ class ve {
404
404
  this.promiseFieldParser(i, t, s);
405
405
  }
406
406
  else
407
- N(e) ? P(
407
+ q(e) ? y(
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 ve {
416
416
  immediate: !0,
417
417
  deep: !0
418
418
  }
419
- ) : q(e) ? P(
419
+ ) : N(e) ? y(
420
420
  () => e,
421
421
  () => {
422
422
  l.isUndefined(e) || (s && l.isObject(e) && !l.isNativeObject(e) ? this.objectParser({
@@ -466,7 +466,7 @@ class V {
466
466
  return u.presets.uiPresets[e ?? u.presets.ui].container.ListItem;
467
467
  }
468
468
  }
469
- class ye {
469
+ class ve {
470
470
  constructor(e) {
471
471
  this.ui = e;
472
472
  }
@@ -476,34 +476,34 @@ class ye {
476
476
  }
477
477
  getRuntimeField(e) {
478
478
  var i;
479
- const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = b.adapters[u.getUI(this.ui)];
479
+ const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[u.getUI(this.ui)];
480
480
  return (t == null ? void 0 : t.getRuntimeField(e)) ?? (s == null ? void 0 : s.getRuntimeField(e));
481
481
  }
482
482
  getRuntimeRequired(e) {
483
483
  var i;
484
- const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = b.adapters[u.getUI(this.ui)];
484
+ const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[u.getUI(this.ui)];
485
485
  return (t == null ? void 0 : t.getRuntimeRequired(e)) ?? (s == null ? void 0 : s.getRuntimeRequired(e));
486
486
  }
487
487
  getFormModelPropName() {
488
488
  var s;
489
- const e = (s = u.presets.uiPresets[this.ui]) == null ? void 0 : s.adapter, t = b.adapters[u.getUI(this.ui)];
489
+ const e = (s = u.presets.uiPresets[this.ui]) == null ? void 0 : s.adapter, t = P.adapters[u.getUI(this.ui)];
490
490
  return (e == null ? void 0 : e.getFormModelPropName()) ?? (t == null ? void 0 : t.getFormModelPropName());
491
491
  }
492
492
  formComponentRenderer(e) {
493
493
  var i;
494
- const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = b.adapters[u.getUI(this.ui)];
494
+ const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[u.getUI(this.ui)];
495
495
  return (t == null ? void 0 : t.formComponentRenderer(e)) ?? (s == null ? void 0 : s.formComponentRenderer(e));
496
496
  }
497
497
  clearValidate(e) {
498
498
  var i;
499
- const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = b.adapters[u.getUI(this.ui)];
499
+ const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[u.getUI(this.ui)];
500
500
  return (t == null ? void 0 : t.clearValidate(e)) ?? (s == null ? void 0 : s.clearValidate(e));
501
501
  }
502
502
  }
503
- function Pe(r) {
503
+ function ye(r) {
504
504
  return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !he(r);
505
505
  }
506
- class be {
506
+ class Pe {
507
507
  constructor(e) {
508
508
  a(this, "schemas", U([]));
509
509
  a(this, "model", U({}));
@@ -528,10 +528,10 @@ class be {
528
528
  }
529
529
  }));
530
530
  a(this, "shared", {});
531
- this.setup = e, this.processor = new ve(this);
531
+ this.setup = e, this.processor = new be(this);
532
532
  const t = this.setup(this);
533
- if (this.ui = t.ui ?? u.presets.ui, this.runtimeAdapter = new ye(this.ui), Object.assign(this.globalNativeFormOverride, this.runtimeAdapter.getRuntimeNative()), N(t.schemas))
534
- P(
533
+ if (this.ui = t.ui ?? u.presets.ui, this.runtimeAdapter = new ve(this.ui), Object.assign(this.globalNativeFormOverride, this.runtimeAdapter.getRuntimeNative()), q(t.schemas))
534
+ y(
535
535
  // @ts-expect-error
536
536
  () => t.schemas.value,
537
537
  () => {
@@ -541,8 +541,8 @@ class be {
541
541
  deep: !0
542
542
  }
543
543
  );
544
- else if (q(t.schemas)) {
545
- const s = P(() => t.schemas, () => {
544
+ else if (N(t.schemas)) {
545
+ const s = y(() => t.schemas, () => {
546
546
  this.processor.parseSchemas(t.schemas), E(() => {
547
547
  s();
548
548
  });
@@ -562,8 +562,8 @@ class be {
562
562
  // share 增加防抖,当开发者在过程中进行 share 时避免频繁触发爆栈
563
563
  share: (s) => {
564
564
  t && clearTimeout(t), t = setTimeout(() => {
565
- if (N(s)) {
566
- const i = P(() => s.value, () => {
565
+ if (q(s)) {
566
+ const i = y(() => s.value, () => {
567
567
  h(this.shared, s.value), this.processor.schemaEffect.triggerEffects(), E(() => {
568
568
  i();
569
569
  });
@@ -571,8 +571,8 @@ class be {
571
571
  deep: !0,
572
572
  immediate: !0
573
573
  });
574
- } else if (q(s)) {
575
- const i = P(() => s, () => {
574
+ } else if (N(s)) {
575
+ const i = y(() => s, () => {
576
576
  h(this.shared, s), this.processor.schemaEffect.triggerEffects(), E(() => {
577
577
  i();
578
578
  });
@@ -587,11 +587,11 @@ class be {
587
587
  };
588
588
  }
589
589
  runtimeItemProcessor(e, t, s = this.model.value, i) {
590
- var z, k, $, B, D, T, G, W, K, H, J, Q, X, Y, Z, A, ee;
590
+ var $, z, k, B, D, T, G, W, K, H, J, Q, X, Y, Z, A, ee;
591
591
  const o = R(e.component);
592
592
  if (!o)
593
593
  return;
594
- (k = (z = e.native) == null ? void 0 : z.props) != null && k.Form && h(this.globalNativeFormOverride.props.Form, (B = ($ = e.native) == null ? void 0 : $.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);
594
+ (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);
595
595
  const n = h(C((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 = {
596
596
  display: "grid",
597
597
  gridColumn: "1 / -1",
@@ -600,16 +600,16 @@ class be {
600
600
  schema: e,
601
601
  parentSchema: i,
602
602
  index: t
603
- }), y = o.name, F = e.componentProps ?? {}, I = b.placeholderPresetByComponentName;
604
- let g = e.placeholder, v = e.show;
605
- v === void 0 && (v = !0);
603
+ }), v = o.name, F = e.componentProps ?? {}, I = P.placeholderPresetByComponentName;
604
+ let g = e.placeholder, b = e.show;
605
+ b === void 0 && (b = !0);
606
606
  let m = e.label ?? "";
607
607
  const j = (i == null ? void 0 : i.runtime) ?? this.runtime;
608
608
  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), "")), !g) {
609
609
  let S = "请输入";
610
- l.isUndefined(y) ? g = `${S}${m}` : /* @ts-expect-error */ I[y.toLowerCase()] ? (S = // @ts-expect-error
611
- I[y.toLowerCase()], g = `${S}${m}`) : (Object.keys(I).forEach((te) => {
612
- y.toLowerCase().includes(te.toLowerCase()) && (S = I[te]);
610
+ l.isUndefined(v) ? g = `${S}${m}` : /* @ts-expect-error */ I[v.toLowerCase()] ? (S = // @ts-expect-error
611
+ I[v.toLowerCase()], g = `${S}${m}`) : (Object.keys(I).forEach((te) => {
612
+ v.toLowerCase().includes(te.toLowerCase()) && (S = I[te]);
613
613
  }), g = `${S}${m}`);
614
614
  }
615
615
  const re = this.runtimeAdapter.getRuntimeRequired({
@@ -619,10 +619,10 @@ class be {
619
619
  return p("div", {
620
620
  style: f
621
621
  }, [p(ie, {
622
- show: v
622
+ show: b
623
623
  }, {
624
624
  default() {
625
- return v && p(oe, O(c, {
625
+ return b && p(oe, O(c, {
626
626
  label: `${m ? `${m}:` : ""}`
627
627
  }, d, re), {
628
628
  default() {
@@ -652,7 +652,7 @@ class be {
652
652
  style: s
653
653
  }, [o && p(i, {
654
654
  schema: e
655
- }, Pe(t = e.children.map((n) => this.runtimeItemProcessor(n))) ? t : {
655
+ }, ye(t = e.children.map((n) => this.runtimeItemProcessor(n))) ? t : {
656
656
  default: () => [t]
657
657
  })]);
658
658
  }
@@ -692,8 +692,8 @@ class be {
692
692
  container: d
693
693
  } = {}) {
694
694
  var F;
695
- const y = d ?? p("button", null, null);
696
- return ce(p(y, {
695
+ const v = d ?? p("button", null, null);
696
+ return ce(p(v, {
697
697
  onClick: () => s.deleteListItem(e, c)
698
698
  }, null), [[fe, ((F = s.model.value[e.field]) == null ? void 0 : F.length) > 1]]);
699
699
  }
@@ -713,13 +713,13 @@ class be {
713
713
  return e.map((t) => (t.type || (t.type = "item"), this.processorBySchemaType[t.type](t)));
714
714
  }
715
715
  exec() {
716
- var f, c, d, y;
716
+ var f, c, d, v;
717
717
  const e = {
718
718
  display: "grid",
719
719
  gridColumn: "1 / -1",
720
720
  gridAutoColumns: "1fr",
721
721
  ...this.grid
722
- }, t = this, s = h(C((c = (f = this.native) == null ? void 0 : f.props) == null ? void 0 : c.Form) ?? {}, this.globalNativeFormOverride.props.Form), i = h(C((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();
722
+ }, t = this, s = h(C((c = (f = this.native) == null ? void 0 : f.props) == null ? void 0 : c.Form) ?? {}, this.globalNativeFormOverride.props.Form), i = h(C((v = (d = this.native) == null ? void 0 : d.slots) == null ? void 0 : v.Form) ?? {}, this.globalNativeFormOverride.slots.Form), o = V.getFormContainer(this), n = this.runtimeAdapter.getFormModelPropName();
723
723
  return p(o, O(s, {
724
724
  ref: this.formRef
725
725
  }, {
@@ -760,20 +760,26 @@ const ge = {
760
760
  };
761
761
  },
762
762
  getRuntimeRequired(r) {
763
- var e, t;
763
+ var e;
764
764
  if (r.required)
765
765
  if (!r.rules)
766
- r.rules = [], (e = r.rules) == null || e.push({
766
+ r.rules = [], r.rules.push({
767
767
  required: !0,
768
768
  message: `${r.label}是必填项`
769
769
  });
770
770
  else {
771
- const s = r.rules.findIndex((i) => !l.isUndefined(i.required));
772
- s !== -1 && (r.rules[s].required = !0, r.rules[s].message = `${r.label}是必填项`);
771
+ const t = r.rules.findIndex((s) => !l.isUndefined(s.required));
772
+ t !== -1 ? (r.rules[t].required = !0, r.rules[t].message = `${r.label}是必填项`) : r.rules.unshift({
773
+ required: !0,
774
+ message: `${r.label}是必填项`
775
+ });
773
776
  }
774
777
  else if (r.rules) {
775
- const s = (t = r.rules) == null ? void 0 : t.findIndex((i) => !!i.required);
776
- s !== -1 && (r.rules[s].required = !1);
778
+ const t = (e = r.rules) == null ? void 0 : e.findIndex((s) => !!s.required);
779
+ t !== -1 ? r.rules[t].required = !1 : r.rules.unshift({
780
+ required: !0,
781
+ message: `${r.label}是必填项`
782
+ });
777
783
  }
778
784
  return {
779
785
  rules: r.rules
@@ -814,20 +820,26 @@ const ge = {
814
820
  };
815
821
  },
816
822
  getRuntimeRequired(r) {
817
- var e, t;
823
+ var e;
818
824
  if (r.required)
819
825
  if (!r.rules)
820
- r.rules = [], (e = r.rules) == null || e.push({
826
+ r.rules = [], r.rules.push({
821
827
  required: !0,
822
828
  message: `${r.label}是必填项`
823
829
  });
824
830
  else {
825
- const s = r.rules.findIndex((i) => !l.isUndefined(i.required));
826
- s !== -1 && (r.rules[s].required = !0, r.rules[s].message = `${r.label}是必填项`);
831
+ const t = r.rules.findIndex((s) => !l.isUndefined(s.required));
832
+ t !== -1 ? (r.rules[t].required = !0, r.rules[t].message = `${r.label}是必填项`) : r.rules.unshift({
833
+ required: !0,
834
+ message: `${r.label}是必填项`
835
+ });
827
836
  }
828
837
  else if (r.rules) {
829
- const s = (t = r.rules) == null ? void 0 : t.findIndex((i) => !!i.required);
830
- s !== -1 && (r.rules[s].required = !1);
838
+ const t = (e = r.rules) == null ? void 0 : e.findIndex((s) => !!s.required);
839
+ t !== -1 ? r.rules[t].required = !1 : r.rules.unshift({
840
+ required: !0,
841
+ message: `${r.label}是必填项`
842
+ });
831
843
  }
832
844
  return {
833
845
  rules: r.rules,
@@ -874,21 +886,29 @@ const ge = {
874
886
  };
875
887
  },
876
888
  getRuntimeRequired(r) {
877
- var e, t;
889
+ var e;
878
890
  if (r.required)
879
891
  if (!r.rules)
880
- r.rules = [], (e = r.rules) == null || e.push({
892
+ r.rules = [], r.rules.push({
881
893
  required: !0,
882
894
  message: `${r.label}是必填项`,
883
895
  trigger: ["input", "blur"]
884
896
  });
885
897
  else {
886
- const s = r.rules.findIndex((i) => !l.isUndefined(i.required));
887
- s !== -1 && (r.rules[s].required = !0, r.rules[s].message = `${r.label}是必填项`);
898
+ const t = r.rules.findIndex((s) => !l.isUndefined(s.required));
899
+ t !== -1 ? (r.rules[t].required = !0, r.rules[t].message = `${r.label}是必填项`) : r.rules.unshift({
900
+ required: !0,
901
+ message: `${r.label}是必填项`,
902
+ trigger: ["input", "blur"]
903
+ });
888
904
  }
889
905
  else if (r.rules) {
890
- const s = (t = r.rules) == null ? void 0 : t.findIndex((i) => !!i.required);
891
- s !== -1 && (r.rules[s].required = !1);
906
+ const t = (e = r.rules) == null ? void 0 : e.findIndex((s) => !!s.required);
907
+ t !== -1 ? r.rules[t].required = !1 : r.rules.unshift({
908
+ required: !0,
909
+ message: `${r.label}是必填项`,
910
+ trigger: ["input", "blur"]
911
+ });
892
912
  }
893
913
  return {
894
914
  rule: r.rules
@@ -985,7 +1005,7 @@ a(w, "schemaPreset", {
985
1005
  }), // 基于基本功能提出基本预设
986
1006
  a(w, "placeholderPresetByComponentName", w.getPlaceholderPrefixPresetByComponentName());
987
1007
  let _ = w;
988
- const b = {
1008
+ const P = {
989
1009
  ..._,
990
1010
  adapters: {
991
1011
  ...ge
@@ -998,7 +1018,7 @@ const b = {
998
1018
  }
999
1019
  },
1000
1020
  setup(r) {
1001
- const e = new be(r.setup);
1021
+ const e = new Pe(r.setup);
1002
1022
  return () => e.exec();
1003
1023
  }
1004
1024
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harbor-design/proform",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",