import { css } from '@emotion/react'; import { EnumDefinitionData, EnumValueData } from '~/components/plugins/api/APIDataTypes'; import { APISectionDeprecationNote } from '~/components/plugins/api/APISectionDeprecationNote'; import { APISectionPlatformTags } from '~/components/plugins/api/APISectionPlatformTags'; import { CommentTextBlock, getTagNamesList, STYLES_APIBOX, STYLES_APIBOX_NESTED, H3Code, } from '~/components/plugins/api/APISectionUtils'; import { H2, H4, CODE, MONOSPACE } from '~/ui/components/Text'; export type APISectionEnumsProps = { data: EnumDefinitionData[]; }; const sortByValue = (a: EnumValueData, b: EnumValueData) => { if (a.type && a.type.value !== undefined && b.type && b.type.value !== undefined) { if (typeof a.type.value === 'string' && typeof b.type.value === 'string') { return a.type.value.localeCompare(b.type.value); } else if (typeof a.type.value === 'number' && typeof b.type.value === 'number') { return (a.type.value ?? Number.MIN_VALUE) - (b.type.value ?? Number.MIN_VALUE); } } return 0; }; const renderEnumValue = (value: any) => (typeof value === 'string' ? `"${value}"` : value); const renderEnum = ({ name, children, comment }: EnumDefinitionData): JSX.Element => (
{enumValue.name}
{`${name}.${enumValue.name} = ${renderEnumValue(enumValue.type.value)}`}