@transferwise/components 46.125.0 → 46.127.1
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/avatarView/AvatarView.js.map +1 -1
- package/build/avatarView/AvatarView.mjs.map +1 -1
- package/build/common/locale/index.js +13 -0
- package/build/common/locale/index.js.map +1 -1
- package/build/common/locale/index.mjs +13 -1
- package/build/common/locale/index.mjs.map +1 -1
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +31 -1
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js.map +1 -1
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +32 -2
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs.map +1 -1
- package/build/field/Field.js +1 -0
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +1 -0
- package/build/field/Field.mjs.map +1 -1
- package/build/index.js +3 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +2 -1
- package/build/index.mjs.map +1 -1
- package/build/inputs/Input.js.map +1 -1
- package/build/inputs/Input.mjs.map +1 -1
- package/build/inputs/SearchInput.js.map +1 -1
- package/build/inputs/SearchInput.mjs.map +1 -1
- package/build/inputs/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput.mjs.map +1 -1
- package/build/inputs/TextArea.js.map +1 -1
- package/build/inputs/TextArea.mjs.map +1 -1
- package/build/listItem/ListItem.js +2 -2
- package/build/listItem/ListItem.js.map +1 -1
- package/build/listItem/ListItem.mjs +2 -2
- package/build/listItem/ListItem.mjs.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.js +6 -4
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.mjs +7 -2
- package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
- package/build/main.css +52 -21
- package/build/moneyInput/MoneyInput.js +6 -1
- package/build/moneyInput/MoneyInput.js.map +1 -1
- package/build/moneyInput/MoneyInput.mjs +6 -1
- package/build/moneyInput/MoneyInput.mjs.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.js +27 -4
- package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.mjs +27 -4
- package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
- package/build/prompt/InfoPrompt/InfoPrompt.js +113 -0
- package/build/prompt/InfoPrompt/InfoPrompt.js.map +1 -0
- package/build/prompt/InfoPrompt/InfoPrompt.mjs +111 -0
- package/build/prompt/InfoPrompt/InfoPrompt.mjs.map +1 -0
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.js.map +1 -1
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs.map +1 -1
- package/build/radioOption/RadioOption.js.map +1 -1
- package/build/radioOption/RadioOption.mjs.map +1 -1
- package/build/slidingPanel/SlidingPanel.js.map +1 -1
- package/build/slidingPanel/SlidingPanel.mjs.map +1 -1
- package/build/statusIcon/StatusIcon.js +2 -0
- package/build/statusIcon/StatusIcon.js.map +1 -1
- package/build/statusIcon/StatusIcon.mjs +2 -0
- package/build/statusIcon/StatusIcon.mjs.map +1 -1
- package/build/styles/main.css +52 -21
- package/build/styles/prompt/InfoPrompt/InfoPrompt.css +31 -0
- package/build/styles/sentimentSurface/SentimentSurface.css +21 -21
- package/build/table/TableCell.js.map +1 -1
- package/build/table/TableCell.mjs.map +1 -1
- package/build/typeahead/Typeahead.js +1 -0
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs +1 -0
- package/build/typeahead/Typeahead.mjs.map +1 -1
- package/build/types/avatarView/AvatarView.d.ts +1 -1
- package/build/types/avatarView/AvatarView.d.ts.map +1 -1
- package/build/types/common/locale/index.d.ts +8 -0
- package/build/types/common/locale/index.d.ts.map +1 -1
- package/build/types/expressiveMoneyInput/currencySelector/CurrencySelector.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/Input.d.ts.map +1 -1
- package/build/types/inputs/SearchInput.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/TextArea.d.ts.map +1 -1
- package/build/types/listItem/ListItem.d.ts +1 -1
- package/build/types/listItem/Prompt/ListItemPrompt.d.ts +2 -3
- package/build/types/listItem/Prompt/ListItemPrompt.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/PrimitiveAnchor.types.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveButton/PrimitiveButton.types.d.ts.map +1 -1
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts +4 -2
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -1
- package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts +56 -0
- package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts.map +1 -0
- package/build/types/prompt/InfoPrompt/index.d.ts +3 -0
- package/build/types/prompt/InfoPrompt/index.d.ts.map +1 -0
- package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts +5 -5
- package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts.map +1 -1
- package/build/types/prompt/index.d.ts +2 -0
- package/build/types/prompt/index.d.ts.map +1 -1
- package/build/types/radioOption/RadioOption.d.ts.map +1 -1
- package/build/types/slidingPanel/SlidingPanel.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts +2 -1
- package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
- package/build/types/table/TableCell.d.ts.map +1 -1
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
- package/build/withDisplayFormat/WithDisplayFormat.js.map +1 -1
- package/build/withDisplayFormat/WithDisplayFormat.mjs.map +1 -1
- package/package.json +3 -3
- package/src/accordion/Accordion.test.js +0 -6
- package/src/accordion/AccordionItem/AccordionItem.test.js +0 -10
- package/src/actionButton/ActionButton.test.tsx +0 -4
- package/src/avatarLayout/AvatarLayout.story.tsx +3 -3
- package/src/avatarView/AvatarView.story.tsx +29 -24
- package/src/avatarView/AvatarView.tsx +1 -1
- package/src/avatarWrapper/AvatarWrapper.test.tsx +0 -53
- package/src/checkbox/Checkbox.test.tsx +0 -5
- package/src/chevron/Chevron.test.tsx +0 -7
- package/src/chips/Chips.test.tsx +0 -8
- package/src/common/RadioButton/RadioButton.test.tsx +0 -18
- package/src/common/bottomSheet/BottomSheet.test.story.tsx +98 -0
- package/src/common/bottomSheet/BottomSheet.test.tsx +0 -9
- package/src/common/card/Card.test.tsx +0 -6
- package/src/common/closeButton/CloseButton.test.tsx +0 -4
- package/src/common/locale/index.test.ts +36 -1
- package/src/common/locale/index.ts +13 -0
- package/src/common/panel/Panel.test.tsx +0 -6
- package/src/expressiveMoneyInput/currencySelector/CurrencySelector.tsx +5 -1
- package/src/flowNavigation/FlowNavigation.test.js +0 -10
- package/src/index.ts +3 -1
- package/src/inputs/Input.tsx +8 -9
- package/src/inputs/SearchInput.tsx +8 -9
- package/src/inputs/SelectInput.test.story.tsx +86 -0
- package/src/inputs/SelectInput.tsx +1 -1
- package/src/inputs/TextArea.tsx +6 -7
- package/src/listItem/ListItem.tsx +2 -2
- package/src/listItem/Prompt/ListItemPrompt.story.tsx +71 -9
- package/src/listItem/Prompt/ListItemPrompt.test.tsx +31 -0
- package/src/listItem/Prompt/ListItemPrompt.tsx +8 -2
- package/src/logo/Logo.story.tsx +24 -5
- package/src/main.css +52 -21
- package/src/main.less +2 -1
- package/src/moneyInput/MoneyInput.test.story.tsx +104 -0
- package/src/moneyInput/MoneyInput.tsx +20 -2
- package/src/overlayHeader/OverlayHeader.test.tsx +0 -3
- package/src/popover/Popover.test.tsx +0 -25
- package/src/primitives/PrimitiveAnchor/PrimitiveAnchor.types.ts +1 -3
- package/src/primitives/PrimitiveButton/PrimitiveButton.types.ts +1 -3
- package/src/promoCard/PromoCard.test.tsx +0 -6
- package/src/promoCard/PromoCardGroup.test.tsx +0 -5
- package/src/prompt/ActionPrompt/ActionPrompt.accessibility.docs.mdx +65 -0
- package/src/prompt/ActionPrompt/ActionPrompt.less +1 -1
- package/src/prompt/ActionPrompt/ActionPrompt.story.tsx +4 -1
- package/src/prompt/ActionPrompt/ActionPrompt.test.story.tsx +147 -0
- package/src/prompt/ActionPrompt/ActionPrompt.test.tsx +2 -7
- package/src/prompt/ActionPrompt/ActionPrompt.tsx +48 -7
- package/src/prompt/InfoPrompt/InfoPrompt.css +31 -0
- package/src/prompt/InfoPrompt/InfoPrompt.less +37 -0
- package/src/prompt/InfoPrompt/InfoPrompt.story.tsx +312 -0
- package/src/prompt/InfoPrompt/InfoPrompt.test.story.tsx +246 -0
- package/src/prompt/InfoPrompt/InfoPrompt.test.tsx +224 -0
- package/src/prompt/InfoPrompt/InfoPrompt.tsx +148 -0
- package/src/prompt/InfoPrompt/index.ts +2 -0
- package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +13 -10
- package/src/prompt/InlinePrompt/InlinePrompt.test.tsx +13 -1
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.less +1 -1
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.tsx +5 -5
- package/src/prompt/index.ts +5 -0
- package/src/radioOption/RadioOption.tsx +2 -1
- package/src/sentimentSurface/SentimentSurface.css +21 -21
- package/src/sentimentSurface/SentimentSurface.less +13 -13
- package/src/sentimentSurface/SentimentSurface.story.tsx +1 -1
- package/src/sentimentSurface/SentimentSurface.test.story.tsx +48 -1
- package/src/slidingPanel/SlidingPanel.tsx +4 -2
- package/src/ssr.test.tsx +2 -0
- package/src/statusIcon/StatusIcon.tsx +8 -1
- package/src/table/TableCell.tsx +1 -3
- package/src/tile/Tile.test.tsx +0 -10
- package/src/tooltip/Tooltip.test.tsx +0 -10
- package/src/withDisplayFormat/WithDisplayFormat.tsx +13 -14
- package/src/accordion/AccordionItem/__snapshots__/AccordionItem.test.js.snap +0 -124
- package/src/accordion/__snapshots__/Accordion.test.js.snap +0 -3
- package/src/actionButton/__snapshots__/ActionButton.test.tsx.snap +0 -12
- package/src/avatarWrapper/__snapshots__/AvatarWrapper.test.tsx.snap +0 -156
- package/src/checkbox/__snapshots__/Checkbox.test.tsx.snap +0 -40
- package/src/chevron/__snapshots__/Chevron.test.tsx.snap +0 -24
- package/src/chips/__snapshots__/Chips.test.tsx.snap +0 -153
- package/src/common/RadioButton/__snapshots__/RadioButton.test.tsx.snap +0 -58
- package/src/common/bottomSheet/__snapshots__/BottomSheet.test.tsx.snap +0 -80
- package/src/common/card/__snapshots__/Card.test.tsx.snap +0 -10
- package/src/common/closeButton/__snapshots__/CloseButton.test.tsx.snap +0 -30
- package/src/common/flowHeader/FlowHeader.test.tsx +0 -22
- package/src/common/flowHeader/__snapshots__/FlowHeader.test.tsx.snap +0 -33
- package/src/common/panel/__snapshots__/Panel.test.tsx.snap +0 -3
- package/src/flowNavigation/__snapshots__/FlowNavigation.test.js.snap +0 -262
- package/src/logo/Logo.test.tsx +0 -55
- package/src/logo/__snapshots__/Logo.test.tsx.snap +0 -281
- package/src/overlayHeader/__snapshots__/OverlayHeader.test.tsx.snap +0 -65
- package/src/popover/__snapshots__/Popover.test.tsx.snap +0 -51
- package/src/promoCard/__snapshots__/PromoCard.test.tsx.snap +0 -40
- package/src/promoCard/__snapshots__/PromoCardGroup.test.tsx.snap +0 -80
- package/src/tile/__snapshots__/Tile.test.tsx.snap +0 -55
- package/src/tooltip/__snapshots__/Tooltip.test.tsx.snap +0 -32
|
@@ -288,7 +288,7 @@ export const EdgeInstances: Story = {
|
|
|
288
288
|
/**
|
|
289
289
|
* Like [AvatarView](?path=/docs/content-avatarview--docs#sentiment-awareness), `AvatarLayout` is sentiment-aware (note: not all features are supported) and will automatically adjust its colours if wrapped inside the
|
|
290
290
|
* [SentimentSurface](?path=/docs/content-sentimentsurface--docs) component.
|
|
291
|
-
*
|
|
291
|
+
*
|
|
292
292
|
* Features like: `interactive` are not supported.
|
|
293
293
|
* Also `AvatarLayout` isn't supported on `"elevated"` state of `SentimentSurface`.
|
|
294
294
|
*/
|
|
@@ -302,7 +302,7 @@ export const SentimentAwareness: Story = {
|
|
|
302
302
|
},
|
|
303
303
|
render: (args) => (
|
|
304
304
|
<>
|
|
305
|
-
{(['success', 'warning', 'negative', 'neutral', 'proposition'] as const).map((sentiment) =>
|
|
305
|
+
{(['success', 'warning', 'negative', 'neutral', 'proposition'] as const).map((sentiment) => (
|
|
306
306
|
<SentimentSurface
|
|
307
307
|
key={`${sentiment}-base`}
|
|
308
308
|
sentiment={sentiment}
|
|
@@ -316,7 +316,7 @@ export const SentimentAwareness: Story = {
|
|
|
316
316
|
avatars={[{ asset: <Freeze /> }, { asset: <Freeze /> }]}
|
|
317
317
|
/>
|
|
318
318
|
</SentimentSurface>
|
|
319
|
-
)}
|
|
319
|
+
))}
|
|
320
320
|
</>
|
|
321
321
|
),
|
|
322
322
|
decorators: [
|
|
@@ -440,7 +440,7 @@ export const Profiles: Story = {
|
|
|
440
440
|
/**
|
|
441
441
|
* `AvatarView` is sentiment-aware (note: not all features are supported) and will automatically adjust its colours if wrapped inside the
|
|
442
442
|
* [SentimentSurface](?path=/docs/content-sentimentsurface--docs) component.
|
|
443
|
-
*
|
|
443
|
+
*
|
|
444
444
|
* Features like `online`, `notification`, `selected`, and `interactive` are not supported.
|
|
445
445
|
* For badge (`<AvatarView badge={}>`) only `flagCode` is supported.
|
|
446
446
|
* Also `AvatarView` isn't supported on `"elevated"` state of `SentimentSurface`.
|
|
@@ -457,29 +457,34 @@ export const SentimentAwareness: Story = {
|
|
|
457
457
|
render: () => {
|
|
458
458
|
return (
|
|
459
459
|
<>
|
|
460
|
-
{(['success', 'warning', 'negative', 'neutral', 'proposition'] as const).map(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
<
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
<
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
<
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
460
|
+
{(['success', 'warning', 'negative', 'neutral', 'proposition'] as const).map(
|
|
461
|
+
(sentiment) => (
|
|
462
|
+
<SentimentSurface
|
|
463
|
+
key={`${sentiment}-base`}
|
|
464
|
+
sentiment={sentiment}
|
|
465
|
+
emphasis="base"
|
|
466
|
+
className="p-a-1 d-flex"
|
|
467
|
+
style={{ gap: 'var(--size-16)' }}
|
|
468
|
+
>
|
|
469
|
+
<AvatarView size={32}>
|
|
470
|
+
<Bank />
|
|
471
|
+
</AvatarView>
|
|
472
|
+
<AvatarView size={32} profileName="John Doe" />
|
|
473
|
+
<AvatarView size={32}>
|
|
474
|
+
<Flag code="JPY" intrinsicSize={32} />
|
|
475
|
+
</AvatarView>
|
|
476
|
+
<AvatarView
|
|
477
|
+
size={32}
|
|
478
|
+
badge={sentiment === 'proposition' ? undefined : { status: sentiment }}
|
|
479
|
+
>
|
|
480
|
+
<Bank />
|
|
481
|
+
</AvatarView>
|
|
482
|
+
<AvatarView size={32} badge={{ flagCode: 'eu' }}>
|
|
483
|
+
<Bank />
|
|
484
|
+
</AvatarView>
|
|
485
|
+
</SentimentSurface>
|
|
486
|
+
),
|
|
487
|
+
)}
|
|
483
488
|
</>
|
|
484
489
|
);
|
|
485
490
|
},
|
|
@@ -32,7 +32,7 @@ export type Props = {
|
|
|
32
32
|
style?: Pick<React.CSSProperties, 'border' | 'backgroundColor' | 'color'>;
|
|
33
33
|
} & Pick<
|
|
34
34
|
HTMLAttributes<HTMLDivElement>,
|
|
35
|
-
'className' | 'children' | 'role' | 'aria-label' | 'aria-labelledby' | 'aria-hidden'
|
|
35
|
+
'id' | 'className' | 'children' | 'role' | 'aria-label' | 'aria-labelledby' | 'aria-hidden'
|
|
36
36
|
>;
|
|
37
37
|
|
|
38
38
|
function AvatarView({
|
|
@@ -36,49 +36,10 @@ describe('FlowNavigationAvatar', () => {
|
|
|
36
36
|
|
|
37
37
|
expect(screen.getByText('M')).toBeInTheDocument();
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
describe('AND profileType', () => {
|
|
41
|
-
it('renders as BUSINESS profile type with an icon', () => {
|
|
42
|
-
const { container } = render(
|
|
43
|
-
<AvatarWrapper name={name} profileType={ProfileType.BUSINESS} />,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('renders as PERSONAL profile type with an icon', () => {
|
|
50
|
-
const { container } = render(
|
|
51
|
-
<AvatarWrapper name={name} profileType={ProfileType.PERSONAL} />,
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('AND avatar url', () => {
|
|
58
|
-
it('renders the image', () => {
|
|
59
|
-
const { container } = render(
|
|
60
|
-
<AvatarWrapper
|
|
61
|
-
url="https://wise.com"
|
|
62
|
-
name={name}
|
|
63
|
-
profileType={ProfileType.BUSINESS}
|
|
64
|
-
avatarProps={{ theme: 'dark' }}
|
|
65
|
-
/>,
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
39
|
});
|
|
73
40
|
});
|
|
74
41
|
|
|
75
42
|
describe('with nothing passed', () => {
|
|
76
|
-
it('renders a personal icon', () => {
|
|
77
|
-
const { container } = render(<AvatarWrapper />);
|
|
78
|
-
|
|
79
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
43
|
it('renders aria-label', () => {
|
|
83
44
|
render(<AvatarWrapper aria-label="test" />);
|
|
84
45
|
|
|
@@ -86,20 +47,6 @@ describe('FlowNavigationAvatar', () => {
|
|
|
86
47
|
});
|
|
87
48
|
});
|
|
88
49
|
|
|
89
|
-
describe('with a badge url passed', () => {
|
|
90
|
-
it('renders the badge', () => {
|
|
91
|
-
const { container } = render(
|
|
92
|
-
<AvatarWrapper
|
|
93
|
-
badgeUrl="https://badge.com"
|
|
94
|
-
badgeAltText="badge alt text"
|
|
95
|
-
badgeProps={{ size: Size.LARGE } as BadgeProps}
|
|
96
|
-
/>,
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
50
|
describe('with a badge status icon passed', () => {
|
|
104
51
|
it('renders the badge', () => {
|
|
105
52
|
render(<AvatarWrapper badgeStatusIcon={Sentiment.POSITIVE} />);
|
|
@@ -19,11 +19,6 @@ describe('Checkbox', () => {
|
|
|
19
19
|
jest.clearAllMocks();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
it('renders the given label', () => {
|
|
23
|
-
const { container } = render(<Checkbox {...props} />);
|
|
24
|
-
expect(container).toMatchSnapshot();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
22
|
it('is enabled by default', () => {
|
|
28
23
|
const { container } = render(<Checkbox {...props} />);
|
|
29
24
|
expect(getCheckboxContainer(container)).not.toHaveClass('disabled');
|
|
@@ -43,11 +43,4 @@ describe('Chevron', () => {
|
|
|
43
43
|
expect(container.querySelector('.tw-icon-chevron-up')).not.toHaveClass('chevron-color');
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
describe('custom xs icon', () => {
|
|
48
|
-
it('renders', () => {
|
|
49
|
-
const { container } = render(<Chevron size={Size.EXTRA_SMALL} />);
|
|
50
|
-
expect(container).toMatchSnapshot();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
46
|
});
|
package/src/chips/Chips.test.tsx
CHANGED
|
@@ -53,10 +53,6 @@ const filterProps = {
|
|
|
53
53
|
|
|
54
54
|
describe('Chips', () => {
|
|
55
55
|
describe('Choice Chips', () => {
|
|
56
|
-
it(`renders as expected`, () => {
|
|
57
|
-
expect(render(<Chips {...choiceProps} />).container).toMatchSnapshot();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
56
|
it(`will pass previous state, updated state, and selected value on select`, () => {
|
|
61
57
|
render(<Chips {...choiceProps} />);
|
|
62
58
|
const accounting = screen.getByText('Accounting');
|
|
@@ -69,10 +65,6 @@ describe('Chips', () => {
|
|
|
69
65
|
});
|
|
70
66
|
|
|
71
67
|
describe('Filter Chips', () => {
|
|
72
|
-
it(`renders as expected`, () => {
|
|
73
|
-
expect(render(<Chips {...filterProps} />).container).toMatchSnapshot();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
68
|
it(`will pass previous state, updated state, and selected value on select`, () => {
|
|
77
69
|
render(<Chips {...filterProps} />);
|
|
78
70
|
const accounting = screen.getByText('Accounting');
|
|
@@ -3,24 +3,6 @@ import { screen, render, userEvent } from '../../test-utils';
|
|
|
3
3
|
import RadioButton from '.';
|
|
4
4
|
|
|
5
5
|
describe('Radio button', () => {
|
|
6
|
-
it('renders correctly', () => {
|
|
7
|
-
const { container } = render(<RadioButton id="an-id" name="a-name" value="a-value" />);
|
|
8
|
-
|
|
9
|
-
expect(container).toMatchSnapshot();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('renders checked state correctly', () => {
|
|
13
|
-
const { container } = render(<RadioButton name="radio-name" checked />);
|
|
14
|
-
|
|
15
|
-
expect(container).toMatchSnapshot();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('renders disabled state correctly', () => {
|
|
19
|
-
const { container } = render(<RadioButton name="radio-name" disabled />);
|
|
20
|
-
|
|
21
|
-
expect(container).toMatchSnapshot();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
6
|
it('responds to user input', async () => {
|
|
25
7
|
const onChange = jest.fn();
|
|
26
8
|
render(
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
3
|
+
import { fireEvent, within } from 'storybook/test';
|
|
4
|
+
import { lorem100, lorem500 } from '../../test-utils';
|
|
5
|
+
import { Typography } from '../propsValues/typography';
|
|
6
|
+
import Alert from '../../alert';
|
|
7
|
+
import Body from '../../body';
|
|
8
|
+
import Button from '../../button';
|
|
9
|
+
import Title from '../../title';
|
|
10
|
+
import BottomSheet from './BottomSheet';
|
|
11
|
+
|
|
12
|
+
const wait = async (duration = 500) =>
|
|
13
|
+
new Promise<void>((resolve) => {
|
|
14
|
+
setTimeout(resolve, duration);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
component: BottomSheet,
|
|
19
|
+
title: 'Dialogs/BottomSheet/tests',
|
|
20
|
+
tags: ['!autodocs'],
|
|
21
|
+
args: {
|
|
22
|
+
open: false,
|
|
23
|
+
},
|
|
24
|
+
} satisfies Meta<typeof BottomSheet>;
|
|
25
|
+
|
|
26
|
+
type Story = StoryObj<typeof BottomSheet>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* This test ensures that when the SelectInput is used within a scrollable page,
|
|
30
|
+
* opening the dropdown does not cause any unwanted scrolling or layout shifts.
|
|
31
|
+
* Expected preview should start with green bar at the top, with yellow section
|
|
32
|
+
* not in the viewport. The issue is particularly prominent on iOS Safari.
|
|
33
|
+
*
|
|
34
|
+
* NB: This test is disabled in Chromatic as there's no obvious way to control
|
|
35
|
+
* <html/> element of a snapshot. It's to be primarily used in manual testing
|
|
36
|
+
* on an actual device or a simulator as it cannot be reproduced with mobile
|
|
37
|
+
* emulation modes on desktop browsers.
|
|
38
|
+
*/
|
|
39
|
+
export const SmoothScrollReset: Story = {
|
|
40
|
+
args: {
|
|
41
|
+
children: (
|
|
42
|
+
<>
|
|
43
|
+
<Title type={Typography.TITLE_SECTION}>Observe the document</Title>
|
|
44
|
+
<Alert className="m-t-2" type="warning">
|
|
45
|
+
Once the <code>BottomSheet</code> opens, the document underneath should be static and
|
|
46
|
+
should not scroll.
|
|
47
|
+
</Alert>
|
|
48
|
+
<Body as="p">{lorem100}</Body>
|
|
49
|
+
<Body as="p">{lorem100}</Body>
|
|
50
|
+
</>
|
|
51
|
+
),
|
|
52
|
+
},
|
|
53
|
+
decorators: [
|
|
54
|
+
(Story) => (
|
|
55
|
+
<>
|
|
56
|
+
<style>{'html { scroll-behavior: smooth; }'}</style>
|
|
57
|
+
<div style={{ maxWidth: 500 }}>
|
|
58
|
+
<Body>
|
|
59
|
+
<p>{lorem100}</p>
|
|
60
|
+
<p>{lorem100}</p>
|
|
61
|
+
</Body>
|
|
62
|
+
<Story />
|
|
63
|
+
<Body as="p" className="m-t-5 disabled">
|
|
64
|
+
{lorem500}
|
|
65
|
+
</Body>
|
|
66
|
+
</div>
|
|
67
|
+
</>
|
|
68
|
+
),
|
|
69
|
+
],
|
|
70
|
+
parameters: {
|
|
71
|
+
chromatic: {
|
|
72
|
+
disableSnapshot: true,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
play: async ({ canvasElement }) => {
|
|
76
|
+
document.documentElement.scrollTop = 400;
|
|
77
|
+
await wait(500);
|
|
78
|
+
const canvas = within(canvasElement);
|
|
79
|
+
// cannot use userEvent.click as it crashes on iOS Safari in the simulator
|
|
80
|
+
await fireEvent.click(canvas.getByRole('button'));
|
|
81
|
+
},
|
|
82
|
+
render: ({ open, ...args }) => {
|
|
83
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div>
|
|
87
|
+
<Button onClick={() => setIsOpen(true)}>Open BottomSheet</Button>
|
|
88
|
+
<BottomSheet
|
|
89
|
+
{...args}
|
|
90
|
+
open={isOpen}
|
|
91
|
+
onClose={() => {
|
|
92
|
+
setIsOpen(false);
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
};
|
|
@@ -5,15 +5,6 @@ import BottomSheet from './BottomSheet';
|
|
|
5
5
|
mockMatchMedia();
|
|
6
6
|
|
|
7
7
|
describe('BottomSheet', () => {
|
|
8
|
-
it('renders content when open', () => {
|
|
9
|
-
const { baseElement } = render(
|
|
10
|
-
<BottomSheet open onClose={jest.fn()}>
|
|
11
|
-
<b>Test Content</b>
|
|
12
|
-
</BottomSheet>,
|
|
13
|
-
);
|
|
14
|
-
expect(baseElement).toMatchSnapshot();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
8
|
it('does not renders when closed', () => {
|
|
18
9
|
const { container } = render(
|
|
19
10
|
<BottomSheet open={false} onClose={jest.fn()}>
|
|
@@ -10,12 +10,6 @@ describe('Card', () => {
|
|
|
10
10
|
testId: 'test-card',
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
it('matches snapshot', () => {
|
|
14
|
-
const { container } = render(<Card {...defaultProps} />);
|
|
15
|
-
|
|
16
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
13
|
it('renders', () => {
|
|
20
14
|
const props = {
|
|
21
15
|
...defaultProps,
|
|
@@ -8,10 +8,6 @@ const props = {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
describe('CloseButton', () => {
|
|
11
|
-
it(`renders as expected`, () => {
|
|
12
|
-
expect(render(<CloseButton {...props} />).container).toMatchSnapshot();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
11
|
describe('tabIndex', () => {
|
|
16
12
|
it('should not have tabIndex by default', () => {
|
|
17
13
|
render(<CloseButton {...props} />);
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IntlShape } from 'react-intl';
|
|
2
|
+
import {
|
|
3
|
+
getLangFromLocale,
|
|
4
|
+
adjustLocale,
|
|
5
|
+
getCountryFromLocale,
|
|
6
|
+
getDirectionFromLocale,
|
|
7
|
+
getLocaleCurrencyName,
|
|
8
|
+
} from '.';
|
|
2
9
|
|
|
3
10
|
describe('locale utils', () => {
|
|
4
11
|
beforeAll(() => {
|
|
@@ -103,4 +110,32 @@ describe('locale utils', () => {
|
|
|
103
110
|
},
|
|
104
111
|
);
|
|
105
112
|
});
|
|
113
|
+
|
|
114
|
+
describe('getLocaleCurrencyName', () => {
|
|
115
|
+
it('should return the localized currency name if Intl.DisplayNames is supported', () => {
|
|
116
|
+
const intl = {
|
|
117
|
+
formatDisplayName: jest.fn().mockReturnValue('US Dollar'),
|
|
118
|
+
} as unknown as IntlShape;
|
|
119
|
+
|
|
120
|
+
const result = getLocaleCurrencyName(intl, 'USD');
|
|
121
|
+
expect(intl.formatDisplayName).toHaveBeenCalledWith('USD', {
|
|
122
|
+
type: 'currency',
|
|
123
|
+
fallback: 'code',
|
|
124
|
+
});
|
|
125
|
+
expect(result).toBe('US Dollar');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should return the original currency code if Intl.DisplayNames is not supported', () => {
|
|
129
|
+
const intl = {
|
|
130
|
+
formatDisplayName: jest.fn().mockReturnValue('US Dollar'),
|
|
131
|
+
} as unknown as IntlShape;
|
|
132
|
+
|
|
133
|
+
// Mock Intl.DisplayNames to be undefined
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
135
|
+
(Intl as any).DisplayNames = undefined;
|
|
136
|
+
|
|
137
|
+
const result = getLocaleCurrencyName(intl, 'USD');
|
|
138
|
+
expect(result).toBe('USD');
|
|
139
|
+
});
|
|
140
|
+
});
|
|
106
141
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IntlShape } from 'react-intl/src/types';
|
|
1
2
|
import { Direction } from '../direction';
|
|
2
3
|
|
|
3
4
|
export const DEFAULT_LANG = 'en';
|
|
@@ -96,3 +97,15 @@ export function getDirectionFromLocale(locale: string) {
|
|
|
96
97
|
? Direction.RTL
|
|
97
98
|
: Direction.LTR;
|
|
98
99
|
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Provides the localized currency name for a given currency code.
|
|
103
|
+
* @param intl The `intl` object from `react-intl` used for localization.
|
|
104
|
+
* @param currencyCode The ISO 4217 currency code (e.g., `USD`, `EUR`, `JPY`).
|
|
105
|
+
* @returns The localized currency name if Intl.DisplayNames is supported supported, otherwise returns the original currency code.
|
|
106
|
+
*/
|
|
107
|
+
export function getLocaleCurrencyName(intl: IntlShape, currencyCode: string) {
|
|
108
|
+
return typeof Intl.DisplayNames === 'function'
|
|
109
|
+
? intl.formatDisplayName(currencyCode, { type: 'currency', fallback: 'code' })
|
|
110
|
+
: currencyCode;
|
|
111
|
+
}
|
|
@@ -20,12 +20,6 @@ describe('Panel', () => {
|
|
|
20
20
|
onClose: jest.fn(),
|
|
21
21
|
} satisfies PanelProps;
|
|
22
22
|
|
|
23
|
-
it('renders', () => {
|
|
24
|
-
const { container } = render(<Panel {...props} />);
|
|
25
|
-
|
|
26
|
-
expect(container).toMatchSnapshot();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
23
|
it('renders arrow', () => {
|
|
30
24
|
const { rerender } = render(<Panel {...props} arrow={false} />);
|
|
31
25
|
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import { useIntl } from 'react-intl';
|
|
19
19
|
|
|
20
20
|
import messages from '../ExpressiveMoneyInput.messages';
|
|
21
|
+
import { getLocaleCurrencyName } from '../../common';
|
|
21
22
|
|
|
22
23
|
export interface CurrencyOption {
|
|
23
24
|
label?: string;
|
|
@@ -126,7 +127,10 @@ export const CurrencySelector = ({
|
|
|
126
127
|
addonEnd={disabled ? undefined : { type: 'icon', value: <ChevronDown /> }}
|
|
127
128
|
onClick={(event) => handleTriggerClick(event)}
|
|
128
129
|
>
|
|
129
|
-
|
|
130
|
+
<>
|
|
131
|
+
<span aria-hidden>{currency}</span>
|
|
132
|
+
<span className="sr-only">{getLocaleCurrencyName(intl, currency)}</span>
|
|
133
|
+
</>
|
|
130
134
|
</SelectInputTriggerButton>
|
|
131
135
|
)}
|
|
132
136
|
onChange={(newValue) => {
|
|
@@ -35,10 +35,6 @@ describe('FlowNavigation', () => {
|
|
|
35
35
|
activeStep: 0,
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
it(`renders as expected`, () => {
|
|
39
|
-
expect(render(<FlowNavigation {...props} />).container).toMatchSnapshot();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
38
|
it(`renders full Logo`, () => {
|
|
43
39
|
render(<FlowNavigation {...props} />);
|
|
44
40
|
expect(logoFull()).toBeInTheDocument();
|
|
@@ -126,12 +122,6 @@ describe('FlowNavigation', () => {
|
|
|
126
122
|
window.innerWidth = Breakpoint.SMALL - 1;
|
|
127
123
|
});
|
|
128
124
|
|
|
129
|
-
it('renders as expected', () => {
|
|
130
|
-
expect(
|
|
131
|
-
render(<FlowNavigation {...props} activeStep={1} onGoBack={jest.fn()} />).container,
|
|
132
|
-
).toMatchSnapshot();
|
|
133
|
-
});
|
|
134
|
-
|
|
135
125
|
it('renders Logo', () => {
|
|
136
126
|
render(<FlowNavigation {...props} />);
|
|
137
127
|
expect(screen.getByAltText('logo')).toBeInTheDocument();
|
package/src/index.ts
CHANGED
|
@@ -36,6 +36,7 @@ export type { EmphasisProps } from './emphasis';
|
|
|
36
36
|
export type { FieldProps } from './field/Field';
|
|
37
37
|
export type { InfoProps } from './info';
|
|
38
38
|
export type { InlinePromptProps, ActionPromptProps } from './prompt';
|
|
39
|
+
export type { InfoPromptProps, InfoPromptAction, InfoPromptMedia } from './prompt';
|
|
39
40
|
export type { InputWithDisplayFormatProps } from './inputWithDisplayFormat';
|
|
40
41
|
export type { InputProps } from './inputs/Input';
|
|
41
42
|
export type { InputGroupProps } from './inputs/InputGroup';
|
|
@@ -171,7 +172,7 @@ export { default as Header } from './header';
|
|
|
171
172
|
export { default as Image } from './image';
|
|
172
173
|
export { default as Info } from './info';
|
|
173
174
|
export { default as InlineAlert } from './inlineAlert';
|
|
174
|
-
export { InlinePrompt, ActionPrompt } from './prompt';
|
|
175
|
+
export { InfoPrompt, InlinePrompt, ActionPrompt } from './prompt';
|
|
175
176
|
export { default as InputWithDisplayFormat } from './inputWithDisplayFormat';
|
|
176
177
|
export { Input } from './inputs/Input';
|
|
177
178
|
export { InputGroup } from './inputs/InputGroup';
|
|
@@ -284,6 +285,7 @@ export {
|
|
|
284
285
|
adjustLocale,
|
|
285
286
|
getCountryFromLocale,
|
|
286
287
|
getDirectionFromLocale,
|
|
288
|
+
getLocaleCurrencyName,
|
|
287
289
|
getLangFromLocale,
|
|
288
290
|
isBrowser,
|
|
289
291
|
isServerSide,
|
package/src/inputs/Input.tsx
CHANGED
|
@@ -7,15 +7,14 @@ import { inputClassNameBase } from './_common';
|
|
|
7
7
|
import { useInputAttributes } from './contexts';
|
|
8
8
|
import { useInputPaddings } from './InputGroup';
|
|
9
9
|
|
|
10
|
-
export interface InputProps
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
> {}
|
|
10
|
+
export interface InputProps extends Merge<
|
|
11
|
+
React.ComponentPropsWithRef<'input'>,
|
|
12
|
+
{
|
|
13
|
+
size?: 'auto' | SizeSmall | SizeMedium | SizeLarge;
|
|
14
|
+
shape?: 'rectangle' | 'pill';
|
|
15
|
+
'aria-invalid'?: boolean;
|
|
16
|
+
}
|
|
17
|
+
> {}
|
|
19
18
|
|
|
20
19
|
export const Input = forwardRef(function Input(
|
|
21
20
|
{ size = 'auto', shape = 'rectangle', className, ...restProps }: InputProps,
|
|
@@ -7,15 +7,14 @@ import { Merge } from '../utils';
|
|
|
7
7
|
import { Input } from './Input';
|
|
8
8
|
import { InputGroup } from './InputGroup';
|
|
9
9
|
|
|
10
|
-
export interface SearchInputProps
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
> {}
|
|
10
|
+
export interface SearchInputProps extends Merge<
|
|
11
|
+
React.ComponentPropsWithRef<'input'>,
|
|
12
|
+
{
|
|
13
|
+
size?: Size.SMALL | Size.MEDIUM;
|
|
14
|
+
shape?: 'rectangle' | 'pill';
|
|
15
|
+
'aria-invalid'?: boolean;
|
|
16
|
+
}
|
|
17
|
+
> {}
|
|
19
18
|
|
|
20
19
|
export const SearchInput = forwardRef(function SearchInput(
|
|
21
20
|
{ shape = 'pill', size = Size.MEDIUM, disabled, className, ...restProps }: SearchInputProps,
|