react-dialogger 1.1.117 → 1.1.119

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.
package/README.md CHANGED
@@ -3,6 +3,9 @@
3
3
  npm i react-dialogger
4
4
  ```
5
5
 
6
+ Please use
7
+
8
+
6
9
  # GitHub
7
10
  You can find the example code and more information about the project on our [GitHub repository](https://github.com/appinsource2021/react-dialogger-example.git).
8
11
 
@@ -12,6 +15,83 @@ You can find the example code about the project on our [Codesandbox](https://cod
12
15
  # Youtube
13
16
  You can watch simple example on Youtube [Youtube](https://www.youtube.com/watch?v=vhSroEgdj1c)
14
17
 
18
+ #### ⚠️ Breaking Change: initialValues Scope Restriction
19
+ ` In previous versions, initialValues, setValue, and setValues were able to store any type of data, including:
20
+ Functions
21
+ Object references
22
+ Component refs
23
+ Arbitrary complex objects
24
+ This behavior has changed in the latest version.`
25
+
26
+ #### ✅ New Behavior
27
+ `initialValues now only supports serializable key–value data, such as:
28
+ Primitive values
29
+ Plain objects
30
+ Arrays
31
+ Collections that represent form/state data
32
+ Methods, functions, class instances, and object references are no longer supported in initialValues.
33
+ This change improves:
34
+ Predictability
35
+ State safety
36
+ Serialization compatibility
37
+ Debugging and maintainability`
38
+
39
+ #### 🔌 How to Pass Methods and References
40
+ * To pass methods or object references, use the new inject API.
41
+ ### Injection Example
42
+ ```js
43
+ dialog.inject({
44
+ myMethod,
45
+ myRef
46
+ });
47
+ ```
48
+
49
+ #### Accessing Injected Dependencies
50
+ * Injected dependencies are available via dialog.deps:
51
+ ```js
52
+ show(dialog => {
53
+ dialog.deps.myMethod('Suleyman');
54
+ dialog.deps.myRef.current;
55
+ });
56
+
57
+ ```
58
+
59
+ #### 🧠 Design Principle
60
+ * State (initialValues) → data only
61
+ * Behavior & references → dependency injection (inject)
62
+ * This separation enforces a clean architecture and prevents unintended side effects.
63
+
64
+
65
+ #### ❌ Invalid Usage (No Longer Supported)
66
+ ```js
67
+ initialValues: {
68
+ onSubmit: () => {},
69
+ tableRef: ref,
70
+ }
71
+ ```
72
+ #### ✅ Correct Usage
73
+ ```js
74
+ initialValues: {
75
+ status: 'active',
76
+ items: []
77
+ }
78
+
79
+ dialog.inject({
80
+ onSubmit,
81
+ tableRef
82
+ });
83
+ ```
84
+
85
+ #### 🚀 Migration Guide
86
+ `If you were previously storing functions or references inside initialValues:
87
+ Remove them from initialValues
88
+ Register them via dialog.inject(...)
89
+ Access them using dialog.deps.*`
90
+
91
+
92
+
93
+
94
+
15
95
  # Why react-dialogger?
16
96
  > react-dialogger is built for React applications that need dynamic, runtime-managed dialogs rather than static JSX-based modals.
17
97
  It enables centralized dialog configuration, action-driven logic, and dialog-owned state, making complex dialog flows easier to manage and scale.
@@ -22,7 +22,7 @@ declare class DialogBase<V, I> extends Component<BaseDialogProps<V, I>, BaseDial
22
22
  protected _formikProps: FormikProps<any>;
23
23
  protected readonly _backdropRef: RefObject<any>;
24
24
  protected readonly _dialogRef: RefObject<any>;
25
- protected readonly _dialogBodyRef: RefObject<any>;
25
+ protected readonly _bodyRef: RefObject<any>;
26
26
  protected readonly _snackbarRef: WithBackdrop['snackbarRef'];
27
27
  protected _dialogOptions?: DialogOptionsType;
28
28
  protected _onClose: TDialogCallbackFn<V, I, void>;
@@ -60,6 +60,7 @@ declare class DialogBase<V, I> extends Component<BaseDialogProps<V, I>, BaseDial
60
60
  set inlineFormikProps(inlineFormikProps: IFormikAdapter);
61
61
  setValues<T>(values: Dialogify<T>, callbackFn?: () => void): void;
62
62
  componentDidMount(): void;
63
+ componentWillUnmount(): void;
63
64
  setInProcess: (process: boolean, message?: string, holder?: TInitialHolder) => this;
64
65
  isInProcess: () => IInProcess;
65
66
  private kill;
@@ -86,7 +86,7 @@ var DialogBase = /** @class */ (function (_super) {
86
86
  return _this._actionRefs[key];
87
87
  };
88
88
  _this.setInProcess = function (process, message, holder) {
89
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
89
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
90
90
  _this._inProcess = __assign({ inProcess: process }, message ? { message: message } : {});
91
91
  if (!process) {
92
92
  _this._holder = null;
@@ -104,8 +104,7 @@ var DialogBase = /** @class */ (function (_super) {
104
104
  var currentDisabled = (_d = (_c = action.current) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.disabled;
105
105
  // Set the options with prevDisabled as the current disabled state
106
106
  if (currentDisabled !== process) {
107
- action.current
108
- .updateOptions(__assign(__assign({}, (_f = (_e = action.current) === null || _e === void 0 ? void 0 : _e.options) !== null && _f !== void 0 ? _f : {}), { prevDisabled: currentDisabled, disabled: process // Set the new disabled state based on the process
107
+ action === null || action === void 0 ? void 0 : action.current.updateOptions(__assign(__assign({}, (_f = (_e = action.current) === null || _e === void 0 ? void 0 : _e.options) !== null && _f !== void 0 ? _f : {}), { prevDisabled: currentDisabled, disabled: process // Set the new disabled state based on the process
109
108
  }));
110
109
  }
111
110
  }
@@ -123,8 +122,8 @@ var DialogBase = /** @class */ (function (_super) {
123
122
  if (!process) {
124
123
  _this.snackbar.close("kInProcess");
125
124
  }
126
- for (var _i = 0, _m = _this._processingListeners; _i < _m.length; _i++) {
127
- var listener = _m[_i];
125
+ for (var _i = 0, _o = _this._processingListeners; _i < _o.length; _i++) {
126
+ var listener = _o[_i];
128
127
  if (typeof listener === "function") {
129
128
  listener(process);
130
129
  }
@@ -133,6 +132,7 @@ var DialogBase = /** @class */ (function (_super) {
133
132
  // @ts-ignore
134
133
  (_k = _this._footerRef.current) === null || _k === void 0 ? void 0 : _k.setProcessing(_this._inProcess);
135
134
  (_l = _this._headerRef.current) === null || _l === void 0 ? void 0 : _l.setProcessing(_this._inProcess);
135
+ (_m = _this._bodyRef.current) === null || _m === void 0 ? void 0 : _m.setProcessing(_this._inProcess);
136
136
  // this._footerRef.current?.setProcessing(process);
137
137
  return _this;
138
138
  };
@@ -154,7 +154,7 @@ var DialogBase = /** @class */ (function (_super) {
154
154
  };
155
155
  setTimeout(function () {
156
156
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
157
- if (((_b = (_a = _this._footerRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.inProcess) && !_this.state.aborted) {
157
+ if (((_b = (_a = _this._footerRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.inProcess.inProcess) && !_this.state.aborted) {
158
158
  var notify = (_e = (_d = (_c = _this._dialogOptions) === null || _c === void 0 ? void 0 : _c.base) === null || _d === void 0 ? void 0 : _d.notifyOnClosing) !== null && _e !== void 0 ? _e : "snackbar";
159
159
  if (notify === "snackbar") {
160
160
  var busyMessage = (_h = (_g = (_f = _this._dialogOptions) === null || _f === void 0 ? void 0 : _f.localText) === null || _g === void 0 ? void 0 : _g.busyMessage) !== null && _h !== void 0 ? _h : 'In Process, Please wait...';
@@ -192,7 +192,7 @@ var DialogBase = /** @class */ (function (_super) {
192
192
  // Component
193
193
  body: _this.state.body,
194
194
  // Refs Props
195
- 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)(_components_1.DialogWithBackdropWrapper, {}) });
195
+ dialogRef: _this._dialogRef, headerRef: _this._headerRef, bodyRef: _this._bodyRef, footerRef: _this._footerRef, backdropRef: _this._backdropRef, snackbarRef: _this._snackbarRef, prevDialogRect: _this.state.prevDialogRect, children: (0, jsx_runtime_1.jsx)(_components_1.DialogWithBackdropWrapper, {}) });
196
196
  };
197
197
  // this.inject(props.inject);
198
198
  _this.state = {
@@ -236,7 +236,7 @@ var DialogBase = /** @class */ (function (_super) {
236
236
  _this._actions = props.actions;
237
237
  _this._backdropRef = React.createRef();
238
238
  _this._dialogRef = React.createRef();
239
- _this._dialogBodyRef = React.createRef();
239
+ _this._bodyRef = React.createRef();
240
240
  _this._inProcess = { inProcess: false };
241
241
  _this._snackbarRef = React.createRef();
242
242
  _this._holder = props.initialHolder;
@@ -375,6 +375,9 @@ var DialogBase = /** @class */ (function (_super) {
375
375
  // accessFrom Property of Parent object Internal->External
376
376
  this.accessFrom = "internal";
377
377
  };
378
+ DialogBase.prototype.componentWillUnmount = function () {
379
+ console.log('componentWillUnmount');
380
+ };
378
381
  DialogBase.prototype.kill = function (callbackFn) {
379
382
  var _this = this;
380
383
  // ReactDOM.unmountComponentAtNode(this.props.dom);
@@ -74,7 +74,7 @@ var appLogger_1 = require("../helpers/appLogger");
74
74
  var DialogContent = function (props) {
75
75
  var _a, _b, _c, _d, _e, _f, _g;
76
76
  var firstUpdate = React.useRef(true);
77
- var _h = (0, react_1.useContext)(_context_1.DialogContentContext), dialog = _h.dialog, dialogRef = _h.dialogRef, prevDialogRect = _h.prevDialogRect, backdropRef = _h.backdropRef, snackbarRef = _h.snackbarRef, footerRef = _h.footerRef, headerRef = _h.headerRef, resizeableObject = _h.resizeableObject, body = _h.body;
77
+ var _h = (0, react_1.useContext)(_context_1.DialogContentContext), dialog = _h.dialog, dialogRef = _h.dialogRef, prevDialogRect = _h.prevDialogRect, backdropRef = _h.backdropRef, snackbarRef = _h.snackbarRef, footerRef = _h.footerRef, bodyRef = _h.bodyRef, headerRef = _h.headerRef, resizeableObject = _h.resizeableObject, body = _h.body;
78
78
  var dialogOptions = dialog.dialogOptions;
79
79
  var baseOptions = dialogOptions.base;
80
80
  var _j = React.useState(false), fullscreenMode = _j[0], setFullscreenMode = _j[1];
@@ -177,7 +177,7 @@ var DialogContent = function (props) {
177
177
  // @ts-ignore
178
178
  dialog.props.keyboardListener(e.key, _this);
179
179
  }
180
- }, 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, style: __assign({ width: 'min-content' }, (_g = (_f = dialog.dialogOptions) === null || _f === void 0 ? void 0 : _f.snackbar) === null || _g === void 0 ? void 0 : _g.style), children: [(dialog.props.header || dialogOptions.slot.header) && ((0, jsx_runtime_1.jsx)(_1.DialogContentHeader, { ref: headerRef, header: dialog.props.header, bounds: bounds })), (0, jsx_runtime_1.jsx)(_1.DialogContentBody, { body: body }), (0, jsx_runtime_1.jsx)(_1.DialogContentFooter, { ref: footerRef }), (baseOptions.resizeable) &&
180
+ }, 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, style: __assign({ width: 'min-content' }, (_g = (_f = dialog.dialogOptions) === null || _f === void 0 ? void 0 : _f.snackbar) === null || _g === void 0 ? void 0 : _g.style), children: [(dialog.props.header || dialogOptions.slot.header) && ((0, jsx_runtime_1.jsx)(_1.DialogContentHeader, { ref: headerRef, header: dialog.props.header, bounds: bounds })), (0, jsx_runtime_1.jsx)(_1.DialogContentBody, { ref: bodyRef, body: body }), (0, jsx_runtime_1.jsx)(_1.DialogContentFooter, { ref: footerRef }), (baseOptions.resizeable) &&
181
181
  (0, jsx_runtime_1.jsx)(React.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "resizable-handle", style: {
182
182
  zIndex: parseInt(domZIndex) + 1
183
183
  }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown, children: (0, jsx_runtime_1.jsx)(_icons_1.ResizeIcon, { color: '#286e94' }) }) })] }) }) });
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
- import { TDialogCallbackFn } from "../types/index.js";
2
+ import { DialogContentBodyReturnType, TDialogCallbackFn } from "../types/index.js";
3
3
  interface IContentBodyProps {
4
4
  body: TDialogCallbackFn<any, any>;
5
5
  }
6
- declare const DialogContentBody: React.FC<IContentBodyProps>;
6
+ declare const DialogContentBody: React.ForwardRefExoticComponent<IContentBodyProps & React.RefAttributes<DialogContentBodyReturnType>>;
7
7
  export { DialogContentBody };
@@ -50,9 +50,23 @@ var Placeholder = function (_a) {
50
50
  display: placeholder ? 'flex' : 'none',
51
51
  }, children: placeholder });
52
52
  };
53
+ // const DialogContentBody: React.FC<IContentBodyProps> = React.forwardRef(({
54
+ // body
55
+ // }, ref ) => {
53
56
  var DialogContentBody = React.forwardRef(function (_a, ref) {
54
57
  var body = _a.body;
55
58
  var dialog = (0, react_1.useContext)(_context_1.DialogContentContext).dialog;
59
+ // Imperative handle
60
+ var _b = React.useState({
61
+ inProcess: false
62
+ }), inProcess = _b[0], setInProcess = _b[1];
63
+ var setProcessing = function (processing) {
64
+ setInProcess(processing);
65
+ };
66
+ React.useImperativeHandle(ref, function () { return ({
67
+ setProcessing: setProcessing,
68
+ inProcess: inProcess
69
+ }); });
56
70
  if (body instanceof Function) {
57
71
  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)] });
58
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.117",
3
+ "version": "1.1.119",
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",
@@ -52,6 +52,10 @@ export interface BaseDialogProps<V extends Record<string, any>, I> {
52
52
  processingListeners?: Array<(inProcess: boolean) => void>;
53
53
  abortedListeners?: Array<(dialog: IDialogApiDef<V, I>) => void>;
54
54
  }
55
+ export interface DialogContentBodyReturnType {
56
+ setProcessing: React.Dispatch<React.SetStateAction<InProcessType>>;
57
+ inProcess: InProcessType;
58
+ }
55
59
  export interface IDialogSize {
56
60
  width?: ITypeWidth | number;
57
61
  height?: ITypeHeight | number;
@@ -212,6 +216,7 @@ export interface IContentProps {
212
216
  snackbarRef: WithBackdrop['snackbarRef'];
213
217
  }
214
218
  import { TSnackbarHorizontal, TSnackbarVertical, TFlexPos } from "./SizePosTypes";
219
+ import { InProcessType } from "./DialogActionTypes";
215
220
  export interface ISnackbarAnchor {
216
221
  vertical?: TSnackbarVertical;
217
222
  horizontal?: TSnackbarHorizontal;