@transferwise/components 45.26.0 → 45.26.2
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/build/i18n/en.json +1 -0
- package/build/index.esm.js +185 -99
- package/build/index.esm.js.map +1 -1
- package/build/index.js +185 -99
- package/build/index.js.map +1 -1
- package/build/main.css +1 -1
- package/build/styles/dateLookup/DateLookup.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/styles/typeahead/typeaheadOption/TypeaheadOption.css +1 -1
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts +9 -0
- package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts.map +1 -0
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/tableLink/TableLink.d.ts +14 -4
- package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
- package/build/types/dateLookup/tableLink/index.d.ts +1 -1
- package/build/types/dateLookup/tableLink/index.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
- package/build/types/info/Info.d.ts +1 -1
- package/build/types/info/Info.d.ts.map +1 -1
- package/build/types/info/Info.messages.d.ts +8 -0
- package/build/types/info/Info.messages.d.ts.map +1 -0
- package/build/types/summary/Summary.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dateLookup/DateLookup.css +1 -1
- package/src/dateLookup/DateLookup.js +19 -4
- package/src/dateLookup/DateLookup.keyboardEvents.spec.js +12 -0
- package/src/dateLookup/DateLookup.less +39 -49
- package/src/dateLookup/DateLookup.story.js +8 -7
- package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +28 -3
- package/src/dateLookup/dayCalendar/table/DayCalendarTable.spec.js +25 -0
- package/src/dateLookup/getFocusableTime/getFocusable.spec.ts +40 -0
- package/src/dateLookup/getFocusableTime/getFocusableTime.tsx +14 -0
- package/src/dateLookup/monthCalendar/table/MonthCalendarTable.js +33 -20
- package/src/dateLookup/monthCalendar/table/MonthCalendarTable.spec.js +33 -0
- package/src/dateLookup/tableLink/TableLink.spec.js +6 -15
- package/src/dateLookup/tableLink/TableLink.tsx +79 -0
- package/src/dateLookup/yearCalendar/table/YearCalendarTable.js +33 -11
- package/src/dateLookup/yearCalendar/table/YearCalendarTable.spec.js +26 -0
- package/src/i18n/en.json +1 -0
- package/src/info/Info.messages.ts +8 -0
- package/src/info/Info.spec.js +10 -4
- package/src/info/Info.tsx +5 -2
- package/src/main.css +1 -1
- package/src/popover/Popover.js +1 -1
- package/src/popover/__snapshots__/Popover.spec.js.snap +2 -2
- package/src/summary/Summary.tsx +0 -1
- package/src/typeahead/Typeahead.story.js +6 -0
- package/src/typeahead/typeaheadOption/TypeaheadOption.css +1 -1
- package/src/typeahead/typeaheadOption/TypeaheadOption.js +1 -1
- package/src/typeahead/typeaheadOption/TypeaheadOption.less +2 -1
- package/src/dateLookup/tableLink/TableLink.js +0 -70
- /package/src/dateLookup/tableLink/{index.js → index.ts} +0 -0
package/build/i18n/en.json
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"neptune.DateLookup.twentyYears": "20 years",
|
|
16
16
|
"neptune.DateLookup.year": "year",
|
|
17
17
|
"neptune.FlowNavigation.back": "back to previous step",
|
|
18
|
+
"neptune.Info.ariaLabel": "More information",
|
|
18
19
|
"neptune.Link.opensInNewTab": "(opens in new tab)",
|
|
19
20
|
"neptune.MoneyInput.Select.placeholder": "Select an option...",
|
|
20
21
|
"neptune.Select.searchPlaceholder": "Search...",
|
package/build/index.esm.js
CHANGED
|
@@ -800,7 +800,7 @@ const ActionOption = ({
|
|
|
800
800
|
});
|
|
801
801
|
};
|
|
802
802
|
|
|
803
|
-
var messages$
|
|
803
|
+
var messages$c = defineMessages({
|
|
804
804
|
ariaLabel: {
|
|
805
805
|
id: "neptune.CloseButton.ariaLabel"
|
|
806
806
|
}
|
|
@@ -816,7 +816,7 @@ const CloseButton = /*#__PURE__*/forwardRef(function CloseButton({
|
|
|
816
816
|
testId
|
|
817
817
|
}, reference) {
|
|
818
818
|
const intl = useIntl();
|
|
819
|
-
ariaLabel ??= intl.formatMessage(messages$
|
|
819
|
+
ariaLabel ??= intl.formatMessage(messages$c.ariaLabel);
|
|
820
820
|
const Icon = filled ? CrossCircleFill : Cross;
|
|
821
821
|
return /*#__PURE__*/jsx("button", {
|
|
822
822
|
ref: reference,
|
|
@@ -836,7 +836,7 @@ const CloseButton = /*#__PURE__*/forwardRef(function CloseButton({
|
|
|
836
836
|
});
|
|
837
837
|
});
|
|
838
838
|
|
|
839
|
-
var messages$
|
|
839
|
+
var messages$b = defineMessages({
|
|
840
840
|
opensInNewTab: {
|
|
841
841
|
id: "neptune.Link.opensInNewTab"
|
|
842
842
|
}
|
|
@@ -865,7 +865,7 @@ const Link = ({
|
|
|
865
865
|
onClick: onClick,
|
|
866
866
|
...props,
|
|
867
867
|
children: [children, " ", isBlank && /*#__PURE__*/jsx(NavigateAway, {
|
|
868
|
-
title: formatMessage(messages$
|
|
868
|
+
title: formatMessage(messages$b.opensInNewTab)
|
|
869
869
|
})]
|
|
870
870
|
});
|
|
871
871
|
};
|
|
@@ -2312,7 +2312,7 @@ ProcessIndicator.defaultProps = {
|
|
|
2312
2312
|
};
|
|
2313
2313
|
var ProcessIndicator$1 = ProcessIndicator;
|
|
2314
2314
|
|
|
2315
|
-
var messages$
|
|
2315
|
+
var messages$a = defineMessages({
|
|
2316
2316
|
loadingAriaLabel: {
|
|
2317
2317
|
id: "neptune.Button.loadingAriaLabel"
|
|
2318
2318
|
}
|
|
@@ -2431,7 +2431,7 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
2431
2431
|
className: classes,
|
|
2432
2432
|
...props,
|
|
2433
2433
|
"aria-live": loading ? 'polite' : 'off',
|
|
2434
|
-
"aria-label": loading ? intl.formatMessage(messages$
|
|
2434
|
+
"aria-label": loading ? intl.formatMessage(messages$a.loadingAriaLabel) : rest['aria-label'],
|
|
2435
2435
|
children: [children, loading && /*#__PURE__*/jsx(ProcessIndicator$1, {
|
|
2436
2436
|
size: processIndicatorSize(),
|
|
2437
2437
|
className: "btn-loader"
|
|
@@ -2724,7 +2724,7 @@ const Chip = ({
|
|
|
2724
2724
|
}, value);
|
|
2725
2725
|
};
|
|
2726
2726
|
|
|
2727
|
-
var messages$
|
|
2727
|
+
var messages$9 = defineMessages({
|
|
2728
2728
|
ariaLabel: {
|
|
2729
2729
|
id: "neptune.Chips.ariaLabel"
|
|
2730
2730
|
}
|
|
@@ -2756,7 +2756,7 @@ const Chips = ({
|
|
|
2756
2756
|
value: chip.value,
|
|
2757
2757
|
label: chip.label,
|
|
2758
2758
|
closeButton: {
|
|
2759
|
-
'aria-label': intl.formatMessage(messages$
|
|
2759
|
+
'aria-label': intl.formatMessage(messages$9.ariaLabel, {
|
|
2760
2760
|
choice: chip.label
|
|
2761
2761
|
})
|
|
2762
2762
|
},
|
|
@@ -2864,7 +2864,7 @@ const validDateObject = dateObject => dateObject instanceof Date && !isNaN(dateO
|
|
|
2864
2864
|
|
|
2865
2865
|
const isMonthAndYearFormat = dateString => validDateString(dateString) && dateString.split('-').length < 3;
|
|
2866
2866
|
|
|
2867
|
-
var messages$
|
|
2867
|
+
var messages$8 = defineMessages({
|
|
2868
2868
|
monthLabel: {
|
|
2869
2869
|
id: "neptune.DateInput.month.label"
|
|
2870
2870
|
},
|
|
@@ -2944,12 +2944,12 @@ const DateInput = ({
|
|
|
2944
2944
|
const [month, setMonth] = useState(() => getExplodedDate('month'));
|
|
2945
2945
|
const [year, setYear] = useState(() => getExplodedDate('year'));
|
|
2946
2946
|
const [lastBroadcastedValue, setLastBroadcastedValue] = useState(getDateObject);
|
|
2947
|
-
dayLabel = dayLabel || formatMessage(messages$
|
|
2948
|
-
monthLabel = monthLabel || formatMessage(messages$
|
|
2949
|
-
yearLabel = yearLabel || formatMessage(messages$
|
|
2947
|
+
dayLabel = dayLabel || formatMessage(messages$8.dayLabel);
|
|
2948
|
+
monthLabel = monthLabel || formatMessage(messages$8.monthLabel);
|
|
2949
|
+
yearLabel = yearLabel || formatMessage(messages$8.yearLabel);
|
|
2950
2950
|
placeholders = {
|
|
2951
2951
|
day: placeholders?.day || 'DD',
|
|
2952
|
-
month: placeholders?.month || formatMessage(messages$
|
|
2952
|
+
month: placeholders?.month || formatMessage(messages$8.monthLabel),
|
|
2953
2953
|
year: placeholders?.year || 'YYYY'
|
|
2954
2954
|
};
|
|
2955
2955
|
const getDateAsString = date => {
|
|
@@ -3482,7 +3482,7 @@ DateTrigger.defaultProps = {
|
|
|
3482
3482
|
};
|
|
3483
3483
|
var DateTrigger$1 = DateTrigger;
|
|
3484
3484
|
|
|
3485
|
-
var messages$
|
|
3485
|
+
var messages$7 = defineMessages({
|
|
3486
3486
|
next: {
|
|
3487
3487
|
id: "neptune.DateLookup.next"
|
|
3488
3488
|
},
|
|
@@ -3528,7 +3528,7 @@ const DateHeader = ({
|
|
|
3528
3528
|
children: /*#__PURE__*/jsx("button", {
|
|
3529
3529
|
type: "button",
|
|
3530
3530
|
className: `d-inline-flex ${buttonClasses}`,
|
|
3531
|
-
"aria-label": `${intl.formatMessage(messages$
|
|
3531
|
+
"aria-label": `${intl.formatMessage(messages$7.previous)} ${dateMode}`,
|
|
3532
3532
|
onClick: onPreviousClick,
|
|
3533
3533
|
children: /*#__PURE__*/jsx(Chevron$1, {
|
|
3534
3534
|
orientation: Position.LEFT,
|
|
@@ -3542,7 +3542,7 @@ const DateHeader = ({
|
|
|
3542
3542
|
children: /*#__PURE__*/jsx("button", {
|
|
3543
3543
|
type: "button",
|
|
3544
3544
|
className: `tw-date-lookup-header-current ${buttonClasses}`,
|
|
3545
|
-
"aria-label": intl.formatMessage(messages$
|
|
3545
|
+
"aria-label": intl.formatMessage(messages$7.goTo20YearView),
|
|
3546
3546
|
onClick: onLabelClick,
|
|
3547
3547
|
children: label
|
|
3548
3548
|
})
|
|
@@ -3551,7 +3551,7 @@ const DateHeader = ({
|
|
|
3551
3551
|
children: /*#__PURE__*/jsx("button", {
|
|
3552
3552
|
type: "button",
|
|
3553
3553
|
className: `d-inline-flex ${buttonClasses}`,
|
|
3554
|
-
"aria-label": `${useIntl().formatMessage(messages$
|
|
3554
|
+
"aria-label": `${useIntl().formatMessage(messages$7.next)} ${dateMode}`,
|
|
3555
3555
|
onClick: onNextClick,
|
|
3556
3556
|
children: /*#__PURE__*/jsx(Chevron$1, {
|
|
3557
3557
|
orientation: Position.RIGHT,
|
|
@@ -3575,6 +3575,10 @@ DateHeader.defaultProps = {
|
|
|
3575
3575
|
};
|
|
3576
3576
|
var DateHeader$1 = DateHeader;
|
|
3577
3577
|
|
|
3578
|
+
function getFocusableTime(props) {
|
|
3579
|
+
return props.timeSpan.find(time => props.isActive(time)) || props.timeSpan.find(time => props.isNow(time) && !props.isDisabled(time)) || props.timeSpan.find(time => !props.isDisabled(time));
|
|
3580
|
+
}
|
|
3581
|
+
|
|
3578
3582
|
// NB! Using with UTC timestamp (YYYY-MM-DD) might lead to unexpected results, for example
|
|
3579
3583
|
// getStartOfDay(new Date('1995-01-01')) in Los Angeles returns 31 Dec 1994, but in
|
|
3580
3584
|
// in Singapore it is 1 Jan 1995.
|
|
@@ -3586,61 +3590,56 @@ function getStartOfDay(date) {
|
|
|
3586
3590
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
3587
3591
|
}
|
|
3588
3592
|
|
|
3589
|
-
|
|
3590
|
-
|
|
3593
|
+
const TableLink = ({
|
|
3594
|
+
item,
|
|
3595
|
+
type,
|
|
3596
|
+
title,
|
|
3597
|
+
longTitle,
|
|
3598
|
+
active,
|
|
3599
|
+
disabled,
|
|
3600
|
+
today,
|
|
3601
|
+
autofocus,
|
|
3602
|
+
onClick
|
|
3603
|
+
}) => {
|
|
3604
|
+
const buttonRef = useRef(null);
|
|
3605
|
+
const intl = useIntl();
|
|
3606
|
+
useEffect(() => {
|
|
3607
|
+
if (autofocus) {
|
|
3608
|
+
setTimeout(() => {
|
|
3609
|
+
buttonRef.current?.focus();
|
|
3610
|
+
}, 0);
|
|
3611
|
+
}
|
|
3612
|
+
}, [autofocus]);
|
|
3613
|
+
const onCalendarClick = event => {
|
|
3591
3614
|
event.preventDefault();
|
|
3592
|
-
if (!
|
|
3593
|
-
|
|
3615
|
+
if (!disabled) {
|
|
3616
|
+
onClick(item);
|
|
3594
3617
|
}
|
|
3595
3618
|
};
|
|
3596
|
-
calculateAriaLabel = (
|
|
3619
|
+
const calculateAriaLabel = () => {
|
|
3597
3620
|
if (active) {
|
|
3598
|
-
return `${longTitle || title}, ${formatMessage(messages$
|
|
3621
|
+
return `${longTitle || title || ''}, ${intl.formatMessage(messages$7.selected)} ${intl.formatMessage(messages$7[type])}`;
|
|
3599
3622
|
}
|
|
3600
3623
|
return longTitle || title;
|
|
3601
3624
|
};
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
type,
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
children:
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
disabled: disabled,
|
|
3620
|
-
"aria-label": this.calculateAriaLabel(longTitle, title, active, type, formatMessage),
|
|
3621
|
-
"aria-pressed": active,
|
|
3622
|
-
onClick: this.onClick,
|
|
3623
|
-
children: title || item
|
|
3624
|
-
})
|
|
3625
|
-
});
|
|
3626
|
-
}
|
|
3627
|
-
}
|
|
3628
|
-
TableLink.propTypes = {
|
|
3629
|
-
item: PropTypes.number.isRequired,
|
|
3630
|
-
// day (1-31), month (0-11) or year (2018 etc)
|
|
3631
|
-
type: PropTypes.oneOf(['day', 'month', 'year']).isRequired,
|
|
3632
|
-
title: PropTypes.string,
|
|
3633
|
-
longTitle: PropTypes.string,
|
|
3634
|
-
active: PropTypes.bool.isRequired,
|
|
3635
|
-
disabled: PropTypes.bool.isRequired,
|
|
3636
|
-
today: PropTypes.bool.isRequired,
|
|
3637
|
-
onClick: PropTypes.func.isRequired
|
|
3638
|
-
};
|
|
3639
|
-
TableLink.defaultProps = {
|
|
3640
|
-
title: null,
|
|
3641
|
-
longTitle: null
|
|
3625
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
3626
|
+
children: /*#__PURE__*/jsx("button", {
|
|
3627
|
+
ref: buttonRef,
|
|
3628
|
+
type: "button",
|
|
3629
|
+
className: classNames(`tw-date-lookup-${type}-option np-text-body-default-bold`, {
|
|
3630
|
+
active: !!active
|
|
3631
|
+
}, {
|
|
3632
|
+
today: !!today
|
|
3633
|
+
}),
|
|
3634
|
+
disabled: disabled,
|
|
3635
|
+
tabIndex: autofocus ? 0 : -1,
|
|
3636
|
+
"aria-label": calculateAriaLabel(),
|
|
3637
|
+
"aria-pressed": active,
|
|
3638
|
+
onClick: onCalendarClick,
|
|
3639
|
+
children: title || item
|
|
3640
|
+
})
|
|
3641
|
+
});
|
|
3642
3642
|
};
|
|
3643
|
-
var TableLink$1 = injectIntl(TableLink);
|
|
3644
3643
|
|
|
3645
3644
|
const SHORT_DAY_FORMAT = {
|
|
3646
3645
|
day: 'numeric'
|
|
@@ -3711,6 +3710,22 @@ class DayCalendarTable extends PureComponent {
|
|
|
3711
3710
|
} = this.props;
|
|
3712
3711
|
return !!(selectedDate && +new Date(viewYear, viewMonth, day) === +selectedDate);
|
|
3713
3712
|
};
|
|
3713
|
+
isToday = day => {
|
|
3714
|
+
const {
|
|
3715
|
+
viewMonth,
|
|
3716
|
+
viewYear
|
|
3717
|
+
} = this.props;
|
|
3718
|
+
return Number(getStartOfDay(new Date())) === Number(new Date(viewYear, viewMonth, day));
|
|
3719
|
+
};
|
|
3720
|
+
getAutofocusDay = weeks => {
|
|
3721
|
+
const days = weeks.flatMap(week => week);
|
|
3722
|
+
return getFocusableTime({
|
|
3723
|
+
isActive: this.isActive,
|
|
3724
|
+
isNow: this.isToday,
|
|
3725
|
+
isDisabled: this.isDisabled,
|
|
3726
|
+
timeSpan: days
|
|
3727
|
+
});
|
|
3728
|
+
};
|
|
3714
3729
|
render() {
|
|
3715
3730
|
const {
|
|
3716
3731
|
viewMonth,
|
|
@@ -3720,12 +3735,13 @@ class DayCalendarTable extends PureComponent {
|
|
|
3720
3735
|
}
|
|
3721
3736
|
} = this.props;
|
|
3722
3737
|
const weeks = this.getTableStructure();
|
|
3738
|
+
let autoFocusDay = this.getAutofocusDay(weeks, viewMonth, viewYear);
|
|
3723
3739
|
return /*#__PURE__*/jsxs("table", {
|
|
3724
3740
|
className: "table table-condensed table-bordered tw-date-lookup-calendar m-b-0",
|
|
3725
3741
|
children: [/*#__PURE__*/jsx("thead", {
|
|
3726
3742
|
children: /*#__PURE__*/jsx("tr", {
|
|
3727
3743
|
children: this.days.map((day, index) => /*#__PURE__*/jsxs("th", {
|
|
3728
|
-
className:
|
|
3744
|
+
className: index > 4 ? 'text-xs-center np-text-body-default' : 'text-xs-center np-text-body-default-bold',
|
|
3729
3745
|
children: [/*#__PURE__*/jsx("span", {
|
|
3730
3746
|
className: "hidden-xs",
|
|
3731
3747
|
children: /*#__PURE__*/jsx("abbr", {
|
|
@@ -3744,15 +3760,16 @@ class DayCalendarTable extends PureComponent {
|
|
|
3744
3760
|
}), /*#__PURE__*/jsx("tbody", {
|
|
3745
3761
|
children: weeks.map((week, weekIndex) => /*#__PURE__*/jsx("tr", {
|
|
3746
3762
|
children: week.map((day, dayIndex) => /*#__PURE__*/jsx("td", {
|
|
3747
|
-
className: dayIndex > 4 ? '
|
|
3748
|
-
children: day && /*#__PURE__*/jsx(TableLink
|
|
3763
|
+
className: dayIndex > 4 ? 'weekend' : '',
|
|
3764
|
+
children: day && /*#__PURE__*/jsx(TableLink, {
|
|
3749
3765
|
item: day,
|
|
3750
3766
|
type: "day",
|
|
3751
3767
|
title: formatDate(new Date(viewYear, viewMonth, day), locale, SHORT_DAY_FORMAT),
|
|
3768
|
+
autofocus: day === autoFocusDay,
|
|
3752
3769
|
longTitle: formatDate(new Date(viewYear, viewMonth, day), locale),
|
|
3753
3770
|
active: this.isActive(day),
|
|
3754
3771
|
disabled: this.isDisabled(day),
|
|
3755
|
-
today:
|
|
3772
|
+
today: this.isToday(day),
|
|
3756
3773
|
onClick: this.selectDay
|
|
3757
3774
|
})
|
|
3758
3775
|
}, dayIndex))
|
|
@@ -3818,7 +3835,7 @@ class DayCalendar extends PureComponent {
|
|
|
3818
3835
|
month: monthFormat,
|
|
3819
3836
|
year: 'numeric'
|
|
3820
3837
|
}),
|
|
3821
|
-
dateMode: formatMessage(messages$
|
|
3838
|
+
dateMode: formatMessage(messages$7.month),
|
|
3822
3839
|
onLabelClick: onLabelClick,
|
|
3823
3840
|
onPreviousClick: this.selectPreviousMonth,
|
|
3824
3841
|
onNextClick: this.selectNextMonth
|
|
@@ -3853,11 +3870,11 @@ var DayCalendar$1 = injectIntl(DayCalendar);
|
|
|
3853
3870
|
|
|
3854
3871
|
const ROWS$1 = 3;
|
|
3855
3872
|
const COLS$1 = 4;
|
|
3856
|
-
const
|
|
3873
|
+
const MONTH_ONLY_FORMAT = {
|
|
3857
3874
|
month: 'short'
|
|
3858
3875
|
};
|
|
3859
3876
|
const MonthCalendarTable = ({
|
|
3860
|
-
selectedDate
|
|
3877
|
+
selectedDate,
|
|
3861
3878
|
min,
|
|
3862
3879
|
max,
|
|
3863
3880
|
viewYear,
|
|
@@ -3867,19 +3884,37 @@ const MonthCalendarTable = ({
|
|
|
3867
3884
|
const {
|
|
3868
3885
|
locale
|
|
3869
3886
|
} = useIntl();
|
|
3870
|
-
const getLink = month =>
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3887
|
+
const getLink = month => {
|
|
3888
|
+
return /*#__PURE__*/jsx(TableLink, {
|
|
3889
|
+
item: month,
|
|
3890
|
+
type: "month",
|
|
3891
|
+
title: formatDate(new Date(viewYear, month), locale, MONTH_ONLY_FORMAT),
|
|
3892
|
+
active: isActive(month),
|
|
3893
|
+
disabled: isDisabled(month),
|
|
3894
|
+
today: viewYear === new Date().getFullYear() && month === new Date().getMonth(),
|
|
3895
|
+
autofocus: autofocusMonth === month,
|
|
3896
|
+
onClick: onSelect
|
|
3897
|
+
});
|
|
3898
|
+
};
|
|
3899
|
+
const isActive = month => {
|
|
3900
|
+
return selectedDate && month === selectedDate.getMonth() && viewYear === selectedDate.getFullYear();
|
|
3901
|
+
};
|
|
3902
|
+
const isThisMonth = month => {
|
|
3903
|
+
return viewYear === new Date().getFullYear() && month === new Date().getMonth();
|
|
3904
|
+
};
|
|
3879
3905
|
const isDisabled = month => {
|
|
3880
3906
|
const date = new Date(viewYear, month);
|
|
3881
3907
|
return !!(min && date < new Date(min.getFullYear(), min.getMonth()) || max && date > new Date(max.getFullYear(), max.getMonth()));
|
|
3882
3908
|
};
|
|
3909
|
+
const autofocusMonth = (() => {
|
|
3910
|
+
const months = [...new Array(ROWS$1 * COLS$1)].map((_, index) => index);
|
|
3911
|
+
return getFocusableTime({
|
|
3912
|
+
isActive,
|
|
3913
|
+
isNow: isThisMonth,
|
|
3914
|
+
isDisabled,
|
|
3915
|
+
timeSpan: months
|
|
3916
|
+
});
|
|
3917
|
+
})();
|
|
3883
3918
|
return /*#__PURE__*/jsxs("table", {
|
|
3884
3919
|
className: "table table-condensed table-bordered tw-date-lookup-calendar np-text-body-default-bold m-b-0",
|
|
3885
3920
|
children: [/*#__PURE__*/jsx("thead", {
|
|
@@ -3946,7 +3981,7 @@ class MonthCalendar extends PureComponent {
|
|
|
3946
3981
|
} = this.props;
|
|
3947
3982
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
3948
3983
|
children: [/*#__PURE__*/jsx(DateHeader$1, {
|
|
3949
|
-
dateMode: formatMessage(messages$
|
|
3984
|
+
dateMode: formatMessage(messages$7.year),
|
|
3950
3985
|
label: formatDate(new Date(viewYear, 0), locale, {
|
|
3951
3986
|
year: 'numeric'
|
|
3952
3987
|
}),
|
|
@@ -3998,15 +4033,36 @@ const YearCalendarTable = ({
|
|
|
3998
4033
|
locale
|
|
3999
4034
|
} = useIntl();
|
|
4000
4035
|
const startYear = viewYear - viewYear % 20;
|
|
4001
|
-
const getLink = year =>
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4036
|
+
const getLink = year => {
|
|
4037
|
+
return /*#__PURE__*/jsx(TableLink, {
|
|
4038
|
+
item: year,
|
|
4039
|
+
type: "year",
|
|
4040
|
+
title: formatDate(new Date(year, 0), locale, YEAR_ONLY_FORMAT),
|
|
4041
|
+
active: isActive(year),
|
|
4042
|
+
disabled: isDisabled(year),
|
|
4043
|
+
today: isThisYear(year),
|
|
4044
|
+
autofocus: autofocusYear === year,
|
|
4045
|
+
onClick: onSelect
|
|
4046
|
+
});
|
|
4047
|
+
};
|
|
4048
|
+
const isActive = year => {
|
|
4049
|
+
return !!(selectedDate && year === selectedDate.getFullYear());
|
|
4050
|
+
};
|
|
4051
|
+
const isThisYear = year => {
|
|
4052
|
+
return year === new Date().getFullYear();
|
|
4053
|
+
};
|
|
4054
|
+
const isDisabled = year => {
|
|
4055
|
+
return !!(min && year < min.getFullYear() || max && year > max.getFullYear());
|
|
4056
|
+
};
|
|
4057
|
+
const autofocusYear = (() => {
|
|
4058
|
+
const years = [...new Array(ROWS * COLS)].map((_, index) => startYear + index);
|
|
4059
|
+
return getFocusableTime({
|
|
4060
|
+
isActive,
|
|
4061
|
+
isNow: isThisYear,
|
|
4062
|
+
isDisabled,
|
|
4063
|
+
timeSpan: years
|
|
4064
|
+
});
|
|
4065
|
+
})();
|
|
4010
4066
|
return /*#__PURE__*/jsxs("table", {
|
|
4011
4067
|
className: "table table-condensed table-bordered tw-date-lookup-calendar m-b-0",
|
|
4012
4068
|
children: [/*#__PURE__*/jsx("thead", {
|
|
@@ -4071,7 +4127,7 @@ class YearCalendar extends PureComponent {
|
|
|
4071
4127
|
} = this.props;
|
|
4072
4128
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
4073
4129
|
children: [/*#__PURE__*/jsx(DateHeader$1, {
|
|
4074
|
-
dateMode: formatMessage(messages$
|
|
4130
|
+
dateMode: formatMessage(messages$7.twentyYears),
|
|
4075
4131
|
onPreviousClick: this.selectPreviousYears,
|
|
4076
4132
|
onNextClick: this.selectNextYears
|
|
4077
4133
|
}), /*#__PURE__*/jsx(YearCalendarTable$1, {
|
|
@@ -4113,6 +4169,7 @@ class DateLookup extends PureComponent {
|
|
|
4113
4169
|
super(props);
|
|
4114
4170
|
this.state = {
|
|
4115
4171
|
selectedDate: getStartOfDay(props.value),
|
|
4172
|
+
originalDate: null,
|
|
4116
4173
|
min: getStartOfDay(props.min),
|
|
4117
4174
|
max: getStartOfDay(props.max),
|
|
4118
4175
|
viewMonth: (props.value || new Date()).getMonth(),
|
|
@@ -4175,12 +4232,22 @@ class DateLookup extends PureComponent {
|
|
|
4175
4232
|
onFocus();
|
|
4176
4233
|
}
|
|
4177
4234
|
};
|
|
4235
|
+
discard = () => {
|
|
4236
|
+
const {
|
|
4237
|
+
originalDate
|
|
4238
|
+
} = this.state;
|
|
4239
|
+
if (originalDate !== null) {
|
|
4240
|
+
this.props.onChange(originalDate);
|
|
4241
|
+
}
|
|
4242
|
+
this.close();
|
|
4243
|
+
};
|
|
4178
4244
|
close = () => {
|
|
4179
4245
|
const {
|
|
4180
4246
|
onBlur
|
|
4181
4247
|
} = this.props;
|
|
4182
4248
|
this.setState({
|
|
4183
|
-
open: false
|
|
4249
|
+
open: false,
|
|
4250
|
+
originalDate: null
|
|
4184
4251
|
});
|
|
4185
4252
|
if (onBlur) {
|
|
4186
4253
|
onBlur();
|
|
@@ -4188,7 +4255,8 @@ class DateLookup extends PureComponent {
|
|
|
4188
4255
|
};
|
|
4189
4256
|
handleKeyDown = event => {
|
|
4190
4257
|
const {
|
|
4191
|
-
open
|
|
4258
|
+
open,
|
|
4259
|
+
originalDate
|
|
4192
4260
|
} = this.state;
|
|
4193
4261
|
switch (event.keyCode) {
|
|
4194
4262
|
case KeyCodes.LEFT:
|
|
@@ -4224,6 +4292,9 @@ class DateLookup extends PureComponent {
|
|
|
4224
4292
|
event.preventDefault();
|
|
4225
4293
|
break;
|
|
4226
4294
|
case KeyCodes.ESCAPE:
|
|
4295
|
+
if (originalDate !== null) {
|
|
4296
|
+
this.props.onChange(originalDate);
|
|
4297
|
+
}
|
|
4227
4298
|
this.close();
|
|
4228
4299
|
event.preventDefault();
|
|
4229
4300
|
break;
|
|
@@ -4234,8 +4305,14 @@ class DateLookup extends PureComponent {
|
|
|
4234
4305
|
selectedDate,
|
|
4235
4306
|
min,
|
|
4236
4307
|
max,
|
|
4237
|
-
mode
|
|
4308
|
+
mode,
|
|
4309
|
+
originalDate
|
|
4238
4310
|
} = this.state;
|
|
4311
|
+
if (originalDate === null) {
|
|
4312
|
+
this.setState({
|
|
4313
|
+
originalDate: selectedDate
|
|
4314
|
+
});
|
|
4315
|
+
}
|
|
4239
4316
|
let date;
|
|
4240
4317
|
if (selectedDate) {
|
|
4241
4318
|
date = new Date(mode === MODE.YEAR ? selectedDate.getFullYear() + yearsToAdd : selectedDate.getFullYear(), mode === MODE.MONTH ? selectedDate.getMonth() + monthsToAdd : selectedDate.getMonth(), mode === MODE.DAY ? selectedDate.getDate() + daysToAdd : selectedDate.getDate());
|
|
@@ -4368,7 +4445,7 @@ class DateLookup extends PureComponent {
|
|
|
4368
4445
|
open: open,
|
|
4369
4446
|
className: "tw-date-lookup-menu",
|
|
4370
4447
|
position: Position.BOTTOM,
|
|
4371
|
-
onClose: this.
|
|
4448
|
+
onClose: this.discard,
|
|
4372
4449
|
children: this.getCalendar()
|
|
4373
4450
|
})]
|
|
4374
4451
|
});
|
|
@@ -5702,7 +5779,7 @@ const Stepper = ({
|
|
|
5702
5779
|
});
|
|
5703
5780
|
};
|
|
5704
5781
|
|
|
5705
|
-
var messages$
|
|
5782
|
+
var messages$6 = defineMessages({
|
|
5706
5783
|
back: {
|
|
5707
5784
|
id: "neptune.FlowNavigation.back"
|
|
5708
5785
|
}
|
|
@@ -5794,7 +5871,7 @@ const FlowNavigation = ({
|
|
|
5794
5871
|
}),
|
|
5795
5872
|
leftContent: /*#__PURE__*/jsxs(Fragment, {
|
|
5796
5873
|
children: [isSmall && displayGoBack ? /*#__PURE__*/jsx(BackButton$1, {
|
|
5797
|
-
"aria-label": intl.formatMessage(messages$
|
|
5874
|
+
"aria-label": intl.formatMessage(messages$6.back),
|
|
5798
5875
|
onClick: onGoBack
|
|
5799
5876
|
}) : logo, isSmall && /*#__PURE__*/jsx(AnimatedLabel, {
|
|
5800
5877
|
className: "m-x-1",
|
|
@@ -6061,7 +6138,7 @@ const Popover$1 = ({
|
|
|
6061
6138
|
children: /*#__PURE__*/jsxs("div", {
|
|
6062
6139
|
className: isModern ? 'np-popover__content np-text-default-body' : 'np-popover__content',
|
|
6063
6140
|
"aria-hidden": !open,
|
|
6064
|
-
role: "
|
|
6141
|
+
role: "dialog",
|
|
6065
6142
|
children: [title && /*#__PURE__*/jsx(Title, {
|
|
6066
6143
|
type: Typography.TITLE_BODY,
|
|
6067
6144
|
className: "m-b-1",
|
|
@@ -6100,6 +6177,12 @@ const deprecatedPlacements = {
|
|
|
6100
6177
|
};
|
|
6101
6178
|
var Popover$2 = Popover$1;
|
|
6102
6179
|
|
|
6180
|
+
var messages$5 = defineMessages({
|
|
6181
|
+
ariaLabel: {
|
|
6182
|
+
id: "neptune.Info.ariaLabel"
|
|
6183
|
+
}
|
|
6184
|
+
});
|
|
6185
|
+
|
|
6103
6186
|
const Info = ({
|
|
6104
6187
|
className = undefined,
|
|
6105
6188
|
content = undefined,
|
|
@@ -6110,7 +6193,9 @@ const Info = ({
|
|
|
6110
6193
|
'aria-label': ariaLabel,
|
|
6111
6194
|
preferredPlacement = Position.BOTTOM
|
|
6112
6195
|
}) => {
|
|
6196
|
+
const intl = useIntl();
|
|
6113
6197
|
const [open, setOpen] = useState(false);
|
|
6198
|
+
ariaLabel ??= intl.formatMessage(messages$5.ariaLabel);
|
|
6114
6199
|
const isModal = presentation === InfoPresentation.MODAL;
|
|
6115
6200
|
const isSmall = size === Size.SMALL;
|
|
6116
6201
|
const buttonProps = {
|
|
@@ -10752,6 +10837,7 @@ var en = {
|
|
|
10752
10837
|
"neptune.DateLookup.twentyYears": "20 years",
|
|
10753
10838
|
"neptune.DateLookup.year": "year",
|
|
10754
10839
|
"neptune.FlowNavigation.back": "back to previous step",
|
|
10840
|
+
"neptune.Info.ariaLabel": "More information",
|
|
10755
10841
|
"neptune.Link.opensInNewTab": "(opens in new tab)",
|
|
10756
10842
|
"neptune.MoneyInput.Select.placeholder": "Select an option...",
|
|
10757
10843
|
"neptune.Select.searchPlaceholder": "Search...",
|
|
@@ -11353,7 +11439,6 @@ const Summary = ({
|
|
|
11353
11439
|
help,
|
|
11354
11440
|
icon,
|
|
11355
11441
|
illustration = null,
|
|
11356
|
-
// @ts-expect-error help is old and deprecated prop
|
|
11357
11442
|
info = help,
|
|
11358
11443
|
status,
|
|
11359
11444
|
title
|
|
@@ -12390,6 +12475,7 @@ const Option = props => {
|
|
|
12390
12475
|
children: /*#__PURE__*/jsxs("a", {
|
|
12391
12476
|
className: "dropdown-item",
|
|
12392
12477
|
href: "#",
|
|
12478
|
+
tabIndex: -1,
|
|
12393
12479
|
onClick: onClick,
|
|
12394
12480
|
children: [/*#__PURE__*/jsx("span", {
|
|
12395
12481
|
children: hightlight(label, query)
|