@harbor-design/proform 1.1.21 → 1.1.23

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 ie = Object.defineProperty;
2
- var oe = (r, e, t) => e in r ? ie(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var a = (r, e, t) => (oe(r, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { isRef as x, watch as I, isReactive as k, toRaw as E, nextTick as w, ref as q, reactive as ne, createVNode as p, withDirectives as Z, mergeProps as S, vShow as A, createTextVNode as le, isVNode as ae, defineComponent as ue } from "vue";
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 k, 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";
5
5
  class l {
6
6
  static typeChecker(e) {
7
7
  return {}.toString.call(e);
@@ -70,7 +70,7 @@ function m(r, ...e) {
70
70
  typeof s == "object" && s !== null ? r[i] = m(Array.isArray(s) ? [] : {}, s) : r[i] = s;
71
71
  });
72
72
  else
73
- for (let s in t)
73
+ for (const s in t)
74
74
  t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ? r[s] = m(r[s] || {}, t[s]) : r[s] = t[s]);
75
75
  }), r;
76
76
  }
@@ -85,13 +85,13 @@ function g(r) {
85
85
  return new RegExp(s);
86
86
  if (s instanceof Map) {
87
87
  const o = /* @__PURE__ */ new Map();
88
- for (let [n, u] of s)
88
+ for (const [n, u] of s)
89
89
  o.set(t(n), t(u));
90
90
  return o;
91
91
  }
92
92
  if (s instanceof Set) {
93
93
  const o = /* @__PURE__ */ new Set();
94
- for (let n of s)
94
+ for (const n of s)
95
95
  o.add(t(n));
96
96
  return o;
97
97
  }
@@ -106,7 +106,7 @@ function g(r) {
106
106
  }
107
107
  const i = Object.create(Object.getPrototypeOf(s));
108
108
  e.set(s, i);
109
- for (let o in s)
109
+ for (const o in s)
110
110
  s.hasOwnProperty(o) && (i[o] = t(s[o]));
111
111
  return i;
112
112
  }
@@ -115,7 +115,7 @@ function g(r) {
115
115
  function U(r, e) {
116
116
  return r.replace(/undefined/g, e);
117
117
  }
118
- class ce {
118
+ class fe {
119
119
  constructor(e) {
120
120
  a(this, "runtimeCore");
121
121
  this.formCustomization = e;
@@ -184,7 +184,7 @@ class N {
184
184
  return !t.lazy && e(), this.effects.add(e), () => this.effects.delete(e);
185
185
  }
186
186
  }
187
- class fe {
187
+ class de {
188
188
  constructor(e) {
189
189
  a(this, "runtimeCore");
190
190
  a(this, "processedSchemas");
@@ -225,11 +225,12 @@ class fe {
225
225
  });
226
226
  }
227
227
  countFunctionDefaultValues(e) {
228
- let t = 0, s = /* @__PURE__ */ new Set();
228
+ let t = 0;
229
+ const s = /* @__PURE__ */ new Set();
229
230
  function i(o) {
230
231
  if (!s.has(o) && (Array.isArray(o) || o !== null && typeof o == "object")) {
231
232
  s.add(o);
232
- for (let n in o)
233
+ for (const n in o)
233
234
  o.hasOwnProperty(n) && (n === "defaultValue" && typeof o[n] == "function" && !o[n].toString().includes("[native code]") && t++, i(o[n]));
234
235
  }
235
236
  }
@@ -252,7 +253,7 @@ class fe {
252
253
  // 对于稳定初始化更新的抽象
253
254
  stableUpdater(e = []) {
254
255
  if (e.every(Boolean)) {
255
- const t = E(this.processedSchemas.value);
256
+ const t = j(this.processedSchemas.value);
256
257
  !l.isProcessInprogress(t) && l.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
257
258
  length: t.length
258
259
  }).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
@@ -271,10 +272,10 @@ class fe {
271
272
  const O = i.parseStable(u.stable), C = s == null ? void 0 : s.index, v = s == null ? void 0 : s.key;
272
273
  let P = O;
273
274
  if (l.isProcessInprogress(P) || (o[y] = !0), s) {
274
- let h = i.processedSchemas.value[C][v][c][d];
275
+ const h = i.processedSchemas.value[C][v][c][d];
275
276
  h && l.isObject(h) && d !== "component" && (P = m(h, P)), i.processedSchemas.value[C][v][c][d] = P, i.stableUpdater(o);
276
277
  } else {
277
- let h = i.processedSchemas.value[c][d];
278
+ const h = i.processedSchemas.value[c][d];
278
279
  h && l.isObject(h) && d !== "component" && (P = m(h, P)), i.processedSchemas.value[c][d] = P, i.stableUpdater(o);
279
280
  }
280
281
  }
@@ -419,7 +420,7 @@ class F {
419
420
  return f.presets.uiPresets[e ?? f.presets.ui].container.ListItem;
420
421
  }
421
422
  }
422
- class de {
423
+ class pe {
423
424
  constructor(e) {
424
425
  this.ui = e;
425
426
  }
@@ -449,10 +450,10 @@ class de {
449
450
  return (t == null ? void 0 : t.clearValidate(e)) ?? (s == null ? void 0 : s.clearValidate(e));
450
451
  }
451
452
  }
452
- function pe(r) {
453
- return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !ae(r);
453
+ function he(r) {
454
+ return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !ue(r);
454
455
  }
455
- class he {
456
+ class me {
456
457
  constructor(e) {
457
458
  a(this, "schemas", q([]));
458
459
  a(this, "model", q({}));
@@ -463,16 +464,16 @@ class he {
463
464
  });
464
465
  a(this, "formRef", q(null));
465
466
  a(this, "hydrateEffect", new N());
466
- a(this, "native", ne({}));
467
+ a(this, "native", le({}));
467
468
  a(this, "grid", {});
468
469
  a(this, "runtime", {});
469
470
  a(this, "globalNativeFormOverride", {
470
471
  props: {},
471
472
  slots: {}
472
473
  });
473
- this.setup = e, this.processor = new fe(this);
474
+ this.setup = e, this.processor = new de(this);
474
475
  const t = this.setup(this);
475
- if (this.ui = t.ui ?? f.presets.ui, this.runtimeAdapter = new de(this.ui), x(t.schemas)) {
476
+ if (this.ui = t.ui ?? f.presets.ui, this.runtimeAdapter = new pe(this.ui), x(t.schemas)) {
476
477
  const s = I(() => t.schemas, () => {
477
478
  this.processor.parseSchemas(t.schemas.value), w(() => {
478
479
  s();
@@ -493,13 +494,13 @@ class he {
493
494
  }
494
495
  getRuntimeMeta() {
495
496
  return {
496
- model: E(g(this.model.value)),
497
+ model: j(g(this.model.value)),
497
498
  reactiveModel: this.model.value
498
499
  };
499
500
  }
500
501
  runtimeItemProcessor(e, t, s = this.model.value, i) {
501
502
  var z, $, _, B, D, G, T, K, W, H, J, Q, X;
502
- const o = E(e.component);
503
+ const o = j(e.component);
503
504
  if (!o)
504
505
  return;
505
506
  m(this.globalNativeFormOverride.props, ($ = (z = e.native) == null ? void 0 : z.props) == null ? void 0 : $.Form), m(this.globalNativeFormOverride.slots, (B = (_ = e.native) == null ? void 0 : _.slots) == null ? void 0 : B.Form);
@@ -514,25 +515,25 @@ class he {
514
515
  }), y = o.name, O = e.componentProps ?? {}, C = b.placeholderPresetByComponentName;
515
516
  let v = e.placeholder, P = e.show;
516
517
  P === void 0 && (P = !0), P || delete s[e.field];
517
- let h = e.label;
518
+ let h = e.label ?? "";
518
519
  const V = (i == null ? void 0 : i.runtime) ?? this.runtime;
519
520
  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) {
520
- let R = "请输入";
521
- l.isUndefined(y) ? v = `${R}${h}` : /* @ts-expect-error */ C[y.toLowerCase()] ? (R = // @ts-expect-error
522
- C[y.toLowerCase()], v = `${R}${h}`) : (Object.keys(C).forEach((Y) => {
523
- y.toLowerCase().includes(Y.toLowerCase()) && (R = C[Y]);
524
- }), v = `${R}${h}`);
521
+ let E = "请输入";
522
+ l.isUndefined(y) ? v = `${E}${h}` : /* @ts-expect-error */ C[y.toLowerCase()] ? (E = // @ts-expect-error
523
+ C[y.toLowerCase()], v = `${E}${h}`) : (Object.keys(C).forEach((Y) => {
524
+ y.toLowerCase().includes(Y.toLowerCase()) && (E = C[Y]);
525
+ }), v = `${E}${h}`);
525
526
  }
526
527
  const ee = this.runtimeAdapter.getRuntimeRequired({
527
528
  ...e,
528
529
  label: h
529
- }), te = F.getItemContainer(this), se = F.getFormItemContainer(this), re = this;
530
+ }), te = F.getItemContainer(this), se = F.getFormItemContainer(this), re = this, ie = e.componentSlots;
530
531
  return p("div", {
531
532
  style: u
532
533
  }, [p(te, null, {
533
534
  default() {
534
- return Z(p(se, S(c, {
535
- label: `${h}:`
535
+ return Z(p(se, R(c, {
536
+ label: `${h ? `${h}:` : ""}`
536
537
  }, d, ee), {
537
538
  default() {
538
539
  return re.runtimeAdapter.formComponentRenderer({
@@ -540,6 +541,7 @@ class he {
540
541
  schema: e,
541
542
  baseModel: s,
542
543
  placeholder: v,
544
+ componentSlots: ie,
543
545
  props: O
544
546
  });
545
547
  },
@@ -559,7 +561,7 @@ class he {
559
561
  style: s
560
562
  }, [p(i, {
561
563
  schema: e
562
- }, pe(t = e.children.map((o) => this.runtimeItemProcessor(o))) ? t : {
564
+ }, he(t = e.children.map((o) => this.runtimeItemProcessor(o))) ? t : {
563
565
  default: () => [t]
564
566
  })]);
565
567
  }
@@ -597,7 +599,7 @@ class he {
597
599
  container: c
598
600
  } = {}) {
599
601
  var y;
600
- let d = c ?? p("button", null, null);
602
+ const d = c ?? p("button", null, null);
601
603
  return Z(p(d, {
602
604
  onClick: () => s.deleteListItem(e, u)
603
605
  }, null), [[A, ((y = s.model.value[e.field]) == null ? void 0 : y.length) > 1]]);
@@ -607,7 +609,7 @@ class he {
607
609
  add({
608
610
  container: n
609
611
  } = {}) {
610
- let u = n ?? p("button", null, [le("添加")]);
612
+ const u = n ?? p("button", null, [ae("添加")]);
611
613
  return p(u, {
612
614
  onClick: () => s.addListItem(e)
613
615
  }, null);
@@ -625,7 +627,7 @@ class he {
625
627
  gridAutoColumns: "1fr",
626
628
  ...this.grid
627
629
  }, t = this, s = m(g((c = (u = this.native) == null ? void 0 : u.props) == null ? void 0 : c.Form) ?? {}, this.globalNativeFormOverride.props), i = m(g((y = (d = this.native) == null ? void 0 : d.slots) == null ? void 0 : y.Form) ?? {}, this.globalNativeFormOverride.slots), o = F.getFormContainer(this), n = this.runtimeAdapter.getFormModelPropName();
628
- return p(o, S(s, {
630
+ return p(o, R(s, {
629
631
  ref: this.formRef
630
632
  }, {
631
633
  [n]: this.model.value
@@ -649,7 +651,7 @@ function M({
649
651
  }) {
650
652
  return r ? `${r.field}.${t}.${e.field}` : e.field;
651
653
  }
652
- const me = {
654
+ const ye = {
653
655
  ArcoVue: {
654
656
  getRuntimeField(r) {
655
657
  return {
@@ -684,17 +686,20 @@ const me = {
684
686
  baseModel: e,
685
687
  schema: t,
686
688
  placeholder: s,
687
- props: i
689
+ componentSlots: i,
690
+ props: o
688
691
  }) {
689
- return p(r, S({
692
+ return p(r, R({
690
693
  modelValue: e[t.field],
691
- "onUpdate:modelValue": (o) => e[t.field] = o,
694
+ "onUpdate:modelValue": (n) => e[t.field] = n,
692
695
  placeholder: s
693
- }, i), null);
696
+ }, o), {
697
+ ...i
698
+ });
694
699
  },
695
700
  validateForm(r) {
696
701
  return new Promise((e, t) => {
697
- r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(E(r.runtimeCore.processor.processedModel.value))));
702
+ r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(j(r.runtimeCore.processor.processedModel.value))));
698
703
  });
699
704
  },
700
705
  clearValidate(r) {
@@ -736,13 +741,16 @@ const me = {
736
741
  baseModel: e,
737
742
  schema: t,
738
743
  placeholder: s,
739
- props: i
744
+ componentSlots: i,
745
+ props: o
740
746
  }) {
741
- return p(r, S({
747
+ return p(r, R({
742
748
  modelValue: e[t.field],
743
- "onUpdate:modelValue": (o) => e[t.field] = o,
749
+ "onUpdate:modelValue": (n) => e[t.field] = n,
744
750
  placeholder: s
745
- }, i), null);
751
+ }, o), {
752
+ ...i
753
+ });
746
754
  },
747
755
  validateForm(r) {
748
756
  return new Promise((e, t) => {
@@ -750,7 +758,7 @@ const me = {
750
758
  valid: s,
751
759
  errors: i
752
760
  }) => {
753
- s ? e(r.cleanFallbackFields(E(r.runtimeCore.processor.processedModel.value))) : t(i);
761
+ s ? e(r.cleanFallbackFields(j(r.runtimeCore.processor.processedModel.value))) : t(i);
754
762
  });
755
763
  });
756
764
  },
@@ -793,37 +801,40 @@ const me = {
793
801
  baseModel: e,
794
802
  schema: t,
795
803
  placeholder: s,
796
- props: i
804
+ componentSlots: i,
805
+ props: o
797
806
  }) {
798
- return p(r, S({
807
+ return p(r, R({
799
808
  value: e[t.field],
800
- "onUpdate:value": (o) => e[t.field] = o,
809
+ "onUpdate:value": (n) => e[t.field] = n,
801
810
  placeholder: s
802
- }, i), null);
811
+ }, o), {
812
+ ...i
813
+ });
803
814
  },
804
815
  validateForm(r) {
805
816
  return new Promise((e, t) => {
806
- r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(E(r.runtimeCore.processor.processedModel.value))));
817
+ r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(j(r.runtimeCore.processor.processedModel.value))));
807
818
  });
808
819
  },
809
820
  clearValidate(r) {
810
821
  r.formRef.value.restoreValidation();
811
822
  }
812
823
  }
813
- }, j = class j {
824
+ }, S = class S {
814
825
  static getPlaceholderPrefixPresetByComponentName() {
815
826
  const e = {
816
827
  请选择: ["select", "tree"],
817
828
  请输入: ["input"]
818
829
  }, t = {};
819
- for (let s in e)
830
+ for (const s in e)
820
831
  e[s].forEach((i) => {
821
832
  t[i] = s;
822
833
  });
823
834
  return t;
824
835
  }
825
836
  };
826
- a(j, "schemaPreset", {
837
+ a(S, "schemaPreset", {
827
838
  type: {
828
839
  defaultValue: "item"
829
840
  },
@@ -833,6 +844,9 @@ a(j, "schemaPreset", {
833
844
  componentProps: {
834
845
  defaultValue: void 0
835
846
  },
847
+ componentSlots: {
848
+ defaultValue: void 0
849
+ },
836
850
  defaultValue: {
837
851
  defaultValue: void 0
838
852
  },
@@ -863,19 +877,19 @@ a(j, "schemaPreset", {
863
877
  grid: {
864
878
  default: void 0
865
879
  }
866
- }), a(j, "componentPropsPreset", {
880
+ }), a(S, "componentPropsPreset", {
867
881
  options: {
868
882
  defaultValue: []
869
883
  }
870
884
  }), // 基于基本功能提出基本预设
871
- a(j, "placeholderPresetByComponentName", j.getPlaceholderPrefixPresetByComponentName());
872
- let L = j;
885
+ a(S, "placeholderPresetByComponentName", S.getPlaceholderPrefixPresetByComponentName());
886
+ let L = S;
873
887
  const b = {
874
888
  ...L,
875
889
  adapters: {
876
- ...me
890
+ ...ye
877
891
  }
878
- }, ve = /* @__PURE__ */ ue({
892
+ }, ge = /* @__PURE__ */ ce({
879
893
  props: {
880
894
  setup: {
881
895
  type: Function,
@@ -883,12 +897,12 @@ const b = {
883
897
  }
884
898
  },
885
899
  setup(r) {
886
- const e = new he(r.setup);
900
+ const e = new me(r.setup);
887
901
  return () => e.exec();
888
902
  }
889
903
  });
890
- function ge(r) {
891
- const e = new ce(r);
904
+ function Ce(r) {
905
+ const e = new fe(r);
892
906
  return [
893
907
  e.setup.bind(e),
894
908
  {
@@ -897,22 +911,22 @@ function ge(r) {
897
911
  }
898
912
  ];
899
913
  }
900
- function Ce(r) {
914
+ function Ie(r) {
901
915
  f.presets = r;
902
916
  }
903
- function ye(r, e) {
917
+ function Pe(r, e) {
904
918
  return e === "native" && Object.defineProperty(r, "name", {
905
919
  value: `__proform_raw_${r.name}`,
906
920
  writable: !0
907
921
  }), r;
908
922
  }
909
- function Ie(r) {
910
- return ye(r, "native");
923
+ function Ve(r) {
924
+ return Pe(r, "native");
911
925
  }
912
926
  export {
913
- ve as ProForm,
914
- Ie as markNativeFunction,
915
- ge as useForm,
916
- Ce as useFormPresetConfigurer,
917
- ye as useModifiers
927
+ ge as ProForm,
928
+ Ve as markNativeFunction,
929
+ Ce as useForm,
930
+ Ie as useFormPresetConfigurer,
931
+ Pe as useModifiers
918
932
  };
@@ -64,6 +64,7 @@ export interface ItemSchema {
64
64
  field: string;
65
65
  component: DomType;
66
66
  componentProps?: AnyObject;
67
+ componentSlots?: AnyObject;
67
68
  defaultValue?: PropertyKey | object;
68
69
  }
69
70
  export interface GroupSchema {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harbor-design/proform",
3
- "version": "1.1.21",
3
+ "version": "1.1.23",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",