@movalib/movalib-commons 1.0.55 → 1.0.57

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/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { default as Loader } from './src/Loader';
1
2
  export { default as MovaDialog } from './src/MovaDialog';
2
3
  export { default as QRCode } from './src/QRCode';
3
4
  export { default as VehiclePlateField } from './src/VehiclePlateField';
package/dist/index.js CHANGED
@@ -4,8 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.Gender = exports.DocumentState = exports.DigitalPassportIndex = exports.DocumentType = exports.EventType = exports.EventState = exports.DayOfWeek = exports.MovaAppType = exports.RoleType = exports.validateEmail = exports.validateText = exports.validatePhoneNumber = exports.validateField = exports.VehicleTire = exports.Event = exports.Schedule = exports.Garage = exports.Document = exports.Vehicle = exports.Address = exports.Role = exports.User = exports.GenderSelector = exports.ConfirmationDialog = exports.MovaVehicleTireField = exports.MovaCopyright = exports.MovaSignUp = exports.MovaLogin = exports.MovaSnackbar = exports.TestButton = exports.VehiclePlateField = exports.QRCode = exports.MovaDialog = void 0;
7
+ exports.Gender = exports.DocumentState = exports.DigitalPassportIndex = exports.DocumentType = exports.EventType = exports.EventState = exports.DayOfWeek = exports.MovaAppType = exports.RoleType = exports.validateEmail = exports.validateText = exports.validatePhoneNumber = exports.validateField = exports.VehicleTire = exports.Event = exports.Schedule = exports.Garage = exports.Document = exports.Vehicle = exports.Address = exports.Role = exports.User = exports.GenderSelector = exports.ConfirmationDialog = exports.MovaVehicleTireField = exports.MovaCopyright = exports.MovaSignUp = exports.MovaLogin = exports.MovaSnackbar = exports.TestButton = exports.VehiclePlateField = exports.QRCode = exports.MovaDialog = exports.Loader = void 0;
8
8
  // Export des composants
9
+ var Loader_1 = require("./src/Loader");
10
+ Object.defineProperty(exports, "Loader", { enumerable: true, get: function () { return __importDefault(Loader_1).default; } });
9
11
  var MovaDialog_1 = require("./src/MovaDialog");
10
12
  Object.defineProperty(exports, "MovaDialog", { enumerable: true, get: function () { return __importDefault(MovaDialog_1).default; } });
11
13
  var QRCode_1 = require("./src/QRCode");
@@ -0,0 +1,7 @@
1
+ import { FunctionComponent } from "react";
2
+ interface LoaderProps {
3
+ loading: boolean;
4
+ padding?: number;
5
+ }
6
+ declare const Loader: FunctionComponent<LoaderProps>;
7
+ export default Loader;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ var jsx_runtime_1 = require("react/jsx-runtime");
15
+ var material_1 = require("@mui/material");
16
+ var Loader = function (_a) {
17
+ var loading = _a.loading, _b = _a.padding, padding = _b === void 0 ? 3 : _b;
18
+ var theme = (0, material_1.useTheme)();
19
+ var containerStyle = {
20
+ width: '100%',
21
+ textAlign: 'center',
22
+ paddingTop: theme.spacing(padding),
23
+ paddingBottom: theme.spacing(padding)
24
+ };
25
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: loading && (0, jsx_runtime_1.jsx)(material_1.Backdrop, __assign({ sx: { color: '#fff', zIndex: function (theme) { return theme.zIndex.drawer + 1; } }, open: loading }, { children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { color: "inherit" }) })) }));
26
+ };
27
+ exports.default = Loader;
@@ -5,6 +5,7 @@ interface MovaDialogProps {
5
5
  fullScreen: boolean;
6
6
  open: boolean;
7
7
  onClose: () => void;
8
+ closable?: boolean;
8
9
  actions?: React.ReactNode;
9
10
  message?: string;
10
11
  transition?: "fade";
@@ -22,7 +22,7 @@ var leaf_green_large_png_1 = __importDefault(require("./assets/images/leaf_green
22
22
  var leaf_yellow_large_png_1 = __importDefault(require("./assets/images/leaf_yellow_large.png"));
23
23
  var leaf_pink_large_png_1 = __importDefault(require("./assets/images/leaf_pink_large.png"));
24
24
  var MovaDialog = function (_a) {
25
- var fullScreen = _a.fullScreen, open = _a.open, onClose = _a.onClose, children = _a.children, title = _a.title, titleStyle = _a.titleStyle, message = _a.message, leafImageColor = _a.leafImageColor, transition = _a.transition, actions = _a.actions;
25
+ var fullScreen = _a.fullScreen, open = _a.open, onClose = _a.onClose, _b = _a.closable, closable = _b === void 0 ? false : _b, children = _a.children, title = _a.title, titleStyle = _a.titleStyle, message = _a.message, leafImageColor = _a.leafImageColor, transition = _a.transition, actions = _a.actions;
26
26
  var getTransition = function () {
27
27
  switch (transition) {
28
28
  case "fade":
@@ -41,11 +41,17 @@ var MovaDialog = function (_a) {
41
41
  var LeafImageComponent = getLeafImage();
42
42
  var purgeLocalState = function () {
43
43
  };
44
- var handleOnClose = function () {
44
+ var handleOnBack = function () {
45
45
  purgeLocalState();
46
46
  onClose();
47
47
  };
48
- return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, __assign({ fullScreen: fullScreen, fullWidth: true, TransitionComponent: getTransition(), open: open, "aria-labelledby": "garage-dialog-title", "aria-describedby": "garage-dialog-description", sx: { textAlign: 'center' } }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getLeafImage(), style: {
48
+ var handleOnClose = function () {
49
+ if (closable) {
50
+ purgeLocalState();
51
+ onClose();
52
+ }
53
+ };
54
+ return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, __assign({ fullScreen: fullScreen, fullWidth: true, TransitionComponent: getTransition(), open: open, "aria-labelledby": "garage-dialog-title", "aria-describedby": "garage-dialog-description", onClose: handleOnClose, sx: { textAlign: 'center' } }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getLeafImage(), style: {
49
55
  position: 'fixed',
50
56
  float: 'left',
51
57
  width: '150px',
@@ -54,6 +60,6 @@ var MovaDialog = function (_a) {
54
60
  zIndex: 0,
55
61
  left: 0,
56
62
  opacity: '0.2'
57
- }, alt: 'Feuille Rose Movalib' }), (0, jsx_runtime_1.jsx)(material_1.DialogTitle, __assign({ id: "garage-dialog-title", sx: { textAlign: 'center', p: 0, pt: 1, mt: 0, mb: 0, zIndex: 10 } }, { children: (0, jsx_runtime_1.jsx)(material_1.AppBar, __assign({ sx: { position: 'relative' }, color: "transparent", elevation: 0 }, { children: (0, jsx_runtime_1.jsxs)(material_1.Toolbar, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ edge: "start", color: "inherit", onClick: handleOnClose, "aria-label": "close" }, { children: (0, jsx_runtime_1.jsx)(ArrowBackIosNewRounded_1.default, {}) })), title && (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ sx: { textAlign: 'center', fontSize: 20, flexGrow: 1, pl: '20px', pr: '40px' }, style: titleStyle }, { children: title }))] }) })) })), (0, jsx_runtime_1.jsxs)(material_1.DialogContent, __assign({ sx: { zIndex: 20 } }, { children: [children, message && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: "error", sx: { mb: 2 } }, { children: message }))] })), (0, jsx_runtime_1.jsx)(material_1.DialogActions, __assign({ sx: { justifyContent: 'center' } }, { children: actions }))] })));
63
+ }, alt: 'Feuille Rose Movalib' }), (0, jsx_runtime_1.jsx)(material_1.DialogTitle, __assign({ id: "garage-dialog-title", sx: { textAlign: 'center', p: 0, pt: 1, mt: 0, mb: 0, zIndex: 10 } }, { children: (0, jsx_runtime_1.jsx)(material_1.AppBar, __assign({ sx: { position: 'relative' }, color: "transparent", elevation: 0 }, { children: (0, jsx_runtime_1.jsxs)(material_1.Toolbar, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ edge: "start", color: "inherit", onClick: handleOnBack, "aria-label": "close" }, { children: (0, jsx_runtime_1.jsx)(ArrowBackIosNewRounded_1.default, {}) })), title && (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ sx: { textAlign: 'center', fontSize: 20, flexGrow: 1, pl: '20px', pr: '40px' }, style: titleStyle }, { children: title }))] }) })) })), (0, jsx_runtime_1.jsxs)(material_1.DialogContent, __assign({ sx: { zIndex: 20 } }, { children: [children, message && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: "error", sx: { mb: 2 } }, { children: message }))] })), (0, jsx_runtime_1.jsx)(material_1.DialogActions, __assign({ sx: { justifyContent: 'center' } }, { children: actions }))] })));
58
64
  };
59
65
  exports.default = MovaDialog;
package/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/index.ts
2
2
 
3
3
  // Export des composants
4
+ export { default as Loader } from './src/Loader';
4
5
  export { default as MovaDialog } from './src/MovaDialog';
5
6
  export { default as QRCode } from './src/QRCode';
6
7
  export { default as VehiclePlateField } from './src/VehiclePlateField';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.0.55",
3
+ "version": "1.0.57",
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",
package/src/Loader.tsx ADDED
@@ -0,0 +1,38 @@
1
+ import { Backdrop, CircularProgress, useTheme } from "@mui/material";
2
+ import { CSSProperties, FunctionComponent } from "react";
3
+
4
+ interface LoaderProps {
5
+ loading:boolean,
6
+ padding?: number
7
+ }
8
+
9
+ const Loader: FunctionComponent<LoaderProps> = ({ loading, padding = 3 }) => {
10
+
11
+ const theme = useTheme();
12
+
13
+ const containerStyle: CSSProperties = {
14
+ width:'100%',
15
+ textAlign: 'center',
16
+ paddingTop: theme.spacing(padding),
17
+ paddingBottom: theme.spacing(padding)
18
+ }
19
+
20
+ return (
21
+ <>
22
+ {loading && <Backdrop
23
+ sx={{ color: '#fff', zIndex: (theme) => theme.zIndex.drawer + 1 }}
24
+ open={loading}
25
+ >
26
+ <CircularProgress color="inherit" />
27
+ </Backdrop>
28
+ }
29
+ {/* {loading &&
30
+ <div style={containerStyle}>
31
+ <CircularProgress />
32
+ </div>
33
+ } */}
34
+ </>
35
+ );
36
+ }
37
+
38
+ export default Loader;
@@ -12,6 +12,7 @@ interface MovaDialogProps {
12
12
  fullScreen: boolean,
13
13
  open: boolean,
14
14
  onClose: () => void,
15
+ closable?: boolean,
15
16
  actions?: React.ReactNode,
16
17
  message?:string,
17
18
  transition?: "fade",
@@ -20,7 +21,7 @@ interface MovaDialogProps {
20
21
  titleStyle?: CSSProperties;
21
22
  }
22
23
 
23
- const MovaDialog: FC<MovaDialogProps> = ({fullScreen, open, onClose, children, title, titleStyle, message, leafImageColor, transition, actions}) => {
24
+ const MovaDialog: FC<MovaDialogProps> = ({fullScreen, open, onClose, closable = false, children, title, titleStyle, message, leafImageColor, transition, actions}) => {
24
25
 
25
26
  const getTransition = () => {
26
27
  switch(transition){
@@ -50,10 +51,17 @@ const MovaDialog: FC<MovaDialogProps> = ({fullScreen, open, onClose, children, t
50
51
 
51
52
  }
52
53
 
53
- const handleOnClose = () => {
54
+ const handleOnBack = () => {
54
55
  purgeLocalState();
55
56
  onClose();
56
57
  }
58
+
59
+ const handleOnClose = () => {
60
+ if(closable){
61
+ purgeLocalState();
62
+ onClose();
63
+ }
64
+ }
57
65
 
58
66
  return (
59
67
  <Dialog
@@ -63,6 +71,7 @@ const MovaDialog: FC<MovaDialogProps> = ({fullScreen, open, onClose, children, t
63
71
  open={open}
64
72
  aria-labelledby="garage-dialog-title"
65
73
  aria-describedby="garage-dialog-description"
74
+ onClose={handleOnClose}
66
75
  sx={{ textAlign:'center'}}
67
76
  >
68
77
  <img src={getLeafImage()} style={{
@@ -81,7 +90,7 @@ const MovaDialog: FC<MovaDialogProps> = ({fullScreen, open, onClose, children, t
81
90
  <IconButton
82
91
  edge="start"
83
92
  color="inherit"
84
- onClick={handleOnClose}
93
+ onClick={handleOnBack}
85
94
  aria-label="close"
86
95
  >
87
96
  <BackIcon />