carbon-react 114.7.1 → 114.8.0

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.
Files changed (77) hide show
  1. package/esm/__internal__/checkable-input/checkable-input.component.d.ts +1 -1
  2. package/esm/__internal__/checkable-input/checkable-input.component.js +5 -10
  3. package/esm/__internal__/checkable-input/hidden-checkable-input.component.d.ts +1 -3
  4. package/esm/__internal__/checkable-input/hidden-checkable-input.component.js +5 -10
  5. package/esm/__internal__/input/input.component.d.ts +2 -2
  6. package/esm/__internal__/input/input.component.js +14 -7
  7. package/esm/__internal__/input-behaviour/useInputBehaviour.d.ts +1 -1
  8. package/esm/components/advanced-color-picker/advanced-color-picker.component.js +1 -3
  9. package/esm/components/checkbox/checkbox.component.d.ts +3 -4
  10. package/esm/components/checkbox/checkbox.component.js +13 -5
  11. package/esm/components/date/date.component.js +32 -17
  12. package/esm/components/date-range/date-range.component.js +20 -2
  13. package/esm/components/date-range/date-range.d.ts +8 -0
  14. package/esm/components/decimal/decimal.component.d.ts +1 -1
  15. package/esm/components/decimal/decimal.component.js +17 -7
  16. package/esm/components/grouped-character/grouped-character.component.d.ts +1 -1
  17. package/esm/components/grouped-character/grouped-character.component.js +15 -5
  18. package/esm/components/menu/menu-item/menu-item.component.js +1 -1
  19. package/esm/components/number/number.component.d.ts +2 -2
  20. package/esm/components/number/number.component.js +15 -5
  21. package/esm/components/numeral-date/numeral-date.component.d.ts +13 -1
  22. package/esm/components/numeral-date/numeral-date.component.js +48 -5
  23. package/esm/components/radio-button/radio-button.component.d.ts +2 -0
  24. package/esm/components/radio-button/radio-button.component.js +10 -1
  25. package/esm/components/search/search.component.d.ts +1 -1
  26. package/esm/components/search/search.component.js +13 -12
  27. package/esm/components/select/filterable-select/filterable-select.component.js +23 -7
  28. package/esm/components/select/multi-select/multi-select.component.js +23 -7
  29. package/esm/components/select/select-textbox/select-textbox.component.js +5 -5
  30. package/esm/components/select/simple-select/simple-select.component.js +23 -7
  31. package/esm/components/simple-color-picker/simple-color/simple-color.style.d.ts +1 -1
  32. package/esm/components/switch/switch.component.d.ts +4 -2
  33. package/esm/components/switch/switch.component.js +14 -5
  34. package/esm/components/textarea/textarea.component.d.ts +1 -1
  35. package/esm/components/textarea/textarea.component.js +37 -14
  36. package/esm/components/textbox/textbox.component.d.ts +1 -1
  37. package/esm/components/textbox/textbox.component.js +13 -5
  38. package/esm/components/tile-select/tile-select.component.js +14 -5
  39. package/lib/__internal__/checkable-input/checkable-input.component.d.ts +1 -1
  40. package/lib/__internal__/checkable-input/checkable-input.component.js +5 -8
  41. package/lib/__internal__/checkable-input/hidden-checkable-input.component.d.ts +1 -3
  42. package/lib/__internal__/checkable-input/hidden-checkable-input.component.js +5 -8
  43. package/lib/__internal__/input/input.component.d.ts +2 -2
  44. package/lib/__internal__/input/input.component.js +13 -6
  45. package/lib/__internal__/input-behaviour/useInputBehaviour.d.ts +1 -1
  46. package/lib/components/advanced-color-picker/advanced-color-picker.component.js +1 -3
  47. package/lib/components/checkbox/checkbox.component.d.ts +3 -4
  48. package/lib/components/checkbox/checkbox.component.js +16 -3
  49. package/lib/components/date/date.component.js +33 -14
  50. package/lib/components/date-range/date-range.component.js +20 -2
  51. package/lib/components/date-range/date-range.d.ts +8 -0
  52. package/lib/components/decimal/decimal.component.d.ts +1 -1
  53. package/lib/components/decimal/decimal.component.js +20 -5
  54. package/lib/components/grouped-character/grouped-character.component.d.ts +1 -1
  55. package/lib/components/grouped-character/grouped-character.component.js +18 -4
  56. package/lib/components/menu/menu-item/menu-item.component.js +1 -1
  57. package/lib/components/number/number.component.d.ts +2 -2
  58. package/lib/components/number/number.component.js +18 -4
  59. package/lib/components/numeral-date/numeral-date.component.d.ts +13 -1
  60. package/lib/components/numeral-date/numeral-date.component.js +48 -5
  61. package/lib/components/radio-button/radio-button.component.d.ts +2 -0
  62. package/lib/components/radio-button/radio-button.component.js +13 -1
  63. package/lib/components/search/search.component.d.ts +1 -1
  64. package/lib/components/search/search.component.js +16 -10
  65. package/lib/components/select/filterable-select/filterable-select.component.js +25 -7
  66. package/lib/components/select/multi-select/multi-select.component.js +25 -7
  67. package/lib/components/select/select-textbox/select-textbox.component.js +5 -3
  68. package/lib/components/select/simple-select/simple-select.component.js +26 -7
  69. package/lib/components/simple-color-picker/simple-color/simple-color.style.d.ts +1 -1
  70. package/lib/components/switch/switch.component.d.ts +4 -2
  71. package/lib/components/switch/switch.component.js +17 -3
  72. package/lib/components/textarea/textarea.component.d.ts +1 -1
  73. package/lib/components/textarea/textarea.component.js +38 -11
  74. package/lib/components/textbox/textbox.component.d.ts +1 -1
  75. package/lib/components/textbox/textbox.component.js +16 -3
  76. package/lib/components/tile-select/tile-select.component.js +17 -4
  77. package/package.json +1 -1
@@ -25,6 +25,8 @@ var _textbox = _interopRequireDefault(require("../textbox"));
25
25
 
26
26
  var _button = _interopRequireDefault(require("../button"));
27
27
 
28
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
29
+
28
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
31
 
30
32
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -33,7 +35,9 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
33
35
 
34
36
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
35
37
 
36
- const Search = ({
38
+ let deprecateInputRefWarnTriggered = false;
39
+
40
+ const Search = /*#__PURE__*/_react.default.forwardRef(({
37
41
  defaultValue,
38
42
  onChange,
39
43
  onClick,
@@ -57,9 +61,16 @@ const Search = ({
57
61
  info,
58
62
  tooltipPosition,
59
63
  ...rest
60
- }) => {
64
+ }, ref) => {
61
65
  const isControlled = value !== undefined;
62
66
  const initialValue = isControlled ? value : defaultValue;
67
+
68
+ if (!deprecateInputRefWarnTriggered && inputRef) {
69
+ deprecateInputRefWarnTriggered = true;
70
+
71
+ _logger.default.deprecate("The `inputRef` prop in `Search` component is deprecated and will soon be removed. Please use `ref` instead.");
72
+ }
73
+
63
74
  !(typeof initialValue === "string") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "This component has no initial value") : (0, _invariant.default)(false) : void 0;
64
75
  !(threshold === undefined || typeof threshold === "number" && threshold > 0) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Threshold must be a positive number") : (0, _invariant.default)(false) : void 0;
65
76
  const [searchValue, setSearchValue] = (0, _react.useState)(initialValue);
@@ -155,12 +166,6 @@ const Search = ({
155
166
  }
156
167
  };
157
168
 
158
- const assignInput = input => {
159
- if (inputRef) {
160
- inputRef.current = input === null || input === void 0 ? void 0 : input.current;
161
- }
162
- };
163
-
164
169
  const isSearchTyped = isFocused || (!isControlled ? !!searchValue.length : !!value.length);
165
170
  return /*#__PURE__*/_react.default.createElement(_search.default, _extends({
166
171
  isFocused: isFocused,
@@ -186,7 +191,7 @@ const Search = ({
186
191
  onBlur: handleBlur,
187
192
  onChange: handleChange,
188
193
  onKeyDown: handleKeyDown,
189
- inputRef: assignInput,
194
+ ref: ref || inputRef,
190
195
  tabIndex: tabIndex,
191
196
  error: error,
192
197
  warning: warning,
@@ -198,7 +203,7 @@ const Search = ({
198
203
  }, buttonProps), /*#__PURE__*/_react.default.createElement(_searchButton.StyledButtonIcon, null, /*#__PURE__*/_react.default.createElement(_icon.default, {
199
204
  type: "search"
200
205
  })))));
201
- };
206
+ });
202
207
 
203
208
  exports.Search = Search;
204
209
  Search.propTypes = {
@@ -381,5 +386,6 @@ Search.propTypes = {
381
386
  "variant": _propTypes.default.oneOf(["dark", "default"]),
382
387
  "warning": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool])
383
388
  };
389
+ Search.displayName = "Search";
384
390
  var _default = Search;
385
391
  exports.default = _default;
@@ -27,6 +27,8 @@ var _isExpectedOption = _interopRequireDefault(require("../utils/is-expected-opt
27
27
 
28
28
  var _isNavigationKey = _interopRequireDefault(require("../utils/is-navigation-key"));
29
29
 
30
+ var _logger = _interopRequireDefault(require("../../../__internal__/utils/logger"));
31
+
30
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
33
 
32
34
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -35,6 +37,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
35
37
 
36
38
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
37
39
 
40
+ let deprecateInputRefWarnTriggered = false;
38
41
  const FilterableSelectList = (0, _withFilter.default)(_selectList.default);
39
42
 
40
43
  const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
@@ -69,8 +72,9 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
69
72
  tooltipPosition,
70
73
  listPlacement = "bottom",
71
74
  flipEnabled = true,
75
+ inputRef,
72
76
  ...textboxProps
73
- }, inputRef) => {
77
+ }, ref) => {
74
78
  const [activeDescendantId, setActiveDescendantId] = (0, _react.useState)();
75
79
  const selectListId = (0, _react.useRef)((0, _guid.default)());
76
80
  const labelId = (0, _react.useRef)(label ? (0, _guid.default)() : undefined);
@@ -86,6 +90,13 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
86
90
  const [selectedValue, setSelectedValue] = (0, _react.useState)(value || defaultValue || "");
87
91
  const [highlightedValue, setHighlightedValue] = (0, _react.useState)("");
88
92
  const [filterText, setFilterText] = (0, _react.useState)("");
93
+
94
+ if (!deprecateInputRefWarnTriggered && inputRef) {
95
+ deprecateInputRefWarnTriggered = true;
96
+
97
+ _logger.default.deprecate("The `inputRef` prop in `FilterableSelect` component is deprecated and will soon be removed. Please use `ref` instead.");
98
+ }
99
+
89
100
  const createCustomEvent = (0, _react.useCallback)(newValue => {
90
101
  const customEvent = {
91
102
  target: { ...(name && {
@@ -383,13 +394,19 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
383
394
  onListAction();
384
395
  }
385
396
 
386
- function assignInput(input) {
387
- setTextboxRef(input.current);
397
+ const assignInput = (0, _react.useCallback)(element => {
398
+ setTextboxRef(element);
388
399
 
389
- if (inputRef) {
390
- inputRef.current = input.current;
400
+ if (inputRef || !ref) {
401
+ return;
391
402
  }
392
- }
403
+
404
+ if (typeof ref === "function") {
405
+ ref(element);
406
+ } else {
407
+ ref.current = element;
408
+ }
409
+ }, [ref, inputRef]);
393
410
 
394
411
  function getTextboxProps() {
395
412
  return {
@@ -398,7 +415,7 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
398
415
  label,
399
416
  disabled,
400
417
  readOnly,
401
- inputRef: assignInput,
418
+ ref: assignInput,
402
419
  selectedValue,
403
420
  formattedValue: textValue,
404
421
  onClick: handleTextboxClick,
@@ -410,6 +427,7 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
410
427
  onChange: handleTextboxChange,
411
428
  onMouseDown: handleTextboxMouseDown,
412
429
  tooltipPosition,
430
+ inputRef,
413
431
  ...(0, _utils.filterOutStyledSystemSpacingProps)(textboxProps)
414
432
  };
415
433
  }
@@ -31,6 +31,8 @@ var _isExpectedValue = _interopRequireDefault(require("../utils/is-expected-valu
31
31
 
32
32
  var _isNavigationKey = _interopRequireDefault(require("../utils/is-navigation-key"));
33
33
 
34
+ var _logger = _interopRequireDefault(require("../../../__internal__/utils/logger"));
35
+
34
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
37
 
36
38
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -39,6 +41,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
39
41
 
40
42
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
41
43
 
44
+ let deprecateInputRefWarnTriggered = false;
42
45
  const FilterableSelectList = (0, _withFilter.default)(_selectList.default);
43
46
 
44
47
  const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
@@ -72,8 +75,9 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
72
75
  listMaxHeight,
73
76
  flipEnabled = true,
74
77
  wrapPillText = true,
78
+ inputRef,
75
79
  ...textboxProps
76
- }, inputRef) => {
80
+ }, ref) => {
77
81
  const [activeDescendantId, setActiveDescendantId] = (0, _react.useState)();
78
82
  const selectListId = (0, _react.useRef)((0, _guid.default)());
79
83
  const accessibilityLabelId = (0, _react.useRef)((0, _guid.default)());
@@ -93,6 +97,13 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
93
97
  const [filterText, setFilterText] = (0, _react.useState)("");
94
98
  const [placeholderOverride, setPlaceholderOverride] = (0, _react.useState)();
95
99
  const actualValue = isControlled.current ? value : selectedValue;
100
+
101
+ if (!deprecateInputRefWarnTriggered && inputRef) {
102
+ deprecateInputRefWarnTriggered = true;
103
+
104
+ _logger.default.deprecate("The `inputRef` prop in `MultiSelect` component is deprecated and will soon be removed. Please use `ref` instead.");
105
+ }
106
+
96
107
  const setOpen = (0, _react.useCallback)(() => {
97
108
  setOpenState(isAlreadyOpen => {
98
109
  if (!isAlreadyOpen && onOpen) {
@@ -402,13 +413,19 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
402
413
  });
403
414
  }
404
415
 
405
- function assignInput(input) {
406
- setTextboxRef(input.current);
416
+ const assignInput = (0, _react.useCallback)(element => {
417
+ setTextboxRef(element);
407
418
 
408
- if (inputRef) {
409
- inputRef.current = input.current;
419
+ if (inputRef || !ref) {
420
+ return;
410
421
  }
411
- }
422
+
423
+ if (typeof ref === "function") {
424
+ ref(element);
425
+ } else {
426
+ ref.current = element;
427
+ }
428
+ }, [ref, inputRef]);
412
429
 
413
430
  function getTextboxProps() {
414
431
  return {
@@ -418,7 +435,7 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
418
435
  readOnly,
419
436
  placeholder: placeholderOverride,
420
437
  leftChildren: mapValuesToPills,
421
- inputRef: assignInput,
438
+ ref: assignInput,
422
439
  formattedValue: textValue,
423
440
  selectedValue: actualValue,
424
441
  onClick: handleTextboxClick,
@@ -431,6 +448,7 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
431
448
  onChange: handleTextboxChange,
432
449
  tooltipPosition,
433
450
  size,
451
+ inputRef,
434
452
  ...(0, _utils.filterOutStyledSystemSpacingProps)(textboxProps)
435
453
  };
436
454
  }
@@ -44,7 +44,7 @@ const floatingMiddleware = [(0, _dom.offset)(({
44
44
 
45
45
  })];
46
46
 
47
- const SelectTextbox = ({
47
+ const SelectTextbox = /*#__PURE__*/_react.default.forwardRef(({
48
48
  accessibilityLabelId,
49
49
  labelId,
50
50
  "aria-controls": ariaControls,
@@ -65,7 +65,7 @@ const SelectTextbox = ({
65
65
  transparent,
66
66
  activeDescendantId,
67
67
  ...restProps
68
- }) => {
68
+ }, ref) => {
69
69
  const reference = (0, _react.useMemo)(() => ({
70
70
  current: textboxRef === null || textboxRef === void 0 ? void 0 : textboxRef.parentElement.parentElement
71
71
  }), [textboxRef]);
@@ -117,6 +117,7 @@ const SelectTextbox = ({
117
117
  onBlur: handleTextboxBlur,
118
118
  labelId,
119
119
  type: "text",
120
+ ref,
120
121
  ...restProps
121
122
  };
122
123
  }
@@ -167,7 +168,7 @@ const SelectTextbox = ({
167
168
  value: selectedValue,
168
169
  placeholder: hasTextCursor ? placeholder || l.select.placeholder() : undefined
169
170
  }, getInputAriaAttributes(), getTextboxProps()), !hasTextCursor && renderSelectText());
170
- };
171
+ });
171
172
 
172
173
  const formInputPropTypes = {
173
174
  /**
@@ -284,5 +285,6 @@ SelectTextbox.propTypes = { ...formInputPropTypes,
284
285
  * Value of the Select Input */
285
286
  selectedValue: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object, _propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.arrayOf(_propTypes.default.object)])
286
287
  };
288
+ SelectTextbox.displayName = "SelectTextbox";
287
289
  var _default = SelectTextbox;
288
290
  exports.default = _default;
@@ -29,6 +29,8 @@ var _isExpectedOption = _interopRequireDefault(require("../utils/is-expected-opt
29
29
 
30
30
  var _isNavigationKey = _interopRequireDefault(require("../utils/is-navigation-key"));
31
31
 
32
+ var _logger = _interopRequireDefault(require("../../../__internal__/utils/logger"));
33
+
32
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
35
 
34
36
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -37,6 +39,8 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
37
39
 
38
40
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
39
41
 
42
+ let deprecateInputRefWarnTriggered = false;
43
+
40
44
  const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
41
45
  value,
42
46
  defaultValue,
@@ -65,8 +69,9 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
65
69
  "data-role": dataRole,
66
70
  listPlacement = "bottom",
67
71
  flipEnabled = true,
72
+ inputRef,
68
73
  ...props
69
- }, inputRef) => {
74
+ }, ref) => {
70
75
  const selectListId = (0, _react.useRef)((0, _guid.default)());
71
76
  const labelId = (0, _react.useRef)((0, _guid.default)());
72
77
  const containerRef = (0, _react.useRef)();
@@ -82,6 +87,13 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
82
87
  const [activeDescendantId, setActiveDescendantId] = (0, _react.useState)();
83
88
  const [textValue, setTextValue] = (0, _react.useState)("");
84
89
  const [selectedValue, setSelectedValue] = (0, _react.useState)(value || defaultValue || "");
90
+
91
+ if (!deprecateInputRefWarnTriggered && inputRef) {
92
+ deprecateInputRefWarnTriggered = true;
93
+
94
+ _logger.default.deprecate("The `inputRef` prop in `Select` component is deprecated and will soon be removed. Please use `ref` instead.");
95
+ }
96
+
85
97
  const childOptions = (0, _react.useMemo)(() => _react.default.Children.toArray(children), [children]);
86
98
  const createCustomEvent = (0, _react.useCallback)(newValue => {
87
99
  const customEvent = {
@@ -312,13 +324,19 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
312
324
  setOpenState(false);
313
325
  }
314
326
 
315
- function assignInput(input) {
316
- setTextboxRef(input.current);
327
+ const assignInput = (0, _react.useCallback)(element => {
328
+ setTextboxRef(element);
317
329
 
318
- if (inputRef) {
319
- inputRef.current = input.current;
330
+ if (inputRef || !ref) {
331
+ return;
320
332
  }
321
- }
333
+
334
+ if (typeof ref === "function") {
335
+ ref(element);
336
+ } else {
337
+ ref.current = element;
338
+ }
339
+ }, [ref, inputRef]);
322
340
 
323
341
  function getTextboxProps() {
324
342
  return {
@@ -326,7 +344,7 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
326
344
  name,
327
345
  disabled,
328
346
  readOnly,
329
- inputRef: assignInput,
347
+ ref: assignInput,
330
348
  selectedValue,
331
349
  formattedValue: textValue,
332
350
  onClick: handleTextboxClick,
@@ -337,6 +355,7 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
337
355
  onBlur: handleTextboxBlur,
338
356
  tooltipPosition,
339
357
  transparent,
358
+ inputRef,
340
359
  ...(0, _utils.filterOutStyledSystemSpacingProps)(props)
341
360
  };
342
361
  }
@@ -3,7 +3,7 @@ export declare const StyledSimpleColor: import("styled-components").StyledCompon
3
3
  export declare const StyledColorSampleBox: import("styled-components").StyledComponent<"div", any, {
4
4
  color: string;
5
5
  }, never>;
6
- export declare const StyledSimpleColorInput: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../../__internal__/input").InputProps & import("react").RefAttributes<HTMLInputElement>>, any, {}, never>;
6
+ export declare const StyledSimpleColorInput: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../../__internal__/input").InputProps & import("react").RefAttributes<HTMLInputElement | HTMLTextAreaElement>>, any, {}, never>;
7
7
  export declare const StyledTickIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {
8
8
  color: string;
9
9
  }, never>;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { MarginProps } from "styled-system";
3
3
  import { CommonCheckableInputProps } from "../../__internal__/checkable-input";
4
4
  export interface SwitchProps extends CommonCheckableInputProps, MarginProps {
@@ -26,6 +26,8 @@ export interface SwitchProps extends CommonCheckableInputProps, MarginProps {
26
26
  tooltipPosition?: "top" | "bottom" | "left" | "right";
27
27
  /** Aria label for rendered help component */
28
28
  helpAriaLabel?: string;
29
+ /** A callback to retrieve the input reference (deprecated) */
30
+ inputRef?: React.Ref<HTMLInputElement>;
29
31
  }
30
- export declare const Switch: ({ autoFocus, id, label, onChange, onBlur, onFocus, value, checked, defaultChecked, disabled, loading, reverse, validationOnLabel, labelInline, labelSpacing, labelHelp, fieldHelpInline, size, name, adaptiveLabelBreakpoint, tooltipPosition, error, warning, info, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, ...rest }: SwitchProps) => JSX.Element;
32
+ export declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLInputElement>>;
31
33
  export default Switch;
@@ -21,13 +21,17 @@ var _tooltipProvider = require("../../__internal__/tooltip-provider");
21
21
 
22
22
  var _utils = require("../../style/utils");
23
23
 
24
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
25
+
24
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
27
 
26
28
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
27
29
 
28
30
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
31
 
30
- const Switch = ({
32
+ let deprecateInputRefWarnTriggered = false;
33
+
34
+ const Switch = /*#__PURE__*/_react.default.forwardRef(({
31
35
  autoFocus,
32
36
  id,
33
37
  label,
@@ -56,10 +60,18 @@ const Switch = ({
56
60
  "data-element": dataElement,
57
61
  "data-role": dataRole,
58
62
  helpAriaLabel,
63
+ inputRef,
59
64
  ...rest
60
- }) => {
65
+ }, ref) => {
61
66
  const isControlled = checked !== undefined;
62
67
  const [checkedInternal, setCheckedInternal] = (0, _react.useState)(defaultChecked || false);
68
+
69
+ if (!deprecateInputRefWarnTriggered && inputRef) {
70
+ deprecateInputRefWarnTriggered = true;
71
+
72
+ _logger.default.deprecate("The `inputRef` prop in `Switch` component is deprecated and will soon be removed. Please use `ref` instead.");
73
+ }
74
+
63
75
  const onChangeInternal = (0, _react.useCallback)(e => {
64
76
  setCheckedInternal(e.target.checked);
65
77
  onChange === null || onChange === void 0 ? void 0 : onChange(e);
@@ -118,13 +130,14 @@ const Switch = ({
118
130
  reverse: !reverse,
119
131
  // switched to preserve backward compatibility
120
132
  validationOnLabel: shouldValidationBeOnLabel && !disabled,
133
+ ref: ref || inputRef,
121
134
  ...rest
122
135
  };
123
136
  return /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
124
137
  helpAriaLabel: helpAriaLabel,
125
138
  tooltipPosition: tooltipPosition
126
139
  }, /*#__PURE__*/_react.default.createElement(_switch.default, switchStyleProps, /*#__PURE__*/_react.default.createElement(_checkableInput.default, inputProps, /*#__PURE__*/_react.default.createElement(_switchSlider.default, switchSliderProps))));
127
- };
140
+ });
128
141
 
129
142
  exports.Switch = Switch;
130
143
  Switch.propTypes = {
@@ -648,5 +661,6 @@ Switch.propTypes = {
648
661
  "warning": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
649
662
  "width": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
650
663
  };
664
+ Switch.displayName = "Switch";
651
665
  var _default = Switch;
652
666
  exports.default = _default;
@@ -94,6 +94,6 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
94
94
  Pass true boolean to only display orange border */
95
95
  warning?: boolean | string;
96
96
  }
97
- export declare const Textarea: ({ autoFocus, fieldHelp, label, size, children, characterLimit, enforceCharacterLimit, warnOverLimit, onChange, disabled, labelInline, labelAlign, labelHelp, labelSpacing, inputIcon, id: idProp, error, warning, info, name, readOnly, placeholder, expandable, rows, cols, validationOnLabel, adaptiveLabelBreakpoint, inputWidth, maxWidth, labelWidth, tooltipPosition, value, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, ...props }: TextareaProps) => JSX.Element;
97
+ export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
98
98
  export { Textarea as OriginalTextarea };
99
99
  export default Textarea;
@@ -39,6 +39,8 @@ var _validationMessage = _interopRequireDefault(require("../../__internal__/vali
39
39
 
40
40
  var _box = _interopRequireDefault(require("../box"));
41
41
 
42
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
43
+
42
44
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
45
 
44
46
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -47,7 +49,9 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
47
49
 
48
50
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
49
51
 
50
- const Textarea = ({
52
+ let deprecateInputRefWarnTriggered = false;
53
+
54
+ const Textarea = /*#__PURE__*/_react.default.forwardRef(({
51
55
  autoFocus,
52
56
  fieldHelp,
53
57
  label,
@@ -84,8 +88,9 @@ const Textarea = ({
84
88
  "data-element": dataElement,
85
89
  "data-role": dataRole,
86
90
  helpAriaLabel,
91
+ inputRef,
87
92
  ...props
88
- }) => {
93
+ }, ref) => {
89
94
  const {
90
95
  validationRedesignOptIn
91
96
  } = (0, _react.useContext)(_carbonProvider.NewValidationContext);
@@ -95,11 +100,31 @@ const Textarea = ({
95
100
  const {
96
101
  current: id
97
102
  } = (0, _react.useRef)(idProp || (0, _guid.default)());
98
- const inputRef = (0, _react.useRef)(null);
103
+ const internalRef = (0, _react.useRef)(null);
104
+ const callbackRef = (0, _react.useCallback)(inputElement => {
105
+ internalRef.current = inputElement;
106
+
107
+ if (!ref) {
108
+ return;
109
+ }
110
+
111
+ if ("current" in ref) {
112
+ ref.current = inputElement;
113
+ } else {
114
+ ref(inputElement);
115
+ }
116
+ }, [ref]);
117
+
118
+ if (!deprecateInputRefWarnTriggered && inputRef) {
119
+ deprecateInputRefWarnTriggered = true;
120
+
121
+ _logger.default.deprecate("The `inputRef` prop in `Textarea` component is deprecated and will soon be removed. Please use `ref` instead.");
122
+ }
123
+
99
124
  const minHeight = (0, _react.useRef)(_textarea.MIN_HEIGHT);
100
125
 
101
126
  const expandTextarea = () => {
102
- const textarea = inputRef.current;
127
+ const textarea = internalRef.current;
103
128
 
104
129
  if (textarea !== null && textarea !== void 0 && textarea.scrollHeight && (textarea === null || textarea === void 0 ? void 0 : textarea.scrollHeight) > minHeight.current) {
105
130
  textarea.style.height = "0px"; // Set the height so all content is shown
@@ -126,9 +151,9 @@ const Textarea = ({
126
151
  typeof characterLimit === "string" ? parseInt(characterLimit, 10) : characterLimit, warnOverLimit, enforceCharacterLimit);
127
152
  (0, _react.useEffect)(() => {
128
153
  if (rows) {
129
- var _inputRef$current;
154
+ var _internalRef$current;
130
155
 
131
- minHeight.current = (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.scrollHeight) || 0;
156
+ minHeight.current = (internalRef === null || internalRef === void 0 ? void 0 : (_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.scrollHeight) || 0;
132
157
  }
133
158
  }, [rows]);
134
159
  (0, _react.useEffect)(() => {
@@ -138,10 +163,10 @@ const Textarea = ({
138
163
  });
139
164
  (0, _react.useEffect)(() => {
140
165
  if (expandable) {
141
- var _inputRef$current2;
166
+ var _internalRef$current2;
142
167
 
143
168
  window.addEventListener("resize", expandTextarea);
144
- minHeight.current = (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.clientHeight) || 0;
169
+ minHeight.current = (internalRef === null || internalRef === void 0 ? void 0 : (_internalRef$current2 = internalRef.current) === null || _internalRef$current2 === void 0 ? void 0 : _internalRef$current2.clientHeight) || 0;
145
170
  }
146
171
 
147
172
  return () => {
@@ -168,7 +193,7 @@ const Textarea = ({
168
193
  autoFocus: autoFocus,
169
194
  name: name,
170
195
  value: value,
171
- ref: inputRef,
196
+ ref: callbackRef,
172
197
  maxLength: maxLength,
173
198
  onChange: onChange,
174
199
  disabled: disabled,
@@ -177,7 +202,8 @@ const Textarea = ({
177
202
  rows: rows,
178
203
  cols: cols,
179
204
  id: id,
180
- as: "textarea"
205
+ as: "textarea",
206
+ inputRef: inputRef
181
207
  }, props)), children, /*#__PURE__*/_react.default.createElement(_inputIconToggle.default, {
182
208
  disabled: disabled,
183
209
  readOnly: readOnly,
@@ -226,7 +252,7 @@ const Textarea = ({
226
252
  }), (error || warning) && /*#__PURE__*/_react.default.createElement(_textbox.ErrorBorder, {
227
253
  warning: !!(!error && warning)
228
254
  }), input) : input), characterCount)));
229
- };
255
+ });
230
256
 
231
257
  exports.OriginalTextarea = exports.Textarea = Textarea;
232
258
  Textarea.propTypes = {
@@ -755,5 +781,6 @@ Textarea.propTypes = {
755
781
  "warnOverLimit": _propTypes.default.bool,
756
782
  "width": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
757
783
  };
784
+ Textarea.displayName = "Textarea";
758
785
  var _default = Textarea;
759
786
  exports.default = _default;
@@ -93,5 +93,5 @@ export interface TextboxProps extends CommonTextboxProps {
93
93
  /** Whether to display the character count message in red */
94
94
  warnOverLimit?: boolean;
95
95
  }
96
- export declare const Textbox: ({ align, autoFocus, children, disabled, inputIcon, leftChildren, labelId: externalLabelId, label, labelAlign, labelHelp, labelInline, labelSpacing, id, formattedValue, fieldHelp, error, warning, info, name, reverse, size, value, readOnly, placeholder, inputRef, onBlur, onClick, onFocus, onChange, onMouseDown, onChangeDeferred, deferTimeout, isOptional, iconOnClick, iconOnMouseDown, iconTabIndex, validationOnLabel, labelWidth, inputWidth, maxWidth, prefix, adaptiveLabelBreakpoint, required, positionedChildren, tooltipPosition, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, enforceCharacterLimit, characterLimit, warnOverLimit, helpAriaLabel, ...props }: TextboxProps) => JSX.Element;
96
+ export declare const Textbox: React.ForwardRefExoticComponent<TextboxProps & React.RefAttributes<HTMLInputElement>>;
97
97
  export default Textbox;
@@ -39,6 +39,8 @@ var _numeralDateContext = _interopRequireDefault(require("../numeral-date/numera
39
39
 
40
40
  var _box = _interopRequireDefault(require("../box"));
41
41
 
42
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
43
+
42
44
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
45
 
44
46
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -47,7 +49,9 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
47
49
 
48
50
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
49
51
 
50
- const Textbox = ({
52
+ let deprecateInputRefWarnTriggered = false;
53
+
54
+ const Textbox = /*#__PURE__*/_react.default.forwardRef(({
51
55
  align = "left",
52
56
  autoFocus,
53
57
  children,
@@ -101,7 +105,7 @@ const Textbox = ({
101
105
  warnOverLimit = false,
102
106
  helpAriaLabel,
103
107
  ...props
104
- }) => {
108
+ }, ref) => {
105
109
  const characterCountValue = typeof value === "string" ? value : "";
106
110
  const [maxLength, characterCount] = (0, _useCharacterCount.default)(characterCountValue, // TODO: Can be removed after the characterLimit type is changed to number
107
111
  typeof characterLimit === "string" ? parseInt(characterLimit, 10) : characterLimit, warnOverLimit, enforceCharacterLimit);
@@ -115,6 +119,13 @@ const Textbox = ({
115
119
  const computeLabelPropValues = prop => validationRedesignOptIn ? undefined : prop;
116
120
 
117
121
  const [uniqueId, uniqueName] = (0, _useUniqueId.default)(id, name);
122
+
123
+ if (!deprecateInputRefWarnTriggered && inputRef) {
124
+ deprecateInputRefWarnTriggered = true;
125
+
126
+ _logger.default.deprecate("The `inputRef` prop in `Textbox` component is deprecated and will soon be removed. Please use `ref` instead.");
127
+ }
128
+
118
129
  const {
119
130
  labelId: internalLabelId,
120
131
  validationIconId,
@@ -158,6 +169,7 @@ const Textbox = ({
158
169
  disabled: disabled,
159
170
  id: uniqueId,
160
171
  inputRef: inputRef,
172
+ ref: ref,
161
173
  name: uniqueName,
162
174
  onBlur: onBlur,
163
175
  onChange: onChange,
@@ -221,7 +233,7 @@ const Textbox = ({
221
233
  }), !disableErrorBorder && (error || warning) && /*#__PURE__*/_react.default.createElement(_textbox.ErrorBorder, {
222
234
  warning: !!(!error && warning)
223
235
  }), input) : input), characterCount));
224
- };
236
+ });
225
237
 
226
238
  exports.Textbox = Textbox;
227
239
  Textbox.propTypes = {
@@ -757,5 +769,6 @@ Textbox.propTypes = {
757
769
  "warnOverLimit": _propTypes.default.bool,
758
770
  "width": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
759
771
  };
772
+ Textbox.displayName = "Textbox";
760
773
  var _default = Textbox;
761
774
  exports.default = _default;