Skip to content

Commit

Permalink
refactor: rowCells 重命名为 currentRow,避免与行头 rowCell 定义冲突 (#2032)
Browse files Browse the repository at this point in the history
Co-authored-by: zishang <[email protected]>
  • Loading branch information
stone-lyl and zishang authored Jan 6, 2023
1 parent c073578 commit 179fa5c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ describe('Interaction Data Cell Brush Selection Tests', () => {
mockRootInteraction.getSelectedCellHighlight = () => ({
rowHeader: false,
colHeader: false,
rowCells: false,
colCells: false,
currentRow: false,
currentCol: false,
});
mockSpreadSheetInstance.interaction = mockRootInteraction;
mockSpreadSheetInstance.render();
Expand Down Expand Up @@ -144,8 +144,8 @@ describe('Interaction Data Cell Brush Selection Tests', () => {
mockRootInteraction.getSelectedCellHighlight = () => ({
rowHeader: true,
colHeader: true,
rowCells: false,
colCells: false,
currentRow: false,
currentCol: false,
});

brushSelectionInstance.getBrushRange = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ describe('Interaction Row Cell Brush Selection Tests', () => {
},
},
});
const rowCells = map(new Array(8), (a, i) => {
const currentRow = map(new Array(8), (a, i) => {
const customY = 30 * i + 30;

return {
Expand All @@ -244,7 +244,7 @@ describe('Interaction Row Cell Brush Selection Tests', () => {
} as RowCell;
});

mockRootInteraction.getAllRowHeaderCells = () => rowCells;
mockRootInteraction.getAllRowHeaderCells = () => currentRow;
mockSpreadSheetInstance.interaction = mockRootInteraction;
mockSpreadSheetInstance.facet.setScrollOffset({
hRowScrollX: 100,
Expand Down Expand Up @@ -277,7 +277,7 @@ describe('Interaction Row Cell Brush Selection Tests', () => {
);
// get brush range selected cells
expect(brushSelectionInstance.brushRangeCells).toHaveLength(
rowCells.length / 2,
currentRow.length / 2,
);
});
});
2 changes: 1 addition & 1 deletion packages/s2-core/__tests__/unit/utils/export/copy-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ describe('List Table Core Data Process', () => {
s2.setOptions({
interaction: {
selectedCellHighlight: {
rowCells: true,
currentRow: true,
},
},
});
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-core/src/common/constant/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ export enum ScrollDirection {
export interface InteractionCellSelectedHighlightType {
rowHeader?: boolean; // 高亮行头
colHeader?: boolean; // 高亮列头
rowCells?: boolean; // 高亮选中单元格所在行
colCells?: boolean; // 高亮选中单元格所在列
currentRow?: boolean; // 高亮选中单元格所在行
currentCol?: boolean; // 高亮选中单元格所在列
}
12 changes: 6 additions & 6 deletions packages/s2-core/src/interaction/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,23 +576,23 @@ export class RootInteraction {
return {
rowHeader: selectedCellHighlight,
colHeader: selectedCellHighlight,
rowCells: false,
colCells: false,
currentRow: false,
currentCol: false,
};
}

const {
rowHeader = false,
colHeader = false,
rowCells = false,
colCells = false,
currentRow = false,
currentCol = false,
} = selectedCellHighlight ?? {};

return {
rowHeader,
colHeader,
rowCells,
colCells,
currentRow,
currentCol,
};
}
}
10 changes: 5 additions & 5 deletions packages/s2-core/src/utils/cell/data-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export const getDataCellId = (rowIndex: string, colIndex: string) => {
};

export const shouldUpdateBySelectedCellsHighlight = (s2: SpreadSheet) => {
const { rowCells, colCells, rowHeader, colHeader } =
const { currentRow, currentCol, rowHeader, colHeader } =
s2.interaction.getSelectedCellHighlight();
return rowCells || colCells || rowHeader || colHeader;
return currentRow || currentCol || rowHeader || colHeader;
};

export const isDataCell = (cell: CellMeta) => {
Expand Down Expand Up @@ -109,18 +109,18 @@ export const updateBySelectedCellsHighlight = (
dataCell: DataCell,
s2: SpreadSheet,
) => {
const { rowHeader, colHeader, rowCells, colCells } =
const { rowHeader, colHeader, currentRow, currentCol } =
s2.interaction.getSelectedCellHighlight();

const isRowCell = dataCell.cellType === CellTypes.ROW_CELL;
// 高亮序号
const showSNWhenRowHeaderHighlight =
s2.isTableMode() && s2.options.showSeriesNumber && rowHeader && isRowCell;

if (rowCells || showSNWhenRowHeaderHighlight) {
if (currentRow || showSNWhenRowHeaderHighlight) {
updateCurrentRowCellState(cells, dataCell);
}
if (colCells) {
if (currentCol) {
updateCurrentColumnCellState(cells, dataCell);
}
if (rowHeader || colHeader) {
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-core/src/utils/export/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,9 @@ function getDataCellCopyable(
}
// normal selected
const selectedCellsMeta = getSelectedCellsMeta(cells);
const { rowCells } = spreadsheet.interaction.getSelectedCellHighlight();
const { currentRow } = spreadsheet.interaction.getSelectedCellHighlight();

if (rowCells) {
if (currentRow) {
const rowData = orderBy(cells, 'rowIndex', 'asc').map((cell) =>
spreadsheet.dataSet.getRowData(cell),
);
Expand Down
12 changes: 6 additions & 6 deletions packages/s2-react/playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,8 @@ function MainLayout() {
selectedCellHighlight = {
rowHeader: false,
colHeader: false,
rowCells: false,
colCells: false,
currentCol: false,
currentRow: false,
};
type.forEach((i) => {
selectedCellHighlight[i] = true;
Expand All @@ -906,11 +906,11 @@ function MainLayout() {
<Select.Option value="colHeader">
colHeader: 高亮所在列头
</Select.Option>
<Select.Option value="rowCells">
rowCells: 高亮所在行
<Select.Option value="currentRow">
currentRow: 高亮所在行
</Select.Option>
<Select.Option value="colCells">
colCells: 高亮所在列
<Select.Option value="currentCol">
currentCol: 高亮所在列
</Select.Option>
</Select>
</Tooltip>
Expand Down

1 comment on commit 179fa5c

@vercel
Copy link

@vercel vercel bot commented on 179fa5c Jan 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

antvis-s2 – ./

antvis-s2.vercel.app
antvis-s2-antv-s2.vercel.app
antvis-s2-git-master-antv-s2.vercel.app

Please sign in to comment.