@ledgerhq/lumen-ui-rnative 0.1.60 → 0.1.62
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/dist/module/lib/Components/core/Avatar/Avatar.js +17 -6
- package/dist/module/lib/Components/core/Avatar/Avatar.js.map +1 -1
- package/dist/module/lib/Components/core/Avatar/Avatar.mdx +10 -6
- package/dist/module/lib/Components/core/Avatar/Avatar.stories.js +15 -6
- package/dist/module/lib/Components/core/Avatar/Avatar.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Avatar/Avatar.test.js +56 -0
- package/dist/module/lib/Components/core/Avatar/Avatar.test.js.map +1 -1
- package/dist/module/lib/Components/core/Avatar/index.js +1 -1
- package/dist/module/lib/Components/core/Avatar/index.js.map +1 -1
- package/dist/module/lib/Components/core/Avatar/useResolveAvatarColor.js +21 -0
- package/dist/module/lib/Components/core/Avatar/useResolveAvatarColor.js.map +1 -0
- package/dist/module/lib/Components/core/Avatar/useResolveAvatarColor.test.js +88 -0
- package/dist/module/lib/Components/core/Avatar/useResolveAvatarColor.test.js.map +1 -0
- package/dist/module/lib/Components/core/Banner/Banner.js +3 -3
- package/dist/module/lib/Components/core/Banner/Banner.js.map +1 -1
- package/dist/module/lib/Components/core/Banner/Banner.test.js +3 -3
- package/dist/module/lib/Components/core/Banner/Banner.test.js.map +1 -1
- package/dist/module/lib/Components/core/DotIcon/DotIcon.js +0 -13
- package/dist/module/lib/Components/core/DotIcon/DotIcon.js.map +1 -1
- package/dist/module/lib/Components/core/DotIcon/DotIcon.mdx +3 -3
- package/dist/module/lib/Components/core/DotIcon/DotIcon.stories.js +14 -13
- package/dist/module/lib/Components/core/DotIcon/DotIcon.stories.js.map +1 -1
- package/dist/module/lib/Components/core/DotIcon/DotIcon.test.js +22 -0
- package/dist/module/lib/Components/core/DotIcon/DotIcon.test.js.map +1 -1
- package/dist/module/lib/Components/core/DotIcon/getDotIconProps.js +37 -0
- package/dist/module/lib/Components/core/DotIcon/getDotIconProps.js.map +1 -0
- package/dist/module/lib/Components/core/DotIcon/getDotIconProps.test.js +38 -0
- package/dist/module/lib/Components/core/DotIcon/getDotIconProps.test.js.map +1 -0
- package/dist/module/lib/Components/core/DotIcon/index.js +2 -1
- package/dist/module/lib/Components/core/DotIcon/index.js.map +1 -1
- package/dist/module/lib/Components/core/DotSymbol/DotSymbol.js +0 -19
- package/dist/module/lib/Components/core/DotSymbol/DotSymbol.js.map +1 -1
- package/dist/module/lib/Components/core/DotSymbol/DotSymbol.mdx +3 -3
- package/dist/module/lib/Components/core/DotSymbol/DotSymbol.stories.js +18 -17
- package/dist/module/lib/Components/core/DotSymbol/DotSymbol.stories.js.map +1 -1
- package/dist/module/lib/Components/core/DotSymbol/getDotSymbolProps.js +55 -0
- package/dist/module/lib/Components/core/DotSymbol/getDotSymbolProps.js.map +1 -0
- package/dist/module/lib/Components/core/DotSymbol/getDotSymbolProps.test.js +56 -0
- package/dist/module/lib/Components/core/DotSymbol/getDotSymbolProps.test.js.map +1 -0
- package/dist/module/lib/Components/core/DotSymbol/index.js +2 -1
- package/dist/module/lib/Components/core/DotSymbol/index.js.map +1 -1
- package/dist/module/lib/Components/core/MediaButton/MediaButton.js +2 -2
- package/dist/module/lib/Components/core/MediaButton/MediaButton.mdx +2 -2
- package/dist/module/lib/Components/core/MenuList/MenuList.figma.js +21 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.figma.js.map +1 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.js +143 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.js.map +1 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.mdx +66 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.stories.js +139 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.stories.js.map +1 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.test.js +146 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.test.js.map +1 -0
- package/dist/module/lib/Components/core/MenuList/index.js +5 -0
- package/dist/module/lib/Components/core/MenuList/index.js.map +1 -0
- package/dist/module/lib/Components/core/MenuList/types.js.map +1 -0
- package/dist/module/lib/Components/core/SelectList/SelectList.figma.js +28 -0
- package/dist/module/lib/Components/core/{OptionList/OptionList.figma.js.map → SelectList/SelectList.figma.js.map} +1 -1
- package/dist/module/lib/Components/core/{OptionList/OptionList.js → SelectList/SelectList.js} +46 -46
- package/dist/module/lib/Components/core/{OptionList/OptionList.js.map → SelectList/SelectList.js.map} +1 -1
- package/dist/module/lib/Components/core/{OptionList/OptionList.mdx → SelectList/SelectList.mdx} +81 -81
- package/dist/module/lib/Components/core/{OptionList/OptionList.stories.js → SelectList/SelectList.stories.js} +130 -130
- package/dist/module/lib/Components/core/{OptionList/OptionList.stories.js.map → SelectList/SelectList.stories.js.map} +1 -1
- package/dist/module/lib/Components/core/{OptionList/OptionList.test.js → SelectList/SelectList.test.js} +83 -83
- package/dist/module/lib/Components/core/{OptionList/OptionList.test.js.map → SelectList/SelectList.test.js.map} +1 -1
- package/dist/module/lib/Components/core/SelectList/index.js +5 -0
- package/dist/module/lib/Components/core/{OptionList → SelectList}/index.js.map +1 -1
- package/dist/module/lib/Components/core/SelectList/types.js +4 -0
- package/dist/module/lib/Components/core/{OptionList → SelectList}/types.js.map +1 -1
- package/dist/module/lib/Components/core/{OptionList/useOptionList/useOptionListItems.js → SelectList/useSelectList/useSelectListItems.js} +2 -2
- package/dist/module/lib/Components/core/{OptionList/useOptionList/useOptionListItems.js.map → SelectList/useSelectList/useSelectListItems.js.map} +1 -1
- package/dist/module/lib/Components/core/{OptionList/useOptionList/useOptionListItems.test.js → SelectList/useSelectList/useSelectListItems.test.js} +17 -17
- package/dist/module/lib/Components/core/{OptionList/useOptionList/useOptionListItems.test.js.map → SelectList/useSelectList/useSelectListItems.test.js.map} +1 -1
- package/dist/module/lib/Components/core/index.js +2 -1
- package/dist/module/lib/Components/core/index.js.map +1 -1
- package/dist/module/lib/Components/internal/BaseButton/BaseButton.js +2 -2
- package/dist/module/lib/Components/internal/BaseButton/BaseButton.js.map +1 -1
- package/dist/module/lib/Components/internal/BaseInput/BaseInputLabel.js +2 -2
- package/dist/module/lib/Components/internal/BaseInput/BaseInputLabel.js.map +1 -1
- package/dist/module/lib/Components/internal/BaseTag/BaseTag.js +3 -3
- package/dist/module/lib/Components/internal/BaseTag/BaseTag.js.map +1 -1
- package/dist/module/lib/Components/internal/BaseTag/BaseTag.test.js +1 -1
- package/dist/module/lib/Components/internal/BaseTag/BaseTag.test.js.map +1 -1
- package/dist/module/lib/Components/symbols/Icon/Icon.test.js +1 -1
- package/dist/module/lib/Components/symbols/icons/CloudSync.js +50 -0
- package/dist/module/lib/Components/symbols/icons/CloudSync.js.map +1 -0
- package/dist/module/lib/Components/symbols/icons/Dollar.js +11 -5
- package/dist/module/lib/Components/symbols/icons/Dollar.js.map +1 -1
- package/dist/module/lib/Components/symbols/icons/DollarConvert.js +1 -1
- package/dist/module/lib/Components/symbols/icons/DollarConvert.js.map +1 -1
- package/dist/module/lib/Components/symbols/icons/DollarFill.js +47 -0
- package/dist/module/lib/Components/symbols/icons/DollarFill.js.map +1 -0
- package/dist/module/lib/Components/symbols/icons/FaceId.js +50 -0
- package/dist/module/lib/Components/symbols/icons/FaceId.js.map +1 -0
- package/dist/module/lib/Components/symbols/icons/Fingerprint.js +50 -0
- package/dist/module/lib/Components/symbols/icons/Fingerprint.js.map +1 -0
- package/dist/module/lib/Components/symbols/icons/Pause.js +2 -1
- package/dist/module/lib/Components/symbols/icons/Pause.js.map +1 -1
- package/dist/module/lib/Components/symbols/icons/Range.js +2 -5
- package/dist/module/lib/Components/symbols/icons/Range.js.map +1 -1
- package/dist/module/lib/Components/symbols/icons/Telegram.js +20 -9
- package/dist/module/lib/Components/symbols/icons/Telegram.js.map +1 -1
- package/dist/module/lib/Components/symbols/icons/Usb.js +1 -1
- package/dist/module/lib/Components/symbols/index.js +4 -0
- package/dist/module/lib/Components/symbols/index.js.map +1 -1
- package/dist/typescript/src/lib/Components/core/Avatar/Avatar.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Avatar/index.d.ts +1 -1
- package/dist/typescript/src/lib/Components/core/Avatar/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Avatar/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/core/Avatar/useResolveAvatarColor.d.ts +10 -0
- package/dist/typescript/src/lib/Components/core/Avatar/useResolveAvatarColor.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/DotIcon/DotIcon.d.ts +0 -13
- package/dist/typescript/src/lib/Components/core/DotIcon/DotIcon.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/DotIcon/getDotIconProps.d.ts +66 -0
- package/dist/typescript/src/lib/Components/core/DotIcon/getDotIconProps.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/DotIcon/index.d.ts +2 -1
- package/dist/typescript/src/lib/Components/core/DotIcon/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/DotSymbol/DotSymbol.d.ts +1 -5
- package/dist/typescript/src/lib/Components/core/DotSymbol/DotSymbol.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/DotSymbol/getDotSymbolProps.d.ts +102 -0
- package/dist/typescript/src/lib/Components/core/DotSymbol/getDotSymbolProps.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/DotSymbol/index.d.ts +2 -1
- package/dist/typescript/src/lib/Components/core/DotSymbol/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/MediaButton/MediaButton.d.ts +2 -2
- package/dist/typescript/src/lib/Components/core/MenuList/MenuList.d.ts +29 -0
- package/dist/typescript/src/lib/Components/core/MenuList/MenuList.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/MenuList/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/core/MenuList/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/MenuList/types.d.ts +42 -0
- package/dist/typescript/src/lib/Components/core/MenuList/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/SelectList/SelectList.d.ts +27 -0
- package/dist/typescript/src/lib/Components/core/{OptionList/OptionList.d.ts.map → SelectList/SelectList.d.ts.map} +1 -1
- package/dist/typescript/src/lib/Components/core/SelectList/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/core/{OptionList → SelectList}/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/{OptionList → SelectList}/types.d.ts +24 -24
- package/dist/typescript/src/lib/Components/core/{OptionList → SelectList}/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/SelectList/useSelectList/useSelectListItems.d.ts +20 -0
- package/dist/typescript/src/lib/Components/core/{OptionList/useOptionList/useOptionListItems.d.ts.map → SelectList/useSelectList/useSelectListItems.d.ts.map} +1 -1
- package/dist/typescript/src/lib/Components/core/index.d.ts +2 -1
- package/dist/typescript/src/lib/Components/core/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/internal/BaseInput/BaseInputLabel.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/symbols/icons/CloudSync.d.ts +35 -0
- package/dist/typescript/src/lib/Components/symbols/icons/CloudSync.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/symbols/icons/Dollar.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/symbols/icons/DollarFill.d.ts +35 -0
- package/dist/typescript/src/lib/Components/symbols/icons/DollarFill.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/symbols/icons/FaceId.d.ts +35 -0
- package/dist/typescript/src/lib/Components/symbols/icons/FaceId.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/symbols/icons/Fingerprint.d.ts +35 -0
- package/dist/typescript/src/lib/Components/symbols/icons/Fingerprint.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/symbols/icons/Pause.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/symbols/icons/Range.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/symbols/icons/Telegram.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/symbols/index.d.ts +4 -0
- package/dist/typescript/src/lib/Components/symbols/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/Components/core/Avatar/Avatar.mdx +10 -6
- package/src/lib/Components/core/Avatar/Avatar.stories.tsx +16 -9
- package/src/lib/Components/core/Avatar/Avatar.test.tsx +64 -0
- package/src/lib/Components/core/Avatar/Avatar.tsx +41 -8
- package/src/lib/Components/core/Avatar/index.ts +1 -1
- package/src/lib/Components/core/Avatar/types.ts +1 -1
- package/src/lib/Components/core/Avatar/useResolveAvatarColor.test.tsx +106 -0
- package/src/lib/Components/core/Avatar/useResolveAvatarColor.ts +25 -0
- package/src/lib/Components/core/Banner/Banner.test.tsx +3 -3
- package/src/lib/Components/core/Banner/Banner.tsx +3 -3
- package/src/lib/Components/core/DotIcon/DotIcon.mdx +3 -3
- package/src/lib/Components/core/DotIcon/DotIcon.stories.tsx +14 -13
- package/src/lib/Components/core/DotIcon/DotIcon.test.tsx +20 -0
- package/src/lib/Components/core/DotIcon/DotIcon.tsx +0 -15
- package/src/lib/Components/core/DotIcon/getDotIconProps.test.ts +19 -0
- package/src/lib/Components/core/DotIcon/getDotIconProps.ts +20 -0
- package/src/lib/Components/core/DotIcon/index.ts +2 -5
- package/src/lib/Components/core/DotSymbol/DotSymbol.mdx +3 -3
- package/src/lib/Components/core/DotSymbol/DotSymbol.stories.tsx +18 -17
- package/src/lib/Components/core/DotSymbol/DotSymbol.tsx +0 -23
- package/src/lib/Components/core/DotSymbol/getDotSymbolProps.test.ts +25 -0
- package/src/lib/Components/core/DotSymbol/getDotSymbolProps.ts +26 -0
- package/src/lib/Components/core/DotSymbol/index.ts +2 -1
- package/src/lib/Components/core/MediaButton/MediaButton.mdx +2 -2
- package/src/lib/Components/core/MediaButton/MediaButton.tsx +2 -2
- package/src/lib/Components/core/MenuList/MenuList.figma.tsx +23 -0
- package/src/lib/Components/core/MenuList/MenuList.mdx +66 -0
- package/src/lib/Components/core/MenuList/MenuList.stories.tsx +114 -0
- package/src/lib/Components/core/MenuList/MenuList.test.tsx +135 -0
- package/src/lib/Components/core/MenuList/MenuList.tsx +162 -0
- package/src/lib/Components/core/MenuList/index.ts +2 -0
- package/src/lib/Components/core/MenuList/types.ts +49 -0
- package/src/lib/Components/core/SelectList/SelectList.figma.tsx +37 -0
- package/src/lib/Components/core/{OptionList/OptionList.mdx → SelectList/SelectList.mdx} +81 -81
- package/src/lib/Components/core/{OptionList/OptionList.stories.tsx → SelectList/SelectList.stories.tsx} +227 -227
- package/src/lib/Components/core/{OptionList/OptionList.test.tsx → SelectList/SelectList.test.tsx} +138 -138
- package/src/lib/Components/core/{OptionList/OptionList.tsx → SelectList/SelectList.tsx} +92 -92
- package/src/lib/Components/core/SelectList/index.ts +2 -0
- package/src/lib/Components/core/{OptionList → SelectList}/types.ts +28 -28
- package/src/lib/Components/core/{OptionList/useOptionList/useOptionListItems.test.ts → SelectList/useSelectList/useSelectListItems.test.ts} +24 -24
- package/src/lib/Components/core/{OptionList/useOptionList/useOptionListItems.ts → SelectList/useSelectList/useSelectListItems.ts} +21 -21
- package/src/lib/Components/core/Spot/Spot.tsx +1 -1
- package/src/lib/Components/core/index.ts +2 -1
- package/src/lib/Components/internal/BaseButton/BaseButton.tsx +2 -2
- package/src/lib/Components/internal/BaseInput/BaseInputLabel.tsx +5 -2
- package/src/lib/Components/internal/BaseTag/BaseTag.test.tsx +3 -3
- package/src/lib/Components/internal/BaseTag/BaseTag.tsx +3 -3
- package/src/lib/Components/symbols/Icon/Icon.test.tsx +1 -1
- package/src/lib/Components/symbols/icons/CloudSync.tsx +45 -0
- package/src/lib/Components/symbols/icons/Dollar.tsx +8 -1
- package/src/lib/Components/symbols/icons/DollarConvert.tsx +1 -1
- package/src/lib/Components/symbols/icons/DollarFill.tsx +42 -0
- package/src/lib/Components/symbols/icons/FaceId.tsx +45 -0
- package/src/lib/Components/symbols/icons/Fingerprint.tsx +45 -0
- package/src/lib/Components/symbols/icons/Pause.tsx +2 -1
- package/src/lib/Components/symbols/icons/Range.tsx +2 -5
- package/src/lib/Components/symbols/icons/Telegram.tsx +14 -7
- package/src/lib/Components/symbols/icons/Usb.tsx +1 -1
- package/src/lib/Components/symbols/index.ts +4 -0
- package/dist/module/lib/Components/core/Avatar/resolveAvatarColor.js +0 -18
- package/dist/module/lib/Components/core/Avatar/resolveAvatarColor.js.map +0 -1
- package/dist/module/lib/Components/core/OptionList/OptionList.figma.js +0 -28
- package/dist/module/lib/Components/core/OptionList/index.js +0 -5
- package/dist/typescript/src/lib/Components/core/Avatar/resolveAvatarColor.d.ts +0 -8
- package/dist/typescript/src/lib/Components/core/Avatar/resolveAvatarColor.d.ts.map +0 -1
- package/dist/typescript/src/lib/Components/core/OptionList/OptionList.d.ts +0 -27
- package/dist/typescript/src/lib/Components/core/OptionList/index.d.ts +0 -3
- package/dist/typescript/src/lib/Components/core/OptionList/useOptionList/useOptionListItems.d.ts +0 -20
- package/src/lib/Components/core/Avatar/resolveAvatarColor.ts +0 -19
- package/src/lib/Components/core/OptionList/OptionList.figma.tsx +0 -37
- package/src/lib/Components/core/OptionList/index.ts +0 -2
- /package/dist/module/lib/Components/core/{OptionList → MenuList}/types.js +0 -0
package/src/lib/Components/core/{OptionList/OptionList.test.tsx → SelectList/SelectList.test.tsx}
RENAMED
|
@@ -4,20 +4,20 @@ import { render, fireEvent } from '@testing-library/react-native';
|
|
|
4
4
|
import { Text } from 'react-native';
|
|
5
5
|
import { ThemeProvider } from '../ThemeProvider/ThemeProvider';
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from './
|
|
20
|
-
import type {
|
|
7
|
+
SelectList,
|
|
8
|
+
SelectListContent,
|
|
9
|
+
SelectListItem,
|
|
10
|
+
SelectListItemContent,
|
|
11
|
+
SelectListItemContentRow,
|
|
12
|
+
SelectListItemLeading,
|
|
13
|
+
SelectListItemText,
|
|
14
|
+
SelectListItemDescription,
|
|
15
|
+
SelectListEmptyState,
|
|
16
|
+
SelectListSearch,
|
|
17
|
+
SelectListTrigger,
|
|
18
|
+
createSelectList,
|
|
19
|
+
} from './SelectList';
|
|
20
|
+
import type { SelectListItemData } from './types';
|
|
21
21
|
|
|
22
22
|
const TestWrapper = ({ children }: { children: React.ReactNode }) => (
|
|
23
23
|
<ThemeProvider themes={ledgerLiveThemes} colorScheme='dark' locale='en'>
|
|
@@ -25,26 +25,26 @@ const TestWrapper = ({ children }: { children: React.ReactNode }) => (
|
|
|
25
25
|
</ThemeProvider>
|
|
26
26
|
);
|
|
27
27
|
|
|
28
|
-
const ITEMS:
|
|
28
|
+
const ITEMS: SelectListItemData[] = [
|
|
29
29
|
{ value: 'a', label: 'Alpha' },
|
|
30
30
|
{ value: 'b', label: 'Beta' },
|
|
31
31
|
{ value: 'c', label: 'Gamma' },
|
|
32
32
|
];
|
|
33
33
|
|
|
34
|
-
const GROUPED_ITEMS:
|
|
34
|
+
const GROUPED_ITEMS: SelectListItemData[] = [
|
|
35
35
|
{ value: 'apple', label: 'Apple', group: 'Fruits' },
|
|
36
36
|
{ value: 'banana', label: 'Banana', group: 'Fruits' },
|
|
37
37
|
{ value: 'carrot', label: 'Carrot', group: 'Vegetables' },
|
|
38
38
|
];
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const renderSelectList = ({
|
|
41
41
|
items = ITEMS,
|
|
42
42
|
value,
|
|
43
43
|
defaultValue,
|
|
44
44
|
onValueChange,
|
|
45
45
|
disabled,
|
|
46
46
|
}: {
|
|
47
|
-
items?:
|
|
47
|
+
items?: SelectListItemData[];
|
|
48
48
|
value?: string | null;
|
|
49
49
|
defaultValue?: string | null;
|
|
50
50
|
onValueChange?: (v: string | null) => void;
|
|
@@ -52,29 +52,29 @@ const renderOptionList = ({
|
|
|
52
52
|
} = {}) =>
|
|
53
53
|
render(
|
|
54
54
|
<TestWrapper>
|
|
55
|
-
<
|
|
55
|
+
<SelectList
|
|
56
56
|
items={items}
|
|
57
57
|
value={value}
|
|
58
58
|
defaultValue={defaultValue}
|
|
59
59
|
onValueChange={onValueChange}
|
|
60
60
|
disabled={disabled}
|
|
61
61
|
>
|
|
62
|
-
<
|
|
62
|
+
<SelectListContent
|
|
63
63
|
renderItem={(item) => (
|
|
64
|
-
<
|
|
65
|
-
<
|
|
66
|
-
<
|
|
67
|
-
</
|
|
68
|
-
</
|
|
64
|
+
<SelectListItem value={item.value} disabled={item.disabled}>
|
|
65
|
+
<SelectListItemContent>
|
|
66
|
+
<SelectListItemText>{item.label}</SelectListItemText>
|
|
67
|
+
</SelectListItemContent>
|
|
68
|
+
</SelectListItem>
|
|
69
69
|
)}
|
|
70
70
|
/>
|
|
71
|
-
</
|
|
71
|
+
</SelectList>
|
|
72
72
|
</TestWrapper>,
|
|
73
73
|
);
|
|
74
74
|
|
|
75
|
-
describe('
|
|
75
|
+
describe('SelectList', () => {
|
|
76
76
|
it('renders all items', () => {
|
|
77
|
-
const { getByText } =
|
|
77
|
+
const { getByText } = renderSelectList();
|
|
78
78
|
|
|
79
79
|
expect(getByText('Alpha')).toBeTruthy();
|
|
80
80
|
expect(getByText('Beta')).toBeTruthy();
|
|
@@ -83,7 +83,7 @@ describe('OptionList', () => {
|
|
|
83
83
|
|
|
84
84
|
it('calls onValueChange when an item is pressed', () => {
|
|
85
85
|
const onValueChange = jest.fn();
|
|
86
|
-
const { getByText } =
|
|
86
|
+
const { getByText } = renderSelectList({ onValueChange });
|
|
87
87
|
|
|
88
88
|
fireEvent.press(getByText('Beta'));
|
|
89
89
|
|
|
@@ -91,7 +91,7 @@ describe('OptionList', () => {
|
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
it('marks the selected item with accessibilityState', () => {
|
|
94
|
-
const { getAllByRole } =
|
|
94
|
+
const { getAllByRole } = renderSelectList({ value: 'a' });
|
|
95
95
|
|
|
96
96
|
const items = getAllByRole('radio');
|
|
97
97
|
const selectedItem = items.find(
|
|
@@ -103,7 +103,7 @@ describe('OptionList', () => {
|
|
|
103
103
|
|
|
104
104
|
it('updates selection on press (uncontrolled)', () => {
|
|
105
105
|
const onValueChange = jest.fn();
|
|
106
|
-
const { getByText } =
|
|
106
|
+
const { getByText } = renderSelectList({
|
|
107
107
|
defaultValue: 'a',
|
|
108
108
|
onValueChange,
|
|
109
109
|
});
|
|
@@ -115,12 +115,12 @@ describe('OptionList', () => {
|
|
|
115
115
|
|
|
116
116
|
it('does not fire onValueChange when disabled item is pressed', () => {
|
|
117
117
|
const onValueChange = jest.fn();
|
|
118
|
-
const items:
|
|
118
|
+
const items: SelectListItemData[] = [
|
|
119
119
|
{ value: 'a', label: 'Enabled' },
|
|
120
120
|
{ value: 'b', label: 'Disabled', disabled: true },
|
|
121
121
|
];
|
|
122
122
|
|
|
123
|
-
const { getByText } =
|
|
123
|
+
const { getByText } = renderSelectList({ items, onValueChange });
|
|
124
124
|
|
|
125
125
|
fireEvent.press(getByText('Disabled'));
|
|
126
126
|
|
|
@@ -128,7 +128,7 @@ describe('OptionList', () => {
|
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
it('renders group labels for grouped items', () => {
|
|
131
|
-
const { getByText } =
|
|
131
|
+
const { getByText } = renderSelectList({ items: GROUPED_ITEMS });
|
|
132
132
|
|
|
133
133
|
expect(getByText('Fruits')).toBeTruthy();
|
|
134
134
|
expect(getByText('Vegetables')).toBeTruthy();
|
|
@@ -138,7 +138,7 @@ describe('OptionList', () => {
|
|
|
138
138
|
|
|
139
139
|
it('passes selected state to renderItem', () => {
|
|
140
140
|
const renderItem = jest.fn(
|
|
141
|
-
(item:
|
|
141
|
+
(item: SelectListItemData, selected: boolean) => (
|
|
142
142
|
<Text testID={`item-${item.value}`}>
|
|
143
143
|
{item.label} {selected ? 'selected' : ''}
|
|
144
144
|
</Text>
|
|
@@ -147,15 +147,15 @@ describe('OptionList', () => {
|
|
|
147
147
|
|
|
148
148
|
render(
|
|
149
149
|
<TestWrapper>
|
|
150
|
-
<
|
|
150
|
+
<SelectList
|
|
151
151
|
items={[
|
|
152
152
|
{ value: 'a', label: 'A' },
|
|
153
153
|
{ value: 'b', label: 'B', disabled: true },
|
|
154
154
|
]}
|
|
155
155
|
value='a'
|
|
156
156
|
>
|
|
157
|
-
<
|
|
158
|
-
</
|
|
157
|
+
<SelectListContent renderItem={renderItem} />
|
|
158
|
+
</SelectList>
|
|
159
159
|
</TestWrapper>,
|
|
160
160
|
);
|
|
161
161
|
|
|
@@ -172,30 +172,30 @@ describe('OptionList', () => {
|
|
|
172
172
|
it('renders description sub-component', () => {
|
|
173
173
|
const { getByText } = render(
|
|
174
174
|
<TestWrapper>
|
|
175
|
-
<
|
|
176
|
-
<
|
|
175
|
+
<SelectList items={ITEMS} value={null}>
|
|
176
|
+
<SelectListContent
|
|
177
177
|
renderItem={(item) => (
|
|
178
|
-
<
|
|
179
|
-
<
|
|
180
|
-
<
|
|
181
|
-
<
|
|
178
|
+
<SelectListItem value={item.value}>
|
|
179
|
+
<SelectListItemContent>
|
|
180
|
+
<SelectListItemText>{item.label}</SelectListItemText>
|
|
181
|
+
<SelectListItemDescription>
|
|
182
182
|
Description for {item.label}
|
|
183
|
-
</
|
|
184
|
-
</
|
|
185
|
-
</
|
|
183
|
+
</SelectListItemDescription>
|
|
184
|
+
</SelectListItemContent>
|
|
185
|
+
</SelectListItem>
|
|
186
186
|
)}
|
|
187
187
|
/>
|
|
188
|
-
</
|
|
188
|
+
</SelectList>
|
|
189
189
|
</TestWrapper>,
|
|
190
190
|
);
|
|
191
191
|
|
|
192
192
|
expect(getByText('Description for Alpha')).toBeTruthy();
|
|
193
193
|
});
|
|
194
194
|
|
|
195
|
-
describe('
|
|
196
|
-
it('prevents all items from being pressed when
|
|
195
|
+
describe('SelectList-level disabled', () => {
|
|
196
|
+
it('prevents all items from being pressed when SelectList is disabled', () => {
|
|
197
197
|
const onValueChange = jest.fn();
|
|
198
|
-
const { getByText } =
|
|
198
|
+
const { getByText } = renderSelectList({
|
|
199
199
|
disabled: true,
|
|
200
200
|
onValueChange,
|
|
201
201
|
});
|
|
@@ -207,7 +207,7 @@ describe('OptionList', () => {
|
|
|
207
207
|
});
|
|
208
208
|
|
|
209
209
|
it('sets disabled accessibilityState on all items', () => {
|
|
210
|
-
const { getAllByRole } =
|
|
210
|
+
const { getAllByRole } = renderSelectList({ disabled: true });
|
|
211
211
|
|
|
212
212
|
const items = getAllByRole('radio');
|
|
213
213
|
for (const item of items) {
|
|
@@ -216,24 +216,24 @@ describe('OptionList', () => {
|
|
|
216
216
|
});
|
|
217
217
|
});
|
|
218
218
|
|
|
219
|
-
describe('
|
|
219
|
+
describe('SelectListItemLeading', () => {
|
|
220
220
|
it('renders leading content beside item text', () => {
|
|
221
221
|
const { getByTestId, getByText } = render(
|
|
222
222
|
<TestWrapper>
|
|
223
|
-
<
|
|
224
|
-
<
|
|
223
|
+
<SelectList items={ITEMS} value={null}>
|
|
224
|
+
<SelectListContent
|
|
225
225
|
renderItem={(item) => (
|
|
226
|
-
<
|
|
227
|
-
<
|
|
226
|
+
<SelectListItem value={item.value}>
|
|
227
|
+
<SelectListItemLeading>
|
|
228
228
|
<Text testID={`leading-${item.value}`}>icon</Text>
|
|
229
|
-
</
|
|
230
|
-
<
|
|
231
|
-
<
|
|
232
|
-
</
|
|
233
|
-
</
|
|
229
|
+
</SelectListItemLeading>
|
|
230
|
+
<SelectListItemContent>
|
|
231
|
+
<SelectListItemText>{item.label}</SelectListItemText>
|
|
232
|
+
</SelectListItemContent>
|
|
233
|
+
</SelectListItem>
|
|
234
234
|
)}
|
|
235
235
|
/>
|
|
236
|
-
</
|
|
236
|
+
</SelectList>
|
|
237
237
|
</TestWrapper>,
|
|
238
238
|
);
|
|
239
239
|
|
|
@@ -242,26 +242,26 @@ describe('OptionList', () => {
|
|
|
242
242
|
});
|
|
243
243
|
});
|
|
244
244
|
|
|
245
|
-
describe('
|
|
245
|
+
describe('SelectListItemContentRow', () => {
|
|
246
246
|
it('renders children in a row layout', () => {
|
|
247
|
-
const singleItem:
|
|
247
|
+
const singleItem: SelectListItemData[] = [{ value: 'a', label: 'Alpha' }];
|
|
248
248
|
|
|
249
249
|
const { getByText } = render(
|
|
250
250
|
<TestWrapper>
|
|
251
|
-
<
|
|
252
|
-
<
|
|
251
|
+
<SelectList items={singleItem} value={null}>
|
|
252
|
+
<SelectListContent
|
|
253
253
|
renderItem={(item) => (
|
|
254
|
-
<
|
|
255
|
-
<
|
|
256
|
-
<
|
|
257
|
-
<
|
|
254
|
+
<SelectListItem value={item.value}>
|
|
255
|
+
<SelectListItemContent>
|
|
256
|
+
<SelectListItemContentRow>
|
|
257
|
+
<SelectListItemText>{item.label}</SelectListItemText>
|
|
258
258
|
<Text>tag</Text>
|
|
259
|
-
</
|
|
260
|
-
</
|
|
261
|
-
</
|
|
259
|
+
</SelectListItemContentRow>
|
|
260
|
+
</SelectListItemContent>
|
|
261
|
+
</SelectListItem>
|
|
262
262
|
)}
|
|
263
263
|
/>
|
|
264
|
-
</
|
|
264
|
+
</SelectList>
|
|
265
265
|
</TestWrapper>,
|
|
266
266
|
);
|
|
267
267
|
|
|
@@ -270,14 +270,14 @@ describe('OptionList', () => {
|
|
|
270
270
|
});
|
|
271
271
|
});
|
|
272
272
|
|
|
273
|
-
describe('
|
|
273
|
+
describe('SelectListEmptyState', () => {
|
|
274
274
|
it('renders title when item list is empty', () => {
|
|
275
275
|
const { getByText } = render(
|
|
276
276
|
<TestWrapper>
|
|
277
|
-
<
|
|
278
|
-
<
|
|
279
|
-
<
|
|
280
|
-
</
|
|
277
|
+
<SelectList items={[]} value={null}>
|
|
278
|
+
<SelectListContent renderItem={() => null} />
|
|
279
|
+
<SelectListEmptyState title='No results' />
|
|
280
|
+
</SelectList>
|
|
281
281
|
</TestWrapper>,
|
|
282
282
|
);
|
|
283
283
|
|
|
@@ -287,13 +287,13 @@ describe('OptionList', () => {
|
|
|
287
287
|
it('renders description when provided', () => {
|
|
288
288
|
const { getByText } = render(
|
|
289
289
|
<TestWrapper>
|
|
290
|
-
<
|
|
291
|
-
<
|
|
292
|
-
<
|
|
290
|
+
<SelectList items={[]} value={null}>
|
|
291
|
+
<SelectListContent renderItem={() => null} />
|
|
292
|
+
<SelectListEmptyState
|
|
293
293
|
title='No results'
|
|
294
294
|
description='Try a different search'
|
|
295
295
|
/>
|
|
296
|
-
</
|
|
296
|
+
</SelectList>
|
|
297
297
|
</TestWrapper>,
|
|
298
298
|
);
|
|
299
299
|
|
|
@@ -304,18 +304,18 @@ describe('OptionList', () => {
|
|
|
304
304
|
it('does not render when items are present', () => {
|
|
305
305
|
const { queryByText } = render(
|
|
306
306
|
<TestWrapper>
|
|
307
|
-
<
|
|
308
|
-
<
|
|
307
|
+
<SelectList items={ITEMS} value={null}>
|
|
308
|
+
<SelectListContent
|
|
309
309
|
renderItem={(item) => (
|
|
310
|
-
<
|
|
311
|
-
<
|
|
312
|
-
<
|
|
313
|
-
</
|
|
314
|
-
</
|
|
310
|
+
<SelectListItem value={item.value}>
|
|
311
|
+
<SelectListItemContent>
|
|
312
|
+
<SelectListItemText>{item.label}</SelectListItemText>
|
|
313
|
+
</SelectListItemContent>
|
|
314
|
+
</SelectListItem>
|
|
315
315
|
)}
|
|
316
316
|
/>
|
|
317
|
-
<
|
|
318
|
-
</
|
|
317
|
+
<SelectListEmptyState title='No results' />
|
|
318
|
+
</SelectList>
|
|
319
319
|
</TestWrapper>,
|
|
320
320
|
);
|
|
321
321
|
|
|
@@ -323,7 +323,7 @@ describe('OptionList', () => {
|
|
|
323
323
|
});
|
|
324
324
|
});
|
|
325
325
|
|
|
326
|
-
describe('
|
|
326
|
+
describe('SelectListSearch', () => {
|
|
327
327
|
const renderSearchable = ({
|
|
328
328
|
items = ITEMS,
|
|
329
329
|
filter,
|
|
@@ -331,33 +331,33 @@ describe('OptionList', () => {
|
|
|
331
331
|
searchValue,
|
|
332
332
|
onSearchValueChange,
|
|
333
333
|
}: {
|
|
334
|
-
items?:
|
|
335
|
-
filter?: null | ((item:
|
|
336
|
-
filteredItems?:
|
|
334
|
+
items?: SelectListItemData[];
|
|
335
|
+
filter?: null | ((item: SelectListItemData, query: string) => boolean);
|
|
336
|
+
filteredItems?: SelectListItemData[];
|
|
337
337
|
searchValue?: string;
|
|
338
338
|
onSearchValueChange?: (v: string) => void;
|
|
339
339
|
} = {}) =>
|
|
340
340
|
render(
|
|
341
341
|
<TestWrapper>
|
|
342
|
-
<
|
|
342
|
+
<SelectList
|
|
343
343
|
items={items}
|
|
344
344
|
filter={filter}
|
|
345
345
|
filteredItems={filteredItems}
|
|
346
346
|
searchValue={searchValue}
|
|
347
347
|
onSearchValueChange={onSearchValueChange}
|
|
348
348
|
>
|
|
349
|
-
<
|
|
350
|
-
<
|
|
349
|
+
<SelectListSearch placeholder='Search' />
|
|
350
|
+
<SelectListContent
|
|
351
351
|
renderItem={(item) => (
|
|
352
|
-
<
|
|
353
|
-
<
|
|
354
|
-
<
|
|
355
|
-
</
|
|
356
|
-
</
|
|
352
|
+
<SelectListItem value={item.value}>
|
|
353
|
+
<SelectListItemContent>
|
|
354
|
+
<SelectListItemText>{item.label}</SelectListItemText>
|
|
355
|
+
</SelectListItemContent>
|
|
356
|
+
</SelectListItem>
|
|
357
357
|
)}
|
|
358
358
|
/>
|
|
359
|
-
<
|
|
360
|
-
</
|
|
359
|
+
<SelectListEmptyState title='No results' />
|
|
360
|
+
</SelectList>
|
|
361
361
|
</TestWrapper>,
|
|
362
362
|
);
|
|
363
363
|
|
|
@@ -389,7 +389,7 @@ describe('OptionList', () => {
|
|
|
389
389
|
});
|
|
390
390
|
|
|
391
391
|
it('uses a custom filter when provided', () => {
|
|
392
|
-
const filter = (item:
|
|
392
|
+
const filter = (item: SelectListItemData, query: string): boolean =>
|
|
393
393
|
item.value.startsWith(query);
|
|
394
394
|
|
|
395
395
|
const { getByPlaceholderText, getByText, queryByText } = renderSearchable(
|
|
@@ -465,14 +465,14 @@ describe('OptionList', () => {
|
|
|
465
465
|
});
|
|
466
466
|
});
|
|
467
467
|
|
|
468
|
-
describe('
|
|
468
|
+
describe('SelectListTrigger', () => {
|
|
469
469
|
it('calls onPress when pressed', () => {
|
|
470
470
|
const onPress = jest.fn();
|
|
471
471
|
const { getByRole } = render(
|
|
472
472
|
<TestWrapper>
|
|
473
|
-
<
|
|
474
|
-
<
|
|
475
|
-
</
|
|
473
|
+
<SelectList items={ITEMS} value={null}>
|
|
474
|
+
<SelectListTrigger label='Choose' onPress={onPress} />
|
|
475
|
+
</SelectList>
|
|
476
476
|
</TestWrapper>,
|
|
477
477
|
);
|
|
478
478
|
|
|
@@ -484,9 +484,9 @@ describe('OptionList', () => {
|
|
|
484
484
|
it('renders the label text', () => {
|
|
485
485
|
const { getByText } = render(
|
|
486
486
|
<TestWrapper>
|
|
487
|
-
<
|
|
488
|
-
<
|
|
489
|
-
</
|
|
487
|
+
<SelectList items={ITEMS} value={null}>
|
|
488
|
+
<SelectListTrigger label='Pick a value' onPress={jest.fn()} />
|
|
489
|
+
</SelectList>
|
|
490
490
|
</TestWrapper>,
|
|
491
491
|
);
|
|
492
492
|
|
|
@@ -496,11 +496,11 @@ describe('OptionList', () => {
|
|
|
496
496
|
it('renders children as selected value content', () => {
|
|
497
497
|
const { getByText } = render(
|
|
498
498
|
<TestWrapper>
|
|
499
|
-
<
|
|
500
|
-
<
|
|
499
|
+
<SelectList items={ITEMS} value='a'>
|
|
500
|
+
<SelectListTrigger label='Currency' onPress={jest.fn()}>
|
|
501
501
|
<Text>Alpha</Text>
|
|
502
|
-
</
|
|
503
|
-
</
|
|
502
|
+
</SelectListTrigger>
|
|
503
|
+
</SelectList>
|
|
504
504
|
</TestWrapper>,
|
|
505
505
|
);
|
|
506
506
|
|
|
@@ -512,9 +512,9 @@ describe('OptionList', () => {
|
|
|
512
512
|
const onPress = jest.fn();
|
|
513
513
|
const { getByRole } = render(
|
|
514
514
|
<TestWrapper>
|
|
515
|
-
<
|
|
516
|
-
<
|
|
517
|
-
</
|
|
515
|
+
<SelectList items={ITEMS} value={null}>
|
|
516
|
+
<SelectListTrigger label='Choose' onPress={onPress} disabled />
|
|
517
|
+
</SelectList>
|
|
518
518
|
</TestWrapper>,
|
|
519
519
|
);
|
|
520
520
|
|
|
@@ -523,13 +523,13 @@ describe('OptionList', () => {
|
|
|
523
523
|
expect(onPress).not.toHaveBeenCalled();
|
|
524
524
|
});
|
|
525
525
|
|
|
526
|
-
it('inherits disabled from
|
|
526
|
+
it('inherits disabled from SelectList', () => {
|
|
527
527
|
const onPress = jest.fn();
|
|
528
528
|
const { getByRole } = render(
|
|
529
529
|
<TestWrapper>
|
|
530
|
-
<
|
|
531
|
-
<
|
|
532
|
-
</
|
|
530
|
+
<SelectList items={ITEMS} value={null} disabled>
|
|
531
|
+
<SelectListTrigger label='Choose' onPress={onPress} />
|
|
532
|
+
</SelectList>
|
|
533
533
|
</TestWrapper>,
|
|
534
534
|
);
|
|
535
535
|
|
|
@@ -541,11 +541,11 @@ describe('OptionList', () => {
|
|
|
541
541
|
it('renders without a label', () => {
|
|
542
542
|
const { getByRole, queryByText } = render(
|
|
543
543
|
<TestWrapper>
|
|
544
|
-
<
|
|
545
|
-
<
|
|
544
|
+
<SelectList items={ITEMS} value={null}>
|
|
545
|
+
<SelectListTrigger onPress={jest.fn()}>
|
|
546
546
|
<Text>Selected value</Text>
|
|
547
|
-
</
|
|
548
|
-
</
|
|
547
|
+
</SelectListTrigger>
|
|
548
|
+
</SelectList>
|
|
549
549
|
</TestWrapper>,
|
|
550
550
|
);
|
|
551
551
|
|
|
@@ -554,21 +554,21 @@ describe('OptionList', () => {
|
|
|
554
554
|
});
|
|
555
555
|
});
|
|
556
556
|
|
|
557
|
-
describe('
|
|
557
|
+
describe('createSelectList', () => {
|
|
558
558
|
it('returns typed components that render and select', () => {
|
|
559
559
|
type Value = 'a' | 'b' | 'c';
|
|
560
|
-
const typedItems:
|
|
560
|
+
const typedItems: SelectListItemData<Value>[] = [
|
|
561
561
|
{ value: 'a', label: 'Alpha' },
|
|
562
562
|
{ value: 'b', label: 'Beta' },
|
|
563
563
|
{ value: 'c', label: 'Gamma' },
|
|
564
564
|
];
|
|
565
565
|
const {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
} =
|
|
566
|
+
SelectList: TypedList,
|
|
567
|
+
SelectListContent: TypedContent,
|
|
568
|
+
SelectListItem: TypedItem,
|
|
569
|
+
SelectListItemContent: TypedItemContent,
|
|
570
|
+
SelectListItemText: TypedItemText,
|
|
571
|
+
} = createSelectList<Value>();
|
|
572
572
|
const onValueChange = jest.fn();
|
|
573
573
|
|
|
574
574
|
const { getByText } = render(
|