carbon-react 110.1.2 → 110.2.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.
- package/esm/__internal__/character-count/character-count.component.d.ts +8 -25
- package/esm/__internal__/character-count/character-count.component.js +12 -18
- package/esm/__internal__/character-count/character-count.style.d.ts +3 -1
- package/esm/__internal__/character-count/character-count.style.js +4 -0
- package/esm/__internal__/form-field/form-field.component.d.ts +5 -1
- package/esm/__internal__/form-field/form-field.component.js +8 -5
- package/esm/__internal__/input/index.d.ts +1 -1
- package/esm/__internal__/utils/helpers/tags/tags.d.ts +5 -2
- package/esm/__spec_helper__/test-utils.d.ts +3 -2
- package/esm/__spec_helper__/test-utils.js +17 -1
- package/esm/components/box/box.component.d.ts +4 -2
- package/esm/components/box/box.component.js +2 -1
- package/esm/components/dismissible-box/dismissible-box.component.js +398 -0
- package/esm/components/numeral-date/numeral-date-context.d.ts +6 -0
- package/esm/components/portal/portal.d.ts +15 -12
- package/esm/components/portal/portal.js +3 -13
- package/esm/components/select/multi-select/multi-select.component.js +1 -1
- package/esm/components/select/select-list/select-list.component.js +20 -11
- package/esm/components/textarea/textarea.component.js +6 -27
- package/esm/components/textarea/textarea.d.ts +2 -1
- package/esm/components/textbox/__internal__/prefix.style.d.ts +2 -0
- package/esm/components/textbox/index.d.ts +2 -1
- package/esm/components/textbox/index.js +1 -1
- package/esm/components/textbox/textbox.component.d.ts +92 -0
- package/esm/components/textbox/textbox.component.js +533 -197
- package/esm/components/textbox/textbox.style.d.ts +5 -0
- package/esm/components/textbox/textbox.style.js +0 -12
- package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +1 -1
- package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.js +7 -6
- package/esm/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +6 -5
- package/esm/style/utils/filter-out-position-props.d.ts +3 -0
- package/esm/style/utils/filter-out-position-props.js +5 -0
- package/lib/__internal__/character-count/character-count.component.d.ts +8 -25
- package/lib/__internal__/character-count/character-count.component.js +13 -23
- package/lib/__internal__/character-count/character-count.style.d.ts +3 -1
- package/lib/__internal__/character-count/character-count.style.js +7 -0
- package/lib/__internal__/form-field/form-field.component.d.ts +5 -1
- package/lib/__internal__/form-field/form-field.component.js +8 -5
- package/lib/__internal__/input/index.d.ts +1 -1
- package/lib/__internal__/utils/helpers/tags/tags.d.ts +5 -2
- package/lib/__spec_helper__/test-utils.d.ts +3 -2
- package/lib/__spec_helper__/test-utils.js +20 -2
- package/lib/components/box/box.component.d.ts +4 -2
- package/lib/components/box/box.component.js +1 -0
- package/lib/components/dismissible-box/dismissible-box.component.js +398 -0
- package/lib/components/numeral-date/numeral-date-context.d.ts +6 -0
- package/lib/components/portal/portal.d.ts +15 -12
- package/lib/components/portal/portal.js +3 -14
- package/lib/components/select/multi-select/multi-select.component.js +1 -1
- package/lib/components/select/select-list/select-list.component.js +20 -11
- package/lib/components/textarea/textarea.component.js +6 -27
- package/lib/components/textarea/textarea.d.ts +2 -1
- package/lib/components/textbox/__internal__/prefix.style.d.ts +2 -0
- package/lib/components/textbox/index.d.ts +2 -1
- package/lib/components/textbox/index.js +2 -10
- package/lib/components/textbox/textbox.component.d.ts +92 -0
- package/lib/components/textbox/textbox.component.js +534 -201
- package/lib/components/textbox/textbox.style.d.ts +5 -0
- package/lib/components/textbox/textbox.style.js +1 -16
- package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +1 -1
- package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.js +7 -6
- package/lib/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +6 -5
- package/lib/style/utils/filter-out-position-props.d.ts +3 -0
- package/lib/style/utils/filter-out-position-props.js +18 -0
- package/package.json +1 -1
- package/esm/components/textbox/textbox.d.ts +0 -125
- package/lib/components/textbox/textbox.d.ts +0 -125
|
@@ -15,7 +15,7 @@ var _input = require("../../__internal__/input");
|
|
|
15
15
|
|
|
16
16
|
var _formField = _interopRequireDefault(require("../../__internal__/form-field"));
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _useCharacterCount = _interopRequireDefault(require("../../hooks/__internal__/useCharacterCount"));
|
|
19
19
|
|
|
20
20
|
var _input2 = _interopRequireDefault(require("../../__internal__/input/input.component"));
|
|
21
21
|
|
|
@@ -29,8 +29,6 @@ var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/gui
|
|
|
29
29
|
|
|
30
30
|
var _textarea = _interopRequireWildcard(require("./textarea.style"));
|
|
31
31
|
|
|
32
|
-
var _i18nContext = _interopRequireDefault(require("../../__internal__/i18n-context"));
|
|
33
|
-
|
|
34
32
|
var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
35
33
|
|
|
36
34
|
var _useInputAccessibility = _interopRequireDefault(require("../../hooks/__internal__/useInputAccessibility"));
|
|
@@ -49,8 +47,6 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
49
47
|
|
|
50
48
|
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); }
|
|
51
49
|
|
|
52
|
-
const getFormatNumber = (value, locale) => new Intl.NumberFormat(locale).format(value);
|
|
53
|
-
|
|
54
50
|
const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
|
|
55
51
|
|
|
56
52
|
const Textarea = ({
|
|
@@ -91,7 +87,6 @@ const Textarea = ({
|
|
|
91
87
|
helpAriaLabel,
|
|
92
88
|
...props
|
|
93
89
|
}) => {
|
|
94
|
-
const locale = (0, _react.useContext)(_i18nContext.default);
|
|
95
90
|
const {
|
|
96
91
|
validationRedesignOptIn
|
|
97
92
|
} = (0, _react.useContext)(_carbonProvider.NewValidationContext);
|
|
@@ -128,6 +123,8 @@ const Textarea = ({
|
|
|
128
123
|
label,
|
|
129
124
|
fieldHelp
|
|
130
125
|
});
|
|
126
|
+
const [maxLength, characterCount] = (0, _useCharacterCount.default)(value, // TODO: Can be removed after the characterLimit type is changed to number
|
|
127
|
+
typeof characterLimit === "string" ? parseInt(characterLimit, 10) : characterLimit, warnOverLimit, enforceCharacterLimit);
|
|
131
128
|
(0, _react.useEffect)(() => {
|
|
132
129
|
if (rows) {
|
|
133
130
|
minHeight.current = inputRef.current.scrollHeight;
|
|
@@ -150,24 +147,6 @@ const Textarea = ({
|
|
|
150
147
|
}
|
|
151
148
|
};
|
|
152
149
|
}, [expandable]);
|
|
153
|
-
|
|
154
|
-
const isOverLimit = () => {
|
|
155
|
-
return (value || "").length > parseInt(characterLimit, 10);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const characterCount = () => {
|
|
159
|
-
if (!characterLimit) {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return /*#__PURE__*/_react.default.createElement(_characterCount.default, {
|
|
164
|
-
isOverLimit: isOverLimit() && warnOverLimit,
|
|
165
|
-
value: getFormatNumber((value || "").length, locale.locale()),
|
|
166
|
-
limit: getFormatNumber(characterLimit, locale.locale()),
|
|
167
|
-
"data-element": "character-limit"
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
|
|
171
150
|
return /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
172
151
|
tooltipPosition: tooltipPosition,
|
|
173
152
|
helpAriaLabel: helpAriaLabel
|
|
@@ -216,7 +195,7 @@ const Textarea = ({
|
|
|
216
195
|
name: name,
|
|
217
196
|
value: value,
|
|
218
197
|
ref: inputRef,
|
|
219
|
-
maxLength:
|
|
198
|
+
maxLength: maxLength,
|
|
220
199
|
onChange: onChange,
|
|
221
200
|
disabled: disabled,
|
|
222
201
|
readOnly: readOnly,
|
|
@@ -236,7 +215,7 @@ const Textarea = ({
|
|
|
236
215
|
info: info,
|
|
237
216
|
validationIconId: validationRedesignOptIn ? undefined : validationIconId,
|
|
238
217
|
useValidationIcon: !(validationRedesignOptIn || validationOnLabel)
|
|
239
|
-
}))), characterCount
|
|
218
|
+
}))), characterCount)));
|
|
240
219
|
};
|
|
241
220
|
|
|
242
221
|
exports.OriginalTextarea = Textarea;
|
|
@@ -258,7 +237,7 @@ Textarea.propTypes = { ...marginPropTypes,
|
|
|
258
237
|
id: _propTypes.default.string,
|
|
259
238
|
|
|
260
239
|
/** Character limit of the textarea */
|
|
261
|
-
characterLimit: _propTypes.default.string,
|
|
240
|
+
characterLimit: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
262
241
|
|
|
263
242
|
/** Type of the icon that will be rendered next to the input */
|
|
264
243
|
children: _propTypes.default.node,
|
|
@@ -4,6 +4,7 @@ import { MarginProps } from "styled-system";
|
|
|
4
4
|
import { ValidationProps } from "../../__internal__/validations";
|
|
5
5
|
import { CommonInputProps } from "../../__internal__/input";
|
|
6
6
|
|
|
7
|
+
// TODO: Change characterLimit type to number - batch with other breaking changes
|
|
7
8
|
export interface TextareaProps
|
|
8
9
|
extends ValidationProps,
|
|
9
10
|
MarginProps,
|
|
@@ -19,7 +20,7 @@ export interface TextareaProps
|
|
|
19
20
|
/** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
|
|
20
21
|
adaptiveLabelBreakpoint?: number;
|
|
21
22
|
/** Character limit of the textarea */
|
|
22
|
-
characterLimit?: string;
|
|
23
|
+
characterLimit?: string | number;
|
|
23
24
|
/** Type of the icon that will be rendered next to the input */
|
|
24
25
|
children?: React.ReactNode;
|
|
25
26
|
/** The visible width of the text control, in average character widths */
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default
|
|
1
|
+
export { default } from "./textbox.component";
|
|
2
|
+
export type { TextboxProps, CommonTextboxProps } from "./textbox.component";
|
|
@@ -9,15 +9,7 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
return _textbox.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "OriginalTextbox", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _textbox.OriginalTextbox;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var _textbox = _interopRequireWildcard(require("./textbox.component"));
|
|
20
12
|
|
|
21
|
-
|
|
13
|
+
var _textbox = _interopRequireDefault(require("./textbox.component"));
|
|
22
14
|
|
|
23
|
-
function
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MarginProps } from "styled-system";
|
|
3
|
+
import { CommonInputProps } from "../../__internal__/input";
|
|
4
|
+
import { ValidationProps } from "../../__internal__/validations";
|
|
5
|
+
import { IconType } from "../icon";
|
|
6
|
+
export interface CommonTextboxProps extends ValidationProps, MarginProps, Omit<CommonInputProps, "size"> {
|
|
7
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
8
|
+
"data-component"?: string;
|
|
9
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
10
|
+
"data-element"?: string;
|
|
11
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
12
|
+
"data-role"?: string;
|
|
13
|
+
/** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
|
|
14
|
+
adaptiveLabelBreakpoint?: number;
|
|
15
|
+
/** Integer to determine a timeout for the deferred callback */
|
|
16
|
+
deferTimeout?: number;
|
|
17
|
+
/** Help content to be displayed under an input */
|
|
18
|
+
fieldHelp?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* An optional alternative for props.value, this is useful if the
|
|
21
|
+
* real value is an ID but you want to show a human-readable version.
|
|
22
|
+
*/
|
|
23
|
+
formattedValue?: string;
|
|
24
|
+
/** Unique identifier for the input. Will use a randomly generated GUID if none is provided */
|
|
25
|
+
id?: string;
|
|
26
|
+
/** Type of the icon that will be rendered next to the input */
|
|
27
|
+
inputIcon?: IconType;
|
|
28
|
+
/** Optional handler for click event on Textbox icon */
|
|
29
|
+
iconOnClick?: (ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
|
|
30
|
+
/** Optional handler for mouse down event on Textbox icon */
|
|
31
|
+
iconOnMouseDown?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
32
|
+
/** Overrides the default tabindex of the component */
|
|
33
|
+
iconTabIndex?: number;
|
|
34
|
+
/** The width of the input as a percentage */
|
|
35
|
+
inputWidth?: number;
|
|
36
|
+
/** Additional child elements to display before the input */
|
|
37
|
+
leftChildren?: React.ReactNode;
|
|
38
|
+
/** Label content */
|
|
39
|
+
label?: string;
|
|
40
|
+
/** Inline label alignment */
|
|
41
|
+
labelAlign?: "left" | "right";
|
|
42
|
+
/** A message that the Help component will display */
|
|
43
|
+
labelHelp?: React.ReactNode;
|
|
44
|
+
/** When true label is inline */
|
|
45
|
+
labelInline?: boolean;
|
|
46
|
+
/** Spacing between label and a field for inline label, given number will be multiplied by base spacing unit (8) */
|
|
47
|
+
labelSpacing?: 1 | 2;
|
|
48
|
+
/** Label width */
|
|
49
|
+
labelWidth?: number;
|
|
50
|
+
/** Specify a callback triggered on change */
|
|
51
|
+
onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
52
|
+
/** Deferred callback to be called after the onChange event */
|
|
53
|
+
onChangeDeferred?: () => void;
|
|
54
|
+
/** Specify a callback triggered on click */
|
|
55
|
+
onClick?: (ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
|
|
56
|
+
/** Event handler for the focus event */
|
|
57
|
+
onFocus?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
58
|
+
/** Event handler for the blur event */
|
|
59
|
+
onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
60
|
+
/** Event handler for the mouse down event */
|
|
61
|
+
onMouseDown?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
62
|
+
/** Emphasized part of the displayed text */
|
|
63
|
+
prefix?: string;
|
|
64
|
+
/** Reverses label and input display */
|
|
65
|
+
reverse?: boolean;
|
|
66
|
+
/** Size of an input */
|
|
67
|
+
size?: "small" | "medium" | "large";
|
|
68
|
+
/** When true, validation icon will be placed on label instead of being placed on the input */
|
|
69
|
+
validationOnLabel?: boolean;
|
|
70
|
+
/** Overrides the default tooltip position */
|
|
71
|
+
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
72
|
+
/** Aria label for rendered help component */
|
|
73
|
+
helpAriaLabel?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface TextboxProps extends CommonTextboxProps {
|
|
76
|
+
/** Content to be rendered next to the input */
|
|
77
|
+
children?: React.ReactNode;
|
|
78
|
+
/** [Legacy] Flag to configure component as optional in Form */
|
|
79
|
+
isOptional?: boolean;
|
|
80
|
+
/** Container for DatePicker or SelectList components */
|
|
81
|
+
positionedChildren?: React.ReactNode;
|
|
82
|
+
/** Label id passed from Select component */
|
|
83
|
+
labelId?: string;
|
|
84
|
+
/** Character limit of the textarea */
|
|
85
|
+
characterLimit?: string | number;
|
|
86
|
+
/** Stop the user typing over the characterLimit */
|
|
87
|
+
enforceCharacterLimit?: boolean;
|
|
88
|
+
/** Whether to display the character count message in red */
|
|
89
|
+
warnOverLimit?: boolean;
|
|
90
|
+
}
|
|
91
|
+
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, prefix, adaptiveLabelBreakpoint, required, positionedChildren, tooltipPosition, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, enforceCharacterLimit, characterLimit, warnOverLimit, helpAriaLabel, ...props }: TextboxProps) => JSX.Element;
|
|
92
|
+
export default Textbox;
|