@harbor-design/proform 1.2.13 → 1.2.14

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 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 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";
4
+ import { readonly as ce, isRef as q, watch as v, isReactive as N, nextTick as g, toRaw as w, ref as M, reactive as se, createVNode as p, mergeProps as O, withDirectives as fe, vShow as de, createTextVNode as he, isVNode as pe, defineComponent as me } from "vue";
5
5
  class l {
6
6
  static typeChecker(e) {
7
7
  return {}.toString.call(e);
@@ -80,7 +80,7 @@ function h(r, ...e) {
80
80
  t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ? r[s] = h(r[s] || {}, t[s]) : r[s] = t[s]);
81
81
  }), r;
82
82
  }
83
- function C(r) {
83
+ function I(r) {
84
84
  const e = /* @__PURE__ */ new WeakMap();
85
85
  function t(s) {
86
86
  if (s === null || typeof s != "object")
@@ -121,9 +121,10 @@ function C(r) {
121
121
  function x(r, e) {
122
122
  return r.replace(/undefined/g, e);
123
123
  }
124
- class me {
124
+ class be {
125
125
  constructor(e) {
126
126
  a(this, "runtimeCore");
127
+ a(this, "reactiveModel");
127
128
  this.formCustomization = e;
128
129
  }
129
130
  // happy path, 后续可以完善更多的 fallback 处理,fallback 处理是为了不卡住异步时的首次渲染做的优化
@@ -133,7 +134,7 @@ class me {
133
134
  })), e;
134
135
  }
135
136
  setup(e) {
136
- return this.runtimeCore = e, Object.assign(this.runtimeCore.native, this.formCustomization.native), Object.assign(this.runtimeCore.grid, this.formCustomization.grid), Object.assign(this.runtimeCore.runtime, this.formCustomization.runtime), this.formCustomization.ui && (this.runtimeCore.ui = this.formCustomization.ui), this.formCustomization;
137
+ return this.runtimeCore = e, this.reactiveModel = ce(e.model.value), Object.assign(this.runtimeCore.native, this.formCustomization.native), Object.assign(this.runtimeCore.grid, this.formCustomization.grid), Object.assign(this.runtimeCore.runtime, this.formCustomization.runtime), this.formCustomization.ui && (this.runtimeCore.ui = this.formCustomization.ui), this.formCustomization;
137
138
  }
138
139
  submit() {
139
140
  var s;
@@ -148,7 +149,7 @@ class me {
148
149
  });
149
150
  this.runtimeCore.hydrateEffect.trackEffect(
150
151
  () => {
151
- q(e) ? y(
152
+ q(e) ? v(
152
153
  () => e.value,
153
154
  () => {
154
155
  h(this.runtimeCore.model.value, e.value);
@@ -157,7 +158,7 @@ class me {
157
158
  deep: !0,
158
159
  immediate: !0
159
160
  }
160
- ) : N(e) ? y(
161
+ ) : N(e) ? v(
161
162
  () => e,
162
163
  () => {
163
164
  h(this.runtimeCore.model.value, e);
@@ -175,10 +176,10 @@ class me {
175
176
  }
176
177
  share(e) {
177
178
  if (q(e)) {
178
- const t = y(
179
+ const t = v(
179
180
  () => e.value,
180
181
  () => {
181
- h(this.runtimeCore.shared, e.value), this.runtimeCore.processor.schemaEffect.triggerEffects(), E(() => {
182
+ h(this.runtimeCore.shared, e.value), this.runtimeCore.processor.schemaEffect.triggerEffects(), g(() => {
182
183
  t();
183
184
  });
184
185
  },
@@ -188,10 +189,10 @@ class me {
188
189
  }
189
190
  );
190
191
  } else if (N(e)) {
191
- const t = y(
192
+ const t = v(
192
193
  () => e,
193
194
  () => {
194
- h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects(), E(() => {
195
+ h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects(), g(() => {
195
196
  t();
196
197
  });
197
198
  },
@@ -203,6 +204,26 @@ class me {
203
204
  } else
204
205
  h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects();
205
206
  }
207
+ subscribeModel(e) {
208
+ g(() => {
209
+ const t = v(
210
+ () => this.reactiveModel,
211
+ (s) => {
212
+ e(s, {
213
+ stopSubscribe() {
214
+ g(() => {
215
+ t();
216
+ });
217
+ }
218
+ });
219
+ },
220
+ {
221
+ immediate: !0,
222
+ deep: !0
223
+ }
224
+ );
225
+ });
226
+ }
206
227
  }
207
228
  class L {
208
229
  constructor() {
@@ -220,7 +241,7 @@ class L {
220
241
  return !t.lazy && e(), this.effects.add(e), () => this.effects.delete(e);
221
242
  }
222
243
  }
223
- class be {
244
+ class ve {
224
245
  constructor(e) {
225
246
  a(this, "runtimeCore");
226
247
  a(this, "processedSchemas");
@@ -237,7 +258,7 @@ class be {
237
258
  a(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
238
259
  a(this, "baseDefaultValueFunctionsLength");
239
260
  a(this, "isModelInitialized", !0);
240
- this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), y(
261
+ this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), v(
241
262
  () => this.processedModel.value,
242
263
  () => {
243
264
  this.schemaEffect.triggerEffects();
@@ -275,7 +296,7 @@ class be {
275
296
  // 派生过程,用于外部应用
276
297
  parseSchemas(e, t) {
277
298
  l.isArrayEmpty(this.processedSchemas.value) && (this.baseDefaultValueFunctionsLength = this.countFunctionDefaultValues(
278
- C(e)
299
+ I(e)
279
300
  ), this.processedSchemas.value = this.initSchemas(e)), this.parse(e, t);
280
301
  }
281
302
  parseStable(e) {
@@ -289,7 +310,7 @@ class be {
289
310
  // 对于稳定初始化更新的抽象
290
311
  stableUpdater(e = []) {
291
312
  if (e.every(Boolean)) {
292
- const t = R(this.processedSchemas.value);
313
+ const t = w(this.processedSchemas.value);
293
314
  !l.isProcessInprogress(t) && l.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
294
315
  length: t.length
295
316
  }).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
@@ -302,14 +323,14 @@ class be {
302
323
  }).fill(!1);
303
324
  this.objectParser({ data: e, index: t, updater: n });
304
325
  function n(f) {
305
- const c = f.index, d = f.key, v = f.keyIndex;
326
+ const c = f.index, d = f.key, y = f.keyIndex;
306
327
  if (l.isUndefined(f.stable))
307
328
  return;
308
- const F = i.parseStable(f.stable), I = s == null ? void 0 : s.index, g = s == null ? void 0 : s.key;
329
+ const F = i.parseStable(f.stable), E = s == null ? void 0 : s.index, C = s == null ? void 0 : s.key;
309
330
  let b = F;
310
- if (l.isProcessInprogress(b) || (o[v] = !0), s) {
311
- const m = i.processedSchemas.value[I][g][c][d];
312
- m && l.isObject(m) && d !== "component" && (b = h(m, b)), i.processedSchemas.value[I][g][c][d] = b, i.stableUpdater(o);
331
+ if (l.isProcessInprogress(b) || (o[y] = !0), s) {
332
+ const m = i.processedSchemas.value[E][C][c][d];
333
+ m && l.isObject(m) && d !== "component" && (b = h(m, b)), i.processedSchemas.value[E][C][c][d] = b, i.stableUpdater(o);
313
334
  } else {
314
335
  const m = i.processedSchemas.value[c][d];
315
336
  m && l.isObject(m) && d !== "component" && (b = h(m, b)), i.processedSchemas.value[c][d] = b, i.stableUpdater(o);
@@ -355,13 +376,13 @@ class be {
355
376
  return n(c);
356
377
  this.defaultValueInprogressMap.set(t[i], c), !l.isProcessInprogress(c) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
357
378
  this.defaultValueInprogressMap.values()
358
- ).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), E(() => {
379
+ ).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), g(() => {
359
380
  f();
360
381
  })) : n(c);
361
382
  }) : this.fieldParser(t[i], (c) => {
362
383
  this.defaultValueInprogressMap.set(t[i], c), !l.isProcessInprogress(c) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
363
384
  this.defaultValueInprogressMap.values()
364
- ).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), E(() => {
385
+ ).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), g(() => {
365
386
  f();
366
387
  })) : n(c);
367
388
  });
@@ -404,7 +425,7 @@ class be {
404
425
  this.promiseFieldParser(i, t, s);
405
426
  }
406
427
  else
407
- q(e) ? y(
428
+ q(e) ? v(
408
429
  () => e.value,
409
430
  () => {
410
431
  l.isUndefined(e.value) || (s && l.isObject(e.value) && !l.isNativeObject(e.value) ? this.objectParser({
@@ -416,7 +437,7 @@ class be {
416
437
  immediate: !0,
417
438
  deep: !0
418
439
  }
419
- ) : N(e) ? y(
440
+ ) : N(e) ? v(
420
441
  () => e,
421
442
  () => {
422
443
  l.isUndefined(e) || (s && l.isObject(e) && !l.isNativeObject(e) ? this.objectParser({
@@ -436,7 +457,7 @@ class be {
436
457
  modelProcessor(e) {
437
458
  e.map(
438
459
  (t) => this.createModel(t, this.processedModel.value)
439
- ), l.isObjectEmpty(this.stableModel) && this.stableUpdaterProcessProgress.every(Boolean) && this.defaultValueEffect.effects.size === 0 && (this.stableModel = C(this.processedModel.value), this.runtimeCore.hydrateEffect.triggerEffects(), this.runtimeCore.hydrateEffect.clearEffects());
460
+ ), l.isObjectEmpty(this.stableModel) && this.stableUpdaterProcessProgress.every(Boolean) && this.defaultValueEffect.effects.size === 0 && (this.stableModel = I(this.processedModel.value), this.runtimeCore.hydrateEffect.triggerEffects(), this.runtimeCore.hydrateEffect.clearEffects());
440
461
  }
441
462
  createModel(e, t) {
442
463
  l.isListSchema(e) && (t[e.field] || (t[e.field] = [{}]), e.children.forEach((s) => {
@@ -466,7 +487,7 @@ class V {
466
487
  return u.presets.uiPresets[e ?? u.presets.ui].container.ListItem;
467
488
  }
468
489
  }
469
- class ve {
490
+ class ye {
470
491
  constructor(e) {
471
492
  this.ui = e;
472
493
  }
@@ -500,19 +521,19 @@ class ve {
500
521
  return (t == null ? void 0 : t.clearValidate(e)) ?? (s == null ? void 0 : s.clearValidate(e));
501
522
  }
502
523
  }
503
- function ye(r) {
504
- return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !he(r);
524
+ function Pe(r) {
525
+ return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !pe(r);
505
526
  }
506
- class Pe {
527
+ class ge {
507
528
  constructor(e) {
508
- a(this, "schemas", U([]));
509
- a(this, "model", U({}));
529
+ a(this, "schemas", M([]));
530
+ a(this, "model", M({}));
510
531
  a(this, "processorBySchemaType", {
511
532
  item: this.runtimeItemProcessor.bind(this),
512
533
  group: this.runtimeGroupProcessor.bind(this),
513
534
  list: this.runtimeListProcessor.bind(this)
514
535
  });
515
- a(this, "formRef", U(null));
536
+ a(this, "formRef", M(null));
516
537
  a(this, "hydrateEffect", new L());
517
538
  a(this, "native", se({}));
518
539
  a(this, "grid", {});
@@ -528,10 +549,10 @@ class Pe {
528
549
  }
529
550
  }));
530
551
  a(this, "shared", {});
531
- this.setup = e, this.processor = new be(this);
552
+ this.setup = e, this.processor = new ve(this);
532
553
  const t = this.setup(this);
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(
554
+ if (this.ui = t.ui ?? u.presets.ui, this.runtimeAdapter = new ye(this.ui), Object.assign(this.globalNativeFormOverride, this.runtimeAdapter.getRuntimeNative()), q(t.schemas))
555
+ v(
535
556
  // @ts-expect-error
536
557
  () => t.schemas.value,
537
558
  () => {
@@ -542,8 +563,8 @@ class Pe {
542
563
  }
543
564
  );
544
565
  else if (N(t.schemas)) {
545
- const s = y(() => t.schemas, () => {
546
- this.processor.parseSchemas(t.schemas), E(() => {
566
+ const s = v(() => t.schemas, () => {
567
+ this.processor.parseSchemas(t.schemas), g(() => {
547
568
  s();
548
569
  });
549
570
  }, {
@@ -553,7 +574,7 @@ class Pe {
553
574
  this.processor.parseSchemas(t.schemas);
554
575
  }
555
576
  getRuntimeMeta() {
556
- const e = R(C(this.model.value));
577
+ const e = w(I(this.model.value));
557
578
  let t;
558
579
  return {
559
580
  model: e,
@@ -563,8 +584,8 @@ class Pe {
563
584
  share: (s) => {
564
585
  t && clearTimeout(t), t = setTimeout(() => {
565
586
  if (q(s)) {
566
- const i = y(() => s.value, () => {
567
- h(this.shared, s.value), this.processor.schemaEffect.triggerEffects(), E(() => {
587
+ const i = v(() => s.value, () => {
588
+ h(this.shared, s.value), this.processor.schemaEffect.triggerEffects(), g(() => {
568
589
  i();
569
590
  });
570
591
  }, {
@@ -572,8 +593,8 @@ class Pe {
572
593
  immediate: !0
573
594
  });
574
595
  } else if (N(s)) {
575
- const i = y(() => s, () => {
576
- h(this.shared, s), this.processor.schemaEffect.triggerEffects(), E(() => {
596
+ const i = v(() => s, () => {
597
+ h(this.shared, s), this.processor.schemaEffect.triggerEffects(), g(() => {
577
598
  i();
578
599
  });
579
600
  }, {
@@ -587,30 +608,30 @@ class Pe {
587
608
  };
588
609
  }
589
610
  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;
591
- const o = R(e.component);
611
+ var _, z, k, B, D, T, G, W, K, H, J, Q, X, Y, Z, A, ee;
612
+ const o = w(e.component);
592
613
  if (!o)
593
614
  return;
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
- 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 = {
615
+ (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);
616
+ const n = h(I((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
617
  display: "grid",
597
618
  gridColumn: "1 / -1",
598
619
  ...e.grid
599
- }, c = h(C((Y = (X = this.native) == null ? void 0 : X.props) == null ? void 0 : Y.FormItem) ?? {}, (A = (Z = e.native) == null ? void 0 : Z.props) == null ? void 0 : A.FormItem), d = this.runtimeAdapter.getRuntimeField({
620
+ }, c = h(I((Y = (X = this.native) == null ? void 0 : X.props) == null ? void 0 : Y.FormItem) ?? {}, (A = (Z = e.native) == null ? void 0 : Z.props) == null ? void 0 : A.FormItem), d = this.runtimeAdapter.getRuntimeField({
600
621
  schema: e,
601
622
  parentSchema: i,
602
623
  index: t
603
- }), v = o.name, F = e.componentProps ?? {}, I = P.placeholderPresetByComponentName;
604
- let g = e.placeholder, b = e.show;
624
+ }), y = o.name, F = e.componentProps ?? {}, E = P.placeholderPresetByComponentName;
625
+ let C = e.placeholder, b = e.show;
605
626
  b === void 0 && (b = !0);
606
627
  let m = e.label ?? "";
607
628
  const j = (i == null ? void 0 : i.runtime) ?? this.runtime;
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
- let S = "请输入";
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
- }), g = `${S}${m}`);
629
+ 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), "")), !C) {
630
+ let R = "请输入";
631
+ l.isUndefined(y) ? C = `${R}${m}` : /* @ts-expect-error */ E[y.toLowerCase()] ? (R = // @ts-expect-error
632
+ E[y.toLowerCase()], C = `${R}${m}`) : (Object.keys(E).forEach((te) => {
633
+ y.toLowerCase().includes(te.toLowerCase()) && (R = E[te]);
634
+ }), C = `${R}${m}`);
614
635
  }
615
636
  const re = this.runtimeAdapter.getRuntimeRequired({
616
637
  ...e,
@@ -630,7 +651,7 @@ class Pe {
630
651
  Component: o,
631
652
  schema: e,
632
653
  baseModel: s,
633
- placeholder: g,
654
+ placeholder: C,
634
655
  componentSlots: le,
635
656
  props: F
636
657
  });
@@ -652,7 +673,7 @@ class Pe {
652
673
  style: s
653
674
  }, [o && p(i, {
654
675
  schema: e
655
- }, ye(t = e.children.map((n) => this.runtimeItemProcessor(n))) ? t : {
676
+ }, Pe(t = e.children.map((n) => this.runtimeItemProcessor(n))) ? t : {
656
677
  default: () => [t]
657
678
  })]);
658
679
  }
@@ -663,7 +684,7 @@ class Pe {
663
684
  code: "0001",
664
685
  message: "异步默认值数据正在处理中,请您耐心等待... "
665
686
  });
666
- (s = this.processor.stableModel[e.field]) != null && s[0] && this.model.value[e.field].push(C(this.processor.stableModel[e.field][0])), this.runtimeAdapter.clearValidate(this);
687
+ (s = this.processor.stableModel[e.field]) != null && s[0] && this.model.value[e.field].push(I(this.processor.stableModel[e.field][0])), this.runtimeAdapter.clearValidate(this);
667
688
  }
668
689
  deleteListItem(e, t) {
669
690
  this.model.value[e.field].splice(t, 1), this.runtimeAdapter.clearValidate(this);
@@ -692,17 +713,17 @@ class Pe {
692
713
  container: d
693
714
  } = {}) {
694
715
  var F;
695
- const v = d ?? p("button", null, null);
696
- return ce(p(v, {
716
+ const y = d ?? p("button", null, null);
717
+ return fe(p(y, {
697
718
  onClick: () => s.deleteListItem(e, c)
698
- }, null), [[fe, ((F = s.model.value[e.field]) == null ? void 0 : F.length) > 1]]);
719
+ }, null), [[de, ((F = s.model.value[e.field]) == null ? void 0 : F.length) > 1]]);
699
720
  }
700
721
  }));
701
722
  },
702
723
  add({
703
724
  container: f
704
725
  } = {}) {
705
- const c = f ?? p("button", null, [de("添加")]);
726
+ const c = f ?? p("button", null, [he("添加")]);
706
727
  return p(c, {
707
728
  onClick: () => s.addListItem(e)
708
729
  }, null);
@@ -713,13 +734,13 @@ class Pe {
713
734
  return e.map((t) => (t.type || (t.type = "item"), this.processorBySchemaType[t.type](t)));
714
735
  }
715
736
  exec() {
716
- var f, c, d, v;
737
+ var f, c, d, y;
717
738
  const e = {
718
739
  display: "grid",
719
740
  gridColumn: "1 / -1",
720
741
  gridAutoColumns: "1fr",
721
742
  ...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((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();
743
+ }, t = this, s = h(I((c = (f = this.native) == null ? void 0 : f.props) == null ? void 0 : c.Form) ?? {}, this.globalNativeFormOverride.props.Form), i = h(I((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();
723
744
  return p(o, O(s, {
724
745
  ref: this.formRef
725
746
  }, {
@@ -745,18 +766,18 @@ class u {
745
766
  }
746
767
  }
747
768
  a(u, "presets");
748
- function M({
769
+ function U({
749
770
  parentSchema: r,
750
771
  schema: e,
751
772
  index: t
752
773
  }) {
753
774
  return r ? `${r.field}.${t}.${e.field}` : e.field;
754
775
  }
755
- const ge = {
776
+ const Ce = {
756
777
  ArcoVue: {
757
778
  getRuntimeField(r) {
758
779
  return {
759
- field: M(r)
780
+ field: U(r)
760
781
  };
761
782
  },
762
783
  getRuntimeRequired(r) {
@@ -806,7 +827,7 @@ const ge = {
806
827
  },
807
828
  validateForm(r) {
808
829
  return new Promise((e, t) => {
809
- r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))));
830
+ r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(w(r.runtimeCore.processor.processedModel.value))));
810
831
  });
811
832
  },
812
833
  clearValidate(r) {
@@ -816,7 +837,7 @@ const ge = {
816
837
  NutUI: {
817
838
  getRuntimeField(r) {
818
839
  return {
819
- prop: M(r)
840
+ prop: U(r)
820
841
  };
821
842
  },
822
843
  getRuntimeRequired(r) {
@@ -871,7 +892,7 @@ const ge = {
871
892
  valid: s,
872
893
  errors: i
873
894
  }) => {
874
- s ? e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))) : t(i);
895
+ s ? e(r.cleanFallbackFields(w(r.runtimeCore.processor.processedModel.value))) : t(i);
875
896
  });
876
897
  });
877
898
  },
@@ -882,7 +903,7 @@ const ge = {
882
903
  NaiveUI: {
883
904
  getRuntimeField(r) {
884
905
  return {
885
- path: M(r)
906
+ path: U(r)
886
907
  };
887
908
  },
888
909
  getRuntimeRequired(r) {
@@ -935,14 +956,14 @@ const ge = {
935
956
  },
936
957
  validateForm(r) {
937
958
  return new Promise((e, t) => {
938
- r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))));
959
+ r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(w(r.runtimeCore.processor.processedModel.value))));
939
960
  });
940
961
  },
941
962
  clearValidate(r) {
942
963
  r.formRef.value.restoreValidation();
943
964
  }
944
965
  }
945
- }, w = class w {
966
+ }, S = class S {
946
967
  static getPlaceholderPrefixPresetByComponentName() {
947
968
  const e = {
948
969
  请选择: ["select", "tree"],
@@ -955,7 +976,7 @@ const ge = {
955
976
  return t;
956
977
  }
957
978
  };
958
- a(w, "schemaPreset", {
979
+ a(S, "schemaPreset", {
959
980
  type: {
960
981
  defaultValue: "item"
961
982
  },
@@ -998,19 +1019,19 @@ a(w, "schemaPreset", {
998
1019
  grid: {
999
1020
  default: void 0
1000
1021
  }
1001
- }), a(w, "componentPropsPreset", {
1022
+ }), a(S, "componentPropsPreset", {
1002
1023
  options: {
1003
1024
  defaultValue: []
1004
1025
  }
1005
1026
  }), // 基于基本功能提出基本预设
1006
- a(w, "placeholderPresetByComponentName", w.getPlaceholderPrefixPresetByComponentName());
1007
- let _ = w;
1027
+ a(S, "placeholderPresetByComponentName", S.getPlaceholderPrefixPresetByComponentName());
1028
+ let $ = S;
1008
1029
  const P = {
1009
- ..._,
1030
+ ...$,
1010
1031
  adapters: {
1011
- ...ge
1032
+ ...Ce
1012
1033
  }
1013
- }, Fe = /* @__PURE__ */ pe({
1034
+ }, je = /* @__PURE__ */ me({
1014
1035
  props: {
1015
1036
  setup: {
1016
1037
  type: Function,
@@ -1018,41 +1039,42 @@ const P = {
1018
1039
  }
1019
1040
  },
1020
1041
  setup(r) {
1021
- const e = new Pe(r.setup);
1042
+ const e = new ge(r.setup);
1022
1043
  return () => e.exec();
1023
1044
  }
1024
1045
  });
1025
- function je(r) {
1026
- const e = new me(r);
1046
+ function Ve(r) {
1047
+ const e = new be(r);
1027
1048
  return [
1028
1049
  e.setup.bind(e),
1029
1050
  {
1030
1051
  submit: e.submit.bind(e),
1031
1052
  hydrate: e.hydrate.bind(e),
1032
- share: e.share.bind(e)
1053
+ share: e.share.bind(e),
1054
+ subscribeModel: e.subscribeModel.bind(e)
1033
1055
  }
1034
1056
  ];
1035
1057
  }
1036
- function Ve(r) {
1058
+ function Se(r) {
1037
1059
  u.presets = r;
1038
1060
  }
1039
- function Ce(r, e) {
1061
+ function Ie(r, e) {
1040
1062
  return e === "native" && Object.defineProperty(r, "name", {
1041
1063
  value: `__proform_raw_${r.name}`,
1042
1064
  writable: !0
1043
1065
  }), r;
1044
1066
  }
1045
1067
  function we(r) {
1046
- return Ce(r, "native");
1068
+ return Ie(r, "native");
1047
1069
  }
1048
1070
  function Re(r) {
1049
1071
  return r.__proform_raw_object = !0, r;
1050
1072
  }
1051
1073
  export {
1052
- Fe as ProForm,
1074
+ je as ProForm,
1053
1075
  we as markNativeFunction,
1054
1076
  Re as markNativeObject,
1055
- je as useForm,
1056
- Ve as useFormPresetConfigurer,
1057
- Ce as useModifiers
1077
+ Ve as useForm,
1078
+ Se as useFormPresetConfigurer,
1079
+ Ie as useModifiers
1058
1080
  };
@@ -1,12 +1,14 @@
1
- import { AnyObject, FormCustomization } from "../../types";
1
+ import { AnyFunction, AnyObject, FormCustomization } from "../../types";
2
2
  import { RuntimeCore } from "../index";
3
3
  export default class FormCustomizer {
4
4
  formCustomization: FormCustomization;
5
5
  runtimeCore: RuntimeCore;
6
+ reactiveModel: AnyObject;
6
7
  private cleanFallbackFields;
7
8
  constructor(formCustomization: FormCustomization);
8
9
  setup(_runtimeCore: RuntimeCore): FormCustomization;
9
10
  submit(): Promise<AnyObject>;
10
11
  hydrate(data: AnyObject): Promise<never> | undefined;
11
12
  share(data: AnyObject): void;
13
+ subscribeModel(callback: AnyFunction): void;
12
14
  }
@@ -1,11 +1,17 @@
1
1
  import { AnyObject } from "../types";
2
2
  import type { RuntimeCore } from "../services";
3
+ import { WatchStopHandle } from "vue";
3
4
  export type Setup = (runtimeCore: RuntimeCore) => any;
5
+ export type SubscribeUtils = {
6
+ stopSubscribe: WatchStopHandle;
7
+ };
8
+ export type SubscribeCallback = (value: any, utils: SubscribeUtils) => any;
4
9
  export type UseForm = [
5
10
  Setup,
6
11
  {
7
12
  submit: () => Promise<AnyObject>;
8
13
  hydrate: (data: AnyObject) => any;
9
14
  share: (data: AnyObject) => any;
15
+ subscribeModel: (callback: SubscribeCallback) => any;
10
16
  }
11
17
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harbor-design/proform",
3
- "version": "1.2.13",
3
+ "version": "1.2.14",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",