@transferwise/components 0.0.0-experimental-a64b578 → 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.
@@ -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
  };
@@ -10401,50 +10426,6 @@ const PromoCardIndicator = ({
10401
10426
  });
10402
10427
  };
10403
10428
 
10404
- const generateRandomId = () => {
10405
- return `id-${Math.random().toString(36).slice(7)}`;
10406
- };
10407
- /**
10408
- * PromoCard component.
10409
- *
10410
- * PromoCard is a marketing style component that is used to group marketing
10411
- * product related information (such as choosing Card types). It can be used to
10412
- * display information in a structured way, and can be customized with various
10413
- * props to suit different use cases.
10414
- *
10415
- * @component
10416
- * @param {string} className - Additional class name for the PromoCard.
10417
- * @param {string} description - Description text for the PromoCard.
10418
- * @param {boolean} defaultChecked - Initial checked state for checkboxes and radios.
10419
- * @param {string} download - Download file name for links.
10420
- * @param {string} href - URL for links.
10421
- * @param {string} hrefLang - Language code for linked URL.
10422
- * @param {string} id - ID of the PromoCard.
10423
- * @param {string} imageAlt - Alt text for the image.
10424
- * @param {string} imageSource - Source URL of the image.
10425
- * @param {string} indicatorLabel - Label for the indicator icon.
10426
- * @param {boolean} isChecked - Checked state for checkboxes and radios.
10427
- * @param {boolean} isDisabled - Whether the PromoCard is disabled.
10428
- * @param {Function} onClick - Click event handler for the PromoCard.
10429
- * @param {string} rel - Relationship between the URL and the current page.
10430
- * @param {number} tabIndex - Tab index for keyboard navigation.
10431
- * @param {string} target - Target window for links.
10432
- * @param {string} testId - ID used for testing.
10433
- * @param {string} title - Title text of the PromoCard.
10434
- * @param {('checkbox'|'radio')} type - Type of the PromoCard (checkbox, radio).
10435
- * @param {string} value - Value for checkboxes and radios.
10436
- * @returns {JSX.Element} The rendered PromoCard component.
10437
- * @example
10438
- * <PromoCard
10439
- * title="Example PromoCard"
10440
- * description="This is an example PromoCard with a link variation."
10441
- * href="https://example.com"
10442
- * target="_blank"
10443
- * imageSource="https://example.com/image.png"
10444
- * imageAlt="Example Image"
10445
- * indicatorLabel="Learn More"
10446
- * />
10447
- */
10448
10429
  const PromoCard = /*#__PURE__*/forwardRef(({
10449
10430
  className,
10450
10431
  description,