@tracktor/shared-module 0.4.0 → 0.5.1
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/CHANGELOG.md +2 -2
- package/README.md +14 -0
- package/dist/components/utils/AxiosConfig.d.ts +40 -0
- package/dist/components/{GTMSendPageView → utils}/GTMSendPageView.d.ts +5 -0
- package/dist/components/utils/I18nConfig.d.ts +26 -0
- package/dist/components/utils/SentryConfig.d.ts +22 -0
- package/dist/context/InjectDependenciesProvider.d.ts +12 -0
- package/dist/context/QueryClientConfigProvider.d.ts +36 -0
- package/dist/main.d.ts +12 -4
- package/dist/main.js +380 -315
- package/dist/main.umd.cjs +10 -10
- package/package.json +1 -1
- package/dist/components/GTMSendPageView/index.d.ts +0 -3
- package/dist/components/RequireAuth/index.d.ts +0 -3
- /package/dist/components/{RequireAuth → utils}/RequireAuth.d.ts +0 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -50,3 +50,17 @@ const App = () => (
|
|
|
50
50
|
|
|
51
51
|
export default App;
|
|
52
52
|
```
|
|
53
|
+
|
|
54
|
+
## Exported module
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
| Module | Type | Description |
|
|
58
|
+
|----------------------------|-----------------|-------------------------------------------------------------------------|
|
|
59
|
+
| RequireAuth | React Component | Component for protected routing |
|
|
60
|
+
| GTMSendPageView | React Component | Send page view event to Google Tag Manager |
|
|
61
|
+
| AxiosConfig | React Component | Initialize Axios instance with custom default config options |
|
|
62
|
+
| I18nConfig | React Component | Initialize i18n instance with custom config options |
|
|
63
|
+
| SentryConfig | React Component | Initialize Sentry |
|
|
64
|
+
| InjectDependenciesProvider | React Provider | Inject dependencies for other shared component |
|
|
65
|
+
| QueryClientConfigProvider | React Provider | This provider is QueryClientProvider with custom default config options |
|
|
66
|
+
| useResponseError | React Hook | This hook is used to print error messages from the API |
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
interface AxiosConfigProps<T> {
|
|
2
|
+
/**
|
|
3
|
+
* Axios instance
|
|
4
|
+
*/
|
|
5
|
+
axios: T & {
|
|
6
|
+
defaults: {
|
|
7
|
+
baseURL?: string;
|
|
8
|
+
headers: {
|
|
9
|
+
common: {
|
|
10
|
+
Authorization?: any;
|
|
11
|
+
};
|
|
12
|
+
post: {
|
|
13
|
+
"Content-Type"?: any;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* User local storage key
|
|
20
|
+
*/
|
|
21
|
+
userLocalStorageKey?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Base URL for Axios instance
|
|
24
|
+
*/
|
|
25
|
+
baseURL?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Post content type for Axios instance
|
|
28
|
+
*/
|
|
29
|
+
postContentType?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* This component initialize Axios instance with custom default config options
|
|
33
|
+
* @param axios
|
|
34
|
+
* @param baseURL
|
|
35
|
+
* @param userLocalStorageKey
|
|
36
|
+
* @param postContentType
|
|
37
|
+
* @constructor
|
|
38
|
+
*/
|
|
39
|
+
declare const AxiosConfig: <T extends unknown>({ axios, baseURL, userLocalStorageKey, postContentType, }: AxiosConfigProps<T>) => null;
|
|
40
|
+
export default AxiosConfig;
|
|
@@ -4,5 +4,10 @@ export interface GTMSendPageViewProps {
|
|
|
4
4
|
Outlet?: InjectDependenciesContextProps["Outlet"];
|
|
5
5
|
useLocation?: InjectDependenciesContextProps["useLocation"];
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* This component send page view to Google Tag Manager
|
|
9
|
+
* @param props
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
7
12
|
declare const GTMSendPageView: ({ ...props }: GTMSendPageViewProps) => JSX.Element;
|
|
8
13
|
export default GTMSendPageView;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
interface I18nConfigProps<I, L, R> {
|
|
2
|
+
/**
|
|
3
|
+
* i18n instance
|
|
4
|
+
*/
|
|
5
|
+
i18n: I & {
|
|
6
|
+
use: (plugin: any) => any;
|
|
7
|
+
init: (options: any) => any;
|
|
8
|
+
on: (event: string, callback: (lng: string) => void) => void;
|
|
9
|
+
resolvedLanguage?: string;
|
|
10
|
+
};
|
|
11
|
+
LanguageDetector?: L;
|
|
12
|
+
resources?: {
|
|
13
|
+
[language: string]: any;
|
|
14
|
+
};
|
|
15
|
+
initReactI18next?: R;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* This component initializes i18n instance with custom config options
|
|
19
|
+
* @param i18n
|
|
20
|
+
* @param initReactI18next
|
|
21
|
+
* @param resources
|
|
22
|
+
* @param LanguageDetector
|
|
23
|
+
* @constructor
|
|
24
|
+
*/
|
|
25
|
+
declare const I18nConfig: <I extends unknown, L extends unknown, R extends unknown>({ i18n, initReactI18next, resources, LanguageDetector, }: I18nConfigProps<I, L, R>) => null;
|
|
26
|
+
export default I18nConfig;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface SentryConfigProps<T> {
|
|
2
|
+
/**
|
|
3
|
+
* Sentry instance
|
|
4
|
+
*/
|
|
5
|
+
sentry: T & {
|
|
6
|
+
init: (config: {
|
|
7
|
+
dsn: string;
|
|
8
|
+
integrations: any[];
|
|
9
|
+
tracesSampleRate: number;
|
|
10
|
+
}) => void;
|
|
11
|
+
BrowserTracing: any;
|
|
12
|
+
};
|
|
13
|
+
dsn: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* This component is used to initialize Sentry
|
|
17
|
+
* @param dsn
|
|
18
|
+
* @param sentry
|
|
19
|
+
* @constructor
|
|
20
|
+
*/
|
|
21
|
+
declare const SentryConfig: <T extends unknown>({ dsn, sentry }: SentryConfigProps<T>) => null;
|
|
22
|
+
export default SentryConfig;
|
|
@@ -51,5 +51,17 @@ export interface InjectDependenciesContextProps {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
export declare const InjectDependenciesContext: import("react").Context<InjectDependenciesContextProps>;
|
|
54
|
+
/**
|
|
55
|
+
* This provider is used to inject dependencies to components
|
|
56
|
+
* @param axios
|
|
57
|
+
* @param children
|
|
58
|
+
* @param translate
|
|
59
|
+
* @param useAuth
|
|
60
|
+
* @param Outlet
|
|
61
|
+
* @param Navigate
|
|
62
|
+
* @param useLocation
|
|
63
|
+
* @param useGoogleTagManager
|
|
64
|
+
* @constructor
|
|
65
|
+
*/
|
|
54
66
|
declare const InjectDependenciesProvider: ({ axios, children, translate, useAuth, Outlet, Navigate, useLocation, useGoogleTagManager, }: InjectDependenciesContextProps) => JSX.Element;
|
|
55
67
|
export default InjectDependenciesProvider;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PropsWithChildren, ReactNode } from "react";
|
|
2
|
+
interface QueryClientConfigProviderProps<T> extends PropsWithChildren {
|
|
3
|
+
/**
|
|
4
|
+
* QueryClient instance
|
|
5
|
+
*/
|
|
6
|
+
QueryClient: {
|
|
7
|
+
new (config: {
|
|
8
|
+
defaultOptions: {
|
|
9
|
+
queries: {
|
|
10
|
+
refetchOnWindowFocus: boolean;
|
|
11
|
+
retry: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}): T;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* QueryClientProvider component
|
|
18
|
+
*/
|
|
19
|
+
QueryClientProvider: ({ client, children }: {
|
|
20
|
+
client: T;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}) => any;
|
|
23
|
+
defaultOptions?: {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* This provider is QueryClientProvider with custom default config options
|
|
29
|
+
* @param children
|
|
30
|
+
* @param options
|
|
31
|
+
* @param QueryClient
|
|
32
|
+
* @param QueryClientProvider
|
|
33
|
+
* @constructor
|
|
34
|
+
*/
|
|
35
|
+
declare const QueryClientConfigProvider: <T extends unknown>({ children, defaultOptions, QueryClient, QueryClientProvider, }: QueryClientConfigProviderProps<T>) => JSX.Element;
|
|
36
|
+
export default QueryClientConfigProvider;
|
package/dist/main.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
export { default as RequireAuth } from './components/RequireAuth';
|
|
2
|
-
export * from './components/RequireAuth';
|
|
3
|
-
export { default as GTMSendPageView } from './components/GTMSendPageView';
|
|
4
|
-
export * from './components/GTMSendPageView';
|
|
1
|
+
export { default as RequireAuth } from './components/utils/RequireAuth';
|
|
2
|
+
export * from './components/utils/RequireAuth';
|
|
3
|
+
export { default as GTMSendPageView } from './components/utils/GTMSendPageView';
|
|
4
|
+
export * from './components/utils/GTMSendPageView';
|
|
5
|
+
export { default as AxiosConfig } from './components/utils/AxiosConfig';
|
|
6
|
+
export * from './components/utils/AxiosConfig';
|
|
7
|
+
export { default as I18nConfig } from './components/utils/I18nConfig';
|
|
8
|
+
export * from './components/utils/I18nConfig';
|
|
9
|
+
export { default as SentryConfig } from './components/utils/SentryConfig';
|
|
10
|
+
export * from './components/utils/SentryConfig';
|
|
5
11
|
export { default as InjectDependenciesProvider } from './context/InjectDependenciesProvider';
|
|
6
12
|
export * from './context/InjectDependenciesProvider';
|
|
13
|
+
export { default as QueryClientProvider } from './context/QueryClientConfigProvider';
|
|
14
|
+
export * from './context/QueryClientConfigProvider';
|
|
7
15
|
export { default as useResponseError } from './hooks/useResponseError';
|
|
8
16
|
export * from './hooks/useResponseError';
|