publish 1.2.8

This commit is contained in:
jonyshi 2018-07-06 14:33:29 +08:00
parent 2023d05bdc
commit d58a2cabc1
10 changed files with 225 additions and 223 deletions

View File

@ -34,9 +34,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
*/
function dragColumn(Table) {
var _class, _temp, _initialiseProps;
return _temp = _class = function (_Component) {
return function (_Component) {
_inherits(DragColumn, _Component);
function DragColumn(props) {
@ -44,17 +43,96 @@ function dragColumn(Table) {
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
_initialiseProps.call(_this);
_this.setColumOrderByIndex = function (_column) {
_column.forEach(function (da, i) {
da.dragIndex = i;
da.drgHover = false;
});
return _column;
};
var columns = props.columns;
_this.onDragStart = function (event, data) {
if (_this.props.onDragStart) {
_this.props.onDragStart(event, data);
}
};
_this.setColumOrderByIndex(columns);
_this.onDragOver = function (event, data) {
if (_this.props.onDragOver) {
_this.props.onDragOver(event, data);
}
};
_this.onDragEnter = function (event, data) {
if (data.key == "checkbox") return;
var _columns = _this.state.columns;
var columns = [];
_extends(columns, _columns);
columns.forEach(function (da) {
return da.drgHover = false;
});
var current = columns.find(function (da) {
return da.key == data.key;
});
if (current.fixed) return;
current.drgHover = true;
_this.setState({
columns: columns
});
if (_this.props.onDragEnter) {
_this.props.onDragEnter(event, data);
}
};
_this.onDrop = function (event, data) {
if (data.key == "checkbox") return;
var columns = _this.state.columns;
var id = event.dataTransfer.getData("Text");
var objIndex = columns.findIndex(function (_da, i) {
return _da.key == id;
});
var targetIndex = columns.findIndex(function (_da, i) {
return _da.key == data.key;
});
if (columns[objIndex].fixed) return; //固定列不让拖拽
if (columns[targetIndex].fixed) return; //固定列不让拖拽
columns.forEach(function (da, i) {
da.drgHover = false;
if (da.key == id) {
//obj
da.dragIndex = targetIndex;
}
if (da.key == data.key) {
//targetObj
da.dragIndex = objIndex;
}
});
var _columns = columns.sort((0, _util.compare)('dragIndex'));
_this.setState({
columns: JSON.parse(JSON.stringify(_columns))
});
if (_this.props.onDrop) {
_this.props.onDrop(event, data);
}
};
_this.getTarget = function (evt) {
return evt.target || evt.srcElement;
};
_this.state = {
columns: _this.setColumOrderByIndex(props.columns)
};
return _this;
}
DragColumn.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (nextProps.columns != this.props.columns) {
this.setColumOrderByIndex(nextProps.columns);
this.setState({
columns: this.setColumOrderByIndex(nextProps.columns)
});
}
};
@ -88,89 +166,6 @@ function dragColumn(Table) {
};
return DragColumn;
}(_react.Component), _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.setColumOrderByIndex = function (_column) {
_column.forEach(function (da, i) {
da.dragIndex = i;
da.drgHover = false;
});
_this2.state = {
columns: _column
};
};
this.onDragStart = function (event, data) {
if (_this2.props.onDragStart) {
_this2.props.onDragStart(event, data);
}
};
this.onDragOver = function (event, data) {
if (_this2.props.onDragOver) {
_this2.props.onDragOver(event, data);
}
};
this.onDragEnter = function (event, data) {
if (data.key == "checkbox") return;
var _columns = _this2.state.columns;
var columns = [];
_extends(columns, _columns);
columns.forEach(function (da) {
return da.drgHover = false;
});
var current = columns.find(function (da) {
return da.key == data.key;
});
if (current.fixed) return;
current.drgHover = true;
_this2.setState({
columns: columns
});
if (_this2.props.onDragEnter) {
_this2.props.onDragEnter(event, data);
}
};
this.onDrop = function (event, data) {
if (data.key == "checkbox") return;
var columns = _this2.state.columns;
var id = event.dataTransfer.getData("Text");
var objIndex = columns.findIndex(function (_da, i) {
return _da.key == id;
});
var targetIndex = columns.findIndex(function (_da, i) {
return _da.key == data.key;
});
if (columns[objIndex].fixed) return; //固定列不让拖拽
if (columns[targetIndex].fixed) return; //固定列不让拖拽
columns.forEach(function (da, i) {
da.drgHover = false;
if (da.key == id) {
//obj
da.dragIndex = targetIndex;
}
if (da.key == data.key) {
//targetObj
da.dragIndex = objIndex;
}
});
var _columns = columns.sort((0, _util.compare)('dragIndex'));
_this2.setState({
columns: JSON.parse(JSON.stringify(_columns))
});
if (_this2.props.onDrop) {
_this2.props.onDrop(event, data);
}
};
this.getTarget = function (evt) {
return evt.target || evt.srcElement;
};
}, _temp;
}(_react.Component);
}
module.exports = exports['default'];

View File

@ -54,13 +54,8 @@ function filterColumn(Table, Popover) {
var columns = props.columns;
var _column = (0, _utils.ObjectAssign)(columns);
_column.forEach(function (da) {
da.checked = true;
da.disable = true;
});
_this.state = {
columns: _column,
columns: _this.setColumOrderByIndex((0, _utils.ObjectAssign)(columns)),
showModal: false,
screenY: 0
};
@ -151,22 +146,30 @@ function filterColumn(Table, Popover) {
}, _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.setColumOrderByIndex = function (_column) {
_column.forEach(function (da) {
da.checked = true;
da.disable = true;
});
return _column;
};
this.checkedColumItemClick = function (da) {
var checkMinSize = _this2.props.checkMinSize;
da.checked = da.checked ? false : true;
// if(checkMinSize)
var sum = 0,
leng = 0;
_this2.state.columns.forEach(function (da) {
da.fixed ? "" : leng++;
!da.fixed && da.checked ? sum++ : "";
});
if (sum < checkMinSize) {
if (sum < checkMinSize && da.checked) {
return;
} else {
if (sum <= 0) return;
if (sum <= 1 && da.checked) return;
}
da.checked = da.checked ? false : true;
da.disable = da.checked ? true : false;
_this2.setState(_extends({}, _this2.state));
};

View File

@ -68,7 +68,8 @@ class Demo13 extends Component {
};
}
getSelectedDataFunc = data => {
// console.log(data);
debugger;
console.log(data);
};
selectDisabled = (record, index) => {
// console.log(record);

View File

@ -248,7 +248,7 @@ class Demo25 extends Component {
data={dataList}
getSelectedDataFunc={this.getSelectedDataFunc}
bordered
checkMinSize={6}
checkMinSize={7}
draggable={true}
multiSelect={{type: "checkbox"}}
scroll={{x:"130%", y: 150}}

File diff suppressed because one or more lines are too long

205
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "bee-table",
"version": "1.2.7",
"version": "1.2.8",
"description": "Table ui component for react",
"keywords": [
"react",

View File

@ -12,13 +12,16 @@ export default function dragColumn(Table) {
constructor(props) {
super(props);
const {columns} = props;
this.setColumOrderByIndex(columns);
this.state = {
columns:this.setColumOrderByIndex(props.columns)
};
}
componentWillReceiveProps(nextProps){
if(nextProps.columns != this.props.columns){
this.setColumOrderByIndex(nextProps.columns);
this.setState({
columns:this.setColumOrderByIndex(nextProps.columns)
})
}
}
@ -27,9 +30,7 @@ export default function dragColumn(Table) {
da.dragIndex = i;
da.drgHover = false;
});
this.state = {
columns:_column
};
return _column;
}

View File

@ -19,16 +19,19 @@ export default function filterColumn(Table,Popover) {
constructor(props) {
super(props);
const {columns} = props;
let _column = ObjectAssign(columns);
this.state = {
columns:this.setColumOrderByIndex(ObjectAssign(columns)),
showModal:false,
screenY:0
};
}
setColumOrderByIndex = (_column)=>{
_column.forEach(da => {
da.checked = true;
da.disable = true;
});
this.state = {
columns:_column,
showModal:false,
screenY:0
};
return _column;
}
componentWillReceiveProps(nextProps){
@ -44,18 +47,18 @@ export default function filterColumn(Table,Popover) {
checkedColumItemClick = (da)=>{
let {checkMinSize} = this.props;
da.checked = da.checked?false:true;
// if(checkMinSize)
let sum = 0,leng=0;
this.state.columns.forEach(da => {
da.fixed?"":leng++;
!da.fixed && da.checked?sum++:"";
});
if(sum < checkMinSize){
if(sum < checkMinSize && da.checked){
return;
}else{
if(sum<=0)return;
if(sum<=1 && da.checked)return;
}
da.checked = da.checked?false:true;
da.disable = da.checked?true:false;
this.setState({
...this.state