@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.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:
|
|
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(
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
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
|
};
|
|
@@ -7502,6 +7527,8 @@ const SearchBox = /*#__PURE__*/React.forwardRef(({
|
|
|
7502
7527
|
}), /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
7503
7528
|
ref: reference,
|
|
7504
7529
|
id: id,
|
|
7530
|
+
role: "searchbox",
|
|
7531
|
+
inputMode: "search",
|
|
7505
7532
|
className: classNames__default.default(style('np-select-filter')),
|
|
7506
7533
|
placeholder: placeholder,
|
|
7507
7534
|
value: value,
|
|
@@ -7792,6 +7819,8 @@ function Select({
|
|
|
7792
7819
|
ref: optionsListReference,
|
|
7793
7820
|
id: listboxId,
|
|
7794
7821
|
role: "listbox",
|
|
7822
|
+
"aria-orientation": "vertical",
|
|
7823
|
+
"aria-activedescendant": getUniqueIdForOption(id, selected),
|
|
7795
7824
|
tabIndex: "-1",
|
|
7796
7825
|
className: dropdownClass,
|
|
7797
7826
|
...dropdownProps,
|
|
@@ -10434,50 +10463,6 @@ const PromoCardIndicator = ({
|
|
|
10434
10463
|
});
|
|
10435
10464
|
};
|
|
10436
10465
|
|
|
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
10466
|
const PromoCard = /*#__PURE__*/React.forwardRef(({
|
|
10482
10467
|
className,
|
|
10483
10468
|
description,
|