@tracktor/shared-module 0.2.1 → 0.4.0
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/dist/components/GTMSendPageView/GTMSendPageView.d.ts +8 -0
- package/dist/components/GTMSendPageView/index.d.ts +3 -0
- package/dist/components/RequireAuth/RequireAuth.d.ts +40 -20
- package/dist/context/InjectDependenciesProvider.d.ts +31 -9
- package/dist/hooks/useResponseError/useResponseError.d.ts +2 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.js +341 -297
- package/dist/main.umd.cjs +10 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
|
|
2
|
+
export interface GTMSendPageViewProps {
|
|
3
|
+
useGoogleTagManager?: InjectDependenciesContextProps["useGoogleTagManager"];
|
|
4
|
+
Outlet?: InjectDependenciesContextProps["Outlet"];
|
|
5
|
+
useLocation?: InjectDependenciesContextProps["useLocation"];
|
|
6
|
+
}
|
|
7
|
+
declare const GTMSendPageView: ({ ...props }: GTMSendPageViewProps) => JSX.Element;
|
|
8
|
+
export default GTMSendPageView;
|
|
@@ -1,32 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
to: string;
|
|
4
|
-
replace?: boolean;
|
|
5
|
-
state?: any;
|
|
6
|
-
}
|
|
7
|
-
interface Location {
|
|
8
|
-
state: any;
|
|
9
|
-
}
|
|
10
|
-
interface Auth {
|
|
11
|
-
isLogged: boolean;
|
|
12
|
-
}
|
|
13
|
-
interface OutletProps {
|
|
14
|
-
context?: unknown;
|
|
15
|
-
}
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
|
|
16
3
|
export interface RequireAuthProps {
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
19
7
|
loginPath?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Fallback component for Suspense
|
|
10
|
+
*/
|
|
20
11
|
Fallback?: ReactNode;
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Outlet dependency for RequireAuth component
|
|
14
|
+
*/
|
|
15
|
+
Outlet?: InjectDependenciesContextProps["Outlet"];
|
|
16
|
+
/**
|
|
17
|
+
* Navigate dependency for RequireAuth component
|
|
18
|
+
*/
|
|
19
|
+
Navigate?: InjectDependenciesContextProps["Navigate"];
|
|
20
|
+
/**
|
|
21
|
+
* useLocation dependency for RequireAuth component
|
|
22
|
+
*/
|
|
23
|
+
useLocation?: InjectDependenciesContextProps["useLocation"];
|
|
24
|
+
/**
|
|
25
|
+
* useAuth dependency for RequireAuth component
|
|
26
|
+
*/
|
|
27
|
+
useAuth?: InjectDependenciesContextProps["useAuth"];
|
|
28
|
+
/**
|
|
29
|
+
* Axios instance dependency is used for intercepting 401 responses
|
|
30
|
+
*/
|
|
31
|
+
axios?: InjectDependenciesContextProps["axios"];
|
|
32
|
+
/**
|
|
33
|
+
* Local storage key for user data
|
|
34
|
+
*/
|
|
35
|
+
localStorageKey?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Redirect path for 401 responses
|
|
38
|
+
*/
|
|
39
|
+
redirect401Path?: string;
|
|
23
40
|
}
|
|
24
41
|
/**
|
|
25
42
|
* RequireAuth component for protected routing
|
|
43
|
+
* @param axios
|
|
26
44
|
* @param Fallback
|
|
27
45
|
* @param loginPath
|
|
46
|
+
* @param localStorageKey
|
|
47
|
+
* @param redirect401Path
|
|
28
48
|
* @param props
|
|
29
49
|
* @constructor
|
|
30
50
|
*/
|
|
31
|
-
declare const RequireAuth: ({ Fallback, loginPath, ...props }: RequireAuthProps) => JSX.Element;
|
|
51
|
+
declare const RequireAuth: ({ Fallback, loginPath, localStorageKey, redirect401Path, ...props }: RequireAuthProps) => JSX.Element;
|
|
32
52
|
export default RequireAuth;
|
|
@@ -1,33 +1,55 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
import type { RequireAuthProps } from '../components/RequireAuth';
|
|
3
|
-
import type { useResponseErrorParams } from '../hooks/useResponseError';
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
4
2
|
export interface InjectDependenciesContextProps {
|
|
5
3
|
/**
|
|
6
4
|
* Children
|
|
7
5
|
*/
|
|
8
6
|
children?: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Axios instance dependency
|
|
9
|
+
*/
|
|
10
|
+
axios?: any;
|
|
9
11
|
/**
|
|
10
12
|
* Translate function dependency for useResponseError hook
|
|
11
13
|
* @param str
|
|
12
14
|
*/
|
|
13
|
-
translate
|
|
15
|
+
translate?(str: string): string;
|
|
14
16
|
/**
|
|
15
17
|
* Outlet dependency for RequireAuth component
|
|
16
18
|
*/
|
|
17
|
-
Outlet
|
|
19
|
+
Outlet?(props: {
|
|
20
|
+
context?: unknown;
|
|
21
|
+
}): ReactElement | null;
|
|
18
22
|
/**
|
|
19
23
|
* Navigate dependency for RequireAuth component
|
|
20
24
|
*/
|
|
21
|
-
Navigate
|
|
25
|
+
Navigate?(props: {
|
|
26
|
+
to: string;
|
|
27
|
+
replace?: boolean;
|
|
28
|
+
state?: any;
|
|
29
|
+
}): null;
|
|
22
30
|
/**
|
|
23
31
|
* useLocation dependency for RequireAuth component
|
|
24
32
|
*/
|
|
25
|
-
useLocation
|
|
33
|
+
useLocation?(): {
|
|
34
|
+
state: any;
|
|
35
|
+
pathname: string;
|
|
36
|
+
};
|
|
26
37
|
/**
|
|
27
38
|
* useAuth dependency for RequireAuth component
|
|
28
39
|
*/
|
|
29
|
-
useAuth
|
|
40
|
+
useAuth?(): {
|
|
41
|
+
isLogged: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* useGoogleTagManager dependency for GTMSendPageView component
|
|
45
|
+
*/
|
|
46
|
+
useGoogleTagManager?(): {
|
|
47
|
+
sendEvent: (event: {
|
|
48
|
+
event: string;
|
|
49
|
+
pathname: string;
|
|
50
|
+
}) => void;
|
|
51
|
+
};
|
|
30
52
|
}
|
|
31
53
|
export declare const InjectDependenciesContext: import("react").Context<InjectDependenciesContextProps>;
|
|
32
|
-
declare const InjectDependenciesProvider: ({ children, translate, useAuth, Outlet, Navigate, useLocation }: InjectDependenciesContextProps) => JSX.Element;
|
|
54
|
+
declare const InjectDependenciesProvider: ({ axios, children, translate, useAuth, Outlet, Navigate, useLocation, useGoogleTagManager, }: InjectDependenciesContextProps) => JSX.Element;
|
|
33
55
|
export default InjectDependenciesProvider;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
|
|
1
2
|
export interface ResponseError {
|
|
2
3
|
data?: {
|
|
3
4
|
code?: number;
|
|
@@ -16,7 +17,7 @@ export interface useResponseErrorParams {
|
|
|
16
17
|
* Translation function if you want to use your own translation function
|
|
17
18
|
* @param str
|
|
18
19
|
*/
|
|
19
|
-
translate?:
|
|
20
|
+
translate?: InjectDependenciesContextProps["translate"];
|
|
20
21
|
/**
|
|
21
22
|
* Translation key returned for the unknown error
|
|
22
23
|
*/
|
package/dist/main.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { default as RequireAuth } from './components/RequireAuth';
|
|
2
2
|
export * from './components/RequireAuth';
|
|
3
|
+
export { default as GTMSendPageView } from './components/GTMSendPageView';
|
|
4
|
+
export * from './components/GTMSendPageView';
|
|
3
5
|
export { default as InjectDependenciesProvider } from './context/InjectDependenciesProvider';
|
|
4
6
|
export * from './context/InjectDependenciesProvider';
|
|
5
7
|
export { default as useResponseError } from './hooks/useResponseError';
|