carbon-react 105.0.1 → 105.1.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 (37) 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/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +10 -3
  5. package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +2 -0
  6. package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.js +9 -0
  7. package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +0 -1
  8. package/esm/components/modal/modal.component.js +2 -1
  9. package/esm/components/multi-action-button/multi-action-button.component.js +1 -1
  10. package/esm/components/select/__internal__/select-text/select-text.component.d.ts +1 -5
  11. package/esm/components/select/__internal__/select-text/select-text.component.js +4 -28
  12. package/esm/components/select/select-textbox/select-textbox.component.js +5 -2
  13. package/esm/components/split-button/split-button.component.js +1 -1
  14. package/esm/components/tile/tile.component.d.ts +3 -2
  15. package/esm/components/tile/tile.component.js +14 -2
  16. package/esm/components/tile/tile.d.ts +2 -0
  17. package/esm/components/toast/toast.component.d.ts +1 -1
  18. package/esm/components/toast/toast.component.js +10 -2
  19. package/lib/__internal__/popover/popover.component.d.ts +1 -1
  20. package/lib/__internal__/popover/popover.component.js +15 -4
  21. package/lib/components/button/button.component.js +1 -1
  22. package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +10 -3
  23. package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +2 -0
  24. package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.js +22 -0
  25. package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +0 -1
  26. package/lib/components/modal/modal.component.js +2 -1
  27. package/lib/components/multi-action-button/multi-action-button.component.js +1 -1
  28. package/lib/components/select/__internal__/select-text/select-text.component.d.ts +1 -5
  29. package/lib/components/select/__internal__/select-text/select-text.component.js +4 -33
  30. package/lib/components/select/select-textbox/select-textbox.component.js +5 -2
  31. package/lib/components/split-button/split-button.component.js +1 -1
  32. package/lib/components/tile/tile.component.d.ts +3 -2
  33. package/lib/components/tile/tile.component.js +17 -2
  34. package/lib/components/tile/tile.d.ts +2 -0
  35. package/lib/components/toast/toast.component.d.ts +1 -1
  36. package/lib/components/toast/toast.component.js +13 -2
  37. package/package.json +5 -3
@@ -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);
@@ -5,7 +5,7 @@ import { useDrop, DndProvider } from "react-dnd";
5
5
  import { HTML5Backend } from "react-dnd-html5-backend";
6
6
  import PropTypes from "prop-types";
7
7
  import StyledIcon from "../../icon/icon.style";
8
- import FlatTableBody from "../flat-table-body/flat-table-body.component";
8
+ import StyledFlatTableBodyDraggable from "./flat-table-body-draggable.style";
9
9
  import FlatTableCell from "../flat-table-cell/flat-table-cell.component";
10
10
 
11
11
  const DropTarget = ({
@@ -13,16 +13,23 @@ const DropTarget = ({
13
13
  getOrder,
14
14
  ...rest
15
15
  }) => {
16
+ const [isDragging, setIsDragging] = useState(false);
16
17
  const [, drop] = useDrop({
17
18
  accept: "flatTableRow",
19
+ hover: (_, monitor) => {
20
+ if (!isDragging && monitor.isOver()) setIsDragging(true);
21
+ },
18
22
 
19
23
  drop() {
24
+ setIsDragging(false);
20
25
  getOrder();
21
26
  }
22
27
 
23
28
  });
24
- return /*#__PURE__*/React.createElement(FlatTableBody, _extends({
25
- ref: drop
29
+ return /*#__PURE__*/React.createElement(StyledFlatTableBodyDraggable, _extends({
30
+ "data-testid": "flat-table-body-draggable",
31
+ ref: drop,
32
+ isDragging: isDragging
26
33
  }, rest), children);
27
34
  };
28
35
 
@@ -0,0 +1,2 @@
1
+ export default StyledFlatTableBodyDraggable;
2
+ declare const StyledFlatTableBodyDraggable: import("styled-components").StyledComponent<"tbody", any, {}, never>;
@@ -0,0 +1,9 @@
1
+ import styled, { css } from "styled-components";
2
+ const StyledFlatTableBodyDraggable = styled.tbody`
3
+ ${({
4
+ isDragging
5
+ }) => isDragging && css`
6
+ cursor: grabbing;
7
+ `}
8
+ `;
9
+ export default StyledFlatTableBodyDraggable;
@@ -248,7 +248,6 @@ const StyledFlatTableRow = styled.tr`
248
248
  ${isDragging && css`
249
249
  border: ${isInSidebar ? "var(--colorsUtilityMajor300)" : "var(--colorsUtilityMajor200)"}
250
250
  2px solid;
251
- cursor: grabbing;
252
251
  ${allCellTypes} {
253
252
  background-color: ${isInSidebar ? "var(--colorsUtilityMajor200)" : "var(--colorsUtilityMajor150)"};
254
253
  }
@@ -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
  };
@@ -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
  }
@@ -19,6 +19,8 @@ var _popover = _interopRequireDefault(require("./popover.style"));
19
19
 
20
20
  var _carbonScopedTokensProvider = _interopRequireDefault(require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component"));
21
21
 
22
+ var _modal = require("../../components/modal/modal.component");
23
+
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
25
 
24
26
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -35,10 +37,18 @@ const Popover = ({
35
37
  disableBackgroundUI
36
38
  }) => {
37
39
  const elementDOM = (0, _react.useRef)();
40
+ const {
41
+ isInModal
42
+ } = (0, _react.useContext)(_modal.ModalContext);
43
+ let mountNode = document.body;
44
+
45
+ if (isInModal && reference.current) {
46
+ mountNode = reference.current.closest("[role='dialog']");
47
+ }
38
48
 
39
49
  if (!elementDOM.current && !disablePortal) {
40
50
  elementDOM.current = document.createElement("div");
41
- document.body.appendChild(elementDOM.current);
51
+ mountNode.appendChild(elementDOM.current);
42
52
  }
43
53
 
44
54
  const popperInstance = (0, _react.useRef)();
@@ -88,10 +98,11 @@ const Popover = ({
88
98
  (0, _react.useEffect)(() => {
89
99
  return () => {
90
100
  if (!disablePortal) {
91
- document.body.removeChild(elementDOM.current);
101
+ mountNode.removeChild(elementDOM.current);
102
+ elementDOM.current = null;
92
103
  }
93
104
  };
94
- }, [disablePortal]);
105
+ }, [disablePortal, mountNode]);
95
106
 
96
107
  if (disableBackgroundUI) {
97
108
  content = /*#__PURE__*/_react.default.createElement(_popover.default, null, content);
@@ -122,7 +133,7 @@ Popover.propTypes = {
122
133
  // Reference element, children will be positioned in relation to this element - should be a ref
123
134
  reference: _propTypes.default.shape({
124
135
  current: _propTypes.default.any
125
- })
136
+ }).isRequired
126
137
  };
127
138
  var _default = Popover;
128
139
  exports.default = _default;
@@ -99,7 +99,7 @@ const Button = ({
99
99
  deprecatedWarnTriggered = true;
100
100
 
101
101
  _logger.default.deprecate( // eslint-disable-next-line max-len
102
- "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");
102
+ "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");
103
103
  }
104
104
 
105
105
  const [internalRef, setInternalRef] = (0, _react.useState)(null);
@@ -15,7 +15,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
15
15
 
16
16
  var _icon = _interopRequireDefault(require("../../icon/icon.style"));
17
17
 
18
- var _flatTableBody = _interopRequireDefault(require("../flat-table-body/flat-table-body.component"));
18
+ var _flatTableBodyDraggable = _interopRequireDefault(require("./flat-table-body-draggable.style"));
19
19
 
20
20
  var _flatTableCell = _interopRequireDefault(require("../flat-table-cell/flat-table-cell.component"));
21
21
 
@@ -32,16 +32,23 @@ const DropTarget = ({
32
32
  getOrder,
33
33
  ...rest
34
34
  }) => {
35
+ const [isDragging, setIsDragging] = (0, _react.useState)(false);
35
36
  const [, drop] = (0, _reactDnd.useDrop)({
36
37
  accept: "flatTableRow",
38
+ hover: (_, monitor) => {
39
+ if (!isDragging && monitor.isOver()) setIsDragging(true);
40
+ },
37
41
 
38
42
  drop() {
43
+ setIsDragging(false);
39
44
  getOrder();
40
45
  }
41
46
 
42
47
  });
43
- return /*#__PURE__*/_react.default.createElement(_flatTableBody.default, _extends({
44
- ref: drop
48
+ return /*#__PURE__*/_react.default.createElement(_flatTableBodyDraggable.default, _extends({
49
+ "data-testid": "flat-table-body-draggable",
50
+ ref: drop,
51
+ isDragging: isDragging
45
52
  }, rest), children);
46
53
  };
47
54
 
@@ -0,0 +1,2 @@
1
+ export default StyledFlatTableBodyDraggable;
2
+ declare const StyledFlatTableBodyDraggable: import("styled-components").StyledComponent<"tbody", any, {}, never>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
+
10
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11
+
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+
14
+ const StyledFlatTableBodyDraggable = _styledComponents.default.tbody`
15
+ ${({
16
+ isDragging
17
+ }) => isDragging && (0, _styledComponents.css)`
18
+ cursor: grabbing;
19
+ `}
20
+ `;
21
+ var _default = StyledFlatTableBodyDraggable;
22
+ exports.default = _default;
@@ -269,7 +269,6 @@ const StyledFlatTableRow = _styledComponents.default.tr`
269
269
  ${isDragging && (0, _styledComponents.css)`
270
270
  border: ${isInSidebar ? "var(--colorsUtilityMajor300)" : "var(--colorsUtilityMajor200)"}
271
271
  2px solid;
272
- cursor: grabbing;
273
272
  ${allCellTypes} {
274
273
  background-color: ${isInSidebar ? "var(--colorsUtilityMajor200)" : "var(--colorsUtilityMajor150)"};
275
274
  }
@@ -165,7 +165,8 @@ const Modal = ({
165
165
  }, /*#__PURE__*/_react.default.createElement(ModalContext.Provider, {
166
166
  value: {
167
167
  isAnimationComplete,
168
- triggerRefocusFlag
168
+ triggerRefocusFlag,
169
+ isInModal: true
169
170
  }
170
171
  }, content)))));
171
172
  };
@@ -51,7 +51,7 @@ const MultiActionButton = ({
51
51
  deprecatedWarnTriggered = true;
52
52
 
53
53
  _logger.default.deprecate( // eslint-disable-next-line max-len
54
- "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");
54
+ "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");
55
55
  }
56
56
 
57
57
  const ref = (0, _react.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>;
@@ -5,50 +5,29 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _react = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _selectText = _interopRequireDefault(require("./select-text.style"));
13
13
 
14
- var _inputBehaviour = require("../../../../__internal__/input-behaviour");
15
-
16
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
15
 
18
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
19
-
20
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
22
16
  const SelectText = ({
23
17
  disabled,
24
18
  formattedValue = "",
25
19
  onClick,
26
20
  onKeyDown,
27
- onFocus,
28
- onBlur,
29
21
  onMouseDown,
30
22
  placeholder,
31
23
  readOnly,
32
24
  textId,
33
25
  transparent
34
26
  }) => {
35
- const inputContext = (0, _react.useContext)(_inputBehaviour.InputContext);
36
27
  const hasPlaceholder = !disabled && !readOnly && !formattedValue;
37
28
 
38
- function handleFocus(event) {
39
- inputContext.onFocus(event);
40
-
41
- if (onFocus) {
42
- onFocus(event);
43
- }
44
- }
45
-
46
- function handleBlur(event) {
47
- inputContext.onBlur(event);
48
-
49
- if (onBlur) {
50
- onBlur(event);
51
- }
29
+ function handleClick(event) {
30
+ onClick(event);
52
31
  }
53
32
 
54
33
  return /*#__PURE__*/_react.default.createElement(_selectText.default, {
@@ -57,9 +36,7 @@ const SelectText = ({
57
36
  disabled: disabled,
58
37
  hasPlaceholder: hasPlaceholder,
59
38
  id: textId,
60
- onBlur: handleBlur,
61
- onClick: onClick,
62
- onFocus: handleFocus,
39
+ onClick: handleClick,
63
40
  onKeyDown: onKeyDown,
64
41
  onMouseDown: onMouseDown,
65
42
  readOnly: readOnly,
@@ -76,15 +53,9 @@ SelectText.propTypes = {
76
53
  /** Value to be displayed */
77
54
  formattedValue: _propTypes.default.string,
78
55
 
79
- /** Callback function for when the Select Textbox loses it's focus. */
80
- onBlur: _propTypes.default.func,
81
-
82
56
  /** Callback function for when the component is clicked. */
83
57
  onClick: _propTypes.default.func,
84
58
 
85
- /** Callback function for when the Select Textbox is focused. */
86
- onFocus: _propTypes.default.func,
87
-
88
59
  /** Callback function for when the key is pressed when focused on Select Text. */
89
60
  onKeyDown: _propTypes.default.func,
90
61
 
@@ -171,8 +171,11 @@ const SelectTextbox = ({
171
171
  textId: textId.current,
172
172
  transparent: transparent,
173
173
  onKeyDown: handleSelectTextKeydown,
174
- placeholder: placeholder || l.select.placeholder()
175
- }, getTextboxProps()));
174
+ placeholder: placeholder || l.select.placeholder(),
175
+ onClick: handleTextboxClick,
176
+ disabled: disabled,
177
+ readOnly: readOnly
178
+ }, restProps));
176
179
  }
177
180
 
178
181
  function handleSelectTextKeydown(event) {
@@ -67,7 +67,7 @@ const SplitButton = ({
67
67
  deprecatedWarnTriggered = true;
68
68
 
69
69
  _logger.default.deprecate( // eslint-disable-next-line max-len
70
- "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");
70
+ "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");
71
71
  }
72
72
 
73
73
  const theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _themes.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;
@@ -13,18 +13,30 @@ var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
13
13
 
14
14
  var _tileStyle = require("./tile.style.js");
15
15
 
16
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
17
+
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
19
 
18
20
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
21
 
22
+ let deprecatedWarnTriggered = false;
23
+
20
24
  const Tile = ({
21
- as = "tile",
25
+ as,
26
+ variant = "tile",
22
27
  p = 3,
23
28
  children,
24
29
  orientation = "horizontal",
25
30
  width,
26
31
  ...props
27
32
  }) => {
33
+ if (!deprecatedWarnTriggered && as) {
34
+ deprecatedWarnTriggered = true;
35
+
36
+ _logger.default.deprecate( // eslint-disable-next-line max-len
37
+ "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");
38
+ }
39
+
28
40
  const isHorizontal = () => orientation === "horizontal";
29
41
 
30
42
  const isVertical = () => orientation === "vertical";
@@ -54,7 +66,7 @@ const Tile = ({
54
66
  });
55
67
 
56
68
  return /*#__PURE__*/_react.default.createElement(_tileStyle.StyledTile, _extends({
57
- tileTheme: as,
69
+ tileTheme: as || variant,
58
70
  width: width,
59
71
  "data-component": "tile",
60
72
  isHorizontal: isHorizontal(orientation),
@@ -69,6 +81,9 @@ Tile.propTypes = {
69
81
  /** Sets the theme of the tile - either 'tile' or 'transparent' */
70
82
  as: _propTypes.default.oneOf(["tile", "transparent"]),
71
83
 
84
+ /** Sets the theme of the tile - either 'tile' or 'transparent' */
85
+ variant: _propTypes.default.oneOf(["tile", "transparent"]),
86
+
72
87
  /**
73
88
  * The content to render within the tile. Each child will be wrapped with
74
89
  * 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;
@@ -27,6 +27,8 @@ var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/e
27
27
 
28
28
  var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
29
29
 
30
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
31
+
30
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
33
 
32
34
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -35,8 +37,10 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
35
37
 
36
38
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
37
39
 
40
+ let deprecatedWarnTriggered = false;
41
+
38
42
  const Toast = ({
39
- as = "success",
43
+ as,
40
44
  children,
41
45
  className,
42
46
  id,
@@ -49,6 +53,13 @@ const Toast = ({
49
53
  variant,
50
54
  ...restProps
51
55
  }) => {
56
+ if (!deprecatedWarnTriggered && as) {
57
+ deprecatedWarnTriggered = true;
58
+
59
+ _logger.default.deprecate( // eslint-disable-next-line max-len
60
+ "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");
61
+ }
62
+
52
63
  const locale = (0, _useLocale.default)();
53
64
  const toastRef = (0, _react.useRef)();
54
65
  const timer = (0, _react.useRef)();
@@ -100,7 +111,7 @@ const Toast = ({
100
111
  if (!open) return null;
101
112
  const toastProps = {
102
113
  isCenter,
103
- variant: variant || as,
114
+ variant: variant || as || "success",
104
115
  id,
105
116
  maxWidth
106
117
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "105.0.1",
3
+ "version": "105.1.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {
@@ -84,6 +84,8 @@
84
84
  "@storybook/components": "^6.4.18",
85
85
  "@storybook/react": "^6.4.18",
86
86
  "@storybook/theming": "^6.4.18",
87
+ "@testing-library/jest-dom": "^5.16.2",
88
+ "@testing-library/react": "^12.1.3",
87
89
  "@types/enzyme": "^3.10.3",
88
90
  "@types/enzyme-adapter-react-16": "^1.0.5",
89
91
  "@types/jest": "^26.0.19",
@@ -172,8 +174,8 @@
172
174
  "polished": "^4.0.5",
173
175
  "prop-types": "^15.7.2",
174
176
  "react-day-picker": "~7.4.10",
175
- "react-dnd": "^14.0.5",
176
- "react-dnd-html5-backend": "^14.1.0",
177
+ "react-dnd": "^15.1.1",
178
+ "react-dnd-html5-backend": "^15.1.2",
177
179
  "react-is": "^17.0.2",
178
180
  "react-transition-group": "^4.4.1",
179
181
  "styled-system": "^5.1.5",