cozy-ui 126.5.0 → 127.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 (63) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/package.json +1 -1
  3. package/react/ActionsMenu/index.jsx +10 -0
  4. package/react/Avatar/index.jsx +6 -0
  5. package/react/Checkbox/Readme.md +12 -0
  6. package/react/Checkbox/index.jsx +25 -3
  7. package/react/ContactsList/ContactRow.jsx +1 -1
  8. package/react/ContactsList/Contacts/ContactIdentity.jsx +34 -15
  9. package/react/ContactsList/Contacts/ContactName.jsx +22 -18
  10. package/react/ContactsList/locales/withContactsListLocales.jsx +1 -1
  11. package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +50 -25
  12. package/react/Table/Readme.md +39 -1
  13. package/react/Table/Virtualized/Cell.jsx +8 -6
  14. package/react/Table/Virtualized/Dnd/TableRow.jsx +14 -6
  15. package/react/Table/Virtualized/Dnd/index.jsx +35 -0
  16. package/react/Table/Virtualized/Dnd/virtuosoComponents.jsx +25 -0
  17. package/react/Table/Virtualized/FixedHeaderContent.jsx +7 -1
  18. package/react/Table/Virtualized/RowContent.jsx +19 -4
  19. package/react/Table/Virtualized/TableRow.jsx +20 -0
  20. package/react/Table/Virtualized/helpers.js +4 -2
  21. package/react/Table/Virtualized/index.jsx +13 -30
  22. package/react/Table/Virtualized/virtuosoComponents.jsx +23 -49
  23. package/react/TableContainer/index.js +16 -1
  24. package/react/utils/index.js +1 -0
  25. package/transpiled/react/ActionsMenu/index.js +13 -2
  26. package/transpiled/react/Avatar/index.d.ts +5 -1
  27. package/transpiled/react/Avatar/index.js +13 -5
  28. package/transpiled/react/Checkbox/index.d.ts +6 -0
  29. package/transpiled/react/Checkbox/index.js +18 -5
  30. package/transpiled/react/ContactsList/ContactRow.js +1 -1
  31. package/transpiled/react/ContactsList/Contacts/ContactIdentity.d.ts +7 -7
  32. package/transpiled/react/ContactsList/Contacts/ContactIdentity.js +39 -22
  33. package/transpiled/react/ContactsList/Contacts/ContactName.d.ts +3 -9
  34. package/transpiled/react/ContactsList/Contacts/ContactName.js +12 -13
  35. package/transpiled/react/ContactsList/locales/withContactsListLocales.d.ts +6 -0
  36. package/transpiled/react/ContactsList/locales/withContactsListLocales.js +1 -1
  37. package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +46 -21
  38. package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +46 -21
  39. package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +46 -21
  40. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +46 -21
  41. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +50 -25
  42. package/transpiled/react/Table/Virtualized/Cell.d.ts +2 -1
  43. package/transpiled/react/Table/Virtualized/Cell.js +24 -17
  44. package/transpiled/react/Table/Virtualized/Dnd/TableRow.d.ts +1 -3
  45. package/transpiled/react/Table/Virtualized/Dnd/TableRow.js +9 -7
  46. package/transpiled/react/Table/Virtualized/Dnd/index.d.ts +7 -0
  47. package/transpiled/react/Table/Virtualized/Dnd/index.js +47 -0
  48. package/transpiled/react/Table/Virtualized/Dnd/virtuosoComponents.d.ts +14 -0
  49. package/transpiled/react/Table/Virtualized/Dnd/virtuosoComponents.js +39 -0
  50. package/transpiled/react/Table/Virtualized/FixedHeaderContent.d.ts +2 -2
  51. package/transpiled/react/Table/Virtualized/FixedHeaderContent.js +7 -1
  52. package/transpiled/react/Table/Virtualized/RowContent.d.ts +3 -2
  53. package/transpiled/react/Table/Virtualized/RowContent.js +13 -4
  54. package/transpiled/react/Table/Virtualized/TableRow.d.ts +3 -0
  55. package/transpiled/react/Table/Virtualized/TableRow.js +21 -0
  56. package/transpiled/react/Table/Virtualized/helpers.js +4 -2
  57. package/transpiled/react/Table/Virtualized/index.d.ts +3 -2
  58. package/transpiled/react/Table/Virtualized/index.js +17 -38
  59. package/transpiled/react/Table/Virtualized/virtuosoComponents.js +37 -65
  60. package/transpiled/react/TableContainer/index.d.ts +2 -1
  61. package/transpiled/react/TableContainer/index.js +20 -1
  62. package/transpiled/react/utils/index.d.ts +1 -0
  63. package/transpiled/react/utils/index.js +1 -0
@@ -484,7 +484,23 @@ export var makeLightNormalOverrides = function makeLightNormalOverrides(theme) {
484
484
  },
485
485
  MuiTableHead: {
486
486
  root: {
487
- backgroundColor: theme.palette.background.paper
487
+ backgroundColor: theme.palette.background.paper,
488
+ '&.virtualized': {
489
+ '& .virtualizedCheckbox': {
490
+ opacity: 0,
491
+ '&.checked': {
492
+ opacity: 1
493
+ },
494
+ '&:hover': {
495
+ opacity: 1
496
+ }
497
+ },
498
+ '&:hover': {
499
+ '& .virtualizedCheckbox': {
500
+ opacity: 0.5
501
+ }
502
+ }
503
+ }
488
504
  }
489
505
  },
490
506
  MuiTableRow: {
@@ -493,6 +509,25 @@ export var makeLightNormalOverrides = function makeLightNormalOverrides(theme) {
493
509
  cursor: 'pointer',
494
510
  pointerEvents: 'none',
495
511
  opacity: 0.5
512
+ },
513
+ '&.virtualized': {
514
+ '& .virtualizedCheckbox': {
515
+ opacity: 0,
516
+ '&.visible': {
517
+ opacity: 0.5
518
+ },
519
+ '&.checked': {
520
+ opacity: 1
521
+ },
522
+ '&:hover': {
523
+ opacity: 1
524
+ }
525
+ },
526
+ '&:hover': {
527
+ '& .virtualizedCheckbox': {
528
+ opacity: 0.5
529
+ }
530
+ }
496
531
  }
497
532
  }
498
533
  },
@@ -506,22 +541,11 @@ export var makeLightNormalOverrides = function makeLightNormalOverrides(theme) {
506
541
  }),
507
542
  body: {
508
543
  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
- }
544
+ height: '2rem'
545
+ },
546
+ paddingCheckbox: {
547
+ width: 32,
548
+ padding: 0
525
549
  },
526
550
  stickyHeader: {
527
551
  backgroundColor: theme.palette.background.paper
@@ -529,13 +553,8 @@ export var makeLightNormalOverrides = function makeLightNormalOverrides(theme) {
529
553
  },
530
554
  MuiTableSortLabel: {
531
555
  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
- }
556
+ padding: '8px 0',
557
+ color: theme.palette.text.secondary
539
558
  },
540
559
  icon: {
541
560
  fontSize: 14
@@ -788,6 +807,9 @@ export var makeLightNormalOverrides = function makeLightNormalOverrides(theme) {
788
807
  opacity: 0.5
789
808
  }
790
809
  },
810
+ '&.displayInline': {
811
+ display: 'inline-flex'
812
+ },
791
813
  '&.border': {
792
814
  border: "2px solid ".concat(theme.palette.background.paper)
793
815
  },
@@ -802,7 +824,10 @@ export var makeLightNormalOverrides = function makeLightNormalOverrides(theme) {
802
824
  },
803
825
  MuiCheckbox: {
804
826
  root: {
805
- padding: 8
827
+ padding: 8,
828
+ '&.small': {
829
+ padding: 6
830
+ }
806
831
  },
807
832
  colorSecondary: {
808
833
  '&$checked': {
@@ -1,7 +1,8 @@
1
- declare var _default: React.MemoExoticComponent<({ row, columns, column, children }: {
1
+ declare var _default: React.MemoExoticComponent<({ row, columns, column, onClick, children }: {
2
2
  row: any;
3
3
  columns: any;
4
4
  column: any;
5
+ onClick: any;
5
6
  children: any;
6
7
  }) => JSX.Element>;
7
8
  export default _default;
@@ -1,46 +1,53 @@
1
- import cx from 'classnames';
1
+ import get from 'lodash/get';
2
2
  import React from 'react';
3
3
  import TableCell from "cozy-ui/transpiled/react/TableCell";
4
4
  import { makeStyles } from "cozy-ui/transpiled/react/styles";
5
5
  var useStyles = makeStyles({
6
6
  root: {
7
- width: function width(_ref) {
8
- var column = _ref.column;
9
- return column.width;
7
+ cursor: function cursor(_ref) {
8
+ var isClickable = _ref.isClickable;
9
+ return isClickable ? 'pointer' : undefined;
10
10
  },
11
- maxWidth: function maxWidth(_ref2) {
11
+ width: function width(_ref2) {
12
12
  var column = _ref2.column;
13
+ return column.width;
14
+ },
15
+ maxWidth: function maxWidth(_ref3) {
16
+ var column = _ref3.column;
13
17
  return column.maxWidth;
14
18
  }
15
19
  }
16
20
  });
17
21
 
18
- var Cell = function Cell(_ref3) {
22
+ var Cell = function Cell(_ref4) {
19
23
  var _column$textAlign;
20
24
 
21
- var row = _ref3.row,
22
- columns = _ref3.columns,
23
- column = _ref3.column,
24
- children = _ref3.children;
25
+ var row = _ref4.row,
26
+ columns = _ref4.columns,
27
+ column = _ref4.column,
28
+ _onClick = _ref4.onClick,
29
+ children = _ref4.children;
25
30
  var classes = useStyles({
26
- column: column
31
+ column: column,
32
+ isClickable: !!_onClick
27
33
  });
34
+ var cellContent = get(row, column.id, '—');
28
35
  return /*#__PURE__*/React.createElement(TableCell, {
29
36
  key: column.id,
30
37
  classes: classes,
31
- className: cx({
32
- sortable: column.sortable !== false
33
- }),
34
38
  align: (_column$textAlign = column.textAlign) !== null && _column$textAlign !== void 0 ? _column$textAlign : 'left',
35
- padding: column.disablePadding ? 'none' : 'normal'
39
+ padding: column.disablePadding ? 'none' : 'normal',
40
+ onClick: function onClick() {
41
+ return _onClick === null || _onClick === void 0 ? void 0 : _onClick(row, column);
42
+ }
36
43
  }, children ? React.Children.map(children, function (child) {
37
44
  return /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
38
45
  row: row,
39
46
  columns: columns,
40
47
  column: column,
41
- cell: row[column.id]
48
+ cell: cellContent
42
49
  }) : null;
43
- }) : row[column.id]);
50
+ }) : cellContent);
44
51
  };
45
52
 
46
53
  export default /*#__PURE__*/React.memo(Cell);
@@ -1,8 +1,6 @@
1
1
  export default TableRow;
2
- declare function TableRow({ item, context, selected, disabled, ...props }: {
2
+ declare function TableRow({ item, context, ...props }: {
3
3
  [x: string]: any;
4
4
  item: any;
5
5
  context: any;
6
- selected: any;
7
- disabled: any;
8
6
  }): JSX.Element;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["item", "context", "selected", "disabled"];
5
+ var _excluded = ["item", "context"];
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import React, { useEffect } from 'react';
8
8
  import { useDrag, useDrop } from 'react-dnd';
@@ -12,17 +12,18 @@ import TableRowClassic from "cozy-ui/transpiled/react/TableRow";
12
12
  var TableRow = function TableRow(_ref) {
13
13
  var item = _ref.item,
14
14
  context = _ref.context,
15
- selected = _ref.selected,
16
- disabled = _ref.disabled,
17
15
  props = _objectWithoutProperties(_ref, _excluded);
18
16
 
19
17
  var selectedItems = context.selectedItems,
18
+ itemsInDropProcess = context.itemsInDropProcess,
20
19
  setItemsInDropProcess = context.setItemsInDropProcess,
21
20
  dragProps = context.dragProps;
22
21
  var onDrop = dragProps.onDrop,
23
22
  canDropProps = dragProps.canDrop,
24
23
  canDragProps = dragProps.canDrag,
25
24
  dragId = dragProps.dragId;
25
+ var isSelected = context === null || context === void 0 ? void 0 : context.isSelectedItem(item);
26
+ var isDisabled = itemsInDropProcess.includes(item._id);
26
27
 
27
28
  var _useDrag = useDrag(function () {
28
29
  return {
@@ -45,7 +46,7 @@ var TableRow = function TableRow(_ref) {
45
46
 
46
47
  // if selectedItems is not empty, only the selected items can be dragged
47
48
  if (selectedItems.length > 0) {
48
- return defaultCanDrag && selected;
49
+ return defaultCanDrag && isSelected;
49
50
  }
50
51
 
51
52
  return defaultCanDrag;
@@ -121,9 +122,10 @@ var TableRow = function TableRow(_ref) {
121
122
  ref: function ref(node) {
122
123
  return dragRef(dropRef(node));
123
124
  },
124
- selected: selected || dropCollect.isOver,
125
- className: dragCollect.isDragging ? 'u-o-50' : '',
126
- disabled: disabled
125
+ selected: isSelected || dropCollect.isOver,
126
+ className: dragCollect.isDragging ? 'virtualized u-o-50' : 'virtualized',
127
+ disabled: isDisabled,
128
+ hover: true
127
129
  }));
128
130
  };
129
131
 
@@ -0,0 +1,7 @@
1
+ export default VirtuosoTableDnd;
2
+ declare function VirtuosoTableDnd({ dragProps, context, components, ...props }: {
3
+ [x: string]: any;
4
+ dragProps: any;
5
+ context: any;
6
+ components: any;
7
+ }): JSX.Element;
@@ -0,0 +1,47 @@
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
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
+ var _excluded = ["dragProps", "context", "components"];
6
+
7
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
+
9
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
+
11
+ import React, { useState, useMemo } from 'react';
12
+ import CustomDragLayer from "cozy-ui/transpiled/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer";
13
+ import virtuosoComponentsDnd from "cozy-ui/transpiled/react/Table/Virtualized/Dnd/virtuosoComponents";
14
+ import VirtualizedTable from "cozy-ui/transpiled/react/Table/Virtualized/index";
15
+ import virtuosoComponents from "cozy-ui/transpiled/react/Table/Virtualized/virtuosoComponents";
16
+
17
+ var _components = _objectSpread(_objectSpread({}, virtuosoComponents), virtuosoComponentsDnd);
18
+
19
+ var VirtuosoTableDnd = function VirtuosoTableDnd(_ref) {
20
+ var dragProps = _ref.dragProps,
21
+ context = _ref.context,
22
+ components = _ref.components,
23
+ props = _objectWithoutProperties(_ref, _excluded);
24
+
25
+ var _useState = useState([]),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ itemsInDropProcess = _useState2[0],
28
+ setItemsInDropProcess = _useState2[1]; // array of Ids, for dragndrop feature
29
+
30
+
31
+ var _context = useMemo(function () {
32
+ return _objectSpread(_objectSpread({}, context), {}, {
33
+ dragProps: dragProps,
34
+ itemsInDropProcess: itemsInDropProcess,
35
+ setItemsInDropProcess: setItemsInDropProcess
36
+ });
37
+ }, [context, dragProps, itemsInDropProcess]);
38
+
39
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CustomDragLayer, {
40
+ dragId: dragProps.dragId
41
+ }), /*#__PURE__*/React.createElement(VirtualizedTable, _extends({
42
+ components: components || _components,
43
+ context: _context
44
+ }, props)));
45
+ };
46
+
47
+ export default VirtuosoTableDnd;
@@ -0,0 +1,14 @@
1
+ export default virtuosoComponentsDnd;
2
+ /**
3
+ Be aware that context is spread to every components but should not be spread to Table components
4
+ so we desctrure it from props, but don't spread to child to avoid its presence in DOM
5
+ */
6
+ declare const virtuosoComponentsDnd: {
7
+ Scroller: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
8
+ TableRow: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
9
+ Table: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
10
+ TableHead: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
11
+ TableBody: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
12
+ TableFooter: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
13
+ };
14
+ import React from "react";
@@ -0,0 +1,39 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ var _excluded = ["context"];
5
+
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+
8
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
+
10
+ import React, { forwardRef } from 'react';
11
+ import DnDConfigWrapper from "cozy-ui/transpiled/react/Table/Virtualized/Dnd/DnDConfigWrapper";
12
+ import TableRowDnD from "cozy-ui/transpiled/react/Table/Virtualized/Dnd/TableRow";
13
+ import TableContainer from "cozy-ui/transpiled/react/TableContainer";
14
+ import virtuosoComponents from "cozy-ui/transpiled/react/Table/Virtualized/virtuosoComponents";
15
+ /**
16
+ Be aware that context is spread to every components but should not be spread to Table components
17
+ so we desctrure it from props, but don't spread to child to avoid its presence in DOM
18
+ */
19
+
20
+ var virtuosoComponentsDnd = _objectSpread(_objectSpread({}, virtuosoComponents), {}, {
21
+ // eslint-disable-next-line no-unused-vars
22
+ Scroller: /*#__PURE__*/forwardRef(function (_ref, ref) {
23
+ var context = _ref.context,
24
+ props = _objectWithoutProperties(_ref, _excluded);
25
+
26
+ return /*#__PURE__*/React.createElement(DnDConfigWrapper, {
27
+ ref: ref
28
+ }, /*#__PURE__*/React.createElement(TableContainer, _extends({}, props, {
29
+ ref: ref
30
+ })));
31
+ }),
32
+ TableRow: /*#__PURE__*/forwardRef(function (props, ref) {
33
+ return /*#__PURE__*/React.createElement(TableRowDnD, _extends({}, props, {
34
+ ref: ref
35
+ }));
36
+ })
37
+ });
38
+
39
+ export default virtuosoComponentsDnd;
@@ -1,10 +1,10 @@
1
1
  export default FixedHeaderContent;
2
- declare function FixedHeaderContent({ columns, order, orderBy, rowCount, selectedCount, onClick, onSelectAllClick }: {
2
+ declare function FixedHeaderContent({ columns, order, orderBy, rowCount, context, onClick, onSelectAllClick }: {
3
3
  columns: any;
4
4
  order: any;
5
5
  orderBy: any;
6
6
  rowCount: any;
7
- selectedCount: any;
7
+ context: any;
8
8
  onClick: any;
9
9
  onSelectAllClick: any;
10
10
  }): JSX.Element;
@@ -1,3 +1,4 @@
1
+ import cx from 'classnames';
1
2
  import React from 'react';
2
3
  import TableHeadCell from "cozy-ui/transpiled/react/Table/Virtualized/HeadCell";
3
4
  import Checkbox from "cozy-ui/transpiled/react/Checkbox";
@@ -23,19 +24,24 @@ var FixedHeaderContent = function FixedHeaderContent(_ref) {
23
24
  order = _ref.order,
24
25
  orderBy = _ref.orderBy,
25
26
  rowCount = _ref.rowCount,
26
- selectedCount = _ref.selectedCount,
27
+ context = _ref.context,
27
28
  _onClick = _ref.onClick,
28
29
  onSelectAllClick = _ref.onSelectAllClick;
29
30
  var classes = useStyles();
31
+ var selectedCount = context.selectedItems.length;
30
32
  return /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
31
33
  align: "center",
32
34
  padding: "checkbox"
33
35
  }, /*#__PURE__*/React.createElement(Checkbox, {
36
+ className: cx('virtualizedCheckbox', {
37
+ checked: selectedCount > 0
38
+ }),
34
39
  indeterminate: selectedCount > 0 && selectedCount < rowCount,
35
40
  checked: rowCount > 0 && selectedCount === rowCount,
36
41
  inputProps: {
37
42
  'aria-label': 'select all'
38
43
  },
44
+ size: "small",
39
45
  onChange: onSelectAllClick
40
46
  })), columns.map(function (column) {
41
47
  return /*#__PURE__*/React.createElement(TableHeadCell, {
@@ -1,10 +1,11 @@
1
- declare var _default: React.MemoExoticComponent<({ index, row, columns, isSelectedItem, children, onSelectClick }: {
1
+ declare var _default: React.MemoExoticComponent<({ index, row, columns, context, children, onSelectClick, onClick }: {
2
2
  index: any;
3
3
  row: any;
4
4
  columns: any;
5
- isSelectedItem: any;
5
+ context: any;
6
6
  children: any;
7
7
  onSelectClick: any;
8
+ onClick: any;
8
9
  }) => JSX.Element>;
9
10
  export default _default;
10
11
  import React from "react";
@@ -1,3 +1,4 @@
1
+ import cx from 'classnames';
1
2
  import React from 'react';
2
3
  import Cell from "cozy-ui/transpiled/react/Table/Virtualized/Cell";
3
4
  import Checkbox from "cozy-ui/transpiled/react/Checkbox";
@@ -7,17 +8,24 @@ var RowContent = function RowContent(_ref) {
7
8
  var index = _ref.index,
8
9
  row = _ref.row,
9
10
  columns = _ref.columns,
10
- isSelectedItem = _ref.isSelectedItem,
11
+ context = _ref.context,
11
12
  children = _ref.children,
12
- onSelectClick = _ref.onSelectClick;
13
+ onSelectClick = _ref.onSelectClick,
14
+ onClick = _ref.onClick;
15
+ var selectedCount = context.selectedItems.length;
13
16
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableCell, {
14
17
  align: "center",
15
18
  padding: "checkbox"
16
19
  }, /*#__PURE__*/React.createElement(Checkbox, {
17
- checked: isSelectedItem(row),
20
+ className: cx('virtualizedCheckbox', {
21
+ visible: selectedCount > 0,
22
+ checked: context.isSelectedItem(row)
23
+ }),
24
+ checked: context.isSelectedItem(row),
18
25
  inputProps: {
19
26
  'aria-labelledby': "enhanced-table-checkbox-".concat(index)
20
27
  },
28
+ size: "small",
21
29
  onChange: function onChange() {
22
30
  return onSelectClick(row);
23
31
  }
@@ -26,7 +34,8 @@ var RowContent = function RowContent(_ref) {
26
34
  key: column.id,
27
35
  row: row,
28
36
  columns: columns,
29
- column: column
37
+ column: column,
38
+ onClick: onClick
30
39
  }, children);
31
40
  }));
32
41
  };
@@ -0,0 +1,3 @@
1
+ export default TableRow;
2
+ declare const TableRow: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
+ import React from "react";
@@ -0,0 +1,21 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["item", "context", "className"];
4
+ import cx from 'classnames';
5
+ import React, { forwardRef } from 'react';
6
+ import TableRowClassic from "cozy-ui/transpiled/react/TableRow";
7
+ var TableRow = /*#__PURE__*/forwardRef(function (_ref, ref) {
8
+ var item = _ref.item,
9
+ context = _ref.context,
10
+ className = _ref.className,
11
+ props = _objectWithoutProperties(_ref, _excluded);
12
+
13
+ var isSelected = context === null || context === void 0 ? void 0 : context.isSelectedItem(item);
14
+ return /*#__PURE__*/React.createElement(TableRowClassic, _extends({}, props, {
15
+ className: cx(className, 'virtualized'),
16
+ ref: ref,
17
+ selected: isSelected,
18
+ hover: true
19
+ }));
20
+ });
21
+ export default TableRow;
@@ -1,11 +1,13 @@
1
+ import get from 'lodash/get';
2
+
1
3
  var descendingComparator = function descendingComparator(_ref) {
2
4
  var a = _ref.a,
3
5
  b = _ref.b,
4
6
  order = _ref.order,
5
7
  orderBy = _ref.orderBy,
6
8
  lang = _ref.lang;
7
- var aValue = a[orderBy];
8
- var bValue = b[orderBy];
9
+ var aValue = get(a, orderBy, '');
10
+ var bValue = get(b, orderBy, '');
9
11
 
10
12
  if (typeof aValue === 'string') {
11
13
  var isDate = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}/.test(aValue);
@@ -1,2 +1,3 @@
1
- export default VirtuosoTableWrapper;
2
- declare function VirtuosoTableWrapper(props: any): JSX.Element;
1
+ export default VirtualizedTable;
2
+ declare const VirtualizedTable: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
+ import React from "react";
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["rows", "columns", "defaultOrder", "secondarySort", "selectedItems", "onSelect", "onSelectAll", "isSelectedItem", "componentsProps", "dragProps", "context", "components"];
5
+ var _excluded = ["rows", "columns", "defaultOrder", "secondarySort", "selectedItems", "onSelect", "onSelectAll", "isSelectedItem", "componentsProps", "context", "components"];
6
6
 
7
7
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
8
 
@@ -10,7 +10,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
10
10
 
11
11
  import React, { useState, forwardRef } from 'react';
12
12
  import { TableVirtuoso } from 'react-virtuoso';
13
- import CustomDragLayer from "cozy-ui/transpiled/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer";
14
13
  import FixedHeaderContent from "cozy-ui/transpiled/react/Table/Virtualized/FixedHeaderContent";
15
14
  import RowContent from "cozy-ui/transpiled/react/Table/Virtualized/RowContent";
16
15
  import { stableSort, getComparator } from "cozy-ui/transpiled/react/Table/Virtualized/helpers";
@@ -25,7 +24,6 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
25
24
  onSelectAll = _ref.onSelectAll,
26
25
  isSelectedItem = _ref.isSelectedItem,
27
26
  componentsProps = _ref.componentsProps,
28
- dragProps = _ref.dragProps,
29
27
  context = _ref.context,
30
28
  components = _ref.components,
31
29
  props = _objectWithoutProperties(_ref, _excluded);
@@ -40,15 +38,14 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
40
38
  orderBy = _useState4[0],
41
39
  setOrderBy = _useState4[1];
42
40
 
43
- var _useState5 = useState([]),
44
- _useState6 = _slicedToArray(_useState5, 2),
45
- itemsInDropProcess = _useState6[0],
46
- setItemsInDropProcess = _useState6[1]; // array of Ids, for dragndrop feature
47
-
48
-
49
41
  var sortedData = stableSort(rows, getComparator(order, orderBy));
50
42
  var data = secondarySort ? secondarySort(sortedData) : sortedData;
51
43
 
44
+ var _context = _objectSpread(_objectSpread({}, context), {}, {
45
+ isSelectedItem: isSelectedItem,
46
+ selectedItems: selectedItems
47
+ });
48
+
52
49
  var handleSort = function handleSort(property) {
53
50
  var isAsc = orderBy === property && order === 'asc';
54
51
  setOrder(isAsc ? 'desc' : 'asc');
@@ -69,35 +66,30 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
69
66
  return /*#__PURE__*/React.createElement(TableVirtuoso, _extends({}, props, {
70
67
  ref: ref,
71
68
  data: data,
72
- context: _objectSpread(_objectSpread({}, context), {}, {
73
- isSelectedItem: isSelectedItem,
74
- selectedItems: selectedItems,
75
- dragProps: dragProps,
76
- itemsInDropProcess: itemsInDropProcess,
77
- setItemsInDropProcess: setItemsInDropProcess
78
- }),
69
+ context: _context,
79
70
  components: components || virtuosoComponents,
80
71
  fixedHeaderContent: function fixedHeaderContent() {
81
- return /*#__PURE__*/React.createElement(FixedHeaderContent, _extends({}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.FixedHeaderContent, {
72
+ return /*#__PURE__*/React.createElement(FixedHeaderContent, _extends({}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.fixedHeaderContent, {
82
73
  columns: columns,
83
74
  rowCount: rows.length,
84
- selectedCount: selectedItems.length,
75
+ context: _context,
85
76
  order: order,
86
77
  orderBy: orderBy,
87
78
  onClick: handleSort,
88
79
  onSelectAllClick: handleSelectAll
89
80
  }));
90
81
  },
91
- itemContent: function itemContent(_index, row) {
92
- var _componentsProps$rowC;
82
+ itemContent: function itemContent(_index, row, context) {
83
+ var _componentsProps$rowC, _componentsProps$rowC2;
93
84
 
94
- return /*#__PURE__*/React.createElement(RowContent, _extends({}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.RowContent, {
85
+ return /*#__PURE__*/React.createElement(RowContent, _extends({}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.rowContent, {
95
86
  index: _index,
96
87
  row: row,
97
88
  columns: columns,
98
- isSelectedItem: isSelectedItem,
99
- onSelectClick: onSelect
100
- }), componentsProps === null || componentsProps === void 0 ? void 0 : (_componentsProps$rowC = componentsProps.rowContent) === null || _componentsProps$rowC === void 0 ? void 0 : _componentsProps$rowC.children);
89
+ context: context,
90
+ onSelectClick: onSelect,
91
+ onClick: componentsProps === null || componentsProps === void 0 ? void 0 : (_componentsProps$rowC = componentsProps.rowContent) === null || _componentsProps$rowC === void 0 ? void 0 : _componentsProps$rowC.onClick
92
+ }), componentsProps === null || componentsProps === void 0 ? void 0 : (_componentsProps$rowC2 = componentsProps.rowContent) === null || _componentsProps$rowC2 === void 0 ? void 0 : _componentsProps$rowC2.children);
101
93
  },
102
94
  rowSpan: 2
103
95
  }));
@@ -109,17 +101,4 @@ VirtualizedTable.defaultProps = {
109
101
  onSelect: function onSelect() {},
110
102
  onSelectAll: function onSelectAll() {}
111
103
  };
112
-
113
- var VirtuosoTableWrapper = function VirtuosoTableWrapper(props) {
114
- var _props$dragProps;
115
-
116
- if (!((_props$dragProps = props.dragProps) !== null && _props$dragProps !== void 0 && _props$dragProps.enabled)) {
117
- return /*#__PURE__*/React.createElement(VirtualizedTable, props);
118
- } else {
119
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CustomDragLayer, {
120
- dragId: props.dragProps.dragId
121
- }), /*#__PURE__*/React.createElement(VirtualizedTable, props));
122
- }
123
- };
124
-
125
- export default VirtuosoTableWrapper;
104
+ export default VirtualizedTable;