react-dialogger 1.1.49 → 1.1.51

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.
@@ -42,6 +42,8 @@ declare class DialogActionBase extends Component<ActionProps, ActionState> {
42
42
  * @deprecated
43
43
  * @see use isDisabled */
44
44
  getDisabled: () => boolean;
45
+ /**
46
+ * @deprecated use Options*/
45
47
  isDisabled: () => boolean;
46
48
  setInProcess: (inProcess: boolean) => DialogActionBase;
47
49
  isInProcess: () => boolean;
@@ -121,6 +121,8 @@ var DialogActionBase = /** @class */ (function (_super) {
121
121
  _this.getDisabled = function () {
122
122
  return _this._options.disabled;
123
123
  };
124
+ /**
125
+ * @deprecated use Options*/
124
126
  _this.isDisabled = function () {
125
127
  return _this._options.disabled;
126
128
  };
@@ -63,8 +63,9 @@ declare class DialogBase<Values extends Record<string, any>> extends Component<B
63
63
  close: (callbackFn?: () => void) => void;
64
64
  focus: () => void;
65
65
  get actions(): {
66
- [key: string]: Pick<DialogActionBase, "setOptions" | "setInProcess" | "getLabel" | "options" | "click" | "remove">;
66
+ [key: string]: Pick<DialogActionBase, "setOptions" | "setInProcess" | "getLabel" | "options" | "click" | "remove" | "name">;
67
67
  };
68
+ updateBody(body: TDialogCallbackFn): void;
68
69
  getDom: () => HTMLDivElement;
69
70
  get snackbar(): {
70
71
  open: (message: string, severity: TSeverity, key?: string, action?: ((key: string, snackbarRef: any) => ReactNode | void), autoHideDuration?: number | null) => void;
@@ -150,6 +150,9 @@ var DialogBase = /** @class */ (function (_super) {
150
150
  return;
151
151
  }
152
152
  _this.kill(callbackFn);
153
+ if (typeof _this.props.onClose === "function") {
154
+ _this.props.onClose(_this);
155
+ }
153
156
  };
154
157
  _this.focus = function () {
155
158
  if (_this._dialogRef.current) {
@@ -163,13 +166,14 @@ var DialogBase = /** @class */ (function (_super) {
163
166
  console.log('this._prevDialogRect', _this.state.prevDialogRect);
164
167
  return (0, jsx_runtime_1.jsx)(_1.DialogWithBackdropWrapper, { initialValues: _this.props.initialValues, dialog: _this,
165
168
  // Component
166
- header: _this.props.header, body: _this.props.body, actions: _this.props.actions,
169
+ header: _this.props.header, body: _this.state.body, actions: _this.props.actions,
167
170
  // Refs Props
168
171
  ref: _this._dialogWithBackDropRef, dialogRef: _this._dialogRef, headerRef: _this._headerRef, bodyRef: _this._dialogBodyRef, footerRef: _this._footerRef, backdropRef: _this._backdropRef, snackbarRef: _this._snackbarRef, prevDialogRect: _this.state.prevDialogRect });
169
172
  };
170
173
  _this.state = {
171
174
  inProcess: { inProcess: false },
172
- prevDialogRect: (0, dialogRectAuto_1.dialogRectAuto)()
175
+ prevDialogRect: (0, dialogRectAuto_1.dialogRectAuto)(),
176
+ body: props.body
173
177
  };
174
178
  console.log('Class_Type', _this instanceof DialogBase);
175
179
  var defaultOptions = {
@@ -389,6 +393,10 @@ var DialogBase = /** @class */ (function (_super) {
389
393
  enumerable: false,
390
394
  configurable: true
391
395
  });
396
+ DialogBase.prototype.updateBody = function (body) {
397
+ var _this = this;
398
+ this.setState(function (prevState) { return (__assign(__assign({}, _this.state), { body: body })); });
399
+ };
392
400
  Object.defineProperty(DialogBase.prototype, "snackbar", {
393
401
  // Reference: https://notistack.com/api-reference#mutual-props
394
402
  get: function () {
@@ -20,6 +20,7 @@ declare class Dialog implements DialogProps {
20
20
  private _initialValues;
21
21
  private _headerRef;
22
22
  private readonly _apiRef;
23
+ private _onCloseCallback;
23
24
  constructor(dialogRef?: React.RefObject<IDialogApiDef | undefined | null> | null, options?: DialogOptionsType);
24
25
  setHeader(header: TDialogCallbackFn): this;
25
26
  setBody(body: TDialogCallbackFn): this;
@@ -33,6 +34,7 @@ declare class Dialog implements DialogProps {
33
34
  initialHolder(holder: TInitialHolder): this;
34
35
  keyboardListener(listener: (key: string, dialog: IDialogApiDef) => void): this;
35
36
  resizeListener(listener: (size: IDialogSize, dialog: IDialogApiDef) => void): this;
37
+ onClose(callback: TDialogCallbackVoidFn): this;
36
38
  private highestZ;
37
39
  private createDom;
38
40
  show(callback?: TDialogCallbackVoidFn): void;
package/models/Dialog.js CHANGED
@@ -135,10 +135,14 @@ var Dialog = /** @class */ (function () {
135
135
  this._resizeListener = listener;
136
136
  return this;
137
137
  };
138
+ Dialog.prototype.onClose = function (callback) {
139
+ this._onCloseCallback = callback;
140
+ return this;
141
+ };
138
142
  Dialog.prototype.show = function (callback) {
139
143
  var dom = this.createDom();
140
144
  var root = (0, client_1.createRoot)(dom);
141
- var props = __assign({
145
+ var props = __assign(__assign({
142
146
  // Initials
143
147
  initialOptions: this._dialogOptions, initialValues: this._initialValues, didMountCallback: callback,
144
148
  // Component contents
@@ -148,7 +152,7 @@ var Dialog = /** @class */ (function () {
148
152
  // Listeners
149
153
  stateListener: this._stateListener, keyboardListener: this._keyboardListener, resizeListener: this._resizeListener,
150
154
  // Others
151
- dialogSize: this._dialogSize, initialHolder: this._initialHolder, snackbarAnchor: this._snackbarAnchor, root: root, dom: dom, parent: this }, this._apiRef ? { ref: this._apiRef } : null);
155
+ dialogSize: this._dialogSize, initialHolder: this._initialHolder, snackbarAnchor: this._snackbarAnchor, root: root, dom: dom, parent: this }, this._apiRef ? { ref: this._apiRef } : null), { onClose: this._onCloseCallback });
152
156
  // @ts-ignore
153
157
  root.render(React.createElement(DialogBase_1.default, props));
154
158
  };
@@ -49,6 +49,57 @@ var DialogAction = /** @class */ (function (_super) {
49
49
  _super.prototype.onClick.call(_this, callback);
50
50
  return _this;
51
51
  };
52
+ // /**
53
+ // * @deprecated
54
+ // * @see onClickHandler */
55
+ // public getAction(): DialogActionType {
56
+ // return this._onClick;
57
+ // }
58
+ // /**
59
+ // * @deprecated
60
+ // * @see DialogActionOptionsType
61
+ // * @info Define this prop inside new DialogAction('varName', {>here<})*/
62
+ // setVariant = ( variant: TBVariant): this => {
63
+ // if( this._baseDialogAction?.dialogBaseComponent.parent.accessFrom === "internal"){
64
+ // this._baseDialogAction.setVariant(variant);
65
+ // return this;
66
+ // }
67
+ // if (this._options) {
68
+ // this._options.variant = variant; // _options'ın başlatıldığını varsayarak erişim
69
+ // } else {
70
+ // console.error('DialogAction _options is not initialized');
71
+ // }
72
+ // return this;
73
+ // }
74
+ // getVariant = (): TBVariant => {
75
+ // if( this._baseDialogAction?.dialogBaseComponent.parent.accessFrom === "internal"){
76
+ // return this._baseDialogAction.getVariant();
77
+ // }
78
+ // return this._options.variant;
79
+ // }
80
+ // /**
81
+ // * @deprecated
82
+ // * @see DialogActionOptionsType
83
+ // * @info Define this prop inside new DialogAction('varName', {>here<})*/
84
+ // setColor = ( color: TBColor): this => {
85
+ // if( this._baseDialogAction?.dialogBaseComponent.parent.accessFrom === "internal"){
86
+ // this._baseDialogAction.setColor(color);
87
+ // return this;
88
+ // }
89
+ // if (this._options) {
90
+ // this._options.color = color; // _options'ın başlatıldığını varsayarak erişim
91
+ // } else {
92
+ // console.error('DialogAction _options is not initialized');
93
+ // }
94
+ // return this;
95
+ // }
96
+ //
97
+ // getColor = (): TBColor => {
98
+ // if( this._baseDialogAction?.dialogBaseComponent.parent.accessFrom === "internal"){
99
+ // return this._baseDialogAction.getColor();
100
+ // }
101
+ // return this._options.color;
102
+ // }
52
103
  /**
53
104
  * Only from init */
54
105
  _this.stateListener = function (listener) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.49",
3
+ "version": "1.1.51",
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",
@@ -6,8 +6,8 @@ import { CSSProperties } from "react";
6
6
  import * as React from "react";
7
7
  import { DialogAction } from "../models";
8
8
  export type ActionDialogDef = Omit<IDialogApiDef, 'switchFullScreen'>;
9
- export type ActionDef = Pick<DialogAction, 'onClick' | 'setInProcess' | 'getLabel' | 'getColor' | 'getVariant' | 'isDisabled' | 'setOptions' | 'isInProcess' | 'setLabel' | 'name'>;
10
- export type ActionBaseDef = Pick<DialogActionBase, 'setOptions' | 'setInProcess' | 'getLabel' | 'options' | 'click' | 'remove'>;
9
+ export type ActionDef = Pick<DialogAction, 'onClick' | 'setOptions' | 'name'>;
10
+ export type ActionBaseDef = Pick<DialogActionBase, 'setOptions' | 'setInProcess' | 'getLabel' | 'options' | 'click' | 'remove' | 'name'>;
11
11
  export interface IDialogActionDef extends ActionBaseDef {
12
12
  }
13
13
  export type DialogActionType = (button: ActionBaseDef, dialog: Omit<IDialogApiDef, 'switchFullScreen'>) => void;
@@ -18,6 +18,7 @@ export interface BaseDialogState {
18
18
  inProcess: IInProcess;
19
19
  fullscreenMode?: boolean;
20
20
  prevDialogRect: WithBackdrop['prevDialogRect'];
21
+ body: TDialogCallbackFn;
21
22
  }
22
23
  export interface BaseDialogProps {
23
24
  initialOptions?: DialogOptionsType;
@@ -125,7 +126,7 @@ export type TDialogStateListenerCallbackType = (values: FormikProps<any>['values
125
126
  export type TDialogCallbackFn<T = React.ReactNode> = (dialog: IDialogApiDef) => T;
126
127
  export type TDialogHeader = TDialogCallbackFn | React.ReactNode | React.JSX.Element;
127
128
  export type TDialogCallbackVoidFn = TDialogCallbackFn<void>;
128
- export interface IDialogApiDef extends Pick<DialogBase<any>, 'isInProcess' | 'setInProcess' | 'values' | 'setValue' | 'setValues' | 'close' | 'dialogOptions' | 'actions' | 'snackbar' | 'formikValidate' | 'formikProps' | 'focus'> {
129
+ export interface IDialogApiDef extends Pick<DialogBase<any>, 'isInProcess' | 'setInProcess' | 'values' | 'setValue' | 'setValues' | 'close' | 'dialogOptions' | 'actions' | 'snackbar' | 'formikValidate' | 'formikProps' | 'focus' | 'updateBody'> {
129
130
  }
130
131
  export interface IDialogCloseRef extends Pick<DialogBase<any>, 'close'> {
131
132
  }