# All files / tabs tab-panel.tsx

100% Statements 10/10
100% Branches 2/2
100% Functions 3/3
100% Lines 10/10

    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
    53
    541x
    1x
    1x

    1x

    1x

    29x

    59x

    59x

    1x
    1x
     import * as React from "react";
    import { get } from "lodash-es";
    import Foundation, { HandledProps } from "@microsoft/fast-components-foundation-react";
    import { ManagedClasses, TabPanelClassNameContract } from "@microsoft/fast-components-class-name-contracts-base";
    import { TabPanelHandledProps, TabPanelManagedClasses, TabPanelProps, TabPanelUnhandledProps } from "./tab-panel.props";

    class TabPanel extends Foundation<
        TabPanelHandledProps,
        TabPanelUnhandledProps,
        {}
    > {
        public static defaultProps: Partial<TabPanelProps> = {
            active: false
        };

        public static displayName: string = "TabPanel";

        protected handledProps: HandledProps<TabPanelHandledProps> = {
            managedClasses: void 0,
            active: void 0,
            slot: void 0
        };

        /**
         * Renders the component
         */
        public render(): JSX.Element {
            return (
                <div
                    {...this.unhandledProps()}
                    role="tabpanel"
                    aria-hidden={!this.props.active}
                    className={this.generateClassNames()}
                >
                    {this.props.children}
                </div>
            );
        }

        /**
         * Generates class names based on props
         */
        protected generateClassNames(): string {
            return this.props.active
                ? super.generateClassNames(get(this.props, "managedClasses.tabPanel"))
                : super.generateClassNames(
                    `${get(this.props, "managedClasses.tabPanel")} ${get(this.props, "managedClasses.tabPanel__hidden")}`
                  );
        }
    }

    export default TabPanel;
    export * from "./tab-panel.props";