eai-frontend-components 2.0.42 → 2.0.43
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 +3 -1
- package/dist/index.esm.js +34 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9367,9 +9367,32 @@ const stringToDate = (dateString, separator = '/') => {
|
|
|
9367
9367
|
if (dateParts.length !== 3)
|
|
9368
9368
|
return undefined;
|
|
9369
9369
|
const day = parseInt(dateParts[0], 10);
|
|
9370
|
-
const month = parseInt(dateParts[1], 10)
|
|
9370
|
+
const month = parseInt(dateParts[1], 10);
|
|
9371
9371
|
const year = parseInt(dateParts[2], 10);
|
|
9372
|
-
|
|
9372
|
+
// Validar se os valores são números válidos
|
|
9373
|
+
if (Number.isNaN(day) || Number.isNaN(month) || Number.isNaN(year)) {
|
|
9374
|
+
return undefined;
|
|
9375
|
+
}
|
|
9376
|
+
// Validar mês (1-12)
|
|
9377
|
+
if (month < 1 || month > 12) {
|
|
9378
|
+
return undefined;
|
|
9379
|
+
}
|
|
9380
|
+
// Validar ano
|
|
9381
|
+
if (year < 1900 || year > 2100) {
|
|
9382
|
+
return undefined;
|
|
9383
|
+
}
|
|
9384
|
+
// Validar dia dentro do mês
|
|
9385
|
+
const daysInMonth = new Date(year, month, 0).getDate();
|
|
9386
|
+
if (day < 1 || day > daysInMonth) {
|
|
9387
|
+
return undefined;
|
|
9388
|
+
}
|
|
9389
|
+
// JavaScript usa meses zero-based (0-11)
|
|
9390
|
+
const date = new Date(year, month - 1, day);
|
|
9391
|
+
// Verificação adicional: garantir que a data criada corresponde aos valores fornecidos
|
|
9392
|
+
if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {
|
|
9393
|
+
return undefined;
|
|
9394
|
+
}
|
|
9395
|
+
return date;
|
|
9373
9396
|
};
|
|
9374
9397
|
const aYearAgo = () => {
|
|
9375
9398
|
const aYearAgo = new Date();
|
|
@@ -9386,6 +9409,14 @@ const addDaysToToday = (days) => {
|
|
|
9386
9409
|
date.setDate(date.getDate() + days);
|
|
9387
9410
|
return date;
|
|
9388
9411
|
};
|
|
9412
|
+
const isValidDate = (date) => {
|
|
9413
|
+
return date instanceof Date && !Number.isNaN(date.getTime());
|
|
9414
|
+
};
|
|
9415
|
+
const isDateRangeValid = (startDate, endDate, maxDays = 90) => {
|
|
9416
|
+
const diffInMs = endDate.getTime() - startDate.getTime();
|
|
9417
|
+
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);
|
|
9418
|
+
return diffInDays <= maxDays;
|
|
9419
|
+
};
|
|
9389
9420
|
|
|
9390
9421
|
const FormInputDate = ({ control, name, label, subLabel, helpText, placeholder = '01/01/2023', className, disabled, required, onChange, onKeyUp, }) => {
|
|
9391
9422
|
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
@@ -10848,8 +10879,10 @@ exports.getFirstDayOf90DaysAgo = getFirstDayOf90DaysAgo;
|
|
|
10848
10879
|
exports.getFirstDayOfCurrentMonth = getFirstDayOfCurrentMonth;
|
|
10849
10880
|
exports.getTailwindColorShades = getTailwindColorShades;
|
|
10850
10881
|
exports.invertDate = invertDate;
|
|
10882
|
+
exports.isDateRangeValid = isDateRangeValid;
|
|
10851
10883
|
exports.isInvalidCurrencyValue = isInvalidCurrencyValue;
|
|
10852
10884
|
exports.isUUIDv4 = isUUIDv4;
|
|
10885
|
+
exports.isValidDate = isValidDate;
|
|
10853
10886
|
exports.maskCpfCnpj = maskCpfCnpj;
|
|
10854
10887
|
exports.maskPhone = maskPhone;
|
|
10855
10888
|
exports.modifyCpfCnpj = modifyCpfCnpj;
|