@suntelecoms/ngx-dynamic-form 1.6.5 → 1.7.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 +57 -3
- package/fesm2022/suntelecoms-ngx-dynamic-form.mjs +115 -21
- package/fesm2022/suntelecoms-ngx-dynamic-form.mjs.map +1 -1
- package/lib/components/dynamic-field/dynamic-field.component.d.ts +8 -0
- package/lib/components/form-builder/form-builder.component.d.ts +5 -1
- package/lib/components/form-loader/form-loader.component.d.ts +1 -0
- package/lib/models/form-field.model.d.ts +5 -0
- package/lib/providers.d.ts +7 -0
- package/lib/services/dynamic-form-builder.service.d.ts +1 -0
- package/lib/services/form-config.service.d.ts +13 -0
- package/lib/storage/http-storage.adapter.d.ts +6 -0
- package/package.json +1 -1
- package/public-api.d.ts +1 -1
|
@@ -70,6 +70,14 @@ export declare class DynamicFieldComponent implements OnInit {
|
|
|
70
70
|
get hasOptions(): boolean;
|
|
71
71
|
get hasError(): boolean;
|
|
72
72
|
get errorMessage(): string | null;
|
|
73
|
+
/** field.minDate/maxDate ('today' or an ISO 'YYYY-MM-DD' string) resolved to a Date, for the mat-datepicker's [min]/[max]. */
|
|
74
|
+
get minDate(): Date | undefined;
|
|
75
|
+
get maxDate(): Date | undefined;
|
|
76
|
+
/** Same bound, as 'YYYY-MM-DD' for the native <input type="date"> min/max attributes (simple appearance). */
|
|
77
|
+
get minDateAttr(): string | undefined;
|
|
78
|
+
get maxDateAttr(): string | undefined;
|
|
79
|
+
private resolveFieldDate;
|
|
80
|
+
private toIsoDateString;
|
|
73
81
|
private setupRequiredWhen;
|
|
74
82
|
private updateRequiredFromConditions;
|
|
75
83
|
onLookupBlur(): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DynamicFormConfig, DynamicFormField, FieldCondition, FieldType, FieldValidation, SelectOption, StepGuard, StepperFormConfig } from '../../models/form-field.model';
|
|
2
|
+
import type { SavedFormSchema } from '../../models/saved-form.model';
|
|
2
3
|
import * as i0 from "@angular/core";
|
|
3
4
|
interface FieldTypeDef {
|
|
4
5
|
type: FieldType;
|
|
@@ -22,6 +23,8 @@ export declare class FormBuilderComponent {
|
|
|
22
23
|
backRoute: string;
|
|
23
24
|
private formService;
|
|
24
25
|
private snack;
|
|
26
|
+
private route;
|
|
27
|
+
constructor();
|
|
25
28
|
isStepperMode: import("@angular/core").WritableSignal<boolean>;
|
|
26
29
|
private flatFields;
|
|
27
30
|
steps: import("@angular/core").WritableSignal<BuilderStep[]>;
|
|
@@ -43,7 +46,7 @@ export declare class FormBuilderComponent {
|
|
|
43
46
|
currentId: import("@angular/core").WritableSignal<string | null>;
|
|
44
47
|
showExport: import("@angular/core").WritableSignal<boolean>;
|
|
45
48
|
exportContent: import("@angular/core").WritableSignal<string>;
|
|
46
|
-
savedSchemas: import("@angular/core").Signal<
|
|
49
|
+
savedSchemas: import("@angular/core").Signal<SavedFormSchema[]>;
|
|
47
50
|
readonly groups: readonly ["Saisie", "Choix", "Mise en page"];
|
|
48
51
|
readonly fieldTypes: FieldTypeDef[];
|
|
49
52
|
readonly colOptions: readonly [1, 2, 3, 4, 6, 8, 9, 12];
|
|
@@ -129,6 +132,7 @@ export declare class FormBuilderComponent {
|
|
|
129
132
|
cancelRename(): void;
|
|
130
133
|
save(): void;
|
|
131
134
|
loadSchema(id: string): void;
|
|
135
|
+
private applySchema;
|
|
132
136
|
deleteSchema(id: string, e: Event): void;
|
|
133
137
|
newForm(): void;
|
|
134
138
|
exportJSON(): void;
|
|
@@ -19,6 +19,7 @@ export declare class FormLoaderComponent implements OnInit {
|
|
|
19
19
|
submitted: import("@angular/core").WritableSignal<boolean>;
|
|
20
20
|
submitData: import("@angular/core").WritableSignal<Record<string, unknown>>;
|
|
21
21
|
notFound: import("@angular/core").WritableSignal<boolean>;
|
|
22
|
+
loading: import("@angular/core").WritableSignal<boolean>;
|
|
22
23
|
ngOnInit(): void;
|
|
23
24
|
onSubmit(event: DynamicFormSubmitEvent): void;
|
|
24
25
|
reset(): void;
|
|
@@ -36,6 +36,9 @@ export interface FieldValidation {
|
|
|
36
36
|
email?: string;
|
|
37
37
|
maxField?: string;
|
|
38
38
|
minField?: string;
|
|
39
|
+
/** type: 'date' — shown when the value is before field.minDate / after field.maxDate */
|
|
40
|
+
minDate?: string;
|
|
41
|
+
maxDate?: string;
|
|
39
42
|
};
|
|
40
43
|
}
|
|
41
44
|
/** Auto-populate sibling fields from an API call when this field loses focus */
|
|
@@ -88,6 +91,8 @@ export interface DynamicFormField {
|
|
|
88
91
|
accept?: string;
|
|
89
92
|
multiple?: boolean;
|
|
90
93
|
rows?: number;
|
|
94
|
+
minDate?: string;
|
|
95
|
+
maxDate?: string;
|
|
91
96
|
min?: number;
|
|
92
97
|
max?: number;
|
|
93
98
|
step?: number;
|
package/lib/providers.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EnvironmentProviders, InjectionToken } from '@angular/core';
|
|
2
2
|
import { HttpInterceptorFn } from '@angular/common/http';
|
|
3
|
+
import { NGX_FORMS_LIST_PAGE_SIZE } from './storage/http-storage.adapter';
|
|
3
4
|
import { NgxFormsAuthService, NgxFormsAuthOptions, NGX_FORMS_AUTH } from './auth/ngx-forms-auth.service';
|
|
4
5
|
export { NgxFormsAuthService, NgxFormsAuthOptions, NGX_FORMS_AUTH };
|
|
5
6
|
/**
|
|
@@ -7,6 +8,7 @@ export { NgxFormsAuthService, NgxFormsAuthOptions, NGX_FORMS_AUTH };
|
|
|
7
8
|
* via la propriété `url` d'un DynamicFormField.
|
|
8
9
|
*/
|
|
9
10
|
export declare const NGX_DATA_API_URL: InjectionToken<string>;
|
|
11
|
+
export { NGX_FORMS_LIST_PAGE_SIZE };
|
|
10
12
|
/**
|
|
11
13
|
* Intercepteur HTTP fonctionnel — ajoute `Authorization: Bearer <token>` si
|
|
12
14
|
* NgxFormsAuthService est fourni (via `auth` dans provideNgxForms).
|
|
@@ -30,6 +32,11 @@ export interface NgxFormsHttpOptions {
|
|
|
30
32
|
dataUrl?: string;
|
|
31
33
|
/** Configuration d'authentification par token (optionnel) */
|
|
32
34
|
auth?: NgxFormsAuthOptions;
|
|
35
|
+
/**
|
|
36
|
+
* Taille de page pour charger le catalogue de formulaires sauvegardés
|
|
37
|
+
* (`GET {apiUrl}?page=0&size=...`). @default 1000
|
|
38
|
+
*/
|
|
39
|
+
listPageSize?: number;
|
|
33
40
|
}
|
|
34
41
|
export type NgxFormsOptions = NgxFormsLocalOptions | NgxFormsHttpOptions;
|
|
35
42
|
export declare function provideNgxForms(options: NgxFormsOptions): EnvironmentProviders;
|
|
@@ -8,6 +8,7 @@ export declare class DynamicFormBuilderService {
|
|
|
8
8
|
buildGroupValidators(fields: DynamicFormField[], atLeastOneOf?: string[], atLeastOneOfMessage?: string): ValidatorFn[];
|
|
9
9
|
buildValidators(validation?: FieldValidation): ValidatorFn[];
|
|
10
10
|
getErrorMessage(control: AbstractControl, validation?: FieldValidation): string | null;
|
|
11
|
+
private formatDateFr;
|
|
11
12
|
/**
|
|
12
13
|
* Cross-field bound validator: sets an error on `fieldKey` when:
|
|
13
14
|
* mode 'max': field value > other field value
|
|
@@ -11,6 +11,19 @@ export declare class FormConfigService {
|
|
|
11
11
|
private _load;
|
|
12
12
|
get(id: string): SavedFormSchema | null;
|
|
13
13
|
getByCode(code: string): SavedFormSchema | null;
|
|
14
|
+
/**
|
|
15
|
+
* Charge un seul formulaire directement depuis l'API (GET {apiUrl}/{id}),
|
|
16
|
+
* sans dépendre de la liste complète chargée en mémoire — à utiliser à la
|
|
17
|
+
* place de `get()` dès qu'on n'a besoin que d'un seul formulaire (au-delà
|
|
18
|
+
* d'une poignée de dizaines de formulaires, tout charger pour n'en lire
|
|
19
|
+
* qu'un devient inutilement coûteux). Met aussi à jour le cache local
|
|
20
|
+
* (`schemas()`) au passage, pour que les lectures synchrones ultérieures
|
|
21
|
+
* en bénéficient également.
|
|
22
|
+
*/
|
|
23
|
+
fetchById(id: string): Observable<SavedFormSchema | null>;
|
|
24
|
+
/** Équivalent de `fetchById`, mais par `code` (GET {apiUrl}/code/{code}). */
|
|
25
|
+
fetchByCode(code: string): Observable<SavedFormSchema | null>;
|
|
26
|
+
private cacheOne;
|
|
14
27
|
create(code: string, title: string, config: AnyFormConfig): Observable<SavedFormSchema>;
|
|
15
28
|
update(schema: SavedFormSchema, title: string, config: AnyFormConfig): Observable<SavedFormSchema>;
|
|
16
29
|
delete(id: string): Observable<void>;
|
|
@@ -4,9 +4,15 @@ import { FormStorageAdapter } from './form-storage.adapter';
|
|
|
4
4
|
import type { SavedFormSchema } from '../models/saved-form.model';
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
6
|
export declare const FORM_API_URL: InjectionToken<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Taille de page pour `list()` (`GET {apiUrl}?page=0&size=...`).
|
|
9
|
+
* Configurable via `listPageSize` dans `provideNgxForms()` — @default 1000.
|
|
10
|
+
*/
|
|
11
|
+
export declare const NGX_FORMS_LIST_PAGE_SIZE: InjectionToken<number>;
|
|
7
12
|
export declare class HttpStorageAdapter extends FormStorageAdapter {
|
|
8
13
|
private http;
|
|
9
14
|
private apiUrl;
|
|
15
|
+
private pageSize;
|
|
10
16
|
/** Mappe le format API vers SavedFormSchema */
|
|
11
17
|
private toSchema;
|
|
12
18
|
list(): Observable<SavedFormSchema[]>;
|
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { FormConfigService } from './lib/services/form-config.service';
|
|
|
10
10
|
export { UniquenessValidatorService } from './lib/services/uniqueness-validator.service';
|
|
11
11
|
export { FormStorageAdapter } from './lib/storage/form-storage.adapter';
|
|
12
12
|
export { LocalStorageAdapter } from './lib/storage/local-storage.adapter';
|
|
13
|
-
export { HttpStorageAdapter, FORM_API_URL } from './lib/storage/http-storage.adapter';
|
|
13
|
+
export { HttpStorageAdapter, FORM_API_URL, NGX_FORMS_LIST_PAGE_SIZE } from './lib/storage/http-storage.adapter';
|
|
14
14
|
export { provideNgxForms, NGX_DATA_API_URL, ngxFormsAuthInterceptor } from './lib/providers';
|
|
15
15
|
export type { NgxFormsOptions, NgxFormsLocalOptions, NgxFormsHttpOptions } from './lib/providers';
|
|
16
16
|
export { NgxFormsAuthService, NGX_FORMS_AUTH } from './lib/auth/ngx-forms-auth.service';
|