@telsystems/inputs
Version:
40 lines • 2.09 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import * as React from 'react';
import { SelectInput } from './SelectInput';
import { BasicDropDown } from './BasicDropDown';
var Select = (function (_super) {
__extends(Select, _super);
function Select() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.apply(this, args) || this;
_this.onDropDownToggle = function (isDropDownActive) { return function () {
_this.setState({ isDropDownActive: isDropDownActive });
}; };
_this.state = {
isDropDownActive: false,
};
return _this;
}
Select.prototype.render = function () {
var _a = this.props, placeholder = _a.placeholder, disabled = _a.disabled, items = _a.items, selectedIndex = _a.selectedIndex, hideAfterClick = _a.hideAfterClick, onItemClick = _a.onItemClick;
var isDropDownActive = this.state.isDropDownActive;
var value = typeof selectedIndex !== 'undefined' ? items[selectedIndex].content.title : '';
return (React.createElement(BasicDropDown, { items: items, disabled: disabled, onItemClick: onItemClick, selectedIndex: selectedIndex, hideAfterClick: hideAfterClick, onOpen: this.onDropDownToggle(true), onClose: this.onDropDownToggle(false) },
React.createElement(SelectInput, { active: isDropDownActive, disabled: disabled, placeholder: placeholder, value: value })));
};
return Select;
}(React.PureComponent));
export { Select };
//# sourceMappingURL=Select.js.map