react-dialogger 1.1.101 → 1.1.104

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.
@@ -66,6 +66,7 @@ var lodash_1 = require("lodash");
66
66
  var _components_1 = require("./index.js");
67
67
  var _helpers_1 = require("../helpers/index.js");
68
68
  var _context_1 = require("../context/index.js");
69
+ var isRefObject_1 = require("../helpers/isRefObject");
69
70
  var DialogBase = /** @class */ (function (_super) {
70
71
  __extends(DialogBase, _super);
71
72
  function DialogBase(props) {
@@ -259,8 +260,9 @@ var DialogBase = /** @class */ (function (_super) {
259
260
  if (!key) {
260
261
  throw new Error('Handler key is required');
261
262
  }
262
- if (typeof handler !== 'function') {
263
- throw new Error("Handler \"".concat(key, "\" must be a function"));
263
+ if (typeof handler !== 'function' &&
264
+ !(0, isRefObject_1.isRefObject)(handler)) {
265
+ throw new Error("Handler \"".concat(key, "\" must be a function or a ref object"));
264
266
  }
265
267
  this._handlers[key] = handler;
266
268
  };
@@ -0,0 +1,4 @@
1
+ declare function isRefObject(value: any): value is {
2
+ current: any;
3
+ };
4
+ export { isRefObject };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRefObject = isRefObject;
4
+ function isRefObject(value) {
5
+ return (typeof value === 'object' &&
6
+ value !== null &&
7
+ 'current' in value);
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.101",
3
+ "version": "1.1.104",
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",
@@ -148,7 +148,7 @@ export type TDialogStateListenerCallbackType = (values: FormikProps<any>['values
148
148
  export type TDialogCallbackFn<T = React.ReactNode | React.ReactElement> = (dialog: IDialogApiDef) => T;
149
149
  export type TDialogHeader = TDialogCallbackFn | React.ReactNode | React.JSX.Element;
150
150
  export type TDialogCallbackVoidFn = TDialogCallbackFn<void>;
151
- export interface IDialogApiDef extends Pick<DialogBase<any>, 'isInProcess' | 'setInProcess' | 'values' | 'setValue' | 'setValues' | 'close' | 'dialogOptions' | 'actions' | 'snackbar' | 'formikValidate' | 'formikProps' | 'focus' | 'updateBody' | 'processingListener' | 'addFeature' | 'getFeature' | 'onAbort' | 'handlers'> {
151
+ export interface IDialogApiDef extends Pick<DialogBase<any>, 'isInProcess' | 'setInProcess' | 'values' | 'setValue' | 'setValues' | 'close' | 'dialogOptions' | 'actions' | 'snackbar' | 'formikValidate' | 'formikProps' | 'focus' | 'updateBody' | 'processingListener' | 'addFeature' | 'getFeature' | 'onAbort' | 'handlers' | 'addHandler'> {
152
152
  }
153
153
  export interface IDialogCloseRef extends Pick<DialogBase<any>, 'close'> {
154
154
  }
@@ -256,7 +256,9 @@ export type DialogValues<T extends Record<string, any>> = ModelDialogValues<T>;
256
256
  export type Dialogify<T> = T extends Function ? never : T extends string | number | boolean | null | undefined | Date ? T : T extends Array<infer U> ? Dialogify<U>[] : T extends object ? {
257
257
  [K in keyof T]: Dialogify<T[K]>;
258
258
  } : never;
259
- export type DialogHandlerFn = (...args: any[]) => any;
259
+ export type DialogHandlerFn = ((...args: any[]) => any) | {
260
+ current: null;
261
+ };
260
262
  export type DialogHandlers = Record<string, DialogHandlerFn>;
261
263
  export interface BaseDialogDOMRect {
262
264
  height?: number;