@harbor-design/proform 1.1.33 → 1.1.35

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
1
  var re = Object.defineProperty;
2
2
  var ie = (r, e, t) => e in r ? re(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
3
  var a = (r, e, t) => (ie(r, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { isRef as q, watch as P, isReactive as N, nextTick as F, toRaw as S, ref as M, reactive as oe, createVNode as p, mergeProps as O, withDirectives as ne, vShow as le, createTextVNode as ae, isVNode as ue, defineComponent as ce } from "vue";
4
+ import { isRef as q, watch as v, isReactive as N, nextTick as I, toRaw as F, ref as M, reactive as oe, createVNode as p, mergeProps as O, 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);
@@ -134,7 +134,7 @@ class fe {
134
134
  }
135
135
  submit() {
136
136
  var s;
137
- const e = (s = f.presets.uiPresets[this.runtimeCore.ui]) == null ? void 0 : s.adapter, t = v.adapters[this.runtimeCore.ui];
137
+ const e = (s = f.presets.uiPresets[this.runtimeCore.ui]) == null ? void 0 : s.adapter, t = P.adapters[this.runtimeCore.ui];
138
138
  return (e == null ? void 0 : e.validateForm(this)) ?? (t == null ? void 0 : t.validateForm(this));
139
139
  }
140
140
  hydrate(e) {
@@ -145,7 +145,7 @@ class fe {
145
145
  });
146
146
  this.runtimeCore.hydrateEffect.trackEffect(
147
147
  () => {
148
- q(e) ? P(
148
+ q(e) ? v(
149
149
  () => e.value,
150
150
  () => {
151
151
  h(this.runtimeCore.model.value, e.value);
@@ -154,7 +154,7 @@ class fe {
154
154
  deep: !0,
155
155
  immediate: !0
156
156
  }
157
- ) : N(e) ? P(
157
+ ) : N(e) ? v(
158
158
  () => e,
159
159
  () => {
160
160
  h(this.runtimeCore.model.value, e);
@@ -172,10 +172,10 @@ class fe {
172
172
  }
173
173
  share(e) {
174
174
  if (q(e)) {
175
- const t = P(
175
+ const t = v(
176
176
  () => e.value,
177
177
  () => {
178
- h(this.runtimeCore.shared, e.value), this.runtimeCore.processor.schemaEffect.triggerEffects(), F(() => {
178
+ h(this.runtimeCore.shared, e.value), this.runtimeCore.processor.schemaEffect.triggerEffects(), I(() => {
179
179
  t();
180
180
  });
181
181
  },
@@ -185,10 +185,10 @@ class fe {
185
185
  }
186
186
  );
187
187
  } else if (N(e)) {
188
- const t = P(
188
+ const t = v(
189
189
  () => e,
190
190
  () => {
191
- h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects(), F(() => {
191
+ h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects(), I(() => {
192
192
  t();
193
193
  });
194
194
  },
@@ -225,8 +225,8 @@ class de {
225
225
  a(this, "getRuntimeMeta");
226
226
  a(this, "stableSchemas", []);
227
227
  a(this, "stableModel", {});
228
- a(this, "schemaPreset", v.schemaPreset);
229
- a(this, "componentPropsPreset", v.componentPropsPreset);
228
+ a(this, "schemaPreset", P.schemaPreset);
229
+ a(this, "componentPropsPreset", P.componentPropsPreset);
230
230
  a(this, "stableUpdaterProcessProgress");
231
231
  a(this, "stableUpdaterTimes", 0);
232
232
  a(this, "schemaEffect", new _());
@@ -234,7 +234,7 @@ class de {
234
234
  a(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
235
235
  a(this, "baseDefaultValueFunctionsLength");
236
236
  a(this, "isModelInitialized", !0);
237
- this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), P(
237
+ this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), v(
238
238
  () => this.processedModel.value,
239
239
  () => {
240
240
  this.schemaEffect.triggerEffects();
@@ -286,7 +286,7 @@ class de {
286
286
  // 对于稳定初始化更新的抽象
287
287
  stableUpdater(e = []) {
288
288
  if (e.every(Boolean)) {
289
- const t = S(this.processedSchemas.value);
289
+ const t = F(this.processedSchemas.value);
290
290
  !l.isProcessInprogress(t) && l.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
291
291
  length: t.length
292
292
  }).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
@@ -302,11 +302,11 @@ class de {
302
302
  const u = c.index, d = c.key, b = c.keyIndex;
303
303
  if (l.isUndefined(c.stable))
304
304
  return;
305
- const V = i.parseStable(c.stable), I = s == null ? void 0 : s.index, g = s == null ? void 0 : s.key;
305
+ const V = i.parseStable(c.stable), E = s == null ? void 0 : s.index, g = s == null ? void 0 : s.key;
306
306
  let y = V;
307
307
  if (l.isProcessInprogress(y) || (o[b] = !0), s) {
308
- const m = i.processedSchemas.value[I][g][u][d];
309
- m && l.isObject(m) && d !== "component" && (y = h(m, y)), i.processedSchemas.value[I][g][u][d] = y, i.stableUpdater(o);
308
+ const m = i.processedSchemas.value[E][g][u][d];
309
+ m && l.isObject(m) && d !== "component" && (y = h(m, y)), i.processedSchemas.value[E][g][u][d] = y, i.stableUpdater(o);
310
310
  } else {
311
311
  const m = i.processedSchemas.value[u][d];
312
312
  m && l.isObject(m) && d !== "component" && (y = h(m, y)), i.processedSchemas.value[u][d] = y, i.stableUpdater(o);
@@ -351,13 +351,13 @@ class de {
351
351
  return n(u);
352
352
  this.defaultValueInprogressMap.set(t[i], u), !l.isProcessInprogress(u) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
353
353
  this.defaultValueInprogressMap.values()
354
- ).every((d) => !d.includes("undefined")) ? (n(u), this.defaultValueEffect.clearEffects(), F(() => {
354
+ ).every((d) => !d.includes("undefined")) ? (n(u), this.defaultValueEffect.clearEffects(), I(() => {
355
355
  c();
356
356
  })) : n(u);
357
357
  }) : this.fieldParser(t[i], (u) => {
358
358
  this.defaultValueInprogressMap.set(t[i], u), !l.isProcessInprogress(u) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
359
359
  this.defaultValueInprogressMap.values()
360
- ).every((d) => !d.includes("undefined")) ? (n(u), this.defaultValueEffect.clearEffects(), F(() => {
360
+ ).every((d) => !d.includes("undefined")) ? (n(u), this.defaultValueEffect.clearEffects(), I(() => {
361
361
  c();
362
362
  })) : n(u);
363
363
  });
@@ -396,7 +396,7 @@ class de {
396
396
  this.promiseFieldParser(i, t, s);
397
397
  }
398
398
  else
399
- q(e) ? P(
399
+ q(e) ? v(
400
400
  () => e.value,
401
401
  () => {
402
402
  l.isUndefined(e.value) || (s && l.isObject(e.value) && !l.isNativeObject(e.value) ? this.objectParser({
@@ -408,7 +408,7 @@ class de {
408
408
  immediate: !0,
409
409
  deep: !0
410
410
  }
411
- ) : N(e) ? P(
411
+ ) : N(e) ? v(
412
412
  () => e,
413
413
  () => {
414
414
  l.isUndefined(e) || (s && l.isObject(e) && !l.isNativeObject(e) ? this.objectParser({
@@ -438,7 +438,7 @@ class de {
438
438
  }), l.isItemSchema(e) && ("defaultValue" in e ? t[e.field] = e.defaultValue : t[e.field] || (t[e.field] = void 0));
439
439
  }
440
440
  }
441
- class E {
441
+ class w {
442
442
  static getFormContainer({ ui: e } = {}) {
443
443
  return f.presets.uiPresets[e ?? f.presets.ui].container.Form;
444
444
  }
@@ -458,37 +458,37 @@ class E {
458
458
  return f.presets.uiPresets[e ?? f.presets.ui].container.ListItem;
459
459
  }
460
460
  }
461
- class pe {
461
+ class he {
462
462
  constructor(e) {
463
463
  this.ui = e;
464
464
  }
465
465
  getRuntimeField(e) {
466
466
  var i;
467
- const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = v.adapters[this.ui];
467
+ const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[this.ui];
468
468
  return (t == null ? void 0 : t.getRuntimeField(e)) ?? (s == null ? void 0 : s.getRuntimeField(e));
469
469
  }
470
470
  getRuntimeRequired(e) {
471
471
  var i;
472
- const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = v.adapters[this.ui];
472
+ const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[this.ui];
473
473
  return (t == null ? void 0 : t.getRuntimeRequired(e)) ?? (s == null ? void 0 : s.getRuntimeRequired(e));
474
474
  }
475
475
  getFormModelPropName() {
476
476
  var s;
477
- const e = (s = f.presets.uiPresets[this.ui]) == null ? void 0 : s.adapter, t = v.adapters[this.ui];
477
+ const e = (s = f.presets.uiPresets[this.ui]) == null ? void 0 : s.adapter, t = P.adapters[this.ui];
478
478
  return (e == null ? void 0 : e.getFormModelPropName()) ?? (t == null ? void 0 : t.getFormModelPropName());
479
479
  }
480
480
  formComponentRenderer(e) {
481
481
  var i;
482
- const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = v.adapters[this.ui];
482
+ const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[this.ui];
483
483
  return (t == null ? void 0 : t.formComponentRenderer(e)) ?? (s == null ? void 0 : s.formComponentRenderer(e));
484
484
  }
485
485
  clearValidate(e) {
486
486
  var i;
487
- const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = v.adapters[this.ui];
487
+ const t = (i = f.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[this.ui];
488
488
  return (t == null ? void 0 : t.clearValidate(e)) ?? (s == null ? void 0 : s.clearValidate(e));
489
489
  }
490
490
  }
491
- function he(r) {
491
+ function pe(r) {
492
492
  return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !ue(r);
493
493
  }
494
494
  class me {
@@ -512,17 +512,17 @@ class me {
512
512
  a(this, "shared", {});
513
513
  this.setup = e, this.processor = new de(this);
514
514
  const t = this.setup(this);
515
- if (this.ui = t.ui ?? f.presets.ui, this.runtimeAdapter = new pe(this.ui), q(t.schemas)) {
516
- const s = P(() => t.schemas, () => {
517
- this.processor.parseSchemas(t.schemas.value), F(() => {
515
+ if (this.ui = t.ui ?? f.presets.ui, this.runtimeAdapter = new he(this.ui), q(t.schemas)) {
516
+ const s = v(() => t.schemas, () => {
517
+ this.processor.parseSchemas(t.schemas.value), I(() => {
518
518
  s();
519
519
  });
520
520
  }, {
521
521
  deep: !0
522
522
  });
523
523
  } else if (N(t.schemas)) {
524
- const s = P(() => t.schemas, () => {
525
- this.processor.parseSchemas(t.schemas), F(() => {
524
+ const s = v(() => t.schemas, () => {
525
+ this.processor.parseSchemas(t.schemas), I(() => {
526
526
  s();
527
527
  });
528
528
  }, {
@@ -533,14 +533,36 @@ class me {
533
533
  }
534
534
  getRuntimeMeta() {
535
535
  return {
536
- model: S(C(this.model.value)),
536
+ model: F(C(this.model.value)),
537
537
  reactiveModel: this.model.value,
538
- shared: this.shared
538
+ shared: this.shared,
539
+ share: (t) => {
540
+ if (q(t)) {
541
+ const s = v(() => t.value, () => {
542
+ h(this.shared, t.value), this.processor.schemaEffect.triggerEffects(), I(() => {
543
+ s();
544
+ });
545
+ }, {
546
+ deep: !0,
547
+ immediate: !0
548
+ });
549
+ } else if (N(t)) {
550
+ const s = v(() => t, () => {
551
+ h(this.shared, t), this.processor.schemaEffect.triggerEffects(), I(() => {
552
+ s();
553
+ });
554
+ }, {
555
+ deep: !0,
556
+ immediate: !0
557
+ });
558
+ } else
559
+ h(this.shared, t), this.processor.schemaEffect.triggerEffects();
560
+ }
539
561
  };
540
562
  }
541
563
  runtimeItemProcessor(e, t, s = this.model.value, i) {
542
564
  var x, z, $, B, D, G, T, W, K, H, J, Q, X;
543
- const o = S(e.component);
565
+ const o = F(e.component);
544
566
  if (!o)
545
567
  return;
546
568
  h(this.globalNativeFormOverride.props, (z = (x = e.native) == null ? void 0 : x.props) == null ? void 0 : z.Form), h(this.globalNativeFormOverride.slots, (B = ($ = e.native) == null ? void 0 : $.slots) == null ? void 0 : B.Form);
@@ -552,22 +574,22 @@ class me {
552
574
  schema: e,
553
575
  parentSchema: i,
554
576
  index: t
555
- }), b = o.name, V = e.componentProps ?? {}, I = v.placeholderPresetByComponentName;
577
+ }), b = o.name, V = e.componentProps ?? {}, E = P.placeholderPresetByComponentName;
556
578
  let g = e.placeholder, y = e.show;
557
579
  y === void 0 && (y = !0), y || delete s[e.field];
558
580
  let m = e.label ?? "";
559
581
  const j = (i == null ? void 0 : i.runtime) ?? this.runtime;
560
582
  if (!l.isUndefined(t) && !l.isObjectEmpty(j) && (m = L((X = j == null ? void 0 : j.customizeItemLabel) == null ? void 0 : X.call(j, e.label ?? "", t + 1), "")), !g) {
561
583
  let R = "请输入";
562
- l.isUndefined(b) ? g = `${R}${m}` : /* @ts-expect-error */ I[b.toLowerCase()] ? (R = // @ts-expect-error
563
- I[b.toLowerCase()], g = `${R}${m}`) : (Object.keys(I).forEach((Y) => {
564
- b.toLowerCase().includes(Y.toLowerCase()) && (R = I[Y]);
584
+ l.isUndefined(b) ? g = `${R}${m}` : /* @ts-expect-error */ E[b.toLowerCase()] ? (R = // @ts-expect-error
585
+ E[b.toLowerCase()], g = `${R}${m}`) : (Object.keys(E).forEach((Y) => {
586
+ b.toLowerCase().includes(Y.toLowerCase()) && (R = E[Y]);
565
587
  }), g = `${R}${m}`);
566
588
  }
567
589
  const Z = this.runtimeAdapter.getRuntimeRequired({
568
590
  ...e,
569
591
  label: m
570
- }), A = E.getItemContainer(this), ee = E.getFormItemContainer(this), te = this, se = e.componentSlots;
592
+ }), A = w.getItemContainer(this), ee = w.getFormItemContainer(this), te = this, se = e.componentSlots;
571
593
  return p("div", {
572
594
  style: c
573
595
  }, [p(A, {
@@ -598,13 +620,13 @@ class me {
598
620
  display: "grid",
599
621
  gridColumn: "1 / -1",
600
622
  ...e.grid
601
- }, i = E.getGroupContainer(this);
623
+ }, i = w.getGroupContainer(this);
602
624
  let o = e.show;
603
625
  return o === void 0 && (o = !0), p("div", {
604
626
  style: s
605
627
  }, [o && p(i, {
606
628
  schema: e
607
- }, he(t = e.children.map((n) => this.runtimeItemProcessor(n))) ? t : {
629
+ }, pe(t = e.children.map((n) => this.runtimeItemProcessor(n))) ? t : {
608
630
  default: () => [t]
609
631
  })]);
610
632
  }
@@ -629,7 +651,7 @@ class me {
629
651
  s.model.value[e.field] || (s.model.value[e.field] = [{}]);
630
652
  let i = e.show;
631
653
  i === void 0 && (i = !0);
632
- const o = E.getListContainer(this), n = E.getListItemContainer(this);
654
+ const o = w.getListContainer(this), n = w.getListItemContainer(this);
633
655
  return p("div", {
634
656
  style: t
635
657
  }, [i && p(o, {
@@ -671,7 +693,7 @@ class me {
671
693
  gridColumn: "1 / -1",
672
694
  gridAutoColumns: "1fr",
673
695
  ...this.grid
674
- }, t = this, s = h(C((u = (c = this.native) == null ? void 0 : c.props) == null ? void 0 : u.Form) ?? {}, this.globalNativeFormOverride.props), i = h(C((b = (d = this.native) == null ? void 0 : d.slots) == null ? void 0 : b.Form) ?? {}, this.globalNativeFormOverride.slots), o = E.getFormContainer(this), n = this.runtimeAdapter.getFormModelPropName();
696
+ }, t = this, s = h(C((u = (c = this.native) == null ? void 0 : c.props) == null ? void 0 : u.Form) ?? {}, this.globalNativeFormOverride.props), i = h(C((b = (d = this.native) == null ? void 0 : d.slots) == null ? void 0 : b.Form) ?? {}, this.globalNativeFormOverride.slots), o = w.getFormContainer(this), n = this.runtimeAdapter.getFormModelPropName();
675
697
  return p(o, O(s, {
676
698
  ref: this.formRef
677
699
  }, {
@@ -744,7 +766,7 @@ const ye = {
744
766
  },
745
767
  validateForm(r) {
746
768
  return new Promise((e, t) => {
747
- r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(S(r.runtimeCore.processor.processedModel.value))));
769
+ r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(F(r.runtimeCore.processor.processedModel.value))));
748
770
  });
749
771
  },
750
772
  clearValidate(r) {
@@ -803,7 +825,7 @@ const ye = {
803
825
  valid: s,
804
826
  errors: i
805
827
  }) => {
806
- s ? e(r.cleanFallbackFields(S(r.runtimeCore.processor.processedModel.value))) : t(i);
828
+ s ? e(r.cleanFallbackFields(F(r.runtimeCore.processor.processedModel.value))) : t(i);
807
829
  });
808
830
  });
809
831
  },
@@ -859,14 +881,14 @@ const ye = {
859
881
  },
860
882
  validateForm(r) {
861
883
  return new Promise((e, t) => {
862
- r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(S(r.runtimeCore.processor.processedModel.value))));
884
+ r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(F(r.runtimeCore.processor.processedModel.value))));
863
885
  });
864
886
  },
865
887
  clearValidate(r) {
866
888
  r.formRef.value.restoreValidation();
867
889
  }
868
890
  }
869
- }, w = class w {
891
+ }, S = class S {
870
892
  static getPlaceholderPrefixPresetByComponentName() {
871
893
  const e = {
872
894
  请选择: ["select", "tree"],
@@ -879,7 +901,7 @@ const ye = {
879
901
  return t;
880
902
  }
881
903
  };
882
- a(w, "schemaPreset", {
904
+ a(S, "schemaPreset", {
883
905
  type: {
884
906
  defaultValue: "item"
885
907
  },
@@ -922,14 +944,14 @@ a(w, "schemaPreset", {
922
944
  grid: {
923
945
  default: void 0
924
946
  }
925
- }), a(w, "componentPropsPreset", {
947
+ }), a(S, "componentPropsPreset", {
926
948
  options: {
927
949
  defaultValue: []
928
950
  }
929
951
  }), // 基于基本功能提出基本预设
930
- a(w, "placeholderPresetByComponentName", w.getPlaceholderPrefixPresetByComponentName());
931
- let k = w;
932
- const v = {
952
+ a(S, "placeholderPresetByComponentName", S.getPlaceholderPrefixPresetByComponentName());
953
+ let k = S;
954
+ const P = {
933
955
  ...k,
934
956
  adapters: {
935
957
  ...ye
@@ -966,16 +988,16 @@ function be(r, e) {
966
988
  writable: !0
967
989
  }), r;
968
990
  }
969
- function Ve(r) {
991
+ function Ee(r) {
970
992
  return be(r, "native");
971
993
  }
972
- function je(r) {
994
+ function Ve(r) {
973
995
  return r.__proform_raw_object = !0, r;
974
996
  }
975
997
  export {
976
998
  ge as ProForm,
977
- Ve as markNativeFunction,
978
- je as markNativeObject,
999
+ Ee as markNativeFunction,
1000
+ Ve as markNativeObject,
979
1001
  Ce as useForm,
980
1002
  Ie as useFormPresetConfigurer,
981
1003
  be as useModifiers
@@ -26,6 +26,7 @@ export default class RuntimeCore {
26
26
  model: AnyObject;
27
27
  reactiveModel: AnyObject;
28
28
  shared: AnyObject;
29
+ share: (data: AnyObject) => void;
29
30
  };
30
31
  runtimeItemProcessor(schema: ItemSchema, index?: number, baseModel?: AnyObject, parentSchema?: ListSchema): JSX.Element | undefined;
31
32
  runtimeGroupProcessor(schema: GroupSchema): JSX.Element;
@@ -89,6 +89,7 @@ export interface runtimeMeta {
89
89
  model: AnyObject;
90
90
  reactiveModel: AnyObject;
91
91
  shared: AnyObject;
92
+ share: (data: AnyObject) => any;
92
93
  }
93
94
  export type ProFormProxyRule<T> = T | ((runtimeMeta: runtimeMeta) => T) | ((runtimeMeta: runtimeMeta) => Promise<T>);
94
95
  export type ProFormProxy<T> = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harbor-design/proform",
3
- "version": "1.1.33",
3
+ "version": "1.1.35",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",