import * as React from "react";

import {MmuiDropChoiceSingleComponent, MmuiDropChoiceSingleProps} from "../../mmui-react-component";
import {renderDropChoiceDropdown} from "./common";

export interface MmuiBlueDropChoiceMultipleProps extends MmuiDropChoiceSingleProps {

}


export class MmuiBlueDropChoiceSingleComponent<P extends MmuiBlueDropChoiceMultipleProps> extends MmuiDropChoiceSingleComponent<P> {
    constructor(props) {
        super(props);
    }

    renderChoiceInput(choice) {
        const choiceInputProps: any = {
                id: choice.id,
                name: choice.name,
                value: choice.value,
                checked: choice.isChecked,
            },
            choiceStyle: any = { display: 'block' };
        if (choice.isParent) {
            choiceInputProps['data-isparent'] = 'true';
        } else {
            choiceInputProps['data-parentid'] = choice.parentValue;
        }

        if (!choice.isVisible) {
            choiceStyle.display = 'none';
        }

        return (
            <div key={choice.id} style={choiceStyle}>
                <div className="custom-control custom-radio">
                    <input
                        type="radio"
                        className="custom-control-input"
                        {...choiceInputProps}
                        data-display={choice.display}
                        onChange={this.onChoiceChange}
                    />
                    <label className="custom-control-label" htmlFor={choice.id}>{choice.display}</label>
                </div>
            </div>
        );
    }

    renderDropdown(summaryDisplayRender, filterInput, selectAllCheck, choiceInputElmts, tooltip){
        return renderDropChoiceDropdown(this, summaryDisplayRender, filterInput, selectAllCheck, choiceInputElmts, tooltip);
    }
}