@elia-assistant/chatui 1.0.0 → 1.0.2

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 CHANGED
@@ -168,10 +168,11 @@ A tab is shown only if its block has `feedUrl` or `items`. If neither tab is con
168
168
 
169
169
  | Parameter | Type | Description |
170
170
  |---|---|---|
171
- | `defaultLanguage` | `string` | Initial UI language code (`'en'`, `'sk'`, …) |
172
171
  | `initialMessages` | `string[]` | Global fallback initial bot messages |
173
172
  | `i18n[lang]` | `LangOverride` | Per-language content overrides |
174
173
 
174
+ To set the initial UI language, call `useSettingsStore.getState().setLanguage('sk')` after `setConfig()` (or pass `language: 'sk'` to `createChat()`). On a fresh browser, the default falls back to `navigator.language` then `'en'`.
175
+
175
176
  `LangOverride` fields: `initialMessages`, `ctaText`, `botName`, `welcomeSubtitle`, `tabs.{notifications,help,chat}.title`.
176
177
 
177
178
  Resolution chain: `i18n[activeLang].X` -> `i18n['en'].X` -> global `config.X`.
@@ -62,5 +62,5 @@ useSettingsStore.getState().setLanguage(${JSON.stringify(i)})
62
62
  fixed md:relative inset-y-0 left-0 z-40
63
63
  transition-transform md:translate-x-0
64
64
  ${s?`translate-x-0`:`-translate-x-full`}
65
- `,children:(0,F.jsx)(tr,{onOpenSettings:g})}),(0,F.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 h-full`,children:[m&&(0,F.jsx)(`button`,{className:`md:hidden absolute top-3 left-3 z-20 w-8 h-8 flex items-center justify-center text-fg-secondary`,onClick:()=>c(e=>!e),children:(0,F.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,F.jsx)(`path`,{d:`M3 12h18M3 6h18M3 18h18`})})}),(0,F.jsx)(ep,{onOpenSettings:g})]})]});if(e.fullscreenSheet){let t=e.fullscreenSheetHeight??`75vh`;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`fixed inset-0 z-40 pointer-events-none`,style:{background:`rgba(0, 0, 0, 0.4)`}}),(0,F.jsxs)(`div`,{className:`fixed inset-x-0 bottom-0 z-50 flex flex-col overflow-hidden`,style:{height:t,borderTopLeftRadius:`20px`,borderTopRightRadius:`20px`,background:`var(--t-bg-base)`,boxShadow:`0 -8px 32px rgba(0, 0, 0, 0.18)`},children:[(0,F.jsx)(`div`,{className:`flex justify-center pt-2 pb-1 flex-shrink-0`,children:(0,F.jsx)(`div`,{className:`w-10 h-1 rounded-full`,style:{background:`var(--t-bg-border)`}})}),(0,F.jsx)(`div`,{className:`flex-1 min-h-0`,children:_})]}),!h&&r&&(0,F.jsx)(op,{onClose:()=>i(!1)})]})}return(0,F.jsxs)(F.Fragment,{children:[_,!h&&r&&(0,F.jsx)(op,{onClose:()=>i(!1)})]})}function pp({open:e,iconSrc:t,onClick:n}){let r=!!t&&!e;return(0,F.jsx)(`button`,{className:`fixed bottom-4 right-4 z-50 w-14 h-14 rounded-full shadow-lg flex items-center justify-center transition-transform hover:scale-105 overflow-hidden`,style:{background:r?`transparent`:`var(--t-accent)`,color:`var(--t-accent-fg)`},onClick:n,"aria-label":`Toggle chat`,children:e?(0,F.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,F.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}):r?(0,F.jsx)(`img`,{src:t,alt:``,className:`w-full h-full object-cover`}):(0,F.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,F.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`})})})}function mp(e){let{target:t,language:n,...r}=e,i=typeof t==`string`?document.querySelector(t):t;if(!i)throw Error(`[chatui] createChat: target "${String(t)}" not found`);let a=qn.getState();a.setConfig(r),r.theme&&a.setTheme(r.theme);let o=n??r.defaultLanguage;o&&a.setLanguage(o);let s=(0,Nn.createRoot)(i);return s.render((0,P.createElement)(fp)),{unmount(){s.unmount()}}}return e.createChat=mp,e})({});
65
+ `,children:(0,F.jsx)(tr,{onOpenSettings:g})}),(0,F.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 h-full`,children:[m&&(0,F.jsx)(`button`,{className:`md:hidden absolute top-3 left-3 z-20 w-8 h-8 flex items-center justify-center text-fg-secondary`,onClick:()=>c(e=>!e),children:(0,F.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,F.jsx)(`path`,{d:`M3 12h18M3 6h18M3 18h18`})})}),(0,F.jsx)(ep,{onOpenSettings:g})]})]});if(e.fullscreenSheet){let t=e.fullscreenSheetHeight??`75vh`;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`fixed inset-0 z-40 pointer-events-none`,style:{background:`rgba(0, 0, 0, 0.4)`}}),(0,F.jsxs)(`div`,{className:`fixed inset-x-0 bottom-0 z-50 flex flex-col overflow-hidden`,style:{height:t,borderTopLeftRadius:`20px`,borderTopRightRadius:`20px`,background:`var(--t-bg-base)`,boxShadow:`0 -8px 32px rgba(0, 0, 0, 0.18)`},children:[(0,F.jsx)(`div`,{className:`flex justify-center pt-2 pb-1 flex-shrink-0`,children:(0,F.jsx)(`div`,{className:`w-10 h-1 rounded-full`,style:{background:`var(--t-bg-border)`}})}),(0,F.jsx)(`div`,{className:`flex-1 min-h-0`,children:_})]}),!h&&r&&(0,F.jsx)(op,{onClose:()=>i(!1)})]})}return(0,F.jsxs)(F.Fragment,{children:[_,!h&&r&&(0,F.jsx)(op,{onClose:()=>i(!1)})]})}function pp({open:e,iconSrc:t,onClick:n}){let r=!!t&&!e;return(0,F.jsx)(`button`,{className:`fixed bottom-4 right-4 z-50 w-14 h-14 rounded-full shadow-lg flex items-center justify-center transition-transform hover:scale-105 overflow-hidden`,style:{background:r?`transparent`:`var(--t-accent)`,color:`var(--t-accent-fg)`},onClick:n,"aria-label":`Toggle chat`,children:e?(0,F.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:(0,F.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}):r?(0,F.jsx)(`img`,{src:t,alt:``,className:`w-full h-full object-cover`}):(0,F.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,F.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`})})})}function mp(e){let{target:t,language:n,...r}=e,i=typeof t==`string`?document.querySelector(t):t;if(!i)throw Error(`[chatui] createChat: target "${String(t)}" not found`);let a=qn.getState();a.setConfig(r),r.theme&&a.setTheme(r.theme),n&&a.setLanguage(n);let o=(0,Nn.createRoot)(i);return o.render((0,P.createElement)(fp)),{unmount(){o.unmount()}}}return e.createChat=mp,e})({});
66
66
  //# sourceMappingURL=chatui.iife.js.map
@@ -2,7 +2,7 @@ import type { ChatConfig } from './types/index.ts';
2
2
  export interface CreateChatOptions extends Partial<ChatConfig> {
3
3
  /** CSS selector or DOM element where the chat will mount. */
4
4
  target: string | HTMLElement;
5
- /** Initial UI language code (e.g. 'en', 'sk'). Same as setting `defaultLanguage` but applied immediately. */
5
+ /** Initial UI language code (e.g. 'en', 'sk'). Applied immediately via `setLanguage()`. */
6
6
  language?: string;
7
7
  }
8
8
  export interface ChatInstance {
package/dist/index.js CHANGED
@@ -9998,12 +9998,10 @@ function $u(e) {
9998
9998
  let { target: t, language: n, ...r } = e, i = typeof t == "string" ? document.querySelector(t) : t;
9999
9999
  if (!i) throw Error(`[chatui] createChat: target "${String(t)}" not found`);
10000
10000
  let a = o.getState();
10001
- a.setConfig(r), r.theme && a.setTheme(r.theme);
10002
- let s = n ?? r.defaultLanguage;
10003
- s && a.setLanguage(s);
10004
- let c = w(i);
10005
- return c.render(f(Zu)), { unmount() {
10006
- c.unmount();
10001
+ a.setConfig(r), r.theme && a.setTheme(r.theme), n && a.setLanguage(n);
10002
+ let s = w(i);
10003
+ return s.render(f(Zu)), { unmount() {
10004
+ s.unmount();
10007
10005
  } };
10008
10006
  }
10009
10007
  //#endregion
@@ -55,7 +55,6 @@ export interface ChatConfig {
55
55
  chatSessionKey?: string;
56
56
  metadata?: Record<string, unknown>;
57
57
  showWelcomeScreen?: boolean;
58
- defaultLanguage?: string;
59
58
  /** Global fallback initial messages — per-language overrides live in i18n[lang].initialMessages */
60
59
  initialMessages?: string[];
61
60
  allowFileUploads?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elia-assistant/chatui",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -50,10 +50,6 @@
50
50
  "react": "^19.0.0",
51
51
  "react-dom": "^19.0.0"
52
52
  },
53
- "peerDependenciesMeta": {
54
- "react": { "optional": true },
55
- "react-dom": { "optional": true }
56
- },
57
53
  "dependencies": {
58
54
  "i18next": "^25.0.0",
59
55
  "i18next-resources-to-backend": "^1.2.0",