@eightyfourthousand/lib-search 2026.3.1 → 2026.4.1
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/index.js +4 -0
- package/index.js.map +1 -0
- package/lib/data/index.js +2 -0
- package/lib/data/index.js.map +1 -0
- package/lib/data/search.d.ts +5 -0
- package/lib/data/search.js +18 -0
- package/lib/data/search.js.map +1 -0
- package/lib/types/index.js +2 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/search.d.ts +71 -0
- package/lib/types/search.js +58 -0
- package/lib/types/search.js.map +1 -0
- package/lib/ui/SearchButton.d.ts +35 -0
- package/lib/ui/SearchButton.js +224 -0
- package/lib/ui/SearchButton.js.map +1 -0
- package/lib/ui/SearchResultCard.d.ts +26 -0
- package/lib/ui/SearchResultCard.js +67 -0
- package/lib/ui/SearchResultCard.js.map +1 -0
- package/lib/ui/SearchResultTab.d.ts +4 -0
- package/lib/ui/SearchResultTab.js +7 -0
- package/lib/ui/SearchResultTab.js.map +1 -0
- package/lib/ui/SearchResultsList.d.ts +8 -0
- package/lib/ui/SearchResultsList.js +10 -0
- package/lib/ui/SearchResultsList.js.map +1 -0
- package/lib/ui/index.js +2 -0
- package/lib/ui/index.js.map +1 -0
- package/package.json +19 -5
- package/.babelrc +0 -12
- package/.eslintrc.json +0 -18
- package/README.md +0 -9
- package/project.json +0 -20
- package/src/lib/data/search.ts +0 -28
- package/src/lib/types/search.ts +0 -140
- package/src/lib/ui/SearchButton.tsx +0 -151
- package/src/lib/ui/SearchResultCard.tsx +0 -117
- package/src/lib/ui/SearchResultTab.tsx +0 -28
- package/src/lib/ui/SearchResultsList.tsx +0 -25
- package/tsconfig.json +0 -17
- package/tsconfig.lib.json +0 -26
- /package/{src/index.ts → index.d.ts} +0 -0
- /package/{src/lib/data/index.ts → lib/data/index.d.ts} +0 -0
- /package/{src/lib/types/index.ts → lib/types/index.d.ts} +0 -0
- /package/{src/lib/ui/index.ts → lib/ui/index.d.ts} +0 -0
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../libs/lib-search/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/lib-search/src/lib/data/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
import { __awaiter } from "tslib";
|
|
3
|
+
import { createServerClient } from '@eightyfourthousand/data-access/ssr';
|
|
4
|
+
import { searchResultsFromDTO } from '../types';
|
|
5
|
+
export const search = (_a) => __awaiter(void 0, [_a], void 0, function* ({ text, uuid, toh, }) {
|
|
6
|
+
const client = yield createServerClient();
|
|
7
|
+
const { data, error } = yield client.rpc('translation_search', {
|
|
8
|
+
search_term: text,
|
|
9
|
+
work_uuid: uuid,
|
|
10
|
+
toh: toh,
|
|
11
|
+
});
|
|
12
|
+
if (error) {
|
|
13
|
+
console.error('Search error:', error);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return searchResultsFromDTO(data);
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../../../libs/lib-search/src/lib/data/search.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,CAAC,MAAM,MAAM,GAAG,KAQnB,EAAE,4CARwB,EAC3B,IAAI,EACJ,IAAI,EACJ,GAAG,GAKJ;IACC,MAAM,MAAM,GAAG,MAAM,kBAAkB,EAAE,CAAC;IAC1C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,oBAAoB,EAAE;QAC7D,WAAW,EAAE,IAAI;QACjB,SAAS,EAAE,IAAI;QACf,GAAG,EAAE,GAAG;KACT,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;QACtC,OAAO;IACT,CAAC;IAED,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/lib-search/src/lib/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { GlossaryTermInstance, GlossaryTermInstanceDTO } from "@eightyfourthousand/data-access";
|
|
2
|
+
export declare const RESULTS_ENTITIES: readonly ["alignments", "passages", "bibliographies", "glossaries"];
|
|
3
|
+
export type ResultsEntity = (typeof RESULTS_ENTITIES)[number];
|
|
4
|
+
export declare const RESULTS_ENTITY_LABELS: Record<ResultsEntity, string>;
|
|
5
|
+
export type BibliographySearchMatchDTO = {
|
|
6
|
+
bibliography_uuid: string;
|
|
7
|
+
content: string;
|
|
8
|
+
};
|
|
9
|
+
export type GlossarySearchMatchDTO = {
|
|
10
|
+
authority_uuid: string;
|
|
11
|
+
glossary_uuid: string;
|
|
12
|
+
content: string;
|
|
13
|
+
entry: GlossaryTermInstanceDTO;
|
|
14
|
+
};
|
|
15
|
+
export type PassageSearchMatchDTO = {
|
|
16
|
+
passage_uuid: string;
|
|
17
|
+
type: ResultsEntity;
|
|
18
|
+
label: string;
|
|
19
|
+
content: string;
|
|
20
|
+
};
|
|
21
|
+
export type AlignmentSearchMatchDTO = {
|
|
22
|
+
passage_uuid: string;
|
|
23
|
+
english_label: string;
|
|
24
|
+
english: string;
|
|
25
|
+
tibetan: string;
|
|
26
|
+
tibetan_volume_number: string;
|
|
27
|
+
tibetan_folio_number: string;
|
|
28
|
+
};
|
|
29
|
+
export type SearchMatch = {
|
|
30
|
+
type: string;
|
|
31
|
+
uuid: string;
|
|
32
|
+
content: string;
|
|
33
|
+
};
|
|
34
|
+
export type PassageMatch = SearchMatch & {
|
|
35
|
+
type: 'passage';
|
|
36
|
+
section: string;
|
|
37
|
+
label: string;
|
|
38
|
+
};
|
|
39
|
+
export type AlignmentMatch = SearchMatch & {
|
|
40
|
+
type: 'alignment';
|
|
41
|
+
section: 'translation';
|
|
42
|
+
label: string;
|
|
43
|
+
source: string;
|
|
44
|
+
volume: string;
|
|
45
|
+
folio: string;
|
|
46
|
+
};
|
|
47
|
+
export type BibliographyMatch = SearchMatch & {
|
|
48
|
+
type: 'bibliography';
|
|
49
|
+
};
|
|
50
|
+
export type GlossaryMatch = SearchMatch & {
|
|
51
|
+
type: 'glossary';
|
|
52
|
+
entry: GlossaryTermInstance;
|
|
53
|
+
};
|
|
54
|
+
export type SearchResultsDTO = {
|
|
55
|
+
passage_matches: PassageSearchMatchDTO[];
|
|
56
|
+
alignment_matches: AlignmentSearchMatchDTO[];
|
|
57
|
+
bibliography_matches: BibliographySearchMatchDTO[];
|
|
58
|
+
glossary_matches: GlossarySearchMatchDTO[];
|
|
59
|
+
};
|
|
60
|
+
export type SearchResult = SearchMatch | PassageMatch | AlignmentMatch | BibliographyMatch | GlossaryMatch;
|
|
61
|
+
export type SearchResults = {
|
|
62
|
+
passages: PassageMatch[];
|
|
63
|
+
alignments: AlignmentMatch[];
|
|
64
|
+
bibliographies: SearchMatch[];
|
|
65
|
+
glossaries: SearchMatch[];
|
|
66
|
+
};
|
|
67
|
+
export declare const bibliographyMatchFromDTO: (dto: BibliographySearchMatchDTO) => BibliographyMatch;
|
|
68
|
+
export declare const glossaryMatchFromDTO: (dto: GlossarySearchMatchDTO) => GlossaryMatch;
|
|
69
|
+
export declare const passageMatchFromDTO: (dto: PassageSearchMatchDTO) => PassageMatch;
|
|
70
|
+
export declare const alignmentMatchFromDTO: (dto: AlignmentSearchMatchDTO) => AlignmentMatch;
|
|
71
|
+
export declare const searchResultsFromDTO: (dto: SearchResultsDTO) => SearchResults;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { glossaryTermInstanceFromDTO } from "@eightyfourthousand/data-access";
|
|
2
|
+
export const RESULTS_ENTITIES = [
|
|
3
|
+
'alignments',
|
|
4
|
+
'passages',
|
|
5
|
+
'bibliographies',
|
|
6
|
+
'glossaries',
|
|
7
|
+
];
|
|
8
|
+
export const RESULTS_ENTITY_LABELS = {
|
|
9
|
+
alignments: 'Translation Passages',
|
|
10
|
+
passages: 'Other Passages',
|
|
11
|
+
bibliographies: 'Bibliographies',
|
|
12
|
+
glossaries: 'Glossaries',
|
|
13
|
+
};
|
|
14
|
+
export const bibliographyMatchFromDTO = (dto) => {
|
|
15
|
+
return {
|
|
16
|
+
type: 'bibliography',
|
|
17
|
+
uuid: dto.bibliography_uuid,
|
|
18
|
+
content: dto.content,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export const glossaryMatchFromDTO = (dto) => {
|
|
22
|
+
return {
|
|
23
|
+
type: 'glossary',
|
|
24
|
+
uuid: dto.authority_uuid,
|
|
25
|
+
content: dto.content,
|
|
26
|
+
entry: glossaryTermInstanceFromDTO(dto.entry),
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export const passageMatchFromDTO = (dto) => {
|
|
30
|
+
return {
|
|
31
|
+
type: 'passage',
|
|
32
|
+
uuid: dto.passage_uuid,
|
|
33
|
+
section: dto.type,
|
|
34
|
+
label: dto.label,
|
|
35
|
+
content: dto.content,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export const alignmentMatchFromDTO = (dto) => {
|
|
39
|
+
return {
|
|
40
|
+
type: 'alignment',
|
|
41
|
+
section: 'translation',
|
|
42
|
+
uuid: dto.passage_uuid,
|
|
43
|
+
label: dto.english_label,
|
|
44
|
+
content: dto.english,
|
|
45
|
+
source: dto.tibetan,
|
|
46
|
+
volume: dto.tibetan_volume_number,
|
|
47
|
+
folio: dto.tibetan_folio_number,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export const searchResultsFromDTO = (dto) => {
|
|
51
|
+
return {
|
|
52
|
+
passages: dto.passage_matches.map(passageMatchFromDTO),
|
|
53
|
+
alignments: dto.alignment_matches.map(alignmentMatchFromDTO),
|
|
54
|
+
bibliographies: dto.bibliography_matches.map(bibliographyMatchFromDTO),
|
|
55
|
+
glossaries: dto.glossary_matches.map(glossaryMatchFromDTO),
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../../../libs/lib-search/src/lib/types/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiD,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAE7H,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,YAAY;IACZ,UAAU;IACV,gBAAgB;IAChB,YAAY;CACJ,CAAC;AAIX,MAAM,CAAC,MAAM,qBAAqB,GAAkC;IAClE,UAAU,EAAE,sBAAsB;IAClC,QAAQ,EAAE,gBAAgB;IAC1B,cAAc,EAAE,gBAAgB;IAChC,UAAU,EAAE,YAAY;CAChB,CAAC;AAiFX,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,GAA+B,EACZ,EAAE;IACrB,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,GAAG,CAAC,iBAAiB;QAC3B,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,GAA2B,EACZ,EAAE;IACjB,OAAO;QACL,IAAI,EAAE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|
|
|
1
|
+
import type { PassageOccurrence } from '@eightyfourthousand/data-access';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { PassageMatch, SearchResult } from '../types';
|
|
4
|
+
export type SearchPendingSelection = {
|
|
5
|
+
kind: 'index';
|
|
6
|
+
index: number;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'cursor';
|
|
9
|
+
start: number;
|
|
10
|
+
passageUuid: string;
|
|
11
|
+
};
|
|
12
|
+
export interface SearchActionContext {
|
|
13
|
+
activeOccurrence?: PassageOccurrence;
|
|
14
|
+
activeOccurrenceIndex: number;
|
|
15
|
+
activePassageLabel?: string;
|
|
16
|
+
activePassageUuid?: string;
|
|
17
|
+
moveActiveOccurrence: (direction: 'next' | 'previous') => void;
|
|
18
|
+
passageOccurrences: PassageOccurrence[];
|
|
19
|
+
passages: PassageMatch[];
|
|
20
|
+
refreshSearch: (options?: {
|
|
21
|
+
nextSelection?: SearchPendingSelection | null;
|
|
22
|
+
}) => Promise<void>;
|
|
23
|
+
searchQuery: string;
|
|
24
|
+
searching: boolean;
|
|
25
|
+
scrollActiveOccurrenceIntoView: () => void;
|
|
26
|
+
setActiveOccurrenceIndex: (index: number) => void;
|
|
27
|
+
setShouldScrollActiveOccurrence: (shouldScroll: boolean) => void;
|
|
28
|
+
}
|
|
29
|
+
export interface SearchButtonProps {
|
|
30
|
+
onResultSelected: (result: SearchResult) => void;
|
|
31
|
+
renderActions?: (context: SearchActionContext) => ReactNode;
|
|
32
|
+
toh?: string;
|
|
33
|
+
workUuid?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare const SearchButton: ({ renderActions, workUuid, toh, onResultSelected, }: SearchButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { __awaiter } from "tslib";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
|
+
import { getPassageOccurrences } from '@eightyfourthousand/data-access';
|
|
5
|
+
import { Button, Dialog, DialogContent, DialogDescription, DialogTitle, DialogTrigger, Input, Tabs, TabsContent, } from '@eightyfourthousand/design-system';
|
|
6
|
+
import { Loader2Icon, SearchIcon, XIcon } from 'lucide-react';
|
|
7
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
8
|
+
import { search } from '../data';
|
|
9
|
+
import { RESULTS_ENTITIES } from '../types';
|
|
10
|
+
import { SearchResultsList } from './SearchResultsList';
|
|
11
|
+
import { SearchResultTabs } from './SearchResultTab';
|
|
12
|
+
const DEFAULT_RESULTS_TAB = 'alignments';
|
|
13
|
+
const getFirstResultsTab = (results) => {
|
|
14
|
+
var _a;
|
|
15
|
+
return ((_a = RESULTS_ENTITIES.find((tab) => { var _a; return ((_a = results === null || results === void 0 ? void 0 : results[tab].length) !== null && _a !== void 0 ? _a : 0) > 0; })) !== null && _a !== void 0 ? _a : DEFAULT_RESULTS_TAB);
|
|
16
|
+
};
|
|
17
|
+
const getOccurrenceResultsTab = (occurrence) => {
|
|
18
|
+
if (!occurrence) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return occurrence.type === 'alignment' ? 'alignments' : 'passages';
|
|
22
|
+
};
|
|
23
|
+
export const SearchButton = ({ renderActions, workUuid, toh, onResultSelected, }) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const [open, setOpen] = useState(false);
|
|
26
|
+
const [searching, setSearching] = useState(false);
|
|
27
|
+
const [hasResults, setHasResults] = useState(false);
|
|
28
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
29
|
+
const [results, setResults] = useState();
|
|
30
|
+
const [activeOccurrenceIndex, setActiveOccurrenceIndexState] = useState(0);
|
|
31
|
+
const [activeResultsTab, setActiveResultsTab] = useState(DEFAULT_RESULTS_TAB);
|
|
32
|
+
const [shouldScrollActiveOccurrence, setShouldScrollActiveOccurrence] = useState(false);
|
|
33
|
+
const pendingOccurrenceSelectionRef = useRef(null);
|
|
34
|
+
const passageOccurrences = useMemo(() => getPassageOccurrences([...((results === null || results === void 0 ? void 0 : results.alignments) || []), ...((results === null || results === void 0 ? void 0 : results.passages) || [])], searchQuery), [results === null || results === void 0 ? void 0 : results.alignments, results === null || results === void 0 ? void 0 : results.passages, searchQuery]);
|
|
35
|
+
const activeOccurrence = passageOccurrences[activeOccurrenceIndex];
|
|
36
|
+
const activeOccurrenceStart = (_a = activeOccurrence === null || activeOccurrence === void 0 ? void 0 : activeOccurrence.start) !== null && _a !== void 0 ? _a : null;
|
|
37
|
+
const activePassageUuid = activeOccurrence === null || activeOccurrence === void 0 ? void 0 : activeOccurrence.passageUuid;
|
|
38
|
+
const activePassageLabel = (_b = results === null || results === void 0 ? void 0 : results.passages.find((passage) => passage.uuid === activePassageUuid)) === null || _b === void 0 ? void 0 : _b.label;
|
|
39
|
+
const passageOrder = useMemo(() => new Map(((results === null || results === void 0 ? void 0 : results.passages) || []).map((passage, index) => [
|
|
40
|
+
passage.uuid,
|
|
41
|
+
index,
|
|
42
|
+
])), [results === null || results === void 0 ? void 0 : results.passages]);
|
|
43
|
+
const scrollActiveOccurrenceIntoView = useCallback(() => {
|
|
44
|
+
requestAnimationFrame(() => {
|
|
45
|
+
var _a;
|
|
46
|
+
(_a = document
|
|
47
|
+
.querySelector('[data-search-result-active="true"]')) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
48
|
+
behavior: 'smooth',
|
|
49
|
+
block: 'start',
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}, []);
|
|
53
|
+
const refreshSearch = useCallback((...args_1) => __awaiter(void 0, [...args_1], void 0, function* (options = {}) {
|
|
54
|
+
var _a;
|
|
55
|
+
if (!searchQuery || !workUuid || !toh) {
|
|
56
|
+
setResults(undefined);
|
|
57
|
+
setHasResults(false);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
setSearching(true);
|
|
61
|
+
const nextResults = yield search({
|
|
62
|
+
text: searchQuery,
|
|
63
|
+
uuid: workUuid,
|
|
64
|
+
toh,
|
|
65
|
+
});
|
|
66
|
+
setHasResults(!!nextResults &&
|
|
67
|
+
(nextResults.passages.length > 0 ||
|
|
68
|
+
nextResults.alignments.length > 0 ||
|
|
69
|
+
nextResults.bibliographies.length > 0 ||
|
|
70
|
+
nextResults.glossaries.length > 0));
|
|
71
|
+
setResults(nextResults);
|
|
72
|
+
if ('nextSelection' in options) {
|
|
73
|
+
pendingOccurrenceSelectionRef.current = (_a = options.nextSelection) !== null && _a !== void 0 ? _a : null;
|
|
74
|
+
}
|
|
75
|
+
setSearching(false);
|
|
76
|
+
}), [searchQuery, toh, workUuid]);
|
|
77
|
+
const setActiveOccurrenceIndex = useCallback((nextIndex) => {
|
|
78
|
+
pendingOccurrenceSelectionRef.current = null;
|
|
79
|
+
setActiveOccurrenceIndexState(Math.max(0, Math.min(nextIndex, Math.max(passageOccurrences.length - 1, 0))));
|
|
80
|
+
}, [passageOccurrences.length]);
|
|
81
|
+
const moveActiveOccurrence = useCallback((direction) => {
|
|
82
|
+
if (passageOccurrences.length === 0) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
pendingOccurrenceSelectionRef.current = null;
|
|
86
|
+
setActiveOccurrenceIndexState((current) => {
|
|
87
|
+
if (direction === 'previous') {
|
|
88
|
+
return Math.max(current - 1, 0);
|
|
89
|
+
}
|
|
90
|
+
return Math.min(current + 1, passageOccurrences.length - 1);
|
|
91
|
+
});
|
|
92
|
+
}, [passageOccurrences.length]);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
const debounce = setTimeout(() => {
|
|
95
|
+
void refreshSearch();
|
|
96
|
+
}, 300);
|
|
97
|
+
return () => clearTimeout(debounce);
|
|
98
|
+
}, [refreshSearch]);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
setResults(undefined);
|
|
101
|
+
setSearchQuery('');
|
|
102
|
+
setActiveOccurrenceIndexState(0);
|
|
103
|
+
setShouldScrollActiveOccurrence(false);
|
|
104
|
+
pendingOccurrenceSelectionRef.current = null;
|
|
105
|
+
}, [open]);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (!results) {
|
|
108
|
+
setActiveResultsTab(DEFAULT_RESULTS_TAB);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
setActiveResultsTab((currentTab) => results[currentTab].length > 0 ? currentTab : getFirstResultsTab(results));
|
|
112
|
+
}, [results]);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (passageOccurrences.length === 0) {
|
|
115
|
+
setActiveOccurrenceIndexState(0);
|
|
116
|
+
pendingOccurrenceSelectionRef.current = null;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const pendingSelection = pendingOccurrenceSelectionRef.current;
|
|
120
|
+
if (pendingSelection) {
|
|
121
|
+
if (pendingSelection.kind === 'index') {
|
|
122
|
+
setActiveOccurrenceIndexState(Math.min(pendingSelection.index, passageOccurrences.length - 1));
|
|
123
|
+
pendingOccurrenceSelectionRef.current = null;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const nextIndex = passageOccurrences.findIndex((occurrence) => {
|
|
127
|
+
if (pendingSelection.kind === 'cursor' &&
|
|
128
|
+
occurrence.passageUuid === pendingSelection.passageUuid &&
|
|
129
|
+
occurrence.start >= pendingSelection.start) {
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
133
|
+
});
|
|
134
|
+
if (nextIndex >= 0) {
|
|
135
|
+
setActiveOccurrenceIndexState(nextIndex);
|
|
136
|
+
pendingOccurrenceSelectionRef.current = null;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const currentPassageOrder = pendingSelection.kind === 'cursor'
|
|
140
|
+
? passageOrder.get(pendingSelection.passageUuid)
|
|
141
|
+
: undefined;
|
|
142
|
+
const nextPassageIndex = pendingSelection.kind === 'cursor' && currentPassageOrder != null
|
|
143
|
+
? passageOccurrences.findIndex((occurrence) => {
|
|
144
|
+
const occurrenceOrder = passageOrder.get(occurrence.passageUuid);
|
|
145
|
+
return (occurrenceOrder != null && occurrenceOrder > currentPassageOrder);
|
|
146
|
+
})
|
|
147
|
+
: -1;
|
|
148
|
+
setActiveOccurrenceIndexState(nextPassageIndex >= 0 ? nextPassageIndex : 0);
|
|
149
|
+
pendingOccurrenceSelectionRef.current = null;
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
setActiveOccurrenceIndexState((current) => Math.min(current, passageOccurrences.length - 1));
|
|
153
|
+
}, [passageOccurrences, passageOrder]);
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (!shouldScrollActiveOccurrence || !activeOccurrence || !results) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const occurrenceTab = getOccurrenceResultsTab(activeOccurrence);
|
|
159
|
+
if (occurrenceTab && results[occurrenceTab].length > 0) {
|
|
160
|
+
setActiveResultsTab(occurrenceTab);
|
|
161
|
+
}
|
|
162
|
+
}, [activeOccurrence, results, shouldScrollActiveOccurrence]);
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
if (!shouldScrollActiveOccurrence ||
|
|
165
|
+
!activePassageUuid ||
|
|
166
|
+
activeOccurrenceStart == null) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
scrollActiveOccurrenceIntoView();
|
|
170
|
+
}, [
|
|
171
|
+
activeOccurrenceStart,
|
|
172
|
+
activeResultsTab,
|
|
173
|
+
activePassageUuid,
|
|
174
|
+
scrollActiveOccurrenceIntoView,
|
|
175
|
+
shouldScrollActiveOccurrence,
|
|
176
|
+
]);
|
|
177
|
+
const onCardClick = (result) => {
|
|
178
|
+
setOpen(false);
|
|
179
|
+
onResultSelected(result);
|
|
180
|
+
};
|
|
181
|
+
const actionContext = useMemo(() => ({
|
|
182
|
+
activeOccurrence,
|
|
183
|
+
activeOccurrenceIndex,
|
|
184
|
+
activePassageLabel,
|
|
185
|
+
activePassageUuid,
|
|
186
|
+
moveActiveOccurrence,
|
|
187
|
+
passageOccurrences,
|
|
188
|
+
passages: (results === null || results === void 0 ? void 0 : results.passages) || [],
|
|
189
|
+
refreshSearch,
|
|
190
|
+
searchQuery,
|
|
191
|
+
searching,
|
|
192
|
+
scrollActiveOccurrenceIntoView,
|
|
193
|
+
setActiveOccurrenceIndex,
|
|
194
|
+
setShouldScrollActiveOccurrence,
|
|
195
|
+
}), [
|
|
196
|
+
activeOccurrence,
|
|
197
|
+
activeOccurrenceIndex,
|
|
198
|
+
activePassageLabel,
|
|
199
|
+
activePassageUuid,
|
|
200
|
+
moveActiveOccurrence,
|
|
201
|
+
passageOccurrences,
|
|
202
|
+
refreshSearch,
|
|
203
|
+
results === null || results === void 0 ? void 0 : results.passages,
|
|
204
|
+
scrollActiveOccurrenceIntoView,
|
|
205
|
+
searchQuery,
|
|
206
|
+
searching,
|
|
207
|
+
setActiveOccurrenceIndex,
|
|
208
|
+
]);
|
|
209
|
+
return (_jsxs(Dialog, { open: open, onOpenChange: setOpen, children: [_jsx(DialogTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", className: "bg-background my-auto [&_svg]:size-6 [&_svg]:stroke-1 hover:bg-background cursor-pointer text-base text-accent hover:text-accent/80", children: _jsx(SearchIcon, {}) }) }), _jsxs(DialogContent, { showCloseButton: false, className: "bg-transparent top-4 max-w-4xl shadow-none border-0 text-secondary translate-y-0", children: [_jsx(DialogTitle, { className: "hidden", children: "Search" }), _jsx(DialogDescription, { className: "hidden", children: "Search this translation" }), _jsxs("div", { className: "flex flex-col justify-start gap-2 h-[calc(100vh-2.5rem)]", children: [_jsxs("div", { className: "w-full flex flex-col gap-2 text-foreground shrink-0", children: [_jsx("div", { className: "flex justify-end", children: _jsx(Button, { className: "text-secondary-foreground -me-3", variant: "ghost", size: "icon", onClick: () => setOpen(false), children: _jsx(XIcon, { className: "size-3 my-auto" }) }) }), _jsx(Input, { autoFocus: true, placeholder: "Type to search...", value: searchQuery, className: "w-full text-foreground px-4 py-6", onChange: (e) => {
|
|
210
|
+
const nextValue = e.target.value;
|
|
211
|
+
if (nextValue === searchQuery) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
setActiveOccurrenceIndexState(0);
|
|
215
|
+
pendingOccurrenceSelectionRef.current = null;
|
|
216
|
+
setSearchQuery(nextValue);
|
|
217
|
+
} }), searchQuery && (renderActions === null || renderActions === void 0 ? void 0 : renderActions(actionContext))] }), searchQuery && (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex flex-col gap-3 text-sm text-secondary-foreground", children: _jsxs("div", { children: ["Showing results for \"", _jsx("strong", { children: searchQuery }), "\"", searching && (_jsx(Loader2Icon, { className: "size-4 ml-2 animate-spin inline-block" }))] }) }), results && hasResults ? (_jsxs(Tabs, { value: activeResultsTab, onValueChange: (tab) => {
|
|
218
|
+
setActiveResultsTab(tab);
|
|
219
|
+
}, className: "flex flex-col grow min-h-0 pt-2", children: [_jsx(SearchResultTabs, { results: results }), RESULTS_ENTITIES.map((tab) => results[tab].length > 0 && (_jsx(TabsContent, { className: "grow min-h-0", value: tab, children: _jsx(SearchResultsList, { activeOccurrenceStart: activeOccurrenceStart != null &&
|
|
220
|
+
shouldScrollActiveOccurrence
|
|
221
|
+
? activeOccurrenceStart
|
|
222
|
+
: undefined, activePassageUuid: activePassageUuid, query: searchQuery, results: results[tab], onCardClick: onCardClick }) }, tab)))] })) : (_jsx("div", { className: "mt-4 text-secondary-foreground", children: "No results found." }))] }))] })] })] }));
|
|
223
|
+
};
|
|
224
|
+
//# sourceMappingURL=SearchButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchButton.js","sourceRoot":"","sources":["../../../../../libs/lib-search/src/lib/ui/SearchButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAGb,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,aAAa,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AAK,EAAE,GAAG,YAEV,KAAC,iBAAiB,IAChB,qBAAqB,EACnB,qBAAqB,IAAI,IAAI;wDAC3B,4BAA4B;wDAC5B,CAAC,CAAC,qBAAqB;wDACvB,CAAC,CAAC,SAAS,EAEf,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EACrB,WAAW,EAAE,WAAW,GACxB,IAfG,GAAG,CAgBI,CACf,CACJ,IACI,CACR,CAAC,CAAC,CAAC,CACF,cAAK,SAAS,EAAC,gCAAgC,kCAEzC,CACP,IACA,CACJ,IACG,IACQ,IACT,CACV,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AlignmentMatch, BibliographyMatch, GlossaryMatch, PassageMatch, SearchResult } from '../types';
|
|
2
|
+
export declare const PassageResult: ({ activeOccurrenceStart, match, query, }: {
|
|
3
|
+
activeOccurrenceStart?: number;
|
|
4
|
+
match: PassageMatch;
|
|
5
|
+
query: string;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const AlignmentResult: ({ activeOccurrenceStart, match, query, }: {
|
|
8
|
+
activeOccurrenceStart?: number;
|
|
9
|
+
match: AlignmentMatch;
|
|
10
|
+
query: string;
|
|
11
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const BibliographyResult: ({ match, query, }: {
|
|
13
|
+
match: BibliographyMatch;
|
|
14
|
+
query: string;
|
|
15
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const GlossaryResult: ({ match, query, }: {
|
|
17
|
+
match: GlossaryMatch;
|
|
18
|
+
query: string;
|
|
19
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare const SearchResultCard: ({ isActive, activeOccurrenceStart, match, query, onClick, }: {
|
|
21
|
+
isActive?: boolean;
|
|
22
|
+
activeOccurrenceStart?: number;
|
|
23
|
+
match: SearchResult;
|
|
24
|
+
query: string;
|
|
25
|
+
onClick: () => void;
|
|
26
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { highlightText, removeDiacritics, removeHtmlTags, useIsMobile } from '@eightyfourthousand/lib-utils';
|
|
4
|
+
import { Separator } from '@eightyfourthousand/design-system';
|
|
5
|
+
const renderPassageHighlight = ({ activeOccurrenceStart, query, text, }) => {
|
|
6
|
+
if (!query.trim()) {
|
|
7
|
+
return text;
|
|
8
|
+
}
|
|
9
|
+
const escapedQuery = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
10
|
+
const parts = text.split(new RegExp(`(${escapedQuery})`, 'gi'));
|
|
11
|
+
let offset = 0;
|
|
12
|
+
return parts.map((part, index) => {
|
|
13
|
+
const isMatch = part.toLowerCase() === query.toLowerCase();
|
|
14
|
+
if (!isMatch) {
|
|
15
|
+
offset += part.length;
|
|
16
|
+
return part;
|
|
17
|
+
}
|
|
18
|
+
const start = offset;
|
|
19
|
+
offset += part.length;
|
|
20
|
+
return (_jsx("mark", { className: start === activeOccurrenceStart
|
|
21
|
+
? 'bg-accent/20 text-foreground font-semibold ring-2 ring-accent ring-offset-1 ring-offset-background rounded-sm'
|
|
22
|
+
: 'bg-highlight text-foreground font-semibold', children: part }, index));
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export const PassageResult = ({ activeOccurrenceStart, match, query, }) => {
|
|
26
|
+
return (_jsx("div", { children: renderPassageHighlight({
|
|
27
|
+
activeOccurrenceStart,
|
|
28
|
+
query,
|
|
29
|
+
text: match.content,
|
|
30
|
+
}) }));
|
|
31
|
+
};
|
|
32
|
+
export const AlignmentResult = ({ activeOccurrenceStart, match, query, }) => {
|
|
33
|
+
return (_jsxs("div", { className: "grid md:grid-cols-2 gap-4", children: [_jsx("div", { children: renderPassageHighlight({
|
|
34
|
+
activeOccurrenceStart,
|
|
35
|
+
query,
|
|
36
|
+
text: match.content,
|
|
37
|
+
}) }), _jsx("div", { className: "text-lg", children: highlightText(match.source, query) })] }));
|
|
38
|
+
};
|
|
39
|
+
export const BibliographyResult = ({ match, query, }) => {
|
|
40
|
+
return _jsx("div", { children: highlightText(removeHtmlTags(match.content), query) });
|
|
41
|
+
};
|
|
42
|
+
export const GlossaryResult = ({ match, query, }) => {
|
|
43
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: 'text-primary font-bold', children: highlightText(removeDiacritics(match.content), removeDiacritics(query)) }), match.entry.definition && _jsx("div", { className: "glossary-instance-definition", dangerouslySetInnerHTML: { __html: match.entry.definition } })] }));
|
|
44
|
+
};
|
|
45
|
+
export const SearchResultCard = ({ isActive = false, activeOccurrenceStart, match, query, onClick, }) => {
|
|
46
|
+
const isMobile = useIsMobile();
|
|
47
|
+
// cast as passage but treat properties as optional
|
|
48
|
+
const passage = match;
|
|
49
|
+
const renderInner = (match) => {
|
|
50
|
+
switch (match.type) {
|
|
51
|
+
case 'passage':
|
|
52
|
+
return (_jsx(PassageResult, { activeOccurrenceStart: isActive ? activeOccurrenceStart : undefined, match: match, query: query }));
|
|
53
|
+
case 'alignment':
|
|
54
|
+
return (_jsx(AlignmentResult, { activeOccurrenceStart: isActive ? activeOccurrenceStart : undefined, match: match, query: query }));
|
|
55
|
+
case 'bibliography':
|
|
56
|
+
return (_jsx(BibliographyResult, { match: match, query: query }));
|
|
57
|
+
case 'glossary':
|
|
58
|
+
return _jsx(GlossaryResult, { match: match, query: query });
|
|
59
|
+
default:
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return (_jsxs("div", { onClick: onClick, "data-search-result-active": isActive ? 'true' : undefined, className: `flex flex-col md:flex-row gap-4 py-6 px-4 md:px-6 font-serif text-sm text-foreground rounded-lg bg-background cursor-pointer border transition-colors ${isActive
|
|
64
|
+
? 'border-accent border-2 scroll-mt-4'
|
|
65
|
+
: 'border-transparent hover:border-secondary border-2'}`, children: [_jsxs("div", { className: "md:w-28 shrink-0 flex md:flex-col gap-1 md:gap-2 md:text-right text-xs md:text-sm", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("span", { className: "text-secondary capitalize", children: passage.type }), passage.section && (_jsx("span", { className: "text-foreground/50 capitalize", children: passage.section.replace('Header', '') }))] }), _jsx("div", { className: "grow" }), passage.label && (_jsx("span", { className: "text-accent mt-auto", children: passage.label }))] }), _jsx(Separator, { orientation: isMobile ? 'horizontal' : 'vertical' }), renderInner(match)] }));
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=SearchResultCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchResultCard.js","sourceRoot":"","sources":["../../../../../libs/lib-search/src/lib/ui/SearchResultCard.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAQ7G,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,MAAM,sBAAsB,GAAG,CAAC,EAC9B,qBAAqB,EACrB,KAAK,EACL,IAAI,GAKL,EAAE,EAAE;IACH,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,YAAY,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IAChE,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC/B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AO,CACL,KAAC,kBAAkB,IACjB,KAAK,EAAE,KAA0B,EACjC,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;YACJ,KAAK,UAAU;gBACb,OAAO,KAAC,cAAc,IAAC,KAAK,EAAE,KAAsB,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC;YACzE;gBACE,OAAO,IAAI,CAAC;QAChB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,eACE,OAAO,EAAE,OAAO,+BACW,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EACxD,SAAS,EAAE,yJAAyJ,QAAQ;YAC1K,CAAC,CAAC,oCAAoC;YACtC,CAAC,CAAC,oDACF,EAAE,aAEJ,eAAK,SAAS,EAAC,mFAAmF,aAChG,eAAK,SAAS,EAAC,qBAAqB,aAClC,eAAM,SAAS,EAAC,2BAA2B,YAAE,OAAO,CAAC,IAAI,GAAQ,EAChE,OAAO,CAAC,OAAO,IAAI,CAClB,eAAM,SAAS,EAAC,+BAA+B,YAC5C,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,GACjC,CACR,IACG,EACN,cAAK,SAAS,EAAC,MAAM,GAAG,EACvB,OAAO,CAAC,KAAK,IAAI,CAChB,eAAM,SAAS,EAAC,qBAAqB,YAAE,OAAO,CAAC,KAAK,GAAQ,CAC7D,IACG,EACN,KAAC,SAAS,IAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,GAAI,EAC/D,WAAW,CAAC,KAAK,CAAC,IACf,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TabsList, TabsTrigger } from '@eightyfourthousand/design-system';
|
|
3
|
+
import { RESULTS_ENTITIES, RESULTS_ENTITY_LABELS } from '../types';
|
|
4
|
+
export const SearchResultTabs = ({ results }) => {
|
|
5
|
+
return (_jsx(TabsList, { className: "h-24 gap-4 flex-shrink-0 rounded-lg p-0 w-full bg-transparent sm:p-0", children: RESULTS_ENTITIES.map((tab) => results[tab].length > 0 && (_jsx(TabsTrigger, { value: tab, className: "h-full border border-border rounded-xl flex-grow data-[state=inactive]:bg-muted data-[state=active]:border-secondary data-[state=active]:border-3 border-2", children: _jsxs("div", { className: "flex flex-col gap-1 items-center", children: [_jsx("span", { className: "text-secondary font-bold", children: RESULTS_ENTITY_LABELS[tab] }), _jsxs("span", { className: "text-primary font-bold", children: [results[tab].length, " matches"] })] }) }, tab))) }));
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=SearchResultTab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchResultTab.js","sourceRoot":"","sources":["../../../../../libs/lib-search/src/lib/ui/SearchResultTab.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAiB,MAAM,UAAU,CAAC;AAElF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAE,OAAO,EAA8B,EAAE,EAAE;IAC1E,OAAO,CACL,KAAC,QAAQ,IAAC,SAAS,EAAC,sEAAsE,YACvF,gBAAgB,CAAC,GAAG,CACnB,CAAC,GAAG,EAAE,EAAE,CACN,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CACzB,KAAC,WAAW,IAEV,KAAK,EAAE,GAAG,EACV,SAAS,EAAC,4JAA4J,YAEtK,eAAK,SAAS,EAAC,kCAAkC,aAC/C,eAAM,SAAS,EAAC,0BAA0B,YACvC,qBAAqB,CAAC,GAAG,CAAC,GACtB,EACP,gBAAM,SAAS,EAAC,wBAAwB,aACrC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,gBACf,IACH,IAXD,GAAG,CAYI,CACf,CACJ,GACQ,CACZ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SearchResult } from '../types';
|
|
2
|
+
export declare const SearchResultsList: ({ activeOccurrenceStart, activePassageUuid, query, results, onCardClick, }: {
|
|
3
|
+
activeOccurrenceStart?: number;
|
|
4
|
+
activePassageUuid?: string;
|
|
5
|
+
query: string;
|
|
6
|
+
results: SearchResult[];
|
|
7
|
+
onCardClick: (result: SearchResult) => void;
|
|
8
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SearchResultCard } from './SearchResultCard';
|
|
3
|
+
export const SearchResultsList = ({ activeOccurrenceStart, activePassageUuid, query, results, onCardClick, }) => {
|
|
4
|
+
return (_jsx("div", { className: "h-full flex flex-col gap-3 pb-4 overflow-y-auto min-h-0", children: results.map((result, index) => {
|
|
5
|
+
const start = result.uuid === activePassageUuid ? activeOccurrenceStart : undefined;
|
|
6
|
+
const isActive = !!start;
|
|
7
|
+
return (_jsx(SearchResultCard, { activeOccurrenceStart: start, isActive: isActive, match: result, query: query, onClick: () => onCardClick(result) }, index));
|
|
8
|
+
}) }));
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=SearchResultsList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchResultsList.js","sourceRoot":"","sources":["../../../../../libs/lib-search/src/lib/ui/SearchResultsList.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,qBAAqB,EACrB,iBAAiB,EACjB,KAAK,EACL,OAAO,EACP,WAAW,GAOZ,EAAE,EAAE;IACH,OAAO,CACL,cAAK,SAAS,EAAC,yDAAyD,YACrE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,SAAS,CAAC;YACpF,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC;YACzB,OAAO,CACL,KAAC,gBAAgB,IAEf,qBAAqB,EAAE,KAAK,EAC5B,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,IAL7B,KAAK,CAMV,CACH,CAAA;QACH,CAAC,CAAC,GACE,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/ui/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/lib-search/src/lib/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|