aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/pages/documentation/enum.tsx
blob: 8fcd2c252a8030a946faa1d86dbedc657e51c50f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import * as _ from 'lodash';
import * as React from 'react';
import {EnumValue, TypeDocNode} from 'ts/types';
import {utils} from 'ts/utils/utils';

const STRING_ENUM_CODE_PREFIX = ' strEnum(';

interface EnumProps {
    values: EnumValue[];
}

export function Enum(props: EnumProps) {
    const values = _.map(props.values, (value, i) => {
        const isLast = i === props.values.length - 1;
        const defaultValueIfAny = !_.isUndefined(value.defaultValue) ? ` = ${value.defaultValue}` : '';
        return `\n\t${value.name}${defaultValueIfAny},`;
    });
    return (
        <span>
            {`{`}
                {values}
                <br />
            {`}`}
        </span>
    );
}