carbon-react 110.1.3 → 110.2.2

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 (65) 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/__spec_helper__/test-utils.d.ts +3 -2
  7. package/esm/__spec_helper__/test-utils.js +17 -1
  8. package/esm/components/box/box.component.d.ts +4 -2
  9. package/esm/components/box/box.component.js +2 -1
  10. package/esm/components/dismissible-box/dismissible-box.component.js +398 -0
  11. package/esm/components/numeral-date/numeral-date-context.d.ts +6 -0
  12. package/esm/components/popover-container/popover-container.component.d.ts +2 -0
  13. package/esm/components/popover-container/popover-container.component.js +9 -4
  14. package/esm/components/portal/portal.d.ts +15 -12
  15. package/esm/components/portal/portal.js +3 -13
  16. package/esm/components/select/multi-select/multi-select.component.js +1 -1
  17. package/esm/components/select/select-list/select-list.component.js +20 -11
  18. package/esm/components/textarea/textarea.component.js +6 -27
  19. package/esm/components/textarea/textarea.d.ts +2 -1
  20. package/esm/components/textbox/__internal__/prefix.style.d.ts +2 -0
  21. package/esm/components/textbox/index.d.ts +2 -1
  22. package/esm/components/textbox/index.js +1 -1
  23. package/esm/components/textbox/textbox.component.d.ts +92 -0
  24. package/esm/components/textbox/textbox.component.js +533 -197
  25. package/esm/components/textbox/textbox.style.d.ts +5 -0
  26. package/esm/components/textbox/textbox.style.js +0 -12
  27. package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +1 -1
  28. package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.js +7 -6
  29. package/esm/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +6 -5
  30. package/esm/style/utils/filter-out-position-props.d.ts +3 -0
  31. package/esm/style/utils/filter-out-position-props.js +5 -0
  32. package/lib/__internal__/character-count/character-count.component.d.ts +8 -25
  33. package/lib/__internal__/character-count/character-count.component.js +13 -23
  34. package/lib/__internal__/character-count/character-count.style.d.ts +3 -1
  35. package/lib/__internal__/character-count/character-count.style.js +7 -0
  36. package/lib/__internal__/input/index.d.ts +1 -1
  37. package/lib/__spec_helper__/test-utils.d.ts +3 -2
  38. package/lib/__spec_helper__/test-utils.js +20 -2
  39. package/lib/components/box/box.component.d.ts +4 -2
  40. package/lib/components/box/box.component.js +1 -0
  41. package/lib/components/dismissible-box/dismissible-box.component.js +398 -0
  42. package/lib/components/numeral-date/numeral-date-context.d.ts +6 -0
  43. package/lib/components/popover-container/popover-container.component.d.ts +2 -0
  44. package/lib/components/popover-container/popover-container.component.js +9 -4
  45. package/lib/components/portal/portal.d.ts +15 -12
  46. package/lib/components/portal/portal.js +3 -14
  47. package/lib/components/select/multi-select/multi-select.component.js +1 -1
  48. package/lib/components/select/select-list/select-list.component.js +20 -11
  49. package/lib/components/textarea/textarea.component.js +6 -27
  50. package/lib/components/textarea/textarea.d.ts +2 -1
  51. package/lib/components/textbox/__internal__/prefix.style.d.ts +2 -0
  52. package/lib/components/textbox/index.d.ts +2 -1
  53. package/lib/components/textbox/index.js +2 -10
  54. package/lib/components/textbox/textbox.component.d.ts +92 -0
  55. package/lib/components/textbox/textbox.component.js +534 -201
  56. package/lib/components/textbox/textbox.style.d.ts +5 -0
  57. package/lib/components/textbox/textbox.style.js +1 -16
  58. package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +1 -1
  59. package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.js +7 -6
  60. package/lib/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +6 -5
  61. package/lib/style/utils/filter-out-position-props.d.ts +3 -0
  62. package/lib/style/utils/filter-out-position-props.js +18 -0
  63. package/package.json +1 -1
  64. package/esm/components/textbox/textbox.d.ts +0 -125
  65. 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 };
@@ -7,10 +7,6 @@ exports.ErrorBorder = exports.StyledHintText = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
 
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
15
11
 
16
12
  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; }
@@ -35,15 +31,4 @@ const StyledHintText = _styledComponents.default.p`
35
31
  color: var(--colorsUtilityYin055);
36
32
  font-size: 14px;
37
33
  `;
38
- exports.StyledHintText = StyledHintText;
39
- StyledHintText.defaultProps = {
40
- size: "medium"
41
- };
42
- ErrorBorder.propTypes = {
43
- warning: _propTypes.default.bool,
44
- size: _propTypes.default.string
45
- };
46
- ErrorBorder.defaultProps = {
47
- warning: false,
48
- size: "medium"
49
- };
34
+ exports.StyledHintText = StyledHintText;
@@ -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;
@@ -19,19 +19,20 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
19
19
 
20
20
  const getFormatNumber = (value, locale) => new Intl.NumberFormat(locale).format(value);
21
21
 
22
- const useCharacterCount = (value, characterLimit, warnOverLimit = false, enforceCharacterLimit = true) => {
22
+ const useCharacterCount = (value = "", characterLimit, warnOverLimit = false, enforceCharacterLimit = true) => {
23
+ const isCharacterLimitValid = typeof characterLimit === "number" && !Number.isNaN(characterLimit);
23
24
  const l = (0, _useLocale.default)();
24
25
  const isOverLimit = (0, _react.useMemo)(() => {
25
- if (value && characterLimit) {
26
- return value.length > parseInt(characterLimit, 10);
26
+ if (value && isCharacterLimitValid) {
27
+ return value.length > characterLimit;
27
28
  }
28
29
 
29
30
  return false;
30
- }, [value, characterLimit]);
31
- return [enforceCharacterLimit && characterLimit ? characterLimit : undefined, characterLimit ? /*#__PURE__*/_react.default.createElement(_characterCount.default, {
31
+ }, [value, characterLimit, isCharacterLimitValid]);
32
+ return [enforceCharacterLimit && isCharacterLimitValid ? characterLimit : undefined, isCharacterLimitValid ? /*#__PURE__*/_react.default.createElement(_characterCount.default, {
32
33
  isOverLimit: isOverLimit && warnOverLimit,
33
34
  value: getFormatNumber(value.length, l.locale()),
34
- limit: getFormatNumber(+characterLimit, l.locale()),
35
+ limit: getFormatNumber(characterLimit, l.locale()),
35
36
  "data-element": "character-limit"
36
37
  }) : null];
37
38
  };
@@ -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;
@@ -0,0 +1,3 @@
1
+ import { PositionProps } from "styled-system";
2
+ export declare const positionPropertyNames: string[];
3
+ export default function filterStyledSystemPositionProps(originalObject: Record<string, unknown> | PositionProps): PositionProps;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = filterStyledSystemPositionProps;
7
+ exports.positionPropertyNames = void 0;
8
+
9
+ var _filterObjectProperties = _interopRequireDefault(require("../../__internal__/filter-object-properties"));
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
13
+ const positionPropertyNames = ["top", "right", "bottom", "left", "position"];
14
+ exports.positionPropertyNames = positionPropertyNames;
15
+
16
+ function filterStyledSystemPositionProps(originalObject) {
17
+ return (0, _filterObjectProperties.default)(originalObject, positionPropertyNames);
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "110.1.3",
3
+ "version": "110.2.2",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {
@@ -1,125 +0,0 @@
1
- import * as React from "react";
2
- import { MarginProps } from "styled-system";
3
-
4
- import { ValidationProps } from "../../__internal__/validations";
5
- import { CommonInputProps } from "../../__internal__/input";
6
-
7
- export interface CommonTextboxProps
8
- extends ValidationProps,
9
- MarginProps,
10
- Omit<CommonInputProps, "size"> {
11
- /** Automatically focus the input on component mount */
12
- autoFocus?: boolean;
13
- /* The default value alignment on the input */
14
- align?: "right" | "left";
15
- /** Identifier used for testing purposes, applied to the root element of the component. */
16
- "data-component"?: string;
17
- /** Identifier used for testing purposes, applied to the root element of the component. */
18
- "data-element"?: string;
19
- /** Identifier used for testing purposes, applied to the root element of the component. */
20
- "data-role"?: string;
21
- /** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
22
- adaptiveLabelBreakpoint?: number;
23
- /** Integer to determine a timeout for the deferred callback */
24
- deferTimeout?: number;
25
- /** If true, the component will be disabled */
26
- disabled?: boolean;
27
- /** Help content to be displayed under an input */
28
- fieldHelp?: React.ReactNode;
29
- /**
30
- * An optional alternative for props.value, this is useful if the
31
- * real value is an ID but you want to show a human-readable version.
32
- */
33
- formattedValue?: string;
34
- /** Unique identifier for the input. Will use a randomly generated GUID if none is provided */
35
- id?: string;
36
- /** Type of the icon that will be rendered next to the input */
37
- inputIcon?: string;
38
- /** Optional handler for click event on Textbox icon */
39
- iconOnClick?: (ev: React.MouseEvent<HTMLElement>) => void;
40
- /** Overrides the default tabindex of the component */
41
- iconTabIndex?: string | number;
42
- /** The width of the input as a percentage */
43
- inputWidth?: number;
44
- /** Additional child elements to display before the input */
45
- leftChildren?: React.ReactNode;
46
- /** Label content */
47
- label?: string;
48
- /** Inline label alignment */
49
- labelAlign?: "left" | "right";
50
- /** A message that the Help component will display */
51
- labelHelp?: React.ReactNode;
52
- /** When true label is inline */
53
- labelInline?: boolean;
54
- /** Spacing between label and a field for inline label, given number will be multiplied by base spacing unit (8) */
55
- labelSpacing?: 1 | 2;
56
- /** Label width */
57
- labelWidth?: number;
58
- /** Specify a callback triggered on change */
59
- onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
60
- /** Deferred callback to be called after the onChange event */
61
- onChangeDeferred?: () => void;
62
- /** Specify a callback triggered on click */
63
- onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
64
- /** Event handler for the focus event */
65
- onFocus?: (ev: React.FocusEvent<HTMLInputElement>) => void;
66
- /** Event handler for the blur event */
67
- onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
68
- /** Event handler for the mouse down event */
69
- onMouseDown?: (ev: React.MouseEvent<HTMLElement>) => void;
70
- /** Input name */
71
- name?: string;
72
- /** Placeholder string to be displayed in input */
73
- placeholder?: string;
74
- /** Emphasized part of the displayed text */
75
- prefix?: string;
76
- /** Reverses label and input display */
77
- reverse?: boolean;
78
- /** The unformatted value */
79
- rawValue?: string;
80
- /** If true, the component will be read-only */
81
- readOnly?: boolean;
82
- /** Flag to configure component as mandatory */
83
- required?: boolean;
84
- /** Size of an input */
85
- size?: "small" | "medium" | "large";
86
- /** When true, validation icon will be placed on label instead of being placed on the input */
87
- validationOnLabel?: boolean;
88
- /** The value of the Input */
89
- value?:
90
- | string
91
- | string[]
92
- | Record<string, unknown>
93
- | Record<string, unknown>[];
94
- /** A callback to retrieve the input reference */
95
- inputRef?: (input: React.RefObject<HTMLInputElement>) => void;
96
- /** Overrides the default tooltip position */
97
- tooltipPosition?: "top" | "bottom" | "left" | "right";
98
- /** Aria label for rendered help component */
99
- helpAriaLabel?: string;
100
- }
101
-
102
- export interface TextboxProps extends CommonTextboxProps {
103
- /** Content to be rendered next to the input */
104
- children?: React.ReactNode;
105
- /** [Legacy] Flag to configure component as optional in Form */
106
- isOptional?: boolean;
107
- /** Container for DatePicker or SelectList components */
108
- positionedChildren?: React.ReactNode;
109
- /** Label id passed from Select component */
110
- labelId?: string;
111
- /** Character limit of the textarea */
112
- characterLimit?: string;
113
- /** Stop the user typing over the characterLimit */
114
- enforceCharacterLimit?: boolean;
115
- /** Whether to display the character count message in red */
116
- warnOverLimit?: boolean;
117
- }
118
-
119
- declare function Textbox(props: TextboxProps): JSX.Element;
120
- declare function TextboxWithUniqueIdProps(
121
- props: TextboxProps & React.RefAttributes<HTMLInputElement>
122
- ): JSX.Element;
123
-
124
- export { Textbox as OriginalTextbox };
125
- export default TextboxWithUniqueIdProps;
@@ -1,125 +0,0 @@
1
- import * as React from "react";
2
- import { MarginProps } from "styled-system";
3
-
4
- import { ValidationProps } from "../../__internal__/validations";
5
- import { CommonInputProps } from "../../__internal__/input";
6
-
7
- export interface CommonTextboxProps
8
- extends ValidationProps,
9
- MarginProps,
10
- Omit<CommonInputProps, "size"> {
11
- /** Automatically focus the input on component mount */
12
- autoFocus?: boolean;
13
- /* The default value alignment on the input */
14
- align?: "right" | "left";
15
- /** Identifier used for testing purposes, applied to the root element of the component. */
16
- "data-component"?: string;
17
- /** Identifier used for testing purposes, applied to the root element of the component. */
18
- "data-element"?: string;
19
- /** Identifier used for testing purposes, applied to the root element of the component. */
20
- "data-role"?: string;
21
- /** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
22
- adaptiveLabelBreakpoint?: number;
23
- /** Integer to determine a timeout for the deferred callback */
24
- deferTimeout?: number;
25
- /** If true, the component will be disabled */
26
- disabled?: boolean;
27
- /** Help content to be displayed under an input */
28
- fieldHelp?: React.ReactNode;
29
- /**
30
- * An optional alternative for props.value, this is useful if the
31
- * real value is an ID but you want to show a human-readable version.
32
- */
33
- formattedValue?: string;
34
- /** Unique identifier for the input. Will use a randomly generated GUID if none is provided */
35
- id?: string;
36
- /** Type of the icon that will be rendered next to the input */
37
- inputIcon?: string;
38
- /** Optional handler for click event on Textbox icon */
39
- iconOnClick?: (ev: React.MouseEvent<HTMLElement>) => void;
40
- /** Overrides the default tabindex of the component */
41
- iconTabIndex?: string | number;
42
- /** The width of the input as a percentage */
43
- inputWidth?: number;
44
- /** Additional child elements to display before the input */
45
- leftChildren?: React.ReactNode;
46
- /** Label content */
47
- label?: string;
48
- /** Inline label alignment */
49
- labelAlign?: "left" | "right";
50
- /** A message that the Help component will display */
51
- labelHelp?: React.ReactNode;
52
- /** When true label is inline */
53
- labelInline?: boolean;
54
- /** Spacing between label and a field for inline label, given number will be multiplied by base spacing unit (8) */
55
- labelSpacing?: 1 | 2;
56
- /** Label width */
57
- labelWidth?: number;
58
- /** Specify a callback triggered on change */
59
- onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
60
- /** Deferred callback to be called after the onChange event */
61
- onChangeDeferred?: () => void;
62
- /** Specify a callback triggered on click */
63
- onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
64
- /** Event handler for the focus event */
65
- onFocus?: (ev: React.FocusEvent<HTMLInputElement>) => void;
66
- /** Event handler for the blur event */
67
- onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
68
- /** Event handler for the mouse down event */
69
- onMouseDown?: (ev: React.MouseEvent<HTMLElement>) => void;
70
- /** Input name */
71
- name?: string;
72
- /** Placeholder string to be displayed in input */
73
- placeholder?: string;
74
- /** Emphasized part of the displayed text */
75
- prefix?: string;
76
- /** Reverses label and input display */
77
- reverse?: boolean;
78
- /** The unformatted value */
79
- rawValue?: string;
80
- /** If true, the component will be read-only */
81
- readOnly?: boolean;
82
- /** Flag to configure component as mandatory */
83
- required?: boolean;
84
- /** Size of an input */
85
- size?: "small" | "medium" | "large";
86
- /** When true, validation icon will be placed on label instead of being placed on the input */
87
- validationOnLabel?: boolean;
88
- /** The value of the Input */
89
- value?:
90
- | string
91
- | string[]
92
- | Record<string, unknown>
93
- | Record<string, unknown>[];
94
- /** A callback to retrieve the input reference */
95
- inputRef?: (input: React.RefObject<HTMLInputElement>) => void;
96
- /** Overrides the default tooltip position */
97
- tooltipPosition?: "top" | "bottom" | "left" | "right";
98
- /** Aria label for rendered help component */
99
- helpAriaLabel?: string;
100
- }
101
-
102
- export interface TextboxProps extends CommonTextboxProps {
103
- /** Content to be rendered next to the input */
104
- children?: React.ReactNode;
105
- /** [Legacy] Flag to configure component as optional in Form */
106
- isOptional?: boolean;
107
- /** Container for DatePicker or SelectList components */
108
- positionedChildren?: React.ReactNode;
109
- /** Label id passed from Select component */
110
- labelId?: string;
111
- /** Character limit of the textarea */
112
- characterLimit?: string;
113
- /** Stop the user typing over the characterLimit */
114
- enforceCharacterLimit?: boolean;
115
- /** Whether to display the character count message in red */
116
- warnOverLimit?: boolean;
117
- }
118
-
119
- declare function Textbox(props: TextboxProps): JSX.Element;
120
- declare function TextboxWithUniqueIdProps(
121
- props: TextboxProps & React.RefAttributes<HTMLInputElement>
122
- ): JSX.Element;
123
-
124
- export { Textbox as OriginalTextbox };
125
- export default TextboxWithUniqueIdProps;