cozy-ui 123.2.1 → 124.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/package.json +11 -6
- package/react/Filename/Readme.md +10 -8
- package/react/Filename/index.jsx +56 -10
- package/react/Filename/styles.styl +3 -0
- package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +60 -0
- package/react/Table/Readme.md +80 -0
- package/react/Table/Virtualized/Cell.jsx +41 -0
- package/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer.jsx +45 -0
- package/react/Table/Virtualized/Dnd/CustomDrag/DragPreview.jsx +43 -0
- package/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper.jsx +52 -0
- package/react/Table/Virtualized/Dnd/DnDConfigWrapper.jsx +48 -0
- package/react/Table/Virtualized/Dnd/TableRow.jsx +86 -0
- package/react/Table/Virtualized/FixedHeaderContent.jsx +58 -0
- package/react/Table/Virtualized/HeadCell.jsx +45 -0
- package/react/Table/Virtualized/RowContent.jsx +35 -0
- package/react/Table/Virtualized/helpers.js +41 -0
- package/react/Table/Virtualized/helpers.spec.js +108 -0
- package/react/Table/Virtualized/index.jsx +104 -0
- package/react/Table/Virtualized/virtuosoComponents.jsx +61 -0
- package/react/TableRow/index.js +16 -1
- package/transpiled/react/Filename/index.d.ts +2 -1
- package/transpiled/react/Filename/index.js +49 -16
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +56 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +56 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +56 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +56 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +59 -0
- package/transpiled/react/Table/Virtualized/Cell.d.ts +8 -0
- package/transpiled/react/Table/Virtualized/Cell.js +46 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer.d.ts +4 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/CustomDragLayer.js +47 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreview.d.ts +6 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreview.js +34 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper.d.ts +8 -0
- package/transpiled/react/Table/Virtualized/Dnd/CustomDrag/DragPreviewWrapper.js +63 -0
- package/transpiled/react/Table/Virtualized/Dnd/DnDConfigWrapper.d.ts +2 -0
- package/transpiled/react/Table/Virtualized/Dnd/DnDConfigWrapper.js +55 -0
- package/transpiled/react/Table/Virtualized/Dnd/TableRow.d.ts +8 -0
- package/transpiled/react/Table/Virtualized/Dnd/TableRow.js +130 -0
- package/transpiled/react/Table/Virtualized/FixedHeaderContent.d.ts +10 -0
- package/transpiled/react/Table/Virtualized/FixedHeaderContent.js +54 -0
- package/transpiled/react/Table/Virtualized/HeadCell.d.ts +8 -0
- package/transpiled/react/Table/Virtualized/HeadCell.js +44 -0
- package/transpiled/react/Table/Virtualized/RowContent.d.ts +10 -0
- package/transpiled/react/Table/Virtualized/RowContent.js +34 -0
- package/transpiled/react/Table/Virtualized/helpers.d.ts +2 -0
- package/transpiled/react/Table/Virtualized/helpers.js +64 -0
- package/transpiled/react/Table/Virtualized/helpers.spec.d.ts +1 -0
- package/transpiled/react/Table/Virtualized/index.d.ts +2 -0
- package/transpiled/react/Table/Virtualized/index.js +115 -0
- package/transpiled/react/Table/Virtualized/virtuosoComponents.d.ts +10 -0
- package/transpiled/react/Table/Virtualized/virtuosoComponents.js +100 -0
- package/transpiled/react/TableRow/index.d.ts +2 -1
- package/transpiled/react/TableRow/index.js +20 -1
- package/transpiled/react/stylesheet.css +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import TableHeadCell from './HeadCell'
|
|
4
|
+
import Checkbox from '../../Checkbox'
|
|
5
|
+
import TableCell from '../../TableCell'
|
|
6
|
+
import TableRow from '../../TableRow'
|
|
7
|
+
import { makeStyles } from '../../styles'
|
|
8
|
+
|
|
9
|
+
const useStyles = makeStyles({
|
|
10
|
+
visuallyHidden: {
|
|
11
|
+
border: 0,
|
|
12
|
+
clip: 'rect(0 0 0 0)',
|
|
13
|
+
height: 1,
|
|
14
|
+
margin: -1,
|
|
15
|
+
overflow: 'hidden',
|
|
16
|
+
padding: 0,
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
top: 20,
|
|
19
|
+
width: 1
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const FixedHeaderContent = ({
|
|
24
|
+
columns,
|
|
25
|
+
order,
|
|
26
|
+
orderBy,
|
|
27
|
+
rowCount,
|
|
28
|
+
selectedCount,
|
|
29
|
+
onClick,
|
|
30
|
+
onSelectAllClick
|
|
31
|
+
}) => {
|
|
32
|
+
const classes = useStyles()
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<TableRow>
|
|
36
|
+
<TableCell align="center" padding="checkbox">
|
|
37
|
+
<Checkbox
|
|
38
|
+
indeterminate={selectedCount > 0 && selectedCount < rowCount}
|
|
39
|
+
checked={rowCount > 0 && selectedCount === rowCount}
|
|
40
|
+
inputProps={{ 'aria-label': 'select all' }}
|
|
41
|
+
onChange={onSelectAllClick}
|
|
42
|
+
/>
|
|
43
|
+
</TableCell>
|
|
44
|
+
{columns.map(column => (
|
|
45
|
+
<TableHeadCell
|
|
46
|
+
key={column.id}
|
|
47
|
+
className={classes.visuallyHidden}
|
|
48
|
+
column={column}
|
|
49
|
+
order={order}
|
|
50
|
+
orderBy={orderBy}
|
|
51
|
+
onClick={() => onClick(column.id)}
|
|
52
|
+
/>
|
|
53
|
+
))}
|
|
54
|
+
</TableRow>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default FixedHeaderContent
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import TableCell from '../../TableCell'
|
|
4
|
+
import TableSortLabel from '../../TableSortLabel'
|
|
5
|
+
import { makeStyles } from '../../styles'
|
|
6
|
+
|
|
7
|
+
const useStyles = makeStyles({
|
|
8
|
+
root: {
|
|
9
|
+
width: ({ column }) => column.width,
|
|
10
|
+
maxWidth: ({ column }) => column.maxWidth
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const TableHeadCell = ({ className, column, orderBy, order, onClick }) => {
|
|
15
|
+
const classes = useStyles({ column })
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<TableCell
|
|
19
|
+
key={column.id}
|
|
20
|
+
classes={classes}
|
|
21
|
+
align={column.textAlign ?? 'left'}
|
|
22
|
+
padding={column.disablePadding ? 'none' : 'normal'}
|
|
23
|
+
sortDirection={orderBy === column.id ? order : false}
|
|
24
|
+
>
|
|
25
|
+
{column.sortable !== false ? (
|
|
26
|
+
<TableSortLabel
|
|
27
|
+
active={orderBy === column.id}
|
|
28
|
+
direction={orderBy === column.id ? order : 'asc'}
|
|
29
|
+
onClick={onClick}
|
|
30
|
+
>
|
|
31
|
+
{column.label}
|
|
32
|
+
{orderBy === column.id && (
|
|
33
|
+
<span className={className}>
|
|
34
|
+
{order === 'desc' ? 'sorted descending' : 'sorted ascending'}
|
|
35
|
+
</span>
|
|
36
|
+
)}
|
|
37
|
+
</TableSortLabel>
|
|
38
|
+
) : (
|
|
39
|
+
column.label
|
|
40
|
+
)}
|
|
41
|
+
</TableCell>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default TableHeadCell
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import Cell from './Cell'
|
|
4
|
+
import Checkbox from '../../Checkbox'
|
|
5
|
+
import TableCell from '../../TableCell'
|
|
6
|
+
|
|
7
|
+
const RowContent = ({
|
|
8
|
+
index,
|
|
9
|
+
row,
|
|
10
|
+
columns,
|
|
11
|
+
isSelectedItem,
|
|
12
|
+
children,
|
|
13
|
+
onSelectClick
|
|
14
|
+
}) => {
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<TableCell align="center" padding="checkbox">
|
|
18
|
+
<Checkbox
|
|
19
|
+
checked={isSelectedItem(row)}
|
|
20
|
+
inputProps={{
|
|
21
|
+
'aria-labelledby': `enhanced-table-checkbox-${index}`
|
|
22
|
+
}}
|
|
23
|
+
onChange={() => onSelectClick(row)}
|
|
24
|
+
/>
|
|
25
|
+
</TableCell>
|
|
26
|
+
{columns.map(column => (
|
|
27
|
+
<Cell key={column.id} row={row} columns={columns} column={column}>
|
|
28
|
+
{children}
|
|
29
|
+
</Cell>
|
|
30
|
+
))}
|
|
31
|
+
</>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default React.memo(RowContent)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const descendingComparator = ({ a, b, order, orderBy, lang }) => {
|
|
2
|
+
const aValue = a[orderBy]
|
|
3
|
+
const bValue = b[orderBy]
|
|
4
|
+
|
|
5
|
+
if (typeof aValue === 'string') {
|
|
6
|
+
const isDate = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}/.test(aValue)
|
|
7
|
+
const isNumber = !isNaN(parseInt(aValue))
|
|
8
|
+
|
|
9
|
+
if (isDate) {
|
|
10
|
+
return new Date(bValue) - new Date(aValue)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (isNumber) {
|
|
14
|
+
return parseInt(bValue) - parseInt(aValue)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { compare } = Intl.Collator(lang || 'en', {
|
|
18
|
+
caseFirst: order === 'asc' ? 'upper' : 'lower'
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
return compare(bValue, aValue)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return bValue - aValue
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const getComparator = (order, orderBy, lang) => {
|
|
28
|
+
return order === 'desc'
|
|
29
|
+
? (a, b) => descendingComparator({ a, b, order, orderBy, lang })
|
|
30
|
+
: (a, b) => -descendingComparator({ a, b, order, orderBy, lang })
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const stableSort = (array, comparator) => {
|
|
34
|
+
const stabilizedThis = array.map((el, index) => [el, index])
|
|
35
|
+
stabilizedThis.sort((a, b) => {
|
|
36
|
+
const order = comparator(a[0], b[0])
|
|
37
|
+
if (order !== 0) return order
|
|
38
|
+
return a[1] - b[1]
|
|
39
|
+
})
|
|
40
|
+
return stabilizedThis.map(el => el[0])
|
|
41
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { stableSort, getComparator } from './helpers'
|
|
2
|
+
|
|
3
|
+
describe('stableSort', () => {
|
|
4
|
+
describe('it should sort string correctly even with number', () => {
|
|
5
|
+
const rows = [
|
|
6
|
+
{ name: 'b' },
|
|
7
|
+
{ name: 'A' },
|
|
8
|
+
{ name: 'B' },
|
|
9
|
+
{ name: 'a' },
|
|
10
|
+
{ name: '10' }
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
it('for asc', () => {
|
|
14
|
+
const sortedData = stableSort(rows, getComparator('asc', 'name', 'fr'))
|
|
15
|
+
|
|
16
|
+
const onlyValues = sortedData.map(el => el.name)
|
|
17
|
+
expect(onlyValues).toStrictEqual(['A', 'a', 'B', 'b', '10'])
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('for desc', () => {
|
|
21
|
+
const sortedData = stableSort(rows, getComparator('desc', 'name', 'fr'))
|
|
22
|
+
|
|
23
|
+
const onlyValues = sortedData.map(el => el.name)
|
|
24
|
+
expect(onlyValues).toStrictEqual(['B', 'b', 'A', 'a', '10'])
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
describe('it should sort number correctly', () => {
|
|
29
|
+
const rows = [
|
|
30
|
+
{ number: 40 },
|
|
31
|
+
{ number: 1 },
|
|
32
|
+
{ number: 8 },
|
|
33
|
+
{ number: 30 },
|
|
34
|
+
{ number: 40 }
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
it('for asc', () => {
|
|
38
|
+
const sortedData = stableSort(rows, getComparator('asc', 'number', 'fr'))
|
|
39
|
+
|
|
40
|
+
const onlyValues = sortedData.map(el => el.number)
|
|
41
|
+
expect(onlyValues).toStrictEqual([1, 8, 30, 40, 40])
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('for desc', () => {
|
|
45
|
+
const sortedData = stableSort(rows, getComparator('desc', 'number', 'fr'))
|
|
46
|
+
|
|
47
|
+
const onlyValues = sortedData.map(el => el.number)
|
|
48
|
+
expect(onlyValues).toStrictEqual([40, 40, 30, 8, 1])
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe('it should sort string-number correctly', () => {
|
|
53
|
+
const rows = [
|
|
54
|
+
{ number: '40' },
|
|
55
|
+
{ number: '1' },
|
|
56
|
+
{ number: '8' },
|
|
57
|
+
{ number: '30' },
|
|
58
|
+
{ number: '40' }
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
it('for asc', () => {
|
|
62
|
+
const sortedData = stableSort(rows, getComparator('asc', 'number', 'fr'))
|
|
63
|
+
|
|
64
|
+
const onlyValues = sortedData.map(el => el.number)
|
|
65
|
+
expect(onlyValues).toStrictEqual(['1', '8', '30', '40', '40'])
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('for desc', () => {
|
|
69
|
+
const sortedData = stableSort(rows, getComparator('desc', 'number', 'fr'))
|
|
70
|
+
|
|
71
|
+
const onlyValues = sortedData.map(el => el.number)
|
|
72
|
+
expect(onlyValues).toStrictEqual(['40', '40', '30', '8', '1'])
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
describe('it should sort date correctly', () => {
|
|
77
|
+
const rows = [
|
|
78
|
+
{ date: '2025-05-01T12:00:00.0000+01:00' },
|
|
79
|
+
{ date: '2025-08-01T12:00:00.0000+01:00' },
|
|
80
|
+
{ date: '2025-01-01T12:00:00.0000+01:00' },
|
|
81
|
+
{ date: '2025-04-01T12:00:00.0000+01:00' }
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
it('for asc', () => {
|
|
85
|
+
const sortedData = stableSort(rows, getComparator('asc', 'date', 'fr'))
|
|
86
|
+
|
|
87
|
+
const onlyValues = sortedData.map(el => el.date)
|
|
88
|
+
expect(onlyValues).toStrictEqual([
|
|
89
|
+
'2025-01-01T12:00:00.0000+01:00',
|
|
90
|
+
'2025-04-01T12:00:00.0000+01:00',
|
|
91
|
+
'2025-05-01T12:00:00.0000+01:00',
|
|
92
|
+
'2025-08-01T12:00:00.0000+01:00'
|
|
93
|
+
])
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it('for desc', () => {
|
|
97
|
+
const sortedData = stableSort(rows, getComparator('desc', 'date', 'fr'))
|
|
98
|
+
|
|
99
|
+
const onlyValues = sortedData.map(el => el.date)
|
|
100
|
+
expect(onlyValues).toStrictEqual([
|
|
101
|
+
'2025-08-01T12:00:00.0000+01:00',
|
|
102
|
+
'2025-05-01T12:00:00.0000+01:00',
|
|
103
|
+
'2025-04-01T12:00:00.0000+01:00',
|
|
104
|
+
'2025-01-01T12:00:00.0000+01:00'
|
|
105
|
+
])
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
@@ -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,
|
|
@@ -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;
|