<commit_before>import React, {PropTypes} from 'react';
import {UNIT_CENTIMETER, UNIT_FOOT, UNIT_INCH, UNIT_METER, UNIT_MILE, UNIT_MILLIMETER} from './../../constants';
import convert from 'convert-units';
import FormLabel from '../../components/style/form-label'
import FormNumberInput from '../../components/style/form-number-input'
import FormSelect from '../../components/style/form-select'


export default function PropertyLengthMeasure({value, onUpdate, configs}, {catalog}) {

  let length = value.get('length');
  let _length, _unit;

  if(value.has('_length') && value.has('_unit')){
    _length = value.get('_length');
     _unit = value.get('_unit');
  }else{
    _length = length;
    _unit = catalog.unit;
  }

  let update = (lengthInput, unitInput) => {
    let _length = parseFloat(lengthInput);
    let length = convert(_length).from(unitInput).to(catalog.unit);
    onUpdate(value.merge({length, _length, _unit: unitInput}));
  };

  return (
    <div style={{marginBottom: "3px"}}>
      <div style={{display: "inline-block", width: "30%"}}>
        <FormLabel>{configs.label}</FormLabel>
      </div><commit_msg>Fix property length-measure bug when textbox is empty<commit_after>import React, {PropTypes} from 'react';
import {UNIT_CENTIMETER, UNIT_FOOT, UNIT_INCH, UNIT_METER, UNIT_MILE, UNIT_MILLIMETER} from './../../constants';
import convert from 'convert-units';
import FormLabel from '../../components/style/form-label'
import FormNumberInput from '../../components/style/form-number-input'
import FormSelect from '../../components/style/form-select'


export default function PropertyLengthMeasure({value, onUpdate, configs}, {catalog}) {

  let length = value.get('length');
  let _length, _unit;

  if(value.has('_length') && value.has('_unit')){
    _length = value.get('_length');
     _unit = value.get('_unit');
  }else{
    _length = length;
    _unit = catalog.unit;
  }

  let update = (lengthInput, unitInput) => {
    let _length = parseFloat(lengthInput);

    if (isNaN(_length)) {
      _length = 0;
    }

    let length = convert(_length).from(unitInput).to(catalog.unit);
    onUpdate(value.merge({length, _length, _unit: unitInput}));
  };

  return (
    <div style={{marginBottom: "3px"}}>
      <div style={{display: "inline-block", width: "30%"}}>
        <FormLabel>{configs.label}</FormLabel>
      </div>
{'fraction_non_alphanumeric': 0.168434450572762, 'fraction_numerical': 0.002969876962240136, 'mean_word_length': 4.017021276595744, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '2135421', 'n_tokens_mistral': 763, 'n_tokens_neox': 759, 'n_words': 168}