@movalib/movalib-commons 1.0.75 → 1.0.77

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,3 +1,4 @@
1
+ import { SxProps, Theme } from '@mui/material';
1
2
  import type { CSSProperties, FC } from 'react';
2
3
  import React from 'react';
3
4
  interface MovaDialogProps {
@@ -12,6 +13,7 @@ interface MovaDialogProps {
12
13
  leafImageColor?: "green" | "yellow" | "pink";
13
14
  title?: string;
14
15
  titleStyle?: CSSProperties;
16
+ sx?: SxProps<Theme>;
15
17
  }
16
18
  declare const MovaDialog: FC<MovaDialogProps>;
17
19
  export default MovaDialog;
@@ -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, _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;
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, sx = _a.sx;
26
26
  var getTransition = function () {
27
27
  switch (transition) {
28
28
  case "fade":
@@ -51,15 +51,15 @@ var MovaDialog = function (_a) {
51
51
  onClose();
52
52
  }
53
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: {
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: __assign(__assign({}, sx), { textAlign: 'center' }) }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getLeafImage(), style: {
55
55
  position: 'absolute',
56
56
  float: 'left',
57
57
  width: '150px',
58
58
  height: '350px',
59
- top: '-20%',
59
+ top: '-150px',
60
60
  zIndex: 0,
61
61
  left: 0,
62
62
  opacity: '0.2'
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 }))] })));
63
+ }, alt: 'Feuille 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 }))] })));
64
64
  };
65
65
  exports.default = MovaDialog;
@@ -16,6 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  var jsx_runtime_1 = require("react/jsx-runtime");
18
18
  var react_1 = require("react");
19
+ var leaf_yellow_small_png_1 = __importDefault(require("./assets/images/leaf_yellow_small.png"));
19
20
  var material_1 = require("@mui/material");
20
21
  var qr_code_styling_1 = __importDefault(require("qr-code-styling"));
21
22
  require("./QRCode.css");
@@ -39,7 +40,7 @@ var QRCode = function (_a) {
39
40
  height: 600,
40
41
  type: 'canvas',
41
42
  data: data !== null && data !== void 0 ? data : defaultData,
42
- //image: QRCodeImage,
43
+ image: leaf_yellow_small_png_1.default,
43
44
  margin: 10,
44
45
  qrOptions: {
45
46
  typeNumber: 0,
@@ -52,14 +53,14 @@ var QRCode = function (_a) {
52
53
  margin: 15
53
54
  },
54
55
  dotsOptions: {
55
- color: 'black',
56
- //color: darken(theme.palette.primary.main, 0.3),
56
+ //color: 'black',
57
+ color: (0, material_1.darken)(theme.palette.primary.main, 0.4),
57
58
  // gradient: {
58
59
  // type: 'linear', // 'radial'
59
60
  // rotation: 0,
60
61
  // colorStops: [{ offset: 0, color: theme.palette.primary.main }, { offset: 1, color: theme.palette.secondary.main }]
61
62
  // },
62
- type: 'rounded' // "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded";
63
+ type: 'square' // "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded";
63
64
  },
64
65
  backgroundOptions: {
65
66
  color: 'white',
@@ -70,9 +71,9 @@ var QRCode = function (_a) {
70
71
  // },
71
72
  },
72
73
  cornersSquareOptions: {
73
- color: '#de007dff',
74
- //color: darken(theme.palette.secondary.main, 0.1),
75
- type: 'extra-rounded',
74
+ //color: '#de007dff',
75
+ color: (0, material_1.darken)(theme.palette.secondary.main, 0.2),
76
+ type: 'square',
76
77
  // gradient: {
77
78
  // type: 'linear', // 'radial'
78
79
  // rotation: 180,
@@ -80,9 +81,9 @@ var QRCode = function (_a) {
80
81
  // },
81
82
  },
82
83
  cornersDotOptions: {
83
- color: '#de007dff',
84
- //color: darken(theme.palette.secondary.main, 0.1),
85
- type: 'dot',
84
+ //color: '#de007dff',
85
+ color: (0, material_1.darken)(theme.palette.secondary.main, 0.2),
86
+ type: 'square',
86
87
  // gradient: {
87
88
  // type: 'linear', // 'radial'
88
89
  // rotation: 180,
@@ -91,7 +92,7 @@ var QRCode = function (_a) {
91
92
  }
92
93
  }), options = _c[0], setOptions = _c[1];
93
94
  // Format de téléchargement par défaut
94
- var _d = (0, react_1.useState)("svg"), fileExt = _d[0], setFileExt = _d[1];
95
+ var _d = (0, react_1.useState)("png"), fileExt = _d[0], setFileExt = _d[1];
95
96
  var qrCode = (0, react_1.useState)(new qr_code_styling_1.default(options))[0];
96
97
  var ref = (0, react_1.useRef)(null);
97
98
  (0, react_1.useEffect)(function () {
@@ -11,4 +11,5 @@ export default class Document {
11
11
  updateDate?: Date;
12
12
  reference?: string;
13
13
  constructor(id: string, state: DocumentState, fileName: string, originalFileName: string, fileType: string, fileSignedUrl: string, name: string, type: DocumentType, creationDate: Date, updateDate?: Date, reference?: string);
14
+ static findByTypeAndReference(documents: Document[], type: DocumentType, reference: string): Document | undefined;
14
15
  }
@@ -13,6 +13,15 @@ var Document = /** @class */ (function () {
13
13
  this.updateDate = updateDate;
14
14
  this.reference = reference;
15
15
  }
16
+ Document.findByTypeAndReference = function (documents, type, reference) {
17
+ if (documents && type && reference) {
18
+ return documents.find(function (document) {
19
+ return document.type === type &&
20
+ document.reference === reference;
21
+ });
22
+ }
23
+ return undefined;
24
+ };
16
25
  return Document;
17
26
  }());
18
27
  exports.default = Document;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.0.75",
3
+ "version": "1.0.77",
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,4 +1,4 @@
1
- import { Alert, AppBar, Dialog, DialogActions, DialogContent, DialogTitle, Fade, IconButton, Toolbar, Typography } from '@mui/material';
1
+ import { Alert, AppBar, Dialog, DialogActions, DialogContent, DialogTitle, Fade, IconButton, Toolbar, Typography, SxProps, Theme } from '@mui/material';
2
2
  import type { CSSProperties, FC } from 'react';
3
3
  import BackIcon from '@mui/icons-material/ArrowBackIosNewRounded';
4
4
  import React from 'react';
@@ -19,9 +19,11 @@ interface MovaDialogProps {
19
19
  leafImageColor?: "green" | "yellow" | "pink",
20
20
  title?: string,
21
21
  titleStyle?: CSSProperties;
22
+ sx?: SxProps<Theme>;
22
23
  }
23
24
 
24
- const MovaDialog: FC<MovaDialogProps> = ({fullScreen, open, onClose, closable = false, children, title, titleStyle, message, leafImageColor, transition, actions}) => {
25
+ const MovaDialog: FC<MovaDialogProps> = ({fullScreen, open, onClose, closable = false, children, title, titleStyle,
26
+ message, leafImageColor, transition, actions, sx}) => {
25
27
 
26
28
  const getTransition = () => {
27
29
  switch(transition){
@@ -72,17 +74,17 @@ const MovaDialog: FC<MovaDialogProps> = ({fullScreen, open, onClose, closable =
72
74
  aria-labelledby="garage-dialog-title"
73
75
  aria-describedby="garage-dialog-description"
74
76
  onClose={handleOnClose}
75
- sx={{ textAlign:'center'}}
77
+ sx={{ ...sx, textAlign:'center'}}
76
78
  >
77
79
  <img src={getLeafImage()} style={{
78
80
  position: 'absolute',
79
81
  float:'left',
80
82
  width: '150px',
81
83
  height: '350px',
82
- top: '-20%',
84
+ top: '-150px',
83
85
  zIndex: 0,
84
86
  left: 0,
85
- opacity: '0.2'}} alt='Feuille Rose Movalib'></img>
87
+ opacity: '0.2'}} alt='Feuille Movalib'></img>
86
88
 
87
89
  <DialogTitle id="garage-dialog-title" sx={{ textAlign:'center', p: 0, pt: 1, mt: 0, mb: 0, zIndex: 10 }} >
88
90
  <AppBar sx={{ position: 'relative' }} color="transparent" elevation={0}>
package/src/QRCode.tsx CHANGED
@@ -43,7 +43,7 @@ const QRCode: FC<QRCodeProps> = ({ data, showDownload=false }) => {
43
43
  height: 600,
44
44
  type: 'canvas' as DrawType,
45
45
  data: data ?? defaultData,
46
- //image: QRCodeImage,
46
+ image: QRCodeImage,
47
47
  margin: 10,
48
48
  qrOptions: {
49
49
  typeNumber: 0 as TypeNumber,
@@ -56,14 +56,14 @@ const QRCode: FC<QRCodeProps> = ({ data, showDownload=false }) => {
56
56
  margin: 15
57
57
  },
58
58
  dotsOptions: {
59
- color: 'black',
60
- //color: darken(theme.palette.primary.main, 0.3),
59
+ //color: 'black',
60
+ color: darken(theme.palette.primary.main, 0.4),
61
61
  // gradient: {
62
62
  // type: 'linear', // 'radial'
63
63
  // rotation: 0,
64
64
  // colorStops: [{ offset: 0, color: theme.palette.primary.main }, { offset: 1, color: theme.palette.secondary.main }]
65
65
  // },
66
- type: 'rounded' as DotType // "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded";
66
+ type: 'square' as DotType // "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded";
67
67
  },
68
68
  backgroundOptions: {
69
69
  color: 'white',
@@ -74,9 +74,9 @@ const QRCode: FC<QRCodeProps> = ({ data, showDownload=false }) => {
74
74
  // },
75
75
  },
76
76
  cornersSquareOptions: {
77
- color: '#de007dff',
78
- //color: darken(theme.palette.secondary.main, 0.1),
79
- type: 'extra-rounded' as CornerSquareType,
77
+ //color: '#de007dff',
78
+ color: darken(theme.palette.secondary.main, 0.2),
79
+ type: 'square' as CornerSquareType,
80
80
  // gradient: {
81
81
  // type: 'linear', // 'radial'
82
82
  // rotation: 180,
@@ -84,9 +84,9 @@ const QRCode: FC<QRCodeProps> = ({ data, showDownload=false }) => {
84
84
  // },
85
85
  },
86
86
  cornersDotOptions: {
87
- color: '#de007dff',
88
- //color: darken(theme.palette.secondary.main, 0.1),
89
- type: 'dot' as CornerDotType,
87
+ //color: '#de007dff',
88
+ color: darken(theme.palette.secondary.main, 0.2),
89
+ type: 'square' as CornerDotType,
90
90
  // gradient: {
91
91
  // type: 'linear', // 'radial'
92
92
  // rotation: 180,
@@ -96,7 +96,7 @@ const QRCode: FC<QRCodeProps> = ({ data, showDownload=false }) => {
96
96
  });
97
97
 
98
98
  // Format de téléchargement par défaut
99
- const [fileExt, setFileExt] = useState<Extension>("svg");
99
+ const [fileExt, setFileExt] = useState<Extension>("png");
100
100
  const [qrCode] = useState<QRCodeStyling>(new QRCodeStyling(options));
101
101
  const ref = useRef<HTMLDivElement>(null);
102
102
 
@@ -38,4 +38,14 @@ export default class Document {
38
38
  this.updateDate = updateDate;
39
39
  this.reference = reference;
40
40
  }
41
+
42
+ static findByTypeAndReference(documents:Document[], type:DocumentType, reference:string): Document | undefined {
43
+ if(documents && type && reference){
44
+ return documents.find(document =>
45
+ document.type === type &&
46
+ document.reference === reference
47
+ );
48
+ }
49
+ return undefined;
50
+ }
41
51
  }