mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
* refactor: minify api.json by shortening keys * fix: links to other packages * refactor: get doclink from canonicalReference, not model * fix: types * fix: again * fix: @link tags with alt texts
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import type { ApiDocumentedItem, ApiParameterListMixin } from '@discordjs/api-extractor-model';
|
|
import { useMemo } from 'react';
|
|
import { resolveParameters } from '~/util/model';
|
|
import { ExcerptText } from './ExcerptText';
|
|
import { Table } from './Table';
|
|
import { TSDoc } from './documentation/tsdoc/TSDoc';
|
|
|
|
const columnStyles = {
|
|
Name: 'font-mono whitespace-nowrap',
|
|
Type: 'font-mono whitespace-pre-wrap break-normal',
|
|
};
|
|
|
|
export function ParameterTable({ item }: { readonly item: ApiDocumentedItem & ApiParameterListMixin }) {
|
|
const params = resolveParameters(item);
|
|
|
|
const rows = useMemo(
|
|
() =>
|
|
params.map((param) => ({
|
|
Name: param.isRest ? `...${param.name}` : param.name,
|
|
Type: <ExcerptText excerpt={param.parameterTypeExcerpt} />,
|
|
Optional: param.isOptional ? 'Yes' : 'No',
|
|
Description: param.description ? <TSDoc item={item} tsdoc={param.description} /> : 'None',
|
|
})),
|
|
[item, params],
|
|
);
|
|
|
|
return (
|
|
<div className="overflow-x-auto">
|
|
<Table columnStyles={columnStyles} columns={['Name', 'Type', 'Optional', 'Description']} rows={rows} />
|
|
</div>
|
|
);
|
|
}
|