@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.
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
  };
@@ -796,7 +821,7 @@ const ActionOption = ({
796
821
  });
797
822
  };
798
823
 
799
- var messages$9 = reactIntl.defineMessages({
824
+ var messages$a = reactIntl.defineMessages({
800
825
  ariaLabel: {
801
826
  id: "neptune.CloseButton.ariaLabel"
802
827
  }
@@ -812,7 +837,7 @@ const CloseButton = /*#__PURE__*/React.forwardRef(function CloseButton({
812
837
  testId
813
838
  }, reference) {
814
839
  const intl = reactIntl.useIntl();
815
- ariaLabel ??= intl.formatMessage(messages$9.ariaLabel);
840
+ ariaLabel ??= intl.formatMessage(messages$a.ariaLabel);
816
841
  const Icon = filled ? icons.CrossCircleFill : icons.Cross;
817
842
  return /*#__PURE__*/jsxRuntime.jsx("button", {
818
843
  ref: reference,
@@ -832,7 +857,7 @@ const CloseButton = /*#__PURE__*/React.forwardRef(function CloseButton({
832
857
  });
833
858
  });
834
859
 
835
- var messages$8 = reactIntl.defineMessages({
860
+ var messages$9 = reactIntl.defineMessages({
836
861
  opensInNewTab: {
837
862
  id: "neptune.Link.opensInNewTab"
838
863
  }
@@ -861,7 +886,7 @@ const Link = ({
861
886
  onClick: onClick,
862
887
  ...props,
863
888
  children: [children, " ", isBlank && /*#__PURE__*/jsxRuntime.jsx(icons.NavigateAway, {
864
- title: formatMessage(messages$8.opensInNewTab)
889
+ title: formatMessage(messages$9.opensInNewTab)
865
890
  })]
866
891
  });
867
892
  };
@@ -2101,6 +2126,12 @@ const BottomSheet$1 = props => {
2101
2126
  };
2102
2127
  var BottomSheet$2 = BottomSheet$1;
2103
2128
 
2129
+ var messages$8 = reactIntl.defineMessages({
2130
+ loadingAriaLabel: {
2131
+ id: "neptune.Button.loadingAriaLabel"
2132
+ }
2133
+ });
2134
+
2104
2135
  const typeClassMap$1 = {
2105
2136
  [exports.ControlType.ACCENT]: 'btn-accent',
2106
2137
  [exports.ControlType.POSITIVE]: 'btn-positive',
@@ -2167,6 +2198,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
2167
2198
  type = exports.ControlType.ACCENT,
2168
2199
  ...rest
2169
2200
  }, reference) => {
2201
+ const intl = reactIntl.useIntl();
2170
2202
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2171
2203
  logDeprecationNotices({
2172
2204
  size,
@@ -2209,6 +2241,8 @@ const Button = /*#__PURE__*/React.forwardRef(({
2209
2241
  ref: reference,
2210
2242
  className: classes,
2211
2243
  ...props,
2244
+ "aria-live": loading ? 'polite' : 'off',
2245
+ "aria-label": loading ? intl.formatMessage(messages$8.loadingAriaLabel) : undefined,
2212
2246
  children: [children, loading && /*#__PURE__*/jsxRuntime.jsx("span", {
2213
2247
  className: classNames__default.default('btn-loader', {
2214
2248
  'm-l-2': !block
@@ -10425,50 +10459,6 @@ const PromoCardIndicator = ({
10425
10459
  });
10426
10460
  };
10427
10461
 
10428
- const generateRandomId = () => {
10429
- return `id-${Math.random().toString(36).slice(7)}`;
10430
- };
10431
- /**
10432
- * PromoCard component.
10433
- *
10434
- * PromoCard is a marketing style component that is used to group marketing
10435
- * product related information (such as choosing Card types). It can be used to
10436
- * display information in a structured way, and can be customized with various
10437
- * props to suit different use cases.
10438
- *
10439
- * @component
10440
- * @param {string} className - Additional class name for the PromoCard.
10441
- * @param {string} description - Description text for the PromoCard.
10442
- * @param {boolean} defaultChecked - Initial checked state for checkboxes and radios.
10443
- * @param {string} download - Download file name for links.
10444
- * @param {string} href - URL for links.
10445
- * @param {string} hrefLang - Language code for linked URL.
10446
- * @param {string} id - ID of the PromoCard.
10447
- * @param {string} imageAlt - Alt text for the image.
10448
- * @param {string} imageSource - Source URL of the image.
10449
- * @param {string} indicatorLabel - Label for the indicator icon.
10450
- * @param {boolean} isChecked - Checked state for checkboxes and radios.
10451
- * @param {boolean} isDisabled - Whether the PromoCard is disabled.
10452
- * @param {Function} onClick - Click event handler for the PromoCard.
10453
- * @param {string} rel - Relationship between the URL and the current page.
10454
- * @param {number} tabIndex - Tab index for keyboard navigation.
10455
- * @param {string} target - Target window for links.
10456
- * @param {string} testId - ID used for testing.
10457
- * @param {string} title - Title text of the PromoCard.
10458
- * @param {('checkbox'|'radio')} type - Type of the PromoCard (checkbox, radio).
10459
- * @param {string} value - Value for checkboxes and radios.
10460
- * @returns {JSX.Element} The rendered PromoCard component.
10461
- * @example
10462
- * <PromoCard
10463
- * title="Example PromoCard"
10464
- * description="This is an example PromoCard with a link variation."
10465
- * href="https://example.com"
10466
- * target="_blank"
10467
- * imageSource="https://example.com/image.png"
10468
- * imageAlt="Example Image"
10469
- * indicatorLabel="Learn More"
10470
- * />
10471
- */
10472
10462
  const PromoCard = /*#__PURE__*/React.forwardRef(({
10473
10463
  className,
10474
10464
  description,
@@ -10643,6 +10633,7 @@ const LanguageProvider = ({
10643
10633
  };
10644
10634
 
10645
10635
  var en = {
10636
+ "neptune.Button.loadingAriaLabel": "loading",
10646
10637
  "neptune.Chips.ariaLabel": "Clear {choice}",
10647
10638
  "neptune.ClearButton.ariaLabel": "Clear",
10648
10639
  "neptune.CloseButton.ariaLabel": "Close",