@piying/view-angular-core 1.2.1 → 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/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 +393 -229
- package/fesm2022/piying-view-angular-core.mjs.map +1 -1
- package/index.d.ts +55 -36
- 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,13 +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
|
-
|
|
131
|
+
protected getInitValue(value: any): any;
|
|
125
132
|
find(name: string | number): AbstractControl | null;
|
|
126
133
|
setControl(name: string | number, control: AbstractControl): void;
|
|
127
134
|
private reduceChildren;
|
|
@@ -132,22 +139,30 @@ declare abstract class AbstractControl<TValue = any> {
|
|
|
132
139
|
emitSubmit(): void;
|
|
133
140
|
}
|
|
134
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
|
+
|
|
135
149
|
declare class FieldGroup<TControl extends {
|
|
136
150
|
[K in keyof TControl]: AbstractControl<any>;
|
|
137
|
-
} = any> extends
|
|
151
|
+
} = any> extends FieldGroupbase {
|
|
138
152
|
#private;
|
|
139
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
|
+
};
|
|
140
159
|
children$$: _angular_core.Signal<AbstractControl<any>[]>;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
registerControl(name: string, control: AbstractControl): AbstractControl<any>;
|
|
144
|
-
removeControl(name: string): void;
|
|
145
|
-
setControl(name: string, control: AbstractControl): void;
|
|
146
|
-
reset(value?: any): void;
|
|
160
|
+
removeRestControl(key: string): void;
|
|
161
|
+
setControl(key: string, control: AbstractControl): void;
|
|
147
162
|
getRawValue(): any;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
163
|
+
clear(): void;
|
|
164
|
+
find(key: string): AbstractControl | null;
|
|
165
|
+
getResetValue(inputValue: any): Record<string, any>;
|
|
151
166
|
}
|
|
152
167
|
|
|
153
168
|
declare class FieldControl<TValue = any> extends AbstractControl<TValue> {
|
|
@@ -171,36 +186,35 @@ declare class FieldControl<TValue = any> extends AbstractControl<TValue> {
|
|
|
171
186
|
/** view变更 */
|
|
172
187
|
viewValueChange(value: TValue | undefined): void;
|
|
173
188
|
updateValue(value: any, force?: boolean): void;
|
|
174
|
-
initConfig(config: any): void;
|
|
175
189
|
emitSubmit(): void;
|
|
190
|
+
updateInitValue(value: any): void;
|
|
176
191
|
}
|
|
177
192
|
|
|
178
|
-
declare class FieldArray<TControl extends AbstractControl<any> = any> extends
|
|
193
|
+
declare class FieldArray<TControl extends AbstractControl<any> = any> extends FieldGroupbase {
|
|
179
194
|
#private;
|
|
180
195
|
value$$: _angular_core.Signal<any>;
|
|
181
196
|
children$$: _angular_core.Signal<AbstractControl<any>[]>;
|
|
182
|
-
|
|
197
|
+
fixedControls$: _angular_core.WritableSignal<AbstractControl<any>[]>;
|
|
198
|
+
resetControls$: _angular_core.WritableSignal<AbstractControl<any>[]>;
|
|
183
199
|
get controls(): AbstractControl<any>[];
|
|
184
|
-
|
|
185
|
-
setControl(
|
|
200
|
+
removeRestControl(key: number): void;
|
|
201
|
+
setControl(key: number, control: TControl): void;
|
|
186
202
|
get length(): number;
|
|
187
|
-
|
|
188
|
-
getRawValue(): any[];
|
|
203
|
+
getRawValue(): any;
|
|
189
204
|
clear(): void;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
beforeUpdateList: ((value: any[]) => void)[];
|
|
193
|
-
updateValue(value?: any[]): void;
|
|
205
|
+
find(key: number): AbstractControl;
|
|
206
|
+
getResetValue(value?: any[]): any[];
|
|
194
207
|
}
|
|
195
208
|
|
|
196
209
|
declare class FieldLogicGroup extends FieldArray {
|
|
210
|
+
#private;
|
|
197
211
|
/** 待定参数 */
|
|
198
212
|
activateIndex$: _angular_core.WritableSignal<number>;
|
|
199
213
|
type: _angular_core.WritableSignal<LogicType>;
|
|
200
214
|
activateControl$: _angular_core.WritableSignal<AbstractControl<any>[] | undefined>;
|
|
201
215
|
value$$: _angular_core.Signal<any>;
|
|
202
|
-
getActivateControls(): AbstractControl<any>[];
|
|
203
216
|
getValue(rawData: boolean): any;
|
|
217
|
+
reset(value?: any[]): void;
|
|
204
218
|
getRawValue(): any;
|
|
205
219
|
updateValue(value: any): void;
|
|
206
220
|
}
|
|
@@ -417,6 +431,9 @@ declare class CoreSchemaHandle<Self extends CoreSchemaHandle<any, any>, RESOLVED
|
|
|
417
431
|
arraySchema(schema: ArraySchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, ErrorMessage<ArrayIssue> | undefined>): void;
|
|
418
432
|
defaultSchema(schema: DefaultSchema): void;
|
|
419
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;
|
|
420
437
|
enumSchema(schema: EnumSchema): void;
|
|
421
438
|
intersectBefore(schema: IntersectSchema): void;
|
|
422
439
|
logicItemSchema(schema: v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>, index: number, type: 'intersect' | 'union'): void;
|
|
@@ -586,8 +603,6 @@ type CoreResolvedComponentDefine = SetWrapper$<CoreRawComponentDefine, 'attribut
|
|
|
586
603
|
interface HookConfig<RESOLVED_FIELD> {
|
|
587
604
|
/** 配置刚被解析 */
|
|
588
605
|
fieldResolved?: (field: RESOLVED_FIELD) => void;
|
|
589
|
-
/** 子级已经初始化,每次array添加都会触发 */
|
|
590
|
-
afterChildrenInit?: (field: RESOLVED_FIELD) => void;
|
|
591
606
|
/** 所有feilds初始化后执行,也就是可以进行表单监听 */
|
|
592
607
|
allFieldsResolved?: (field: RESOLVED_FIELD) => void;
|
|
593
608
|
/** todo 此hook暂时没有使用到 创建组件之前 */
|
|
@@ -602,8 +617,9 @@ type PiResolvedCommonViewFieldConfig<SelfResolvedFn extends () => any, Define> =
|
|
|
602
617
|
readonly keyPath?: KeyPath | undefined;
|
|
603
618
|
readonly fullPath: KeyPath;
|
|
604
619
|
readonly props: WritableSignal<Record<string, any>>;
|
|
605
|
-
|
|
606
|
-
|
|
620
|
+
children?: Signal<ReturnType<SelfResolvedFn>[]>;
|
|
621
|
+
fixedChildren?: WritableSignal<ReturnType<SelfResolvedFn>[]>;
|
|
622
|
+
restChildren?: WritableSignal<ReturnType<SelfResolvedFn>[]>;
|
|
607
623
|
parent: ReturnType<SelfResolvedFn>;
|
|
608
624
|
readonly form: {
|
|
609
625
|
readonly control?: FieldGroup | FieldArray | FieldControl | FieldLogicGroup;
|
|
@@ -616,8 +632,8 @@ type PiResolvedCommonViewFieldConfig<SelfResolvedFn extends () => any, Define> =
|
|
|
616
632
|
readonly context?: any;
|
|
617
633
|
get: (keyPath: KeyPath, aliasNotFoundFn?: (name: string, field: PiResolvedCommonViewFieldConfig<any, any>) => PiResolvedCommonViewFieldConfig<any, any>) => ReturnType<SelfResolvedFn> | undefined;
|
|
618
634
|
action: {
|
|
619
|
-
set: (value: any, index?:
|
|
620
|
-
remove: (index:
|
|
635
|
+
set: (value: any, index?: any) => void;
|
|
636
|
+
remove: (index: any) => void;
|
|
621
637
|
};
|
|
622
638
|
readonly define?: Define;
|
|
623
639
|
wrappers: WritableSignal<CoreResolvedWrapperConfig[]>;
|
|
@@ -668,17 +684,21 @@ interface BuildRootItem {
|
|
|
668
684
|
}
|
|
669
685
|
interface BuildGroupItem<SchemaHandle extends CoreSchemaHandle<any, any>> {
|
|
670
686
|
type: 'group';
|
|
687
|
+
templateField?: SchemaHandle;
|
|
671
688
|
fields: SchemaHandle[];
|
|
672
689
|
form: FieldGroup;
|
|
673
690
|
field: _PiResolvedCommonViewFieldConfig;
|
|
674
691
|
append: (input: _PiResolvedCommonViewFieldConfig) => void;
|
|
692
|
+
skipAppend?: boolean;
|
|
675
693
|
}
|
|
676
694
|
interface BuildArrayItem<SchemaHandle extends CoreSchemaHandle<any, any>> {
|
|
677
695
|
type: 'array';
|
|
678
696
|
templateField: SchemaHandle;
|
|
697
|
+
fields: SchemaHandle[];
|
|
679
698
|
form: FieldArray;
|
|
680
699
|
field: _PiResolvedCommonViewFieldConfig;
|
|
681
700
|
append: (input: _PiResolvedCommonViewFieldConfig) => void;
|
|
701
|
+
skipAppend?: boolean;
|
|
682
702
|
}
|
|
683
703
|
|
|
684
704
|
declare class FormBuilder<SchemaHandle extends CoreSchemaHandle<any, any>> {
|
|
@@ -686,7 +706,6 @@ declare class FormBuilder<SchemaHandle extends CoreSchemaHandle<any, any>> {
|
|
|
686
706
|
buildRoot(item: BuildRootInputItem<SchemaHandle>): void;
|
|
687
707
|
allFieldInitHookCall(): void;
|
|
688
708
|
afterResolveConfig(rawConfig: SchemaHandle, config: _PiResolvedCommonViewFieldConfig): _PiResolvedCommonViewFieldConfig | undefined;
|
|
689
|
-
createArrayItem(parent: BuildGroupItem<SchemaHandle> | BuildArrayItem<SchemaHandle>, field: AnyCoreSchemaHandle, index: number): PiResolvedCommonViewFieldConfig<any, any>;
|
|
690
709
|
protected configMergeRaw<T extends SignalInputValue<any>>(list: T[], isArray: boolean, strategy: ConfigMergeStrategy): UnWrapSignal<NonNullable<T>>;
|
|
691
710
|
/**
|
|
692
711
|
* 后面覆盖前面
|
|
@@ -712,5 +731,5 @@ declare const PI_CONTEXT_TOKEN: InjectionToken<any>;
|
|
|
712
731
|
declare function isGroup(schema: AnyCoreSchemaHandle): boolean | undefined;
|
|
713
732
|
declare function isArray(schema: AnyCoreSchemaHandle): boolean;
|
|
714
733
|
|
|
715
|
-
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 };
|
|
716
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 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
|