cozy-ui 142.0.1 → 142.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 +15 -0
- package/package.json +1 -1
- package/react/Table/Readme.md +33 -27
- package/react/Table/Virtualized/Cell.jsx +7 -3
- package/react/Table/Virtualized/HeadCell.jsx +11 -2
- package/react/Table/Virtualized/index.jsx +9 -5
- package/react/Table/Virtualized/locales/en.json +6 -0
- package/react/Table/Virtualized/locales/fr.json +6 -0
- package/react/Table/Virtualized/locales/ru.json +6 -0
- package/react/Table/Virtualized/locales/vi.json +6 -0
- package/transpiled/react/Table/Virtualized/Cell.js +4 -3
- package/transpiled/react/Table/Virtualized/HeadCell.js +37 -1
- package/transpiled/react/Table/Virtualized/index.d.ts +1 -0
- package/transpiled/react/Table/Virtualized/index.js +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [142.1.0](https://github.com/cozy/cozy-ui/compare/v142.0.1...v142.1.0) (2026-09-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **Table:** Keep slow clicks on VirtualizedTable cells without a long press handler ([a283f77](https://github.com/cozy/cozy-ui/commit/a283f77))
|
|
7
|
+
* **Table:** Show a pointer only on clickable VirtualizedTable cells ([9953f49](https://github.com/cozy/cozy-ui/commit/9953f49))
|
|
8
|
+
* **Table:** Sort VirtualizedTable rows only when rows or order change ([b1be981](https://github.com/cozy/cozy-ui/commit/b1be981))
|
|
9
|
+
* **Table:** Translate the VirtualizedTable sort direction announcement ([2d67cd8](https://github.com/cozy/cozy-ui/commit/2d67cd8))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **Table:** Export VirtuosoMockContext to test VirtualizedTable ([ba3e8bd](https://github.com/cozy/cozy-ui/commit/ba3e8bd))
|
|
15
|
+
|
|
1
16
|
## [142.0.1](https://github.com/cozy/cozy-ui/compare/v142.0.0...v142.0.1) (2026-09-17)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
package/react/Table/Readme.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
```jsx
|
|
4
4
|
import { useState } from 'react'
|
|
5
5
|
import VirtualizedTable from 'cozy-ui/transpiled/react/Table/Virtualized'
|
|
6
|
+
import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
|
|
6
7
|
import Variants from 'cozy-ui/docs/components/Variants'
|
|
7
8
|
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
8
9
|
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
@@ -138,26 +139,28 @@ const SelectButton = () => {
|
|
|
138
139
|
|
|
139
140
|
;
|
|
140
141
|
|
|
141
|
-
<
|
|
142
|
-
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
<
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
142
|
+
<DemoProvider>
|
|
143
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
144
|
+
{variant => (
|
|
145
|
+
<>
|
|
146
|
+
<SelectionProvider>
|
|
147
|
+
<Typography className="u-mt-1" variant="h4">Not sorted table</Typography>
|
|
148
|
+
<SelectButton />
|
|
149
|
+
<div style={{ border: "1px solid var(--borderMainColor)", height: 400, width: "100%" }}>
|
|
150
|
+
<ExampleTable variant={variant} />
|
|
151
|
+
</div>
|
|
152
|
+
</SelectionProvider>
|
|
153
|
+
<SelectionProvider>
|
|
154
|
+
<Typography className="u-mt-1" variant="h4">Sorted table</Typography>
|
|
155
|
+
<SelectButton />
|
|
156
|
+
<div style={{ border: "1px solid var(--borderMainColor)", height: 400, width: "100%" }}>
|
|
157
|
+
<ExampleTable variant={variant} defaultOrder={{by: columns[0].id, direction: 'asc'}} />
|
|
158
|
+
</div>
|
|
159
|
+
</SelectionProvider>
|
|
160
|
+
</>
|
|
161
|
+
)}
|
|
162
|
+
</Variants>
|
|
163
|
+
</DemoProvider>
|
|
161
164
|
```
|
|
162
165
|
|
|
163
166
|
### With Drag'n'Drop
|
|
@@ -165,6 +168,7 @@ const SelectButton = () => {
|
|
|
165
168
|
```jsx
|
|
166
169
|
import { useState } from 'react'
|
|
167
170
|
import VirtualizedTableDnd from 'cozy-ui/transpiled/react/Table/Virtualized/Dnd'
|
|
171
|
+
import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
|
|
168
172
|
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
169
173
|
import SelectionProvider, { useSelection } from 'cozy-ui/transpiled/react/providers/Selection'
|
|
170
174
|
import { DndProvider } from 'react-dnd'
|
|
@@ -238,11 +242,13 @@ const DndExample = () => {
|
|
|
238
242
|
|
|
239
243
|
;
|
|
240
244
|
|
|
241
|
-
<
|
|
242
|
-
<
|
|
243
|
-
<
|
|
244
|
-
<
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
</
|
|
245
|
+
<DemoProvider>
|
|
246
|
+
<SelectionProvider>
|
|
247
|
+
<DndProvider backend={HTML5Backend}>
|
|
248
|
+
<div className="u-mt-half" style={{ border: "1px solid var(--borderMainColor)", height: 400, width: "100%" }}>
|
|
249
|
+
<DndExample />
|
|
250
|
+
</div>
|
|
251
|
+
</DndProvider>
|
|
252
|
+
</SelectionProvider>
|
|
253
|
+
</DemoProvider>
|
|
248
254
|
```
|
|
@@ -28,17 +28,21 @@ const Cell = ({
|
|
|
28
28
|
const [isLongPress, setIsLongPress] = useState(false) // onClick is triggered after a long press anyway, so we need this bool to avoid this behavior
|
|
29
29
|
const [lastClickTime, setLastClickTime] = useState(0)
|
|
30
30
|
|
|
31
|
-
const classes = useStyles({
|
|
31
|
+
const classes = useStyles({
|
|
32
|
+
column,
|
|
33
|
+
isClickable: !!onClick && !column.disableClick
|
|
34
|
+
})
|
|
32
35
|
const cellContent = get(row, column.id, '—')
|
|
33
36
|
|
|
34
37
|
const longPressRef = useOnLongPress(
|
|
35
38
|
() => {
|
|
36
|
-
|
|
39
|
+
// without a long press handler, a slow click must stay a click
|
|
40
|
+
if (column.disableClick || !onLongPress) {
|
|
37
41
|
return
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
setIsLongPress(true)
|
|
41
|
-
onLongPress
|
|
45
|
+
onLongPress(row, column)
|
|
42
46
|
},
|
|
43
47
|
{ duration: 300 }
|
|
44
48
|
)
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import { useI18n, useExtendI18n } from 'twake-i18n'
|
|
2
3
|
|
|
4
|
+
import en from './locales/en.json'
|
|
5
|
+
import fr from './locales/fr.json'
|
|
6
|
+
import ru from './locales/ru.json'
|
|
7
|
+
import vi from './locales/vi.json'
|
|
3
8
|
import TableCell from '../../TableCell'
|
|
4
9
|
import TableSortLabel from '../../TableSortLabel'
|
|
5
10
|
import { makeStyles } from '../../styles'
|
|
6
11
|
|
|
12
|
+
const locales = { en, fr, ru, vi }
|
|
13
|
+
|
|
7
14
|
const useStyles = makeStyles({
|
|
8
15
|
root: {
|
|
9
16
|
width: ({ column }) => column.width,
|
|
@@ -18,6 +25,8 @@ const TableHeadCell = ({
|
|
|
18
25
|
orderDirection,
|
|
19
26
|
onClick
|
|
20
27
|
}) => {
|
|
28
|
+
useExtendI18n(locales)
|
|
29
|
+
const { t } = useI18n()
|
|
21
30
|
const classes = useStyles({ column })
|
|
22
31
|
|
|
23
32
|
return (
|
|
@@ -39,8 +48,8 @@ const TableHeadCell = ({
|
|
|
39
48
|
{orderBy === column.id && (
|
|
40
49
|
<span className={className}>
|
|
41
50
|
{orderDirection === 'desc'
|
|
42
|
-
? '
|
|
43
|
-
: '
|
|
51
|
+
? t('VirtualizedTable.sortedDesc')
|
|
52
|
+
: t('VirtualizedTable.sortedAsc')}
|
|
44
53
|
</span>
|
|
45
54
|
)}
|
|
46
55
|
</TableSortLabel>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { useState, forwardRef } from 'react'
|
|
2
|
+
import React, { useMemo, useState, forwardRef } from 'react'
|
|
3
3
|
import { TableVirtuoso, GroupedTableVirtuoso } from 'react-virtuoso'
|
|
4
4
|
|
|
5
|
+
export { VirtuosoMockContext } from 'react-virtuoso'
|
|
6
|
+
|
|
5
7
|
import FixedHeaderContent from './FixedHeaderContent'
|
|
6
8
|
import RowContent from './RowContent'
|
|
7
9
|
import { stableSort, getComparator } from './helpers'
|
|
@@ -32,10 +34,12 @@ const VirtualizedTable = forwardRef(
|
|
|
32
34
|
)
|
|
33
35
|
const [orderBy, setOrderBy] = useState(defaultOrder?.by ?? undefined)
|
|
34
36
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const data = useMemo(() => {
|
|
38
|
+
const sortedData = orderBy
|
|
39
|
+
? stableSort(rows, getComparator(orderDirection, orderBy))
|
|
40
|
+
: rows
|
|
41
|
+
return secondarySort ? secondarySort(sortedData) : sortedData
|
|
42
|
+
}, [rows, orderBy, orderDirection, secondarySort])
|
|
39
43
|
const { groupLabels, groupCounts } = groups?.(data) || {}
|
|
40
44
|
const isGroupedTable = !!groupCounts
|
|
41
45
|
const _context = {
|
|
@@ -47,16 +47,17 @@ var Cell = function Cell(_ref4) {
|
|
|
47
47
|
|
|
48
48
|
var classes = useStyles({
|
|
49
49
|
column: column,
|
|
50
|
-
isClickable: !!onClick
|
|
50
|
+
isClickable: !!onClick && !column.disableClick
|
|
51
51
|
});
|
|
52
52
|
var cellContent = get(row, column.id, '—');
|
|
53
53
|
var longPressRef = useOnLongPress(function () {
|
|
54
|
-
|
|
54
|
+
// without a long press handler, a slow click must stay a click
|
|
55
|
+
if (column.disableClick || !onLongPress) {
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
setIsLongPress(true);
|
|
59
|
-
onLongPress
|
|
60
|
+
onLongPress(row, column);
|
|
60
61
|
}, {
|
|
61
62
|
duration: 300
|
|
62
63
|
});
|
|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useI18n, useExtendI18n } from 'twake-i18n';
|
|
3
|
+
var en = {
|
|
4
|
+
VirtualizedTable: {
|
|
5
|
+
sortedAsc: "sorted ascending",
|
|
6
|
+
sortedDesc: "sorted descending"
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
var fr = {
|
|
10
|
+
VirtualizedTable: {
|
|
11
|
+
sortedAsc: "tri croissant",
|
|
12
|
+
sortedDesc: "tri d\xE9croissant"
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var ru = {
|
|
16
|
+
VirtualizedTable: {
|
|
17
|
+
sortedAsc: "\u043E\u0442\u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043E \u043F\u043E \u0432\u043E\u0437\u0440\u0430\u0441\u0442\u0430\u043D\u0438\u044E",
|
|
18
|
+
sortedDesc: "\u043E\u0442\u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043E \u043F\u043E \u0443\u0431\u044B\u0432\u0430\u043D\u0438\u044E"
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var vi = {
|
|
22
|
+
VirtualizedTable: {
|
|
23
|
+
sortedAsc: "s\u1EAFp x\u1EBFp t\u0103ng d\u1EA7n",
|
|
24
|
+
sortedDesc: "s\u1EAFp x\u1EBFp gi\u1EA3m d\u1EA7n"
|
|
25
|
+
}
|
|
26
|
+
};
|
|
2
27
|
import TableCell from "cozy-ui/transpiled/react/TableCell";
|
|
3
28
|
import TableSortLabel from "cozy-ui/transpiled/react/TableSortLabel";
|
|
4
29
|
import { makeStyles } from "cozy-ui/transpiled/react/styles";
|
|
30
|
+
var locales = {
|
|
31
|
+
en: en,
|
|
32
|
+
fr: fr,
|
|
33
|
+
ru: ru,
|
|
34
|
+
vi: vi
|
|
35
|
+
};
|
|
5
36
|
var useStyles = makeStyles({
|
|
6
37
|
root: {
|
|
7
38
|
width: function width(_ref) {
|
|
@@ -23,6 +54,11 @@ var TableHeadCell = function TableHeadCell(_ref3) {
|
|
|
23
54
|
orderBy = _ref3.orderBy,
|
|
24
55
|
orderDirection = _ref3.orderDirection,
|
|
25
56
|
onClick = _ref3.onClick;
|
|
57
|
+
useExtendI18n(locales);
|
|
58
|
+
|
|
59
|
+
var _useI18n = useI18n(),
|
|
60
|
+
t = _useI18n.t;
|
|
61
|
+
|
|
26
62
|
var classes = useStyles({
|
|
27
63
|
column: column
|
|
28
64
|
});
|
|
@@ -39,7 +75,7 @@ var TableHeadCell = function TableHeadCell(_ref3) {
|
|
|
39
75
|
onClick: onClick
|
|
40
76
|
}, column.label, orderBy === column.id && /*#__PURE__*/React.createElement("span", {
|
|
41
77
|
className: className
|
|
42
|
-
}, orderDirection === 'desc' ? '
|
|
78
|
+
}, orderDirection === 'desc' ? t('VirtualizedTable.sortedDesc') : t('VirtualizedTable.sortedAsc'))) : column.label);
|
|
43
79
|
};
|
|
44
80
|
|
|
45
81
|
export default TableHeadCell;
|
|
@@ -9,8 +9,9 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
9
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
10
|
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
|
-
import React, { useState, forwardRef } from 'react';
|
|
12
|
+
import React, { useMemo, useState, forwardRef } from 'react';
|
|
13
13
|
import { TableVirtuoso, GroupedTableVirtuoso } from 'react-virtuoso';
|
|
14
|
+
export { VirtuosoMockContext } from 'react-virtuoso';
|
|
14
15
|
import FixedHeaderContent from "cozy-ui/transpiled/react/Table/Virtualized/FixedHeaderContent";
|
|
15
16
|
import RowContent from "cozy-ui/transpiled/react/Table/Virtualized/RowContent";
|
|
16
17
|
import { stableSort, getComparator } from "cozy-ui/transpiled/react/Table/Virtualized/helpers";
|
|
@@ -43,8 +44,10 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
43
44
|
orderBy = _useState4[0],
|
|
44
45
|
setOrderBy = _useState4[1];
|
|
45
46
|
|
|
46
|
-
var
|
|
47
|
-
|
|
47
|
+
var data = useMemo(function () {
|
|
48
|
+
var sortedData = orderBy ? stableSort(rows, getComparator(orderDirection, orderBy)) : rows;
|
|
49
|
+
return secondarySort ? secondarySort(sortedData) : sortedData;
|
|
50
|
+
}, [rows, orderBy, orderDirection, secondarySort]);
|
|
48
51
|
|
|
49
52
|
var _ref2 = (groups === null || groups === void 0 ? void 0 : groups(data)) || {},
|
|
50
53
|
groupLabels = _ref2.groupLabels,
|