carbon-react 109.3.1 → 109.3.2
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,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import MatchingText from "./matching-text.style";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
function highlightPartOfText(text, partToHighlight) {
|
|
4
5
|
if (!partToHighlight || !partToHighlight.length || !text) return text;
|
|
5
6
|
const lowercaseText = text.toLowerCase();
|
|
6
7
|
const lowercasePart = partToHighlight.toLowerCase();
|
|
@@ -26,4 +27,15 @@ export default function highlightPartOfText(text, partToHighlight) {
|
|
|
26
27
|
key: "following"
|
|
27
28
|
}, followingText)];
|
|
28
29
|
return newValue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default function highlightPartOfTextRecursive(child, partToHighlight) {
|
|
33
|
+
if (typeof child === "string") {
|
|
34
|
+
return highlightPartOfText(child, partToHighlight);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const highlightedChildren = React.Children.map(child.props.children, grandChild => highlightPartOfTextRecursive(grandChild, partToHighlight));
|
|
38
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
39
|
+
children: highlightedChildren
|
|
40
|
+
});
|
|
29
41
|
}
|
|
@@ -29,9 +29,10 @@ const filterOptionRows = (optionRow, filterText) => {
|
|
|
29
29
|
const processedText = cell.props.children.toLowerCase();
|
|
30
30
|
const processedValue = filterText.toLowerCase();
|
|
31
31
|
return processedText.includes(processedValue);
|
|
32
|
-
}
|
|
32
|
+
} // filter recursively based on children
|
|
33
|
+
|
|
33
34
|
|
|
34
|
-
return
|
|
35
|
+
return filterOptionRows(cell, filterText);
|
|
35
36
|
});
|
|
36
37
|
|
|
37
38
|
if (hasText) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = highlightPartOfTextRecursive;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -37,4 +37,16 @@ function highlightPartOfText(text, partToHighlight) {
|
|
|
37
37
|
key: "following"
|
|
38
38
|
}, followingText)];
|
|
39
39
|
return newValue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function highlightPartOfTextRecursive(child, partToHighlight) {
|
|
43
|
+
if (typeof child === "string") {
|
|
44
|
+
return highlightPartOfText(child, partToHighlight);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const highlightedChildren = _react.default.Children.map(child.props.children, grandChild => highlightPartOfTextRecursive(grandChild, partToHighlight));
|
|
48
|
+
|
|
49
|
+
return /*#__PURE__*/_react.default.cloneElement(child, {
|
|
50
|
+
children: highlightedChildren
|
|
51
|
+
});
|
|
40
52
|
}
|
|
@@ -50,9 +50,10 @@ const filterOptionRows = (optionRow, filterText) => {
|
|
|
50
50
|
const processedText = cell.props.children.toLowerCase();
|
|
51
51
|
const processedValue = filterText.toLowerCase();
|
|
52
52
|
return processedText.includes(processedValue);
|
|
53
|
-
}
|
|
53
|
+
} // filter recursively based on children
|
|
54
|
+
|
|
54
55
|
|
|
55
|
-
return
|
|
56
|
+
return filterOptionRows(cell, filterText);
|
|
56
57
|
});
|
|
57
58
|
|
|
58
59
|
if (hasText) {
|