@danikokonn/yarik-frontend-lib 2.0.58-test18 → 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,KAMN,MAAM,OAAO,CAAC;AAUf,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAKlE,QAAA,MAAM,mBAAmB,GAAI,4HAS1B,wBAAwB,sBAkT1B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
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,42 +12,29 @@ 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 instant = _instant ?? true;
16
15
  const [searchHist, setSearchHist] = useState(filterExprHist);
17
- // const [inputAnchor, setInputAnchor] = useState<HTMLDivElement | null>(null);
18
16
  const [cursorPos, setCursorPos] = useState(null);
19
- // const [currentHintOptions, setCurrentHintOptions] = useState<
20
- // Map<string, string | undefined>
21
- // >(() => new Map());
22
17
  const [focusIdx, setFocusIdx] = useState(0);
23
18
  const inputRef = useRef(null);
24
19
  const textFieldRef = useRef(null);
20
+ const prevFilterExpr = useRef(filterExpr);
21
+ const instant = _instant ?? true;
25
22
  const currentHintOptions = (cursorPos != null
26
23
  ? getHints(search, cursorPos, fields, operators)
27
24
  : null) ?? new Map();
28
25
  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]);
26
+ if (prevFilterExpr.current !== filterExpr && filterExpr !== search) {
27
+ setSearch(filterExpr);
28
+ setCursorPos(null);
29
+ setFocusIdx(0);
30
+ prevFilterExpr.current = filterExpr;
31
+ }
43
32
  if (cursorPos != null &&
44
33
  inputRef.current &&
45
34
  cursorPos !== inputRef.current.selectionStart) {
46
35
  inputRef.current.selectionStart = cursorPos;
47
36
  inputRef.current.selectionEnd = cursorPos;
48
37
  }
49
- // Принудительное изменение состояния, если изменился пропс
50
- // useEffect(() => setSearch(filterExpr), [filterExpr]);
51
38
  const handleChange = (value, _idx) => {
52
39
  setSearch(value);
53
40
  if (cursorPos &&
@@ -103,7 +90,6 @@ const RichFilterTextField = ({ filterExpr, filterExprHist, fields, operators, ad
103
90
  }
104
91
  case "Escape":
105
92
  case "Tab": {
106
- // setInputAnchor(null);
107
93
  setCursorPos(null);
108
94
  break;
109
95
  }
@@ -156,7 +142,6 @@ const RichFilterTextField = ({ filterExpr, filterExprHist, fields, operators, ad
156
142
  }
157
143
  case "Escape":
158
144
  case "Tab": {
159
- // setInputAnchor(null);
160
145
  setCursorPos(null);
161
146
  setFocusIdx(0);
162
147
  break;
@@ -180,12 +165,7 @@ const RichFilterTextField = ({ filterExpr, filterExprHist, fields, operators, ad
180
165
  getHints(e.target.value, newCursorPos, fields, operators) !==
181
166
  currentHintOptions)
182
167
  setFocusIdx(0);
183
- },
184
- // onClick={(e) => {
185
- // if (e.target !== e.currentTarget) return;
186
- // setCursorPos(inputRef.current?.selectionStart ?? null);
187
- // }}
188
- onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, slotProps: {
168
+ }, onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, slotProps: {
189
169
  htmlInput: {
190
170
  onClick: (e) => {
191
171
  if (Object(e).target !== Object(e).currentTarget)
@@ -217,7 +197,6 @@ const RichFilterTextField = ({ filterExpr, filterExprHist, fields, operators, ad
217
197
  },
218
198
  } }),
219
199
  React.createElement(HintOptionsMenu, { inputAnchor: inputAnchor, inputRef: inputRef, textFieldRef: textFieldRef, options: currentHintOptions, focusIdx: focusIdx, onSelectHint: insertHint, onClose: () => {
220
- // setInputAnchor(null);
221
200
  setCursorPos(null);
222
201
  setFocusIdx(0);
223
202
  } })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danikokonn/yarik-frontend-lib",
3
- "version": "2.0.58-test18",
3
+ "version": "2.0.58-test20",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "author": "",