carbon-react 105.0.0 → 105.1.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 (51) hide show
  1. package/esm/__internal__/popover/popover.component.d.ts +1 -1
  2. package/esm/__internal__/popover/popover.component.js +15 -5
  3. package/esm/components/button/button.component.js +1 -1
  4. package/esm/components/menu/menu-full-screen/menu-full-screen.component.js +2 -1
  5. package/esm/components/menu/menu.component.js +2 -1
  6. package/esm/components/menu/menu.context.d.ts +1 -0
  7. package/esm/components/menu/menu.context.js +2 -1
  8. package/esm/components/menu/menu.d.ts +1 -0
  9. package/esm/components/modal/modal.component.js +2 -1
  10. package/esm/components/multi-action-button/multi-action-button.component.js +1 -1
  11. package/esm/components/select/__internal__/select-text/select-text.component.d.ts +1 -5
  12. package/esm/components/select/__internal__/select-text/select-text.component.js +4 -28
  13. package/esm/components/select/select-textbox/select-textbox.component.js +5 -2
  14. package/esm/components/split-button/split-button.component.js +1 -1
  15. package/esm/components/tile/tile.component.d.ts +3 -2
  16. package/esm/components/tile/tile.component.js +14 -2
  17. package/esm/components/tile/tile.d.ts +2 -0
  18. package/esm/components/toast/toast.component.d.ts +1 -1
  19. package/esm/components/toast/toast.component.js +10 -2
  20. package/esm/components/vertical-divider/index.d.ts +1 -2
  21. package/esm/components/vertical-divider/vertical-divider.component.d.ts +11 -9
  22. package/esm/components/vertical-divider/vertical-divider.component.js +1410 -25
  23. package/esm/components/vertical-divider/vertical-divider.style.d.ts +4 -2
  24. package/esm/components/vertical-divider/vertical-divider.style.js +1 -1
  25. package/lib/__internal__/popover/popover.component.d.ts +1 -1
  26. package/lib/__internal__/popover/popover.component.js +15 -4
  27. package/lib/components/button/button.component.js +1 -1
  28. package/lib/components/menu/menu-full-screen/menu-full-screen.component.js +2 -1
  29. package/lib/components/menu/menu.component.js +2 -1
  30. package/lib/components/menu/menu.context.d.ts +1 -0
  31. package/lib/components/menu/menu.context.js +2 -1
  32. package/lib/components/menu/menu.d.ts +1 -0
  33. package/lib/components/modal/modal.component.js +2 -1
  34. package/lib/components/multi-action-button/multi-action-button.component.js +1 -1
  35. package/lib/components/select/__internal__/select-text/select-text.component.d.ts +1 -5
  36. package/lib/components/select/__internal__/select-text/select-text.component.js +4 -33
  37. package/lib/components/select/select-textbox/select-textbox.component.js +5 -2
  38. package/lib/components/split-button/split-button.component.js +1 -1
  39. package/lib/components/tile/tile.component.d.ts +3 -2
  40. package/lib/components/tile/tile.component.js +17 -2
  41. package/lib/components/tile/tile.d.ts +2 -0
  42. package/lib/components/toast/toast.component.d.ts +1 -1
  43. package/lib/components/toast/toast.component.js +13 -2
  44. package/lib/components/vertical-divider/index.d.ts +1 -2
  45. package/lib/components/vertical-divider/vertical-divider.component.d.ts +11 -9
  46. package/lib/components/vertical-divider/vertical-divider.component.js +1459 -28
  47. package/lib/components/vertical-divider/vertical-divider.style.d.ts +4 -2
  48. package/lib/components/vertical-divider/vertical-divider.style.js +1 -1
  49. package/package.json +1 -1
  50. package/esm/components/vertical-divider/vertical-divider.d.ts +0 -113
  51. package/lib/components/vertical-divider/vertical-divider.d.ts +0 -113
@@ -16,7 +16,7 @@ declare namespace Popover {
16
16
  const modifiers: PropTypes.Requireable<any[]>;
17
17
  const onFirstUpdate: PropTypes.Requireable<(...args: any[]) => any>;
18
18
  const disablePortal: PropTypes.Requireable<boolean>;
19
- const reference: PropTypes.Requireable<PropTypes.InferProps<{
19
+ const reference: PropTypes.Validator<PropTypes.InferProps<{
20
20
  current: PropTypes.Requireable<any>;
21
21
  }>>;
22
22
  }
@@ -1,10 +1,11 @@
1
- import React, { useEffect, useLayoutEffect, useRef } from "react";
1
+ import React, { useContext, useEffect, useLayoutEffect, useRef } from "react";
2
2
  import ReactDOM from "react-dom";
3
3
  import PropTypes from "prop-types";
4
4
  import { createPopper } from "@popperjs/core";
5
5
  import useResizeObserver from "../../hooks/__internal__/useResizeObserver";
6
6
  import StyledBackdrop from "./popover.style";
7
7
  import CarbonScopedTokensProvider from "../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component";
8
+ import { ModalContext } from "../../components/modal/modal.component";
8
9
 
9
10
  const Popover = ({
10
11
  children,
@@ -16,10 +17,18 @@ const Popover = ({
16
17
  disableBackgroundUI
17
18
  }) => {
18
19
  const elementDOM = useRef();
20
+ const {
21
+ isInModal
22
+ } = useContext(ModalContext);
23
+ let mountNode = document.body;
24
+
25
+ if (isInModal && reference.current) {
26
+ mountNode = reference.current.closest("[role='dialog']");
27
+ }
19
28
 
20
29
  if (!elementDOM.current && !disablePortal) {
21
30
  elementDOM.current = document.createElement("div");
22
- document.body.appendChild(elementDOM.current);
31
+ mountNode.appendChild(elementDOM.current);
23
32
  }
24
33
 
25
34
  const popperInstance = useRef();
@@ -68,10 +77,11 @@ const Popover = ({
68
77
  useEffect(() => {
69
78
  return () => {
70
79
  if (!disablePortal) {
71
- document.body.removeChild(elementDOM.current);
80
+ mountNode.removeChild(elementDOM.current);
81
+ elementDOM.current = null;
72
82
  }
73
83
  };
74
- }, [disablePortal]);
84
+ }, [disablePortal, mountNode]);
75
85
 
76
86
  if (disableBackgroundUI) {
77
87
  content = /*#__PURE__*/React.createElement(StyledBackdrop, null, content);
@@ -102,6 +112,6 @@ Popover.propTypes = {
102
112
  // Reference element, children will be positioned in relation to this element - should be a ref
103
113
  reference: PropTypes.shape({
104
114
  current: PropTypes.any
105
- })
115
+ }).isRequired
106
116
  };
107
117
  export default Popover;
@@ -78,7 +78,7 @@ const Button = ({
78
78
  if (!deprecatedWarnTriggered && as) {
79
79
  deprecatedWarnTriggered = true;
80
80
  Logger.deprecate( // eslint-disable-next-line max-len
81
- "The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
81
+ "The `as` prop is deprecated and will soon be removed from the `Button` component interface. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
82
82
  }
83
83
 
84
84
  const [internalRef, setInternalRef] = useState(null);
@@ -98,7 +98,8 @@ const MenuFullscreen = ({
98
98
  }, React.Children.map(children, (child, index) => /*#__PURE__*/React.createElement(MenuContext.Provider, {
99
99
  value: {
100
100
  inFullscreenView: true,
101
- menuType
101
+ menuType,
102
+ inMenu: true
102
103
  }
103
104
  }, child, index < React.Children.count(children) - 1 && /*#__PURE__*/React.createElement(MenuDivider, null)))))))));
104
105
  };
@@ -43,7 +43,8 @@ const Menu = ({
43
43
  value: {
44
44
  menuType,
45
45
  handleKeyDown: ev => handleKeyDown(ev, index),
46
- isFocused
46
+ isFocused,
47
+ inMenu: true
47
48
  }
48
49
  }, child);
49
50
  }));
@@ -1,5 +1,6 @@
1
1
  declare var _default: React.Context<{
2
2
  menuType: string;
3
+ inMenu: boolean;
3
4
  }>;
4
5
  export default _default;
5
6
  import React from "react";
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
2
  export default /*#__PURE__*/React.createContext({
3
- menuType: "light"
3
+ menuType: "light",
4
+ inMenu: false
4
5
  });
@@ -8,6 +8,7 @@ interface MenuContextProps {
8
8
  handleKeyDown: (ev, submenuOpen) => void;
9
9
  isFocused: boolean;
10
10
  openSubmenu: boolean;
11
+ inMenu: boolean;
11
12
  }
12
13
 
13
14
  export interface MenuProps extends LayoutProps, FlexBoxProps {
@@ -140,7 +140,8 @@ const Modal = ({
140
140
  }, /*#__PURE__*/React.createElement(ModalContext.Provider, {
141
141
  value: {
142
142
  isAnimationComplete,
143
- triggerRefocusFlag
143
+ triggerRefocusFlag,
144
+ isInModal: true
144
145
  }
145
146
  }, content)))));
146
147
  };
@@ -27,7 +27,7 @@ const MultiActionButton = ({
27
27
  if (!deprecatedWarnTriggered && as) {
28
28
  deprecatedWarnTriggered = true;
29
29
  Logger.deprecate( // eslint-disable-next-line max-len
30
- "The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
30
+ "The `as` prop is deprecated and will soon be removed from the `MultiActionButton` component interface. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
31
31
  }
32
32
 
33
33
  const ref = useRef();
@@ -1,11 +1,9 @@
1
1
  export default SelectText;
2
- declare function SelectText({ disabled, formattedValue, onClick, onKeyDown, onFocus, onBlur, onMouseDown, placeholder, readOnly, textId, transparent, }: {
2
+ declare function SelectText({ disabled, formattedValue, onClick, onKeyDown, onMouseDown, placeholder, readOnly, textId, transparent, }: {
3
3
  disabled: any;
4
4
  formattedValue?: string | undefined;
5
5
  onClick: any;
6
6
  onKeyDown: any;
7
- onFocus: any;
8
- onBlur: any;
9
7
  onMouseDown: any;
10
8
  placeholder: any;
11
9
  readOnly: any;
@@ -16,9 +14,7 @@ declare namespace SelectText {
16
14
  namespace propTypes {
17
15
  const disabled: PropTypes.Requireable<boolean>;
18
16
  const formattedValue: PropTypes.Requireable<string>;
19
- const onBlur: PropTypes.Requireable<(...args: any[]) => any>;
20
17
  const onClick: PropTypes.Requireable<(...args: any[]) => any>;
21
- const onFocus: PropTypes.Requireable<(...args: any[]) => any>;
22
18
  const onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
23
19
  const onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
24
20
  const placeholder: PropTypes.Requireable<string>;
@@ -1,38 +1,22 @@
1
- import React, { useContext } from "react";
1
+ import React from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import StyledSelectText from "./select-text.style";
4
- import { InputContext } from "../../../../__internal__/input-behaviour";
5
4
 
6
5
  const SelectText = ({
7
6
  disabled,
8
7
  formattedValue = "",
9
8
  onClick,
10
9
  onKeyDown,
11
- onFocus,
12
- onBlur,
13
10
  onMouseDown,
14
11
  placeholder,
15
12
  readOnly,
16
13
  textId,
17
14
  transparent
18
15
  }) => {
19
- const inputContext = useContext(InputContext);
20
16
  const hasPlaceholder = !disabled && !readOnly && !formattedValue;
21
17
 
22
- function handleFocus(event) {
23
- inputContext.onFocus(event);
24
-
25
- if (onFocus) {
26
- onFocus(event);
27
- }
28
- }
29
-
30
- function handleBlur(event) {
31
- inputContext.onBlur(event);
32
-
33
- if (onBlur) {
34
- onBlur(event);
35
- }
18
+ function handleClick(event) {
19
+ onClick(event);
36
20
  }
37
21
 
38
22
  return /*#__PURE__*/React.createElement(StyledSelectText, {
@@ -41,9 +25,7 @@ const SelectText = ({
41
25
  disabled: disabled,
42
26
  hasPlaceholder: hasPlaceholder,
43
27
  id: textId,
44
- onBlur: handleBlur,
45
- onClick: onClick,
46
- onFocus: handleFocus,
28
+ onClick: handleClick,
47
29
  onKeyDown: onKeyDown,
48
30
  onMouseDown: onMouseDown,
49
31
  readOnly: readOnly,
@@ -60,15 +42,9 @@ SelectText.propTypes = {
60
42
  /** Value to be displayed */
61
43
  formattedValue: PropTypes.string,
62
44
 
63
- /** Callback function for when the Select Textbox loses it's focus. */
64
- onBlur: PropTypes.func,
65
-
66
45
  /** Callback function for when the component is clicked. */
67
46
  onClick: PropTypes.func,
68
47
 
69
- /** Callback function for when the Select Textbox is focused. */
70
- onFocus: PropTypes.func,
71
-
72
48
  /** Callback function for when the key is pressed when focused on Select Text. */
73
49
  onKeyDown: PropTypes.func,
74
50
 
@@ -150,8 +150,11 @@ const SelectTextbox = ({
150
150
  textId: textId.current,
151
151
  transparent: transparent,
152
152
  onKeyDown: handleSelectTextKeydown,
153
- placeholder: placeholder || l.select.placeholder()
154
- }, getTextboxProps()));
153
+ placeholder: placeholder || l.select.placeholder(),
154
+ onClick: handleTextboxClick,
155
+ disabled: disabled,
156
+ readOnly: readOnly
157
+ }, restProps));
155
158
  }
156
159
 
157
160
  function handleSelectTextKeydown(event) {
@@ -37,7 +37,7 @@ const SplitButton = ({
37
37
  if (!deprecatedWarnTriggered && as) {
38
38
  deprecatedWarnTriggered = true;
39
39
  Logger.deprecate( // eslint-disable-next-line max-len
40
- "The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
40
+ "The `as` prop is deprecated and will soon be removed from the `SplitButton` component interface. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
41
41
  }
42
42
 
43
43
  const theme = useContext(ThemeContext) || baseTheme;
@@ -1,7 +1,8 @@
1
1
  export default Tile;
2
- declare function Tile({ as, p, children, orientation, width, ...props }: {
2
+ declare function Tile({ as, variant, p, children, orientation, width, ...props }: {
3
3
  [x: string]: any;
4
- as?: string | undefined;
4
+ as: any;
5
+ variant?: string | undefined;
5
6
  p?: number | undefined;
6
7
  children: any;
7
8
  orientation?: string | undefined;
@@ -4,15 +4,24 @@ import React from "react";
4
4
  import PropTypes from "prop-types";
5
5
  import propTypes from "@styled-system/prop-types";
6
6
  import { StyledTile, TileContent } from "./tile.style.js";
7
+ import Logger from "../../__internal__/utils/logger";
8
+ let deprecatedWarnTriggered = false;
7
9
 
8
10
  const Tile = ({
9
- as = "tile",
11
+ as,
12
+ variant = "tile",
10
13
  p = 3,
11
14
  children,
12
15
  orientation = "horizontal",
13
16
  width,
14
17
  ...props
15
18
  }) => {
19
+ if (!deprecatedWarnTriggered && as) {
20
+ deprecatedWarnTriggered = true;
21
+ Logger.deprecate( // eslint-disable-next-line max-len
22
+ "The `as` prop is deprecated and will soon be removed from the `Tile` component interface. You should use the `variant` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
23
+ }
24
+
16
25
  const isHorizontal = () => orientation === "horizontal";
17
26
 
18
27
  const isVertical = () => orientation === "vertical";
@@ -41,7 +50,7 @@ const Tile = ({
41
50
  }), /*#__PURE__*/React.cloneElement(child, childProps));
42
51
  });
43
52
  return /*#__PURE__*/React.createElement(StyledTile, _extends({
44
- tileTheme: as,
53
+ tileTheme: as || variant,
45
54
  width: width,
46
55
  "data-component": "tile",
47
56
  isHorizontal: isHorizontal(orientation),
@@ -56,6 +65,9 @@ Tile.propTypes = {
56
65
  /** Sets the theme of the tile - either 'tile' or 'transparent' */
57
66
  as: PropTypes.oneOf(["tile", "transparent"]),
58
67
 
68
+ /** Sets the theme of the tile - either 'tile' or 'transparent' */
69
+ variant: PropTypes.oneOf(["tile", "transparent"]),
70
+
59
71
  /**
60
72
  * The content to render within the tile. Each child will be wrapped with
61
73
  * a TileContent wrapper, which allows any individual child component to take a
@@ -4,6 +4,8 @@ import { SpaceProps } from "styled-system";
4
4
  export interface TileProps extends SpaceProps {
5
5
  /** Sets the theme of the tile - either 'tile' or 'transparent' */
6
6
  as?: "tile" | "transparent";
7
+ /** Sets the theme of the tile - either 'tile' or 'transparent' */
8
+ variant?: "tile" | "transparent";
7
9
  /**
8
10
  * The content to render within the tile. Each child will be wrapped with
9
11
  * a TileContent wrapper, which allows any individual child component to take a
@@ -1,7 +1,7 @@
1
1
  export default Toast;
2
2
  declare function Toast({ as, children, className, id, isCenter, maxWidth, onDismiss, open, targetPortalId, timeout, variant, ...restProps }: {
3
3
  [x: string]: any;
4
- as?: string | undefined;
4
+ as: any;
5
5
  children: any;
6
6
  className: any;
7
7
  id: any;
@@ -11,9 +11,11 @@ import IconButton from "../icon-button";
11
11
  import ModalManager from "../modal/__internal__/modal-manager";
12
12
  import Events from "../../__internal__/utils/helpers/events";
13
13
  import useLocale from "../../hooks/__internal__/useLocale";
14
+ import Logger from "../../__internal__/utils/logger";
15
+ let deprecatedWarnTriggered = false;
14
16
 
15
17
  const Toast = ({
16
- as = "success",
18
+ as,
17
19
  children,
18
20
  className,
19
21
  id,
@@ -26,6 +28,12 @@ const Toast = ({
26
28
  variant,
27
29
  ...restProps
28
30
  }) => {
31
+ if (!deprecatedWarnTriggered && as) {
32
+ deprecatedWarnTriggered = true;
33
+ Logger.deprecate( // eslint-disable-next-line max-len
34
+ "The `as` prop is deprecated and will soon be removed from the `Toast` component interface. You should use the `variant` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
35
+ }
36
+
29
37
  const locale = useLocale();
30
38
  const toastRef = useRef();
31
39
  const timer = useRef();
@@ -74,7 +82,7 @@ const Toast = ({
74
82
  if (!open) return null;
75
83
  const toastProps = {
76
84
  isCenter,
77
- variant: variant || as,
85
+ variant: variant || as || "success",
78
86
  id,
79
87
  maxWidth
80
88
  };
@@ -1,2 +1 @@
1
- export { default } from "./vertical-divider";
2
- export * from "./vertical-divider";
1
+ export { default } from "./vertical-divider.component";
@@ -1,10 +1,12 @@
1
- export default VerticalDivider;
2
- declare function VerticalDivider({ h, displayInline, tint, ...props }: {
3
- [x: string]: any;
4
- h: any;
5
- displayInline?: boolean | undefined;
6
- tint?: number | undefined;
7
- }): JSX.Element;
8
- declare namespace VerticalDivider {
9
- const propTypes: any;
1
+ /// <reference types="react" />
2
+ import { SpaceProps } from "styled-system";
3
+ declare type TintRange = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100;
4
+ export interface VerticalDividerPropTypes extends SpaceProps {
5
+ h?: number | string;
6
+ height?: number | string;
7
+ displayInline?: boolean;
8
+ /** the supported rage is 1-100 */
9
+ tint?: TintRange;
10
10
  }
11
+ declare const VerticalDivider: ({ h, height, displayInline, tint, ...props }: VerticalDividerPropTypes) => JSX.Element;
12
+ export default VerticalDivider;