dhre-ui-kit 0.0.67 → 0.0.68
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/package.json
CHANGED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {View, Text, Pressable, FlatList, StyleSheet} from 'react-native';
|
|
3
|
+
|
|
4
|
+
interface Tag {
|
|
5
|
+
value: string;
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface TagsComponentProps {
|
|
10
|
+
tagList: Tag[];
|
|
11
|
+
selectedTag: string; // Allow null for unselected state
|
|
12
|
+
setSelectedTag: (val: string) => void; // Allow null for unselected state
|
|
13
|
+
handleTagPress?: (val: string) => void | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const TagsComponent: React.FC<TagsComponentProps> = ({
|
|
17
|
+
tagList,
|
|
18
|
+
selectedTag,
|
|
19
|
+
handleTagPress,
|
|
20
|
+
}) => {
|
|
21
|
+
const reorderedTags = (): Tag[] => {
|
|
22
|
+
if (selectedTag) {
|
|
23
|
+
return [
|
|
24
|
+
tagList.find(tag => tag.name === selectedTag)!,
|
|
25
|
+
...tagList.filter(tag => tag.name !== selectedTag),
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
return tagList;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const renderTagItem = ({item}: {item: Tag}) => (
|
|
32
|
+
<Pressable
|
|
33
|
+
onPress={() => handleTagPress?.(item.name)}
|
|
34
|
+
style={[
|
|
35
|
+
styles.tagButton,
|
|
36
|
+
selectedTag === item?.name
|
|
37
|
+
? styles.selectedTagButton
|
|
38
|
+
: styles.unselectedTagButton,
|
|
39
|
+
]}>
|
|
40
|
+
<Text
|
|
41
|
+
style={[
|
|
42
|
+
styles.tagText,
|
|
43
|
+
selectedTag === item?.name
|
|
44
|
+
? styles.selectedTagText
|
|
45
|
+
: styles.unselectedTagText,
|
|
46
|
+
]}>
|
|
47
|
+
{item?.name}
|
|
48
|
+
</Text>
|
|
49
|
+
{selectedTag === item?.name && <Text style={styles.closeButton}>✕</Text>}
|
|
50
|
+
</Pressable>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<View>
|
|
55
|
+
<FlatList
|
|
56
|
+
data={reorderedTags()}
|
|
57
|
+
renderItem={renderTagItem}
|
|
58
|
+
keyExtractor={item => item?.name}
|
|
59
|
+
horizontal
|
|
60
|
+
showsHorizontalScrollIndicator={false}
|
|
61
|
+
contentContainerStyle={styles.listContainer}
|
|
62
|
+
/>
|
|
63
|
+
</View>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const styles = StyleSheet.create({
|
|
68
|
+
listContainer: {
|
|
69
|
+
paddingHorizontal: 10,
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
},
|
|
72
|
+
tagButton: {
|
|
73
|
+
flexDirection: 'row',
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
paddingVertical: 8,
|
|
76
|
+
paddingHorizontal: 12,
|
|
77
|
+
borderRadius: 20,
|
|
78
|
+
marginHorizontal: 8,
|
|
79
|
+
borderWidth: 1,
|
|
80
|
+
},
|
|
81
|
+
selectedTagButton: {
|
|
82
|
+
backgroundColor: '#FFF',
|
|
83
|
+
borderColor: '#000',
|
|
84
|
+
},
|
|
85
|
+
unselectedTagButton: {
|
|
86
|
+
backgroundColor: 'transparent',
|
|
87
|
+
borderColor: '#888',
|
|
88
|
+
},
|
|
89
|
+
tagText: {
|
|
90
|
+
fontSize: 16,
|
|
91
|
+
},
|
|
92
|
+
selectedTagText: {
|
|
93
|
+
color: '#000',
|
|
94
|
+
},
|
|
95
|
+
unselectedTagText: {
|
|
96
|
+
color: '#888',
|
|
97
|
+
},
|
|
98
|
+
closeButton: {
|
|
99
|
+
marginLeft: 10,
|
|
100
|
+
fontSize: 18,
|
|
101
|
+
color: '#000',
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export default TagsComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default} from './TagSingleSelection';
|
package/src/index.ts
CHANGED
|
@@ -38,6 +38,7 @@ export {default as TextInput} from './components/textInput';
|
|
|
38
38
|
export {default as DropDown} from './components/dropDown';
|
|
39
39
|
export {default as CustomSwitchBtn} from './components/customSwitchBtn';
|
|
40
40
|
export {default as toastService} from './components/toast/ToastService';
|
|
41
|
+
export {default as SingleSelectionTags} from './components/singleSelectionTag';
|
|
41
42
|
export {FONT_STYLES} from './theme/fonts';
|
|
42
43
|
export {FontStyle, Theme} from './utils/appEnum';
|
|
43
44
|
|