wenay-react2 1.0.20 → 1.0.21
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 +383 -382
- package/lib/common/api.d.ts +28 -0
- package/lib/common/api.js +41 -16
- package/lib/common/src/components/Buttons/MiniButton.d.ts +1 -0
- package/lib/common/src/components/Buttons/MiniButton.js +2 -2
- package/lib/common/src/components/Dnd/DraggableOutlineDiv.d.ts +1 -0
- package/lib/common/src/components/Dnd/DraggableOutlineDiv.js +7 -6
- package/lib/common/src/components/Dnd/RNDFunc.js +28 -17
- package/lib/common/src/components/Dnd/RNDFunc3.d.ts +27 -17
- package/lib/common/src/components/Dnd/RNDFunc3.js +107 -105
- package/lib/common/src/components/Dnd/Resizable.js +3 -3
- package/lib/common/src/components/Menu/RightMenu.js +11 -17
- package/lib/common/src/components/Menu/StickerMenu.js +42 -28
- package/lib/common/src/components/Menu/index.d.ts +1 -1
- package/lib/common/src/components/Menu/index.js +1 -1
- package/lib/common/src/components/Modal/LeftModal.d.ts +14 -12
- package/lib/common/src/components/Modal/LeftModal.js +30 -16
- package/lib/common/src/components/Modal/Modal.d.ts +26 -12
- package/lib/common/src/components/Modal/Modal.js +66 -89
- package/lib/common/src/components/Modal/ModalContextProvider.d.ts +20 -3
- package/lib/common/src/components/Modal/ModalContextProvider.js +35 -8
- package/lib/common/src/components/MyResizeObserver.js +15 -18
- package/lib/common/src/components/Other.js +3 -2
- package/lib/common/src/components/Parameters.js +7 -6
- package/lib/common/src/components/ParametersEngine.js +25 -54
- package/lib/common/src/grid/agGrid4/agGrid4.d.ts +53 -0
- package/lib/common/src/grid/agGrid4/agGrid4.js +132 -0
- package/lib/common/src/grid/agGrid4/core.d.ts +56 -0
- package/lib/common/src/grid/agGrid4/core.js +127 -0
- package/lib/common/src/grid/agGrid4/index.d.ts +6 -0
- package/lib/common/src/grid/agGrid4/index.js +3 -0
- package/lib/common/src/grid/agGrid4/theme.d.ts +7 -0
- package/lib/common/src/grid/agGrid4/theme.js +18 -0
- package/lib/common/src/hooks/useAddDownAnyKey.d.ts +21 -2
- package/lib/common/src/hooks/useAddDownAnyKey.js +46 -8
- package/lib/common/src/hooks/useDraggable.d.ts +20 -2
- package/lib/common/src/hooks/useDraggable.js +146 -115
- package/lib/common/src/hooks/useOutside.d.ts +24 -4
- package/lib/common/src/hooks/useOutside.js +76 -27
- package/lib/common/src/logs/logs.d.ts +5 -2
- package/lib/common/src/logs/logs.js +15 -31
- package/lib/common/src/logs/logs3.d.ts +9 -9
- package/lib/common/src/logs/logs3.js +47 -38
- package/lib/common/src/logs/miniLogs.d.ts +3 -3
- package/lib/common/src/logs/miniLogs.js +28 -36
- package/lib/common/src/menu/menu.d.ts +18 -18
- package/lib/common/src/menu/menu.js +48 -24
- package/lib/common/src/menu/menuMouse.js +4 -1
- package/lib/common/src/menu/menuR.d.ts +2 -2
- package/lib/common/src/menu/menuR.js +34 -34
- package/lib/common/src/myChart/1/myChart.d.ts +5 -5
- package/lib/common/src/myChart/1/myChart.js +58 -47
- package/lib/common/src/myChart/1/myChartTest.js +8 -4
- package/lib/common/src/myChart/chartEngine/chartEngineReact.d.ts +24 -27
- package/lib/common/src/myChart/chartEngine/chartEngineReact.js +166 -117
- package/lib/common/src/styles/styleGrid.d.ts +2 -1
- package/lib/common/src/styles/styleGrid.js +10 -12
- package/lib/common/src/styles/tokens.d.ts +39 -0
- package/lib/common/src/styles/tokens.js +40 -0
- package/lib/common/src/utils/applyTransactionAsyncUpdate.d.ts +7 -0
- package/lib/common/src/utils/applyTransactionAsyncUpdate.js +19 -12
- package/lib/common/src/utils/arrayPromise.d.ts +6 -0
- package/lib/common/src/utils/arrayPromise.js +7 -1
- package/lib/common/src/utils/cache.js +24 -21
- package/lib/common/src/utils/inputAutoStep.d.ts +1 -1
- package/lib/common/src/utils/inputAutoStep.js +30 -19
- package/lib/common/src/utils/mapMemory.js +9 -10
- package/lib/common/updateBy.d.ts +21 -2
- package/lib/common/updateBy.js +66 -31
- package/lib/index.js +0 -2
- package/lib/style/menuRight.css +13 -26
- package/lib/style/style.css +51 -39
- package/lib/style/tokens.css +34 -0
- package/package.json +2 -2
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useLayoutEffect,
|
|
2
|
+
import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
3
|
import { Rnd } from "react-rnd";
|
|
4
4
|
import { renderBy, updateBy } from "../../../updateBy";
|
|
5
|
-
//
|
|
5
|
+
// Map of all popup window sizes
|
|
6
6
|
export const ExRNDMap3 = new Map();
|
|
7
7
|
// limit={{x:{min:0}, y:{min:0}}}
|
|
8
8
|
let k = 0;
|
|
9
9
|
const openWindows = { ar: [] };
|
|
10
|
+
// Freezes the subtree until update changes (intentionally ignores render closure changes) -
|
|
11
|
+
// the previous useMemo-in-callback semantics, but without calling a hook from an arbitrary place
|
|
12
|
+
const MemoChild = React.memo(({ update, render }) => render(update), (prev, next) => prev.update === next.update);
|
|
10
13
|
export const DivRnd3 = (a) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const Base2 = ({ update }) => {
|
|
16
|
-
return typeof a.children === "function" ? a.children(update) : a.children;
|
|
17
|
-
};
|
|
18
|
-
// const ff = (update: number) => useMemo(() => <Base update={update} />, [update]);
|
|
19
|
-
const ff = (update) => useMemo(() => _jsx(Base2, { update: update }), [typeof a.children === "function" ? update : true]);
|
|
20
|
-
return DivRndBase3({ ...a, children: ff });
|
|
14
|
+
const isFunc = typeof a.children === "function";
|
|
15
|
+
const renderChild = (update) => typeof a.children === "function" ? a.children(update) : a.children;
|
|
16
|
+
const ff = (update) => _jsx(MemoChild, { update: isFunc ? update : 0, render: renderChild });
|
|
17
|
+
return _jsx(DivRndBase3, { ...a, children: ff });
|
|
21
18
|
};
|
|
22
19
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* Wrapper component around react-rnd.
|
|
21
|
+
* Provides dragging and resizing, an optional header, and a close button.
|
|
25
22
|
*/
|
|
26
23
|
export function DivRndBase3({ children, keyForSave: ks, position, size, overflow = true, zIndex = 9, onUpdate, disableDragging, className, header, moveOnlyHeader, limit, onCLickClose, sizeByWindow = true }) {
|
|
27
24
|
if (onCLickClose && !limit) {
|
|
@@ -29,17 +26,13 @@ export function DivRndBase3({ children, keyForSave: ks, position, size, overflow
|
|
|
29
26
|
}
|
|
30
27
|
const positionDef = { x: 0, y: 0, ...(position ?? {}) };
|
|
31
28
|
const sizeDef = { height: 0, width: 0, ...(size ?? {}) };
|
|
32
|
-
//
|
|
29
|
+
// If there is a key, store position and size data in the map
|
|
33
30
|
let map;
|
|
34
31
|
if (ks) {
|
|
35
32
|
map = ExRNDMap3.get(ks) ?? ExRNDMap3.set(ks, { size: sizeDef, position: positionDef }).get(ks);
|
|
36
33
|
}
|
|
37
34
|
position = map?.position ?? positionDef;
|
|
38
35
|
size = map?.size ?? sizeDef;
|
|
39
|
-
// Если нужно вписаться в окно по размеру
|
|
40
|
-
if (sizeByWindow) {
|
|
41
|
-
// ...здесь можно добавить логику проверки/коррекции на window.innerWidth, window.innerHeight и т.д.
|
|
42
|
-
}
|
|
43
36
|
const id2 = useRef({ k: k++ });
|
|
44
37
|
const id = id2.current;
|
|
45
38
|
const [zIndexX, setZIndexX] = useState(0);
|
|
@@ -47,47 +40,48 @@ export function DivRndBase3({ children, keyForSave: ks, position, size, overflow
|
|
|
47
40
|
const lastT = useRef(null);
|
|
48
41
|
const [a, setA] = useState(false);
|
|
49
42
|
const [b, setB] = useState(false);
|
|
50
|
-
const [x, setX] = useState(position
|
|
51
|
-
const [y, setY] = useState(position
|
|
52
|
-
const [width, setWidth] = useState(size
|
|
53
|
-
const [height, setHeight] = useState(size
|
|
43
|
+
const [x, setX] = useState(position.x);
|
|
44
|
+
const [y, setY] = useState(position.y);
|
|
45
|
+
const [width, setWidth] = useState(size.width);
|
|
46
|
+
const [height, setHeight] = useState(size.height);
|
|
54
47
|
const [update, setUpdate] = useState(0);
|
|
55
48
|
const zindex = useRef(zIndexX);
|
|
56
49
|
zindex.current = zIndexX;
|
|
57
|
-
//
|
|
50
|
+
// Update the window zIndex if it was brought to the top
|
|
58
51
|
updateBy(openWindows, () => {
|
|
59
52
|
const z = openWindows.ar.findIndex((v) => v.k === id.k);
|
|
60
53
|
if (z >= 0 && z !== zindex.current) {
|
|
61
54
|
setZIndexX(z);
|
|
62
55
|
}
|
|
63
56
|
});
|
|
57
|
+
// limit via ref: an inline object in props must not resubscribe document listeners on every render
|
|
58
|
+
const limitRef = useRef(limit);
|
|
59
|
+
useLayoutEffect(() => { limitRef.current = limit; });
|
|
64
60
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
61
|
+
* Hook for mouse dragging (a) and touch-device dragging (b).
|
|
62
|
+
* Remove subscriptions on unmount and when dependencies change (a/b).
|
|
67
63
|
*/
|
|
68
64
|
useEffect(() => {
|
|
69
|
-
//
|
|
65
|
+
// Mouse
|
|
70
66
|
const mouseMoveHandler = (e) => {
|
|
71
67
|
e.stopPropagation();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
y: e.clientY
|
|
76
|
-
};
|
|
77
|
-
}
|
|
68
|
+
// mousedown always sets lastC before this subscription exists
|
|
69
|
+
if (lastC.current == null)
|
|
70
|
+
return;
|
|
78
71
|
const data = lastC.current;
|
|
79
72
|
if (e.buttons === 1) {
|
|
80
73
|
let newX = e.clientX + data.x;
|
|
81
74
|
let newY = e.clientY + data.y;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
const lim = limitRef.current;
|
|
76
|
+
if (lim) {
|
|
77
|
+
if (lim.x?.min !== undefined && lim.x.min > newX)
|
|
78
|
+
newX = lim.x.min;
|
|
79
|
+
if (lim.x?.max !== undefined && lim.x.max < newX)
|
|
80
|
+
newX = lim.x.max;
|
|
81
|
+
if (lim.y?.min !== undefined && lim.y.min > newY)
|
|
82
|
+
newY = lim.y.min;
|
|
83
|
+
if (lim.y?.max !== undefined && lim.y.max < newY)
|
|
84
|
+
newY = lim.y.max;
|
|
91
85
|
}
|
|
92
86
|
setX(newX);
|
|
93
87
|
setY(newY);
|
|
@@ -102,7 +96,7 @@ export function DivRndBase3({ children, keyForSave: ks, position, size, overflow
|
|
|
102
96
|
lastC.current = null;
|
|
103
97
|
setA(false);
|
|
104
98
|
};
|
|
105
|
-
//
|
|
99
|
+
// Touch
|
|
106
100
|
const touchMoveHandler = (e) => {
|
|
107
101
|
const data = lastT.current;
|
|
108
102
|
if (!data)
|
|
@@ -117,15 +111,16 @@ export function DivRndBase3({ children, keyForSave: ks, position, size, overflow
|
|
|
117
111
|
return;
|
|
118
112
|
let newX = t.clientX + data.x;
|
|
119
113
|
let newY = t.clientY + data.y;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
114
|
+
const lim = limitRef.current;
|
|
115
|
+
if (lim) {
|
|
116
|
+
if (lim.x?.min !== undefined && lim.x.min > newX)
|
|
117
|
+
newX = lim.x.min;
|
|
118
|
+
if (lim.x?.max !== undefined && lim.x.max < newX)
|
|
119
|
+
newX = lim.x.max;
|
|
120
|
+
if (lim.y?.min !== undefined && lim.y.min > newY)
|
|
121
|
+
newY = lim.y.min;
|
|
122
|
+
if (lim.y?.max !== undefined && lim.y.max < newY)
|
|
123
|
+
newY = lim.y.max;
|
|
129
124
|
}
|
|
130
125
|
setX(newX);
|
|
131
126
|
setY(newY);
|
|
@@ -146,25 +141,25 @@ export function DivRndBase3({ children, keyForSave: ks, position, size, overflow
|
|
|
146
141
|
setB(false);
|
|
147
142
|
}
|
|
148
143
|
};
|
|
149
|
-
//
|
|
144
|
+
// If mouse dragging mode is active
|
|
150
145
|
if (a) {
|
|
151
146
|
document.addEventListener("mousemove", mouseMoveHandler);
|
|
152
147
|
document.addEventListener("mouseup", mouseUpHandler);
|
|
153
148
|
}
|
|
154
|
-
//
|
|
149
|
+
// If touch-event dragging mode is active
|
|
155
150
|
if (b) {
|
|
156
151
|
document.addEventListener("touchmove", touchMoveHandler);
|
|
157
152
|
document.addEventListener("touchend", touchEndHandler);
|
|
158
153
|
}
|
|
159
|
-
//
|
|
154
|
+
// Return the cleanup function for unmount and a/b changes:
|
|
160
155
|
return () => {
|
|
161
156
|
document.removeEventListener("mousemove", mouseMoveHandler);
|
|
162
157
|
document.removeEventListener("mouseup", mouseUpHandler);
|
|
163
158
|
document.removeEventListener("touchmove", touchMoveHandler);
|
|
164
159
|
document.removeEventListener("touchend", touchEndHandler);
|
|
165
160
|
};
|
|
166
|
-
}, [a, b
|
|
167
|
-
//
|
|
161
|
+
}, [a, b]);
|
|
162
|
+
// On the first render, add the window to the array; remove it on unmount
|
|
168
163
|
useEffect(() => {
|
|
169
164
|
openWindows.ar.push(id);
|
|
170
165
|
renderBy(openWindows);
|
|
@@ -176,7 +171,7 @@ export function DivRndBase3({ children, keyForSave: ks, position, size, overflow
|
|
|
176
171
|
}
|
|
177
172
|
};
|
|
178
173
|
}, []);
|
|
179
|
-
//
|
|
174
|
+
// Update coordinates and size in the map if keyForSave is set
|
|
180
175
|
if (size) {
|
|
181
176
|
size.height = height;
|
|
182
177
|
size.width = width;
|
|
@@ -185,22 +180,26 @@ export function DivRndBase3({ children, keyForSave: ks, position, size, overflow
|
|
|
185
180
|
position.x = x;
|
|
186
181
|
position.y = y;
|
|
187
182
|
}
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
183
|
+
const headerRef = useRef(null);
|
|
184
|
+
// clamp to the viewport in a layout effect: an inline ref-callback ran twice per render
|
|
185
|
+
// (null + element) with a forced reflow from getBoundingClientRect on each call
|
|
186
|
+
useLayoutEffect(() => {
|
|
187
|
+
const el = headerRef.current;
|
|
188
|
+
if (!el || !sizeByWindow)
|
|
189
|
+
return;
|
|
190
|
+
const rect = el.getBoundingClientRect();
|
|
191
|
+
if (rect.x < 0)
|
|
192
|
+
setX(x - rect.x);
|
|
193
|
+
if (rect.y < 0)
|
|
194
|
+
setY(y - rect.y);
|
|
195
|
+
if (typeof width === "number" && width > window.innerWidth) {
|
|
196
|
+
setWidth(window.innerWidth);
|
|
197
|
+
}
|
|
198
|
+
if (typeof height === "number" && height > window.innerHeight) {
|
|
199
|
+
setHeight(window.innerHeight);
|
|
200
|
+
}
|
|
201
|
+
}, [x, y, width, height, sizeByWindow]);
|
|
202
|
+
const headerD = (_jsx("div", { ref: headerRef, onTouchStart: (e) => {
|
|
204
203
|
const t = e.changedTouches[0];
|
|
205
204
|
if (t) {
|
|
206
205
|
lastT.current = {
|
|
@@ -229,8 +228,9 @@ export function DivRndBase3({ children, keyForSave: ks, position, size, overflow
|
|
|
229
228
|
}, className: className, onResizeStop: (e, dir, elementRef, delta, { x: nx, y: ny }) => {
|
|
230
229
|
setX(nx);
|
|
231
230
|
setY(ny);
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
// actual element size: `+height + delta.height` gave NaN for string sizes like "100%"
|
|
232
|
+
setHeight(elementRef.offsetHeight);
|
|
233
|
+
setWidth(elementRef.offsetWidth);
|
|
234
234
|
setUpdate(update + 1);
|
|
235
235
|
}, onResize: (e, dir, elementRef, delta, pos) => {
|
|
236
236
|
onUpdate?.({ e, dir, elementRef, delta, position: pos });
|
|
@@ -245,7 +245,7 @@ export function DivRndBase3({ children, keyForSave: ks, position, size, overflow
|
|
|
245
245
|
position: "relative",
|
|
246
246
|
flex: "auto"
|
|
247
247
|
}, onMouseDown: () => {
|
|
248
|
-
//
|
|
248
|
+
// Bring the window to the top
|
|
249
249
|
const z = openWindows.ar.findIndex((v) => v === id);
|
|
250
250
|
if (z !== openWindows.ar.length - 1 || zindex.current !== z) {
|
|
251
251
|
const buf = openWindows.ar[z];
|
|
@@ -256,21 +256,19 @@ export function DivRndBase3({ children, keyForSave: ks, position, size, overflow
|
|
|
256
256
|
}, children: [moveOnlyHeader || header ? headerD : null, _jsxs("div", { className: "maxSize", style: { overflow: overflow ? "auto" : undefined }, children: [(a || b) && (_jsx("div", { className: "maxSize", style: {
|
|
257
257
|
position: "absolute",
|
|
258
258
|
zIndex: zIndexX * 2 + zIndex + 1
|
|
259
|
-
} })), typeof children === "function" ? children(update) : children] }), onCLickClose && (_jsx("div", { className: "
|
|
259
|
+
} })), typeof children === "function" ? children(update) : children] }), onCLickClose && (_jsx("div", { className: "wenayCloseBtn", title: "Close", style: {
|
|
260
260
|
position: "absolute",
|
|
261
|
-
right: -
|
|
262
|
-
top: -
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
cursor: "pointer"
|
|
266
|
-
}, onClick: onCLickClose, children: "x" }, "323"))] }) }));
|
|
261
|
+
right: -12,
|
|
262
|
+
top: -12,
|
|
263
|
+
zIndex: zIndexX * 2 + zIndex + 1
|
|
264
|
+
}, onClick: onCLickClose, children: _jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", children: _jsx("path", { d: "M2 2 L10 10 M10 2 L2 10", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) }) }, "323"))] }) }));
|
|
267
265
|
}
|
|
268
266
|
/**
|
|
269
|
-
*
|
|
270
|
-
*
|
|
267
|
+
* Wrapper component that lets a nested element be dragged
|
|
268
|
+
* with both mouse and touch input.
|
|
271
269
|
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
270
|
+
* Function only as a hook for parameter changes during movement, although it has its own component (for offset counting).
|
|
271
|
+
* Returns the distance traveled when moving the child element.
|
|
274
272
|
*/
|
|
275
273
|
export function Drag22({ children, onX, onY, x = 0, y = 0, right = false, last, dragging, onStart, onStop }) {
|
|
276
274
|
const offsetMouse = useRef({ x: 0, y: 0 });
|
|
@@ -278,22 +276,30 @@ export function Drag22({ children, onX, onY, x = 0, y = 0, right = false, last,
|
|
|
278
276
|
const [draggingMouse, setDraggingMouse] = useState(false);
|
|
279
277
|
const [draggingTouch, setDraggingTouch] = useState(false);
|
|
280
278
|
const posRef = useRef(last?.current ?? { x, y });
|
|
279
|
+
const wasDragging = useRef(false);
|
|
280
|
+
const callbacksRef = useRef({ onX, onY, onStart, onStop });
|
|
281
|
+
callbacksRef.current = { onX, onY, onStart, onStop };
|
|
281
282
|
useLayoutEffect(() => {
|
|
282
283
|
posRef.current.x = x;
|
|
283
284
|
posRef.current.y = y;
|
|
284
285
|
}, [x, y]);
|
|
285
286
|
useEffect(() => {
|
|
286
287
|
if (!draggingMouse && !draggingTouch) {
|
|
287
|
-
onStop
|
|
288
|
+
// onStop only after a real drag - previously it also fired on initial mount
|
|
289
|
+
if (wasDragging.current) {
|
|
290
|
+
wasDragging.current = false;
|
|
291
|
+
callbacksRef.current.onStop?.();
|
|
292
|
+
}
|
|
288
293
|
return;
|
|
289
294
|
}
|
|
295
|
+
wasDragging.current = true;
|
|
290
296
|
if (draggingMouse) {
|
|
291
297
|
const handleMouseMove = (e) => {
|
|
292
298
|
const newX = e.clientX + offsetMouse.current.x;
|
|
293
299
|
const newY = e.clientY + offsetMouse.current.y;
|
|
294
300
|
posRef.current = { x: newX, y: newY };
|
|
295
|
-
onX?.(newX);
|
|
296
|
-
onY?.(newY);
|
|
301
|
+
callbacksRef.current.onX?.(newX);
|
|
302
|
+
callbacksRef.current.onY?.(newY);
|
|
297
303
|
};
|
|
298
304
|
const handleMouseUp = () => {
|
|
299
305
|
offsetMouse.current.x = 0;
|
|
@@ -304,7 +310,7 @@ export function Drag22({ children, onX, onY, x = 0, y = 0, right = false, last,
|
|
|
304
310
|
};
|
|
305
311
|
document.addEventListener("mousemove", handleMouseMove);
|
|
306
312
|
document.addEventListener("mouseup", handleMouseUp);
|
|
307
|
-
onStart?.();
|
|
313
|
+
callbacksRef.current.onStart?.();
|
|
308
314
|
return () => {
|
|
309
315
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
310
316
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
@@ -320,8 +326,8 @@ export function Drag22({ children, onX, onY, x = 0, y = 0, right = false, last,
|
|
|
320
326
|
const newX = theTouch.clientX + offsetTouch.current.x;
|
|
321
327
|
const newY = theTouch.clientY + offsetTouch.current.y;
|
|
322
328
|
posRef.current = { x: newX, y: newY };
|
|
323
|
-
onX?.(newX);
|
|
324
|
-
onY?.(newY);
|
|
329
|
+
callbacksRef.current.onX?.(newX);
|
|
330
|
+
callbacksRef.current.onY?.(newY);
|
|
325
331
|
};
|
|
326
332
|
const handleTouchEnd = (e) => {
|
|
327
333
|
if (!offsetTouch.current)
|
|
@@ -336,13 +342,13 @@ export function Drag22({ children, onX, onY, x = 0, y = 0, right = false, last,
|
|
|
336
342
|
};
|
|
337
343
|
document.addEventListener("touchmove", handleTouchMove);
|
|
338
344
|
document.addEventListener("touchend", handleTouchEnd);
|
|
339
|
-
onStart?.();
|
|
345
|
+
callbacksRef.current.onStart?.();
|
|
340
346
|
return () => {
|
|
341
347
|
document.removeEventListener("touchmove", handleTouchMove);
|
|
342
348
|
document.removeEventListener("touchend", handleTouchEnd);
|
|
343
349
|
};
|
|
344
350
|
}
|
|
345
|
-
}, [draggingMouse, draggingTouch
|
|
351
|
+
}, [draggingMouse, draggingTouch]);
|
|
346
352
|
useLayoutEffect(() => {
|
|
347
353
|
if (last) {
|
|
348
354
|
last.current = posRef.current;
|
|
@@ -352,21 +358,17 @@ export function Drag22({ children, onX, onY, x = 0, y = 0, right = false, last,
|
|
|
352
358
|
e.preventDefault();
|
|
353
359
|
posRef.current.x = 0;
|
|
354
360
|
posRef.current.y = 0;
|
|
355
|
-
offsetMouse.current = {
|
|
356
|
-
x: posRef.current.x - e.clientX,
|
|
357
|
-
y: posRef.current.y - e.clientY
|
|
358
|
-
};
|
|
361
|
+
offsetMouse.current = { x: -e.clientX, y: -e.clientY };
|
|
359
362
|
setDraggingMouse(true);
|
|
360
363
|
};
|
|
361
364
|
const handleTouchStart = (e) => {
|
|
362
365
|
const t = e.changedTouches[0];
|
|
363
366
|
if (!t)
|
|
364
367
|
return;
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
};
|
|
368
|
+
// same per-gesture reset as mouse - without it repeated touch drags accumulated offset
|
|
369
|
+
posRef.current.x = 0;
|
|
370
|
+
posRef.current.y = 0;
|
|
371
|
+
offsetTouch.current = { x: -t.clientX, y: -t.clientY, id: t.identifier };
|
|
370
372
|
setDraggingTouch(true);
|
|
371
373
|
};
|
|
372
374
|
return (_jsx("div", { style: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Resizable } from "re-resizable";
|
|
3
|
-
//
|
|
3
|
+
// Memory for all column sizes
|
|
4
4
|
export const mapResiReact = new Map();
|
|
5
5
|
export function FResizableReact({ style, onResize, enable, children, keyForSave, onResizeStop, size = { height: 50, width: 50 }, minWidth, minHeight, maxWidth = "100%", maxHeight = "100%", moveWith = true, moveHeight = true }) {
|
|
6
6
|
let obj = size;
|
|
@@ -12,8 +12,8 @@ export function FResizableReact({ style, onResize, enable, children, keyForSave,
|
|
|
12
12
|
mapResiReact.set(keyForSave, obj);
|
|
13
13
|
}
|
|
14
14
|
return _jsx(Resizable, { style: style, onResize: (event, direction, elementRef, delta) => {
|
|
15
|
-
onResize?.();
|
|
16
|
-
//
|
|
15
|
+
onResize?.(obj);
|
|
16
|
+
// Workaround for a bug that appears when the parent div changes
|
|
17
17
|
if (moveHeight == false && typeof obj.height == "string" && elementRef.style.height != obj.height)
|
|
18
18
|
elementRef.style.height = obj.height;
|
|
19
19
|
}, enable: enable, onResizeStop: (e, dir, elementRef, delta) => {
|
|
@@ -10,14 +10,14 @@ export function DropdownMenu({ elements, style, position: initialPosition = 'rig
|
|
|
10
10
|
const [isFixed, setIsFixed] = useState(false);
|
|
11
11
|
const [select, setSelect] = useState(null);
|
|
12
12
|
const data = useRef({ m1: false, m2: false });
|
|
13
|
-
//
|
|
13
|
+
// Get modal JSX functions
|
|
14
14
|
const jsx = useMemo(GetModalFuncJSX, []);
|
|
15
15
|
const jsxRender = useMemo(() => _jsx(jsx.Render, {}), [jsx]);
|
|
16
16
|
const [position, setPosition] = useState(initialPosition);
|
|
17
17
|
const [isTop, setIsTop] = useState(initialPos2 === 'top');
|
|
18
18
|
const positionLast = useRef({ x: 0, y: 0 });
|
|
19
19
|
const handleDragEnd = useCallback((finalPosition) => {
|
|
20
|
-
//
|
|
20
|
+
// Handle horizontal offset
|
|
21
21
|
if (position === 'left') {
|
|
22
22
|
positionLast.current.x += finalPosition.x;
|
|
23
23
|
if (positionLast.current.x > window.innerWidth * 0.6) {
|
|
@@ -32,7 +32,7 @@ export function DropdownMenu({ elements, style, position: initialPosition = 'rig
|
|
|
32
32
|
setPosition('left');
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
//
|
|
35
|
+
// Handle vertical offset
|
|
36
36
|
if (isTop) {
|
|
37
37
|
positionLast.current.y += finalPosition.y;
|
|
38
38
|
if (positionLast.current.y > document.documentElement.clientHeight * 0.6) {
|
|
@@ -49,7 +49,7 @@ export function DropdownMenu({ elements, style, position: initialPosition = 'rig
|
|
|
49
49
|
}
|
|
50
50
|
}, [position, isTop]);
|
|
51
51
|
const { position: pos, dragProps } = useDraggable(0, 0, 50, handleDragEnd, () => { });
|
|
52
|
-
//
|
|
52
|
+
// Click and hover handlers
|
|
53
53
|
const handleClickOutside = useCallback(() => {
|
|
54
54
|
setIsOpen(false);
|
|
55
55
|
}, []);
|
|
@@ -83,33 +83,27 @@ export function DropdownMenu({ elements, style, position: initialPosition = 'rig
|
|
|
83
83
|
setSelect(null);
|
|
84
84
|
}
|
|
85
85
|
}, [jsx]);
|
|
86
|
-
//
|
|
87
|
-
const dop = (isFixed || isOpen) && (_jsxs("div", { onMouseEnter:
|
|
88
|
-
data.current.m1 = true;
|
|
89
|
-
}, onMouseLeave: () => {
|
|
90
|
-
data.current.m1 = false;
|
|
91
|
-
jsx.set(null);
|
|
92
|
-
setSelect(null);
|
|
93
|
-
}, className: `dropdown-content2 ${!isTop ? 'dropdown-up' : ''}`, style: {
|
|
86
|
+
// Render dropdown menu (dop)
|
|
87
|
+
const dop = (isFixed || isOpen) && (_jsxs("div", { onMouseEnter: handleContentMouseEnter, onMouseLeave: handleContentMouseLeave, className: `dropdown-content2 ${!isTop ? 'dropdown-up' : ''}`, style: {
|
|
94
88
|
display: 'flex',
|
|
95
89
|
[position]: 0,
|
|
96
90
|
right: position === 'left' ? 'auto' : 0,
|
|
97
91
|
flexDirection: position === 'left' ? 'row' : 'row-reverse'
|
|
98
|
-
}, children: [_jsx("div", { className: "dropdown-content", onMouseEnter: handleContentMouseEnter, onMouseLeave: handleContentMouseLeave, children: elements.map((item, index) => (_jsx("div", { className: `menu-item ${select === index ? 'force-hover' : ''}`, onMouseEnter: () => handleSelect(item, index), onClick: () => handleSelect(item, index), children: item.label },
|
|
99
|
-
//
|
|
92
|
+
}, children: [_jsx("div", { className: "dropdown-content", onMouseEnter: handleContentMouseEnter, onMouseLeave: handleContentMouseLeave, children: elements.map((item, index) => (_jsx("div", { className: `menu-item ${select === index ? 'force-hover' : ''}`, onMouseEnter: () => handleSelect(item, index), onClick: () => handleSelect(item, index), children: item.label }, item.label))) }), _jsx("div", { onMouseEnter: handleSubmenuMouseEnter, onMouseLeave: handleSubmenuMouseLeave, children: jsx.JSX ? (_jsx("div", { className: "submenu", style: { width: '40vw', minHeight: '70vh' }, children: jsxRender })) : null })] }));
|
|
93
|
+
// Calculate offsets
|
|
100
94
|
const computedX = position === 'left'
|
|
101
95
|
? positionLast.current.x + pos.x
|
|
102
96
|
: positionLast.current.x - pos.x;
|
|
103
97
|
const computedY = isTop
|
|
104
98
|
? positionLast.current.y + pos.y
|
|
105
99
|
: positionLast.current.y - pos.y;
|
|
106
|
-
//
|
|
100
|
+
// Calculate menu container styles
|
|
107
101
|
const containerStyle = useMemo(() => {
|
|
108
102
|
const computedStyle = {
|
|
109
103
|
...style,
|
|
110
104
|
display: 'flex'
|
|
111
105
|
};
|
|
112
|
-
//
|
|
106
|
+
// Horizontal positioning
|
|
113
107
|
if (position === 'left') {
|
|
114
108
|
computedStyle.left = Math.max(0, Math.min(computedX, window.innerWidth - 50));
|
|
115
109
|
computedStyle.right = 'auto';
|
|
@@ -118,7 +112,7 @@ export function DropdownMenu({ elements, style, position: initialPosition = 'rig
|
|
|
118
112
|
computedStyle.right = Math.max(0, Math.min(computedX, window.innerWidth - 50));
|
|
119
113
|
computedStyle.left = 'auto';
|
|
120
114
|
}
|
|
121
|
-
//
|
|
115
|
+
// Vertical positioning
|
|
122
116
|
if (isTop) {
|
|
123
117
|
computedStyle.top = Math.max(0, Math.min(computedY, window.innerHeight - 50));
|
|
124
118
|
computedStyle.bottom = 'auto';
|