@piying/view-angular-core 1.2.2 → 1.3.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.
- package/fesm2022/piying-view-angular-core-test.mjs +0 -6
- package/fesm2022/piying-view-angular-core-test.mjs.map +1 -1
- package/fesm2022/piying-view-angular-core.mjs +396 -261
- package/fesm2022/piying-view-angular-core.mjs.map +1 -1
- package/index.d.ts +53 -40
- package/package.json +1 -1
- package/readme.md +27 -1
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
|
-
|
|
69
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -132,25 +137,33 @@ declare abstract class AbstractControl<TValue = any> {
|
|
|
132
137
|
get statusChanges(): Observable<VALID_STATUS>;
|
|
133
138
|
/** 仅触发 updateOn: submit 时使用 */
|
|
134
139
|
emitSubmit(): void;
|
|
140
|
+
protected isUnChanged(): boolean;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
declare class FieldGroupbase extends AbstractControl {
|
|
144
|
+
resetValue$: _angular_core.WritableSignal<any>;
|
|
145
|
+
updateValue(value: any): void;
|
|
146
|
+
protected inited: boolean;
|
|
147
|
+
reset(value?: any): void;
|
|
135
148
|
}
|
|
136
149
|
|
|
137
150
|
declare class FieldGroup<TControl extends {
|
|
138
151
|
[K in keyof TControl]: AbstractControl<any>;
|
|
139
|
-
} = any> extends
|
|
152
|
+
} = any> extends FieldGroupbase {
|
|
140
153
|
#private;
|
|
141
154
|
value$$: _angular_core.Signal<any>;
|
|
155
|
+
fixedControls$: _angular_core.WritableSignal<Record<string, AbstractControl<any>>>;
|
|
156
|
+
resetControls$: _angular_core.WritableSignal<Record<string, AbstractControl<any>>>;
|
|
157
|
+
get controls(): {
|
|
158
|
+
[x: string]: AbstractControl<any>;
|
|
159
|
+
};
|
|
142
160
|
children$$: _angular_core.Signal<AbstractControl<any>[]>;
|
|
143
|
-
|
|
144
|
-
|
|
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;
|
|
161
|
+
removeRestControl(key: string): void;
|
|
162
|
+
setControl(key: string, control: AbstractControl): void;
|
|
149
163
|
getRawValue(): any;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
updateInitValue(value: any): void;
|
|
164
|
+
clear(): void;
|
|
165
|
+
find(key: string): AbstractControl | null;
|
|
166
|
+
getResetValue(inputValue: any): Record<string, any>;
|
|
154
167
|
}
|
|
155
168
|
|
|
156
169
|
declare class FieldControl<TValue = any> extends AbstractControl<TValue> {
|
|
@@ -160,7 +173,6 @@ declare class FieldControl<TValue = any> extends AbstractControl<TValue> {
|
|
|
160
173
|
change: boolean;
|
|
161
174
|
value: undefined;
|
|
162
175
|
}>;
|
|
163
|
-
children$$: undefined;
|
|
164
176
|
/** 视图变化时model值不变也要更新view */
|
|
165
177
|
private viewIndex$;
|
|
166
178
|
/** model输入值 */
|
|
@@ -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
|
|
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
|
-
|
|
197
|
+
fixedControls$: _angular_core.WritableSignal<AbstractControl<any>[]>;
|
|
198
|
+
resetControls$: _angular_core.WritableSignal<AbstractControl<any>[]>;
|
|
186
199
|
get controls(): AbstractControl<any>[];
|
|
187
|
-
|
|
188
|
-
setControl(
|
|
200
|
+
removeRestControl(key: number): void;
|
|
201
|
+
setControl(key: number, control: TControl): void;
|
|
189
202
|
get length(): number;
|
|
190
|
-
|
|
191
|
-
getRawValue(): any[];
|
|
203
|
+
getRawValue(): any;
|
|
192
204
|
clear(): void;
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
612
|
-
|
|
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?:
|
|
626
|
-
remove: (index:
|
|
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
package/readme.md
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
-
|
|
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 build: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
|