aloha-vue 1.2.195 → 1.2.196

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/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "Vue.js"
15
15
  ],
16
16
  "homepage": "https://github.com/ilia-brykin/aloha/#README.md",
17
- "version": "1.2.195",
17
+ "version": "1.2.196",
18
18
  "author": {
19
19
  "name": "Ilia Brykin",
20
20
  "email": "brykin.ilia@gmail.com"
@@ -6,6 +6,7 @@ import {
6
6
  import AKeyId from "../../const/AKeyId";
7
7
  import AKeyLabel from "../../const/AKeyLabel";
8
8
  import {
9
+ escapeRegExp,
9
10
  forEach,
10
11
  } from "lodash-es";
11
12
 
@@ -49,7 +50,7 @@ export default function AMenuSearchAPI(props, {
49
50
  rest: {},
50
51
  };
51
52
  if (isSearchActive.value) {
52
- const RE = new RegExp(modelSearch.value, "gi");
53
+ const RE = new RegExp(escapeRegExp(modelSearch.value), "gi");
53
54
  forEach(dataProParentList.value, (items, index) => {
54
55
  let isVisible = false;
55
56
  forEach(items, item => {
@@ -6,6 +6,7 @@ import {
6
6
 
7
7
  import AKeyLabel from "../../const/AKeyLabel";
8
8
  import {
9
+ escapeRegExp,
9
10
  forEach,
10
11
  } from "lodash-es";
11
12
 
@@ -40,10 +41,14 @@ export default function SearchAPI(props, {
40
41
  }
41
42
  };
42
43
 
44
+ const modelSearchEscapeRegExp = computed(() => {
45
+ return escapeRegExp(modelSearch.value);
46
+ });
47
+
43
48
  const itemsWithSearch = computed(() => {
44
49
  const ITEMS = [];
45
50
  if (isSearchActive.value) {
46
- const RE = new RegExp(modelSearch.value, "gi");
51
+ const RE = new RegExp(modelSearchEscapeRegExp.value, "gi");
47
52
  forEach(dataKeyById.value, item => {
48
53
  const ITEM_LABEL = item[AKeyLabel];
49
54
  if (`${ ITEM_LABEL }`.search(RE) !== -1) {
@@ -3,6 +3,10 @@ import {
3
3
  toRef,
4
4
  } from "vue";
5
5
 
6
+ import {
7
+ escapeRegExp,
8
+ } from "lodash-es";
9
+
6
10
  export default function AttributesComponentAPI(props, {
7
11
  attributesForRoot = computed(() => ({})),
8
12
  isColumnVisible = computed(() => false),
@@ -15,7 +19,7 @@ export default function AttributesComponentAPI(props, {
15
19
  if (!searchColumnModel.value) {
16
20
  return true;
17
21
  }
18
- const RE = new RegExp(searchColumnModel.value, "gi");
22
+ const RE = new RegExp(escapeRegExp(searchColumnModel.value), "gi");
19
23
  return `${ labelTranslated.value }`.search(RE) !== -1;
20
24
  });
21
25
 
@@ -1,4 +1,5 @@
1
1
  import {
2
+ escapeRegExp,
2
3
  isNil,
3
4
  } from "lodash-es";
4
5
 
@@ -20,6 +21,6 @@ export default function(value, { searchModel = "", searchClass = "a_search_highl
20
21
  if (searchModel === "" || isNil(searchModel)) {
21
22
  return value;
22
23
  }
23
- const RE = new RegExp(searchModel, "gi");
24
+ const RE = new RegExp(escapeRegExp(searchModel), "gi");
24
25
  return value.replace(RE, val => `<span class="${ searchClass }">${ val }</span>`);
25
26
  }
@@ -7,6 +7,7 @@ import {
7
7
  import AKeyLabel from "../../const/AKeyLabel";
8
8
  import AKeyId from "../../const/AKeyId";
9
9
  import {
10
+ escapeRegExp,
10
11
  forEach,
11
12
  get,
12
13
  isEmpty,
@@ -46,6 +47,14 @@ export default function UiSearchAPI(props, { emit }, {
46
47
  return toLower(modelSearch.value || "");
47
48
  });
48
49
 
50
+ const modelSearchEscapeRegExp = computed(() => {
51
+ return escapeRegExp(modelSearchLowerCase.value);
52
+ });
53
+
54
+ const modelSearchRE = computed(() => {
55
+ return new RegExp(modelSearchEscapeRegExp.value, "gi");
56
+ });
57
+
49
58
  const setElementsVisibleWithSearch = () => {
50
59
  const ELEMENTS_EXTRA_VISIBLE = {};
51
60
  const ELEMENTS_VISIBLE = {};
@@ -56,7 +65,7 @@ export default function UiSearchAPI(props, { emit }, {
56
65
  forEach(data.value, element => {
57
66
  const ELEMENT_LABEL = element[AKeyLabel];
58
67
  const ELEMENT_ID = element[AKeyId];
59
- if (toLower(`${ ELEMENT_LABEL }`).indexOf(modelSearchLowerCase.value) !== -1) {
68
+ if (`${ ELEMENT_LABEL }`.search(modelSearchRE.value) !== -1) {
60
69
  ELEMENTS_VISIBLE[ELEMENT_ID] = true;
61
70
  let allGroupKeys = "";
62
71
  forEach(keyGroupArray.value, keyGroup => {
@@ -73,7 +82,7 @@ export default function UiSearchAPI(props, { emit }, {
73
82
  forEach(data.value, element => {
74
83
  const ELEMENT_LABEL = element[AKeyLabel];
75
84
  const ELEMENT_ID = element[AKeyId];
76
- if (toLower(`${ ELEMENT_LABEL }`).indexOf(modelSearchLowerCase.value) !== -1) {
85
+ if (`${ ELEMENT_LABEL }`.search(modelSearchRE.value) !== -1) {
77
86
  ELEMENTS_VISIBLE[ELEMENT_ID] = true;
78
87
  }
79
88
  });
@@ -81,7 +90,7 @@ export default function UiSearchAPI(props, { emit }, {
81
90
  forEach(dataExtra.value, element => {
82
91
  const ELEMENT_LABEL = element[AKeyLabel];
83
92
  const ELEMENT_ID = element[AKeyId];
84
- if (toLower(`${ ELEMENT_LABEL }`).indexOf(modelSearchLowerCase.value) !== -1) {
93
+ if (`${ ELEMENT_LABEL }`.search(modelSearchRE.value) !== -1) {
85
94
  ELEMENTS_EXTRA_VISIBLE[ELEMENT_ID] = true;
86
95
  }
87
96
  });