react-dialogger 1.1.127 → 1.1.129
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 +16 -0
- package/components/DialogContent.js +18 -15
- package/helpers/dialogBoundsMemoize.js +2 -2
- package/package.json +1 -1
- package/types/BoundTypes.d.ts +1 -0
- package/types/DialogTypes.d.ts +1 -1
package/README.md
CHANGED
|
@@ -123,6 +123,22 @@ Custom Dialog Configurations
|
|
|
123
123
|
|
|
124
124
|
Although a global configuration is set by useDialogOptions, each dialog can still be individually customized as needed. You can override the default settings for specific dialogs to meet particular requirements. This flexibility allows you to customize the appearance, behavior, and actions of each dialog instance separately, while still maintaining the benefits of a unified base configuration.
|
|
125
125
|
```
|
|
126
|
+
|
|
127
|
+
## New feature
|
|
128
|
+
```
|
|
129
|
+
backdrop: {
|
|
130
|
+
dimOnInactive: boolean
|
|
131
|
+
},
|
|
132
|
+
scaleable: boolean,
|
|
133
|
+
```
|
|
134
|
+
#### Explanations:
|
|
135
|
+
* <b>backdrop.dimOnInactive</b>:
|
|
136
|
+
When set to true, the dialog will dim the background when it becomes inactive. This makes it easier for the user to identify which dialog is currently active.
|
|
137
|
+
* <b>scaleable</b>:
|
|
138
|
+
When set to true, the dialog becomes resizable, allowing the user to change its size. When this feature is enabled, resizing handles will appear around the dialog.
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
126
142
|
## Example Usage
|
|
127
143
|
|
|
128
144
|
Below is an example of customizing a dialog using `baseDialogOptions`:
|
|
@@ -74,16 +74,16 @@ var appLogger_1 = require("../helpers/appLogger");
|
|
|
74
74
|
var PlusIcon_1 = __importDefault(require("../icons/PlusIcon"));
|
|
75
75
|
var MinusIcon_1 = __importDefault(require("../icons/MinusIcon"));
|
|
76
76
|
var DialogContent = function (props) {
|
|
77
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
77
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
78
78
|
var firstUpdate = React.useRef(true);
|
|
79
|
-
var
|
|
79
|
+
var _k = (0, react_1.useContext)(_context_1.DialogContentContext), dialog = _k.dialog, dialogRef = _k.dialogRef, prevDialogRect = _k.prevDialogRect, backdropRef = _k.backdropRef, snackbarRef = _k.snackbarRef, footerRef = _k.footerRef, bodyRef = _k.bodyRef, headerRef = _k.headerRef, resizeableObject = _k.resizeableObject, body = _k.body;
|
|
80
80
|
var dialogOptions = dialog.dialogOptions;
|
|
81
81
|
var baseOptions = dialogOptions.base;
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
var bounds = ((_b = dialog.dialogOptions.base) === null || _b === void 0 ? void 0 : _b.memoBounds) ? (0, _helpers_1.getDialogBounds)(dialog.dialogOptions.base.id) : null;
|
|
82
|
+
var _l = React.useState(false), fullscreenMode = _l[0], setFullscreenMode = _l[1];
|
|
83
|
+
var _m = React.useState(null), rect = _m[0], setRect = _m[1];
|
|
84
|
+
var bounds = ((_a = dialog.dialogOptions.base) === null || _a === void 0 ? void 0 : _a.memoBounds) ? (0, _helpers_1.getDialogBounds)(dialog.dialogOptions.base.id) : null;
|
|
86
85
|
var domZIndex = window.getComputedStyle(dialog.getDom()).zIndex;
|
|
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
89
|
var dialogRectSelectors = { xKey: 'marginLeft', yKey: 'marginTop' };
|
|
@@ -151,13 +151,16 @@ var DialogContent = function (props) {
|
|
|
151
151
|
dialogRef.current = null;
|
|
152
152
|
};
|
|
153
153
|
}, []);
|
|
154
|
-
// TODO Bi dene Zoom + Scale ile drag yapiliyor (Resize eksik) & Memo tam coordine degil!!
|
|
155
|
-
var scale = zoom; //dialogOptions?.scale ?? 1;
|
|
156
154
|
// Set Zoom
|
|
157
155
|
(0, react_1.useEffect)(function () {
|
|
156
|
+
var _a, _b;
|
|
158
157
|
dialogOptions.scale = zoom;
|
|
158
|
+
if (((_a = dialogOptions.base) === null || _a === void 0 ? void 0 : _a.memoBounds) && ((_b = dialogOptions.base) === null || _b === void 0 ? void 0 : _b.id)) {
|
|
159
|
+
// const gb = getDialogBounds(dialogOptions.base.id)
|
|
160
|
+
(0, _helpers_1.setDialogBounds)(dialogOptions.base.id, __assign(__assign({}, bounds), { scale: zoom }), dialogRef);
|
|
161
|
+
}
|
|
159
162
|
}, [zoom]);
|
|
160
|
-
return (0, jsx_runtime_1.jsx)(react_draggable_1.default, { disabled: !baseOptions.draggable || fullscreenMode, axis: 'both', handle: baseOptions.draggable ? '.drag-handle' : '', scale:
|
|
163
|
+
return (0, jsx_runtime_1.jsx)(react_draggable_1.default, { disabled: !baseOptions.draggable || fullscreenMode, axis: 'both', handle: baseOptions.draggable ? '.drag-handle' : '', scale: zoom, nodeRef: dialogRef, onDrag: function (event, data) {
|
|
161
164
|
event.stopPropagation();
|
|
162
165
|
dialog._dialogTranslate = { lastX: data.lastX, lastY: data.lastY };
|
|
163
166
|
}, onStop: function (event, data) {
|
|
@@ -167,10 +170,10 @@ var DialogContent = function (props) {
|
|
|
167
170
|
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;
|
|
168
171
|
(0, appLogger_1.appLog)('onDragStop', 'fired', (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect());
|
|
169
172
|
(0, _helpers_1.setDialogBounds)(dialogOptions.base.id, {
|
|
170
|
-
width: width /
|
|
171
|
-
height: height /
|
|
172
|
-
x: x /
|
|
173
|
-
y: y /
|
|
173
|
+
width: width / zoom,
|
|
174
|
+
height: height / zoom,
|
|
175
|
+
x: x / zoom,
|
|
176
|
+
y: y / zoom,
|
|
174
177
|
fullscreen: false
|
|
175
178
|
}, dialogRef);
|
|
176
179
|
}, children: (0, jsx_runtime_1.jsxs)("div", { onBlur: function (event) {
|
|
@@ -204,7 +207,7 @@ var DialogContent = function (props) {
|
|
|
204
207
|
// @ts-ignore
|
|
205
208
|
dialog.props.keyboardListener(e.key, _this);
|
|
206
209
|
}
|
|
207
|
-
}, 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: (
|
|
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 &&
|
|
208
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 () {
|
|
209
212
|
setZoom(function (prev) { return Number((prev + 0.1).toFixed(2)); }); // 0.6 → 0.7
|
|
210
213
|
}, children: (0, jsx_runtime_1.jsx)(PlusIcon_1.default, { size: 22 }) }), (0, jsx_runtime_1.jsx)("div", { className: "zoom-action", onClick: function (event) {
|
|
@@ -212,7 +215,7 @@ var DialogContent = function (props) {
|
|
|
212
215
|
setTimeout(function () {
|
|
213
216
|
event.clientX;
|
|
214
217
|
});
|
|
215
|
-
}, 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' }, (
|
|
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) &&
|
|
216
219
|
(0, jsx_runtime_1.jsx)(React.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "resizable-handle", style: {
|
|
217
220
|
zIndex: parseInt(domZIndex) + 1
|
|
218
221
|
}, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown, children: (0, jsx_runtime_1.jsx)(_icons_1.ResizeIcon, { color: '#286e94' }) }) })] })] }) });
|
|
@@ -78,7 +78,7 @@ var setDialogBounds = function (dialogId, bounds, dialogRef) {
|
|
|
78
78
|
// Save to RAM
|
|
79
79
|
initDialogMemoizeBounds_1.registeredDialogs.set(combined.join('-'), {
|
|
80
80
|
id: combined.join('-'),
|
|
81
|
-
bounds: bounds
|
|
81
|
+
bounds: __assign(__assign({}, (0, exports.getDialogBounds)(dialogId)), bounds)
|
|
82
82
|
});
|
|
83
83
|
/**
|
|
84
84
|
* const myMap = new Map();
|
|
@@ -92,7 +92,7 @@ var setDialogBounds = function (dialogId, bounds, dialogRef) {
|
|
|
92
92
|
*
|
|
93
93
|
* */
|
|
94
94
|
// Save to Store
|
|
95
|
-
|
|
95
|
+
// console.log('registeredDialogs', registeredDialogs);
|
|
96
96
|
try {
|
|
97
97
|
window.localStorage.setItem(initDialogMemoizeBounds_1.BOUNDS_STORE_KEY, JSON.stringify(Array.from(initDialogMemoizeBounds_1.registeredDialogs)));
|
|
98
98
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-dialogger",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.129",
|
|
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/types/BoundTypes.d.ts
CHANGED
package/types/DialogTypes.d.ts
CHANGED
|
@@ -233,7 +233,7 @@ export interface IBackdropOptions {
|
|
|
233
233
|
opacity?: number;
|
|
234
234
|
hideOnClick?: boolean;
|
|
235
235
|
throughable?: boolean;
|
|
236
|
-
dimOnInactive
|
|
236
|
+
dimOnInactive?: boolean;
|
|
237
237
|
}
|
|
238
238
|
export type TNotifyOnClosing = "snackbar" | "zoom" | undefined;
|
|
239
239
|
export type TInitialHolder = any;
|