@arbor-education/ask-arbor-chat-panel 1.0.0 → 1.1.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 +149 -27
- package/dist/index.cjs +21 -21
- package/dist/index.d.ts +13 -2
- package/dist/index.js +593 -558
- 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 +8 -6
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,44 +54,158 @@ 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
|
---
|
|
77
111
|
|
|
78
112
|
## React component (NPM package)
|
|
79
113
|
|
|
114
|
+
### Installation
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
yarn add @arbor-education/ask-arbor-chat-panel
|
|
118
|
+
# or
|
|
119
|
+
npm install @arbor-education/ask-arbor-chat-panel
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Peer dependencies: `react ≥18`, `react-dom ≥18`, `@arbor-education/design-system.components ≥0.21`.
|
|
123
|
+
|
|
124
|
+
### Usage
|
|
125
|
+
|
|
126
|
+
**Bare panel** (`AskArborWidget`) — embed in your own container or drawer:
|
|
127
|
+
|
|
80
128
|
```tsx
|
|
81
|
-
import {
|
|
82
|
-
import 'ask-arbor-chat-panel/style.css';
|
|
129
|
+
import { AskArborWidget } from '@arbor-education/ask-arbor-chat-panel';
|
|
130
|
+
import '@arbor-education/ask-arbor-chat-panel/style.css';
|
|
83
131
|
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
authorizationToken={jwt}
|
|
132
|
+
<AskArborWidget
|
|
133
|
+
connector={connector}
|
|
87
134
|
onClose={() => setOpen(false)}
|
|
88
135
|
/>
|
|
89
136
|
```
|
|
90
137
|
|
|
91
|
-
|
|
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
|
+
|
|
164
|
+
### Published package contents
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
dist/
|
|
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>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Releasing
|
|
186
|
+
|
|
187
|
+
Releases are managed via [Changesets](https://github.com/changesets/changesets).
|
|
188
|
+
|
|
189
|
+
### Creating a changeset
|
|
190
|
+
|
|
191
|
+
When your change is ready, run:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
yarn changeset
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Select the bump type (patch / minor / major) and write a short summary. This creates a file in `.changeset/` - commit it with your branch.
|
|
198
|
+
|
|
199
|
+
### Automated publishing
|
|
200
|
+
|
|
201
|
+
`.github/workflows/release.yml` runs at 07:00 UTC Monday-Friday. It:
|
|
202
|
+
|
|
203
|
+
1. Runs `npx changeset version` to apply any pending changesets and bump the package version
|
|
204
|
+
2. Publishes the updated package to npm (only if the version changed)
|
|
205
|
+
3. Creates a GitHub release with a `.tgz` tarball attached
|
|
206
|
+
4. Posts a success/failure notification to Slack
|
|
207
|
+
|
|
208
|
+
Both `dist/` (React components) and `dist-iife/` (IIFE bundles) are included in the published npm package.
|
|
92
209
|
|
|
93
210
|
---
|
|
94
211
|
|
|
@@ -130,21 +247,26 @@ Authorization: Bearer <token>
|
|
|
130
247
|
|
|
131
248
|
```
|
|
132
249
|
src/
|
|
133
|
-
widget.tsx
|
|
134
|
-
|
|
135
|
-
|
|
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
|
|
136
254
|
utils/
|
|
137
|
-
http.ts
|
|
255
|
+
http.ts # fetch wrapper with Authorization header support
|
|
138
256
|
getNewAgentMessage.ts
|
|
139
257
|
getHistoricMessages.ts
|
|
140
258
|
sendNotification.ts
|
|
141
259
|
sendMessageRating.ts
|
|
142
260
|
playground/
|
|
143
|
-
widget-demo.html
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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)
|
|
148
269
|
tests/
|
|
149
|
-
ChatPanel.test.tsx
|
|
270
|
+
ChatPanel.test.tsx
|
|
271
|
+
AskArborSlideover.test.tsx
|
|
150
272
|
```
|