@open-mercato/search 0.6.2-develop.3366.1.4692954e44 → 0.6.2-develop.3373.1.be847b1058
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/.turbo/turbo-build.log +1 -1
- package/dist/modules/search/frontend/components/TopbarSearchInline.js +455 -0
- package/dist/modules/search/frontend/components/TopbarSearchInline.js.map +7 -0
- package/dist/modules/search/frontend/index.js +3 -1
- package/dist/modules/search/frontend/index.js.map +2 -2
- package/dist/modules/search/i18n/de.json +2 -0
- package/dist/modules/search/i18n/en.json +2 -0
- package/dist/modules/search/i18n/es.json +2 -0
- package/dist/modules/search/i18n/pl.json +2 -0
- package/package.json +4 -4
- package/src/modules/search/frontend/components/TopbarSearchInline.tsx +518 -0
- package/src/modules/search/frontend/index.ts +1 -0
- package/src/modules/search/i18n/de.json +2 -0
- package/src/modules/search/i18n/en.json +2 -0
- package/src/modules/search/i18n/es.json +2 -0
- package/src/modules/search/i18n/pl.json +2 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[build:search] found
|
|
1
|
+
[build:search] found 81 entry points
|
|
2
2
|
[build:search] built successfully
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import NextLink from "next/link";
|
|
5
|
+
import { useRouter } from "next/navigation";
|
|
6
|
+
import {
|
|
7
|
+
Search,
|
|
8
|
+
Loader2,
|
|
9
|
+
Zap,
|
|
10
|
+
User,
|
|
11
|
+
Users,
|
|
12
|
+
Building,
|
|
13
|
+
StickyNote,
|
|
14
|
+
Briefcase,
|
|
15
|
+
CheckSquare,
|
|
16
|
+
FileText,
|
|
17
|
+
Mail,
|
|
18
|
+
Phone,
|
|
19
|
+
Calendar,
|
|
20
|
+
Clock,
|
|
21
|
+
Star,
|
|
22
|
+
Tag,
|
|
23
|
+
Flag,
|
|
24
|
+
Heart,
|
|
25
|
+
Bookmark,
|
|
26
|
+
Package,
|
|
27
|
+
Truck,
|
|
28
|
+
ShoppingCart,
|
|
29
|
+
CreditCard,
|
|
30
|
+
DollarSign,
|
|
31
|
+
Target,
|
|
32
|
+
Award,
|
|
33
|
+
Trophy,
|
|
34
|
+
Rocket,
|
|
35
|
+
Lightbulb,
|
|
36
|
+
MessageSquare,
|
|
37
|
+
Bell,
|
|
38
|
+
Settings,
|
|
39
|
+
Globe,
|
|
40
|
+
MapPin,
|
|
41
|
+
Link as LinkIcon,
|
|
42
|
+
Folder,
|
|
43
|
+
Database,
|
|
44
|
+
Activity,
|
|
45
|
+
X
|
|
46
|
+
} from "lucide-react";
|
|
47
|
+
import { cn } from "@open-mercato/shared/lib/utils";
|
|
48
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
49
|
+
import {
|
|
50
|
+
getCurrentOrganizationScope,
|
|
51
|
+
subscribeOrganizationScopeChanged
|
|
52
|
+
} from "@open-mercato/shared/lib/frontend/organizationEvents";
|
|
53
|
+
import { isAllOrganizationsSelection } from "@open-mercato/core/modules/directory/constants";
|
|
54
|
+
import { parseSelectedOrganizationCookie } from "@open-mercato/core/modules/directory/utils/scopeCookies";
|
|
55
|
+
import { ForbiddenError } from "@open-mercato/ui/backend/utils/api";
|
|
56
|
+
import { IconButton } from "@open-mercato/ui/primitives/icon-button";
|
|
57
|
+
import { resolveSearchMinTokenLength } from "@open-mercato/shared/lib/search/config";
|
|
58
|
+
import { fetchGlobalSearchResults } from "../utils.js";
|
|
59
|
+
const MIN_QUERY_LENGTH = resolveSearchMinTokenLength();
|
|
60
|
+
function normalizeLinks(links) {
|
|
61
|
+
if (!Array.isArray(links)) return [];
|
|
62
|
+
return links.filter((link) => typeof link?.href === "string");
|
|
63
|
+
}
|
|
64
|
+
function pickPrimaryLink(result) {
|
|
65
|
+
if (result.url) return result.url;
|
|
66
|
+
const links = normalizeLinks(result.links);
|
|
67
|
+
if (!links.length) return null;
|
|
68
|
+
const primary = links.find((link) => link.kind === "primary");
|
|
69
|
+
return (primary ?? links[0]).href;
|
|
70
|
+
}
|
|
71
|
+
function hasActiveOrganizationSelection() {
|
|
72
|
+
const fromEvent = getCurrentOrganizationScope().organizationId;
|
|
73
|
+
if (typeof fromEvent === "string" && fromEvent.trim().length > 0) return true;
|
|
74
|
+
const cookieHeader = typeof document === "undefined" ? null : document.cookie;
|
|
75
|
+
const cookieValue = parseSelectedOrganizationCookie(cookieHeader);
|
|
76
|
+
if (!cookieValue) return false;
|
|
77
|
+
return !isAllOrganizationsSelection(cookieValue);
|
|
78
|
+
}
|
|
79
|
+
function humanizeSegment(segment) {
|
|
80
|
+
return segment.split(/[_-]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
81
|
+
}
|
|
82
|
+
const ICON_MAP = {
|
|
83
|
+
bolt: Zap,
|
|
84
|
+
zap: Zap,
|
|
85
|
+
user: User,
|
|
86
|
+
users: Users,
|
|
87
|
+
building: Building,
|
|
88
|
+
"sticky-note": StickyNote,
|
|
89
|
+
briefcase: Briefcase,
|
|
90
|
+
"check-square": CheckSquare,
|
|
91
|
+
"file-text": FileText,
|
|
92
|
+
mail: Mail,
|
|
93
|
+
phone: Phone,
|
|
94
|
+
calendar: Calendar,
|
|
95
|
+
clock: Clock,
|
|
96
|
+
star: Star,
|
|
97
|
+
tag: Tag,
|
|
98
|
+
flag: Flag,
|
|
99
|
+
heart: Heart,
|
|
100
|
+
bookmark: Bookmark,
|
|
101
|
+
package: Package,
|
|
102
|
+
truck: Truck,
|
|
103
|
+
"shopping-cart": ShoppingCart,
|
|
104
|
+
"credit-card": CreditCard,
|
|
105
|
+
"dollar-sign": DollarSign,
|
|
106
|
+
target: Target,
|
|
107
|
+
award: Award,
|
|
108
|
+
trophy: Trophy,
|
|
109
|
+
rocket: Rocket,
|
|
110
|
+
lightbulb: Lightbulb,
|
|
111
|
+
"message-square": MessageSquare,
|
|
112
|
+
bell: Bell,
|
|
113
|
+
settings: Settings,
|
|
114
|
+
globe: Globe,
|
|
115
|
+
"map-pin": MapPin,
|
|
116
|
+
link: LinkIcon,
|
|
117
|
+
folder: Folder,
|
|
118
|
+
database: Database,
|
|
119
|
+
activity: Activity
|
|
120
|
+
};
|
|
121
|
+
function resolveIcon(name) {
|
|
122
|
+
if (!name) return null;
|
|
123
|
+
return ICON_MAP[name.toLowerCase()] ?? null;
|
|
124
|
+
}
|
|
125
|
+
function formatEntityId(entityId) {
|
|
126
|
+
if (!entityId.includes(":")) return humanizeSegment(entityId);
|
|
127
|
+
const [module, entity] = entityId.split(":");
|
|
128
|
+
return `${humanizeSegment(module)} \xB7 ${humanizeSegment(entity)}`;
|
|
129
|
+
}
|
|
130
|
+
function TopbarSearchInline({
|
|
131
|
+
embeddingConfigured,
|
|
132
|
+
missingConfigMessage
|
|
133
|
+
}) {
|
|
134
|
+
const router = useRouter();
|
|
135
|
+
const t = useT();
|
|
136
|
+
const [query, setQuery] = React.useState("");
|
|
137
|
+
const [results, setResults] = React.useState([]);
|
|
138
|
+
const [loading, setLoading] = React.useState(false);
|
|
139
|
+
const [error, setError] = React.useState(null);
|
|
140
|
+
const [open, setOpen] = React.useState(false);
|
|
141
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
142
|
+
const [selectedIndex, setSelectedIndex] = React.useState(0);
|
|
143
|
+
const [showScopeHint, setShowScopeHint] = React.useState(() => hasActiveOrganizationSelection());
|
|
144
|
+
const inputRef = React.useRef(null);
|
|
145
|
+
const popoverRef = React.useRef(null);
|
|
146
|
+
const containerRef = React.useRef(null);
|
|
147
|
+
const listRef = React.useRef(null);
|
|
148
|
+
const abortRef = React.useRef(null);
|
|
149
|
+
const expandAndFocus = React.useCallback(() => {
|
|
150
|
+
setExpanded(true);
|
|
151
|
+
requestAnimationFrame(() => {
|
|
152
|
+
inputRef.current?.focus();
|
|
153
|
+
inputRef.current?.select();
|
|
154
|
+
});
|
|
155
|
+
}, []);
|
|
156
|
+
const collapseAndReset = React.useCallback(() => {
|
|
157
|
+
setOpen(false);
|
|
158
|
+
setExpanded(false);
|
|
159
|
+
setQuery("");
|
|
160
|
+
inputRef.current?.blur();
|
|
161
|
+
}, []);
|
|
162
|
+
React.useEffect(() => {
|
|
163
|
+
setShowScopeHint(hasActiveOrganizationSelection());
|
|
164
|
+
return subscribeOrganizationScopeChanged((detail) => {
|
|
165
|
+
setShowScopeHint(Boolean(detail.organizationId && detail.organizationId.trim().length > 0));
|
|
166
|
+
});
|
|
167
|
+
}, []);
|
|
168
|
+
React.useEffect(() => {
|
|
169
|
+
const handler = (event) => {
|
|
170
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
expandAndFocus();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
window.addEventListener("keydown", handler);
|
|
176
|
+
return () => window.removeEventListener("keydown", handler);
|
|
177
|
+
}, [expandAndFocus]);
|
|
178
|
+
React.useEffect(() => {
|
|
179
|
+
if (!expanded) return;
|
|
180
|
+
const handler = (event) => {
|
|
181
|
+
const target = event.target;
|
|
182
|
+
if (!target) return;
|
|
183
|
+
if (containerRef.current?.contains(target)) return;
|
|
184
|
+
if (popoverRef.current?.contains(target)) return;
|
|
185
|
+
collapseAndReset();
|
|
186
|
+
};
|
|
187
|
+
document.addEventListener("mousedown", handler);
|
|
188
|
+
return () => document.removeEventListener("mousedown", handler);
|
|
189
|
+
}, [expanded, collapseAndReset]);
|
|
190
|
+
React.useEffect(() => {
|
|
191
|
+
abortRef.current?.abort();
|
|
192
|
+
const trimmed2 = query.trim();
|
|
193
|
+
if (trimmed2.length < MIN_QUERY_LENGTH) {
|
|
194
|
+
setResults([]);
|
|
195
|
+
setError(null);
|
|
196
|
+
setLoading(false);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const controller = new AbortController();
|
|
200
|
+
abortRef.current = controller;
|
|
201
|
+
setLoading(true);
|
|
202
|
+
const handle = setTimeout(async () => {
|
|
203
|
+
try {
|
|
204
|
+
const data = await fetchGlobalSearchResults(query, {
|
|
205
|
+
limit: 10,
|
|
206
|
+
signal: controller.signal
|
|
207
|
+
});
|
|
208
|
+
setResults(data.results);
|
|
209
|
+
setError(data.error ?? null);
|
|
210
|
+
setSelectedIndex(0);
|
|
211
|
+
} catch (err) {
|
|
212
|
+
if (controller.signal.aborted) return;
|
|
213
|
+
const abortError = err;
|
|
214
|
+
if (abortError?.name === "AbortError") return;
|
|
215
|
+
if (err instanceof ForbiddenError) {
|
|
216
|
+
setError(t("search.dialog.errors.noPermission"));
|
|
217
|
+
} else {
|
|
218
|
+
setError(err instanceof Error ? err.message : t("search.dialog.errors.searchFailed"));
|
|
219
|
+
}
|
|
220
|
+
setResults([]);
|
|
221
|
+
} finally {
|
|
222
|
+
if (!controller.signal.aborted) setLoading(false);
|
|
223
|
+
}
|
|
224
|
+
}, 220);
|
|
225
|
+
return () => {
|
|
226
|
+
clearTimeout(handle);
|
|
227
|
+
controller.abort();
|
|
228
|
+
};
|
|
229
|
+
}, [query, t]);
|
|
230
|
+
React.useEffect(() => {
|
|
231
|
+
const container = listRef.current;
|
|
232
|
+
const active = container?.querySelector('[data-active="true"]');
|
|
233
|
+
if (!container || !active) return;
|
|
234
|
+
const { top: containerTop, bottom: containerBottom } = container.getBoundingClientRect();
|
|
235
|
+
const { top: activeTop, bottom: activeBottom } = active.getBoundingClientRect();
|
|
236
|
+
if (activeTop < containerTop) {
|
|
237
|
+
container.scrollTop -= containerTop - activeTop;
|
|
238
|
+
} else if (activeBottom > containerBottom) {
|
|
239
|
+
container.scrollTop += activeBottom - containerBottom;
|
|
240
|
+
}
|
|
241
|
+
}, [selectedIndex]);
|
|
242
|
+
const openResult = React.useCallback(
|
|
243
|
+
(result) => {
|
|
244
|
+
if (!result) return;
|
|
245
|
+
const href = pickPrimaryLink(result);
|
|
246
|
+
if (!href) return;
|
|
247
|
+
router.push(href);
|
|
248
|
+
collapseAndReset();
|
|
249
|
+
},
|
|
250
|
+
[router, collapseAndReset]
|
|
251
|
+
);
|
|
252
|
+
const handleKeyDown = React.useCallback(
|
|
253
|
+
(event) => {
|
|
254
|
+
if (event.key === "ArrowDown") {
|
|
255
|
+
event.preventDefault();
|
|
256
|
+
if (!open) setOpen(true);
|
|
257
|
+
setSelectedIndex((prev) => results.length ? (prev + 1) % results.length : 0);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
if (event.key === "ArrowUp") {
|
|
261
|
+
event.preventDefault();
|
|
262
|
+
setSelectedIndex((prev) => {
|
|
263
|
+
if (!results.length) return 0;
|
|
264
|
+
return prev <= 0 ? results.length - 1 : prev - 1;
|
|
265
|
+
});
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (event.key === "Escape") {
|
|
269
|
+
event.preventDefault();
|
|
270
|
+
if (open) {
|
|
271
|
+
setOpen(false);
|
|
272
|
+
} else if (query) {
|
|
273
|
+
setQuery("");
|
|
274
|
+
} else {
|
|
275
|
+
collapseAndReset();
|
|
276
|
+
}
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (event.key === "Enter") {
|
|
280
|
+
event.preventDefault();
|
|
281
|
+
const target = results[selectedIndex];
|
|
282
|
+
openResult(target);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
[open, query, results, selectedIndex, openResult, collapseAndReset]
|
|
287
|
+
);
|
|
288
|
+
const showVectorWarning = !embeddingConfigured && !error;
|
|
289
|
+
const trimmed = query.trim();
|
|
290
|
+
const tooShort = trimmed.length > 0 && trimmed.length < MIN_QUERY_LENGTH;
|
|
291
|
+
const showPopover = open && (loading || results.length > 0 || error !== null || tooShort || showVectorWarning);
|
|
292
|
+
const showClear = query.length > 0;
|
|
293
|
+
if (!expanded) {
|
|
294
|
+
return /* @__PURE__ */ jsx(
|
|
295
|
+
"span",
|
|
296
|
+
{
|
|
297
|
+
ref: (el) => {
|
|
298
|
+
containerRef.current = el;
|
|
299
|
+
},
|
|
300
|
+
className: "inline-flex",
|
|
301
|
+
children: /* @__PURE__ */ jsx(
|
|
302
|
+
IconButton,
|
|
303
|
+
{
|
|
304
|
+
type: "button",
|
|
305
|
+
variant: "ghost",
|
|
306
|
+
size: "lg",
|
|
307
|
+
onClick: expandAndFocus,
|
|
308
|
+
"aria-label": t("search.dialog.actions.openGlobalSearch", "Open global search"),
|
|
309
|
+
title: t("search.dialog.actions.openGlobalSearch", "Open global search"),
|
|
310
|
+
children: /* @__PURE__ */ jsx(Search, { className: "size-4", "aria-hidden": "true" })
|
|
311
|
+
}
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
return /* @__PURE__ */ jsxs(
|
|
317
|
+
"div",
|
|
318
|
+
{
|
|
319
|
+
ref: (el) => {
|
|
320
|
+
containerRef.current = el;
|
|
321
|
+
},
|
|
322
|
+
"data-search-expanded": "true",
|
|
323
|
+
className: "relative min-w-0 sm:w-[260px] md:w-[320px] max-sm:absolute max-sm:inset-x-3 max-sm:top-1/2 max-sm:-translate-y-1/2 max-sm:z-popover",
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ jsxs(
|
|
326
|
+
"div",
|
|
327
|
+
{
|
|
328
|
+
className: cn(
|
|
329
|
+
"flex h-9 items-center gap-2 rounded-md border border-input bg-background px-3 text-sm shadow-xs transition-colors hover:bg-muted/40",
|
|
330
|
+
open ? "border-foreground bg-background shadow-focus" : ""
|
|
331
|
+
),
|
|
332
|
+
onClick: () => inputRef.current?.focus(),
|
|
333
|
+
children: [
|
|
334
|
+
/* @__PURE__ */ jsx(Search, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
335
|
+
/* @__PURE__ */ jsx(
|
|
336
|
+
"input",
|
|
337
|
+
{
|
|
338
|
+
ref: inputRef,
|
|
339
|
+
type: "text",
|
|
340
|
+
value: query,
|
|
341
|
+
onChange: (event) => {
|
|
342
|
+
setQuery(event.target.value);
|
|
343
|
+
if (!open) setOpen(true);
|
|
344
|
+
},
|
|
345
|
+
onFocus: () => setOpen(true),
|
|
346
|
+
onKeyDown: handleKeyDown,
|
|
347
|
+
placeholder: t("search.dialog.actions.search", "Search"),
|
|
348
|
+
"aria-label": t("search.dialog.actions.openGlobalSearch", "Search"),
|
|
349
|
+
"aria-autocomplete": "list",
|
|
350
|
+
"aria-expanded": open,
|
|
351
|
+
"aria-controls": "topbar-search-results",
|
|
352
|
+
className: "flex-1 min-w-0 bg-transparent placeholder:text-muted-foreground/70 focus:outline-none",
|
|
353
|
+
autoComplete: "off",
|
|
354
|
+
spellCheck: false
|
|
355
|
+
}
|
|
356
|
+
),
|
|
357
|
+
loading ? /* @__PURE__ */ jsx(Loader2, { className: "size-4 shrink-0 animate-spin text-muted-foreground", "aria-hidden": "true" }) : showClear ? /* @__PURE__ */ jsx(
|
|
358
|
+
"button",
|
|
359
|
+
{
|
|
360
|
+
type: "button",
|
|
361
|
+
onClick: (event) => {
|
|
362
|
+
event.stopPropagation();
|
|
363
|
+
setQuery("");
|
|
364
|
+
inputRef.current?.focus();
|
|
365
|
+
},
|
|
366
|
+
className: "rounded-sm p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
367
|
+
"aria-label": t("search.dialog.actions.clear", "Clear search"),
|
|
368
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-3.5", "aria-hidden": "true" })
|
|
369
|
+
}
|
|
370
|
+
) : /* @__PURE__ */ jsx("kbd", { className: "hidden md:inline-flex shrink-0 items-center rounded border bg-muted/50 px-1.5 text-overline font-medium uppercase tracking-wider text-muted-foreground", children: "\u2318K" })
|
|
371
|
+
]
|
|
372
|
+
}
|
|
373
|
+
),
|
|
374
|
+
showPopover ? /* @__PURE__ */ jsxs(
|
|
375
|
+
"div",
|
|
376
|
+
{
|
|
377
|
+
ref: popoverRef,
|
|
378
|
+
id: "topbar-search-results",
|
|
379
|
+
role: "listbox",
|
|
380
|
+
className: "absolute left-0 right-0 top-[calc(100%+4px)] z-popover min-w-[320px] rounded-md border bg-popover text-popover-foreground shadow-md",
|
|
381
|
+
children: [
|
|
382
|
+
error ? /* @__PURE__ */ jsx("p", { className: "border-b px-3 py-2 text-sm text-destructive", children: error }) : null,
|
|
383
|
+
showVectorWarning && !error ? /* @__PURE__ */ jsxs("div", { className: "border-b bg-status-warning-bg px-3 py-2 text-xs text-status-warning-text", children: [
|
|
384
|
+
/* @__PURE__ */ jsx("p", { children: missingConfigMessage }),
|
|
385
|
+
/* @__PURE__ */ jsx(
|
|
386
|
+
NextLink,
|
|
387
|
+
{
|
|
388
|
+
href: "/backend/config/search",
|
|
389
|
+
onClick: () => collapseAndReset(),
|
|
390
|
+
className: "mt-1 inline-flex items-center font-medium underline underline-offset-2 hover:no-underline",
|
|
391
|
+
children: t("search.dialog.warnings.configureLink", "Configure search settings")
|
|
392
|
+
}
|
|
393
|
+
)
|
|
394
|
+
] }) : null,
|
|
395
|
+
showScopeHint ? /* @__PURE__ */ jsx("p", { className: "border-b px-3 py-1.5 text-overline font-medium uppercase tracking-wider text-muted-foreground", children: t("search.scopeHint.currentOrg", "Scoped to current organization") }) : null,
|
|
396
|
+
tooShort && !error ? /* @__PURE__ */ jsx("div", { className: "px-3 py-3 text-sm text-muted-foreground", children: t("search.dialog.empty.hint", { count: MIN_QUERY_LENGTH }) }) : null,
|
|
397
|
+
!tooShort && results.length === 0 && !loading && !error ? /* @__PURE__ */ jsx("div", { className: "px-3 py-3 text-sm text-muted-foreground", children: t("search.dialog.empty.none", "No results") }) : null,
|
|
398
|
+
results.length > 0 ? /* @__PURE__ */ jsx("div", { ref: listRef, className: "max-h-[380px] overflow-y-auto p-1", children: results.map((result, index) => {
|
|
399
|
+
const presenter = result.presenter;
|
|
400
|
+
const isActive = index === selectedIndex;
|
|
401
|
+
const hasLink = pickPrimaryLink(result) !== null;
|
|
402
|
+
const Icon = presenter?.icon ? resolveIcon(presenter.icon) : null;
|
|
403
|
+
return /* @__PURE__ */ jsxs(
|
|
404
|
+
"button",
|
|
405
|
+
{
|
|
406
|
+
type: "button",
|
|
407
|
+
"data-active": isActive,
|
|
408
|
+
onClick: () => openResult(result),
|
|
409
|
+
onMouseEnter: () => setSelectedIndex(index),
|
|
410
|
+
role: "option",
|
|
411
|
+
"aria-selected": isActive,
|
|
412
|
+
className: cn(
|
|
413
|
+
"flex w-full items-start gap-3 rounded-sm px-2 py-2 text-left transition-colors",
|
|
414
|
+
isActive ? "bg-muted" : "hover:bg-muted/60",
|
|
415
|
+
!hasLink && "opacity-60"
|
|
416
|
+
),
|
|
417
|
+
children: [
|
|
418
|
+
Icon ? /* @__PURE__ */ jsx("span", { className: "mt-0.5 inline-flex size-7 shrink-0 items-center justify-center rounded-md border bg-background", children: /* @__PURE__ */ jsx(Icon, { className: "size-4 text-muted-foreground", "aria-hidden": "true" }) }) : /* @__PURE__ */ jsx("span", { className: "mt-0.5 inline-flex size-7 shrink-0 items-center justify-center rounded-md border bg-background", children: /* @__PURE__ */ jsx(FileText, { className: "size-4 text-muted-foreground", "aria-hidden": "true" }) }),
|
|
419
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
420
|
+
/* @__PURE__ */ jsx("span", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(
|
|
421
|
+
"span",
|
|
422
|
+
{
|
|
423
|
+
className: cn(
|
|
424
|
+
"truncate text-sm font-medium",
|
|
425
|
+
!hasLink ? "text-muted-foreground" : "text-foreground"
|
|
426
|
+
),
|
|
427
|
+
children: presenter?.title ?? result.recordId
|
|
428
|
+
}
|
|
429
|
+
) }),
|
|
430
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-overline text-muted-foreground", children: [
|
|
431
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: formatEntityId(result.entityId) }),
|
|
432
|
+
presenter?.subtitle ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
433
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\xB7" }),
|
|
434
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: presenter.subtitle })
|
|
435
|
+
] }) : null
|
|
436
|
+
] })
|
|
437
|
+
] })
|
|
438
|
+
]
|
|
439
|
+
},
|
|
440
|
+
`${result.entityId}:${result.recordId}`
|
|
441
|
+
);
|
|
442
|
+
}) }) : null
|
|
443
|
+
]
|
|
444
|
+
}
|
|
445
|
+
) : null
|
|
446
|
+
]
|
|
447
|
+
}
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
var TopbarSearchInline_default = TopbarSearchInline;
|
|
451
|
+
export {
|
|
452
|
+
TopbarSearchInline,
|
|
453
|
+
TopbarSearchInline_default as default
|
|
454
|
+
};
|
|
455
|
+
//# sourceMappingURL=TopbarSearchInline.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/search/frontend/components/TopbarSearchInline.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport NextLink from 'next/link'\nimport { useRouter } from 'next/navigation'\nimport {\n Search,\n Loader2,\n Zap,\n User,\n Users,\n Building,\n StickyNote,\n Briefcase,\n CheckSquare,\n FileText,\n Mail,\n Phone,\n Calendar,\n Clock,\n Star,\n Tag,\n Flag,\n Heart,\n Bookmark,\n Package,\n Truck,\n ShoppingCart,\n CreditCard,\n DollarSign,\n Target,\n Award,\n Trophy,\n Rocket,\n Lightbulb,\n MessageSquare,\n Bell,\n Settings,\n Globe,\n MapPin,\n Link as LinkIcon,\n Folder,\n Database,\n Activity,\n X,\n} from 'lucide-react'\nimport type { LucideIcon } from 'lucide-react'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport type { SearchResult, SearchResultLink } from '@open-mercato/shared/modules/search'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport {\n getCurrentOrganizationScope,\n subscribeOrganizationScopeChanged,\n} from '@open-mercato/shared/lib/frontend/organizationEvents'\nimport { isAllOrganizationsSelection } from '@open-mercato/core/modules/directory/constants'\nimport { parseSelectedOrganizationCookie } from '@open-mercato/core/modules/directory/utils/scopeCookies'\nimport { ForbiddenError } from '@open-mercato/ui/backend/utils/api'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { resolveSearchMinTokenLength } from '@open-mercato/shared/lib/search/config'\nimport { fetchGlobalSearchResults } from '../utils'\n\nconst MIN_QUERY_LENGTH = resolveSearchMinTokenLength()\n\nfunction normalizeLinks(links?: SearchResultLink[] | null): SearchResultLink[] {\n if (!Array.isArray(links)) return []\n return links.filter((link) => typeof link?.href === 'string')\n}\n\nfunction pickPrimaryLink(result: SearchResult): string | null {\n if (result.url) return result.url\n const links = normalizeLinks(result.links)\n if (!links.length) return null\n const primary = links.find((link) => link.kind === 'primary')\n return (primary ?? links[0]).href\n}\n\nfunction hasActiveOrganizationSelection(): boolean {\n const fromEvent = getCurrentOrganizationScope().organizationId\n if (typeof fromEvent === 'string' && fromEvent.trim().length > 0) return true\n const cookieHeader = typeof document === 'undefined' ? null : document.cookie\n const cookieValue = parseSelectedOrganizationCookie(cookieHeader)\n if (!cookieValue) return false\n return !isAllOrganizationsSelection(cookieValue)\n}\n\nfunction humanizeSegment(segment: string): string {\n return segment\n .split(/[_-]+/)\n .filter(Boolean)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(' ')\n}\n\nconst ICON_MAP: Record<string, LucideIcon> = {\n bolt: Zap,\n zap: Zap,\n user: User,\n users: Users,\n building: Building,\n 'sticky-note': StickyNote,\n briefcase: Briefcase,\n 'check-square': CheckSquare,\n 'file-text': FileText,\n mail: Mail,\n phone: Phone,\n calendar: Calendar,\n clock: Clock,\n star: Star,\n tag: Tag,\n flag: Flag,\n heart: Heart,\n bookmark: Bookmark,\n package: Package,\n truck: Truck,\n 'shopping-cart': ShoppingCart,\n 'credit-card': CreditCard,\n 'dollar-sign': DollarSign,\n target: Target,\n award: Award,\n trophy: Trophy,\n rocket: Rocket,\n lightbulb: Lightbulb,\n 'message-square': MessageSquare,\n bell: Bell,\n settings: Settings,\n globe: Globe,\n 'map-pin': MapPin,\n link: LinkIcon,\n folder: Folder,\n database: Database,\n activity: Activity,\n}\n\nfunction resolveIcon(name?: string): LucideIcon | null {\n if (!name) return null\n return ICON_MAP[name.toLowerCase()] ?? null\n}\n\nfunction formatEntityId(entityId: string): string {\n if (!entityId.includes(':')) return humanizeSegment(entityId)\n const [module, entity] = entityId.split(':')\n return `${humanizeSegment(module)} \u00B7 ${humanizeSegment(entity)}`\n}\n\nexport type TopbarSearchInlineProps = {\n /** Whether embedding provider is configured for vector search */\n embeddingConfigured: boolean\n /** Warning text to show when vector search is enabled but not configured */\n missingConfigMessage: string\n}\n\nexport function TopbarSearchInline({\n embeddingConfigured,\n missingConfigMessage,\n}: TopbarSearchInlineProps) {\n const router = useRouter()\n const t = useT()\n const [query, setQuery] = React.useState('')\n const [results, setResults] = React.useState<SearchResult[]>([])\n const [loading, setLoading] = React.useState(false)\n const [error, setError] = React.useState<string | null>(null)\n const [open, setOpen] = React.useState(false)\n const [expanded, setExpanded] = React.useState(false)\n const [selectedIndex, setSelectedIndex] = React.useState(0)\n const [showScopeHint, setShowScopeHint] = React.useState<boolean>(() => hasActiveOrganizationSelection())\n const inputRef = React.useRef<HTMLInputElement | null>(null)\n const popoverRef = React.useRef<HTMLDivElement | null>(null)\n const containerRef = React.useRef<HTMLElement | null>(null)\n const listRef = React.useRef<HTMLDivElement | null>(null)\n const abortRef = React.useRef<AbortController | null>(null)\n\n const expandAndFocus = React.useCallback(() => {\n setExpanded(true)\n // Wait one tick so the input is mounted/transitioned before focusing\n requestAnimationFrame(() => {\n inputRef.current?.focus()\n inputRef.current?.select()\n })\n }, [])\n\n const collapseAndReset = React.useCallback(() => {\n setOpen(false)\n setExpanded(false)\n setQuery('')\n inputRef.current?.blur()\n }, [])\n\n React.useEffect(() => {\n setShowScopeHint(hasActiveOrganizationSelection())\n return subscribeOrganizationScopeChanged((detail) => {\n setShowScopeHint(Boolean(detail.organizationId && detail.organizationId.trim().length > 0))\n })\n }, [])\n\n // Cmd/Ctrl+K expands + focuses the input\n React.useEffect(() => {\n const handler = (event: KeyboardEvent) => {\n if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'k') {\n event.preventDefault()\n expandAndFocus()\n }\n }\n window.addEventListener('keydown', handler)\n return () => window.removeEventListener('keydown', handler)\n }, [expandAndFocus])\n\n // Click outside closes the popover AND collapses input (unless user has typed something)\n React.useEffect(() => {\n if (!expanded) return\n const handler = (event: MouseEvent) => {\n const target = event.target as Node | null\n if (!target) return\n if (containerRef.current?.contains(target)) return\n if (popoverRef.current?.contains(target)) return\n collapseAndReset()\n }\n document.addEventListener('mousedown', handler)\n return () => document.removeEventListener('mousedown', handler)\n }, [expanded, collapseAndReset])\n\n // Fetch results on query change (debounced)\n React.useEffect(() => {\n abortRef.current?.abort()\n const trimmed = query.trim()\n if (trimmed.length < MIN_QUERY_LENGTH) {\n setResults([])\n setError(null)\n setLoading(false)\n return\n }\n\n const controller = new AbortController()\n abortRef.current = controller\n setLoading(true)\n\n const handle = setTimeout(async () => {\n try {\n const data = await fetchGlobalSearchResults(query, {\n limit: 10,\n signal: controller.signal,\n })\n setResults(data.results)\n setError(data.error ?? null)\n setSelectedIndex(0)\n } catch (err: unknown) {\n if (controller.signal.aborted) return\n const abortError = err as { name?: string }\n if (abortError?.name === 'AbortError') return\n if (err instanceof ForbiddenError) {\n setError(t('search.dialog.errors.noPermission'))\n } else {\n setError(err instanceof Error ? err.message : t('search.dialog.errors.searchFailed'))\n }\n setResults([])\n } finally {\n if (!controller.signal.aborted) setLoading(false)\n }\n }, 220)\n\n return () => {\n clearTimeout(handle)\n controller.abort()\n }\n }, [query, t])\n\n // Auto-scroll active item into view\n React.useEffect(() => {\n const container = listRef.current\n const active = container?.querySelector<HTMLElement>('[data-active=\"true\"]')\n if (!container || !active) return\n const { top: containerTop, bottom: containerBottom } = container.getBoundingClientRect()\n const { top: activeTop, bottom: activeBottom } = active.getBoundingClientRect()\n if (activeTop < containerTop) {\n container.scrollTop -= containerTop - activeTop\n } else if (activeBottom > containerBottom) {\n container.scrollTop += activeBottom - containerBottom\n }\n }, [selectedIndex])\n\n const openResult = React.useCallback(\n (result: SearchResult | undefined) => {\n if (!result) return\n const href = pickPrimaryLink(result)\n if (!href) return\n router.push(href)\n collapseAndReset()\n },\n [router, collapseAndReset],\n )\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n if (!open) setOpen(true)\n setSelectedIndex((prev) => (results.length ? (prev + 1) % results.length : 0))\n return\n }\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n setSelectedIndex((prev) => {\n if (!results.length) return 0\n return prev <= 0 ? results.length - 1 : prev - 1\n })\n return\n }\n if (event.key === 'Escape') {\n event.preventDefault()\n if (open) {\n setOpen(false)\n } else if (query) {\n setQuery('')\n } else {\n collapseAndReset()\n }\n return\n }\n if (event.key === 'Enter') {\n event.preventDefault()\n const target = results[selectedIndex]\n openResult(target)\n return\n }\n },\n [open, query, results, selectedIndex, openResult, collapseAndReset],\n )\n\n const showVectorWarning = !embeddingConfigured && !error\n const trimmed = query.trim()\n const tooShort = trimmed.length > 0 && trimmed.length < MIN_QUERY_LENGTH\n const showPopover =\n open && (loading || results.length > 0 || error !== null || tooShort || showVectorWarning)\n const showClear = query.length > 0\n\n if (!expanded) {\n return (\n <span\n ref={(el) => {\n containerRef.current = el\n }}\n className=\"inline-flex\"\n >\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n size=\"lg\"\n onClick={expandAndFocus}\n aria-label={t('search.dialog.actions.openGlobalSearch', 'Open global search')}\n title={t('search.dialog.actions.openGlobalSearch', 'Open global search')}\n >\n <Search className=\"size-4\" aria-hidden=\"true\" />\n </IconButton>\n </span>\n )\n }\n\n return (\n <div\n ref={(el) => {\n containerRef.current = el\n }}\n data-search-expanded=\"true\"\n className=\"relative min-w-0 sm:w-[260px] md:w-[320px] max-sm:absolute max-sm:inset-x-3 max-sm:top-1/2 max-sm:-translate-y-1/2 max-sm:z-popover\"\n >\n <div\n className={cn(\n 'flex h-9 items-center gap-2 rounded-md border border-input bg-background px-3 text-sm shadow-xs transition-colors hover:bg-muted/40',\n open ? 'border-foreground bg-background shadow-focus' : '',\n )}\n onClick={() => inputRef.current?.focus()}\n >\n <Search className=\"size-4 shrink-0 text-muted-foreground\" aria-hidden=\"true\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={(event) => {\n setQuery(event.target.value)\n if (!open) setOpen(true)\n }}\n onFocus={() => setOpen(true)}\n onKeyDown={handleKeyDown}\n placeholder={t('search.dialog.actions.search', 'Search')}\n aria-label={t('search.dialog.actions.openGlobalSearch', 'Search')}\n aria-autocomplete=\"list\"\n aria-expanded={open}\n aria-controls=\"topbar-search-results\"\n className=\"flex-1 min-w-0 bg-transparent placeholder:text-muted-foreground/70 focus:outline-none\"\n // Inline search; no need for native browser autocomplete or autocapitalize\n autoComplete=\"off\"\n spellCheck={false}\n />\n {loading ? (\n <Loader2 className=\"size-4 shrink-0 animate-spin text-muted-foreground\" aria-hidden=\"true\" />\n ) : showClear ? (\n <button\n type=\"button\"\n onClick={(event) => {\n event.stopPropagation()\n setQuery('')\n inputRef.current?.focus()\n }}\n className=\"rounded-sm p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\"\n aria-label={t('search.dialog.actions.clear', 'Clear search')}\n >\n <X className=\"size-3.5\" aria-hidden=\"true\" />\n </button>\n ) : (\n <kbd className=\"hidden md:inline-flex shrink-0 items-center rounded border bg-muted/50 px-1.5 text-overline font-medium uppercase tracking-wider text-muted-foreground\">\n \u2318K\n </kbd>\n )}\n </div>\n\n {showPopover ? (\n <div\n ref={popoverRef}\n id=\"topbar-search-results\"\n role=\"listbox\"\n className=\"absolute left-0 right-0 top-[calc(100%+4px)] z-popover min-w-[320px] rounded-md border bg-popover text-popover-foreground shadow-md\"\n >\n {error ? (\n <p className=\"border-b px-3 py-2 text-sm text-destructive\">{error}</p>\n ) : null}\n {showVectorWarning && !error ? (\n <div className=\"border-b bg-status-warning-bg px-3 py-2 text-xs text-status-warning-text\">\n <p>{missingConfigMessage}</p>\n <NextLink\n href=\"/backend/config/search\"\n onClick={() => collapseAndReset()}\n className=\"mt-1 inline-flex items-center font-medium underline underline-offset-2 hover:no-underline\"\n >\n {t('search.dialog.warnings.configureLink', 'Configure search settings')}\n </NextLink>\n </div>\n ) : null}\n {showScopeHint ? (\n <p className=\"border-b px-3 py-1.5 text-overline font-medium uppercase tracking-wider text-muted-foreground\">\n {t('search.scopeHint.currentOrg', 'Scoped to current organization')}\n </p>\n ) : null}\n\n {tooShort && !error ? (\n <div className=\"px-3 py-3 text-sm text-muted-foreground\">\n {t('search.dialog.empty.hint', { count: MIN_QUERY_LENGTH })}\n </div>\n ) : null}\n\n {!tooShort && results.length === 0 && !loading && !error ? (\n <div className=\"px-3 py-3 text-sm text-muted-foreground\">\n {t('search.dialog.empty.none', 'No results')}\n </div>\n ) : null}\n\n {results.length > 0 ? (\n <div ref={listRef} className=\"max-h-[380px] overflow-y-auto p-1\">\n {results.map((result, index) => {\n const presenter = result.presenter\n const isActive = index === selectedIndex\n const hasLink = pickPrimaryLink(result) !== null\n const Icon = presenter?.icon ? resolveIcon(presenter.icon) : null\n return (\n <button\n key={`${result.entityId}:${result.recordId}`}\n type=\"button\"\n data-active={isActive}\n onClick={() => openResult(result)}\n onMouseEnter={() => setSelectedIndex(index)}\n role=\"option\"\n aria-selected={isActive}\n className={cn(\n 'flex w-full items-start gap-3 rounded-sm px-2 py-2 text-left transition-colors',\n isActive ? 'bg-muted' : 'hover:bg-muted/60',\n !hasLink && 'opacity-60',\n )}\n >\n {Icon ? (\n <span className=\"mt-0.5 inline-flex size-7 shrink-0 items-center justify-center rounded-md border bg-background\">\n <Icon className=\"size-4 text-muted-foreground\" aria-hidden=\"true\" />\n </span>\n ) : (\n <span className=\"mt-0.5 inline-flex size-7 shrink-0 items-center justify-center rounded-md border bg-background\">\n <FileText className=\"size-4 text-muted-foreground\" aria-hidden=\"true\" />\n </span>\n )}\n <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n <span className=\"flex items-center gap-2\">\n <span\n className={cn(\n 'truncate text-sm font-medium',\n !hasLink ? 'text-muted-foreground' : 'text-foreground',\n )}\n >\n {presenter?.title ?? result.recordId}\n </span>\n </span>\n <span className=\"flex items-center gap-2 text-overline text-muted-foreground\">\n <span className=\"truncate\">{formatEntityId(result.entityId)}</span>\n {presenter?.subtitle ? (\n <>\n <span aria-hidden=\"true\">\u00B7</span>\n <span className=\"truncate\">{presenter.subtitle}</span>\n </>\n ) : null}\n </span>\n </span>\n </button>\n )\n })}\n </div>\n ) : null}\n </div>\n ) : null}\n </div>\n )\n}\n\nexport default TopbarSearchInline\n"],
|
|
5
|
+
"mappings": ";AA8VU,SAqJgB,UArJhB,KAcJ,YAdI;AA5VV,YAAY,WAAW;AACvB,OAAO,cAAc;AACrB,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,UAAU;AAEnB,SAAS,YAAY;AACrB;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SAAS,OAAO;AAAA;AAAA,wBAC9B,GACF;AAAA,wBACA,qBAAC,UAAK,WAAU,+DACd;AAAA,8CAAC,UAAK,WAAU,YAAY,yBAAe,OAAO,QAAQ,GAAE;AAAA,0BAC3D,WAAW,WACV,iCACE;AAAA,gDAAC,UAAK,eAAY,QAAO,kBAAC;AAAA,4BAC1B,oBAAC,UAAK,WAAU,YAAY,oBAAU,UAAS;AAAA,6BACjD,IACE;AAAA,2BACN;AAAA,yBACF;AAAA;AAAA;AAAA,kBA1CK,GAAG,OAAO,QAAQ,IAAI,OAAO,QAAQ;AAAA,gBA2C5C;AAAA,cAEJ,CAAC,GACH,IACE;AAAA;AAAA;AAAA,QACN,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;AAEA,IAAO,6BAAQ;",
|
|
6
|
+
"names": ["trimmed"]
|
|
7
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { GlobalSearchDialog } from "./components/GlobalSearchDialog.js";
|
|
2
|
+
import { TopbarSearchInline } from "./components/TopbarSearchInline.js";
|
|
2
3
|
import { SearchSettingsPageClient } from "./components/SearchSettingsPageClient.js";
|
|
3
4
|
import { HybridSearchTable } from "./components/HybridSearchTable.js";
|
|
4
5
|
export {
|
|
5
6
|
GlobalSearchDialog,
|
|
6
7
|
HybridSearchTable,
|
|
7
|
-
SearchSettingsPageClient
|
|
8
|
+
SearchSettingsPageClient,
|
|
9
|
+
TopbarSearchInline
|
|
8
10
|
};
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/search/frontend/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { GlobalSearchDialog } from './components/GlobalSearchDialog'\nexport { SearchSettingsPageClient } from './components/SearchSettingsPageClient'\nexport { HybridSearchTable } from './components/HybridSearchTable'\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,0BAA0B;AACnC,SAAS,gCAAgC;AACzC,SAAS,yBAAyB;",
|
|
4
|
+
"sourcesContent": ["export { GlobalSearchDialog } from './components/GlobalSearchDialog'\nexport { TopbarSearchInline } from './components/TopbarSearchInline'\nexport { SearchSettingsPageClient } from './components/SearchSettingsPageClient'\nexport { HybridSearchTable } from './components/HybridSearchTable'\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,gCAAgC;AACzC,SAAS,yBAAyB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"search.api.errors.vectorUnavailable": "Vektorsuche ist nicht verfügbar.",
|
|
23
23
|
"search.config.nav.hybridSearch": "Sucheinstellungen",
|
|
24
24
|
"search.dialog.actions.cancel": "Abbrechen (Esc)",
|
|
25
|
+
"search.dialog.actions.clear": "Suche löschen",
|
|
25
26
|
"search.dialog.actions.openGlobalSearch": "Globale Suche öffnen",
|
|
26
27
|
"search.dialog.actions.openSelected": "Öffnen (Enter)",
|
|
27
28
|
"search.dialog.actions.search": "Suchen",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"search.dialog.strategies.semanticDescription": "KI-gestützte bedeutungsbasierte Suche",
|
|
45
46
|
"search.dialog.strategies.toggle": "Suchoptionen",
|
|
46
47
|
"search.dialog.title": "Globale Suche",
|
|
48
|
+
"search.dialog.warnings.configureLink": "Sucheinstellungen konfigurieren",
|
|
47
49
|
"search.messages.missingConfig": "Die Suche erfordert die Konfiguration eines Embedding-Anbieters für die semantische Suche.",
|
|
48
50
|
"search.nav.hybridSearch": "Suche",
|
|
49
51
|
"search.scopeHint.currentOrg": "Bereich: aktuelle Organisation",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"search.api.errors.vectorUnavailable": "Vector search is unavailable.",
|
|
23
23
|
"search.config.nav.hybridSearch": "Search Settings",
|
|
24
24
|
"search.dialog.actions.cancel": "Cancel (Esc)",
|
|
25
|
+
"search.dialog.actions.clear": "Clear search",
|
|
25
26
|
"search.dialog.actions.openGlobalSearch": "Open global search",
|
|
26
27
|
"search.dialog.actions.openSelected": "Open (Enter)",
|
|
27
28
|
"search.dialog.actions.search": "Search",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"search.dialog.strategies.semanticDescription": "AI-powered meaning-based search",
|
|
45
46
|
"search.dialog.strategies.toggle": "Search options",
|
|
46
47
|
"search.dialog.title": "Global Search",
|
|
48
|
+
"search.dialog.warnings.configureLink": "Configure search settings",
|
|
47
49
|
"search.messages.missingConfig": "Search requires configuring an embedding provider for semantic search.",
|
|
48
50
|
"search.nav.hybridSearch": "Search",
|
|
49
51
|
"search.scopeHint.currentOrg": "Scoped to current organization",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"search.api.errors.vectorUnavailable": "La búsqueda vectorial no está disponible.",
|
|
23
23
|
"search.config.nav.hybridSearch": "Configuración de búsqueda",
|
|
24
24
|
"search.dialog.actions.cancel": "Cancelar (Esc)",
|
|
25
|
+
"search.dialog.actions.clear": "Limpiar búsqueda",
|
|
25
26
|
"search.dialog.actions.openGlobalSearch": "Abrir búsqueda global",
|
|
26
27
|
"search.dialog.actions.openSelected": "Abrir (Enter)",
|
|
27
28
|
"search.dialog.actions.search": "Buscar",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"search.dialog.strategies.semanticDescription": "Búsqueda basada en significado impulsada por IA",
|
|
45
46
|
"search.dialog.strategies.toggle": "Opciones de búsqueda",
|
|
46
47
|
"search.dialog.title": "Búsqueda Global",
|
|
48
|
+
"search.dialog.warnings.configureLink": "Configurar búsqueda",
|
|
47
49
|
"search.messages.missingConfig": "La búsqueda requiere configurar un proveedor de embeddings para la búsqueda semántica.",
|
|
48
50
|
"search.nav.hybridSearch": "Búsqueda",
|
|
49
51
|
"search.scopeHint.currentOrg": "Alcance: organización actual",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"search.api.errors.vectorUnavailable": "Wyszukiwanie wektorowe jest niedostępne.",
|
|
23
23
|
"search.config.nav.hybridSearch": "Ustawienia wyszukiwania",
|
|
24
24
|
"search.dialog.actions.cancel": "Anuluj (Esc)",
|
|
25
|
+
"search.dialog.actions.clear": "Wyczyść wyszukiwanie",
|
|
25
26
|
"search.dialog.actions.openGlobalSearch": "Otwórz globalne wyszukiwanie",
|
|
26
27
|
"search.dialog.actions.openSelected": "Otwórz (Enter)",
|
|
27
28
|
"search.dialog.actions.search": "Szukaj",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"search.dialog.strategies.semanticDescription": "Wyszukiwanie oparte na znaczeniu wspomagane AI",
|
|
45
46
|
"search.dialog.strategies.toggle": "Opcje wyszukiwania",
|
|
46
47
|
"search.dialog.title": "Globalne Wyszukiwanie",
|
|
48
|
+
"search.dialog.warnings.configureLink": "Skonfiguruj wyszukiwanie",
|
|
47
49
|
"search.messages.missingConfig": "Wyszukiwanie wymaga skonfigurowania dostawcy embeddingów dla wyszukiwania semantycznego.",
|
|
48
50
|
"search.nav.hybridSearch": "Wyszukiwanie",
|
|
49
51
|
"search.scopeHint.currentOrg": "Zakres: bieżąca organizacja",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/search",
|
|
3
|
-
"version": "0.6.2-develop.
|
|
3
|
+
"version": "0.6.2-develop.3373.1.be847b1058",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -126,9 +126,9 @@
|
|
|
126
126
|
"zod": "^4.3.6"
|
|
127
127
|
},
|
|
128
128
|
"peerDependencies": {
|
|
129
|
-
"@open-mercato/core": "0.6.2-develop.
|
|
130
|
-
"@open-mercato/queue": "0.6.2-develop.
|
|
131
|
-
"@open-mercato/shared": "0.6.2-develop.
|
|
129
|
+
"@open-mercato/core": "0.6.2-develop.3373.1.be847b1058",
|
|
130
|
+
"@open-mercato/queue": "0.6.2-develop.3373.1.be847b1058",
|
|
131
|
+
"@open-mercato/shared": "0.6.2-develop.3373.1.be847b1058"
|
|
132
132
|
},
|
|
133
133
|
"devDependencies": {
|
|
134
134
|
"@types/jest": "^30.0.0",
|
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import NextLink from 'next/link'
|
|
5
|
+
import { useRouter } from 'next/navigation'
|
|
6
|
+
import {
|
|
7
|
+
Search,
|
|
8
|
+
Loader2,
|
|
9
|
+
Zap,
|
|
10
|
+
User,
|
|
11
|
+
Users,
|
|
12
|
+
Building,
|
|
13
|
+
StickyNote,
|
|
14
|
+
Briefcase,
|
|
15
|
+
CheckSquare,
|
|
16
|
+
FileText,
|
|
17
|
+
Mail,
|
|
18
|
+
Phone,
|
|
19
|
+
Calendar,
|
|
20
|
+
Clock,
|
|
21
|
+
Star,
|
|
22
|
+
Tag,
|
|
23
|
+
Flag,
|
|
24
|
+
Heart,
|
|
25
|
+
Bookmark,
|
|
26
|
+
Package,
|
|
27
|
+
Truck,
|
|
28
|
+
ShoppingCart,
|
|
29
|
+
CreditCard,
|
|
30
|
+
DollarSign,
|
|
31
|
+
Target,
|
|
32
|
+
Award,
|
|
33
|
+
Trophy,
|
|
34
|
+
Rocket,
|
|
35
|
+
Lightbulb,
|
|
36
|
+
MessageSquare,
|
|
37
|
+
Bell,
|
|
38
|
+
Settings,
|
|
39
|
+
Globe,
|
|
40
|
+
MapPin,
|
|
41
|
+
Link as LinkIcon,
|
|
42
|
+
Folder,
|
|
43
|
+
Database,
|
|
44
|
+
Activity,
|
|
45
|
+
X,
|
|
46
|
+
} from 'lucide-react'
|
|
47
|
+
import type { LucideIcon } from 'lucide-react'
|
|
48
|
+
import { cn } from '@open-mercato/shared/lib/utils'
|
|
49
|
+
import type { SearchResult, SearchResultLink } from '@open-mercato/shared/modules/search'
|
|
50
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
51
|
+
import {
|
|
52
|
+
getCurrentOrganizationScope,
|
|
53
|
+
subscribeOrganizationScopeChanged,
|
|
54
|
+
} from '@open-mercato/shared/lib/frontend/organizationEvents'
|
|
55
|
+
import { isAllOrganizationsSelection } from '@open-mercato/core/modules/directory/constants'
|
|
56
|
+
import { parseSelectedOrganizationCookie } from '@open-mercato/core/modules/directory/utils/scopeCookies'
|
|
57
|
+
import { ForbiddenError } from '@open-mercato/ui/backend/utils/api'
|
|
58
|
+
import { IconButton } from '@open-mercato/ui/primitives/icon-button'
|
|
59
|
+
import { resolveSearchMinTokenLength } from '@open-mercato/shared/lib/search/config'
|
|
60
|
+
import { fetchGlobalSearchResults } from '../utils'
|
|
61
|
+
|
|
62
|
+
const MIN_QUERY_LENGTH = resolveSearchMinTokenLength()
|
|
63
|
+
|
|
64
|
+
function normalizeLinks(links?: SearchResultLink[] | null): SearchResultLink[] {
|
|
65
|
+
if (!Array.isArray(links)) return []
|
|
66
|
+
return links.filter((link) => typeof link?.href === 'string')
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function pickPrimaryLink(result: SearchResult): string | null {
|
|
70
|
+
if (result.url) return result.url
|
|
71
|
+
const links = normalizeLinks(result.links)
|
|
72
|
+
if (!links.length) return null
|
|
73
|
+
const primary = links.find((link) => link.kind === 'primary')
|
|
74
|
+
return (primary ?? links[0]).href
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function hasActiveOrganizationSelection(): boolean {
|
|
78
|
+
const fromEvent = getCurrentOrganizationScope().organizationId
|
|
79
|
+
if (typeof fromEvent === 'string' && fromEvent.trim().length > 0) return true
|
|
80
|
+
const cookieHeader = typeof document === 'undefined' ? null : document.cookie
|
|
81
|
+
const cookieValue = parseSelectedOrganizationCookie(cookieHeader)
|
|
82
|
+
if (!cookieValue) return false
|
|
83
|
+
return !isAllOrganizationsSelection(cookieValue)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function humanizeSegment(segment: string): string {
|
|
87
|
+
return segment
|
|
88
|
+
.split(/[_-]+/)
|
|
89
|
+
.filter(Boolean)
|
|
90
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
91
|
+
.join(' ')
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const ICON_MAP: Record<string, LucideIcon> = {
|
|
95
|
+
bolt: Zap,
|
|
96
|
+
zap: Zap,
|
|
97
|
+
user: User,
|
|
98
|
+
users: Users,
|
|
99
|
+
building: Building,
|
|
100
|
+
'sticky-note': StickyNote,
|
|
101
|
+
briefcase: Briefcase,
|
|
102
|
+
'check-square': CheckSquare,
|
|
103
|
+
'file-text': FileText,
|
|
104
|
+
mail: Mail,
|
|
105
|
+
phone: Phone,
|
|
106
|
+
calendar: Calendar,
|
|
107
|
+
clock: Clock,
|
|
108
|
+
star: Star,
|
|
109
|
+
tag: Tag,
|
|
110
|
+
flag: Flag,
|
|
111
|
+
heart: Heart,
|
|
112
|
+
bookmark: Bookmark,
|
|
113
|
+
package: Package,
|
|
114
|
+
truck: Truck,
|
|
115
|
+
'shopping-cart': ShoppingCart,
|
|
116
|
+
'credit-card': CreditCard,
|
|
117
|
+
'dollar-sign': DollarSign,
|
|
118
|
+
target: Target,
|
|
119
|
+
award: Award,
|
|
120
|
+
trophy: Trophy,
|
|
121
|
+
rocket: Rocket,
|
|
122
|
+
lightbulb: Lightbulb,
|
|
123
|
+
'message-square': MessageSquare,
|
|
124
|
+
bell: Bell,
|
|
125
|
+
settings: Settings,
|
|
126
|
+
globe: Globe,
|
|
127
|
+
'map-pin': MapPin,
|
|
128
|
+
link: LinkIcon,
|
|
129
|
+
folder: Folder,
|
|
130
|
+
database: Database,
|
|
131
|
+
activity: Activity,
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function resolveIcon(name?: string): LucideIcon | null {
|
|
135
|
+
if (!name) return null
|
|
136
|
+
return ICON_MAP[name.toLowerCase()] ?? null
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function formatEntityId(entityId: string): string {
|
|
140
|
+
if (!entityId.includes(':')) return humanizeSegment(entityId)
|
|
141
|
+
const [module, entity] = entityId.split(':')
|
|
142
|
+
return `${humanizeSegment(module)} · ${humanizeSegment(entity)}`
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type TopbarSearchInlineProps = {
|
|
146
|
+
/** Whether embedding provider is configured for vector search */
|
|
147
|
+
embeddingConfigured: boolean
|
|
148
|
+
/** Warning text to show when vector search is enabled but not configured */
|
|
149
|
+
missingConfigMessage: string
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function TopbarSearchInline({
|
|
153
|
+
embeddingConfigured,
|
|
154
|
+
missingConfigMessage,
|
|
155
|
+
}: TopbarSearchInlineProps) {
|
|
156
|
+
const router = useRouter()
|
|
157
|
+
const t = useT()
|
|
158
|
+
const [query, setQuery] = React.useState('')
|
|
159
|
+
const [results, setResults] = React.useState<SearchResult[]>([])
|
|
160
|
+
const [loading, setLoading] = React.useState(false)
|
|
161
|
+
const [error, setError] = React.useState<string | null>(null)
|
|
162
|
+
const [open, setOpen] = React.useState(false)
|
|
163
|
+
const [expanded, setExpanded] = React.useState(false)
|
|
164
|
+
const [selectedIndex, setSelectedIndex] = React.useState(0)
|
|
165
|
+
const [showScopeHint, setShowScopeHint] = React.useState<boolean>(() => hasActiveOrganizationSelection())
|
|
166
|
+
const inputRef = React.useRef<HTMLInputElement | null>(null)
|
|
167
|
+
const popoverRef = React.useRef<HTMLDivElement | null>(null)
|
|
168
|
+
const containerRef = React.useRef<HTMLElement | null>(null)
|
|
169
|
+
const listRef = React.useRef<HTMLDivElement | null>(null)
|
|
170
|
+
const abortRef = React.useRef<AbortController | null>(null)
|
|
171
|
+
|
|
172
|
+
const expandAndFocus = React.useCallback(() => {
|
|
173
|
+
setExpanded(true)
|
|
174
|
+
// Wait one tick so the input is mounted/transitioned before focusing
|
|
175
|
+
requestAnimationFrame(() => {
|
|
176
|
+
inputRef.current?.focus()
|
|
177
|
+
inputRef.current?.select()
|
|
178
|
+
})
|
|
179
|
+
}, [])
|
|
180
|
+
|
|
181
|
+
const collapseAndReset = React.useCallback(() => {
|
|
182
|
+
setOpen(false)
|
|
183
|
+
setExpanded(false)
|
|
184
|
+
setQuery('')
|
|
185
|
+
inputRef.current?.blur()
|
|
186
|
+
}, [])
|
|
187
|
+
|
|
188
|
+
React.useEffect(() => {
|
|
189
|
+
setShowScopeHint(hasActiveOrganizationSelection())
|
|
190
|
+
return subscribeOrganizationScopeChanged((detail) => {
|
|
191
|
+
setShowScopeHint(Boolean(detail.organizationId && detail.organizationId.trim().length > 0))
|
|
192
|
+
})
|
|
193
|
+
}, [])
|
|
194
|
+
|
|
195
|
+
// Cmd/Ctrl+K expands + focuses the input
|
|
196
|
+
React.useEffect(() => {
|
|
197
|
+
const handler = (event: KeyboardEvent) => {
|
|
198
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'k') {
|
|
199
|
+
event.preventDefault()
|
|
200
|
+
expandAndFocus()
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
window.addEventListener('keydown', handler)
|
|
204
|
+
return () => window.removeEventListener('keydown', handler)
|
|
205
|
+
}, [expandAndFocus])
|
|
206
|
+
|
|
207
|
+
// Click outside closes the popover AND collapses input (unless user has typed something)
|
|
208
|
+
React.useEffect(() => {
|
|
209
|
+
if (!expanded) return
|
|
210
|
+
const handler = (event: MouseEvent) => {
|
|
211
|
+
const target = event.target as Node | null
|
|
212
|
+
if (!target) return
|
|
213
|
+
if (containerRef.current?.contains(target)) return
|
|
214
|
+
if (popoverRef.current?.contains(target)) return
|
|
215
|
+
collapseAndReset()
|
|
216
|
+
}
|
|
217
|
+
document.addEventListener('mousedown', handler)
|
|
218
|
+
return () => document.removeEventListener('mousedown', handler)
|
|
219
|
+
}, [expanded, collapseAndReset])
|
|
220
|
+
|
|
221
|
+
// Fetch results on query change (debounced)
|
|
222
|
+
React.useEffect(() => {
|
|
223
|
+
abortRef.current?.abort()
|
|
224
|
+
const trimmed = query.trim()
|
|
225
|
+
if (trimmed.length < MIN_QUERY_LENGTH) {
|
|
226
|
+
setResults([])
|
|
227
|
+
setError(null)
|
|
228
|
+
setLoading(false)
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const controller = new AbortController()
|
|
233
|
+
abortRef.current = controller
|
|
234
|
+
setLoading(true)
|
|
235
|
+
|
|
236
|
+
const handle = setTimeout(async () => {
|
|
237
|
+
try {
|
|
238
|
+
const data = await fetchGlobalSearchResults(query, {
|
|
239
|
+
limit: 10,
|
|
240
|
+
signal: controller.signal,
|
|
241
|
+
})
|
|
242
|
+
setResults(data.results)
|
|
243
|
+
setError(data.error ?? null)
|
|
244
|
+
setSelectedIndex(0)
|
|
245
|
+
} catch (err: unknown) {
|
|
246
|
+
if (controller.signal.aborted) return
|
|
247
|
+
const abortError = err as { name?: string }
|
|
248
|
+
if (abortError?.name === 'AbortError') return
|
|
249
|
+
if (err instanceof ForbiddenError) {
|
|
250
|
+
setError(t('search.dialog.errors.noPermission'))
|
|
251
|
+
} else {
|
|
252
|
+
setError(err instanceof Error ? err.message : t('search.dialog.errors.searchFailed'))
|
|
253
|
+
}
|
|
254
|
+
setResults([])
|
|
255
|
+
} finally {
|
|
256
|
+
if (!controller.signal.aborted) setLoading(false)
|
|
257
|
+
}
|
|
258
|
+
}, 220)
|
|
259
|
+
|
|
260
|
+
return () => {
|
|
261
|
+
clearTimeout(handle)
|
|
262
|
+
controller.abort()
|
|
263
|
+
}
|
|
264
|
+
}, [query, t])
|
|
265
|
+
|
|
266
|
+
// Auto-scroll active item into view
|
|
267
|
+
React.useEffect(() => {
|
|
268
|
+
const container = listRef.current
|
|
269
|
+
const active = container?.querySelector<HTMLElement>('[data-active="true"]')
|
|
270
|
+
if (!container || !active) return
|
|
271
|
+
const { top: containerTop, bottom: containerBottom } = container.getBoundingClientRect()
|
|
272
|
+
const { top: activeTop, bottom: activeBottom } = active.getBoundingClientRect()
|
|
273
|
+
if (activeTop < containerTop) {
|
|
274
|
+
container.scrollTop -= containerTop - activeTop
|
|
275
|
+
} else if (activeBottom > containerBottom) {
|
|
276
|
+
container.scrollTop += activeBottom - containerBottom
|
|
277
|
+
}
|
|
278
|
+
}, [selectedIndex])
|
|
279
|
+
|
|
280
|
+
const openResult = React.useCallback(
|
|
281
|
+
(result: SearchResult | undefined) => {
|
|
282
|
+
if (!result) return
|
|
283
|
+
const href = pickPrimaryLink(result)
|
|
284
|
+
if (!href) return
|
|
285
|
+
router.push(href)
|
|
286
|
+
collapseAndReset()
|
|
287
|
+
},
|
|
288
|
+
[router, collapseAndReset],
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
const handleKeyDown = React.useCallback(
|
|
292
|
+
(event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
293
|
+
if (event.key === 'ArrowDown') {
|
|
294
|
+
event.preventDefault()
|
|
295
|
+
if (!open) setOpen(true)
|
|
296
|
+
setSelectedIndex((prev) => (results.length ? (prev + 1) % results.length : 0))
|
|
297
|
+
return
|
|
298
|
+
}
|
|
299
|
+
if (event.key === 'ArrowUp') {
|
|
300
|
+
event.preventDefault()
|
|
301
|
+
setSelectedIndex((prev) => {
|
|
302
|
+
if (!results.length) return 0
|
|
303
|
+
return prev <= 0 ? results.length - 1 : prev - 1
|
|
304
|
+
})
|
|
305
|
+
return
|
|
306
|
+
}
|
|
307
|
+
if (event.key === 'Escape') {
|
|
308
|
+
event.preventDefault()
|
|
309
|
+
if (open) {
|
|
310
|
+
setOpen(false)
|
|
311
|
+
} else if (query) {
|
|
312
|
+
setQuery('')
|
|
313
|
+
} else {
|
|
314
|
+
collapseAndReset()
|
|
315
|
+
}
|
|
316
|
+
return
|
|
317
|
+
}
|
|
318
|
+
if (event.key === 'Enter') {
|
|
319
|
+
event.preventDefault()
|
|
320
|
+
const target = results[selectedIndex]
|
|
321
|
+
openResult(target)
|
|
322
|
+
return
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
[open, query, results, selectedIndex, openResult, collapseAndReset],
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
const showVectorWarning = !embeddingConfigured && !error
|
|
329
|
+
const trimmed = query.trim()
|
|
330
|
+
const tooShort = trimmed.length > 0 && trimmed.length < MIN_QUERY_LENGTH
|
|
331
|
+
const showPopover =
|
|
332
|
+
open && (loading || results.length > 0 || error !== null || tooShort || showVectorWarning)
|
|
333
|
+
const showClear = query.length > 0
|
|
334
|
+
|
|
335
|
+
if (!expanded) {
|
|
336
|
+
return (
|
|
337
|
+
<span
|
|
338
|
+
ref={(el) => {
|
|
339
|
+
containerRef.current = el
|
|
340
|
+
}}
|
|
341
|
+
className="inline-flex"
|
|
342
|
+
>
|
|
343
|
+
<IconButton
|
|
344
|
+
type="button"
|
|
345
|
+
variant="ghost"
|
|
346
|
+
size="lg"
|
|
347
|
+
onClick={expandAndFocus}
|
|
348
|
+
aria-label={t('search.dialog.actions.openGlobalSearch', 'Open global search')}
|
|
349
|
+
title={t('search.dialog.actions.openGlobalSearch', 'Open global search')}
|
|
350
|
+
>
|
|
351
|
+
<Search className="size-4" aria-hidden="true" />
|
|
352
|
+
</IconButton>
|
|
353
|
+
</span>
|
|
354
|
+
)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return (
|
|
358
|
+
<div
|
|
359
|
+
ref={(el) => {
|
|
360
|
+
containerRef.current = el
|
|
361
|
+
}}
|
|
362
|
+
data-search-expanded="true"
|
|
363
|
+
className="relative min-w-0 sm:w-[260px] md:w-[320px] max-sm:absolute max-sm:inset-x-3 max-sm:top-1/2 max-sm:-translate-y-1/2 max-sm:z-popover"
|
|
364
|
+
>
|
|
365
|
+
<div
|
|
366
|
+
className={cn(
|
|
367
|
+
'flex h-9 items-center gap-2 rounded-md border border-input bg-background px-3 text-sm shadow-xs transition-colors hover:bg-muted/40',
|
|
368
|
+
open ? 'border-foreground bg-background shadow-focus' : '',
|
|
369
|
+
)}
|
|
370
|
+
onClick={() => inputRef.current?.focus()}
|
|
371
|
+
>
|
|
372
|
+
<Search className="size-4 shrink-0 text-muted-foreground" aria-hidden="true" />
|
|
373
|
+
<input
|
|
374
|
+
ref={inputRef}
|
|
375
|
+
type="text"
|
|
376
|
+
value={query}
|
|
377
|
+
onChange={(event) => {
|
|
378
|
+
setQuery(event.target.value)
|
|
379
|
+
if (!open) setOpen(true)
|
|
380
|
+
}}
|
|
381
|
+
onFocus={() => setOpen(true)}
|
|
382
|
+
onKeyDown={handleKeyDown}
|
|
383
|
+
placeholder={t('search.dialog.actions.search', 'Search')}
|
|
384
|
+
aria-label={t('search.dialog.actions.openGlobalSearch', 'Search')}
|
|
385
|
+
aria-autocomplete="list"
|
|
386
|
+
aria-expanded={open}
|
|
387
|
+
aria-controls="topbar-search-results"
|
|
388
|
+
className="flex-1 min-w-0 bg-transparent placeholder:text-muted-foreground/70 focus:outline-none"
|
|
389
|
+
// Inline search; no need for native browser autocomplete or autocapitalize
|
|
390
|
+
autoComplete="off"
|
|
391
|
+
spellCheck={false}
|
|
392
|
+
/>
|
|
393
|
+
{loading ? (
|
|
394
|
+
<Loader2 className="size-4 shrink-0 animate-spin text-muted-foreground" aria-hidden="true" />
|
|
395
|
+
) : showClear ? (
|
|
396
|
+
<button
|
|
397
|
+
type="button"
|
|
398
|
+
onClick={(event) => {
|
|
399
|
+
event.stopPropagation()
|
|
400
|
+
setQuery('')
|
|
401
|
+
inputRef.current?.focus()
|
|
402
|
+
}}
|
|
403
|
+
className="rounded-sm p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
|
|
404
|
+
aria-label={t('search.dialog.actions.clear', 'Clear search')}
|
|
405
|
+
>
|
|
406
|
+
<X className="size-3.5" aria-hidden="true" />
|
|
407
|
+
</button>
|
|
408
|
+
) : (
|
|
409
|
+
<kbd className="hidden md:inline-flex shrink-0 items-center rounded border bg-muted/50 px-1.5 text-overline font-medium uppercase tracking-wider text-muted-foreground">
|
|
410
|
+
⌘K
|
|
411
|
+
</kbd>
|
|
412
|
+
)}
|
|
413
|
+
</div>
|
|
414
|
+
|
|
415
|
+
{showPopover ? (
|
|
416
|
+
<div
|
|
417
|
+
ref={popoverRef}
|
|
418
|
+
id="topbar-search-results"
|
|
419
|
+
role="listbox"
|
|
420
|
+
className="absolute left-0 right-0 top-[calc(100%+4px)] z-popover min-w-[320px] rounded-md border bg-popover text-popover-foreground shadow-md"
|
|
421
|
+
>
|
|
422
|
+
{error ? (
|
|
423
|
+
<p className="border-b px-3 py-2 text-sm text-destructive">{error}</p>
|
|
424
|
+
) : null}
|
|
425
|
+
{showVectorWarning && !error ? (
|
|
426
|
+
<div className="border-b bg-status-warning-bg px-3 py-2 text-xs text-status-warning-text">
|
|
427
|
+
<p>{missingConfigMessage}</p>
|
|
428
|
+
<NextLink
|
|
429
|
+
href="/backend/config/search"
|
|
430
|
+
onClick={() => collapseAndReset()}
|
|
431
|
+
className="mt-1 inline-flex items-center font-medium underline underline-offset-2 hover:no-underline"
|
|
432
|
+
>
|
|
433
|
+
{t('search.dialog.warnings.configureLink', 'Configure search settings')}
|
|
434
|
+
</NextLink>
|
|
435
|
+
</div>
|
|
436
|
+
) : null}
|
|
437
|
+
{showScopeHint ? (
|
|
438
|
+
<p className="border-b px-3 py-1.5 text-overline font-medium uppercase tracking-wider text-muted-foreground">
|
|
439
|
+
{t('search.scopeHint.currentOrg', 'Scoped to current organization')}
|
|
440
|
+
</p>
|
|
441
|
+
) : null}
|
|
442
|
+
|
|
443
|
+
{tooShort && !error ? (
|
|
444
|
+
<div className="px-3 py-3 text-sm text-muted-foreground">
|
|
445
|
+
{t('search.dialog.empty.hint', { count: MIN_QUERY_LENGTH })}
|
|
446
|
+
</div>
|
|
447
|
+
) : null}
|
|
448
|
+
|
|
449
|
+
{!tooShort && results.length === 0 && !loading && !error ? (
|
|
450
|
+
<div className="px-3 py-3 text-sm text-muted-foreground">
|
|
451
|
+
{t('search.dialog.empty.none', 'No results')}
|
|
452
|
+
</div>
|
|
453
|
+
) : null}
|
|
454
|
+
|
|
455
|
+
{results.length > 0 ? (
|
|
456
|
+
<div ref={listRef} className="max-h-[380px] overflow-y-auto p-1">
|
|
457
|
+
{results.map((result, index) => {
|
|
458
|
+
const presenter = result.presenter
|
|
459
|
+
const isActive = index === selectedIndex
|
|
460
|
+
const hasLink = pickPrimaryLink(result) !== null
|
|
461
|
+
const Icon = presenter?.icon ? resolveIcon(presenter.icon) : null
|
|
462
|
+
return (
|
|
463
|
+
<button
|
|
464
|
+
key={`${result.entityId}:${result.recordId}`}
|
|
465
|
+
type="button"
|
|
466
|
+
data-active={isActive}
|
|
467
|
+
onClick={() => openResult(result)}
|
|
468
|
+
onMouseEnter={() => setSelectedIndex(index)}
|
|
469
|
+
role="option"
|
|
470
|
+
aria-selected={isActive}
|
|
471
|
+
className={cn(
|
|
472
|
+
'flex w-full items-start gap-3 rounded-sm px-2 py-2 text-left transition-colors',
|
|
473
|
+
isActive ? 'bg-muted' : 'hover:bg-muted/60',
|
|
474
|
+
!hasLink && 'opacity-60',
|
|
475
|
+
)}
|
|
476
|
+
>
|
|
477
|
+
{Icon ? (
|
|
478
|
+
<span className="mt-0.5 inline-flex size-7 shrink-0 items-center justify-center rounded-md border bg-background">
|
|
479
|
+
<Icon className="size-4 text-muted-foreground" aria-hidden="true" />
|
|
480
|
+
</span>
|
|
481
|
+
) : (
|
|
482
|
+
<span className="mt-0.5 inline-flex size-7 shrink-0 items-center justify-center rounded-md border bg-background">
|
|
483
|
+
<FileText className="size-4 text-muted-foreground" aria-hidden="true" />
|
|
484
|
+
</span>
|
|
485
|
+
)}
|
|
486
|
+
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
487
|
+
<span className="flex items-center gap-2">
|
|
488
|
+
<span
|
|
489
|
+
className={cn(
|
|
490
|
+
'truncate text-sm font-medium',
|
|
491
|
+
!hasLink ? 'text-muted-foreground' : 'text-foreground',
|
|
492
|
+
)}
|
|
493
|
+
>
|
|
494
|
+
{presenter?.title ?? result.recordId}
|
|
495
|
+
</span>
|
|
496
|
+
</span>
|
|
497
|
+
<span className="flex items-center gap-2 text-overline text-muted-foreground">
|
|
498
|
+
<span className="truncate">{formatEntityId(result.entityId)}</span>
|
|
499
|
+
{presenter?.subtitle ? (
|
|
500
|
+
<>
|
|
501
|
+
<span aria-hidden="true">·</span>
|
|
502
|
+
<span className="truncate">{presenter.subtitle}</span>
|
|
503
|
+
</>
|
|
504
|
+
) : null}
|
|
505
|
+
</span>
|
|
506
|
+
</span>
|
|
507
|
+
</button>
|
|
508
|
+
)
|
|
509
|
+
})}
|
|
510
|
+
</div>
|
|
511
|
+
) : null}
|
|
512
|
+
</div>
|
|
513
|
+
) : null}
|
|
514
|
+
</div>
|
|
515
|
+
)
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
export default TopbarSearchInline
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { GlobalSearchDialog } from './components/GlobalSearchDialog'
|
|
2
|
+
export { TopbarSearchInline } from './components/TopbarSearchInline'
|
|
2
3
|
export { SearchSettingsPageClient } from './components/SearchSettingsPageClient'
|
|
3
4
|
export { HybridSearchTable } from './components/HybridSearchTable'
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"search.api.errors.vectorUnavailable": "Vektorsuche ist nicht verfügbar.",
|
|
23
23
|
"search.config.nav.hybridSearch": "Sucheinstellungen",
|
|
24
24
|
"search.dialog.actions.cancel": "Abbrechen (Esc)",
|
|
25
|
+
"search.dialog.actions.clear": "Suche löschen",
|
|
25
26
|
"search.dialog.actions.openGlobalSearch": "Globale Suche öffnen",
|
|
26
27
|
"search.dialog.actions.openSelected": "Öffnen (Enter)",
|
|
27
28
|
"search.dialog.actions.search": "Suchen",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"search.dialog.strategies.semanticDescription": "KI-gestützte bedeutungsbasierte Suche",
|
|
45
46
|
"search.dialog.strategies.toggle": "Suchoptionen",
|
|
46
47
|
"search.dialog.title": "Globale Suche",
|
|
48
|
+
"search.dialog.warnings.configureLink": "Sucheinstellungen konfigurieren",
|
|
47
49
|
"search.messages.missingConfig": "Die Suche erfordert die Konfiguration eines Embedding-Anbieters für die semantische Suche.",
|
|
48
50
|
"search.nav.hybridSearch": "Suche",
|
|
49
51
|
"search.scopeHint.currentOrg": "Bereich: aktuelle Organisation",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"search.api.errors.vectorUnavailable": "Vector search is unavailable.",
|
|
23
23
|
"search.config.nav.hybridSearch": "Search Settings",
|
|
24
24
|
"search.dialog.actions.cancel": "Cancel (Esc)",
|
|
25
|
+
"search.dialog.actions.clear": "Clear search",
|
|
25
26
|
"search.dialog.actions.openGlobalSearch": "Open global search",
|
|
26
27
|
"search.dialog.actions.openSelected": "Open (Enter)",
|
|
27
28
|
"search.dialog.actions.search": "Search",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"search.dialog.strategies.semanticDescription": "AI-powered meaning-based search",
|
|
45
46
|
"search.dialog.strategies.toggle": "Search options",
|
|
46
47
|
"search.dialog.title": "Global Search",
|
|
48
|
+
"search.dialog.warnings.configureLink": "Configure search settings",
|
|
47
49
|
"search.messages.missingConfig": "Search requires configuring an embedding provider for semantic search.",
|
|
48
50
|
"search.nav.hybridSearch": "Search",
|
|
49
51
|
"search.scopeHint.currentOrg": "Scoped to current organization",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"search.api.errors.vectorUnavailable": "La búsqueda vectorial no está disponible.",
|
|
23
23
|
"search.config.nav.hybridSearch": "Configuración de búsqueda",
|
|
24
24
|
"search.dialog.actions.cancel": "Cancelar (Esc)",
|
|
25
|
+
"search.dialog.actions.clear": "Limpiar búsqueda",
|
|
25
26
|
"search.dialog.actions.openGlobalSearch": "Abrir búsqueda global",
|
|
26
27
|
"search.dialog.actions.openSelected": "Abrir (Enter)",
|
|
27
28
|
"search.dialog.actions.search": "Buscar",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"search.dialog.strategies.semanticDescription": "Búsqueda basada en significado impulsada por IA",
|
|
45
46
|
"search.dialog.strategies.toggle": "Opciones de búsqueda",
|
|
46
47
|
"search.dialog.title": "Búsqueda Global",
|
|
48
|
+
"search.dialog.warnings.configureLink": "Configurar búsqueda",
|
|
47
49
|
"search.messages.missingConfig": "La búsqueda requiere configurar un proveedor de embeddings para la búsqueda semántica.",
|
|
48
50
|
"search.nav.hybridSearch": "Búsqueda",
|
|
49
51
|
"search.scopeHint.currentOrg": "Alcance: organización actual",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"search.api.errors.vectorUnavailable": "Wyszukiwanie wektorowe jest niedostępne.",
|
|
23
23
|
"search.config.nav.hybridSearch": "Ustawienia wyszukiwania",
|
|
24
24
|
"search.dialog.actions.cancel": "Anuluj (Esc)",
|
|
25
|
+
"search.dialog.actions.clear": "Wyczyść wyszukiwanie",
|
|
25
26
|
"search.dialog.actions.openGlobalSearch": "Otwórz globalne wyszukiwanie",
|
|
26
27
|
"search.dialog.actions.openSelected": "Otwórz (Enter)",
|
|
27
28
|
"search.dialog.actions.search": "Szukaj",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"search.dialog.strategies.semanticDescription": "Wyszukiwanie oparte na znaczeniu wspomagane AI",
|
|
45
46
|
"search.dialog.strategies.toggle": "Opcje wyszukiwania",
|
|
46
47
|
"search.dialog.title": "Globalne Wyszukiwanie",
|
|
48
|
+
"search.dialog.warnings.configureLink": "Skonfiguruj wyszukiwanie",
|
|
47
49
|
"search.messages.missingConfig": "Wyszukiwanie wymaga skonfigurowania dostawcy embeddingów dla wyszukiwania semantycznego.",
|
|
48
50
|
"search.nav.hybridSearch": "Wyszukiwanie",
|
|
49
51
|
"search.scopeHint.currentOrg": "Zakres: bieżąca organizacja",
|