@piying/view-angular-core 1.2.2 → 1.3.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.
package/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { WritableSignal, Signal, Injector, CreateEffectOptions, EffectRef, Injec
3
3
  import * as rxjs from 'rxjs';
4
4
  import { UnaryFunction, Observable } from 'rxjs';
5
5
  import * as _piying_valibot_visit from '@piying/valibot-visit';
6
- import { SchemaOrPipe, BaseSchemaHandle, LazySchema, DefaultSchema, TupleSchema, EnumSchema, IntersectSchema, UnionSchema, Schema, VoidSchema, MetadataAction, RawConfigActionCommon, ConvertOptions } from '@piying/valibot-visit';
6
+ import { SchemaOrPipe, BaseSchemaHandle, LazySchema, DefaultSchema, TupleSchema, ObjectSchema, EnumSchema, IntersectSchema, UnionSchema, Schema, VoidSchema, MetadataAction, RawConfigActionCommon, ConvertOptions } from '@piying/valibot-visit';
7
7
  export { RawConfig, asControl, asVirtualGroup, changeObject, condition, getDefaults, getSchemaByIssuePath, getSchemaMetadata } from '@piying/valibot-visit';
8
8
  import * as v from 'valibot';
9
9
  import { BaseMetadata, ArraySchema, BaseSchema, BaseIssue, ErrorMessage, ArrayIssue } from 'valibot';
@@ -35,11 +35,18 @@ interface FieldFormConfig<T = any> {
35
35
  emptyValue?: any;
36
36
  /** array */
37
37
  deletionMode?: ArrayDeletionMode;
38
+ /** group/array */
39
+ groupMode?: 'loose' | 'default' | 'strict' | 'reset';
38
40
  }
39
41
  type FieldFormConfig$ = WritableSignal<FieldFormConfig>;
40
42
  type FieldGroupConfig$ = WritableSignal<Omit<FieldFormConfig, 'defaultValue'>>;
41
43
  type FieldArrayConfig$ = WritableSignal<Omit<FieldFormConfig, 'defaultValue'>>;
42
44
  type FieldLogicGroupConfig$ = WritableSignal<Omit<FieldFormConfig, 'defaultValue'>>;
45
+ declare const enum UpdateType {
46
+ init = 0,
47
+ update = 1,
48
+ reset = 2
49
+ }
43
50
 
44
51
  declare const ValidatorPending: unique symbol;
45
52
 
@@ -65,8 +72,8 @@ declare abstract class AbstractControl<TValue = any> {
65
72
  shouldInclude$$: Signal<boolean>;
66
73
  readonly injector: Injector;
67
74
  /** model的value */
68
- abstract value$$: Signal<TValue | undefined>;
69
- abstract children$$?: Signal<AbstractControl[]>;
75
+ value$$: Signal<TValue | undefined>;
76
+ children$$?: Signal<AbstractControl[]>;
70
77
  /** disabled */
71
78
  readonly selfDisabled$$: Signal<boolean>;
72
79
  /** `self` || `parent` */
@@ -115,15 +122,13 @@ declare abstract class AbstractControl<TValue = any> {
115
122
  markAsUntouched(): void;
116
123
  markAsDirty(): void;
117
124
  markAsPristine(): void;
118
- abstract reset(value?: any): void;
125
+ reset(value?: any): void;
119
126
  getRawValue(): any;
120
127
  get<P extends string | (string | number)[]>(path: P): AbstractControl | null;
121
128
  get root(): AbstractControl;
122
- abstract updateValue(value: any): void;
129
+ updateValue(value: any): void;
123
130
  config$: FieldFormConfig$;
124
- initConfig(config: any): void;
125
131
  protected getInitValue(value: any): any;
126
- abstract updateInitValue(value: any): void;
127
132
  find(name: string | number): AbstractControl | null;
128
133
  setControl(name: string | number, control: AbstractControl): void;
129
134
  private reduceChildren;
@@ -134,23 +139,30 @@ declare abstract class AbstractControl<TValue = any> {
134
139
  emitSubmit(): void;
135
140
  }
136
141
 
142
+ declare class FieldGroupbase extends AbstractControl {
143
+ resetValue$: _angular_core.WritableSignal<any>;
144
+ updateValue(value: any): void;
145
+ protected inited: boolean;
146
+ reset(value?: any): void;
147
+ }
148
+
137
149
  declare class FieldGroup<TControl extends {
138
150
  [K in keyof TControl]: AbstractControl<any>;
139
- } = any> extends AbstractControl {
151
+ } = any> extends FieldGroupbase {
140
152
  #private;
141
153
  value$$: _angular_core.Signal<any>;
154
+ fixedControls$: _angular_core.WritableSignal<Record<string, AbstractControl<any>>>;
155
+ resetControls$: _angular_core.WritableSignal<Record<string, AbstractControl<any>>>;
156
+ get controls(): {
157
+ [x: string]: AbstractControl<any>;
158
+ };
142
159
  children$$: _angular_core.Signal<AbstractControl<any>[]>;
143
- controls$: _angular_core.WritableSignal<Record<string, AbstractControl<any>>>;
144
- get controls(): Record<string, AbstractControl<any>>;
145
- registerControl(name: string, control: AbstractControl): AbstractControl<any>;
146
- removeControl(name: string): void;
147
- setControl(name: string, control: AbstractControl): void;
148
- reset(value?: any): void;
160
+ removeRestControl(key: string): void;
161
+ setControl(key: string, control: AbstractControl): void;
149
162
  getRawValue(): any;
150
- find(name: string): AbstractControl | null;
151
- looseValue$$: _angular_core.Signal<any>;
152
- updateValue(value: any): void;
153
- updateInitValue(value: any): void;
163
+ clear(): void;
164
+ find(key: string): AbstractControl | null;
165
+ getResetValue(inputValue: any): Record<string, any>;
154
166
  }
155
167
 
156
168
  declare class FieldControl<TValue = any> extends AbstractControl<TValue> {
@@ -178,37 +190,33 @@ declare class FieldControl<TValue = any> extends AbstractControl<TValue> {
178
190
  updateInitValue(value: any): void;
179
191
  }
180
192
 
181
- declare class FieldArray<TControl extends AbstractControl<any> = any> extends AbstractControl {
193
+ declare class FieldArray<TControl extends AbstractControl<any> = any> extends FieldGroupbase {
182
194
  #private;
183
195
  value$$: _angular_core.Signal<any>;
184
196
  children$$: _angular_core.Signal<AbstractControl<any>[]>;
185
- controls$: _angular_core.WritableSignal<AbstractControl<any>[]>;
197
+ fixedControls$: _angular_core.WritableSignal<AbstractControl<any>[]>;
198
+ resetControls$: _angular_core.WritableSignal<AbstractControl<any>[]>;
186
199
  get controls(): AbstractControl<any>[];
187
- removeAt(index: number): void;
188
- setControl(index: number, control: TControl): void;
200
+ removeRestControl(key: number): void;
201
+ setControl(key: number, control: TControl): void;
189
202
  get length(): number;
190
- reset(value?: any[]): void;
191
- getRawValue(): any[];
203
+ getRawValue(): any;
192
204
  clear(): void;
193
- private _adjustIndex;
194
- find(name: number): AbstractControl;
195
- beforeUpdateList: ((value: any[]) => void)[];
196
- updateValue(value?: any[]): void;
197
- updateInitValue(value: any): void;
205
+ find(key: number): AbstractControl;
206
+ getResetValue(value?: any[]): any[];
198
207
  }
199
208
 
200
209
  declare class FieldLogicGroup extends FieldArray {
210
+ #private;
201
211
  /** 待定参数 */
202
212
  activateIndex$: _angular_core.WritableSignal<number>;
203
213
  type: _angular_core.WritableSignal<LogicType>;
204
214
  activateControl$: _angular_core.WritableSignal<AbstractControl<any>[] | undefined>;
205
215
  value$$: _angular_core.Signal<any>;
206
- getActivateControls(): AbstractControl<any>[];
207
216
  getValue(rawData: boolean): any;
208
217
  reset(value?: any[]): void;
209
218
  getRawValue(): any;
210
219
  updateValue(value: any): void;
211
- updateInitValue(value: any): void;
212
220
  }
213
221
 
214
222
  declare function isFieldGroup(input: any): input is FieldGroup;
@@ -423,6 +431,9 @@ declare class CoreSchemaHandle<Self extends CoreSchemaHandle<any, any>, RESOLVED
423
431
  arraySchema(schema: ArraySchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, ErrorMessage<ArrayIssue> | undefined>): void;
424
432
  defaultSchema(schema: DefaultSchema): void;
425
433
  tupleDefault(schema: TupleSchema): void;
434
+ objectDefault(schema: ObjectSchema): void;
435
+ recordSchema(key: v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>, value: v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>): void;
436
+ restSchema(schema: v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>): void;
426
437
  enumSchema(schema: EnumSchema): void;
427
438
  intersectBefore(schema: IntersectSchema): void;
428
439
  logicItemSchema(schema: v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>, index: number, type: 'intersect' | 'union'): void;
@@ -592,8 +603,6 @@ type CoreResolvedComponentDefine = SetWrapper$<CoreRawComponentDefine, 'attribut
592
603
  interface HookConfig<RESOLVED_FIELD> {
593
604
  /** 配置刚被解析 */
594
605
  fieldResolved?: (field: RESOLVED_FIELD) => void;
595
- /** 子级已经初始化,每次array添加都会触发 */
596
- afterChildrenInit?: (field: RESOLVED_FIELD) => void;
597
606
  /** 所有feilds初始化后执行,也就是可以进行表单监听 */
598
607
  allFieldsResolved?: (field: RESOLVED_FIELD) => void;
599
608
  /** todo 此hook暂时没有使用到 创建组件之前 */
@@ -608,8 +617,9 @@ type PiResolvedCommonViewFieldConfig<SelfResolvedFn extends () => any, Define> =
608
617
  readonly keyPath?: KeyPath | undefined;
609
618
  readonly fullPath: KeyPath;
610
619
  readonly props: WritableSignal<Record<string, any>>;
611
- fieldGroup?: WritableSignal<ReturnType<SelfResolvedFn>[]>;
612
- fieldArray?: WritableSignal<ReturnType<SelfResolvedFn>[]>;
620
+ children?: Signal<ReturnType<SelfResolvedFn>[]>;
621
+ fixedChildren?: WritableSignal<ReturnType<SelfResolvedFn>[]>;
622
+ restChildren?: WritableSignal<ReturnType<SelfResolvedFn>[]>;
613
623
  parent: ReturnType<SelfResolvedFn>;
614
624
  readonly form: {
615
625
  readonly control?: FieldGroup | FieldArray | FieldControl | FieldLogicGroup;
@@ -622,8 +632,8 @@ type PiResolvedCommonViewFieldConfig<SelfResolvedFn extends () => any, Define> =
622
632
  readonly context?: any;
623
633
  get: (keyPath: KeyPath, aliasNotFoundFn?: (name: string, field: PiResolvedCommonViewFieldConfig<any, any>) => PiResolvedCommonViewFieldConfig<any, any>) => ReturnType<SelfResolvedFn> | undefined;
624
634
  action: {
625
- set: (value: any, index?: number) => void;
626
- remove: (index: number) => void;
635
+ set: (value: any, index?: any) => void;
636
+ remove: (index: any) => void;
627
637
  };
628
638
  readonly define?: Define;
629
639
  wrappers: WritableSignal<CoreResolvedWrapperConfig[]>;
@@ -674,17 +684,21 @@ interface BuildRootItem {
674
684
  }
675
685
  interface BuildGroupItem<SchemaHandle extends CoreSchemaHandle<any, any>> {
676
686
  type: 'group';
687
+ templateField?: SchemaHandle;
677
688
  fields: SchemaHandle[];
678
689
  form: FieldGroup;
679
690
  field: _PiResolvedCommonViewFieldConfig;
680
691
  append: (input: _PiResolvedCommonViewFieldConfig) => void;
692
+ skipAppend?: boolean;
681
693
  }
682
694
  interface BuildArrayItem<SchemaHandle extends CoreSchemaHandle<any, any>> {
683
695
  type: 'array';
684
696
  templateField: SchemaHandle;
697
+ fields: SchemaHandle[];
685
698
  form: FieldArray;
686
699
  field: _PiResolvedCommonViewFieldConfig;
687
700
  append: (input: _PiResolvedCommonViewFieldConfig) => void;
701
+ skipAppend?: boolean;
688
702
  }
689
703
 
690
704
  declare class FormBuilder<SchemaHandle extends CoreSchemaHandle<any, any>> {
@@ -692,7 +706,6 @@ declare class FormBuilder<SchemaHandle extends CoreSchemaHandle<any, any>> {
692
706
  buildRoot(item: BuildRootInputItem<SchemaHandle>): void;
693
707
  allFieldInitHookCall(): void;
694
708
  afterResolveConfig(rawConfig: SchemaHandle, config: _PiResolvedCommonViewFieldConfig): _PiResolvedCommonViewFieldConfig | undefined;
695
- createArrayItem(parent: BuildGroupItem<SchemaHandle> | BuildArrayItem<SchemaHandle>, field: AnyCoreSchemaHandle, index: number): PiResolvedCommonViewFieldConfig<any, any>;
696
709
  protected configMergeRaw<T extends SignalInputValue<any>>(list: T[], isArray: boolean, strategy: ConfigMergeStrategy): UnWrapSignal<NonNullable<T>>;
697
710
  /**
698
711
  * 后面覆盖前面
@@ -718,5 +731,5 @@ declare const PI_CONTEXT_TOKEN: InjectionToken<any>;
718
731
  declare function isGroup(schema: AnyCoreSchemaHandle): boolean | undefined;
719
732
  declare function isArray(schema: AnyCoreSchemaHandle): boolean;
720
733
 
721
- export { AbstractControl, CoreSchemaHandle, FieldArray, FieldControl, FieldGroup, FieldLogicGroup, FormBuilder, INVALID, NFCSchema, PENDING, PI_CONTEXT_TOKEN, PI_VIEW_CONFIG_TOKEN, SortedArray, VALID, arrayStartsWith, asyncInputMerge, clone, componentClass, controlStatusList, convert, createViewControlLink, disableWhen, effectListen, fieldControlStatusClass, formConfig, hideWhen, isArray, isFieldArray, isFieldControl, isFieldGroup, isFieldLogicGroup, isGroup, layout, mergeHooks, mergeHooksFn, mergeOutputFn, mergeOutputs, nonFieldControl, outputChange, outputChangeFn, patchAsyncAttributes, patchAsyncFn, patchAsyncInputs, patchAsyncProps, patchAttributes, patchHooks, patchInputs, patchOutputs, patchProps, patchWrappers, rawConfig, removeAttributes, removeHooks, removeInputs, removeOutputs, removeProps, removeWrappers, renderConfig, setAlias, setAttributes, setComponent, setHooks, setInputs, setOutputs, setProps, setWrappers, toArray, toObservable, topClass, unWrapSignal, valueChange, valueChangeFn };
734
+ export { AbstractControl, CoreSchemaHandle, FieldArray, FieldControl, FieldGroup, FieldLogicGroup, FormBuilder, INVALID, NFCSchema, PENDING, PI_CONTEXT_TOKEN, PI_VIEW_CONFIG_TOKEN, SortedArray, UpdateType, VALID, arrayStartsWith, asyncInputMerge, clone, componentClass, controlStatusList, convert, createViewControlLink, disableWhen, effectListen, fieldControlStatusClass, formConfig, hideWhen, isArray, isFieldArray, isFieldControl, isFieldGroup, isFieldLogicGroup, isGroup, layout, mergeHooks, mergeHooksFn, mergeOutputFn, mergeOutputs, nonFieldControl, outputChange, outputChangeFn, patchAsyncAttributes, patchAsyncFn, patchAsyncInputs, patchAsyncProps, patchAttributes, patchHooks, patchInputs, patchOutputs, patchProps, patchWrappers, rawConfig, removeAttributes, removeHooks, removeInputs, removeOutputs, removeProps, removeWrappers, renderConfig, setAlias, setAttributes, setComponent, setHooks, setInputs, setOutputs, setProps, setWrappers, toArray, toObservable, topClass, unWrapSignal, valueChange, valueChangeFn };
722
735
  export type { AbstractControlParams, AnyCoreSchemaHandle, ArraryIterable, ArrayDeletionMode, AsyncValidatorFn, BuildArrayItem, BuildGroupItem, BuildRootInputItem, BuildRootItem, ChangeWhenOption, ConfigMergeStrategy, ControlValueAccessor, CoreRawComponentDefine, CoreRawProps, CoreRawViewAttributes, CoreRawViewInputs, CoreRawViewOutputs, CoreRawWrapperConfig, CoreResolvedComponentDefine, CoreResolvedWrapperConfig, CoreWrapperConfig1, DefaultConfigKey, DisableWhenOption, DisabledValueStrategy, EventChangeFn, FieldArrayConfig$, FieldFormConfig, FieldFormConfig$, FieldGroupConfig$, FieldLogicGroupConfig$, FieldRenderConfig, FieldTransformerConfig, FormBuilderOptions, FormHooks, HideWhenOption, HookConfig, HooksConfig, KeyPath, LayoutAction, LazyImport, LogicType, MergeHooksConfig, NonFieldControlAction, PiCommonConfig, PiCommonDefaultConfig, PiResolvedCommonViewFieldConfig, QueryPath, RawKeyPath, SetOptional, SetReadonly, SetWrapper$, SetWrapper$$, SignalInputValue, ToObservableOptions, UnWrapSignal, VALID_STATUS, ValidationErrors, ValidatorFn, ValueChangFnOptions, ValueChangeFn, Wrapper$, Writeable, _PiResolvedCommonViewFieldConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piying/view-angular-core",
3
- "version": "1.2.2",
3
+ "version": "1.3.1",
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"
package/readme.md CHANGED
@@ -1 +1,27 @@
1
- [document](https://piying-org.github.io/website/docs/client/intro)
1
+ <div><a href="https://www.npmjs.com/package/@piying/view-core"><img src="https://img.shields.io/npm/v/@piying/view-core" alt="NPM Version" /></a> <a href="https://coveralls.io/github/piying-org/piying-view?branch=main"><img src="https://coveralls.io/repos/github/piying-org/piying-view/badge.svg" alt="Coverage Status" ></a> <a href=""><img src="https://img.shields.io/badge/License-MIT-teal.svg" alt="MIT License" /></a></div>
2
+
3
+ ## document
4
+
5
+ - https://piying-org.github.io/website/docs/client/intro
6
+
7
+ ## start
8
+
9
+ - npm i
10
+ - npm run create-view-core
11
+
12
+ ## test
13
+
14
+ - npx playwright install
15
+ - npm run test:all
16
+
17
+ ### test Core/Angular
18
+
19
+ - npm run test
20
+
21
+ ### test Vue
22
+
23
+ - npm run test:vue
24
+
25
+ ### test React
26
+
27
+ - npm run test:react