@movalib/movalib-commons 1.39.0 → 1.40.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.
@@ -1,15 +1,13 @@
1
1
  import React, { FunctionComponent } from 'react';
2
- import { SxProps, Theme } from '@mui/material';
3
- interface ConfirmationDialogProps {
4
- open: boolean;
5
- onClose: () => void;
2
+ import { type DialogProps } from '@mui/material/Dialog';
3
+ type ConfirmationDialogProps = DialogProps & {
4
+ onClose?: () => void;
6
5
  onConfirm?: () => void;
7
6
  showConfirm?: boolean;
8
7
  confirmLabel?: string;
9
8
  closeLabel?: string;
10
9
  title?: React.ReactNode;
11
10
  message?: React.ReactNode;
12
- sx?: SxProps<Theme>;
13
- }
11
+ };
14
12
  declare const ConfirmationDialog: FunctionComponent<ConfirmationDialogProps>;
15
13
  export default ConfirmationDialog;
@@ -10,6 +10,17 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
13
24
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
26
  };
@@ -24,13 +35,13 @@ var Button_1 = __importDefault(require("@mui/material/Button"));
24
35
  var material_1 = require("@mui/material");
25
36
  var Tools_1 = require("./helpers/Tools");
26
37
  var ConfirmationDialog = function (_a) {
27
- var open = _a.open, onClose = _a.onClose, onConfirm = _a.onConfirm, title = _a.title, message = _a.message, _b = _a.showConfirm, showConfirm = _b === void 0 ? true : _b, confirmLabel = _a.confirmLabel, closeLabel = _a.closeLabel, sx = _a.sx;
38
+ var open = _a.open, onClose = _a.onClose, onConfirm = _a.onConfirm, title = _a.title, message = _a.message, _b = _a.showConfirm, showConfirm = _b === void 0 ? true : _b, confirmLabel = _a.confirmLabel, closeLabel = _a.closeLabel, dialogProps = __rest(_a, ["open", "onClose", "onConfirm", "title", "message", "showConfirm", "confirmLabel", "closeLabel"]);
28
39
  var theme = (0, material_1.useTheme)();
29
40
  var defaultMessage = "Êtes-vous sûr de vouloir continuer ?";
30
41
  var defaultTitle = "Confirmation";
31
42
  var defaultConfirmLabel = "Oui";
32
43
  var defaultCloseLabel = "Non";
33
- return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, __assign({ open: open, onClose: onClose, "aria-labelledby": "alert-dialog-title", "aria-describedby": "alert-dialog-description", sx: __assign({}, sx) }, { children: [(0, jsx_runtime_1.jsx)(DialogTitle_1.default, __assign({ id: "alert-dialog-title", sx: {
44
+ return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, __assign({ open: open, onClose: onClose, "aria-labelledby": "alert-dialog-title", "aria-describedby": "alert-dialog-description" }, dialogProps, { children: [(0, jsx_runtime_1.jsx)(DialogTitle_1.default, __assign({ id: "alert-dialog-title", sx: {
34
45
  backgroundColor: theme.palette.grey[200]
35
46
  }, style: Tools_1.flexLeftRow }, { children: title || defaultTitle })), (0, jsx_runtime_1.jsx)(DialogContent_1.default, __assign({ sx: { textAlign: 'center' } }, { children: (0, jsx_runtime_1.jsx)(DialogContentText_1.default, __assign({ id: "alert-dialog-description", sx: { pt: 2 } }, { children: message || defaultMessage })) })), (0, jsx_runtime_1.jsxs)(DialogActions_1.default, __assign({ sx: {
36
47
  py: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.39.0",
3
+ "version": "1.40.0",
4
4
  "description": "Bibliothèque d'objets communs à l'ensemble des projets React de Movalib",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,27 +1,25 @@
1
1
  import React, { FunctionComponent } from 'react';
2
- import Dialog from '@mui/material/Dialog';
2
+ import Dialog, { type DialogProps } from '@mui/material/Dialog';
3
3
  import DialogActions from '@mui/material/DialogActions';
4
4
  import DialogContent from '@mui/material/DialogContent';
5
5
  import DialogContentText from '@mui/material/DialogContentText';
6
6
  import DialogTitle from '@mui/material/DialogTitle';
7
7
  import Button from '@mui/material/Button';
8
- import { SxProps, Theme, useTheme } from '@mui/material';
8
+ import { useTheme } from '@mui/material';
9
9
  import { flexLeftRow } from './helpers/Tools';
10
10
 
11
- interface ConfirmationDialogProps {
12
- open: boolean;
13
- onClose: () => void;
11
+ type ConfirmationDialogProps = DialogProps & {
12
+ onClose?: () => void;
14
13
  onConfirm?: () => void;
15
14
  showConfirm?: boolean;
16
15
  confirmLabel?: string;
17
16
  closeLabel?: string;
18
17
  title?: React.ReactNode;
19
18
  message?: React.ReactNode;
20
- sx?: SxProps<Theme>;
21
19
  }
22
20
 
23
21
  const ConfirmationDialog: FunctionComponent<ConfirmationDialogProps> = ({ open, onClose, onConfirm, title, message, showConfirm = true,
24
- confirmLabel, closeLabel, sx }) => {
22
+ confirmLabel, closeLabel, ...dialogProps }) => {
25
23
 
26
24
  const theme = useTheme();
27
25
  const defaultMessage = "Êtes-vous sûr de vouloir continuer ?";
@@ -35,7 +33,7 @@ const ConfirmationDialog: FunctionComponent<ConfirmationDialogProps> = ({ open,
35
33
  onClose={onClose}
36
34
  aria-labelledby="alert-dialog-title"
37
35
  aria-describedby="alert-dialog-description"
38
- sx={{ ...sx }}
36
+ {...dialogProps}
39
37
  >
40
38
  <DialogTitle id="alert-dialog-title" sx={{
41
39
  backgroundColor: theme.palette.grey[200]
@@ -64,4 +62,4 @@ const ConfirmationDialog: FunctionComponent<ConfirmationDialogProps> = ({ open,
64
62
  );
65
63
  }
66
64
 
67
- export default ConfirmationDialog;
65
+ export default ConfirmationDialog;