-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves #2616
- Loading branch information
Showing
9 changed files
with
141 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,61 @@ | ||
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import { JSX } from "../../../../utils"; | ||
import { type ContainerReflection, DeclarationReflection } from "../../../../models"; | ||
import { classNames } from "../../lib"; | ||
import { filterMap, JSX } from "../../../../utils"; | ||
import type { ContainerReflection } from "../../../../models"; | ||
|
||
export function members(context: DefaultThemeRenderContext, props: ContainerReflection) { | ||
if (props.categories && props.categories.length) { | ||
return ( | ||
<> | ||
{props.categories.map( | ||
(item) => | ||
!item.allChildrenHaveOwnDocument() && ( | ||
<details | ||
class={classNames( | ||
{ "tsd-panel-group": true, "tsd-member-group": true, "tsd-accordion": true }, | ||
props instanceof DeclarationReflection ? context.getReflectionClasses(props) : "", | ||
)} | ||
> | ||
<summary class="tsd-accordion-summary" data-key={"section-" + item.title}> | ||
<h2> | ||
{context.icons.chevronDown()} {item.title} | ||
</h2> | ||
</summary> | ||
<section> | ||
{item.children.map((item) => !item.hasOwnDocument && context.member(item))} | ||
</section> | ||
</details> | ||
), | ||
)} | ||
</> | ||
); | ||
function getMemberSections(parent: ContainerReflection) { | ||
if (parent.categories?.length) { | ||
return filterMap(parent.categories, (cat) => { | ||
if (!cat.allChildrenHaveOwnDocument()) { | ||
return { | ||
title: cat.title, | ||
children: cat.children.filter((child) => !child.hasOwnDocument), | ||
}; | ||
} | ||
}); | ||
} | ||
|
||
return <>{props.groups?.map((item) => !item.allChildrenHaveOwnDocument() && context.membersGroup(item))}</>; | ||
if (parent.groups?.length) { | ||
return parent.groups.flatMap((group) => { | ||
if (group.categories?.length) { | ||
return filterMap(group.categories, (cat) => { | ||
if (!cat.allChildrenHaveOwnDocument()) { | ||
return { | ||
title: `${group.title} - ${cat.title}`, | ||
children: cat.children.filter((child) => !child.hasOwnDocument), | ||
}; | ||
} | ||
}); | ||
} | ||
|
||
return { | ||
title: group.title, | ||
children: group.children.filter((child) => !child.hasOwnDocument), | ||
}; | ||
}); | ||
} | ||
|
||
return []; | ||
} | ||
|
||
export function members(context: DefaultThemeRenderContext, props: ContainerReflection) { | ||
const sections = getMemberSections(props).filter((sect) => sect.children.length); | ||
|
||
return ( | ||
<> | ||
{sections.map(({ title, children }) => { | ||
context.page.startNewSection(title); | ||
|
||
return ( | ||
<details class="tsd-panel-group tsd-member-group tsd-accordion" open> | ||
<summary class="tsd-accordion-summary" data-key={"section-" + title}> | ||
<h2> | ||
{context.icons.chevronDown()} {title} | ||
</h2> | ||
</summary> | ||
<section>{children.map((item) => context.member(item))}</section> | ||
</details> | ||
); | ||
})} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters