@rsuci/shared-form-components 1.0.81 → 1.0.83

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":"ConfirmationModal.d.ts","sourceRoot":"","sources":["../../../src/components/form-renderer/ConfirmationModal.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAE9E,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA8JvD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"ConfirmationModal.d.ts","sourceRoot":"","sources":["../../../src/components/form-renderer/ConfirmationModal.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAE9E,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA4JvD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -74,6 +74,6 @@ const ConfirmationModal = ({ isOpen, title, message, confirmText = 'Confirmer',
74
74
  onCancel();
75
75
  }
76
76
  };
77
- return (_jsxs("div", { className: "fixed inset-0 z-50 overflow-y-auto", "aria-labelledby": "modal-title", role: "dialog", "aria-modal": "true", children: [_jsx("div", { className: "fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity", onClick: handleOverlayClick }), _jsx("div", { className: "flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0", children: _jsxs("div", { ref: modalRef, className: "relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg", children: [_jsx("div", { className: "bg-white px-4 pb-4 pt-5 sm:p-6 sm:pb-4", children: _jsxs("div", { className: "sm:flex sm:items-start", children: [_jsx("div", { className: `mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full ${config.iconBg} sm:mx-0 sm:h-10 sm:w-10`, children: config.icon }), _jsxs("div", { className: "mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left", children: [_jsx("h3", { className: "text-base font-semibold leading-6 text-gray-900", id: "modal-title", children: title }), _jsx("div", { className: "mt-2", children: _jsx("p", { className: "text-sm text-gray-500", children: message }) })] })] }) }), _jsxs("div", { className: "bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6", children: [_jsx("button", { ref: confirmButtonRef, type: "button", disabled: isProcessing, onClick: onConfirm, className: `inline-flex w-full justify-center rounded-md px-3 py-2 text-sm font-semibold shadow-sm ${config.confirmBg} ${config.confirmText} sm:ml-3 sm:w-auto focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed`, children: isProcessing ? (_jsxs("span", { className: "flex items-center", children: [_jsx("span", { className: "animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2" }), "Traitement..."] })) : (confirmText) }), _jsx("button", { type: "button", disabled: isProcessing, onClick: onCancel, className: "mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed", children: cancelText })] })] }) })] }));
77
+ return (_jsxs("div", { className: "fixed inset-0 z-50 flex items-center justify-center p-4", "aria-labelledby": "modal-title", role: "dialog", "aria-modal": "true", children: [_jsx("div", { className: "fixed inset-0 bg-black/50 transition-opacity", onClick: handleOverlayClick }), _jsxs("div", { ref: modalRef, className: "relative z-10 w-full max-w-md transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all", children: [_jsx("div", { className: "bg-white px-4 pb-4 pt-5 sm:p-6 sm:pb-4", children: _jsxs("div", { className: "sm:flex sm:items-start", children: [_jsx("div", { className: `mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full ${config.iconBg} sm:mx-0 sm:h-10 sm:w-10`, children: config.icon }), _jsxs("div", { className: "mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left", children: [_jsx("h3", { className: "text-base font-semibold leading-6 text-gray-900", id: "modal-title", children: title }), _jsx("div", { className: "mt-2", children: _jsx("p", { className: "text-sm text-gray-500", children: message }) })] })] }) }), _jsxs("div", { className: "bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6", children: [_jsx("button", { ref: confirmButtonRef, type: "button", disabled: isProcessing, onClick: onConfirm, className: `inline-flex w-full justify-center rounded-md px-3 py-2 text-sm font-semibold shadow-sm ${config.confirmBg} ${config.confirmText} sm:ml-3 sm:w-auto focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed`, children: isProcessing ? (_jsxs("span", { className: "flex items-center", children: [_jsx("span", { className: "animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2" }), "Traitement..."] })) : (confirmText) }), _jsx("button", { type: "button", disabled: isProcessing, onClick: onCancel, className: "mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed", children: cancelText })] })] })] }));
78
78
  };
79
79
  export default ConfirmationModal;
@@ -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;AA0wBD;;;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;AAuxBD;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAgBpD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -26,7 +26,7 @@ import { interpolateVariableLabel } from '../../lib/utils/interpolateVariableLab
26
26
  */
27
27
  const FormRendererInner = () => {
28
28
  const context = useFormRendererContext();
29
- const { formulaire, enquete, config, callbacks, services, geographicComponents, navigation, validation, instances, responses, updateResponse, hasUnsavedChanges, isSubmitting, effectiveDisabled, currentGroup, currentInstance, groupesWithInstances } = context;
29
+ const { formulaire, enquete, config, callbacks, services, geographicComponents, navigation, validation, instances, responses, updateResponse, hasUnsavedChanges, setHasUnsavedChanges, isSubmitting, effectiveDisabled, currentGroup, currentInstance, groupesWithInstances } = context;
30
30
  const { mode, features } = config;
31
31
  const labels = config.labels || {};
32
32
  // Map de fallback: variableCode → réponse (même stratégie que interpolateVariableLabel)
@@ -41,6 +41,10 @@ const FormRendererInner = () => {
41
41
  });
42
42
  return map;
43
43
  }, [responses]);
44
+ // Ref pour tracker si le brouillon vient d'être sauvegardé
45
+ // Un ref est utilisé car les state updates en cascade (auto-actions, etc.)
46
+ // peuvent remettre hasUnsavedChanges à true après setHasUnsavedChanges(false)
47
+ const draftJustSavedRef = useRef(false);
44
48
  // État local pour les modals et actions
45
49
  const [showCancelModal, setShowCancelModal] = useState(false);
46
50
  const [showValidationModal, setShowValidationModal] = useState(false);
@@ -130,6 +134,8 @@ const FormRendererInner = () => {
130
134
  }, [currentGroup, getFilteredVariables, isVariableVisible]);
131
135
  // Handler pour le changement de variable
132
136
  const handleVariableChange = useCallback((variable, value) => {
137
+ // L'utilisateur fait une nouvelle modification → réinitialiser le flag de sauvegarde
138
+ draftJustSavedRef.current = false;
133
139
  let numeroMembre = currentGroup?.estMultiple
134
140
  ? currentInstance?.numeroInstance
135
141
  : undefined;
@@ -179,7 +185,9 @@ const FormRendererInner = () => {
179
185
  }, [formulaire.variables, formulaire.groupes, updateResponse]);
180
186
  // Handler pour l'annulation
181
187
  const handleCancelClick = () => {
182
- if (hasUnsavedChanges) {
188
+ // Si le brouillon vient d'être sauvegardé et l'utilisateur n'a pas fait
189
+ // de nouvelle modification, ne pas afficher le modal de confirmation
190
+ if (hasUnsavedChanges && !draftJustSavedRef.current) {
183
191
  setShowCancelModal(true);
184
192
  }
185
193
  else {
@@ -348,6 +356,8 @@ const FormRendererInner = () => {
348
356
  setIsSavingDraft(true);
349
357
  try {
350
358
  await callbacks.onSaveDraft(responses);
359
+ draftJustSavedRef.current = true;
360
+ setHasUnsavedChanges(false);
351
361
  }
352
362
  finally {
353
363
  setIsSavingDraft(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsuci/shared-form-components",
3
- "version": "1.0.81",
3
+ "version": "1.0.83",
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",