Skip to content

Commit

Permalink
Merge pull request #2103 from VisActor/release/1.5.3
Browse files Browse the repository at this point in the history
[Auto release] release 1.5.3
  • Loading branch information
fangsmile committed Jul 19, 2024
2 parents dba7450 + 1f73b57 commit efe9cf0
Show file tree
Hide file tree
Showing 23 changed files with 138 additions and 32 deletions.
2 changes: 1 addition & 1 deletion common/config/rush/version-policies.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"definitionName":"lockStepVersion","policyName":"vtableMain","version":"1.5.2","mainProject":"@visactor/vtable","nextBump":"patch"}]
[{"definitionName":"lockStepVersion","policyName":"vtableMain","version":"1.5.3","mainProject":"@visactor/vtable","nextBump":"patch"}]
6 changes: 4 additions & 2 deletions docs/assets/api/en/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -879,11 +879,13 @@ Get the editor for the cell configuration

## startEditCell(Function)

Enable cell editing
Enable cell editing.

If you want to change the value displayed in the edit box, you can configure the value to set the change

```
/** Enable cell editing */
startEditCell: (col?: number, row?: number) => void;
startEditCell: (col?: number, row?: number, value?: string | number) => void;
```

## completeEditCell(Function)
Expand Down
6 changes: 4 additions & 2 deletions docs/assets/api/zh/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -877,11 +877,13 @@ use case: 点击图例项后 更新过滤规则 来更新图表

## startEditCell(Function)

开启单元格编辑
开启单元格编辑。

如果想要改变显示到编辑框中的值 可以配置上 value 来设置改变

```
/** 开启单元格编辑 */
startEditCell: (col?: number, row?: number) => void;
startEditCell: (col?: number, row?: number, value?: string | number) => void;
```

## completeEditCell(Function)
Expand Down
22 changes: 22 additions & 0 deletions docs/assets/changelog/en/release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# v1.5.2

2024-07-15


**🆕 New feature**

- **@visactor/vtable**: add api disableScroll and enableScroll [#2073](https://github.com/VisActor/VTable/issues/2073)
- **@visactor/vtable**: add renderDefault prop in react customLayout component
- **@visactor/vtable**: support multiple columns tag in react-vtable

**🐛 Bug fix**

- **@visactor/vtable**: edit api validateValue support async
- **@visactor/vtable**: api changeFieldValue occor errow when records has null [#2067](https://github.com/VisActor/VTable/issues/2067)
- **@visactor/vtable**: fix react component error in updateCell() [#2038](https://github.com/VisActor/VTable/issues/2038)
- **@visactor/vtable**: fix axes default config in scatter chart [#2071](https://github.com/VisActor/VTable/issues/2071)



[more detail about v1.5.2](https://github.com/VisActor/VTable/releases/tag/v1.5.2)

# v1.5.1

2024-07-10
Expand Down
22 changes: 22 additions & 0 deletions docs/assets/changelog/zh/release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# v1.5.2

2024-07-15


**🆕 新增功能**

- **@visactor/vtable**: add api disableScroll and enableScroll [#2073](https://github.com/VisActor/VTable/issues/2073)
- **@visactor/vtable**: add renderDefault prop in react customLayout component
- **@visactor/vtable**: support multiple columns tag in react-vtable

**🐛 功能修复**

- **@visactor/vtable**: edit api validateValue support async
- **@visactor/vtable**: api changeFieldValue occor errow when records has null [#2067](https://github.com/VisActor/VTable/issues/2067)
- **@visactor/vtable**: fix react component error in updateCell() [#2038](https://github.com/VisActor/VTable/issues/2038)
- **@visactor/vtable**: fix axes default config in scatter chart [#2071](https://github.com/VisActor/VTable/issues/2071)



[更多详情请查看 v1.5.2](https://github.com/VisActor/VTable/releases/tag/v1.5.2)

# v1.5.1

2024-07-10
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/guide/en/edit/edit_cell.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ interface ListTableAPI {
/** Get the editor of cell configuration */
getEditor: (col: number, row: number) => IEditor;
/** Enable cell editing */
startEditCell: (col?: number, row?: number) => void;
startEditCell: (col?: number, row?: number, value?: string | number) => void;
/** End editing */
completeEditCell: () => void;
// ...
Expand Down
4 changes: 2 additions & 2 deletions docs/assets/guide/zh/edit/edit_cell.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ interface ListTableConstructorOptions {

如未定义该接口则编辑值值默认不做校验,接口返回 false,校验失败则保留在编辑状态;

若需要实现异步校验,可以返回一个Promise对象,该Promise对象在校验成功时以真值解析,校验失败时以假值解析。
若需要实现异步校验,可以返回一个 Promise 对象,该 Promise 对象在校验成功时以真值解析,校验失败时以假值解析。

## 9. 相关 api

Expand All @@ -296,7 +296,7 @@ interface ListTableAPI {
/** 获取单元格配置的编辑器 */
getEditor: (col: number, row: number) => IEditor;
/** 开启单元格编辑 */
startEditCell: (col?: number, row?: number) => void;
startEditCell: (col?: number, row?: number, value?: string | number) => void;
/** 结束编辑 */
completeEditCell: () => void;
// ...
Expand Down
2 changes: 1 addition & 1 deletion packages/openinula-vtable/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@visactor/openinula-vtable",
"version": "1.5.2",
"version": "1.5.3",
"description": "The openinula version of VTable",
"keywords": [
"openinula",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-vtable/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@visactor/react-vtable",
"version": "1.5.2",
"version": "1.5.3",
"description": "The react version of VTable",
"keywords": [
"react",
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable-editors/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@visactor/vtable-editors",
"version": "1.5.2",
"version": "1.5.3",
"description": "",
"sideEffects": false,
"main": "cjs/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable-export/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@visactor/vtable-export",
"version": "1.5.2",
"version": "1.5.3",
"description": "The export util of VTable",
"author": {
"name": "VisActor",
Expand Down
4 changes: 2 additions & 2 deletions packages/vtable-export/src/excel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function addCell(
const offset = getHierarchyOffset(col, row, tableInstance as any);
cell.alignment = getCellAlignment(cellStyle, Math.ceil(offset / cell.font.size));

if (cell && options.formatExcelJSCell) {
if (cell && options?.formatExcelJSCell) {
const formatedCell = options.formatExcelJSCell({ cellType, cellValue, table: tableInstance, col, row }, cell);
if (formatedCell) {
cell = formatedCell;
Expand Down Expand Up @@ -198,7 +198,7 @@ function addCell(
tableInstance.scenegraph.updateNextFrame(); // rerender chart to avoid display error
}

if (cell && options.formatExcelJSCell) {
if (cell && options?.formatExcelJSCell) {
const formatedCell = options.formatExcelJSCell({ cellType, cellValue, table: tableInstance, col, row }, cell);
if (formatedCell) {
cell = formatedCell;
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable-search/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@visactor/vtable-search",
"version": "1.5.2",
"version": "1.5.3",
"description": "The search util of VTable",
"author": {
"name": "VisActor",
Expand Down
15 changes: 15 additions & 0 deletions packages/vtable/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"name": "@visactor/vtable",
"entries": [
{
"version": "1.5.3",
"tag": "@visactor/vtable_v1.5.3",
"date": "Thu, 18 Jul 2024 12:13:07 GMT",
"comments": {
"none": [
{
"comment": "feat: add param value for startEditCell api #2089\n\n"
},
{
"comment": "fix: fix option config in vtable-export"
}
]
}
},
{
"version": "1.5.2",
"tag": "@visactor/vtable_v1.5.2",
Expand Down
12 changes: 11 additions & 1 deletion packages/vtable/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Change Log - @visactor/vtable

This log was last generated on Fri, 12 Jul 2024 10:47:37 GMT and should not be manually modified.
This log was last generated on Thu, 18 Jul 2024 12:13:07 GMT and should not be manually modified.

## 1.5.3
Thu, 18 Jul 2024 12:13:07 GMT

### Updates

- feat: add param value for startEditCell api #2089


- fix: fix option config in vtable-export

## 1.5.2
Fri, 12 Jul 2024 10:47:37 GMT
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@visactor/vtable",
"version": "1.5.2",
"version": "1.5.3",
"description": "canvas table width high performance",
"keywords": [
"grid",
Expand Down
8 changes: 4 additions & 4 deletions packages/vtable/src/ListTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1101,16 +1101,16 @@ export class ListTable extends BaseTable implements ListTableAPI {
this.dataSource.setRecord(record, index);
this._refreshHierarchyState(col, row);
}
/** 开启单元格编辑 */
startEditCell(col?: number, row?: number) {

startEditCell(col?: number, row?: number, value?: string | number) {
if (isValid(col) && isValid(row)) {
this.eventManager.isDraging = false;
this.selectCell(col, row);
this.editorManager.startEditCell(col, row);
this.editorManager.startEditCell(col, row, value);
} else if (this.stateManager.select?.cellPos) {
const { col, row } = this.stateManager.select.cellPos;
if (isValid(col) && isValid(row)) {
this.editorManager.startEditCell(col, row);
this.editorManager.startEditCell(col, row, value);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/vtable/src/PivotTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1572,16 +1572,16 @@ export class PivotTable extends BaseTable implements PivotTableAPI {
}
}
}
/** 开启单元格编辑 */
startEditCell(col?: number, row?: number) {

startEditCell(col?: number, row?: number, value?: string | number) {
if (isValid(col) && isValid(row)) {
this.eventManager.isDraging = false;
this.selectCell(col, row);
this.editorManager.startEditCell(col, row);
this.editorManager.startEditCell(col, row, value);
} else if (this.stateManager.select?.cellPos) {
const { col, row } = this.stateManager.select.cellPos;
if (isValid(col) && isValid(row)) {
this.editorManager.startEditCell(col, row);
this.editorManager.startEditCell(col, row, value);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/vtable/src/edit/edit-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ListTableAPI, ListTableConstructorOptions } from '../ts-types';
import { getCellEventArgsSet } from '../event/util';
import type { SimpleHeaderLayoutMap } from '../layout';
import { isPromise } from '../tools/helper';
import { isValid } from '@visactor/vutils';

export class EditManeger {
table: BaseTableAPI;
Expand Down Expand Up @@ -58,7 +59,7 @@ export class EditManeger {
});
}

startEditCell(col: number, row: number) {
startEditCell(col: number, row: number, value?: string | number) {
const editor = (this.table as ListTableAPI).getEditor(col, row);
if (editor) {
// //自定义内容单元格不允许编辑
Expand All @@ -83,7 +84,7 @@ export class EditManeger {
this.editCell = { col, row };
}
this.editingEditor = editor;
const dataValue = this.table.getCellOriginValue(col, row);
const dataValue = isValid(value) ? value : this.table.getCellOriginValue(col, row);
const rect = this.table.getCellRangeRelativeRect(this.table.getCellRange(col, row));
const referencePosition = { rect: { left: rect.left, top: rect.top, width: rect.width, height: rect.height } };

Expand Down
10 changes: 9 additions & 1 deletion packages/vtable/src/event/listener/container-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { browser } from '../../tools/helper';
import type { EventManager } from '../event';
import { getPixelRatio } from '../../tools/pixel-ratio';
import { endResizeCol, endResizeRow } from './table-group';

import { isCellDisableSelect } from '../../state/select/is-cell-select-highlight';
export function bindContainerDomListener(eventManager: EventManager) {
const table = eventManager.table;
const stateManager = table.stateManager;
Expand Down Expand Up @@ -107,6 +107,10 @@ export function bindContainerDomListener(eventManager: EventManager) {
targetCol = Math.min(table.colCount - 1, Math.max(0, stateManager.select.cellPos.col + 1));
}
}
// 如果是不支持选中的单元格 则退出
if (isCellDisableSelect(table, targetCol, targetRow)) {
return;
}
table.selectCell(targetCol, targetRow, e.shiftKey);
if (
(table.options.keyboardOptions?.moveEditCellOnArrowKeys ?? false) &&
Expand Down Expand Up @@ -162,6 +166,10 @@ export function bindContainerDomListener(eventManager: EventManager) {
targetRow = stateManager.select.cellPos.row;
targetCol = stateManager.select.cellPos.col + 1;
}
// 如果是不支持选中的单元格 则退出
if (isCellDisableSelect(table, targetCol, targetRow)) {
return;
}
table.selectCell(targetCol, targetRow);
if ((table as ListTableAPI).editorManager?.editingEditor) {
(table as ListTableAPI).editorManager.completeEdit();
Expand Down
10 changes: 8 additions & 2 deletions packages/vtable/src/event/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ function isScrollToTop(deltaY: number, state: StateManager) {
}

function isScrollToBottom(deltaY: number, state: StateManager) {
// 这里加入tolerance,避免出现无用滚动
const sizeTolerance = state.table.options.customConfig?._disableColumnAndRowSizeRound ? 1 : 0;

const totalHeight = state.table.getAllRowsHeight() - state.table.scenegraph.height;
return totalHeight !== 0 && deltaY >= 0 && Math.abs(state.scroll.verticalBarPos - totalHeight) < 1;
return totalHeight !== 0 && deltaY >= 0 && Math.abs(state.scroll.verticalBarPos - totalHeight) < 1 + sizeTolerance;
}

function isScrollToLeft(deltaX: number, state: StateManager) {
Expand All @@ -94,8 +97,11 @@ function isScrollToLeft(deltaX: number, state: StateManager) {
}

function isScrollToRight(deltaX: number, state: StateManager) {
// 这里加入tolerance,避免出现无用滚动
const sizeTolerance = state.table.options.customConfig?._disableColumnAndRowSizeRound ? 1 : 0;

const totalWidth = state.table.getAllColsWidth() - state.table.scenegraph.width;
return totalWidth !== 0 && deltaX >= 0 && Math.abs(state.scroll.horizontalBarPos - totalWidth) < 1;
return totalWidth !== 0 && deltaX >= 0 && Math.abs(state.scroll.horizontalBarPos - totalWidth) < 1 + sizeTolerance;
}

export class InertiaScroll {
Expand Down
12 changes: 12 additions & 0 deletions packages/vtable/src/state/select/is-cell-select-highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,15 @@ export function isCellSelected(state: StateManager, col: number, row: number, ce
}
return selectMode;
}

export function isCellDisableSelect(table: BaseTableAPI, col: number, row: number) {
const columnDefine = table.getBodyColumnDefine(col, row);
const isHeader = table.isHeader(col, row);
if ((columnDefine as ColumnDefine)?.disableSelect && !isHeader) {
return true;
}
if (isHeader && (columnDefine as ColumnDefine)?.disableHeaderSelect) {
return true;
}
return false;
}
10 changes: 8 additions & 2 deletions packages/vtable/src/ts-types/table-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,14 @@ export interface ListTableAPI extends BaseTableAPI {
//#region 编辑器相关demo
/** 获取单元格配置的编辑器 */
getEditor: (col: number, row: number) => IEditor;
/** 开启单元格编辑 */
startEditCell: (col?: number, row?: number) => void;
/**
* 开启单元格编辑
* @param col
* @param row
* @param value 如果想要改变显示到编辑框中的值 可以value来设置改变
* @returns
*/
startEditCell: (col?: number, row?: number, value?: string | number) => void;
/** 结束编辑 */
completeEditCell: () => void;
//#endregion
Expand Down

0 comments on commit efe9cf0

Please sign in to comment.