carbon-react 141.0.5 → 141.0.6

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.
@@ -149,7 +149,7 @@ export const NumeralDate = ({
149
149
  }
150
150
  });
151
151
  const onKeyDown = event => {
152
- const isValidKey = Events.isNumberKey(event) || Events.isTabKey(event) || event.key === "Delete" || event.key === "Backspace";
152
+ const isValidKey = Events.isNumberKey(event) || Events.isTabKey(event) || Events.isEnterKey(event) || event.key === "Delete" || event.key === "Backspace";
153
153
  if (!isValidKey) {
154
154
  event.preventDefault();
155
155
  }
@@ -8,9 +8,9 @@ function highlightPartOfText(text, partToHighlight) {
8
8
  if (indexOfFirstMatch === -1) {
9
9
  return text;
10
10
  }
11
- const precedingText = text.substr(0, indexOfFirstMatch);
12
- const matchingText = text.substr(indexOfFirstMatch, partToHighlight.length);
13
- const followingText = text.substr(indexOfFirstMatch + partToHighlight.length, text.length);
11
+ const precedingText = text.slice(0, indexOfFirstMatch);
12
+ const matchingText = text.slice(indexOfFirstMatch, indexOfFirstMatch + partToHighlight.length);
13
+ const followingText = text.slice(indexOfFirstMatch + partToHighlight.length, text.length);
14
14
  let followingTextNode = followingText;
15
15
  if (followingText.length >= partToHighlight.length) {
16
16
  followingTextNode = highlightPartOfText(followingText, partToHighlight);
@@ -18,7 +18,8 @@ function highlightPartOfText(text, partToHighlight) {
18
18
  const newValue = [/*#__PURE__*/React.createElement("span", {
19
19
  key: "preceding"
20
20
  }, precedingText), /*#__PURE__*/React.createElement(MatchingText, {
21
- key: "match"
21
+ key: "match",
22
+ "data-role": "matching-text"
22
23
  }, matchingText), /*#__PURE__*/React.createElement("span", {
23
24
  key: "following"
24
25
  }, followingTextNode)];
@@ -158,7 +158,7 @@ const NumeralDate = ({
158
158
  }
159
159
  });
160
160
  const onKeyDown = event => {
161
- const isValidKey = _events.default.isNumberKey(event) || _events.default.isTabKey(event) || event.key === "Delete" || event.key === "Backspace";
161
+ const isValidKey = _events.default.isNumberKey(event) || _events.default.isTabKey(event) || _events.default.isEnterKey(event) || event.key === "Delete" || event.key === "Backspace";
162
162
  if (!isValidKey) {
163
163
  event.preventDefault();
164
164
  }
@@ -15,9 +15,9 @@ function highlightPartOfText(text, partToHighlight) {
15
15
  if (indexOfFirstMatch === -1) {
16
16
  return text;
17
17
  }
18
- const precedingText = text.substr(0, indexOfFirstMatch);
19
- const matchingText = text.substr(indexOfFirstMatch, partToHighlight.length);
20
- const followingText = text.substr(indexOfFirstMatch + partToHighlight.length, text.length);
18
+ const precedingText = text.slice(0, indexOfFirstMatch);
19
+ const matchingText = text.slice(indexOfFirstMatch, indexOfFirstMatch + partToHighlight.length);
20
+ const followingText = text.slice(indexOfFirstMatch + partToHighlight.length, text.length);
21
21
  let followingTextNode = followingText;
22
22
  if (followingText.length >= partToHighlight.length) {
23
23
  followingTextNode = highlightPartOfText(followingText, partToHighlight);
@@ -25,7 +25,8 @@ function highlightPartOfText(text, partToHighlight) {
25
25
  const newValue = [/*#__PURE__*/_react.default.createElement("span", {
26
26
  key: "preceding"
27
27
  }, precedingText), /*#__PURE__*/_react.default.createElement(_matchingText.default, {
28
- key: "match"
28
+ key: "match",
29
+ "data-role": "matching-text"
29
30
  }, matchingText), /*#__PURE__*/_react.default.createElement("span", {
30
31
  key: "following"
31
32
  }, followingTextNode)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "141.0.5",
3
+ "version": "141.0.6",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",