@up-group/react-controls
Version:
We know that there are a ton of react UI library projects to choose from. Our hope with this one is to provide the next generation of react components that you can use to bootstrap your next project, or as a reference for building a UIKit. Read on to get
90 lines • 3.78 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 __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var index_1 = require("../../Inputs/Button/index");
var typestyle_1 = require("typestyle");
var UpButtonGroupDropDown = (function (_super) {
__extends(UpButtonGroupDropDown, _super);
function UpButtonGroupDropDown(p, c) {
var _this = _super.call(this, p, c) || this;
_this.expand = function () {
_this.setState({ open: true });
};
_this.collapse = function (e) {
_this.setState({ open: false });
};
_this.change = function () {
_this.setState({ open: !_this.state.open });
};
_this.state = {
open: false
};
return _this;
}
UpButtonGroupDropDown.prototype.render = function () {
var main = {
position: "relative",
display: "inline-block"
};
var BtnList = typestyle_1.style({
display: this.state.open ? "block" : "none",
position: "absolute",
zIndex: 1000,
listStyle: "none",
backgroundColor: "#ffffff",
minWidth: 160,
margin: 0,
paddingTop: 10,
paddingBottom: 10,
paddingLeft: 0,
borderRadius: 4,
boxShadow: "0 6px 12px rgba(0, 0, 0, .175)"
});
var buttonElement = typestyle_1.style({
cursor: "pointer",
paddingLeft: 10,
$nest: {
'&:hover': { backgroundColor: "#f5f5f5" },
},
});
var _a = this.props, text = _a.text, buttons = _a.buttons, onClick = _a.onClick, other = __rest(_a, ["text", "buttons", "onClick"]);
return React.createElement("div", { style: main, tabIndex: 0, onBlur: this.collapse },
React.createElement(index_1.default, __assign({ iconName: "caret-down", iconPosition: "right" }, other, { onClick: this.change }), this.props.text),
React.createElement("ul", { className: BtnList }, this.props.buttons.map(function (v, i) {
return React.createElement("li", { key: i, className: buttonElement, onMouseDown: function (e) {
v.onClick();
e.stopPropagation();
} }, v.name);
})));
};
return UpButtonGroupDropDown;
}(React.Component));
exports.default = UpButtonGroupDropDown;
//# sourceMappingURL=UpButtonGroupDropDown.js.map
;