@transferwise/components 46.127.1 → 46.128.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/alert/Alert.js +3 -0
- package/build/alert/Alert.js.map +1 -1
- package/build/alert/Alert.mjs +3 -0
- package/build/alert/Alert.mjs.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -1
- package/build/inputs/SelectInput.js +81 -12
- package/build/inputs/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput.mjs +81 -13
- package/build/inputs/SelectInput.mjs.map +1 -1
- package/build/listItem/Button/ListItemButton.js +4 -3
- package/build/listItem/Button/ListItemButton.js.map +1 -1
- package/build/listItem/Button/ListItemButton.mjs +5 -4
- package/build/listItem/Button/ListItemButton.mjs.map +1 -1
- package/build/main.css +15 -7
- package/build/prompt/ActionPrompt/ActionPrompt.js +6 -4
- package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.mjs +6 -4
- package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
- package/build/prompt/InfoPrompt/InfoPrompt.js.map +1 -1
- package/build/prompt/InfoPrompt/InfoPrompt.mjs.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.js +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
- package/build/styles/main.css +15 -7
- package/build/styles/prompt/ActionPrompt/ActionPrompt.css +4 -0
- package/build/styles/prompt/InfoPrompt/InfoPrompt.css +7 -5
- package/build/styles/prompt/InlinePrompt/InlinePrompt.css +3 -2
- package/build/styles/prompt/PrimitivePrompt/PrimitivePrompt.css +1 -0
- package/build/types/alert/Alert.d.ts +15 -0
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +19 -0
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/listItem/Button/ListItemButton.d.ts +7 -4
- package/build/types/listItem/Button/ListItemButton.d.ts.map +1 -1
- package/build/types/listItem/ListItem.d.ts +4 -4
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts +7 -0
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -1
- package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts +4 -2
- package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/alert/Alert.story.tsx +4 -0
- package/src/alert/Alert.test.story.tsx +1 -1
- package/src/alert/Alert.tsx +16 -0
- package/src/iconButton/IconButton.story.tsx +173 -48
- package/src/iconButton/IconButton.test.story.tsx +194 -0
- package/src/index.ts +1 -0
- package/src/inputs/SelectInput.story.tsx +33 -20
- package/src/inputs/SelectInput.test.story.tsx +1285 -5
- package/src/inputs/SelectInput.tsx +93 -15
- package/src/listItem/Button/ListItemButton.tsx +30 -28
- package/src/listItem/_stories/ListItem.story.tsx +0 -1
- package/src/main.css +15 -7
- package/src/prompt/ActionPrompt/ActionPrompt.accessibility.docs.mdx +2 -18
- package/src/prompt/ActionPrompt/ActionPrompt.css +4 -0
- package/src/prompt/ActionPrompt/ActionPrompt.less +5 -1
- package/src/prompt/ActionPrompt/ActionPrompt.story.tsx +323 -108
- package/src/prompt/ActionPrompt/ActionPrompt.test.story.tsx +86 -3
- package/src/prompt/ActionPrompt/ActionPrompt.tsx +17 -6
- package/src/prompt/InfoPrompt/InfoPrompt.accessibility.docs.mdx +79 -0
- package/src/prompt/InfoPrompt/InfoPrompt.css +7 -5
- package/src/prompt/InfoPrompt/InfoPrompt.less +8 -8
- package/src/prompt/InfoPrompt/InfoPrompt.story.tsx +112 -82
- package/src/prompt/InfoPrompt/InfoPrompt.test.story.tsx +54 -1
- package/src/prompt/InfoPrompt/InfoPrompt.tsx +4 -2
- package/src/prompt/InlinePrompt/InlinePrompt.accessibility.docs.mdx +63 -0
- package/src/prompt/InlinePrompt/InlinePrompt.css +3 -2
- package/src/prompt/InlinePrompt/InlinePrompt.less +2 -2
- package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +25 -30
- package/src/prompt/InlinePrompt/InlinePrompt.test.story.tsx +21 -0
- package/src/prompt/InlinePrompt/InlinePrompt.test.tsx +10 -3
- package/src/prompt/InlinePrompt/InlinePrompt.tsx +1 -1
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.css +1 -0
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.less +2 -1
- package/src/sentimentSurface/SentimentSurface.docs.mdx +1 -1
- package/src/sentimentSurface/SentimentSurface.story.tsx +1 -1
- package/src/sentimentSurface/SentimentSurface.test.story.tsx +1 -1
|
@@ -624,6 +624,7 @@ interface CountryWithCurrency extends Country {
|
|
|
624
624
|
const countriesWithCurrency: CountryWithCurrency[] = [
|
|
625
625
|
{ code: 'AD', name: 'Andorra', keywords: ['united states dollar'] },
|
|
626
626
|
{ code: 'DE', name: 'Germany', keywords: ['EUR'] },
|
|
627
|
+
{ code: 'NR', name: 'New United Republic', keywords: ['NUR'] },
|
|
627
628
|
{ code: 'US', name: 'United States', keywords: ['USD'] },
|
|
628
629
|
{ code: 'ZM', name: 'Zambia', keywords: ['USD', 'united states dollar'] },
|
|
629
630
|
];
|
|
@@ -649,38 +650,50 @@ export const WithCustomSearchResultSorting: Story<CountryWithCurrency> = {
|
|
|
649
650
|
value: countriesWithCurrency[0],
|
|
650
651
|
filterable: true,
|
|
651
652
|
filterPlaceholder: 'Type a currency / country',
|
|
652
|
-
sortFilteredOptions: (
|
|
653
|
-
const normalizedQuery = searchQuery.toLowerCase();
|
|
654
|
-
const nameA = a.value.name.toLowerCase();
|
|
655
|
-
const nameB = b.value.name.toLowerCase();
|
|
656
|
-
|
|
657
|
-
// Prioritize countries where name contains the search query
|
|
658
|
-
const aNameMatch = nameA.includes(normalizedQuery);
|
|
659
|
-
const bNameMatch = nameB.includes(normalizedQuery);
|
|
660
|
-
|
|
661
|
-
if (aNameMatch && !bNameMatch) return -1;
|
|
662
|
-
if (!aNameMatch && bNameMatch) return 1;
|
|
663
|
-
|
|
664
|
-
// Then sort alphabetically
|
|
665
|
-
return nameA.localeCompare(nameB);
|
|
666
|
-
},
|
|
653
|
+
sortFilteredOptions: SelectInput.sortByRelevance((value) => value.name),
|
|
667
654
|
size: 'lg',
|
|
668
655
|
} satisfies Story<CountryWithCurrency>['args'],
|
|
669
656
|
decorators: [
|
|
670
657
|
(Story) => (
|
|
671
658
|
<div>
|
|
672
659
|
<p className="m-b-3 np-text-body-default" style={{ maxWidth: '600px' }}>
|
|
673
|
-
This example
|
|
660
|
+
This example uses the built-in <code>SelectInput.sortByRelevance</code> helper to sort
|
|
661
|
+
filtered results by relevance. It prioritises: exact matches → starts with → contains →
|
|
662
|
+
alphabetical.
|
|
674
663
|
<br />
|
|
675
664
|
<br />
|
|
676
|
-
Try searching for "united"
|
|
677
|
-
provided options order.
|
|
665
|
+
Try searching for "united" to see the sorting tiers in action:
|
|
678
666
|
<br />
|
|
679
|
-
|
|
680
|
-
|
|
667
|
+
1. <strong>United States</strong> — name starts with "United"
|
|
668
|
+
<br />
|
|
669
|
+
2. <strong>New United Republic</strong> — name contains "United"
|
|
670
|
+
<br />
|
|
671
|
+
3. <strong>Andorra, Zambia</strong> — match only via keywords
|
|
681
672
|
</p>
|
|
682
673
|
<Story />
|
|
683
674
|
</div>
|
|
684
675
|
),
|
|
685
676
|
],
|
|
677
|
+
parameters: {
|
|
678
|
+
docs: {
|
|
679
|
+
source: {
|
|
680
|
+
code: `<SelectInput
|
|
681
|
+
filterable
|
|
682
|
+
filterPlaceholder="Type a currency / country"
|
|
683
|
+
sortFilteredOptions={SelectInput.sortByRelevance((value) => value.name)}
|
|
684
|
+
items={countries.map((country) => ({
|
|
685
|
+
type: 'option',
|
|
686
|
+
value: country,
|
|
687
|
+
filterMatchers: [country.name, country.code, ...country.keywords],
|
|
688
|
+
}))}
|
|
689
|
+
renderValue={(country) => (
|
|
690
|
+
<SelectInputOptionContent
|
|
691
|
+
title={country.name}
|
|
692
|
+
icon={<Flag code={country.code} />}
|
|
693
|
+
/>
|
|
694
|
+
)}
|
|
695
|
+
/>`,
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
},
|
|
686
699
|
};
|