-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathListItemMultiSelectButton.tsx
More file actions
88 lines (82 loc) · 2.48 KB
/
ListItemMultiSelectButton.tsx
File metadata and controls
88 lines (82 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* eslint-disable react/prop-types */
// Third party dependencies.
import React from 'react';
import { TouchableOpacity, View } from 'react-native';
// External dependencies.
import { useStyles } from '../../hooks';
import ListItem from '../../../component-library/components/List/ListItem/ListItem';
// Internal dependencies.
import styleSheet from './ListItemMultiSelectButton.styles';
import { ListItemMultiSelectButtonProps } from './ListItemMultiSelectButton.types';
import {
BUTTON_TEST_ID,
DEFAULT_LISTITEMMULTISELECT_GAP,
} from './ListItemMultiSelectButton.constants';
import ButtonIcon from '../../../component-library/components/Buttons/ButtonIcon';
import {
IconColor,
IconName,
} from '../../../component-library/components/Icons/Icon';
import Button, {
ButtonSize,
ButtonVariants,
ButtonWidthTypes,
} from '../../../component-library/components/Buttons/Button';
import { TextVariant } from '../../../component-library/components/Texts/Text';
const ListItemMultiSelectButton: React.FC<ListItemMultiSelectButtonProps> = ({
style,
isSelected = false,
isDisabled = false,
children,
gap = DEFAULT_LISTITEMMULTISELECT_GAP,
showButtonIcon = true,
buttonIcon = IconName.MoreVertical,
buttonProps,
...props
}) => {
const { styles } = useStyles(styleSheet, {
style,
gap,
isDisabled,
isSelected,
});
return (
<View style={styles.container}>
<TouchableOpacity
style={styles.base}
disabled={isDisabled}
onPress={props.onPress}
onLongPress={props.onPress}
{...props}
>
<ListItem gap={gap} style={styles.containerColumn}>
{children}
</ListItem>
</TouchableOpacity>
{showButtonIcon ? (
<View style={styles.buttonIcon}>
<ButtonIcon
iconName={buttonIcon}
iconColor={IconColor.Default}
testID={buttonProps?.buttonTestId || BUTTON_TEST_ID}
onPress={buttonProps?.onButtonClick as () => void}
accessibilityRole="button"
/>
</View>
) : null}
{buttonProps?.textButton ? (
<View>
<Button
variant={ButtonVariants.Link}
onPress={buttonProps?.onButtonClick as () => void}
labelTextVariant={TextVariant.BodyMD}
size={ButtonSize.Lg}
width={ButtonWidthTypes.Auto}
label={buttonProps?.textButton}
/>
</View>
) : null}
</View>
);
};
export default ListItemMultiSelectButton;