@suntelecoms/ngx-dynamic-form 1.7.4 → 1.7.10

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.
@@ -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,19 @@ export declare class DynamicFieldComponent implements OnInit {
19
20
  private evaluator;
20
21
  private http;
21
22
  private dataApiUrl;
23
+ private globalDateLocale;
24
+ private dateAdapter;
25
+ private cdr;
22
26
  resolvedOptions: SelectOption[];
23
27
  loadingOptions: boolean;
24
28
  lookupLoading: boolean;
29
+ /** Texte affiché/tapé dans le champ — distinct de `formControl`, qui reçoit
30
+ * la valeur sélectionnée (opt.value) plutôt que le texte de recherche. */
31
+ searchDisplayControl: FormControl<string | null>;
32
+ private remoteSearch$;
33
+ get remoteSearchHasEnoughChars(): boolean;
34
+ displayRemoteOption: (value: SelectOption | string | null) => string;
35
+ onRemoteOptionSelected(event: MatAutocompleteSelectedEvent): void;
25
36
  /** Emitted on every value change of this field */
26
37
  fieldChange: EventEmitter<{
27
38
  key: string;
@@ -51,6 +62,13 @@ export declare class DynamicFieldComponent implements OnInit {
51
62
  private applyClientFilter;
52
63
  /** Remplace les `{{cléDeChamp}}` d'une URL par la valeur courante du champ correspondant dans ce formulaire. */
53
64
  private interpolateUrl;
65
+ /** Câble la recherche distante debouncée (field.remoteSearch) : ne charge rien
66
+ * tant que l'utilisateur ne tape pas, contrairement à `resolveOptions()`. */
67
+ private setupRemoteSearch;
68
+ private fetchRemoteSearch;
69
+ /** Applique field.optionsFilter (ex: ne garder que status === 'ACTIF') aux items bruts
70
+ * reçus de l'API, avant leur mapping en {label, value}. No-op si non configuré. */
71
+ private filterItems;
54
72
  /** @param cacheRaw Conserve la réponse brute dans `rawRemoteItems` pour un filtrage local ultérieur, au lieu de la mapper directement dans `resolvedOptions`. */
55
73
  private loadRemoteOptions;
56
74
  /**
@@ -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;
@@ -94,6 +95,11 @@ export declare class FormBuilderComponent {
94
95
  addCondition(): void;
95
96
  removeCondition(index: number): void;
96
97
  updateCondition(index: number, key: keyof FieldCondition, value: any): void;
98
+ getOptionsFilterConditions(): FieldCondition[];
99
+ setOptionsFilterLogic(logic: 'AND' | 'OR'): void;
100
+ addOptionsFilterCondition(): void;
101
+ removeOptionsFilterCondition(index: number): void;
102
+ updateOptionsFilterCondition(index: number, key: keyof FieldCondition, value: any): void;
97
103
  toggleUniqueCheck(enabled: boolean): void;
98
104
  setUniqueCheckProp(key: 'url' | 'message', value: string): void;
99
105
  toggleLookup(enabled: boolean): void;
@@ -12,6 +12,8 @@ export declare class MesFormulairesComponent {
12
12
  private snack;
13
13
  readonly savedForms: import("@angular/core").Signal<SavedFormSchema[]>;
14
14
  readonly loadError: import("@angular/core").WritableSignal<string | null>;
15
+ searchTerm: import("@angular/core").WritableSignal<string>;
16
+ filteredForms: import("@angular/core").Signal<SavedFormSchema[]>;
15
17
  selectedId: import("@angular/core").WritableSignal<string | null>;
16
18
  submitted: import("@angular/core").WritableSignal<boolean>;
17
19
  submitData: import("@angular/core").WritableSignal<Record<string, unknown>>;
@@ -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,14 @@ 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;
103
+ /** Filtre les items reçus de `url` avant leur mapping en {label, value} (ex: ne garder que
104
+ * status === 'ACTIF'). Même forme que showWhen, mais évalué contre les propriétés BRUTES
105
+ * de chaque item API (ex: item.status) — pas les valeurs d'un autre champ du formulaire. */
106
+ optionsFilter?: FieldCondition | FieldCondition[];
107
+ /** Logique entre les conditions de optionsFilter (indépendante de conditionLogic, qui régit showWhen/requiredWhen). @default 'AND' */
108
+ optionsFilterLogic?: 'AND' | 'OR';
88
109
  col?: 1 | 2 | 3 | 4 | 6 | 8 | 9 | 12;
89
110
  cssClass?: string;
90
111
  showWhen?: FieldCondition | FieldCondition[];
@@ -94,6 +115,7 @@ export interface DynamicFormField {
94
115
  rows?: number;
95
116
  minDate?: string;
96
117
  maxDate?: string;
118
+ dateLocale?: string;
97
119
  min?: number;
98
120
  max?: number;
99
121
  step?: number;
@@ -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
@@ -4,6 +4,12 @@ import * as i0 from "@angular/core";
4
4
  export declare class ConditionEvaluatorService {
5
5
  isVisible(field: DynamicFormField, form: FormGroup): boolean;
6
6
  evaluate(condition: FieldCondition, form: FormGroup): boolean;
7
+ /** Comme evaluate(), mais contre les propriétés d'un objet brut (ex: un item de réponse API)
8
+ * plutôt que les valeurs d'un FormGroup — utilisé par optionsFilter. */
9
+ evaluateItem(condition: FieldCondition, item: Record<string, any>): boolean;
10
+ /** condition(s) + logique ET/OU, contre un item brut — voir optionsFilter sur DynamicFormField. */
11
+ matchesItem(conditions: FieldCondition | FieldCondition[], logic: 'AND' | 'OR' | undefined, item: Record<string, any>): boolean;
12
+ private compare;
7
13
  static ɵfac: i0.ɵɵFactoryDeclaration<ConditionEvaluatorService, never>;
8
14
  static ɵprov: i0.ɵɵInjectableDeclaration<ConditionEvaluatorService>;
9
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suntelecoms/ngx-dynamic-form",
3
- "version": "1.7.4",
3
+ "version": "1.7.10",
4
4
  "description": "Générateur de formulaires Angular dynamiques — SUNTELECOMS",
5
5
  "author": "Amadou Diallo <amadoumacbookpro38@gmail.com>",
6
6
  "license": "MIT",