@rsuci/shared-form-components 1.0.28 → 1.0.32
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/dist/components/form-renderer/ConfirmationModal.d.ts +20 -0
- package/dist/components/form-renderer/ConfirmationModal.d.ts.map +1 -0
- package/dist/components/form-renderer/ConfirmationModal.js +79 -0
- package/dist/components/form-renderer/FormActions.d.ts +21 -0
- package/dist/components/form-renderer/FormActions.d.ts.map +1 -0
- package/dist/components/form-renderer/FormActions.js +81 -0
- package/dist/components/form-renderer/FormNavigationButtons.d.ts +23 -0
- package/dist/components/form-renderer/FormNavigationButtons.d.ts.map +1 -0
- package/dist/components/form-renderer/FormNavigationButtons.js +35 -0
- package/dist/components/form-renderer/FormProgress.d.ts +19 -0
- package/dist/components/form-renderer/FormProgress.d.ts.map +1 -0
- package/dist/components/form-renderer/FormProgress.js +26 -0
- package/dist/components/form-renderer/FormRenderer.d.ts +39 -0
- package/dist/components/form-renderer/FormRenderer.d.ts.map +1 -0
- package/dist/components/form-renderer/FormRenderer.js +113 -0
- package/dist/components/form-renderer/FormRendererContext.d.ts +109 -0
- package/dist/components/form-renderer/FormRendererContext.d.ts.map +1 -0
- package/dist/components/form-renderer/FormRendererContext.js +114 -0
- package/dist/components/form-renderer/GroupeInstanceTabs.d.ts +18 -0
- package/dist/components/form-renderer/GroupeInstanceTabs.d.ts.map +1 -0
- package/dist/components/form-renderer/GroupeInstanceTabs.js +174 -0
- package/dist/components/form-renderer/index.d.ts +17 -0
- package/dist/components/form-renderer/index.d.ts.map +1 -0
- package/dist/components/form-renderer/index.js +23 -0
- package/dist/components/inputs/NumberInput.js +1 -1
- package/dist/hooks/useFormInstances.d.ts +87 -0
- package/dist/hooks/useFormInstances.d.ts.map +1 -0
- package/dist/hooks/useFormInstances.js +197 -0
- package/dist/hooks/useFormNavigation.d.ts +72 -0
- package/dist/hooks/useFormNavigation.d.ts.map +1 -0
- package/dist/hooks/useFormNavigation.js +147 -0
- package/dist/hooks/useFormRenderer.d.ts +87 -0
- package/dist/hooks/useFormRenderer.d.ts.map +1 -0
- package/dist/hooks/useFormRenderer.js +177 -0
- package/dist/hooks/useFormValidation.d.ts +50 -0
- package/dist/hooks/useFormValidation.d.ts.map +1 -0
- package/dist/hooks/useFormValidation.js +175 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -0
- package/dist/lib/__tests__/date-functions.test.d.ts +5 -0
- package/dist/lib/__tests__/date-functions.test.d.ts.map +1 -0
- package/dist/lib/__tests__/date-functions.test.js +184 -0
- package/dist/lib/utils/groupeInstanceManager.d.ts +88 -0
- package/dist/lib/utils/groupeInstanceManager.d.ts.map +1 -0
- package/dist/lib/utils/groupeInstanceManager.js +606 -0
- package/dist/types/form-renderer.d.ts +115 -1
- package/dist/types/form-renderer.d.ts.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook de validation pour les formulaires d'enquête
|
|
3
|
+
* Gère la validation des variables, groupes et instances
|
|
4
|
+
* RSU v2 - Package Partagé
|
|
5
|
+
*/
|
|
6
|
+
import { useCallback } from 'react';
|
|
7
|
+
import { GroupeInstanceManager } from '../lib/utils/groupeInstanceManager';
|
|
8
|
+
/**
|
|
9
|
+
* Hook pour gérer la validation dans un formulaire d'enquête
|
|
10
|
+
*
|
|
11
|
+
* @param options - Options de configuration
|
|
12
|
+
* @returns Objet contenant les fonctions de validation
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const {
|
|
17
|
+
* validateVariable,
|
|
18
|
+
* validateCurrentGroupRequiredFields,
|
|
19
|
+
* validateAllGroups
|
|
20
|
+
* } = useFormValidation({
|
|
21
|
+
* isVariableVisible: (v) => formTree.isVariableVisible(v.code),
|
|
22
|
+
* isControlVariable: (v) => groupes.some(g => g.codeVariable === v.code),
|
|
23
|
+
* debug: true
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function useFormValidation(options = {}) {
|
|
28
|
+
const { isVariableVisible = () => true, isControlVariable = () => false, debug = false } = options;
|
|
29
|
+
// Fonction utilitaire pour logger en mode debug
|
|
30
|
+
const log = useCallback((message, data) => {
|
|
31
|
+
if (debug) {
|
|
32
|
+
console.log(`[FormValidation] ${message}`, data || '');
|
|
33
|
+
}
|
|
34
|
+
}, [debug]);
|
|
35
|
+
/**
|
|
36
|
+
* Valide une variable individuelle selon les règles conditionnelles
|
|
37
|
+
*/
|
|
38
|
+
const validateVariable = useCallback((variable, allResponses) => {
|
|
39
|
+
const response = allResponses[variable.code];
|
|
40
|
+
const hasValue = response && response.valeur != null && response.valeur !== '';
|
|
41
|
+
// Étape 1: Variables non obligatoires → Toujours OK
|
|
42
|
+
if (!variable.estObligatoire) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
// Étape 2: Variables de contrôle → TOUJOURS requises (même si masquées)
|
|
46
|
+
if (isControlVariable(variable)) {
|
|
47
|
+
log('Validation variable de contrôle:', {
|
|
48
|
+
variableCode: variable.code,
|
|
49
|
+
hasValue,
|
|
50
|
+
isControlVariable: true
|
|
51
|
+
});
|
|
52
|
+
return Boolean(hasValue);
|
|
53
|
+
}
|
|
54
|
+
// Étape 3: Variables normales → Dépend de la visibilité
|
|
55
|
+
const isVisible = isVariableVisible(variable);
|
|
56
|
+
if (!isVisible) {
|
|
57
|
+
log('Variable obligatoire masquée ignorée:', {
|
|
58
|
+
variableCode: variable.code,
|
|
59
|
+
isVisible: false
|
|
60
|
+
});
|
|
61
|
+
return true; // Masquée = pas de validation
|
|
62
|
+
}
|
|
63
|
+
log('Validation variable normale:', {
|
|
64
|
+
variableCode: variable.code,
|
|
65
|
+
hasValue,
|
|
66
|
+
isVisible
|
|
67
|
+
});
|
|
68
|
+
return Boolean(hasValue);
|
|
69
|
+
}, [isControlVariable, isVariableVisible, log]);
|
|
70
|
+
/**
|
|
71
|
+
* Valide que toutes les instances d'un groupe multiple sont complètes
|
|
72
|
+
*/
|
|
73
|
+
const validateAllInstancesComplete = useCallback((groupe) => {
|
|
74
|
+
if (!groupe.estMultiple || !groupe.instances) {
|
|
75
|
+
return true; // Groupe normal, validation standard
|
|
76
|
+
}
|
|
77
|
+
// TOUS les onglets doivent être complets
|
|
78
|
+
return groupe.instances.every(instance => GroupeInstanceManager.isInstanceComplete(instance, groupe));
|
|
79
|
+
}, []);
|
|
80
|
+
/**
|
|
81
|
+
* Valide les champs obligatoires du groupe actuel
|
|
82
|
+
*/
|
|
83
|
+
const validateCurrentGroupRequiredFields = useCallback((currentGroup, responses) => {
|
|
84
|
+
if (!currentGroup || !currentGroup.variables)
|
|
85
|
+
return true;
|
|
86
|
+
if (currentGroup.estMultiple) {
|
|
87
|
+
// Pour les groupes multiples, TOUTES les instances doivent être complètes
|
|
88
|
+
return validateAllInstancesComplete(currentGroup);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// Pour les groupes normaux, utiliser la validation conditionnelle
|
|
92
|
+
const requiredVariables = currentGroup.variables.filter(v => v.estObligatoire);
|
|
93
|
+
for (const variable of requiredVariables) {
|
|
94
|
+
if (!validateVariable(variable, responses)) {
|
|
95
|
+
log('Validation groupe actuel échouée:', {
|
|
96
|
+
variableCode: variable.code,
|
|
97
|
+
isControlVariable: isControlVariable(variable),
|
|
98
|
+
isVisible: isVariableVisible(variable)
|
|
99
|
+
});
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}, [validateVariable, validateAllInstancesComplete, isControlVariable, isVariableVisible, log]);
|
|
106
|
+
/**
|
|
107
|
+
* Valide un groupe complet et retourne les erreurs
|
|
108
|
+
*/
|
|
109
|
+
const validateGroup = useCallback((groupe, allResponses) => {
|
|
110
|
+
const errors = [];
|
|
111
|
+
if (groupe.estMultiple) {
|
|
112
|
+
// Pour les groupes multiples, vérifier les instances
|
|
113
|
+
if (!validateAllInstancesComplete(groupe)) {
|
|
114
|
+
errors.push({
|
|
115
|
+
variableCode: groupe.code,
|
|
116
|
+
message: 'Toutes les instances du groupe doivent être complètes',
|
|
117
|
+
type: 'required'
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
// Pour les groupes normaux
|
|
123
|
+
const requiredVariables = groupe.variables.filter(v => v.estObligatoire);
|
|
124
|
+
for (const variable of requiredVariables) {
|
|
125
|
+
if (!validateVariable(variable, allResponses)) {
|
|
126
|
+
errors.push({
|
|
127
|
+
variableCode: variable.code,
|
|
128
|
+
message: `Le champ "${variable.designation}" est obligatoire`,
|
|
129
|
+
type: 'required'
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
isValid: errors.length === 0,
|
|
136
|
+
errors
|
|
137
|
+
};
|
|
138
|
+
}, [validateVariable, validateAllInstancesComplete]);
|
|
139
|
+
/**
|
|
140
|
+
* Valide tous les groupes du formulaire
|
|
141
|
+
*/
|
|
142
|
+
const validateAllGroups = useCallback((groupes, responses) => {
|
|
143
|
+
const allErrors = [];
|
|
144
|
+
for (const groupe of groupes) {
|
|
145
|
+
const result = validateGroup(groupe, responses);
|
|
146
|
+
if (!result.isValid) {
|
|
147
|
+
allErrors.push(...result.errors);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
log('Validation de tous les groupes:', {
|
|
151
|
+
totalGroupes: groupes.length,
|
|
152
|
+
totalErrors: allErrors.length,
|
|
153
|
+
isValid: allErrors.length === 0
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
isValid: allErrors.length === 0,
|
|
157
|
+
errors: allErrors
|
|
158
|
+
};
|
|
159
|
+
}, [validateGroup, log]);
|
|
160
|
+
/**
|
|
161
|
+
* Récupère les erreurs de validation pour un groupe
|
|
162
|
+
*/
|
|
163
|
+
const getGroupValidationErrors = useCallback((groupe, responses) => {
|
|
164
|
+
return validateGroup(groupe, responses).errors;
|
|
165
|
+
}, [validateGroup]);
|
|
166
|
+
return {
|
|
167
|
+
validateVariable,
|
|
168
|
+
validateGroup,
|
|
169
|
+
validateCurrentGroupRequiredFields,
|
|
170
|
+
validateAllInstancesComplete,
|
|
171
|
+
validateAllGroups,
|
|
172
|
+
getGroupValidationErrors
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export default useFormValidation;
|
package/dist/index.d.ts
CHANGED
|
@@ -31,16 +31,28 @@ export { default as VillageInput } from './components/geographic/VillageInput';
|
|
|
31
31
|
export { default as RSUInput } from './components/selectors/RSUInput';
|
|
32
32
|
export { default as MenageInput } from './components/selectors/MenageInput';
|
|
33
33
|
export { default as EnqueteInput } from './components/selectors/EnqueteInput';
|
|
34
|
+
export { default as ConfirmationModal, type ConfirmationModalProps, type ConfirmationModalType } from './components/form-renderer/ConfirmationModal';
|
|
35
|
+
export { default as GroupeInstanceTabs, type GroupeInstanceTabsProps } from './components/form-renderer/GroupeInstanceTabs';
|
|
36
|
+
export { FormRendererProvider, useFormRendererContext, useFormRendererNavigation, useFormRendererValidation, useFormRendererInstances, useFormRendererConfig, useFormRendererResponses, useFormRendererState, type FormRendererContextValue, type FormRendererProviderProps } from './components/form-renderer/FormRendererContext';
|
|
37
|
+
export { default as FormProgress, type FormProgressProps } from './components/form-renderer/FormProgress';
|
|
38
|
+
export { default as FormNavigationButtons, type FormNavigationButtonsProps } from './components/form-renderer/FormNavigationButtons';
|
|
39
|
+
export { default as FormActions, type FormActionsProps } from './components/form-renderer/FormActions';
|
|
40
|
+
export { default as FormRenderer, type FormRendererProps as UnifiedFormRendererProps } from './components/form-renderer/FormRenderer';
|
|
34
41
|
export type { EnqueteReponse, VariableFormulaire, GroupeFormulaire, FormulaireComplet, EnqueteInstance, GroupeInstance, VariableValue, VariableType, ComponentStyle, ValidationError, AutoAction, NavigationState } from './types/enquete';
|
|
35
42
|
export type { FormRendererServices, GeographicComponents, DistrictSelectorProps, RegionSelectorProps, DepartementSelectorProps, SousPrefectureSelectorProps, QuartierSelectorProps, VillageSelectorProps } from './types/services';
|
|
36
|
-
export type { FormRendererProps, GroupRendererProps, VariableRendererProps } from './types/form-renderer';
|
|
43
|
+
export type { FormRendererProps, GroupRendererProps, VariableRendererProps, FormRendererMode, FormRendererFeatures, FormRendererLabels, FormRendererConfig, FormRendererCallbacks, FormRendererUnifiedProps, DRValidationResult } from './types/form-renderer';
|
|
37
44
|
export type { VariableNodeState, GroupNodeState, JumpRange, JumpError, IFormTree, FormTreeOptions, JumpEvaluationResult } from './types/form-tree';
|
|
38
45
|
export { VariableValueConverter } from './lib/utils/variableValueConverter';
|
|
46
|
+
export { GroupeInstanceManager } from './lib/utils/groupeInstanceManager';
|
|
39
47
|
export { interpolateVariableLabel } from './lib/utils/interpolateVariableLabel';
|
|
40
48
|
export { ConditionEngine } from './lib/condition-engine';
|
|
41
49
|
export { RosterConditionEngine, type RosterConditionError, type RosterConditionErrorType, type RosterConditionValidationResult, type RosterVariableRef } from './lib/roster-condition-engine';
|
|
42
50
|
export { FormTree } from './lib/form-tree';
|
|
43
51
|
export { useFormTree, type UseFormTreeOptions, type UseFormTreeReturn } from './hooks/useFormTree';
|
|
52
|
+
export { useFormNavigation, type UseFormNavigationOptions, type UseFormNavigationResult } from './hooks/useFormNavigation';
|
|
53
|
+
export { useFormValidation, type UseFormValidationOptions, type UseFormValidationResult } from './hooks/useFormValidation';
|
|
54
|
+
export { useFormInstances, type UseFormInstancesOptions, type UseFormInstancesResult } from './hooks/useFormInstances';
|
|
55
|
+
export { useFormRenderer, type UseFormRendererOptions, type UseFormRendererResult } from './hooks/useFormRenderer';
|
|
44
56
|
export { cn } from './lib/utils/cn';
|
|
45
57
|
export { getStyleObject, getContainerStyle, applyComponentStyle } from './utils/styleUtils';
|
|
46
58
|
export { isComponentReadonly, isComponentDisabled, getReadonlyAttributes, getReadonlyClasses, readonlyClasses } from './utils/compon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C,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC5B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAOpC,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EAChB,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -50,10 +50,25 @@ export { default as RSUInput } from './components/selectors/RSUInput';
|
|
|
50
50
|
export { default as MenageInput } from './components/selectors/MenageInput';
|
|
51
51
|
export { default as EnqueteInput } from './components/selectors/EnqueteInput';
|
|
52
52
|
// ========================================
|
|
53
|
+
// COMPOSANTS FORM RENDERER
|
|
54
|
+
// ========================================
|
|
55
|
+
export { default as ConfirmationModal } from './components/form-renderer/ConfirmationModal';
|
|
56
|
+
export { default as GroupeInstanceTabs } from './components/form-renderer/GroupeInstanceTabs';
|
|
57
|
+
// Contexte et Provider FormRenderer
|
|
58
|
+
export { FormRendererProvider, useFormRendererContext, useFormRendererNavigation, useFormRendererValidation, useFormRendererInstances, useFormRendererConfig, useFormRendererResponses, useFormRendererState } from './components/form-renderer/FormRendererContext';
|
|
59
|
+
// Sous-composants du FormRenderer
|
|
60
|
+
export { default as FormProgress } from './components/form-renderer/FormProgress';
|
|
61
|
+
export { default as FormNavigationButtons } from './components/form-renderer/FormNavigationButtons';
|
|
62
|
+
export { default as FormActions } from './components/form-renderer/FormActions';
|
|
63
|
+
// Composant principal FormRenderer
|
|
64
|
+
export { default as FormRenderer } from './components/form-renderer/FormRenderer';
|
|
65
|
+
// ========================================
|
|
53
66
|
// UTILITAIRES
|
|
54
67
|
// ========================================
|
|
55
68
|
// Convertisseur de valeurs
|
|
56
69
|
export { VariableValueConverter } from './lib/utils/variableValueConverter';
|
|
70
|
+
// Gestionnaire d'instances multiples pour groupes
|
|
71
|
+
export { GroupeInstanceManager } from './lib/utils/groupeInstanceManager';
|
|
57
72
|
// Interpolation de libellés
|
|
58
73
|
export { interpolateVariableLabel } from './lib/utils/interpolateVariableLabel';
|
|
59
74
|
// Moteur de conditions
|
|
@@ -67,6 +82,11 @@ export { FormTree } from './lib/form-tree';
|
|
|
67
82
|
// ========================================
|
|
68
83
|
// Hook FormTree
|
|
69
84
|
export { useFormTree } from './hooks/useFormTree';
|
|
85
|
+
// Hooks FormRenderer
|
|
86
|
+
export { useFormNavigation } from './hooks/useFormNavigation';
|
|
87
|
+
export { useFormValidation } from './hooks/useFormValidation';
|
|
88
|
+
export { useFormInstances } from './hooks/useFormInstances';
|
|
89
|
+
export { useFormRenderer } from './hooks/useFormRenderer';
|
|
70
90
|
// Utilitaire CSS
|
|
71
91
|
export { cn } from './lib/utils/cn';
|
|
72
92
|
// ========================================
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-functions.test.d.ts","sourceRoot":"","sources":["../../../src/lib/__tests__/date-functions.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests unitaires pour les fonctions de date du conditionEngine
|
|
3
|
+
*/
|
|
4
|
+
import { calculateDateDiff, calculateDateAdd, parseDateString, isValidDateUnit } from '../utils/date-functions';
|
|
5
|
+
describe('date-functions', () => {
|
|
6
|
+
describe('calculateDateDiff', () => {
|
|
7
|
+
describe('différence en jours', () => {
|
|
8
|
+
it('devrait calculer la différence en jours entre deux dates', () => {
|
|
9
|
+
const date1 = new Date('2024-01-01');
|
|
10
|
+
const date2 = new Date('2024-01-31');
|
|
11
|
+
expect(calculateDateDiff(date1, date2, 'd')).toBe(30);
|
|
12
|
+
});
|
|
13
|
+
it('devrait retourner un nombre négatif si date2 < date1', () => {
|
|
14
|
+
const date1 = new Date('2024-01-31');
|
|
15
|
+
const date2 = new Date('2024-01-01');
|
|
16
|
+
expect(calculateDateDiff(date1, date2, 'd')).toBe(-30);
|
|
17
|
+
});
|
|
18
|
+
it('devrait retourner 0 pour la même date', () => {
|
|
19
|
+
const date = new Date('2024-01-15');
|
|
20
|
+
expect(calculateDateDiff(date, date, 'd')).toBe(0);
|
|
21
|
+
});
|
|
22
|
+
it('devrait calculer 365 jours pour une année non bissextile', () => {
|
|
23
|
+
const date1 = new Date('2023-01-01');
|
|
24
|
+
const date2 = new Date('2024-01-01');
|
|
25
|
+
expect(calculateDateDiff(date1, date2, 'd')).toBe(365);
|
|
26
|
+
});
|
|
27
|
+
it('devrait calculer 366 jours pour une année bissextile', () => {
|
|
28
|
+
const date1 = new Date('2024-01-01');
|
|
29
|
+
const date2 = new Date('2025-01-01');
|
|
30
|
+
expect(calculateDateDiff(date1, date2, 'd')).toBe(366);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe('différence en mois', () => {
|
|
34
|
+
it('devrait calculer la différence en mois', () => {
|
|
35
|
+
const date1 = new Date('2024-01-15');
|
|
36
|
+
const date2 = new Date('2024-07-15');
|
|
37
|
+
expect(calculateDateDiff(date1, date2, 'm')).toBe(6);
|
|
38
|
+
});
|
|
39
|
+
it('devrait ajuster si le jour du mois n\'est pas atteint', () => {
|
|
40
|
+
const date1 = new Date('2024-01-31');
|
|
41
|
+
const date2 = new Date('2024-02-15');
|
|
42
|
+
expect(calculateDateDiff(date1, date2, 'm')).toBe(0);
|
|
43
|
+
});
|
|
44
|
+
it('devrait retourner 12 mois pour une année exacte', () => {
|
|
45
|
+
const date1 = new Date('2024-01-15');
|
|
46
|
+
const date2 = new Date('2025-01-15');
|
|
47
|
+
expect(calculateDateDiff(date1, date2, 'm')).toBe(12);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe('différence en années', () => {
|
|
51
|
+
it('devrait calculer la différence en années avec anniversaire passé', () => {
|
|
52
|
+
const date1 = new Date('2000-06-15');
|
|
53
|
+
const date2 = new Date('2024-08-15');
|
|
54
|
+
expect(calculateDateDiff(date1, date2, 'y')).toBe(24);
|
|
55
|
+
});
|
|
56
|
+
it('devrait retourner 23 si l\'anniversaire n\'est pas encore passé', () => {
|
|
57
|
+
const date1 = new Date('2000-12-31');
|
|
58
|
+
const date2 = new Date('2024-01-01');
|
|
59
|
+
expect(calculateDateDiff(date1, date2, 'y')).toBe(23);
|
|
60
|
+
});
|
|
61
|
+
it('devrait retourner l\'âge exact le jour de l\'anniversaire', () => {
|
|
62
|
+
const date1 = new Date('2000-06-15');
|
|
63
|
+
const date2 = new Date('2024-06-15');
|
|
64
|
+
expect(calculateDateDiff(date1, date2, 'y')).toBe(24);
|
|
65
|
+
});
|
|
66
|
+
it('devrait retourner 0 pour moins d\'un an', () => {
|
|
67
|
+
const date1 = new Date('2024-01-01');
|
|
68
|
+
const date2 = new Date('2024-06-01');
|
|
69
|
+
expect(calculateDateDiff(date1, date2, 'y')).toBe(0);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe('gestion des erreurs', () => {
|
|
73
|
+
it('devrait retourner null pour date1 null', () => {
|
|
74
|
+
expect(calculateDateDiff(null, new Date(), 'd')).toBe(null);
|
|
75
|
+
});
|
|
76
|
+
it('devrait retourner null pour date2 null', () => {
|
|
77
|
+
expect(calculateDateDiff(new Date(), null, 'd')).toBe(null);
|
|
78
|
+
});
|
|
79
|
+
it('devrait retourner null pour date invalide', () => {
|
|
80
|
+
expect(calculateDateDiff(new Date('invalid'), new Date(), 'd')).toBe(null);
|
|
81
|
+
});
|
|
82
|
+
it('devrait retourner null pour unité invalide', () => {
|
|
83
|
+
expect(calculateDateDiff(new Date(), new Date(), 'x')).toBe(null);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
describe('calculateDateAdd', () => {
|
|
88
|
+
describe('ajout de jours', () => {
|
|
89
|
+
it('devrait ajouter des jours à une date', () => {
|
|
90
|
+
const date = new Date('2024-01-01');
|
|
91
|
+
const result = calculateDateAdd(date, 30, 'd');
|
|
92
|
+
expect(result?.toISOString().slice(0, 10)).toBe('2024-01-31');
|
|
93
|
+
});
|
|
94
|
+
it('devrait soustraire des jours avec une valeur négative', () => {
|
|
95
|
+
const date = new Date('2024-01-15');
|
|
96
|
+
const result = calculateDateAdd(date, -7, 'd');
|
|
97
|
+
expect(result?.toISOString().slice(0, 10)).toBe('2024-01-08');
|
|
98
|
+
});
|
|
99
|
+
it('devrait gérer le passage de mois', () => {
|
|
100
|
+
const date = new Date('2024-01-31');
|
|
101
|
+
const result = calculateDateAdd(date, 1, 'd');
|
|
102
|
+
expect(result?.toISOString().slice(0, 10)).toBe('2024-02-01');
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
describe('ajout de mois', () => {
|
|
106
|
+
it('devrait ajouter des mois à une date', () => {
|
|
107
|
+
const date = new Date('2024-01-15');
|
|
108
|
+
const result = calculateDateAdd(date, 6, 'm');
|
|
109
|
+
expect(result?.toISOString().slice(0, 10)).toBe('2024-07-15');
|
|
110
|
+
});
|
|
111
|
+
it('devrait soustraire des mois avec une valeur négative', () => {
|
|
112
|
+
const date = new Date('2024-07-15');
|
|
113
|
+
const result = calculateDateAdd(date, -6, 'm');
|
|
114
|
+
expect(result?.toISOString().slice(0, 10)).toBe('2024-01-15');
|
|
115
|
+
});
|
|
116
|
+
it('devrait gérer le passage d\'année', () => {
|
|
117
|
+
const date = new Date('2024-11-15');
|
|
118
|
+
const result = calculateDateAdd(date, 3, 'm');
|
|
119
|
+
expect(result?.toISOString().slice(0, 10)).toBe('2025-02-15');
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
describe('ajout d\'années', () => {
|
|
123
|
+
it('devrait ajouter des années à une date', () => {
|
|
124
|
+
const date = new Date('2024-01-01');
|
|
125
|
+
const result = calculateDateAdd(date, 1, 'y');
|
|
126
|
+
expect(result?.toISOString().slice(0, 10)).toBe('2025-01-01');
|
|
127
|
+
});
|
|
128
|
+
it('devrait soustraire des années avec une valeur négative', () => {
|
|
129
|
+
const date = new Date('2024-01-01');
|
|
130
|
+
const result = calculateDateAdd(date, -5, 'y');
|
|
131
|
+
expect(result?.toISOString().slice(0, 10)).toBe('2019-01-01');
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
describe('gestion des erreurs', () => {
|
|
135
|
+
it('devrait retourner null pour date null', () => {
|
|
136
|
+
expect(calculateDateAdd(null, 30, 'd')).toBe(null);
|
|
137
|
+
});
|
|
138
|
+
it('devrait retourner null pour date invalide', () => {
|
|
139
|
+
expect(calculateDateAdd(new Date('invalid'), 30, 'd')).toBe(null);
|
|
140
|
+
});
|
|
141
|
+
it('devrait retourner null pour valeur NaN', () => {
|
|
142
|
+
expect(calculateDateAdd(new Date(), NaN, 'd')).toBe(null);
|
|
143
|
+
});
|
|
144
|
+
it('devrait retourner null pour unité invalide', () => {
|
|
145
|
+
expect(calculateDateAdd(new Date(), 30, 'x')).toBe(null);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
describe('parseDateString', () => {
|
|
150
|
+
it('devrait parser une date ISO', () => {
|
|
151
|
+
const result = parseDateString('2024-01-15');
|
|
152
|
+
expect(result?.toISOString().slice(0, 10)).toBe('2024-01-15');
|
|
153
|
+
});
|
|
154
|
+
it('devrait parser une date ISO avec heure', () => {
|
|
155
|
+
const result = parseDateString('2024-01-15T10:30:00');
|
|
156
|
+
expect(result).not.toBe(null);
|
|
157
|
+
});
|
|
158
|
+
it('devrait parser un timestamp', () => {
|
|
159
|
+
const timestamp = new Date('2024-01-15').getTime().toString();
|
|
160
|
+
const result = parseDateString(timestamp);
|
|
161
|
+
expect(result).not.toBe(null);
|
|
162
|
+
});
|
|
163
|
+
it('devrait retourner null pour une chaîne vide', () => {
|
|
164
|
+
expect(parseDateString('')).toBe(null);
|
|
165
|
+
});
|
|
166
|
+
it('devrait retourner null pour une date invalide', () => {
|
|
167
|
+
expect(parseDateString('invalid')).toBe(null);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
describe('isValidDateUnit', () => {
|
|
171
|
+
it('devrait retourner true pour "d"', () => {
|
|
172
|
+
expect(isValidDateUnit('d')).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
it('devrait retourner true pour "m"', () => {
|
|
175
|
+
expect(isValidDateUnit('m')).toBe(true);
|
|
176
|
+
});
|
|
177
|
+
it('devrait retourner true pour "y"', () => {
|
|
178
|
+
expect(isValidDateUnit('y')).toBe(true);
|
|
179
|
+
});
|
|
180
|
+
it('devrait retourner false pour une unité invalide', () => {
|
|
181
|
+
expect(isValidDateUnit('x')).toBe(false);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gestionnaire des instances multiples pour les groupes d'enquête
|
|
3
|
+
* RSU v2 - Moteur de Rendu des Formulaires d'Enquête
|
|
4
|
+
*/
|
|
5
|
+
import { GroupeFormulaire, GroupeInstance, EnqueteReponse, ConstraintValidationResult } from '../../types/enquete';
|
|
6
|
+
export declare class GroupeInstanceManager {
|
|
7
|
+
/**
|
|
8
|
+
* Récupère le nombre maximum d'instances autorisées depuis la variable de contrôle
|
|
9
|
+
* RÈGLE DE PROTECTION : Ne jamais permettre de réduire sous le nombre d'instances existantes
|
|
10
|
+
*/
|
|
11
|
+
static getMaxInstances(groupe: GroupeFormulaire, responses: Record<string, EnqueteReponse>): number;
|
|
12
|
+
/**
|
|
13
|
+
* Récupère le nombre minimum d'instances (basé sur les instances existantes)
|
|
14
|
+
*/
|
|
15
|
+
static getMinInstances(groupe: GroupeFormulaire): number;
|
|
16
|
+
/**
|
|
17
|
+
* Compte le nombre d'instances existantes pour un groupe
|
|
18
|
+
*/
|
|
19
|
+
static getInstancesCount(groupe: GroupeFormulaire, responses: Record<string, EnqueteReponse>): number;
|
|
20
|
+
/**
|
|
21
|
+
* Crée une nouvelle instance pour un groupe multiple
|
|
22
|
+
*/
|
|
23
|
+
static createInstance(groupe: GroupeFormulaire, numeroInstance: number): GroupeInstance;
|
|
24
|
+
/**
|
|
25
|
+
* Initialise les instances pour un groupe multiple
|
|
26
|
+
*/
|
|
27
|
+
static initializeInstances(groupe: GroupeFormulaire, responses: Record<string, EnqueteReponse>): GroupeInstance[];
|
|
28
|
+
/**
|
|
29
|
+
* Vérifie si une instance est complètement renseignée
|
|
30
|
+
*/
|
|
31
|
+
static isInstanceComplete(instance: GroupeInstance, groupe: GroupeFormulaire): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Valide si on peut ajouter une nouvelle instance
|
|
34
|
+
*/
|
|
35
|
+
static canAddInstance(groupe: GroupeFormulaire, responses: Record<string, EnqueteReponse>): ConstraintValidationResult;
|
|
36
|
+
/**
|
|
37
|
+
* Valide si on peut supprimer une instance
|
|
38
|
+
*/
|
|
39
|
+
static canRemoveInstance(groupe: GroupeFormulaire, responses: Record<string, EnqueteReponse>): ConstraintValidationResult;
|
|
40
|
+
/**
|
|
41
|
+
* Valide si on peut modifier la variable de contrôle
|
|
42
|
+
*/
|
|
43
|
+
static canModifyControlVariable(variableCode: string, newValue: number, groupesMultiples: GroupeFormulaire[], responses: Record<string, EnqueteReponse>): ConstraintValidationResult;
|
|
44
|
+
/**
|
|
45
|
+
* Ajoute une nouvelle instance à un groupe
|
|
46
|
+
*/
|
|
47
|
+
static addInstance(groupe: GroupeFormulaire, responses: Record<string, EnqueteReponse>): {
|
|
48
|
+
success: boolean;
|
|
49
|
+
instance?: GroupeInstance;
|
|
50
|
+
error?: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Supprime une instance d'un groupe
|
|
54
|
+
*/
|
|
55
|
+
static removeInstance(groupe: GroupeFormulaire, instanceNumber: number, responses: Record<string, EnqueteReponse>): {
|
|
56
|
+
success: boolean;
|
|
57
|
+
error?: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Met à jour les propriétés calculées d'un groupe multiple
|
|
61
|
+
*/
|
|
62
|
+
static updateGroupeProperties(groupe: GroupeFormulaire, responses: Record<string, EnqueteReponse>): void;
|
|
63
|
+
/**
|
|
64
|
+
* Synchronise les réponses d'une instance avec le store global
|
|
65
|
+
*/
|
|
66
|
+
static syncInstanceResponses(instance: GroupeInstance, groupe: GroupeFormulaire, globalResponses: Record<string, EnqueteReponse>): void;
|
|
67
|
+
/**
|
|
68
|
+
* Valide la navigation vers l'instance suivante
|
|
69
|
+
*/
|
|
70
|
+
static canNavigateToNextInstance(currentInstance: GroupeInstance, groupe: GroupeFormulaire): ConstraintValidationResult;
|
|
71
|
+
/**
|
|
72
|
+
* Trouve la prochaine instance incomplète dans un groupe
|
|
73
|
+
*/
|
|
74
|
+
static findNextIncompleteInstance(groupe: GroupeFormulaire): GroupeInstance | null;
|
|
75
|
+
/**
|
|
76
|
+
* Calcule la progression d'un groupe multiple
|
|
77
|
+
*/
|
|
78
|
+
static calculateGroupProgress(groupe: GroupeFormulaire): {
|
|
79
|
+
completedInstances: number;
|
|
80
|
+
totalInstances: number;
|
|
81
|
+
progressPercentage: number;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Réorganise les numéros d'instances après suppression
|
|
85
|
+
*/
|
|
86
|
+
static reorderInstances(groupe: GroupeFormulaire, responses: Record<string, EnqueteReponse>): void;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=groupeInstanceManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groupeInstanceManager.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/groupeInstanceManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,cAAc,EAEd,0BAA0B,EAE3B,MAAM,qBAAqB,CAAC;AAE7B,qBAAa,qBAAqB;IAEhC;;;OAGG;IACH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