@rsuci/shared-form-components 1.0.127 → 1.0.129

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.
@@ -2,8 +2,8 @@
2
2
  * Composant ExtraitInput - Saisie d'Extrait de Naissance
3
3
  * RSU v2 - Moteur de Rendu des Formulaires d'Enquête
4
4
  *
5
- * Format composé : numéro (3 chiffres) + date d'établissement + année registre (4 chiffres)
6
- * Exemple affiché : "556 du 12/12/2020 du registre 2020"
5
+ * Format composé : numéro (1 à 4 chiffres) + date d'établissement + année registre (4 chiffres)
6
+ * Exemple affiché : "1000 du 12/12/2020 du registre 2020"
7
7
  * Stockage : JSON { numero, dateEtablissement, anneeRegistre }
8
8
  */
9
9
  import React from 'react';
@@ -1 +1 @@
1
- {"version":3,"file":"ExtraitInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/ExtraitInput.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAA2C,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC;IACvD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAgED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAkJ7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"ExtraitInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/ExtraitInput.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAA2C,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC;IACvD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAgED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA8I7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -2,8 +2,8 @@
2
2
  * Composant ExtraitInput - Saisie d'Extrait de Naissance
3
3
  * RSU v2 - Moteur de Rendu des Formulaires d'Enquête
4
4
  *
5
- * Format composé : numéro (3 chiffres) + date d'établissement + année registre (4 chiffres)
6
- * Exemple affiché : "556 du 12/12/2020 du registre 2020"
5
+ * Format composé : numéro (1 à 4 chiffres) + date d'établissement + année registre (4 chiffres)
6
+ * Exemple affiché : "1000 du 12/12/2020 du registre 2020"
7
7
  * Stockage : JSON { numero, dateEtablissement, anneeRegistre }
8
8
  */
9
9
  'use client';
@@ -71,7 +71,7 @@ const ExtraitInput = ({ variable, value, onChange, onBlur, error, disabled, isCo
71
71
  onChange(JSON.stringify(newData));
72
72
  }, [onChange]);
73
73
  const handleNumeroChange = useCallback((e) => {
74
- const digitsOnly = e.target.value.replace(/\D/g, '').slice(0, 3);
74
+ const digitsOnly = e.target.value.replace(/\D/g, '').slice(0, 4);
75
75
  updateValue({ ...data, numero: digitsOnly });
76
76
  }, [data, updateValue]);
77
77
  const handleDateChange = useCallback((e) => {
@@ -83,9 +83,6 @@ const ExtraitInput = ({ variable, value, onChange, onBlur, error, disabled, isCo
83
83
  }, [data, updateValue]);
84
84
  const handleBlur = useCallback(() => {
85
85
  const errors = [];
86
- if (data.numero && data.numero.length !== 3) {
87
- errors.push('Le numéro doit contenir 3 chiffres');
88
- }
89
86
  if (data.anneeRegistre && data.anneeRegistre.length !== 4) {
90
87
  errors.push("L'année du registre doit contenir 4 chiffres");
91
88
  }
@@ -110,6 +107,6 @@ const ExtraitInput = ({ variable, value, onChange, onBlur, error, disabled, isCo
110
107
  };
111
108
  const displayError = error || localError;
112
109
  const formattedValue = formatDisplayValue(data);
113
- return (_jsxs("div", { style: containerStyle, className: "space-y-3", children: [_jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-3", children: [_jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Num\u00E9ro" }), _jsx("input", { type: "text", inputMode: "numeric", value: data.numero, onChange: handleNumeroChange, onBlur: handleBlur, placeholder: disabled ? '' : '556', disabled: disabled, readOnly: isReadonly, style: textStyle, className: `${getInputClasses()} w-full font-mono`, maxLength: 3, autoComplete: "off" })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Date d'\u00E9tablissement" }), _jsx("input", { type: "date", value: data.dateEtablissement, onChange: handleDateChange, onBlur: handleBlur, disabled: disabled, readOnly: isReadonly, style: textStyle, className: `${getInputClasses()} w-full`, max: new Date().toISOString().split('T')[0] })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Ann\u00E9e du registre" }), _jsx("input", { type: "text", inputMode: "numeric", value: data.anneeRegistre, onChange: handleAnneeChange, onBlur: handleBlur, placeholder: disabled ? '' : '2020', disabled: disabled, readOnly: isReadonly, style: textStyle, className: `${getInputClasses()} w-full font-mono`, maxLength: 4, autoComplete: "off" })] })] }), formattedValue && (_jsx("div", { className: "p-2 bg-blue-50 border border-blue-200 rounded-lg", children: _jsxs("p", { className: "text-sm text-blue-800", children: [_jsx("span", { className: "font-medium", children: "Valeur :" }), " ", formattedValue] }) })), displayError && (_jsx("p", { className: "text-sm text-red-500", children: displayError }))] }));
110
+ return (_jsxs("div", { style: containerStyle, className: "space-y-3", children: [_jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-3", children: [_jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Num\u00E9ro" }), _jsx("input", { type: "text", inputMode: "numeric", value: data.numero, onChange: handleNumeroChange, onBlur: handleBlur, placeholder: disabled ? '' : '1000', disabled: disabled, readOnly: isReadonly, style: textStyle, className: `${getInputClasses()} w-full font-mono`, maxLength: 4, autoComplete: "off" })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Date d'\u00E9tablissement" }), _jsx("input", { type: "date", value: data.dateEtablissement, onChange: handleDateChange, onBlur: handleBlur, disabled: disabled, readOnly: isReadonly, style: textStyle, className: `${getInputClasses()} w-full`, max: new Date().toISOString().split('T')[0] })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Ann\u00E9e du registre" }), _jsx("input", { type: "text", inputMode: "numeric", value: data.anneeRegistre, onChange: handleAnneeChange, onBlur: handleBlur, placeholder: disabled ? '' : '2020', disabled: disabled, readOnly: isReadonly, style: textStyle, className: `${getInputClasses()} w-full font-mono`, maxLength: 4, autoComplete: "off" })] })] }), formattedValue && (_jsx("div", { className: "p-2 bg-blue-50 border border-blue-200 rounded-lg", children: _jsxs("p", { className: "text-sm text-blue-800", children: [_jsx("span", { className: "font-medium", children: "Valeur :" }), " ", formattedValue] }) })), displayError && (_jsx("p", { className: "text-sm text-red-500", children: displayError }))] }));
114
111
  };
115
112
  export default ExtraitInput;
@@ -1 +1 @@
1
- {"version":3,"file":"groupeInstanceManager.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/groupe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EAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACxC,gBAAgB,EAAE;CA0CtB"}
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,MAAM,CAAC,eAAe,CACpB,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACxC,MAAM;IAsCT;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM;IASxD;;;;OAIG;IACH,MAAM,CAAC,iBAAiB,CACtB,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACxC,MAAM;IAuBT;;OAEG;IACH,MAAM,CAAC,cAAc,CACnB,MAAM,EAAE,gBAAgB,EACxB,cAAc,EAAE,MAAM,GACrB,cAAc;IAWjB;;OAEG;IACH,MAAM,CAAC,mBAAmB,CACxB,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACxC,cAAc,EAAE;IA6FnB;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO;IAStF;;OAEG;IACH,MAAM,CAAC,cAAc,CACnB,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACxC,0BAA0B;IA+C7B;;OAEG;IACH,MAAM,CAAC,iBAAiB,CACtB,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,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M,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QACjD,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB;IAgED;;;OAGG;IACH,MAAM,CAAC,wBAAwB,CAC7B,UAAU,EAAE,gBAAgB,EAAE,EAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACxC,gBAAgB,EAAE;CAqDtB"}
@@ -107,20 +107,19 @@ export class GroupeInstanceManager {
107
107
  // Note: le parsing de clé par format "CODE_NUMERO" a été supprimé car il
108
108
  // produisait des faux positifs pour les codes variables contenant des chiffres (ex: S1_01)
109
109
  const maxInstances = this.getMaxInstances(groupe, responses);
110
- // Déterminer le nombre d'instances à créer
111
- let instanceCount = Math.max(1, instanceNumbers.size);
112
- // CORRECTION: Ne pas forcer la création de maxInstances instances
113
- // Respecter la limite de la variable de contrôle
114
- instanceCount = Math.min(instanceCount, maxInstances);
115
- // Si aucune instance existante, créer au moins 1 instance
116
- if (instanceCount === 0) {
117
- instanceCount = 1;
118
- }
110
+ // Borne supérieure : au moins maxInstances (variable de contrôle), au moins le
111
+ // numéro le plus élevé trouvé dans les réponses (protège contre la perte de données
112
+ // si des réponses existent au-delà de la variable de contrôle, ex: membre 2 vide
113
+ // dans un groupe lié le numéro max existant est 3).
114
+ const highestExistingMembre = instanceNumbers.size > 0
115
+ ? Math.max(...Array.from(instanceNumbers))
116
+ : 0;
117
+ const upperBound = Math.max(maxInstances, highestExistingMembre, 1);
119
118
  const instances = [];
120
119
  // Séparer les réponses avec et sans numeroMembre
121
120
  const responsesWithMember = groupResponses.filter(r => r.numeroMembre);
122
121
  const responsesWithoutMember = groupResponses.filter(r => !r.numeroMembre);
123
- for (let i = 1; i <= instanceCount; i++) {
122
+ for (let i = 1; i <= upperBound; i++) {
124
123
  const instance = this.createInstance(groupe, i);
125
124
  // Remplir les réponses existantes pour cette instance
126
125
  groupe.variables.forEach(variable => {
@@ -287,7 +286,10 @@ export class GroupeInstanceManager {
287
286
  };
288
287
  }
289
288
  const currentInstances = groupe.instances || [];
290
- const newInstanceNumber = currentInstances.length + 1;
289
+ const maxExisting = currentInstances.length > 0
290
+ ? Math.max(...currentInstances.map(i => i.numeroInstance))
291
+ : 0;
292
+ const newInstanceNumber = maxExisting + 1;
291
293
  const newInstance = this.createInstance(groupe, newInstanceNumber);
292
294
  // Construire un nouveau groupe avec l'instance ajoutée (sans muter l'original)
293
295
  const updatedInstances = [...currentInstances, newInstance];
@@ -621,32 +623,42 @@ export class GroupeInstanceManager {
621
623
  groupsByControlVar.set(g.codeVariable, existing);
622
624
  }
623
625
  }
624
- // Pour chaque ensemble de groupes liés, synchroniser le nombre d'instances
626
+ // Pour chaque ensemble de groupes liés, synchroniser les instances manquantes
625
627
  const updatedGroupes = [...allGroupes];
626
628
  for (const [, linkedGroups] of groupsByControlVar) {
627
629
  if (linkedGroups.length <= 1)
628
630
  continue;
629
- // Trouver le max d'instances parmi les groupes liés
630
- const maxCount = Math.max(...linkedGroups.map(g => g.instances?.length || 0));
631
- if (maxCount <= 0)
631
+ // Union de tous les numéros d'instances réels à travers les groupes liés
632
+ const allInstanceNumbers = new Set();
633
+ for (const g of linkedGroups) {
634
+ for (const inst of g.instances || []) {
635
+ allInstanceNumbers.add(inst.numeroInstance);
636
+ }
637
+ }
638
+ if (allInstanceNumbers.size === 0)
632
639
  continue;
633
- // Ajouter les instances manquantes dans chaque groupe
640
+ // Pour chaque groupe, créer uniquement les instances dont le numéro est absent
641
+ // (comparaison par ensemble, pas par longueur — évite les doublons)
634
642
  for (const g of linkedGroups) {
635
- const currentCount = g.instances?.length || 0;
636
- if (currentCount < maxCount) {
637
- const idx = updatedGroupes.findIndex(ug => ug.code === g.code);
638
- if (idx === -1)
639
- continue;
640
- const instances = [...(updatedGroupes[idx].instances || [])];
641
- for (let i = currentCount + 1; i <= maxCount; i++) {
642
- instances.push(this.createInstance(g, i));
643
- }
644
- updatedGroupes[idx] = {
645
- ...updatedGroupes[idx],
646
- instances,
647
- instancesCount: instances.length
648
- };
643
+ const existingNumbers = new Set((g.instances || []).map(i => i.numeroInstance));
644
+ const missingNumbers = [...allInstanceNumbers]
645
+ .filter(n => !existingNumbers.has(n))
646
+ .sort((a, b) => a - b);
647
+ if (missingNumbers.length === 0)
648
+ continue;
649
+ const idx = updatedGroupes.findIndex(ug => ug.code === g.code);
650
+ if (idx === -1)
651
+ continue;
652
+ const instances = [...(updatedGroupes[idx].instances || [])];
653
+ for (const num of missingNumbers) {
654
+ instances.push(this.createInstance(g, num));
649
655
  }
656
+ instances.sort((a, b) => a.numeroInstance - b.numeroInstance);
657
+ updatedGroupes[idx] = {
658
+ ...updatedGroupes[idx],
659
+ instances,
660
+ instancesCount: instances.length
661
+ };
650
662
  }
651
663
  }
652
664
  return updatedGroupes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsuci/shared-form-components",
3
- "version": "1.0.127",
3
+ "version": "1.0.129",
4
4
  "description": "Composants partagés de rendu de formulaires RSU v2 - Package local pour frontend Admin et Public",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",