react-dialogger 1.1.22 → 1.1.23

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.
@@ -64,6 +64,7 @@ declare class DialogBase extends Component<BaseDialogProps, BaseDialogState> {
64
64
  * which is not assignable to that type.
65
65
  * */
66
66
  private readonly _fontFamily;
67
+ private _storedBounds;
67
68
  constructor(props?: Readonly<BaseDialogProps>);
68
69
  get fullscreenMode(): boolean;
69
70
  private initializeActionRef;
@@ -81,7 +82,6 @@ declare class DialogBase extends Component<BaseDialogProps, BaseDialogState> {
81
82
  private dialogAutoPos;
82
83
  componentDidMount(): void;
83
84
  onResize(callbackFn: (size: IDialogSize, dialog: IDialogDef) => void): void;
84
- componentDidUpdate(prevProps: Readonly<BaseDialogProps>, prevState: Readonly<BaseDialogState>, snapshot?: any): void;
85
85
  componentWillUnmount(): void;
86
86
  setState<K extends keyof BaseDialogState>(state: ((prevState: Readonly<BaseDialogState>, props: Readonly<BaseDialogProps>) => (Pick<BaseDialogState, K> | BaseDialogState | null)) | Pick<BaseDialogState, K> | BaseDialogState | null, callback?: () => void): void;
87
87
  protected setHeader(header: TDialogCallbackNodeFn): DialogBase;
@@ -65,6 +65,8 @@ var client_1 = require("react-dom/client");
65
65
  var Resizeable_1 = __importDefault(require("../models/Resizeable"));
66
66
  var ResizeIcon_1 = __importDefault(require("./icons/ResizeIcon"));
67
67
  var Futures_1 = require("./Futures");
68
+ // Bounds methods
69
+ var helpers_1 = require("../helpers");
68
70
  var WithSnackbar = function (props) {
69
71
  return (0, jsx_runtime_1.jsx)(notistack_1.SnackbarProvider, { ref: props.snackbarRef, maxSnack: props.maxSnack, children: props.children });
70
72
  };
@@ -87,11 +89,12 @@ var hexToRgb = function (hex, opacity) {
87
89
  return '';
88
90
  };
89
91
  exports.DialogHeaderFooterContext = React.createContext(null);
92
+ // export const DialogContext = React.createContext(null);
90
93
  var DialogBase = /** @class */ (function (_super) {
91
94
  __extends(DialogBase, _super);
92
95
  function DialogBase(props) {
93
96
  if (props === void 0) { props = {}; }
94
- var _a;
97
+ var _a, _b;
95
98
  var _this = _super.call(this, props) || this; // This ensures that props is treated as readonly
96
99
  _this._dialogTranslate = { lastX: 0, lastY: 0 };
97
100
  _this._shInterval = 300;
@@ -297,6 +300,7 @@ var DialogBase = /** @class */ (function (_super) {
297
300
  return _this._dialogSize;
298
301
  };
299
302
  _this.baseZoomEffect = function () {
303
+ console.log('this._dialogTranslate', _this._dialogTranslate);
300
304
  var _a = _this._dialogTranslate, lastX = _a.lastX, lastY = _a.lastY;
301
305
  _this._dialogRef.current.animate([
302
306
  // key frames
@@ -521,9 +525,26 @@ var DialogBase = /** @class */ (function (_super) {
521
525
  console.log('Content:', actions);
522
526
  var xKey = _this.dialogPosFromMultipleDialogs.isMultiple ? "left" : "marginLeft";
523
527
  var yKey = _this.dialogPosFromMultipleDialogs.isMultiple ? "top" : "marginTop";
528
+ /**
529
+ * default null
530
+ * eget momoize islemi uygulanmissa read from memory
531
+ * */
532
+ var bounds = _this._storedBounds;
524
533
  return (0, jsx_runtime_1.jsx)(react_draggable_1.default, { disabled: !_this._draggable || _this.state.fullscreenMode, axis: 'both', handle: _this._draggable ? '.drag-handle' : '', scale: 1, ref: _this._backdropRef, onDrag: function (event, data) {
525
534
  event.stopPropagation();
526
535
  _this._dialogTranslate = { lastX: data.lastX, lastY: data.lastY };
536
+ }, onStop: function (event, data) {
537
+ var _a;
538
+ event.stopPropagation();
539
+ event.preventDefault();
540
+ console.log('onDragStop', 'fired');
541
+ var _b = (_a = _this._dialogRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(), width = _b.width, height = _b.height, x = _b.x, y = _b.y;
542
+ (0, helpers_1.setDialogBounds)(_this._dialogOptions.base.id, {
543
+ width: width,
544
+ height: height,
545
+ x: x,
546
+ y: y
547
+ }, _this._dialogRef);
527
548
  }, children: (0, jsx_runtime_1.jsxs)("div", { id: "dialog-main", ref: _this._dialogRef, onClick: function (e) {
528
549
  e.stopPropagation();
529
550
  }, onKeyDown: function (e) {
@@ -533,9 +554,13 @@ var DialogBase = /** @class */ (function (_super) {
533
554
  }
534
555
  },
535
556
  // className={this._dialogSize.width === 'auto' ? 'auto' : `dialog-width-${this._dialogSize.width} dialog-main show-opacity show-position-${this._dialogOptions.base.initialAnchor.vertical}`}
536
- className: _this._dialogOptions.base.size.width === 'auto' ? 'auto' : "dialog-width-".concat(_this._dialogOptions.base.size.width, " dialog-main show-opacity show-position-").concat(_this._dialogOptions.base.initialAnchor.vertical), style: __assign(__assign(__assign(__assign({ alignSelf: _this._dialogOptions.base.initialAnchor.vertical, height: (_b = _this._dialogOptions.base.size.height) !== null && _b !== void 0 ? _b : 'auto' }, typeof _this._dialogOptions.base.size.width === "number" ? { width: _this._dialogOptions.base.size.width } : null), (_a = { outline: 'none' }, _a[yKey] = _this.dialogPosFromMultipleDialogs.top + 'px', _a[xKey] = _this.dialogPosFromMultipleDialogs.left + 'px', _a)), _this._dialogOptions.base.style), { fontFamily: _this._fontFamily }), children: [(0, jsx_runtime_1.jsxs)(WithSnackbar, { snackbarRef: _this._snackbarRef, maxSnack: _this._dialogOptions.snackbar.maxSnack, children: [(_this._header || _this._dialogOptions.slot.header) && _this.Header(header), _this.Body(body), (0, jsx_runtime_1.jsx)(_this.Footer, { ref: _this._footeRef, actions: actions })] }), (_this._dialogOptions.base.resizeable) &&
557
+ className: _this._dialogOptions.base.size.width === 'auto' ? 'auto' : "dialog-width-".concat(_this._dialogOptions.base.size.width, " dialog-main show-opacity show-position-").concat(_this._dialogOptions.base.initialAnchor.vertical), style: __assign(__assign(__assign(__assign(__assign({ alignSelf: _this._dialogOptions.base.initialAnchor.vertical, height: (_b = _this._dialogOptions.base.size.height) !== null && _b !== void 0 ? _b : 'auto' }, typeof _this._dialogOptions.base.size.width === "number" ? { width: _this._dialogOptions.base.size.width } : null), (_a = { outline: 'none' }, _a[yKey] = _this.dialogPosFromMultipleDialogs.top + 'px', _a[xKey] = _this.dialogPosFromMultipleDialogs.left + 'px', _a)), _this._dialogOptions.base.style), { fontFamily: _this._fontFamily }), bounds ? { position: 'absolute', top: bounds.y, left: bounds.x, width: bounds.width, height: bounds.height } : null), children: [(0, jsx_runtime_1.jsxs)(WithSnackbar, { snackbarRef: _this._snackbarRef, maxSnack: _this._dialogOptions.snackbar.maxSnack, children: [(_this._header || _this._dialogOptions.slot.header) && _this.Header(header), _this.Body(body), (0, jsx_runtime_1.jsx)(_this.Footer, { ref: _this._footeRef, actions: actions })] }), (_this._dialogOptions.base.resizeable) &&
537
558
  (0, jsx_runtime_1.jsx)(React.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "resizable-handle", onMouseDown: (_c = _this._Resizeable) === null || _c === void 0 ? void 0 : _c.resizeHandleMouseDown, children: (0, jsx_runtime_1.jsx)(ResizeIcon_1.default, { color: '#286e94' }) }) })] }) });
538
559
  };
560
+ // render = () => {
561
+ //
562
+ // return this.withBackdrop(this._body, this._header, this._actions)
563
+ // }
539
564
  _this.render = function () {
540
565
  return _this.withBackdrop(_this._body, _this._header, _this._actions);
541
566
  };
@@ -598,6 +623,10 @@ var DialogBase = /** @class */ (function (_super) {
598
623
  // this._slots = this._dialogOptions.base.slots
599
624
  _this._initialValues = props.initialValues;
600
625
  _this._resizeListenersStore = [];
626
+ // Fetch Initial Dialog Bounds
627
+ var base = _this._dialogOptions.base;
628
+ var memoBounds = base.memoBounds;
629
+ _this._storedBounds = ((_b = _this._dialogOptions.base) === null || _b === void 0 ? void 0 : _b.memoBounds) ? (0, helpers_1.getDialogBounds)(base) : null;
601
630
  return _this;
602
631
  }
603
632
  Object.defineProperty(DialogBase.prototype, "parent", {
@@ -680,9 +709,10 @@ var DialogBase = /** @class */ (function (_super) {
680
709
  };
681
710
  DialogBase.prototype.componentDidMount = function () {
682
711
  var _this = this;
683
- var _a, _b;
712
+ var _a, _b, _c, _d;
713
+ console.log('clalisan componentDidMount');
684
714
  // İlk konumları global seçeneklerden al
685
- var _c = this._dialogOptions.snackbar.anchorOrigin, vertical = _c.vertical, horizontal = _c.horizontal;
715
+ var _e = this._dialogOptions.snackbar.anchorOrigin, vertical = _e.vertical, horizontal = _e.horizontal;
686
716
  var initialAnchor = { vertical: vertical, horizontal: horizontal };
687
717
  // Kullanıcı tanımlı konumlar varsa, onları ilk konumlarla birleştir
688
718
  this._snackbarAnchor = __assign(__assign(__assign({}, initialAnchor), (((_a = this.props.snackbarAnchor) === null || _a === void 0 ? void 0 : _a.vertical) ? { vertical: this.props.snackbarAnchor.vertical } : {})), (((_b = this.props.snackbarAnchor) === null || _b === void 0 ? void 0 : _b.horizontal) ? { horizontal: this.props.snackbarAnchor.horizontal } : {}));
@@ -710,7 +740,7 @@ var DialogBase = /** @class */ (function (_super) {
710
740
  this._dialogRef.current.tabIndex = 0; // Odaklanabilir hale getirir
711
741
  this._dialogRef.current.focus();
712
742
  if (this._Resizeable) {
713
- this._Resizeable.setContainer(this._dialogRef.current);
743
+ this._Resizeable.setContainer(this._dialogRef, this._dialogOptions);
714
744
  this._Resizeable.onResizeListener(function (width, height) {
715
745
  if (typeof _this.props.resizeListener === "function") {
716
746
  _this._resizeListenersStore.push(_this.props.resizeListener);
@@ -736,6 +766,28 @@ var DialogBase = /** @class */ (function (_super) {
736
766
  // }
737
767
  // Parent objesinin accessFrom özelliğini ayarla
738
768
  this.props.parent.accessFrom = "internal";
769
+ // Check This
770
+ try {
771
+ var t = window.localStorage.getItem('react-super-dialog');
772
+ console.log('Parsed Bounds Store', JSON.parse(t));
773
+ }
774
+ catch (e) {
775
+ }
776
+ // Register Dialog Bounds
777
+ if ((_c = this._dialogOptions.base) === null || _c === void 0 ? void 0 : _c.memoBounds) {
778
+ if (!helpers_1.InitDialogMemoizeBoundsDeclared) {
779
+ throw new Error('InitDialogMemoizeBounds is not defined. Please make sure to declare it only once, at the top‑level of your module—outside of App or its render logic.\n' +
780
+ 'InitDialogMemoizeBounds()\n' +
781
+ 'const App() => {...');
782
+ }
783
+ var _f = (_d = this._dialogRef.current) === null || _d === void 0 ? void 0 : _d.getBoundingClientRect(), width = _f.width, height = _f.height, x = _f.x, y = _f.y;
784
+ (0, helpers_1.dialogRegister)(this._dialogOptions.base, {
785
+ width: width,
786
+ height: height,
787
+ x: x,
788
+ y: y
789
+ });
790
+ }
739
791
  };
740
792
  DialogBase.prototype.onResize = function (callbackFn) {
741
793
  if (typeof callbackFn === "function") {
@@ -743,32 +795,8 @@ var DialogBase = /** @class */ (function (_super) {
743
795
  // Bu olay overwite olmasinin onune gecer
744
796
  // Cunku en sonku callback calistirildigi icin ornedin header ve
745
797
  this._resizeListenersStore.push(callbackFn);
746
- // if(this._Resizeable){
747
- // this._Resizeable.onResizeListener((width, height) => {
748
- // // @ts-ignore
749
- // callbackFn({width, height}, this);
750
- // });
751
- // }
752
798
  }
753
799
  };
754
- // onResize: (callbackFn: (size: IDialogSize, dialog: IDialogDef) => void){
755
- // if(typeof callbackFn === "function"){
756
- //
757
- // }
758
- // }
759
- DialogBase.prototype.componentDidUpdate = function (prevProps, prevState, snapshot) {
760
- /*if(this._dialogRef.current && this._dialogOptions.base.resizeable && !this._Resizeable){
761
- console.log('this._Resizeable.onResizeListener', this._Resizeable );
762
-
763
- this._Resizeable.onResizeListener((width, height) => {
764
- console.log('this._Resizeable.onResizeListener', width, height );
765
- this._dialogRef.current.style.width = width + 'px';
766
- this._dialogRef.current.style.height = height + 'px';
767
- })
768
- }*/
769
- };
770
- // getSnapshotBeforeUpdate(prevProps: Readonly<BaseDialogProps>, prevState: Readonly<BaseDialogState>): any {
771
- // }
772
800
  DialogBase.prototype.componentWillUnmount = function () {
773
801
  if (this._Resizeable) {
774
802
  // Temizlik fonksiyonu
@@ -921,8 +949,10 @@ var DialogBase = /** @class */ (function (_super) {
921
949
  this._dom.classList.add('appinsource-dialog-root');
922
950
  // Find root element
923
951
  var rootElement = document.getElementById('root');
952
+ var AppElement = rootElement.firstElementChild;
924
953
  if (rootElement) {
925
- rootElement.appendChild(this._dom);
954
+ // rootElement.appendChild(this._dom);
955
+ AppElement.prepend(this._dom);
926
956
  }
927
957
  else {
928
958
  document.body.appendChild(this._dom);
@@ -0,0 +1,20 @@
1
+ import { IBaseDialogOptions } from "../types/DialogTypes";
2
+ /**
3
+ * RAM den okuyoruz...
4
+ * */
5
+ declare const dialogInStore: (options: IBaseDialogOptions) => IDialogBoundDef | undefined;
6
+ declare const dialogRegister: (options: IBaseDialogOptions, initialBounds: IDialogBoundsDef) => IDialogBoundsDef;
7
+ declare const getDialogBounds: (options: IBaseDialogOptions) => IDialogBoundsDef | undefined;
8
+ declare const setDialogBounds: (dialogId: string, bounds: IDialogBoundsDef, dialogRef: React.RefObject<any>) => void;
9
+ export { dialogRegister, getDialogBounds, setDialogBounds, dialogInStore };
10
+ export type IDialogBoundsMemoKey = string | number;
11
+ export interface IDialogBoundsDef {
12
+ width: number;
13
+ height: number;
14
+ x: number;
15
+ y: number;
16
+ }
17
+ export interface IDialogBoundDef {
18
+ id: string;
19
+ bounds: IDialogBoundsDef;
20
+ }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dialogInStore = exports.setDialogBounds = exports.getDialogBounds = exports.dialogRegister = void 0;
4
+ var initDialogMemoizeBounds_1 = require("../hooks/initDialogMemoizeBounds");
5
+ var BOUNDS_STORE_KEY = 'react-super-dialog';
6
+ // const boundStoreExists = () => {
7
+ // try{
8
+ // return !!window.localStorage.getItem(BOUNDS_STORE_KEY);
9
+ // } catch (e){
10
+ // return false;
11
+ // }
12
+ // }
13
+ // const createBoundStore = () => {
14
+ // if (!boundStoreExists()) {
15
+ // try{
16
+ // window.localStorage.setItem(BOUNDS_STORE_KEY, JSON.stringify([]));
17
+ // } catch (e){
18
+ // console.log(e);
19
+ // }
20
+ // }
21
+ // }
22
+ /**
23
+ * RAM den okuyoruz...
24
+ * */
25
+ var dialogInStore = function (options) {
26
+ var stores = initDialogMemoizeBounds_1.registeredDialogs;
27
+ console.log('dialogInStoreX1', stores);
28
+ if (!stores)
29
+ return undefined;
30
+ var parsedStores = stores; // JSON.parse(stores);
31
+ var foundedStore = parsedStores.find(function (store) { return store.id === options.id; });
32
+ return foundedStore;
33
+ };
34
+ exports.dialogInStore = dialogInStore;
35
+ var dialogRegister = function (options, initialBounds) {
36
+ console.log('Regsister fired!!!', options);
37
+ if (dialogInStore(options))
38
+ return;
39
+ if (!options.id) {
40
+ throw new Error('Dialog bounds can not be memoized. Dialog id is required.');
41
+ }
42
+ // createBoundStore();
43
+ var newBounds = {
44
+ id: options.id,
45
+ bounds: {
46
+ width: initialBounds.width,
47
+ height: initialBounds.height,
48
+ x: initialBounds.x,
49
+ y: initialBounds.y + 100
50
+ }
51
+ };
52
+ var foundedDialog = initDialogMemoizeBounds_1.registeredDialogs.find(function (b) { return b.id === options.id; });
53
+ console.log('foundedDialog', foundedDialog);
54
+ if (!foundedDialog) {
55
+ initDialogMemoizeBounds_1.registeredDialogs.push(newBounds);
56
+ }
57
+ console.log('foundedDialog_2', initDialogMemoizeBounds_1.registeredDialogs);
58
+ // Register to Cookie
59
+ try {
60
+ window.localStorage.setItem(BOUNDS_STORE_KEY, JSON.stringify(initDialogMemoizeBounds_1.registeredDialogs));
61
+ }
62
+ catch (e) {
63
+ console.log(e);
64
+ }
65
+ // registeredDialogs.push(newBounds);
66
+ console.log('Dialog_Bounds, initialBounds-A', initialBounds);
67
+ var bounds = getDialogBounds(options);
68
+ return bounds;
69
+ };
70
+ exports.dialogRegister = dialogRegister;
71
+ var getDialogBounds = function (options) {
72
+ var dialog = dialogInStore(options);
73
+ if (!options.id) {
74
+ throw new Error('Dialog bounds can not be memoized. Dialog id is required.');
75
+ }
76
+ // Eget local vaiable icinde bulunamassa localStorage'dan al
77
+ if (!dialog) {
78
+ var boundsRaw = window.localStorage.getItem(BOUNDS_STORE_KEY);
79
+ var boundsArray = boundsRaw ? JSON.parse(boundsRaw) : [];
80
+ var founded = boundsArray.find(function (b) { return b.id === options.id; });
81
+ if (founded) {
82
+ return {
83
+ width: founded.bounds.width,
84
+ height: founded.bounds.height,
85
+ x: founded.bounds.x,
86
+ y: founded.bounds.y
87
+ };
88
+ }
89
+ }
90
+ if (dialog) {
91
+ return {
92
+ width: dialog.bounds.width,
93
+ height: dialog.bounds.height,
94
+ x: dialog.bounds.x,
95
+ y: dialog.bounds.y
96
+ };
97
+ }
98
+ return undefined;
99
+ };
100
+ exports.getDialogBounds = getDialogBounds;
101
+ var setDialogBounds = function (dialogId, bounds, dialogRef) {
102
+ var newBounds = {
103
+ id: dialogId,
104
+ bounds: bounds
105
+ };
106
+ var founded = initDialogMemoizeBounds_1.registeredDialogs.find(function (b) { return b.id === dialogId; });
107
+ if (founded) {
108
+ founded.bounds = bounds;
109
+ try {
110
+ window.localStorage.setItem(BOUNDS_STORE_KEY, JSON.stringify(initDialogMemoizeBounds_1.registeredDialogs));
111
+ }
112
+ catch (e) {
113
+ console.log(e);
114
+ }
115
+ }
116
+ };
117
+ exports.setDialogBounds = setDialogBounds;
@@ -0,0 +1,11 @@
1
+ export type IDialogBoundsMemoKey = string;
2
+ export interface IDialogBoundsDef {
3
+ width: number;
4
+ height: number;
5
+ x: number;
6
+ y: number;
7
+ }
8
+ export interface IDialogBoundDef {
9
+ id: string;
10
+ bounds: IDialogBoundsDef;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import { IDialogBoundsDef } from "./BoundTypes";
2
+ import { IBaseDialogOptions } from "../types/DialogTypes";
3
+ export declare const dialogRegister: (options: IBaseDialogOptions, initialBounds: IDialogBoundsDef) => IDialogBoundsDef;
4
+ export declare const getDialogBounds: (options: IBaseDialogOptions) => IDialogBoundsDef | undefined;
5
+ export declare const setDialogBounds: (dialogId: string, bounds: IDialogBoundsDef, dialogRef: React.RefObject<any>) => void;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setDialogBounds = exports.getDialogBounds = exports.dialogRegister = void 0;
4
+ // import {registeredDialogs} from "../hooks/initDialogMemoizeBounds";
5
+ var initDialogMemoizeBounds_1 = require("./initDialogMemoizeBounds");
6
+ // const BOUNDS_STORE_KEY: IDialogBoundsMemoKey = 'react-super-dialog';
7
+ // const boundStoreExists = () => {
8
+ // try{
9
+ // return !!window.localStorage.getItem(BOUNDS_STORE_KEY);
10
+ // } catch (e){
11
+ // return false;
12
+ // }
13
+ // }
14
+ // const createBoundStore = () => {
15
+ // if (!boundStoreExists()) {
16
+ // try{
17
+ // window.localStorage.setItem(BOUNDS_STORE_KEY, JSON.stringify([]));
18
+ // } catch (e){
19
+ // console.log(e);
20
+ // }
21
+ // }
22
+ // }
23
+ /**
24
+ * RAM den okuyoruz...
25
+ * */
26
+ var dialogInStore = function (options) {
27
+ var stores = initDialogMemoizeBounds_1.registeredDialogs;
28
+ console.log('dialogInStoreX1', stores);
29
+ if (!stores)
30
+ return undefined;
31
+ var parsedStores = stores; // JSON.parse(stores);
32
+ var foundedStore = parsedStores.find(function (store) { return store.id === options.id; });
33
+ return foundedStore;
34
+ };
35
+ var dialogRegister = function (options, initialBounds) {
36
+ console.log('Regsister fired!!!', options);
37
+ if (dialogInStore(options))
38
+ return;
39
+ if (!options.id) {
40
+ throw new Error('Dialog bounds can not be memoized. Dialog id is required.');
41
+ }
42
+ // createBoundStore();
43
+ var newBounds = {
44
+ id: options.id,
45
+ bounds: {
46
+ width: initialBounds.width,
47
+ height: initialBounds.height,
48
+ x: initialBounds.x,
49
+ y: initialBounds.y + 100
50
+ }
51
+ };
52
+ var foundedDialog = initDialogMemoizeBounds_1.registeredDialogs.find(function (b) { return b.id === options.id; });
53
+ console.log('foundedDialog', foundedDialog);
54
+ if (!foundedDialog) {
55
+ initDialogMemoizeBounds_1.registeredDialogs.push(newBounds);
56
+ }
57
+ console.log('foundedDialog_2', initDialogMemoizeBounds_1.registeredDialogs);
58
+ // Register to Cookie
59
+ try {
60
+ window.localStorage.setItem(initDialogMemoizeBounds_1.BOUNDS_STORE_KEY, JSON.stringify(initDialogMemoizeBounds_1.registeredDialogs));
61
+ }
62
+ catch (e) {
63
+ console.log(e);
64
+ }
65
+ // registeredDialogs.push(newBounds);
66
+ console.log('Dialog_Bounds, initialBounds-A', initialBounds);
67
+ var bounds = (0, exports.getDialogBounds)(options);
68
+ return bounds;
69
+ };
70
+ exports.dialogRegister = dialogRegister;
71
+ var getDialogBounds = function (options) {
72
+ var dialog = dialogInStore(options);
73
+ if (!options.id) {
74
+ throw new Error('Dialog bounds can not be memoized. Dialog id is required.');
75
+ }
76
+ // Eget local vaiable icinde bulunamassa localStorage'dan al
77
+ if (!dialog) {
78
+ var boundsRaw = window.localStorage.getItem(initDialogMemoizeBounds_1.BOUNDS_STORE_KEY);
79
+ var boundsArray = boundsRaw ? JSON.parse(boundsRaw) : [];
80
+ var founded = boundsArray.find(function (b) { return b.id === options.id; });
81
+ if (founded) {
82
+ return {
83
+ width: founded.bounds.width,
84
+ height: founded.bounds.height,
85
+ x: founded.bounds.x,
86
+ y: founded.bounds.y
87
+ };
88
+ }
89
+ }
90
+ if (dialog) {
91
+ return {
92
+ width: dialog.bounds.width,
93
+ height: dialog.bounds.height,
94
+ x: dialog.bounds.x,
95
+ y: dialog.bounds.y
96
+ };
97
+ }
98
+ return undefined;
99
+ };
100
+ exports.getDialogBounds = getDialogBounds;
101
+ var setDialogBounds = function (dialogId, bounds, dialogRef) {
102
+ var newBounds = {
103
+ id: dialogId,
104
+ bounds: bounds
105
+ };
106
+ var founded = initDialogMemoizeBounds_1.registeredDialogs.find(function (b) { return b.id === dialogId; });
107
+ if (founded) {
108
+ founded.bounds = bounds;
109
+ try {
110
+ window.localStorage.setItem(initDialogMemoizeBounds_1.BOUNDS_STORE_KEY, JSON.stringify(initDialogMemoizeBounds_1.registeredDialogs));
111
+ }
112
+ catch (e) {
113
+ console.log(e);
114
+ }
115
+ }
116
+ };
117
+ exports.setDialogBounds = setDialogBounds;
@@ -0,0 +1,2 @@
1
+ export { InitDialogMemoizeBounds, InitDialogMemoizeBoundsDeclared, registeredDialogs } from "./initDialogMemoizeBounds";
2
+ export * from "./dialogBoundsMemoize";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.registeredDialogs = exports.InitDialogMemoizeBoundsDeclared = exports.InitDialogMemoizeBounds = void 0;
18
+ var initDialogMemoizeBounds_1 = require("./initDialogMemoizeBounds");
19
+ Object.defineProperty(exports, "InitDialogMemoizeBounds", { enumerable: true, get: function () { return initDialogMemoizeBounds_1.InitDialogMemoizeBounds; } });
20
+ Object.defineProperty(exports, "InitDialogMemoizeBoundsDeclared", { enumerable: true, get: function () { return initDialogMemoizeBounds_1.InitDialogMemoizeBoundsDeclared; } });
21
+ Object.defineProperty(exports, "registeredDialogs", { enumerable: true, get: function () { return initDialogMemoizeBounds_1.registeredDialogs; } });
22
+ __exportStar(require("./dialogBoundsMemoize"), exports);
@@ -0,0 +1,5 @@
1
+ import { IDialogBoundDef, IDialogBoundsMemoKey } from "./BoundTypes";
2
+ export declare let registeredDialogs: IDialogBoundDef[];
3
+ export declare let InitDialogMemoizeBoundsDeclared: boolean;
4
+ export declare const BOUNDS_STORE_KEY: IDialogBoundsMemoKey;
5
+ export declare const InitDialogMemoizeBounds: () => void;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InitDialogMemoizeBounds = exports.BOUNDS_STORE_KEY = exports.InitDialogMemoizeBoundsDeclared = exports.registeredDialogs = void 0;
4
+ // Sayfa ilk yuklendiginde calisacak
5
+ exports.registeredDialogs = [];
6
+ exports.InitDialogMemoizeBoundsDeclared = false;
7
+ exports.BOUNDS_STORE_KEY = 'react-super-dialog';
8
+ // Bu App level sevyesinde olmali
9
+ // ILk Kayitlari olusturuyoruz
10
+ var InitDialogMemoizeBounds = function () {
11
+ var boundStoreExists = function () {
12
+ try {
13
+ return !!window.localStorage.getItem(exports.BOUNDS_STORE_KEY);
14
+ }
15
+ catch (e) {
16
+ return false;
17
+ }
18
+ };
19
+ var createBoundStore = function () {
20
+ if (!boundStoreExists()) {
21
+ try {
22
+ window.localStorage.setItem(exports.BOUNDS_STORE_KEY, JSON.stringify([]));
23
+ }
24
+ catch (e) {
25
+ console.log(e);
26
+ }
27
+ }
28
+ };
29
+ var readFromStore = function () {
30
+ createBoundStore();
31
+ var boundsRaw = window.localStorage.getItem(exports.BOUNDS_STORE_KEY);
32
+ var boundsArray = boundsRaw ? JSON.parse(boundsRaw) : [];
33
+ return boundsArray;
34
+ };
35
+ console.log('readFromStore', readFromStore());
36
+ // Set this on App level
37
+ exports.registeredDialogs = readFromStore();
38
+ exports.InitDialogMemoizeBoundsDeclared = true;
39
+ };
40
+ exports.InitDialogMemoizeBounds = InitDialogMemoizeBounds;
@@ -0,0 +1,4 @@
1
+ import { IDialogBoundDef } from "../components/dialogBoundsMemoize";
2
+ export declare let registeredDialogs: IDialogBoundDef[];
3
+ export declare let initDialogMemoizeBoundsDeclared: boolean;
4
+ export declare const initDialogMemoizeBounds: () => void;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initDialogMemoizeBounds = exports.initDialogMemoizeBoundsDeclared = exports.registeredDialogs = void 0;
4
+ // Sayfa ilk yuklendiginde calisacak
5
+ exports.registeredDialogs = [];
6
+ exports.initDialogMemoizeBoundsDeclared = false;
7
+ // Bu App level sevyesinde olmali
8
+ var initDialogMemoizeBounds = function () {
9
+ var BOUNDS_STORE_KEY = 'react-super-dialog';
10
+ var boundStoreExists = function () {
11
+ try {
12
+ return !!window.localStorage.getItem(BOUNDS_STORE_KEY);
13
+ }
14
+ catch (e) {
15
+ return false;
16
+ }
17
+ };
18
+ var createBoundStore = function () {
19
+ if (!boundStoreExists()) {
20
+ try {
21
+ window.localStorage.setItem(BOUNDS_STORE_KEY, JSON.stringify([]));
22
+ }
23
+ catch (e) {
24
+ console.log(e);
25
+ }
26
+ }
27
+ };
28
+ var readFromStore = function () {
29
+ createBoundStore();
30
+ var boundsRaw = window.localStorage.getItem(BOUNDS_STORE_KEY);
31
+ var boundsArray = boundsRaw ? JSON.parse(boundsRaw) : [];
32
+ return boundsArray;
33
+ };
34
+ console.log('readFromStore', readFromStore());
35
+ // Set this on App level
36
+ exports.registeredDialogs = readFromStore();
37
+ exports.initDialogMemoizeBoundsDeclared = true;
38
+ };
39
+ exports.initDialogMemoizeBounds = initDialogMemoizeBounds;
@@ -0,0 +1 @@
1
+ export declare const useDialogMemoizeBounds: () => void;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDialogMemoizeBounds = void 0;
4
+ // Sayfa ilk yuklendiginde calisacak
5
+ var registeredDialogs = [];
6
+ // Bu App level sevyesinde olmali
7
+ var useDialogMemoizeBounds = function () {
8
+ var BOUNDS_STORE_KEY = 'react-super-dialog';
9
+ var boundStoreExists = function () {
10
+ try {
11
+ return !!window.localStorage.getItem(BOUNDS_STORE_KEY);
12
+ }
13
+ catch (e) {
14
+ return false;
15
+ }
16
+ };
17
+ var createBoundStore = function () {
18
+ if (!boundStoreExists()) {
19
+ try {
20
+ window.localStorage.setItem(BOUNDS_STORE_KEY, JSON.stringify([]));
21
+ }
22
+ catch (e) {
23
+ console.log(e);
24
+ }
25
+ }
26
+ };
27
+ var readFromStore = function () {
28
+ createBoundStore();
29
+ var boundsRaw = window.localStorage.getItem(BOUNDS_STORE_KEY);
30
+ var boundsArray = boundsRaw ? JSON.parse(boundsRaw) : [];
31
+ return boundsArray;
32
+ };
33
+ console.log('readFromStore', readFromStore());
34
+ // Set this on App level
35
+ registeredDialogs = readFromStore();
36
+ };
37
+ exports.useDialogMemoizeBounds = useDialogMemoizeBounds;
package/index.d.ts CHANGED
@@ -6,3 +6,4 @@ export { default } from "./models/Dialog";
6
6
  export { DialogProcessing, DialogCloseAction, DialogFullscreenAction, DialogHeaderActionsWrapper, DialogInfoAction } from "./components/Futures";
7
7
  export { DialogAction, ActionProgress } from "./models/DialogAction";
8
8
  export { useDialogOptions } from "./hooks/useDialogOptions";
9
+ export { InitDialogMemoizeBounds } from "./helpers/initDialogMemoizeBounds";
package/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useDialogOptions = exports.ActionProgress = exports.DialogAction = exports.DialogInfoAction = exports.DialogHeaderActionsWrapper = exports.DialogFullscreenAction = exports.DialogCloseAction = exports.DialogProcessing = exports.default = exports.Dialog = void 0;
6
+ exports.InitDialogMemoizeBounds = exports.useDialogOptions = exports.ActionProgress = exports.DialogAction = exports.DialogInfoAction = exports.DialogHeaderActionsWrapper = exports.DialogFullscreenAction = exports.DialogCloseAction = exports.DialogProcessing = exports.default = exports.Dialog = void 0;
7
7
  require("./styles/dialog.css");
8
8
  require("./styles/dialog.action.css");
9
9
  require("./styles/circular-progress.css");
@@ -24,3 +24,5 @@ Object.defineProperty(exports, "ActionProgress", { enumerable: true, get: functi
24
24
  // Hooks
25
25
  var useDialogOptions_1 = require("./hooks/useDialogOptions");
26
26
  Object.defineProperty(exports, "useDialogOptions", { enumerable: true, get: function () { return useDialogOptions_1.useDialogOptions; } });
27
+ var initDialogMemoizeBounds_1 = require("./helpers/initDialogMemoizeBounds");
28
+ Object.defineProperty(exports, "InitDialogMemoizeBounds", { enumerable: true, get: function () { return initDialogMemoizeBounds_1.InitDialogMemoizeBounds; } });
@@ -1,4 +1,5 @@
1
1
  import { MouseEvent } from "react";
2
+ import { DialogOptionsType } from "../types/DialogTypes";
2
3
  declare class Resizeable {
3
4
  onResizeListener: (callbackFn: (width: number, height: number) => void) => void;
4
5
  get width(): number;
@@ -10,8 +11,9 @@ declare class Resizeable {
10
11
  private _container;
11
12
  private _width;
12
13
  private _height;
14
+ private _dialogOptions;
13
15
  constructor();
14
- setContainer: (container: HTMLElement) => void;
16
+ setContainer: (container: React.RefObject<HTMLDivElement>, options: DialogOptionsType) => void;
15
17
  private resizeHandleMouseUp;
16
18
  resizeHandleMouseDown: () => void;
17
19
  resizeHandleMouseMove: (e: MouseEvent) => void;
@@ -1,32 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ var helpers_1 = require("../helpers");
3
4
  var Resizeable = /** @class */ (function () {
4
5
  function Resizeable() {
5
6
  var _this = this;
6
7
  this.onResizeListener = function (callbackFn) {
7
8
  _this._onResizeListener = callbackFn;
8
9
  };
9
- this.setContainer = function (container) {
10
+ this.setContainer = function (container, options) {
10
11
  _this._container = container;
12
+ _this._dialogOptions = options;
11
13
  };
12
14
  this.resizeHandleMouseUp = function () {
13
- console.log('handleMouseUp', false);
14
- _this._container.classList.remove('no-select-on-resize');
15
+ // console.log('handleMouseUp', false);
16
+ _this._container.current.classList.remove('no-select-on-resize');
15
17
  _this.isResizing = false;
18
+ // Bounds case
19
+ var container = _this._container.current;
20
+ var _a = container === null || container === void 0 ? void 0 : container.getBoundingClientRect(), width = _a.width, height = _a.height, x = _a.x, y = _a.y;
21
+ (0, helpers_1.setDialogBounds)(_this._dialogOptions.base.id, { width: width, height: height, x: x, y: y }, _this._container);
16
22
  };
17
23
  this.resizeHandleMouseDown = function () {
18
24
  console.log('resizeHandleMouseDown', true);
19
25
  _this.isResizing = true;
20
- _this._container.classList.add('no-select-on-resize');
26
+ _this._container.current.classList.add('no-select-on-resize');
21
27
  _this.init();
22
28
  };
23
29
  this.resizeHandleMouseMove = function (e) {
24
- if (!_this.isResizing || !_this._container)
30
+ if (!_this.isResizing || !_this._container.current)
25
31
  return;
26
- if (!_this._container) {
32
+ if (!_this._container.current) {
27
33
  throw new Error('Please define container');
28
34
  }
29
- var container = _this._container;
35
+ var container = _this._container.current;
30
36
  var newWidth = e.clientX - (container === null || container === void 0 ? void 0 : container.getBoundingClientRect().left) + 10;
31
37
  var newHeight = e.clientY - (container === null || container === void 0 ? void 0 : container.getBoundingClientRect().top) + 10;
32
38
  _this._width = Math.max(newWidth, 100); // Minimum genişlik
@@ -34,8 +40,8 @@ var Resizeable = /** @class */ (function () {
34
40
  if (typeof _this._onResizeListener === "function") {
35
41
  _this._onResizeListener(_this._width, _this._height);
36
42
  }
37
- _this._container.style.width = _this._width + 'px';
38
- _this._container.style.height = _this._height + 'px';
43
+ _this._container.current.style.width = _this._width + 'px';
44
+ _this._container.current.style.height = _this._height + 'px';
39
45
  };
40
46
  this.init = function () {
41
47
  if (_this.isResizing) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.22",
3
+ "version": "1.1.23",
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",
@@ -83,6 +83,11 @@ export interface IBaseDialogOptions {
83
83
  style?: React.CSSProperties;
84
84
  size?: IDialogSize;
85
85
  notifyOnClosing?: TNotifyOnClosing;
86
+ /**
87
+ * Momoize dialog sized and position
88
+ * */
89
+ memoBounds?: boolean;
90
+ id?: string;
86
91
  actions?: {
87
92
  disabledOnDialogProcessing?: boolean;
88
93
  baseStyle?: React.CSSProperties;