react-dialogger 1.1.51 → 1.1.53

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.
@@ -10,8 +10,9 @@ var Actions = function (_a) {
10
10
  var actions = _a.actions, dialog = _a.dialog;
11
11
  var dialogOptions = dialog.dialogOptions;
12
12
  return (0, jsx_runtime_1.jsx)("div", { style: { position: 'relative', display: 'flex', flexDirection: 'row', columnGap: 10, alignItems: 'center' }, children: actions.map(function (action, index) {
13
+ console.log('Actions_action', action, action.getIntent());
13
14
  var referencedAction = dialog.initializeActionRef(action.name);
14
- return (0, jsx_runtime_1.jsx)(DialogActionBase_1.default, { name: action.name, ref: referencedAction, dialogBaseComponent: dialog, options: action.options, onClick: action.onClickHandler(), inProcess: action.isInProcess(), style: action.options.style, baseStyle: dialogOptions.base.actions.baseStyle, fontFamily: dialogOptions.base.style.fontFamily, stateListener: action._stateListener }, index.toString());
15
+ return (0, jsx_runtime_1.jsx)(DialogActionBase_1.default, { name: action.name, ref: referencedAction, dialogBaseComponent: dialog, options: action.options, onClick: action.onClickHandler(), inProcess: action.isInProcess(), style: action.options.style, baseStyle: dialogOptions.base.actions.baseStyle, fontFamily: dialogOptions.base.style.fontFamily, stateListener: action._stateListener, intent: action.getIntent() }, index.toString());
15
16
  }) });
16
17
  };
17
18
  exports.Actions = Actions;
@@ -1,9 +1,10 @@
1
1
  import { Component } from "react";
2
2
  import DialogBase from "./DialogBase";
3
- import { ActionProps, ActionState, DialogActionType, TBVariant, TBColor, DialogActionOptionsType, TDialogStateListenerForActionCallbackType } from "../types/DialogActionTypes";
3
+ import { ActionProps, ActionState, DialogActionType, TBVariant, TBColor, DialogActionOptionsType, TDialogStateListenerForActionCallbackType, ActionIntent } from "../types/DialogActionTypes";
4
4
  declare class DialogActionBase extends Component<ActionProps, ActionState> {
5
5
  get dialogBaseComponent(): DialogBase<any>;
6
6
  protected _options: DialogActionOptionsType;
7
+ protected _intent: ActionIntent;
7
8
  _stateListener: TDialogStateListenerForActionCallbackType;
8
9
  protected _baseDialogAction?: DialogActionBase;
9
10
  protected _name: string;
@@ -18,20 +19,20 @@ declare class DialogActionBase extends Component<ActionProps, ActionState> {
18
19
  componentDidMount(): void;
19
20
  get baseDialogAction(): DialogActionBase;
20
21
  getInitialClickHandler: () => DialogActionType;
21
- setOptions(options: DialogActionOptionsType): this;
22
+ updateOptions(options: DialogActionOptionsType): this;
22
23
  get options(): DialogActionOptionsType;
23
- setLabel: (label: string) => DialogActionBase;
24
+ updateLabel: (label: string) => DialogActionBase;
24
25
  getLabel(): string;
25
26
  protected onClick(callback: DialogActionType): DialogActionBase;
26
27
  /**
27
28
  * @deprecated use Options*/
28
- setVariant: (variant: TBVariant) => DialogActionBase;
29
+ updateVariant: (variant: TBVariant) => DialogActionBase;
29
30
  /**
30
31
  * @deprecated use Options*/
31
32
  getVariant: () => TBVariant;
32
33
  /**
33
34
  * @deprecated use Options*/
34
- setColor: (color: TBColor) => DialogActionBase;
35
+ updateColor: (color: TBColor) => DialogActionBase;
35
36
  /**
36
37
  * @deprecated use Options*/
37
38
  getColor: () => TBColor;
@@ -45,6 +46,7 @@ declare class DialogActionBase extends Component<ActionProps, ActionState> {
45
46
  /**
46
47
  * @deprecated use Options*/
47
48
  isDisabled: () => boolean;
49
+ updateIntent: (intent: ActionIntent) => DialogActionBase;
48
50
  setInProcess: (inProcess: boolean) => DialogActionBase;
49
51
  isInProcess: () => boolean;
50
52
  remove: () => void;
@@ -75,17 +75,18 @@ var DialogActionBase = /** @class */ (function (_super) {
75
75
  disabled: false,
76
76
  prevDisabled: false
77
77
  };
78
+ _this._intent = null; // {color: "primary", variant: 'contained'};
78
79
  _this.getInitialClickHandler = function () {
79
80
  return _this._initialClickHandler;
80
81
  };
81
- _this.setLabel = function (label) {
82
+ _this.updateLabel = function (label) {
82
83
  _this._options.label = label;
83
84
  _this.forceUpdate();
84
85
  return _this;
85
86
  };
86
87
  /**
87
88
  * @deprecated use Options*/
88
- _this.setVariant = function (variant) {
89
+ _this.updateVariant = function (variant) {
89
90
  _this._options.variant = variant;
90
91
  _this.forceUpdate();
91
92
  return _this;
@@ -97,7 +98,7 @@ var DialogActionBase = /** @class */ (function (_super) {
97
98
  };
98
99
  /**
99
100
  * @deprecated use Options*/
100
- _this.setColor = function (color) {
101
+ _this.updateColor = function (color) {
101
102
  // this._color = color;
102
103
  _this._options.color = color;
103
104
  _this.forceUpdate();
@@ -126,6 +127,10 @@ var DialogActionBase = /** @class */ (function (_super) {
126
127
  _this.isDisabled = function () {
127
128
  return _this._options.disabled;
128
129
  };
130
+ _this.updateIntent = function (intent) {
131
+ _this.setState(function (prevState) { return (__assign(__assign({}, _this.state), { intent: intent })); });
132
+ return _this;
133
+ };
129
134
  _this.setInProcess = function (inProcess) {
130
135
  _this._inProcess = inProcess;
131
136
  _this._options.disabled = inProcess;
@@ -147,8 +152,16 @@ var DialogActionBase = /** @class */ (function (_super) {
147
152
  return _this._onClick;
148
153
  };
149
154
  _this.render = function () {
150
- console.log('this._options.style.render', _this._options);
151
- return (0, jsx_runtime_1.jsx)(index_1.RippleButton, { ref: _this._buttonRef, innerRef: _this._rippleButtonRef, variant: _this._options.variant, color: _this._options.color, disabled: _this._options.disabled, onClick: function (e) {
155
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
156
+ console.log('Dialog_Action_Base_render', _this._options, _this._intent);
157
+ // Set as default converted from action name prop
158
+ var converted = (_b = (_a = _this.props.name) === null || _a === void 0 ? void 0 : _a.replace(/action/i, '')) !== null && _b !== void 0 ? _b : _this.props.name;
159
+ _this._options.label = (_g = ((_f = (_e = (_d = (_c = _this.props.dialogBaseComponent) === null || _c === void 0 ? void 0 : _c.dialogOptions) === null || _d === void 0 ? void 0 : _d.localText) === null || _e === void 0 ? void 0 : _e[converted]) !== null && _f !== void 0 ? _f : converted)) !== null && _g !== void 0 ? _g : 'Button';
160
+ return (0, jsx_runtime_1.jsx)(index_1.RippleButton, { ref: _this._buttonRef, innerRef: _this._rippleButtonRef,
161
+ // Intent Based
162
+ variant: (_k = (_j = (_h = _this.state) === null || _h === void 0 ? void 0 : _h.intent) === null || _j === void 0 ? void 0 : _j.variant) !== null && _k !== void 0 ? _k : _this._options.variant,
163
+ // Intent Based
164
+ color: (_o = (_m = (_l = _this.state) === null || _l === void 0 ? void 0 : _l.intent) === null || _m === void 0 ? void 0 : _m.color) !== null && _o !== void 0 ? _o : _this._options.color, disabled: _this._options.disabled, onClick: function (e) {
152
165
  if (_this._options.disabled || _this.isInProcess())
153
166
  return;
154
167
  // @ts-ignore
@@ -159,8 +172,16 @@ var DialogActionBase = /** @class */ (function (_super) {
159
172
  buttonRef.style.minWidth = buttonRef.getBoundingClientRect().width + 'px';
160
173
  }
161
174
  }
175
+ /**
176
+ * 🎯 Amaç:
177
+ * action veya Action kelimesini silmek
178
+ * this.props.name.replace(/action/i, '');
179
+ * /action/ → kelime
180
+ * i → case-insensitive
181
+ * Daha temiz, daha kısa
182
+ */
162
183
  return (0, jsx_runtime_1.jsxs)(React.Fragment, { children: [(0, jsx_runtime_1.jsx)(index_1.CircularProgress, { size: 15, inProcess: { inProcess: _this.isInProcess() } }), !_this.isInProcess() &&
163
- _this._options.label] });
184
+ _this.options.label] });
164
185
  } });
165
186
  };
166
187
  _this._options = props.options;
@@ -172,7 +193,8 @@ var DialogActionBase = /** @class */ (function (_super) {
172
193
  _this._inProcess = props.inProcess;
173
194
  _this.state = {
174
195
  coords: { x: -1, y: -1 },
175
- isRippling: false
196
+ isRippling: false,
197
+ intent: props.intent
176
198
  };
177
199
  _this._buttonRef = React.createRef();
178
200
  _this._rippleButtonRef = React.createRef();
@@ -208,9 +230,7 @@ var DialogActionBase = /** @class */ (function (_super) {
208
230
  enumerable: false,
209
231
  configurable: true
210
232
  });
211
- DialogActionBase.prototype.setOptions = function (options) {
212
- console.log(23);
213
- console.log('setOptions-XAA', JSON.stringify(options));
233
+ DialogActionBase.prototype.updateOptions = function (options) {
214
234
  this._options = __assign(__assign({}, this._options), options);
215
235
  this.forceUpdate();
216
236
  return this;
@@ -7,6 +7,7 @@ import { DialogContentFooterReturnType } from "../types/DialogActionTypes";
7
7
  import Dialog, { DialogAction } from "../index";
8
8
  interface IFormikAdapter extends Pick<FormikProps<any>, 'setValues' | 'setFieldValue' | 'values'> {
9
9
  }
10
+ type FeatureType = Partial<Record<string, any>>;
10
11
  declare class DialogBase<Values extends Record<string, any>> extends Component<BaseDialogProps, BaseDialogState> {
11
12
  _dialogTranslate: {
12
13
  lastX: number;
@@ -15,7 +16,6 @@ declare class DialogBase<Values extends Record<string, any>> extends Component<B
15
16
  readonly _actionRefs: {
16
17
  [key: string]: RefObject<DialogActionBase>;
17
18
  };
18
- private _keyboardListener;
19
19
  protected _inlineFormikProps: IFormikAdapter;
20
20
  protected _header: TDialogCallbackFn;
21
21
  protected _body: TDialogCallbackFn;
@@ -38,7 +38,12 @@ declare class DialogBase<Values extends Record<string, any>> extends Component<B
38
38
  private readonly _dialogWithBackDropRef;
39
39
  protected readonly _parent: Dialog;
40
40
  private _accessFrom;
41
+ private _processingListener;
41
42
  constructor(props?: Readonly<BaseDialogProps>);
43
+ private T;
44
+ private readonly _features;
45
+ addFeature(key: string, value: any): void;
46
+ getFeature(key: string): FeatureType;
42
47
  get parent(): Dialog;
43
48
  get dialogTranslate(): {
44
49
  lastX: number;
@@ -63,9 +68,10 @@ declare class DialogBase<Values extends Record<string, any>> extends Component<B
63
68
  close: (callbackFn?: () => void) => void;
64
69
  focus: () => void;
65
70
  get actions(): {
66
- [key: string]: Pick<DialogActionBase, "setOptions" | "setInProcess" | "getLabel" | "options" | "click" | "remove" | "name">;
71
+ [key: string]: Pick<DialogActionBase, "updateOptions" | "setInProcess" | "getLabel" | "options" | "click" | "remove" | "name">;
67
72
  };
68
73
  updateBody(body: TDialogCallbackFn): void;
74
+ processingListener(listener: (inProcess: boolean) => void): this;
69
75
  getDom: () => HTMLDivElement;
70
76
  get snackbar(): {
71
77
  open: (message: string, severity: TSeverity, key?: string, action?: ((key: string, snackbarRef: any) => ReactNode | void), autoHideDuration?: number | null) => void;
@@ -58,15 +58,17 @@ var __importStar = (this && this.__importStar) || (function () {
58
58
  return result;
59
59
  };
60
60
  })();
61
+ var __importDefault = (this && this.__importDefault) || function (mod) {
62
+ return (mod && mod.__esModule) ? mod : { "default": mod };
63
+ };
61
64
  Object.defineProperty(exports, "__esModule", { value: true });
62
65
  var jsx_runtime_1 = require("react/jsx-runtime");
63
66
  var react_1 = require("react");
64
67
  var React = __importStar(require("react"));
65
68
  var lodash_1 = require("lodash");
66
69
  var _1 = require("./");
67
- // Bounds methods
68
- var helpers_1 = require("../helpers");
69
70
  var dialogRectAuto_1 = require("../helpers/dialogRectAuto");
71
+ var DialogContentContextProvider_1 = __importDefault(require("../context/DialogContentContextProvider"));
70
72
  var DialogBase = /** @class */ (function (_super) {
71
73
  __extends(DialogBase, _super);
72
74
  function DialogBase(props) {
@@ -78,6 +80,8 @@ var DialogBase = /** @class */ (function (_super) {
78
80
  _this._inProcess = { inProcess: false };
79
81
  _this._footerRef = React.createRef();
80
82
  _this._headerRef = React.createRef();
83
+ _this.T = [];
84
+ _this._features = {};
81
85
  // Initialize a ref for each action dynamically
82
86
  _this.initializeActionRef = function (key) {
83
87
  if (!_this._actionRefs.hasOwnProperty(key)) {
@@ -107,7 +111,7 @@ var DialogBase = /** @class */ (function (_super) {
107
111
  // Set the options with prevDisabled as the current disabled state
108
112
  if (currentDisabled !== process) {
109
113
  action.current
110
- .setOptions(__assign(__assign({}, action.current.options), { prevDisabled: currentDisabled, disabled: process // Set the new disabled state based on the process
114
+ .updateOptions(__assign(__assign({}, action.current.options), { prevDisabled: currentDisabled, disabled: process // Set the new disabled state based on the process
111
115
  }));
112
116
  }
113
117
  }
@@ -118,7 +122,7 @@ var DialogBase = /** @class */ (function (_super) {
118
122
  // Restore the previous disabled state from options
119
123
  // Call prevDisabled state from memo
120
124
  action.current
121
- .setOptions(__assign(__assign({}, action.current.options), { disabled: action.current.options.prevDisabled // Set the new disabled state based on the process
125
+ .updateOptions(__assign(__assign({}, action.current.options), { disabled: action.current.options.prevDisabled // Set the new disabled state based on the process
122
126
  }));
123
127
  }
124
128
  }
@@ -126,23 +130,23 @@ var DialogBase = /** @class */ (function (_super) {
126
130
  if (!process) {
127
131
  _this.snackbar.close("kInProcess");
128
132
  }
133
+ if (typeof _this._processingListener === "function") {
134
+ _this._processingListener(process);
135
+ }
129
136
  // @ts-ignore
130
137
  (_c = _this._footerRef.current) === null || _c === void 0 ? void 0 : _c.setProcessing(process);
131
138
  return _this;
132
139
  };
133
140
  _this.isInProcess = function () {
134
- // return this.state.inProcess;
135
141
  return _this._inProcess;
136
- // @ts-ignore
137
- // return this._footerRef?.current?.inProcess ?? false;
138
142
  };
139
143
  _this.close = function (callbackFn) {
140
- var _a;
144
+ var _a, _b, _c, _d;
141
145
  if (_this._footerRef.current.inProcess) {
142
146
  var notify = (_a = _this._dialogOptions.base.notifyOnClosing) !== null && _a !== void 0 ? _a : "snackbar";
143
147
  if (notify === "snackbar") {
144
- // this.snackbar.open(this._dialogOptions.snackbar.busyMessage ? this._dialogOptions.snackbar.busyMessage : 'In Process, Please wait...', "warning", "kInProcess");
145
- _this.snackbar.open(_this._dialogOptions.snackbar.busyMessage ? _this._dialogOptions.snackbar.busyMessage : 'In Process, Please wait...', "warning");
148
+ 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...';
149
+ _this.snackbar.open(busyMessage, "warning");
146
150
  }
147
151
  else {
148
152
  _this._dialogWithBackDropRef.current.baseZoomEffect();
@@ -164,11 +168,15 @@ var DialogBase = /** @class */ (function (_super) {
164
168
  };
165
169
  _this.render = function () {
166
170
  console.log('this._prevDialogRect', _this.state.prevDialogRect);
167
- return (0, jsx_runtime_1.jsx)(_1.DialogWithBackdropWrapper, { initialValues: _this.props.initialValues, dialog: _this,
171
+ return (0, jsx_runtime_1.jsx)(DialogContentContextProvider_1.default
172
+ // 1️⃣initialValues={this.props.initialValues}
173
+ , {
174
+ // 1️⃣initialValues={this.props.initialValues}
175
+ dialogBase: _this,
168
176
  // Component
169
- header: _this.props.header, body: _this.state.body, actions: _this.props.actions,
177
+ body: _this.state.body,
170
178
  // Refs Props
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 });
179
+ dialogRef: _this._dialogRef, headerRef: _this._headerRef, bodyRef: _this._dialogBodyRef, footerRef: _this._footerRef, backdropRef: _this._backdropRef, snackbarRef: _this._snackbarRef, prevDialogRect: _this.state.prevDialogRect, children: (0, jsx_runtime_1.jsx)(_1.DialogWithBackdropWrapper, {}) });
172
180
  };
173
181
  _this.state = {
174
182
  inProcess: { inProcess: false },
@@ -204,6 +212,7 @@ var DialogBase = /** @class */ (function (_super) {
204
212
  size: _this._dialogSize
205
213
  }
206
214
  }, _this._dialogOptions);
215
+ console.log('Dialog_Base_Options', defaultOptions, window["dialogOptions"], props.initialOptions);
207
216
  _this._dialogOptions = (0, lodash_1.merge)({}, defaultOptions, window["dialogOptions"], props.initialOptions);
208
217
  _this._header = props.header;
209
218
  _this._body = props.body;
@@ -219,9 +228,17 @@ var DialogBase = /** @class */ (function (_super) {
219
228
  _this._initialValues = props.initialValues;
220
229
  _this._dialogWithBackDropRef = (0, react_1.createRef)();
221
230
  _this._parent = props.parent;
231
+ _this._processingListener = props.processingListener;
232
+ _this._features = [];
222
233
  console.log('this._dialogOptions', _this._dialogOptions);
223
234
  return _this;
224
235
  }
236
+ DialogBase.prototype.addFeature = function (key, value) {
237
+ this._features[key] = value;
238
+ };
239
+ DialogBase.prototype.getFeature = function (key) {
240
+ return this._features[key];
241
+ };
225
242
  Object.defineProperty(DialogBase.prototype, "parent", {
226
243
  get: function () {
227
244
  return this._parent;
@@ -329,33 +346,16 @@ var DialogBase = /** @class */ (function (_super) {
329
346
  };
330
347
  // ✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨
331
348
  DialogBase.prototype.componentDidMount = function () {
332
- var _a, _b, _c, _d, _e;
333
- console.log('clalisan componentDidMount');
334
- // İlk konumları global seçeneklerden al
335
- var _f = this._dialogOptions.snackbar.anchorOrigin, vertical = _f.vertical, horizontal = _f.horizontal;
349
+ var _a, _b, _c;
350
+ // First position take from Global
351
+ var _d = this._dialogOptions.snackbar.anchorOrigin, vertical = _d.vertical, horizontal = _d.horizontal;
336
352
  var initialAnchor = { vertical: vertical, horizontal: horizontal };
337
- // Kullanıcı tanımlı konumlar varsa, onları ilk konumlarla birleştir
353
+ // Merge user defied positions with global positions!
338
354
  this._snackbarAnchor = __assign(__assign(__assign({}, initialAnchor), (((_a = this.props.snackbarAnchor) === null || _a === void 0 ? void 0 : _a.vertical) ? { vertical: this.props.snackbarAnchor.vertical } : {})), (((_b = this.props.snackbarAnchor) === null || _b === void 0 ? void 0 : _b.horizontal) ? { horizontal: this.props.snackbarAnchor.horizontal } : {}));
339
355
  if (typeof ((_c = this.props) === null || _c === void 0 ? void 0 : _c.didMountCallback) === "function") {
340
356
  this.props.didMountCallback(this);
341
357
  }
342
- // Register Dialog Bounds
343
- if ((_d = this._dialogOptions.base) === null || _d === void 0 ? void 0 : _d.memoBounds) {
344
- if (!helpers_1.InitDialogMemoizeBoundsDeclared) {
345
- throw new Error('InitDialogMemoizeBounds is not defined. Please make sure to declare it only once, at the top‑level of your module—outside of App or its render logic.\n' +
346
- 'InitDialogMemoizeBounds()\n' +
347
- 'const App() => {...');
348
- }
349
- var _g = (_e = this._dialogRef.current) === null || _e === void 0 ? void 0 : _e.getBoundingClientRect(), width = _g.width, height = _g.height, x = _g.x, y = _g.y;
350
- (0, helpers_1.dialogRegister)(this._dialogOptions.base.id, {
351
- width: width,
352
- height: height,
353
- x: x,
354
- y: y,
355
- fullscreen: false
356
- });
357
- }
358
- // Parent objesinin accessFrom özelliğini ayarla
358
+ // accessFrom Property of Parent object Internal->External
359
359
  this.accessFrom = "internal";
360
360
  };
361
361
  DialogBase.prototype.kill = function (callbackFn) {
@@ -397,6 +397,11 @@ var DialogBase = /** @class */ (function (_super) {
397
397
  var _this = this;
398
398
  this.setState(function (prevState) { return (__assign(__assign({}, _this.state), { body: body })); });
399
399
  };
400
+ DialogBase.prototype.processingListener = function (listener) {
401
+ // @ts-ignore
402
+ this._processingListener = listener;
403
+ return this;
404
+ };
400
405
  Object.defineProperty(DialogBase.prototype, "snackbar", {
401
406
  // Reference: https://notistack.com/api-reference#mutual-props
402
407
  get: function () {
@@ -1,4 +1,3 @@
1
1
  import * as React from "react";
2
- import { IContentProps } from "../types/DialogTypes";
3
- declare const DialogContent: React.FC<IContentProps>;
2
+ declare const DialogContent: React.FC<{}>;
4
3
  export { DialogContent };
@@ -70,22 +70,26 @@ var _1 = require("./");
70
70
  var react_1 = require("react");
71
71
  var helpers_2 = require("../helpers");
72
72
  var jumper_animate_1 = require("./utils/effects/jumper-animate");
73
- var WithSnackbar = function (props) {
74
- return (0, jsx_runtime_1.jsx)(notistack_1.SnackbarProvider, { ref: props.snackbarRef, maxSnack: props.maxSnack, children: props.children });
75
- };
76
- var DialogContent = function (_a) {
77
- var _b, _c, _d, _e, _f;
78
- var body = _a.body, header = _a.header, actions = _a.actions, dialogRef = _a.dialogRef, headerRef = _a.headerRef, bodyRef = _a.bodyRef, footerRef = _a.footerRef, dialogOptions = _a.dialogOptions, backdropRef = _a.backdropRef, dialog = _a.dialog, resizeableObject = _a.resizeableObject, prevDialogRect = _a.prevDialogRect, snackbarRef = _a.snackbarRef;
73
+ var DialogContentContextProvider_1 = require("../context/DialogContentContextProvider");
74
+ var DialogContent = function (props) {
75
+ var _a, _b, _c, _d, _e;
76
+ var _f = (0, react_1.useContext)(DialogContentContextProvider_1.DialogContentContext), dialog = _f.dialog, dialogRef = _f.dialogRef, prevDialogRect = _f.prevDialogRect, backdropRef = _f.backdropRef, snackbarRef = _f.snackbarRef, footerRef = _f.footerRef, resizeableObject = _f.resizeableObject;
77
+ var dialogOptions = dialog.dialogOptions;
78
+ var baseOptions = dialogOptions.base;
79
79
  var _g = React.useState(false), fullscreenMode = _g[0], setFullscreenMode = _g[1];
80
80
  var _h = React.useState(null), rect = _h[0], setRect = _h[1];
81
- var baseOptions = dialogOptions.base;
82
- /**
83
- * default null
84
- * If memoized, than read values from memory
85
- * */
86
- var base = dialogOptions.base;
87
- var bounds = ((_b = dialogOptions.base) === null || _b === void 0 ? void 0 : _b.memoBounds) ? (0, helpers_1.getDialogBounds)(base.id) : null;
81
+ var bounds = ((_a = dialog.dialogOptions.base) === null || _a === void 0 ? void 0 : _a.memoBounds) ? (0, helpers_1.getDialogBounds)(dialog.dialogOptions.base.id) : null;
88
82
  var domZIndex = window.getComputedStyle(dialog.getDom()).zIndex;
83
+ var positionSelector = function () {
84
+ var _a;
85
+ var dialogRectSelectors = { xKey: 'marginLeft', yKey: 'marginTop' };
86
+ if (prevDialogRect === null || prevDialogRect === void 0 ? void 0 : prevDialogRect.isMultiple) {
87
+ dialogRectSelectors = { xKey: 'left', yKey: 'top' };
88
+ }
89
+ var _b = bounds !== null && bounds !== void 0 ? bounds : {}, fullscreen = _b.fullscreen, x = _b.x, y = _b.y, restBounds = __rest(_b, ["fullscreen", "x", "y"]);
90
+ var cssBounds = __assign(__assign(__assign(__assign({}, restBounds), (_a = {}, _a[dialogRectSelectors.xKey] = prevDialogRect === null || prevDialogRect === void 0 ? void 0 : prevDialogRect.left, _a[dialogRectSelectors.yKey] = prevDialogRect === null || prevDialogRect === void 0 ? void 0 : prevDialogRect.top, _a)), prevDialogRect.isMultiple ? { position: 'absolute' } : null), { translate: prevDialogRect.isMultiple ? "".concat(5, "px ").concat(5, "px") : 'none' });
91
+ return __assign({}, bounds ? { position: 'absolute', top: bounds.y, left: bounds.x, width: bounds.width, height: bounds.height } : cssBounds);
92
+ };
89
93
  // Effect Listener
90
94
  (0, react_1.useEffect)(function () {
91
95
  var _a;
@@ -101,6 +105,7 @@ var DialogContent = function (_a) {
101
105
  }
102
106
  }
103
107
  }, [dialog === null || dialog === void 0 ? void 0 : dialog.values]);
108
+ // Listener & Animate
104
109
  (0, react_1.useEffect)(function () {
105
110
  // setDialogRect();
106
111
  (0, helpers_2.formInputKeyListeners)(dialogRef.current);
@@ -108,15 +113,31 @@ var DialogContent = function (_a) {
108
113
  (0, jumper_animate_1.jumperAnimate)(dialogRef.current);
109
114
  }
110
115
  }, []);
116
+ // Set Rect
111
117
  (0, react_1.useEffect)(function () {
112
- var _a;
113
- var dialogRectSelectors = { xKey: 'marginLeft', yKey: 'marginTop' };
114
- if (prevDialogRect === null || prevDialogRect === void 0 ? void 0 : prevDialogRect.isMultiple) {
115
- dialogRectSelectors = { xKey: 'left', yKey: 'top' };
116
- }
117
- var _b = bounds !== null && bounds !== void 0 ? bounds : {}, fullscreen = _b.fullscreen, x = _b.x, y = _b.y, restBounds = __rest(_b, ["fullscreen", "x", "y"]);
118
- var cssBounds = __assign(__assign(__assign(__assign({}, restBounds), (_a = {}, _a[dialogRectSelectors.xKey] = prevDialogRect === null || prevDialogRect === void 0 ? void 0 : prevDialogRect.left, _a[dialogRectSelectors.yKey] = prevDialogRect === null || prevDialogRect === void 0 ? void 0 : prevDialogRect.top, _a)), prevDialogRect.isMultiple ? { position: 'absolute' } : null), { translate: prevDialogRect.isMultiple ? "".concat(5, "px ").concat(5, "px") : 'none' });
119
- setRect(__assign({}, bounds ? { position: 'absolute', top: bounds.y, left: bounds.x, width: bounds.width, height: bounds.height } : cssBounds));
118
+ setRect(positionSelector());
119
+ }, []);
120
+ // Register Dialog If already not registered
121
+ (0, react_1.useEffect)(function () {
122
+ // Register Dialog Bounds
123
+ setTimeout(function () {
124
+ var _a, _b;
125
+ if ((_a = dialog.dialogOptions.base) === null || _a === void 0 ? void 0 : _a.memoBounds) {
126
+ if (!helpers_1.InitDialogMemoizeBoundsDeclared) {
127
+ throw new Error('InitDialogMemoizeBounds is not defined. Please make sure to declare it only once, at the top‑level of your module—outside of App or its render logic.\n' +
128
+ 'InitDialogMemoizeBounds()\n' +
129
+ 'const App() => {...');
130
+ }
131
+ var _c = (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect(), width = _c.width, height = _c.height, x = _c.x, y = _c.y;
132
+ (0, helpers_1.dialogRegister)(dialog.dialogOptions.base.id, {
133
+ width: width,
134
+ height: height,
135
+ x: x,
136
+ y: y,
137
+ fullscreen: false
138
+ });
139
+ }
140
+ }, 1000);
120
141
  }, []);
121
142
  return (0, jsx_runtime_1.jsx)(react_draggable_1.default, { disabled: !baseOptions.draggable || fullscreenMode, axis: 'both', handle: baseOptions.draggable ? '.drag-handle' : '', scale: 1, ref: backdropRef, onDrag: function (event, data) {
122
143
  event.stopPropagation();
@@ -134,7 +155,7 @@ var DialogContent = function (_a) {
134
155
  y: y,
135
156
  fullscreen: false
136
157
  }, dialogRef);
137
- }, children: (0, jsx_runtime_1.jsxs)("div", { id: "dialog-main", ref: dialogRef, onClick: function (e) {
158
+ }, children: (0, jsx_runtime_1.jsx)("div", { id: "dialog-main", ref: dialogRef, onClick: function (e) {
138
159
  e.stopPropagation();
139
160
  }, tabIndex: 0, onKeyDown: function (e) {
140
161
  var target = e.target;
@@ -147,9 +168,9 @@ var DialogContent = function (_a) {
147
168
  // @ts-ignore
148
169
  dialog.props.keyboardListener(e.key, _this);
149
170
  }
150
- }, className: baseOptions.size.width === 'auto' ? 'auto' : "dialog-width-".concat(dialogOptions.base.size.width, " dialog-main show-opacity show-position-").concat(baseOptions.initialAnchor.vertical), style: __assign(__assign(__assign(__assign({ height: (_c = baseOptions.size.height) !== null && _c !== void 0 ? _c : 'auto' }, typeof baseOptions.size.width === "number" ? { width: "".concat(baseOptions.size.width, "px") } : { width: "".concat(baseOptions.size.width) }), { outline: 'none', fontFamily: (_d = baseOptions.style.fontFamily) !== null && _d !== void 0 ? _d : 'Arial' }), rect), { alignSelf: (_e = baseOptions.initialAnchor.vertical) !== null && _e !== void 0 ? _e : 'flex-start', justifySelf: (_f = baseOptions.initialAnchor.horizontal) !== null && _f !== void 0 ? _f : 'flex-start' }), children: [(0, jsx_runtime_1.jsxs)(WithSnackbar, { snackbarRef: snackbarRef, maxSnack: dialogOptions.snackbar.maxSnack, children: [(header || dialogOptions.slot.header) && ((0, jsx_runtime_1.jsx)(_1.DialogContentHeader, { ref: headerRef, dialogRef: dialogRef, header: header, dialog: dialog, bounds: bounds })), (0, jsx_runtime_1.jsx)(_1.DialogContentBody, { ref: bodyRef, dialog: dialog, body: body }), (0, jsx_runtime_1.jsx)(_1.DialogContentFooter, { ref: footerRef, dialog: dialog, actions: actions })] }), (baseOptions.resizeable) &&
151
- (0, jsx_runtime_1.jsx)(React.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "resizable-handle", style: {
152
- zIndex: parseInt(domZIndex) + 1
153
- }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown, children: (0, jsx_runtime_1.jsx)(ResizeIcon_1.default, { color: '#286e94' }) }) })] }) });
171
+ }, className: baseOptions.size.width === 'auto' ? 'auto' : "dialog-width-".concat(dialogOptions.base.size.width, " dialog-main show-opacity show-position-").concat(baseOptions.initialAnchor.vertical), style: __assign(__assign(__assign(__assign({ height: (_b = baseOptions.size.height) !== null && _b !== void 0 ? _b : 'auto' }, typeof baseOptions.size.width === "number" ? { width: "".concat(baseOptions.size.width, "px") } : { width: "".concat(baseOptions.size.width) }), { outline: 'none', fontFamily: (_c = baseOptions.style.fontFamily) !== null && _c !== void 0 ? _c : 'Arial' }), rect), { alignSelf: (_d = baseOptions.initialAnchor.vertical) !== null && _d !== void 0 ? _d : 'flex-start', justifySelf: (_e = baseOptions.initialAnchor.horizontal) !== null && _e !== void 0 ? _e : 'flex-start' }), children: (0, jsx_runtime_1.jsxs)(notistack_1.SnackbarProvider, { ref: snackbarRef, maxSnack: dialog.dialogOptions.snackbar.maxSnack, children: [(dialog.props.header || dialogOptions.slot.header) && ((0, jsx_runtime_1.jsx)(_1.DialogContentHeader, { header: dialog.props.header, bounds: bounds })), (0, jsx_runtime_1.jsx)(_1.DialogContentBody, { body: dialog.state.body }), (0, jsx_runtime_1.jsx)(_1.DialogContentFooter, { ref: footerRef }), (baseOptions.resizeable) &&
172
+ (0, jsx_runtime_1.jsx)(React.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "resizable-handle", style: {
173
+ zIndex: parseInt(domZIndex) + 1
174
+ }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown, children: (0, jsx_runtime_1.jsx)(ResizeIcon_1.default, { color: '#286e94' }) }) })] }) }) });
154
175
  };
155
176
  exports.DialogContent = DialogContent;
@@ -1,10 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { TDialogCallbackFn } from "../types/DialogTypes";
3
- import DialogBase from "./DialogBase";
4
3
  interface IContentBodyProps {
5
4
  body: TDialogCallbackFn;
6
- dialog: DialogBase<any>;
7
- ref?: React.RefObject<any>;
8
5
  }
9
6
  declare const DialogContentBody: React.FC<IContentBodyProps>;
10
7
  export { DialogContentBody };
@@ -36,6 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.DialogContentBody = void 0;
37
37
  var jsx_runtime_1 = require("react/jsx-runtime");
38
38
  var React = __importStar(require("react"));
39
+ var react_1 = require("react");
40
+ var DialogContentContextProvider_1 = require("../context/DialogContentContextProvider");
39
41
  var Placeholder = function (_a) {
40
42
  var dialogOptions = _a.dialogOptions, placeholder = _a.placeholder;
41
43
  var bgColor = dialogOptions.base.style.backgroundColor ?
@@ -49,9 +51,16 @@ var Placeholder = function (_a) {
49
51
  }, children: placeholder });
50
52
  };
51
53
  var DialogContentBody = React.forwardRef(function (_a, ref) {
52
- var body = _a.body, dialog = _a.dialog;
54
+ // const [localBody, setLocalBody] = React.useState(null);
55
+ var body = _a.body;
56
+ var dialog = (0, react_1.useContext)(DialogContentContextProvider_1.DialogContentContext).dialog;
57
+ // useEffect(() => {
58
+ // setLocalBody(body(dialog));
59
+ // }, [body]);
53
60
  if (body instanceof Function) {
54
- return (0, jsx_runtime_1.jsxs)("div", { className: 'dialog-body', style: { height: '100%' }, children: [dialog.holder && (0, jsx_runtime_1.jsx)(Placeholder, { dialogOptions: dialog.dialogOptions, placeholder: dialog.holder }), body(dialog)] });
61
+ var BodyElement = body(dialog); // localBody;
62
+ console.log('Typeof BodyElement', BodyElement);
63
+ return (0, jsx_runtime_1.jsxs)("div", { className: 'dialog-body', style: { height: '100%' }, children: [dialog.holder && (0, jsx_runtime_1.jsx)(Placeholder, { dialogOptions: dialog.dialogOptions, placeholder: dialog.holder }), (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: BodyElement })] });
55
64
  }
56
65
  return (0, jsx_runtime_1.jsx)("div", { className: 'dialog-body', style: { height: '100%', padding: 10 }, children: dialog.holder ?
57
66
  (0, jsx_runtime_1.jsx)(Placeholder, { dialogOptions: dialog.dialogOptions, placeholder: dialog.holder })
@@ -52,13 +52,14 @@ var react_1 = require("react");
52
52
  var Features_1 = require("./Features");
53
53
  var context_1 = require("../context");
54
54
  var _1 = require("./");
55
- var DialogContentFooter = (0, react_1.forwardRef)(function (_a, ref) {
56
- var _b, _c, _d;
57
- var actions = _a.actions, dialog = _a.dialog;
55
+ var DialogContentContextProvider_1 = require("../context/DialogContentContextProvider");
56
+ var DialogContentFooter = (0, react_1.forwardRef)(function (props, ref) {
57
+ var _a, _b, _c;
58
+ var dialog = (0, react_1.useContext)(DialogContentContextProvider_1.DialogContentContext).dialog;
58
59
  var dialogOptions = dialog.dialogOptions;
59
- var CustomFooter = (_b = dialogOptions.slot) === null || _b === void 0 ? void 0 : _b.footer;
60
+ var CustomFooter = (_a = dialogOptions.slot) === null || _a === void 0 ? void 0 : _a.footer;
60
61
  // Imperative handle
61
- var _e = React.useState(false), inProcess = _e[0], setInProcess = _e[1];
62
+ var _d = React.useState(false), inProcess = _d[0], setInProcess = _d[1];
62
63
  var setProcessing = function (inProcess) {
63
64
  setInProcess(inProcess);
64
65
  };
@@ -77,9 +78,9 @@ var DialogContentFooter = (0, react_1.forwardRef)(function (_a, ref) {
77
78
  inProcess: dialog.isInProcess()
78
79
  });
79
80
  }
80
- return (0, jsx_runtime_1.jsxs)("div", { className: 'dialog-footer', style: (_d = (_c = dialogOptions.base) === null || _c === void 0 ? void 0 : _c.footer) === null || _d === void 0 ? void 0 : _d.style, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(context_1.WithHeaderFooterContext, __assign({}, staticProps, { dialog: dialog, children: dialogOptions.slot.footer ?
81
+ return (0, jsx_runtime_1.jsxs)("div", { className: 'dialog-footer', style: (_c = (_b = dialogOptions.base) === null || _b === void 0 ? void 0 : _b.footer) === null || _c === void 0 ? void 0 : _c.style, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(context_1.WithHeaderFooterContext, __assign({}, staticProps, { dialog: dialog, children: dialogOptions.slot.footer ?
81
82
  (0, jsx_runtime_1.jsx)(CustomFooter, __assign({}, staticProps, footerProps))
82
83
  :
83
- (0, jsx_runtime_1.jsx)(Features_1.DialogProcessing, {}) })) }), (0, jsx_runtime_1.jsx)(_1.Actions, { dialog: dialog, actions: actions })] });
84
+ (0, jsx_runtime_1.jsx)(Features_1.DialogProcessing, {}) })) }), (0, jsx_runtime_1.jsx)(_1.Actions, { dialog: dialog, actions: dialog.props.actions })] });
84
85
  });
85
86
  exports.DialogContentFooter = DialogContentFooter;
@@ -1,12 +1,8 @@
1
1
  import { TDialogCallbackFn } from "../types/DialogTypes";
2
2
  import * as React from "react";
3
- import DialogBase from "./DialogBase";
4
3
  import { IDialogBoundsDef } from "../types/BoundTypes";
5
4
  interface IContentHeaderProps {
6
5
  header: TDialogCallbackFn;
7
- dialog: DialogBase<any>;
8
- ref: React.RefObject<any>;
9
- dialogRef: React.RefObject<any>;
10
6
  bounds: IDialogBoundsDef;
11
7
  }
12
8
  declare const DialogContentHeader: React.FC<IContentHeaderProps>;
@@ -52,15 +52,14 @@ var React = __importStar(require("react"));
52
52
  var react_1 = require("react");
53
53
  var helpers_1 = require("../helpers");
54
54
  var context_1 = require("../context");
55
- var DialogContentHeader = React.forwardRef(function (_a, ref) {
55
+ var DialogContentContextProvider_1 = require("../context/DialogContentContextProvider");
56
+ var DialogContentHeader = function (_a) {
56
57
  var _b, _c, _d, _e;
57
- var header = _a.header, dialog = _a.dialog, dialogRef = _a.dialogRef, bounds = _a.bounds;
58
+ var header = _a.header, bounds = _a.bounds;
59
+ var _f = (0, react_1.useContext)(DialogContentContextProvider_1.DialogContentContext), dialog = _f.dialog, dialogRef = _f.dialogRef;
58
60
  var dialogOptions = dialog.dialogOptions;
59
- var _f = React.useState(bounds === null || bounds === void 0 ? void 0 : bounds.fullscreen), fullscreen = _f[0], setFullscreen = _f[1];
60
- (0, react_1.useImperativeHandle)(ref, function () { return ({
61
- setFullscreen: setFullscreen,
62
- fullscreen: fullscreen
63
- }); });
61
+ var baseOptions = dialogOptions.base;
62
+ var _g = React.useState(bounds === null || bounds === void 0 ? void 0 : bounds.fullscreen), fullscreen = _g[0], setFullscreen = _g[1];
64
63
  (0, react_1.useEffect)(function () {
65
64
  if (fullscreen) {
66
65
  dialogRef.current.classList.add('fullscreen');
@@ -73,7 +72,6 @@ var DialogContentHeader = React.forwardRef(function (_a, ref) {
73
72
  dialogRef.current.classList.remove('no-user-select');
74
73
  }, 300);
75
74
  }, [fullscreen]);
76
- var baseOptions = dialogOptions.base;
77
75
  var CustomHeader = (_b = dialogOptions.slot) === null || _b === void 0 ? void 0 : _b.header;
78
76
  var staticProps = {
79
77
  dialogOptions: dialogOptions,
@@ -105,5 +103,5 @@ var DialogContentHeader = React.forwardRef(function (_a, ref) {
105
103
  (0, jsx_runtime_1.jsx)(Features_1.DialogInfoAction, {})] }) })] });
106
104
  }
107
105
  return (0, jsx_runtime_1.jsx)("div", { style: (_e = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.header) === null || _e === void 0 ? void 0 : _e.style, className: 'drag-handle dialog-header', children: header });
108
- });
106
+ };
109
107
  exports.DialogContentHeader = DialogContentHeader;
@@ -1,4 +1,2 @@
1
- import React from "react";
2
- import { DialogWithBackdropWrapperRefProps, WithBackdrop } from "../types/DialogTypes";
3
- declare const DialogWithBackdropWrapper: React.ForwardRefExoticComponent<Omit<WithBackdrop, "ref"> & React.RefAttributes<DialogWithBackdropWrapperRefProps>>;
1
+ declare const DialogWithBackdropWrapper: () => import("react/jsx-runtime").JSX.Element;
4
2
  export { DialogWithBackdropWrapper };