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.
- package/esm/__internal__/checkable-input/checkable-input.component.d.ts +1 -1
- package/esm/__internal__/checkable-input/checkable-input.component.js +5 -10
- package/esm/__internal__/checkable-input/hidden-checkable-input.component.d.ts +1 -3
- package/esm/__internal__/checkable-input/hidden-checkable-input.component.js +5 -10
- package/esm/__internal__/input/input.component.d.ts +2 -2
- package/esm/__internal__/input/input.component.js +14 -7
- package/esm/__internal__/input-behaviour/useInputBehaviour.d.ts +1 -1
- package/esm/components/advanced-color-picker/advanced-color-picker.component.js +1 -3
- package/esm/components/checkbox/checkbox.component.d.ts +3 -4
- package/esm/components/checkbox/checkbox.component.js +13 -5
- package/esm/components/date/date.component.js +32 -17
- package/esm/components/date-range/date-range.component.js +20 -2
- package/esm/components/date-range/date-range.d.ts +8 -0
- package/esm/components/decimal/decimal.component.d.ts +1 -1
- package/esm/components/decimal/decimal.component.js +17 -7
- package/esm/components/grouped-character/grouped-character.component.d.ts +1 -1
- package/esm/components/grouped-character/grouped-character.component.js +15 -5
- package/esm/components/menu/menu-item/menu-item.component.js +1 -1
- package/esm/components/number/number.component.d.ts +2 -2
- package/esm/components/number/number.component.js +15 -5
- package/esm/components/numeral-date/numeral-date.component.d.ts +13 -1
- package/esm/components/numeral-date/numeral-date.component.js +48 -5
- package/esm/components/radio-button/radio-button.component.d.ts +2 -0
- package/esm/components/radio-button/radio-button.component.js +10 -1
- package/esm/components/search/search.component.d.ts +1 -1
- package/esm/components/search/search.component.js +13 -12
- package/esm/components/select/filterable-select/filterable-select.component.js +23 -7
- package/esm/components/select/multi-select/multi-select.component.js +23 -7
- package/esm/components/select/select-textbox/select-textbox.component.js +5 -5
- package/esm/components/select/simple-select/simple-select.component.js +23 -7
- package/esm/components/simple-color-picker/simple-color/simple-color.style.d.ts +1 -1
- package/esm/components/switch/switch.component.d.ts +4 -2
- package/esm/components/switch/switch.component.js +14 -5
- package/esm/components/textarea/textarea.component.d.ts +1 -1
- package/esm/components/textarea/textarea.component.js +37 -14
- package/esm/components/textbox/textbox.component.d.ts +1 -1
- package/esm/components/textbox/textbox.component.js +13 -5
- package/esm/components/tile-select/tile-select.component.js +14 -5
- package/lib/__internal__/checkable-input/checkable-input.component.d.ts +1 -1
- package/lib/__internal__/checkable-input/checkable-input.component.js +5 -8
- package/lib/__internal__/checkable-input/hidden-checkable-input.component.d.ts +1 -3
- package/lib/__internal__/checkable-input/hidden-checkable-input.component.js +5 -8
- package/lib/__internal__/input/input.component.d.ts +2 -2
- package/lib/__internal__/input/input.component.js +13 -6
- package/lib/__internal__/input-behaviour/useInputBehaviour.d.ts +1 -1
- package/lib/components/advanced-color-picker/advanced-color-picker.component.js +1 -3
- package/lib/components/checkbox/checkbox.component.d.ts +3 -4
- package/lib/components/checkbox/checkbox.component.js +16 -3
- package/lib/components/date/date.component.js +33 -14
- package/lib/components/date-range/date-range.component.js +20 -2
- package/lib/components/date-range/date-range.d.ts +8 -0
- package/lib/components/decimal/decimal.component.d.ts +1 -1
- package/lib/components/decimal/decimal.component.js +20 -5
- package/lib/components/grouped-character/grouped-character.component.d.ts +1 -1
- package/lib/components/grouped-character/grouped-character.component.js +18 -4
- package/lib/components/menu/menu-item/menu-item.component.js +1 -1
- package/lib/components/number/number.component.d.ts +2 -2
- package/lib/components/number/number.component.js +18 -4
- package/lib/components/numeral-date/numeral-date.component.d.ts +13 -1
- package/lib/components/numeral-date/numeral-date.component.js +48 -5
- package/lib/components/radio-button/radio-button.component.d.ts +2 -0
- package/lib/components/radio-button/radio-button.component.js +13 -1
- package/lib/components/search/search.component.d.ts +1 -1
- package/lib/components/search/search.component.js +16 -10
- package/lib/components/select/filterable-select/filterable-select.component.js +25 -7
- package/lib/components/select/multi-select/multi-select.component.js +25 -7
- package/lib/components/select/select-textbox/select-textbox.component.js +5 -3
- package/lib/components/select/simple-select/simple-select.component.js +26 -7
- package/lib/components/simple-color-picker/simple-color/simple-color.style.d.ts +1 -1
- package/lib/components/switch/switch.component.d.ts +4 -2
- package/lib/components/switch/switch.component.js +17 -3
- package/lib/components/textarea/textarea.component.d.ts +1 -1
- package/lib/components/textarea/textarea.component.js +38 -11
- package/lib/components/textbox/textbox.component.d.ts +1 -1
- package/lib/components/textbox/textbox.component.js +16 -3
- package/lib/components/tile-select/tile-select.component.js +17 -4
- package/package.json +1 -1
|
@@ -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:
|
|
97
|
+
export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
98
98
|
export { Textarea as OriginalTextarea };
|
|
99
99
|
export default Textarea;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
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); }
|
|
2
2
|
|
|
3
|
-
import React, { useRef, useEffect, useContext } from "react";
|
|
3
|
+
import React, { useRef, useEffect, useContext, useCallback } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import { InputPresentation } from "../../__internal__/input";
|
|
6
6
|
import FormField from "../../__internal__/form-field";
|
|
@@ -16,9 +16,11 @@ import useInputAccessibility from "../../hooks/__internal__/useInputAccessibilit
|
|
|
16
16
|
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
17
17
|
import { ErrorBorder, StyledHintText } from "../textbox/textbox.style";
|
|
18
18
|
import ValidationMessage from "../../__internal__/validation-message";
|
|
19
|
-
import Box from "../box";
|
|
19
|
+
import Box from "../box";
|
|
20
|
+
import Logger from "../../__internal__/utils/logger"; // TODO: Change characterLimit type to number - batch with other breaking changes
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
let deprecateInputRefWarnTriggered = false;
|
|
23
|
+
const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
22
24
|
autoFocus,
|
|
23
25
|
fieldHelp,
|
|
24
26
|
label,
|
|
@@ -55,8 +57,9 @@ const Textarea = ({
|
|
|
55
57
|
"data-element": dataElement,
|
|
56
58
|
"data-role": dataRole,
|
|
57
59
|
helpAriaLabel,
|
|
60
|
+
inputRef,
|
|
58
61
|
...props
|
|
59
|
-
}) => {
|
|
62
|
+
}, ref) => {
|
|
60
63
|
const {
|
|
61
64
|
validationRedesignOptIn
|
|
62
65
|
} = useContext(NewValidationContext);
|
|
@@ -66,11 +69,30 @@ const Textarea = ({
|
|
|
66
69
|
const {
|
|
67
70
|
current: id
|
|
68
71
|
} = useRef(idProp || guid());
|
|
69
|
-
const
|
|
72
|
+
const internalRef = useRef(null);
|
|
73
|
+
const callbackRef = useCallback(inputElement => {
|
|
74
|
+
internalRef.current = inputElement;
|
|
75
|
+
|
|
76
|
+
if (!ref) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if ("current" in ref) {
|
|
81
|
+
ref.current = inputElement;
|
|
82
|
+
} else {
|
|
83
|
+
ref(inputElement);
|
|
84
|
+
}
|
|
85
|
+
}, [ref]);
|
|
86
|
+
|
|
87
|
+
if (!deprecateInputRefWarnTriggered && inputRef) {
|
|
88
|
+
deprecateInputRefWarnTriggered = true;
|
|
89
|
+
Logger.deprecate("The `inputRef` prop in `Textarea` component is deprecated and will soon be removed. Please use `ref` instead.");
|
|
90
|
+
}
|
|
91
|
+
|
|
70
92
|
const minHeight = useRef(MIN_HEIGHT);
|
|
71
93
|
|
|
72
94
|
const expandTextarea = () => {
|
|
73
|
-
const textarea =
|
|
95
|
+
const textarea = internalRef.current;
|
|
74
96
|
|
|
75
97
|
if (textarea !== null && textarea !== void 0 && textarea.scrollHeight && (textarea === null || textarea === void 0 ? void 0 : textarea.scrollHeight) > minHeight.current) {
|
|
76
98
|
textarea.style.height = "0px"; // Set the height so all content is shown
|
|
@@ -97,9 +119,9 @@ const Textarea = ({
|
|
|
97
119
|
typeof characterLimit === "string" ? parseInt(characterLimit, 10) : characterLimit, warnOverLimit, enforceCharacterLimit);
|
|
98
120
|
useEffect(() => {
|
|
99
121
|
if (rows) {
|
|
100
|
-
var
|
|
122
|
+
var _internalRef$current;
|
|
101
123
|
|
|
102
|
-
minHeight.current = (
|
|
124
|
+
minHeight.current = (internalRef === null || internalRef === void 0 ? void 0 : (_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.scrollHeight) || 0;
|
|
103
125
|
}
|
|
104
126
|
}, [rows]);
|
|
105
127
|
useEffect(() => {
|
|
@@ -109,10 +131,10 @@ const Textarea = ({
|
|
|
109
131
|
});
|
|
110
132
|
useEffect(() => {
|
|
111
133
|
if (expandable) {
|
|
112
|
-
var
|
|
134
|
+
var _internalRef$current2;
|
|
113
135
|
|
|
114
136
|
window.addEventListener("resize", expandTextarea);
|
|
115
|
-
minHeight.current = (
|
|
137
|
+
minHeight.current = (internalRef === null || internalRef === void 0 ? void 0 : (_internalRef$current2 = internalRef.current) === null || _internalRef$current2 === void 0 ? void 0 : _internalRef$current2.clientHeight) || 0;
|
|
116
138
|
}
|
|
117
139
|
|
|
118
140
|
return () => {
|
|
@@ -138,7 +160,7 @@ const Textarea = ({
|
|
|
138
160
|
autoFocus: autoFocus,
|
|
139
161
|
name: name,
|
|
140
162
|
value: value,
|
|
141
|
-
ref:
|
|
163
|
+
ref: callbackRef,
|
|
142
164
|
maxLength: maxLength,
|
|
143
165
|
onChange: onChange,
|
|
144
166
|
disabled: disabled,
|
|
@@ -147,7 +169,8 @@ const Textarea = ({
|
|
|
147
169
|
rows: rows,
|
|
148
170
|
cols: cols,
|
|
149
171
|
id: id,
|
|
150
|
-
as: "textarea"
|
|
172
|
+
as: "textarea",
|
|
173
|
+
inputRef: inputRef
|
|
151
174
|
}, props)), children, /*#__PURE__*/React.createElement(InputIconToggle, {
|
|
152
175
|
disabled: disabled,
|
|
153
176
|
readOnly: readOnly,
|
|
@@ -195,8 +218,7 @@ const Textarea = ({
|
|
|
195
218
|
}), (error || warning) && /*#__PURE__*/React.createElement(ErrorBorder, {
|
|
196
219
|
warning: !!(!error && warning)
|
|
197
220
|
}), input) : input), characterCount)));
|
|
198
|
-
};
|
|
199
|
-
|
|
221
|
+
});
|
|
200
222
|
Textarea.propTypes = {
|
|
201
223
|
"about": PropTypes.string,
|
|
202
224
|
"accept": PropTypes.string,
|
|
@@ -724,5 +746,6 @@ Textarea.propTypes = {
|
|
|
724
746
|
"width": PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
725
747
|
};
|
|
726
748
|
export { Textarea };
|
|
749
|
+
Textarea.displayName = "Textarea";
|
|
727
750
|
export { Textarea as OriginalTextarea };
|
|
728
751
|
export default Textarea;
|
|
@@ -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:
|
|
96
|
+
export declare const Textbox: React.ForwardRefExoticComponent<TextboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
97
97
|
export default Textbox;
|
|
@@ -17,8 +17,9 @@ import ValidationMessage from "../../__internal__/validation-message";
|
|
|
17
17
|
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
18
18
|
import NumeralDateContext from "../numeral-date/numeral-date-context";
|
|
19
19
|
import Box from "../box";
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
import Logger from "../../__internal__/utils/logger";
|
|
21
|
+
let deprecateInputRefWarnTriggered = false;
|
|
22
|
+
const Textbox = /*#__PURE__*/React.forwardRef(({
|
|
22
23
|
align = "left",
|
|
23
24
|
autoFocus,
|
|
24
25
|
children,
|
|
@@ -72,7 +73,7 @@ const Textbox = ({
|
|
|
72
73
|
warnOverLimit = false,
|
|
73
74
|
helpAriaLabel,
|
|
74
75
|
...props
|
|
75
|
-
}) => {
|
|
76
|
+
}, ref) => {
|
|
76
77
|
const characterCountValue = typeof value === "string" ? value : "";
|
|
77
78
|
const [maxLength, characterCount] = useCharacterCount(characterCountValue, // TODO: Can be removed after the characterLimit type is changed to number
|
|
78
79
|
typeof characterLimit === "string" ? parseInt(characterLimit, 10) : characterLimit, warnOverLimit, enforceCharacterLimit);
|
|
@@ -86,6 +87,12 @@ const Textbox = ({
|
|
|
86
87
|
const computeLabelPropValues = prop => validationRedesignOptIn ? undefined : prop;
|
|
87
88
|
|
|
88
89
|
const [uniqueId, uniqueName] = useUniqueId(id, name);
|
|
90
|
+
|
|
91
|
+
if (!deprecateInputRefWarnTriggered && inputRef) {
|
|
92
|
+
deprecateInputRefWarnTriggered = true;
|
|
93
|
+
Logger.deprecate("The `inputRef` prop in `Textbox` component is deprecated and will soon be removed. Please use `ref` instead.");
|
|
94
|
+
}
|
|
95
|
+
|
|
89
96
|
const {
|
|
90
97
|
labelId: internalLabelId,
|
|
91
98
|
validationIconId,
|
|
@@ -128,6 +135,7 @@ const Textbox = ({
|
|
|
128
135
|
disabled: disabled,
|
|
129
136
|
id: uniqueId,
|
|
130
137
|
inputRef: inputRef,
|
|
138
|
+
ref: ref,
|
|
131
139
|
name: uniqueName,
|
|
132
140
|
onBlur: onBlur,
|
|
133
141
|
onChange: onChange,
|
|
@@ -190,8 +198,7 @@ const Textbox = ({
|
|
|
190
198
|
}), !disableErrorBorder && (error || warning) && /*#__PURE__*/React.createElement(ErrorBorder, {
|
|
191
199
|
warning: !!(!error && warning)
|
|
192
200
|
}), input) : input), characterCount));
|
|
193
|
-
};
|
|
194
|
-
|
|
201
|
+
});
|
|
195
202
|
Textbox.propTypes = {
|
|
196
203
|
"about": PropTypes.string,
|
|
197
204
|
"accept": PropTypes.string,
|
|
@@ -726,4 +733,5 @@ Textbox.propTypes = {
|
|
|
726
733
|
"width": PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
727
734
|
};
|
|
728
735
|
export { Textbox };
|
|
736
|
+
Textbox.displayName = "Textbox";
|
|
729
737
|
export default Textbox;
|
|
@@ -9,6 +9,7 @@ import createGuid from "../../__internal__/utils/helpers/guid";
|
|
|
9
9
|
import Button from "../button";
|
|
10
10
|
import Box from "../box";
|
|
11
11
|
import Accordion from "./__internal__/accordion";
|
|
12
|
+
import Logger from "../../__internal__/utils/logger";
|
|
12
13
|
import { StyledTileSelectContainer, StyledTileSelect, StyledTileSelectInput, StyledTitleContainer, StyledTitle, StyledSubtitle, StyledAdornment, StyledDescription, StyledDeselectWrapper, StyledFooterWrapper, StyledFocusWrapper, StyledAccordionFooterWrapper } from "./tile-select.style";
|
|
13
14
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
14
15
|
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
@@ -17,7 +18,8 @@ const checkPropTypeIsNode = prop => typeof prop !== "string" && {
|
|
|
17
18
|
as: "div"
|
|
18
19
|
};
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
let deprecateInputRefWarnTriggered = false;
|
|
22
|
+
const TileSelect = /*#__PURE__*/React.forwardRef(({
|
|
21
23
|
onChange,
|
|
22
24
|
onBlur,
|
|
23
25
|
onFocus,
|
|
@@ -40,8 +42,9 @@ const TileSelect = ({
|
|
|
40
42
|
accordionContent,
|
|
41
43
|
accordionControl,
|
|
42
44
|
accordionExpanded,
|
|
45
|
+
inputRef,
|
|
43
46
|
...rest
|
|
44
|
-
}) => {
|
|
47
|
+
}, ref) => {
|
|
45
48
|
const l = useLocale();
|
|
46
49
|
const [hasFocus, setHasFocus] = useState(false);
|
|
47
50
|
|
|
@@ -57,6 +60,11 @@ const TileSelect = ({
|
|
|
57
60
|
}
|
|
58
61
|
});
|
|
59
62
|
|
|
63
|
+
if (!deprecateInputRefWarnTriggered && inputRef) {
|
|
64
|
+
deprecateInputRefWarnTriggered = true;
|
|
65
|
+
Logger.deprecate("The `inputRef` prop in `TileSelect` component is deprecated and will soon be removed. Please use `ref` instead.");
|
|
66
|
+
}
|
|
67
|
+
|
|
60
68
|
const renderActionButton = () => /*#__PURE__*/React.createElement(StyledDeselectWrapper, {
|
|
61
69
|
hasActionAdornment: !!actionButtonAdornment
|
|
62
70
|
}, customActionButton && customActionButton(handleDeselect), !customActionButton && checked && /*#__PURE__*/React.createElement(Button, {
|
|
@@ -101,7 +109,9 @@ const TileSelect = ({
|
|
|
101
109
|
value: value,
|
|
102
110
|
disabled: disabled,
|
|
103
111
|
"aria-checked": checked,
|
|
104
|
-
id: id
|
|
112
|
+
id: id,
|
|
113
|
+
inputRef: inputRef,
|
|
114
|
+
ref: ref
|
|
105
115
|
}, rest)), /*#__PURE__*/React.createElement(StyledTileSelect, {
|
|
106
116
|
disabled: disabled,
|
|
107
117
|
checked: checked
|
|
@@ -124,8 +134,7 @@ const TileSelect = ({
|
|
|
124
134
|
controlId: controlId,
|
|
125
135
|
expanded: accordionExpanded
|
|
126
136
|
}, accordionContent)));
|
|
127
|
-
};
|
|
128
|
-
|
|
137
|
+
});
|
|
129
138
|
TileSelect.defaultProps = {
|
|
130
139
|
checked: false,
|
|
131
140
|
type: "checkbox"
|
|
@@ -46,5 +46,5 @@ export interface CheckableInputProps extends CommonCheckableInputProps {
|
|
|
46
46
|
/** When true label is inline */
|
|
47
47
|
labelInline?: boolean;
|
|
48
48
|
}
|
|
49
|
-
declare const CheckableInput:
|
|
49
|
+
declare const CheckableInput: React.ForwardRefExoticComponent<CheckableInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
50
50
|
export default CheckableInput;
|
|
@@ -27,7 +27,7 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
27
27
|
|
|
28
28
|
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
29
|
|
|
30
|
-
const CheckableInput = ({
|
|
30
|
+
const CheckableInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
31
31
|
ariaLabelledBy: externalAriaLabelledBy,
|
|
32
32
|
autoFocus,
|
|
33
33
|
checked,
|
|
@@ -38,7 +38,6 @@ const CheckableInput = ({
|
|
|
38
38
|
fieldHelpInline,
|
|
39
39
|
info,
|
|
40
40
|
id: inputId,
|
|
41
|
-
inputRef,
|
|
42
41
|
type,
|
|
43
42
|
value,
|
|
44
43
|
inputWidth,
|
|
@@ -57,7 +56,7 @@ const CheckableInput = ({
|
|
|
57
56
|
validationOnLabel,
|
|
58
57
|
warning,
|
|
59
58
|
...props
|
|
60
|
-
}) => {
|
|
59
|
+
}, ref) => {
|
|
61
60
|
const {
|
|
62
61
|
current: id
|
|
63
62
|
} = (0, _react.useRef)(inputId || (0, _guid.default)());
|
|
@@ -108,7 +107,6 @@ const CheckableInput = ({
|
|
|
108
107
|
checked,
|
|
109
108
|
disabled,
|
|
110
109
|
id,
|
|
111
|
-
inputRef,
|
|
112
110
|
type,
|
|
113
111
|
value,
|
|
114
112
|
name,
|
|
@@ -116,6 +114,7 @@ const CheckableInput = ({
|
|
|
116
114
|
onChange,
|
|
117
115
|
onFocus,
|
|
118
116
|
required,
|
|
117
|
+
ref,
|
|
119
118
|
...props
|
|
120
119
|
};
|
|
121
120
|
return /*#__PURE__*/_react.default.createElement(_checkableInput.StyledCheckableInputWrapper, {
|
|
@@ -126,7 +125,7 @@ const CheckableInput = ({
|
|
|
126
125
|
labelInline: labelInline,
|
|
127
126
|
reverse: reverse
|
|
128
127
|
}, /*#__PURE__*/_react.default.createElement(_inputBehaviour.InputBehaviour, null, /*#__PURE__*/_react.default.createElement(_formField.default, formFieldProps, /*#__PURE__*/_react.default.createElement(_checkableInput.StyledCheckableInput, null, /*#__PURE__*/_react.default.createElement(_hiddenCheckableInput.default, inputProps), children))));
|
|
129
|
-
};
|
|
128
|
+
});
|
|
130
129
|
|
|
131
130
|
CheckableInput.propTypes = {
|
|
132
131
|
"about": _propTypes.default.string,
|
|
@@ -223,9 +222,6 @@ CheckableInput.propTypes = {
|
|
|
223
222
|
"info": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
|
|
224
223
|
"inlist": _propTypes.default.any,
|
|
225
224
|
"inputMode": _propTypes.default.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
|
|
226
|
-
"inputRef": _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
227
|
-
"current": _propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.object]).isRequired
|
|
228
|
-
})]),
|
|
229
225
|
"inputWidth": _propTypes.default.number,
|
|
230
226
|
"is": _propTypes.default.string,
|
|
231
227
|
"itemID": _propTypes.default.string,
|
|
@@ -489,5 +485,6 @@ CheckableInput.propTypes = {
|
|
|
489
485
|
"warning": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
|
|
490
486
|
"width": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
491
487
|
};
|
|
488
|
+
CheckableInput.displayName = "CheckableInput";
|
|
492
489
|
var _default = CheckableInput;
|
|
493
490
|
exports.default = _default;
|
|
@@ -18,8 +18,6 @@ export interface CommonHiddenCheckableInputProps extends Omit<React.InputHTMLAtt
|
|
|
18
18
|
onMouseEnter?: (ev: React.MouseEvent<HTMLInputElement>) => void;
|
|
19
19
|
/** Value of the input */
|
|
20
20
|
value?: string;
|
|
21
|
-
/** A callback to retrieve the input reference */
|
|
22
|
-
inputRef?: React.Ref<HTMLInputElement>;
|
|
23
21
|
}
|
|
24
22
|
export interface HiddenCheckableInputProps extends CommonHiddenCheckableInputProps {
|
|
25
23
|
/** HTML type attribute of the input */
|
|
@@ -27,5 +25,5 @@ export interface HiddenCheckableInputProps extends CommonHiddenCheckableInputPro
|
|
|
27
25
|
/** Role attribute of the input */
|
|
28
26
|
role?: string;
|
|
29
27
|
}
|
|
30
|
-
declare const _default: React.MemoExoticComponent<
|
|
28
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<HiddenCheckableInputProps & React.RefAttributes<HTMLInputElement>>>;
|
|
31
29
|
export default _default;
|
|
@@ -21,17 +21,16 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
21
21
|
|
|
22
22
|
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); }
|
|
23
23
|
|
|
24
|
-
const HiddenCheckableInput = ({
|
|
24
|
+
const HiddenCheckableInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
25
25
|
name,
|
|
26
26
|
checked,
|
|
27
27
|
type,
|
|
28
28
|
value,
|
|
29
|
-
inputRef,
|
|
30
29
|
onChange,
|
|
31
30
|
autoFocus,
|
|
32
31
|
role,
|
|
33
32
|
...props
|
|
34
|
-
}) => {
|
|
33
|
+
}, ref) => {
|
|
35
34
|
const {
|
|
36
35
|
onBlur,
|
|
37
36
|
onFocus,
|
|
@@ -86,9 +85,9 @@ const HiddenCheckableInput = ({
|
|
|
86
85
|
onMouseEnter: handleMouseEnter,
|
|
87
86
|
onMouseLeave: handleMouseLeave,
|
|
88
87
|
onChange: onChange,
|
|
89
|
-
ref:
|
|
88
|
+
ref: ref
|
|
90
89
|
}));
|
|
91
|
-
};
|
|
90
|
+
});
|
|
92
91
|
|
|
93
92
|
HiddenCheckableInput.propTypes = {
|
|
94
93
|
"about": _propTypes.default.string,
|
|
@@ -180,9 +179,6 @@ HiddenCheckableInput.propTypes = {
|
|
|
180
179
|
"id": _propTypes.default.string,
|
|
181
180
|
"inlist": _propTypes.default.any,
|
|
182
181
|
"inputMode": _propTypes.default.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
|
|
183
|
-
"inputRef": _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
184
|
-
"current": _propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.object]).isRequired
|
|
185
|
-
})]),
|
|
186
182
|
"is": _propTypes.default.string,
|
|
187
183
|
"itemID": _propTypes.default.string,
|
|
188
184
|
"itemProp": _propTypes.default.string,
|
|
@@ -385,6 +381,7 @@ HiddenCheckableInput.propTypes = {
|
|
|
385
381
|
"vocab": _propTypes.default.string,
|
|
386
382
|
"width": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
387
383
|
};
|
|
384
|
+
HiddenCheckableInput.displayName = "HiddenCheckableInput";
|
|
388
385
|
|
|
389
386
|
var _default = /*#__PURE__*/_react.default.memo(HiddenCheckableInput);
|
|
390
387
|
|
|
@@ -10,7 +10,7 @@ export interface CommonInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
10
10
|
/** HTML id attribute of the input */
|
|
11
11
|
id?: string;
|
|
12
12
|
/** A callback to retrieve the input reference */
|
|
13
|
-
inputRef?: (input: React.RefObject<HTMLInputElement>) => void;
|
|
13
|
+
inputRef?: (input: React.RefObject<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
14
14
|
/** Name of the input */
|
|
15
15
|
name?: string;
|
|
16
16
|
/** Specify a callback triggered on blur */
|
|
@@ -42,5 +42,5 @@ export interface InputProps extends CommonInputProps {
|
|
|
42
42
|
/** HTML type attribute of the input */
|
|
43
43
|
type?: string;
|
|
44
44
|
}
|
|
45
|
-
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
45
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement | HTMLTextAreaElement>>;
|
|
46
46
|
export default Input;
|
|
@@ -49,6 +49,7 @@ const Input = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
49
49
|
disabled,
|
|
50
50
|
readOnly,
|
|
51
51
|
autoFocus,
|
|
52
|
+
// TODO: remove inputRef prop from this component (and props interface) when it has been removed from all exposed input components
|
|
52
53
|
inputRef,
|
|
53
54
|
onClick,
|
|
54
55
|
onChangeDeferred,
|
|
@@ -66,15 +67,21 @@ const Input = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
66
67
|
const deferredTimeout = (0, _react.useRef)(null);
|
|
67
68
|
let input = (0, _react.useRef)(null);
|
|
68
69
|
|
|
69
|
-
if (ref) {
|
|
70
|
+
if (ref && "current" in ref) {
|
|
70
71
|
input = ref;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
(0, _react.
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const callbackRef = (0, _react.useCallback)(element => {
|
|
75
|
+
input.current = element;
|
|
76
|
+
|
|
77
|
+
if (typeof ref === "function") {
|
|
78
|
+
ref(element);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (autoFocus && element) {
|
|
82
|
+
element.focus();
|
|
76
83
|
}
|
|
77
|
-
}, [autoFocus,
|
|
84
|
+
}, [autoFocus, ref]);
|
|
78
85
|
(0, _react.useEffect)(() => {
|
|
79
86
|
if (inputRef) {
|
|
80
87
|
inputRef(input);
|
|
@@ -162,7 +169,7 @@ const Input = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
162
169
|
name: name,
|
|
163
170
|
type: type,
|
|
164
171
|
id: id || name,
|
|
165
|
-
ref:
|
|
172
|
+
ref: callbackRef,
|
|
166
173
|
"data-element": "input",
|
|
167
174
|
onFocus: handleFocus,
|
|
168
175
|
onBlur: handleBlur,
|
|
@@ -22,9 +22,8 @@ export interface CheckboxProps extends CommonCheckableInputProps, MarginProps {
|
|
|
22
22
|
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
23
23
|
/** The value of the checkbox, passed on form submit */
|
|
24
24
|
value?: string;
|
|
25
|
+
/** A callback to retrieve the input reference (deprecated) */
|
|
26
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
25
27
|
}
|
|
26
|
-
export declare const Checkbox:
|
|
27
|
-
({ id, label, onChange, name, onClick, onBlur, onFocus, value, fieldHelp, autoFocus, labelHelp, labelSpacing, labelWidth, adaptiveSpacingBreakpoint, required, error, warning, info, fieldHelpInline, reverse, checked, disabled, inputWidth, size, tooltipPosition, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, ...props }: CheckboxProps): JSX.Element;
|
|
28
|
-
displayName: string;
|
|
29
|
-
};
|
|
28
|
+
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
30
29
|
export default Checkbox;
|
|
@@ -23,6 +23,8 @@ var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
|
23
23
|
|
|
24
24
|
var _checkboxGroup = require("./checkbox-group.component");
|
|
25
25
|
|
|
26
|
+
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
27
|
+
|
|
26
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
29
|
|
|
28
30
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -31,7 +33,9 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
31
33
|
|
|
32
34
|
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); }
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
let deprecateInputRefWarnTriggered = false;
|
|
37
|
+
|
|
38
|
+
const Checkbox = /*#__PURE__*/_react.default.forwardRef(({
|
|
35
39
|
id,
|
|
36
40
|
label,
|
|
37
41
|
onChange,
|
|
@@ -63,8 +67,9 @@ const Checkbox = ({
|
|
|
63
67
|
"data-element": dataElement,
|
|
64
68
|
"data-role": dataRole,
|
|
65
69
|
helpAriaLabel,
|
|
70
|
+
inputRef,
|
|
66
71
|
...props
|
|
67
|
-
}) => {
|
|
72
|
+
}, ref) => {
|
|
68
73
|
const largeScreen = (0, _useIsAboveBreakpoint.default)(adaptiveSpacingBreakpoint);
|
|
69
74
|
const adaptiveSpacingSmallScreen = !!(adaptiveSpacingBreakpoint && !largeScreen);
|
|
70
75
|
const {
|
|
@@ -72,6 +77,13 @@ const Checkbox = ({
|
|
|
72
77
|
warning: contextWarning,
|
|
73
78
|
info: contextInfo
|
|
74
79
|
} = (0, _react.useContext)(_checkboxGroup.CheckboxGroupContext);
|
|
80
|
+
|
|
81
|
+
if (!deprecateInputRefWarnTriggered && inputRef) {
|
|
82
|
+
deprecateInputRefWarnTriggered = true;
|
|
83
|
+
|
|
84
|
+
_logger.default.deprecate("The `inputRef` prop in `Checkbox` component is deprecated and will soon be removed. Please use `ref` instead.");
|
|
85
|
+
}
|
|
86
|
+
|
|
75
87
|
const inputProps = {
|
|
76
88
|
onClick,
|
|
77
89
|
onChange,
|
|
@@ -98,6 +110,7 @@ const Checkbox = ({
|
|
|
98
110
|
inputWidth,
|
|
99
111
|
labelWidth,
|
|
100
112
|
tooltipPosition,
|
|
113
|
+
ref: ref || inputRef,
|
|
101
114
|
...props
|
|
102
115
|
};
|
|
103
116
|
return /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
@@ -118,7 +131,7 @@ const Checkbox = ({
|
|
|
118
131
|
reverse: reverse,
|
|
119
132
|
size: size
|
|
120
133
|
}, (0, _utils.filterStyledSystemMarginProps)(props)), /*#__PURE__*/_react.default.createElement(_checkableInput.default, inputProps, /*#__PURE__*/_react.default.createElement(_checkboxSvg.default, null))));
|
|
121
|
-
};
|
|
134
|
+
});
|
|
122
135
|
|
|
123
136
|
exports.Checkbox = Checkbox;
|
|
124
137
|
Checkbox.propTypes = {
|