@asgard-js/react 0.1.3 → 0.1.4

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
@@ -132,6 +132,46 @@ When `enableLoadConfigFromService` is enabled, you can also control the upload f
132
132
 
133
133
  **Features**: Multiple file selection, image preview with modal view, and responsive design. Supports JPEG, PNG, GIF, WebP up to 20MB per file, maximum 10 files at once.
134
134
 
135
+ ### Conversation Export
136
+
137
+ The Chatbot component includes built-in conversation export functionality, allowing users to download chat history as Markdown files. You can control this feature using the `enableExport` prop.
138
+
139
+ #### Enabling Conversation Export
140
+
141
+ ```javascript
142
+ <Chatbot
143
+ config={{
144
+ apiKey: 'your-api-key',
145
+ botProviderEndpoint: 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
146
+ }}
147
+ customChannelId="your-channel-id"
148
+ enableExport={true} // Explicitly enable conversation export
149
+ />
150
+ ```
151
+
152
+ #### Control via Remote Configuration
153
+
154
+ When `enableLoadConfigFromService` is enabled, you can also control the export feature through the bot provider's `embedConfig`:
155
+
156
+ ```javascript
157
+ <Chatbot
158
+ config={{
159
+ apiKey: 'your-api-key',
160
+ botProviderEndpoint: 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
161
+ }}
162
+ customChannelId="your-channel-id"
163
+ enableLoadConfigFromService={true}
164
+ // Export feature will be controlled by annotations.embedConfig.enableExport from the API
165
+ />
166
+ ```
167
+
168
+ **Configuration Priority** (highest to lowest):
169
+ 1. `enableExport` prop value
170
+ 2. `annotations.embedConfig.enableExport` from bot provider metadata
171
+ 3. Default: `false`
172
+
173
+ **Features**: Download button in chatbot footer, exports conversation history with timestamps and trace IDs, human-readable filename format (`{BotName}_對話紀錄_{Date}_{Time}.md`).
174
+
135
175
  ### API Key Authentication
136
176
 
137
177
  For applications that need dynamic API key input (such as embedded chatbots), you can use the authentication state management:
@@ -222,6 +262,7 @@ config: {
222
262
  - **customActions?**: `ReactNode[]` - Custom actions to display on the chatbot header
223
263
  - **enableLoadConfigFromService?**: `boolean` - Enable loading configuration from service
224
264
  - **enableUpload?**: `boolean` - Enable file upload functionality. When set, it takes priority over the `embedConfig.enableUpload` setting from the bot provider metadata. Defaults to `false` if not specified in either location. Supports image files (JPEG, PNG, GIF, WebP) up to 20MB per file, maximum 10 files at once.
265
+ - **enableExport?**: `boolean` - Enable conversation export functionality. When set, it takes priority over the `embedConfig.enableExport` setting from the bot provider metadata. Defaults to `false` if not specified in either location. Adds a download button to the chatbot footer that exports the conversation history as a Markdown file with timestamps and trace IDs.
225
266
  - **maintainConnectionWhenClosed?**: `boolean` - Maintain connection when chat is closed, defaults to `false`
226
267
  - **loadingComponent?**: `ReactNode` - Custom loading component
227
268
  - **asyncInitializers?**: `Record<string, () => Promise<unknown>>` - Asynchronous initializers for app initialization before rendering any component. Good for loading data or other async operations as the initial state. It only works when `enableLoadConfigFromService` is set to `true`.
@@ -1 +1 @@
1
- {"version":3,"file":"bot-typing-placeholder.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/text-template/bot-typing-placeholder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AAI3C,UAAU,yBAAyB;IACjC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,yBAAyB,GAC/B,SAAS,CA4BX"}
1
+ {"version":3,"file":"bot-typing-placeholder.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/text-template/bot-typing-placeholder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AAI3C,UAAU,yBAAyB;IACjC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,yBAAyB,GAC/B,SAAS,CAiBX"}
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var U = (e, t, n) => AL(e, typeof t != "symbol" ? t + "" : t, n), hC = (e, t, n)
7
7
  var pC = (e, t, n) => (hC(e, t, "read from private field"), n ? n.call(e) : t.get(e)), gC = (e, t, n) => t.has(e) ? dC("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), O0 = (e, t, n, i) => (hC(e, t, "write to private field"), i ? i.call(e, n) : t.set(e, n), n);
8
8
  import { jsx as N, jsxs as we, Fragment as If } from "react/jsx-runtime";
9
9
  import * as Te from "react";
10
- import ra, { useRef as Bi, useEffect as pt, useState as et, useCallback as Ve, useMemo as Je, useLayoutEffect as m5, createContext as $g, useContext as Ag, useImperativeHandle as ML, memo as FL, forwardRef as TL } from "react";
10
+ import ra, { useRef as Bi, useEffect as pt, useState as Qe, useCallback as Ve, useMemo as et, useLayoutEffect as m5, createContext as $g, useContext as Ag, useImperativeHandle as ML, memo as FL, forwardRef as TL } from "react";
11
11
  import { AsgardServiceClient as NL, EventType as nu, Conversation as RL, Channel as OL, MessageTemplateType as Hs } from "@asgard-js/core";
12
12
  function mC(e) {
13
13
  return e !== null && typeof e == "object" && !Array.isArray(e);
@@ -118,7 +118,7 @@ function IL(e) {
118
118
  throw new Error("Client instance is required");
119
119
  if (!r)
120
120
  throw new Error("Custom channel id is required");
121
- const [l, c] = et(null), [f, d] = et(n ?? !0), [h, p] = et(!1), [g, m] = et(!1), [y, b] = et(null), v = Ve(
121
+ const [l, c] = Qe(null), [f, d] = Qe(n ?? !0), [h, p] = Qe(!1), [g, m] = Qe(!1), [y, b] = Qe(null), v = Ve(
122
122
  async (E) => {
123
123
  const w = new RL({
124
124
  messages: new Map(
@@ -162,7 +162,7 @@ function IL(e) {
162
162
  );
163
163
  return pt(() => {
164
164
  !l && f && v(i);
165
- }, [l, f, v, i]), pt(() => () => x(), [x]), Je(
165
+ }, [l, f, v, i]), pt(() => () => x(), [x]), et(
166
166
  () => ({
167
167
  isOpen: f,
168
168
  isResetting: h,
@@ -184,7 +184,7 @@ function IL(e) {
184
184
  );
185
185
  }
186
186
  function zL(e, t) {
187
- const [n, i] = et(e);
187
+ const [n, i] = Qe(e);
188
188
  return pt(() => {
189
189
  const r = window.setTimeout(() => {
190
190
  i(e);
@@ -197,7 +197,7 @@ function BL() {
197
197
  return window.visualViewport ? [window.visualViewport.width, window.visualViewport.height] : [window.innerWidth, window.innerHeight];
198
198
  }
199
199
  function UL() {
200
- const [e, t] = et(), n = Ve(() => {
200
+ const [e, t] = Qe(), n = Ve(() => {
201
201
  const i = BL();
202
202
  t(
203
203
  (r) => r && r[0] === i[0] && r[1] === i[1] ? r : i
@@ -220,7 +220,7 @@ function bC(e) {
220
220
  ) || e.hasAttribute("contenteditable");
221
221
  }
222
222
  function jL() {
223
- const [e, t] = et(!1);
223
+ const [e, t] = Qe(!1);
224
224
  return pt(() => {
225
225
  function n(r) {
226
226
  if (!r.target) return;
@@ -384,9 +384,9 @@ const x5 = $g({
384
384
  n
385
385
  ),
386
386
  [...VL(n), o]
387
- ), [a, u] = et(
387
+ ), [a, u] = Qe(
388
388
  {}
389
- ), [l, c] = et(!0), [f, d] = et(null);
389
+ ), [l, c] = Qe(!0), [f, d] = Qe(null);
390
390
  return pt(() => {
391
391
  let h = !0;
392
392
  if (t)
@@ -751,7 +751,7 @@ function xC(e) {
751
751
  return vu(u, n);
752
752
  },
753
753
  [n, (s = i == null ? void 0 : i.embedConfig) == null ? void 0 : s.theme]
754
- ), o = Je(() => r(), [r]);
754
+ ), o = et(() => r(), [r]);
755
755
  return /* @__PURE__ */ N(_5.Provider, { value: o, children: t });
756
756
  }
757
757
  function an() {
@@ -801,7 +801,7 @@ function _C(e) {
801
801
  initMessages: f,
802
802
  onSseMessage: d,
803
803
  onAuthError: h
804
- }), w = Je(
804
+ }), w = et(
805
805
  () => ({
806
806
  avatar: t,
807
807
  title: n,
@@ -858,7 +858,7 @@ function XL(e) {
858
858
  errorMessageRenderer: i,
859
859
  onTemplateBtnClick: r,
860
860
  defaultLinkTarget: o
861
- } = e, s = Je(
861
+ } = e, s = et(
862
862
  () => ({
863
863
  onErrorClick: n,
864
864
  errorMessageRenderer: i,
@@ -926,7 +926,7 @@ function wC({
926
926
  className: s
927
927
  }) {
928
928
  var m, y;
929
- const [a, u] = et(""), [l, c] = et(!1), { chatbot: f } = an(), { avatar: d } = ri(), h = (b) => {
929
+ const [a, u] = Qe(""), [l, c] = Qe(!1), { chatbot: f } = an(), { avatar: d } = ri(), h = (b) => {
930
930
  b.preventDefault(), a.trim() && !t && e(a.trim());
931
931
  }, p = (b) => {
932
932
  u(b.target.value);
@@ -1013,7 +1013,7 @@ function EC(e) {
1013
1013
  maintainConnectionWhenClosed: o
1014
1014
  } = e, { chatbot: s } = an(), {
1015
1015
  data: { annotations: a }
1016
- } = Wv(), { avatar: u, isResetting: l, resetChannel: c, closeChannel: f } = ri(), d = Je(
1016
+ } = Wv(), { avatar: u, isResetting: l, resetChannel: c, closeChannel: f } = ri(), d = et(
1017
1017
  () => ({
1018
1018
  maxWidth: (s == null ? void 0 : s.contentMaxWidth) ?? "1200px",
1019
1019
  borderBottomColor: s == null ? void 0 : s.borderColor
@@ -1067,7 +1067,7 @@ const gP = "_chatbot_body_f6sqm_1", mP = "_chatbot_body__content_f6sqm_5", SC =
1067
1067
  "template_box--user": "_template_box--user_1ozig_14"
1068
1068
  };
1069
1069
  function ts(e) {
1070
- const { type: t, direction: n = "horizontal", children: i, style: r, className: o } = e, s = Je(() => {
1070
+ const { type: t, direction: n = "horizontal", children: i, style: r, className: o } = e, s = et(() => {
1071
1071
  switch (t) {
1072
1072
  case "user":
1073
1073
  return Ye(iu.template_box, iu["template_box--user"]);
@@ -1140,7 +1140,7 @@ const EP = "_time_rgg92_1", SP = {
1140
1140
  };
1141
1141
  function zf(e) {
1142
1142
  var o, s;
1143
- const { time: t, className: n } = e, { template: i } = an(), r = Je(
1143
+ const { time: t, className: n } = e, { template: i } = an(), r = et(
1144
1144
  () => {
1145
1145
  var a, u;
1146
1146
  return {
@@ -1223,10 +1223,10 @@ function DP(e, t, n) {
1223
1223
  }
1224
1224
  function A5(e) {
1225
1225
  var l;
1226
- const { template: t, customStyle: n } = e, { sendMessage: i } = ri(), { onTemplateBtnClick: r, defaultLinkTarget: o } = S5(), s = Je(() => {
1226
+ const { template: t, customStyle: n } = e, { sendMessage: i } = ri(), { onTemplateBtnClick: r, defaultLinkTarget: o } = S5(), s = et(() => {
1227
1227
  var c;
1228
1228
  return ((c = t == null ? void 0 : t.thumbnailImageUrl) == null ? void 0 : c.replace(/^http:/, "").replace(/^https:/, "")) || "https://via.assets.so/img.jpg?w=200&h=270&tc=white&bg=#eeeeee";
1229
- }, [t]), a = Je(() => {
1229
+ }, [t]), a = et(() => {
1230
1230
  switch (t == null ? void 0 : t.imageAspectRatio) {
1231
1231
  case "square":
1232
1232
  return "1 / 1";
@@ -1344,7 +1344,7 @@ const PP = "_text_1ooxl_1", IP = "_dot_1ooxl_42", ur = {
1344
1344
  dot: IP
1345
1345
  };
1346
1346
  function M5({ children: e }) {
1347
- const [t, n] = et(null), [i, r] = et(!1);
1347
+ const [t, n] = Qe(null), [i, r] = Qe(!1);
1348
1348
  return pt(() => {
1349
1349
  (async () => {
1350
1350
  try {
@@ -1358,7 +1358,7 @@ function M5({ children: e }) {
1358
1358
  }
1359
1359
  function AC(e) {
1360
1360
  var l, c, f, d;
1361
- const { message: t } = e, { avatar: n } = ri(), i = an(), { botMessage: r } = i, o = ((l = t == null ? void 0 : t.message) == null ? void 0 : l.text) || "", s = t.type === "bot", a = (f = (c = i == null ? void 0 : i.template) == null ? void 0 : c.TextMessageTemplate) == null ? void 0 : f.style, u = Je(() => {
1361
+ const { message: t } = e, { avatar: n } = ri(), i = an(), { botMessage: r } = i, o = ((l = t == null ? void 0 : t.message) == null ? void 0 : l.text) || "", s = t.type === "bot", a = (f = (c = i == null ? void 0 : i.template) == null ? void 0 : c.TextMessageTemplate) == null ? void 0 : f.style, u = et(() => {
1362
1362
  var h, p, g, m, y, b, v, x, _;
1363
1363
  switch (t.type) {
1364
1364
  case "user":
@@ -1431,7 +1431,7 @@ function F5(e) {
1431
1431
  (f = i.current) == null || f.scrollIntoView({ behavior: "smooth" });
1432
1432
  }, [i]);
1433
1433
  GL({ ref: s, onResize: a });
1434
- const u = zL(t, 500), l = Je(
1434
+ const u = zL(t, 500), l = et(
1435
1435
  () => {
1436
1436
  var f, d;
1437
1437
  return {
@@ -1440,7 +1440,7 @@ function F5(e) {
1440
1440
  };
1441
1441
  },
1442
1442
  [o]
1443
- ), c = Je(
1443
+ ), c = et(
1444
1444
  () => {
1445
1445
  var f;
1446
1446
  return {
@@ -1478,19 +1478,13 @@ function F5(e) {
1478
1478
  ) : null;
1479
1479
  }
1480
1480
  function zP(e) {
1481
- const { placeholder: t } = e, { isConnecting: n, messages: i } = ri(), r = Je(
1481
+ const { placeholder: t } = e, { isConnecting: n, messages: i } = ri(), r = et(
1482
1482
  () => Array.from((i == null ? void 0 : i.values()) ?? []).some(
1483
- (s) => s.type === "bot" && s.isTyping
1483
+ (o) => o.type === "bot" && o.isTyping
1484
1484
  ),
1485
1485
  [i]
1486
- ), o = Je(
1487
- () => {
1488
- const a = Array.from((i == null ? void 0 : i.values()) ?? []).filter((u) => u.type === "bot").pop();
1489
- return a && !a.isTyping;
1490
- },
1491
- [i]
1492
1486
  );
1493
- return n && !r && !o ? /* @__PURE__ */ N(F5, { isTyping: !0, typingText: t }) : null;
1487
+ return n && !r ? /* @__PURE__ */ N(F5, { isTyping: !0, typingText: t }) : null;
1494
1488
  }
1495
1489
  const BP = "_carousel_root_sv1hc_1", UP = "_carousel_time_sv1hc_12", MC = {
1496
1490
  carousel_root: BP,
@@ -13394,7 +13388,7 @@ function AV(e) {
13394
13388
  const t = e.bounds.clone();
13395
13389
  return t.empty() ? t.set(0, 0, 0, 0) : t.translate(-(e.x || 0), -(e.y || 0));
13396
13390
  }
13397
- function Qe(e, t, n) {
13391
+ function Je(e, t, n) {
13398
13392
  const i = J(e) ? e[t] : e;
13399
13393
  return i ?? (n !== void 0 ? n : 0);
13400
13394
  }
@@ -13402,7 +13396,7 @@ function x$(e) {
13402
13396
  return e < 0 ? Math.ceil(-e) : 0;
13403
13397
  }
13404
13398
  function qN(e, t, n) {
13405
- var i = !n.nodirty, r = n.bounds === y_ ? $V : AV, o = Xt.set(0, 0, 0, 0), s = Qe(n.align, Wo), a = Qe(n.align, Ho), u = Qe(n.padding, Wo), l = Qe(n.padding, Ho), c = n.columns || t.length, f = c <= 0 ? 1 : Math.ceil(t.length / c), d = t.length, h = Array(d), p = Array(c), g = 0, m = Array(d), y = Array(f), b = 0, v = Array(d), x = Array(d), _ = Array(d), E, w, S, C, A, $, R, T, M, k, F;
13399
+ var i = !n.nodirty, r = n.bounds === y_ ? $V : AV, o = Xt.set(0, 0, 0, 0), s = Je(n.align, Wo), a = Je(n.align, Ho), u = Je(n.padding, Wo), l = Je(n.padding, Ho), c = n.columns || t.length, f = c <= 0 ? 1 : Math.ceil(t.length / c), d = t.length, h = Array(d), p = Array(c), g = 0, m = Array(d), y = Array(f), b = 0, v = Array(d), x = Array(d), _ = Array(d), E, w, S, C, A, $, R, T, M, k, F;
13406
13400
  for (w = 0; w < c; ++w) p[w] = 0;
13407
13401
  for (w = 0; w < f; ++w) y[w] = 0;
13408
13402
  for (w = 0; w < d; ++w)
@@ -13446,22 +13440,22 @@ function qN(e, t, n) {
13446
13440
  for (S = 0; S < c; ++S)
13447
13441
  for (k = 0, w = S; w < d; w += c)
13448
13442
  k += m[w], x[w] += k - t[w].y;
13449
- if (s && Qe(n.center, Wo) && f > 1)
13443
+ if (s && Je(n.center, Wo) && f > 1)
13450
13444
  for (w = 0; w < d; ++w)
13451
13445
  A = s === Wd ? g : p[w % c], M = A - _[w].x2 - t[w].x - v[w], M > 0 && (v[w] += M / 2);
13452
- if (a && Qe(n.center, Ho) && c !== 1)
13446
+ if (a && Je(n.center, Ho) && c !== 1)
13453
13447
  for (w = 0; w < d; ++w)
13454
13448
  A = a === Wd ? b : y[~~(w / c)], k = A - _[w].y2 - t[w].y - x[w], k > 0 && (x[w] += k / 2);
13455
13449
  for (w = 0; w < d; ++w)
13456
13450
  o.union(_[w].translate(v[w], x[w]));
13457
- switch (M = Qe(n.anchor, dV), k = Qe(n.anchor, hV), Qe(n.anchor, Wo)) {
13451
+ switch (M = Je(n.anchor, dV), k = Je(n.anchor, hV), Je(n.anchor, Wo)) {
13458
13452
  case fn:
13459
13453
  M -= o.width();
13460
13454
  break;
13461
13455
  case hb:
13462
13456
  M -= o.width() / 2;
13463
13457
  }
13464
- switch (Qe(n.anchor, Ho)) {
13458
+ switch (Je(n.anchor, Ho)) {
13465
13459
  case fn:
13466
13460
  k -= o.height();
13467
13461
  break;
@@ -13477,7 +13471,7 @@ function qN(e, t, n) {
13477
13471
  function MV(e, t, n) {
13478
13472
  var i = kV(t), r = i.marks, o = n.bounds === y_ ? FV : TV, s = n.offset, a = n.columns || r.length, u = a <= 0 ? 1 : Math.ceil(r.length / a), l = u * a, c, f, d, h, p, g, m;
13479
13473
  const y = qN(e, r, n);
13480
- y.empty() && y.set(0, 0, 0, 0), i.rowheaders && (g = Qe(n.headerBand, Ho, null), c = Vd(e, i.rowheaders, r, a, u, -Qe(s, "rowHeader"), b$, 0, o, "x1", 0, a, 1, g)), i.colheaders && (g = Qe(n.headerBand, Wo, null), f = Vd(e, i.colheaders, r, a, a, -Qe(s, "columnHeader"), b$, 1, o, "y1", 0, 1, a, g)), i.rowfooters && (g = Qe(n.footerBand, Ho, null), d = Vd(e, i.rowfooters, r, a, u, Qe(s, "rowFooter"), v$, 0, o, "x2", a - 1, a, 1, g)), i.colfooters && (g = Qe(n.footerBand, Wo, null), h = Vd(e, i.colfooters, r, a, a, Qe(s, "columnFooter"), v$, 1, o, "y2", l - a, 1, a, g)), i.rowtitle && (p = Qe(n.titleAnchor, Ho), m = Qe(s, "rowTitle"), m = p === fn ? d + m : c - m, g = Qe(n.titleBand, Ho, 0.5), _$(e, i.rowtitle, m, 0, y, g)), i.coltitle && (p = Qe(n.titleAnchor, Wo), m = Qe(s, "columnTitle"), m = p === fn ? h + m : f - m, g = Qe(n.titleBand, Wo, 0.5), _$(e, i.coltitle, m, 1, y, g));
13474
+ y.empty() && y.set(0, 0, 0, 0), i.rowheaders && (g = Je(n.headerBand, Ho, null), c = Vd(e, i.rowheaders, r, a, u, -Je(s, "rowHeader"), b$, 0, o, "x1", 0, a, 1, g)), i.colheaders && (g = Je(n.headerBand, Wo, null), f = Vd(e, i.colheaders, r, a, a, -Je(s, "columnHeader"), b$, 1, o, "y1", 0, 1, a, g)), i.rowfooters && (g = Je(n.footerBand, Ho, null), d = Vd(e, i.rowfooters, r, a, u, Je(s, "rowFooter"), v$, 0, o, "x2", a - 1, a, 1, g)), i.colfooters && (g = Je(n.footerBand, Wo, null), h = Vd(e, i.colfooters, r, a, a, Je(s, "columnFooter"), v$, 1, o, "y2", l - a, 1, a, g)), i.rowtitle && (p = Je(n.titleAnchor, Ho), m = Je(s, "rowTitle"), m = p === fn ? d + m : c - m, g = Je(n.titleBand, Ho, 0.5), _$(e, i.rowtitle, m, 0, y, g)), i.coltitle && (p = Je(n.titleAnchor, Wo), m = Je(s, "columnTitle"), m = p === fn ? h + m : f - m, g = Je(n.titleBand, Wo, 0.5), _$(e, i.coltitle, m, 1, y, g));
13481
13475
  }
13482
13476
  function FV(e, t) {
13483
13477
  return t === "x1" ? e.x || 0 : t === "y1" ? e.y || 0 : t === "x2" ? (e.x || 0) + (e.width || 0) : t === "y2" ? (e.y || 0) + (e.height || 0) : void 0;
@@ -40861,15 +40855,15 @@ const o0e = "_text_we7dz_1", s0e = "_chart_time_we7dz_30", a0e = "_quick_replies
40861
40855
  };
40862
40856
  function l0e(e) {
40863
40857
  var f, d, h;
40864
- const { message: t } = e, n = t.message.template, { template: i, botMessage: r } = an(), { avatar: o } = ri(), [s, a] = et(
40858
+ const { message: t } = e, n = t.message.template, { template: i, botMessage: r } = an(), { avatar: o } = ri(), [s, a] = Qe(
40865
40859
  (n == null ? void 0 : n.defaultChart) ?? ((d = (f = n == null ? void 0 : n.chartOptions) == null ? void 0 : f[0]) == null ? void 0 : d.type)
40866
- ), u = Je(() => n.chartOptions, [n]), l = Je(
40860
+ ), u = et(() => n.chartOptions, [n]), l = et(
40867
40861
  () => {
40868
40862
  var p, g;
40869
40863
  return ((g = (p = n == null ? void 0 : n.chartOptions) == null ? void 0 : p.find((m) => m.type === s)) == null ? void 0 : g.spec) ?? u[0].spec;
40870
40864
  },
40871
40865
  [s, n.chartOptions, u]
40872
- ), c = Je(
40866
+ ), c = et(
40873
40867
  () => ({
40874
40868
  color: r == null ? void 0 : r.color,
40875
40869
  backgroundColor: r == null ? void 0 : r.backgroundColor
@@ -40912,7 +40906,7 @@ const c0e = "_image_box_8cz9p_1", f0e = "_full_screen_8cz9p_24", d0e = "_imageOr
40912
40906
  };
40913
40907
  function p0e(e) {
40914
40908
  var l;
40915
- const { message: t } = e, n = t.message.template, { previewImageUrl: i, originalContentUrl: r } = n, { template: o } = an(), { avatar: s } = ri(), [a, u] = et(!1);
40909
+ const { message: t } = e, n = t.message.template, { previewImageUrl: i, originalContentUrl: r } = n, { template: o } = an(), { avatar: s } = ri(), [a, u] = Qe(!1);
40916
40910
  return a ? /* @__PURE__ */ we(
40917
40911
  "div",
40918
40912
  {
@@ -40962,7 +40956,7 @@ const g0e = "_message_wrapper_a44in_1", m0e = "_text_bubble_a44in_9", y0e = "_im
40962
40956
  };
40963
40957
  function w0e({ message: e }) {
40964
40958
  var s, a;
40965
- const [t, n] = et(null), i = an(), r = Je(() => {
40959
+ const [t, n] = Qe(null), i = an(), r = et(() => {
40966
40960
  var u, l;
40967
40961
  return {
40968
40962
  color: (u = i == null ? void 0 : i.userMessage) == null ? void 0 : u.color,
@@ -41051,7 +41045,7 @@ function S0e() {
41051
41045
  var s;
41052
41046
  (s = n.current) == null || s.scrollIntoView({ behavior: "smooth" });
41053
41047
  }, [t, n]);
41054
- const r = Je(
41048
+ const r = et(
41055
41049
  () => ({
41056
41050
  maxWidth: (e == null ? void 0 : e.contentMaxWidth) ?? "1200px"
41057
41051
  }),
@@ -41102,7 +41096,7 @@ const C0e = "_chatbot_footer_1d2n0_1", k0e = "_chatbot_footer__content_1d2n0_4",
41102
41096
  image_modal_close_button: j0e
41103
41097
  }, q0e = (e) => /* @__PURE__ */ Te.createElement("svg", { width: 15, height: 12, viewBox: "0 0 15 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ Te.createElement("path", { d: "M0.823242 11.6953V0.945312L14.3328 6.32031L0.823242 11.6953ZM1.90658 10.0911L11.3649 6.32031L1.90658 2.54948V4.98052L5.92574 6.32031L1.90658 7.6601V10.0911Z", fill: "currentColor" })), W0e = (e) => /* @__PURE__ */ Te.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ Te.createElement("rect", { x: 3, y: 3, width: 18, height: 18, rx: 2, ry: 2, stroke: "currentColor", strokeWidth: 2 }), /* @__PURE__ */ Te.createElement("circle", { cx: 8.5, cy: 8.5, r: 1.5, fill: "currentColor" }), /* @__PURE__ */ Te.createElement("path", { d: "M21 15L16 10L5 21", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" })), H0e = (e) => /* @__PURE__ */ Te.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ Te.createElement("path", { d: "M12 3V16M12 16L16 12M12 16L8 12", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ Te.createElement("path", { d: "M3 17V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V17", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" })), G0e = (e) => /* @__PURE__ */ Te.createElement("svg", { width: 11, height: 16, viewBox: "0 0 11 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ Te.createElement("path", { d: "M5.40658 9.90397C4.82435 9.90397 4.33158 9.7023 3.92824 9.29897C3.52491 8.89564 3.32324 8.40286 3.32324 7.82064V2.82064C3.32324 2.23842 3.52491 1.74564 3.92824 1.3423C4.33158 0.938971 4.82435 0.737305 5.40658 0.737305C5.9888 0.737305 6.48158 0.938971 6.88491 1.3423C7.28824 1.74564 7.48991 2.23842 7.48991 2.82064V7.82064C7.48991 8.40286 7.28824 8.89564 6.88491 9.29897C6.48158 9.7023 5.9888 9.90397 5.40658 9.90397ZM4.86491 15.1123V12.8654C3.56213 12.7208 2.47949 12.1724 1.61699 11.2202C0.754492 10.2679 0.323242 9.13467 0.323242 7.82064H1.40658C1.40658 8.92731 1.79706 9.87064 2.57803 10.6506C3.35887 11.4306 4.30331 11.8206 5.41137 11.8206C6.51928 11.8206 7.46213 11.4306 8.23991 10.6506C9.01769 9.87064 9.40658 8.92731 9.40658 7.82064H10.4899C10.4899 9.13467 10.0587 10.2679 9.19616 11.2202C8.33366 12.1724 7.25102 12.7208 5.94824 12.8654V15.1123H4.86491ZM5.40658 8.82064C5.68991 8.82064 5.92741 8.7248 6.11908 8.53314C6.31074 8.34147 6.40658 8.10397 6.40658 7.82064V2.82064C6.40658 2.5373 6.31074 2.2998 6.11908 2.10814C5.92741 1.91647 5.68991 1.82064 5.40658 1.82064C5.12324 1.82064 4.88574 1.91647 4.69408 2.10814C4.50241 2.2998 4.40658 2.5373 4.40658 2.82064V7.82064C4.40658 8.10397 4.50241 8.34147 4.69408 8.53314C4.88574 8.7248 5.12324 8.82064 5.40658 8.82064Z", fill: "currentColor" })), V0e = (e) => /* @__PURE__ */ Te.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ Te.createElement("circle", { cx: 20, cy: 20, r: 18, fill: "#D04444" }), /* @__PURE__ */ Te.createElement("rect", { x: 12, y: 12, width: 16, height: 16, fill: "#FFFFFF", rx: 2, ry: 2 }));
41104
41098
  function Y0e(e) {
41105
- const { setValue: t, className: n, style: i } = e, [r, o] = et(!1), s = Bi(null);
41099
+ const { setValue: t, className: n, style: i } = e, [r, o] = Qe(!1), s = Bi(null);
41106
41100
  pt(() => {
41107
41101
  const h = window.SpeechRecognition || window.webkitSpeechRecognition;
41108
41102
  if (!h) return;
@@ -41189,19 +41183,19 @@ function Z0e(e) {
41189
41183
  }
41190
41184
  function J0e() {
41191
41185
  var I, Z, ae, se, he, Ne, pe, at, Un, Cn, ee, ge, be, q;
41192
- const { sendMessage: e, isConnecting: t, inputPlaceholder: n, client: i, customChannelId: r, enableUpload: o, enableExport: s, messages: a, title: u } = ri(), { data: l } = Wv(), { chatbot: c } = an(), f = Je(() => {
41186
+ const { sendMessage: e, isConnecting: t, inputPlaceholder: n, client: i, customChannelId: r, enableUpload: o, enableExport: s, messages: a, title: u } = ri(), { data: l } = Wv(), { chatbot: c } = an(), f = et(() => {
41193
41187
  var ie, ne;
41194
41188
  return o !== void 0 ? o : ((ne = (ie = l.annotations) == null ? void 0 : ie.embedConfig) == null ? void 0 : ne.enableUpload) ?? !1;
41195
- }, [o, (Z = (I = l.annotations) == null ? void 0 : I.embedConfig) == null ? void 0 : Z.enableUpload]), d = Je(() => {
41189
+ }, [o, (Z = (I = l.annotations) == null ? void 0 : I.embedConfig) == null ? void 0 : Z.enableUpload]), d = et(() => {
41196
41190
  var ie, ne;
41197
41191
  return s !== void 0 ? s : ((ne = (ie = l.annotations) == null ? void 0 : ie.embedConfig) == null ? void 0 : ne.enableExport) ?? !1;
41198
- }, [s, (se = (ae = l.annotations) == null ? void 0 : ae.embedConfig) == null ? void 0 : se.enableExport]), h = Je(() => {
41192
+ }, [s, (se = (ae = l.annotations) == null ? void 0 : ae.embedConfig) == null ? void 0 : se.enableExport]), h = et(() => {
41199
41193
  var ie, ne;
41200
41194
  return ((ne = (ie = l.annotations) == null ? void 0 : ie.embedConfig) == null ? void 0 : ne.title) || u || "Bot";
41201
- }, [(Ne = (he = l.annotations) == null ? void 0 : he.embedConfig) == null ? void 0 : Ne.title, u]), [p, g] = et(""), [m, y] = et(!1), [b, v] = et([]), [x, _] = et([]), [E, w] = et(null), S = Bi(null), C = Bi(null), A = Je(
41195
+ }, [(Ne = (he = l.annotations) == null ? void 0 : he.embedConfig) == null ? void 0 : Ne.title, u]), [p, g] = Qe(""), [m, y] = Qe(!1), [b, v] = Qe([]), [x, _] = Qe([]), [E, w] = Qe(null), S = Bi(null), C = Bi(null), A = et(
41202
41196
  () => t || !p.trim() && b.length === 0,
41203
41197
  [t, p, b.length]
41204
- ), $ = Je(
41198
+ ), $ = et(
41205
41199
  () => ({
41206
41200
  maxWidth: (c == null ? void 0 : c.contentMaxWidth) ?? "1200px",
41207
41201
  borderTopColor: c == null ? void 0 : c.borderColor
@@ -41453,7 +41447,7 @@ function i1e(e) {
41453
41447
  v5(n);
41454
41448
  const [, r] = UL() ?? [], o = jL();
41455
41449
  qL(o);
41456
- const s = Je(() => {
41450
+ const s = et(() => {
41457
41451
  var a, u;
41458
41452
  return Object.assign(
41459
41453
  (a = i == null ? void 0 : i.chatbot) != null && a.backgroundColor ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgard-js/react",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -48,7 +48,7 @@
48
48
  "vitest": "^1.6.0"
49
49
  },
50
50
  "peerDependencies": {
51
- "@asgard-js/core": "^0.1.3",
51
+ "@asgard-js/core": "^0.1.4",
52
52
  "react": "^18.0.0",
53
53
  "react-dom": "^18.0.0"
54
54
  },