cozy-ui 127.7.0 → 127.9.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 +20 -0
- package/package.json +1 -1
- package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +8 -0
- package/react/SearchBar/index.jsx +1 -1
- package/react/Table/Readme.md +29 -18
- package/react/Table/Virtualized/Cell.jsx +8 -0
- package/react/Table/Virtualized/TableRow.jsx +2 -1
- package/react/Table/Virtualized/index.jsx +30 -7
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +1 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +1 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +1 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +1 -0
- package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +7 -0
- package/transpiled/react/SearchBar/index.js +1 -1
- package/transpiled/react/Table/Virtualized/Cell.js +8 -0
- package/transpiled/react/Table/Virtualized/TableRow.js +3 -1
- package/transpiled/react/Table/Virtualized/index.js +38 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# [127.9.0](https://github.com/cozy/cozy-ui/compare/v127.8.0...v127.9.0) (2025-07-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **VirtualizedTable:** Add `disableClick` prop on column config ([6c68c01](https://github.com/cozy/cozy-ui/commit/6c68c01))
|
|
7
|
+
|
|
8
|
+
# [127.8.0](https://github.com/cozy/cozy-ui/compare/v127.7.0...v127.8.0) (2025-07-30)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **SearchBar:** Adjust flex behavior ([34f78b2](https://github.com/cozy/cozy-ui/commit/34f78b2))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **TableCell:** Set css for `sizeSmall` ([17ff031](https://github.com/cozy/cozy-ui/commit/17ff031))
|
|
19
|
+
* **VirtualizedTable:** Add `groups` props to be able to group data ([dac73e0](https://github.com/cozy/cozy-ui/commit/dac73e0))
|
|
20
|
+
|
|
1
21
|
# [127.7.0](https://github.com/cozy/cozy-ui/compare/v127.6.0...v127.7.0) (2025-07-29)
|
|
2
22
|
|
|
3
23
|
|
package/package.json
CHANGED
|
@@ -571,6 +571,14 @@ export const makeLightNormalOverrides = theme => ({
|
|
|
571
571
|
color: theme.palette.text.secondary,
|
|
572
572
|
height: '2rem'
|
|
573
573
|
},
|
|
574
|
+
sizeSmall: {
|
|
575
|
+
...theme.typography.subtitle2,
|
|
576
|
+
paddingBottom: 0,
|
|
577
|
+
paddingTop: 0,
|
|
578
|
+
outline: `1px solid ${theme.palette.background.default}`,
|
|
579
|
+
borderBottom: 'none',
|
|
580
|
+
backgroundColor: theme.palette.background.default
|
|
581
|
+
},
|
|
574
582
|
paddingCheckbox: {
|
|
575
583
|
width: 32,
|
|
576
584
|
padding: 0
|
package/react/Table/Readme.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
```jsx
|
|
4
4
|
import VirtualizedTable from 'cozy-ui/transpiled/react/Table/Virtualized'
|
|
5
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
5
6
|
|
|
6
7
|
const createData = (id, name, calories, fat, carbs, protein) => {
|
|
7
8
|
return { id, name, calories, fat, carbs, protein }
|
|
@@ -64,7 +65,8 @@ const columns = [
|
|
|
64
65
|
disablePadding: false,
|
|
65
66
|
width: 115,
|
|
66
67
|
label: 'Protein (g)',
|
|
67
|
-
textAlign: 'right'
|
|
68
|
+
textAlign: 'right',
|
|
69
|
+
disableClick: true
|
|
68
70
|
}
|
|
69
71
|
]
|
|
70
72
|
|
|
@@ -97,23 +99,32 @@ const onSelectAll = rows => {
|
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
|
|
102
|
+
const initialVariants = [{ grouped: false }]
|
|
103
|
+
|
|
104
|
+
const makeGroups = () => ({ groupLabels: ['C', 'D', 'Others'], groupCounts: [1,1,12] })
|
|
105
|
+
|
|
100
106
|
;
|
|
101
107
|
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
109
|
+
{variant => (
|
|
110
|
+
<div style={{ border: "1px solid var(--borderMainColor)", height: 400, width: "100%" }}>
|
|
111
|
+
<VirtualizedTable
|
|
112
|
+
rows={rows}
|
|
113
|
+
columns={columns}
|
|
114
|
+
groups={variant.grouped ? makeGroups : undefined}
|
|
115
|
+
defaultOrder={columns[0].id}
|
|
116
|
+
selectedItems={state.selectedItemsId}
|
|
117
|
+
isSelectedItem={row => isSelectedItem(row)}
|
|
118
|
+
onSelect={onSelect}
|
|
119
|
+
onSelectAll={onSelectAll}
|
|
120
|
+
componentsProps={{
|
|
121
|
+
rowContent: {
|
|
122
|
+
onClick: (row, column) => { console.info(`click on cell. Row ${row['id']}, Column ${column['id']}`) },
|
|
123
|
+
onLongPress: (row, column) => { console.info(`long press on cell. Row ${row['id']}, Column ${column['id']}`) },
|
|
124
|
+
},
|
|
125
|
+
}}
|
|
126
|
+
/>
|
|
127
|
+
</div>
|
|
128
|
+
)}
|
|
129
|
+
</Variants>
|
|
119
130
|
```
|
|
@@ -20,11 +20,19 @@ const Cell = ({ row, columns, column, onClick, onLongPress, children }) => {
|
|
|
20
20
|
const cellContent = get(row, column.id, '—')
|
|
21
21
|
|
|
22
22
|
const longPressRef = useOnLongPress(() => {
|
|
23
|
+
if (column.disableClick) {
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
setIsLongPress(true)
|
|
24
28
|
onLongPress?.(row, column)
|
|
25
29
|
})
|
|
26
30
|
|
|
27
31
|
const handleClick = () => {
|
|
32
|
+
if (column.disableClick) {
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
28
36
|
if (!isLongPress) {
|
|
29
37
|
onClick?.(row, column)
|
|
30
38
|
} else {
|
|
@@ -4,7 +4,8 @@ import React from 'react'
|
|
|
4
4
|
import TableRowClassic from '../../TableRow'
|
|
5
5
|
|
|
6
6
|
const TableRow = ({ item, context, className, ...props }) => {
|
|
7
|
-
const
|
|
7
|
+
const _item = item || context.data[props['data-item-index']]
|
|
8
|
+
const isSelected = context.isSelectedItem(_item)
|
|
8
9
|
|
|
9
10
|
return (
|
|
10
11
|
<TableRowClassic
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
1
2
|
import React, { useState, forwardRef } from 'react'
|
|
2
|
-
import { TableVirtuoso } from 'react-virtuoso'
|
|
3
|
+
import { TableVirtuoso, GroupedTableVirtuoso } from 'react-virtuoso'
|
|
3
4
|
|
|
4
5
|
import FixedHeaderContent from './FixedHeaderContent'
|
|
5
6
|
import RowContent from './RowContent'
|
|
6
7
|
import { stableSort, getComparator } from './helpers'
|
|
7
8
|
import virtuosoComponents from './virtuosoComponents'
|
|
9
|
+
import TableCell from '../../TableCell'
|
|
8
10
|
|
|
9
11
|
const VirtualizedTable = forwardRef(
|
|
10
12
|
(
|
|
11
13
|
{
|
|
12
14
|
rows,
|
|
13
15
|
columns,
|
|
16
|
+
groups,
|
|
14
17
|
defaultOrder,
|
|
15
18
|
secondarySort,
|
|
16
19
|
selectedItems,
|
|
@@ -29,8 +32,11 @@ const VirtualizedTable = forwardRef(
|
|
|
29
32
|
|
|
30
33
|
const sortedData = stableSort(rows, getComparator(order, orderBy))
|
|
31
34
|
const data = secondarySort ? secondarySort(sortedData) : sortedData
|
|
35
|
+
const { groupLabels, groupCounts } = groups?.(data) || {}
|
|
36
|
+
const isGroupedTable = !!groupCounts
|
|
32
37
|
const _context = {
|
|
33
38
|
...context,
|
|
39
|
+
...(isGroupedTable && { data }), // we use directly `data` prop if no groupCounts
|
|
34
40
|
isSelectedItem,
|
|
35
41
|
selectedItems
|
|
36
42
|
}
|
|
@@ -49,11 +55,14 @@ const VirtualizedTable = forwardRef(
|
|
|
49
55
|
onSelectAll([])
|
|
50
56
|
}
|
|
51
57
|
|
|
58
|
+
const Component = isGroupedTable ? GroupedTableVirtuoso : TableVirtuoso
|
|
59
|
+
|
|
52
60
|
return (
|
|
53
|
-
<
|
|
61
|
+
<Component
|
|
54
62
|
{...props}
|
|
55
63
|
ref={ref}
|
|
56
|
-
data={data}
|
|
64
|
+
data={!isGroupedTable ? data : undefined}
|
|
65
|
+
groupCounts={isGroupedTable ? groupCounts : []}
|
|
57
66
|
context={_context}
|
|
58
67
|
components={components || virtuosoComponents}
|
|
59
68
|
fixedHeaderContent={() => (
|
|
@@ -68,13 +77,20 @@ const VirtualizedTable = forwardRef(
|
|
|
68
77
|
onSelectAllClick={handleSelectAll}
|
|
69
78
|
/>
|
|
70
79
|
)}
|
|
71
|
-
|
|
80
|
+
{...(isGroupedTable && {
|
|
81
|
+
groupContent: index => (
|
|
82
|
+
<TableCell colSpan={columns.length + 1} size="small">
|
|
83
|
+
{groupLabels[index]}
|
|
84
|
+
</TableCell>
|
|
85
|
+
)
|
|
86
|
+
})}
|
|
87
|
+
itemContent={index => (
|
|
72
88
|
<RowContent
|
|
73
89
|
{...componentsProps?.rowContent}
|
|
74
|
-
index={
|
|
75
|
-
row={
|
|
90
|
+
index={index}
|
|
91
|
+
row={data[index]}
|
|
76
92
|
columns={columns}
|
|
77
|
-
context={
|
|
93
|
+
context={_context}
|
|
78
94
|
onSelectClick={onSelect}
|
|
79
95
|
>
|
|
80
96
|
{componentsProps?.rowContent?.children}
|
|
@@ -95,4 +111,11 @@ VirtualizedTable.defaultProps = {
|
|
|
95
111
|
onSelectAll: () => {}
|
|
96
112
|
}
|
|
97
113
|
|
|
114
|
+
VirtualizedTable.propTypes = {
|
|
115
|
+
/**
|
|
116
|
+
Returned object is: PropTypes.shape({ groupLabels: PropTypes.array, groupCounts: PropTypes.array })
|
|
117
|
+
*/
|
|
118
|
+
groups: PropTypes.func
|
|
119
|
+
}
|
|
120
|
+
|
|
98
121
|
export default VirtualizedTable
|
|
@@ -543,6 +543,13 @@ export var makeLightNormalOverrides = function makeLightNormalOverrides(theme) {
|
|
|
543
543
|
color: theme.palette.text.secondary,
|
|
544
544
|
height: '2rem'
|
|
545
545
|
},
|
|
546
|
+
sizeSmall: _objectSpread(_objectSpread({}, theme.typography.subtitle2), {}, {
|
|
547
|
+
paddingBottom: 0,
|
|
548
|
+
paddingTop: 0,
|
|
549
|
+
outline: "1px solid ".concat(theme.palette.background.default),
|
|
550
|
+
borderBottom: 'none',
|
|
551
|
+
backgroundColor: theme.palette.background.default
|
|
552
|
+
}),
|
|
546
553
|
paddingCheckbox: {
|
|
547
554
|
width: 32,
|
|
548
555
|
padding: 0
|
|
@@ -43,11 +43,19 @@ var Cell = function Cell(_ref4) {
|
|
|
43
43
|
});
|
|
44
44
|
var cellContent = get(row, column.id, '—');
|
|
45
45
|
var longPressRef = useOnLongPress(function () {
|
|
46
|
+
if (column.disableClick) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
46
50
|
setIsLongPress(true);
|
|
47
51
|
onLongPress === null || onLongPress === void 0 ? void 0 : onLongPress(row, column);
|
|
48
52
|
});
|
|
49
53
|
|
|
50
54
|
var handleClick = function handleClick() {
|
|
55
|
+
if (column.disableClick) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
51
59
|
if (!isLongPress) {
|
|
52
60
|
onClick === null || onClick === void 0 ? void 0 : onClick(row, column);
|
|
53
61
|
} else {
|
|
@@ -11,7 +11,9 @@ var TableRow = function TableRow(_ref) {
|
|
|
11
11
|
className = _ref.className,
|
|
12
12
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _item = item || context.data[props['data-item-index']];
|
|
15
|
+
|
|
16
|
+
var isSelected = context.isSelectedItem(_item);
|
|
15
17
|
return /*#__PURE__*/React.createElement(TableRowClassic, _extends({}, props, {
|
|
16
18
|
className: cx(className, 'virtualized'),
|
|
17
19
|
selected: isSelected,
|
|
@@ -2,21 +2,24 @@ 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", "context", "components"];
|
|
5
|
+
var _excluded = ["rows", "columns", "groups", "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
|
|
|
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
|
+
import PropTypes from 'prop-types';
|
|
11
12
|
import React, { useState, forwardRef } from 'react';
|
|
12
|
-
import { TableVirtuoso } from 'react-virtuoso';
|
|
13
|
+
import { TableVirtuoso, GroupedTableVirtuoso } from 'react-virtuoso';
|
|
13
14
|
import FixedHeaderContent from "cozy-ui/transpiled/react/Table/Virtualized/FixedHeaderContent";
|
|
14
15
|
import RowContent from "cozy-ui/transpiled/react/Table/Virtualized/RowContent";
|
|
15
16
|
import { stableSort, getComparator } from "cozy-ui/transpiled/react/Table/Virtualized/helpers";
|
|
16
17
|
import virtuosoComponents from "cozy-ui/transpiled/react/Table/Virtualized/virtuosoComponents";
|
|
18
|
+
import TableCell from "cozy-ui/transpiled/react/TableCell";
|
|
17
19
|
var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
18
20
|
var rows = _ref.rows,
|
|
19
21
|
columns = _ref.columns,
|
|
22
|
+
groups = _ref.groups,
|
|
20
23
|
defaultOrder = _ref.defaultOrder,
|
|
21
24
|
secondarySort = _ref.secondarySort,
|
|
22
25
|
selectedItems = _ref.selectedItems,
|
|
@@ -41,7 +44,16 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
41
44
|
var sortedData = stableSort(rows, getComparator(order, orderBy));
|
|
42
45
|
var data = secondarySort ? secondarySort(sortedData) : sortedData;
|
|
43
46
|
|
|
44
|
-
var
|
|
47
|
+
var _ref2 = (groups === null || groups === void 0 ? void 0 : groups(data)) || {},
|
|
48
|
+
groupLabels = _ref2.groupLabels,
|
|
49
|
+
groupCounts = _ref2.groupCounts;
|
|
50
|
+
|
|
51
|
+
var isGroupedTable = !!groupCounts;
|
|
52
|
+
|
|
53
|
+
var _context = _objectSpread(_objectSpread(_objectSpread({}, context), isGroupedTable && {
|
|
54
|
+
data: data
|
|
55
|
+
}), {}, {
|
|
56
|
+
// we use directly `data` prop if no groupCounts
|
|
45
57
|
isSelectedItem: isSelectedItem,
|
|
46
58
|
selectedItems: selectedItems
|
|
47
59
|
});
|
|
@@ -63,9 +75,11 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
63
75
|
onSelectAll([]);
|
|
64
76
|
};
|
|
65
77
|
|
|
66
|
-
|
|
78
|
+
var Component = isGroupedTable ? GroupedTableVirtuoso : TableVirtuoso;
|
|
79
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
67
80
|
ref: ref,
|
|
68
|
-
data: data,
|
|
81
|
+
data: !isGroupedTable ? data : undefined,
|
|
82
|
+
groupCounts: isGroupedTable ? groupCounts : [],
|
|
69
83
|
context: _context,
|
|
70
84
|
components: components || virtuosoComponents,
|
|
71
85
|
fixedHeaderContent: function fixedHeaderContent() {
|
|
@@ -78,15 +92,23 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
78
92
|
onClick: handleSort,
|
|
79
93
|
onSelectAllClick: handleSelectAll
|
|
80
94
|
}));
|
|
81
|
-
}
|
|
82
|
-
|
|
95
|
+
}
|
|
96
|
+
}, isGroupedTable && {
|
|
97
|
+
groupContent: function groupContent(index) {
|
|
98
|
+
return /*#__PURE__*/React.createElement(TableCell, {
|
|
99
|
+
colSpan: columns.length + 1,
|
|
100
|
+
size: "small"
|
|
101
|
+
}, groupLabels[index]);
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
itemContent: function itemContent(index) {
|
|
83
105
|
var _componentsProps$rowC;
|
|
84
106
|
|
|
85
107
|
return /*#__PURE__*/React.createElement(RowContent, _extends({}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.rowContent, {
|
|
86
|
-
index:
|
|
87
|
-
row:
|
|
108
|
+
index: index,
|
|
109
|
+
row: data[index],
|
|
88
110
|
columns: columns,
|
|
89
|
-
context:
|
|
111
|
+
context: _context,
|
|
90
112
|
onSelectClick: onSelect
|
|
91
113
|
}), componentsProps === null || componentsProps === void 0 ? void 0 : (_componentsProps$rowC = componentsProps.rowContent) === null || _componentsProps$rowC === void 0 ? void 0 : _componentsProps$rowC.children);
|
|
92
114
|
},
|
|
@@ -100,4 +122,10 @@ VirtualizedTable.defaultProps = {
|
|
|
100
122
|
onSelect: function onSelect() {},
|
|
101
123
|
onSelectAll: function onSelectAll() {}
|
|
102
124
|
};
|
|
125
|
+
VirtualizedTable.propTypes = {
|
|
126
|
+
/**
|
|
127
|
+
Returned object is: PropTypes.shape({ groupLabels: PropTypes.array, groupCounts: PropTypes.array })
|
|
128
|
+
*/
|
|
129
|
+
groups: PropTypes.func
|
|
130
|
+
};
|
|
103
131
|
export default VirtualizedTable;
|