react-dialogger 1.1.105 → 1.1.107

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,11 +1,10 @@
1
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, IDialogSnackbar, IInProcess, TInitialHolder, ISnackbarAnchor, TSeverity, TAccessFrom, ActionApiDef, DialogContentFooterReturnType, DialogFormikAdapter, DialogHandlers, DialogHandlerFn, Dialogify } from "../types/index.js";
4
+ import { BaseDialogProps, BaseDialogState, IDialogSize, DialogOptionsType, TDialogCallbackFn, TDialogCallbackVoidFn, WithBackdrop, IDialogSnackbar, IInProcess, TInitialHolder, ISnackbarAnchor, TSeverity, TAccessFrom, ActionApiDef, DialogContentFooterReturnType, DialogFormikAdapter, DialogExternalHandlers, DialogExternalHandlerFn, Dialogify, DialogExternalRefs, DialogExternalRef } 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
  }
8
- type FeatureType = Partial<Record<string, any>>;
9
8
  declare class DialogBase<Values extends Record<string, any>> extends Component<BaseDialogProps<Values>, BaseDialogState> {
10
9
  protected _initialValues: Dialogify<Values>;
11
10
  _dialogTranslate: {
@@ -31,7 +30,8 @@ declare class DialogBase<Values extends Record<string, any>> extends Component<B
31
30
  protected _shInterval: number;
32
31
  protected _snackbarAnchor: ISnackbarAnchor;
33
32
  protected _parent: Dialog<Values>;
34
- protected _handlers: DialogHandlers;
33
+ protected _xhandlers: DialogExternalHandlers;
34
+ protected _xrefs: DialogExternalRefs;
35
35
  private _inProcess;
36
36
  private _footerRef;
37
37
  protected _headerRef: RefObject<DialogContentFooterReturnType>;
@@ -42,12 +42,10 @@ declare class DialogBase<Values extends Record<string, any>> extends Component<B
42
42
  constructor(props: BaseDialogProps<Values> & {
43
43
  parent: Dialog<Values>;
44
44
  });
45
- private T;
46
- private readonly _features;
47
- get handlers(): DialogHandlers;
48
- addHandler(key: string, handler: DialogHandlerFn): void;
49
- addFeature(key: string, value: any): void;
50
- getFeature(key: string): FeatureType;
45
+ get xhandlers(): DialogExternalHandlers;
46
+ appendXHandler(key: string, handler: DialogExternalHandlerFn): void;
47
+ get xrefs(): DialogExternalRefs;
48
+ appendXRef(key: string, ref: DialogExternalRef): void;
51
49
  get parent(): Dialog<Values>;
52
50
  get dialogTranslate(): {
53
51
  lastX: number;
@@ -78,8 +78,6 @@ var DialogBase = /** @class */ (function (_super) {
78
78
  _this._inProcess = { inProcess: false };
79
79
  _this._footerRef = React.createRef();
80
80
  _this._headerRef = React.createRef();
81
- _this.T = [];
82
- _this._features = {};
83
81
  // Initialize a ref for each action dynamically
84
82
  _this.initializeActionRef = function (key) {
85
83
  if (!_this._actionRefs.hasOwnProperty(key)) {
@@ -245,32 +243,39 @@ var DialogBase = /** @class */ (function (_super) {
245
243
  _this._dialogWithBackDropRef = (0, react_1.createRef)();
246
244
  _this._processingListeners = (_a = props.processingListeners) !== null && _a !== void 0 ? _a : [];
247
245
  _this._abortedListeners = (_b = props.abortedListeners) !== null && _b !== void 0 ? _b : [];
248
- _this._features = [];
249
- _this._handlers = props.handlers;
246
+ _this._xhandlers = props.xhandlers;
250
247
  return _this;
248
+ // this._externalRefs = props.externalRefs;
251
249
  }
252
- Object.defineProperty(DialogBase.prototype, "handlers", {
250
+ Object.defineProperty(DialogBase.prototype, "xhandlers", {
253
251
  get: function () {
254
- return this._handlers;
252
+ return this._xhandlers;
255
253
  },
256
254
  enumerable: false,
257
255
  configurable: true
258
256
  });
259
- DialogBase.prototype.addHandler = function (key, handler) {
257
+ DialogBase.prototype.appendXHandler = function (key, handler) {
260
258
  if (!key) {
261
259
  throw new Error('Handler key is required');
262
260
  }
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"));
261
+ if (typeof handler !== 'function') {
262
+ throw new Error("Handler \"".concat(key, "\" must be a function"));
266
263
  }
267
- this._handlers[key] = handler;
264
+ this._xhandlers[key] = handler;
268
265
  };
269
- DialogBase.prototype.addFeature = function (key, value) {
270
- this._features[key] = value;
271
- };
272
- DialogBase.prototype.getFeature = function (key) {
273
- return this._features[key];
266
+ Object.defineProperty(DialogBase.prototype, "xrefs", {
267
+ get: function () {
268
+ return this._xrefs;
269
+ },
270
+ enumerable: false,
271
+ configurable: true
272
+ });
273
+ DialogBase.prototype.appendXRef = function (key, ref) {
274
+ if (!key)
275
+ throw new Error('Ref key is required');
276
+ if (!(0, isRefObject_1.isRefObject)(ref))
277
+ throw new Error("Ref \"".concat(key, "\" must be a Reference RefObject"));
278
+ this._xrefs[key] = ref;
274
279
  };
275
280
  Object.defineProperty(DialogBase.prototype, "parent", {
276
281
  get: function () {
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { DialogAction } from "./DialogAction";
3
- import { TInitialHolder, IDialogSize, TDialogStateListenerCallbackType, DialogOptionsType, IDialogApiDef, TDialogCallbackVoidFn, TDialogCallbackFn, DialogHandlers, Dialogify } from "../types/index.js";
3
+ import { TInitialHolder, IDialogSize, TDialogStateListenerCallbackType, DialogOptionsType, IDialogApiDef, TDialogCallbackVoidFn, TDialogCallbackFn, DialogExternalHandlers, Dialogify, DialogExternalRefs } from "../types/index.js";
4
4
  declare class Dialog<Values extends Record<string, any>> {
5
5
  private readonly _processingListeners;
6
6
  private readonly _abortedListeners;
@@ -21,7 +21,8 @@ declare class Dialog<Values extends Record<string, any>> {
21
21
  * Fonksiyon taşıdığını net anlatıyor
22
22
  * UI / Dialog / Form bağlamında alışıldık
23
23
  * */
24
- private _handlers;
24
+ private _xhandlers;
25
+ private _xrefs;
25
26
  private _headerRef;
26
27
  private readonly _apiRef;
27
28
  private _onCloseCallback;
@@ -36,7 +37,8 @@ declare class Dialog<Values extends Record<string, any>> {
36
37
  processingListener(listener: (inProcess: boolean) => void): this;
37
38
  onAbort(callbackFn: TDialogCallbackFn<void>): this;
38
39
  initialValues<T extends Record<string, any>>(values: Dialogify<T>): Dialog<T>;
39
- handlers(handlers: DialogHandlers): this;
40
+ registerHandlers(handlers: DialogExternalHandlers): this;
41
+ registerRefs(refs: DialogExternalRefs): this;
40
42
  initialHolder(holder: TInitialHolder): this;
41
43
  keyboardListener(listener: (key: string, dialog: IDialogApiDef) => void): this;
42
44
  resizeListener(listener: (size: IDialogSize, dialog: IDialogApiDef) => void): this;
package/models/Dialog.js CHANGED
@@ -95,6 +95,7 @@ var Dialog = /** @class */ (function () {
95
95
  if (options) {
96
96
  this._dialogOptions = options;
97
97
  }
98
+ this._xrefs = {};
98
99
  }
99
100
  Dialog.prototype.setHeader = function (header) {
100
101
  this._header = header;
@@ -139,8 +140,12 @@ var Dialog = /** @class */ (function () {
139
140
  next._initialValues = values;
140
141
  return next;
141
142
  };
142
- Dialog.prototype.handlers = function (handlers) {
143
- this._handlers = handlers;
143
+ Dialog.prototype.registerHandlers = function (handlers) {
144
+ this._xhandlers = handlers;
145
+ return this;
146
+ };
147
+ Dialog.prototype.registerRefs = function (refs) {
148
+ this._xrefs = refs;
144
149
  return this;
145
150
  };
146
151
  Dialog.prototype.initialHolder = function (holder) {
@@ -171,7 +176,7 @@ var Dialog = /** @class */ (function () {
171
176
  var root = (0, client_1.createRoot)(dom);
172
177
  var props = __assign(__assign({
173
178
  // Initials
174
- initialOptions: this._dialogOptions, initialValues: this._initialValues, handlers: this._handlers, didMountCallback: callback,
179
+ initialOptions: this._dialogOptions, initialValues: this._initialValues, xhandlers: this._xhandlers, xrefs: this._xrefs, didMountCallback: callback,
175
180
  // Component contents
176
181
  header: this._header, body: this._body, actions: this._actions,
177
182
  // Refs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.105",
3
+ "version": "1.1.107",
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",
@@ -40,7 +40,8 @@ export interface BaseDialogProps<Values extends Record<string, any>> {
40
40
  didMountCallback?: TDialogCallbackVoidFn;
41
41
  dialogSize?: IDialogSize;
42
42
  stateListener: TDialogStateListenerCallbackType;
43
- handlers: DialogHandlers;
43
+ xhandlers: DialogExternalHandlers;
44
+ xrefs: DialogExternalRefs;
44
45
  initialHolder: TInitialHolder;
45
46
  snackbarAnchor?: ISnackbarAnchor;
46
47
  dom: HTMLDivElement;
@@ -148,7 +149,7 @@ export type TDialogStateListenerCallbackType = (values: FormikProps<any>['values
148
149
  export type TDialogCallbackFn<T = React.ReactNode | React.ReactElement> = (dialog: IDialogApiDef) => T;
149
150
  export type TDialogHeader = TDialogCallbackFn | React.ReactNode | React.JSX.Element;
150
151
  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' | 'addHandler'> {
152
+ export interface IDialogApiDef extends Pick<DialogBase<any>, 'isInProcess' | 'setInProcess' | 'values' | 'setValue' | 'setValues' | 'close' | 'dialogOptions' | 'actions' | 'snackbar' | 'formikValidate' | 'formikProps' | 'focus' | 'updateBody' | 'processingListener' | 'onAbort' | 'xhandlers' | 'appendXHandler' | 'xrefs' | 'appendXRef'> {
152
153
  }
153
154
  export interface IDialogCloseRef extends Pick<DialogBase<any>, 'close'> {
154
155
  }
@@ -256,10 +257,14 @@ export type DialogValues<T extends Record<string, any>> = ModelDialogValues<T>;
256
257
  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
258
  [K in keyof T]: Dialogify<T[K]>;
258
259
  } : never;
259
- export type DialogHandlerFn = ((...args: any[]) => any) | {
260
+ export type DialogExternalHandlerFn = (...args: any[]) => any;
261
+ export type DialogExternalHandlers = Record<string, DialogExternalHandlerFn>;
262
+ export type DialogExternalRef = {
260
263
  current: unknown;
261
264
  };
262
- export type DialogHandlers = Record<string, DialogHandlerFn>;
265
+ export type DialogExternalRefs = {
266
+ [key: string]: DialogExternalRef;
267
+ };
263
268
  export interface BaseDialogDOMRect {
264
269
  height?: number;
265
270
  width?: number;