@harbor-design/proform 1.1.15 → 1.1.17
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 ie = Object.defineProperty;
|
|
2
2
|
var oe = (r, e, t) => e in r ? ie(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var a = (r, e, t) => (oe(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
import { isRef as x, watch as I, isReactive as
|
|
4
|
+
import { isRef as x, watch as I, isReactive as z, toRaw as E, nextTick as w, ref as q, reactive as ne, createVNode as p, withDirectives as Z, mergeProps as R, vShow as A, createTextVNode as le, isVNode as ae, defineComponent as ue } from "vue";
|
|
5
5
|
class l {
|
|
6
6
|
static typeChecker(e) {
|
|
7
7
|
return {}.toString.call(e);
|
|
@@ -115,7 +115,7 @@ function g(r) {
|
|
|
115
115
|
function N(r, e) {
|
|
116
116
|
return r.replace(/undefined/g, e);
|
|
117
117
|
}
|
|
118
|
-
class
|
|
118
|
+
class fe {
|
|
119
119
|
constructor(e) {
|
|
120
120
|
a(this, "runtimeCore");
|
|
121
121
|
this.formCustomization = e;
|
|
@@ -131,7 +131,7 @@ class ce {
|
|
|
131
131
|
}
|
|
132
132
|
submit() {
|
|
133
133
|
var s;
|
|
134
|
-
const e = (s =
|
|
134
|
+
const e = (s = c.presets.uiPresets[this.runtimeCore.ui]) == null ? void 0 : s.adapter, t = b.adapters[this.runtimeCore.ui];
|
|
135
135
|
return (e == null ? void 0 : e.validateForm(this)) ?? (t == null ? void 0 : t.validateForm(this));
|
|
136
136
|
}
|
|
137
137
|
hydrate(e) {
|
|
@@ -151,7 +151,7 @@ class ce {
|
|
|
151
151
|
deep: !0,
|
|
152
152
|
immediate: !0
|
|
153
153
|
}
|
|
154
|
-
) :
|
|
154
|
+
) : z(e) ? I(
|
|
155
155
|
() => e,
|
|
156
156
|
() => {
|
|
157
157
|
m(this.runtimeCore.model.value, e);
|
|
@@ -179,12 +179,12 @@ class U {
|
|
|
179
179
|
Array.from(this.effects).forEach((e) => e());
|
|
180
180
|
}
|
|
181
181
|
trackEffect(e, t = {
|
|
182
|
-
lazy: !
|
|
182
|
+
lazy: !0
|
|
183
183
|
}) {
|
|
184
184
|
return !t.lazy && e(), this.effects.add(e), () => this.effects.delete(e);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
class
|
|
187
|
+
class ce {
|
|
188
188
|
constructor(e) {
|
|
189
189
|
a(this, "runtimeCore");
|
|
190
190
|
a(this, "processedSchemas");
|
|
@@ -200,6 +200,7 @@ class fe {
|
|
|
200
200
|
a(this, "defaultValueEffect", new U());
|
|
201
201
|
a(this, "defaultValueInprogressMap", /* @__PURE__ */ new Map());
|
|
202
202
|
a(this, "baseDefaultValueFunctionsLength");
|
|
203
|
+
a(this, "isModelInitialized", !0);
|
|
203
204
|
this.runtimeCore = e, this.processedSchemas = e.schemas, this.processedModel = e.model, this.getRuntimeMeta = e.getRuntimeMeta.bind(e), I(
|
|
204
205
|
() => this.processedModel.value,
|
|
205
206
|
() => {
|
|
@@ -264,17 +265,17 @@ class fe {
|
|
|
264
265
|
}).fill(!1);
|
|
265
266
|
this.objectParser({ data: e, index: t, updater: n });
|
|
266
267
|
function n(u) {
|
|
267
|
-
const
|
|
268
|
+
const f = u.index, d = u.key, y = u.keyIndex;
|
|
268
269
|
if (l.isUndefined(u.stable))
|
|
269
270
|
return;
|
|
270
271
|
const O = i.parseStable(u.stable), C = s == null ? void 0 : s.index, v = s == null ? void 0 : s.key;
|
|
271
272
|
let P = O;
|
|
272
273
|
if (l.isProcessInprogress(P) || (o[y] = !0), s) {
|
|
273
|
-
let h = i.processedSchemas.value[C][v][
|
|
274
|
-
h && l.isObject(h) && d !== "component" && (P = m(h, P)), i.processedSchemas.value[C][v][
|
|
274
|
+
let h = i.processedSchemas.value[C][v][f][d];
|
|
275
|
+
h && l.isObject(h) && d !== "component" && (P = m(h, P)), i.processedSchemas.value[C][v][f][d] = P, i.stableUpdater(o);
|
|
275
276
|
} else {
|
|
276
|
-
let h = i.processedSchemas.value[
|
|
277
|
-
h && l.isObject(h) && d !== "component" && (P = m(h, P)), i.processedSchemas.value[
|
|
277
|
+
let h = i.processedSchemas.value[f][d];
|
|
278
|
+
h && l.isObject(h) && d !== "component" && (P = m(h, P)), i.processedSchemas.value[f][d] = P, i.stableUpdater(o);
|
|
278
279
|
}
|
|
279
280
|
}
|
|
280
281
|
}
|
|
@@ -303,25 +304,30 @@ class fe {
|
|
|
303
304
|
this.promiseFieldParser(u, n, !1);
|
|
304
305
|
} else
|
|
305
306
|
this.fieldParser(t[i], n);
|
|
306
|
-
}) : this.defaultValueEffect.trackEffect(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
(
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
this.
|
|
318
|
-
(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
307
|
+
}) : this.defaultValueEffect.trackEffect(
|
|
308
|
+
() => {
|
|
309
|
+
const u = this.schemaEffect.trackEffect(() => {
|
|
310
|
+
/\{\s*model\s*\}/.test(t[i].toString()) ? this.fieldParser(t[i], (f) => {
|
|
311
|
+
if (!f)
|
|
312
|
+
return n(f);
|
|
313
|
+
this.defaultValueInprogressMap.set(t[i], f), !l.isProcessInprogress(f) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
|
|
314
|
+
this.defaultValueInprogressMap.values()
|
|
315
|
+
).every((d) => !d.includes("undefined")) ? (n(f), this.defaultValueEffect.clearEffects(), w(() => {
|
|
316
|
+
u();
|
|
317
|
+
})) : n(f);
|
|
318
|
+
}) : this.fieldParser(t[i], (f) => {
|
|
319
|
+
this.defaultValueInprogressMap.set(t[i], f), !l.isProcessInprogress(f) && this.defaultValueInprogressMap.size === this.baseDefaultValueFunctionsLength && Array.from(
|
|
320
|
+
this.defaultValueInprogressMap.values()
|
|
321
|
+
).every((d) => !d.includes("undefined")) ? (n(f), this.defaultValueEffect.clearEffects(), w(() => {
|
|
322
|
+
u();
|
|
323
|
+
})) : n(f);
|
|
324
|
+
});
|
|
322
325
|
});
|
|
323
|
-
}
|
|
324
|
-
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
lazy: !1
|
|
329
|
+
}
|
|
330
|
+
) : i === "component" || i === "slots" || i === "runtime" ? this.promiseFieldParser(t[i], n, !1) : this.fieldParser(t[i], n);
|
|
325
331
|
}
|
|
326
332
|
});
|
|
327
333
|
}
|
|
@@ -363,7 +369,7 @@ class fe {
|
|
|
363
369
|
immediate: !0,
|
|
364
370
|
deep: !0
|
|
365
371
|
}
|
|
366
|
-
) :
|
|
372
|
+
) : z(e) ? I(
|
|
367
373
|
() => e,
|
|
368
374
|
() => {
|
|
369
375
|
l.isUndefined(e) || (s && l.isObject(e) ? this.objectParser({
|
|
@@ -390,27 +396,27 @@ class fe {
|
|
|
390
396
|
this.createModel(s, t[e.field][0]);
|
|
391
397
|
})), l.isGroupSchema(e) && e.children.forEach((s) => {
|
|
392
398
|
this.createModel(s, t);
|
|
393
|
-
}), l.isItemSchema(e) && (t[e.field] = e.defaultValue);
|
|
399
|
+
}), l.isItemSchema(e) && ("defaultValue" in e ? t[e.field] = e.defaultValue : t[e.field] || (t[e.field] = void 0));
|
|
394
400
|
}
|
|
395
401
|
}
|
|
396
402
|
class F {
|
|
397
403
|
static getFormContainer({ ui: e } = {}) {
|
|
398
|
-
return
|
|
404
|
+
return c.presets.uiPresets[e ?? c.presets.ui].container.Form;
|
|
399
405
|
}
|
|
400
406
|
static getFormItemContainer({ ui: e } = {}) {
|
|
401
|
-
return
|
|
407
|
+
return c.presets.uiPresets[e ?? c.presets.ui].container.FormItem;
|
|
402
408
|
}
|
|
403
409
|
static getItemContainer({ ui: e } = {}) {
|
|
404
|
-
return
|
|
410
|
+
return c.presets.uiPresets[e ?? c.presets.ui].container.Item;
|
|
405
411
|
}
|
|
406
412
|
static getGroupContainer({ ui: e } = {}) {
|
|
407
|
-
return
|
|
413
|
+
return c.presets.uiPresets[e ?? c.presets.ui].container.Group;
|
|
408
414
|
}
|
|
409
415
|
static getListContainer({ ui: e } = {}) {
|
|
410
|
-
return
|
|
416
|
+
return c.presets.uiPresets[e ?? c.presets.ui].container.List;
|
|
411
417
|
}
|
|
412
418
|
static getListItemContainer({ ui: e } = {}) {
|
|
413
|
-
return
|
|
419
|
+
return c.presets.uiPresets[e ?? c.presets.ui].container.ListItem;
|
|
414
420
|
}
|
|
415
421
|
}
|
|
416
422
|
class de {
|
|
@@ -419,27 +425,27 @@ class de {
|
|
|
419
425
|
}
|
|
420
426
|
getRuntimeField(e) {
|
|
421
427
|
var i;
|
|
422
|
-
const t = (i =
|
|
428
|
+
const t = (i = c.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = b.adapters[this.ui];
|
|
423
429
|
return (t == null ? void 0 : t.getRuntimeField(e)) ?? (s == null ? void 0 : s.getRuntimeField(e));
|
|
424
430
|
}
|
|
425
431
|
getRuntimeRequired(e) {
|
|
426
432
|
var i;
|
|
427
|
-
const t = (i =
|
|
433
|
+
const t = (i = c.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = b.adapters[this.ui];
|
|
428
434
|
return (t == null ? void 0 : t.getRuntimeRequired(e)) ?? (s == null ? void 0 : s.getRuntimeRequired(e));
|
|
429
435
|
}
|
|
430
436
|
getFormModelPropName() {
|
|
431
437
|
var s;
|
|
432
|
-
const e = (s =
|
|
438
|
+
const e = (s = c.presets.uiPresets[this.ui]) == null ? void 0 : s.adapter, t = b.adapters[this.ui];
|
|
433
439
|
return (e == null ? void 0 : e.getFormModelPropName()) ?? (t == null ? void 0 : t.getFormModelPropName());
|
|
434
440
|
}
|
|
435
441
|
formComponentRenderer(e) {
|
|
436
442
|
var i;
|
|
437
|
-
const t = (i =
|
|
443
|
+
const t = (i = c.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = b.adapters[this.ui];
|
|
438
444
|
return (t == null ? void 0 : t.formComponentRenderer(e)) ?? (s == null ? void 0 : s.formComponentRenderer(e));
|
|
439
445
|
}
|
|
440
446
|
clearValidate(e) {
|
|
441
447
|
var i;
|
|
442
|
-
const t = (i =
|
|
448
|
+
const t = (i = c.presets.uiPresets[this.ui]) == null ? void 0 : i.adapter, s = b.adapters[this.ui];
|
|
443
449
|
return (t == null ? void 0 : t.clearValidate(e)) ?? (s == null ? void 0 : s.clearValidate(e));
|
|
444
450
|
}
|
|
445
451
|
}
|
|
@@ -464,9 +470,9 @@ class he {
|
|
|
464
470
|
props: {},
|
|
465
471
|
slots: {}
|
|
466
472
|
});
|
|
467
|
-
this.setup = e, this.processor = new
|
|
473
|
+
this.setup = e, this.processor = new ce(this);
|
|
468
474
|
const t = this.setup(this);
|
|
469
|
-
if (this.ui = t.ui ??
|
|
475
|
+
if (this.ui = t.ui ?? c.presets.ui, this.runtimeAdapter = new de(this.ui), x(t.schemas)) {
|
|
470
476
|
const s = I(() => t.schemas, () => {
|
|
471
477
|
this.processor.parseSchemas(t.schemas.value), w(() => {
|
|
472
478
|
s();
|
|
@@ -474,7 +480,7 @@ class he {
|
|
|
474
480
|
}, {
|
|
475
481
|
deep: !0
|
|
476
482
|
});
|
|
477
|
-
} else if (
|
|
483
|
+
} else if (z(t.schemas)) {
|
|
478
484
|
const s = I(() => t.schemas, () => {
|
|
479
485
|
this.processor.parseSchemas(t.schemas), w(() => {
|
|
480
486
|
s();
|
|
@@ -487,20 +493,21 @@ class he {
|
|
|
487
493
|
}
|
|
488
494
|
getRuntimeMeta() {
|
|
489
495
|
return {
|
|
490
|
-
model: E(g(this.model.value))
|
|
496
|
+
model: E(g(this.model.value)),
|
|
497
|
+
reactiveModel: this.model.value
|
|
491
498
|
};
|
|
492
499
|
}
|
|
493
500
|
runtimeItemProcessor(e, t, s = this.model.value, i) {
|
|
494
|
-
var
|
|
501
|
+
var k, $, _, B, D, G, T, K, W, H, J, Q, X;
|
|
495
502
|
const o = E(e.component);
|
|
496
503
|
if (!o)
|
|
497
504
|
return;
|
|
498
|
-
m(this.globalNativeFormOverride.props, ($ = (
|
|
505
|
+
m(this.globalNativeFormOverride.props, ($ = (k = e.native) == null ? void 0 : k.props) == null ? void 0 : $.Form), m(this.globalNativeFormOverride.slots, (B = (_ = e.native) == null ? void 0 : _.slots) == null ? void 0 : B.Form);
|
|
499
506
|
const n = m(g((G = (D = this.native) == null ? void 0 : D.slots) == null ? void 0 : G.FormItem) ?? {}, (K = (T = e.native) == null ? void 0 : T.slots) == null ? void 0 : K.FormItem), u = {
|
|
500
507
|
display: "grid",
|
|
501
508
|
gridColumn: "1 / -1",
|
|
502
509
|
...e.grid
|
|
503
|
-
},
|
|
510
|
+
}, f = m(g((H = (W = this.native) == null ? void 0 : W.props) == null ? void 0 : H.FormItem) ?? {}, (Q = (J = e.native) == null ? void 0 : J.props) == null ? void 0 : Q.FormItem), d = this.runtimeAdapter.getRuntimeField({
|
|
504
511
|
schema: e,
|
|
505
512
|
parentSchema: i,
|
|
506
513
|
index: t
|
|
@@ -524,7 +531,7 @@ class he {
|
|
|
524
531
|
style: u
|
|
525
532
|
}, [p(te, null, {
|
|
526
533
|
default() {
|
|
527
|
-
return Z(p(se, R(
|
|
534
|
+
return Z(p(se, R(f, {
|
|
528
535
|
label: `${h}:`
|
|
529
536
|
}, d, ee), {
|
|
530
537
|
default() {
|
|
@@ -584,13 +591,13 @@ class he {
|
|
|
584
591
|
default() {
|
|
585
592
|
return s.model.value[e.field].map((n, u) => p(o, null, {
|
|
586
593
|
default() {
|
|
587
|
-
return e.children.map((
|
|
594
|
+
return e.children.map((f) => s.runtimeItemProcessor(f, u, n, e));
|
|
588
595
|
},
|
|
589
596
|
delete({
|
|
590
|
-
container:
|
|
597
|
+
container: f
|
|
591
598
|
} = {}) {
|
|
592
599
|
var y;
|
|
593
|
-
let d =
|
|
600
|
+
let d = f ?? p("button", null, null);
|
|
594
601
|
return Z(p(d, {
|
|
595
602
|
onClick: () => s.deleteListItem(e, u)
|
|
596
603
|
}, null), [[A, ((y = s.model.value[e.field]) == null ? void 0 : y.length) > 1]]);
|
|
@@ -611,13 +618,13 @@ class he {
|
|
|
611
618
|
return e.map((t) => (t.type || (t.type = "item"), this.processorBySchemaType[t.type](t)));
|
|
612
619
|
}
|
|
613
620
|
exec() {
|
|
614
|
-
var u,
|
|
621
|
+
var u, f, d, y;
|
|
615
622
|
const e = {
|
|
616
623
|
display: "grid",
|
|
617
624
|
gridColumn: "1 / -1",
|
|
618
625
|
gridAutoColumns: "1fr",
|
|
619
626
|
...this.grid
|
|
620
|
-
}, t = this, s = m(g((
|
|
627
|
+
}, t = this, s = m(g((f = (u = this.native) == null ? void 0 : u.props) == null ? void 0 : f.Form) ?? {}, this.globalNativeFormOverride.props), i = m(g((y = (d = this.native) == null ? void 0 : d.slots) == null ? void 0 : y.Form) ?? {}, this.globalNativeFormOverride.slots), o = F.getFormContainer(this), n = this.runtimeAdapter.getFormModelPropName();
|
|
621
628
|
return p(o, R(s, {
|
|
622
629
|
ref: this.formRef
|
|
623
630
|
}, {
|
|
@@ -632,9 +639,9 @@ class he {
|
|
|
632
639
|
});
|
|
633
640
|
}
|
|
634
641
|
}
|
|
635
|
-
class
|
|
642
|
+
class c {
|
|
636
643
|
}
|
|
637
|
-
a(
|
|
644
|
+
a(c, "presets");
|
|
638
645
|
function M({
|
|
639
646
|
parentSchema: r,
|
|
640
647
|
schema: e,
|
|
@@ -881,7 +888,7 @@ const b = {
|
|
|
881
888
|
}
|
|
882
889
|
});
|
|
883
890
|
function ve(r) {
|
|
884
|
-
const e = new
|
|
891
|
+
const e = new fe(r);
|
|
885
892
|
return [
|
|
886
893
|
e.setup.bind(e),
|
|
887
894
|
{
|
|
@@ -891,7 +898,7 @@ function ve(r) {
|
|
|
891
898
|
];
|
|
892
899
|
}
|
|
893
900
|
function ge(r) {
|
|
894
|
-
|
|
901
|
+
c.presets = r;
|
|
895
902
|
}
|
|
896
903
|
function Ce(r, e) {
|
|
897
904
|
return e === "raw" && Object.defineProperty(r, "name", {
|
|
@@ -21,6 +21,7 @@ export default class Processor {
|
|
|
21
21
|
defaultValueEffect: Effect;
|
|
22
22
|
defaultValueInprogressMap: Map<any, any>;
|
|
23
23
|
baseDefaultValueFunctionsLength: number;
|
|
24
|
+
isModelInitialized: boolean;
|
|
24
25
|
constructor(runtimeCore: RuntimeCore);
|
|
25
26
|
parse<T extends object = any>(data: T[], parentMeta?: AnyObject): void;
|
|
26
27
|
initSchemas(schemas: AnyObject[]): AnyObject[];
|
|
@@ -23,6 +23,7 @@ export default class RuntimeCore {
|
|
|
23
23
|
constructor(setup: Setup);
|
|
24
24
|
getRuntimeMeta(): {
|
|
25
25
|
model: AnyObject;
|
|
26
|
+
reactiveModel: AnyObject;
|
|
26
27
|
};
|
|
27
28
|
runtimeItemProcessor(schema: ItemSchema, index?: number, baseModel?: AnyObject, parentSchema?: ListSchema): JSX.Element | undefined;
|
|
28
29
|
runtimeGroupProcessor(schema: GroupSchema): JSX.Element;
|