cozy-ui 138.11.0 → 138.13.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
+ # [138.13.0](https://github.com/cozy/cozy-ui/compare/v138.12.0...v138.13.0) (2026-05-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add hook to submit with a loader ([ff36c73](https://github.com/cozy/cozy-ui/commit/ff36c73))
7
+
8
+ # [138.12.0](https://github.com/cozy/cozy-ui/compare/v138.11.0...v138.12.0) (2026-05-13)
9
+
10
+
11
+ ### Features
12
+
13
+ * Allow to customize background color of ProgressionBanner component ([91b5cee](https://github.com/cozy/cozy-ui/commit/91b5cee))
14
+
1
15
  # [138.11.0](https://github.com/cozy/cozy-ui/compare/v138.10.0...v138.11.0) (2026-05-07)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "138.11.0",
3
+ "version": "138.13.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -12,7 +12,7 @@ import { BreakpointsProvider } from "cozy-ui/transpiled/react/providers/Breakpoi
12
12
  const { progression } = useProgression();
13
13
 
14
14
  const initialVariants = [
15
- { withValue: true, progressBar: true, withButton: false },
15
+ { withValue: true, progressBar: true, withButton: false, customColor: false },
16
16
  ];
17
17
 
18
18
  <BreakpointsProvider>
@@ -21,6 +21,7 @@ const initialVariants = [
21
21
  <ProgressionBanner
22
22
  progressBar={variant.progressBar}
23
23
  value={variant.withValue && progression}
24
+ color={variant.customColor ? 'var(--errorColorLight)': undefined}
24
25
  text={
25
26
  variant.withButton
26
27
  ? "Storage limit nearly reached"
@@ -19,7 +19,7 @@ const styles = () => ({
19
19
  })
20
20
 
21
21
  const ProgressionBanner = withStyles(styles)(
22
- ({ classes, value, text, icon, button, progressBar }) => {
22
+ ({ classes, value, text, icon, button, progressBar, color }) => {
23
23
  const variant = value ? 'determinate' : undefined
24
24
  const { isMobile } = useBreakpoints()
25
25
 
@@ -32,7 +32,7 @@ const ProgressionBanner = withStyles(styles)(
32
32
  <>
33
33
  <Alert
34
34
  icon={_icon}
35
- color="var(--contrastBackgroundColor)"
35
+ color={color}
36
36
  square
37
37
  block={isMobile}
38
38
  action={button}
@@ -63,11 +63,14 @@ ProgressionBanner.propTypes = {
63
63
  /** Button to use in the banner */
64
64
  button: PropTypes.node,
65
65
  /** Progression bar is hidden if set to false (defaults to true) */
66
- progressBar: PropTypes.bool
66
+ progressBar: PropTypes.bool,
67
+ /** Background color of the banner, css color */
68
+ color: PropTypes.string
67
69
  }
68
70
 
69
71
  ProgressionBanner.defaultProps = {
70
- progressBar: true
72
+ progressBar: true,
73
+ color: 'var(--contrastBackgroundColor)'
71
74
  }
72
75
 
73
76
  export default ProgressionBanner
@@ -0,0 +1,36 @@
1
+ import { useState } from 'react'
2
+ import { useI18n } from 'twake-i18n'
3
+
4
+ import { useAlert } from '../../providers/Alert'
5
+
6
+ export const useSubmitWithLoader = () => {
7
+ const [isLoading, setIsLoading] = useState(false)
8
+ const { showAlert } = useAlert()
9
+ const { t } = useI18n()
10
+
11
+ const onSubmit = async ({ submit, success, error }) => {
12
+ setIsLoading(true)
13
+
14
+ try {
15
+ await submit()
16
+
17
+ showAlert({
18
+ severity: 'success',
19
+ message: success?.message || t('useSubmitWithLoader.success')
20
+ })
21
+
22
+ success?.action()
23
+ } catch (e) {
24
+ showAlert({
25
+ severity: 'error',
26
+ message: error?.message(e) || t('useSubmitWithLoader.error', { error })
27
+ })
28
+
29
+ error?.action()
30
+ } finally {
31
+ setIsLoading(false)
32
+ }
33
+ }
34
+
35
+ return { onSubmit, isLoading }
36
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "useSubmitWithLoader": {
3
+ "success": "Success!",
4
+ "error": "An error occured %{error}"
5
+ }
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "useSubmitWithLoader": {
3
+ "success": "Succès !",
4
+ "error": "Une erreur est survenue %{error}"
5
+ }
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "useSubmitWithLoader": {
3
+ "success": "Успешно!",
4
+ "error": "Произошла ошибка %{error}"
5
+ }
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "useSubmitWithLoader": {
3
+ "success": "Thành công!",
4
+ "error": "Đã xảy ra lỗi %{error}"
5
+ }
6
+ }
@@ -30,7 +30,8 @@ var ProgressionBanner = withStyles(styles)(function (_ref) {
30
30
  text = _ref.text,
31
31
  icon = _ref.icon,
32
32
  button = _ref.button,
33
- progressBar = _ref.progressBar;
33
+ progressBar = _ref.progressBar,
34
+ color = _ref.color;
34
35
  var variant = value ? 'determinate' : undefined;
35
36
 
36
37
  var _useBreakpoints = useBreakpoints(),
@@ -46,7 +47,7 @@ var ProgressionBanner = withStyles(styles)(function (_ref) {
46
47
 
47
48
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Alert, {
48
49
  icon: _icon,
49
- color: "var(--contrastBackgroundColor)",
50
+ color: color,
50
51
  square: true,
51
52
  block: isMobile,
52
53
  action: button
@@ -73,9 +74,13 @@ ProgressionBanner.propTypes = {
73
74
  button: PropTypes.node,
74
75
 
75
76
  /** Progression bar is hidden if set to false (defaults to true) */
76
- progressBar: PropTypes.bool
77
+ progressBar: PropTypes.bool,
78
+
79
+ /** Background color of the banner, css color */
80
+ color: PropTypes.string
77
81
  };
78
82
  ProgressionBanner.defaultProps = {
79
- progressBar: true
83
+ progressBar: true,
84
+ color: 'var(--contrastBackgroundColor)'
80
85
  };
81
86
  export default ProgressionBanner;
@@ -0,0 +1,8 @@
1
+ export function useSubmitWithLoader(): {
2
+ onSubmit: ({ submit, success, error }: {
3
+ submit: any;
4
+ success: any;
5
+ error: any;
6
+ }) => Promise<void>;
7
+ isLoading: boolean;
8
+ };
@@ -0,0 +1,74 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import { useState } from 'react';
5
+ import { useI18n } from 'twake-i18n';
6
+ import { useAlert } from "cozy-ui/transpiled/react/providers/Alert";
7
+ export var useSubmitWithLoader = function useSubmitWithLoader() {
8
+ var _useState = useState(false),
9
+ _useState2 = _slicedToArray(_useState, 2),
10
+ isLoading = _useState2[0],
11
+ setIsLoading = _useState2[1];
12
+
13
+ var _useAlert = useAlert(),
14
+ showAlert = _useAlert.showAlert;
15
+
16
+ var _useI18n = useI18n(),
17
+ t = _useI18n.t;
18
+
19
+ var onSubmit = /*#__PURE__*/function () {
20
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
21
+ var submit, success, error;
22
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
23
+ while (1) {
24
+ switch (_context.prev = _context.next) {
25
+ case 0:
26
+ submit = _ref.submit, success = _ref.success, error = _ref.error;
27
+ setIsLoading(true);
28
+ _context.prev = 2;
29
+ _context.next = 5;
30
+ return submit();
31
+
32
+ case 5:
33
+ showAlert({
34
+ severity: 'success',
35
+ message: (success === null || success === void 0 ? void 0 : success.message) || t('useSubmitWithLoader.success')
36
+ });
37
+ success === null || success === void 0 ? void 0 : success.action();
38
+ _context.next = 13;
39
+ break;
40
+
41
+ case 9:
42
+ _context.prev = 9;
43
+ _context.t0 = _context["catch"](2);
44
+ showAlert({
45
+ severity: 'error',
46
+ message: (error === null || error === void 0 ? void 0 : error.message(_context.t0)) || t('useSubmitWithLoader.error', {
47
+ error: error
48
+ })
49
+ });
50
+ error === null || error === void 0 ? void 0 : error.action();
51
+
52
+ case 13:
53
+ _context.prev = 13;
54
+ setIsLoading(false);
55
+ return _context.finish(13);
56
+
57
+ case 16:
58
+ case "end":
59
+ return _context.stop();
60
+ }
61
+ }
62
+ }, _callee, null, [[2, 9, 13, 16]]);
63
+ }));
64
+
65
+ return function onSubmit(_x) {
66
+ return _ref2.apply(this, arguments);
67
+ };
68
+ }();
69
+
70
+ return {
71
+ onSubmit: onSubmit,
72
+ isLoading: isLoading
73
+ };
74
+ };