@ledgerhq/lumen-ui-rnative 0.1.21 → 0.1.23

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 (99) hide show
  1. package/dist/module/lib/Components/ListItem/ListItem.js +57 -27
  2. package/dist/module/lib/Components/ListItem/ListItem.js.map +1 -1
  3. package/dist/module/lib/Components/ListItem/ListItem.mdx +15 -7
  4. package/dist/module/lib/Components/ListItem/ListItem.stories.js +497 -283
  5. package/dist/module/lib/Components/ListItem/ListItem.stories.js.map +1 -1
  6. package/dist/module/lib/Components/ListItem/ListItem.test.js +153 -0
  7. package/dist/module/lib/Components/ListItem/ListItem.test.js.map +1 -0
  8. package/dist/module/lib/Components/{TriggerButton/TriggerButton.js → MediaButton/MediaButton.js} +13 -10
  9. package/dist/module/lib/Components/MediaButton/MediaButton.js.map +1 -0
  10. package/{src/lib/Components/TriggerButton/TriggerButton.mdx → dist/module/lib/Components/MediaButton/MediaButton.mdx} +10 -10
  11. package/dist/module/lib/Components/{TriggerButton/TriggerButton.stories.js → MediaButton/MediaButton.stories.js} +18 -18
  12. package/dist/module/lib/Components/MediaButton/MediaButton.stories.js.map +1 -0
  13. package/dist/module/lib/Components/{TriggerButton/TriggerButton.test.js → MediaButton/MediaButton.test.js} +14 -14
  14. package/dist/module/lib/Components/MediaButton/MediaButton.test.js.map +1 -0
  15. package/dist/module/lib/Components/MediaButton/index.js +5 -0
  16. package/dist/module/lib/Components/MediaButton/index.js.map +1 -0
  17. package/dist/module/lib/Components/MediaButton/types.js.map +1 -0
  18. package/dist/module/lib/Components/NavBar/NavBar.js +0 -2
  19. package/dist/module/lib/Components/NavBar/NavBar.js.map +1 -1
  20. package/dist/module/lib/Components/OptionList/OptionList.figma.js +28 -0
  21. package/dist/module/lib/Components/OptionList/OptionList.figma.js.map +1 -0
  22. package/dist/module/lib/Components/OptionList/OptionList.js +452 -0
  23. package/dist/module/lib/Components/OptionList/OptionList.js.map +1 -0
  24. package/dist/module/lib/Components/OptionList/OptionList.mdx +304 -0
  25. package/dist/module/lib/Components/OptionList/OptionList.stories.js +735 -0
  26. package/dist/module/lib/Components/OptionList/OptionList.stories.js.map +1 -0
  27. package/dist/module/lib/Components/OptionList/OptionList.test.js +443 -0
  28. package/dist/module/lib/Components/OptionList/OptionList.test.js.map +1 -0
  29. package/dist/module/lib/Components/OptionList/index.js +5 -0
  30. package/dist/module/lib/Components/OptionList/index.js.map +1 -0
  31. package/dist/module/lib/Components/OptionList/types.js +4 -0
  32. package/dist/module/lib/Components/OptionList/types.js.map +1 -0
  33. package/dist/module/lib/Components/OptionList/useOptionList/useOptionListItems.js +36 -0
  34. package/dist/module/lib/Components/OptionList/useOptionList/useOptionListItems.js.map +1 -0
  35. package/dist/module/lib/Components/OptionList/useOptionList/useOptionListItems.test.js +84 -0
  36. package/dist/module/lib/Components/OptionList/useOptionList/useOptionListItems.test.js.map +1 -0
  37. package/dist/module/lib/Components/index.js +2 -1
  38. package/dist/module/lib/Components/index.js.map +1 -1
  39. package/dist/typescript/src/lib/Components/ListItem/ListItem.d.ts +8 -8
  40. package/dist/typescript/src/lib/Components/ListItem/ListItem.d.ts.map +1 -1
  41. package/dist/typescript/src/lib/Components/ListItem/types.d.ts +11 -7
  42. package/dist/typescript/src/lib/Components/ListItem/types.d.ts.map +1 -1
  43. package/dist/typescript/src/lib/Components/MediaButton/MediaButton.d.ts +23 -0
  44. package/dist/typescript/src/lib/Components/MediaButton/MediaButton.d.ts.map +1 -0
  45. package/dist/typescript/src/lib/Components/MediaButton/index.d.ts +3 -0
  46. package/dist/typescript/src/lib/Components/MediaButton/index.d.ts.map +1 -0
  47. package/dist/typescript/src/lib/Components/{TriggerButton → MediaButton}/types.d.ts +10 -5
  48. package/dist/typescript/src/lib/Components/MediaButton/types.d.ts.map +1 -0
  49. package/dist/typescript/src/lib/Components/OptionList/OptionList.d.ts +12 -0
  50. package/dist/typescript/src/lib/Components/OptionList/OptionList.d.ts.map +1 -0
  51. package/dist/typescript/src/lib/Components/OptionList/OptionList.figma.d.ts +2 -0
  52. package/dist/typescript/src/lib/Components/OptionList/OptionList.figma.d.ts.map +1 -0
  53. package/dist/typescript/src/lib/Components/OptionList/index.d.ts +3 -0
  54. package/dist/typescript/src/lib/Components/OptionList/index.d.ts.map +1 -0
  55. package/dist/typescript/src/lib/Components/OptionList/types.d.ts +97 -0
  56. package/dist/typescript/src/lib/Components/OptionList/types.d.ts.map +1 -0
  57. package/dist/typescript/src/lib/Components/OptionList/useOptionList/useOptionListItems.d.ts +12 -0
  58. package/dist/typescript/src/lib/Components/OptionList/useOptionList/useOptionListItems.d.ts.map +1 -0
  59. package/dist/typescript/src/lib/Components/index.d.ts +2 -1
  60. package/dist/typescript/src/lib/Components/index.d.ts.map +1 -1
  61. package/dist/typescript/src/styles/types/theme.types.d.ts +7 -6
  62. package/dist/typescript/src/styles/types/theme.types.d.ts.map +1 -1
  63. package/package.json +1 -1
  64. package/src/lib/Components/ListItem/ListItem.mdx +15 -7
  65. package/src/lib/Components/ListItem/ListItem.stories.tsx +354 -220
  66. package/src/lib/Components/ListItem/ListItem.test.tsx +152 -0
  67. package/src/lib/Components/ListItem/ListItem.tsx +63 -28
  68. package/src/lib/Components/ListItem/types.ts +11 -8
  69. package/{dist/module/lib/Components/TriggerButton/TriggerButton.mdx → src/lib/Components/MediaButton/MediaButton.mdx} +10 -10
  70. package/src/lib/Components/{TriggerButton/TriggerButton.stories.tsx → MediaButton/MediaButton.stories.tsx} +28 -28
  71. package/src/lib/Components/{TriggerButton/TriggerButton.test.tsx → MediaButton/MediaButton.test.tsx} +22 -22
  72. package/src/lib/Components/{TriggerButton/TriggerButton.tsx → MediaButton/MediaButton.tsx} +27 -21
  73. package/src/lib/Components/MediaButton/index.ts +2 -0
  74. package/src/lib/Components/{TriggerButton → MediaButton}/types.ts +10 -5
  75. package/src/lib/Components/NavBar/NavBar.tsx +0 -3
  76. package/src/lib/Components/OptionList/OptionList.figma.tsx +37 -0
  77. package/src/lib/Components/OptionList/OptionList.mdx +304 -0
  78. package/src/lib/Components/OptionList/OptionList.stories.tsx +755 -0
  79. package/src/lib/Components/OptionList/OptionList.test.tsx +412 -0
  80. package/src/lib/Components/OptionList/OptionList.tsx +532 -0
  81. package/src/lib/Components/OptionList/index.ts +2 -0
  82. package/src/lib/Components/OptionList/types.ts +115 -0
  83. package/src/lib/Components/OptionList/useOptionList/useOptionListItems.test.ts +73 -0
  84. package/src/lib/Components/OptionList/useOptionList/useOptionListItems.ts +49 -0
  85. package/src/lib/Components/index.ts +2 -1
  86. package/src/styles/types/theme.types.ts +8 -6
  87. package/dist/module/lib/Components/TriggerButton/TriggerButton.js.map +0 -1
  88. package/dist/module/lib/Components/TriggerButton/TriggerButton.stories.js.map +0 -1
  89. package/dist/module/lib/Components/TriggerButton/TriggerButton.test.js.map +0 -1
  90. package/dist/module/lib/Components/TriggerButton/index.js +0 -5
  91. package/dist/module/lib/Components/TriggerButton/index.js.map +0 -1
  92. package/dist/module/lib/Components/TriggerButton/types.js.map +0 -1
  93. package/dist/typescript/src/lib/Components/TriggerButton/TriggerButton.d.ts +0 -23
  94. package/dist/typescript/src/lib/Components/TriggerButton/TriggerButton.d.ts.map +0 -1
  95. package/dist/typescript/src/lib/Components/TriggerButton/index.d.ts +0 -3
  96. package/dist/typescript/src/lib/Components/TriggerButton/index.d.ts.map +0 -1
  97. package/dist/typescript/src/lib/Components/TriggerButton/types.d.ts.map +0 -1
  98. package/src/lib/Components/TriggerButton/index.ts +0 -2
  99. /package/dist/module/lib/Components/{TriggerButton → MediaButton}/types.js +0 -0
@@ -0,0 +1,735 @@
1
+ "use strict";
2
+
3
+ import { CryptoIcon } from '@ledgerhq/crypto-icons';
4
+ import { useState } from 'react';
5
+ import { Settings } from "../../Symbols/index.js";
6
+ import { BottomSheet } from "../BottomSheet/index.js";
7
+ import { BottomSheetHeader } from "../BottomSheet/BottomSheetHeader.js";
8
+ import { BottomSheetScrollView, BottomSheetView } from "../BottomSheet/Scrollables.js";
9
+ import { useBottomSheetRef } from "../BottomSheet/useBottomSheetRef.js";
10
+ import { MediaButton } from "../MediaButton/index.js";
11
+ import { Spot } from "../Spot/index.js";
12
+ import { Tag } from "../Tag/Tag.js";
13
+ import { Box, Text } from "../Utility/index.js";
14
+ import { OptionList, OptionListContent, OptionListEmptyState, OptionListItem, OptionListItemLeading, OptionListItemContent, OptionListItemDescription, OptionListItemContentRow, OptionListTrigger, OptionListItemText } from "./OptionList.js";
15
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
16
+ const meta = {
17
+ component: OptionList,
18
+ title: 'Selection/OptionList',
19
+ subcomponents: {
20
+ OptionListContent,
21
+ OptionListItem,
22
+ OptionListItemLeading,
23
+ OptionListItemContent,
24
+ OptionListItemText,
25
+ OptionListItemDescription,
26
+ OptionListItemContentRow,
27
+ OptionListTrigger
28
+ },
29
+ decorators: [Story => /*#__PURE__*/_jsx("div", {
30
+ children: /*#__PURE__*/_jsx(Box, {
31
+ lx: {
32
+ flex: 1,
33
+ padding: 's24',
34
+ alignItems: 'flex-start',
35
+ width: 's320',
36
+ height: 's480'
37
+ },
38
+ children: /*#__PURE__*/_jsx(Story, {})
39
+ })
40
+ })],
41
+ parameters: {
42
+ layout: 'fullscreen',
43
+ docs: {
44
+ source: {
45
+ language: 'tsx',
46
+ format: true,
47
+ type: 'code'
48
+ }
49
+ }
50
+ }
51
+ };
52
+ export default meta;
53
+ const CURRENCIES = [{
54
+ value: 'btc',
55
+ label: 'Bitcoin',
56
+ meta: {
57
+ ticker: 'BTC',
58
+ ledgerId: 'bitcoin'
59
+ }
60
+ }, {
61
+ value: 'eth',
62
+ label: 'Ethereum',
63
+ meta: {
64
+ ticker: 'ETH',
65
+ ledgerId: 'ethereum'
66
+ }
67
+ }, {
68
+ value: 'sol',
69
+ label: 'Solana',
70
+ meta: {
71
+ ticker: 'SOL',
72
+ ledgerId: 'solana'
73
+ }
74
+ }, {
75
+ value: 'dot',
76
+ label: 'Polkadot',
77
+ meta: {
78
+ ticker: 'DOT',
79
+ ledgerId: 'polkadot'
80
+ }
81
+ }];
82
+ export const Base = {
83
+ render: () => {
84
+ const [value, setValue] = useState(null);
85
+ const bottomSheetRef = useBottomSheetRef();
86
+ const selected = CURRENCIES.find(c => c.value === value);
87
+ return /*#__PURE__*/_jsxs(_Fragment, {
88
+ children: [/*#__PURE__*/_jsx(OptionListTrigger, {
89
+ label: "Currency",
90
+ onPress: () => bottomSheetRef.current?.present(),
91
+ children: selected && /*#__PURE__*/_jsx(Text, {
92
+ lx: {
93
+ color: 'base'
94
+ },
95
+ children: selected.label
96
+ })
97
+ }), /*#__PURE__*/_jsx(BottomSheet, {
98
+ ref: bottomSheetRef,
99
+ enableDynamicSizing: true,
100
+ snapPoints: null,
101
+ onClose: () => bottomSheetRef.current?.dismiss(),
102
+ children: /*#__PURE__*/_jsxs(BottomSheetView, {
103
+ children: [/*#__PURE__*/_jsx(BottomSheetHeader, {
104
+ title: "Select currency"
105
+ }), /*#__PURE__*/_jsx(OptionList, {
106
+ items: CURRENCIES,
107
+ value: value,
108
+ onValueChange: v => {
109
+ setValue(v);
110
+ bottomSheetRef.current?.dismiss();
111
+ },
112
+ children: /*#__PURE__*/_jsx(OptionListContent, {
113
+ renderItem: item => {
114
+ const ticker = item.meta.ticker;
115
+ return /*#__PURE__*/_jsxs(OptionListItem, {
116
+ value: item.value,
117
+ children: [/*#__PURE__*/_jsx(OptionListItemLeading, {
118
+ children: /*#__PURE__*/_jsx(CryptoIcon, {
119
+ ledgerId: item.meta?.ledgerId ?? '',
120
+ ticker: ticker,
121
+ size: "32px"
122
+ })
123
+ }), /*#__PURE__*/_jsxs(OptionListItemContent, {
124
+ children: [/*#__PURE__*/_jsx(OptionListItemText, {
125
+ children: item.label
126
+ }), /*#__PURE__*/_jsx(OptionListItemDescription, {
127
+ children: ticker
128
+ })]
129
+ })]
130
+ });
131
+ }
132
+ })
133
+ })]
134
+ })
135
+ })]
136
+ });
137
+ }
138
+ };
139
+ const FOODS = [{
140
+ value: 'apple',
141
+ label: 'Apple',
142
+ group: 'Fruits'
143
+ }, {
144
+ value: 'banana',
145
+ label: 'Banana',
146
+ group: 'Fruits'
147
+ }, {
148
+ value: 'orange',
149
+ label: 'Orange',
150
+ group: 'Fruits'
151
+ }, {
152
+ value: 'carrot',
153
+ label: 'Carrot',
154
+ group: 'Vegetables'
155
+ }, {
156
+ value: 'broccoli',
157
+ label: 'Broccoli',
158
+ group: 'Vegetables'
159
+ }, {
160
+ value: 'spinach',
161
+ label: 'Spinach',
162
+ group: 'Vegetables'
163
+ }];
164
+ export const WithGroups = {
165
+ render: () => {
166
+ const [value, setValue] = useState(null);
167
+ const bottomSheetRef = useBottomSheetRef();
168
+ const selected = FOODS.find(f => f.value === value);
169
+ return /*#__PURE__*/_jsxs(_Fragment, {
170
+ children: [/*#__PURE__*/_jsx(OptionListTrigger, {
171
+ label: "Food",
172
+ onPress: () => bottomSheetRef.current?.present(),
173
+ children: selected && /*#__PURE__*/_jsx(Text, {
174
+ lx: {
175
+ color: 'base'
176
+ },
177
+ children: selected.label
178
+ })
179
+ }), /*#__PURE__*/_jsx(BottomSheet, {
180
+ ref: bottomSheetRef,
181
+ enableDynamicSizing: true,
182
+ snapPoints: null,
183
+ onClose: () => bottomSheetRef.current?.dismiss(),
184
+ children: /*#__PURE__*/_jsxs(BottomSheetScrollView, {
185
+ children: [/*#__PURE__*/_jsx(BottomSheetHeader, {
186
+ title: "Pick a food"
187
+ }), /*#__PURE__*/_jsx(OptionList, {
188
+ items: FOODS,
189
+ value: value,
190
+ onValueChange: v => {
191
+ setValue(v);
192
+ bottomSheetRef.current?.dismiss();
193
+ },
194
+ children: /*#__PURE__*/_jsx(OptionListContent, {
195
+ renderItem: item => /*#__PURE__*/_jsx(OptionListItem, {
196
+ value: item.value,
197
+ children: /*#__PURE__*/_jsx(OptionListItemContent, {
198
+ children: /*#__PURE__*/_jsx(OptionListItemText, {
199
+ children: item.label
200
+ })
201
+ })
202
+ })
203
+ })
204
+ })]
205
+ })
206
+ })]
207
+ });
208
+ }
209
+ };
210
+ const NETWORKS = [{
211
+ value: 'ethereum',
212
+ label: 'Ethereum',
213
+ meta: {
214
+ ticker: 'ETH',
215
+ ledgerId: 'ethereum',
216
+ tag: 'ERC-20'
217
+ }
218
+ }, {
219
+ value: 'polygon',
220
+ label: 'Polygon',
221
+ meta: {
222
+ ticker: 'MATIC',
223
+ ledgerId: 'polygon',
224
+ tag: 'Layer 2'
225
+ }
226
+ }, {
227
+ value: 'arbitrum',
228
+ label: 'Arbitrum',
229
+ meta: {
230
+ ticker: 'ARB',
231
+ ledgerId: 'arbitrum',
232
+ tag: 'Layer 2'
233
+ }
234
+ }, {
235
+ value: 'optimism',
236
+ label: 'Optimism',
237
+ meta: {
238
+ ticker: 'OP',
239
+ ledgerId: 'optimism',
240
+ tag: 'Layer 2'
241
+ }
242
+ }];
243
+ export const WithContentRow = {
244
+ render: () => {
245
+ const [value, setValue] = useState(null);
246
+ const bottomSheetRef = useBottomSheetRef();
247
+ const selected = NETWORKS.find(n => n.value === value);
248
+ return /*#__PURE__*/_jsxs(_Fragment, {
249
+ children: [/*#__PURE__*/_jsx(OptionListTrigger, {
250
+ label: "Network",
251
+ onPress: () => bottomSheetRef.current?.present(),
252
+ children: selected && /*#__PURE__*/_jsx(Text, {
253
+ lx: {
254
+ color: 'base'
255
+ },
256
+ children: selected.label
257
+ })
258
+ }), /*#__PURE__*/_jsx(BottomSheet, {
259
+ ref: bottomSheetRef,
260
+ enableDynamicSizing: true,
261
+ snapPoints: null,
262
+ onClose: () => bottomSheetRef.current?.dismiss(),
263
+ children: /*#__PURE__*/_jsxs(BottomSheetView, {
264
+ children: [/*#__PURE__*/_jsx(BottomSheetHeader, {
265
+ title: "Select network"
266
+ }), /*#__PURE__*/_jsx(OptionList, {
267
+ items: NETWORKS,
268
+ value: value,
269
+ onValueChange: v => {
270
+ setValue(v);
271
+ bottomSheetRef.current?.dismiss();
272
+ },
273
+ children: /*#__PURE__*/_jsx(OptionListContent, {
274
+ renderItem: item => {
275
+ const meta = item.meta;
276
+ return /*#__PURE__*/_jsxs(OptionListItem, {
277
+ value: item.value,
278
+ children: [/*#__PURE__*/_jsx(OptionListItemLeading, {
279
+ children: /*#__PURE__*/_jsx(CryptoIcon, {
280
+ ledgerId: meta.ledgerId,
281
+ ticker: meta.ticker,
282
+ size: "32px"
283
+ })
284
+ }), /*#__PURE__*/_jsxs(OptionListItemContent, {
285
+ children: [/*#__PURE__*/_jsxs(OptionListItemContentRow, {
286
+ children: [/*#__PURE__*/_jsx(OptionListItemText, {
287
+ children: item.label
288
+ }), /*#__PURE__*/_jsx(Tag, {
289
+ label: meta.tag,
290
+ appearance: "gray",
291
+ size: "sm"
292
+ })]
293
+ }), /*#__PURE__*/_jsx(OptionListItemDescription, {
294
+ children: meta.ticker
295
+ })]
296
+ })]
297
+ });
298
+ }
299
+ })
300
+ })]
301
+ })
302
+ })]
303
+ });
304
+ }
305
+ };
306
+ const ACCOUNTS = [{
307
+ value: 'savings',
308
+ label: 'Savings Account',
309
+ description: 'High-yield savings'
310
+ }, {
311
+ value: 'checking',
312
+ label: 'Checking Account',
313
+ description: 'Primary checking',
314
+ disabled: true
315
+ }, {
316
+ value: 'investment',
317
+ label: 'Investment Account'
318
+ }, {
319
+ value: 'retirement',
320
+ label: 'Retirement Fund',
321
+ description: 'Long-term growth',
322
+ disabled: true
323
+ }];
324
+ export const WithDisabledItems = {
325
+ render: () => {
326
+ const [value, setValue] = useState(null);
327
+ const bottomSheetRef = useBottomSheetRef();
328
+ const selected = ACCOUNTS.find(a => a.value === value);
329
+ return /*#__PURE__*/_jsxs(_Fragment, {
330
+ children: [/*#__PURE__*/_jsx(OptionListTrigger, {
331
+ label: "Account",
332
+ onPress: () => bottomSheetRef.current?.present(),
333
+ children: selected && /*#__PURE__*/_jsx(Text, {
334
+ lx: {
335
+ color: 'base'
336
+ },
337
+ children: selected.label
338
+ })
339
+ }), /*#__PURE__*/_jsx(BottomSheet, {
340
+ ref: bottomSheetRef,
341
+ enableDynamicSizing: true,
342
+ snapPoints: null,
343
+ onClose: () => bottomSheetRef.current?.dismiss(),
344
+ children: /*#__PURE__*/_jsxs(BottomSheetView, {
345
+ children: [/*#__PURE__*/_jsx(BottomSheetHeader, {
346
+ title: "Select account"
347
+ }), /*#__PURE__*/_jsx(OptionList, {
348
+ items: ACCOUNTS,
349
+ value: value,
350
+ onValueChange: v => {
351
+ setValue(v);
352
+ bottomSheetRef.current?.dismiss();
353
+ },
354
+ children: /*#__PURE__*/_jsx(OptionListContent, {
355
+ renderItem: item => /*#__PURE__*/_jsxs(OptionListItem, {
356
+ value: item.value,
357
+ disabled: item.disabled,
358
+ children: [/*#__PURE__*/_jsx(OptionListItemLeading, {
359
+ children: /*#__PURE__*/_jsx(Spot, {
360
+ appearance: "icon",
361
+ icon: Settings
362
+ })
363
+ }), /*#__PURE__*/_jsxs(OptionListItemContent, {
364
+ children: [/*#__PURE__*/_jsx(OptionListItemText, {
365
+ children: item.label
366
+ }), item.description && /*#__PURE__*/_jsx(OptionListItemDescription, {
367
+ children: item.description
368
+ })]
369
+ })]
370
+ })
371
+ })
372
+ })]
373
+ })
374
+ })]
375
+ });
376
+ }
377
+ };
378
+ const GROUPED_NETWORKS = [{
379
+ value: 'eth-main',
380
+ label: 'Ethereum',
381
+ group: 'Layer 1',
382
+ meta: {
383
+ ticker: 'ETH',
384
+ ledgerId: 'ethereum',
385
+ tag: 'Mainnet'
386
+ }
387
+ }, {
388
+ value: 'btc-main',
389
+ label: 'Bitcoin',
390
+ group: 'Layer 1',
391
+ meta: {
392
+ ticker: 'BTC',
393
+ ledgerId: 'bitcoin',
394
+ tag: 'Mainnet'
395
+ }
396
+ }, {
397
+ value: 'polygon',
398
+ label: 'Polygon',
399
+ group: 'Layer 2',
400
+ meta: {
401
+ ticker: 'MATIC',
402
+ ledgerId: 'polygon',
403
+ tag: 'Rollup'
404
+ }
405
+ }, {
406
+ value: 'arbitrum',
407
+ label: 'Arbitrum',
408
+ group: 'Layer 2',
409
+ meta: {
410
+ ticker: 'ARB',
411
+ ledgerId: 'arbitrum',
412
+ tag: 'Rollup'
413
+ }
414
+ }, {
415
+ value: 'optimism',
416
+ label: 'Optimism',
417
+ group: 'Layer 2',
418
+ meta: {
419
+ ticker: 'OP',
420
+ ledgerId: 'optimism',
421
+ tag: 'Rollup'
422
+ }
423
+ }];
424
+ export const GroupedWithContentRow = {
425
+ render: () => {
426
+ const [value, setValue] = useState(null);
427
+ const bottomSheetRef = useBottomSheetRef();
428
+ const selected = GROUPED_NETWORKS.find(n => n.value === value);
429
+ return /*#__PURE__*/_jsxs(_Fragment, {
430
+ children: [/*#__PURE__*/_jsx(OptionListTrigger, {
431
+ label: "Network",
432
+ onPress: () => bottomSheetRef.current?.present(),
433
+ children: selected && /*#__PURE__*/_jsx(Text, {
434
+ lx: {
435
+ color: 'base'
436
+ },
437
+ children: selected.label
438
+ })
439
+ }), /*#__PURE__*/_jsx(BottomSheet, {
440
+ ref: bottomSheetRef,
441
+ enableDynamicSizing: true,
442
+ snapPoints: null,
443
+ onClose: () => bottomSheetRef.current?.dismiss(),
444
+ children: /*#__PURE__*/_jsxs(BottomSheetScrollView, {
445
+ children: [/*#__PURE__*/_jsx(BottomSheetHeader, {
446
+ title: "Select network"
447
+ }), /*#__PURE__*/_jsx(OptionList, {
448
+ items: GROUPED_NETWORKS,
449
+ value: value,
450
+ onValueChange: v => {
451
+ setValue(v);
452
+ bottomSheetRef.current?.dismiss();
453
+ },
454
+ children: /*#__PURE__*/_jsx(OptionListContent, {
455
+ renderItem: item => {
456
+ const meta = item.meta;
457
+ return /*#__PURE__*/_jsxs(OptionListItem, {
458
+ value: item.value,
459
+ children: [/*#__PURE__*/_jsx(OptionListItemLeading, {
460
+ children: /*#__PURE__*/_jsx(CryptoIcon, {
461
+ ledgerId: meta.ledgerId,
462
+ ticker: meta.ticker,
463
+ size: "32px"
464
+ })
465
+ }), /*#__PURE__*/_jsxs(OptionListItemContent, {
466
+ children: [/*#__PURE__*/_jsxs(OptionListItemContentRow, {
467
+ children: [/*#__PURE__*/_jsx(OptionListItemText, {
468
+ children: item.label
469
+ }), /*#__PURE__*/_jsx(Tag, {
470
+ label: meta.tag,
471
+ appearance: "gray",
472
+ size: "sm"
473
+ })]
474
+ }), /*#__PURE__*/_jsx(OptionListItemDescription, {
475
+ children: meta.ticker
476
+ })]
477
+ })]
478
+ });
479
+ }
480
+ })
481
+ })]
482
+ })
483
+ })]
484
+ });
485
+ }
486
+ };
487
+ export const EmptyState = {
488
+ render: () => {
489
+ const bottomSheetRef = useBottomSheetRef();
490
+ return /*#__PURE__*/_jsxs(_Fragment, {
491
+ children: [/*#__PURE__*/_jsx(OptionListTrigger, {
492
+ label: "Currency",
493
+ onPress: () => bottomSheetRef.current?.present()
494
+ }), /*#__PURE__*/_jsx(BottomSheet, {
495
+ ref: bottomSheetRef,
496
+ enableDynamicSizing: true,
497
+ snapPoints: null,
498
+ onClose: () => bottomSheetRef.current?.dismiss(),
499
+ children: /*#__PURE__*/_jsxs(BottomSheetView, {
500
+ children: [/*#__PURE__*/_jsx(BottomSheetHeader, {
501
+ title: "Select currency"
502
+ }), /*#__PURE__*/_jsxs(OptionList, {
503
+ items: [],
504
+ value: null,
505
+ children: [/*#__PURE__*/_jsx(OptionListContent, {
506
+ renderItem: item => /*#__PURE__*/_jsx(OptionListItem, {
507
+ value: item.value,
508
+ children: /*#__PURE__*/_jsx(OptionListItemContent, {
509
+ children: /*#__PURE__*/_jsx(OptionListItemText, {
510
+ children: item.label
511
+ })
512
+ })
513
+ })
514
+ }), /*#__PURE__*/_jsx(OptionListEmptyState, {
515
+ title: "No options available",
516
+ description: "There are no items to display"
517
+ })]
518
+ })]
519
+ })
520
+ })]
521
+ });
522
+ }
523
+ };
524
+ const SIMPLE_OPTIONS = [{
525
+ value: 'all',
526
+ label: 'All accounts'
527
+ }, {
528
+ value: 'savings',
529
+ label: 'Savings'
530
+ }, {
531
+ value: 'checking',
532
+ label: 'Checking'
533
+ }];
534
+ const SETTINGS_OPTIONS = [{
535
+ value: 'general',
536
+ label: 'General'
537
+ }, {
538
+ value: 'security',
539
+ label: 'Security'
540
+ }, {
541
+ value: 'notifications',
542
+ label: 'Notifications'
543
+ }];
544
+ const appearances = ['gray', 'transparent', 'no-background'];
545
+ const SimpleOptionListSheet = ({
546
+ sheetRef,
547
+ items,
548
+ title,
549
+ value,
550
+ onValueChange
551
+ }) => /*#__PURE__*/_jsx(BottomSheet, {
552
+ ref: sheetRef,
553
+ enableDynamicSizing: true,
554
+ snapPoints: null,
555
+ onClose: () => sheetRef.current?.dismiss(),
556
+ children: /*#__PURE__*/_jsxs(BottomSheetView, {
557
+ children: [/*#__PURE__*/_jsx(BottomSheetHeader, {
558
+ title: title
559
+ }), /*#__PURE__*/_jsx(OptionList, {
560
+ items: items,
561
+ value: value,
562
+ onValueChange: v => {
563
+ onValueChange(v);
564
+ sheetRef.current?.dismiss();
565
+ },
566
+ children: /*#__PURE__*/_jsx(OptionListContent, {
567
+ renderItem: item => /*#__PURE__*/_jsx(OptionListItem, {
568
+ value: item.value,
569
+ children: /*#__PURE__*/_jsx(OptionListItemContent, {
570
+ children: /*#__PURE__*/_jsx(OptionListItemText, {
571
+ children: item.label
572
+ })
573
+ })
574
+ })
575
+ })
576
+ })]
577
+ })
578
+ });
579
+ export const TriggerShowcase = {
580
+ render: () => {
581
+ const [buttonValue, setButtonValue] = useState(null);
582
+ const [iconValue, setIconValue] = useState(null);
583
+ const [cryptoValue, setCryptoValue] = useState(null);
584
+ const [appearanceValues, setAppearanceValues] = useState({});
585
+ const buttonRef = useBottomSheetRef();
586
+ const iconRef = useBottomSheetRef();
587
+ const cryptoRef = useBottomSheetRef();
588
+ const appearanceRefs = {
589
+ gray: useBottomSheetRef(),
590
+ transparent: useBottomSheetRef(),
591
+ 'no-background': useBottomSheetRef()
592
+ };
593
+ const selectedButton = SIMPLE_OPTIONS.find(o => o.value === buttonValue);
594
+ const selectedIcon = SETTINGS_OPTIONS.find(o => o.value === iconValue);
595
+ const selectedCrypto = CURRENCIES.find(c => c.value === cryptoValue);
596
+ return /*#__PURE__*/_jsxs(Box, {
597
+ lx: {
598
+ gap: 's16',
599
+ alignItems: 'flex-start'
600
+ },
601
+ children: [/*#__PURE__*/_jsx(MediaButton, {
602
+ appearance: "gray",
603
+ onPress: () => buttonRef.current?.present(),
604
+ children: selectedButton?.label ?? 'All accounts'
605
+ }), /*#__PURE__*/_jsx(MediaButton, {
606
+ appearance: "gray",
607
+ disabled: true,
608
+ children: "Disabled"
609
+ }), /*#__PURE__*/_jsx(MediaButton, {
610
+ appearance: "gray",
611
+ onPress: () => iconRef.current?.present(),
612
+ icon: /*#__PURE__*/_jsx(Settings, {
613
+ size: 20
614
+ }),
615
+ iconType: "flat",
616
+ children: selectedIcon?.label ?? 'Settings'
617
+ }), /*#__PURE__*/_jsx(MediaButton, {
618
+ appearance: "gray",
619
+ onPress: () => cryptoRef.current?.present(),
620
+ icon: selectedCrypto?.meta ? /*#__PURE__*/_jsx(CryptoIcon, {
621
+ ledgerId: selectedCrypto.meta.ledgerId,
622
+ ticker: selectedCrypto.meta.ticker,
623
+ size: "32px"
624
+ }) : undefined,
625
+ iconType: "rounded",
626
+ children: selectedCrypto?.label ?? 'Network'
627
+ }), /*#__PURE__*/_jsx(Box, {
628
+ lx: {
629
+ flexDirection: 'row',
630
+ gap: 's16'
631
+ },
632
+ children: appearances.map(appearance => {
633
+ const selected = SIMPLE_OPTIONS.find(o => o.value === appearanceValues[appearance]);
634
+ return /*#__PURE__*/_jsx(MediaButton, {
635
+ appearance: appearance,
636
+ onPress: () => appearanceRefs[appearance].current?.present(),
637
+ children: selected?.label ?? appearance
638
+ }, appearance);
639
+ })
640
+ }), /*#__PURE__*/_jsx(SimpleOptionListSheet, {
641
+ sheetRef: buttonRef,
642
+ items: SIMPLE_OPTIONS,
643
+ title: "All accounts",
644
+ value: buttonValue,
645
+ onValueChange: setButtonValue
646
+ }), /*#__PURE__*/_jsx(SimpleOptionListSheet, {
647
+ sheetRef: iconRef,
648
+ items: SETTINGS_OPTIONS,
649
+ title: "Settings",
650
+ value: iconValue,
651
+ onValueChange: setIconValue
652
+ }), /*#__PURE__*/_jsx(BottomSheet, {
653
+ ref: cryptoRef,
654
+ enableDynamicSizing: true,
655
+ snapPoints: null,
656
+ onClose: () => cryptoRef.current?.dismiss(),
657
+ children: /*#__PURE__*/_jsxs(BottomSheetView, {
658
+ children: [/*#__PURE__*/_jsx(BottomSheetHeader, {
659
+ title: "Select network"
660
+ }), /*#__PURE__*/_jsx(OptionList, {
661
+ items: CURRENCIES,
662
+ value: cryptoValue,
663
+ onValueChange: v => {
664
+ setCryptoValue(v);
665
+ cryptoRef.current?.dismiss();
666
+ },
667
+ children: /*#__PURE__*/_jsx(OptionListContent, {
668
+ renderItem: item => {
669
+ const ticker = item.meta.ticker;
670
+ return /*#__PURE__*/_jsxs(OptionListItem, {
671
+ value: item.value,
672
+ children: [/*#__PURE__*/_jsx(OptionListItemLeading, {
673
+ children: /*#__PURE__*/_jsx(CryptoIcon, {
674
+ ledgerId: item.meta?.ledgerId ?? '',
675
+ ticker: ticker,
676
+ size: "32px"
677
+ })
678
+ }), /*#__PURE__*/_jsxs(OptionListItemContent, {
679
+ children: [/*#__PURE__*/_jsx(OptionListItemText, {
680
+ children: item.label
681
+ }), /*#__PURE__*/_jsx(OptionListItemDescription, {
682
+ children: ticker
683
+ })]
684
+ })]
685
+ });
686
+ }
687
+ })
688
+ })]
689
+ })
690
+ }), appearances.map(appearance => /*#__PURE__*/_jsx(SimpleOptionListSheet, {
691
+ sheetRef: appearanceRefs[appearance],
692
+ items: SIMPLE_OPTIONS,
693
+ title: appearance,
694
+ value: appearanceValues[appearance] ?? null,
695
+ onValueChange: v => setAppearanceValues(prev => ({
696
+ ...prev,
697
+ [appearance]: v
698
+ }))
699
+ }, appearance))]
700
+ });
701
+ }
702
+ };
703
+ export const WithDefaultValue = {
704
+ render: () => /*#__PURE__*/_jsx(Box, {
705
+ lx: {
706
+ width: 's320'
707
+ },
708
+ children: /*#__PURE__*/_jsx(OptionList, {
709
+ items: CURRENCIES,
710
+ defaultValue: "eth",
711
+ children: /*#__PURE__*/_jsx(OptionListContent, {
712
+ renderItem: item => {
713
+ const meta = item.meta;
714
+ return /*#__PURE__*/_jsxs(OptionListItem, {
715
+ value: item.value,
716
+ children: [/*#__PURE__*/_jsx(OptionListItemLeading, {
717
+ children: /*#__PURE__*/_jsx(CryptoIcon, {
718
+ ledgerId: meta.ledgerId,
719
+ ticker: meta.ticker,
720
+ size: "32px"
721
+ })
722
+ }), /*#__PURE__*/_jsxs(OptionListItemContent, {
723
+ children: [/*#__PURE__*/_jsx(OptionListItemText, {
724
+ children: item.label
725
+ }), /*#__PURE__*/_jsx(OptionListItemDescription, {
726
+ children: meta.ticker
727
+ })]
728
+ })]
729
+ });
730
+ }
731
+ })
732
+ })
733
+ })
734
+ };
735
+ //# sourceMappingURL=OptionList.stories.js.map