@suntelecoms/ngx-dynamic-form 1.8.0 → 1.9.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.
@@ -1,4 +1,4 @@
1
- import { EventEmitter, OnInit } from '@angular/core';
1
+ import { EventEmitter, OnInit, Type } from '@angular/core';
2
2
  import { FormControl, FormGroup } from '@angular/forms';
3
3
  import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
4
4
  import { DynamicFormField, SelectOption } from '../../models/form-field.model';
@@ -20,6 +20,7 @@ export declare class DynamicFieldComponent implements OnInit {
20
20
  private evaluator;
21
21
  private http;
22
22
  private dataApiUrl;
23
+ private customFields;
23
24
  private globalDateLocale;
24
25
  private dateAdapter;
25
26
  private cdr;
@@ -111,6 +112,13 @@ export declare class DynamicFieldComponent implements OnInit {
111
112
  * Ex : '## ## ## ## ##' → téléphone, '##/##/####' → date.
112
113
  */
113
114
  applyMask(event: Event): void;
115
+ /** Item d'API -> option (label, value, et locked / group si optionLockedKey / optionGroupKey). */
116
+ private toOption;
117
+ /** Options sans groupe (cases à cocher), puis groupes exclusifs « Une seule option ». */
118
+ get cardSections(): {
119
+ group: string | null;
120
+ options: SelectOption[];
121
+ }[];
114
122
  private get cardValues();
115
123
  get selectedCount(): number;
116
124
  isOptionChecked(opt: SelectOption): boolean;
@@ -118,6 +126,8 @@ export declare class DynamicFieldComponent implements OnInit {
118
126
  /** Locked options are part of the value (sent with the form), not only displayed as checked. */
119
127
  private ensureLockedOptions;
120
128
  get isInputField(): boolean;
129
+ /** type: 'custom' — composant déclaré par l'application (provideNgxForms({ customFields })). */
130
+ get customComponent(): Type<unknown> | null;
121
131
  get hasOptions(): boolean;
122
132
  get hasError(): boolean;
123
133
  get errorMessage(): string | null;
@@ -22,6 +22,11 @@ export declare const ICON_OPTIONS: {
22
22
  export declare class FormBuilderComponent {
23
23
  backRoute: string;
24
24
  private formService;
25
+ /** Noms des composants déclarés pour les champs « Composant personnalisé » (provideNgxForms customFields). */
26
+ readonly customFieldNames: string[];
27
+ /** componentConfig édité en JSON ; texte invalide conservé tant qu'il n'est pas corrigé. */
28
+ componentConfigText(): string;
29
+ updateComponentConfig(text: string): void;
25
30
  private snack;
26
31
  private route;
27
32
  constructor();
@@ -1,4 +1,4 @@
1
- export type FieldType = 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'textarea' | 'select' | 'multiselect' | 'checkbox' | 'radio' | 'switch' | 'date' | 'datetime-local' | 'time' | 'month' | 'week' | 'range' | 'color' | 'location' | 'file' | 'hidden' | 'phone' | 'iso-country' | 'country-dial-code' | 'divider' | 'heading';
1
+ export type FieldType = 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'textarea' | 'select' | 'multiselect' | 'checkbox' | 'radio' | 'switch' | 'date' | 'datetime-local' | 'time' | 'month' | 'week' | 'range' | 'color' | 'location' | 'file' | 'hidden' | 'phone' | 'iso-country' | 'country-dial-code' | 'divider' | 'heading' | 'custom';
2
2
  export interface SelectOption {
3
3
  label: string;
4
4
  value: any;
@@ -142,6 +142,24 @@ export interface DynamicFormField {
142
142
  display?: 'select' | 'cards';
143
143
  /** display: 'cards' — word after the counter, e.g. 'retenue(s)' (default 'sélectionnée(s)'). */
144
144
  counterLabel?: string;
145
+ /**
146
+ * Options from `url`: item property mapped to SelectOption.locked (e.g. 'obligatoire') —
147
+ * display: 'cards' shows it as an always-selected « Obligatoire » card.
148
+ */
149
+ optionLockedKey?: string;
150
+ /**
151
+ * Options from `url`: item property mapped to SelectOption.group (e.g. 'groupe') —
152
+ * display: 'cards' shows each group as an exclusive « Une seule option » section.
153
+ */
154
+ optionGroupKey?: string;
155
+ /**
156
+ * type: 'custom' — name of a component registered by the host application
157
+ * (provideNgxForms({ customFields: { name: Component } })). It receives `field` and `form`
158
+ * inputs and may write its own FormControl (form.get(field.key)).
159
+ */
160
+ component?: string;
161
+ /** type: 'custom' — free configuration passed to the component (field.componentConfig). */
162
+ componentConfig?: Record<string, any>;
145
163
  min?: number;
146
164
  max?: number;
147
165
  step?: number;
@@ -1,4 +1,4 @@
1
- import { EnvironmentProviders, InjectionToken } from '@angular/core';
1
+ import { EnvironmentProviders, InjectionToken, Type } from '@angular/core';
2
2
  import { HttpInterceptorFn } from '@angular/common/http';
3
3
  import { NGX_FORMS_LIST_PAGE_SIZE } from './storage/http-storage.adapter';
4
4
  import { NgxFormsAuthService, NgxFormsAuthOptions, NGX_FORMS_AUTH } from './auth/ngx-forms-auth.service';
@@ -15,6 +15,11 @@ export declare const NGX_DATA_API_URL: InjectionToken<string>;
15
15
  * pas de nouveau parseur de format à maintenir. Surchargeable par champ via
16
16
  * `DynamicFormField.dateLocale`.
17
17
  */
18
+ /**
19
+ * Composants des champs `type: 'custom'`, par nom (provideNgxForms({ customFields })).
20
+ * Chaque composant reçoit les inputs `field` (DynamicFormField) et `form` (FormGroup).
21
+ */
22
+ export declare const NGX_CUSTOM_FIELDS: InjectionToken<Record<string, Type<unknown>>>;
18
23
  export declare const NGX_DATE_LOCALE: InjectionToken<string>;
19
24
  export { NGX_FORMS_LIST_PAGE_SIZE };
20
25
  /**
@@ -33,6 +38,8 @@ export interface NgxFormsLocalOptions {
33
38
  auth?: NgxFormsAuthOptions;
34
39
  /** Locale par défaut des champs `type: 'date'` (ex: 'fr-FR', 'en-US'). @default 'fr-FR' */
35
40
  dateLocale?: string;
41
+ /** Composants des champs `type: 'custom'`, par nom. */
42
+ customFields?: Record<string, Type<unknown>>;
36
43
  }
37
44
  export interface NgxFormsHttpOptions {
38
45
  storage: 'http';
@@ -49,6 +56,8 @@ export interface NgxFormsHttpOptions {
49
56
  * (`GET {apiUrl}?page=0&size=...`). @default 1000
50
57
  */
51
58
  listPageSize?: number;
59
+ /** Composants des champs `type: 'custom'`, par nom. */
60
+ customFields?: Record<string, Type<unknown>>;
52
61
  }
53
62
  export type NgxFormsOptions = NgxFormsLocalOptions | NgxFormsHttpOptions;
54
63
  export declare function provideNgxForms(options: NgxFormsOptions): EnvironmentProviders;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suntelecoms/ngx-dynamic-form",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Générateur de formulaires Angular dynamiques — SUNTELECOMS",
5
5
  "author": "Amadou Diallo <amadoumacbookpro38@gmail.com>",
6
6
  "license": "MIT",
package/public-api.d.ts CHANGED
@@ -12,7 +12,7 @@ export { UniquenessValidatorService } from './lib/services/uniqueness-validator.
12
12
  export { FormStorageAdapter } from './lib/storage/form-storage.adapter';
13
13
  export { LocalStorageAdapter } from './lib/storage/local-storage.adapter';
14
14
  export { HttpStorageAdapter, FORM_API_URL, NGX_FORMS_LIST_PAGE_SIZE } from './lib/storage/http-storage.adapter';
15
- export { provideNgxForms, NGX_DATA_API_URL, ngxFormsAuthInterceptor } from './lib/providers';
15
+ export { provideNgxForms, NGX_DATA_API_URL, NGX_CUSTOM_FIELDS, ngxFormsAuthInterceptor } from './lib/providers';
16
16
  export type { NgxFormsOptions, NgxFormsLocalOptions, NgxFormsHttpOptions } from './lib/providers';
17
17
  export { NgxFormsAuthService, NGX_FORMS_AUTH } from './lib/auth/ngx-forms-auth.service';
18
18
  export type { NgxFormsAuthOptions } from './lib/auth/ngx-forms-auth.service';