react-dialogger 1.1.133 → 1.1.135

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.
@@ -70,7 +70,7 @@ declare class DialogBase<V, I> extends Component<BaseDialogProps<V, I>, BaseDial
70
70
  [key: string]: ActionApiDef;
71
71
  };
72
72
  updateBody(body: TDialogCallbackFn<V, I>): void;
73
- processingListener(listener: (inProcess: boolean) => void): this;
73
+ processingListener(listener: (inProcess: boolean, message: string) => void): this;
74
74
  onAbort(callbackFn: TDialogCallbackFn<V, I, void>): this;
75
75
  getDom: () => HTMLDivElement;
76
76
  get snackbar(): {
@@ -88,14 +88,13 @@ var DialogBase = /** @class */ (function (_super) {
88
88
  _this.setInProcess = function (process, message, holder) {
89
89
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
90
90
  _this._inProcess = __assign({ inProcess: process }, message ? { message: message } : {});
91
- if (!process) {
92
- _this._holder = null;
93
- }
94
- else {
95
- if (holder) {
96
- _this._holder = holder;
97
- }
98
- }
91
+ // if(!process){
92
+ // this._holder = null;
93
+ // } else {
94
+ // if(holder){
95
+ // this._holder = holder;
96
+ // }
97
+ // }
99
98
  if ((_b = (_a = _this._dialogOptions.base) === null || _a === void 0 ? void 0 : _a.actions) === null || _b === void 0 ? void 0 : _b.disabledOnDialogProcessing) {
100
99
  if (process) {
101
100
  for (var actionKey in _this._actionRefs) {
@@ -125,7 +124,7 @@ var DialogBase = /** @class */ (function (_super) {
125
124
  for (var _i = 0, _m = _this._processingListeners; _i < _m.length; _i++) {
126
125
  var listener = _m[_i];
127
126
  if (typeof listener === "function") {
128
- listener(process);
127
+ listener(process, message);
129
128
  }
130
129
  }
131
130
  console.log('setInProcess_process', process);
@@ -99,34 +99,33 @@ var Placeholder = function (_a) {
99
99
  // </div>
100
100
  // }
101
101
  var PlaceholderWrapper = function (_a) {
102
- var _b, _c, _d;
102
+ var _b, _c;
103
103
  var dialog = _a.dialog, dialogOptions = _a.dialogOptions, children = _a.children;
104
+ var _d = (_b = dialog.dialogOptions.slotProps.loader) !== null && _b !== void 0 ? _b : { message: null }, message = _d.message, loading = _d.loading;
104
105
  var _e = React.useState({
105
- message: (_c = (_b = dialog.dialogOptions.slotProps.loader) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : null,
106
- inProcess: true
106
+ message: message,
107
+ loading: typeof loading === "boolean" ? loading : true
107
108
  }), inProcess = _e[0], setInProcess = _e[1];
108
109
  React.useEffect(function () {
109
- var unsubscribe = dialog.processingListener(function (processing) {
110
- if (inProcess.inProcess !== processing) {
111
- if (!processing) {
112
- setTimeout(function () { return setInProcess(dialog.isInProcess()); }, 300);
113
- return;
114
- }
115
- setInProcess(dialog.isInProcess());
116
- }
110
+ dialog.processingListener(function (processing, message) {
111
+ console.log('PlaceholderWrapper_useEffect_processingListener', processing, message);
112
+ setInProcess({
113
+ message: message,
114
+ loading: processing
115
+ });
117
116
  });
118
- // return () => (unsubscribe as any)?.()
119
117
  }, [dialog]);
120
118
  var initialElement = React.useState(function () {
121
119
  if (!children)
122
120
  return null;
123
121
  return React.isValidElement(children) ? children : React.createElement(children, {});
124
122
  })[0];
123
+ console.log('PlaceholderWrapper_useEffect_processingListener_2', inProcess.loading);
125
124
  var LoaderSlotElement = initialElement
126
125
  ? React.cloneElement(initialElement, __assign(__assign({}, dialog.dialogOptions.slotProps.loader), { values: dialog.values, inProcess: dialog.isInProcess() }))
127
126
  : null;
128
- var backgroundColor = (_d = dialogOptions.base.style.backgroundColor) !== null && _d !== void 0 ? _d : "#FFFFFF";
129
- return (0, jsx_runtime_1.jsx)("div", { className: 'dialog-content-placeholder', style: { display: inProcess.inProcess ? 'flex' : 'none', backgroundColor: backgroundColor }, children: LoaderSlotElement });
127
+ var backgroundColor = (_c = dialogOptions.base.style.backgroundColor) !== null && _c !== void 0 ? _c : "#FFFFFF";
128
+ return (0, jsx_runtime_1.jsx)("div", { className: 'dialog-content-placeholder', style: { display: inProcess.loading ? 'flex' : 'none', backgroundColor: backgroundColor }, children: LoaderSlotElement });
130
129
  };
131
130
  // const DialogContentBody: React.FC<IContentBodyProps> = React.forwardRef(({
132
131
  // body
@@ -145,23 +144,29 @@ var DialogContentBody = React.forwardRef(function (_a, ref) {
145
144
  setProcessing: setProcessing,
146
145
  inProcess: inProcess
147
146
  }); });
148
- // const LoaderSlotElement = dialog.holder ? React.isValidElement(dialog.holder)
149
- // ? React.cloneElement( dialog.holder as React.ReactElement<DialogOptionsType['slotProps']['loader'] & {dialog: IDialogApiDef}>, {
150
- // ...dialog.dialogOptions.slotProps.loader,
151
- // dialog
152
- // })
153
- // : React.createElement(dialog.holder as JSXElementConstructor<DialogOptionsType['slotProps']['loader'] & {dialog: IDialogApiDef}>, {
154
- // ...dialog.dialogOptions.slotProps.loader,
155
- // dialog
156
- // }) : null
157
- console.log('LoaderSlotElement', dialog.isInProcess());
158
- if (body instanceof Function) {
159
- return (0, jsx_runtime_1.jsxs)("div", { className: 'dialog-body', style: { height: '100%' }, children: [dialog.holder && (0, jsx_runtime_1.jsx)(PlaceholderWrapper, { dialog: dialog, dialogOptions: dialog.dialogOptions, children: dialog.holder }), body(dialog)] });
160
- }
161
- return (0, jsx_runtime_1.jsx)("div", { className: 'dialog-body', style: { height: '100%', padding: 10 }, children: dialog.holder ?
162
- // <Placeholder dialogOptions={dialog.dialogOptions} placeholder={dialog.holder} />
163
- (0, jsx_runtime_1.jsx)(PlaceholderWrapper, { dialog: dialog, dialogOptions: dialog.dialogOptions, children: dialog.holder })
164
- :
165
- body });
147
+ return (0, jsx_runtime_1.jsxs)("div", { className: 'dialog-body', style: { height: '100%' }, children: [dialog.holder &&
148
+ (0, jsx_runtime_1.jsx)(PlaceholderWrapper, { dialog: dialog, dialogOptions: dialog.dialogOptions, children: dialog.holder }), body(dialog)] });
149
+ // if(body instanceof Function){
150
+ // return <div className={'dialog-body'} style={{ height: '100%'}}>
151
+ // {/*{dialog.holder && <Placeholder dialogOptions={dialog.dialogOptions} placeholder={dialog.holder} />}*/}
152
+ // {
153
+ // dialog.holder &&
154
+ // <PlaceholderWrapper dialog={dialog} dialogOptions={dialog.dialogOptions}>
155
+ // {dialog.holder as any}
156
+ // </PlaceholderWrapper>
157
+ // }
158
+ // {body(dialog)}
159
+ // </div>
160
+ // }
161
+ // return <div className={'dialog-body'} style={{height: '100%', padding: 10}} >
162
+ // {
163
+ // dialog.holder ?
164
+ // // <Placeholder dialogOptions={dialog.dialogOptions} placeholder={dialog.holder} />
165
+ // <PlaceholderWrapper dialog={dialog} dialogOptions={dialog.dialogOptions}>
166
+ // {dialog.holder as any}
167
+ // </PlaceholderWrapper>
168
+ // :
169
+ // body }
170
+ // </div>
166
171
  });
167
172
  exports.DialogContentBody = DialogContentBody;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.133",
3
+ "version": "1.1.135",
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",
@@ -50,7 +50,7 @@ export interface BaseDialogProps<V extends Record<string, any>, I> {
50
50
  root?: any;
51
51
  keyboardListener: (key: string, dialog: IDialogApiDef<V, I>) => void;
52
52
  resizeListener?: (size: IDialogSize, dialog: IDialogApiDef<V, I>) => void;
53
- processingListeners?: Array<(inProcess: boolean) => void>;
53
+ processingListeners?: Array<(inProcess: boolean, message: string) => void>;
54
54
  abortedListeners?: Array<(dialog: IDialogApiDef<V, I>) => void>;
55
55
  zFinder: () => number;
56
56
  }
@@ -102,6 +102,7 @@ interface kSlotProps {
102
102
  header?: Record<string, any>;
103
103
  loader?: {
104
104
  message?: string;
105
+ loading?: boolean;
105
106
  [key: string]: any;
106
107
  };
107
108
  }