@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.
Files changed (81) hide show
  1. package/build/alert/Alert.js +3 -0
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +3 -0
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/index.js +1 -0
  6. package/build/index.js.map +1 -1
  7. package/build/index.mjs +1 -1
  8. package/build/inputs/SelectInput.js +81 -12
  9. package/build/inputs/SelectInput.js.map +1 -1
  10. package/build/inputs/SelectInput.mjs +81 -13
  11. package/build/inputs/SelectInput.mjs.map +1 -1
  12. package/build/listItem/Button/ListItemButton.js +4 -3
  13. package/build/listItem/Button/ListItemButton.js.map +1 -1
  14. package/build/listItem/Button/ListItemButton.mjs +5 -4
  15. package/build/listItem/Button/ListItemButton.mjs.map +1 -1
  16. package/build/main.css +15 -7
  17. package/build/prompt/ActionPrompt/ActionPrompt.js +6 -4
  18. package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
  19. package/build/prompt/ActionPrompt/ActionPrompt.mjs +6 -4
  20. package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
  21. package/build/prompt/InfoPrompt/InfoPrompt.js.map +1 -1
  22. package/build/prompt/InfoPrompt/InfoPrompt.mjs.map +1 -1
  23. package/build/prompt/InlinePrompt/InlinePrompt.js +1 -1
  24. package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
  25. package/build/prompt/InlinePrompt/InlinePrompt.mjs +1 -1
  26. package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
  27. package/build/styles/main.css +15 -7
  28. package/build/styles/prompt/ActionPrompt/ActionPrompt.css +4 -0
  29. package/build/styles/prompt/InfoPrompt/InfoPrompt.css +7 -5
  30. package/build/styles/prompt/InlinePrompt/InlinePrompt.css +3 -2
  31. package/build/styles/prompt/PrimitivePrompt/PrimitivePrompt.css +1 -0
  32. package/build/types/alert/Alert.d.ts +15 -0
  33. package/build/types/alert/Alert.d.ts.map +1 -1
  34. package/build/types/index.d.ts +1 -1
  35. package/build/types/index.d.ts.map +1 -1
  36. package/build/types/inputs/SelectInput.d.ts +19 -0
  37. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  38. package/build/types/listItem/Button/ListItemButton.d.ts +7 -4
  39. package/build/types/listItem/Button/ListItemButton.d.ts.map +1 -1
  40. package/build/types/listItem/ListItem.d.ts +4 -4
  41. package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts +7 -0
  42. package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -1
  43. package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts +4 -2
  44. package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts.map +1 -1
  45. package/package.json +5 -5
  46. package/src/alert/Alert.story.tsx +4 -0
  47. package/src/alert/Alert.test.story.tsx +1 -1
  48. package/src/alert/Alert.tsx +16 -0
  49. package/src/iconButton/IconButton.story.tsx +173 -48
  50. package/src/iconButton/IconButton.test.story.tsx +194 -0
  51. package/src/index.ts +1 -0
  52. package/src/inputs/SelectInput.story.tsx +33 -20
  53. package/src/inputs/SelectInput.test.story.tsx +1285 -5
  54. package/src/inputs/SelectInput.tsx +93 -15
  55. package/src/listItem/Button/ListItemButton.tsx +30 -28
  56. package/src/listItem/_stories/ListItem.story.tsx +0 -1
  57. package/src/main.css +15 -7
  58. package/src/prompt/ActionPrompt/ActionPrompt.accessibility.docs.mdx +2 -18
  59. package/src/prompt/ActionPrompt/ActionPrompt.css +4 -0
  60. package/src/prompt/ActionPrompt/ActionPrompt.less +5 -1
  61. package/src/prompt/ActionPrompt/ActionPrompt.story.tsx +323 -108
  62. package/src/prompt/ActionPrompt/ActionPrompt.test.story.tsx +86 -3
  63. package/src/prompt/ActionPrompt/ActionPrompt.tsx +17 -6
  64. package/src/prompt/InfoPrompt/InfoPrompt.accessibility.docs.mdx +79 -0
  65. package/src/prompt/InfoPrompt/InfoPrompt.css +7 -5
  66. package/src/prompt/InfoPrompt/InfoPrompt.less +8 -8
  67. package/src/prompt/InfoPrompt/InfoPrompt.story.tsx +112 -82
  68. package/src/prompt/InfoPrompt/InfoPrompt.test.story.tsx +54 -1
  69. package/src/prompt/InfoPrompt/InfoPrompt.tsx +4 -2
  70. package/src/prompt/InlinePrompt/InlinePrompt.accessibility.docs.mdx +63 -0
  71. package/src/prompt/InlinePrompt/InlinePrompt.css +3 -2
  72. package/src/prompt/InlinePrompt/InlinePrompt.less +2 -2
  73. package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +25 -30
  74. package/src/prompt/InlinePrompt/InlinePrompt.test.story.tsx +21 -0
  75. package/src/prompt/InlinePrompt/InlinePrompt.test.tsx +10 -3
  76. package/src/prompt/InlinePrompt/InlinePrompt.tsx +1 -1
  77. package/src/prompt/PrimitivePrompt/PrimitivePrompt.css +1 -0
  78. package/src/prompt/PrimitivePrompt/PrimitivePrompt.less +2 -1
  79. package/src/sentimentSurface/SentimentSurface.docs.mdx +1 -1
  80. package/src/sentimentSurface/SentimentSurface.story.tsx +1 -1
  81. 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: (a, b, searchQuery) => {
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 demonstrates custom sorting with the <code>sortFilteredOptions</code> prop.
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 &quot;united&quot; - Without the custom sorter, it would just be the
677
- provided options order.
665
+ Try searching for &quot;united&quot; to see the sorting tiers in action:
678
666
  <br />
679
- With a customer sorter function in this story, the countries with &quot;United&quot; in
680
- their name appear first, followed by countries that only match via keywords.
667
+ 1. <strong>United States</strong> name starts with &quot;United&quot;
668
+ <br />
669
+ 2. <strong>New United Republic</strong> — name contains &quot;United&quot;
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
  };