Repository URL to install this package:
|
Version:
2.7.3 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const exotic_1 = require("exotic");
const mobx_react_1 = require("xmobx/mobx-react");
const styled_1 = require("./styled");
const renderProps_1 = require("./renderProps");
/**
* @description this is for optimization
*/
const defaultOptionOnClick = process.env.NODE_ENV === 'production' ? exotic_1.NO_OP : () => console.info('[Select.Option] defaultOptionOnClick');
let Option = 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);
};
}
render() {
// @todo !!!
const _a = this.props,
{
renderBeforeText,
renderText,
className,
state
} = _a,
// renderChildren,
props = tslib_1.__rest(_a, ["renderBeforeText", "renderText", "className", "state"]); // 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
};
Option = tslib_1.__decorate([mobx_react_1.observer], Option);
exports.Option = Option;
exports.SelectOption = Option;
exports.default = Option; //# sourceMappingURL=Option.js.map