Skip to content

Commit

Permalink
Merge remote-tracking branch 'github.com/next' into dev-fix-antvis#2958
Browse files Browse the repository at this point in the history
  • Loading branch information
linwrui committed Dec 1, 2024
2 parents 766aacb + 52a2576 commit 3db870a
Show file tree
Hide file tree
Showing 83 changed files with 538 additions and 360 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prerelease-notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
${{ secrets.DING_TALK_GROUP_TOKEN }}
${{ secrets.DING_TALK_PUBLIC_TOKEN }}
notify_title: '🎉 AntV/S2 测试版发布 🎉'
notify_body: '🎉 AntV/S2 新版本发布啦 🎉 <br/> ![preview](https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*1PTTQLk3j5AAAAAAAAAAAAAADmJ7AQ/original) <hr /> [**点击查看更新日志**](https://github.com/antvis/S2/releases) <hr />'
notify_body: '🎉 **AntV/S2 新版本发布啦** 🎉 <hr /><br/> ![preview](https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*1PTTQLk3j5AAAAAAAAAAAAAADmJ7AQ/original) <hr /> [**点击查看更新日志**](https://github.com/antvis/S2/releases) <hr />'
notify_footer: '> 该版本为测试版, 请谨慎使用 ([AntV/S2 Releases](https://github.com/antvis/S2/releases))'
at_all: false
enable_prerelease: true
2 changes: 1 addition & 1 deletion .github/workflows/release-notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
${{ secrets.DING_TALK_GROUP_TOKEN }}
${{ secrets.DING_TALK_PUBLIC_TOKEN }}
notify_title: '🎉 AntV/S2 新版本发布啦 🎉'
notify_body: '🎉 AntV/S2 新版本发布啦 🎉 <br/> ![preview](https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*1PTTQLk3j5AAAAAAAAAAAAAADmJ7AQ/original) <hr /> [**点击查看更新日志**](https://github.com/antvis/S2/releases) <hr />'
notify_body: '🎉 **AntV/S2 新版本发布啦** 🎉 <hr /><br/> ![preview](https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*1PTTQLk3j5AAAAAAAAAAAAAADmJ7AQ/original) <hr /> [**点击查看更新日志**](https://github.com/antvis/S2/releases) <hr />'
notify_footer: '> [AntV/S2 Releases](https://github.com/antvis/S2/releases)'
at_all: false
enable_prerelease: false
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions build.config.base.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 16 additions & 0 deletions packages/s2-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 19 additions & 5 deletions packages/s2-core/__tests__/spreadsheet/custom-cell-style-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand All @@ -113,7 +127,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
},
},
});
await s2.render();
await s2.render(false);

expect(mapNodeSize(s2.facet.getRowNodes())).toMatchSnapshot();
});
Expand All @@ -131,7 +145,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
},
},
});
await s2.render();
await s2.render(false);

expect(mapNodeSize(s2.facet.getRowNodes())).toMatchSnapshot();
});
Expand All @@ -151,7 +165,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
},
},
});
await s2.render();
await s2.render(false);

expect(mapNodeSize(s2.facet.getRowNodes())).toMatchSnapshot();
});
Expand Down Expand Up @@ -200,7 +214,7 @@ describe('SpreadSheet Custom Cell Style Tests', () => {
},
},
});
await s2.render();
await s2.render(false);

const rootRowNodes = s2.facet
.getRowNodes()
Expand Down
5 changes: 3 additions & 2 deletions packages/s2-core/__tests__/spreadsheet/custom-tree-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const s2Options: S2Options = {
hierarchyType: 'tree',
style: {
rowCell: {
width: 400,
treeWidth: 400,
},
},
};
Expand Down Expand Up @@ -208,7 +208,8 @@ describe('SpreadSheet Custom Tree Tests', () => {
s2.setOptions({
style: {
rowCell: {
width: 50,
treeWidth: 50,
width: 30,
},
},
});
Expand Down
25 changes: 25 additions & 0 deletions packages/s2-core/__tests__/spreadsheet/table-sheet-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
16 changes: 16 additions & 0 deletions packages/s2-core/__tests__/spreadsheet/tooltip-spec.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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();
});
});
6 changes: 3 additions & 3 deletions packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ describe('Interaction Corner Cell Click Tests', () => {
[],
{
data: { summaries: [{ name: '', selectedData: [], value: null }] },
operator: {
menu: {
items: [],
},
},
},
);
expect(s2.interaction.getState()).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ describe('Interaction Hover Tests', () => {
hideSummary: true,
isTotals: undefined,
onlyShowCellText: true,
operator: {
menu: {
items: [],
},
},
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
11 changes: 11 additions & 0 deletions packages/s2-core/__tests__/unit/utils/tooltip-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = [
{
Expand Down
1 change: 1 addition & 0 deletions packages/s2-core/__tests__/util/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
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": "2.0.0",
"version": "2.1.0",
"private": false,
"description": "effective spreadsheet render core lib",
"keywords": [
Expand Down
9 changes: 0 additions & 9 deletions packages/s2-core/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -32,14 +31,6 @@ const output = {

const plugins = [
peerDepsExternal(),
alias({
entries: [
{
find: /^(?<name>.*).less\?inline$/,
replacement: '$1.less',
},
],
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
preventAssignment: true,
Expand Down
6 changes: 3 additions & 3 deletions packages/s2-core/src/cell/row-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ export class RowCell extends HeaderCell<RowHeaderConfig> {
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,
Expand All @@ -456,7 +456,7 @@ export class RowCell extends HeaderCell<RowHeaderConfig> {
{
align: normalizeTextAlign(textStyle.textBaseline!),
size: {
textSize: textStyle.fontSize!,
textSize: textHeight,
},
padding: {
start: cell.padding.top,
Expand All @@ -476,7 +476,7 @@ export class RowCell extends HeaderCell<RowHeaderConfig> {
const iconY = getVerticalIconPosition(
iconStyle?.size!,
textStart,
textStyle.fontSize!,
textHeight,
textStyle.textBaseline!,
);

Expand Down
2 changes: 1 addition & 1 deletion packages/s2-core/src/common/constant/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 3db870a

Please sign in to comment.