react-dialogger 1.1.124 → 1.1.125

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.
@@ -71,15 +71,18 @@ var react_1 = require("react");
71
71
  var jumper_animate_1 = require("../utils/effects/jumper-animate");
72
72
  var _context_1 = require("../context/index.js");
73
73
  var appLogger_1 = require("../helpers/appLogger");
74
+ var PlusIcon_1 = __importDefault(require("../icons/PlusIcon"));
75
+ var MinusIcon_1 = __importDefault(require("../icons/MinusIcon"));
74
76
  var DialogContent = function (props) {
75
- var _a, _b, _c, _d, _e, _f, _g;
77
+ var _a, _b, _c, _d, _e, _f, _g, _h;
76
78
  var firstUpdate = React.useRef(true);
77
- var _h = (0, react_1.useContext)(_context_1.DialogContentContext), dialog = _h.dialog, dialogRef = _h.dialogRef, prevDialogRect = _h.prevDialogRect, backdropRef = _h.backdropRef, snackbarRef = _h.snackbarRef, footerRef = _h.footerRef, bodyRef = _h.bodyRef, headerRef = _h.headerRef, resizeableObject = _h.resizeableObject, body = _h.body;
79
+ var _j = (0, react_1.useContext)(_context_1.DialogContentContext), dialog = _j.dialog, dialogRef = _j.dialogRef, prevDialogRect = _j.prevDialogRect, backdropRef = _j.backdropRef, snackbarRef = _j.snackbarRef, footerRef = _j.footerRef, bodyRef = _j.bodyRef, headerRef = _j.headerRef, resizeableObject = _j.resizeableObject, body = _j.body;
78
80
  var dialogOptions = dialog.dialogOptions;
79
81
  var baseOptions = dialogOptions.base;
80
- var _j = React.useState(false), fullscreenMode = _j[0], setFullscreenMode = _j[1];
81
- var _k = React.useState(null), rect = _k[0], setRect = _k[1];
82
- var bounds = ((_a = dialog.dialogOptions.base) === null || _a === void 0 ? void 0 : _a.memoBounds) ? (0, _helpers_1.getDialogBounds)(dialog.dialogOptions.base.id) : null;
82
+ var _k = React.useState(false), fullscreenMode = _k[0], setFullscreenMode = _k[1];
83
+ var _l = React.useState(null), rect = _l[0], setRect = _l[1];
84
+ var _m = React.useState((_a = dialogOptions === null || dialogOptions === void 0 ? void 0 : dialogOptions.scale) !== null && _a !== void 0 ? _a : 1), zoom = _m[0], setZoom = _m[1];
85
+ var bounds = ((_b = dialog.dialogOptions.base) === null || _b === void 0 ? void 0 : _b.memoBounds) ? (0, _helpers_1.getDialogBounds)(dialog.dialogOptions.base.id) : null;
83
86
  var domZIndex = window.getComputedStyle(dialog.getDom()).zIndex;
84
87
  var positionSelector = function () {
85
88
  var _a;
@@ -148,7 +151,30 @@ var DialogContent = function (props) {
148
151
  dialogRef.current = null;
149
152
  };
150
153
  }, []);
151
- return (0, jsx_runtime_1.jsx)(react_draggable_1.default, { disabled: !baseOptions.draggable || fullscreenMode, axis: 'both', handle: baseOptions.draggable ? '.drag-handle' : '', scale: 1, nodeRef: dialogRef, onDrag: function (event, data) {
154
+ // TODO Bi dene Zoom + Scale ile drag yapiliyor (Resize eksik) & Memo tam coordine degil!!
155
+ var scale = zoom; //dialogOptions?.scale ?? 1;
156
+ var MIN_ZOOM = 10;
157
+ var MAX_ZOOM = 100;
158
+ function decreaseZoom() {
159
+ setZoom(function (prev) {
160
+ // Önce 0.1 çıkar → sonra yuvarla → sonra clamp ile sınırla
161
+ var newZoom = Math.round(prev - 0.1);
162
+ newZoom = Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, newZoom));
163
+ return newZoom;
164
+ });
165
+ }
166
+ function increaseZoom() {
167
+ setZoom(function (prev) {
168
+ var newZoom = Math.round(prev + 0.1);
169
+ newZoom = Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, newZoom));
170
+ return newZoom;
171
+ });
172
+ }
173
+ // Set Zoom
174
+ (0, react_1.useEffect)(function () {
175
+ dialogOptions.scale = zoom;
176
+ }, [zoom]);
177
+ return (0, jsx_runtime_1.jsx)(react_draggable_1.default, { disabled: !baseOptions.draggable || fullscreenMode, axis: 'both', handle: baseOptions.draggable ? '.drag-handle' : '', scale: scale, nodeRef: dialogRef, onDrag: function (event, data) {
152
178
  event.stopPropagation();
153
179
  dialog._dialogTranslate = { lastX: data.lastX, lastY: data.lastY };
154
180
  }, onStop: function (event, data) {
@@ -158,13 +184,13 @@ var DialogContent = function (props) {
158
184
  var _c = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(), width = _c.width, height = _c.height, x = _c.x, y = _c.y;
159
185
  (0, appLogger_1.appLog)('onDragStop', 'fired', (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect());
160
186
  (0, _helpers_1.setDialogBounds)(dialogOptions.base.id, {
161
- width: width,
162
- height: height,
163
- x: x,
164
- y: y,
187
+ width: width / scale,
188
+ height: height / scale,
189
+ x: x / scale,
190
+ y: y / scale,
165
191
  fullscreen: false
166
192
  }, dialogRef);
167
- }, children: (0, jsx_runtime_1.jsx)("div", { id: "dialog-main", ref: dialogRef, onClick: function (e) {
193
+ }, children: (0, jsx_runtime_1.jsxs)("div", { id: "dialog-main", ref: dialogRef, onClick: function (e) {
168
194
  e.stopPropagation();
169
195
  if (dialog.dialogOptions.backdrop.throughable) {
170
196
  var toppest = dialog.props.zFinder();
@@ -187,9 +213,16 @@ var DialogContent = function (props) {
187
213
  // @ts-ignore
188
214
  dialog.props.keyboardListener(e.key, _this);
189
215
  }
190
- }, 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: (_b = baseOptions.size.height) !== null && _b !== void 0 ? _b : 'auto' }, typeof baseOptions.size.width === "number" ? { width: "".concat(baseOptions.size.width, "px") } : { width: "".concat(baseOptions.size.width) }), { outline: 'none', fontFamily: (_c = baseOptions.style.fontFamily) !== null && _c !== void 0 ? _c : 'Arial' }), rect), { alignSelf: (_d = baseOptions.initialAnchor.vertical) !== null && _d !== void 0 ? _d : 'flex-start', justifySelf: (_e = baseOptions.initialAnchor.horizontal) !== null && _e !== void 0 ? _e : 'flex-start' }), children: (0, jsx_runtime_1.jsxs)(notistack_1.SnackbarProvider, { ref: snackbarRef, maxSnack: dialog.dialogOptions.snackbar.maxSnack, style: __assign({ width: 'min-content' }, (_g = (_f = dialog.dialogOptions) === null || _f === void 0 ? void 0 : _f.snackbar) === null || _g === void 0 ? void 0 : _g.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) &&
191
- (0, jsx_runtime_1.jsx)(React.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "resizable-handle", style: {
192
- zIndex: parseInt(domZIndex) + 1
193
- }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown, children: (0, jsx_runtime_1.jsx)(_icons_1.ResizeIcon, { color: '#286e94' }) }) })] }) }) });
216
+ }, 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: (_c = baseOptions.size.height) !== null && _c !== void 0 ? _c : 'auto' }, typeof baseOptions.size.width === "number" ? { width: "".concat(baseOptions.size.width, "px") } : { width: "".concat(baseOptions.size.width) }), { outline: 'none', fontFamily: (_d = baseOptions.style.fontFamily) !== null && _d !== void 0 ? _d : 'Arial' }), rect), { alignSelf: (_e = baseOptions.initialAnchor.vertical) !== null && _e !== void 0 ? _e : 'flex-start', justifySelf: (_f = baseOptions.initialAnchor.horizontal) !== null && _f !== void 0 ? _f : 'flex-start', zoom: scale !== null && scale !== void 0 ? scale : 1, overflow: 'unset' }), children: [(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 () {
217
+ setZoom(function (prev) { return Number((prev + 0.1).toFixed(2)); }); // 0.6 0.7
218
+ }, children: (0, jsx_runtime_1.jsx)(PlusIcon_1.default, { size: 22 }) }), (0, jsx_runtime_1.jsx)("div", { className: "zoom-action", onClick: function (event) {
219
+ setZoom(function (prev) { return Number((prev - 0.1).toFixed(2)); }); // 0.7 → 0.6
220
+ setTimeout(function () {
221
+ event.clientX;
222
+ });
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)), "%"] })] }), (0, jsx_runtime_1.jsxs)(notistack_1.SnackbarProvider, { ref: snackbarRef, maxSnack: dialog.dialogOptions.snackbar.maxSnack, style: __assign({ width: 'min-content' }, (_h = (_g = dialog.dialogOptions) === null || _g === void 0 ? void 0 : _g.snackbar) === null || _h === void 0 ? void 0 : _h.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) &&
224
+ (0, jsx_runtime_1.jsx)(React.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "resizable-handle", style: {
225
+ zIndex: parseInt(domZIndex) + 1
226
+ }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown, children: (0, jsx_runtime_1.jsx)(_icons_1.ResizeIcon, { color: '#286e94' }) }) })] })] }) });
194
227
  };
195
228
  exports.DialogContent = DialogContent;
@@ -41,6 +41,7 @@ var Resizeable = /** @class */ (function () {
41
41
  _this.init();
42
42
  };
43
43
  this.resizeHandleMouseMove = function (e) {
44
+ var _a;
44
45
  if (!_this.isResizing || !_this._container.current)
45
46
  return;
46
47
  if (!_this._container.current) {
@@ -55,8 +56,9 @@ var Resizeable = /** @class */ (function () {
55
56
  if (typeof _this._onResizeListener === "function") {
56
57
  _this._onResizeListener(_this._width, _this._height, rect);
57
58
  }
58
- _this._container.current.style.width = _this._width + 'px';
59
- _this._container.current.style.height = _this._height + 'px';
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';
60
62
  };
61
63
  this.init = function () {
62
64
  if (_this.isResizing) {
@@ -0,0 +1,5 @@
1
+ declare const _default: ({ size, color }: {
2
+ size?: number;
3
+ color?: string;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export default _default;
@@ -0,0 +1,18 @@
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
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ var jsx_runtime_1 = require("react/jsx-runtime");
15
+ exports.default = (function (_a) {
16
+ var size = _a.size, color = _a.color;
17
+ return (0, jsx_runtime_1.jsx)("div", { className: 'close-icon icon-base', style: __assign({ fill: color }, size ? { width: size } : null), children: (0, jsx_runtime_1.jsx)("svg", { focusable: "false", "aria-hidden": "true", viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { d: "M5 12h14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) });
18
+ });
@@ -0,0 +1,5 @@
1
+ declare const _default: ({ size, color }: {
2
+ size?: number;
3
+ color?: string;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export default _default;
@@ -0,0 +1,18 @@
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
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ var jsx_runtime_1 = require("react/jsx-runtime");
15
+ exports.default = (function (_a) {
16
+ var size = _a.size, color = _a.color;
17
+ return (0, jsx_runtime_1.jsx)("div", { className: 'close-icon icon-base', style: __assign({ fill: color }, size ? { width: size } : null), children: (0, jsx_runtime_1.jsx)("svg", { focusable: "false", "aria-hidden": "true", viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { d: "M12 5v14M5 12h14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) });
18
+ });
@@ -34,6 +34,7 @@ var BASE_DIALOG_OPTIONS = {
34
34
  opacity: 0.6,
35
35
  hideOnClick: false,
36
36
  },
37
+ scale: 1,
37
38
  base: {
38
39
  style: {
39
40
  backgroundColor: "white",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.124",
3
+ "version": "1.1.125",
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
@@ -215,6 +215,28 @@
215
215
  overflow: clip;
216
216
  pointer-events: auto;
217
217
  }
218
+ .dialog-main .dialog-zoom-root {
219
+ display: flex;
220
+ flex-direction: column;
221
+ align-items: center;
222
+ row-gap: 11px;
223
+ padding-top: 10px;
224
+ padding-bottom: 20px;
225
+ position: absolute;
226
+ top: 4px;
227
+ /* height: 120px; */
228
+ right: -40px;
229
+ /* width: 80px; */
230
+ background: rgba(0, 0, 0, 0.1);
231
+ border: 1px solid #CCC;
232
+ border-radius: 32px;
233
+ }
234
+ .dialog-main .dialog-zoom-root .dialog-zoom-wrapper .zoom-action {
235
+ cursor: pointer;
236
+ }
237
+ .dialog-main .dialog-zoom-root .dialog-zoom-label {
238
+ transform: rotate(-90deg);
239
+ }
218
240
  .dialog-main .actions-wrapper {
219
241
  display: flex;
220
242
  flex-direction: row;
@@ -293,6 +315,7 @@
293
315
  align-items: center;
294
316
  justify-content: space-between;
295
317
  flex: 0;
318
+ overflow: hidden;
296
319
  }
297
320
  .dialog-main .resizable-handle {
298
321
  position: absolute;
@@ -82,8 +82,9 @@ interface IDialogOptionsType {
82
82
  busyMessage?: string;
83
83
  [k: string]: any;
84
84
  };
85
+ scale?: number;
85
86
  }
86
- export type DialogOptionsType = Partial<Pick<IDialogOptionsType, 'base' | 'snackbar' | 'backdrop' | 'slotProps' | 'slot' | 'animate' | 'progress' | 'localText'>>;
87
+ export type DialogOptionsType = Partial<Pick<IDialogOptionsType, 'base' | 'snackbar' | 'backdrop' | 'slotProps' | 'slot' | 'animate' | 'progress' | 'scale' | 'localText'>>;
87
88
  interface kSlot {
88
89
  action?: React.JSXElementConstructor<any>;
89
90
  footer?: React.JSXElementConstructor<any>;