Skip to content

Commit c9a5b32

Browse files
authored
refactor: FunctionSignature return type container (#8717)
* refactor: function return type container * chore: patch and unique key * chore: remove unnecessary container * chore: review updates
1 parent 01b00b6 commit c9a5b32

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

packages/ui-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@node-core/ui-components",
3-
"version": "1.6.2",
3+
"version": "1.6.3",
44
"type": "module",
55
"exports": {
66
"./*": {

packages/ui-components/src/Common/Signature/SignatureRoot/index.module.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
}
1313

1414
.root {
15-
@apply flex
15+
@apply mb-3
16+
flex
1617
flex-col
1718
gap-4
1819
rounded-sm

packages/ui-components/src/Containers/FunctionSignature/index.stories.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ export const Nested: Story = {
118118
},
119119
],
120120
},
121+
{
122+
name: 'Returns',
123+
kind: 'return',
124+
description: 'description',
125+
type: (
126+
<>
127+
<a href="#">&lt;Promise&gt;</a>|
128+
<a href="#">&lt;AsyncIterable&gt;</a>
129+
</>
130+
),
131+
},
121132
],
122133
},
123134
};

packages/ui-components/src/Containers/FunctionSignature/index.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,26 @@ const renderSignature = (param: SignatureDefinition, index: number) => (
2929

3030
const FunctionSignature: FC<FunctionSignatureProps> = ({ title, items }) => {
3131
if (title) {
32+
const attributes: Array<SignatureDefinition> = [];
33+
const returnTypes: Array<SignatureDefinition> = [];
34+
35+
for (const item of items) {
36+
const target = item.kind === 'return' ? returnTypes : attributes;
37+
38+
target.push(item);
39+
}
40+
3241
return (
33-
<Signature title={title}>
34-
{items.map((param, i) => renderSignature(param, i))}
35-
</Signature>
42+
<>
43+
<Signature title={title}>
44+
{attributes.map((param, i) => renderSignature(param, i))}
45+
</Signature>
46+
47+
{returnTypes.length > 0 &&
48+
returnTypes.map((param, i) =>
49+
renderSignature(param, attributes.length + i)
50+
)}
51+
</>
3652
);
3753
}
3854

0 commit comments

Comments
 (0)