fix: build

This commit is contained in:
gx 2021-06-01 15:28:29 +08:00
parent 0c824495a1
commit 598e883c9c
3 changed files with 46 additions and 26 deletions

View File

@ -508,8 +508,12 @@ var _initialiseProps = function _initialiseProps() {
return _this3.moveTo('left');
};
this.moveToRight = function (insertIndex) {
return _this3.moveTo('right', insertIndex);
this.moveToRight = function () {
return _this3.moveTo('right');
};
this.multiMoveToRight = function (insertIndex) {
_this3.moveTo('right', insertIndex);
};
this.handleSelectAll = function (direction, filteredDataSource, checkAll) {
@ -645,7 +649,7 @@ var _initialiseProps = function _initialiseProps() {
} else {
// case5从左往右拖拽添加已选
if (_this3.state.sourceSelectedKeys.length > 1) {
return _this3.moveToRight(destination.index);
return _this3.multiMoveToRight(destination.index);
}
var _result = (0, _utils.move)( // 一次移动的方法
_this3.getList(source.droppableId), _this3.getList(destination.droppableId), source, destination, targetKeys);

View File

@ -87,9 +87,9 @@ var TransferList = function (_React$Component) {
_initialiseProps.call(_this);
var pagination = props.pagination,
dataSource = props.dataSource;
var pagination = props.pagination;
var dataSource = _this.handleFilterDataSource();
var totalPages = Math.ceil(dataSource.length / 10);
var paginationInfo = pagination ? {
currentPage: 1,
@ -97,7 +97,8 @@ var TransferList = function (_React$Component) {
} : {};
_this.state = {
mounted: false,
paginationInfo: paginationInfo
paginationInfo: paginationInfo,
dataSource: dataSource
};
return _this;
}
@ -112,21 +113,25 @@ var TransferList = function (_React$Component) {
}, 0);
};
TransferList.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
var paginationInfo = prevState.paginationInfo;
var pagination = nextProps.pagination,
dataSource = nextProps.dataSource;
TransferList.prototype.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
var paginationInfo = this.state.paginationInfo;
var pagination = nextProps.pagination;
var dataSource = this.handleFilterDataSource(nextProps);
if (pagination) {
var totalPages = Math.ceil(dataSource.length / 10);
var currentPage = paginationInfo.currentPage;
console.log('walieva', currentPage, totalPages);
return {
this.setState({
dataSource: dataSource,
paginationInfo: {
totalPages: totalPages === 0 ? 1 : totalPages,
currentPage: totalPages === 0 ? 1 : currentPage && totalPages && totalPages < currentPage ? totalPages : currentPage // 在最后一页移除元素之后,当前页设置为最后一页
}
};
});
} else {
this.setState({
dataSource: dataSource
});
}
return {};
};
@ -201,7 +206,6 @@ var TransferList = function (_React$Component) {
var _props = this.props,
prefixCls = _props.prefixCls,
dataSource = _props.dataSource,
titleText = _props.titleText,
filter = _props.filter,
checkedKeys = _props.checkedKeys,
@ -227,13 +231,14 @@ var TransferList = function (_React$Component) {
// Custom Layout
var paginationInfo = this.state.paginationInfo;
var _state = this.state,
paginationInfo = _state.paginationInfo,
dataSource = _state.dataSource;
var footerDom = footer((0, _objectAssign2["default"])({}, this.props));
var bodyDom = body((0, _objectAssign2["default"])({}, this.props));
var listCls = (0, _classnames2["default"])(prefixCls, (_classNames2 = {}, _defineProperty(_classNames2, prefixCls + '-with-footer', !!footerDom), _defineProperty(_classNames2, prefixCls + '-draggable', !!draggable), _defineProperty(_classNames2, prefixCls + '-with-pagination', !!pagination), _classNames2));
var filteredDataSource = [];
var totalDataSource = pagination ? dataSource : [];
var splitedDataSource = !pagination ? dataSource.concat() : dataSource.slice(10 * (paginationInfo.currentPage - 1), 10 * paginationInfo.currentPage);
@ -251,11 +256,9 @@ var TransferList = function (_React$Component) {
renderedText = _renderItem.renderedText,
renderedEl = _renderItem.renderedEl;
if (filter && filter.trim() && !_this4.matchFilter(renderedText, item)) {
return null;
}
// all show items
if (!pagination) {
totalDataSource.push(item);
}
@ -428,13 +431,9 @@ var TransferList = function (_React$Component) {
var _initialiseProps = function _initialiseProps() {
var _this5 = this;
this.matchFilter = function (text, item) {
this.matchFilter = function (text, item, filter, filterOption) {
//filter搜索框中的内容
//filterOption用户自定义的搜索过滤方法
var _props3 = _this5.props,
filter = _props3.filter,
filterOption = _props3.filterOption;
if (filterOption) {
return filterOption(filter, item);
}
@ -581,6 +580,23 @@ var _initialiseProps = function _initialiseProps() {
)
);
};
this.handleFilterDataSource = function (nextProps) {
var _ref2 = nextProps || _this5.props,
dataSource = _ref2.dataSource,
filter = _ref2.filter,
filterOption = _ref2.filterOption;
return dataSource.filter(function (data) {
var _renderItem2 = _this5.renderItem(data),
renderedText = _renderItem2.renderedText;
if (filter && filter.trim() && !_this5.matchFilter(renderedText, data, filter, filterOption)) {
return false;
}
return true;
});
};
};
TransferList.defaultProps = defaultProps;

View File

@ -1,6 +1,6 @@
{
"name": "bee-transfer",
"version": "2.0.21-beta.1",
"version": "2.0.21-beta.2",
"description": "Transfer ui component for react",
"keywords": [
"react",