@nabeh/chat-widget 0.1.2 → 0.1.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/README.md CHANGED
@@ -51,9 +51,64 @@ export class AppComponent implements AfterViewInit, OnDestroy {
51
51
  }
52
52
  ```
53
53
 
54
+ ## Angular Embedded Page Usage
55
+
56
+ Use `displayMode: 'embedded'` when the host application already owns the page shell and you only want the chat experience rendered inside a content area.
57
+
58
+ ```ts
59
+ import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from '@angular/core';
60
+ import { createChatWidget } from '@nabeh/chat-widget';
61
+
62
+ @Component({
63
+ selector: 'app-knowledge-assistant-page',
64
+ template: `<div #chatRoot class="knowledge-assistant-root"></div>`
65
+ })
66
+ export class KnowledgeAssistantPageComponent implements AfterViewInit, OnDestroy {
67
+ @ViewChild('chatRoot', { static: true })
68
+ private chatRoot?: ElementRef<HTMLElement>;
69
+
70
+ private widget?: ReturnType<typeof createChatWidget>;
71
+
72
+ ngAfterViewInit(): void {
73
+ if (!this.chatRoot?.nativeElement) {
74
+ return;
75
+ }
76
+
77
+ this.widget = createChatWidget({
78
+ apiBaseUrl: 'http://your-api-url',
79
+ displayMode: 'embedded',
80
+ mount: this.chatRoot.nativeElement,
81
+ embedded: {
82
+ showHeader: false
83
+ },
84
+ endpoints: {
85
+ ask: '/my-chats/:chatId/messages',
86
+ history: '/my-chats/:chatId/messages',
87
+ listChats: '/my-chats',
88
+ createChat: '/my-chats',
89
+ updateChat: '/my-chats/:chatId',
90
+ deleteChat: '/my-chats/:chatId'
91
+ },
92
+ rag: {
93
+ knowledgeNames: ['sample-kb'],
94
+ loadHistoryOnOpen: true
95
+ },
96
+ getUserContext: async () => ({
97
+ userId: 'your-user-id'
98
+ })
99
+ });
100
+ }
101
+
102
+ ngOnDestroy(): void {
103
+ this.widget?.destroy();
104
+ }
105
+ }
106
+ ```
107
+
54
108
  ## Configuration
55
109
 
56
110
  - `apiBaseUrl`: Backend base URL. Example: `https://api.example.com`
111
+ - `displayMode`: `widget` for the floating launcher, `embedded` for a full chat page rendered inside `mount`
57
112
  - `endpoints.ask`: Send-message endpoint
58
113
  - `endpoints.history`: Fetch chat history endpoint
59
114
  - `endpoints.listChats`: List chats endpoint
@@ -64,6 +119,7 @@ export class AppComponent implements AfterViewInit, OnDestroy {
64
119
  - `rag.loadHistoryOnOpen`: Load history automatically when the widget opens
65
120
  - `getUserContext`: Function that returns the current user context
66
121
  - `getAccessToken`: Optional function that returns a bearer token
122
+ - `embedded.showHeader`: In embedded mode, show or hide the library-owned page header. Default: `false`
67
123
 
68
124
  ## Example With Token
69
125
 
@@ -118,3 +174,4 @@ If you are loading the browser bundle manually, the package also exposes:
118
174
  - `apiBaseUrl` should point to your backend, not your Angular frontend
119
175
  - initialize the widget after authentication if your backend requires user identity or tokens
120
176
  - call `destroy()` when the hosting Angular component is destroyed
177
+ - for embedded mode, give the mount container a real height such as `min-height: calc(100vh - navbar - footer)`