cozy-ui 130.4.0 → 130.5.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
+ # [130.5.0](https://github.com/cozy/cozy-ui/compare/v130.4.0...v130.5.0) (2025-10-01)
2
+
3
+
4
+ ### Features
5
+
6
+ * **TableRow, VirtualizedTable:** add isNewItem prop to track new items and highlight them ([d60d485](https://github.com/cozy/cozy-ui/commit/d60d485))
7
+
1
8
  # [130.4.0](https://github.com/cozy/cozy-ui/compare/v130.3.1...v130.4.0) (2025-10-01)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "130.4.0",
3
+ "version": "130.5.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -1,4 +1,6 @@
1
1
  import React, { useEffect } from 'react'
2
+ import cx from 'classnames'
3
+
2
4
  import { useDrag, useDrop } from 'react-dnd'
3
5
  import { getEmptyImage } from 'react-dnd-html5-backend'
4
6
 
@@ -20,6 +22,7 @@ const TableRow = ({ item, context, componentsProps, ...props }) => {
20
22
  const isSelected = context?.isSelectedItem(item)
21
23
  const isDisabled =
22
24
  itemsInDropProcess.includes(item._id) || componentsProps?.tableRow?.disabled
25
+ const isNew = context?.isNewItem?.(item)
23
26
 
24
27
  const [dragCollect, dragRef, dragRefPreview] = useDrag(
25
28
  () => ({
@@ -85,7 +88,10 @@ const TableRow = ({ item, context, componentsProps, ...props }) => {
85
88
  {...props}
86
89
  ref={node => dragRef(dropRef(node))}
87
90
  selected={isSelected || dropCollect.isOver}
88
- className={dragCollect.isDragging ? 'virtualized u-o-50' : 'virtualized'}
91
+ className={cx(
92
+ dragCollect.isDragging ? 'virtualized u-o-50' : 'virtualized',
93
+ isNew ? 'u-bg-primaryColorLight' : ''
94
+ )}
89
95
  disabled={isDisabled}
90
96
  hover
91
97
  />
@@ -24,6 +24,7 @@ const VirtualizedTable = forwardRef(
24
24
  context,
25
25
  components,
26
26
  onSortChange,
27
+ isNewItem,
27
28
  ...props
28
29
  },
29
30
  ref
@@ -43,7 +44,8 @@ const VirtualizedTable = forwardRef(
43
44
  ...context,
44
45
  ...(isGroupedTable && { data }), // we use directly `data` prop if no groupCounts
45
46
  isSelectedItem,
46
- selectedItems
47
+ selectedItems,
48
+ isNewItem
47
49
  }
48
50
 
49
51
  const handleSort = property => {
@@ -141,7 +143,9 @@ VirtualizedTable.propTypes = {
141
143
  /** Function to determine if a row is selected */
142
144
  isSelectedItem: PropTypes.func,
143
145
  /** Callback called after the sort */
144
- onSortChange: PropTypes.func
146
+ onSortChange: PropTypes.func,
147
+ /** Function to determine if a row is new */
148
+ isNewItem: PropTypes.func
145
149
  }
146
150
 
147
151
  export default VirtualizedTable
@@ -5,12 +5,13 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
5
5
  var _excluded = ["item", "context", "componentsProps"];
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import React, { useEffect } from 'react';
8
+ import cx from 'classnames';
8
9
  import { useDrag, useDrop } from 'react-dnd';
9
10
  import { getEmptyImage } from 'react-dnd-html5-backend';
10
11
  import TableRowClassic from "cozy-ui/transpiled/react/TableRow";
11
12
 
12
13
  var TableRow = function TableRow(_ref) {
13
- var _componentsProps$tabl;
14
+ var _componentsProps$tabl, _context$isNewItem;
14
15
 
15
16
  var item = _ref.item,
16
17
  context = _ref.context,
@@ -27,6 +28,7 @@ var TableRow = function TableRow(_ref) {
27
28
  dragId = dragProps.dragId;
28
29
  var isSelected = context === null || context === void 0 ? void 0 : context.isSelectedItem(item);
29
30
  var isDisabled = itemsInDropProcess.includes(item._id) || (componentsProps === null || componentsProps === void 0 ? void 0 : (_componentsProps$tabl = componentsProps.tableRow) === null || _componentsProps$tabl === void 0 ? void 0 : _componentsProps$tabl.disabled);
31
+ var isNew = context === null || context === void 0 ? void 0 : (_context$isNewItem = context.isNewItem) === null || _context$isNewItem === void 0 ? void 0 : _context$isNewItem.call(context, item);
30
32
 
31
33
  var _useDrag = useDrag(function () {
32
34
  return {
@@ -126,7 +128,7 @@ var TableRow = function TableRow(_ref) {
126
128
  return dragRef(dropRef(node));
127
129
  },
128
130
  selected: isSelected || dropCollect.isOver,
129
- className: dragCollect.isDragging ? 'virtualized u-o-50' : 'virtualized',
131
+ className: cx(dragCollect.isDragging ? 'virtualized u-o-50' : 'virtualized', isNew ? 'u-bg-primaryColorLight' : ''),
130
132
  disabled: isDisabled,
131
133
  hover: true
132
134
  }));
@@ -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"];
5
+ var _excluded = ["rows", "columns", "groups", "defaultOrder", "secondarySort", "selectedItems", "onSelect", "onSelectAll", "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
 
@@ -32,6 +32,7 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
32
32
  context = _ref.context,
33
33
  components = _ref.components,
34
34
  onSortChange = _ref.onSortChange,
35
+ isNewItem = _ref.isNewItem,
35
36
  props = _objectWithoutProperties(_ref, _excluded);
36
37
 
37
38
  var _useState = useState((_defaultOrder$directi = defaultOrder === null || defaultOrder === void 0 ? void 0 : defaultOrder.direction) !== null && _defaultOrder$directi !== void 0 ? _defaultOrder$directi : 'asc'),
@@ -58,7 +59,8 @@ var VirtualizedTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
58
59
  }), {}, {
59
60
  // we use directly `data` prop if no groupCounts
60
61
  isSelectedItem: isSelectedItem,
61
- selectedItems: selectedItems
62
+ selectedItems: selectedItems,
63
+ isNewItem: isNewItem
62
64
  });
63
65
 
64
66
  var handleSort = function handleSort(property) {
@@ -162,6 +164,9 @@ VirtualizedTable.propTypes = {
162
164
  isSelectedItem: PropTypes.func,
163
165
 
164
166
  /** Callback called after the sort */
165
- onSortChange: PropTypes.func
167
+ onSortChange: PropTypes.func,
168
+
169
+ /** Function to determine if a row is new */
170
+ isNewItem: PropTypes.func
166
171
  };
167
172
  export default VirtualizedTable;