@medipha/chat 1.0.14 → 1.0.15

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
@@ -1,103 +1,103 @@
1
- # @medipha/chat
2
-
3
- `@medipha/chat` is an embeddable React chat module for Medic-ERP. It uses the
4
- ERP application's React tree, BrowserRouter, authentication, and Ant Design 4
5
- installation; it does not use an iframe or create a router.
6
-
7
- ## Install
8
-
9
- ```bash
10
- pnpm add @medipha/chat
11
- ```
12
-
13
- ## Mount in Medic-ERP
14
-
15
- The ERP imports the Ant Design 4 stylesheet exactly once, at its application
16
- entry point. The chat library deliberately does not import it.
17
-
18
- ```tsx
19
- import 'antd/dist/antd.css';
20
- import { ChatModule } from '@medipha/chat';
21
- import '@medipha/chat/styles.css';
22
-
23
- <Route
24
- path="/chat-erp/*"
25
- element={
26
- <ChatModule
27
- accessToken={accessToken}
28
- apiUrl={CHAT_API_URL}
29
- socketUrl={CHAT_SOCKET_URL}
30
- onUnauthorized={handleUnauthorized}
31
- onNavigateOutsideChat={handleNavigateOutsideChat}
32
- />
33
- }
34
- />;
35
- ```
36
-
37
- The ERP must own the surrounding `BrowserRouter`. `ChatModule` adds only
38
- relative routes: `/chat-erp` for the conversation list and
39
- `/chat-erp/:conversationId` for a room.
40
-
41
- ## `ChatModuleProps`
42
-
43
- | Prop | Required | Meaning |
44
- | ----------------------- | -------- | --------------------------------------------------------- |
45
- | `accessToken` | Yes | Current ERP access token used by chat API/socket clients. |
46
- | `apiUrl` | Yes | Base URL for the Chat HTTP API. |
47
- | `socketUrl` | Yes | Socket server URL. |
48
- | `onUnauthorized` | No | ERP callback for an unauthorized chat response. |
49
- | `onNavigateOutsideChat` | No | ERP callback for navigation that leaves chat. |
50
-
51
- Pass a new `accessToken` prop whenever ERP refreshes its credential.
52
- `ChatModule` updates its internal runtime context from the new prop and never
53
- writes a token to `localStorage` or `sessionStorage`.
54
-
55
- ## Nginx SPA fallback
56
-
57
- Configure the ERP server so deep links under `/chat-erp/*` return the ERP
58
- application entry file:
59
-
60
- ```nginx
61
- location / {
62
- try_files $uri $uri/ /index.html;
63
- }
64
- ```
65
-
66
- ## Development and validation
67
-
68
- Vite 8 requires Node.js `20.19+` or `22.12+`.
69
-
70
- ```bash
71
- pnpm install
72
- pnpm dev
73
- ```
74
-
75
- `pnpm dev` opens the root development playground. It loads `ChatModule`
76
- directly from `src`, so library code and CSS changes use Vite HMR without a
77
- library build after every edit. The playground's `BrowserRouter` is
78
- development-only; it is not part of the published package.
79
-
80
- To validate the publishable library:
81
-
82
- ```bash
83
- pnpm typecheck
84
- pnpm build
85
- npm pack --dry-run
86
- ```
87
-
88
- To verify the CRA host after building the library:
89
-
90
- ```bash
91
- cd examples/erp-host
92
- pnpm install
93
- pnpm build
94
- ```
95
-
96
- ## Publish
97
-
98
- Publish `@medipha/chat-core` before `@medipha/chat`. GitLab CI uses a masked,
99
- protected `NPM_TOKEN` variable with npm publish permission and runs only for a
100
- version tag such as `v0.1.0`. Update versions using semantic versioning: patch
101
- for fixes, minor for backward-compatible features, and major for breaking API
102
- changes. Create and push the version tag through your normal release process
103
- after reviewing the working tree.
1
+ # @medipha/chat
2
+
3
+ `@medipha/chat` is an embeddable React chat module for Medic-ERP. It uses the
4
+ ERP application's React tree, BrowserRouter, authentication, and Ant Design 4
5
+ installation; it does not use an iframe or create a router.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @medipha/chat
11
+ ```
12
+
13
+ ## Mount in Medic-ERP
14
+
15
+ The ERP imports the Ant Design 4 stylesheet exactly once, at its application
16
+ entry point. The chat library deliberately does not import it.
17
+
18
+ ```tsx
19
+ import 'antd/dist/antd.css';
20
+ import { ChatModule } from '@medipha/chat';
21
+ import '@medipha/chat/styles.css';
22
+
23
+ <Route
24
+ path="/chat-erp/*"
25
+ element={
26
+ <ChatModule
27
+ accessToken={accessToken}
28
+ apiUrl={CHAT_API_URL}
29
+ socketUrl={CHAT_SOCKET_URL}
30
+ onUnauthorized={handleUnauthorized}
31
+ onNavigateOutsideChat={handleNavigateOutsideChat}
32
+ />
33
+ }
34
+ />;
35
+ ```
36
+
37
+ The ERP must own the surrounding `BrowserRouter`. `ChatModule` adds only
38
+ relative routes: `/chat-erp` for the conversation list and
39
+ `/chat-erp/:conversationId` for a room.
40
+
41
+ ## `ChatModuleProps`
42
+
43
+ | Prop | Required | Meaning |
44
+ | ----------------------- | -------- | --------------------------------------------------------- |
45
+ | `accessToken` | Yes | Current ERP access token used by chat API/socket clients. |
46
+ | `apiUrl` | Yes | Base URL for the Chat HTTP API. |
47
+ | `socketUrl` | Yes | Socket server URL. |
48
+ | `onUnauthorized` | No | ERP callback for an unauthorized chat response. |
49
+ | `onNavigateOutsideChat` | No | ERP callback for navigation that leaves chat. |
50
+
51
+ Pass a new `accessToken` prop whenever ERP refreshes its credential.
52
+ `ChatModule` updates its internal runtime context from the new prop and never
53
+ writes a token to `localStorage` or `sessionStorage`.
54
+
55
+ ## Nginx SPA fallback
56
+
57
+ Configure the ERP server so deep links under `/chat-erp/*` return the ERP
58
+ application entry file:
59
+
60
+ ```nginx
61
+ location / {
62
+ try_files $uri $uri/ /index.html;
63
+ }
64
+ ```
65
+
66
+ ## Development and validation
67
+
68
+ Vite 8 requires Node.js `20.19+` or `22.12+`.
69
+
70
+ ```bash
71
+ pnpm install
72
+ pnpm dev
73
+ ```
74
+
75
+ `pnpm dev` opens the root development playground. It loads `ChatModule`
76
+ directly from `src`, so library code and CSS changes use Vite HMR without a
77
+ library build after every edit. The playground's `BrowserRouter` is
78
+ development-only; it is not part of the published package.
79
+
80
+ To validate the publishable library:
81
+
82
+ ```bash
83
+ pnpm typecheck
84
+ pnpm build
85
+ npm pack --dry-run
86
+ ```
87
+
88
+ To verify the CRA host after building the library:
89
+
90
+ ```bash
91
+ cd examples/erp-host
92
+ pnpm install
93
+ pnpm build
94
+ ```
95
+
96
+ ## Publish
97
+
98
+ Publish `@medipha/chat-core` before `@medipha/chat`. GitLab CI uses a masked,
99
+ protected `NPM_TOKEN` variable with npm publish permission and runs only for a
100
+ version tag such as `v0.1.0`. Update versions using semantic versioning: patch
101
+ for fixes, minor for backward-compatible features, and major for breaking API
102
+ changes. Create and push the version tag through your normal release process
103
+ after reviewing the working tree.
@@ -0,0 +1,8 @@
1
+ interface TypingIndicatorProps {
2
+ typingNames: string[];
3
+ }
4
+ /** Sits in normal flow between the timeline and the composer toolbar (Messenger/Zalo
5
+ * style) instead of floating over the message list — the name(s) typing, plus a small
6
+ * bubble of three bouncing dots standing in for "...". */
7
+ export declare function TypingIndicator({ typingNames }: TypingIndicatorProps): import("react/jsx-runtime").JSX.Element | null;
8
+ export {};