react-dialogger 1.1.129 → 1.1.130

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.
@@ -53,7 +53,7 @@ declare class DialogBase<V, I> extends Component<BaseDialogProps<V, I>, BaseDial
53
53
  get accessFrom(): TAccessFrom;
54
54
  initializeActionRef: (key: string) => RefObject<DialogActionBase>;
55
55
  get dialogOptions(): DialogOptionsType;
56
- get holder(): DialogOptionsType;
56
+ get holder(): DialogOptionsType['slot']['loader'];
57
57
  get formikProps(): FormikProps<any>;
58
58
  set formikProps(value: FormikProps<any>);
59
59
  get formikValidate(): Promise<DialogFormikAdapter<any>>;
@@ -69,7 +69,7 @@ var _context_1 = require("../context/index.js");
69
69
  var DialogBase = /** @class */ (function (_super) {
70
70
  __extends(DialogBase, _super);
71
71
  function DialogBase(props) {
72
- var _a, _b;
72
+ var _a, _b, _c, _d, _e;
73
73
  var _this = _super.call(this, props) || this;
74
74
  // ✨✨✨✨✨✨✨✨✨✨✨
75
75
  _this._dialogTranslate = { lastX: 0, lastY: 0 };
@@ -238,13 +238,13 @@ var DialogBase = /** @class */ (function (_super) {
238
238
  _this._bodyRef = React.createRef();
239
239
  _this._inProcess = { inProcess: false };
240
240
  _this._snackbarRef = React.createRef();
241
- _this._holder = props.initialHolder;
241
+ _this._holder = (_c = (_b = (_a = props.initialOptions) === null || _a === void 0 ? void 0 : _a.slot) === null || _b === void 0 ? void 0 : _b.loader) !== null && _c !== void 0 ? _c : props === null || props === void 0 ? void 0 : props.initialHolder;
242
242
  // Initialize _actionRefs as an empty object
243
243
  _this._actionRefs = {};
244
244
  _this._parent = props.parent;
245
245
  _this._dialogWithBackDropRef = (0, react_1.createRef)();
246
- _this._processingListeners = (_a = props.processingListeners) !== null && _a !== void 0 ? _a : [];
247
- _this._abortedListeners = (_b = props.abortedListeners) !== null && _b !== void 0 ? _b : [];
246
+ _this._processingListeners = (_d = props.processingListeners) !== null && _d !== void 0 ? _d : [];
247
+ _this._abortedListeners = (_e = props.abortedListeners) !== null && _e !== void 0 ? _e : [];
248
248
  _this._initialValues = props.initialValues;
249
249
  return _this;
250
250
  }
@@ -176,7 +176,7 @@ var DialogContent = function (props) {
176
176
  y: y / zoom,
177
177
  fullscreen: false
178
178
  }, dialogRef);
179
- }, children: (0, jsx_runtime_1.jsxs)("div", { onBlur: function (event) {
179
+ }, children: (0, jsx_runtime_1.jsx)("div", { onBlur: function (event) {
180
180
  if (dialog.dialogOptions.backdrop.dimOnInactive) {
181
181
  dialogRef.current.classList.add('inactive');
182
182
  }
@@ -207,17 +207,21 @@ var DialogContent = function (props) {
207
207
  // @ts-ignore
208
208
  dialog.props.keyboardListener(e.key, _this);
209
209
  }
210
- }, 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: (_d = baseOptions.size.height) !== null && _d !== void 0 ? _d : 'auto' }, typeof baseOptions.size.width === "number" ? { width: "".concat(baseOptions.size.width, "px") } : { width: "".concat(baseOptions.size.width) }), { outline: 'none', fontFamily: (_e = baseOptions.style.fontFamily) !== null && _e !== void 0 ? _e : 'Arial' }), rect), { alignSelf: (_f = baseOptions.initialAnchor.vertical) !== null && _f !== void 0 ? _f : 'flex-start', justifySelf: (_g = baseOptions.initialAnchor.horizontal) !== null && _g !== void 0 ? _g : 'flex-start', zoom: zoom !== null && zoom !== void 0 ? zoom : 1, overflow: 'unset' }), children: [dialog.dialogOptions.scaleable &&
211
- (0, jsx_runtime_1.jsxs)("div", { className: 'dialog-zoom-root', style: { width: 36 }, children: [(0, jsx_runtime_1.jsxs)("div", { className: 'dialog-zoom-wrapper', children: [(0, jsx_runtime_1.jsx)("div", { className: "zoom-action", onClick: function () {
212
- setZoom(function (prev) { return Number((prev + 0.1).toFixed(2)); }); // 0.6 → 0.7
213
- }, children: (0, jsx_runtime_1.jsx)(PlusIcon_1.default, { size: 22 }) }), (0, jsx_runtime_1.jsx)("div", { className: "zoom-action", onClick: function (event) {
214
- setZoom(function (prev) { return Number((prev - 0.1).toFixed(2)); }); // 0.7 0.6
215
- setTimeout(function () {
216
- event.clientX;
217
- });
218
- }, children: (0, jsx_runtime_1.jsx)(MinusIcon_1.default, { size: 22 }) })] }), (0, jsx_runtime_1.jsxs)("span", { className: 'dialog-zoom-label', children: [(Math.round(zoom * 100)), "%"] })] }), (0, jsx_runtime_1.jsxs)(notistack_1.SnackbarProvider, { ref: snackbarRef, maxSnack: dialog.dialogOptions.snackbar.maxSnack, style: __assign({ width: 'min-content' }, (_j = (_h = dialog.dialogOptions) === null || _h === void 0 ? void 0 : _h.snackbar) === null || _j === void 0 ? void 0 : _j.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) &&
219
- (0, jsx_runtime_1.jsx)(React.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "resizable-handle", style: {
220
- zIndex: parseInt(domZIndex) + 1
221
- }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown, children: (0, jsx_runtime_1.jsx)(_icons_1.ResizeIcon, { color: '#286e94' }) }) })] })] }) });
210
+ }, 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: (_d = baseOptions.size.height) !== null && _d !== void 0 ? _d : 'auto' }, typeof baseOptions.size.width === "number" ? { width: "".concat(baseOptions.size.width, "px") } : { width: "".concat(baseOptions.size.width) }), { outline: 'none', fontFamily: (_e = baseOptions.style.fontFamily) !== null && _e !== void 0 ? _e : 'Arial' }), rect), { alignSelf: (_f = baseOptions.initialAnchor.vertical) !== null && _f !== void 0 ? _f : 'flex-start', justifySelf: (_g = baseOptions.initialAnchor.horizontal) !== null && _g !== void 0 ? _g : 'flex-start', zoom: zoom !== null && zoom !== void 0 ? zoom : 1, overflow: 'hidden' }), children: (0, jsx_runtime_1.jsxs)(notistack_1.SnackbarProvider
211
+ // domRoot={document.getElementById('mirsak')}
212
+ , {
213
+ // domRoot={document.getElementById('mirsak')}
214
+ ref: snackbarRef, maxSnack: dialog.dialogOptions.snackbar.maxSnack, style: __assign({ width: 'min-content' }, (_j = (_h = dialog.dialogOptions) === null || _h === void 0 ? void 0 : _h.snackbar) === null || _j === void 0 ? void 0 : _j.style), children: [dialog.dialogOptions.scaleable &&
215
+ (0, jsx_runtime_1.jsxs)("div", { className: 'dialog-zoom-root', style: { width: 36 }, children: [(0, jsx_runtime_1.jsxs)("div", { className: 'dialog-zoom-wrapper', children: [(0, jsx_runtime_1.jsx)("div", { className: "zoom-action", onClick: function () {
216
+ setZoom(function (prev) { return Number((prev + 0.1).toFixed(2)); }); // 0.6 → 0.7
217
+ }, children: (0, jsx_runtime_1.jsx)(PlusIcon_1.default, { size: 22 }) }), (0, jsx_runtime_1.jsx)("div", { className: "zoom-action", onClick: function (event) {
218
+ setZoom(function (prev) { return Number((prev - 0.1).toFixed(2)); }); // 0.7 0.6
219
+ setTimeout(function () {
220
+ event.clientX;
221
+ });
222
+ }, children: (0, jsx_runtime_1.jsx)(MinusIcon_1.default, { size: 22 }) })] }), (0, jsx_runtime_1.jsxs)("span", { className: 'dialog-zoom-label', children: [(Math.round(zoom * 100)), "%"] })] }), (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) &&
223
+ (0, jsx_runtime_1.jsx)(React.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "resizable-handle", style: {
224
+ zIndex: parseInt(domZIndex) + 1
225
+ }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown, children: (0, jsx_runtime_1.jsx)(_icons_1.ResizeIcon, { color: '#286e94' }) }) })] }) }) });
222
226
  };
223
227
  exports.DialogContent = DialogContent;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
14
  if (k2 === undefined) k2 = k;
4
15
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -50,6 +61,64 @@ var Placeholder = function (_a) {
50
61
  display: placeholder ? 'flex' : 'none',
51
62
  }, children: placeholder });
52
63
  };
64
+ // /**
65
+ // * @deprecated gereksiz render */
66
+ // const PlaceholderWrapper_: React.FC<{dialog: IDialogApiDef, dialogOptions: DialogOptionsType, children: React.ReactNode}> = ({dialog, dialogOptions, children}) => {
67
+ // const bgColor = dialogOptions.base.style.backgroundColor ?
68
+ // dialogOptions.base.style.backgroundColor : "#FFFFFF";
69
+ // const bg = dialogOptions.base.style.background ?
70
+ // dialogOptions.base.style.background : "#FFFFFF";
71
+ //
72
+ // const [inProcess, setInProcess] = React.useState<any>();
73
+ //
74
+ // React.useEffect(() => {
75
+ // dialog.processingListener( inProcess => {
76
+ // setInProcess(dialog.isInProcess);
77
+ // })
78
+ // }, []);
79
+ //
80
+ // const LoaderSlotElement = children ? React.isValidElement(children)
81
+ // ? React.cloneElement( children as React.ReactElement<DialogOptionsType['slotProps']['loader'] & {dialog: IDialogApiDef}>, {
82
+ // ...dialog.dialogOptions.slotProps.loader,
83
+ // dialog
84
+ // })
85
+ // : React.createElement(children as unknown as React.JSXElementConstructor<DialogOptionsType['slotProps']['loader'] & {dialog: IDialogApiDef}>, {
86
+ // ...dialog.dialogOptions.slotProps.loader,
87
+ // dialog
88
+ // }) : null
89
+ //
90
+ // console.log('PlaceholderWrapper', dialog.isInProcess().message)
91
+ //
92
+ // return <div className={'dialog-content-placeholder'} style={{
93
+ // backgroundColor: bgColor,
94
+ // background: bg,
95
+ // display: "flex"
96
+ // }}>
97
+ // {/*{children}*/}
98
+ // {LoaderSlotElement}
99
+ // </div>
100
+ // }
101
+ var PlaceholderWrapper = function (_a) {
102
+ var _b;
103
+ var dialog = _a.dialog, dialogOptions = _a.dialogOptions, children = _a.children;
104
+ var _c = React.useState(dialog.isInProcess()), inProcess = _c[0], setInProcess = _c[1];
105
+ React.useEffect(function () {
106
+ var unsubscribe = dialog.processingListener(function () {
107
+ setInProcess(dialog.isInProcess());
108
+ });
109
+ // return () => (unsubscribe as any)?.()
110
+ }, [dialog]);
111
+ var initialElement = React.useState(function () {
112
+ if (!children)
113
+ return null;
114
+ return React.isValidElement(children) ? children : React.createElement(children, {});
115
+ })[0];
116
+ var LoaderSlotElement = initialElement
117
+ ? React.cloneElement(initialElement, __assign(__assign({}, dialog.dialogOptions.slotProps.loader), { values: dialog.values, inProcess: dialog.isInProcess() }))
118
+ : null;
119
+ var backgroundColor = (_b = dialogOptions.base.style.backgroundColor) !== null && _b !== void 0 ? _b : "#FFFFFF";
120
+ return (0, jsx_runtime_1.jsx)("div", { className: 'dialog-content-placeholder', style: { display: 'flex', backgroundColor: backgroundColor }, children: LoaderSlotElement });
121
+ };
53
122
  // const DialogContentBody: React.FC<IContentBodyProps> = React.forwardRef(({
54
123
  // body
55
124
  // }, ref ) => {
@@ -67,8 +136,18 @@ var DialogContentBody = React.forwardRef(function (_a, ref) {
67
136
  setProcessing: setProcessing,
68
137
  inProcess: inProcess
69
138
  }); });
139
+ // const LoaderSlotElement = dialog.holder ? React.isValidElement(dialog.holder)
140
+ // ? React.cloneElement( dialog.holder as React.ReactElement<DialogOptionsType['slotProps']['loader'] & {dialog: IDialogApiDef}>, {
141
+ // ...dialog.dialogOptions.slotProps.loader,
142
+ // dialog
143
+ // })
144
+ // : React.createElement(dialog.holder as JSXElementConstructor<DialogOptionsType['slotProps']['loader'] & {dialog: IDialogApiDef}>, {
145
+ // ...dialog.dialogOptions.slotProps.loader,
146
+ // dialog
147
+ // }) : null
148
+ console.log('LoaderSlotElement', dialog.isInProcess());
70
149
  if (body instanceof Function) {
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)] });
150
+ 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)] });
72
151
  }
73
152
  return (0, jsx_runtime_1.jsx)("div", { className: 'dialog-body', style: { height: '100%', padding: 10 }, children: dialog.holder ?
74
153
  (0, jsx_runtime_1.jsx)(Placeholder, { dialogOptions: dialog.dialogOptions, placeholder: dialog.holder })
@@ -37,6 +37,7 @@ declare class Dialog<V, I> {
37
37
  stateListener(listener: TDialogStateListenerCallbackType): this;
38
38
  processingListener(listener: (inProcess: boolean) => void): this;
39
39
  onAbort(callbackFn: TDialogCallbackFn<V, I, void>): this;
40
+ /**@deprecated use slot.loader instead */
40
41
  initialHolder(holder: TInitialHolder): this;
41
42
  keyboardListener(listener: (key: string, dialog: IDialogApiDef) => void): this;
42
43
  resizeListener(listener: (size: IDialogSize, dialog: IDialogApiDef) => void): this;
package/models/Dialog.js CHANGED
@@ -155,6 +155,7 @@ var Dialog = /** @class */ (function () {
155
155
  this._abortedListeners.push(callbackFn);
156
156
  return this;
157
157
  };
158
+ /**@deprecated use slot.loader instead */
158
159
  Dialog.prototype.initialHolder = function (holder) {
159
160
  this._initialHolder = holder;
160
161
  return this;
@@ -76,7 +76,7 @@ var BASE_DIALOG_OPTIONS = {
76
76
  busyMessage: "Please wait...",
77
77
  },
78
78
  slot: {
79
- action: undefined,
79
+ action: undefined
80
80
  },
81
81
  slotProps: {
82
82
  action: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.129",
3
+ "version": "1.1.130",
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",
@@ -41,6 +41,7 @@ export interface BaseDialogProps<V extends Record<string, any>, I> {
41
41
  didMountCallback?: TDialogCallbackFn<V, I, void>;
42
42
  dialogSize?: IDialogSize;
43
43
  stateListener: TDialogStateListenerCallbackType;
44
+ /**@deprecated use slot.loader instead */
44
45
  initialHolder: TInitialHolder;
45
46
  snackbarAnchor?: ISnackbarAnchor;
46
47
  dom: HTMLDivElement;
@@ -90,6 +91,7 @@ interface kSlot {
90
91
  action?: React.JSXElementConstructor<any>;
91
92
  footer?: React.JSXElementConstructor<any>;
92
93
  header?: React.JSXElementConstructor<any>;
94
+ loader?: React.JSXElementConstructor<any>;
93
95
  }
94
96
  interface kSlotProps {
95
97
  action?: {
@@ -98,6 +100,7 @@ interface kSlotProps {
98
100
  };
99
101
  footer?: Record<string, any>;
100
102
  header?: Record<string, any>;
103
+ loader?: Record<string, any>;
101
104
  }
102
105
  export interface IBaseDialogOptions {
103
106
  closeable?: boolean;
@@ -236,7 +239,7 @@ export interface IBackdropOptions {
236
239
  dimOnInactive?: boolean;
237
240
  }
238
241
  export type TNotifyOnClosing = "snackbar" | "zoom" | undefined;
239
- export type TInitialHolder = any;
242
+ export type TInitialHolder = kSlot['loader'];
240
243
  export type TLoaderHolder = any;
241
244
  export interface IInProcess {
242
245
  inProcess: boolean;