@danikokonn/yarik-frontend-lib 2.0.58-test19 → 2.0.58-test20
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,KAKN,MAAM,OAAO,CAAC;AAUf,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAKlE,QAAA,MAAM,mBAAmB,GAAI,4HAS1B,wBAAwB,
|
|
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,sBAwR1B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -12,21 +12,23 @@ 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
|
-
}
|
|
20
|
-
const instant = _instant ?? true;
|
|
21
15
|
const [searchHist, setSearchHist] = useState(filterExprHist);
|
|
22
16
|
const [cursorPos, setCursorPos] = useState(null);
|
|
23
17
|
const [focusIdx, setFocusIdx] = useState(0);
|
|
24
18
|
const inputRef = useRef(null);
|
|
25
19
|
const textFieldRef = useRef(null);
|
|
20
|
+
const prevFilterExpr = useRef(filterExpr);
|
|
21
|
+
const instant = _instant ?? true;
|
|
26
22
|
const currentHintOptions = (cursorPos != null
|
|
27
23
|
? getHints(search, cursorPos, fields, operators)
|
|
28
24
|
: null) ?? new Map();
|
|
29
25
|
const inputAnchor = currentHintOptions?.size > 0 ? textFieldRef.current : null;
|
|
26
|
+
if (prevFilterExpr.current !== filterExpr && filterExpr !== search) {
|
|
27
|
+
setSearch(filterExpr);
|
|
28
|
+
setCursorPos(null);
|
|
29
|
+
setFocusIdx(0);
|
|
30
|
+
prevFilterExpr.current = filterExpr;
|
|
31
|
+
}
|
|
30
32
|
if (cursorPos != null &&
|
|
31
33
|
inputRef.current &&
|
|
32
34
|
cursorPos !== inputRef.current.selectionStart) {
|
|
@@ -88,7 +90,6 @@ const RichFilterTextField = ({ filterExpr, filterExprHist, fields, operators, ad
|
|
|
88
90
|
}
|
|
89
91
|
case "Escape":
|
|
90
92
|
case "Tab": {
|
|
91
|
-
// setInputAnchor(null);
|
|
92
93
|
setCursorPos(null);
|
|
93
94
|
break;
|
|
94
95
|
}
|
|
@@ -141,7 +142,6 @@ const RichFilterTextField = ({ filterExpr, filterExprHist, fields, operators, ad
|
|
|
141
142
|
}
|
|
142
143
|
case "Escape":
|
|
143
144
|
case "Tab": {
|
|
144
|
-
// setInputAnchor(null);
|
|
145
145
|
setCursorPos(null);
|
|
146
146
|
setFocusIdx(0);
|
|
147
147
|
break;
|
|
@@ -165,12 +165,7 @@ const RichFilterTextField = ({ filterExpr, filterExprHist, fields, operators, ad
|
|
|
165
165
|
getHints(e.target.value, newCursorPos, fields, operators) !==
|
|
166
166
|
currentHintOptions)
|
|
167
167
|
setFocusIdx(0);
|
|
168
|
-
},
|
|
169
|
-
// onClick={(e) => {
|
|
170
|
-
// if (e.target !== e.currentTarget) return;
|
|
171
|
-
// setCursorPos(inputRef.current?.selectionStart ?? null);
|
|
172
|
-
// }}
|
|
173
|
-
onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, slotProps: {
|
|
168
|
+
}, onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, slotProps: {
|
|
174
169
|
htmlInput: {
|
|
175
170
|
onClick: (e) => {
|
|
176
171
|
if (Object(e).target !== Object(e).currentTarget)
|
|
@@ -202,7 +197,6 @@ const RichFilterTextField = ({ filterExpr, filterExprHist, fields, operators, ad
|
|
|
202
197
|
},
|
|
203
198
|
} }),
|
|
204
199
|
React.createElement(HintOptionsMenu, { inputAnchor: inputAnchor, inputRef: inputRef, textFieldRef: textFieldRef, options: currentHintOptions, focusIdx: focusIdx, onSelectHint: insertHint, onClose: () => {
|
|
205
|
-
// setInputAnchor(null);
|
|
206
200
|
setCursorPos(null);
|
|
207
201
|
setFocusIdx(0);
|
|
208
202
|
} })));
|