@mcurros2/microm 1.1.439-0 → 1.1.441-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/dist/index.d.ts CHANGED
@@ -339,8 +339,10 @@ export type ValidatorConfigurationParms = {
339
339
  data?: any;
340
340
  };
341
341
  export type ValidatorConfiguration = Partial<Record<keyof typeof CommonValidators, ValidatorConfigurationParms>>;
342
- /** `disabled` bypasses protection. `allways` skips dirty checks only in edit; view is unprotected. */
343
342
  export type NavigationProtectionMode = 'save' | 'confirm' | 'allways' | 'disabled';
343
+ export type NavigationProtection = Partial<Record<FormMode, NavigationProtectionMode>> & {
344
+ default: NavigationProtectionMode;
345
+ };
344
346
  export const ModalsManagerDefaultProps: {
345
347
  closeLabel: string;
346
348
  fullscreenLabel: string;
@@ -490,9 +492,16 @@ export interface UseEntityFormReturnType {
490
492
  isFormFieldValid: (column_name: string) => boolean;
491
493
  activeFormActions: EntityFormActions;
492
494
  silentSave: (requestOptions?: MicroMRequestOptions) => Promise<SilentSaveResult>;
495
+ navigationGuard: UseConfirmNavigationOptions;
493
496
  }
494
497
  export const UseEntityFormDefaultProps: Partial<UseEntityFormOptions>;
495
498
  export function useEntityForm(props: UseEntityFormOptions): UseEntityFormReturnType;
499
+ export interface EntityFormNavigationPresentation {
500
+ showOK?: boolean;
501
+ showCancel?: boolean;
502
+ buttons?: ReactNode;
503
+ }
504
+ export function useEntityFormNavigationProtection(formAPI: UseEntityFormReturnType, { showCancel, showOK, buttons }: EntityFormNavigationPresentation): void;
496
505
  export interface EntityFormProps extends PropsWithChildren {
497
506
  showOK?: boolean;
498
507
  showCancel?: boolean;
@@ -579,7 +588,7 @@ export interface EntityFormModalProps {
579
588
  entityConstructor: (client: MicroMClient) => Entity<EntityDefinition>;
580
589
  initialFormMode?: FormMode;
581
590
  getDataOnInit?: boolean;
582
- navigationProtection?: NavigationProtectionMode;
591
+ navigationProtection?: NavigationProtection;
583
592
  openState: boolean;
584
593
  setOpenState: (open: boolean) => void;
585
594
  onModalClosed?: () => void;
@@ -1302,7 +1311,7 @@ export interface FormOptions<T extends Entity<EntityDefinition>> extends Omit<En
1302
1311
  getDataOnInit?: boolean;
1303
1312
  onSaved?: (status: OperationStatus<DBStatusResult>) => void;
1304
1313
  onCancel?: () => void;
1305
- navigationProtection?: NavigationProtectionMode;
1314
+ navigationProtection?: NavigationProtection;
1306
1315
  validateForm?: ValidateFormCallback;
1307
1316
  }
1308
1317
  export type useStateReturnType<T> = [T, React.Dispatch<React.SetStateAction<T>>];
@@ -2463,7 +2472,7 @@ export interface OpenFormProps {
2463
2472
  title?: string;
2464
2473
  element?: HTMLElement;
2465
2474
  getDataOnInit?: boolean;
2466
- navigationProtection?: NavigationProtectionMode;
2475
+ navigationProtection?: NavigationProtection;
2467
2476
  onModalSaved?: (new_status: OperationStatus<DBStatusResult | null>) => void;
2468
2477
  onModalCancelled?: () => void;
2469
2478
  onModalClosed?: () => void;