@getsoren/shared-module 2.43.4
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/LICENSE +21 -0
- package/README.md +154 -0
- package/dist/axios/axiosCustomInstance.d.ts +5 -0
- package/dist/axiosCustomInstance.ts +23 -0
- package/dist/chat/ChatClient.d.ts +35 -0
- package/dist/chat/tests/ChatClient.test.d.ts +1 -0
- package/dist/chat/types.d.ts +116 -0
- package/dist/components/Inputs/MaskTextField.d.ts +32 -0
- package/dist/components/Utils/GTMSendPageView.d.ts +23 -0
- package/dist/components/Utils/InitializeAmplitude.d.ts +27 -0
- package/dist/components/Utils/InitializeAxiosConfig.d.ts +41 -0
- package/dist/components/Utils/InitializeDaysJSConfig.d.ts +27 -0
- package/dist/components/Utils/InitializeHubSpot.d.ts +27 -0
- package/dist/components/Utils/InitializeI18nConfig.d.ts +26 -0
- package/dist/components/Utils/InitializeSentryConfig.d.ts +81 -0
- package/dist/components/Utils/RequireAuth.d.ts +48 -0
- package/dist/components/Utils/ShowHubSpotBubble.d.ts +10 -0
- package/dist/config/orval/index.d.ts +2 -0
- package/dist/config/orval/orval.d.ts +81 -0
- package/dist/config/orval/orval.test.d.ts +1 -0
- package/dist/constants/hubspot.d.ts +12 -0
- package/dist/context/ChatProvider.d.ts +33 -0
- package/dist/context/InjectDependenciesProvider.d.ts +72 -0
- package/dist/context/QueryClientProviderWithConfig.d.ts +26 -0
- package/dist/hooks/tests/useFilters.test.d.ts +1 -0
- package/dist/hooks/useAdapter.d.ts +22 -0
- package/dist/hooks/useAmplitude.d.ts +16 -0
- package/dist/hooks/useAuth.d.ts +20 -0
- package/dist/hooks/useChat.d.ts +13 -0
- package/dist/hooks/useCurrentLanguage/useCurrentLanguage.d.ts +13 -0
- package/dist/hooks/useCurrentLanguage/useCurrentLanguage.test.d.ts +1 -0
- package/dist/hooks/useFilters.d.ts +44 -0
- package/dist/hooks/useHubSpot.d.ts +9 -0
- package/dist/hooks/useInfiniteDataGrid.d.ts +30 -0
- package/dist/hooks/useResponseError/useResponseError.d.ts +33 -0
- package/dist/hooks/useResponseError/useResponseError.test.d.ts +1 -0
- package/dist/main.d.ts +52 -0
- package/dist/main.js +823 -0
- package/dist/utils/adapter/dateAdapter.d.ts +17 -0
- package/dist/utils/adapter/distanceAdapter.d.ts +12 -0
- package/dist/utils/adapter/worksiteNameAdapter/worksiteNameAdapter.d.ts +9 -0
- package/dist/utils/adapter/worksiteNameAdapter/worksiteNameAdapter.test.d.ts +1 -0
- package/dist/utils/isReactNative.d.ts +5 -0
- package/dist/utils/lazyWithRetry.d.ts +18 -0
- package/package.json +117 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
|
|
3
|
+
export interface RequireAuthProps {
|
|
4
|
+
/**
|
|
5
|
+
* Axios library
|
|
6
|
+
*/
|
|
7
|
+
axios?: NonNullable<InjectDependenciesContextProps["libraries"]>["axios"];
|
|
8
|
+
/**
|
|
9
|
+
* React router is a libraries dependencies
|
|
10
|
+
*/
|
|
11
|
+
reactRouter?: NonNullable<InjectDependenciesContextProps["libraries"]>["reactRouter"];
|
|
12
|
+
/**
|
|
13
|
+
* Is user logged in
|
|
14
|
+
*/
|
|
15
|
+
isLogged?: () => {
|
|
16
|
+
isLogged: boolean;
|
|
17
|
+
} | boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Login path
|
|
20
|
+
* @default /login
|
|
21
|
+
*/
|
|
22
|
+
loginPath?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Fallback component for Suspense
|
|
25
|
+
*/
|
|
26
|
+
Fallback?: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Local storage key for user data
|
|
29
|
+
* @default user
|
|
30
|
+
*/
|
|
31
|
+
localStorageKey?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Redirect path for 401 responses
|
|
34
|
+
* @default /login
|
|
35
|
+
*/
|
|
36
|
+
redirect401Path?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* RequireAuth component for protected routing
|
|
40
|
+
* @param Fallback
|
|
41
|
+
* @param isLogged
|
|
42
|
+
* @param loginPath
|
|
43
|
+
* @param redirect401Path
|
|
44
|
+
* @param props
|
|
45
|
+
* @constructor
|
|
46
|
+
*/
|
|
47
|
+
declare const RequireAuth: ({ Fallback, isLogged, loginPath, redirect401Path, ...props }: RequireAuthProps) => import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
export default RequireAuth;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount inside a page to make the HubSpot launcher bubble visible there.
|
|
3
|
+
* Unmount restores the default hidden state (set by `<InitializeHubSpot />`).
|
|
4
|
+
*
|
|
5
|
+
* A module-level registry tolerates multiple simultaneous instances
|
|
6
|
+
* (nested layouts, route transitions) — the attribute is only restored
|
|
7
|
+
* when the last instance unmounts.
|
|
8
|
+
*/
|
|
9
|
+
declare const ShowHubSpotBubble: () => null;
|
|
10
|
+
export default ShowHubSpotBubble;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
interface CustomOrvalConfig {
|
|
2
|
+
/**
|
|
3
|
+
* Path to the openapi file(s)
|
|
4
|
+
* @default "./openapi.json"
|
|
5
|
+
*/
|
|
6
|
+
input?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Output configuration
|
|
9
|
+
*/
|
|
10
|
+
output?: {
|
|
11
|
+
/**
|
|
12
|
+
* Path to the folder where you want to generate all your models.
|
|
13
|
+
* @default to "src/api/model"
|
|
14
|
+
*/
|
|
15
|
+
schemas?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Path to the file which will contains the implementation.
|
|
18
|
+
* @default "src/api/services/api.ts"
|
|
19
|
+
*/
|
|
20
|
+
target?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Give you the possibility to set base url to your mock handlers.
|
|
23
|
+
*/
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* List of operations to use an infinite query
|
|
28
|
+
*/
|
|
29
|
+
useInfiniteIds?: string[];
|
|
30
|
+
/**
|
|
31
|
+
* List of operations to force query
|
|
32
|
+
* Like POST requests that you want to use with useQuery instead of useMutation
|
|
33
|
+
*/
|
|
34
|
+
useQueryIds?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* A custom Axios instance to be used instead of the default one provided by us.
|
|
37
|
+
* This is useful to define dynamic baseUrl in the axios default instance.
|
|
38
|
+
*/
|
|
39
|
+
customAxiosInstancePath?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The default API name inferred from the "filename".
|
|
42
|
+
* Orval can also retrieve OAS from a fully formed URL.
|
|
43
|
+
*/
|
|
44
|
+
overrideApiName?: string;
|
|
45
|
+
}
|
|
46
|
+
interface OrvalConfig {
|
|
47
|
+
[key: string]: CustomOrvalConfig;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Convert a string to capitalize
|
|
51
|
+
* @param method
|
|
52
|
+
*/
|
|
53
|
+
export declare const convertToCapitalize: (method: string) => string;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieve the filename in a given OS path minus the file extension.
|
|
56
|
+
* @param fullPath
|
|
57
|
+
*/
|
|
58
|
+
export declare const getFileNameWithoutExtension: (fullPath: string) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Convert a route to camelCase
|
|
61
|
+
* @param route
|
|
62
|
+
*/
|
|
63
|
+
export declare const convertRouteToCamelCase: (route: string) => string;
|
|
64
|
+
/**
|
|
65
|
+
* Generate the key name for orval output
|
|
66
|
+
* @param input
|
|
67
|
+
*/
|
|
68
|
+
export declare const generateApiName: (input: string) => string;
|
|
69
|
+
/**
|
|
70
|
+
* Generate the operation name for orval output
|
|
71
|
+
* @param operation
|
|
72
|
+
* @param route
|
|
73
|
+
* @param verb
|
|
74
|
+
* @param useQueryIds
|
|
75
|
+
*/
|
|
76
|
+
export declare const getOrvalOperationName: (operation: unknown, route: string, verb: string, useQueryIds?: string[]) => string;
|
|
77
|
+
/**
|
|
78
|
+
* Get the orval config required for the generation
|
|
79
|
+
*/
|
|
80
|
+
export declare const getOrvalConfig: (config?: CustomOrvalConfig | CustomOrvalConfig[]) => OrvalConfig;
|
|
81
|
+
export default getOrvalConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ID of the HubSpot chat widget container element in the DOM
|
|
3
|
+
*/
|
|
4
|
+
export declare const HUBSPOT_CONTAINER_ID = "hubspot-messages-iframe-container";
|
|
5
|
+
/**
|
|
6
|
+
* CSS class added to the container to make the widget visible
|
|
7
|
+
*/
|
|
8
|
+
export declare const HUBSPOT_SHOW_CLASS = "hs-show";
|
|
9
|
+
/**
|
|
10
|
+
* HTML attribute toggled on `<html>` to hide the default launcher bubble
|
|
11
|
+
*/
|
|
12
|
+
export declare const HUBSPOT_HIDDEN_ATTR = "data-hs-hidden";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { ServerEvent } from '../chat/types';
|
|
3
|
+
type EventListener = (event: ServerEvent) => void;
|
|
4
|
+
type ChatContext = "client" | "supplier";
|
|
5
|
+
export interface ChatProviderProps {
|
|
6
|
+
token?: string | null;
|
|
7
|
+
url?: string;
|
|
8
|
+
context?: ChatContext;
|
|
9
|
+
wsPath?: string;
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
reconnect?: boolean;
|
|
12
|
+
maxReconnectAttempts?: number;
|
|
13
|
+
reconnectBaseDelay?: number;
|
|
14
|
+
maxMessageBodyLength?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ChatContextValue {
|
|
17
|
+
isConnected: boolean;
|
|
18
|
+
isReady: boolean;
|
|
19
|
+
unreadCount: number;
|
|
20
|
+
incrementUnreadCount: (amount?: number) => void;
|
|
21
|
+
decrementUnreadCount: (amount?: number) => void;
|
|
22
|
+
subscribe: (callback: EventListener) => () => void;
|
|
23
|
+
joinThread: (threadId: string) => void;
|
|
24
|
+
leaveThread: (threadId: string) => void;
|
|
25
|
+
listThreads: (limit?: number, offset?: number) => void;
|
|
26
|
+
markRead: (threadId: string) => void;
|
|
27
|
+
sendMessage: (threadId: string, body: string) => void;
|
|
28
|
+
disconnect: () => void;
|
|
29
|
+
setEnabled: (enabled: boolean) => void;
|
|
30
|
+
}
|
|
31
|
+
export declare const ChatContext: import('react').Context<ChatContextValue | null>;
|
|
32
|
+
declare const ChatProvider: ({ children, token, url, wsPath, maxReconnectAttempts, reconnectBaseDelay, maxMessageBodyLength, reconnect, enabled: enabledProp, context, }: PropsWithChildren<ChatProviderProps>) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export default ChatProvider;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { sessionReplayPlugin } from '@amplitude/plugin-session-replay-browser';
|
|
2
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
3
|
+
import { useGoogleTagManager } from '@getsoren/react-google-tag-manager';
|
|
4
|
+
import { AxiosInstance } from 'axios';
|
|
5
|
+
import { default as dayjs, PluginFunc } from 'dayjs';
|
|
6
|
+
import { i18n, TFunction } from 'i18next';
|
|
7
|
+
import { default as LanguageDetector } from 'i18next-browser-languagedetector';
|
|
8
|
+
import { ReactNode } from 'react';
|
|
9
|
+
import { initReactI18next } from 'react-i18next';
|
|
10
|
+
import type * as amplitudeAnalytics from "@amplitude/analytics-browser";
|
|
11
|
+
import type * as Sentry from "@sentry/react";
|
|
12
|
+
import type * as ReactRouter from "react-router";
|
|
13
|
+
export interface InjectDependenciesContextProps {
|
|
14
|
+
/**
|
|
15
|
+
* Children
|
|
16
|
+
*/
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* API URL dependency for useAdapter hook
|
|
20
|
+
*/
|
|
21
|
+
apiURL?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Local storage keys
|
|
24
|
+
*/
|
|
25
|
+
localStorageKeys?: {
|
|
26
|
+
/**
|
|
27
|
+
* Local storage key for filters, used in useFilters hook
|
|
28
|
+
*/
|
|
29
|
+
filter?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Local storage key for user, used in useUser hook
|
|
32
|
+
*/
|
|
33
|
+
user?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* List of dependencies for libraries
|
|
37
|
+
*/
|
|
38
|
+
libraries?: {
|
|
39
|
+
amplitude?: {
|
|
40
|
+
analytics?: typeof amplitudeAnalytics;
|
|
41
|
+
sessionReplayPlugin?: typeof sessionReplayPlugin;
|
|
42
|
+
};
|
|
43
|
+
axios?: AxiosInstance;
|
|
44
|
+
dayjs?: typeof dayjs;
|
|
45
|
+
dayjsPlugin?: PluginFunc<any>[];
|
|
46
|
+
gtm?: {
|
|
47
|
+
useGoogleTagManager: typeof useGoogleTagManager;
|
|
48
|
+
};
|
|
49
|
+
reactRouter?: typeof ReactRouter;
|
|
50
|
+
sentry?: typeof Sentry;
|
|
51
|
+
i18?: {
|
|
52
|
+
i18next?: i18n;
|
|
53
|
+
initReactI18next?: typeof initReactI18next;
|
|
54
|
+
languageDetector?: typeof LanguageDetector;
|
|
55
|
+
translateFunction?: TFunction;
|
|
56
|
+
};
|
|
57
|
+
reactQuery?: {
|
|
58
|
+
QueryClientProvider: typeof QueryClientProvider;
|
|
59
|
+
QueryClient: typeof QueryClient;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export declare const InjectDependenciesContext: import('react').Context<InjectDependenciesContextProps>;
|
|
64
|
+
/**
|
|
65
|
+
* This provider is used to inject major dependencies
|
|
66
|
+
* @param children
|
|
67
|
+
* @param librariesDependencies
|
|
68
|
+
* @param apiURL
|
|
69
|
+
* @constructor
|
|
70
|
+
*/
|
|
71
|
+
declare const InjectDependenciesProvider: ({ children, apiURL, libraries, localStorageKeys }: InjectDependenciesContextProps) => import("react/jsx-runtime").JSX.Element;
|
|
72
|
+
export default InjectDependenciesProvider;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { InjectDependenciesContextProps } from './InjectDependenciesProvider';
|
|
3
|
+
interface QueryProviderProps extends PropsWithChildren {
|
|
4
|
+
/**
|
|
5
|
+
* QueryClientProvider from react-query
|
|
6
|
+
*/
|
|
7
|
+
QueryClientProvider?: NonNullable<NonNullable<InjectDependenciesContextProps["libraries"]>["reactQuery"]>["QueryClientProvider"];
|
|
8
|
+
/**
|
|
9
|
+
* QueryClient from react-query
|
|
10
|
+
*/
|
|
11
|
+
QueryClient?: NonNullable<NonNullable<InjectDependenciesContextProps["libraries"]>["reactQuery"]>["QueryClient"];
|
|
12
|
+
/**
|
|
13
|
+
* Default options for queries
|
|
14
|
+
*/
|
|
15
|
+
defaultQueriesOptions?: {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Default options for mutations
|
|
20
|
+
*/
|
|
21
|
+
defaultMutationsOptions?: {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
declare const QueryProvider: ({ children, defaultQueriesOptions, defaultMutationsOptions, ...props }: QueryProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export default QueryProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InjectDependenciesContextProps } from '../context/InjectDependenciesProvider';
|
|
2
|
+
export interface useAdapterParams {
|
|
3
|
+
/**
|
|
4
|
+
* Dayjs library
|
|
5
|
+
*/
|
|
6
|
+
dayjs?: NonNullable<InjectDependenciesContextProps["libraries"]>["dayjs"];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Use adapter
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare const useAdapter: (params?: useAdapterParams) => {
|
|
13
|
+
dateAdapter: (date: string | number | Date | null | undefined, format?: string) => string;
|
|
14
|
+
distanceAdapter: (distance?: string | number | null, options?: {
|
|
15
|
+
fractionDigits?: number;
|
|
16
|
+
metric?: string;
|
|
17
|
+
spacingBetween?: boolean;
|
|
18
|
+
}) => string;
|
|
19
|
+
filePathAdapter: (path?: string | null, size?: number | "full") => string;
|
|
20
|
+
worksiteNameAdapter: (name: unknown) => string;
|
|
21
|
+
};
|
|
22
|
+
export default useAdapter;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type * as amplitudeAnalytics from "@amplitude/analytics-browser";
|
|
2
|
+
type AmplitudePropertyValue = amplitudeAnalytics.Types.ValidPropertyType;
|
|
3
|
+
type AmplitudeProperties = Record<string, AmplitudePropertyValue>;
|
|
4
|
+
/**
|
|
5
|
+
* Hook exposing helpers around the Amplitude SDK.
|
|
6
|
+
* Requires `amplitude.analytics` to be injected via `InjectDependenciesProvider`
|
|
7
|
+
* and `InitializeAmplitude` to be mounted higher in the tree.
|
|
8
|
+
* Calls are no-ops when analytics is missing (dev builds without a key).
|
|
9
|
+
*/
|
|
10
|
+
declare const useAmplitude: () => {
|
|
11
|
+
identify: (userId: string, userProperties?: AmplitudeProperties) => void;
|
|
12
|
+
reset: () => void;
|
|
13
|
+
setGroup: (groupType: string, groupName: string, groupProperties?: AmplitudeProperties) => void;
|
|
14
|
+
track: (eventName: string, eventProperties?: AmplitudeProperties) => void;
|
|
15
|
+
};
|
|
16
|
+
export default useAmplitude;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InjectDependenciesContextProps } from '../context/InjectDependenciesProvider';
|
|
2
|
+
interface useAuthParams {
|
|
3
|
+
/**
|
|
4
|
+
* Axios library
|
|
5
|
+
*/
|
|
6
|
+
axios?: NonNullable<InjectDependenciesContextProps["libraries"]>["axios"];
|
|
7
|
+
/**
|
|
8
|
+
* Local storage key
|
|
9
|
+
* @default user
|
|
10
|
+
*/
|
|
11
|
+
localStorageKey?: string;
|
|
12
|
+
}
|
|
13
|
+
declare const useAuth: (params?: useAuthParams) => {
|
|
14
|
+
clearAuthenticationToken: () => void;
|
|
15
|
+
setAuthenticationToken: ({ tokenType, accessToken }: {
|
|
16
|
+
tokenType: string;
|
|
17
|
+
accessToken: string;
|
|
18
|
+
}) => void;
|
|
19
|
+
};
|
|
20
|
+
export default useAuth;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UseChatParams } from '../chat/types';
|
|
2
|
+
import { ChatContextValue } from '../context/ChatProvider';
|
|
3
|
+
type UseChatReturn = Omit<ChatContextValue, "subscribe" | "setEnabled">;
|
|
4
|
+
/**
|
|
5
|
+
* Hook to access the shared WebSocket chat connection.
|
|
6
|
+
* Provides methods to join/leave threads, send messages, mark as read, and list threads.
|
|
7
|
+
* Accepts optional event handlers (onNewMessage, onNewMessageNotification, etc.).
|
|
8
|
+
* Accepts an optional `enabled` flag to control the WebSocket connection from the consumer.
|
|
9
|
+
* Accepts an optional `browserNotification` flag to show native browser notifications on new messages.
|
|
10
|
+
* Must be used within a ChatProvider.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useChat: (params?: UseChatParams) => UseChatReturn;
|
|
13
|
+
export default useChat;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface useCurrentLanguageParams {
|
|
2
|
+
language?: string;
|
|
3
|
+
on?: (event: string, callback: (language: string) => void) => void;
|
|
4
|
+
off?: (event: string, callback: (language: string) => void) => void;
|
|
5
|
+
}
|
|
6
|
+
type LocaleType = "short" | "full";
|
|
7
|
+
/**
|
|
8
|
+
* Hook to get the current language
|
|
9
|
+
* @param i18
|
|
10
|
+
* @param localeType
|
|
11
|
+
*/
|
|
12
|
+
declare const useCurrentLanguage: (i18?: useCurrentLanguageParams, localeType?: LocaleType) => string;
|
|
13
|
+
export default useCurrentLanguage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SyntheticEvent } from 'react';
|
|
2
|
+
import { InjectDependenciesContextProps } from '../context/InjectDependenciesProvider';
|
|
3
|
+
interface useFiltersOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Pathname to store filters
|
|
6
|
+
* Defined to set filters for different pages to store in local storage
|
|
7
|
+
* @example If you want same filter for "/deals", "/deals/planning" and "/deals/list"
|
|
8
|
+
* Then you can define pathname "useFilters({ pathname: "/deals" })" and filter will be shared between these pages
|
|
9
|
+
* @default pathname from useLocation
|
|
10
|
+
*/
|
|
11
|
+
pathname?: string;
|
|
12
|
+
/**
|
|
13
|
+
* React Router library
|
|
14
|
+
*/
|
|
15
|
+
reactRouter?: NonNullable<InjectDependenciesContextProps["libraries"]>["reactRouter"];
|
|
16
|
+
/**
|
|
17
|
+
* Enable URL synchronization for filters
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
syncWithUrl?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Enable persistence to localStorage
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
persistToLocalStorage?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Hook to handle filter
|
|
29
|
+
* @param options
|
|
30
|
+
*/
|
|
31
|
+
declare const useFilters: (options?: useFiltersOptions) => {
|
|
32
|
+
readonly getFilter: () => undefined;
|
|
33
|
+
readonly getFilters: () => {};
|
|
34
|
+
readonly handleFilter: () => () => void;
|
|
35
|
+
readonly setFilter: () => void;
|
|
36
|
+
} | {
|
|
37
|
+
getFilter: <T = string, DefaultValue = undefined>(name: string, defaultValue?: T) => DefaultValue extends undefined ? T | undefined : T;
|
|
38
|
+
getFilters: () => {
|
|
39
|
+
[x: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
handleFilter: <T>(name: string, key?: string) => (_: SyntheticEvent, value?: T) => void;
|
|
42
|
+
setFilter: (name: string, value: unknown, persist?: boolean) => void;
|
|
43
|
+
};
|
|
44
|
+
export default useFilters;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to interact with the HubSpot chat widget.
|
|
3
|
+
* Returns `isAvailable` (true once HubSpot is loaded) and `toggle` to open/close the chat.
|
|
4
|
+
*/
|
|
5
|
+
declare const useHubSpot: () => {
|
|
6
|
+
isAvailable: boolean;
|
|
7
|
+
toggle: () => void;
|
|
8
|
+
};
|
|
9
|
+
export default useHubSpot;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface useInfiniteDataGridParams<T> {
|
|
2
|
+
data?: {
|
|
3
|
+
pages: T[];
|
|
4
|
+
};
|
|
5
|
+
fetchNextPage: (fetchNextPageOptions?: any) => Promise<any>;
|
|
6
|
+
isFetchingNextPage: boolean;
|
|
7
|
+
isInitialLoading: boolean;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface GridRowScrollEndParams {
|
|
12
|
+
visibleRowsCount: number;
|
|
13
|
+
pageParam?: unknown;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* This hook is used to handle the infinite scroll of the DataGrid component.
|
|
17
|
+
* @param data
|
|
18
|
+
* @param fetchNextPage
|
|
19
|
+
* @param isFetchingNextPage
|
|
20
|
+
* @param isInitialLoading
|
|
21
|
+
* @param isLoading
|
|
22
|
+
* @param enabled
|
|
23
|
+
*/
|
|
24
|
+
declare const useInfiniteDataGrid: <T>({ data, fetchNextPage, isFetchingNextPage, isInitialLoading, isLoading, enabled, }: useInfiniteDataGridParams<T>) => {
|
|
25
|
+
fetchNextPageOnRowsScrollEnd: (params: GridRowScrollEndParams) => Promise<void>;
|
|
26
|
+
isLoading: boolean;
|
|
27
|
+
loadingVariant: "skeleton" | "linear-progress";
|
|
28
|
+
rows: T | undefined;
|
|
29
|
+
};
|
|
30
|
+
export default useInfiniteDataGrid;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
|
|
2
|
+
export interface ResponseError {
|
|
3
|
+
data?: {
|
|
4
|
+
code?: number;
|
|
5
|
+
message?: string;
|
|
6
|
+
payload?: any;
|
|
7
|
+
reason?: string;
|
|
8
|
+
detail?: {
|
|
9
|
+
loc?: [];
|
|
10
|
+
msg?: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface useResponseErrorParams {
|
|
16
|
+
/**
|
|
17
|
+
* i18 library
|
|
18
|
+
*/
|
|
19
|
+
i18?: NonNullable<InjectDependenciesContextProps["libraries"]>["i18"];
|
|
20
|
+
/**
|
|
21
|
+
* Translation key returned for the unknown error
|
|
22
|
+
*/
|
|
23
|
+
unknownErrorTranslationKey?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* This hook is used to print error messages from the API
|
|
27
|
+
* @param params
|
|
28
|
+
*/
|
|
29
|
+
export declare const useResponseError: <T = ResponseError>(params?: useResponseErrorParams) => {
|
|
30
|
+
getErrorCode: (error?: T | any) => string;
|
|
31
|
+
printError: (error?: T | unknown) => string;
|
|
32
|
+
};
|
|
33
|
+
export default useResponseError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export { axiosCustomInstance, type BodyType, type ErrorType } from './axios/axiosCustomInstance';
|
|
2
|
+
export { default as ChatClient } from './chat/ChatClient';
|
|
3
|
+
export * from './chat/types';
|
|
4
|
+
export * from './components/Inputs/MaskTextField';
|
|
5
|
+
export { default as MaskTextField } from './components/Inputs/MaskTextField';
|
|
6
|
+
export * from './components/Utils/GTMSendPageView';
|
|
7
|
+
export { default as GTMSendPageView } from './components/Utils/GTMSendPageView';
|
|
8
|
+
export * from './components/Utils/InitializeAmplitude';
|
|
9
|
+
export { default as InitializeAmplitude } from './components/Utils/InitializeAmplitude';
|
|
10
|
+
export * from './components/Utils/InitializeAxiosConfig';
|
|
11
|
+
export { default as InitializeAxiosConfig } from './components/Utils/InitializeAxiosConfig';
|
|
12
|
+
export * from './components/Utils/InitializeDaysJSConfig';
|
|
13
|
+
export { default as InitializeDaysJSConfig } from './components/Utils/InitializeDaysJSConfig';
|
|
14
|
+
export * from './components/Utils/InitializeHubSpot';
|
|
15
|
+
export { default as InitializeHubSpot } from './components/Utils/InitializeHubSpot';
|
|
16
|
+
export * from './components/Utils/InitializeI18nConfig';
|
|
17
|
+
export { default as InitializeI18nConfig } from './components/Utils/InitializeI18nConfig';
|
|
18
|
+
export * from './components/Utils/InitializeSentryConfig';
|
|
19
|
+
export { default as InitializeSentryConfig } from './components/Utils/InitializeSentryConfig';
|
|
20
|
+
export * from './components/Utils/RequireAuth';
|
|
21
|
+
export { default as RequireAuth } from './components/Utils/RequireAuth';
|
|
22
|
+
export * from './components/Utils/ShowHubSpotBubble';
|
|
23
|
+
export { default as ShowHubSpotBubble } from './components/Utils/ShowHubSpotBubble';
|
|
24
|
+
export * from './config/orval';
|
|
25
|
+
export { default as getOrvalConfig } from './config/orval';
|
|
26
|
+
export * from './context/ChatProvider';
|
|
27
|
+
export { default as ChatProvider } from './context/ChatProvider';
|
|
28
|
+
export * from './context/InjectDependenciesProvider';
|
|
29
|
+
export { default as InjectDependenciesProvider } from './context/InjectDependenciesProvider';
|
|
30
|
+
export { default as QueryProvider } from './context/QueryClientProviderWithConfig';
|
|
31
|
+
export * from './hooks/useAdapter';
|
|
32
|
+
export { default as useAdapter } from './hooks/useAdapter';
|
|
33
|
+
export * from './hooks/useAmplitude';
|
|
34
|
+
export { default as useAmplitude } from './hooks/useAmplitude';
|
|
35
|
+
export * from './hooks/useAuth';
|
|
36
|
+
export { default as useAuth } from './hooks/useAuth';
|
|
37
|
+
export * from './hooks/useChat';
|
|
38
|
+
export { default as useChat } from './hooks/useChat';
|
|
39
|
+
export * from './hooks/useCurrentLanguage/useCurrentLanguage';
|
|
40
|
+
export { default as useCurrentLanguage } from './hooks/useCurrentLanguage/useCurrentLanguage';
|
|
41
|
+
export * from './hooks/useFilters';
|
|
42
|
+
export { default as useFilters } from './hooks/useFilters';
|
|
43
|
+
export * from './hooks/useHubSpot';
|
|
44
|
+
export { default as useHubSpot } from './hooks/useHubSpot';
|
|
45
|
+
export * from './hooks/useInfiniteDataGrid';
|
|
46
|
+
export { default as useInfiniteDataGrid } from './hooks/useInfiniteDataGrid';
|
|
47
|
+
export * from './hooks/useResponseError/useResponseError';
|
|
48
|
+
export { default as useResponseError } from './hooks/useResponseError/useResponseError';
|
|
49
|
+
export { default as dateAdapter } from './utils/adapter/dateAdapter';
|
|
50
|
+
export { default as distanceAdapter } from './utils/adapter/distanceAdapter';
|
|
51
|
+
export { default as worksiteNameAdapter } from './utils/adapter/worksiteNameAdapter/worksiteNameAdapter';
|
|
52
|
+
export { default as lazyWithRetry } from './utils/lazyWithRetry';
|