wenay-react2 1.0.1
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/lib/common/api.d.ts +17 -0
- package/lib/common/api.js +24 -0
- package/lib/common/src/components/Buttons/MiniButton.d.ts +17 -0
- package/lib/common/src/components/Buttons/MiniButton.js +18 -0
- package/lib/common/src/components/Buttons/index.d.ts +1 -0
- package/lib/common/src/components/Buttons/index.js +1 -0
- package/lib/common/src/components/Dnd/DraggableOutlineDiv.d.ts +1 -0
- package/lib/common/src/components/Dnd/DraggableOutlineDiv.js +31 -0
- package/lib/common/src/components/Dnd/RNDFunc.d.ts +13 -0
- package/lib/common/src/components/Dnd/RNDFunc.js +111 -0
- package/lib/common/src/components/Dnd/RNDFunc3.d.ts +81 -0
- package/lib/common/src/components/Dnd/RNDFunc3.js +380 -0
- package/lib/common/src/components/Dnd/Resizable.d.ts +15 -0
- package/lib/common/src/components/Dnd/Resizable.js +36 -0
- package/lib/common/src/components/Dnd/index.d.ts +4 -0
- package/lib/common/src/components/Dnd/index.js +4 -0
- package/lib/common/src/components/Input.d.ts +28 -0
- package/lib/common/src/components/Input.js +30 -0
- package/lib/common/src/components/Menu/RightMenu.d.ts +22 -0
- package/lib/common/src/components/Menu/RightMenu.js +179 -0
- package/lib/common/src/components/Menu/StickerMenu.d.ts +5 -0
- package/lib/common/src/components/Menu/StickerMenu.js +110 -0
- package/lib/common/src/components/Menu/index.d.ts +2 -0
- package/lib/common/src/components/Menu/index.js +2 -0
- package/lib/common/src/components/Modal/LeftModal.d.ts +58 -0
- package/lib/common/src/components/Modal/LeftModal.js +284 -0
- package/lib/common/src/components/Modal/Modal.d.ts +31 -0
- package/lib/common/src/components/Modal/Modal.js +104 -0
- package/lib/common/src/components/Modal/index.d.ts +2 -0
- package/lib/common/src/components/Modal/index.js +2 -0
- package/lib/common/src/components/MyResizeObserver.d.ts +10 -0
- package/lib/common/src/components/MyResizeObserver.js +94 -0
- package/lib/common/src/components/Other.d.ts +9 -0
- package/lib/common/src/components/Other.js +31 -0
- package/lib/common/src/components/Parameters.d.ts +10 -0
- package/lib/common/src/components/Parameters.js +24 -0
- package/lib/common/src/components/ParametersEngine.d.ts +8 -0
- package/lib/common/src/components/ParametersEngine.js +373 -0
- package/lib/common/src/components/index.d.ts +9 -0
- package/lib/common/src/components/index.js +9 -0
- package/lib/common/src/hooks/index.d.ts +3 -0
- package/lib/common/src/hooks/index.js +3 -0
- package/lib/common/src/hooks/useAddDownAnyKey.d.ts +5 -0
- package/lib/common/src/hooks/useAddDownAnyKey.js +22 -0
- package/lib/common/src/hooks/useDraggable.d.ts +15 -0
- package/lib/common/src/hooks/useDraggable.js +134 -0
- package/lib/common/src/hooks/useOutside.d.ts +40 -0
- package/lib/common/src/hooks/useOutside.js +68 -0
- package/lib/common/src/logs/logs.d.ts +163 -0
- package/lib/common/src/logs/logs.js +249 -0
- package/lib/common/src/logs/logs3.d.ts +63 -0
- package/lib/common/src/logs/logs3.js +245 -0
- package/lib/common/src/logs/miniLogs.d.ts +5 -0
- package/lib/common/src/logs/miniLogs.js +51 -0
- package/lib/common/src/menu/menu.d.ts +72 -0
- package/lib/common/src/menu/menu.js +230 -0
- package/lib/common/src/menu/menuMouse.d.ts +21 -0
- package/lib/common/src/menu/menuMouse.js +32 -0
- package/lib/common/src/menu/menuR.d.ts +17 -0
- package/lib/common/src/menu/menuR.js +116 -0
- package/lib/common/src/myChart/1/myChart.d.ts +40 -0
- package/lib/common/src/myChart/1/myChart.js +306 -0
- package/lib/common/src/myChart/1/myChartTest.d.ts +1 -0
- package/lib/common/src/myChart/1/myChartTest.js +45 -0
- package/lib/common/src/myChart/chartEngine/chartEngineReact.d.ts +164 -0
- package/lib/common/src/myChart/chartEngine/chartEngineReact.js +834 -0
- package/lib/common/src/styles/index.d.ts +1 -0
- package/lib/common/src/styles/index.js +1 -0
- package/lib/common/src/styles/styleGrid.d.ts +20 -0
- package/lib/common/src/styles/styleGrid.js +50 -0
- package/lib/common/src/utils/applyTransactionAsyncUpdate.d.ts +42 -0
- package/lib/common/src/utils/applyTransactionAsyncUpdate.js +97 -0
- package/lib/common/src/utils/arrayPromise.d.ts +5 -0
- package/lib/common/src/utils/arrayPromise.js +16 -0
- package/lib/common/src/utils/cache.d.ts +31 -0
- package/lib/common/src/utils/cache.js +119 -0
- package/lib/common/src/utils/index.d.ts +6 -0
- package/lib/common/src/utils/index.js +6 -0
- package/lib/common/src/utils/inputAutoStep.d.ts +4 -0
- package/lib/common/src/utils/inputAutoStep.js +79 -0
- package/lib/common/src/utils/mapMemory.d.ts +26 -0
- package/lib/common/src/utils/mapMemory.js +72 -0
- package/lib/common/src/utils/pageVisibilityContext.d.ts +5 -0
- package/lib/common/src/utils/pageVisibilityContext.js +18 -0
- package/lib/common/updateBy.d.ts +12 -0
- package/lib/common/updateBy.js +88 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/style/menuRight.css +139 -0
- package/lib/style/style.css +334 -0
- package/lib/tsconfig.json +6 -0
- package/package.json +50 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { Rnd } from "react-rnd";
|
|
4
|
+
import { renderBy, updateBy } from "../../../updateBy";
|
|
5
|
+
// Карта всех размеров всплывающих окон
|
|
6
|
+
export const ExRNDMap3 = new Map();
|
|
7
|
+
// limit={{x:{min:0}, y:{min:0}}}
|
|
8
|
+
let k = 0;
|
|
9
|
+
const openWindows = { ar: [] };
|
|
10
|
+
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 });
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Компонент-обёртка над react-rnd.
|
|
24
|
+
* Обеспечивает перетаскивание и изменение размеров, опциональный заголовок и кнопку закрытия.
|
|
25
|
+
*/
|
|
26
|
+
export function DivRndBase3({ children, keyForSave: ks, position, size, overflow = true, zIndex = 9, onUpdate, disableDragging, className, header, moveOnlyHeader, limit, onCLickClose, sizeByWindow = true }) {
|
|
27
|
+
if (onCLickClose && !limit) {
|
|
28
|
+
limit = { y: { min: 0 } };
|
|
29
|
+
}
|
|
30
|
+
const positionDef = { x: 0, y: 0, ...(position ?? {}) };
|
|
31
|
+
const sizeDef = { height: 0, width: 0, ...(size ?? {}) };
|
|
32
|
+
// Если есть ключ — данные положения и размера храним в карте
|
|
33
|
+
let map;
|
|
34
|
+
if (ks) {
|
|
35
|
+
map = ExRNDMap3.get(ks) ?? ExRNDMap3.set(ks, { size: sizeDef, position: positionDef }).get(ks);
|
|
36
|
+
}
|
|
37
|
+
position = map?.position ?? positionDef;
|
|
38
|
+
size = map?.size ?? sizeDef;
|
|
39
|
+
// Если нужно вписаться в окно по размеру
|
|
40
|
+
if (sizeByWindow) {
|
|
41
|
+
// ...здесь можно добавить логику проверки/коррекции на window.innerWidth, window.innerHeight и т.д.
|
|
42
|
+
}
|
|
43
|
+
const id2 = useRef({ k: k++ });
|
|
44
|
+
const id = id2.current;
|
|
45
|
+
const [zIndexX, setZIndexX] = useState(0);
|
|
46
|
+
const lastC = useRef(null);
|
|
47
|
+
const lastT = useRef(null);
|
|
48
|
+
const [a, setA] = useState(false);
|
|
49
|
+
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);
|
|
54
|
+
const [update, setUpdate] = useState(0);
|
|
55
|
+
const zindex = useRef(zIndexX);
|
|
56
|
+
zindex.current = zIndexX;
|
|
57
|
+
// Обновляем zIndex окна, если оно поднято сверху
|
|
58
|
+
updateBy(openWindows, () => {
|
|
59
|
+
const z = openWindows.ar.findIndex((v) => v.k === id.k);
|
|
60
|
+
if (z >= 0 && z !== zindex.current) {
|
|
61
|
+
setZIndexX(z);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Хук для перетаскивания мышкой (a) и перетаскивания на тач-устройствах (b).
|
|
66
|
+
* Снимаем подписки при размонтировании и при изменении зависимостей (a/b).
|
|
67
|
+
*/
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
// Мышь
|
|
70
|
+
const mouseMoveHandler = (e) => {
|
|
71
|
+
e.stopPropagation();
|
|
72
|
+
if (lastC.current == null) {
|
|
73
|
+
lastC.current = {
|
|
74
|
+
x: e.clientX,
|
|
75
|
+
y: e.clientY
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const data = lastC.current;
|
|
79
|
+
if (e.buttons === 1) {
|
|
80
|
+
let newX = e.clientX + data.x;
|
|
81
|
+
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;
|
|
91
|
+
}
|
|
92
|
+
setX(newX);
|
|
93
|
+
setY(newY);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
mouseUpHandler();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const mouseUpHandler = () => {
|
|
100
|
+
document.removeEventListener("mouseup", mouseUpHandler);
|
|
101
|
+
document.removeEventListener("mousemove", mouseMoveHandler);
|
|
102
|
+
lastC.current = null;
|
|
103
|
+
setA(false);
|
|
104
|
+
};
|
|
105
|
+
// Тач
|
|
106
|
+
const touchMoveHandler = (e) => {
|
|
107
|
+
const data = lastT.current;
|
|
108
|
+
if (!data)
|
|
109
|
+
return touchEndHandler(e);
|
|
110
|
+
let t = null;
|
|
111
|
+
for (let i = 0; i < e.changedTouches.length; i++) {
|
|
112
|
+
const zz = e.changedTouches[i];
|
|
113
|
+
if (zz.identifier === data.id)
|
|
114
|
+
t = zz;
|
|
115
|
+
}
|
|
116
|
+
if (!t)
|
|
117
|
+
return;
|
|
118
|
+
let newX = t.clientX + data.x;
|
|
119
|
+
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;
|
|
129
|
+
}
|
|
130
|
+
setX(newX);
|
|
131
|
+
setY(newY);
|
|
132
|
+
};
|
|
133
|
+
const touchEndHandler = (e) => {
|
|
134
|
+
const data = lastT.current;
|
|
135
|
+
if (data) {
|
|
136
|
+
for (let i = 0; i < e.changedTouches.length; i++) {
|
|
137
|
+
const zz = e.changedTouches[i];
|
|
138
|
+
if (zz.identifier === data.id) {
|
|
139
|
+
lastT.current = null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (lastT.current == null) {
|
|
144
|
+
document.removeEventListener("touchend", touchEndHandler);
|
|
145
|
+
document.removeEventListener("touchmove", touchMoveHandler);
|
|
146
|
+
setB(false);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
// Если активирован режим перетаскивания мышью
|
|
150
|
+
if (a) {
|
|
151
|
+
document.addEventListener("mousemove", mouseMoveHandler);
|
|
152
|
+
document.addEventListener("mouseup", mouseUpHandler);
|
|
153
|
+
}
|
|
154
|
+
// Если активирован режим перетаскивания для тач-событий
|
|
155
|
+
if (b) {
|
|
156
|
+
document.addEventListener("touchmove", touchMoveHandler);
|
|
157
|
+
document.addEventListener("touchend", touchEndHandler);
|
|
158
|
+
}
|
|
159
|
+
// Возвращаем функцию очистки для размонтирования и при изменениях a/b:
|
|
160
|
+
return () => {
|
|
161
|
+
document.removeEventListener("mousemove", mouseMoveHandler);
|
|
162
|
+
document.removeEventListener("mouseup", mouseUpHandler);
|
|
163
|
+
document.removeEventListener("touchmove", touchMoveHandler);
|
|
164
|
+
document.removeEventListener("touchend", touchEndHandler);
|
|
165
|
+
};
|
|
166
|
+
}, [a, b, limit, x, y]);
|
|
167
|
+
// При первой отрисовке добавляем "окно" в массив, при размонтировании — удаляем
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
openWindows.ar.push(id);
|
|
170
|
+
renderBy(openWindows);
|
|
171
|
+
return () => {
|
|
172
|
+
const z = openWindows.ar.findIndex((v) => v.k === id.k);
|
|
173
|
+
if (z >= 0) {
|
|
174
|
+
openWindows.ar.splice(z, 1);
|
|
175
|
+
renderBy(openWindows);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}, []);
|
|
179
|
+
// Обновляем в карте координаты и размер, если задан keyForSave
|
|
180
|
+
if (size) {
|
|
181
|
+
size.height = height;
|
|
182
|
+
size.width = width;
|
|
183
|
+
}
|
|
184
|
+
if (position) {
|
|
185
|
+
position.x = x;
|
|
186
|
+
position.y = y;
|
|
187
|
+
}
|
|
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) => {
|
|
204
|
+
const t = e.changedTouches[0];
|
|
205
|
+
if (t) {
|
|
206
|
+
lastT.current = {
|
|
207
|
+
x: x - t.clientX,
|
|
208
|
+
y: y - t.clientY,
|
|
209
|
+
id: t.identifier
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
setB(true);
|
|
213
|
+
}, onMouseDown: (e) => {
|
|
214
|
+
lastC.current = {
|
|
215
|
+
x: x - e.clientX,
|
|
216
|
+
y: y - e.clientY
|
|
217
|
+
};
|
|
218
|
+
setA(true);
|
|
219
|
+
}, style: {
|
|
220
|
+
userSelect: "none",
|
|
221
|
+
cursor: "grabbing"
|
|
222
|
+
}, children: header ?? (_jsx("div", { style: {
|
|
223
|
+
height: 20,
|
|
224
|
+
width: "100%",
|
|
225
|
+
backgroundImage: "repeating-linear-gradient(139deg, hsla(0,0%,100%,.1), hsla(0,0%,100%,.1) 15px, transparent 0, transparent 30px)"
|
|
226
|
+
} })) }));
|
|
227
|
+
return (_jsx(Rnd, { disableDragging: true, style: {
|
|
228
|
+
zIndex: zIndexX * 2 + zIndex
|
|
229
|
+
}, className: className, onResizeStop: (e, dir, elementRef, delta, { x: nx, y: ny }) => {
|
|
230
|
+
setX(nx);
|
|
231
|
+
setY(ny);
|
|
232
|
+
setHeight(+height + delta.height);
|
|
233
|
+
setWidth(+width + delta.width);
|
|
234
|
+
setUpdate(update + 1);
|
|
235
|
+
}, onResize: (e, dir, elementRef, delta, pos) => {
|
|
236
|
+
onUpdate?.({ e, dir, elementRef, delta, position: pos });
|
|
237
|
+
}, position: { x, y }, size: { width, height }, default: {
|
|
238
|
+
...position,
|
|
239
|
+
...size
|
|
240
|
+
}, children: _jsxs("div", { style: {
|
|
241
|
+
width: "100%",
|
|
242
|
+
height: "100%",
|
|
243
|
+
display: "flex",
|
|
244
|
+
flexDirection: "column",
|
|
245
|
+
position: "relative",
|
|
246
|
+
flex: "auto"
|
|
247
|
+
}, onMouseDown: () => {
|
|
248
|
+
// Поднимаем окно наверх
|
|
249
|
+
const z = openWindows.ar.findIndex((v) => v === id);
|
|
250
|
+
if (z !== openWindows.ar.length - 1 || zindex.current !== z) {
|
|
251
|
+
const buf = openWindows.ar[z];
|
|
252
|
+
openWindows.ar.splice(z, 1);
|
|
253
|
+
openWindows.ar.push(buf);
|
|
254
|
+
renderBy(openWindows);
|
|
255
|
+
}
|
|
256
|
+
}, children: [moveOnlyHeader || header ? headerD : null, _jsxs("div", { className: "maxSize", style: { overflow: overflow ? "auto" : undefined }, children: [(a || b) && (_jsx("div", { className: "maxSize", style: {
|
|
257
|
+
position: "absolute",
|
|
258
|
+
zIndex: zIndexX * 2 + zIndex + 1
|
|
259
|
+
} })), typeof children === "function" ? children(update) : children] }), onCLickClose && (_jsx("div", { className: "msTradeAlt", style: {
|
|
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"))] }) }));
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Компонент-обёртка, позволяющий перетаскивать вложенный элемент
|
|
270
|
+
* как мышью, так и касаниями (touch).
|
|
271
|
+
*
|
|
272
|
+
* Функция исключительно как хук на изменения параметров при движении - хоть и имеет свой компонент (для отсчета)
|
|
273
|
+
* возвращает пройденное расстояние при перемещении дочернего элемента
|
|
274
|
+
*/
|
|
275
|
+
export function Drag22({ children, onX, onY, x = 0, y = 0, right = false, last, dragging, onStart, onStop }) {
|
|
276
|
+
const offsetMouse = useRef({ x: 0, y: 0 });
|
|
277
|
+
const offsetTouch = useRef(null);
|
|
278
|
+
const [draggingMouse, setDraggingMouse] = useState(false);
|
|
279
|
+
const [draggingTouch, setDraggingTouch] = useState(false);
|
|
280
|
+
const posRef = useRef(last?.current ?? { x, y });
|
|
281
|
+
useLayoutEffect(() => {
|
|
282
|
+
posRef.current.x = x;
|
|
283
|
+
posRef.current.y = y;
|
|
284
|
+
}, [x, y]);
|
|
285
|
+
useEffect(() => {
|
|
286
|
+
if (!draggingMouse && !draggingTouch) {
|
|
287
|
+
onStop?.();
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (draggingMouse) {
|
|
291
|
+
const handleMouseMove = (e) => {
|
|
292
|
+
const newX = e.clientX + offsetMouse.current.x;
|
|
293
|
+
const newY = e.clientY + offsetMouse.current.y;
|
|
294
|
+
posRef.current = { x: newX, y: newY };
|
|
295
|
+
onX?.(newX);
|
|
296
|
+
onY?.(newY);
|
|
297
|
+
};
|
|
298
|
+
const handleMouseUp = () => {
|
|
299
|
+
offsetMouse.current.x = 0;
|
|
300
|
+
offsetMouse.current.y = 0;
|
|
301
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
302
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
303
|
+
setDraggingMouse(false);
|
|
304
|
+
};
|
|
305
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
306
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
307
|
+
onStart?.();
|
|
308
|
+
return () => {
|
|
309
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
310
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
if (draggingTouch) {
|
|
314
|
+
const handleTouchMove = (e) => {
|
|
315
|
+
if (!offsetTouch.current)
|
|
316
|
+
return;
|
|
317
|
+
const theTouch = Array.from(e.changedTouches).find((t) => t.identifier === offsetTouch.current?.id);
|
|
318
|
+
if (!theTouch)
|
|
319
|
+
return;
|
|
320
|
+
const newX = theTouch.clientX + offsetTouch.current.x;
|
|
321
|
+
const newY = theTouch.clientY + offsetTouch.current.y;
|
|
322
|
+
posRef.current = { x: newX, y: newY };
|
|
323
|
+
onX?.(newX);
|
|
324
|
+
onY?.(newY);
|
|
325
|
+
};
|
|
326
|
+
const handleTouchEnd = (e) => {
|
|
327
|
+
if (!offsetTouch.current)
|
|
328
|
+
return;
|
|
329
|
+
const ended = Array.from(e.changedTouches).find((t) => t.identifier === offsetTouch.current?.id);
|
|
330
|
+
if (ended) {
|
|
331
|
+
offsetTouch.current = null;
|
|
332
|
+
document.removeEventListener("touchmove", handleTouchMove);
|
|
333
|
+
document.removeEventListener("touchend", handleTouchEnd);
|
|
334
|
+
setDraggingTouch(false);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
document.addEventListener("touchmove", handleTouchMove);
|
|
338
|
+
document.addEventListener("touchend", handleTouchEnd);
|
|
339
|
+
onStart?.();
|
|
340
|
+
return () => {
|
|
341
|
+
document.removeEventListener("touchmove", handleTouchMove);
|
|
342
|
+
document.removeEventListener("touchend", handleTouchEnd);
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
}, [draggingMouse, draggingTouch, onX, onY, onStart, onStop]);
|
|
346
|
+
useLayoutEffect(() => {
|
|
347
|
+
if (last) {
|
|
348
|
+
last.current = posRef.current;
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
const handleMouseDown = (e) => {
|
|
352
|
+
e.preventDefault();
|
|
353
|
+
posRef.current.x = 0;
|
|
354
|
+
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
|
+
setDraggingMouse(true);
|
|
362
|
+
};
|
|
363
|
+
const handleTouchStart = (e) => {
|
|
364
|
+
const t = e.changedTouches[0];
|
|
365
|
+
if (!t)
|
|
366
|
+
return;
|
|
367
|
+
offsetTouch.current = {
|
|
368
|
+
x: posRef.current.x - t.clientX,
|
|
369
|
+
y: posRef.current.y - t.clientY,
|
|
370
|
+
id: t.identifier
|
|
371
|
+
};
|
|
372
|
+
setDraggingTouch(true);
|
|
373
|
+
};
|
|
374
|
+
return (_jsx("div", { style: {
|
|
375
|
+
position: "absolute",
|
|
376
|
+
left: right ? undefined : 0,
|
|
377
|
+
right: right ? 0 : undefined,
|
|
378
|
+
top: 0
|
|
379
|
+
}, onMouseDown: handleMouseDown, onTouchStart: handleTouchStart, children: children }));
|
|
380
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ResizableProps } from "re-resizable";
|
|
2
|
+
type tSaveMap = {
|
|
3
|
+
height?: number | string;
|
|
4
|
+
width?: number | string;
|
|
5
|
+
};
|
|
6
|
+
export declare const mapResiReact: Map<string, tSaveMap>;
|
|
7
|
+
type t3 = Pick<ResizableProps, "style" | "enable" | "onResize" | "children" | "size" | "maxWidth" | "maxHeight" | "minWidth" | "minHeight">;
|
|
8
|
+
export declare function FResizableReact({ style, onResize, enable, children, keyForSave, onResizeStop, size, minWidth, minHeight, maxWidth, maxHeight, moveWith, moveHeight }: t3 & {
|
|
9
|
+
keyForSave?: string;
|
|
10
|
+
onResize?: (size?: tSaveMap) => void;
|
|
11
|
+
onResizeStop?: (size: tSaveMap) => void;
|
|
12
|
+
moveWith?: boolean;
|
|
13
|
+
moveHeight?: boolean;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Resizable } from "re-resizable";
|
|
3
|
+
// память всех размеров колонок
|
|
4
|
+
export const mapResiReact = new Map();
|
|
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
|
+
let obj = size;
|
|
7
|
+
if (keyForSave) {
|
|
8
|
+
let b = mapResiReact.get(keyForSave);
|
|
9
|
+
if (b)
|
|
10
|
+
obj = b;
|
|
11
|
+
else
|
|
12
|
+
mapResiReact.set(keyForSave, obj);
|
|
13
|
+
}
|
|
14
|
+
return _jsx(Resizable, { style: style, onResize: (event, direction, elementRef, delta) => {
|
|
15
|
+
onResize?.();
|
|
16
|
+
// костыль устраняет какой-то баг - проявляется при изменении родительского дива
|
|
17
|
+
if (moveHeight == false && typeof obj.height == "string" && elementRef.style.height != obj.height)
|
|
18
|
+
elementRef.style.height = obj.height;
|
|
19
|
+
}, enable: enable, onResizeStop: (e, dir, elementRef, delta) => {
|
|
20
|
+
if (delta.width && moveWith)
|
|
21
|
+
if (typeof obj.width == "number")
|
|
22
|
+
obj.width += delta.width;
|
|
23
|
+
else {
|
|
24
|
+
obj.width = elementRef.style.width;
|
|
25
|
+
}
|
|
26
|
+
if (delta.height && moveHeight)
|
|
27
|
+
if (typeof obj.height == "number")
|
|
28
|
+
obj.height += delta.height;
|
|
29
|
+
else {
|
|
30
|
+
obj.height = elementRef.style.height;
|
|
31
|
+
}
|
|
32
|
+
// onResize?.(size)
|
|
33
|
+
onResizeStop?.(obj);
|
|
34
|
+
// this.Refresh()
|
|
35
|
+
}, size: obj, defaultSize: obj, maxWidth: maxWidth, maxHeight: maxHeight, minWidth: minWidth, minHeight: minHeight, children: children });
|
|
36
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare function InputPage({ callback, name, txt }: {
|
|
3
|
+
callback: (txt: string) => void;
|
|
4
|
+
name?: string;
|
|
5
|
+
txt?: string;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function InputPageModal({ callback, name, outClick, keyForSave, txt }: Parameters<typeof InputPage>[0] & {
|
|
8
|
+
outClick: () => any;
|
|
9
|
+
keyForSave?: string;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function InputFileModal({ callback, name, outClick, keyForSave }: Parameters<typeof InputFile>[0] & {
|
|
12
|
+
outClick: () => any;
|
|
13
|
+
keyForSave?: string;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function InputFile({ callback, name }: {
|
|
16
|
+
callback: (file: File | null) => void;
|
|
17
|
+
name?: string;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function PageModalFree({ outClick, children, zIndex, size, keyForSave }: {
|
|
20
|
+
zIndex?: number;
|
|
21
|
+
outClick: () => any;
|
|
22
|
+
children: React.JSX.Element;
|
|
23
|
+
size?: {
|
|
24
|
+
height: number;
|
|
25
|
+
width: number;
|
|
26
|
+
};
|
|
27
|
+
keyForSave?: string;
|
|
28
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { DivOutsideClick } from "../hooks";
|
|
4
|
+
import { DivRnd3 } from "./Dnd";
|
|
5
|
+
// Unified modal wrapper component
|
|
6
|
+
function ModalWrapper({ outClick, children, zIndex, size = { height: 150, width: 300 }, keyForSave, position }) {
|
|
7
|
+
const defaultPosition = position ?? { y: -(size.height / 2), x: -(size.width / 2) };
|
|
8
|
+
return _jsx(DivOutsideClick, { outsideClick: outClick, style: { position: "absolute", top: "50%", left: "50%" }, children: _jsx(DivRnd3, { keyForSave: keyForSave, size: size, zIndex: zIndex, position: defaultPosition, className: "fon border fonLight", moveOnlyHeader: true, children: children }) });
|
|
9
|
+
}
|
|
10
|
+
export function InputPage({ callback, name = "", txt = "" }) {
|
|
11
|
+
const txtName = useRef(txt);
|
|
12
|
+
return _jsxs("div", { className: "maxSize", style: { padding: 20, }, children: [_jsx("label", { children: name }), _jsx("input", { type: "text", style: { width: "100%" }, defaultValue: txtName.current, onChange: (e) => {
|
|
13
|
+
txtName.current = e.target.value; //?? txt
|
|
14
|
+
} }), _jsx("div", { style: { marginTop: 20 }, className: "msTradeAlt msTradeActive", onClick: () => { callback(txtName.current); }, children: "send" })] });
|
|
15
|
+
}
|
|
16
|
+
export function InputPageModal({ callback, name, outClick, keyForSave = "InputPage2", txt }) {
|
|
17
|
+
return _jsx(ModalWrapper, { outClick: outClick, keyForSave: keyForSave, size: { height: 150, width: 300 }, position: { y: -150, x: -250 }, children: InputPage({ callback, name, txt }) });
|
|
18
|
+
}
|
|
19
|
+
export function InputFileModal({ callback, name, outClick, keyForSave = "InputFile2" }) {
|
|
20
|
+
return _jsx(ModalWrapper, { outClick: outClick, keyForSave: keyForSave, size: { height: 150, width: 300 }, position: { y: -150, x: -250 }, children: InputFile({ callback, name }) });
|
|
21
|
+
}
|
|
22
|
+
export function InputFile({ callback, name = "" }) {
|
|
23
|
+
let file = null;
|
|
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" })] });
|
|
27
|
+
}
|
|
28
|
+
export function PageModalFree({ outClick, children, zIndex, size = { height: 150, width: 300 }, keyForSave = "PageModalFree2" }) {
|
|
29
|
+
return _jsx(ModalWrapper, { outClick: outClick, keyForSave: keyForSave, size: size, zIndex: zIndex, children: children });
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { JSX } from 'react';
|
|
2
|
+
type MenuElement = {
|
|
3
|
+
label: string;
|
|
4
|
+
subMenuContent: () => JSX.Element;
|
|
5
|
+
};
|
|
6
|
+
type DropdownMenuProps = {
|
|
7
|
+
elements: MenuElement[];
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
position?: 'left' | 'right';
|
|
10
|
+
position2?: 'top' | 'bottom';
|
|
11
|
+
};
|
|
12
|
+
export declare function DropdownMenu({ elements, style, position: initialPosition, position2: initialPos2 }: DropdownMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function MenuRightApi(): {
|
|
14
|
+
set(array: MenuElement[]): void;
|
|
15
|
+
delete(array: MenuElement[]): void;
|
|
16
|
+
get(): MenuElement[];
|
|
17
|
+
Render({ style }: {
|
|
18
|
+
style?: React.CSSProperties;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
};
|
|
21
|
+
export declare function DropdownMenuTest(): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export {};
|