cozy-ui 123.2.1 → 124.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/assets/icons/ui/cloud2.svg +1 -0
- package/assets/icons/ui/discuss.svg +1 -0
- package/assets/icons/ui/email-open.svg +1 -0
- package/assets/icons/ui/key2.svg +1 -0
- package/assets/icons/ui/peoples.svg +1 -0
- package/assets/icons/ui/security.svg +1 -0
- package/package.json +11 -6
- package/react/Filename/Readme.md +10 -8
- package/react/Filename/index.jsx +56 -10
- package/react/Filename/styles.styl +3 -0
- package/react/Icon/Readme.md +13 -1
- package/react/Icons/Cloud2.jsx +29 -0
- package/react/Icons/Discuss.jsx +16 -0
- package/react/Icons/EmailOpen.jsx +55 -0
- package/react/Icons/Key2.jsx +23 -0
- package/react/Icons/Peoples.jsx +12 -0
- package/react/Icons/Security.jsx +12 -0
- package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +60 -0
- package/react/Table/Readme.md +80 -0
- package/react/Table/Virtualized/Cell.jsx +41 -0
- package/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer.jsx +45 -0
- package/react/Table/Virtualized/Dnd/CustomDrag/DragPreview.jsx +43 -0
- package/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper.jsx +52 -0
- package/react/Table/Virtualized/Dnd/DnDConfigWrapper.jsx +48 -0
- package/react/Table/Virtualized/Dnd/TableRow.jsx +86 -0
- package/react/Table/Virtualized/FixedHeaderContent.jsx +58 -0
- package/react/Table/Virtualized/HeadCell.jsx +45 -0
- package/react/Table/Virtualized/RowContent.jsx +35 -0
- package/react/Table/Virtualized/helpers.js +41 -0
- package/react/Table/Virtualized/helpers.spec.js +108 -0
- package/react/Table/Virtualized/index.jsx +104 -0
- package/react/Table/Virtualized/virtuosoComponents.jsx +61 -0
- package/react/TableRow/index.js +16 -1
- package/transpiled/react/Filename/index.d.ts +2 -1
- package/transpiled/react/Filename/index.js +49 -16
- package/transpiled/react/Icon/icons-sprite.d.ts +1 -1
- package/transpiled/react/Icon/icons-sprite.js +1 -1
- package/transpiled/react/Icons/Cloud2.d.ts +2 -0
- package/transpiled/react/Icons/Cloud2.js +26 -0
- package/transpiled/react/Icons/Discuss.d.ts +2 -0
- package/transpiled/react/Icons/Discuss.js +15 -0
- package/transpiled/react/Icons/EmailOpen.d.ts +2 -0
- package/transpiled/react/Icons/EmailOpen.js +53 -0
- package/transpiled/react/Icons/Key2.d.ts +2 -0
- package/transpiled/react/Icons/Key2.js +21 -0
- package/transpiled/react/Icons/Peoples.d.ts +2 -0
- package/transpiled/react/Icons/Peoples.js +13 -0
- package/transpiled/react/Icons/Security.d.ts +2 -0
- package/transpiled/react/Icons/Security.js +13 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +56 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +56 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +56 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +56 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +59 -0
- package/transpiled/react/Table/Virtualized/Cell.d.ts +8 -0
- package/transpiled/react/Table/Virtualized/Cell.js +46 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer.d.ts +4 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer.js +47 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreview.d.ts +6 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreview.js +34 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper.d.ts +8 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper.js +63 -0
- package/transpiled/react/Table/Virtualized/Dnd/DnDConfigWrapper.d.ts +2 -0
- package/transpiled/react/Table/Virtualized/Dnd/DnDConfigWrapper.js +55 -0
- package/transpiled/react/Table/Virtualized/Dnd/TableRow.d.ts +8 -0
- package/transpiled/react/Table/Virtualized/Dnd/TableRow.js +130 -0
- package/transpiled/react/Table/Virtualized/FixedHeaderContent.d.ts +10 -0
- package/transpiled/react/Table/Virtualized/FixedHeaderContent.js +54 -0
- package/transpiled/react/Table/Virtualized/HeadCell.d.ts +8 -0
- package/transpiled/react/Table/Virtualized/HeadCell.js +44 -0
- package/transpiled/react/Table/Virtualized/RowContent.d.ts +10 -0
- package/transpiled/react/Table/Virtualized/RowContent.js +34 -0
- package/transpiled/react/Table/Virtualized/helpers.d.ts +2 -0
- package/transpiled/react/Table/Virtualized/helpers.js +64 -0
- package/transpiled/react/Table/Virtualized/helpers.spec.d.ts +1 -0
- package/transpiled/react/Table/Virtualized/index.d.ts +2 -0
- package/transpiled/react/Table/Virtualized/index.js +115 -0
- package/transpiled/react/Table/Virtualized/virtuosoComponents.d.ts +10 -0
- package/transpiled/react/Table/Virtualized/virtuosoComponents.js +100 -0
- package/transpiled/react/TableRow/index.d.ts +2 -1
- package/transpiled/react/TableRow/index.js +20 -1
- package/transpiled/react/stylesheet.css +1 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React, { useState, forwardRef } from 'react'
|
|
2
|
+
import { TableVirtuoso } from 'react-virtuoso'
|
|
3
|
+
|
|
4
|
+
import CustomDragLayer from './Dnd/CustomDrag/CustomDragLayer'
|
|
5
|
+
import FixedHeaderContent from './FixedHeaderContent'
|
|
6
|
+
import RowContent from './RowContent'
|
|
7
|
+
import { stableSort, getComparator } from './helpers'
|
|
8
|
+
import virtuosoComponents from './virtuosoComponents'
|
|
9
|
+
|
|
10
|
+
const VirtualizedTable = forwardRef(
|
|
11
|
+
(
|
|
12
|
+
{
|
|
13
|
+
rows,
|
|
14
|
+
columns,
|
|
15
|
+
defaultOrder,
|
|
16
|
+
secondarySort,
|
|
17
|
+
selectedItems = [],
|
|
18
|
+
onSelect = () => {},
|
|
19
|
+
onSelectAll = () => {},
|
|
20
|
+
isSelectedItem = () => {},
|
|
21
|
+
componentsProps,
|
|
22
|
+
dragProps,
|
|
23
|
+
...props
|
|
24
|
+
},
|
|
25
|
+
ref
|
|
26
|
+
) => {
|
|
27
|
+
const [order, setOrder] = useState('asc')
|
|
28
|
+
const [orderBy, setOrderBy] = useState(defaultOrder)
|
|
29
|
+
const [itemsInDropProcess, setItemsInDropProcess] = useState([]) // array of Ids, for dragndrop feature
|
|
30
|
+
|
|
31
|
+
const sortedData = stableSort(rows, getComparator(order, orderBy))
|
|
32
|
+
const data = secondarySort ? secondarySort(sortedData) : sortedData
|
|
33
|
+
|
|
34
|
+
const handleSort = property => {
|
|
35
|
+
const isAsc = orderBy === property && order === 'asc'
|
|
36
|
+
setOrder(isAsc ? 'desc' : 'asc')
|
|
37
|
+
setOrderBy(property)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const handleSelectAll = event => {
|
|
41
|
+
if (event?.target?.checked) {
|
|
42
|
+
onSelectAll(rows)
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
onSelectAll([])
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<TableVirtuoso
|
|
50
|
+
{...props}
|
|
51
|
+
ref={ref}
|
|
52
|
+
data={data}
|
|
53
|
+
context={{
|
|
54
|
+
isSelectedItem,
|
|
55
|
+
selectedItems,
|
|
56
|
+
dragProps,
|
|
57
|
+
itemsInDropProcess,
|
|
58
|
+
setItemsInDropProcess
|
|
59
|
+
}}
|
|
60
|
+
components={virtuosoComponents}
|
|
61
|
+
fixedHeaderContent={() => (
|
|
62
|
+
<FixedHeaderContent
|
|
63
|
+
columns={columns}
|
|
64
|
+
rowCount={rows.length}
|
|
65
|
+
selectedCount={selectedItems.length}
|
|
66
|
+
order={order}
|
|
67
|
+
orderBy={orderBy}
|
|
68
|
+
onClick={handleSort}
|
|
69
|
+
onSelectAllClick={handleSelectAll}
|
|
70
|
+
/>
|
|
71
|
+
)}
|
|
72
|
+
itemContent={(_index, row) => (
|
|
73
|
+
<RowContent
|
|
74
|
+
index={_index}
|
|
75
|
+
row={row}
|
|
76
|
+
columns={columns}
|
|
77
|
+
isSelectedItem={isSelectedItem}
|
|
78
|
+
onSelectClick={onSelect}
|
|
79
|
+
>
|
|
80
|
+
{componentsProps?.rowContent?.children}
|
|
81
|
+
</RowContent>
|
|
82
|
+
)}
|
|
83
|
+
rowSpan={2}
|
|
84
|
+
/>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
VirtualizedTable.displayName = 'VirtualizedTable'
|
|
90
|
+
|
|
91
|
+
const VirtuosoTableWrapper = props => {
|
|
92
|
+
if (!props.dragProps?.enabled) {
|
|
93
|
+
return <VirtualizedTable {...props} />
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<>
|
|
98
|
+
<CustomDragLayer dragId={props.dragProps.dragId} />
|
|
99
|
+
<VirtualizedTable {...props} />
|
|
100
|
+
</>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default VirtuosoTableWrapper
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import DnDConfigWrapper from './Dnd/DnDConfigWrapper'
|
|
4
|
+
import TableRowDnD from './Dnd/TableRow'
|
|
5
|
+
import Table from '..'
|
|
6
|
+
import Paper from '../../Paper'
|
|
7
|
+
import TableBody from '../../TableBody'
|
|
8
|
+
import TableContainer from '../../TableContainer'
|
|
9
|
+
import TableFooter from '../../TableFooter'
|
|
10
|
+
import TableHead from '../../TableHead'
|
|
11
|
+
import TableRow from '../../TableRow'
|
|
12
|
+
|
|
13
|
+
const _TableContainer = forwardRef((props, ref) => (
|
|
14
|
+
<TableContainer
|
|
15
|
+
{...props}
|
|
16
|
+
ref={ref}
|
|
17
|
+
component={Paper}
|
|
18
|
+
style={{ zIndex: 'var(--zIndex-app)', ...props.style }}
|
|
19
|
+
elevation={0}
|
|
20
|
+
/>
|
|
21
|
+
))
|
|
22
|
+
_TableContainer.displayName = '_TableContainer'
|
|
23
|
+
|
|
24
|
+
const virtuosoComponents = {
|
|
25
|
+
Scroller: forwardRef(({ context, ...props }, ref) => {
|
|
26
|
+
if (!context.dragProps?.enabled) {
|
|
27
|
+
return <_TableContainer {...props} ref={ref} />
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<DnDConfigWrapper ref={ref}>
|
|
32
|
+
<_TableContainer {...props} ref={ref} />
|
|
33
|
+
</DnDConfigWrapper>
|
|
34
|
+
)
|
|
35
|
+
}),
|
|
36
|
+
Table: forwardRef((props, ref) => <Table {...props} ref={ref} />),
|
|
37
|
+
TableHead: forwardRef((props, ref) => <TableHead {...props} ref={ref} />),
|
|
38
|
+
TableBody: forwardRef((props, ref) => <TableBody {...props} ref={ref} />),
|
|
39
|
+
TableFooter: forwardRef((props, ref) => <TableFooter {...props} ref={ref} />),
|
|
40
|
+
TableRow: forwardRef(({ item, context, ...props }, ref) => {
|
|
41
|
+
const isSelected = context?.isSelectedItem(item)
|
|
42
|
+
const isDisabled = context?.itemsInDropProcess.includes(item._id)
|
|
43
|
+
|
|
44
|
+
if (!context.dragProps?.enabled) {
|
|
45
|
+
return <TableRow {...props} ref={ref} selected={isSelected} hover />
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<TableRowDnD
|
|
50
|
+
{...props}
|
|
51
|
+
item={item}
|
|
52
|
+
context={context}
|
|
53
|
+
selected={isSelected}
|
|
54
|
+
disabled={isDisabled}
|
|
55
|
+
hover
|
|
56
|
+
/>
|
|
57
|
+
)
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default virtuosoComponents
|
package/react/TableRow/index.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import MuiTableRow from '@material-ui/core/TableRow'
|
|
2
|
+
import cx from 'classnames'
|
|
3
|
+
import React, { forwardRef } from 'react'
|
|
4
|
+
|
|
5
|
+
const TableRow = forwardRef(({ disabled, className, ...props }, ref) => {
|
|
6
|
+
return (
|
|
7
|
+
<MuiTableRow
|
|
8
|
+
{...props}
|
|
9
|
+
className={cx(className, { disabled })}
|
|
10
|
+
disabled={disabled}
|
|
11
|
+
ref={ref}
|
|
12
|
+
/>
|
|
13
|
+
)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
TableRow.displayName = 'TableRow'
|
|
2
17
|
|
|
3
18
|
export default TableRow
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export default Filename;
|
|
2
|
-
declare function Filename({ icon, filename, extension, midEllipsis, variant }: {
|
|
2
|
+
declare function Filename({ icon, filename, extension, midEllipsis, variant, path }: {
|
|
3
3
|
icon: any;
|
|
4
4
|
filename: any;
|
|
5
5
|
extension: any;
|
|
6
6
|
midEllipsis: any;
|
|
7
7
|
variant: any;
|
|
8
|
+
path: any;
|
|
8
9
|
}): JSX.Element;
|
|
9
10
|
declare namespace Filename {
|
|
10
11
|
namespace propTypes {
|
|
@@ -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
|
-
|
|
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
|
|
8
|
-
var
|
|
9
|
-
filename = _ref.filename,
|
|
13
|
+
var NameAndExtension = function NameAndExtension(_ref) {
|
|
14
|
+
var filename = _ref.filename,
|
|
10
15
|
extension = _ref.extension,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return /*#__PURE__*/React.createElement(
|
|
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,
|