Skip to content

Commit e67bcff

Browse files
committed
Merge remote-tracking branch 'origin/master' into release-v1.7.0
2 parents 921c59b + 9c8657d commit e67bcff

File tree

10 files changed

+85
-25
lines changed

10 files changed

+85
-25
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"react:playground": "yarn workspace @antv/s2-react start",
2828
"react:build": "yarn workspace @antv/s2-react build",
2929
"react:test": "yarn workspace @antv/s2-react test",
30+
"react:watch": " yarn workspace @antv/s2-react watch",
3031
"build": "lerna run build --include-dependencies --stream --concurrency 1",
3132
"build:umd": "lerna run build:umd --include-dependencies --stream --concurrency 1",
3233
"bundle:size": "lerna run bundle:size --stream",

packages/s2-core/src/cell/row-cell.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export class RowCell extends HeaderCell {
116116
if (!isCollapsed) {
117117
const oldScrollY = this.spreadsheet.store.get('scrollY');
118118
// 可视窗口高度
119-
const viewportHeight = this.spreadsheet.facet.panelBBox.height || 0;
119+
const viewportHeight =
120+
this.spreadsheet.facet.panelBBox.viewportHeight || 0;
120121
// 被折叠项的高度
121122
const deleteHeight = getAllChildrenNodeHeight(this.meta);
122123
// 折叠后真实高度
@@ -213,7 +214,7 @@ export class RowCell extends HeaderCell {
213214
position,
214215
seriesNumberWidth,
215216
width: headerWidth,
216-
height: headerHeight,
217+
viewportHeight: headerHeight,
217218
scrollX,
218219
scrollY,
219220
} = this.headerConfig;
@@ -343,7 +344,7 @@ export class RowCell extends HeaderCell {
343344

344345
protected getTextPosition(): Point {
345346
const { y, height: contentHeight } = this.getContentArea();
346-
const { scrollY, height } = this.headerConfig;
347+
const { scrollY, viewportHeight: height } = this.headerConfig;
347348

348349
const { fontSize } = this.getTextStyle();
349350
const textIndent = this.getTextIndent();

packages/s2-core/src/facet/base-facet.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,16 +1052,18 @@ export abstract class BaseFacet {
10521052

10531053
this.rowHeader = this.getRowHeader();
10541054
this.columnHeader = this.getColHeader();
1055-
if (seriesNumberWidth > 0 && this.rowIndexHeader) {
1055+
if (seriesNumberWidth > 0 && !this.rowIndexHeader) {
10561056
this.rowIndexHeader = this.getSeriesNumberHeader();
1057-
this.foregroundGroup.add(this.rowIndexHeader);
10581057
}
10591058
this.cornerHeader = this.getCornerHeader();
10601059
this.centerFrame = this.getCenterFrame();
10611060

10621061
if (this.rowHeader) {
10631062
this.foregroundGroup.add(this.rowHeader);
10641063
}
1064+
if (this.rowIndexHeader) {
1065+
this.foregroundGroup.add(this.rowIndexHeader);
1066+
}
10651067
this.foregroundGroup.add(this.columnHeader);
10661068
this.foregroundGroup.add(this.cornerHeader);
10671069
this.foregroundGroup.add(this.centerFrame);

packages/s2-core/src/facet/header/row.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class RowHeader extends BaseHeader<RowHeaderConfig> {
3838
data,
3939
spreadsheet,
4040
width,
41-
height,
41+
viewportHeight,
4242
seriesNumberWidth,
4343
scrollY,
4444
scrollX,
@@ -48,7 +48,7 @@ export class RowHeader extends BaseHeader<RowHeaderConfig> {
4848
// row'cell only show when visible
4949
const rowCellInRect = (item: Node): boolean => {
5050
return (
51-
height + scrollY > item.y && // bottom
51+
viewportHeight + scrollY > item.y && // bottom
5252
scrollY < item.y + item.height && // top
5353
width - seriesNumberWidth + scrollX > item.x && // left
5454
scrollX - seriesNumberWidth < item.x + item.width
@@ -84,7 +84,7 @@ export class RowHeader extends BaseHeader<RowHeaderConfig> {
8484
}
8585

8686
protected clip(): void {
87-
const { width, height, scrollX, scrollY, seriesNumberWidth } =
87+
const { width, viewportHeight, scrollX, scrollY, seriesNumberWidth } =
8888
this.headerConfig;
8989
this.setClip({
9090
type: 'rect',
@@ -93,7 +93,7 @@ export class RowHeader extends BaseHeader<RowHeaderConfig> {
9393
x: scrollX - seriesNumberWidth,
9494
y: scrollY,
9595
width,
96-
height,
96+
height: viewportHeight,
9797
},
9898
});
9999
}

packages/s2-core/src/facet/header/series-number.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { BBox, Group, IGroup, IShape } from '@antv/g-canvas';
1+
import { Group, IGroup, IShape } from '@antv/g-canvas';
22
import { each } from 'lodash';
33
import { getBorderPositionAndStyle } from 'src/utils/cell/cell';
44
import { translateGroup } from '../utils';
5+
import { PanelBBox } from '../bbox/panelBBox';
56
import { BaseHeader, BaseHeaderConfig } from './base';
67
import { Node } from '@/facet/layout/node';
78
import { SpreadSheet } from '@/sheet-type/index';
@@ -25,13 +26,13 @@ export class SeriesNumberHeader extends BaseHeader<BaseHeaderConfig> {
2526
*/
2627

2728
public static getSeriesNumberHeader(
28-
viewportBBox: BBox,
29+
viewportBBox: PanelBBox,
2930
seriesNumberWidth: number,
3031
leafNodes: Node[],
3132
spreadsheet: SpreadSheet,
3233
cornerWidth: number,
3334
): SeriesNumberHeader {
34-
const { width, height } = viewportBBox;
35+
const { height, viewportHeight } = viewportBBox;
3536
const seriesNodes: Node[] = [];
3637
const isHierarchyTreeType = spreadsheet.isHierarchyTreeType();
3738
leafNodes.forEach((node: Node): void => {
@@ -53,8 +54,8 @@ export class SeriesNumberHeader extends BaseHeader<BaseHeaderConfig> {
5354
return new SeriesNumberHeader({
5455
width: cornerWidth,
5556
height,
56-
viewportWidth: width,
57-
viewportHeight: height,
57+
viewportWidth: cornerWidth,
58+
viewportHeight: viewportHeight,
5859
position: { x: 0, y: viewportBBox.y },
5960
data: seriesNodes,
6061
spreadsheet,
@@ -65,10 +66,21 @@ export class SeriesNumberHeader extends BaseHeader<BaseHeaderConfig> {
6566
super(cfg);
6667
}
6768

68-
public clip(): void {}
69+
public clip(): void {
70+
const { width, viewportHeight, scrollY } = this.headerConfig;
71+
this.setClip({
72+
type: 'rect',
73+
attrs: {
74+
x: 0,
75+
y: scrollY,
76+
width,
77+
height: viewportHeight,
78+
},
79+
});
80+
}
6981

7082
public layout() {
71-
const { data, scrollY, height, spreadsheet } = this.headerConfig;
83+
const { data, scrollY, viewportHeight, spreadsheet } = this.headerConfig;
7284
if (spreadsheet.isPivotMode) {
7385
// 添加矩形背景
7486
this.addBackGround();
@@ -81,7 +93,7 @@ export class SeriesNumberHeader extends BaseHeader<BaseHeaderConfig> {
8193
y,
8294
cellHeight,
8395
scrollY,
84-
height,
96+
viewportHeight,
8597
);
8698
if (isHeaderCellInViewport) {
8799
// 按需渲染:视窗内的才渲染
@@ -113,13 +125,13 @@ export class SeriesNumberHeader extends BaseHeader<BaseHeaderConfig> {
113125

114126
private addBackGround() {
115127
const rowCellTheme = this.headerConfig.spreadsheet.theme.rowCell.cell;
116-
const { position, width, height } = this.headerConfig;
128+
const { position, width, viewportHeight } = this.headerConfig;
117129

118130
this.backgroundShape = renderRect(this, {
119131
x: position.x,
120132
y: -position.y,
121133
width,
122-
height,
134+
height: viewportHeight,
123135
fill: rowCellTheme.backgroundColor,
124136
stroke: 'transparent',
125137
opacity: rowCellTheme.backgroundColorOpacity,
@@ -132,7 +144,7 @@ export class SeriesNumberHeader extends BaseHeader<BaseHeaderConfig> {
132144
x: position.x,
133145
y: -position.y,
134146
width,
135-
height,
147+
height: viewportHeight,
136148
},
137149
rowCellTheme,
138150
);
@@ -150,7 +162,7 @@ export class SeriesNumberHeader extends BaseHeader<BaseHeaderConfig> {
150162
}
151163

152164
private addText(group: IGroup, cellData: ViewMeta) {
153-
const { scrollY, height } = this.headerConfig;
165+
const { scrollY, viewportHeight: height } = this.headerConfig;
154166
const rowCellTheme = this.headerConfig.spreadsheet.theme.rowCell;
155167
const {
156168
label,

packages/s2-core/src/facet/pivot-facet.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,8 @@ export class PivotFacet extends BaseFacet {
786786
},
787787

788788
getTotalLength: () => {
789-
return heights.length;
789+
// 多了一个数据 [0]
790+
return heights.length - 1;
790791
},
791792

792793
getIndexRange: (minHeight: number, maxHeight: number) => {

packages/s2-core/src/utils/facet.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ export const getSubTotalNodeWidthOrHeightByLevel = (
1212
.reduce((sum, current) => sum + current, 0);
1313
};
1414

15+
/**
16+
* 根据视窗高度计算需要展示的数据数组下标
17+
* 如有2个节点,每个高度30
18+
* @param heights 所有单元格的高度偏移量数组 [0, 30, 60]
19+
* @param minHeight 视窗高度起点
20+
* @param maxHeight 视窗高度终点
21+
* @returns
22+
*/
1523
export const getIndexRangeWithOffsets = (
1624
heights: number[],
1725
minHeight: number,
@@ -32,7 +40,7 @@ export const getIndexRangeWithOffsets = (
3240
heights,
3341
(height: number, idx: number) => {
3442
const y = maxHeight;
35-
return y >= height && y < heights[idx + 1];
43+
return y > height && y <= heights[idx + 1];
3644
},
3745
yMin,
3846
);

packages/s2-react/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"build:analysis": "cross-env FORMAT=es ANALYSIS=true vite build",
4545
"build:declaration": "ttsc -p tsconfig-declaration.json",
4646
"bundle:size": "bundlesize",
47+
"watch": "rimraf esm && concurrently \"yarn build:esm -w\" \"yarn build:declaration -w\"",
4748
"test": "jest",
4849
"test:live": "node ./scripts/test-live.mjs",
4950
"test:coverage": "yarn test --coverage",
@@ -65,6 +66,7 @@
6566
"devDependencies": {
6667
"@types/react-beautiful-dnd": "^13.1.2",
6768
"antd": "^4.16.13",
69+
"concurrently": "^7.0.0",
6870
"react": "^17.0.2",
6971
"react-dom": "^17.0.2"
7072
},

packages/s2-react/src/components/sheets/base-sheet/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ export const BaseSheet: React.FC<BaseSheetProps> = memo((props) => {
292292
setLoading(false);
293293
setOwnSpreadsheet(baseSpreadsheet.current);
294294
getSpreadSheet?.(baseSpreadsheet.current);
295+
setTotal(
296+
options?.pagination?.total ??
297+
baseSpreadsheet.current.facet.viewCellHeights.getTotalLength(),
298+
);
295299
};
296300

297301
useEffect(() => {

yarn.lock

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,6 +4146,20 @@ concat-with-sourcemaps@^1.1.0:
41464146
dependencies:
41474147
source-map "^0.6.1"
41484148

4149+
concurrently@^7.0.0:
4150+
version "7.0.0"
4151+
resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-7.0.0.tgz#78d31b441cec338dab03316c221a2f9a67c529b0"
4152+
integrity sha512-WKM7PUsI8wyXpF80H+zjHP32fsgsHNQfPLw/e70Z5dYkV7hF+rf8q3D+ScWJIEr57CpkO3OWBko6hwhQLPR8Pw==
4153+
dependencies:
4154+
chalk "^4.1.0"
4155+
date-fns "^2.16.1"
4156+
lodash "^4.17.21"
4157+
rxjs "^6.6.3"
4158+
spawn-command "^0.0.2-1"
4159+
supports-color "^8.1.0"
4160+
tree-kill "^1.2.2"
4161+
yargs "^16.2.0"
4162+
41494163
config-chain@^1.1.11, config-chain@^1.1.12:
41504164
version "1.1.13"
41514165
resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.13.tgz#fad0795aa6a6cdaff9ed1b68e9dff94372c232f4"
@@ -4663,6 +4677,11 @@ [email protected]:
46634677
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.26.0.tgz#fa45305543c392c4f914e50775fd2a4461e60fbd"
46644678
integrity sha512-VQI812dRi3cusdY/fhoBKvc6l2W8BPWU1FNVnFH9Nttjx4AFBRzfSVb/Eyc7jBT6e9sg1XtAGsYpBQ6c/jygbg==
46654679

4680+
date-fns@^2.16.1:
4681+
version "2.28.0"
4682+
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.28.0.tgz#9570d656f5fc13143e50c975a3b6bbeb46cd08b2"
4683+
integrity sha512-8d35hViGYx/QH0icHYCeLmsLmMUheMmTyV9Fcm6gvNwdw31yXXH+O85sOBJ+OLnLQMKZowvpKb6FgMIQjcpvQw==
4684+
46664685
dateformat@^3.0.0:
46674686
version "3.0.3"
46684687
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
@@ -12304,7 +12323,7 @@ rw@1:
1230412323
resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4"
1230512324
integrity sha1-P4Yt+pGrdmsUiF700BEkv9oHT7Q=
1230612325

12307-
rxjs@^6.6.0, rxjs@^6.6.2:
12326+
rxjs@^6.6.0, rxjs@^6.6.2, rxjs@^6.6.3:
1230812327
version "6.6.7"
1230912328
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.7.tgz#90ac018acabf491bf65044235d5863c4dab804c9"
1231012329
integrity sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==
@@ -12747,6 +12766,11 @@ sourcemap-codec@^1.4.4:
1274712766
resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
1274812767
integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==
1274912768

12769+
spawn-command@^0.0.2-1:
12770+
version "0.0.2-1"
12771+
resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0"
12772+
integrity sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A=
12773+
1275012774
spawn-error-forwarder@~1.0.0:
1275112775
version "1.0.0"
1275212776
resolved "https://registry.yarnpkg.com/spawn-error-forwarder/-/spawn-error-forwarder-1.0.0.tgz#1afd94738e999b0346d7b9fc373be55e07577029"
@@ -13211,7 +13235,7 @@ sumchecker@^3.0.1:
1321113235
dependencies:
1321213236
debug "^4.1.0"
1321313237

13214-
13238+
[email protected], supports-color@^8.1.0:
1321513239
version "8.1.1"
1321613240
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c"
1321713241
integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==
@@ -13565,6 +13589,11 @@ traverse@~0.6.6:
1356513589
resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137"
1356613590
integrity sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc=
1356713591

13592+
tree-kill@^1.2.2:
13593+
version "1.2.2"
13594+
resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc"
13595+
integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==
13596+
1356813597
treeverse@^1.0.4:
1356913598
version "1.0.4"
1357013599
resolved "https://registry.yarnpkg.com/treeverse/-/treeverse-1.0.4.tgz#a6b0ebf98a1bca6846ddc7ecbc900df08cb9cd5f"

0 commit comments

Comments
 (0)