cozy-ui 123.2.1 → 124.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.
- package/CHANGELOG.md +36 -0
- package/assets/icons/ui/cloud2.svg +1 -0
- package/assets/icons/ui/discuss.svg +1 -0
- package/assets/icons/ui/email-open.svg +1 -0
- package/assets/icons/ui/key2.svg +1 -0
- package/assets/icons/ui/peoples.svg +1 -0
- package/assets/icons/ui/security.svg +1 -0
- package/package.json +11 -6
- package/react/Filename/Readme.md +10 -8
- package/react/Filename/index.jsx +56 -10
- package/react/Filename/styles.styl +3 -0
- package/react/Icon/Readme.md +13 -1
- package/react/Icons/Cloud2.jsx +29 -0
- package/react/Icons/Discuss.jsx +16 -0
- package/react/Icons/EmailOpen.jsx +55 -0
- package/react/Icons/Key2.jsx +23 -0
- package/react/Icons/Peoples.jsx +12 -0
- package/react/Icons/Security.jsx +12 -0
- package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +60 -0
- package/react/Table/Readme.md +80 -0
- package/react/Table/Virtualized/Cell.jsx +41 -0
- package/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer.jsx +45 -0
- package/react/Table/Virtualized/Dnd/CustomDrag/DragPreview.jsx +43 -0
- package/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper.jsx +52 -0
- package/react/Table/Virtualized/Dnd/DnDConfigWrapper.jsx +48 -0
- package/react/Table/Virtualized/Dnd/TableRow.jsx +86 -0
- package/react/Table/Virtualized/FixedHeaderContent.jsx +58 -0
- package/react/Table/Virtualized/HeadCell.jsx +45 -0
- package/react/Table/Virtualized/RowContent.jsx +35 -0
- package/react/Table/Virtualized/helpers.js +41 -0
- package/react/Table/Virtualized/helpers.spec.js +108 -0
- package/react/Table/Virtualized/index.jsx +104 -0
- package/react/Table/Virtualized/virtuosoComponents.jsx +61 -0
- package/react/TableRow/index.js +16 -1
- package/transpiled/react/Filename/index.d.ts +2 -1
- package/transpiled/react/Filename/index.js +49 -16
- package/transpiled/react/Icon/icons-sprite.d.ts +1 -1
- package/transpiled/react/Icon/icons-sprite.js +1 -1
- package/transpiled/react/Icons/Cloud2.d.ts +2 -0
- package/transpiled/react/Icons/Cloud2.js +26 -0
- package/transpiled/react/Icons/Discuss.d.ts +2 -0
- package/transpiled/react/Icons/Discuss.js +15 -0
- package/transpiled/react/Icons/EmailOpen.d.ts +2 -0
- package/transpiled/react/Icons/EmailOpen.js +53 -0
- package/transpiled/react/Icons/Key2.d.ts +2 -0
- package/transpiled/react/Icons/Key2.js +21 -0
- package/transpiled/react/Icons/Peoples.d.ts +2 -0
- package/transpiled/react/Icons/Peoples.js +13 -0
- package/transpiled/react/Icons/Security.d.ts +2 -0
- package/transpiled/react/Icons/Security.js +13 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +56 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +56 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +56 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +56 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +59 -0
- package/transpiled/react/Table/Virtualized/Cell.d.ts +8 -0
- package/transpiled/react/Table/Virtualized/Cell.js +46 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer.d.ts +4 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer.js +47 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreview.d.ts +6 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreview.js +34 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper.d.ts +8 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper.js +63 -0
- package/transpiled/react/Table/Virtualized/Dnd/DnDConfigWrapper.d.ts +2 -0
- package/transpiled/react/Table/Virtualized/Dnd/DnDConfigWrapper.js +55 -0
- package/transpiled/react/Table/Virtualized/Dnd/TableRow.d.ts +8 -0
- package/transpiled/react/Table/Virtualized/Dnd/TableRow.js +130 -0
- package/transpiled/react/Table/Virtualized/FixedHeaderContent.d.ts +10 -0
- package/transpiled/react/Table/Virtualized/FixedHeaderContent.js +54 -0
- package/transpiled/react/Table/Virtualized/HeadCell.d.ts +8 -0
- package/transpiled/react/Table/Virtualized/HeadCell.js +44 -0
- package/transpiled/react/Table/Virtualized/RowContent.d.ts +10 -0
- package/transpiled/react/Table/Virtualized/RowContent.js +34 -0
- package/transpiled/react/Table/Virtualized/helpers.d.ts +2 -0
- package/transpiled/react/Table/Virtualized/helpers.js +64 -0
- package/transpiled/react/Table/Virtualized/helpers.spec.d.ts +1 -0
- package/transpiled/react/Table/Virtualized/index.d.ts +2 -0
- package/transpiled/react/Table/Virtualized/index.js +115 -0
- package/transpiled/react/Table/Virtualized/virtuosoComponents.d.ts +10 -0
- package/transpiled/react/Table/Virtualized/virtuosoComponents.js +100 -0
- package/transpiled/react/TableRow/index.d.ts +2 -1
- package/transpiled/react/TableRow/index.js +20 -1
- package/transpiled/react/stylesheet.css +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import DragPreview from "cozy-ui/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreview";
|
|
4
|
+
|
|
5
|
+
var makeStyles = function makeStyles(_ref) {
|
|
6
|
+
var x = _ref.x,
|
|
7
|
+
y = _ref.y;
|
|
8
|
+
|
|
9
|
+
if (!x || !y) {
|
|
10
|
+
return {
|
|
11
|
+
display: 'none'
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
var transform = "translate(".concat(x, "px, ").concat(y, "px)");
|
|
16
|
+
return {
|
|
17
|
+
transform: transform,
|
|
18
|
+
WebkitTransform: transform
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var DragPreviewWrapper = function DragPreviewWrapper(_ref2) {
|
|
23
|
+
var item = _ref2.item,
|
|
24
|
+
itemType = _ref2.itemType,
|
|
25
|
+
dragId = _ref2.dragId,
|
|
26
|
+
initialOffset = _ref2.initialOffset,
|
|
27
|
+
currentOffset = _ref2.currentOffset;
|
|
28
|
+
|
|
29
|
+
var _useState = useState({
|
|
30
|
+
x: null,
|
|
31
|
+
y: null
|
|
32
|
+
}),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
mousePosition = _useState2[0],
|
|
35
|
+
setMousePosition = _useState2[1];
|
|
36
|
+
|
|
37
|
+
useEffect(function () {
|
|
38
|
+
var handleMouseMove = function handleMouseMove(e) {
|
|
39
|
+
setMousePosition({
|
|
40
|
+
x: e.clientX,
|
|
41
|
+
y: e.clientY
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
window.addEventListener('dragover', handleMouseMove);
|
|
46
|
+
return function () {
|
|
47
|
+
window.removeEventListener('dragover', handleMouseMove);
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
if (!initialOffset || !currentOffset || itemType !== dragId) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
style: makeStyles(mousePosition)
|
|
57
|
+
}, /*#__PURE__*/React.createElement(DragPreview, {
|
|
58
|
+
fileName: item.draggedItems[0].name,
|
|
59
|
+
selectedCount: item.draggedItems.length
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default DragPreviewWrapper;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { forwardRef, useEffect, useState } from 'react';
|
|
3
|
+
import { useDragDropManager } from 'react-dnd';
|
|
4
|
+
var DnDConfigWrapper = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
5
|
+
var children = _ref.children;
|
|
6
|
+
var dragDropManager = useDragDropManager();
|
|
7
|
+
var monitor = dragDropManager.getMonitor();
|
|
8
|
+
|
|
9
|
+
var _useState = useState(false),
|
|
10
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
11
|
+
isDragging = _useState2[0],
|
|
12
|
+
setIsDragging = _useState2[1];
|
|
13
|
+
|
|
14
|
+
useEffect(function () {
|
|
15
|
+
var unsubscribe = monitor.subscribeToStateChange(function () {
|
|
16
|
+
setIsDragging(monitor.isDragging());
|
|
17
|
+
});
|
|
18
|
+
return function () {
|
|
19
|
+
return unsubscribe();
|
|
20
|
+
};
|
|
21
|
+
}, [monitor]);
|
|
22
|
+
useEffect(function () {
|
|
23
|
+
if (!isDragging) return;
|
|
24
|
+
var scrollThreshold = 100;
|
|
25
|
+
var scrollMaxSpeed = 75;
|
|
26
|
+
var intervalId = setInterval(function () {
|
|
27
|
+
var offset = monitor.getClientOffset();
|
|
28
|
+
var container = ref.current;
|
|
29
|
+
if (!offset || !container) return;
|
|
30
|
+
|
|
31
|
+
var _container$getBoundin = container.getBoundingClientRect(),
|
|
32
|
+
top = _container$getBoundin.top,
|
|
33
|
+
bottom = _container$getBoundin.bottom;
|
|
34
|
+
|
|
35
|
+
var distanceToTop = offset.y - top;
|
|
36
|
+
var distanceToBottom = bottom - offset.y;
|
|
37
|
+
|
|
38
|
+
if (distanceToTop < scrollThreshold) {
|
|
39
|
+
var speed = scrollMaxSpeed * (1 - distanceToTop / scrollThreshold);
|
|
40
|
+
container.scrollBy(0, -speed);
|
|
41
|
+
} else if (distanceToBottom < scrollThreshold) {
|
|
42
|
+
var _speed = scrollMaxSpeed * (1 - distanceToBottom / scrollThreshold);
|
|
43
|
+
|
|
44
|
+
container.scrollBy(0, _speed);
|
|
45
|
+
}
|
|
46
|
+
}, 16); // ~60fps
|
|
47
|
+
|
|
48
|
+
return function () {
|
|
49
|
+
return clearInterval(intervalId);
|
|
50
|
+
};
|
|
51
|
+
}, [isDragging, monitor, ref]);
|
|
52
|
+
return children;
|
|
53
|
+
});
|
|
54
|
+
DnDConfigWrapper.displayName = 'DnDConfigWrapper';
|
|
55
|
+
export default DnDConfigWrapper;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["item", "context", "selected", "disabled"];
|
|
6
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
+
import React, { useEffect } from 'react';
|
|
8
|
+
import { useDrag, useDrop } from 'react-dnd';
|
|
9
|
+
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
10
|
+
import TableRowClassic from "cozy-ui/transpiled/react/TableRow";
|
|
11
|
+
|
|
12
|
+
var TableRow = function TableRow(_ref) {
|
|
13
|
+
var item = _ref.item,
|
|
14
|
+
context = _ref.context,
|
|
15
|
+
selected = _ref.selected,
|
|
16
|
+
disabled = _ref.disabled,
|
|
17
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
18
|
+
|
|
19
|
+
var selectedItems = context.selectedItems,
|
|
20
|
+
setItemsInDropProcess = context.setItemsInDropProcess,
|
|
21
|
+
dragProps = context.dragProps;
|
|
22
|
+
var onDrop = dragProps.onDrop,
|
|
23
|
+
canDropProps = dragProps.canDrop,
|
|
24
|
+
canDragProps = dragProps.canDrag,
|
|
25
|
+
dragId = dragProps.dragId;
|
|
26
|
+
|
|
27
|
+
var _useDrag = useDrag(function () {
|
|
28
|
+
return {
|
|
29
|
+
type: dragId,
|
|
30
|
+
isDragging: function isDragging(monitor) {
|
|
31
|
+
// put all selected items in isDragging state
|
|
32
|
+
if (selectedItems.length > 0) {
|
|
33
|
+
return selectedItems.some(function (selectedItem) {
|
|
34
|
+
return selectedItem._id === item._id;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return item._id === monitor.getItem().draggedItems[0]._id;
|
|
39
|
+
},
|
|
40
|
+
item: {
|
|
41
|
+
draggedItems: selectedItems.length > 0 ? selectedItems : [item]
|
|
42
|
+
},
|
|
43
|
+
canDrag: function canDrag() {
|
|
44
|
+
var defaultCanDrag = (canDragProps === null || canDragProps === void 0 ? void 0 : canDragProps(item)) || true; // if selectedItems is not empty, only the selected items can be dragged
|
|
45
|
+
|
|
46
|
+
// if selectedItems is not empty, only the selected items can be dragged
|
|
47
|
+
if (selectedItems.length > 0) {
|
|
48
|
+
return defaultCanDrag && selected;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return defaultCanDrag;
|
|
52
|
+
},
|
|
53
|
+
collect: function collect(monitor) {
|
|
54
|
+
return {
|
|
55
|
+
isDragging: monitor.isDragging()
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}, [item, selectedItems] // used to pass args inside returned object attributes
|
|
60
|
+
),
|
|
61
|
+
_useDrag2 = _slicedToArray(_useDrag, 3),
|
|
62
|
+
dragCollect = _useDrag2[0],
|
|
63
|
+
dragRef = _useDrag2[1],
|
|
64
|
+
dragRefPreview = _useDrag2[2];
|
|
65
|
+
|
|
66
|
+
var _useDrop = useDrop(function () {
|
|
67
|
+
return {
|
|
68
|
+
accept: dragId,
|
|
69
|
+
canDrop: function canDrop() {
|
|
70
|
+
return canDropProps ? canDropProps(item) : true;
|
|
71
|
+
},
|
|
72
|
+
drop: function () {
|
|
73
|
+
var _drop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(draggedItem) {
|
|
74
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
75
|
+
while (1) {
|
|
76
|
+
switch (_context.prev = _context.next) {
|
|
77
|
+
case 0:
|
|
78
|
+
setItemsInDropProcess(draggedItem.draggedItems.map(function (draggedItem) {
|
|
79
|
+
return draggedItem._id;
|
|
80
|
+
}));
|
|
81
|
+
_context.next = 3;
|
|
82
|
+
return onDrop(draggedItem.draggedItems, item, selectedItems);
|
|
83
|
+
|
|
84
|
+
case 3:
|
|
85
|
+
setItemsInDropProcess([]);
|
|
86
|
+
|
|
87
|
+
case 4:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context.stop();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, _callee);
|
|
93
|
+
}));
|
|
94
|
+
|
|
95
|
+
function drop(_x) {
|
|
96
|
+
return _drop.apply(this, arguments);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return drop;
|
|
100
|
+
}(),
|
|
101
|
+
collect: function collect(monitor) {
|
|
102
|
+
return {
|
|
103
|
+
isOver: monitor.isOver()
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}, [item._id, selectedItems] // used to pass args inside returned object attributes
|
|
108
|
+
),
|
|
109
|
+
_useDrop2 = _slicedToArray(_useDrop, 2),
|
|
110
|
+
dropCollect = _useDrop2[0],
|
|
111
|
+
dropRef = _useDrop2[1]; // Tricks for the preview image to be empty
|
|
112
|
+
// https://react-dnd.github.io/react-dnd/examples/drag-around/custom-drag-layer
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
useEffect(function () {
|
|
116
|
+
dragRefPreview(getEmptyImage(), {
|
|
117
|
+
captureDraggingState: true
|
|
118
|
+
});
|
|
119
|
+
}, [dragRefPreview]);
|
|
120
|
+
return /*#__PURE__*/React.createElement(TableRowClassic, _extends({}, props, {
|
|
121
|
+
ref: function ref(node) {
|
|
122
|
+
return dragRef(dropRef(node));
|
|
123
|
+
},
|
|
124
|
+
selected: selected || dropCollect.isOver,
|
|
125
|
+
className: dragCollect.isDragging ? 'u-o-50' : '',
|
|
126
|
+
disabled: disabled
|
|
127
|
+
}));
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export default TableRow;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default FixedHeaderContent;
|
|
2
|
+
declare function FixedHeaderContent({ columns, order, orderBy, rowCount, selectedCount, onClick, onSelectAllClick }: {
|
|
3
|
+
columns: any;
|
|
4
|
+
order: any;
|
|
5
|
+
orderBy: any;
|
|
6
|
+
rowCount: any;
|
|
7
|
+
selectedCount: any;
|
|
8
|
+
onClick: any;
|
|
9
|
+
onSelectAllClick: any;
|
|
10
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import TableHeadCell from "cozy-ui/transpiled/react/Table/Virtualized/HeadCell";
|
|
3
|
+
import Checkbox from "cozy-ui/transpiled/react/Checkbox";
|
|
4
|
+
import TableCell from "cozy-ui/transpiled/react/TableCell";
|
|
5
|
+
import TableRow from "cozy-ui/transpiled/react/TableRow";
|
|
6
|
+
import { makeStyles } from "cozy-ui/transpiled/react/styles";
|
|
7
|
+
var useStyles = makeStyles({
|
|
8
|
+
visuallyHidden: {
|
|
9
|
+
border: 0,
|
|
10
|
+
clip: 'rect(0 0 0 0)',
|
|
11
|
+
height: 1,
|
|
12
|
+
margin: -1,
|
|
13
|
+
overflow: 'hidden',
|
|
14
|
+
padding: 0,
|
|
15
|
+
position: 'absolute',
|
|
16
|
+
top: 20,
|
|
17
|
+
width: 1
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
var FixedHeaderContent = function FixedHeaderContent(_ref) {
|
|
22
|
+
var columns = _ref.columns,
|
|
23
|
+
order = _ref.order,
|
|
24
|
+
orderBy = _ref.orderBy,
|
|
25
|
+
rowCount = _ref.rowCount,
|
|
26
|
+
selectedCount = _ref.selectedCount,
|
|
27
|
+
_onClick = _ref.onClick,
|
|
28
|
+
onSelectAllClick = _ref.onSelectAllClick;
|
|
29
|
+
var classes = useStyles();
|
|
30
|
+
return /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
|
|
31
|
+
align: "center",
|
|
32
|
+
padding: "checkbox"
|
|
33
|
+
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
34
|
+
indeterminate: selectedCount > 0 && selectedCount < rowCount,
|
|
35
|
+
checked: rowCount > 0 && selectedCount === rowCount,
|
|
36
|
+
inputProps: {
|
|
37
|
+
'aria-label': 'select all'
|
|
38
|
+
},
|
|
39
|
+
onChange: onSelectAllClick
|
|
40
|
+
})), columns.map(function (column) {
|
|
41
|
+
return /*#__PURE__*/React.createElement(TableHeadCell, {
|
|
42
|
+
key: column.id,
|
|
43
|
+
className: classes.visuallyHidden,
|
|
44
|
+
column: column,
|
|
45
|
+
order: order,
|
|
46
|
+
orderBy: orderBy,
|
|
47
|
+
onClick: function onClick() {
|
|
48
|
+
return _onClick(column.id);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default FixedHeaderContent;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import TableCell from "cozy-ui/transpiled/react/TableCell";
|
|
3
|
+
import TableSortLabel from "cozy-ui/transpiled/react/TableSortLabel";
|
|
4
|
+
import { makeStyles } from "cozy-ui/transpiled/react/styles";
|
|
5
|
+
var useStyles = makeStyles({
|
|
6
|
+
root: {
|
|
7
|
+
width: function width(_ref) {
|
|
8
|
+
var column = _ref.column;
|
|
9
|
+
return column.width;
|
|
10
|
+
},
|
|
11
|
+
maxWidth: function maxWidth(_ref2) {
|
|
12
|
+
var column = _ref2.column;
|
|
13
|
+
return column.maxWidth;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
var TableHeadCell = function TableHeadCell(_ref3) {
|
|
19
|
+
var _column$textAlign;
|
|
20
|
+
|
|
21
|
+
var className = _ref3.className,
|
|
22
|
+
column = _ref3.column,
|
|
23
|
+
orderBy = _ref3.orderBy,
|
|
24
|
+
order = _ref3.order,
|
|
25
|
+
onClick = _ref3.onClick;
|
|
26
|
+
var classes = useStyles({
|
|
27
|
+
column: column
|
|
28
|
+
});
|
|
29
|
+
return /*#__PURE__*/React.createElement(TableCell, {
|
|
30
|
+
key: column.id,
|
|
31
|
+
classes: classes,
|
|
32
|
+
align: (_column$textAlign = column.textAlign) !== null && _column$textAlign !== void 0 ? _column$textAlign : 'left',
|
|
33
|
+
padding: column.disablePadding ? 'none' : 'normal',
|
|
34
|
+
sortDirection: orderBy === column.id ? order : false
|
|
35
|
+
}, column.sortable !== false ? /*#__PURE__*/React.createElement(TableSortLabel, {
|
|
36
|
+
active: orderBy === column.id,
|
|
37
|
+
direction: orderBy === column.id ? order : 'asc',
|
|
38
|
+
onClick: onClick
|
|
39
|
+
}, column.label, orderBy === column.id && /*#__PURE__*/React.createElement("span", {
|
|
40
|
+
className: className
|
|
41
|
+
}, order === 'desc' ? 'sorted descending' : 'sorted ascending')) : column.label);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default TableHeadCell;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare var _default: React.MemoExoticComponent<({ index, row, columns, isSelectedItem, children, onSelectClick }: {
|
|
2
|
+
index: any;
|
|
3
|
+
row: any;
|
|
4
|
+
columns: any;
|
|
5
|
+
isSelectedItem: any;
|
|
6
|
+
children: any;
|
|
7
|
+
onSelectClick: any;
|
|
8
|
+
}) => JSX.Element>;
|
|
9
|
+
export default _default;
|
|
10
|
+
import React from "react";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Cell from "cozy-ui/transpiled/react/Table/Virtualized/Cell";
|
|
3
|
+
import Checkbox from "cozy-ui/transpiled/react/Checkbox";
|
|
4
|
+
import TableCell from "cozy-ui/transpiled/react/TableCell";
|
|
5
|
+
|
|
6
|
+
var RowContent = function RowContent(_ref) {
|
|
7
|
+
var index = _ref.index,
|
|
8
|
+
row = _ref.row,
|
|
9
|
+
columns = _ref.columns,
|
|
10
|
+
isSelectedItem = _ref.isSelectedItem,
|
|
11
|
+
children = _ref.children,
|
|
12
|
+
onSelectClick = _ref.onSelectClick;
|
|
13
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableCell, {
|
|
14
|
+
align: "center",
|
|
15
|
+
padding: "checkbox"
|
|
16
|
+
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
17
|
+
checked: isSelectedItem(row),
|
|
18
|
+
inputProps: {
|
|
19
|
+
'aria-labelledby': "enhanced-table-checkbox-".concat(index)
|
|
20
|
+
},
|
|
21
|
+
onChange: function onChange() {
|
|
22
|
+
return onSelectClick(row);
|
|
23
|
+
}
|
|
24
|
+
})), columns.map(function (column) {
|
|
25
|
+
return /*#__PURE__*/React.createElement(Cell, {
|
|
26
|
+
key: column.id,
|
|
27
|
+
row: row,
|
|
28
|
+
columns: columns,
|
|
29
|
+
column: column
|
|
30
|
+
}, children);
|
|
31
|
+
}));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default /*#__PURE__*/React.memo(RowContent);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var descendingComparator = function descendingComparator(_ref) {
|
|
2
|
+
var a = _ref.a,
|
|
3
|
+
b = _ref.b,
|
|
4
|
+
order = _ref.order,
|
|
5
|
+
orderBy = _ref.orderBy,
|
|
6
|
+
lang = _ref.lang;
|
|
7
|
+
var aValue = a[orderBy];
|
|
8
|
+
var bValue = b[orderBy];
|
|
9
|
+
|
|
10
|
+
if (typeof aValue === 'string') {
|
|
11
|
+
var isDate = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}/.test(aValue);
|
|
12
|
+
var isNumber = !isNaN(parseInt(aValue));
|
|
13
|
+
|
|
14
|
+
if (isDate) {
|
|
15
|
+
return new Date(bValue) - new Date(aValue);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (isNumber) {
|
|
19
|
+
return parseInt(bValue) - parseInt(aValue);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var _Intl$Collator = Intl.Collator(lang || 'en', {
|
|
23
|
+
caseFirst: order === 'asc' ? 'upper' : 'lower'
|
|
24
|
+
}),
|
|
25
|
+
compare = _Intl$Collator.compare;
|
|
26
|
+
|
|
27
|
+
return compare(bValue, aValue);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return bValue - aValue;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export var getComparator = function getComparator(order, orderBy, lang) {
|
|
34
|
+
return order === 'desc' ? function (a, b) {
|
|
35
|
+
return descendingComparator({
|
|
36
|
+
a: a,
|
|
37
|
+
b: b,
|
|
38
|
+
order: order,
|
|
39
|
+
orderBy: orderBy,
|
|
40
|
+
lang: lang
|
|
41
|
+
});
|
|
42
|
+
} : function (a, b) {
|
|
43
|
+
return -descendingComparator({
|
|
44
|
+
a: a,
|
|
45
|
+
b: b,
|
|
46
|
+
order: order,
|
|
47
|
+
orderBy: orderBy,
|
|
48
|
+
lang: lang
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export var stableSort = function stableSort(array, comparator) {
|
|
53
|
+
var stabilizedThis = array.map(function (el, index) {
|
|
54
|
+
return [el, index];
|
|
55
|
+
});
|
|
56
|
+
stabilizedThis.sort(function (a, b) {
|
|
57
|
+
var order = comparator(a[0], b[0]);
|
|
58
|
+
if (order !== 0) return order;
|
|
59
|
+
return a[1] - b[1];
|
|
60
|
+
});
|
|
61
|
+
return stabilizedThis.map(function (el) {
|
|
62
|
+
return el[0];
|
|
63
|
+
});
|
|
64
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["rows", "columns", "defaultOrder", "secondarySort", "selectedItems", "onSelect", "onSelectAll", "isSelectedItem", "componentsProps", "dragProps"];
|
|
5
|
+
import React, { useState, forwardRef } from 'react';
|
|
6
|
+
import { TableVirtuoso } from 'react-virtuoso';
|
|
7
|
+
import CustomDragLayer from "cozy-ui/transpiled/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer";
|
|
8
|
+
import FixedHeaderContent from "cozy-ui/transpiled/react/Table/Virtualized/FixedHeaderContent";
|
|
9
|
+
import RowContent from "cozy-ui/transpiled/react/Table/Virtualized/RowContent";
|
|
10
|
+
import { stableSort, getComparator } from "cozy-ui/transpiled/react/Table/Virtualized/helpers";
|
|
11
|
+
import virtuosoComponents from "cozy-ui/transpiled/react/Table/Virtualized/virtuosoComponents";
|
|
12
|
+
var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
13
|
+
var rows = _ref.rows,
|
|
14
|
+
columns = _ref.columns,
|
|
15
|
+
defaultOrder = _ref.defaultOrder,
|
|
16
|
+
secondarySort = _ref.secondarySort,
|
|
17
|
+
_ref$selectedItems = _ref.selectedItems,
|
|
18
|
+
selectedItems = _ref$selectedItems === void 0 ? [] : _ref$selectedItems,
|
|
19
|
+
_ref$onSelect = _ref.onSelect,
|
|
20
|
+
onSelect = _ref$onSelect === void 0 ? function () {} : _ref$onSelect,
|
|
21
|
+
_ref$onSelectAll = _ref.onSelectAll,
|
|
22
|
+
onSelectAll = _ref$onSelectAll === void 0 ? function () {} : _ref$onSelectAll,
|
|
23
|
+
_ref$isSelectedItem = _ref.isSelectedItem,
|
|
24
|
+
isSelectedItem = _ref$isSelectedItem === void 0 ? function () {} : _ref$isSelectedItem,
|
|
25
|
+
componentsProps = _ref.componentsProps,
|
|
26
|
+
dragProps = _ref.dragProps,
|
|
27
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
|
|
29
|
+
var _useState = useState('asc'),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
order = _useState2[0],
|
|
32
|
+
setOrder = _useState2[1];
|
|
33
|
+
|
|
34
|
+
var _useState3 = useState(defaultOrder),
|
|
35
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
|
+
orderBy = _useState4[0],
|
|
37
|
+
setOrderBy = _useState4[1];
|
|
38
|
+
|
|
39
|
+
var _useState5 = useState([]),
|
|
40
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
41
|
+
itemsInDropProcess = _useState6[0],
|
|
42
|
+
setItemsInDropProcess = _useState6[1]; // array of Ids, for dragndrop feature
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
var sortedData = stableSort(rows, getComparator(order, orderBy));
|
|
46
|
+
var data = secondarySort ? secondarySort(sortedData) : sortedData;
|
|
47
|
+
|
|
48
|
+
var handleSort = function handleSort(property) {
|
|
49
|
+
var isAsc = orderBy === property && order === 'asc';
|
|
50
|
+
setOrder(isAsc ? 'desc' : 'asc');
|
|
51
|
+
setOrderBy(property);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var handleSelectAll = function handleSelectAll(event) {
|
|
55
|
+
var _event$target;
|
|
56
|
+
|
|
57
|
+
if (event !== null && event !== void 0 && (_event$target = event.target) !== null && _event$target !== void 0 && _event$target.checked) {
|
|
58
|
+
onSelectAll(rows);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
onSelectAll([]);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return /*#__PURE__*/React.createElement(TableVirtuoso, _extends({}, props, {
|
|
66
|
+
ref: ref,
|
|
67
|
+
data: data,
|
|
68
|
+
context: {
|
|
69
|
+
isSelectedItem: isSelectedItem,
|
|
70
|
+
selectedItems: selectedItems,
|
|
71
|
+
dragProps: dragProps,
|
|
72
|
+
itemsInDropProcess: itemsInDropProcess,
|
|
73
|
+
setItemsInDropProcess: setItemsInDropProcess
|
|
74
|
+
},
|
|
75
|
+
components: virtuosoComponents,
|
|
76
|
+
fixedHeaderContent: function fixedHeaderContent() {
|
|
77
|
+
return /*#__PURE__*/React.createElement(FixedHeaderContent, {
|
|
78
|
+
columns: columns,
|
|
79
|
+
rowCount: rows.length,
|
|
80
|
+
selectedCount: selectedItems.length,
|
|
81
|
+
order: order,
|
|
82
|
+
orderBy: orderBy,
|
|
83
|
+
onClick: handleSort,
|
|
84
|
+
onSelectAllClick: handleSelectAll
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
itemContent: function itemContent(_index, row) {
|
|
88
|
+
var _componentsProps$rowC;
|
|
89
|
+
|
|
90
|
+
return /*#__PURE__*/React.createElement(RowContent, {
|
|
91
|
+
index: _index,
|
|
92
|
+
row: row,
|
|
93
|
+
columns: columns,
|
|
94
|
+
isSelectedItem: isSelectedItem,
|
|
95
|
+
onSelectClick: onSelect
|
|
96
|
+
}, componentsProps === null || componentsProps === void 0 ? void 0 : (_componentsProps$rowC = componentsProps.rowContent) === null || _componentsProps$rowC === void 0 ? void 0 : _componentsProps$rowC.children);
|
|
97
|
+
},
|
|
98
|
+
rowSpan: 2
|
|
99
|
+
}));
|
|
100
|
+
});
|
|
101
|
+
VirtualizedTable.displayName = 'VirtualizedTable';
|
|
102
|
+
|
|
103
|
+
var VirtuosoTableWrapper = function VirtuosoTableWrapper(props) {
|
|
104
|
+
var _props$dragProps;
|
|
105
|
+
|
|
106
|
+
if (!((_props$dragProps = props.dragProps) !== null && _props$dragProps !== void 0 && _props$dragProps.enabled)) {
|
|
107
|
+
return /*#__PURE__*/React.createElement(VirtualizedTable, props);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CustomDragLayer, {
|
|
111
|
+
dragId: props.dragProps.dragId
|
|
112
|
+
}), /*#__PURE__*/React.createElement(VirtualizedTable, props));
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export default VirtuosoTableWrapper;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default virtuosoComponents;
|
|
2
|
+
declare namespace virtuosoComponents {
|
|
3
|
+
const Scroller: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
4
|
+
const Table: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
5
|
+
const TableHead: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
6
|
+
const TableBody: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
7
|
+
const TableFooter: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
8
|
+
const TableRow: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
9
|
+
}
|
|
10
|
+
import React from "react";
|