Skip to content

Commit 2a22ccb

Browse files
authored
Merge branch 'master' into feat-tablesheet-muliheaders
2 parents fec687e + c15f8c8 commit 2a22ccb

28 files changed

+719
-52
lines changed

packages/s2-core/CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# [@antv/s2-v1.46.0](https://github.com/antvis/S2/compare/@antv/s2-v1.45.1...@antv/s2-v1.46.0) (2023-05-15)
2+
3+
4+
### Bug Fixes
5+
6+
* 修复 meta name 同名时,hoverFocus 出错的问题 ([#2187](https://github.com/antvis/S2/issues/2187)) ([a2d7a81](https://github.com/antvis/S2/commit/a2d7a8162e4a177bf593af463e4bb7a4b0e96fc7))
7+
* 修复总计小计被意外 format 的问题 ([#2209](https://github.com/antvis/S2/issues/2209)) ([6e98291](https://github.com/antvis/S2/commit/6e982917d15ad66d6caecac6da30050527811875))
8+
* 复制时移除空控制符 ([#2204](https://github.com/antvis/S2/issues/2204)) ([ce9dcab](https://github.com/antvis/S2/commit/ce9dcab8ffe00cec60fe412ce7a71aa00541dc13))
9+
* 系统拦截快捷键后多选交互异常 ([#2191](https://github.com/antvis/S2/issues/2191)) ([6a8b85a](https://github.com/antvis/S2/commit/6a8b85ab59ebf2ce9f03e4a3aaa841c251654eb3))
10+
11+
12+
### Features
13+
14+
* 行列头和数值为空时,不渲染表格框架 ([#2207](https://github.com/antvis/S2/issues/2207)) ([1a404e1](https://github.com/antvis/S2/commit/1a404e1ec256298801222dacd318a57ba890dbcd))
15+
116
# [@antv/s2-v1.45.1](https://github.com/antvis/S2/compare/@antv/s2-v1.45.0...@antv/s2-v1.45.1) (2023-04-28)
217

318

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* eslint-disable @typescript-eslint/ban-ts-comment */
2+
/**
3+
* @description spec for issue #1781
4+
* https://github.com/antvis/S2/issues/1781
5+
*/
6+
7+
import { getContainer, sleep } from '../util/helpers';
8+
import * as mockDataConfig from '../data/simple-table-data.json';
9+
import {
10+
OriginEventType,
11+
S2Event,
12+
type S2DataConfig,
13+
type S2Options,
14+
} from '@/index';
15+
import { TableSheet } from '@/sheet-type';
16+
17+
const s2DataConfig: S2DataConfig = {
18+
...mockDataConfig,
19+
meta: [
20+
{
21+
field: 'province',
22+
name: '一样的名字',
23+
},
24+
{
25+
field: 'city',
26+
name: '一样的名字',
27+
},
28+
],
29+
};
30+
31+
const s2Options: S2Options = {
32+
width: 800,
33+
height: 400,
34+
};
35+
36+
describe('Hover Focus Tests', () => {
37+
const s2 = new TableSheet(getContainer(), s2DataConfig, s2Options);
38+
39+
s2.render();
40+
41+
test(`should focus on province cell but don't focus on city cell when hover on province cell`, async () => {
42+
await sleep(3000);
43+
44+
// 浙江省份信息
45+
const provinceCell = s2.panelScrollGroup.getChildByIndex(7);
46+
47+
// 义乌城市信息
48+
const cityCell = s2.panelScrollGroup.getChildByIndex(10);
49+
50+
const event = new MouseEvent(OriginEventType.MOUSE_MOVE);
51+
52+
// @ts-ignore
53+
s2.emit(S2Event.DATA_CELL_HOVER, { ...event, target: provinceCell });
54+
55+
expect(
56+
// @ts-ignore
57+
provinceCell.stateShapes.get('interactiveBorderShape')?.cfg.visible,
58+
).toBeTrue();
59+
expect(
60+
// @ts-ignore
61+
cityCell.stateShapes.get('interactiveBorderShape')?.cfg.visible,
62+
).toBeFalse();
63+
});
64+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* 字段代码中有方括号,无法拖拽调整该字段所在列的宽度
3+
* 描述应当调整为:字段代码中有方括号,无法使用 `xxxByField` 配置调整该字段的布局
4+
* @description spec for issue #2195
5+
* https://github.com/antvis/S2/issues/2195
6+
*/
7+
8+
import { getContainer } from '../util/helpers';
9+
import type { S2Options } from '@/index';
10+
import { PivotSheet } from '@/sheet-type';
11+
12+
const modifiedMockDataConfig = {
13+
fields: {
14+
rows: ['province', '[city]'],
15+
columns: ['type'],
16+
values: ['price', 'cost'],
17+
valueInCols: true,
18+
},
19+
data: [
20+
{
21+
province: '浙江',
22+
'[city]': '义乌',
23+
type: '笔',
24+
price: 1,
25+
cost: 2,
26+
},
27+
{
28+
province: '浙江',
29+
'[city]': '义乌',
30+
type: '笔',
31+
price: 1,
32+
cost: 2,
33+
},
34+
{
35+
province: '浙江',
36+
'[city]': '杭州',
37+
type: '笔',
38+
price: 1,
39+
cost: 2,
40+
},
41+
],
42+
};
43+
44+
const s2Options: S2Options = {
45+
width: 400,
46+
height: 400,
47+
frozenRowHeader: false,
48+
style: {
49+
rowCfg: {
50+
widthByField: {
51+
province: 300,
52+
'[city]': 123,
53+
},
54+
},
55+
},
56+
};
57+
58+
describe('Field surrounded by square brackets Tests', () => {
59+
const s2 = new PivotSheet(getContainer(), modifiedMockDataConfig, s2Options);
60+
s2.render();
61+
62+
test('should render correctly when use field surrounded by square brackets', () => {
63+
s2.facet.layoutResult.rowNodes
64+
.filter((node) => node.field === '[city]')
65+
.forEach((node) => {
66+
expect(node.width).toEqual(123);
67+
});
68+
});
69+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* @description spec for issue #2199
3+
* https://github.com/antvis/S2/issues/2199
4+
* 明细表: 当有冻结列 + 列分组的情况下, 会出现列头文本不居中现象
5+
*/
6+
import { getContainer } from 'tests/util/helpers';
7+
import dataCfg from '../data/data-issue-2199.json';
8+
import { TableSheet } from '@/sheet-type';
9+
import type { S2Options } from '@/common/interface';
10+
11+
const s2Options: S2Options = {
12+
width: 300,
13+
height: 480,
14+
showSeriesNumber: true,
15+
frozenColCount: 1,
16+
};
17+
18+
describe('ColCell Text Center Tests', () => {
19+
test('should draw text centered in cell', () => {
20+
const s2 = new TableSheet(getContainer(), dataCfg, s2Options);
21+
s2.render();
22+
23+
s2.facet.updateScrollOffset({ offsetX: { value: 500, animate: false } });
24+
25+
const node = s2.getColumnNodes(0).slice(-1)?.[0];
26+
const cell = node?.belongsCell;
27+
const { width: nodeWidth, x: nodeX } = node;
28+
const { width: textWidth, x: textXActual } = cell.getContentArea();
29+
const textXCalc = nodeX + (nodeWidth - textWidth) / 2;
30+
expect(textXCalc).toBeCloseTo(textXActual);
31+
});
32+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"fields": {
3+
"columns": [
4+
{
5+
"key": "area",
6+
"children": ["province", "city"]
7+
},
8+
"type",
9+
{
10+
"key": "money",
11+
"children": [
12+
{
13+
"key": "price"
14+
}
15+
]
16+
}
17+
]
18+
},
19+
"meta": [
20+
{
21+
"field": "province",
22+
"name": "省份"
23+
},
24+
{
25+
"field": "city",
26+
"name": "城市"
27+
},
28+
{
29+
"field": "type",
30+
"name": "商品类别"
31+
},
32+
{
33+
"field": "price",
34+
"name": "价格"
35+
},
36+
{
37+
"field": "cost",
38+
"name": "成本"
39+
},
40+
{
41+
"field": "area",
42+
"name": "位置"
43+
},
44+
{
45+
"field": "money",
46+
"name": "金额"
47+
}
48+
],
49+
"data": [
50+
{
51+
"province": "浙江",
52+
"city": "杭州",
53+
"type": "",
54+
"price": 1
55+
},
56+
{
57+
"province": "浙江",
58+
"city": "杭州",
59+
"type": "纸张",
60+
"price": 2
61+
},
62+
{
63+
"province": "浙江",
64+
"city": "舟山",
65+
"type": "",
66+
"price": 17
67+
},
68+
{
69+
"province": "浙江",
70+
"city": "舟山",
71+
"type": "纸张",
72+
"price": 6
73+
},
74+
{
75+
"province": "吉林",
76+
"city": "长春",
77+
"type": "",
78+
"price": 8
79+
},
80+
{
81+
"province": "吉林",
82+
"city": "白山",
83+
"type": "",
84+
"price": 12
85+
},
86+
{
87+
"province": "吉林",
88+
"city": "长春",
89+
"type": "纸张",
90+
"price": 3
91+
},
92+
{
93+
"province": "吉林",
94+
"city": "白山",
95+
"type": "纸张",
96+
"price": 25
97+
},
98+
{
99+
"province": "浙江",
100+
"city": "杭州",
101+
"type": "",
102+
"price": 20
103+
},
104+
{
105+
"province": "浙江",
106+
"city": "杭州",
107+
"type": "纸张",
108+
"price": 10
109+
},
110+
{
111+
"province": "浙江",
112+
"city": "舟山",
113+
"type": "",
114+
"price": 15
115+
},
116+
{
117+
"province": "浙江",
118+
"city": "舟山",
119+
"type": "纸张",
120+
"price": 2
121+
},
122+
{
123+
"province": "吉林",
124+
"city": "长春",
125+
"type": "",
126+
"price": 15
127+
},
128+
{
129+
"province": "吉林",
130+
"city": "白山",
131+
"type": "",
132+
"price": 30
133+
},
134+
{
135+
"province": "吉林",
136+
"city": "长春",
137+
"type": "纸张",
138+
"price": 40
139+
},
140+
{
141+
"province": "吉林",
142+
"city": "白山",
143+
"type": "纸张",
144+
"price": 50
145+
}
146+
]
147+
}

packages/s2-core/__tests__/spreadsheet/scroll-spec.ts

+31-3
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ describe('Scroll Tests', () => {
636636
).toBeFalsy();
637637
});
638638

639-
test('should scroll horizontally when shift key is held', async () => {
639+
test('should scroll horizontally when shift key is held on Windows', async () => {
640640
s2.setOptions({
641641
frozenRowHeader: true,
642642
style: {
@@ -671,13 +671,41 @@ describe('Scroll Tests', () => {
671671
shiftKey: true,
672672
});
673673

674-
canvas.dispatchEvent(wheelEvent);
674+
Object.defineProperty(window.navigator, 'userAgent', {
675+
value: 'Windows',
676+
configurable: true,
677+
writable: true,
678+
});
675679

680+
canvas.dispatchEvent(wheelEvent);
676681
await sleep(200);
677-
678682
expect(onScroll).toHaveBeenCalled();
679683
});
680684

685+
test('should not scroll horizontally when shift key is held on macOS', async () => {
686+
const onScroll = jest.fn((...args) => {
687+
expect(args[0].rowHeaderScrollX).toBeGreaterThan(0);
688+
expect(args[0].scrollX).toBe(0);
689+
expect(args[0].scrollY).toBe(0);
690+
});
691+
692+
const wheelEvent = new WheelEvent('wheel', {
693+
deltaX: 0,
694+
deltaY: 20,
695+
shiftKey: true,
696+
});
697+
698+
Object.defineProperty(window.navigator, 'userAgent', {
699+
value: 'Mac OS',
700+
configurable: true,
701+
writable: true,
702+
});
703+
704+
canvas.dispatchEvent(wheelEvent);
705+
await sleep(200);
706+
expect(onScroll).not.toHaveBeenCalled();
707+
});
708+
681709
it('should not change init body overscrollBehavior style when render and destroyed', () => {
682710
document.body.style.overscrollBehavior = 'none';
683711

0 commit comments

Comments
 (0)