react-dialogger 1.1.116 → 1.1.118

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.
@@ -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;
89
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
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,14 +122,17 @@ var DialogBase = /** @class */ (function (_super) {
123
122
  if (!process) {
124
123
  _this.snackbar.close("kInProcess");
125
124
  }
126
- for (var _i = 0, _l = _this._processingListeners; _i < _l.length; _i++) {
127
- var listener = _l[_i];
125
+ for (var _i = 0, _m = _this._processingListeners; _i < _m.length; _i++) {
126
+ var listener = _m[_i];
128
127
  if (typeof listener === "function") {
129
128
  listener(process);
130
129
  }
131
130
  }
131
+ console.log('setInProcess_process', process);
132
132
  // @ts-ignore
133
- (_k = _this._footerRef.current) === null || _k === void 0 ? void 0 : _k.setProcessing(process);
133
+ (_k = _this._footerRef.current) === null || _k === void 0 ? void 0 : _k.setProcessing(_this._inProcess);
134
+ (_l = _this._headerRef.current) === null || _l === void 0 ? void 0 : _l.setProcessing(_this._inProcess);
135
+ // this._footerRef.current?.setProcessing(process);
134
136
  return _this;
135
137
  };
136
138
  _this.isInProcess = function () {
@@ -151,7 +153,7 @@ var DialogBase = /** @class */ (function (_super) {
151
153
  };
152
154
  setTimeout(function () {
153
155
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
154
- if (((_b = (_a = _this._footerRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.inProcess) && !_this.state.aborted) {
156
+ 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) {
155
157
  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";
156
158
  if (notify === "snackbar") {
157
159
  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...';
@@ -372,6 +374,9 @@ var DialogBase = /** @class */ (function (_super) {
372
374
  // accessFrom Property of Parent object Internal->External
373
375
  this.accessFrom = "internal";
374
376
  };
377
+ DialogBase.prototype.componentWillUnmount = function () {
378
+ console.log('componentWillUnmount');
379
+ };
375
380
  DialogBase.prototype.kill = function (callbackFn) {
376
381
  var _this = this;
377
382
  // 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, 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, 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, { 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, { 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' }) }) })] }) }) });
@@ -58,15 +58,16 @@ var DialogContentFooter = (0, react_1.forwardRef)(function (props, ref) {
58
58
  var dialogOptions = dialog.dialogOptions;
59
59
  var CustomFooter = (_a = dialogOptions.slot) === null || _a === void 0 ? void 0 : _a.footer;
60
60
  // Imperative handle
61
- var _d = React.useState(false), inProcess = _d[0], setInProcess = _d[1];
61
+ var _d = React.useState({
62
+ inProcess: false
63
+ }), inProcess = _d[0], setInProcess = _d[1];
62
64
  var inProcessRef = React.useRef(inProcess);
63
65
  var setProcessing = function (processing) {
64
66
  setInProcess(processing);
65
- inProcessRef.current = processing;
66
67
  };
67
68
  React.useImperativeHandle(ref, function () { return ({
68
69
  setProcessing: setProcessing,
69
- inProcess: inProcessRef.current
70
+ inProcess: inProcess
70
71
  }); });
71
72
  var staticProps = {
72
73
  dialogOptions: dialogOptions,
@@ -81,7 +82,7 @@ var DialogContentFooter = (0, react_1.forwardRef)(function (props, ref) {
81
82
  // footerProps = {...dialogOptions.slotProps.footer, dialogOptions: dialogOptions, inProcess: dialog.isInProcess() }
82
83
  footerProps = dialogOptions.slotProps.footer;
83
84
  }
84
- console.log('DialogBase_Render', dialog.actions);
85
+ console.log('DialogBase_DialogContentFooter', dialog.isInProcess());
85
86
  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 ?
86
87
  (0, jsx_runtime_1.jsx)(CustomFooter, __assign({}, staticProps, footerProps))
87
88
  :
@@ -1,8 +1,8 @@
1
- import { TDialogCallbackFn, IDialogBoundsDef } from "../types/index.js";
1
+ import { TDialogCallbackFn, IDialogBoundsDef, DialogContentFooterReturnType } from "../types/index.js";
2
2
  import * as React from "react";
3
3
  interface IContentHeaderProps {
4
4
  header: TDialogCallbackFn<any, any>;
5
5
  bounds: IDialogBoundsDef;
6
6
  }
7
- declare const DialogContentHeader: React.FC<IContentHeaderProps>;
7
+ declare const DialogContentHeader: React.ForwardRefExoticComponent<IContentHeaderProps & React.RefAttributes<DialogContentFooterReturnType>>;
8
8
  export { DialogContentHeader };
@@ -51,13 +51,24 @@ var React = __importStar(require("react"));
51
51
  var react_1 = require("react");
52
52
  var _helpers_1 = require("../helpers/index.js");
53
53
  var _context_1 = require("../context/index.js");
54
- var DialogContentHeader = function (_a) {
54
+ var DialogContentHeader = React.forwardRef(function (_a, ref) {
55
55
  var _b, _c, _d, _e;
56
56
  var header = _a.header, bounds = _a.bounds;
57
57
  var _f = (0, react_1.useContext)(_context_1.DialogContentContext), dialog = _f.dialog, dialogRef = _f.dialogRef;
58
58
  var dialogOptions = dialog.dialogOptions;
59
59
  var baseOptions = dialogOptions.base;
60
60
  var _g = React.useState(bounds === null || bounds === void 0 ? void 0 : bounds.fullscreen), fullscreen = _g[0], setFullscreen = _g[1];
61
+ // Imperative handle
62
+ var _h = React.useState({
63
+ inProcess: false
64
+ }), inProcess = _h[0], setInProcess = _h[1];
65
+ var setProcessing = function (processing) {
66
+ setInProcess(processing);
67
+ };
68
+ React.useImperativeHandle(ref, function () { return ({
69
+ setProcessing: setProcessing,
70
+ inProcess: inProcess
71
+ }); });
61
72
  (0, react_1.useEffect)(function () {
62
73
  var _a, _b, _c;
63
74
  if (fullscreen) {
@@ -80,7 +91,10 @@ var DialogContentHeader = function (_a) {
80
91
  };
81
92
  if (dialogOptions.slot.header) {
82
93
  // const headerProps = dialogOptions.slotProps.header ? {...dialogOptions.slotProps.header(staticProps)} : {};
83
- console.log('CustomHeader_Content', dialogOptions.slot.header, fullscreen);
94
+ console.log('CustomHeader_Content',
95
+ // dialogOptions.slot.header,
96
+ // fullscreen,
97
+ dialog.isInProcess());
84
98
  var headerProps = dialogOptions.slotProps.header;
85
99
  return (0, jsx_runtime_1.jsx)("div", { onDoubleClick: function (event) {
86
100
  if (baseOptions.fullscreen) {
@@ -110,5 +124,5 @@ var DialogContentHeader = function (_a) {
110
124
  (0, jsx_runtime_1.jsx)(_features_1.DialogInfoAction, {})] }) })] });
111
125
  }
112
126
  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 });
113
- };
127
+ });
114
128
  exports.DialogContentHeader = DialogContentHeader;
@@ -48,6 +48,7 @@ exports.DialogHeaderFooterContext = exports.WithHeaderFooterContext = void 0;
48
48
  var jsx_runtime_1 = require("react/jsx-runtime");
49
49
  var React = __importStar(require("react"));
50
50
  var WithHeaderFooterContext = function (props) {
51
+ console.log('DialogBase_WithHeaderFooterContext', props.dialog.isInProcess());
51
52
  return (0, jsx_runtime_1.jsx)(exports.DialogHeaderFooterContext.Provider, { value: __assign({}, props), children: props.children });
52
53
  };
53
54
  exports.WithHeaderFooterContext = WithHeaderFooterContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.116",
3
+ "version": "1.1.118",
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",
@@ -66,9 +66,13 @@ type TListenerButtonType = Pick<DialogActionBase, Exclude<keyof ActionApiDef, 'o
66
66
  export type TDialogStateListenerForActionCallbackType = (values: Record<string, any>, button: TListenerButtonType, dialog: IListenerDialogDef) => void;
67
67
  export interface IContentFooterProps {
68
68
  }
69
- export interface DialogContentFooterReturnType {
70
- setProcessing: React.Dispatch<React.SetStateAction<boolean>>;
69
+ export interface InProcessType {
71
70
  inProcess: boolean;
71
+ message?: string;
72
+ }
73
+ export interface DialogContentFooterReturnType {
74
+ setProcessing: React.Dispatch<React.SetStateAction<InProcessType>>;
75
+ inProcess: InProcessType;
72
76
  }
73
77
  export interface IActionIntents {
74
78
  positive?: ActionIntent;