cozy-ui 123.2.0 → 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.
Files changed (58) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/package.json +11 -6
  3. package/react/ActionsMenu/ActionsMenuWrapper.jsx +21 -15
  4. package/react/Filename/Readme.md +10 -8
  5. package/react/Filename/index.jsx +56 -10
  6. package/react/Filename/styles.styl +3 -0
  7. package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +60 -0
  8. package/react/Table/Readme.md +80 -0
  9. package/react/Table/Virtualized/Cell.jsx +41 -0
  10. package/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer.jsx +45 -0
  11. package/react/Table/Virtualized/Dnd/CustomDrag/DragPreview.jsx +43 -0
  12. package/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper.jsx +52 -0
  13. package/react/Table/Virtualized/Dnd/DnDConfigWrapper.jsx +48 -0
  14. package/react/Table/Virtualized/Dnd/TableRow.jsx +86 -0
  15. package/react/Table/Virtualized/FixedHeaderContent.jsx +58 -0
  16. package/react/Table/Virtualized/HeadCell.jsx +45 -0
  17. package/react/Table/Virtualized/RowContent.jsx +35 -0
  18. package/react/Table/Virtualized/helpers.js +41 -0
  19. package/react/Table/Virtualized/helpers.spec.js +108 -0
  20. package/react/Table/Virtualized/index.jsx +104 -0
  21. package/react/Table/Virtualized/virtuosoComponents.jsx +61 -0
  22. package/react/TableRow/index.js +16 -1
  23. package/transpiled/react/ActionsMenu/ActionsMenuWrapper.js +14 -10
  24. package/transpiled/react/Filename/index.d.ts +2 -1
  25. package/transpiled/react/Filename/index.js +49 -16
  26. package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +56 -0
  27. package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +56 -0
  28. package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +56 -0
  29. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +56 -0
  30. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +59 -0
  31. package/transpiled/react/Table/Virtualized/Cell.d.ts +8 -0
  32. package/transpiled/react/Table/Virtualized/Cell.js +46 -0
  33. package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer.d.ts +4 -0
  34. package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer.js +47 -0
  35. package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreview.d.ts +6 -0
  36. package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreview.js +34 -0
  37. package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper.d.ts +8 -0
  38. package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper.js +63 -0
  39. package/transpiled/react/Table/Virtualized/Dnd/DnDConfigWrapper.d.ts +2 -0
  40. package/transpiled/react/Table/Virtualized/Dnd/DnDConfigWrapper.js +55 -0
  41. package/transpiled/react/Table/Virtualized/Dnd/TableRow.d.ts +8 -0
  42. package/transpiled/react/Table/Virtualized/Dnd/TableRow.js +130 -0
  43. package/transpiled/react/Table/Virtualized/FixedHeaderContent.d.ts +10 -0
  44. package/transpiled/react/Table/Virtualized/FixedHeaderContent.js +54 -0
  45. package/transpiled/react/Table/Virtualized/HeadCell.d.ts +8 -0
  46. package/transpiled/react/Table/Virtualized/HeadCell.js +44 -0
  47. package/transpiled/react/Table/Virtualized/RowContent.d.ts +10 -0
  48. package/transpiled/react/Table/Virtualized/RowContent.js +34 -0
  49. package/transpiled/react/Table/Virtualized/helpers.d.ts +2 -0
  50. package/transpiled/react/Table/Virtualized/helpers.js +64 -0
  51. package/transpiled/react/Table/Virtualized/helpers.spec.d.ts +1 -0
  52. package/transpiled/react/Table/Virtualized/index.d.ts +2 -0
  53. package/transpiled/react/Table/Virtualized/index.js +115 -0
  54. package/transpiled/react/Table/Virtualized/virtuosoComponents.d.ts +10 -0
  55. package/transpiled/react/Table/Virtualized/virtuosoComponents.js +100 -0
  56. package/transpiled/react/TableRow/index.d.ts +2 -1
  57. package/transpiled/react/TableRow/index.js +20 -1
  58. package/transpiled/react/stylesheet.css +1 -1
@@ -1,24 +1,21 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import cx from 'classnames';
1
4
  import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import Icon, { iconPropType } from "cozy-ui/transpiled/react/Icon";
5
+ import React, { Fragment } from 'react';
6
+ var styles = {
7
+ "icon-withPath": "styles__icon-withPath___1IcPC"
8
+ };
9
+ import { iconPropType } from "cozy-ui/transpiled/react/Icon";
4
10
  import MidEllipsis from "cozy-ui/transpiled/react/MidEllipsis";
5
11
  import Typography from "cozy-ui/transpiled/react/Typography";
6
12
 
7
- var Filename = function Filename(_ref) {
8
- var icon = _ref.icon,
9
- filename = _ref.filename,
13
+ var NameAndExtension = function NameAndExtension(_ref) {
14
+ var filename = _ref.filename,
10
15
  extension = _ref.extension,
11
- midEllipsis = _ref.midEllipsis,
12
- variant = _ref.variant;
13
- return /*#__PURE__*/React.createElement("div", {
14
- className: "u-flex u-flex-items-center"
15
- }, icon && /*#__PURE__*/React.createElement("div", {
16
- className: "u-mr-1"
17
- }, /*#__PURE__*/React.createElement(Icon, {
18
- icon: icon,
19
- width: 30,
20
- height: 30
21
- })), filename && /*#__PURE__*/React.createElement(Typography, {
16
+ variant = _ref.variant,
17
+ midEllipsis = _ref.midEllipsis;
18
+ return /*#__PURE__*/React.createElement(React.Fragment, null, filename && /*#__PURE__*/React.createElement(Typography, {
22
19
  variant: variant,
23
20
  component: "span",
24
21
  noWrap: true
@@ -31,6 +28,42 @@ var Filename = function Filename(_ref) {
31
28
  }, extension));
32
29
  };
33
30
 
31
+ var Filename = function Filename(_ref2) {
32
+ var icon = _ref2.icon,
33
+ filename = _ref2.filename,
34
+ extension = _ref2.extension,
35
+ midEllipsis = _ref2.midEllipsis,
36
+ variant = _ref2.variant,
37
+ path = _ref2.path;
38
+
39
+ var _ref3 = path ? [Fragment, {}] : ['div', {
40
+ className: cx('u-flex u-flex-items-center')
41
+ }],
42
+ _ref4 = _slicedToArray(_ref3, 2),
43
+ Wrapper = _ref4[0],
44
+ wrapperProps = _ref4[1];
45
+
46
+ return /*#__PURE__*/React.createElement(Wrapper, wrapperProps, icon && /*#__PURE__*/React.createElement("div", {
47
+ className: cx('u-flex u-pos-relative u-mr-1', _defineProperty({}, styles['icon-withPath'], !!path))
48
+ }, icon), path ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
49
+ className: "u-flex"
50
+ }, /*#__PURE__*/React.createElement(NameAndExtension, {
51
+ filename: filename,
52
+ extension: extension,
53
+ variant: variant,
54
+ midEllipsis: midEllipsis
55
+ })), /*#__PURE__*/React.createElement(Typography, {
56
+ variant: "body2",
57
+ component: "div",
58
+ noWrap: true
59
+ }, path)) : /*#__PURE__*/React.createElement(NameAndExtension, {
60
+ filename: filename,
61
+ extension: extension,
62
+ variant: variant,
63
+ midEllipsis: midEllipsis
64
+ }));
65
+ };
66
+
34
67
  Filename.propTypes = {
35
68
  /** Filename icon */
36
69
  icon: iconPropType,
@@ -580,6 +580,62 @@ export function makeDarkInvertedOverrides(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 makeDarkNormalOverrides(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 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,8 @@
1
+ declare var _default: React.MemoExoticComponent<({ row, columns, column, children }: {
2
+ row: any;
3
+ columns: any;
4
+ column: any;
5
+ children: any;
6
+ }) => JSX.Element>;
7
+ export default _default;
8
+ import React from "react";
@@ -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,4 @@
1
+ export function CustomDragLayer({ dragId }: {
2
+ dragId: any;
3
+ }): JSX.Element | null;
4
+ export default CustomDragLayer;
@@ -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,6 @@
1
+ declare var _default: React.MemoExoticComponent<({ fileName, selectedCount }: {
2
+ fileName: any;
3
+ selectedCount: any;
4
+ }) => JSX.Element>;
5
+ export default _default;
6
+ import React from "react";
@@ -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,8 @@
1
+ export default DragPreviewWrapper;
2
+ declare function DragPreviewWrapper({ item, itemType, dragId, initialOffset, currentOffset }: {
3
+ item: any;
4
+ itemType: any;
5
+ dragId: any;
6
+ initialOffset: any;
7
+ currentOffset: any;
8
+ }): JSX.Element | null;
@@ -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,2 @@
1
+ export default DnDConfigWrapper;
2
+ declare const DnDConfigWrapper: import("react").ForwardRefExoticComponent<import("react").RefAttributes<any>>;
@@ -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;