@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.
Files changed (54) hide show
  1. package/build/i18n/en.json +1 -0
  2. package/build/index.esm.js +185 -99
  3. package/build/index.esm.js.map +1 -1
  4. package/build/index.js +185 -99
  5. package/build/index.js.map +1 -1
  6. package/build/main.css +1 -1
  7. package/build/styles/dateLookup/DateLookup.css +1 -1
  8. package/build/styles/main.css +1 -1
  9. package/build/styles/typeahead/typeaheadOption/TypeaheadOption.css +1 -1
  10. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  11. package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts +9 -0
  12. package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts.map +1 -0
  13. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +1 -1
  14. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
  15. package/build/types/dateLookup/tableLink/TableLink.d.ts +14 -4
  16. package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
  17. package/build/types/dateLookup/tableLink/index.d.ts +1 -1
  18. package/build/types/dateLookup/tableLink/index.d.ts.map +1 -1
  19. package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
  20. package/build/types/info/Info.d.ts +1 -1
  21. package/build/types/info/Info.d.ts.map +1 -1
  22. package/build/types/info/Info.messages.d.ts +8 -0
  23. package/build/types/info/Info.messages.d.ts.map +1 -0
  24. package/build/types/summary/Summary.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/dateLookup/DateLookup.css +1 -1
  27. package/src/dateLookup/DateLookup.js +19 -4
  28. package/src/dateLookup/DateLookup.keyboardEvents.spec.js +12 -0
  29. package/src/dateLookup/DateLookup.less +39 -49
  30. package/src/dateLookup/DateLookup.story.js +8 -7
  31. package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +28 -3
  32. package/src/dateLookup/dayCalendar/table/DayCalendarTable.spec.js +25 -0
  33. package/src/dateLookup/getFocusableTime/getFocusable.spec.ts +40 -0
  34. package/src/dateLookup/getFocusableTime/getFocusableTime.tsx +14 -0
  35. package/src/dateLookup/monthCalendar/table/MonthCalendarTable.js +33 -20
  36. package/src/dateLookup/monthCalendar/table/MonthCalendarTable.spec.js +33 -0
  37. package/src/dateLookup/tableLink/TableLink.spec.js +6 -15
  38. package/src/dateLookup/tableLink/TableLink.tsx +79 -0
  39. package/src/dateLookup/yearCalendar/table/YearCalendarTable.js +33 -11
  40. package/src/dateLookup/yearCalendar/table/YearCalendarTable.spec.js +26 -0
  41. package/src/i18n/en.json +1 -0
  42. package/src/info/Info.messages.ts +8 -0
  43. package/src/info/Info.spec.js +10 -4
  44. package/src/info/Info.tsx +5 -2
  45. package/src/main.css +1 -1
  46. package/src/popover/Popover.js +1 -1
  47. package/src/popover/__snapshots__/Popover.spec.js.snap +2 -2
  48. package/src/summary/Summary.tsx +0 -1
  49. package/src/typeahead/Typeahead.story.js +6 -0
  50. package/src/typeahead/typeaheadOption/TypeaheadOption.css +1 -1
  51. package/src/typeahead/typeaheadOption/TypeaheadOption.js +1 -1
  52. package/src/typeahead/typeaheadOption/TypeaheadOption.less +2 -1
  53. package/src/dateLookup/tableLink/TableLink.js +0 -70
  54. /package/src/dateLookup/tableLink/{index.js → index.ts} +0 -0
package/build/index.js CHANGED
@@ -834,7 +834,7 @@ const ActionOption = ({
834
834
  });
835
835
  };
836
836
 
837
- var messages$b = reactIntl.defineMessages({
837
+ var messages$c = reactIntl.defineMessages({
838
838
  ariaLabel: {
839
839
  id: "neptune.CloseButton.ariaLabel"
840
840
  }
@@ -850,7 +850,7 @@ const CloseButton = /*#__PURE__*/React.forwardRef(function CloseButton({
850
850
  testId
851
851
  }, reference) {
852
852
  const intl = reactIntl.useIntl();
853
- ariaLabel ??= intl.formatMessage(messages$b.ariaLabel);
853
+ ariaLabel ??= intl.formatMessage(messages$c.ariaLabel);
854
854
  const Icon = filled ? icons.CrossCircleFill : icons.Cross;
855
855
  return /*#__PURE__*/jsxRuntime.jsx("button", {
856
856
  ref: reference,
@@ -870,7 +870,7 @@ const CloseButton = /*#__PURE__*/React.forwardRef(function CloseButton({
870
870
  });
871
871
  });
872
872
 
873
- var messages$a = reactIntl.defineMessages({
873
+ var messages$b = reactIntl.defineMessages({
874
874
  opensInNewTab: {
875
875
  id: "neptune.Link.opensInNewTab"
876
876
  }
@@ -899,7 +899,7 @@ const Link = ({
899
899
  onClick: onClick,
900
900
  ...props,
901
901
  children: [children, " ", isBlank && /*#__PURE__*/jsxRuntime.jsx(icons.NavigateAway, {
902
- title: formatMessage(messages$a.opensInNewTab)
902
+ title: formatMessage(messages$b.opensInNewTab)
903
903
  })]
904
904
  });
905
905
  };
@@ -2346,7 +2346,7 @@ ProcessIndicator.defaultProps = {
2346
2346
  };
2347
2347
  var ProcessIndicator$1 = ProcessIndicator;
2348
2348
 
2349
- var messages$9 = reactIntl.defineMessages({
2349
+ var messages$a = reactIntl.defineMessages({
2350
2350
  loadingAriaLabel: {
2351
2351
  id: "neptune.Button.loadingAriaLabel"
2352
2352
  }
@@ -2465,7 +2465,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
2465
2465
  className: classes,
2466
2466
  ...props,
2467
2467
  "aria-live": loading ? 'polite' : 'off',
2468
- "aria-label": loading ? intl.formatMessage(messages$9.loadingAriaLabel) : rest['aria-label'],
2468
+ "aria-label": loading ? intl.formatMessage(messages$a.loadingAriaLabel) : rest['aria-label'],
2469
2469
  children: [children, loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
2470
2470
  size: processIndicatorSize(),
2471
2471
  className: "btn-loader"
@@ -2758,7 +2758,7 @@ const Chip = ({
2758
2758
  }, value);
2759
2759
  };
2760
2760
 
2761
- var messages$8 = reactIntl.defineMessages({
2761
+ var messages$9 = reactIntl.defineMessages({
2762
2762
  ariaLabel: {
2763
2763
  id: "neptune.Chips.ariaLabel"
2764
2764
  }
@@ -2790,7 +2790,7 @@ const Chips = ({
2790
2790
  value: chip.value,
2791
2791
  label: chip.label,
2792
2792
  closeButton: {
2793
- 'aria-label': intl.formatMessage(messages$8.ariaLabel, {
2793
+ 'aria-label': intl.formatMessage(messages$9.ariaLabel, {
2794
2794
  choice: chip.label
2795
2795
  })
2796
2796
  },
@@ -2898,7 +2898,7 @@ const validDateObject = dateObject => dateObject instanceof Date && !isNaN(dateO
2898
2898
 
2899
2899
  const isMonthAndYearFormat = dateString => validDateString(dateString) && dateString.split('-').length < 3;
2900
2900
 
2901
- var messages$7 = reactIntl.defineMessages({
2901
+ var messages$8 = reactIntl.defineMessages({
2902
2902
  monthLabel: {
2903
2903
  id: "neptune.DateInput.month.label"
2904
2904
  },
@@ -2978,12 +2978,12 @@ const DateInput = ({
2978
2978
  const [month, setMonth] = React.useState(() => getExplodedDate('month'));
2979
2979
  const [year, setYear] = React.useState(() => getExplodedDate('year'));
2980
2980
  const [lastBroadcastedValue, setLastBroadcastedValue] = React.useState(getDateObject);
2981
- dayLabel = dayLabel || formatMessage(messages$7.dayLabel);
2982
- monthLabel = monthLabel || formatMessage(messages$7.monthLabel);
2983
- yearLabel = yearLabel || formatMessage(messages$7.yearLabel);
2981
+ dayLabel = dayLabel || formatMessage(messages$8.dayLabel);
2982
+ monthLabel = monthLabel || formatMessage(messages$8.monthLabel);
2983
+ yearLabel = yearLabel || formatMessage(messages$8.yearLabel);
2984
2984
  placeholders = {
2985
2985
  day: placeholders?.day || 'DD',
2986
- month: placeholders?.month || formatMessage(messages$7.monthLabel),
2986
+ month: placeholders?.month || formatMessage(messages$8.monthLabel),
2987
2987
  year: placeholders?.year || 'YYYY'
2988
2988
  };
2989
2989
  const getDateAsString = date => {
@@ -3516,7 +3516,7 @@ DateTrigger.defaultProps = {
3516
3516
  };
3517
3517
  var DateTrigger$1 = DateTrigger;
3518
3518
 
3519
- var messages$6 = reactIntl.defineMessages({
3519
+ var messages$7 = reactIntl.defineMessages({
3520
3520
  next: {
3521
3521
  id: "neptune.DateLookup.next"
3522
3522
  },
@@ -3562,7 +3562,7 @@ const DateHeader = ({
3562
3562
  children: /*#__PURE__*/jsxRuntime.jsx("button", {
3563
3563
  type: "button",
3564
3564
  className: `d-inline-flex ${buttonClasses}`,
3565
- "aria-label": `${intl.formatMessage(messages$6.previous)} ${dateMode}`,
3565
+ "aria-label": `${intl.formatMessage(messages$7.previous)} ${dateMode}`,
3566
3566
  onClick: onPreviousClick,
3567
3567
  children: /*#__PURE__*/jsxRuntime.jsx(Chevron$1, {
3568
3568
  orientation: exports.Position.LEFT,
@@ -3576,7 +3576,7 @@ const DateHeader = ({
3576
3576
  children: /*#__PURE__*/jsxRuntime.jsx("button", {
3577
3577
  type: "button",
3578
3578
  className: `tw-date-lookup-header-current ${buttonClasses}`,
3579
- "aria-label": intl.formatMessage(messages$6.goTo20YearView),
3579
+ "aria-label": intl.formatMessage(messages$7.goTo20YearView),
3580
3580
  onClick: onLabelClick,
3581
3581
  children: label
3582
3582
  })
@@ -3585,7 +3585,7 @@ const DateHeader = ({
3585
3585
  children: /*#__PURE__*/jsxRuntime.jsx("button", {
3586
3586
  type: "button",
3587
3587
  className: `d-inline-flex ${buttonClasses}`,
3588
- "aria-label": `${reactIntl.useIntl().formatMessage(messages$6.next)} ${dateMode}`,
3588
+ "aria-label": `${reactIntl.useIntl().formatMessage(messages$7.next)} ${dateMode}`,
3589
3589
  onClick: onNextClick,
3590
3590
  children: /*#__PURE__*/jsxRuntime.jsx(Chevron$1, {
3591
3591
  orientation: exports.Position.RIGHT,
@@ -3609,6 +3609,10 @@ DateHeader.defaultProps = {
3609
3609
  };
3610
3610
  var DateHeader$1 = DateHeader;
3611
3611
 
3612
+ function getFocusableTime(props) {
3613
+ 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));
3614
+ }
3615
+
3612
3616
  // NB! Using with UTC timestamp (YYYY-MM-DD) might lead to unexpected results, for example
3613
3617
  // getStartOfDay(new Date('1995-01-01')) in Los Angeles returns 31 Dec 1994, but in
3614
3618
  // in Singapore it is 1 Jan 1995.
@@ -3620,61 +3624,56 @@ function getStartOfDay(date) {
3620
3624
  return new Date(date.getFullYear(), date.getMonth(), date.getDate());
3621
3625
  }
3622
3626
 
3623
- class TableLink extends React.PureComponent {
3624
- onClick = event => {
3627
+ const TableLink = ({
3628
+ item,
3629
+ type,
3630
+ title,
3631
+ longTitle,
3632
+ active,
3633
+ disabled,
3634
+ today,
3635
+ autofocus,
3636
+ onClick
3637
+ }) => {
3638
+ const buttonRef = React.useRef(null);
3639
+ const intl = reactIntl.useIntl();
3640
+ React.useEffect(() => {
3641
+ if (autofocus) {
3642
+ setTimeout(() => {
3643
+ buttonRef.current?.focus();
3644
+ }, 0);
3645
+ }
3646
+ }, [autofocus]);
3647
+ const onCalendarClick = event => {
3625
3648
  event.preventDefault();
3626
- if (!this.props.disabled) {
3627
- this.props.onClick(this.props.item);
3649
+ if (!disabled) {
3650
+ onClick(item);
3628
3651
  }
3629
3652
  };
3630
- calculateAriaLabel = (longTitle, title, active, type, formatMessage) => {
3653
+ const calculateAriaLabel = () => {
3631
3654
  if (active) {
3632
- return `${longTitle || title}, ${formatMessage(messages$6.selected)} ${formatMessage(messages$6[type])}`;
3655
+ return `${longTitle || title || ''}, ${intl.formatMessage(messages$7.selected)} ${intl.formatMessage(messages$7[type])}`;
3633
3656
  }
3634
3657
  return longTitle || title;
3635
3658
  };
3636
- render() {
3637
- const {
3638
- item,
3639
- type,
3640
- title,
3641
- longTitle,
3642
- active,
3643
- disabled,
3644
- today,
3645
- intl: {
3646
- formatMessage
3647
- }
3648
- } = this.props;
3649
- return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
3650
- children: /*#__PURE__*/jsxRuntime.jsx("button", {
3651
- type: "button",
3652
- className: `tw-date-lookup-${type}-option ${active ? 'active' : ''} ${today ? 'today' : ''} np-text-body-default-bold`,
3653
- disabled: disabled,
3654
- "aria-label": this.calculateAriaLabel(longTitle, title, active, type, formatMessage),
3655
- "aria-pressed": active,
3656
- onClick: this.onClick,
3657
- children: title || item
3658
- })
3659
- });
3660
- }
3661
- }
3662
- TableLink.propTypes = {
3663
- item: PropTypes__default.default.number.isRequired,
3664
- // day (1-31), month (0-11) or year (2018 etc)
3665
- type: PropTypes__default.default.oneOf(['day', 'month', 'year']).isRequired,
3666
- title: PropTypes__default.default.string,
3667
- longTitle: PropTypes__default.default.string,
3668
- active: PropTypes__default.default.bool.isRequired,
3669
- disabled: PropTypes__default.default.bool.isRequired,
3670
- today: PropTypes__default.default.bool.isRequired,
3671
- onClick: PropTypes__default.default.func.isRequired
3672
- };
3673
- TableLink.defaultProps = {
3674
- title: null,
3675
- longTitle: null
3659
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
3660
+ children: /*#__PURE__*/jsxRuntime.jsx("button", {
3661
+ ref: buttonRef,
3662
+ type: "button",
3663
+ className: classNames__default.default(`tw-date-lookup-${type}-option np-text-body-default-bold`, {
3664
+ active: !!active
3665
+ }, {
3666
+ today: !!today
3667
+ }),
3668
+ disabled: disabled,
3669
+ tabIndex: autofocus ? 0 : -1,
3670
+ "aria-label": calculateAriaLabel(),
3671
+ "aria-pressed": active,
3672
+ onClick: onCalendarClick,
3673
+ children: title || item
3674
+ })
3675
+ });
3676
3676
  };
3677
- var TableLink$1 = reactIntl.injectIntl(TableLink);
3678
3677
 
3679
3678
  const SHORT_DAY_FORMAT = {
3680
3679
  day: 'numeric'
@@ -3745,6 +3744,22 @@ class DayCalendarTable extends React.PureComponent {
3745
3744
  } = this.props;
3746
3745
  return !!(selectedDate && +new Date(viewYear, viewMonth, day) === +selectedDate);
3747
3746
  };
3747
+ isToday = day => {
3748
+ const {
3749
+ viewMonth,
3750
+ viewYear
3751
+ } = this.props;
3752
+ return Number(getStartOfDay(new Date())) === Number(new Date(viewYear, viewMonth, day));
3753
+ };
3754
+ getAutofocusDay = weeks => {
3755
+ const days = weeks.flatMap(week => week);
3756
+ return getFocusableTime({
3757
+ isActive: this.isActive,
3758
+ isNow: this.isToday,
3759
+ isDisabled: this.isDisabled,
3760
+ timeSpan: days
3761
+ });
3762
+ };
3748
3763
  render() {
3749
3764
  const {
3750
3765
  viewMonth,
@@ -3754,12 +3769,13 @@ class DayCalendarTable extends React.PureComponent {
3754
3769
  }
3755
3770
  } = this.props;
3756
3771
  const weeks = this.getTableStructure();
3772
+ let autoFocusDay = this.getAutofocusDay(weeks, viewMonth, viewYear);
3757
3773
  return /*#__PURE__*/jsxRuntime.jsxs("table", {
3758
3774
  className: "table table-condensed table-bordered tw-date-lookup-calendar m-b-0",
3759
3775
  children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
3760
3776
  children: /*#__PURE__*/jsxRuntime.jsx("tr", {
3761
3777
  children: this.days.map((day, index) => /*#__PURE__*/jsxRuntime.jsxs("th", {
3762
- className: "text-xs-center np-text-body-default-bold",
3778
+ className: index > 4 ? 'text-xs-center np-text-body-default' : 'text-xs-center np-text-body-default-bold',
3763
3779
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
3764
3780
  className: "hidden-xs",
3765
3781
  children: /*#__PURE__*/jsxRuntime.jsx("abbr", {
@@ -3778,15 +3794,16 @@ class DayCalendarTable extends React.PureComponent {
3778
3794
  }), /*#__PURE__*/jsxRuntime.jsx("tbody", {
3779
3795
  children: weeks.map((week, weekIndex) => /*#__PURE__*/jsxRuntime.jsx("tr", {
3780
3796
  children: week.map((day, dayIndex) => /*#__PURE__*/jsxRuntime.jsx("td", {
3781
- className: dayIndex > 4 ? 'default' : '',
3782
- children: day && /*#__PURE__*/jsxRuntime.jsx(TableLink$1, {
3797
+ className: dayIndex > 4 ? 'weekend' : '',
3798
+ children: day && /*#__PURE__*/jsxRuntime.jsx(TableLink, {
3783
3799
  item: day,
3784
3800
  type: "day",
3785
3801
  title: formatting.formatDate(new Date(viewYear, viewMonth, day), locale, SHORT_DAY_FORMAT),
3802
+ autofocus: day === autoFocusDay,
3786
3803
  longTitle: formatting.formatDate(new Date(viewYear, viewMonth, day), locale),
3787
3804
  active: this.isActive(day),
3788
3805
  disabled: this.isDisabled(day),
3789
- today: +getStartOfDay(new Date()) === +new Date(viewYear, viewMonth, day),
3806
+ today: this.isToday(day),
3790
3807
  onClick: this.selectDay
3791
3808
  })
3792
3809
  }, dayIndex))
@@ -3852,7 +3869,7 @@ class DayCalendar extends React.PureComponent {
3852
3869
  month: monthFormat,
3853
3870
  year: 'numeric'
3854
3871
  }),
3855
- dateMode: formatMessage(messages$6.month),
3872
+ dateMode: formatMessage(messages$7.month),
3856
3873
  onLabelClick: onLabelClick,
3857
3874
  onPreviousClick: this.selectPreviousMonth,
3858
3875
  onNextClick: this.selectNextMonth
@@ -3887,11 +3904,11 @@ var DayCalendar$1 = reactIntl.injectIntl(DayCalendar);
3887
3904
 
3888
3905
  const ROWS$1 = 3;
3889
3906
  const COLS$1 = 4;
3890
- const MONTH_ONLY_FORMAY = {
3907
+ const MONTH_ONLY_FORMAT = {
3891
3908
  month: 'short'
3892
3909
  };
3893
3910
  const MonthCalendarTable = ({
3894
- selectedDate: selected,
3911
+ selectedDate,
3895
3912
  min,
3896
3913
  max,
3897
3914
  viewYear,
@@ -3901,19 +3918,37 @@ const MonthCalendarTable = ({
3901
3918
  const {
3902
3919
  locale
3903
3920
  } = reactIntl.useIntl();
3904
- const getLink = month => /*#__PURE__*/jsxRuntime.jsx(TableLink$1, {
3905
- item: month,
3906
- type: "month",
3907
- title: formatting.formatDate(new Date(viewYear, month), locale, MONTH_ONLY_FORMAY),
3908
- active: !!(selected && month === selected.getMonth() && viewYear === selected.getFullYear()),
3909
- disabled: isDisabled(month),
3910
- today: viewYear === new Date().getFullYear() && month === new Date().getMonth(),
3911
- onClick: onSelect
3912
- });
3921
+ const getLink = month => {
3922
+ return /*#__PURE__*/jsxRuntime.jsx(TableLink, {
3923
+ item: month,
3924
+ type: "month",
3925
+ title: formatting.formatDate(new Date(viewYear, month), locale, MONTH_ONLY_FORMAT),
3926
+ active: isActive(month),
3927
+ disabled: isDisabled(month),
3928
+ today: viewYear === new Date().getFullYear() && month === new Date().getMonth(),
3929
+ autofocus: autofocusMonth === month,
3930
+ onClick: onSelect
3931
+ });
3932
+ };
3933
+ const isActive = month => {
3934
+ return selectedDate && month === selectedDate.getMonth() && viewYear === selectedDate.getFullYear();
3935
+ };
3936
+ const isThisMonth = month => {
3937
+ return viewYear === new Date().getFullYear() && month === new Date().getMonth();
3938
+ };
3913
3939
  const isDisabled = month => {
3914
3940
  const date = new Date(viewYear, month);
3915
3941
  return !!(min && date < new Date(min.getFullYear(), min.getMonth()) || max && date > new Date(max.getFullYear(), max.getMonth()));
3916
3942
  };
3943
+ const autofocusMonth = (() => {
3944
+ const months = [...new Array(ROWS$1 * COLS$1)].map((_, index) => index);
3945
+ return getFocusableTime({
3946
+ isActive,
3947
+ isNow: isThisMonth,
3948
+ isDisabled,
3949
+ timeSpan: months
3950
+ });
3951
+ })();
3917
3952
  return /*#__PURE__*/jsxRuntime.jsxs("table", {
3918
3953
  className: "table table-condensed table-bordered tw-date-lookup-calendar np-text-body-default-bold m-b-0",
3919
3954
  children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
@@ -3980,7 +4015,7 @@ class MonthCalendar extends React.PureComponent {
3980
4015
  } = this.props;
3981
4016
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3982
4017
  children: [/*#__PURE__*/jsxRuntime.jsx(DateHeader$1, {
3983
- dateMode: formatMessage(messages$6.year),
4018
+ dateMode: formatMessage(messages$7.year),
3984
4019
  label: formatting.formatDate(new Date(viewYear, 0), locale, {
3985
4020
  year: 'numeric'
3986
4021
  }),
@@ -4032,15 +4067,36 @@ const YearCalendarTable = ({
4032
4067
  locale
4033
4068
  } = reactIntl.useIntl();
4034
4069
  const startYear = viewYear - viewYear % 20;
4035
- const getLink = year => /*#__PURE__*/jsxRuntime.jsx(TableLink$1, {
4036
- item: year,
4037
- type: "year",
4038
- title: formatting.formatDate(new Date(year, 0), locale, YEAR_ONLY_FORMAT),
4039
- active: !!(selectedDate && year === selectedDate.getFullYear()),
4040
- disabled: !!(min && year < min.getFullYear() || max && year > max.getFullYear()),
4041
- today: year === new Date().getFullYear(),
4042
- onClick: onSelect
4043
- });
4070
+ const getLink = year => {
4071
+ return /*#__PURE__*/jsxRuntime.jsx(TableLink, {
4072
+ item: year,
4073
+ type: "year",
4074
+ title: formatting.formatDate(new Date(year, 0), locale, YEAR_ONLY_FORMAT),
4075
+ active: isActive(year),
4076
+ disabled: isDisabled(year),
4077
+ today: isThisYear(year),
4078
+ autofocus: autofocusYear === year,
4079
+ onClick: onSelect
4080
+ });
4081
+ };
4082
+ const isActive = year => {
4083
+ return !!(selectedDate && year === selectedDate.getFullYear());
4084
+ };
4085
+ const isThisYear = year => {
4086
+ return year === new Date().getFullYear();
4087
+ };
4088
+ const isDisabled = year => {
4089
+ return !!(min && year < min.getFullYear() || max && year > max.getFullYear());
4090
+ };
4091
+ const autofocusYear = (() => {
4092
+ const years = [...new Array(ROWS * COLS)].map((_, index) => startYear + index);
4093
+ return getFocusableTime({
4094
+ isActive,
4095
+ isNow: isThisYear,
4096
+ isDisabled,
4097
+ timeSpan: years
4098
+ });
4099
+ })();
4044
4100
  return /*#__PURE__*/jsxRuntime.jsxs("table", {
4045
4101
  className: "table table-condensed table-bordered tw-date-lookup-calendar m-b-0",
4046
4102
  children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
@@ -4105,7 +4161,7 @@ class YearCalendar extends React.PureComponent {
4105
4161
  } = this.props;
4106
4162
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
4107
4163
  children: [/*#__PURE__*/jsxRuntime.jsx(DateHeader$1, {
4108
- dateMode: formatMessage(messages$6.twentyYears),
4164
+ dateMode: formatMessage(messages$7.twentyYears),
4109
4165
  onPreviousClick: this.selectPreviousYears,
4110
4166
  onNextClick: this.selectNextYears
4111
4167
  }), /*#__PURE__*/jsxRuntime.jsx(YearCalendarTable$1, {
@@ -4147,6 +4203,7 @@ class DateLookup extends React.PureComponent {
4147
4203
  super(props);
4148
4204
  this.state = {
4149
4205
  selectedDate: getStartOfDay(props.value),
4206
+ originalDate: null,
4150
4207
  min: getStartOfDay(props.min),
4151
4208
  max: getStartOfDay(props.max),
4152
4209
  viewMonth: (props.value || new Date()).getMonth(),
@@ -4209,12 +4266,22 @@ class DateLookup extends React.PureComponent {
4209
4266
  onFocus();
4210
4267
  }
4211
4268
  };
4269
+ discard = () => {
4270
+ const {
4271
+ originalDate
4272
+ } = this.state;
4273
+ if (originalDate !== null) {
4274
+ this.props.onChange(originalDate);
4275
+ }
4276
+ this.close();
4277
+ };
4212
4278
  close = () => {
4213
4279
  const {
4214
4280
  onBlur
4215
4281
  } = this.props;
4216
4282
  this.setState({
4217
- open: false
4283
+ open: false,
4284
+ originalDate: null
4218
4285
  });
4219
4286
  if (onBlur) {
4220
4287
  onBlur();
@@ -4222,7 +4289,8 @@ class DateLookup extends React.PureComponent {
4222
4289
  };
4223
4290
  handleKeyDown = event => {
4224
4291
  const {
4225
- open
4292
+ open,
4293
+ originalDate
4226
4294
  } = this.state;
4227
4295
  switch (event.keyCode) {
4228
4296
  case KeyCodes.LEFT:
@@ -4258,6 +4326,9 @@ class DateLookup extends React.PureComponent {
4258
4326
  event.preventDefault();
4259
4327
  break;
4260
4328
  case KeyCodes.ESCAPE:
4329
+ if (originalDate !== null) {
4330
+ this.props.onChange(originalDate);
4331
+ }
4261
4332
  this.close();
4262
4333
  event.preventDefault();
4263
4334
  break;
@@ -4268,8 +4339,14 @@ class DateLookup extends React.PureComponent {
4268
4339
  selectedDate,
4269
4340
  min,
4270
4341
  max,
4271
- mode
4342
+ mode,
4343
+ originalDate
4272
4344
  } = this.state;
4345
+ if (originalDate === null) {
4346
+ this.setState({
4347
+ originalDate: selectedDate
4348
+ });
4349
+ }
4273
4350
  let date;
4274
4351
  if (selectedDate) {
4275
4352
  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());
@@ -4402,7 +4479,7 @@ class DateLookup extends React.PureComponent {
4402
4479
  open: open,
4403
4480
  className: "tw-date-lookup-menu",
4404
4481
  position: exports.Position.BOTTOM,
4405
- onClose: this.close,
4482
+ onClose: this.discard,
4406
4483
  children: this.getCalendar()
4407
4484
  })]
4408
4485
  });
@@ -5736,7 +5813,7 @@ const Stepper = ({
5736
5813
  });
5737
5814
  };
5738
5815
 
5739
- var messages$5 = reactIntl.defineMessages({
5816
+ var messages$6 = reactIntl.defineMessages({
5740
5817
  back: {
5741
5818
  id: "neptune.FlowNavigation.back"
5742
5819
  }
@@ -5828,7 +5905,7 @@ const FlowNavigation = ({
5828
5905
  }),
5829
5906
  leftContent: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
5830
5907
  children: [isSmall && displayGoBack ? /*#__PURE__*/jsxRuntime.jsx(BackButton$1, {
5831
- "aria-label": intl.formatMessage(messages$5.back),
5908
+ "aria-label": intl.formatMessage(messages$6.back),
5832
5909
  onClick: onGoBack
5833
5910
  }) : logo, isSmall && /*#__PURE__*/jsxRuntime.jsx(AnimatedLabel, {
5834
5911
  className: "m-x-1",
@@ -6095,7 +6172,7 @@ const Popover$1 = ({
6095
6172
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
6096
6173
  className: isModern ? 'np-popover__content np-text-default-body' : 'np-popover__content',
6097
6174
  "aria-hidden": !open,
6098
- role: "tooltip",
6175
+ role: "dialog",
6099
6176
  children: [title && /*#__PURE__*/jsxRuntime.jsx(Title, {
6100
6177
  type: exports.Typography.TITLE_BODY,
6101
6178
  className: "m-b-1",
@@ -6134,6 +6211,12 @@ const deprecatedPlacements = {
6134
6211
  };
6135
6212
  var Popover$2 = Popover$1;
6136
6213
 
6214
+ var messages$5 = reactIntl.defineMessages({
6215
+ ariaLabel: {
6216
+ id: "neptune.Info.ariaLabel"
6217
+ }
6218
+ });
6219
+
6137
6220
  const Info = ({
6138
6221
  className = undefined,
6139
6222
  content = undefined,
@@ -6144,7 +6227,9 @@ const Info = ({
6144
6227
  'aria-label': ariaLabel,
6145
6228
  preferredPlacement = exports.Position.BOTTOM
6146
6229
  }) => {
6230
+ const intl = reactIntl.useIntl();
6147
6231
  const [open, setOpen] = React.useState(false);
6232
+ ariaLabel ??= intl.formatMessage(messages$5.ariaLabel);
6148
6233
  const isModal = presentation === exports.InfoPresentation.MODAL;
6149
6234
  const isSmall = size === exports.Size.SMALL;
6150
6235
  const buttonProps = {
@@ -10786,6 +10871,7 @@ var en = {
10786
10871
  "neptune.DateLookup.twentyYears": "20 years",
10787
10872
  "neptune.DateLookup.year": "year",
10788
10873
  "neptune.FlowNavigation.back": "back to previous step",
10874
+ "neptune.Info.ariaLabel": "More information",
10789
10875
  "neptune.Link.opensInNewTab": "(opens in new tab)",
10790
10876
  "neptune.MoneyInput.Select.placeholder": "Select an option...",
10791
10877
  "neptune.Select.searchPlaceholder": "Search...",
@@ -11387,7 +11473,6 @@ const Summary = ({
11387
11473
  help,
11388
11474
  icon,
11389
11475
  illustration = null,
11390
- // @ts-expect-error help is old and deprecated prop
11391
11476
  info = help,
11392
11477
  status,
11393
11478
  title
@@ -12424,6 +12509,7 @@ const Option = props => {
12424
12509
  children: /*#__PURE__*/jsxRuntime.jsxs("a", {
12425
12510
  className: "dropdown-item",
12426
12511
  href: "#",
12512
+ tabIndex: -1,
12427
12513
  onClick: onClick,
12428
12514
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
12429
12515
  children: hightlight(label, query)