diff --git a/common/config/rush/version-policies.json b/common/config/rush/version-policies.json index a4a1eb3ce..7b5172ff6 100644 --- a/common/config/rush/version-policies.json +++ b/common/config/rush/version-policies.json @@ -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"}] diff --git a/docs/assets/api/en/methods.md b/docs/assets/api/en/methods.md index 06831e570..45e535a9c 100644 --- a/docs/assets/api/en/methods.md +++ b/docs/assets/api/en/methods.md @@ -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) diff --git a/docs/assets/api/zh/methods.md b/docs/assets/api/zh/methods.md index 71d3245bf..648b134e4 100644 --- a/docs/assets/api/zh/methods.md +++ b/docs/assets/api/zh/methods.md @@ -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) diff --git a/docs/assets/changelog/en/release.md b/docs/assets/changelog/en/release.md index 81b56dfb6..277b85117 100644 --- a/docs/assets/changelog/en/release.md +++ b/docs/assets/changelog/en/release.md @@ -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 diff --git a/docs/assets/changelog/zh/release.md b/docs/assets/changelog/zh/release.md index 1050d0e30..551fc283f 100644 --- a/docs/assets/changelog/zh/release.md +++ b/docs/assets/changelog/zh/release.md @@ -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 diff --git a/docs/assets/guide/en/edit/edit_cell.md b/docs/assets/guide/en/edit/edit_cell.md index f875b33af..ad7f25628 100644 --- a/docs/assets/guide/en/edit/edit_cell.md +++ b/docs/assets/guide/en/edit/edit_cell.md @@ -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; // ... diff --git a/docs/assets/guide/zh/edit/edit_cell.md b/docs/assets/guide/zh/edit/edit_cell.md index 7bfb06131..4ace715b8 100644 --- a/docs/assets/guide/zh/edit/edit_cell.md +++ b/docs/assets/guide/zh/edit/edit_cell.md @@ -277,7 +277,7 @@ interface ListTableConstructorOptions { 如未定义该接口则编辑值值默认不做校验,接口返回 false,校验失败则保留在编辑状态; -若需要实现异步校验,可以返回一个Promise对象,该Promise对象在校验成功时以真值解析,校验失败时以假值解析。 +若需要实现异步校验,可以返回一个 Promise 对象,该 Promise 对象在校验成功时以真值解析,校验失败时以假值解析。 ## 9. 相关 api @@ -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; // ... diff --git a/packages/openinula-vtable/package.json b/packages/openinula-vtable/package.json index a7bbd1a37..d2d20c7c1 100644 --- a/packages/openinula-vtable/package.json +++ b/packages/openinula-vtable/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/openinula-vtable", - "version": "1.5.2", + "version": "1.5.3", "description": "The openinula version of VTable", "keywords": [ "openinula", diff --git a/packages/react-vtable/package.json b/packages/react-vtable/package.json index a804c98d6..81dc3ff72 100644 --- a/packages/react-vtable/package.json +++ b/packages/react-vtable/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/react-vtable", - "version": "1.5.2", + "version": "1.5.3", "description": "The react version of VTable", "keywords": [ "react", diff --git a/packages/vtable-editors/package.json b/packages/vtable-editors/package.json index 406f5f73a..f23694d67 100644 --- a/packages/vtable-editors/package.json +++ b/packages/vtable-editors/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/vtable-editors", - "version": "1.5.2", + "version": "1.5.3", "description": "", "sideEffects": false, "main": "cjs/index.js", diff --git a/packages/vtable-export/package.json b/packages/vtable-export/package.json index 7237eb56b..446bd462a 100644 --- a/packages/vtable-export/package.json +++ b/packages/vtable-export/package.json @@ -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", diff --git a/packages/vtable-export/src/excel/index.ts b/packages/vtable-export/src/excel/index.ts index e47e48348..8ff6f214d 100644 --- a/packages/vtable-export/src/excel/index.ts +++ b/packages/vtable-export/src/excel/index.ts @@ -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; @@ -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; diff --git a/packages/vtable-search/package.json b/packages/vtable-search/package.json index 0635be7b6..ae4a2c864 100644 --- a/packages/vtable-search/package.json +++ b/packages/vtable-search/package.json @@ -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", diff --git a/packages/vtable/CHANGELOG.json b/packages/vtable/CHANGELOG.json index 3971d5943..e4cf8736e 100644 --- a/packages/vtable/CHANGELOG.json +++ b/packages/vtable/CHANGELOG.json @@ -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", diff --git a/packages/vtable/CHANGELOG.md b/packages/vtable/CHANGELOG.md index 83460a09e..2d5f53004 100644 --- a/packages/vtable/CHANGELOG.md +++ b/packages/vtable/CHANGELOG.md @@ -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 diff --git a/packages/vtable/package.json b/packages/vtable/package.json index f6f7e191e..7deddc248 100644 --- a/packages/vtable/package.json +++ b/packages/vtable/package.json @@ -1,6 +1,6 @@ { "name": "@visactor/vtable", - "version": "1.5.2", + "version": "1.5.3", "description": "canvas table width high performance", "keywords": [ "grid", diff --git a/packages/vtable/src/ListTable.ts b/packages/vtable/src/ListTable.ts index b28f24b50..458fa04c0 100644 --- a/packages/vtable/src/ListTable.ts +++ b/packages/vtable/src/ListTable.ts @@ -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); } } } diff --git a/packages/vtable/src/PivotTable.ts b/packages/vtable/src/PivotTable.ts index 44fa6e68d..604cb0bd9 100644 --- a/packages/vtable/src/PivotTable.ts +++ b/packages/vtable/src/PivotTable.ts @@ -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); } } } diff --git a/packages/vtable/src/edit/edit-manager.ts b/packages/vtable/src/edit/edit-manager.ts index 2f7fe0025..cc2303498 100644 --- a/packages/vtable/src/edit/edit-manager.ts +++ b/packages/vtable/src/edit/edit-manager.ts @@ -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; @@ -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) { // //自定义内容单元格不允许编辑 @@ -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 } }; diff --git a/packages/vtable/src/event/listener/container-dom.ts b/packages/vtable/src/event/listener/container-dom.ts index e03b2b1ee..e9ad0aab4 100644 --- a/packages/vtable/src/event/listener/container-dom.ts +++ b/packages/vtable/src/event/listener/container-dom.ts @@ -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; @@ -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) && @@ -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(); diff --git a/packages/vtable/src/event/scroll.ts b/packages/vtable/src/event/scroll.ts index bd80a4282..9078f2aad 100644 --- a/packages/vtable/src/event/scroll.ts +++ b/packages/vtable/src/event/scroll.ts @@ -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) { @@ -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 { diff --git a/packages/vtable/src/state/select/is-cell-select-highlight.ts b/packages/vtable/src/state/select/is-cell-select-highlight.ts index 2abaa146d..7361735cf 100644 --- a/packages/vtable/src/state/select/is-cell-select-highlight.ts +++ b/packages/vtable/src/state/select/is-cell-select-highlight.ts @@ -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; +} diff --git a/packages/vtable/src/ts-types/table-engine.ts b/packages/vtable/src/ts-types/table-engine.ts index 9dd669770..10c109ad6 100644 --- a/packages/vtable/src/ts-types/table-engine.ts +++ b/packages/vtable/src/ts-types/table-engine.ts @@ -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