@movalib/movalib-commons 1.0.1 → 1.0.3
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/package.json +11 -2
- package/src/MovaCopyright.tsx +17 -0
- package/src/MovaLogin.tsx +198 -0
- package/src/assets/images/leaf_green_large.png +0 -0
- package/src/assets/images/leaf_orange_large.png +0 -0
- package/src/assets/images/leaf_pink_large.png +0 -0
- package/src/assets/images/logo/logo_large.png +0 -0
- package/src/assets/images/logo/logo_pro_large.png +0 -0
- package/src/helpers/Enums.ts +15 -0
- package/src/helpers/Tools.ts +1 -0
- package/src/helpers/Types.ts +11 -0
- package/src/helpers/Validator.ts +57 -0
- package/src/index.ts +8 -0
- package/src/react-app-env.d.ts +1 -0
- package/tsconfig.json +13 -9
- package/dist/MovaSnackbar.d.ts +0 -15
- package/dist/MovaSnackbar.js +0 -27
- package/dist/TestButton.d.ts +0 -6
- package/dist/TestButton.js +0 -7
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -9
- /package/{README.md → PV_README.md} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movalib/movalib-commons",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,11 +15,20 @@
|
|
|
15
15
|
"license": "ISC",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"react": "^18.2.0",
|
|
18
|
-
"react-
|
|
18
|
+
"react-scripts": "5.0.1",
|
|
19
|
+
"react-dom": "^18.2.0",
|
|
20
|
+
"@types/node": "^16.18.53",
|
|
21
|
+
"@types/react": "^18.2.22"
|
|
22
|
+
},
|
|
23
|
+
"eslintConfig": {
|
|
24
|
+
"extends": [
|
|
25
|
+
"react-app"
|
|
26
|
+
]
|
|
19
27
|
},
|
|
20
28
|
"devDependencies": {
|
|
21
29
|
"@mui/material": "^5.13.5",
|
|
22
30
|
"@mui/icons-material": "^5.11.16",
|
|
31
|
+
"@mui/lab": "^5.0.0-alpha.134",
|
|
23
32
|
"@types/react": "^18.2.22",
|
|
24
33
|
"@types/react-dom": "^18.2.7",
|
|
25
34
|
"typescript": "^4.9.5"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { FunctionComponent } from "react";
|
|
2
|
+
import { Link, Typography } from "@mui/material";
|
|
3
|
+
|
|
4
|
+
function MovaCopyright(props: any) {
|
|
5
|
+
return (
|
|
6
|
+
<Typography variant="body2" color="text.secondary" align="center" {...props}>
|
|
7
|
+
{'Copyright © '}
|
|
8
|
+
<Link color="inherit" href="https://www.movalib.com">
|
|
9
|
+
Movalib.com
|
|
10
|
+
</Link>{' '}
|
|
11
|
+
{new Date().getFullYear()}
|
|
12
|
+
{'.'}
|
|
13
|
+
</Typography>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default MovaCopyright;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { CSSProperties, FormEvent, FunctionComponent, useState } from "react";
|
|
2
|
+
import { LoadingButton } from '@mui/lab';
|
|
3
|
+
import LogoLarge from './assets/images/logo/logo_large.png';
|
|
4
|
+
import LogoProLarge from './assets/images/logo/logo_pro_large.png';
|
|
5
|
+
import GreenLeafImage from './assets/images/logo/leaf_green_large.png';
|
|
6
|
+
import PinkLeafImage from './assets/images/logo/leaf_pink_large.png';
|
|
7
|
+
import { Alert, Box, Checkbox, Container, CssBaseline, FormControlLabel, Grid, Link, TextField } from "@mui/material";
|
|
8
|
+
import MovaCopyright from "./MovaCopyright";
|
|
9
|
+
import { MovaLoginForm, MovaFormField } from "./helpers/Types";
|
|
10
|
+
import { MovaAppType } from "./helpers/Enums";
|
|
11
|
+
import { validateEmail } from "./helpers/Validator";
|
|
12
|
+
|
|
13
|
+
// Permet de centrer le contenu de l'application
|
|
14
|
+
const styles: CSSProperties = {
|
|
15
|
+
display: 'flex',
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
height: '100vh', // Ajustez la hauteur en fonction de vos besoins
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const initialFormState = {
|
|
22
|
+
email: { value: '', isValid: true },
|
|
23
|
+
password: { value: '', isValid: true },
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
interface MovaLoginProps {
|
|
27
|
+
movaAppType: MovaAppType,
|
|
28
|
+
onSubmit: (form: MovaLoginForm) => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const MovaLogin: FunctionComponent<MovaLoginProps> = ({ movaAppType, onSubmit }) => {
|
|
32
|
+
|
|
33
|
+
const [form, setForm] = useState<MovaLoginForm>(initialFormState);
|
|
34
|
+
const [message, setMessage] = useState<string>("");
|
|
35
|
+
const [loading, setLoading] = useState(false);
|
|
36
|
+
|
|
37
|
+
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {
|
|
38
|
+
const fieldName: string = e.target.name;
|
|
39
|
+
const fieldValue: string = e.target.value;
|
|
40
|
+
const newField: MovaFormField = { [fieldName]: { value: fieldValue, isValid: true } };
|
|
41
|
+
|
|
42
|
+
setForm({ ...form, ...newField});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const handleSubmit = async (e: FormEvent) => {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
setLoading(true);
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
if(validateForm() && onSubmit) {
|
|
51
|
+
// Si le formulaire est valide, on appel la function callback transmise en props
|
|
52
|
+
onSubmit(form);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}catch (error){
|
|
56
|
+
console.error('Error occurred during submission:', error);
|
|
57
|
+
}finally {
|
|
58
|
+
setLoading(false);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const validateForm = () => {
|
|
63
|
+
let newForm: MovaLoginForm = form;
|
|
64
|
+
|
|
65
|
+
// Validator email
|
|
66
|
+
if(!validateEmail(form.email.value.length)) {
|
|
67
|
+
const errorMsg: string = 'Adresse email invalide';
|
|
68
|
+
const newField: MovaFormField = { value: form.email.value, error: errorMsg, isValid: false };
|
|
69
|
+
newForm = { ...newForm, ...{ email: newField } };
|
|
70
|
+
} else {
|
|
71
|
+
const newField: MovaFormField = { value: form.email.value, error: '', isValid: true };
|
|
72
|
+
newForm = { ...newForm, ...{ email: newField } };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Validator password
|
|
76
|
+
if(form.password.value.length < 8) {
|
|
77
|
+
const errorMsg: string = 'Votre mot de passe doit faire au moins 8 caractères de long.';
|
|
78
|
+
const newField: MovaFormField = {value: form.password.value, error: errorMsg, isValid: false};
|
|
79
|
+
newForm = { ...newForm, ...{ password: newField } };
|
|
80
|
+
} else {
|
|
81
|
+
const newField: MovaFormField = { value: form.password.value, error: '', isValid: true };
|
|
82
|
+
newForm = { ...newForm, ...{ password: newField } };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
setForm(newForm);
|
|
86
|
+
|
|
87
|
+
return newForm.email.isValid && newForm.password.isValid;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const getMovaLogo = () => {
|
|
91
|
+
|
|
92
|
+
return movaAppType === MovaAppType.GARAGE ? LogoProLarge :
|
|
93
|
+
movaAppType === MovaAppType.USER ? LogoLarge :
|
|
94
|
+
movaAppType === MovaAppType.ADMIN ? LogoLarge : LogoLarge;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<div style={styles}>
|
|
100
|
+
<img src={GreenLeafImage} style={{position: 'fixed',
|
|
101
|
+
float:'left',
|
|
102
|
+
width: '250px',
|
|
103
|
+
height: '400px',
|
|
104
|
+
top: '-20%',
|
|
105
|
+
left: '3%',
|
|
106
|
+
opacity: '0.3',
|
|
107
|
+
zIndex: -8}} alt='Feuille Verte Movalib'></img>
|
|
108
|
+
|
|
109
|
+
<Container component="main" maxWidth="xs">
|
|
110
|
+
<CssBaseline />
|
|
111
|
+
<Box
|
|
112
|
+
sx={{
|
|
113
|
+
marginTop: 6,
|
|
114
|
+
display: 'flex',
|
|
115
|
+
flexDirection: 'column',
|
|
116
|
+
alignItems: 'center',
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
<img src={getMovaLogo()} style={{width:'80%'}}/>
|
|
120
|
+
<br />
|
|
121
|
+
</Box>
|
|
122
|
+
|
|
123
|
+
<Box component="form" onSubmit={handleSubmit} noValidate sx={{ mt: 1 }}>
|
|
124
|
+
<TextField
|
|
125
|
+
margin="normal"
|
|
126
|
+
required
|
|
127
|
+
fullWidth
|
|
128
|
+
id="email"
|
|
129
|
+
label="Adresse email"
|
|
130
|
+
name="email"
|
|
131
|
+
autoComplete="email"
|
|
132
|
+
autoFocus
|
|
133
|
+
onChange={e => handleInputChange(e)}
|
|
134
|
+
value={form.email.value}
|
|
135
|
+
error={!form.email.isValid}
|
|
136
|
+
helperText={form.email.error}
|
|
137
|
+
/>
|
|
138
|
+
<TextField
|
|
139
|
+
margin="normal"
|
|
140
|
+
required
|
|
141
|
+
fullWidth
|
|
142
|
+
name="password"
|
|
143
|
+
label="Mot de passe"
|
|
144
|
+
type="password"
|
|
145
|
+
id="password"
|
|
146
|
+
autoComplete="current-password"
|
|
147
|
+
onChange={e => handleInputChange(e)}
|
|
148
|
+
value={form.password.value}
|
|
149
|
+
error={!form.password.isValid}
|
|
150
|
+
helperText={form.password.error}
|
|
151
|
+
/>
|
|
152
|
+
<FormControlLabel control={<Checkbox value="remember" color="primary" />}
|
|
153
|
+
label="Se souvenir de moi"
|
|
154
|
+
/>
|
|
155
|
+
{/* <MyLoadingButton
|
|
156
|
+
type={ButtonType.SUBMIT}
|
|
157
|
+
label="Se connecter" /> */}
|
|
158
|
+
|
|
159
|
+
<LoadingButton
|
|
160
|
+
loading={loading}
|
|
161
|
+
type="submit"
|
|
162
|
+
fullWidth
|
|
163
|
+
variant="contained"
|
|
164
|
+
sx={{ mt: 3, mb: 2 }}>
|
|
165
|
+
<span>Se connecter</span>
|
|
166
|
+
</LoadingButton>
|
|
167
|
+
|
|
168
|
+
{message && <Alert severity="error" sx={{ mb: 2 }}>{message}</Alert>}
|
|
169
|
+
|
|
170
|
+
<Grid container>
|
|
171
|
+
<Grid item xs>
|
|
172
|
+
<Link href="#" variant="body2" color="text.secondary">
|
|
173
|
+
Mot de passe oublié ?
|
|
174
|
+
</Link>
|
|
175
|
+
</Grid>
|
|
176
|
+
<Grid item>
|
|
177
|
+
<Link href="#" variant="body2" color="text.secondary">
|
|
178
|
+
{"Créer un compte"}
|
|
179
|
+
</Link>
|
|
180
|
+
</Grid>
|
|
181
|
+
</Grid>
|
|
182
|
+
</Box>
|
|
183
|
+
<MovaCopyright sx={{ mt: 8, mb: 4 }} />
|
|
184
|
+
</Container>
|
|
185
|
+
|
|
186
|
+
<img src={PinkLeafImage} style={{position: 'fixed',
|
|
187
|
+
float:'right',
|
|
188
|
+
width: '250px',
|
|
189
|
+
height: '400px',
|
|
190
|
+
bottom: '-20%',
|
|
191
|
+
right: '3%',
|
|
192
|
+
opacity: '0.3',
|
|
193
|
+
zIndex: '-10'}} alt='Feuille Rose Movalib'></img>
|
|
194
|
+
</div>
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export default MovaLogin;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Un email valide
|
|
3
|
+
*/
|
|
4
|
+
const emailRegex:RegExp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Un mot de passe qui contient au moins une majuscule, une minuscule, un chiffre
|
|
8
|
+
* et un caractère spécial. La longueur du mot de passe doit être d'au moins 8 caractères.
|
|
9
|
+
*/
|
|
10
|
+
const passwordRegex:RegExp = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Un numéro de téléphone (10 chiffres)
|
|
14
|
+
*/
|
|
15
|
+
const phoneNumberRegex:RegExp = /^\d{0,10}$/;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Un code postal (5 chiffres)
|
|
19
|
+
*/
|
|
20
|
+
const postalCodeRegex:RegExp = /^\d{5}$/;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Une URL valide
|
|
24
|
+
*/
|
|
25
|
+
const urlRegex:RegExp =/^(ftp|http|https):\/\/[^ "]+$/;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Un nom pouvant contenir des lettres, chiffres d'une taille comprise entre 3 et 20 caractères
|
|
29
|
+
*/
|
|
30
|
+
const userNameRegex:RegExp = /^[a-z0-9_-]{3,20}$/;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Un texte pouvant contenir des lettres, chiffres et quelques caractères spéciaux
|
|
34
|
+
*/
|
|
35
|
+
const textRegex:RegExp = /^[a-zA-Z0-9\s.,!?'"()+=-_-éèçà]+$/;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
export function validatePhoneNumber(phoneNumber: string) : boolean {
|
|
39
|
+
if (phoneNumber === null || phoneNumber === undefined) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return phoneNumberRegex.test(phoneNumber);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function validateText(text: string) : boolean {
|
|
46
|
+
if (text === null || text === undefined) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return textRegex.test(text);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function validateEmail(email: string) : boolean {
|
|
53
|
+
if (email === null || email === undefined) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return emailRegex.test(email);
|
|
57
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
+
|
|
2
3
|
export { default as TestButton } from './TestButton';
|
|
4
|
+
export { default as MovaSnackbar } from './MovaSnackbar';
|
|
5
|
+
export { default as MovaLogin } from './MovaLogin';
|
|
6
|
+
export { default as MovaCopyright } from './MovaCopyright';
|
|
7
|
+
|
|
8
|
+
// Export des types
|
|
9
|
+
export type { MovaFormField } from './helpers/Types';
|
|
10
|
+
export type { MovaLoginForm } from './helpers/Types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="react-scripts" />
|
package/tsconfig.json
CHANGED
|
@@ -11,8 +11,12 @@
|
|
|
11
11
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
12
|
|
|
13
13
|
/* Language and Environment */
|
|
14
|
-
"target": "
|
|
15
|
-
|
|
14
|
+
"target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
+
"lib": [
|
|
16
|
+
"dom",
|
|
17
|
+
"dom.iterable",
|
|
18
|
+
"esnext"
|
|
19
|
+
], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
20
|
"jsx": "react-jsx", /* Specify what JSX code is generated. */
|
|
17
21
|
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
22
|
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
@@ -25,7 +29,7 @@
|
|
|
25
29
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
30
|
|
|
27
31
|
/* Modules */
|
|
28
|
-
"module": "
|
|
32
|
+
"module": "esnext", /* Specify what module code is generated. */
|
|
29
33
|
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
30
34
|
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
35
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
@@ -39,12 +43,12 @@
|
|
|
39
43
|
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
40
44
|
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
41
45
|
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
42
|
-
|
|
46
|
+
"resolveJsonModule": true, /* Enable importing .json files. */
|
|
43
47
|
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
44
48
|
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
45
49
|
|
|
46
50
|
/* JavaScript Support */
|
|
47
|
-
|
|
51
|
+
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
48
52
|
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
49
53
|
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
54
|
|
|
@@ -57,7 +61,7 @@
|
|
|
57
61
|
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
62
|
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
59
63
|
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
-
|
|
64
|
+
"noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
65
|
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
62
66
|
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
63
67
|
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
@@ -74,7 +78,7 @@
|
|
|
74
78
|
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
75
79
|
|
|
76
80
|
/* Interop Constraints */
|
|
77
|
-
|
|
81
|
+
"isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
78
82
|
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
79
83
|
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
80
84
|
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
@@ -95,7 +99,7 @@
|
|
|
95
99
|
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
96
100
|
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
97
101
|
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
98
|
-
|
|
102
|
+
"noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
99
103
|
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
100
104
|
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
101
105
|
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
@@ -106,5 +110,5 @@
|
|
|
106
110
|
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
107
111
|
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
108
112
|
},
|
|
109
|
-
"include": ["src
|
|
113
|
+
"include": ["src"]
|
|
110
114
|
}
|
package/dist/MovaSnackbar.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
interface MovaSnackbarProps {
|
|
3
|
-
snackbar: {
|
|
4
|
-
open: boolean;
|
|
5
|
-
message: string;
|
|
6
|
-
severity: 'success' | 'info' | 'warning' | 'error' | undefined;
|
|
7
|
-
};
|
|
8
|
-
setSnackbar: (snackbar: {
|
|
9
|
-
open: boolean;
|
|
10
|
-
message: string;
|
|
11
|
-
severity: 'success' | 'info' | 'warning' | 'error' | undefined;
|
|
12
|
-
}) => void;
|
|
13
|
-
}
|
|
14
|
-
declare const MovaSnackbar: FunctionComponent<MovaSnackbarProps>;
|
|
15
|
-
export default MovaSnackbar;
|
package/dist/MovaSnackbar.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const material_1 = require("@mui/material");
|
|
8
|
-
const CloseRounded_1 = __importDefault(require("@mui/icons-material/CloseRounded"));
|
|
9
|
-
const MovaSnackbar = ({ snackbar, setSnackbar }) => {
|
|
10
|
-
/**
|
|
11
|
-
* Gestion de la fermeture de la snackbar. Si la raison de cette fermeture est
|
|
12
|
-
* un clic en dehors de la zone de contenu on intercepte et annule la fermeture 'clickaway'.
|
|
13
|
-
* @param event Evénnement de fermeture
|
|
14
|
-
* @param reason Origine de l'événnement de fermeture
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
const handleClose = (event, reason) => {
|
|
18
|
-
if (reason === 'clickaway')
|
|
19
|
-
return;
|
|
20
|
-
setSnackbar({ open: false, message: '', severity: undefined });
|
|
21
|
-
};
|
|
22
|
-
const handleCloseAlert = (event) => {
|
|
23
|
-
setSnackbar({ open: false, message: '', severity: undefined });
|
|
24
|
-
};
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Snackbar, Object.assign({ open: snackbar.open, autoHideDuration: 5000, onClose: handleClose }, { children: (0, jsx_runtime_1.jsx)(material_1.Alert, Object.assign({ severity: snackbar.severity, variant: "filled", sx: { width: '100%' }, action: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "small", "aria-label": "close", color: "inherit", onClick: handleCloseAlert }, { children: (0, jsx_runtime_1.jsx)(CloseRounded_1.default, { fontSize: "small" }) })) }) }, { children: snackbar.message })) })));
|
|
26
|
-
};
|
|
27
|
-
exports.default = MovaSnackbar;
|
package/dist/TestButton.d.ts
DELETED
package/dist/TestButton.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const TestButton = ({ label }) => {
|
|
5
|
-
return (0, jsx_runtime_1.jsx)("button", { children: label });
|
|
6
|
-
};
|
|
7
|
-
exports.default = TestButton;
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as TestButton } from './TestButton';
|
package/dist/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TestButton = void 0;
|
|
7
|
-
// src/index.ts
|
|
8
|
-
var TestButton_1 = require("./TestButton");
|
|
9
|
-
Object.defineProperty(exports, "TestButton", { enumerable: true, get: function () { return __importDefault(TestButton_1).default; } });
|
|
File without changes
|