carbon-react 105.1.0 → 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.
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +10 -3
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +2 -0
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.js +9 -0
- package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +0 -1
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +10 -3
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +2 -0
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.js +22 -0
- package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +0 -1
- package/package.json +5 -3
package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js
CHANGED
|
@@ -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
|
|
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(
|
|
25
|
-
|
|
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
|
|
|
@@ -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
|
}
|
package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js
CHANGED
|
@@ -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
|
|
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(
|
|
44
|
-
|
|
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
|
|
package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.js
ADDED
|
@@ -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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "105.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": "^
|
|
176
|
-
"react-dnd-html5-backend": "^
|
|
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",
|