@harbor-design/proform 1.1.28 → 1.1.30

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 oe = Object.defineProperty;
2
- var ne = (r, e, t) => e in r ? oe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var a = (r, e, t) => (ne(r, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { isRef as x, watch as I, isReactive as z, toRaw as j, nextTick as w, ref as q, reactive as le, createVNode as p, withDirectives as Z, mergeProps as R, vShow as A, createTextVNode as ae, isVNode as ue, defineComponent as ce } from "vue";
1
+ var re = Object.defineProperty;
2
+ var ie = (r, e, t) => e in r ? re(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var a = (r, e, t) => (ie(r, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { isRef as x, watch as I, isReactive as z, toRaw as w, nextTick as O, ref as q, reactive as oe, createVNode as p, mergeProps as R, 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);
@@ -85,8 +85,8 @@ function g(r) {
85
85
  return new RegExp(s);
86
86
  if (s instanceof Map) {
87
87
  const o = /* @__PURE__ */ new Map();
88
- for (const [n, u] of s)
89
- o.set(t(n), t(u));
88
+ for (const [n, c] of s)
89
+ o.set(t(n), t(c));
90
90
  return o;
91
91
  }
92
92
  if (s instanceof Set) {
@@ -253,7 +253,7 @@ class de {
253
253
  // 对于稳定初始化更新的抽象
254
254
  stableUpdater(e = []) {
255
255
  if (e.every(Boolean)) {
256
- const t = j(this.processedSchemas.value);
256
+ const t = w(this.processedSchemas.value);
257
257
  !l.isProcessInprogress(t) && l.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
258
258
  length: t.length
259
259
  }).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
@@ -262,21 +262,21 @@ class de {
262
262
  // 核心单 schema 处理过程,接收一个对象键值对的数据结构
263
263
  parseItem(e, t, s) {
264
264
  const i = this, o = Array.from({
265
- length: Object.keys(e).filter((u) => u !== "children").length
265
+ length: Object.keys(e).filter((c) => c !== "children").length
266
266
  }).fill(!1);
267
267
  this.objectParser({ data: e, index: t, updater: n });
268
- function n(u) {
269
- const c = u.index, d = u.key, P = u.keyIndex;
270
- if (l.isUndefined(u.stable))
268
+ function n(c) {
269
+ const u = c.index, d = c.key, P = c.keyIndex;
270
+ if (l.isUndefined(c.stable))
271
271
  return;
272
- const O = i.parseStable(u.stable), C = s == null ? void 0 : s.index, v = s == null ? void 0 : s.key;
273
- let m = O;
272
+ const V = i.parseStable(c.stable), C = s == null ? void 0 : s.index, v = s == null ? void 0 : s.key;
273
+ let m = V;
274
274
  if (l.isProcessInprogress(m) || (o[P] = !0), s) {
275
- const h = i.processedSchemas.value[C][v][c][d];
276
- h && l.isObject(h) && d !== "component" && (m = y(h, m)), i.processedSchemas.value[C][v][c][d] = m, i.stableUpdater(o);
275
+ const h = i.processedSchemas.value[C][v][u][d];
276
+ h && l.isObject(h) && d !== "component" && (m = y(h, m)), i.processedSchemas.value[C][v][u][d] = m, i.stableUpdater(o);
277
277
  } else {
278
- const h = i.processedSchemas.value[c][d];
279
- h && l.isObject(h) && d !== "component" && (m = y(h, m)), i.processedSchemas.value[c][d] = m, i.stableUpdater(o);
278
+ const h = i.processedSchemas.value[u][d];
279
+ h && l.isObject(h) && d !== "component" && (m = y(h, m)), i.processedSchemas.value[u][d] = m, i.stableUpdater(o);
280
280
  }
281
281
  }
282
282
  }
@@ -291,19 +291,19 @@ class de {
291
291
  keyIndex: o
292
292
  });
293
293
  else {
294
- const n = (u) => {
294
+ const n = (c) => {
295
295
  e.updater({
296
296
  ...e,
297
297
  key: i,
298
298
  keyIndex: o,
299
- stable: u
299
+ stable: c
300
300
  });
301
301
  };
302
302
  l.isFunction(t[i]) ? i !== "defaultValue" ? this.schemaEffect.trackEffect(
303
303
  () => {
304
304
  if (i === "component") {
305
- const u = t[i](this.getRuntimeMeta());
306
- this.promiseFieldParser(u, n, !1);
305
+ const c = t[i](this.getRuntimeMeta());
306
+ this.promiseFieldParser(c, n, !1);
307
307
  } else
308
308
  this.fieldParser(t[i], n);
309
309
  },
@@ -312,21 +312,21 @@ class de {
312
312
  }
313
313
  ) : this.defaultValueEffect.trackEffect(
314
314
  () => {
315
- const u = this.schemaEffect.trackEffect(() => {
316
- /\{\s*model\s*\}/.test(t[i].toString()) ? this.fieldParser(t[i], (c) => {
317
- if (!c)
318
- return n(c);
319
- this.defaultValueInprogressMap.set(t[i], c), !l.isProcessInprogress(c) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
315
+ const c = this.schemaEffect.trackEffect(() => {
316
+ /\{\s*model\s*\}/.test(t[i].toString()) ? this.fieldParser(t[i], (u) => {
317
+ if (!u)
318
+ return n(u);
319
+ this.defaultValueInprogressMap.set(t[i], u), !l.isProcessInprogress(u) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
320
320
  this.defaultValueInprogressMap.values()
321
- ).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), w(() => {
322
- u();
323
- })) : n(c);
324
- }) : this.fieldParser(t[i], (c) => {
325
- this.defaultValueInprogressMap.set(t[i], c), !l.isProcessInprogress(c) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
321
+ ).every((d) => !d.includes("undefined")) ? (n(u), this.defaultValueEffect.clearEffects(), O(() => {
322
+ c();
323
+ })) : n(u);
324
+ }) : this.fieldParser(t[i], (u) => {
325
+ this.defaultValueInprogressMap.set(t[i], u), !l.isProcessInprogress(u) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
326
326
  this.defaultValueInprogressMap.values()
327
- ).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), w(() => {
328
- u();
329
- })) : n(c);
327
+ ).every((d) => !d.includes("undefined")) ? (n(u), this.defaultValueEffect.clearEffects(), O(() => {
328
+ c();
329
+ })) : n(u);
330
330
  });
331
331
  });
332
332
  },
@@ -405,7 +405,7 @@ class de {
405
405
  }), l.isItemSchema(e) && ("defaultValue" in e ? t[e.field] = e.defaultValue : t[e.field] || (t[e.field] = void 0));
406
406
  }
407
407
  }
408
- class F {
408
+ class S {
409
409
  static getFormContainer({ ui: e } = {}) {
410
410
  return f.presets.uiPresets[e ?? f.presets.ui].container.Form;
411
411
  }
@@ -469,7 +469,7 @@ class me {
469
469
  });
470
470
  a(this, "formRef", q(null));
471
471
  a(this, "hydrateEffect", new N());
472
- a(this, "native", le({}));
472
+ a(this, "native", oe({}));
473
473
  a(this, "grid", {});
474
474
  a(this, "runtime", {});
475
475
  a(this, "globalNativeFormOverride", {
@@ -480,7 +480,7 @@ class me {
480
480
  const t = this.setup(this);
481
481
  if (this.ui = t.ui ?? f.presets.ui, this.runtimeAdapter = new pe(this.ui), x(t.schemas)) {
482
482
  const s = I(() => t.schemas, () => {
483
- this.processor.parseSchemas(t.schemas.value), w(() => {
483
+ this.processor.parseSchemas(t.schemas.value), O(() => {
484
484
  s();
485
485
  });
486
486
  }, {
@@ -488,7 +488,7 @@ class me {
488
488
  });
489
489
  } else if (z(t.schemas)) {
490
490
  const s = I(() => t.schemas, () => {
491
- this.processor.parseSchemas(t.schemas), w(() => {
491
+ this.processor.parseSchemas(t.schemas), O(() => {
492
492
  s();
493
493
  });
494
494
  }, {
@@ -499,61 +499,61 @@ class me {
499
499
  }
500
500
  getRuntimeMeta() {
501
501
  return {
502
- model: j(g(this.model.value)),
502
+ model: w(g(this.model.value)),
503
503
  reactiveModel: this.model.value
504
504
  };
505
505
  }
506
506
  runtimeItemProcessor(e, t, s = this.model.value, i) {
507
507
  var k, $, _, B, D, G, T, K, W, H, J, Q, X;
508
- const o = j(e.component);
508
+ const o = w(e.component);
509
509
  if (!o)
510
510
  return;
511
511
  y(this.globalNativeFormOverride.props, ($ = (k = e.native) == null ? void 0 : k.props) == null ? void 0 : $.Form), y(this.globalNativeFormOverride.slots, (B = (_ = e.native) == null ? void 0 : _.slots) == null ? void 0 : B.Form);
512
- const n = y(g((G = (D = this.native) == null ? void 0 : D.slots) == null ? void 0 : G.FormItem) ?? {}, (K = (T = e.native) == null ? void 0 : T.slots) == null ? void 0 : K.FormItem), u = {
512
+ const n = y(g((G = (D = this.native) == null ? void 0 : D.slots) == null ? void 0 : G.FormItem) ?? {}, (K = (T = e.native) == null ? void 0 : T.slots) == null ? void 0 : K.FormItem), c = {
513
513
  display: "grid",
514
514
  gridColumn: "1 / -1",
515
515
  ...e.grid
516
- }, c = y(g((H = (W = this.native) == null ? void 0 : W.props) == null ? void 0 : H.FormItem) ?? {}, (Q = (J = e.native) == null ? void 0 : J.props) == null ? void 0 : Q.FormItem), d = this.runtimeAdapter.getRuntimeField({
516
+ }, u = y(g((H = (W = this.native) == null ? void 0 : W.props) == null ? void 0 : H.FormItem) ?? {}, (Q = (J = e.native) == null ? void 0 : J.props) == null ? void 0 : Q.FormItem), d = this.runtimeAdapter.getRuntimeField({
517
517
  schema: e,
518
518
  parentSchema: i,
519
519
  index: t
520
- }), P = o.name, O = e.componentProps ?? {}, C = b.placeholderPresetByComponentName;
520
+ }), P = o.name, V = e.componentProps ?? {}, C = b.placeholderPresetByComponentName;
521
521
  let v = e.placeholder, m = e.show;
522
522
  m === void 0 && (m = !0), m || delete s[e.field];
523
523
  let h = e.label ?? "";
524
- const V = (i == null ? void 0 : i.runtime) ?? this.runtime;
525
- if (!l.isUndefined(t) && !l.isObjectEmpty(V) && (h = U((X = V == null ? void 0 : V.customizeItemLabel) == null ? void 0 : X.call(V, e.label ?? "", t + 1), "")), !v) {
524
+ const F = (i == null ? void 0 : i.runtime) ?? this.runtime;
525
+ if (!l.isUndefined(t) && !l.isObjectEmpty(F) && (h = U((X = F == null ? void 0 : F.customizeItemLabel) == null ? void 0 : X.call(F, e.label ?? "", t + 1), "")), !v) {
526
526
  let E = "请输入";
527
527
  l.isUndefined(P) ? v = `${E}${h}` : /* @ts-expect-error */ C[P.toLowerCase()] ? (E = // @ts-expect-error
528
528
  C[P.toLowerCase()], v = `${E}${h}`) : (Object.keys(C).forEach((Y) => {
529
529
  P.toLowerCase().includes(Y.toLowerCase()) && (E = C[Y]);
530
530
  }), v = `${E}${h}`);
531
531
  }
532
- const ee = this.runtimeAdapter.getRuntimeRequired({
532
+ const Z = this.runtimeAdapter.getRuntimeRequired({
533
533
  ...e,
534
534
  label: h
535
- }), te = F.getItemContainer(this), se = F.getFormItemContainer(this), re = this, ie = e.componentSlots;
535
+ }), A = S.getItemContainer(this), ee = S.getFormItemContainer(this), te = this, se = e.componentSlots;
536
536
  return p("div", {
537
- style: u
538
- }, [p(te, {
537
+ style: c
538
+ }, [p(A, {
539
539
  show: m
540
540
  }, {
541
541
  default() {
542
- return Z(p(se, R(c, {
542
+ return m && p(ee, R(u, {
543
543
  label: `${h ? `${h}:` : ""}`
544
- }, d, ee), {
544
+ }, d, Z), {
545
545
  default() {
546
- return re.runtimeAdapter.formComponentRenderer({
546
+ return te.runtimeAdapter.formComponentRenderer({
547
547
  Component: o,
548
548
  schema: e,
549
549
  baseModel: s,
550
550
  placeholder: v,
551
- componentSlots: ie,
552
- props: O
551
+ componentSlots: se,
552
+ props: V
553
553
  });
554
554
  },
555
555
  ...n
556
- }), [[A, m]]);
556
+ });
557
557
  }
558
558
  })]);
559
559
  }
@@ -563,12 +563,13 @@ class me {
563
563
  display: "grid",
564
564
  gridColumn: "1 / -1",
565
565
  ...e.grid
566
- }, i = F.getGroupContainer(this);
567
- return p("div", {
566
+ }, i = S.getGroupContainer(this);
567
+ let o = e.show;
568
+ return o === void 0 && (o = !0), p("div", {
568
569
  style: s
569
- }, [p(i, {
570
+ }, [o && p(i, {
570
571
  schema: e
571
- }, he(t = e.children.map((o) => this.runtimeItemProcessor(o))) ? t : {
572
+ }, he(t = e.children.map((n) => this.runtimeItemProcessor(n))) ? t : {
572
573
  default: () => [t]
573
574
  })]);
574
575
  }
@@ -591,32 +592,34 @@ class me {
591
592
  ...e.grid
592
593
  }, s = this;
593
594
  s.model.value[e.field] || (s.model.value[e.field] = [{}]);
594
- const i = F.getListContainer(this), o = F.getListItemContainer(this);
595
+ let i = e.show;
596
+ i === void 0 && (i = !0);
597
+ const o = S.getListContainer(this), n = S.getListItemContainer(this);
595
598
  return p("div", {
596
599
  style: t
597
- }, [p(i, {
600
+ }, [i && p(o, {
598
601
  schema: e
599
602
  }, {
600
603
  default() {
601
- return s.model.value[e.field].map((n, u) => p(o, null, {
604
+ return s.model.value[e.field].map((c, u) => p(n, null, {
602
605
  default() {
603
- return e.children.map((c) => s.runtimeItemProcessor(c, u, n, e));
606
+ return e.children.map((d) => s.runtimeItemProcessor(d, u, c, e));
604
607
  },
605
608
  delete({
606
- container: c
609
+ container: d
607
610
  } = {}) {
608
- var P;
609
- const d = c ?? p("button", null, null);
610
- return Z(p(d, {
611
+ var V;
612
+ const P = d ?? p("button", null, null);
613
+ return ne(p(P, {
611
614
  onClick: () => s.deleteListItem(e, u)
612
- }, null), [[A, ((P = s.model.value[e.field]) == null ? void 0 : P.length) > 1]]);
615
+ }, null), [[le, ((V = s.model.value[e.field]) == null ? void 0 : V.length) > 1]]);
613
616
  }
614
617
  }));
615
618
  },
616
619
  add({
617
- container: n
620
+ container: c
618
621
  } = {}) {
619
- const u = n ?? p("button", null, [ae("添加")]);
622
+ const u = c ?? p("button", null, [ae("添加")]);
620
623
  return p(u, {
621
624
  onClick: () => s.addListItem(e)
622
625
  }, null);
@@ -627,13 +630,13 @@ class me {
627
630
  return e.map((t) => (t.type || (t.type = "item"), this.processorBySchemaType[t.type](t)));
628
631
  }
629
632
  exec() {
630
- var u, c, d, P;
633
+ var c, u, d, P;
631
634
  const e = {
632
635
  display: "grid",
633
636
  gridColumn: "1 / -1",
634
637
  gridAutoColumns: "1fr",
635
638
  ...this.grid
636
- }, t = this, s = y(g((c = (u = this.native) == null ? void 0 : u.props) == null ? void 0 : c.Form) ?? {}, this.globalNativeFormOverride.props), i = y(g((P = (d = this.native) == null ? void 0 : d.slots) == null ? void 0 : P.Form) ?? {}, this.globalNativeFormOverride.slots), o = F.getFormContainer(this), n = this.runtimeAdapter.getFormModelPropName();
639
+ }, t = this, s = y(g((u = (c = this.native) == null ? void 0 : c.props) == null ? void 0 : u.Form) ?? {}, this.globalNativeFormOverride.props), i = y(g((P = (d = this.native) == null ? void 0 : d.slots) == null ? void 0 : P.Form) ?? {}, this.globalNativeFormOverride.slots), o = S.getFormContainer(this), n = this.runtimeAdapter.getFormModelPropName();
637
640
  return p(o, R(s, {
638
641
  ref: this.formRef
639
642
  }, {
@@ -706,7 +709,7 @@ const ye = {
706
709
  },
707
710
  validateForm(r) {
708
711
  return new Promise((e, t) => {
709
- r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(j(r.runtimeCore.processor.processedModel.value))));
712
+ r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(w(r.runtimeCore.processor.processedModel.value))));
710
713
  });
711
714
  },
712
715
  clearValidate(r) {
@@ -765,7 +768,7 @@ const ye = {
765
768
  valid: s,
766
769
  errors: i
767
770
  }) => {
768
- s ? e(r.cleanFallbackFields(j(r.runtimeCore.processor.processedModel.value))) : t(i);
771
+ s ? e(r.cleanFallbackFields(w(r.runtimeCore.processor.processedModel.value))) : t(i);
769
772
  });
770
773
  });
771
774
  },
@@ -821,14 +824,14 @@ const ye = {
821
824
  },
822
825
  validateForm(r) {
823
826
  return new Promise((e, t) => {
824
- r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(j(r.runtimeCore.processor.processedModel.value))));
827
+ r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(w(r.runtimeCore.processor.processedModel.value))));
825
828
  });
826
829
  },
827
830
  clearValidate(r) {
828
831
  r.formRef.value.restoreValidation();
829
832
  }
830
833
  }
831
- }, S = class S {
834
+ }, j = class j {
832
835
  static getPlaceholderPrefixPresetByComponentName() {
833
836
  const e = {
834
837
  请选择: ["select", "tree"],
@@ -841,7 +844,7 @@ const ye = {
841
844
  return t;
842
845
  }
843
846
  };
844
- a(S, "schemaPreset", {
847
+ a(j, "schemaPreset", {
845
848
  type: {
846
849
  defaultValue: "item"
847
850
  },
@@ -884,13 +887,13 @@ a(S, "schemaPreset", {
884
887
  grid: {
885
888
  default: void 0
886
889
  }
887
- }), a(S, "componentPropsPreset", {
890
+ }), a(j, "componentPropsPreset", {
888
891
  options: {
889
892
  defaultValue: []
890
893
  }
891
894
  }), // 基于基本功能提出基本预设
892
- a(S, "placeholderPresetByComponentName", S.getPlaceholderPrefixPresetByComponentName());
893
- let L = S;
895
+ a(j, "placeholderPresetByComponentName", j.getPlaceholderPrefixPresetByComponentName());
896
+ let L = j;
894
897
  const b = {
895
898
  ...L,
896
899
  adapters: {
@@ -73,6 +73,7 @@ export interface GroupSchema {
73
73
  label?: string;
74
74
  children: ProxyedSchema[];
75
75
  grid?: GridStyle;
76
+ show?: boolean;
76
77
  }
77
78
  export interface ListSchema {
78
79
  type: "list";
@@ -81,6 +82,7 @@ export interface ListSchema {
81
82
  children: ProxyedSchema[];
82
83
  grid?: GridStyle;
83
84
  runtime?: Runtime;
85
+ show?: boolean;
84
86
  }
85
87
  export type Schema = ItemSchema | GroupSchema | ListSchema;
86
88
  export interface runtimeMeta {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harbor-design/proform",
3
- "version": "1.1.28",
3
+ "version": "1.1.30",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",