@transferwise/components 0.0.0-experimental-9ff97c1 → 0.0.0-experimental-8d248e3

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.
@@ -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
@@ -10392,50 +10426,6 @@ const PromoCardIndicator = ({
10392
10426
  });
10393
10427
  };
10394
10428
 
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
10429
  const PromoCard = /*#__PURE__*/forwardRef(({
10440
10430
  className,
10441
10431
  description,
@@ -10610,6 +10600,7 @@ const LanguageProvider = ({
10610
10600
  };
10611
10601
 
10612
10602
  var en = {
10603
+ "neptune.Button.loadingAriaLabel": "loading",
10613
10604
  "neptune.Chips.ariaLabel": "Clear {choice}",
10614
10605
  "neptune.ClearButton.ariaLabel": "Clear",
10615
10606
  "neptune.CloseButton.ariaLabel": "Close",