@arbidocs/react 0.3.146 → 0.3.148

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/dist/index.cjs CHANGED
@@ -600,8 +600,7 @@ var arbiQueryKeys = {
600
600
  projects: () => ["arbi", "projects"],
601
601
  projectUsage: (projectExtId, monthsBack) => ["arbi", "projectUsage", projectExtId, monthsBack],
602
602
  projectInvoices: (projectExtId) => ["arbi", "projectInvoices", projectExtId],
603
- userUsageToday: () => ["arbi", "userUsageToday"],
604
- workspaceChronology: (workspaceId) => ["arbi", "workspaceChronology", workspaceId]
603
+ userUsageToday: () => ["arbi", "userUsageToday"]
605
604
  };
606
605
  function useWorkspaces(options) {
607
606
  const arbi = chunkZMTLGO3K_cjs.useArbi();
@@ -817,14 +816,6 @@ function useUserUsageToday(options) {
817
816
  enabled: options?.enabled ?? arbi.isLoggedIn
818
817
  });
819
818
  }
820
- function useWorkspaceChronology(workspaceId, options) {
821
- const arbi = chunkZMTLGO3K_cjs.useArbi();
822
- return reactQuery.useQuery({
823
- queryKey: arbiQueryKeys.workspaceChronology(workspaceId ?? ""),
824
- queryFn: () => arbi.workspaces.chronology(workspaceId),
825
- enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
826
- });
827
- }
828
819
  function WorkspaceScreen({ theme, labels, onSelect }) {
829
820
  const arbi = chunkZMTLGO3K_cjs.useArbi();
830
821
  const { data: workspaces, isLoading } = useWorkspaces();
@@ -2710,6 +2701,79 @@ function DocumentReview({
2710
2701
  }
2711
2702
  );
2712
2703
  }
2704
+ var TIERS = [
2705
+ { min: 0.7, tone: "bg-emerald-500", label: "High relevance" },
2706
+ { min: 0.4, tone: "bg-amber-500", label: "Medium relevance" },
2707
+ { min: -Infinity, tone: "bg-muted-foreground/40", label: "Low relevance" }
2708
+ ];
2709
+ function RelevanceDot({ score }) {
2710
+ if (score == null) return null;
2711
+ const tier = TIERS.find((t) => score >= t.min) ?? TIERS[TIERS.length - 1];
2712
+ return /* @__PURE__ */ jsxRuntime.jsx(
2713
+ "span",
2714
+ {
2715
+ role: "img",
2716
+ "aria-label": tier.label,
2717
+ title: `${tier.label} (${score.toFixed(2)})`,
2718
+ className: chunkZBZKHBDS_cjs.cn("size-1.5 shrink-0 rounded-full", tier.tone),
2719
+ "data-testid": "passage-relevance"
2720
+ }
2721
+ );
2722
+ }
2723
+ function PassageCard({
2724
+ header,
2725
+ score,
2726
+ headerRight,
2727
+ active,
2728
+ onClick,
2729
+ footer,
2730
+ className,
2731
+ children,
2732
+ "data-testid": testId
2733
+ }) {
2734
+ const body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2735
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-1.5 flex items-center gap-2", children: [
2736
+ header,
2737
+ (score != null || headerRight) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-2", children: [
2738
+ /* @__PURE__ */ jsxRuntime.jsx(RelevanceDot, { score }),
2739
+ headerRight
2740
+ ] })
2741
+ ] }),
2742
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "[&_mark]:rounded-sm [&_mark]:bg-ai-accent/20 [&_mark]:px-0.5 [&_mark]:font-medium [&_mark]:text-foreground", children })
2743
+ ] });
2744
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2745
+ "div",
2746
+ {
2747
+ className: chunkZBZKHBDS_cjs.cn(
2748
+ "group rounded-lg border border-border bg-card p-3 text-left transition-colors",
2749
+ onClick && "hover:border-ai-accent/40 focus-within:ring-2 focus-within:ring-ai-accent/40",
2750
+ active && "border-ai-accent/60 ring-1 ring-ai-accent/30",
2751
+ className
2752
+ ),
2753
+ children: [
2754
+ onClick ? /* @__PURE__ */ jsxRuntime.jsx(
2755
+ "div",
2756
+ {
2757
+ role: "button",
2758
+ tabIndex: 0,
2759
+ onClick,
2760
+ onKeyDown: (e) => {
2761
+ if (e.key === "Enter" || e.key === " ") {
2762
+ e.preventDefault();
2763
+ onClick(e);
2764
+ }
2765
+ },
2766
+ "aria-current": active || void 0,
2767
+ "data-testid": testId,
2768
+ className: "cursor-pointer focus:outline-none",
2769
+ children: body
2770
+ }
2771
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-current": active || void 0, "data-testid": testId, children: body }),
2772
+ footer
2773
+ ]
2774
+ }
2775
+ );
2776
+ }
2713
2777
  function queryTerms(query) {
2714
2778
  const terms = /* @__PURE__ */ new Set();
2715
2779
  for (const phrase of query.match(/"([^"]+)"/g) ?? []) {
@@ -2726,20 +2790,10 @@ function HighlightedSnippet({ text, terms }) {
2726
2790
  if (terms.length === 0) return [text];
2727
2791
  const escaped = terms.map((t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
2728
2792
  const re = new RegExp(`(${escaped.join("|")})`, "gi");
2729
- return text.split(re).map(
2730
- (part, i) => i % 2 === 1 ? /* @__PURE__ */ jsxRuntime.jsx("mark", { className: "rounded-sm bg-ai-accent/20 px-0.5 text-foreground", children: part }, i) : part
2731
- );
2793
+ return text.split(re).map((part, i) => i % 2 === 1 ? /* @__PURE__ */ jsxRuntime.jsx("mark", { children: part }, i) : part);
2732
2794
  }, [text, terms]);
2733
2795
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: nodes });
2734
2796
  }
2735
- function RelevanceDot({ score }) {
2736
- if (score == null) return null;
2737
- const tone = score >= 0.7 ? "bg-emerald-500" : score >= 0.4 ? "bg-amber-500" : "bg-muted-foreground/40";
2738
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-auto inline-flex items-center gap-1.5 text-[10px] text-muted-foreground", children: [
2739
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkZBZKHBDS_cjs.cn("size-1.5 rounded-full", tone), "aria-hidden": true }),
2740
- score.toFixed(2)
2741
- ] });
2742
- }
2743
2797
  function ResultRow({
2744
2798
  result,
2745
2799
  index,
@@ -2747,34 +2801,26 @@ function ResultRow({
2747
2801
  isActive,
2748
2802
  onSelect
2749
2803
  }) {
2750
- return /* @__PURE__ */ jsxRuntime.jsxs(
2751
- "button",
2804
+ return /* @__PURE__ */ jsxRuntime.jsx(
2805
+ PassageCard,
2752
2806
  {
2753
- type: "button",
2754
2807
  onClick: onSelect,
2808
+ active: isActive,
2809
+ score: result.score,
2755
2810
  "data-testid": `arbi-semantic-search-result-${index}`,
2756
- "aria-current": isActive,
2757
- className: chunkZBZKHBDS_cjs.cn(
2758
- "w-full rounded-lg border border-border bg-card p-3 text-left transition-colors",
2759
- "hover:border-ai-accent/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-ai-accent/40",
2760
- isActive && "border-ai-accent/60 ring-1 ring-ai-accent/30"
2761
- ),
2762
- children: [
2763
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-1 flex items-center gap-2", children: [
2764
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "size-3.5 shrink-0 text-ai-accent" }),
2765
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs font-medium text-foreground", children: result.docTitle ?? "Document" }),
2766
- result.page != null && /* @__PURE__ */ jsxRuntime.jsxs(chunkZBZKHBDS_cjs.Badge, { variant: "secondary", children: [
2767
- "p.",
2768
- result.page
2769
- ] }),
2770
- /* @__PURE__ */ jsxRuntime.jsx(RelevanceDot, { score: result.score })
2771
- ] }),
2772
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "line-clamp-3 text-xs leading-relaxed text-muted-foreground", children: [
2773
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground/60", children: "\u2026 " }),
2774
- /* @__PURE__ */ jsxRuntime.jsx(HighlightedSnippet, { text: result.content, terms }),
2775
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground/60", children: " \u2026" })
2811
+ header: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2812
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "size-3.5 shrink-0 text-ai-accent" }),
2813
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs font-medium text-foreground", children: result.docTitle ?? "Document" }),
2814
+ result.page != null && /* @__PURE__ */ jsxRuntime.jsxs(chunkZBZKHBDS_cjs.Badge, { variant: "secondary", children: [
2815
+ "p.",
2816
+ result.page
2776
2817
  ] })
2777
- ]
2818
+ ] }),
2819
+ children: /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "line-clamp-3 text-xs leading-relaxed text-muted-foreground", children: [
2820
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground/60", children: "\u2026 " }),
2821
+ /* @__PURE__ */ jsxRuntime.jsx(HighlightedSnippet, { text: result.content, terms }),
2822
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground/60", children: " \u2026" })
2823
+ ] })
2778
2824
  }
2779
2825
  );
2780
2826
  }
@@ -7250,10 +7296,12 @@ exports.NEUTRAL_GRAY = NEUTRAL_GRAY2;
7250
7296
  exports.NotificationBell = NotificationBell;
7251
7297
  exports.OpenAIIcon = OpenAIIcon;
7252
7298
  exports.PLACEHOLDER_COLOR = PLACEHOLDER_COLOR;
7299
+ exports.PassageCard = PassageCard;
7253
7300
  exports.PdfIcon = PdfIcon;
7254
7301
  exports.ProjectEntity = ProjectEntity;
7255
7302
  exports.ProviderIcon = ProviderIcon;
7256
7303
  exports.RagDot = RagDot;
7304
+ exports.RelevanceDot = RelevanceDot;
7257
7305
  exports.SemanticSearch = SemanticSearch;
7258
7306
  exports.StatusPill = StatusPill;
7259
7307
  exports.TAG_TYPE_ICONS = TAG_TYPE_ICONS;
@@ -7328,7 +7376,6 @@ exports.useTags = useTags;
7328
7376
  exports.useTasks = useTasks;
7329
7377
  exports.useThumbnails = useThumbnails;
7330
7378
  exports.useUserUsageToday = useUserUsageToday;
7331
- exports.useWorkspaceChronology = useWorkspaceChronology;
7332
7379
  exports.useWorkspaceDocs = useWorkspaceDocs;
7333
7380
  exports.useWorkspaces = useWorkspaces;
7334
7381
  exports.userDisplayName = userDisplayName;