carbon-react 152.3.1 → 152.5.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.
@@ -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
  declare 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`
@@ -1,6 +1,6 @@
1
1
  import { SpaceProps } from "styled-system";
2
2
  import { TileProps } from "./tile.component";
3
- declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant" | "highlightVariant"> & {
3
+ declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "highlightVariant" | "roundness" | "borderWidth" | "borderVariant"> & {
4
4
  isHorizontal?: boolean | undefined;
5
5
  } & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
6
6
  export default StyledTile;
@@ -12,5 +12,5 @@ export interface VerticalMenuFullScreenProps extends TagProps {
12
12
  /** A callback to be called when the close icon is clicked or enter is pressed when focused */
13
13
  onClose: (ev: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement> | KeyboardEvent) => void;
14
14
  }
15
- export declare const VerticalMenuFullScreen: ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children, isOpen, onClose, ...rest }: VerticalMenuFullScreenProps) => React.JSX.Element | null;
15
+ export declare const VerticalMenuFullScreen: ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children, isOpen, onClose, ...rest }: VerticalMenuFullScreenProps) => React.JSX.Element;
16
16
  export default VerticalMenuFullScreen;
@@ -12,6 +12,7 @@ import VerticalMenuFullScreenContext from "./__internal__/vertical-menu-full-scr
12
12
  import { getDocument } from "../../../__internal__/dom/globals";
13
13
  import Events from "../../../__internal__/utils/helpers/events/events";
14
14
  import useModalManager from "../../../hooks/__internal__/useModalManager";
15
+ import useMediaQuery from "../../../hooks/useMediaQuery";
15
16
  export const VerticalMenuFullScreen = ({
16
17
  "aria-label": ariaLabel,
17
18
  "aria-labelledby": ariaLabelledBy,
@@ -22,6 +23,7 @@ export const VerticalMenuFullScreen = ({
22
23
  }) => {
23
24
  const l = useLocale();
24
25
  const menuWrapperRef = useRef(null);
26
+ const reduceMotion = !useMediaQuery("screen and (prefers-reduced-motion: no-preference)");
25
27
  const handleKeyDown = useCallback(ev => {
26
28
  // istanbul ignore else
27
29
  if (Events.isEscKey(ev)) {
@@ -36,14 +38,13 @@ export const VerticalMenuFullScreen = ({
36
38
  topModalOverride: true,
37
39
  focusCallToActionElement: safeDocument?.activeElement
38
40
  });
39
-
40
- // TODO remove this as part of FE-5650
41
- if (!isOpen) return null;
42
41
  return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(FocusTrap, {
43
42
  isOpen: isOpen,
44
43
  wrapperRef: menuWrapperRef
45
44
  }, /*#__PURE__*/React.createElement(StyledVerticalMenuFullScreen, _extends({
46
45
  ref: menuWrapperRef,
46
+ isOpen: isOpen,
47
+ prefersReducedMotion: reduceMotion,
47
48
  scrollVariant: "light",
48
49
  as: "nav",
49
50
  "aria-label": ariaLabel,
@@ -62,9 +63,7 @@ export const VerticalMenuFullScreen = ({
62
63
  "data-element": "close"
63
64
  }, /*#__PURE__*/React.createElement(Icon, {
64
65
  type: "close",
65
- color: "var(--colorsComponentsLeftnavWinterStandardContent)",
66
- bgSize: "small",
67
- fontSize: "medium"
66
+ color: "var(--colorsComponentsLeftnavWinterStandardContent)"
68
67
  }))), /*#__PURE__*/React.createElement(VerticalMenuFullScreenContext.Provider, {
69
68
  value: {
70
69
  isFullScreen: true
@@ -18,6 +18,10 @@ export declare const StyledVerticalMenu: import("styled-components").StyledCompo
18
18
  width?: string | undefined;
19
19
  } | undefined;
20
20
  }, never>;
21
+ interface FullScreenProps {
22
+ isOpen: boolean;
23
+ prefersReducedMotion?: boolean;
24
+ }
21
25
  export declare const StyledVerticalMenuFullScreen: import("styled-components").StyledComponent<"div", any, import("../box").BoxProps & {
22
26
  cssProps?: {
23
27
  color?: string | undefined;
@@ -25,5 +29,5 @@ export declare const StyledVerticalMenuFullScreen: import("styled-components").S
25
29
  height?: string | undefined;
26
30
  width?: string | undefined;
27
31
  } | undefined;
28
- }, never>;
32
+ } & FullScreenProps, never>;
29
33
  export {};
@@ -114,11 +114,30 @@ export const StyledVerticalMenuFullScreen = styled(StyledBox)`
114
114
  overflow: auto;
115
115
  background-color: var(--colorsComponentsLeftnavWinterStandardBackground);
116
116
  box-sizing: border-box;
117
- transition: all 0.3s ease;
118
117
  z-index: ${({
119
118
  theme
120
119
  }) => theme.zIndex.fullScreenModal};
121
120
 
121
+ ${({
122
+ prefersReducedMotion
123
+ }) => !prefersReducedMotion && css`
124
+ transition: all 0.3s ease;
125
+ `}
126
+
127
+ ${({
128
+ isOpen
129
+ }) => isOpen && css`
130
+ visibility: visible;
131
+ transform: translateX(0);
132
+ `}
133
+
134
+ ${({
135
+ isOpen
136
+ }) => !isOpen && css`
137
+ transform: translateX(-100%);
138
+ visibility: hidden;
139
+ `}
140
+
122
141
  // TODO remove hardcoded values when DS have had chance to review which token to use
123
142
  &::-webkit-scrollbar-track {
124
143
  background-color: #cccccc;
@@ -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 */
@@ -40,6 +40,7 @@ const Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(({
40
40
  bespokeFocusTrap,
41
41
  disableClose,
42
42
  help,
43
+ highlightVariant = "default",
43
44
  role = "dialog",
44
45
  contentPadding = {},
45
46
  greyBackground = false,
@@ -124,6 +125,7 @@ const Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(({
124
125
  "aria-modal": isTopModal ? true : undefined,
125
126
  ref: containerRef
126
127
  }, dialogProps, {
128
+ highlightVariant: highlightVariant,
127
129
  role: role,
128
130
  tabIndex: -1
129
131
  }, 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
  declare type StyledDialogTitleProps = {
8
9
  showCloseIcon?: boolean;
@@ -60,6 +60,20 @@ const StyledDialog = exports.StyledDialog = _styledComponents.default.div`
60
60
  outline: none;
61
61
  }
62
62
 
63
+ ${({
64
+ highlightVariant
65
+ }) => highlightVariant === "ai" && `
66
+ &::before {
67
+ content: "";
68
+ position: absolute;
69
+ top: -8px;
70
+ height: 100px;
71
+ width: 100%;
72
+ z-index: -1;
73
+ background: linear-gradient(90deg, #00D639 0%, #00D6DE 40%, #9D60FF 90%);
74
+ border-radius: var(--borderRadius200) var(--borderRadius200) 0 0;
75
+ }`}
76
+
63
77
  ${({
64
78
  backgroundColor
65
79
  }) => (0, _styledComponents.css)`
@@ -1,6 +1,6 @@
1
1
  import { SpaceProps } from "styled-system";
2
2
  import { TileProps } from "./tile.component";
3
- declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant" | "highlightVariant"> & {
3
+ declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "highlightVariant" | "roundness" | "borderWidth" | "borderVariant"> & {
4
4
  isHorizontal?: boolean | undefined;
5
5
  } & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
6
6
  export default StyledTile;
@@ -12,5 +12,5 @@ export interface VerticalMenuFullScreenProps extends TagProps {
12
12
  /** A callback to be called when the close icon is clicked or enter is pressed when focused */
13
13
  onClose: (ev: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement> | KeyboardEvent) => void;
14
14
  }
15
- export declare const VerticalMenuFullScreen: ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children, isOpen, onClose, ...rest }: VerticalMenuFullScreenProps) => React.JSX.Element | null;
15
+ export declare const VerticalMenuFullScreen: ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children, isOpen, onClose, ...rest }: VerticalMenuFullScreenProps) => React.JSX.Element;
16
16
  export default VerticalMenuFullScreen;
@@ -17,6 +17,7 @@ var _verticalMenuFullScreen = _interopRequireDefault(require("./__internal__/ver
17
17
  var _globals = require("../../../__internal__/dom/globals");
18
18
  var _events = _interopRequireDefault(require("../../../__internal__/utils/helpers/events/events"));
19
19
  var _useModalManager = _interopRequireDefault(require("../../../hooks/__internal__/useModalManager"));
20
+ var _useMediaQuery = _interopRequireDefault(require("../../../hooks/useMediaQuery"));
20
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
22
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
22
23
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -31,6 +32,7 @@ const VerticalMenuFullScreen = ({
31
32
  }) => {
32
33
  const l = (0, _useLocale.default)();
33
34
  const menuWrapperRef = (0, _react.useRef)(null);
35
+ const reduceMotion = !(0, _useMediaQuery.default)("screen and (prefers-reduced-motion: no-preference)");
34
36
  const handleKeyDown = (0, _react.useCallback)(ev => {
35
37
  // istanbul ignore else
36
38
  if (_events.default.isEscKey(ev)) {
@@ -45,14 +47,13 @@ const VerticalMenuFullScreen = ({
45
47
  topModalOverride: true,
46
48
  focusCallToActionElement: safeDocument?.activeElement
47
49
  });
48
-
49
- // TODO remove this as part of FE-5650
50
- if (!isOpen) return null;
51
50
  return /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement(_focusTrap.default, {
52
51
  isOpen: isOpen,
53
52
  wrapperRef: menuWrapperRef
54
53
  }, /*#__PURE__*/_react.default.createElement(_verticalMenu.StyledVerticalMenuFullScreen, _extends({
55
54
  ref: menuWrapperRef,
55
+ isOpen: isOpen,
56
+ prefersReducedMotion: reduceMotion,
56
57
  scrollVariant: "light",
57
58
  as: "nav",
58
59
  "aria-label": ariaLabel,
@@ -71,9 +72,7 @@ const VerticalMenuFullScreen = ({
71
72
  "data-element": "close"
72
73
  }, /*#__PURE__*/_react.default.createElement(_icon.default, {
73
74
  type: "close",
74
- color: "var(--colorsComponentsLeftnavWinterStandardContent)",
75
- bgSize: "small",
76
- fontSize: "medium"
75
+ color: "var(--colorsComponentsLeftnavWinterStandardContent)"
77
76
  }))), /*#__PURE__*/_react.default.createElement(_verticalMenuFullScreen.default.Provider, {
78
77
  value: {
79
78
  isFullScreen: true
@@ -18,6 +18,10 @@ export declare const StyledVerticalMenu: import("styled-components").StyledCompo
18
18
  width?: string | undefined;
19
19
  } | undefined;
20
20
  }, never>;
21
+ interface FullScreenProps {
22
+ isOpen: boolean;
23
+ prefersReducedMotion?: boolean;
24
+ }
21
25
  export declare const StyledVerticalMenuFullScreen: import("styled-components").StyledComponent<"div", any, import("../box").BoxProps & {
22
26
  cssProps?: {
23
27
  color?: string | undefined;
@@ -25,5 +29,5 @@ export declare const StyledVerticalMenuFullScreen: import("styled-components").S
25
29
  height?: string | undefined;
26
30
  width?: string | undefined;
27
31
  } | undefined;
28
- }, never>;
32
+ } & FullScreenProps, never>;
29
33
  export {};
@@ -123,11 +123,30 @@ const StyledVerticalMenuFullScreen = exports.StyledVerticalMenuFullScreen = (0,
123
123
  overflow: auto;
124
124
  background-color: var(--colorsComponentsLeftnavWinterStandardBackground);
125
125
  box-sizing: border-box;
126
- transition: all 0.3s ease;
127
126
  z-index: ${({
128
127
  theme
129
128
  }) => theme.zIndex.fullScreenModal};
130
129
 
130
+ ${({
131
+ prefersReducedMotion
132
+ }) => !prefersReducedMotion && (0, _styledComponents.css)`
133
+ transition: all 0.3s ease;
134
+ `}
135
+
136
+ ${({
137
+ isOpen
138
+ }) => isOpen && (0, _styledComponents.css)`
139
+ visibility: visible;
140
+ transform: translateX(0);
141
+ `}
142
+
143
+ ${({
144
+ isOpen
145
+ }) => !isOpen && (0, _styledComponents.css)`
146
+ transform: translateX(-100%);
147
+ visibility: hidden;
148
+ `}
149
+
131
150
  // TODO remove hardcoded values when DS have had chance to review which token to use
132
151
  &::-webkit-scrollbar-track {
133
152
  background-color: #cccccc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "152.3.1",
3
+ "version": "152.5.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",