Skip to content

Commit

Permalink
refactor: 调整 s2Options API 命名 (#2015)
Browse files Browse the repository at this point in the history
* refactor: 调整 s2Options API 命名

s2Options.tooltip.(row|col|data) => s2Options.tooltip.(rowCell|colCell|dataCell)
s2Options.style.(rowCfg|colCfg|cellCfg) => s2Options.style.(rowCell|colCell|dataCell)

BREAKING CHANGE: s2Options.tooltip 和 s2Options.style API 命名更改, 移除 trend 操作项

* refactor: tree 相关配置移动到 rowCell 下

* refactor: hideMeasureColumn => hideValue

* refactor: 冻结相关配置收拢到 forzen 命名空间下

* test: 修复测试
  • Loading branch information
lijinke666 authored Dec 28, 2022
1 parent 6592ede commit e39b32f
Show file tree
Hide file tree
Showing 165 changed files with 2,667 additions and 2,445 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"build:umd": "lerna run build:umd --include-dependencies --stream",
"bundle:size": "lerna run bundle:size --stream",
"release": "lerna exec --ignore @antv/s2-shared --concurrency 1 -- npx --no-install semantic-release",
"release:bump-latest":"node ./scripts/latest-bump-version.js",
"release:bump-latest": "node ./scripts/latest-bump-version.js",
"release:preview": "yarn release --dry-run --no-ci",
"prepublish:manual": "yarn build",
"publish:manual": "lerna publish",
Expand Down Expand Up @@ -177,5 +177,6 @@
"vite-plugin-imp": "^2.3.1",
"vue-jest": "^5.0.0-alpha.10"
},
"license": "MIT"
}
"license": "MIT",
"repository": "[email protected]:antvis/S2.git"
}
2,076 changes: 1,037 additions & 1,039 deletions packages/s2-core/CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/s2-core/__tests__/bugs/issue-1014-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const s2options: S2Options = {
width: 300,
height: 200,
style: {
colCfg: {
colCell: {
height: 60,
},
cellCfg: {
dataCell: {
width: 100,
height: 50,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-core/__tests__/bugs/issue-1191-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const s2options: S2Options = {
width: 300,
height: 200,
style: {
colCfg: {
colCell: {
height: 60,
},
cellCfg: {
dataCell: {
width: 100,
height: 50,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-core/__tests__/bugs/issue-1764-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const s2Options: S2Options = {
height: 400,
style: {
// 显示滚动条
cellCfg: {
dataCell: {
width: 200,
},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-core/__tests__/bugs/issue-720-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const s2Options: S2Options = {
width: 200,
height: 200,
style: {
colCfg: {
colCell: {
height: 60,
},
cellCfg: {
dataCell: {
width: 100,
height: 50,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-core/__tests__/bugs/issue-840-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const s2Options: S2Options = {
width: 300,
height: 200,
style: {
colCfg: {
colCell: {
height: 60,
},
cellCfg: {
dataCell: {
width: 100,
height: 50,
},
Expand Down
4 changes: 3 additions & 1 deletion packages/s2-core/__tests__/bugs/issue-860-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import type { S2Options } from '@/common/interface';
const s2Options: S2Options = {
width: 600,
height: 400,
frozenRowHeader: false,
frozen: {
rowHeader: false,
},
};

describe('Empty String Row Value Tests', () => {
Expand Down
70 changes: 35 additions & 35 deletions packages/s2-core/__tests__/spreadsheet/custom-cell-style-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
const sheet = createPivotSheet({
...s2Options,
style: {
cellCfg: {
dataCell: {
width: 300,
height: 90,
},
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
test('should get custom row cell style', () => {
s2.setOptions({
style: {
rowCfg: {
rowCell: {
width: 50,
height: 60,
},
Expand All @@ -94,7 +94,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
test('should get custom row cell style by custom hook', () => {
s2.setOptions({
style: {
rowCfg: {
rowCell: {
width: (node) => {
expect(node?.id).toInclude('root[&]浙江');
return 100;
Expand All @@ -114,7 +114,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
test('should get custom row cell style by field', () => {
s2.setOptions({
style: {
rowCfg: {
rowCell: {
widthByField: {
city: 66,
},
Expand All @@ -134,7 +134,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {

s2.setOptions({
style: {
rowCfg: {
rowCell: {
widthByField: {
[cityId]: 50,
},
Expand All @@ -157,7 +157,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {

s2.setOptions({
style: {
rowCfg: {
rowCell: {
widthByField: {
province: width,
[provinceId]: width,
Expand All @@ -182,36 +182,36 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
});
});

test('should get custom row cell style priority by rowCfg.heightByField > rowCfg.height > cellCfg.height', () => {
test('should get custom row cell style priority by rowCell.heightByField > rowCell.height > dataCell.height', () => {
const sheet = createPivotSheet({
...s2Options,
style: {
rowCfg: {
rowCell: {
heightByField: {
city: 40,
},
height: 20,
},
cellCfg: {
dataCell: {
height: 50,
},
},
});
sheet.render();

// 1. rowCfg.heightByField > rowCfg.height > cellCfg.height
// 1. rowCell.heightByField > rowCell.height > dataCell.height
sheet.getRowLeafNodes().forEach((node) => {
expect(node.height).toEqual(40);
});

// 2. rowCfg.height > cellCfg.height
// 2. rowCell.height > dataCell.height
sheet.setOptions(
{
style: {
rowCfg: {
rowCell: {
height: 20,
},
cellCfg: {
dataCell: {
height: 50,
},
},
Expand All @@ -225,13 +225,13 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
});
});

test('should get custom row cell style priority by treeRowsWidth > rowCfg.width', () => {
test('should get custom row cell style priority by rowCell.treeWidth > rowCell.width', () => {
const sheet = createPivotSheet({
...s2Options,
hierarchyType: 'tree',
style: {
treeRowsWidth: 200,
rowCfg: {
rowCell: {
treeWidth: 200,
width: 100,
height: 30,
},
Expand All @@ -250,7 +250,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
test('should get custom col cell style', () => {
s2.setOptions({
style: {
colCfg: {
colCell: {
width: 50,
height: 60,
},
Expand All @@ -264,7 +264,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
test('should get custom col cell style by custom hook', () => {
s2.setOptions({
style: {
colCfg: {
colCell: {
width: (node) => {
expect(node?.id).toInclude('root[&]笔');
return 100;
Expand All @@ -284,7 +284,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
test('should get custom col cell style by field', () => {
s2.setOptions({
style: {
colCfg: {
colCell: {
widthByField: {
sub_type: 66,
},
Expand All @@ -304,7 +304,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {

s2.setOptions({
style: {
colCfg: {
colCell: {
widthByField: {
[priceId]: 50,
},
Expand All @@ -327,7 +327,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {

s2.setOptions({
style: {
colCfg: {
colCell: {
widthByField: {
sub_type: width,
[subTypeId]: width,
Expand All @@ -352,36 +352,36 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
});
});

test('should get custom col cell style priority by colCfg.widthByField > colCfg.width > cellCfg.width', () => {
test('should get custom col cell style priority by colCell.widthByField > colCell.width > dataCell.width', () => {
const sheet = createPivotSheet({
...s2Options,
style: {
colCfg: {
colCell: {
width: 200,
widthByField: {
[EXTRA_FIELD]: 300,
},
},
cellCfg: {
dataCell: {
width: 100,
},
},
});
sheet.render();

// 1. colCfg.widthByField > colCfg.width > cellCfg.width
// 1. colCell.widthByField > colCell.width > dataCell.width
sheet.getColumnLeafNodes().forEach((node) => {
expect(node.width).toEqual(300);
});

// 2. colCfg.width > cellCfg.width
// 2. colCell.width > dataCell.width
sheet.setOptions(
{
style: {
colCfg: {
colCell: {
width: 200,
},
cellCfg: {
dataCell: {
width: 100,
},
},
Expand All @@ -399,8 +399,8 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
const sheet = createPivotSheet({
...s2Options,
style: {
colCfg: {
hideMeasureColumn: true,
colCell: {
hideValue: true,
widthByField: {
'root[&]笔': 100,
},
Expand Down Expand Up @@ -443,7 +443,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
test('should set row cell style by height', () => {
s2.setOptions({
style: {
rowCfg: {
rowCell: {
height: 60,
},
},
Expand All @@ -462,7 +462,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
test('should set row cell style by row index', () => {
s2.setOptions({
style: {
rowCfg: {
rowCell: {
heightByField: {
0: 40,
'2': 100,
Expand All @@ -484,7 +484,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
test('should set col cell style by width', () => {
s2.setOptions({
style: {
colCfg: {
colCell: {
width: 100,
},
},
Expand All @@ -500,7 +500,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
});
sheet.setOptions({
style: {
colCfg: {
colCell: {
widthByField: {
type: 50,
sub_type: 120,
Expand All @@ -519,7 +519,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
});
sheet.setOptions({
style: {
colCfg: {
colCell: {
widthByField: {
'root[&]类别': 100,
'root[&]子类别': 200,
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-core/__tests__/spreadsheet/custom-grid-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('SpreadSheet Custom Grid Tests', () => {
test('should calc correctly leaf nodes width after row resized', () => {
s2.setOptions({
style: {
rowCfg: {
rowCell: {
widthByField: {
'a-1-1': 40,
},
Expand Down Expand Up @@ -234,7 +234,7 @@ describe('SpreadSheet Custom Grid Tests', () => {
test('should calc correctly leaf nodes width after column resized', () => {
s2.setOptions({
style: {
colCfg: {
colCell: {
heightByField: {
'a-1-1': 40,
},
Expand Down
8 changes: 6 additions & 2 deletions packages/s2-core/__tests__/spreadsheet/custom-tree-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const s2Options: S2Options = {
height: 400,
hierarchyType: 'tree',
style: {
treeRowsWidth: 400,
rowCell: {
treeWidth: 400,
},
},
};

Expand Down Expand Up @@ -194,7 +196,9 @@ describe('SpreadSheet Custom Tree Tests', () => {
test('should render custom tree row node width', () => {
s2.setOptions({
style: {
treeRowsWidth: 50,
rowCell: {
treeWidth: 50,
},
},
});

Expand Down
Loading

0 comments on commit e39b32f

Please sign in to comment.