@tracktor/shared-module 1.0.4 → 1.0.6

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 CHANGED
@@ -1,4 +1,4 @@
1
1
  # [Versions](https://github.com/Tracktor/shared-module/releases)
2
2
 
3
- ## v1.0.4
4
- - **[chore]** : improvement
3
+ ## v1.0.5
4
+ - **[fix]** : name export
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # @tracktor/shared-module
1
+ # shared-module
2
2
 
3
3
  > This package contains shared components, hooks and utilities for the Tracktor project.
4
- > This package use dependencies only with injection.
4
+ > This package don't use any external dependencies, only peer dependencies.
5
5
  > This package is not intended to be used outside the Tracktor project.
6
6
 
7
7
  - [Installation](#Installation)
@@ -17,19 +17,17 @@ yarn add @tracktor/shared-module
17
17
  ## Usage
18
18
 
19
19
  ```typescript jsx
20
- import { InitializeAxiosConfig } from "@tracktor/shared-module";
20
+ import { AxiosConfig } from "@tracktor/shared-module";
21
21
  ```
22
22
 
23
23
  ## Inject dependencies with provider
24
24
 
25
25
  ```typescript jsx
26
- import { InjectDependenciesProvider, InitializeAxiosConfig } from "@tracktor/shared-module";
26
+ import { AxiosConfig, InjectDependenciesProvider } from "@tracktor/shared-module";
27
27
 
28
28
  const App = () => (
29
- <InjectDependenciesProvider apiURL={import.meta.env.VITE_API_URL} libraries={{
30
- axios,
31
- }}>
32
- <InitializeAxiosConfig/>
29
+ <InjectDependenciesProvider apiURL={import.meta.env.VITE_API_URL}>
30
+ <AxiosConfig baseURL={import.meta.env.VITE_API_URL} />
33
31
  ...
34
32
  </InjectDependenciesProvider>
35
33
  );
@@ -38,10 +36,10 @@ export default App;
38
36
  ```
39
37
 
40
38
  ## Providers
41
- | Module | Description | Dependencies |
42
- |-------------------------------|------------------------------------------------|--------------|
43
- | InjectDependenciesProvider | Inject dependencies for other shared component | - |
44
- | QueryClientProviderWithConfig | React Query provider with default config | React Query |
39
+ | Module | Description | Dependencies |
40
+ |----------------------------|------------------------------------------------|--------------|
41
+ | InjectDependenciesProvider | Inject dependencies for other shared component | - |
42
+ | QueryClientConfigProvider | React Query provider with default config | React Query |
45
43
 
46
44
 
47
45
  ## Components
@@ -1,18 +1,6 @@
1
- import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
2
- export interface GTMSendPageViewProps {
3
- /**
4
- * GTM library from @tracktor
5
- */
6
- gtm?: NonNullable<InjectDependenciesContextProps["libraries"]>["gtm"];
7
- /**
8
- * React Router library
9
- */
10
- reactRouter?: NonNullable<InjectDependenciesContextProps["libraries"]>["reactRouter"];
11
- }
12
1
  /**
13
2
  * This component send page view to Google Tag Manager
14
- * @param props
15
3
  * @constructor
16
4
  */
17
- declare const GTMSendPageView: ({ ...props }: GTMSendPageViewProps) => import("react/jsx-runtime").JSX.Element;
5
+ declare const GTMSendPageView: () => import("react/jsx-runtime").JSX.Element | null;
18
6
  export default GTMSendPageView;
@@ -1,29 +1,10 @@
1
1
  import { ReactNode } from "react";
2
- import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
3
2
  export interface RequireAuthProps {
4
- /**
5
- * React router is a libraries dependencies
6
- */
7
- reactRouter?: NonNullable<InjectDependenciesContextProps["libraries"]>["reactRouter"];
8
- /**
9
- * Axios is a libraries dependencies
10
- */
11
- axios?: NonNullable<InjectDependenciesContextProps["libraries"]>["axios"];
12
- /**
13
- * Is user logged in
14
- */
15
- isLogged?: () => {
16
- isLogged: boolean;
17
- } | boolean;
18
3
  /**
19
4
  * Login path
20
5
  * @default /login
21
6
  */
22
7
  loginPath?: string;
23
- /**
24
- * Fallback component for Suspense
25
- */
26
- Fallback?: ReactNode;
27
8
  /**
28
9
  * Local storage key for user data
29
10
  * @default user
@@ -34,16 +15,25 @@ export interface RequireAuthProps {
34
15
  * @default /login
35
16
  */
36
17
  redirect401Path?: string;
18
+ /**
19
+ * Is user logged in
20
+ */
21
+ isLogged?: () => {
22
+ isLogged: boolean;
23
+ } | boolean;
24
+ /**
25
+ * Fallback component for Suspense
26
+ */
27
+ Fallback?: ReactNode;
37
28
  }
38
29
  /**
39
30
  * RequireAuth component for protected routing
40
31
  * @param Fallback
41
- * @param isLogged
42
32
  * @param loginPath
43
33
  * @param localStorageKey
44
34
  * @param redirect401Path
45
- * @param props
35
+ * @param isLogged
46
36
  * @constructor
47
37
  */
48
- declare const RequireAuth: ({ Fallback, isLogged, loginPath, localStorageKey, redirect401Path, ...props }: RequireAuthProps) => import("react/jsx-runtime").JSX.Element;
38
+ declare const RequireAuth: ({ Fallback, loginPath, localStorageKey, redirect401Path, isLogged, }: RequireAuthProps) => import("react/jsx-runtime").JSX.Element;
49
39
  export default RequireAuth;
@@ -8,53 +8,14 @@ export interface InjectDependenciesContextProps {
8
8
  * API URL dependency for useAdapter hook
9
9
  */
10
10
  apiURL?: string;
11
- /**
12
- * List of dependencies for libraries
13
- */
14
- libraries?: {
15
- axios?: any;
16
- dayjs?: any;
17
- dayjsPlugin?: any[];
18
- gtm?: {
19
- useGoogleTagManager: () => any;
20
- };
21
- mapbox?: any;
22
- reactRouter?: any;
23
- sentry?: any;
24
- i18?: {
25
- i18next?: any;
26
- initReactI18next?: any;
27
- languageDetector?: any;
28
- };
29
- reactQuery?: {
30
- QueryClientProvider: ({ client, children }: {
31
- client: any;
32
- children: ReactNode;
33
- }) => any;
34
- QueryClient: {
35
- new (config: {
36
- defaultOptions: {
37
- queries: {
38
- refetchOnWindowFocus: boolean;
39
- retry: number;
40
- getNextPageParam: (lastPage: [], allPages: [], lastPageParam: number) => number;
41
- };
42
- mutations: {
43
- [key: string]: any;
44
- };
45
- };
46
- }): any;
47
- };
48
- };
49
- };
50
11
  }
51
12
  export declare const InjectDependenciesContext: import("react").Context<InjectDependenciesContextProps>;
52
13
  /**
53
- * This provider is used to inject major dependencies
14
+ *
54
15
  * @param children
55
- * @param librariesDependencies
16
+ * @param translate
56
17
  * @param apiURL
57
18
  * @constructor
58
19
  */
59
- declare const InjectDependenciesProvider: ({ children, apiURL, libraries }: InjectDependenciesContextProps) => import("react/jsx-runtime").JSX.Element;
20
+ declare const InjectDependenciesProvider: ({ children, apiURL }: InjectDependenciesContextProps) => import("react/jsx-runtime").JSX.Element;
60
21
  export default InjectDependenciesProvider;
@@ -1,4 +1,4 @@
1
- import { c as o } from "./main-EkPM5n5x.js";
1
+ import { c as o } from "./main-srWqMrqy.js";
2
2
  var a = { exports: {} };
3
3
  (function(t, _) {
4
4
  (function(r, e) {
@@ -1,4 +1,4 @@
1
- import { c as m } from "./main-EkPM5n5x.js";
1
+ import { c as m } from "./main-srWqMrqy.js";
2
2
  import o from "dayjs";
3
3
  var i = { exports: {} };
4
4
  (function(n, s) {
@@ -1,20 +1,9 @@
1
- import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
2
- export interface useAdapterParams {
3
- /**
4
- * Dayjs library
5
- */
6
- dayjs?: NonNullable<InjectDependenciesContextProps["libraries"]>["dayjs"];
7
- /**
8
- * Translation key returned for the unknown error
9
- */
10
- unknownErrorTranslationKey?: string;
11
- }
12
1
  /**
13
2
  * Use adapter
14
3
  * @returns
15
4
  */
16
- export declare const useAdapter: (params?: useAdapterParams) => {
17
- dateAdapter: (date: string | number | Date | null | undefined, format?: string) => any;
5
+ export declare const useAdapter: () => {
6
+ dateAdapter: (date: string | number | import("dayjs").Dayjs | Date | null | undefined, format?: string) => string;
18
7
  distanceAdapter: (distance?: string | number | null | undefined, metric?: string) => string;
19
8
  filePathAdapter: (href?: string | null | {
20
9
  pathname: string;
@@ -1,11 +1,4 @@
1
- import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
2
- interface useAuthParams {
3
- /**
4
- * Axios library
5
- */
6
- axios?: NonNullable<InjectDependenciesContextProps["libraries"]>["axios"];
7
- }
8
- declare const useAuth: (params?: useAuthParams) => {
1
+ declare const useAuth: () => {
9
2
  clearAuthenticationToken: () => void;
10
3
  setAuthenticationToken: ({ tokenType, accessToken }: {
11
4
  tokenType: string;
@@ -1,4 +1,3 @@
1
- import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
2
1
  export interface ResponseError {
3
2
  data?: {
4
3
  code?: number;
@@ -13,10 +12,6 @@ export interface ResponseError {
13
12
  };
14
13
  }
15
14
  export interface useResponseErrorParams {
16
- /**
17
- * i18 library
18
- */
19
- i18?: NonNullable<InjectDependenciesContextProps["libraries"]>["i18"];
20
15
  /**
21
16
  * Translation key returned for the unknown error
22
17
  */
@@ -28,6 +23,6 @@ export interface useResponseErrorParams {
28
23
  */
29
24
  export declare const useResponseError: <T = ResponseError>(params?: useResponseErrorParams) => {
30
25
  getErrorCode: (error?: any) => string;
31
- printError: (error?: any) => any;
26
+ printError: (error?: any) => string;
32
27
  };
33
28
  export default useResponseError;