@suntelecoms/ngx-dynamic-form 1.7.21 → 1.8.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.
- package/README.md +80 -2
- package/fesm2022/suntelecoms-ngx-dynamic-form.mjs +233 -8
- package/fesm2022/suntelecoms-ngx-dynamic-form.mjs.map +1 -1
- package/lib/components/dynamic-field/dynamic-field.component.d.ts +12 -0
- package/lib/components/form-builder/form-builder.component.d.ts +3 -1
- package/lib/models/form-field.model.d.ts +24 -0
- package/lib/services/dynamic-form-builder.service.d.ts +8 -0
- package/package.json +1 -1
|
@@ -111,6 +111,12 @@ export declare class DynamicFieldComponent implements OnInit {
|
|
|
111
111
|
* Ex : '## ## ## ## ##' → téléphone, '##/##/####' → date.
|
|
112
112
|
*/
|
|
113
113
|
applyMask(event: Event): void;
|
|
114
|
+
private get cardValues();
|
|
115
|
+
get selectedCount(): number;
|
|
116
|
+
isOptionChecked(opt: SelectOption): boolean;
|
|
117
|
+
toggleOption(opt: SelectOption, checked: boolean): void;
|
|
118
|
+
/** Locked options are part of the value (sent with the form), not only displayed as checked. */
|
|
119
|
+
private ensureLockedOptions;
|
|
114
120
|
get isInputField(): boolean;
|
|
115
121
|
get hasOptions(): boolean;
|
|
116
122
|
get hasError(): boolean;
|
|
@@ -120,6 +126,12 @@ export declare class DynamicFieldComponent implements OnInit {
|
|
|
120
126
|
* — une période début/fin grise ainsi les dates invalides dans le calendrier. */
|
|
121
127
|
get minDate(): Date | undefined;
|
|
122
128
|
get maxDate(): Date | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Date of birth bounded by validation.minAge / maxAge, when the age is computed at today's date
|
|
131
|
+
* (with ageReferenceField the reference can change: only the validator applies).
|
|
132
|
+
* max = today − minAge years ; min = today − (maxAge + 1) years + 1 day.
|
|
133
|
+
*/
|
|
134
|
+
private ageBound;
|
|
123
135
|
/** Same bound, as 'YYYY-MM-DD' for the native <input type="date"> min/max attributes (simple appearance). */
|
|
124
136
|
get minDateAttr(): string | undefined;
|
|
125
137
|
get maxDateAttr(): string | undefined;
|
|
@@ -83,7 +83,9 @@ export declare class FormBuilderComponent {
|
|
|
83
83
|
updateValidation(prop: keyof FieldValidation, value: any): void;
|
|
84
84
|
getOptions(): SelectOption[];
|
|
85
85
|
addOption(): void;
|
|
86
|
-
updateOption(idx: number, prop: 'label' | 'value', value: string): void;
|
|
86
|
+
updateOption(idx: number, prop: 'label' | 'value' | 'dependsOnValue' | 'locked', value: string | boolean): void;
|
|
87
|
+
/** Options statiques du champ dont dépend le champ sélectionné (vide si liste API ou autre type). */
|
|
88
|
+
parentStaticOptions(): SelectOption[];
|
|
87
89
|
removeOption(idx: number): void;
|
|
88
90
|
setOptionsSource(useUrl: boolean): void;
|
|
89
91
|
private deleteProp;
|
|
@@ -5,6 +5,11 @@ export interface SelectOption {
|
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
group?: string;
|
|
7
7
|
dependsOnValue?: any;
|
|
8
|
+
/**
|
|
9
|
+
* type: 'multiselect' + display: 'cards' — option always selected and not deselectable
|
|
10
|
+
* (badge « Obligatoire »), e.g. a mandatory guarantee.
|
|
11
|
+
*/
|
|
12
|
+
locked?: boolean;
|
|
8
13
|
}
|
|
9
14
|
export interface FieldCondition {
|
|
10
15
|
field: string;
|
|
@@ -26,6 +31,15 @@ export interface FieldValidation {
|
|
|
26
31
|
maxField?: string;
|
|
27
32
|
/** This field's numeric value must be >= the value of the named sibling field */
|
|
28
33
|
minField?: string;
|
|
34
|
+
/**
|
|
35
|
+
* type: 'date' (date of birth) — minimum age in completed years, computed at `ageReferenceField`
|
|
36
|
+
* (another date field of the form, e.g. the effective date) or today when not set.
|
|
37
|
+
*/
|
|
38
|
+
minAge?: number;
|
|
39
|
+
/** type: 'date' (date of birth) — maximum age in completed years (same reference as minAge). */
|
|
40
|
+
maxAge?: number;
|
|
41
|
+
/** Date field used as the reference date for minAge / maxAge (default: today). */
|
|
42
|
+
ageReferenceField?: string;
|
|
29
43
|
messages?: {
|
|
30
44
|
required?: string;
|
|
31
45
|
minLength?: string;
|
|
@@ -39,6 +53,9 @@ export interface FieldValidation {
|
|
|
39
53
|
/** type: 'date' — shown when the value is before field.minDate / after field.maxDate */
|
|
40
54
|
minDate?: string;
|
|
41
55
|
maxDate?: string;
|
|
56
|
+
/** type: 'date' — age below minAge / above maxAge */
|
|
57
|
+
minAge?: string;
|
|
58
|
+
maxAge?: string;
|
|
42
59
|
};
|
|
43
60
|
}
|
|
44
61
|
/** Auto-populate sibling fields from an API call when this field loses focus */
|
|
@@ -118,6 +135,13 @@ export interface DynamicFormField {
|
|
|
118
135
|
minDate?: string;
|
|
119
136
|
maxDate?: string;
|
|
120
137
|
dateLocale?: string;
|
|
138
|
+
/**
|
|
139
|
+
* type: 'multiselect' — 'select' (default): drop-down list; 'cards': grid of checkbox cards with a
|
|
140
|
+
* « n / total » counter, hint shown under the label, `locked` options always selected.
|
|
141
|
+
*/
|
|
142
|
+
display?: 'select' | 'cards';
|
|
143
|
+
/** display: 'cards' — word after the counter, e.g. 'retenue(s)' (default 'sélectionnée(s)'). */
|
|
144
|
+
counterLabel?: string;
|
|
121
145
|
min?: number;
|
|
122
146
|
max?: number;
|
|
123
147
|
step?: number;
|
|
@@ -19,8 +19,16 @@ export declare class DynamicFormBuilderService {
|
|
|
19
19
|
* error display in DynamicFieldComponent picks it up automatically.
|
|
20
20
|
*/
|
|
21
21
|
private crossFieldBoundValidator;
|
|
22
|
+
/**
|
|
23
|
+
* Group-level validator for a date of birth: age in completed years at the reference date
|
|
24
|
+
* (`referenceKey` field, or today) must be within [minAge, maxAge]. Sets `minAge` / `maxAge`
|
|
25
|
+
* errors (message string) on the field control, like crossFieldBoundValidator.
|
|
26
|
+
*/
|
|
27
|
+
private ageValidator;
|
|
22
28
|
/** Group-level validator: at least one of the listed field keys must have a non-empty value */
|
|
23
29
|
atLeastOneOfValidator(keys: string[], msg?: string): ValidatorFn;
|
|
24
30
|
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicFormBuilderService, never>;
|
|
25
31
|
static ɵprov: i0.ɵɵInjectableDeclaration<DynamicFormBuilderService>;
|
|
26
32
|
}
|
|
33
|
+
/** Completed years between two dates (birthday not reached yet = one year less). */
|
|
34
|
+
export declare function completedYears(birth: Date, at: Date): number;
|
package/package.json
CHANGED