@piying/view-angular-core 2.4.6 → 2.5.1
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.
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { signal, computed, InjectionToken, effect, inject, Injector, untracked, DestroyRef, linkedSignal, isSignal } from '@angular/core';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
|
+
import { summarize } from 'valibot';
|
|
3
4
|
import { isObservable, BehaviorSubject, Subject, tap, pipe, shareReplay, map, combineLatest, startWith, skip } from 'rxjs';
|
|
4
5
|
import rfdc from 'rfdc';
|
|
5
6
|
import { deepEqual } from 'fast-equals';
|
|
6
7
|
import { createRawConfig, defineType, BaseSchemaHandle, convertSchema, convertCore } from '@piying/valibot-visit';
|
|
7
8
|
export { asControl, asVirtualGroup, changeObject, condition, getDefaults, getSchemaByIssuePath, getSchemaMetadata } from '@piying/valibot-visit';
|
|
8
9
|
import clsx from 'clsx';
|
|
10
|
+
import { pick } from 'es-toolkit';
|
|
9
11
|
|
|
10
12
|
function isPromise(obj) {
|
|
11
13
|
return !!obj && typeof obj.then === 'function';
|
|
@@ -111,6 +113,15 @@ function toObservable(listen, source, options) {
|
|
|
111
113
|
return subject.asObservable();
|
|
112
114
|
}
|
|
113
115
|
|
|
116
|
+
function computedWithPrev(computation, options) {
|
|
117
|
+
let previous;
|
|
118
|
+
return computed(() => {
|
|
119
|
+
const newValue = computation(previous);
|
|
120
|
+
previous = newValue;
|
|
121
|
+
return newValue;
|
|
122
|
+
}, options);
|
|
123
|
+
}
|
|
124
|
+
|
|
114
125
|
function shortCircuitTrue(value) {
|
|
115
126
|
return value;
|
|
116
127
|
}
|
|
@@ -130,8 +141,12 @@ class AbstractControl {
|
|
|
130
141
|
(!this.selfDisabled$$() ||
|
|
131
142
|
(this.selfDisabled$$() && this.config$().disabledValue === 'reserve')));
|
|
132
143
|
injector;
|
|
144
|
+
originValue$$;
|
|
133
145
|
/** model的value */
|
|
134
|
-
value
|
|
146
|
+
value$$ = computedWithPrev((value) => {
|
|
147
|
+
const result = this.#schemaCheck$$();
|
|
148
|
+
return result.success ? result.output : value;
|
|
149
|
+
});
|
|
135
150
|
/** 已激活的子级,用于校验获得返回值之类 */
|
|
136
151
|
activatedChildren$$;
|
|
137
152
|
/** 通用的子级,用于查询之类 */
|
|
@@ -180,22 +195,46 @@ class AbstractControl {
|
|
|
180
195
|
if (disabled) {
|
|
181
196
|
return undefined;
|
|
182
197
|
}
|
|
198
|
+
// 请求同级
|
|
183
199
|
this.resetIndex$();
|
|
184
|
-
this.
|
|
185
|
-
const
|
|
200
|
+
this.originValue$$();
|
|
201
|
+
const childrenResult = this.reduceChildren([], (child, value, key) => {
|
|
202
|
+
if ((!child.selfDisabled$$() ||
|
|
203
|
+
(child.selfDisabled$$() &&
|
|
204
|
+
child.config$().disabledValue === 'reserve')) &&
|
|
205
|
+
child.errors) {
|
|
206
|
+
value.push({
|
|
207
|
+
kind: 'descendant',
|
|
208
|
+
key: key,
|
|
209
|
+
metadata: child.errors,
|
|
210
|
+
field: child,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
return value;
|
|
214
|
+
});
|
|
215
|
+
if (childrenResult.length) {
|
|
216
|
+
return childrenResult;
|
|
217
|
+
}
|
|
218
|
+
const result = this.#validators$$().flatMap((item) => {
|
|
186
219
|
const result = untracked(() => item(this));
|
|
187
|
-
if (result) {
|
|
188
|
-
|
|
220
|
+
if (!result) {
|
|
221
|
+
return [];
|
|
189
222
|
}
|
|
190
|
-
|
|
191
|
-
|
|
223
|
+
if (Array.isArray(result)) {
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
226
|
+
return Object.entries(result).map(([key, value]) => ({
|
|
227
|
+
kind: key,
|
|
228
|
+
metadata: value,
|
|
229
|
+
}));
|
|
230
|
+
});
|
|
192
231
|
const schemaResult = this.#schemaCheck$$();
|
|
193
232
|
if (!schemaResult.success) {
|
|
194
|
-
return
|
|
233
|
+
return result.concat([
|
|
234
|
+
{ kind: 'valibot', metadata: schemaResult.issues },
|
|
235
|
+
]);
|
|
195
236
|
}
|
|
196
|
-
return
|
|
197
|
-
? result
|
|
198
|
-
: undefined;
|
|
237
|
+
return result.length ? result : undefined;
|
|
199
238
|
}, { equal: () => false }));
|
|
200
239
|
asyncErrorRes$$ = computed(() => {
|
|
201
240
|
const result = this.#asyncValidators$$();
|
|
@@ -203,24 +242,34 @@ class AbstractControl {
|
|
|
203
242
|
return undefined;
|
|
204
243
|
}
|
|
205
244
|
this.resetIndex$();
|
|
206
|
-
this.
|
|
245
|
+
this.originValue$$();
|
|
207
246
|
const dataList = result.map((item) => untracked(() => asyncValidatorToSignal(item(this))));
|
|
208
247
|
return computed(() => {
|
|
209
248
|
const params = dataList.map((item) => item());
|
|
210
249
|
let pendingCount = 0;
|
|
211
|
-
const errorResult = params.
|
|
250
|
+
const errorResult = params.flatMap((item) => {
|
|
212
251
|
if (item === ValidatorPending) {
|
|
213
252
|
pendingCount++;
|
|
214
|
-
return
|
|
253
|
+
return [];
|
|
215
254
|
}
|
|
216
255
|
else if ('value' in item) {
|
|
217
|
-
|
|
256
|
+
const result = item.value;
|
|
257
|
+
if (!result) {
|
|
258
|
+
return [];
|
|
259
|
+
}
|
|
260
|
+
if (Array.isArray(result)) {
|
|
261
|
+
return result;
|
|
262
|
+
}
|
|
263
|
+
return Object.entries(result).map(([key, value]) => ({
|
|
264
|
+
kind: key,
|
|
265
|
+
metadata: value,
|
|
266
|
+
}));
|
|
218
267
|
}
|
|
219
268
|
else {
|
|
220
|
-
return {
|
|
269
|
+
return { kind: 'error', metadata: item.error };
|
|
221
270
|
}
|
|
222
|
-
}
|
|
223
|
-
if (!
|
|
271
|
+
});
|
|
272
|
+
if (!errorResult.length) {
|
|
224
273
|
if (pendingCount) {
|
|
225
274
|
return ValidatorPending;
|
|
226
275
|
}
|
|
@@ -259,7 +308,7 @@ class AbstractControl {
|
|
|
259
308
|
return PENDING;
|
|
260
309
|
}
|
|
261
310
|
if (syncError && asyncError) {
|
|
262
|
-
return
|
|
311
|
+
return [...syncError, ...asyncError];
|
|
263
312
|
}
|
|
264
313
|
else if (syncError || asyncError) {
|
|
265
314
|
return syncError || asyncError;
|
|
@@ -289,7 +338,7 @@ class AbstractControl {
|
|
|
289
338
|
this.schemaParser = v.safeParser(rawSchema);
|
|
290
339
|
this.context = this.injector.get(PI_CONTEXT_TOKEN);
|
|
291
340
|
}
|
|
292
|
-
#schemaCheck$$ = computed(() => this.schemaParser(this.
|
|
341
|
+
#schemaCheck$$ = computed(() => this.schemaParser(this.originValue$$()));
|
|
293
342
|
setParent(parent) {
|
|
294
343
|
this._parent = parent;
|
|
295
344
|
}
|
|
@@ -366,7 +415,13 @@ class AbstractControl {
|
|
|
366
415
|
getInitValue(value) {
|
|
367
416
|
return value ?? this.config$().defaultValue;
|
|
368
417
|
}
|
|
369
|
-
|
|
418
|
+
#transformer$$ = computed(() => this.config$().transfomer);
|
|
419
|
+
transformToModel(value, control) {
|
|
420
|
+
if (this.#transformer$$()) {
|
|
421
|
+
value = this.#transformer$$()?.toModel?.(value, control) ?? value;
|
|
422
|
+
}
|
|
423
|
+
return value;
|
|
424
|
+
}
|
|
370
425
|
/** @internal */
|
|
371
426
|
updateInitValue(value) { }
|
|
372
427
|
find(name) {
|
|
@@ -380,14 +435,18 @@ class AbstractControl {
|
|
|
380
435
|
return initialValue;
|
|
381
436
|
}
|
|
382
437
|
let value = initialValue;
|
|
383
|
-
|
|
384
|
-
|
|
438
|
+
const list = Object.entries(childrenMap);
|
|
439
|
+
const isArray = Array.isArray(childrenMap);
|
|
440
|
+
for (let index = 0; index < list.length; index++) {
|
|
441
|
+
if (!list[index][1]) {
|
|
385
442
|
continue;
|
|
386
443
|
}
|
|
444
|
+
const key = isArray ? index : list[index][0];
|
|
445
|
+
const item = list[index][1];
|
|
387
446
|
if (shortCircuit?.(value)) {
|
|
388
447
|
break;
|
|
389
448
|
}
|
|
390
|
-
value = fn(
|
|
449
|
+
value = fn(item, value, key);
|
|
391
450
|
}
|
|
392
451
|
return value;
|
|
393
452
|
}
|
|
@@ -436,7 +495,7 @@ class AbstractControl {
|
|
|
436
495
|
/** 仅触发 updateOn: submit 时使用 */
|
|
437
496
|
emitSubmit() {
|
|
438
497
|
if (this.children$$) {
|
|
439
|
-
this.children$$().forEach((child) => {
|
|
498
|
+
Object.values(this.children$$()).forEach((child) => {
|
|
440
499
|
if (!child) {
|
|
441
500
|
return;
|
|
442
501
|
}
|
|
@@ -498,7 +557,7 @@ class FieldGroupbase extends AbstractControl {
|
|
|
498
557
|
});
|
|
499
558
|
}
|
|
500
559
|
updateValue(value) {
|
|
501
|
-
if (deepEqual(value, this.value$$())) {
|
|
560
|
+
if (this.valid && deepEqual(value, this.value$$())) {
|
|
502
561
|
return;
|
|
503
562
|
}
|
|
504
563
|
if (this.isUnChanged()) {
|
|
@@ -544,9 +603,9 @@ class FieldGroup extends FieldGroupbase {
|
|
|
544
603
|
const returnResult = Object.keys(result).length
|
|
545
604
|
? result
|
|
546
605
|
: this.emptyValue$$();
|
|
547
|
-
return this.
|
|
606
|
+
return this.transformToModel(returnResult, this);
|
|
548
607
|
}
|
|
549
|
-
|
|
608
|
+
originValue$$ = computed(() => {
|
|
550
609
|
if (this.updateOn$$() === 'submit') {
|
|
551
610
|
this.submitIndex$();
|
|
552
611
|
return untracked(() => this.#childUpdate());
|
|
@@ -562,7 +621,7 @@ class FieldGroup extends FieldGroupbase {
|
|
|
562
621
|
get controls() {
|
|
563
622
|
return this.#controls$$();
|
|
564
623
|
}
|
|
565
|
-
children$$ = computed(() =>
|
|
624
|
+
children$$ = computed(() => this.#controls$$());
|
|
566
625
|
removeRestControl(key) {
|
|
567
626
|
if (!this.resetControls$()[key]) {
|
|
568
627
|
return;
|
|
@@ -632,7 +691,7 @@ class FieldControl extends AbstractControl {
|
|
|
632
691
|
return this.modelValueToViewValueOrigin$$();
|
|
633
692
|
}, { equal: () => false });
|
|
634
693
|
/** modelValue + viewValue => modelValue */
|
|
635
|
-
|
|
694
|
+
originValue$$ = signal(undefined);
|
|
636
695
|
reset(formState = this.config$().defaultValue) {
|
|
637
696
|
this.markAsPristine();
|
|
638
697
|
this.markAsUntouched();
|
|
@@ -654,24 +713,7 @@ class FieldControl extends AbstractControl {
|
|
|
654
713
|
#viewValueChange(value) {
|
|
655
714
|
this.markAllAsDirty();
|
|
656
715
|
this.#viewIndex++;
|
|
657
|
-
|
|
658
|
-
const originValue = toModel ? toModel(value, this) : value;
|
|
659
|
-
const transfomered = this.schemaParser(originValue);
|
|
660
|
-
if (transfomered.success) {
|
|
661
|
-
this.value$$.set(transfomered.output);
|
|
662
|
-
this.syncError$.update((data) => {
|
|
663
|
-
if (data) {
|
|
664
|
-
delete data['valibot'];
|
|
665
|
-
}
|
|
666
|
-
return data && Object.keys(data).length ? data : undefined;
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
else {
|
|
670
|
-
this.syncError$.update((data) => ({
|
|
671
|
-
...data,
|
|
672
|
-
valibot: transfomered.issues,
|
|
673
|
-
}));
|
|
674
|
-
}
|
|
716
|
+
this.originValue$$.set(this.transformToModel(value, this));
|
|
675
717
|
}
|
|
676
718
|
/** view变更 */
|
|
677
719
|
viewValueChange(value) {
|
|
@@ -686,17 +728,17 @@ class FieldControl extends AbstractControl {
|
|
|
686
728
|
if (this.isUnChanged() || force) {
|
|
687
729
|
value ??= this.getInitValue(value);
|
|
688
730
|
this.modelValue$.set(value);
|
|
689
|
-
this.
|
|
731
|
+
this.originValue$$.set(value);
|
|
690
732
|
this.#viewIndex++;
|
|
691
733
|
this.viewIndex$.set(this.#viewIndex);
|
|
692
734
|
this.resetIndex$.update((a) => a + 1);
|
|
693
735
|
return;
|
|
694
736
|
}
|
|
695
|
-
if (deepEqual(value, this.value$$())) {
|
|
737
|
+
if (this.valid && deepEqual(value, this.value$$())) {
|
|
696
738
|
return;
|
|
697
739
|
}
|
|
698
740
|
this.modelValue$.set(value);
|
|
699
|
-
this.
|
|
741
|
+
this.originValue$$.set(value);
|
|
700
742
|
this.viewIndex$.set(this.#viewIndex);
|
|
701
743
|
}
|
|
702
744
|
emitSubmit() {
|
|
@@ -709,7 +751,7 @@ class FieldControl extends AbstractControl {
|
|
|
709
751
|
updateInitValue(value) {
|
|
710
752
|
const initValue = this.getInitValue(value);
|
|
711
753
|
this.modelValue$.set(initValue);
|
|
712
|
-
this.
|
|
754
|
+
this.originValue$$.set(value);
|
|
713
755
|
}
|
|
714
756
|
}
|
|
715
757
|
|
|
@@ -733,9 +775,9 @@ class FieldArray extends FieldGroupbase {
|
|
|
733
775
|
});
|
|
734
776
|
list = [...list, ...(this.resetValue$() ?? [])];
|
|
735
777
|
const returnResult = list.length === 0 ? this.emptyValue$$() : list;
|
|
736
|
-
return this.
|
|
778
|
+
return this.transformToModel(returnResult, this);
|
|
737
779
|
}
|
|
738
|
-
|
|
780
|
+
originValue$$ = computed(() => {
|
|
739
781
|
if (this.updateOn$$() === 'submit') {
|
|
740
782
|
this.submitIndex$();
|
|
741
783
|
return untracked(() => this.#childUpdate());
|
|
@@ -808,9 +850,9 @@ class FieldLogicGroup extends FieldArray {
|
|
|
808
850
|
activateControls$ = signal(undefined);
|
|
809
851
|
#childUpdate() {
|
|
810
852
|
const returnResult = this.getValue(false);
|
|
811
|
-
return this.
|
|
853
|
+
return this.transformToModel(returnResult, this);
|
|
812
854
|
}
|
|
813
|
-
|
|
855
|
+
originValue$$ = computed(() => {
|
|
814
856
|
if (this.updateOn$$() === 'submit') {
|
|
815
857
|
this.submitIndex$();
|
|
816
858
|
return untracked(() => this.#childUpdate());
|
|
@@ -856,7 +898,7 @@ class FieldLogicGroup extends FieldArray {
|
|
|
856
898
|
return this.getValue(true);
|
|
857
899
|
}
|
|
858
900
|
updateValue(value) {
|
|
859
|
-
if (deepEqual(value, this.value$$())) {
|
|
901
|
+
if (this.valid && deepEqual(value, this.value$$())) {
|
|
860
902
|
return;
|
|
861
903
|
}
|
|
862
904
|
if (this.isUnChanged()) {
|
|
@@ -932,7 +974,7 @@ key, formConfig$$, isRoot, injector) {
|
|
|
932
974
|
}
|
|
933
975
|
let control;
|
|
934
976
|
if (isRoot) {
|
|
935
|
-
control = new FieldClass(field.sourceSchema, injector);
|
|
977
|
+
control = new FieldClass(field.checkSchema ?? field.sourceSchema, injector);
|
|
936
978
|
if (isFieldLogicGroup(control)) {
|
|
937
979
|
control.type.set(field.isLogicAnd ? 'and' : 'or');
|
|
938
980
|
}
|
|
@@ -941,7 +983,7 @@ key, formConfig$$, isRoot, injector) {
|
|
|
941
983
|
else {
|
|
942
984
|
control = parentForm.get([key]);
|
|
943
985
|
if (!control) {
|
|
944
|
-
control = new FieldClass(field.sourceSchema, injector);
|
|
986
|
+
control = new FieldClass(field.checkSchema ?? field.sourceSchema, injector);
|
|
945
987
|
if (isFieldLogicGroup(control)) {
|
|
946
988
|
control.type.set(field.isLogicAnd ? 'and' : 'or');
|
|
947
989
|
}
|
|
@@ -1127,26 +1169,52 @@ function initListen(input, control, injector, fn) {
|
|
|
1127
1169
|
}, { injector });
|
|
1128
1170
|
}
|
|
1129
1171
|
|
|
1130
|
-
function
|
|
1131
|
-
if (
|
|
1172
|
+
function errorItem(item, prefixList, list) {
|
|
1173
|
+
if (item.kind === 'descendant') {
|
|
1174
|
+
const item2 = item;
|
|
1175
|
+
item2.metadata.forEach((child) => {
|
|
1176
|
+
errorItem(child, prefixList.slice().concat(item2), list);
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
else {
|
|
1180
|
+
list.push({
|
|
1181
|
+
debugPathList: prefixList.map((item) => {
|
|
1182
|
+
const parentField = item.field.parent;
|
|
1183
|
+
if (parentField instanceof FieldLogicGroup) {
|
|
1184
|
+
return parentField.type() === 'and'
|
|
1185
|
+
? `[∧${item.key}]`
|
|
1186
|
+
: `[∨${item.key}]`;
|
|
1187
|
+
}
|
|
1188
|
+
else if (parentField instanceof FieldArray) {
|
|
1189
|
+
return `[${item.key}]`;
|
|
1190
|
+
}
|
|
1191
|
+
else {
|
|
1192
|
+
return `${item.key}`;
|
|
1193
|
+
}
|
|
1194
|
+
}),
|
|
1195
|
+
queryPathList: prefixList.map((item) => item.key),
|
|
1196
|
+
fieldList: prefixList.map((item) => item.field),
|
|
1197
|
+
item: item,
|
|
1198
|
+
get valibotIssueSummary() {
|
|
1199
|
+
if (item.kind === 'valibot') {
|
|
1200
|
+
return summarize(item.metadata);
|
|
1201
|
+
}
|
|
1202
|
+
return undefined;
|
|
1203
|
+
},
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
function errorSummary(control) {
|
|
1208
|
+
if (!control?.errors) {
|
|
1132
1209
|
return [];
|
|
1133
1210
|
}
|
|
1134
1211
|
const list = [];
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1137
|
-
const control = controlList.shift();
|
|
1138
|
-
if (control.valid) {
|
|
1139
|
-
continue;
|
|
1140
|
-
}
|
|
1141
|
-
list.push({ control, errors: control.errors });
|
|
1142
|
-
if (isFieldArray(control) || isFieldGroup(control)) {
|
|
1143
|
-
(control.activatedChildren$$ ?? control.children$$)().forEach((control) => {
|
|
1144
|
-
controlList.push(control);
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1212
|
+
for (const item of control.errors) {
|
|
1213
|
+
errorItem(item, [], list);
|
|
1147
1214
|
}
|
|
1148
1215
|
return list;
|
|
1149
1216
|
}
|
|
1217
|
+
const getDeepError = errorSummary;
|
|
1150
1218
|
|
|
1151
1219
|
const DefaultOptions$1 = { autoDestroy: true };
|
|
1152
1220
|
/** set输入,()输出的是管道后的值, */
|
|
@@ -1768,6 +1836,13 @@ class FormBuilder {
|
|
|
1768
1836
|
}
|
|
1769
1837
|
_a = FormBuilder;
|
|
1770
1838
|
|
|
1839
|
+
function findError(list, key) {
|
|
1840
|
+
if (!list) {
|
|
1841
|
+
return undefined;
|
|
1842
|
+
}
|
|
1843
|
+
return list.find((item) => item.kind === key);
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1771
1846
|
function layout(value) {
|
|
1772
1847
|
return {
|
|
1773
1848
|
kind: 'metadata',
|
|
@@ -2421,6 +2496,62 @@ const actions = {
|
|
|
2421
2496
|
},
|
|
2422
2497
|
};
|
|
2423
2498
|
|
|
2499
|
+
const AnyDefine = v.any();
|
|
2500
|
+
function AnyDefault(input, schemahandle) {
|
|
2501
|
+
return schemahandle.undefinedable
|
|
2502
|
+
? v.optional(input)
|
|
2503
|
+
: schemahandle.nullable
|
|
2504
|
+
? v.nullable(input)
|
|
2505
|
+
: input;
|
|
2506
|
+
}
|
|
2507
|
+
const checkOverride = {
|
|
2508
|
+
logicGroup: (schemahandle) => v.pipe(AnyDefault(v.pipe(AnyDefine, v.check(Boolean)), schemahandle)),
|
|
2509
|
+
array: (schemahandle) => {
|
|
2510
|
+
const source = schemahandle.coreSchema;
|
|
2511
|
+
const length = source &&
|
|
2512
|
+
schemahandle.formConfig.groupMode &&
|
|
2513
|
+
schemahandle.formConfig.groupMode !== 'reset'
|
|
2514
|
+
? source.items.length
|
|
2515
|
+
: undefined;
|
|
2516
|
+
return v.pipe(AnyDefault(v.pipe(AnyDefine, v.check((value) => {
|
|
2517
|
+
if (!Array.isArray(value)) {
|
|
2518
|
+
return false;
|
|
2519
|
+
}
|
|
2520
|
+
if (schemahandle.formConfig.groupMode === 'strict') {
|
|
2521
|
+
return value.length === length;
|
|
2522
|
+
}
|
|
2523
|
+
return true;
|
|
2524
|
+
}), v.transform((value) => {
|
|
2525
|
+
if (schemahandle.formConfig.groupMode === 'default' &&
|
|
2526
|
+
value.length !== length) {
|
|
2527
|
+
return value.slice(0, length);
|
|
2528
|
+
}
|
|
2529
|
+
return value;
|
|
2530
|
+
})), schemahandle));
|
|
2531
|
+
},
|
|
2532
|
+
group: (schemahandle) => {
|
|
2533
|
+
const source = schemahandle.coreSchema;
|
|
2534
|
+
const keys = source &&
|
|
2535
|
+
schemahandle.formConfig.groupMode &&
|
|
2536
|
+
schemahandle.formConfig.groupMode !== 'reset'
|
|
2537
|
+
? Object.keys(source.entries)
|
|
2538
|
+
: undefined;
|
|
2539
|
+
return v.pipe(AnyDefault(v.pipe(AnyDefine, v.check((value) => {
|
|
2540
|
+
if (typeof value !== 'object') {
|
|
2541
|
+
return false;
|
|
2542
|
+
}
|
|
2543
|
+
if (schemahandle.formConfig.groupMode === 'strict') {
|
|
2544
|
+
return Object.keys(value).every((key) => key in source.entries);
|
|
2545
|
+
}
|
|
2546
|
+
return true;
|
|
2547
|
+
}), v.transform((a) => {
|
|
2548
|
+
if (schemahandle.formConfig.groupMode === 'default') {
|
|
2549
|
+
return pick(a, keys);
|
|
2550
|
+
}
|
|
2551
|
+
return a;
|
|
2552
|
+
})), schemahandle));
|
|
2553
|
+
},
|
|
2554
|
+
};
|
|
2424
2555
|
class CoreSchemaHandle extends BaseSchemaHandle {
|
|
2425
2556
|
inputs = {};
|
|
2426
2557
|
outputs = {};
|
|
@@ -2441,6 +2572,8 @@ class CoreSchemaHandle extends BaseSchemaHandle {
|
|
|
2441
2572
|
nonFieldControl = false;
|
|
2442
2573
|
hooks;
|
|
2443
2574
|
providers;
|
|
2575
|
+
checkSchema;
|
|
2576
|
+
checkActions = [];
|
|
2444
2577
|
lazySchema(schema) {
|
|
2445
2578
|
super.lazySchema(schema);
|
|
2446
2579
|
if (this.parent) {
|
|
@@ -2572,10 +2705,32 @@ class CoreSchemaHandle extends BaseSchemaHandle {
|
|
|
2572
2705
|
break;
|
|
2573
2706
|
}
|
|
2574
2707
|
}
|
|
2708
|
+
validation(item) {
|
|
2709
|
+
super.validation(item);
|
|
2710
|
+
this.checkActions.push(item);
|
|
2711
|
+
}
|
|
2712
|
+
transformation(item) {
|
|
2713
|
+
super.transformation(item);
|
|
2714
|
+
this.checkActions.push(item);
|
|
2715
|
+
}
|
|
2575
2716
|
end(schema) {
|
|
2576
2717
|
super.end(schema);
|
|
2577
2718
|
this.formConfig.defaultValue =
|
|
2578
2719
|
this.defaultValue ?? (this.nullable ? null : undefined);
|
|
2720
|
+
if (this.isGroup) {
|
|
2721
|
+
this.checkSchema = v.pipe(checkOverride.group(this), ...this.checkActions);
|
|
2722
|
+
}
|
|
2723
|
+
else if (this.isTuple || this.isArray) {
|
|
2724
|
+
this.checkSchema = v.pipe(checkOverride.array(this), ...this.checkActions);
|
|
2725
|
+
}
|
|
2726
|
+
else if (this.isLogicAnd || this.isLogicOr) {
|
|
2727
|
+
this.checkSchema = v.pipe(checkOverride.logicGroup(this), ...this.checkActions);
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
coreSchema;
|
|
2731
|
+
defineSchema(schema) {
|
|
2732
|
+
super.defineSchema(schema);
|
|
2733
|
+
this.coreSchema = schema;
|
|
2579
2734
|
}
|
|
2580
2735
|
}
|
|
2581
2736
|
|
|
@@ -2638,5 +2793,5 @@ const NFCSchema = v.optional(v.void());
|
|
|
2638
2793
|
* Generated bundle index. Do not edit.
|
|
2639
2794
|
*/
|
|
2640
2795
|
|
|
2641
|
-
export { AbstractControl, CoreSchemaHandle, CustomDataSymbol, FieldArray, FieldControl, FieldGroup, FieldLogicGroup, FormBuilder, INVALID, InitPendingValue, NFCSchema, PENDING, PI_CONTEXT_TOKEN, PI_FORM_BUILDER_ALIAS_MAP, PI_FORM_BUILDER_OPTIONS_TOKEN, PI_VIEW_CONFIG_TOKEN, PI_VIEW_FIELD_TOKEN, SortedArray, UpdateType, VALID, actions, arrayStartsWith, asyncMergeOutputs, asyncObjectSignal, clone, combineSignal, controlStatusList, convert, createViewControlLink, disableWhen, effectListen, fieldControlStatusClass, findComponent, formConfig, getDeepError, getLazyImport, hideWhen, initListen, isArray, isFieldArray, isFieldControl, isFieldGroup, isFieldLogicGroup, isGroup, isLazyMark, layout, lazyMark, mergeHooks, mergeHooksFn, mergeOutputFn, mergeOutputs, nonFieldControl, observableSignal, outputChange, outputChangeFn, patchHooks, rawConfig, removeHooks, renderConfig, setAlias, setComponent, setHooks, toArray, toObservable, valueChange, valueChangeFn, changeProviders as ɵchangeProviders, classAction as ɵclassAction, patchProviders as ɵpatchProviders, setProviders as ɵsetProviders, wrappers as ɵwrappers };
|
|
2796
|
+
export { AbstractControl, CoreSchemaHandle, CustomDataSymbol, FieldArray, FieldControl, FieldGroup, FieldLogicGroup, FormBuilder, INVALID, InitPendingValue, NFCSchema, PENDING, PI_CONTEXT_TOKEN, PI_FORM_BUILDER_ALIAS_MAP, PI_FORM_BUILDER_OPTIONS_TOKEN, PI_VIEW_CONFIG_TOKEN, PI_VIEW_FIELD_TOKEN, SortedArray, UpdateType, VALID, actions, arrayStartsWith, asyncMergeOutputs, asyncObjectSignal, clone, combineSignal, controlStatusList, convert, createViewControlLink, disableWhen, effectListen, errorSummary, fieldControlStatusClass, findComponent, findError, formConfig, getDeepError, getLazyImport, hideWhen, initListen, isArray, isFieldArray, isFieldControl, isFieldGroup, isFieldLogicGroup, isGroup, isLazyMark, layout, lazyMark, mergeHooks, mergeHooksFn, mergeOutputFn, mergeOutputs, nonFieldControl, observableSignal, outputChange, outputChangeFn, patchHooks, rawConfig, removeHooks, renderConfig, setAlias, setComponent, setHooks, toArray, toObservable, valueChange, valueChangeFn, changeProviders as ɵchangeProviders, classAction as ɵclassAction, patchProviders as ɵpatchProviders, setProviders as ɵsetProviders, wrappers as ɵwrappers };
|
|
2642
2797
|
//# sourceMappingURL=piying-view-angular-core.mjs.map
|