@rsuci/shared-form-components 1.0.39 → 1.0.41
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":"FormRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/form-renderer/FormRenderer.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,cAAc,EAIf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EAEtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAmBlF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,yBAAyB;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAClD,oCAAoC;IACpC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,iCAAiC;IACjC,SAAS,EAAE,qBAAqB,CAAC;IACjC,wBAAwB;IACxB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,wCAAwC;IACxC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iCAAiC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"FormRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/form-renderer/FormRenderer.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,cAAc,EAIf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EAEtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAmBlF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,yBAAyB;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAClD,oCAAoC;IACpC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,iCAAiC;IACjC,SAAS,EAAE,qBAAqB,CAAC;IACjC,wBAAwB;IACxB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,wCAAwC;IACxC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iCAAiC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AA6fD;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAgBpD,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -98,7 +98,36 @@ const FormRendererInner = () => {
|
|
|
98
98
|
};
|
|
99
99
|
// Navigation - Validation avant navigation
|
|
100
100
|
const groupes = groupesWithInstances.length > 0 ? groupesWithInstances : formulaire?.groupes || [];
|
|
101
|
-
|
|
101
|
+
// Validation locale utilisant isVariableVisible du formTree
|
|
102
|
+
const validateCurrentGroupWithVisibility = useCallback(() => {
|
|
103
|
+
if (!currentGroup || !currentGroup.variables)
|
|
104
|
+
return true;
|
|
105
|
+
// Pour les groupes multiples, vérifier si toutes les instances sont complètes
|
|
106
|
+
if (currentGroup.estMultiple && currentGroup.instances) {
|
|
107
|
+
return validation.validateAllInstancesComplete(currentGroup);
|
|
108
|
+
}
|
|
109
|
+
// Pour les groupes normaux, valider uniquement les variables visibles et obligatoires
|
|
110
|
+
const requiredVariables = currentGroup.variables.filter(v => v.estObligatoire);
|
|
111
|
+
for (const variable of requiredVariables) {
|
|
112
|
+
// Vérifier si la variable est visible via le formTree
|
|
113
|
+
const isVisible = isVariableVisible(variable);
|
|
114
|
+
if (!isVisible) {
|
|
115
|
+
// Variable masquée = pas de validation
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
// Vérifier si la variable a une valeur
|
|
119
|
+
const responseKey = currentGroup.estMultiple && currentInstance?.numeroInstance
|
|
120
|
+
? `${variable.code}_${currentInstance.numeroInstance}`
|
|
121
|
+
: variable.code;
|
|
122
|
+
const response = responses[responseKey];
|
|
123
|
+
const hasValue = response && response.valeur != null && response.valeur !== '';
|
|
124
|
+
if (!hasValue) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
}, [currentGroup, currentInstance, responses, isVariableVisible, validation]);
|
|
130
|
+
const canGoNext = validateCurrentGroupWithVisibility();
|
|
102
131
|
const isFormValid = validation.validateAllGroups(groupes, responses).isValid;
|
|
103
132
|
const handleNext = () => {
|
|
104
133
|
if (canGoNext && !navigation.isLastGroup) {
|
|
@@ -170,7 +199,7 @@ const FormRendererInner = () => {
|
|
|
170
199
|
if (!formulaire || !formulaire.groupes || formulaire.groupes.length === 0) {
|
|
171
200
|
return (_jsx("div", { className: "min-h-screen bg-gray-50 flex items-center justify-center", children: _jsxs("div", { className: "bg-white rounded-lg shadow-sm border border-gray-200 p-8 text-center max-w-md", children: [_jsx("div", { className: "text-red-500 mb-4", children: _jsx("svg", { className: "w-12 h-12 mx-auto", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.732-.833-2.5 0L4.268 18.5c-.77.833.192 2.5 1.732 2.5z" }) }) }), _jsx("h3", { className: "text-lg font-medium text-gray-900 mb-2", children: "Formulaire non configur\u00E9" }), _jsx("p", { className: "text-gray-600 mb-4", children: "Ce formulaire ne contient aucun groupe de variables." }), _jsx("button", { onClick: callbacks.onCancel, className: "inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700", children: "Retour" })] }) }));
|
|
172
201
|
}
|
|
173
|
-
return (_jsxs("div", { className: "min-h-screen bg-gray-50", children: [_jsxs("div", { className: "max-w-4xl mx-auto px-4 py-6", children: [_jsxs("div", { className: "bg-white rounded-lg shadow-sm border border-gray-200 p-4 mb-6", children: [_jsx("h1", { className: "text-xl font-semibold text-gray-900 mb-4", children: formulaire.designation }), _jsx(FormProgress, { showPercentage: true })] }), _jsxs("div", { className: "bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden mb-6", children: [_jsx("div", { className: "bg-green-600 px-6 py-4", children:
|
|
202
|
+
return (_jsxs("div", { className: "min-h-screen bg-gray-50", children: [_jsxs("div", { className: "max-w-4xl mx-auto px-4 py-6", children: [_jsxs("div", { className: "bg-white rounded-lg shadow-sm border border-gray-200 p-4 mb-6", children: [_jsx("h1", { className: "text-xl font-semibold text-gray-900 mb-4", children: formulaire.designation }), _jsx(FormProgress, { showPercentage: true })] }), _jsxs("div", { className: "bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden mb-6", children: [_jsx("div", { className: "bg-green-600 px-6 py-4", children: _jsx("h2", { className: "text-xl font-bold text-white uppercase tracking-wide", children: currentGroup?.designation }) }), _jsxs("div", { className: "p-6", children: [currentGroup?.estMultiple && currentGroup.instances && (_jsx("div", { className: "mb-6", children: _jsx(GroupeInstanceTabs, { groupe: currentGroup, currentInstanceIndex: navigation.navigationState.instanceIndex, responses: responses, onInstanceChange: handleInstanceChange, onInstanceAdded: handleInstanceAdded, onInstanceRemoved: handleInstanceRemoved, disabled: effectiveDisabled }) })), _jsx("div", { className: "space-y-6", children: visibleVariables.map(variable => {
|
|
174
203
|
const responseKey = currentGroup?.estMultiple && currentInstance?.numeroInstance
|
|
175
204
|
? `${variable.code}_${currentInstance.numeroInstance}`
|
|
176
205
|
: variable.code;
|
package/package.json
CHANGED