@iota-uz/sdk 0.4.16 → 0.4.17

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.
@@ -64,14 +64,15 @@ function useTranslation() {
64
64
  const { translations, language } = locale;
65
65
  const t = React.useCallback(
66
66
  (key2, params) => {
67
- let text = translations[key2] || key2;
67
+ const raw = translations[key2];
68
+ let text = typeof raw === "string" && raw.trim() ? raw : key2;
68
69
  if (params) {
69
70
  Object.keys(params).forEach((paramKey) => {
70
71
  const value = params[paramKey];
71
72
  text = text.replace(new RegExp(`{{${paramKey}}}`, "g"), String(value));
72
73
  });
73
74
  }
74
- return text;
75
+ return text.trim() ? text : key2;
75
76
  },
76
77
  [translations]
77
78
  );
@@ -6072,6 +6073,8 @@ function WarningBox({ message }) {
6072
6073
  }
6073
6074
  function ArtifactActions({ url }) {
6074
6075
  const { t } = useTranslation();
6076
+ const openLabel = t("BiChat.Artifacts.OpenInNewTab");
6077
+ const downloadLabel = t("BiChat.Artifacts.Download");
6075
6078
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
6076
6079
  /* @__PURE__ */ jsxRuntime.jsxs(
6077
6080
  "a",
@@ -6082,7 +6085,7 @@ function ArtifactActions({ url }) {
6082
6085
  className: "inline-flex items-center gap-2 rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-50 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800",
6083
6086
  children: [
6084
6087
  /* @__PURE__ */ jsxRuntime.jsx(react.ArrowSquareOut, { className: "h-3.5 w-3.5", weight: "bold" }),
6085
- t("BiChat.Artifacts.OpenInNewTab")
6088
+ openLabel
6086
6089
  ]
6087
6090
  }
6088
6091
  ),
@@ -6096,7 +6099,7 @@ function ArtifactActions({ url }) {
6096
6099
  className: "inline-flex items-center gap-2 rounded-lg bg-primary-600 px-3 py-1.5 text-xs font-medium text-white shadow-sm transition-colors hover:bg-primary-700",
6097
6100
  children: [
6098
6101
  /* @__PURE__ */ jsxRuntime.jsx(react.DownloadSimple, { className: "h-3.5 w-3.5", weight: "bold" }),
6099
- t("BiChat.Artifacts.Download")
6102
+ downloadLabel
6100
6103
  ]
6101
6104
  }
6102
6105
  )
@@ -7416,6 +7419,7 @@ var EditableText = React.forwardRef(
7416
7419
  setIsEditing(false);
7417
7420
  };
7418
7421
  const handleKeyDown = (e) => {
7422
+ e.stopPropagation();
7419
7423
  if (e.key === "Enter") {
7420
7424
  e.preventDefault();
7421
7425
  handleSave();
@@ -7449,6 +7453,7 @@ var EditableText = React.forwardRef(
7449
7453
  value: editValue,
7450
7454
  onChange: (e) => setEditValue(e.target.value),
7451
7455
  onKeyDown: handleKeyDown,
7456
+ onKeyUp: (e) => e.stopPropagation(),
7452
7457
  onBlur: handleBlur,
7453
7458
  maxLength,
7454
7459
  placeholder: resolvedPlaceholder,
@@ -8495,6 +8500,9 @@ var SessionItem = React.memo(
8495
8500
  onSelect(session.id);
8496
8501
  },
8497
8502
  onKeyDown: (e) => {
8503
+ const target = e.target;
8504
+ const isFromEditable = !!target?.closest('input, textarea, [contenteditable="true"]');
8505
+ if (isFromEditable) return;
8498
8506
  if (e.key === "Enter" || e.key === " ") {
8499
8507
  e.preventDefault();
8500
8508
  onSelect(session.id);
@@ -9253,6 +9261,15 @@ function Sidebar2({
9253
9261
  React.useEffect(() => {
9254
9262
  fetchSessions();
9255
9263
  }, [fetchSessions, refreshKey]);
9264
+ React.useEffect(() => {
9265
+ const handleSessionsUpdated = () => {
9266
+ setRefreshKey((k) => k + 1);
9267
+ };
9268
+ window.addEventListener("bichat:sessions-updated", handleSessionsUpdated);
9269
+ return () => {
9270
+ window.removeEventListener("bichat:sessions-updated", handleSessionsUpdated);
9271
+ };
9272
+ }, []);
9256
9273
  React.useEffect(() => {
9257
9274
  if (!activeSessionId) {
9258
9275
  refreshForActiveSessionRef.current = null;
@@ -9627,13 +9644,14 @@ function Sidebar2({
9627
9644
  anchor: "top start",
9628
9645
  className: "w-48 bg-white/95 dark:bg-gray-900/95 backdrop-blur-lg rounded-xl shadow-lg border border-gray-200/80 dark:border-gray-700/60 z-30 [--anchor-gap:8px] mb-1 p-1.5",
9629
9646
  children: [
9630
- onArchivedView && /* @__PURE__ */ jsxRuntime.jsx(react$1.MenuItem, { children: ({ focus }) => /* @__PURE__ */ jsxRuntime.jsxs(
9647
+ onArchivedView && /* @__PURE__ */ jsxRuntime.jsx(react$1.MenuItem, { children: ({ focus, close }) => /* @__PURE__ */ jsxRuntime.jsxs(
9631
9648
  "button",
9632
9649
  {
9633
9650
  onClick: (e) => {
9634
9651
  e.preventDefault();
9635
9652
  e.stopPropagation();
9636
9653
  onArchivedView();
9654
+ close();
9637
9655
  },
9638
9656
  className: `cursor-pointer flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-gray-600 dark:text-gray-300 transition-colors ${focus ? "bg-gray-100 dark:bg-gray-800/70" : ""}`,
9639
9657
  "aria-label": t("BiChat.Sidebar.ArchivedChats"),
@@ -9643,13 +9661,14 @@ function Sidebar2({
9643
9661
  ]
9644
9662
  }
9645
9663
  ) }),
9646
- showAllChatsTab && activeTab !== "all-chats" && /* @__PURE__ */ jsxRuntime.jsx(react$1.MenuItem, { children: ({ focus }) => /* @__PURE__ */ jsxRuntime.jsxs(
9664
+ showAllChatsTab && activeTab !== "all-chats" && /* @__PURE__ */ jsxRuntime.jsx(react$1.MenuItem, { children: ({ focus, close }) => /* @__PURE__ */ jsxRuntime.jsxs(
9647
9665
  "button",
9648
9666
  {
9649
9667
  onClick: (e) => {
9650
9668
  e.preventDefault();
9651
9669
  e.stopPropagation();
9652
9670
  setActiveTab("all-chats");
9671
+ close();
9653
9672
  },
9654
9673
  className: `cursor-pointer flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-gray-600 dark:text-gray-300 transition-colors ${focus ? "bg-gray-100 dark:bg-gray-800/70" : ""}`,
9655
9674
  "aria-label": t("BiChat.Sidebar.AllChats"),
@@ -9659,13 +9678,14 @@ function Sidebar2({
9659
9678
  ]
9660
9679
  }
9661
9680
  ) }),
9662
- showAllChatsTab && activeTab === "all-chats" && /* @__PURE__ */ jsxRuntime.jsx(react$1.MenuItem, { children: ({ focus }) => /* @__PURE__ */ jsxRuntime.jsxs(
9681
+ showAllChatsTab && activeTab === "all-chats" && /* @__PURE__ */ jsxRuntime.jsx(react$1.MenuItem, { children: ({ focus, close }) => /* @__PURE__ */ jsxRuntime.jsxs(
9663
9682
  "button",
9664
9683
  {
9665
9684
  onClick: (e) => {
9666
9685
  e.preventDefault();
9667
9686
  e.stopPropagation();
9668
9687
  setActiveTab("my-chats");
9688
+ close();
9669
9689
  },
9670
9690
  className: `cursor-pointer flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-gray-600 dark:text-gray-300 transition-colors ${focus ? "bg-gray-100 dark:bg-gray-800/70" : ""}`,
9671
9691
  "aria-label": t("BiChat.Sidebar.MyChats"),
@@ -9780,7 +9800,11 @@ function ArchivedChatList({
9780
9800
  const confirmRestore = async () => {
9781
9801
  if (!sessionToRestore) return;
9782
9802
  try {
9783
- await dataSource.unarchiveSession(sessionToRestore);
9803
+ const restoredSessionID = sessionToRestore;
9804
+ await dataSource.unarchiveSession(restoredSessionID);
9805
+ window.dispatchEvent(new CustomEvent("bichat:sessions-updated", {
9806
+ detail: { reason: "restored", sessionId: restoredSessionID }
9807
+ }));
9784
9808
  setRefreshKey((k) => k + 1);
9785
9809
  toast.success(t("BiChat.Archived.ChatRestoredSuccessfully"));
9786
9810
  } catch (err) {
@@ -12262,7 +12286,7 @@ var HttpDataSource = class {
12262
12286
  this.abortController = null;
12263
12287
  this.config = {
12264
12288
  streamEndpoint: "/stream",
12265
- timeout: 3e4,
12289
+ timeout: 12e4,
12266
12290
  ...config
12267
12291
  };
12268
12292
  if (config.navigateToSession) {