wenay-react2 1.0.19 → 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.
Files changed (77) hide show
  1. package/README.md +383 -382
  2. package/lib/common/api.d.ts +28 -0
  3. package/lib/common/api.js +41 -16
  4. package/lib/common/src/components/Buttons/MiniButton.d.ts +1 -0
  5. package/lib/common/src/components/Buttons/MiniButton.js +2 -2
  6. package/lib/common/src/components/Dnd/DraggableOutlineDiv.d.ts +1 -0
  7. package/lib/common/src/components/Dnd/DraggableOutlineDiv.js +10 -7
  8. package/lib/common/src/components/Dnd/RNDFunc.js +28 -17
  9. package/lib/common/src/components/Dnd/RNDFunc3.d.ts +27 -17
  10. package/lib/common/src/components/Dnd/RNDFunc3.js +107 -107
  11. package/lib/common/src/components/Dnd/Resizable.js +3 -3
  12. package/lib/common/src/components/Input.js +3 -3
  13. package/lib/common/src/components/Menu/RightMenu.js +17 -18
  14. package/lib/common/src/components/Menu/StickerMenu.d.ts +1 -3
  15. package/lib/common/src/components/Menu/StickerMenu.js +42 -28
  16. package/lib/common/src/components/Menu/index.d.ts +1 -1
  17. package/lib/common/src/components/Menu/index.js +1 -1
  18. package/lib/common/src/components/Modal/LeftModal.d.ts +14 -12
  19. package/lib/common/src/components/Modal/LeftModal.js +34 -52
  20. package/lib/common/src/components/Modal/Modal.d.ts +26 -12
  21. package/lib/common/src/components/Modal/Modal.js +66 -89
  22. package/lib/common/src/components/Modal/ModalContextProvider.d.ts +20 -3
  23. package/lib/common/src/components/Modal/ModalContextProvider.js +35 -8
  24. package/lib/common/src/components/MyResizeObserver.js +15 -18
  25. package/lib/common/src/components/Other.js +6 -5
  26. package/lib/common/src/components/Parameters.js +8 -7
  27. package/lib/common/src/components/ParametersEngine.js +36 -59
  28. package/lib/common/src/grid/agGrid4/agGrid4.d.ts +53 -0
  29. package/lib/common/src/grid/agGrid4/agGrid4.js +132 -0
  30. package/lib/common/src/grid/agGrid4/core.d.ts +56 -0
  31. package/lib/common/src/grid/agGrid4/core.js +127 -0
  32. package/lib/common/src/grid/agGrid4/index.d.ts +6 -0
  33. package/lib/common/src/grid/agGrid4/index.js +3 -0
  34. package/lib/common/src/grid/agGrid4/theme.d.ts +7 -0
  35. package/lib/common/src/grid/agGrid4/theme.js +18 -0
  36. package/lib/common/src/hooks/useAddDownAnyKey.d.ts +21 -2
  37. package/lib/common/src/hooks/useAddDownAnyKey.js +46 -9
  38. package/lib/common/src/hooks/useDraggable.d.ts +20 -2
  39. package/lib/common/src/hooks/useDraggable.js +146 -115
  40. package/lib/common/src/hooks/useOutside.d.ts +24 -4
  41. package/lib/common/src/hooks/useOutside.js +77 -26
  42. package/lib/common/src/logs/logs.d.ts +5 -2
  43. package/lib/common/src/logs/logs.js +18 -34
  44. package/lib/common/src/logs/logs3.d.ts +9 -9
  45. package/lib/common/src/logs/logs3.js +48 -39
  46. package/lib/common/src/logs/miniLogs.d.ts +3 -3
  47. package/lib/common/src/logs/miniLogs.js +28 -36
  48. package/lib/common/src/menu/menu.d.ts +18 -18
  49. package/lib/common/src/menu/menu.js +49 -25
  50. package/lib/common/src/menu/menuMouse.d.ts +2 -1
  51. package/lib/common/src/menu/menuMouse.js +5 -4
  52. package/lib/common/src/menu/menuR.d.ts +4 -3
  53. package/lib/common/src/menu/menuR.js +42 -38
  54. package/lib/common/src/myChart/1/myChart.d.ts +5 -5
  55. package/lib/common/src/myChart/1/myChart.js +58 -47
  56. package/lib/common/src/myChart/1/myChartTest.js +8 -4
  57. package/lib/common/src/myChart/chartEngine/chartEngineReact.d.ts +24 -27
  58. package/lib/common/src/myChart/chartEngine/chartEngineReact.js +189 -118
  59. package/lib/common/src/styles/styleGrid.d.ts +2 -1
  60. package/lib/common/src/styles/styleGrid.js +10 -12
  61. package/lib/common/src/styles/tokens.d.ts +39 -0
  62. package/lib/common/src/styles/tokens.js +40 -0
  63. package/lib/common/src/utils/applyTransactionAsyncUpdate.d.ts +7 -0
  64. package/lib/common/src/utils/applyTransactionAsyncUpdate.js +25 -19
  65. package/lib/common/src/utils/arrayPromise.d.ts +6 -0
  66. package/lib/common/src/utils/arrayPromise.js +7 -1
  67. package/lib/common/src/utils/cache.js +32 -24
  68. package/lib/common/src/utils/inputAutoStep.d.ts +1 -1
  69. package/lib/common/src/utils/inputAutoStep.js +30 -19
  70. package/lib/common/src/utils/mapMemory.js +15 -15
  71. package/lib/common/updateBy.d.ts +21 -2
  72. package/lib/common/updateBy.js +66 -131
  73. package/lib/index.js +0 -2
  74. package/lib/style/menuRight.css +13 -26
  75. package/lib/style/style.css +51 -39
  76. package/lib/style/tokens.css +34 -0
  77. 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, useMemo, useRef, useState } from "react";
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
- // const Base = ({ update }: { update: number }) => {
12
- // console.log(update)
13
- // return typeof a.children === "function" ? a.children(update) : a.children;
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
- * Компонент-обёртка над react-rnd.
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?.x ?? 0);
51
- const [y, setY] = useState(position?.y ?? 30);
52
- const [width, setWidth] = useState(size?.width ?? 400);
53
- const [height, setHeight] = useState(size?.height ?? 400);
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
- // Обновляем zIndex окна, если оно поднято сверху
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
- * Хук для перетаскивания мышкой (a) и перетаскивания на тач-устройствах (b).
66
- * Снимаем подписки при размонтировании и при изменении зависимостей (a/b).
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
- if (lastC.current == null) {
73
- lastC.current = {
74
- x: e.clientX,
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
- if (limit) {
83
- if (limit.x?.min !== undefined && limit.x.min > newX)
84
- newX = limit.x.min;
85
- if (limit.x?.max !== undefined && limit.x.max < newX)
86
- newX = limit.x.max;
87
- if (limit.y?.min !== undefined && limit.y.min > newY)
88
- newY = limit.y.min;
89
- if (limit.y?.max !== undefined && limit.y.max < newY)
90
- newY = limit.y.max;
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
- if (limit) {
121
- if (limit.x?.min !== undefined && limit.x.min > newX)
122
- newX = limit.x.min;
123
- if (limit.x?.max !== undefined && limit.x.max < newX)
124
- newX = limit.x.max;
125
- if (limit.y?.min !== undefined && limit.y.min > newY)
126
- newY = limit.y.min;
127
- if (limit.y?.max !== undefined && limit.y.max < newY)
128
- newY = limit.y.max;
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
- // Возвращаем функцию очистки для размонтирования и при изменениях a/b:
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, limit, x, y]);
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
- // Обновляем в карте координаты и размер, если задан keyForSave
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 headerD = (_jsx("div", { ref: (el) => {
189
- if (el && sizeByWindow) {
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
- // Пример небольшой коррекции, если окно слишком большое
196
- if (typeof width === "number" && width > window.innerWidth) {
197
- setWidth(window.innerWidth);
198
- }
199
- if (typeof height === "number" && height > window.innerHeight) {
200
- setHeight(window.innerHeight);
201
- }
202
- }
203
- }, onTouchStart: (e) => {
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
- setHeight(+height + delta.height);
233
- setWidth(+width + delta.width);
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: "msTradeAlt", style: {
259
+ } })), typeof children === "function" ? children(update) : children] }), onCLickClose && (_jsx("div", { className: "wenayCloseBtn", title: "Close", style: {
260
260
  position: "absolute",
261
- right: -15,
262
- top: -15,
263
- fontSize: "32px",
264
- zIndex: zIndexX * 2 + zIndex + 1,
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
- * как мышью, так и касаниями (touch).
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, onX, onY, onStart, onStop]);
351
+ }, [draggingMouse, draggingTouch]);
346
352
  useLayoutEffect(() => {
347
353
  if (last) {
348
354
  last.current = posRef.current;
@@ -352,23 +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
- };
359
- console.log("xxx");
360
- console.log(offsetMouse.current.x, posRef.current.x, e.clientX);
361
+ offsetMouse.current = { x: -e.clientX, y: -e.clientY };
361
362
  setDraggingMouse(true);
362
363
  };
363
364
  const handleTouchStart = (e) => {
364
365
  const t = e.changedTouches[0];
365
366
  if (!t)
366
367
  return;
367
- offsetTouch.current = {
368
- x: posRef.current.x - t.clientX,
369
- y: posRef.current.y - t.clientY,
370
- id: t.identifier
371
- };
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 };
372
372
  setDraggingTouch(true);
373
373
  };
374
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) => {
@@ -20,10 +20,10 @@ export function InputFileModal({ callback, name, outClick, keyForSave = "InputFi
20
20
  return _jsx(ModalWrapper, { outClick: outClick, keyForSave: keyForSave, size: { height: 150, width: 300 }, position: { y: -150, x: -250 }, children: _jsx(InputFile, { callback: callback, name: name }) });
21
21
  }
22
22
  export function InputFile({ callback, name = "" }) {
23
- let file = null;
23
+ const file = useRef(null);
24
24
  return _jsxs("div", { className: "maxSize", style: { padding: 20, }, children: [_jsx("label", { children: name }), _jsx("input", { type: "file", style: { width: "100%" }, onChange: (e) => {
25
- file = e.target.files?.[0] ?? null;
26
- } }), _jsx("div", { style: { marginTop: 20 }, className: "msTradeAlt msTradeActive", onClick: () => { callback(file); }, children: "send" })] });
25
+ file.current = e.target.files?.[0] ?? null;
26
+ } }), _jsx("div", { style: { marginTop: 20 }, className: "msTradeAlt msTradeActive", onClick: () => { callback(file.current); }, children: "send" })] });
27
27
  }
28
28
  export function PageModalFree({ outClick, children, zIndex, size = { height: 150, width: 300 }, keyForSave = "PageModalFree2" }) {
29
29
  return _jsx(ModalWrapper, { outClick: outClick, keyForSave: keyForSave, size: size, zIndex: zIndex, children: children });
@@ -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
- // Получаем JSX-функции модального окна
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
- // Отрисовка выпадающего меню (dop)
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 }, index))) }), _jsx("div", { onMouseEnter: handleSubmenuMouseEnter, onMouseLeave: handleSubmenuMouseLeave, children: jsx.JSX ? (_jsx("div", { className: "submenu", style: { width: '40vw', minHeight: '70vh' }, children: jsxRender })) : null })] }));
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';
@@ -143,7 +137,12 @@ export function MenuRightApi() {
143
137
  render?.(elements);
144
138
  },
145
139
  delete(array) {
146
- array.forEach((e) => elements.splice(elements.indexOf(e), 1));
140
+ array.forEach((e) => {
141
+ const i = elements.indexOf(e);
142
+ if (i !== -1)
143
+ elements.splice(i, 1);
144
+ });
145
+ render?.([...elements]);
147
146
  },
148
147
  get() {
149
148
  return elements;
@@ -1,5 +1,3 @@
1
1
  import React from 'react';
2
- interface StickerMenuProps {
3
- }
4
- declare const StickerMenu: React.FC<StickerMenuProps>;
2
+ declare const StickerMenu: React.FC;
5
3
  export default StickerMenu;