react-dialogger 1.1.84 → 1.1.86

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
@@ -22,7 +22,7 @@ Perfect for applications with dynamic forms, async workflows, and advanced UI or
22
22
  To understand why react-dialogger exists and when to use it,
23
23
  see the detailed philosophy document:
24
24
 
25
- 👉 [Dialogger Philosophy](docs/philosophy.md)
25
+ 👉 [Dialogger Philosophy](https://github.com/appinsource2021/react-dialogger-example/blob/main/docs/philosophy.md)
26
26
 
27
27
  # react-dialogger - Custom Dialog Component Documentation
28
28
 
@@ -82,7 +82,7 @@ var DialogActionBase = /** @class */ (function (_super) {
82
82
  __extends(DialogActionBase, _super);
83
83
  function DialogActionBase(props) {
84
84
  if (props === void 0) { props = {}; }
85
- var _a, _b, _c, _d, _e, _f, _g;
85
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
86
86
  var _this = _super.call(this, props) || this; // This ensures that props is treated as readonly
87
87
  _this._options = {
88
88
  label: 'Button label',
@@ -196,13 +196,13 @@ var DialogActionBase = /** @class */ (function (_super) {
196
196
  _this._inProcess = props.inProcess;
197
197
  var converted = (_b = (_a = props.name) === null || _a === void 0 ? void 0 : _a.replace(/action/i, '')) !== null && _b !== void 0 ? _b : props.name;
198
198
  var 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';
199
- var initialIntents = props.dialogBaseComponent.dialogOptions.base.actions.initialIntents;
199
+ var initialIntents = ((_l = (_k = (_j = (_h = props.dialogBaseComponent) === null || _h === void 0 ? void 0 : _h.dialogOptions) === null || _j === void 0 ? void 0 : _j.base) === null || _k === void 0 ? void 0 : _k.actions) !== null && _l !== void 0 ? _l : {}).initialIntents;
200
200
  var mergedIntents = __assign(__assign({}, exports.BASE_INTENTS), initialIntents);
201
201
  _this.state = {
202
202
  coords: { x: -1, y: -1 },
203
203
  isRippling: false,
204
204
  // intent: props.intent,
205
- options: __assign(__assign(__assign({}, props.options), mergedIntents[props.intent]), { label: label }),
205
+ options: __assign(__assign(__assign({}, props.options), mergedIntents[props.intent]), { label: (_m = props.options.label) !== null && _m !== void 0 ? _m : label }),
206
206
  inProcess: false
207
207
  };
208
208
  _this._buttonRef = React.createRef();
@@ -36,7 +36,8 @@ declare class DialogBase<Values extends FormikProps<Values>> extends Component<B
36
36
  private readonly _dialogWithBackDropRef;
37
37
  protected readonly _parent: Dialog;
38
38
  private _accessFrom;
39
- private _processingListeners;
39
+ private readonly _processingListeners;
40
+ private readonly _abortedListeners;
40
41
  constructor(props?: Readonly<BaseDialogProps>);
41
42
  private T;
42
43
  private readonly _features;
@@ -70,6 +71,7 @@ declare class DialogBase<Values extends FormikProps<Values>> extends Component<B
70
71
  };
71
72
  updateBody(body: TDialogCallbackFn): void;
72
73
  processingListener(listener: (inProcess: boolean) => void): this;
74
+ onAbort(callbackFn: TDialogCallbackFn<void>): this;
73
75
  getDom: () => HTMLDivElement;
74
76
  get snackbar(): {
75
77
  open: (message: string, severity: TSeverity, key?: string, action?: IDialogSnackbar["action"], autoHideDuration?: number | null) => void;
@@ -70,7 +70,7 @@ var DialogBase = /** @class */ (function (_super) {
70
70
  __extends(DialogBase, _super);
71
71
  function DialogBase(props) {
72
72
  if (props === void 0) { props = {}; }
73
- var _a;
73
+ var _a, _b;
74
74
  var _this = _super.call(this, props) || this;
75
75
  // ✨✨✨✨✨✨✨✨✨✨✨
76
76
  _this._dialogTranslate = { lastX: 0, lastY: 0 };
@@ -148,13 +148,29 @@ var DialogBase = /** @class */ (function (_super) {
148
148
  return _this._inProcess;
149
149
  };
150
150
  _this.close = function (callbackFn) {
151
+ var handleAbort = function () {
152
+ _this.setState(function (prevState) { return (__assign(__assign({}, prevState), { aborted: true })); });
153
+ setTimeout(function () {
154
+ for (var _i = 0, _a = _this._abortedListeners; _i < _a.length; _i++) {
155
+ var aborted = _a[_i];
156
+ if (typeof aborted === "function") {
157
+ aborted(_this);
158
+ }
159
+ }
160
+ _this.close(callbackFn);
161
+ }, 50);
162
+ };
151
163
  setTimeout(function () {
152
164
  var _a, _b, _c, _d;
153
- if (_this._footerRef.current.inProcess) {
165
+ if (_this._footerRef.current.inProcess && !_this.state.aborted) {
154
166
  var notify = (_a = _this._dialogOptions.base.notifyOnClosing) !== null && _a !== void 0 ? _a : "snackbar";
155
167
  if (notify === "snackbar") {
156
168
  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...';
157
- _this.snackbar.open(busyMessage, "warning");
169
+ _this.snackbar.open(busyMessage, "warning", null, function (key, snackbarRef) { return (0, jsx_runtime_1.jsx)(_components_1.DialogActionBase, { name: 'force_close', onClick: handleAbort, options: {
170
+ label: 'Abort',
171
+ variant: 'text',
172
+ color: '#361540'
173
+ } }); });
158
174
  }
159
175
  else {
160
176
  _this._dialogWithBackDropRef.current.baseZoomEffect();
@@ -191,7 +207,8 @@ var DialogBase = /** @class */ (function (_super) {
191
207
  _this.state = {
192
208
  inProcess: { inProcess: false },
193
209
  prevDialogRect: (0, _helpers_1.dialogRectAuto)(),
194
- body: props.body
210
+ body: props.body,
211
+ aborted: false
195
212
  };
196
213
  var defaultOptions = {
197
214
  base: {
@@ -237,6 +254,7 @@ var DialogBase = /** @class */ (function (_super) {
237
254
  _this._dialogWithBackDropRef = (0, react_1.createRef)();
238
255
  _this._parent = props.parent;
239
256
  _this._processingListeners = (_a = props.processingListeners) !== null && _a !== void 0 ? _a : [];
257
+ _this._abortedListeners = (_b = props.abortedListeners) !== null && _b !== void 0 ? _b : [];
240
258
  _this._features = [];
241
259
  return _this;
242
260
  }
@@ -413,6 +431,11 @@ var DialogBase = /** @class */ (function (_super) {
413
431
  this._processingListeners.push(listener);
414
432
  return this;
415
433
  };
434
+ DialogBase.prototype.onAbort = function (callbackFn) {
435
+ // @ts-ignore
436
+ this._abortedListeners.push(callbackFn);
437
+ return this;
438
+ };
416
439
  Object.defineProperty(DialogBase.prototype, "snackbar", {
417
440
  // Reference: https://notistack.com/api-reference#mutual-props
418
441
  get: function () {
@@ -2,7 +2,8 @@ import * as React from "react";
2
2
  import { DialogAction } from "./DialogAction";
3
3
  import { TInitialHolder, DialogValues, IDialogSize, TDialogStateListenerCallbackType, DialogOptionsType, IDialogApiDef, TDialogCallbackVoidFn, TDialogCallbackFn } from "../types/index.js";
4
4
  declare class Dialog {
5
- private _processingListeners;
5
+ private readonly _processingListeners;
6
+ private readonly _abortedListeners;
6
7
  private _stateListener;
7
8
  private _keyboardListener;
8
9
  private _resizeListener;
@@ -26,6 +27,7 @@ declare class Dialog {
26
27
  * Only from init */
27
28
  stateListener(listener: TDialogStateListenerCallbackType): this;
28
29
  processingListener(listener: (inProcess: boolean) => void): this;
30
+ onAbort(callbackFn: TDialogCallbackFn<void>): this;
29
31
  initialValues(values: DialogValues): this;
30
32
  initialHolder(holder: TInitialHolder): this;
31
33
  keyboardListener(listener: (key: string, dialog: IDialogApiDef) => void): this;
package/models/Dialog.js CHANGED
@@ -54,6 +54,9 @@ var appLogger_1 = require("../helpers/appLogger");
54
54
  var Dialog = /** @class */ (function () {
55
55
  function Dialog(dialogRef, options) {
56
56
  var _this = this;
57
+ // ✨✨✨✨✨✨✨✨✨✨✨
58
+ this._processingListeners = [];
59
+ this._abortedListeners = [];
57
60
  this._headerRef = React.createRef();
58
61
  this.highestZ = function () {
59
62
  var presentationElements = document.querySelectorAll('div[data-family="presentation"]');
@@ -117,7 +120,12 @@ var Dialog = /** @class */ (function () {
117
120
  };
118
121
  Dialog.prototype.processingListener = function (listener) {
119
122
  // @ts-ignore
120
- this._processingListeners = listener;
123
+ this._processingListeners.push(listener);
124
+ return this;
125
+ };
126
+ Dialog.prototype.onAbort = function (callbackFn) {
127
+ // @ts-ignore
128
+ this._abortedListeners.push(callbackFn);
121
129
  return this;
122
130
  };
123
131
  Dialog.prototype.initialValues = function (values) {
@@ -151,7 +159,7 @@ var Dialog = /** @class */ (function () {
151
159
  // Refs
152
160
  headerRef: this._headerRef,
153
161
  // Listeners
154
- stateListener: this._stateListener, keyboardListener: this._keyboardListener, resizeListener: this._resizeListener, processingListeners: this._processingListeners,
162
+ stateListener: this._stateListener, keyboardListener: this._keyboardListener, resizeListener: this._resizeListener, processingListeners: this._processingListeners, abortedListeners: this._abortedListeners,
155
163
  // Others
156
164
  dialogSize: this._dialogSize, initialHolder: this._initialHolder, snackbarAnchor: this._snackbarAnchor, root: root, dom: dom, parent: this }, this._apiRef ? { ref: this._apiRef } : null), { onClose: this._onCloseCallback });
157
165
  // @ts-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.84",
3
+ "version": "1.1.86",
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",
package/styles/dialog.css CHANGED
@@ -210,7 +210,7 @@
210
210
  overflow: clip;
211
211
  }
212
212
  .dialog-main .dialog-header {
213
- min-height: 64px;
213
+ min-height: 3rem;
214
214
  padding: 10px 20px 10px 20px;
215
215
  display: flex;
216
216
  flex: 0;
@@ -276,7 +276,7 @@
276
276
  z-index: 2;
277
277
  }
278
278
  .dialog-main .dialog-footer {
279
- min-height: 64px;
279
+ min-height: 3rem;
280
280
  border-top: 0.5px solid rgba(0, 0, 0, 0.2);
281
281
  padding: 10px 20px 10px 20px;
282
282
  bottom: 0;
@@ -17,7 +17,7 @@ export interface ActionProps {
17
17
  * @see options.label */
18
18
  label?: string;
19
19
  onClick: DialogActionType;
20
- dialogBaseComponent: DialogBase<any>;
20
+ dialogBaseComponent?: DialogBase<any>;
21
21
  /**
22
22
  * @deprecated
23
23
  * @see options.variant */
@@ -43,7 +43,7 @@ export interface ActionProps {
43
43
  baseStyle?: CSSProperties;
44
44
  fontFamily?: string;
45
45
  stateListener?: TDialogStateListenerForActionCallbackType;
46
- intent: ActionIntentsType;
46
+ intent?: ActionIntentsType;
47
47
  }
48
48
  export interface ActionState {
49
49
  isRippling: boolean;
@@ -17,6 +17,12 @@ export interface BaseDialogState {
17
17
  fullscreenMode?: boolean;
18
18
  prevDialogRect: WithBackdrop['prevDialogRect'];
19
19
  body: TDialogCallbackFn;
20
+ /**
21
+ * Indicates whether the operation was aborted by the user or the system.
22
+ * - true: The dialog or background process (e.g., API request) was aborted.
23
+ * - false: The operation is continuing or completed normally.
24
+ */
25
+ aborted: boolean;
20
26
  }
21
27
  export interface DialogFormikAdapter<Values> extends Omit<FormikProps<any>, 'values' | 'setValues' | 'setFieldValue' | 'validateForm' | 'errors'> {
22
28
  values: Values;
@@ -43,6 +49,7 @@ export interface BaseDialogProps {
43
49
  keyboardListener: (key: string, dialog: IDialogApiDef) => void;
44
50
  resizeListener?: (size: IDialogSize, dialog: IDialogApiDef) => void;
45
51
  processingListeners?: Array<(inProcess: boolean) => void>;
52
+ abortedListeners?: Array<(dialog: IDialogApiDef) => void>;
46
53
  }
47
54
  export interface IDialogSize {
48
55
  width?: ITypeWidth | number;
@@ -139,7 +146,7 @@ export type TDialogStateListenerCallbackType = (values: FormikProps<any>['values
139
146
  export type TDialogCallbackFn<T = React.ReactNode | React.ReactElement> = (dialog: IDialogApiDef) => T;
140
147
  export type TDialogHeader = TDialogCallbackFn | React.ReactNode | React.JSX.Element;
141
148
  export type TDialogCallbackVoidFn = TDialogCallbackFn<void>;
142
- export interface IDialogApiDef extends Pick<DialogBase<any>, 'isInProcess' | 'setInProcess' | 'values' | 'setValue' | 'setValues' | 'close' | 'dialogOptions' | 'actions' | 'snackbar' | 'formikValidate' | 'formikProps' | 'focus' | 'updateBody' | 'processingListener' | 'addFeature' | 'getFeature'> {
149
+ export interface IDialogApiDef extends Pick<DialogBase<any>, 'isInProcess' | 'setInProcess' | 'values' | 'setValue' | 'setValues' | 'close' | 'dialogOptions' | 'actions' | 'snackbar' | 'formikValidate' | 'formikProps' | 'focus' | 'updateBody' | 'processingListener' | 'addFeature' | 'getFeature' | 'onAbort'> {
143
150
  }
144
151
  export interface IDialogCloseRef extends Pick<DialogBase<any>, 'close'> {
145
152
  }