cozy-ui 135.6.0 → 135.7.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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [135.7.0](https://github.com/cozy/cozy-ui/compare/v135.6.0...v135.7.0) (2026-02-02)
2
+
3
+
4
+ ### Features
5
+
6
+ * Allow to hide checkboxes in VirtualizedTable ([fa375d7](https://github.com/cozy/cozy-ui/commit/fa375d7))
7
+
1
8
  # [135.6.0](https://github.com/cozy/cozy-ui/compare/v135.5.0...v135.6.0) (2026-01-27)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "135.6.0",
3
+ "version": "135.7.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -73,7 +73,7 @@ const columns = [
73
73
  }
74
74
  ]
75
75
 
76
- const initialVariants = [{ grouped: false }]
76
+ const initialVariants = [{ grouped: false, withCheckbox: true }, { grouped: false, withCheckbox: false }]
77
77
 
78
78
  // Very basic usage only works when Dessert is sorted "asc"
79
79
  // Ideally you have to create a logic to create groups with sorted data
@@ -98,6 +98,7 @@ const ExampleTable = ({ variant, ...props }) => {
98
98
  onSelect={(row, event, index) => toggleSelectedItem(row.id)}
99
99
  onSelectAll={rows => toggleSelectAllItems(rows.map(item => item.id))}
100
100
  onSortChange={onSortChange}
101
+ withCheckbox={variant.withCheckbox}
101
102
  componentsProps={{
102
103
  rowContent: {
103
104
  onClick: (row, column) => { console.info(`click on cell. Row ${row['id']}, Column ${column['id']}`) },
@@ -35,18 +35,20 @@ const FixedHeaderContent = ({
35
35
 
36
36
  return (
37
37
  <TableRow>
38
- <TableCell align="center" padding="checkbox">
39
- <Checkbox
40
- className={cx('virtualizedCheckbox', {
41
- checked: selectedCount > 0
42
- })}
43
- indeterminate={selectedCount > 0 && selectedCount < rowCount}
44
- checked={rowCount > 0 && selectedCount === rowCount}
45
- inputProps={{ 'aria-label': 'select all' }}
46
- size="small"
47
- onChange={onSelectAllClick}
48
- />
49
- </TableCell>
38
+ {context.withCheckbox && (
39
+ <TableCell align="center" padding="checkbox">
40
+ <Checkbox
41
+ className={cx('virtualizedCheckbox', {
42
+ checked: selectedCount > 0
43
+ })}
44
+ indeterminate={selectedCount > 0 && selectedCount < rowCount}
45
+ checked={rowCount > 0 && selectedCount === rowCount}
46
+ inputProps={{ 'aria-label': 'select all' }}
47
+ size="small"
48
+ onChange={onSelectAllClick}
49
+ />
50
+ </TableCell>
51
+ )}
50
52
  {columns.map(column => (
51
53
  <TableHeadCell
52
54
  key={column.id}
@@ -19,20 +19,22 @@ const RowContent = ({
19
19
 
20
20
  return (
21
21
  <>
22
- <TableCell align="center" padding="checkbox">
23
- <Checkbox
24
- className={cx('virtualizedCheckbox', {
25
- visible: selectedCount > 0,
26
- checked: context.isSelectedItem(row)
27
- })}
28
- checked={context.isSelectedItem(row)}
29
- inputProps={{
30
- 'aria-labelledby': `enhanced-table-checkbox-${index}`
31
- }}
32
- size="small"
33
- onClick={event => onSelectClick(row, event, index)}
34
- />
35
- </TableCell>
22
+ {context.withCheckbox && (
23
+ <TableCell align="center" padding="checkbox">
24
+ <Checkbox
25
+ className={cx('virtualizedCheckbox', {
26
+ visible: selectedCount > 0,
27
+ checked: context.isSelectedItem(row)
28
+ })}
29
+ checked={context.isSelectedItem(row)}
30
+ inputProps={{
31
+ 'aria-labelledby': `enhanced-table-checkbox-${index}`
32
+ }}
33
+ size="small"
34
+ onClick={event => onSelectClick(row, event, index)}
35
+ />
36
+ </TableCell>
37
+ )}
36
38
  {columns.map(column => (
37
39
  <Cell
38
40
  key={column.id}
@@ -7,12 +7,20 @@ const TableRow = ({ item, context, className, ...props }) => {
7
7
  const _item = item || context.data[props['data-item-index']]
8
8
  const isSelected = context.isSelectedItem(_item)
9
9
 
10
+ const handleClick = () => {
11
+ if (!context.withCheckbox && _item) {
12
+ const index = props['data-item-index']
13
+ context.onSelect?.(_item, null, index)
14
+ }
15
+ }
16
+
10
17
  return (
11
18
  <TableRowClassic
12
19
  {...props}
13
20
  className={cx(className, 'virtualized')}
14
21
  selected={isSelected}
15
22
  hover
23
+ onClick={!context.withCheckbox ? handleClick : props.onClick}
16
24
  />
17
25
  )
18
26
  }
@@ -25,6 +25,7 @@ const VirtualizedTable = forwardRef(
25
25
  components,
26
26
  onSortChange,
27
27
  isNewItem,
28
+ withCheckbox,
28
29
  ...props
29
30
  },
30
31
  ref
@@ -45,7 +46,9 @@ const VirtualizedTable = forwardRef(
45
46
  ...(isGroupedTable && { data }), // we use directly `data` prop if no groupCounts
46
47
  isSelectedItem,
47
48
  selectedItems,
48
- isNewItem
49
+ isNewItem,
50
+ withCheckbox,
51
+ onSelect
49
52
  }
50
53
 
51
54
  const handleSort = property => {
@@ -117,7 +120,8 @@ VirtualizedTable.defaultProps = {
117
120
  selectedItems: [],
118
121
  isSelectedItem: () => {},
119
122
  onSelect: () => {},
120
- onSelectAll: () => {}
123
+ onSelectAll: () => {},
124
+ withCheckbox: true
121
125
  }
122
126
 
123
127
  VirtualizedTable.propTypes = {
@@ -145,7 +149,9 @@ VirtualizedTable.propTypes = {
145
149
  /** Callback called after the sort */
146
150
  onSortChange: PropTypes.func,
147
151
  /** Function to determine if a row is new */
148
- isNewItem: PropTypes.func
152
+ isNewItem: PropTypes.func,
153
+ /** Whether to show checkboxes. When false, rows become clickable for selection */
154
+ withCheckbox: PropTypes.bool
149
155
  }
150
156
 
151
157
  export default VirtualizedTable
@@ -29,7 +29,7 @@ var FixedHeaderContent = function FixedHeaderContent(_ref) {
29
29
  onSelectAllClick = _ref.onSelectAllClick;
30
30
  var classes = useStyles();
31
31
  var selectedCount = context.selectedItems.length;
32
- return /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
32
+ return /*#__PURE__*/React.createElement(TableRow, null, context.withCheckbox && /*#__PURE__*/React.createElement(TableCell, {
33
33
  align: "center",
34
34
  padding: "checkbox"
35
35
  }, /*#__PURE__*/React.createElement(Checkbox, {
@@ -14,7 +14,7 @@ var RowContent = function RowContent(_ref) {
14
14
  onLongPress = _ref.onLongPress,
15
15
  onClick = _ref.onClick;
16
16
  var selectedCount = context.selectedItems.length;
17
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableCell, {
17
+ return /*#__PURE__*/React.createElement(React.Fragment, null, context.withCheckbox && /*#__PURE__*/React.createElement(TableCell, {
18
18
  align: "center",
19
19
  padding: "checkbox"
20
20
  }, /*#__PURE__*/React.createElement(Checkbox, {
@@ -14,10 +14,21 @@ var TableRow = function TableRow(_ref) {
14
14
  var _item = item || context.data[props['data-item-index']];
15
15
 
16
16
  var isSelected = context.isSelectedItem(_item);
17
+
18
+ var handleClick = function handleClick() {
19
+ if (!context.withCheckbox && _item) {
20
+ var _context$onSelect;
21
+
22
+ var index = props['data-item-index'];
23
+ (_context$onSelect = context.onSelect) === null || _context$onSelect === void 0 ? void 0 : _context$onSelect.call(context, _item, null, index);
24
+ }
25
+ };
26
+
17
27
  return /*#__PURE__*/React.createElement(TableRowClassic, _extends({}, props, {
18
28
  className: cx(className, 'virtualized'),
19
29
  selected: isSelected,
20
- hover: true
30
+ hover: true,
31
+ onClick: !context.withCheckbox ? handleClick : props.onClick
21
32
  }));
22
33
  };
23
34
 
@@ -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", "groups", "defaultOrder", "secondarySort", "selectedItems", "onSelect", "onSelectAll", "isSelectedItem", "componentsProps", "context", "components", "onSortChange", "isNewItem"];
5
+ var _excluded = ["rows", "columns", "groups", "defaultOrder", "secondarySort", "selectedItems", "onSelect", "onSelectAll", "isSelectedItem", "componentsProps", "context", "components", "onSortChange", "isNewItem", "withCheckbox"];
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
 
@@ -33,6 +33,7 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
33
33
  components = _ref.components,
34
34
  onSortChange = _ref.onSortChange,
35
35
  isNewItem = _ref.isNewItem,
36
+ withCheckbox = _ref.withCheckbox,
36
37
  props = _objectWithoutProperties(_ref, _excluded);
37
38
 
38
39
  var _useState = useState((_defaultOrder$directi = defaultOrder === null || defaultOrder === void 0 ? void 0 : defaultOrder.direction) !== null && _defaultOrder$directi !== void 0 ? _defaultOrder$directi : 'asc'),
@@ -60,7 +61,9 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
60
61
  // we use directly `data` prop if no groupCounts
61
62
  isSelectedItem: isSelectedItem,
62
63
  selectedItems: selectedItems,
63
- isNewItem: isNewItem
64
+ isNewItem: isNewItem,
65
+ withCheckbox: withCheckbox,
66
+ onSelect: onSelect
64
67
  });
65
68
 
66
69
  var handleSort = function handleSort(property) {
@@ -130,7 +133,8 @@ VirtualizedTable.defaultProps = {
130
133
  selectedItems: [],
131
134
  isSelectedItem: function isSelectedItem() {},
132
135
  onSelect: function onSelect() {},
133
- onSelectAll: function onSelectAll() {}
136
+ onSelectAll: function onSelectAll() {},
137
+ withCheckbox: true
134
138
  };
135
139
  VirtualizedTable.propTypes = {
136
140
  /** Rows to display in the table */
@@ -167,6 +171,9 @@ VirtualizedTable.propTypes = {
167
171
  onSortChange: PropTypes.func,
168
172
 
169
173
  /** Function to determine if a row is new */
170
- isNewItem: PropTypes.func
174
+ isNewItem: PropTypes.func,
175
+
176
+ /** Whether to show checkboxes. When false, rows become clickable for selection */
177
+ withCheckbox: PropTypes.bool
171
178
  };
172
179
  export default VirtualizedTable;