@movalib/movalib-commons 1.0.24 → 1.0.25

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.
@@ -112,7 +112,7 @@ var MovaLogin = function (_a) {
112
112
  // Validator pour l'email
113
113
  newForm.email = (0, Tools_1.validateField)(form.email, Validator_1.validateEmail, 'Adresse email invalide');
114
114
  // Validator pour le mot de passe
115
- newForm.password = (0, Tools_1.validateField)(form.password, function (value) { return value.length >= 10 && /[a-z]/.test(value) && /[A-Z]/.test(value); }, 'Votre mot de passe doit faire au moins 8 caractères de long');
115
+ newForm.password = (0, Tools_1.validateField)(form.password, function (value) { return value.length >= 10 && /[a-z]/.test(value) && /[A-Z]/.test(value); }, 'Mot de passe invalide');
116
116
  setForm(newForm);
117
117
  return newForm.email.isValid && newForm.password.isValid;
118
118
  };
@@ -67,8 +67,7 @@ var Tools_1 = require("./helpers/Tools");
67
67
  var styles = {
68
68
  display: 'flex',
69
69
  justifyContent: 'center',
70
- alignItems: 'center',
71
- height: '100vh', // Ajustez la hauteur en fonction de vos besoins
70
+ alignItems: 'center'
72
71
  };
73
72
  var initialUserFormState = {
74
73
  firstname: { value: '', isValid: true },
@@ -6,13 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var jsx_runtime_1 = require("react/jsx-runtime");
7
7
  var react_1 = require("react");
8
8
  var TextField_1 = __importDefault(require("@mui/material/TextField"));
9
+ // Regex pour une plaque d'immatriculation française
10
+ var regex = /^[A-Z]{2}-\d{3}-[A-Z]{2}$/;
9
11
  var VehiclePlateField = function (_a) {
10
12
  var onValidVehiclePlate = _a.onValidVehiclePlate;
11
13
  var _b = (0, react_1.useState)(''), value = _b[0], setValue = _b[1];
12
14
  var _c = (0, react_1.useState)(false), error = _c[0], setError = _c[1];
13
15
  var _d = (0, react_1.useState)(0), lastLength = _d[0], setLastLength = _d[1]; // Ajout d'un état pour stocker la longueur précédente
14
16
  (0, react_1.useEffect)(function () {
15
- if (!error && value !== '') {
17
+ if (!error && value !== '' && value.match(regex)) {
16
18
  onValidVehiclePlate(value);
17
19
  }
18
20
  }, [error, value, onValidVehiclePlate]);
@@ -29,7 +31,6 @@ var VehiclePlateField = function (_a) {
29
31
  if (cleanInput.length > 4 && !(cleanInput.length == 5 && isDeleting)) {
30
32
  inputValue = "".concat(cleanInput.slice(0, 2), "-").concat(cleanInput.slice(2, 5), "-").concat(cleanInput.slice(5, 7));
31
33
  }
32
- var regex = /^[A-Z]{2}-\d{3}-[A-Z]{2}$/; // Regex pour une plaque d'immatriculation française
33
34
  setValue(inputValue);
34
35
  setError(!regex.test(inputValue));
35
36
  setLastLength(inputValue.length); // Mettre à jour la longueur précédente
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
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/MovaLogin.tsx CHANGED
@@ -84,7 +84,7 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
84
84
  // Validator pour le mot de passe
85
85
  newForm.password = validateField(form.password,
86
86
  value => value.length >= 10 && /[a-z]/.test(value) && /[A-Z]/.test(value),
87
- 'Votre mot de passe doit faire au moins 8 caractères de long');
87
+ 'Mot de passe invalide');
88
88
 
89
89
  setForm(newForm);
90
90
 
@@ -16,8 +16,7 @@ import { validateField } from "./helpers/Tools";
16
16
  const styles: CSSProperties = {
17
17
  display: 'flex',
18
18
  justifyContent: 'center',
19
- alignItems: 'center',
20
- height: '100vh', // Ajustez la hauteur en fonction de vos besoins
19
+ alignItems: 'center'
21
20
  };
22
21
 
23
22
  const initialUserFormState = {
@@ -5,6 +5,9 @@ interface VehiclePlateFieldProps {
5
5
  onValidVehiclePlate: (vehiclePlate: string) => void;
6
6
  }
7
7
 
8
+ // Regex pour une plaque d'immatriculation française
9
+ const regex = /^[A-Z]{2}-\d{3}-[A-Z]{2}$/;
10
+
8
11
  const VehiclePlateField: FunctionComponent<VehiclePlateFieldProps> = ({ onValidVehiclePlate }) => {
9
12
 
10
13
  const [value, setValue] = useState<string>('');
@@ -12,7 +15,7 @@ const VehiclePlateField: FunctionComponent<VehiclePlateFieldProps> = ({ onValidV
12
15
  const [lastLength, setLastLength] = useState<number>(0); // Ajout d'un état pour stocker la longueur précédente
13
16
 
14
17
  useEffect(() => {
15
- if (!error && value !== '') {
18
+ if (!error && value !== '' && value.match(regex)) {
16
19
  onValidVehiclePlate(value);
17
20
  }
18
21
  }, [error, value, onValidVehiclePlate]);
@@ -36,8 +39,6 @@ const VehiclePlateField: FunctionComponent<VehiclePlateFieldProps> = ({ onValidV
36
39
  inputValue = `${cleanInput.slice(0, 2)}-${cleanInput.slice(2, 5)}-${cleanInput.slice(5, 7)}`;
37
40
  }
38
41
 
39
- const regex = /^[A-Z]{2}-\d{3}-[A-Z]{2}$/; // Regex pour une plaque d'immatriculation française
40
-
41
42
  setValue(inputValue);
42
43
  setError(!regex.test(inputValue));
43
44
  setLastLength(inputValue.length); // Mettre à jour la longueur précédente