@transferwise/components 46.100.1 → 46.101.0

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 (190) hide show
  1. package/build/avatarLayout/AvatarLayout.js +1 -1
  2. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  3. package/build/avatarLayout/AvatarLayout.mjs +1 -1
  4. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  5. package/build/dateLookup/DateLookup.js +3 -2
  6. package/build/dateLookup/DateLookup.js.map +1 -1
  7. package/build/dateLookup/DateLookup.mjs +3 -2
  8. package/build/dateLookup/DateLookup.mjs.map +1 -1
  9. package/build/i18n/en.json +2 -0
  10. package/build/i18n/en.json.js +2 -0
  11. package/build/i18n/en.json.js.map +1 -1
  12. package/build/i18n/en.json.mjs +2 -0
  13. package/build/i18n/en.json.mjs.map +1 -1
  14. package/build/main.css +4 -94
  15. package/build/styles/accordion/Accordion.css +27 -16
  16. package/build/styles/avatar/Avatar.css +95 -50
  17. package/build/styles/inputs/Input.css +37 -21
  18. package/build/styles/inputs/TextArea.css +35 -20
  19. package/build/styles/loader/Loader.css +4 -90
  20. package/build/styles/main.css +4 -94
  21. package/build/styles/popover/Popover.css +19 -12
  22. package/build/styles/select/Select.css +131 -68
  23. package/build/styles/switch/Switch.css +27 -16
  24. package/build/styles/tile/Tile.css +31 -18
  25. package/build/types/dateLookup/DateLookup.d.ts +2 -2
  26. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  27. package/build/types/test-utils/index.d.ts +4 -0
  28. package/build/types/test-utils/index.d.ts.map +1 -1
  29. package/build/types/test-utils/story-config.d.ts +2 -3
  30. package/build/types/test-utils/story-config.d.ts.map +1 -1
  31. package/build/types/upload/Upload.d.ts +6 -2
  32. package/build/types/upload/Upload.d.ts.map +1 -1
  33. package/build/types/upload/Upload.messages.d.ts +8 -0
  34. package/build/types/upload/Upload.messages.d.ts.map +1 -1
  35. package/build/types/uploadInput/UploadInput.d.ts +1 -1
  36. package/build/types/uploadInput/uploadButton/UploadButton.d.ts +4 -2
  37. package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
  38. package/build/upload/Upload.js +16 -9
  39. package/build/upload/Upload.js.map +1 -1
  40. package/build/upload/Upload.messages.js +6 -0
  41. package/build/upload/Upload.messages.js.map +1 -1
  42. package/build/upload/Upload.messages.mjs +6 -0
  43. package/build/upload/Upload.messages.mjs.map +1 -1
  44. package/build/upload/Upload.mjs +16 -9
  45. package/build/upload/Upload.mjs.map +1 -1
  46. package/build/uploadInput/UploadInput.js +1 -1
  47. package/build/uploadInput/UploadInput.js.map +1 -1
  48. package/build/uploadInput/UploadInput.mjs +1 -1
  49. package/build/uploadInput/UploadInput.mjs.map +1 -1
  50. package/build/uploadInput/uploadButton/UploadButton.js +7 -4
  51. package/build/uploadInput/uploadButton/UploadButton.js.map +1 -1
  52. package/build/uploadInput/uploadButton/UploadButton.mjs +7 -4
  53. package/build/uploadInput/uploadButton/UploadButton.mjs.map +1 -1
  54. package/package.json +19 -27
  55. package/src/accordion/Accordion.css +27 -16
  56. package/src/accordion/Accordion.story.tsx +1 -1
  57. package/src/actionButton/ActionButton.story.tsx +3 -2
  58. package/src/actionOption/ActionOption.story.tsx +2 -2
  59. package/src/alert/Alert.story.tsx +2 -2
  60. package/src/alert/Alert.tests.story.tsx +2 -2
  61. package/src/avatar/Avatar.css +95 -50
  62. package/src/avatar/Avatar.spec.tsx +1 -1
  63. package/src/avatar/Avatar.story.tsx +3 -2
  64. package/src/avatarLayout/AvatarLayout.story.tsx +1 -1
  65. package/src/avatarLayout/AvatarLayout.tsx +1 -1
  66. package/src/avatarView/AvatarView.story.tsx +1 -1
  67. package/src/avatarWrapper/AvatarWrapper.story.tsx +3 -2
  68. package/src/badge/Badge.story.tsx +49 -28
  69. package/src/button/Button.accessibility.docs.mdx +1 -1
  70. package/src/button/Button.story.tsx +2 -2
  71. package/src/button/Button.tests.story.tsx +2 -2
  72. package/src/button/LegacyButton.story.tsx +3 -2
  73. package/src/card/Card.story.tsx +2 -2
  74. package/src/carousel/Carousel.story.tsx +1 -1
  75. package/src/checkbox/Checkbox.story.tsx +2 -2
  76. package/src/checkboxButton/CheckboxButton.story.tsx +2 -2
  77. package/src/checkboxOption/CheckboxOption.story.tsx +35 -29
  78. package/src/chevron/Chevron.story.tsx +1 -1
  79. package/src/chips/Chips.story.tsx +1 -1
  80. package/src/circularButton/CircularButton.story.tsx +1 -1
  81. package/src/circularButton/CircularButton.tests.story.tsx +1 -1
  82. package/src/common/bottomSheet/BottomSheet.story.tsx +2 -2
  83. package/src/common/card/Card.story.tsx +1 -1
  84. package/src/common/circle/Circle.story.tsx +2 -2
  85. package/src/common/locale/index.spec.ts +28 -16
  86. package/src/common/responsivePanel/ResponsivePanel.spec.js +8 -29
  87. package/src/criticalBanner/CriticalCommsBanner.story.tsx +1 -1
  88. package/src/dateInput/DateInput.story.tsx +2 -2
  89. package/src/dateInput/DateInput.tests.story.tsx +2 -2
  90. package/src/dateLookup/DateLookup.spec.tsx +5 -5
  91. package/src/dateLookup/DateLookup.story.tsx +43 -71
  92. package/src/dateLookup/DateLookup.tests.story.tsx +3 -3
  93. package/src/dateLookup/DateLookup.tsx +4 -1
  94. package/src/decision/Decision.story.tsx +24 -49
  95. package/src/definitionList/DefinitionList.story.tsx +1 -1
  96. package/src/dimmer/Dimmer.story.tsx +2 -2
  97. package/src/divider/Divider.accessibility.docs.mdx +1 -1
  98. package/src/divider/Divider.story.tsx +1 -1
  99. package/src/drawer/Drawer.story.tsx +13 -7
  100. package/src/dropFade/DropFade.story.tsx +1 -1
  101. package/src/emphasis/Emphasis.spec.tsx +8 -8
  102. package/src/emphasis/Emphasis.story.tsx +1 -1
  103. package/src/field/Field.story.tsx +3 -3
  104. package/src/flowNavigation/FlowNavigation.story.tsx +305 -260
  105. package/src/i18n/en.json +2 -0
  106. package/src/iconButton/IconButton.story.tsx +2 -2
  107. package/src/image/Image.story.tsx +27 -54
  108. package/src/info/Info.story.tsx +2 -2
  109. package/src/inlineAlert/InlineAlert.story.tsx +1 -1
  110. package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +2 -2
  111. package/src/inputs/Input.css +37 -21
  112. package/src/inputs/InputGroup.story.tsx +1 -1
  113. package/src/inputs/SearchInput.story.tsx +1 -1
  114. package/src/inputs/SelectInput.docs.mdx +1 -1
  115. package/src/inputs/SelectInput.story.tsx +2 -2
  116. package/src/inputs/TextArea.css +35 -20
  117. package/src/instructionsList/InstructionsList.story.tsx +2 -2
  118. package/src/legacylistItem/LegacyListItem.story.tsx +1 -1
  119. package/src/loader/Loader.css +4 -90
  120. package/src/loader/Loader.story.tsx +1 -1
  121. package/src/logo/Logo.story.tsx +1 -1
  122. package/src/main.css +4 -94
  123. package/src/markdown/Markdown.story.tsx +1 -1
  124. package/src/modal/Modal.story.tsx +2 -2
  125. package/src/money/Money.story.tsx +1 -1
  126. package/src/moneyInput/MoneyInput.docs.mdx +1 -1
  127. package/src/moneyInput/MoneyInput.spec.tsx +8 -5
  128. package/src/moneyInput/MoneyInput.story.tsx +2 -2
  129. package/src/moneyInput/currencyFormatting.spec.ts +1 -1
  130. package/src/navigationOption/NavigationOption.story.tsx +265 -226
  131. package/src/nudge/Nudge.story.tsx +1 -1
  132. package/src/overlayHeader/OverlayHeader.story.tsx +32 -24
  133. package/src/phoneNumberInput/PhoneNumberInput.story.tsx +1 -1
  134. package/src/phoneNumberInput/utils/setDefaultPrefix/setDefaultPrefix.spec.ts +6 -3
  135. package/src/popover/Popover.css +19 -12
  136. package/src/popover/Popover.story.tsx +2 -2
  137. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +2 -2
  138. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.tests.story.tsx +2 -2
  139. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +2 -2
  140. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.tests.story.tsx +2 -2
  141. package/src/processIndicator/ProcessIndicator.story.tsx +1 -1
  142. package/src/progress/Progress.story.tsx +1 -1
  143. package/src/progressBar/ProgressBar.story.tsx +1 -1
  144. package/src/promoCard/PromoCard.story.tsx +1 -1
  145. package/src/promoCard/PromoCardGroup.story.tsx +1 -1
  146. package/src/provider/Provider.spec.tsx +2 -2
  147. package/src/provider/Provider.story.tsx +1 -1
  148. package/src/provider/direction/DirectionProvider.spec.tsx +1 -1
  149. package/src/provider/language/LanguageProvider.spec.tsx +1 -1
  150. package/src/provider/theme/ThemeProvider.story.tsx +1 -1
  151. package/src/radio/Radio.story.tsx +59 -42
  152. package/src/radioGroup/RadioGroup.story.tsx +2 -2
  153. package/src/radioOption/RadioOption.story.tsx +73 -38
  154. package/src/segmentedControl/SegmentedControl.story.tsx +1 -1
  155. package/src/select/Select.css +131 -68
  156. package/src/select/Select.story.tsx +385 -397
  157. package/src/slidingPanel/SlidingPanel.story.tsx +30 -13
  158. package/src/snackbar/Snackbar.story.tsx +50 -36
  159. package/src/snackbar/Snackbar.tests.story.tsx +3 -2
  160. package/src/statusIcon/StatusIcon.docs.mdx +1 -1
  161. package/src/statusIcon/StatusIcon.spec.tsx +8 -5
  162. package/src/statusIcon/StatusIcon.story.tsx +1 -1
  163. package/src/stepper/Stepper.story.tsx +2 -2
  164. package/src/stepper/Stepper.tests.story.tsx +2 -2
  165. package/src/sticky/Sticky.story.tsx +1 -1
  166. package/src/summary/Summary.story.tsx +18 -17
  167. package/src/switch/Switch.css +27 -16
  168. package/src/switch/Switch.story.tsx +2 -2
  169. package/src/switchOption/SwitchOption.story.tsx +1 -1
  170. package/src/table/Table.story.tsx +1 -1
  171. package/src/test-utils/story-config.ts +9 -6
  172. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +2 -2
  173. package/src/tile/Tile.css +31 -18
  174. package/src/tile/Tile.story.tsx +43 -43
  175. package/src/tooltip/Tooltip.story.tsx +2 -2
  176. package/src/typeahead/Typeahead.story.tsx +2 -2
  177. package/src/upload/Upload.messages.ts +8 -0
  178. package/src/upload/Upload.spec.tsx +6 -0
  179. package/src/upload/Upload.story.tsx +120 -5
  180. package/src/upload/Upload.tests.story.tsx +5 -3
  181. package/src/upload/Upload.tsx +24 -15
  182. package/src/upload/utils/isTypeValid/isTypeValid.spec.ts +3 -1
  183. package/src/uploadInput/UploadInput.story.tsx +1 -1
  184. package/src/uploadInput/UploadInput.tests.story.tsx +10 -3
  185. package/src/uploadInput/UploadInput.tsx +2 -2
  186. package/src/uploadInput/uploadButton/UploadButton.spec.tsx +6 -0
  187. package/src/uploadInput/uploadButton/UploadButton.tsx +12 -6
  188. package/src/withId/withId.docs.mdx +1 -1
  189. package/src/withId/withId.story.tsx +1 -1
  190. package/src/common/responsivePanel/__snapshots__/ResponsivePanel.spec.js.snap +0 -21
@@ -1,16 +1,38 @@
1
- import { text, boolean, select } from '@storybook/addon-knobs';
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { Person as ProfileIcon, Globe as GlobeIcon } from '@transferwise/icons';
3
3
  import { useState } from 'react';
4
-
5
4
  import Select, { SelectItem, SelectOptionItem } from './Select';
6
5
 
7
6
  /**
8
- * @deprecated Use **`SelectInput`** instead (https://neptune.wise.design/blog/2023-11-28-adopting-our-new-selectinput)
7
+ * @deprecated Use **`SelectInput`** instead <br/> [https://neptune.wise.design/blog/2023-11-28-adopting-our-new-selectinput](https://neptune.wise.design/blog/2023-11-28-adopting-our-new-selectinput)
9
8
  */
10
- export default {
9
+ const meta: Meta<typeof Select> = {
11
10
  component: Select,
12
- title: 'Forms/Select (Deprecated)',
11
+ title: 'Forms/Select',
12
+ tags: ['deprecated'],
13
+ argTypes: {
14
+ id: { control: 'text' },
15
+ size: { control: 'radio', options: ['sm', 'md', 'lg'] },
16
+ dropdownRight: { control: 'radio', options: ['xs', 'sm', 'md', 'lg', 'xl'] },
17
+ dropdownWidth: { control: 'radio', options: [undefined, 'sm', 'md', 'lg'] },
18
+ placeholder: { control: 'text' },
19
+ inverse: { control: 'boolean' },
20
+ block: { control: 'boolean' },
21
+ required: { control: 'boolean' },
22
+ dropdownUp: { control: 'boolean' },
23
+ disabled: { control: 'boolean' },
24
+ search: { control: 'boolean' },
25
+ searchPlaceholder: { control: 'text' },
26
+ options: { control: false },
27
+ selected: { control: false },
28
+ onChange: { action: 'onChange' },
29
+ onSearchChange: { action: 'onSearchChange' },
30
+ searchValue: { control: false },
31
+ },
13
32
  };
33
+ export default meta;
34
+
35
+ type Story = StoryObj<typeof Select>;
14
36
 
15
37
  const ImageIcon = () => (
16
38
  <img
@@ -20,410 +42,376 @@ const ImageIcon = () => (
20
42
  />
21
43
  );
22
44
 
23
- interface SelectItemWithCountries extends SelectItem {
24
- countries?: string;
25
- }
26
-
27
45
  const isSelectOptionItem = (option: SelectItem | null): option is SelectOptionItem => {
28
46
  return option !== null && typeof option.value !== 'undefined';
29
47
  };
30
48
 
31
- export const Basic = () => {
32
- const [selected, setSelected] = useState<SelectOptionItem>({
33
- value: 0,
34
- label: 'A thing',
35
- note: 'with a note',
36
- });
37
-
38
- const size = select('size', ['sm', 'md', 'lg'], 'md');
39
- const dropdownRight = select('dropdownRight', ['xs', 'sm', 'md', 'lg', 'xl'], 'md');
40
- const dropdownWidth = select('dropdownWidth', [undefined, 'sm', 'md', 'lg'], 'md');
41
-
42
- const id = text('id', 'basic-button');
43
- const placeholder = text('placeholder', 'Placeholder text');
44
- const inverse = boolean('inverse', false);
45
- const block = boolean('block', true);
46
- const required = boolean('required', false);
47
- const dropdownUp = boolean('dropdownUp', false);
48
- const disabled = boolean('disabled', false);
49
- const search = boolean('search', true);
50
-
51
- return (
52
- <Select
53
- id={id}
54
- size={size}
55
- placeholder={placeholder}
56
- dropdownRight={dropdownRight}
57
- dropdownWidth={dropdownWidth}
58
- inverse={inverse}
59
- block={block}
60
- selected={selected}
61
- disabled={disabled}
62
- search={search}
63
- required={required}
64
- searchPlaceholder="Search placeholder"
65
- dropdownUp={dropdownUp}
66
- options={[
67
- { header: 'Basic' },
68
- { value: -1, label: 'A thing' },
69
- { value: 0, label: 'A thing', note: 'with a note' },
70
- { value: 1, label: 'Another thing', secondary: 'with secondary text this time' },
71
- {
72
- value: -2,
73
- label: 'One more thing',
74
- note: 'with a note',
75
- secondary: 'and with secondary text',
76
- },
77
- { value: 6, icon: <ImageIcon />, label: 'An <img>', note: 'with a note' },
78
- { value: 2, label: 'A disabled thing', disabled: true },
79
- { separator: true },
80
- { header: 'Icons' },
81
- { value: 3, label: 'Profile', icon: <ProfileIcon /> },
82
- {
83
- value: 4,
84
- label: 'USD',
85
- icon: <GlobeIcon />,
86
- note: 'United States dollar - Outside of the US',
87
- },
88
- { header: 'Currencies' },
89
- { value: 5, label: 'British pound', currency: 'gbp' },
90
- { value: 6, label: 'Euro', currency: 'eur' },
91
- { value: 7, label: 'USD', currency: 'usd', note: 'United States dollar' },
92
- { separator: true },
93
- { value: 8, label: 'Something else' },
94
- { header: 'Options with searchable alternatives' },
95
- {
96
- value: 9,
97
- label: 'A thing with searchable alternatives',
98
- searchStrings: ['abbreviation', 'acronym', 'nickname'],
99
- },
100
- { separator: true },
101
- { header: 'Long content options' },
102
- {
103
- value: 10,
104
- label:
105
- 'One more thing with lorem ipsum dolor sit amet, consectetur adipiscing elit consequat text',
106
- note: 'with lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor note text',
107
- secondary:
108
- 'and with lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation secondary text',
109
- },
110
- {
111
- value: 11,
112
- icon: <GlobeIcon />,
113
- label:
114
- 'One more thing with lorem ipsum dolor sit amet, consectetur adipiscing elit consequat text',
115
- note: 'with lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor note text',
116
- secondary:
117
- 'and with lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation secondary text',
118
- },
119
- ]}
120
- onChange={(option) => {
121
- if (isSelectOptionItem(option)) {
122
- setSelected(option);
123
- }
124
- }}
125
- />
126
- );
49
+ export const Basic: Story = {
50
+ args: {
51
+ id: 'basic-button',
52
+ size: 'md',
53
+ placeholder: 'Placeholder text',
54
+ dropdownRight: 'md',
55
+ dropdownWidth: 'md',
56
+ inverse: false,
57
+ block: true,
58
+ required: false,
59
+ dropdownUp: false,
60
+ disabled: false,
61
+ search: true,
62
+ searchPlaceholder: 'Search placeholder',
63
+ options: [
64
+ { header: 'Basic' },
65
+ { value: -1, label: 'A thing' },
66
+ { value: 0, label: 'A thing', note: 'with a note' },
67
+ { value: 1, label: 'Another thing', secondary: 'with secondary text this time' },
68
+ {
69
+ value: -2,
70
+ label: 'One more thing',
71
+ note: 'with a note',
72
+ secondary: 'and with secondary text',
73
+ },
74
+ { value: 6, icon: <ImageIcon />, label: 'An <img>', note: 'with a note' },
75
+ { value: 2, label: 'A disabled thing', disabled: true },
76
+ { separator: true },
77
+ { header: 'Icons' },
78
+ { value: 3, label: 'Profile', icon: <ProfileIcon /> },
79
+ {
80
+ value: 4,
81
+ label: 'USD',
82
+ icon: <GlobeIcon />,
83
+ note: 'United States dollar - Outside of the US',
84
+ },
85
+ { header: 'Currencies' },
86
+ { value: 5, label: 'British pound', currency: 'gbp' },
87
+ { value: 6, label: 'Euro', currency: 'eur' },
88
+ { value: 7, label: 'USD', currency: 'usd', note: 'United States dollar' },
89
+ { separator: true },
90
+ { value: 8, label: 'Something else' },
91
+ { header: 'Options with searchable alternatives' },
92
+ {
93
+ value: 9,
94
+ label: 'A thing with searchable alternatives',
95
+ searchStrings: ['abbreviation', 'acronym', 'nickname'],
96
+ },
97
+ { separator: true },
98
+ { header: 'Long content options' },
99
+ {
100
+ value: 10,
101
+ label:
102
+ 'One more thing with lorem ipsum dolor sit amet, consectetur adipiscing elit consequat text',
103
+ note: 'with lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor note text',
104
+ secondary:
105
+ 'and with lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation secondary text',
106
+ },
107
+ {
108
+ value: 11,
109
+ icon: <GlobeIcon />,
110
+ label:
111
+ 'One more thing with lorem ipsum dolor sit amet, consectetur adipiscing elit consequat text',
112
+ note: 'with lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor note text',
113
+ secondary:
114
+ 'and with lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation secondary text',
115
+ },
116
+ ],
117
+ selected: { value: 0, label: 'A thing', note: 'with a note' },
118
+ },
119
+ render: (args) => {
120
+ const initialSelected = args.selected ?? { value: 0, label: 'A thing', note: 'with a note' };
121
+ const [selected, setSelected] = useState<SelectOptionItem>(initialSelected);
122
+ return (
123
+ <Select
124
+ {...args}
125
+ selected={selected}
126
+ onChange={(option) => {
127
+ if (isSelectOptionItem(option)) {
128
+ setSelected(option);
129
+ }
130
+ }}
131
+ />
132
+ );
133
+ },
127
134
  };
128
135
 
129
- export const CustomSearchFunction = () => {
130
- const [selected, setSelected] = useState<SelectOptionItem>({
131
- value: 1,
132
- label: 'EUR',
133
- currency: 'EUR',
134
- });
135
-
136
- const size = select('size', ['sm', 'md', 'lg'], 'md');
137
- const dropdownRight = select('dropdownRight', ['xs', 'sm', 'md', 'lg', 'xl'], 'md');
138
- const dropdownWidth = select('dropdownWidth', [undefined, 'sm', 'md', 'lg'], 'md');
139
-
140
- const id = text('id', 'custom-search-button');
141
- const placeholder = text('placeholder', 'placeholder');
142
- const inverse = boolean('inverse', false);
143
- const block = boolean('block', true);
144
- const required = boolean('required', false);
145
- const dropdownUp = boolean('dropdownUp', false);
146
- const disabled = boolean('disabled', false);
147
- const search = boolean('search', true);
148
-
149
- return (
150
- <Select
151
- id={id}
152
- size={size}
153
- placeholder={placeholder}
154
- dropdownRight={dropdownRight}
155
- dropdownWidth={dropdownWidth}
156
- inverse={inverse}
157
- block={block}
158
- selected={selected}
159
- disabled={disabled}
160
- search={search}
161
- required={required}
162
- searchPlaceholder="Search placeholder"
163
- dropdownUp={dropdownUp}
164
- options={[
165
- { header: 'Popular currencies' },
166
- {
167
- value: 1,
168
- label: 'EUR',
169
- currency: 'EUR',
170
- searchStrings: [
171
- 'Austria',
172
- 'Belgium',
173
- 'Cyprus',
174
- 'Estonia',
175
- 'Finland',
176
- 'France',
177
- 'Germany',
178
- 'Greece',
179
- 'Ireland',
180
- 'Italy',
181
- 'Latvia',
182
- 'Lithuania',
183
- 'Luxembourg',
184
- 'Malta',
185
- 'Netherlands',
186
- 'Portugal',
187
- 'Slovakia',
188
- 'Slovenia',
189
- 'Spain',
190
- 'Andorra',
191
- 'Monaco',
192
- 'San Marino',
193
- 'Vatican City',
194
- 'Kosovo',
195
- 'Montenegro',
196
- ],
197
- },
198
- {
199
- value: 2,
200
- label: 'GBP',
201
- currency: 'GBP',
202
- searchStrings: ['Isle of Man', 'United Kingdom'],
203
- },
204
- {
205
- value: 3,
206
- label: 'INR',
207
- currency: 'INR',
208
- searchStrings: ['India'],
209
- },
210
- {
211
- value: 4,
212
- label: 'USD',
213
- currency: 'USD',
214
- searchStrings: [
215
- 'United States',
216
- 'Ecuador',
217
- 'El Salvador',
218
- 'Panama',
219
- 'East Timor',
220
- 'Zimbabwe',
221
- 'Micronesia',
222
- 'Marshall Islands',
223
- 'Palau',
224
- 'Turks and Caicos Islands',
225
- 'British Virgin Islands',
226
- 'Caribbean Netherlands',
227
- 'Bermuda',
228
- 'Bahamas',
229
- 'Puerto Rico',
230
- 'Guam',
231
- 'Northern Mariana Islands',
232
- 'American Samoa',
233
- 'U.S. Virgin Islands',
234
- ],
235
- },
236
- {
237
- value: 5,
238
- label: 'DOP',
239
- currency: 'dop',
240
- },
241
- {
242
- value: 6,
243
- label: 'UZS',
244
- currency: 'uzs',
245
- },
246
- {
247
- value: 7,
248
- label: 'TTD',
249
- currency: 'ttd',
250
- },
251
- { header: 'All currencies' },
252
- {
253
- currency: 'aed',
254
- value: 'AED',
255
- label: 'AED',
256
- searchStrings: ['United Arab Emirates'],
257
- },
258
- {
259
- currency: 'aud',
260
- value: 'AUD',
261
- label: 'AUD',
262
- note: 'Australian dollar',
263
- searchStrings: ['Australia'],
264
- secondary: '',
265
- icon: null,
266
- },
267
- {
268
- currency: 'bgn',
269
- value: 'BGN',
270
- label: 'BGN',
271
- note: 'Bulgarian lev',
272
- searchStrings: ['Bulgaria'],
273
- secondary: '',
274
- icon: null,
275
- },
276
- {
277
- currency: 'brl',
278
- value: 'BRL',
279
- label: 'BRL',
280
- note: 'Brazilian real',
281
- searchStrings: ['Brazil'],
282
- secondary: '',
283
- icon: null,
284
- },
285
- {
286
- currency: undefined,
287
- value: 'USD',
288
- label: 'USD',
289
- note: 'United States dollar - Outside of the US',
290
- searchStrings: ['United States'],
291
- secondary: '',
292
- icon: <GlobeIcon />,
293
- },
294
- ]}
295
- onChange={(option) => {
296
- if (isSelectOptionItem(option)) {
297
- setSelected(option);
298
- }
299
- }}
300
- />
301
- );
136
+ export const CustomSearchFunction: Story = {
137
+ args: {
138
+ id: 'custom-search-button',
139
+ size: 'md',
140
+ placeholder: 'placeholder',
141
+ dropdownRight: 'md',
142
+ dropdownWidth: 'md',
143
+ inverse: false,
144
+ block: true,
145
+ required: false,
146
+ dropdownUp: false,
147
+ disabled: false,
148
+ search: true,
149
+ searchPlaceholder: 'Search placeholder',
150
+ options: [
151
+ { header: 'Popular currencies' },
152
+ {
153
+ value: 1,
154
+ label: 'EUR',
155
+ currency: 'EUR',
156
+ searchStrings: [
157
+ 'Austria',
158
+ 'Belgium',
159
+ 'Cyprus',
160
+ 'Estonia',
161
+ 'Finland',
162
+ 'France',
163
+ 'Germany',
164
+ 'Greece',
165
+ 'Ireland',
166
+ 'Italy',
167
+ 'Latvia',
168
+ 'Lithuania',
169
+ 'Luxembourg',
170
+ 'Malta',
171
+ 'Netherlands',
172
+ 'Portugal',
173
+ 'Slovakia',
174
+ 'Slovenia',
175
+ 'Spain',
176
+ 'Andorra',
177
+ 'Monaco',
178
+ 'San Marino',
179
+ 'Vatican City',
180
+ 'Kosovo',
181
+ 'Montenegro',
182
+ ],
183
+ },
184
+ {
185
+ value: 2,
186
+ label: 'GBP',
187
+ currency: 'GBP',
188
+ searchStrings: ['Isle of Man', 'United Kingdom'],
189
+ },
190
+ {
191
+ value: 3,
192
+ label: 'INR',
193
+ currency: 'INR',
194
+ searchStrings: ['India'],
195
+ },
196
+ {
197
+ value: 4,
198
+ label: 'USD',
199
+ currency: 'USD',
200
+ searchStrings: [
201
+ 'United States',
202
+ 'Ecuador',
203
+ 'El Salvador',
204
+ 'Panama',
205
+ 'East Timor',
206
+ 'Zimbabwe',
207
+ 'Micronesia',
208
+ 'Marshall Islands',
209
+ 'Palau',
210
+ 'Turks and Caicos Islands',
211
+ 'British Virgin Islands',
212
+ 'Caribbean Netherlands',
213
+ 'Bermuda',
214
+ 'Bahamas',
215
+ 'Puerto Rico',
216
+ 'Guam',
217
+ 'Northern Mariana Islands',
218
+ 'American Samoa',
219
+ 'U.S. Virgin Islands',
220
+ ],
221
+ },
222
+ { value: 5, label: 'DOP', currency: 'dop' },
223
+ { value: 6, label: 'UZS', currency: 'uzs' },
224
+ { value: 7, label: 'TTD', currency: 'ttd' },
225
+ { header: 'All currencies' },
226
+ {
227
+ currency: 'aed',
228
+ value: 'AED',
229
+ label: 'AED',
230
+ searchStrings: ['United Arab Emirates'],
231
+ },
232
+ {
233
+ currency: 'aud',
234
+ value: 'AUD',
235
+ label: 'AUD',
236
+ note: 'Australian dollar',
237
+ searchStrings: ['Australia'],
238
+ secondary: '',
239
+ icon: null,
240
+ },
241
+ {
242
+ currency: 'bgn',
243
+ value: 'BGN',
244
+ label: 'BGN',
245
+ note: 'Bulgarian lev',
246
+ searchStrings: ['Bulgaria'],
247
+ secondary: '',
248
+ icon: null,
249
+ },
250
+ {
251
+ currency: 'brl',
252
+ value: 'BRL',
253
+ label: 'BRL',
254
+ note: 'Brazilian real',
255
+ searchStrings: ['Brazil'],
256
+ secondary: '',
257
+ icon: null,
258
+ },
259
+ {
260
+ currency: undefined,
261
+ value: 'USD',
262
+ label: 'USD',
263
+ note: 'United States dollar - Outside of the US',
264
+ searchStrings: ['United States'],
265
+ secondary: '',
266
+ icon: <GlobeIcon />,
267
+ },
268
+ ],
269
+ selected: { value: 1, label: 'EUR', currency: 'EUR' },
270
+ },
271
+ render: (args) => {
272
+ const initialSelected = args.selected ?? { value: 1, label: 'EUR', currency: 'EUR' };
273
+ const [selected, setSelected] = useState<SelectOptionItem>(initialSelected);
274
+ return (
275
+ <Select
276
+ {...args}
277
+ selected={selected}
278
+ onChange={(option) => {
279
+ if (isSelectOptionItem(option)) {
280
+ setSelected(option);
281
+ }
282
+ }}
283
+ />
284
+ );
285
+ },
302
286
  };
303
287
 
304
- export const AdvancedSearch = () => {
305
- const [searchValue, setSearchValue] = useState('');
306
- const [selected, setSelected] = useState<SelectOptionItem>({
307
- value: 0,
308
- label: 'A thing',
309
- note: 'with a note',
310
- });
311
-
312
- const size = select('size', ['sm', 'md', 'lg'], 'md');
313
- const dropdownRight = select('dropdownRight', ['xs', 'sm', 'md', 'lg', 'xl'], 'md');
314
- const dropdownWidth = select('dropdownWidth', [undefined, 'sm', 'md', 'lg'], 'md');
315
-
316
- const id = text('id', 'advanced-search-button');
317
- const placeholder = text('placeholder', 'placeholder');
318
- const inverse = boolean('inverse', false);
319
- const block = boolean('block', true);
320
- const required = boolean('required', false);
321
- const dropdownUp = boolean('dropdownUp', false);
322
- const disabled = boolean('disabled', false);
323
-
324
- return (
325
- <Select
326
- id={id}
327
- size={size}
328
- placeholder={placeholder}
329
- dropdownRight={dropdownRight}
330
- dropdownWidth={dropdownWidth}
331
- inverse={inverse}
332
- block={block}
333
- selected={selected}
334
- disabled={disabled}
335
- required={required}
336
- searchValue={searchValue}
337
- searchPlaceholder="searchplaceholder"
338
- dropdownUp={dropdownUp}
339
- options={[
340
- { header: 'Basic' },
341
- { value: -1, label: 'A thing' },
342
- { value: 0, label: 'A thing', note: 'with a note' },
343
- { value: 1, label: 'Another thing', secondary: 'with secondary text this time' },
344
- {
345
- value: -2,
346
- label: 'One more thing',
347
- note: 'with a note',
348
- secondary: 'and with secondary text',
349
- },
350
- { value: 2, label: 'A disabled thing', disabled: true },
351
- { separator: true },
352
- { header: 'Icons' },
353
- { value: 3, label: 'Profile', icon: <ProfileIcon /> },
354
- { value: 4, label: 'Globe', icon: <GlobeIcon /> },
355
- { header: 'Currencies' },
356
- { value: 5, label: 'British pound', currency: 'gbp' },
357
- { value: 6, label: 'Euro', currency: 'eur' },
358
- { separator: true },
359
- { value: 7, label: 'Something else' },
360
- { header: 'Options with searchable alternatives' },
361
- {
362
- value: 8,
363
- label: 'A thing with searchable alternatives',
364
- searchStrings: ['abbreviation', 'acronym', 'nickname'],
365
- },
366
- ].filter((option) => option.label?.toLowerCase().includes(searchValue))}
367
- onChange={(option) => {
368
- if (isSelectOptionItem(option)) {
369
- setSelected(option);
288
+ export const AdvancedSearch: Story = {
289
+ args: {
290
+ id: 'advanced-search-button',
291
+ size: 'md',
292
+ placeholder: 'placeholder',
293
+ dropdownRight: 'md',
294
+ dropdownWidth: 'md',
295
+ inverse: false,
296
+ block: true,
297
+ required: false,
298
+ dropdownUp: false,
299
+ disabled: false,
300
+ searchPlaceholder: 'searchplaceholder',
301
+ options: [
302
+ { header: 'Basic' },
303
+ { value: -1, label: 'A thing' },
304
+ { value: 0, label: 'A thing', note: 'with a note' },
305
+ { value: 1, label: 'Another thing', secondary: 'with secondary text this time' },
306
+ {
307
+ value: -2,
308
+ label: 'One more thing',
309
+ note: 'with a note',
310
+ secondary: 'and with secondary text',
311
+ },
312
+ { value: 2, label: 'A disabled thing', disabled: true },
313
+ { separator: true },
314
+ { header: 'Icons' },
315
+ { value: 3, label: 'Profile', icon: <ProfileIcon /> },
316
+ { value: 4, label: 'Globe', icon: <GlobeIcon /> },
317
+ { header: 'Currencies' },
318
+ { value: 5, label: 'British pound', currency: 'gbp' },
319
+ { value: 6, label: 'Euro', currency: 'eur' },
320
+ { separator: true },
321
+ { value: 7, label: 'Something else' },
322
+ { header: 'Options with searchable alternatives' },
323
+ {
324
+ value: 8,
325
+ label: 'A thing with searchable alternatives',
326
+ searchStrings: ['abbreviation', 'acronym', 'nickname'],
327
+ },
328
+ ],
329
+ selected: { value: 0, label: 'A thing', note: 'with a note' },
330
+ },
331
+ render: (args) => {
332
+ const [searchValue, setSearchValue] = useState('');
333
+ const initialSelected = args.selected ?? { value: 0, label: 'A thing', note: 'with a note' };
334
+ const [selected, setSelected] = useState<SelectOptionItem>(initialSelected);
335
+ return (
336
+ <Select
337
+ {...args}
338
+ selected={selected}
339
+ searchValue={searchValue}
340
+ options={
341
+ Array.isArray(args.options)
342
+ ? args.options.filter(
343
+ (option) =>
344
+ typeof option.label === 'string' &&
345
+ option.label.toLowerCase().includes(searchValue),
346
+ )
347
+ : []
370
348
  }
371
- }}
372
- onSearchChange={(v) => setSearchValue(v)}
373
- />
374
- );
349
+ onChange={(option) => {
350
+ if (isSelectOptionItem(option)) {
351
+ setSelected(option);
352
+ }
353
+ }}
354
+ onSearchChange={(v) => setSearchValue(v)}
355
+ />
356
+ );
357
+ },
375
358
  };
376
359
 
377
- export const SearchingLargeLists = () => {
378
- const [selected, setSelected] = useState<SelectOptionItem>({
379
- value: 'option1',
380
- label: 'Option 1',
381
- secondary: 'Here we have a description describing option 1',
382
- });
383
-
384
- const size = select('size', ['sm', 'md', 'lg'], 'md');
385
- const dropdownRight = select('dropdownRight', ['xs', 'sm', 'md', 'lg', 'xl'], 'md');
386
- const dropdownWidth = select('dropdownWidth', [undefined, 'sm', 'md', 'lg'], 'md');
387
-
388
- const id = text('id', 'large-list-button');
389
- const placeholder = text('placeholder', 'Placeholder text');
390
- const inverse = boolean('inverse', false);
391
- const block = boolean('block', true);
392
- const required = boolean('required', false);
393
- const dropdownUp = boolean('dropdownUp', false);
394
- const disabled = boolean('disabled', false);
395
-
396
- return (
397
- <Select
398
- id={id}
399
- size={size}
400
- placeholder={placeholder}
401
- dropdownRight={dropdownRight}
402
- dropdownWidth={dropdownWidth}
403
- inverse={inverse}
404
- block={block}
405
- selected={selected}
406
- disabled={disabled}
407
- search
408
- required={required}
409
- searchPlaceholder="Search placeholder"
410
- dropdownUp={dropdownUp}
411
- options={new Array(1500).fill(null).map((x, index) => ({
412
- value: `option${index + 1}`,
413
- label: `Option ${index + 1}`,
414
- secondary: `Here we have a description describing option ${index + 1}`,
415
- }))}
416
- onChange={(option) => {
417
- if (isSelectOptionItem(option)) {
418
- setSelected(option);
419
- }
420
- }}
421
- />
422
- );
360
+ export const SearchingLargeLists: Story = {
361
+ parameters: {
362
+ docs: {
363
+ canvas: {
364
+ sourceState: 'hidden',
365
+ },
366
+ },
367
+ },
368
+ args: {
369
+ id: 'large-list-button',
370
+ size: 'md',
371
+ placeholder: 'Placeholder text',
372
+ dropdownRight: 'md',
373
+ dropdownWidth: 'md',
374
+ inverse: false,
375
+ block: true,
376
+ required: false,
377
+ dropdownUp: false,
378
+ disabled: false,
379
+ search: true,
380
+ searchPlaceholder: 'Search placeholder',
381
+ options: new Array(1500).fill(null).map((x, index) => ({
382
+ value: `option${index + 1}`,
383
+ label: `Option ${index + 1}`,
384
+ secondary: `Here we have a description describing option ${index + 1}`,
385
+ })),
386
+ selected: {
387
+ value: 'option1',
388
+ label: 'Option 1',
389
+ secondary: 'Here we have a description describing option 1',
390
+ },
391
+ },
392
+ render: (args) => {
393
+ const initialSelected = args.selected ?? {
394
+ value: 'option1',
395
+ label: 'Option 1',
396
+ secondary: 'Here we have a description describing option 1',
397
+ };
398
+ const [selected, setSelected] = useState<SelectOptionItem>(initialSelected);
399
+ return (
400
+ <Select
401
+ {...args}
402
+ selected={selected}
403
+ onChange={(option) => {
404
+ if (isSelectOptionItem(option)) {
405
+ setSelected(option);
406
+ }
407
+ }}
408
+ />
409
+ );
410
+ },
423
411
  };
424
412
 
425
- export const CustomDropdownBalances = () => {
426
- return (
413
+ export const CustomDropdownBalances: Story = {
414
+ render: () => (
427
415
  <>
428
416
  Bye
429
417
  <div className="open">
@@ -451,5 +439,5 @@ export const CustomDropdownBalances = () => {
451
439
  </ul>
452
440
  </div>
453
441
  </>
454
- );
442
+ ),
455
443
  };