-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform-bible-react.tsx
More file actions
84 lines (78 loc) · 2.34 KB
/
Copy pathplatform-bible-react.tsx
File metadata and controls
84 lines (78 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* @file Jest mock for platform-bible-react. The real package ships ESM which Jest cannot parse
* without extra transform configuration. This stub provides the subset used by extension
* components: `BookChapterControl`, `BOOK_CHAPTER_CONTROL_STRING_KEYS`, `TabToolbar`, and
* `ScrollGroupSelector`.
*/
import type { ReactElement, ReactNode } from 'react';
interface SerializedVerseRef {
book: string;
chapterNum: number;
verseNum: number;
verse?: string;
versificationStr?: string;
}
export const BOOK_CHAPTER_CONTROL_STRING_KEYS: string[] = [];
export function TabToolbar({
startAreaChildren,
endAreaChildren,
}: Readonly<{
className?: string;
startAreaChildren?: ReactNode;
endAreaChildren?: ReactNode;
onSelectProjectMenuItem?: () => void;
onSelectViewInfoMenuItem?: () => void;
}>): ReactElement {
return (
<div data-testid="tab-toolbar">
<div data-testid="tab-toolbar-start">{startAreaChildren}</div>
<div data-testid="tab-toolbar-end">{endAreaChildren}</div>
</div>
);
}
export function ScrollGroupSelector({
availableScrollGroupIds,
scrollGroupId,
onChangeScrollGroupId,
}: Readonly<{
availableScrollGroupIds?: (number | undefined)[];
scrollGroupId?: number;
onChangeScrollGroupId?: (id: number | undefined) => void;
}>): ReactElement {
return (
<select
data-testid="scroll-group-selector"
value={scrollGroupId ?? ''}
onChange={(e) => onChangeScrollGroupId?.(e.target.value === '' ? undefined : Number(e.target.value))}
>
<option value="">—</option>
{availableScrollGroupIds?.map((id) => (
<option key={id ?? 'undefined'} value={id ?? ''}>
{id ?? '—'}
</option>
))}
</select>
);
}
export function BookChapterControl({
scrRef,
handleSubmit,
onAddRecentSearch,
}: Readonly<{
scrRef: SerializedVerseRef;
handleSubmit: (ref: SerializedVerseRef) => void;
className?: string;
localizedStrings?: Record<string, string>;
recentSearches?: SerializedVerseRef[];
onAddRecentSearch?: (scrRef: SerializedVerseRef) => void;
id?: string;
}>): ReactElement {
return (
<div data-testid="book-chapter-control">
{scrRef.book} {scrRef.chapterNum}:{scrRef.verseNum}
<button type="button" onClick={() => {handleSubmit(scrRef); onAddRecentSearch?.(scrRef);}}>
Submit reference
</button>
</div>
);
}