@arbor-education/ask-arbor-chat-panel 1.0.2 → 1.1.1
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 +105 -30
- package/dist/index.cjs +21 -21
- package/dist/index.d.ts +21 -2
- package/dist/index.js +898 -851
- package/dist/style.css +1 -1
- package/dist-iife/ask-arbor-slideover.js +975 -0
- package/dist-iife/ask-arbor-widget.js +975 -0
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Self-contained AI chat widget and React component library. No arbor-fe ecosystem dependencies.
|
|
4
4
|
|
|
5
5
|
Published as two artefacts:
|
|
6
|
-
- **NPM package** — `
|
|
7
|
-
- **IIFE widget** — `ask-arbor-
|
|
6
|
+
- **NPM package** — `AskArborWidget` (bare panel) and `AskArborSlideover` (panel in Arbor Slideover) React components for host apps that already use React
|
|
7
|
+
- **IIFE widget** — `ask-arbor-slideover.js` (floating button + Slideover) and `ask-arbor-widget.js` (bare panel, embed in any container) for vanilla JS pages
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -24,10 +24,11 @@ Opens `http://localhost:5173/playground/widget-demo.html` with hot reload. Mock
|
|
|
24
24
|
| Command | What it does |
|
|
25
25
|
|---|---|
|
|
26
26
|
| `yarn dev` / `make dev` | Hot-reload widget demo (`playground/widget-demo.html`) |
|
|
27
|
-
| `yarn build:
|
|
27
|
+
| `yarn build:slideover` | Production IIFE bundle → `dist-iife/ask-arbor-slideover.js` |
|
|
28
|
+
| `yarn build:widget` | Production bare panel IIFE → `dist-iife/ask-arbor-widget.js` |
|
|
28
29
|
| `yarn build` | NPM package build → `dist/` |
|
|
29
|
-
| `yarn build:all` |
|
|
30
|
-
| `yarn test` | Run Vitest test suite (
|
|
30
|
+
| `yarn build:all` | All three builds in sequence |
|
|
31
|
+
| `yarn test` | Run Vitest test suite (135 tests) |
|
|
31
32
|
| `yarn test:watch` | Vitest in watch mode |
|
|
32
33
|
| `yarn check-types` | TypeScript type-check with no emit |
|
|
33
34
|
| `yarn eslint` | ESLint check |
|
|
@@ -37,12 +38,14 @@ Opens `http://localhost:5173/playground/widget-demo.html` with hot reload. Mock
|
|
|
37
38
|
|
|
38
39
|
## Widget integration (production)
|
|
39
40
|
|
|
41
|
+
### Floating button + Slideover (`ask-arbor-slideover.js`)
|
|
42
|
+
|
|
40
43
|
Drop one `<script>` into any HTML page — no React, no CSS imports required:
|
|
41
44
|
|
|
42
45
|
```html
|
|
43
|
-
<script src="ask-arbor-
|
|
46
|
+
<script src="ask-arbor-slideover.js"></script>
|
|
44
47
|
<script>
|
|
45
|
-
|
|
48
|
+
AskArborSlideover.init({
|
|
46
49
|
chatUrl: 'https://your-api.example.com/chat',
|
|
47
50
|
openOnStart: false, // true → opens immediately
|
|
48
51
|
position: 'bottom-right', // 'bottom-right' | 'bottom-left'
|
|
@@ -51,26 +54,57 @@ AskArbor.init({
|
|
|
51
54
|
</script>
|
|
52
55
|
```
|
|
53
56
|
|
|
57
|
+
### Bare panel (`ask-arbor-widget.js`)
|
|
58
|
+
|
|
59
|
+
Embed the chat panel directly into any container element — no floating button, no Slideover chrome:
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<div id="my-panel" style="height: 600px;"></div>
|
|
63
|
+
<script src="ask-arbor-widget.js"></script>
|
|
64
|
+
<script>
|
|
65
|
+
AskArborWidget.init(document.getElementById('my-panel'), {
|
|
66
|
+
chatUrl: 'https://your-api.example.com/chat',
|
|
67
|
+
authorizationToken: 'eyJ...',
|
|
68
|
+
onClose: () => { /* handle close button */ },
|
|
69
|
+
});
|
|
70
|
+
</script>
|
|
71
|
+
```
|
|
72
|
+
|
|
54
73
|
### Auto-init
|
|
55
74
|
|
|
56
|
-
Set `window
|
|
75
|
+
Set the config on `window` before loading the script and init runs automatically:
|
|
57
76
|
|
|
58
77
|
```html
|
|
78
|
+
<!-- Floating button widget -->
|
|
59
79
|
<script>
|
|
60
|
-
window.
|
|
80
|
+
window.AskArborSlideoverConfig = {
|
|
61
81
|
chatUrl: 'https://your-api.example.com/chat',
|
|
62
82
|
platform: 'SAM_PEOPLE',
|
|
63
83
|
openOnStart: true,
|
|
64
84
|
};
|
|
65
85
|
</script>
|
|
86
|
+
<script src="ask-arbor-slideover.js"></script>
|
|
87
|
+
|
|
88
|
+
<!-- Bare panel -->
|
|
89
|
+
<script>
|
|
90
|
+
window.AskArborWidgetConfig = {
|
|
91
|
+
chatUrl: 'https://your-api.example.com/chat',
|
|
92
|
+
containerId: 'my-panel',
|
|
93
|
+
};
|
|
94
|
+
</script>
|
|
66
95
|
<script src="ask-arbor-widget.js"></script>
|
|
67
96
|
```
|
|
68
97
|
|
|
69
98
|
### Global API
|
|
70
99
|
|
|
71
100
|
```js
|
|
72
|
-
|
|
73
|
-
|
|
101
|
+
// Floating button
|
|
102
|
+
AskArborSlideover.init(config)
|
|
103
|
+
AskArborSlideover.destroy()
|
|
104
|
+
|
|
105
|
+
// Bare panel
|
|
106
|
+
AskArborWidget.init(container, config)
|
|
107
|
+
AskArborWidget.destroy()
|
|
74
108
|
```
|
|
75
109
|
|
|
76
110
|
---
|
|
@@ -89,25 +123,61 @@ Peer dependencies: `react ≥18`, `react-dom ≥18`, `@arbor-education/design-sy
|
|
|
89
123
|
|
|
90
124
|
### Usage
|
|
91
125
|
|
|
126
|
+
**Bare panel** (`AskArborWidget`) — embed in your own container or drawer:
|
|
127
|
+
|
|
92
128
|
```tsx
|
|
93
|
-
import {
|
|
129
|
+
import { AskArborWidget } from '@arbor-education/ask-arbor-chat-panel';
|
|
94
130
|
import '@arbor-education/ask-arbor-chat-panel/style.css';
|
|
95
131
|
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
authorizationToken={jwt}
|
|
132
|
+
<AskArborWidget
|
|
133
|
+
connector={connector}
|
|
99
134
|
onClose={() => setOpen(false)}
|
|
100
135
|
/>
|
|
101
136
|
```
|
|
102
137
|
|
|
138
|
+
**Slideover-wrapped** (`AskArborSlideover`) — renders inside the Arbor design system Slideover:
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import { AskArborSlideover } from '@arbor-education/ask-arbor-chat-panel';
|
|
142
|
+
import '@arbor-education/ask-arbor-chat-panel/style.css';
|
|
143
|
+
|
|
144
|
+
<AskArborSlideover
|
|
145
|
+
connector={connector}
|
|
146
|
+
isOpen={isOpen}
|
|
147
|
+
onClose={() => setIsOpen(false)}
|
|
148
|
+
/>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Both components require an `IAIServiceConnector` instance. Use `AIServiceConnectorFactory.create(config)` to build one from a config object:
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
import { AIServiceConnectorFactory, AskArborWidget } from '@arbor-education/ask-arbor-chat-panel';
|
|
155
|
+
|
|
156
|
+
const connector = AIServiceConnectorFactory.create({
|
|
157
|
+
chatUrl: 'https://your-api.example.com/chat',
|
|
158
|
+
authorizationToken: jwt,
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
`ChatPanel` is also still exported for backwards compatibility.
|
|
163
|
+
|
|
103
164
|
### Published package contents
|
|
104
165
|
|
|
105
166
|
```
|
|
106
167
|
dist/
|
|
107
|
-
index.js
|
|
108
|
-
index.cjs
|
|
109
|
-
index.d.ts
|
|
110
|
-
style.css
|
|
168
|
+
index.js # ESM bundle
|
|
169
|
+
index.cjs # CommonJS bundle
|
|
170
|
+
index.d.ts # TypeScript declarations
|
|
171
|
+
style.css # Component styles (must be imported separately)
|
|
172
|
+
dist-iife/
|
|
173
|
+
ask-arbor-slideover.js # IIFE — floating button + Slideover (self-contained)
|
|
174
|
+
ask-arbor-widget.js # IIFE — bare embed panel (self-contained)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
The IIFE files are self-contained (CSS injected, no dependencies). Reference them via unpkg or jsdelivr:
|
|
178
|
+
|
|
179
|
+
```html
|
|
180
|
+
<script src="https://unpkg.com/@arbor-education/ask-arbor-chat-panel/dist-iife/ask-arbor-slideover.js"></script>
|
|
111
181
|
```
|
|
112
182
|
|
|
113
183
|
---
|
|
@@ -135,7 +205,7 @@ Select the bump type (patch / minor / major) and write a short summary. This cre
|
|
|
135
205
|
3. Creates a GitHub release with a `.tgz` tarball attached
|
|
136
206
|
4. Posts a success/failure notification to Slack
|
|
137
207
|
|
|
138
|
-
|
|
208
|
+
Both `dist/` (React components) and `dist-iife/` (IIFE bundles) are included in the published npm package.
|
|
139
209
|
|
|
140
210
|
---
|
|
141
211
|
|
|
@@ -177,21 +247,26 @@ Authorization: Bearer <token>
|
|
|
177
247
|
|
|
178
248
|
```
|
|
179
249
|
src/
|
|
180
|
-
widget.tsx
|
|
181
|
-
|
|
182
|
-
|
|
250
|
+
widget.tsx # IIFE entry — floating button + Slideover (AskArborSlideover)
|
|
251
|
+
widget-embed.tsx # IIFE entry — embed panel (AskArborWidget)
|
|
252
|
+
ChatPanel.tsx # Core React component
|
|
253
|
+
AskArborSlideover.tsx # React component — ChatPanel wrapped in Slideover
|
|
183
254
|
utils/
|
|
184
|
-
http.ts
|
|
255
|
+
http.ts # fetch wrapper with Authorization header support
|
|
185
256
|
getNewAgentMessage.ts
|
|
186
257
|
getHistoricMessages.ts
|
|
187
258
|
sendNotification.ts
|
|
188
259
|
sendMessageRating.ts
|
|
189
260
|
playground/
|
|
190
|
-
widget-demo.html
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
261
|
+
widget-demo.html # Floating button widget demo (yarn dev)
|
|
262
|
+
panel-demo.html # Bare panel demo (yarn dev → /playground/panel-demo.html)
|
|
263
|
+
index.html # React component playground (yarn dev → /playground/)
|
|
264
|
+
widget-dev-shim.ts # Dev-only: exposes window.AskArborSlideover from source
|
|
265
|
+
panel-dev-shim.ts # Dev-only: exposes window.AskArborWidget from source
|
|
266
|
+
dist-iife/
|
|
267
|
+
ask-arbor-slideover.js # Production IIFE — floating button + Slideover (build:slideover)
|
|
268
|
+
ask-arbor-widget.js # Production IIFE — bare panel (build:widget)
|
|
195
269
|
tests/
|
|
196
|
-
ChatPanel.test.tsx
|
|
270
|
+
ChatPanel.test.tsx
|
|
271
|
+
AskArborSlideover.test.tsx
|
|
197
272
|
```
|