Fix linter errors
parent
727e672dfc
commit
561136594a
|
@ -14,6 +14,7 @@ const factory = (TableHead, TableRow) => {
|
|||
model: PropTypes.object,
|
||||
multiSelectable: PropTypes.bool,
|
||||
onChange: PropTypes.func,
|
||||
onRowClick: PropTypes.func,
|
||||
onSelect: PropTypes.func,
|
||||
selectable: PropTypes.bool,
|
||||
selected: PropTypes.array,
|
||||
|
@ -62,7 +63,9 @@ const factory = (TableHead, TableRow) => {
|
|||
};
|
||||
|
||||
handleRowClick = (index, event) => {
|
||||
this.props.onRowClick ? this.props.onRowClick(index, event) : "";
|
||||
if (this.props.onRowClick) {
|
||||
this.props.onRowClick(index, event);
|
||||
}
|
||||
}
|
||||
|
||||
renderHead () {
|
||||
|
|
|
@ -8,6 +8,8 @@ const factory = (Checkbox) => {
|
|||
data: PropTypes.object,
|
||||
index: PropTypes.number,
|
||||
model: PropTypes.object,
|
||||
onChange: PropTypes.func,
|
||||
onRowClick: PropTypes.onRowChange,
|
||||
onSelect: PropTypes.func,
|
||||
selectable: PropTypes.bool,
|
||||
selected: PropTypes.bool,
|
||||
|
@ -50,7 +52,7 @@ const factory = (Checkbox) => {
|
|||
|
||||
renderCells () {
|
||||
return Object.keys(this.props.model).map((key) => {
|
||||
return <td key={key} onClick={this.props.onRowClick}>{this.renderCell(key)}</td>
|
||||
return <td key={key} onClick={this.props.onRowClick}>{this.renderCell(key)}</td>;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|||
});
|
||||
exports.AppBar = exports.appBarFactory = undefined;
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _react = require('react');
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
@ -25,45 +27,119 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var factory = function factory(IconButton) {
|
||||
var AppBar = function AppBar(_ref) {
|
||||
var _classnames;
|
||||
var AppBar = function (_React$Component) {
|
||||
_inherits(AppBar, _React$Component);
|
||||
|
||||
var children = _ref.children;
|
||||
var leftIcon = _ref.leftIcon;
|
||||
var onLeftIconClick = _ref.onLeftIconClick;
|
||||
var onRightIconClick = _ref.onRightIconClick;
|
||||
var rightIcon = _ref.rightIcon;
|
||||
var theme = _ref.theme;
|
||||
var title = _ref.title;
|
||||
function AppBar() {
|
||||
var _Object$getPrototypeO;
|
||||
|
||||
var props = _objectWithoutProperties(_ref, ['children', 'leftIcon', 'onLeftIconClick', 'onRightIconClick', 'rightIcon', 'theme', 'title']);
|
||||
var _temp, _this, _ret;
|
||||
|
||||
var className = (0, _classnames3.default)(theme.appBar, (_classnames = {}, _defineProperty(_classnames, theme.fixed, props.fixed), _defineProperty(_classnames, theme.flat, props.flat), _classnames), props.className);
|
||||
_classCallCheck(this, AppBar);
|
||||
|
||||
return _react2.default.createElement(
|
||||
'header',
|
||||
{ className: className, 'data-react-toolbox': 'app-bar' },
|
||||
leftIcon && _react2.default.createElement(IconButton, {
|
||||
inverse: true,
|
||||
className: (0, _classnames3.default)(theme.leftIcon),
|
||||
onClick: onLeftIconClick,
|
||||
icon: leftIcon }),
|
||||
title && _react2.default.createElement(
|
||||
'h1',
|
||||
{ className: (0, _classnames3.default)(theme.title) },
|
||||
title
|
||||
),
|
||||
children,
|
||||
rightIcon && _react2.default.createElement(IconButton, {
|
||||
inverse: true,
|
||||
className: (0, _classnames3.default)(theme.rightIcon),
|
||||
onClick: onRightIconClick,
|
||||
icon: rightIcon })
|
||||
);
|
||||
};
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(AppBar)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { hidden: false, height: 0 }, _this.initializeScroll = function () {
|
||||
window.addEventListener('scroll', _this.handleScroll);
|
||||
|
||||
var _this$rootNode$getBou = _this.rootNode.getBoundingClientRect();
|
||||
|
||||
var height = _this$rootNode$getBou.height;
|
||||
|
||||
_this.curScroll = window.scrollY;
|
||||
_this.setState({ height: height });
|
||||
}, _this.endScroll = function () {
|
||||
window.removeEventListener('scroll', _this.handleScroll);
|
||||
}, _this.handleScroll = function () {
|
||||
var scrollDiff = _this.curScroll - window.scrollY;
|
||||
var hidden = scrollDiff < 0 && window.scrollY !== undefined && window.scrollY > _this.state.height;
|
||||
_this.setState({ hidden: hidden });
|
||||
_this.curScroll = window.scrollY;
|
||||
}, _temp), _possibleConstructorReturn(_this, _ret);
|
||||
}
|
||||
|
||||
_createClass(AppBar, [{
|
||||
key: 'componentDidMount',
|
||||
value: function componentDidMount() {
|
||||
if (this.props.scrollHide) {
|
||||
this.initializeScroll();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillReceiveProps',
|
||||
value: function componentWillReceiveProps(nextProps) {
|
||||
if (!this.props.scrollHide && nextProps.scrollHide) {
|
||||
this.initializeScroll();
|
||||
}
|
||||
|
||||
if (this.props.scrollHide && !nextProps.scrollHide) {
|
||||
this.endScroll();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillUnmount',
|
||||
value: function componentWillUnmount() {
|
||||
if (this.props.scrollHide) {
|
||||
this.endScroll();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
var _classnames,
|
||||
_this2 = this;
|
||||
|
||||
var _props = this.props;
|
||||
var children = _props.children;
|
||||
var leftIcon = _props.leftIcon;
|
||||
var onLeftIconClick = _props.onLeftIconClick;
|
||||
var onRightIconClick = _props.onRightIconClick;
|
||||
var rightIcon = _props.rightIcon;
|
||||
var theme = _props.theme;
|
||||
var title = _props.title;
|
||||
|
||||
var className = (0, _classnames3.default)(theme.appBar, (_classnames = {}, _defineProperty(_classnames, theme.fixed, this.props.fixed), _defineProperty(_classnames, theme.flat, this.props.flat), _defineProperty(_classnames, theme.scrollHide, this.state.hidden), _classnames), this.props.className);
|
||||
|
||||
return _react2.default.createElement(
|
||||
'header',
|
||||
{
|
||||
className: className,
|
||||
'data-react-toolbox': 'app-bar',
|
||||
ref: function ref(node) {
|
||||
_this2.rootNode = node;
|
||||
}
|
||||
},
|
||||
leftIcon && _react2.default.createElement(IconButton, {
|
||||
inverse: true,
|
||||
className: (0, _classnames3.default)(theme.leftIcon),
|
||||
onClick: onLeftIconClick,
|
||||
icon: leftIcon }),
|
||||
title && _react2.default.createElement(
|
||||
'h1',
|
||||
{ className: (0, _classnames3.default)(theme.title) },
|
||||
title
|
||||
),
|
||||
children,
|
||||
rightIcon && _react2.default.createElement(IconButton, {
|
||||
inverse: true,
|
||||
className: (0, _classnames3.default)(theme.rightIcon),
|
||||
onClick: onRightIconClick,
|
||||
icon: rightIcon })
|
||||
);
|
||||
}
|
||||
}]);
|
||||
|
||||
return AppBar;
|
||||
}(_react2.default.Component);
|
||||
|
||||
AppBar.propTypes = {
|
||||
children: _react.PropTypes.node,
|
||||
|
@ -74,6 +150,7 @@ var factory = function factory(IconButton) {
|
|||
onLeftIconClick: _react.PropTypes.func,
|
||||
onRightIconClick: _react.PropTypes.func,
|
||||
rightIcon: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.element]),
|
||||
scrollHide: _react.PropTypes.bool,
|
||||
theme: _react.PropTypes.shape({
|
||||
appBar: _react.PropTypes.string,
|
||||
fixed: _react.PropTypes.string,
|
||||
|
@ -84,13 +161,14 @@ var factory = function factory(IconButton) {
|
|||
}),
|
||||
title: _react.PropTypes.string
|
||||
};
|
||||
|
||||
AppBar.defaultProps = {
|
||||
className: '',
|
||||
fixed: false,
|
||||
flat: false
|
||||
flat: false,
|
||||
scrollHide: false
|
||||
};
|
||||
|
||||
|
||||
return AppBar;
|
||||
};
|
||||
|
||||
|
|
|
@ -54,4 +54,12 @@
|
|||
margin-right: -1.2 * $unit;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
|
||||
transition-duration: .5s;
|
||||
transition-property: transform;
|
||||
|
||||
&.scrollHide {
|
||||
transform: translateY(-100%);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ NavDrawer.propTypes = {
|
|||
children: _react.PropTypes.any,
|
||||
className: _react.PropTypes.string,
|
||||
onOverlayClick: _react.PropTypes.func,
|
||||
permanentAt: _react.PropTypes.oneOf(['sm', 'md', 'lg', 'xl', 'xxl', 'xxxl']),
|
||||
permanentAt: _react.PropTypes.oneOf(['sm', 'smTablet', 'md', 'lg', 'lgTablet', 'xl', 'xxl', 'xxxl']),
|
||||
pinned: _react.PropTypes.bool,
|
||||
scrollY: _react.PropTypes.bool,
|
||||
theme: _react.PropTypes.shape({
|
||||
|
|
|
@ -108,6 +108,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: $layout-breakpoint-sm-tablet) {
|
||||
&.smTabletPermanent {
|
||||
@include permanent();
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: $layout-breakpoint-md) {
|
||||
&.mdPermanent {
|
||||
@include permanent();
|
||||
|
@ -120,6 +126,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: $layout-breakpoint-lg-tablet) {
|
||||
&.lgTabletPermanent {
|
||||
@include permanent();
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: $layout-breakpoint-xl) {
|
||||
&.xlPermanent {
|
||||
@include permanent();
|
||||
|
|
|
@ -86,6 +86,10 @@ var factory = function factory(TableHead, TableRow) {
|
|||
if (_this.props.onChange) {
|
||||
_this.props.onChange(index, key, value);
|
||||
}
|
||||
}, _this.handleRowClick = function (index, event) {
|
||||
if (_this.props.onRowClick) {
|
||||
_this.props.onRowClick(index, event);
|
||||
}
|
||||
}, _temp), _possibleConstructorReturn(_this, _ret);
|
||||
}
|
||||
|
||||
|
@ -135,6 +139,7 @@ var factory = function factory(TableHead, TableRow) {
|
|||
model: model,
|
||||
onChange: onChange ? _this2.handleRowChange.bind(_this2) : undefined,
|
||||
onSelect: _this2.handleRowSelect.bind(_this2, index),
|
||||
onRowClick: _this2.handleRowClick.bind(_this2, index),
|
||||
selectable: selectable,
|
||||
selected: selected.indexOf(index) !== -1,
|
||||
theme: theme
|
||||
|
@ -167,6 +172,7 @@ var factory = function factory(TableHead, TableRow) {
|
|||
model: _react.PropTypes.object,
|
||||
multiSelectable: _react.PropTypes.bool,
|
||||
onChange: _react.PropTypes.func,
|
||||
onRowClick: _react.PropTypes.func,
|
||||
onSelect: _react.PropTypes.func,
|
||||
selectable: _react.PropTypes.bool,
|
||||
selected: _react.PropTypes.array,
|
||||
|
|
|
@ -82,7 +82,7 @@ var factory = function factory(Checkbox) {
|
|||
return Object.keys(this.props.model).map(function (key) {
|
||||
return _react2.default.createElement(
|
||||
'td',
|
||||
{ key: key },
|
||||
{ key: key, onClick: _this2.props.onRowClick },
|
||||
_this2.renderCell(key)
|
||||
);
|
||||
});
|
||||
|
@ -153,6 +153,7 @@ var factory = function factory(Checkbox) {
|
|||
index: _react.PropTypes.number,
|
||||
model: _react.PropTypes.object,
|
||||
onChange: _react.PropTypes.func,
|
||||
onRowClick: _react.PropTypes.onRowChange,
|
||||
onSelect: _react.PropTypes.func,
|
||||
selectable: _react.PropTypes.bool,
|
||||
selected: _react.PropTypes.bool,
|
||||
|
|
Loading…
Reference in New Issue