@aparte/n8n-chat 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.
Files changed (66) hide show
  1. package/README.md +24 -3
  2. package/dist/cdn/chunks/{chunk-XY3GEFGN.js → chunk-6ZVO7OTR.js} +2 -2
  3. package/dist/cdn/chunks/{chunk-XY3GEFGN.js.map → chunk-6ZVO7OTR.js.map} +1 -1
  4. package/dist/cdn/chunks/{chunk-LGVX5DQP.js → chunk-7K4YMHQR.js} +2 -2
  5. package/dist/cdn/chunks/{chunk-LGVX5DQP.js.map → chunk-7K4YMHQR.js.map} +1 -1
  6. package/dist/cdn/chunks/{chunk-KPADIE5S.js → chunk-KB6DEEIQ.js} +1 -1
  7. package/dist/cdn/chunks/{chunk-KPADIE5S.js.map → chunk-KB6DEEIQ.js.map} +1 -1
  8. package/dist/cdn/chunks/{chunk-4MZPEZPE.js → chunk-L72XRVUT.js} +30 -30
  9. package/dist/cdn/chunks/chunk-L72XRVUT.js.map +7 -0
  10. package/dist/cdn/chunks/{chunk-PPDOW5CO.js → chunk-S6J6TTL4.js} +2 -2
  11. package/dist/cdn/chunks/{chunk-PPDOW5CO.js.map → chunk-S6J6TTL4.js.map} +1 -1
  12. package/dist/cdn/chunks/{chunk-HASLYSSG.js → chunk-Y44OMGIJ.js} +2 -2
  13. package/dist/cdn/chunks/{chunk-HASLYSSG.js.map → chunk-Y44OMGIJ.js.map} +1 -1
  14. package/dist/cdn/chunks/{de-VHSIFTGU.js → de-7VJXZS3Y.js} +2 -2
  15. package/dist/cdn/chunks/{de-VHSIFTGU.js.map → de-7VJXZS3Y.js.map} +3 -3
  16. package/dist/cdn/chunks/{es-CSDZBDZK.js → es-DJOVPGNH.js} +2 -2
  17. package/dist/cdn/chunks/{es-CSDZBDZK.js.map → es-DJOVPGNH.js.map} +3 -3
  18. package/dist/cdn/chunks/{fr-A7LKKK4U.js → fr-MX37SEJL.js} +2 -2
  19. package/dist/cdn/chunks/{fr-A7LKKK4U.js.map → fr-MX37SEJL.js.map} +3 -3
  20. package/dist/cdn/chunks/{highlight-KR6IJJGG.js → highlight-UOFUMZVB.js} +2 -2
  21. package/dist/cdn/chunks/{highlight-KR6IJJGG.js.map → highlight-UOFUMZVB.js.map} +1 -1
  22. package/dist/cdn/chunks/{it-4UDH2XVX.js → it-ACF2ENLA.js} +2 -2
  23. package/dist/cdn/chunks/{it-4UDH2XVX.js.map → it-ACF2ENLA.js.map} +3 -3
  24. package/dist/cdn/chunks/{items-FFNVAESC.js → items-ZVVHDZQS.js} +2 -2
  25. package/dist/cdn/chunks/{items-FFNVAESC.js.map → items-ZVVHDZQS.js.map} +1 -1
  26. package/dist/cdn/chunks/{ja-5FMFPBXT.js → ja-RUBXQ3AK.js} +2 -2
  27. package/dist/cdn/chunks/{ja-5FMFPBXT.js.map → ja-RUBXQ3AK.js.map} +3 -3
  28. package/dist/cdn/chunks/{ko-KXXFK5U7.js → ko-SZPL4AIC.js} +2 -2
  29. package/dist/cdn/chunks/{ko-KXXFK5U7.js.map → ko-SZPL4AIC.js.map} +3 -3
  30. package/dist/cdn/chunks/{link-3AMG5PIK.js → link-7HOSE2HR.js} +2 -2
  31. package/dist/cdn/chunks/{link-3AMG5PIK.js.map → link-7HOSE2HR.js.map} +1 -1
  32. package/dist/cdn/chunks/{media-F3HYZLYR.js → media-TKQMGWJL.js} +2 -2
  33. package/dist/cdn/chunks/{media-F3HYZLYR.js.map → media-TKQMGWJL.js.map} +1 -1
  34. package/dist/cdn/chunks/{order-L6GKT5I6.js → order-JHIBAOAM.js} +2 -2
  35. package/dist/cdn/chunks/{order-L6GKT5I6.js.map → order-JHIBAOAM.js.map} +1 -1
  36. package/dist/cdn/chunks/{place-J7BDZGKL.js → place-U5X4TNLJ.js} +2 -2
  37. package/dist/cdn/chunks/{place-J7BDZGKL.js.map → place-U5X4TNLJ.js.map} +1 -1
  38. package/dist/cdn/chunks/{plan-BAI6GY4A.js → plan-SLX26KB6.js} +2 -2
  39. package/dist/cdn/chunks/{plan-BAI6GY4A.js.map → plan-SLX26KB6.js.map} +1 -1
  40. package/dist/cdn/chunks/{product-VOKQKP4K.js → product-QD2UM2YC.js} +2 -2
  41. package/dist/cdn/chunks/{product-VOKQKP4K.js.map → product-QD2UM2YC.js.map} +1 -1
  42. package/dist/cdn/chunks/{pt-BR-T2PIW5LH.js → pt-BR-O6V4ZHQV.js} +2 -2
  43. package/dist/cdn/chunks/{pt-BR-T2PIW5LH.js.map → pt-BR-O6V4ZHQV.js.map} +3 -3
  44. package/dist/cdn/chunks/{ru-CWHLBHXX.js → ru-GHVKB5QT.js} +2 -2
  45. package/dist/cdn/chunks/{ru-CWHLBHXX.js.map → ru-GHVKB5QT.js.map} +3 -3
  46. package/dist/cdn/chunks/{score-IPBHXWWN.js → score-SIWLGKFB.js} +2 -2
  47. package/dist/cdn/chunks/{score-IPBHXWWN.js.map → score-SIWLGKFB.js.map} +1 -1
  48. package/dist/cdn/chunks/{stats-V6H3J3WL.js → stats-I7FWD22A.js} +2 -2
  49. package/dist/cdn/chunks/{stats-V6H3J3WL.js.map → stats-I7FWD22A.js.map} +1 -1
  50. package/dist/cdn/chunks/{stock-UNSEZYGA.js → stock-SU4RHFTL.js} +2 -2
  51. package/dist/cdn/chunks/{stock-UNSEZYGA.js.map → stock-SU4RHFTL.js.map} +1 -1
  52. package/dist/cdn/chunks/{weather-4IMAIRYF.js → weather-OLNMWGUD.js} +2 -2
  53. package/dist/cdn/chunks/{weather-4IMAIRYF.js.map → weather-OLNMWGUD.js.map} +1 -1
  54. package/dist/cdn/chunks/{zh-CN-UEBLECMR.js → zh-CN-EHJ3XH3O.js} +2 -2
  55. package/dist/cdn/chunks/{zh-CN-UEBLECMR.js.map → zh-CN-EHJ3XH3O.js.map} +3 -3
  56. package/dist/cdn/latest.js +4 -4
  57. package/dist/cdn/n8n-chat.js +42 -42
  58. package/dist/cdn/n8n-chat.js.map +4 -4
  59. package/dist/create-chat.d.ts +18 -1
  60. package/dist/index.js +40 -26
  61. package/dist/index.js.map +1 -1
  62. package/dist/strings.d.ts +3 -1
  63. package/dist/style.css +65 -13
  64. package/dist/theme.css +64 -12
  65. package/package.json +7 -7
  66. package/dist/cdn/chunks/chunk-4MZPEZPE.js.map +0 -7
package/README.md CHANGED
@@ -46,9 +46,9 @@ To keep one version until you change it, load the module and its stylesheet by t
46
46
  instead:
47
47
 
48
48
  ```html
49
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@1.0.2/dist/style.css">
49
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@1.1.1/dist/style.css">
50
50
  <script type="module">
51
- import { createChat } from 'https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@1.0.2/dist/cdn/n8n-chat.js';
51
+ import { createChat } from 'https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@1.1.1/dist/cdn/n8n-chat.js';
52
52
 
53
53
  createChat({ webhookUrl: 'https://your-n8n.example.com/webhook/<id>/chat' });
54
54
  </script>
@@ -114,7 +114,8 @@ memory on the agent only, n8n answers that request with an error.
114
114
  | `webhookConfig` | `headers` sent with every request, read each time (a refreshed token is sent); `method` is accepted, every request is a POST | `{}` |
115
115
  | `target` | where it mounts: an element, or a selector | `'#n8n-chat'` |
116
116
  | `mode` | `'window'` (a button in the corner) or `'embedded'` (a block in the page, filling its target; `'fullscreen'`, `@n8n/chat`'s name for it, works too) | `'window'` |
117
- | `showWindowCloseButton` | a ✕ in the header, in window mode | `false` |
117
+ | `showWindowCloseButton` | a ✕ in the [header](#the-windows-header), in window mode (there anyway while the chat fills a phone's screen or is maximized) | `false` |
118
+ | `maximizable` | a button in the [header](#the-windows-header) that maximizes the chat: `true` to the whole window, `'panel'` to a full-height panel beside the page | `false` |
118
119
  | `showWelcomeScreen` | a screen with a "New Conversation" button first | `false` |
119
120
  | `loadPreviousSession` | keep the session in the browser and show its earlier messages | `true` |
120
121
  | `sessionId` | use this session instead of the stored one | — |
@@ -140,6 +141,25 @@ memory on the agent only, n8n answers that request with an error.
140
141
  | `fetch` | the `fetch` every request goes through | the global one |
141
142
  | `enableStreaming`, `theme` | accepted for compatibility | — |
142
143
 
144
+ ## The window's header
145
+
146
+ In window mode the chat opens under a header: n8n's title and the line under it (`title` and
147
+ `subtitle` in `i18n`), in n8n's colors (`--chat--header--background`, `--chat--header--color`).
148
+ The ✕ is there with `showWindowCloseButton`, and always while the chat fills a phone's screen or
149
+ is maximized, where the button in the corner is not. A button that maximizes the chat is
150
+ yours to add:
151
+
152
+ ```js
153
+ createChat({
154
+ webhookUrl: 'https://your-n8n.example.com/webhook/<id>/chat',
155
+ maximizable: true, // the whole window; 'panel' for a full-height panel that keeps the page in view
156
+ });
157
+ ```
158
+
159
+ The same button, or Escape, brings it back, and `chat.maximize()` and `chat.restore()` do it from
160
+ your page. Embedded in the page (`mode: 'embedded'`), the chat keeps its own header, with nothing to
161
+ maximize.
162
+
143
163
  ## The handle
144
164
 
145
165
  `createChat()` returns what your page drives it with:
@@ -148,6 +168,7 @@ memory on the agent only, n8n answers that request with an error.
148
168
  const chat = createChat({ webhookUrl });
149
169
 
150
170
  chat.open(); // open the window (close, toggle too)
171
+ chat.maximize(); // maximize it, restore() brings it back (give `maximizable` for the button)
151
172
  chat.send('Where is my order?'); // as the visitor; waits for an answer on its way
152
173
  chat.reset(); // a new conversation, in a new session
153
174
  chat.setDisabled(true); // block the input, or let the visitor type again
@@ -1,2 +1,2 @@
1
- import{a as n}from"./chunk-PPDOW5CO.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-XY3GEFGN.js.map
1
+ import{a as n}from"./chunk-S6J6TTL4.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-6ZVO7OTR.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../node_modules/.pnpm/@aparte+plugin-cards@1.1.2_@aparte+core@1.1.2/node_modules/@aparte/plugin-cards/src/kit/controls.ts"],
3
+ "sources": ["../../../node_modules/.pnpm/@aparte+plugin-cards@1.5.0_@aparte+core@1.5.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-PPDOW5CO.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-LGVX5DQP.js.map
1
+ import{a as i,b as p,i as l,j as g,q as e}from"./chunk-S6J6TTL4.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-7K4YMHQR.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../node_modules/.pnpm/@aparte+plugin-cards@1.1.2_@aparte+core@1.1.2/node_modules/@aparte/plugin-cards/src/kit/rating.ts"],
3
+ "sources": ["../../../node_modules/.pnpm/@aparte+plugin-cards@1.5.0_@aparte+core@1.5.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"]
@@ -1,2 +1,2 @@
1
1
  var f="http://www.w3.org/2000/svg";function k(u,{pad:c=.15,range:t}={}){let s=u.filter(Number.isFinite);if(s.length===0)return{line:"",area:"",points:[]};let l=s.length===1?[s[0],s[0]]:s,i=t?t[0]:Math.min(...s),x=(t?t[1]:Math.max(...s))-i,r=40,F=100/(l.length-1),e=l.map((n,d)=>[d*F,x===0?r/2:r-(c*r+(n-i)/x*(r-2*c*r))]),h=`M${e[0][0].toFixed(2)} ${e[0][1].toFixed(2)}`;for(let n=0;n<e.length-1;n++){let d=e[n-1]??e[n],p=e[n],o=e[n+1],$=e[n+2]??o,m=[p[0]+(o[0]-d[0])/6,p[1]+(o[1]-d[1])/6],b=[o[0]-($[0]-p[0])/6,o[1]-($[1]-p[1])/6];h+=` C${m[0].toFixed(2)} ${m[1].toFixed(2)} ${b[0].toFixed(2)} ${b[1].toFixed(2)} ${o[0].toFixed(2)} ${o[1].toFixed(2)}`}let A=e[e.length-1],g=`${h} L${A[0].toFixed(2)} ${r} L${e[0][0].toFixed(2)} ${r} Z`;return{line:h,area:g,points:e}}function v(u,c={}){let t=document.createElementNS(f,"svg");t.setAttribute("viewBox","0 0 100 40"),t.setAttribute("preserveAspectRatio","none"),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false"),t.classList.add("aparte-rich-card__sparkline");for(let a of c.className?.split(/\s+/)??[])a&&t.classList.add(a);let{line:s,area:l}=k(u,c);if(!s)return t;if(c.area){let a=document.createElementNS(f,"path");a.setAttribute("d",l),a.setAttribute("class","aparte-rich-card__sparkline-area"),t.append(a)}let i=document.createElementNS(f,"path");return i.setAttribute("d",s),i.setAttribute("class","aparte-rich-card__sparkline-line"),i.setAttribute("vector-effect","non-scaling-stroke"),t.append(i),t}export{v as a};
2
- //# sourceMappingURL=chunk-KPADIE5S.js.map
2
+ //# sourceMappingURL=chunk-KB6DEEIQ.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../node_modules/.pnpm/@aparte+plugin-cards@1.1.2_@aparte+core@1.1.2/node_modules/@aparte/plugin-cards/src/kit/sparkline.ts"],
3
+ "sources": ["../../../node_modules/.pnpm/@aparte+plugin-cards@1.5.0_@aparte+core@1.5.0/node_modules/@aparte/plugin-cards/src/kit/sparkline.ts"],
4
4
  "sourcesContent": ["/**\n * A small line chart in SVG, with no dependency: the temperature over the next hours, a\n * price over a day. Built with `createElementNS` from numbers only, so a tool's values\n * never reach a parser. Stretched to its box (`preserveAspectRatio=\"none\"`), the stroke\n * kept at its width by `vector-effect`.\n */\nconst SVG = 'http://www.w3.org/2000/svg';\n\nexport interface SparklineOptions {\n /** Extra class on the `<svg>`. */\n className?: string;\n /** Fill the area under the line (a gradient from the stroke's colour, in the sheet). */\n area?: boolean;\n /** Padding above and below the line, as a share of the height (0.15 by default). */\n pad?: number;\n /** The value range to scale against, when several charts must share one. */\n range?: [number, number];\n}\n\n/** The points of a smooth line through `values`, in a 100 × 40 box. */\nexport function sparklinePath(values: number[], { pad = 0.15, range }: SparklineOptions = {}): { line: string; area: string; points: Array<[number, number]> } {\n // A gap (`null`, `NaN`) is left out: written into the path it would stop the drawing there.\n const finite = values.filter(Number.isFinite);\n if (finite.length === 0) return { line: '', area: '', points: [] };\n // One value is a level, drawn flat across the box: a single point would draw nothing.\n const series = finite.length === 1 ? [finite[0]!, finite[0]!] : finite;\n const lo = range ? range[0] : Math.min(...finite);\n const hi = range ? range[1] : Math.max(...finite);\n const span = hi - lo;\n const h = 40;\n const step = 100 / (series.length - 1);\n // A series that does not move is a flat line through the middle, not along the floor.\n const points = series.map((v, i): [number, number] => [\n i * step,\n span === 0 ? h / 2 : h - (pad * h + ((v - lo) / span) * (h - 2 * pad * h)),\n ]);\n // A Catmull-Rom curve through the points, written as cubic Béziers.\n let line = `M${points[0]![0].toFixed(2)} ${points[0]![1].toFixed(2)}`;\n for (let i = 0; i < points.length - 1; i++) {\n const p0 = points[i - 1] ?? points[i]!;\n const p1 = points[i]!;\n const p2 = points[i + 1]!;\n const p3 = points[i + 2] ?? p2;\n const c1: [number, number] = [p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6];\n const c2: [number, number] = [p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6];\n line += ` C${c1[0].toFixed(2)} ${c1[1].toFixed(2)} ${c2[0].toFixed(2)} ${c2[1].toFixed(2)} ${p2[0].toFixed(2)} ${p2[1].toFixed(2)}`;\n }\n const last = points[points.length - 1]!;\n const area = `${line} L${last[0].toFixed(2)} ${h} L${points[0]![0].toFixed(2)} ${h} Z`;\n return { line, area, points };\n}\n\n/** The chart as an `<svg>`; decorative (`aria-hidden`), so put the numbers in text beside it. */\nexport function sparkline(values: number[], options: SparklineOptions = {}): SVGSVGElement {\n const svg = document.createElementNS(SVG, 'svg');\n svg.setAttribute('viewBox', '0 0 100 40');\n svg.setAttribute('preserveAspectRatio', 'none');\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('focusable', 'false');\n svg.classList.add('aparte-rich-card__sparkline');\n // The caller's own class (its own prefix is its business), added beside ours.\n for (const name of options.className?.split(/\\s+/) ?? []) if (name) svg.classList.add(name);\n const { line, area } = sparklinePath(values, options);\n if (!line) return svg;\n if (options.area) {\n const fill = document.createElementNS(SVG, 'path');\n fill.setAttribute('d', area);\n fill.setAttribute('class', 'aparte-rich-card__sparkline-area');\n svg.append(fill);\n }\n const stroke = document.createElementNS(SVG, 'path');\n stroke.setAttribute('d', line);\n stroke.setAttribute('class', 'aparte-rich-card__sparkline-line');\n stroke.setAttribute('vector-effect', 'non-scaling-stroke');\n svg.append(stroke);\n return svg;\n}\n"],
5
5
  "mappings": "AAMA,IAAMA,EAAM,6BAcL,SAASC,EAAcC,EAAkB,CAAE,IAAAC,EAAM,IAAM,MAAAC,CAAA,EAA4B,CAAA,EAAqE,CAE3J,IAAMC,EAASH,EAAO,OAAO,OAAO,QAAQ,EAC5C,GAAIG,EAAO,SAAW,EAAG,MAAO,CAAE,KAAM,GAAI,KAAM,GAAI,OAAQ,CAAA,CAAC,EA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M,EACVH,CACX",
6
6
  "names": ["SVG", "sparklinePath", "values", "pad", "range", "finite", "series", "lo", "span", "h", "step", "points", "v", "i", "line", "p0", "p1", "p2", "p3", "c1", "c2", "last", "area", "sparkline", "options", "svg", "name", "fill", "stroke"]