carbon-react 104.58.5 → 104.58.8

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 (27) hide show
  1. package/esm/components/message/message-content/message-content.component.d.ts +3 -13
  2. package/esm/components/message/message-content/message-content.component.js +1 -12
  3. package/esm/components/message/message.component.js +1 -3
  4. package/esm/components/message/message.d.ts +1 -9
  5. package/esm/components/message/type-icon/type-icon.component.js +1 -1
  6. package/esm/components/message/type-icon/type-icon.style.js +1 -1
  7. package/esm/components/pager/pager.component.js +1 -2
  8. package/esm/components/textarea/textarea.component.js +7 -3
  9. package/esm/components/textarea/textarea.style.d.ts +1 -0
  10. package/esm/components/textarea/textarea.style.js +2 -1
  11. package/esm/components/toast/toast.component.js +3 -3
  12. package/esm/components/toast/toast.config.js +1 -1
  13. package/esm/components/toast/toast.d.ts +4 -18
  14. package/lib/components/message/message-content/message-content.component.d.ts +3 -13
  15. package/lib/components/message/message-content/message-content.component.js +1 -12
  16. package/lib/components/message/message.component.js +1 -3
  17. package/lib/components/message/message.d.ts +1 -9
  18. package/lib/components/message/type-icon/type-icon.component.js +1 -1
  19. package/lib/components/message/type-icon/type-icon.style.js +1 -1
  20. package/lib/components/pager/pager.component.js +1 -2
  21. package/lib/components/textarea/textarea.component.js +7 -3
  22. package/lib/components/textarea/textarea.style.d.ts +1 -0
  23. package/lib/components/textarea/textarea.style.js +4 -2
  24. package/lib/components/toast/toast.component.js +3 -3
  25. package/lib/components/toast/toast.config.js +1 -1
  26. package/lib/components/toast/toast.d.ts +4 -18
  27. package/package.json +1 -1
@@ -1,22 +1,12 @@
1
1
  export default MessageContent;
2
- declare function MessageContent({ variant, title, transparent, children }: {
3
- variant: any;
2
+ declare function MessageContent({ title, children }: {
4
3
  title: any;
5
- transparent: any;
6
4
  children: any;
7
5
  }): JSX.Element;
8
6
  declare namespace MessageContent {
9
- namespace defaultProps {
10
- const variant: string;
11
- const transparent: boolean;
12
- }
13
7
  namespace propTypes {
14
- const variant_1: PropTypes.Requireable<string>;
15
- export { variant_1 as variant };
16
- export const title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
17
- const transparent_1: PropTypes.Requireable<boolean>;
18
- export { transparent_1 as transparent };
19
- export const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
8
+ const title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
9
+ const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
20
10
  }
21
11
  }
22
12
  import PropTypes from "prop-types";
@@ -4,28 +4,17 @@ import Content from "../../content/content.component.js";
4
4
  import MessageContentStyle from "./message-content.style";
5
5
 
6
6
  const MessageContent = ({
7
- variant,
8
7
  title,
9
- transparent,
10
8
  children
11
9
  }) => {
12
- return /*#__PURE__*/React.createElement(MessageContentStyle, {
13
- variant: variant,
14
- transparent: transparent
15
- }, /*#__PURE__*/React.createElement(Content, {
10
+ return /*#__PURE__*/React.createElement(MessageContentStyle, null, /*#__PURE__*/React.createElement(Content, {
16
11
  title: title,
17
12
  className: "message-content"
18
13
  }, children));
19
14
  };
20
15
 
21
- MessageContent.defaultProps = {
22
- variant: "info",
23
- transparent: false
24
- };
25
16
  MessageContent.propTypes = {
26
- variant: PropTypes.oneOf(["default", "error", "help", "info", "maintenance", "new", "success", "warning"]),
27
17
  title: PropTypes.node,
28
- transparent: PropTypes.bool,
29
18
  children: PropTypes.node
30
19
  };
31
20
  export default MessageContent;
@@ -51,8 +51,6 @@ const Message = ({
51
51
  variant: variant,
52
52
  transparent: transparent
53
53
  }), /*#__PURE__*/React.createElement(MessageContent, {
54
- variant: variant,
55
- transparent: transparent,
56
54
  title: title
57
55
  }, children), renderCloseIcon());
58
56
  };
@@ -60,7 +58,7 @@ const Message = ({
60
58
  Message.propTypes = { ...marginPropTypes,
61
59
 
62
60
  /** set type of message based on new DLS standard */
63
- variant: PropTypes.oneOf(["default", "error", "help", "info", "maintenance", "new", "success", "warning"]),
61
+ variant: PropTypes.oneOf(["error", "info", "success", "warning"]),
64
62
 
65
63
  /** set content to component */
66
64
  children: PropTypes.node,
@@ -21,15 +21,7 @@ export interface MessageProps extends MarginProps {
21
21
  /** set background to be invisible */
22
22
  transparent?: boolean;
23
23
  /** set type of message based on new DLS standard */
24
- variant?:
25
- | "default"
26
- | "error"
27
- | "help"
28
- | "info"
29
- | "maintenance"
30
- | "new"
31
- | "success"
32
- | "warning";
24
+ variant?: "error" | "info" | "success" | "warning";
33
25
  }
34
26
 
35
27
  declare function Message(props: MessageProps): JSX.Element;
@@ -20,7 +20,7 @@ TypeIcon.defaultProps = {
20
20
  transparent: false
21
21
  };
22
22
  TypeIcon.propTypes = {
23
- variant: PropTypes.oneOf(["default", "error", "help", "info", "maintenance", "new", "success", "warning"]),
23
+ variant: PropTypes.oneOf(["error", "info", "success", "warning"]),
24
24
  transparent: PropTypes.bool
25
25
  };
26
26
  export default TypeIcon;
@@ -39,7 +39,7 @@ TypeIconStyle.defaultProps = {
39
39
  transparent: false
40
40
  };
41
41
  TypeIconStyle.propTypes = {
42
- variant: PropTypes.oneOf(["default", "error", "help", "info", "maintenance", "new", "success", "warning"]),
42
+ variant: PropTypes.oneOf(["error", "info", "success", "warning"]),
43
43
  border: PropTypes.bool,
44
44
  transparent: PropTypes.bool
45
45
  };
@@ -110,8 +110,7 @@ const Pager = ({
110
110
  onChange: ev => setValue(ev.target.value),
111
111
  onBlur: () => setValue(currentPageSize),
112
112
  onKeyDown: handleKeyDown,
113
- "data-element": "page-select",
114
- id: "page-select"
113
+ "data-element": "page-select"
115
114
  }, pageSizeSelectionOptions.map(sizeOption => /*#__PURE__*/React.createElement(Option, {
116
115
  key: sizeOption.id,
117
116
  text: sizeOption.id,
@@ -11,7 +11,7 @@ import { InputBehaviour } from "../../__internal__/input-behaviour";
11
11
  import { filterStyledSystemMarginProps } from "../../style/utils";
12
12
  import InputIconToggle from "../../__internal__/input-icon-toggle";
13
13
  import guid from "../../__internal__/utils/helpers/guid";
14
- import StyledTextarea from "./textarea.style";
14
+ import StyledTextarea, { MIN_HEIGHT } from "./textarea.style";
15
15
  import LocaleContext from "../../__internal__/i18n-context";
16
16
  import { TooltipProvider } from "../../__internal__/tooltip-provider";
17
17
  import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility";
@@ -72,13 +72,12 @@ const Textarea = ({
72
72
  current: id
73
73
  } = useRef(idProp || guid());
74
74
  const inputRef = useRef();
75
- const minHeight = useRef(0);
75
+ const minHeight = useRef(MIN_HEIGHT);
76
76
 
77
77
  const expandTextarea = () => {
78
78
  const textarea = inputRef.current;
79
79
 
80
80
  if (textarea.scrollHeight > minHeight.current) {
81
- // Reset height to zero - IE specific
82
81
  textarea.style.height = "0px"; // Set the height so all content is shown
83
82
 
84
83
  textarea.style.height = `${Math.max(textarea.scrollHeight, minHeight.current)}px`;
@@ -99,6 +98,11 @@ const Textarea = ({
99
98
  label,
100
99
  fieldHelp
101
100
  });
101
+ useEffect(() => {
102
+ if (rows) {
103
+ minHeight.current = inputRef.current.scrollHeight;
104
+ }
105
+ }, [rows]);
102
106
  useEffect(() => {
103
107
  if (expandable) {
104
108
  expandTextarea();
@@ -1,2 +1,3 @@
1
+ export const MIN_HEIGHT: 40;
1
2
  export default StyledTextarea;
2
3
  declare const StyledTextarea: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -4,12 +4,13 @@ import StyledInput from "../../__internal__/input/input.style";
4
4
  import { StyledLabelContainer } from "../../__internal__/label/label.style";
5
5
  import InputIconToggleStyle from "../../__internal__/input-icon-toggle/input-icon-toggle.style";
6
6
  import BaseTheme from "../../style/themes/base";
7
+ export const MIN_HEIGHT = 40;
7
8
  const StyledTextarea = styled.div`
8
9
  ${margin};
9
10
 
10
11
  ${StyledInput} {
11
12
  resize: none;
12
- min-height: 40px;
13
+ min-height: ${MIN_HEIGHT}px;
13
14
  margin-top: 5px;
14
15
  margin-bottom: 5px;
15
16
  }
@@ -13,7 +13,7 @@ import Events from "../../__internal__/utils/helpers/events";
13
13
  import useLocale from "../../hooks/__internal__/useLocale";
14
14
 
15
15
  const Toast = ({
16
- as = "warning",
16
+ as = "success",
17
17
  children,
18
18
  className,
19
19
  id,
@@ -109,10 +109,10 @@ const Toast = ({
109
109
 
110
110
  Toast.propTypes = {
111
111
  /** Customizes the appearance in the DLS theme */
112
- variant: PropTypes.oneOf(["default", "error", "help", "info", "maintenance", "new", "success", "warning"]),
112
+ variant: PropTypes.oneOf(["error", "info", "success", "warning"]),
113
113
 
114
114
  /** Customizes the appearance in a legacy theme through colour (see the 'iconColorSets' for possible values) */
115
- as: PropTypes.oneOf(["default", "error", "help", "info", "maintenance", "new", "success", "warning"]),
115
+ as: PropTypes.oneOf(["error", "info", "success", "warning"]),
116
116
 
117
117
  /** Custom className */
118
118
  className: PropTypes.string,
@@ -1,2 +1,2 @@
1
1
  // eslint-disable-next-line import/prefer-default-export
2
- export const TOAST_COLORS = ["default", "error", "help", "info", "maintenance", "new", "success", "warning"];
2
+ export const TOAST_COLORS = ["error", "info", "success", "warning"];
@@ -1,28 +1,14 @@
1
1
  import * as React from "react";
2
2
 
3
+ type ToastVariants = "error" | "info" | "success" | "warning";
4
+
3
5
  export interface ToastPropTypes {
4
6
  /** The rendered children of the component. */
5
7
  children: React.ReactNode;
6
8
  /** Customizes the appearance in the DLS theme */
7
- variant?:
8
- | "default"
9
- | "error"
10
- | "help"
11
- | "info"
12
- | "maintenance"
13
- | "new"
14
- | "success"
15
- | "warning";
9
+ variant?: ToastVariants;
16
10
  /** Customizes the appearance in a legacy theme through colour (see the 'iconColorSets' for possible values) */
17
- as?:
18
- | "default"
19
- | "error"
20
- | "help"
21
- | "info"
22
- | "maintenance"
23
- | "new"
24
- | "success"
25
- | "warning";
11
+ as?: ToastVariants;
26
12
  /** Custom className */
27
13
  className?: string;
28
14
  /** Custom id */
@@ -1,22 +1,12 @@
1
1
  export default MessageContent;
2
- declare function MessageContent({ variant, title, transparent, children }: {
3
- variant: any;
2
+ declare function MessageContent({ title, children }: {
4
3
  title: any;
5
- transparent: any;
6
4
  children: any;
7
5
  }): JSX.Element;
8
6
  declare namespace MessageContent {
9
- namespace defaultProps {
10
- const variant: string;
11
- const transparent: boolean;
12
- }
13
7
  namespace propTypes {
14
- const variant_1: PropTypes.Requireable<string>;
15
- export { variant_1 as variant };
16
- export const title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
17
- const transparent_1: PropTypes.Requireable<boolean>;
18
- export { transparent_1 as transparent };
19
- export const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
8
+ const title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
9
+ const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
20
10
  }
21
11
  }
22
12
  import PropTypes from "prop-types";
@@ -16,28 +16,17 @@ var _messageContent = _interopRequireDefault(require("./message-content.style"))
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
18
  const MessageContent = ({
19
- variant,
20
19
  title,
21
- transparent,
22
20
  children
23
21
  }) => {
24
- return /*#__PURE__*/_react.default.createElement(_messageContent.default, {
25
- variant: variant,
26
- transparent: transparent
27
- }, /*#__PURE__*/_react.default.createElement(_contentComponent.default, {
22
+ return /*#__PURE__*/_react.default.createElement(_messageContent.default, null, /*#__PURE__*/_react.default.createElement(_contentComponent.default, {
28
23
  title: title,
29
24
  className: "message-content"
30
25
  }, children));
31
26
  };
32
27
 
33
- MessageContent.defaultProps = {
34
- variant: "info",
35
- transparent: false
36
- };
37
28
  MessageContent.propTypes = {
38
- variant: _propTypes.default.oneOf(["default", "error", "help", "info", "maintenance", "new", "success", "warning"]),
39
29
  title: _propTypes.default.node,
40
- transparent: _propTypes.default.bool,
41
30
  children: _propTypes.default.node
42
31
  };
43
32
  var _default = MessageContent;
@@ -71,8 +71,6 @@ const Message = ({
71
71
  variant: variant,
72
72
  transparent: transparent
73
73
  }), /*#__PURE__*/_react.default.createElement(_messageContent.default, {
74
- variant: variant,
75
- transparent: transparent,
76
74
  title: title
77
75
  }, children), renderCloseIcon());
78
76
  };
@@ -80,7 +78,7 @@ const Message = ({
80
78
  Message.propTypes = { ...marginPropTypes,
81
79
 
82
80
  /** set type of message based on new DLS standard */
83
- variant: _propTypes.default.oneOf(["default", "error", "help", "info", "maintenance", "new", "success", "warning"]),
81
+ variant: _propTypes.default.oneOf(["error", "info", "success", "warning"]),
84
82
 
85
83
  /** set content to component */
86
84
  children: _propTypes.default.node,
@@ -21,15 +21,7 @@ export interface MessageProps extends MarginProps {
21
21
  /** set background to be invisible */
22
22
  transparent?: boolean;
23
23
  /** set type of message based on new DLS standard */
24
- variant?:
25
- | "default"
26
- | "error"
27
- | "help"
28
- | "info"
29
- | "maintenance"
30
- | "new"
31
- | "success"
32
- | "warning";
24
+ variant?: "error" | "info" | "success" | "warning";
33
25
  }
34
26
 
35
27
  declare function Message(props: MessageProps): JSX.Element;
@@ -32,7 +32,7 @@ TypeIcon.defaultProps = {
32
32
  transparent: false
33
33
  };
34
34
  TypeIcon.propTypes = {
35
- variant: _propTypes.default.oneOf(["default", "error", "help", "info", "maintenance", "new", "success", "warning"]),
35
+ variant: _propTypes.default.oneOf(["error", "info", "success", "warning"]),
36
36
  transparent: _propTypes.default.bool
37
37
  };
38
38
  var _default = TypeIcon;
@@ -54,7 +54,7 @@ TypeIconStyle.defaultProps = {
54
54
  transparent: false
55
55
  };
56
56
  TypeIconStyle.propTypes = {
57
- variant: _propTypes.default.oneOf(["default", "error", "help", "info", "maintenance", "new", "success", "warning"]),
57
+ variant: _propTypes.default.oneOf(["error", "info", "success", "warning"]),
58
58
  border: _propTypes.default.bool,
59
59
  transparent: _propTypes.default.bool
60
60
  };
@@ -130,8 +130,7 @@ const Pager = ({
130
130
  onChange: ev => setValue(ev.target.value),
131
131
  onBlur: () => setValue(currentPageSize),
132
132
  onKeyDown: handleKeyDown,
133
- "data-element": "page-select",
134
- id: "page-select"
133
+ "data-element": "page-select"
135
134
  }, pageSizeSelectionOptions.map(sizeOption => /*#__PURE__*/_react.default.createElement(_option.default, {
136
135
  key: sizeOption.id,
137
136
  text: sizeOption.id,
@@ -27,7 +27,7 @@ var _inputIconToggle = _interopRequireDefault(require("../../__internal__/input-
27
27
 
28
28
  var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
29
29
 
30
- var _textarea = _interopRequireDefault(require("./textarea.style"));
30
+ var _textarea = _interopRequireWildcard(require("./textarea.style"));
31
31
 
32
32
  var _i18nContext = _interopRequireDefault(require("../../__internal__/i18n-context"));
33
33
 
@@ -102,13 +102,12 @@ const Textarea = ({
102
102
  current: id
103
103
  } = (0, _react.useRef)(idProp || (0, _guid.default)());
104
104
  const inputRef = (0, _react.useRef)();
105
- const minHeight = (0, _react.useRef)(0);
105
+ const minHeight = (0, _react.useRef)(_textarea.MIN_HEIGHT);
106
106
 
107
107
  const expandTextarea = () => {
108
108
  const textarea = inputRef.current;
109
109
 
110
110
  if (textarea.scrollHeight > minHeight.current) {
111
- // Reset height to zero - IE specific
112
111
  textarea.style.height = "0px"; // Set the height so all content is shown
113
112
 
114
113
  textarea.style.height = `${Math.max(textarea.scrollHeight, minHeight.current)}px`;
@@ -129,6 +128,11 @@ const Textarea = ({
129
128
  label,
130
129
  fieldHelp
131
130
  });
131
+ (0, _react.useEffect)(() => {
132
+ if (rows) {
133
+ minHeight.current = inputRef.current.scrollHeight;
134
+ }
135
+ }, [rows]);
132
136
  (0, _react.useEffect)(() => {
133
137
  if (expandable) {
134
138
  expandTextarea();
@@ -1,2 +1,3 @@
1
+ export const MIN_HEIGHT: 40;
1
2
  export default StyledTextarea;
2
3
  declare const StyledTextarea: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.MIN_HEIGHT = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
 
@@ -23,12 +23,14 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
23
23
 
24
24
  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; }
25
25
 
26
+ const MIN_HEIGHT = 40;
27
+ exports.MIN_HEIGHT = MIN_HEIGHT;
26
28
  const StyledTextarea = _styledComponents.default.div`
27
29
  ${_styledSystem.margin};
28
30
 
29
31
  ${_input.default} {
30
32
  resize: none;
31
- min-height: 40px;
33
+ min-height: ${MIN_HEIGHT}px;
32
34
  margin-top: 5px;
33
35
  margin-bottom: 5px;
34
36
  }
@@ -36,7 +36,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
36
36
  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); }
37
37
 
38
38
  const Toast = ({
39
- as = "warning",
39
+ as = "success",
40
40
  children,
41
41
  className,
42
42
  id,
@@ -135,10 +135,10 @@ const Toast = ({
135
135
 
136
136
  Toast.propTypes = {
137
137
  /** Customizes the appearance in the DLS theme */
138
- variant: _propTypes.default.oneOf(["default", "error", "help", "info", "maintenance", "new", "success", "warning"]),
138
+ variant: _propTypes.default.oneOf(["error", "info", "success", "warning"]),
139
139
 
140
140
  /** Customizes the appearance in a legacy theme through colour (see the 'iconColorSets' for possible values) */
141
- as: _propTypes.default.oneOf(["default", "error", "help", "info", "maintenance", "new", "success", "warning"]),
141
+ as: _propTypes.default.oneOf(["error", "info", "success", "warning"]),
142
142
 
143
143
  /** Custom className */
144
144
  className: _propTypes.default.string,
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.TOAST_COLORS = void 0;
7
7
  // eslint-disable-next-line import/prefer-default-export
8
- const TOAST_COLORS = ["default", "error", "help", "info", "maintenance", "new", "success", "warning"];
8
+ const TOAST_COLORS = ["error", "info", "success", "warning"];
9
9
  exports.TOAST_COLORS = TOAST_COLORS;
@@ -1,28 +1,14 @@
1
1
  import * as React from "react";
2
2
 
3
+ type ToastVariants = "error" | "info" | "success" | "warning";
4
+
3
5
  export interface ToastPropTypes {
4
6
  /** The rendered children of the component. */
5
7
  children: React.ReactNode;
6
8
  /** Customizes the appearance in the DLS theme */
7
- variant?:
8
- | "default"
9
- | "error"
10
- | "help"
11
- | "info"
12
- | "maintenance"
13
- | "new"
14
- | "success"
15
- | "warning";
9
+ variant?: ToastVariants;
16
10
  /** Customizes the appearance in a legacy theme through colour (see the 'iconColorSets' for possible values) */
17
- as?:
18
- | "default"
19
- | "error"
20
- | "help"
21
- | "info"
22
- | "maintenance"
23
- | "new"
24
- | "success"
25
- | "warning";
11
+ as?: ToastVariants;
26
12
  /** Custom className */
27
13
  className?: string;
28
14
  /** Custom id */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "104.58.5",
3
+ "version": "104.58.8",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {