@transferwise/components 45.16.0 → 45.17.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 (46) hide show
  1. package/build/i18n/en.json +1 -0
  2. package/build/index.esm.js +52 -57
  3. package/build/index.esm.js.map +1 -1
  4. package/build/index.js +52 -57
  5. package/build/index.js.map +1 -1
  6. package/build/main.css +1 -1
  7. package/build/styles/common/Option/Option.css +1 -1
  8. package/build/styles/inputs/SelectInput.css +1 -1
  9. package/build/styles/main.css +1 -1
  10. package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
  11. package/build/types/button/Button.d.ts.map +1 -1
  12. package/build/types/button/Button.messages.d.ts +9 -0
  13. package/build/types/button/Button.messages.d.ts.map +1 -0
  14. package/build/types/common/index.d.ts +1 -0
  15. package/build/types/common/randomId.d.ts +13 -0
  16. package/build/types/common/randomId.d.ts.map +1 -0
  17. package/build/types/promoCard/PromoCard.d.ts.map +1 -1
  18. package/build/types/select/Select.d.ts.map +1 -1
  19. package/build/types/select/searchBox/SearchBox.d.ts.map +1 -1
  20. package/package.json +1 -1
  21. package/src/accordion/AccordionItem/AccordionItem.spec.js +1 -0
  22. package/src/accordion/AccordionItem/AccordionItem.tsx +19 -11
  23. package/src/accordion/AccordionItem/__snapshots__/AccordionItem.spec.js.snap +18 -4
  24. package/src/button/Button.messages.js +9 -0
  25. package/src/button/Button.spec.js +1 -2
  26. package/src/button/Button.tsx +11 -1
  27. package/src/button/__snapshots__/Button.spec.js.snap +22 -15
  28. package/src/common/Option/Option.css +1 -1
  29. package/src/common/Option/Option.less +0 -5
  30. package/src/common/index.js +1 -0
  31. package/src/common/randomId.ts +14 -0
  32. package/src/dateInput/DateInput.story.tsx +0 -3
  33. package/src/i18n/en.json +1 -0
  34. package/src/inputs/SelectInput.css +1 -1
  35. package/src/inputs/SelectInput.less +3 -0
  36. package/src/main.css +1 -1
  37. package/src/main.less +0 -3
  38. package/src/moneyInput/MoneyInput.story.tsx +0 -3
  39. package/src/phoneNumberInput/PhoneNumberInput.story.js +0 -3
  40. package/src/promoCard/PromoCard.tsx +1 -16
  41. package/src/select/Select.js +2 -0
  42. package/src/select/Select.story.js +0 -6
  43. package/src/select/searchBox/SearchBox.spec.js +3 -7
  44. package/src/select/searchBox/SearchBox.tsx +2 -0
  45. package/src/upload/Upload.spec.js +2 -0
  46. package/src/select/searchBox/__snapshots__/SearchBox.spec.js.snap +0 -46
@@ -1,4 +1,5 @@
1
1
  {
2
+ "neptune.Button.loadingAriaLabel": "loading",
2
3
  "neptune.Chips.ariaLabel": "Clear {choice}",
3
4
  "neptune.ClearButton.ariaLabel": "Clear",
4
5
  "neptune.CloseButton.ariaLabel": "Close",
@@ -2,6 +2,7 @@ import classNames from 'classnames';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import * as React from 'react';
4
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 { useId } from '@radix-ui/react-id';
5
6
  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
7
  import PropTypes from 'prop-types';
7
8
  import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
@@ -15,7 +16,6 @@ import mergeRefs from 'react-merge-refs';
15
16
  import { isUndefined, isKey, isNumber, isEmpty, isNull, isArray } from '@transferwise/neptune-validation';
16
17
  import { usePopper } from 'react-popper';
17
18
  import { Transition, Listbox } from '@headlessui/react';
18
- import { useId } from '@radix-ui/react-id';
19
19
  import { useSyncExternalStore } from 'use-sync-external-store/shim';
20
20
  import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, offset, flip, shift, size, autoUpdate } from '@floating-ui/react';
21
21
  import { usePreventScroll } from '@react-aria/overlays';
@@ -457,6 +457,21 @@ function getDirectionFromLocale(locale) {
457
457
  }
458
458
  }
459
459
 
460
+ /**
461
+ * generateRandomId() function
462
+ *
463
+ * This function generates a random string of characters that can be used as
464
+ * an ID.
465
+ *
466
+ * @returns {string} A random string of characters.
467
+ * @example
468
+ * const id = generateRandomId();
469
+ * // id will be a random string of characters, such as "id-4711".
470
+ */
471
+ const generateRandomId = () => {
472
+ return `id-${Math.random().toString(36).slice(7)}`;
473
+ };
474
+
460
475
  const DEFAULT_TYPE$1 = Typography.TITLE_GROUP;
461
476
  const titleTypeMapping = {
462
477
  [Typography.TITLE_SCREEN]: 'h1',
@@ -640,8 +655,10 @@ const AccordionItem = ({
640
655
  const iconElement = icon ? /*#__PURE__*/cloneElement(icon, {
641
656
  size: 24
642
657
  }) : null;
658
+ const fallbackId = useId();
659
+ const accordionId = id ?? fallbackId;
643
660
  return /*#__PURE__*/jsxs("div", {
644
- id: id,
661
+ id: accordionId,
645
662
  className: classNames('np-accordion-item', iconElement ? 'np-accordion-item--with-icon' : null, {
646
663
  'np-accordion-item--open': open
647
664
  }),
@@ -655,14 +672,22 @@ const AccordionItem = ({
655
672
  size: Size.MEDIUM
656
673
  }),
657
674
  inverseMediaCircle: false,
675
+ "aria-expanded": open,
676
+ "aria-controls": `${accordionId}-section`,
677
+ id: `${accordionId}-control`,
658
678
  onClick: onClick
659
- }), open && /*#__PURE__*/jsx(Body, {
660
- as: "span",
661
- type: Typography.BODY_LARGE,
662
- className: classNames('np-accordion-item__content', 'd-block', {
663
- 'has-icon': icon
664
- }),
665
- children: content
679
+ }), open && /*#__PURE__*/jsx("div", {
680
+ id: `${accordionId}-section`,
681
+ role: "region",
682
+ "aria-labelledby": `${accordionId}-control`,
683
+ children: /*#__PURE__*/jsx(Body, {
684
+ as: "span",
685
+ type: Typography.BODY_LARGE,
686
+ className: classNames('np-accordion-item__content', 'd-block', {
687
+ 'has-icon': icon
688
+ }),
689
+ children: content
690
+ })
666
691
  })]
667
692
  });
668
693
  };
@@ -763,7 +788,7 @@ const ActionOption = ({
763
788
  });
764
789
  };
765
790
 
766
- var messages$9 = defineMessages({
791
+ var messages$a = defineMessages({
767
792
  ariaLabel: {
768
793
  id: "neptune.CloseButton.ariaLabel"
769
794
  }
@@ -779,7 +804,7 @@ const CloseButton = /*#__PURE__*/forwardRef(function CloseButton({
779
804
  testId
780
805
  }, reference) {
781
806
  const intl = useIntl();
782
- ariaLabel ??= intl.formatMessage(messages$9.ariaLabel);
807
+ ariaLabel ??= intl.formatMessage(messages$a.ariaLabel);
783
808
  const Icon = filled ? CrossCircleFill : Cross;
784
809
  return /*#__PURE__*/jsx("button", {
785
810
  ref: reference,
@@ -799,7 +824,7 @@ const CloseButton = /*#__PURE__*/forwardRef(function CloseButton({
799
824
  });
800
825
  });
801
826
 
802
- var messages$8 = defineMessages({
827
+ var messages$9 = defineMessages({
803
828
  opensInNewTab: {
804
829
  id: "neptune.Link.opensInNewTab"
805
830
  }
@@ -828,7 +853,7 @@ const Link = ({
828
853
  onClick: onClick,
829
854
  ...props,
830
855
  children: [children, " ", isBlank && /*#__PURE__*/jsx(NavigateAway, {
831
- title: formatMessage(messages$8.opensInNewTab)
856
+ title: formatMessage(messages$9.opensInNewTab)
832
857
  })]
833
858
  });
834
859
  };
@@ -2068,6 +2093,12 @@ const BottomSheet$1 = props => {
2068
2093
  };
2069
2094
  var BottomSheet$2 = BottomSheet$1;
2070
2095
 
2096
+ var messages$8 = defineMessages({
2097
+ loadingAriaLabel: {
2098
+ id: "neptune.Button.loadingAriaLabel"
2099
+ }
2100
+ });
2101
+
2071
2102
  const typeClassMap$1 = {
2072
2103
  [ControlType.ACCENT]: 'btn-accent',
2073
2104
  [ControlType.POSITIVE]: 'btn-positive',
@@ -2134,6 +2165,7 @@ const Button = /*#__PURE__*/forwardRef(({
2134
2165
  type = ControlType.ACCENT,
2135
2166
  ...rest
2136
2167
  }, reference) => {
2168
+ const intl = useIntl();
2137
2169
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2138
2170
  logDeprecationNotices({
2139
2171
  size,
@@ -2176,6 +2208,8 @@ const Button = /*#__PURE__*/forwardRef(({
2176
2208
  ref: reference,
2177
2209
  className: classes,
2178
2210
  ...props,
2211
+ "aria-live": loading ? 'polite' : 'off',
2212
+ "aria-label": loading ? intl.formatMessage(messages$8.loadingAriaLabel) : undefined,
2179
2213
  children: [children, loading && /*#__PURE__*/jsx("span", {
2180
2214
  className: classNames('btn-loader', {
2181
2215
  'm-l-2': !block
@@ -7460,6 +7494,8 @@ const SearchBox = /*#__PURE__*/forwardRef(({
7460
7494
  }), /*#__PURE__*/jsx(Input, {
7461
7495
  ref: reference,
7462
7496
  id: id,
7497
+ role: "searchbox",
7498
+ inputMode: "search",
7463
7499
  className: classNames(style('np-select-filter')),
7464
7500
  placeholder: placeholder,
7465
7501
  value: value,
@@ -7750,6 +7786,8 @@ function Select({
7750
7786
  ref: optionsListReference,
7751
7787
  id: listboxId,
7752
7788
  role: "listbox",
7789
+ "aria-orientation": "vertical",
7790
+ "aria-activedescendant": getUniqueIdForOption(id, selected),
7753
7791
  tabIndex: "-1",
7754
7792
  className: dropdownClass,
7755
7793
  ...dropdownProps,
@@ -10392,50 +10430,6 @@ const PromoCardIndicator = ({
10392
10430
  });
10393
10431
  };
10394
10432
 
10395
- const generateRandomId = () => {
10396
- return `id-${Math.random().toString(36).slice(7)}`;
10397
- };
10398
- /**
10399
- * PromoCard component.
10400
- *
10401
- * PromoCard is a marketing style component that is used to group marketing
10402
- * product related information (such as choosing Card types). It can be used to
10403
- * display information in a structured way, and can be customized with various
10404
- * props to suit different use cases.
10405
- *
10406
- * @component
10407
- * @param {string} className - Additional class name for the PromoCard.
10408
- * @param {string} description - Description text for the PromoCard.
10409
- * @param {boolean} defaultChecked - Initial checked state for checkboxes and radios.
10410
- * @param {string} download - Download file name for links.
10411
- * @param {string} href - URL for links.
10412
- * @param {string} hrefLang - Language code for linked URL.
10413
- * @param {string} id - ID of the PromoCard.
10414
- * @param {string} imageAlt - Alt text for the image.
10415
- * @param {string} imageSource - Source URL of the image.
10416
- * @param {string} indicatorLabel - Label for the indicator icon.
10417
- * @param {boolean} isChecked - Checked state for checkboxes and radios.
10418
- * @param {boolean} isDisabled - Whether the PromoCard is disabled.
10419
- * @param {Function} onClick - Click event handler for the PromoCard.
10420
- * @param {string} rel - Relationship between the URL and the current page.
10421
- * @param {number} tabIndex - Tab index for keyboard navigation.
10422
- * @param {string} target - Target window for links.
10423
- * @param {string} testId - ID used for testing.
10424
- * @param {string} title - Title text of the PromoCard.
10425
- * @param {('checkbox'|'radio')} type - Type of the PromoCard (checkbox, radio).
10426
- * @param {string} value - Value for checkboxes and radios.
10427
- * @returns {JSX.Element} The rendered PromoCard component.
10428
- * @example
10429
- * <PromoCard
10430
- * title="Example PromoCard"
10431
- * description="This is an example PromoCard with a link variation."
10432
- * href="https://example.com"
10433
- * target="_blank"
10434
- * imageSource="https://example.com/image.png"
10435
- * imageAlt="Example Image"
10436
- * indicatorLabel="Learn More"
10437
- * />
10438
- */
10439
10433
  const PromoCard = /*#__PURE__*/forwardRef(({
10440
10434
  className,
10441
10435
  description,
@@ -10610,6 +10604,7 @@ const LanguageProvider = ({
10610
10604
  };
10611
10605
 
10612
10606
  var en = {
10607
+ "neptune.Button.loadingAriaLabel": "loading",
10613
10608
  "neptune.Chips.ariaLabel": "Clear {choice}",
10614
10609
  "neptune.ClearButton.ariaLabel": "Clear",
10615
10610
  "neptune.CloseButton.ariaLabel": "Close",