@aiden-voice/widget 0.9.0 → 0.10.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 +36 -4
- package/dist/components/MessageList.d.ts +12 -1
- package/dist/config.d.ts +6 -1
- package/dist/controller.d.ts +8 -1
- package/dist/i18n/messages.d.ts +2 -0
- package/dist/storage.d.ts +2 -0
- package/dist/types.d.ts +41 -2
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +7 -7
- package/dist/widget.js +703 -559
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -134,14 +134,19 @@ throws synchronously, at call time, if you pass both or neither.
|
|
|
134
134
|
| `getSessionToken` | `sessionToken` mode only: a function returning a fresh session token (or a promise of one) from your backend, called when the current one has run out or is refused. Without it an expired session ends the chat until the page is reloaded. Ignored, with a warning, with `publishableKey` or when not a function. | none |
|
|
135
135
|
| `language` | Language of the widget's own text, as a BCP 47 tag (`'fr'`, `'pt-BR'`, `'zh-CN'`). Without it the widget follows the page's `<html lang>`, then English. See [Language](#language). | the page's language, else `'en'` |
|
|
136
136
|
| `messages` | Replaces individual built-in strings in the active language, e.g. `{ newConversation: 'Start over' }`. See [Language](#language). | none |
|
|
137
|
-
| `contentLanguage` | The language of the conversation's content (replies, the visitor's messages, and your `greeting`, `title`, `name` and image text), as a BCP 47 tag, so screen readers read it with the right voice. Separate from `language`, which only sets the widget's own text; `language` counts only for a page with no `<html lang>`. See [Language](#language). | the page's `<html lang>`, else `language`, else unknown |
|
|
137
|
+
| `contentLanguage` | The language of the conversation's content (replies, the visitor's messages, and your `greeting`, `notice`, `title`, `subtitle`, `name` and image text), as a BCP 47 tag, so screen readers read it with the right voice. Separate from `language`, which only sets the widget's own text; `language` counts only for a page with no `<html lang>`. See [Language](#language). | the page's `<html lang>`, else `language`, else unknown |
|
|
138
138
|
| `position` | Launcher/panel corner: `'bottom-right'` or `'bottom-left'`. | `'bottom-right'` |
|
|
139
139
|
| `color` | Primary accent color (any valid CSS color). Overrides the color configured in whoo-aiden; omit it to use that one. | whoo-aiden's, else `'#4f46e5'` |
|
|
140
140
|
| `inkColor` | Body text color (chat title and replies). Darkened automatically if needed to stay readable. Overrides the color configured in whoo-aiden; omit it to use that one. | whoo-aiden's, else `'#111111'` |
|
|
141
141
|
| `accentColor` | Link color in replies. Darkened automatically if needed to stay readable. Overrides the color configured in whoo-aiden; omit it to use that one. | whoo-aiden's, else `'#0000ee'` |
|
|
142
142
|
| `name` | Agent name for the panel header and the dialog's screen-reader label ("Chat with {name}"). Overrides the name configured in whoo-aiden; omit it to use that one. | whoo-aiden's, else `'Aiden'` |
|
|
143
143
|
| `title` | Full panel title, used for the header heading and the dialog's screen-reader label. Replaces the whole "Chat with {name}" string (e.g. `'Ask our concierge'`), with surrounding whitespace trimmed; the agent's messages are still labelled with its name. A blank value is ignored. | `'Chat with {name}'` |
|
|
144
|
+
| `subtitle` | A second, smaller line under the panel title (e.g. your property's name). Not part of the dialog's screen-reader name, which stays the title. Blank values are ignored. | none |
|
|
144
145
|
| `greeting` | Welcome text shown in the panel before the first message. | none |
|
|
146
|
+
| `greetingStyle` | How `greeting` is shown: `'bubble'`, as the agent's first message, or `'centered'`, as plain text centered under `emptyStateImageUrl`, the two together in the middle of the empty panel. Either way it goes away once the visitor writes. | `'bubble'` |
|
|
147
|
+
| `notice` | A notice, such as a disclaimer or terms of use, pinned at the top of the conversation (or under the message field, with `noticePlacement`). Unlike `greeting` it stays after the visitor writes, and comes back after "New conversation". Screen readers read it with the panel's title when the panel opens, until the visitor sends a first message. Supports `**bold**`, `_italic_`, `[links](https://...)` and `- ` lists; raw HTML shows as text. Blank values are ignored. See [Notice](#notice). | none |
|
|
148
|
+
| `requireNoticeAgreement` | Ask the visitor to agree to `notice` before chatting: an "I agree" button (the `agreeToNotice` message) replaces the message field until they do. Remembered for the tab session, and asked again if the notice text changes. Ignored, with a console warning, without a `notice`. See [Notice](#notice). | `false` |
|
|
149
|
+
| `noticePlacement` | Where `notice` is shown: `'top'`, above the conversation, or `'footer'`, as small print under the message field. See [Notice](#notice). | `'top'` |
|
|
145
150
|
| `launcherIconUrl` | Image shown on the launcher bubble instead of the default chat icon. `https:` or `data:image/` only. Until it loads, and permanently if it fails, the default icon shows. Alias of `theme.launcher.iconUrl`. | none (default icon) |
|
|
146
151
|
| `theme` | Colors, font and launcher icons. See [Theming](#theming). | defaults |
|
|
147
152
|
| `layout` | Launcher position and size, and panel size. See [Layout](#layout). | defaults |
|
|
@@ -155,6 +160,28 @@ throws synchronously, at call time, if you pass both or neither.
|
|
|
155
160
|
|
|
156
161
|
Some third-party overlays (accessibility toolbars, chat or cookie widgets) sit at the maximum possible z-index, `2147483647`, in the same corner. No `zIndex` value can beat that: at an equal level, whichever element comes later in the page wins, and those overlays are usually injected after the widget. Move the widget to the other corner with `position: 'bottom-left'` instead. (None of this applies while the panel fills the screen; see `zIndex`.)
|
|
157
162
|
|
|
163
|
+
|
|
164
|
+
## Notice
|
|
165
|
+
|
|
166
|
+
Use `notice` for text every visitor must be shown before chatting, such as a disclaimer, and `requireNoticeAgreement` to have them agree to it first:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
init({
|
|
170
|
+
publishableKey: 'pk_...',
|
|
171
|
+
notice:
|
|
172
|
+
"**Welcome to Ask Aiden, our Guest Assistant!**\n\nAll information provided is for informational purposes only. By selecting \"I agree\", you accept our [Website Terms of Use](https://example.com/terms).",
|
|
173
|
+
requireNoticeAgreement: true,
|
|
174
|
+
})
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
- **Where it shows:** above the conversation (below `emptyStateImageUrl`, above `greeting`), outlined rather than in a chat bubble, since it isn't something the agent said. It never leaves the transcript. The panel opens scrolled to its first line until the visitor writes.
|
|
178
|
+
- **As a footer (`noticePlacement: 'footer'`):** small centered print under the message field (or under "I agree"), always in view. It takes at most a quarter of the panel; a longer notice scrolls inside it, and it is then reachable with Tab so keyboard users can scroll it. Keep a footer notice to a sentence or two.
|
|
179
|
+
- **Screen readers:** the panel is described by the notice, so it's read with the title when the panel opens, until the visitor sends a first message (after that it would repeat on every open). It stays reachable as the first item of the conversation.
|
|
180
|
+
- **It isn't sent to the agent** and isn't saved with the conversation.
|
|
181
|
+
- **Agreement (`requireNoticeAgreement: true`):** until the visitor agrees, an "I agree" button takes the message field's place, and nothing can be sent. When the panel opens, focus is on the button, which the notice describes, so screen readers read the title, "I agree, button" and the notice; after agreeing, focus moves to the message field. The agreement lasts for the tab session (like the conversation), survives "New conversation", and is asked for again if you change the notice text. Change the label with `messages: { agreeToNotice: '...' }`; if you do, make the notice text match it.
|
|
182
|
+
- **No record is kept.** The agreement lives only in the visitor's browser (`sessionStorage`); the widget doesn't send it to whoo-aiden, so it is no proof of consent. Whether that, and the wording, is enough is a question for your legal counsel.
|
|
183
|
+
- **Write it in your content language,** like `greeting`. It's not translated.
|
|
184
|
+
|
|
158
185
|
## Language
|
|
159
186
|
|
|
160
187
|
The widget's own text (buttons, labels, status and error messages, and what screen readers announce) comes in eleven languages: English (`en`), French (`fr`), Spanish (`es`), Portuguese (`pt`), German (`de`), Italian (`it`), Japanese (`ja`), Simplified Chinese (`zh`), Russian (`ru`), Hindi (`hi`) and Arabic (`ar`).
|
|
@@ -163,7 +190,7 @@ The widget's own text (buttons, labels, status and error messages, and what scre
|
|
|
163
190
|
- **Regional tags** match their language: `fr-CA` is French, any `pt-*` gets Brazilian Portuguese, any `es-*` gets Latin American Spanish. Simplified Chinese matches `zh`, `zh-CN`, `zh-SG` and `zh-Hans`. Traditional Chinese (`zh-TW`, `zh-HK`, `zh-Hant`) is not supported and falls back to English.
|
|
164
191
|
- **Decided once, at `init()`.** If your single-page app changes `<html lang>` later, pass `language` (unmount and `init()` again to switch).
|
|
165
192
|
- **Arabic is right to left:** the panel's layout mirrors (the visitor's messages on the left). The corner set by `position` doesn't change.
|
|
166
|
-
- **Not translated:** the agent's replies (the model answers in whatever language it does), and `greeting`, `title` and `name`, which you write in the language you want. These are marked with the **content language**, not the widget's: `contentLanguage` if you pass it, else your page's `<html lang>` (any language, not just the eleven), else `language` if the page has no `lang`, else unknown. So on a Dutch page the widget's buttons are English, while replies and your Dutch greeting are read with a Dutch voice.
|
|
193
|
+
- **Not translated:** the agent's replies (the model answers in whatever language it does), and `greeting`, `notice`, `title` and `name`, which you write in the language you want. These are marked with the **content language**, not the widget's: `contentLanguage` if you pass it, else your page's `<html lang>` (any language, not just the eleven), else `language` if the page has no `lang`, else unknown. So on a Dutch page the widget's buttons are English, while replies and your Dutch greeting are read with a Dutch voice.
|
|
167
194
|
- **Direction:** each paragraph and list item of a message takes its direction from its own first letter, so an English reply in an Arabic widget, or the reverse, still reads correctly. A paragraph that starts with a Latin name ("Aiden …") in Arabic text is laid out left to right, as the bidi standard decides.
|
|
168
195
|
- **The widget marks its own language** (`lang` and `dir` on its root, naming the variant it ships: `pt-BR`, `es-419`, `zh-Hans`), so screen readers pronounce it correctly even on a page in another language.
|
|
169
196
|
- **Upgrading from a version before 0.8.0:** a page whose `<html lang>` is one of these languages now gets the widget in that language, where it was English before. Pass `language: 'en'` to keep it in English; replies and your own text keep your page's language for screen readers either way.
|
|
@@ -187,6 +214,7 @@ window.whooAidenWidget.init({
|
|
|
187
214
|
| `conversation` | Conversation | message list region name |
|
|
188
215
|
| `you` | You | screen-reader speaker label on the visitor's messages |
|
|
189
216
|
| `message` | Message | message box label |
|
|
217
|
+
| `messagePlaceholder` | Type a message… | message box placeholder (a hint; `message` stays its label) |
|
|
190
218
|
| `send` | Send | composer button |
|
|
191
219
|
| `lookingItUp` | Looking that up for you… | slow-reply notice |
|
|
192
220
|
| `goodResponse` | Good response | thumbs-up name |
|
|
@@ -206,6 +234,8 @@ window.whooAidenWidget.init({
|
|
|
206
234
|
| `conversationCleared` | Conversation cleared | screen-reader announcement |
|
|
207
235
|
| `genericError` | Something went wrong, please try again. | error alert |
|
|
208
236
|
| `sessionExpired` | This chat session has expired. Reload the page to continue. | error alert |
|
|
237
|
+
| `opensInNewTab` | (opens in new tab) | screen readers only, after each link in a reply: every link in a reply opens in a new tab |
|
|
238
|
+
| `agreeToNotice` | I agree | button the visitor presses to agree to the `notice`, with `requireNoticeAgreement` |
|
|
209
239
|
|
|
210
240
|
**About the translations:** they were machine-drafted and cross-checked by independent AI agents (back-translation, critique, and rendering checks), not reviewed by native speakers. [docs/translation-verification.md](docs/translation-verification.md) records every check. If any wording reads wrong, override it with `messages`, and please tell us.
|
|
211
241
|
|
|
@@ -252,13 +282,13 @@ init({
|
|
|
252
282
|
| `border` | Dividers | `#e5e5e5` |
|
|
253
283
|
| `headerHover` | Header control hover fill | `#f3f4f6` |
|
|
254
284
|
| `assistantBubble` | Reply bubble background | `#f0f0f0` |
|
|
255
|
-
| `muted` | Secondary text on replies | `#4b5563` |
|
|
285
|
+
| `muted` | Secondary text on replies and on the panel (`subtitle`, the footer notice, the message box placeholder) | `#4b5563` |
|
|
256
286
|
| `typingDots` | "Waiting for a reply" dots | `#6b7280` |
|
|
257
287
|
| `errorBackground`, `errorText` | Error banner | `#fee2e2`, `#991b1b` |
|
|
258
288
|
| `inputBorder` | Input and form borders | `#6b7280` |
|
|
259
289
|
| `focusRing` | Dark tone of the keyboard focus outline | `#111827` |
|
|
260
290
|
|
|
261
|
-
If you override a surface (`panel`, `assistantBubble`, ...), also override the roles drawn on it: the defaults are made for the default surfaces, and an override of one is never adjusted to fit another. The roles drawn on each surface are `panel`: `primaryText`, `text`, `focusRing`, `border`, `inputBorder`; `headerHover`: `primaryText`; `assistantBubble`: `ink`, `link`, `muted`, `typingDots`, `text`; `errorBackground`: `errorText`. (The example above leaves `inputBorder`, `typingDots` and the error colors at their defaults, which already read well on it.)
|
|
291
|
+
If you override a surface (`panel`, `assistantBubble`, ...), also override the roles drawn on it: the defaults are made for the default surfaces, and an override of one is never adjusted to fit another. The roles drawn on each surface are `panel`: `primaryText`, `ink`, `link`, `muted`, `text`, `focusRing`, `border`, `inputBorder`; `headerHover`: `primaryText`; `assistantBubble`: `ink`, `link`, `muted`, `typingDots`, `text`; `errorBackground`: `errorText`. (The example above leaves `inputBorder`, `typingDots` and the error colors at their defaults, which already read well on it.)
|
|
262
292
|
|
|
263
293
|
**Fonts.** `theme.fonts.family` takes a CSS font-family stack. The widget never loads fonts, so the font must already be available: a system font, or one your page loads (a Google Fonts `<link>`, or your own `@font-face`). A stack that is over 200 characters or contains `url(`, `@`, `;`, `{`, `}` or `\` is ignored with a warning.
|
|
264
294
|
|
|
@@ -276,6 +306,7 @@ init({
|
|
|
276
306
|
offset: { x: 24, y: 96 }, // distance from the chosen corner (default 20, 20)
|
|
277
307
|
launcherSize: 64, // launcher diameter, 24-120 (default 56)
|
|
278
308
|
panel: { width: 420, height: 640 }, // preferred panel size (default 360×480, minimum 280×320)
|
|
309
|
+
cornerRadius: 20, // panel, message box, Send and "I agree", 0-32 (default 12 panel, 6 controls)
|
|
279
310
|
},
|
|
280
311
|
})
|
|
281
312
|
```
|
|
@@ -283,6 +314,7 @@ init({
|
|
|
283
314
|
- The launcher can't be moved off-screen, and not so far from its corner that the chat panel loses its room: an offset that doesn't leave space for the launcher and a minimum-size panel is held back (a warning is logged if that applies when the page loads). A smaller offset than the 20px default is always honored.
|
|
284
315
|
- A `launcherSize` outside 24-120 is clamped (the 24px floor is WCAG 2.2's minimum target size).
|
|
285
316
|
- The panel is always placed above the launcher, whatever its size or offset, and is capped to the viewport. `panel` is a preferred size: it can never run past the screen, and on very small screens (a viewport 400px wide or less, or 420px tall or less) it fills the viewport as before. A `panel.width` or `panel.height` below 280×320 is raised to that minimum, with a warning.
|
|
317
|
+
- `cornerRadius` rounds the panel, the message box and the Send and "I agree" buttons alike; about 20 or more turns the message box and Send into pills. It's clamped to 32, past which a short panel's corners eat into the header and message box. Without it, the panel keeps 12px corners and the controls 6px.
|
|
286
318
|
- A value that isn't a non-negative number is ignored with a warning and the default is used.
|
|
287
319
|
- On a phone, while the on-screen keyboard is open, the panel moves and shrinks to stay above it, so the message box is never hidden. While the panel fills the screen, the page behind it doesn't scroll (the widget sets `overflow: hidden` on `<html>` and restores your value on close).
|
|
288
320
|
- Your page needs `<meta name="viewport" content="width=device-width, initial-scale=1">` for the phone layout to apply; without it phones render the page, widget included, at desktop width and shrink it.
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { FeedbackCategory, Message, MessageFeedbackState } from '../controller';
|
|
2
2
|
import { WidgetMessages } from '../i18n/messages';
|
|
3
|
+
export declare const NOTICE_ID = "whoo-widget-notice";
|
|
4
|
+
export declare function Notice({ notice, placement, text, contentLanguage, languageTag, }: {
|
|
5
|
+
notice: string;
|
|
6
|
+
placement?: 'top' | 'footer';
|
|
7
|
+
text: WidgetMessages;
|
|
8
|
+
contentLanguage?: string;
|
|
9
|
+
languageTag?: string;
|
|
10
|
+
}): import('preact').JSX.Element;
|
|
3
11
|
type DraftChangeHandler = (messageId: string, correction: string, category: '' | FeedbackCategory) => void;
|
|
4
12
|
type SubmitHandler = (messageId: string, correction: string, category: '' | FeedbackCategory) => void;
|
|
5
|
-
export declare function MessageList({ messages, messageFeedback, announcement, emptyStateImage, agentName, showFeedback, isStreaming, isSlowResponse, onThumbsUp, onThumbsDown, onDraftChange, onSubmitDetailed, onCancelFeedback, text, contentLanguage, languageTag, announcementIsContent, }: {
|
|
13
|
+
export declare function MessageList({ messages, messageFeedback, announcement, emptyStateImage, centerEmptyState, centeredGreeting, notice, agentName, showFeedback, isStreaming, isSlowResponse, onThumbsUp, onThumbsDown, onDraftChange, onSubmitDetailed, onCancelFeedback, text, contentLanguage, languageTag, announcementIsContent, }: {
|
|
6
14
|
messages: Message[];
|
|
7
15
|
messageFeedback: Record<string, MessageFeedbackState>;
|
|
8
16
|
announcement: string | null;
|
|
@@ -10,6 +18,9 @@ export declare function MessageList({ messages, messageFeedback, announcement, e
|
|
|
10
18
|
url: string;
|
|
11
19
|
alt: string;
|
|
12
20
|
};
|
|
21
|
+
centerEmptyState?: boolean;
|
|
22
|
+
centeredGreeting?: string;
|
|
23
|
+
notice?: string;
|
|
13
24
|
agentName?: string;
|
|
14
25
|
showFeedback?: boolean;
|
|
15
26
|
isStreaming?: boolean;
|
package/dist/config.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { WidgetMessages } from './i18n/messages';
|
|
2
2
|
import { ThemeColorOverrides } from './themeRoles';
|
|
3
|
-
import { LauncherIcon, LauncherOpenIcon, WidgetConfig } from './types';
|
|
3
|
+
import { GreetingStyle, LauncherIcon, LauncherOpenIcon, NoticePlacement, WidgetConfig } from './types';
|
|
4
4
|
export declare const DEFAULT_API_BASE_URL = "https://api.aidenvoice.com";
|
|
5
5
|
export declare const DEFAULT_Z_INDEX = 2147483000;
|
|
6
6
|
export declare function resolveZIndex(zIndex: unknown): number;
|
|
7
7
|
export declare const DEFAULT_AGENT_NAME = "Aiden";
|
|
8
8
|
export declare function trimmedName(name: unknown): string;
|
|
9
|
+
export declare function isBlankText(text: string): boolean;
|
|
9
10
|
export declare function validateConfig(config: WidgetConfig): void;
|
|
10
11
|
export declare function normalizeGetSessionToken(config: WidgetConfig): (() => string | Promise<string>) | undefined;
|
|
11
12
|
export declare function normalizeMessages(value: unknown): Partial<WidgetMessages>;
|
|
13
|
+
export declare function normalizeGreetingStyle(value: unknown): GreetingStyle;
|
|
14
|
+
export declare function normalizeNoticePlacement(value: unknown): NoticePlacement;
|
|
12
15
|
export declare function safeFontFamily(value: unknown): string | undefined;
|
|
13
16
|
export interface NormalizedTheme {
|
|
14
17
|
colors: ThemeColorOverrides;
|
|
@@ -32,11 +35,13 @@ export declare const LAUNCHER_SIZE_MIN = 24;
|
|
|
32
35
|
export declare const LAUNCHER_SIZE_MAX = 120;
|
|
33
36
|
export declare const PANEL_MIN_WIDTH = 280;
|
|
34
37
|
export declare const PANEL_MIN_HEIGHT = 320;
|
|
38
|
+
export declare const CORNER_RADIUS_MAX = 32;
|
|
35
39
|
export interface NormalizedLayout {
|
|
36
40
|
offsetX: number;
|
|
37
41
|
offsetY: number;
|
|
38
42
|
launcherSize: number;
|
|
39
43
|
panelWidth: number;
|
|
40
44
|
panelHeight: number;
|
|
45
|
+
cornerRadius?: number;
|
|
41
46
|
}
|
|
42
47
|
export declare function normalizeLayout(layout: unknown): NormalizedLayout;
|
package/dist/controller.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NormalizedTheme } from './config';
|
|
2
2
|
import { SupportedLanguage } from './i18n';
|
|
3
3
|
import { WidgetMessages } from './i18n/messages';
|
|
4
|
-
import { WidgetConfig } from './types';
|
|
4
|
+
import { GreetingStyle, NoticePlacement, WidgetConfig } from './types';
|
|
5
5
|
export declare const SLOW_RESPONSE_DELAY_MS = 8000;
|
|
6
6
|
export declare const BRANDING_LOOKUP_WAIT_MS = 3000;
|
|
7
7
|
export declare const TOKEN_RENEWAL_MARGIN_MS = 60000;
|
|
@@ -33,6 +33,7 @@ export interface WidgetState {
|
|
|
33
33
|
announcement: string | null;
|
|
34
34
|
announcementIsContent: boolean;
|
|
35
35
|
isSlowResponse: boolean;
|
|
36
|
+
noticeAgreed: boolean;
|
|
36
37
|
draft: string;
|
|
37
38
|
}
|
|
38
39
|
type Listener = (state: WidgetState) => void;
|
|
@@ -55,6 +56,11 @@ export declare class WidgetController {
|
|
|
55
56
|
readonly launcherIconUrl: string | undefined;
|
|
56
57
|
readonly emptyStateImageUrl: string | undefined;
|
|
57
58
|
readonly emptyStateImageAlt: string;
|
|
59
|
+
readonly notice: string;
|
|
60
|
+
readonly requireNoticeAgreement: boolean;
|
|
61
|
+
readonly noticePlacement: NoticePlacement;
|
|
62
|
+
readonly subtitle: string;
|
|
63
|
+
readonly greetingStyle: GreetingStyle;
|
|
58
64
|
readonly showFeedback: boolean;
|
|
59
65
|
readonly text: WidgetMessages;
|
|
60
66
|
readonly language: SupportedLanguage;
|
|
@@ -71,6 +77,7 @@ export declare class WidgetController {
|
|
|
71
77
|
private loadBranding;
|
|
72
78
|
open(): void;
|
|
73
79
|
resetConversation(): void;
|
|
80
|
+
agreeToNotice(): void;
|
|
74
81
|
setDraft(draft: string): void;
|
|
75
82
|
close(): void;
|
|
76
83
|
sendMessage(text: string): Promise<void>;
|
package/dist/i18n/messages.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface WidgetMessages {
|
|
|
6
6
|
conversation: string;
|
|
7
7
|
you: string;
|
|
8
8
|
message: string;
|
|
9
|
+
messagePlaceholder: string;
|
|
9
10
|
send: string;
|
|
10
11
|
lookingItUp: string;
|
|
11
12
|
goodResponse: string;
|
|
@@ -26,6 +27,7 @@ export interface WidgetMessages {
|
|
|
26
27
|
genericError: string;
|
|
27
28
|
sessionExpired: string;
|
|
28
29
|
opensInNewTab: string;
|
|
30
|
+
agreeToNotice: string;
|
|
29
31
|
}
|
|
30
32
|
export declare const ENGLISH: WidgetMessages;
|
|
31
33
|
export declare const MESSAGE_KEYS: (keyof WidgetMessages)[];
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare function getStoredConversationId(identifier: string): string | null;
|
|
2
2
|
export declare function setStoredConversationId(identifier: string, conversationId: string): void;
|
|
3
|
+
export declare function hasAgreedToNotice(identifier: string, notice: string): boolean;
|
|
4
|
+
export declare function setAgreedToNotice(identifier: string, notice: string): void;
|
|
3
5
|
export declare function clearStoredConversationId(identifier: string): void;
|
package/dist/types.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface WidgetTheme {
|
|
|
28
28
|
headerHover?: string;
|
|
29
29
|
/** Reply bubble background. */
|
|
30
30
|
assistantBubble?: string;
|
|
31
|
-
/** Secondary text on the reply bubble. */
|
|
31
|
+
/** Secondary text on the reply bubble and the panel (subtitle, footer notice, placeholder). */
|
|
32
32
|
muted?: string;
|
|
33
33
|
/** Waiting-for-reply indicator. */
|
|
34
34
|
typingDots?: string;
|
|
@@ -69,7 +69,15 @@ export interface WidgetLayout {
|
|
|
69
69
|
width?: number;
|
|
70
70
|
height?: number;
|
|
71
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Corner radius in px, 0-32, of the panel, the message field and the Send
|
|
74
|
+
* and "I agree" buttons. Half the field's height or more rounds the field
|
|
75
|
+
* and Send into pills. Default: 12 on the panel and 6 on the controls.
|
|
76
|
+
*/
|
|
77
|
+
cornerRadius?: number;
|
|
72
78
|
}
|
|
79
|
+
export type GreetingStyle = 'bubble' | 'centered';
|
|
80
|
+
export type NoticePlacement = 'top' | 'footer';
|
|
73
81
|
export interface WidgetConfig {
|
|
74
82
|
publishableKey?: string;
|
|
75
83
|
sessionToken?: string;
|
|
@@ -96,7 +104,7 @@ export interface WidgetConfig {
|
|
|
96
104
|
messages?: Partial<WidgetMessages>;
|
|
97
105
|
/**
|
|
98
106
|
* The language of the conversation's content (replies, the visitor's
|
|
99
|
-
* messages, and your greeting, title, name and image text), as a BCP 47
|
|
107
|
+
* messages, and your greeting, notice, title, name and image text), as a BCP 47
|
|
100
108
|
* tag, so screen readers read it with the right voice. Defaults to the
|
|
101
109
|
* page's <html lang>, then to `language` when the page has none, else
|
|
102
110
|
* unknown. Separate from `language`, which only sets the widget's own
|
|
@@ -121,7 +129,38 @@ export interface WidgetConfig {
|
|
|
121
129
|
accentColor?: string;
|
|
122
130
|
name?: string;
|
|
123
131
|
title?: string;
|
|
132
|
+
/**
|
|
133
|
+
* A second, smaller line under the panel title (e.g. the property's name).
|
|
134
|
+
* Shown as given, trimmed; blank or non-string values are ignored.
|
|
135
|
+
*/
|
|
136
|
+
subtitle?: string;
|
|
124
137
|
greeting?: string;
|
|
138
|
+
/**
|
|
139
|
+
* How `greeting` is shown: 'bubble' (the default) as the agent's first
|
|
140
|
+
* message, or 'centered' as plain text centered under
|
|
141
|
+
* `emptyStateImageUrl`, the two centered together in the empty panel.
|
|
142
|
+
*/
|
|
143
|
+
greetingStyle?: GreetingStyle;
|
|
144
|
+
/**
|
|
145
|
+
* A notice (e.g. a disclaimer or terms of use) pinned at the top of the
|
|
146
|
+
* conversation. Unlike `greeting` it stays after the visitor sends a
|
|
147
|
+
* message, and screen readers read it when the panel opens until then.
|
|
148
|
+
* Supports **bold**, _italic_ and [links](https://...). Blank or non-string
|
|
149
|
+
* values are ignored.
|
|
150
|
+
*/
|
|
151
|
+
notice?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Where `notice` is shown: 'top' (the default) pinned above the
|
|
154
|
+
* conversation, or 'footer' as small print under the message field.
|
|
155
|
+
*/
|
|
156
|
+
noticePlacement?: NoticePlacement;
|
|
157
|
+
/**
|
|
158
|
+
* Require the visitor to agree to `notice` before chatting: the panel shows
|
|
159
|
+
* an "I agree" button (the `agreeToNotice` message) in place of the message
|
|
160
|
+
* field until they do. Remembered for the tab session, and asked again if
|
|
161
|
+
* the notice text changes. Ignored without a `notice`. Off by default.
|
|
162
|
+
*/
|
|
163
|
+
requireNoticeAgreement?: boolean;
|
|
125
164
|
/** Image shown on the launcher bubble instead of the default chat icon. Alias of `theme.launcher.iconUrl`, which wins if both are set. */
|
|
126
165
|
launcherIconUrl?: string;
|
|
127
166
|
/** Image shown above the greeting while the conversation is empty. */
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const WIDGET_VERSION = "0.
|
|
1
|
+
export declare const WIDGET_VERSION = "0.10.0";
|