cozy-ui 110.7.0 → 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,17 @@
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
+
8
+ ## [110.7.1](https://github.com/cozy/cozy-ui/compare/v110.7.0...v110.7.1) (2024-07-09)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **AlertProvider:** `filled` wasn't the default variant ([c4d545d](https://github.com/cozy/cozy-ui/commit/c4d545d))
14
+
1
15
  # [110.7.0](https://github.com/cozy/cozy-ui/compare/v110.6.0...v110.7.0) (2024-07-09)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "110.7.0",
3
+ "version": "110.8.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -13,7 +13,7 @@ const initialVariants = [{
13
13
  largeIcon: false,
14
14
  noIcon: false,
15
15
  square: false,
16
- filled: false,
16
+ standard: false,
17
17
  outlined: false,
18
18
  close: true
19
19
  }]
@@ -30,17 +30,17 @@ const Component = ({ variant }) => {
30
30
  severity: 'success',
31
31
  message: 'Alert message',
32
32
  color: variant.color ? "#EFA82D" : undefined,
33
- variant: variant.filled
34
- ? 'filled'
33
+ variant: variant.standard
34
+ ? 'standard'
35
35
  : variant.outlined
36
36
  ? 'outlined'
37
- : undefined,
37
+ : 'filled',
38
38
  block: variant.block,
39
39
  square: variant.square,
40
40
  icon: variant.noIcon
41
41
  ? false
42
42
  : variant.largeIcon
43
- ? <Icon icon={DeviceLaptopIcon} color="var(--errorColor)" size={32} />
43
+ ? <Icon icon={DeviceLaptopIcon} size={32} />
44
44
  : undefined,
45
45
  onClose: variant.close ? () => {} : undefined
46
46
  })
@@ -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,8 +55,13 @@ 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
64
+ variant="filled"
59
65
  elevation={6}
60
66
  onClose={handleClose(state, setState)}
61
67
  {...alertProps}
@@ -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,8 +80,10 @@ 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({
86
+ variant: "filled",
83
87
  elevation: 6,
84
88
  onClose: handleClose(state, setState)
85
89
  }, alertProps), title && /*#__PURE__*/React.createElement(AlertTitle, null, title), message)));