@piying/view-angular-core 1.9.1 → 1.9.2
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.
|
@@ -3,7 +3,7 @@ import * as v from 'valibot';
|
|
|
3
3
|
import * as jsonActions from '@piying/view-angular-core';
|
|
4
4
|
import { hideWhen, patchInputs, asControl, setComponent } from '@piying/view-angular-core';
|
|
5
5
|
import { computed } from '@angular/core';
|
|
6
|
-
import { merge, map, BehaviorSubject, switchMap, combineLatest } from 'rxjs';
|
|
6
|
+
import { merge, map, BehaviorSubject, switchMap, distinctUntilChanged, combineLatest } from 'rxjs';
|
|
7
7
|
import { schema } from '@piying/valibot-visit';
|
|
8
8
|
import rfdc from 'rfdc';
|
|
9
9
|
|
|
@@ -832,24 +832,24 @@ class CommonTypeService extends BaseTypeService {
|
|
|
832
832
|
* 也就是then/else都会合并base,然后按条件展示,
|
|
833
833
|
*/
|
|
834
834
|
const useThen$ = new BehaviorSubject(undefined);
|
|
835
|
-
|
|
835
|
+
let base1Schema = v.pipe(this.#jsonSchemaBase(schema$1, () => [
|
|
836
836
|
...this.getValidationActionList(schema$1),
|
|
837
|
-
jsonActions.hideWhen({
|
|
838
|
-
disabled: false,
|
|
839
|
-
listen: (fn) => fn({}).pipe(map(({ list: [value], field }) => {
|
|
840
|
-
const isThen = isBoolean(schema$1.if)
|
|
841
|
-
? schema$1.if
|
|
842
|
-
: v.safeParse(ifVSchema, value).success;
|
|
843
|
-
field.form.parent.activateIndex$.set(isThen ? 1 : 2);
|
|
844
|
-
useThen$.next(isThen);
|
|
845
|
-
return !((isThen && !thenSchema) || (!isThen && !elseSchema));
|
|
846
|
-
})),
|
|
847
|
-
}),
|
|
848
837
|
]));
|
|
838
|
+
const baseSchema = v.pipe(base1Schema, jsonActions.hideWhen({
|
|
839
|
+
disabled: false,
|
|
840
|
+
listen: (fn) => fn({}).pipe(map(({ list: [value], field }) => {
|
|
841
|
+
const isThen = isBoolean(schema$1.if)
|
|
842
|
+
? schema$1.if
|
|
843
|
+
: v.safeParse(ifVSchema, value).success;
|
|
844
|
+
field.form.parent.activateIndex$.set(isThen ? 1 : 2);
|
|
845
|
+
useThen$.next(isThen);
|
|
846
|
+
return true;
|
|
847
|
+
})),
|
|
848
|
+
}));
|
|
849
849
|
/** 仅为验证项,非显示用 */
|
|
850
850
|
let ifVSchema;
|
|
851
851
|
if (isBoolean(schema$1.if)) {
|
|
852
|
-
ifVSchema = v.
|
|
852
|
+
ifVSchema = v.pipe(v.any(), v.check(() => !!schema$1.if));
|
|
853
853
|
}
|
|
854
854
|
else {
|
|
855
855
|
const ifSchema = this.#mergeSchema(schema$1, schema$1.if);
|
|
@@ -861,7 +861,7 @@ class CommonTypeService extends BaseTypeService {
|
|
|
861
861
|
jsonActions.hideWhen({
|
|
862
862
|
disabled: true,
|
|
863
863
|
listen(fn) {
|
|
864
|
-
return fn({ list: [['..', 0]] }).pipe(switchMap(({ list: [] }) => useThen$), map((a) => (a === undefined ? true : isThen ? !a : a)));
|
|
864
|
+
return fn({ list: [['..', 0]] }).pipe(switchMap(({ list: [] }) => useThen$), map((a) => (a === undefined ? true : isThen ? !a : a)), distinctUntilChanged());
|
|
865
865
|
},
|
|
866
866
|
}),
|
|
867
867
|
];
|
|
@@ -871,23 +871,25 @@ class CommonTypeService extends BaseTypeService {
|
|
|
871
871
|
const subSchema = this.#mergeSchema(schema$1, schema$1.then);
|
|
872
872
|
thenSchema = v.pipe(this.#jsonSchemaBase(subSchema.schema, () => [
|
|
873
873
|
...subSchema.actionList,
|
|
874
|
-
...hideAction(true),
|
|
875
874
|
]));
|
|
876
875
|
}
|
|
876
|
+
else {
|
|
877
|
+
thenSchema = base1Schema;
|
|
878
|
+
}
|
|
879
|
+
thenSchema = v.pipe(thenSchema, ...hideAction(true));
|
|
877
880
|
let elseSchema;
|
|
878
881
|
if (schema$1.else && !isBoolean(schema$1.else)) {
|
|
879
882
|
const subSchema = this.#mergeSchema(schema$1, schema$1.else);
|
|
880
883
|
elseSchema = v.pipe(this.#jsonSchemaBase(subSchema.schema, () => [
|
|
881
884
|
...subSchema.actionList,
|
|
882
|
-
...hideAction(false),
|
|
883
885
|
]));
|
|
884
886
|
}
|
|
887
|
+
else {
|
|
888
|
+
elseSchema = base1Schema;
|
|
889
|
+
}
|
|
890
|
+
elseSchema = v.pipe(elseSchema, ...hideAction(false));
|
|
885
891
|
// 这种逻辑没问题,因为jsonschema验证中,也会出现base和子级架构一起验证
|
|
886
|
-
vSchema = v.pipe(v.union([
|
|
887
|
-
baseSchema,
|
|
888
|
-
thenSchema ?? baseSchema,
|
|
889
|
-
elseSchema ?? baseSchema,
|
|
890
|
-
].filter(Boolean)), jsonActions.formConfig({ disableOrUpdateActivate: true }), v.rawCheck(({ dataset, addIssue }) => {
|
|
892
|
+
vSchema = v.pipe(v.union([baseSchema, thenSchema, elseSchema]), jsonActions.formConfig({ disableOrUpdateActivate: true }), v.rawCheck(({ dataset, addIssue }) => {
|
|
891
893
|
if (dataset.issues) {
|
|
892
894
|
return;
|
|
893
895
|
}
|