diff --git a/.github/workflows/prerelease-notify.yml b/.github/workflows/prerelease-notify.yml
index b6e93ef37f..09b5040cb6 100644
--- a/.github/workflows/prerelease-notify.yml
+++ b/.github/workflows/prerelease-notify.yml
@@ -19,7 +19,7 @@ jobs:
${{ secrets.DING_TALK_GROUP_TOKEN }}
${{ secrets.DING_TALK_PUBLIC_TOKEN }}
notify_title: '🎉 AntV/S2 测试版发布 🎉'
- notify_body: '🎉 AntV/S2 新版本发布啦 🎉
![preview](https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*1PTTQLk3j5AAAAAAAAAAAAAADmJ7AQ/original)
[**点击查看更新日志**](https://github.com/antvis/S2/releases)
'
+ notify_body: '🎉 **AntV/S2 新版本发布啦** 🎉
![preview](https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*1PTTQLk3j5AAAAAAAAAAAAAADmJ7AQ/original)
[**点击查看更新日志**](https://github.com/antvis/S2/releases)
'
notify_footer: '> 该版本为测试版, 请谨慎使用 ([AntV/S2 Releases](https://github.com/antvis/S2/releases))'
at_all: false
enable_prerelease: true
diff --git a/.github/workflows/release-notify.yml b/.github/workflows/release-notify.yml
index e0a25a61c9..31429c6389 100644
--- a/.github/workflows/release-notify.yml
+++ b/.github/workflows/release-notify.yml
@@ -19,7 +19,7 @@ jobs:
${{ secrets.DING_TALK_GROUP_TOKEN }}
${{ secrets.DING_TALK_PUBLIC_TOKEN }}
notify_title: '🎉 AntV/S2 新版本发布啦 🎉'
- notify_body: '🎉 AntV/S2 新版本发布啦 🎉
![preview](https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*1PTTQLk3j5AAAAAAAAAAAAAADmJ7AQ/original)
[**点击查看更新日志**](https://github.com/antvis/S2/releases)
'
+ notify_body: '🎉 **AntV/S2 新版本发布啦** 🎉
![preview](https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*1PTTQLk3j5AAAAAAAAAAAAAADmJ7AQ/original)
[**点击查看更新日志**](https://github.com/antvis/S2/releases)
'
notify_footer: '> [AntV/S2 Releases](https://github.com/antvis/S2/releases)'
at_all: false
enable_prerelease: false
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 51251dfb66..2905791ec2 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -11,7 +11,8 @@ jobs:
# jest-electron 需要 macOS 环境, 但是 免费用户 并发有限制, 容易排队 https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
# runs-on: macos-latest # (目前 macos-latest 对应的是 Big Sur 11, macos-12 对应 Monterey 12)
# macOS 3-core CPU, 其他 2-core CPU
- runs-on: macos-latest
+ # > macos-14 会导致 CI 的测试卡死, 没有任何报错!!!
+ runs-on: macos-13
if: "!contains(github.event.head_commit.message, '[skip ci]')"
strategy:
matrix:
diff --git a/build.config.base.mjs b/build.config.base.mjs
index 04968185cb..8a5aac453a 100644
--- a/build.config.base.mjs
+++ b/build.config.base.mjs
@@ -40,10 +40,6 @@ export const getBaseConfig = ({
// 防止开发模式下直接加载 s2-core 中的主题 less
resolve.alias.push(
...[
- {
- find: /^(.*)\/theme\/(.*)\.less$/,
- replacement: '$1/theme/$2.less?inline',
- },
{
find: /^@antv\/s2$/,
replacement: path.join(__dirname, './packages/s2-core/src'),
diff --git a/package.json b/package.json
index 074e589c8b..32bbc30fea 100644
--- a/package.json
+++ b/package.json
@@ -57,7 +57,7 @@
"build:umd": "pnpm -r --filter './packages/*' --stream build:umd",
"build:size-limit": "pnpm -r --filter './packages/*' --stream build:size-limit",
"build:size-limit-json": "pnpm -r --filter './packages/*' --stream build:size-limit-json",
- "release": "pnpm -r --filter !@antv/s2-site --filter !@antv/s2-vue --workspace-concurrency=1 exec npx --no-install semantic-release",
+ "release": "pnpm -r --filter !@antv/s2-site --workspace-concurrency=1 exec npx --no-install semantic-release",
"release:preview": "pnpm release --dry-run --no-ci",
"release:bump-version": "node ./scripts/bump-version.js",
"test": "pnpm -r --filter './packages/*' --stream test",
diff --git a/packages/s2-core/CHANGELOG.md b/packages/s2-core/CHANGELOG.md
index d56dfe6d73..73bbdef1ca 100644
--- a/packages/s2-core/CHANGELOG.md
+++ b/packages/s2-core/CHANGELOG.md
@@ -1,3 +1,19 @@
+# [@antv/s2-v2.1.0](https://github.com/antvis/S2/compare/@antv/s2-v2.0.1...@antv/s2-v2.1.0) (2024-11-29)
+
+
+### Bug Fixes
+
+* **tooltip:** 修复操作按钮的 visible 对角头和文本溢出场景不生效 ([#3001](https://github.com/antvis/S2/issues/3001)) ([8f56023](https://github.com/antvis/S2/commit/8f56023b4f29584bc619b00bc5a03a0c3bf30494))
+* 修复行头底部存在多行文本, 初始化和滚动时文本展示溢出的问题 ([#3000](https://github.com/antvis/S2/issues/3000)) ([6204839](https://github.com/antvis/S2/commit/620483901c40d64e2e1e6be6753a08ee26f35677))
+* 明细表未指定 dataCfg.fields 配置时不应该渲染空数据占位 ([#3003](https://github.com/antvis/S2/issues/3003)) ([60d6497](https://github.com/antvis/S2/commit/60d649705365bca0bde3acc836bd8eeb13e47c3c))
+
+
+### Features
+
+* 增加树状模式下行头宽度配置 rowCell.treeWidth ([#2998](https://github.com/antvis/S2/issues/2998)) ([b8fdd2a](https://github.com/antvis/S2/commit/b8fdd2a700a9a3bdc5d565c2bf89a85427c66a88))
+
+# [@antv/s2-v2.0.1](https://github.com/antvis/S2/compare/@antv/s2-v2.0.0...@antv/s2-v2.0.1) (2024-11-26)
+
# [@antv/s2-v2.0.0](https://github.com/antvis/S2/compare/@antv/s2-v1.45.1...@antv/s2-v2.0.0) (2024-11-21)
diff --git a/packages/s2-core/__tests__/spreadsheet/__snapshots__/custom-cell-style-spec.ts.snap b/packages/s2-core/__tests__/spreadsheet/__snapshots__/custom-cell-style-spec.ts.snap
index c9eb35e66e..ad75e1272b 100644
--- a/packages/s2-core/__tests__/spreadsheet/__snapshots__/custom-cell-style-spec.ts.snap
+++ b/packages/s2-core/__tests__/spreadsheet/__snapshots__/custom-cell-style-spec.ts.snap
@@ -235,6 +235,26 @@ Array [
]
`;
+exports[`SpreadSheet Custom Cell Style Tests PivotSheet Custom Cell Style Tests #RowCell should get custom tree row cell style 1`] = `
+Array [
+ Object {
+ "height": 30,
+ "id": "root[&]浙江",
+ "width": 150,
+ },
+ Object {
+ "height": 30,
+ "id": "root[&]浙江[&]义乌",
+ "width": 150,
+ },
+ Object {
+ "height": 30,
+ "id": "root[&]浙江[&]杭州",
+ "width": 150,
+ },
+]
+`;
+
exports[`SpreadSheet Custom Cell Style Tests PivotSheet Custom Cell Style Tests should render default cell style 1`] = `
Array [
Object {
diff --git a/packages/s2-core/__tests__/spreadsheet/custom-cell-style-spec.ts b/packages/s2-core/__tests__/spreadsheet/custom-cell-style-spec.ts
index fbea95055f..4ce5c67366 100644
--- a/packages/s2-core/__tests__/spreadsheet/custom-cell-style-spec.ts
+++ b/packages/s2-core/__tests__/spreadsheet/custom-cell-style-spec.ts
@@ -91,7 +91,21 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
},
},
});
- await s2.render();
+ await s2.render(false);
+
+ expect(mapNodeSize(s2.facet.getRowNodes())).toMatchSnapshot();
+ });
+
+ test('should get custom tree row cell style', async () => {
+ s2.setOptions({
+ hierarchyType: 'tree',
+ style: {
+ rowCell: {
+ treeWidth: 150,
+ },
+ },
+ });
+ await s2.render(false);
expect(mapNodeSize(s2.facet.getRowNodes())).toMatchSnapshot();
});
@@ -113,7 +127,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
},
},
});
- await s2.render();
+ await s2.render(false);
expect(mapNodeSize(s2.facet.getRowNodes())).toMatchSnapshot();
});
@@ -131,7 +145,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
},
},
});
- await s2.render();
+ await s2.render(false);
expect(mapNodeSize(s2.facet.getRowNodes())).toMatchSnapshot();
});
@@ -151,7 +165,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
},
},
});
- await s2.render();
+ await s2.render(false);
expect(mapNodeSize(s2.facet.getRowNodes())).toMatchSnapshot();
});
@@ -200,7 +214,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
},
},
});
- await s2.render();
+ await s2.render(false);
const rootRowNodes = s2.facet
.getRowNodes()
diff --git a/packages/s2-core/__tests__/spreadsheet/custom-tree-spec.ts b/packages/s2-core/__tests__/spreadsheet/custom-tree-spec.ts
index f2a256984d..9a47217b6d 100644
--- a/packages/s2-core/__tests__/spreadsheet/custom-tree-spec.ts
+++ b/packages/s2-core/__tests__/spreadsheet/custom-tree-spec.ts
@@ -18,7 +18,7 @@ const s2Options: S2Options = {
hierarchyType: 'tree',
style: {
rowCell: {
- width: 400,
+ treeWidth: 400,
},
},
};
@@ -208,7 +208,8 @@ describe('SpreadSheet Custom Tree Tests', () => {
s2.setOptions({
style: {
rowCell: {
- width: 50,
+ treeWidth: 50,
+ width: 30,
},
},
});
diff --git a/packages/s2-core/__tests__/spreadsheet/table-sheet-spec.ts b/packages/s2-core/__tests__/spreadsheet/table-sheet-spec.ts
index c3a8e156dd..7fc3c6b10f 100644
--- a/packages/s2-core/__tests__/spreadsheet/table-sheet-spec.ts
+++ b/packages/s2-core/__tests__/spreadsheet/table-sheet-spec.ts
@@ -429,5 +429,30 @@ describe('TableSheet normal spec', () => {
await expectEmptyPlaceholder(s2);
});
+
+ test('should not render empty placeholder if all fields is empty', async () => {
+ const s2 = new TableSheet(
+ getContainer(),
+ { ...dataCfg, fields: {}, data: [] },
+ {
+ ...options,
+ frozen: {},
+ seriesNumber: {
+ enable: false,
+ },
+ },
+ );
+
+ await s2.render();
+ const [rect, icon, text] = (s2.facet as TableFacet).emptyPlaceholderGroup
+ .children;
+
+ expect(
+ (s2.facet as TableFacet).emptyPlaceholderGroup.children,
+ ).toHaveLength(0);
+ expect(rect).not.toBeDefined();
+ expect(icon).not.toBeDefined();
+ expect(text).not.toBeDefined();
+ });
});
});
diff --git a/packages/s2-core/__tests__/spreadsheet/tooltip-spec.ts b/packages/s2-core/__tests__/spreadsheet/tooltip-spec.ts
index 531a477fda..2cf0d00d6c 100644
--- a/packages/s2-core/__tests__/spreadsheet/tooltip-spec.ts
+++ b/packages/s2-core/__tests__/spreadsheet/tooltip-spec.ts
@@ -1,4 +1,5 @@
import type { S2Options } from '@/common/interface';
+import { DARK_THEME_CLS } from '@antv/s2';
import { createPivotSheet } from 'tests/util/helpers';
const s2Options: S2Options = {
@@ -106,4 +107,19 @@ describe('Tooltip Tests', () => {
s2.destroy();
});
+
+ test('should render dark theme tooltip style', async () => {
+ const s2 = createS2({ enable: true });
+
+ s2.setThemeCfg({
+ name: 'dark',
+ });
+
+ await s2.render();
+ s2.showTooltip({ position: { x: 0, y: 0 } });
+
+ expect(document.querySelector(`body > .${DARK_THEME_CLS}`)).toBeTruthy();
+
+ s2.destroy();
+ });
});
diff --git a/packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts b/packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts
index 799b2e54cf..fd6132b9b1 100644
--- a/packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts
+++ b/packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts
@@ -4,8 +4,8 @@
import { CornerCell, DataCell } from '@/cell';
import {
DEFAULT_OPTIONS,
+ DEFAULT_ROW_CELL_TREE_WIDTH,
DEFAULT_STYLE,
- DEFAULT_TREE_ROW_CELL_WIDTH,
} from '@/common/constant/options';
import type { ViewMeta } from '@/common/interface/basic';
import { Store } from '@/common/store';
@@ -261,11 +261,11 @@ describe('Pivot Mode Facet Test', () => {
expect(rowsHierarchy.getLeaves()).toHaveLength(8);
expect(rowsHierarchy.getNodes()).toHaveLength(10);
- expect(rowsHierarchy.width).toBe(DEFAULT_TREE_ROW_CELL_WIDTH);
+ expect(rowsHierarchy.width).toBe(DEFAULT_ROW_CELL_TREE_WIDTH);
expect(rowCell?.width).toBeUndefined();
rowsHierarchy.getNodes().forEach((node, index) => {
- expect(node.width).toBe(DEFAULT_TREE_ROW_CELL_WIDTH);
+ expect(node.width).toBe(DEFAULT_ROW_CELL_TREE_WIDTH);
expect(node.height).toBe(dataCell!.height!);
expect(node.x).toBe(0);
expect(node.y).toBe(node.height * index);
diff --git a/packages/s2-core/__tests__/unit/interaction/base-interaction/click/corner-cell-click-spec.ts b/packages/s2-core/__tests__/unit/interaction/base-interaction/click/corner-cell-click-spec.ts
index 77df5ac102..3546b41d88 100644
--- a/packages/s2-core/__tests__/unit/interaction/base-interaction/click/corner-cell-click-spec.ts
+++ b/packages/s2-core/__tests__/unit/interaction/base-interaction/click/corner-cell-click-spec.ts
@@ -69,6 +69,11 @@ describe('Interaction Corner Cell Click Tests', () => {
[],
{
data: { summaries: [{ name: '', selectedData: [], value: null }] },
+ operator: {
+ menu: {
+ items: [],
+ },
+ },
},
);
expect(s2.interaction.getState()).toEqual({
diff --git a/packages/s2-core/__tests__/unit/interaction/base-interaction/hover-spec.ts b/packages/s2-core/__tests__/unit/interaction/base-interaction/hover-spec.ts
index c3bb8d2760..3f573fa2c4 100644
--- a/packages/s2-core/__tests__/unit/interaction/base-interaction/hover-spec.ts
+++ b/packages/s2-core/__tests__/unit/interaction/base-interaction/hover-spec.ts
@@ -36,6 +36,11 @@ describe('Interaction Hover Tests', () => {
hideSummary: true,
isTotals: undefined,
onlyShowCellText: true,
+ operator: {
+ menu: {
+ items: [],
+ },
+ },
},
];
diff --git a/packages/s2-core/__tests__/unit/interaction/row-column-resize-spec.ts b/packages/s2-core/__tests__/unit/interaction/row-column-resize-spec.ts
index d674efcfb3..4233da2abd 100644
--- a/packages/s2-core/__tests__/unit/interaction/row-column-resize-spec.ts
+++ b/packages/s2-core/__tests__/unit/interaction/row-column-resize-spec.ts
@@ -523,14 +523,14 @@ describe('Interaction Row Column Resize Tests', () => {
info: { ...resizeInfo, resizedWidth: 5, resizedHeight: 0 },
style: {
rowCell: {
- width: 5,
+ treeWidth: 5,
},
},
};
expect(resize).toHaveBeenCalledWith(newResizeInfo);
expect(treeWidthResize).toHaveBeenCalledWith(newResizeInfo);
- expect(s2.options.style!.rowCell!.width).toEqual(resizeInfo.width);
+ expect(s2.options.style!.rowCell!.treeWidth).toEqual(resizeInfo.width);
});
test('should get horizontal filed resize style', () => {
diff --git a/packages/s2-core/__tests__/unit/utils/tooltip-spec.ts b/packages/s2-core/__tests__/unit/utils/tooltip-spec.ts
index 062823c0e5..a3ef6b164d 100644
--- a/packages/s2-core/__tests__/unit/utils/tooltip-spec.ts
+++ b/packages/s2-core/__tests__/unit/utils/tooltip-spec.ts
@@ -29,6 +29,7 @@ import {
getTooltipOptions,
setTooltipContainerStyle,
} from '@/utils/tooltip';
+import { DARK_THEME_CLS } from '@antv/s2';
import { omit } from 'lodash';
import * as dataConfig from 'tests/data/mock-dataset.json';
import {
@@ -1221,6 +1222,16 @@ describe('Tooltip Utils Tests', () => {
);
});
+ test('should set container dark style', () => {
+ const container = document.createElement('div');
+
+ setTooltipContainerStyle(container, {
+ dark: true,
+ });
+
+ expect(container.classList.contains(DARK_THEME_CLS)).toBeTruthy();
+ });
+
test('should get custom fields summaries of custom tree', () => {
const mockData = [
{
diff --git a/packages/s2-core/__tests__/util/helpers.ts b/packages/s2-core/__tests__/util/helpers.ts
index b66bb26d5b..a74cb9a577 100644
--- a/packages/s2-core/__tests__/util/helpers.ts
+++ b/packages/s2-core/__tests__/util/helpers.ts
@@ -215,6 +215,7 @@ export const createFakeSpreadSheet = (config?: {
s2.hideTooltip = jest.fn();
s2.showTooltip = jest.fn();
s2.showTooltipWithInfo = jest.fn();
+ s2.getThemeName = jest.fn();
s2.isTableMode = jest.fn();
s2.isPivotMode = jest.fn();
s2.getCell = jest.fn();
diff --git a/packages/s2-core/package.json b/packages/s2-core/package.json
index 261a05344f..236a786ebc 100644
--- a/packages/s2-core/package.json
+++ b/packages/s2-core/package.json
@@ -1,6 +1,6 @@
{
"name": "@antv/s2",
- "version": "2.0.0",
+ "version": "2.1.0",
"private": false,
"description": "effective spreadsheet render core lib",
"keywords": [
diff --git a/packages/s2-core/rollup.config.mjs b/packages/s2-core/rollup.config.mjs
index 4fd868cdc3..a3d1d2046a 100644
--- a/packages/s2-core/rollup.config.mjs
+++ b/packages/s2-core/rollup.config.mjs
@@ -1,5 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
-import alias from '@rollup/plugin-alias';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
@@ -32,14 +31,6 @@ const output = {
const plugins = [
peerDepsExternal(),
- alias({
- entries: [
- {
- find: /^(?.*).less\?inline$/,
- replacement: '$1.less',
- },
- ],
- }),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
preventAssignment: true,
diff --git a/packages/s2-core/src/cell/row-cell.ts b/packages/s2-core/src/cell/row-cell.ts
index 03840d442b..5ae2898241 100644
--- a/packages/s2-core/src/cell/row-cell.ts
+++ b/packages/s2-core/src/cell/row-cell.ts
@@ -444,8 +444,8 @@ export class RowCell extends HeaderCell {
const textArea = this.getTextArea();
const textStyle = this.getTextStyle();
const { cell, icon: iconStyle } = this.getStyle();
-
const viewport = this.handleViewport();
+ const textHeight = this.getActualTextHeight();
const { textStart } = adjustTextIconPositionWhileScrolling(
viewport,
@@ -456,7 +456,7 @@ export class RowCell extends HeaderCell {
{
align: normalizeTextAlign(textStyle.textBaseline!),
size: {
- textSize: textStyle.fontSize!,
+ textSize: textHeight,
},
padding: {
start: cell.padding.top,
@@ -476,7 +476,7 @@ export class RowCell extends HeaderCell {
const iconY = getVerticalIconPosition(
iconStyle?.size!,
textStart,
- textStyle.fontSize!,
+ textHeight,
textStyle.textBaseline!,
);
diff --git a/packages/s2-core/src/common/constant/options.ts b/packages/s2-core/src/common/constant/options.ts
index d68512f8fd..5cb68a8717 100644
--- a/packages/s2-core/src/common/constant/options.ts
+++ b/packages/s2-core/src/common/constant/options.ts
@@ -28,7 +28,7 @@ export enum LayoutWidthType {
export const SPLIT_LINE_WIDTH = 1;
-export const DEFAULT_TREE_ROW_CELL_WIDTH = 120;
+export const DEFAULT_ROW_CELL_TREE_WIDTH = 120;
export const DEFAULT_CELL_TEXT_WORD_WRAP_STYLE: CellTextWordWrapStyle = {
wordWrap: true,
diff --git a/packages/s2-core/src/common/constant/theme.ts b/packages/s2-core/src/common/constant/theme.ts
index 12d307d31d..56d6c82aee 100644
--- a/packages/s2-core/src/common/constant/theme.ts
+++ b/packages/s2-core/src/common/constant/theme.ts
@@ -23,10 +23,7 @@ export const FONT_FAMILY =
export const INTERVAL_BAR_HEIGHT = 12;
-/**
- * 注入主题 css 变量的节点名
- */
-export const STYLE_ELEMENT_ID = `${S2_PREFIX_CLS}-core-vars`;
+export const DARK_THEME_CLS = `${S2_PREFIX_CLS}-dark-theme`;
/**
* 兼容 G2 主题: S2 和 G2 的主题名转换
diff --git a/packages/s2-core/src/common/interface/style.ts b/packages/s2-core/src/common/interface/style.ts
index 5bfae42052..262abccd94 100644
--- a/packages/s2-core/src/common/interface/style.ts
+++ b/packages/s2-core/src/common/interface/style.ts
@@ -80,6 +80,11 @@ export interface DataCellStyle extends CellTextWordWrapStyle {
}
export interface RowCellStyle extends BaseCellStyle, CellTextWordWrapStyle {
+ /**
+ * 树状结构的行头宽度
+ */
+ treeWidth?: number;
+
/**
* 是否展示树状分层下的层级占位点
*/
diff --git a/packages/s2-core/src/facet/base-facet.ts b/packages/s2-core/src/facet/base-facet.ts
index df23062ccc..730ce7e627 100644
--- a/packages/s2-core/src/facet/base-facet.ts
+++ b/packages/s2-core/src/facet/base-facet.ts
@@ -236,6 +236,10 @@ export abstract class BaseFacet {
this.init();
}
+ protected shouldRender() {
+ return !areAllFieldsEmpty(this.spreadsheet.dataCfg.fields);
+ }
+
public getLayoutResult = (): LayoutResult => {
return {
...this.layoutResult,
@@ -609,11 +613,8 @@ export abstract class BaseFacet {
this.emitPaginationEvent();
};
- /**
- * Start render, call from outside
- */
public render() {
- if (areAllFieldsEmpty(this.spreadsheet.dataCfg.fields)) {
+ if (!this.shouldRender()) {
return;
}
@@ -710,7 +711,7 @@ export abstract class BaseFacet {
}
public setScrollOffset = (scrollOffset: ScrollOffset) => {
- Object.keys(scrollOffset).forEach((key) => {
+ Object.keys(scrollOffset || {}).forEach((key) => {
const offset = get(scrollOffset, key);
if (!isUndefined(offset)) {
diff --git a/packages/s2-core/src/facet/frozen-facet.ts b/packages/s2-core/src/facet/frozen-facet.ts
index e68fc1cfbf..2f4409c752 100644
--- a/packages/s2-core/src/facet/frozen-facet.ts
+++ b/packages/s2-core/src/facet/frozen-facet.ts
@@ -675,6 +675,10 @@ export abstract class FrozenFacet extends BaseFacet {
}
public render() {
+ if (!this.shouldRender()) {
+ return;
+ }
+
this.calculateFrozenGroupInfo();
this.renderFrozenPanelCornerGroup();
super.render();
@@ -697,7 +701,7 @@ export abstract class FrozenFacet extends BaseFacet {
cellRange,
);
- (Object.keys(result) as (keyof typeof result)[]).forEach((key) => {
+ (Object.keys(result || {}) as (keyof typeof result)[]).forEach((key) => {
const cells = result[key];
const group = this.frozenGroups[key];
diff --git a/packages/s2-core/src/facet/pivot-facet.ts b/packages/s2-core/src/facet/pivot-facet.ts
index 3a0f4bdace..18a7b502b3 100644
--- a/packages/s2-core/src/facet/pivot-facet.ts
+++ b/packages/s2-core/src/facet/pivot-facet.ts
@@ -17,7 +17,7 @@ import {
} from 'lodash';
import { ColCell, RowCell, SeriesNumberCell } from '../cell';
import {
- DEFAULT_TREE_ROW_CELL_WIDTH,
+ DEFAULT_ROW_CELL_TREE_WIDTH,
LAYOUT_SAMPLE_COUNT,
type IconTheme,
type MultiData,
@@ -804,6 +804,10 @@ export class PivotFacet extends FrozenFacet {
const { rowCell } = this.spreadsheet.options.style!;
// 1. 用户拖拽或手动指定的行头宽度优先级最高
+ if (isNumber(rowCell?.treeWidth)) {
+ return rowCell.treeWidth;
+ }
+
const customRowCellWidth = this.getCellCustomSize(null, rowCell?.width!);
if (isNumber(customRowCellWidth)) {
@@ -829,11 +833,11 @@ export class PivotFacet extends FrozenFacet {
this.rowCellTheme.padding?.right;
const width = Math.max(
- customRowCellWidth ?? DEFAULT_TREE_ROW_CELL_WIDTH,
+ customRowCellWidth ?? DEFAULT_ROW_CELL_TREE_WIDTH,
maxLabelWidth,
);
- return Number.isNaN(width) ? DEFAULT_TREE_ROW_CELL_WIDTH : width;
+ return Number.isNaN(width) ? DEFAULT_ROW_CELL_TREE_WIDTH : width;
}
/**
diff --git a/packages/s2-core/src/facet/table-facet.ts b/packages/s2-core/src/facet/table-facet.ts
index d62c326d5a..fe5c658ca8 100644
--- a/packages/s2-core/src/facet/table-facet.ts
+++ b/packages/s2-core/src/facet/table-facet.ts
@@ -83,6 +83,10 @@ export class TableFacet extends FrozenFacet {
}
public render() {
+ if (!this.shouldRender()) {
+ return;
+ }
+
super.render();
this.renderEmptyPlaceholder();
}
diff --git a/packages/s2-core/src/interaction/base-event.ts b/packages/s2-core/src/interaction/base-event.ts
index 7e0d2fcf6e..b5e2c66dda 100644
--- a/packages/s2-core/src/interaction/base-event.ts
+++ b/packages/s2-core/src/interaction/base-event.ts
@@ -2,9 +2,14 @@ import type {
FederatedPointerEvent as CanvasEvent,
DisplayObject,
} from '@antv/g';
-import { type CellAppendInfo } from '../common';
+import {
+ type CellAppendInfo,
+ type TooltipOperatorMenuItems,
+ type TooltipOperatorOptions,
+} from '../common';
import type { SpreadSheet } from '../sheet-type';
import { getAppendInfo } from '../utils/interaction/common';
+import { getTooltipOptions, getTooltipVisibleOperator } from '../utils/tooltip';
export interface BaseEventImplement {
bindEvents: () => void;
@@ -30,6 +35,19 @@ export abstract class BaseEvent {
return cellAppendInfo?.isLinkFieldText;
};
+ protected getTooltipOperator(
+ event: CanvasEvent,
+ defaultMenus: TooltipOperatorMenuItems = [],
+ ): TooltipOperatorOptions {
+ const cell = this.spreadsheet.getCell(event.target)!;
+ const { operation } = getTooltipOptions(this.spreadsheet, event)!;
+
+ return getTooltipVisibleOperator(operation!, {
+ defaultMenus,
+ cell,
+ });
+ }
+
public reset() {}
public abstract bindEvents(): void;
diff --git a/packages/s2-core/src/interaction/base-interaction/click/corner-cell-click.ts b/packages/s2-core/src/interaction/base-interaction/click/corner-cell-click.ts
index bfefa750ae..344bedab50 100644
--- a/packages/s2-core/src/interaction/base-interaction/click/corner-cell-click.ts
+++ b/packages/s2-core/src/interaction/base-interaction/click/corner-cell-click.ts
@@ -154,8 +154,10 @@ export class CornerCellClick extends BaseEvent implements BaseEventImplement {
private showTooltip(event: CanvasEvent) {
// 角头的选中是维值, 不需要计算数值总和, 显示 [`xx 项已选中`] 即可
const selectedData = this.spreadsheet.interaction.getActiveCells();
+ const operator = this.getTooltipOperator(event);
this.spreadsheet.showTooltipWithInfo(event, [], {
+ operator,
data: {
summaries: [
{
diff --git a/packages/s2-core/src/interaction/base-interaction/click/data-cell-click.ts b/packages/s2-core/src/interaction/base-interaction/click/data-cell-click.ts
index 0615e9839f..16b4f45c04 100644
--- a/packages/s2-core/src/interaction/base-interaction/click/data-cell-click.ts
+++ b/packages/s2-core/src/interaction/base-interaction/click/data-cell-click.ts
@@ -8,7 +8,6 @@ import {
} from '../../../common/constant';
import type {
TooltipData,
- TooltipOperatorOptions,
ViewMeta,
ViewMetaData,
} from '../../../common/interface';
@@ -16,10 +15,6 @@ import {
afterSelectDataCells,
getCellMeta,
} from '../../../utils/interaction/select-event';
-import {
- getTooltipOptions,
- getTooltipVisibleOperator,
-} from '../../../utils/tooltip';
import { BaseEvent, type BaseEventImplement } from '../../base-event';
export class DataCellClick extends BaseEvent implements BaseEventImplement {
@@ -94,16 +89,6 @@ export class DataCellClick extends BaseEvent implements BaseEventImplement {
});
}
- private getTooltipOperator(event: CanvasEvent): TooltipOperatorOptions {
- const cell = this.spreadsheet.getCell(event.target)!;
- const { operation } = getTooltipOptions(this.spreadsheet, event)!;
-
- return getTooltipVisibleOperator(operation!, {
- defaultMenus: [],
- cell,
- });
- }
-
private showTooltip(event: CanvasEvent, meta: ViewMeta) {
const { data, isTotals = false, fieldValue, valueField } = meta;
const onlyShowCellText = this.spreadsheet.isTableMode();
diff --git a/packages/s2-core/src/interaction/base-interaction/click/row-column-click.ts b/packages/s2-core/src/interaction/base-interaction/click/row-column-click.ts
index 51487aef9e..bfd2d8604c 100644
--- a/packages/s2-core/src/interaction/base-interaction/click/row-column-click.ts
+++ b/packages/s2-core/src/interaction/base-interaction/click/row-column-click.ts
@@ -26,11 +26,7 @@ import {
isMouseEventWithMeta,
isMultiSelectionKey,
} from '../../../utils/interaction/select-event';
-import {
- getTooltipOptions,
- getTooltipVisibleOperator,
- mergeCellInfo,
-} from '../../../utils/tooltip';
+import { getTooltipOptions, mergeCellInfo } from '../../../utils/tooltip';
import type { ViewMeta } from './../../../common/interface/basic';
export class RowColumnClick extends BaseEvent implements BaseEventImplement {
@@ -147,7 +143,7 @@ export class RowColumnClick extends BaseEvent implements BaseEventImplement {
? mergeCellInfo(interaction.getActiveCells())
: [];
- const operator = this.getTooltipOperator(event, operation!);
+ const operator = this.getHeaderTooltipOperator(event, operation!);
this.spreadsheet.showTooltipWithInfo(event, cellInfos, {
onlyShowCellText: true,
@@ -155,7 +151,7 @@ export class RowColumnClick extends BaseEvent implements BaseEventImplement {
});
}
- protected getTooltipOperator(
+ protected getHeaderTooltipOperator(
event: CanvasEvent,
operation: TooltipOperation,
): TooltipOperatorOptions {
@@ -185,10 +181,7 @@ export class RowColumnClick extends BaseEvent implements BaseEventImplement {
const menus = enableHiddenColumnOperator ? [hiddenColumnsMenu] : [];
- return getTooltipVisibleOperator(operation, {
- defaultMenus: menus,
- cell,
- });
+ return this.getTooltipOperator(event, menus);
}
protected bindTableColExpand() {
diff --git a/packages/s2-core/src/interaction/base-interaction/hover.ts b/packages/s2-core/src/interaction/base-interaction/hover.ts
index 07c66584f1..889c25ed3f 100644
--- a/packages/s2-core/src/interaction/base-interaction/hover.ts
+++ b/packages/s2-core/src/interaction/base-interaction/hover.ts
@@ -128,6 +128,7 @@ export class HoverEvent extends BaseEvent implements BaseEventImplement {
hideSummary: true,
onlyShowCellText: true,
enableFormat: true,
+ operator: this.getTooltipOperator(event),
};
const data = this.getCellData(meta, options.onlyShowCellText);
diff --git a/packages/s2-core/src/interaction/row-column-resize.ts b/packages/s2-core/src/interaction/row-column-resize.ts
index a1e2aa53eb..525d0dab55 100644
--- a/packages/s2-core/src/interaction/row-column-resize.ts
+++ b/packages/s2-core/src/interaction/row-column-resize.ts
@@ -351,7 +351,7 @@ export class RowColumnResize extends BaseEvent implements BaseEventImplement {
eventType: S2Event.LAYOUT_RESIZE_TREE_WIDTH,
style: {
rowCell: {
- width: displayWidth,
+ treeWidth: displayWidth,
},
},
};
@@ -445,7 +445,7 @@ export class RowColumnResize extends BaseEvent implements BaseEventImplement {
Math.floor((displayHeight - padding) / lineHeight),
);
- const maxLinesByField = Object.keys(heightByField).reduce<
+ const maxLinesByField = Object.keys(heightByField || {}).reduce<
Record
>((result, field) => {
result![field] = maxLines;
diff --git a/packages/s2-core/src/shared/constant/theme.ts b/packages/s2-core/src/shared/constant/theme.ts
deleted file mode 100644
index 8bb0c51171..0000000000
--- a/packages/s2-core/src/shared/constant/theme.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { S2_PREFIX_CLS } from '../../common';
-
-/**
- * 注入主题 css 变量的节点名
- */
-export const STYLE_ELEMENT_ID = `${S2_PREFIX_CLS}-component-vars`;
diff --git a/packages/s2-core/src/shared/styles/theme/dark.less b/packages/s2-core/src/shared/styles/theme/dark.less
deleted file mode 100644
index ba9a811a39..0000000000
--- a/packages/s2-core/src/shared/styles/theme/dark.less
+++ /dev/null
@@ -1,20 +0,0 @@
-@import '../variables.less';
-
-:root {
- @white: #fff;
-
- // container
- @{css-var-prefix}-container-background: #191919;
- @{css-var-prefix}-block-background: #232323;
-
- // text
- @{css-var-prefix}-font: @white;
- each(range(19), {
- @fadePercent: 100 - @value * 5;
- @{css-var-prefix}-font-@{fadePercent}: fade(@white, @fadePercent);
- });
-
- // border
- @{css-var-prefix}-border: fade(@white, 15);
- @{css-var-prefix}-divider: fade(@white, 10);
-}
diff --git a/packages/s2-core/src/shared/styles/tooltip/operator.less b/packages/s2-core/src/shared/styles/tooltip/operator.less
index d55b166b3f..873b87f7c8 100644
--- a/packages/s2-core/src/shared/styles/tooltip/operator.less
+++ b/packages/s2-core/src/shared/styles/tooltip/operator.less
@@ -54,7 +54,7 @@
&.ant-menu-submenu-selected {
background-color: var(
- --antv-s2-tooltip-operator-menu-selected-background,
+ ~'@{css-var-prefix}-tooltip-operator-menu-selected-background',
#e6f4ff
);
}
diff --git a/packages/s2-core/src/sheet-type/spread-sheet.ts b/packages/s2-core/src/sheet-type/spread-sheet.ts
index 14e48d5816..4d213c23e3 100644
--- a/packages/s2-core/src/sheet-type/spread-sheet.ts
+++ b/packages/s2-core/src/sheet-type/spread-sheet.ts
@@ -70,7 +70,6 @@ import { clearValueRangeState } from '../utils/condition/state-controller';
import { hideColumnsByThunkGroup } from '../utils/hide-columns';
import { isMobile } from '../utils/is-mobile';
import { customMerge, setupDataConfig, setupOptions } from '../utils/merge';
-import { injectThemeVars } from '../utils/theme';
import { getTooltipData, getTooltipOptions } from '../utils/tooltip';
import type { PivotSheet } from './pivot-sheet';
import type { TableSheet } from './table-sheet';
@@ -548,7 +547,6 @@ export abstract class SpreadSheet extends EE {
this.theme = customMerge(newTheme, theme);
this.setThemeName(themeCfg?.name!);
- injectThemeVars(themeCfg?.name);
}
public setTheme(theme: S2Theme) {
diff --git a/packages/s2-core/src/styles/theme/dark.less b/packages/s2-core/src/styles/theme/dark.less
index 3a2fd87c3a..f5907e92ae 100644
--- a/packages/s2-core/src/styles/theme/dark.less
+++ b/packages/s2-core/src/styles/theme/dark.less
@@ -1,9 +1,27 @@
@import '../variables.less';
-:root {
+.@{s2-cls-prefix}-dark-theme {
+ @white: #fff;
+
// container
@{css-var-prefix}-background: #000;
@{css-var-prefix}-tooltip-background: rgba(43, 43, 43, 0.95);
@{css-var-prefix}-tooltip-operator-background: rgba(43, 43, 43, 0.95);
@{css-var-prefix}-tooltip-operator-menu-selected-background: #1677ff;
+
+ // container
+ @{css-var-prefix}-container-background: #191919;
+ @{css-var-prefix}-block-background: #232323;
+
+ // text
+ @{css-var-prefix}-font: @white;
+
+ each(range(19), {
+ @fadePercent: 100 - @value * 5;
+ @{css-var-prefix}-font-@{fadePercent}: fade(@white, @fadePercent);
+ });
+
+ // border
+ @{css-var-prefix}-border: fade(@white, 15);
+ @{css-var-prefix}-divider: fade(@white, 10);
}
diff --git a/packages/s2-core/src/ui/tooltip/index.less b/packages/s2-core/src/ui/tooltip/index.less
index a5be94f521..075d337a43 100644
--- a/packages/s2-core/src/ui/tooltip/index.less
+++ b/packages/s2-core/src/ui/tooltip/index.less
@@ -1,4 +1,5 @@
@import '../../styles/variables.less';
+@import '../../styles/theme/dark.less';
.@{tooltip-cls-prefix} {
&-container {
diff --git a/packages/s2-core/src/ui/tooltip/index.ts b/packages/s2-core/src/ui/tooltip/index.ts
index fa34348899..b971c3db96 100644
--- a/packages/s2-core/src/ui/tooltip/index.ts
+++ b/packages/s2-core/src/ui/tooltip/index.ts
@@ -11,7 +11,6 @@ import {
getAutoAdjustPosition,
setTooltipContainerStyle,
} from '../../utils/tooltip';
-
import './index.less';
/**
@@ -73,6 +72,7 @@ export class BaseTooltip<
pointerEvents: 'all',
},
visible: true,
+ dark: this.spreadsheet.getThemeName() === 'dark',
});
}
diff --git a/packages/s2-core/src/utils/indexes.ts b/packages/s2-core/src/utils/indexes.ts
index 141200d4e2..bd422a0494 100644
--- a/packages/s2-core/src/utils/indexes.ts
+++ b/packages/s2-core/src/utils/indexes.ts
@@ -106,7 +106,7 @@ export const diffPanelIndexes = (
const allAdd: Diff['add'] = [];
const allRemove: Diff['remove'] = [];
- Object.keys(targetIndexes).forEach((key) => {
+ Object.keys(targetIndexes || {}).forEach((key) => {
const { add, remove } = diffIndexes(
sourceIndexes?.[key as keyof PanelIndexes] || ([] as unknown as Indexes),
targetIndexes[key as keyof PanelIndexes]!,
diff --git a/packages/s2-core/src/utils/theme.ts b/packages/s2-core/src/utils/theme.ts
index 6cbf01a3e5..6681c78bdf 100644
--- a/packages/s2-core/src/utils/theme.ts
+++ b/packages/s2-core/src/utils/theme.ts
@@ -1,7 +1,5 @@
-import { PALETTE_MAP, STYLE_ELEMENT_ID } from '../common/constant';
+import { PALETTE_MAP } from '../common/constant';
import type { Palette, ThemeName } from '../common/interface/theme';
-import DarkVars from '../styles/theme/dark.less';
-import { injectCssText } from './inject-css-text';
/**
* 获取当前的主题色板
@@ -9,14 +7,3 @@ import { injectCssText } from './inject-css-text';
export const getPalette = (themeName?: ThemeName): Palette => {
return PALETTE_MAP[themeName!] || PALETTE_MAP['default'];
};
-
-/**
- * 根据主题注入组件的 CSS 变量
- */
-export const injectThemeVars = (themeName?: ThemeName) => {
- // 目前仅 dark 主题需要定制
- injectCssText(
- STYLE_ELEMENT_ID,
- themeName === 'dark' ? (DarkVars as string) : '',
- );
-};
diff --git a/packages/s2-core/src/utils/tooltip.ts b/packages/s2-core/src/utils/tooltip.ts
index 87822b2c6f..b9dad19c2d 100644
--- a/packages/s2-core/src/utils/tooltip.ts
+++ b/packages/s2-core/src/utils/tooltip.ts
@@ -29,6 +29,7 @@ import {
} from 'lodash';
import {
CellType,
+ DARK_THEME_CLS,
EXTRA_FIELD,
PRECISION,
VALUE_FIELD,
@@ -153,13 +154,14 @@ export const setTooltipContainerStyle = (
visible?: boolean;
style?: CSS.Properties;
className?: string[];
+ dark?: boolean;
},
) => {
if (!container) {
return;
}
- const { style, className = [], visible } = options;
+ const { style, className = [], visible, dark = false } = options;
if (style) {
Object.assign(container.style, style);
@@ -173,6 +175,7 @@ export const setTooltipContainerStyle = (
container.classList.toggle(TOOLTIP_CONTAINER_SHOW_CLS, visible);
container.classList.toggle(TOOLTIP_CONTAINER_HIDE_CLS, !visible);
+ container.classList.toggle(DARK_THEME_CLS, dark);
};
export const getListItem = (
@@ -454,7 +457,7 @@ export const getCustomFieldsSummaries = (
): TooltipSummaryOptions[] => {
const customFieldGroup = groupBy(summaries, 'name');
- return Object.keys(customFieldGroup).map((name) => {
+ return Object.keys(customFieldGroup || {}).map((name) => {
const cellsData = customFieldGroup[name];
const selectedData = flatMap(
cellsData,
diff --git a/packages/s2-react-components/CHANGELOG.md b/packages/s2-react-components/CHANGELOG.md
index f2512230ef..45c89ac481 100644
--- a/packages/s2-react-components/CHANGELOG.md
+++ b/packages/s2-react-components/CHANGELOG.md
@@ -1,3 +1,15 @@
+# [@antv/s2-react-components-v2.1.0](https://github.com/antvis/S2/compare/@antv/s2-react-components-v2.0.1...@antv/s2-react-components-v2.1.0) (2024-11-29)
+
+
+### Bug Fixes
+
+* 修复 react, vue component 层的 svg 问题 close [#2990](https://github.com/antvis/S2/issues/2990) ([#2999](https://github.com/antvis/S2/issues/2999)) ([b626986](https://github.com/antvis/S2/commit/b626986827a4cd6439d06bdd2e9fb8aa6e19fdc4))
+
+
+### Features
+
+* 增加树状模式下行头宽度配置 rowCell.treeWidth ([#2998](https://github.com/antvis/S2/issues/2998)) ([b8fdd2a](https://github.com/antvis/S2/commit/b8fdd2a700a9a3bdc5d565c2bf89a85427c66a88))
+
# [@antv/s2-react-components-v2.0.1](https://github.com/antvis/S2/compare/@antv/s2-react-components-v2.0.0...@antv/s2-react-components-v2.0.1) (2024-11-21)
diff --git a/packages/s2-react-components/__tests__/unit/components/drill-down/__snapshots__/drill-down-spec.tsx.snap b/packages/s2-react-components/__tests__/unit/components/drill-down/__snapshots__/drill-down-spec.tsx.snap
index a57365cea4..bd18855843 100644
--- a/packages/s2-react-components/__tests__/unit/components/drill-down/__snapshots__/drill-down-spec.tsx.snap
+++ b/packages/s2-react-components/__tests__/unit/components/drill-down/__snapshots__/drill-down-spec.tsx.snap
@@ -446,9 +446,18 @@ exports[`DrillDown Component Tests should render custom dataset 1`] = `
role="menuitem"
tabindex="-1"
>
-
+ height="12.6"
+ viewBox="0 0 1024 1024"
+ width="12.6"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+
+