cozy-ui 126.6.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.
- package/CHANGELOG.md +39 -0
- package/package.json +1 -1
- package/react/Avatar/index.jsx +6 -0
- package/react/Checkbox/Readme.md +12 -0
- package/react/Checkbox/index.jsx +25 -3
- package/react/ContactsList/ContactRow.jsx +1 -1
- package/react/ContactsList/Contacts/ContactIdentity.jsx +34 -15
- package/react/ContactsList/Contacts/ContactName.jsx +22 -18
- package/react/ContactsList/locales/withContactsListLocales.jsx +1 -1
- package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +50 -25
- package/react/Table/Readme.md +39 -1
- package/react/Table/Virtualized/Cell.jsx +8 -6
- package/react/Table/Virtualized/Dnd/TableRow.jsx +14 -6
- package/react/Table/Virtualized/Dnd/index.jsx +35 -0
- package/react/Table/Virtualized/Dnd/virtuosoComponents.jsx +25 -0
- package/react/Table/Virtualized/FixedHeaderContent.jsx +7 -1
- package/react/Table/Virtualized/RowContent.jsx +19 -4
- package/react/Table/Virtualized/TableRow.jsx +20 -0
- package/react/Table/Virtualized/helpers.js +4 -2
- package/react/Table/Virtualized/index.jsx +13 -30
- package/react/Table/Virtualized/virtuosoComponents.jsx +23 -49
- package/react/TableContainer/index.js +16 -1
- package/react/utils/index.js +1 -0
- package/transpiled/react/Avatar/index.d.ts +5 -1
- package/transpiled/react/Avatar/index.js +13 -5
- package/transpiled/react/Checkbox/index.d.ts +6 -0
- package/transpiled/react/Checkbox/index.js +18 -5
- package/transpiled/react/ContactsList/ContactRow.js +1 -1
- package/transpiled/react/ContactsList/Contacts/ContactIdentity.d.ts +7 -7
- package/transpiled/react/ContactsList/Contacts/ContactIdentity.js +39 -22
- package/transpiled/react/ContactsList/Contacts/ContactName.d.ts +3 -9
- package/transpiled/react/ContactsList/Contacts/ContactName.js +12 -13
- package/transpiled/react/ContactsList/locales/withContactsListLocales.d.ts +6 -0
- package/transpiled/react/ContactsList/locales/withContactsListLocales.js +1 -1
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +46 -21
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +46 -21
- package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +46 -21
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +46 -21
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +50 -25
- package/transpiled/react/Table/Virtualized/Cell.d.ts +2 -1
- package/transpiled/react/Table/Virtualized/Cell.js +24 -17
- package/transpiled/react/Table/Virtualized/Dnd/TableRow.d.ts +1 -3
- package/transpiled/react/Table/Virtualized/Dnd/TableRow.js +9 -7
- package/transpiled/react/Table/Virtualized/Dnd/index.d.ts +7 -0
- package/transpiled/react/Table/Virtualized/Dnd/index.js +47 -0
- package/transpiled/react/Table/Virtualized/Dnd/virtuosoComponents.d.ts +14 -0
- package/transpiled/react/Table/Virtualized/Dnd/virtuosoComponents.js +39 -0
- package/transpiled/react/Table/Virtualized/FixedHeaderContent.d.ts +2 -2
- package/transpiled/react/Table/Virtualized/FixedHeaderContent.js +7 -1
- package/transpiled/react/Table/Virtualized/RowContent.d.ts +3 -2
- package/transpiled/react/Table/Virtualized/RowContent.js +13 -4
- package/transpiled/react/Table/Virtualized/TableRow.d.ts +3 -0
- package/transpiled/react/Table/Virtualized/TableRow.js +21 -0
- package/transpiled/react/Table/Virtualized/helpers.js +4 -2
- package/transpiled/react/Table/Virtualized/index.d.ts +3 -2
- package/transpiled/react/Table/Virtualized/index.js +17 -38
- package/transpiled/react/Table/Virtualized/virtuosoComponents.js +37 -65
- package/transpiled/react/TableContainer/index.d.ts +2 -1
- package/transpiled/react/TableContainer/index.js +20 -1
- package/transpiled/react/utils/index.d.ts +1 -0
- package/transpiled/react/utils/index.js +1 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export default TableRow;
|
|
2
|
-
declare function TableRow({ item, context,
|
|
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"
|
|
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 &&
|
|
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:
|
|
125
|
-
className: dragCollect.isDragging ? 'u-o-50' : '',
|
|
126
|
-
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,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,
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,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
|
|
8
|
-
var bValue = b
|
|
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
|
|
2
|
-
declare
|
|
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", "
|
|
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:
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
99
|
-
onSelectClick: onSelect
|
|
100
|
-
|
|
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;
|
|
@@ -1,100 +1,72 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
3
|
var _excluded = ["context"],
|
|
5
|
-
_excluded2 = ["
|
|
6
|
-
|
|
7
|
-
|
|
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; }
|
|
4
|
+
_excluded2 = ["context"],
|
|
5
|
+
_excluded3 = ["context", "className"],
|
|
6
|
+
_excluded4 = ["context"],
|
|
7
|
+
_excluded5 = ["context"];
|
|
10
8
|
|
|
9
|
+
/* eslint-disable no-unused-vars */
|
|
10
|
+
import cx from 'classnames';
|
|
11
11
|
import React, { forwardRef } from 'react';
|
|
12
|
-
import
|
|
13
|
-
import TableRowDnD from "cozy-ui/transpiled/react/Table/Virtualized/Dnd/TableRow";
|
|
12
|
+
import TableRow from "cozy-ui/transpiled/react/Table/Virtualized/TableRow";
|
|
14
13
|
import Table from "cozy-ui/transpiled/react/Table";
|
|
15
|
-
import Paper from "cozy-ui/transpiled/react/Paper";
|
|
16
14
|
import TableBody from "cozy-ui/transpiled/react/TableBody";
|
|
17
15
|
import TableContainer from "cozy-ui/transpiled/react/TableContainer";
|
|
18
16
|
import TableFooter from "cozy-ui/transpiled/react/TableFooter";
|
|
19
17
|
import TableHead from "cozy-ui/transpiled/react/TableHead";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
ref: ref,
|
|
25
|
-
component: Paper,
|
|
26
|
-
style: _objectSpread({
|
|
27
|
-
zIndex: 'var(--zIndex-app)'
|
|
28
|
-
}, props.style),
|
|
29
|
-
elevation: 0
|
|
30
|
-
}));
|
|
31
|
-
});
|
|
18
|
+
/**
|
|
19
|
+
Be aware that context is spread to every components but should not be spread to Table components
|
|
20
|
+
so we desctrure it from props, but don't spread to child to avoid its presence in DOM
|
|
21
|
+
*/
|
|
32
22
|
|
|
33
|
-
_TableContainer.displayName = '_TableContainer';
|
|
34
23
|
var virtuosoComponents = {
|
|
35
24
|
Scroller: /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
36
|
-
var _context$dragProps;
|
|
37
|
-
|
|
38
25
|
var context = _ref.context,
|
|
39
26
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}));
|
|
45
|
-
} else {
|
|
46
|
-
return /*#__PURE__*/React.createElement(DnDConfigWrapper, {
|
|
47
|
-
ref: ref
|
|
48
|
-
}, /*#__PURE__*/React.createElement(_TableContainer, _extends({}, props, {
|
|
49
|
-
ref: ref
|
|
50
|
-
})));
|
|
51
|
-
}
|
|
28
|
+
return /*#__PURE__*/React.createElement(TableContainer, _extends({}, props, {
|
|
29
|
+
ref: ref
|
|
30
|
+
}));
|
|
52
31
|
}),
|
|
53
|
-
Table: /*#__PURE__*/forwardRef(function (
|
|
32
|
+
Table: /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
33
|
+
var context = _ref2.context,
|
|
34
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
35
|
+
|
|
54
36
|
return /*#__PURE__*/React.createElement(Table, _extends({}, props, {
|
|
55
37
|
ref: ref
|
|
56
38
|
}));
|
|
57
39
|
}),
|
|
58
|
-
TableHead: /*#__PURE__*/forwardRef(function (
|
|
40
|
+
TableHead: /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
41
|
+
var context = _ref3.context,
|
|
42
|
+
className = _ref3.className,
|
|
43
|
+
props = _objectWithoutProperties(_ref3, _excluded3);
|
|
44
|
+
|
|
59
45
|
return /*#__PURE__*/React.createElement(TableHead, _extends({}, props, {
|
|
46
|
+
className: cx(className, 'virtualized'),
|
|
60
47
|
ref: ref
|
|
61
48
|
}));
|
|
62
49
|
}),
|
|
63
|
-
TableBody: /*#__PURE__*/forwardRef(function (
|
|
50
|
+
TableBody: /*#__PURE__*/forwardRef(function (_ref4, ref) {
|
|
51
|
+
var context = _ref4.context,
|
|
52
|
+
props = _objectWithoutProperties(_ref4, _excluded4);
|
|
53
|
+
|
|
64
54
|
return /*#__PURE__*/React.createElement(TableBody, _extends({}, props, {
|
|
65
55
|
ref: ref
|
|
66
56
|
}));
|
|
67
57
|
}),
|
|
68
|
-
TableFooter: /*#__PURE__*/forwardRef(function (
|
|
58
|
+
TableFooter: /*#__PURE__*/forwardRef(function (_ref5, ref) {
|
|
59
|
+
var context = _ref5.context,
|
|
60
|
+
props = _objectWithoutProperties(_ref5, _excluded5);
|
|
61
|
+
|
|
69
62
|
return /*#__PURE__*/React.createElement(TableFooter, _extends({}, props, {
|
|
70
63
|
ref: ref
|
|
71
64
|
}));
|
|
72
65
|
}),
|
|
73
|
-
TableRow: /*#__PURE__*/forwardRef(function (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
context = _ref2.context,
|
|
78
|
-
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
79
|
-
|
|
80
|
-
var isSelected = context === null || context === void 0 ? void 0 : context.isSelectedItem(item);
|
|
81
|
-
var isDisabled = context === null || context === void 0 ? void 0 : context.itemsInDropProcess.includes(item._id);
|
|
82
|
-
|
|
83
|
-
if (!((_context$dragProps2 = context.dragProps) !== null && _context$dragProps2 !== void 0 && _context$dragProps2.enabled)) {
|
|
84
|
-
return /*#__PURE__*/React.createElement(TableRow, _extends({}, props, {
|
|
85
|
-
ref: ref,
|
|
86
|
-
selected: isSelected,
|
|
87
|
-
hover: true
|
|
88
|
-
}));
|
|
89
|
-
} else {
|
|
90
|
-
return /*#__PURE__*/React.createElement(TableRowDnD, _extends({}, props, {
|
|
91
|
-
item: item,
|
|
92
|
-
context: context,
|
|
93
|
-
selected: isSelected,
|
|
94
|
-
disabled: isDisabled,
|
|
95
|
-
hover: true
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
66
|
+
TableRow: /*#__PURE__*/forwardRef(function (props, ref) {
|
|
67
|
+
return /*#__PURE__*/React.createElement(TableRow, _extends({}, props, {
|
|
68
|
+
ref: ref
|
|
69
|
+
}));
|
|
98
70
|
})
|
|
99
71
|
};
|
|
100
72
|
export default virtuosoComponents;
|
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
|
|
4
|
+
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; }
|
|
5
|
+
|
|
6
|
+
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; }
|
|
7
|
+
|
|
8
|
+
import MuiTableContainer from '@material-ui/core/TableContainer';
|
|
9
|
+
import React, { forwardRef } from 'react';
|
|
10
|
+
import Paper from "cozy-ui/transpiled/react/Paper";
|
|
11
|
+
var TableContainer = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
12
|
+
return /*#__PURE__*/React.createElement(MuiTableContainer, _extends({}, props, {
|
|
13
|
+
ref: ref,
|
|
14
|
+
component: Paper,
|
|
15
|
+
style: _objectSpread({
|
|
16
|
+
zIndex: 'var(--zIndex-app)'
|
|
17
|
+
}, props.style),
|
|
18
|
+
elevation: 0
|
|
19
|
+
}));
|
|
20
|
+
});
|
|
2
21
|
export default TableContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@material-ui/core/utils";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@material-ui/core/utils';
|