@tracktor/shared-module 2.31.0 → 2.33.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/README.md CHANGED
@@ -39,10 +39,10 @@ export default App;
39
39
  ```
40
40
 
41
41
  ## Providers
42
- | Module | Description | Dependencies |
43
- |-------------------------------|-----------------------------------------------------|--------------|
44
- | InjectDependenciesProvider | Inject dependencies for other shared component | - |
45
- | QueryClientProviderWithConfig | React Query provider with default config | React Query |
42
+ | Module | Description | Dependencies |
43
+ |-------------------------------|-------------------------------------------------------|--------------|
44
+ | InjectDependenciesProvider | Inject dependencies for other shared component | - |
45
+ | QueryClientProviderWithConfig | React Query provider with default config | React Query |
46
46
  | ChatProvider | Shared WebSocket chat connection provider via context | - |
47
47
 
48
48
 
@@ -56,22 +56,26 @@ export default App;
56
56
  | InitializeSentryConfig | React Component | Initialize Sentry | @sentry/react & react-router-dom |
57
57
  | InitializeMapBoxConfig | React Component | Initialize MapBox | mapbox-gl |
58
58
  | InitializeDaysJSConfig | React Component | Initialize DayJS | dayjs |
59
+ | InitializeHubSpot | React Component | Initialize HubSpot chat widget | - |
59
60
  | PreloadErrorHandler | React Component | his component is used to handle preload error. | dayjs |
60
61
 
61
62
  ## Hooks
62
- | Module | Description | Dependencies |
63
- |---------------------|----------------------------------------------------------------------------|--------------|
64
- | useAdapter | Hook with several adapter | - |
65
- | useAuth | Hook for authentification management | Axios |
66
- | useResponseError | This hook is used to print error messages from the API | i18next |
67
- | useInfiniteDataGrid | This hook is used to handle the infinite scroll of the DataGrid component. | - |
68
- | useCurrentLanguage | This get the current language of app | - |
69
- | useFilters | Hook to handle filter | - |
70
- | useChat | Hook to consume the ChatProvider context (threads, messaging, presence) | ChatProvider |
63
+ | Module | Description | Dependencies |
64
+ |---------------------|----------------------------------------------------------------------------|-------------------|
65
+ | useAdapter | Hook with several adapter | - |
66
+ | useAuth | Hook for authentification management | Axios |
67
+ | useHubSpot | Hook to interact with the HubSpot chat widget (toggle, availability) | InitializeHubSpot |
68
+ | useResponseError | This hook is used to print error messages from the API | i18next |
69
+ | useInfiniteDataGrid | This hook is used to handle the infinite scroll of the DataGrid component. | - |
70
+ | useCurrentLanguage | This get the current language of app | - |
71
+ | useFilters | Hook to handle filter | - |
72
+ | useChat | Hook to consume the ChatProvider context (threads, messaging, presence) | ChatProvider |
71
73
 
72
74
 
73
75
  ## WebSocket
74
76
 
77
+ ### Chat
78
+
75
79
  The chat module provides a WebSocket client for the Tracktor chat protocol (`/v2/threads/ws`). It supports thread subscription, messaging, read receipts, and presence events.
76
80
 
77
81
  **With the React provider** (recommended):
@@ -131,12 +135,11 @@ client.joinThread("thread-1");
131
135
  client.sendMessage("thread-1", "Hello!");
132
136
  ```
133
137
 
134
- ### Chat WebSocket
135
- | Module | Description | Dependencies |
136
- |------------|-----------------------------------------------------------|--------------|
137
- | ChatClient | Framework-agnostic WebSocket client for the chat protocol | - |
138
- | ChatProvider | Provider for shared WebSocket connection via context | - |
139
- | useChat | React hook to consume the ChatProvider context | ChatProvider |
138
+ | Module | Description | Dependencies |
139
+ |--------------|-----------------------------------------------------------|--------------|
140
+ | ChatClient | Framework-agnostic WebSocket client for the chat protocol | - |
141
+ | ChatProvider | Provider for shared WebSocket connection via context | - |
142
+ | useChat | React hook to consume the ChatProvider context | ChatProvider |
140
143
 
141
144
 
142
145
  ## Config
@@ -0,0 +1,25 @@
1
+ declare global {
2
+ interface Window {
3
+ hsConversationsOnReady?: Array<() => void>;
4
+ HubSpotConversations?: {
5
+ widget: {
6
+ close: () => void;
7
+ open: () => void;
8
+ };
9
+ on: (event: string, callback: () => void) => void;
10
+ };
11
+ }
12
+ }
13
+ interface InitializeHubSpotProps {
14
+ /**
15
+ * HubSpot account ID used to load the chat widget script
16
+ */
17
+ hubId: string;
18
+ }
19
+ /**
20
+ * Initializes the HubSpot chat widget by injecting the script and CSS.
21
+ * The default launcher bubble is hidden via CSS (div#id beats HubSpot's #id !important).
22
+ * Use the `useHubSpot` hook to interact with the widget.
23
+ */
24
+ declare const InitializeHubSpot: ({ hubId }: InitializeHubSpotProps) => null;
25
+ export default InitializeHubSpot;
@@ -0,0 +1,8 @@
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";
@@ -22,6 +22,7 @@ export interface ChatContextValue {
22
22
  listThreads: (limit?: number, offset?: number) => void;
23
23
  markRead: (threadId: string) => void;
24
24
  sendMessage: (threadId: string, body: string) => void;
25
+ disconnect: () => void;
25
26
  }
26
27
  export declare const ChatContext: import('react').Context<ChatContextValue | null>;
27
28
  declare const ChatProvider: ({ children, token, url, wsPath, reconnect, enabled, context, }: PropsWithChildren<ChatProviderProps>) => import("react/jsx-runtime").JSX.Element;
@@ -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;
package/dist/main.d.ts CHANGED
@@ -9,6 +9,8 @@ export * from './components/Utils/InitializeAxiosConfig';
9
9
  export { default as InitializeAxiosConfig } from './components/Utils/InitializeAxiosConfig';
10
10
  export * from './components/Utils/InitializeDaysJSConfig';
11
11
  export { default as InitializeDaysJSConfig } from './components/Utils/InitializeDaysJSConfig';
12
+ export * from './components/Utils/InitializeHubSpot';
13
+ export { default as InitializeHubSpot } from './components/Utils/InitializeHubSpot';
12
14
  export * from './components/Utils/InitializeI18nConfig';
13
15
  export { default as InitializeI18nConfig } from './components/Utils/InitializeI18nConfig';
14
16
  export * from './components/Utils/InitializeSentryConfig';
@@ -35,6 +37,8 @@ export * from './hooks/useCurrentLanguage/useCurrentLanguage';
35
37
  export { default as useCurrentLanguage } from './hooks/useCurrentLanguage/useCurrentLanguage';
36
38
  export * from './hooks/useFilters';
37
39
  export { default as useFilters } from './hooks/useFilters';
40
+ export * from './hooks/useHubSpot';
41
+ export { default as useHubSpot } from './hooks/useHubSpot';
38
42
  export * from './hooks/useInfiniteDataGrid';
39
43
  export { default as useInfiniteDataGrid } from './hooks/useInfiniteDataGrid';
40
44
  export * from './hooks/useResponseError/useResponseError';