@ceedcv-maya/shared-hooks-react 0.8.0 → 0.9.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ceedcv-maya/shared-hooks-react",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -14,11 +14,12 @@ export interface UseAutoSaveResult {
14
14
  * Hook de autoguardado con debounce unificado.
15
15
  * Reutilizable en WizardStep2Blocks, TemplateEditor y DocumentWizard.
16
16
  *
17
- * @param saveFn Función async que realiza el guardado.
17
+ * @param saveFn Función async que realiza el guardado. Devuelve `false` si no hubo
18
+ * persistencia real (sin cambios); cualquier otro valor marca éxito.
18
19
  * @param delay Milisegundos de debounce (por defecto 1500ms).
19
20
  */
20
21
  export function useAutoSave(
21
- saveFn: () => Promise<void>,
22
+ saveFn: () => Promise<boolean | void>,
22
23
  delay = 1500,
23
24
  ): UseAutoSaveResult {
24
25
  const [saveStatus, setSaveStatus] = useState<SaveStatus>('idle');
@@ -32,7 +33,11 @@ export function useAutoSave(
32
33
  const executeSave = useCallback(async () => {
33
34
  setSaveStatus('saving');
34
35
  try {
35
- await saveFnRef.current();
36
+ const persisted = await saveFnRef.current();
37
+ if (persisted === false) {
38
+ setSaveStatus('idle');
39
+ return;
40
+ }
36
41
  setLastSaved(new Date());
37
42
  setSaveStatus('saved');
38
43
  if (savedClearRef.current) clearTimeout(savedClearRef.current);