@rsuci/shared-form-components 1.0.56 → 1.0.58
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/GroupeInstanceTabs.js +3 -3
- package/dist/components/inputs/GeographicCascadeInput.d.ts.map +1 -1
- package/dist/components/inputs/GeographicCascadeInput.js +31 -9
- package/dist/components/roster/RosterPanel.d.ts.map +1 -1
- package/dist/components/roster/RosterPanel.js +4 -16
- package/package.json +1 -1
|
@@ -65,9 +65,9 @@ const GroupeInstanceTabs = ({ groupe, currentInstanceIndex, responses, onInstanc
|
|
|
65
65
|
// Fonction pour obtenir l'icône et la couleur selon l'état
|
|
66
66
|
const getInstanceDisplay = (instance, isActive) => {
|
|
67
67
|
const state = getInstanceState(instance);
|
|
68
|
-
const baseClasses = `
|
|
69
|
-
flex items-center justify-center min-w-[3rem] h-10 px-3 rounded-lg font-medium text-sm
|
|
70
|
-
transition-all duration-200 cursor-pointer border-2
|
|
68
|
+
const baseClasses = `
|
|
69
|
+
flex items-center justify-center min-w-[3rem] h-10 px-3 rounded-lg font-medium text-sm
|
|
70
|
+
transition-all duration-200 cursor-pointer border-2
|
|
71
71
|
`;
|
|
72
72
|
let stateClasses = '';
|
|
73
73
|
let icon = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeographicCascadeInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/GeographicCascadeInput.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"GeographicCascadeInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/GeographicCascadeInput.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AAWjF;;GAEG;AACH,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAWD,UAAU,2BAA2B;IACnC,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAkPxE,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
* Gère la cascade via le champ variable.valeur (ex: "${G_01}")
|
|
6
6
|
* Utilise SearchableSelect pour une meilleure UX avec recherche intégrée
|
|
7
7
|
*/
|
|
8
|
-
import { useEffect, useState, useCallback, useRef } from 'react';
|
|
8
|
+
import { useEffect, useState, useCallback, useRef, useMemo } from 'react';
|
|
9
9
|
import SearchableSelect from './SearchableSelect';
|
|
10
10
|
import { extractVariableCode, resolveParentValue, getApiEndpoint, getParentLabel, requiresParent } from '../../utils/variableDependencyResolver';
|
|
11
11
|
import { isComponentReadonly } from '../../utils/componentStateUtils';
|
|
@@ -21,11 +21,11 @@ export const GeographicCascadeInput = ({ variable, value, onChange, reponses, di
|
|
|
21
21
|
console.log('[GeographicCascade] Debug:', {
|
|
22
22
|
variableCode: variable.code,
|
|
23
23
|
variableType: variable.typeCode,
|
|
24
|
-
|
|
24
|
+
valueProp: value,
|
|
25
|
+
valueType: typeof value,
|
|
25
26
|
variableValeurDefaut: variable.valeurDefaut,
|
|
26
27
|
needsParent,
|
|
27
28
|
parentCode: extractVariableCode(variable),
|
|
28
|
-
parentReponse: reponses?.[extractVariableCode(variable) || ''],
|
|
29
29
|
parentValue,
|
|
30
30
|
reponsesKeys: Object.keys(reponses || {})
|
|
31
31
|
});
|
|
@@ -147,13 +147,35 @@ export const GeographicCascadeInput = ({ variable, value, onChange, reponses, di
|
|
|
147
147
|
code: item.code,
|
|
148
148
|
designation: item.designation
|
|
149
149
|
}));
|
|
150
|
-
// 11.
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
// 11. Parser la valeur si c'est une chaîne JSON (cas édition d'enquête existante)
|
|
151
|
+
const parsedValue = useMemo(() => {
|
|
152
|
+
if (!value)
|
|
153
|
+
return null;
|
|
154
|
+
// Si c'est déjà un objet avec les propriétés attendues
|
|
155
|
+
if (typeof value === 'object' && value !== null && 'id' in value) {
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
// Si c'est une chaîne JSON, la parser
|
|
159
|
+
if (typeof value === 'string') {
|
|
160
|
+
try {
|
|
161
|
+
const parsed = JSON.parse(value);
|
|
162
|
+
if (parsed && typeof parsed === 'object' && 'id' in parsed) {
|
|
163
|
+
return parsed;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
// Ignorer les erreurs de parsing (valeur non-JSON)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
}, [value]);
|
|
172
|
+
// 12. Convertir la valeur parsée en SelectOption
|
|
173
|
+
const currentValue = parsedValue ? {
|
|
174
|
+
id: parsedValue.id,
|
|
175
|
+
code: parsedValue.code,
|
|
176
|
+
designation: parsedValue.designation
|
|
155
177
|
} : null;
|
|
156
|
-
//
|
|
178
|
+
// 13. Rendu du composant
|
|
157
179
|
return (_jsxs("div", { className: "w-full", children: [_jsx(SearchableSelect, { options: options, value: currentValue, onChange: handleChange, placeholder: getPlaceholder(), searchPlaceholder: "Rechercher...", disabled: isDisabled, required: required, loading: loading, error: error || undefined, className: className, noOptionsMessage: needsParent && !parentValue
|
|
158
180
|
? `Veuillez d'abord sélectionner ${getParentLabel(variable.typeCode)}`
|
|
159
181
|
: `Aucun(e) ${variable.designation?.toLowerCase() || 'élément'} disponible`, formatOptionLabel: (option) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RosterPanel.d.ts","sourceRoot":"","sources":["../../../src/components/roster/RosterPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAAsB,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAM5D,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;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;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,OAA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E,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;IAE3C,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACvH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA+L3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -53,32 +53,20 @@ const RosterPanel = ({ option, rosterVariables, value, onChange, disabled, showC
|
|
|
53
53
|
const uniqueCode = `${option.code}_${rosterVar.code}`;
|
|
54
54
|
// Récupérer les options (format: "01#Option1|02#Option2|...")
|
|
55
55
|
const optionsValue = rosterVar.valeurDefaut || rosterVar.valeur;
|
|
56
|
-
// Déterminer le type de la variable
|
|
57
|
-
// Si typeCode est absent, on essaie de déduire le type
|
|
56
|
+
// Déterminer le type de la variable
|
|
58
57
|
let effectiveTypeCode = rosterVar.typeCode;
|
|
58
|
+
// Si typeCode absent, essayer de détecter par le format des options
|
|
59
59
|
if (!effectiveTypeCode) {
|
|
60
|
-
const designation = (rosterVar.designation || '').toLowerCase();
|
|
61
60
|
if (optionsValue && typeof optionsValue === 'string') {
|
|
62
61
|
// Vérifier si c'est un format d'options : "01#Label1|02#Label2"
|
|
63
62
|
if (optionsValue.includes('#') && optionsValue.includes('|')) {
|
|
64
|
-
// Si peu d'options (2-4), probablement RADIO, sinon LISTE
|
|
65
63
|
const optionsCount = optionsValue.split('|').length;
|
|
66
64
|
effectiveTypeCode = optionsCount <= 4 ? 'RADIO' : 'LISTE';
|
|
67
|
-
console.log(`[RosterPanel] Fallback typeCode pour ${rosterVar.code}: ${effectiveTypeCode} (${optionsCount} options)`);
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
|
-
//
|
|
67
|
+
// Fallback final vers STRING
|
|
71
68
|
if (!effectiveTypeCode) {
|
|
72
|
-
|
|
73
|
-
const numericPatterns = ['âge', 'age', 'nombre', 'quantité', 'montant', 'prix', 'taille', 'poids', 'année', 'annee', 'mois', 'jour', 'durée', 'duree', 'distance', 'superficie', 'effectif', 'score', 'note', 'pourcentage', '%'];
|
|
74
|
-
const isNumeric = numericPatterns.some(pattern => designation.includes(pattern));
|
|
75
|
-
if (isNumeric) {
|
|
76
|
-
effectiveTypeCode = 'NUMERIQUE';
|
|
77
|
-
console.log(`[RosterPanel] Fallback typeCode pour ${rosterVar.code}: NUMERIQUE (détecté par libellé)`);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
effectiveTypeCode = 'STRING';
|
|
81
|
-
}
|
|
69
|
+
effectiveTypeCode = 'STRING';
|
|
82
70
|
}
|
|
83
71
|
}
|
|
84
72
|
const variable = {
|
package/package.json
CHANGED