@danikokonn/yarik-frontend-lib 2.0.58-test18 → 2.0.58-test19
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichFilterTextField.d.ts","sourceRoot":"","sources":["../../../src/components/RichFilterTextField/RichFilterTextField.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"RichFilterTextField.d.ts","sourceRoot":"","sources":["../../../src/components/RichFilterTextField/RichFilterTextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAKN,MAAM,OAAO,CAAC;AAUf,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAKlE,QAAA,MAAM,mBAAmB,GAAI,4HAS1B,wBAAwB,sBA+R1B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -12,13 +12,14 @@ import { Stack } from "@mui/material";
|
|
|
12
12
|
const RichFilterTextField = ({ filterExpr, filterExprHist, fields, operators, additionalComponents, instant: _instant, onChange, onSelectFromHistory, }) => {
|
|
13
13
|
const { enqueueSnackbar } = useSnackbarContext();
|
|
14
14
|
const [search, setSearch] = useState(filterExpr);
|
|
15
|
+
const prevFilterExpr = useRef(filterExpr);
|
|
16
|
+
if (prevFilterExpr.current !== filterExpr && filterExpr !== search) {
|
|
17
|
+
setSearch(filterExpr);
|
|
18
|
+
prevFilterExpr.current = filterExpr;
|
|
19
|
+
}
|
|
15
20
|
const instant = _instant ?? true;
|
|
16
21
|
const [searchHist, setSearchHist] = useState(filterExprHist);
|
|
17
|
-
// const [inputAnchor, setInputAnchor] = useState<HTMLDivElement | null>(null);
|
|
18
22
|
const [cursorPos, setCursorPos] = useState(null);
|
|
19
|
-
// const [currentHintOptions, setCurrentHintOptions] = useState<
|
|
20
|
-
// Map<string, string | undefined>
|
|
21
|
-
// >(() => new Map());
|
|
22
23
|
const [focusIdx, setFocusIdx] = useState(0);
|
|
23
24
|
const inputRef = useRef(null);
|
|
24
25
|
const textFieldRef = useRef(null);
|
|
@@ -26,28 +27,12 @@ const RichFilterTextField = ({ filterExpr, filterExprHist, fields, operators, ad
|
|
|
26
27
|
? getHints(search, cursorPos, fields, operators)
|
|
27
28
|
: null) ?? new Map();
|
|
28
29
|
const inputAnchor = currentHintOptions?.size > 0 ? textFieldRef.current : null;
|
|
29
|
-
// useEffect(() => {
|
|
30
|
-
// if (cursorPos == null) return;
|
|
31
|
-
// if (currentHintOptions === getHints(search, cursorPos, fields, operators))
|
|
32
|
-
// return;
|
|
33
|
-
// setFocusIdx(0);
|
|
34
|
-
// // setInputAnchor(currentHintOptions?.size > 0 ? textFieldRef.current : null);
|
|
35
|
-
// }, [search, cursorPos]);
|
|
36
|
-
// useEffect(() => {
|
|
37
|
-
// if (cursorPos == null) return;
|
|
38
|
-
// if (inputRef.current && cursorPos !== inputRef.current.selectionStart) {
|
|
39
|
-
// inputRef.current.selectionStart = cursorPos;
|
|
40
|
-
// inputRef.current.selectionEnd = cursorPos;
|
|
41
|
-
// }
|
|
42
|
-
// }, [cursorPos]);
|
|
43
30
|
if (cursorPos != null &&
|
|
44
31
|
inputRef.current &&
|
|
45
32
|
cursorPos !== inputRef.current.selectionStart) {
|
|
46
33
|
inputRef.current.selectionStart = cursorPos;
|
|
47
34
|
inputRef.current.selectionEnd = cursorPos;
|
|
48
35
|
}
|
|
49
|
-
// Принудительное изменение состояния, если изменился пропс
|
|
50
|
-
// useEffect(() => setSearch(filterExpr), [filterExpr]);
|
|
51
36
|
const handleChange = (value, _idx) => {
|
|
52
37
|
setSearch(value);
|
|
53
38
|
if (cursorPos &&
|