cozy-ui 129.0.0 → 130.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 CHANGED
@@ -1,3 +1,15 @@
1
+ # [130.0.0](https://github.com/cozy/cozy-ui/compare/v129.0.0...v130.0.0) (2025-09-18)
2
+
3
+
4
+ ### Features
5
+
6
+ * **VirtualizedTable:** defaultOrder become an object to change the sorted direction ([11edbe7](https://github.com/cozy/cozy-ui/commit/11edbe7))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * **VirtualizedTable:** - VirtualizedTable: When using `cozy-ui/transpiled/react/table/virtualized`, you need to pass `defaultOrder` as an object `{by: 'columnName', direction: 'asc'}` and not a string anymore `defaultOrder='columnName'`
12
+
1
13
  # [129.0.0](https://github.com/cozy/cozy-ui/compare/v128.10.1...v129.0.0) (2025-09-17)
2
14
 
3
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "129.0.0",
3
+ "version": "130.0.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -121,7 +121,7 @@ const ExampleTable = ({ variant, ...props }) => {
121
121
  <Typography className="u-mt-1" variant="h4">Sorted table</Typography>
122
122
  <div className="u-mt-half" style={{ border: "1px solid var(--borderMainColor)", height: 400, width: "100%" }}>
123
123
  <SelectionProvider>
124
- <ExampleTable variant={variant} defaultOrder={columns[0].id} />
124
+ <ExampleTable variant={variant} defaultOrder={{by: columns[0].id, direction: 'asc'}} />
125
125
  </SelectionProvider>
126
126
  </div>
127
127
  </>
@@ -28,8 +28,10 @@ const VirtualizedTable = forwardRef(
28
28
  },
29
29
  ref
30
30
  ) => {
31
- const [orderDirection, setOrderDirection] = useState('asc')
32
- const [orderBy, setOrderBy] = useState(defaultOrder)
31
+ const [orderDirection, setOrderDirection] = useState(
32
+ defaultOrder?.direction ?? 'asc'
33
+ )
34
+ const [orderBy, setOrderBy] = useState(defaultOrder?.by ?? undefined)
33
35
 
34
36
  const sortedData = orderBy
35
37
  ? stableSort(rows, getComparator(orderDirection, orderBy))
@@ -117,10 +119,27 @@ VirtualizedTable.defaultProps = {
117
119
  }
118
120
 
119
121
  VirtualizedTable.propTypes = {
120
- /** Column ID to be used for initiating the sort */
121
- defaultOrder: PropTypes.string,
122
+ /** Rows to display in the table */
123
+ rows: PropTypes.array,
124
+ /** Column configuration */
125
+ columns: PropTypes.array,
122
126
  /** Returned object is: PropTypes.shape({ groupLabels: PropTypes.array, groupCounts: PropTypes.array }) */
123
127
  groups: PropTypes.func,
128
+ /** Default sorting configuration */
129
+ defaultOrder: PropTypes.shape({
130
+ direction: PropTypes.oneOf(['asc', 'desc']),
131
+ by: PropTypes.string
132
+ }),
133
+ /** Sort files by type to put directory and trash before files */
134
+ secondarySort: PropTypes.func,
135
+ /** Array of selected items */
136
+ selectedItems: PropTypes.array,
137
+ /** Callback function when a row is selected */
138
+ onSelect: PropTypes.func,
139
+ /** Callback function when all rows are selected/deselected */
140
+ onSelectAll: PropTypes.func,
141
+ /** Function to determine if a row is selected */
142
+ isSelectedItem: PropTypes.func,
124
143
  /** Callback called after the sort */
125
144
  onSortChange: PropTypes.func
126
145
  }
@@ -17,6 +17,8 @@ import { stableSort, getComparator } from "cozy-ui/transpiled/react/Table/Virtua
17
17
  import virtuosoComponents from "cozy-ui/transpiled/react/Table/Virtualized/virtuosoComponents";
18
18
  import TableCell from "cozy-ui/transpiled/react/TableCell";
19
19
  var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
20
+ var _defaultOrder$directi, _defaultOrder$by;
21
+
20
22
  var rows = _ref.rows,
21
23
  columns = _ref.columns,
22
24
  groups = _ref.groups,
@@ -32,12 +34,12 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
32
34
  onSortChange = _ref.onSortChange,
33
35
  props = _objectWithoutProperties(_ref, _excluded);
34
36
 
35
- var _useState = useState('asc'),
37
+ var _useState = useState((_defaultOrder$directi = defaultOrder === null || defaultOrder === void 0 ? void 0 : defaultOrder.direction) !== null && _defaultOrder$directi !== void 0 ? _defaultOrder$directi : 'asc'),
36
38
  _useState2 = _slicedToArray(_useState, 2),
37
39
  orderDirection = _useState2[0],
38
40
  setOrderDirection = _useState2[1];
39
41
 
40
- var _useState3 = useState(defaultOrder),
42
+ var _useState3 = useState((_defaultOrder$by = defaultOrder === null || defaultOrder === void 0 ? void 0 : defaultOrder.by) !== null && _defaultOrder$by !== void 0 ? _defaultOrder$by : undefined),
41
43
  _useState4 = _slicedToArray(_useState3, 2),
42
44
  orderBy = _useState4[0],
43
45
  setOrderBy = _useState4[1];
@@ -129,12 +131,36 @@ VirtualizedTable.defaultProps = {
129
131
  onSelectAll: function onSelectAll() {}
130
132
  };
131
133
  VirtualizedTable.propTypes = {
132
- /** Column ID to be used for initiating the sort */
133
- defaultOrder: PropTypes.string,
134
+ /** Rows to display in the table */
135
+ rows: PropTypes.array,
136
+
137
+ /** Column configuration */
138
+ columns: PropTypes.array,
134
139
 
135
140
  /** Returned object is: PropTypes.shape({ groupLabels: PropTypes.array, groupCounts: PropTypes.array }) */
136
141
  groups: PropTypes.func,
137
142
 
143
+ /** Default sorting configuration */
144
+ defaultOrder: PropTypes.shape({
145
+ direction: PropTypes.oneOf(['asc', 'desc']),
146
+ by: PropTypes.string
147
+ }),
148
+
149
+ /** Sort files by type to put directory and trash before files */
150
+ secondarySort: PropTypes.func,
151
+
152
+ /** Array of selected items */
153
+ selectedItems: PropTypes.array,
154
+
155
+ /** Callback function when a row is selected */
156
+ onSelect: PropTypes.func,
157
+
158
+ /** Callback function when all rows are selected/deselected */
159
+ onSelectAll: PropTypes.func,
160
+
161
+ /** Function to determine if a row is selected */
162
+ isSelectedItem: PropTypes.func,
163
+
138
164
  /** Callback called after the sort */
139
165
  onSortChange: PropTypes.func
140
166
  };