<commit_before>import h from '../hyperscript.js';
import SiimpleComponent from '../index.js';

//Input component
export default class SiimpleInput extends SiimpleComponent
{
  //Constructor
  constructor(props)
  {
    //Call super
    super(props);

    //Initialize the reference object
    this.ref = { input: null };

    //Bind handler methods
    this.handleChange = this.handleChange.bind(this);
    this.handleKeyUp = this.handleKeyUp.bind(this);
  }

  //Initialize the input types list
  static types = ['text', 'password', 'email', 'date'];

  //Handle the input change event
  handleChange(e)
  {
    //Check the change listener
    if(typeof this.props.onChange !== 'function'){ return; }

    //Call the change listener
    this.props.onChange.call(null, e.nativeEvent);
  }

  //Handle the input key press event
  handleKeyUp(e)
  {
    //Check the key up listener
    if(typeof this.props.onKeyUp !== 'function'){ return; }

    //Call the key up listener
    this.props.onKeyUp.call(null, e.nativeEvent);
  }

  //Get the current value
  value()
  {
    //Return the input current value
    return this.ref.input.value;
  }

  //Render the input element
  render()
  {
    //Save this
    var self = this;

    //Input props
    var input_props = { type: 'text', onChange: self.handleChange, onKeyUp: self.handleKeyUp };

    //Initialize the input class list
    input_props.className = [ 'siimple-input' ];

    //Add the input type
    if(this.types.indexOf(this.props.type.toLowerCase()) !== -1)
    {
      //Save the input type
      input_props.type = this.props.type.toLowerCase();
    }

    //Add the reference function
    input_props.ref = function(i){ self.ref.input = i; };

    //Check the fluid property
    if(this.props.fluid === true)
    {
      //Add the fluid style
      input_props.className.push('siimple-input--fluid');
    }

    //Check the disabled property
    if(this.props.disabled === true)
    {
      //Add the disabled style
      input_props.className.push('siimple-input--disabled');
    }

    //Check the placeholder
    if(typeof this.props.placeholder === 'string')
    {
      //Add the placeholder attribute
      input_props.placeholder = this.props.placeholder;
    }

    //Check the name attribute<commit_msg>src/form/input.js: fixed bug<commit_after>import h from '../hyperscript.js';
import SiimpleComponent from '../index.js';

//Initialize the input types list
var inputTypes = ['text', 'password', 'email', 'date'];

//Input component
export default class SiimpleInput extends SiimpleComponent
{
  //Constructor
  constructor(props)
  {
    //Call super
    super(props);

    //Initialize the reference object
    this.ref = { input: null };

    //Bind handler methods
    this.handleChange = this.handleChange.bind(this);
    this.handleKeyUp = this.handleKeyUp.bind(this);
  }

  //Handle the input change event
  handleChange(e)
  {
    //Check the change listener
    if(typeof this.props.onChange !== 'function'){ return; }

    //Call the change listener
    this.props.onChange.call(null, e.nativeEvent);
  }

  //Handle the input key press event
  handleKeyUp(e)
  {
    //Check the key up listener
    if(typeof this.props.onKeyUp !== 'function'){ return; }

    //Call the key up listener
    this.props.onKeyUp.call(null, e.nativeEvent);
  }

  //Get the current value
  value()
  {
    //Return the input current value
    return this.ref.input.value;
  }

  //Render the input element
  render()
  {
    //Save this
    var self = this;

    //Input props
    var input_props = { type: 'text', onChange: self.handleChange, onKeyUp: self.handleKeyUp };

    //Initialize the input class list
    input_props.className = [ 'siimple-input' ];

    //Add the input type
    if(inputTypes.indexOf(this.props.type.toLowerCase()) !== -1)
    {
      //Save the input type
      input_props.type = this.props.type.toLowerCase();
    }

    //Add the reference function
    input_props.ref = function(i){ self.ref.input = i; };

    //Check the fluid property
    if(this.props.fluid === true)
    {
      //Add the fluid style
      input_props.className.push('siimple-input--fluid');
    }

    //Check the disabled property
    if(this.props.disabled === true)
    {
      //Add the disabled style
      input_props.className.push('siimple-input--disabled');
    }

    //Check the placeholder
    if(typeof this.props.placeholder === 'string')
    {
      //Add the placeholder attribute
      input_props.placeholder = this.props.placeholder;
    }

    //Check the name attribute
{'fraction_non_alphanumeric': 0.1269458452093839, 'fraction_numerical': 0.0004385003288752467, 'mean_word_length': 2.6350597609561754, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '303909', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1356, 'n_words': 373}