react-dialogger 1.1.75 → 1.1.78

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,7 +1,7 @@
1
- import { Component, ReactNode, RefObject } from 'react';
1
+ import { Component, RefObject } from 'react';
2
2
  import { FormikProps } from "formik";
3
3
  import { DialogActionBase } from "./index.js";
4
- import { BaseDialogProps, BaseDialogState, IDialogSize, DialogOptionsType, TDialogCallbackFn, TDialogCallbackVoidFn, WithBackdrop, IInProcess, TInitialHolder, ISnackbarAnchor, TSeverity, DialogValues, TAccessFrom, ActionBaseDef, DialogContentFooterReturnType, DialogFormikAdapter } from "../types/index.js";
4
+ import { BaseDialogProps, BaseDialogState, IDialogSize, DialogOptionsType, TDialogCallbackFn, TDialogCallbackVoidFn, WithBackdrop, IDialogSnackbar, IInProcess, TInitialHolder, ISnackbarAnchor, TSeverity, DialogValues, TAccessFrom, ActionApiDef, DialogContentFooterReturnType, DialogFormikAdapter } from "../types/index.js";
5
5
  import Dialog, { DialogAction } from "../models/index.js";
6
6
  interface IFormikAdapter extends Pick<FormikProps<any>, 'setValues' | 'setFieldValue' | 'values'> {
7
7
  }
@@ -66,18 +66,18 @@ declare class DialogBase<Values extends FormikProps<Values>> extends Component<B
66
66
  close: (callbackFn?: () => void) => void;
67
67
  focus: () => void;
68
68
  get actions(): {
69
- [key: string]: ActionBaseDef;
69
+ [key: string]: ActionApiDef;
70
70
  };
71
71
  updateBody(body: TDialogCallbackFn): void;
72
72
  processingListener(listener: (inProcess: boolean) => void): this;
73
73
  getDom: () => HTMLDivElement;
74
74
  get snackbar(): {
75
- open: (message: string, severity: TSeverity, key?: string, action?: ((key: string, snackbarRef: any) => ReactNode | void), autoHideDuration?: number | null) => void;
75
+ open: (message: string, severity: TSeverity, key?: string, action?: IDialogSnackbar["action"], autoHideDuration?: number | null) => void;
76
76
  openX: ({ message, severity, key, action, autoHideDuration }: {
77
77
  message: string;
78
78
  severity: TSeverity;
79
79
  key?: string;
80
- action?: (key: string, snackbarRef: any) => ReactNode | void;
80
+ action?: IDialogSnackbar["action"];
81
81
  autoHideDuration?: number;
82
82
  }) => void;
83
83
  close: (key?: string) => void;
@@ -148,22 +148,24 @@ var DialogBase = /** @class */ (function (_super) {
148
148
  return _this._inProcess;
149
149
  };
150
150
  _this.close = function (callbackFn) {
151
- var _a, _b, _c, _d;
152
- if (_this._footerRef.current.inProcess) {
153
- var notify = (_a = _this._dialogOptions.base.notifyOnClosing) !== null && _a !== void 0 ? _a : "snackbar";
154
- if (notify === "snackbar") {
155
- var busyMessage = (_d = (_c = (_b = _this._dialogOptions) === null || _b === void 0 ? void 0 : _b.localText) === null || _c === void 0 ? void 0 : _c.busyMessage) !== null && _d !== void 0 ? _d : 'In Process, Please wait...';
156
- _this.snackbar.open(busyMessage, "warning");
151
+ setTimeout(function () {
152
+ var _a, _b, _c, _d;
153
+ if (_this._footerRef.current.inProcess) {
154
+ var notify = (_a = _this._dialogOptions.base.notifyOnClosing) !== null && _a !== void 0 ? _a : "snackbar";
155
+ if (notify === "snackbar") {
156
+ var busyMessage = (_d = (_c = (_b = _this._dialogOptions) === null || _b === void 0 ? void 0 : _b.localText) === null || _c === void 0 ? void 0 : _c.busyMessage) !== null && _d !== void 0 ? _d : 'In Process, Please wait...';
157
+ _this.snackbar.open(busyMessage, "warning");
158
+ }
159
+ else {
160
+ _this._dialogWithBackDropRef.current.baseZoomEffect();
161
+ }
162
+ return;
157
163
  }
158
- else {
159
- _this._dialogWithBackDropRef.current.baseZoomEffect();
164
+ _this.kill(callbackFn);
165
+ if (typeof _this.props.onClose === "function") {
166
+ _this.props.onClose(_this);
160
167
  }
161
- return;
162
- }
163
- _this.kill(callbackFn);
164
- if (typeof _this.props.onClose === "function") {
165
- _this.props.onClose(_this);
166
- }
168
+ }, 150);
167
169
  };
168
170
  _this.focus = function () {
169
171
  if (_this._dialogRef.current) {
@@ -419,14 +421,19 @@ var DialogBase = /** @class */ (function (_super) {
419
421
  var s = (_a = this._snackbarRef) === null || _a === void 0 ? void 0 : _a.current;
420
422
  var sId = Math.random().toString(36).substring(2, 9);
421
423
  var openMe = function (message, severity, key, action, autoHideDuration) {
422
- s === null || s === void 0 ? void 0 : s.enqueueSnackbar(message, __assign({ autoHideDuration: autoHideDuration !== undefined ? autoHideDuration : _this._dialogOptions.snackbar.autoHideDuration, variant: severity,
424
+ s === null || s === void 0 ? void 0 : s.enqueueSnackbar(message, {
425
+ autoHideDuration: autoHideDuration !== undefined ? autoHideDuration : _this._dialogOptions.snackbar.autoHideDuration,
426
+ variant: severity,
423
427
  // maxSnack: this._dialogOptions.snackbar.maxSnack,
424
- key: key !== null && key !== void 0 ? key : sId, anchorOrigin: {
428
+ key: key !== null && key !== void 0 ? key : sId,
429
+ anchorOrigin: {
425
430
  vertical: _this._dialogOptions.snackbar.anchorOrigin.vertical,
426
431
  horizontal: _this._dialogOptions.snackbar.anchorOrigin.horizontal,
427
- } }, action ? { action: function (key) {
428
- return action(key, s);
429
- } } : {}));
432
+ },
433
+ action: function (key) {
434
+ return typeof action === "function" ? action(key, _this._snackbarRef) : action;
435
+ }
436
+ });
430
437
  };
431
438
  var open = function (message, severity, key, action, autoHideDuration) {
432
439
  openMe(message, severity, key, action, autoHideDuration);
@@ -58,15 +58,15 @@ var DialogContentFooter = (0, react_1.forwardRef)(function (props, ref) {
58
58
  var dialogOptions = dialog.dialogOptions;
59
59
  var CustomFooter = (_a = dialogOptions.slot) === null || _a === void 0 ? void 0 : _a.footer;
60
60
  // Imperative handle
61
- // const [inProcess, setInProcess] = React.useState(false);
62
- var inProcess = false;
61
+ var _d = React.useState(false), inProcess = _d[0], setInProcess = _d[1];
62
+ var inProcessRef = React.useRef(inProcess);
63
63
  var setProcessing = function (processing) {
64
- // setInProcess(processing);
65
- inProcess = processing;
64
+ setInProcess(processing);
65
+ inProcessRef.current = processing;
66
66
  };
67
67
  React.useImperativeHandle(ref, function () { return ({
68
68
  setProcessing: setProcessing,
69
- inProcess: inProcess
69
+ inProcess: inProcessRef.current
70
70
  }); });
71
71
  var staticProps = {
72
72
  dialogOptions: dialogOptions,
package/index.d.ts CHANGED
@@ -5,4 +5,4 @@ export { default } from "./models/Dialog";
5
5
  export { DialogProcessing, DialogCloseAction, DialogFullscreenAction, DialogHeaderActionsWrapper, DialogInfoAction } from "./features";
6
6
  export { DialogAction, ActionProgress, baseDialogOptions } from "./models";
7
7
  export { InitDialogMemoizeBounds } from "./helpers";
8
- export { IDialogApiDef } from './types';
8
+ export { IDialogApiDef, ActionApiDef } from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.75",
3
+ "version": "1.1.78",
4
4
  "description": "This package is a continuation of the react-araci package. Due to an error, react-araci was removed, and it has been decided to continue under the new package name react-dialogger",
5
5
  "main": "index.js",
6
6
  "author": "Sueleyman Topaloglu",
@@ -5,10 +5,10 @@ import { DialogAction } from "../models/index.js";
5
5
  import { CSSProperties } from "react";
6
6
  export type ActionDialogDef = Omit<IDialogApiDef, 'switchFullScreen'>;
7
7
  export type ActionDef = Pick<DialogAction, 'onClick' | 'setOptions' | 'name'>;
8
- export type ActionBaseDef = Pick<InstanceType<typeof DialogActionBase>, 'updateOptions' | 'updateColor' | 'updateVariant' | 'updateLabel' | 'updateIntent' | 'setOptions' | 'setInProcess' | 'getLabel' | 'options' | 'click' | 'remove' | 'name'>;
9
- export interface IDialogActionDef extends ActionBaseDef {
8
+ export type ActionApiDef = Pick<InstanceType<typeof DialogActionBase>, 'updateOptions' | 'updateColor' | 'updateVariant' | 'updateLabel' | 'updateIntent' | 'setOptions' | 'setInProcess' | 'getLabel' | 'options' | 'click' | 'remove' | 'name'>;
9
+ export interface IDialogActionDef extends ActionApiDef {
10
10
  }
11
- export type DialogActionType = (button: ActionBaseDef, dialog: Omit<IDialogApiDef, 'switchFullScreen'>) => void;
11
+ export type DialogActionType = (button: ActionApiDef, dialog: Omit<IDialogApiDef, 'switchFullScreen'>) => void;
12
12
  export interface ActionProps {
13
13
  name: string;
14
14
  options?: DialogActionOptionsType;
@@ -62,7 +62,7 @@ export type DialogActionOptionsType = {
62
62
  style?: React.CSSProperties;
63
63
  baseStyle?: React.CSSProperties;
64
64
  };
65
- type TListenerButtonType = Pick<DialogActionBase, Exclude<keyof ActionBaseDef, 'onClick' | 'getStateListener' | 'name'>>;
65
+ type TListenerButtonType = Pick<DialogActionBase, Exclude<keyof ActionApiDef, 'onClick' | 'getStateListener' | 'name'>>;
66
66
  export type TDialogStateListenerForActionCallbackType = (values: TValues, button: TListenerButtonType, dialog: IListenerDialogDef) => void;
67
67
  export interface IContentFooterProps {
68
68
  }
@@ -6,7 +6,7 @@ import type { FormikProps } from "formik";
6
6
  import type { RefObject } from "react";
7
7
  import { Resizeable } from "../helpers/index.js";
8
8
  import type { DialogContentFooterReturnType, IActionIntents } from "./DialogActionTypes";
9
- import { SnackbarKey, VariantType } from "notistack";
9
+ import { SharedProps, SnackbarKey, SnackbarProvider, VariantType } from "notistack";
10
10
  export interface TBaseDialogState {
11
11
  [K: string]: any;
12
12
  }
@@ -176,7 +176,10 @@ export interface WithBackdrop {
176
176
  bodyRef: RefObject<any>;
177
177
  footerRef: RefObject<any>;
178
178
  prevDialogRect?: BaseDialogDOMRect;
179
- snackbarRef: React.RefObject<any>;
179
+ snackbarRef: React.RefObject<SnackbarProvider>;
180
+ }
181
+ export interface IDialogSnackbar extends Omit<SharedProps, 'action'> {
182
+ action: React.ReactNode | ((key: SnackbarKey, snackbarRef: React.RefObject<SnackbarProvider>) => React.ReactNode);
180
183
  }
181
184
  export interface DialogWithBackdropWrapperRefProps {
182
185
  baseZoomEffect: () => void;