@kdcloudjs/kdesign 1.6.32 → 1.6.34
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/kdesign-complete.less +3 -9
- package/dist/kdesign.css +4 -5
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +660 -216
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +3 -3
- package/dist/kdesign.min.js +8 -8
- package/dist/kdesign.min.js.map +1 -1
- package/es/date-picker/date-picker.js +2 -5
- package/es/rate/style/index.css +3 -3
- package/es/rate/style/index.less +3 -9
- package/es/style/icon/kdicon.css +0 -1
- package/es/table/api.d.ts +4 -0
- package/es/table/api.js +162 -0
- package/es/table/feature/colGroupExtendable.d.ts +4 -0
- package/es/table/feature/colGroupExtendable.js +9 -0
- package/es/table/interface.d.ts +5 -1
- package/es/table/table.js +7 -9
- package/lib/date-picker/date-picker.js +2 -6
- package/lib/rate/style/index.css +3 -3
- package/lib/rate/style/index.less +3 -9
- package/lib/style/icon/kdicon.css +0 -1
- package/lib/table/api.d.ts +4 -0
- package/lib/table/api.js +171 -0
- package/lib/table/feature/colGroupExtendable.d.ts +4 -0
- package/lib/table/feature/colGroupExtendable.js +17 -0
- package/lib/table/interface.d.ts +5 -1
- package/lib/table/table.js +9 -9
- package/package.json +1 -1
|
@@ -85,7 +85,6 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
|
|
|
85
85
|
onClick = datePickerProps.onClick,
|
|
86
86
|
_onOk = datePickerProps.onOk; // ref
|
|
87
87
|
|
|
88
|
-
var panelDivRef = React.useRef(null);
|
|
89
88
|
var inputDivRefDefault = React.useRef(null);
|
|
90
89
|
var inputDivRef = ref || inputDivRefDefault;
|
|
91
90
|
var popperRefDefault = React.useRef(null);
|
|
@@ -244,9 +243,7 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
|
|
|
244
243
|
if (!openValue) {
|
|
245
244
|
setSelectedValue(dateValue);
|
|
246
245
|
|
|
247
|
-
if (valueText
|
|
248
|
-
triggerTextChange('');
|
|
249
|
-
} else if (valueText !== text) {
|
|
246
|
+
if (valueText !== text) {
|
|
250
247
|
resetText();
|
|
251
248
|
}
|
|
252
249
|
} else {
|
|
@@ -399,7 +396,7 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
|
|
|
399
396
|
|
|
400
397
|
var inputProps = {
|
|
401
398
|
inputRef: inputRef,
|
|
402
|
-
panelDivRef:
|
|
399
|
+
panelDivRef: popperRef,
|
|
403
400
|
id: id,
|
|
404
401
|
autoFocus: autoFocus,
|
|
405
402
|
allowClear: allowClear,
|
package/es/rate/style/index.css
CHANGED
|
@@ -120,13 +120,13 @@
|
|
|
120
120
|
-ms-flex-pack: start;
|
|
121
121
|
justify-content: flex-start;
|
|
122
122
|
}
|
|
123
|
-
.kd-rate-size-large
|
|
123
|
+
.kd-rate-size-large {
|
|
124
124
|
font-size: var(--kd-c-rate-font-size-large, 20px);
|
|
125
125
|
}
|
|
126
|
-
.kd-rate-size-middle
|
|
126
|
+
.kd-rate-size-middle {
|
|
127
127
|
font-size: var(--kd-c-rate-font-size-middle, 16px);
|
|
128
128
|
}
|
|
129
|
-
.kd-rate-size-small
|
|
129
|
+
.kd-rate-size-small {
|
|
130
130
|
font-size: var(--kd-c-rate-font-size-small, 12px);
|
|
131
131
|
}
|
|
132
132
|
.kd-rate-item {
|
package/es/rate/style/index.less
CHANGED
|
@@ -9,19 +9,13 @@
|
|
|
9
9
|
display: inline-flex;
|
|
10
10
|
justify-content: flex-start;
|
|
11
11
|
&-size-large {
|
|
12
|
-
|
|
13
|
-
font-size: @rate-large-font-size;
|
|
14
|
-
}
|
|
12
|
+
font-size: @rate-large-font-size;
|
|
15
13
|
}
|
|
16
14
|
&-size-middle {
|
|
17
|
-
|
|
18
|
-
font-size: @rate-middle-font-size;
|
|
19
|
-
}
|
|
15
|
+
font-size: @rate-middle-font-size;
|
|
20
16
|
}
|
|
21
17
|
&-size-small {
|
|
22
|
-
|
|
23
|
-
font-size: @rate-small-font-size;
|
|
24
|
-
}
|
|
18
|
+
font-size: @rate-small-font-size;
|
|
25
19
|
}
|
|
26
20
|
}
|
|
27
21
|
.@{rate-prefix-cls}-item {
|
package/es/style/icon/kdicon.css
CHANGED
package/es/table/api.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
2
|
+
import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
|
|
3
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
4
|
+
import { collectNodes } from '@kdcloudjs/table/es/table/utils';
|
|
5
|
+
import { rangeSelectionKey } from '@kdcloudjs/table/es/table/pipeline/features/rangeSelection';
|
|
6
|
+
export default function getApi(pipelineRef) {
|
|
7
|
+
function getColumns() {
|
|
8
|
+
var _a;
|
|
9
|
+
|
|
10
|
+
return (_a = pipelineRef.current.getColumns) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current)();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getDataSource() {
|
|
14
|
+
var _a;
|
|
15
|
+
|
|
16
|
+
return (_a = pipelineRef.current.getDataSource) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current)();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getFooterDataSource() {
|
|
20
|
+
var _a;
|
|
21
|
+
|
|
22
|
+
return (_a = pipelineRef.current.getFooterDataSource) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current)();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 清除范围选中内容
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
function clearRangeSelection() {
|
|
30
|
+
var pipeline = pipelineRef.current;
|
|
31
|
+
pipeline.setStateAtKey(rangeSelectionKey, null);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 将目标行滚动到可视位置
|
|
35
|
+
* @param rowIndex 行索引
|
|
36
|
+
* @param position 目标行滚动到的位置,不传则根据目标行相对视口的位置滚动到底部或顶部,可取值为'top' | 'middle' | 'bottom'
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
function ensureRowIndexVisible(rowIndex, position) {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
|
|
44
|
+
var pipeline = pipelineRef.current;
|
|
45
|
+
|
|
46
|
+
var _ref = (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.rowHeightManager,
|
|
47
|
+
cache = _ref.cache;
|
|
48
|
+
|
|
49
|
+
if (typeof rowIndex !== 'number' || rowIndex < 0 || rowIndex >= cache.length) {
|
|
50
|
+
console.warn('invalid row index for ensureIndexVisible: ' + rowIndex);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var tableBodyContainer = (_b = pipeline.ref) === null || _b === void 0 ? void 0 : _b.current.domHelper.tableBody;
|
|
55
|
+
if (!tableBodyContainer) return;
|
|
56
|
+
var rowTopPixel = 0;
|
|
57
|
+
|
|
58
|
+
for (var i = 0; i < rowIndex; i++) {
|
|
59
|
+
rowTopPixel += cache[i];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var rowBottomPixel = rowTopPixel + cache[rowIndex];
|
|
63
|
+
var viewportHeight = tableBodyContainer.clientHeight;
|
|
64
|
+
var vScrollTop = tableBodyContainer.scrollTop;
|
|
65
|
+
var vScrollBottom = vScrollTop + viewportHeight;
|
|
66
|
+
var pxTop = rowTopPixel;
|
|
67
|
+
var pxBottom = rowBottomPixel - viewportHeight;
|
|
68
|
+
var pxMiddle = Math.min((pxTop + pxBottom) / 2, rowTopPixel);
|
|
69
|
+
var rowBelowViewport = vScrollTop > rowTopPixel;
|
|
70
|
+
var rowAboveViewport = vScrollBottom < rowBottomPixel;
|
|
71
|
+
var newScrollPosition = null;
|
|
72
|
+
|
|
73
|
+
if (position === 'top') {
|
|
74
|
+
newScrollPosition = pxTop;
|
|
75
|
+
} else if (position === 'bottom') {
|
|
76
|
+
newScrollPosition = pxBottom;
|
|
77
|
+
} else if (position === 'middle') {
|
|
78
|
+
newScrollPosition = pxMiddle;
|
|
79
|
+
} else if (rowBelowViewport) {
|
|
80
|
+
// 目标行在视口之上,则向上滚动到顶部
|
|
81
|
+
newScrollPosition = pxTop;
|
|
82
|
+
} else if (rowAboveViewport) {
|
|
83
|
+
// 目标行在视口之下,则向下滚动到底部
|
|
84
|
+
newScrollPosition = pxBottom;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (newScrollPosition !== null) {
|
|
88
|
+
tableBodyContainer.scrollTop = newScrollPosition;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 将目标列滚动到可视位置
|
|
93
|
+
* @param code 列标识
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
function ensureColumnVisible(code) {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
|
|
101
|
+
var pipeline = pipelineRef.current;
|
|
102
|
+
var tableBodyContainer = (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.domHelper.tableBody;
|
|
103
|
+
var tableScroll = (_b = pipeline.ref) === null || _b === void 0 ? void 0 : _b.current.domHelper.stickyScroll;
|
|
104
|
+
var columnNodes = collectNodes(pipeline.getColumns(), 'leaf-only');
|
|
105
|
+
|
|
106
|
+
var column = _findInstanceProperty(columnNodes).call(columnNodes, function (col) {
|
|
107
|
+
return col.code === code;
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
var index = _findIndexInstanceProperty(columnNodes).call(columnNodes, function (col) {
|
|
111
|
+
return col.code === code;
|
|
112
|
+
}); // 固定列也不需要重置滚动条
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
if (!column || !tableBodyContainer || (column === null || column === void 0 ? void 0 : column.lock)) return;
|
|
116
|
+
|
|
117
|
+
var colLeft = _sliceInstanceProperty(columnNodes).call(columnNodes, 0, index).reduce(function (acc, col) {
|
|
118
|
+
return acc + col.width;
|
|
119
|
+
}, 0);
|
|
120
|
+
|
|
121
|
+
var colLeftPixel = colLeft; // 目标列前面列宽总和
|
|
122
|
+
|
|
123
|
+
var colRightPixel = colLeftPixel + column.width;
|
|
124
|
+
var viewportWidth = tableBodyContainer.clientWidth; // 表体容器的宽度
|
|
125
|
+
|
|
126
|
+
var scrollPosition = tableScroll.scrollLeft; // 滚动条滚动的距离
|
|
127
|
+
|
|
128
|
+
var vScrollLeft = scrollPosition;
|
|
129
|
+
var vScrollRight = scrollPosition + viewportWidth;
|
|
130
|
+
var pxLeft = colLeftPixel;
|
|
131
|
+
var pxRight = colRightPixel - viewportWidth;
|
|
132
|
+
var colBeforeViewport = vScrollLeft > colLeftPixel; // 滚动距离大于目标列前面列宽总和,说明目标列在视口之前
|
|
133
|
+
|
|
134
|
+
var colPastViewport = vScrollRight < colRightPixel; // 目标列是视口之后
|
|
135
|
+
|
|
136
|
+
var colToSmallForViewport = viewportWidth < column.width;
|
|
137
|
+
var alignColToLeft = colBeforeViewport || colToSmallForViewport;
|
|
138
|
+
var alignColToRight = colPastViewport;
|
|
139
|
+
|
|
140
|
+
if (alignColToLeft || alignColToRight) {
|
|
141
|
+
var newScrollPosition = alignColToLeft ? pxLeft : pxRight;
|
|
142
|
+
tableScroll.scrollLeft = newScrollPosition;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getHeightCache() {
|
|
147
|
+
var _a;
|
|
148
|
+
|
|
149
|
+
var pipeline = pipelineRef.current;
|
|
150
|
+
return (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.rowHeightManager.cache;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
getColumns: getColumns,
|
|
155
|
+
getDataSource: getDataSource,
|
|
156
|
+
getFooterDataSource: getFooterDataSource,
|
|
157
|
+
clearRangeSelection: clearRangeSelection,
|
|
158
|
+
ensureRowIndexVisible: ensureRowIndexVisible,
|
|
159
|
+
ensureColumnVisible: ensureColumnVisible,
|
|
160
|
+
getHeightCache: getHeightCache
|
|
161
|
+
};
|
|
162
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colGroupExtendOption } from '@kdcloudjs/table/es/table/pipeline/features';
|
|
2
|
+
import { TablePipeline } from '../interface';
|
|
3
|
+
declare function colGroupExtendable(pipeline: TablePipeline, columnGroupExtend: colGroupExtendOption): void;
|
|
4
|
+
export default colGroupExtendable;
|
package/es/table/interface.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableProps as BaseTableProps, TablePipeline as TP, ArtColumnStaticPart } from '@kdcloudjs/table';
|
|
3
|
-
import { SortFeatureOptions, RowDetailFeatureOptions, FilterFeatureOptions, TreeModeFeatureOptions, ColumnDragOptions, ColumnResizeOptions, ContextMenuFeatureOptions, RangeSelectionFeatureOptions } from '@kdcloudjs/table/es/table/pipeline/features';
|
|
3
|
+
import { SortFeatureOptions, RowDetailFeatureOptions, FilterFeatureOptions, TreeModeFeatureOptions, ColumnDragOptions, ColumnResizeOptions, ContextMenuFeatureOptions, RangeSelectionFeatureOptions, colGroupExtendOption } from '@kdcloudjs/table/es/table/pipeline/features';
|
|
4
4
|
declare type TablePropsOfComponents = Pick<BaseTableProps, 'components'> & {
|
|
5
5
|
components?: {
|
|
6
6
|
/** 复选框 */
|
|
@@ -15,6 +15,9 @@ export declare type TableApi = {
|
|
|
15
15
|
getDataSource: () => any[];
|
|
16
16
|
getFooterDataSource: () => any[];
|
|
17
17
|
clearRangeSelection: () => void;
|
|
18
|
+
getHeightCache: () => number[];
|
|
19
|
+
ensureRowIndexVisible: (rowIndex: number, position?: string | undefined) => void;
|
|
20
|
+
ensureColumnVisible: (code: string) => void;
|
|
18
21
|
};
|
|
19
22
|
export declare type TableInstance = {
|
|
20
23
|
api: TableApi;
|
|
@@ -31,6 +34,7 @@ export interface TableProps extends TablePropsOfExtend, TablePropsOfComponents {
|
|
|
31
34
|
columnResize?: boolean | ColumnResizeOptions;
|
|
32
35
|
contextMenu?: IContextMenu;
|
|
33
36
|
rangeSelection?: TableRangeSelection;
|
|
37
|
+
columnGroupExtend?: colGroupExtendOption;
|
|
34
38
|
}
|
|
35
39
|
export declare type RowSelectionType = 'checkbox' | 'radio';
|
|
36
40
|
export declare type RowSelectionFixed = 'start' | 'end';
|
package/es/table/table.js
CHANGED
|
@@ -21,6 +21,8 @@ import useRangeSelection from './feature/useRangeSelection';
|
|
|
21
21
|
import useMergeCellHover from './feature/mergeCellHover';
|
|
22
22
|
import devWarning from '../_utils/devwarning';
|
|
23
23
|
import useFooterDataSource from './feature/useFooterDataSource';
|
|
24
|
+
import usecolGroupExtendable from './feature/colGroupExtendable';
|
|
25
|
+
import getApi from './api';
|
|
24
26
|
var Table = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
25
27
|
var columns = props.columns,
|
|
26
28
|
dataSource = props.dataSource,
|
|
@@ -52,7 +54,9 @@ var Table = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
52
54
|
cssVariables = props.cssVariables,
|
|
53
55
|
stickyScrollHeight = props.stickyScrollHeight,
|
|
54
56
|
scrollbarWidth = props.scrollbarWidth,
|
|
55
|
-
scrollLoad = props.scrollLoad
|
|
57
|
+
scrollLoad = props.scrollLoad,
|
|
58
|
+
_props$columnGroupExt = props.columnGroupExtend,
|
|
59
|
+
columnGroupExtend = _props$columnGroupExt === void 0 ? {} : _props$columnGroupExt;
|
|
56
60
|
|
|
57
61
|
var _useContext = useContext(ConfigContext),
|
|
58
62
|
getPrefixCls = _useContext.getPrefixCls,
|
|
@@ -77,15 +81,8 @@ var Table = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
77
81
|
// }
|
|
78
82
|
|
|
79
83
|
useImperativeHandle(ref, function () {
|
|
80
|
-
var _a, _b, _c, _d;
|
|
81
|
-
|
|
82
84
|
return {
|
|
83
|
-
api:
|
|
84
|
-
getColumns: (_a = pipelineRef.current.getColumns) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current),
|
|
85
|
-
getDataSource: (_b = pipelineRef.current.getDataSource) === null || _b === void 0 ? void 0 : _b.bind(pipelineRef.current),
|
|
86
|
-
getFooterDataSource: (_c = pipelineRef.current.getFooterDataSource) === null || _c === void 0 ? void 0 : _c.bind(pipelineRef.current),
|
|
87
|
-
clearRangeSelection: (_d = pipelineRef.current.clearRangeSelection) === null || _d === void 0 ? void 0 : _d.bind(pipelineRef.current)
|
|
88
|
-
}
|
|
85
|
+
api: getApi(pipelineRef)
|
|
89
86
|
};
|
|
90
87
|
});
|
|
91
88
|
/* -------------------------------------------------------------------------- */
|
|
@@ -106,6 +103,7 @@ var Table = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
106
103
|
useRangeSelection(pipeline, rangeSelection);
|
|
107
104
|
useMergeCellHover(pipeline);
|
|
108
105
|
useFooterDataSource(pipeline, footerDataSource);
|
|
106
|
+
usecolGroupExtendable(pipeline, columnGroupExtend);
|
|
109
107
|
/* -------------------------------------------------------------------------- */
|
|
110
108
|
|
|
111
109
|
/* after useTablePipeline, merge pipeline.getProps result */
|
|
@@ -122,8 +122,6 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
|
|
|
122
122
|
onClick = datePickerProps.onClick,
|
|
123
123
|
_onOk = datePickerProps.onOk; // ref
|
|
124
124
|
|
|
125
|
-
var panelDivRef = _react.default.useRef(null);
|
|
126
|
-
|
|
127
125
|
var inputDivRefDefault = _react.default.useRef(null);
|
|
128
126
|
|
|
129
127
|
var inputDivRef = ref || inputDivRefDefault;
|
|
@@ -285,9 +283,7 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
|
|
|
285
283
|
if (!openValue) {
|
|
286
284
|
setSelectedValue(dateValue);
|
|
287
285
|
|
|
288
|
-
if (valueText
|
|
289
|
-
triggerTextChange('');
|
|
290
|
-
} else if (valueText !== text) {
|
|
286
|
+
if (valueText !== text) {
|
|
291
287
|
resetText();
|
|
292
288
|
}
|
|
293
289
|
} else {
|
|
@@ -439,7 +435,7 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
|
|
|
439
435
|
|
|
440
436
|
var inputProps = {
|
|
441
437
|
inputRef: inputRef,
|
|
442
|
-
panelDivRef:
|
|
438
|
+
panelDivRef: popperRef,
|
|
443
439
|
id: id,
|
|
444
440
|
autoFocus: autoFocus,
|
|
445
441
|
allowClear: allowClear,
|
package/lib/rate/style/index.css
CHANGED
|
@@ -120,13 +120,13 @@
|
|
|
120
120
|
-ms-flex-pack: start;
|
|
121
121
|
justify-content: flex-start;
|
|
122
122
|
}
|
|
123
|
-
.kd-rate-size-large
|
|
123
|
+
.kd-rate-size-large {
|
|
124
124
|
font-size: var(--kd-c-rate-font-size-large, 20px);
|
|
125
125
|
}
|
|
126
|
-
.kd-rate-size-middle
|
|
126
|
+
.kd-rate-size-middle {
|
|
127
127
|
font-size: var(--kd-c-rate-font-size-middle, 16px);
|
|
128
128
|
}
|
|
129
|
-
.kd-rate-size-small
|
|
129
|
+
.kd-rate-size-small {
|
|
130
130
|
font-size: var(--kd-c-rate-font-size-small, 12px);
|
|
131
131
|
}
|
|
132
132
|
.kd-rate-item {
|
|
@@ -9,19 +9,13 @@
|
|
|
9
9
|
display: inline-flex;
|
|
10
10
|
justify-content: flex-start;
|
|
11
11
|
&-size-large {
|
|
12
|
-
|
|
13
|
-
font-size: @rate-large-font-size;
|
|
14
|
-
}
|
|
12
|
+
font-size: @rate-large-font-size;
|
|
15
13
|
}
|
|
16
14
|
&-size-middle {
|
|
17
|
-
|
|
18
|
-
font-size: @rate-middle-font-size;
|
|
19
|
-
}
|
|
15
|
+
font-size: @rate-middle-font-size;
|
|
20
16
|
}
|
|
21
17
|
&-size-small {
|
|
22
|
-
|
|
23
|
-
font-size: @rate-small-font-size;
|
|
24
|
-
}
|
|
18
|
+
font-size: @rate-small-font-size;
|
|
25
19
|
}
|
|
26
20
|
}
|
|
27
21
|
.@{rate-prefix-cls}-item {
|
package/lib/table/api.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = getApi;
|
|
9
|
+
|
|
10
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
11
|
+
|
|
12
|
+
var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
|
|
13
|
+
|
|
14
|
+
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
15
|
+
|
|
16
|
+
var _utils = require("@kdcloudjs/table/es/table/utils");
|
|
17
|
+
|
|
18
|
+
var _rangeSelection = require("@kdcloudjs/table/es/table/pipeline/features/rangeSelection");
|
|
19
|
+
|
|
20
|
+
function getApi(pipelineRef) {
|
|
21
|
+
function getColumns() {
|
|
22
|
+
var _a;
|
|
23
|
+
|
|
24
|
+
return (_a = pipelineRef.current.getColumns) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current)();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getDataSource() {
|
|
28
|
+
var _a;
|
|
29
|
+
|
|
30
|
+
return (_a = pipelineRef.current.getDataSource) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current)();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getFooterDataSource() {
|
|
34
|
+
var _a;
|
|
35
|
+
|
|
36
|
+
return (_a = pipelineRef.current.getFooterDataSource) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current)();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 清除范围选中内容
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
function clearRangeSelection() {
|
|
44
|
+
var pipeline = pipelineRef.current;
|
|
45
|
+
pipeline.setStateAtKey(_rangeSelection.rangeSelectionKey, null);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 将目标行滚动到可视位置
|
|
49
|
+
* @param rowIndex 行索引
|
|
50
|
+
* @param position 目标行滚动到的位置,不传则根据目标行相对视口的位置滚动到底部或顶部,可取值为'top' | 'middle' | 'bottom'
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
function ensureRowIndexVisible(rowIndex, position) {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
|
|
58
|
+
var pipeline = pipelineRef.current;
|
|
59
|
+
|
|
60
|
+
var _ref = (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.rowHeightManager,
|
|
61
|
+
cache = _ref.cache;
|
|
62
|
+
|
|
63
|
+
if (typeof rowIndex !== 'number' || rowIndex < 0 || rowIndex >= cache.length) {
|
|
64
|
+
console.warn('invalid row index for ensureIndexVisible: ' + rowIndex);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var tableBodyContainer = (_b = pipeline.ref) === null || _b === void 0 ? void 0 : _b.current.domHelper.tableBody;
|
|
69
|
+
if (!tableBodyContainer) return;
|
|
70
|
+
var rowTopPixel = 0;
|
|
71
|
+
|
|
72
|
+
for (var i = 0; i < rowIndex; i++) {
|
|
73
|
+
rowTopPixel += cache[i];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var rowBottomPixel = rowTopPixel + cache[rowIndex];
|
|
77
|
+
var viewportHeight = tableBodyContainer.clientHeight;
|
|
78
|
+
var vScrollTop = tableBodyContainer.scrollTop;
|
|
79
|
+
var vScrollBottom = vScrollTop + viewportHeight;
|
|
80
|
+
var pxTop = rowTopPixel;
|
|
81
|
+
var pxBottom = rowBottomPixel - viewportHeight;
|
|
82
|
+
var pxMiddle = Math.min((pxTop + pxBottom) / 2, rowTopPixel);
|
|
83
|
+
var rowBelowViewport = vScrollTop > rowTopPixel;
|
|
84
|
+
var rowAboveViewport = vScrollBottom < rowBottomPixel;
|
|
85
|
+
var newScrollPosition = null;
|
|
86
|
+
|
|
87
|
+
if (position === 'top') {
|
|
88
|
+
newScrollPosition = pxTop;
|
|
89
|
+
} else if (position === 'bottom') {
|
|
90
|
+
newScrollPosition = pxBottom;
|
|
91
|
+
} else if (position === 'middle') {
|
|
92
|
+
newScrollPosition = pxMiddle;
|
|
93
|
+
} else if (rowBelowViewport) {
|
|
94
|
+
// 目标行在视口之上,则向上滚动到顶部
|
|
95
|
+
newScrollPosition = pxTop;
|
|
96
|
+
} else if (rowAboveViewport) {
|
|
97
|
+
// 目标行在视口之下,则向下滚动到底部
|
|
98
|
+
newScrollPosition = pxBottom;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (newScrollPosition !== null) {
|
|
102
|
+
tableBodyContainer.scrollTop = newScrollPosition;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 将目标列滚动到可视位置
|
|
107
|
+
* @param code 列标识
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
function ensureColumnVisible(code) {
|
|
113
|
+
var _a, _b;
|
|
114
|
+
|
|
115
|
+
var pipeline = pipelineRef.current;
|
|
116
|
+
var tableBodyContainer = (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.domHelper.tableBody;
|
|
117
|
+
var tableScroll = (_b = pipeline.ref) === null || _b === void 0 ? void 0 : _b.current.domHelper.stickyScroll;
|
|
118
|
+
var columnNodes = (0, _utils.collectNodes)(pipeline.getColumns(), 'leaf-only');
|
|
119
|
+
var column = (0, _find.default)(columnNodes).call(columnNodes, function (col) {
|
|
120
|
+
return col.code === code;
|
|
121
|
+
});
|
|
122
|
+
var index = (0, _findIndex.default)(columnNodes).call(columnNodes, function (col) {
|
|
123
|
+
return col.code === code;
|
|
124
|
+
}); // 固定列也不需要重置滚动条
|
|
125
|
+
|
|
126
|
+
if (!column || !tableBodyContainer || (column === null || column === void 0 ? void 0 : column.lock)) return;
|
|
127
|
+
var colLeft = (0, _slice.default)(columnNodes).call(columnNodes, 0, index).reduce(function (acc, col) {
|
|
128
|
+
return acc + col.width;
|
|
129
|
+
}, 0);
|
|
130
|
+
var colLeftPixel = colLeft; // 目标列前面列宽总和
|
|
131
|
+
|
|
132
|
+
var colRightPixel = colLeftPixel + column.width;
|
|
133
|
+
var viewportWidth = tableBodyContainer.clientWidth; // 表体容器的宽度
|
|
134
|
+
|
|
135
|
+
var scrollPosition = tableScroll.scrollLeft; // 滚动条滚动的距离
|
|
136
|
+
|
|
137
|
+
var vScrollLeft = scrollPosition;
|
|
138
|
+
var vScrollRight = scrollPosition + viewportWidth;
|
|
139
|
+
var pxLeft = colLeftPixel;
|
|
140
|
+
var pxRight = colRightPixel - viewportWidth;
|
|
141
|
+
var colBeforeViewport = vScrollLeft > colLeftPixel; // 滚动距离大于目标列前面列宽总和,说明目标列在视口之前
|
|
142
|
+
|
|
143
|
+
var colPastViewport = vScrollRight < colRightPixel; // 目标列是视口之后
|
|
144
|
+
|
|
145
|
+
var colToSmallForViewport = viewportWidth < column.width;
|
|
146
|
+
var alignColToLeft = colBeforeViewport || colToSmallForViewport;
|
|
147
|
+
var alignColToRight = colPastViewport;
|
|
148
|
+
|
|
149
|
+
if (alignColToLeft || alignColToRight) {
|
|
150
|
+
var newScrollPosition = alignColToLeft ? pxLeft : pxRight;
|
|
151
|
+
tableScroll.scrollLeft = newScrollPosition;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function getHeightCache() {
|
|
156
|
+
var _a;
|
|
157
|
+
|
|
158
|
+
var pipeline = pipelineRef.current;
|
|
159
|
+
return (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.rowHeightManager.cache;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
getColumns: getColumns,
|
|
164
|
+
getDataSource: getDataSource,
|
|
165
|
+
getFooterDataSource: getFooterDataSource,
|
|
166
|
+
clearRangeSelection: clearRangeSelection,
|
|
167
|
+
ensureRowIndexVisible: ensureRowIndexVisible,
|
|
168
|
+
ensureColumnVisible: ensureColumnVisible,
|
|
169
|
+
getHeightCache: getHeightCache
|
|
170
|
+
};
|
|
171
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colGroupExtendOption } from '@kdcloudjs/table/es/table/pipeline/features';
|
|
2
|
+
import { TablePipeline } from '../interface';
|
|
3
|
+
declare function colGroupExtendable(pipeline: TablePipeline, columnGroupExtend: colGroupExtendOption): void;
|
|
4
|
+
export default colGroupExtendable;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _table = require("@kdcloudjs/table");
|
|
9
|
+
|
|
10
|
+
function colGroupExtendable(pipeline, columnGroupExtend) {
|
|
11
|
+
if (columnGroupExtend) {
|
|
12
|
+
pipeline.use(_table.features.colGroupExtendable(columnGroupExtend));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var _default = colGroupExtendable;
|
|
17
|
+
exports.default = _default;
|
package/lib/table/interface.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableProps as BaseTableProps, TablePipeline as TP, ArtColumnStaticPart } from '@kdcloudjs/table';
|
|
3
|
-
import { SortFeatureOptions, RowDetailFeatureOptions, FilterFeatureOptions, TreeModeFeatureOptions, ColumnDragOptions, ColumnResizeOptions, ContextMenuFeatureOptions, RangeSelectionFeatureOptions } from '@kdcloudjs/table/es/table/pipeline/features';
|
|
3
|
+
import { SortFeatureOptions, RowDetailFeatureOptions, FilterFeatureOptions, TreeModeFeatureOptions, ColumnDragOptions, ColumnResizeOptions, ContextMenuFeatureOptions, RangeSelectionFeatureOptions, colGroupExtendOption } from '@kdcloudjs/table/es/table/pipeline/features';
|
|
4
4
|
declare type TablePropsOfComponents = Pick<BaseTableProps, 'components'> & {
|
|
5
5
|
components?: {
|
|
6
6
|
/** 复选框 */
|
|
@@ -15,6 +15,9 @@ export declare type TableApi = {
|
|
|
15
15
|
getDataSource: () => any[];
|
|
16
16
|
getFooterDataSource: () => any[];
|
|
17
17
|
clearRangeSelection: () => void;
|
|
18
|
+
getHeightCache: () => number[];
|
|
19
|
+
ensureRowIndexVisible: (rowIndex: number, position?: string | undefined) => void;
|
|
20
|
+
ensureColumnVisible: (code: string) => void;
|
|
18
21
|
};
|
|
19
22
|
export declare type TableInstance = {
|
|
20
23
|
api: TableApi;
|
|
@@ -31,6 +34,7 @@ export interface TableProps extends TablePropsOfExtend, TablePropsOfComponents {
|
|
|
31
34
|
columnResize?: boolean | ColumnResizeOptions;
|
|
32
35
|
contextMenu?: IContextMenu;
|
|
33
36
|
rangeSelection?: TableRangeSelection;
|
|
37
|
+
columnGroupExtend?: colGroupExtendOption;
|
|
34
38
|
}
|
|
35
39
|
export declare type RowSelectionType = 'checkbox' | 'radio';
|
|
36
40
|
export declare type RowSelectionFixed = 'start' | 'end';
|