@rsuci/shared-form-components 1.0.23 → 1.0.24
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.
|
@@ -21,6 +21,10 @@ interface GroupRendererProps {
|
|
|
21
21
|
onValidation: (errors: ValidationError[]) => void;
|
|
22
22
|
onAutoAction?: (actions: AutoAction[]) => void;
|
|
23
23
|
disabled?: boolean;
|
|
24
|
+
allResponses?: Record<string, EnqueteReponse>;
|
|
25
|
+
interpolateVariableLabel?: (label: string, responses: Record<string, EnqueteReponse>, numeroMembre?: number) => string;
|
|
26
|
+
RosterCheckInput?: React.ComponentType<any>;
|
|
27
|
+
RosterListInput?: React.ComponentType<any>;
|
|
24
28
|
}
|
|
25
29
|
declare const GroupRenderer: React.FC<GroupRendererProps>;
|
|
26
30
|
export default GroupRenderer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupRenderer.d.ts","sourceRoot":"","sources":["../../src/components/GroupRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,eAAe,EACf,UAAU,EAEX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC1C,+CAA+C;IAC/C,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,IAAI,CAA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C,EAAE,MAAM,KAClB,MAAM,CAAC;IACZ,gBAAgB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC5C,eAAe,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;CAC5C;AAsJD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA+U/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -20,7 +20,7 @@ const MultipleGroupManager = ({ groupe, entries, onAddEntry, onRemoveEntry, chil
|
|
|
20
20
|
: 'bg-gray-300 text-gray-500 cursor-not-allowed'}`, children: [_jsx(Plus, { className: "h-4 w-4 mr-1" }), "Ajouter"] }))] }), _jsx("div", { className: "space-y-4", children: children })] }));
|
|
21
21
|
};
|
|
22
22
|
// Composant pour une entrée individuelle dans un groupe multiple
|
|
23
|
-
const MultipleGroupEntry = ({ groupe, iterationNumber, totalIterations, visibleVariables, responses, onChange, onRemove, canRemove, disabled }) => {
|
|
23
|
+
const MultipleGroupEntry = ({ groupe, iterationNumber, totalIterations, visibleVariables, responses, onChange, onRemove, canRemove, disabled, allResponses, interpolateVariableLabel, RosterCheckInput, RosterListInput }) => {
|
|
24
24
|
const entryTitle = groupe.configMultiple?.labelTemplate?.replace('{index}', iterationNumber.toString()) ||
|
|
25
25
|
`${groupe.designation} ${iterationNumber}`;
|
|
26
26
|
return (_jsxs("div", { className: "iteration-card bg-white border border-gray-200 rounded-lg p-4 shadow-sm", children: [_jsxs("div", { className: "flex items-center justify-between mb-4", children: [_jsxs("h4", { className: "text-lg font-medium text-gray-800 flex items-center", children: [_jsx("span", { className: "w-6 h-6 bg-blue-100 text-blue-800 rounded-full flex items-center justify-center text-sm font-semibold mr-2", children: iterationNumber }), entryTitle] }), groupe.configMultiple?.allowManualControl && canRemove && onRemove && (_jsx("button", { onClick: onRemove, disabled: disabled, className: "p-2 text-red-500 hover:text-red-700 hover:bg-red-50 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed", title: "Supprimer cette entr\u00E9e", children: _jsx(Trash2, { className: "h-4 w-4" }) }))] }), _jsx("div", { className: "variables-grid grid grid-cols-1 md:grid-cols-2 gap-4", children: visibleVariables.map(variable => {
|
|
@@ -29,11 +29,11 @@ const MultipleGroupEntry = ({ groupe, iterationNumber, totalIterations, visibleV
|
|
|
29
29
|
const rosterVariables = (variable.typeCode === 'ROSTERCHECK' || variable.typeCode === 'ROSTERLIST')
|
|
30
30
|
? variable.rosterVariables
|
|
31
31
|
: undefined;
|
|
32
|
-
return (_jsx(VariableRenderer, { variable: variable, value: responses[responseKey]?.valeur, onChange: (value) => onChange(responseKey, value, iterationNumber), numeroMembre: iterationNumber, disabled: disabled, rosterVariables: rosterVariables }, responseKey));
|
|
32
|
+
return (_jsx(VariableRenderer, { variable: variable, value: responses[responseKey]?.valeur, onChange: (value) => onChange(responseKey, value, iterationNumber), numeroMembre: iterationNumber, disabled: disabled, rosterVariables: rosterVariables, allResponses: allResponses, interpolateVariableLabel: interpolateVariableLabel, RosterCheckInput: RosterCheckInput, RosterListInput: RosterListInput }, responseKey));
|
|
33
33
|
}) })] }));
|
|
34
34
|
};
|
|
35
35
|
// Composant principal GroupRenderer
|
|
36
|
-
const GroupRenderer = ({ groupe, responses, conditionEngine, formTree, onChange, onValidation, onAutoAction, disabled = false }) => {
|
|
36
|
+
const GroupRenderer = ({ groupe, responses, conditionEngine, formTree, onChange, onValidation, onAutoAction, disabled = false, allResponses, interpolateVariableLabel, RosterCheckInput, RosterListInput }) => {
|
|
37
37
|
const [multipleEntries, setMultipleEntries] = useState([1]);
|
|
38
38
|
const [validationErrors, setValidationErrors] = useState([]);
|
|
39
39
|
// Déterminer le mode d'utilisation
|
|
@@ -226,7 +226,7 @@ const GroupRenderer = ({ groupe, responses, conditionEngine, formTree, onChange,
|
|
|
226
226
|
return (_jsxs("div", { className: "mb-4 p-3 bg-red-50 border border-red-200 rounded-lg", children: [_jsxs("div", { className: "flex items-center mb-2", children: [_jsx(AlertCircle, { className: "h-4 w-4 text-red-600 mr-2" }), _jsxs("h4", { className: "text-sm font-medium text-red-800", children: ["Erreurs de validation (", validationErrors.length, ")"] })] }), _jsxs("ul", { className: "text-sm text-red-700 space-y-1", children: [validationErrors.slice(0, 5).map((error, index) => (_jsxs("li", { children: ["\u2022 ", error.message] }, index))), validationErrors.length > 5 && (_jsxs("li", { className: "text-red-600 font-medium", children: ["... et ", validationErrors.length - 5, " autres erreurs"] }))] })] }));
|
|
227
227
|
};
|
|
228
228
|
if (groupe.estMultiple) {
|
|
229
|
-
return (_jsxs("div", { className: "group-renderer-multiple", children: [_jsx(ErrorSummary, {}), _jsx(MultipleGroupManager, { groupe: groupe, entries: multipleEntries, onAddEntry: addEntry, onRemoveEntry: removeEntry, children: multipleEntries.map((iterationNumber, index) => (_jsx(MultipleGroupEntry, { groupe: groupe, iterationNumber: iterationNumber, totalIterations: multipleEntries.length, visibleVariables: visibleVariables, responses: responses, onChange: onChange, onRemove: () => removeEntry(index), canRemove: multipleEntries.length > (groupe.configMultiple?.minIterations || 1), disabled: disabled }, iterationNumber))) })] }));
|
|
229
|
+
return (_jsxs("div", { className: "group-renderer-multiple", children: [_jsx(ErrorSummary, {}), _jsx(MultipleGroupManager, { groupe: groupe, entries: multipleEntries, onAddEntry: addEntry, onRemoveEntry: removeEntry, children: multipleEntries.map((iterationNumber, index) => (_jsx(MultipleGroupEntry, { groupe: groupe, iterationNumber: iterationNumber, totalIterations: multipleEntries.length, visibleVariables: visibleVariables, responses: responses, onChange: onChange, onRemove: () => removeEntry(index), canRemove: multipleEntries.length > (groupe.configMultiple?.minIterations || 1), disabled: disabled, allResponses: allResponses, interpolateVariableLabel: interpolateVariableLabel, RosterCheckInput: RosterCheckInput, RosterListInput: RosterListInput }, iterationNumber))) })] }));
|
|
230
230
|
}
|
|
231
231
|
// Groupe simple
|
|
232
232
|
return (_jsxs("div", { className: "group-renderer-simple", children: [_jsxs("div", { className: "mb-6", children: [_jsx("h2", { className: "text-xl font-semibold text-gray-900 mb-2", children: groupe.designation }), visibleVariables.length > 0 && (_jsxs("p", { className: "text-gray-600 text-sm", children: [visibleVariables.length, " ", visibleVariables.length > 1 ? 'champs' : 'champ'] }))] }), _jsx(ErrorSummary, {}), _jsx("div", { className: "variables-container space-y-6", children: visibleVariables.map(variable => {
|
|
@@ -234,7 +234,7 @@ const GroupRenderer = ({ groupe, responses, conditionEngine, formTree, onChange,
|
|
|
234
234
|
const rosterVariables = (variable.typeCode === 'ROSTERCHECK' || variable.typeCode === 'ROSTERLIST')
|
|
235
235
|
? variable.rosterVariables
|
|
236
236
|
: undefined;
|
|
237
|
-
return (_jsx(VariableRenderer, { variable: variable, value: responses[variable.code]?.valeur, onChange: (value) => onChange(variable.code, value), disabled: disabled, rosterVariables: rosterVariables }, variable.code));
|
|
237
|
+
return (_jsx(VariableRenderer, { variable: variable, value: responses[variable.code]?.valeur, onChange: (value) => onChange(variable.code, value), disabled: disabled, rosterVariables: rosterVariables, allResponses: allResponses, interpolateVariableLabel: interpolateVariableLabel, RosterCheckInput: RosterCheckInput, RosterListInput: RosterListInput }, variable.code));
|
|
238
238
|
}) }), visibleVariables.length === 0 && (_jsx("div", { className: "text-center py-8 text-gray-500", children: _jsx("p", { children: "Aucun champ \u00E0 afficher dans ce groupe" }) }))] }));
|
|
239
239
|
};
|
|
240
240
|
export default GroupRenderer;
|
package/package.json
CHANGED