dhre-ui-kit 0.0.68 → 0.0.71
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 +2 -1
- package/src/assets/images/uploadFileIcon.svg +12 -0
- package/src/assets/index.ts +2 -0
- package/src/components/customDocumentPicker/CustomDocumentPicker.interface.ts +9 -0
- package/src/components/customDocumentPicker/CustomDocumentPicker.styles.ts +23 -0
- package/src/components/customDocumentPicker/CustomDocumentPicker.tsx +78 -0
- package/src/components/customDocumentPicker/index.ts +1 -0
- package/src/index.ts +1 -2
- package/src/theme/themes.ts +18 -1
- package/src/utils/appEnum.ts +4 -0
- package/src/components/toast/ToastProvider.tsx +0 -61
- package/src/components/toast/typings.ts +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dhre-ui-kit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.71",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"react-native-blob-util": "^0.19.11",
|
|
33
33
|
"react-native-calendars": "^1.1306.0",
|
|
34
34
|
"react-native-country-picker-modal": "^2.0.0",
|
|
35
|
+
"react-native-document-picker": "^9.3.1",
|
|
35
36
|
"react-native-element-dropdown": "^2.12.1",
|
|
36
37
|
"react-native-gesture-handler": "2.17.0",
|
|
37
38
|
"react-native-otp-verify": "^1.1.8",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g clip-path="url(#clip0_489_41808)">
|
|
3
|
+
<path d="M12 14V3.5" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4
|
+
<path d="M20.25 14V20H3.75V14" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
<path d="M8.25 7.25L12 3.5L15.75 7.25" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
|
|
6
|
+
</g>
|
|
7
|
+
<defs>
|
|
8
|
+
<clipPath id="clip0_489_41808">
|
|
9
|
+
<rect width="24" height="24" fill="white" transform="translate(0 0.5)"/>
|
|
10
|
+
</clipPath>
|
|
11
|
+
</defs>
|
|
12
|
+
</svg>
|
package/src/assets/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import HeaderIcon from './images/dotsThreeVertical.svg';
|
|
|
8
8
|
import CircleTick from './images/circleTick.svg';
|
|
9
9
|
import ArrowLeft from './images/arrowLeft.svg';
|
|
10
10
|
import BellSimple from './images/bellSimple.svg';
|
|
11
|
+
import UploadFile from './images/uploadFileIcon.svg';
|
|
11
12
|
|
|
12
13
|
export {
|
|
13
14
|
CalenderDots,
|
|
@@ -20,4 +21,5 @@ export {
|
|
|
20
21
|
CircleTick,
|
|
21
22
|
ArrowLeft,
|
|
22
23
|
BellSimple,
|
|
24
|
+
UploadFile,
|
|
23
25
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {DocumentPickerResponse} from 'react-native-document-picker';
|
|
2
|
+
|
|
3
|
+
export interface CustomDocumentPickerProps {
|
|
4
|
+
onDocumentUpload: (document: DocumentPickerResponse) => void;
|
|
5
|
+
title?: string;
|
|
6
|
+
hint?: string;
|
|
7
|
+
maxFileSize?: number;
|
|
8
|
+
fileTypes?: string[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {
|
|
3
|
+
verticalScale,
|
|
4
|
+
horizontalScale,
|
|
5
|
+
moderateScale,
|
|
6
|
+
} from '../../utils/stylehelper';
|
|
7
|
+
|
|
8
|
+
const styles = StyleSheet.create({
|
|
9
|
+
container: {
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
paddingVertical: verticalScale(16),
|
|
13
|
+
paddingHorizontal: horizontalScale(24),
|
|
14
|
+
borderWidth: 1,
|
|
15
|
+
borderStyle: 'dashed',
|
|
16
|
+
borderRadius: moderateScale(8),
|
|
17
|
+
gap: moderateScale(24),
|
|
18
|
+
marginBottom: verticalScale(8),
|
|
19
|
+
},
|
|
20
|
+
titleContainer: {gap: verticalScale(4)},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export default styles;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React, {useState} from 'react';
|
|
2
|
+
import {View, Pressable, Alert} from 'react-native';
|
|
3
|
+
import DocumentPicker from 'react-native-document-picker';
|
|
4
|
+
import {UploadFile} from '../../assets';
|
|
5
|
+
import {FontStyle} from '../../utils/appEnum';
|
|
6
|
+
import CustomTypography from '../customTypography';
|
|
7
|
+
import {useTheme} from '../../theme/ThemeContext';
|
|
8
|
+
import styles from './CustomDocumentPicker.styles';
|
|
9
|
+
import {CustomDocumentPickerProps} from './CustomDocumentPicker.interface';
|
|
10
|
+
|
|
11
|
+
const CustomDocumentPicker = ({
|
|
12
|
+
onDocumentUpload,
|
|
13
|
+
title = 'Upload Images/Videos',
|
|
14
|
+
hint = 'PNG, JPEG (max size. 4MB)',
|
|
15
|
+
maxFileSize = 4,
|
|
16
|
+
fileTypes = [DocumentPicker.types.images, DocumentPicker.types.pdf],
|
|
17
|
+
}: CustomDocumentPickerProps) => {
|
|
18
|
+
const [error, setError] = useState('');
|
|
19
|
+
|
|
20
|
+
const pickDocument = async () => {
|
|
21
|
+
try {
|
|
22
|
+
const res = await DocumentPicker.pickSingle({
|
|
23
|
+
type: fileTypes,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (res?.size && res?.size > maxFileSize * 1024 * 1024) {
|
|
27
|
+
setError(
|
|
28
|
+
`File size higher than ${maxFileSize}MB. Please upload a smaller file.`,
|
|
29
|
+
);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
onDocumentUpload(res);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
if (DocumentPicker.isCancel(err)) {
|
|
35
|
+
Alert.alert('User canceled the picker');
|
|
36
|
+
} else if (err instanceof Error) {
|
|
37
|
+
Alert.alert('Unknown Error: ' + err.message);
|
|
38
|
+
} else {
|
|
39
|
+
Alert.alert('Unknown Error: ' + JSON.stringify(err));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const {theme} = useTheme();
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
<Pressable
|
|
48
|
+
style={[
|
|
49
|
+
styles.container,
|
|
50
|
+
{borderColor: error ? theme.ERROR : theme.BORDER_SECONDRY},
|
|
51
|
+
]}
|
|
52
|
+
onPress={pickDocument}>
|
|
53
|
+
<UploadFile />
|
|
54
|
+
<View style={styles.titleContainer}>
|
|
55
|
+
<CustomTypography
|
|
56
|
+
variant={FontStyle.L2_REGULAR}
|
|
57
|
+
text={title}
|
|
58
|
+
style={{color: theme.CONTENT_PRIMARY}}
|
|
59
|
+
/>
|
|
60
|
+
<CustomTypography
|
|
61
|
+
variant={FontStyle.L3_REGULAR}
|
|
62
|
+
text={hint}
|
|
63
|
+
style={{color: theme.CONTENT_SECONDRY}}
|
|
64
|
+
/>
|
|
65
|
+
</View>
|
|
66
|
+
</Pressable>
|
|
67
|
+
{error && (
|
|
68
|
+
<CustomTypography
|
|
69
|
+
variant={FontStyle.L2_REGULAR}
|
|
70
|
+
text={error}
|
|
71
|
+
style={{color: theme.ERROR}}
|
|
72
|
+
/>
|
|
73
|
+
)}
|
|
74
|
+
</>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export default CustomDocumentPicker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default} from './CustomDocumentPicker';
|
package/src/index.ts
CHANGED
|
@@ -39,6 +39,7 @@ 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
41
|
export {default as SingleSelectionTags} from './components/singleSelectionTag';
|
|
42
|
+
export {default as CustomDocumentPicker} from './components/customDocumentPicker';
|
|
42
43
|
export {FONT_STYLES} from './theme/fonts';
|
|
43
44
|
export {FontStyle, Theme} from './utils/appEnum';
|
|
44
45
|
|
|
@@ -52,6 +53,4 @@ export {
|
|
|
52
53
|
export {copyToClipboard} from './utils/deviceUtils';
|
|
53
54
|
|
|
54
55
|
export {default} from './theme/themes';
|
|
55
|
-
export {useToast} from './components/toast/ToastProvider';
|
|
56
|
-
export {default as ToastProvider} from './components/toast/ToastProvider';
|
|
57
56
|
export {default as CustomTextTest} from '../__mocks__/custom-text.mock';
|
package/src/theme/themes.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {Theme} from '../utils/appEnum';
|
|
|
3
3
|
const theme = {
|
|
4
4
|
[Theme.SURFACE_PRIMARY]: {
|
|
5
5
|
light: '#FFFFFF',
|
|
6
|
-
dark: '#
|
|
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;
|
package/src/utils/appEnum.ts
CHANGED
|
@@ -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
|
-
}
|