import React from 'react';
import PropTypes from 'prop-types';

import {CommonListHighlight} from '../common/CommonListHighlight';

export class ListHighlight extends React.Component {
    static propTypes = CommonListHighlight.propTypes;
    static defaultProps = CommonListHighlight.defaultProps;
    static contextTypes = {
        listStore: PropTypes.object
    };

    static HIGHLIGHT_TYPE_BACKGROUND = CommonListHighlight.HIGHLIGHT_TYPE_BACKGROUND;
    static HIGHLIGHT_TYPE_BOLD = CommonListHighlight.HIGHLIGHT_TYPE_BOLD;

    getTextHighlightPattern() {
        return this.props.textHighlightPattern || this.context.listStore.textHighlightPattern;
    }

    getTextFilterPattern() {
        return this.props.textFilterPattern || this.context.listStore.textFilterPattern;
    }

    render() {
        return (
            <CommonListHighlight
                {...this.props}
                textHighlightPattern={this.getTextHighlightPattern()}
                textFilterPattern={this.getTextFilterPattern()}
            />
        );
    }
}
