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,373 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { deepCloneMutable, isDate, TF, timeLocalToStr_yyyymmdd, timeLocalToStr_yyyymmdd_hhmm, timeLocalToStr_yyyymmdd_hhmmss, timeLocalToStr_yyyymmdd_hhmmss_ms } from "wenay-common2";
|
|
4
|
+
import { setResizeableElement } from "./MyResizeObserver";
|
|
5
|
+
import { CParameter, FNameButton } from "./Parameters";
|
|
6
|
+
import { SetAutoStepForElement } from "../utils";
|
|
7
|
+
function timeToStr(time, step) {
|
|
8
|
+
function getTimeStep(time) {
|
|
9
|
+
return [TF.D1.msec, TF.M1.msec, TF.S1.msec, 1].find(period => time % period == 0);
|
|
10
|
+
}
|
|
11
|
+
let t = new Date(time.valueOf());
|
|
12
|
+
step ??= getTimeStep(t.valueOf());
|
|
13
|
+
return step % TF.D1.msec == 0 ? timeLocalToStr_yyyymmdd(t) : step % TF.M1.msec == 0 ? timeLocalToStr_yyyymmdd_hhmm(t) : timeLocalToStr_yyyymmdd_hhmmss(t);
|
|
14
|
+
}
|
|
15
|
+
function CButton({ name, className, status: statusDef, header, onExpand, children }) {
|
|
16
|
+
const [status, setStatus] = useState(statusDef ?? false);
|
|
17
|
+
return _jsxs(_Fragment, { children: [_jsxs("div", { className: "toLine" + (className ? " " + className : ""), children: [_jsx("div", { style: { width: "100%" }, onClick: () => {
|
|
18
|
+
let status2 = !status;
|
|
19
|
+
setStatus(status2);
|
|
20
|
+
onExpand?.(status2);
|
|
21
|
+
}, children: name(status) }), header] }), status && children] });
|
|
22
|
+
}
|
|
23
|
+
//класс наведение на объект, если на вели на оболочку над children то появиться onFocusUp/focusDw
|
|
24
|
+
function DivHover({ children, className, style }) {
|
|
25
|
+
const [hover, setHover] = useState(false);
|
|
26
|
+
return _jsx("div", { className: className, style: style, onMouseLeave: () => { setHover(false); }, onMouseEnter: () => { setHover(true); }, children: children(hover) });
|
|
27
|
+
}
|
|
28
|
+
function CheckBox(set, val, style) {
|
|
29
|
+
return _jsx("input", { type: "checkbox", style: { marginTop: "auto", marginBottom: "auto", ...style }, checked: val, onChange: (a) => {
|
|
30
|
+
set(a.currentTarget.checked);
|
|
31
|
+
} });
|
|
32
|
+
}
|
|
33
|
+
function InputString(set, val, style) {
|
|
34
|
+
return _jsx("input", { type: "text", style: { marginTop: "auto", marginBottom: "auto", ...style }, value: val, onChange: (e) => {
|
|
35
|
+
set(e.currentTarget.value);
|
|
36
|
+
} });
|
|
37
|
+
}
|
|
38
|
+
function InputTime(set, value, range) {
|
|
39
|
+
//const data= this._inputNumStrMap.get(range);
|
|
40
|
+
//let val= value;
|
|
41
|
+
//if (1) return null;
|
|
42
|
+
let { min, max } = range ?? {};
|
|
43
|
+
// (data?.value==value)
|
|
44
|
+
// ? data
|
|
45
|
+
// : { min: range.min, max: range.max, step: range.defaultStep??range.step, val: value };
|
|
46
|
+
//this._inputNumStrMap.delete(range);
|
|
47
|
+
const timeSplits = typeof value == "string" ? value.split(":").length : 2;
|
|
48
|
+
const hasDot = typeof value == "string" ? value.includes(".") : false;
|
|
49
|
+
const step = range?.step ?? (timeSplits <= 1 ? TF.D1.msec : timeSplits == 2 ? TF.M1.msec : hasDot ? 1 : TF.S1.msec);
|
|
50
|
+
const normalizedValue = new Date(Math.floor(toNum(value) / step) * step);
|
|
51
|
+
function toNum(val) {
|
|
52
|
+
return val ? new Date(val).valueOf() : undefined;
|
|
53
|
+
}
|
|
54
|
+
function setVal(val) {
|
|
55
|
+
let str = timeToStr(val, step);
|
|
56
|
+
set(str);
|
|
57
|
+
}
|
|
58
|
+
function toInputStr(val) {
|
|
59
|
+
if (!val)
|
|
60
|
+
return undefined;
|
|
61
|
+
let val_ = val;
|
|
62
|
+
let timeStr = step % TF.D1.msec == 0 ? timeLocalToStr_yyyymmdd(new Date(val_)) :
|
|
63
|
+
step % TF.M1.msec == 0 ? timeLocalToStr_yyyymmdd_hhmm(new Date(val_)) :
|
|
64
|
+
step % TF.S1.msec == 0 ? timeLocalToStr_yyyymmdd_hhmmss(new Date(val_)) : timeLocalToStr_yyyymmdd_hhmmss_ms(new Date(val_));
|
|
65
|
+
return timeStr.replace(" ", "T");
|
|
66
|
+
}
|
|
67
|
+
//function toInputVal(val: string | const_Date | undefined) { return val ? new Date(val).valueOf() : undefined; }
|
|
68
|
+
//const inputType : React.InputHTMLAttributes.type = ;
|
|
69
|
+
let _ref = null;
|
|
70
|
+
return _jsxs(_Fragment, { children: [_jsx("input", { type: "range", min: toNum(range?.defaultMin ?? range?.min ?? "2015.01.01"), max: toNum(range?.defaultMax ?? range?.max ?? new Date().toString()), step: range?.defaultStep ?? step, value: toNum(value), onInput: (e) => {
|
|
71
|
+
setVal(Number(e.currentTarget.value));
|
|
72
|
+
}, ref: (ref) => {
|
|
73
|
+
if (ref) {
|
|
74
|
+
setResizeableElement(ref);
|
|
75
|
+
}
|
|
76
|
+
} }), _jsx("div", { children: _jsx("input", { type: step % TF.D1.msec == 0 ? "date" : "datetime-local", style: { width: "calc(100% - 13px)", marginTop: 5 }, onInput: (e) => {
|
|
77
|
+
set(e.currentTarget.value);
|
|
78
|
+
}, min: toInputStr(min), max: toInputStr(max), step: step % TF.D1.msec == 0 ? step / TF.D1.msec : step / TF.S1.msec, value: toInputStr(normalizedValue),
|
|
79
|
+
//onMouseOver={()=>{ console.log("over"); _ref?.dispatchEvent(new MouseEvent("mouseenter", { 'bubbles': true })); _ref?.dispatchEvent(new MouseEvent("mouseover", { 'bubbles': true }))}}
|
|
80
|
+
onMouseEnter: () => {
|
|
81
|
+
_ref?.focus();
|
|
82
|
+
}, onMouseLeave: () => {
|
|
83
|
+
_ref?.blur();
|
|
84
|
+
} }) }), _jsx("input", { required: true, className: "toNumberInput inputCan", type: "number", style: { width: 18, marginLeft: -13, marginRight: 0 }, min: toNum(min), max: toNum(max), step: step, value: toNum(value), onInput: (e) => {
|
|
85
|
+
//console.log("value:",toNum(value),"->",e.currentTarget.value);
|
|
86
|
+
//<input type="number" value={this.vvv ?? 99} onInput={(e)=>{console.log(this.vvv= e.currentTarget.value); this.Refresh(); }}/>
|
|
87
|
+
const target = e.currentTarget;
|
|
88
|
+
setVal(Number(target.value));
|
|
89
|
+
},
|
|
90
|
+
//onMouseEnter={()=>console.log("!!!", deepClone(_ref?.classList))}
|
|
91
|
+
ref: (ref) => {
|
|
92
|
+
if (ref) {
|
|
93
|
+
_ref = ref;
|
|
94
|
+
}
|
|
95
|
+
} })] });
|
|
96
|
+
}
|
|
97
|
+
function InputList(set, value, range, rangeLabels) {
|
|
98
|
+
function toType(val, type) {
|
|
99
|
+
return type == "number" ? Number(val) : type == "boolean" ? Boolean(val) : String(val);
|
|
100
|
+
}
|
|
101
|
+
function convertType(val) {
|
|
102
|
+
return (value instanceof Date ? new Date(val) : toType(val, typeof value));
|
|
103
|
+
}
|
|
104
|
+
//return null;
|
|
105
|
+
function toString(val) {
|
|
106
|
+
return val instanceof Date ? timeToStr(val) : String(val);
|
|
107
|
+
}
|
|
108
|
+
return _jsx("select", { style: { width: "180px", marginTop: "auto", marginBottom: "auto", paddingTop: 5, paddingBottom: 5 }, value: toString(value), onChange: (select) => {
|
|
109
|
+
set(convertType(select.target.value));
|
|
110
|
+
}, ref: (ref) => {
|
|
111
|
+
if (ref) {
|
|
112
|
+
setResizeableElement(ref);
|
|
113
|
+
}
|
|
114
|
+
}, children: range.map((a, i) => {
|
|
115
|
+
return _jsx("option", { value: toString(a), label: rangeLabels?.at(i) ?? toString(a), children: toString(a) }, toString(a));
|
|
116
|
+
}) });
|
|
117
|
+
}
|
|
118
|
+
const _inputNumStrMap = new WeakMap();
|
|
119
|
+
function InputNumber(set, value, range) {
|
|
120
|
+
//if (1) return null;
|
|
121
|
+
const data = _inputNumStrMap.get(range);
|
|
122
|
+
//let val= value;
|
|
123
|
+
let { min, max, step, val } = (data?.value == value)
|
|
124
|
+
? data
|
|
125
|
+
: { min: range.min, max: range.max, step: range.defaultStep ?? range.step, val: value };
|
|
126
|
+
_inputNumStrMap.delete(range);
|
|
127
|
+
let _ref;
|
|
128
|
+
return _jsxs(_Fragment, { children: [_jsx("input", { type: "range", min: range.defaultMin ?? range.min, max: range.defaultMax ?? range.max, step: range.defaultStep ?? range.step, value: String(value), onInput: (e) => {
|
|
129
|
+
set(Number(e.currentTarget.value));
|
|
130
|
+
if (_ref)
|
|
131
|
+
_ref.step = e.currentTarget.step;
|
|
132
|
+
}, ref: (ref) => {
|
|
133
|
+
if (ref) {
|
|
134
|
+
setResizeableElement(ref);
|
|
135
|
+
}
|
|
136
|
+
} }), _jsx("input", { required: true, className: "toNumberInput inputCan", type: "number", min: min, max: max, step: step, value: val, onInput: (e) => {
|
|
137
|
+
const target = e.currentTarget;
|
|
138
|
+
let value2 = target.value != "" ? Number(target.value) : value;
|
|
139
|
+
//if (target.value=="") console.log(value, range);
|
|
140
|
+
_inputNumStrMap.set(range, {
|
|
141
|
+
val: target.value,
|
|
142
|
+
min: target.min,
|
|
143
|
+
max: target.max,
|
|
144
|
+
step: target.step,
|
|
145
|
+
value: value2
|
|
146
|
+
});
|
|
147
|
+
if (target.value != "")
|
|
148
|
+
set(Number(target.value));
|
|
149
|
+
else {
|
|
150
|
+
target.reportValidity();
|
|
151
|
+
// this.Refresh();
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
//onBlur={ (a)=>{ console.log("blur"); if (! a.currentTarget.checkValidity()) set(Number(a.currentTarget.value)); } }
|
|
155
|
+
ref: (ref) => {
|
|
156
|
+
if (ref) {
|
|
157
|
+
_ref = ref;
|
|
158
|
+
ref.step = step + "";
|
|
159
|
+
SetAutoStepForElement(ref, { minStep: range.step });
|
|
160
|
+
}
|
|
161
|
+
} })] });
|
|
162
|
+
}
|
|
163
|
+
function InputListArray(set, values, range, rangeLabels) {
|
|
164
|
+
function toType(val, type) {
|
|
165
|
+
return type == "number" ? Number(val) : String(val);
|
|
166
|
+
} //type=="string" ? String(val) : Boolean(val); }
|
|
167
|
+
function convertType(val) {
|
|
168
|
+
return toType(val, typeof values[0]);
|
|
169
|
+
}
|
|
170
|
+
return _jsx("select", { style: { width: "180px", resize: "vertical" }, value: values.map((a) => String(a)), onChange: (select) => {
|
|
171
|
+
let values = [];
|
|
172
|
+
for (let option of Array.from(select.target.options))
|
|
173
|
+
if (option.selected)
|
|
174
|
+
values.push(convertType(option.value));
|
|
175
|
+
set(values);
|
|
176
|
+
}, multiple: true, ref: (ref) => {
|
|
177
|
+
if (ref) {
|
|
178
|
+
setResizeableElement(ref);
|
|
179
|
+
}
|
|
180
|
+
}, children: range.map((a, i) => {
|
|
181
|
+
return _jsx("option", { value: String(a), label: rangeLabels?.at(i) ?? String(a), children: a }, String(a));
|
|
182
|
+
}) });
|
|
183
|
+
}
|
|
184
|
+
export function ParametersReact(data) {
|
|
185
|
+
const params = useRef(null);
|
|
186
|
+
const result = useMemo(() => {
|
|
187
|
+
params.current = data.params;
|
|
188
|
+
return _jsx(ParametersBaseReact, { params: data.params, onChange: data.onChange, onExpand: data.onExpand, expandStatus: data.expandStatus, expandStatusLvl: data.expandStatusLvl });
|
|
189
|
+
}, [data.params]);
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
function ParametersBaseReact(data) {
|
|
193
|
+
const [_, setUpdate] = useState(0);
|
|
194
|
+
function Refresh() { setUpdate(e => ++e); }
|
|
195
|
+
const styleColorDisable = "rgb(146,146,146)";
|
|
196
|
+
const p = useMemo(() => deepCloneMutable(data.params), [data.params]);
|
|
197
|
+
const myParams = useRef(p);
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
myParams.current = p;
|
|
200
|
+
Refresh();
|
|
201
|
+
}, [p]);
|
|
202
|
+
let timeoutId = null;
|
|
203
|
+
function refreshIndicator() {
|
|
204
|
+
data.onChange(myParams.current);
|
|
205
|
+
}
|
|
206
|
+
function refreshIndicatorDelayed() {
|
|
207
|
+
if (timeoutId != null)
|
|
208
|
+
clearTimeout(timeoutId);
|
|
209
|
+
timeoutId = setTimeout(() => {
|
|
210
|
+
refreshIndicator();
|
|
211
|
+
}, 200);
|
|
212
|
+
}
|
|
213
|
+
function Param(//<T extends boolean|number|string|const_Date>(
|
|
214
|
+
set, val, type, range, labels) {
|
|
215
|
+
if (typeof (val) == "boolean")
|
|
216
|
+
return CheckBox(set, val);
|
|
217
|
+
if (Array.isArray(range))
|
|
218
|
+
return InputList(set, val, range, labels);
|
|
219
|
+
if (typeof (val) == "number" && range)
|
|
220
|
+
return InputNumber(set, val, range);
|
|
221
|
+
if ((typeof (val) == "string" && type == "time") || val instanceof Date)
|
|
222
|
+
return InputTime(set, val, range);
|
|
223
|
+
if (typeof (val) == "string")
|
|
224
|
+
return InputString(set, val);
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
function onSetValueA(param, value, enabled) {
|
|
228
|
+
Refresh();
|
|
229
|
+
if (enabled)
|
|
230
|
+
if (typeof value == "number" || value instanceof Date || (value instanceof Array && (typeof value[0] == "number" || value[0] instanceof Date)))
|
|
231
|
+
refreshIndicatorDelayed(); // обрабатываем с задержкой
|
|
232
|
+
else
|
|
233
|
+
refreshIndicator(); // обрабатываем без задержки
|
|
234
|
+
//SessionSave();
|
|
235
|
+
}
|
|
236
|
+
function onExpandA(param, flag) {
|
|
237
|
+
data.onExpand?.(myParams.current);
|
|
238
|
+
}
|
|
239
|
+
function ListParams(obj, parentEnabled = true, expandLevel = 0) {
|
|
240
|
+
return Object.entries(obj).map(([key, param]) => {
|
|
241
|
+
//изменения параметров индикатора
|
|
242
|
+
const onSetValue = (value, currentEnabled = true) => {
|
|
243
|
+
onSetValueA(param, value, parentEnabled && currentEnabled);
|
|
244
|
+
};
|
|
245
|
+
if (!Array.isArray(obj))
|
|
246
|
+
if (typeof (param) == "boolean" || typeof (param) == "string") {
|
|
247
|
+
const set = (data) => {
|
|
248
|
+
obj[key] = data;
|
|
249
|
+
onSetValue(data);
|
|
250
|
+
};
|
|
251
|
+
return _jsx(CParameter, { name: key, enabled: parentEnabled, children: Param(set, param) }, key + "#" + typeof (param));
|
|
252
|
+
}
|
|
253
|
+
if (typeof (param) == "function") {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
else if (typeof (param) == "object") {
|
|
257
|
+
if (param.hidden)
|
|
258
|
+
return null;
|
|
259
|
+
const { value, range, name = key, enabled } = param;
|
|
260
|
+
const nameButton = (type) => FNameButton(type, name);
|
|
261
|
+
const nameT = _jsx("p", { className: "toPTextIndicator", children: name });
|
|
262
|
+
const set = (a) => {
|
|
263
|
+
//if (typeof a=="boolean") {a=!value;}
|
|
264
|
+
const aa = param.value instanceof Date ? new Date(a) : a;
|
|
265
|
+
param.value = aa;
|
|
266
|
+
onSetValue(aa, param.enabled ?? true);
|
|
267
|
+
};
|
|
268
|
+
const onExpand = (flag) => {
|
|
269
|
+
param.expanded = flag;
|
|
270
|
+
onExpandA(param, flag);
|
|
271
|
+
};
|
|
272
|
+
const expanded = param.expanded ?? (data.expandStatus || (expandLevel > 0));
|
|
273
|
+
const simpleParameter = (element) => {
|
|
274
|
+
if (!element)
|
|
275
|
+
return null;
|
|
276
|
+
return _jsxs(CParameter, { name: nameT, enabled: parentEnabled && enabled != false, commentary: param.commentary, children: [element, enabled != null ?
|
|
277
|
+
CheckBox((flag) => {
|
|
278
|
+
param.enabled = flag;
|
|
279
|
+
onSetValue(flag);
|
|
280
|
+
}, enabled)
|
|
281
|
+
: undefined] }, key + "a1");
|
|
282
|
+
};
|
|
283
|
+
const nestedMarginLeft = 20;
|
|
284
|
+
// @ts-ignore
|
|
285
|
+
if (isDate(value)) {
|
|
286
|
+
param.type = "time";
|
|
287
|
+
}
|
|
288
|
+
else if (typeof (value) == "object") {
|
|
289
|
+
let type = param.type;
|
|
290
|
+
const enableHTML = enabled != undefined ?
|
|
291
|
+
_jsx("div", { className: "miniEl", style: { color: enabled ? "inherit" : styleColorDisable }, onClick: () => {
|
|
292
|
+
param.enabled = !enabled;
|
|
293
|
+
onSetValue(value);
|
|
294
|
+
}, children: param.enabled ? "ON " : "OFF" })
|
|
295
|
+
: null;
|
|
296
|
+
// если есть вложение, то делам рекурсию со сдвигом
|
|
297
|
+
if (!Array.isArray(value)) {
|
|
298
|
+
const enabledD = enabled != false && parentEnabled != false;
|
|
299
|
+
const list = ListParams(value, enabledD, expandLevel - 1);
|
|
300
|
+
return _jsx(CButton, { className: "toIndicatorMenuButton", name: nameButton, header: enableHTML, status: expanded, onExpand: onExpand, children: _jsx("div", { className: "", style: {
|
|
301
|
+
paddingLeft: nestedMarginLeft,
|
|
302
|
+
color: enabledD ? "inherit" : styleColorDisable
|
|
303
|
+
}, children: list }, key + "##other") }, key + "#other");
|
|
304
|
+
}
|
|
305
|
+
if (Array.isArray(value)) {
|
|
306
|
+
let arr = value;
|
|
307
|
+
if (Array.isArray(range)) { // значит рисуем выпадающий список
|
|
308
|
+
if (typeof arr[0] == "boolean")
|
|
309
|
+
throw "boolean range is not supported!";
|
|
310
|
+
let arr2 = arr;
|
|
311
|
+
function timeToStrings(data) {
|
|
312
|
+
return data.map(item => item instanceof Date ? timeToStr(item) : item);
|
|
313
|
+
}
|
|
314
|
+
let arr3 = timeToStrings(arr2);
|
|
315
|
+
return simpleParameter(InputListArray(set, arr3, timeToStrings(range), param.labels));
|
|
316
|
+
}
|
|
317
|
+
if (!type) {
|
|
318
|
+
const itemType = typeof (arr[0] ?? range?.min ?? range?.defaultMin);
|
|
319
|
+
if (itemType == "number" || itemType == "string" || itemType == "boolean")
|
|
320
|
+
type = itemType;
|
|
321
|
+
}
|
|
322
|
+
const elements = arr.map((itemVal, index, array) => {
|
|
323
|
+
//работа с массивом отображения и добавления
|
|
324
|
+
const name_ = name + " #" + String(index + 1);
|
|
325
|
+
const nameElement = _jsx("div", { children: name_ }, name_ + "#$3");
|
|
326
|
+
const enabledElements = Array.isArray(param.elementsEnabled) ? param.elementsEnabled : undefined;
|
|
327
|
+
//const onHoverElement = <div style={{position: "absolute", left: -30, top: 0, display: "flex"}}>
|
|
328
|
+
const onHoverElement = _jsxs("div", { style: { marginLeft: -18, marginTop: -7 }, children: [_jsx("div", { className: "toButtonEasy", style: { width: "15px", fontSize: "medium", marginRight: 3 }, onClick: () => {
|
|
329
|
+
array.splice(index, 0, itemVal);
|
|
330
|
+
enabledElements?.splice(index, 0, enabledElements[index]);
|
|
331
|
+
set(array);
|
|
332
|
+
}, children: "+" }), _jsx("div", { className: "toButtonEasy", style: { width: "15px", fontSize: "medium" }, onClick: (e) => {
|
|
333
|
+
array.splice(index, 1);
|
|
334
|
+
enabledElements?.splice(index, 1);
|
|
335
|
+
set(array);
|
|
336
|
+
}, children: "–" })] });
|
|
337
|
+
function onSet(data) {
|
|
338
|
+
array.splice(index, 1, data);
|
|
339
|
+
set(array);
|
|
340
|
+
}
|
|
341
|
+
const paramL = (hover) => _jsxs(CParameter, { name: _jsxs(_Fragment, { children: [hover && !param.constLength && onHoverElement, nameElement] }), commentary: param.commentary, children: [Param(onSet, itemVal, type, range, param.labels), param.elementsEnabled != null ?
|
|
342
|
+
CheckBox((flag) => {
|
|
343
|
+
if (!Array.isArray(param.elementsEnabled))
|
|
344
|
+
param.elementsEnabled = new Array(array.length).fill(param.elementsEnabled == true);
|
|
345
|
+
param.elementsEnabled[index] = flag;
|
|
346
|
+
onSetValue(value, enabled && flag);
|
|
347
|
+
}, Array.isArray(param.elementsEnabled) ? param.elementsEnabled[index] : param.elementsEnabled)
|
|
348
|
+
: undefined] });
|
|
349
|
+
return _jsx(DivHover, { children: (hover) => paramL(hover) }, name_ + "#$");
|
|
350
|
+
});
|
|
351
|
+
return _jsx(CButton, { className: "toIndicatorMenuButton", name: nameButton, status: expanded, header: enableHTML, onExpand: onExpand, children: _jsx("div", { className: "", style: { overflow: "hidden", paddingLeft: nestedMarginLeft }, children: _jsxs("div", { style: { animation: "0.1s ease 0s 1 normal none running moveDown" }, children: [_jsx("div", { className: "", style: {
|
|
352
|
+
//marginLeft: widthStr,
|
|
353
|
+
//width: "calc(100%-" + widthStr + ")",
|
|
354
|
+
color: "inherit"
|
|
355
|
+
}, children: elements }), !param.constLength &&
|
|
356
|
+
_jsx("div", { className: "toButtonEasy", style: { paddingLeft: 10, textAlign: "left" /*width: "255px"*/ }, onClick: () => {
|
|
357
|
+
let element = arr.at(-1);
|
|
358
|
+
element ??= Array.isArray(param.range) ? param.range[0] : param.range ? param.range.min :
|
|
359
|
+
type == "boolean" ? false : type == "string" ? "" : (() => { throw "unknown array param type: " + type; })();
|
|
360
|
+
arr.push(element);
|
|
361
|
+
set(arr);
|
|
362
|
+
}, children: " ......add new element" })] }) }) }, key + "#$");
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
{
|
|
366
|
+
return simpleParameter(Param(set, value, undefined, range, param.labels));
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return null;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
return _jsx(_Fragment, { children: ListParams(myParams.current, undefined, data.expandStatusLvl).filter((el) => el != null) });
|
|
373
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './Buttons';
|
|
2
|
+
export * from './Dnd';
|
|
3
|
+
export * from './Menu';
|
|
4
|
+
export * from './Modal';
|
|
5
|
+
export * from './Input';
|
|
6
|
+
export * from './Parameters';
|
|
7
|
+
export * from './ParametersEngine';
|
|
8
|
+
export * from './MyResizeObserver';
|
|
9
|
+
export * from './Other';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './Buttons';
|
|
2
|
+
export * from './Dnd';
|
|
3
|
+
export * from './Menu';
|
|
4
|
+
export * from './Modal';
|
|
5
|
+
export * from './Input';
|
|
6
|
+
export * from './Parameters';
|
|
7
|
+
export * from './ParametersEngine';
|
|
8
|
+
export * from './MyResizeObserver';
|
|
9
|
+
export * from './Other';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { renderBy } from "../../updateBy";
|
|
3
|
+
export const KeyDown = {
|
|
4
|
+
key: ""
|
|
5
|
+
};
|
|
6
|
+
export function useAddDownAnyKey() {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const func = (ev) => {
|
|
9
|
+
console.log(ev);
|
|
10
|
+
KeyDown.key = ev.key;
|
|
11
|
+
renderBy(KeyDown);
|
|
12
|
+
};
|
|
13
|
+
document.addEventListener("keydown", func);
|
|
14
|
+
return () => {
|
|
15
|
+
document.removeEventListener("keydown", func);
|
|
16
|
+
};
|
|
17
|
+
}, [true]);
|
|
18
|
+
}
|
|
19
|
+
// Backward-compatible name.
|
|
20
|
+
export function addDownAnyKey() {
|
|
21
|
+
return useAddDownAnyKey();
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface Position {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export interface UseDraggableReturn {
|
|
6
|
+
position: Position;
|
|
7
|
+
dragProps: {
|
|
8
|
+
onMouseDown: React.MouseEventHandler<HTMLDivElement>;
|
|
9
|
+
onTouchStart: React.TouchEventHandler<HTMLDivElement>;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
type DragEndCallback = (finalPosition: Position) => void;
|
|
13
|
+
type DragStartCallback = () => void;
|
|
14
|
+
export declare function useDraggable(initialX?: number, initialY?: number, timeOut?: number, onDragEnd?: DragEndCallback, onDragStart?: DragStartCallback): UseDraggableReturn;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { useRef, useState, useEffect } from "react";
|
|
2
|
+
export function useDraggable(initialX = 0, initialY = 0, timeOut = 500, onDragEnd, onDragStart) {
|
|
3
|
+
const [position, setPosition] = useState({ x: initialX, y: initialY });
|
|
4
|
+
const offsetMouse = useRef({ x: 0, y: 0 });
|
|
5
|
+
const offsetTouch = useRef(null);
|
|
6
|
+
const [draggingMouse, setDraggingMouse] = useState(false);
|
|
7
|
+
const [draggingTouch, setDraggingTouch] = useState(false);
|
|
8
|
+
// Таймеры для определения длинного нажатия
|
|
9
|
+
const holdTimerMouse = useRef(null);
|
|
10
|
+
const holdTimerTouch = useRef(null);
|
|
11
|
+
const cancelMouseHold = () => {
|
|
12
|
+
if (holdTimerMouse.current) {
|
|
13
|
+
clearTimeout(holdTimerMouse.current);
|
|
14
|
+
holdTimerMouse.current = null;
|
|
15
|
+
}
|
|
16
|
+
document.removeEventListener("mouseup", handleMouseUpForHold);
|
|
17
|
+
};
|
|
18
|
+
const handleMouseUpForHold = () => {
|
|
19
|
+
cancelMouseHold();
|
|
20
|
+
};
|
|
21
|
+
const handleMouseDown = (e) => {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
offsetMouse.current = {
|
|
24
|
+
x: e.clientX,
|
|
25
|
+
y: e.clientY,
|
|
26
|
+
};
|
|
27
|
+
if (timeOut) {
|
|
28
|
+
holdTimerMouse.current = window.setTimeout(() => {
|
|
29
|
+
setDraggingMouse(true);
|
|
30
|
+
holdTimerMouse.current = null;
|
|
31
|
+
document.removeEventListener("mouseup", handleMouseUpForHold);
|
|
32
|
+
}, timeOut);
|
|
33
|
+
document.addEventListener("mouseup", handleMouseUpForHold);
|
|
34
|
+
}
|
|
35
|
+
onDragStart?.();
|
|
36
|
+
};
|
|
37
|
+
const cancelTouchHold = () => {
|
|
38
|
+
if (holdTimerTouch.current) {
|
|
39
|
+
clearTimeout(holdTimerTouch.current);
|
|
40
|
+
holdTimerTouch.current = null;
|
|
41
|
+
}
|
|
42
|
+
document.removeEventListener("touchend", handleTouchEndForHold);
|
|
43
|
+
};
|
|
44
|
+
const handleTouchEndForHold = () => {
|
|
45
|
+
cancelTouchHold();
|
|
46
|
+
};
|
|
47
|
+
const handleTouchStart = (e) => {
|
|
48
|
+
const touch = e.changedTouches[0];
|
|
49
|
+
if (!touch)
|
|
50
|
+
return;
|
|
51
|
+
offsetTouch.current = {
|
|
52
|
+
x: touch.clientX,
|
|
53
|
+
y: touch.clientY,
|
|
54
|
+
id: touch.identifier,
|
|
55
|
+
};
|
|
56
|
+
if (timeOut) {
|
|
57
|
+
holdTimerTouch.current = window.setTimeout(() => {
|
|
58
|
+
setDraggingTouch(true);
|
|
59
|
+
holdTimerTouch.current = null;
|
|
60
|
+
document.removeEventListener("touchend", handleTouchEndForHold);
|
|
61
|
+
}, timeOut);
|
|
62
|
+
document.addEventListener("touchend", handleTouchEndForHold);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (draggingMouse) {
|
|
67
|
+
const handleMouseMove = (e) => {
|
|
68
|
+
const newX = e.clientX - offsetMouse.current.x;
|
|
69
|
+
const newY = e.clientY - offsetMouse.current.y;
|
|
70
|
+
setPosition({ x: newX, y: newY });
|
|
71
|
+
};
|
|
72
|
+
const handleMouseUp = (e) => {
|
|
73
|
+
setPosition({ x: 0, y: 0 });
|
|
74
|
+
// Остальные действия по завершению перетаскивания мышью
|
|
75
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
76
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
77
|
+
setDraggingMouse(false);
|
|
78
|
+
if (onDragEnd) {
|
|
79
|
+
onDragEnd({ ...position });
|
|
80
|
+
}
|
|
81
|
+
// Сбрасываем смещение
|
|
82
|
+
offsetMouse.current = { x: 0, y: 0 };
|
|
83
|
+
};
|
|
84
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
85
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
86
|
+
return () => {
|
|
87
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
88
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}, [draggingMouse, onDragEnd, position]);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (draggingTouch) {
|
|
94
|
+
const handleTouchMove = (e) => {
|
|
95
|
+
if (!offsetTouch.current)
|
|
96
|
+
return;
|
|
97
|
+
const theTouch = Array.from(e.changedTouches).find((t) => t.identifier === offsetTouch.current?.id);
|
|
98
|
+
if (!theTouch)
|
|
99
|
+
return;
|
|
100
|
+
const newX = theTouch.clientX - offsetTouch.current.x;
|
|
101
|
+
const newY = theTouch.clientY - offsetTouch.current.y;
|
|
102
|
+
setPosition({ x: newX, y: newY });
|
|
103
|
+
};
|
|
104
|
+
const handleTouchEnd = (e) => {
|
|
105
|
+
if (!offsetTouch.current)
|
|
106
|
+
return;
|
|
107
|
+
const ended = Array.from(e.changedTouches).find((t) => t.identifier === offsetTouch.current?.id);
|
|
108
|
+
if (ended) {
|
|
109
|
+
setPosition({ x: 0, y: 0 });
|
|
110
|
+
document.removeEventListener("touchmove", handleTouchMove);
|
|
111
|
+
document.removeEventListener("touchend", handleTouchEnd);
|
|
112
|
+
setDraggingTouch(false);
|
|
113
|
+
if (onDragEnd) {
|
|
114
|
+
onDragEnd({ ...position });
|
|
115
|
+
}
|
|
116
|
+
offsetTouch.current = null;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
document.addEventListener("touchmove", handleTouchMove);
|
|
120
|
+
document.addEventListener("touchend", handleTouchEnd);
|
|
121
|
+
return () => {
|
|
122
|
+
document.removeEventListener("touchmove", handleTouchMove);
|
|
123
|
+
document.removeEventListener("touchend", handleTouchEnd);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}, [draggingTouch, onDragEnd, position]);
|
|
127
|
+
return {
|
|
128
|
+
position,
|
|
129
|
+
dragProps: {
|
|
130
|
+
onMouseDown: handleMouseDown,
|
|
131
|
+
onTouchStart: handleTouchStart,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
2
|
+
export declare const StyleOtherRow: React.CSSProperties;
|
|
3
|
+
export declare const StyleOtherColum: React.CSSProperties;
|
|
4
|
+
export declare function useOutside({ outsideClick, ref, status }: {
|
|
5
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
6
|
+
outsideClick: () => void;
|
|
7
|
+
status?: boolean;
|
|
8
|
+
}): React.RefObject<HTMLDivElement | null>;
|
|
9
|
+
type tChildrenFunc = (api: {
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
}) => ReactElement | React.JSX.Element;
|
|
12
|
+
type tChildrenEl = ReactElement | React.ReactNode;
|
|
13
|
+
type tChildren = tChildrenEl | tChildrenFunc;
|
|
14
|
+
type tButtonBase = {
|
|
15
|
+
children: tChildren;
|
|
16
|
+
button: ReactElement | ((status: boolean) => ReactElement);
|
|
17
|
+
style?: React.CSSProperties;
|
|
18
|
+
className?: string;
|
|
19
|
+
};
|
|
20
|
+
type tButton = tButtonBase & {
|
|
21
|
+
statusDef?: boolean;
|
|
22
|
+
keySave?: string;
|
|
23
|
+
outClick?: boolean | (() => void);
|
|
24
|
+
zIndex?: number;
|
|
25
|
+
};
|
|
26
|
+
export declare const DivOutsideClick: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
27
|
+
outsideClick: () => void;
|
|
28
|
+
status?: boolean;
|
|
29
|
+
zIndex?: number;
|
|
30
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
31
|
+
export declare const DivOutsideClick2: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
32
|
+
outsideClick: () => void;
|
|
33
|
+
status?: boolean;
|
|
34
|
+
zIndex?: number;
|
|
35
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
36
|
+
export declare function Button({ keySave, statusDef, outClick, ...data }: tButton): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
37
|
+
export declare function ButtonHover(props: tButtonBase): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export declare const ButtonOutClick: typeof Button;
|
|
39
|
+
export declare function ButtonAbs(...a: Parameters<typeof Button>): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
40
|
+
export {};
|