@suntelecoms/ngx-dynamic-form 1.2.0 → 1.2.5
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 +493 -76
- package/fesm2022/suntelecoms-ngx-dynamic-form.mjs +261 -159
- package/fesm2022/suntelecoms-ngx-dynamic-form.mjs.map +1 -1
- package/lib/components/dynamic-field/dynamic-field.component.d.ts +6 -4
- package/lib/components/form-builder/form-builder.component.d.ts +2 -0
- package/lib/models/form-field.model.d.ts +3 -0
- package/lib/providers.d.ts +12 -2
- package/package.json +1 -1
- package/public-api.d.ts +1 -1
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
|
|
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
|
[](https://angular.dev)
|
|
6
6
|
[](https://material.angular.io)
|
|
7
|
-
[](CHANGELOG.md)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
[](mailto:amadoumacbookpro38@gmail.com)
|
|
10
10
|
|
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
- [Types de champs](#types-de-champs)
|
|
21
21
|
- [Configuration — DynamicFormConfig](#configuration--dynamicformconfig)
|
|
22
22
|
- [Propriétés d'un champ — DynamicFormField](#propriétés-dun-champ--dynamicformfield)
|
|
23
|
+
- [Options dynamiques depuis une API](#options-dynamiques-depuis-une-api)
|
|
23
24
|
- [Validation](#validation)
|
|
24
25
|
- [Affichage conditionnel — showWhen](#affichage-conditionnel--showwhen)
|
|
25
26
|
- [Icônes (Material Icons)](#icônes-material-icons)
|
|
26
27
|
- [Disposition en grille (col)](#disposition-en-grille-col)
|
|
27
28
|
- [API du composant DynamicForm](#api-du-composant-dynamicform)
|
|
29
|
+
- [Formulaires multi-étapes — Stepper](#formulaires-multi-étapes--stepper)
|
|
28
30
|
- [provideNgxForms — configuration globale](#providengxforms--configuration-globale)
|
|
29
31
|
- [FormConfigService — gestion des schémas](#formconfigservice--gestion-des-schémas)
|
|
30
32
|
- [Stockage — LocalStorage vs API REST](#stockage--localstorage-vs-api-rest)
|
|
@@ -43,11 +45,12 @@
|
|
|
43
45
|
|
|
44
46
|
**@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
47
|
|
|
46
|
-
Depuis la **v1.
|
|
47
|
-
- Le **Form Builder visuel** (`<ngx-form-builder>`)
|
|
48
|
+
Depuis la **v1.2.0**, le plugin embarque :
|
|
49
|
+
- Le **Form Builder visuel** (`<ngx-form-builder>`) — avec mode **Stepper**
|
|
48
50
|
- Le **gestionnaire de formulaires** (`<ngx-mes-formulaires>`)
|
|
49
51
|
- La **page de rendu par ID** (`<ngx-form-loader>`)
|
|
50
52
|
- Un **système de stockage abstrait** (localStorage par défaut, API REST Spring en option)
|
|
53
|
+
- Les **formulaires multi-étapes** (`<ngx-stepper-form>`) avec étape de récapitulatif
|
|
51
54
|
|
|
52
55
|
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
56
|
|
|
@@ -68,8 +71,10 @@ Résultat : dans n'importe quel projet Angular, il suffit de **2 lignes** pour a
|
|
|
68
71
|
- **Sections et séparateurs** (`heading`, `divider`)
|
|
69
72
|
- **API publique** — `getForm()`, `patchValues()` via `@ViewChild`
|
|
70
73
|
- **Événements** — `formSubmit`, `formChange`, `formReset`
|
|
71
|
-
- **
|
|
72
|
-
- **
|
|
74
|
+
- **Formulaires multi-étapes (Stepper)** — `<ngx-stepper-form>` avec navigation, validation par étape et récapitulatif automatique _(v1.2.0)_
|
|
75
|
+
- **Form Builder visuel** — interface 3 panneaux, supporte les modes Formulaire et Stepper _(v1.2.0)_
|
|
76
|
+
- **Options dynamiques depuis une API** — propriétés `url`, `displayName`, `displayValue` sur les champs `select`, `multiselect`, `radio` _(v1.2.5)_
|
|
77
|
+
- **Stockage abstrait** — localStorage ou API REST Spring
|
|
73
78
|
- **FormConfigService** — Signal-based, Observable API
|
|
74
79
|
|
|
75
80
|
---
|
|
@@ -127,7 +132,6 @@ export const appConfig: ApplicationConfig = {
|
|
|
127
132
|
import { Routes } from '@angular/router';
|
|
128
133
|
|
|
129
134
|
export const routes: Routes = [
|
|
130
|
-
// ... vos routes
|
|
131
135
|
{
|
|
132
136
|
path: 'builder',
|
|
133
137
|
loadComponent: () => import('@suntelecoms/ngx-dynamic-form').then(m => m.FormBuilderComponent),
|
|
@@ -192,7 +196,7 @@ Pour disposer du **Form Builder + gestionnaire + rendu par URL** dans votre appl
|
|
|
192
196
|
|
|
193
197
|
| URL | Page |
|
|
194
198
|
|---|---|
|
|
195
|
-
| `/builder` | Interface graphique de création de formulaires |
|
|
199
|
+
| `/builder` | Interface graphique de création de formulaires (simple ou stepper) |
|
|
196
200
|
| `/mes-formulaires` | Liste des formulaires sauvegardés, avec rendu à la volée |
|
|
197
201
|
| `/form/abc123` | Rendu d'un formulaire sauvegardé par son ID |
|
|
198
202
|
|
|
@@ -258,9 +262,14 @@ interface DynamicFormField {
|
|
|
258
262
|
readonly?: boolean;
|
|
259
263
|
hidden?: boolean;
|
|
260
264
|
|
|
261
|
-
// Options (select / multiselect / radio)
|
|
265
|
+
// Options statiques (select / multiselect / radio)
|
|
262
266
|
options?: SelectOption[];
|
|
263
267
|
|
|
268
|
+
// Options dynamiques chargées depuis une API ← v1.2.5
|
|
269
|
+
url?: string; // endpoint relatif ('villes') ou absolu ('https://...')
|
|
270
|
+
displayName?: string; // propriété de la réponse API utilisée comme label (défaut : 'label')
|
|
271
|
+
displayValue?: string; // propriété de la réponse API utilisée comme valeur (défaut : 'value')
|
|
272
|
+
|
|
264
273
|
// Validation
|
|
265
274
|
validation?: FieldValidation;
|
|
266
275
|
|
|
@@ -299,6 +308,120 @@ interface SelectOption {
|
|
|
299
308
|
|
|
300
309
|
---
|
|
301
310
|
|
|
311
|
+
## Options dynamiques depuis une API
|
|
312
|
+
|
|
313
|
+
> **Nouveauté v1.2.5**
|
|
314
|
+
|
|
315
|
+
Pour les champs `select`, `multiselect` et `radio`, les options peuvent être chargées automatiquement depuis une API REST au lieu d'être définies statiquement. Il suffit d'utiliser `url` à la place de `options`.
|
|
316
|
+
|
|
317
|
+
### Comment ça fonctionne
|
|
318
|
+
|
|
319
|
+
1. Le composant détecte la propriété `url` sur le champ
|
|
320
|
+
2. Il effectue un `GET` sur l'URL complète (`dataUrl` + `url`)
|
|
321
|
+
3. Il mappe chaque objet de la réponse en `{ label, value }` en utilisant `displayName` et `displayValue`
|
|
322
|
+
4. Pendant le chargement, le select affiche **"Chargement…"** avec un spinner
|
|
323
|
+
|
|
324
|
+
### Configuration dans `app.config.ts`
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
import { provideHttpClient } from '@angular/common/http';
|
|
328
|
+
import { provideNgxForms } from '@suntelecoms/ngx-dynamic-form';
|
|
329
|
+
|
|
330
|
+
providers: [
|
|
331
|
+
provideHttpClient(), // requis pour les options depuis API
|
|
332
|
+
provideNgxForms({
|
|
333
|
+
storage: 'local',
|
|
334
|
+
dataUrl: 'https://api.monprojet.com', // base URL pour les options
|
|
335
|
+
}),
|
|
336
|
+
]
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Exemples
|
|
340
|
+
|
|
341
|
+
**Options depuis une API (URL relative) :**
|
|
342
|
+
```typescript
|
|
343
|
+
{
|
|
344
|
+
key: 'ville',
|
|
345
|
+
type: 'select',
|
|
346
|
+
label: 'Ville',
|
|
347
|
+
col: 6,
|
|
348
|
+
icon: 'location_city',
|
|
349
|
+
url: 'villes', // → GET https://api.monprojet.com/villes
|
|
350
|
+
displayName: 'nom', // propriété affichée dans la liste
|
|
351
|
+
displayValue: 'id', // propriété utilisée comme valeur du formulaire
|
|
352
|
+
validation: { required: true },
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
**Options depuis une API (URL absolue) :**
|
|
357
|
+
```typescript
|
|
358
|
+
{
|
|
359
|
+
key: 'compte',
|
|
360
|
+
type: 'select',
|
|
361
|
+
label: 'Compte',
|
|
362
|
+
col: 6,
|
|
363
|
+
url: 'https://autre-api.com/comptes', // URL absolue — dataUrl ignoré
|
|
364
|
+
displayName: 'numero',
|
|
365
|
+
displayValue: 'numero',
|
|
366
|
+
validation: { required: true },
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**Multi-sélection depuis une API :**
|
|
371
|
+
```typescript
|
|
372
|
+
{
|
|
373
|
+
key: 'categories',
|
|
374
|
+
type: 'multiselect',
|
|
375
|
+
label: 'Catégories',
|
|
376
|
+
col: 12,
|
|
377
|
+
url: 'categories',
|
|
378
|
+
displayName: 'libelle',
|
|
379
|
+
displayValue: 'code',
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**Options statiques avec `displayName` / `displayValue` personnalisés :**
|
|
384
|
+
|
|
385
|
+
Si les données viennent d'un objet mais sans passer par une API, utilisez `options` directement :
|
|
386
|
+
```typescript
|
|
387
|
+
{
|
|
388
|
+
key: 'type',
|
|
389
|
+
type: 'select',
|
|
390
|
+
label: 'Type',
|
|
391
|
+
col: 6,
|
|
392
|
+
options: [
|
|
393
|
+
{ label: 'MCOD — Identifiant marchand', value: 'MCOD' },
|
|
394
|
+
{ label: 'SHID — Adresse de paiement', value: 'SHID' },
|
|
395
|
+
],
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### Réponse API attendue
|
|
400
|
+
|
|
401
|
+
L'API doit retourner un **tableau JSON** d'objets :
|
|
402
|
+
|
|
403
|
+
```json
|
|
404
|
+
[
|
|
405
|
+
{ "id": 1, "nom": "Dakar" },
|
|
406
|
+
{ "id": 2, "nom": "Thiès" },
|
|
407
|
+
{ "id": 3, "nom": "Saint-Louis" }
|
|
408
|
+
]
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Avec `displayName: 'nom'` et `displayValue: 'id'`, le select affichera `Dakar`, `Thiès`, `Saint-Louis` et soumettra `1`, `2`, `3`.
|
|
412
|
+
|
|
413
|
+
### Résumé des propriétés
|
|
414
|
+
|
|
415
|
+
| Propriété | Type | Description |
|
|
416
|
+
|---|---|---|
|
|
417
|
+
| `url` | `string` | Endpoint relatif (`'villes'`) ou absolu (`'https://...'`). Quand défini, `options` est ignoré. |
|
|
418
|
+
| `displayName` | `string` | Propriété de l'objet API utilisée comme **label** affiché (défaut : `'label'`) |
|
|
419
|
+
| `displayValue` | `string` | Propriété de l'objet API utilisée comme **valeur** du formulaire (défaut : `'value'`) |
|
|
420
|
+
|
|
421
|
+
> **Note :** `url` et `options` sont mutuellement exclusifs. Si `url` est défini, `options` est ignoré.
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
302
425
|
## Validation
|
|
303
426
|
|
|
304
427
|
```typescript
|
|
@@ -361,8 +484,10 @@ interface FieldValidation {
|
|
|
361
484
|
|
|
362
485
|
## Affichage conditionnel — showWhen
|
|
363
486
|
|
|
487
|
+
Un champ peut être affiché ou masqué en fonction de la valeur d'un autre champ, sans écrire de code Angular.
|
|
488
|
+
|
|
364
489
|
```typescript
|
|
365
|
-
// Condition unique
|
|
490
|
+
// Condition unique — afficher "Entreprise" seulement si accountType === 'pro'
|
|
366
491
|
{
|
|
367
492
|
key: 'company',
|
|
368
493
|
type: 'text',
|
|
@@ -429,7 +554,7 @@ La propriété `col` détermine le nombre de colonnes sur 12 occupées par le ch
|
|
|
429
554
|
|
|
430
555
|
> En dessous de 600 px, tous les champs passent automatiquement en pleine largeur.
|
|
431
556
|
|
|
432
|
-
**
|
|
557
|
+
**Exemple avec sections :**
|
|
433
558
|
```typescript
|
|
434
559
|
fields: [
|
|
435
560
|
{ key: '_s1', type: 'heading', text: 'Informations', level: 3, col: 12 },
|
|
@@ -484,6 +609,141 @@ this.formRef.patchValues({ name: 'Nouveau nom' });
|
|
|
484
609
|
|
|
485
610
|
---
|
|
486
611
|
|
|
612
|
+
## Formulaires multi-étapes — Stepper
|
|
613
|
+
|
|
614
|
+
> **Nouveauté v1.2.0**
|
|
615
|
+
|
|
616
|
+
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.
|
|
617
|
+
|
|
618
|
+
### Comment ça fonctionne
|
|
619
|
+
|
|
620
|
+
```
|
|
621
|
+
Étape 1 Étape 2 Étape 3 Récapitulatif
|
|
622
|
+
Identité ──► Adresse ──► Documents ──► Vérification + Envoi
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
- **Navigation linéaire** : impossible de passer à l'étape suivante si l'étape en cours est invalide.
|
|
626
|
+
- **Bouton Modifier** dans le récapitulatif : permet de revenir à n'importe quelle étape.
|
|
627
|
+
- **Un seul `formSubmit`** : les données de toutes les étapes sont fusionnées dans un seul objet au moment de l'envoi.
|
|
628
|
+
|
|
629
|
+
### Utilisation du composant `<ngx-stepper-form>`
|
|
630
|
+
|
|
631
|
+
```typescript
|
|
632
|
+
import { Component } from '@angular/core';
|
|
633
|
+
import { StepperFormComponent } from '@suntelecoms/ngx-dynamic-form';
|
|
634
|
+
import type { StepperFormConfig, DynamicFormSubmitEvent } from '@suntelecoms/ngx-dynamic-form';
|
|
635
|
+
|
|
636
|
+
@Component({
|
|
637
|
+
selector: 'app-inscription',
|
|
638
|
+
standalone: true,
|
|
639
|
+
imports: [StepperFormComponent],
|
|
640
|
+
template: `
|
|
641
|
+
<ngx-stepper-form [config]="config" (formSubmit)="onSubmit($event)" />
|
|
642
|
+
`,
|
|
643
|
+
})
|
|
644
|
+
export class InscriptionComponent {
|
|
645
|
+
config: StepperFormConfig = {
|
|
646
|
+
showSummary: true, // Affiche l'étape Récapitulatif à la fin
|
|
647
|
+
submitLabel: 'Valider',
|
|
648
|
+
steps: [
|
|
649
|
+
{
|
|
650
|
+
label: 'Identité',
|
|
651
|
+
icon: 'person', // Icône Material Icons dans l'en-tête de l'étape
|
|
652
|
+
fields: [
|
|
653
|
+
{ key: 'firstName', type: 'text', label: 'Prénom', col: 6, validation: { required: true } },
|
|
654
|
+
{ key: 'lastName', type: 'text', label: 'Nom', col: 6, validation: { required: true } },
|
|
655
|
+
{ key: 'email', type: 'email', label: 'E-mail', col: 12, validation: { required: true, email: true } },
|
|
656
|
+
],
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
label: 'Adresse',
|
|
660
|
+
icon: 'home',
|
|
661
|
+
fields: [
|
|
662
|
+
{ key: 'street', type: 'text', label: 'Rue', col: 12, validation: { required: true } },
|
|
663
|
+
{ key: 'city', type: 'text', label: 'Ville', col: 6, validation: { required: true } },
|
|
664
|
+
{ key: 'zip', type: 'text', label: 'Code postal', col: 6, validation: { required: true } },
|
|
665
|
+
],
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
label: 'Confirmation',
|
|
669
|
+
icon: 'check_circle',
|
|
670
|
+
fields: [
|
|
671
|
+
{ key: 'terms', type: 'checkbox', placeholder: "J'accepte les CGU", col: 12,
|
|
672
|
+
validation: { required: true } },
|
|
673
|
+
],
|
|
674
|
+
},
|
|
675
|
+
],
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
onSubmit(event: DynamicFormSubmitEvent): void {
|
|
679
|
+
// event.value contient les données de TOUTES les étapes fusionnées
|
|
680
|
+
console.log(event.value);
|
|
681
|
+
// { firstName: '...', lastName: '...', email: '...', street: '...', city: '...', zip: '...', terms: true }
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
### Configuration — StepperFormConfig
|
|
687
|
+
|
|
688
|
+
```typescript
|
|
689
|
+
interface StepperFormConfig {
|
|
690
|
+
steps: FormStep[]; // Liste des étapes (obligatoire)
|
|
691
|
+
submitLabel?: string; // Libellé du bouton Envoyer (défaut : "Envoyer")
|
|
692
|
+
showReset?: boolean; // Afficher Réinitialiser (défaut : false)
|
|
693
|
+
resetLabel?: string; // Libellé du bouton Reset
|
|
694
|
+
linear?: boolean; // Bloque la navigation si l'étape est invalide (défaut : true)
|
|
695
|
+
orientation?: 'horizontal' | 'vertical'; // Orientation de la barre des étapes
|
|
696
|
+
showSummary?: boolean; // Ajoute une étape Récapitulatif à la fin (défaut : false)
|
|
697
|
+
summaryLabel?: string; // Libellé de l'étape récapitulatif (défaut : "Récapitulatif")
|
|
698
|
+
cssClass?: string;
|
|
699
|
+
debug?: boolean; // Affiche les valeurs JSON en temps réel
|
|
700
|
+
}
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
### Configuration — FormStep
|
|
704
|
+
|
|
705
|
+
Chaque étape contient ses propres champs, exactement comme un `DynamicFormConfig` :
|
|
706
|
+
|
|
707
|
+
```typescript
|
|
708
|
+
interface FormStep {
|
|
709
|
+
label: string; // Titre de l'étape affiché dans la barre de navigation
|
|
710
|
+
icon?: string; // Icône Material Icons (optionnelle)
|
|
711
|
+
description?: string; // Sous-titre de l'étape (optionnel)
|
|
712
|
+
fields: DynamicFormField[]; // Mêmes champs que pour DynamicFormConfig
|
|
713
|
+
}
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
### L'étape Récapitulatif
|
|
717
|
+
|
|
718
|
+
Quand `showSummary: true`, une étape supplémentaire est ajoutée automatiquement à la fin du stepper. Elle affiche :
|
|
719
|
+
|
|
720
|
+
- Toutes les étapes sous forme de **sections distinctes**
|
|
721
|
+
- Pour chaque champ rempli : son **label** et sa **valeur** formatée
|
|
722
|
+
- Un bouton **Modifier** par étape pour naviguer directement vers elle
|
|
723
|
+
- Les types spéciaux sont formatés intelligemment :
|
|
724
|
+
- `checkbox` → "Oui" / "Non"
|
|
725
|
+
- `select` / `radio` → le **label** de l'option (pas la valeur brute)
|
|
726
|
+
- `date` → format `jj/mm/aaaa`
|
|
727
|
+
- `password` → `••••••••`
|
|
728
|
+
- `multiselect` → labels séparés par des virgules
|
|
729
|
+
|
|
730
|
+
### Inputs de StepperFormComponent
|
|
731
|
+
|
|
732
|
+
| Propriété | Type | Description |
|
|
733
|
+
|---|---|---|
|
|
734
|
+
| `[config]` | `StepperFormConfig` | Configuration du stepper (obligatoire) |
|
|
735
|
+
| `[initialValues]` | `Record<string, any>` | Préremplissage des champs |
|
|
736
|
+
|
|
737
|
+
### Outputs de StepperFormComponent
|
|
738
|
+
|
|
739
|
+
| Événement | Type | Description |
|
|
740
|
+
|---|---|---|
|
|
741
|
+
| `(formSubmit)` | `DynamicFormSubmitEvent` | Toutes les étapes valides — données fusionnées |
|
|
742
|
+
| `(formChange)` | `Record<string, any>` | Émis à chaque modification (toutes étapes) |
|
|
743
|
+
| `(stepChange)` | `number` | Index de la nouvelle étape active |
|
|
744
|
+
|
|
745
|
+
---
|
|
746
|
+
|
|
487
747
|
## provideNgxForms — configuration globale
|
|
488
748
|
|
|
489
749
|
`provideNgxForms()` est la fonction de configuration du plugin. Elle enregistre le `FormConfigService` et l'adaptateur de stockage dans le contexte Angular.
|
|
@@ -492,6 +752,7 @@ this.formRef.patchValues({ name: 'Nouveau nom' });
|
|
|
492
752
|
|
|
493
753
|
```typescript
|
|
494
754
|
// app.config.ts
|
|
755
|
+
import { provideHttpClient } from '@angular/common/http';
|
|
495
756
|
import { provideNgxForms } from '@suntelecoms/ngx-dynamic-form';
|
|
496
757
|
|
|
497
758
|
providers: [
|
|
@@ -499,19 +760,39 @@ providers: [
|
|
|
499
760
|
]
|
|
500
761
|
```
|
|
501
762
|
|
|
763
|
+
**Avec options dynamiques depuis une API :**
|
|
764
|
+
```typescript
|
|
765
|
+
providers: [
|
|
766
|
+
provideHttpClient(), // requis pour charger les options depuis une API
|
|
767
|
+
provideNgxForms({
|
|
768
|
+
storage: 'local',
|
|
769
|
+
dataUrl: 'https://api.monprojet.com', // base URL pour les champs url: 'villes', etc.
|
|
770
|
+
}),
|
|
771
|
+
]
|
|
772
|
+
```
|
|
773
|
+
|
|
502
774
|
### Stockage API REST (Spring Boot)
|
|
503
775
|
|
|
504
776
|
```typescript
|
|
505
777
|
// app.config.ts
|
|
506
778
|
providers: [
|
|
779
|
+
provideHttpClient(), // requis
|
|
507
780
|
provideNgxForms({
|
|
508
781
|
storage: 'http',
|
|
509
|
-
apiUrl: 'https://api.monprojet.com/forms',
|
|
782
|
+
apiUrl: 'https://api.monprojet.com/forms', // stockage des schémas
|
|
783
|
+
dataUrl: 'https://api.monprojet.com', // options dynamiques des champs
|
|
510
784
|
}),
|
|
511
|
-
provideHttpClient(), // requis pour le mode http
|
|
512
785
|
]
|
|
513
786
|
```
|
|
514
787
|
|
|
788
|
+
### Options de configuration
|
|
789
|
+
|
|
790
|
+
| Option | Type | Description |
|
|
791
|
+
|---|---|---|
|
|
792
|
+
| `storage` | `'local' \| 'http'` | Moteur de stockage des schémas |
|
|
793
|
+
| `apiUrl` | `string` | _(mode `http` uniquement)_ URL de l'API de stockage |
|
|
794
|
+
| `dataUrl` | `string` | _(optionnel)_ Base URL pour le chargement des options de champs |
|
|
795
|
+
|
|
515
796
|
L'API doit exposer les endpoints suivants :
|
|
516
797
|
|
|
517
798
|
```
|
|
@@ -527,6 +808,8 @@ DELETE /forms/:id → void
|
|
|
527
808
|
|
|
528
809
|
`FormConfigService` est fourni par `provideNgxForms()`. Il gère les schémas de formulaires avec un **Signal réactif** et une **API Observable**.
|
|
529
810
|
|
|
811
|
+
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.
|
|
812
|
+
|
|
530
813
|
```typescript
|
|
531
814
|
import { inject } from '@angular/core';
|
|
532
815
|
import { FormConfigService } from '@suntelecoms/ngx-dynamic-form';
|
|
@@ -534,7 +817,7 @@ import { FormConfigService } from '@suntelecoms/ngx-dynamic-form';
|
|
|
534
817
|
export class MonComposant {
|
|
535
818
|
private formService = inject(FormConfigService);
|
|
536
819
|
|
|
537
|
-
// Signal réactif — mise à jour
|
|
820
|
+
// Signal réactif — liste mise à jour automatiquement
|
|
538
821
|
readonly schemas = this.formService.schemas; // Signal<SavedFormSchema[]>
|
|
539
822
|
|
|
540
823
|
// Lecture synchrone
|
|
@@ -542,18 +825,16 @@ export class MonComposant {
|
|
|
542
825
|
return this.formService.get(id); // SavedFormSchema | null
|
|
543
826
|
}
|
|
544
827
|
|
|
545
|
-
// Sauvegarde —
|
|
546
|
-
saveForm(id: string, title: string, config:
|
|
828
|
+
// Sauvegarde — fonctionne pour DynamicFormConfig ET StepperFormConfig
|
|
829
|
+
saveForm(id: string, title: string, config: AnyFormConfig) {
|
|
547
830
|
this.formService.save(id, title, config).subscribe(schema => {
|
|
548
831
|
console.log('Sauvegardé :', schema);
|
|
549
832
|
});
|
|
550
833
|
}
|
|
551
834
|
|
|
552
|
-
// Suppression
|
|
835
|
+
// Suppression
|
|
553
836
|
deleteForm(id: string) {
|
|
554
|
-
this.formService.delete(id).subscribe(() =>
|
|
555
|
-
console.log('Supprimé');
|
|
556
|
-
});
|
|
837
|
+
this.formService.delete(id).subscribe(() => console.log('Supprimé'));
|
|
557
838
|
}
|
|
558
839
|
|
|
559
840
|
// Génère un ID unique
|
|
@@ -567,11 +848,14 @@ export class MonComposant {
|
|
|
567
848
|
|
|
568
849
|
```typescript
|
|
569
850
|
interface SavedFormSchema {
|
|
570
|
-
id: string;
|
|
571
|
-
title: string;
|
|
572
|
-
config:
|
|
573
|
-
updatedAt: string;
|
|
851
|
+
id: string; // Identifiant unique
|
|
852
|
+
title: string; // Nom du formulaire
|
|
853
|
+
config: AnyFormConfig; // DynamicFormConfig OU StepperFormConfig
|
|
854
|
+
updatedAt: string; // ISO 8601
|
|
574
855
|
}
|
|
856
|
+
|
|
857
|
+
// AnyFormConfig = DynamicFormConfig | StepperFormConfig
|
|
858
|
+
// Pour distinguer les deux : 'steps' in config → c'est un StepperFormConfig
|
|
575
859
|
```
|
|
576
860
|
|
|
577
861
|
---
|
|
@@ -599,15 +883,15 @@ localStorage['ngx-dynamic-form__schemas'] = [ { id, title, config, updatedAt },
|
|
|
599
883
|
|
|
600
884
|
```typescript
|
|
601
885
|
import { Injectable } from '@angular/core';
|
|
602
|
-
import { Observable
|
|
886
|
+
import { Observable } from 'rxjs';
|
|
603
887
|
import { FormStorageAdapter, SavedFormSchema } from '@suntelecoms/ngx-dynamic-form';
|
|
604
888
|
|
|
605
889
|
@Injectable()
|
|
606
890
|
export class IndexedDBAdapter extends FormStorageAdapter {
|
|
607
|
-
list():
|
|
608
|
-
get(id: string):
|
|
609
|
-
save(schema: SavedFormSchema): Observable<SavedFormSchema>
|
|
610
|
-
delete(id: string):
|
|
891
|
+
list(): Observable<SavedFormSchema[]> { /* ... */ }
|
|
892
|
+
get(id: string): Observable<SavedFormSchema | null> { /* ... */ }
|
|
893
|
+
save(schema: SavedFormSchema): Observable<SavedFormSchema> { /* ... */ }
|
|
894
|
+
delete(id: string): Observable<void> { /* ... */ }
|
|
611
895
|
}
|
|
612
896
|
|
|
613
897
|
// app.config.ts
|
|
@@ -621,7 +905,7 @@ providers: [
|
|
|
621
905
|
|
|
622
906
|
## Form Builder — éditeur visuel
|
|
623
907
|
|
|
624
|
-
Le **Form Builder** est une interface 3 panneaux intégrée
|
|
908
|
+
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
909
|
|
|
626
910
|
### Ajouter la route
|
|
627
911
|
|
|
@@ -636,23 +920,36 @@ Le **Form Builder** est une interface 3 panneaux intégrée directement dans le
|
|
|
636
920
|
|
|
637
921
|
```
|
|
638
922
|
┌──────────────────┬───────────────────────────────┬─────────────────────┐
|
|
639
|
-
│ Palette │
|
|
640
|
-
│ │
|
|
641
|
-
│
|
|
642
|
-
│
|
|
643
|
-
│
|
|
644
|
-
│
|
|
645
|
-
│
|
|
646
|
-
│
|
|
647
|
-
│ [
|
|
648
|
-
│ [
|
|
649
|
-
│ ...
|
|
650
|
-
│ │
|
|
651
|
-
│ Formulaires │
|
|
652
|
-
│ sauvegardés │
|
|
923
|
+
│ Palette │ [Formulaire] [Stepper] │ Propriétés │
|
|
924
|
+
│ │ Schéma / Aperçu │ (champ sélect.) │
|
|
925
|
+
│ ÉTAPES (stepper)│ │ │
|
|
926
|
+
│ ① Étape 1 ✏X│ ┌────────────────────────┐ │ Label : Nom │
|
|
927
|
+
│ ② Étape 2 ✏X│ │ Nom (text) ↑↓⎘🗑 │ │ Col : 6/12 │
|
|
928
|
+
│ + Ajouter │ │ Email (email) ↑↓⎘🗑 │ │ Icône : person │
|
|
929
|
+
│ │ └────────────────────────┘ │ Required : ✓ │
|
|
930
|
+
│ TYPES DE CHAMPS │ │ │
|
|
931
|
+
│ [Texte] │ Paramètres du formulaire │ Validation │
|
|
932
|
+
│ [E-mail] │ Bouton Envoyer : [Envoyer] │ Options │
|
|
933
|
+
│ [Select] ... │ [ ] Réinitialiser │ │
|
|
934
|
+
│ │ [✓] Récapitulatif (stepper) │ │
|
|
935
|
+
│ Formulaires │ │ │
|
|
936
|
+
│ sauvegardés │ [Schéma] [Aperçu] │ │
|
|
653
937
|
└──────────────────┴───────────────────────────────┴─────────────────────┘
|
|
654
938
|
```
|
|
655
939
|
|
|
940
|
+
### Mode Stepper dans le Builder
|
|
941
|
+
|
|
942
|
+
En mode Stepper, la palette affiche en haut la liste des **étapes** :
|
|
943
|
+
|
|
944
|
+
- **Cliquer sur une étape** → affiche ses champs dans le canvas
|
|
945
|
+
- **Icône crayon** → renommer l'étape
|
|
946
|
+
- **Icône ×** → supprimer l'étape
|
|
947
|
+
- **+ Ajouter une étape** → crée une nouvelle étape vide
|
|
948
|
+
|
|
949
|
+
Les champs sont ajoutés à **l'étape active**. Chaque étape a ses propres champs indépendants.
|
|
950
|
+
|
|
951
|
+
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.
|
|
952
|
+
|
|
656
953
|
### Fonctionnalités du Builder
|
|
657
954
|
|
|
658
955
|
| Action | Description |
|
|
@@ -662,13 +959,16 @@ Le **Form Builder** est une interface 3 panneaux intégrée directement dans le
|
|
|
662
959
|
| Dupliquer | Copie d'un champ avec toutes ses propriétés |
|
|
663
960
|
| Supprimer | Icône corbeille |
|
|
664
961
|
| Éditer | Panneau droit — label, col, icône, validation, options… |
|
|
665
|
-
|
|
|
962
|
+
| Mode Stepper | Bascule Formulaire ↔ Stepper en haut de page |
|
|
963
|
+
| Gérer les étapes | Créer, renommer, supprimer les étapes |
|
|
964
|
+
| Récapitulatif | Case à cocher pour activer l'étape de synthèse |
|
|
965
|
+
| Aperçu | Onglet **Aperçu** — rendu réel en temps réel |
|
|
666
966
|
| Sauvegarder | Stocke en localStorage (ou API) avec ID unique |
|
|
667
967
|
| Export JSON | JSON de la config dans un modal copiable |
|
|
668
|
-
| Export TypeScript | `const config: DynamicFormConfig = { ... }` |
|
|
968
|
+
| Export TypeScript | `const config: DynamicFormConfig = { ... }` ou `StepperFormConfig` |
|
|
669
969
|
| Partager | Copie l'URL `/form/<id>` dans le presse-papiers |
|
|
670
970
|
|
|
671
|
-
###
|
|
971
|
+
### Input du FormBuilderComponent
|
|
672
972
|
|
|
673
973
|
| Input | Type | Défaut | Description |
|
|
674
974
|
|---|---|---|---|
|
|
@@ -680,7 +980,7 @@ Le **Form Builder** est une interface 3 panneaux intégrée directement dans le
|
|
|
680
980
|
|
|
681
981
|
### MesFormulairesComponent — `<ngx-mes-formulaires>`
|
|
682
982
|
|
|
683
|
-
Liste et aperçu de tous les formulaires sauvegardés. Permet de les prévisualiser, les soumettre, les supprimer.
|
|
983
|
+
Liste et aperçu de tous les formulaires sauvegardés (simples **et** stepper). Permet de les prévisualiser, les soumettre, les supprimer.
|
|
684
984
|
|
|
685
985
|
```typescript
|
|
686
986
|
{
|
|
@@ -697,7 +997,7 @@ Liste et aperçu de tous les formulaires sauvegardés. Permet de les prévisuali
|
|
|
697
997
|
|
|
698
998
|
### FormLoaderComponent — `<ngx-form-loader>`
|
|
699
999
|
|
|
700
|
-
Charge et affiche un formulaire depuis son ID
|
|
1000
|
+
Charge et affiche un formulaire depuis son ID — détecte automatiquement s'il s'agit d'un formulaire simple ou d'un stepper.
|
|
701
1001
|
|
|
702
1002
|
```typescript
|
|
703
1003
|
{
|
|
@@ -716,7 +1016,7 @@ Charge et affiche un formulaire depuis son ID (via `ActivatedRoute` ou `@Input`)
|
|
|
716
1016
|
|
|
717
1017
|
## Intégration dans un composant
|
|
718
1018
|
|
|
719
|
-
### Approche A —
|
|
1019
|
+
### Approche A — formulaire simple chargé par ID
|
|
720
1020
|
|
|
721
1021
|
```typescript
|
|
722
1022
|
import { Component, computed, inject, signal } from '@angular/core';
|
|
@@ -734,25 +1034,56 @@ import type { DynamicFormConfig, DynamicFormSubmitEvent } from '@suntelecoms/ngx
|
|
|
734
1034
|
})
|
|
735
1035
|
export class MonFormulaireComponent {
|
|
736
1036
|
private formService = inject(FormConfigService);
|
|
1037
|
+
selectedId = signal('votre-id-ici');
|
|
1038
|
+
activeConfig = computed(() =>
|
|
1039
|
+
this.formService.get(this.selectedId())?.config as DynamicFormConfig ?? null
|
|
1040
|
+
);
|
|
1041
|
+
onSubmit(event: DynamicFormSubmitEvent): void { console.log(event.value); }
|
|
1042
|
+
}
|
|
1043
|
+
```
|
|
1044
|
+
|
|
1045
|
+
### Approche B — stepper chargé par ID (détection automatique)
|
|
737
1046
|
|
|
738
|
-
|
|
739
|
-
|
|
1047
|
+
```typescript
|
|
1048
|
+
import { Component, computed, inject, signal } from '@angular/core';
|
|
1049
|
+
import { DynamicFormComponent, StepperFormComponent, FormConfigService } from '@suntelecoms/ngx-dynamic-form';
|
|
1050
|
+
import type { DynamicFormConfig, StepperFormConfig, DynamicFormSubmitEvent } from '@suntelecoms/ngx-dynamic-form';
|
|
740
1051
|
|
|
741
|
-
|
|
1052
|
+
@Component({
|
|
1053
|
+
standalone: true,
|
|
1054
|
+
imports: [DynamicFormComponent, StepperFormComponent],
|
|
1055
|
+
template: `
|
|
1056
|
+
@if (flatConfig(); as flatCfg) {
|
|
1057
|
+
<ngx-dynamic-form [config]="flatCfg" (formSubmit)="onSubmit($event)" />
|
|
1058
|
+
}
|
|
1059
|
+
@if (stepperConfig(); as stepperCfg) {
|
|
1060
|
+
<ngx-stepper-form [config]="stepperCfg" (formSubmit)="onSubmit($event)" />
|
|
1061
|
+
}
|
|
1062
|
+
`,
|
|
1063
|
+
})
|
|
1064
|
+
export class MonFormulaireComponent {
|
|
1065
|
+
private formService = inject(FormConfigService);
|
|
742
1066
|
selectedId = signal('votre-id-ici');
|
|
743
1067
|
|
|
744
|
-
|
|
745
|
-
activeConfig = computed(() =>
|
|
746
|
-
this.formService.get(this.selectedId())?.config ?? null
|
|
747
|
-
);
|
|
1068
|
+
private anyConfig = computed(() => this.formService.get(this.selectedId())?.config ?? null);
|
|
748
1069
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
1070
|
+
// Formulaire simple : n'a pas de propriété "steps"
|
|
1071
|
+
flatConfig = computed<DynamicFormConfig | null>(() => {
|
|
1072
|
+
const c = this.anyConfig();
|
|
1073
|
+
return c && !('steps' in c) ? c as DynamicFormConfig : null;
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
// Formulaire stepper : a une propriété "steps"
|
|
1077
|
+
stepperConfig = computed<StepperFormConfig | null>(() => {
|
|
1078
|
+
const c = this.anyConfig();
|
|
1079
|
+
return c && 'steps' in c ? c as StepperFormConfig : null;
|
|
1080
|
+
});
|
|
1081
|
+
|
|
1082
|
+
onSubmit(event: DynamicFormSubmitEvent): void { console.log(event.value); }
|
|
752
1083
|
}
|
|
753
1084
|
```
|
|
754
1085
|
|
|
755
|
-
### Approche
|
|
1086
|
+
### Approche C — configuration TypeScript statique
|
|
756
1087
|
|
|
757
1088
|
```typescript
|
|
758
1089
|
import { Component } from '@angular/core';
|
|
@@ -772,18 +1103,15 @@ export class ContactComponent {
|
|
|
772
1103
|
{ key: 'email', type: 'email', label: 'E-mail', col: 6, validation: { required: true } },
|
|
773
1104
|
],
|
|
774
1105
|
};
|
|
775
|
-
|
|
776
|
-
onSubmit(event: DynamicFormSubmitEvent): void {
|
|
777
|
-
console.log(event.value);
|
|
778
|
-
}
|
|
1106
|
+
onSubmit(event: DynamicFormSubmitEvent): void { console.log(event.value); }
|
|
779
1107
|
}
|
|
780
1108
|
```
|
|
781
1109
|
|
|
782
1110
|
> **Astuce :** créez le formulaire dans le Builder (`/builder`) → cliquez **Export TypeScript** → collez dans votre composant.
|
|
783
1111
|
|
|
784
|
-
### Approche
|
|
1112
|
+
### Approche D — avec backend API REST (Spring Boot)
|
|
785
1113
|
|
|
786
|
-
Configurez
|
|
1114
|
+
Configurez `provideNgxForms({ storage: 'http', apiUrl: '...' })` — tout le reste est identique. Le `FormConfigService` appellera automatiquement votre API au lieu de localStorage.
|
|
787
1115
|
|
|
788
1116
|
```typescript
|
|
789
1117
|
// app.config.ts
|
|
@@ -799,10 +1127,11 @@ provideHttpClient(),
|
|
|
799
1127
|
@RestController
|
|
800
1128
|
@RequestMapping("/forms")
|
|
801
1129
|
public class FormController {
|
|
802
|
-
@GetMapping
|
|
803
|
-
@GetMapping("/{id}") SavedFormSchema get(@PathVariable String id)
|
|
804
|
-
@PutMapping("/{id}") SavedFormSchema save(@PathVariable String id,
|
|
805
|
-
|
|
1130
|
+
@GetMapping List<SavedFormSchema> list() { ... }
|
|
1131
|
+
@GetMapping("/{id}") SavedFormSchema get(@PathVariable String id) { ... }
|
|
1132
|
+
@PutMapping("/{id}") SavedFormSchema save(@PathVariable String id,
|
|
1133
|
+
@RequestBody SavedFormSchema s) { ... }
|
|
1134
|
+
@DeleteMapping("/{id}") void delete(@PathVariable String id) { ... }
|
|
806
1135
|
}
|
|
807
1136
|
```
|
|
808
1137
|
|
|
@@ -818,9 +1147,9 @@ L'application de démonstration (`ng serve`) illustre le plugin sur plusieurs ca
|
|
|
818
1147
|
| `/inscription` | Formulaire multi-sections avec `showWhen` |
|
|
819
1148
|
| `/contact` | Formulaire de contact (select, textarea, radio) |
|
|
820
1149
|
| `/produit` | Fiche produit — modes vue / édition / création |
|
|
821
|
-
| `/builder` | **Form Builder** —
|
|
822
|
-
| `/mes-formulaires` | **Gestionnaire** —
|
|
823
|
-
| `/form/:id` | **Rendu par ID** —
|
|
1150
|
+
| `/builder` | **Form Builder** — modes Formulaire et Stepper |
|
|
1151
|
+
| `/mes-formulaires` | **Gestionnaire** — liste et aperçu de tous les formulaires |
|
|
1152
|
+
| `/form/:id` | **Rendu par ID** — formulaire simple ou stepper automatiquement |
|
|
824
1153
|
|
|
825
1154
|
---
|
|
826
1155
|
|
|
@@ -859,6 +1188,65 @@ config: DynamicFormConfig = {
|
|
|
859
1188
|
};
|
|
860
1189
|
```
|
|
861
1190
|
|
|
1191
|
+
### Formulaire stepper — processus d'inscription en 3 étapes
|
|
1192
|
+
|
|
1193
|
+
```typescript
|
|
1194
|
+
config: StepperFormConfig = {
|
|
1195
|
+
showSummary: true,
|
|
1196
|
+
submitLabel: 'Créer mon compte',
|
|
1197
|
+
steps: [
|
|
1198
|
+
{
|
|
1199
|
+
label: 'Identité',
|
|
1200
|
+
icon: 'person',
|
|
1201
|
+
fields: [
|
|
1202
|
+
{ key: 'firstName', type: 'text', label: 'Prénom', col: 6, validation: { required: true } },
|
|
1203
|
+
{ key: 'lastName', type: 'text', label: 'Nom', col: 6, validation: { required: true } },
|
|
1204
|
+
{ key: 'birthDate', type: 'date', label: 'Date de naissance', col: 6 },
|
|
1205
|
+
{ key: 'gender', type: 'select', label: 'Genre', col: 6,
|
|
1206
|
+
options: [{ label: 'Homme', value: 'M' }, { label: 'Femme', value: 'F' }] },
|
|
1207
|
+
],
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
label: 'Coordonnées',
|
|
1211
|
+
icon: 'contact_mail',
|
|
1212
|
+
fields: [
|
|
1213
|
+
{ key: 'email', type: 'email', label: 'E-mail', col: 12,
|
|
1214
|
+
validation: { required: true, email: true } },
|
|
1215
|
+
{ key: 'phone', type: 'tel', label: 'Téléphone', col: 6 },
|
|
1216
|
+
{ key: 'city', type: 'text', label: 'Ville', col: 6 },
|
|
1217
|
+
],
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
label: 'Sécurité',
|
|
1221
|
+
icon: 'lock',
|
|
1222
|
+
fields: [
|
|
1223
|
+
{ key: 'password', type: 'password', label: 'Mot de passe', col: 6,
|
|
1224
|
+
validation: { required: true, custom: v => v?.length < 8 ? 'Minimum 8 caractères' : null } },
|
|
1225
|
+
{ key: 'terms', type: 'checkbox', placeholder: "J'accepte les CGU", col: 12,
|
|
1226
|
+
validation: { required: true } },
|
|
1227
|
+
],
|
|
1228
|
+
},
|
|
1229
|
+
],
|
|
1230
|
+
};
|
|
1231
|
+
```
|
|
1232
|
+
|
|
1233
|
+
Le récapitulatif final affichera automatiquement :
|
|
1234
|
+
```
|
|
1235
|
+
── Identité ─────────────── [Modifier]
|
|
1236
|
+
Prénom Jean
|
|
1237
|
+
Nom Dupont
|
|
1238
|
+
Date de naissance 15/03/1990
|
|
1239
|
+
Genre Homme
|
|
1240
|
+
|
|
1241
|
+
── Coordonnées ─────────── [Modifier]
|
|
1242
|
+
E-mail jean@example.com
|
|
1243
|
+
Téléphone +33 6 12 34 56 78
|
|
1244
|
+
|
|
1245
|
+
── Sécurité ─────────────── [Modifier]
|
|
1246
|
+
Mot de passe ••••••••
|
|
1247
|
+
J'accepte les CGU Oui
|
|
1248
|
+
```
|
|
1249
|
+
|
|
862
1250
|
### Fiche produit avec préremplissage et mode vue/édition
|
|
863
1251
|
|
|
864
1252
|
```typescript
|
|
@@ -912,6 +1300,7 @@ Pour les couleurs des champs Material (outline, focus, erreur), personnalisez le
|
|
|
912
1300
|
|
|
913
1301
|
// Composants
|
|
914
1302
|
export { DynamicFormComponent } // <ngx-dynamic-form>
|
|
1303
|
+
export { StepperFormComponent } // <ngx-stepper-form> ← v1.2.0
|
|
915
1304
|
export { FormBuilderComponent } // <ngx-form-builder>
|
|
916
1305
|
export { MesFormulairesComponent } // <ngx-mes-formulaires>
|
|
917
1306
|
export { FormLoaderComponent } // <ngx-form-loader>
|
|
@@ -923,13 +1312,17 @@ export { LocalStorageAdapter } // implémentation localStorage
|
|
|
923
1312
|
export { HttpStorageAdapter } // implémentation API REST
|
|
924
1313
|
export { FORM_API_URL } // InjectionToken<string>
|
|
925
1314
|
export { provideNgxForms } // function(options) → EnvironmentProviders
|
|
1315
|
+
export { NGX_DATA_API_URL } // InjectionToken<string> — base URL pour les options dynamiques ← v1.2.5
|
|
926
1316
|
|
|
927
1317
|
// Types
|
|
928
|
-
export type { NgxFormsOptions }
|
|
929
|
-
export type {
|
|
1318
|
+
export type { NgxFormsOptions } // { storage: 'local' } | { storage: 'http', apiUrl: string }
|
|
1319
|
+
export type { AnyFormConfig } // DynamicFormConfig | StepperFormConfig ← v1.2.0
|
|
1320
|
+
export type { SavedFormSchema } // { id, title, config: AnyFormConfig, updatedAt }
|
|
930
1321
|
export type { DynamicFormConfig }
|
|
931
1322
|
export type { DynamicFormField }
|
|
932
1323
|
export type { DynamicFormSubmitEvent }
|
|
1324
|
+
export type { StepperFormConfig } // ← v1.2.0
|
|
1325
|
+
export type { FormStep } // ← v1.2.0
|
|
933
1326
|
export type { FieldType }
|
|
934
1327
|
export type { FieldValidation }
|
|
935
1328
|
export type { FieldCondition }
|
|
@@ -938,6 +1331,30 @@ export type { SelectOption }
|
|
|
938
1331
|
|
|
939
1332
|
---
|
|
940
1333
|
|
|
1334
|
+
## Changelog
|
|
1335
|
+
|
|
1336
|
+
### v1.2.5
|
|
1337
|
+
- Options dynamiques depuis une API pour les champs `select`, `multiselect`, `radio` : nouvelles propriétés `url`, `displayName`, `displayValue` sur `DynamicFormField`
|
|
1338
|
+
- Token `NGX_DATA_API_URL` et option `dataUrl` dans `provideNgxForms()` pour configurer la base URL
|
|
1339
|
+
- Form Builder : toggle **Statiques / Depuis une API** dans le panneau Options — paramétrage visuel de `url`, `displayName`, `displayValue`
|
|
1340
|
+
- Spinner de chargement dans le dropdown pendant le fetch des options
|
|
1341
|
+
|
|
1342
|
+
### v1.2.0
|
|
1343
|
+
- Ajout du composant `<ngx-stepper-form>` pour les formulaires multi-étapes
|
|
1344
|
+
- Étape **Récapitulatif** automatique (`showSummary: true`) avec boutons Modifier par étape
|
|
1345
|
+
- Mode **Stepper** dans le Form Builder : gestion des étapes (créer, renommer, supprimer), aperçu en temps réel
|
|
1346
|
+
- Case "Afficher Récapitulatif" dans les paramètres du Builder
|
|
1347
|
+
- `AnyFormConfig` = `DynamicFormConfig | StepperFormConfig` — `SavedFormSchema.config` supporte les deux
|
|
1348
|
+
- `MesFormulairesComponent` et `FormLoaderComponent` détectent et rendent automatiquement les deux types
|
|
1349
|
+
|
|
1350
|
+
### v1.1.0
|
|
1351
|
+
- Grille 12 colonnes (`col`) intégrée dans les styles du composant
|
|
1352
|
+
- Form Builder, MesFormulaires et FormLoader intégrés dans le plugin
|
|
1353
|
+
- Système de stockage abstrait (localStorage / API REST)
|
|
1354
|
+
- `FormConfigService` Signal-based
|
|
1355
|
+
|
|
1356
|
+
---
|
|
1357
|
+
|
|
941
1358
|
## Auteur
|
|
942
1359
|
|
|
943
1360
|
**Amadou Diallo** — [@amepro](https://github.com/amepro)
|