@transferwise/components 45.14.2 → 45.15.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.
Files changed (160) hide show
  1. package/build/i18n/en.json +8 -0
  2. package/build/index.esm.js +1001 -367
  3. package/build/index.esm.js.map +1 -1
  4. package/build/index.js +1003 -366
  5. package/build/index.js.map +1 -1
  6. package/build/main.css +1 -1
  7. package/build/styles/common/closeButton/CloseButton.css +1 -1
  8. package/build/styles/dateLookup/DateLookup.css +1 -1
  9. package/build/styles/inputs/Input.css +1 -1
  10. package/build/styles/inputs/InputGroup.css +1 -1
  11. package/build/styles/inputs/SelectInput.css +1 -0
  12. package/build/styles/inputs/TextArea.css +1 -1
  13. package/build/styles/main.css +1 -1
  14. package/build/styles/promoCard/PromoCard.css +1 -1
  15. package/build/styles/stepper/Stepper.css +1 -1
  16. package/build/types/avatarWrapper/AvatarWrapper.d.ts +14 -5
  17. package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
  18. package/build/types/common/Option/Option.d.ts.map +1 -1
  19. package/build/types/common/focusBoundary/FocusBoundary.d.ts +2 -2
  20. package/build/types/common/focusBoundary/FocusBoundary.d.ts.map +1 -1
  21. package/build/types/common/hooks/useMedia.d.ts +2 -0
  22. package/build/types/common/hooks/useMedia.d.ts.map +1 -0
  23. package/build/types/common/hooks/useScreenSize.d.ts +3 -0
  24. package/build/types/common/hooks/useScreenSize.d.ts.map +1 -0
  25. package/build/types/common/preventScroll/PreventScroll.d.ts +2 -0
  26. package/build/types/common/preventScroll/PreventScroll.d.ts.map +1 -0
  27. package/build/types/dateInput/DateInput.d.ts +2 -0
  28. package/build/types/dateInput/DateInput.d.ts.map +1 -1
  29. package/build/types/dateLookup/DateLookup.messages.d.ts +65 -0
  30. package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -0
  31. package/build/types/dateLookup/dateHeader/DateHeader.d.ts +3 -1
  32. package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
  33. package/build/types/dateLookup/dateTrigger/DateTrigger.messages.d.ts +7 -7
  34. package/build/types/dateLookup/dateTrigger/DateTrigger.messages.d.ts.map +1 -1
  35. package/build/types/dateLookup/tableLink/TableLink.d.ts +4 -26
  36. package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
  37. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +4 -29
  38. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
  39. package/build/types/index.d.ts +4 -0
  40. package/build/types/index.d.ts.map +1 -1
  41. package/build/types/inputs/Input.d.ts +1 -0
  42. package/build/types/inputs/Input.d.ts.map +1 -1
  43. package/build/types/inputs/SearchInput.d.ts +10 -0
  44. package/build/types/inputs/SearchInput.d.ts.map +1 -0
  45. package/build/types/inputs/SelectInput.d.ts +41 -0
  46. package/build/types/inputs/SelectInput.d.ts.map +1 -0
  47. package/build/types/inputs/_BottomSheet.d.ts +17 -0
  48. package/build/types/inputs/_BottomSheet.d.ts.map +1 -0
  49. package/build/types/inputs/_ButtonInput.d.ts +6 -0
  50. package/build/types/inputs/_ButtonInput.d.ts.map +1 -0
  51. package/build/types/inputs/_Popover.d.ts +18 -0
  52. package/build/types/inputs/_Popover.d.ts.map +1 -0
  53. package/build/types/inputs/_common.d.ts.map +1 -1
  54. package/build/types/logo/Logo.d.ts.map +1 -1
  55. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  56. package/build/types/snackbar/Snackbar.d.ts.map +1 -1
  57. package/build/types/stepper/Stepper.d.ts.map +1 -1
  58. package/build/types/tabs/Tabs.d.ts.map +1 -1
  59. package/build/types/tile/Tile.d.ts.map +1 -1
  60. package/build/types/upload/steps/completeStep/completeStep.d.ts.map +1 -1
  61. package/build/types/upload/steps/processingStep/processingStep.d.ts.map +1 -1
  62. package/build/types/utilities/wrapInFragment.d.ts +3 -0
  63. package/build/types/utilities/wrapInFragment.d.ts.map +1 -0
  64. package/package.json +27 -20
  65. package/src/accordion/AccordionItem/__snapshots__/AccordionItem.spec.js.snap +6 -6
  66. package/src/avatarWrapper/AvatarWrapper.tsx +20 -8
  67. package/src/avatarWrapper/__snapshots__/AvatarWrapper.spec.tsx.snap +1 -1
  68. package/src/card/Card.spec.js +2 -2
  69. package/src/common/Option/Option.tsx +1 -7
  70. package/src/common/bottomSheet/__snapshots__/BottomSheet.spec.tsx.snap +8 -1
  71. package/src/common/closeButton/CloseButton.css +1 -1
  72. package/src/common/focusBoundary/FocusBoundary.tsx +9 -32
  73. package/src/common/hooks/useMedia.spec.ts +39 -0
  74. package/src/common/hooks/useMedia.ts +15 -0
  75. package/src/common/hooks/useScreenSize.ts +7 -0
  76. package/src/common/preventScroll/PreventScroll.tsx +6 -0
  77. package/src/dateInput/DateInput.js +6 -0
  78. package/src/dateInput/DateInput.story.tsx +2 -0
  79. package/src/dateLookup/DateLookup.css +1 -1
  80. package/src/dateLookup/DateLookup.keyboardEvents.spec.js +3 -3
  81. package/src/dateLookup/DateLookup.less +4 -0
  82. package/src/dateLookup/DateLookup.messages.js +44 -0
  83. package/src/dateLookup/DateLookup.testingLibrary.spec.js +39 -0
  84. package/src/dateLookup/dateHeader/DateHeader.js +48 -26
  85. package/src/dateLookup/dateHeader/DateHeader.spec.js +37 -0
  86. package/src/dateLookup/dayCalendar/DayCalendar.js +3 -1
  87. package/src/dateLookup/dayCalendar/DayCalendar.spec.js +7 -1
  88. package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +7 -3
  89. package/src/dateLookup/dayCalendar/table/DayCalendarTable.spec.js +1 -0
  90. package/src/dateLookup/monthCalendar/MonthCalendar.js +3 -1
  91. package/src/dateLookup/monthCalendar/MonthCalendar.spec.js +7 -1
  92. package/src/dateLookup/monthCalendar/table/MonthCalendarTable.spec.js +4 -5
  93. package/src/dateLookup/tableLink/TableLink.js +24 -3
  94. package/src/dateLookup/tableLink/TableLink.spec.js +60 -4
  95. package/src/dateLookup/yearCalendar/YearCalendar.js +16 -3
  96. package/src/dateLookup/yearCalendar/YearCalendar.spec.js +14 -1
  97. package/src/dateLookup/yearCalendar/table/YearCalendarTable.spec.js +4 -5
  98. package/src/decision/Decision.story.js +11 -11
  99. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +12 -12
  100. package/src/i18n/en.json +9 -0
  101. package/src/index.ts +8 -0
  102. package/src/inputs/Input.css +1 -1
  103. package/src/inputs/Input.less +14 -0
  104. package/src/inputs/Input.tsx +6 -2
  105. package/src/inputs/InputGroup.css +1 -1
  106. package/src/inputs/InputGroup.less +5 -0
  107. package/src/inputs/SearchInput.story.tsx +40 -0
  108. package/src/inputs/SearchInput.tsx +35 -0
  109. package/src/inputs/SelectInput.css +1 -0
  110. package/src/inputs/SelectInput.less +183 -0
  111. package/src/inputs/SelectInput.spec.tsx +120 -0
  112. package/src/inputs/SelectInput.story.tsx +264 -0
  113. package/src/inputs/SelectInput.tsx +565 -0
  114. package/src/inputs/TextArea.css +1 -1
  115. package/src/inputs/TextArea.less +5 -0
  116. package/src/inputs/_BottomSheet.less +107 -0
  117. package/src/inputs/_BottomSheet.tsx +128 -0
  118. package/src/inputs/_ButtonInput.less +7 -0
  119. package/src/inputs/_ButtonInput.tsx +27 -0
  120. package/src/inputs/_Popover.less +38 -0
  121. package/src/inputs/_Popover.tsx +118 -0
  122. package/src/inputs/_common.less +0 -4
  123. package/src/inputs/_common.ts +0 -1
  124. package/src/logo/Logo.js +3 -21
  125. package/src/logo/__snapshots__/Logo.spec.js.snap +78 -30
  126. package/src/main.css +1 -1
  127. package/src/main.less +4 -0
  128. package/src/phoneNumberInput/PhoneNumberInput.js +1 -0
  129. package/src/promoCard/PromoCard.css +1 -1
  130. package/src/select/searchBox/__snapshots__/SearchBox.spec.js.snap +1 -1
  131. package/src/snackbar/Snackbar.js +6 -1
  132. package/src/snackbar/Snackbar.spec.js +1 -3
  133. package/src/ssr.spec.js +7 -0
  134. package/src/stepper/Stepper.css +1 -1
  135. package/src/stepper/Stepper.less +1 -9
  136. package/src/stepper/Stepper.spec.js +4 -4
  137. package/src/stepper/Stepper.tsx +2 -5
  138. package/src/tabs/Tabs.js +2 -1
  139. package/src/tile/Tile.js +5 -11
  140. package/src/tile/__snapshots__/Tile.spec.js.snap +7 -9
  141. package/src/upload/Upload.js +1 -1
  142. package/src/upload/steps/completeStep/completeStep.js +4 -1
  143. package/src/upload/steps/processingStep/processingStep.js +1 -0
  144. package/src/uploadInput/uploadItem/UploadItem.tsx +1 -1
  145. package/src/utilities/wrapInFragment.tsx +3 -0
  146. package/build/types/common/focusBoundary/utils/getFocusableElements.d.ts +0 -2
  147. package/build/types/common/focusBoundary/utils/getFocusableElements.d.ts.map +0 -1
  148. package/build/types/common/focusBoundary/utils/index.d.ts +0 -3
  149. package/build/types/common/focusBoundary/utils/index.d.ts.map +0 -1
  150. package/build/types/common/focusBoundary/utils/resetFocus.d.ts +0 -2
  151. package/build/types/common/focusBoundary/utils/resetFocus.d.ts.map +0 -1
  152. package/src/common/focusBoundary/FocusBoundary.spec.tsx +0 -66
  153. package/src/common/focusBoundary/__snapshots__/FocusBoundary.spec.tsx.snap +0 -16
  154. package/src/common/focusBoundary/utils/getFocusableElements.js +0 -25
  155. package/src/common/focusBoundary/utils/getFocusableElements.spec.js +0 -51
  156. package/src/common/focusBoundary/utils/index.js +0 -2
  157. package/src/common/focusBoundary/utils/resetFocus.js +0 -23
  158. package/src/common/focusBoundary/utils/resetFocus.spec.js +0 -103
  159. package/src/snackbar/__snapshots__/Snackbar.spec.js.snap +0 -5
  160. /package/src/dateLookup/dateTrigger/{DateTrigger.messages.js → DateTrigger.messages.ts} +0 -0
@@ -1,8 +1,8 @@
1
1
  import classNames from 'classnames';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import * as React from 'react';
4
- import React__default, { forwardRef, cloneElement, useState, useRef, useMemo, useEffect, useLayoutEffect, createContext, useContext, useCallback, PureComponent, createRef, Component, Children, Fragment as Fragment$1 } from 'react';
5
- import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$2, ClockBorderless, CheckCircle, InfoCircle, Warning, CrossCircle, Clock, Briefcase, Person, ArrowLeft, QuestionMarkCircle, AlertCircle, CheckCircleFill, Search, ArrowRight, Download, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle, AlertCircleFill } from '@transferwise/icons';
4
+ import React__default, { forwardRef, cloneElement, useState, useRef, useMemo, useEffect, useCallback, useLayoutEffect, createContext, useContext, PureComponent, createRef, Component, Children, Fragment as Fragment$1 } from 'react';
5
+ import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$2, ClockBorderless, CheckCircle, InfoCircle, Warning, CrossCircle, Clock, Briefcase, Person, ArrowLeft, QuestionMarkCircle, AlertCircle, Search, ChevronDown, CheckCircleFill, ArrowRight, Download, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle, AlertCircleFill } from '@transferwise/icons';
6
6
  import PropTypes from 'prop-types';
7
7
  import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
8
8
  import { useTheme, ThemeProvider } from '@wise/components-theming';
@@ -10,9 +10,15 @@ import { formatDate, formatNumber, formatMoney, formatAmount } from '@transferwi
10
10
  import throttle from 'lodash.throttle';
11
11
  import { CSSTransition } from 'react-transition-group';
12
12
  import { createPortal } from 'react-dom';
13
- import { isUndefined, isKey, isNumber, isEmpty, isNull, isArray } from '@transferwise/neptune-validation';
13
+ import { FocusScope } from '@react-aria/focus';
14
14
  import mergeRefs from 'react-merge-refs';
15
+ import { isUndefined, isKey, isNumber, isEmpty, isNull, isArray } from '@transferwise/neptune-validation';
15
16
  import { usePopper } from 'react-popper';
17
+ import { Transition, Listbox } from '@headlessui/react';
18
+ import { useId } from '@radix-ui/react-id';
19
+ import { useSyncExternalStore } from 'use-sync-external-store/shim';
20
+ import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, offset, flip, shift, size, autoUpdate } from '@floating-ui/react';
21
+ import { usePreventScroll } from '@react-aria/overlays';
16
22
  import { Illustration } from '@wise/art';
17
23
  import clamp$2 from 'lodash.clamp';
18
24
  import debounce from 'lodash.debounce';
@@ -606,10 +612,8 @@ const Option$2 = /*#__PURE__*/forwardRef(({
606
612
  })
607
613
  }), /*#__PURE__*/jsxs("div", {
608
614
  className: "media-body",
609
- children: [/*#__PURE__*/jsx(Body, {
610
- as: "span",
611
- type: Typography.BODY_LARGE_BOLD,
612
- className: "text-primary np-option__title d-block",
615
+ children: [/*#__PURE__*/jsx("h4", {
616
+ className: "np-text-body-large-bold text-primary np-option__title",
613
617
  children: title
614
618
  }), content && /*#__PURE__*/jsx(Body, {
615
619
  className: "d-block np-option__body",
@@ -759,7 +763,7 @@ const ActionOption = ({
759
763
  });
760
764
  };
761
765
 
762
- var messages$8 = defineMessages({
766
+ var messages$9 = defineMessages({
763
767
  ariaLabel: {
764
768
  id: "neptune.CloseButton.ariaLabel"
765
769
  }
@@ -775,7 +779,7 @@ const CloseButton = /*#__PURE__*/forwardRef(function CloseButton({
775
779
  testId
776
780
  }, reference) {
777
781
  const intl = useIntl();
778
- ariaLabel ??= intl.formatMessage(messages$8.ariaLabel);
782
+ ariaLabel ??= intl.formatMessage(messages$9.ariaLabel);
779
783
  const Icon = filled ? CrossCircleFill : Cross;
780
784
  return /*#__PURE__*/jsx("button", {
781
785
  ref: reference,
@@ -795,7 +799,7 @@ const CloseButton = /*#__PURE__*/forwardRef(function CloseButton({
795
799
  });
796
800
  });
797
801
 
798
- var messages$7 = defineMessages({
802
+ var messages$8 = defineMessages({
799
803
  opensInNewTab: {
800
804
  id: "neptune.Link.opensInNewTab"
801
805
  }
@@ -824,7 +828,7 @@ const Link = ({
824
828
  onClick: onClick,
825
829
  ...props,
826
830
  children: [children, " ", isBlank && /*#__PURE__*/jsx(NavigateAway, {
827
- title: formatMessage(messages$7.opensInNewTab)
831
+ title: formatMessage(messages$8.opensInNewTab)
828
832
  })]
829
833
  });
830
834
  };
@@ -1400,7 +1404,7 @@ const AvatarWrapper = ({
1400
1404
  type: AvatarType.THUMBNAIL,
1401
1405
  children: /*#__PURE__*/jsx("img", {
1402
1406
  src: url,
1403
- alt: "avatar",
1407
+ alt: "",
1404
1408
  onError: () => setImageLoadError(true)
1405
1409
  }),
1406
1410
  ...avatarProps
@@ -1454,268 +1458,23 @@ function getInitials(name) {
1454
1458
  return allInitials[0] + allInitials.slice(-1);
1455
1459
  }
1456
1460
 
1457
- const THROTTLE_MS = 100;
1458
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
1459
- const useClientWidth = ({
1460
- ref,
1461
- throttleMs = THROTTLE_MS
1462
- }) => {
1463
- const [clientWidth, setClientWidth] = useState(null);
1464
- useIsomorphicLayoutEffect(() => {
1465
- // eslint-disable-next-line unicorn/consistent-function-scoping
1466
- const updateClientWidth = () => {
1467
- if (ref) {
1468
- // when `ref` is a window
1469
- if ('innerWidth' in ref) {
1470
- setClientWidth(ref.innerWidth);
1471
- }
1472
- // when `ref` is an element
1473
- else if (ref.current) {
1474
- setClientWidth(ref.current.clientWidth);
1475
- }
1476
- }
1477
- };
1478
- // This assignment saves a reference to the function so it will be the same passed to both addEventListener removeEventListener.
1479
- // If throttle gets passed directly to both add and removeEventListenet the results will be that the event
1480
- // won't get removed even if the component is unmounted.
1481
- const attachedFunction = throttle(updateClientWidth, throttleMs);
1482
- window.addEventListener('resize', attachedFunction, true);
1483
- // using requestAnimationFrame to perform the calculation before the next repaint
1484
- // getting width earlier causes issues in animations when used with react-transition-group
1485
- window.requestAnimationFrame(updateClientWidth);
1486
- return () => window.removeEventListener('resize', attachedFunction, true);
1487
- }, []);
1488
- return [clientWidth];
1489
- };
1490
- useClientWidth.THROTTLE_MS = THROTTLE_MS;
1491
-
1492
- const useConditionalListener = ({
1493
- attachListener,
1494
- callback,
1495
- eventType,
1496
- parent
1497
- }) => {
1498
- useEffect(() => {
1499
- if (attachListener && !isUndefined(parent)) {
1500
- parent.addEventListener(eventType, callback, true);
1501
- }
1502
- return () => {
1503
- if (!isUndefined(parent)) {
1504
- parent.removeEventListener(eventType, callback, true);
1505
- }
1506
- };
1507
- }, [attachListener, callback, eventType, parent]);
1508
- };
1509
-
1510
- const DirectionContext = /*#__PURE__*/createContext(Direction.LTR);
1511
- const DirectionProvider = ({
1512
- direction,
1513
- children
1514
- }) => {
1515
- return /*#__PURE__*/jsx(DirectionContext.Provider, {
1516
- value: direction,
1517
- children: children
1518
- });
1519
- };
1520
-
1521
- const useDirection = () => {
1522
- const direction = useContext(DirectionContext);
1523
- return {
1524
- direction,
1525
- isRTL: direction === 'rtl'
1526
- };
1527
- };
1528
-
1529
- const ObserverParams = {
1530
- threshold: 0.1
1531
- };
1532
-
1533
- /**
1534
- * useHasIntersected.
1535
- * Use this custom hook to detect when an element has became visible inside the viewport. This hook checks only if the intersection happend.
1536
- * Once the intersection has happened the hook will not return false even if the element gets out of the viewport.
1537
- *
1538
- * @param elRef.elRef
1539
- * @param {object} [elRef] - node object that contains a react reference to the element that needs to be observed.
1540
- * @param {strimng} [loading = 'eager'] - string that contains the type of loading.
1541
- * @param elRef.loading
1542
- * @usage `const [hasIntersected] = useHasIntersected({imageRef,loading});`
1543
- */
1544
- const useHasIntersected = ({
1545
- elRef,
1546
- loading
1547
- }) => {
1548
- const [hasIntersected, setHasIntersected] = useState(false);
1549
- const {
1550
- current
1551
- } = elRef || {};
1552
- const isValidReference = () => {
1553
- return elRef && current;
1554
- };
1555
- const handleOnIntersect = (entries, observer) => {
1556
- entries.forEach(entry => {
1557
- if (entry.isIntersecting) {
1558
- setHasIntersected(true);
1559
- observer.unobserve(current);
1560
- }
1561
- });
1562
- };
1563
- useEffect(() => {
1564
- let observer;
1565
- let didCancel = false;
1566
-
1567
- // Check if window is define for SSR and Old browsers fallback
1568
- if (typeof window === 'undefined' || !window.IntersectionObserver || !isValidReference()) {
1569
- setHasIntersected(true);
1570
- } else if (!didCancel) {
1571
- observer = new IntersectionObserver(handleOnIntersect, ObserverParams);
1572
- observer.observe(current);
1573
- }
1574
- return () => {
1575
- didCancel = true;
1576
- if (observer) {
1577
- observer.unobserve(current);
1578
- }
1579
- };
1580
- }, [elRef]);
1581
- if (loading === 'eager') {
1582
- return [false];
1583
- }
1584
- return [hasIntersected];
1585
- };
1586
-
1587
- const useLayout = () => {
1588
- const windowReference = typeof window === 'undefined' ? undefined : window;
1589
- const [breakpoint, setBreakpoint] = useState();
1590
- const [clientWidth] = useClientWidth({
1591
- ref: windowReference
1592
- });
1593
- useEffect(() => {
1594
- if (!clientWidth) {
1595
- return;
1596
- }
1597
- if (clientWidth <= Breakpoint.EXTRA_SMALL) {
1598
- setBreakpoint(Breakpoint.EXTRA_SMALL);
1599
- return;
1600
- }
1601
- if (Breakpoint.EXTRA_SMALL < clientWidth && clientWidth <= Breakpoint.SMALL) {
1602
- setBreakpoint(Breakpoint.SMALL);
1603
- return;
1604
- }
1605
- if (Breakpoint.SMALL < clientWidth && clientWidth <= Breakpoint.MEDIUM) {
1606
- setBreakpoint(Breakpoint.MEDIUM);
1607
- return;
1608
- }
1609
- if (Breakpoint.MEDIUM < clientWidth && clientWidth <= Breakpoint.LARGE) {
1610
- setBreakpoint(Breakpoint.LARGE);
1611
- return;
1612
- }
1613
- if (Breakpoint.LARGE < clientWidth) {
1614
- setBreakpoint(Breakpoint.EXTRA_LARGE);
1615
- }
1616
- }, [clientWidth]);
1617
- return {
1618
- isMobile: !!breakpoint && [Breakpoint.EXTRA_SMALL, Breakpoint.SMALL].includes(breakpoint),
1619
- isExtraSmall: breakpoint === Breakpoint.EXTRA_SMALL,
1620
- isSmall: breakpoint === Breakpoint.SMALL,
1621
- isMedium: breakpoint === Breakpoint.MEDIUM,
1622
- isLarge: breakpoint === Breakpoint.LARGE,
1623
- isExtraLarge: breakpoint === Breakpoint.EXTRA_LARGE
1624
- };
1625
- };
1626
-
1627
- /**
1628
- * This function returns the first and the last focusable elements within a node.
1629
- *
1630
- * @param {Node} focusBoundaryContainer - the area that contains focused elements.
1631
- * @returns {object} focusableEls - which contains the first focusable element and the last focusable element. First and last can be the same element if area contains one or none focusable element.
1632
- */
1633
-
1634
- const getFocusableElements = focusBoundaryContainer => {
1635
- const focusableEls = {
1636
- first: focusBoundaryContainer,
1637
- last: focusBoundaryContainer
1638
- };
1639
- if (focusBoundaryContainer?.querySelectorAll) {
1640
- const allEls = [...focusBoundaryContainer.querySelectorAll('a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])')].filter(element => !element.hasAttribute('disabled'));
1641
- if (allEls.length > 0) {
1642
- [focusableEls.first] = allEls;
1643
- focusableEls.last = allEls[allEls.length - 1];
1644
- }
1645
- }
1646
- return focusableEls;
1647
- };
1648
-
1649
- /**
1650
- * This function resets the focus to either last of first focusable elements within a node.
1651
- *
1652
- * @param {object} focusableEls - contains the first last of first focusable elements within a node.
1653
- * @param {object} event - the triggered event
1654
- */
1655
-
1656
- const resetFocus = ({
1657
- focusableEls: {
1658
- first,
1659
- last
1660
- },
1661
- event
1662
- }) => {
1663
- const {
1664
- activeElement
1665
- } = document;
1666
- if (event.shiftKey && activeElement === first) {
1667
- if (last) {
1668
- last.focus();
1669
- }
1670
- event.preventDefault();
1671
- }
1672
- if (!event.shiftKey && activeElement === last) {
1673
- if (first) {
1674
- first.focus();
1675
- }
1676
- event.preventDefault();
1677
- }
1678
- };
1679
-
1680
- const {
1681
- TAB
1682
- } = Key;
1683
1461
  const FocusBoundary = ({
1684
1462
  children
1685
1463
  }) => {
1686
- const boundaryReference = useRef(null);
1687
- const parent = isUndefined(document) ? undefined : document;
1688
- const [focusableEls, setFocusableEls] = useState({});
1464
+ const wrapperReference = useRef(null);
1689
1465
  useEffect(() => {
1690
- if (boundaryReference?.current) {
1691
- boundaryReference.current.focus({
1692
- preventScroll: true
1693
- });
1694
- setFocusableEls(getFocusableElements(boundaryReference.current));
1695
- }
1466
+ wrapperReference.current?.focus({
1467
+ preventScroll: true
1468
+ });
1696
1469
  }, []);
1697
- // If event type is Tab the resetFocus will force the focus to either the first focusable or last in boundaryRef .
1698
- useConditionalListener({
1699
- eventType: 'keydown',
1700
- callback: event => {
1701
- if (isKey({
1702
- keyType: TAB,
1703
- event
1704
- })) {
1705
- resetFocus({
1706
- event,
1707
- focusableEls
1708
- });
1709
- }
1710
- },
1711
- attachListener: true,
1712
- parent
1713
- });
1714
1470
  return /*#__PURE__*/jsx("div", {
1715
- ref: boundaryReference,
1471
+ ref: wrapperReference,
1716
1472
  tabIndex: -1,
1717
- className: "np-focus-boundary outline-none",
1718
- children: children
1473
+ children: /*#__PURE__*/jsx(FocusScope, {
1474
+ contain: true,
1475
+ restoreFocus: true,
1476
+ children: children
1477
+ })
1719
1478
  });
1720
1479
  };
1721
1480
  var FocusBoundary$1 = FocusBoundary;
@@ -1971,6 +1730,176 @@ SlidingPanel.defaultProps = {
1971
1730
  };
1972
1731
  var SlidingPanel$1 = SlidingPanel;
1973
1732
 
1733
+ const THROTTLE_MS = 100;
1734
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
1735
+ const useClientWidth = ({
1736
+ ref,
1737
+ throttleMs = THROTTLE_MS
1738
+ }) => {
1739
+ const [clientWidth, setClientWidth] = useState(null);
1740
+ useIsomorphicLayoutEffect(() => {
1741
+ // eslint-disable-next-line unicorn/consistent-function-scoping
1742
+ const updateClientWidth = () => {
1743
+ if (ref) {
1744
+ // when `ref` is a window
1745
+ if ('innerWidth' in ref) {
1746
+ setClientWidth(ref.innerWidth);
1747
+ }
1748
+ // when `ref` is an element
1749
+ else if (ref.current) {
1750
+ setClientWidth(ref.current.clientWidth);
1751
+ }
1752
+ }
1753
+ };
1754
+ // This assignment saves a reference to the function so it will be the same passed to both addEventListener removeEventListener.
1755
+ // If throttle gets passed directly to both add and removeEventListenet the results will be that the event
1756
+ // won't get removed even if the component is unmounted.
1757
+ const attachedFunction = throttle(updateClientWidth, throttleMs);
1758
+ window.addEventListener('resize', attachedFunction, true);
1759
+ // using requestAnimationFrame to perform the calculation before the next repaint
1760
+ // getting width earlier causes issues in animations when used with react-transition-group
1761
+ window.requestAnimationFrame(updateClientWidth);
1762
+ return () => window.removeEventListener('resize', attachedFunction, true);
1763
+ }, []);
1764
+ return [clientWidth];
1765
+ };
1766
+ useClientWidth.THROTTLE_MS = THROTTLE_MS;
1767
+
1768
+ const useConditionalListener = ({
1769
+ attachListener,
1770
+ callback,
1771
+ eventType,
1772
+ parent
1773
+ }) => {
1774
+ useEffect(() => {
1775
+ if (attachListener && !isUndefined(parent)) {
1776
+ parent.addEventListener(eventType, callback, true);
1777
+ }
1778
+ return () => {
1779
+ if (!isUndefined(parent)) {
1780
+ parent.removeEventListener(eventType, callback, true);
1781
+ }
1782
+ };
1783
+ }, [attachListener, callback, eventType, parent]);
1784
+ };
1785
+
1786
+ const DirectionContext = /*#__PURE__*/createContext(Direction.LTR);
1787
+ const DirectionProvider = ({
1788
+ direction,
1789
+ children
1790
+ }) => {
1791
+ return /*#__PURE__*/jsx(DirectionContext.Provider, {
1792
+ value: direction,
1793
+ children: children
1794
+ });
1795
+ };
1796
+
1797
+ const useDirection = () => {
1798
+ const direction = useContext(DirectionContext);
1799
+ return {
1800
+ direction,
1801
+ isRTL: direction === 'rtl'
1802
+ };
1803
+ };
1804
+
1805
+ const ObserverParams = {
1806
+ threshold: 0.1
1807
+ };
1808
+
1809
+ /**
1810
+ * useHasIntersected.
1811
+ * Use this custom hook to detect when an element has became visible inside the viewport. This hook checks only if the intersection happend.
1812
+ * Once the intersection has happened the hook will not return false even if the element gets out of the viewport.
1813
+ *
1814
+ * @param elRef.elRef
1815
+ * @param {object} [elRef] - node object that contains a react reference to the element that needs to be observed.
1816
+ * @param {strimng} [loading = 'eager'] - string that contains the type of loading.
1817
+ * @param elRef.loading
1818
+ * @usage `const [hasIntersected] = useHasIntersected({imageRef,loading});`
1819
+ */
1820
+ const useHasIntersected = ({
1821
+ elRef,
1822
+ loading
1823
+ }) => {
1824
+ const [hasIntersected, setHasIntersected] = useState(false);
1825
+ const {
1826
+ current
1827
+ } = elRef || {};
1828
+ const isValidReference = () => {
1829
+ return elRef && current;
1830
+ };
1831
+ const handleOnIntersect = (entries, observer) => {
1832
+ entries.forEach(entry => {
1833
+ if (entry.isIntersecting) {
1834
+ setHasIntersected(true);
1835
+ observer.unobserve(current);
1836
+ }
1837
+ });
1838
+ };
1839
+ useEffect(() => {
1840
+ let observer;
1841
+ let didCancel = false;
1842
+
1843
+ // Check if window is define for SSR and Old browsers fallback
1844
+ if (typeof window === 'undefined' || !window.IntersectionObserver || !isValidReference()) {
1845
+ setHasIntersected(true);
1846
+ } else if (!didCancel) {
1847
+ observer = new IntersectionObserver(handleOnIntersect, ObserverParams);
1848
+ observer.observe(current);
1849
+ }
1850
+ return () => {
1851
+ didCancel = true;
1852
+ if (observer) {
1853
+ observer.unobserve(current);
1854
+ }
1855
+ };
1856
+ }, [elRef]);
1857
+ if (loading === 'eager') {
1858
+ return [false];
1859
+ }
1860
+ return [hasIntersected];
1861
+ };
1862
+
1863
+ const useLayout = () => {
1864
+ const windowReference = typeof window === 'undefined' ? undefined : window;
1865
+ const [breakpoint, setBreakpoint] = useState();
1866
+ const [clientWidth] = useClientWidth({
1867
+ ref: windowReference
1868
+ });
1869
+ useEffect(() => {
1870
+ if (!clientWidth) {
1871
+ return;
1872
+ }
1873
+ if (clientWidth <= Breakpoint.EXTRA_SMALL) {
1874
+ setBreakpoint(Breakpoint.EXTRA_SMALL);
1875
+ return;
1876
+ }
1877
+ if (Breakpoint.EXTRA_SMALL < clientWidth && clientWidth <= Breakpoint.SMALL) {
1878
+ setBreakpoint(Breakpoint.SMALL);
1879
+ return;
1880
+ }
1881
+ if (Breakpoint.SMALL < clientWidth && clientWidth <= Breakpoint.MEDIUM) {
1882
+ setBreakpoint(Breakpoint.MEDIUM);
1883
+ return;
1884
+ }
1885
+ if (Breakpoint.MEDIUM < clientWidth && clientWidth <= Breakpoint.LARGE) {
1886
+ setBreakpoint(Breakpoint.LARGE);
1887
+ return;
1888
+ }
1889
+ if (Breakpoint.LARGE < clientWidth) {
1890
+ setBreakpoint(Breakpoint.EXTRA_LARGE);
1891
+ }
1892
+ }, [clientWidth]);
1893
+ return {
1894
+ isMobile: !!breakpoint && [Breakpoint.EXTRA_SMALL, Breakpoint.SMALL].includes(breakpoint),
1895
+ isExtraSmall: breakpoint === Breakpoint.EXTRA_SMALL,
1896
+ isSmall: breakpoint === Breakpoint.SMALL,
1897
+ isMedium: breakpoint === Breakpoint.MEDIUM,
1898
+ isLarge: breakpoint === Breakpoint.LARGE,
1899
+ isExtraLarge: breakpoint === Breakpoint.EXTRA_LARGE
1900
+ };
1901
+ };
1902
+
1974
1903
  const INITIAL_Y_POSITION = 0;
1975
1904
  const CONTENT_SCROLL_THRESHOLD = 1;
1976
1905
  const MOVE_OFFSET_THRESHOLD = 50;
@@ -1980,7 +1909,7 @@ const MOVE_OFFSET_THRESHOLD = 50;
1980
1909
  * Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet
1981
1910
  *
1982
1911
  */
1983
- const BottomSheet = props => {
1912
+ const BottomSheet$1 = props => {
1984
1913
  const bottomSheetReference = useRef(null);
1985
1914
  const topBarReference = useRef(null);
1986
1915
  const contentReference = useRef(null);
@@ -2134,7 +2063,7 @@ const BottomSheet = props => {
2134
2063
  })
2135
2064
  });
2136
2065
  };
2137
- var BottomSheet$1 = BottomSheet;
2066
+ var BottomSheet$2 = BottomSheet$1;
2138
2067
 
2139
2068
  const typeClassMap$1 = {
2140
2069
  [ControlType.ACCENT]: 'btn-accent',
@@ -2534,7 +2463,7 @@ const Chip = ({
2534
2463
  }, value);
2535
2464
  };
2536
2465
 
2537
- var messages$6 = defineMessages({
2466
+ var messages$7 = defineMessages({
2538
2467
  ariaLabel: {
2539
2468
  id: "neptune.Chips.ariaLabel"
2540
2469
  }
@@ -2566,7 +2495,7 @@ const Chips = ({
2566
2495
  value: chip.value,
2567
2496
  label: chip.label,
2568
2497
  closeButton: {
2569
- 'aria-label': intl.formatMessage(messages$6.ariaLabel, {
2498
+ 'aria-label': intl.formatMessage(messages$7.ariaLabel, {
2570
2499
  choice: chip.label
2571
2500
  })
2572
2501
  },
@@ -2674,7 +2603,7 @@ const validDateObject = dateObject => dateObject instanceof Date && !isNaN(dateO
2674
2603
 
2675
2604
  const isMonthAndYearFormat = dateString => validDateString(dateString) && dateString.split('-').length < 3;
2676
2605
 
2677
- var messages$5 = defineMessages({
2606
+ var messages$6 = defineMessages({
2678
2607
  monthLabel: {
2679
2608
  id: "neptune.DateInput.month.label"
2680
2609
  },
@@ -2714,8 +2643,10 @@ const DateInput = ({
2714
2643
  size,
2715
2644
  value,
2716
2645
  dayLabel,
2646
+ dayAutoComplete,
2717
2647
  monthLabel,
2718
2648
  yearLabel,
2649
+ yearAutoComplete,
2719
2650
  monthFormat,
2720
2651
  mode,
2721
2652
  onChange,
@@ -2750,12 +2681,12 @@ const DateInput = ({
2750
2681
  const [month, setMonth] = useState(() => getExplodedDate('month'));
2751
2682
  const [year, setYear] = useState(() => getExplodedDate('year'));
2752
2683
  const [lastBroadcastedValue, setLastBroadcastedValue] = useState(getDateObject);
2753
- dayLabel = dayLabel || formatMessage(messages$5.dayLabel);
2754
- monthLabel = monthLabel || formatMessage(messages$5.monthLabel);
2755
- yearLabel = yearLabel || formatMessage(messages$5.yearLabel);
2684
+ dayLabel = dayLabel || formatMessage(messages$6.dayLabel);
2685
+ monthLabel = monthLabel || formatMessage(messages$6.monthLabel);
2686
+ yearLabel = yearLabel || formatMessage(messages$6.yearLabel);
2756
2687
  placeholders = {
2757
2688
  day: placeholders?.day || 'DD',
2758
- month: placeholders?.month || formatMessage(messages$5.monthLabel),
2689
+ month: placeholders?.month || formatMessage(messages$6.monthLabel),
2759
2690
  year: placeholders?.year || 'YYYY'
2760
2691
  };
2761
2692
  const getDateAsString = date => {
@@ -2913,6 +2844,7 @@ const DateInput = ({
2913
2844
  children: /*#__PURE__*/jsx(Input, {
2914
2845
  type: "number",
2915
2846
  name: "day",
2847
+ autoComplete: dayAutoComplete,
2916
2848
  value: day || '',
2917
2849
  placeholder: placeholders.day,
2918
2850
  disabled: disabled,
@@ -2935,6 +2867,7 @@ const DateInput = ({
2935
2867
  children: /*#__PURE__*/jsx(Input, {
2936
2868
  type: "number",
2937
2869
  name: "year",
2870
+ autoComplete: yearAutoComplete,
2938
2871
  placeholder: placeholders.year,
2939
2872
  value: year || '',
2940
2873
  disabled: disabled,
@@ -2982,8 +2915,10 @@ DateInput.propTypes = {
2982
2915
  onFocus: PropTypes.func,
2983
2916
  onBlur: PropTypes.func,
2984
2917
  dayLabel: PropTypes.string,
2918
+ dayAutoComplete: PropTypes.string,
2985
2919
  monthLabel: PropTypes.string,
2986
2920
  yearLabel: PropTypes.string,
2921
+ yearAutoComplete: PropTypes.string,
2987
2922
  monthFormat: PropTypes.oneOf(['long', 'short']),
2988
2923
  mode: PropTypes.oneOf(['day-month-year', 'month-year']),
2989
2924
  placeholders: PropTypes.shape({
@@ -3161,7 +3096,7 @@ const ResponsivePanel = /*#__PURE__*/forwardRef(({
3161
3096
  isMobile
3162
3097
  } = useLayout();
3163
3098
  if (isMobile) {
3164
- return /*#__PURE__*/jsx(BottomSheet$1, {
3099
+ return /*#__PURE__*/jsx(BottomSheet$2, {
3165
3100
  open: open,
3166
3101
  className: className,
3167
3102
  onClose: onClose,
@@ -3182,7 +3117,7 @@ const ResponsivePanel = /*#__PURE__*/forwardRef(({
3182
3117
  });
3183
3118
  var ResponsivePanel$1 = ResponsivePanel;
3184
3119
 
3185
- var messages$4 = defineMessages({
3120
+ var messages$5 = defineMessages({
3186
3121
  ariaLabel: {
3187
3122
  id: "neptune.ClearButton.ariaLabel"
3188
3123
  }
@@ -3245,7 +3180,7 @@ const DateTrigger = ({
3245
3180
  className: "input-group-addon",
3246
3181
  children: /*#__PURE__*/jsx(CloseButton, {
3247
3182
  className: `clear-btn clear-btn--${size}`,
3248
- "aria-label": formatMessage(messages$4.ariaLabel),
3183
+ "aria-label": formatMessage(messages$5.ariaLabel),
3249
3184
  size: Size.SMALL,
3250
3185
  onClick: event => {
3251
3186
  event.stopPropagation();
@@ -3275,50 +3210,85 @@ DateTrigger.defaultProps = {
3275
3210
  };
3276
3211
  var DateTrigger$1 = DateTrigger;
3277
3212
 
3213
+ var messages$4 = defineMessages({
3214
+ next: {
3215
+ id: "neptune.DateLookup.next"
3216
+ },
3217
+ previous: {
3218
+ id: "neptune.DateLookup.previous"
3219
+ },
3220
+ day: {
3221
+ id: "neptune.DateLookup.day"
3222
+ },
3223
+ month: {
3224
+ id: "neptune.DateLookup.month"
3225
+ },
3226
+ year: {
3227
+ id: "neptune.DateLookup.year"
3228
+ },
3229
+ twentyYears: {
3230
+ id: "neptune.DateLookup.twentyYears"
3231
+ },
3232
+ selected: {
3233
+ id: "neptune.DateLookup.selected"
3234
+ },
3235
+ goTo20YearView: {
3236
+ id: "neptune.DateLookup.goTo20YearView"
3237
+ }
3238
+ });
3239
+
3278
3240
  const buttonClasses = 'btn-link p-a-0 text-no-decoration np-text-body-large-bold rounded-sm';
3279
3241
  const DateHeader = ({
3280
3242
  label,
3281
3243
  onLabelClick,
3282
3244
  onPreviousClick,
3283
- onNextClick
3284
- }) => /*#__PURE__*/jsxs("div", {
3285
- className: "text-xs-center p-t-1 p-b-2 clearfix",
3286
- children: [/*#__PURE__*/jsx("div", {
3287
- className: "pull-left-single-direction",
3288
- children: /*#__PURE__*/jsx("button", {
3289
- type: "button",
3290
- className: `d-inline-flex ${buttonClasses}`,
3291
- onClick: onPreviousClick,
3292
- children: /*#__PURE__*/jsx(Chevron$1, {
3293
- orientation: Position.LEFT,
3294
- className: "left-single-direction",
3295
- size: Size.MEDIUM
3245
+ onNextClick,
3246
+ dateMode
3247
+ }) => {
3248
+ const intl = useIntl();
3249
+ return /*#__PURE__*/jsxs("div", {
3250
+ className: "text-xs-center p-t-1 p-b-2 clearfix",
3251
+ children: [/*#__PURE__*/jsx("div", {
3252
+ className: "pull-left-single-direction",
3253
+ children: /*#__PURE__*/jsx("button", {
3254
+ type: "button",
3255
+ className: `d-inline-flex ${buttonClasses}`,
3256
+ "aria-label": `${intl.formatMessage(messages$4.previous)} ${dateMode}`,
3257
+ onClick: onPreviousClick,
3258
+ children: /*#__PURE__*/jsx(Chevron$1, {
3259
+ orientation: Position.LEFT,
3260
+ className: "left-single-direction",
3261
+ size: Size.MEDIUM
3262
+ })
3296
3263
  })
3297
- })
3298
- }), label && /*#__PURE__*/jsx("button", {
3299
- type: "button",
3300
- className: `tw-date-lookup-header-current ${buttonClasses}`,
3301
- onClick: onLabelClick,
3302
- children: label
3303
- }), /*#__PURE__*/jsx("div", {
3304
- className: "pull-right-single-direction",
3305
- children: /*#__PURE__*/jsx("button", {
3264
+ }), label && /*#__PURE__*/jsx("button", {
3306
3265
  type: "button",
3307
- className: `d-inline-flex ${buttonClasses}`,
3308
- onClick: onNextClick,
3309
- children: /*#__PURE__*/jsx(Chevron$1, {
3310
- orientation: Position.RIGHT,
3311
- className: "right-single-direction",
3312
- size: Size.MEDIUM
3266
+ className: `tw-date-lookup-header-current ${buttonClasses}`,
3267
+ "aria-label": intl.formatMessage(messages$4.goTo20YearView),
3268
+ onClick: onLabelClick,
3269
+ children: label
3270
+ }), /*#__PURE__*/jsx("div", {
3271
+ className: "pull-right-single-direction",
3272
+ children: /*#__PURE__*/jsx("button", {
3273
+ type: "button",
3274
+ className: `d-inline-flex ${buttonClasses}`,
3275
+ "aria-label": `${useIntl().formatMessage(messages$4.next)} ${dateMode}`,
3276
+ onClick: onNextClick,
3277
+ children: /*#__PURE__*/jsx(Chevron$1, {
3278
+ orientation: Position.RIGHT,
3279
+ className: "right-single-direction",
3280
+ size: Size.MEDIUM
3281
+ })
3313
3282
  })
3314
- })
3315
- })]
3316
- });
3283
+ })]
3284
+ });
3285
+ };
3317
3286
  DateHeader.propTypes = {
3318
3287
  label: PropTypes.string,
3319
3288
  onLabelClick: PropTypes.func,
3320
3289
  onPreviousClick: PropTypes.func.isRequired,
3321
- onNextClick: PropTypes.func.isRequired
3290
+ onNextClick: PropTypes.func.isRequired,
3291
+ dateMode: PropTypes.string
3322
3292
  };
3323
3293
  DateHeader.defaultProps = {
3324
3294
  label: null,
@@ -3344,6 +3314,12 @@ class TableLink extends PureComponent {
3344
3314
  this.props.onClick(this.props.item);
3345
3315
  }
3346
3316
  };
3317
+ calculateAriaLabel = (longTitle, title, active, type, formatMessage) => {
3318
+ if (active) {
3319
+ return `${longTitle || title}, ${formatMessage(messages$4.selected)} ${formatMessage(messages$4[type])}`;
3320
+ }
3321
+ return longTitle || title;
3322
+ };
3347
3323
  render() {
3348
3324
  const {
3349
3325
  item,
@@ -3352,14 +3328,17 @@ class TableLink extends PureComponent {
3352
3328
  longTitle,
3353
3329
  active,
3354
3330
  disabled,
3355
- today
3331
+ today,
3332
+ intl: {
3333
+ formatMessage
3334
+ }
3356
3335
  } = this.props;
3357
3336
  return /*#__PURE__*/jsx(Fragment, {
3358
3337
  children: /*#__PURE__*/jsx("button", {
3359
3338
  type: "button",
3360
3339
  className: `tw-date-lookup-${type}-option ${active ? 'active' : ''} ${today ? 'today' : ''} np-text-body-default-bold`,
3361
3340
  disabled: disabled,
3362
- "aria-label": longTitle,
3341
+ "aria-label": this.calculateAriaLabel(longTitle, title, active, type, formatMessage),
3363
3342
  onClick: this.onClick,
3364
3343
  children: title || item
3365
3344
  })
@@ -3381,7 +3360,7 @@ TableLink.defaultProps = {
3381
3360
  title: null,
3382
3361
  longTitle: null
3383
3362
  };
3384
- var TableLink$1 = TableLink;
3363
+ var TableLink$1 = injectIntl(TableLink);
3385
3364
 
3386
3365
  const SHORT_DAY_FORMAT = {
3387
3366
  day: 'numeric'
@@ -3425,6 +3404,7 @@ class DayCalendarTable extends PureComponent {
3425
3404
  };
3426
3405
  days = getDayNames(this.props.intl.locale, 'short');
3427
3406
  daysShort = getDayNames(this.props.intl.locale, 'narrow');
3407
+ daysLong = getDayNames(this.props.intl.locale, 'long');
3428
3408
  selectDay = day => {
3429
3409
  const {
3430
3410
  viewMonth,
@@ -3468,10 +3448,16 @@ class DayCalendarTable extends PureComponent {
3468
3448
  className: "text-xs-center np-text-body-default-bold",
3469
3449
  children: [/*#__PURE__*/jsx("span", {
3470
3450
  className: "hidden-xs",
3471
- children: day.slice(0, 3)
3451
+ children: /*#__PURE__*/jsx("abbr", {
3452
+ title: this.daysLong[index],
3453
+ children: day.slice(0, 3)
3454
+ })
3472
3455
  }), /*#__PURE__*/jsx("span", {
3473
3456
  className: "visible-xs-inline-block",
3474
- children: this.daysShort[index].slice(0, 2)
3457
+ children: /*#__PURE__*/jsx("abbr", {
3458
+ title: this.daysLong[index],
3459
+ children: this.daysShort[index].slice(0, 2)
3460
+ })
3475
3461
  })]
3476
3462
  }, day))
3477
3463
  })
@@ -3539,7 +3525,8 @@ class DayCalendar extends PureComponent {
3539
3525
  viewMonth,
3540
3526
  viewYear,
3541
3527
  intl: {
3542
- locale
3528
+ locale,
3529
+ formatMessage
3543
3530
  },
3544
3531
  monthFormat,
3545
3532
  onLabelClick,
@@ -3551,6 +3538,7 @@ class DayCalendar extends PureComponent {
3551
3538
  month: monthFormat,
3552
3539
  year: 'numeric'
3553
3540
  }),
3541
+ dateMode: formatMessage(messages$4.month),
3554
3542
  onLabelClick: onLabelClick,
3555
3543
  onPreviousClick: this.selectPreviousMonth,
3556
3544
  onNextClick: this.selectNextMonth
@@ -3670,13 +3658,15 @@ class MonthCalendar extends PureComponent {
3670
3658
  max,
3671
3659
  viewYear,
3672
3660
  intl: {
3673
- locale
3661
+ locale,
3662
+ formatMessage
3674
3663
  },
3675
3664
  placeholder,
3676
3665
  onLabelClick
3677
3666
  } = this.props;
3678
3667
  return /*#__PURE__*/jsxs(Fragment, {
3679
3668
  children: [/*#__PURE__*/jsx(DateHeader$1, {
3669
+ dateMode: formatMessage(messages$4.year),
3680
3670
  label: formatDate(new Date(viewYear, 0), locale, {
3681
3671
  year: 'numeric'
3682
3672
  }),
@@ -3794,10 +3784,14 @@ class YearCalendar extends PureComponent {
3794
3784
  min,
3795
3785
  max,
3796
3786
  viewYear,
3797
- placeholder
3787
+ placeholder,
3788
+ intl: {
3789
+ formatMessage
3790
+ }
3798
3791
  } = this.props;
3799
3792
  return /*#__PURE__*/jsxs(Fragment, {
3800
3793
  children: [/*#__PURE__*/jsx(DateHeader$1, {
3794
+ dateMode: formatMessage(messages$4.twentyYears),
3801
3795
  onPreviousClick: this.selectPreviousYears,
3802
3796
  onNextClick: this.selectNextYears
3803
3797
  }), /*#__PURE__*/jsx(YearCalendarTable$1, {
@@ -3825,7 +3819,7 @@ YearCalendar.defaultProps = {
3825
3819
  min: null,
3826
3820
  max: null
3827
3821
  };
3828
- var YearCalendar$1 = YearCalendar;
3822
+ var YearCalendar$1 = injectIntl(YearCalendar);
3829
3823
 
3830
3824
  const MODE = {
3831
3825
  DAY: 'day',
@@ -4242,21 +4236,14 @@ const Tile = ({
4242
4236
  title
4243
4237
  }) => {
4244
4238
  const isSmall = size === Size.SMALL;
4245
- const {
4246
- isModern
4247
- } = useTheme();
4248
4239
  const Element = href ? 'a' : 'button';
4249
4240
  return /*#__PURE__*/jsxs(Element, {
4250
4241
  className: classNames('decision', 'flex-column', 'np-tile', 'text-no-decoration', 'text-xs-center', className, {
4251
- 'p-a-3': !isSmall && isModern,
4252
- 'p-y-5 p-x-4': !isSmall && !isModern,
4253
- 'p-a-2': isSmall,
4254
- 'np-tile--small': isSmall,
4255
- disabled
4256
- }),
4242
+ 'p-a-3': !isSmall,
4243
+ 'p-a-2 np-tile--small': isSmall
4244
+ }, disabled && 'disabled'),
4257
4245
  href: href,
4258
4246
  target: target,
4259
- "aria-label": title,
4260
4247
  onClick: disabled ? null : onClick,
4261
4248
  onKeyDown: disabled ? null : ({
4262
4249
  key
@@ -4272,15 +4259,12 @@ const Tile = ({
4272
4259
  type: Typography.TITLE_SUBSECTION,
4273
4260
  className: classNames(isSmall ? 'm-t-1' : 'm-t-2'),
4274
4261
  children: title
4275
- }), isModern && description && /*#__PURE__*/jsx(Body, {
4262
+ }), description ? /*#__PURE__*/jsx(Body, {
4276
4263
  as: "span",
4277
4264
  type: Typography.BODY_DEFAULT,
4278
4265
  className: "m-t-1",
4279
4266
  children: description
4280
- }), !isModern && description && /*#__PURE__*/jsx("div", {
4281
- className: "np-tile__description",
4282
- children: description
4283
- })]
4267
+ }) : null]
4284
4268
  });
4285
4269
  };
4286
4270
  Tile.propTypes = {
@@ -5293,14 +5277,6 @@ LogoWise.defaultProps = {
5293
5277
  height: "24",
5294
5278
  fill: "none"
5295
5279
  };
5296
- const baseUrl = 'https://wise.com/public-resources/assets/logos/wise/';
5297
- const logoPaths = {
5298
- WISE: 'brand_logo.svg',
5299
- WISE_BUSINESS: 'brand_logo_business.svg',
5300
- WISE_INVERSE: 'brand_logo_inverse.svg',
5301
- WISE_BUSINESS_INVERSE: 'brand_logo_business_inverse.svg',
5302
- WISE_FLAG: 'brand_flag.svg'
5303
- };
5304
5280
  const svgPaths = {
5305
5281
  WISE: LogoWise,
5306
5282
  WISE_BUSINESS: LogoWise,
@@ -5314,21 +5290,14 @@ const Logo = ({
5314
5290
  inverse,
5315
5291
  type
5316
5292
  }) => {
5317
- const {
5318
- isModern
5319
- } = useTheme();
5320
5293
  const [clientWidth] = useClientWidth({
5321
5294
  ref: isServerSide() ? undefined : window
5322
5295
  });
5323
5296
  const isSmall = clientWidth < Breakpoint.SMALL;
5324
- const path = isSmall ? logoPaths['WISE_FLAG'] : logoPaths[`${type}${inverse ? '_INVERSE' : ''}`];
5325
5297
  const LogoSvg = isSmall ? svgPaths[`WISE_FLAG${inverse ? '_INVERSE' : ''}`] : svgPaths[`${type}${inverse ? '_INVERSE' : ''}`];
5326
- return isModern ? /*#__PURE__*/jsx(LogoSvg, {
5327
- className: "np-logo-svg"
5328
- }) : /*#__PURE__*/jsx("img", {
5329
- className: classNames('np-logo', className),
5330
- alt: type === LogoType.WISE ? 'Wise' : 'Wise business',
5331
- src: `${baseUrl}${path}`
5298
+ return /*#__PURE__*/jsx(LogoSvg, {
5299
+ className: classNames('np-logo-svg', className),
5300
+ alt: type === LogoType.WISE ? 'Wise' : 'Wise business'
5332
5301
  });
5333
5302
  };
5334
5303
  Logo.propTypes = {
@@ -5500,13 +5469,12 @@ const Stepper = ({
5500
5469
  children: /*#__PURE__*/jsx("small", {
5501
5470
  children: step.label
5502
5471
  })
5503
- }) : /*#__PURE__*/jsx(Body, {
5504
- as: "span",
5505
- className: "tw-stepper__step-label small",
5472
+ }) : /*#__PURE__*/jsx("span", {
5473
+ className: "tw-stepper__step-label",
5506
5474
  children: step.label
5507
5475
  });
5508
5476
  return /*#__PURE__*/jsx("li", {
5509
- className: classNames('hidden-xs', 'tw-stepper__step', active && 'tw-stepper__step--active', clickable && 'tw-stepper__step--clickable', step.hoverLabel && 'tw-stepper__step--has-tooltip'),
5477
+ className: classNames('hidden-xs', 'tw-stepper__step', active ? 'np-text-body-default-bold tw-stepper__step--active' : 'np-text-body-default', clickable && 'tw-stepper__step--clickable', step.hoverLabel && 'tw-stepper__step--has-tooltip'),
5510
5478
  style: isRTL ? {
5511
5479
  right: `${index * stepPercentage * 100}%`
5512
5480
  } : {
@@ -5839,7 +5807,7 @@ const Modal = ({
5839
5807
  });
5840
5808
  };
5841
5809
 
5842
- const Popover = ({
5810
+ const Popover$1 = ({
5843
5811
  children,
5844
5812
  className,
5845
5813
  content,
@@ -5893,12 +5861,12 @@ const logActionRequired = ({
5893
5861
  }) => {
5894
5862
  logActionRequiredIf(`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${deprecatedPlacements[preferredPlacement]} instead.`, deprecatedPlacements[preferredPlacement]);
5895
5863
  };
5896
- Popover.defaultProps = {
5864
+ Popover$1.defaultProps = {
5897
5865
  className: undefined,
5898
5866
  preferredPlacement: Position.RIGHT,
5899
5867
  title: undefined
5900
5868
  };
5901
- Popover.propTypes = {
5869
+ Popover$1.propTypes = {
5902
5870
  children: PropTypes.node.isRequired,
5903
5871
  className: PropTypes.string,
5904
5872
  content: PropTypes.node.isRequired,
@@ -5915,7 +5883,7 @@ const deprecatedPlacements = {
5915
5883
  [Position.LEFT_TOP]: Position.TOP,
5916
5884
  [Position.RIGHT_TOP]: Position.TOP
5917
5885
  };
5918
- var Popover$1 = Popover;
5886
+ var Popover$2 = Popover$1;
5919
5887
 
5920
5888
  const Info = ({
5921
5889
  className = undefined,
@@ -5957,7 +5925,7 @@ const Info = ({
5957
5925
  title: title,
5958
5926
  onClose: () => setOpen(false)
5959
5927
  })]
5960
- }) : /*#__PURE__*/jsx(Popover$1, {
5928
+ }) : /*#__PURE__*/jsx(Popover$2, {
5961
5929
  content: content,
5962
5930
  preferredPlacement: Position.BOTTOM,
5963
5931
  title: title,
@@ -6146,11 +6114,12 @@ function formControlClassNameBase({
6146
6114
  'np-form-control--size-sm np-text-body-default': size === 'sm',
6147
6115
  'np-form-control--size-md np-text-body-large': size === 'md',
6148
6116
  'np-form-control--size-lg np-text-title-subsection': size === 'lg'
6149
- }, 'np-form-control--shape-rectangle');
6117
+ });
6150
6118
  }
6151
6119
 
6152
6120
  const Input = /*#__PURE__*/forwardRef(function Input({
6153
6121
  size = 'auto',
6122
+ shape = 'rectangle',
6154
6123
  className,
6155
6124
  ...restProps
6156
6125
  }, reference) {
@@ -6159,7 +6128,10 @@ const Input = /*#__PURE__*/forwardRef(function Input({
6159
6128
  ref: reference,
6160
6129
  className: classNames(className, formControlClassNameBase({
6161
6130
  size
6162
- }))
6131
+ }), 'np-input', {
6132
+ 'np-input--shape-rectangle': shape === 'rectangle',
6133
+ 'np-input--shape-pill': shape === 'pill'
6134
+ })
6163
6135
  // eslint-disable-next-line react/forbid-dom-props
6164
6136
  ,
6165
6137
  style: inputPaddings,
@@ -6167,6 +6139,653 @@ const Input = /*#__PURE__*/forwardRef(function Input({
6167
6139
  });
6168
6140
  });
6169
6141
 
6142
+ const SearchInput = /*#__PURE__*/forwardRef(function SearchInput({
6143
+ shape = 'pill',
6144
+ disabled,
6145
+ className,
6146
+ ...restProps
6147
+ }, ref) {
6148
+ return /*#__PURE__*/jsx(InputGroup, {
6149
+ addonStart: {
6150
+ content: /*#__PURE__*/jsx(Search, {
6151
+ size: 24
6152
+ }),
6153
+ initialContentWidth: 24
6154
+ },
6155
+ disabled: disabled,
6156
+ className: className,
6157
+ children: /*#__PURE__*/jsx(Input, {
6158
+ ref: ref,
6159
+ role: "searchbox",
6160
+ inputMode: "search",
6161
+ shape: shape,
6162
+ ...restProps
6163
+ })
6164
+ });
6165
+ });
6166
+
6167
+ function useMedia(query) {
6168
+ return useSyncExternalStore(onStoreChange => {
6169
+ const mediaQueryList = window.matchMedia(query);
6170
+ mediaQueryList.addEventListener('change', onStoreChange);
6171
+ return () => {
6172
+ mediaQueryList.removeEventListener('change', onStoreChange);
6173
+ };
6174
+ }, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
6175
+ }
6176
+
6177
+ function useScreenSize(size) {
6178
+ return useMedia(`(min-width: ${size}px)`);
6179
+ }
6180
+
6181
+ function wrapInFragment(value) {
6182
+ return /*#__PURE__*/jsx(Fragment, {
6183
+ children: value
6184
+ });
6185
+ }
6186
+
6187
+ function PreventScroll() {
6188
+ usePreventScroll();
6189
+ return null;
6190
+ }
6191
+
6192
+ function BottomSheet({
6193
+ open,
6194
+ renderTrigger,
6195
+ title,
6196
+ initialFocusRef,
6197
+ padding = 'md',
6198
+ children,
6199
+ onClose
6200
+ }) {
6201
+ const {
6202
+ refs,
6203
+ context
6204
+ } = useFloating({
6205
+ open,
6206
+ onOpenChange: value => {
6207
+ if (!value) {
6208
+ onClose?.();
6209
+ }
6210
+ }
6211
+ });
6212
+ const dismiss = useDismiss(context, {
6213
+ outsidePressEvent: 'mousedown'
6214
+ });
6215
+ const role = useRole(context);
6216
+ const {
6217
+ getReferenceProps,
6218
+ getFloatingProps
6219
+ } = useInteractions([dismiss, role]);
6220
+ const [floatingKey, setFloatingKey] = useState(0);
6221
+ return /*#__PURE__*/jsxs(Fragment, {
6222
+ children: [open ? /*#__PURE__*/jsx(PreventScroll, {}) : null, renderTrigger?.({
6223
+ ref: refs.setReference,
6224
+ getInteractionProps: getReferenceProps
6225
+ }), /*#__PURE__*/jsx(FloatingPortal, {
6226
+ children: /*#__PURE__*/jsxs(Transition, {
6227
+ show: open,
6228
+ className: "np-bottom-sheet-v2-container",
6229
+ beforeEnter: () => {
6230
+ setFloatingKey(prev => prev + 1);
6231
+ },
6232
+ children: [/*#__PURE__*/jsx(Transition.Child, {
6233
+ enter: "np-bottom-sheet-v2-backdrop-container--enter",
6234
+ enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
6235
+ leave: "np-bottom-sheet-v2-backdrop-container--leave",
6236
+ leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
6237
+ children: /*#__PURE__*/jsx("div", {
6238
+ className: "np-bottom-sheet-v2-backdrop"
6239
+ })
6240
+ }), /*#__PURE__*/jsx(FloatingFocusManager, {
6241
+ context: context,
6242
+ initialFocus: initialFocusRef,
6243
+ children: /*#__PURE__*/jsx("div", {
6244
+ className: "np-bottom-sheet-v2",
6245
+ children: /*#__PURE__*/jsx(Transition.Child, {
6246
+ className: "np-bottom-sheet-v2-content",
6247
+ enter: "np-bottom-sheet-v2-content--enter",
6248
+ enterFrom: "np-bottom-sheet-v2-content--enter-from",
6249
+ leave: "np-bottom-sheet-v2-content--leave",
6250
+ leaveTo: "np-bottom-sheet-v2-content--leave-to",
6251
+ children: /*#__PURE__*/jsxs("div", {
6252
+ // Force inner state invalidation on open
6253
+ ref: refs.setFloating,
6254
+ className: "np-bottom-sheet-v2-content-inner-container",
6255
+ ...getFloatingProps(),
6256
+ children: [/*#__PURE__*/jsx("div", {
6257
+ className: "np-bottom-sheet-v2-header",
6258
+ children: /*#__PURE__*/jsx(CloseButton, {
6259
+ size: Size.SMALL,
6260
+ onClick: () => {
6261
+ onClose?.();
6262
+ }
6263
+ })
6264
+ }), /*#__PURE__*/jsxs("div", {
6265
+ className: classNames('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
6266
+ 'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
6267
+ }),
6268
+ children: [title ? /*#__PURE__*/jsx("h2", {
6269
+ className: "np-bottom-sheet-v2-title np-text-title-body",
6270
+ children: title
6271
+ }) : null, /*#__PURE__*/jsx("div", {
6272
+ className: "np-bottom-sheet-v2-body np-text-body-default",
6273
+ children: children
6274
+ })]
6275
+ })]
6276
+ }, floatingKey)
6277
+ })
6278
+ })
6279
+ })]
6280
+ })
6281
+ })]
6282
+ });
6283
+ }
6284
+
6285
+ const ButtonInput = /*#__PURE__*/forwardRef(function ButtonInput({
6286
+ size = 'md',
6287
+ className,
6288
+ style,
6289
+ ...restProps
6290
+ }, ref) {
6291
+ const inputPaddings = useInputPaddings();
6292
+ return /*#__PURE__*/jsx("button", {
6293
+ ref: ref,
6294
+ type: "button",
6295
+ className: classNames(className, formControlClassNameBase({
6296
+ size
6297
+ }), 'np-button-input')
6298
+ // eslint-disable-next-line react/forbid-dom-props
6299
+ ,
6300
+ style: {
6301
+ ...inputPaddings,
6302
+ ...style
6303
+ },
6304
+ ...restProps
6305
+ });
6306
+ });
6307
+
6308
+ const floatingPadding = 16;
6309
+ function Popover({
6310
+ placement,
6311
+ open,
6312
+ renderTrigger,
6313
+ title,
6314
+ padding = 'md',
6315
+ children,
6316
+ onClose
6317
+ }) {
6318
+ const {
6319
+ refs,
6320
+ floatingStyles,
6321
+ context
6322
+ } = useFloating({
6323
+ placement,
6324
+ middleware: [offset(8), flip({
6325
+ padding: floatingPadding,
6326
+ crossAxis: false
6327
+ }), shift(), size({
6328
+ padding: floatingPadding,
6329
+ apply: ({
6330
+ elements,
6331
+ rects,
6332
+ availableHeight
6333
+ }) => {
6334
+ elements.floating.style.setProperty('--max-height', `${availableHeight}px`);
6335
+ elements.floating.style.setProperty('--width', `${rects.reference.width}px`);
6336
+ }
6337
+ })],
6338
+ whileElementsMounted: autoUpdate,
6339
+ open,
6340
+ onOpenChange: value => {
6341
+ if (!value) {
6342
+ onClose?.();
6343
+ }
6344
+ }
6345
+ });
6346
+ const dismiss = useDismiss(context, {
6347
+ outsidePressEvent: 'mousedown'
6348
+ });
6349
+ const role = useRole(context);
6350
+ const {
6351
+ getReferenceProps,
6352
+ getFloatingProps
6353
+ } = useInteractions([role, dismiss]);
6354
+ const [floatingKey, setFloatingKey] = useState(0);
6355
+ return /*#__PURE__*/jsxs(Fragment, {
6356
+ children: [open ? /*#__PURE__*/jsx(PreventScroll, {}) : null, renderTrigger({
6357
+ ref: refs.setReference,
6358
+ getInteractionProps: getReferenceProps
6359
+ }), /*#__PURE__*/jsx(FloatingPortal, {
6360
+ children: /*#__PURE__*/jsx(FloatingFocusManager, {
6361
+ context: context,
6362
+ children: /*#__PURE__*/jsx(Transition, {
6363
+ show: open,
6364
+ leave: "transition-opacity",
6365
+ leaveTo: "opacity-0",
6366
+ beforeEnter: () => {
6367
+ setFloatingKey(prev => prev + 1);
6368
+ },
6369
+ children: /*#__PURE__*/jsx("div", {
6370
+ // Force inner state invalidation on open
6371
+ ref: refs.setFloating,
6372
+ className: "np-popover-v2-container"
6373
+ // eslint-disable-next-line react/forbid-dom-props
6374
+ ,
6375
+ style: floatingStyles,
6376
+ ...getFloatingProps(),
6377
+ children: /*#__PURE__*/jsxs("div", {
6378
+ className: classNames('np-popover-v2', title && 'np-popover-v2--has-title', {
6379
+ 'np-popover-v2--padding-md': padding === 'md'
6380
+ }),
6381
+ children: [title ? /*#__PURE__*/jsx("h2", {
6382
+ className: "np-popover-v2-title np-text-title-body",
6383
+ children: title
6384
+ }) : null, /*#__PURE__*/jsx("div", {
6385
+ className: "np-popover-v2-content np-text-body-default",
6386
+ children: children
6387
+ })]
6388
+ })
6389
+ }, floatingKey)
6390
+ })
6391
+ })
6392
+ })]
6393
+ });
6394
+ }
6395
+
6396
+ function searchableString(value) {
6397
+ return value.trim().replace(/\s+/gu, ' ').toLowerCase();
6398
+ }
6399
+ function inferSearchableStrings(value) {
6400
+ if (typeof value === 'string') {
6401
+ return [searchableString(value)];
6402
+ }
6403
+ if (typeof value === 'object' && value != null) {
6404
+ return Object.values(value).filter(innerValue => typeof innerValue === 'string').map(innerValue => searchableString(innerValue));
6405
+ }
6406
+ return [];
6407
+ }
6408
+ const SelectInputHasValueContext = /*#__PURE__*/createContext(false);
6409
+ const SelectInputOptionContentCompactContext = /*#__PURE__*/createContext(false);
6410
+ function dedupeSelectInputOptionItem(item, existingValues) {
6411
+ if (existingValues.has(item.value)) {
6412
+ return {
6413
+ ...item,
6414
+ value: undefined
6415
+ };
6416
+ }
6417
+ existingValues.add(item.value);
6418
+ return item;
6419
+ }
6420
+ function dedupeSelectInputItems(items) {
6421
+ const existingValues = new Set();
6422
+ return items.map(item => {
6423
+ switch (item.type) {
6424
+ case 'option':
6425
+ {
6426
+ return dedupeSelectInputOptionItem(item, existingValues);
6427
+ }
6428
+ case 'group':
6429
+ {
6430
+ return {
6431
+ ...item,
6432
+ options: item.options.map(option => dedupeSelectInputOptionItem(option, existingValues))
6433
+ };
6434
+ }
6435
+ }
6436
+ return item;
6437
+ });
6438
+ }
6439
+ function SelectInput({
6440
+ name,
6441
+ placeholder,
6442
+ items,
6443
+ defaultValue,
6444
+ value: controlledValue,
6445
+ renderValue = wrapInFragment,
6446
+ compareValues,
6447
+ filterable,
6448
+ filterPlaceholder,
6449
+ disabled,
6450
+ className,
6451
+ onChange,
6452
+ onClear
6453
+ }) {
6454
+ const intl = useIntl();
6455
+ const [open, setOpen] = useState(false);
6456
+ const triggerRef = useRef(null);
6457
+ const screenSm = useScreenSize(Breakpoint.SMALL);
6458
+ const OptionsOverlay = screenSm ? Popover : BottomSheet;
6459
+ const searchInputRef = useRef(null);
6460
+ const listboxRef = useRef(null);
6461
+ const controllerRef = filterable ? searchInputRef : listboxRef;
6462
+ return /*#__PURE__*/jsx(Listbox, {
6463
+ name: name,
6464
+ defaultValue: defaultValue,
6465
+ value: controlledValue
6466
+ // TODO: Remove assertion when upgrading TypeScript to v5
6467
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
6468
+ ,
6469
+ by: compareValues,
6470
+ disabled: disabled,
6471
+ onChange: value => {
6472
+ setOpen(false);
6473
+ onChange?.(value);
6474
+ },
6475
+ children: ({
6476
+ disabled: uiDisabled,
6477
+ value
6478
+ }) => /*#__PURE__*/jsx(SelectInputHasValueContext.Provider, {
6479
+ value: value != null,
6480
+ children: /*#__PURE__*/jsx(InputGroup, {
6481
+ addonEnd: {
6482
+ content: /*#__PURE__*/jsxs("span", {
6483
+ className: classNames('np-select-input-addon-container', uiDisabled && 'disabled'),
6484
+ children: [onClear != null && value != null ? /*#__PURE__*/jsxs(Fragment, {
6485
+ children: [/*#__PURE__*/jsx("button", {
6486
+ type: "button",
6487
+ "aria-label": intl.formatMessage(messages$5.ariaLabel),
6488
+ disabled: uiDisabled,
6489
+ className: "np-select-input-addon np-select-input-addon--interactive",
6490
+ onClick: event => {
6491
+ event.preventDefault();
6492
+ onClear();
6493
+ triggerRef.current?.focus({
6494
+ preventScroll: true
6495
+ });
6496
+ },
6497
+ children: /*#__PURE__*/jsx(Cross, {
6498
+ size: 16
6499
+ })
6500
+ }), /*#__PURE__*/jsx("span", {
6501
+ className: "np-select-input-addon-separator"
6502
+ })]
6503
+ }) : null, /*#__PURE__*/jsx("span", {
6504
+ className: "np-select-input-addon",
6505
+ children: /*#__PURE__*/jsx(ChevronDown, {
6506
+ size: 16
6507
+ })
6508
+ })]
6509
+ }),
6510
+ padding: 'sm'
6511
+ },
6512
+ className: className,
6513
+ children: /*#__PURE__*/jsx(OptionsOverlay, {
6514
+ open: open,
6515
+ renderTrigger: ({
6516
+ ref,
6517
+ getInteractionProps
6518
+ }) => /*#__PURE__*/jsx(Listbox.Button, {
6519
+ ref: mergeRefs([ref, triggerRef]),
6520
+ as: SelectInputButton,
6521
+ overrides: getInteractionProps(),
6522
+ onClick: () => {
6523
+ setOpen(prev => !prev);
6524
+ },
6525
+ children: value != null ? /*#__PURE__*/jsx(SelectInputOptionContentCompactContext.Provider, {
6526
+ value: true,
6527
+ children: renderValue(value, true)
6528
+ }) : /*#__PURE__*/jsx("span", {
6529
+ className: "np-select-input-placeholder",
6530
+ children: placeholder
6531
+ })
6532
+ }),
6533
+ initialFocusRef: controllerRef,
6534
+ padding: "none",
6535
+ onClose: () => {
6536
+ setOpen(false);
6537
+ },
6538
+ children: /*#__PURE__*/jsx(SelectInputOptions, {
6539
+ items: items,
6540
+ renderValue: renderValue,
6541
+ filterable: filterable,
6542
+ filterPlaceholder: filterPlaceholder,
6543
+ searchInputRef: searchInputRef,
6544
+ listboxRef: listboxRef
6545
+ })
6546
+ })
6547
+ })
6548
+ })
6549
+ });
6550
+ }
6551
+ const SelectInputButton = /*#__PURE__*/forwardRef(function SelectInputButton({
6552
+ overrides,
6553
+ ...restProps
6554
+ }, ref) {
6555
+ return /*#__PURE__*/jsx(ButtonInput, {
6556
+ ref: ref,
6557
+ ...restProps,
6558
+ ...overrides
6559
+ });
6560
+ });
6561
+ const SelectInputOptionsContainer = /*#__PURE__*/forwardRef(function SelectInputOptionsContainer({
6562
+ 'aria-orientation': ariaOrientation,
6563
+ 'aria-activedescendant': ariaActiveDescendant,
6564
+ role,
6565
+ tabIndex,
6566
+ onAriaActiveDescendantChange,
6567
+ onKeyDown,
6568
+ ...restProps
6569
+ }, ref) {
6570
+ const handleAriaActiveDescendantChange = useEffectEvent(onAriaActiveDescendantChange);
6571
+ useEffect(() => {
6572
+ handleAriaActiveDescendantChange(ariaActiveDescendant);
6573
+ }, [ariaActiveDescendant, handleAriaActiveDescendantChange]);
6574
+ return (
6575
+ /*#__PURE__*/
6576
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
6577
+ jsx("div", {
6578
+ ref: ref,
6579
+ onKeyDown: event => {
6580
+ // Prevent absorbing dismissal requests too early
6581
+ if (event.key !== 'Escape') {
6582
+ onKeyDown?.(event);
6583
+ }
6584
+ },
6585
+ ...restProps
6586
+ })
6587
+ );
6588
+ });
6589
+ function SelectInputOptions({
6590
+ items,
6591
+ renderValue = wrapInFragment,
6592
+ filterable,
6593
+ filterPlaceholder,
6594
+ searchInputRef,
6595
+ listboxRef
6596
+ }) {
6597
+ const [query, setQuery] = useState('');
6598
+ const needle = useMemo(() => query ? searchableString(query) : null, [query]);
6599
+ const listboxContainerRef = useRef(null);
6600
+ useEffect(() => {
6601
+ if (listboxContainerRef.current != null) {
6602
+ listboxContainerRef.current.style.setProperty('--initial-height', `${listboxContainerRef.current.offsetHeight}px`);
6603
+ }
6604
+ }, []);
6605
+ const listboxId = useId();
6606
+ const controllerRef = filterable ? searchInputRef : listboxRef;
6607
+ return /*#__PURE__*/jsxs(Listbox.Options, {
6608
+ as: SelectInputOptionsContainer,
6609
+ static: true,
6610
+ className: "np-select-input-options-container",
6611
+ onAriaActiveDescendantChange: value => {
6612
+ if (controllerRef.current != null) {
6613
+ if (value != null) {
6614
+ controllerRef.current.setAttribute('aria-activedescendant', value);
6615
+ } else {
6616
+ controllerRef.current.removeAttribute('aria-activedescendant');
6617
+ }
6618
+ }
6619
+ },
6620
+ children: [filterable ? /*#__PURE__*/jsx("div", {
6621
+ className: "np-select-input-query-container",
6622
+ children: /*#__PURE__*/jsx(SearchInput, {
6623
+ ref: searchInputRef,
6624
+ shape: "rectangle",
6625
+ placeholder: filterPlaceholder,
6626
+ value: query,
6627
+ "aria-controls": listboxId,
6628
+ onKeyDown: event => {
6629
+ // Prevent interfering with the matcher of Headless UI
6630
+ // https://mathiasbynens.be/notes/javascript-unicode#regex
6631
+ if (/^.$/u.test(event.key)) {
6632
+ event.stopPropagation();
6633
+ }
6634
+ },
6635
+ onChange: event => {
6636
+ setQuery(event.currentTarget.value);
6637
+ }
6638
+ })
6639
+ }) : null, /*#__PURE__*/jsx("div", {
6640
+ ref: listboxContainerRef,
6641
+ className: classNames('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
6642
+ children: /*#__PURE__*/jsx("div", {
6643
+ ref: listboxRef,
6644
+ id: listboxId,
6645
+ role: "listbox",
6646
+ "aria-orientation": "vertical",
6647
+ tabIndex: 0,
6648
+ className: "np-select-input-listbox",
6649
+ children: (needle == null ? items : dedupeSelectInputItems(items)).map((item, index) => /*#__PURE__*/jsx(SelectInputItemView
6650
+ // eslint-disable-next-line react/no-array-index-key
6651
+ , {
6652
+ item: item,
6653
+ renderValue: renderValue,
6654
+ needle: needle
6655
+ }, index))
6656
+ })
6657
+ })]
6658
+ });
6659
+ }
6660
+ function SelectInputItemView({
6661
+ item,
6662
+ renderValue,
6663
+ needle
6664
+ }) {
6665
+ switch (item.type) {
6666
+ case 'option':
6667
+ {
6668
+ if (item.value != null && (!needle || inferSearchableStrings(item.filterMatchers ?? item.value).some(haystack => haystack.includes(needle)))) {
6669
+ return /*#__PURE__*/jsx(SelectInputOption, {
6670
+ value: item.value,
6671
+ disabled: item.disabled,
6672
+ children: renderValue(item.value, false)
6673
+ });
6674
+ }
6675
+ break;
6676
+ }
6677
+ case 'group':
6678
+ {
6679
+ return /*#__PURE__*/jsx(SelectInputGroupItemView, {
6680
+ item: item,
6681
+ renderValue: renderValue,
6682
+ needle: needle
6683
+ });
6684
+ }
6685
+ case 'separator':
6686
+ {
6687
+ if (needle == null) {
6688
+ return /*#__PURE__*/jsx("hr", {
6689
+ className: "np-select-input-separator-item",
6690
+ "aria-hidden": true
6691
+ });
6692
+ }
6693
+ break;
6694
+ }
6695
+ }
6696
+ return null;
6697
+ }
6698
+ function SelectInputGroupItemView({
6699
+ item,
6700
+ renderValue,
6701
+ needle
6702
+ }) {
6703
+ const headerId = useId();
6704
+ return (
6705
+ /*#__PURE__*/
6706
+ // An empty container may be rendered when no options match `needle`
6707
+ // However, pre-filtering would result in worse performance overall
6708
+ jsxs("section", {
6709
+ role: "group",
6710
+ "aria-labelledby": headerId,
6711
+ className: classNames(needle == null && 'np-select-input-group-item--without-needle'),
6712
+ children: [needle == null ? /*#__PURE__*/jsx("header", {
6713
+ id: headerId,
6714
+ role: "presentation",
6715
+ className: "np-select-input-group-item-header np-text-title-group",
6716
+ children: item.label
6717
+ }) : null, item.options.map((option, index) => /*#__PURE__*/jsx(SelectInputItemView
6718
+ // eslint-disable-next-line react/no-array-index-key
6719
+ , {
6720
+ item: option,
6721
+ renderValue: renderValue,
6722
+ needle: needle
6723
+ }, index))]
6724
+ })
6725
+ );
6726
+ }
6727
+ function SelectInputOption({
6728
+ value,
6729
+ disabled,
6730
+ children
6731
+ }) {
6732
+ const parentHasValue = useContext(SelectInputHasValueContext);
6733
+ // Avoid flash during exit transition
6734
+ const {
6735
+ current: cachedParentHasValue
6736
+ } = useRef(parentHasValue);
6737
+ return /*#__PURE__*/jsx(Listbox.Option, {
6738
+ as: "div",
6739
+ value: value,
6740
+ disabled: disabled,
6741
+ className: ({
6742
+ active,
6743
+ disabled: uiDisabled
6744
+ }) => classNames('np-select-input-option-container np-text-body-large', active && 'np-select-input-option-container--active', uiDisabled && 'np-select-input-option-container--disabled'),
6745
+ children: ({
6746
+ selected
6747
+ }) => /*#__PURE__*/jsxs(Fragment, {
6748
+ children: [cachedParentHasValue ? /*#__PURE__*/jsx(Check, {
6749
+ size: 16,
6750
+ className: classNames(!selected && 'np-select-input-option-check--not-selected')
6751
+ }) : null, /*#__PURE__*/jsx("div", {
6752
+ className: "np-select-input-option",
6753
+ children: children
6754
+ })]
6755
+ })
6756
+ });
6757
+ }
6758
+ function SelectInputOptionContent({
6759
+ title,
6760
+ note,
6761
+ description,
6762
+ icon
6763
+ }) {
6764
+ const compact = useContext(SelectInputOptionContentCompactContext);
6765
+ return /*#__PURE__*/jsxs("div", {
6766
+ className: "np-select-input-option-content-container np-text-body-large",
6767
+ children: [icon ? /*#__PURE__*/jsx("div", {
6768
+ className: classNames('np-select-input-option-content-icon', !compact && 'np-select-input-option-content-icon--not-compact'),
6769
+ children: icon
6770
+ }) : null, /*#__PURE__*/jsxs("div", {
6771
+ className: "np-select-input-option-content-text",
6772
+ children: [/*#__PURE__*/jsxs("div", {
6773
+ className: classNames('np-select-input-option-content-text-line-1', compact && 'np-select-input-option-content-text-compact'),
6774
+ children: [/*#__PURE__*/jsx("h4", {
6775
+ className: "d-inline np-text-body-large",
6776
+ children: title
6777
+ }), note ? /*#__PURE__*/jsx("span", {
6778
+ className: "np-select-input-option-content-text-secondary np-text-body-default",
6779
+ children: note
6780
+ }) : null]
6781
+ }), description ? /*#__PURE__*/jsx("div", {
6782
+ className: classNames('np-select-input-option-content-text-secondary np-text-body-default', compact && 'np-select-input-option-content-text-compact'),
6783
+ children: description
6784
+ }) : null]
6785
+ })]
6786
+ });
6787
+ }
6788
+
6170
6789
  const TextArea = /*#__PURE__*/forwardRef(function TextArea({
6171
6790
  className,
6172
6791
  ...restProps
@@ -7282,7 +7901,7 @@ function Select({
7282
7901
  headerTitle: searchPlaceholder || formatMessage(messages$3.searchPlaceholder),
7283
7902
  onClose: handleCloseOptions,
7284
7903
  children: renderOptionsList()
7285
- }) : /*#__PURE__*/jsx(BottomSheet$1, {
7904
+ }) : /*#__PURE__*/jsx(BottomSheet$2, {
7286
7905
  open: open,
7287
7906
  onClose: handleCloseOptions,
7288
7907
  children: renderOptionsList({
@@ -9464,6 +10083,7 @@ const PhoneNumberInput = props => {
9464
10083
  className: `input-group input-group-${size}`,
9465
10084
  children: /*#__PURE__*/jsx("input", {
9466
10085
  id: id,
10086
+ autoComplete: "tel-national",
9467
10087
  name: "phoneNumber",
9468
10088
  inputMode: "numeric",
9469
10089
  value: internalValue.suffix,
@@ -9938,6 +10558,14 @@ var en = {
9938
10558
  "neptune.DateInput.day.label": "Day",
9939
10559
  "neptune.DateInput.month.label": "Month",
9940
10560
  "neptune.DateInput.year.label": "Year",
10561
+ "neptune.DateLookup.day": "day",
10562
+ "neptune.DateLookup.goTo20YearView": "Go to 20 year view",
10563
+ "neptune.DateLookup.month": "month",
10564
+ "neptune.DateLookup.next": "next",
10565
+ "neptune.DateLookup.previous": "previous",
10566
+ "neptune.DateLookup.selected": "selected",
10567
+ "neptune.DateLookup.twentyYears": "20 years",
10568
+ "neptune.DateLookup.year": "year",
9941
10569
  "neptune.Link.opensInNewTab": "(opens in new tab)",
9942
10570
  "neptune.MoneyInput.Select.placeholder": "Select an option...",
9943
10571
  "neptune.Select.searchPlaceholder": "Search...",
@@ -10399,6 +11027,7 @@ class Snackbar extends Component {
10399
11027
  ref: this.bodyRef,
10400
11028
  as: "span",
10401
11029
  className: `snackbar__text snackbar__text--${theme}`,
11030
+ "aria-live": "polite",
10402
11031
  children: [text, action ? /*#__PURE__*/jsx(ActionButton, {
10403
11032
  className: "snackbar__text__action",
10404
11033
  onClick: action.onClick,
@@ -11298,7 +11927,8 @@ class Tabs extends Component {
11298
11927
  children: title
11299
11928
  }, title);
11300
11929
  }), translateLineX ? /*#__PURE__*/jsx("li", {
11301
- className: classNames('tabs__line'),
11930
+ role: "none",
11931
+ className: "tabs__line",
11302
11932
  style: {
11303
11933
  width: this.getTabLineWidth(),
11304
11934
  transform: isRTL ? `translateX(-${translateLineX})` : `translateX(${translateLineX})`
@@ -12445,6 +13075,7 @@ const ProcessingStep = props => {
12445
13075
  'm-b-2': isModern
12446
13076
  }),
12447
13077
  type: Typography.TITLE_BODY,
13078
+ "aria-live": "polite",
12448
13079
  children: psProcessingText
12449
13080
  }), psButtonText && /*#__PURE__*/jsx(Button, {
12450
13081
  disabled: psButtonDisabled,
@@ -12488,6 +13119,7 @@ const CompleteStep = props => {
12488
13119
  className: "droppable-card-content",
12489
13120
  children: [/*#__PURE__*/jsx("div", {
12490
13121
  className: "droppable-card-content d-flex flex-column align-items-center",
13122
+ "aria-live": "polite",
12491
13123
  children: isError ? /*#__PURE__*/jsxs(Fragment, {
12492
13124
  children: [isModern ? /*#__PURE__*/jsx(StatusIcon, {
12493
13125
  size: Size.LARGE,
@@ -12856,6 +13488,7 @@ class Upload extends Component {
12856
13488
  onClear: event => this.handleOnClear(event)
12857
13489
  }), !isProcessing && /*#__PURE__*/jsx("div", {
12858
13490
  className: "droppable-dropping-card droppable-card",
13491
+ "aria-live": "polite",
12859
13492
  children: /*#__PURE__*/jsxs("div", {
12860
13493
  className: "droppable-card-content",
12861
13494
  children: [/*#__PURE__*/jsx("div", {
@@ -13330,6 +13963,7 @@ const UploadItem = ({
13330
13963
  onDownload: onDownloadFile,
13331
13964
  children: /*#__PURE__*/jsx("div", {
13332
13965
  className: "np-upload-button",
13966
+ "aria-live": "polite",
13333
13967
  children: /*#__PURE__*/jsxs("div", {
13334
13968
  className: "media",
13335
13969
  children: [/*#__PURE__*/jsx("div", {
@@ -14397,5 +15031,5 @@ const translations = {
14397
15031
  zh
14398
15032
  };
14399
15033
 
14400
- export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$1 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron$1 as 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$1 as 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$1 as PhoneNumberInput, Popover$1 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, Section, Select, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider$1 as SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat$1 as 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, useSnackbar };
15034
+ 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$1 as 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$1 as 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$1 as 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, Select, SelectInput, SelectInputOptionContent, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider$1 as SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat$1 as 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, useSnackbar };
14401
15035
  //# sourceMappingURL=index.esm.js.map