cozy-ui 123.2.1 → 124.0.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 +29 -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/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/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
|
@@ -580,6 +580,62 @@ export function makeLightInvertedOverrides(theme: any): {
|
|
|
580
580
|
paddingRight: number;
|
|
581
581
|
};
|
|
582
582
|
};
|
|
583
|
+
MuiTableHead: {
|
|
584
|
+
root: {
|
|
585
|
+
backgroundColor: any;
|
|
586
|
+
};
|
|
587
|
+
};
|
|
588
|
+
MuiTableRow: {
|
|
589
|
+
root: {
|
|
590
|
+
'&.disabled': {
|
|
591
|
+
cursor: string;
|
|
592
|
+
pointerEvents: string;
|
|
593
|
+
opacity: number;
|
|
594
|
+
};
|
|
595
|
+
};
|
|
596
|
+
};
|
|
597
|
+
MuiTableCell: {
|
|
598
|
+
root: {
|
|
599
|
+
padding: string;
|
|
600
|
+
};
|
|
601
|
+
head: any;
|
|
602
|
+
body: {
|
|
603
|
+
color: any;
|
|
604
|
+
'&.sortable': {
|
|
605
|
+
'&$paddingNone': {
|
|
606
|
+
'&$alignLeft': {
|
|
607
|
+
paddingLeft: string;
|
|
608
|
+
};
|
|
609
|
+
'&$alignRight': {
|
|
610
|
+
paddingRight: string;
|
|
611
|
+
};
|
|
612
|
+
};
|
|
613
|
+
'&$alignLeft': {
|
|
614
|
+
paddingLeft: string;
|
|
615
|
+
};
|
|
616
|
+
'&$alignRight': {
|
|
617
|
+
paddingRight: string;
|
|
618
|
+
};
|
|
619
|
+
};
|
|
620
|
+
};
|
|
621
|
+
stickyHeader: {
|
|
622
|
+
backgroundColor: any;
|
|
623
|
+
};
|
|
624
|
+
};
|
|
625
|
+
MuiTableSortLabel: {
|
|
626
|
+
root: {
|
|
627
|
+
padding: string;
|
|
628
|
+
color: any;
|
|
629
|
+
'&:hover': {
|
|
630
|
+
color: any;
|
|
631
|
+
borderRadius: number;
|
|
632
|
+
backgroundColor: any;
|
|
633
|
+
};
|
|
634
|
+
};
|
|
635
|
+
icon: {
|
|
636
|
+
fontSize: number;
|
|
637
|
+
};
|
|
638
|
+
};
|
|
583
639
|
MuiFormLabel: {
|
|
584
640
|
root: {
|
|
585
641
|
color: any;
|
|
@@ -580,6 +580,62 @@ export function makeLightNormalOverrides(theme: any): {
|
|
|
580
580
|
paddingRight: number;
|
|
581
581
|
};
|
|
582
582
|
};
|
|
583
|
+
MuiTableHead: {
|
|
584
|
+
root: {
|
|
585
|
+
backgroundColor: any;
|
|
586
|
+
};
|
|
587
|
+
};
|
|
588
|
+
MuiTableRow: {
|
|
589
|
+
root: {
|
|
590
|
+
'&.disabled': {
|
|
591
|
+
cursor: string;
|
|
592
|
+
pointerEvents: string;
|
|
593
|
+
opacity: number;
|
|
594
|
+
};
|
|
595
|
+
};
|
|
596
|
+
};
|
|
597
|
+
MuiTableCell: {
|
|
598
|
+
root: {
|
|
599
|
+
padding: string;
|
|
600
|
+
};
|
|
601
|
+
head: any;
|
|
602
|
+
body: {
|
|
603
|
+
color: any;
|
|
604
|
+
'&.sortable': {
|
|
605
|
+
'&$paddingNone': {
|
|
606
|
+
'&$alignLeft': {
|
|
607
|
+
paddingLeft: string;
|
|
608
|
+
};
|
|
609
|
+
'&$alignRight': {
|
|
610
|
+
paddingRight: string;
|
|
611
|
+
};
|
|
612
|
+
};
|
|
613
|
+
'&$alignLeft': {
|
|
614
|
+
paddingLeft: string;
|
|
615
|
+
};
|
|
616
|
+
'&$alignRight': {
|
|
617
|
+
paddingRight: string;
|
|
618
|
+
};
|
|
619
|
+
};
|
|
620
|
+
};
|
|
621
|
+
stickyHeader: {
|
|
622
|
+
backgroundColor: any;
|
|
623
|
+
};
|
|
624
|
+
};
|
|
625
|
+
MuiTableSortLabel: {
|
|
626
|
+
root: {
|
|
627
|
+
padding: string;
|
|
628
|
+
color: any;
|
|
629
|
+
'&:hover': {
|
|
630
|
+
color: any;
|
|
631
|
+
borderRadius: number;
|
|
632
|
+
backgroundColor: any;
|
|
633
|
+
};
|
|
634
|
+
};
|
|
635
|
+
icon: {
|
|
636
|
+
fontSize: number;
|
|
637
|
+
};
|
|
638
|
+
};
|
|
583
639
|
MuiFormLabel: {
|
|
584
640
|
root: {
|
|
585
641
|
color: any;
|
|
@@ -482,6 +482,65 @@ export var makeLightNormalOverrides = function makeLightNormalOverrides(theme) {
|
|
|
482
482
|
paddingRight: 16
|
|
483
483
|
}
|
|
484
484
|
},
|
|
485
|
+
MuiTableHead: {
|
|
486
|
+
root: {
|
|
487
|
+
backgroundColor: theme.palette.background.paper
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
MuiTableRow: {
|
|
491
|
+
root: {
|
|
492
|
+
'&.disabled': {
|
|
493
|
+
cursor: 'pointer',
|
|
494
|
+
pointerEvents: 'none',
|
|
495
|
+
opacity: 0.5
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
MuiTableCell: {
|
|
500
|
+
root: {
|
|
501
|
+
padding: '8px 4px'
|
|
502
|
+
},
|
|
503
|
+
head: _objectSpread(_objectSpread({}, theme.typography.subtitle2), {}, {
|
|
504
|
+
color: theme.palette.text.secondary,
|
|
505
|
+
lineHeight: 1.292
|
|
506
|
+
}),
|
|
507
|
+
body: {
|
|
508
|
+
color: theme.palette.text.secondary,
|
|
509
|
+
'&.sortable': {
|
|
510
|
+
'&$paddingNone': {
|
|
511
|
+
'&$alignLeft': {
|
|
512
|
+
paddingLeft: '12px'
|
|
513
|
+
},
|
|
514
|
+
'&$alignRight': {
|
|
515
|
+
paddingRight: '12px'
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
'&$alignLeft': {
|
|
519
|
+
paddingLeft: '16px'
|
|
520
|
+
},
|
|
521
|
+
'&$alignRight': {
|
|
522
|
+
paddingRight: '16px'
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
stickyHeader: {
|
|
527
|
+
backgroundColor: theme.palette.background.paper
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
MuiTableSortLabel: {
|
|
531
|
+
root: {
|
|
532
|
+
padding: '8px 12px',
|
|
533
|
+
color: theme.palette.text.secondary,
|
|
534
|
+
'&:hover': {
|
|
535
|
+
color: theme.palette.text.primary,
|
|
536
|
+
borderRadius: 999,
|
|
537
|
+
backgroundColor: theme.palette.action.hover
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
icon: {
|
|
541
|
+
fontSize: 14
|
|
542
|
+
}
|
|
543
|
+
},
|
|
485
544
|
MuiFormLabel: {
|
|
486
545
|
root: {
|
|
487
546
|
color: theme.palette.text.secondary,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import TableCell from "cozy-ui/transpiled/react/TableCell";
|
|
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 Cell = function Cell(_ref3) {
|
|
19
|
+
var _column$textAlign;
|
|
20
|
+
|
|
21
|
+
var row = _ref3.row,
|
|
22
|
+
columns = _ref3.columns,
|
|
23
|
+
column = _ref3.column,
|
|
24
|
+
children = _ref3.children;
|
|
25
|
+
var classes = useStyles({
|
|
26
|
+
column: column
|
|
27
|
+
});
|
|
28
|
+
return /*#__PURE__*/React.createElement(TableCell, {
|
|
29
|
+
key: column.id,
|
|
30
|
+
classes: classes,
|
|
31
|
+
className: cx({
|
|
32
|
+
sortable: column.sortable !== false
|
|
33
|
+
}),
|
|
34
|
+
align: (_column$textAlign = column.textAlign) !== null && _column$textAlign !== void 0 ? _column$textAlign : 'left',
|
|
35
|
+
padding: column.disablePadding ? 'none' : 'normal'
|
|
36
|
+
}, children ? React.Children.map(children, function (child) {
|
|
37
|
+
return /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
|
|
38
|
+
row: row,
|
|
39
|
+
columns: columns,
|
|
40
|
+
column: column,
|
|
41
|
+
cell: row[column.id]
|
|
42
|
+
}) : null;
|
|
43
|
+
}) : row[column.id]);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default /*#__PURE__*/React.memo(Cell);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useDragLayer } from 'react-dnd';
|
|
3
|
+
import DragPreviewWrapper from "cozy-ui/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper";
|
|
4
|
+
var layerStyles = {
|
|
5
|
+
position: 'fixed',
|
|
6
|
+
pointerEvents: 'none',
|
|
7
|
+
zIndex: 100,
|
|
8
|
+
left: 0,
|
|
9
|
+
top: 0,
|
|
10
|
+
width: '100%',
|
|
11
|
+
height: '100%'
|
|
12
|
+
}; // Example find in the official documentation
|
|
13
|
+
// https://react-dnd.github.io/react-dnd/examples/drag-around/custom-drag-layer
|
|
14
|
+
|
|
15
|
+
export var CustomDragLayer = function CustomDragLayer(_ref) {
|
|
16
|
+
var dragId = _ref.dragId;
|
|
17
|
+
|
|
18
|
+
var _useDragLayer = useDragLayer(function (monitor) {
|
|
19
|
+
return {
|
|
20
|
+
item: monitor.getItem(),
|
|
21
|
+
itemType: monitor.getItemType(),
|
|
22
|
+
initialOffset: monitor.getInitialSourceClientOffset(),
|
|
23
|
+
currentOffset: monitor.getSourceClientOffset(),
|
|
24
|
+
isDragging: monitor.isDragging()
|
|
25
|
+
};
|
|
26
|
+
}),
|
|
27
|
+
itemType = _useDragLayer.itemType,
|
|
28
|
+
isDragging = _useDragLayer.isDragging,
|
|
29
|
+
item = _useDragLayer.item,
|
|
30
|
+
initialOffset = _useDragLayer.initialOffset,
|
|
31
|
+
currentOffset = _useDragLayer.currentOffset;
|
|
32
|
+
|
|
33
|
+
if (!isDragging) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
style: layerStyles
|
|
39
|
+
}, /*#__PURE__*/React.createElement(DragPreviewWrapper, {
|
|
40
|
+
item: item,
|
|
41
|
+
itemType: itemType,
|
|
42
|
+
dragId: dragId,
|
|
43
|
+
initialOffset: initialOffset,
|
|
44
|
+
currentOffset: currentOffset
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
export default CustomDragLayer;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Badge from "cozy-ui/transpiled/react/Badge";
|
|
3
|
+
import Paper from "cozy-ui/transpiled/react/Paper";
|
|
4
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
5
|
+
import { makeStyles } from "cozy-ui/transpiled/react/styles";
|
|
6
|
+
var useStyles = makeStyles({
|
|
7
|
+
root: {
|
|
8
|
+
width: 'fit-content'
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
var DragPreview = function DragPreview(_ref) {
|
|
13
|
+
var fileName = _ref.fileName,
|
|
14
|
+
selectedCount = _ref.selectedCount;
|
|
15
|
+
var classes = useStyles();
|
|
16
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, selectedCount > 1 ? /*#__PURE__*/React.createElement(Badge, {
|
|
17
|
+
badgeContent: selectedCount,
|
|
18
|
+
size: "large",
|
|
19
|
+
color: "primary",
|
|
20
|
+
anchorOrigin: {
|
|
21
|
+
vertical: 'top',
|
|
22
|
+
horizontal: 'right'
|
|
23
|
+
},
|
|
24
|
+
overlap: "rectangular"
|
|
25
|
+
}, /*#__PURE__*/React.createElement(Paper, {
|
|
26
|
+
classes: classes,
|
|
27
|
+
className: "u-p-half u-maw-5"
|
|
28
|
+
}, /*#__PURE__*/React.createElement(Typography, null, fileName))) : /*#__PURE__*/React.createElement(Paper, {
|
|
29
|
+
classes: classes,
|
|
30
|
+
className: "u-p-half u-maw-5"
|
|
31
|
+
}, /*#__PURE__*/React.createElement(Typography, null, fileName)));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default /*#__PURE__*/React.memo(DragPreview);
|
|
@@ -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;
|