cozy-ui 110.7.1 → 110.8.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
+ # [110.8.0](https://github.com/cozy/cozy-ui/compare/v110.7.1...v110.8.0) (2024-07-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * **AlertProvider:** Add `duration` prop ([03b2f0e](https://github.com/cozy/cozy-ui/commit/03b2f0e))
7
+
1
8
  ## [110.7.1](https://github.com/cozy/cozy-ui/compare/v110.7.0...v110.7.1) (2024-07-09)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "110.7.1",
3
+ "version": "110.8.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -29,6 +29,7 @@ export const useAlert = () => {
29
29
  const defaultState = {
30
30
  title: '',
31
31
  message: '',
32
+ duration: null,
32
33
  open: false
33
34
  }
34
35
  const handleClose = (state, setState) => () => {
@@ -37,7 +38,7 @@ const handleClose = (state, setState) => () => {
37
38
 
38
39
  const AlertProvider = ({ children }) => {
39
40
  const [state, setState] = useState(defaultState)
40
- const { open, message, title, ...alertProps } = state
41
+ const { open, message, title, duration, ...alertProps } = state
41
42
 
42
43
  const value = useMemo(
43
44
  () => ({
@@ -54,7 +55,11 @@ const AlertProvider = ({ children }) => {
54
55
  return (
55
56
  <AlertContext.Provider value={value}>
56
57
  {children}
57
- <Snackbar open={open} onClose={handleClose(state, setState)}>
58
+ <Snackbar
59
+ open={open}
60
+ autoHideDuration={duration}
61
+ onClose={handleClose(state, setState)}
62
+ >
58
63
  <Alert
59
64
  variant="filled"
60
65
  elevation={6}
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
- var _excluded = ["open", "message", "title"];
5
+ var _excluded = ["open", "message", "title", "duration"];
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
 
@@ -38,6 +38,7 @@ export var useAlert = function useAlert() {
38
38
  var defaultState = {
39
39
  title: '',
40
40
  message: '',
41
+ duration: null,
41
42
  open: false
42
43
  };
43
44
 
@@ -60,6 +61,7 @@ var AlertProvider = function AlertProvider(_ref) {
60
61
  var open = state.open,
61
62
  message = state.message,
62
63
  title = state.title,
64
+ duration = state.duration,
63
65
  alertProps = _objectWithoutProperties(state, _excluded);
64
66
 
65
67
  var value = useMemo(function () {
@@ -78,6 +80,7 @@ var AlertProvider = function AlertProvider(_ref) {
78
80
  value: value
79
81
  }, children, /*#__PURE__*/React.createElement(Snackbar, {
80
82
  open: open,
83
+ autoHideDuration: duration,
81
84
  onClose: handleClose(state, setState)
82
85
  }, /*#__PURE__*/React.createElement(Alert, _extends({
83
86
  variant: "filled",