@jescon-technologies/react-native-ui-kit 0.0.20 → 0.0.21

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/index.d.ts CHANGED
@@ -23,10 +23,11 @@ export { default as HeaderBlock } from './src/CustomComponents/HeaderBlock';
23
23
  export { default as HDashboard } from './src/Hoc/HDashboard';
24
24
  export { default as NetworkServiceCall } from './src/Common/NetworkServiceCall';
25
25
  export { default as useNotifications } from './src/Handlers/NotificationsContext';
26
- export { default as ResponseComponentContext, ResponseComponentProvider } from './src/Handlers/ResponseComponentContext';
27
- export type { ResponseComponentProviderProps, ResponseContextValue, ResponseJSON } from './src/Handlers/ResponseComponentContext';
26
+ export { default as CBackHandler } from './src/CustomComponents/CBackHandler';
27
+ export * from './src/Handlers/ResponseComponentContext';
28
28
  export * from './src/Navigation/useNavigation';
29
29
  export * from './src/Navigation/useIsFocused';
30
30
  export * from './src/Navigation/useFocusEffect';
31
- export { default as CBackHandler } from './src/CustomComponents/CBackHandler';
32
31
  export * from './src/CommonStyle/ComponentFunctions';
32
+ export * from '../../../src/Common/apiConstants'
33
+ export * from '../../../src/Common/Global';
package/index.js CHANGED
@@ -23,9 +23,11 @@ export { default as HeaderBlock } from './src/CustomComponents/HeaderBlock';
23
23
  export { default as HDashboard } from './src/Hoc/HDashboard';
24
24
  export { default as NetworkServiceCall } from './src/Common/NetworkServiceCall';
25
25
  export { default as useNotifications } from './src/Handlers/NotificationsContext';
26
- export { default as ResponseComponentContext, ResponseComponentProvider } from './src/Handlers/ResponseComponentContext';
26
+ export { default as CBackHandler } from './src/CustomComponents/CBackHandler';
27
+ export * from './src/Handlers/ResponseComponentContext';
27
28
  export * from './src/Navigation/useNavigation';
28
29
  export * from './src/Navigation/useIsFocused';
29
30
  export * from './src/Navigation/useFocusEffect';
30
- export { default as CBackHandler } from './src/CustomComponents/CBackHandler';
31
31
  export * from './src/CommonStyle/ComponentFunctions';
32
+ export * from '../../../src/Common/apiConstants'
33
+ export * from '../../../src/Common/Global';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jescon-technologies/react-native-ui-kit",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "A React Native module for Jescon Technologies that provides react-native-ui-kit",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -0,0 +1,78 @@
1
+ import React, {
2
+ createContext,
3
+ useContext,
4
+ useEffect,
5
+ useSyncExternalStore,
6
+ } from 'react';
7
+ import type { ReactNode } from 'react';
8
+
9
+ export type GlobalConfig = Record<string, unknown>;
10
+
11
+ interface GlobalStore {
12
+ getSnapshot: () => object;
13
+ subscribe: (listener: () => void) => () => void;
14
+ }
15
+
16
+ let globalConfig: object = {};
17
+ const listeners = new Set<() => void>();
18
+
19
+ const notifyListeners = (): void => {
20
+ listeners.forEach(listener => listener());
21
+ };
22
+
23
+ const globalStore: GlobalStore = {
24
+ getSnapshot: () => globalConfig,
25
+ subscribe: listener => {
26
+ listeners.add(listener);
27
+ return () => listeners.delete(listener);
28
+ },
29
+ };
30
+
31
+ export const GlobalContext = createContext<GlobalStore>(globalStore);
32
+
33
+ export const setGlobal = <T extends object>(config: T): void => {
34
+ globalConfig = config;
35
+ notifyListeners();
36
+ };
37
+
38
+ export const getGlobal = <
39
+ T extends object = GlobalConfig,
40
+ >(): T => globalConfig as T;
41
+
42
+ export const updateGlobal = <T extends object = GlobalConfig>(
43
+ config: Partial<T>,
44
+ ): void => {
45
+ Object.assign(globalConfig, config);
46
+ notifyListeners();
47
+ };
48
+
49
+ export const useGlobal = <T extends object = GlobalConfig>(): T => {
50
+ const store = useContext(GlobalContext);
51
+ return useSyncExternalStore(
52
+ store.subscribe,
53
+ store.getSnapshot,
54
+ store.getSnapshot,
55
+ ) as T;
56
+ };
57
+
58
+ interface GlobalProviderProps {
59
+ global?: object;
60
+ children?: ReactNode;
61
+ }
62
+
63
+ export const GlobalProvider: React.FC<GlobalProviderProps> = ({
64
+ global,
65
+ children,
66
+ }) => {
67
+ useEffect(() => {
68
+ if (global !== undefined) {
69
+ setGlobal(global);
70
+ }
71
+ }, [global]);
72
+
73
+ return (
74
+ <GlobalContext.Provider value={globalStore}>
75
+ {children}
76
+ </GlobalContext.Provider>
77
+ );
78
+ };
@@ -14,7 +14,7 @@ import {
14
14
  ViewStyle,
15
15
  TextStyle,
16
16
  } from 'react-native';
17
- import { APIURL } from '../../../../../src/Common/apiConstants';
17
+ import { APIURL } from '@jescon-technologies/react-native-ui-kit';
18
18
  import Loader from '../Custom/Loader';
19
19
  import { isBNU, isBNUL, isNU, normalize } from '../CommonStyle/ComponentFunctions';
20
20
  import NetworkServiceCall from '../Common/NetworkServiceCall';
@@ -11,7 +11,7 @@ import {
11
11
  import { normalize} from '../CommonStyle/ComponentFunctions';
12
12
  import RNExitApp from 'react-native-exit-app';
13
13
  import { Global, GlobalUserData } from '../../../../../src/Common/Global';
14
- import { imageURL } from '../../../../../src/Common/apiConstants';
14
+ import { imageURL } from '@jescon-technologies/react-native-ui-kit';
15
15
  import { useNavigation } from '../Navigation/useNavigation';
16
16
  import CModalOverlay from '../CustomComponents/CModalOverlay';
17
17
  import HIcons from '../Hoc/HIcons';
@@ -13,7 +13,7 @@ import {
13
13
  TextStyle,
14
14
  } from 'react-native';
15
15
  import { normalize} from '../CommonStyle/ComponentFunctions';
16
- import { APIURL } from '../../../../../src/Common/apiConstants';
16
+ import { imageURL } from '@jescon-technologies/react-native-ui-kit';
17
17
 
18
18
  // ---------------------------------------------------------------------------
19
19
  // Types
@@ -45,7 +45,7 @@ export default function Loader({
45
45
  overlayColor = 'rgba(0,0,0,0.4)',
46
46
  loaderColor = 'lightblue',
47
47
  size = Platform.OS !== 'web' ? 30 : 50,
48
- gifSource = { uri: `${APIURL}file/getCommonFile/image/heartpulse.gif` },
48
+ gifSource = { uri: `${imageURL}heartpulse.gif` },
49
49
  message = '',
50
50
  messageStyle = {},
51
51
  animationType = 'fade',
@@ -33,7 +33,7 @@ import NetworkServiceCall from '../Common/NetworkServiceCall';
33
33
  import HIcons from '../Hoc/HIcons';
34
34
  import ResponseComponentContext from '../Handlers/ResponseComponentContext';
35
35
  import { Global } from '../../../../../src/Common/Global';
36
- import { APIURL } from '../../../../../src/Common/apiConstants';
36
+ import { notifyURL } from '../../../../../src/Common/apiConstants';
37
37
 
38
38
  // import HelpdeskScreenFocus from '../Helpdesk/View/HelpdeskScreenFocus';
39
39
  // import CHelpdeskView from '../Helpdesk/View/CHelpdeskView';
@@ -50,7 +50,6 @@ interface HeaderBlockProps {
50
50
  webview?: unknown;
51
51
  data?: unknown;
52
52
  navigation?: (route: string, params?: object) => void;
53
- APIURL?: string;
54
53
  [key: string]: unknown;
55
54
  }
56
55
 
@@ -358,9 +357,7 @@ const HeaderBlock: React.FC<HeaderBlockProps> = (props) => {
358
357
  const userData = Global.userData as UserDataLite | null | undefined;
359
358
  if (userData && userData.suuser) {
360
359
  setIsLoadingNotifications(true);
361
- const url =
362
- APIURL + 'invget/invcommonget/rnhrsumessageuserretrievaljson ' + userData.suuser;
363
- NetworkServiceCall('get', url)
360
+ NetworkServiceCall('get',`${notifyURL} ${userData.suuser}`)
364
361
  .then((response: NetworkResponse<NotificationItem[] | NotificationsPayload>) => {
365
362
  setIsLoadingNotifications(false);
366
363
  if (response && response.httpstatus == 200) {
@@ -32,7 +32,6 @@ import HShadowButton from './HShadowButton';
32
32
  import HIcons from './HIcons';
33
33
  import { normalize} from '../CommonStyle/ComponentFunctions';
34
34
  import { Global } from '../../../../../src/Common/Global';
35
- ;
36
35
  import SDateTimePicker from '../StaticComponents/SDateTimePicker';
37
36
 
38
37
  // ---------------------------------------------------------------------------
@@ -2,20 +2,27 @@ import React from 'react';
2
2
  import HView from '../Hoc/HView';
3
3
  import Navigation from '../Navigation/PageNavigation';
4
4
  import ErrorBoundary from '../Common/ErrorBoundary';
5
+ import { GlobalProvider } from '../Common/GlobalContext';
5
6
  import { SafeAreaView } from 'react-native-safe-area-context';
6
7
 
7
8
  interface HProviderProps {
8
9
  components: Record<string, React.ComponentType<any>>;
9
10
  screens: any;
11
+ Global?: object;
12
+ global?: object;
10
13
  }
11
14
  export default function HProvider(props: HProviderProps) {
15
+ const global = props.Global ?? props.global;
16
+
12
17
  return (
13
- <SafeAreaView style={{ flex: 1 }}>
14
- <ErrorBoundary>
15
- <HView components={props.components}>
16
- <Navigation screens={props.screens} />
17
- </HView>
18
- </ErrorBoundary>
19
- </SafeAreaView>
18
+ <GlobalProvider global={global}>
19
+ <SafeAreaView style={{ flex: 1 }}>
20
+ <ErrorBoundary>
21
+ <HView components={props.components}>
22
+ <Navigation screens={props.screens} />
23
+ </HView>
24
+ </ErrorBoundary>
25
+ </SafeAreaView>
26
+ </GlobalProvider>
20
27
  );
21
28
  }