Sha256: a6aaca9dcb4b2928f00eefa20374911f507b62daa2ab3b123afc1b75927f544d

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

import React from 'react';

export class FakeInputEvent {
    constructor(value) {
        this.target = {value};
    }
    isDefaultPrevented() { return false; }
}


export class Checkbox extends React.Component {
    static propTypes =
        {supportIndeterminate: React.PropTypes.bool};

    static mixins = [
        Lanes.Components.Form.InputFieldMixin
    ];
    componentDidMount() { return this.updateIndeterminate(); }
    componentDidUpdate() { return this.updateIndeterminate(); }

    updateIndeterminate() {
        if (!this.props.supportIndeterminate) { return; }
        return (
            _.dom(this).el.indeterminate =
                (this.props.checked !== true) && (this.props.checked !== false)
        );
    }

    handleCheckboxChange(ev) {
        if (ev.target.checked) {
            return (
                this.fieldMixinSetValue( new FakeInputEvent(this.props.value) )
            );
        }
    }

    renderInputField(props, handlers) {
        return (
            <input
                type="checkbox"
                {...handlers}
                {...props}
                checked={this.props.checked}
                onChange={this.handleCheckboxChange} />
        );
    }
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lanes-0.8.3 client/lanes/components/shared/Checkbox.jsx
lanes-0.8.2 client/lanes/components/shared/Checkbox.jsx
lanes-0.8.1 client/lanes/components/shared/Checkbox.jsx
lanes-0.8.0 client/lanes/components/shared/Checkbox.jsx