carbon-react 110.2.0 → 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.
Files changed (43) hide show
  1. package/esm/__internal__/character-count/character-count.component.d.ts +8 -25
  2. package/esm/__internal__/character-count/character-count.component.js +12 -18
  3. package/esm/__internal__/character-count/character-count.style.d.ts +3 -1
  4. package/esm/__internal__/character-count/character-count.style.js +4 -0
  5. package/esm/__internal__/input/index.d.ts +1 -1
  6. package/esm/components/numeral-date/numeral-date-context.d.ts +6 -0
  7. package/esm/components/select/multi-select/multi-select.component.js +1 -1
  8. package/esm/components/select/select-list/select-list.component.js +20 -11
  9. package/esm/components/textarea/textarea.component.js +6 -27
  10. package/esm/components/textarea/textarea.d.ts +2 -1
  11. package/esm/components/textbox/__internal__/prefix.style.d.ts +2 -0
  12. package/esm/components/textbox/index.d.ts +2 -1
  13. package/esm/components/textbox/index.js +1 -1
  14. package/esm/components/textbox/textbox.component.d.ts +92 -0
  15. package/esm/components/textbox/textbox.component.js +533 -197
  16. package/esm/components/textbox/textbox.style.d.ts +5 -0
  17. package/esm/components/textbox/textbox.style.js +0 -12
  18. package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +1 -1
  19. package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.js +7 -6
  20. package/esm/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +6 -5
  21. package/lib/__internal__/character-count/character-count.component.d.ts +8 -25
  22. package/lib/__internal__/character-count/character-count.component.js +13 -23
  23. package/lib/__internal__/character-count/character-count.style.d.ts +3 -1
  24. package/lib/__internal__/character-count/character-count.style.js +7 -0
  25. package/lib/__internal__/input/index.d.ts +1 -1
  26. package/lib/components/numeral-date/numeral-date-context.d.ts +6 -0
  27. package/lib/components/select/multi-select/multi-select.component.js +1 -1
  28. package/lib/components/select/select-list/select-list.component.js +20 -11
  29. package/lib/components/textarea/textarea.component.js +6 -27
  30. package/lib/components/textarea/textarea.d.ts +2 -1
  31. package/lib/components/textbox/__internal__/prefix.style.d.ts +2 -0
  32. package/lib/components/textbox/index.d.ts +2 -1
  33. package/lib/components/textbox/index.js +2 -10
  34. package/lib/components/textbox/textbox.component.d.ts +92 -0
  35. package/lib/components/textbox/textbox.component.js +534 -201
  36. package/lib/components/textbox/textbox.style.d.ts +5 -0
  37. package/lib/components/textbox/textbox.style.js +1 -16
  38. package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +1 -1
  39. package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.js +7 -6
  40. package/lib/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +6 -5
  41. package/package.json +1 -1
  42. package/esm/components/textbox/textbox.d.ts +0 -125
  43. package/lib/components/textbox/textbox.d.ts +0 -125
@@ -0,0 +1,5 @@
1
+ declare const ErrorBorder: import("styled-components").StyledComponent<"span", any, {
2
+ warning: boolean;
3
+ }, never>;
4
+ declare const StyledHintText: import("styled-components").StyledComponent<"p", any, {}, never>;
5
+ export { StyledHintText, ErrorBorder };
@@ -1,5 +1,4 @@
1
1
  import styled, { css } from "styled-components";
2
- import PropTypes from "prop-types";
3
2
  const ErrorBorder = styled.span`
4
3
  ${({
5
4
  warning
@@ -19,15 +18,4 @@ const StyledHintText = styled.p`
19
18
  color: var(--colorsUtilityYin055);
20
19
  font-size: 14px;
21
20
  `;
22
- StyledHintText.defaultProps = {
23
- size: "medium"
24
- };
25
- ErrorBorder.propTypes = {
26
- warning: PropTypes.bool,
27
- size: PropTypes.string
28
- };
29
- ErrorBorder.defaultProps = {
30
- warning: false,
31
- size: "medium"
32
- };
33
21
  export { StyledHintText, ErrorBorder };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- declare const useCharacterCount: (value: string, characterLimit?: string | undefined, warnOverLimit?: boolean, enforceCharacterLimit?: boolean) => [string | undefined, JSX.Element | null];
2
+ declare const useCharacterCount: (value?: string, characterLimit?: number | undefined, warnOverLimit?: boolean, enforceCharacterLimit?: boolean) => [number | undefined, JSX.Element | null];
3
3
  export default useCharacterCount;
@@ -4,19 +4,20 @@ import useLocale from "../useLocale";
4
4
 
5
5
  const getFormatNumber = (value, locale) => new Intl.NumberFormat(locale).format(value);
6
6
 
7
- const useCharacterCount = (value, characterLimit, warnOverLimit = false, enforceCharacterLimit = true) => {
7
+ const useCharacterCount = (value = "", characterLimit, warnOverLimit = false, enforceCharacterLimit = true) => {
8
+ const isCharacterLimitValid = typeof characterLimit === "number" && !Number.isNaN(characterLimit);
8
9
  const l = useLocale();
9
10
  const isOverLimit = useMemo(() => {
10
- if (value && characterLimit) {
11
- return value.length > parseInt(characterLimit, 10);
11
+ if (value && isCharacterLimitValid) {
12
+ return value.length > characterLimit;
12
13
  }
13
14
 
14
15
  return false;
15
- }, [value, characterLimit]);
16
- return [enforceCharacterLimit && characterLimit ? characterLimit : undefined, characterLimit ? /*#__PURE__*/React.createElement(CharacterCount, {
16
+ }, [value, characterLimit, isCharacterLimitValid]);
17
+ return [enforceCharacterLimit && isCharacterLimitValid ? characterLimit : undefined, isCharacterLimitValid ? /*#__PURE__*/React.createElement(CharacterCount, {
17
18
  isOverLimit: isOverLimit && warnOverLimit,
18
19
  value: getFormatNumber(value.length, l.locale()),
19
- limit: getFormatNumber(+characterLimit, l.locale()),
20
+ limit: getFormatNumber(characterLimit, l.locale()),
20
21
  "data-element": "character-limit"
21
22
  }) : null];
22
23
  };
@@ -1,10 +1,11 @@
1
+ /// <reference types="react" />
1
2
  export default function useInputAccessibility({ id, error, warning, info, label, fieldHelp, }: {
2
3
  id: string;
3
- error?: string;
4
- warning?: string;
5
- info?: string;
6
- label?: string;
7
- fieldHelp?: string;
4
+ error?: string | boolean;
5
+ warning?: string | boolean;
6
+ info?: string | boolean;
7
+ label?: React.ReactNode;
8
+ fieldHelp?: React.ReactNode;
8
9
  }): {
9
10
  labelId?: string;
10
11
  validationIconId?: string;
@@ -1,26 +1,9 @@
1
- declare var _default: React.ForwardRefExoticComponent<{
2
- [x: string]: any;
3
- [x: number]: any;
4
- } & {
5
- theme?: any;
6
- }>;
7
- export default _default;
8
- import React from "react";
9
- export function CharacterCount({ value, limit, theme, ...props }: {
10
- [x: string]: any;
11
- value: any;
12
- limit: any;
13
- theme: any;
14
- }): JSX.Element;
15
- export namespace CharacterCount {
16
- namespace propTypes {
17
- const value: PropTypes.Validator<string>;
18
- const limit: PropTypes.Validator<string>;
19
- const theme: PropTypes.Requireable<object>;
20
- }
21
- namespace defaultProps {
22
- export { baseTheme as theme };
23
- }
1
+ /// <reference types="react" />
2
+ interface CharacterCountProps {
3
+ value: string;
4
+ limit: string;
5
+ isOverLimit: boolean;
6
+ "data-element"?: string;
24
7
  }
25
- import PropTypes from "prop-types";
26
- import baseTheme from "../../style/themes/base";
8
+ declare const CharacterCount: ({ value, limit, isOverLimit, "data-element": dataElement, }: CharacterCountProps) => JSX.Element;
9
+ export default CharacterCount;
@@ -3,42 +3,32 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.CharacterCount = exports.default = void 0;
6
+ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _styledComponents = require("styled-components");
13
-
14
- var _base = _interopRequireDefault(require("../../style/themes/base"));
15
-
16
12
  var _characterCount = _interopRequireDefault(require("./character-count.style"));
17
13
 
18
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
15
 
20
- 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); }
21
-
22
16
  const CharacterCount = ({
23
17
  value,
24
18
  limit,
25
- theme,
26
- ...props
27
- }) => /*#__PURE__*/_react.default.createElement(_characterCount.default, _extends({
28
- theme: theme,
29
- "aria-live": "polite"
30
- }, props), `${value}/${limit}`);
19
+ isOverLimit,
20
+ "data-element": dataElement
21
+ }) => /*#__PURE__*/_react.default.createElement(_characterCount.default, {
22
+ "aria-live": "polite",
23
+ isOverLimit: isOverLimit,
24
+ "data-element": dataElement
25
+ }, `${value}/${limit}`);
31
26
 
32
- exports.CharacterCount = CharacterCount;
33
27
  CharacterCount.propTypes = {
34
- value: _propTypes.default.string.isRequired,
35
- limit: _propTypes.default.string.isRequired,
36
- theme: _propTypes.default.object
28
+ "data-element": _propTypes.default.string,
29
+ "isOverLimit": _propTypes.default.bool.isRequired,
30
+ "limit": _propTypes.default.string.isRequired,
31
+ "value": _propTypes.default.string.isRequired
37
32
  };
38
- CharacterCount.defaultProps = {
39
- theme: _base.default
40
- };
41
-
42
- var _default = (0, _styledComponents.withTheme)(CharacterCount);
43
-
33
+ var _default = CharacterCount;
44
34
  exports.default = _default;
@@ -1,2 +1,4 @@
1
+ declare const StyledCharacterCount: import("styled-components").StyledComponent<"div", any, {
2
+ isOverLimit: boolean;
3
+ }, never>;
1
4
  export default StyledCharacterCount;
2
- declare const StyledCharacterCount: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -7,6 +7,10 @@ exports.default = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
 
10
+ var _base = _interopRequireDefault(require("../../style/themes/base"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
10
14
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11
15
 
12
16
  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; }
@@ -26,5 +30,8 @@ const StyledCharacterCount = _styledComponents.default.div`
26
30
  font-weight: 700;
27
31
  `}
28
32
  `;
33
+ StyledCharacterCount.defaultProps = {
34
+ theme: _base.default
35
+ };
29
36
  var _default = StyledCharacterCount;
30
37
  exports.default = _default;
@@ -1,5 +1,5 @@
1
1
  import Input from "./input.component";
2
2
  import InputPresentation from "./input-presentation.component";
3
- export type { InputProps } from "./input.component";
3
+ export type { InputProps, CommonInputProps } from "./input.component";
4
4
  export { Input, InputPresentation };
5
5
  export default Input;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ declare type NumeralContextType = {
3
+ disableErrorBorder?: boolean;
4
+ };
5
+ declare const _default: React.Context<NumeralContextType>;
6
+ export default _default;
@@ -236,7 +236,7 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
236
236
  wrapText: wrapPillText
237
237
  }, pillProps), title));
238
238
  }); // eslint-disable-next-line react-hooks/exhaustive-deps
239
- }, [children, disabled, readOnly, selectedValue]);
239
+ }, [children, disabled, readOnly, actualValue]);
240
240
  (0, _react.useEffect)(() => {
241
241
  const modeSwitchedMessage = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
242
242
  const onChangeMissingMessage = "onChange prop required when using a controlled input element";
@@ -91,6 +91,24 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
91
91
  blockScroll,
92
92
  allowScroll
93
93
  } = (0, _useScrollBlock.default)();
94
+
95
+ const updateListHeight = () => {
96
+ let newHeight = listRef.current.clientHeight;
97
+
98
+ if (listActionButtonRef.current) {
99
+ newHeight += listActionButtonRef.current.parentElement.clientHeight;
100
+ }
101
+
102
+ setListHeight(`${newHeight}px`);
103
+ };
104
+
105
+ const listCallbackRef = (0, _react.useCallback)(element => {
106
+ listRef.current = element;
107
+
108
+ if (element) {
109
+ setTimeout(updateListHeight, 0);
110
+ }
111
+ }, []);
94
112
  (0, _react.useEffect)(() => {
95
113
  blockScroll();
96
114
  return () => {
@@ -255,16 +273,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
255
273
  window.removeEventListener("resize", assignListWidth);
256
274
  };
257
275
  }, [assignListWidth]);
258
- (0, _react.useLayoutEffect)(() => {
259
- let newHeight;
260
- newHeight = listRef.current.clientHeight;
261
-
262
- if (listActionButtonRef.current) {
263
- newHeight += listActionButtonRef.current.parentElement.clientHeight;
264
- }
265
-
266
- setListHeight(`${newHeight}px`);
267
- }, [children]);
276
+ (0, _react.useLayoutEffect)(updateListHeight, [children]);
268
277
  (0, _react.useEffect)(() => {
269
278
  const keyboardEvent = "keydown";
270
279
  const listElement = listRef.current;
@@ -355,7 +364,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
355
364
  "aria-labelledby": labelId,
356
365
  "data-element": "select-list",
357
366
  role: "listbox",
358
- ref: listRef,
367
+ ref: listCallbackRef,
359
368
  tabIndex: "-1",
360
369
  isLoading: isLoading,
361
370
  multiColumn: multiColumn
@@ -15,7 +15,7 @@ var _input = require("../../__internal__/input");
15
15
 
16
16
  var _formField = _interopRequireDefault(require("../../__internal__/form-field"));
17
17
 
18
- var _characterCount = _interopRequireDefault(require("../../__internal__/character-count"));
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: enforceCharacterLimit && characterLimit ? characterLimit : undefined,
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 */
@@ -0,0 +1,2 @@
1
+ declare const StyledPrefix: import("styled-components").StyledComponent<"span", any, {}, never>;
2
+ export default StyledPrefix;
@@ -1 +1,2 @@
1
- export { default, TextboxProps, CommonTextboxProps } from "./textbox";
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
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
13
+ var _textbox = _interopRequireDefault(require("./textbox.component"));
22
14
 
23
- 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; }
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;