carbon-react 153.0.0-beta.1 → 153.0.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 (117) hide show
  1. package/README.md +1 -1
  2. package/esm/__internal__/ai-icon/ai-icon.component.d.ts +4 -0
  3. package/esm/__internal__/ai-icon/ai-icon.component.js +28 -0
  4. package/esm/__internal__/ai-icon/index.d.ts +1 -0
  5. package/esm/__internal__/ai-icon/index.js +1 -0
  6. package/esm/__internal__/dom/globals.js +1 -1
  7. package/esm/__internal__/input/input.component.d.ts +6 -1
  8. package/esm/__internal__/input/input.component.js +3 -2
  9. package/esm/components/accordion/accordion-group/accordion-group.component.js +6 -0
  10. package/esm/components/button/button-types.style.js +11 -1
  11. package/esm/components/button/button.component.js +1 -1
  12. package/esm/components/button-bar/button-bar.style.js +25 -53
  13. package/esm/components/dialog/dialog.component.d.ts +1 -0
  14. package/esm/components/dialog/dialog.component.js +2 -0
  15. package/esm/components/dialog/dialog.style.d.ts +1 -0
  16. package/esm/components/dialog/dialog.style.js +14 -0
  17. package/esm/components/hr/hr.style.js +1 -1
  18. package/esm/components/link/link.component.js +8 -1
  19. package/esm/components/menu/menu-item/menu-item.component.js +13 -7
  20. package/esm/components/message/message.component.d.ts +5 -1
  21. package/esm/components/message/message.component.js +38 -24
  22. package/esm/components/message/message.style.d.ts +4 -1
  23. package/esm/components/message/message.style.js +39 -13
  24. package/esm/components/portrait/portrait.style.js +0 -1
  25. package/esm/components/preview/preview.style.js +1 -1
  26. package/esm/components/select/__internal__/select-textbox/select-textbox.component.js +1 -1
  27. package/esm/components/select/simple-select/simple-select.component.js +1 -1
  28. package/esm/components/split-button/split-button-toggle.style.d.ts +1 -0
  29. package/esm/components/split-button/split-button-toggle.style.js +30 -2
  30. package/esm/components/split-button/split-button.component.d.ts +2 -0
  31. package/esm/components/split-button/split-button.component.js +4 -0
  32. package/esm/components/textarea/textarea.component.js +10 -3
  33. package/esm/components/textbox/textbox.component.js +10 -3
  34. package/esm/components/tile/tile.style.d.ts +1 -1
  35. package/esm/components/time/index.d.ts +1 -1
  36. package/esm/components/time/time.component.js +16 -1
  37. package/esm/components/toast/toast.component.js +2 -1
  38. package/esm/components/toast/toast.style.d.ts +2 -3
  39. package/esm/components/toast/toast.style.js +1 -2
  40. package/esm/components/vertical-menu/vertical-menu-full-screen/vertical-menu-full-screen.component.d.ts +1 -1
  41. package/esm/components/vertical-menu/vertical-menu-full-screen/vertical-menu-full-screen.component.js +5 -6
  42. package/esm/components/vertical-menu/vertical-menu.style.d.ts +5 -1
  43. package/esm/components/vertical-menu/vertical-menu.style.js +20 -1
  44. package/esm/hooks/{__internal__/useCharacterCount → useCharacterCount}/useCharacterCount.js +3 -3
  45. package/esm/locales/en-gb.js +2 -1
  46. package/esm/locales/locale.d.ts +1 -0
  47. package/lib/__internal__/ai-icon/ai-icon.component.d.ts +4 -0
  48. package/lib/__internal__/ai-icon/ai-icon.component.js +36 -0
  49. package/lib/__internal__/ai-icon/index.d.ts +1 -0
  50. package/lib/__internal__/ai-icon/index.js +13 -0
  51. package/lib/__internal__/ai-icon/package.json +6 -0
  52. package/lib/__internal__/dom/globals.js +1 -1
  53. package/lib/__internal__/input/input.component.d.ts +6 -1
  54. package/lib/__internal__/input/input.component.js +3 -2
  55. package/lib/components/accordion/accordion-group/accordion-group.component.js +6 -0
  56. package/lib/components/button/button-types.style.js +11 -1
  57. package/lib/components/button/button.component.js +1 -1
  58. package/lib/components/button-bar/button-bar.style.js +25 -53
  59. package/lib/components/dialog/dialog.component.d.ts +1 -0
  60. package/lib/components/dialog/dialog.component.js +2 -0
  61. package/lib/components/dialog/dialog.style.d.ts +1 -0
  62. package/lib/components/dialog/dialog.style.js +14 -0
  63. package/lib/components/hr/hr.style.js +1 -1
  64. package/lib/components/link/link.component.js +8 -1
  65. package/lib/components/menu/menu-item/menu-item.component.js +12 -6
  66. package/lib/components/message/message.component.d.ts +5 -1
  67. package/lib/components/message/message.component.js +38 -24
  68. package/lib/components/message/message.style.d.ts +4 -1
  69. package/lib/components/message/message.style.js +38 -13
  70. package/lib/components/portrait/portrait.style.js +0 -1
  71. package/lib/components/preview/preview.style.js +1 -1
  72. package/lib/components/select/__internal__/select-textbox/select-textbox.component.js +1 -1
  73. package/lib/components/select/simple-select/simple-select.component.js +1 -1
  74. package/lib/components/split-button/split-button-toggle.style.d.ts +1 -0
  75. package/lib/components/split-button/split-button-toggle.style.js +30 -2
  76. package/lib/components/split-button/split-button.component.d.ts +2 -0
  77. package/lib/components/split-button/split-button.component.js +4 -0
  78. package/lib/components/textarea/textarea.component.js +10 -3
  79. package/lib/components/textbox/textbox.component.js +10 -3
  80. package/lib/components/tile/tile.style.d.ts +1 -1
  81. package/lib/components/time/index.d.ts +1 -1
  82. package/lib/components/time/time.component.js +15 -0
  83. package/lib/components/toast/toast.component.js +2 -1
  84. package/lib/components/toast/toast.style.d.ts +2 -3
  85. package/lib/components/toast/toast.style.js +0 -7
  86. package/lib/components/vertical-menu/vertical-menu-full-screen/vertical-menu-full-screen.component.d.ts +1 -1
  87. package/lib/components/vertical-menu/vertical-menu-full-screen/vertical-menu-full-screen.component.js +5 -6
  88. package/lib/components/vertical-menu/vertical-menu.style.d.ts +5 -1
  89. package/lib/components/vertical-menu/vertical-menu.style.js +20 -1
  90. package/lib/hooks/useCharacterCount/package.json +6 -0
  91. package/lib/hooks/{__internal__/useCharacterCount → useCharacterCount}/useCharacterCount.js +3 -3
  92. package/lib/locales/en-gb.js +2 -1
  93. package/lib/locales/locale.d.ts +1 -0
  94. package/package.json +15 -15
  95. package/esm/components/message/__internal__/message-content/message-content.component.d.ts +0 -9
  96. package/esm/components/message/__internal__/message-content/message-content.component.js +0 -19
  97. package/esm/components/message/__internal__/message-content/message-content.style.d.ts +0 -3
  98. package/esm/components/message/__internal__/message-content/message-content.style.js +0 -12
  99. package/esm/components/message/__internal__/type-icon/type-icon.component.d.ts +0 -8
  100. package/esm/components/message/__internal__/type-icon/type-icon.component.js +0 -20
  101. package/esm/components/message/__internal__/type-icon/type-icon.style.d.ts +0 -7
  102. package/esm/components/message/__internal__/type-icon/type-icon.style.js +0 -38
  103. package/lib/components/message/__internal__/message-content/message-content.component.d.ts +0 -9
  104. package/lib/components/message/__internal__/message-content/message-content.component.js +0 -26
  105. package/lib/components/message/__internal__/message-content/message-content.style.d.ts +0 -3
  106. package/lib/components/message/__internal__/message-content/message-content.style.js +0 -19
  107. package/lib/components/message/__internal__/type-icon/type-icon.component.d.ts +0 -8
  108. package/lib/components/message/__internal__/type-icon/type-icon.component.js +0 -27
  109. package/lib/components/message/__internal__/type-icon/type-icon.style.d.ts +0 -7
  110. package/lib/components/message/__internal__/type-icon/type-icon.style.js +0 -46
  111. package/lib/hooks/__internal__/useCharacterCount/package.json +0 -6
  112. /package/esm/hooks/{__internal__/useCharacterCount → useCharacterCount}/index.d.ts +0 -0
  113. /package/esm/hooks/{__internal__/useCharacterCount → useCharacterCount}/index.js +0 -0
  114. /package/esm/hooks/{__internal__/useCharacterCount → useCharacterCount}/useCharacterCount.d.ts +0 -0
  115. /package/lib/hooks/{__internal__/useCharacterCount → useCharacterCount}/index.d.ts +0 -0
  116. /package/lib/hooks/{__internal__/useCharacterCount → useCharacterCount}/index.js +0 -0
  117. /package/lib/hooks/{__internal__/useCharacterCount → useCharacterCount}/useCharacterCount.d.ts +0 -0
package/README.md CHANGED
@@ -51,4 +51,4 @@ Thanks to [Chromatic](https://www.chromatic.com/) for providing the visual testi
51
51
 
52
52
  Carbon is licensed under the [Apache-2.0 licence](LICENSE).
53
53
 
54
- Copyright (c) 2018-2024 Sage Group Plc. All rights reserved.
54
+ Copyright (c) 2018-2025 Sage Group Plc. All rights reserved.
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
3
+ export declare const AiIcon: ({ ...rest }: TagProps) => React.JSX.Element;
4
+ export default AiIcon;
@@ -0,0 +1,28 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React from "react";
3
+ import tagComponent from "../../__internal__/utils/helpers/tags/tags";
4
+ export const AiIcon = ({
5
+ ...rest
6
+ }) => /*#__PURE__*/React.createElement("svg", _extends({}, tagComponent("ai-icon", rest), {
7
+ xmlns: "http://www.w3.org/2000/svg",
8
+ width: "20",
9
+ height: "20",
10
+ fill: "none",
11
+ viewBox: "0 0 20 20"
12
+ }), /*#__PURE__*/React.createElement("g", {
13
+ clipPath: "url(#a)"
14
+ }, /*#__PURE__*/React.createElement("path", {
15
+ "data-role": "white-star",
16
+ fill: "#fff",
17
+ d: "m16.378 9.799-3.776-1.49a1.615 1.615 0 0 1-.91-.91l-1.49-3.775c-.537-1.364-2.466-1.364-3.004 0L5.708 7.4a1.615 1.615 0 0 1-.91.91L1.022 9.799c-1.363.537-1.363 2.466 0 3.004l3.776 1.49c.417.163.746.493.91.91l1.49 3.775c.538 1.363 2.467 1.363 3.005 0l1.489-3.776c.164-.416.494-.745.91-.91l3.776-1.489c1.364-.538 1.364-2.467 0-3.004Z"
18
+ }), /*#__PURE__*/React.createElement("path", {
19
+ "data-role": "green-circle",
20
+ fill: "#00D639",
21
+ d: "M17.172 5.655a2.827 2.827 0 1 0 0-5.655 2.827 2.827 0 0 0 0 5.655Z"
22
+ })), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
23
+ id: "a"
24
+ }, /*#__PURE__*/React.createElement("path", {
25
+ fill: "#fff",
26
+ d: "M0 0h20v20H0z"
27
+ }))));
28
+ export default AiIcon;
@@ -0,0 +1 @@
1
+ export { default } from "./ai-icon.component";
@@ -0,0 +1 @@
1
+ export { default } from "./ai-icon.component";
@@ -55,5 +55,5 @@ export function getDocument() {
55
55
  * @returns The global `navigator` object, if it exists.
56
56
  */
57
57
  export function getNavigator() {
58
- return typeof navigator !== "undefined" ? navigator : undefined;
58
+ return typeof navigator !== "undefined" ? navigator : /* istanbul ignore next: node versions >=21 have a partial implementation of navigatior */undefined;
59
59
  }
@@ -3,8 +3,13 @@ import { BorderRadiusType } from "../../components/box/box.component";
3
3
  export type EnterKeyHintTypes = "enter" | "done" | "go" | "next" | "previous" | "search" | "send";
4
4
  export interface CommonInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> {
5
5
  align?: "right" | "left";
6
- /** The id of the element that describe the input. */
6
+ /**
7
+ * Set the ID of the input's description.
8
+ * @deprecated Please use `aria-describedby` instead.
9
+ */
7
10
  ariaDescribedBy?: string;
11
+ /** The ID of the input's description, is set along with hint text and error message. */
12
+ "aria-describedby"?: string;
8
13
  /** Override the variant component */
9
14
  as?: React.ElementType;
10
15
  /** If true the Component will be focused when rendered */
@@ -27,7 +27,8 @@ function selectTextOnFocus(input) {
27
27
  const Input = /*#__PURE__*/React.forwardRef(({
28
28
  align,
29
29
  "aria-labelledby": ariaLabelledBy,
30
- ariaDescribedBy,
30
+ "aria-describedby": ariaDescribedBy,
31
+ ariaDescribedBy: ariaDescribedByDeprecated,
31
32
  placeholder,
32
33
  disabled,
33
34
  readOnly,
@@ -126,7 +127,7 @@ const Input = /*#__PURE__*/React.forwardRef(({
126
127
  handleDeferred(ev);
127
128
  };
128
129
  const hasValidationPart = (context.hasFocus || groupContext.hasFocus || context.hasMouseOver || groupContext.hasMouseOver) && validationIconId;
129
- const descriptionList = ariaDescribedBy ? [ariaDescribedBy] : [];
130
+ const descriptionList = ariaDescribedBy || ariaDescribedByDeprecated ? [ariaDescribedBy || ariaDescribedByDeprecated] : [];
130
131
  if (hasValidationPart) {
131
132
  descriptionList.push(validationIconId);
132
133
  }
@@ -5,14 +5,20 @@ import Events from "../../../__internal__/utils/helpers/events";
5
5
  import Accordion from "../accordion.component";
6
6
  import { StyledAccordionGroup } from "../accordion.style";
7
7
  import tagComponent from "../../../__internal__/utils/helpers/tags";
8
+ import Logger from "../../../__internal__/utils/logger";
8
9
 
9
10
  // typescript-to-proptypes breaks on recursive type references so it has to be an interface
10
11
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
11
12
 
13
+ let deprecatedWarnTriggered = false;
12
14
  export const AccordionGroup = ({
13
15
  children,
14
16
  ...rest
15
17
  }) => {
18
+ if (!deprecatedWarnTriggered) {
19
+ deprecatedWarnTriggered = true;
20
+ Logger.deprecate("`AccordionGroup` is deprecated and will soon be removed.");
21
+ }
16
22
  const hasProperChildren = useMemo(() => {
17
23
  let hasAccordionChildren = true;
18
24
  React.Children.toArray(children).forEach(child => {
@@ -76,6 +76,16 @@ export default (isDisabled, destructive, isWhite) => ({
76
76
  ${makeColors("var(--colorsActionMajorYang100)")};
77
77
  }
78
78
 
79
+ ${isWhite && (!isDisabled || !destructive) ? `
80
+ border-color: var(--colorsActionMajorYang100);
81
+ ${makeColors("var(--colorsActionMajorYang100)")};
82
+ &:hover {
83
+ background: var(--colorsActionMajorYang100);
84
+ border-color: var(--colorsActionMajorYang100);
85
+ ${makeColors("var(--colorsYin100)")};
86
+ }
87
+ ` : ""}
88
+
79
89
  ${destructive ? `
80
90
  border-color: var(--colorsSemanticNegative500);
81
91
  ${makeColors("var(--colorsSemanticNegative500)")}
@@ -86,7 +96,7 @@ export default (isDisabled, destructive, isWhite) => ({
86
96
  }
87
97
  ` : ""}
88
98
 
89
- ${isDisabled ? `
99
+ ${isDisabled && !isWhite ? `
90
100
  border-color: var(--colorsActionDisabled500);
91
101
  ${makeColors("var(--colorsActionMajorYin030)")};
92
102
  &:hover {
@@ -64,13 +64,13 @@ const Button = /*#__PURE__*/React.forwardRef(({
64
64
  children,
65
65
  destructive = false,
66
66
  disabled = false,
67
+ isWhite = false,
67
68
  fullWidth: fullWidthProp = false,
68
69
  href,
69
70
  iconPosition: iconPositionProp = "before",
70
71
  iconTooltipMessage,
71
72
  iconTooltipPosition,
72
73
  iconType,
73
- isWhite = false,
74
74
  m = 0,
75
75
  noWrap,
76
76
  onClick,
@@ -1,13 +1,8 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import { space } from "styled-system";
3
3
  import BaseTheme from "../../style/themes/base";
4
- import StyledButton from "../button/button.style";
5
4
  import StyledIcon from "../icon/icon.style";
6
5
  import StyledIconButton from "../icon-button/icon-button.style";
7
- const commonHoverStyles = `
8
- background-color: var(--colorsActionMajor600);
9
- border-color: var(--colorsActionMajor600);
10
- `;
11
6
  const StyledButtonBar = styled.div`
12
7
  ${space}
13
8
  ${({
@@ -29,84 +24,61 @@ const StyledButtonBar = styled.div`
29
24
 
30
25
  button {
31
26
  margin: 0;
27
+ position: relative;
32
28
 
33
- :not(:first-child):not(:last-child) {
29
+ &:not(:first-child):not(:last-child) {
34
30
  border-radius: var(--borderRadius000);
35
31
  }
36
- :first-child:not(:last-child) {
32
+ &:first-child:not(:last-child) {
37
33
  border-top-right-radius: var(--borderRadius000);
38
34
  border-bottom-right-radius: var(--borderRadius000);
39
35
  }
40
- :last-child:not(:first-child) {
36
+ &:last-child:not(:first-child) {
41
37
  border-top-left-radius: var(--borderRadius000);
42
38
  border-bottom-left-radius: var(--borderRadius000);
43
39
  }
44
40
 
45
- &:not(:last-of-type) {
46
- border-right-color: transparent;
47
- }
48
-
49
41
  &:not(:first-of-type) {
50
42
  margin-left: -2px;
51
43
  }
52
44
 
53
- &:focus {
54
- position: relative;
55
- z-index: 2;
45
+ &:not(:disabled) {
46
+ z-index: 1;
56
47
  }
57
48
 
58
- &:hover {
59
- background-color: var(--colorsActionMajor600);
60
- border-color: var(--colorsActionMajor600);
61
-
62
- & + button {
63
- border-left-color: var(--colorsActionMajor600);
64
- }
65
-
66
- & ${StyledIcon} {
67
- ${commonHoverStyles}
68
- color: white;
69
- }
49
+ &:hover:not(:disabled) {
50
+ z-index: 2;
70
51
  }
71
52
 
72
- & ${StyledIcon} {
73
- color: var(--colorsActionMajor500);
53
+ &:focus {
54
+ z-index: 3;
74
55
  }
75
56
  }
76
57
 
77
- [data-component="button"] {
78
- :hover {
79
- ${commonHoverStyles}
80
- & + ${StyledButton} {
81
- border-left-color: var(--colorsActionMajor600);
82
- }
58
+ ${StyledIconButton}:not(:disabled) {
59
+ border: 2px solid var(--colorsActionMajor500);
60
+
61
+ &:focus {
62
+ border-right-color: var(--colorsActionMajor500);
83
63
  }
84
- }
85
64
 
86
- [data-component="button-minor"] {
87
- & ${StyledIcon} {
88
- color: var(--colorsActionMinor500);
65
+ &:hover {
66
+ background-color: var(--colorsActionMajor600);
67
+ border-color: var(--colorsActionMajor600);
68
+ color: var(--colorsActionMajorYang100);
89
69
  }
90
- }
91
70
 
92
- [data-component="button-minor"] {
93
- :hover {
94
- color: var(--colorsActionMinorYang100);
95
- background-color: var(--colorsActionMinor500);
96
- border-color: var(--colorsActionMinor500);
71
+ ${StyledIcon} {
72
+ color: var(--colorsActionMajor500);
97
73
 
98
- & + ${StyledButton} {
99
- border-left-color: var(--colorsActionMinor500);
74
+ &:hover {
75
+ color: var(--colorsActionMajorYang100);
100
76
  }
101
77
  }
102
78
  }
103
79
 
104
- ${StyledIconButton} {
105
- border: 2px solid var(--colorsActionMajor500);
106
-
107
- :focus {
108
- border-right-color: var(--colorsActionMajor500);
109
- }
80
+ ${StyledIconButton}:disabled {
81
+ border: 2px solid var(--colorsActionDisabled500);
110
82
  }
111
83
  `}
112
84
  `;
@@ -46,6 +46,7 @@ export interface DialogProps extends ModalProps, TagProps {
46
46
  height?: string;
47
47
  /** Adds Help tooltip to Header */
48
48
  help?: string;
49
+ highlightVariant?: string;
49
50
  /** A custom close event handler */
50
51
  onCancel?: (ev: React.KeyboardEvent<HTMLElement> | KeyboardEvent | React.MouseEvent<HTMLButtonElement>) => void;
51
52
  /** Determines if the close icon is shown */
@@ -31,6 +31,7 @@ export const Dialog = /*#__PURE__*/forwardRef(({
31
31
  bespokeFocusTrap,
32
32
  disableClose,
33
33
  help,
34
+ highlightVariant = "default",
34
35
  role = "dialog",
35
36
  contentPadding = {},
36
37
  greyBackground = false,
@@ -115,6 +116,7 @@ export const Dialog = /*#__PURE__*/forwardRef(({
115
116
  "aria-modal": isTopModal ? true : undefined,
116
117
  ref: containerRef
117
118
  }, dialogProps, {
119
+ highlightVariant: highlightVariant,
118
120
  role: role,
119
121
  tabIndex: -1
120
122
  }, contentPadding, {
@@ -3,6 +3,7 @@ declare const DialogPositioner: import("styled-components").StyledComponent<"div
3
3
  declare const StyledDialog: import("styled-components").StyledComponent<"div", any, Required<Pick<DialogProps, "size">> & {
4
4
  dialogHeight?: string | undefined;
5
5
  backgroundColor: string;
6
+ highlightVariant?: string | undefined;
6
7
  } & ContentPaddingInterface, never>;
7
8
  type StyledDialogTitleProps = {
8
9
  showCloseIcon?: boolean;
@@ -51,6 +51,20 @@ const StyledDialog = styled.div`
51
51
  outline: none;
52
52
  }
53
53
 
54
+ ${({
55
+ highlightVariant
56
+ }) => highlightVariant === "ai" && `
57
+ &::before {
58
+ content: "";
59
+ position: absolute;
60
+ top: -8px;
61
+ height: 100px;
62
+ width: 100%;
63
+ z-index: -1;
64
+ background: linear-gradient(90deg, #00D639 0%, #00D6DE 40%, #9D60FF 90%);
65
+ border-radius: var(--borderRadius200) var(--borderRadius200) 0 0;
66
+ }`}
67
+
54
68
  ${({
55
69
  backgroundColor
56
70
  }) => css`
@@ -8,7 +8,7 @@ const heightMap = {
8
8
  };
9
9
  const StyledHr = styled.hr`
10
10
  ${margin}
11
- width: inherit;
11
+ width: 100%;
12
12
  border: 0;
13
13
  height: ${({
14
14
  height
@@ -36,6 +36,13 @@ export const Link = /*#__PURE__*/React.forwardRef(({
36
36
  batchSelectionDisabled
37
37
  } = useContext(BatchSelectionContext);
38
38
  const isDisabled = disabled || batchSelectionDisabled;
39
+ const setRefs = React.useCallback(reference => {
40
+ if (!ref) return;
41
+ if (typeof ref === "object") ref.current = reference;
42
+ if (typeof ref === "function") {
43
+ ref(reference);
44
+ }
45
+ }, [ref]);
39
46
  const renderLinkIcon = (currentAlignment = "left") => {
40
47
  const hasProperAlignment = icon && iconAlign === currentAlignment;
41
48
  return hasProperAlignment ? /*#__PURE__*/React.createElement(Icon, {
@@ -59,7 +66,7 @@ export const Link = /*#__PURE__*/React.forwardRef(({
59
66
  onClick,
60
67
  disabled: isDisabled,
61
68
  target,
62
- ref,
69
+ ref: setRefs,
63
70
  href,
64
71
  rel,
65
72
  "aria-label": ariaLabel,
@@ -1,5 +1,5 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useRef, useEffect, useContext } from "react";
2
+ import React, { useRef, useEffect, useContext, useState, useLayoutEffect } from "react";
3
3
  import invariant from "invariant";
4
4
  import { defaultFocusableSelectors as focusableSelectors } from "../../../__internal__/focus-trap/focus-trap-utils";
5
5
  import { filterStyledSystemPaddingProps } from "../../../style/utils";
@@ -63,8 +63,14 @@ export const MenuItem = ({
63
63
  } = submenuContext;
64
64
  const focusFromMenu = focusId === menuItemId.current;
65
65
  const focusFromSubmenu = submenuFocusId ? submenuFocusId === menuItemId.current : undefined;
66
- const ref = useRef(null);
67
- const firstFocusableChild = ref.current?.querySelector(focusableSelectors) ?? null;
66
+ const [ref, setRef] = useState(null);
67
+ const [firstFocusableChild, setFirstFocusableChild] = useState(null);
68
+ useLayoutEffect(() => {
69
+ const firstFocusable = ref?.querySelector(focusableSelectors) ?? null;
70
+ if (firstFocusable !== firstFocusableChild) {
71
+ setFirstFocusableChild(firstFocusable);
72
+ }
73
+ }, [ref]);
68
74
  useEffect(() => {
69
75
  const id = menuItemId.current;
70
76
 
@@ -85,7 +91,7 @@ export const MenuItem = ({
85
91
  firstFocusableChild.focus();
86
92
  return;
87
93
  }
88
- ref.current?.focus();
94
+ ref?.focus();
89
95
  }
90
96
  }, [firstFocusableChild, focusFromMenu, focusFromSubmenu]);
91
97
  const handleFocus = event => {
@@ -99,7 +105,7 @@ export const MenuItem = ({
99
105
  const handleKeyDown = event => {
100
106
  onKeyDown?.(event);
101
107
  if (Events.isEscKey(event)) {
102
- ref.current?.focus();
108
+ ref?.focus();
103
109
  }
104
110
  handleSubmenuKeyDown?.(event);
105
111
  };
@@ -114,7 +120,7 @@ export const MenuItem = ({
114
120
  selected,
115
121
  onKeyDown: !inFullscreenView ? handleKeyDown : undefined,
116
122
  overrideColor,
117
- ref
123
+ ref: setRef
118
124
  };
119
125
  if (overriddenVariant === "alternate" && isChildOfSegment && variant === "alternate" && ["white", "black"].includes(menuType)) {
120
126
  elementProps.overrideColor = true;
@@ -153,7 +159,7 @@ export const MenuItem = ({
153
159
  }, rest), children));
154
160
  }
155
161
  const paddingProps = filterStyledSystemPaddingProps(rest);
156
- const hasInput = !!ref.current?.querySelector("[data-element='input']");
162
+ const hasInput = !!ref?.querySelector("[data-element='input']");
157
163
  return /*#__PURE__*/React.createElement(StyledMenuItem, _extends({
158
164
  "data-component": "menu-item",
159
165
  "data-element": dataElement,
@@ -1,7 +1,11 @@
1
1
  import React from "react";
2
2
  import { MarginProps } from "styled-system";
3
3
  import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
4
- export type MessageVariant = "error" | "info" | "success" | "warning" | "neutral";
4
+ export interface TypeIconProps {
5
+ transparent?: boolean;
6
+ variant: MessageVariant;
7
+ }
8
+ export type MessageVariant = "error" | "info" | "success" | "warning" | "neutral" | "ai";
5
9
  export interface MessageProps extends MarginProps, TagProps {
6
10
  /** Set the component's content */
7
11
  children?: React.ReactNode;
@@ -1,12 +1,12 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React, { useRef } from "react";
3
3
  import Typography from "../typography";
4
- import MessageStyle from "./message.style";
5
- import TypeIcon from "./__internal__/type-icon/type-icon.component";
6
- import MessageContent from "./__internal__/message-content/message-content.component";
4
+ import Content from "../content";
5
+ import MessageStyle, { MessageContent, TypeIconStyle } from "./message.style";
7
6
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
8
7
  import Icon from "../icon";
9
8
  import IconButton from "../icon-button";
9
+ import AiIcon from "../../__internal__/ai-icon";
10
10
  import { filterStyledSystemMarginProps } from "../../style/utils";
11
11
  import useLocale from "../../hooks/__internal__/useLocale";
12
12
  export const Message = /*#__PURE__*/React.forwardRef(({
@@ -22,38 +22,52 @@ export const Message = /*#__PURE__*/React.forwardRef(({
22
22
  width,
23
23
  ...props
24
24
  }, ref) => {
25
- const messageRef = useRef(null);
26
- const refToPass = ref || messageRef;
25
+ const localRef = useRef(null);
26
+ const messageRef = ref || localRef;
27
+ const locale = useLocale();
27
28
  const marginProps = filterStyledSystemMarginProps(props);
28
- const l = useLocale();
29
- const renderCloseIcon = () => {
30
- if (!showCloseIcon || !onDismiss) return null;
31
- return /*#__PURE__*/React.createElement(IconButton, {
32
- "data-element": "close",
33
- "aria-label": closeButtonAriaLabel || l.message.closeButtonAriaLabel(),
34
- onClick: onDismiss
35
- }, /*#__PURE__*/React.createElement(Icon, {
36
- type: "close"
37
- }));
29
+ const VARIANT_ICON_MAP = {
30
+ neutral: "info",
31
+ success: "tick_circle",
32
+ error: "error",
33
+ warning: "warning",
34
+ info: "info"
38
35
  };
39
- return open ? /*#__PURE__*/React.createElement(MessageStyle, _extends({}, tagComponent("Message", props), {
36
+ if (!open) {
37
+ return null;
38
+ }
39
+ return /*#__PURE__*/React.createElement(MessageStyle, _extends({}, tagComponent("Message", props), {
40
40
  transparent: transparent,
41
41
  variant: variant,
42
42
  id: id,
43
43
  width: width,
44
- ref: refToPass
44
+ ref: messageRef
45
45
  }, marginProps, {
46
46
  tabIndex: -1
47
- }), /*#__PURE__*/React.createElement(TypeIcon, {
47
+ }), /*#__PURE__*/React.createElement(TypeIconStyle, {
48
48
  variant: variant,
49
49
  transparent: transparent
50
- }), /*#__PURE__*/React.createElement(Typography, {
50
+ }, variant === "ai" ? /*#__PURE__*/React.createElement(AiIcon, {
51
+ "data-role": "ai-icon"
52
+ }) : /*#__PURE__*/React.createElement(Icon, {
53
+ "data-role": "category-icon",
54
+ type: VARIANT_ICON_MAP[variant]
55
+ })), /*#__PURE__*/React.createElement(Typography, {
51
56
  screenReaderOnly: true
52
- }, l.message[variant]()), /*#__PURE__*/React.createElement(MessageContent, {
53
- showCloseIcon: showCloseIcon,
54
- title: title,
55
- reduceLeftPadding: transparent
56
- }, children), renderCloseIcon()) : null;
57
+ }, locale.message?.[variant]?.()), /*#__PURE__*/React.createElement(MessageContent, {
58
+ "data-element": "message-content",
59
+ "data-role": "message-content"
60
+ }, !showCloseIcon || !onDismiss ? /*#__PURE__*/React.createElement(Content, {
61
+ title: title
62
+ }, children) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Content, {
63
+ title: title
64
+ }, children), /*#__PURE__*/React.createElement(IconButton, {
65
+ "data-element": "close",
66
+ "aria-label": closeButtonAriaLabel || locale.message.closeButtonAriaLabel(),
67
+ onClick: onDismiss
68
+ }, /*#__PURE__*/React.createElement(Icon, {
69
+ type: "close"
70
+ })))));
57
71
  });
58
72
  Message.displayName = "Message";
59
73
  export default Message;
@@ -1,9 +1,12 @@
1
1
  import { MarginProps } from "styled-system";
2
- import { MessageVariant } from "./message.component";
2
+ import { MessageVariant, TypeIconProps } from "./message.component";
3
3
  type MessageStyleProps = {
4
4
  variant?: MessageVariant;
5
5
  transparent?: boolean;
6
6
  width?: string;
7
7
  };
8
8
  declare const MessageStyle: import("styled-components").StyledComponent<"div", any, MessageStyleProps & MarginProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, never>;
9
+ declare const MessageContent: import("styled-components").StyledComponent<"div", any, {}, never>;
10
+ declare const TypeIconStyle: import("styled-components").StyledComponent<"div", any, TypeIconProps, never>;
9
11
  export default MessageStyle;
12
+ export { MessageContent, TypeIconStyle };
@@ -1,19 +1,17 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import { margin } from "styled-system";
3
3
  import BaseTheme from "../../style/themes/base";
4
- import StyledIconButton from "../icon-button/icon-button.style";
5
4
  const messageVariants = {
6
5
  error: "var(--colorsSemanticNegative500)",
7
6
  info: "var(--colorsSemanticInfo500)",
8
7
  success: "var(--colorsSemanticPositive500)",
9
8
  warning: "var(--colorsSemanticCaution500)",
10
- neutral: "var(--colorsSemanticNeutral500)"
9
+ neutral: "var(--colorsSemanticNeutral500)",
10
+ ai: "var(--colorsUtilityYin100)"
11
11
  };
12
12
  const MessageStyle = styled.div`
13
13
  position: relative;
14
14
  display: flex;
15
- justify-content: flex-start;
16
- align-content: center;
17
15
  border-radius: var(--borderRadius100);
18
16
  overflow: hidden;
19
17
  border: 1px solid ${({
@@ -33,20 +31,48 @@ const MessageStyle = styled.div`
33
31
  background: transparent;
34
32
  `}
35
33
 
36
- ${StyledIconButton} {
37
- position: absolute;
38
- right: 20px;
39
- top: 50%;
40
- transform: translateY(-50%);
41
- }
42
-
43
34
  ${({
44
35
  width
45
36
  }) => width && `width: ${width};`}
46
-
47
37
  ${margin}
48
38
  `;
39
+ const MessageContent = styled.div`
40
+ width: 100%;
41
+ display: flex;
42
+ justify-content: space-between;
43
+ align-items: center;
44
+ padding: var(--spacing200);
45
+ gap: var(--spacing300);
46
+ `;
47
+ const TypeIconStyle = styled.div`
48
+ display: flex;
49
+ justify-content: center;
50
+ align-items: center;
51
+ background-color: ${({
52
+ variant
53
+ }) => messageVariants[variant]};
54
+ min-width: 30px;
55
+
56
+ span {
57
+ &:before {
58
+ color: var(--colorsUtilityYang100);
59
+ }
60
+ }
61
+
62
+ ${({
63
+ transparent,
64
+ variant
65
+ }) => transparent && css`
66
+ background-color: transparent;
67
+ span {
68
+ &:before {
69
+ color: ${messageVariants[variant]};
70
+ }
71
+ }
72
+ `}
73
+ `;
49
74
  MessageStyle.defaultProps = {
50
75
  theme: BaseTheme
51
76
  };
52
- export default MessageStyle;
77
+ export default MessageStyle;
78
+ export { MessageContent, TypeIconStyle };
@@ -23,7 +23,6 @@ export const StyledCustomImg = styled.img`
23
23
  `;
24
24
 
25
25
  // && is used here to increase the specificity
26
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
26
  export const StyledIcon = styled(Icon)`
28
27
  && {
29
28
  color: inherit;
@@ -63,7 +63,7 @@ const StyledPreviewPlaceholder = styled.span`
63
63
  animation: ${shimmer} 2s ease infinite;
64
64
 
65
65
  ${isLastLine && shape === "text" && css`
66
- width: calc(; ${width || getWidth(shape)}*0.8);
66
+ width: calc(${width || getWidth(shape)}*0.8);
67
67
  `}
68
68
 
69
69
  ${shape === "circle" && css`
@@ -72,7 +72,7 @@ const SelectTextbox = /*#__PURE__*/React.forwardRef(({
72
72
  isInputInSelect: true
73
73
  }
74
74
  }, /*#__PURE__*/React.createElement(Textbox, _extends({
75
- ariaDescribedBy: ariaDescribedBy,
75
+ "aria-describedby": ariaDescribedBy,
76
76
  "aria-label": ariaLabel,
77
77
  "data-element": "select-input",
78
78
  "data-role": "select-textbox",