Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
            t[p[i]] = s[p[i]];
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const exotic_1 = require("exotic");
const _styled_1 = require("./_styled");
const _renderProps_1 = require("./_renderProps");
const defaultOptionOnClick = process.env.NODE_ENV === 'production'
    ? exotic_1.NO_OP
    : () => console.info('[Select.Option] defaultOptionOnClick');
/**
 * @todo <extends keyof>
 */
class Option extends react_1.default.Component {
    constructor() {
        super(...arguments);
        this.handleClick = (event) => {
            const { onClick, value, label } = this.props;
            console.debug('[Select.Option] handleClick');
            // @todo should be `item` but also we want `props`...
            // identifier...
            // @todo invalid value?
            onClick(value || label);
        };
    }
    static from(item, props) {
        return react_1.default.createElement(Option, Object.assign({ key: item.label }, item, props));
    }
    render() {
        // @todo !!!
        const _a = this.props, { renderBeforeText, renderText, className } = _a, 
        // renderChildren,
        props = __rest(_a, ["renderBeforeText", "renderText", "className"]);
        const state = this.props.state;
        const children = props.children || (react_1.default.createElement(react_1.default.Fragment, null,
            renderBeforeText(props, state),
            renderText(props, state)));
        return (react_1.default.createElement(_styled_1.StyledOption, { className: className, onClick: this.handleClick, isSelected: props.isSelected, isDisabled: props.isDisabled, role: "option" }, children));
    }
}
Option.defaultProps = {
    identifier: 0,
    label: '',
    onClick: defaultOptionOnClick,
    // @todo
    // or children...
    renderText: _renderProps_1.defaultRenderText,
    // @note can't import 2 aliases
    renderBeforeText: _renderProps_1.defaultRenderBeforeText,
};
exports.Option = Option;
exports.SelectOption = Option;
exports.default = Option;
//# sourceMappingURL=Option.js.map