@jescon-technologies/react-native-ui-kit 0.0.13 → 0.0.15

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.
Files changed (35) hide show
  1. package/index.d.ts +11 -5
  2. package/index.js +11 -5
  3. package/package.json +1 -1
  4. package/src/Common/Global.ts +10 -0
  5. package/src/Common/NetworkServiceCall.ts +1 -1
  6. package/src/CommonStyle/ComponentFunctions.tsx +1 -23
  7. package/src/Custom/CSliderMenu.tsx +10 -0
  8. package/src/Custom/OUserView.tsx +10 -0
  9. package/src/CustomComponents/CBackHandler.tsx +1 -1
  10. package/src/CustomComponents/CContainerView.tsx +38 -0
  11. package/src/CustomComponents/CDetailView.tsx +235 -0
  12. package/src/CustomComponents/CFooterView.tsx +86 -0
  13. package/src/CustomComponents/CNetworkStatus.tsx +172 -0
  14. package/src/CustomComponents/COverlay.tsx +110 -0
  15. package/src/CustomComponents/HeaderBlock.tsx +772 -0
  16. package/src/Handlers/NotificationsContext.tsx +7 -0
  17. package/src/Handlers/ResponseComponentContext.tsx +56 -0
  18. package/src/Hoc/HDashboard.tsx +1064 -0
  19. package/src/Hoc/HIcons.tsx +48 -56
  20. package/src/Hoc/HShadowButton.tsx +101 -0
  21. package/src/Hoc/HView.tsx +33 -0
  22. package/src/Navigation/PageNavigation.tsx +189 -0
  23. package/src/Navigation/useFocusEffect.ts +1 -1
  24. package/src/Navigation/useFocusEffect.web.ts +1 -1
  25. package/src/Navigation/useIsFocused.ts +1 -1
  26. package/src/Navigation/useIsFocused.web.ts +1 -1
  27. package/src/Navigation/useNavigation.ts +1 -1
  28. package/src/Navigation/useNavigation.web.ts +1 -1
  29. package/src/StaticComponents/SDateTimePicker.tsx +503 -0
  30. package/src/StaticComponents/SSearchBar.tsx +118 -0
  31. package/src/Custom/Loader.js +0 -182
  32. package/src/Layout/LoginLayout.tsx +0 -711
  33. package/src/Screens/ForgotPassword.tsx +0 -342
  34. package/src/Screens/Login.tsx +0 -331
  35. package/src/Screens/Splash.tsx +0 -782
@@ -15,69 +15,60 @@ import AntDesignI from 'react-native-vector-icons/AntDesign';
15
15
 
16
16
  import type { IconProps } from 'react-native-vector-icons/Icon';
17
17
 
18
- /**
19
- * Shared icon props type
20
- */
21
18
  type Props = IconProps;
22
19
 
23
- /**
24
- * Wrapper components (typed)
25
- */
26
- export const MaterialCommunityIcons: React.FC<Props> = (props) => (
27
- <MaterialCommunityIconsI {...props} />
28
- );
29
-
30
- export const SimpleLineIcons: React.FC<Props> = (props) => (
31
- <SimpleLineIconsI {...props} />
32
- );
33
-
34
- export const MaterialIcons: React.FC<Props> = (props) => (
35
- <MaterialIconsI {...props} />
36
- );
37
-
38
- export const FontAwesome: React.FC<Props> = (props) => (
39
- <FontAwesomeI {...props} />
40
- );
41
-
42
- export const Foundation: React.FC<Props> = (props) => (
43
- <FoundationI {...props} />
44
- );
45
-
46
- export const EvilIcons: React.FC<Props> = (props) => (
47
- <EvilIconsI {...props} />
48
- );
49
-
50
- export const Ionicons: React.FC<Props> = (props) => (
51
- <IoniconsI {...props} />
52
- );
53
-
54
- export const Octicons: React.FC<Props> = (props) => (
55
- <OcticonsI {...props} />
56
- );
57
-
58
- export const Feather: React.FC<Props> = (props) => (
59
- <FeatherI {...props} />
60
- );
20
+ export interface IconsProps extends Props {
21
+ icongroup?: number | null;
22
+ }
23
+
24
+ // Wrappers (kept, but note: declare BEFORE the map)
25
+ export const MaterialCommunityIcons: React.FC<Props> = (p) => <MaterialCommunityIconsI {...p} />;
26
+ export const SimpleLineIcons: React.FC<Props> = (p) => <SimpleLineIconsI {...p} />;
27
+ export const MaterialIcons: React.FC<Props> = (p) => <MaterialIconsI {...p} />;
28
+ export const FontAwesome: React.FC<Props> = (p) => <FontAwesomeI {...p} />;
29
+ export const Foundation: React.FC<Props> = (p) => <FoundationI {...p} />;
30
+ export const EvilIcons: React.FC<Props> = (p) => <EvilIconsI {...p} />;
31
+ export const Ionicons: React.FC<Props> = (p) => <IoniconsI {...p} />;
32
+ export const Octicons: React.FC<Props> = (p) => <OcticonsI {...p} />;
33
+ export const Feather: React.FC<Props> = (p) => <FeatherI {...p} />;
34
+ export const Entypo: React.FC<Props> = (p) => <EntypoI {...p} />;
35
+ export const Zocial: React.FC<Props> = (p) => <ZocialI {...p} />;
36
+ export const FontAwesome5: React.FC<Props> = (p) => <FontAwesome5I {...p} />;
37
+ export const AntDesign: React.FC<Props> = (p) => <AntDesignI {...p} />;
38
+
39
+ // If you actually need Fontisto, add:
40
+ // import FontistoI from 'react-native-vector-icons/Fontisto';
41
+ // export const Fontisto: React.FC<Props> = (p) => <FontistoI {...p} />;
42
+
43
+ const components: Record<number, React.ComponentType<Props>> = {
44
+ 1: AntDesign,
45
+ 2: MaterialIcons,
46
+ 3: MaterialCommunityIcons,
47
+ 4: FontAwesome,
48
+ 5: FontAwesome5,
49
+ 6: Foundation,
50
+ 7: EvilIcons,
51
+ 8: Ionicons,
52
+ 9: Octicons,
53
+ 10: Feather,
54
+ 11: Entypo,
55
+ 12: Zocial,
56
+ 14: SimpleLineIcons,
57
+ };
61
58
 
62
- export const Entypo: React.FC<Props> = (props) => (
63
- <EntypoI {...props} />
64
- );
59
+ const DEFAULT_ICON_GROUP = 5;
65
60
 
66
- export const Zocial: React.FC<Props> = (props) => (
67
- <ZocialI {...props} />
68
- );
61
+ function Icons({ icongroup, ...rest }: IconsProps): React.ReactElement {
62
+ const group =
63
+ typeof icongroup === 'number' && Number.isInteger(icongroup) && icongroup >= 1 && icongroup in components
64
+ ? icongroup
65
+ : DEFAULT_ICON_GROUP;
69
66
 
70
- export const FontAwesome5: React.FC<Props> = (props) => (
71
- <FontAwesome5I {...props} />
72
- );
67
+ const IconComponent = components[group] ?? components[DEFAULT_ICON_GROUP];
73
68
 
74
- export const AntDesign: React.FC<Props> = (props) => (
75
- <AntDesignI {...props} />
76
- );
69
+ return <IconComponent {...rest} />;
70
+ }
77
71
 
78
- /**
79
- * Default export object (same usage style as your JS version)
80
- */
81
72
  const HIcons = {
82
73
  MaterialCommunityIcons,
83
74
  SimpleLineIcons,
@@ -92,6 +83,7 @@ const HIcons = {
92
83
  Zocial,
93
84
  FontAwesome5,
94
85
  AntDesign,
86
+ Icons,
95
87
  };
96
88
 
97
89
  export default HIcons;
@@ -0,0 +1,101 @@
1
+ import { StyleProp, Text, TextStyle, TouchableOpacity, ViewStyle } from 'react-native';
2
+ import { isBNU, isNU, isNUQ, normalize } from '../CommonStyle/ComponentFunctions';
3
+ import HIcons from './HIcons';
4
+ import { Global } from '../Common/Global';
5
+ import React from 'react';
6
+
7
+ // ---------------------------------------------------------------------------
8
+ // Types
9
+ // ---------------------------------------------------------------------------
10
+
11
+ export interface HShadowButtonProps {
12
+ /** Disables the button when true. */
13
+ disabled?: boolean;
14
+ /** Invoked on press. Receives `true` when pressed. */
15
+ buttonCallback?: (pressed: boolean) => void;
16
+ /** Outer button (TouchableOpacity) style. */
17
+ buttonstyle?: StyleProp<ViewStyle>;
18
+
19
+ /** Render the leading icon when true. */
20
+ useicon?: boolean;
21
+ /** Icon group index (e.g. FontAwesome vs MaterialIcons). Defaults to 5. */
22
+ icongroup?: number;
23
+ /** Icon name string. Defaults to 'file-alt'. */
24
+ iconname?: string;
25
+ /** Icon color. Defaults to `Global.AppTheme.primary_color`. */
26
+ iconcolor?: string;
27
+ /** Icon size. Defaults to `normalize(15)`. */
28
+ iconsize?: number;
29
+ /** Extra icon container style. */
30
+ iconstyle?: StyleProp<ViewStyle>;
31
+
32
+ /** Render the label when true. */
33
+ usetext?: boolean;
34
+ /** Label text. */
35
+ displaytext?: string;
36
+ /** Text style. Defaults provided in component. */
37
+ textstyle?: StyleProp<TextStyle>;
38
+ /** Max lines for the label. Defaults to 1. */
39
+ numberOfLines?: number;
40
+ }
41
+
42
+ // ---------------------------------------------------------------------------
43
+ // Component
44
+ // ---------------------------------------------------------------------------
45
+
46
+ export default function HShadowButton(props: HShadowButtonProps): React.ReactElement {
47
+ const {
48
+ disabled,
49
+ buttonCallback,
50
+ buttonstyle,
51
+ useicon,
52
+ icongroup,
53
+ iconname,
54
+ iconcolor,
55
+ iconsize,
56
+ iconstyle,
57
+ usetext,
58
+ displaytext,
59
+ textstyle,
60
+ numberOfLines,
61
+ } = props;
62
+
63
+ return (
64
+ <TouchableOpacity
65
+ disabled={!!disabled}
66
+ onPress={() => {
67
+ if (isNU(buttonCallback)) {
68
+ buttonCallback!(true);
69
+ }
70
+ }}
71
+ style={isNU(buttonstyle) ? buttonstyle : {}}
72
+ >
73
+ {useicon ? (
74
+ <HIcons.Icons
75
+ icongroup={isNU(icongroup) ? icongroup : 5}
76
+ name={isBNU(iconname) ? iconname : 'file-alt'}
77
+ color={isNU(iconcolor) ? iconcolor : Global.AppTheme.primary_color}
78
+ size={isNU(iconsize) ? iconsize : normalize(15)}
79
+ style={iconstyle ? iconstyle : {}}
80
+ />
81
+ ) : null}
82
+ {usetext ? (
83
+ <Text
84
+ numberOfLines={numberOfLines || 1}
85
+ adjustsFontSizeToFit={true}
86
+ style={
87
+ textstyle
88
+ ? textstyle
89
+ : {
90
+ color: Global.AppTheme.primary_color,
91
+ fontSize: normalize(6),
92
+ textAlign: 'center',
93
+ }
94
+ }
95
+ >
96
+ {isNUQ(displaytext) ? displaytext : null}
97
+ </Text>
98
+ ) : null}
99
+ </TouchableOpacity>
100
+ );
101
+ }
@@ -0,0 +1,33 @@
1
+ import React, { createContext, useContext } from 'react';
2
+ import type { ReactNode } from 'react';
3
+
4
+ interface HViewProps {
5
+ component?: string;
6
+ components?: Record<string, React.ComponentType<any>>;
7
+ children?: ReactNode;
8
+ [key: string]: any;
9
+ }
10
+
11
+ const ComponentsContext = createContext<
12
+ Record<string, React.ComponentType<any>> | undefined
13
+ >(undefined);
14
+
15
+ const HView: React.FC<HViewProps> = ({ component, components, ...props }) => {
16
+ const inheritedComponents = useContext(ComponentsContext);
17
+
18
+ if (!component) {
19
+ return components ? (
20
+ <ComponentsContext.Provider value={components}>
21
+ {props.children}
22
+ </ComponentsContext.Provider>
23
+ ) : (
24
+ <>{props.children}</>
25
+ );
26
+ }
27
+
28
+ const ViewHOCComponent = (components ?? inheritedComponents)?.[component];
29
+
30
+ return ViewHOCComponent ? <ViewHOCComponent {...props} /> : null;
31
+ };
32
+
33
+ export default HView;
@@ -0,0 +1,189 @@
1
+ import React, {
2
+ createContext,
3
+ useState,
4
+ useRef,
5
+ useEffect,
6
+ useContext,
7
+ ReactNode,
8
+ } from 'react';
9
+
10
+ import { View, Platform } from 'react-native';
11
+ import { NavigationContainer } from '@react-navigation/native';
12
+ import { createNativeStackNavigator } from '@react-navigation/native-stack';
13
+
14
+ type Route = {
15
+ name: string;
16
+ params?: any;
17
+ };
18
+
19
+ type NavigationContextType = {
20
+ navigate: (screenName: string, params?: any) => void;
21
+ replace: (screenName: string, params?: any) => void;
22
+ goBack: () => void;
23
+ addFocusListener: (screenName: string, callback: () => void) => () => void;
24
+ current: Route;
25
+ };
26
+
27
+ const NavigationContext = createContext<NavigationContextType | null>(null);
28
+
29
+ type NavigationScreens = Record<string, React.ComponentType<any>>;
30
+
31
+ type ProviderProps = {
32
+ screens: NavigationScreens;
33
+ children?: ReactNode;
34
+ };
35
+
36
+ export const NavigationProvider: React.FC<ProviderProps> = ({
37
+ screens,
38
+ children,
39
+ }) => {
40
+ const [stack, setStack] = useState<Route[]>([
41
+ { name: Object.keys(screens)[0], params: {} },
42
+ ]);
43
+
44
+ const focusListeners = useRef<Record<string, Array<() => void>>>({});
45
+
46
+ const current = stack[stack.length - 1];
47
+
48
+ const navigate = (screenName: string, params = {}) => {
49
+ setStack(prev => [...prev, { name: screenName, params }]);
50
+ };
51
+
52
+ const replace = (screenName: string, params = {}) => {
53
+ setStack(prev => [
54
+ ...prev.slice(0, -1),
55
+ { name: screenName, params },
56
+ ]);
57
+ };
58
+
59
+ const goBack = () => {
60
+ setStack(prev => (prev.length > 1 ? prev.slice(0, -1) : prev));
61
+ };
62
+
63
+ const addFocusListener = (screenName: string, callback: () => void) => {
64
+ if (!focusListeners.current[screenName]) {
65
+ focusListeners.current[screenName] = [];
66
+ }
67
+
68
+ focusListeners.current[screenName].push(callback);
69
+
70
+ return () => {
71
+ const listeners = focusListeners.current[screenName] || [];
72
+ focusListeners.current[screenName] = listeners.filter(
73
+ cb => cb !== callback
74
+ );
75
+ };
76
+ };
77
+
78
+ useEffect(() => {
79
+ const listeners = focusListeners.current[current.name] || [];
80
+ listeners.forEach(cb => cb());
81
+ }, [current.name]);
82
+
83
+ return (
84
+ <NavigationContext.Provider
85
+ value={{ navigate, goBack, replace, addFocusListener, current }}
86
+ >
87
+ <View style={{ flex: 1 }}>
88
+ {stack.map((route, index) => {
89
+ const ScreenComponent: React.ComponentType<any> = screens[route.name];
90
+ const isFocused = index === stack.length - 1;
91
+
92
+ return (
93
+ <View
94
+ key={index}
95
+ style={{
96
+ flex: 1,
97
+ display: isFocused ? 'flex' : 'none',
98
+ }}
99
+ >
100
+ <ScreenComponent
101
+ navigation={{ navigate, replace, goBack }}
102
+ route={{ params: route.params }}
103
+ />
104
+ </View>
105
+ );
106
+ })}
107
+
108
+ {children}
109
+ </View>
110
+ </NavigationContext.Provider>
111
+ );
112
+ };
113
+
114
+ export const useNavigation = () => {
115
+ const ctx = useContext(NavigationContext);
116
+ if (!ctx) {
117
+ throw new Error('useNavigation must be used inside NavigationProvider');
118
+ }
119
+ return ctx;
120
+ };
121
+
122
+ export const useFocusEffect = (callback: () => void | (() => void)) => {
123
+ const { current, addFocusListener } = useNavigation();
124
+ const cleanupRef = useRef<any>(null);
125
+
126
+ useEffect(() => {
127
+ cleanupRef.current?.();
128
+
129
+ const unsubscribe = addFocusListener(current.name, () => {
130
+ cleanupRef.current?.();
131
+ cleanupRef.current = callback();
132
+ });
133
+
134
+ return () => {
135
+ cleanupRef.current?.();
136
+ unsubscribe?.();
137
+ };
138
+ }, [current.name]);
139
+ };
140
+
141
+ export const useIsFocused = (): boolean => {
142
+ const { current, addFocusListener } = useNavigation();
143
+ const [isFocused, setIsFocused] = useState(true);
144
+
145
+ useEffect(() => {
146
+ setIsFocused(true);
147
+
148
+ const unsubscribe = addFocusListener(current.name, () => {
149
+ setIsFocused(true);
150
+ });
151
+
152
+ return () => {
153
+ setIsFocused(false);
154
+ unsubscribe();
155
+ };
156
+ }, [current.name]);
157
+
158
+ return isFocused;
159
+ };
160
+
161
+ export const ReactNativeNavigation: React.FC<{
162
+ screens: NavigationScreens;
163
+ }> = ({ screens }) => {
164
+ const Stack = createNativeStackNavigator();
165
+
166
+ return (
167
+ <NavigationContainer>
168
+ <Stack.Navigator
169
+ initialRouteName={Object.keys(screens)[0]}
170
+ screenOptions={{
171
+ animation: 'none',
172
+ headerShown: false,
173
+ }}
174
+ >
175
+ {Object.entries(screens).map(([name, component]) => (
176
+ <Stack.Screen key={name} name={name} component={component} />
177
+ ))}
178
+ </Stack.Navigator>
179
+ </NavigationContainer>
180
+ );
181
+ };
182
+
183
+ export default function Navigation({ screens }: { screens: NavigationScreens }) {
184
+ return Platform.OS === 'web' ? (
185
+ <NavigationProvider screens={screens} />
186
+ ) : (
187
+ <ReactNativeNavigation screens={screens} />
188
+ );
189
+ }
@@ -1,2 +1,2 @@
1
1
 
2
- export { useFocusEffect } from '../../../../../src/Navigation/PageNavigation';
2
+ export { useFocusEffect } from './PageNavigation';
@@ -1 +1 @@
1
- export { useFocusEffect } from '../../../../../src/Navigation/PageNavigation';
1
+ export { useFocusEffect } from './PageNavigation';
@@ -1 +1 @@
1
- export { useIsFocused } from '../../../../../src/Navigation/PageNavigation';
1
+ export { useIsFocused } from './PageNavigation';
@@ -1 +1 @@
1
- export { useIsFocused } from '../../../../../src/Navigation/PageNavigation';
1
+ export { useIsFocused } from './PageNavigation';
@@ -1,2 +1,2 @@
1
1
 
2
- export { useNavigation } from '../../../../../src/Navigation/PageNavigation';
2
+ export { useNavigation } from './PageNavigation';
@@ -1 +1 @@
1
- export { useNavigation } from '../../../../../src/Navigation/PageNavigation';
1
+ export { useNavigation } from './PageNavigation';