dhre-ui-kit 0.0.67 → 0.0.70

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dhre-ui-kit",
3
- "version": "0.0.67",
3
+ "version": "0.0.70",
4
4
  "main": "src/index.ts",
5
5
  "files": [
6
6
  "src",
@@ -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
 
@@ -51,6 +52,4 @@ export {
51
52
  export {copyToClipboard} from './utils/deviceUtils';
52
53
 
53
54
  export {default} from './theme/themes';
54
- export {useToast} from './components/toast/ToastProvider';
55
- export {default as ToastProvider} from './components/toast/ToastProvider';
56
55
  export {default as CustomTextTest} from '../__mocks__/custom-text.mock';
@@ -3,7 +3,7 @@ import {Theme} from '../utils/appEnum';
3
3
  const theme = {
4
4
  [Theme.SURFACE_PRIMARY]: {
5
5
  light: '#FFFFFF',
6
- dark: '#404040',
6
+ dark: '#000000',
7
7
  },
8
8
  [Theme.SURFACE_SECONDARY]: {
9
9
  light: '#F5F5F5',
@@ -87,6 +87,23 @@ const theme = {
87
87
  light: '#282828',
88
88
  dark: '#FFFFFF',
89
89
  },
90
+
91
+ [Theme.WARNING]: {
92
+ light: '#B65E01',
93
+ dark: '#EB8425',
94
+ },
95
+ [Theme.SUCCESS]: {
96
+ light: '#008256',
97
+ dark: '#00B578',
98
+ },
99
+ [Theme.INFO]: {
100
+ light: '#0569C2',
101
+ dark: '#339ECF',
102
+ },
103
+ [Theme.ERROR]: {
104
+ light: '#EB0542',
105
+ dark: '#EB0542',
106
+ },
90
107
  };
91
108
 
92
109
  export default theme;
@@ -95,4 +95,8 @@ export enum Theme {
95
95
  BORDER_BRAND_TRANSPARENT_STATIC = 'BORDER_BRAND_TRANSPARENT_STATIC',
96
96
  BORDER_STATIC = 'BORDER_STATIC',
97
97
  BORDER_SEPRATOR = 'BORDER_SEPRATOR',
98
+ WARNING = 'WARNING',
99
+ SUCCESS = 'SUCCESS',
100
+ INFO = 'INFO',
101
+ ERROR = 'ERROR',
98
102
  }
@@ -1,61 +0,0 @@
1
- import React, {
2
- createContext,
3
- useRef,
4
- useImperativeHandle,
5
- useContext,
6
- forwardRef,
7
- } from 'react';
8
- import Toast from './Toast';
9
- import {ShowToast, ToastRef} from './Toast.interface';
10
-
11
- const ToastContext = createContext<{showToast: ShowToast} | undefined>(
12
- undefined,
13
- );
14
-
15
- const ToastProvider = forwardRef<ToastRef, React.PropsWithChildren<object>>(
16
- (props, ref) => {
17
- const toastRef = useRef<ToastRef>(null);
18
-
19
- useImperativeHandle(ref, () => ({
20
- showToast: (message, duration, isSuccess, btnText, onBtnPress) => {
21
- toastRef.current?.showToast(
22
- message,
23
- duration,
24
- isSuccess,
25
- btnText,
26
- onBtnPress,
27
- );
28
- },
29
- }));
30
-
31
- return (
32
- <ToastContext.Provider
33
- value={{
34
- showToast: (message, duration, isSuccess, btnText, onBtnPress) => {
35
- toastRef.current?.showToast(
36
- message,
37
- duration,
38
- isSuccess,
39
- btnText,
40
- onBtnPress,
41
- );
42
- },
43
- }}>
44
- {props.children}
45
- <Toast ref={toastRef} />
46
- </ToastContext.Provider>
47
- );
48
- },
49
- );
50
-
51
- ToastProvider.displayName = 'ToastProvider';
52
-
53
- export const useToast = () => {
54
- const context = useContext(ToastContext);
55
- if (!context) {
56
- throw new Error('useToast must be used within a ToastProvider');
57
- }
58
- return context;
59
- };
60
-
61
- export default ToastProvider;
@@ -1,17 +0,0 @@
1
- import type React from 'react';
2
-
3
- export type ShowToast = (text: string, duration?: number) => void;
4
-
5
- export type Provider = React.FunctionComponent & {
6
- ref: ToastRef | null;
7
- };
8
-
9
- export type RegisterRef = (ref: ToastRef) => void;
10
-
11
- export interface ToastRef {
12
- showToast: ShowToast;
13
- }
14
-
15
- export interface ToastProps {
16
- ref: (ref: ToastRef) => void;
17
- }