carbon-react 120.3.0 → 120.4.0

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/components/flat-table/__internal__/index.d.ts +1 -1
  2. package/esm/components/flat-table/__internal__/index.js +1 -1
  3. package/esm/components/flat-table/__internal__/{use-calculate-sticky-cells.d.ts → use-table-cell.d.ts} +3 -0
  4. package/esm/components/flat-table/__internal__/{use-calculate-sticky-cells.js → use-table-cell.js} +21 -3
  5. package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +10 -14
  6. package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +2 -2
  7. package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-context.d.ts +2 -0
  8. package/esm/components/flat-table/flat-table-row/flat-table-row.component.js +9 -11
  9. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +10 -12
  10. package/esm/components/flat-table/flat-table.component.d.ts +1 -2
  11. package/esm/components/flat-table/flat-table.component.js +9 -29
  12. package/esm/components/message/message.component.d.ts +1 -1
  13. package/esm/components/message/message.component.js +1 -1
  14. package/esm/components/message/message.style.js +3 -2
  15. package/esm/components/message/type-icon/type-icon.component.js +6 -1
  16. package/esm/components/message/type-icon/type-icon.style.js +4 -2
  17. package/esm/components/toast/toast.component.d.ts +4 -1
  18. package/esm/components/toast/toast.component.js +27 -5
  19. package/esm/components/toast/toast.config.js +1 -1
  20. package/esm/components/toast/toast.style.d.ts +4 -0
  21. package/esm/components/toast/toast.style.js +36 -3
  22. package/lib/components/flat-table/__internal__/index.d.ts +1 -1
  23. package/lib/components/flat-table/__internal__/index.js +3 -3
  24. package/lib/components/flat-table/__internal__/{use-calculate-sticky-cells.d.ts → use-table-cell.d.ts} +3 -0
  25. package/lib/components/flat-table/__internal__/{use-calculate-sticky-cells.js → use-table-cell.js} +20 -2
  26. package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +9 -13
  27. package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +2 -2
  28. package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-context.d.ts +2 -0
  29. package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +9 -11
  30. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +9 -11
  31. package/lib/components/flat-table/flat-table.component.d.ts +1 -2
  32. package/lib/components/flat-table/flat-table.component.js +9 -29
  33. package/lib/components/message/message.component.d.ts +1 -1
  34. package/lib/components/message/message.component.js +1 -1
  35. package/lib/components/message/message.style.js +3 -2
  36. package/lib/components/message/type-icon/type-icon.component.js +6 -1
  37. package/lib/components/message/type-icon/type-icon.style.js +4 -2
  38. package/lib/components/toast/toast.component.d.ts +4 -1
  39. package/lib/components/toast/toast.component.js +27 -5
  40. package/lib/components/toast/toast.config.js +1 -1
  41. package/lib/components/toast/toast.style.d.ts +4 -0
  42. package/lib/components/toast/toast.style.js +36 -3
  43. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- export { default as useCalculateStickyCells } from "./use-calculate-sticky-cells";
1
+ export { default as useTableCell } from "./use-table-cell";
2
2
  export { default as buildPositionMap } from "./build-position-map";
@@ -1,2 +1,2 @@
1
- export { default as useCalculateStickyCells } from "./use-calculate-sticky-cells";
1
+ export { default as useTableCell } from "./use-table-cell";
2
2
  export { default as buildPositionMap } from "./build-position-map";
@@ -8,5 +8,8 @@ declare const _default: (id: string) => {
8
8
  onKeyDown: ((ev: import("react").KeyboardEvent<HTMLElement>) => void) | undefined;
9
9
  isFirstCell: boolean;
10
10
  isExpandableCell: boolean | undefined;
11
+ tabIndex: number;
12
+ isInHighlightedRow: boolean | undefined;
13
+ isInSelectedRow: boolean | undefined;
11
14
  };
12
15
  export default _default;
@@ -1,6 +1,11 @@
1
- import { useContext } from "react";
1
+ import { useContext, useEffect, useState } from "react";
2
2
  import FlatTableRowContext from "../flat-table-row/__internal__/flat-table-row-context";
3
+ import { FlatTableThemeContext } from "../flat-table.component";
3
4
  export default (id => {
5
+ const {
6
+ getTabStopElementId
7
+ } = useContext(FlatTableThemeContext);
8
+ const [tabIndex, setTabIndex] = useState(-1);
4
9
  const {
5
10
  expandable,
6
11
  firstCellId,
@@ -8,13 +13,23 @@ export default (id => {
8
13
  leftPositions,
9
14
  rightPositions,
10
15
  onClick,
11
- onKeyDown
16
+ onKeyDown,
17
+ highlighted,
18
+ selected
12
19
  } = useContext(FlatTableRowContext);
13
20
  const leftPosition = leftPositions[id];
14
21
  const rightPosition = rightPositions[id];
15
22
  const makeCellSticky = leftPosition !== undefined || rightPosition !== undefined;
16
23
  const isFirstCell = id === firstCellId;
17
24
  const isExpandableCell = expandable && isFirstCell && firstColumnExpandable;
25
+ useEffect(() => {
26
+ const tabstopTimer = setTimeout(() => {
27
+ setTabIndex(isExpandableCell && getTabStopElementId() === id ? 0 : -1);
28
+ }, 0);
29
+ return () => {
30
+ clearTimeout(tabstopTimer);
31
+ };
32
+ }, [getTabStopElementId, isExpandableCell, id]);
18
33
  return {
19
34
  expandable,
20
35
  leftPosition,
@@ -23,6 +38,9 @@ export default (id => {
23
38
  onClick,
24
39
  onKeyDown,
25
40
  isFirstCell,
26
- isExpandableCell
41
+ isExpandableCell,
42
+ tabIndex,
43
+ isInHighlightedRow: highlighted,
44
+ isInSelectedRow: selected
27
45
  };
28
46
  });
@@ -1,11 +1,10 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
2
- import React, { useRef, useState, useEffect, useContext } from "react";
2
+ import React, { useRef } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { StyledFlatTableCell, StyledCellContent } from "./flat-table-cell.style";
5
5
  import Icon from "../../icon";
6
- import { FlatTableThemeContext } from "../flat-table.component";
7
6
  import guid from "../../../__internal__/utils/helpers/guid";
8
- import useCalculateStickyCells from "../__internal__/use-calculate-sticky-cells";
7
+ import useTableCell from "../__internal__/use-table-cell";
9
8
  export const FlatTableCell = ({
10
9
  align = "left",
11
10
  children,
@@ -18,12 +17,7 @@ export const FlatTableCell = ({
18
17
  id,
19
18
  ...rest
20
19
  }) => {
21
- const ref = useRef(null);
22
20
  const internalId = useRef(id || guid());
23
- const [tabIndex, setTabIndex] = useState(-1);
24
- const {
25
- selectedId
26
- } = useContext(FlatTableThemeContext);
27
21
  const {
28
22
  leftPosition,
29
23
  rightPosition,
@@ -32,17 +26,16 @@ export const FlatTableCell = ({
32
26
  onKeyDown,
33
27
  isFirstCell,
34
28
  isExpandableCell,
35
- makeCellSticky
36
- } = useCalculateStickyCells(internalId.current);
37
- useEffect(() => {
38
- setTabIndex(isExpandableCell && selectedId === internalId.current ? 0 : -1);
39
- }, [selectedId, isExpandableCell]);
29
+ makeCellSticky,
30
+ isInHighlightedRow,
31
+ isInSelectedRow,
32
+ tabIndex
33
+ } = useTableCell(internalId.current);
40
34
  return /*#__PURE__*/React.createElement(StyledFlatTableCell, _extends({
41
35
  leftPosition: leftPosition,
42
36
  rightPosition: rightPosition,
43
37
  makeCellSticky: makeCellSticky,
44
38
  className: makeCellSticky ? "isSticky" : undefined,
45
- ref: ref,
46
39
  align: align,
47
40
  "data-element": "flat-table-cell",
48
41
  pl: pl,
@@ -56,6 +49,9 @@ export const FlatTableCell = ({
56
49
  colSpan: Number(colspan)
57
50
  }, rowspan !== undefined && {
58
51
  rowSpan: Number(rowspan)
52
+ }, {
53
+ "data-selected": isInSelectedRow && isExpandableCell,
54
+ "data-highlighted": isInHighlightedRow && isExpandableCell
59
55
  }, rest, {
60
56
  id: internalId.current
61
57
  }), /*#__PURE__*/React.createElement(StyledCellContent, {
@@ -4,7 +4,7 @@ import PropTypes from "prop-types";
4
4
  import StyledFlatTableHeader from "./flat-table-header.style";
5
5
  import { FlatTableThemeContext } from "../flat-table.component";
6
6
  import guid from "../../../__internal__/utils/helpers/guid";
7
- import useCalculateStickyCells from "../__internal__/use-calculate-sticky-cells";
7
+ import useTableCell from "../__internal__/use-table-cell";
8
8
  export const FlatTableHeader = ({
9
9
  align,
10
10
  children,
@@ -25,7 +25,7 @@ export const FlatTableHeader = ({
25
25
  leftPosition,
26
26
  rightPosition,
27
27
  makeCellSticky
28
- } = useCalculateStickyCells(internalId.current);
28
+ } = useTableCell(internalId.current);
29
29
  return /*#__PURE__*/React.createElement(StyledFlatTableHeader, _extends({
30
30
  ref: ref,
31
31
  leftPosition: leftPosition,
@@ -7,6 +7,8 @@ export interface FlatTableRowContextProps {
7
7
  leftPositions: Record<string, number>;
8
8
  rightPositions: Record<string, number>;
9
9
  firstColumnExpandable?: boolean;
10
+ highlighted?: boolean;
11
+ selected?: boolean;
10
12
  }
11
13
  declare const _default: React.Context<FlatTableRowContextProps>;
12
14
  export default _default;
@@ -93,8 +93,7 @@ const FlatTableRow = /*#__PURE__*/React.forwardRef(({
93
93
  const {
94
94
  colorTheme,
95
95
  size,
96
- setSelectedId,
97
- selectedId
96
+ getTabStopElementId
98
97
  } = useContext(FlatTableThemeContext);
99
98
  const {
100
99
  isInSidebar
@@ -141,13 +140,8 @@ const FlatTableRow = /*#__PURE__*/React.forwardRef(({
141
140
  setIsExpanded(expanded);
142
141
  }, [expanded]);
143
142
  useEffect(() => {
144
- if (highlighted || selected) {
145
- setSelectedId(internalId.current);
146
- }
147
- }, [highlighted, selected, setSelectedId]);
148
- useEffect(() => {
149
- setTabIndex(selectedId === internalId.current ? 0 : -1);
150
- }, [selectedId]);
143
+ setTabIndex(getTabStopElementId() === internalId.current ? 0 : -1);
144
+ }, [getTabStopElementId]);
151
145
  const {
152
146
  isSubRow,
153
147
  firstRowId,
@@ -183,7 +177,9 @@ const FlatTableRow = /*#__PURE__*/React.forwardRef(({
183
177
  horizontalBorderSize: horizontalBorderSize,
184
178
  draggable: draggable,
185
179
  totalChildren: cellsArray.length,
186
- id: internalId.current
180
+ id: internalId.current,
181
+ "data-selected": selected && expandableArea === "wholeRow",
182
+ "data-highlighted": highlighted && expandableArea === "wholeRow"
187
183
  }, interactiveRowProps, rest), /*#__PURE__*/React.createElement(FlatTableRowContext.Provider, {
188
184
  value: {
189
185
  firstCellId,
@@ -192,7 +188,9 @@ const FlatTableRow = /*#__PURE__*/React.forwardRef(({
192
188
  rightPositions,
193
189
  firstColumnExpandable,
194
190
  onKeyDown: handleCellKeyDown,
195
- onClick: () => toggleExpanded()
191
+ onClick: () => toggleExpanded(),
192
+ highlighted,
193
+ selected
196
194
  }
197
195
  }, children));
198
196
  const draggableComponent = () => /*#__PURE__*/React.createElement(FlatTableRowDraggable, {
@@ -1,12 +1,11 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
2
- import React, { useCallback, useContext, useState, useRef, useEffect } from "react";
2
+ import React, { useCallback, useRef } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import Icon from "../../icon";
5
5
  import { StyledFlatTableRowHeader, StyledFlatTableRowHeaderContent } from "./flat-table-row-header.style";
6
- import { FlatTableThemeContext } from "../flat-table.component";
7
6
  import guid from "../../../__internal__/utils/helpers/guid";
8
7
  import tagComponent from "../../../__internal__/utils/helpers/tags/tags";
9
- import useCalculateStickyCells from "../__internal__/use-calculate-sticky-cells";
8
+ import useTableCell from "../__internal__/use-table-cell";
10
9
  export const FlatTableRowHeader = ({
11
10
  align = "left",
12
11
  children,
@@ -22,10 +21,6 @@ export const FlatTableRowHeader = ({
22
21
  ...rest
23
22
  }) => {
24
23
  const internalId = useRef(id || guid());
25
- const [tabIndex, setTabIndex] = useState(-1);
26
- const {
27
- selectedId
28
- } = useContext(FlatTableThemeContext);
29
24
  const {
30
25
  leftPosition,
31
26
  rightPosition,
@@ -33,11 +28,11 @@ export const FlatTableRowHeader = ({
33
28
  onClick,
34
29
  onKeyDown,
35
30
  isFirstCell,
36
- isExpandableCell
37
- } = useCalculateStickyCells(internalId.current);
38
- useEffect(() => {
39
- setTabIndex(isExpandableCell && selectedId === internalId.current ? 0 : -1);
40
- }, [selectedId, isExpandableCell]);
31
+ isExpandableCell,
32
+ tabIndex,
33
+ isInHighlightedRow,
34
+ isInSelectedRow
35
+ } = useTableCell(internalId.current);
41
36
  const handleOnClick = useCallback(ev => {
42
37
  if (isExpandableCell && onClick) onClick(ev);
43
38
  }, [isExpandableCell, onClick]);
@@ -67,6 +62,9 @@ export const FlatTableRowHeader = ({
67
62
  colSpan: Number(colspan)
68
63
  }, rowspan !== undefined && {
69
64
  rowSpan: Number(rowspan)
65
+ }, {
66
+ "data-selected": isInSelectedRow && isExpandableCell,
67
+ "data-highlighted": isInHighlightedRow && isExpandableCell
70
68
  }, rest, {
71
69
  id: internalId.current
72
70
  }), /*#__PURE__*/React.createElement(StyledFlatTableRowHeaderContent, {
@@ -31,8 +31,7 @@ export interface FlatTableProps extends MarginProps {
31
31
  width?: string;
32
32
  }
33
33
  export interface FlatTableThemeContextProps extends Pick<FlatTableProps, "colorTheme" | "size"> {
34
- selectedId?: string;
35
- setSelectedId: (id: string) => void;
34
+ getTabStopElementId: () => string;
36
35
  }
37
36
  export declare const FlatTableThemeContext: React.Context<FlatTableThemeContextProps>;
38
37
  export declare const FlatTable: {
@@ -5,7 +5,7 @@ import { StyledFlatTableWrapper, StyledFlatTable, StyledFlatTableFooter, StyledT
5
5
  import { DrawerSidebarContext } from "../drawer";
6
6
  import Events from "../../__internal__/utils/helpers/events/events";
7
7
  export const FlatTableThemeContext = /*#__PURE__*/React.createContext({
8
- setSelectedId: () => {}
8
+ getTabStopElementId: () => ""
9
9
  });
10
10
  const FOCUSABLE_ROW_AND_CELL_QUERY = "tbody tr[tabindex], tbody tr td[tabindex], tbody tr th[tabindex]";
11
11
  export const FlatTable = ({
@@ -31,7 +31,6 @@ export const FlatTable = ({
31
31
  const [hasHorizontalScrollbar, setHasHorizontalScrollbar] = useState(false);
32
32
  const [firstColRowSpanIndex, setFirstColRowSpanIndex] = useState(-1);
33
33
  const [lastColRowSpanIndex, setLastColRowSpanIndex] = useState(-1);
34
- const [selectedId, setSelectedId] = useState("");
35
34
  const addDefaultHeight = !height && (hasStickyHead || hasStickyFooter);
36
35
  const tableStylingProps = {
37
36
  caption,
@@ -124,32 +123,14 @@ export const FlatTable = ({
124
123
  }
125
124
  }
126
125
  };
127
- useLayoutEffect(() => {
128
- const findSelectedId = () => {
129
- const firstfocusableElement = tableRef.current?.querySelector(FOCUSABLE_ROW_AND_CELL_QUERY);
130
-
131
- // if no other menu item is selected, we need to make the first row a tab stop
132
- if (firstfocusableElement && !selectedId) {
133
- const currentlySelectedId = firstfocusableElement?.getAttribute("id");
134
-
135
- /* istanbul ignore else */
136
- if (currentlySelectedId && selectedId !== currentlySelectedId) {
137
- setSelectedId(currentlySelectedId);
138
- }
139
- }
140
- };
141
- const observer = new MutationObserver(findSelectedId);
126
+ const getTabStopElementId = () => {
127
+ const focusableElements = Array.from(tableRef.current?.querySelectorAll(FOCUSABLE_ROW_AND_CELL_QUERY) || /* istanbul ignore next */[]);
142
128
 
143
- /* istanbul ignore else */
144
- if (wrapperRef.current) {
145
- observer.observe(wrapperRef.current, {
146
- subtree: true,
147
- childList: true,
148
- attributes: true
149
- });
150
- }
151
- return () => observer.disconnect();
152
- }, [selectedId]);
129
+ // if no other row is selected/ highlighted, we need to make the first row/ cell a tab stop
130
+ const focusableElement = focusableElements.find(el => el.getAttribute("data-selected") === "true" || el.getAttribute("data-highlighted") === "true") || focusableElements[0];
131
+ const currentlySelectedId = focusableElement?.getAttribute("id") || "";
132
+ return currentlySelectedId;
133
+ };
153
134
  return /*#__PURE__*/React.createElement(StyledFlatTableWrapper, _extends({
154
135
  ref: wrapperRef,
155
136
  "data-component": "flat-table-wrapper",
@@ -184,8 +165,7 @@ export const FlatTable = ({
184
165
  value: {
185
166
  colorTheme,
186
167
  size,
187
- setSelectedId,
188
- selectedId
168
+ getTabStopElementId
189
169
  }
190
170
  }, children))), footer && /*#__PURE__*/React.createElement(StyledFlatTableFooter, {
191
171
  hasStickyFooter: hasStickyFooter
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { MarginProps } from "styled-system";
3
- export declare type MessageVariant = "error" | "info" | "success" | "warning";
3
+ export declare type MessageVariant = "error" | "info" | "success" | "warning" | "neutral";
4
4
  export interface MessageProps extends MarginProps {
5
5
  /** set content to component */
6
6
  children?: React.ReactNode;
@@ -217,7 +217,7 @@ Message.propTypes = {
217
217
  "showCloseIcon": PropTypes.bool,
218
218
  "title": PropTypes.node,
219
219
  "transparent": PropTypes.bool,
220
- "variant": PropTypes.oneOf(["error", "info", "success", "warning"])
220
+ "variant": PropTypes.oneOf(["error", "info", "neutral", "success", "warning"])
221
221
  };
222
222
  export { Message };
223
223
  Message.displayName = "Message";
@@ -4,9 +4,10 @@ import BaseTheme from "../../style/themes/base";
4
4
  import StyledIconButton from "../icon-button/icon-button.style";
5
5
  const messageVariants = {
6
6
  error: "var(--colorsSemanticNegative500)",
7
- info: "var(--colorsSemanticNeutral500)",
7
+ info: "var(--colorsSemanticInfo500)",
8
8
  success: "var(--colorsSemanticPositive500)",
9
- warning: "var(--colorsSemanticCaution500)"
9
+ warning: "var(--colorsSemanticCaution500)",
10
+ neutral: "var(--colorsSemanticNeutral500)"
10
11
  };
11
12
  const MessageStyle = styled.div`
12
13
  position: relative;
@@ -6,11 +6,16 @@ const TypeIcon = ({
6
6
  variant = "info",
7
7
  transparent = false
8
8
  }) => {
9
+ function iconToRender() {
10
+ if (variant === "neutral") return "info";
11
+ if (variant === "success") return "tick_circle";
12
+ return variant;
13
+ }
9
14
  return /*#__PURE__*/React.createElement(TypeIconStyle, {
10
15
  variant: variant,
11
16
  transparent: transparent
12
17
  }, /*#__PURE__*/React.createElement(Icon, {
13
- type: variant
18
+ type: iconToRender()
14
19
  }));
15
20
  };
16
21
  export default TypeIcon;
@@ -1,9 +1,11 @@
1
1
  import styled, { css } from "styled-components";
2
2
  const messageVariants = {
3
3
  error: "var(--colorsSemanticNegative500)",
4
- info: "var(--colorsSemanticNeutral500)",
4
+ info: "var(--colorsSemanticInfo500)",
5
5
  success: "var(--colorsSemanticPositive500)",
6
- warning: "var(--colorsSemanticCaution500)"
6
+ warning: "var(--colorsSemanticCaution500)",
7
+ neutral: "var(--colorsSemanticNeutral500)",
8
+ notification: "var(--colorsSemanticInfo500)"
7
9
  };
8
10
  const TypeIconStyle = styled.div`
9
11
  align-items: center;
@@ -1,6 +1,9 @@
1
1
  import React from "react";
2
- declare type ToastVariants = "error" | "info" | "success" | "warning" | "notice";
2
+ declare type ToastVariants = "error" | "info" | "success" | "warning" | "notice" | "neutral" | "notification";
3
+ declare type AlignOptions = "left" | "center" | "right";
3
4
  export interface ToastProps {
5
+ /** Sets the alignment of the component. */
6
+ align?: AlignOptions;
4
7
  /** The rendered children of the component. */
5
8
  children: React.ReactNode;
6
9
  /** Customizes the appearance in the DLS theme */
@@ -9,7 +9,10 @@ import IconButton from "../icon-button";
9
9
  import Events from "../../__internal__/utils/helpers/events";
10
10
  import useLocale from "../../hooks/__internal__/useLocale";
11
11
  import useModalManager from "../../hooks/__internal__/useModalManager";
12
+ import Logger from "../../__internal__/utils/logger";
13
+ let isDeprecationWarningTriggered = false;
12
14
  const Toast = /*#__PURE__*/React.forwardRef(({
15
+ align,
13
16
  children,
14
17
  className,
15
18
  id,
@@ -24,6 +27,7 @@ const Toast = /*#__PURE__*/React.forwardRef(({
24
27
  ...restProps
25
28
  }, ref) => {
26
29
  const isNotice = variant === "notice";
30
+ const isNotification = variant === "notification";
27
31
  const locale = useLocale();
28
32
  const toastRef = useRef(null);
29
33
  const timer = useRef(null);
@@ -35,6 +39,10 @@ const Toast = /*#__PURE__*/React.forwardRef(({
35
39
  if (ref && typeof ref === "object" && "current" in ref) {
36
40
  refToPass = ref;
37
41
  }
42
+ if (isCenter !== undefined && !isDeprecationWarningTriggered) {
43
+ isDeprecationWarningTriggered = true;
44
+ Logger.deprecate(`isCenter prop in ${Toast.displayName} is being deprecated in favour of the align prop.`);
45
+ }
38
46
  const dismissToast = useCallback(ev => {
39
47
  if (onDismiss && Events.isEscKey(ev)) {
40
48
  ev.stopImmediatePropagation();
@@ -87,10 +95,19 @@ const Toast = /*#__PURE__*/React.forwardRef(({
87
95
  type: "close"
88
96
  }));
89
97
  }
98
+ const iconToRender = {
99
+ notification: "alert",
100
+ neutral: "info",
101
+ success: "tick_circle",
102
+ error: "error",
103
+ info: "info",
104
+ warning: "warning"
105
+ };
106
+ const toastIcon = iconToRender[variant] || "none";
90
107
  function renderToastContent() {
91
108
  if (!open) return null;
92
109
  let toastVariant;
93
- if (variant !== "notice") {
110
+ if (!isNotice && !isNotification) {
94
111
  toastVariant = variant;
95
112
  }
96
113
  return /*#__PURE__*/React.createElement(CSSTransition, {
@@ -103,7 +120,9 @@ const Toast = /*#__PURE__*/React.forwardRef(({
103
120
  },
104
121
  nodeRef: toastContentNodeRef
105
122
  }, /*#__PURE__*/React.createElement(ToastStyle, _extends({
123
+ align: align,
106
124
  isNotice: isNotice,
125
+ isNotification: isNotification,
107
126
  className: className
108
127
  }, tagComponent(restProps["data-component"] || "toast", restProps), {
109
128
  isCenter: isCenter,
@@ -114,10 +133,10 @@ const Toast = /*#__PURE__*/React.forwardRef(({
114
133
  }, !disableAutoFocus && {
115
134
  tabIndex,
116
135
  onBlur: () => setTabIndex(undefined)
117
- }), variant !== "notice" && /*#__PURE__*/React.createElement(TypeIcon, {
118
- variant: variant
136
+ }), !isNotice && /*#__PURE__*/React.createElement(TypeIcon, {
137
+ variant: isNotification ? "info" : variant
119
138
  }, /*#__PURE__*/React.createElement(Icon, {
120
- type: variant
139
+ type: toastIcon
121
140
  })), /*#__PURE__*/React.createElement(ToastContentStyle, {
122
141
  isNotice: isNotice,
123
142
  isDismiss: !!onDismiss
@@ -125,15 +144,18 @@ const Toast = /*#__PURE__*/React.forwardRef(({
125
144
  }
126
145
  return /*#__PURE__*/React.createElement(StyledPortal, {
127
146
  id: targetPortalId,
147
+ align: align,
128
148
  isCenter: isCenter,
129
149
  isNotice: isNotice
130
150
  }, /*#__PURE__*/React.createElement(ToastWrapper, {
151
+ align: align,
131
152
  isCenter: isCenter,
132
153
  ref: refToPass,
133
154
  isNotice: isNotice
134
155
  }, /*#__PURE__*/React.createElement(TransitionGroup, null, renderToastContent())));
135
156
  });
136
157
  Toast.propTypes = {
158
+ "align": PropTypes.oneOf(["center", "left", "right"]),
137
159
  "children": PropTypes.node,
138
160
  "className": PropTypes.string,
139
161
  "data-component": PropTypes.string,
@@ -145,7 +167,7 @@ Toast.propTypes = {
145
167
  "open": PropTypes.bool,
146
168
  "targetPortalId": PropTypes.string,
147
169
  "timeout": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
148
- "variant": PropTypes.oneOf(["error", "info", "notice", "success", "warning"])
170
+ "variant": PropTypes.oneOf(["error", "info", "neutral", "notice", "notification", "success", "warning"])
149
171
  };
150
172
  export { Toast };
151
173
  Toast.displayName = "Toast";
@@ -1,2 +1,2 @@
1
1
  // eslint-disable-next-line import/prefer-default-export
2
- export const TOAST_COLORS = ["error", "info", "success", "warning"];
2
+ export const TOAST_COLORS = ["error", "info", "success", "warning", "neutral", "notification"];
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import TypeIcon from "../message/type-icon/type-icon.style";
3
3
  declare const StyledPortal: import("styled-components").StyledComponent<({ children, className, id, onReposition }: import("../portal/portal").PortalProps) => import("react").JSX.Element, any, {
4
+ align?: "left" | "right" | "center" | undefined;
4
5
  isCenter?: boolean | undefined;
5
6
  isNotice?: boolean | undefined;
6
7
  }, never>;
@@ -8,15 +9,18 @@ declare const ToastStyle: import("styled-components").StyledComponent<"div", any
8
9
  variant?: import("../message/message.component").MessageVariant | undefined;
9
10
  transparent?: boolean | undefined;
10
11
  } & import("styled-system").MarginProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
12
+ align?: "left" | "right" | "center" | undefined;
11
13
  maxWidth?: string | undefined;
12
14
  isCenter?: boolean | undefined;
13
15
  isNotice?: boolean | undefined;
16
+ isNotification?: boolean | undefined;
14
17
  }, never>;
15
18
  declare const ToastContentStyle: import("styled-components").StyledComponent<"div", any, Pick<import("../message/message-content/message-content.component").MessageContentProps, "showCloseIcon"> & {
16
19
  isNotice?: boolean | undefined;
17
20
  isDismiss?: boolean | undefined;
18
21
  }, never>;
19
22
  declare const ToastWrapper: import("styled-components").StyledComponent<"div", any, {
23
+ align?: "left" | "right" | "center" | undefined;
20
24
  isCenter?: boolean | undefined;
21
25
  isNotice?: boolean | undefined;
22
26
  }, never>;
@@ -10,7 +10,8 @@ const StyledPortal = styled(Portal)`
10
10
  ${({
11
11
  theme,
12
12
  isCenter,
13
- isNotice
13
+ isNotice,
14
+ align
14
15
  }) => css`
15
16
  position: fixed;
16
17
  top: 0;
@@ -22,6 +23,22 @@ const StyledPortal = styled(Portal)`
22
23
  transform: translateX(-50%);
23
24
  `}
24
25
 
26
+ ${align === "left" && css`
27
+ left: 12%;
28
+ transform: translateX(-50%);
29
+ `}
30
+
31
+ ${align === "center" && css`
32
+ margin-left: 50%;
33
+ transform: translateX(-50%);
34
+ `}
35
+
36
+ ${align === "right" && css`
37
+ display: flex;
38
+ right: 0;
39
+ transform: translateX(-50%);
40
+ `}
41
+
25
42
  ${isNotice && css`
26
43
  bottom: 0;
27
44
  top: auto;
@@ -37,7 +54,9 @@ const alternativeAnimationName = ".toast-alternative";
37
54
  const ToastStyle = styled(MessageStyle)`
38
55
  ${({
39
56
  maxWidth,
40
- isCenter
57
+ isCenter,
58
+ align,
59
+ isNotification
41
60
  }) => css`
42
61
  box-shadow: 0 10px 30px 0 rgba(0, 20, 29, 0.1),
43
62
  0 30px 60px 0 rgba(0, 20, 29, 0.1);
@@ -45,7 +64,11 @@ const ToastStyle = styled(MessageStyle)`
45
64
  margin-top: 30px;
46
65
  max-width: ${!maxWidth ? "300px" : maxWidth};
47
66
  position: relative;
48
- margin-right: ${isCenter ? "auto" : "30px"};
67
+ margin-right: ${isCenter || align === "right" ? "auto" : "30px"};
68
+
69
+ ${isNotification && css`
70
+ border: 1px solid var(--colorsSemanticInfo500);
71
+ `}
49
72
  `}
50
73
 
51
74
  :focus {
@@ -139,6 +162,16 @@ const ToastContentStyle = styled(MessageContentStyle)`
139
162
  `}
140
163
  `;
141
164
  const ToastWrapper = styled.div`
165
+ ${({
166
+ align
167
+ }) => align && css`
168
+ position: relative;
169
+ width: auto;
170
+ height: auto;
171
+ justify-content: ${align};
172
+ display: flex;
173
+ `}
174
+
142
175
  ${({
143
176
  isCenter
144
177
  }) => isCenter && css`
@@ -1,2 +1,2 @@
1
- export { default as useCalculateStickyCells } from "./use-calculate-sticky-cells";
1
+ export { default as useTableCell } from "./use-table-cell";
2
2
  export { default as buildPositionMap } from "./build-position-map";
@@ -9,12 +9,12 @@ Object.defineProperty(exports, "buildPositionMap", {
9
9
  return _buildPositionMap.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "useCalculateStickyCells", {
12
+ Object.defineProperty(exports, "useTableCell", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _useCalculateStickyCells.default;
15
+ return _useTableCell.default;
16
16
  }
17
17
  });
18
- var _useCalculateStickyCells = _interopRequireDefault(require("./use-calculate-sticky-cells"));
18
+ var _useTableCell = _interopRequireDefault(require("./use-table-cell"));
19
19
  var _buildPositionMap = _interopRequireDefault(require("./build-position-map"));
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -8,5 +8,8 @@ declare const _default: (id: string) => {
8
8
  onKeyDown: ((ev: import("react").KeyboardEvent<HTMLElement>) => void) | undefined;
9
9
  isFirstCell: boolean;
10
10
  isExpandableCell: boolean | undefined;
11
+ tabIndex: number;
12
+ isInHighlightedRow: boolean | undefined;
13
+ isInSelectedRow: boolean | undefined;
11
14
  };
12
15
  export default _default;