@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.
package/build/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  var classNames = require('classnames');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var React = require('react');
6
+ var reactId = require('@radix-ui/react-id');
6
7
  var icons = require('@transferwise/icons');
7
8
  var PropTypes = require('prop-types');
8
9
  var reactIntl = require('react-intl');
@@ -16,7 +17,6 @@ var mergeRefs = require('react-merge-refs');
16
17
  var neptuneValidation = require('@transferwise/neptune-validation');
17
18
  var reactPopper = require('react-popper');
18
19
  var react$1 = require('@headlessui/react');
19
- var reactId = require('@radix-ui/react-id');
20
20
  var shim = require('use-sync-external-store/shim');
21
21
  var react = require('@floating-ui/react');
22
22
  var overlays = require('@react-aria/overlays');
@@ -490,6 +490,21 @@ function getDirectionFromLocale(locale) {
490
490
  }
491
491
  }
492
492
 
493
+ /**
494
+ * generateRandomId() function
495
+ *
496
+ * This function generates a random string of characters that can be used as
497
+ * an ID.
498
+ *
499
+ * @returns {string} A random string of characters.
500
+ * @example
501
+ * const id = generateRandomId();
502
+ * // id will be a random string of characters, such as "id-4711".
503
+ */
504
+ const generateRandomId = () => {
505
+ return `id-${Math.random().toString(36).slice(7)}`;
506
+ };
507
+
493
508
  const DEFAULT_TYPE$1 = exports.Typography.TITLE_GROUP;
494
509
  const titleTypeMapping = {
495
510
  [exports.Typography.TITLE_SCREEN]: 'h1',
@@ -673,8 +688,10 @@ const AccordionItem = ({
673
688
  const iconElement = icon ? /*#__PURE__*/React.cloneElement(icon, {
674
689
  size: 24
675
690
  }) : null;
691
+ const fallbackId = reactId.useId();
692
+ const accordionId = id ?? fallbackId;
676
693
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
677
- id: id,
694
+ id: accordionId,
678
695
  className: classNames__default.default('np-accordion-item', iconElement ? 'np-accordion-item--with-icon' : null, {
679
696
  'np-accordion-item--open': open
680
697
  }),
@@ -688,14 +705,22 @@ const AccordionItem = ({
688
705
  size: exports.Size.MEDIUM
689
706
  }),
690
707
  inverseMediaCircle: false,
708
+ "aria-expanded": open,
709
+ "aria-controls": `${accordionId}-section`,
710
+ id: `${accordionId}-control`,
691
711
  onClick: onClick
692
- }), open && /*#__PURE__*/jsxRuntime.jsx(Body, {
693
- as: "span",
694
- type: exports.Typography.BODY_LARGE,
695
- className: classNames__default.default('np-accordion-item__content', 'd-block', {
696
- 'has-icon': icon
697
- }),
698
- children: content
712
+ }), open && /*#__PURE__*/jsxRuntime.jsx("div", {
713
+ id: `${accordionId}-section`,
714
+ role: "region",
715
+ "aria-labelledby": `${accordionId}-control`,
716
+ children: /*#__PURE__*/jsxRuntime.jsx(Body, {
717
+ as: "span",
718
+ type: exports.Typography.BODY_LARGE,
719
+ className: classNames__default.default('np-accordion-item__content', 'd-block', {
720
+ 'has-icon': icon
721
+ }),
722
+ children: content
723
+ })
699
724
  })]
700
725
  });
701
726
  };
@@ -10434,50 +10459,6 @@ const PromoCardIndicator = ({
10434
10459
  });
10435
10460
  };
10436
10461
 
10437
- const generateRandomId = () => {
10438
- return `id-${Math.random().toString(36).slice(7)}`;
10439
- };
10440
- /**
10441
- * PromoCard component.
10442
- *
10443
- * PromoCard is a marketing style component that is used to group marketing
10444
- * product related information (such as choosing Card types). It can be used to
10445
- * display information in a structured way, and can be customized with various
10446
- * props to suit different use cases.
10447
- *
10448
- * @component
10449
- * @param {string} className - Additional class name for the PromoCard.
10450
- * @param {string} description - Description text for the PromoCard.
10451
- * @param {boolean} defaultChecked - Initial checked state for checkboxes and radios.
10452
- * @param {string} download - Download file name for links.
10453
- * @param {string} href - URL for links.
10454
- * @param {string} hrefLang - Language code for linked URL.
10455
- * @param {string} id - ID of the PromoCard.
10456
- * @param {string} imageAlt - Alt text for the image.
10457
- * @param {string} imageSource - Source URL of the image.
10458
- * @param {string} indicatorLabel - Label for the indicator icon.
10459
- * @param {boolean} isChecked - Checked state for checkboxes and radios.
10460
- * @param {boolean} isDisabled - Whether the PromoCard is disabled.
10461
- * @param {Function} onClick - Click event handler for the PromoCard.
10462
- * @param {string} rel - Relationship between the URL and the current page.
10463
- * @param {number} tabIndex - Tab index for keyboard navigation.
10464
- * @param {string} target - Target window for links.
10465
- * @param {string} testId - ID used for testing.
10466
- * @param {string} title - Title text of the PromoCard.
10467
- * @param {('checkbox'|'radio')} type - Type of the PromoCard (checkbox, radio).
10468
- * @param {string} value - Value for checkboxes and radios.
10469
- * @returns {JSX.Element} The rendered PromoCard component.
10470
- * @example
10471
- * <PromoCard
10472
- * title="Example PromoCard"
10473
- * description="This is an example PromoCard with a link variation."
10474
- * href="https://example.com"
10475
- * target="_blank"
10476
- * imageSource="https://example.com/image.png"
10477
- * imageAlt="Example Image"
10478
- * indicatorLabel="Learn More"
10479
- * />
10480
- */
10481
10462
  const PromoCard = /*#__PURE__*/React.forwardRef(({
10482
10463
  className,
10483
10464
  description,