cozy-ui 130.4.0 → 130.6.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,17 @@
1
+ # [130.6.0](https://github.com/cozy/cozy-ui/compare/v130.5.0...v130.6.0) (2025-10-02)
2
+
3
+
4
+ ### Features
5
+
6
+ * **AlertProvider:** Add `noClickAway` and `noTimeOut` prop ([eee29d0](https://github.com/cozy/cozy-ui/commit/eee29d0))
7
+
8
+ # [130.5.0](https://github.com/cozy/cozy-ui/compare/v130.4.0...v130.5.0) (2025-10-01)
9
+
10
+
11
+ ### Features
12
+
13
+ * **TableRow, VirtualizedTable:** add isNewItem prop to track new items and highlight them ([d60d485](https://github.com/cozy/cozy-ui/commit/d60d485))
14
+
1
15
  # [130.4.0](https://github.com/cozy/cozy-ui/compare/v130.3.1...v130.4.0) (2025-10-01)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "130.4.0",
3
+ "version": "130.6.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
@@ -15,6 +15,8 @@ const initialVariants = [{
15
15
  square: false,
16
16
  standard: false,
17
17
  outlined: false,
18
+ noClickAway: false,
19
+ noTimeOut: false,
18
20
  close: true
19
21
  }]
20
22
 
@@ -23,7 +25,7 @@ const Component = ({ variant }) => {
23
25
 
24
26
  return (
25
27
  <Button
26
- label="show alert"
28
+ label="Show alert"
27
29
  onClick={() =>
28
30
  showAlert({
29
31
  title: variant.title ? 'Alert title' : undefined,
@@ -42,6 +44,8 @@ const Component = ({ variant }) => {
42
44
  : variant.largeIcon
43
45
  ? <Icon icon={DeviceLaptopIcon} size={32} />
44
46
  : undefined,
47
+ noClickAway: variant.noClickAway,
48
+ noTimeOut: variant.noTimeOut,
45
49
  onClose: variant.close ? () => {} : undefined
46
50
  })
47
51
  }
@@ -0,0 +1,13 @@
1
+ export const handleClose = (state, setState) => (event, reason) => {
2
+ const { noClickAway, noTimeOut } = state
3
+
4
+ if (reason === 'clickaway' && noClickAway) {
5
+ return
6
+ }
7
+
8
+ if (reason === 'timeout' && noTimeOut) {
9
+ return
10
+ }
11
+
12
+ return setState({ ...state, open: false })
13
+ }
@@ -1,5 +1,6 @@
1
1
  import React, { createContext, useState, useContext, useMemo } from 'react'
2
2
 
3
+ import { handleClose } from './helpers'
3
4
  import Alert from '../../Alert'
4
5
  import AlertTitle from '../../AlertTitle'
5
6
  import Snackbar from '../../Snackbar'
@@ -32,13 +33,19 @@ const defaultState = {
32
33
  duration: null,
33
34
  open: false
34
35
  }
35
- const handleClose = (state, setState) => () => {
36
- return setState({ ...state, open: false })
37
- }
38
36
 
39
37
  const AlertProvider = ({ children }) => {
40
38
  const [state, setState] = useState(defaultState)
41
- const { open, message, title, duration, ...alertProps } = state
39
+ // noTimeOut and noClickAway are destructured to not being passed to the DOM through ...alertProps
40
+ const {
41
+ open,
42
+ message,
43
+ title,
44
+ duration,
45
+ noTimeOut, // eslint-disable-line no-unused-vars
46
+ noClickAway, // eslint-disable-line no-unused-vars
47
+ ...alertProps
48
+ } = state
42
49
 
43
50
  const value = useMemo(
44
51
  () => ({
@@ -63,7 +70,7 @@ const AlertProvider = ({ children }) => {
63
70
  <Alert
64
71
  variant="filled"
65
72
  elevation={6}
66
- onClose={handleClose(state, setState)}
73
+ onClose={ev => handleClose(state, setState)(ev, 'click')}
67
74
  {...alertProps}
68
75
  >
69
76
  {title && <AlertTitle>{title}</AlertTitle>}
@@ -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;
@@ -0,0 +1 @@
1
+ export function handleClose(state: any, setState: any): (event: any, reason: any) => any;
@@ -0,0 +1,24 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ 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; }
4
+
5
+ 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; }
6
+
7
+ export var handleClose = function handleClose(state, setState) {
8
+ return function (event, reason) {
9
+ var noClickAway = state.noClickAway,
10
+ noTimeOut = state.noTimeOut;
11
+
12
+ if (reason === 'clickaway' && noClickAway) {
13
+ return;
14
+ }
15
+
16
+ if (reason === 'timeout' && noTimeOut) {
17
+ return;
18
+ }
19
+
20
+ return setState(_objectSpread(_objectSpread({}, state), {}, {
21
+ open: false
22
+ }));
23
+ };
24
+ };
@@ -1,14 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
- var _excluded = ["open", "message", "title", "duration"];
5
+ var _excluded = ["open", "message", "title", "duration", "noTimeOut", "noClickAway"];
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
11
  import React, { createContext, useState, useContext, useMemo } from 'react';
12
+ import { handleClose } from "cozy-ui/transpiled/react/providers/Alert/helpers";
12
13
  import Alert from "cozy-ui/transpiled/react/Alert";
13
14
  import AlertTitle from "cozy-ui/transpiled/react/AlertTitle";
14
15
  import Snackbar from "cozy-ui/transpiled/react/Snackbar";
@@ -42,26 +43,21 @@ var defaultState = {
42
43
  open: false
43
44
  };
44
45
 
45
- var handleClose = function handleClose(state, setState) {
46
- return function () {
47
- return setState(_objectSpread(_objectSpread({}, state), {}, {
48
- open: false
49
- }));
50
- };
51
- };
52
-
53
46
  var AlertProvider = function AlertProvider(_ref) {
54
47
  var children = _ref.children;
55
48
 
56
49
  var _useState = useState(defaultState),
57
50
  _useState2 = _slicedToArray(_useState, 2),
58
51
  state = _useState2[0],
59
- setState = _useState2[1];
52
+ setState = _useState2[1]; // noTimeOut and noClickAway are destructured to not being passed to the DOM through ...alertProps
53
+
60
54
 
61
55
  var open = state.open,
62
56
  message = state.message,
63
57
  title = state.title,
64
58
  duration = state.duration,
59
+ noTimeOut = state.noTimeOut,
60
+ noClickAway = state.noClickAway,
65
61
  alertProps = _objectWithoutProperties(state, _excluded);
66
62
 
67
63
  var value = useMemo(function () {
@@ -85,7 +81,9 @@ var AlertProvider = function AlertProvider(_ref) {
85
81
  }, /*#__PURE__*/React.createElement(Alert, _extends({
86
82
  variant: "filled",
87
83
  elevation: 6,
88
- onClose: handleClose(state, setState)
84
+ onClose: function onClose(ev) {
85
+ return handleClose(state, setState)(ev, 'click');
86
+ }
89
87
  }, alertProps), title && /*#__PURE__*/React.createElement(AlertTitle, null, title), message)));
90
88
  };
91
89