@transferwise/components 0.0.0-experimental-cbb427b → 0.0.0-experimental-53fa20a

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 (86) hide show
  1. package/build/index.esm.js +94 -133
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +94 -133
  4. package/build/index.js.map +1 -1
  5. package/build/types/common/dateUtils/getDayNames/getDayNames.d.ts +1 -1
  6. package/build/types/common/dateUtils/getDayNames/getDayNames.d.ts.map +1 -1
  7. package/build/types/common/dateUtils/getDayNames/index.d.ts +1 -1
  8. package/build/types/common/dateUtils/getDayNames/index.d.ts.map +1 -1
  9. package/build/types/common/dateUtils/getMonthNames/getMonthNames.d.ts +1 -1
  10. package/build/types/common/dateUtils/getMonthNames/getMonthNames.d.ts.map +1 -1
  11. package/build/types/common/dateUtils/getMonthNames/index.d.ts +1 -1
  12. package/build/types/common/dateUtils/getMonthNames/index.d.ts.map +1 -1
  13. package/build/types/common/dateUtils/index.d.ts +6 -6
  14. package/build/types/common/dateUtils/index.d.ts.map +1 -1
  15. package/build/types/common/dateUtils/isDateValid/index.d.ts +1 -1
  16. package/build/types/common/dateUtils/isDateValid/index.d.ts.map +1 -1
  17. package/build/types/common/dateUtils/isDateValid/isDateValid.d.ts +2 -2
  18. package/build/types/common/dateUtils/isDateValid/isDateValid.d.ts.map +1 -1
  19. package/build/types/common/dateUtils/isMonthAndYearFormat/index.d.ts +1 -1
  20. package/build/types/common/dateUtils/isMonthAndYearFormat/index.d.ts.map +1 -1
  21. package/build/types/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.d.ts +1 -1
  22. package/build/types/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.d.ts.map +1 -1
  23. package/build/types/common/dateUtils/isWithinRange/index.d.ts +1 -1
  24. package/build/types/common/dateUtils/isWithinRange/index.d.ts.map +1 -1
  25. package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts +1 -1
  26. package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts.map +1 -1
  27. package/build/types/common/dateUtils/moveToWithinRange/index.d.ts +1 -1
  28. package/build/types/common/dateUtils/moveToWithinRange/index.d.ts.map +1 -1
  29. package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts +1 -1
  30. package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
  31. package/build/types/dateInput/DateInput.d.ts +30 -41
  32. package/build/types/dateInput/DateInput.d.ts.map +1 -1
  33. package/build/types/dateInput/DateInput.messages.d.ts +24 -33
  34. package/build/types/dateInput/DateInput.messages.d.ts.map +1 -1
  35. package/build/types/dateInput/index.d.ts +1 -1
  36. package/build/types/dateInput/index.d.ts.map +1 -1
  37. package/build/types/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.d.ts +1 -1
  38. package/build/types/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.d.ts.map +1 -1
  39. package/build/types/dateInput/utils/convertToLocalMidnight/index.d.ts +1 -1
  40. package/build/types/dateInput/utils/convertToLocalMidnight/index.d.ts.map +1 -1
  41. package/build/types/dateInput/utils/index.d.ts +1 -2
  42. package/build/types/dateInput/utils/index.d.ts.map +1 -1
  43. package/build/types/drawer/Drawer.d.ts.map +1 -1
  44. package/build/types/modal/Modal.d.ts.map +1 -1
  45. package/package.json +1 -1
  46. package/src/common/dateUtils/getDayNames/getDayNames.spec.js +2 -2
  47. package/src/common/dateUtils/getDayNames/{getDayNames.js → getDayNames.ts} +5 -2
  48. package/src/common/dateUtils/getMonthNames/getMonthNames.spec.js +9 -8
  49. package/src/common/dateUtils/getMonthNames/{getMonthNames.js → getMonthNames.ts} +5 -3
  50. package/src/common/dateUtils/isDateValid/{isDateValid.spec.js → isDateValid.spec.ts} +1 -1
  51. package/src/common/dateUtils/isDateValid/isDateValid.ts +13 -0
  52. package/src/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.spec.js +3 -7
  53. package/src/common/dateUtils/isMonthAndYearFormat/{isMonthAndYearFormat.js → isMonthAndYearFormat.ts} +1 -1
  54. package/src/common/dateUtils/isWithinRange/{isWithinRange.spec.js → isWithinRange.spec.ts} +0 -10
  55. package/src/common/dateUtils/isWithinRange/{isWithinRange.js → isWithinRange.ts} +1 -1
  56. package/src/common/dateUtils/moveToWithinRange/{moveToWithinRange.js → moveToWithinRange.ts} +2 -2
  57. package/src/dateInput/DateInput.spec.js +7 -56
  58. package/src/dateInput/DateInput.story.tsx +11 -8
  59. package/src/dateInput/{DateInput.js → DateInput.tsx} +113 -121
  60. package/src/dateInput/utils/convertToLocalMidnight/{convertToLocalMidnight.js → convertToLocalMidnight.ts} +1 -1
  61. package/src/dateInput/utils/{index.js → index.ts} +0 -1
  62. package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +1 -0
  63. package/src/drawer/Drawer.js +13 -2
  64. package/src/drawer/__snapshots__/Drawer.rtl.spec.js.snap +1 -0
  65. package/src/modal/Modal.tsx +6 -3
  66. package/src/popover/Popover.spec.js +16 -8
  67. package/src/popover/__snapshots__/Popover.spec.js.snap +0 -56
  68. package/build/types/dateInput/utils/explodeDate/explodeDate.d.ts +0 -6
  69. package/build/types/dateInput/utils/explodeDate/explodeDate.d.ts.map +0 -1
  70. package/build/types/dateInput/utils/explodeDate/index.d.ts +0 -2
  71. package/build/types/dateInput/utils/explodeDate/index.d.ts.map +0 -1
  72. package/src/common/dateUtils/isDateValid/isDateValid.js +0 -6
  73. package/src/dateInput/utils/explodeDate/explodeDate.js +0 -7
  74. package/src/dateInput/utils/explodeDate/explodeDate.spec.js +0 -11
  75. package/src/dateInput/utils/explodeDate/index.js +0 -1
  76. /package/src/common/dateUtils/getDayNames/{index.js → index.ts} +0 -0
  77. /package/src/common/dateUtils/getMonthNames/{index.js → index.ts} +0 -0
  78. /package/src/common/dateUtils/{index.js → index.ts} +0 -0
  79. /package/src/common/dateUtils/isDateValid/{index.js → index.ts} +0 -0
  80. /package/src/common/dateUtils/isMonthAndYearFormat/{index.js → index.ts} +0 -0
  81. /package/src/common/dateUtils/isWithinRange/{index.js → index.ts} +0 -0
  82. /package/src/common/dateUtils/moveToWithinRange/{index.js → index.ts} +0 -0
  83. /package/src/dateInput/{DateInput.messages.js → DateInput.messages.ts} +0 -0
  84. /package/src/dateInput/{index.js → index.ts} +0 -0
  85. /package/src/dateInput/utils/convertToLocalMidnight/{convertToLocalMidnight.spec.js → convertToLocalMidnight.spec.ts} +0 -0
  86. /package/src/dateInput/utils/convertToLocalMidnight/{index.js → index.ts} +0 -0
@@ -7,6 +7,7 @@ import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1,
7
7
  import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
8
8
  import PropTypes from 'prop-types';
9
9
  import { useTheme, ThemeProvider } from '@wise/components-theming';
10
+ import { formatDate, formatNumber, formatMoney, formatAmount } from '@transferwise/formatting';
10
11
  import { Transition, Listbox } from '@headlessui/react';
11
12
  import mergeProps from 'merge-props';
12
13
  import mergeRefs from 'react-merge-refs';
@@ -14,7 +15,6 @@ import { useSyncExternalStore } from 'use-sync-external-store/shim';
14
15
  import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, offset, flip, shift, size, autoUpdate } from '@floating-ui/react';
15
16
  import { FocusScope } from '@react-aria/focus';
16
17
  import { usePreventScroll } from '@react-aria/overlays';
17
- import { formatDate, formatNumber, formatMoney, formatAmount } from '@transferwise/formatting';
18
18
  import { CSSTransition } from 'react-transition-group';
19
19
  import { usePopper } from 'react-popper';
20
20
  import throttle from 'lodash.throttle';
@@ -1867,6 +1867,7 @@ const Drawer = ({
1867
1867
  const {
1868
1868
  isMobile
1869
1869
  } = useLayout();
1870
+ const titleId = useId();
1870
1871
  return /*#__PURE__*/jsx(Dimmer$1, {
1871
1872
  open: open,
1872
1873
  onClose: onClose,
@@ -1874,13 +1875,16 @@ const Drawer = ({
1874
1875
  open: open,
1875
1876
  position: isMobile ? Position.BOTTOM : position,
1876
1877
  children: /*#__PURE__*/jsxs("div", {
1877
- className: classNames('np-drawer', className),
1878
1878
  role: "dialog",
1879
+ "aria-modal": true,
1880
+ "aria-labelledby": headerTitle ? titleId : undefined,
1881
+ className: classNames('np-drawer', className),
1879
1882
  children: [/*#__PURE__*/jsxs("div", {
1880
1883
  className: classNames('np-drawer-header', {
1881
1884
  'np-drawer-header--withborder': headerTitle
1882
1885
  }),
1883
1886
  children: [headerTitle && /*#__PURE__*/jsx(Title, {
1887
+ id: titleId,
1884
1888
  type: Typography.TITLE_BODY,
1885
1889
  children: headerTitle
1886
1890
  }), /*#__PURE__*/jsx(CloseButton, {
@@ -2741,15 +2745,15 @@ function getDayNames(locale, format = 'short') {
2741
2745
  return days;
2742
2746
  }
2743
2747
 
2744
- function isWithinRange(date, min, max) {
2745
- return !date || (!min || date >= min) && (!max || date <= max);
2746
- }
2747
-
2748
2748
  // Makes sure that date is between min and max dates, returns a cloned min or max
2749
2749
  function moveToWithinRange(date, min, max) {
2750
2750
  return isWithinRange(date, min, max) ? date : new Date(min && date < min ? +min : +max);
2751
2751
  }
2752
2752
 
2753
+ function isWithinRange(date, min, max) {
2754
+ return !date || (!min || date >= min) && (!max || date <= max);
2755
+ }
2756
+
2753
2757
  const getMonthNames = (locale, format = 'long') => {
2754
2758
  const months = [];
2755
2759
  const date = new Date(2018, 0, 1);
@@ -2763,9 +2767,17 @@ const getMonthNames = (locale, format = 'long') => {
2763
2767
  return months;
2764
2768
  };
2765
2769
 
2766
- const isDateValid = date => validDateObject(date) || validDateString(date);
2767
- const validDateString = dateString => typeof dateString === 'string' && validDateObject(new Date(dateString));
2768
- const validDateObject = dateObject => dateObject instanceof Date && !isNaN(dateObject); // eslint-disable-line no-restricted-globals
2770
+ const isDateValid = date => {
2771
+ if (date === null) {
2772
+ return false;
2773
+ } else if (date instanceof Date) {
2774
+ return validDateObject(date);
2775
+ } else {
2776
+ return validDateString(date);
2777
+ }
2778
+ };
2779
+ const validDateString = dateString => validDateObject(new Date(dateString));
2780
+ const validDateObject = dateObject => !isNaN(dateObject.getTime());
2769
2781
 
2770
2782
  const isMonthAndYearFormat = dateString => validDateString(dateString) && dateString.split('-').length < 3;
2771
2783
 
@@ -2787,48 +2799,31 @@ var messages$9 = defineMessages({
2787
2799
  }
2788
2800
  });
2789
2801
 
2790
- const explodeDate = date => {
2791
- const year = date.getFullYear();
2792
- const month = date.getMonth();
2793
- const day = date.getDate();
2794
- return {
2795
- year,
2796
- month,
2797
- day
2798
- };
2799
- };
2800
-
2801
2802
  const convertToLocalMidnight = date => {
2802
2803
  const utcDate = new Date(date.split('T')[0]); // using YYYY-MM-DD creates UTC date
2803
-
2804
2804
  return new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate());
2805
2805
  };
2806
2806
 
2807
2807
  const MonthBeforeDay = new Set(['en-US', 'ja-JP']);
2808
- const INITIAL_DEFAULT_STATE = {
2809
- year: null,
2810
- month: null,
2811
- day: null
2812
- };
2813
2808
  const DateInput = ({
2814
2809
  'aria-labelledby': ariaLabelledBy,
2815
2810
  'aria-label': ariaLabel,
2816
- disabled,
2817
- size,
2811
+ disabled = false,
2812
+ size = Size.MEDIUM,
2818
2813
  value,
2819
2814
  dayLabel,
2820
2815
  dayAutoComplete,
2821
2816
  monthLabel,
2822
2817
  yearLabel,
2823
2818
  yearAutoComplete,
2824
- monthFormat,
2825
- mode,
2819
+ monthFormat = MonthFormat.LONG,
2820
+ mode = DateMode.DAY_MONTH_YEAR,
2826
2821
  onChange,
2827
2822
  onFocus,
2828
2823
  onBlur,
2829
2824
  placeholders,
2830
2825
  id,
2831
- selectProps
2826
+ selectProps = {}
2832
2827
  }) => {
2833
2828
  const {
2834
2829
  locale,
@@ -2840,20 +2835,30 @@ const DateInput = ({
2840
2835
  }
2841
2836
  return null;
2842
2837
  };
2843
- const getExplodedDate = unit => {
2844
- let explodedDate = INITIAL_DEFAULT_STATE;
2838
+ const getInitialDate = unit => {
2845
2839
  if (value && isDateValid(value)) {
2846
2840
  const dateObject = getDateObject();
2847
- explodedDate = explodeDate(dateObject);
2848
- if (isMonthAndYearFormat(value)) {
2849
- explodedDate.day = null;
2841
+ if (typeof value === 'string' && isMonthAndYearFormat(value) && unit === 'day') {
2842
+ return null;
2843
+ }
2844
+ if (dateObject !== null) {
2845
+ switch (unit) {
2846
+ case 'year':
2847
+ return dateObject.getFullYear();
2848
+ case 'month':
2849
+ return dateObject.getMonth();
2850
+ case 'day':
2851
+ return dateObject.getDate();
2852
+ default:
2853
+ return null;
2854
+ }
2850
2855
  }
2851
2856
  }
2852
- return explodedDate[unit];
2857
+ return null;
2853
2858
  };
2854
- const [day, setDay] = useState(() => getExplodedDate('day'));
2855
- const [month, setMonth] = useState(() => getExplodedDate('month'));
2856
- const [year, setYear] = useState(() => getExplodedDate('year'));
2859
+ const [day, setDay] = useState(() => getInitialDate('day'));
2860
+ const [month, setMonth] = useState(() => getInitialDate('month'));
2861
+ const [year, setYear] = useState(() => getInitialDate('year'));
2857
2862
  const [lastBroadcastedValue, setLastBroadcastedValue] = useState(getDateObject);
2858
2863
  dayLabel = dayLabel || formatMessage(messages$9.dayLabel);
2859
2864
  monthLabel = monthLabel || formatMessage(messages$9.monthLabel);
@@ -2876,7 +2881,6 @@ const DateInput = ({
2876
2881
  }
2877
2882
  };
2878
2883
  const getSelectElement = () => {
2879
- const monthOptions = getMonthsOptions();
2880
2884
  return /*#__PURE__*/jsxs("label", {
2881
2885
  className: "d-flex flex-column",
2882
2886
  children: [/*#__PURE__*/jsx("span", {
@@ -2885,70 +2889,60 @@ const DateInput = ({
2885
2889
  }), /*#__PURE__*/jsx(SelectInput, {
2886
2890
  name: "month",
2887
2891
  disabled: disabled,
2888
- placeholder: placeholders.month,
2889
- items: monthOptions,
2892
+ placeholder: placeholders?.month,
2893
+ items: Array.from({
2894
+ length: 12
2895
+ }, (_, index) => ({
2896
+ type: 'option',
2897
+ value: index
2898
+ })),
2890
2899
  size: size,
2891
- value: monthOptions.find(item => item.value.value === month)?.value,
2892
- renderValue: ({
2893
- label
2894
- }) => /*#__PURE__*/jsx(SelectInputOptionContent, {
2895
- title: label
2900
+ value: month,
2901
+ renderValue: selectedValue => /*#__PURE__*/jsx(SelectInputOptionContent, {
2902
+ title: getMonthNames(locale, monthFormat)[selectedValue]
2896
2903
  }),
2897
2904
  onChange: selectedValue => handleMonthChange(selectedValue),
2898
2905
  ...selectProps
2899
2906
  })]
2900
2907
  });
2901
2908
  };
2902
- const getMonthsOptions = () => {
2903
- const options = [];
2904
- const months = getMonthNames(locale, monthFormat);
2905
- months.forEach((label, index) => {
2906
- options.push({
2907
- type: 'option',
2908
- value: {
2909
- label,
2910
- value: index
2911
- }
2912
- });
2913
- });
2914
- return options;
2915
- };
2916
2909
  const handleInternalValue = (newDay = day, newMonth = month, newYear = year) => {
2917
- const dateValue = newDay != null && newMonth != null && newYear != null ? new Date(newYear, newMonth, newDay) : null;
2918
- const newValue = isDateValid(dateValue) ? dateValue : null;
2919
- if (!newValue) {
2920
- broadcastNewValue(INITIAL_DEFAULT_STATE);
2910
+ if (newDay == null || newMonth == null || newYear == null) {
2911
+ broadcastNewValue(null);
2912
+ return;
2913
+ }
2914
+ const dateValue = new Date(newYear, newMonth, newDay);
2915
+ if (!isDateValid(dateValue)) {
2916
+ broadcastNewValue(null);
2917
+ return;
2921
2918
  }
2922
2919
  if (mode === DateMode.MONTH_YEAR) {
2923
- if (newMonth >= 0 && newYear && (newMonth !== month || newYear !== year)) {
2924
- broadcastNewValue(newValue);
2920
+ if (newMonth !== month || newYear !== year) {
2921
+ broadcastNewValue(dateValue);
2925
2922
  }
2926
- } else if (newDay && newMonth >= 0 && newYear && (newDay !== day || newMonth !== month || newYear !== year)) {
2927
- broadcastNewValue(newValue);
2923
+ } else if (newDay !== day || newMonth !== month || newYear !== year) {
2924
+ broadcastNewValue(dateValue);
2928
2925
  }
2929
2926
  };
2930
2927
  const handleDayChange = event => {
2931
2928
  const {
2932
2929
  checkedDay
2933
- } = checkDate(event.target.value, month, year);
2930
+ } = checkDate(Number.parseInt(event.target.value, 10), month, year);
2934
2931
  setDay(checkedDay);
2935
2932
  handleInternalValue(checkedDay, month, year);
2936
2933
  };
2937
- const handleMonthChange = selectedValue => {
2938
- if (!selectedValue) {
2934
+ const handleMonthChange = selectedMonth => {
2935
+ if (selectedMonth === null) {
2939
2936
  setMonth(null);
2940
2937
  handleInternalValue(day, null, year);
2941
2938
  return;
2942
2939
  }
2943
- const selectedMonth = selectedValue ? selectedValue.value : 0;
2944
2940
  const {
2945
2941
  checkedDay
2946
2942
  } = checkDate(day, selectedMonth, year);
2947
2943
  setMonth(selectedMonth);
2948
- if (day) {
2949
- if (checkedDay !== day) {
2950
- setDay(checkedDay);
2951
- }
2944
+ if (day && checkedDay !== day) {
2945
+ setDay(checkedDay);
2952
2946
  }
2953
2947
  handleInternalValue(checkedDay, selectedMonth, year);
2954
2948
  };
@@ -2959,35 +2953,35 @@ const DateInput = ({
2959
2953
  // Correct day based on year and month.
2960
2954
  const {
2961
2955
  checkedDay
2962
- } = checkDate(day, month, newValue);
2963
- if (day) {
2964
- if (checkedDay !== day) {
2965
- setDay(checkedDay);
2966
- }
2956
+ } = checkDate(day, month, Number.parseInt(newValue, 10));
2957
+ if (day && checkedDay !== day) {
2958
+ setDay(checkedDay);
2967
2959
  }
2968
- setYear(slicedYear);
2969
- handleInternalValue(checkedDay, month, slicedYear);
2960
+ setYear(Number.parseInt(slicedYear, 10));
2961
+ handleInternalValue(checkedDay, month, Number.parseInt(slicedYear, 10));
2970
2962
  } else {
2971
- setYear(slicedYear);
2963
+ setYear(Number.parseInt(slicedYear, 10));
2972
2964
  handleInternalValue(day, month, null);
2973
2965
  }
2974
2966
  };
2975
2967
  const broadcastNewValue = newValue => {
2976
2968
  if (newValue !== lastBroadcastedValue) {
2977
2969
  setLastBroadcastedValue(newValue);
2978
- onChange(getDateAsString(newValue) || null);
2970
+ onChange(newValue != null ? getDateAsString(newValue) : null);
2971
+ } else if (newValue === null) {
2972
+ onChange(null);
2979
2973
  }
2980
2974
  };
2981
2975
  const checkDate = (newDay = null, newMonth = 0, newYear = null) => {
2982
2976
  let checkedDay = newDay;
2983
- const maxDay = new Date(newYear || 2000, newMonth + 1, 0).getDate();
2977
+ const maxDay = new Date(newYear || 2000, newMonth != null ? newMonth + 1 : 1, 0).getDate();
2984
2978
  if (!newDay) {
2985
2979
  checkedDay = null;
2986
2980
  }
2987
- if (newDay && newDay < 0 || newDay === '00') {
2981
+ if (newDay && newDay < 0) {
2988
2982
  checkedDay = 1;
2989
2983
  }
2990
- if (newDay && newMonth || newDay > 31) {
2984
+ if (newDay && newMonth || newDay && newDay > 31) {
2991
2985
  checkedDay = newDay > maxDay ? maxDay : newDay;
2992
2986
  }
2993
2987
  return {
@@ -3007,8 +3001,10 @@ const DateInput = ({
3007
3001
  id: id,
3008
3002
  "aria-labelledby": ariaLabelledBy,
3009
3003
  "aria-label": ariaLabel,
3010
- onFocus: event => shouldPropagateOnFocus(event) ? onFocus && onFocus() : event.stopPropagation(),
3011
- onBlur: event => shouldPropagateOnBlur(event) ? onBlur && onBlur() : event.stopPropagation(),
3004
+ role: "group" // Add role attribute to indicate container for interactive elements
3005
+ ,
3006
+ onFocus: event => shouldPropagateOnFocus(event) ? onFocus && onFocus(event) : event.stopPropagation(),
3007
+ onBlur: event => shouldPropagateOnBlur(event) ? onBlur && onBlur(event) : event.stopPropagation(),
3012
3008
  children: /*#__PURE__*/jsxs("div", {
3013
3009
  className: "row",
3014
3010
  children: [monthBeforeDay && /*#__PURE__*/jsx("div", {
@@ -3061,7 +3057,6 @@ const DateInput = ({
3061
3057
  })
3062
3058
  });
3063
3059
  };
3064
-
3065
3060
  // Should only propagate if the relatedTarget is not part of this DateInput component.
3066
3061
  function shouldPropagateOnFocus({
3067
3062
  target,
@@ -3071,7 +3066,6 @@ function shouldPropagateOnFocus({
3071
3066
  const relatedParent = relatedTarget && relatedTarget.closest('.tw-date');
3072
3067
  return targetParent !== relatedParent;
3073
3068
  }
3074
-
3075
3069
  // Should only propagate if the relatedTarget or the activeElement is not part of this DateInput component.
3076
3070
  function shouldPropagateOnBlur({
3077
3071
  target,
@@ -3088,42 +3082,6 @@ function shouldPropagateOnBlur({
3088
3082
  const focusElementParent = focusElement && focusElement.closest('.tw-date');
3089
3083
  return blurElementParent !== focusElementParent;
3090
3084
  }
3091
- DateInput.propTypes = {
3092
- 'aria-label': PropTypes.string,
3093
- 'aria-labelledby': PropTypes.string,
3094
- disabled: PropTypes.bool,
3095
- size: PropTypes.oneOf(['sm', 'md', 'lg']),
3096
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
3097
- onChange: PropTypes.func.isRequired,
3098
- onFocus: PropTypes.func,
3099
- onBlur: PropTypes.func,
3100
- dayLabel: PropTypes.string,
3101
- dayAutoComplete: PropTypes.string,
3102
- monthLabel: PropTypes.string,
3103
- yearLabel: PropTypes.string,
3104
- yearAutoComplete: PropTypes.string,
3105
- monthFormat: PropTypes.oneOf(['long', 'short']),
3106
- mode: PropTypes.oneOf(['day-month-year', 'month-year']),
3107
- placeholders: PropTypes.shape({
3108
- day: PropTypes.node,
3109
- month: PropTypes.node,
3110
- year: PropTypes.node
3111
- }),
3112
- id: PropTypes.string,
3113
- selectProps: PropTypes.object
3114
- };
3115
- DateInput.defaultProps = {
3116
- disabled: false,
3117
- size: Size.MEDIUM,
3118
- value: null,
3119
- onFocus: null,
3120
- onBlur: null,
3121
- monthFormat: MonthFormat.LONG,
3122
- mode: DateMode.DAY_MONTH_YEAR,
3123
- id: '',
3124
- selectProps: {}
3125
- };
3126
- var DateInput$1 = DateInput;
3127
3085
 
3128
3086
  const POPOVER_OFFSET = [0, 16];
3129
3087
  // By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space
@@ -5922,6 +5880,7 @@ const Modal = ({
5922
5880
  const isCompact = checkSpecialClasses('compact');
5923
5881
  const noDivider = checkSpecialClasses('no-divider');
5924
5882
  const contentReference = useRef(null);
5883
+ const titleId = useId();
5925
5884
  return !isMedium ? /*#__PURE__*/jsx(Drawer$1, {
5926
5885
  open: open,
5927
5886
  headerTitle: title,
@@ -5949,11 +5908,12 @@ const Modal = ({
5949
5908
  className: classNames('tw-modal', 'd-flex', 'fade', 'outline-none', scroll === Scroll.CONTENT && 'tw-modal--scrollable', className),
5950
5909
  ...otherProps,
5951
5910
  children: /*#__PURE__*/jsx("div", {
5911
+ role: "dialog",
5912
+ "aria-modal": true,
5913
+ "aria-labelledby": titleId,
5952
5914
  className: classNames('tw-modal-dialog', 'd-flex', {
5953
5915
  [`tw-modal-${size}`]: size
5954
5916
  }),
5955
- "aria-modal": true,
5956
- role: "dialog",
5957
5917
  children: /*#__PURE__*/jsxs("div", {
5958
5918
  className: classNames('tw-modal-content', 'd-flex', 'flex-column', 'justify-content-between', {
5959
5919
  'tw-modal-compact': isCompact,
@@ -5964,6 +5924,7 @@ const Modal = ({
5964
5924
  'modal--withoutborder': !title || noDivider
5965
5925
  }),
5966
5926
  children: [/*#__PURE__*/jsx(Title, {
5927
+ id: titleId,
5967
5928
  type: Typography.TITLE_BODY,
5968
5929
  className: "tw-modal-title",
5969
5930
  children: title
@@ -15420,5 +15381,5 @@ const translations = {
15420
15381
  'zh-HK': zhHK
15421
15382
  };
15422
15383
 
15423
- export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton$1 as CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput$1 as DateInput, DateLookup$1 as DateLookup, DateMode, Decision$1 as Decision, Presentation as DecisionPresentation, Type as DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList$1 as InstructionsList, LanguageProvider, Layout$1 as Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$2 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider$1 as Provider, RTL_LANGUAGES, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type$1 as Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
15384
+ export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton$1 as CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup$1 as DateLookup, DateMode, Decision$1 as Decision, Presentation as DecisionPresentation, Type as DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList$1 as InstructionsList, LanguageProvider, Layout$1 as Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$2 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider$1 as Provider, RTL_LANGUAGES, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type$1 as Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
15424
15385
  //# sourceMappingURL=index.esm.js.map