react-dialogger 1.1.109 → 1.1.111

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.
@@ -2,6 +2,6 @@ import { DialogAction } from "../models/index.js";
2
2
  import { DialogBase } from "./index.js";
3
3
  declare const Actions: ({ actions, dialog }: {
4
4
  actions?: DialogAction[];
5
- dialog: DialogBase<any>;
5
+ dialog: DialogBase<any, any, any>;
6
6
  }) => import("react/jsx-runtime").JSX.Element;
7
7
  export { Actions };
@@ -16,7 +16,7 @@ export declare const BASE_INTENTS: {
16
16
  };
17
17
  };
18
18
  declare class DialogActionBase extends Component<ActionProps, ActionState> {
19
- get dialogBaseComponent(): DialogBase<any>;
19
+ get dialogBaseComponent(): DialogBase<any, any, any>;
20
20
  protected _options: DialogActionOptionsType;
21
21
  protected _intent: ActionIntent;
22
22
  _stateListener: TDialogStateListenerForActionCallbackType;
@@ -1,12 +1,11 @@
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, DialogExternalHandlers, DialogExternalHandlerFn, Dialogify, DialogExternalRefs, DialogExternalRef } from "../types/index.js";
4
+ import { BaseDialogProps, BaseDialogState, IDialogSize, DialogOptionsType, TDialogCallbackFn, TDialogCallbackVoidFn, WithBackdrop, IDialogSnackbar, IInProcess, TInitialHolder, ISnackbarAnchor, TSeverity, TAccessFrom, ActionApiDef, DialogContentFooterReturnType, DialogFormikAdapter, DialogExternalHandlers, DialogExternalHandler, 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
- declare class DialogBase<Values extends Record<string, any>> extends Component<BaseDialogProps<Values>, BaseDialogState> {
9
- protected _initialValues: Dialogify<Values>;
8
+ declare class DialogBase<Values extends Record<string, any>, StockDialogHandlers extends Record<string, DialogExternalHandler> = {}, StockDialogRefs extends Record<string, DialogExternalRef> = {}> extends Component<BaseDialogProps<Values, StockDialogHandlers, StockDialogRefs>, BaseDialogState> {
10
9
  _dialogTranslate: {
11
10
  lastX: number;
12
11
  lastY: number;
@@ -29,9 +28,10 @@ declare class DialogBase<Values extends Record<string, any>> extends Component<B
29
28
  protected _onClose: TDialogCallbackVoidFn;
30
29
  protected _shInterval: number;
31
30
  protected _snackbarAnchor: ISnackbarAnchor;
32
- protected _parent: Dialog<Values>;
33
- protected _xhandlers: DialogExternalHandlers;
34
- protected _xrefs: DialogExternalRefs;
31
+ protected _parent: Dialog<Values, StockDialogHandlers, StockDialogRefs>;
32
+ protected _xhandlers: DialogExternalHandlers<StockDialogHandlers>;
33
+ protected _xrefs: DialogExternalRefs<StockDialogRefs>;
34
+ protected _initialValues: Dialogify<Values>;
35
35
  private _inProcess;
36
36
  private _footerRef;
37
37
  protected _headerRef: RefObject<DialogContentFooterReturnType>;
@@ -39,14 +39,15 @@ declare class DialogBase<Values extends Record<string, any>> extends Component<B
39
39
  private _accessFrom;
40
40
  private readonly _processingListeners;
41
41
  private readonly _abortedListeners;
42
- constructor(props: BaseDialogProps<Values> & {
43
- parent: Dialog<Values>;
42
+ constructor(props: BaseDialogProps<Values, StockDialogHandlers, StockDialogRefs> & {
43
+ parent: Dialog<Values, StockDialogHandlers, StockDialogRefs>;
44
44
  });
45
- get xhandlers(): DialogExternalHandlers;
46
- appendXHandler(key: string, handler: DialogExternalHandlerFn): void;
47
- get xrefs(): DialogExternalRefs;
48
- appendXRef(key: string, ref: DialogExternalRef): void;
49
- get parent(): Dialog<Values>;
45
+ setValue<T>(key: string, value: Dialogify<T>): void;
46
+ get xhandlers(): StockDialogHandlers;
47
+ appendXHandler<H>(key: string, handler: DialogExternalHandler): void;
48
+ get xrefs(): DialogExternalRefs<DialogExternalRef>;
49
+ appendXRef<R>(key: R, ref: DialogExternalRef): void;
50
+ get parent(): Dialog<Values, StockDialogHandlers, StockDialogRefs>;
50
51
  get dialogTranslate(): {
51
52
  lastX: number;
52
53
  lastY: number;
@@ -61,7 +62,6 @@ declare class DialogBase<Values extends Record<string, any>> extends Component<B
61
62
  get formikValidate(): Promise<DialogFormikAdapter<any>>;
62
63
  set inlineFormikProps(inlineFormikProps: IFormikAdapter);
63
64
  get values(): Values;
64
- setValue<T>(key: string, value: Dialogify<T>): void;
65
65
  setValues<T>(values: Dialogify<T>, callbackFn?: () => void): void;
66
66
  componentDidMount(): void;
67
67
  setInProcess: (process: boolean, message?: string, holder?: TInitialHolder) => this;
@@ -238,33 +238,39 @@ var DialogBase = /** @class */ (function (_super) {
238
238
  _this._holder = props.initialHolder;
239
239
  // Initialize _actionRefs as an empty object
240
240
  _this._actionRefs = {};
241
- _this._initialValues = props.initialValues;
242
241
  _this._parent = props.parent;
243
242
  _this._dialogWithBackDropRef = (0, react_1.createRef)();
244
243
  _this._processingListeners = (_a = props.processingListeners) !== null && _a !== void 0 ? _a : [];
245
244
  _this._abortedListeners = (_b = props.abortedListeners) !== null && _b !== void 0 ? _b : [];
245
+ _this._initialValues = props.initialValues;
246
246
  _this._xhandlers = props.xhandlers;
247
+ _this._xrefs = props.xrefs;
247
248
  return _this;
248
- // this._externalRefs = props.externalRefs;
249
249
  }
250
+ DialogBase.prototype.setValue = function (key, value) {
251
+ var _a;
252
+ (_a = this._inlineFormikProps) === null || _a === void 0 ? void 0 : _a.setFieldValue(key, value);
253
+ };
250
254
  Object.defineProperty(DialogBase.prototype, "xhandlers", {
251
255
  get: function () {
256
+ // @ts-ignore
252
257
  return this._xhandlers;
253
258
  },
254
259
  enumerable: false,
255
260
  configurable: true
256
261
  });
257
262
  DialogBase.prototype.appendXHandler = function (key, handler) {
258
- if (!key) {
263
+ // public appendXHandler(key: string, handler: DialogExternalHandler) {
264
+ if (!key)
259
265
  throw new Error('Handler key is required');
260
- }
261
- if (typeof handler !== 'function') {
262
- throw new Error("Handler \"".concat(key, "\" must be a function"));
263
- }
266
+ if (typeof handler !== 'function')
267
+ throw new Error("Handler \"".concat(String(key), "\" must be a function"));
268
+ // @ts-ignore
264
269
  this._xhandlers[key] = handler;
265
270
  };
266
271
  Object.defineProperty(DialogBase.prototype, "xrefs", {
267
272
  get: function () {
273
+ // @ts-ignore
268
274
  return this._xrefs;
269
275
  },
270
276
  enumerable: false,
@@ -274,7 +280,8 @@ var DialogBase = /** @class */ (function (_super) {
274
280
  if (!key)
275
281
  throw new Error('Ref key is required');
276
282
  if (!(0, isRefObject_1.isRefObject)(ref))
277
- throw new Error("Ref \"".concat(key, "\" must be a Reference RefObject"));
283
+ throw new Error("Ref \"".concat(String(key), "\" must be a Reference RefObject"));
284
+ // @ts-ignore
278
285
  this._xrefs[key] = ref;
279
286
  };
280
287
  Object.defineProperty(DialogBase.prototype, "parent", {
@@ -360,10 +367,6 @@ var DialogBase = /** @class */ (function (_super) {
360
367
  enumerable: false,
361
368
  configurable: true
362
369
  });
363
- DialogBase.prototype.setValue = function (key, value) {
364
- var _a;
365
- (_a = this._inlineFormikProps) === null || _a === void 0 ? void 0 : _a.setFieldValue(key, value);
366
- };
367
370
  DialogBase.prototype.setValues = function (values, callbackFn) {
368
371
  this._inlineFormikProps.setValues(values);
369
372
  if (typeof callbackFn === "function") {
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { DialogAction } from "./DialogAction";
3
3
  import { TInitialHolder, IDialogSize, TDialogStateListenerCallbackType, DialogOptionsType, IDialogApiDef, TDialogCallbackVoidFn, TDialogCallbackFn, DialogExternalHandlers, Dialogify, DialogExternalRefs } from "../types/index.js";
4
- declare class Dialog<Values extends Record<string, any>> {
4
+ declare class Dialog<Values extends Record<string, any>, StockDialogHandlers extends Record<string, any> = {}, StockDialogRefs extends Record<string, any> = {}> {
5
5
  private readonly _processingListeners;
6
6
  private readonly _abortedListeners;
7
7
  private _stateListener;
@@ -14,18 +14,18 @@ declare class Dialog<Values extends Record<string, any>> {
14
14
  private _dialogSize;
15
15
  private readonly _dialogOptions?;
16
16
  private _snackbarAnchor;
17
- private _initialValues;
18
17
  /**
19
18
  * Move Fucntions
20
19
  * behavior
21
20
  * Fonksiyon taşıdığını net anlatıyor
22
21
  * UI / Dialog / Form bağlamında alışıldık
23
22
  * */
24
- private _xhandlers;
25
- private _xrefs;
26
23
  private _headerRef;
27
24
  private readonly _apiRef;
28
25
  private _onCloseCallback;
26
+ private _initialValues;
27
+ private _xhandlers;
28
+ private _xrefs;
29
29
  constructor(dialogRef?: React.RefObject<IDialogApiDef | undefined | null> | null, options?: DialogOptionsType);
30
30
  setHeader(header: TDialogCallbackFn): this;
31
31
  setBody(body: TDialogCallbackFn): this;
@@ -36,9 +36,9 @@ declare class Dialog<Values extends Record<string, any>> {
36
36
  stateListener(listener: TDialogStateListenerCallbackType): this;
37
37
  processingListener(listener: (inProcess: boolean) => void): this;
38
38
  onAbort(callbackFn: TDialogCallbackFn<void>): this;
39
- initialValues<T extends Record<string, any>>(values: Dialogify<T>): Dialog<T>;
40
- registerHandlers(handlers: DialogExternalHandlers): this;
41
- registerRefs(refs: DialogExternalRefs): this;
39
+ initialValues<T extends Record<string, any>>(values: Dialogify<T>): Dialog<T, any, any>;
40
+ registerHandlers<H extends StockDialogHandlers>(handlers: DialogExternalHandlers<H>): Dialog<any, H, any>;
41
+ registerRefs<R extends StockDialogRefs>(refs: DialogExternalRefs<R>): Dialog<any, any, R>;
42
42
  initialHolder(holder: TInitialHolder): this;
43
43
  keyboardListener(listener: (key: string, dialog: IDialogApiDef) => void): this;
44
44
  resizeListener(listener: (size: IDialogSize, dialog: IDialogApiDef) => void): this;
package/models/Dialog.js CHANGED
@@ -57,6 +57,13 @@ var Dialog = /** @class */ (function () {
57
57
  // ✨✨✨✨✨✨✨✨✨✨✨
58
58
  this._processingListeners = [];
59
59
  this._abortedListeners = [];
60
+ // private _initialValues :DialogValues<Values>;
61
+ /**
62
+ * Move Fucntions
63
+ * behavior
64
+ * Fonksiyon taşıdığını net anlatıyor
65
+ * UI / Dialog / Form bağlamında alışıldık
66
+ * */
60
67
  this._headerRef = React.createRef();
61
68
  this.highestZ = function () {
62
69
  var presentationElements = document.querySelectorAll('div[data-family="presentation"]');
@@ -95,7 +102,7 @@ var Dialog = /** @class */ (function () {
95
102
  if (options) {
96
103
  this._dialogOptions = options;
97
104
  }
98
- this._xrefs = {};
105
+ // this._xrefs = {} as DialogExternalRefs<StockDialogRefs>;
99
106
  }
100
107
  Dialog.prototype.setHeader = function (header) {
101
108
  this._header = header;
@@ -141,12 +148,16 @@ var Dialog = /** @class */ (function () {
141
148
  return next;
142
149
  };
143
150
  Dialog.prototype.registerHandlers = function (handlers) {
151
+ // this._xhandlers = handlers;
152
+ // return this;
153
+ var next = this;
144
154
  this._xhandlers = handlers;
145
- return this;
155
+ return next;
146
156
  };
147
157
  Dialog.prototype.registerRefs = function (refs) {
158
+ var next = this;
148
159
  this._xrefs = refs;
149
- return this;
160
+ return next;
150
161
  };
151
162
  Dialog.prototype.initialHolder = function (holder) {
152
163
  this._initialHolder = holder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.109",
3
+ "version": "1.1.111",
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",
@@ -17,7 +17,7 @@ export interface ActionProps {
17
17
  * @see options.label */
18
18
  label?: string;
19
19
  onClick: DialogActionType;
20
- dialogBaseComponent?: DialogBase<any>;
20
+ dialogBaseComponent?: DialogBase<any, any, any>;
21
21
  /**
22
22
  * @deprecated
23
23
  * @see options.variant */
@@ -4,7 +4,7 @@ import { ReactNode, RefObject } from "react";
4
4
  import { BaseDialogDOMRect } from "./index.js";
5
5
  import { Resizeable } from "../helpers/index.js";
6
6
  export interface DialogContentContextProviderProps {
7
- dialogBase: DialogBase<any>;
7
+ dialogBase: DialogBase<any, any, any>;
8
8
  body: TDialogCallbackFn<ReturnType<any>>;
9
9
  dialogRef: RefObject<any>;
10
10
  headerRef: RefObject<any>;
@@ -17,6 +17,6 @@ export interface DialogContentContextProviderProps {
17
17
  }
18
18
  export interface DialogContentContextProviderSharedProps extends Partial<Pick<DialogContentContextProviderProps, 'body' | 'dialogRef' | 'headerRef' | 'bodyRef' | 'footerRef' | 'backdropRef' | 'snackbarRef' | 'prevDialogRect'>> {
19
19
  baseZoomEffect: () => void;
20
- dialog: DialogBase<any>;
20
+ dialog: DialogBase<any, any, any>;
21
21
  resizeableObject: Resizeable | null;
22
22
  }
@@ -31,7 +31,7 @@ export interface DialogFormikAdapter<Values> extends Omit<FormikProps<any>, 'val
31
31
  validateForm(): Promise<any>;
32
32
  errors: any;
33
33
  }
34
- export interface BaseDialogProps<Values extends Record<string, any>> {
34
+ export interface BaseDialogProps<Values extends Record<string, any>, StockDialogHandlers extends Record<string, any>, StockDialogRefs extends Record<string, any>> {
35
35
  initialValues: Dialogify<Values>;
36
36
  initialOptions?: DialogOptionsType;
37
37
  body: TDialogCallbackFn;
@@ -40,8 +40,8 @@ export interface BaseDialogProps<Values extends Record<string, any>> {
40
40
  didMountCallback?: TDialogCallbackVoidFn;
41
41
  dialogSize?: IDialogSize;
42
42
  stateListener: TDialogStateListenerCallbackType;
43
- xhandlers: DialogExternalHandlers;
44
- xrefs: DialogExternalRefs;
43
+ xhandlers: DialogExternalHandlers<StockDialogHandlers>;
44
+ xrefs: DialogExternalRefs<StockDialogRefs>;
45
45
  initialHolder: TInitialHolder;
46
46
  snackbarAnchor?: ISnackbarAnchor;
47
47
  dom: HTMLDivElement;
@@ -149,9 +149,7 @@ export type TDialogStateListenerCallbackType = (values: FormikProps<any>['values
149
149
  export type TDialogCallbackFn<T = React.ReactNode | React.ReactElement> = (dialog: IDialogApiDef) => T;
150
150
  export type TDialogHeader = TDialogCallbackFn | React.ReactNode | React.JSX.Element;
151
151
  export type TDialogCallbackVoidFn = TDialogCallbackFn<void>;
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'> {
153
- }
154
- export interface IDialogCloseRef extends Pick<DialogBase<any>, 'close'> {
152
+ export interface IDialogApiDef extends Pick<DialogBase<any, any, any>, 'isInProcess' | 'setInProcess' | 'values' | 'setValue' | 'setValues' | 'close' | 'dialogOptions' | 'actions' | 'snackbar' | 'formikValidate' | 'formikProps' | 'focus' | 'updateBody' | 'processingListener' | 'onAbort' | 'xhandlers' | 'appendXHandler' | 'xrefs' | 'appendXRef'> {
155
153
  }
156
154
  interface OpenArgs {
157
155
  message: any;
@@ -178,7 +176,7 @@ export interface WithBackdrop {
178
176
  body: TDialogCallbackFn;
179
177
  header: TDialogCallbackFn;
180
178
  actions?: DialogAction[];
181
- dialog: DialogBase<any>;
179
+ dialog: DialogBase<any, any, any>;
182
180
  backdropRef: RefObject<any>;
183
181
  initialValues: Partial<Record<string, any>>;
184
182
  dialogRef: RefObject<any>;
@@ -205,7 +203,7 @@ export interface IContentProps {
205
203
  footerRef: React.RefObject<DialogContentFooterReturnType>;
206
204
  backdropRef: React.RefObject<any>;
207
205
  dialogOptions: DialogOptionsType;
208
- dialog: DialogBase<any>;
206
+ dialog: DialogBase<any, any, any>;
209
207
  resizeableObject?: Resizeable | null;
210
208
  prevDialogRect: WithBackdrop['prevDialogRect'];
211
209
  snackbarRef: WithBackdrop['snackbarRef'];
@@ -254,17 +252,23 @@ export type ModelDialogValues<T> = {
254
252
  [K in keyof T]: DialogValue<T>;
255
253
  };
256
254
  export type DialogValues<T extends Record<string, any>> = ModelDialogValues<T>;
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 ? {
255
+ export type Dialogify<T> = T extends Function ? never : T extends {
256
+ current: null;
257
+ } ? never : T extends string | number | boolean | null | undefined | Date ? T : T extends Array<infer U> ? Dialogify<U>[] : T extends object ? {
258
258
  [K in keyof T]: Dialogify<T[K]>;
259
259
  } : never;
260
- export type DialogExternalHandlerFn = ((...args: any[]) => any) | unknown;
261
- export type DialogExternalHandlers = Record<string, DialogExternalHandlerFn>;
262
- export type DialogExternalRef<T = unknown> = {
263
- current: T | null;
264
- };
265
- export type DialogExternalRefs = {
266
- [key: string]: DialogExternalRef;
260
+ export type DialogExternalHandler = (...args: any[]) => any;
261
+ export type DialogExternalHandlers<T> = T extends (...args: any[]) => any ? DialogExternalHandler : T extends object ? {
262
+ [K in keyof T]: DialogExternalHandlers<T[K]>;
263
+ } : never;
264
+ export type DialogExternalRef = {
265
+ current: null;
267
266
  };
267
+ export type DialogExternalRefs<T> = T extends {
268
+ current: null;
269
+ } ? DialogExternalRef : T extends object ? {
270
+ [K in keyof T]: DialogExternalRefs<T[K]>;
271
+ } : never;
268
272
  export interface BaseDialogDOMRect {
269
273
  height?: number;
270
274
  width?: number;
@@ -288,6 +292,6 @@ export interface ICoords {
288
292
  y: number;
289
293
  }
290
294
  export interface DialogProps {
291
- setHeader(header: TDialogCallbackFn): Dialog<Record<string, any>>;
295
+ setHeader(header: TDialogCallbackFn): Dialog<any, any, any>;
292
296
  }
293
297
  export {};
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import { DialogBase } from "../components/index.js";
3
3
  import { Resizeable } from "../helpers/index.js";
4
- declare const resizeManager: (dialogRef: React.RefObject<HTMLDivElement>, dialog: DialogBase<any>) => Resizeable | null;
4
+ declare const resizeManager: (dialogRef: React.RefObject<HTMLDivElement>, dialog: DialogBase<any, any, any>) => Resizeable | null;
5
5
  export { resizeManager };