@stemy/ngx-dynamic-form 19.8.16 → 19.8.18
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/stemy-ngx-dynamic-form.mjs +55 -26
- package/fesm2022/stemy-ngx-dynamic-form.mjs.map +1 -1
- package/ngx-dynamic-form/common-types.d.ts +71 -2
- package/ngx-dynamic-form/components/dynamic-form/dynamic-form.component.d.ts +5 -2
- package/ngx-dynamic-form/services/dynamic-form-builder.service.d.ts +1 -1
- package/ngx-dynamic-form/services/dynamic-form-template.service.d.ts +7 -1
- package/package.json +1 -1
|
@@ -185,14 +185,59 @@ export type FormFieldExpressions = {
|
|
|
185
185
|
"props.required"?: FormFieldExpression<boolean>;
|
|
186
186
|
};
|
|
187
187
|
export interface FormFieldConfig<T = FormFieldProps> extends FormlyFieldConfig<T> {
|
|
188
|
+
/**
|
|
189
|
+
* Conditional check if the field should be serialized or not, normal serialization can happen even if the field is hidden
|
|
190
|
+
*/
|
|
188
191
|
serialize?: FormFieldConditionFn;
|
|
192
|
+
/**
|
|
193
|
+
* This is a custom serializer callback function.
|
|
194
|
+
*/
|
|
189
195
|
serializer?: FormFieldSerializer;
|
|
196
|
+
/**
|
|
197
|
+
* Puts the field in a custom field set
|
|
198
|
+
*/
|
|
190
199
|
fieldSet?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Optionally change the default label prefix for this field and its children
|
|
202
|
+
*/
|
|
203
|
+
labelPrefix?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Optional key to use when requesting a ng-template for the field control (instead of key || id)
|
|
206
|
+
*/
|
|
207
|
+
controlTemplateKey?: string;
|
|
208
|
+
/**
|
|
209
|
+
* Optional key to use when requesting a ng-template for the field label (instead of key || id)
|
|
210
|
+
*/
|
|
211
|
+
labelTemplateKey?: string;
|
|
212
|
+
/**
|
|
213
|
+
* Optional key to use when requesting a ng-template for the field input (instead of key || id)
|
|
214
|
+
*/
|
|
215
|
+
inputTemplateKey?: string;
|
|
216
|
+
/**
|
|
217
|
+
* Optional key to use when requesting a ng-template for the field prefix (instead of key || id)
|
|
218
|
+
*/
|
|
219
|
+
prefixTemplateKey?: string;
|
|
220
|
+
/**
|
|
221
|
+
* Optional key to use when requesting a ng-template for the field suffix (instead of key || id)
|
|
222
|
+
*/
|
|
223
|
+
suffixTemplateKey?: string;
|
|
224
|
+
/**
|
|
225
|
+
* Gives purpose to a field (can be used as a filter in serialization)
|
|
226
|
+
*/
|
|
191
227
|
purposes?: string[];
|
|
228
|
+
/**
|
|
229
|
+
* Use this field as a field set instead of a keyed form group
|
|
230
|
+
*/
|
|
192
231
|
asFieldSet?: boolean;
|
|
193
232
|
priority?: number;
|
|
194
233
|
fieldGroup?: FormFieldConfig[];
|
|
234
|
+
/**
|
|
235
|
+
* Definition of how array items look
|
|
236
|
+
*/
|
|
195
237
|
fieldArray?: FormFieldConfig;
|
|
238
|
+
/**
|
|
239
|
+
* Custom field hook definitions
|
|
240
|
+
*/
|
|
196
241
|
hooks: FormHookConfig;
|
|
197
242
|
expressions: FormFieldExpressions;
|
|
198
243
|
readonly parent?: FormFieldConfig;
|
|
@@ -287,6 +332,30 @@ export type FormFieldData = Pick<FormFieldProps, "label" | "labelAlign" | "descr
|
|
|
287
332
|
* Puts the field in a custom field set
|
|
288
333
|
*/
|
|
289
334
|
fieldSet?: string;
|
|
335
|
+
/**
|
|
336
|
+
* Optionally change the default label prefix for this field and its children
|
|
337
|
+
*/
|
|
338
|
+
labelPrefix?: string;
|
|
339
|
+
/**
|
|
340
|
+
* Optional key to use when requesting a ng-template for the field control (instead of key || id)
|
|
341
|
+
*/
|
|
342
|
+
controlTemplateKey?: string;
|
|
343
|
+
/**
|
|
344
|
+
* Optional key to use when requesting a ng-template for the field label (instead of key || id)
|
|
345
|
+
*/
|
|
346
|
+
labelTemplateKey?: string;
|
|
347
|
+
/**
|
|
348
|
+
* Optional key to use when requesting a ng-template for the field input (instead of key || id)
|
|
349
|
+
*/
|
|
350
|
+
inputTemplateKey?: string;
|
|
351
|
+
/**
|
|
352
|
+
* Optional key to use when requesting a ng-template for the field prefix (instead of key || id)
|
|
353
|
+
*/
|
|
354
|
+
prefixTemplateKey?: string;
|
|
355
|
+
/**
|
|
356
|
+
* Optional key to use when requesting a ng-template for the field suffix (instead of key || id)
|
|
357
|
+
*/
|
|
358
|
+
suffixTemplateKey?: string;
|
|
290
359
|
/**
|
|
291
360
|
* Gives purpose to a field (can be used as a filter in serialization)
|
|
292
361
|
*/
|
|
@@ -329,12 +398,12 @@ export type FormGroupData = FormFieldData & Pick<FormFieldProps, "useTabs"> & {
|
|
|
329
398
|
};
|
|
330
399
|
export type FormArrayData = FormFieldData & Pick<FormFieldProps, "useTabs" | "tabsLabel" | "insertItem" | "cloneItem" | "moveItem" | "removeItem" | "addItem" | "clearItems">;
|
|
331
400
|
export type FormSerializerData = RequireAtLeastOne<Pick<FormFieldData, "serialize" | "serializer">>;
|
|
332
|
-
export type FormFieldSetData = RequireAtLeastOne<Pick<FormFieldData, "classes" | "layout">> & {
|
|
401
|
+
export type FormFieldSetData = RequireAtLeastOne<Pick<FormFieldData, "label" | "labelPrefix" | "classes" | "layout">> & {
|
|
333
402
|
id: string;
|
|
334
403
|
};
|
|
335
404
|
export type AsyncSubmitMode = "click" | "submit" | "all";
|
|
336
405
|
export type AsyncSubmitMethod = (form: IDynamicForm, context?: any, ev?: MouseEvent) => Promise<IAsyncMessage>;
|
|
337
|
-
export type FormTemplateType = "control" | "label" | "input" | "prefix" | "suffix"
|
|
406
|
+
export type FormTemplateType = "control" | "label" | "input" | "prefix" | "suffix";
|
|
338
407
|
export type FormFieldCustomizer = (field: FormFieldConfig, options: FormBuilderOptions, injector: Injector, property: OpenApiSchemaProperty, schema: OpenApiSchema) => MaybePromise<MaybeArray<FormFieldConfig>>;
|
|
339
408
|
export interface ConfigForSchemaOptionsBase extends FormBuilderOptionsBase {
|
|
340
409
|
fieldCustomizer?: FormFieldCustomizer;
|
|
@@ -5,12 +5,15 @@ import { EventsService } from "@stemy/ngx-utils";
|
|
|
5
5
|
import { FormFieldChangeEvent, FormFieldConfig, FormFieldLabelCustomizer, FormSerializeResult, IDynamicForm } from "../../common-types";
|
|
6
6
|
import { DynamicFormBuilderService } from "../../services/dynamic-form-builder.service";
|
|
7
7
|
import { DynamicFormService } from "../../services/dynamic-form.service";
|
|
8
|
+
import { DynamicFormTemplateService } from "../../services/dynamic-form-template.service";
|
|
8
9
|
import * as i0 from "@angular/core";
|
|
9
10
|
export declare class DynamicFormComponent implements IDynamicForm {
|
|
10
11
|
readonly forms: DynamicFormService;
|
|
12
|
+
protected readonly templates: DynamicFormTemplateService;
|
|
11
13
|
protected readonly builder: DynamicFormBuilderService;
|
|
12
14
|
protected readonly events: EventsService;
|
|
13
15
|
protected readonly languages: import("@stemy/ngx-utils").ILanguageService;
|
|
16
|
+
readonly globalTemplatePrefix: import("@angular/core").InputSignal<string>;
|
|
14
17
|
readonly labelPrefix: import("@angular/core").InputSignal<string>;
|
|
15
18
|
readonly labelCustomizer: import("@angular/core").InputSignal<FormFieldLabelCustomizer>;
|
|
16
19
|
readonly testId: import("@angular/core").InputSignal<string>;
|
|
@@ -32,12 +35,12 @@ export declare class DynamicFormComponent implements IDynamicForm {
|
|
|
32
35
|
readonly onValueChanges: import("@angular/core").OutputRef<FormFieldChangeEvent>;
|
|
33
36
|
readonly onInit: import("@angular/core").OutputRef<FormFieldChangeEvent>;
|
|
34
37
|
readonly options: FormlyFormOptions;
|
|
35
|
-
constructor(forms: DynamicFormService);
|
|
38
|
+
constructor(forms: DynamicFormService, templates: DynamicFormTemplateService);
|
|
36
39
|
submit(): void;
|
|
37
40
|
reset(): void;
|
|
38
41
|
serialize(validate?: boolean, ...purposes: string[]): Promise<FormSerializeResult>;
|
|
39
42
|
getField(path: string): FormFieldConfig;
|
|
40
43
|
getControl(path: string): AbstractControl;
|
|
41
44
|
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicFormComponent, never>;
|
|
42
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<DynamicFormComponent, "dynamic-form", never, { "labelPrefix": { "alias": "labelPrefix"; "required": false; "isSignal": true; }; "labelCustomizer": { "alias": "labelCustomizer"; "required": false; "isSignal": true; }; "testId": { "alias": "testId"; "required": false; "isSignal": true; }; "useTabs": { "alias": "useTabs"; "required": false; "isSignal": true; }; "legacyLabels": { "alias": "legacyLabels"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; "fields": { "alias": "fields"; "required": false; "isSignal": true; }; }, { "onSubmit": "onSubmit"; "onFieldChanges": "onFieldChanges"; "onValueChanges": "onValueChanges"; "onInit": "onInit"; }, never, ["*"], false, never>;
|
|
45
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DynamicFormComponent, "dynamic-form", never, { "globalTemplatePrefix": { "alias": "globalTemplatePrefix"; "required": false; "isSignal": true; }; "labelPrefix": { "alias": "labelPrefix"; "required": false; "isSignal": true; }; "labelCustomizer": { "alias": "labelCustomizer"; "required": false; "isSignal": true; }; "testId": { "alias": "testId"; "required": false; "isSignal": true; }; "useTabs": { "alias": "useTabs"; "required": false; "isSignal": true; }; "legacyLabels": { "alias": "legacyLabels"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; "fields": { "alias": "fields"; "required": false; "isSignal": true; }; }, { "onSubmit": "onSubmit"; "onFieldChanges": "onFieldChanges"; "onValueChanges": "onValueChanges"; "onInit": "onInit"; }, never, ["*"], false, never>;
|
|
43
46
|
}
|
|
@@ -26,7 +26,7 @@ export declare class DynamicFormBuilderService {
|
|
|
26
26
|
createFormSerializer(key: string, data: FormFieldSerializer | FormSerializerData): Partial<FormFieldConfig>;
|
|
27
27
|
fixSelectOptions(field: FormFieldConfig, options: FormSelectOption[]): Promise<FormSelectOption[]>;
|
|
28
28
|
protected isFieldset(field: FormFieldConfig): boolean;
|
|
29
|
-
protected getLabel(key: string, label: string, parent: FormFieldConfig, options: FormBuilderOptions, legacyPrefix?: string): string;
|
|
29
|
+
protected getLabel(key: string, label: string, labelPrefix: string, parent: FormFieldConfig, options: FormBuilderOptions, legacyPrefix?: string): string;
|
|
30
30
|
protected createFormField(key: string, type: string, data: FormFieldData, props: FormFieldProps, parent: FormFieldConfig, options?: FormBuilderOptions): FormFieldConfig;
|
|
31
31
|
protected isValid(field: FormFieldConfig): boolean;
|
|
32
32
|
protected setExpressions(field: FormFieldConfig, options: FormBuilderOptions): void;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { TemplateRef } from "@angular/core";
|
|
2
2
|
import { Subject } from "rxjs";
|
|
3
|
+
import { GlobalTemplateService } from "@stemy/ngx-utils";
|
|
3
4
|
import { FormTemplateType } from "../common-types";
|
|
4
5
|
import * as i0 from "@angular/core";
|
|
5
6
|
export declare class DynamicFormTemplateService {
|
|
7
|
+
protected readonly globalTemplates: GlobalTemplateService;
|
|
6
8
|
readonly templatesUpdated: Subject<void>;
|
|
7
9
|
protected templates: Map<FormTemplateType, Map<string, TemplateRef<any>>>;
|
|
8
|
-
|
|
10
|
+
protected globalTemplatePrefix: string;
|
|
11
|
+
get globalPrefix(): string;
|
|
12
|
+
set globalPrefix(value: string);
|
|
13
|
+
constructor(globalTemplates: GlobalTemplateService);
|
|
9
14
|
isValidType(type: string): boolean;
|
|
10
15
|
get(type: FormTemplateType, key: string): TemplateRef<any>;
|
|
16
|
+
protected getGlobalTemplate(type: FormTemplateType, key: string): TemplateRef<any>;
|
|
11
17
|
add(key: string, type: FormTemplateType, template: TemplateRef<any>): void;
|
|
12
18
|
remove(key: string, type: FormTemplateType): void;
|
|
13
19
|
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicFormTemplateService, never>;
|