@rsuci/shared-form-components 1.0.82 → 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":"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;AA4wBD;;;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"}
@@ -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,7 @@ const FormRendererInner = () => {
348
356
  setIsSavingDraft(true);
349
357
  try {
350
358
  await callbacks.onSaveDraft(responses);
359
+ draftJustSavedRef.current = true;
351
360
  setHasUnsavedChanges(false);
352
361
  }
353
362
  finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsuci/shared-form-components",
3
- "version": "1.0.82",
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",