carbon-react 114.7.1 → 114.9.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/tabs/__internal__/tab-title/tab-title.component.js +5 -0
- package/esm/components/tabs/__internal__/tab-title/tab-title.d.ts +2 -0
- package/esm/components/tabs/tab/tab.component.js +8 -1
- package/esm/components/tabs/tab/tab.d.ts +5 -0
- package/esm/components/tabs/tabs.component.js +16 -23
- 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/tabs/__internal__/tab-title/tab-title.component.js +5 -0
- package/lib/components/tabs/__internal__/tab-title/tab-title.d.ts +2 -0
- package/lib/components/tabs/tab/tab.component.js +8 -1
- package/lib/components/tabs/tab/tab.d.ts +5 -0
- package/lib/components/tabs/tabs.component.js +16 -24
- 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;
|
|
@@ -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
|
-
|
|
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
|
|
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 =
|
|
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
|
|
154
|
+
var _internalRef$current;
|
|
130
155
|
|
|
131
|
-
minHeight.current = (
|
|
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
|
|
166
|
+
var _internalRef$current2;
|
|
142
167
|
|
|
143
168
|
window.addEventListener("resize", expandTextarea);
|
|
144
|
-
minHeight.current = (
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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;
|
|
@@ -23,6 +23,8 @@ var _box = _interopRequireDefault(require("../box"));
|
|
|
23
23
|
|
|
24
24
|
var _accordion = _interopRequireDefault(require("./__internal__/accordion"));
|
|
25
25
|
|
|
26
|
+
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
27
|
+
|
|
26
28
|
var _tileSelect = require("./tile-select.style");
|
|
27
29
|
|
|
28
30
|
var _utils = require("../../style/utils");
|
|
@@ -41,7 +43,9 @@ const checkPropTypeIsNode = prop => typeof prop !== "string" && {
|
|
|
41
43
|
as: "div"
|
|
42
44
|
};
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
let deprecateInputRefWarnTriggered = false;
|
|
47
|
+
|
|
48
|
+
const TileSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
45
49
|
onChange,
|
|
46
50
|
onBlur,
|
|
47
51
|
onFocus,
|
|
@@ -64,8 +68,9 @@ const TileSelect = ({
|
|
|
64
68
|
accordionContent,
|
|
65
69
|
accordionControl,
|
|
66
70
|
accordionExpanded,
|
|
71
|
+
inputRef,
|
|
67
72
|
...rest
|
|
68
|
-
}) => {
|
|
73
|
+
}, ref) => {
|
|
69
74
|
const l = (0, _useLocale.default)();
|
|
70
75
|
const [hasFocus, setHasFocus] = (0, _react.useState)(false);
|
|
71
76
|
|
|
@@ -81,6 +86,12 @@ const TileSelect = ({
|
|
|
81
86
|
}
|
|
82
87
|
});
|
|
83
88
|
|
|
89
|
+
if (!deprecateInputRefWarnTriggered && inputRef) {
|
|
90
|
+
deprecateInputRefWarnTriggered = true;
|
|
91
|
+
|
|
92
|
+
_logger.default.deprecate("The `inputRef` prop in `TileSelect` component is deprecated and will soon be removed. Please use `ref` instead.");
|
|
93
|
+
}
|
|
94
|
+
|
|
84
95
|
const renderActionButton = () => /*#__PURE__*/_react.default.createElement(_tileSelect.StyledDeselectWrapper, {
|
|
85
96
|
hasActionAdornment: !!actionButtonAdornment
|
|
86
97
|
}, customActionButton && customActionButton(handleDeselect), !customActionButton && checked && /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
@@ -125,7 +136,9 @@ const TileSelect = ({
|
|
|
125
136
|
value: value,
|
|
126
137
|
disabled: disabled,
|
|
127
138
|
"aria-checked": checked,
|
|
128
|
-
id: id
|
|
139
|
+
id: id,
|
|
140
|
+
inputRef: inputRef,
|
|
141
|
+
ref: ref
|
|
129
142
|
}, rest)), /*#__PURE__*/_react.default.createElement(_tileSelect.StyledTileSelect, {
|
|
130
143
|
disabled: disabled,
|
|
131
144
|
checked: checked
|
|
@@ -148,7 +161,7 @@ const TileSelect = ({
|
|
|
148
161
|
controlId: controlId,
|
|
149
162
|
expanded: accordionExpanded
|
|
150
163
|
}, accordionContent)));
|
|
151
|
-
};
|
|
164
|
+
});
|
|
152
165
|
|
|
153
166
|
TileSelect.defaultProps = {
|
|
154
167
|
checked: false,
|