carbon-react 104.26.0 → 104.26.1

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.
@@ -63,10 +63,12 @@ const Search = ({
63
63
  const [searchValue, setSearchValue] = (0, _react.useState)(initialValue);
64
64
  const [isFocused, setIsFocused] = (0, _react.useState)(false);
65
65
  const [searchIsActive, setSearchIsActive] = (0, _react.useState)(initialValue.length >= threshold);
66
+ (0, _react.useEffect)(() => {
67
+ setSearchIsActive(!isControlled ? searchValue.length >= threshold : value.length >= threshold);
68
+ }, [isControlled, searchValue, threshold, value]);
66
69
  const [iconType, iconTabIndex] = (0, _react.useMemo)(() => {
67
70
  const isSearchValueEmpty = !isControlled ? searchValue.length === 0 : value.length === 0;
68
71
  const isFocusedOrActive = isFocused || searchIsActive || (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === document.activeElement;
69
- setSearchIsActive(!isControlled ? searchValue.length >= threshold : value.length >= threshold);
70
72
 
71
73
  if (!isSearchValueEmpty) {
72
74
  return ["cross", 0];
@@ -89,8 +91,12 @@ const Search = ({
89
91
  }
90
92
  };
91
93
 
92
- const handleOnFocus = () => {
94
+ const handleFocus = e => {
93
95
  setIsFocused(true);
96
+
97
+ if (onFocus) {
98
+ onFocus(e);
99
+ }
94
100
  };
95
101
 
96
102
  let buttonProps = {};
@@ -130,14 +136,22 @@ const Search = ({
130
136
  ev.preventDefault();
131
137
  };
132
138
 
133
- const handleBlur = () => {
139
+ const handleBlur = e => {
134
140
  setIsFocused(false);
141
+
142
+ if (onBlur) {
143
+ onBlur(e);
144
+ }
135
145
  };
136
146
 
137
147
  const handleKeyDown = ev => {
138
148
  if (_events.default.isAlphabetKey(ev) || _events.default.isNumberKey(ev)) {
139
149
  ev.stopPropagation();
140
150
  }
151
+
152
+ if (onKeyDown) {
153
+ onKeyDown(ev);
154
+ }
141
155
  };
142
156
 
143
157
  const assignInput = input => {
@@ -156,11 +170,6 @@ const Search = ({
156
170
  mb: 0
157
171
  }, (0, _utils.filterStyledSystemMarginProps)(rest), (0, _tags.default)("search", rest), {
158
172
  id: id,
159
- onFocus: handleOnFocus,
160
- onClick: handleOnFocus,
161
- onBlur: handleBlur,
162
- onChange: handleChange,
163
- onKeyDown: handleKeyDown,
164
173
  name: name
165
174
  }, rest), /*#__PURE__*/_react.default.createElement(_textbox.default, {
166
175
  placeholder: placeholder,
@@ -170,10 +179,10 @@ const Search = ({
170
179
  iconOnClick: handleIconClick,
171
180
  iconOnMouseDown: handleMouseDown,
172
181
  "aria-label": ariaLabel,
173
- onFocus: onFocus,
174
- onBlur: onBlur,
175
- onChange: onChange,
176
- onKeyDown: onKeyDown,
182
+ onFocus: handleFocus,
183
+ onBlur: handleBlur,
184
+ onChange: handleChange,
185
+ onKeyDown: handleKeyDown,
177
186
  inputRef: assignInput,
178
187
  tabIndex: tabIndex
179
188
  }), searchButton && /*#__PURE__*/_react.default.createElement(_search.StyledSearchButton, null, Boolean(isFocused || (!isControlled ? searchValue.length : value.length)) && /*#__PURE__*/_react.default.createElement(_button.default, _extends({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "104.26.0",
3
+ "version": "104.26.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {