@elia-assistant/chatui 1.0.25 → 2.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.
@@ -1,6 +1,11 @@
1
1
  import e from "react";
2
+ //#region src/lib/storage.ts
3
+ function t(e, t) {
4
+ return t ? `${e}-${t}` : e;
5
+ }
6
+ //#endregion
2
7
  //#region node_modules/zustand/esm/vanilla.mjs
3
- var t = (e) => {
8
+ var n = (e) => {
4
9
  let t, n = /* @__PURE__ */ new Set(), r = (e, r) => {
5
10
  let i = typeof e == "function" ? e(t) : e;
6
11
  if (!Object.is(i, t)) {
@@ -14,18 +19,18 @@ var t = (e) => {
14
19
  subscribe: (e) => (n.add(e), () => n.delete(e))
15
20
  }, o = t = e(r, i, a);
16
21
  return a;
17
- }, n = ((e) => e ? t(e) : t), r = (e) => e;
18
- function i(t, n = r) {
19
- let i = e.useSyncExternalStore(t.subscribe, e.useCallback(() => n(t.getState()), [t, n]), e.useCallback(() => n(t.getInitialState()), [t, n]));
20
- return e.useDebugValue(i), i;
22
+ }, r = ((e) => e ? n(e) : n), i = (e) => e;
23
+ function a(t, n = i) {
24
+ let r = e.useSyncExternalStore(t.subscribe, e.useCallback(() => n(t.getState()), [t, n]), e.useCallback(() => n(t.getInitialState()), [t, n]));
25
+ return e.useDebugValue(r), r;
21
26
  }
22
- var a = (e) => {
23
- let t = n(e), r = (e) => i(t, e);
24
- return Object.assign(r, t), r;
25
- }, o = ((e) => e ? a(e) : a);
27
+ var o = (e) => {
28
+ let t = r(e), n = (e) => a(t, e);
29
+ return Object.assign(n, t), n;
30
+ }, s = ((e) => e ? o(e) : o);
26
31
  //#endregion
27
32
  //#region node_modules/zustand/esm/middleware.mjs
28
- function s(e, t) {
33
+ function c(e, t) {
29
34
  let n;
30
35
  try {
31
36
  n = e();
@@ -41,12 +46,12 @@ function s(e, t) {
41
46
  removeItem: (e) => n.removeItem(e)
42
47
  };
43
48
  }
44
- var c = (e) => (t) => {
49
+ var l = (e) => (t) => {
45
50
  try {
46
51
  let n = e(t);
47
52
  return n instanceof Promise ? n : {
48
53
  then(e) {
49
- return c(e)(n);
54
+ return l(e)(n);
50
55
  },
51
56
  catch(e) {
52
57
  return this;
@@ -58,13 +63,13 @@ var c = (e) => (t) => {
58
63
  return this;
59
64
  },
60
65
  catch(t) {
61
- return c(t)(e);
66
+ return l(t)(e);
62
67
  }
63
68
  };
64
69
  }
65
- }, l = (e, t) => (n, r, i) => {
70
+ }, u = (e, t) => (n, r, i) => {
66
71
  let a = {
67
- storage: s(() => window.localStorage),
72
+ storage: c(() => window.localStorage),
68
73
  partialize: (e) => e,
69
74
  version: 0,
70
75
  merge: (e, t) => ({
@@ -72,7 +77,7 @@ var c = (e) => (t) => {
72
77
  ...e
73
78
  }),
74
79
  ...t
75
- }, o = !1, l = 0, u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), f = a.storage;
80
+ }, o = !1, s = 0, u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), f = a.storage;
76
81
  if (!f) return e((...e) => {
77
82
  console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`), n(...e);
78
83
  }, r, i);
@@ -88,10 +93,10 @@ var c = (e) => (t) => {
88
93
  i.getInitialState = () => h;
89
94
  let g, _ = () => {
90
95
  if (!f) return;
91
- let e = ++l;
96
+ let e = ++s;
92
97
  o = !1, u.forEach((e) => e(r() ?? h));
93
98
  let t = a.onRehydrateStorage?.call(a, r() ?? h) || void 0;
94
- return c(f.getItem.bind(f))(a.name).then((e) => {
99
+ return l(f.getItem.bind(f))(a.name).then((e) => {
95
100
  if (e) if (typeof e.version == "number" && e.version !== a.version) {
96
101
  if (a.migrate) {
97
102
  let t = a.migrate(e.state, e.version);
@@ -101,13 +106,13 @@ var c = (e) => (t) => {
101
106
  } else return [!1, e.state];
102
107
  return [!1, void 0];
103
108
  }).then((t) => {
104
- if (e !== l) return;
109
+ if (e !== s) return;
105
110
  let [i, o] = t;
106
111
  if (g = a.merge(o, r() ?? h), n(g, !0), i) return p();
107
112
  }).then(() => {
108
- e === l && (t?.(r(), void 0), g = r(), o = !0, d.forEach((e) => e(g)));
113
+ e === s && (t?.(r(), void 0), g = r(), o = !0, d.forEach((e) => e(g)));
109
114
  }).catch((n) => {
110
- e === l && t?.(void 0, n);
115
+ e === s && t?.(void 0, n);
111
116
  });
112
117
  };
113
118
  return i.persist = {
@@ -132,6 +137,6 @@ var c = (e) => (t) => {
132
137
  }, a.skipHydration || _(), g || h;
133
138
  };
134
139
  //#endregion
135
- export { o as n, l as t };
140
+ export { s as n, t as r, u as t };
136
141
 
137
- //# sourceMappingURL=middleware-Brf3TxqP.js.map
142
+ //# sourceMappingURL=middleware-BG8DEvI8.js.map
@@ -1,18 +1,6 @@
1
- import { n as e, t } from "./middleware-Brf3TxqP.js";
1
+ import { n as e, r as t, t as n } from "./middleware-BG8DEvI8.js";
2
2
  //#region src/themes.ts
3
- var n = [
4
- {
5
- id: "midnight",
6
- label: "Midnight",
7
- baseColor: "#0f1117",
8
- accentColor: "#6366f1"
9
- },
10
- {
11
- id: "ivory",
12
- label: "Ivory",
13
- baseColor: "#ffffff",
14
- accentColor: "#4338ca"
15
- },
3
+ var r = [
16
4
  {
17
5
  id: "sunrise",
18
6
  label: "Sunrise",
@@ -20,22 +8,10 @@ var n = [
20
8
  accentColor: "#f97316"
21
9
  },
22
10
  {
23
- id: "cosmos",
24
- label: "Cosmos",
25
- baseColor: "#1e1a30",
26
- accentColor: "#a855f7"
27
- },
28
- {
29
- id: "forest",
30
- label: "Forest",
31
- baseColor: "#0a1410",
32
- accentColor: "#22c55e"
33
- },
34
- {
35
- id: "ocean",
36
- label: "Ocean",
37
- baseColor: "#060f1a",
38
- accentColor: "#06b6d4"
11
+ id: "ivory",
12
+ label: "Ivory",
13
+ baseColor: "#f1ede5",
14
+ accentColor: "#e08229"
39
15
  },
40
16
  {
41
17
  id: "cherry",
@@ -44,10 +20,10 @@ var n = [
44
20
  accentColor: "#ef4444"
45
21
  },
46
22
  {
47
- id: "navy",
48
- label: "Navy",
49
- baseColor: "#080f1e",
50
- accentColor: "#3b82f6"
23
+ id: "sky",
24
+ label: "Sky",
25
+ baseColor: "#ffffff",
26
+ accentColor: "#5ba1da"
51
27
  },
52
28
  {
53
29
  id: "lavender",
@@ -55,10 +31,22 @@ var n = [
55
31
  baseColor: "#faf5ff",
56
32
  accentColor: "#8b5cf6"
57
33
  },
34
+ {
35
+ id: "nice",
36
+ label: "Nice",
37
+ baseColor: "#ffffff",
38
+ accentColor: "#3f7e83"
39
+ },
40
+ {
41
+ id: "navy",
42
+ label: "Navy",
43
+ baseColor: "#ebf3f2",
44
+ accentColor: "#bed6dd"
45
+ },
58
46
  {
59
47
  id: "amber",
60
48
  label: "Amber",
61
- baseColor: "#0f0a00",
49
+ baseColor: "#3d2c15",
62
50
  accentColor: "#f59e0b"
63
51
  },
64
52
  {
@@ -70,28 +58,52 @@ var n = [
70
58
  {
71
59
  id: "graphite",
72
60
  label: "Graphite",
73
- baseColor: "#424242",
74
- accentColor: "#f472b6"
75
- },
76
- {
77
- id: "teal",
78
- label: "Teal",
79
- baseColor: "#F1F5F9",
80
- accentColor: "#0D9488"
61
+ baseColor: "#313949",
62
+ accentColor: "#4185eb"
81
63
  },
82
64
  {
83
65
  id: "stone",
84
66
  label: "Stone",
85
67
  baseColor: "#44403c",
86
68
  accentColor: "#fbbf24"
69
+ },
70
+ {
71
+ id: "cosmos",
72
+ label: "Cosmos",
73
+ baseColor: "#2f356b",
74
+ accentColor: "#7855f7"
75
+ },
76
+ {
77
+ id: "forest",
78
+ label: "Forest",
79
+ baseColor: "#1b362c",
80
+ accentColor: "#22c55e"
81
+ },
82
+ {
83
+ id: "ocean",
84
+ label: "Ocean",
85
+ baseColor: "#075985",
86
+ accentColor: "#3b82f6"
87
+ },
88
+ {
89
+ id: "cherryDark",
90
+ label: "Cherry Dark",
91
+ baseColor: "#440b19",
92
+ accentColor: "#ef4444"
93
+ },
94
+ {
95
+ id: "midnight",
96
+ label: "Midnight",
97
+ baseColor: "#0f1117",
98
+ accentColor: "#6366f1"
87
99
  }
88
- ], r = "midnight";
89
- function i(e) {
90
- return n.find((t) => t.id === e) ?? n[0];
100
+ ], i = "midnight";
101
+ function a(e) {
102
+ return r.find((t) => t.id === e) ?? r[0];
91
103
  }
92
104
  //#endregion
93
105
  //#region src/store/settingsStore.ts
94
- var a = {
106
+ var o = {
95
107
  webhookUrl: "",
96
108
  chatInputKey: "chatInput",
97
109
  chatSessionKey: "sessionId",
@@ -116,39 +128,40 @@ var a = {
116
128
  ctaText: "Dobrý deň! Ako vám môžem pomôcť?"
117
129
  }
118
130
  }
119
- }, o = e()(t((e) => ({
120
- config: a,
121
- activeTheme: r,
122
- language: "en",
123
- setConfig(t) {
124
- e((e) => ({ config: {
125
- ...e.config,
126
- ...t
127
- } }));
128
- },
129
- setTheme(t) {
130
- e({ activeTheme: t });
131
- },
132
- setLanguage(t) {
133
- e({ language: t }), import("./i18n-Vi-f1TFq.js").then((e) => e.t).then((e) => {
134
- e.default.changeLanguage(t);
135
- });
136
- }
137
- }), {
138
- name: "chatui-settings",
139
- merge: (e, t) => {
140
- let n = e;
141
- return {
142
- ...t,
143
- ...n,
144
- config: {
145
- ...t.config,
146
- ...n.config ?? {}
147
- }
148
- };
149
- }
150
- }));
131
+ };
132
+ function s(r, a) {
133
+ return e()(n((e) => ({
134
+ config: o,
135
+ activeTheme: i,
136
+ language: "en",
137
+ setConfig(t) {
138
+ e((e) => ({ config: {
139
+ ...e.config,
140
+ ...t
141
+ } }));
142
+ },
143
+ setTheme(t) {
144
+ e({ activeTheme: t });
145
+ },
146
+ setLanguage(t) {
147
+ e({ language: t }), r.changeLanguage(t);
148
+ }
149
+ }), {
150
+ name: t("chatui-settings", a),
151
+ merge: (e, t) => {
152
+ let n = e;
153
+ return {
154
+ ...t,
155
+ ...n,
156
+ config: {
157
+ ...t.config,
158
+ ...n.config ?? {}
159
+ }
160
+ };
161
+ }
162
+ }));
163
+ }
151
164
  //#endregion
152
- export { i as n, n as r, o as t };
165
+ export { a as n, r, s as t };
153
166
 
154
- //# sourceMappingURL=settingsStore-yU8h8KVJ.js.map
167
+ //# sourceMappingURL=settingsStore-DzpdfGcd.js.map
@@ -0,0 +1,94 @@
1
+ //#region src/locales/cs/translation.json
2
+ var e = {
3
+ failedToSend: "Zprávu se nepodařilo odeslat",
4
+ retry: "Zkusit znovu"
5
+ }, t = { subtitle: "Začněte konverzaci. Jsem tu pro vás." }, n = {
6
+ placeholder: "Napište zprávu… (Enter = odeslat)",
7
+ placeholderUnconfigured: "Nastavte webhook URL v nastavení…"
8
+ }, r = {
9
+ assistant: "Bot",
10
+ online: "online",
11
+ notConfigured: "Nenakonfigurováno"
12
+ }, i = {
13
+ title: "Konverzace",
14
+ empty: "Zatím žádné konverzace.",
15
+ newChat: "Nová konverzace",
16
+ settings: "Nastavení"
17
+ }, a = { poweredBy: "Poskytuje <a>{{label}}</a>" }, o = {
18
+ notifications: "Tipy",
19
+ help: "Pomoc",
20
+ chat: "Chat",
21
+ faqSearch: "Hledat ve FAQ…",
22
+ loading: "Načítám…",
23
+ error: "Nepodařilo se načíst",
24
+ empty: {
25
+ notifications: "Zatím žádná oznámení.",
26
+ faq: "Žádné shodné položky."
27
+ }
28
+ }, s = {
29
+ title: "Nastavení",
30
+ language: "Jazyk rozhraní",
31
+ webhookUrl: "Webhook URL",
32
+ chatInputKey: "Klíč vstupu chatu",
33
+ sessionKey: "Klíč relace",
34
+ botName: "Jméno bota (globální záloha)",
35
+ metadata: "Metadata (JSON)",
36
+ streaming: "Streamovat odpověď bota po tokenech",
37
+ agentStreamSection: "Živý operátor",
38
+ agentStreamHint: "Když je nastaveno, odpovědi operátora odeslané z dashboardu se zobrazí v chatu v reálném čase. Pro vypnutí nechte obě pole prázdná.",
39
+ agentStreamApiBaseUrl: "URL backendu",
40
+ agentStreamTenantId: "ID tenanta",
41
+ welcomeScreen: "Zobrazit uvítací obrazovku",
42
+ sidebar: "Zobrazit historii konverzací",
43
+ fileUploads: "Povolit nahrávání souborů",
44
+ allowedFileExtensions: "Povolené přípony souborů",
45
+ mode: "Režim zobrazení",
46
+ position: "Pozice widgetu",
47
+ position_right: "Vpravo",
48
+ position_left: "Vlevo",
49
+ fullscreenSheet: "Styl spodního panelu (nepokryje celou obrazovku)",
50
+ fullscreenSheetHeight: "Výška panelu (CSS délka, např. 75vh, 600px)",
51
+ tabsSection: "Záložky (oznámení + FAQ)",
52
+ tabsNotificationsTitle: "Název záložky oznámení",
53
+ tabsNotificationsFeedUrl: "URL feedu oznámení",
54
+ tabsHelpTitle: "Název záložky FAQ",
55
+ tabsHelpFeedUrl: "URL feedu FAQ",
56
+ tabsChatTitle: "Název záložky chatu",
57
+ cta: "Zobrazit CTA popup",
58
+ ctaSound: "Přehrát zvuk notifikace",
59
+ ctaDelay: "Zpoždění CTA (ms)",
60
+ perLanguage: "Obsah podle jazyka",
61
+ addLanguage: "Přidat jazyk",
62
+ botNameOverride: "Přepsat jméno bota",
63
+ welcomeSubtitle: "Uvítací podtitul",
64
+ initialMessages: "Úvodní zprávy (jedna na řádek)",
65
+ initialMessagesPlaceholder: "Dobrý den! Jak vám mohu pomoci?\nMluvím vaším jazykem.",
66
+ ctaTextLabel: "Text CTA popupu",
67
+ botAvatar: "Avatar bota",
68
+ toggleButtonIcon: "Ikona tlačítka popupu",
69
+ toggleButtonSameAsAvatar: "Stejně jako avatar bota",
70
+ avatarNone: "Žádný",
71
+ avatarClear: "Vymazat",
72
+ avatarUrlPlaceholder: "nebo vložte URL",
73
+ save: "Uložit",
74
+ cancel: "Zrušit",
75
+ theme: "Téma",
76
+ exportConfig: "Exportovat konfiguraci",
77
+ exportHint: "Vložte toto do bootstrap souboru vaší hostitelské aplikace (např. <code>src/main.tsx</code>) před prvním renderem Reactu. Podívejte se na <code>example.html</code> pro kompletní návod k integraci.",
78
+ back: "Zpět",
79
+ copyToClipboard: "Kopírovat do schránky",
80
+ copied: "Zkopírováno"
81
+ }, c = {
82
+ errors: e,
83
+ welcome: t,
84
+ input: n,
85
+ header: r,
86
+ sidebar: i,
87
+ footer: a,
88
+ tabs: o,
89
+ settings: s
90
+ };
91
+ //#endregion
92
+ export { c as default, e as errors, a as footer, r as header, n as input, s as settings, i as sidebar, o as tabs, t as welcome };
93
+
94
+ //# sourceMappingURL=translation-BL8dP5qm.js.map
@@ -1,3 +1,4 @@
1
+ import type { i18n as I18nInstance } from 'i18next';
1
2
  import type { ChatConfig } from './types/index.ts';
2
3
  export interface CreateChatOptions extends Partial<ChatConfig> {
3
4
  /** CSS selector or DOM element where the chat will mount.
@@ -7,9 +8,25 @@ export interface CreateChatOptions extends Partial<ChatConfig> {
7
8
  target?: string | HTMLElement;
8
9
  /** Initial UI language code (e.g. 'en', 'sk'). Applied immediately via `setLanguage()`. */
9
10
  language?: string;
11
+ /** Isolates this instance's persisted settings/session storage (and in-memory config/theme/
12
+ * conversation state) from any other chatui instance mounted on the same page - e.g. a
13
+ * host's own floating widget alongside a page's embedded demo. Only needed when multiple
14
+ * instances can be mounted simultaneously; a single instance per page can omit it. */
15
+ storageNamespace?: string;
10
16
  }
11
17
  export interface ChatInstance {
12
18
  /** Unmount the chat and detach React. */
13
19
  unmount(): void;
20
+ /** Update the config without remounting. */
21
+ setConfig(patch: Partial<ChatConfig>): void;
22
+ /** Switch the active theme without remounting. */
23
+ setTheme(id: string): void;
24
+ /** Switch the UI language without remounting. */
25
+ setLanguage(lang: string): void;
26
+ /** This instance's i18next instance, for registering extra UI languages at runtime via
27
+ * `addResourceBundle()`. The widget does not read the global i18next singleton, so a bundle
28
+ * registered there will not reach it - use this. `undefined` until the instance has mounted
29
+ * (only possible when createChat() was called before DOMContentLoaded). */
30
+ readonly i18n: I18nInstance | undefined;
14
31
  }
15
32
  export declare function createChat(opts: CreateChatOptions): ChatInstance;
package/dist/i18n.d.ts CHANGED
@@ -1,2 +1,8 @@
1
- import i18n from 'i18next';
2
- export default i18n;
1
+ import { type i18n as I18nInstance } from 'i18next';
2
+ /**
3
+ * Creates one createChat() instance's i18next instance (UI chrome strings: input placeholder,
4
+ * "Powered by", etc. - not the host-supplied bot content in config.i18n). Each instance gets
5
+ * its own so simultaneous instances on the same page don't force each other's UI language when
6
+ * one switches (see StoreContext.tsx for the equivalent settings/chat store isolation).
7
+ */
8
+ export declare function createChatI18n(namespace?: string): I18nInstance;
package/dist/iife.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { createChat } from './createChat.tsx';
2
+ export type { CreateChatOptions, ChatInstance } from './createChat.tsx';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,10 @@
1
1
  export { App } from './App.tsx';
2
- export { createChat } from './createChat.ts';
3
- export type { CreateChatOptions, ChatInstance } from './createChat.ts';
2
+ export { createChat } from './createChat.tsx';
3
+ export type { CreateChatOptions, ChatInstance } from './createChat.tsx';
4
+ export { StoreProvider } from './store/StoreContext.tsx';
5
+ export { createSettingsStore } from './store/settingsStore.ts';
6
+ export { createChatStore } from './store/chatStore.ts';
7
+ export { createChatI18n } from './i18n.ts';
8
+ export type { SettingsState } from './store/settingsStore.ts';
9
+ export type { ChatState } from './store/chatStore.ts';
4
10
  export type { ChatConfig, LangOverride, Message, Session, ThemeDef, NotificationItem, NotificationTag, NotificationTagVariant, FaqItem, Attachment, } from './types/index.ts';