@transferwise/components 45.25.0 → 45.25.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.
@@ -7,19 +7,19 @@ import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1,
7
7
  import PropTypes from 'prop-types';
8
8
  import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
9
9
  import { useTheme, ThemeProvider } from '@wise/components-theming';
10
- import { formatDate, formatNumber, formatMoney, formatAmount } from '@transferwise/formatting';
11
- import throttle from 'lodash.throttle';
12
- import { CSSTransition } from 'react-transition-group';
13
- import { createPortal } from 'react-dom';
14
- import { FocusScope } from '@react-aria/focus';
15
- import mergeRefs from 'react-merge-refs';
16
- import { useSyncExternalStore } from 'use-sync-external-store/shim';
17
- import { isUndefined, isKey, isNumber, isEmpty, isNull, isArray } from '@transferwise/neptune-validation';
18
- import { usePopper } from 'react-popper';
19
10
  import { Transition, Listbox } from '@headlessui/react';
20
11
  import mergeProps from 'merge-props';
12
+ import mergeRefs from 'react-merge-refs';
13
+ import { useSyncExternalStore } from 'use-sync-external-store/shim';
21
14
  import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, offset, flip, shift, size, autoUpdate } from '@floating-ui/react';
15
+ import { FocusScope } from '@react-aria/focus';
22
16
  import { usePreventScroll } from '@react-aria/overlays';
17
+ import { formatDate, formatNumber, formatMoney, formatAmount } from '@transferwise/formatting';
18
+ import { CSSTransition } from 'react-transition-group';
19
+ import { usePopper } from 'react-popper';
20
+ import throttle from 'lodash.throttle';
21
+ import { createPortal } from 'react-dom';
22
+ import { isUndefined, isKey, isNumber, isEmpty, isNull, isArray } from '@transferwise/neptune-validation';
23
23
  import { Illustration } from '@wise/art';
24
24
  import clamp$2 from 'lodash.clamp';
25
25
  import debounce from 'lodash.debounce';
@@ -2900,6 +2900,8 @@ const INITIAL_DEFAULT_STATE = {
2900
2900
  day: null
2901
2901
  };
2902
2902
  const DateInput = ({
2903
+ 'aria-labelledby': ariaLabelledBy,
2904
+ 'aria-label': ariaLabel,
2903
2905
  disabled,
2904
2906
  size,
2905
2907
  value,
@@ -2963,22 +2965,24 @@ const DateInput = ({
2963
2965
  }
2964
2966
  };
2965
2967
  const getSelectElement = () => {
2966
- const months = getMonthNames(locale, monthFormat);
2968
+ const monthOptions = getMonthsOptions();
2967
2969
  return /*#__PURE__*/jsxs("label", {
2970
+ className: "d-flex flex-column",
2968
2971
  children: [/*#__PURE__*/jsx("span", {
2969
2972
  className: "sr-only",
2970
2973
  children: monthLabel
2971
- }), /*#__PURE__*/jsx(Select, {
2972
- id: id ? `${id}-select` : undefined,
2974
+ }), /*#__PURE__*/jsx(SelectInput, {
2973
2975
  name: "month",
2974
2976
  disabled: disabled,
2975
2977
  placeholder: placeholders.month,
2976
- options: getMonthsOptions(),
2978
+ items: monthOptions,
2977
2979
  size: size,
2978
- selected: month === null ? null : {
2979
- value: month,
2980
- label: months[month]
2981
- },
2980
+ value: monthOptions.find(item => item.value.value === month)?.value,
2981
+ renderValue: ({
2982
+ label
2983
+ }) => /*#__PURE__*/jsx(SelectInputOptionContent, {
2984
+ title: label
2985
+ }),
2982
2986
  onChange: selectedValue => handleMonthChange(selectedValue),
2983
2987
  ...selectProps
2984
2988
  })]
@@ -2989,8 +2993,11 @@ const DateInput = ({
2989
2993
  const months = getMonthNames(locale, monthFormat);
2990
2994
  months.forEach((label, index) => {
2991
2995
  options.push({
2992
- value: index,
2993
- label
2996
+ type: 'option',
2997
+ value: {
2998
+ label,
2999
+ value: index
3000
+ }
2994
3001
  });
2995
3002
  });
2996
3003
  return options;
@@ -3087,6 +3094,8 @@ const DateInput = ({
3087
3094
  return /*#__PURE__*/jsx("div", {
3088
3095
  className: "tw-date",
3089
3096
  id: id,
3097
+ "aria-labelledby": ariaLabelledBy,
3098
+ "aria-label": ariaLabel,
3090
3099
  onFocus: event => shouldPropagateOnFocus(event) ? onFocus && onFocus() : event.stopPropagation(),
3091
3100
  onBlur: event => shouldPropagateOnBlur(event) ? onBlur && onBlur() : event.stopPropagation(),
3092
3101
  children: /*#__PURE__*/jsxs("div", {
@@ -3169,6 +3178,8 @@ function shouldPropagateOnBlur({
3169
3178
  return blurElementParent !== focusElementParent;
3170
3179
  }
3171
3180
  DateInput.propTypes = {
3181
+ 'aria-label': PropTypes.string,
3182
+ 'aria-labelledby': PropTypes.string,
3172
3183
  disabled: PropTypes.bool,
3173
3184
  size: PropTypes.oneOf(['sm', 'md', 'lg']),
3174
3185
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
@@ -7832,6 +7843,10 @@ const getUniqueIdForOption = (parentId = '', option) => {
7832
7843
  const uniqueOptionId = option.value || (option.label?.replace(/\s/g, '') ?? '');
7833
7844
  return `option-${parentId}-${uniqueOptionId}`;
7834
7845
  };
7846
+
7847
+ /**
7848
+ * @deprecated Use `SelectInput` instead (https://neptune.wise.design/blog/2023-11-28-adopting-our-new-selectinput)
7849
+ */
7835
7850
  function Select({
7836
7851
  placeholder,
7837
7852
  id,