import type {
ApiClassJSON,
ApiInterfaceJSON,
ParameterDocumentation,
ApiConstructorJSON,
} from '@discordjs/api-extractor-utils';
import { Section } from '@discordjs/ui';
import { useMemo } from 'react';
import { VscSymbolConstant, VscSymbolMethod, VscSymbolProperty } from 'react-icons/vsc';
import { useMedia } from 'react-use';
import { MethodList } from './MethodList';
import { ParameterTable } from './ParameterTable';
import { PropertyList } from './PropertyList';
import { TSDoc } from './tsdoc/TSDoc';
export function PropertiesSection({ data }: { data: ApiClassJSON['properties'] | ApiInterfaceJSON['properties'] }) {
const matches = useMedia('(max-width: 768px)', true);
return data.length ? (
} padded title="Properties">
) : null;
}
export function MethodsSection({ data }: { data: ApiClassJSON['methods'] | ApiInterfaceJSON['methods'] }) {
const matches = useMedia('(max-width: 768px)', true);
return data.length ? (
} padded title="Methods">
) : null;
}
export function ParametersSection({ data }: { data: ParameterDocumentation[] }) {
const matches = useMedia('(max-width: 768px)', true);
return data.length ? (
} padded title="Parameters">
) : null;
}
export function ConstructorSection({ data }: { data: ApiConstructorJSON }) {
const matches = useMedia('(max-width: 768px)', true);
const getShorthandName = useMemo(
() =>
`constructor(${data.parameters.reduce((prev, cur, index) => {
if (index === 0) {
return `${prev}${cur.isOptional ? `${cur.name}?` : cur.name}`;
}
return `${prev}, ${cur.isOptional ? `${cur.name}?` : cur.name}`;
}, '')})`,
[data.parameters],
);
return data.parameters.length ? (
} padded title="Constructor">
{data.deprecated || data.protected ? (
{data.deprecated ? (
Deprecated
) : null}
{data.protected ? (
Protected
) : null}
) : null}
{getShorthandName}
{data.summary || data.parameters.length ? (
{data.deprecated ?
: null}
{data.summary ?
: null}
{data.remarks ?
: null}
{data.comment ?
: null}
{data.parameters.length ?
: null}
) : null}
) : null;
}