react-magma-dom 4.12.2-next.0 → 4.12.2-next.1
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/components/DatePicker/utils.d.ts +1 -0
- package/dist/esm/index.js +39 -16
- package/dist/esm/index.js.map +1 -1
- package/dist/i18n/interface.d.ts +1 -0
- package/dist/properties.json +121 -121
- package/dist/react-magma-dom.cjs.development.js +39 -16
- package/dist/react-magma-dom.cjs.development.js.map +1 -1
- package/dist/react-magma-dom.cjs.production.min.js +1 -1
- package/dist/react-magma-dom.cjs.production.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -14,3 +14,4 @@ export declare function setMonthForDate(prevDate: any, numberMonth: number): Dat
|
|
|
14
14
|
export declare function setYearForDate(prevDate: any, numberYear: number): Date;
|
|
15
15
|
export declare const MAX_YEAR = 2099;
|
|
16
16
|
export declare const MIN_YEAR = 1900;
|
|
17
|
+
export declare const isYearOutOfRange: (year: number) => boolean;
|
package/dist/esm/index.js
CHANGED
|
@@ -492,6 +492,7 @@ var defaultI18n = {
|
|
|
492
492
|
day: 'Day',
|
|
493
493
|
month: 'Month',
|
|
494
494
|
year: 'Year',
|
|
495
|
+
invalidYearError: 'Invalid date. Please enter a year between {minYear} and {maxYear}.',
|
|
495
496
|
helpModal: {
|
|
496
497
|
header: 'Keyboard Shortcuts',
|
|
497
498
|
helpButtonAriaLabel: 'Keyboard instructions for calendar widget',
|
|
@@ -10754,6 +10755,9 @@ function setYearForDate(prevDate, numberYear) {
|
|
|
10754
10755
|
}
|
|
10755
10756
|
var MAX_YEAR = 2099;
|
|
10756
10757
|
var MIN_YEAR = 1900;
|
|
10758
|
+
var isYearOutOfRange = function isYearOutOfRange(year) {
|
|
10759
|
+
return year < MIN_YEAR || year > MAX_YEAR;
|
|
10760
|
+
};
|
|
10757
10761
|
|
|
10758
10762
|
function _EMOTION_STRINGIFIED_CSS_ERROR__$g() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
10759
10763
|
function getCalendarDayBackground(isInverse, isChosen, theme) {
|
|
@@ -13460,6 +13464,9 @@ var DateFieldInput = function DateFieldInput(props) {
|
|
|
13460
13464
|
var _React$useState = useState(false),
|
|
13461
13465
|
isFocused = _React$useState[0],
|
|
13462
13466
|
setIsFocused = _React$useState[1];
|
|
13467
|
+
var _React$useState2 = useState(false),
|
|
13468
|
+
isInvalidYear = _React$useState2[0],
|
|
13469
|
+
setIsInvalidYear = _React$useState2[1];
|
|
13463
13470
|
var dayId = id + "__day";
|
|
13464
13471
|
var monthId = id + "__month";
|
|
13465
13472
|
var yearId = id + "__year";
|
|
@@ -13473,11 +13480,13 @@ var DateFieldInput = function DateFieldInput(props) {
|
|
|
13473
13480
|
}
|
|
13474
13481
|
return isEmpty(month) ? 3.25 : 2;
|
|
13475
13482
|
};
|
|
13483
|
+
var invalidYearErrorMessage = i18n.datePicker.invalidYearError.replace('{minYear}', MIN_YEAR.toString()).replace('{maxYear}', MAX_YEAR.toString());
|
|
13484
|
+
var ariaDescribedBy = invalidYearErrorMessage || errorMessage || helperMessage ? "" + id + descriptionSuffix : undefined;
|
|
13476
13485
|
var renderInput = function renderInput(key) {
|
|
13477
13486
|
switch (key) {
|
|
13478
13487
|
case InputDateFields.Day:
|
|
13479
13488
|
return createElement(StyledNumInput, {
|
|
13480
|
-
"aria-describedby":
|
|
13489
|
+
"aria-describedby": ariaDescribedBy,
|
|
13481
13490
|
"aria-label": datePicker.day,
|
|
13482
13491
|
"data-testid": "day-input",
|
|
13483
13492
|
id: dayId,
|
|
@@ -13500,7 +13509,7 @@ var DateFieldInput = function DateFieldInput(props) {
|
|
|
13500
13509
|
});
|
|
13501
13510
|
case InputDateFields.Month:
|
|
13502
13511
|
return createElement(StyledNumInput, {
|
|
13503
|
-
"aria-describedby":
|
|
13512
|
+
"aria-describedby": ariaDescribedBy,
|
|
13504
13513
|
"aria-label": datePicker.month,
|
|
13505
13514
|
"data-testid": "month-input",
|
|
13506
13515
|
id: monthId,
|
|
@@ -13523,7 +13532,7 @@ var DateFieldInput = function DateFieldInput(props) {
|
|
|
13523
13532
|
});
|
|
13524
13533
|
case InputDateFields.Year:
|
|
13525
13534
|
return createElement(StyledNumInput, {
|
|
13526
|
-
"aria-describedby":
|
|
13535
|
+
"aria-describedby": ariaDescribedBy,
|
|
13527
13536
|
"aria-label": datePicker.year,
|
|
13528
13537
|
"data-testid": "year-input",
|
|
13529
13538
|
id: yearId,
|
|
@@ -13560,27 +13569,31 @@ var DateFieldInput = function DateFieldInput(props) {
|
|
|
13560
13569
|
firstFieldRef == null || firstFieldRef.focus();
|
|
13561
13570
|
};
|
|
13562
13571
|
useEffect(function () {
|
|
13563
|
-
var isMounted = true;
|
|
13564
|
-
// Preventing calling handleDateChange and onClearDate on initial mount when fields are empty
|
|
13565
13572
|
if (!didMountRef.current) {
|
|
13566
13573
|
didMountRef.current = true;
|
|
13567
13574
|
return;
|
|
13568
13575
|
}
|
|
13569
|
-
var allFieldsEmpty =
|
|
13570
|
-
if (allFieldsEmpty
|
|
13576
|
+
var allFieldsEmpty = !month && !day && !year;
|
|
13577
|
+
if (allFieldsEmpty) {
|
|
13571
13578
|
handleDateChange == null || handleDateChange(null, null);
|
|
13572
13579
|
onClearDate == null || onClearDate();
|
|
13580
|
+
setIsInvalidYear(false);
|
|
13581
|
+
return;
|
|
13582
|
+
}
|
|
13583
|
+
var hasAllFields = month && day && year;
|
|
13584
|
+
if (!hasAllFields) {
|
|
13585
|
+
setIsInvalidYear(false);
|
|
13573
13586
|
return;
|
|
13574
13587
|
}
|
|
13575
|
-
var
|
|
13576
|
-
if (
|
|
13577
|
-
|
|
13578
|
-
|
|
13588
|
+
var yearValue = Number(year);
|
|
13589
|
+
if (isYearOutOfRange(yearValue)) {
|
|
13590
|
+
return;
|
|
13591
|
+
}
|
|
13592
|
+
setIsInvalidYear(false);
|
|
13593
|
+
var newDate = hasMonthLongFormat ? new Date(month + " " + day + ", " + year) : new Date(yearValue, Number(month) - 1, Number(day));
|
|
13594
|
+
if (!isNaN(newDate.getTime())) {
|
|
13579
13595
|
handleDateChange == null || handleDateChange(newDate, null);
|
|
13580
13596
|
}
|
|
13581
|
-
return function () {
|
|
13582
|
-
isMounted = false;
|
|
13583
|
-
};
|
|
13584
13597
|
}, [month, day, year, hasMonthLongFormat]);
|
|
13585
13598
|
useEffect(function () {
|
|
13586
13599
|
var isMounted = true;
|
|
@@ -13637,12 +13650,18 @@ var DateFieldInput = function DateFieldInput(props) {
|
|
|
13637
13650
|
setIsFocused(true);
|
|
13638
13651
|
};
|
|
13639
13652
|
var handleOnBlur = function handleOnBlur(e) {
|
|
13653
|
+
var isLeavingGroup = !e.currentTarget.contains(e.relatedTarget);
|
|
13654
|
+
if (isLeavingGroup && month && day && year) {
|
|
13655
|
+
if (isYearOutOfRange(Number(year))) {
|
|
13656
|
+
setIsInvalidYear(true);
|
|
13657
|
+
}
|
|
13658
|
+
}
|
|
13640
13659
|
onInputBlur == null || onInputBlur(e);
|
|
13641
13660
|
setIsFocused(false);
|
|
13642
13661
|
};
|
|
13643
13662
|
return createElement(FormFieldContainer, {
|
|
13644
13663
|
containerStyle: containerStyle,
|
|
13645
|
-
errorMessage: errorMessage,
|
|
13664
|
+
errorMessage: isInvalidYear ? invalidYearErrorMessage : errorMessage,
|
|
13646
13665
|
fieldId: id,
|
|
13647
13666
|
helperMessage: helperMessage,
|
|
13648
13667
|
isInverse: isInverse,
|
|
@@ -13690,7 +13709,11 @@ var DateFieldInput = function DateFieldInput(props) {
|
|
|
13690
13709
|
type: ButtonType.button,
|
|
13691
13710
|
variant: ButtonVariant.link,
|
|
13692
13711
|
onKeyDown: onIconKeyDown
|
|
13693
|
-
})))
|
|
13712
|
+
}))), createElement(VisuallyHidden, null, createElement("input", {
|
|
13713
|
+
id: id,
|
|
13714
|
+
"aria-hidden": "true",
|
|
13715
|
+
tabIndex: -1
|
|
13716
|
+
}))));
|
|
13694
13717
|
};
|
|
13695
13718
|
|
|
13696
13719
|
var _excluded$K = ["placeholder", "testId", "dateTimePickerContent"];
|