@suntelecoms/ngx-dynamic-form 1.3.1 → 1.4.0
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/README.md +202 -14
- package/fesm2022/suntelecoms-ngx-dynamic-form.mjs +282 -67
- package/fesm2022/suntelecoms-ngx-dynamic-form.mjs.map +1 -1
- package/lib/components/dynamic-field/dynamic-field.component.d.ts +5 -0
- package/lib/components/form-builder/form-builder.component.d.ts +12 -1
- package/lib/components/mes-formulaires/mes-formulaires.component.d.ts +3 -0
- package/lib/data/phone-countries.d.ts +8 -0
- package/lib/models/form-field.model.d.ts +7 -1
- package/lib/services/condition-evaluator.service.d.ts +0 -3
- package/lib/services/dynamic-form-builder.service.d.ts +1 -9
- package/lib/services/form-config.service.d.ts +3 -0
- package/lib/services/uniqueness-validator.service.d.ts +8 -0
- package/package.json +1 -1
- package/public-api.d.ts +3 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OnInit } from '@angular/core';
|
|
2
2
|
import { FormControl, FormGroup } from '@angular/forms';
|
|
3
3
|
import { DynamicFormField, SelectOption } from '../../models/form-field.model';
|
|
4
|
+
import { PhoneCountry } from '../../data/phone-countries';
|
|
4
5
|
import * as i0 from "@angular/core";
|
|
5
6
|
export declare class DynamicFieldComponent implements OnInit {
|
|
6
7
|
field: DynamicFormField;
|
|
@@ -21,8 +22,12 @@ export declare class DynamicFieldComponent implements OnInit {
|
|
|
21
22
|
loadingOptions: boolean;
|
|
22
23
|
locating: boolean;
|
|
23
24
|
locationError: string;
|
|
25
|
+
readonly phoneCountries: PhoneCountry[];
|
|
26
|
+
selectedPhoneCountry: PhoneCountry;
|
|
24
27
|
getLocation(): void;
|
|
25
28
|
private _geoError;
|
|
29
|
+
onPhoneSelectChange(event: Event): void;
|
|
30
|
+
applyPhoneMask(event: Event): void;
|
|
26
31
|
get hostStyle(): Record<string, string>;
|
|
27
32
|
get hostClass(): string;
|
|
28
33
|
ngOnInit(): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DynamicFormConfig, DynamicFormField, FieldType, FieldValidation, SelectOption, StepperFormConfig } from '../../models/form-field.model';
|
|
1
|
+
import type { DynamicFormConfig, DynamicFormField, FieldCondition, FieldType, FieldValidation, SelectOption, StepperFormConfig } from '../../models/form-field.model';
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
3
|
interface FieldTypeDef {
|
|
4
4
|
type: FieldType;
|
|
@@ -46,6 +46,7 @@ export declare class FormBuilderComponent {
|
|
|
46
46
|
value: string;
|
|
47
47
|
label: string;
|
|
48
48
|
}[];
|
|
49
|
+
readonly phoneCountries: import("@suntelecoms/ngx-dynamic-form").PhoneCountry[];
|
|
49
50
|
readonly fields: import("@angular/core").Signal<DynamicFormField[]>;
|
|
50
51
|
readonly selectedField: import("@angular/core").Signal<DynamicFormField | null>;
|
|
51
52
|
readonly previewConfig: import("@angular/core").Signal<DynamicFormConfig>;
|
|
@@ -77,6 +78,16 @@ export declare class FormBuilderComponent {
|
|
|
77
78
|
removeOption(idx: number): void;
|
|
78
79
|
setOptionsSource(useUrl: boolean): void;
|
|
79
80
|
private deleteProp;
|
|
81
|
+
setPattern(regex: string): void;
|
|
82
|
+
updateValidationMessage(key: keyof NonNullable<FieldValidation['messages']>, value: string): void;
|
|
83
|
+
getConditions(): FieldCondition[];
|
|
84
|
+
allFieldKeysExcludingCurrent(): string[];
|
|
85
|
+
setConditionLogic(logic: 'AND' | 'OR'): void;
|
|
86
|
+
addCondition(): void;
|
|
87
|
+
removeCondition(index: number): void;
|
|
88
|
+
updateCondition(index: number, key: keyof FieldCondition, value: any): void;
|
|
89
|
+
toggleUniqueCheck(enabled: boolean): void;
|
|
90
|
+
setUniqueCheckProp(key: 'url' | 'message', value: string): void;
|
|
80
91
|
/** Presets de masques de saisie courants */
|
|
81
92
|
readonly maskPresets: {
|
|
82
93
|
label: string;
|
|
@@ -9,7 +9,9 @@ export declare class MesFormulairesComponent {
|
|
|
9
9
|
/** Route du lien "Retour" */
|
|
10
10
|
backRoute: string;
|
|
11
11
|
private formService;
|
|
12
|
+
private snack;
|
|
12
13
|
readonly savedForms: import("@angular/core").Signal<SavedFormSchema[]>;
|
|
14
|
+
readonly loadError: import("@angular/core").WritableSignal<string | null>;
|
|
13
15
|
selectedId: import("@angular/core").WritableSignal<string | null>;
|
|
14
16
|
submitted: import("@angular/core").WritableSignal<boolean>;
|
|
15
17
|
submitData: import("@angular/core").WritableSignal<Record<string, unknown>>;
|
|
@@ -20,6 +22,7 @@ export declare class MesFormulairesComponent {
|
|
|
20
22
|
selectForm(id: string): void;
|
|
21
23
|
onSubmit(event: DynamicFormSubmitEvent): void;
|
|
22
24
|
resetForm(): void;
|
|
25
|
+
retry(): void;
|
|
23
26
|
deleteForm(id: string, e: Event): void;
|
|
24
27
|
formatDate(iso: string): string;
|
|
25
28
|
fieldCount(config: AnyFormConfig): number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type FieldType = 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'textarea' | 'select' | 'multiselect' | 'checkbox' | 'radio' | 'switch' | 'date' | 'datetime-local' | 'time' | 'month' | 'week' | 'range' | 'color' | 'location' | 'file' | 'hidden' | 'divider' | 'heading';
|
|
1
|
+
export type FieldType = 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'textarea' | 'select' | 'multiselect' | 'checkbox' | 'radio' | 'switch' | 'date' | 'datetime-local' | 'time' | 'month' | 'week' | 'range' | 'color' | 'location' | 'file' | 'hidden' | 'phone' | 'divider' | 'heading';
|
|
2
2
|
export interface SelectOption {
|
|
3
3
|
label: string;
|
|
4
4
|
value: any;
|
|
@@ -72,6 +72,12 @@ export interface DynamicFormField {
|
|
|
72
72
|
fontWeight?: 'normal' | 'bold';
|
|
73
73
|
fontStyle?: 'normal' | 'italic';
|
|
74
74
|
styles?: Record<string, string>;
|
|
75
|
+
conditionLogic?: 'AND' | 'OR';
|
|
76
|
+
uniqueCheck?: {
|
|
77
|
+
url: string;
|
|
78
|
+
message?: string;
|
|
79
|
+
};
|
|
80
|
+
defaultCountry?: string;
|
|
75
81
|
attrs?: Record<string, any>;
|
|
76
82
|
}
|
|
77
83
|
export interface DynamicFormConfig {
|
|
@@ -2,9 +2,6 @@ import { FormGroup } from '@angular/forms';
|
|
|
2
2
|
import { DynamicFormField } from '../models/form-field.model';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
4
|
export declare class ConditionEvaluatorService {
|
|
5
|
-
/**
|
|
6
|
-
* Evaluate whether a field should be visible based on its showWhen condition(s).
|
|
7
|
-
*/
|
|
8
5
|
isVisible(field: DynamicFormField, form: FormGroup): boolean;
|
|
9
6
|
private evaluate;
|
|
10
7
|
static ɵfac: i0.ɵɵFactoryDeclaration<ConditionEvaluatorService, never>;
|
|
@@ -2,17 +2,9 @@ import { AbstractControl, FormGroup, ValidatorFn } from '@angular/forms';
|
|
|
2
2
|
import { DynamicFormField, FieldValidation } from '../models/form-field.model';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
4
|
export declare class DynamicFormBuilderService {
|
|
5
|
-
|
|
6
|
-
* Build a FormGroup from an array of DynamicFormField definitions.
|
|
7
|
-
*/
|
|
5
|
+
private uniqueness;
|
|
8
6
|
buildFormGroup(fields: DynamicFormField[]): FormGroup;
|
|
9
|
-
/**
|
|
10
|
-
* Convert FieldValidation config into Angular ValidatorFn[].
|
|
11
|
-
*/
|
|
12
7
|
buildValidators(validation?: FieldValidation): ValidatorFn[];
|
|
13
|
-
/**
|
|
14
|
-
* Get the human-readable error message for a form control.
|
|
15
|
-
*/
|
|
16
8
|
getErrorMessage(control: AbstractControl, validation?: FieldValidation): string | null;
|
|
17
9
|
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicFormBuilderService, never>;
|
|
18
10
|
static ɵprov: i0.ɵɵInjectableDeclaration<DynamicFormBuilderService>;
|
|
@@ -5,7 +5,10 @@ export declare class FormConfigService {
|
|
|
5
5
|
private adapter;
|
|
6
6
|
private _schemas;
|
|
7
7
|
readonly schemas: import("@angular/core").Signal<SavedFormSchema[]>;
|
|
8
|
+
readonly loadError: import("@angular/core").WritableSignal<string | null>;
|
|
8
9
|
constructor();
|
|
10
|
+
reload(): void;
|
|
11
|
+
private _load;
|
|
9
12
|
get(id: string): SavedFormSchema | null;
|
|
10
13
|
getByCode(code: string): SavedFormSchema | null;
|
|
11
14
|
create(code: string, title: string, config: AnyFormConfig): Observable<SavedFormSchema>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AsyncValidatorFn } from '@angular/forms';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class UniquenessValidatorService {
|
|
4
|
+
private http;
|
|
5
|
+
build(url: string, message?: string): AsyncValidatorFn;
|
|
6
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<UniquenessValidatorService, never>;
|
|
7
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<UniquenessValidatorService>;
|
|
8
|
+
}
|
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { FormLoaderComponent } from './lib/components/form-loader/form-loader.co
|
|
|
7
7
|
export { DynamicFormBuilderService } from './lib/services/dynamic-form-builder.service';
|
|
8
8
|
export { ConditionEvaluatorService } from './lib/services/condition-evaluator.service';
|
|
9
9
|
export { FormConfigService } from './lib/services/form-config.service';
|
|
10
|
+
export { UniquenessValidatorService } from './lib/services/uniqueness-validator.service';
|
|
10
11
|
export { FormStorageAdapter } from './lib/storage/form-storage.adapter';
|
|
11
12
|
export { LocalStorageAdapter } from './lib/storage/local-storage.adapter';
|
|
12
13
|
export { HttpStorageAdapter, FORM_API_URL } from './lib/storage/http-storage.adapter';
|
|
@@ -16,3 +17,5 @@ export { NgxFormsAuthService, NGX_FORMS_AUTH } from './lib/auth/ngx-forms-auth.s
|
|
|
16
17
|
export type { NgxFormsAuthOptions } from './lib/auth/ngx-forms-auth.service';
|
|
17
18
|
export type { DynamicFormField, DynamicFormConfig, StepperFormConfig, FormStep, DynamicFormSubmitEvent, FieldType, FieldValidation, FieldCondition, SelectOption, } from './lib/models/form-field.model';
|
|
18
19
|
export type { SavedFormSchema, AnyFormConfig } from './lib/models/saved-form.model';
|
|
20
|
+
export type { PhoneCountry } from './lib/data/phone-countries';
|
|
21
|
+
export { PHONE_COUNTRIES } from './lib/data/phone-countries';
|