-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Member.tsx
64 lines (57 loc) · 2.1 KB
/
Member.tsx
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
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/members.hbs
import React from 'react';
import type { JSONOutput } from 'typedoc';
import { useReflection } from '../hooks/useReflection';
import { useReflectionMap } from '../hooks/useReflectionMap';
import { hasOwnDocument } from '../utils/visibility';
import { AnchorLink } from './AnchorLink';
import { CommentBadges, isCommentWithModifiers } from './CommentBadges';
import { Flags } from './Flags';
import { MemberDeclaration } from './MemberDeclaration';
import { MemberGetterSetter } from './MemberGetterSetter';
import { MemberReference } from './MemberReference';
import { MemberSignatures } from './MemberSignatures';
import { SourceLink } from './SourceLink';
export interface MemberProps {
id: number;
}
export function Member({ id }: MemberProps) {
const reflections = useReflectionMap();
const reflection = useReflection(id)!;
const { comment } = reflection;
let content: React.ReactNode = null;
if (reflection.signatures) {
content = <MemberSignatures inPanel sigs={reflection.signatures} />;
} else if (reflection.getSignature || reflection.setSignature) {
content = (
<MemberGetterSetter
inPanel
getter={reflection.getSignature}
setter={reflection.setSignature}
/>
);
} else if ('target' in reflection && (reflection as JSONOutput.ReferenceReflection).target) {
content = <MemberReference reflection={reflection as JSONOutput.ReferenceReflection} />;
} else {
content = <MemberDeclaration id={id} />;
}
return (
<section className="tsd-panel tsd-member">
<h3 className="tsd-panel-header">
<AnchorLink id={reflection.name} />
<SourceLink sources={reflection.sources} />
<Flags flags={reflection.flags} />
{reflection.name}
{isCommentWithModifiers(comment) && <CommentBadges comment={comment} />}
</h3>
{content}
{reflection.groups?.map((group) => (
<React.Fragment key={group.title}>
{group.children?.map((child) =>
hasOwnDocument(child, reflections) ? null : <Member key={child} id={child} />,
)}
</React.Fragment>
))}
</section>
);
}