@suntelecoms/ngx-dynamic-form 1.7.4 → 1.7.7
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 -2
- package/fesm2022/suntelecoms-ngx-dynamic-form.mjs +165 -11
- package/fesm2022/suntelecoms-ngx-dynamic-form.mjs.map +1 -1
- package/lib/components/dynamic-field/dynamic-field.component.d.ts +14 -0
- package/lib/components/form-builder/form-builder.component.d.ts +2 -1
- package/lib/models/form-field.model.d.ts +16 -0
- package/lib/providers.d.ts +12 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventEmitter, OnInit } from '@angular/core';
|
|
2
2
|
import { FormControl, FormGroup } from '@angular/forms';
|
|
3
|
+
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
|
3
4
|
import { DynamicFormField, SelectOption } from '../../models/form-field.model';
|
|
4
5
|
import { PhoneCountry } from '../../data/phone-countries';
|
|
5
6
|
import * as i0 from "@angular/core";
|
|
@@ -19,9 +20,18 @@ export declare class DynamicFieldComponent implements OnInit {
|
|
|
19
20
|
private evaluator;
|
|
20
21
|
private http;
|
|
21
22
|
private dataApiUrl;
|
|
23
|
+
private globalDateLocale;
|
|
24
|
+
private dateAdapter;
|
|
22
25
|
resolvedOptions: SelectOption[];
|
|
23
26
|
loadingOptions: boolean;
|
|
24
27
|
lookupLoading: boolean;
|
|
28
|
+
/** Texte affiché/tapé dans le champ — distinct de `formControl`, qui reçoit
|
|
29
|
+
* la valeur sélectionnée (opt.value) plutôt que le texte de recherche. */
|
|
30
|
+
searchDisplayControl: FormControl<string | null>;
|
|
31
|
+
private remoteSearch$;
|
|
32
|
+
get remoteSearchHasEnoughChars(): boolean;
|
|
33
|
+
displayRemoteOption: (value: SelectOption | string | null) => string;
|
|
34
|
+
onRemoteOptionSelected(event: MatAutocompleteSelectedEvent): void;
|
|
25
35
|
/** Emitted on every value change of this field */
|
|
26
36
|
fieldChange: EventEmitter<{
|
|
27
37
|
key: string;
|
|
@@ -51,6 +61,10 @@ export declare class DynamicFieldComponent implements OnInit {
|
|
|
51
61
|
private applyClientFilter;
|
|
52
62
|
/** Remplace les `{{cléDeChamp}}` d'une URL par la valeur courante du champ correspondant dans ce formulaire. */
|
|
53
63
|
private interpolateUrl;
|
|
64
|
+
/** Câble la recherche distante debouncée (field.remoteSearch) : ne charge rien
|
|
65
|
+
* tant que l'utilisateur ne tape pas, contrairement à `resolveOptions()`. */
|
|
66
|
+
private setupRemoteSearch;
|
|
67
|
+
private fetchRemoteSearch;
|
|
54
68
|
/** @param cacheRaw Conserve la réponse brute dans `rawRemoteItems` pour un filtrage local ultérieur, au lieu de la mapper directement dans `resolvedOptions`. */
|
|
55
69
|
private loadRemoteOptions;
|
|
56
70
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DynamicFormConfig, DynamicFormField, FieldCondition, FieldType, FieldValidation, SelectOption, StepGuard, StepperFormConfig } from '../../models/form-field.model';
|
|
1
|
+
import type { DynamicFormConfig, DynamicFormField, FieldCondition, FieldType, FieldValidation, RemoteSearchConfig, SelectOption, StepGuard, StepperFormConfig } from '../../models/form-field.model';
|
|
2
2
|
import type { SavedFormSchema } from '../../models/saved-form.model';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
4
|
interface FieldTypeDef {
|
|
@@ -79,6 +79,7 @@ export declare class FormBuilderComponent {
|
|
|
79
79
|
selectField(i: number): void;
|
|
80
80
|
duplicateField(i: number, e: Event): void;
|
|
81
81
|
updateProp(prop: keyof DynamicFormField, value: any): void;
|
|
82
|
+
updateRemoteSearch(prop: keyof RemoteSearchConfig, value: any): void;
|
|
82
83
|
updateValidation(prop: keyof FieldValidation, value: any): void;
|
|
83
84
|
getOptions(): SelectOption[];
|
|
84
85
|
addOption(): void;
|
|
@@ -51,6 +51,19 @@ export interface FieldLookup {
|
|
|
51
51
|
/** @default 'blur' */
|
|
52
52
|
triggerOn?: 'blur' | 'change';
|
|
53
53
|
}
|
|
54
|
+
/** type: 'select' + remoteSearch — turns an eager `url`-loaded select into a
|
|
55
|
+
* debounced remote-search typeahead: the field's `url` is called with the
|
|
56
|
+
* typed text as a query param instead of loading every option upfront. */
|
|
57
|
+
export interface RemoteSearchConfig {
|
|
58
|
+
/** Query param name the typed text is sent under. @default 'q' */
|
|
59
|
+
paramName?: string;
|
|
60
|
+
/** Minimum characters typed before firing a request. @default 3 */
|
|
61
|
+
minChars?: number;
|
|
62
|
+
/** Debounce delay in ms after the user stops typing. @default 300 */
|
|
63
|
+
debounceMs?: number;
|
|
64
|
+
/** Extra static query params sent on every request (e.g. { size: 20 }). */
|
|
65
|
+
params?: Record<string, string | number>;
|
|
66
|
+
}
|
|
54
67
|
/** Async guard executed before advancing to the next stepper step */
|
|
55
68
|
export interface StepGuard {
|
|
56
69
|
url: string;
|
|
@@ -85,6 +98,8 @@ export interface DynamicFormField {
|
|
|
85
98
|
validation?: FieldValidation;
|
|
86
99
|
/** On blur: call lookup.url and patch sibling fields from the response */
|
|
87
100
|
lookup?: FieldLookup;
|
|
101
|
+
/** type: 'select' only — remote-search typeahead instead of eager-loading `url`. */
|
|
102
|
+
remoteSearch?: RemoteSearchConfig;
|
|
88
103
|
col?: 1 | 2 | 3 | 4 | 6 | 8 | 9 | 12;
|
|
89
104
|
cssClass?: string;
|
|
90
105
|
showWhen?: FieldCondition | FieldCondition[];
|
|
@@ -94,6 +109,7 @@ export interface DynamicFormField {
|
|
|
94
109
|
rows?: number;
|
|
95
110
|
minDate?: string;
|
|
96
111
|
maxDate?: string;
|
|
112
|
+
dateLocale?: string;
|
|
97
113
|
min?: number;
|
|
98
114
|
max?: number;
|
|
99
115
|
step?: number;
|
package/lib/providers.d.ts
CHANGED
|
@@ -8,6 +8,14 @@ export { NgxFormsAuthService, NgxFormsAuthOptions, NGX_FORMS_AUTH };
|
|
|
8
8
|
* via la propriété `url` d'un DynamicFormField.
|
|
9
9
|
*/
|
|
10
10
|
export declare const NGX_DATA_API_URL: InjectionToken<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Locale utilisée par le DateAdapter natif pour l'affichage des champs `type: 'date'`
|
|
13
|
+
* (format du texte tapé/affiché + noms de mois/jours du calendrier). Une locale plutôt
|
|
14
|
+
* qu'un motif de format arbitraire : réutilise le formatage Intl natif du navigateur,
|
|
15
|
+
* pas de nouveau parseur de format à maintenir. Surchargeable par champ via
|
|
16
|
+
* `DynamicFormField.dateLocale`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const NGX_DATE_LOCALE: InjectionToken<string>;
|
|
11
19
|
export { NGX_FORMS_LIST_PAGE_SIZE };
|
|
12
20
|
/**
|
|
13
21
|
* Intercepteur HTTP fonctionnel — ajoute `Authorization: Bearer <token>` si
|
|
@@ -23,6 +31,8 @@ export interface NgxFormsLocalOptions {
|
|
|
23
31
|
dataUrl?: string;
|
|
24
32
|
/** Configuration d'authentification par token (optionnel) */
|
|
25
33
|
auth?: NgxFormsAuthOptions;
|
|
34
|
+
/** Locale par défaut des champs `type: 'date'` (ex: 'fr-FR', 'en-US'). @default 'fr-FR' */
|
|
35
|
+
dateLocale?: string;
|
|
26
36
|
}
|
|
27
37
|
export interface NgxFormsHttpOptions {
|
|
28
38
|
storage: 'http';
|
|
@@ -32,6 +42,8 @@ export interface NgxFormsHttpOptions {
|
|
|
32
42
|
dataUrl?: string;
|
|
33
43
|
/** Configuration d'authentification par token (optionnel) */
|
|
34
44
|
auth?: NgxFormsAuthOptions;
|
|
45
|
+
/** Locale par défaut des champs `type: 'date'` (ex: 'fr-FR', 'en-US'). @default 'fr-FR' */
|
|
46
|
+
dateLocale?: string;
|
|
35
47
|
/**
|
|
36
48
|
* Taille de page pour charger le catalogue de formulaires sauvegardés
|
|
37
49
|
* (`GET {apiUrl}?page=0&size=...`). @default 1000
|
package/package.json
CHANGED