@stemy/ngx-dynamic-form 19.8.15 → 19.8.17

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.
@@ -185,14 +185,55 @@ 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
+ * Optional key to use when requesting a ng-template for the field control (instead of key || id)
202
+ */
203
+ controlTemplateKey?: string;
204
+ /**
205
+ * Optional key to use when requesting a ng-template for the field label (instead of key || id)
206
+ */
207
+ labelTemplateKey?: string;
208
+ /**
209
+ * Optional key to use when requesting a ng-template for the field input (instead of key || id)
210
+ */
211
+ inputTemplateKey?: string;
212
+ /**
213
+ * Optional key to use when requesting a ng-template for the field prefix (instead of key || id)
214
+ */
215
+ prefixTemplateKey?: string;
216
+ /**
217
+ * Optional key to use when requesting a ng-template for the field suffix (instead of key || id)
218
+ */
219
+ suffixTemplateKey?: string;
220
+ /**
221
+ * Gives purpose to a field (can be used as a filter in serialization)
222
+ */
191
223
  purposes?: string[];
224
+ /**
225
+ * Use this field as a field set instead of a keyed form group
226
+ */
192
227
  asFieldSet?: boolean;
193
228
  priority?: number;
194
229
  fieldGroup?: FormFieldConfig[];
230
+ /**
231
+ * Definition of how array items look
232
+ */
195
233
  fieldArray?: FormFieldConfig;
234
+ /**
235
+ * Custom field hook definitions
236
+ */
196
237
  hooks: FormHookConfig;
197
238
  expressions: FormFieldExpressions;
198
239
  readonly parent?: FormFieldConfig;
@@ -287,6 +328,26 @@ export type FormFieldData = Pick<FormFieldProps, "label" | "labelAlign" | "descr
287
328
  * Puts the field in a custom field set
288
329
  */
289
330
  fieldSet?: string;
331
+ /**
332
+ * Optional key to use when requesting a ng-template for the field control (instead of key || id)
333
+ */
334
+ controlTemplateKey?: string;
335
+ /**
336
+ * Optional key to use when requesting a ng-template for the field label (instead of key || id)
337
+ */
338
+ labelTemplateKey?: string;
339
+ /**
340
+ * Optional key to use when requesting a ng-template for the field input (instead of key || id)
341
+ */
342
+ inputTemplateKey?: string;
343
+ /**
344
+ * Optional key to use when requesting a ng-template for the field prefix (instead of key || id)
345
+ */
346
+ prefixTemplateKey?: string;
347
+ /**
348
+ * Optional key to use when requesting a ng-template for the field suffix (instead of key || id)
349
+ */
350
+ suffixTemplateKey?: string;
290
351
  /**
291
352
  * Gives purpose to a field (can be used as a filter in serialization)
292
353
  */
@@ -334,6 +395,7 @@ export type FormFieldSetData = RequireAtLeastOne<Pick<FormFieldData, "classes" |
334
395
  };
335
396
  export type AsyncSubmitMode = "click" | "submit" | "all";
336
397
  export type AsyncSubmitMethod = (form: IDynamicForm, context?: any, ev?: MouseEvent) => Promise<IAsyncMessage>;
398
+ export type FormTemplateType = "control" | "label" | "input" | "prefix" | "suffix";
337
399
  export type FormFieldCustomizer = (field: FormFieldConfig, options: FormBuilderOptions, injector: Injector, property: OpenApiSchemaProperty, schema: OpenApiSchema) => MaybePromise<MaybeArray<FormFieldConfig>>;
338
400
  export interface ConfigForSchemaOptionsBase extends FormBuilderOptionsBase {
339
401
  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
  }
@@ -0,0 +1,22 @@
1
+ import { OnChanges, OnDestroy, TemplateRef } from "@angular/core";
2
+ import { DynamicFormTemplateService } from "../services/dynamic-form-template.service";
3
+ import { FormTemplateType } from "../common-types";
4
+ import * as i0 from "@angular/core";
5
+ export declare class DynamicFormTemplateDirective implements OnChanges, OnDestroy {
6
+ readonly templates: DynamicFormTemplateService;
7
+ readonly template: TemplateRef<any>;
8
+ control: string;
9
+ label: string;
10
+ input: string;
11
+ prefix: string;
12
+ suffix: string;
13
+ setPrefix: string;
14
+ setSuffix: string;
15
+ protected setting: [string, FormTemplateType];
16
+ constructor(templates: DynamicFormTemplateService, template: TemplateRef<any>);
17
+ ngOnChanges(): void;
18
+ ngOnDestroy(): void;
19
+ selectType(): [string, FormTemplateType];
20
+ static ɵfac: i0.ɵɵFactoryDeclaration<DynamicFormTemplateDirective, never>;
21
+ static ɵdir: i0.ɵɵDirectiveDeclaration<DynamicFormTemplateDirective, "ng-template[control], ng-template[label], ng-template[input], ng-template[prefix], ng-template[suffix], ng-template[setPrefix], ng-template[setSuffix]", never, { "control": { "alias": "control"; "required": false; }; "label": { "alias": "label"; "required": false; }; "input": { "alias": "input"; "required": false; }; "prefix": { "alias": "prefix"; "required": false; }; "suffix": { "alias": "suffix"; "required": false; }; "setPrefix": { "alias": "setPrefix"; "required": false; }; "setSuffix": { "alias": "setSuffix"; "required": false; }; }, {}, never, never, false, never>;
22
+ }
@@ -1,9 +1,9 @@
1
- import { AsyncSubmitDirective } from "./directives/async-submit.directive";
1
+ import { Type } from "@angular/core";
2
2
  import { DynamicFormComponent } from "./components/dynamic-form/dynamic-form.component";
3
3
  import { DynamicFormArrayComponent } from "./components/dynamic-form-array/dynamic-form-array.component";
4
4
  import { DynamicFormChipsComponent } from "./components/dynamic-form-chips/dynamic-form-chips.component";
5
5
  import { DynamicFormTranslationComponent } from "./components/dynamic-form-translation/dynamic-form-translation.component";
6
6
  import { DynamicFormAlertComponent } from "./components/dynamic-form-alert/dynamic-form-alert.component";
7
- export declare const components: (typeof DynamicFormComponent | typeof DynamicFormArrayComponent | typeof DynamicFormChipsComponent | typeof DynamicFormTranslationComponent | typeof DynamicFormAlertComponent)[];
8
- export declare const directives: (typeof AsyncSubmitDirective)[];
9
- export declare const pipes: any[];
7
+ export declare const components: (typeof DynamicFormArrayComponent | typeof DynamicFormComponent | typeof DynamicFormChipsComponent | typeof DynamicFormTranslationComponent | typeof DynamicFormAlertComponent)[];
8
+ export declare const directives: Type<any>[];
9
+ export declare const pipes: Type<any>[];
@@ -14,16 +14,18 @@ import * as i10 from "./components/dynamic-form-field/dynamic-form-field.compone
14
14
  import * as i11 from "./components/dynamic-form-fieldset/dynamic-form-fieldset.component";
15
15
  import * as i12 from "./components/dynamic-form-group/dynamic-form-group.component";
16
16
  import * as i13 from "./directives/async-submit.directive";
17
- import * as i14 from "@angular/common";
18
- import * as i15 from "@angular/forms";
19
- import * as i16 from "@stemy/ngx-utils";
20
- import * as i17 from "@ngx-formly/core";
21
- import * as i18 from "@ngx-formly/core/select";
17
+ import * as i14 from "./directives/dynamic-form-template.directive";
18
+ import * as i15 from "./pipes/dynamic-form-template.pipe";
19
+ import * as i16 from "@angular/common";
20
+ import * as i17 from "@angular/forms";
21
+ import * as i18 from "@stemy/ngx-utils";
22
+ import * as i19 from "@ngx-formly/core";
23
+ import * as i20 from "@ngx-formly/core/select";
22
24
  export declare class NgxDynamicFormModule {
23
25
  private static getProviders;
24
26
  static forRoot(config?: IDynamicFormModuleConfig): ModuleWithProviders<NgxDynamicFormModule>;
25
27
  static provideForms(config?: IDynamicFormModuleConfig): EnvironmentProviders;
26
28
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxDynamicFormModule, never>;
27
- static ɵmod: i0.ɵɵNgModuleDeclaration<NgxDynamicFormModule, [typeof i1.DynamicFieldType, typeof i2.DynamicFormComponent, typeof i3.DynamicFormArrayComponent, typeof i4.DynamicFormChipsComponent, typeof i5.DynamicFormStaticComponent, typeof i6.DynamicFormTranslationComponent, typeof i7.DynamicFormUploadComponent, typeof i8.DynamicFormWysiwygComponent, typeof i9.DynamicFormAlertComponent, typeof i10.DynamicFormFieldComponent, typeof i11.DynamicFormFieldsetComponent, typeof i12.DynamicFormGroupComponent, typeof i13.AsyncSubmitDirective], [typeof i14.CommonModule, typeof i15.FormsModule, typeof i15.ReactiveFormsModule, typeof i16.NgxUtilsModule, typeof i17.FormlyModule, typeof i18.FormlySelectModule], [typeof i1.DynamicFieldType, typeof i2.DynamicFormComponent, typeof i3.DynamicFormArrayComponent, typeof i4.DynamicFormChipsComponent, typeof i5.DynamicFormStaticComponent, typeof i6.DynamicFormTranslationComponent, typeof i7.DynamicFormUploadComponent, typeof i8.DynamicFormWysiwygComponent, typeof i9.DynamicFormAlertComponent, typeof i10.DynamicFormFieldComponent, typeof i11.DynamicFormFieldsetComponent, typeof i12.DynamicFormGroupComponent, typeof i13.AsyncSubmitDirective, typeof i15.FormsModule, typeof i15.ReactiveFormsModule, typeof i16.NgxUtilsModule, typeof i17.FormlyModule, typeof i18.FormlySelectModule]>;
29
+ static ɵmod: i0.ɵɵNgModuleDeclaration<NgxDynamicFormModule, [typeof i1.DynamicFieldType, typeof i2.DynamicFormComponent, typeof i3.DynamicFormArrayComponent, typeof i4.DynamicFormChipsComponent, typeof i5.DynamicFormStaticComponent, typeof i6.DynamicFormTranslationComponent, typeof i7.DynamicFormUploadComponent, typeof i8.DynamicFormWysiwygComponent, typeof i9.DynamicFormAlertComponent, typeof i10.DynamicFormFieldComponent, typeof i11.DynamicFormFieldsetComponent, typeof i12.DynamicFormGroupComponent, typeof i13.AsyncSubmitDirective, typeof i14.DynamicFormTemplateDirective, typeof i15.DynamicFormTemplatePipe], [typeof i16.CommonModule, typeof i17.FormsModule, typeof i17.ReactiveFormsModule, typeof i18.NgxUtilsModule, typeof i19.FormlyModule, typeof i20.FormlySelectModule], [typeof i1.DynamicFieldType, typeof i2.DynamicFormComponent, typeof i3.DynamicFormArrayComponent, typeof i4.DynamicFormChipsComponent, typeof i5.DynamicFormStaticComponent, typeof i6.DynamicFormTranslationComponent, typeof i7.DynamicFormUploadComponent, typeof i8.DynamicFormWysiwygComponent, typeof i9.DynamicFormAlertComponent, typeof i10.DynamicFormFieldComponent, typeof i11.DynamicFormFieldsetComponent, typeof i12.DynamicFormGroupComponent, typeof i13.AsyncSubmitDirective, typeof i14.DynamicFormTemplateDirective, typeof i15.DynamicFormTemplatePipe, typeof i17.FormsModule, typeof i17.ReactiveFormsModule, typeof i18.NgxUtilsModule, typeof i19.FormlyModule, typeof i20.FormlySelectModule]>;
28
30
  static ɵinj: i0.ɵɵInjectorDeclaration<NgxDynamicFormModule>;
29
31
  }
@@ -0,0 +1,18 @@
1
+ import { OnDestroy, OnInit, PipeTransform, TemplateRef } from "@angular/core";
2
+ import { Subscription } from "rxjs";
3
+ import { DynamicFormTemplateService } from "../services/dynamic-form-template.service";
4
+ import { FormFieldConfig, FormTemplateType } from "../common-types";
5
+ import * as i0 from "@angular/core";
6
+ export declare class DynamicFormTemplatePipe implements PipeTransform, OnInit, OnDestroy {
7
+ readonly templates: DynamicFormTemplateService;
8
+ protected templatesUpdated: Subscription;
9
+ protected cachedKey: string;
10
+ protected cachedType: FormTemplateType;
11
+ protected cachedTemplate: TemplateRef<any>;
12
+ constructor(templates: DynamicFormTemplateService);
13
+ ngOnInit(): void;
14
+ ngOnDestroy(): void;
15
+ transform(field: FormFieldConfig, type: FormTemplateType): TemplateRef<any>;
16
+ static ɵfac: i0.ɵɵFactoryDeclaration<DynamicFormTemplatePipe, never>;
17
+ static ɵpipe: i0.ɵɵPipeDeclaration<DynamicFormTemplatePipe, "dynamicFormTemplate", false>;
18
+ }
@@ -0,0 +1,21 @@
1
+ import { TemplateRef } from "@angular/core";
2
+ import { Subject } from "rxjs";
3
+ import { GlobalTemplateService } from "@stemy/ngx-utils";
4
+ import { FormTemplateType } from "../common-types";
5
+ import * as i0 from "@angular/core";
6
+ export declare class DynamicFormTemplateService {
7
+ protected readonly globalTemplates: GlobalTemplateService;
8
+ readonly templatesUpdated: Subject<void>;
9
+ protected templates: Map<FormTemplateType, Map<string, TemplateRef<any>>>;
10
+ protected globalTemplatePrefix: string;
11
+ get globalPrefix(): string;
12
+ set globalPrefix(value: string);
13
+ constructor(globalTemplates: GlobalTemplateService);
14
+ isValidType(type: string): boolean;
15
+ get(type: FormTemplateType, key: string): TemplateRef<any>;
16
+ protected getGlobalTemplate(type: FormTemplateType, key: string): TemplateRef<any>;
17
+ add(key: string, type: FormTemplateType, template: TemplateRef<any>): void;
18
+ remove(key: string, type: FormTemplateType): void;
19
+ static ɵfac: i0.ɵɵFactoryDeclaration<DynamicFormTemplateService, never>;
20
+ static ɵprov: i0.ɵɵInjectableDeclaration<DynamicFormTemplateService>;
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stemy/ngx-dynamic-form",
3
- "version": "19.8.15",
3
+ "version": "19.8.17",
4
4
  "license": "MIT",
5
5
  "public": true,
6
6
  "repository": "https://github.com/stemyke/ngx-dynamic-form.git",
package/public_api.d.ts CHANGED
@@ -1,14 +1,17 @@
1
- export { FORM_ROOT_ID, FormFieldKey, FormFieldLabelCustomizer, FormBuilderOptions, FormFieldArrayItemsAction, FormFieldProps, FormFieldSerializer, FormHookFn, FormHookConfig, FormFieldExpression, FormFieldExpressions, FormFieldConfig, FormFieldType, FormFieldChangeEvent, FormSerializeResult, FormSelectOption, FormSelectOptions, FormSelectOptionsFactory, FormFieldConditionFn, FormFieldCondition, IDynamicForm, ValidationMessageFn, ValidatorFn, ValidatorExpression, Validators, AsyncValidatorFn, AsyncValidatorExpression, AsyncValidators, AllValidationErrors, FormFieldCustom, FormFieldData, FormInputData, FormSelectData, FormStaticData, FormUploadData, FormGroupData, FormArrayData, FormSerializerData, FormFieldSetData, AsyncSubmitMode, AsyncSubmitMethod, FormFieldCustomizer, ConfigForSchemaOptions, DynamicFormStatus, DynamicFormUpdateOn, IDynamicFormModuleConfig, } from "./ngx-dynamic-form/common-types";
1
+ export { FORM_ROOT_ID, FormFieldKey, FormFieldLabelCustomizer, FormBuilderOptions, FormFieldArrayItemsAction, FormFieldProps, FormFieldSerializer, FormHookFn, FormHookConfig, FormFieldExpression, FormFieldExpressions, FormFieldConfig, FormFieldType, FormFieldChangeEvent, FormSerializeResult, FormSelectOption, FormSelectOptions, FormSelectOptionsFactory, FormFieldConditionFn, FormFieldCondition, IDynamicForm, ValidationMessageFn, ValidatorFn, ValidatorExpression, Validators, AsyncValidatorFn, AsyncValidatorExpression, AsyncValidators, AllValidationErrors, FormFieldCustom, FormFieldData, FormInputData, FormSelectData, FormStaticData, FormUploadData, FormGroupData, FormArrayData, FormSerializerData, FormFieldSetData, AsyncSubmitMode, AsyncSubmitMethod, FormTemplateType, FormFieldCustomizer, ConfigForSchemaOptions, DynamicFormStatus, DynamicFormUpdateOn, IDynamicFormModuleConfig, } from "./ngx-dynamic-form/common-types";
2
2
  export { IFormFieldCustomizer, customizeFormField } from "./ngx-dynamic-form/utils/customizer";
3
3
  export { FormInput, FormSelect, FormStatic, FormUpload, FormGroup, FormArray, FormSerializable, FormFieldSet } from "./ngx-dynamic-form/utils/decorators";
4
4
  export { addFieldValidators, removeFieldValidators, jsonValidation, requiredValidation, translationValidation, phoneValidation, emailValidation, arrayLengthValidation, minLengthValidation, maxLengthValidation, minValueValidation, maxValueValidation } from "./ngx-dynamic-form/utils/validation";
5
5
  export { replaceSpecialChars, controlValues, controlStatus, convertToDateFormat, convertToDate, convertToNumber, getFieldByPath, getFieldsByPredicate, getFieldsByKey, getSelectOptions, replaceFieldArray, clearFieldArray, insertToFieldArray, removeFromFieldArray, setFieldDefault, setFieldValue, setFieldProps, setFieldProp, setFieldSerialize, setFieldHidden, setFieldDisabled, setFieldHooks, isFieldVisible, isFieldHidden, MIN_INPUT_NUM, MAX_INPUT_NUM, EDITOR_FORMATS } from "./ngx-dynamic-form/utils/misc";
6
6
  export { RichTranslationModel } from "./ngx-dynamic-form/models/rich-translation.model";
7
7
  export { TranslationModel } from "./ngx-dynamic-form/models/translation.model";
8
+ export { DynamicFormService } from "./ngx-dynamic-form/services/dynamic-form.service";
8
9
  export { DynamicFormBuilderService } from "./ngx-dynamic-form/services/dynamic-form-builder.service";
9
10
  export { DynamicFormSchemaService } from "./ngx-dynamic-form/services/dynamic-form-schema.service";
10
- export { DynamicFormService } from "./ngx-dynamic-form/services/dynamic-form.service";
11
+ export { DynamicFormTemplateService } from "./ngx-dynamic-form/services/dynamic-form-template.service";
11
12
  export { AsyncSubmitDirective } from "./ngx-dynamic-form/directives/async-submit.directive";
13
+ export { DynamicFormTemplateDirective } from "./ngx-dynamic-form/directives/dynamic-form-template.directive";
14
+ export { DynamicFormTemplatePipe } from "./ngx-dynamic-form/pipes/dynamic-form-template.pipe";
12
15
  export { DynamicFieldType } from "./ngx-dynamic-form/components/base/dynamic-field-type";
13
16
  export { DynamicFormComponent } from "./ngx-dynamic-form/components/dynamic-form/dynamic-form.component";
14
17
  export { DynamicFormArrayComponent } from "./ngx-dynamic-form/components/dynamic-form-array/dynamic-form-array.component";