@piying/view-angular-core 2.4.5 → 2.5.0

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/index.d.ts CHANGED
@@ -55,14 +55,34 @@ declare const enum UpdateType {
55
55
 
56
56
  declare const ValidatorPending: unique symbol;
57
57
 
58
- type ValidationErrors = {
58
+ type ValidationErrorsLegacy = {
59
59
  [key: string]: any;
60
60
  };
61
+ type ValidationValibotError2 = {
62
+ kind: 'valibot';
63
+ metadata: [v.BaseIssue<unknown>, ...v.BaseIssue<unknown>[]];
64
+ };
65
+ type ValidationErrorError2 = {
66
+ kind: 'error';
67
+ metadata: Error;
68
+ };
69
+ type ValidationDescendantError2 = {
70
+ kind: 'descendant';
71
+ key: string | number;
72
+ field: AbstractControl;
73
+ metadata: ValidationCommonError2[];
74
+ };
75
+ type ValidationCommonError2 = {
76
+ kind: string;
77
+ metadata?: any;
78
+ message?: string;
79
+ };
80
+ type ValidationErrors2 = ValidationValibotError2 | ValidationErrorError2 | ValidationDescendantError2 | ValidationCommonError2;
61
81
  interface ValidatorFn {
62
- (control: AbstractControl): ValidationErrors | undefined;
82
+ (control: AbstractControl): ValidationErrorsLegacy | ValidationErrors2[] | undefined;
63
83
  }
64
84
  interface AsyncValidatorFn {
65
- (control: AbstractControl): Promise<ValidationErrors | undefined> | Observable<ValidationErrors | undefined> | Signal<ValidationErrors | undefined>;
85
+ (control: AbstractControl): Promise<ValidationErrorsLegacy | ValidationErrors2[] | undefined> | Observable<ValidationErrorsLegacy | ValidationErrors2[] | undefined> | Signal<ValidationErrorsLegacy | ValidationErrors2[] | undefined>;
66
86
  }
67
87
  declare const VALID = "VALID";
68
88
  declare const INVALID = "INVALID";
@@ -86,12 +106,15 @@ declare abstract class AbstractControl<TValue = any> {
86
106
  /** 父级取值时,当前子级是否包含在内 */
87
107
  shouldInclude$$: Signal<boolean>;
88
108
  readonly injector: Injector;
109
+ originValue$$: Signal<TValue | undefined>;
89
110
  /** model的value */
90
- value$$: Signal<TValue | undefined>;
111
+ value$$: Signal<TValue>;
91
112
  /** 已激活的子级,用于校验获得返回值之类 */
92
113
  activatedChildren$$?: Signal<AbstractControl[]>;
93
114
  /** 通用的子级,用于查询之类 */
94
- children$$?: Signal<AbstractControl[]>;
115
+ children$$?: Signal<{
116
+ [s: string]: AbstractControl;
117
+ } | ArrayLike<AbstractControl>>;
95
118
  /** disabled */
96
119
  readonly selfDisabled$$: Signal<boolean>;
97
120
  /** `self` || `parent` */
@@ -112,16 +135,16 @@ declare abstract class AbstractControl<TValue = any> {
112
135
  get dirty(): boolean;
113
136
  get pristine(): boolean;
114
137
  protected resetIndex$: _angular_core.WritableSignal<number>;
115
- syncError$: _angular_core.WritableSignal<ValidationErrors | undefined>;
116
- asyncErrorRes$$: Signal<Signal<typeof ValidatorPending | Record<string, any> | undefined> | undefined>;
117
- asyncError$$: Signal<"PENDING" | Record<string, any> | undefined>;
118
- rawError$$: Signal<"PENDING" | ValidationErrors | undefined>;
138
+ syncError$: _angular_core.WritableSignal<ValidationErrors2[] | undefined>;
139
+ asyncErrorRes$$: Signal<Signal<typeof ValidatorPending | (ValidationValibotError2 | ValidationErrorError2 | ValidationDescendantError2 | ValidationCommonError2)[] | undefined> | undefined>;
140
+ asyncError$$: Signal<"PENDING" | (ValidationValibotError2 | ValidationErrorError2 | ValidationDescendantError2 | ValidationCommonError2)[] | undefined>;
141
+ rawError$$: Signal<"PENDING" | ValidationErrors2[] | undefined>;
119
142
  valueNoError$$: Signal<boolean>;
120
- get errors(): ValidationErrors | undefined;
143
+ get errors(): ValidationErrors2[] | undefined;
121
144
  /** parent */
122
145
  private _parent?;
123
146
  get parent(): AbstractControl | undefined;
124
- get value(): TValue | undefined;
147
+ get value(): TValue;
125
148
  required$$: Signal<boolean | undefined>;
126
149
  readonly schemaParser: v.SafeParser<SchemaOrPipe, undefined>;
127
150
  context: any;
@@ -146,7 +169,7 @@ declare abstract class AbstractControl<TValue = any> {
146
169
  updateValue(value: any): void;
147
170
  config$: FieldFormConfig$;
148
171
  protected getInitValue(value: any): any;
149
- protected transfomerToModel$$: Signal<((value: any, control: AbstractControl) => any) | undefined>;
172
+ protected transformToModel(value: any, control: AbstractControl<any>): any;
150
173
  find(name: string | number): AbstractControl | null;
151
174
  setControl(name: string | number, control: AbstractControl): void;
152
175
  /** 校验和获得值用 */
@@ -171,13 +194,15 @@ declare class FieldGroup<TControl extends {
171
194
  [K in keyof TControl]: AbstractControl<any>;
172
195
  } = any> extends FieldGroupbase {
173
196
  #private;
174
- value$$: _angular_core.Signal<any>;
197
+ originValue$$: _angular_core.Signal<any>;
175
198
  fixedControls$: _angular_core.WritableSignal<Record<string, AbstractControl<any>>>;
176
199
  resetControls$: _angular_core.WritableSignal<Record<string, AbstractControl<any>>>;
177
200
  get controls(): {
178
201
  [x: string]: AbstractControl<any>;
179
202
  };
180
- children$$: _angular_core.Signal<AbstractControl<any>[]>;
203
+ children$$: _angular_core.Signal<{
204
+ [x: string]: AbstractControl<any>;
205
+ }>;
181
206
  removeRestControl(key: string): void;
182
207
  setControl(key: string, control: AbstractControl): void;
183
208
  getRawValue(): any;
@@ -196,7 +221,7 @@ declare class FieldControl<TValue = any> extends AbstractControl<TValue> {
196
221
  /** 传入到view中的值 */
197
222
  modelValueToViewValue$$: _angular_core.Signal<any>;
198
223
  /** modelValue + viewValue => modelValue */
199
- value$$: WritableSignal<any>;
224
+ originValue$$: WritableSignal<any>;
200
225
  reset(formState?: TValue): void;
201
226
  /** view变更 */
202
227
  viewValueChange(value: TValue | undefined): void;
@@ -207,7 +232,7 @@ declare class FieldControl<TValue = any> extends AbstractControl<TValue> {
207
232
 
208
233
  declare class FieldArray<TControl extends AbstractControl<any> = any> extends FieldGroupbase {
209
234
  #private;
210
- value$$: _angular_core.Signal<any>;
235
+ originValue$$: _angular_core.Signal<any>;
211
236
  children$$: _angular_core.Signal<AbstractControl<any>[]>;
212
237
  fixedControls$: _angular_core.WritableSignal<AbstractControl<any>[]>;
213
238
  resetControls$: _angular_core.WritableSignal<AbstractControl<any>[]>;
@@ -226,7 +251,7 @@ declare class FieldLogicGroup extends FieldArray {
226
251
  activateIndex$: _angular_core.WritableSignal<number>;
227
252
  type: _angular_core.WritableSignal<LogicType>;
228
253
  activateControls$: _angular_core.WritableSignal<AbstractControl<any>[] | undefined>;
229
- value$$: _angular_core.Signal<any>;
254
+ originValue$$: _angular_core.Signal<any>;
230
255
  activatedChildren$$: _angular_core.Signal<AbstractControl<any>[]>;
231
256
  getValue(rawData: boolean): any;
232
257
  reset(value?: any[]): void;
@@ -427,10 +452,14 @@ declare function fieldControlStatusClass(fieldControl?: AbstractControl, skipDis
427
452
 
428
453
  declare function initListen(input: any, control: AbstractControl, injector: Injector, fn: (input: any) => void): _angular_core.EffectRef;
429
454
 
430
- declare function getDeepError(control?: AbstractControl): {
431
- control: AbstractControl<any>;
432
- errors: _piying_view_angular_core.ValidationErrors | undefined;
433
- }[];
455
+ interface ErrorSummary {
456
+ pathList: string[];
457
+ fieldList: AbstractControl[];
458
+ item: Exclude<ValidationErrors2, ValidationDescendantError2>;
459
+ valibotIssueSummary: string | undefined;
460
+ }
461
+ declare function errorSummary(control?: AbstractControl): ErrorSummary[];
462
+ declare const getDeepError: typeof errorSummary;
434
463
 
435
464
  type ObservableSignal<Input, Output> = WritableSignal<Input> & {
436
465
  input: Signal<Input>;
@@ -496,6 +525,8 @@ declare class CoreSchemaHandle<Self extends CoreSchemaHandle<any, any>, RESOLVED
496
525
  nonFieldControl: boolean;
497
526
  hooks?: HookConfig<ReturnType<RESOLVED_FN>>;
498
527
  providers?: InjectorProvider[];
528
+ checkSchema?: v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>;
529
+ checkActions: (v.BaseValidation<any, any, any> | v.BaseTransformation<any, any, any>)[];
499
530
  lazySchema(schema: LazySchema): void;
500
531
  arraySchema(schema: ArraySchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, ErrorMessage<ArrayIssue> | undefined>): void;
501
532
  defaultSchema(schema: DefaultSchema): void;
@@ -511,7 +542,11 @@ declare class CoreSchemaHandle<Self extends CoreSchemaHandle<any, any>, RESOLVED
511
542
  beforeSchemaType(schema: Schema): void;
512
543
  voidSchema(schema: VoidSchema): void;
513
544
  metadataDefaulthandle(metadata: MetadataAction, environments: string[]): void;
545
+ validation(item: v.BaseValidation<any, any, v.BaseIssue<unknown>>): void;
546
+ transformation(item: v.BaseTransformation<any, any, v.BaseIssue<unknown>>): void;
514
547
  end(schema: SchemaOrPipe): void;
548
+ coreSchema: v.BaseSchema<any, any, any>;
549
+ defineSchema(schema: SchemaOrPipe): void;
515
550
  }
516
551
  type AnyCoreSchemaHandle = CoreSchemaHandle<any, () => _PiResolvedCommonViewFieldConfig>;
517
552
 
@@ -858,5 +893,7 @@ declare class FormBuilder<SchemaHandle extends CoreSchemaHandle<any, any>> {
858
893
  declare function isGroup(schema: AnyCoreSchemaHandle): boolean | undefined;
859
894
  declare function isArray(schema: AnyCoreSchemaHandle): boolean;
860
895
 
861
- export { AbstractControl, CoreSchemaHandle, CustomDataSymbol, FieldArray, FieldControl, FieldGroup, FieldLogicGroup, FormBuilder, INVALID, InitPendingValue, NFCSchema, PENDING, PI_CONTEXT_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 };
862
- export type { AbstractControlParams, AnyCoreSchemaHandle, ArraryIterable, ArrayDeletionMode, AsyncCallback, AsyncObjectSignal, AsyncValidatorFn, BuildArrayItem, BuildGroupItem, BuildRootInputItem, BuildRootItem, CombineSignal, ConfigAction, ControlValueAccessor, CoreResolvedComponentDefine, CoreWrapperConfig, DisableWhenOption, DisabledValueStrategy, EventChangeFn, FieldArrayConfig$, FieldFormConfig, FieldFormConfig$, FieldGroupConfig$, FieldLogicGroupConfig$, FieldRenderConfig, FieldTransformerConfig, FormBuilderOptions, FormHooks, HideWhenOption, HookConfig, HooksConfig, InjectorProvider, KeyPath, LayoutAction, LazyImport, LazyMarkType, LogicType, MergeHooksConfig, NonFieldControlAction, ObservableSignal, PiCommonConfig, PiResolvedCommonViewFieldConfig, QueryPath, RawCoreWrapperConfig, RawKeyPath, SetOptional, SetReadonly, SetUnWrapper$, SetWrapper$, SetWrapper$$, SignalInputValue, ToObservableOptions, UnWrapSignal, UnWrapper$, VALID_STATUS, ValidationErrors, ValidatorFn, ValueChangFnOptions, ValueChangeFn, ViewAttributes, ViewEvents, ViewInputs, ViewOutputs, ViewProps, Wrapper$, Writeable, _PiResolvedCommonViewFieldConfig };
896
+ declare function findError<K extends string>(list: ValidationErrors2[] | undefined, key: K): (K extends ValidationValibotError2['kind'] ? ValidationValibotError2 : K extends ValidationErrorError2['kind'] ? ValidationErrorError2 : ValidationCommonError2) | undefined;
897
+
898
+ export { AbstractControl, CoreSchemaHandle, CustomDataSymbol, FieldArray, FieldControl, FieldGroup, FieldLogicGroup, FormBuilder, INVALID, InitPendingValue, NFCSchema, PENDING, PI_CONTEXT_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 };
899
+ export type { AbstractControlParams, AnyCoreSchemaHandle, ArraryIterable, ArrayDeletionMode, AsyncCallback, AsyncObjectSignal, AsyncValidatorFn, BuildArrayItem, BuildGroupItem, BuildRootInputItem, BuildRootItem, CombineSignal, ConfigAction, ControlValueAccessor, CoreResolvedComponentDefine, CoreWrapperConfig, DisableWhenOption, DisabledValueStrategy, ErrorSummary, EventChangeFn, FieldArrayConfig$, FieldFormConfig, FieldFormConfig$, FieldGroupConfig$, FieldLogicGroupConfig$, FieldRenderConfig, FieldTransformerConfig, FormBuilderOptions, FormHooks, HideWhenOption, HookConfig, HooksConfig, InjectorProvider, KeyPath, LayoutAction, LazyImport, LazyMarkType, LogicType, MergeHooksConfig, NonFieldControlAction, ObservableSignal, PiCommonConfig, PiResolvedCommonViewFieldConfig, QueryPath, RawCoreWrapperConfig, RawKeyPath, SetOptional, SetReadonly, SetUnWrapper$, SetWrapper$, SetWrapper$$, SignalInputValue, ToObservableOptions, UnWrapSignal, UnWrapper$, VALID_STATUS, ValidationCommonError2, ValidationDescendantError2, ValidationErrorError2, ValidationErrors2, ValidationErrorsLegacy, ValidationValibotError2, ValidatorFn, ValueChangFnOptions, ValueChangeFn, ViewAttributes, ViewEvents, ViewInputs, ViewOutputs, ViewProps, Wrapper$, Writeable, _PiResolvedCommonViewFieldConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piying/view-angular-core",
3
- "version": "2.4.5",
3
+ "version": "2.5.0",
4
4
  "homepage": "https://piying-org.github.io/website/docs/client/intro",
5
5
  "repository": {
6
6
  "url": "https://github.com/piying-org/piying-view"