@aparte/n8n-chat 0.5.0 → 1.0.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 +109 -18
- package/dist/cdn/chunks/{chunk-27HPUSEO.js → chunk-75MBZEMR.js} +2 -2
- package/dist/cdn/chunks/{chunk-27HPUSEO.js.map → chunk-75MBZEMR.js.map} +1 -1
- package/dist/cdn/chunks/{chunk-J2RB5NH4.js → chunk-EKOAQWDB.js} +2 -2
- package/dist/cdn/chunks/{chunk-J2RB5NH4.js.map → chunk-EKOAQWDB.js.map} +1 -1
- package/dist/cdn/chunks/chunk-FPBJCFJN.js +379 -0
- package/dist/cdn/chunks/chunk-FPBJCFJN.js.map +7 -0
- package/dist/cdn/chunks/chunk-FZXRS5MT.js +208 -0
- package/dist/cdn/chunks/chunk-FZXRS5MT.js.map +7 -0
- package/dist/cdn/chunks/{chunk-A2H2YABP.js → chunk-UCBMONE6.js} +2 -2
- package/dist/cdn/chunks/{chunk-A2H2YABP.js.map → chunk-UCBMONE6.js.map} +1 -1
- package/dist/cdn/chunks/{chunk-GJ4YMVTA.js → chunk-WCZRD7U7.js} +1 -1
- package/dist/cdn/chunks/{chunk-GJ4YMVTA.js.map → chunk-WCZRD7U7.js.map} +1 -1
- package/dist/cdn/chunks/de-7JCOF7FR.js +2 -0
- package/dist/cdn/chunks/de-7JCOF7FR.js.map +7 -0
- package/dist/cdn/chunks/es-KUX7YCK6.js +2 -0
- package/dist/cdn/chunks/es-KUX7YCK6.js.map +7 -0
- package/dist/cdn/chunks/fr-VYD7EC55.js +2 -0
- package/dist/cdn/chunks/fr-VYD7EC55.js.map +7 -0
- package/dist/cdn/chunks/{highlight-SCSTGNZJ.js → highlight-W7QGGHNK.js} +2 -2
- package/dist/cdn/chunks/{highlight-SCSTGNZJ.js.map → highlight-W7QGGHNK.js.map} +1 -1
- package/dist/cdn/chunks/it-BXNO2THQ.js +2 -0
- package/dist/cdn/chunks/it-BXNO2THQ.js.map +7 -0
- package/dist/cdn/chunks/{items-TBASSOQ3.js → items-X2D73Z5A.js} +3 -3
- package/dist/cdn/chunks/{items-TBASSOQ3.js.map → items-X2D73Z5A.js.map} +4 -4
- package/dist/cdn/chunks/ja-6VGJFQ66.js +2 -0
- package/dist/cdn/chunks/ja-6VGJFQ66.js.map +7 -0
- package/dist/cdn/chunks/ko-HUU4F44X.js +2 -0
- package/dist/cdn/chunks/ko-HUU4F44X.js.map +7 -0
- package/dist/cdn/chunks/{link-VR62DJAD.js → link-LNDRLLUH.js} +3 -3
- package/dist/cdn/chunks/link-LNDRLLUH.js.map +7 -0
- package/dist/cdn/chunks/{media-O7WQHRGC.js → media-JDTPNZHJ.js} +4 -4
- package/dist/cdn/chunks/{media-O7WQHRGC.js.map → media-JDTPNZHJ.js.map} +4 -4
- package/dist/cdn/chunks/{order-H7FHTQ2J.js → order-HS6FXBIB.js} +3 -3
- package/dist/cdn/chunks/{order-H7FHTQ2J.js.map → order-HS6FXBIB.js.map} +3 -3
- package/dist/cdn/chunks/{place-TGHDGFFI.js → place-N3E7T2EV.js} +3 -3
- package/dist/cdn/chunks/{place-TGHDGFFI.js.map → place-N3E7T2EV.js.map} +4 -4
- package/dist/cdn/chunks/{plan-JA7466PF.js → plan-TCWRW3OC.js} +3 -3
- package/dist/cdn/chunks/{plan-JA7466PF.js.map → plan-TCWRW3OC.js.map} +4 -4
- package/dist/cdn/chunks/{product-VEI5FUDZ.js → product-JH7QUP6I.js} +3 -3
- package/dist/cdn/chunks/{product-VEI5FUDZ.js.map → product-JH7QUP6I.js.map} +4 -4
- package/dist/cdn/chunks/pt-BR-SNSDLB4C.js +2 -0
- package/dist/cdn/chunks/pt-BR-SNSDLB4C.js.map +7 -0
- package/dist/cdn/chunks/ru-QE2LLTEY.js +2 -0
- package/dist/cdn/chunks/ru-QE2LLTEY.js.map +7 -0
- package/dist/cdn/chunks/{score-QTZEGTBP.js → score-GUHJWHW3.js} +6 -6
- package/dist/cdn/chunks/{score-QTZEGTBP.js.map → score-GUHJWHW3.js.map} +4 -4
- package/dist/cdn/chunks/{stats-CNVSRBY6.js → stats-UIVYR2CG.js} +2 -2
- package/dist/cdn/chunks/{stats-CNVSRBY6.js.map → stats-UIVYR2CG.js.map} +1 -1
- package/dist/cdn/chunks/{stock-2KHFILSB.js → stock-PV4GC573.js} +2 -2
- package/dist/cdn/chunks/{stock-2KHFILSB.js.map → stock-PV4GC573.js.map} +1 -1
- package/dist/cdn/chunks/{weather-FAK6EHSV.js → weather-7L3Y3DNB.js} +2 -2
- package/dist/cdn/chunks/{weather-FAK6EHSV.js.map → weather-7L3Y3DNB.js.map} +1 -1
- package/dist/cdn/chunks/zh-CN-WKC5MGZY.js +2 -0
- package/dist/cdn/chunks/zh-CN-WKC5MGZY.js.map +7 -0
- package/dist/cdn/n8n-chat.js +61 -61
- package/dist/cdn/n8n-chat.js.map +4 -4
- package/dist/create-chat.d.ts +27 -2
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/dist/strings.d.ts +5 -0
- package/dist/style.css +5 -9
- package/dist/theme.css +4 -8
- package/package.json +7 -7
- package/dist/cdn/chunks/chunk-7CJVMXIB.js +0 -356
- package/dist/cdn/chunks/chunk-7CJVMXIB.js.map +0 -7
- package/dist/cdn/chunks/chunk-N7SVHDCW.js +0 -206
- package/dist/cdn/chunks/chunk-N7SVHDCW.js.map +0 -7
- package/dist/cdn/chunks/de-NQDMZC5V.js +0 -2
- package/dist/cdn/chunks/de-NQDMZC5V.js.map +0 -7
- package/dist/cdn/chunks/es-IBJAOBGB.js +0 -2
- package/dist/cdn/chunks/es-IBJAOBGB.js.map +0 -7
- package/dist/cdn/chunks/fr-32HJELG3.js +0 -2
- package/dist/cdn/chunks/fr-32HJELG3.js.map +0 -7
- package/dist/cdn/chunks/it-HHSL2KBW.js +0 -2
- package/dist/cdn/chunks/it-HHSL2KBW.js.map +0 -7
- package/dist/cdn/chunks/ja-2EHR4WNO.js +0 -2
- package/dist/cdn/chunks/ja-2EHR4WNO.js.map +0 -7
- package/dist/cdn/chunks/ko-XONDEFR4.js +0 -2
- package/dist/cdn/chunks/ko-XONDEFR4.js.map +0 -7
- package/dist/cdn/chunks/link-VR62DJAD.js.map +0 -7
- package/dist/cdn/chunks/pt-BR-367NLYVE.js +0 -2
- package/dist/cdn/chunks/pt-BR-367NLYVE.js.map +0 -7
- package/dist/cdn/chunks/ru-ETHLBBSY.js +0 -2
- package/dist/cdn/chunks/ru-ETHLBBSY.js.map +0 -7
- package/dist/cdn/chunks/zh-CN-OGEW5BS2.js +0 -2
- package/dist/cdn/chunks/zh-CN-OGEW5BS2.js.map +0 -7
package/README.md
CHANGED
|
@@ -7,8 +7,8 @@ your call. And your workflow can answer with **rich cards** — an order, a book
|
|
|
7
7
|
weather — and offer **quick replies** the visitor clicks. [See it live](https://n8n-chat.apartejs.dev).
|
|
8
8
|
|
|
9
9
|
<p>
|
|
10
|
-
<img src="https://raw.githubusercontent.com/apartejs/n8n-chat/
|
|
11
|
-
<img src="https://raw.githubusercontent.com/apartejs/n8n-chat/
|
|
10
|
+
<img src="https://raw.githubusercontent.com/apartejs/n8n-chat/v1.0.0/docs/widget-card-order.png" alt="The widget answering where order 1001 is, with the order's card: its items, its status and its total, and a small Powered by aparté line under the input" width="300">
|
|
11
|
+
<img src="https://raw.githubusercontent.com/apartejs/n8n-chat/v1.0.0/docs/widget-card-dark.png" alt="The same widget in its dark scheme, answering about order 1002 with its card" width="300">
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
- Rich cards your workflow writes as text: weather, order and booking, product, place, list, key
|
|
@@ -19,7 +19,7 @@ weather — and offer **quick replies** the visitor clicks. [See it live](https:
|
|
|
19
19
|
- Every option of `@n8n/chat` 1.43, the same defaults, the same session in the browser — and the
|
|
20
20
|
Chat nodes' messages and buttons of a workflow that answers through response nodes.
|
|
21
21
|
- Ten languages, keyboard and screen-reader access, readable contrast, a dark scheme.
|
|
22
|
-
- About
|
|
22
|
+
- About 151 KB compressed on the first load, against about 471 KB (measured 2026-11-07 on 1.0.0; `@n8n/chat` 1.44.7 on 2026-10-31).
|
|
23
23
|
- A handle to drive it from your page: `open`, `close`, `toggle`, `send`, `reset`, `setDisabled`,
|
|
24
24
|
`destroy`.
|
|
25
25
|
- MIT. A small grey "Powered by aparté" line sits under the input, linking to [apartejs.dev](https://apartejs.dev).
|
|
@@ -29,9 +29,9 @@ weather — and offer **quick replies** the visitor clicks. [See it live](https:
|
|
|
29
29
|
### From a CDN — no build step
|
|
30
30
|
|
|
31
31
|
```html
|
|
32
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@0.
|
|
32
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@1.0.0/dist/style.css">
|
|
33
33
|
<script type="module">
|
|
34
|
-
import { createChat } from 'https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@0.
|
|
34
|
+
import { createChat } from 'https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@1.0.0/dist/cdn/n8n-chat.js';
|
|
35
35
|
|
|
36
36
|
createChat({ webhookUrl: 'https://your-n8n.example.com/webhook/<id>/chat' });
|
|
37
37
|
</script>
|
|
@@ -61,10 +61,10 @@ Replace the stylesheet and the import; the call stays as it is:
|
|
|
61
61
|
|
|
62
62
|
```diff
|
|
63
63
|
- <link href="https://cdn.jsdelivr.net/npm/@n8n/chat/dist/style.css" rel="stylesheet" />
|
|
64
|
-
+ <link href="https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@0.
|
|
64
|
+
+ <link href="https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@1.0.0/dist/style.css" rel="stylesheet" />
|
|
65
65
|
<script type="module">
|
|
66
66
|
- import { createChat } from 'https://cdn.jsdelivr.net/npm/@n8n/chat/dist/chat.bundle.es.js';
|
|
67
|
-
+ import { createChat } from 'https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@0.
|
|
67
|
+
+ import { createChat } from 'https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@1.0.0/dist/cdn/n8n-chat.js';
|
|
68
68
|
createChat({ webhookUrl: 'https://your-n8n.example.com/webhook/<id>/chat' });
|
|
69
69
|
</script>
|
|
70
70
|
```
|
|
@@ -113,6 +113,8 @@ memory on the agent only, n8n answers that request with an error.
|
|
|
113
113
|
| `metadata` | sent with every message, as `metadata` in the trigger's output | — |
|
|
114
114
|
| `allowFileUploads`, `allowedFilesMimeTypes` | let the person attach files, and which (`'image/*,application/pdf'`, extensions too) | `false`, any |
|
|
115
115
|
| `cards` | draw the ` ```card-<name> ` blocks of an answer as [cards](#cards-and-quick-replies-from-a-text-answer); an object gives a card its options (`{ place: { mapTiles } }`) | `true` |
|
|
116
|
+
| `images` | which [pictures in an answer](#pictures-in-an-answer) load by themselves: every one, or only those from the origins you list (`['https://cdn.example.com']`; the others wait for a click) | every one |
|
|
117
|
+
| `waitingPrefix` | where your n8n serves a Chat node's button links, when the webhook URL does not tell ([buttons](#response-nodes-and-buttons)) | read from the webhook URL |
|
|
116
118
|
| `setup` | `(config) => stop?`: aparté's plugins and your own cards, on this chat ([below](#your-own-cards-and-apartés-plugins)) | — |
|
|
117
119
|
| `enableMessageActions` | "Repost" and "Reuse" on the person's own messages | `false` |
|
|
118
120
|
| `disabled` | block the input (`true`, or n8n's `{ value }`) | `false` |
|
|
@@ -155,7 +157,10 @@ not approved — as with n8n's own widget.
|
|
|
155
157
|
Up to n8n 2.45, Chat nodes run only when the Chat Trigger's **Mode** is **Hosted Chat**; an
|
|
156
158
|
embedded one stops with "Embedded chat is not supported". n8n 2.46 and 3.0 lift that limit and run
|
|
157
159
|
them in **Embedded** mode too; the widget has been tested with Hosted Chat. A button whose link
|
|
158
|
-
leads off your n8n is not shown.
|
|
160
|
+
leads off your n8n is not shown, nor one whose link does not resume the running execution. The
|
|
161
|
+
widget reads where n8n's waiting links live from the webhook URL. Set `waitingPrefix` (a path) when
|
|
162
|
+
they live elsewhere: your own `N8N_ENDPOINT_WEBHOOK_WAIT`, or your own `N8N_ENDPOINT_WEBHOOK` (a
|
|
163
|
+
webhook URL that is not `…/webhook/<id>/chat`), where no button shows until you do.
|
|
159
164
|
|
|
160
165
|
## Cards and quick replies, from a text answer
|
|
161
166
|
|
|
@@ -177,8 +182,11 @@ Which day suits you?
|
|
|
177
182
|
````
|
|
178
183
|
|
|
179
184
|
Nothing of the block shows in the message; the replies are the last answer's, a click sends one as
|
|
180
|
-
if it were typed, and they go when a message is sent. A string
|
|
181
|
-
|
|
185
|
+
if it were typed, and they go when a message is sent. A string, or an object's `label`, is both what
|
|
186
|
+
is shown and what is sent: a `prompt` beside it is ignored, so a button never sends words the
|
|
187
|
+
visitor did not read. A reply is 1 to 100 visible characters: a blank one, a longer one or one
|
|
188
|
+
holding invisible characters is left out (the console says so), so a label built from data — a
|
|
189
|
+
long product name — is best shortened.
|
|
182
190
|
The [booking workflow](https://n8n-chat.apartejs.dev/#workflows) offers its days and times this way:
|
|
183
191
|
the agent calls a small **Suggest replies** tool, and a Code node writes the block. `replies: false`
|
|
184
192
|
shows the blocks as code.
|
|
@@ -259,7 +267,7 @@ createChat({
|
|
|
259
267
|
```
|
|
260
268
|
|
|
261
269
|
Take `defineCard` from the widget's own module, as above, and from the same URL when you load
|
|
262
|
-
it from a CDN (`…/@aparte/n8n-chat@0.
|
|
270
|
+
it from a CDN (`…/@aparte/n8n-chat@1.0.0/dist/cdn/n8n-chat.js`): the card and the chat then share
|
|
263
271
|
one copy of aparté. A kit loaded from another URL keeps its cards where the chat never looks.
|
|
264
272
|
|
|
265
273
|
````md
|
|
@@ -345,6 +353,23 @@ With `allowFileUploads`, the visitor picks, drops or pastes files, and n8n recei
|
|
|
345
353
|
`files`, as from n8n's widget. A file can be removed with the keyboard; a picture or a file the
|
|
346
354
|
visitor sent opens in a new tab.
|
|
347
355
|
|
|
356
|
+
## Pictures in an answer
|
|
357
|
+
|
|
358
|
+
A picture an answer names loads by itself, as in n8n's own widget: nothing to set. If your workflow
|
|
359
|
+
reads content you do not control — e-mails, web pages, a document a visitor sends — name the
|
|
360
|
+
origins your pictures come from. A model steered by such content can write the conversation into a
|
|
361
|
+
picture's address, and the browser fetches it without a click; with `images`, any other picture
|
|
362
|
+
waits behind a link that names its host, until the visitor clicks it. The same list decides a
|
|
363
|
+
media card's video and sound.
|
|
364
|
+
|
|
365
|
+
```js
|
|
366
|
+
createChat({ webhookUrl: '…', images: ['https://cdn.example.com'] });
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
An origin is written with its scheme: `'https://cdn.example.com'` (a bare host allows nothing).
|
|
370
|
+
`'self'` is your page's own origin, `true` or `'*'` every picture, `false` none by itself, and a
|
|
371
|
+
function decides each address (`'load'`, `'hold'` or `'drop'`).
|
|
372
|
+
|
|
348
373
|
## Keeping bots out
|
|
349
374
|
|
|
350
375
|
A public Chat Trigger answers anyone who finds its URL, and every answer can cost you a call to
|
|
@@ -358,11 +383,11 @@ so the page puts a fresh token in `metadata` before every message.
|
|
|
358
383
|
2. In the page:
|
|
359
384
|
|
|
360
385
|
```html
|
|
361
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@0.
|
|
386
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@1.0.0/dist/style.css">
|
|
362
387
|
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit"></script>
|
|
363
388
|
<div id="turnstile"></div>
|
|
364
389
|
<script type="module">
|
|
365
|
-
import { createChat } from 'https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@0.
|
|
390
|
+
import { createChat } from 'https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@1.0.0/dist/cdn/n8n-chat.js';
|
|
366
391
|
|
|
367
392
|
// A Turnstile token is single-use and lasts five minutes: ask for a new one before each message.
|
|
368
393
|
let widgetId;
|
|
@@ -416,9 +441,69 @@ only: with file uploads, check that your agent still receives the files after th
|
|
|
416
441
|
|
|
417
442
|
## Languages
|
|
418
443
|
|
|
419
|
-
English, French, Spanish, Portuguese (Brazil), German, Italian, Russian, Japanese, Korean
|
|
420
|
-
Chinese (Simplified). A page downloads only the language it uses.
|
|
421
|
-
|
|
444
|
+
Ten ship: English, French, Spanish, Portuguese (Brazil), German, Italian, Russian, Japanese, Korean
|
|
445
|
+
and Chinese (Simplified). A page downloads only the language it uses.
|
|
446
|
+
|
|
447
|
+
### Pick one
|
|
448
|
+
|
|
449
|
+
```js
|
|
450
|
+
createChat({
|
|
451
|
+
webhookUrl: '…',
|
|
452
|
+
defaultLanguage: 'fr', // a tag: 'de', 'pt-BR', 'zh-CN'… 'fr-CA' reads in French
|
|
453
|
+
});
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
The header, the first messages, the input and the chat's own words (its buttons, its error card,
|
|
457
|
+
what a screen reader hears) all switch. To follow the visitor's browser, pass
|
|
458
|
+
`defaultLanguage: navigator.language`: a language not shipped reads in English, left to right,
|
|
459
|
+
until you give its words ([below](#another-language-right-to-left-included)); `i18n` words under
|
|
460
|
+
`ar` serve `ar-SA` too.
|
|
461
|
+
|
|
462
|
+
### Change a few words
|
|
463
|
+
|
|
464
|
+
`i18n` takes the header's and the input's words by language, over the built-in ones:
|
|
465
|
+
|
|
466
|
+
```js
|
|
467
|
+
createChat({
|
|
468
|
+
webhookUrl: '…',
|
|
469
|
+
defaultLanguage: 'fr',
|
|
470
|
+
i18n: { fr: { title: 'Bonjour 👋', subtitle: 'Une question sur votre commande ?', inputPlaceholder: 'Votre question…' } },
|
|
471
|
+
initialMessages: ['Bonjour ! Comment puis-je vous aider ?'],
|
|
472
|
+
});
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
The keys: `title`, `subtitle`, `footer`, `inputPlaceholder`, `getStarted`, `closeButtonTooltip`,
|
|
476
|
+
`poweredBy` (`{aparte}` stands for the link), `repostButton` and `reuseButton`.
|
|
477
|
+
|
|
478
|
+
### Another language, right to left included
|
|
479
|
+
|
|
480
|
+
A language that does not ship takes its words from you: `i18n` for the header and the input, and
|
|
481
|
+
aparté's locale, through `setup`, for the chat's own. Arabic, Hebrew, Persian, Urdu and the other
|
|
482
|
+
right-to-left languages turn the whole widget right to left from their tag alone — header, messages,
|
|
483
|
+
input, and the launcher, which moves to the bottom left — even on a left-to-right page. Code, a
|
|
484
|
+
formula or an English answer inside it still read left to right.
|
|
485
|
+
|
|
486
|
+
```js
|
|
487
|
+
createChat({
|
|
488
|
+
webhookUrl: '…',
|
|
489
|
+
defaultLanguage: 'ar',
|
|
490
|
+
i18n: {
|
|
491
|
+
ar: {
|
|
492
|
+
title: 'مرحبا 👋',
|
|
493
|
+
subtitle: 'نحن هنا لمساعدتك.',
|
|
494
|
+
inputPlaceholder: 'اكتب سؤالك…',
|
|
495
|
+
closeButtonTooltip: 'إغلاق',
|
|
496
|
+
poweredBy: 'بدعم من {aparte}',
|
|
497
|
+
},
|
|
498
|
+
},
|
|
499
|
+
initialMessages: ['مرحبا! كيف يمكنني مساعدتك اليوم؟'],
|
|
500
|
+
// The chat's own words, over the English ones: the type lists every key.
|
|
501
|
+
setup: (config) => config.setLocale({ ...config.getLocale(), tag: 'ar', sendButton: 'إرسال', copy: 'نسخ' }),
|
|
502
|
+
});
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
A page that is right to left already (`<html dir="rtl">`) needs nothing more: the widget follows it in
|
|
506
|
+
any language.
|
|
422
507
|
|
|
423
508
|
## Colors
|
|
424
509
|
|
|
@@ -481,18 +566,24 @@ or Angular components, inside an `.aparte-n8n` element.
|
|
|
481
566
|
| Drive it from the page | — | `open`, `close`, `toggle`, `send`, `reset`, `setDisabled`, `destroy` |
|
|
482
567
|
| A new conversation | not until the browser's storage is cleared | `reset()` |
|
|
483
568
|
| A tool's steps after a reload | bubbles with raw JSON | left out, as while chatting |
|
|
484
|
-
| An error | the raw message | a sentence in the visitor's language
|
|
569
|
+
| An error | the raw message | a sentence in the visitor's language; the workflow's own words and what to fix, on the console |
|
|
485
570
|
| Languages | English | ten, loaded one at a time |
|
|
486
571
|
| Keyboard and screen reader | buttons without names | named controls, a labelled window, a modal sheet on a phone |
|
|
487
572
|
| Contrast of the visitor's bubble | 2.55:1 | 4.7:1 (WCAG AA) |
|
|
488
573
|
| Dark scheme | — | ✓ |
|
|
489
574
|
| Rich cards | the JSON as text | drawn: order, booking, product, weather… |
|
|
490
575
|
| Quick replies offered by an answer | the block as code | buttons above the input |
|
|
491
|
-
| Weight, first load (compressed) | ~471 KB | ~
|
|
576
|
+
| Weight, first load (compressed) | ~471 KB | ~151 KB |
|
|
492
577
|
| License | Sustainable Use License | MIT |
|
|
493
578
|
|
|
494
579
|
## Versions
|
|
495
580
|
|
|
581
|
+
From 1.0.0 the widget follows semantic versioning: the options of `createChat`, the handle it
|
|
582
|
+
returns, what the module exports (the card kit included), the `i18n` keys, the `--chat--*`
|
|
583
|
+
variables, the `.aparte-n8n` root with its `data-aparte-theme`, and the files a page loads
|
|
584
|
+
(`dist/cdn/n8n-chat.js`, `dist/style.css`, `./theme.css`) keep their names, and what they do, until
|
|
585
|
+
2.0. A security fix may refuse what was accepted in any release, and says so first in its notes.
|
|
586
|
+
|
|
496
587
|
The widget depends on **exact** versions of aparté's packages, and moves to a newer aparté only in
|
|
497
588
|
a release of its own. Pin the widget's version in a CDN URL and in your `package.json`, and what you
|
|
498
589
|
tested is what your visitors run.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as n}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as n}from"./chunk-FPBJCFJN.js";function p(a,{name:s,options:i,value:c,label:l}){if(!a.live||i.length===0)return null;let r=n("div",{class:"aparte-rich-card__segmented",attrs:{role:"group"}});l&&a.bind(r,l,"aria-label");for(let e of i){let d=e.value===c,t=n("button",{class:"aparte-rich-card__segment",attrs:{type:"button","aria-pressed":d?"true":"false","data-card-key":`${s}:${e.value}`}});typeof e.label=="function"?a.bind(t,e.label):t.textContent=e.label,t.addEventListener("click",()=>{if(t.getAttribute("aria-pressed")!=="true"){for(let u of r.querySelectorAll(".aparte-rich-card__segment"))u.setAttribute("aria-pressed",u===t?"true":"false");a.change(s,e.value)}}),r.append(t)}return r}export{p as a};
|
|
2
|
+
//# sourceMappingURL=chunk-75MBZEMR.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../node_modules/.pnpm/@aparte+plugin-cards@0.
|
|
3
|
+
"sources": ["../../../node_modules/.pnpm/@aparte+plugin-cards@1.0.0_@aparte+core@1.0.0/node_modules/@aparte/plugin-cards/src/kit/controls.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * Controls a card can carry: a row of choices, a switch, a slider. Each reports through\n * `ctx.change(name, value)`, so the card fires `aparte-card-change` and the app's\n * `onChange` answers with new data, drawn in place — a stock chart's range, a light's\n * brightness.\n *\n * A control is drawn only when something will answer it (`ctx.live`): without an\n * `onChange`, a button that does nothing would be a promise the card cannot keep\n * (ratified decision #8). Each control carries a `data-card-key`, so a redraw puts the\n * focus back on the control that was pressed.\n */\nimport type { CardContext } from './define.js';\nimport { el } from './dom.js';\n\nexport interface SegmentedOptions {\n /** The control's name in the change (`range`). */\n name: string;\n /** The choices; a label is a string or a function read again on a language switch. */\n options: Array<{ value: string; label: string | (() => string) }>;\n /** The choice in force. */\n value?: string;\n /** The group's accessible name. */\n label?: () => string;\n}\n\n/** A row of choices, one pressed (`aria-pressed`). `null` when nothing would answer it. */\nexport function segmented(ctx: CardContext, { name, options, value, label }: SegmentedOptions): HTMLElement | null {\n if (!ctx.live || options.length === 0) return null;\n const group = el('div', { class: 'aparte-rich-card__segmented', attrs: { role: 'group' } });\n if (label) ctx.bind(group, label, 'aria-label');\n for (const option of options) {\n const pressed = option.value === value;\n const button = el('button', {\n class: 'aparte-rich-card__segment',\n attrs: { type: 'button', 'aria-pressed': pressed ? 'true' : 'false', 'data-card-key': `${name}:${option.value}` },\n });\n if (typeof option.label === 'function') ctx.bind(button, option.label);\n else button.textContent = option.label;\n button.addEventListener('click', () => {\n if (button.getAttribute('aria-pressed') === 'true') return;\n // Pressed at once, before the app answers: a second press reads what was chosen.\n for (const other of group.querySelectorAll('.aparte-rich-card__segment')) other.setAttribute('aria-pressed', other === button ? 'true' : 'false');\n ctx.change(name, option.value);\n });\n group.append(button);\n }\n return group;\n}\n\nexport interface ToggleOptions {\n name: string;\n checked: boolean;\n /** What it switches (\"Living-room light\"). */\n label: () => string;\n}\n\n/** A switch (`role=\"switch\"`). `null` when nothing would answer it. */\nexport function toggle(ctx: CardContext, { name, checked, label }: ToggleOptions): HTMLElement | null {\n if (!ctx.live) return null;\n const button = el('button', {\n class: 'aparte-rich-card__toggle',\n attrs: { type: 'button', role: 'switch', 'aria-checked': checked ? 'true' : 'false', 'data-card-key': name },\n }, el('span', { class: 'aparte-rich-card__toggle-thumb', attrs: { 'aria-hidden': 'true' } }));\n ctx.bind(button, label, 'aria-label');\n button.addEventListener('click', () => {\n // Flipped at once, before the app answers: a second click before the answer flips it\n // back, rather than sending the same state twice.\n const next = button.getAttribute('aria-checked') !== 'true';\n button.setAttribute('aria-checked', next ? 'true' : 'false');\n ctx.change(name, next);\n });\n return button;\n}\n\nexport interface SliderOptions {\n name: string;\n value: number;\n min?: number;\n max?: number;\n step?: number;\n label: () => string;\n /** How the value reads beside it, and to a screen reader (\"60 %\"). */\n format?: (value: number) => string;\n}\n\n/**\n * A slider: the value beside it follows while it moves, the change is reported once it is\n * let go (`change`, not `input`) — one request for a drag, not one per pixel.\n */\nexport function slider(ctx: CardContext, { name, value, min = 0, max = 100, step = 1, label, format = String }: SliderOptions): HTMLElement | null {\n if (!ctx.live) return null;\n const input = el('input', {\n class: 'aparte-rich-card__slider-input',\n attrs: { type: 'range', min, max, step, value, 'data-card-key': name },\n });\n const shown = el('output', { class: 'aparte-rich-card__slider-value' });\n const name_ = el('span', { class: 'aparte-rich-card__slider-label' });\n ctx.bind(name_, label);\n ctx.bind(input, label, 'aria-label');\n const paint = (v: number) => {\n shown.textContent = format(v);\n input.setAttribute('aria-valuetext', format(v));\n };\n ctx.bind(shown, () => format(Number(input.value)));\n paint(value);\n input.addEventListener('input', () => paint(Number(input.value)));\n input.addEventListener('change', () => ctx.change(name, Number(input.value)));\n return el('label', { class: 'aparte-rich-card__slider' }, name_, input, shown);\n}\n"],
|
|
5
5
|
"mappings": "wCA0BO,SAASA,EAAUC,EAAkB,CAAE,KAAAC,EAAM,QAAAC,EAAS,MAAAC,EAAO,MAAAC,CAAA,EAA+C,CAC/G,GAAI,CAACJ,EAAI,MAAQE,EAAQ,SAAW,EAAG,OAAO,KAC9C,IAAMG,EAAQC,EAAG,MAAO,CAAE,MAAO,8BAA+B,MAAO,CAAE,KAAM,OAAA,CAAA,CAAW,EACtFF,GAAOJ,EAAI,KAAKK,EAAOD,EAAO,YAAY,EAC9C,QAAWG,KAAUL,EAAS,CAC1B,IAAMM,EAAUD,EAAO,QAAUJ,EAC3BM,EAASH,EAAG,SAAU,CACxB,MAAO,4BACP,MAAO,CAAE,KAAM,SAAU,eAAgBE,EAAU,OAAS,QAAS,gBAAiB,GAAGP,CAAI,IAAIM,EAAO,KAAK,EAAA,CAAG,CACnH,EACG,OAAOA,EAAO,OAAU,WAAAP,EAAgB,KAAKS,EAAQF,EAAO,KAAK,EAChEE,EAAO,YAAcF,EAAO,MACjCE,EAAO,iBAAiB,QAAS,IAAM,CACnC,GAAIA,EAAO,aAAa,cAAc,IAAM,OAE5C,SAAWC,KAASL,EAAM,iBAAiB,4BAA4B,EAAGK,EAAM,aAAa,eAAgBA,IAAUD,EAAS,OAAS,OAAO,EAChJT,EAAI,OAAOC,EAAMM,EAAO,KAAK,EACjC,CAAC,EACDF,EAAM,OAAOI,CAAM,CACvB,CACA,OAAOJ,CACX",
|
|
6
6
|
"names": ["segmented", "ctx", "name", "options", "value", "label", "group", "el", "option", "pressed", "button", "other"]
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i,b as p,i as l,j as g,q as e}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as i,b as p,i as l,j as g,q as e}from"./chunk-FPBJCFJN.js";var _="M12 2.6l2.9 5.9 6.5.95-4.7 4.6 1.1 6.5L12 17.5l-5.8 3.05 1.1-6.5-4.7-4.6 6.5-.95z",h=`<svg viewBox="0 0 120 24" xmlns="http://www.w3.org/2000/svg">${[0,24,48,72,96].map(a=>`<path transform="translate(${a} 0)" d="${_}"/>`).join("")}</svg>`;function b(a,c,{max:t=5,count:s,starsOnly:f=!1}={}){if(c===void 0||!Number.isFinite(c)||t<=0)return null;let d=Math.max(0,Math.min(t,c)),m=i("span",{class:"aparte-rich-card__stars",attrs:{"aria-hidden":"true"}},p(h,"aparte-rich-card__stars-base"),p(h,"aparte-rich-card__stars-fill"));m.style.setProperty("--aparte-rich-card-rating",`${d/t*100}%`);let n=i("span",{class:"aparte-rich-card__rating",attrs:{role:"img"}},m),o=r=>e(a.config,r,{maximumFractionDigits:1});if(!f){let r=i("span",{class:"aparte-rich-card__rating-value",attrs:{"aria-hidden":"true"}});a.bind(r,()=>o(d)),n.append(r)}if(s!==void 0&&Number.isFinite(s)){let r=i("span",{class:"aparte-rich-card__rating-count",attrs:{"aria-hidden":"true"}});a.bind(r,()=>`(${e(a.config,s,{notation:s>=1e4?"compact":"standard"})})`),n.append(r)}return a.bind(n,()=>{let r=l(a.config,"cardsRating",g.cardsRating,{value:o(d),max:o(t)});return s!==void 0&&Number.isFinite(s)?`${r}, ${l(a.config,"cardsReviews",g.cardsReviews,{count:e(a.config,s)})}`:r},"aria-label"),n}export{b as a};
|
|
2
|
+
//# sourceMappingURL=chunk-EKOAQWDB.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../node_modules/.pnpm/@aparte+plugin-cards@0.
|
|
3
|
+
"sources": ["../../../node_modules/.pnpm/@aparte+plugin-cards@1.0.0_@aparte+core@1.0.0/node_modules/@aparte/plugin-cards/src/kit/rating.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * A rating: stars filled to the value, the value, and how many reviews it averages.\n *\n * Two rows of the same five stars, the coloured one clipped to the value's width, so\n * 4.6 shows six tenths of the fifth star. Read aloud as one sentence (\"Rated 4.6 out\n * of 5, 1,284 reviews\"); the stars themselves are hidden from a screen reader.\n */\nimport type { CardContext } from './define.js';\nimport { el, glyph } from './dom.js';\nimport { formatNumber } from './format.js';\nimport { KIT_WORDS, word } from './strings.js';\n\nconst STAR = 'M12 2.6l2.9 5.9 6.5.95-4.7 4.6 1.1 6.5L12 17.5l-5.8 3.05 1.1-6.5-4.7-4.6 6.5-.95z';\nconst FIVE = `<svg viewBox=\"0 0 120 24\" xmlns=\"http://www.w3.org/2000/svg\">${[0, 24, 48, 72, 96].map((x) => `<path transform=\"translate(${x} 0)\" d=\"${STAR}\"/>`).join('')}</svg>`; // safe-attr: this package's own glyph constants and loop numbers, never data // safe-text: this package's own SVG, built from its glyph constants\n\nexport interface RatingOptions {\n /** The scale's top (5 by default). */\n max?: number;\n /** How many reviews the value averages. */\n count?: number;\n /** Leave the number out and keep the stars. */\n starsOnly?: boolean;\n}\n\n/** The rating as an element, or `null` for no value. */\nexport function rating(ctx: CardContext, value: number | undefined, { max = 5, count, starsOnly = false }: RatingOptions = {}): HTMLElement | null {\n if (value === undefined || !Number.isFinite(value) || max <= 0) return null;\n const clamped = Math.max(0, Math.min(max, value));\n const stars = el('span', { class: 'aparte-rich-card__stars', attrs: { 'aria-hidden': 'true' } },\n glyph(FIVE, 'aparte-rich-card__stars-base'),\n glyph(FIVE, 'aparte-rich-card__stars-fill'));\n stars.style.setProperty('--aparte-rich-card-rating', `${(clamped / max) * 100}%`);\n const node = el('span', { class: 'aparte-rich-card__rating', attrs: { role: 'img' } }, stars);\n const shown = (n: number) => formatNumber(ctx.config, n, { maximumFractionDigits: 1 });\n if (!starsOnly) {\n const number = el('span', { class: 'aparte-rich-card__rating-value', attrs: { 'aria-hidden': 'true' } });\n ctx.bind(number, () => shown(clamped));\n node.append(number);\n }\n if (count !== undefined && Number.isFinite(count)) {\n const reviews = el('span', { class: 'aparte-rich-card__rating-count', attrs: { 'aria-hidden': 'true' } });\n ctx.bind(reviews, () => `(${formatNumber(ctx.config, count, { notation: count >= 10_000 ? 'compact' : 'standard' })})`);\n node.append(reviews);\n }\n ctx.bind(node, () => {\n const sentence = word(ctx.config, 'cardsRating', KIT_WORDS.cardsRating, { value: shown(clamped), max: shown(max) });\n return count !== undefined && Number.isFinite(count)\n ? `${sentence}, ${word(ctx.config, 'cardsReviews', KIT_WORDS.cardsReviews, { count: formatNumber(ctx.config, count) })}`\n : sentence;\n }, 'aria-label');\n return node;\n}\n"],
|
|
5
5
|
"mappings": "oEAYA,IAAMA,EAAO,oFACPC,EAAO,gEAAgE,CAAC,EAAG,GAAI,GAAI,GAAI,EAAE,EAAE,IAAKC,GAAM,8BAA8BA,CAAC,WAAWF,CAAI,KAAK,EAAE,KAAK,EAAE,CAAC,SAYlK,SAASG,EAAOC,EAAkBC,EAA2B,CAAE,IAAAC,EAAM,EAAG,MAAAC,EAAO,UAAAC,EAAY,EAAA,EAAyB,CAAA,EAAwB,CAC/I,GAAIH,IAAU,QAAa,CAAC,OAAO,SAASA,CAAK,GAAKC,GAAO,EAAG,OAAO,KACvE,IAAMG,EAAU,KAAK,IAAI,EAAG,KAAK,IAAIH,EAAKD,CAAK,CAAC,EAC1CK,EAAQC,EAAG,OAAQ,CAAE,MAAO,0BAA2B,MAAO,CAAE,cAAe,MAAA,CAAO,EACxFC,EAAMX,EAAM,8BAA8B,EAC1CW,EAAMX,EAAM,8BAA8B,CAAA,EAC9CS,EAAM,MAAM,YAAY,4BAA6B,GAAID,EAAUH,EAAO,GAAG,GAAG,EAChF,IAAMO,EAAOF,EAAG,OAAQ,CAAE,MAAO,2BAA4B,MAAO,CAAE,KAAM,KAAA,CAAM,EAAKD,CAAK,EACtFI,EAASC,GAAcC,EAAaZ,EAAI,OAAQW,EAAG,CAAE,sBAAuB,CAAA,CAAG,EACrF,GAAI,CAACP,EAAW,CACZ,IAAMS,EAASN,EAAG,OAAQ,CAAE,MAAO,iCAAkC,MAAO,CAAE,cAAe,MAAA,CAAA,CAAU,EACvGP,EAAI,KAAKa,EAAQ,IAAMH,EAAML,CAAO,CAAC,EACrCI,EAAK,OAAOI,CAAM,CACtB,CACA,GAAIV,IAAU,QAAa,OAAO,SAASA,CAAK,EAAG,CAC/C,IAAMW,EAAUP,EAAG,OAAQ,CAAE,MAAO,iCAAkC,MAAO,CAAE,cAAe,MAAA,CAAA,CAAU,EACxGP,EAAI,KAAKc,EAAS,IAAM,IAAIF,EAAaZ,EAAI,OAAQG,EAAO,CAAE,SAAUA,GAAS,IAAS,UAAY,UAAA,CAAY,CAAC,GAAG,EACtHM,EAAK,OAAOK,CAAO,CACvB,CACA,OAAAd,EAAI,KAAKS,EAAM,IAAM,CACjB,IAAMM,EAAWC,EAAKhB,EAAI,OAAQ,cAAeiB,EAAU,YAAa,CAAE,MAAOP,EAAML,CAAO,EAAG,IAAKK,EAAMR,CAAG,CAAA,CAAG,EAClH,OAAOC,IAAU,QAAa,OAAO,SAASA,CAAK,EAC7C,GAAGY,CAAQ,KAAKC,EAAKhB,EAAI,OAAQ,eAAgBiB,EAAU,aAAc,CAAE,MAAOL,EAAaZ,EAAI,OAAQG,CAAK,CAAA,CAAG,CAAC,GACpHY,CACV,EAAG,YAAY,EACRN,CACX",
|
|
6
6
|
"names": ["STAR", "FIVE", "x", "rating", "ctx", "value", "max", "count", "starsOnly", "clamped", "stars", "el", "glyph", "node", "shown", "n", "formatNumber", "number", "reviews", "sentence", "word", "KIT_WORDS"]
|