@transferwise/components 0.0.0-experimental-a64b578 → 0.0.0-experimental-0b6896b
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.esm.js +38 -53
- package/build/index.esm.js.map +1 -1
- package/build/index.js +38 -53
- package/build/index.js.map +1 -1
- package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
- package/build/types/common/index.d.ts +1 -0
- package/build/types/common/randomId.d.ts +13 -0
- package/build/types/common/randomId.d.ts.map +1 -0
- package/build/types/promoCard/PromoCard.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/select/searchBox/SearchBox.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/accordion/AccordionItem/AccordionItem.spec.js +1 -0
- package/src/accordion/AccordionItem/AccordionItem.tsx +19 -11
- package/src/accordion/AccordionItem/__snapshots__/AccordionItem.spec.js.snap +18 -4
- package/src/common/index.js +1 -0
- package/src/common/randomId.ts +14 -0
- package/src/dateInput/DateInput.story.tsx +0 -3
- package/src/moneyInput/MoneyInput.story.tsx +0 -3
- package/src/phoneNumberInput/PhoneNumberInput.story.js +0 -3
- package/src/promoCard/PromoCard.tsx +1 -16
- package/src/select/Select.js +2 -0
- package/src/select/Select.story.js +0 -6
- package/src/select/searchBox/SearchBox.spec.js +3 -7
- package/src/select/searchBox/SearchBox.tsx +2 -0
- package/src/select/searchBox/__snapshots__/SearchBox.spec.js.snap +0 -46
package/build/index.esm.js
CHANGED
|
@@ -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:
|
|
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(
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
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
|
};
|
|
@@ -7469,6 +7494,8 @@ const SearchBox = /*#__PURE__*/forwardRef(({
|
|
|
7469
7494
|
}), /*#__PURE__*/jsx(Input, {
|
|
7470
7495
|
ref: reference,
|
|
7471
7496
|
id: id,
|
|
7497
|
+
role: "searchbox",
|
|
7498
|
+
inputMode: "search",
|
|
7472
7499
|
className: classNames(style('np-select-filter')),
|
|
7473
7500
|
placeholder: placeholder,
|
|
7474
7501
|
value: value,
|
|
@@ -7759,6 +7786,8 @@ function Select({
|
|
|
7759
7786
|
ref: optionsListReference,
|
|
7760
7787
|
id: listboxId,
|
|
7761
7788
|
role: "listbox",
|
|
7789
|
+
"aria-orientation": "vertical",
|
|
7790
|
+
"aria-activedescendant": getUniqueIdForOption(id, selected),
|
|
7762
7791
|
tabIndex: "-1",
|
|
7763
7792
|
className: dropdownClass,
|
|
7764
7793
|
...dropdownProps,
|
|
@@ -10401,50 +10430,6 @@ const PromoCardIndicator = ({
|
|
|
10401
10430
|
});
|
|
10402
10431
|
};
|
|
10403
10432
|
|
|
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
10433
|
const PromoCard = /*#__PURE__*/forwardRef(({
|
|
10449
10434
|
className,
|
|
10450
10435
|
description,
|