# All files / text-field text-field.tsx

100% Statements 12/12
100% Branches 6/6
100% Functions 3/3
100% Lines 12/12

    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
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    531x

    1x
    1x

    1x
    1x

    1x

    12x

    12x

    12x

    1x
    1x
    1x
     import * as React from "react";
    import * as ReactDOM from "react-dom";
    import Foundation, { HandledProps } from "@microsoft/fast-components-foundation-react";
    import {
        TextFieldHandledProps,
        TextFieldManagedClasses,
        TextFieldType,
        TextFieldUnhandledProps
    } from "./text-field.props";
    import { ManagedClasses, TextFieldClassNameContract } from "@microsoft/fast-components-class-name-contracts-base";
    import { get } from "lodash-es";

    class TextField extends Foundation<
        TextFieldHandledProps,
        TextFieldUnhandledProps,
        {}
    > {
        public static displayName: string = "TextField";

        protected handledProps: HandledProps<TextFieldHandledProps> = {
            disabled: void 0,
            placeholder: void 0,
            managedClasses: void 0,
            type: void 0
        };

        /**
         * Renders the component
         */
        public render(): React.ReactElement<HTMLInputElement> {
            return (
                <input
                    {...this.unhandledProps()}
                    className={this.generateClassNames()}
                    disabled={this.props.disabled || null}
                    placeholder={this.props.placeholder || null}
                    type={this.props.type || TextFieldType.text}
                />
            );
        }

        /**
         * Generates class names
         */
        protected generateClassNames(): string {
            return super.generateClassNames(get(this.props, "managedClasses.textField"));
        }
    }

    export default TextField;
    export * from "./text-field.props";
    export { TextFieldClassNameContract };