@ucloud-fe/react-components 1.3.9 → 1.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/icon.min.js +1 -1
- package/dist/main.min.js +4 -4
- package/lib/components/SvgIcon/SvgIcon.js +4 -1
- package/lib/components/SvgIcon/icons/Dragger.d.ts +3 -0
- package/lib/components/SvgIcon/icons/Dragger.js +23 -0
- package/lib/components/Table/DragWrap.d.ts +42 -0
- package/lib/components/Table/DragWrap.js +64 -0
- package/lib/components/Table/Table.js +284 -59
- package/lib/components/Table/TableRow.d.ts +9 -0
- package/lib/components/Table/TableRow.js +62 -76
- package/lib/components/Table/style/index.js +36 -18
- package/lib/components/TransferMenu/TransferMenu.js +2 -1
- package/lib/libs/rc-table/ExpandableTable.js +1 -0
- package/lib/libs/rc-table/Table.d.ts +13 -1
- package/lib/libs/rc-table/Table.js +12 -11
- package/lib/libs/rc-table/TableRow.js +2 -1
- package/package.json +3 -2
|
@@ -15,6 +15,8 @@ Object.defineProperty(exports, "prefixCls", {
|
|
|
15
15
|
});
|
|
16
16
|
exports.default = exports.TableContext = exports.placeholderKey = exports.deprecatedLogForOnRowSelect = void 0;
|
|
17
17
|
|
|
18
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
|
+
|
|
18
20
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
19
21
|
|
|
20
22
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
@@ -69,12 +71,16 @@ var _rcTable = _interopRequireDefault(require("../../libs/rc-table"));
|
|
|
69
71
|
|
|
70
72
|
var _deprecatedLog = _interopRequireDefault(require("../../utils/deprecatedLog"));
|
|
71
73
|
|
|
74
|
+
var _warning = _interopRequireWildcard(require("../../utils/warning"));
|
|
75
|
+
|
|
72
76
|
var _Pagination = _interopRequireDefault(require("../../components/Pagination"));
|
|
73
77
|
|
|
74
78
|
var _Notice = _interopRequireDefault(require("../../components/Notice"));
|
|
75
79
|
|
|
76
80
|
var _Checkbox = _interopRequireDefault(require("../../components/Checkbox"));
|
|
77
81
|
|
|
82
|
+
var _SvgIcon = _interopRequireDefault(require("../../components/SvgIcon"));
|
|
83
|
+
|
|
78
84
|
var _Radio = _interopRequireDefault(require("../../components/Radio"));
|
|
79
85
|
|
|
80
86
|
var _Select = _interopRequireDefault(require("../../components/Select"));
|
|
@@ -89,10 +95,12 @@ var _style = require("./style");
|
|
|
89
95
|
|
|
90
96
|
var _zh_CN = _interopRequireDefault(require("./locale/zh_CN"));
|
|
91
97
|
|
|
98
|
+
var _DragWrap = _interopRequireDefault(require("./DragWrap"));
|
|
99
|
+
|
|
92
100
|
var _TableRow = _interopRequireDefault(require("./TableRow"));
|
|
93
101
|
|
|
94
102
|
var _excluded = ["options", "multiple", "onChange"],
|
|
95
|
-
_excluded2 = ["pagination", "dataSource", "columns", "rowSelection", "onRowSelect", "contextMenu", "emptyContent", "errorContent", "className", "style", "expandedRowRender", "expandIconAsCell", "expandIconColumnIndex", "defaultExpandAllRows", "title", "footer", "locale", "hideExpandIcon", "onRow", "components", "onExpand", "zebraCrossing", "columnPlaceholder", "tableLayout", "scroll", "customStyle"];
|
|
103
|
+
_excluded2 = ["pagination", "dataSource", "columns", "rowSelection", "onRowSelect", "contextMenu", "emptyContent", "errorContent", "className", "style", "expandedRowRender", "expandIconAsCell", "expandIconColumnIndex", "defaultExpandAllRows", "title", "footer", "locale", "hideExpandIcon", "onRow", "components", "onExpand", "zebraCrossing", "columnPlaceholder", "tableLayout", "scroll", "customStyle", "dragSorting"];
|
|
96
104
|
|
|
97
105
|
var _this = void 0,
|
|
98
106
|
_dec,
|
|
@@ -125,9 +133,11 @@ exports.TableContext = TableContext;
|
|
|
125
133
|
|
|
126
134
|
var missingColumnKeyWarn = function missingColumnKeyWarn() {
|
|
127
135
|
(0, _newArrowCheck2.default)(this, _this);
|
|
128
|
-
return
|
|
136
|
+
return (0, _warning.default)('Table column need a unique key');
|
|
129
137
|
}.bind(void 0);
|
|
130
138
|
|
|
139
|
+
var dragSortingWarning = (0, _warning.onceWarning)("Can't use dragSorting with expandedRowRender or column.children");
|
|
140
|
+
var uid = 0;
|
|
131
141
|
var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
132
142
|
defaultLocale: _zh_CN.default,
|
|
133
143
|
localeName: 'Table'
|
|
@@ -756,35 +766,56 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
756
766
|
return (key === undefined ? index : key) + '';
|
|
757
767
|
};
|
|
758
768
|
|
|
759
|
-
_this2.
|
|
769
|
+
_this2.getDragSorting = function () {
|
|
760
770
|
var _this23 = this;
|
|
761
771
|
|
|
762
772
|
(0, _newArrowCheck2.default)(this, _this3);
|
|
763
773
|
var _this2$props2 = _this2.props,
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
774
|
+
dragSorting = _this2$props2.dragSorting,
|
|
775
|
+
expandedRowRender = _this2$props2.expandedRowRender,
|
|
776
|
+
columns = _this2$props2.columns;
|
|
777
|
+
if (!dragSorting) return false;
|
|
778
|
+
|
|
779
|
+
if (expandedRowRender || columns && columns.findIndex(function (column) {
|
|
780
|
+
(0, _newArrowCheck2.default)(this, _this23);
|
|
781
|
+
return !!column.children;
|
|
782
|
+
}.bind(this)) >= 0) {
|
|
783
|
+
dragSortingWarning();
|
|
784
|
+
return false;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
return dragSorting;
|
|
788
|
+
}.bind(this);
|
|
789
|
+
|
|
790
|
+
_this2.getColumns = function (dataSourceOfCurrentPage, filters) {
|
|
791
|
+
var _this24 = this;
|
|
792
|
+
|
|
793
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
794
|
+
var _this2$props3 = _this2.props,
|
|
795
|
+
columns = _this2$props3.columns,
|
|
796
|
+
rowSelection = _this2$props3.rowSelection,
|
|
797
|
+
columnPlaceholder = _this2$props3.columnPlaceholder,
|
|
798
|
+
locale = _this2$props3.locale,
|
|
799
|
+
dataSource = _this2$props3.dataSource;
|
|
769
800
|
var _this2$state2 = _this2.state,
|
|
770
801
|
_this2$state2$order = _this2$state2.order,
|
|
771
802
|
currentOrder = _this2$state2$order === void 0 ? {} : _this2$state2$order,
|
|
772
803
|
selectedRowKeyMap = _this2$state2.selectedRowKeyMap,
|
|
773
804
|
columnConfig = _this2$state2.columnConfig;
|
|
774
805
|
var cloneColumns = columns.map(function (column, index) {
|
|
775
|
-
(0, _newArrowCheck2.default)(this,
|
|
806
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
776
807
|
return _objectSpread(_objectSpread({}, column), {}, {
|
|
777
808
|
index: index
|
|
778
809
|
});
|
|
779
810
|
}.bind(this));
|
|
780
811
|
var newColumns = cloneColumns.filter(function (column) {
|
|
781
|
-
(0, _newArrowCheck2.default)(this,
|
|
812
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
782
813
|
var key = column.key;
|
|
783
814
|
return !columnConfig[key] || !columnConfig[key].hidden;
|
|
784
815
|
}.bind(this));
|
|
785
816
|
|
|
786
817
|
var _generateColumnTitle = function generateColumnTitle(column) {
|
|
787
|
-
(0, _newArrowCheck2.default)(this,
|
|
818
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
788
819
|
var dataIndex = column.dataIndex,
|
|
789
820
|
title = column.title,
|
|
790
821
|
renderTitle = column.renderTitle,
|
|
@@ -819,42 +850,42 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
819
850
|
|
|
820
851
|
if (rowSelection.getDisabledOfRow) {
|
|
821
852
|
enableDataSourceOfCurrentPage = (0, _filter2.default)(flatDataSourceOfCurrentPage, function (item) {
|
|
822
|
-
(0, _newArrowCheck2.default)(this,
|
|
853
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
823
854
|
return !rowSelection.getDisabledOfRow(item.record);
|
|
824
855
|
}.bind(this));
|
|
825
856
|
enableDataSource = (0, _filter2.default)(flatDataSource, function (item) {
|
|
826
|
-
(0, _newArrowCheck2.default)(this,
|
|
857
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
827
858
|
return !rowSelection.getDisabledOfRow(item.record);
|
|
828
859
|
}.bind(this));
|
|
829
860
|
}
|
|
830
861
|
|
|
831
862
|
var selectedEnableDataSourceOfCurrentPage = (0, _filter2.default)(enableDataSourceOfCurrentPage, function (item) {
|
|
832
|
-
(0, _newArrowCheck2.default)(this,
|
|
863
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
833
864
|
return selectedRowKeyMap[item.key];
|
|
834
865
|
}.bind(this));
|
|
835
866
|
var selectedEnableDataSource = (0, _filter2.default)(enableDataSource, function (item) {
|
|
836
|
-
(0, _newArrowCheck2.default)(this,
|
|
867
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
837
868
|
return selectedRowKeyMap[item.key];
|
|
838
869
|
}.bind(this));
|
|
839
870
|
var selectedEnableDataSourceOfCurrentPageCount = selectedEnableDataSourceOfCurrentPage.length;
|
|
840
871
|
var isAllSelected = selectedEnableDataSourceOfCurrentPageCount === enableDataSourceOfCurrentPage.length && selectedEnableDataSourceOfCurrentPageCount > 0;
|
|
841
872
|
var selectedCount = (0, _filter2.default)(selectedRowKeyMap, function (v) {
|
|
842
|
-
(0, _newArrowCheck2.default)(this,
|
|
873
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
843
874
|
return v;
|
|
844
875
|
}.bind(this)).length;
|
|
845
876
|
|
|
846
877
|
var renderSelectedAllCheckbox = function renderSelectedAllCheckbox() {
|
|
847
|
-
var
|
|
878
|
+
var _this25 = this;
|
|
848
879
|
|
|
849
|
-
(0, _newArrowCheck2.default)(this,
|
|
880
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
850
881
|
return /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
|
|
851
882
|
disabled: selectionDisabled,
|
|
852
883
|
onChange: function () {
|
|
853
|
-
var
|
|
884
|
+
var _this26 = this;
|
|
854
885
|
|
|
855
|
-
(0, _newArrowCheck2.default)(this,
|
|
886
|
+
(0, _newArrowCheck2.default)(this, _this25);
|
|
856
887
|
var enableKeysOfCurrentPage = enableDataSourceOfCurrentPage.map(function (item) {
|
|
857
|
-
(0, _newArrowCheck2.default)(this,
|
|
888
|
+
(0, _newArrowCheck2.default)(this, _this26);
|
|
858
889
|
return item.key;
|
|
859
890
|
}.bind(this));
|
|
860
891
|
|
|
@@ -871,11 +902,11 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
871
902
|
getPopupContainer: _this2.getPopupContainer,
|
|
872
903
|
popup: /*#__PURE__*/_react.default.createElement("span", null, locale.selected, " ", selectedCount, ' ', /*#__PURE__*/_react.default.createElement(_style.CancelSelect, {
|
|
873
904
|
onClick: function () {
|
|
874
|
-
var
|
|
905
|
+
var _this27 = this;
|
|
875
906
|
|
|
876
|
-
(0, _newArrowCheck2.default)(this,
|
|
907
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
877
908
|
var enableKeys = selectedEnableDataSource.map(function (item) {
|
|
878
|
-
(0, _newArrowCheck2.default)(this,
|
|
909
|
+
(0, _newArrowCheck2.default)(this, _this27);
|
|
879
910
|
return item.key;
|
|
880
911
|
}.bind(this));
|
|
881
912
|
|
|
@@ -891,21 +922,21 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
891
922
|
width: 32,
|
|
892
923
|
fixed: rowSelection.fixed,
|
|
893
924
|
onHeaderCell: function onHeaderCell() {
|
|
894
|
-
(0, _newArrowCheck2.default)(this,
|
|
925
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
895
926
|
return {
|
|
896
927
|
className: _style.selectIconHeaderCls
|
|
897
928
|
};
|
|
898
929
|
}.bind(this),
|
|
899
930
|
onCell: function onCell() {
|
|
900
|
-
(0, _newArrowCheck2.default)(this,
|
|
931
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
901
932
|
return {
|
|
902
933
|
className: _style.selectIconCellCls
|
|
903
934
|
};
|
|
904
935
|
}.bind(this),
|
|
905
936
|
render: function render(value, record, index) {
|
|
906
|
-
var
|
|
937
|
+
var _this28 = this;
|
|
907
938
|
|
|
908
|
-
(0, _newArrowCheck2.default)(this,
|
|
939
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
909
940
|
|
|
910
941
|
var rowKey = _this2.getRowKey(record, index);
|
|
911
942
|
|
|
@@ -920,14 +951,14 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
920
951
|
return rowSelection.multiple === false ? /*#__PURE__*/_react.default.createElement(_Radio.default, {
|
|
921
952
|
disabled: disabled,
|
|
922
953
|
onChange: function () {
|
|
923
|
-
(0, _newArrowCheck2.default)(this,
|
|
954
|
+
(0, _newArrowCheck2.default)(this, _this28);
|
|
924
955
|
return _this2.handleSelectRecord(rowKey);
|
|
925
956
|
}.bind(this),
|
|
926
957
|
checked: !!selectedRowKeyMap[rowKey]
|
|
927
958
|
}) : /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
|
|
928
959
|
disabled: disabled,
|
|
929
960
|
onChange: function () {
|
|
930
|
-
(0, _newArrowCheck2.default)(this,
|
|
961
|
+
(0, _newArrowCheck2.default)(this, _this28);
|
|
931
962
|
return _this2.handleSelectRecord(rowKey, !selectedRowKeyMap[rowKey]);
|
|
932
963
|
}.bind(this),
|
|
933
964
|
checked: !!selectedRowKeyMap[rowKey]
|
|
@@ -936,28 +967,66 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
936
967
|
});
|
|
937
968
|
}
|
|
938
969
|
|
|
970
|
+
var dragSorting = _this2.getDragSorting();
|
|
971
|
+
|
|
972
|
+
if (dragSorting) {
|
|
973
|
+
newColumns.unshift({
|
|
974
|
+
title: null,
|
|
975
|
+
key: 'table_row_drag_sorting',
|
|
976
|
+
width: 40,
|
|
977
|
+
fixed: dragSorting === null || dragSorting === void 0 ? void 0 : dragSorting.fixed,
|
|
978
|
+
onHeaderCell: function onHeaderCell() {
|
|
979
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
980
|
+
return {
|
|
981
|
+
className: _style.draggerHeaderCls
|
|
982
|
+
};
|
|
983
|
+
}.bind(this),
|
|
984
|
+
onCell: function onCell() {
|
|
985
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
986
|
+
return {
|
|
987
|
+
className: _style.draggerCellCls
|
|
988
|
+
};
|
|
989
|
+
}.bind(this),
|
|
990
|
+
render: function render(value, record, index) {
|
|
991
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
992
|
+
|
|
993
|
+
var rowKey = _this2.getRowKey(record, index);
|
|
994
|
+
|
|
995
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
996
|
+
"data-row-key": rowKey,
|
|
997
|
+
onMouseEnter: _this2.setDraggable,
|
|
998
|
+
onMouseLeave: _this2.unsetDraggable,
|
|
999
|
+
className: _style.draggerCls
|
|
1000
|
+
}, /*#__PURE__*/_react.default.createElement(_SvgIcon.default, {
|
|
1001
|
+
type: "dragger",
|
|
1002
|
+
size: "16px"
|
|
1003
|
+
}));
|
|
1004
|
+
}.bind(this)
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
|
|
939
1008
|
if (columnPlaceholder) {
|
|
940
1009
|
var lastUnFixedIndex = (0, _findLastIndex2.default)(newColumns, function (columnConfig) {
|
|
941
|
-
(0, _newArrowCheck2.default)(this,
|
|
1010
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
942
1011
|
return !columnConfig.fixed;
|
|
943
1012
|
}.bind(this));
|
|
944
1013
|
newColumns.splice(lastUnFixedIndex + 1, 0, {
|
|
945
1014
|
title: '',
|
|
946
1015
|
key: placeholderKey,
|
|
947
1016
|
onHeaderCell: function onHeaderCell() {
|
|
948
|
-
(0, _newArrowCheck2.default)(this,
|
|
1017
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
949
1018
|
return {
|
|
950
1019
|
className: _style.placeholderHeaderCls
|
|
951
1020
|
};
|
|
952
1021
|
}.bind(this),
|
|
953
1022
|
onCell: function onCell() {
|
|
954
|
-
(0, _newArrowCheck2.default)(this,
|
|
1023
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
955
1024
|
return {
|
|
956
1025
|
className: _style.placeholderCellCls
|
|
957
1026
|
};
|
|
958
1027
|
}.bind(this),
|
|
959
1028
|
render: function render() {
|
|
960
|
-
(0, _newArrowCheck2.default)(this,
|
|
1029
|
+
(0, _newArrowCheck2.default)(this, _this24);
|
|
961
1030
|
return null;
|
|
962
1031
|
}.bind(this)
|
|
963
1032
|
});
|
|
@@ -966,6 +1035,144 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
966
1035
|
return newColumns;
|
|
967
1036
|
}.bind(this);
|
|
968
1037
|
|
|
1038
|
+
_this2.getTableDom = function () {
|
|
1039
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1040
|
+
return document.querySelector("[data-table-id=\"".concat(_this2.tableId, "\"]"));
|
|
1041
|
+
}.bind(this);
|
|
1042
|
+
|
|
1043
|
+
_this2.getContentDom = function () {
|
|
1044
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1045
|
+
return _this2.getTableDom().querySelector(".".concat(_style.contentCls));
|
|
1046
|
+
}.bind(this);
|
|
1047
|
+
|
|
1048
|
+
_this2.getBodyDom = function () {
|
|
1049
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1050
|
+
return _this2.getTableDom().querySelector(".".concat(_style.bodyCls));
|
|
1051
|
+
}.bind(this);
|
|
1052
|
+
|
|
1053
|
+
_this2.getRowDom = function (rowKey) {
|
|
1054
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1055
|
+
return _this2.getTableDom().querySelector("tr[data-row-key=\"".concat(rowKey, "\"]"));
|
|
1056
|
+
}.bind(this);
|
|
1057
|
+
|
|
1058
|
+
_this2.getRowDomByIndex = function (rowIndex) {
|
|
1059
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1060
|
+
return _this2.getTableDom().querySelector("tr[data-row-index=\"".concat(rowIndex, "\"]"));
|
|
1061
|
+
}.bind(this);
|
|
1062
|
+
|
|
1063
|
+
_this2.__dragEnterCounter = null;
|
|
1064
|
+
|
|
1065
|
+
_this2.initDrag = function (source) {
|
|
1066
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1067
|
+
_this2.__dragEnterCounter = 0;
|
|
1068
|
+
|
|
1069
|
+
_this2.unsetDragOver(source, source);
|
|
1070
|
+
}.bind(this);
|
|
1071
|
+
|
|
1072
|
+
_this2.setDraggable = function (e) {
|
|
1073
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1074
|
+
var rowKey = e.currentTarget.dataset['rowKey'];
|
|
1075
|
+
|
|
1076
|
+
_this2.getRowDom(rowKey).setAttribute('draggable', true);
|
|
1077
|
+
}.bind(this);
|
|
1078
|
+
|
|
1079
|
+
_this2.unsetDraggable = function (e) {
|
|
1080
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1081
|
+
var rowKey = e.currentTarget.dataset['rowKey'];
|
|
1082
|
+
|
|
1083
|
+
_this2.getRowDom(rowKey).setAttribute('draggable', false);
|
|
1084
|
+
}.bind(this);
|
|
1085
|
+
|
|
1086
|
+
_this2.setDragOver = function (source, target) {
|
|
1087
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1088
|
+
|
|
1089
|
+
var _this2$transformDomIn = _this2.transformDomIndex(source, target),
|
|
1090
|
+
_this2$transformDomIn2 = (0, _slicedToArray2.default)(_this2$transformDomIn, 2),
|
|
1091
|
+
sourceIndex = _this2$transformDomIn2[0],
|
|
1092
|
+
targetIndex = _this2$transformDomIn2[1];
|
|
1093
|
+
|
|
1094
|
+
if (sourceIndex > targetIndex) targetIndex--;
|
|
1095
|
+
|
|
1096
|
+
if (targetIndex >= 0) {
|
|
1097
|
+
var _this2$getRowDomByInd;
|
|
1098
|
+
|
|
1099
|
+
(_this2$getRowDomByInd = _this2.getRowDomByIndex(targetIndex)) === null || _this2$getRowDomByInd === void 0 ? void 0 : _this2$getRowDomByInd.classList.add(_style.dragOverDownCls);
|
|
1100
|
+
} else {
|
|
1101
|
+
_this2.getRowDomByIndex(0).classList.add(_style.dragOverUpCls);
|
|
1102
|
+
}
|
|
1103
|
+
}.bind(this);
|
|
1104
|
+
|
|
1105
|
+
_this2.unsetDragOver = function (source, target) {
|
|
1106
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1107
|
+
|
|
1108
|
+
var _this2$transformDomIn3 = _this2.transformDomIndex(source, target),
|
|
1109
|
+
_this2$transformDomIn4 = (0, _slicedToArray2.default)(_this2$transformDomIn3, 2),
|
|
1110
|
+
sourceIndex = _this2$transformDomIn4[0],
|
|
1111
|
+
targetIndex = _this2$transformDomIn4[1];
|
|
1112
|
+
|
|
1113
|
+
if (sourceIndex > targetIndex) targetIndex--;
|
|
1114
|
+
|
|
1115
|
+
if (targetIndex >= 0) {
|
|
1116
|
+
var _this2$getRowDomByInd2;
|
|
1117
|
+
|
|
1118
|
+
(_this2$getRowDomByInd2 = _this2.getRowDomByIndex(targetIndex)) === null || _this2$getRowDomByInd2 === void 0 ? void 0 : _this2$getRowDomByInd2.classList.remove(_style.dragOverDownCls);
|
|
1119
|
+
} else {
|
|
1120
|
+
_this2.getRowDomByIndex(0).classList.remove(_style.dragOverUpCls);
|
|
1121
|
+
}
|
|
1122
|
+
}.bind(this);
|
|
1123
|
+
|
|
1124
|
+
_this2.onDragStart = function (source) {
|
|
1125
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1126
|
+
|
|
1127
|
+
_this2.initDrag(source);
|
|
1128
|
+
}.bind(this);
|
|
1129
|
+
|
|
1130
|
+
_this2.onDragEnd = function (source) {
|
|
1131
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1132
|
+
|
|
1133
|
+
_this2.initDrag(source);
|
|
1134
|
+
}.bind(this);
|
|
1135
|
+
|
|
1136
|
+
_this2.onDragEnter = function (source, target) {
|
|
1137
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1138
|
+
_this2.__dragEnterCounter++;
|
|
1139
|
+
|
|
1140
|
+
_this2.unsetDragOver(source, source);
|
|
1141
|
+
|
|
1142
|
+
_this2.setDragOver(source, target);
|
|
1143
|
+
}.bind(this);
|
|
1144
|
+
|
|
1145
|
+
_this2.onDragLeave = function (source, target) {
|
|
1146
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1147
|
+
_this2.__dragEnterCounter--;
|
|
1148
|
+
|
|
1149
|
+
_this2.unsetDragOver(source, target); // drag out the table
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
if (!_this2.__dragEnterCounter) _this2.setDragOver(source, source);
|
|
1153
|
+
}.bind(this);
|
|
1154
|
+
|
|
1155
|
+
_this2.onDrop = function (source, target) {
|
|
1156
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1157
|
+
if (source === target) return;
|
|
1158
|
+
|
|
1159
|
+
var _this2$transformDomIn5 = _this2.transformDomIndex(source, target),
|
|
1160
|
+
_this2$transformDomIn6 = (0, _slicedToArray2.default)(_this2$transformDomIn5, 2),
|
|
1161
|
+
sourceIndex = _this2$transformDomIn6[0],
|
|
1162
|
+
targetIndex = _this2$transformDomIn6[1];
|
|
1163
|
+
|
|
1164
|
+
var dragSorting = _this2.getDragSorting();
|
|
1165
|
+
|
|
1166
|
+
dragSorting === null || dragSorting === void 0 ? void 0 : dragSorting.onChange(sourceIndex, targetIndex);
|
|
1167
|
+
|
|
1168
|
+
_this2.initDrag(source);
|
|
1169
|
+
}.bind(this);
|
|
1170
|
+
|
|
1171
|
+
_this2.transformDomIndex = function (source, target) {
|
|
1172
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
1173
|
+
return [+source.dataset['rowIndex'], +target.dataset['rowIndex']];
|
|
1174
|
+
}.bind(this);
|
|
1175
|
+
|
|
969
1176
|
_this2.getPagination = function () {
|
|
970
1177
|
(0, _newArrowCheck2.default)(this, _this3);
|
|
971
1178
|
var paginationS = _this2.state.pagination,
|
|
@@ -974,7 +1181,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
974
1181
|
}.bind(this);
|
|
975
1182
|
|
|
976
1183
|
_this2.renderSearchInfo = function (option) {
|
|
977
|
-
var
|
|
1184
|
+
var _this29 = this;
|
|
978
1185
|
|
|
979
1186
|
(0, _newArrowCheck2.default)(this, _this3);
|
|
980
1187
|
var filters = option.filters,
|
|
@@ -984,15 +1191,15 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
984
1191
|
var first = true;
|
|
985
1192
|
|
|
986
1193
|
var renderLabel = function renderLabel(_ref5) {
|
|
987
|
-
var
|
|
1194
|
+
var _this30 = this;
|
|
988
1195
|
|
|
989
|
-
(0, _newArrowCheck2.default)(this,
|
|
1196
|
+
(0, _newArrowCheck2.default)(this, _this29);
|
|
990
1197
|
var value = _ref5.value,
|
|
991
1198
|
_ref5$column$filter = _ref5.column.filter,
|
|
992
1199
|
multiple = _ref5$column$filter.multiple,
|
|
993
1200
|
options = _ref5$column$filter.options;
|
|
994
1201
|
options = options.map(function (option) {
|
|
995
|
-
(0, _newArrowCheck2.default)(this,
|
|
1202
|
+
(0, _newArrowCheck2.default)(this, _this30);
|
|
996
1203
|
return !(0, _isObject2.default)(option) ? {
|
|
997
1204
|
value: option,
|
|
998
1205
|
label: option
|
|
@@ -1001,23 +1208,23 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1001
1208
|
|
|
1002
1209
|
if (multiple) {
|
|
1003
1210
|
var label = (0, _map2.default)(value, function (v) {
|
|
1004
|
-
var
|
|
1211
|
+
var _this31 = this;
|
|
1005
1212
|
|
|
1006
|
-
(0, _newArrowCheck2.default)(this,
|
|
1213
|
+
(0, _newArrowCheck2.default)(this, _this30);
|
|
1007
1214
|
var option = (0, _find2.default)(options, function (option) {
|
|
1008
|
-
(0, _newArrowCheck2.default)(this,
|
|
1215
|
+
(0, _newArrowCheck2.default)(this, _this31);
|
|
1009
1216
|
return v === option.value;
|
|
1010
1217
|
}.bind(this));
|
|
1011
1218
|
return option && option.label;
|
|
1012
1219
|
}.bind(this));
|
|
1013
1220
|
var _first = true;
|
|
1014
1221
|
return (0, _map2.default)(label, function (_label) {
|
|
1015
|
-
(0, _newArrowCheck2.default)(this,
|
|
1222
|
+
(0, _newArrowCheck2.default)(this, _this30);
|
|
1016
1223
|
return _first ? [_first = false, _label] : [' | ', _label];
|
|
1017
1224
|
}.bind(this));
|
|
1018
1225
|
} else {
|
|
1019
1226
|
var _option = (0, _find2.default)(options, function (option) {
|
|
1020
|
-
(0, _newArrowCheck2.default)(this,
|
|
1227
|
+
(0, _newArrowCheck2.default)(this, _this30);
|
|
1021
1228
|
return value === option.value;
|
|
1022
1229
|
}.bind(this));
|
|
1023
1230
|
|
|
@@ -1033,7 +1240,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1033
1240
|
closable: false,
|
|
1034
1241
|
className: "".concat(_style.prefixCls, "-filter-notice")
|
|
1035
1242
|
}, searchValue && /*#__PURE__*/_react.default.createElement("span", null, locale.search, locale.colon, searchValue, locale.semicolon), !(0, _isEmpty2.default)(filters) && /*#__PURE__*/_react.default.createElement("span", null, locale.filter, locale.colon, (0, _map2.default)(filters, function (filterInfo) {
|
|
1036
|
-
(0, _newArrowCheck2.default)(this,
|
|
1243
|
+
(0, _newArrowCheck2.default)(this, _this29);
|
|
1037
1244
|
return first ? [first = false, renderLabel(filterInfo)] : [', ', renderLabel(filterInfo)];
|
|
1038
1245
|
}.bind(this)), locale.semicolon), /*#__PURE__*/_react.default.createElement("span", null, locale.searchResult, locale.colon, total, locale.items, locale.semicolon), /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement("a", {
|
|
1039
1246
|
className: "".concat(_style.prefixCls, "-reset-link"),
|
|
@@ -1105,10 +1312,10 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1105
1312
|
|
|
1106
1313
|
_this2.onRow = function (record, index) {
|
|
1107
1314
|
(0, _newArrowCheck2.default)(this, _this3);
|
|
1108
|
-
var _this2$
|
|
1109
|
-
_this2$
|
|
1110
|
-
onRow = _this2$
|
|
1111
|
-
contextMenu = _this2$
|
|
1315
|
+
var _this2$props4 = _this2.props,
|
|
1316
|
+
_this2$props4$onRow = _this2$props4.onRow,
|
|
1317
|
+
onRow = _this2$props4$onRow === void 0 ? noop : _this2$props4$onRow,
|
|
1318
|
+
contextMenu = _this2$props4.contextMenu;
|
|
1112
1319
|
return _objectSpread(_objectSpread({}, onRow(record, index)), {}, {
|
|
1113
1320
|
record: record,
|
|
1114
1321
|
contextMenu: contextMenu
|
|
@@ -1132,7 +1339,8 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1132
1339
|
selectedRowKeyMap: {},
|
|
1133
1340
|
columnConfig: _props.defaultColumnConfig,
|
|
1134
1341
|
searchValue: ''
|
|
1135
|
-
};
|
|
1342
|
+
};
|
|
1343
|
+
_this2.tableId = "uc_table_uid_".concat(uid++); // init pagination
|
|
1136
1344
|
|
|
1137
1345
|
var _pagination = _props.pagination;
|
|
1138
1346
|
|
|
@@ -1185,7 +1393,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1185
1393
|
(0, _createClass2.default)(Table, [{
|
|
1186
1394
|
key: "render",
|
|
1187
1395
|
value: function render() {
|
|
1188
|
-
var
|
|
1396
|
+
var _this32 = this;
|
|
1189
1397
|
|
|
1190
1398
|
/* eslint-disable no-unused-vars */
|
|
1191
1399
|
var _this$props = this.props,
|
|
@@ -1218,6 +1426,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1218
1426
|
tableLayout = _this$props.tableLayout,
|
|
1219
1427
|
scroll = _this$props.scroll,
|
|
1220
1428
|
customStyle = _this$props.customStyle,
|
|
1429
|
+
_dragSorting = _this$props.dragSorting,
|
|
1221
1430
|
rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded2);
|
|
1222
1431
|
|
|
1223
1432
|
if (emptyContent === undefined) {
|
|
@@ -1246,7 +1455,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1246
1455
|
|
|
1247
1456
|
var columns = this.getColumns(dataSource, finalFilters);
|
|
1248
1457
|
var defaultExpandAllRowsProps = !defaultExpandAllRows ? null : function () {
|
|
1249
|
-
(0, _newArrowCheck2.default)(this,
|
|
1458
|
+
(0, _newArrowCheck2.default)(this, _this32);
|
|
1250
1459
|
var _this$state$changedUn = this.state.changedUnExpandedRowKeys,
|
|
1251
1460
|
changedUnExpandedRowKeys = _this$state$changedUn === void 0 ? {} : _this$state$changedUn;
|
|
1252
1461
|
var expandedRowKeys = this.getExpandedRowKeys(dataSource, changedUnExpandedRowKeys);
|
|
@@ -1254,7 +1463,15 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1254
1463
|
expandedRowKeys: expandedRowKeys
|
|
1255
1464
|
};
|
|
1256
1465
|
}.bind(this)();
|
|
1257
|
-
|
|
1466
|
+
var dragSorting = this.getDragSorting();
|
|
1467
|
+
return /*#__PURE__*/_react.default.createElement(_DragWrap.default, {
|
|
1468
|
+
draggable: !!dragSorting,
|
|
1469
|
+
onDragStart: this.onDragStart,
|
|
1470
|
+
onDragEnd: this.onDragEnd,
|
|
1471
|
+
onDrop: this.onDrop,
|
|
1472
|
+
onDragEnter: this.onDragEnter,
|
|
1473
|
+
onDragLeave: this.onDragLeave
|
|
1474
|
+
}, /*#__PURE__*/_react.default.createElement(_ContainerContext.InheritProvider, {
|
|
1258
1475
|
value: {
|
|
1259
1476
|
getPopupContainer: this.getPopupContainer
|
|
1260
1477
|
}
|
|
@@ -1271,7 +1488,8 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1271
1488
|
style: style,
|
|
1272
1489
|
hideExpandIcon: hideExpandIcon,
|
|
1273
1490
|
zebraCrossing: zebraCrossing,
|
|
1274
|
-
customStyle: customStyle
|
|
1491
|
+
customStyle: customStyle,
|
|
1492
|
+
"data-table-id": this.tableId
|
|
1275
1493
|
}, /*#__PURE__*/_react.default.createElement(_style.PopupContainer, {
|
|
1276
1494
|
ref: this.savePopupContainer
|
|
1277
1495
|
}), /*#__PURE__*/_react.default.createElement(_rcTable.default, (0, _extends2.default)({}, defaultExpandAllRowsProps, {
|
|
@@ -1293,7 +1511,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1293
1511
|
expandedRowRender: expandedRowRender,
|
|
1294
1512
|
expandIconColumnIndex: expandIconColumnIndex === undefined ? columns[0] && columns[0].key === 'table_row_selection' ? 1 : 0 : expandIconColumnIndex,
|
|
1295
1513
|
title: function () {
|
|
1296
|
-
(0, _newArrowCheck2.default)(this,
|
|
1514
|
+
(0, _newArrowCheck2.default)(this, _this32);
|
|
1297
1515
|
return this.renderTitle({
|
|
1298
1516
|
filters: finalFilters,
|
|
1299
1517
|
searchValue: searchValue,
|
|
@@ -1302,7 +1520,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1302
1520
|
});
|
|
1303
1521
|
}.bind(this),
|
|
1304
1522
|
footer: function () {
|
|
1305
|
-
(0, _newArrowCheck2.default)(this,
|
|
1523
|
+
(0, _newArrowCheck2.default)(this, _this32);
|
|
1306
1524
|
return this.renderFooter({
|
|
1307
1525
|
dataSource: _d,
|
|
1308
1526
|
emptyContent: emptyContent,
|
|
@@ -1318,7 +1536,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1318
1536
|
}, pagination, {
|
|
1319
1537
|
className: "".concat(_style.prefixCls, "-pagination"),
|
|
1320
1538
|
onChange: function (current, pageSize) {
|
|
1321
|
-
(0, _newArrowCheck2.default)(this,
|
|
1539
|
+
(0, _newArrowCheck2.default)(this, _this32);
|
|
1322
1540
|
this.setState({
|
|
1323
1541
|
pagination: {
|
|
1324
1542
|
current: current,
|
|
@@ -1328,7 +1546,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1328
1546
|
pagination.onChange && pagination.onChange(current, pageSize);
|
|
1329
1547
|
}.bind(this),
|
|
1330
1548
|
onPageSizeChange: function (current, pageSize) {
|
|
1331
|
-
(0, _newArrowCheck2.default)(this,
|
|
1549
|
+
(0, _newArrowCheck2.default)(this, _this32);
|
|
1332
1550
|
this.setState({
|
|
1333
1551
|
pagination: {
|
|
1334
1552
|
current: current,
|
|
@@ -1338,7 +1556,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1338
1556
|
pagination.onPageSizeChange && pagination.onPageSizeChange(current, pageSize);
|
|
1339
1557
|
}.bind(this),
|
|
1340
1558
|
onAdvise: function (current, pageSize) {
|
|
1341
|
-
(0, _newArrowCheck2.default)(this,
|
|
1559
|
+
(0, _newArrowCheck2.default)(this, _this32);
|
|
1342
1560
|
this.setState({
|
|
1343
1561
|
pagination: {
|
|
1344
1562
|
current: current,
|
|
@@ -1347,7 +1565,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1347
1565
|
});
|
|
1348
1566
|
pagination.onAdvise && pagination.onAdvise(current, pageSize);
|
|
1349
1567
|
}.bind(this)
|
|
1350
|
-
})))));
|
|
1568
|
+
}))))));
|
|
1351
1569
|
}
|
|
1352
1570
|
}]);
|
|
1353
1571
|
return Table;
|
|
@@ -1449,6 +1667,13 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
|
|
|
1449
1667
|
disabled: _propTypes.default.bool
|
|
1450
1668
|
}), _propTypes.default.oneOf([true])]),
|
|
1451
1669
|
|
|
1670
|
+
/** 拖拽排序 */
|
|
1671
|
+
dragSorting: _propTypes.default.oneOfType([_propTypes.default.oneOf([true]), _propTypes.default.shape({
|
|
1672
|
+
fixed: _propTypes.default.bool,
|
|
1673
|
+
// (record, fromIndex, toIndex) => void
|
|
1674
|
+
onChange: _propTypes.default.func
|
|
1675
|
+
})]),
|
|
1676
|
+
|
|
1452
1677
|
/**
|
|
1453
1678
|
* 列表选项变化回调
|
|
1454
1679
|
* @deprecated - 请使用rowSelection.onChange来替换
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
interface TableRowProps {
|
|
3
|
+
record: any;
|
|
4
|
+
contextMenu?: (record: any, hideContextMenu: () => void) => ReactNode;
|
|
5
|
+
draggable?: boolean;
|
|
6
|
+
'data-row-key'?: string | number;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: React.MemoExoticComponent<({ ...restProps }: TableRowProps) => JSX.Element>;
|
|
9
|
+
export default _default;
|