/
parameter.tsx
132 lines (128 loc) · 6.6 KB
/
parameter.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import { renderFlags, wbr } from "../../lib";
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
import { JSX } from "../../../../utils";
import { DeclarationReflection, ReflectionType } from "../../../../models";
export const parameter = (context: DefaultThemeRenderContext, props: DeclarationReflection) => (
<>
<ul class="tsd-parameters">
{!!props.signatures && (
<li class="tsd-parameter-signature">
<ul class={"tsd-signatures " + props.cssClasses}>
{props.signatures.map((item) => (
<>
<li class="tsd-signature" id={item.anchor}>
{context.memberSignatureTitle(item, {
hideName: true,
})}
</li>
<li class="tsd-description">
{context.memberSignatureBody(item, {
hideSources: true,
})}
</li>
</>
))}
</ul>
</li>
)}
{!!props.indexSignature && (
<>
<li class="tsd-parameter-index-signature">
<h5>
<span class="tsd-signature-symbol">[</span>
{props.indexSignature?.parameters?.map((item) => (
<>
{!!item.flags.isRest && <span class="tsd-signature-symbol">...</span>}
{item.name}
{": "}
{context.type(item.type)}
</>
))}
<span class="tsd-signature-symbol">{"]: "}</span>
{context.type(props.indexSignature.type)}
</h5>
{context.comment(props.indexSignature)}
{props.indexSignature.type instanceof ReflectionType &&
context.parameter(props.indexSignature.type.declaration)}
</li>
</>
)}
{props.children?.map((item) => (
<>
{item.signatures ? (
<li class="tsd-parameter">
<h5>
{!!item.flags.isRest && <span class="tsd-signature-symbol">...</span>}
{wbr(item.name)}
<span class="tsd-signature-symbol">{!!item.flags.isOptional && "?"}:</span>
function
</h5>
{context.memberSignatures(item)}
</li>
) : item.type ? (
<>
{/* standard type */}
<li class="tsd-parameter">
<h5>
{renderFlags(item.flags, item.comment)}
{!!item.flags.isRest && <span class="tsd-signature-symbol">...</span>}
{wbr(item.name)}
<span class="tsd-signature-symbol">
{!!item.flags.isOptional && "?"}
{": "}
</span>
{context.type(item.type)}
</h5>
{context.comment(item)}
{!!item.children && context.parameter(item)}
{item.type instanceof ReflectionType && context.parameter(item.type.declaration)}
</li>
</>
) : (
<>
{/* getter/setter */}
{item.getSignature && (
<>
{/* getter */}
<li class="tsd-parameter">
<h5>
{renderFlags(item.getSignature.flags, item.getSignature.comment)}
<span class="tsd-signature-symbol">get </span>
{wbr(item.name)}
<span class="tsd-signature-symbol">(): </span>
{context.type(item.getSignature.type)}
</h5>
{context.comment(item.getSignature)}
</li>
</>
)}
{item.setSignature && (
<>
{/* setter */}
<li class="tsd-parameter">
<h5>
{renderFlags(item.setSignature.flags, item.setSignature.comment)}
<span class="tsd-signature-symbol">set </span>
{wbr(item.name)}
<span class="tsd-signature-symbol">(</span>
{item.setSignature.parameters?.map((item) => (
<>
{item.name}
<span class="tsd-signature-symbol">: </span>
{context.type(item.type)}
</>
))}
<span class="tsd-signature-symbol">): </span>
{context.type(item.setSignature.type)}
</h5>
{context.comment(item.setSignature)}
</li>
</>
)}
</>
)}
</>
))}
</ul>
</>
);