Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tooltip): 重构 tooltip API 命名 #2271

Merged
merged 9 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/s2-core/__tests__/spreadsheet/corner-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('PivotSheet Corner Tests', () => {
width: 300,
height: 300,
tooltip: {
showTooltip: true,
enable: true,
},
});
await s2.render();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const s2Options: S2Options = {
width: 400,
height: 120,
tooltip: {
showTooltip: true,
enable: true,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const s2Options: S2Options = {
width: 600,
height: 400,
tooltip: {
showTooltip: true,
enable: true,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const s2Options: S2Options = {
width: 600,
height: 400,
tooltip: {
showTooltip: true,
enable: true,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
},
},
tooltip: {
showTooltip: true,
enable: true,
},
// layout hooks
layoutArrange: CustomLayoutArrange,
Expand Down Expand Up @@ -196,7 +196,7 @@
});

test('layout cell meta hook', () => {
const { fieldValue, data } = s2.facet.getCellMeta(0, 0)!;

Check warning on line 199 in packages/s2-core/__tests__/spreadsheet/layout-hooks-spec.ts

View workflow job for this annotation

GitHub Actions / lint (18)

'data' is already declared in the upper scope on line 13 column 7

expect(fieldValue).toEqual(999);
expect(data).toMatchInlineSnapshot(`
Expand Down
10 changes: 5 additions & 5 deletions packages/s2-core/__tests__/spreadsheet/tooltip-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Tooltip Tests', () => {
});

test('should not render tooltip in default container if disable tooltip', async () => {
const s2 = createS2({ showTooltip: false });
const s2 = createS2({ enable: false });

await s2.render();

Expand All @@ -28,7 +28,7 @@ describe('Tooltip Tests', () => {
});

test('should not render tooltip in default container when hide tooltip if disable tooltip', async () => {
const s2 = createS2({ showTooltip: false });
const s2 = createS2({ enable: false });

await s2.render();

Expand All @@ -42,7 +42,7 @@ describe('Tooltip Tests', () => {
});

test('should render tooltip in default container', async () => {
const s2 = createS2({ showTooltip: true });
const s2 = createS2({ enable: true });

await s2.render();

Expand All @@ -62,7 +62,7 @@ describe('Tooltip Tests', () => {
document.body.appendChild(container);

const s2 = createS2({
showTooltip: true,
enable: true,
adjustPosition: (positionInfo) => {
const { position } = positionInfo;

Expand All @@ -86,7 +86,7 @@ describe('Tooltip Tests', () => {
document.body.appendChild(container);

const s2 = createS2({
showTooltip: true,
enable: true,
getContainer: () => container,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Interaction Row & Column Cell Click Tests', () => {
hiddenColumnFields: ['a'],
},
tooltip: {
showTooltip: true,
enable: true,
operation: {
hiddenColumns: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ describe('Interaction Hover Tests', () => {
const mockTooltipParams = [
[{ value: undefined, valueField: undefined }],
{
enterable: true,
hideSummary: true,
isTotals: undefined,
showSingleTips: true,
onlyShowCellText: true,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const s2Options: S2Options = {
width: 200,
height: 200,
tooltip: {
showTooltip: true,
enable: true,
},
interaction: {
enableCopy: true,
Expand Down Expand Up @@ -954,15 +954,15 @@ describe('Interaction Event Controller Tests', () => {

spreadsheet.on(S2Event.GLOBAL_RESET, reset);
spreadsheet.options.tooltip = {
showTooltip: false,
enable: false,
dataCell: {
showTooltip: true,
enable: true,
},
colCell: {
showTooltip: true,
enable: true,
},
rowCell: {
showTooltip: true,
enable: true,
},
};
spreadsheet.tooltip.visible = true;
Expand Down
18 changes: 9 additions & 9 deletions packages/s2-core/__tests__/unit/sheet-type/pivot-sheet-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('PivotSheet Tests', () => {
hierarchyType: 'grid',
customSVGIcons: [customSVGIcon],
tooltip: {
showTooltip: true,
enable: true,
},
interaction: {
autoResetSheetStyle: false,
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('PivotSheet Tests', () => {
test("should dont't show tooltip when call showTooltipWithInfo if disable tooltip", () => {
Object.defineProperty(s2.options, 'tooltip', {
value: {
showTooltip: false,
enable: false,
},
configurable: true,
});
Expand All @@ -162,7 +162,7 @@ describe('PivotSheet Tests', () => {
test('should show tooltip when call showTooltipWithInfo if enable tooltip', () => {
Object.defineProperty(s2.options, 'tooltip', {
value: {
showTooltip: true,
enable: true,
},
configurable: true,
});
Expand Down Expand Up @@ -384,8 +384,8 @@ describe('PivotSheet Tests', () => {
dataCfg,
customMerge(s2Options, {
tooltip: {
showTooltip: true,
renderTooltip: (spreadsheet) => new CustomTooltip(spreadsheet),
enable: true,
render: (spreadsheet) => new CustomTooltip(spreadsheet),
autoAdjustBoundary: null,
} as S2Options['tooltip'],
}),
Expand Down Expand Up @@ -414,8 +414,8 @@ describe('PivotSheet Tests', () => {
dataCfg,
customMerge(s2Options, {
tooltip: {
showTooltip: true,
renderTooltip: () => new CustomTooltip(),
enable: true,
render: () => new CustomTooltip(),
autoAdjustBoundary: null,
},
}),
Expand Down Expand Up @@ -908,7 +908,7 @@ describe('PivotSheet Tests', () => {
expect.anything(),
expect.anything(),
{
onlyMenu: true,
onlyShowOperator: true,
forceRender: true,
operator: {
menus: [
Expand Down Expand Up @@ -1254,7 +1254,7 @@ describe('PivotSheet Tests', () => {
const sheet = new PivotSheet(getContainer(), originalDataCfg, {
facet: (spreadsheet) => new CustomFacet(spreadsheet),
tooltip: {
showTooltip: false,
enable: false,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('TableSheet Tests', () => {
width: 100,
height: 100,
tooltip: {
showTooltip: true,
enable: true,
},
interaction: {
autoResetSheetStyle: false,
Expand Down Expand Up @@ -63,7 +63,7 @@ describe('TableSheet Tests', () => {
[],
{
operator: expect.anything(),
onlyMenu: true,
onlyShowOperator: true,
forceRender: true,
},
);
Expand Down Expand Up @@ -199,7 +199,7 @@ describe('TableSheet Tests', () => {
expect.anything(),
{
forceRender: true,
onlyMenu: true,
onlyShowOperator: true,
operator: {
menus: [
{ icon: 'groupAsc', key: 'asc', text: groupAscText },
Expand Down Expand Up @@ -254,7 +254,7 @@ describe('TableSheet Tests', () => {
const sheet = new TableSheet(getContainer(), dataCfg, {
facet: (spreadsheet) => new CustomFacet(spreadsheet),
tooltip: {
showTooltip: false,
enable: false,
},
});

Expand Down
6 changes: 3 additions & 3 deletions packages/s2-core/__tests__/unit/utils/merge-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ describe('merge test', () => {
"supportCSSTransform": false,
"tooltip": Object {
"autoAdjustBoundary": "body",
"enable": false,
"operation": Object {
"hiddenColumns": false,
"menus": Array [],
"sort": false,
},
"showTooltip": false,
},
"totals": Object {},
"width": 600,
Expand All @@ -269,7 +269,7 @@ describe('merge test', () => {
test('should get custom options', () => {
const options = getSafetyOptions({
tooltip: {
showTooltip: false,
enable: false,
operation: {
sort: false,
menus: [
Expand All @@ -285,6 +285,7 @@ describe('merge test', () => {
expect(options.tooltip).toMatchInlineSnapshot(`
Object {
"autoAdjustBoundary": "body",
"enable": false,
"operation": Object {
"hiddenColumns": false,
"menus": Array [
Expand All @@ -295,7 +296,6 @@ describe('merge test', () => {
],
"sort": false,
},
"showTooltip": false,
}
`);
});
Expand Down
12 changes: 6 additions & 6 deletions packages/s2-core/__tests__/unit/utils/tooltip-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ describe('Tooltip Utils Tests', () => {
const type = getCellNameByType(cellType);

const tooltip: Tooltip = {
showTooltip: false,
enable: false,
content: '',
operation: {
hiddenColumns: true,
Expand All @@ -286,7 +286,7 @@ describe('Tooltip Utils Tests', () => {
menus: [{ key: 'menu-a', text: 'menu-a' }],
},
[type]: {
showTooltip: true,
enable: true,
operation: {
hiddenColumns: false,
menus: [{ key: 'menu-b', text: 'menu-b' }],
Expand All @@ -307,7 +307,7 @@ describe('Tooltip Utils Tests', () => {
);

expect(tooltipOptions).toEqual({
showTooltip: true,
enable: true,
content: '',
operation: {
hiddenColumns: false,
Expand Down Expand Up @@ -465,7 +465,7 @@ describe('Tooltip Utils Tests', () => {
return getTooltipData({
cellInfos: [cell as TooltipData],
options: {
showSingleTips: true,
onlyShowCellText: true,
},
targetCell: cell,
spreadsheet: s2,
Expand Down Expand Up @@ -501,7 +501,7 @@ describe('Tooltip Utils Tests', () => {
const tooltipData = getTooltipData({
cellInfos: [selectedCellMetas as TooltipData],
options: {
showSingleTips: false,
onlyShowCellText: false,
},
targetCell: null,
spreadsheet: s2,
Expand Down Expand Up @@ -552,7 +552,7 @@ describe('Tooltip Utils Tests', () => {
cellInfos: [],
options: {
enableFormat: true,
showSingleTips: false,
onlyShowCellText: false,
},
targetCell: cell.mockCell,
spreadsheet: s2,
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-core/__tests__/util/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const getTestTooltipData = (s2: SpreadSheet, cell: S2CellType) => {
cellInfos,
targetCell: cell,
options: {
showSingleTips: true,
onlyShowCellText: true,
},
});
};
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 @@ -47,7 +47,7 @@ export const DEFAULT_OPTIONS: Readonly<S2Options> = {
conditions: {},
totals: {},
tooltip: {
showTooltip: false,
enable: false,
autoAdjustBoundary: 'body',
operation: {
hiddenColumns: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-core/src/common/interface/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export type FullyIconName = {
export type ActionIconName = string | FullyIconName;

export interface HeaderActionIcon {
/*
/**
* 已注册的 icon 类型或自定义的 icon 类型名
* 如果是 string[], 则默认 icon 位置为右侧
*/
Expand Down
Loading
Loading