@harbor-design/proform 1.2.10 → 1.2.12

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 { isRef as w, watch as v, isReactive as S, nextTick as E, toRaw as O, ref as N, reactive as se, createVNode as p, mergeProps as q, 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);
@@ -69,15 +69,15 @@ class l {
69
69
  return !!e.__proform_raw_object;
70
70
  }
71
71
  }
72
- function h(r, ...e) {
72
+ function d(r, ...e) {
73
73
  return e.forEach((t) => {
74
74
  if (Array.isArray(t))
75
75
  Array.isArray(r) || (r = []), t.forEach((s, i) => {
76
- typeof s == "object" && s !== null ? r[i] = h(Array.isArray(s) ? [] : {}, s) : r[i] = s;
76
+ typeof s == "object" && s !== null ? r[i] = d(Array.isArray(s) ? [] : {}, s) : r[i] = s;
77
77
  });
78
78
  else
79
79
  for (const s in t)
80
- t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ? r[s] = h(r[s] || {}, t[s]) : r[s] = t[s]);
80
+ t.hasOwnProperty(s) && (typeof t[s] == "object" && t[s] !== null ? r[s] = d(r[s] || {}, t[s]) : r[s] = t[s]);
81
81
  }), r;
82
82
  }
83
83
  function C(r) {
@@ -124,6 +124,7 @@ function x(r, e) {
124
124
  class me {
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 = 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,25 +149,25 @@ class me {
148
149
  });
149
150
  this.runtimeCore.hydrateEffect.trackEffect(
150
151
  () => {
151
- q(e) ? y(
152
+ w(e) ? v(
152
153
  () => e.value,
153
154
  () => {
154
- h(this.runtimeCore.model.value, e.value);
155
+ d(this.runtimeCore.model.value, e.value);
155
156
  },
156
157
  {
157
158
  deep: !0,
158
159
  immediate: !0
159
160
  }
160
- ) : N(e) ? y(
161
+ ) : S(e) ? v(
161
162
  () => e,
162
163
  () => {
163
- h(this.runtimeCore.model.value, e);
164
+ d(this.runtimeCore.model.value, e);
164
165
  },
165
166
  {
166
167
  deep: !0,
167
168
  immediate: !0
168
169
  }
169
- ) : h(this.runtimeCore.model.value, e);
170
+ ) : d(this.runtimeCore.model.value, e);
170
171
  },
171
172
  {
172
173
  lazy: !1
@@ -174,11 +175,11 @@ class me {
174
175
  );
175
176
  }
176
177
  share(e) {
177
- if (q(e)) {
178
- const t = y(
178
+ if (w(e)) {
179
+ const t = v(
179
180
  () => e.value,
180
181
  () => {
181
- h(this.runtimeCore.shared, e.value), this.runtimeCore.processor.schemaEffect.triggerEffects(), E(() => {
182
+ d(this.runtimeCore.shared, e.value), this.runtimeCore.processor.schemaEffect.triggerEffects(), E(() => {
182
183
  t();
183
184
  });
184
185
  },
@@ -187,11 +188,11 @@ class me {
187
188
  immediate: !0
188
189
  }
189
190
  );
190
- } else if (N(e)) {
191
- const t = y(
191
+ } else if (S(e)) {
192
+ const t = v(
192
193
  () => e,
193
194
  () => {
194
- h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects(), E(() => {
195
+ d(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects(), E(() => {
195
196
  t();
196
197
  });
197
198
  },
@@ -201,7 +202,42 @@ class me {
201
202
  }
202
203
  );
203
204
  } else
204
- h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects();
205
+ d(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects();
206
+ }
207
+ getReactiveModel() {
208
+ return this.reactiveModel || console.error(
209
+ "调用 getReactiveModel 受限:理论上 model 需要在 useForm 的下一个 tick 使用,可在 nextTick 及部分合适的框架钩子中使用该函数"
210
+ ), this.reactiveModel;
211
+ }
212
+ setReactiveModel(e) {
213
+ return this.reactiveModel || console.error(
214
+ "调用 getReactiveModel 受限:理论上 model 需要在 useForm 的下一个 tick 使用,可在 nextTick 及部分合适的框架钩子中使用该函数"
215
+ ), this.runtimeCore.hydrateEffect.trackEffect(
216
+ () => {
217
+ w(e) ? v(
218
+ () => e.value,
219
+ () => {
220
+ d(this.runtimeCore.model.value, e.value);
221
+ },
222
+ {
223
+ deep: !0,
224
+ immediate: !0
225
+ }
226
+ ) : S(e) ? v(
227
+ () => e,
228
+ () => {
229
+ d(this.runtimeCore.model.value, e);
230
+ },
231
+ {
232
+ deep: !0,
233
+ immediate: !0
234
+ }
235
+ ) : d(this.runtimeCore.model.value, e);
236
+ },
237
+ {
238
+ lazy: !1
239
+ }
240
+ ), this.reactiveModel;
205
241
  }
206
242
  }
207
243
  class L {
@@ -220,7 +256,7 @@ class L {
220
256
  return !t.lazy && e(), this.effects.add(e), () => this.effects.delete(e);
221
257
  }
222
258
  }
223
- class be {
259
+ class ve {
224
260
  constructor(e) {
225
261
  a(this, "runtimeCore");
226
262
  a(this, "processedSchemas");
@@ -237,7 +273,7 @@ class be {
237
273
  a(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
238
274
  a(this, "baseDefaultValueFunctionsLength");
239
275
  a(this, "isModelInitialized", !0);
240
- this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), y(
276
+ this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), v(
241
277
  () => this.processedModel.value,
242
278
  () => {
243
279
  this.schemaEffect.triggerEffects();
@@ -289,7 +325,7 @@ class be {
289
325
  // 对于稳定初始化更新的抽象
290
326
  stableUpdater(e = []) {
291
327
  if (e.every(Boolean)) {
292
- const t = R(this.processedSchemas.value);
328
+ const t = O(this.processedSchemas.value);
293
329
  !l.isProcessInprogress(t) && l.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
294
330
  length: t.length
295
331
  }).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
@@ -302,17 +338,17 @@ class be {
302
338
  }).fill(!1);
303
339
  this.objectParser({ data: e, index: t, updater: n });
304
340
  function n(f) {
305
- const c = f.index, d = f.key, v = f.keyIndex;
341
+ const c = f.index, h = f.key, y = f.keyIndex;
306
342
  if (l.isUndefined(f.stable))
307
343
  return;
308
344
  const F = i.parseStable(f.stable), I = s == null ? void 0 : s.index, g = s == null ? void 0 : s.key;
309
345
  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);
346
+ if (l.isProcessInprogress(b) || (o[y] = !0), s) {
347
+ const m = i.processedSchemas.value[I][g][c][h];
348
+ m && l.isObject(m) && h !== "component" && (b = d(m, b)), i.processedSchemas.value[I][g][c][h] = b, i.stableUpdater(o);
313
349
  } else {
314
- const m = i.processedSchemas.value[c][d];
315
- m && l.isObject(m) && d !== "component" && (b = h(m, b)), i.processedSchemas.value[c][d] = b, i.stableUpdater(o);
350
+ const m = i.processedSchemas.value[c][h];
351
+ m && l.isObject(m) && h !== "component" && (b = d(m, b)), i.processedSchemas.value[c][h] = b, i.stableUpdater(o);
316
352
  }
317
353
  }
318
354
  }
@@ -355,13 +391,13 @@ class be {
355
391
  return n(c);
356
392
  this.defaultValueInprogressMap.set(t[i], c), !l.isProcessInprogress(c) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
357
393
  this.defaultValueInprogressMap.values()
358
- ).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), E(() => {
394
+ ).every((h) => !h.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), E(() => {
359
395
  f();
360
396
  })) : n(c);
361
397
  }) : this.fieldParser(t[i], (c) => {
362
398
  this.defaultValueInprogressMap.set(t[i], c), !l.isProcessInprogress(c) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
363
399
  this.defaultValueInprogressMap.values()
364
- ).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), E(() => {
400
+ ).every((h) => !h.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), E(() => {
365
401
  f();
366
402
  })) : n(c);
367
403
  });
@@ -404,7 +440,7 @@ class be {
404
440
  this.promiseFieldParser(i, t, s);
405
441
  }
406
442
  else
407
- q(e) ? y(
443
+ w(e) ? v(
408
444
  () => e.value,
409
445
  () => {
410
446
  l.isUndefined(e.value) || (s && l.isObject(e.value) && !l.isNativeObject(e.value) ? this.objectParser({
@@ -416,7 +452,7 @@ class be {
416
452
  immediate: !0,
417
453
  deep: !0
418
454
  }
419
- ) : N(e) ? y(
455
+ ) : S(e) ? v(
420
456
  () => e,
421
457
  () => {
422
458
  l.isUndefined(e) || (s && l.isObject(e) && !l.isNativeObject(e) ? this.objectParser({
@@ -446,7 +482,7 @@ class be {
446
482
  }), l.isItemSchema(e) && ("defaultValue" in e ? t[e.field] = e.defaultValue : t[e.field] || (t[e.field] = void 0));
447
483
  }
448
484
  }
449
- class V {
485
+ class j {
450
486
  static getFormContainer({ ui: e } = {}) {
451
487
  return u.presets.uiPresets[e ?? u.presets.ui].container.Form;
452
488
  }
@@ -466,7 +502,7 @@ class V {
466
502
  return u.presets.uiPresets[e ?? u.presets.ui].container.ListItem;
467
503
  }
468
504
  }
469
- class ve {
505
+ class be {
470
506
  constructor(e) {
471
507
  this.ui = e;
472
508
  }
@@ -505,14 +541,14 @@ function ye(r) {
505
541
  }
506
542
  class Pe {
507
543
  constructor(e) {
508
- a(this, "schemas", U([]));
509
- a(this, "model", U({}));
544
+ a(this, "schemas", N([]));
545
+ a(this, "model", N({}));
510
546
  a(this, "processorBySchemaType", {
511
547
  item: this.runtimeItemProcessor.bind(this),
512
548
  group: this.runtimeGroupProcessor.bind(this),
513
549
  list: this.runtimeListProcessor.bind(this)
514
550
  });
515
- a(this, "formRef", U(null));
551
+ a(this, "formRef", N(null));
516
552
  a(this, "hydrateEffect", new L());
517
553
  a(this, "native", se({}));
518
554
  a(this, "grid", {});
@@ -528,10 +564,10 @@ class Pe {
528
564
  }
529
565
  }));
530
566
  a(this, "shared", {});
531
- this.setup = e, this.processor = new be(this);
567
+ this.setup = e, this.processor = new ve(this);
532
568
  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(
569
+ if (this.ui = t.ui ?? u.presets.ui, this.runtimeAdapter = new be(this.ui), Object.assign(this.globalNativeFormOverride, this.runtimeAdapter.getRuntimeNative()), w(t.schemas))
570
+ v(
535
571
  // @ts-expect-error
536
572
  () => t.schemas.value,
537
573
  () => {
@@ -541,8 +577,8 @@ class Pe {
541
577
  deep: !0
542
578
  }
543
579
  );
544
- else if (N(t.schemas)) {
545
- const s = y(() => t.schemas, () => {
580
+ else if (S(t.schemas)) {
581
+ const s = v(() => t.schemas, () => {
546
582
  this.processor.parseSchemas(t.schemas), E(() => {
547
583
  s();
548
584
  });
@@ -553,7 +589,7 @@ class Pe {
553
589
  this.processor.parseSchemas(t.schemas);
554
590
  }
555
591
  getRuntimeMeta() {
556
- const e = R(C(this.model.value));
592
+ const e = O(C(this.model.value));
557
593
  let t;
558
594
  return {
559
595
  model: e,
@@ -562,18 +598,18 @@ class Pe {
562
598
  // share 增加防抖,当开发者在过程中进行 share 时避免频繁触发爆栈
563
599
  share: (s) => {
564
600
  t && clearTimeout(t), t = setTimeout(() => {
565
- if (q(s)) {
566
- const i = y(() => s.value, () => {
567
- h(this.shared, s.value), this.processor.schemaEffect.triggerEffects(), E(() => {
601
+ if (w(s)) {
602
+ const i = v(() => s.value, () => {
603
+ d(this.shared, s.value), this.processor.schemaEffect.triggerEffects(), E(() => {
568
604
  i();
569
605
  });
570
606
  }, {
571
607
  deep: !0,
572
608
  immediate: !0
573
609
  });
574
- } else if (N(s)) {
575
- const i = y(() => s, () => {
576
- h(this.shared, s), this.processor.schemaEffect.triggerEffects(), E(() => {
610
+ } else if (S(s)) {
611
+ const i = v(() => s, () => {
612
+ d(this.shared, s), this.processor.schemaEffect.triggerEffects(), E(() => {
577
613
  i();
578
614
  });
579
615
  }, {
@@ -581,50 +617,50 @@ class Pe {
581
617
  immediate: !0
582
618
  });
583
619
  } else
584
- h(this.shared, s), this.processor.schemaEffect.triggerEffects();
620
+ d(this.shared, s), this.processor.schemaEffect.triggerEffects();
585
621
  }, 0);
586
622
  }
587
623
  };
588
624
  }
589
625
  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);
626
+ var $, _, z, T, B, D, G, W, K, H, J, Q, X, Y, Z, A, ee;
627
+ const o = O(e.component);
592
628
  if (!o)
593
629
  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 = {
630
+ (_ = ($ = e.native) == null ? void 0 : $.props) != null && _.Form && d(this.globalNativeFormOverride.props.Form, (T = (z = e.native) == null ? void 0 : z.props) == null ? void 0 : T.Form), (D = (B = e.native) == null ? void 0 : B.slots) != null && D.Form && d(this.globalNativeFormOverride.slots.Form, (W = (G = e.native) == null ? void 0 : G.slots) == null ? void 0 : W.Form);
631
+ const n = d(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
632
  display: "grid",
597
633
  gridColumn: "1 / -1",
598
634
  ...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({
635
+ }, c = d(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), h = this.runtimeAdapter.getRuntimeField({
600
636
  schema: e,
601
637
  parentSchema: i,
602
638
  index: t
603
- }), v = o.name, F = e.componentProps ?? {}, I = P.placeholderPresetByComponentName;
639
+ }), y = o.name, F = e.componentProps ?? {}, I = P.placeholderPresetByComponentName;
604
640
  let g = e.placeholder, b = e.show;
605
641
  b === void 0 && (b = !0);
606
642
  let m = e.label ?? "";
607
- 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}`);
643
+ const R = (i == null ? void 0 : i.runtime) ?? this.runtime;
644
+ if (!l.isUndefined(t) && !l.isObjectEmpty(R) && (m = x((ee = R == null ? void 0 : R.customizeListItemLabel) == null ? void 0 : ee.call(R, e.label ?? "", t + 1), "")), !g) {
645
+ let M = "请输入";
646
+ l.isUndefined(y) ? g = `${M}${m}` : /* @ts-expect-error */ I[y.toLowerCase()] ? (M = // @ts-expect-error
647
+ I[y.toLowerCase()], g = `${M}${m}`) : (Object.keys(I).forEach((te) => {
648
+ y.toLowerCase().includes(te.toLowerCase()) && (M = I[te]);
649
+ }), g = `${M}${m}`);
614
650
  }
615
651
  const re = this.runtimeAdapter.getRuntimeRequired({
616
652
  ...e,
617
653
  label: m
618
- }), ie = V.getItemContainer(this), oe = V.getFormItemContainer(this), ne = this, le = e.componentSlots;
654
+ }), ie = j.getItemContainer(this), oe = j.getFormItemContainer(this), ne = this, le = e.componentSlots;
619
655
  return p("div", {
620
656
  style: f
621
657
  }, [p(ie, {
622
658
  show: b
623
659
  }, {
624
660
  default() {
625
- return b && p(oe, O(c, {
661
+ return b && p(oe, q(c, {
626
662
  label: `${m ? `${m}:` : ""}`
627
- }, d, re), {
663
+ }, h, re), {
628
664
  default() {
629
665
  return ne.runtimeAdapter.formComponentRenderer({
630
666
  Component: o,
@@ -646,7 +682,7 @@ class Pe {
646
682
  display: "grid",
647
683
  gridColumn: "1 / -1",
648
684
  ...e.grid
649
- }, i = V.getGroupContainer(this);
685
+ }, i = j.getGroupContainer(this);
650
686
  let o = e.show;
651
687
  return o === void 0 && (o = !0), p("div", {
652
688
  style: s
@@ -677,7 +713,7 @@ class Pe {
677
713
  s.model.value[e.field] || (s.model.value[e.field] = [{}]);
678
714
  let i = e.show;
679
715
  i === void 0 && (i = !0);
680
- const o = V.getListContainer(this), n = V.getListItemContainer(this);
716
+ const o = j.getListContainer(this), n = j.getListItemContainer(this);
681
717
  return p("div", {
682
718
  style: t
683
719
  }, [i && p(o, {
@@ -686,14 +722,14 @@ class Pe {
686
722
  default() {
687
723
  return s.model.value[e.field].map((f, c) => p(n, null, {
688
724
  default() {
689
- return e.children.map((d) => s.runtimeItemProcessor(d, c, f, e));
725
+ return e.children.map((h) => s.runtimeItemProcessor(h, c, f, e));
690
726
  },
691
727
  delete({
692
- container: d
728
+ container: h
693
729
  } = {}) {
694
730
  var F;
695
- const v = d ?? p("button", null, null);
696
- return ce(p(v, {
731
+ const y = h ?? p("button", null, null);
732
+ return ce(p(y, {
697
733
  onClick: () => s.deleteListItem(e, c)
698
734
  }, null), [[fe, ((F = s.model.value[e.field]) == null ? void 0 : F.length) > 1]]);
699
735
  }
@@ -713,14 +749,14 @@ class Pe {
713
749
  return e.map((t) => (t.type || (t.type = "item"), this.processorBySchemaType[t.type](t)));
714
750
  }
715
751
  exec() {
716
- var f, c, d, v;
752
+ var f, c, h, y;
717
753
  const e = {
718
754
  display: "grid",
719
755
  gridColumn: "1 / -1",
720
756
  gridAutoColumns: "1fr",
721
757
  ...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();
723
- return p(o, O(s, {
758
+ }, t = this, s = d(C((c = (f = this.native) == null ? void 0 : f.props) == null ? void 0 : c.Form) ?? {}, this.globalNativeFormOverride.props.Form), i = d(C((y = (h = this.native) == null ? void 0 : h.slots) == null ? void 0 : y.Form) ?? {}, this.globalNativeFormOverride.slots.Form), o = j.getFormContainer(this), n = this.runtimeAdapter.getFormModelPropName();
759
+ return p(o, q(s, {
724
760
  ref: this.formRef
725
761
  }, {
726
762
  [n]: this.model.value
@@ -745,7 +781,7 @@ class u {
745
781
  }
746
782
  }
747
783
  a(u, "presets");
748
- function M({
784
+ function U({
749
785
  parentSchema: r,
750
786
  schema: e,
751
787
  index: t
@@ -756,7 +792,7 @@ const ge = {
756
792
  ArcoVue: {
757
793
  getRuntimeField(r) {
758
794
  return {
759
- field: M(r)
795
+ field: U(r)
760
796
  };
761
797
  },
762
798
  getRuntimeRequired(r) {
@@ -769,14 +805,14 @@ const ge = {
769
805
  });
770
806
  else {
771
807
  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.push({
808
+ t !== -1 ? (r.rules[t].required = !0, r.rules[t].message = `${r.label}是必填项`) : r.rules.unshift({
773
809
  required: !0,
774
810
  message: `${r.label}是必填项`
775
811
  });
776
812
  }
777
813
  else if (r.rules) {
778
814
  const t = (e = r.rules) == null ? void 0 : e.findIndex((s) => !!s.required);
779
- t !== -1 ? r.rules[t].required = !1 : r.rules.push({
815
+ t !== -1 ? r.rules[t].required = !1 : r.rules.unshift({
780
816
  required: !0,
781
817
  message: `${r.label}是必填项`
782
818
  });
@@ -796,7 +832,7 @@ const ge = {
796
832
  componentSlots: i,
797
833
  props: o
798
834
  }) {
799
- return p(r, O({
835
+ return p(r, q({
800
836
  modelValue: e[t.field],
801
837
  "onUpdate:modelValue": (n) => e[t.field] = n,
802
838
  placeholder: s
@@ -806,7 +842,7 @@ const ge = {
806
842
  },
807
843
  validateForm(r) {
808
844
  return new Promise((e, t) => {
809
- r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))));
845
+ r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(O(r.runtimeCore.processor.processedModel.value))));
810
846
  });
811
847
  },
812
848
  clearValidate(r) {
@@ -816,7 +852,7 @@ const ge = {
816
852
  NutUI: {
817
853
  getRuntimeField(r) {
818
854
  return {
819
- prop: M(r)
855
+ prop: U(r)
820
856
  };
821
857
  },
822
858
  getRuntimeRequired(r) {
@@ -829,14 +865,14 @@ const ge = {
829
865
  });
830
866
  else {
831
867
  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.push({
868
+ t !== -1 ? (r.rules[t].required = !0, r.rules[t].message = `${r.label}是必填项`) : r.rules.unshift({
833
869
  required: !0,
834
870
  message: `${r.label}是必填项`
835
871
  });
836
872
  }
837
873
  else if (r.rules) {
838
874
  const t = (e = r.rules) == null ? void 0 : e.findIndex((s) => !!s.required);
839
- t !== -1 ? r.rules[t].required = !1 : r.rules.push({
875
+ t !== -1 ? r.rules[t].required = !1 : r.rules.unshift({
840
876
  required: !0,
841
877
  message: `${r.label}是必填项`
842
878
  });
@@ -857,7 +893,7 @@ const ge = {
857
893
  componentSlots: i,
858
894
  props: o
859
895
  }) {
860
- return p(r, O({
896
+ return p(r, q({
861
897
  modelValue: e[t.field],
862
898
  "onUpdate:modelValue": (n) => e[t.field] = n,
863
899
  placeholder: s
@@ -871,7 +907,7 @@ const ge = {
871
907
  valid: s,
872
908
  errors: i
873
909
  }) => {
874
- s ? e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))) : t(i);
910
+ s ? e(r.cleanFallbackFields(O(r.runtimeCore.processor.processedModel.value))) : t(i);
875
911
  });
876
912
  });
877
913
  },
@@ -882,7 +918,7 @@ const ge = {
882
918
  NaiveUI: {
883
919
  getRuntimeField(r) {
884
920
  return {
885
- path: M(r)
921
+ path: U(r)
886
922
  };
887
923
  },
888
924
  getRuntimeRequired(r) {
@@ -896,7 +932,7 @@ const ge = {
896
932
  });
897
933
  else {
898
934
  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.push({
935
+ t !== -1 ? (r.rules[t].required = !0, r.rules[t].message = `${r.label}是必填项`) : r.rules.unshift({
900
936
  required: !0,
901
937
  message: `${r.label}是必填项`,
902
938
  trigger: ["input", "blur"]
@@ -904,7 +940,7 @@ const ge = {
904
940
  }
905
941
  else if (r.rules) {
906
942
  const t = (e = r.rules) == null ? void 0 : e.findIndex((s) => !!s.required);
907
- t !== -1 ? r.rules[t].required = !1 : r.rules.push({
943
+ t !== -1 ? r.rules[t].required = !1 : r.rules.unshift({
908
944
  required: !0,
909
945
  message: `${r.label}是必填项`,
910
946
  trigger: ["input", "blur"]
@@ -925,7 +961,7 @@ const ge = {
925
961
  componentSlots: i,
926
962
  props: o
927
963
  }) {
928
- return p(r, O({
964
+ return p(r, q({
929
965
  value: e[t.field],
930
966
  "onUpdate:value": (n) => e[t.field] = n,
931
967
  placeholder: s
@@ -935,14 +971,14 @@ const ge = {
935
971
  },
936
972
  validateForm(r) {
937
973
  return new Promise((e, t) => {
938
- r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))));
974
+ r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(O(r.runtimeCore.processor.processedModel.value))));
939
975
  });
940
976
  },
941
977
  clearValidate(r) {
942
978
  r.formRef.value.restoreValidation();
943
979
  }
944
980
  }
945
- }, w = class w {
981
+ }, V = class V {
946
982
  static getPlaceholderPrefixPresetByComponentName() {
947
983
  const e = {
948
984
  请选择: ["select", "tree"],
@@ -955,7 +991,7 @@ const ge = {
955
991
  return t;
956
992
  }
957
993
  };
958
- a(w, "schemaPreset", {
994
+ a(V, "schemaPreset", {
959
995
  type: {
960
996
  defaultValue: "item"
961
997
  },
@@ -998,15 +1034,15 @@ a(w, "schemaPreset", {
998
1034
  grid: {
999
1035
  default: void 0
1000
1036
  }
1001
- }), a(w, "componentPropsPreset", {
1037
+ }), a(V, "componentPropsPreset", {
1002
1038
  options: {
1003
1039
  defaultValue: []
1004
1040
  }
1005
1041
  }), // 基于基本功能提出基本预设
1006
- a(w, "placeholderPresetByComponentName", w.getPlaceholderPrefixPresetByComponentName());
1007
- let _ = w;
1042
+ a(V, "placeholderPresetByComponentName", V.getPlaceholderPrefixPresetByComponentName());
1043
+ let k = V;
1008
1044
  const P = {
1009
- ..._,
1045
+ ...k,
1010
1046
  adapters: {
1011
1047
  ...ge
1012
1048
  }
@@ -1022,18 +1058,20 @@ const P = {
1022
1058
  return () => e.exec();
1023
1059
  }
1024
1060
  });
1025
- function je(r) {
1061
+ function Re(r) {
1026
1062
  const e = new me(r);
1027
1063
  return [
1028
1064
  e.setup.bind(e),
1029
1065
  {
1030
1066
  submit: e.submit.bind(e),
1031
1067
  hydrate: e.hydrate.bind(e),
1032
- share: e.share.bind(e)
1068
+ share: e.share.bind(e),
1069
+ getReactiveModel: e.getReactiveModel.bind(e),
1070
+ setReactiveModel: e.setReactiveModel.bind(e)
1033
1071
  }
1034
1072
  ];
1035
1073
  }
1036
- function Ve(r) {
1074
+ function je(r) {
1037
1075
  u.presets = r;
1038
1076
  }
1039
1077
  function Ce(r, e) {
@@ -1042,17 +1080,17 @@ function Ce(r, e) {
1042
1080
  writable: !0
1043
1081
  }), r;
1044
1082
  }
1045
- function we(r) {
1083
+ function Ve(r) {
1046
1084
  return Ce(r, "native");
1047
1085
  }
1048
- function Re(r) {
1086
+ function we(r) {
1049
1087
  return r.__proform_raw_object = !0, r;
1050
1088
  }
1051
1089
  export {
1052
1090
  Fe as ProForm,
1053
- we as markNativeFunction,
1054
- Re as markNativeObject,
1055
- je as useForm,
1056
- Ve as useFormPresetConfigurer,
1091
+ Ve as markNativeFunction,
1092
+ we as markNativeObject,
1093
+ Re as useForm,
1094
+ je as useFormPresetConfigurer,
1057
1095
  Ce as useModifiers
1058
1096
  };
@@ -3,10 +3,13 @@ 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
+ getReactiveModel(): AnyObject;
14
+ setReactiveModel(data: AnyObject): AnyObject;
12
15
  }
@@ -7,5 +7,7 @@ export type UseForm = [
7
7
  submit: () => Promise<AnyObject>;
8
8
  hydrate: (data: AnyObject) => any;
9
9
  share: (data: AnyObject) => any;
10
+ getReactiveModel: () => AnyObject;
11
+ setReactiveModel: (data: AnyObject) => AnyObject;
10
12
  }
11
13
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harbor-design/proform",
3
- "version": "1.2.10",
3
+ "version": "1.2.12",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",