@rsuci/shared-form-components 1.0.73 → 1.0.75

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,KAA4D,MAAM,OAAO,CAAC;AACjF,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;AAsBlF;;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;AAwsBD;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAgBpD,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"FormRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/form-renderer/FormRenderer.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,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;AAsBlF;;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;AAutBD;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAgBpD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -122,6 +122,20 @@ const FormRendererInner = () => {
122
122
  ? currentInstance?.numeroInstance
123
123
  : undefined;
124
124
  updateResponse(variable.code, value, variable, numeroMembre);
125
+ // Mettre à jour le contexte du ConditionEngine immédiatement avec la nouvelle valeur
126
+ // avant de lancer la validation (sinon le contexte est en retard d'un cycle React)
127
+ if (conditionEngine) {
128
+ const responseKey = numeroMembre ? `${variable.code}_${numeroMembre}` : variable.code;
129
+ conditionEngine.updateContext({
130
+ [responseKey]: {
131
+ variableId: variable.id,
132
+ variableCode: variable.code,
133
+ valeur: value,
134
+ numeroMembre,
135
+ dateModification: new Date()
136
+ }
137
+ });
138
+ }
125
139
  // Valider la condition de validation de cette variable
126
140
  if (variable.conditionsValidation) {
127
141
  validateConditionVariable(variable, numeroMembre);
@@ -129,7 +143,7 @@ const FormRendererInner = () => {
129
143
  // Réévaluer les validations des variables dépendantes
130
144
  const groupes = groupesWithInstances.length > 0 ? groupesWithInstances : formulaire?.groupes || [];
131
145
  revalidateDependents(variable.code, groupes, numeroMembre);
132
- }, [currentGroup, currentInstance, updateResponse, validateConditionVariable, revalidateDependents, groupesWithInstances, formulaire?.groupes]);
146
+ }, [currentGroup, currentInstance, updateResponse, conditionEngine, validateConditionVariable, revalidateDependents, groupesWithInstances, formulaire?.groupes]);
133
147
  // Handler pour l'annulation
134
148
  const handleCancelClick = () => {
135
149
  if (hasUnsavedChanges) {
@@ -359,11 +373,11 @@ const FormRendererInner = () => {
359
373
  ? 'bg-orange-500 text-white hover:bg-orange-600'
360
374
  : 'bg-gray-100 text-gray-400 cursor-not-allowed'}`, children: [_jsx("svg", { className: "h-4 w-4 mr-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }), _jsx("span", { className: "hidden sm:inline", children: labels.previousButton || 'Précédent' }), _jsx("span", { className: "sm:hidden", children: "Pr\u00E9c." })] }), mode === 'admin' && features?.saveDraft && callbacks.onSaveDraft && (_jsx("button", { type: "button", onClick: handleSaveDraft, disabled: effectiveDisabled || isSavingDraft || isSubmitting || isSubmittingForm, className: `flex items-center px-4 py-2 rounded-lg font-medium transition-colors ${!effectiveDisabled && !isSavingDraft && !isSubmitting && !isSubmittingForm
361
375
  ? 'bg-yellow-500 text-white hover:bg-yellow-600'
362
- : 'bg-gray-300 text-gray-500 cursor-not-allowed'}`, children: isSavingDraft ? (_jsxs("span", { className: "flex items-center", children: [_jsxs("svg", { className: "animate-spin -ml-1 mr-2 h-4 w-4", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), "Enregistrement..."] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "hidden sm:inline", children: labels.draftButton || 'Enregistrer brouillon' }), _jsx("span", { className: "sm:hidden", children: "Brouillon" })] })) }))] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs("button", { type: "button", onClick: handleCancelClick, disabled: isSubmitting || isSubmittingForm || isSavingDraft, className: "px-4 py-2 rounded-lg font-medium transition-colors bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 disabled:cursor-not-allowed", children: [_jsx("span", { className: "hidden sm:inline", children: labels.cancelButton || 'Annuler' }), _jsx("span", { className: "sm:hidden", children: "Annuler" })] }), !navigation.isLastGroup && (_jsxs("button", { type: "button", onClick: handleNext, disabled: !canGoNext || (!isConsultationMode && effectiveDisabled), className: `flex items-center px-4 py-2 rounded-lg font-medium transition-colors ${canGoNext && (isConsultationMode || !effectiveDisabled)
376
+ : 'bg-gray-300 text-gray-500 cursor-not-allowed'}`, children: isSavingDraft ? (_jsxs("span", { className: "flex items-center", children: [_jsxs("svg", { className: "animate-spin -ml-1 mr-2 h-4 w-4", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), "Enregistrement..."] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "hidden sm:inline", children: labels.draftButton || 'Enregistrer brouillon' }), _jsx("span", { className: "sm:hidden", children: "Brouillon" })] })) }))] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs("button", { type: "button", onClick: handleCancelClick, disabled: isSubmitting || isSubmittingForm || isSavingDraft, className: "px-4 py-2 rounded-lg font-medium transition-colors bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 disabled:cursor-not-allowed", children: [_jsx("span", { className: "hidden sm:inline", children: labels.cancelButton || 'Annuler' }), _jsx("span", { className: "sm:hidden", children: "Annuler" })] }), !navigation.isLastGroup && (_jsxs("button", { type: "button", onClick: handleNext, disabled: !canGoNext || hasConditionErrors || (!isConsultationMode && effectiveDisabled), className: `flex items-center px-4 py-2 rounded-lg font-medium transition-colors ${canGoNext && !hasConditionErrors && (isConsultationMode || !effectiveDisabled)
363
377
  ? 'bg-green-600 text-white hover:bg-green-700'
364
- : 'bg-gray-400 text-gray-200 cursor-not-allowed'}`, title: !canGoNext ? 'Veuillez remplir tous les champs obligatoires' : 'Passer au groupe suivant', children: [_jsx("span", { className: "hidden sm:inline", children: labels.nextButton || 'Suivant' }), _jsx("span", { className: "sm:hidden", children: "Suiv." }), _jsx("svg", { className: "h-4 w-4 ml-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) })] })), navigation.isLastGroup && !isConsultationMode && !showDRValidationButtons && (_jsx("button", { type: "button", onClick: handleSubmit, disabled: effectiveDisabled || isSubmitting || isSubmittingForm || !isFormValid, className: `flex items-center px-4 py-2 rounded-lg font-medium transition-colors ${isFormValid && !effectiveDisabled
378
+ : 'bg-gray-400 text-gray-200 cursor-not-allowed'}`, title: hasConditionErrors ? 'Corrigez les erreurs de validation' : !canGoNext ? 'Veuillez remplir tous les champs obligatoires' : 'Passer au groupe suivant', children: [_jsx("span", { className: "hidden sm:inline", children: labels.nextButton || 'Suivant' }), _jsx("span", { className: "sm:hidden", children: "Suiv." }), _jsx("svg", { className: "h-4 w-4 ml-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) })] })), navigation.isLastGroup && !isConsultationMode && !showDRValidationButtons && (_jsx("button", { type: "button", onClick: handleSubmit, disabled: effectiveDisabled || isSubmitting || isSubmittingForm || !isFormValid || hasConditionErrors, className: `flex items-center px-4 py-2 rounded-lg font-medium transition-colors ${isFormValid && !effectiveDisabled && !hasConditionErrors
365
379
  ? 'bg-green-600 text-white hover:bg-green-700'
366
- : 'bg-gray-400 text-gray-200 cursor-not-allowed'}`, title: !isFormValid ? 'Veuillez remplir tous les champs obligatoires' : '', children: isSubmitting || isSubmittingForm ? (_jsxs("span", { className: "flex items-center", children: [_jsxs("svg", { className: "animate-spin -ml-1 mr-2 h-4 w-4", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), "Envoi en cours..."] })) : (labels.submitButton || (mode === 'admin' ? 'Valider' : 'Soumettre')) })), showDRValidationButtons && (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", onClick: () => handleOpenValidationModal('rejeter'), disabled: isSubmitting || isSubmittingForm, className: "px-4 py-2 rounded-lg font-medium transition-colors bg-red-600 text-white hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center", children: [_jsx("svg", { className: "h-4 w-4 mr-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }), labels.rejectDRButton || 'Rejeter'] }), _jsxs("button", { type: "button", onClick: () => handleOpenValidationModal('valider'), disabled: isSubmitting || isSubmittingForm, className: "px-4 py-2 rounded-lg font-medium transition-colors bg-green-600 text-white hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center", children: [_jsx("svg", { className: "h-4 w-4 mr-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }), labels.validateDRButton || 'Valider'] })] }))] })] }) })] }), _jsx(ConfirmationModal, { isOpen: showCancelModal, title: "Annuler les modifications", message: "Vous avez des modifications non sauvegard\u00E9es. \u00CAtes-vous s\u00FBr de vouloir quitter ?", confirmText: "Quitter", cancelText: "Continuer", onConfirm: handleConfirmCancel, onCancel: () => setShowCancelModal(false), type: "danger" }), _jsx(ValidationModal, { isOpen: showValidationModal, onClose: () => setShowValidationModal(false), onConfirm: handleConfirmValidation, action: validationAction, enquetesCount: 1 })] }));
380
+ : 'bg-gray-400 text-gray-200 cursor-not-allowed'}`, title: hasConditionErrors ? 'Corrigez les erreurs de validation' : !isFormValid ? 'Veuillez remplir tous les champs obligatoires' : '', children: isSubmitting || isSubmittingForm ? (_jsxs("span", { className: "flex items-center", children: [_jsxs("svg", { className: "animate-spin -ml-1 mr-2 h-4 w-4", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), "Envoi en cours..."] })) : (labels.submitButton || (mode === 'admin' ? 'Valider' : 'Soumettre')) })), showDRValidationButtons && (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", onClick: () => handleOpenValidationModal('rejeter'), disabled: isSubmitting || isSubmittingForm, className: "px-4 py-2 rounded-lg font-medium transition-colors bg-red-600 text-white hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center", children: [_jsx("svg", { className: "h-4 w-4 mr-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }), labels.rejectDRButton || 'Rejeter'] }), _jsxs("button", { type: "button", onClick: () => handleOpenValidationModal('valider'), disabled: isSubmitting || isSubmittingForm, className: "px-4 py-2 rounded-lg font-medium transition-colors bg-green-600 text-white hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center", children: [_jsx("svg", { className: "h-4 w-4 mr-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }), labels.validateDRButton || 'Valider'] })] }))] })] }) })] }), _jsx(ConfirmationModal, { isOpen: showCancelModal, title: "Annuler les modifications", message: "Vous avez des modifications non sauvegard\u00E9es. \u00CAtes-vous s\u00FBr de vouloir quitter ?", confirmText: "Quitter", cancelText: "Continuer", onConfirm: handleConfirmCancel, onCancel: () => setShowCancelModal(false), type: "danger" }), _jsx(ValidationModal, { isOpen: showValidationModal, onClose: () => setShowValidationModal(false), onConfirm: handleConfirmValidation, action: validationAction, enquetesCount: 1 })] }));
367
381
  };
368
382
  /**
369
383
  * Composant principal FormRenderer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsuci/shared-form-components",
3
- "version": "1.0.73",
3
+ "version": "1.0.75",
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",