@harbor-design/proform 1.2.13 → 1.2.15

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 M, nextTick as C, toRaw as w, ref as N, 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 P(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,11 +134,11 @@ 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;
140
- const e = (s = u.getPreset(this.runtimeCore.ui)) == null ? void 0 : s.adapter, t = P.adapters[u.getUI(this.runtimeCore.ui)];
141
+ const e = (s = u.getPreset(this.runtimeCore.ui)) == null ? void 0 : s.adapter, t = g.adapters[u.getUI(this.runtimeCore.ui)];
141
142
  return (e == null ? void 0 : e.validateForm(this)) ?? (t == null ? void 0 : t.validateForm(this));
142
143
  }
143
144
  hydrate(e) {
@@ -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
+ ) : M(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(), C(() => {
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 (M(e)) {
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(), C(() => {
195
196
  t();
196
197
  });
197
198
  },
@@ -203,6 +204,31 @@ class me {
203
204
  } else
204
205
  h(this.runtimeCore.shared, e), this.runtimeCore.processor.schemaEffect.triggerEffects();
205
206
  }
207
+ subscribeModel(e) {
208
+ C(() => {
209
+ const t = v(
210
+ () => this.reactiveModel,
211
+ (s) => {
212
+ e(s, {
213
+ stopSubscribe() {
214
+ C(() => {
215
+ t();
216
+ });
217
+ }
218
+ });
219
+ },
220
+ {
221
+ immediate: !0,
222
+ deep: !0
223
+ }
224
+ );
225
+ });
226
+ }
227
+ resetModel() {
228
+ this.runtimeCore.model.value = P(
229
+ this.runtimeCore.processor.stableModel
230
+ );
231
+ }
206
232
  }
207
233
  class L {
208
234
  constructor() {
@@ -220,7 +246,7 @@ class L {
220
246
  return !t.lazy && e(), this.effects.add(e), () => this.effects.delete(e);
221
247
  }
222
248
  }
223
- class be {
249
+ class ve {
224
250
  constructor(e) {
225
251
  a(this, "runtimeCore");
226
252
  a(this, "processedSchemas");
@@ -228,8 +254,8 @@ class be {
228
254
  a(this, "getRuntimeMeta");
229
255
  a(this, "stableSchemas", []);
230
256
  a(this, "stableModel", {});
231
- a(this, "schemaPreset", P.schemaPreset);
232
- a(this, "componentPropsPreset", P.componentPropsPreset);
257
+ a(this, "schemaPreset", g.schemaPreset);
258
+ a(this, "componentPropsPreset", g.componentPropsPreset);
233
259
  a(this, "stableUpdaterProcessProgress");
234
260
  a(this, "stableUpdaterTimes", 0);
235
261
  a(this, "schemaEffect", new L());
@@ -237,7 +263,7 @@ class be {
237
263
  a(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
238
264
  a(this, "baseDefaultValueFunctionsLength");
239
265
  a(this, "isModelInitialized", !0);
240
- this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), y(
266
+ this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), v(
241
267
  () => this.processedModel.value,
242
268
  () => {
243
269
  this.schemaEffect.triggerEffects();
@@ -275,7 +301,7 @@ class be {
275
301
  // 派生过程,用于外部应用
276
302
  parseSchemas(e, t) {
277
303
  l.isArrayEmpty(this.processedSchemas.value) && (this.baseDefaultValueFunctionsLength = this.countFunctionDefaultValues(
278
- C(e)
304
+ P(e)
279
305
  ), this.processedSchemas.value = this.initSchemas(e)), this.parse(e, t);
280
306
  }
281
307
  parseStable(e) {
@@ -289,7 +315,7 @@ class be {
289
315
  // 对于稳定初始化更新的抽象
290
316
  stableUpdater(e = []) {
291
317
  if (e.every(Boolean)) {
292
- const t = R(this.processedSchemas.value);
318
+ const t = w(this.processedSchemas.value);
293
319
  !l.isProcessInprogress(t) && l.isObjectEmpty(this.stableModel) && (this.stableUpdaterProcessProgress || (this.stableUpdaterProcessProgress = Array.from({
294
320
  length: t.length
295
321
  }).fill(!1)), this.stableUpdaterProcessProgress[this.stableUpdaterTimes] = !0, this.stableUpdaterTimes++, this.modelProcessor(t));
@@ -302,14 +328,14 @@ class be {
302
328
  }).fill(!1);
303
329
  this.objectParser({ data: e, index: t, updater: n });
304
330
  function n(f) {
305
- const c = f.index, d = f.key, v = f.keyIndex;
331
+ const c = f.index, d = f.key, y = f.keyIndex;
306
332
  if (l.isUndefined(f.stable))
307
333
  return;
308
- const F = i.parseStable(f.stable), I = s == null ? void 0 : s.index, g = s == null ? void 0 : s.key;
334
+ const F = i.parseStable(f.stable), E = s == null ? void 0 : s.index, I = s == null ? void 0 : s.key;
309
335
  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);
336
+ if (l.isProcessInprogress(b) || (o[y] = !0), s) {
337
+ const m = i.processedSchemas.value[E][I][c][d];
338
+ m && l.isObject(m) && d !== "component" && (b = h(m, b)), i.processedSchemas.value[E][I][c][d] = b, i.stableUpdater(o);
313
339
  } else {
314
340
  const m = i.processedSchemas.value[c][d];
315
341
  m && l.isObject(m) && d !== "component" && (b = h(m, b)), i.processedSchemas.value[c][d] = b, i.stableUpdater(o);
@@ -355,13 +381,13 @@ class be {
355
381
  return n(c);
356
382
  this.defaultValueInprogressMap.set(t[i], c), !l.isProcessInprogress(c) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
357
383
  this.defaultValueInprogressMap.values()
358
- ).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), E(() => {
384
+ ).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), C(() => {
359
385
  f();
360
386
  })) : n(c);
361
387
  }) : this.fieldParser(t[i], (c) => {
362
388
  this.defaultValueInprogressMap.set(t[i], c), !l.isProcessInprogress(c) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
363
389
  this.defaultValueInprogressMap.values()
364
- ).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), E(() => {
390
+ ).every((d) => !d.includes("undefined")) ? (n(c), this.defaultValueEffect.clearEffects(), C(() => {
365
391
  f();
366
392
  })) : n(c);
367
393
  });
@@ -404,7 +430,7 @@ class be {
404
430
  this.promiseFieldParser(i, t, s);
405
431
  }
406
432
  else
407
- q(e) ? y(
433
+ q(e) ? v(
408
434
  () => e.value,
409
435
  () => {
410
436
  l.isUndefined(e.value) || (s && l.isObject(e.value) && !l.isNativeObject(e.value) ? this.objectParser({
@@ -416,7 +442,7 @@ class be {
416
442
  immediate: !0,
417
443
  deep: !0
418
444
  }
419
- ) : N(e) ? y(
445
+ ) : M(e) ? v(
420
446
  () => e,
421
447
  () => {
422
448
  l.isUndefined(e) || (s && l.isObject(e) && !l.isNativeObject(e) ? this.objectParser({
@@ -436,7 +462,7 @@ class be {
436
462
  modelProcessor(e) {
437
463
  e.map(
438
464
  (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());
465
+ ), l.isObjectEmpty(this.stableModel) && this.stableUpdaterProcessProgress.every(Boolean) && this.defaultValueEffect.effects.size === 0 && (console.log("done once"), this.stableModel = P(this.processedModel.value), this.runtimeCore.hydrateEffect.triggerEffects(), this.runtimeCore.hydrateEffect.clearEffects());
440
466
  }
441
467
  createModel(e, t) {
442
468
  l.isListSchema(e) && (t[e.field] || (t[e.field] = [{}]), e.children.forEach((s) => {
@@ -466,7 +492,7 @@ class V {
466
492
  return u.presets.uiPresets[e ?? u.presets.ui].container.ListItem;
467
493
  }
468
494
  }
469
- class ve {
495
+ class ye {
470
496
  constructor(e) {
471
497
  this.ui = e;
472
498
  }
@@ -476,43 +502,43 @@ class ve {
476
502
  }
477
503
  getRuntimeField(e) {
478
504
  var i;
479
- const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[u.getUI(this.ui)];
505
+ const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = g.adapters[u.getUI(this.ui)];
480
506
  return (t == null ? void 0 : t.getRuntimeField(e)) ?? (s == null ? void 0 : s.getRuntimeField(e));
481
507
  }
482
508
  getRuntimeRequired(e) {
483
509
  var i;
484
- const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[u.getUI(this.ui)];
510
+ const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = g.adapters[u.getUI(this.ui)];
485
511
  return (t == null ? void 0 : t.getRuntimeRequired(e)) ?? (s == null ? void 0 : s.getRuntimeRequired(e));
486
512
  }
487
513
  getFormModelPropName() {
488
514
  var s;
489
- const e = (s = u.presets.uiPresets[this.ui]) == null ? void 0 : s.adapter, t = P.adapters[u.getUI(this.ui)];
515
+ const e = (s = u.presets.uiPresets[this.ui]) == null ? void 0 : s.adapter, t = g.adapters[u.getUI(this.ui)];
490
516
  return (e == null ? void 0 : e.getFormModelPropName()) ?? (t == null ? void 0 : t.getFormModelPropName());
491
517
  }
492
518
  formComponentRenderer(e) {
493
519
  var i;
494
- const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[u.getUI(this.ui)];
520
+ const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = g.adapters[u.getUI(this.ui)];
495
521
  return (t == null ? void 0 : t.formComponentRenderer(e)) ?? (s == null ? void 0 : s.formComponentRenderer(e));
496
522
  }
497
523
  clearValidate(e) {
498
524
  var i;
499
- const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = P.adapters[u.getUI(this.ui)];
525
+ const t = (i = u.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = g.adapters[u.getUI(this.ui)];
500
526
  return (t == null ? void 0 : t.clearValidate(e)) ?? (s == null ? void 0 : s.clearValidate(e));
501
527
  }
502
528
  }
503
- function ye(r) {
504
- return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !he(r);
529
+ function Pe(r) {
530
+ return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !pe(r);
505
531
  }
506
- class Pe {
532
+ class ge {
507
533
  constructor(e) {
508
- a(this, "schemas", U([]));
509
- a(this, "model", U({}));
534
+ a(this, "schemas", N([]));
535
+ a(this, "model", N({}));
510
536
  a(this, "processorBySchemaType", {
511
537
  item: this.runtimeItemProcessor.bind(this),
512
538
  group: this.runtimeGroupProcessor.bind(this),
513
539
  list: this.runtimeListProcessor.bind(this)
514
540
  });
515
- a(this, "formRef", U(null));
541
+ a(this, "formRef", N(null));
516
542
  a(this, "hydrateEffect", new L());
517
543
  a(this, "native", se({}));
518
544
  a(this, "grid", {});
@@ -528,10 +554,10 @@ class Pe {
528
554
  }
529
555
  }));
530
556
  a(this, "shared", {});
531
- this.setup = e, this.processor = new be(this);
557
+ this.setup = e, this.processor = new ve(this);
532
558
  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(
559
+ if (this.ui = t.ui ?? u.presets.ui, this.runtimeAdapter = new ye(this.ui), Object.assign(this.globalNativeFormOverride, this.runtimeAdapter.getRuntimeNative()), q(t.schemas))
560
+ v(
535
561
  // @ts-expect-error
536
562
  () => t.schemas.value,
537
563
  () => {
@@ -541,9 +567,9 @@ class Pe {
541
567
  deep: !0
542
568
  }
543
569
  );
544
- else if (N(t.schemas)) {
545
- const s = y(() => t.schemas, () => {
546
- this.processor.parseSchemas(t.schemas), E(() => {
570
+ else if (M(t.schemas)) {
571
+ const s = v(() => t.schemas, () => {
572
+ this.processor.parseSchemas(t.schemas), C(() => {
547
573
  s();
548
574
  });
549
575
  }, {
@@ -553,7 +579,7 @@ class Pe {
553
579
  this.processor.parseSchemas(t.schemas);
554
580
  }
555
581
  getRuntimeMeta() {
556
- const e = R(C(this.model.value));
582
+ const e = w(P(this.model.value));
557
583
  let t;
558
584
  return {
559
585
  model: e,
@@ -563,17 +589,17 @@ class Pe {
563
589
  share: (s) => {
564
590
  t && clearTimeout(t), t = setTimeout(() => {
565
591
  if (q(s)) {
566
- const i = y(() => s.value, () => {
567
- h(this.shared, s.value), this.processor.schemaEffect.triggerEffects(), E(() => {
592
+ const i = v(() => s.value, () => {
593
+ h(this.shared, s.value), this.processor.schemaEffect.triggerEffects(), C(() => {
568
594
  i();
569
595
  });
570
596
  }, {
571
597
  deep: !0,
572
598
  immediate: !0
573
599
  });
574
- } else if (N(s)) {
575
- const i = y(() => s, () => {
576
- h(this.shared, s), this.processor.schemaEffect.triggerEffects(), E(() => {
600
+ } else if (M(s)) {
601
+ const i = v(() => s, () => {
602
+ h(this.shared, s), this.processor.schemaEffect.triggerEffects(), C(() => {
577
603
  i();
578
604
  });
579
605
  }, {
@@ -587,30 +613,30 @@ class Pe {
587
613
  };
588
614
  }
589
615
  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);
616
+ var _, z, k, B, D, T, G, W, K, H, J, Q, X, Y, Z, A, ee;
617
+ const o = w(e.component);
592
618
  if (!o)
593
619
  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 = {
620
+ (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);
621
+ const n = h(P((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
622
  display: "grid",
597
623
  gridColumn: "1 / -1",
598
624
  ...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({
625
+ }, c = h(P((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
626
  schema: e,
601
627
  parentSchema: i,
602
628
  index: t
603
- }), v = o.name, F = e.componentProps ?? {}, I = P.placeholderPresetByComponentName;
604
- let g = e.placeholder, b = e.show;
629
+ }), y = o.name, F = e.componentProps ?? {}, E = g.placeholderPresetByComponentName;
630
+ let I = e.placeholder, b = e.show;
605
631
  b === void 0 && (b = !0);
606
632
  let m = e.label ?? "";
607
633
  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}`);
634
+ 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), "")), !I) {
635
+ let R = "请输入";
636
+ l.isUndefined(y) ? I = `${R}${m}` : /* @ts-expect-error */ E[y.toLowerCase()] ? (R = // @ts-expect-error
637
+ E[y.toLowerCase()], I = `${R}${m}`) : (Object.keys(E).forEach((te) => {
638
+ y.toLowerCase().includes(te.toLowerCase()) && (R = E[te]);
639
+ }), I = `${R}${m}`);
614
640
  }
615
641
  const re = this.runtimeAdapter.getRuntimeRequired({
616
642
  ...e,
@@ -630,7 +656,7 @@ class Pe {
630
656
  Component: o,
631
657
  schema: e,
632
658
  baseModel: s,
633
- placeholder: g,
659
+ placeholder: I,
634
660
  componentSlots: le,
635
661
  props: F
636
662
  });
@@ -652,7 +678,7 @@ class Pe {
652
678
  style: s
653
679
  }, [o && p(i, {
654
680
  schema: e
655
- }, ye(t = e.children.map((n) => this.runtimeItemProcessor(n))) ? t : {
681
+ }, Pe(t = e.children.map((n) => this.runtimeItemProcessor(n))) ? t : {
656
682
  default: () => [t]
657
683
  })]);
658
684
  }
@@ -663,7 +689,7 @@ class Pe {
663
689
  code: "0001",
664
690
  message: "异步默认值数据正在处理中,请您耐心等待... "
665
691
  });
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);
692
+ (s = this.processor.stableModel[e.field]) != null && s[0] && this.model.value[e.field].push(P(this.processor.stableModel[e.field][0])), this.runtimeAdapter.clearValidate(this);
667
693
  }
668
694
  deleteListItem(e, t) {
669
695
  this.model.value[e.field].splice(t, 1), this.runtimeAdapter.clearValidate(this);
@@ -692,17 +718,17 @@ class Pe {
692
718
  container: d
693
719
  } = {}) {
694
720
  var F;
695
- const v = d ?? p("button", null, null);
696
- return ce(p(v, {
721
+ const y = d ?? p("button", null, null);
722
+ return fe(p(y, {
697
723
  onClick: () => s.deleteListItem(e, c)
698
- }, null), [[fe, ((F = s.model.value[e.field]) == null ? void 0 : F.length) > 1]]);
724
+ }, null), [[de, ((F = s.model.value[e.field]) == null ? void 0 : F.length) > 1]]);
699
725
  }
700
726
  }));
701
727
  },
702
728
  add({
703
729
  container: f
704
730
  } = {}) {
705
- const c = f ?? p("button", null, [de("添加")]);
731
+ const c = f ?? p("button", null, [he("添加")]);
706
732
  return p(c, {
707
733
  onClick: () => s.addListItem(e)
708
734
  }, null);
@@ -713,13 +739,13 @@ class Pe {
713
739
  return e.map((t) => (t.type || (t.type = "item"), this.processorBySchemaType[t.type](t)));
714
740
  }
715
741
  exec() {
716
- var f, c, d, v;
742
+ var f, c, d, y;
717
743
  const e = {
718
744
  display: "grid",
719
745
  gridColumn: "1 / -1",
720
746
  gridAutoColumns: "1fr",
721
747
  ...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();
748
+ }, t = this, s = h(P((c = (f = this.native) == null ? void 0 : f.props) == null ? void 0 : c.Form) ?? {}, this.globalNativeFormOverride.props.Form), i = h(P((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
749
  return p(o, O(s, {
724
750
  ref: this.formRef
725
751
  }, {
@@ -745,18 +771,18 @@ class u {
745
771
  }
746
772
  }
747
773
  a(u, "presets");
748
- function M({
774
+ function U({
749
775
  parentSchema: r,
750
776
  schema: e,
751
777
  index: t
752
778
  }) {
753
779
  return r ? `${r.field}.${t}.${e.field}` : e.field;
754
780
  }
755
- const ge = {
781
+ const Ce = {
756
782
  ArcoVue: {
757
783
  getRuntimeField(r) {
758
784
  return {
759
- field: M(r)
785
+ field: U(r)
760
786
  };
761
787
  },
762
788
  getRuntimeRequired(r) {
@@ -806,7 +832,7 @@ const ge = {
806
832
  },
807
833
  validateForm(r) {
808
834
  return new Promise((e, t) => {
809
- r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))));
835
+ r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(w(r.runtimeCore.processor.processedModel.value))));
810
836
  });
811
837
  },
812
838
  clearValidate(r) {
@@ -816,7 +842,7 @@ const ge = {
816
842
  NutUI: {
817
843
  getRuntimeField(r) {
818
844
  return {
819
- prop: M(r)
845
+ prop: U(r)
820
846
  };
821
847
  },
822
848
  getRuntimeRequired(r) {
@@ -871,7 +897,7 @@ const ge = {
871
897
  valid: s,
872
898
  errors: i
873
899
  }) => {
874
- s ? e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))) : t(i);
900
+ s ? e(r.cleanFallbackFields(w(r.runtimeCore.processor.processedModel.value))) : t(i);
875
901
  });
876
902
  });
877
903
  },
@@ -882,7 +908,7 @@ const ge = {
882
908
  NaiveUI: {
883
909
  getRuntimeField(r) {
884
910
  return {
885
- path: M(r)
911
+ path: U(r)
886
912
  };
887
913
  },
888
914
  getRuntimeRequired(r) {
@@ -935,14 +961,14 @@ const ge = {
935
961
  },
936
962
  validateForm(r) {
937
963
  return new Promise((e, t) => {
938
- r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(R(r.runtimeCore.processor.processedModel.value))));
964
+ r.runtimeCore.formRef.value.validate((s) => s ? t(s) : e(r.cleanFallbackFields(w(r.runtimeCore.processor.processedModel.value))));
939
965
  });
940
966
  },
941
967
  clearValidate(r) {
942
968
  r.formRef.value.restoreValidation();
943
969
  }
944
970
  }
945
- }, w = class w {
971
+ }, S = class S {
946
972
  static getPlaceholderPrefixPresetByComponentName() {
947
973
  const e = {
948
974
  请选择: ["select", "tree"],
@@ -955,7 +981,7 @@ const ge = {
955
981
  return t;
956
982
  }
957
983
  };
958
- a(w, "schemaPreset", {
984
+ a(S, "schemaPreset", {
959
985
  type: {
960
986
  defaultValue: "item"
961
987
  },
@@ -998,19 +1024,19 @@ a(w, "schemaPreset", {
998
1024
  grid: {
999
1025
  default: void 0
1000
1026
  }
1001
- }), a(w, "componentPropsPreset", {
1027
+ }), a(S, "componentPropsPreset", {
1002
1028
  options: {
1003
1029
  defaultValue: []
1004
1030
  }
1005
1031
  }), // 基于基本功能提出基本预设
1006
- a(w, "placeholderPresetByComponentName", w.getPlaceholderPrefixPresetByComponentName());
1007
- let _ = w;
1008
- const P = {
1009
- ..._,
1032
+ a(S, "placeholderPresetByComponentName", S.getPlaceholderPrefixPresetByComponentName());
1033
+ let $ = S;
1034
+ const g = {
1035
+ ...$,
1010
1036
  adapters: {
1011
- ...ge
1037
+ ...Ce
1012
1038
  }
1013
- }, Fe = /* @__PURE__ */ pe({
1039
+ }, je = /* @__PURE__ */ me({
1014
1040
  props: {
1015
1041
  setup: {
1016
1042
  type: Function,
@@ -1018,41 +1044,43 @@ const P = {
1018
1044
  }
1019
1045
  },
1020
1046
  setup(r) {
1021
- const e = new Pe(r.setup);
1047
+ const e = new ge(r.setup);
1022
1048
  return () => e.exec();
1023
1049
  }
1024
1050
  });
1025
- function je(r) {
1026
- const e = new me(r);
1051
+ function Ve(r) {
1052
+ const e = new be(r);
1027
1053
  return [
1028
1054
  e.setup.bind(e),
1029
1055
  {
1030
1056
  submit: e.submit.bind(e),
1031
1057
  hydrate: e.hydrate.bind(e),
1032
- share: e.share.bind(e)
1058
+ share: e.share.bind(e),
1059
+ subscribeModel: e.subscribeModel.bind(e),
1060
+ resetModel: e.resetModel.bind(e)
1033
1061
  }
1034
1062
  ];
1035
1063
  }
1036
- function Ve(r) {
1064
+ function Se(r) {
1037
1065
  u.presets = r;
1038
1066
  }
1039
- function Ce(r, e) {
1067
+ function Ie(r, e) {
1040
1068
  return e === "native" && Object.defineProperty(r, "name", {
1041
1069
  value: `__proform_raw_${r.name}`,
1042
1070
  writable: !0
1043
1071
  }), r;
1044
1072
  }
1045
1073
  function we(r) {
1046
- return Ce(r, "native");
1074
+ return Ie(r, "native");
1047
1075
  }
1048
1076
  function Re(r) {
1049
1077
  return r.__proform_raw_object = !0, r;
1050
1078
  }
1051
1079
  export {
1052
- Fe as ProForm,
1080
+ je as ProForm,
1053
1081
  we as markNativeFunction,
1054
1082
  Re as markNativeObject,
1055
- je as useForm,
1056
- Ve as useFormPresetConfigurer,
1057
- Ce as useModifiers
1083
+ Ve as useForm,
1084
+ Se as useFormPresetConfigurer,
1085
+ Ie as useModifiers
1058
1086
  };
@@ -1,12 +1,15 @@
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;
14
+ resetModel(): void;
12
15
  }
@@ -1,11 +1,18 @@
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;
16
+ resetModel: () => any;
10
17
  }
11
18
  ];
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.15",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",