fast-table
Advanced tools
Comparing version 1.4.8-beta.23 to 1.4.8-beta.24
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,169 +8,328 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _detectElementResize = _interopRequireDefault(require("./utils/detectElementResize")); | ||
var _detectElementResize = _interopRequireDefault( | ||
require('./utils/detectElementResize') | ||
); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { | ||
if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') { | ||
_typeof = function _typeof(obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && | ||
typeof Symbol === 'function' && | ||
obj.constructor === Symbol && | ||
obj !== Symbol.prototype | ||
? 'symbol' | ||
: typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat( | ||
Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
}) | ||
); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a 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); } } | ||
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); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === 'object' || typeof call === 'function')) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf | ||
? Object.getPrototypeOf | ||
: function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== 'function' && superClass !== null) { | ||
throw new TypeError('Super expression must either be null or a function'); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: {value: subClass, writable: true, configurable: true} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = | ||
Object.setPrototypeOf || | ||
function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError( | ||
"this hasn't been initialised - super() hasn't been called" | ||
); | ||
} | ||
return self; | ||
} | ||
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 _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; | ||
} | ||
var AutoSizer = | ||
/*#__PURE__*/ | ||
function (_React$PureComponent) { | ||
_inherits(AutoSizer, _React$PureComponent); | ||
/*#__PURE__*/ | ||
(function(_React$PureComponent) { | ||
_inherits(AutoSizer, _React$PureComponent); | ||
function AutoSizer() { | ||
var _getPrototypeOf2; | ||
function AutoSizer() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
var _this; | ||
_classCallCheck(this, AutoSizer); | ||
_classCallCheck(this, AutoSizer); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
for ( | ||
var _len = arguments.length, args = new Array(_len), _key = 0; | ||
_key < _len; | ||
_key++ | ||
) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(AutoSizer)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_this = _possibleConstructorReturn( | ||
this, | ||
(_getPrototypeOf2 = _getPrototypeOf(AutoSizer)).call.apply( | ||
_getPrototypeOf2, | ||
[this].concat(args) | ||
) | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", { | ||
height: _this.props.defaultHeight || 0, | ||
width: _this.props.defaultWidth || 0 | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'state', | ||
{ | ||
height: _this.props.defaultHeight || 0, | ||
width: _this.props.defaultWidth || 0 | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_parentNode", void 0); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_parentNode', | ||
void 0 | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_autoSizer", void 0); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_autoSizer', | ||
void 0 | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_detectElementResize", void 0); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_detectElementResize', | ||
void 0 | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_onResize", function () { | ||
var _this$props = _this.props, | ||
disableHeight = _this$props.disableHeight, | ||
disableWidth = _this$props.disableWidth, | ||
onResize = _this$props.onResize; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_onResize', | ||
function() { | ||
var _this$props = _this.props, | ||
disableHeight = _this$props.disableHeight, | ||
disableWidth = _this$props.disableWidth, | ||
onResize = _this$props.onResize; | ||
if (_this._parentNode) { | ||
var height = _this._parentNode.offsetHeight || 0; | ||
var width = _this._parentNode.offsetWidth || 0; | ||
var style = window.getComputedStyle(_this._parentNode) || {}; | ||
var paddingLeft = parseInt(style.paddingLeft, 10) || 0; | ||
var paddingRight = parseInt(style.paddingRight, 10) || 0; | ||
var paddingTop = parseInt(style.paddingTop, 10) || 0; | ||
var paddingBottom = parseInt(style.paddingBottom, 10) || 0; | ||
var borderLeftWidth = parseInt(style.borderLeftWidth, 10) || 0; | ||
var borderTopWidth = parseInt(style.borderTopWidth, 10) || 0; | ||
var borderRightWidth = parseInt(style.borderRightWidth, 10) || 0; | ||
var borderBottomWidth = parseInt(style.borderBottomWidth, 10) || 0; | ||
var newHeight = height - paddingTop - paddingBottom; | ||
var newWidth = width - paddingLeft - paddingRight; | ||
if (_this._parentNode) { | ||
var height = _this._parentNode.offsetHeight || 0; | ||
var width = _this._parentNode.offsetWidth || 0; | ||
var style = window.getComputedStyle(_this._parentNode) || {}; | ||
var paddingLeft = parseInt(style.paddingLeft, 10) || 0; | ||
var paddingRight = parseInt(style.paddingRight, 10) || 0; | ||
var paddingTop = parseInt(style.paddingTop, 10) || 0; | ||
var paddingBottom = parseInt(style.paddingBottom, 10) || 0; | ||
var borderLeftWidth = parseInt(style.borderLeftWidth, 10) || 0; | ||
var borderTopWidth = parseInt(style.borderTopWidth, 10) || 0; | ||
var borderRightWidth = parseInt(style.borderRightWidth, 10) || 0; | ||
var borderBottomWidth = parseInt(style.borderBottomWidth, 10) || 0; | ||
var newHeight = height - paddingTop - paddingBottom; | ||
var newWidth = width - paddingLeft - paddingRight; | ||
if (style.boxSizing === 'border-box') { | ||
newHeight = newHeight - borderTopWidth - borderBottomWidth; | ||
newWidth = newWidth - borderLeftWidth - borderRightWidth; | ||
} | ||
if (style.boxSizing === 'border-box') { | ||
newHeight = newHeight - borderTopWidth - borderBottomWidth; | ||
newWidth = newWidth - borderLeftWidth - borderRightWidth; | ||
} | ||
if (!disableHeight && _this.state.height !== newHeight || !disableWidth && _this.state.width !== newWidth) { | ||
var state = { | ||
height: newHeight, | ||
width: newWidth | ||
}; | ||
if ( | ||
(!disableHeight && _this.state.height !== newHeight) || | ||
(!disableWidth && _this.state.width !== newWidth) | ||
) { | ||
var state = { | ||
height: newHeight, | ||
width: newWidth | ||
}; | ||
_this.setState(state); | ||
_this.setState(state); | ||
onResize(state); | ||
onResize(state); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_setRef", function (autoSizer) { | ||
_this._autoSizer = autoSizer; | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_setRef', | ||
function(autoSizer) { | ||
_this._autoSizer = autoSizer; | ||
} | ||
); | ||
return _this; | ||
} | ||
return _this; | ||
} | ||
_createClass(AutoSizer, [{ | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
var nonce = this.props.nonce; | ||
_createClass(AutoSizer, [ | ||
{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
var nonce = this.props.nonce; | ||
if (this._autoSizer && this._autoSizer.parentNode && this._autoSizer.parentNode.ownerDocument && this._autoSizer.parentNode.ownerDocument.defaultView && this._autoSizer.parentNode instanceof this._autoSizer.parentNode.ownerDocument.defaultView.HTMLElement) { | ||
this._parentNode = this._autoSizer.parentNode; | ||
this._detectElementResize = (0, _detectElementResize.default)(nonce); | ||
if ( | ||
this._autoSizer && | ||
this._autoSizer.parentNode && | ||
this._autoSizer.parentNode.ownerDocument && | ||
this._autoSizer.parentNode.ownerDocument.defaultView && | ||
this._autoSizer.parentNode instanceof | ||
this._autoSizer.parentNode.ownerDocument.defaultView.HTMLElement | ||
) { | ||
this._parentNode = this._autoSizer.parentNode; | ||
this._detectElementResize = (0, _detectElementResize.default)( | ||
nonce | ||
); | ||
this._detectElementResize.addResizeListener(this._parentNode, this._onResize); | ||
this._detectElementResize.addResizeListener( | ||
this._parentNode, | ||
this._onResize | ||
); | ||
this._onResize(); | ||
} | ||
} | ||
}, { | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
if (this._detectElementResize && this._parentNode) { | ||
this._detectElementResize.removeResizeListener(this._parentNode, this._onResize); | ||
} | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _this$props2 = this.props, | ||
children = _this$props2.children, | ||
className = _this$props2.className, | ||
disableHeight = _this$props2.disableHeight, | ||
disableWidth = _this$props2.disableWidth, | ||
style = _this$props2.style; | ||
var _this$state = this.state, | ||
height = _this$state.height, | ||
width = _this$state.width; | ||
var outerStyle = { | ||
overflow: 'visible' | ||
}; | ||
var childParams = {}; | ||
this._onResize(); | ||
} | ||
} | ||
}, | ||
{ | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
if (this._detectElementResize && this._parentNode) { | ||
this._detectElementResize.removeResizeListener( | ||
this._parentNode, | ||
this._onResize | ||
); | ||
} | ||
} | ||
}, | ||
{ | ||
key: 'render', | ||
value: function render() { | ||
var _this$props2 = this.props, | ||
children = _this$props2.children, | ||
className = _this$props2.className, | ||
disableHeight = _this$props2.disableHeight, | ||
disableWidth = _this$props2.disableWidth, | ||
style = _this$props2.style; | ||
var _this$state = this.state, | ||
height = _this$state.height, | ||
width = _this$state.width; | ||
var outerStyle = { | ||
overflow: 'visible' | ||
}; | ||
var childParams = {}; | ||
if (!disableHeight) { | ||
outerStyle.height = 0; | ||
childParams.height = height; | ||
} | ||
if (!disableHeight) { | ||
outerStyle.height = 0; | ||
childParams.height = height; | ||
} | ||
if (!disableWidth) { | ||
outerStyle.width = 0; | ||
childParams.width = width; | ||
if (!disableWidth) { | ||
outerStyle.width = 0; | ||
childParams.width = width; | ||
} | ||
return _react.default.createElement( | ||
'div', | ||
{ | ||
className: className, | ||
ref: this._setRef, | ||
style: _objectSpread({}, outerStyle, style, { | ||
minHeight: '100%' | ||
}) | ||
}, | ||
children(childParams) | ||
); | ||
} | ||
} | ||
]); | ||
return _react.default.createElement("div", { | ||
className: className, | ||
ref: this._setRef, | ||
style: _objectSpread({}, outerStyle, style, { | ||
minHeight: '100%' | ||
}) | ||
}, children(childParams)); | ||
} | ||
}]); | ||
return AutoSizer; | ||
})(_react.default.PureComponent); | ||
return AutoSizer; | ||
}(_react.default.PureComponent); | ||
exports.default = AutoSizer; | ||
_defineProperty(AutoSizer, "defaultProps", { | ||
_defineProperty(AutoSizer, 'defaultProps', { | ||
onResize: function onResize() {}, | ||
@@ -180,2 +339,2 @@ disableHeight: false, | ||
style: {} | ||
}); | ||
}); |
1059
lib/BaseTable.js
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,517 +8,762 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _propTypes = _interopRequireDefault(require('prop-types')); | ||
var _TableHeader = _interopRequireDefault(require("./TableHeader")); | ||
var _TableHeader = _interopRequireDefault(require('./TableHeader')); | ||
var _TableRow = _interopRequireDefault(require("./TableRow")); | ||
var _TableRow = _interopRequireDefault(require('./TableRow')); | ||
var _miniStore = require("./mini-store"); | ||
var _miniStore = require('./mini-store'); | ||
var _ExpandedIcon = _interopRequireDefault(require("./ExpandedIcon")); | ||
var _ExpandedIcon = _interopRequireDefault(require('./ExpandedIcon')); | ||
var _TableCell = _interopRequireDefault(require("./TableCell")); | ||
var _TableCell = _interopRequireDefault(require('./TableCell')); | ||
var _Select = _interopRequireDefault(require("./Select")); | ||
var _Select = _interopRequireDefault(require('./Select')); | ||
var _types = require("./types"); | ||
var _types = require('./types'); | ||
var _utils = require("./utils"); | ||
var _utils = require('./utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { | ||
if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') { | ||
_typeof = function _typeof(obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && | ||
typeof Symbol === 'function' && | ||
obj.constructor === Symbol && | ||
obj !== Symbol.prototype | ||
? 'symbol' | ||
: typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat( | ||
Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
}) | ||
); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a 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); } } | ||
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); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === 'object' || typeof call === 'function')) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf | ||
? Object.getPrototypeOf | ||
: function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== 'function' && superClass !== null) { | ||
throw new TypeError('Super expression must either be null or a function'); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: {value: subClass, writable: true, configurable: true} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = | ||
Object.setPrototypeOf || | ||
function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError( | ||
"this hasn't been initialised - super() hasn't been called" | ||
); | ||
} | ||
return self; | ||
} | ||
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 _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; | ||
} | ||
var BaseTable = | ||
/*#__PURE__*/ | ||
function (_React$PureComponent) { | ||
_inherits(BaseTable, _React$PureComponent); | ||
/*#__PURE__*/ | ||
(function(_React$PureComponent) { | ||
_inherits(BaseTable, _React$PureComponent); | ||
function BaseTable() { | ||
var _getPrototypeOf2; | ||
function BaseTable() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
var _this; | ||
_classCallCheck(this, BaseTable); | ||
_classCallCheck(this, BaseTable); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
for ( | ||
var _len = arguments.length, args = new Array(_len), _key = 0; | ||
_key < _len; | ||
_key++ | ||
) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(BaseTable)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_this = _possibleConstructorReturn( | ||
this, | ||
(_getPrototypeOf2 = _getPrototypeOf(BaseTable)).call.apply( | ||
_getPrototypeOf2, | ||
[this].concat(args) | ||
) | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_children", []); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_children', | ||
[] | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_startIndex", 0); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_startIndex', | ||
0 | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_stopIndex", 0); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_stopIndex', | ||
0 | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_forceCount", 0); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_forceCount', | ||
0 | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "fExpanded", function (event) { | ||
event.stopPropagation(); | ||
var expandChange = _this.context.expandChange; | ||
expandChange(event.currentTarget.getAttribute('data-key')); | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'fExpanded', | ||
function(event) { | ||
event.stopPropagation(); | ||
var expandChange = _this.context.expandChange; | ||
expandChange(event.currentTarget.getAttribute('data-key')); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "fSort", function (key, order) { | ||
var sortManager = _this.context.manager.sortManager; | ||
var onSort = _this.context.props.onSort; | ||
sortManager.setOrder(key, order, function (orders) { | ||
_this.props.store.setState({ | ||
orders: orders | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'fSort', | ||
function(key, order) { | ||
var sortManager = _this.context.manager.sortManager; | ||
var onSort = _this.context.props.onSort; | ||
sortManager.setOrder(key, order, function(orders) { | ||
_this.props.store.setState({ | ||
orders: orders | ||
}); | ||
if (typeof onSort === 'function') { | ||
onSort(orders, order); | ||
if (typeof onSort === 'function') { | ||
onSort(orders, key, order); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getRowData", function (event) { | ||
var key = event.currentTarget.getAttribute('data-key'); | ||
var dataManager = _this.context.manager.dataManager; | ||
return dataManager.getByKey(key) || {}; | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'getRowData', | ||
function(event) { | ||
var key = event.currentTarget.getAttribute('data-key'); | ||
var dataManager = _this.context.manager.dataManager; | ||
return dataManager.getByKey(key) || {}; | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "fEvents", function (event) { | ||
var record = _this.getRowData(event); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'fEvents', | ||
function(event) { | ||
var record = _this.getRowData(event); | ||
var expandChange = _this.context.expandChange; | ||
var _this$context$props = _this.context.props, | ||
expandedRowByClick = _this$context$props.expandedRowByClick, | ||
onRow = _this$context$props.onRow; | ||
var events = onRow(record) || {}; | ||
var func = _types.eventsMap[event.type]; | ||
var expandChange = _this.context.expandChange; | ||
var _this$context$props = _this.context.props, | ||
expandedRowByClick = _this$context$props.expandedRowByClick, | ||
onRow = _this$context$props.onRow; | ||
var events = onRow(record) || {}; | ||
var func = _types.eventsMap[event.type]; | ||
if ((0, _utils.has)(events, func) && typeof events[func] === 'function') { | ||
events[func](event); | ||
} | ||
if ( | ||
(0, _utils.has)(events, func) && | ||
typeof events[func] === 'function' | ||
) { | ||
events[func](event); | ||
} | ||
if (event.type === 'click') { | ||
expandedRowByClick && record[_types.DS._expandedEnable] && expandChange(record[_types.DS._key]); | ||
} else if (event.type === 'mouseenter') { | ||
_this.fHover(true, record[_types.DS._key]); | ||
} else if (event.type === 'mouseleave') { | ||
_this.fHover(false, record[_types.DS._key]); | ||
} | ||
}); | ||
if (event.type === 'click') { | ||
expandedRowByClick && | ||
record[_types.DS._expandedEnable] && | ||
expandChange(record[_types.DS._key]); | ||
} else if (event.type === 'mouseenter') { | ||
_this.fHover(true, record[_types.DS._key]); | ||
} else if (event.type === 'mouseleave') { | ||
_this.fHover(false, record[_types.DS._key]); | ||
} | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "fHover", function (isHover, key) { | ||
var hoverEnable = _this.context.props.hoverEnable; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'fHover', | ||
function(isHover, key) { | ||
var hoverEnable = _this.context.props.hoverEnable; | ||
if (hoverEnable) { | ||
_this.props.store.setState({ | ||
currentHoverKey: isHover ? key : null | ||
}); | ||
} | ||
}); | ||
if (hoverEnable) { | ||
_this.props.store.setState({ | ||
currentHoverKey: isHover ? key : null | ||
}); | ||
} | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "fDrag", function (parent, columns) { | ||
var update = _this.context.update; | ||
var onHeaderSortable = _this.context.props.onHeaderSortable; | ||
var columnManager = _this.context.manager.columnManager; | ||
columnManager.updateGroupedColumns(_this.updateColumn(columnManager.groupedColumns(), parent, columns)); | ||
_this._forceCount += 1; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'fDrag', | ||
function(parent, columns) { | ||
var update = _this.context.update; | ||
var onHeaderSortable = _this.context.props.onHeaderSortable; | ||
var columnManager = _this.context.manager.columnManager; | ||
columnManager.updateGroupedColumns( | ||
_this.updateColumn(columnManager.groupedColumns(), parent, columns) | ||
); | ||
_this._forceCount += 1; | ||
if (typeof update === 'function') { | ||
update(); | ||
} | ||
if (typeof update === 'function') { | ||
update(); | ||
} | ||
if (typeof onHeaderSortable === 'function') { | ||
onHeaderSortable(columnManager.groupedColumns()); | ||
} | ||
if (typeof onHeaderSortable === 'function') { | ||
onHeaderSortable(columnManager.groupedColumns()); | ||
} | ||
_this.forceUpdate(); | ||
}); | ||
_this.forceUpdate(); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "updateColumn", function (columns, parent, newColumns) { | ||
columns = columns || []; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'updateColumn', | ||
function(columns, parent, newColumns) { | ||
columns = columns || []; | ||
if (!parent) { | ||
return newColumns; | ||
} | ||
if (!parent) { | ||
return newColumns; | ||
} | ||
return columns.map(function (column) { | ||
if (column[_types.CS._pathKey] === parent[_types.CS._pathKey]) { | ||
column = _objectSpread({}, column, { | ||
children: newColumns | ||
return columns.map(function(column) { | ||
if (column[_types.CS._pathKey] === parent[_types.CS._pathKey]) { | ||
column = _objectSpread({}, column, { | ||
children: newColumns | ||
}); | ||
} else { | ||
if (column.children && column.children.length > 0) { | ||
return _objectSpread({}, column, { | ||
children: _this.updateColumn( | ||
column.children, | ||
parent, | ||
newColumns | ||
) | ||
}); | ||
} | ||
} | ||
return column; | ||
}); | ||
} else { | ||
if (column.children && column.children.length > 0) { | ||
return _objectSpread({}, column, { | ||
children: _this.updateColumn(column.children, parent, newColumns) | ||
}); | ||
} | ||
} | ||
); | ||
return column; | ||
}); | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'getCellStyle', | ||
function(column, record) { | ||
var onCell = column.onCell; | ||
var align = column.align || 'left'; | ||
var width = column[_types.CS._width]; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getCellStyle", function (column, record) { | ||
var onCell = column.onCell; | ||
var align = column.align || 'left'; | ||
var width = column[_types.CS._width]; | ||
var style = _objectSpread({}, (0, _utils.cellAlignStyle)(align)); | ||
var style = _objectSpread({}, (0, _utils.cellAlignStyle)(align)); | ||
if (width) { | ||
style.width = width; | ||
style.minWidth = width; | ||
} | ||
if (width) { | ||
style.width = width; | ||
style.minWidth = width; | ||
} | ||
if (onCell) { | ||
style = _objectSpread({}, style, onCell(column, record)); | ||
} | ||
if (onCell) { | ||
style = _objectSpread({}, style, onCell(column, record)); | ||
} | ||
return style; | ||
} | ||
); | ||
return style; | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'getCellText', | ||
function(column, record) { | ||
var render = column.render, | ||
dataIndex = column.dataIndex; | ||
var text = (record || {})[dataIndex]; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getCellText", function (column, record) { | ||
var render = column.render, | ||
dataIndex = column.dataIndex; | ||
var text = (record || {})[dataIndex]; | ||
if (typeof render === 'function') { | ||
text = render(text, record, record[_types.DS._index]); | ||
} | ||
if (typeof render === 'function') { | ||
text = render(text, record, record[_types.DS._index]); | ||
} | ||
if ((0, _utils.isInvalidRenderCellText)(text)) { | ||
text = null; | ||
} | ||
if ((0, _utils.isInvalidRenderCellText)(text)) { | ||
text = null; | ||
} | ||
return text; | ||
} | ||
); | ||
return text; | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'recomputeBody', | ||
function(_ref) { | ||
var startIndex = _ref.startIndex, | ||
stopIndex = _ref.stopIndex; | ||
var _this$props = _this.props, | ||
hasBody = _this$props.hasBody, | ||
fixed = _this$props.fixed; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "recomputeBody", function (_ref) { | ||
var startIndex = _ref.startIndex, | ||
stopIndex = _ref.stopIndex; | ||
var _this$props = _this.props, | ||
hasBody = _this$props.hasBody, | ||
fixed = _this$props.fixed; | ||
if (hasBody) { | ||
_this._startIndex = startIndex; | ||
_this._stopIndex = stopIndex; | ||
} | ||
if (hasBody) { | ||
_this._startIndex = startIndex; | ||
_this._stopIndex = stopIndex; | ||
} | ||
if (fixed !== 'right') _this.forceUpdate(); | ||
} | ||
); | ||
if (fixed !== 'right') _this.forceUpdate(); | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'getRowStyle', | ||
function(record, key) { | ||
var _this$context$manager = _this.context.manager, | ||
sizeManager = _this$context$manager.sizeManager, | ||
cacheManager = _this$context$manager.cacheManager, | ||
dataManager = _this$context$manager.dataManager; | ||
var rowStyle = cacheManager.getRowStyle(key); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getRowStyle", function (record, key) { | ||
var _this$context$manager = _this.context.manager, | ||
sizeManager = _this$context$manager.sizeManager, | ||
cacheManager = _this$context$manager.cacheManager, | ||
dataManager = _this$context$manager.dataManager; | ||
var rowStyle = cacheManager.getRowStyle(key); | ||
if (!rowStyle || dataManager.isFixed(record)) { | ||
rowStyle = { | ||
position: 'absolute', | ||
top: record[_types.DS._top], | ||
height: record[_types.DS._height], | ||
lineHeight: ''.concat(record[_types.DS._height] - 1, 'px') | ||
}; | ||
if (!rowStyle || dataManager.isFixed(record)) { | ||
rowStyle = { | ||
position: 'absolute', | ||
top: record[_types.DS._top], | ||
height: record[_types.DS._height], | ||
lineHeight: "".concat(record[_types.DS._height] - 1, "px") | ||
}; | ||
if ( | ||
record[_types.DS._isFixed] === true || | ||
record[_types.DS._isFixed] === 'top' | ||
) { | ||
rowStyle.top += sizeManager._scrollTop; | ||
rowStyle.zIndex = 1; | ||
} else if (record[_types.DS._isFixed] === 'bottom') { | ||
if (sizeManager._hasScrollY) { | ||
rowStyle.top -= | ||
sizeManager._dataHeight + | ||
sizeManager.scrollSizeX() - | ||
sizeManager._scrollTop - | ||
sizeManager._clientBodyHeight; | ||
} | ||
if (record[_types.DS._isFixed] === true || record[_types.DS._isFixed] === 'top') { | ||
rowStyle.top += sizeManager._scrollTop; | ||
rowStyle.zIndex = 1; | ||
} else if (record[_types.DS._isFixed] === 'bottom') { | ||
if (sizeManager._hasScrollY) { | ||
rowStyle.top -= sizeManager._dataHeight + sizeManager.scrollSizeX() - sizeManager._scrollTop - sizeManager._clientBodyHeight; | ||
rowStyle.zIndex = 1; | ||
} | ||
if (!record[_types.DS._isFixed]) { | ||
cacheManager.setRowStyle(key, rowStyle); | ||
} | ||
} | ||
rowStyle.zIndex = 1; | ||
return rowStyle; | ||
} | ||
); | ||
if (!record[_types.DS._isFixed]) { | ||
cacheManager.setRowStyle(key, rowStyle); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'h_selectAll', | ||
function() { | ||
var _this$context$manager2 = _this.context.manager, | ||
selectManager = _this$context$manager2.selectManager, | ||
dataManager = _this$context$manager2.dataManager; | ||
var keys = selectManager.getKeys(dataManager.getData()); | ||
selectManager.selectAll(keys); | ||
} | ||
} | ||
); | ||
return rowStyle; | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'r_selectAll', | ||
function() { | ||
var prefixCls = _this.context.props.prefixCls; | ||
var _this$context$manager3 = _this.context.manager, | ||
selectManager = _this$context$manager3.selectManager, | ||
dataManager = _this$context$manager3.dataManager; | ||
var keys = selectManager.getKeys(dataManager.getData()); | ||
selectManager.count = keys.length; | ||
return (0, _Select.default)({ | ||
prefixCls: prefixCls, | ||
selected: selectManager.selectedAll, | ||
type: 'checkbox', | ||
onClick: _this.h_selectAll | ||
}); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "h_selectAll", function () { | ||
var _this$context$manager2 = _this.context.manager, | ||
selectManager = _this$context$manager2.selectManager, | ||
dataManager = _this$context$manager2.dataManager; | ||
var keys = selectManager.getKeys(dataManager.getData()); | ||
selectManager.selectAll(keys); | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'r_select', | ||
function(record) { | ||
var prefixCls = _this.context.props.prefixCls; | ||
var selectManager = _this.context.manager.selectManager; | ||
var selected = selectManager.selectedKeys.includes( | ||
record[_types.DS._key] | ||
); | ||
return (0, _Select.default)({ | ||
prefixCls: prefixCls, | ||
selected: selected, | ||
disabled: selectManager.disabled(record), | ||
type: selectManager.type, | ||
onClick: function onClick() { | ||
return selectManager.select(record, !selected); | ||
} | ||
}); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "r_selectAll", function () { | ||
var prefixCls = _this.context.props.prefixCls; | ||
var _this$context$manager3 = _this.context.manager, | ||
selectManager = _this$context$manager3.selectManager, | ||
dataManager = _this$context$manager3.dataManager; | ||
var keys = selectManager.getKeys(dataManager.getData()); | ||
selectManager.count = keys.length; | ||
return (0, _Select.default)({ | ||
prefixCls: prefixCls, | ||
selected: selectManager.selectedAll, | ||
type: 'checkbox', | ||
onClick: _this.h_selectAll | ||
}); | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'renderCells', | ||
function(props, record) { | ||
var fixed = props.fixed; | ||
var _this$context$props2 = _this.context.props, | ||
prefixCls = _this$context$props2.prefixCls, | ||
indentSize = _this$context$props2.indentSize; | ||
var _this$context$manager4 = _this.context.manager, | ||
dataManager = _this$context$manager4.dataManager, | ||
cacheManager = _this$context$manager4.cacheManager, | ||
columnManager = _this$context$manager4.columnManager, | ||
selectManager = _this$context$manager4.selectManager; | ||
var columns = columnManager.bodyColumns(fixed); | ||
var hasExpanded = dataManager._hasExpanded; | ||
var cells = []; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "r_select", function (record) { | ||
var prefixCls = _this.context.props.prefixCls; | ||
var selectManager = _this.context.manager.selectManager; | ||
var selected = selectManager.selectedKeys.includes(record[_types.DS._key]); | ||
return (0, _Select.default)({ | ||
prefixCls: prefixCls, | ||
selected: selected, | ||
disabled: selectManager.disabled(record), | ||
type: selectManager.type, | ||
onClick: function onClick() { | ||
return selectManager.select(record, !selected); | ||
} | ||
}); | ||
}); | ||
for (var i = 0; i < columns.length; i++) { | ||
var cellKey = 'Row[' | ||
.concat(record[_types.DS._path], ']-Col[') | ||
.concat(columns[i][_types.CS._pathKey], ']-') | ||
.concat(i, '_') | ||
.concat(fixed || '', '-') | ||
.concat(_this._forceCount); | ||
var cell = cacheManager.getCell(cellKey); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderCells", function (props, record) { | ||
var fixed = props.fixed; | ||
var _this$context$props2 = _this.context.props, | ||
prefixCls = _this$context$props2.prefixCls, | ||
indentSize = _this$context$props2.indentSize; | ||
var _this$context$manager4 = _this.context.manager, | ||
dataManager = _this$context$manager4.dataManager, | ||
cacheManager = _this$context$manager4.cacheManager, | ||
columnManager = _this$context$manager4.columnManager, | ||
selectManager = _this$context$manager4.selectManager; | ||
var columns = columnManager.bodyColumns(fixed); | ||
var hasExpanded = dataManager._hasExpanded; | ||
var cells = []; | ||
if (!cell || record[_types.DS._isFixed]) { | ||
var cellProps = { | ||
key: cellKey, | ||
className: columns[i].className, | ||
style: _this.getCellStyle(columns[i], record), | ||
children: _this.getCellText(columns[i], record) | ||
}; | ||
for (var i = 0; i < columns.length; i++) { | ||
var cellKey = "Row[".concat(record[_types.DS._path], "]-Col[").concat(columns[i][_types.CS._pathKey], "]-").concat(i, "_").concat(fixed || '', "-").concat(_this._forceCount); | ||
var cell = cacheManager.getCell(cellKey); | ||
if (hasExpanded && fixed !== 'right' && i === 0) { | ||
cellProps.ExpandedIcon = (0, _ExpandedIcon.default)({ | ||
prefixCls: prefixCls, | ||
indentSize: indentSize, | ||
record: record, | ||
onClick: _this.fExpanded | ||
}); | ||
} | ||
if (!cell || record[_types.DS._isFixed]) { | ||
var cellProps = { | ||
key: cellKey, | ||
className: columns[i].className, | ||
style: _this.getCellStyle(columns[i], record), | ||
children: _this.getCellText(columns[i], record) | ||
}; | ||
if (selectManager.enable && fixed !== 'right' && i === 0) { | ||
cellProps.SelectIcon = _this.r_select(record, fixed); | ||
} | ||
if (hasExpanded && fixed !== 'right' && i === 0) { | ||
cellProps.ExpandedIcon = (0, _ExpandedIcon.default)({ | ||
prefixCls: prefixCls, | ||
indentSize: indentSize, | ||
record: record, | ||
onClick: _this.fExpanded | ||
}); | ||
} | ||
cacheManager.setCell(cellKey, (0, _TableCell.default)(cellProps)); | ||
cell = cacheManager.getCell(cellKey); | ||
} | ||
if (selectManager.enable && fixed !== 'right' && i === 0) { | ||
cellProps.SelectIcon = _this.r_select(record, fixed); | ||
cells.push(cell); | ||
} | ||
cacheManager.setCell(cellKey, (0, _TableCell.default)(cellProps)); | ||
cell = cacheManager.getCell(cellKey); | ||
return cells; | ||
} | ||
); | ||
cells.push(cell); | ||
} | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'renderRowChildren', | ||
function(props, record) { | ||
var expandedRowRender = _this.context.props.expandedRowRender; | ||
return cells; | ||
}); | ||
if (expandedRowRender && record[_types.DS._expandedLevel] > 0) { | ||
return expandedRowRender( | ||
record, | ||
props.fixed, | ||
record[_types.DS._expandedLevel] | ||
); | ||
} else { | ||
return _this.renderCells(props, record); | ||
} | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderRowChildren", function (props, record) { | ||
var expandedRowRender = _this.context.props.expandedRowRender; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'renderRows', | ||
function(props) { | ||
var rows = []; | ||
var fixed = props.fixed, | ||
currentHoverKey = props.currentHoverKey; | ||
var _this$context$props3 = _this.context.props, | ||
prefixCls = _this$context$props3.prefixCls, | ||
onRow = _this$context$props3.onRow; | ||
var dataManager = _this.context.manager.dataManager; | ||
var showData = dataManager.showData(); | ||
var dataSource = showData.filter(function(d, index) { | ||
return ( | ||
(index >= _this._startIndex && index <= _this._stopIndex) || | ||
dataManager.isFixed(d) | ||
); | ||
}); | ||
if (expandedRowRender && record[_types.DS._expandedLevel] > 0) { | ||
return expandedRowRender(record, props.fixed, record[_types.DS._expandedLevel]); | ||
} else { | ||
return _this.renderCells(props, record); | ||
} | ||
}); | ||
var _loop = function _loop(index) { | ||
var record = dataSource[index]; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderRows", function (props) { | ||
var rows = []; | ||
var fixed = props.fixed, | ||
currentHoverKey = props.currentHoverKey; | ||
var _this$context$props3 = _this.context.props, | ||
prefixCls = _this$context$props3.prefixCls, | ||
onRow = _this$context$props3.onRow; | ||
var dataManager = _this.context.manager.dataManager; | ||
var showData = dataManager.showData(); | ||
var dataSource = showData.filter(function (d, index) { | ||
return index >= _this._startIndex && index <= _this._stopIndex || dataManager.isFixed(d); | ||
}); | ||
var cells = _this.renderRowChildren(props, record); | ||
var _loop = function _loop(index) { | ||
var record = dataSource[index]; | ||
var key = 'Row_' | ||
.concat(fixed || '', '_') | ||
.concat(record[_types.DS._path], '_') | ||
.concat(_this._forceCount); | ||
var rowProps = { | ||
key: key, | ||
prefixCls: prefixCls, | ||
cells: cells, | ||
record: record, | ||
hovered: currentHoverKey === record[_types.DS._key], | ||
style: _this.getRowStyle(record, key), | ||
children: cells | ||
}; | ||
(0, _utils.keys)(onRow(record) || {}).forEach(function(event) { | ||
return (rowProps[event] = _this.fEvents); | ||
}); | ||
['onClick', 'onMouseEnter', 'onMouseLeave'].forEach(function( | ||
event | ||
) { | ||
if (!(0, _utils.has)(onRow(record), event)) { | ||
rowProps[event] = _this.fEvents; | ||
} | ||
}); | ||
rows.push((0, _TableRow.default)(rowProps)); | ||
}; | ||
var cells = _this.renderRowChildren(props, record); | ||
for (var index = 0; index < dataSource.length; index++) { | ||
_loop(index); | ||
} | ||
var key = "Row_".concat(fixed || '', "_").concat(record[_types.DS._path], "_").concat(_this._forceCount); | ||
var rowProps = { | ||
key: key, | ||
prefixCls: prefixCls, | ||
cells: cells, | ||
record: record, | ||
hovered: currentHoverKey === record[_types.DS._key], | ||
style: _this.getRowStyle(record, key), | ||
children: cells | ||
}; | ||
(0, _utils.keys)(onRow(record) || {}).forEach(function (event) { | ||
return rowProps[event] = _this.fEvents; | ||
}); | ||
['onClick', 'onMouseEnter', 'onMouseLeave'].forEach(function (event) { | ||
if (!(0, _utils.has)(onRow(record), event)) { | ||
rowProps[event] = _this.fEvents; | ||
_this._children = rows; | ||
return _this._children; | ||
} | ||
); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'r_header', | ||
function() { | ||
var _this$props2 = _this.props, | ||
hasHead = _this$props2.hasHead, | ||
fixed = _this$props2.fixed, | ||
orders = _this$props2.orders; | ||
var _this$context$manager5 = _this.context.manager, | ||
columnManager = _this$context$manager5.columnManager, | ||
selectManager = _this$context$manager5.selectManager; | ||
var _this$context$props4 = _this.context.props, | ||
prefixCls = _this$context$props4.prefixCls, | ||
headerRowHeight = _this$context$props4.headerRowHeight, | ||
onHeaderRow = _this$context$props4.onHeaderRow; | ||
if (!hasHead) return null; | ||
var props = { | ||
columns: columnManager.headColumns(fixed), | ||
fixed: fixed, | ||
onSort: _this.fSort, | ||
orders: orders, | ||
prefixCls: prefixCls, | ||
headerRowHeight: headerRowHeight, | ||
onHeaderRow: onHeaderRow, | ||
onDrag: _this.fDrag | ||
}; | ||
if (selectManager.useSelectAll) { | ||
props.SelectIcon = _this.r_selectAll(); | ||
props.selectedAll = selectManager.selectedAll; | ||
} | ||
}); | ||
rows.push((0, _TableRow.default)(rowProps)); | ||
}; | ||
for (var index = 0; index < dataSource.length; index++) { | ||
_loop(index); | ||
} | ||
return (0, _TableHeader.default)(props); | ||
} | ||
); | ||
_this._children = rows; | ||
return _this._children; | ||
}); | ||
return _this; | ||
} | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "r_header", function () { | ||
var _this$props2 = _this.props, | ||
hasHead = _this$props2.hasHead, | ||
fixed = _this$props2.fixed, | ||
orders = _this$props2.orders; | ||
var _this$context$manager5 = _this.context.manager, | ||
columnManager = _this$context$manager5.columnManager, | ||
selectManager = _this$context$manager5.selectManager; | ||
var _this$context$props4 = _this.context.props, | ||
prefixCls = _this$context$props4.prefixCls, | ||
headerRowHeight = _this$context$props4.headerRowHeight, | ||
onHeaderRow = _this$context$props4.onHeaderRow; | ||
if (!hasHead) return null; | ||
var props = { | ||
columns: columnManager.headColumns(fixed), | ||
fixed: fixed, | ||
onSort: _this.fSort, | ||
orders: orders, | ||
prefixCls: prefixCls, | ||
headerRowHeight: headerRowHeight, | ||
onHeaderRow: onHeaderRow, | ||
onDrag: _this.fDrag | ||
}; | ||
_createClass(BaseTable, [ | ||
{ | ||
key: 'componentWillMount', | ||
value: function componentWillMount() { | ||
this._forceCount = 0; | ||
var _this$props3 = this.props, | ||
registerForce = _this$props3.registerForce, | ||
fixed = _this$props3.fixed, | ||
hasHead = _this$props3.hasHead, | ||
hasBody = _this$props3.hasBody; | ||
var sizeManager = this.context.manager.sizeManager; | ||
if (selectManager.useSelectAll) { | ||
props.SelectIcon = _this.r_selectAll(); | ||
props.selectedAll = selectManager.selectedAll; | ||
} | ||
if (registerForce) { | ||
var name = fixed; | ||
return (0, _TableHeader.default)(props); | ||
}); | ||
if (hasHead) { | ||
name += '-head'; | ||
} | ||
return _this; | ||
} | ||
if (hasBody) { | ||
name += '-body'; | ||
} | ||
_createClass(BaseTable, [{ | ||
key: "componentWillMount", | ||
value: function componentWillMount() { | ||
this._forceCount = 0; | ||
var _this$props3 = this.props, | ||
registerForce = _this$props3.registerForce, | ||
fixed = _this$props3.fixed, | ||
hasHead = _this$props3.hasHead, | ||
hasBody = _this$props3.hasBody; | ||
var sizeManager = this.context.manager.sizeManager; | ||
registerForce(name, this.recomputeBody); | ||
} | ||
if (registerForce) { | ||
var name = fixed; | ||
if (hasHead) { | ||
name += '-head'; | ||
this._startIndex = sizeManager._startIndex; | ||
this._stopIndex = sizeManager._stopIndex; | ||
this.renderRows(this.props); | ||
} | ||
}, | ||
{ | ||
key: 'componentWillUpdate', | ||
value: function componentWillUpdate(nextProps, nextState, nextContext) { | ||
var hasBody = nextProps.hasBody; | ||
if (hasBody) { | ||
name += '-body'; | ||
if (hasBody) { | ||
this.renderRows(nextProps); | ||
} | ||
} | ||
}, | ||
{ | ||
key: 'render', | ||
value: function render() { | ||
var _this$props4 = this.props, | ||
hasBody = _this$props4.hasBody, | ||
fixed = _this$props4.fixed; | ||
var _this$context$manager6 = this.context.manager, | ||
columnManager = _this$context$manager6.columnManager, | ||
sizeManager = _this$context$manager6.sizeManager; | ||
var rowHeight = this.context.props.rowHeight; | ||
var body; | ||
registerForce(name, this.recomputeBody); | ||
} | ||
if (hasBody) { | ||
body = _react.default.createElement( | ||
'div', | ||
{ | ||
className: 'tbody', | ||
style: { | ||
height: sizeManager._dataHeight, | ||
minHeight: rowHeight | ||
} | ||
}, | ||
this._children | ||
); | ||
} | ||
this._startIndex = sizeManager._startIndex; | ||
this._stopIndex = sizeManager._stopIndex; | ||
this.renderRows(this.props); | ||
} | ||
}, { | ||
key: "componentWillUpdate", | ||
value: function componentWillUpdate(nextProps, nextState, nextContext) { | ||
var hasBody = nextProps.hasBody; | ||
var width = columnManager.getWidth(fixed) || '100%'; | ||
var style = { | ||
width: width | ||
}; | ||
if (hasBody) { | ||
this.renderRows(nextProps); | ||
} | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _this$props4 = this.props, | ||
hasBody = _this$props4.hasBody, | ||
fixed = _this$props4.fixed; | ||
var _this$context$manager6 = this.context.manager, | ||
columnManager = _this$context$manager6.columnManager, | ||
sizeManager = _this$context$manager6.sizeManager; | ||
var rowHeight = this.context.props.rowHeight; | ||
var body; | ||
if (hasBody) { | ||
body = _react.default.createElement("div", { | ||
className: "tbody", | ||
style: { | ||
height: sizeManager._dataHeight, | ||
minHeight: rowHeight | ||
if (!fixed) { | ||
style.minWidth = '100%'; | ||
} | ||
}, this._children); | ||
} | ||
var width = columnManager.getWidth(fixed) || '100%'; | ||
var style = { | ||
width: width | ||
}; | ||
if (!fixed) { | ||
style.minWidth = '100%'; | ||
var header = this.r_header(); | ||
return _react.default.createElement( | ||
'div', | ||
{ | ||
className: 'table', | ||
style: style | ||
}, | ||
header, | ||
body | ||
); | ||
} | ||
} | ||
]); | ||
var header = this.r_header(); | ||
return _react.default.createElement("div", { | ||
className: "table", | ||
style: style | ||
}, header, body); | ||
} | ||
}]); | ||
return BaseTable; | ||
})(_react.default.PureComponent); | ||
return BaseTable; | ||
}(_react.default.PureComponent); | ||
_defineProperty(BaseTable, "contextTypes", { | ||
_defineProperty(BaseTable, 'contextTypes', { | ||
props: _propTypes.default.object, | ||
@@ -530,5 +775,5 @@ manager: _propTypes.default.object, | ||
var _default = (0, _miniStore.connect)(function (state) { | ||
var _default = (0, _miniStore.connect)(function(state) { | ||
var currentHoverKey = state.currentHoverKey, | ||
orders = state.orders; | ||
orders = state.orders; | ||
return { | ||
@@ -540,2 +785,2 @@ currentHoverKey: currentHoverKey, | ||
exports.default = _default; | ||
exports.default = _default; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,31 +8,76 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _propTypes = _interopRequireDefault(require('prop-types')); | ||
var _BaseTable = _interopRequireDefault(require("./BaseTable")); | ||
var _BaseTable = _interopRequireDefault(require('./BaseTable')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function _extends() { | ||
_extends = | ||
Object.assign || | ||
function(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat( | ||
Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
}) | ||
); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
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 _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 BodyTable(props, _ref) { | ||
var manager = _ref.manager, | ||
baseProps = _ref.props, | ||
getProps = _ref.getProps; | ||
baseProps = _ref.props, | ||
getProps = _ref.getProps; | ||
var columnManager = manager.columnManager, | ||
sizeManager = manager.sizeManager; | ||
sizeManager = manager.sizeManager; | ||
var prefixCls = baseProps.prefixCls, | ||
fixedHeader = baseProps.fixedHeader, | ||
showHeader = baseProps.showHeader, | ||
dataSource = baseProps.dataSource, | ||
bodyMaxHeight = baseProps.bodyMaxHeight; | ||
fixedHeader = baseProps.fixedHeader, | ||
showHeader = baseProps.showHeader, | ||
dataSource = baseProps.dataSource, | ||
bodyMaxHeight = baseProps.bodyMaxHeight; | ||
var saveRef = props.saveRef, | ||
fixed = props.fixed, | ||
handleBodyScroll = props.handleBodyScroll, | ||
registerForce = props.registerForce; | ||
fixed = props.fixed, | ||
handleBodyScroll = props.handleBodyScroll, | ||
registerForce = props.registerForce; | ||
@@ -51,3 +96,4 @@ var baseTable = _react.default.createElement(_BaseTable.default, { | ||
height = sizeManager._wrapperHeight - sizeManager.footerHeight; | ||
height = height - (showHeader && fixedHeader ? sizeManager._headerHeight : 0); | ||
height = | ||
height - (showHeader && fixedHeader ? sizeManager._headerHeight : 0); | ||
} | ||
@@ -81,3 +127,3 @@ | ||
if (scrollSize > 0 && fixed) { | ||
style.marginBottom = "-".concat(scrollSize, "px"); | ||
style.marginBottom = '-'.concat(scrollSize, 'px'); | ||
style.paddingBottom = '0px'; | ||
@@ -112,21 +158,39 @@ } | ||
return _react.default.createElement("div", { | ||
key: "bodyTable", | ||
className: "".concat(prefixCls, "-body-outer"), | ||
style: _objectSpread({}, style) | ||
}, _react.default.createElement("div", _extends({ | ||
className: "".concat(prefixCls, "-body-inner"), | ||
style: { | ||
height: '100%', | ||
overflowY: sizeManager._hasScrollY ? 'scroll' : 'hidden', | ||
overflowX: sizeManager._hasScrollX ? 'scroll' : 'hidden' | ||
} | ||
}, bodyProps), baseTable)); | ||
return _react.default.createElement( | ||
'div', | ||
{ | ||
key: 'bodyTable', | ||
className: ''.concat(prefixCls, '-body-outer'), | ||
style: _objectSpread({}, style) | ||
}, | ||
_react.default.createElement( | ||
'div', | ||
_extends( | ||
{ | ||
className: ''.concat(prefixCls, '-body-inner'), | ||
style: { | ||
height: '100%', | ||
overflowY: sizeManager._hasScrollY ? 'scroll' : 'hidden', | ||
overflowX: sizeManager._hasScrollX ? 'scroll' : 'hidden' | ||
} | ||
}, | ||
bodyProps | ||
), | ||
baseTable | ||
) | ||
); | ||
} | ||
return _react.default.createElement("div", _extends({ | ||
key: "bodyTable", | ||
className: "".concat(prefixCls, "-body"), | ||
style: style | ||
}, bodyProps), baseTable); | ||
return _react.default.createElement( | ||
'div', | ||
_extends( | ||
{ | ||
key: 'bodyTable', | ||
className: ''.concat(prefixCls, '-body'), | ||
style: style | ||
}, | ||
bodyProps | ||
), | ||
baseTable | ||
); | ||
} | ||
@@ -140,2 +204,2 @@ | ||
getProps: _propTypes.default.func | ||
}; | ||
}; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,41 +8,127 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _classnames = _interopRequireDefault(require('classnames')); | ||
var _types = require("./types"); | ||
var _types = require('./types'); | ||
var _Icon = _interopRequireDefault(require("./Icon")); | ||
var _Icon = _interopRequireDefault(require('./Icon')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure undefined"); } | ||
function _objectDestructuringEmpty(obj) { | ||
if (obj == null) throw new TypeError('Cannot destructure undefined'); | ||
} | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function _extends() { | ||
_extends = | ||
Object.assign || | ||
function(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat( | ||
Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
}) | ||
); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
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 _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(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutProperties(source, excluded) { | ||
if (source == null) return {}; | ||
var target = _objectWithoutPropertiesLoose(source, excluded); | ||
var key, i; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
key = sourceSymbolKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
target[key] = source[key]; | ||
} | ||
} | ||
return target; | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return target; | ||
} | ||
function ExpandedIcon(props) { | ||
var prefixCls = props.prefixCls, | ||
record = props.record, | ||
expanded = props.expanded, | ||
other = _objectWithoutProperties(props, ["prefixCls", "record", "expanded"]); | ||
record = props.record, | ||
expanded = props.expanded, | ||
other = _objectWithoutProperties(props, [ | ||
'prefixCls', | ||
'record', | ||
'expanded' | ||
]); | ||
var newProps = _objectSpread({ | ||
className: (0, _classnames.default)("".concat(prefixCls, "-expanded-icon"), { | ||
expanded: expanded | ||
var newProps = _objectSpread( | ||
{ | ||
className: (0, _classnames.default)( | ||
''.concat(prefixCls, '-expanded-icon'), | ||
{ | ||
expanded: expanded | ||
} | ||
) | ||
}, | ||
other | ||
); | ||
return _react.default.createElement( | ||
'span', | ||
_extends({}, newProps, { | ||
'data-key': record[_types.DS._key] | ||
}), | ||
_react.default.createElement(_Icon.default, { | ||
type: expanded ? 'minus' : 'plus' | ||
}) | ||
}, other); | ||
return _react.default.createElement("span", _extends({}, newProps, { | ||
"data-key": record[_types.DS._key] | ||
}), _react.default.createElement(_Icon.default, { | ||
type: expanded ? 'minus' : 'plus' | ||
})); | ||
); | ||
} | ||
@@ -52,5 +138,5 @@ | ||
var prefixCls = props.prefixCls, | ||
indentSize = props.indentSize, | ||
record = props.record, | ||
onClick = props.onClick; | ||
indentSize = props.indentSize, | ||
record = props.record, | ||
onClick = props.onClick; | ||
@@ -75,19 +161,25 @@ var _ref = record || []; | ||
return _react.default.createElement("div", { | ||
style: { | ||
display: 'inline-block', | ||
textAlign: 'left', | ||
verticalAlign: 'middle' | ||
} | ||
}, _react.default.createElement("span", { | ||
style: { | ||
width: expandedLevel * indentSize, | ||
display: 'inline-block' | ||
} | ||
}), icon || _react.default.createElement("span", { | ||
style: { | ||
width: indentSize, | ||
display: 'inline-block' | ||
} | ||
})); | ||
} | ||
return _react.default.createElement( | ||
'div', | ||
{ | ||
style: { | ||
display: 'inline-block', | ||
textAlign: 'left', | ||
verticalAlign: 'middle' | ||
} | ||
}, | ||
_react.default.createElement('span', { | ||
style: { | ||
width: expandedLevel * indentSize, | ||
display: 'inline-block' | ||
} | ||
}), | ||
icon || | ||
_react.default.createElement('span', { | ||
style: { | ||
width: indentSize, | ||
display: 'inline-block' | ||
} | ||
}) | ||
); | ||
} |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,39 +8,69 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _classnames = _interopRequireDefault(require('classnames')); | ||
var _utils = require("./utils"); | ||
var _utils = require('./utils'); | ||
var _Sorter = _interopRequireDefault(require("./Sorter")); | ||
var _Sorter = _interopRequireDefault(require('./Sorter')); | ||
var _types = require("./types"); | ||
var _types = require('./types'); | ||
var _Sortable = _interopRequireDefault(require("./Sortable")); | ||
var _Sortable = _interopRequireDefault(require('./Sortable')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat( | ||
Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
}) | ||
); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
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 _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 HeadCell(props) { | ||
var key = props.key, | ||
column = props.column, | ||
_props$current = props.current, | ||
current = _props$current === void 0 ? 0 : _props$current, | ||
prefixCls = props.prefixCls, | ||
headerRowHeight = props.headerRowHeight, | ||
orders = props.orders, | ||
onSort = props.onSort, | ||
fixed = props.fixed, | ||
onHeaderRow = props.onHeaderRow, | ||
onDrag = props.onDrag, | ||
SelectIcon = props.SelectIcon; | ||
column = props.column, | ||
_props$current = props.current, | ||
current = _props$current === void 0 ? 0 : _props$current, | ||
prefixCls = props.prefixCls, | ||
headerRowHeight = props.headerRowHeight, | ||
orders = props.orders, | ||
onSort = props.onSort, | ||
fixed = props.fixed, | ||
onHeaderRow = props.onHeaderRow, | ||
onDrag = props.onDrag, | ||
SelectIcon = props.SelectIcon; | ||
var children = column.children || []; | ||
var dataIndex = column.dataIndex, | ||
align = column.align, | ||
title = column.title, | ||
sortEnable = column.sortEnable, | ||
onHeaderCell = column.onHeaderCell; | ||
align = column.align, | ||
title = column.title, | ||
sortEnable = column.sortEnable, | ||
onHeaderCell = column.onHeaderCell; | ||
var rowSpan = column[_types.CS.rowSpan]; | ||
@@ -59,3 +89,3 @@ var width = column[_types.CS._width]; | ||
style.height = (rowSpan || 1) * headerRowHeight; | ||
style.lineHeight = "".concat(style.height - 1, "px"); | ||
style.lineHeight = ''.concat(style.height - 1, 'px'); | ||
@@ -100,8 +130,17 @@ if (onHeaderCell) { | ||
if (sortEnable && children.length === 0) { | ||
cellProps.onClick = function () { | ||
return onSort(column.dataIndex, order === 'desc' || order === true ? 'asc' : 'desc'); | ||
cellProps.onClick = function() { | ||
return onSort( | ||
column.dataIndex, | ||
order === 'desc' || order === true ? 'asc' : 'desc' | ||
); | ||
}; | ||
} | ||
var cell = _react.default.createElement("div", cellProps, SelectIcon, text, sorter); | ||
var cell = _react.default.createElement( | ||
'div', | ||
cellProps, | ||
SelectIcon, | ||
text, | ||
sorter | ||
); | ||
@@ -116,26 +155,42 @@ if (children.length > 0) { | ||
return _react.default.createElement("div", { | ||
className: current === 0 ? 'row-group' : '', | ||
key: key, | ||
style: _style, | ||
fixed: fixed | ||
}, cell, _react.default.createElement("div", { | ||
className: "col-group" | ||
}, _react.default.createElement(_Sortable.default, { | ||
parent: column, | ||
columns: children, | ||
onDrag: onDrag | ||
}, children.map(function (child, i) { | ||
return HeadCell({ | ||
key: "".concat(key, "-").concat(current, "-").concat(i), | ||
column: child, | ||
headerRowHeight: headerRowHeight, | ||
current: current + 1, | ||
orders: orders, | ||
prefixCls: prefixCls, | ||
onSort: onSort, | ||
fixed: fixed, | ||
onDrag: onDrag | ||
}); | ||
})))); | ||
return _react.default.createElement( | ||
'div', | ||
{ | ||
className: current === 0 ? 'row-group' : '', | ||
key: key, | ||
style: _style, | ||
fixed: fixed | ||
}, | ||
cell, | ||
_react.default.createElement( | ||
'div', | ||
{ | ||
className: 'col-group' | ||
}, | ||
_react.default.createElement( | ||
_Sortable.default, | ||
{ | ||
parent: column, | ||
columns: children, | ||
onDrag: onDrag | ||
}, | ||
children.map(function(child, i) { | ||
return HeadCell({ | ||
key: '' | ||
.concat(key, '-') | ||
.concat(current, '-') | ||
.concat(i), | ||
column: child, | ||
headerRowHeight: headerRowHeight, | ||
current: current + 1, | ||
orders: orders, | ||
prefixCls: prefixCls, | ||
onSort: onSort, | ||
fixed: fixed, | ||
onDrag: onDrag | ||
}); | ||
}) | ||
) | ||
) | ||
); | ||
} | ||
@@ -147,2 +202,2 @@ | ||
var _default = HeadCell; | ||
exports.default = _default; | ||
exports.default = _default; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,21 +8,23 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _propTypes = _interopRequireDefault(require('prop-types')); | ||
var _BaseTable = _interopRequireDefault(require("./BaseTable")); | ||
var _BaseTable = _interopRequireDefault(require('./BaseTable')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function HeadTable(props, _ref) { | ||
var manager = _ref.manager, | ||
baseProps = _ref.props; | ||
baseProps = _ref.props; | ||
var fixedHeader = baseProps.fixedHeader, | ||
prefixCls = baseProps.prefixCls, | ||
showHeader = baseProps.showHeader; | ||
prefixCls = baseProps.prefixCls, | ||
showHeader = baseProps.showHeader; | ||
var saveRef = props.saveRef, | ||
fixed = props.fixed, | ||
registerForce = props.registerForce; | ||
fixed = props.fixed, | ||
registerForce = props.registerForce; | ||
var sizeManager = manager.sizeManager, | ||
columnManager = manager.columnManager; | ||
columnManager = manager.columnManager; | ||
var headStyle = {}; | ||
@@ -34,3 +36,3 @@ | ||
if (scrollbarWidth > 0 && !fixed) { | ||
headStyle.marginBottom = "-".concat(scrollbarWidth, "px"); | ||
headStyle.marginBottom = '-'.concat(scrollbarWidth, 'px'); | ||
headStyle.paddingBottom = '0px'; | ||
@@ -44,14 +46,18 @@ } | ||
headStyle.overflowY = sizeManager._hasScrollY ? 'scroll' : 'hidden'; | ||
return _react.default.createElement("div", { | ||
key: "headTable", | ||
className: "".concat(prefixCls, "-header"), | ||
style: headStyle, | ||
ref: fixed ? null : saveRef('headTable') | ||
}, _react.default.createElement(_BaseTable.default, { | ||
hasHead: true, | ||
hasBody: false, | ||
fixed: fixed, | ||
registerForce: registerForce, | ||
columns: columnManager.headColumns(fixed) | ||
})); | ||
return _react.default.createElement( | ||
'div', | ||
{ | ||
key: 'headTable', | ||
className: ''.concat(prefixCls, '-header'), | ||
style: headStyle, | ||
ref: fixed ? null : saveRef('headTable') | ||
}, | ||
_react.default.createElement(_BaseTable.default, { | ||
hasHead: true, | ||
hasBody: false, | ||
fixed: fixed, | ||
registerForce: registerForce, | ||
columns: columnManager.headColumns(fixed) | ||
}) | ||
); | ||
} | ||
@@ -67,2 +73,2 @@ | ||
manager: _propTypes.default.object | ||
}; | ||
}; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,11 +8,17 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
var Path = { | ||
checkbox: 'M896 0l-768 0c-70.41024 0-128 57.61024-128 128l0 768c0 70.41024 57.61024 128 128 128l768 0c70.41024 0 128-57.61024 128-128l0-768c0-70.41024-57.61024-128-128-128zM448 794.50112l-237.2608-237.2608 90.50112-90.50112 146.7392 146.7392 306.74944-306.74944 90.50112 90.50112-397.25056 397.25056z', | ||
radio: 'M512 4.533c-279.803 0-507.467 227.665-507.467 507.467 0 279.839 227.629 507.467 507.467 507.467 279.839 0 507.467-227.629 507.467-507.467 0-279.803-227.629-507.467-507.467-507.467zM512 946.65c-239.68 0-434.65-195.006-434.65-434.65 0-239.68 194.97-434.65 434.65-434.65 239.644 0 434.65 194.97 434.65 434.65 0 239.644-195.006 434.65-434.65 434.65zM512 329.955c-100.38 0-182.045 81.665-182.045 182.045s81.665 182.045 182.045 182.045 182.045-81.665 182.045-182.045-81.665-182.045-182.045-182.045z', | ||
plus: 'M810.666667 469.333333h-256V213.333333a42.666667 42.666667 0 0 0-85.333334 0v256H213.333333a42.666667 42.666667 0 0 0 0 85.333334h256v256a42.666667 42.666667 0 0 0 85.333334 0v-256h256a42.666667 42.666667 0 0 0 0-85.333334z', | ||
minus: 'M810.666667 554.666667H213.333333a42.666667 42.666667 0 0 1 0-85.333334h597.333334a42.666667 42.666667 0 0 1 0 85.333334z' | ||
checkbox: | ||
'M896 0l-768 0c-70.41024 0-128 57.61024-128 128l0 768c0 70.41024 57.61024 128 128 128l768 0c70.41024 0 128-57.61024 128-128l0-768c0-70.41024-57.61024-128-128-128zM448 794.50112l-237.2608-237.2608 90.50112-90.50112 146.7392 146.7392 306.74944-306.74944 90.50112 90.50112-397.25056 397.25056z', | ||
radio: | ||
'M512 4.533c-279.803 0-507.467 227.665-507.467 507.467 0 279.839 227.629 507.467 507.467 507.467 279.839 0 507.467-227.629 507.467-507.467 0-279.803-227.629-507.467-507.467-507.467zM512 946.65c-239.68 0-434.65-195.006-434.65-434.65 0-239.68 194.97-434.65 434.65-434.65 239.644 0 434.65 194.97 434.65 434.65 0 239.644-195.006 434.65-434.65 434.65zM512 329.955c-100.38 0-182.045 81.665-182.045 182.045s81.665 182.045 182.045 182.045 182.045-81.665 182.045-182.045-81.665-182.045-182.045-182.045z', | ||
plus: | ||
'M810.666667 469.333333h-256V213.333333a42.666667 42.666667 0 0 0-85.333334 0v256H213.333333a42.666667 42.666667 0 0 0 0 85.333334h256v256a42.666667 42.666667 0 0 0 85.333334 0v-256h256a42.666667 42.666667 0 0 0 0-85.333334z', | ||
minus: | ||
'M810.666667 554.666667H213.333333a42.666667 42.666667 0 0 1 0-85.333334h597.333334a42.666667 42.666667 0 0 1 0 85.333334z' | ||
}; | ||
@@ -22,17 +28,21 @@ | ||
var type = _ref.type; | ||
return _react.default.createElement("svg", { | ||
viewBox: "0 0 1024 1024", | ||
className: "", | ||
"data-icon": type, | ||
width: "1em", | ||
height: "1em", | ||
fill: "currentColor", | ||
"aria-hidden": "true", | ||
focusable: "false", | ||
style: { | ||
display: 'inline-block' | ||
} | ||
}, _react.default.createElement("path", { | ||
d: Path[type] | ||
})); | ||
} | ||
return _react.default.createElement( | ||
'svg', | ||
{ | ||
viewBox: '0 0 1024 1024', | ||
className: '', | ||
'data-icon': type, | ||
width: '1em', | ||
height: '1em', | ||
fill: 'currentColor', | ||
'aria-hidden': 'true', | ||
focusable: 'false', | ||
style: { | ||
display: 'inline-block' | ||
} | ||
}, | ||
_react.default.createElement('path', { | ||
d: Path[type] | ||
}) | ||
); | ||
} |
1453
lib/index.js
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,711 +8,1078 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _propTypes = _interopRequireDefault(require('prop-types')); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _classnames = _interopRequireDefault(require('classnames')); | ||
var _floor = _interopRequireDefault(require("lodash/floor")); | ||
var _floor = _interopRequireDefault(require('lodash/floor')); | ||
var _ceil = _interopRequireDefault(require("lodash/ceil")); | ||
var _ceil = _interopRequireDefault(require('lodash/ceil')); | ||
var _shallowequal = _interopRequireDefault(require("shallowequal")); | ||
var _shallowequal = _interopRequireDefault(require('shallowequal')); | ||
var _componentClasses = _interopRequireDefault(require("component-classes")); | ||
var _componentClasses = _interopRequireDefault(require('component-classes')); | ||
var _HeadTable = _interopRequireDefault(require("./HeadTable")); | ||
var _HeadTable = _interopRequireDefault(require('./HeadTable')); | ||
var _BodyTable = _interopRequireDefault(require("./BodyTable")); | ||
var _BodyTable = _interopRequireDefault(require('./BodyTable')); | ||
var _ColumnManager = _interopRequireDefault(require("./managers/ColumnManager")); | ||
var _ColumnManager = _interopRequireDefault( | ||
require('./managers/ColumnManager') | ||
); | ||
var _DataManager = _interopRequireDefault(require("./managers/DataManager")); | ||
var _DataManager = _interopRequireDefault(require('./managers/DataManager')); | ||
var _SortManager = _interopRequireDefault(require("./managers/SortManager")); | ||
var _SortManager = _interopRequireDefault(require('./managers/SortManager')); | ||
var _SizeManager = _interopRequireDefault(require("./managers/SizeManager")); | ||
var _SizeManager = _interopRequireDefault(require('./managers/SizeManager')); | ||
var _CacheManager = _interopRequireDefault(require("./managers/CacheManager")); | ||
var _CacheManager = _interopRequireDefault(require('./managers/CacheManager')); | ||
var _SelectManager = _interopRequireDefault(require("./managers/SelectManager")); | ||
var _SelectManager = _interopRequireDefault( | ||
require('./managers/SelectManager') | ||
); | ||
var _AutoSizer = _interopRequireDefault(require("./AutoSizer")); | ||
var _AutoSizer = _interopRequireDefault(require('./AutoSizer')); | ||
var _miniStore = require("./mini-store"); | ||
var _miniStore = require('./mini-store'); | ||
var _types = require("./types"); | ||
var _types = require('./types'); | ||
var _utils = require("./utils"); | ||
var _utils = require('./utils'); | ||
require("../theme/table.css"); | ||
require('../theme/table.css'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { | ||
if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') { | ||
_typeof = function _typeof(obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && | ||
typeof Symbol === 'function' && | ||
obj.constructor === Symbol && | ||
obj !== Symbol.prototype | ||
? 'symbol' | ||
: typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat( | ||
Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
}) | ||
); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a 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); } } | ||
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); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === 'object' || typeof call === 'function')) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf | ||
? Object.getPrototypeOf | ||
: function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== 'function' && superClass !== null) { | ||
throw new TypeError('Super expression must either be null or a function'); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: {value: subClass, writable: true, configurable: true} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = | ||
Object.setPrototypeOf || | ||
function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError( | ||
"this hasn't been initialised - super() hasn't been called" | ||
); | ||
} | ||
return self; | ||
} | ||
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 _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; | ||
} | ||
var Table = | ||
/*#__PURE__*/ | ||
function (_React$PureComponent) { | ||
_inherits(Table, _React$PureComponent); | ||
/*#__PURE__*/ | ||
(function(_React$PureComponent) { | ||
_inherits(Table, _React$PureComponent); | ||
function Table(props) { | ||
var _this; | ||
function Table(props) { | ||
var _this; | ||
_classCallCheck(this, Table); | ||
_classCallCheck(this, Table); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(Table).call(this, props)); | ||
_this = _possibleConstructorReturn( | ||
this, | ||
_getPrototypeOf(Table).call(this, props) | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_forceTable", {}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_forceTable', | ||
{} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_renderEnable", false); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_renderEnable', | ||
false | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", { | ||
width: 0, | ||
height: 0 | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'state', | ||
{ | ||
width: 0, | ||
height: 0 | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "updateAll", function () { | ||
_this.cacheManager.reset(); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'updateAll', | ||
function() { | ||
_this.cacheManager.reset(); | ||
_this.resetShowData(); | ||
}); | ||
_this.resetShowData(); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getProps", function (prop) { | ||
return _this.props[prop]; | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'getProps', | ||
function(prop) { | ||
return _this.props[prop]; | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getShowCount", function () { | ||
var showHeader = _this.props.showHeader; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'getShowCount', | ||
function() { | ||
var showHeader = _this.props.showHeader; | ||
var dataSource = _this.dataManager.showData(); | ||
var dataSource = _this.dataManager.showData(); | ||
if (!_this.sizeManager.useScrollY) { | ||
_this.showCount = (dataSource || []).length; | ||
return; | ||
} | ||
if (!_this.sizeManager.useScrollY) { | ||
_this.showCount = (dataSource || []).length; | ||
return; | ||
} | ||
var _height = _this._height || 0; | ||
var _height = _this._height || 0; | ||
if (showHeader) { | ||
_height -= _this.sizeManager._headerHeight; | ||
_height = Math.max(_height, 0); | ||
} | ||
if (showHeader) { | ||
_height -= _this.sizeManager._headerHeight; | ||
_height = Math.max(_height, 0); | ||
} | ||
_this.showCount = Math.min((0, _ceil.default)(_height / _this.props.rowHeight), dataSource.length); | ||
}); | ||
_this.showCount = Math.min( | ||
(0, _ceil.default)(_height / _this.props.rowHeight), | ||
dataSource.length | ||
); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onResize", function (_ref) { | ||
var width = _ref.width, | ||
height = _ref.height; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'onResize', | ||
function(_ref) { | ||
var width = _ref.width, | ||
height = _ref.height; | ||
if (_this._width !== width || _this._height !== height) { | ||
_this._renderEnable = true; | ||
_this._width = width; | ||
_this._height = height; | ||
if (_this._width !== width || _this._height !== height) { | ||
_this._renderEnable = true; | ||
_this._width = width; | ||
_this._height = height; | ||
_this.cacheManager.reset(); | ||
_this.cacheManager.reset(); | ||
_this.sizeManager.update({ | ||
_wrapperWidth: width, | ||
_wrapperHeight: height, | ||
_scrollSizeX: (0, _utils.measureScrollbar)('horizontal'), | ||
_scrollSizeY: (0, _utils.measureScrollbar)() | ||
}); | ||
_this.sizeManager.update({ | ||
_wrapperWidth: width, | ||
_wrapperHeight: height, | ||
_scrollSizeX: (0, _utils.measureScrollbar)('horizontal'), | ||
_scrollSizeY: (0, _utils.measureScrollbar)() | ||
}); | ||
_this.getShowCount(); | ||
_this.getShowCount(); | ||
_this.updateColumn(); | ||
_this.updateColumn(); | ||
_this.resetShowData(); | ||
} | ||
}); | ||
_this.resetShowData(); | ||
} | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "updateColumn", function () { | ||
if (_this.sizeManager._wrapperWidth > 0) { | ||
var cWidth = _this.sizeManager._wrapperWidth - _this.sizeManager.scrollSizeY(); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'updateColumn', | ||
function() { | ||
if (_this.sizeManager._wrapperWidth > 0) { | ||
var cWidth = | ||
_this.sizeManager._wrapperWidth - _this.sizeManager.scrollSizeY(); | ||
_this.sizeManager.update(_this.columnManager.updateWidth(cWidth)); | ||
} | ||
}); | ||
_this.sizeManager.update(_this.columnManager.updateWidth(cWidth)); | ||
} | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleBodyScroll", function (e) { | ||
var onScroll = _this.props.onScroll; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'handleBodyScroll', | ||
function(e) { | ||
var onScroll = _this.props.onScroll; | ||
_this.handleBodyScrollLeft(e); | ||
_this.handleBodyScrollLeft(e); | ||
_this.handleBodyScrollTop(e); | ||
_this.handleBodyScrollTop(e); | ||
if (typeof onScroll === 'function') { | ||
onScroll(e); | ||
} | ||
}); | ||
if (typeof onScroll === 'function') { | ||
onScroll(e); | ||
} | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleBodyScrollLeft", function (e) { | ||
if (e.currentTarget !== e.target) { | ||
return; | ||
} | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'handleBodyScrollLeft', | ||
function(e) { | ||
if (e.currentTarget !== e.target) { | ||
return; | ||
} | ||
var target = e.target; | ||
var target = e.target; | ||
var _assertThisInitialize = _assertThisInitialized(_assertThisInitialized(_this)), | ||
headTable = _assertThisInitialize.headTable, | ||
bodyTable = _assertThisInitialize.bodyTable; | ||
var _assertThisInitialize = _assertThisInitialized( | ||
_assertThisInitialized(_this) | ||
), | ||
headTable = _assertThisInitialize.headTable, | ||
bodyTable = _assertThisInitialize.bodyTable; | ||
if (target.scrollLeft !== _this.lastScrollLeft) { | ||
if (target === bodyTable && headTable) { | ||
headTable.scrollLeft = target.scrollLeft; | ||
} | ||
if (target.scrollLeft !== _this.lastScrollLeft) { | ||
if (target === bodyTable && headTable) { | ||
headTable.scrollLeft = target.scrollLeft; | ||
} | ||
_this.setScrollPositionClassName(); | ||
} | ||
_this.setScrollPositionClassName(); | ||
} | ||
_this.lastScrollLeft = target.scrollLeft; | ||
_this.lastScrollLeft = target.scrollLeft; | ||
_this.sizeManager.update({ | ||
_scrollLeft: _this.lastScrollLeft | ||
}); | ||
}); | ||
_this.sizeManager.update({ | ||
_scrollLeft: _this.lastScrollLeft | ||
}); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "updateScrollLeft", function (scrollLeft) { | ||
var _assertThisInitialize2 = _assertThisInitialized(_assertThisInitialized(_this)), | ||
headTable = _assertThisInitialize2.headTable, | ||
bodyTable = _assertThisInitialize2.bodyTable; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'updateScrollLeft', | ||
function(scrollLeft) { | ||
var _assertThisInitialize2 = _assertThisInitialized( | ||
_assertThisInitialized(_this) | ||
), | ||
headTable = _assertThisInitialize2.headTable, | ||
bodyTable = _assertThisInitialize2.bodyTable; | ||
if (!bodyTable || bodyTable.scrollHeight === 0) { | ||
return; | ||
} | ||
if (!bodyTable || bodyTable.scrollHeight === 0) { | ||
return; | ||
} | ||
if (_this.lastScrollLeft !== scrollLeft) { | ||
if (headTable) { | ||
headTable.scrollLeft = scrollLeft; | ||
} | ||
if (_this.lastScrollLeft !== scrollLeft) { | ||
if (headTable) { | ||
headTable.scrollLeft = scrollLeft; | ||
} | ||
if (bodyTable) { | ||
bodyTable.scrollLeft = scrollLeft; | ||
} | ||
if (bodyTable) { | ||
bodyTable.scrollLeft = scrollLeft; | ||
} | ||
_this.setScrollPositionClassName(); | ||
} | ||
_this.setScrollPositionClassName(); | ||
} | ||
_this.lastScrollLeft = scrollLeft; | ||
_this.lastScrollLeft = scrollLeft; | ||
_this.sizeManager.update({ | ||
_scrollLeft: _this.lastScrollLeft | ||
}); | ||
}); | ||
_this.sizeManager.update({ | ||
_scrollLeft: _this.lastScrollLeft | ||
}); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "updateScrollTop", function (target) { | ||
['bodyTable', 'fixedColumnsBodyLeft', 'fixedColumnsBodyRight'].forEach(function (node) { | ||
if (_this[node] && target !== _this[node]) { | ||
_this[node].scrollTop = target.scrollTop; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'updateScrollTop', | ||
function(target) { | ||
[ | ||
'bodyTable', | ||
'fixedColumnsBodyLeft', | ||
'fixedColumnsBodyRight' | ||
].forEach(function(node) { | ||
if (_this[node] && target !== _this[node]) { | ||
_this[node].scrollTop = target.scrollTop; | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "updateScrollTopEnable", function (nextProps) {}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'updateScrollTopEnable', | ||
function(nextProps) {} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleBodyScrollTop", function (e) { | ||
var target = e.target; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'handleBodyScrollTop', | ||
function(e) { | ||
var target = e.target; | ||
if (target !== e.currentTarget) { | ||
return; | ||
} | ||
if (target !== e.currentTarget) { | ||
return; | ||
} | ||
var _assertThisInitialize3 = _assertThisInitialized(_assertThisInitialized(_this)), | ||
headTable = _assertThisInitialize3.headTable; | ||
var _assertThisInitialize3 = _assertThisInitialized( | ||
_assertThisInitialized(_this) | ||
), | ||
headTable = _assertThisInitialize3.headTable; | ||
if (_this.lastScrollTop !== target.scrollTop && target !== headTable) { | ||
_this.updateScrollTop(target); | ||
if ( | ||
_this.lastScrollTop !== target.scrollTop && | ||
target !== headTable | ||
) { | ||
_this.updateScrollTop(target); | ||
_this.sizeManager.update({ | ||
_scrollTop: target.scrollTop | ||
}); | ||
_this.sizeManager.update({ | ||
_scrollTop: target.scrollTop | ||
}); | ||
_this.resetShowData(target); | ||
_this.resetShowData(target); | ||
if (_this.props.refreshEnable) { | ||
_this.scrollRefresh(target); | ||
if (_this.props.refreshEnable) { | ||
_this.scrollRefresh(target); | ||
} | ||
} | ||
_this.lastScrollTop = target.scrollTop; | ||
} | ||
} | ||
); | ||
_this.lastScrollTop = target.scrollTop; | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'scrollRefresh', | ||
function(target) { | ||
var _this$props = _this.props, | ||
scrollEndPosition = _this$props.scrollEndPosition, | ||
onScrollEnd = _this$props.onScrollEnd; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "scrollRefresh", function (target) { | ||
var _this$props = _this.props, | ||
scrollEndPosition = _this$props.scrollEndPosition, | ||
onScrollEnd = _this$props.onScrollEnd; | ||
if (target.scrollTop + target.clientHeight + scrollEndPosition > target.scrollHeight && _this.refreshAble) { | ||
if (typeof onScrollEnd === 'function') { | ||
onScrollEnd(); | ||
_this.refreshAble = false; | ||
if ( | ||
target.scrollTop + target.clientHeight + scrollEndPosition > | ||
target.scrollHeight && | ||
_this.refreshAble | ||
) { | ||
if (typeof onScrollEnd === 'function') { | ||
onScrollEnd(); | ||
_this.refreshAble = false; | ||
} | ||
} else { | ||
_this.refreshAble = true; | ||
} | ||
} | ||
} else { | ||
_this.refreshAble = true; | ||
} | ||
}); | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "skipIndex", function () { | ||
var dataSource = _this.dataManager.showData() || []; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'skipIndex', | ||
function() { | ||
var dataSource = _this.dataManager.showData() || []; | ||
if (_this.sizeManager._showStartIndex > 0 && dataSource.length > 0) { | ||
var state = {}; | ||
state.startIndex = _this.sizeManager._showStartIndex; | ||
state.stopIndex = state.startIndex + _this.showCount + 2; | ||
if (_this.sizeManager._showStartIndex > 0 && dataSource.length > 0) { | ||
var state = {}; | ||
state.startIndex = _this.sizeManager._showStartIndex; | ||
state.stopIndex = state.startIndex + _this.showCount + 2; | ||
if (state.stopIndex > dataSource.length - 1) { | ||
state.stopIndex = dataSource.length - 1; | ||
state.startIndex = state.stopIndex - _this.showCount - 2; | ||
} | ||
if (state.stopIndex > dataSource.length - 1) { | ||
state.stopIndex = dataSource.length - 1; | ||
state.startIndex = state.stopIndex - _this.showCount - 2; | ||
} | ||
_this.lastScrollTop = dataSource[state.startIndex][_types.DS._top]; | ||
_this.lastScrollTop = dataSource[state.startIndex][_types.DS._top]; | ||
_this.updateScrollTop({ | ||
scrollTop: dataSource[state.startIndex][_types.DS._top] | ||
}); | ||
_this.updateScrollTop({ | ||
scrollTop: dataSource[state.startIndex][_types.DS._top] | ||
}); | ||
_this.sizeManager.update({ | ||
_startIndex: state.startIndex, | ||
_stopIndex: state.stopIndex, | ||
_showStartIndex: 0 | ||
}); | ||
_this.sizeManager.update({ | ||
_startIndex: state.startIndex, | ||
_stopIndex: state.stopIndex, | ||
_showStartIndex: 0 | ||
}); | ||
for (var key in _this._forceTable) { | ||
if (_this._forceTable.hasOwnProperty(key) && _this._forceTable[key]) { | ||
_this._forceTable[key](state); | ||
for (var key in _this._forceTable) { | ||
if ( | ||
_this._forceTable.hasOwnProperty(key) && | ||
_this._forceTable[key] | ||
) { | ||
_this._forceTable[key](state); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "resetShowData", function () { | ||
var scrollTop = _this.sizeManager._scrollTop; | ||
var rowHeight = _this.props.rowHeight; | ||
var dataSource = _this.dataManager.showData() || []; | ||
var state = {}; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'resetShowData', | ||
function() { | ||
var scrollTop = _this.sizeManager._scrollTop; | ||
var rowHeight = _this.props.rowHeight; | ||
var dataSource = _this.dataManager.showData() || []; | ||
var state = {}; | ||
if (!_this.sizeManager._hasScrollY || !_this.sizeManager.useScrollY) { | ||
state.startIndex = 0; | ||
state.stopIndex = dataSource.length - 1; | ||
} else { | ||
var startIndex = (0, _floor.default)(scrollTop / rowHeight) - 1; | ||
if (!_this.sizeManager._hasScrollY || !_this.sizeManager.useScrollY) { | ||
state.startIndex = 0; | ||
state.stopIndex = dataSource.length - 1; | ||
} else { | ||
var startIndex = (0, _floor.default)(scrollTop / rowHeight) - 1; | ||
for (var i = 0; i < dataSource.length; i++) { | ||
if (scrollTop < dataSource[i][_types.DS._top]) { | ||
startIndex = i - 1; | ||
break; | ||
for (var i = 0; i < dataSource.length; i++) { | ||
if (scrollTop < dataSource[i][_types.DS._top]) { | ||
startIndex = i - 1; | ||
break; | ||
} | ||
} | ||
state.startIndex = Math.max(0, startIndex - 2); | ||
state.stopIndex = Math.min( | ||
startIndex + _this.showCount + 2, | ||
dataSource.length - 1 | ||
); | ||
} | ||
} | ||
state.startIndex = Math.max(0, startIndex - 2); | ||
state.stopIndex = Math.min(startIndex + _this.showCount + 2, dataSource.length - 1); | ||
} | ||
_this.sizeManager.update({ | ||
_startIndex: state.startIndex, | ||
_stopIndex: state.stopIndex | ||
}); | ||
_this.sizeManager.update({ | ||
_startIndex: state.startIndex, | ||
_stopIndex: state.stopIndex | ||
}); | ||
for (var key in _this._forceTable) { | ||
if (_this._forceTable.hasOwnProperty(key) && _this._forceTable[key]) { | ||
_this._forceTable[key](state); | ||
for (var key in _this._forceTable) { | ||
if ( | ||
_this._forceTable.hasOwnProperty(key) && | ||
_this._forceTable[key] | ||
) { | ||
_this._forceTable[key](state); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleExpandChange", function (key) { | ||
var onExpandedRowsChange = _this.props.onExpandedRowsChange; | ||
var dataManager = _this.dataManager; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'handleExpandChange', | ||
function(key) { | ||
var onExpandedRowsChange = _this.props.onExpandedRowsChange; | ||
var dataManager = _this.dataManager; | ||
_this.cacheManager.reset(); | ||
_this.cacheManager.reset(); | ||
var result = dataManager.expanded(key); | ||
var result = dataManager.expanded(key); | ||
if (typeof onExpandedRowsChange === 'function') { | ||
onExpandedRowsChange(result); | ||
} | ||
if (typeof onExpandedRowsChange === 'function') { | ||
onExpandedRowsChange(result); | ||
} | ||
_this.getShowCount(); | ||
_this.getShowCount(); | ||
_this.sizeManager.update({ | ||
_dataHeight: _this.dataManager._bodyHeight | ||
}); | ||
_this.sizeManager.update({ | ||
_dataHeight: _this.dataManager._bodyHeight | ||
}); | ||
_this.resetShowData(); | ||
_this.resetShowData(); | ||
_this.forceUpdate(); | ||
}); | ||
_this.forceUpdate(); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "saveRef", function (name) { | ||
return function (node) { | ||
_this[name] = node; | ||
}; | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'saveRef', | ||
function(name) { | ||
return function(node) { | ||
_this[name] = node; | ||
}; | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "registerForce", function (name, fn) { | ||
_this._forceTable[name || 'body'] = fn; | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'registerForce', | ||
function(name, fn) { | ||
_this._forceTable[name || 'body'] = fn; | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getClassName", function () { | ||
var _classNames; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'getClassName', | ||
function() { | ||
var _classNames; | ||
var _this$props2 = _this.props, | ||
prefixCls = _this$props2.prefixCls, | ||
className = _this$props2.className, | ||
fixedHeader = _this$props2.fixedHeader, | ||
bordered = _this$props2.bordered; | ||
var flag = false; | ||
var _this$props2 = _this.props, | ||
prefixCls = _this$props2.prefixCls, | ||
className = _this$props2.className, | ||
fixedHeader = _this$props2.fixedHeader, | ||
bordered = _this$props2.bordered; | ||
var flag = false; | ||
if (_this.sizeManager._hasScrollX) { | ||
flag = !(_this['bodyTable'] && _this['bodyTable'].scrollLeft !== 0); | ||
} | ||
if (_this.sizeManager._hasScrollX) { | ||
flag = !(_this['bodyTable'] && _this['bodyTable'].scrollLeft !== 0); | ||
} | ||
return (0, _classnames.default)(prefixCls, className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-fixed-header"), fixedHeader), _defineProperty(_classNames, "bordered", bordered), _defineProperty(_classNames, "".concat(prefixCls, "-expanded"), _this.dataManager.isExpanded()), _defineProperty(_classNames, "".concat(prefixCls, "-scroll-position-left"), flag), _classNames)); | ||
}); | ||
return (0, _classnames.default)( | ||
prefixCls, | ||
className, | ||
((_classNames = {}), | ||
_defineProperty( | ||
_classNames, | ||
''.concat(prefixCls, '-fixed-header'), | ||
fixedHeader | ||
), | ||
_defineProperty(_classNames, 'bordered', bordered), | ||
_defineProperty( | ||
_classNames, | ||
''.concat(prefixCls, '-expanded'), | ||
_this.dataManager.isExpanded() | ||
), | ||
_defineProperty( | ||
_classNames, | ||
''.concat(prefixCls, '-scroll-position-left'), | ||
flag | ||
), | ||
_classNames) | ||
); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderTable", function (options) { | ||
var fixed = options.fixed; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'renderTable', | ||
function(options) { | ||
var fixed = options.fixed; | ||
var headTable = _react.default.createElement(_HeadTable.default, { | ||
key: "head", | ||
fixed: fixed, | ||
saveRef: _this.saveRef, | ||
registerForce: _this.registerForce | ||
}); | ||
var headTable = _react.default.createElement(_HeadTable.default, { | ||
key: 'head', | ||
fixed: fixed, | ||
saveRef: _this.saveRef, | ||
registerForce: _this.registerForce | ||
}); | ||
var bodyTable = _react.default.createElement(_BodyTable.default, { | ||
key: "body", | ||
fixed: fixed, | ||
saveRef: _this.saveRef, | ||
handleBodyScroll: _this.handleBodyScroll, | ||
registerForce: _this.registerForce | ||
}); | ||
var bodyTable = _react.default.createElement(_BodyTable.default, { | ||
key: 'body', | ||
fixed: fixed, | ||
saveRef: _this.saveRef, | ||
handleBodyScroll: _this.handleBodyScroll, | ||
registerForce: _this.registerForce | ||
}); | ||
return [headTable, bodyTable]; | ||
}); | ||
return [headTable, bodyTable]; | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "fixedClassName", function (fixed) { | ||
return "".concat(_this.props.prefixCls, "-fixed-").concat(fixed); | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'fixedClassName', | ||
function(fixed) { | ||
return ''.concat(_this.props.prefixCls, '-fixed-').concat(fixed); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderMainTable", function () { | ||
var table = _this.renderTable({}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'renderMainTable', | ||
function() { | ||
var table = _this.renderTable({}); | ||
return [table, _this.renderEmptyText()]; | ||
}); | ||
return [table, _this.renderEmptyText()]; | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderLeftFixedTable", function () { | ||
var table = _this.renderTable({ | ||
fixed: 'left' | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'renderLeftFixedTable', | ||
function() { | ||
var table = _this.renderTable({ | ||
fixed: 'left' | ||
}); | ||
return _react.default.createElement("div", { | ||
className: _this.fixedClassName('left') | ||
}, table); | ||
}); | ||
return _react.default.createElement( | ||
'div', | ||
{ | ||
className: _this.fixedClassName('left') | ||
}, | ||
table | ||
); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderRightFixedTable", function () { | ||
var table = _this.renderTable({ | ||
fixed: 'right' | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'renderRightFixedTable', | ||
function() { | ||
var table = _this.renderTable({ | ||
fixed: 'right' | ||
}); | ||
return _react.default.createElement("div", { | ||
className: _this.fixedClassName('right') | ||
}, table); | ||
}); | ||
return _react.default.createElement( | ||
'div', | ||
{ | ||
className: _this.fixedClassName('right') | ||
}, | ||
table | ||
); | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderFooter", function () { | ||
var _this$props3 = _this.props, | ||
footer = _this$props3.footer, | ||
footerHeight = _this$props3.footerHeight, | ||
prefixCls = _this$props3.prefixCls; | ||
return footer ? _react.default.createElement("div", { | ||
key: "table-footer", | ||
className: "".concat(prefixCls, "-footer"), | ||
style: { | ||
flex: "0 1 ".concat(footerHeight, "px"), | ||
height: footerHeight, | ||
color: 'inherit' | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'renderFooter', | ||
function() { | ||
var _this$props3 = _this.props, | ||
footer = _this$props3.footer, | ||
footerHeight = _this$props3.footerHeight, | ||
prefixCls = _this$props3.prefixCls; | ||
return footer | ||
? _react.default.createElement( | ||
'div', | ||
{ | ||
key: 'table-footer', | ||
className: ''.concat(prefixCls, '-footer'), | ||
style: { | ||
flex: '0 1 '.concat(footerHeight, 'px'), | ||
height: footerHeight, | ||
color: 'inherit' | ||
} | ||
}, | ||
footer(_this.props.dataSource) | ||
) | ||
: null; | ||
} | ||
}, footer(_this.props.dataSource)) : null; | ||
}); | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderEmptyText", function () { | ||
var _this$props4 = _this.props, | ||
emptyText = _this$props4.emptyText, | ||
dataSource = _this$props4.dataSource, | ||
rowHeight = _this$props4.rowHeight, | ||
prefixCls = _this$props4.prefixCls, | ||
fixedHeader = _this$props4.fixedHeader, | ||
showHeader = _this$props4.showHeader; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'renderEmptyText', | ||
function() { | ||
var _this$props4 = _this.props, | ||
emptyText = _this$props4.emptyText, | ||
dataSource = _this$props4.dataSource, | ||
rowHeight = _this$props4.rowHeight, | ||
prefixCls = _this$props4.prefixCls, | ||
fixedHeader = _this$props4.fixedHeader, | ||
showHeader = _this$props4.showHeader; | ||
if (dataSource && dataSource.length > 0) { | ||
return null; | ||
} | ||
if (dataSource && dataSource.length > 0) { | ||
return null; | ||
} | ||
var style = { | ||
height: rowHeight, | ||
lineHeight: rowHeight + 'px', | ||
flex: "0 1 ".concat(rowHeight, "px"), | ||
textAlign: 'center' | ||
}; | ||
var style = { | ||
height: rowHeight, | ||
lineHeight: rowHeight + 'px', | ||
flex: '0 1 '.concat(rowHeight, 'px'), | ||
textAlign: 'center' | ||
}; | ||
var scrollSizeX = _this.sizeManager.scrollSizeX(); | ||
var scrollSizeX = _this.sizeManager.scrollSizeX(); | ||
if (scrollSizeX > 0 && fixedHeader && showHeader) { | ||
style.marginTop = "".concat(scrollSizeX, "px"); | ||
} | ||
if (scrollSizeX > 0 && fixedHeader && showHeader) { | ||
style.marginTop = ''.concat(scrollSizeX, 'px'); | ||
} | ||
return typeof emptyText === 'function' ? _react.default.createElement("div", { | ||
key: "table-empty-text", | ||
className: "".concat(prefixCls, "-empty-text"), | ||
style: style | ||
}, emptyText()) : emptyText; | ||
}); | ||
return typeof emptyText === 'function' | ||
? _react.default.createElement( | ||
'div', | ||
{ | ||
key: 'table-empty-text', | ||
className: ''.concat(prefixCls, '-empty-text'), | ||
style: style | ||
}, | ||
emptyText() | ||
) | ||
: emptyText; | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderChild", function (params) { | ||
if (!_this._renderEnable) { | ||
return null; | ||
} | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'renderChild', | ||
function(params) { | ||
if (!_this._renderEnable) { | ||
return null; | ||
} | ||
_this.onResize(params); | ||
_this.onResize(params); | ||
var _this$props5 = _this.props, | ||
prefixCls = _this$props5.prefixCls, | ||
useScrollY = _this$props5.useScrollY; | ||
var _this$props5 = _this.props, | ||
prefixCls = _this$props5.prefixCls, | ||
useScrollY = _this$props5.useScrollY; | ||
var hasLeftFixed = _this.columnManager.isAnyColumnsLeftFixed(); | ||
var hasLeftFixed = _this.columnManager.isAnyColumnsLeftFixed(); | ||
var hasRightFixed = _this.columnManager.isAnyColumnsRightFixed(); | ||
var hasRightFixed = _this.columnManager.isAnyColumnsRightFixed(); | ||
var style = _objectSpread({}, _this.props.style); | ||
var style = _objectSpread({}, _this.props.style); | ||
style.width = _this.sizeManager._wrapperWidth; | ||
style.width = _this.sizeManager._wrapperWidth; | ||
if (useScrollY) { | ||
style.height = _this.sizeManager._wrapperHeight; | ||
} | ||
if (useScrollY) { | ||
style.height = _this.sizeManager._wrapperHeight; | ||
} | ||
return _react.default.createElement("div", { | ||
className: _this.getClassName(), | ||
ref: _this.saveRef('tableNode'), | ||
style: style | ||
}, _react.default.createElement("div", { | ||
className: "".concat(prefixCls, "-content") | ||
}, _this.renderMainTable(), hasLeftFixed && _this.renderLeftFixedTable(), hasRightFixed && _this.renderRightFixedTable()), _this.renderFooter()); | ||
}); | ||
return _react.default.createElement( | ||
'div', | ||
{ | ||
className: _this.getClassName(), | ||
ref: _this.saveRef('tableNode'), | ||
style: style | ||
}, | ||
_react.default.createElement( | ||
'div', | ||
{ | ||
className: ''.concat(prefixCls, '-content') | ||
}, | ||
_this.renderMainTable(), | ||
hasLeftFixed && _this.renderLeftFixedTable(), | ||
hasRightFixed && _this.renderRightFixedTable() | ||
), | ||
_this.renderFooter() | ||
); | ||
} | ||
); | ||
_this.lastScrollTop = 0; | ||
_this.lastScrollLeft = 0; | ||
_this.refreshAble = true; | ||
_this.showCount = props.defaultShowCount || 20; | ||
_this.columnManager = new _ColumnManager.default(props); | ||
_this.dataManager = new _DataManager.default({ | ||
getProps: _this.getProps | ||
}); | ||
_this.sortManager = new _SortManager.default({ | ||
columns: _this.columnManager.groupedColumns(), | ||
sortMulti: props.sortMulti | ||
}); | ||
_this.sizeManager = new _SizeManager.default(props); | ||
_this.cacheManager = new _CacheManager.default(); | ||
_this.lastScrollTop = 0; | ||
_this.lastScrollLeft = 0; | ||
_this.refreshAble = true; | ||
_this.showCount = props.defaultShowCount || 20; | ||
_this.columnManager = new _ColumnManager.default(props); | ||
_this.dataManager = new _DataManager.default({ | ||
getProps: _this.getProps | ||
}); | ||
_this.sortManager = new _SortManager.default({ | ||
columns: _this.columnManager.groupedColumns(), | ||
sortMulti: props.sortMulti | ||
}); | ||
_this.sizeManager = new _SizeManager.default(props); | ||
_this.cacheManager = new _CacheManager.default(); | ||
_this.sizeManager.update(_objectSpread({ | ||
_dataHeight: _this.dataManager._bodyHeight, | ||
_dataEmpty: _this.dataManager.isEmpty(), | ||
_scrollSizeX: props.scrollSize.x, | ||
_scrollSizeY: props.scrollSize.y | ||
}, _this.columnManager.headerSize())); | ||
_this.sizeManager.update( | ||
_objectSpread( | ||
{ | ||
_dataHeight: _this.dataManager._bodyHeight, | ||
_dataEmpty: _this.dataManager.isEmpty(), | ||
_scrollSizeX: props.scrollSize.x, | ||
_scrollSizeY: props.scrollSize.y | ||
}, | ||
_this.columnManager.headerSize() | ||
) | ||
); | ||
_this.selectManager = new _SelectManager.default({ | ||
getProps: _this.getProps, | ||
update: _this.updateAll | ||
}); | ||
_this.store = (0, _miniStore.create)({ | ||
currentHoverKey: null, | ||
orders: _this.sortManager.enabled() | ||
}); | ||
return _this; | ||
} | ||
_createClass(Table, [{ | ||
key: "getChildContext", | ||
value: function getChildContext() { | ||
return { | ||
props: this.props, | ||
manager: { | ||
columnManager: this.columnManager, | ||
dataManager: this.dataManager, | ||
sortManager: this.sortManager, | ||
sizeManager: this.sizeManager, | ||
cacheManager: this.cacheManager, | ||
selectManager: this.selectManager | ||
}, | ||
expandChange: this.handleExpandChange, | ||
updateScrollLeft: this.updateScrollLeft, | ||
update: this.updateAll, | ||
getProps: this.getProps | ||
}; | ||
_this.selectManager = new _SelectManager.default({ | ||
getProps: _this.getProps, | ||
update: _this.updateAll | ||
}); | ||
_this.store = (0, _miniStore.create)({ | ||
currentHoverKey: null, | ||
orders: _this.sortManager.enabled() | ||
}); | ||
return _this; | ||
} | ||
}, { | ||
key: "componentWillReceiveProps", | ||
value: function componentWillReceiveProps(nextProps) { | ||
if (!(0, _shallowequal.default)(nextProps.showStartIndex, this.props.showStartIndex)) { | ||
this.sizeManager.update({ | ||
_showStartIndex: nextProps.showStartIndex | ||
}); | ||
} | ||
if (!(0, _shallowequal.default)(nextProps.rowSelection, this.props.rowSelection)) { | ||
this.selectManager.updateSelection(nextProps.rowSelection); | ||
} | ||
_createClass(Table, [ | ||
{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return { | ||
props: this.props, | ||
manager: { | ||
columnManager: this.columnManager, | ||
dataManager: this.dataManager, | ||
sortManager: this.sortManager, | ||
sizeManager: this.sizeManager, | ||
cacheManager: this.cacheManager, | ||
selectManager: this.selectManager | ||
}, | ||
expandChange: this.handleExpandChange, | ||
updateScrollLeft: this.updateScrollLeft, | ||
update: this.updateAll, | ||
getProps: this.getProps | ||
}; | ||
} | ||
}, | ||
{ | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
if ( | ||
!(0, _shallowequal.default)( | ||
nextProps.showStartIndex, | ||
this.props.showStartIndex | ||
) | ||
) { | ||
this.sizeManager.update({ | ||
_showStartIndex: nextProps.showStartIndex | ||
}); | ||
} | ||
if (!(0, _shallowequal.default)(nextProps.dataSource, this.props.dataSource)) { | ||
this.dataManager.reset(nextProps.dataSource); | ||
var dh = this.sizeManager._dataHeight; | ||
this.selectManager.count = this.selectManager.getKeys(this.dataManager.getData()).length; | ||
this.sizeManager.update({ | ||
_dataHeight: this.dataManager._bodyHeight, | ||
_dataEmpty: this.dataManager.isEmpty() | ||
}); | ||
if ( | ||
!(0, _shallowequal.default)( | ||
nextProps.rowSelection, | ||
this.props.rowSelection | ||
) | ||
) { | ||
this.selectManager.updateSelection(nextProps.rowSelection); | ||
} | ||
if (dh !== 0 && this.sizeManager._dataHeight === 0) { | ||
this.sizeManager.update({ | ||
_scrollTop: 0 | ||
}); | ||
this.updateScrollTop({ | ||
scrollTop: 0 | ||
}); | ||
} | ||
if ( | ||
!(0, _shallowequal.default)( | ||
nextProps.dataSource, | ||
this.props.dataSource | ||
) | ||
) { | ||
this.dataManager.reset(nextProps.dataSource); | ||
var dh = this.sizeManager._dataHeight; | ||
this.selectManager.count = this.selectManager.getKeys( | ||
this.dataManager.getData() | ||
).length; | ||
this.sizeManager.update({ | ||
_dataHeight: this.dataManager._bodyHeight, | ||
_dataEmpty: this.dataManager.isEmpty() | ||
}); | ||
if (nextProps.pullDown && dh < this.sizeManager._dataHeight && this.sizeManager._hasScrollY && this.sizeManager._scrollTop < 5) { | ||
var top = this.sizeManager._dataHeight - dh; | ||
this.sizeManager.update({ | ||
_scrollTop: this.sizeManager._scrollTop + top | ||
}); | ||
this.updateScrollTop({ | ||
scrollTop: this.sizeManager._scrollTop | ||
}); | ||
} | ||
if (dh !== 0 && this.sizeManager._dataHeight === 0) { | ||
this.sizeManager.update({ | ||
_scrollTop: 0 | ||
}); | ||
this.updateScrollTop({ | ||
scrollTop: 0 | ||
}); | ||
} | ||
this.cacheManager.reset(); | ||
this.getShowCount(); | ||
this.resetShowData(); | ||
} | ||
if ( | ||
nextProps.pullDown && | ||
dh < this.sizeManager._dataHeight && | ||
this.sizeManager._hasScrollY && | ||
this.sizeManager._scrollTop < 5 | ||
) { | ||
var top = this.sizeManager._dataHeight - dh; | ||
this.sizeManager.update({ | ||
_scrollTop: this.sizeManager._scrollTop + top | ||
}); | ||
this.updateScrollTop({ | ||
scrollTop: this.sizeManager._scrollTop | ||
}); | ||
} | ||
if (!(0, _shallowequal.default)(nextProps.columns, this.props.columns)) { | ||
this.sizeManager.update(this.columnManager.reset(nextProps)); | ||
this.sortManager.update({ | ||
columns: this.columnManager.groupedColumns(), | ||
sortMulti: nextProps.sortMulti | ||
}); | ||
this.store.setState({ | ||
orders: this.sortManager.enable | ||
}); | ||
this.cacheManager.reset(); | ||
this.updateColumn(); | ||
} | ||
this.cacheManager.reset(); | ||
this.getShowCount(); | ||
this.resetShowData(); | ||
} | ||
if (!(0, _shallowequal.default)(nextProps.expandedRowKeys, this.props.expandedRowKeys)) { | ||
this.dataManager.resetExpandedRowKeys(nextProps.expandedRowKeys); | ||
this.sizeManager.update({ | ||
_dataHeight: this.dataManager._bodyHeight, | ||
_dataEmpty: this.dataManager.isEmpty() | ||
}); | ||
this.cacheManager.reset(); | ||
this.getShowCount(); | ||
this.resetShowData(); | ||
} | ||
} | ||
}, { | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate() { | ||
this.setScrollPositionClassName(); | ||
this.skipIndex(); | ||
} | ||
}, { | ||
key: "setScrollPosition", | ||
value: function setScrollPosition(position) { | ||
this.scrollPosition = position; | ||
var tableNode = this.tableNode; | ||
if ( | ||
!(0, _shallowequal.default)(nextProps.columns, this.props.columns) | ||
) { | ||
this.sizeManager.update(this.columnManager.reset(nextProps)); | ||
this.sortManager.update({ | ||
columns: this.columnManager.groupedColumns(), | ||
sortMulti: nextProps.sortMulti | ||
}); | ||
this.store.setState({ | ||
orders: this.sortManager.enable | ||
}); | ||
this.cacheManager.reset(); | ||
this.updateColumn(); | ||
} | ||
if (tableNode) { | ||
var prefixCls = this.props.prefixCls; | ||
if ( | ||
!(0, _shallowequal.default)( | ||
nextProps.expandedRowKeys, | ||
this.props.expandedRowKeys | ||
) | ||
) { | ||
this.dataManager.resetExpandedRowKeys(nextProps.expandedRowKeys); | ||
this.sizeManager.update({ | ||
_dataHeight: this.dataManager._bodyHeight, | ||
_dataEmpty: this.dataManager.isEmpty() | ||
}); | ||
this.cacheManager.reset(); | ||
this.getShowCount(); | ||
this.resetShowData(); | ||
} | ||
} | ||
}, | ||
{ | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
this.setScrollPositionClassName(); | ||
this.skipIndex(); | ||
} | ||
}, | ||
{ | ||
key: 'setScrollPosition', | ||
value: function setScrollPosition(position) { | ||
this.scrollPosition = position; | ||
var tableNode = this.tableNode; | ||
if (position === 'clear') { | ||
(0, _componentClasses.default)(tableNode).remove(new RegExp("^".concat(prefixCls, "-scroll-position-.+$"))); | ||
} else if (position === 'both') { | ||
(0, _componentClasses.default)(tableNode).remove(new RegExp("^".concat(prefixCls, "-scroll-position-.+$"))).add("".concat(prefixCls, "-scroll-position-left")).add("".concat(prefixCls, "-scroll-position-right")); | ||
} else { | ||
(0, _componentClasses.default)(tableNode).remove(new RegExp("^".concat(prefixCls, "-scroll-position-.+$"))).add("".concat(prefixCls, "-scroll-position-").concat(position)); | ||
if (tableNode) { | ||
var prefixCls = this.props.prefixCls; | ||
if (position === 'clear') { | ||
(0, _componentClasses.default)(tableNode).remove( | ||
new RegExp('^'.concat(prefixCls, '-scroll-position-.+$')) | ||
); | ||
} else if (position === 'both') { | ||
(0, _componentClasses.default)(tableNode) | ||
.remove( | ||
new RegExp('^'.concat(prefixCls, '-scroll-position-.+$')) | ||
) | ||
.add(''.concat(prefixCls, '-scroll-position-left')) | ||
.add(''.concat(prefixCls, '-scroll-position-right')); | ||
} else { | ||
(0, _componentClasses.default)(tableNode) | ||
.remove( | ||
new RegExp('^'.concat(prefixCls, '-scroll-position-.+$')) | ||
) | ||
.add( | ||
''.concat(prefixCls, '-scroll-position-').concat(position) | ||
); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, { | ||
key: "setScrollPositionClassName", | ||
value: function setScrollPositionClassName() { | ||
var node = this['bodyTable']; | ||
var scrollToLeft = node.scrollLeft === 0; | ||
var scrollToRight = node.scrollLeft + 1 >= node.children[0].getBoundingClientRect().width - node.getBoundingClientRect().width; | ||
}, | ||
{ | ||
key: 'setScrollPositionClassName', | ||
value: function setScrollPositionClassName() { | ||
var node = this['bodyTable']; | ||
var scrollToLeft = node.scrollLeft === 0; | ||
var scrollToRight = | ||
node.scrollLeft + 1 >= | ||
node.children[0].getBoundingClientRect().width - | ||
node.getBoundingClientRect().width; | ||
if (!this.sizeManager._hasScrollX) { | ||
this.setScrollPosition('clear'); | ||
} else if (scrollToLeft && scrollToRight) { | ||
this.setScrollPosition('both'); | ||
} else if (scrollToLeft) { | ||
this.setScrollPosition('left'); | ||
} else if (scrollToRight) { | ||
this.setScrollPosition('right'); | ||
} else if (this.scrollPosition !== 'middle') { | ||
this.setScrollPosition('middle'); | ||
} | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _this$props6 = this.props, | ||
prefixCls = _this$props6.prefixCls, | ||
useScrollY = _this$props6.useScrollY; | ||
if (!this.sizeManager._hasScrollX) { | ||
this.setScrollPosition('clear'); | ||
} else if (scrollToLeft && scrollToRight) { | ||
this.setScrollPosition('both'); | ||
} else if (scrollToLeft) { | ||
this.setScrollPosition('left'); | ||
} else if (scrollToRight) { | ||
this.setScrollPosition('right'); | ||
} else if (this.scrollPosition !== 'middle') { | ||
this.setScrollPosition('middle'); | ||
} | ||
} | ||
}, | ||
{ | ||
key: 'render', | ||
value: function render() { | ||
var _this$props6 = this.props, | ||
prefixCls = _this$props6.prefixCls, | ||
useScrollY = _this$props6.useScrollY; | ||
var autoSizeProps = _objectSpread({}, this.props, { | ||
onResize: this.onResize, | ||
className: "".concat(prefixCls, "-auto-size"), | ||
disableHeight: !useScrollY | ||
}); | ||
var autoSizeProps = _objectSpread({}, this.props, { | ||
onResize: this.onResize, | ||
className: ''.concat(prefixCls, '-auto-size'), | ||
disableHeight: !useScrollY | ||
}); | ||
return _react.default.createElement(_miniStore.Provider, { | ||
store: this.store | ||
}, _react.default.createElement(_AutoSizer.default, autoSizeProps, this.renderChild)); | ||
} | ||
}]); | ||
return _react.default.createElement( | ||
_miniStore.Provider, | ||
{ | ||
store: this.store | ||
}, | ||
_react.default.createElement( | ||
_AutoSizer.default, | ||
autoSizeProps, | ||
this.renderChild | ||
) | ||
); | ||
} | ||
} | ||
]); | ||
return Table; | ||
}(_react.default.PureComponent); | ||
return Table; | ||
})(_react.default.PureComponent); | ||
exports.default = Table; | ||
_defineProperty(Table, "defaultProps", _types.TableDefaultParams); | ||
_defineProperty(Table, 'defaultProps', _types.TableDefaultParams); | ||
_defineProperty(Table, "childContextTypes", { | ||
_defineProperty(Table, 'childContextTypes', { | ||
props: _propTypes.default.object, | ||
@@ -724,2 +1091,2 @@ manager: _propTypes.default.object, | ||
getProps: _propTypes.default.func | ||
}); | ||
}); |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,9 +8,27 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a function'); | ||
} | ||
} | ||
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 _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; | ||
} | ||
@@ -22,27 +40,27 @@ var CacheManager = function CacheManager() { | ||
_defineProperty(this, "_rowCache", {}); | ||
_defineProperty(this, '_rowCache', {}); | ||
_defineProperty(this, "_cellCache", {}); | ||
_defineProperty(this, '_cellCache', {}); | ||
_defineProperty(this, "_styleCache", {}); | ||
_defineProperty(this, '_styleCache', {}); | ||
_defineProperty(this, "_rowStyleCache", {}); | ||
_defineProperty(this, '_rowStyleCache', {}); | ||
_defineProperty(this, "setRow", function (key, element) { | ||
_defineProperty(this, 'setRow', function(key, element) { | ||
_this._rowCache[key] = element; | ||
}); | ||
_defineProperty(this, "getRow", function (key) { | ||
_defineProperty(this, 'getRow', function(key) { | ||
return _this._rowCache[key]; | ||
}); | ||
_defineProperty(this, "setCell", function (key, element) { | ||
_defineProperty(this, 'setCell', function(key, element) { | ||
_this._cellCache[key] = element; | ||
}); | ||
_defineProperty(this, "getCell", function (key) { | ||
_defineProperty(this, 'getCell', function(key) { | ||
return _this._cellCache[key]; | ||
}); | ||
_defineProperty(this, "reset", function () { | ||
_defineProperty(this, 'reset', function() { | ||
_this._cellCache = {}; | ||
@@ -52,15 +70,15 @@ _this._rowStyleCache = {}; | ||
_defineProperty(this, "setStyle", function (key, style) { | ||
_defineProperty(this, 'setStyle', function(key, style) { | ||
_this._styleCache[key] = style; | ||
}); | ||
_defineProperty(this, "getStyle", function (key) { | ||
_defineProperty(this, 'getStyle', function(key) { | ||
return _this._styleCache[key]; | ||
}); | ||
_defineProperty(this, "getRowStyle", function (key) { | ||
_defineProperty(this, 'getRowStyle', function(key) { | ||
return _this._rowStyleCache[key]; | ||
}); | ||
_defineProperty(this, "setRowStyle", function (key, style) { | ||
_defineProperty(this, 'setRowStyle', function(key, style) { | ||
_this._rowStyleCache[key] = style; | ||
@@ -71,2 +89,2 @@ }); | ||
var _default = CacheManager; | ||
exports.default = _default; | ||
exports.default = _default; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,50 +8,119 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _max = _interopRequireDefault(require("lodash/max")); | ||
var _max = _interopRequireDefault(require('lodash/max')); | ||
var _multiply = _interopRequireDefault(require("lodash/multiply")); | ||
var _multiply = _interopRequireDefault(require('lodash/multiply')); | ||
var _isNumber = _interopRequireDefault(require("lodash/isNumber")); | ||
var _isNumber = _interopRequireDefault(require('lodash/isNumber')); | ||
var _toNumber = _interopRequireDefault(require("lodash/toNumber")); | ||
var _toNumber = _interopRequireDefault(require('lodash/toNumber')); | ||
var _divide = _interopRequireDefault(require("lodash/divide")); | ||
var _divide = _interopRequireDefault(require('lodash/divide')); | ||
var _floor = _interopRequireDefault(require("lodash/floor")); | ||
var _floor = _interopRequireDefault(require('lodash/floor')); | ||
var _sumBy = _interopRequireDefault(require("lodash/sumBy")); | ||
var _sumBy = _interopRequireDefault(require('lodash/sumBy')); | ||
var _isNaN = _interopRequireDefault(require("lodash/isNaN")); | ||
var _isNaN = _interopRequireDefault(require('lodash/isNaN')); | ||
var _min = _interopRequireDefault(require("lodash/min")); | ||
var _min = _interopRequireDefault(require('lodash/min')); | ||
var _types = require("../types"); | ||
var _types = require('../types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat( | ||
Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
}) | ||
); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _toConsumableArray(arr) { | ||
return ( | ||
_arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread() | ||
); | ||
} | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _nonIterableSpread() { | ||
throw new TypeError('Invalid attempt to spread non-iterable instance'); | ||
} | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _iterableToArray(iter) { | ||
if ( | ||
Symbol.iterator in Object(iter) || | ||
Object.prototype.toString.call(iter) === '[object Arguments]' | ||
) | ||
return Array.from(iter); | ||
} | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { | ||
arr2[i] = arr[i]; | ||
} | ||
return arr2; | ||
} | ||
} | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { | ||
if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') { | ||
_typeof = function _typeof(obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && | ||
typeof Symbol === 'function' && | ||
obj.constructor === Symbol && | ||
obj !== Symbol.prototype | ||
? 'symbol' | ||
: typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a function'); | ||
} | ||
} | ||
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 _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; | ||
} | ||
var _path = _types.CS._path, | ||
_pathKey = _types.CS._pathKey, | ||
_currentRow = _types.CS._currentRow, | ||
_width = _types.CS._width, | ||
_minWidth = _types.CS._minWidth, | ||
path = _types.CS.path, | ||
rowSpan = _types.CS.rowSpan, | ||
colSpan = _types.CS.colSpan; | ||
_pathKey = _types.CS._pathKey, | ||
_currentRow = _types.CS._currentRow, | ||
_width = _types.CS._width, | ||
_minWidth = _types.CS._minWidth, | ||
path = _types.CS.path, | ||
rowSpan = _types.CS.rowSpan, | ||
colSpan = _types.CS.colSpan; | ||
var percentReg = /^\d+\.?\d{0,2}%$/; | ||
@@ -63,12 +132,12 @@ | ||
var _columns = _ref.columns, | ||
_minWidth2 = _ref.minWidth, | ||
_headerRowHeight = _ref.headerRowHeight; | ||
_minWidth2 = _ref.minWidth, | ||
_headerRowHeight = _ref.headerRowHeight; | ||
_classCallCheck(this, ColumnManager); | ||
_defineProperty(this, "_cached", {}); | ||
_defineProperty(this, '_cached', {}); | ||
_defineProperty(this, "_maxRowSpan", 1); | ||
_defineProperty(this, '_maxRowSpan', 1); | ||
_defineProperty(this, "init", function () { | ||
_defineProperty(this, 'init', function() { | ||
_this.width = 0; | ||
@@ -80,5 +149,5 @@ _this.leftWidth = 0; | ||
_defineProperty(this, "isAnyColumnsLeftFixed", function () { | ||
return _this._cache('isAnyColumnsLeftFixed', function () { | ||
return _this.groupedColumns().some(function (column) { | ||
_defineProperty(this, 'isAnyColumnsLeftFixed', function() { | ||
return _this._cache('isAnyColumnsLeftFixed', function() { | ||
return _this.groupedColumns().some(function(column) { | ||
return column.fixed === 'left' || column.fixed === true; | ||
@@ -89,5 +158,5 @@ }); | ||
_defineProperty(this, "isAnyColumnsRightFixed", function () { | ||
return _this._cache('isAnyColumnsRightFixed', function () { | ||
return _this.groupedColumns().some(function (column) { | ||
_defineProperty(this, 'isAnyColumnsRightFixed', function() { | ||
return _this._cache('isAnyColumnsRightFixed', function() { | ||
return _this.groupedColumns().some(function(column) { | ||
return column.fixed === 'right'; | ||
@@ -98,3 +167,3 @@ }); | ||
_defineProperty(this, "headColumns", function (fixed) { | ||
_defineProperty(this, 'headColumns', function(fixed) { | ||
if (fixed === 'left') { | ||
@@ -109,3 +178,3 @@ return _this.leftColumns(); | ||
_defineProperty(this, "bodyColumns", function (fixed) { | ||
_defineProperty(this, 'bodyColumns', function(fixed) { | ||
if (fixed === 'left') { | ||
@@ -120,5 +189,5 @@ return _this.leftLeafColumns(); | ||
_defineProperty(this, "leftColumns", function () { | ||
return _this._cache('leftColumns', function () { | ||
return _this.groupedColumns().filter(function (column) { | ||
_defineProperty(this, 'leftColumns', function() { | ||
return _this._cache('leftColumns', function() { | ||
return _this.groupedColumns().filter(function(column) { | ||
return column.fixed === 'left' || column.fixed === true; | ||
@@ -129,5 +198,5 @@ }); | ||
_defineProperty(this, "rightColumns", function () { | ||
return _this._cache('rightColumns', function () { | ||
return _this.groupedColumns().filter(function (column) { | ||
_defineProperty(this, 'rightColumns', function() { | ||
return _this._cache('rightColumns', function() { | ||
return _this.groupedColumns().filter(function(column) { | ||
return column.fixed === 'right'; | ||
@@ -138,4 +207,4 @@ }); | ||
_defineProperty(this, "leafColumns", function () { | ||
return _this._cache('leafColumns', function () { | ||
_defineProperty(this, 'leafColumns', function() { | ||
return _this._cache('leafColumns', function() { | ||
return _this._leafColumns(_this.groupedColumns()); | ||
@@ -145,4 +214,4 @@ }); | ||
_defineProperty(this, "leftLeafColumns", function () { | ||
return _this._cache('leftLeafColumns', function () { | ||
_defineProperty(this, 'leftLeafColumns', function() { | ||
return _this._cache('leftLeafColumns', function() { | ||
return _this._leafColumns(_this.leftColumns()); | ||
@@ -152,4 +221,4 @@ }); | ||
_defineProperty(this, "rightLeafColumns", function () { | ||
return _this._cache('rightLeafColumns', function () { | ||
_defineProperty(this, 'rightLeafColumns', function() { | ||
return _this._cache('rightLeafColumns', function() { | ||
return _this._leafColumns(_this.rightColumns()); | ||
@@ -159,4 +228,4 @@ }); | ||
_defineProperty(this, "groupedColumns", function () { | ||
return _this._cache('groupedColumns', function () { | ||
_defineProperty(this, 'groupedColumns', function() { | ||
return _this._cache('groupedColumns', function() { | ||
return _this._updateWidth(_this._groupColumns(_this.columns)); | ||
@@ -166,3 +235,3 @@ }); | ||
_defineProperty(this, "headerSize", function () { | ||
_defineProperty(this, 'headerSize', function() { | ||
return { | ||
@@ -177,3 +246,3 @@ _leftWidth: _this.leftWidth, | ||
_defineProperty(this, "updateWidth", function (wrapperWidth) { | ||
_defineProperty(this, 'updateWidth', function(wrapperWidth) { | ||
if (_this.wrapperWidth !== wrapperWidth) { | ||
@@ -191,3 +260,3 @@ _this.wrapperWidth = wrapperWidth; | ||
_defineProperty(this, "getWidth", function (fixed) { | ||
_defineProperty(this, 'getWidth', function(fixed) { | ||
if (fixed === 'left' || fixed === true) { | ||
@@ -202,6 +271,6 @@ return _this.leftWidth; | ||
_defineProperty(this, "reset", function (_ref2) { | ||
_defineProperty(this, 'reset', function(_ref2) { | ||
var columns = _ref2.columns, | ||
minWidth = _ref2.minWidth, | ||
headerRowHeight = _ref2.headerRowHeight; | ||
minWidth = _ref2.minWidth, | ||
headerRowHeight = _ref2.headerRowHeight; | ||
_this.columns = columns; | ||
@@ -219,3 +288,3 @@ _this.minWidth = minWidth; | ||
_defineProperty(this, "updateGroupedColumns", function (columns) { | ||
_defineProperty(this, 'updateGroupedColumns', function(columns) { | ||
_this._cached = {}; | ||
@@ -226,8 +295,11 @@ _this.columns = _this._uColumns(columns); | ||
_defineProperty(this, "_uColumns", function (columns) { | ||
return columns.map(function (c) { | ||
_defineProperty(this, '_uColumns', function(columns) { | ||
return columns.map(function(c) { | ||
var column = {}; | ||
for (var key in c) { | ||
if (_typeof(key) !== 'symbol' && Object.prototype.hasOwnProperty.call(c, key)) { | ||
if ( | ||
_typeof(key) !== 'symbol' && | ||
Object.prototype.hasOwnProperty.call(c, key) | ||
) { | ||
column[key] = c[key]; | ||
@@ -247,6 +319,10 @@ } | ||
_defineProperty(this, "_calcWidth", function (width, wrapperWidth) { | ||
_defineProperty(this, '_calcWidth', function(width, wrapperWidth) { | ||
if (typeof width === 'string' && percentReg.test(width)) { | ||
var i = width.replace('%', ''); | ||
return (0, _floor.default)(_this._minWidth((0, _multiply.default)(wrapperWidth, (0, _divide.default)(i, 100)))); | ||
return (0, _floor.default)( | ||
_this._minWidth( | ||
(0, _multiply.default)(wrapperWidth, (0, _divide.default)(i, 100)) | ||
) | ||
); | ||
} | ||
@@ -267,7 +343,7 @@ | ||
_defineProperty(this, "_minWidth", function (width) { | ||
_defineProperty(this, '_minWidth', function(width) { | ||
return !width ? width : (0, _max.default)([_this.minWidth, width]); | ||
}); | ||
_defineProperty(this, "_cache", function (name, fn) { | ||
_defineProperty(this, '_cache', function(name, fn) { | ||
if (name in _this._cached) { | ||
@@ -281,3 +357,3 @@ return _this._cached[name]; | ||
_defineProperty(this, "_leafColumns", function (columns) { | ||
_defineProperty(this, '_leafColumns', function(columns) { | ||
var leafColumns = []; | ||
@@ -291,3 +367,6 @@ | ||
} else { | ||
leafColumns.push.apply(leafColumns, _toConsumableArray(_this._leafColumns(column.children))); | ||
leafColumns.push.apply( | ||
leafColumns, | ||
_toConsumableArray(_this._leafColumns(column.children)) | ||
); | ||
} | ||
@@ -299,6 +378,9 @@ } | ||
_defineProperty(this, "_groupColumns", function (columns) { | ||
var currentRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
var parentColumn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var rows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
_defineProperty(this, '_groupColumns', function(columns) { | ||
var currentRow = | ||
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
var parentColumn = | ||
arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var rows = | ||
arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
rows[currentRow] = rows[currentRow] || []; | ||
@@ -310,3 +392,8 @@ var grouped = []; | ||
if (column && !column.children && rs > 1 && (!column[rowSpan] || column[rowSpan] < rs)) { | ||
if ( | ||
column && | ||
!column.children && | ||
rs > 1 && | ||
(!column[rowSpan] || column[rowSpan] < rs) | ||
) { | ||
column[rowSpan] = rs; | ||
@@ -322,3 +409,6 @@ } | ||
rows[currentRow].push(newColumn); | ||
newColumn[path] = [].concat(_toConsumableArray(parentColumn[path] || [currentRow]), [index]); | ||
newColumn[path] = [].concat( | ||
_toConsumableArray(parentColumn[path] || [currentRow]), | ||
[index] | ||
); | ||
newColumn[_pathKey] = newColumn[path].join('-'); | ||
@@ -329,3 +419,8 @@ newColumn[_currentRow] = currentRow; | ||
if (newColumn.children && newColumn.children.length > 0) { | ||
newColumn.children = _this._groupColumns(newColumn.children, currentRow + 1, newColumn, rows); | ||
newColumn.children = _this._groupColumns( | ||
newColumn.children, | ||
currentRow + 1, | ||
newColumn, | ||
rows | ||
); | ||
parentColumn[colSpan] = parentColumn[colSpan] + newColumn[colSpan]; | ||
@@ -335,10 +430,25 @@ newColumn[_width] = (0, _sumBy.default)(newColumn.children, _width); | ||
parentColumn[colSpan]++; | ||
newColumn[_width] = _this._calcWidth(newColumn.width, _this.wrapperWidth); | ||
newColumn[_width] = _this._calcWidth( | ||
newColumn.width, | ||
_this.wrapperWidth | ||
); | ||
if ((0, _isNumber.default)(newColumn.minWidth) && !(0, _isNaN.default)(newColumn.minWidth)) { | ||
newColumn[_width] = (0, _max.default)([newColumn[_width], newColumn.minWidth]); | ||
if ( | ||
(0, _isNumber.default)(newColumn.minWidth) && | ||
!(0, _isNaN.default)(newColumn.minWidth) | ||
) { | ||
newColumn[_width] = (0, _max.default)([ | ||
newColumn[_width], | ||
newColumn.minWidth | ||
]); | ||
} | ||
if ((0, _isNumber.default)(newColumn.maxWidth) && !(0, _isNaN.default)(newColumn.maxWidth)) { | ||
newColumn[_width] = (0, _min.default)([newColumn[_width], newColumn.maxWidth]); | ||
if ( | ||
(0, _isNumber.default)(newColumn.maxWidth) && | ||
!(0, _isNaN.default)(newColumn.maxWidth) | ||
) { | ||
newColumn[_width] = (0, _min.default)([ | ||
newColumn[_width], | ||
newColumn.maxWidth | ||
]); | ||
} | ||
@@ -364,12 +474,13 @@ } | ||
_this.hasOverflowX = _this.width > _this.wrapperWidth && _this.wrapperWidth !== 0; | ||
_this.hasOverflowX = | ||
_this.width > _this.wrapperWidth && _this.wrapperWidth !== 0; | ||
return grouped; | ||
}); | ||
_defineProperty(this, "_updateWidth", function (columns) { | ||
_defineProperty(this, '_updateWidth', function(columns) { | ||
var wrapperWidth = _this.wrapperWidth || 0; | ||
var leftColumns = columns.filter(function (c) { | ||
var leftColumns = columns.filter(function(c) { | ||
return c.fixed === true || c.fixed === 'left'; | ||
}); | ||
var rightColumns = columns.filter(function (c) { | ||
var rightColumns = columns.filter(function(c) { | ||
return c.fixed === 'right'; | ||
@@ -384,7 +495,9 @@ }); | ||
var len = leafColumns.length - leftLeafColumns.length - rightLeafColumns.length; | ||
var len = | ||
leafColumns.length - leftLeafColumns.length - rightLeafColumns.length; | ||
var last; | ||
var lcArr = leafColumns.filter(function (c) { | ||
return !c.fixed && c.fixed !== 'left' && c.fixed !== 'right'; | ||
}) || []; | ||
var lcArr = | ||
leafColumns.filter(function(c) { | ||
return !c.fixed && c.fixed !== 'left' && c.fixed !== 'right'; | ||
}) || []; | ||
@@ -404,7 +517,13 @@ if (leafColumns.length > 0) { | ||
_this.rightWidth = (0, _sumBy.default)(rightColumns, _width); | ||
var average = (0, _max.default)([(0, _floor.default)((wrapperWidth - baseWidth) / len), 0]); | ||
var average = (0, _max.default)([ | ||
(0, _floor.default)((wrapperWidth - baseWidth) / len), | ||
0 | ||
]); | ||
var update = function update(columns) { | ||
var fixed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
return columns.map(function (column) { | ||
var fixed = | ||
arguments.length > 1 && arguments[1] !== undefined | ||
? arguments[1] | ||
: false; | ||
return columns.map(function(column) { | ||
var width = column[_width]; | ||
@@ -417,12 +536,21 @@ var children = column.children || []; | ||
} else { | ||
if (!leftColumns.some(function (c) { | ||
return c[_pathKey] === column[_pathKey]; | ||
}) && !rightColumns.some(function (c) { | ||
return c[_pathKey] === column[_pathKey]; | ||
})) { | ||
if ( | ||
!leftColumns.some(function(c) { | ||
return c[_pathKey] === column[_pathKey]; | ||
}) && | ||
!rightColumns.some(function(c) { | ||
return c[_pathKey] === column[_pathKey]; | ||
}) | ||
) { | ||
column[_width] = width + average; | ||
} | ||
if ((0, _isNumber.default)(column.maxWidth) && !(0, _isNaN.default)(column.maxWidth)) { | ||
column[_width] = (0, _min.default)([column.maxWidth, column[_width]]); | ||
if ( | ||
(0, _isNumber.default)(column.maxWidth) && | ||
!(0, _isNaN.default)(column.maxWidth) | ||
) { | ||
column[_width] = (0, _min.default)([ | ||
column.maxWidth, | ||
column[_width] | ||
]); | ||
} | ||
@@ -434,3 +562,5 @@ } | ||
if (column.fixed === 'left' || column.fixed === true) {} else if (column.fixed === 'right') {} else { | ||
if (column.fixed === 'left' || column.fixed === true) { | ||
} else if (column.fixed === 'right') { | ||
} else { | ||
centerWidth += column[_width]; | ||
@@ -447,3 +577,10 @@ } | ||
if (last) { | ||
last[_width] = (0, _max.default)([wrapperWidth - _this.leftWidth - _this.rightWidth - centerWidth + last[_width], last[_width]]); | ||
last[_width] = (0, _max.default)([ | ||
wrapperWidth - | ||
_this.leftWidth - | ||
_this.rightWidth - | ||
centerWidth + | ||
last[_width], | ||
last[_width] | ||
]); | ||
} | ||
@@ -463,2 +600,2 @@ | ||
exports.default = ColumnManager; | ||
exports.default = ColumnManager; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,298 +8,372 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _classnames = _interopRequireDefault(require('classnames')); | ||
var _findIndex = _interopRequireDefault(require("lodash/findIndex")); | ||
var _findIndex = _interopRequireDefault(require('lodash/findIndex')); | ||
var _types = require("../types"); | ||
var _types = require('../types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _toConsumableArray(arr) { | ||
return ( | ||
_arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread() | ||
); | ||
} | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _nonIterableSpread() { | ||
throw new TypeError('Invalid attempt to spread non-iterable instance'); | ||
} | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _iterableToArray(iter) { | ||
if ( | ||
Symbol.iterator in Object(iter) || | ||
Object.prototype.toString.call(iter) === '[object Arguments]' | ||
) | ||
return Array.from(iter); | ||
} | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { | ||
arr2[i] = arr[i]; | ||
} | ||
return arr2; | ||
} | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a 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); } } | ||
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); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
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 _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; | ||
} | ||
var DataManager = | ||
/*#__PURE__*/ | ||
function () { | ||
function DataManager(_ref) { | ||
var _this = this; | ||
/*#__PURE__*/ | ||
(function() { | ||
function DataManager(_ref) { | ||
var _this = this; | ||
var getProps = _ref.getProps; | ||
var getProps = _ref.getProps; | ||
_classCallCheck(this, DataManager); | ||
_classCallCheck(this, DataManager); | ||
_defineProperty(this, "_cached", {}); | ||
_defineProperty(this, '_cached', {}); | ||
_defineProperty(this, "_bodyHeight", 0); | ||
_defineProperty(this, '_bodyHeight', 0); | ||
_defineProperty(this, "_hasExpanded", false); | ||
_defineProperty(this, '_hasExpanded', false); | ||
_defineProperty(this, "_data", []); | ||
_defineProperty(this, '_data', []); | ||
_defineProperty(this, "getData", function () { | ||
return _this._cache('getData', function () { | ||
return _this._getData(_this._data); | ||
_defineProperty(this, 'getData', function() { | ||
return _this._cache('getData', function() { | ||
return _this._getData(_this._data); | ||
}); | ||
}); | ||
}); | ||
_defineProperty(this, "getFixedData", function () { | ||
return _this._cache('getFixedData', function () { | ||
return _this._getFixedData(_this.showData()); | ||
_defineProperty(this, 'getFixedData', function() { | ||
return _this._cache('getFixedData', function() { | ||
return _this._getFixedData(_this.showData()); | ||
}); | ||
}); | ||
}); | ||
_defineProperty(this, "showData", function () { | ||
return _this._cache('showData', function () { | ||
return _this._showData(_this.getData()); | ||
_defineProperty(this, 'showData', function() { | ||
return _this._cache('showData', function() { | ||
return _this._showData(_this.getData()); | ||
}); | ||
}); | ||
}); | ||
_defineProperty(this, "fixedData", function () { | ||
return _this._cache('fixedData', function () { | ||
return _this._getFixedData(_this.showData()); | ||
_defineProperty(this, 'fixedData', function() { | ||
return _this._cache('fixedData', function() { | ||
return _this._getFixedData(_this.showData()); | ||
}); | ||
}); | ||
}); | ||
_defineProperty(this, "fixedDataLength", function () { | ||
return _this._cache('fixedDataLength', function () { | ||
return _this.fixedData().length; | ||
_defineProperty(this, 'fixedDataLength', function() { | ||
return _this._cache('fixedDataLength', function() { | ||
return _this.fixedData().length; | ||
}); | ||
}); | ||
}); | ||
_defineProperty(this, "isExpanded", function () { | ||
return _this._cache('isExpanded', function () { | ||
return _this.getData().some(function (d) { | ||
return d.children && d.children.length > 0; | ||
_defineProperty(this, 'isExpanded', function() { | ||
return _this._cache('isExpanded', function() { | ||
return _this.getData().some(function(d) { | ||
return d.children && d.children.length > 0; | ||
}); | ||
}); | ||
}); | ||
}); | ||
_defineProperty(this, "rowIsExpanded", function (record) { | ||
return _this.expandedRowKeys.indexOf(record[_types.DS._key]) > -1; | ||
}); | ||
_defineProperty(this, 'rowIsExpanded', function(record) { | ||
return _this.expandedRowKeys.indexOf(record[_types.DS._key]) > -1; | ||
}); | ||
_defineProperty(this, "isFixed", function (record) { | ||
if ((record.children || []).length > 0) { | ||
return false; | ||
} | ||
_defineProperty(this, 'isFixed', function(record) { | ||
if ((record.children || []).length > 0) { | ||
return false; | ||
} | ||
return record['isFixed'] === true || record['isFixed'] === 'top' || record['isFixed'] === 'bottom'; | ||
}); | ||
_defineProperty(this, "reset", function (data) { | ||
var _data = data || []; | ||
_this._hasExpanded = _data.some(function (d) { | ||
return !_this.isFixed(d) && (d.children || []).length > 0; | ||
return ( | ||
record['isFixed'] === true || | ||
record['isFixed'] === 'top' || | ||
record['isFixed'] === 'bottom' | ||
); | ||
}); | ||
if (!_this.getProps('fixedHeader')) { | ||
_this._data = _data; | ||
} else { | ||
var dataBase = _data.filter(function (d) { | ||
var children = d.children || []; | ||
return children.length > 0 || !_this.isFixed(d); | ||
}); | ||
_defineProperty(this, 'reset', function(data) { | ||
var _data = data || []; | ||
var topData = _data.filter(function (d) { | ||
var children = d.children || []; | ||
return (d['isFixed'] === true || d['isFixed'] === 'top') && children.length === 0; | ||
_this._hasExpanded = _data.some(function(d) { | ||
return !_this.isFixed(d) && (d.children || []).length > 0; | ||
}); | ||
var bottomData = _data.filter(function (d) { | ||
var children = d.children || []; | ||
return d['isFixed'] === 'bottom' && children.length === 0; | ||
}); | ||
if (!_this.getProps('fixedHeader')) { | ||
_this._data = _data; | ||
} else { | ||
var dataBase = _data.filter(function(d) { | ||
var children = d.children || []; | ||
return children.length > 0 || !_this.isFixed(d); | ||
}); | ||
_this._data = [].concat(_toConsumableArray(topData), _toConsumableArray(dataBase), _toConsumableArray(bottomData)); | ||
} | ||
var topData = _data.filter(function(d) { | ||
var children = d.children || []; | ||
return ( | ||
(d['isFixed'] === true || d['isFixed'] === 'top') && | ||
children.length === 0 | ||
); | ||
}); | ||
_this._bodyHeight = 0; | ||
_this._cached = {}; | ||
var bottomData = _data.filter(function(d) { | ||
var children = d.children || []; | ||
return d['isFixed'] === 'bottom' && children.length === 0; | ||
}); | ||
_this.showData(); | ||
}); | ||
_this._data = [].concat( | ||
_toConsumableArray(topData), | ||
_toConsumableArray(dataBase), | ||
_toConsumableArray(bottomData) | ||
); | ||
} | ||
_defineProperty(this, "getByKey", function (key) { | ||
var index = (0, _findIndex.default)(_this.showData(), function (d) { | ||
return d[_types.DS._key] === key; | ||
_this._bodyHeight = 0; | ||
_this._cached = {}; | ||
_this.showData(); | ||
}); | ||
if (index < 0) { | ||
return null; | ||
} | ||
_defineProperty(this, 'getByKey', function(key) { | ||
var index = (0, _findIndex.default)(_this.showData(), function(d) { | ||
return d[_types.DS._key] === key; | ||
}); | ||
return _this.showData()[index]; | ||
}); | ||
if (index < 0) { | ||
return null; | ||
} | ||
_defineProperty(this, "resetExpandedRowKeys", function (keys) { | ||
_this.expandedRowKeys = Array.from(new Set(keys)); | ||
delete _this._cached['getRowsHeight']; | ||
delete _this._cached['showData']; | ||
return _this.showData()[index]; | ||
}); | ||
_this.showData(); | ||
_defineProperty(this, 'resetExpandedRowKeys', function(keys) { | ||
_this.expandedRowKeys = Array.from(new Set(keys)); | ||
delete _this._cached['getRowsHeight']; | ||
delete _this._cached['showData']; | ||
return _this.expandedRowKeys; | ||
}); | ||
_this.showData(); | ||
_defineProperty(this, "expanded", function (key) { | ||
var keys = _this.expandedRowKeys || []; | ||
return _this.expandedRowKeys; | ||
}); | ||
if (keys.indexOf(key) < 0) { | ||
keys.push(key); | ||
} else { | ||
keys = keys.filter(function (k) { | ||
return key !== k; | ||
}); | ||
} | ||
_defineProperty(this, 'expanded', function(key) { | ||
var keys = _this.expandedRowKeys || []; | ||
_this.expandedRowKeys = Array.from(new Set(keys)); | ||
delete _this._cached['getRowsHeight']; | ||
delete _this._cached['showData']; | ||
if (keys.indexOf(key) < 0) { | ||
keys.push(key); | ||
} else { | ||
keys = keys.filter(function(k) { | ||
return key !== k; | ||
}); | ||
} | ||
_this.showData(); | ||
_this.expandedRowKeys = Array.from(new Set(keys)); | ||
delete _this._cached['getRowsHeight']; | ||
delete _this._cached['showData']; | ||
return _this.expandedRowKeys; | ||
}); | ||
_this.showData(); | ||
_defineProperty(this, "_cache", function (name, fn) { | ||
if (name in _this._cached) { | ||
return _this.expandedRowKeys; | ||
}); | ||
_defineProperty(this, '_cache', function(name, fn) { | ||
if (name in _this._cached) { | ||
return _this._cached[name]; | ||
} | ||
_this._cached[name] = fn(); | ||
return _this._cached[name]; | ||
} | ||
}); | ||
_this._cached[name] = fn(); | ||
return _this._cached[name]; | ||
}); | ||
_defineProperty(this, '_getData', function(dataSource) { | ||
var level = | ||
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
var parentPath = arguments.length > 2 ? arguments[2] : undefined; | ||
dataSource = dataSource || []; | ||
_defineProperty(this, "_getData", function (dataSource) { | ||
var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
var parentPath = arguments.length > 2 ? arguments[2] : undefined; | ||
dataSource = dataSource || []; | ||
var getRowHeight = _this.getProps('getRowHeight'); | ||
var getRowHeight = _this.getProps('getRowHeight'); | ||
var rowHeight = _this.getProps('rowHeight'); | ||
var rowHeight = _this.getProps('rowHeight'); | ||
for (var index = 0; index < dataSource.length; index++) { | ||
var height = getRowHeight(dataSource[index], index) * rowHeight; | ||
var path = ''.concat( | ||
parentPath === undefined | ||
? index | ||
: ''.concat(parentPath, '-').concat(index) | ||
); | ||
var record = dataSource[index]; | ||
var children = record['children'] || []; | ||
record[_types.DS._index] = index; | ||
record[_types.DS._path] = path; | ||
record[_types.DS._expandedLevel] = level; | ||
record[_types.DS._height] = height; | ||
record[_types.DS._key] = _this._rowKey(record, index); | ||
record[_types.DS._expandedEnable] = children.length > 0; | ||
for (var index = 0; index < dataSource.length; index++) { | ||
var height = getRowHeight(dataSource[index], index) * rowHeight; | ||
var path = "".concat(parentPath === undefined ? index : "".concat(parentPath, "-").concat(index)); | ||
var record = dataSource[index]; | ||
var children = record['children'] || []; | ||
record[_types.DS._index] = index; | ||
record[_types.DS._path] = path; | ||
record[_types.DS._expandedLevel] = level; | ||
record[_types.DS._height] = height; | ||
record[_types.DS._key] = _this._rowKey(record, index); | ||
record[_types.DS._expandedEnable] = children.length > 0; | ||
if (_this.isFixed(record)) { | ||
record[_types.DS._isFixed] = record['isFixed']; | ||
} | ||
if (_this.isFixed(record)) { | ||
record[_types.DS._isFixed] = record['isFixed']; | ||
if (children.length > 0) { | ||
record['children'] = _this._getData(children, level + 1, path); | ||
} | ||
} | ||
if (children.length > 0) { | ||
record['children'] = _this._getData(children, level + 1, path); | ||
} | ||
} | ||
return dataSource; | ||
}); | ||
return dataSource; | ||
}); | ||
_defineProperty(this, "_getFixedData", function (data) { | ||
return data.filter(function (d) { | ||
return d['isFixed'] && (d.children || []).length === 0; | ||
_defineProperty(this, '_getFixedData', function(data) { | ||
return data.filter(function(d) { | ||
return d['isFixed'] && (d.children || []).length === 0; | ||
}); | ||
}); | ||
}); | ||
_defineProperty(this, "_showData", function (dataSource, data) { | ||
dataSource = dataSource || []; | ||
data = data || []; | ||
_defineProperty(this, '_showData', function(dataSource, data) { | ||
dataSource = dataSource || []; | ||
data = data || []; | ||
if (data.length === 0) { | ||
_this._bodyHeight = 0; | ||
} | ||
if (data.length === 0) { | ||
_this._bodyHeight = 0; | ||
} | ||
var expandedKeys = _this.expandedRowKeys || []; | ||
var expandedKeys = _this.expandedRowKeys || []; | ||
for (var index = 0; index < dataSource.length; index++) { | ||
var record = dataSource[index]; | ||
record[_types.DS._showIndex] = data.length; | ||
record[_types.DS._top] = _this._bodyHeight; | ||
record[_types.DS._rowClassName] = _this._rowClassName(record, data.length); | ||
_this._bodyHeight += record[_types.DS._height]; | ||
var children = record.children || []; | ||
for (var index = 0; index < dataSource.length; index++) { | ||
var record = dataSource[index]; | ||
record[_types.DS._showIndex] = data.length; | ||
record[_types.DS._top] = _this._bodyHeight; | ||
record[_types.DS._rowClassName] = _this._rowClassName( | ||
record, | ||
data.length | ||
); | ||
_this._bodyHeight += record[_types.DS._height]; | ||
var children = record.children || []; | ||
var _expanded = expandedKeys.length > 0 && expandedKeys.indexOf(record[_types.DS._key]) > -1 && children.length > 0; | ||
var _expanded = | ||
expandedKeys.length > 0 && | ||
expandedKeys.indexOf(record[_types.DS._key]) > -1 && | ||
children.length > 0; | ||
record[_types.DS._expanded] = _expanded; | ||
data.push(record); | ||
record[_types.DS._expanded] = _expanded; | ||
data.push(record); | ||
if (_expanded) { | ||
data = _this._showData(children, data); | ||
if (_expanded) { | ||
data = _this._showData(children, data); | ||
} | ||
} | ||
} | ||
return data; | ||
}); | ||
return data; | ||
}); | ||
_defineProperty(this, "_rowKey", function (record, index) { | ||
var rowKey = _this.getProps('rowKey'); | ||
_defineProperty(this, '_rowKey', function(record, index) { | ||
var rowKey = _this.getProps('rowKey'); | ||
if (typeof rowKey === 'function') { | ||
return String(rowKey(record, index)); | ||
} else if (typeof rowKey === 'string') { | ||
return String(record[rowKey]); | ||
} else if (record['key']) { | ||
return String(record['key']); | ||
} | ||
if (typeof rowKey === 'function') { | ||
return String(rowKey(record, index)); | ||
} else if (typeof rowKey === 'string') { | ||
return String(record[rowKey]); | ||
} else if (record['key']) { | ||
return String(record['key']); | ||
} | ||
return String(record[_types.DS._path]); | ||
}); | ||
return String(record[_types.DS._path]); | ||
}); | ||
_defineProperty(this, "_rowClassName", function (record, index, level) { | ||
var _classNames; | ||
_defineProperty(this, '_rowClassName', function(record, index, level) { | ||
var _classNames; | ||
var className = ''; | ||
var className = ''; | ||
var rowClassName = _this.getProps('rowClassName'); | ||
var rowClassName = _this.getProps('rowClassName'); | ||
if (typeof rowClassName === 'function') { | ||
className = rowClassName(record, index); | ||
} else if (rowClassName === 'string') { | ||
className = rowClassName || ''; | ||
} | ||
if (typeof rowClassName === 'function') { | ||
className = rowClassName(record, index); | ||
} else if (rowClassName === 'string') { | ||
className = rowClassName || ''; | ||
} | ||
var prefixCls = _this.getProps('prefixCls'); | ||
var prefixCls = _this.getProps('prefixCls'); | ||
return (0, _classnames.default)('tr', "".concat(prefixCls, "-row"), className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-expanded-row-").concat(level), _this._hasExpanded), _defineProperty(_classNames, "".concat(prefixCls, "-row-fixed"), record[_types.DS._isFixed]), _classNames)); | ||
}); | ||
return (0, | ||
_classnames.default)('tr', ''.concat(prefixCls, '-row'), className, ((_classNames = {}), _defineProperty(_classNames, ''.concat(prefixCls, '-expanded-row-').concat(level), _this._hasExpanded), _defineProperty(_classNames, ''.concat(prefixCls, '-row-fixed'), record[_types.DS._isFixed]), _classNames)); | ||
}); | ||
this.getProps = getProps; | ||
this.expandedRowKeys = getProps('expandedRowKeys') || []; | ||
this.reset(getProps('dataSource')); | ||
} | ||
_createClass(DataManager, [{ | ||
key: "isEmpty", | ||
value: function isEmpty() { | ||
return this.getData().length === 0; | ||
this.getProps = getProps; | ||
this.expandedRowKeys = getProps('expandedRowKeys') || []; | ||
this.reset(getProps('dataSource')); | ||
} | ||
}]); | ||
return DataManager; | ||
}(); | ||
_createClass(DataManager, [ | ||
{ | ||
key: 'isEmpty', | ||
value: function isEmpty() { | ||
return this.getData().length === 0; | ||
} | ||
} | ||
]); | ||
exports.default = DataManager; | ||
return DataManager; | ||
})(); | ||
exports.default = DataManager; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,184 +8,221 @@ }); | ||
var _types = require("../types"); | ||
var _types = require('../types'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a 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); } } | ||
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); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
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 _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; | ||
} | ||
var SelectManager = | ||
/*#__PURE__*/ | ||
function () { | ||
function SelectManager(props) { | ||
var _this = this; | ||
/*#__PURE__*/ | ||
(function() { | ||
function SelectManager(props) { | ||
var _this = this; | ||
_classCallCheck(this, SelectManager); | ||
_classCallCheck(this, SelectManager); | ||
_defineProperty(this, "_selectedKeys", []); | ||
_defineProperty(this, '_selectedKeys', []); | ||
_defineProperty(this, "_type", 'checkbox'); | ||
_defineProperty(this, '_type', 'checkbox'); | ||
_defineProperty(this, "_useSelectAll", false); | ||
_defineProperty(this, '_useSelectAll', false); | ||
_defineProperty(this, "_enable", false); | ||
_defineProperty(this, '_enable', false); | ||
_defineProperty(this, "_selectedAll", false); | ||
_defineProperty(this, '_selectedAll', false); | ||
_defineProperty(this, "_disabled", []); | ||
_defineProperty(this, '_disabled', []); | ||
_defineProperty(this, "_count", 0); | ||
_defineProperty(this, '_count', 0); | ||
_defineProperty(this, "getKeys", function (arr, keys) { | ||
arr = arr || []; | ||
keys = keys || []; | ||
_defineProperty(this, 'getKeys', function(arr, keys) { | ||
arr = arr || []; | ||
keys = keys || []; | ||
for (var i = 0; i < arr.length; i++) { | ||
keys.push(arr[i][_types.DS._key]); | ||
var children = arr[i].children || []; | ||
for (var i = 0; i < arr.length; i++) { | ||
keys.push(arr[i][_types.DS._key]); | ||
var children = arr[i].children || []; | ||
if (children.length > 0) { | ||
_this.getKeys(children, keys); | ||
if (children.length > 0) { | ||
_this.getKeys(children, keys); | ||
} | ||
} | ||
} | ||
return keys; | ||
}); | ||
return keys; | ||
}); | ||
_defineProperty(this, "selectAll", function (keys) { | ||
var _this$getProps = _this.getProps('rowSelection'), | ||
_defineProperty(this, 'selectAll', function(keys) { | ||
var _this$getProps = _this.getProps('rowSelection'), | ||
onSelect = _this$getProps.onSelect, | ||
type = _this$getProps.type; | ||
_this._selectedAll = !_this._selectedAll; | ||
_this._selectedAll = !_this._selectedAll; | ||
if (_this._selectedAll) { | ||
_this._selectedKeys = keys; | ||
} else { | ||
_this._selectedKeys = []; | ||
} | ||
if (_this._selectedAll) { | ||
_this._selectedKeys = keys; | ||
} else { | ||
_this._selectedKeys = []; | ||
} | ||
if (typeof onSelect === 'function') { | ||
onSelect(null, _this._selectedAll, _this._selectedKeys); | ||
} | ||
if (typeof onSelect === 'function') { | ||
onSelect(null, _this._selectedAll, _this._selectedKeys); | ||
} | ||
_this.update(); | ||
}); | ||
_this.update(); | ||
}); | ||
_defineProperty(this, "disabled", function (record) { | ||
return _this._disabled.includes(record[_types.DS._key]); | ||
}); | ||
_defineProperty(this, 'disabled', function(record) { | ||
return _this._disabled.includes(record[_types.DS._key]); | ||
}); | ||
_defineProperty(this, "select", function (record, selected) { | ||
var _this$getProps2 = _this.getProps('rowSelection'), | ||
_defineProperty(this, 'select', function(record, selected) { | ||
var _this$getProps2 = _this.getProps('rowSelection'), | ||
onSelect = _this$getProps2.onSelect, | ||
type = _this$getProps2.type; | ||
var t = type || _this._type; | ||
var t = type || _this._type; | ||
if (t === 'checkbox') { | ||
var keys = _this.getKeys([record]); | ||
if (t === 'checkbox') { | ||
var keys = _this.getKeys([record]); | ||
if (selected) { | ||
for (var i = 0; i < keys.length; i++) { | ||
if (!_this._selectedKeys.includes(keys[i])) { | ||
_this._selectedKeys.push(keys[i]); | ||
if (selected) { | ||
for (var i = 0; i < keys.length; i++) { | ||
if (!_this._selectedKeys.includes(keys[i])) { | ||
_this._selectedKeys.push(keys[i]); | ||
} | ||
} | ||
} else { | ||
_this._selectedKeys = _this._selectedKeys.filter(function(k) { | ||
return !keys.includes(k); | ||
}); | ||
} | ||
} else { | ||
_this._selectedKeys = _this._selectedKeys.filter(function (k) { | ||
return !keys.includes(k); | ||
}); | ||
} else if (t === 'radio') { | ||
if (_this._selectedKeys.includes(record[_types.DS._key])) { | ||
return false; | ||
} else { | ||
_this._selectedKeys = [record[_types.DS._key]]; | ||
} | ||
} | ||
} else if (t === 'radio') { | ||
if (_this._selectedKeys.includes(record[_types.DS._key])) { | ||
return false; | ||
} else { | ||
_this._selectedKeys = [record[_types.DS._key]]; | ||
if (typeof onSelect === 'function') { | ||
onSelect(record, selected, _this._selectedKeys); | ||
} | ||
} | ||
if (typeof onSelect === 'function') { | ||
onSelect(record, selected, _this._selectedKeys); | ||
} | ||
_this._selectedAll = _this._selectedKeys.length === _this._count; | ||
_this._selectedAll = _this._selectedKeys.length === _this._count; | ||
_this.update(); | ||
}); | ||
_this.update(); | ||
}); | ||
_defineProperty(this, 'updateSelection', function(rowSelection) { | ||
_this.getSelection(rowSelection); | ||
_defineProperty(this, "updateSelection", function (rowSelection) { | ||
_this.getSelection(rowSelection); | ||
_this.update(); | ||
}); | ||
_this.update(); | ||
}); | ||
_defineProperty(this, 'getSelection', function(rowSelection) { | ||
_this._enable = !!rowSelection; | ||
_defineProperty(this, "getSelection", function (rowSelection) { | ||
_this._enable = !!rowSelection; | ||
if (_this._enable) { | ||
['selectedKeys', 'type', 'useSelectAll', 'disabled'].forEach(function( | ||
k | ||
) { | ||
if (Object.prototype.hasOwnProperty.call(rowSelection, k)) { | ||
_this['_'.concat(k)] = rowSelection[k]; | ||
} | ||
}); | ||
_this._selectedKeys = _this._selectedKeys || []; | ||
_this._disabled = (_this._disabled || []).map(function(d) { | ||
return d + ''; | ||
}); | ||
_this._type = _this._type || 'checkbox'; | ||
if (_this._enable) { | ||
['selectedKeys', 'type', 'useSelectAll', 'disabled'].forEach(function (k) { | ||
if (Object.prototype.hasOwnProperty.call(rowSelection, k)) { | ||
_this["_".concat(k)] = rowSelection[k]; | ||
if (_this._type === 'radio' && _this._selectedKeys.length > 1) { | ||
_this._selectedKeys = []; | ||
} | ||
}); | ||
_this._selectedKeys = _this._selectedKeys || []; | ||
_this._disabled = (_this._disabled || []).map(function (d) { | ||
return d + ''; | ||
}); | ||
_this._type = _this._type || 'checkbox'; | ||
if (_this._type === 'radio' && _this._selectedKeys.length > 1) { | ||
_this._selectedKeys = []; | ||
_this._useSelectAll = !!_this._useSelectAll; | ||
} | ||
}); | ||
_this._useSelectAll = !!_this._useSelectAll; | ||
} | ||
}); | ||
this.getProps = props.getProps; | ||
this.update = props.update; | ||
this.getProps = props.getProps; | ||
this.update = props.update; | ||
var _rowSelection = props.getProps('rowSelection'); | ||
var _rowSelection = props.getProps('rowSelection'); | ||
this.getSelection(_rowSelection); | ||
} | ||
this.getSelection(_rowSelection); | ||
} | ||
_createClass(SelectManager, [ | ||
{ | ||
key: 'enable', | ||
get: function get() { | ||
return this._enable; | ||
} | ||
}, | ||
{ | ||
key: 'type', | ||
get: function get() { | ||
return this._type; | ||
} | ||
}, | ||
{ | ||
key: 'selectedKeys', | ||
get: function get() { | ||
return this._selectedKeys || []; | ||
} | ||
}, | ||
{ | ||
key: 'useSelectAll', | ||
get: function get() { | ||
return this._useSelectAll; | ||
} | ||
}, | ||
{ | ||
key: 'selectedAll', | ||
get: function get() { | ||
return this._selectedAll; | ||
} | ||
}, | ||
{ | ||
key: 'count', | ||
set: function set(c) { | ||
this._count = c; | ||
} | ||
} | ||
]); | ||
_createClass(SelectManager, [{ | ||
key: "enable", | ||
get: function get() { | ||
return this._enable; | ||
} | ||
}, { | ||
key: "type", | ||
get: function get() { | ||
return this._type; | ||
} | ||
}, { | ||
key: "selectedKeys", | ||
get: function get() { | ||
return this._selectedKeys || []; | ||
} | ||
}, { | ||
key: "useSelectAll", | ||
get: function get() { | ||
return this._useSelectAll; | ||
} | ||
}, { | ||
key: "selectedAll", | ||
get: function get() { | ||
return this._selectedAll; | ||
} | ||
}, { | ||
key: "count", | ||
set: function set(c) { | ||
this._count = c; | ||
} | ||
}]); | ||
return SelectManager; | ||
})(); | ||
return SelectManager; | ||
}(); | ||
exports.default = SelectManager; | ||
exports.default = SelectManager; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,9 +8,27 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a function'); | ||
} | ||
} | ||
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 _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; | ||
} | ||
@@ -21,54 +39,55 @@ var SizeManager = function SizeManager(_ref) { | ||
var showHeader = _ref.showHeader, | ||
footerHeight = _ref.footerHeight, | ||
rowHeight = _ref.rowHeight, | ||
footer = _ref.footer, | ||
dataSource = _ref.dataSource, | ||
useScrollY = _ref.useScrollY, | ||
fixedHeader = _ref.fixedHeader, | ||
showStartIndex = _ref.showStartIndex; | ||
footerHeight = _ref.footerHeight, | ||
rowHeight = _ref.rowHeight, | ||
footer = _ref.footer, | ||
dataSource = _ref.dataSource, | ||
useScrollY = _ref.useScrollY, | ||
fixedHeader = _ref.fixedHeader, | ||
showStartIndex = _ref.showStartIndex; | ||
_classCallCheck(this, SizeManager); | ||
_defineProperty(this, "_dataWidth", 0); | ||
_defineProperty(this, '_dataWidth', 0); | ||
_defineProperty(this, "_dataHeight", 0); | ||
_defineProperty(this, '_dataHeight', 0); | ||
_defineProperty(this, "_wrapperWidth", 0); | ||
_defineProperty(this, '_wrapperWidth', 0); | ||
_defineProperty(this, "_wrapperHeight", 0); | ||
_defineProperty(this, '_wrapperHeight', 0); | ||
_defineProperty(this, "_leftWidth", 0); | ||
_defineProperty(this, '_leftWidth', 0); | ||
_defineProperty(this, "_rightWidth", 0); | ||
_defineProperty(this, '_rightWidth', 0); | ||
_defineProperty(this, "_headerWidth", 0); | ||
_defineProperty(this, '_headerWidth', 0); | ||
_defineProperty(this, "_headerHeight", 0); | ||
_defineProperty(this, '_headerHeight', 0); | ||
_defineProperty(this, "_scrollTop", 0); | ||
_defineProperty(this, '_scrollTop', 0); | ||
_defineProperty(this, "_scrollLeft", 0); | ||
_defineProperty(this, '_scrollLeft', 0); | ||
_defineProperty(this, "_startIndex", 0); | ||
_defineProperty(this, '_startIndex', 0); | ||
_defineProperty(this, "_stopIndex", 0); | ||
_defineProperty(this, '_stopIndex', 0); | ||
_defineProperty(this, "_scrollSizeY", 0); | ||
_defineProperty(this, '_scrollSizeY', 0); | ||
_defineProperty(this, "_scrollSizeX", 0); | ||
_defineProperty(this, '_scrollSizeX', 0); | ||
_defineProperty(this, "_showCount", 10); | ||
_defineProperty(this, '_showCount', 10); | ||
_defineProperty(this, "_hasScrollX", false); | ||
_defineProperty(this, '_hasScrollX', false); | ||
_defineProperty(this, "_hasScrollY", false); | ||
_defineProperty(this, '_hasScrollY', false); | ||
_defineProperty(this, "_dataEmpty", true); | ||
_defineProperty(this, '_dataEmpty', true); | ||
_defineProperty(this, "_clientBodyHeight", 0); | ||
_defineProperty(this, '_clientBodyHeight', 0); | ||
_defineProperty(this, "_showStartIndex", 0); | ||
_defineProperty(this, '_showStartIndex', 0); | ||
_defineProperty(this, "update", function () { | ||
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
_defineProperty(this, 'update', function() { | ||
var size = | ||
arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -88,22 +107,33 @@ for (var key in size) { | ||
_defineProperty(this, "setHasScrollY", function () { | ||
_this._hasScrollY = _this.useScrollY && _this._wrapperHeight > 0 && _this._wrapperHeight < _this._totalHeight(); | ||
_defineProperty(this, 'setHasScrollY', function() { | ||
_this._hasScrollY = | ||
_this.useScrollY && | ||
_this._wrapperHeight > 0 && | ||
_this._wrapperHeight < _this._totalHeight(); | ||
}); | ||
_defineProperty(this, "clientBodyHeight", function () { | ||
_defineProperty(this, 'clientBodyHeight', function() { | ||
var height = _this._wrapperHeight - _this.footerHeight; | ||
height = height - (_this.showHeader && _this.fixedHeader ? _this._headerHeight : 0); | ||
height = | ||
height - | ||
(_this.showHeader && _this.fixedHeader ? _this._headerHeight : 0); | ||
_this._clientBodyHeight = height; | ||
}); | ||
_defineProperty(this, "scrollSizeX", function () { | ||
_defineProperty(this, 'scrollSizeX', function() { | ||
return _this._hasScrollX ? _this._scrollSizeX : 0; | ||
}); | ||
_defineProperty(this, "scrollSizeY", function () { | ||
_defineProperty(this, 'scrollSizeY', function() { | ||
return _this._hasScrollY ? _this._scrollSizeY : 0; | ||
}); | ||
_defineProperty(this, "_totalHeight", function () { | ||
return _this._dataHeight + (_this.showHeader ? _this._headerHeight : 0) + _this.footerHeight + _this._emptyTextHeight + (_this._hasScrollX && _this._scrollSizeY ? _this._scrollSizeY : 0); | ||
_defineProperty(this, '_totalHeight', function() { | ||
return ( | ||
_this._dataHeight + | ||
(_this.showHeader ? _this._headerHeight : 0) + | ||
_this.footerHeight + | ||
_this._emptyTextHeight + | ||
(_this._hasScrollX && _this._scrollSizeY ? _this._scrollSizeY : 0) | ||
); | ||
}); | ||
@@ -125,2 +155,2 @@ | ||
var _default = SizeManager; | ||
exports.default = _default; | ||
exports.default = _default; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,97 +8,134 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a 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); } } | ||
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); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
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 _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; | ||
} | ||
var SortManager = | ||
/*#__PURE__*/ | ||
function () { | ||
function SortManager(_ref) { | ||
var _this = this; | ||
/*#__PURE__*/ | ||
(function() { | ||
function SortManager(_ref) { | ||
var _this = this; | ||
var _columns = _ref.columns, | ||
var _columns = _ref.columns, | ||
_sortMulti = _ref.sortMulti; | ||
_classCallCheck(this, SortManager); | ||
_classCallCheck(this, SortManager); | ||
_defineProperty(this, "_cached", {}); | ||
_defineProperty(this, '_cached', {}); | ||
_defineProperty(this, "update", function (_ref2) { | ||
var columns = _ref2.columns, | ||
_defineProperty(this, 'update', function(_ref2) { | ||
var columns = _ref2.columns, | ||
sortMulti = _ref2.sortMulti; | ||
_this.columns = columns; | ||
_this.sortMulti = sortMulti; | ||
_this.enable = {}; | ||
_this.enable = _this._enable(columns); | ||
}); | ||
_this.columns = columns; | ||
_this.sortMulti = sortMulti; | ||
_this.enable = {}; | ||
_this.enable = _this._enable(columns); | ||
}); | ||
_defineProperty(this, "_enable", function (columns) { | ||
var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
_defineProperty(this, '_enable', function(columns) { | ||
var order = | ||
arguments.length > 1 && arguments[1] !== undefined | ||
? arguments[1] | ||
: {}; | ||
for (var i = 0; i < columns.length; i++) { | ||
var column = columns[i] || {}; | ||
var children = column.children || []; | ||
for (var i = 0; i < columns.length; i++) { | ||
var column = columns[i] || {}; | ||
var children = column.children || []; | ||
if (children.length > 0) { | ||
order = _this._enable(children, order); | ||
} else { | ||
if (column.sortEnable) { | ||
order[column.dataIndex] = column.order; | ||
if (children.length > 0) { | ||
order = _this._enable(children, order); | ||
} else { | ||
if (column.sortEnable) { | ||
order[column.dataIndex] = column.order; | ||
} | ||
} | ||
} | ||
} | ||
return order; | ||
}); | ||
return order; | ||
}); | ||
this.columns = _columns; | ||
this.sortMulti = _sortMulti; | ||
this.enable = this._enable(_columns); | ||
} | ||
this.columns = _columns; | ||
this.sortMulti = _sortMulti; | ||
this.enable = this._enable(_columns); | ||
} | ||
_createClass(SortManager, [{ | ||
key: "enabled", | ||
value: function enabled() { | ||
var _this2 = this; | ||
_createClass(SortManager, [ | ||
{ | ||
key: 'enabled', | ||
value: function enabled() { | ||
var _this2 = this; | ||
return this._cache('enabled', function () { | ||
return _this2.enable; | ||
}); | ||
} | ||
}, { | ||
key: "setOrder", | ||
value: function setOrder(key, order, fn) { | ||
if (!this.sortMulti) { | ||
this.enable = _defineProperty({}, "".concat(key), order); | ||
} | ||
return this._cache('enabled', function() { | ||
return _this2.enable; | ||
}); | ||
} | ||
}, | ||
{ | ||
key: 'setOrder', | ||
value: function setOrder(key, order, fn) { | ||
if (!this.sortMulti) { | ||
this.enable = _defineProperty({}, ''.concat(key), order); | ||
} | ||
this.enable[key] = order; | ||
this.enable[key] = order; | ||
if (typeof fn === 'function') { | ||
fn(this.enable); | ||
if (typeof fn === 'function') { | ||
fn(this.enable); | ||
} | ||
} | ||
}, | ||
{ | ||
key: '_cache', | ||
value: function _cache(name, fn) { | ||
if (name in this._cached) { | ||
return this._cached[name]; | ||
} | ||
this._cached[name] = fn(); | ||
return this._cached[name]; | ||
} | ||
} | ||
} | ||
}, { | ||
key: "_cache", | ||
value: function _cache(name, fn) { | ||
if (name in this._cached) { | ||
return this._cached[name]; | ||
} | ||
]); | ||
this._cached[name] = fn(); | ||
return this._cached[name]; | ||
} | ||
}]); | ||
return SortManager; | ||
})(); | ||
return SortManager; | ||
}(); | ||
exports.default = SortManager; | ||
exports.default = SortManager; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,33 +8,132 @@ }); | ||
var _react = require("react"); | ||
var _react = require('react'); | ||
var _shallowequal = _interopRequireDefault(require("shallowequal")); | ||
var _shallowequal = _interopRequireDefault(require('shallowequal')); | ||
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics")); | ||
var _hoistNonReactStatics = _interopRequireDefault( | ||
require('hoist-non-react-statics') | ||
); | ||
var _PropTypes = require("./PropTypes"); | ||
var _PropTypes = require('./PropTypes'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { | ||
if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') { | ||
_typeof = function _typeof(obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && | ||
typeof Symbol === 'function' && | ||
obj.constructor === Symbol && | ||
obj !== Symbol.prototype | ||
? 'symbol' | ||
: typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat( | ||
Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
}) | ||
); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a 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); } } | ||
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); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === 'object' || typeof call === 'function')) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf | ||
? Object.getPrototypeOf | ||
: function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== 'function' && superClass !== null) { | ||
throw new TypeError('Super expression must either be null or a function'); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: {value: subClass, writable: true, configurable: true} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = | ||
Object.setPrototypeOf || | ||
function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError( | ||
"this hasn't been initialised - super() hasn't been called" | ||
); | ||
} | ||
return self; | ||
} | ||
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 _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; | ||
} | ||
@@ -54,77 +153,100 @@ function getDisplayName(WrappedComponent) { | ||
var Connect = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(Connect, _Component); | ||
/*#__PURE__*/ | ||
(function(_Component) { | ||
_inherits(Connect, _Component); | ||
function Connect(props, context) { | ||
var _this; | ||
function Connect(props, context) { | ||
var _this; | ||
_classCallCheck(this, Connect); | ||
_classCallCheck(this, Connect); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(Connect).call(this, props, context)); | ||
_this = _possibleConstructorReturn( | ||
this, | ||
_getPrototypeOf(Connect).call(this, props, context) | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleChange", function () { | ||
if (!_this.unsubscribe) { | ||
return; | ||
} | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'handleChange', | ||
function() { | ||
if (!_this.unsubscribe) { | ||
return; | ||
} | ||
var nextState = finnalMapStateToProps(_this.store.getState(), _this.props); | ||
var nextState = finnalMapStateToProps( | ||
_this.store.getState(), | ||
_this.props | ||
); | ||
if (!(0, _shallowequal.default)(_this.nextState, nextState)) { | ||
_this.nextState = nextState; | ||
if (!(0, _shallowequal.default)(_this.nextState, nextState)) { | ||
_this.nextState = nextState; | ||
_this.setState({ | ||
subscribed: nextState | ||
}); | ||
} | ||
}); | ||
_this.setState({ | ||
subscribed: nextState | ||
}); | ||
} | ||
} | ||
); | ||
_this.store = context.miniStore; | ||
_this.state = { | ||
subscribed: finnalMapStateToProps(_this.store.getState(), props) | ||
}; | ||
return _this; | ||
} | ||
_this.store = context.miniStore; | ||
_this.state = { | ||
subscribed: finnalMapStateToProps(_this.store.getState(), props) | ||
}; | ||
return _this; | ||
} | ||
_createClass(Connect, [{ | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
this.trySubscribe(); | ||
} | ||
}, { | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
this.tryUnsubscribe(); | ||
} | ||
}, { | ||
key: "trySubscribe", | ||
value: function trySubscribe() { | ||
if (shouldSubscribe) { | ||
this.unsubscribe = this.store.subscribe(this.handleChange); | ||
this.handleChange(); | ||
_createClass(Connect, [ | ||
{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.trySubscribe(); | ||
} | ||
}, | ||
{ | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
this.tryUnsubscribe(); | ||
} | ||
}, | ||
{ | ||
key: 'trySubscribe', | ||
value: function trySubscribe() { | ||
if (shouldSubscribe) { | ||
this.unsubscribe = this.store.subscribe(this.handleChange); | ||
this.handleChange(); | ||
} | ||
} | ||
}, | ||
{ | ||
key: 'tryUnsubscribe', | ||
value: function tryUnsubscribe() { | ||
if (this.unsubscribe) { | ||
this.unsubscribe(); | ||
this.unsubscribe = null; | ||
} | ||
} | ||
}, | ||
{ | ||
key: 'render', | ||
value: function render() { | ||
return (0, _react.createElement)( | ||
WrappedComponent, | ||
_objectSpread({}, this.props, this.state.subscribed, { | ||
store: this.store | ||
}) | ||
); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "tryUnsubscribe", | ||
value: function tryUnsubscribe() { | ||
if (this.unsubscribe) { | ||
this.unsubscribe(); | ||
this.unsubscribe = null; | ||
} | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
return (0, _react.createElement)(WrappedComponent, _objectSpread({}, this.props, this.state.subscribed, { | ||
store: this.store | ||
})); | ||
} | ||
}]); | ||
]); | ||
return Connect; | ||
}(_react.Component); | ||
return Connect; | ||
})(_react.Component); | ||
_defineProperty(Connect, "displayName", "Connect(".concat(getDisplayName(WrappedComponent), ")")); | ||
_defineProperty( | ||
Connect, | ||
'displayName', | ||
'Connect('.concat(getDisplayName(WrappedComponent), ')') | ||
); | ||
_defineProperty(Connect, "contextTypes", { | ||
_defineProperty(Connect, 'contextTypes', { | ||
miniStore: _PropTypes.storeShape.isRequired | ||
@@ -135,2 +257,2 @@ }); | ||
}; | ||
} | ||
} |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,5 +8,33 @@ }); | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat( | ||
Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
}) | ||
); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
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 _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; | ||
} | ||
@@ -42,2 +70,2 @@ function create(initialState) { | ||
}; | ||
} | ||
} |
@@ -1,7 +0,7 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "Provider", { | ||
Object.defineProperty(exports, 'Provider', { | ||
enumerable: true, | ||
@@ -12,3 +12,3 @@ get: function get() { | ||
}); | ||
Object.defineProperty(exports, "connect", { | ||
Object.defineProperty(exports, 'connect', { | ||
enumerable: true, | ||
@@ -19,3 +19,3 @@ get: function get() { | ||
}); | ||
Object.defineProperty(exports, "create", { | ||
Object.defineProperty(exports, 'create', { | ||
enumerable: true, | ||
@@ -27,8 +27,10 @@ get: function get() { | ||
var _Provider2 = _interopRequireDefault(require("./Provider")); | ||
var _Provider2 = _interopRequireDefault(require('./Provider')); | ||
var _connect2 = _interopRequireDefault(require("./connect")); | ||
var _connect2 = _interopRequireDefault(require('./connect')); | ||
var _create2 = _interopRequireDefault(require("./create")); | ||
var _create2 = _interopRequireDefault(require('./create')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,5 +8,7 @@ }); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _propTypes = _interopRequireDefault(require('prop-types')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
@@ -19,2 +21,2 @@ var storeShape = _propTypes.default.shape({ | ||
exports.storeShape = storeShape; | ||
exports.storeShape = storeShape; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,64 +8,172 @@ }); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react = _interopRequireWildcard(require('react')); | ||
var _PropTypes = require("./PropTypes"); | ||
var _PropTypes = require('./PropTypes'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _interopRequireWildcard(obj) { | ||
if (obj && obj.__esModule) { | ||
return obj; | ||
} else { | ||
var newObj = {}; | ||
if (obj != null) { | ||
for (var key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = | ||
Object.defineProperty && Object.getOwnPropertyDescriptor | ||
? Object.getOwnPropertyDescriptor(obj, key) | ||
: {}; | ||
if (desc.get || desc.set) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
return newObj; | ||
} | ||
} | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { | ||
if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') { | ||
_typeof = function _typeof(obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && | ||
typeof Symbol === 'function' && | ||
obj.constructor === Symbol && | ||
obj !== Symbol.prototype | ||
? 'symbol' | ||
: typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a 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); } } | ||
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); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === 'object' || typeof call === 'function')) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError( | ||
"this hasn't been initialised - super() hasn't been called" | ||
); | ||
} | ||
return self; | ||
} | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf | ||
? Object.getPrototypeOf | ||
: function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== 'function' && superClass !== null) { | ||
throw new TypeError('Super expression must either be null or a function'); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: {value: subClass, writable: true, configurable: true} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = | ||
Object.setPrototypeOf || | ||
function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
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 _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; | ||
} | ||
var Provider = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(Provider, _Component); | ||
/*#__PURE__*/ | ||
(function(_Component) { | ||
_inherits(Provider, _Component); | ||
function Provider() { | ||
_classCallCheck(this, Provider); | ||
function Provider() { | ||
_classCallCheck(this, Provider); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(Provider).apply(this, arguments)); | ||
} | ||
_createClass(Provider, [{ | ||
key: "getChildContext", | ||
value: function getChildContext() { | ||
return { | ||
miniStore: this.props.store | ||
}; | ||
return _possibleConstructorReturn( | ||
this, | ||
_getPrototypeOf(Provider).apply(this, arguments) | ||
); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
return _react.Children.only(this.props.children); | ||
} | ||
}]); | ||
return Provider; | ||
}(_react.Component); | ||
_createClass(Provider, [ | ||
{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return { | ||
miniStore: this.props.store | ||
}; | ||
} | ||
}, | ||
{ | ||
key: 'render', | ||
value: function render() { | ||
return _react.Children.only(this.props.children); | ||
} | ||
} | ||
]); | ||
return Provider; | ||
})(_react.Component); | ||
exports.default = Provider; | ||
_defineProperty(Provider, "propTypes", { | ||
_defineProperty(Provider, 'propTypes', { | ||
store: _PropTypes.storeShape.isRequired | ||
}); | ||
_defineProperty(Provider, "childContextTypes", { | ||
_defineProperty(Provider, 'childContextTypes', { | ||
miniStore: _PropTypes.storeShape.isRequired | ||
}); | ||
}); |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,21 +8,43 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _classnames = _interopRequireDefault(require('classnames')); | ||
var _Icon = _interopRequireDefault(require("./Icon")); | ||
var _Icon = _interopRequireDefault(require('./Icon')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
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 _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 Select(props) { | ||
var prefixCls = props.prefixCls, | ||
selected = props.selected, | ||
onClick = props.onClick, | ||
type = props.type, | ||
disabled = props.disabled; | ||
var cls = (0, _classnames.default)("".concat(prefixCls, "-select"), "".concat(prefixCls, "-select-").concat(type), _defineProperty({ | ||
selected: selected | ||
}, "".concat(prefixCls, "-select-disabled"), disabled)); | ||
selected = props.selected, | ||
onClick = props.onClick, | ||
type = props.type, | ||
disabled = props.disabled; | ||
var cls = (0, _classnames.default)( | ||
''.concat(prefixCls, '-select'), | ||
''.concat(prefixCls, '-select-').concat(type), | ||
_defineProperty( | ||
{ | ||
selected: selected | ||
}, | ||
''.concat(prefixCls, '-select-disabled'), | ||
disabled | ||
) | ||
); | ||
var children = null; | ||
@@ -44,12 +66,20 @@ | ||
return _react.default.createElement("div", { | ||
style: { | ||
display: 'inline-block', | ||
textAlign: 'left', | ||
verticalAlign: 'middle' | ||
return _react.default.createElement( | ||
'div', | ||
{ | ||
style: { | ||
display: 'inline-block', | ||
textAlign: 'left', | ||
verticalAlign: 'middle' | ||
}, | ||
onClick: click | ||
}, | ||
onClick: click | ||
}, _react.default.createElement("span", { | ||
className: cls | ||
}, children)); | ||
} | ||
_react.default.createElement( | ||
'span', | ||
{ | ||
className: cls | ||
}, | ||
children | ||
) | ||
); | ||
} |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,316 +8,517 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _propTypes = _interopRequireDefault(require('prop-types')); | ||
var _reactDom = require("react-dom"); | ||
var _reactDom = require('react-dom'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { | ||
if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') { | ||
_typeof = function _typeof(obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && | ||
typeof Symbol === 'function' && | ||
obj.constructor === Symbol && | ||
obj !== Symbol.prototype | ||
? 'symbol' | ||
: typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _toConsumableArray(arr) { | ||
return ( | ||
_arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread() | ||
); | ||
} | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _nonIterableSpread() { | ||
throw new TypeError('Invalid attempt to spread non-iterable instance'); | ||
} | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _iterableToArray(iter) { | ||
if ( | ||
Symbol.iterator in Object(iter) || | ||
Object.prototype.toString.call(iter) === '[object Arguments]' | ||
) | ||
return Array.from(iter); | ||
} | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { | ||
arr2[i] = arr[i]; | ||
} | ||
return arr2; | ||
} | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a 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); } } | ||
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); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === 'object' || typeof call === 'function')) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf | ||
? Object.getPrototypeOf | ||
: function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== 'function' && superClass !== null) { | ||
throw new TypeError('Super expression must either be null or a function'); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: {value: subClass, writable: true, configurable: true} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = | ||
Object.setPrototypeOf || | ||
function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError( | ||
"this hasn't been initialised - super() hasn't been called" | ||
); | ||
} | ||
return self; | ||
} | ||
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 _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; | ||
} | ||
var Children = _react.default.Children, | ||
PureComponent = _react.default.PureComponent; | ||
PureComponent = _react.default.PureComponent; | ||
var Sortable = | ||
/*#__PURE__*/ | ||
function (_PureComponent) { | ||
_inherits(Sortable, _PureComponent); | ||
/*#__PURE__*/ | ||
(function(_PureComponent) { | ||
_inherits(Sortable, _PureComponent); | ||
function Sortable(_props) { | ||
var _this; | ||
function Sortable(_props) { | ||
var _this; | ||
_classCallCheck(this, Sortable); | ||
_classCallCheck(this, Sortable); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(Sortable).call(this, _props)); | ||
_this = _possibleConstructorReturn( | ||
this, | ||
_getPrototypeOf(Sortable).call(this, _props) | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "currentEl", null); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'currentEl', | ||
null | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "cloneEl", null); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'cloneEl', | ||
null | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "parentEl", null); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'parentEl', | ||
null | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "dragAble", false); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'dragAble', | ||
false | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "offsetX", 0); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'offsetX', | ||
0 | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "currentElIndex", null); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'currentElIndex', | ||
null | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "prevEl", null); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'prevEl', | ||
null | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "nextEl", null); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'nextEl', | ||
null | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "propsToState", function () { | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props; | ||
var showIndex = []; | ||
var children = Children.map(props.children, function (child, index) { | ||
showIndex.push(index); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'propsToState', | ||
function() { | ||
var props = | ||
arguments.length > 0 && arguments[0] !== undefined | ||
? arguments[0] | ||
: _this.props; | ||
var showIndex = []; | ||
var children = Children.map(props.children, function(child, index) { | ||
showIndex.push(index); | ||
if (child.props.fixed === 'left') { | ||
_this.fixedIndex.push(index); | ||
if (child.props.fixed === 'left') { | ||
_this.fixedIndex.push(index); | ||
_this.leftFixedIndex.push(index); | ||
} | ||
_this.leftFixedIndex.push(index); | ||
} | ||
if (child.props.fixed === 'right') { | ||
_this.fixedIndex.push(index); | ||
if (child.props.fixed === 'right') { | ||
_this.fixedIndex.push(index); | ||
_this.rightFixedIndex.push(index); | ||
_this.rightFixedIndex.push(index); | ||
} | ||
return _react.default.cloneElement(child, { | ||
ref: _this.saveRef(index), | ||
onMouseDown: _this.handleMouseDown, | ||
'data-index': index | ||
}); | ||
}); | ||
_this.backIndex = showIndex; | ||
return { | ||
showIndex: showIndex, | ||
children: children | ||
}; | ||
} | ||
); | ||
return _react.default.cloneElement(child, { | ||
ref: _this.saveRef(index), | ||
onMouseDown: _this.handleMouseDown, | ||
'data-index': index | ||
}); | ||
}); | ||
_this.backIndex = showIndex; | ||
return { | ||
showIndex: showIndex, | ||
children: children | ||
}; | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'saveRef', | ||
function(index) { | ||
return function(node) { | ||
_this['child-'.concat(index)] = node; | ||
}; | ||
} | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "saveRef", function (index) { | ||
return function (node) { | ||
_this["child-".concat(index)] = node; | ||
}; | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'handleMouseMove', | ||
function(event) { | ||
if (_this.dragAble) { | ||
var left = event.pageX - _this.offsetX; | ||
left = left < 0 ? 0 : left; | ||
_this.cloneEl.style.left = ''.concat(left, 'px'); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleMouseMove", function (event) { | ||
if (_this.dragAble) { | ||
var left = event.pageX - _this.offsetX; | ||
left = left < 0 ? 0 : left; | ||
_this.cloneEl.style.left = "".concat(left, "px"); | ||
_this._swap(); | ||
} else { | ||
return event; | ||
} | ||
} | ||
); | ||
_this._swap(); | ||
} else { | ||
return event; | ||
} | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'handleMouseUp', | ||
function(event) { | ||
var _this$props = _this.props, | ||
onDrag = _this$props.onDrag, | ||
parent = _this$props.parent, | ||
columns = _this$props.columns; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleMouseUp", function (event) { | ||
var _this$props = _this.props, | ||
onDrag = _this$props.onDrag, | ||
parent = _this$props.parent, | ||
columns = _this$props.columns; | ||
if (!_this.dragAble) { | ||
return event; | ||
} | ||
if (!_this.dragAble) { | ||
return event; | ||
} | ||
_this.dragAble = false; | ||
_this.dragAble = false; | ||
if (_this.cloneEl && _this.parentEl) { | ||
_this.parentEl.removeChild(_this.cloneEl); | ||
if (_this.cloneEl && _this.parentEl) { | ||
_this.parentEl.removeChild(_this.cloneEl); | ||
_this.parentEl = null; | ||
_this.cloneEl = null; | ||
_this.currentEl.style.opacity = 1; | ||
_this.currentEl.style.background = 'transparent'; | ||
_this.currentEl = null; | ||
_this.currentElIndex = null; | ||
_this.prevEl = null; | ||
_this.nextEl = null; | ||
_this.dataCurrentIndex = null; | ||
_this.prevElIndex = null; | ||
_this.nextElIndex = null; | ||
} | ||
_this.parentEl = null; | ||
_this.cloneEl = null; | ||
_this.currentEl.style.opacity = 1; | ||
_this.currentEl.style.background = 'transparent'; | ||
_this.currentEl = null; | ||
_this.currentElIndex = null; | ||
_this.prevEl = null; | ||
_this.nextEl = null; | ||
_this.dataCurrentIndex = null; | ||
_this.prevElIndex = null; | ||
_this.nextElIndex = null; | ||
} | ||
document.body.style['user-select'] = 'text'; | ||
document.body.style['-ms-user-select'] = 'text'; | ||
document.body.style['-moz-user-select'] = 'text'; | ||
document.body.style['-webkit-user-select'] = 'text'; | ||
document.body.style['user-select'] = 'text'; | ||
document.body.style['-ms-user-select'] = 'text'; | ||
document.body.style['-moz-user-select'] = 'text'; | ||
document.body.style['-webkit-user-select'] = 'text'; | ||
var dragChange = _this.state.showIndex.some(function(index, i) { | ||
return _this.backIndex[i] !== index; | ||
}); | ||
var dragChange = _this.state.showIndex.some(function (index, i) { | ||
return _this.backIndex[i] !== index; | ||
}); | ||
if (dragChange && typeof onDrag === 'function') { | ||
onDrag( | ||
parent, | ||
_this.state.showIndex.map(function(index) { | ||
return columns[index]; | ||
}) | ||
); | ||
} | ||
} | ||
); | ||
if (dragChange && typeof onDrag === 'function') { | ||
onDrag(parent, _this.state.showIndex.map(function (index) { | ||
return columns[index]; | ||
})); | ||
} | ||
}); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'handleMouseDown', | ||
function(event) { | ||
var headerSortable = _this.context.getProps('headerSortable'); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleMouseDown", function (event) { | ||
var headerSortable = _this.context.getProps('headerSortable'); | ||
if (event.button !== 0) { | ||
return event; | ||
} | ||
if (event.button !== 0) { | ||
return event; | ||
} | ||
if (!headerSortable) { | ||
return event; | ||
} | ||
if (!headerSortable) { | ||
return event; | ||
} | ||
_this.backIndex = _this.state.showIndex; | ||
document.body.style['user-select'] = 'none'; | ||
document.body.style['-ms-user-select'] = 'none'; | ||
document.body.style['-moz-user-select'] = 'none'; | ||
document.body.style['-webkit-user-select'] = 'none'; | ||
_this.parentEl = event.currentTarget.parentNode; | ||
_this.cloneEl = event.currentTarget.cloneNode(true); | ||
_this.currentEl = event.currentTarget; | ||
_this.currentEl.style.opacity = 0; // get current index | ||
_this.backIndex = _this.state.showIndex; | ||
document.body.style['user-select'] = 'none'; | ||
document.body.style['-ms-user-select'] = 'none'; | ||
document.body.style['-moz-user-select'] = 'none'; | ||
document.body.style['-webkit-user-select'] = 'none'; | ||
_this.parentEl = event.currentTarget.parentNode; | ||
_this.cloneEl = event.currentTarget.cloneNode(true); | ||
_this.currentEl = event.currentTarget; | ||
_this.currentEl.style.opacity = 0; // get current index | ||
var index = _this.currentEl.getAttribute('data-index'); | ||
var index = _this.currentEl.getAttribute('data-index'); | ||
_this.dataCurrentIndex = Number(index); | ||
_this.dataCurrentIndex = Number(index); | ||
_this._both(); // clone current element | ||
_this._both(); // clone current element | ||
var currentRect = _this.currentEl.getBoundingClientRect(); | ||
var parentRect = _this.parentEl.getBoundingClientRect(); | ||
var currentRect = _this.currentEl.getBoundingClientRect(); | ||
_this.cloneEl.style.position = 'absolute'; | ||
_this.cloneEl.style.zIndex = 9999; | ||
_this.cloneEl.style.background = '#393939'; | ||
_this.cloneEl.style.opacity = 0.8; | ||
_this.cloneEl.style.left = ''.concat( | ||
currentRect.left - (parentRect.left > 0 ? parentRect.left : 0), | ||
'px' | ||
); | ||
_this.cloneEl.style.boxShadow = '0 0 10px rgba(0, 0, 0, .4)'; | ||
_this.offsetX = | ||
event.pageX - | ||
currentRect.left + | ||
(parentRect.left > 0 ? parentRect.left : 0); // calc left max and min | ||
var parentRect = _this.parentEl.getBoundingClientRect(); | ||
var left = 0; | ||
_this.cloneEl.style.position = 'absolute'; | ||
_this.cloneEl.style.zIndex = 9999; | ||
_this.cloneEl.style.background = '#393939'; | ||
_this.cloneEl.style.opacity = 0.8; | ||
_this.cloneEl.style.left = "".concat(currentRect.left - (parentRect.left > 0 ? parentRect.left : 0), "px"); | ||
_this.cloneEl.style.boxShadow = '0 0 10px rgba(0, 0, 0, .4)'; | ||
_this.offsetX = event.pageX - currentRect.left + (parentRect.left > 0 ? parentRect.left : 0); // calc left max and min | ||
if (_this.leftFixedIndex > 0) { | ||
_this.leftFixedIndex.forEach(function(i) { | ||
var ele = (0, _reactDom.findDOMNode)( | ||
_this['child-'.concat(i)] | ||
).getBoundingClientRect(); | ||
left = left > ele.left + ele.width ? left : ele.left + ele.width; | ||
}); | ||
} | ||
var left = 0; | ||
_this.parentEl.appendChild(_this.cloneEl); | ||
if (_this.leftFixedIndex > 0) { | ||
_this.leftFixedIndex.forEach(function (i) { | ||
var ele = (0, _reactDom.findDOMNode)(_this["child-".concat(i)]).getBoundingClientRect(); | ||
left = left > ele.left + ele.width ? left : ele.left + ele.width; | ||
}); | ||
} | ||
_this.dragAble = true; | ||
event.stopPropagation(); | ||
} | ||
); | ||
_this.parentEl.appendChild(_this.cloneEl); | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_swap', | ||
function() { | ||
var cloneRect = _this.cloneEl.getBoundingClientRect(); | ||
_this.dragAble = true; | ||
event.stopPropagation(); | ||
}); | ||
var nextRect, prevRect; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_swap", function () { | ||
var cloneRect = _this.cloneEl.getBoundingClientRect(); | ||
if (_this.nextEl) { | ||
nextRect = _this.nextEl.getBoundingClientRect(); | ||
var nextRect, prevRect; | ||
if ( | ||
cloneRect.left + cloneRect.width > | ||
nextRect.left + nextRect.width / 2 | ||
) { | ||
// next swap | ||
var showIndex = _toConsumableArray(_this.state.showIndex); | ||
if (_this.nextEl) { | ||
nextRect = _this.nextEl.getBoundingClientRect(); | ||
var temp = showIndex[_this.currentElIndex]; | ||
showIndex[_this.currentElIndex] = showIndex[_this.nextElIndex]; | ||
showIndex[_this.nextElIndex] = temp; | ||
if (cloneRect.left + cloneRect.width > nextRect.left + nextRect.width / 2) { | ||
// next swap | ||
var showIndex = _toConsumableArray(_this.state.showIndex); | ||
_this.setState( | ||
{ | ||
showIndex: showIndex | ||
}, | ||
_this._both | ||
); | ||
} | ||
} | ||
var temp = showIndex[_this.currentElIndex]; | ||
showIndex[_this.currentElIndex] = showIndex[_this.nextElIndex]; | ||
showIndex[_this.nextElIndex] = temp; | ||
if (_this.prevEl) { | ||
prevRect = _this.prevEl.getBoundingClientRect(); | ||
_this.setState({ | ||
showIndex: showIndex | ||
}, _this._both); | ||
} | ||
} | ||
if (cloneRect.left < prevRect.left + prevRect.width / 2) { | ||
// prev swap | ||
var _showIndex = _toConsumableArray(_this.state.showIndex); | ||
if (_this.prevEl) { | ||
prevRect = _this.prevEl.getBoundingClientRect(); | ||
var _temp = _showIndex[_this.currentElIndex]; | ||
_showIndex[_this.currentElIndex] = _showIndex[_this.prevElIndex]; | ||
_showIndex[_this.prevElIndex] = _temp; | ||
if (cloneRect.left < prevRect.left + prevRect.width / 2) { | ||
// prev swap | ||
var _showIndex = _toConsumableArray(_this.state.showIndex); | ||
var _temp = _showIndex[_this.currentElIndex]; | ||
_showIndex[_this.currentElIndex] = _showIndex[_this.prevElIndex]; | ||
_showIndex[_this.prevElIndex] = _temp; | ||
_this.setState({ | ||
showIndex: _showIndex | ||
}, _this._both); | ||
_this.setState( | ||
{ | ||
showIndex: _showIndex | ||
}, | ||
_this._both | ||
); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_both", function () { | ||
var showIndex = _this.state.showIndex; | ||
_this.currentElIndex = showIndex.indexOf(_this.dataCurrentIndex); | ||
_this.prevElIndex = _this.currentElIndex - 1; | ||
_this.nextElIndex = _this.currentElIndex + 1; | ||
_this.prevEl = null; | ||
_this.nextEl = null; | ||
_defineProperty( | ||
_assertThisInitialized(_assertThisInitialized(_this)), | ||
'_both', | ||
function() { | ||
var showIndex = _this.state.showIndex; | ||
_this.currentElIndex = showIndex.indexOf(_this.dataCurrentIndex); | ||
_this.prevElIndex = _this.currentElIndex - 1; | ||
_this.nextElIndex = _this.currentElIndex + 1; | ||
_this.prevEl = null; | ||
_this.nextEl = null; | ||
if (_this.prevElIndex >= 0 && (_this.fixedIndex.length === 0 || !_this.fixedIndex.some(function (i) { | ||
return i === _this.prevElIndex; | ||
}))) { | ||
// enable drag prev | ||
_this.prevEl = (0, _reactDom.findDOMNode)(_this["child-".concat(showIndex[_this.prevElIndex])]); | ||
} | ||
if ( | ||
_this.prevElIndex >= 0 && | ||
(_this.fixedIndex.length === 0 || | ||
!_this.fixedIndex.some(function(i) { | ||
return i === _this.prevElIndex; | ||
})) | ||
) { | ||
// enable drag prev | ||
_this.prevEl = (0, _reactDom.findDOMNode)( | ||
_this['child-'.concat(showIndex[_this.prevElIndex])] | ||
); | ||
} | ||
if (_this.nextElIndex < showIndex.length && (_this.fixedIndex.length === 0 || !_this.fixedIndex.some(function (i) { | ||
return i === _this.nextElIndex; | ||
}))) { | ||
//enable drag next | ||
_this.nextEl = (0, _reactDom.findDOMNode)(_this["child-".concat(showIndex[_this.nextElIndex])]); | ||
} | ||
}); | ||
if ( | ||
_this.nextElIndex < showIndex.length && | ||
(_this.fixedIndex.length === 0 || | ||
!_this.fixedIndex.some(function(i) { | ||
return i === _this.nextElIndex; | ||
})) | ||
) { | ||
//enable drag next | ||
_this.nextEl = (0, _reactDom.findDOMNode)( | ||
_this['child-'.concat(showIndex[_this.nextElIndex])] | ||
); | ||
} | ||
} | ||
); | ||
_this.fixedIndex = []; | ||
_this.leftFixedIndex = []; | ||
_this.rightFixedIndex = []; | ||
_this.state = _this.propsToState(); | ||
return _this; | ||
} | ||
_this.fixedIndex = []; | ||
_this.leftFixedIndex = []; | ||
_this.rightFixedIndex = []; | ||
_this.state = _this.propsToState(); | ||
return _this; | ||
} | ||
_createClass(Sortable, [{ | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
document.addEventListener('mousemove', this.handleMouseMove); | ||
document.addEventListener('mouseup', this.handleMouseUp); | ||
} | ||
}, { | ||
key: "componentWillReceiveProps", | ||
value: function componentWillReceiveProps(nextProps) { | ||
if (nextProps.children !== this.props.children) { | ||
this.setState(this.propsToState(nextProps)); | ||
_createClass(Sortable, [ | ||
{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
document.addEventListener('mousemove', this.handleMouseMove); | ||
document.addEventListener('mouseup', this.handleMouseUp); | ||
} | ||
}, | ||
{ | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
if (nextProps.children !== this.props.children) { | ||
this.setState(this.propsToState(nextProps)); | ||
} | ||
} | ||
}, | ||
{ | ||
key: 'render', | ||
value: function render() { | ||
var _this$state = this.state, | ||
showIndex = _this$state.showIndex, | ||
children = _this$state.children; | ||
return showIndex.map(function(i) { | ||
return children[i]; | ||
}); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _this$state = this.state, | ||
showIndex = _this$state.showIndex, | ||
children = _this$state.children; | ||
return showIndex.map(function (i) { | ||
return children[i]; | ||
}); | ||
} | ||
}]); | ||
]); | ||
return Sortable; | ||
}(PureComponent); | ||
return Sortable; | ||
})(PureComponent); | ||
_defineProperty(Sortable, "contextTypes", { | ||
_defineProperty(Sortable, 'contextTypes', { | ||
props: _propTypes.default.object, | ||
@@ -329,2 +530,2 @@ updateScrollLeft: _propTypes.default.func, | ||
var _default = Sortable; | ||
exports.default = _default; | ||
exports.default = _default; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,7 +8,9 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _classnames = _interopRequireDefault(require('classnames')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
@@ -22,4 +24,4 @@ var Order = { | ||
var onSort = props.onSort, | ||
dataIndex = props.dataIndex, | ||
prefixCls = props.prefixCls; | ||
dataIndex = props.dataIndex, | ||
prefixCls = props.prefixCls; | ||
var order = props.order; | ||
@@ -31,6 +33,8 @@ | ||
var path = 'M556.8 876.8l134.4-134.4c25.6-25.6 25.6-64 0-89.6-25.6-25.6-64-25.6-89.6 0L576 678.4 576 192c0-38.4-25.6-64-64-64S448 153.6 448 192l0 486.4-25.6-25.6c-25.6-25.6-64-25.6-89.6 0-25.6 25.6-25.6 64 0 89.6l134.4 134.4C492.8 902.4 531.2 902.4 556.8 876.8z'; | ||
var path = | ||
'M556.8 876.8l134.4-134.4c25.6-25.6 25.6-64 0-89.6-25.6-25.6-64-25.6-89.6 0L576 678.4 576 192c0-38.4-25.6-64-64-64S448 153.6 448 192l0 486.4-25.6-25.6c-25.6-25.6-64-25.6-89.6 0-25.6 25.6-25.6 64 0 89.6l134.4 134.4C492.8 902.4 531.2 902.4 556.8 876.8z'; | ||
if (order === 'asc') { | ||
path = 'M467.2 147.2 332.8 281.6c-25.6 25.6-25.6 64 0 89.6 25.6 25.6 64 25.6 89.6 0L448 345.6 448 832c0 38.4 25.6 64 64 64s64-25.6 64-64L576 345.6l25.6 25.6c25.6 25.6 64 25.6 89.6 0 25.6-25.6 25.6-64 0-89.6L556.8 147.2C531.2 121.6 492.8 121.6 467.2 147.2z'; | ||
path = | ||
'M467.2 147.2 332.8 281.6c-25.6 25.6-25.6 64 0 89.6 25.6 25.6 64 25.6 89.6 0L448 345.6 448 832c0 38.4 25.6 64 64 64s64-25.6 64-64L576 345.6l25.6 25.6c25.6 25.6 64 25.6 89.6 0 25.6-25.6 25.6-64 0-89.6L556.8 147.2C531.2 121.6 492.8 121.6 467.2 147.2z'; | ||
} | ||
@@ -46,24 +50,32 @@ | ||
var wrapperCls = "".concat(prefixCls, "-sorter"); | ||
return _react.default.createElement("div", { | ||
className: wrapperCls, | ||
onClick: onClick | ||
}, _react.default.createElement("svg", { | ||
viewBox: "64 64 896 896", | ||
className: "", | ||
"data-icon": "plus", | ||
width: "1em", | ||
height: "1em", | ||
fill: "currentColor", | ||
"aria-hidden": "true", | ||
focusable: "false", | ||
style: { | ||
display: 'inline-block' | ||
} | ||
}, _react.default.createElement("path", { | ||
d: path | ||
}))); | ||
var wrapperCls = ''.concat(prefixCls, '-sorter'); | ||
return _react.default.createElement( | ||
'div', | ||
{ | ||
className: wrapperCls, | ||
onClick: onClick | ||
}, | ||
_react.default.createElement( | ||
'svg', | ||
{ | ||
viewBox: '64 64 896 896', | ||
className: '', | ||
'data-icon': 'plus', | ||
width: '1em', | ||
height: '1em', | ||
fill: 'currentColor', | ||
'aria-hidden': 'true', | ||
focusable: 'false', | ||
style: { | ||
display: 'inline-block' | ||
} | ||
}, | ||
_react.default.createElement('path', { | ||
d: path | ||
}) | ||
) | ||
); | ||
} | ||
var _default = Sorter; | ||
exports.default = _default; | ||
exports.default = _default; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,15 +8,17 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _classnames = _interopRequireDefault(require('classnames')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function Cell(props) { | ||
var className = props.className, | ||
ExpandedIcon = props.ExpandedIcon, | ||
SelectIcon = props.SelectIcon, | ||
style = props.style, | ||
children = props.children, | ||
key = props.key; | ||
ExpandedIcon = props.ExpandedIcon, | ||
SelectIcon = props.SelectIcon, | ||
style = props.style, | ||
children = props.children, | ||
key = props.key; | ||
var newProps = { | ||
@@ -27,6 +29,12 @@ key: key, | ||
}; | ||
return _react.default.createElement("div", newProps, SelectIcon, ExpandedIcon, children); | ||
return _react.default.createElement( | ||
'div', | ||
newProps, | ||
SelectIcon, | ||
ExpandedIcon, | ||
children | ||
); | ||
} | ||
var _default = Cell; | ||
exports.default = _default; | ||
exports.default = _default; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,23 +8,25 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _HeadCell = _interopRequireDefault(require("./HeadCell")); | ||
var _HeadCell = _interopRequireDefault(require('./HeadCell')); | ||
var _Sortable = _interopRequireDefault(require("./Sortable")); | ||
var _Sortable = _interopRequireDefault(require('./Sortable')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
function TableHeader(props) { | ||
var columns = props.columns, | ||
orders = props.orders, | ||
onSort = props.onSort, | ||
fixed = props.fixed, | ||
headerRowHeight = props.headerRowHeight, | ||
prefixCls = props.prefixCls, | ||
onHeaderRow = props.onHeaderRow, | ||
onDrag = props.onDrag, | ||
SelectIcon = props.SelectIcon; | ||
var children = columns.map(function (column, index) { | ||
orders = props.orders, | ||
onSort = props.onSort, | ||
fixed = props.fixed, | ||
headerRowHeight = props.headerRowHeight, | ||
prefixCls = props.prefixCls, | ||
onHeaderRow = props.onHeaderRow, | ||
onDrag = props.onDrag, | ||
SelectIcon = props.SelectIcon; | ||
var children = columns.map(function(column, index) { | ||
return (0, _HeadCell.default)({ | ||
key: "HeadCol".concat(index), | ||
key: 'HeadCol'.concat(index), | ||
column: column, | ||
@@ -38,3 +40,4 @@ prefixCls: prefixCls, | ||
onDrag: onDrag, | ||
SelectIcon: index === 0 && fixed !== 'right' && SelectIcon ? SelectIcon : null | ||
SelectIcon: | ||
index === 0 && fixed !== 'right' && SelectIcon ? SelectIcon : null | ||
}); | ||
@@ -44,16 +47,28 @@ }); | ||
if (!fixed) { | ||
children = _react.default.createElement(_Sortable.default, { | ||
columns: columns, | ||
onDrag: onDrag | ||
}, children); | ||
children = _react.default.createElement( | ||
_Sortable.default, | ||
{ | ||
columns: columns, | ||
onDrag: onDrag | ||
}, | ||
children | ||
); | ||
} | ||
return _react.default.createElement("div", { | ||
className: "thead" | ||
}, _react.default.createElement("div", { | ||
className: "tr" | ||
}, children)); | ||
return _react.default.createElement( | ||
'div', | ||
{ | ||
className: 'thead' | ||
}, | ||
_react.default.createElement( | ||
'div', | ||
{ | ||
className: 'tr' | ||
}, | ||
children | ||
) | ||
); | ||
} | ||
var _default = TableHeader; | ||
exports.default = _default; | ||
exports.default = _default; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,20 +8,37 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _classnames = _interopRequireDefault(require('classnames')); | ||
var _types = require("./types"); | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
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 _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 Row(props) { | ||
var prefixCls = props.prefixCls, | ||
hovered = props.hovered, | ||
children = props.children, | ||
style = props.style, | ||
record = props.record, | ||
key = props.key; | ||
var rowClass = (0, _classnames.default)(record[_types.DS._rowClassName], _defineProperty({}, "".concat(prefixCls, "-hover"), hovered)); | ||
hovered = props.hovered, | ||
children = props.children, | ||
style = props.style, | ||
record = props.record, | ||
key = props.key; | ||
var rowClass = (0, _classnames.default)( | ||
record[_types.DS._rowClassName], | ||
_defineProperty({}, ''.concat(prefixCls, '-hover'), hovered) | ||
); | ||
var newProps = { | ||
@@ -34,3 +51,3 @@ key: key, | ||
_types.rowEvents.forEach(function (event) { | ||
_types.rowEvents.forEach(function(event) { | ||
if (typeof props[event] === 'function') { | ||
@@ -41,6 +58,6 @@ newProps[event] = props[event]; | ||
return _react.default.createElement("div", newProps, children); | ||
return _react.default.createElement('div', newProps, children); | ||
} | ||
var _default = Row; | ||
exports.default = _default; | ||
exports.default = _default; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -8,5 +8,7 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
@@ -121,3 +123,13 @@ function defaultFunction() { | ||
exports.DS = DS; | ||
var rowEvents = ['onMouseEnter', 'onMouseLeave', 'onClick', 'onDoubleClick', 'onBlur', 'onFocus', 'onAnimationStart', 'onAnimationEnd', 'onTransitionEnd']; | ||
var rowEvents = [ | ||
'onMouseEnter', | ||
'onMouseLeave', | ||
'onClick', | ||
'onDoubleClick', | ||
'onBlur', | ||
'onFocus', | ||
'onAnimationStart', | ||
'onAnimationEnd', | ||
'onTransitionEnd' | ||
]; | ||
exports.rowEvents = rowEvents; | ||
@@ -135,2 +147,2 @@ var eventsMap = { | ||
}; | ||
exports.eventsMap = eventsMap; | ||
exports.eventsMap = eventsMap; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -22,24 +22,32 @@ }); | ||
if (!attachEvent) { | ||
var requestFrame = function () { | ||
var raf = _window.requestAnimationFrame || _window.mozRequestAnimationFrame || _window.webkitRequestAnimationFrame || function (fn) { | ||
return _window.setTimeout(fn, 20); | ||
}; | ||
var requestFrame = (function() { | ||
var raf = | ||
_window.requestAnimationFrame || | ||
_window.mozRequestAnimationFrame || | ||
_window.webkitRequestAnimationFrame || | ||
function(fn) { | ||
return _window.setTimeout(fn, 20); | ||
}; | ||
return function (fn) { | ||
return function(fn) { | ||
return raf(fn); | ||
}; | ||
}(); | ||
})(); | ||
var cancelFrame = function () { | ||
var cancel = _window.cancelAnimationFrame || _window.mozCancelAnimationFrame || _window.webkitCancelAnimationFrame || _window.clearTimeout; | ||
return function (id) { | ||
var cancelFrame = (function() { | ||
var cancel = | ||
_window.cancelAnimationFrame || | ||
_window.mozCancelAnimationFrame || | ||
_window.webkitCancelAnimationFrame || | ||
_window.clearTimeout; | ||
return function(id) { | ||
return cancel(id); | ||
}; | ||
}(); | ||
})(); | ||
var resetTriggers = function resetTriggers(element) { | ||
var triggers = element.__resizeTriggers__, | ||
expand = triggers.firstElementChild, | ||
contract = triggers.lastElementChild, | ||
expandChild = expand.firstElementChild; | ||
expand = triggers.firstElementChild, | ||
contract = triggers.lastElementChild, | ||
expandChild = expand.firstElementChild; | ||
contract.scrollLeft = contract.scrollWidth; | ||
@@ -54,3 +62,6 @@ contract.scrollTop = contract.scrollHeight; | ||
var checkTriggers = function checkTriggers(element) { | ||
return element.offsetWidth != element.__resizeLast__.width || element.offsetHeight != element.__resizeLast__.height; | ||
return ( | ||
element.offsetWidth != element.__resizeLast__.width || | ||
element.offsetHeight != element.__resizeLast__.height | ||
); | ||
}; | ||
@@ -60,3 +71,6 @@ | ||
// Don't measure (which forces) reflow for scrolls that happen inside of children! | ||
if (e.target.className.indexOf('contract-trigger') < 0 && e.target.className.indexOf('expand-trigger') < 0) { | ||
if ( | ||
e.target.className.indexOf('contract-trigger') < 0 && | ||
e.target.className.indexOf('expand-trigger') < 0 | ||
) { | ||
return; | ||
@@ -72,3 +86,3 @@ } | ||
this.__resizeRAF__ = requestFrame(function () { | ||
this.__resizeRAF__ = requestFrame(function() { | ||
if (checkTriggers(element)) { | ||
@@ -78,3 +92,3 @@ element.__resizeLast__.width = element.offsetWidth; | ||
element.__resizeListeners__.forEach(function (fn) { | ||
element.__resizeListeners__.forEach(function(fn) { | ||
fn.call(element, e); | ||
@@ -87,9 +101,10 @@ }); | ||
var animation = false, | ||
keyframeprefix = '', | ||
animationstartevent = 'animationstart', | ||
domPrefixes = 'Webkit Moz O ms'.split(' '), | ||
startEvents = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(' '), | ||
pfx = ''; | ||
keyframeprefix = '', | ||
animationstartevent = 'animationstart', | ||
domPrefixes = 'Webkit Moz O ms'.split(' '), | ||
startEvents = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split( | ||
' ' | ||
), | ||
pfx = ''; | ||
{ | ||
@@ -115,4 +130,10 @@ var elm = document.createElement('fakeelement'); | ||
var animationName = 'resizeanim'; | ||
var animationKeyframes = '@' + keyframeprefix + 'keyframes ' + animationName + ' { from { opacity: 0; } to { opacity: 0; } } '; | ||
var animationStyle = keyframeprefix + 'animation: 1ms ' + animationName + '; '; | ||
var animationKeyframes = | ||
'@' + | ||
keyframeprefix + | ||
'keyframes ' + | ||
animationName + | ||
' { from { opacity: 0; } to { opacity: 0; } } '; | ||
var animationStyle = | ||
keyframeprefix + 'animation: 1ms ' + animationName + '; '; | ||
} | ||
@@ -123,5 +144,10 @@ | ||
//opacity:0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360 | ||
var css = (animationKeyframes ? animationKeyframes : '') + '.resize-triggers { ' + (animationStyle ? animationStyle : '') + 'visibility: hidden; opacity: 0; } ' + '.resize-triggers, .resize-triggers > div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; z-index: -1; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }', | ||
head = doc.head || doc.getElementsByTagName('head')[0], | ||
style = doc.createElement('style'); | ||
var css = | ||
(animationKeyframes ? animationKeyframes : '') + | ||
'.resize-triggers { ' + | ||
(animationStyle ? animationStyle : '') + | ||
'visibility: hidden; opacity: 0; } ' + | ||
'.resize-triggers, .resize-triggers > div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; z-index: -1; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }', | ||
head = doc.head || doc.getElementsByTagName('head')[0], | ||
style = doc.createElement('style'); | ||
style.id = 'detectElementResize'; | ||
@@ -160,4 +186,7 @@ style.type = 'text/css'; | ||
element.__resizeListeners__ = []; | ||
(element.__resizeTriggers__ = doc.createElement('div')).className = 'resize-triggers'; | ||
element.__resizeTriggers__.innerHTML = '<div class="expand-trigger"><div></div></div>' + '<div class="contract-trigger"></div>'; | ||
(element.__resizeTriggers__ = doc.createElement('div')).className = | ||
'resize-triggers'; | ||
element.__resizeTriggers__.innerHTML = | ||
'<div class="expand-trigger"><div></div></div>' + | ||
'<div class="contract-trigger"></div>'; | ||
element.appendChild(element.__resizeTriggers__); | ||
@@ -169,3 +198,5 @@ resetTriggers(element); | ||
if (animationstartevent) { | ||
element.__resizeTriggers__.__animationListener__ = function animationListener(e) { | ||
element.__resizeTriggers__.__animationListener__ = function animationListener( | ||
e | ||
) { | ||
if (e.animationName == animationName) { | ||
@@ -176,3 +207,6 @@ resetTriggers(element); | ||
element.__resizeTriggers__.addEventListener(animationstartevent, element.__resizeTriggers__.__animationListener__); | ||
element.__resizeTriggers__.addEventListener( | ||
animationstartevent, | ||
element.__resizeTriggers__.__animationListener__ | ||
); | ||
} | ||
@@ -189,3 +223,6 @@ } | ||
} else { | ||
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1); | ||
element.__resizeListeners__.splice( | ||
element.__resizeListeners__.indexOf(fn), | ||
1 | ||
); | ||
@@ -196,3 +233,6 @@ if (!element.__resizeListeners__.length) { | ||
if (element.__resizeTriggers__.__animationListener__) { | ||
element.__resizeTriggers__.removeEventListener(animationstartevent, element.__resizeTriggers__.__animationListener__); | ||
element.__resizeTriggers__.removeEventListener( | ||
animationstartevent, | ||
element.__resizeTriggers__.__animationListener__ | ||
); | ||
@@ -203,4 +243,7 @@ element.__resizeTriggers__.__animationListener__ = null; | ||
try { | ||
element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__); | ||
} catch (e) {// Preact compat; see developit/preact-compat/issues/228 | ||
element.__resizeTriggers__ = !element.removeChild( | ||
element.__resizeTriggers__ | ||
); | ||
} catch (e) { | ||
// Preact compat; see developit/preact-compat/issues/228 | ||
} | ||
@@ -215,2 +258,2 @@ } | ||
}; | ||
} | ||
} |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
@@ -12,5 +12,7 @@ }); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireDefault(require('react')); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
@@ -28,3 +30,6 @@ var scrollbarSize; | ||
function measureScrollbar() { | ||
var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'vertical'; | ||
var direction = | ||
arguments.length > 0 && arguments[0] !== undefined | ||
? arguments[0] | ||
: 'vertical'; | ||
@@ -44,3 +49,3 @@ if (typeof document === 'undefined' || typeof window === 'undefined') { | ||
var scrollDiv = document.createElement('div'); | ||
Object.keys(scrollbarMeasure).forEach(function (scrollProp) { | ||
Object.keys(scrollbarMeasure).forEach(function(scrollProp) { | ||
scrollDiv.style[scrollProp] = scrollbarMeasure[scrollProp]; | ||
@@ -96,3 +101,7 @@ }); // Append related overflow style | ||
function isInvalidRenderCellText(text) { | ||
return text && !_react.default.isValidElement(text) && Object.prototype.toString.call(text) === '[object Object]'; | ||
return ( | ||
text && | ||
!_react.default.isValidElement(text) && | ||
Object.prototype.toString.call(text) === '[object Object]' | ||
); | ||
} | ||
@@ -106,2 +115,2 @@ | ||
return Object.keys(obj || {}) || []; | ||
} | ||
} |
{ | ||
"name": "fast-table", | ||
"version": "1.4.8-beta.23", | ||
"version": "1.4.8-beta.24", | ||
"description": "react table fast", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -75,3 +75,3 @@ import React from 'react'; | ||
if (typeof onSort === 'function') { | ||
onSort(orders, order); | ||
onSort(orders, key, order); | ||
} | ||
@@ -78,0 +78,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
288093
8824