<commit_before>import React from 'react';
import shallowCompare from 'react-addons-shallow-compare';
import classNames from 'classnames';
import elementType from 'react-prop-types/lib/elementType';
import { validateClassProps, hasChild } from '../../utilities';
import DefaultProps from '../../defaultProps';
import Icon from '../icon/icon';
import Image from '../image/image';

let validProps = {
    aligned: ['right', 'left', 'justified', 'center'],
    attached: ['bottom', 'top'],
    floated: ['right', 'left']
};

export default class Header extends React.Component {
    static propTypes = {
        ...DefaultProps.propTypes,
        /**
         * A header can have its text aligned to a side
         */
        aligned: React.PropTypes.oneOf(['right', 'left', 'justified', 'center']),
        /**
         * A header can be attached to other content, like a segment
         */
        attached: React.PropTypes.oneOfType([
            React.PropTypes.oneOf(['bottom', 'top']),
            React.PropTypes.bool
        ]),
        /**
         * A header can be formatted with different colors
         */
        color: React.PropTypes.string,
        /**
         * A header can show that it is inactive
         */
        disabled: React.PropTypes.bool,
        /**
         * Header may be used as divider
         */
        divider: React.PropTypes.bool,
        /**
         * dividing: can be formatted to divide itself from the content below it
         * block: can be formatted to appear inside a content block
         */
        emphasis: React.PropTypes.oneOf(['dividing', 'block']),
        /**
         * A header can sit to the left or right of other content
         */
        floated: React.PropTypes.oneOf(['right', 'left']),
        /**
         * Icon name for header. This will turn header into icon header (ui icon header)
         */
        icon: React.PropTypes.string,
        /**
         * Icon component
         */
        iconComponent: elementType,
        /**
         * A header can have its colors inverted for contrast
         */
        inverted: React.PropTypes.bool,
        /**
         * May be used as menu item
         */
        item: React.PropTypes.bool,
        /**
         * May have various sizes
         */
        size: React.PropTypes.string
    };

    // we don't want the ui in these circumstances
    static contextTypes = {
        isListChild: React.PropTypes.bool,
        isHeaderChild: React.PropTypes.bool,
        isAccordionChild: React.PropTypes.bool,
        isMenuChild: React.PropTypes.bool,
        isCardChild: React.PropTypes.bool,
        isModalChild: React.PropTypes.bool
    };

    // any header/sub header under a header is a sub header
    static childContextTypes = {
        isHeaderChild: React.PropTypes.bool
    };

    static defaultProps = {
        ...DefaultProps.defaultProps,
        attached: false,
        item: true // handles
    };

    /* eslint-disable */
    static Components = {
        Icon: Icon,
        Image: Image
    };
    /* eslint-enable */

    getChildContext() {
        return {
            isHeaderChild: true
        };
    }

    shouldComponentUpdate(nextProps, nextState) {
        return shallowCompare(this, nextProps, nextState);
    }

    render() {

        /* eslint-disable no-use-before-define */
        let { 
            aligned, attached, children, className, color, component,
            defaultClasses, disabled, divider, emphasis, floated,
            horizontal, icon, iconComponent, inverted, item, size, ...other 
        } = this.props;
        /* eslint-enable no-use-before-define */

        // add class names
        other.className = classNames(other.className, this.getClasses());
        const IconComponent = iconComponent || Header.Components.Icon;
        let Component = component;
        if (Component === 'div' && this.props.onClick) {
            Component = 'a';
        }
        
        return (
            <Component {...other}>
                {icon &&
                <IconComponent name={icon}/>
                }
                {children}
            </Component>
        );

    }
    
    shouldHaveUiClass() {
        if (!this.props.defaultClasses) {<commit_msg>fix add custom class for header<commit_after>import React from 'react';
import shallowCompare from 'react-addons-shallow-compare';
import classNames from 'classnames';
import elementType from 'react-prop-types/lib/elementType';
import { validateClassProps, hasChild } from '../../utilities';
import DefaultProps from '../../defaultProps';
import Icon from '../icon/icon';
import Image from '../image/image';

let validProps = {
    aligned: ['right', 'left', 'justified', 'center'],
    attached: ['bottom', 'top'],
    floated: ['right', 'left']
};

export default class Header extends React.Component {
    static propTypes = {
        ...DefaultProps.propTypes,
        /**
         * A header can have its text aligned to a side
         */
        aligned: React.PropTypes.oneOf(['right', 'left', 'justified', 'center']),
        /**
         * A header can be attached to other content, like a segment
         */
        attached: React.PropTypes.oneOfType([
            React.PropTypes.oneOf(['bottom', 'top']),
            React.PropTypes.bool
        ]),
        /**
         * A header can be formatted with different colors
         */
        color: React.PropTypes.string,
        /**
         * A header can show that it is inactive
         */
        disabled: React.PropTypes.bool,
        /**
         * Header may be used as divider
         */
        divider: React.PropTypes.bool,
        /**
         * dividing: can be formatted to divide itself from the content below it
         * block: can be formatted to appear inside a content block
         */
        emphasis: React.PropTypes.oneOf(['dividing', 'block']),
        /**
         * A header can sit to the left or right of other content
         */
        floated: React.PropTypes.oneOf(['right', 'left']),
        /**
         * Icon name for header. This will turn header into icon header (ui icon header)
         */
        icon: React.PropTypes.string,
        /**
         * Icon component
         */
        iconComponent: elementType,
        /**
         * A header can have its colors inverted for contrast
         */
        inverted: React.PropTypes.bool,
        /**
         * May be used as menu item
         */
        item: React.PropTypes.bool,
        /**
         * May have various sizes
         */
        size: React.PropTypes.string
    };

    // we don't want the ui in these circumstances
    static contextTypes = {
        isListChild: React.PropTypes.bool,
        isHeaderChild: React.PropTypes.bool,
        isAccordionChild: React.PropTypes.bool,
        isMenuChild: React.PropTypes.bool,
        isCardChild: React.PropTypes.bool,
        isModalChild: React.PropTypes.bool
    };

    // any header/sub header under a header is a sub header
    static childContextTypes = {
        isHeaderChild: React.PropTypes.bool
    };

    static defaultProps = {
        ...DefaultProps.defaultProps,
        attached: false,
        item: true // handles
    };

    /* eslint-disable */
    static Components = {
        Icon: Icon,
        Image: Image
    };
    /* eslint-enable */

    getChildContext() {
        return {
            isHeaderChild: true
        };
    }

    shouldComponentUpdate(nextProps, nextState) {
        return shallowCompare(this, nextProps, nextState);
    }

    render() {

        /* eslint-disable no-use-before-define */
        let { 
            aligned, attached, children, color, component,
            defaultClasses, disabled, divider, emphasis, floated,
            horizontal, icon, iconComponent, inverted, item, size, ...other 
        } = this.props;
        /* eslint-enable no-use-before-define */

        // add class names
        other.className = classNames(other.className, this.getClasses());
        const IconComponent = iconComponent || Header.Components.Icon;
        let Component = component;
        if (Component === 'div' && this.props.onClick) {
            Component = 'a';
        }
        
        return (
            <Component {...other}>
                {icon &&
                <IconComponent name={icon}/>
                }
                {children}
            </Component>
        );

    }
    
    shouldHaveUiClass() {
        if (!this.props.defaultClasses) {
{'fraction_non_alphanumeric': 0.11359097850346529, 'fraction_numerical': 0.0, 'mean_word_length': 1.8126858275520317, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2389186', 'n_tokens_mistral': 2240, 'n_tokens_neox': 2203, 'n_words': 636}