@rsuci/shared-form-components 1.0.106 → 1.0.107
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/inputs/CollectionInput.js +1 -1
- package/dist/components/roster/RosterPanel.d.ts +1 -0
- package/dist/components/roster/RosterPanel.d.ts.map +1 -1
- package/dist/components/roster/RosterPanel.js +7 -1
- package/dist/lib/roster-condition-engine.d.ts +7 -0
- package/dist/lib/roster-condition-engine.d.ts.map +1 -1
- package/dist/lib/roster-condition-engine.js +33 -0
- package/package.json +1 -1
|
@@ -131,6 +131,6 @@ const CollectionInput = ({ variable, value, onChange, onBlur, error, disabled, i
|
|
|
131
131
|
return (_jsxs("div", { className: "space-y-2", style: containerStyle, children: [options.map((option) => (_jsxs("label", { className: "flex items-center space-x-2 cursor-pointer", children: [_jsx("input", { type: "radio", name: variable.code + (numeroMembre ? `_${numeroMembre}` : ''), value: option.code, checked: selectedValue === option.code, onChange: (e) => onChange(e.target.value), onBlur: onBlur, disabled: effectiveDisabled, className: `w-4 h-4 text-green-600 border-gray-300 focus:ring-green-500 ${effectiveDisabled ? 'cursor-not-allowed' : 'cursor-pointer'}` }), _jsx("span", { className: `text-sm ${effectiveDisabled ? 'text-gray-400' : 'text-gray-700'}`, style: textStyle, children: option.designation })] }, option.code))), isStaleSelection && (_jsx("div", { className: "p-2 bg-orange-50 border border-orange-200 rounded text-sm", children: _jsxs("span", { className: "text-orange-700", children: ["La selection precedente (instance ", selectedValue, ") n'est plus disponible."] }) }))] }));
|
|
132
132
|
}
|
|
133
133
|
// Affichage avec SearchableSelect pour beaucoup d'options (>5)
|
|
134
|
-
return (_jsxs("div", { className: "space-y-2", style: containerStyle, children: [_jsx(SearchableSelect, { options: options, value: selectedOption, onChange: handleChange, placeholder: "
|
|
134
|
+
return (_jsxs("div", { className: "space-y-2", style: containerStyle, children: [_jsx(SearchableSelect, { options: options, value: selectedOption, onChange: handleChange, placeholder: "S\u00E9lectionner...", searchPlaceholder: "Rechercher...", disabled: effectiveDisabled, required: variable.estObligatoire, error: error, formatOptionLabel: formatOptionLabel, noOptionsMessage: "Aucune donnee disponible" }), selectedValue && selectedOption && (_jsx("div", { className: "p-2 bg-green-50 border border-green-200 rounded text-sm", children: _jsxs("span", { className: "text-green-800", style: textStyle, children: ["Selectionne: ", selectedOption.designation] }) })), isStaleSelection && (_jsx("div", { className: "p-2 bg-orange-50 border border-orange-200 rounded text-sm", children: _jsxs("span", { className: "text-orange-700", children: ["La selection precedente (instance ", selectedValue, ") n'est plus disponible."] }) }))] }));
|
|
135
135
|
};
|
|
136
136
|
export default CollectionInput;
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"RosterPanel.d.ts","sourceRoot":"","sources":["../../../src/components/roster/RosterPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAkB,MAA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,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,CAyM3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -100,6 +100,10 @@ const RosterPanel = ({ option, rosterVariables, value, onChange, disabled, showC
|
|
|
100
100
|
isDisabled: disabled,
|
|
101
101
|
variableIsReadonly: variable.isReadonly
|
|
102
102
|
});
|
|
103
|
+
// Évaluer la condition de validation scopée au roster
|
|
104
|
+
const validationResult = rosterVar.conditionsValidation
|
|
105
|
+
? RosterConditionEngine.evaluateValidation(rosterVar.conditionsValidation, value)
|
|
106
|
+
: null;
|
|
103
107
|
return (_jsx("div", { className: "roster-variable", children: _jsx(VariableRenderer, { variable: variable, value: currentValue, onChange: (newValue) => {
|
|
104
108
|
console.log('[RosterPanel] onChange appelé', {
|
|
105
109
|
variableCode: rosterVar.code,
|
|
@@ -107,7 +111,9 @@ const RosterPanel = ({ option, rosterVariables, value, onChange, disabled, showC
|
|
|
107
111
|
newValueType: typeof newValue
|
|
108
112
|
});
|
|
109
113
|
onChange(rosterVar.code, newValue);
|
|
110
|
-
}, disabled: disabled, services: services, isConsultationMode: isConsultationMode, interpolateVariableLabel: interpolateVariableLabel, allResponses: allResponses, numeroMembre: numeroMembre
|
|
114
|
+
}, disabled: disabled, services: services, isConsultationMode: isConsultationMode, interpolateVariableLabel: interpolateVariableLabel, allResponses: allResponses, numeroMembre: numeroMembre, conditionValidationError: validationResult && !validationResult.isValid
|
|
115
|
+
? validationResult.errorMessage
|
|
116
|
+
: null }) }, rosterVar.code));
|
|
111
117
|
}) })) : (_jsx("div", { className: "p-4 text-center text-gray-500 bg-gray-50 rounded border border-gray-200", children: _jsx("p", { className: "text-sm", children: "\u2713 Cochez l'option ci-dessus pour renseigner les variables" }) }))] }));
|
|
112
118
|
};
|
|
113
119
|
export default RosterPanel;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* Les conditions sont évaluées PAR LIGNE (par option de roster) indépendamment.
|
|
7
7
|
* Le scope est limité aux variables du même ROSTER uniquement.
|
|
8
8
|
*/
|
|
9
|
+
import { ValidationEvalResult } from '../types/enquete';
|
|
9
10
|
export type RosterConditionErrorType = 'variable_not_in_scope' | 'jump_out_of_scope' | 'backward_jump' | 'self_reference' | 'syntax_error';
|
|
10
11
|
export interface RosterConditionError {
|
|
11
12
|
type: RosterConditionErrorType;
|
|
@@ -37,6 +38,12 @@ export declare class RosterConditionEngine {
|
|
|
37
38
|
* la fuite de données entre les différentes lignes du roster.
|
|
38
39
|
*/
|
|
39
40
|
static evaluate(condition: string, lineValues: Record<string, any>): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Évalue une condition de validation (ConditionEval) au runtime
|
|
43
|
+
* Utilise les valeurs de la ligne courante du roster (scope isolé)
|
|
44
|
+
* Même pattern d'isolation que evaluate() pour les conditions d'affichage
|
|
45
|
+
*/
|
|
46
|
+
static evaluateValidation(condition: string, lineValues: Record<string, any>): ValidationEvalResult;
|
|
40
47
|
/**
|
|
41
48
|
* Extrait toutes les références de variables d'une condition
|
|
42
49
|
* Format: ${VAR_CODE}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roster-condition-engine.d.ts","sourceRoot":"","sources":["../../src/lib/roster-condition-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"roster-condition-engine.d.ts","sourceRoot":"","sources":["../../src/lib/roster-condition-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,MAAM,wBAAwB,GAChC,uBAAuB,GACvB,mBAAmB,GACnB,eAAe,GACf,gBAAgB,GAChB,cAAc,CAAC;AAEnB,MAAM,WAAW,oBAAoB;IACnC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EAAE,GAAG,CAAC,GAC9B,GAAG,CAAC,MAAM,CAAC;IAyCd;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IA8BrC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;CAsD9B"}
|
|
@@ -115,6 +115,39 @@ export class RosterConditionEngine {
|
|
|
115
115
|
return true; // En cas d'erreur, afficher par défaut
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Évalue une condition de validation (ConditionEval) au runtime
|
|
120
|
+
* Utilise les valeurs de la ligne courante du roster (scope isolé)
|
|
121
|
+
* Même pattern d'isolation que evaluate() pour les conditions d'affichage
|
|
122
|
+
*/
|
|
123
|
+
static evaluateValidation(condition, lineValues) {
|
|
124
|
+
if (!condition?.trim()) {
|
|
125
|
+
return { isValid: true, errorMessage: null, variableCode: '', condition: '' };
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
// Construire un contexte isolé pour cette ligne du roster
|
|
129
|
+
const responses = {};
|
|
130
|
+
for (const [code, value] of Object.entries(lineValues)) {
|
|
131
|
+
responses[code] = {
|
|
132
|
+
variableCode: code,
|
|
133
|
+
valeur: value,
|
|
134
|
+
dateModification: new Date()
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// Créer un engine isolé pour cette évaluation
|
|
138
|
+
const engine = new ConditionEngine(responses);
|
|
139
|
+
return engine.evaluateValidation(condition, '');
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
console.warn('[RosterConditionEngine] Erreur évaluation validation:', condition, error);
|
|
143
|
+
return {
|
|
144
|
+
isValid: false,
|
|
145
|
+
errorMessage: 'Erreur de validation',
|
|
146
|
+
variableCode: '',
|
|
147
|
+
condition
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
118
151
|
/**
|
|
119
152
|
* Extrait toutes les références de variables d'une condition
|
|
120
153
|
* Format: ${VAR_CODE}
|
package/package.json
CHANGED