@steroidsjs/core 2.2.74 → 2.2.77

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/hooks/useFetch.js CHANGED
@@ -128,6 +128,7 @@ function useFetch(rawConfig) {
128
128
  if (newConfig) {
129
129
  setConfig(__assign(__assign(__assign({}, config), newConfig), { params: __assign(__assign({}, config === null || config === void 0 ? void 0 : config.params), newConfig === null || newConfig === void 0 ? void 0 : newConfig.params) }));
130
130
  }
131
+ setAxiosError(null);
131
132
  setData(null);
132
133
  if (!config) return [3 /*break*/, 5];
133
134
  setIsLoading(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steroidsjs/core",
3
- "version": "2.2.74",
3
+ "version": "2.2.77",
4
4
  "description": "",
5
5
  "author": "Vladimir Kozhin <hello@kozhindev.com>",
6
6
  "repository": {
package/utils/text.d.ts CHANGED
@@ -1 +1,16 @@
1
- export declare const smartSearch: (query: any, sourceItems: any) => any;
1
+ interface ISmartSearchSourceItem {
2
+ id: string | number;
3
+ label: string | number;
4
+ }
5
+ interface ISmartSearchOutputItem extends ISmartSearchSourceItem {
6
+ labelHighlighted?: [string, boolean][];
7
+ }
8
+ export declare type TSmartSearchOutput = ISmartSearchOutputItem[];
9
+ /**
10
+ * Регистронезависимый поиск.
11
+ *
12
+ * @param query
13
+ * @param sourceItems
14
+ */
15
+ export declare const smartSearch: (query: string, sourceItems: ISmartSearchSourceItem[]) => TSmartSearchOutput;
16
+ export {};
package/utils/text.js CHANGED
@@ -15,6 +15,12 @@ var stringToWords = function (str) {
15
15
  words.pop();
16
16
  return words.filter(Boolean);
17
17
  };
18
+ /**
19
+ * Регистронезависимый поиск.
20
+ *
21
+ * @param query
22
+ * @param sourceItems
23
+ */
18
24
  // eslint-disable-next-line import/prefer-default-export
19
25
  var smartSearch = function (query, sourceItems) {
20
26
  if (!query) {
@@ -34,6 +40,7 @@ var smartSearch = function (query, sourceItems) {
34
40
  var wordIndex = 0;
35
41
  var wordChar = null;
36
42
  var wordCharIndex = 0;
43
+ var prevIsMatch = false;
37
44
  // eslint-disable-next-line no-constant-condition
38
45
  while (true) {
39
46
  var char = queryCharacters[index];
@@ -50,24 +57,28 @@ var smartSearch = function (query, sourceItems) {
50
57
  highlighted = [];
51
58
  break;
52
59
  }
53
- var isMatch = !char.match(/[\p{Lu}]/u)
54
- ? wordChar.toLowerCase() === char.toLowerCase()
55
- : wordChar === char;
60
+ var isMatch = wordChar.toLowerCase() === char.toLowerCase();
56
61
  if (isMatch) {
57
62
  index += 1;
58
63
  wordCharIndex += 1;
59
64
  highlighted[highlighted.length - 1][0] += wordChar;
60
65
  highlighted[highlighted.length - 1][1] = true;
66
+ prevIsMatch = true;
61
67
  }
62
68
  else {
69
+ if (!prevIsMatch) {
70
+ index = 0;
71
+ }
63
72
  highlighted.push([word.substr(wordCharIndex), false]);
64
73
  highlighted.push(['', false]);
65
74
  wordIndex += 1;
66
75
  wordCharIndex = 0;
76
+ prevIsMatch = false;
67
77
  }
68
78
  }
69
79
  highlighted = highlighted.filter(function (highlightedItem) { return !!highlightedItem[0]; });
70
80
  if (highlighted.findIndex(function (highlightedItem) { return highlightedItem[1]; }) !== -1) {
81
+ // @ts-ignore
71
82
  item.labelHighlighted = highlighted;
72
83
  return true;
73
84
  }