<commit_before>import * as React from 'react';
import * as M from 'react-mdl';

import { PurchaseDetailItem } from '../selectors';
import { RootState, Column } from '../reducers';
import { format, toYen, toPercentage } from './Utils';

interface Props {
    columns: Column[];
    purchaseDetailItems?: PurchaseDetailItem[];
    onChangeQuantity: (id: string, newQuantity: number) => void;
    onDeleteItem: (id: string) => void;
}

export class PurchaseItems extends React.Component<Props, void> {

    editableQuantity = (value, item: PurchaseDetailItem) => {
        return <div className='quantity' style={{ marginLeft: 10 }}>
            <M.Textfield label='' value={value} type='number' onChange={this.modifyQuantity(item)} />
        </div>;
    };

    modifyQuantity = (item: PurchaseDetailItem) => (e) => {
        const quantity = Number(e.target.value);
        this.props.onChangeQuantity(item.id, quantity);
    };
<commit_msg>Improve quantity typing<commit_after>import * as React from 'react';
import * as M from 'react-mdl';

import { PurchaseDetailItem } from '../selectors';
import { RootState, Column } from '../reducers';
import { format, toYen, toPercentage } from './Utils';

interface Props {
    columns: Column[];
    purchaseDetailItems?: PurchaseDetailItem[];
    onChangeQuantity: (id: string, newQuantity: number) => void;
    onDeleteItem: (id: string) => void;
}

export class PurchaseItems extends React.Component<Props, void> {

    editableQuantity = (value, item: PurchaseDetailItem) => {
        return <div className='quantity' style={{ marginLeft: 10 }}>
            <M.Textfield label='' value={value} onChange={this.modifyQuantity(item)} />
        </div>;
    };

    modifyQuantity = (item: PurchaseDetailItem) => (e) => {
        const value = e.target.value.replace(/[０-９]/g, str => {
            return String.fromCharCode(str.charCodeAt(0) - 0xFEE0);
        });

        const quantity = Number(value);
        if (isNaN(quantity) || e.target.value === '') {
            return;
        }

        this.props.onChangeQuantity(item.id, quantity);
    };

{'fraction_non_alphanumeric': 0.1504045692527368, 'fraction_numerical': 0.004283674440742504, 'mean_word_length': 3.34297520661157, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 22, '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': '1997112', 'n_tokens_mistral': 643, 'n_tokens_neox': 615, 'n_words': 156}