react-dialogger 1.1.138 → 1.1.140

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.
@@ -86,13 +86,14 @@ var DialogContent = function (props) {
86
86
  var _o = React.useState(((_b = bounds === null || bounds === void 0 ? void 0 : bounds.scale) !== null && _b !== void 0 ? _b : ((_c = dialogOptions === null || dialogOptions === void 0 ? void 0 : dialogOptions.scale) !== null && _c !== void 0 ? _c : 1))), zoom = _o[0], setZoom = _o[1];
87
87
  var positionSelector = function () {
88
88
  var _a;
89
+ var _b;
89
90
  var dialogRectSelectors = { xKey: 'marginLeft', yKey: 'marginTop' };
90
91
  if (prevDialogRect === null || prevDialogRect === void 0 ? void 0 : prevDialogRect.isMultiple) {
91
92
  dialogRectSelectors = { xKey: 'left', yKey: 'top' };
92
93
  }
93
- var _b = bounds !== null && bounds !== void 0 ? bounds : {}, fullscreen = _b.fullscreen, x = _b.x, y = _b.y, restBounds = __rest(_b, ["fullscreen", "x", "y"]);
94
+ var _c = bounds !== null && bounds !== void 0 ? bounds : {}, fullscreen = _c.fullscreen, x = _c.x, y = _c.y, restBounds = __rest(_c, ["fullscreen", "x", "y"]);
94
95
  var cssBounds = __assign(__assign(__assign(__assign({}, restBounds), (_a = {}, _a[dialogRectSelectors.xKey] = prevDialogRect === null || prevDialogRect === void 0 ? void 0 : prevDialogRect.left, _a[dialogRectSelectors.yKey] = prevDialogRect === null || prevDialogRect === void 0 ? void 0 : prevDialogRect.top, _a)), prevDialogRect.isMultiple ? { position: 'absolute' } : null), { translate: prevDialogRect.isMultiple ? "".concat(5, "px ").concat(5, "px") : 'none' });
95
- return __assign({}, bounds ? { position: 'absolute', top: bounds.y, left: bounds.x, width: bounds.width, height: bounds.height } : cssBounds);
96
+ return __assign({}, bounds ? { position: 'absolute', top: Math.max(0, (_b = bounds.y) !== null && _b !== void 0 ? _b : 0), left: bounds.x, width: bounds.width, height: bounds.height } : cssBounds);
96
97
  };
97
98
  // Effect Listener
98
99
  (0, react_1.useEffect)(function () {
@@ -219,9 +220,6 @@ var DialogContent = function (props) {
219
220
  setTimeout(function () {
220
221
  event.clientX;
221
222
  });
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' }) }) })] }) }) });
223
+ }, 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) && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "resize-handle resize-n", style: { zIndex: parseInt(domZIndex) + 1 }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown('n') }), (0, jsx_runtime_1.jsx)("div", { className: "resize-handle resize-s", style: { zIndex: parseInt(domZIndex) + 1 }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown('s') }), (0, jsx_runtime_1.jsx)("div", { className: "resize-handle resize-e", style: { zIndex: parseInt(domZIndex) + 1 }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown('e') }), (0, jsx_runtime_1.jsx)("div", { className: "resize-handle resize-w", style: { zIndex: parseInt(domZIndex) + 1 }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown('w') }), (0, jsx_runtime_1.jsx)("div", { className: "resize-handle resize-nw", style: { zIndex: parseInt(domZIndex) + 2 }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown('nw') }), (0, jsx_runtime_1.jsx)("div", { className: "resize-handle resize-ne", style: { zIndex: parseInt(domZIndex) + 2 }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown('ne') }), (0, jsx_runtime_1.jsx)("div", { className: "resize-handle resize-sw", style: { zIndex: parseInt(domZIndex) + 2 }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown('sw') }), (0, jsx_runtime_1.jsx)("div", { className: "resize-handle resize-se", style: { zIndex: parseInt(domZIndex) + 2 }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown('se'), children: (0, jsx_runtime_1.jsx)(_icons_1.ResizeIcon, { color: '#286e94' }) })] })] }) }) });
226
224
  };
227
225
  exports.DialogContent = DialogContent;
@@ -1,5 +1,6 @@
1
1
  import { MouseEvent } from "react";
2
2
  import { DialogOptionsType } from "../types/index.js";
3
+ export type ResizeDirection = 'n' | 's' | 'e' | 'w' | 'ne' | 'nw' | 'se' | 'sw';
3
4
  declare class Resizeable {
4
5
  onResizeListener: (callbackFn: (width: number, height: number, rect?: DOMRect) => void) => void;
5
6
  get width(): number;
@@ -12,10 +13,27 @@ declare class Resizeable {
12
13
  private _width;
13
14
  private _height;
14
15
  private _dialogOptions;
16
+ private _direction;
17
+ private _startMouseX;
18
+ private _startMouseY;
19
+ private _startVisualWidth;
20
+ private _startVisualHeight;
21
+ private _startCssLeft;
22
+ private _startCssTop;
15
23
  constructor();
16
24
  setContainer: (container: React.RefObject<HTMLDivElement>, options: DialogOptionsType) => void;
25
+ /**
26
+ * Read the Draggable component's current CSS transform translation.
27
+ * react-draggable applies transform: translate(x, y) to the element.
28
+ * We need this to correctly compute absolute CSS position from visual position.
29
+ */
30
+ private getDraggableTranslate;
17
31
  private resizeHandleMouseUp;
18
- resizeHandleMouseDown: () => void;
32
+ /**
33
+ * Returns a mousedown handler for the given resize direction.
34
+ * Captures start position and visual bounds so mousemove can compute deltas.
35
+ */
36
+ resizeHandleMouseDown: (direction: ResizeDirection) => (e: React.MouseEvent) => void;
19
37
  resizeHandleMouseMove: (e: MouseEvent) => void;
20
38
  init: () => void;
21
39
  cleanUp: () => void;
@@ -20,45 +20,112 @@ var Resizeable = /** @class */ (function () {
20
20
  this.onResizeListener = function (callbackFn) {
21
21
  _this._onResizeListener = callbackFn;
22
22
  };
23
+ // Multi-direction resize state
24
+ this._direction = 'se';
25
+ this._startMouseX = 0;
26
+ this._startMouseY = 0;
27
+ this._startVisualWidth = 0;
28
+ this._startVisualHeight = 0;
29
+ this._startCssLeft = 0;
30
+ this._startCssTop = 0;
23
31
  this.setContainer = function (container, options) {
24
32
  _this._container = container;
25
33
  _this._dialogOptions = options;
26
34
  };
35
+ /**
36
+ * Read the Draggable component's current CSS transform translation.
37
+ * react-draggable applies transform: translate(x, y) to the element.
38
+ * We need this to correctly compute absolute CSS position from visual position.
39
+ */
40
+ this.getDraggableTranslate = function () {
41
+ var _a;
42
+ var el = (_a = _this._container) === null || _a === void 0 ? void 0 : _a.current;
43
+ if (!el)
44
+ return { x: 0, y: 0 };
45
+ var transform = window.getComputedStyle(el).transform;
46
+ if (!transform || transform === 'none')
47
+ return { x: 0, y: 0 };
48
+ var m = new DOMMatrix(transform);
49
+ return { x: m.m41, y: m.m42 };
50
+ };
27
51
  this.resizeHandleMouseUp = function () {
28
- var _a, _b, _c;
52
+ var _a, _b;
29
53
  (_b = (_a = _this._container) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.classList.remove('no-select-on-resize');
30
54
  _this.isResizing = false;
31
- // Bounds case
32
55
  var container = _this._container.current;
33
- var _d = (_c = container === null || container === void 0 ? void 0 : container.getBoundingClientRect()) !== null && _c !== void 0 ? _c : {}, width = _d.width, height = _d.height, x = _d.x, y = _d.y;
34
56
  (0, appLogger_1.appLog)('resizeHandleMouseUp', container === null || container === void 0 ? void 0 : container.getBoundingClientRect().toJSON());
35
- // setDialogBounds( this._dialogOptions.base.id, {width, height, x, y, fullscreen: false}, this._container );
36
57
  (0, _helpers_1.setDialogBounds)(_this._dialogOptions.base.id, __assign(__assign({}, container === null || container === void 0 ? void 0 : container.getBoundingClientRect().toJSON()), { fullscreen: false }), _this._container);
37
58
  };
38
- this.resizeHandleMouseDown = function () {
39
- _this.isResizing = true;
59
+ /**
60
+ * Returns a mousedown handler for the given resize direction.
61
+ * Captures start position and visual bounds so mousemove can compute deltas.
62
+ */
63
+ this.resizeHandleMouseDown = function (direction) { return function (e) {
64
+ e.preventDefault();
65
+ e.stopPropagation();
66
+ _this._direction = direction;
67
+ _this._isResizing = true;
68
+ _this._startMouseX = e.clientX;
69
+ _this._startMouseY = e.clientY;
70
+ var rect = _this._container.current.getBoundingClientRect();
71
+ var translate = _this.getDraggableTranslate();
72
+ // Visual dimensions from getBoundingClientRect (screen pixels, zoom accounted)
73
+ _this._startVisualWidth = rect.width;
74
+ _this._startVisualHeight = rect.height;
75
+ // CSS position = visual position minus Draggable's transform offset
76
+ _this._startCssLeft = rect.left - translate.x;
77
+ _this._startCssTop = rect.top - translate.y;
40
78
  _this._container.current.classList.add('no-select-on-resize');
41
79
  _this.init();
42
- };
80
+ }; };
43
81
  this.resizeHandleMouseMove = function (e) {
44
- var _a;
82
+ var _a, _b;
45
83
  if (!_this.isResizing || !_this._container.current)
46
84
  return;
47
- if (!_this._container.current) {
48
- throw new Error('Please define container');
49
- }
50
85
  var container = _this._container.current;
51
- var newWidth = e.clientX - (container === null || container === void 0 ? void 0 : container.getBoundingClientRect().left) + 10;
52
- var newHeight = e.clientY - (container === null || container === void 0 ? void 0 : container.getBoundingClientRect().top) + 10;
53
- _this._width = Math.max(newWidth, 100); // Min Width
54
- _this._height = Math.max(newHeight, 100); // Min Height
55
- var rect = __assign(__assign({}, container === null || container === void 0 ? void 0 : container.getBoundingClientRect().toJSON()), { width: _this._width, height: _this._height });
86
+ var scale = (_b = (_a = _this._dialogOptions) === null || _a === void 0 ? void 0 : _a.scale) !== null && _b !== void 0 ? _b : 1;
87
+ var dx = e.clientX - _this._startMouseX;
88
+ var dy = e.clientY - _this._startMouseY;
89
+ var dir = _this._direction;
90
+ var MIN_SIZE = 100; // screen pixels
91
+ var newVisualWidth = _this._startVisualWidth;
92
+ var newVisualHeight = _this._startVisualHeight;
93
+ var newCssLeft = _this._startCssLeft;
94
+ var newCssTop = _this._startCssTop;
95
+ // East — grow/shrink from the right edge
96
+ if (dir.includes('e')) {
97
+ newVisualWidth = Math.max(MIN_SIZE, _this._startVisualWidth + dx);
98
+ }
99
+ // West — grow/shrink from the left edge, compensate position
100
+ if (dir.includes('w')) {
101
+ newVisualWidth = Math.max(MIN_SIZE, _this._startVisualWidth - dx);
102
+ // left edge moves by the amount width actually changed
103
+ newCssLeft = _this._startCssLeft + (_this._startVisualWidth - newVisualWidth);
104
+ }
105
+ // South — grow/shrink from the bottom edge
106
+ if (dir.includes('s')) {
107
+ newVisualHeight = Math.max(MIN_SIZE, _this._startVisualHeight + dy);
108
+ }
109
+ // North — grow/shrink from the top edge, compensate position
110
+ if (dir.includes('n')) {
111
+ newVisualHeight = Math.max(MIN_SIZE, _this._startVisualHeight - dy);
112
+ // top edge moves by the amount height actually changed, clamped to 0
113
+ newCssTop = Math.max(0, _this._startCssTop + (_this._startVisualHeight - newVisualHeight));
114
+ }
115
+ // Apply size (divide by scale to get CSS pixels from visual pixels)
116
+ container.style.width = (newVisualWidth / scale) + 'px';
117
+ container.style.height = (newVisualHeight / scale) + 'px';
118
+ // Apply position for n/w directions
119
+ if (dir.includes('w') || dir.includes('n')) {
120
+ container.style.position = 'absolute';
121
+ container.style.left = newCssLeft + 'px';
122
+ container.style.top = Math.max(0, newCssTop) + 'px';
123
+ }
124
+ _this._width = newVisualWidth / scale;
125
+ _this._height = newVisualHeight / scale;
56
126
  if (typeof _this._onResizeListener === "function") {
57
- _this._onResizeListener(_this._width, _this._height, rect);
127
+ _this._onResizeListener(_this._width, _this._height, container.getBoundingClientRect());
58
128
  }
59
- var scale = ((_a = _this._dialogOptions) !== null && _a !== void 0 ? _a : { scale: 1 }).scale;
60
- _this._container.current.style.width = (_this._width / scale) + 'px';
61
- _this._container.current.style.height = (_this._height / scale) + 'px';
62
129
  };
63
130
  this.init = function () {
64
131
  if (_this.isResizing) {
@@ -75,10 +75,11 @@ var setDialogBounds = function (dialogId, bounds, dialogRef) {
75
75
  var foundedDialog = initDialogMemoizeBounds_1.registeredDialogs.get(combined.join('-'));
76
76
  (0, appLogger_1.appLog)('setDialogBounds_combined', combined, combined.join('-'), bounds, foundedDialog);
77
77
  if (foundedDialog) {
78
+ var safeBounds = __assign(__assign({}, bounds), { y: typeof bounds.y === 'number' ? Math.max(0, bounds.y) : bounds.y });
78
79
  // Save to RAM
79
80
  initDialogMemoizeBounds_1.registeredDialogs.set(combined.join('-'), {
80
81
  id: combined.join('-'),
81
- bounds: __assign(__assign({}, (0, exports.getDialogBounds)(dialogId)), bounds)
82
+ bounds: __assign(__assign({}, (0, exports.getDialogBounds)(dialogId)), safeBounds)
82
83
  });
83
84
  /**
84
85
  * const myMap = new Map();
@@ -44,6 +44,26 @@ declare class Dialog<V, I> {
44
44
  keyboardListener(listener: (key: string, dialog: IDialogApiDef) => void): this;
45
45
  resizeListener(listener: (size: IDialogSize, dialog: IDialogApiDef) => void): this;
46
46
  onClose(callback: TDialogCallbackFn<V, I, void>): this;
47
+ /**
48
+ * Nutzungsszenarien
49
+ *
50
+ * 1. Szenario
51
+ * Dialog A (normal) z: 1202
52
+ * Dialog B (throughable) z: 1203
53
+ * Dialog C (throughable) z: 1204
54
+ *
55
+ * highestZ(false) → 1204 // Alle Dialoge berücksichtigen → höchsten z-Index nehmen → 1205
56
+ * highestZ(true) → 1204 // Nur throughable Dialoge berücksichtigen → 1205
57
+ *
58
+ * 2. Szenario
59
+ * Dialog A (normal) z: 1205 ← höchster z-Index
60
+ * Dialog B (throughable) z: 1203
61
+ * Dialog C (throughable) z: 1204
62
+ *
63
+ * highestZ(false) → 1205 // Über dem normalen Dialog platzieren → 1206
64
+ * highestZ(true) → 1204 // Nur den höchsten throughable Dialog berücksichtigen → 1205
65
+ * // Bleibt UNTERHALB des normalen Dialogs! !!Gewünschtes Verhalten
66
+ */
47
67
  private highestZ;
48
68
  private createDom;
49
69
  /**
package/models/Dialog.js CHANGED
@@ -68,15 +68,41 @@ var Dialog = /** @class */ (function () {
68
68
  * UI / Dialog / Form bağlamında alışıldık
69
69
  * */
70
70
  this._headerRef = React.createRef();
71
+ /**
72
+ * Nutzungsszenarien
73
+ *
74
+ * 1. Szenario
75
+ * Dialog A (normal) z: 1202
76
+ * Dialog B (throughable) z: 1203
77
+ * Dialog C (throughable) z: 1204
78
+ *
79
+ * highestZ(false) → 1204 // Alle Dialoge berücksichtigen → höchsten z-Index nehmen → 1205
80
+ * highestZ(true) → 1204 // Nur throughable Dialoge berücksichtigen → 1205
81
+ *
82
+ * 2. Szenario
83
+ * Dialog A (normal) z: 1205 ← höchster z-Index
84
+ * Dialog B (throughable) z: 1203
85
+ * Dialog C (throughable) z: 1204
86
+ *
87
+ * highestZ(false) → 1205 // Über dem normalen Dialog platzieren → 1206
88
+ * highestZ(true) → 1204 // Nur den höchsten throughable Dialog berücksichtigen → 1205
89
+ * // Bleibt UNTERHALB des normalen Dialogs! !!Gewünschtes Verhalten
90
+ */
71
91
  this.highestZ = function (throughableOnly) {
72
- var _a, _b;
92
+ var _a;
73
93
  if (throughableOnly === void 0) { throughableOnly = false; }
74
94
  if ((_a = _this._dialogOptions) === null || _a === void 0 ? void 0 : _a.zIndex) {
75
- return (_b = _this._dialogOptions) === null || _b === void 0 ? void 0 : _b.zIndex;
95
+ return _this._dialogOptions.zIndex;
76
96
  }
77
- var presentationElements = document.querySelectorAll("div[data-family=\"presentation\"]".concat(throughableOnly ? ' > div.dialogger-throughable' : ''));
97
+ var presentationElements = document.querySelectorAll('div[data-family="presentation"]');
78
98
  var highest = 1201;
79
99
  presentationElements.forEach(function (element) {
100
+ // throughableOnly → sadece ilk child'ı dialogger-throughable olan presentation'lar
101
+ if (throughableOnly) {
102
+ var firstDiv = element.querySelector('div:first-child');
103
+ if (!(firstDiv === null || firstDiv === void 0 ? void 0 : firstDiv.classList.contains('dialogger-throughable')))
104
+ return;
105
+ }
80
106
  var z = parseInt(window.getComputedStyle(element).zIndex, 10);
81
107
  if (!isNaN(z) && z > highest) {
82
108
  highest = z;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.138",
3
+ "version": "1.1.140",
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
@@ -322,22 +322,67 @@
322
322
  flex: 0;
323
323
  overflow: hidden;
324
324
  }
325
- .dialog-main .resizable-handle {
325
+ .dialog-main .resize-handle {
326
326
  position: absolute;
327
- width: 20px;
328
- height: 20px;
329
- /*background: repeating-linear-gradient(
330
- 45deg,
331
- #ccc,
332
- #ccc 2px,
333
- transparent 2px,
334
- transparent 4px
335
- );*/
327
+ user-select: none;
328
+ }
329
+ .dialog-main .resize-handle.resize-n {
330
+ top: 0;
331
+ left: 8px;
332
+ right: 8px;
333
+ height: 4px;
334
+ cursor: n-resize;
335
+ }
336
+ .dialog-main .resize-handle.resize-s {
337
+ bottom: 0;
338
+ left: 8px;
339
+ right: 8px;
340
+ height: 4px;
341
+ cursor: s-resize;
342
+ }
343
+ .dialog-main .resize-handle.resize-e {
344
+ right: 0;
345
+ top: 8px;
346
+ bottom: 8px;
347
+ width: 4px;
348
+ cursor: e-resize;
349
+ }
350
+ .dialog-main .resize-handle.resize-w {
351
+ left: 0;
352
+ top: 8px;
353
+ bottom: 8px;
354
+ width: 4px;
355
+ cursor: w-resize;
356
+ }
357
+ .dialog-main .resize-handle.resize-nw {
358
+ top: 0;
359
+ left: 0;
360
+ width: 8px;
361
+ height: 8px;
362
+ cursor: nw-resize;
363
+ }
364
+ .dialog-main .resize-handle.resize-ne {
365
+ top: 0;
366
+ right: 0;
367
+ width: 8px;
368
+ height: 8px;
369
+ cursor: ne-resize;
370
+ }
371
+ .dialog-main .resize-handle.resize-sw {
372
+ bottom: 0;
373
+ left: 0;
374
+ width: 8px;
375
+ height: 8px;
376
+ cursor: sw-resize;
377
+ }
378
+ .dialog-main .resize-handle.resize-se {
336
379
  bottom: 0;
337
380
  right: 0;
338
- cursor: se-resize; /* Sağ alt köşe için özel imleç */
381
+ width: 20px;
382
+ height: 20px;
383
+ cursor: se-resize;
339
384
  }
340
- .dialog-main .resizable-handle .resizable-handle-icon svg {
385
+ .dialog-main .resize-handle.resize-se svg {
341
386
  transform: rotate(-135deg);
342
387
  display: flex;
343
388
  fill: #286e94;