Skip to content

Commit

Permalink
chore: alpha 合并到 master (#1286)
Browse files Browse the repository at this point in the history
* chore(release): 🔖@antv/[email protected]  @antv/[email protected]

* chore(release): 🔖 @antv/[email protected]  @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.3.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.3.0 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.4.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.4.0 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.5.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.5.0 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected] (#1003)

* chore(release): 🤖 @antv/s2-v1.6.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.6.0 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected] (#1046)

* chore(release): 🤖 @antv/s2-v1.7.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.7.0 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.8.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.8.0 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.9.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.9.0 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.9.1 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.9.1 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.10.0-alpha.1 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.10.0-alpha.1 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.10.0-alpha.2 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.10.0-alpha.2 [skip ci]

* chore: 🤖 更新 lock 和 changelog 文件 (#1101)

* chore(release): 🔖@antv/[email protected]  @antv/[email protected]

* chore(release): 🔖 @antv/[email protected]  @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.3.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.3.0 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.4.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.4.0 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.5.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.5.0 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected] (#1003)

* chore(release): 🤖 @antv/s2-v1.6.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.6.0 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected] (#1046)

* chore(release): 🤖 @antv/s2-v1.7.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.7.0 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.8.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.8.0 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.9.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.9.0 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.9.1 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.9.1 [skip ci]

* chore: 🤖 更新 lock 和 changelog 文件

Co-authored-by: yingying.xwy <[email protected]>
Co-authored-by: semantic-release-bot <[email protected]>
Co-authored-by: xinhui.zxh <[email protected]>
Co-authored-by: wengyidong.wyd <[email protected]>
Co-authored-by: YardWill <[email protected]>
Co-authored-by: Jinke Li <[email protected]>

* feat(interaction): 透视表支持隐藏列头 (#1081)

* feat(interaction): 透视表支持隐藏列头

* fix: 修复默认隐藏不生效

* docs: 修改文档错别字

* docs: 优化文档

* test: 修复测试

* style(drilldown): 下钻组件增加自定义dom节点 (#1102)

* style(drilldown): 下钻组件增加自定义dom节点

* docs: 补充下钻配置文档

* fix: 修复行头为空无默认角头指标文字问题 (#1104)

* fix: 修复行头为空无默认角头指标文字问题

* test: 增加角头单元格文本单测

* style: 代码优化

* style: 代码优化

* feat(tooltip): tooltip 自定义操作项点击事件透出 cell 信息 close #1106 (#1107)

* feat(tooltip): tooltip 自定义操作项点击事件透出 cell 信息 close #1106

* docs: 完善文档

* fix: 不添加总计时错误地添加了小计节点 (#1111)

* fix: 不添加总计时错误地添加了小计节点

* test: 增加总计节点测试

* docs: 新增获取单元格数据文档 (#1117)

* fix: 增加行头收起展开按钮回调事件的透传参数 (#1121)

* fix: 增加行头收起展开按钮回调事件的透传参数

* test: 单测修复

* fix: 修复头部cell错误使用meta中formatter的问题,close #1014 (#1120)

* fix: 修复头部cell错误format问题

* test: 补充头部cell单测

* fix: 移除col cell中无用的formatter属性

* fix: 对于 extra 字段单独处理

* fix: 明细表锁行/列时分割线阴影显隐逻辑 (#1123)

* fix(facet): 明细表分界线阴影按需绘制

* fix(facet): 兼容分页情况

* fix(copy): 当异步复制失败时降级为同步复制 (#1125)

* fix(copy): 当异步复制失败时降级为同步复制

* docs: 更新文档

* docs: 更新demo

* test: 更新测试

* fix: rename

* test: 修复测试

* fix: 梳理单元格对齐方式, close #1084 (#1128)

* fix: 修复row cell 文本对齐

* fix: 修复corner cell 文本对齐

* refactor: remove unused import

* docs: shrink icon size

* docs: add custom alignment docs

* docs: add alt for img

* docs: add space between word and Chinese

* feat: ✨ 支持覆盖默认icon (#1130)

* fix: corner 事件监听失效(之前只有点击文字时生效) (#1131)

* fix: 修复对全局鼠标按下事件的污染 (#1132)

* fix(interaction): 修复开启复制后, 无法复制表格外的文字 (#1134)

* fix(interaction): 修复开启复制后, 无法复制表格外的文字

* chore: 语法问题

* docs: 新增如何提问 faq (#1118)

* docs: 新增如何提问 faq

* chore: 更新 pr reviewers

* chore: 润湿文档 & s2options => s2Options

* feat: ✨ 允许用户自定义行头单元格宽度 (#1135)

* feat: 维度切换组件增加allowEmpty配置 close #533 (#1136)

* feat: add allowEmpty config for switcher

* docs: update swithcer docs for allow empty config

* docs: add demo gif in docs

* feat: adaptive 的 container 自适应包含 header 和 page (#1133)

* feat: adaptive 的 container 自适应包含 header 和 page

* refactor: adaptive 自适应,使用flex 替代直接获取 element height的方式

* fix: 修复单测报错,1 changeSize 命名 g-base 重复,导致部分代码调用出错。2 添加 wrapper 参数

* test: adaptive 为 false 时,options width 和 height 改变不需要触发 changeSheetSize 方法

* refactor: 添加 changeSize 别名方法,兼容线上使用

* refactor: 样式合并

* feat(tooltip): 支持自定义挂载节点 (#1139)

* feat(tooltip): 支持自定义挂载节点

* test: 修复测试

* test: 修改测试断言描述

* test: 修复测试

* test: 修复测试

* fix: 修复未开启tooltip, 还是会渲染 container 节点的问题

* test: 修复测试

* chore(release): @antv/[email protected] @antv/[email protected] (#1141)

* chore(release): 🤖 @antv/s2-v1.10.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.10.0 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.11.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.11.0 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected] (#1168)

* chore(release): 🤖 @antv/s2-v1.12.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.11.1 [skip ci]

* chore(release): 🔖@antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.12.1 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-react-v1.11.2 [skip ci]

* fix: 指标列头对齐样式修复升级

* fix: 指标列头对齐样式修复升级

* chore(release): 🔖@antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.12.2 [skip ci]

* chore(release): 🔖@antv/[email protected]

* chore(release): 🤖 @antv/s2-react-v1.11.3 [skip ci]

* feat: 增加根据主题色生成对应主题风格色板功能

* fix: 修复lint报错

* chore(release): @antv/[email protected] @antv/[email protected] (#1198)

* chore(release): 🤖 @antv/s2-v1.13.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.12.0 [skip ci]

* feat: 固定背景色

* chore(release): @antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.14.0-alpha.1 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.13.0-alpha.1 [skip ci]

* chore(release): 🔖@antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.13.1 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.12.1 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.14.0-alpha.2 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.13.0-alpha.2 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-react-v1.13.0-alpha.3 [skip ci]

* refactor: 改用hsl颜色

* chore: type

* feat: hsl分量作用方式从
绝对比例改为各自区间相对比例

* chore(release): @antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.14.0-alpha.3 [skip ci]

* feat: 增加搜索高亮交互状态及主题色 (#1240)

* feat: 增加搜索高亮交互状态及主题色

* chore: 修改默认主题值

* chore: 修改版本号

* chore(release): 🔖@antv/[email protected]   @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.14.0-alpha.4 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.13.0-alpha.4 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected] (#1247)

* chore(release): 🤖 @antv/s2-v1.14.0 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.13.0 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.15.0-alpha.1 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.14.0-alpha.1 [skip ci]

* fix(s2): 如果是 table mode,列头不需要被格式化 (#1249)

* fix(s2): 如果是 table mode,列头不需要被格式化

* fix(s2): 添加明细和聚合模式下,表头的格式化单测

* chore(release): @antv/s2-v1.15.0-alpha.2

* chore(release): 🤖 @antv/s2-v1.15.0-alpha.2 [skip ci]

* chore(release): @antv/[email protected]

* chore(release): 🤖 @antv/s2-react-v1.14.0-alpha.2 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.15.0-alpha.3 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.14.0-alpha.3 [skip ci]

* fix: 添加当多个数值在行头显示时,小计展示被遮挡的问题 (#1267)

* fix: 优先计算样本坐标和宽度

* refactor: 删除 sampleNodeByLevel 这个中间变量,因为本质还是修改 sampleNodesForAllLevels 的引用

* test: 添加当多个数值在行头显示时,小计展示位置单测

* chore(release): @antv/s2-v1.15.0-alpha.4

* chore(release): @antv/s2-v1.15.0-alpha.4

* chore(release): 🤖 @antv/s2-v1.15.0-alpha.4 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.14.0-alpha.4 [skip ci]

* chore(release): @antv/[email protected] @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.15.0-alpha.5 [skip ci]

* fix: 为第一个子层级时,parentNode.id === ROOT_ID 时,不需要通过分割获取当前节点的真实 value (#1285)

* chore(release): @antv/[email protected]

* chore(release): 🤖 @antv/s2-v1.15.0-alpha.6 [skip ci]

* chore(release): 🤖 @antv/s2-react-v1.14.0-alpha.5 [skip ci]

Co-authored-by: yingying.xwy <[email protected]>
Co-authored-by: semantic-release-bot <[email protected]>
Co-authored-by: xinhui.zxh <[email protected]>
Co-authored-by: wengyidong.wyd <[email protected]>
Co-authored-by: YardWill <[email protected]>
Co-authored-by: Jinke Li <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: 刘嘉一 <[email protected]>
Co-authored-by: Wenjun Xu <[email protected]>
  • Loading branch information
10 people authored Apr 22, 2022
1 parent 17c5780 commit c261d3f
Show file tree
Hide file tree
Showing 18 changed files with 1,922 additions and 1,599 deletions.
2,149 changes: 1,137 additions & 1,012 deletions packages/s2-core/CHANGELOG.md

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions packages/s2-core/__tests__/bugs/issue-368-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,38 @@ describe('Total Cells Rendering Test', () => {
expect(colSubTotalNodes[0].x).toEqual(192);
expect(colSubTotalNodes[0].y).toEqual(30);
});

test('should get right SubTotals position when valueInCols is false', () => {
s2.setDataCfg({
...mockDataConfig,
fields: {
...mockDataConfig.fields,
valueInCols: false,
},
});
s2.setOptions({
...s2Options,
totals: {
...s2Options.totals,
row: {
...s2Options.totals.row,
subTotalsDimensions: ['row0'],
},
},
});

s2.render();

const layoutResult = s2.facet.layoutResult;
const rowSubTotalNodes = layoutResult.rowsHierarchy
.getNodes()
.filter((node: Node) => node.isSubTotals);
const rowSubTotalChildNode = rowSubTotalNodes[0].children[0];

expect(rowSubTotalNodes[0].x).toEqual(96);
expect(rowSubTotalNodes[0].y).toEqual(60);

expect(rowSubTotalChildNode.x).toEqual(288);
expect(rowSubTotalChildNode.y).toEqual(60);
});
});
3 changes: 2 additions & 1 deletion packages/s2-core/__tests__/unit/cell/header-cell-spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { PivotSheet, SpreadSheet, TableSheet } from '@/sheet-type';
import { PivotDataSet, TableDataSet } from '@/data-set';
import { Formatter } from '@/common';

import { ColCell, CornerCell, RowCell, TableColCell } from '@/cell';
import { Node } from '@/facet/layout/node';
import { BaseFacet, TableFacet } from '@/facet';
import { TableFacet } from '@/facet';

const MockPivotSheet = PivotSheet as unknown as jest.Mock<PivotSheet>;
const MockPivotDataSet = PivotDataSet as unknown as jest.Mock<PivotDataSet>;
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/s2",
"version": "1.12.4",
"version": "1.15.0-alpha.6",
"main": "lib/index.js",
"module": "esm/index.js",
"unpkg": "dist/index.min.js",
Expand Down
31 changes: 25 additions & 6 deletions packages/s2-core/src/cell/data-cell.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IShape, Point } from '@antv/g-canvas';
import { clamp, findLast, first, get, isEmpty, isEqual } from 'lodash';
import { clamp, findLast, first, get, isEmpty, isEqual, find } from 'lodash';
import { BaseCell } from '@/cell/base-cell';
import {
CellTypes,
Expand Down Expand Up @@ -55,9 +55,27 @@ export class DataCell extends BaseCell<ViewMeta> {
return CellTypes.DATA_CELL;
}

protected handlePrepareSelect(cells: CellMeta[]) {
protected handleByStateName(
cells: CellMeta[],
stateName: InteractionStateName,
) {
if (includeCell(cells, this)) {
this.updateByState(InteractionStateName.PREPARE_SELECT);
this.updateByState(stateName);
}
}

protected handleSearchResult(cells: CellMeta[]) {
if (!includeCell(cells, this)) {
return;
}
const targetCell = find(
cells,
(cell: CellMeta) => cell?.isTarget,
) as CellMeta;
if (targetCell.id === this.getMeta().id) {
this.updateByState(InteractionStateName.HIGHLIGHT);
} else {
this.updateByState(InteractionStateName.SEARCH_RESULT);
}
}

Expand Down Expand Up @@ -129,17 +147,18 @@ export class DataCell extends BaseCell<ViewMeta> {
}

switch (stateName) {
case InteractionStateName.PREPARE_SELECT:
this.handlePrepareSelect(cells);
break;
case InteractionStateName.SELECTED:
this.handleSelect(cells);
break;
case InteractionStateName.HOVER_FOCUS:
case InteractionStateName.HOVER:
this.handleHover(cells);
break;
case InteractionStateName.SEARCH_RESULT:
this.handleSearchResult(cells);
break;
default:
this.handleByStateName(cells, stateName);
break;
}
}
Expand Down
33 changes: 32 additions & 1 deletion packages/s2-core/src/cell/header-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { S2Event } from '@/common/constant';
import { CellTypes } from '@/common/constant';
import { getSortTypeIcon } from '@/utils/sort-action';
import { SortParam } from '@/common/interface';
import { TableColCell } from '@/cell/table-col-cell';

export abstract class HeaderCell extends BaseCell<Node> {
protected headerConfig: BaseHeaderConfig;
Expand Down Expand Up @@ -58,7 +59,9 @@ export abstract class HeaderCell extends BaseCell<Node> {
this.meta.field,
);

if (formatter) {
const isTableMode = this.spreadsheet.isTableMode();
// 如果是 table mode,列头不需要被格式化
if (formatter && !isTableMode) {
content = formatter(label);
}

Expand Down Expand Up @@ -208,6 +211,30 @@ export abstract class HeaderCell extends BaseCell<Node> {
return isMaxLevel && this.cellType === CellTypes.ROW_CELL;
}

protected handleByStateName(
cells: CellMeta[],
stateName: InteractionStateName,
) {
if (includeCell(cells, this)) {
this.updateByState(stateName);
}
}

protected handleSearchResult(cells: CellMeta[]) {
if (!includeCell(cells, this)) {
return;
}
const targetCell = find(
cells,
(cell: CellMeta) => cell?.isTarget,
) as CellMeta;
if (targetCell.id === this.getMeta().id) {
this.updateByState(InteractionStateName.HIGHLIGHT);
} else {
this.updateByState(InteractionStateName.SEARCH_RESULT);
}
}

protected handleHover(cells: CellMeta[]) {
if (includeCell(cells, this)) {
this.updateByState(InteractionStateName.HOVER);
Expand Down Expand Up @@ -255,7 +282,11 @@ export abstract class HeaderCell extends BaseCell<Node> {
case InteractionStateName.HOVER:
this.handleHover(cells);
break;
case InteractionStateName.SEARCH_RESULT:
this.handleSearchResult(cells);
break;
default:
this.handleByStateName(cells, stateInfo?.stateName);
break;
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/s2-core/src/common/constant/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export enum InteractionStateName {
UNSELECTED = 'unselected',
HOVER = 'hover',
HOVER_FOCUS = 'hoverFocus',
HIGHLIGHT = 'highlight',
SEARCH_RESULT = 'searchResult',
PREPARE_SELECT = 'prepareSelect',
}

Expand Down
1 change: 1 addition & 0 deletions packages/s2-core/src/common/interface/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface CellMeta {
colIndex: number;
rowIndex: number;
type: CellTypes;
[key: string]: unknown;
}

export interface InteractionStateInfo {
Expand Down
6 changes: 5 additions & 1 deletion packages/s2-core/src/common/interface/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export interface PaletteMeta {
green?: string;
[key: string]: string;
};
/* 补充色值 */
others?: {
[key: string]: string;
};
}

export interface Palette extends PaletteMeta {
Expand Down Expand Up @@ -252,7 +256,7 @@ export interface ThemeCfg {
/* 主题 */
theme?: S2Theme;
/* 色板 */
palette?: Pick<Palette, 'basicColors' | 'semanticColors'>;
palette?: Pick<Palette, 'basicColors' | 'semanticColors' | 'others'>;
/* 主题名 */
name?: ThemeName;
}
14 changes: 10 additions & 4 deletions packages/s2-core/src/facet/layout/build-row-tree-hierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,19 @@ export const buildRowTreeHierarchy = (params: TreeHeaderParams) => {
const isDrillDownItem = spreadsheet.dataCfg.fields.rows?.length <= level;
const sortedDimensionValues =
(dataSet as PivotDataSet)?.sortedDimensionValues?.[currentField] || [];
const dimensions = sortedDimensionValues?.filter((item) =>
item?.includes(id?.split(`${ROOT_ID}${ID_SEPARATOR}`)[1]),
);

// 为第一个子层级时,parentNode.id === ROOT_ID 时,不需要通过分割获取当前节点的真实 value
const dimensions =
ROOT_ID === id
? sortedDimensionValues
: sortedDimensionValues?.filter((item) =>
item?.includes(id?.split(`${ROOT_ID}${ID_SEPARATOR}`)[1]),
);

const dimValues = filterUndefined(
getListBySorted(
[...(pivotMeta.keys() || [])],
[...getDimensionsWithoutPathPre(dimensions)],
[...getDimensionsWithoutPathPre([...dimensions])],
),
);

Expand Down
13 changes: 9 additions & 4 deletions packages/s2-core/src/facet/pivot-facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ export class PivotFacet extends BaseFacet {
'options.style.rowCfg.heightByField',
{},
);
const sampleNodeByLevel = new Map();

const sampleNodeByLevel = rowsHierarchy.sampleNodesForAllLevels ?? [];

// 1、calculate first node's width in every level
if (isTree) {
Expand All @@ -390,7 +391,11 @@ export class PivotFacet extends BaseFacet {
colLeafNodes,
);
rowsHierarchy.width += levelSample.width;
sampleNodeByLevel.set(levelSample.level, levelSample);
const preLevelSample = sampleNodeByLevel[levelSample.level - 1] ?? {
x: 0,
width: 0,
};
levelSample.x = preLevelSample?.x + preLevelSample?.width;
}
}

Expand Down Expand Up @@ -420,7 +425,7 @@ export class PivotFacet extends BaseFacet {
if (isTree || currentNode.level === 0) {
currentNode.x = 0;
} else {
const preLevelSample = sampleNodeByLevel.get(currentNode.level - 1);
const preLevelSample = sampleNodeByLevel[currentNode.level - 1];
currentNode.x = preLevelSample?.x + preLevelSample?.width;
}

Expand All @@ -429,7 +434,7 @@ export class PivotFacet extends BaseFacet {
currentNode.width = this.getTreeRowHeaderWidth();
} else {
// same level -> same width
const levelSampleNode = sampleNodeByLevel.get(currentNode.level);
const levelSampleNode = sampleNodeByLevel[currentNode.level];
currentNode.width = levelSampleNode?.width;
}

Expand Down
39 changes: 36 additions & 3 deletions packages/s2-core/src/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import { getPalette } from '../utils/theme';
export const getTheme = (
themeCfg: Omit<ThemeCfg, 'theme'> & { spreadsheet?: SpreadSheet },
): S2Theme => {
const { basicColors, semanticColors } =
themeCfg?.palette || getPalette(themeCfg?.name);
const {
basicColors,
semanticColors,
others: otherColors,
} = themeCfg?.palette || getPalette(themeCfg?.name);

const isTable = themeCfg?.spreadsheet?.isTableMode();

Expand Down Expand Up @@ -72,7 +75,7 @@ export const getTheme = (
fontSize: 12,
fontWeight: isWindows() ? 'bold' : 520,
fill: basicColors[14],
linkTextFill: basicColors[14],
linkTextFill: basicColors[6],
opacity: 1,
textAlign: isTable ? 'center' : 'left',
textBaseline: 'middle',
Expand Down Expand Up @@ -124,6 +127,16 @@ export const getTheme = (
textOpacity: 0.3,
opacity: 0.3,
},
// -------------- searchResult -------------------
searchResult: {
backgroundColor: otherColors?.results ?? basicColors[2],
backgroundOpacity: 1,
},
// -------------- highlight -------------------
highlight: {
backgroundColor: otherColors?.highlight ?? basicColors[6],
backgroundOpacity: 1,
},
},
},
icon: {
Expand Down Expand Up @@ -192,6 +205,16 @@ export const getTheme = (
textOpacity: 0.3,
opacity: 0.3,
},
// -------------- searchResult -------------------
searchResult: {
backgroundColor: otherColors?.results ?? basicColors[2],
backgroundOpacity: 1,
},
// -------------- highlight -------------------
highlight: {
backgroundColor: otherColors?.highlight ?? basicColors[6],
backgroundOpacity: 1,
},
},
},
icon: {
Expand Down Expand Up @@ -271,6 +294,16 @@ export const getTheme = (
textOpacity: 0.3,
opacity: 0.3,
},
// -------------- searchResult -------------------
searchResult: {
backgroundColor: otherColors?.results ?? basicColors[2],
backgroundOpacity: 1,
},
// -------------- highlight -------------------
highlight: {
backgroundColor: otherColors?.highlight ?? basicColors[6],
backgroundOpacity: 1,
},
// -------------- prepare select --------------
prepareSelect: {
borderColor: basicColors[14],
Expand Down
5 changes: 5 additions & 0 deletions packages/s2-core/src/theme/palette/colorful.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const paletteColorfulMeta: PaletteMeta = {
red: '#FF4D4F',
green: '#29A294',
},
others: {
// ---------- searchResults colors ----------
highlight: '#87B5FF',
results: '#F0F7FF',
},
basicColorRelations: [
{
basicColorIndex: 1,
Expand Down
5 changes: 5 additions & 0 deletions packages/s2-core/src/theme/palette/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const paletteDefaultMeta: PaletteMeta = {
red: '#FF4D4F',
green: '#29A294',
},
others: {
// ---------- searchResults colors ----------
highlight: '#87B5FF',
results: '#F0F7FF',
},
basicColorRelations: [
{
basicColorIndex: 1,
Expand Down
5 changes: 5 additions & 0 deletions packages/s2-core/src/theme/palette/gray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const paletteGrayMeta: PaletteMeta = {
red: '#FF4D4F',
green: '#29A294',
},
others: {
// ---------- searchResults colors ----------
highlight: '#87B5FF',
results: '#F0F7FF',
},
basicColorRelations: [
{
basicColorIndex: 1,
Expand Down
Loading

0 comments on commit c261d3f

Please sign in to comment.