@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.
@@ -54,14 +54,15 @@ function useTranslation() {
54
54
  const { translations, language } = locale;
55
55
  const t = useCallback(
56
56
  (key2, params) => {
57
- let text = translations[key2] || key2;
57
+ const raw = translations[key2];
58
+ let text = typeof raw === "string" && raw.trim() ? raw : key2;
58
59
  if (params) {
59
60
  Object.keys(params).forEach((paramKey) => {
60
61
  const value = params[paramKey];
61
62
  text = text.replace(new RegExp(`{{${paramKey}}}`, "g"), String(value));
62
63
  });
63
64
  }
64
- return text;
65
+ return text.trim() ? text : key2;
65
66
  },
66
67
  [translations]
67
68
  );
@@ -6062,6 +6063,8 @@ function WarningBox({ message }) {
6062
6063
  }
6063
6064
  function ArtifactActions({ url }) {
6064
6065
  const { t } = useTranslation();
6066
+ const openLabel = t("BiChat.Artifacts.OpenInNewTab");
6067
+ const downloadLabel = t("BiChat.Artifacts.Download");
6065
6068
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6066
6069
  /* @__PURE__ */ jsxs(
6067
6070
  "a",
@@ -6072,7 +6075,7 @@ function ArtifactActions({ url }) {
6072
6075
  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",
6073
6076
  children: [
6074
6077
  /* @__PURE__ */ jsx(ArrowSquareOut, { className: "h-3.5 w-3.5", weight: "bold" }),
6075
- t("BiChat.Artifacts.OpenInNewTab")
6078
+ openLabel
6076
6079
  ]
6077
6080
  }
6078
6081
  ),
@@ -6086,7 +6089,7 @@ function ArtifactActions({ url }) {
6086
6089
  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",
6087
6090
  children: [
6088
6091
  /* @__PURE__ */ jsx(DownloadSimple, { className: "h-3.5 w-3.5", weight: "bold" }),
6089
- t("BiChat.Artifacts.Download")
6092
+ downloadLabel
6090
6093
  ]
6091
6094
  }
6092
6095
  )
@@ -7406,6 +7409,7 @@ var EditableText = forwardRef(
7406
7409
  setIsEditing(false);
7407
7410
  };
7408
7411
  const handleKeyDown = (e) => {
7412
+ e.stopPropagation();
7409
7413
  if (e.key === "Enter") {
7410
7414
  e.preventDefault();
7411
7415
  handleSave();
@@ -7439,6 +7443,7 @@ var EditableText = forwardRef(
7439
7443
  value: editValue,
7440
7444
  onChange: (e) => setEditValue(e.target.value),
7441
7445
  onKeyDown: handleKeyDown,
7446
+ onKeyUp: (e) => e.stopPropagation(),
7442
7447
  onBlur: handleBlur,
7443
7448
  maxLength,
7444
7449
  placeholder: resolvedPlaceholder,
@@ -8485,6 +8490,9 @@ var SessionItem = memo(
8485
8490
  onSelect(session.id);
8486
8491
  },
8487
8492
  onKeyDown: (e) => {
8493
+ const target = e.target;
8494
+ const isFromEditable = !!target?.closest('input, textarea, [contenteditable="true"]');
8495
+ if (isFromEditable) return;
8488
8496
  if (e.key === "Enter" || e.key === " ") {
8489
8497
  e.preventDefault();
8490
8498
  onSelect(session.id);
@@ -9243,6 +9251,15 @@ function Sidebar2({
9243
9251
  useEffect(() => {
9244
9252
  fetchSessions();
9245
9253
  }, [fetchSessions, refreshKey]);
9254
+ useEffect(() => {
9255
+ const handleSessionsUpdated = () => {
9256
+ setRefreshKey((k) => k + 1);
9257
+ };
9258
+ window.addEventListener("bichat:sessions-updated", handleSessionsUpdated);
9259
+ return () => {
9260
+ window.removeEventListener("bichat:sessions-updated", handleSessionsUpdated);
9261
+ };
9262
+ }, []);
9246
9263
  useEffect(() => {
9247
9264
  if (!activeSessionId) {
9248
9265
  refreshForActiveSessionRef.current = null;
@@ -9617,13 +9634,14 @@ function Sidebar2({
9617
9634
  anchor: "top start",
9618
9635
  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",
9619
9636
  children: [
9620
- onArchivedView && /* @__PURE__ */ jsx(MenuItem, { children: ({ focus }) => /* @__PURE__ */ jsxs(
9637
+ onArchivedView && /* @__PURE__ */ jsx(MenuItem, { children: ({ focus, close }) => /* @__PURE__ */ jsxs(
9621
9638
  "button",
9622
9639
  {
9623
9640
  onClick: (e) => {
9624
9641
  e.preventDefault();
9625
9642
  e.stopPropagation();
9626
9643
  onArchivedView();
9644
+ close();
9627
9645
  },
9628
9646
  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" : ""}`,
9629
9647
  "aria-label": t("BiChat.Sidebar.ArchivedChats"),
@@ -9633,13 +9651,14 @@ function Sidebar2({
9633
9651
  ]
9634
9652
  }
9635
9653
  ) }),
9636
- showAllChatsTab && activeTab !== "all-chats" && /* @__PURE__ */ jsx(MenuItem, { children: ({ focus }) => /* @__PURE__ */ jsxs(
9654
+ showAllChatsTab && activeTab !== "all-chats" && /* @__PURE__ */ jsx(MenuItem, { children: ({ focus, close }) => /* @__PURE__ */ jsxs(
9637
9655
  "button",
9638
9656
  {
9639
9657
  onClick: (e) => {
9640
9658
  e.preventDefault();
9641
9659
  e.stopPropagation();
9642
9660
  setActiveTab("all-chats");
9661
+ close();
9643
9662
  },
9644
9663
  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" : ""}`,
9645
9664
  "aria-label": t("BiChat.Sidebar.AllChats"),
@@ -9649,13 +9668,14 @@ function Sidebar2({
9649
9668
  ]
9650
9669
  }
9651
9670
  ) }),
9652
- showAllChatsTab && activeTab === "all-chats" && /* @__PURE__ */ jsx(MenuItem, { children: ({ focus }) => /* @__PURE__ */ jsxs(
9671
+ showAllChatsTab && activeTab === "all-chats" && /* @__PURE__ */ jsx(MenuItem, { children: ({ focus, close }) => /* @__PURE__ */ jsxs(
9653
9672
  "button",
9654
9673
  {
9655
9674
  onClick: (e) => {
9656
9675
  e.preventDefault();
9657
9676
  e.stopPropagation();
9658
9677
  setActiveTab("my-chats");
9678
+ close();
9659
9679
  },
9660
9680
  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" : ""}`,
9661
9681
  "aria-label": t("BiChat.Sidebar.MyChats"),
@@ -9770,7 +9790,11 @@ function ArchivedChatList({
9770
9790
  const confirmRestore = async () => {
9771
9791
  if (!sessionToRestore) return;
9772
9792
  try {
9773
- await dataSource.unarchiveSession(sessionToRestore);
9793
+ const restoredSessionID = sessionToRestore;
9794
+ await dataSource.unarchiveSession(restoredSessionID);
9795
+ window.dispatchEvent(new CustomEvent("bichat:sessions-updated", {
9796
+ detail: { reason: "restored", sessionId: restoredSessionID }
9797
+ }));
9774
9798
  setRefreshKey((k) => k + 1);
9775
9799
  toast.success(t("BiChat.Archived.ChatRestoredSuccessfully"));
9776
9800
  } catch (err) {
@@ -12252,7 +12276,7 @@ var HttpDataSource = class {
12252
12276
  this.abortController = null;
12253
12277
  this.config = {
12254
12278
  streamEndpoint: "/stream",
12255
- timeout: 3e4,
12279
+ timeout: 12e4,
12256
12280
  ...config
12257
12281
  };
12258
12282
  if (config.navigateToSession) {