cozy-ui 138.13.1 → 139.0.1

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,23 @@
1
+ ## [139.0.1](https://github.com/cozy/cozy-ui/compare/v139.0.0...v139.0.1) (2026-06-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **Table:** Disable double click when `disableClick` is true in column config ([6da0985](https://github.com/cozy/cozy-ui/commit/6da0985))
7
+
8
+ # [139.0.0](https://github.com/cozy/cozy-ui/compare/v138.13.1...v139.0.0) (2026-06-01)
9
+
10
+
11
+ ### Features
12
+
13
+ * **Table:** Add `onDoubleClick` prop ([5fb38ec](https://github.com/cozy/cozy-ui/commit/5fb38ec))
14
+ * **Table:** Remove checkboxes ([2f9761c](https://github.com/cozy/cozy-ui/commit/2f9761c))
15
+
16
+
17
+ ### BREAKING CHANGES
18
+
19
+ * **Table:** Props `onSelect`, `onSelectAll` and `withCheckbox` have been removed from Virtualized Tables (`import Table from 'cozy-ui/transpiled/react/Table/Virtualized'`. You must put the `onSelectAll` in something else outside of the Table, and `onSelect` func in `componentsProps.rowContent.onClick` prop.
20
+
1
21
  ## [138.13.1](https://github.com/cozy/cozy-ui/compare/v138.13.0...v138.13.1) (2026-05-28)
2
22
 
3
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "138.13.1",
3
+ "version": "139.0.1",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -4,6 +4,8 @@
4
4
  import { useState } from 'react'
5
5
  import VirtualizedTable from 'cozy-ui/transpiled/react/Table/Virtualized'
6
6
  import Variants from 'cozy-ui/docs/components/Variants'
7
+ import Button from 'cozy-ui/transpiled/react/Buttons'
8
+ import Stack from 'cozy-ui/transpiled/react/Stack'
7
9
  import Typography from 'cozy-ui/transpiled/react/Typography'
8
10
  import SelectionProvider, { useSelection } from 'cozy-ui/transpiled/react/providers/Selection'
9
11
 
@@ -13,7 +15,7 @@ const createData = (id, name, calories, fat, carbs, protein) => {
13
15
 
14
16
  const rows = [
15
17
  createData(0, 'Cupcake', 305, 3.7, 67, 4.3),
16
- createData(1, 'Frozen yoghurt', 159, 6.0, 24, 4.0),
18
+ createData(1, 'Frozen yoghurt (unselectable)', 159, 6.0, 24, 4.0),
17
19
  createData(2, 'Donut', 452, 25.0, 51, 4.9),
18
20
  createData(3, 'Eclair', 262, 16.0, 24, 6.0),
19
21
  createData(4, 'Ice cream sandwich', 237, 9.0, 37, 4.3),
@@ -38,7 +40,7 @@ const rows = [
38
40
  const columns = [
39
41
  {
40
42
  id: 'name',
41
- disablePadding: true,
43
+ disablePadding: false,
42
44
  label: 'Dessert'
43
45
  },
44
46
  {
@@ -73,7 +75,7 @@ const columns = [
73
75
  }
74
76
  ]
75
77
 
76
- const initialVariants = [{ grouped: false, withCheckbox: true }, { grouped: false, withCheckbox: false }]
78
+ const initialVariants = [{ grouped: false}]
77
79
 
78
80
  // Very basic usage only works when Dessert is sorted "asc"
79
81
  // Ideally you have to create a logic to create groups with sorted data
@@ -87,31 +89,43 @@ const ExampleTable = ({ variant, ...props }) => {
87
89
  }
88
90
 
89
91
  return (
90
- <div style={{ border: "1px solid var(--borderMainColor)", height: 400, width: "100%" }}>
91
- <VirtualizedTable
92
- {...props}
93
- rows={rows}
94
- columns={columns}
95
- groups={variant.grouped ? makeGroups : undefined}
96
- selectedItems={selectedItemsId}
97
- isSelectedItem={row => isSelectedItem(row.id)}
98
- onSelect={(row, event, index) => toggleSelectedItem(row.id)}
99
- onSelectAll={rows => toggleSelectAllItems(rows.map(item => item.id !== 1 ? item.id : undefined))}
100
- onSortChange={onSortChange}
101
- withCheckbox={variant.withCheckbox}
102
- componentsProps={{
103
- rowContent: {
104
- disableCheckbox: row => row.id === 1,
105
- onClick: (row, column) => {
106
- if (!variant.withCheckbox) {
107
- return toggleSelectedItem(row.id)
108
- }
109
- console.info(`click on cell. Row ${row['id']}, Column ${column['id']}`)
110
- },
111
- onLongPress: (row, column) => { console.info(`long press on cell. Row ${row['id']}, Column ${column['id']}`) },
112
- },
113
- }}
92
+ <div>
93
+ <Button
94
+ className="u-mt-1 u-mb-1"
95
+ variant="ghost"
96
+ label="Select all"
97
+ onClick={() => toggleSelectAllItems(rows.map(item => item.id !== 1 ? item.id : undefined))}
114
98
  />
99
+ <div style={{ border: "1px solid var(--borderMainColor)", height: 400, width: "100%" }}>
100
+ <VirtualizedTable
101
+ {...props}
102
+ rows={rows}
103
+ columns={columns}
104
+ groups={variant.grouped ? makeGroups : undefined}
105
+ selectedItems={selectedItemsId}
106
+ isSelectedItem={row => isSelectedItem(row.id)}
107
+ onSortChange={onSortChange}
108
+ componentsProps={{
109
+ rowContent: {
110
+ onClick: (row, column) => {
111
+ row.id !== 1
112
+ ? toggleSelectedItem(row.id)
113
+ : undefined
114
+ },
115
+ onDoubleClick: (row, column) => {
116
+ row.id !== 1
117
+ ? console.info(`double click on cell. Row ${row['id']}, Column ${column['id']}`)
118
+ : undefined
119
+ },
120
+ onLongPress: (row, column) => {
121
+ row.id !== 1
122
+ ? console.info(`long press on cell. Row ${row['id']}, Column ${column['id']}`)
123
+ : undefined
124
+ }
125
+ }
126
+ }}
127
+ />
128
+ </div>
115
129
  </div>
116
130
  )
117
131
  }
@@ -120,7 +134,7 @@ const ExampleTable = ({ variant, ...props }) => {
120
134
  {variant => (
121
135
  <>
122
136
  <Typography variant="h4">Not sorted table</Typography>
123
- <div className="u-mt-half" style={{ border: "1px solid var(--borderMainColor)", height: 400, width: "100%" }}>
137
+ <div className="u-mt-half" style={{ border: "1px solid var(--borderMainColor)", height: 400, width: "100%", marginBottom: "6rem" }}>
124
138
  <SelectionProvider>
125
139
  <ExampleTable variant={variant} />
126
140
  </SelectionProvider>
@@ -135,3 +149,86 @@ const ExampleTable = ({ variant, ...props }) => {
135
149
  )}
136
150
  </Variants>
137
151
  ```
152
+
153
+ ### With Drag'n'Drop
154
+
155
+ ```jsx
156
+ import { useState } from 'react'
157
+ import VirtualizedTableDnd from 'cozy-ui/transpiled/react/Table/Virtualized/Dnd'
158
+ import Typography from 'cozy-ui/transpiled/react/Typography'
159
+ import SelectionProvider, { useSelection } from 'cozy-ui/transpiled/react/providers/Selection'
160
+ import { DndProvider } from 'react-dnd'
161
+ import { HTML5Backend } from 'react-dnd-html5-backend'
162
+
163
+ const createData = (_id, name, calories, fat, carbs, protein) => {
164
+ return { _id, name, calories, fat, carbs, protein }
165
+ }
166
+
167
+ const rows = [
168
+ createData(0, 'Cupcake', 305, 3.7, 67, 4.3),
169
+ createData(1, 'Frozen yoghurt', 159, 6.0, 24, 4.0),
170
+ createData(2, 'Donut', 452, 25.0, 51, 4.9),
171
+ createData(3, 'Eclair', 262, 16.0, 24, 6.0),
172
+ createData(4, 'Ice cream sandwich', 237, 9.0, 37, 4.3),
173
+ createData(5, 'Gingerbread', 356, 16.0, 49, 3.9),
174
+ createData(6, 'Honeycomb', 408, 3.2, 87, 6.5),
175
+ createData(7, 'Jelly Bean', 375, 0.0, 94, 0.0),
176
+ createData(8, 'KitKat', 518, 26.0, 65, 7.0),
177
+ createData(9, 'Oreo', 437, 18.0, 63, 4.0),
178
+ ]
179
+
180
+ const columns = [
181
+ { id: 'name', disablePadding: false, label: 'Dessert' },
182
+ { id: 'calories', disablePadding: false, width: 80, label: 'Calories', textAlign: 'left' },
183
+ { id: 'fat', disablePadding: false, width: 85, label: 'Fat (g)', textAlign: 'right' },
184
+ { id: 'carbs', disablePadding: false, width: 115, label: 'Carbs (g)', textAlign: 'right' },
185
+ { id: 'protein', disablePadding: false, width: 115, label: 'Protein (g)', textAlign: 'right', disableClick: true }
186
+ ]
187
+
188
+ const DndExample = () => {
189
+ const { selectedItemsId, isSelectedItem, toggleSelectedItem } = useSelection()
190
+
191
+ const dragProps = {
192
+ dragId: 'dessert-dnd',
193
+ onDrop: async (draggedItems, targetItem, selectedItems) => {
194
+ console.info('Dropped items:', draggedItems)
195
+ console.info('Target item:', targetItem)
196
+ },
197
+ canDrag: (item) => item.calories > 100,
198
+ canDrop: (item) => item.fat < 20,
199
+ }
200
+
201
+ return (
202
+ <div style={{ border: "1px solid var(--borderMainColor)", height: 400, width: "100%" }}>
203
+ <VirtualizedTableDnd
204
+ rows={rows}
205
+ columns={columns}
206
+ dragProps={dragProps}
207
+ selectedItems={selectedItemsId}
208
+ isSelectedItem={row => isSelectedItem(row._id)}
209
+ componentsProps={{
210
+ rowContent: {
211
+ onClick: (row, column) => toggleSelectedItem(row._id),
212
+ onDoubleClick: (row, column) => {
213
+ console.info(`double click on cell. Row ${row['_id']}, Column ${column['id']}`)
214
+ },
215
+ onLongPress: (row, column) => { console.info(`long press on cell. Row ${row['_id']}, Column ${column['id']}`) },
216
+ },
217
+ }}
218
+ />
219
+ </div>
220
+ )
221
+ }
222
+
223
+ ;
224
+
225
+ <>
226
+ <div className="u-mt-half" style={{ border: "1px solid var(--borderMainColor)", height: 400, width: "100%" }}>
227
+ <SelectionProvider>
228
+ <DndProvider backend={HTML5Backend}>
229
+ <DndExample />
230
+ </DndProvider>
231
+ </SelectionProvider>
232
+ </div>
233
+ </>
234
+ ```
@@ -4,6 +4,9 @@ import { useOnLongPress } from 'rooks'
4
4
 
5
5
  import TableCell from '../../TableCell'
6
6
  import { makeStyles } from '../../styles'
7
+ import { AddPropsToChildren } from '../../utils/react'
8
+
9
+ const DOUBLECLICKDELAY = 400
7
10
 
8
11
  const useStyles = makeStyles({
9
12
  root: {
@@ -13,30 +16,49 @@ const useStyles = makeStyles({
13
16
  }
14
17
  })
15
18
 
16
- const Cell = ({ row, columns, column, onClick, onLongPress, children }) => {
19
+ const Cell = ({
20
+ row,
21
+ columns,
22
+ column,
23
+ onClick,
24
+ onDoubleClick,
25
+ onLongPress,
26
+ children
27
+ }) => {
17
28
  const [isLongPress, setIsLongPress] = useState(false) // onClick is triggered after a long press anyway, so we need this bool to avoid this behavior
29
+ const [lastClickTime, setLastClickTime] = useState(0)
18
30
 
19
31
  const classes = useStyles({ column, isClickable: !!onClick })
20
32
  const cellContent = get(row, column.id, '—')
21
33
 
22
- const longPressRef = useOnLongPress(() => {
23
- if (column.disableClick) {
24
- return
25
- }
34
+ const longPressRef = useOnLongPress(
35
+ () => {
36
+ if (column.disableClick) {
37
+ return
38
+ }
26
39
 
27
- setIsLongPress(true)
28
- onLongPress?.(row, column)
29
- })
40
+ setIsLongPress(true)
41
+ onLongPress?.(row, column)
42
+ },
43
+ { duration: 300 }
44
+ )
30
45
 
31
46
  const handleClick = () => {
32
47
  if (column.disableClick) {
33
48
  return
34
49
  }
35
50
 
36
- if (!isLongPress) {
37
- onClick?.(row, column)
38
- } else {
51
+ if (isLongPress) {
39
52
  setIsLongPress(false)
53
+ return
54
+ }
55
+
56
+ const currentTime = Date.now()
57
+ const isDoubleClick = currentTime - lastClickTime < DOUBLECLICKDELAY
58
+ setLastClickTime(currentTime)
59
+
60
+ if (!isDoubleClick) {
61
+ onClick?.(row, column)
40
62
  }
41
63
  }
42
64
 
@@ -48,19 +70,18 @@ const Cell = ({ row, columns, column, onClick, onLongPress, children }) => {
48
70
  align={column.textAlign ?? 'left'}
49
71
  padding={column.disablePadding ? 'none' : 'normal'}
50
72
  onClick={handleClick}
73
+ onDoubleClick={() =>
74
+ column.disableClick ? undefined : onDoubleClick?.(row, column)
75
+ }
51
76
  onContextMenu={isLongPress ? ev => ev.preventDefault() : undefined}
52
77
  >
53
78
  {children
54
- ? React.Children.map(children, child =>
55
- React.isValidElement(child)
56
- ? React.cloneElement(child, {
57
- row,
58
- columns,
59
- column,
60
- cell: cellContent
61
- })
62
- : null
63
- )
79
+ ? AddPropsToChildren(children, () => ({
80
+ row,
81
+ columns,
82
+ column,
83
+ cell: cellContent
84
+ }))
64
85
  : cellContent}
65
86
  </TableCell>
66
87
  )
@@ -1,9 +1,6 @@
1
- import cx from 'classnames'
2
1
  import React from 'react'
3
2
 
4
3
  import TableHeadCell from './HeadCell'
5
- import Checkbox from '../../Checkbox'
6
- import TableCell from '../../TableCell'
7
4
  import TableRow from '../../TableRow'
8
5
  import { makeStyles } from '../../styles'
9
6
 
@@ -21,34 +18,11 @@ const useStyles = makeStyles({
21
18
  }
22
19
  })
23
20
 
24
- const FixedHeaderContent = ({
25
- columns,
26
- orderDirection,
27
- orderBy,
28
- rowCount,
29
- context,
30
- onClick,
31
- onSelectAllClick
32
- }) => {
21
+ const FixedHeaderContent = ({ columns, orderDirection, orderBy, onClick }) => {
33
22
  const classes = useStyles()
34
- const selectedCount = context.selectedItems.length
35
23
 
36
24
  return (
37
25
  <TableRow>
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
- )}
52
26
  {columns.map(column => (
53
27
  <TableHeadCell
54
28
  key={column.id}
@@ -1,42 +1,17 @@
1
- import cx from 'classnames'
2
1
  import React from 'react'
3
2
 
4
3
  import Cell from './Cell'
5
- import Checkbox from '../../Checkbox'
6
- import TableCell from '../../TableCell'
7
4
 
8
5
  const RowContent = ({
9
- index,
10
6
  row,
11
7
  columns,
12
- context,
13
8
  children,
14
- disableCheckbox,
15
- onSelectClick,
16
9
  onLongPress,
10
+ onDoubleClick,
17
11
  onClick
18
12
  }) => {
19
- const selectedCount = context.selectedItems.length
20
-
21
13
  return (
22
14
  <>
23
- {context.withCheckbox && (
24
- <TableCell align="center" padding="checkbox">
25
- <Checkbox
26
- className={cx('virtualizedCheckbox', {
27
- visible: selectedCount > 0,
28
- checked: context.isSelectedItem(row)
29
- })}
30
- disabled={disableCheckbox?.(row)}
31
- checked={context.isSelectedItem(row)}
32
- inputProps={{
33
- 'aria-labelledby': `enhanced-table-checkbox-${index}`
34
- }}
35
- size="small"
36
- onClick={event => onSelectClick(row, event, index)}
37
- />
38
- </TableCell>
39
- )}
40
15
  {columns.map(column => (
41
16
  <Cell
42
17
  key={column.id}
@@ -44,6 +19,7 @@ const RowContent = ({
44
19
  columns={columns}
45
20
  column={column}
46
21
  onClick={onClick}
22
+ onDoubleClick={onDoubleClick}
47
23
  onLongPress={onLongPress}
48
24
  >
49
25
  {children}
@@ -17,15 +17,12 @@ const VirtualizedTable = forwardRef(
17
17
  defaultOrder,
18
18
  secondarySort,
19
19
  selectedItems,
20
- onSelect,
21
- onSelectAll,
22
20
  isSelectedItem,
23
21
  componentsProps,
24
22
  context,
25
23
  components,
26
24
  onSortChange,
27
25
  isNewItem,
28
- withCheckbox,
29
26
  ...props
30
27
  },
31
28
  ref
@@ -46,9 +43,7 @@ const VirtualizedTable = forwardRef(
46
43
  ...(isGroupedTable && { data }), // we use directly `data` prop if no groupCounts
47
44
  isSelectedItem,
48
45
  selectedItems,
49
- isNewItem,
50
- withCheckbox,
51
- onSelect
46
+ isNewItem
52
47
  }
53
48
 
54
49
  const handleSort = property => {
@@ -59,14 +54,6 @@ const VirtualizedTable = forwardRef(
59
54
  onSortChange?.({ order: newOrder, orderBy: property })
60
55
  }
61
56
 
62
- const handleSelectAll = event => {
63
- if (event?.target?.checked) {
64
- onSelectAll(rows)
65
- return
66
- }
67
- onSelectAll([])
68
- }
69
-
70
57
  const Component = isGroupedTable ? GroupedTableVirtuoso : TableVirtuoso
71
58
 
72
59
  return (
@@ -86,7 +73,6 @@ const VirtualizedTable = forwardRef(
86
73
  orderDirection={orderDirection}
87
74
  orderBy={orderBy}
88
75
  onClick={handleSort}
89
- onSelectAllClick={handleSelectAll}
90
76
  />
91
77
  )}
92
78
  {...(isGroupedTable && {
@@ -103,7 +89,6 @@ const VirtualizedTable = forwardRef(
103
89
  row={data[index]}
104
90
  columns={columns}
105
91
  context={_context}
106
- onSelectClick={onSelect}
107
92
  >
108
93
  {componentsProps?.rowContent?.children}
109
94
  </RowContent>
@@ -118,10 +103,7 @@ VirtualizedTable.displayName = 'VirtualizedTable'
118
103
 
119
104
  VirtualizedTable.defaultProps = {
120
105
  selectedItems: [],
121
- isSelectedItem: () => {},
122
- onSelect: () => {},
123
- onSelectAll: () => {},
124
- withCheckbox: true
106
+ isSelectedItem: () => {}
125
107
  }
126
108
 
127
109
  VirtualizedTable.propTypes = {
@@ -146,18 +128,12 @@ VirtualizedTable.propTypes = {
146
128
  secondarySort: PropTypes.func,
147
129
  /** Array of selected items */
148
130
  selectedItems: PropTypes.array,
149
- /** Callback function when a row is selected */
150
- onSelect: PropTypes.func,
151
- /** Callback function when all rows are selected/deselected */
152
- onSelectAll: PropTypes.func,
153
131
  /** Function to determine if a row is selected */
154
132
  isSelectedItem: PropTypes.func,
155
133
  /** Callback called after the sort */
156
134
  onSortChange: PropTypes.func,
157
135
  /** Function to determine if a row is new */
158
- isNewItem: PropTypes.func,
159
- /** Whether to show checkboxes. When false, rows become clickable for selection */
160
- withCheckbox: PropTypes.bool
136
+ isNewItem: PropTypes.func
161
137
  }
162
138
 
163
139
  export default VirtualizedTable
@@ -24,7 +24,7 @@ import 'cozy-ui/transpiled/react/stylesheet.css'
24
24
 
25
25
  ## What This Skill Provides
26
26
 
27
- - 88+ React components with examples and extracted props.
27
+ - 89+ React components with examples and extracted props.
28
28
  - CSS utility classes for spacing, typography, colors, layout, and component-specific classes.
29
29
  - Cozy theming conventions built on Material-UI v4.
30
30
  - Import patterns for `cozy-ui/transpiled/react` and `cozy-ui/dist`.
@@ -18,7 +18,7 @@ Generated reference for React components available in cozy-ui. Use this file to
18
18
  - **Utils**: [DropdownText](#dropdowntext), [MuiCozyTheme](#muicozytheme)
19
19
  - **Hooks & Providers**: [Breakpoints (providers/Breakpoints)](#breakpoints-providers-breakpoints), [ConfirmDialog (providers/ConfirmDialog)](#confirmdialog-providers-confirmdialog), [CozyTheme (providers/CozyTheme)](#cozytheme-providers-cozytheme), [Selection (providers/Selection)](#selection-providers-selection), [useConfirmExit (hooks/useConfirmExit)](#useconfirmexit-hooks-useconfirmexit)
20
20
  - **Labs**: [IconGrid (Labs/IconGrid)](#icongrid-labs-icongrid), [Labs](#labs), [PasswordInput (Labs/PasswordInput)](#passwordinput-labs-passwordinput)
21
- - **Other**: [providers](#providers)
21
+ - **Other**: [BottomSheet](#bottomsheet), [providers](#providers)
22
22
 
23
23
  ## Buttons
24
24
 
@@ -789,6 +789,7 @@ import ProgressionBanner from 'cozy-ui/transpiled/react/ProgressionBanner'
789
789
  | `icon` | React.node | - | Icon to be shown in the banner |
790
790
  | `button` | React.node | - | Button to use in the banner |
791
791
  | `progressBar` | boolean | `true` | Progression bar is hidden if set to false (defaults to true) |
792
+ | `color` | string | `'var(--contrastBackgroundColor)'` | Background color of the banner, css color |
792
793
 
793
794
 
794
795
  ### Skeletons
@@ -1843,6 +1844,15 @@ import PasswordInput from 'cozy-ui/transpiled/react/Labs/PasswordInput'
1843
1844
 
1844
1845
  ## Other
1845
1846
 
1847
+ ### BottomSheet
1848
+
1849
+ Display content coming up from the bottom of the screen. The pane can be swiped to the top of the screen. Based on cozy / mui-bottom-sheet: API documentation is here. It uses Portal to have the same behavior as Dialogs / Modals (can be disabled with the disablePortal prop).
1850
+
1851
+ ```jsx
1852
+ import BottomSheet from 'cozy-ui/transpiled/react/BottomSheet'
1853
+ ```
1854
+
1855
+
1846
1856
  ### providers
1847
1857
 
1848
1858
  ```jsx
@@ -1,8 +1,9 @@
1
- declare var _default: React.MemoExoticComponent<({ row, columns, column, onClick, onLongPress, children }: {
1
+ declare var _default: React.MemoExoticComponent<({ row, columns, column, onClick, onDoubleClick, onLongPress, children }: {
2
2
  row: any;
3
3
  columns: any;
4
4
  column: any;
5
5
  onClick: any;
6
+ onDoubleClick: any;
6
7
  onLongPress: any;
7
8
  children: any;
8
9
  }) => JSX.Element>;
@@ -4,6 +4,8 @@ import React, { useState } from 'react';
4
4
  import { useOnLongPress } from 'rooks';
5
5
  import TableCell from "cozy-ui/transpiled/react/TableCell";
6
6
  import { makeStyles } from "cozy-ui/transpiled/react/styles";
7
+ import { AddPropsToChildren } from "cozy-ui/transpiled/react/utils/react";
8
+ var DOUBLECLICKDELAY = 400;
7
9
  var useStyles = makeStyles({
8
10
  root: {
9
11
  cursor: function cursor(_ref) {
@@ -28,6 +30,7 @@ var Cell = function Cell(_ref4) {
28
30
  columns = _ref4.columns,
29
31
  column = _ref4.column,
30
32
  onClick = _ref4.onClick,
33
+ _onDoubleClick = _ref4.onDoubleClick,
31
34
  onLongPress = _ref4.onLongPress,
32
35
  children = _ref4.children;
33
36
 
@@ -37,6 +40,11 @@ var Cell = function Cell(_ref4) {
37
40
  setIsLongPress = _useState2[1]; // onClick is triggered after a long press anyway, so we need this bool to avoid this behavior
38
41
 
39
42
 
43
+ var _useState3 = useState(0),
44
+ _useState4 = _slicedToArray(_useState3, 2),
45
+ lastClickTime = _useState4[0],
46
+ setLastClickTime = _useState4[1];
47
+
40
48
  var classes = useStyles({
41
49
  column: column,
42
50
  isClickable: !!onClick
@@ -49,6 +57,8 @@ var Cell = function Cell(_ref4) {
49
57
 
50
58
  setIsLongPress(true);
51
59
  onLongPress === null || onLongPress === void 0 ? void 0 : onLongPress(row, column);
60
+ }, {
61
+ duration: 300
52
62
  });
53
63
 
54
64
  var handleClick = function handleClick() {
@@ -56,10 +66,17 @@ var Cell = function Cell(_ref4) {
56
66
  return;
57
67
  }
58
68
 
59
- if (!isLongPress) {
60
- onClick === null || onClick === void 0 ? void 0 : onClick(row, column);
61
- } else {
69
+ if (isLongPress) {
62
70
  setIsLongPress(false);
71
+ return;
72
+ }
73
+
74
+ var currentTime = Date.now();
75
+ var isDoubleClick = currentTime - lastClickTime < DOUBLECLICKDELAY;
76
+ setLastClickTime(currentTime);
77
+
78
+ if (!isDoubleClick) {
79
+ onClick === null || onClick === void 0 ? void 0 : onClick(row, column);
63
80
  }
64
81
  };
65
82
 
@@ -70,16 +87,19 @@ var Cell = function Cell(_ref4) {
70
87
  align: (_column$textAlign = column.textAlign) !== null && _column$textAlign !== void 0 ? _column$textAlign : 'left',
71
88
  padding: column.disablePadding ? 'none' : 'normal',
72
89
  onClick: handleClick,
90
+ onDoubleClick: function onDoubleClick() {
91
+ return column.disableClick ? undefined : _onDoubleClick === null || _onDoubleClick === void 0 ? void 0 : _onDoubleClick(row, column);
92
+ },
73
93
  onContextMenu: isLongPress ? function (ev) {
74
94
  return ev.preventDefault();
75
95
  } : undefined
76
- }, children ? React.Children.map(children, function (child) {
77
- return /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
96
+ }, children ? AddPropsToChildren(children, function () {
97
+ return {
78
98
  row: row,
79
99
  columns: columns,
80
100
  column: column,
81
101
  cell: cellContent
82
- }) : null;
102
+ };
83
103
  }) : cellContent);
84
104
  };
85
105
 
@@ -1,10 +1,7 @@
1
1
  export default FixedHeaderContent;
2
- declare function FixedHeaderContent({ columns, orderDirection, orderBy, rowCount, context, onClick, onSelectAllClick }: {
2
+ declare function FixedHeaderContent({ columns, orderDirection, orderBy, onClick }: {
3
3
  columns: any;
4
4
  orderDirection: any;
5
5
  orderBy: any;
6
- rowCount: any;
7
- context: any;
8
6
  onClick: any;
9
- onSelectAllClick: any;
10
7
  }): JSX.Element;
@@ -1,8 +1,5 @@
1
- import cx from 'classnames';
2
1
  import React from 'react';
3
2
  import TableHeadCell from "cozy-ui/transpiled/react/Table/Virtualized/HeadCell";
4
- import Checkbox from "cozy-ui/transpiled/react/Checkbox";
5
- import TableCell from "cozy-ui/transpiled/react/TableCell";
6
3
  import TableRow from "cozy-ui/transpiled/react/TableRow";
7
4
  import { makeStyles } from "cozy-ui/transpiled/react/styles";
8
5
  var useStyles = makeStyles({
@@ -23,27 +20,9 @@ var FixedHeaderContent = function FixedHeaderContent(_ref) {
23
20
  var columns = _ref.columns,
24
21
  orderDirection = _ref.orderDirection,
25
22
  orderBy = _ref.orderBy,
26
- rowCount = _ref.rowCount,
27
- context = _ref.context,
28
- _onClick = _ref.onClick,
29
- onSelectAllClick = _ref.onSelectAllClick;
23
+ _onClick = _ref.onClick;
30
24
  var classes = useStyles();
31
- var selectedCount = context.selectedItems.length;
32
- return /*#__PURE__*/React.createElement(TableRow, null, context.withCheckbox && /*#__PURE__*/React.createElement(TableCell, {
33
- align: "center",
34
- padding: "checkbox"
35
- }, /*#__PURE__*/React.createElement(Checkbox, {
36
- className: cx('virtualizedCheckbox', {
37
- checked: selectedCount > 0
38
- }),
39
- indeterminate: selectedCount > 0 && selectedCount < rowCount,
40
- checked: rowCount > 0 && selectedCount === rowCount,
41
- inputProps: {
42
- 'aria-label': 'select all'
43
- },
44
- size: "small",
45
- onChange: onSelectAllClick
46
- })), columns.map(function (column) {
25
+ return /*#__PURE__*/React.createElement(TableRow, null, columns.map(function (column) {
47
26
  return /*#__PURE__*/React.createElement(TableHeadCell, {
48
27
  key: column.id,
49
28
  className: classes.visuallyHidden,
@@ -1,12 +1,9 @@
1
- declare var _default: React.MemoExoticComponent<({ index, row, columns, context, children, disableCheckbox, onSelectClick, onLongPress, onClick }: {
2
- index: any;
1
+ declare var _default: React.MemoExoticComponent<({ row, columns, children, onLongPress, onDoubleClick, onClick }: {
3
2
  row: any;
4
3
  columns: any;
5
- context: any;
6
4
  children: any;
7
- disableCheckbox: any;
8
- onSelectClick: any;
9
5
  onLongPress: any;
6
+ onDoubleClick: any;
10
7
  onClick: any;
11
8
  }) => JSX.Element>;
12
9
  export default _default;
@@ -1,44 +1,21 @@
1
- import cx from 'classnames';
2
1
  import React from 'react';
3
2
  import Cell from "cozy-ui/transpiled/react/Table/Virtualized/Cell";
4
- import Checkbox from "cozy-ui/transpiled/react/Checkbox";
5
- import TableCell from "cozy-ui/transpiled/react/TableCell";
6
3
 
7
4
  var RowContent = function RowContent(_ref) {
8
- var index = _ref.index,
9
- row = _ref.row,
5
+ var row = _ref.row,
10
6
  columns = _ref.columns,
11
- context = _ref.context,
12
7
  children = _ref.children,
13
- disableCheckbox = _ref.disableCheckbox,
14
- onSelectClick = _ref.onSelectClick,
15
8
  onLongPress = _ref.onLongPress,
9
+ onDoubleClick = _ref.onDoubleClick,
16
10
  onClick = _ref.onClick;
17
- var selectedCount = context.selectedItems.length;
18
- return /*#__PURE__*/React.createElement(React.Fragment, null, context.withCheckbox && /*#__PURE__*/React.createElement(TableCell, {
19
- align: "center",
20
- padding: "checkbox"
21
- }, /*#__PURE__*/React.createElement(Checkbox, {
22
- className: cx('virtualizedCheckbox', {
23
- visible: selectedCount > 0,
24
- checked: context.isSelectedItem(row)
25
- }),
26
- disabled: disableCheckbox === null || disableCheckbox === void 0 ? void 0 : disableCheckbox(row),
27
- checked: context.isSelectedItem(row),
28
- inputProps: {
29
- 'aria-labelledby': "enhanced-table-checkbox-".concat(index)
30
- },
31
- size: "small",
32
- onClick: function onClick(event) {
33
- return onSelectClick(row, event, index);
34
- }
35
- })), columns.map(function (column) {
11
+ return /*#__PURE__*/React.createElement(React.Fragment, null, columns.map(function (column) {
36
12
  return /*#__PURE__*/React.createElement(Cell, {
37
13
  key: column.id,
38
14
  row: row,
39
15
  columns: columns,
40
16
  column: column,
41
17
  onClick: onClick,
18
+ onDoubleClick: onDoubleClick,
42
19
  onLongPress: onLongPress
43
20
  }, children);
44
21
  }));
@@ -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", "withCheckbox"];
5
+ var _excluded = ["rows", "columns", "groups", "defaultOrder", "secondarySort", "selectedItems", "isSelectedItem", "componentsProps", "context", "components", "onSortChange", "isNewItem"];
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
 
@@ -25,15 +25,12 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
25
25
  defaultOrder = _ref.defaultOrder,
26
26
  secondarySort = _ref.secondarySort,
27
27
  selectedItems = _ref.selectedItems,
28
- onSelect = _ref.onSelect,
29
- onSelectAll = _ref.onSelectAll,
30
28
  isSelectedItem = _ref.isSelectedItem,
31
29
  componentsProps = _ref.componentsProps,
32
30
  context = _ref.context,
33
31
  components = _ref.components,
34
32
  onSortChange = _ref.onSortChange,
35
33
  isNewItem = _ref.isNewItem,
36
- withCheckbox = _ref.withCheckbox,
37
34
  props = _objectWithoutProperties(_ref, _excluded);
38
35
 
39
36
  var _useState = useState((_defaultOrder$directi = defaultOrder === null || defaultOrder === void 0 ? void 0 : defaultOrder.direction) !== null && _defaultOrder$directi !== void 0 ? _defaultOrder$directi : 'asc'),
@@ -61,9 +58,7 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
61
58
  // we use directly `data` prop if no groupCounts
62
59
  isSelectedItem: isSelectedItem,
63
60
  selectedItems: selectedItems,
64
- isNewItem: isNewItem,
65
- withCheckbox: withCheckbox,
66
- onSelect: onSelect
61
+ isNewItem: isNewItem
67
62
  });
68
63
 
69
64
  var handleSort = function handleSort(property) {
@@ -77,17 +72,6 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
77
72
  });
78
73
  };
79
74
 
80
- var handleSelectAll = function handleSelectAll(event) {
81
- var _event$target;
82
-
83
- if (event !== null && event !== void 0 && (_event$target = event.target) !== null && _event$target !== void 0 && _event$target.checked) {
84
- onSelectAll(rows);
85
- return;
86
- }
87
-
88
- onSelectAll([]);
89
- };
90
-
91
75
  var Component = isGroupedTable ? GroupedTableVirtuoso : TableVirtuoso;
92
76
  return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
93
77
  ref: ref,
@@ -102,8 +86,7 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
102
86
  context: _context,
103
87
  orderDirection: orderDirection,
104
88
  orderBy: orderBy,
105
- onClick: handleSort,
106
- onSelectAllClick: handleSelectAll
89
+ onClick: handleSort
107
90
  }));
108
91
  }
109
92
  }, isGroupedTable && {
@@ -121,8 +104,7 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
121
104
  index: index,
122
105
  row: data[index],
123
106
  columns: columns,
124
- context: _context,
125
- onSelectClick: onSelect
107
+ context: _context
126
108
  }), componentsProps === null || componentsProps === void 0 ? void 0 : (_componentsProps$rowC = componentsProps.rowContent) === null || _componentsProps$rowC === void 0 ? void 0 : _componentsProps$rowC.children);
127
109
  },
128
110
  rowSpan: 2
@@ -131,10 +113,7 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
131
113
  VirtualizedTable.displayName = 'VirtualizedTable';
132
114
  VirtualizedTable.defaultProps = {
133
115
  selectedItems: [],
134
- isSelectedItem: function isSelectedItem() {},
135
- onSelect: function onSelect() {},
136
- onSelectAll: function onSelectAll() {},
137
- withCheckbox: true
116
+ isSelectedItem: function isSelectedItem() {}
138
117
  };
139
118
  VirtualizedTable.propTypes = {
140
119
  /** Rows to display in the table */
@@ -167,12 +146,6 @@ VirtualizedTable.propTypes = {
167
146
  /** Array of selected items */
168
147
  selectedItems: PropTypes.array,
169
148
 
170
- /** Callback function when a row is selected */
171
- onSelect: PropTypes.func,
172
-
173
- /** Callback function when all rows are selected/deselected */
174
- onSelectAll: PropTypes.func,
175
-
176
149
  /** Function to determine if a row is selected */
177
150
  isSelectedItem: PropTypes.func,
178
151
 
@@ -180,9 +153,6 @@ VirtualizedTable.propTypes = {
180
153
  onSortChange: PropTypes.func,
181
154
 
182
155
  /** Function to determine if a row is new */
183
- isNewItem: PropTypes.func,
184
-
185
- /** Whether to show checkboxes. When false, rows become clickable for selection */
186
- withCheckbox: PropTypes.bool
156
+ isNewItem: PropTypes.func
187
157
  };
188
158
  export default VirtualizedTable;