<commit_before>/**
 * Field Component for tingle
 * @author gnosaij
 *
 * Copyright 2014-2015, Tingle Team, Alinw.
 * All rights reserved.
 */
let Context = require('tingle-context');
let Field = require('tingle-field');
let Icon = require('tingle-icon');
let classnames = require('classnames');

class TextField extends React.Component {

    constructor(props) {
        super(props);
    }

    handleChange(e) {
        let value = this.props.filter(e.target.value);
        this.props.onChange(value);
    }

    handleFocus(e) {
        let t = this;
        t.props.onFocus(t.props.value);

        // 处理placeholder
        if (t.props.value.length) {
            return;
        }
        React.findDOMNode(t.refs.placeholder).style.display = 'none';
    }

    handleBlur(e) {
        let t = this;
        t.props.onBlur(t.props.value);

        // 处理placeholder
        if (t.props.value.length) {
            return;
        }
        React.findDOMNode(t.refs.placeholder).style.display = 'block';
    }

    handleClear(e) {

        let t = this;

        // TODO fix iOS blur bug
        //setTimeout(()=> {
        React.findDOMNode(t.refs.input).focus();
        //}, 40);

        this.props.onChange('');
    }

    render() {
        let t = this;

        return <Field {...t.props} className={classnames('tTextField', t.props.className, {
            'multiline': t.props.multiLine,
            'readOnly': t.props.readOnly
        })}>
            <div ref="placeholder" className={classnames('tOmit tTextFieldPlaceholder', {
                tDN: !!t.props.value
            })}>{t.props.placeholder}</div>
            {<commit_msg>Update TextField.js<commit_after>/**
 * Field Component for tingle
 * @author gnosaij
 *
 * Copyright 2014-2015, Tingle Team, Alinw.
 * All rights reserved.
 */
let Context = require('tingle-context');
let Field = require('tingle-field');
let Icon = require('tingle-icon');
let classnames = require('classnames');

class TextField extends React.Component {

    constructor(props) {
        super(props);
    }

    handleChange(e) {
        let value = this.props.filter(e.target.value);
        this.props.onChange(value);
    }

    handleFocus(e) {
        let t = this;
        t.props.onFocus(t.props.value);

        if (t.props.value.length || t.props.readOnly) {
            return;
        }
        React.findDOMNode(t.refs.placeholder).style.display = 'none';
    }

    handleBlur(e) {
        let t = this;
        t.props.onBlur(t.props.value);

        if (t.props.value.length || t.props.readOnly) {
            return;
        }
        React.findDOMNode(t.refs.placeholder).style.display = 'block';
    }

    handleClear(e) {

        let t = this;

        // TODO fix iOS blur bug
        //setTimeout(()=> {
        React.findDOMNode(t.refs.input).focus();
        //}, 40);

        this.props.onChange('');
    }

    render() {
        let t = this;

        return <Field {...t.props} className={classnames('tTextField', t.props.className, {
            'multiline': t.props.multiLine,
            'readOnly': t.props.readOnly
        })}>
            <div ref="placeholder" className={classnames('tOmit tTextFieldPlaceholder', {
                tDN: !!t.props.value
            })}>{t.props.placeholder}</div>
            {
{'fraction_non_alphanumeric': 0.1485178463399879, 'fraction_numerical': 0.006049606775559589, 'mean_word_length': 1.9927601809954751, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6491594', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1016, 'n_words': 187}