<commit_before>var mixins = require( './../../../mixins' );

module.exports = function ( React, tools ) {
    var getOrDefault = tools.getOrDefault
      , getOrNull    = tools.getOrNull;

    return React.createClass({
        displayName: 'SelectRenderer',

        propTypes: {
            config: React.PropTypes.object.isRequired
        },

        mixins: [ mixins.PrimitiveAccessors ],

        /* =========================================================== */
        /* ======================== Lyfe Cycle ======================= */
        /* =========================================================== */
        getDefaultProps: function () {
            return { config: {} };
        },

        /* =========================================================== */
        /* ======================== Handlers ========================= */
        /* =========================================================== */
        handleOnChange: function ( e ) {
            var res = { 
                id:    this._conf().fieldID,
                meta:  this._meta(),
                value: {}
            };

            res.value[ res.id ] = e.target.value; 
            this.handleEvent( 'change' )( e );
            this._conf().onChange( res );
        },

        handleEvent: mixins.handleEvent,

        /* =========================================================== */
        /* ======================== Renders ========================== */
        /* =========================================================== */
        render: function () {
            var config = this._conf()
              , spec   = this._spec()
              , meta   = this._meta();

            return (
                React.createElement("select", {id: config.fieldID, 
                        disabled: meta.isDisabled, 
                        className: "generated-select-field", 
                        value: config.value, 
                        onBlur: this.handleEvent( 'blur'), 
                        onFocus: this.handleEvent( 'focus'), 
                        onChange: this.handleOnChange}, 
                    this.renderItems( spec.possibleValues)
                )
            );
        },

        renderItems: function ( items ) {
            var self   = this
              , config = this._conf()
              , meta   = this._meta();

            return (items || []).map(function ( item, idx ) {
                var key = config.fieldID <KEY>;
                return (
                    React.createElement("option", {
                        key: key, 
                        className: "generated-select-item", 
                        value: item.id
                        }, item.text)
                );
            });
        }
    });
};
<commit_msg>Add unit-tests for <select> primitive<commit_after>var mixins = require( './../../../mixins' );

module.exports = function ( React, tools ) {
    var getOrDefault = tools.getOrDefault
      , getOrNull    = tools.getOrNull;

    return React.createClass({
        displayName: 'SelectRenderer',

        propTypes: {
            config: React.PropTypes.object.isRequired
        },

        mixins: [ mixins.PrimitiveAccessors ],

        /* =========================================================== */
        /* ======================== Lyfe Cycle ======================= */
        /* =========================================================== */
        getDefaultProps: function () {
            return { config: {} };
        },

        /* =========================================================== */
        /* ======================== Handlers ========================= */
        /* =========================================================== */
        handleOnChange: function ( e ) {
            var res = { 
                id:    this._conf().fieldID,
                meta:  this._meta(),
                value: {}
            };

            res.value[ res.id ] = e.target.value; 
            this.handleEvent( 'change' )( e );
            this._conf().onChange( res );
        },

        handleEvent: mixins.handleEvent,

        /* =========================================================== */
        /* ======================== Renders ========================== */
        /* =========================================================== */
        render: function () {
            var config = this._conf()
              , spec   = this._spec()
              , meta   = this._meta();

            if ( meta.isHidden ) return null;

            return (
                React.createElement("select", {id: config.fieldID, 
                        disabled: meta.isDisabled, 
                        className: "generated-select-field", 
                        value: config.value, 
                        onBlur: this.handleEvent( 'blur'), 
                        onFocus: this.handleEvent( 'focus'), 
                        onChange: this.handleOnChange}, 
                    this.renderItems( spec.possibleValues)
                )
            );
        },

        renderItems: function ( items ) {
            var self   = this
              , config = this._conf()
              , meta   = this._meta();

            return (items || []).map(function ( item, idx ) {
                var key = config.fieldID + '-' + idx;
                return (
                    React.createElement("option", {
                        key: key, 
                        className: "generated-select-item", 
                        value: item.id
                        }, item.text)
                );
            });
        }
    });
};

{'fraction_non_alphanumeric': 0.2788886922668554, 'fraction_numerical': 0.0, 'mean_word_length': 1.4811237928007024, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3860772', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1177, 'n_words': 222}