@rsuci/shared-form-components 1.0.10 → 1.0.12

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 +1 @@
1
- {"version":3,"file":"RosterPanel.d.ts","sourceRoot":"","sources":["../../../src/components/roster/RosterPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAGD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,YAAY,CAAC;IACrB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAwG3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"RosterPanel.d.ts","sourceRoot":"","sources":["../../../src/components/roster/RosterPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAGD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,YAAY,CAAC;IACrB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAuI3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -18,11 +18,39 @@ const RosterPanel = ({ option, rosterVariables, value, onChange, disabled, showC
18
18
  const uniqueCode = `${option.code}_${rosterVar.code}`;
19
19
  // Récupérer les options (format: "01#Option1|02#Option2|...")
20
20
  const optionsValue = rosterVar.valeurDefaut || rosterVar.valeur;
21
+ // Déterminer le type de la variable avec fallback intelligent
22
+ // Si typeCode est absent, on essaie de déduire le type
23
+ let effectiveTypeCode = rosterVar.typeCode;
24
+ if (!effectiveTypeCode) {
25
+ const designation = (rosterVar.designation || '').toLowerCase();
26
+ if (optionsValue && typeof optionsValue === 'string') {
27
+ // Vérifier si c'est un format d'options : "01#Label1|02#Label2"
28
+ if (optionsValue.includes('#') && optionsValue.includes('|')) {
29
+ // Si peu d'options (2-4), probablement RADIO, sinon LISTE
30
+ const optionsCount = optionsValue.split('|').length;
31
+ effectiveTypeCode = optionsCount <= 4 ? 'RADIO' : 'LISTE';
32
+ console.log(`[RosterPanel] Fallback typeCode pour ${rosterVar.code}: ${effectiveTypeCode} (${optionsCount} options)`);
33
+ }
34
+ }
35
+ // Si toujours pas de type, essayer de déduire par le libellé
36
+ if (!effectiveTypeCode) {
37
+ // Patterns pour détecter les types numériques
38
+ const numericPatterns = ['âge', 'age', 'nombre', 'quantité', 'montant', 'prix', 'taille', 'poids', 'année', 'annee', 'mois', 'jour', 'durée', 'duree', 'distance', 'superficie', 'effectif', 'score', 'note', 'pourcentage', '%'];
39
+ const isNumeric = numericPatterns.some(pattern => designation.includes(pattern));
40
+ if (isNumeric) {
41
+ effectiveTypeCode = 'NUMERIQUE';
42
+ console.log(`[RosterPanel] Fallback typeCode pour ${rosterVar.code}: NUMERIQUE (détecté par libellé)`);
43
+ }
44
+ else {
45
+ effectiveTypeCode = 'STRING';
46
+ }
47
+ }
48
+ }
21
49
  const variable = {
22
50
  id: 0, // Pas d'ID propre pour les variables roster
23
51
  code: uniqueCode, // Code unique par panel
24
52
  designation: rosterVar.designation || rosterVar.code,
25
- typeCode: rosterVar.typeCode || 'STRING', // Fallback explicite si typeCode manquant
53
+ typeCode: effectiveTypeCode, // Utiliser le type effectif (du backend ou fallback)
26
54
  groupeCode: '',
27
55
  ordre: rosterVar.ordre,
28
56
  estObligatoire: rosterVar.estObligatoire || false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsuci/shared-form-components",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
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",