@suntelecoms/ngx-dynamic-form 1.1.3 → 1.2.3

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 CHANGED
@@ -1,10 +1,10 @@
1
1
  # @suntelecoms/ngx-dynamic-form
2
2
 
3
- > Génère des formulaires Angular complexes à partir d'une configuration TypeScript — sans écrire une ligne de template HTML. Inclut un Form Builder visuel, la gestion des schémas sauvegardés et un système de stockage interchangeable (localStorage / API REST).
3
+ > Génère des formulaires Angular complexes à partir d'une configuration TypeScript — sans écrire une ligne de template HTML. Inclut un Form Builder visuel, la gestion des schémas sauvegardés, un système de stockage interchangeable (localStorage / API REST) et le support des formulaires **multi-étapes (Stepper)**.
4
4
 
5
5
  [![Angular](https://img.shields.io/badge/Angular-19-red?logo=angular)](https://angular.dev)
6
6
  [![Angular Material](https://img.shields.io/badge/Angular_Material-19-blue?logo=material-design)](https://material.angular.io)
7
- [![Version](https://img.shields.io/badge/version-1.1.0-brightgreen)](CHANGELOG.md)
7
+ [![Version](https://img.shields.io/badge/version-1.2.3-brightgreen)](CHANGELOG.md)
8
8
  [![License](https://img.shields.io/badge/License-MIT-green)](LICENSE)
9
9
  [![Author](https://img.shields.io/badge/Author-Amadou%20Diallo-purple)](mailto:amadoumacbookpro38@gmail.com)
10
10
 
@@ -25,6 +25,7 @@
25
25
  - [Icônes (Material Icons)](#icônes-material-icons)
26
26
  - [Disposition en grille (col)](#disposition-en-grille-col)
27
27
  - [API du composant DynamicForm](#api-du-composant-dynamicform)
28
+ - [Formulaires multi-étapes — Stepper](#formulaires-multi-étapes--stepper)
28
29
  - [provideNgxForms — configuration globale](#providengxforms--configuration-globale)
29
30
  - [FormConfigService — gestion des schémas](#formconfigservice--gestion-des-schémas)
30
31
  - [Stockage — LocalStorage vs API REST](#stockage--localstorage-vs-api-rest)
@@ -43,11 +44,12 @@
43
44
 
44
45
  **@suntelecoms/ngx-dynamic-form** est un plugin Angular 19 qui génère des formulaires réactifs dynamiquement à partir d'un objet de configuration TypeScript. Il s'appuie sur **Angular Reactive Forms** et **Angular Material**.
45
46
 
46
- Depuis la **v1.1.0**, le plugin embarque directement :
47
- - Le **Form Builder visuel** (`<ngx-form-builder>`)
47
+ Depuis la **v1.2.0**, le plugin embarque :
48
+ - Le **Form Builder visuel** (`<ngx-form-builder>`) — avec mode **Stepper**
48
49
  - Le **gestionnaire de formulaires** (`<ngx-mes-formulaires>`)
49
50
  - La **page de rendu par ID** (`<ngx-form-loader>`)
50
51
  - Un **système de stockage abstrait** (localStorage par défaut, API REST Spring en option)
52
+ - Les **formulaires multi-étapes** (`<ngx-stepper-form>`) avec étape de récapitulatif
51
53
 
52
54
  Résultat : dans n'importe quel projet Angular, il suffit de **2 lignes** pour avoir une interface complète de paramétrage de formulaires.
53
55
 
@@ -68,8 +70,9 @@ Résultat : dans n'importe quel projet Angular, il suffit de **2 lignes** pour a
68
70
  - **Sections et séparateurs** (`heading`, `divider`)
69
71
  - **API publique** — `getForm()`, `patchValues()` via `@ViewChild`
70
72
  - **Événements** — `formSubmit`, `formChange`, `formReset`
71
- - **Form Builder visuel** — interface 3 panneaux intégrée dans le plugin
72
- - **Stockage abstrait** — localStorage (v1.1.0) ou API REST Spring (v1.1.0)
73
+ - **Formulaires multi-étapes (Stepper)** — `<ngx-stepper-form>` avec navigation, validation par étape et récapitulatif automatique _(v1.2.0)_
74
+ - **Form Builder visuel** — interface 3 panneaux, supporte les modes Formulaire et Stepper _(v1.2.0)_
75
+ - **Stockage abstrait** — localStorage ou API REST Spring
73
76
  - **FormConfigService** — Signal-based, Observable API
74
77
 
75
78
  ---
@@ -127,7 +130,6 @@ export const appConfig: ApplicationConfig = {
127
130
  import { Routes } from '@angular/router';
128
131
 
129
132
  export const routes: Routes = [
130
- // ... vos routes
131
133
  {
132
134
  path: 'builder',
133
135
  loadComponent: () => import('@suntelecoms/ngx-dynamic-form').then(m => m.FormBuilderComponent),
@@ -192,7 +194,7 @@ Pour disposer du **Form Builder + gestionnaire + rendu par URL** dans votre appl
192
194
 
193
195
  | URL | Page |
194
196
  |---|---|
195
- | `/builder` | Interface graphique de création de formulaires |
197
+ | `/builder` | Interface graphique de création de formulaires (simple ou stepper) |
196
198
  | `/mes-formulaires` | Liste des formulaires sauvegardés, avec rendu à la volée |
197
199
  | `/form/abc123` | Rendu d'un formulaire sauvegardé par son ID |
198
200
 
@@ -361,8 +363,10 @@ interface FieldValidation {
361
363
 
362
364
  ## Affichage conditionnel — showWhen
363
365
 
366
+ Un champ peut être affiché ou masqué en fonction de la valeur d'un autre champ, sans écrire de code Angular.
367
+
364
368
  ```typescript
365
- // Condition unique
369
+ // Condition unique — afficher "Entreprise" seulement si accountType === 'pro'
366
370
  {
367
371
  key: 'company',
368
372
  type: 'text',
@@ -429,7 +433,7 @@ La propriété `col` détermine le nombre de colonnes sur 12 occupées par le ch
429
433
 
430
434
  > En dessous de 600 px, tous les champs passent automatiquement en pleine largeur.
431
435
 
432
- **Sections :**
436
+ **Exemple avec sections :**
433
437
  ```typescript
434
438
  fields: [
435
439
  { key: '_s1', type: 'heading', text: 'Informations', level: 3, col: 12 },
@@ -484,6 +488,141 @@ this.formRef.patchValues({ name: 'Nouveau nom' });
484
488
 
485
489
  ---
486
490
 
491
+ ## Formulaires multi-étapes — Stepper
492
+
493
+ > **Nouveauté v1.2.0**
494
+
495
+ Un formulaire stepper découpe la saisie en plusieurs **étapes** numérotées. L'utilisateur avance étape par étape — chaque étape est validée avant de passer à la suivante. À la fin, une étape **Récapitulatif** affiche toutes les valeurs saisies avec la possibilité de revenir corriger une étape.
496
+
497
+ ### Comment ça fonctionne
498
+
499
+ ```
500
+ Étape 1 Étape 2 Étape 3 Récapitulatif
501
+ Identité ──► Adresse ──► Documents ──► Vérification + Envoi
502
+ ```
503
+
504
+ - **Navigation linéaire** : impossible de passer à l'étape suivante si l'étape en cours est invalide.
505
+ - **Bouton Modifier** dans le récapitulatif : permet de revenir à n'importe quelle étape.
506
+ - **Un seul `formSubmit`** : les données de toutes les étapes sont fusionnées dans un seul objet au moment de l'envoi.
507
+
508
+ ### Utilisation du composant `<ngx-stepper-form>`
509
+
510
+ ```typescript
511
+ import { Component } from '@angular/core';
512
+ import { StepperFormComponent } from '@suntelecoms/ngx-dynamic-form';
513
+ import type { StepperFormConfig, DynamicFormSubmitEvent } from '@suntelecoms/ngx-dynamic-form';
514
+
515
+ @Component({
516
+ selector: 'app-inscription',
517
+ standalone: true,
518
+ imports: [StepperFormComponent],
519
+ template: `
520
+ <ngx-stepper-form [config]="config" (formSubmit)="onSubmit($event)" />
521
+ `,
522
+ })
523
+ export class InscriptionComponent {
524
+ config: StepperFormConfig = {
525
+ showSummary: true, // Affiche l'étape Récapitulatif à la fin
526
+ submitLabel: 'Valider',
527
+ steps: [
528
+ {
529
+ label: 'Identité',
530
+ icon: 'person', // Icône Material Icons dans l'en-tête de l'étape
531
+ fields: [
532
+ { key: 'firstName', type: 'text', label: 'Prénom', col: 6, validation: { required: true } },
533
+ { key: 'lastName', type: 'text', label: 'Nom', col: 6, validation: { required: true } },
534
+ { key: 'email', type: 'email', label: 'E-mail', col: 12, validation: { required: true, email: true } },
535
+ ],
536
+ },
537
+ {
538
+ label: 'Adresse',
539
+ icon: 'home',
540
+ fields: [
541
+ { key: 'street', type: 'text', label: 'Rue', col: 12, validation: { required: true } },
542
+ { key: 'city', type: 'text', label: 'Ville', col: 6, validation: { required: true } },
543
+ { key: 'zip', type: 'text', label: 'Code postal', col: 6, validation: { required: true } },
544
+ ],
545
+ },
546
+ {
547
+ label: 'Confirmation',
548
+ icon: 'check_circle',
549
+ fields: [
550
+ { key: 'terms', type: 'checkbox', placeholder: "J'accepte les CGU", col: 12,
551
+ validation: { required: true } },
552
+ ],
553
+ },
554
+ ],
555
+ };
556
+
557
+ onSubmit(event: DynamicFormSubmitEvent): void {
558
+ // event.value contient les données de TOUTES les étapes fusionnées
559
+ console.log(event.value);
560
+ // { firstName: '...', lastName: '...', email: '...', street: '...', city: '...', zip: '...', terms: true }
561
+ }
562
+ }
563
+ ```
564
+
565
+ ### Configuration — StepperFormConfig
566
+
567
+ ```typescript
568
+ interface StepperFormConfig {
569
+ steps: FormStep[]; // Liste des étapes (obligatoire)
570
+ submitLabel?: string; // Libellé du bouton Envoyer (défaut : "Envoyer")
571
+ showReset?: boolean; // Afficher Réinitialiser (défaut : false)
572
+ resetLabel?: string; // Libellé du bouton Reset
573
+ linear?: boolean; // Bloque la navigation si l'étape est invalide (défaut : true)
574
+ orientation?: 'horizontal' | 'vertical'; // Orientation de la barre des étapes
575
+ showSummary?: boolean; // Ajoute une étape Récapitulatif à la fin (défaut : false)
576
+ summaryLabel?: string; // Libellé de l'étape récapitulatif (défaut : "Récapitulatif")
577
+ cssClass?: string;
578
+ debug?: boolean; // Affiche les valeurs JSON en temps réel
579
+ }
580
+ ```
581
+
582
+ ### Configuration — FormStep
583
+
584
+ Chaque étape contient ses propres champs, exactement comme un `DynamicFormConfig` :
585
+
586
+ ```typescript
587
+ interface FormStep {
588
+ label: string; // Titre de l'étape affiché dans la barre de navigation
589
+ icon?: string; // Icône Material Icons (optionnelle)
590
+ description?: string; // Sous-titre de l'étape (optionnel)
591
+ fields: DynamicFormField[]; // Mêmes champs que pour DynamicFormConfig
592
+ }
593
+ ```
594
+
595
+ ### L'étape Récapitulatif
596
+
597
+ Quand `showSummary: true`, une étape supplémentaire est ajoutée automatiquement à la fin du stepper. Elle affiche :
598
+
599
+ - Toutes les étapes sous forme de **sections distinctes**
600
+ - Pour chaque champ rempli : son **label** et sa **valeur** formatée
601
+ - Un bouton **Modifier** par étape pour naviguer directement vers elle
602
+ - Les types spéciaux sont formatés intelligemment :
603
+ - `checkbox` → "Oui" / "Non"
604
+ - `select` / `radio` → le **label** de l'option (pas la valeur brute)
605
+ - `date` → format `jj/mm/aaaa`
606
+ - `password` → `••••••••`
607
+ - `multiselect` → labels séparés par des virgules
608
+
609
+ ### Inputs de StepperFormComponent
610
+
611
+ | Propriété | Type | Description |
612
+ |---|---|---|
613
+ | `[config]` | `StepperFormConfig` | Configuration du stepper (obligatoire) |
614
+ | `[initialValues]` | `Record<string, any>` | Préremplissage des champs |
615
+
616
+ ### Outputs de StepperFormComponent
617
+
618
+ | Événement | Type | Description |
619
+ |---|---|---|
620
+ | `(formSubmit)` | `DynamicFormSubmitEvent` | Toutes les étapes valides — données fusionnées |
621
+ | `(formChange)` | `Record<string, any>` | Émis à chaque modification (toutes étapes) |
622
+ | `(stepChange)` | `number` | Index de la nouvelle étape active |
623
+
624
+ ---
625
+
487
626
  ## provideNgxForms — configuration globale
488
627
 
489
628
  `provideNgxForms()` est la fonction de configuration du plugin. Elle enregistre le `FormConfigService` et l'adaptateur de stockage dans le contexte Angular.
@@ -527,6 +666,8 @@ DELETE /forms/:id → void
527
666
 
528
667
  `FormConfigService` est fourni par `provideNgxForms()`. Il gère les schémas de formulaires avec un **Signal réactif** et une **API Observable**.
529
668
 
669
+ Depuis la v1.2.0, un schéma peut contenir soit un formulaire simple (`DynamicFormConfig`), soit un formulaire stepper (`StepperFormConfig`). Le type `AnyFormConfig` représente les deux.
670
+
530
671
  ```typescript
531
672
  import { inject } from '@angular/core';
532
673
  import { FormConfigService } from '@suntelecoms/ngx-dynamic-form';
@@ -534,7 +675,7 @@ import { FormConfigService } from '@suntelecoms/ngx-dynamic-form';
534
675
  export class MonComposant {
535
676
  private formService = inject(FormConfigService);
536
677
 
537
- // Signal réactif — mise à jour automatique
678
+ // Signal réactif — liste mise à jour automatiquement
538
679
  readonly schemas = this.formService.schemas; // Signal<SavedFormSchema[]>
539
680
 
540
681
  // Lecture synchrone
@@ -542,18 +683,16 @@ export class MonComposant {
542
683
  return this.formService.get(id); // SavedFormSchema | null
543
684
  }
544
685
 
545
- // Sauvegarde — Observable (complète après écriture)
546
- saveForm(id: string, title: string, config: DynamicFormConfig) {
686
+ // Sauvegarde — fonctionne pour DynamicFormConfig ET StepperFormConfig
687
+ saveForm(id: string, title: string, config: AnyFormConfig) {
547
688
  this.formService.save(id, title, config).subscribe(schema => {
548
689
  console.log('Sauvegardé :', schema);
549
690
  });
550
691
  }
551
692
 
552
- // Suppression — Observable
693
+ // Suppression
553
694
  deleteForm(id: string) {
554
- this.formService.delete(id).subscribe(() => {
555
- console.log('Supprimé');
556
- });
695
+ this.formService.delete(id).subscribe(() => console.log('Supprimé'));
557
696
  }
558
697
 
559
698
  // Génère un ID unique
@@ -567,11 +706,14 @@ export class MonComposant {
567
706
 
568
707
  ```typescript
569
708
  interface SavedFormSchema {
570
- id: string; // Identifiant unique
571
- title: string; // Nom du formulaire
572
- config: DynamicFormConfig; // Configuration complète
573
- updatedAt: string; // ISO 8601
709
+ id: string; // Identifiant unique
710
+ title: string; // Nom du formulaire
711
+ config: AnyFormConfig; // DynamicFormConfig OU StepperFormConfig
712
+ updatedAt: string; // ISO 8601
574
713
  }
714
+
715
+ // AnyFormConfig = DynamicFormConfig | StepperFormConfig
716
+ // Pour distinguer les deux : 'steps' in config → c'est un StepperFormConfig
575
717
  ```
576
718
 
577
719
  ---
@@ -599,15 +741,15 @@ localStorage['ngx-dynamic-form__schemas'] = [ { id, title, config, updatedAt },
599
741
 
600
742
  ```typescript
601
743
  import { Injectable } from '@angular/core';
602
- import { Observable, of } from 'rxjs';
744
+ import { Observable } from 'rxjs';
603
745
  import { FormStorageAdapter, SavedFormSchema } from '@suntelecoms/ngx-dynamic-form';
604
746
 
605
747
  @Injectable()
606
748
  export class IndexedDBAdapter extends FormStorageAdapter {
607
- list(): Observable<SavedFormSchema[]> { /* ... */ }
608
- get(id: string): Observable<SavedFormSchema | null> { /* ... */ }
609
- save(schema: SavedFormSchema): Observable<SavedFormSchema> { /* ... */ }
610
- delete(id: string): Observable<void> { /* ... */ }
749
+ list(): Observable<SavedFormSchema[]> { /* ... */ }
750
+ get(id: string): Observable<SavedFormSchema | null> { /* ... */ }
751
+ save(schema: SavedFormSchema): Observable<SavedFormSchema> { /* ... */ }
752
+ delete(id: string): Observable<void> { /* ... */ }
611
753
  }
612
754
 
613
755
  // app.config.ts
@@ -621,7 +763,7 @@ providers: [
621
763
 
622
764
  ## Form Builder — éditeur visuel
623
765
 
624
- Le **Form Builder** est une interface 3 panneaux intégrée directement dans le plugin via le composant `<ngx-form-builder>` (sélecteur `ngx-form-builder`).
766
+ Le **Form Builder** est une interface 3 panneaux intégrée dans le plugin. Il supporte deux modes : **Formulaire** (simple) et **Stepper** (multi-étapes).
625
767
 
626
768
  ### Ajouter la route
627
769
 
@@ -636,23 +778,36 @@ Le **Form Builder** est une interface 3 panneaux intégrée directement dans le
636
778
 
637
779
  ```
638
780
  ┌──────────────────┬───────────────────────────────┬─────────────────────┐
639
- │ Palette │ Schéma / Aperçu │ Propriétés │
640
- │ │ │ (champ sélect.) │
641
- │ Saisie │ ┌────────────────────────┐ │ │
642
- │ [Texte] │ │ 👤 Nom (text) ↑↓⎘🗑│ │ Label : Nom │
643
- │ [E-mail] │ │ 📧 Email (email) ↑↓⎘🗑│ │ Col : 6/12 │
644
- │ [Nombre] │ └────────────────────────┘ │ Icône : person │
645
- │ ... │ │ Required : ✓ │
646
- │ Choix │ Paramètres du formulaire │ │
647
- │ [Select] ├───────────────────────────────┤ Validation │
648
- │ [Radio] │ Bouton Envoyer : [Envoyer] │ Options │
649
- │ ... │ [ ] Afficher Réinitialiser │ │
650
- │ │ │ │
651
- │ Formulaires │ [Schéma] [Aperçu] │ │
652
- │ sauvegardés │ │ │
781
+ │ Palette │ [Formulaire] [Stepper] │ Propriétés │
782
+ │ │ Schéma / Aperçu │ (champ sélect.) │
783
+ │ ÉTAPES (stepper)│ │ │
784
+ │ ① Étape 1 ✏X│ ┌────────────────────────┐ │ Label : Nom │
785
+ │ ② Étape 2 ✏X│ │ Nom (text) ↑↓⎘🗑 │ │ Col : 6/12 │
786
+ │ + Ajouter │ │ Email (email) ↑↓⎘🗑 │ │ Icône : person │
787
+ │ │ └────────────────────────┘ │ Required : ✓ │
788
+ │ TYPES DE CHAMPS │ │ │
789
+ │ [Texte] │ Paramètres du formulaire │ Validation │
790
+ │ [E-mail] │ Bouton Envoyer : [Envoyer] │ Options │
791
+ │ [Select] ... │ [ ] Réinitialiser │ │
792
+ │ │ [✓] Récapitulatif (stepper) │ │
793
+ │ Formulaires │ │ │
794
+ │ sauvegardés │ [Schéma] [Aperçu] │ │
653
795
  └──────────────────┴───────────────────────────────┴─────────────────────┘
654
796
  ```
655
797
 
798
+ ### Mode Stepper dans le Builder
799
+
800
+ En mode Stepper, la palette affiche en haut la liste des **étapes** :
801
+
802
+ - **Cliquer sur une étape** → affiche ses champs dans le canvas
803
+ - **Icône crayon** → renommer l'étape
804
+ - **Icône ×** → supprimer l'étape
805
+ - **+ Ajouter une étape** → crée une nouvelle étape vide
806
+
807
+ Les champs sont ajoutés à **l'étape active**. Chaque étape a ses propres champs indépendants.
808
+
809
+ Dans les **Paramètres du formulaire** (bas du canvas), la case **"Afficher Récapitulatif"** est disponible en mode Stepper pour activer/désactiver l'étape de synthèse automatique.
810
+
656
811
  ### Fonctionnalités du Builder
657
812
 
658
813
  | Action | Description |
@@ -662,13 +817,16 @@ Le **Form Builder** est une interface 3 panneaux intégrée directement dans le
662
817
  | Dupliquer | Copie d'un champ avec toutes ses propriétés |
663
818
  | Supprimer | Icône corbeille |
664
819
  | Éditer | Panneau droit — label, col, icône, validation, options… |
665
- | Aperçu | Onglet **Aperçu** — rendu réel via `<ngx-dynamic-form>` |
820
+ | Mode Stepper | Bascule Formulaire ↔ Stepper en haut de page |
821
+ | Gérer les étapes | Créer, renommer, supprimer les étapes |
822
+ | Récapitulatif | Case à cocher pour activer l'étape de synthèse |
823
+ | Aperçu | Onglet **Aperçu** — rendu réel en temps réel |
666
824
  | Sauvegarder | Stocke en localStorage (ou API) avec ID unique |
667
825
  | Export JSON | JSON de la config dans un modal copiable |
668
- | Export TypeScript | `const config: DynamicFormConfig = { ... }` |
826
+ | Export TypeScript | `const config: DynamicFormConfig = { ... }` ou `StepperFormConfig` |
669
827
  | Partager | Copie l'URL `/form/<id>` dans le presse-papiers |
670
828
 
671
- ### Inputs du FormBuilderComponent
829
+ ### Input du FormBuilderComponent
672
830
 
673
831
  | Input | Type | Défaut | Description |
674
832
  |---|---|---|---|
@@ -680,7 +838,7 @@ Le **Form Builder** est une interface 3 panneaux intégrée directement dans le
680
838
 
681
839
  ### MesFormulairesComponent — `<ngx-mes-formulaires>`
682
840
 
683
- Liste et aperçu de tous les formulaires sauvegardés. Permet de les prévisualiser, les soumettre, les supprimer.
841
+ Liste et aperçu de tous les formulaires sauvegardés (simples **et** stepper). Permet de les prévisualiser, les soumettre, les supprimer.
684
842
 
685
843
  ```typescript
686
844
  {
@@ -697,7 +855,7 @@ Liste et aperçu de tous les formulaires sauvegardés. Permet de les prévisuali
697
855
 
698
856
  ### FormLoaderComponent — `<ngx-form-loader>`
699
857
 
700
- Charge et affiche un formulaire depuis son ID (via `ActivatedRoute` ou `@Input`).
858
+ Charge et affiche un formulaire depuis son ID — détecte automatiquement s'il s'agit d'un formulaire simple ou d'un stepper.
701
859
 
702
860
  ```typescript
703
861
  {
@@ -716,7 +874,7 @@ Charge et affiche un formulaire depuis son ID (via `ActivatedRoute` ou `@Input`)
716
874
 
717
875
  ## Intégration dans un composant
718
876
 
719
- ### Approche A — chargement dynamique via FormConfigService
877
+ ### Approche A — formulaire simple chargé par ID
720
878
 
721
879
  ```typescript
722
880
  import { Component, computed, inject, signal } from '@angular/core';
@@ -734,25 +892,56 @@ import type { DynamicFormConfig, DynamicFormSubmitEvent } from '@suntelecoms/ngx
734
892
  })
735
893
  export class MonFormulaireComponent {
736
894
  private formService = inject(FormConfigService);
895
+ selectedId = signal('votre-id-ici');
896
+ activeConfig = computed(() =>
897
+ this.formService.get(this.selectedId())?.config as DynamicFormConfig ?? null
898
+ );
899
+ onSubmit(event: DynamicFormSubmitEvent): void { console.log(event.value); }
900
+ }
901
+ ```
737
902
 
738
- // Signal réactif — liste des formulaires disponibles
739
- readonly schemas = this.formService.schemas;
903
+ ### Approche B — stepper chargé par ID (détection automatique)
740
904
 
741
- // Sélection de l'ID actif
905
+ ```typescript
906
+ import { Component, computed, inject, signal } from '@angular/core';
907
+ import { DynamicFormComponent, StepperFormComponent, FormConfigService } from '@suntelecoms/ngx-dynamic-form';
908
+ import type { DynamicFormConfig, StepperFormConfig, DynamicFormSubmitEvent } from '@suntelecoms/ngx-dynamic-form';
909
+
910
+ @Component({
911
+ standalone: true,
912
+ imports: [DynamicFormComponent, StepperFormComponent],
913
+ template: `
914
+ @if (flatConfig(); as flatCfg) {
915
+ <ngx-dynamic-form [config]="flatCfg" (formSubmit)="onSubmit($event)" />
916
+ }
917
+ @if (stepperConfig(); as stepperCfg) {
918
+ <ngx-stepper-form [config]="stepperCfg" (formSubmit)="onSubmit($event)" />
919
+ }
920
+ `,
921
+ })
922
+ export class MonFormulaireComponent {
923
+ private formService = inject(FormConfigService);
742
924
  selectedId = signal('votre-id-ici');
743
925
 
744
- // Config dérivée automatiquement
745
- activeConfig = computed(() =>
746
- this.formService.get(this.selectedId())?.config ?? null
747
- );
926
+ private anyConfig = computed(() => this.formService.get(this.selectedId())?.config ?? null);
748
927
 
749
- onSubmit(event: DynamicFormSubmitEvent): void {
750
- console.log(event.value);
751
- }
928
+ // Formulaire simple : n'a pas de propriété "steps"
929
+ flatConfig = computed<DynamicFormConfig | null>(() => {
930
+ const c = this.anyConfig();
931
+ return c && !('steps' in c) ? c as DynamicFormConfig : null;
932
+ });
933
+
934
+ // Formulaire stepper : a une propriété "steps"
935
+ stepperConfig = computed<StepperFormConfig | null>(() => {
936
+ const c = this.anyConfig();
937
+ return c && 'steps' in c ? c as StepperFormConfig : null;
938
+ });
939
+
940
+ onSubmit(event: DynamicFormSubmitEvent): void { console.log(event.value); }
752
941
  }
753
942
  ```
754
943
 
755
- ### Approche B — configuration statique TypeScript
944
+ ### Approche C — configuration TypeScript statique
756
945
 
757
946
  ```typescript
758
947
  import { Component } from '@angular/core';
@@ -772,18 +961,15 @@ export class ContactComponent {
772
961
  { key: 'email', type: 'email', label: 'E-mail', col: 6, validation: { required: true } },
773
962
  ],
774
963
  };
775
-
776
- onSubmit(event: DynamicFormSubmitEvent): void {
777
- console.log(event.value);
778
- }
964
+ onSubmit(event: DynamicFormSubmitEvent): void { console.log(event.value); }
779
965
  }
780
966
  ```
781
967
 
782
968
  > **Astuce :** créez le formulaire dans le Builder (`/builder`) → cliquez **Export TypeScript** → collez dans votre composant.
783
969
 
784
- ### Approche C — avec backend API REST (Spring Boot)
970
+ ### Approche D — avec backend API REST (Spring Boot)
785
971
 
786
- Configurez simplement `provideNgxForms({ storage: 'http', apiUrl: '...' })` — tout le reste est identique aux approches A et B. Le `FormConfigService` appellera automatiquement votre API au lieu de localStorage.
972
+ Configurez `provideNgxForms({ storage: 'http', apiUrl: '...' })` — tout le reste est identique. Le `FormConfigService` appellera automatiquement votre API au lieu de localStorage.
787
973
 
788
974
  ```typescript
789
975
  // app.config.ts
@@ -799,10 +985,11 @@ provideHttpClient(),
799
985
  @RestController
800
986
  @RequestMapping("/forms")
801
987
  public class FormController {
802
- @GetMapping List<SavedFormSchema> list() { ... }
803
- @GetMapping("/{id}") SavedFormSchema get(@PathVariable String id) { ... }
804
- @PutMapping("/{id}") SavedFormSchema save(@PathVariable String id, @RequestBody SavedFormSchema s) { ... }
805
- @DeleteMapping("/{id}") void delete(@PathVariable String id) { ... }
988
+ @GetMapping List<SavedFormSchema> list() { ... }
989
+ @GetMapping("/{id}") SavedFormSchema get(@PathVariable String id) { ... }
990
+ @PutMapping("/{id}") SavedFormSchema save(@PathVariable String id,
991
+ @RequestBody SavedFormSchema s) { ... }
992
+ @DeleteMapping("/{id}") void delete(@PathVariable String id) { ... }
806
993
  }
807
994
  ```
808
995
 
@@ -818,9 +1005,9 @@ L'application de démonstration (`ng serve`) illustre le plugin sur plusieurs ca
818
1005
  | `/inscription` | Formulaire multi-sections avec `showWhen` |
819
1006
  | `/contact` | Formulaire de contact (select, textarea, radio) |
820
1007
  | `/produit` | Fiche produit — modes vue / édition / création |
821
- | `/builder` | **Form Builder** — composant `FormBuilderComponent` de la lib |
822
- | `/mes-formulaires` | **Gestionnaire** — composant `MesFormulairesComponent` de la lib |
823
- | `/form/:id` | **Rendu par ID** — composant `FormLoaderComponent` de la lib |
1008
+ | `/builder` | **Form Builder** — modes Formulaire et Stepper |
1009
+ | `/mes-formulaires` | **Gestionnaire** — liste et aperçu de tous les formulaires |
1010
+ | `/form/:id` | **Rendu par ID** — formulaire simple ou stepper automatiquement |
824
1011
 
825
1012
  ---
826
1013
 
@@ -859,6 +1046,65 @@ config: DynamicFormConfig = {
859
1046
  };
860
1047
  ```
861
1048
 
1049
+ ### Formulaire stepper — processus d'inscription en 3 étapes
1050
+
1051
+ ```typescript
1052
+ config: StepperFormConfig = {
1053
+ showSummary: true,
1054
+ submitLabel: 'Créer mon compte',
1055
+ steps: [
1056
+ {
1057
+ label: 'Identité',
1058
+ icon: 'person',
1059
+ fields: [
1060
+ { key: 'firstName', type: 'text', label: 'Prénom', col: 6, validation: { required: true } },
1061
+ { key: 'lastName', type: 'text', label: 'Nom', col: 6, validation: { required: true } },
1062
+ { key: 'birthDate', type: 'date', label: 'Date de naissance', col: 6 },
1063
+ { key: 'gender', type: 'select', label: 'Genre', col: 6,
1064
+ options: [{ label: 'Homme', value: 'M' }, { label: 'Femme', value: 'F' }] },
1065
+ ],
1066
+ },
1067
+ {
1068
+ label: 'Coordonnées',
1069
+ icon: 'contact_mail',
1070
+ fields: [
1071
+ { key: 'email', type: 'email', label: 'E-mail', col: 12,
1072
+ validation: { required: true, email: true } },
1073
+ { key: 'phone', type: 'tel', label: 'Téléphone', col: 6 },
1074
+ { key: 'city', type: 'text', label: 'Ville', col: 6 },
1075
+ ],
1076
+ },
1077
+ {
1078
+ label: 'Sécurité',
1079
+ icon: 'lock',
1080
+ fields: [
1081
+ { key: 'password', type: 'password', label: 'Mot de passe', col: 6,
1082
+ validation: { required: true, custom: v => v?.length < 8 ? 'Minimum 8 caractères' : null } },
1083
+ { key: 'terms', type: 'checkbox', placeholder: "J'accepte les CGU", col: 12,
1084
+ validation: { required: true } },
1085
+ ],
1086
+ },
1087
+ ],
1088
+ };
1089
+ ```
1090
+
1091
+ Le récapitulatif final affichera automatiquement :
1092
+ ```
1093
+ ── Identité ─────────────── [Modifier]
1094
+ Prénom Jean
1095
+ Nom Dupont
1096
+ Date de naissance 15/03/1990
1097
+ Genre Homme
1098
+
1099
+ ── Coordonnées ─────────── [Modifier]
1100
+ E-mail jean@example.com
1101
+ Téléphone +33 6 12 34 56 78
1102
+
1103
+ ── Sécurité ─────────────── [Modifier]
1104
+ Mot de passe ••••••••
1105
+ J'accepte les CGU Oui
1106
+ ```
1107
+
862
1108
  ### Fiche produit avec préremplissage et mode vue/édition
863
1109
 
864
1110
  ```typescript
@@ -912,6 +1158,7 @@ Pour les couleurs des champs Material (outline, focus, erreur), personnalisez le
912
1158
 
913
1159
  // Composants
914
1160
  export { DynamicFormComponent } // <ngx-dynamic-form>
1161
+ export { StepperFormComponent } // <ngx-stepper-form> ← v1.2.0
915
1162
  export { FormBuilderComponent } // <ngx-form-builder>
916
1163
  export { MesFormulairesComponent } // <ngx-mes-formulaires>
917
1164
  export { FormLoaderComponent } // <ngx-form-loader>
@@ -925,11 +1172,14 @@ export { FORM_API_URL } // InjectionToken<string>
925
1172
  export { provideNgxForms } // function(options) → EnvironmentProviders
926
1173
 
927
1174
  // Types
928
- export type { NgxFormsOptions } // { storage: 'local' } | { storage: 'http', apiUrl: string }
929
- export type { SavedFormSchema } // { id, title, config, updatedAt }
1175
+ export type { NgxFormsOptions } // { storage: 'local' } | { storage: 'http', apiUrl: string }
1176
+ export type { AnyFormConfig } // DynamicFormConfig | StepperFormConfig ← v1.2.0
1177
+ export type { SavedFormSchema } // { id, title, config: AnyFormConfig, updatedAt }
930
1178
  export type { DynamicFormConfig }
931
1179
  export type { DynamicFormField }
932
1180
  export type { DynamicFormSubmitEvent }
1181
+ export type { StepperFormConfig } // ← v1.2.0
1182
+ export type { FormStep } // ← v1.2.0
933
1183
  export type { FieldType }
934
1184
  export type { FieldValidation }
935
1185
  export type { FieldCondition }
@@ -938,6 +1188,24 @@ export type { SelectOption }
938
1188
 
939
1189
  ---
940
1190
 
1191
+ ## Changelog
1192
+
1193
+ ### v1.2.0
1194
+ - Ajout du composant `<ngx-stepper-form>` pour les formulaires multi-étapes
1195
+ - Étape **Récapitulatif** automatique (`showSummary: true`) avec boutons Modifier par étape
1196
+ - Mode **Stepper** dans le Form Builder : gestion des étapes (créer, renommer, supprimer), aperçu en temps réel
1197
+ - Case "Afficher Récapitulatif" dans les paramètres du Builder
1198
+ - `AnyFormConfig` = `DynamicFormConfig | StepperFormConfig` — `SavedFormSchema.config` supporte les deux
1199
+ - `MesFormulairesComponent` et `FormLoaderComponent` détectent et rendent automatiquement les deux types
1200
+
1201
+ ### v1.1.0
1202
+ - Grille 12 colonnes (`col`) intégrée dans les styles du composant
1203
+ - Form Builder, MesFormulaires et FormLoader intégrés dans le plugin
1204
+ - Système de stockage abstrait (localStorage / API REST)
1205
+ - `FormConfigService` Signal-based
1206
+
1207
+ ---
1208
+
941
1209
  ## Auteur
942
1210
 
943
1211
  **Amadou Diallo** — [@amepro](https://github.com/amepro)