Skip to content

Commit

Permalink
Merge pull request #669 from VisActor/release/0.15.4
Browse files Browse the repository at this point in the history
[Auto release] release 0.15.4
  • Loading branch information
Rui-Sun authored Dec 1, 2023
2 parents 677160d + ecbd3bf commit 3418328
Show file tree
Hide file tree
Showing 34 changed files with 357 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ body:
attributes:
label: Link to Minimal Reproduction
description: |
If the reproduction does not need a build setup, please provide a link to [Official Editor](TODO), [JSFiddle](TODO), [JSBin](https://jsbin.com/) or [CodePen](TODO). If it requires a build setup, you can use [CodeSandbox](TODO) or provide a GitHub repo.
If the reproduction does not need a build setup, please provide a link to [Official Editor](TODO), [JSFiddle](TODO), [JSBin](https://jsbin.com/) or [CodePen](TODO). If it requires a build setup, you can use [CodeSandbox](https://codesandbox.io/p/sandbox/vtable-bug-report-dd9pfl?file=%2Fsrc%2Findex.ts%3A57%2C11) or provide a GitHub repo.
The reproduction should be **minimal** - i.e. it should contain only the bare minimum amount of code needed to show the bug.
Please do not just fill in a random link. The issue will be closed if no valid reproduction is provided. [Why?](https://antfu.me/posts/why-reproductions-are-required)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/react-vtable",
"comment": "fix: fix types in react-vtable",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
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":"0.15.3","mainProject":"@visactor/vtable","nextBump":"patch"}]
[{"definitionName":"lockStepVersion","policyName":"vtableMain","version":"0.15.4","mainProject":"@visactor/vtable","nextBump":"patch"}]
18 changes: 15 additions & 3 deletions docs/assets/guide/en/basic_function/row_height_column_width.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,22 @@ const table = new VTable.ListTable({
defaultColWidth: 100,
});
```
## Default Column Width for Row Header

## Row header default column width

In addition to the default column width setting, VTable also supports setting the column width for row headers. Pass`defaultHeaderColWidth`The configuration item can be set. The configuration item can be set to one, which corresponds to the width of each row header column. The following code example shows how to set the width of the first row header column to 50 and the width of the second row header column to 60:
In addition to setting the default column width, VTable also supports setting the column width specifically for the row header. This can be achieved using the `defaultHeaderColWidth` configuration option, which can be an array representing the widths of each level of row header columns. The following code example demonstrates how to set the column width to 50 for the first-level row header column and 60 for the second-level row header column:

```javascript
const table = new VTable.ListTable({
defaultHeaderColWidth: [50, 60],
});
```

Please note that this configuration only applies to row headers. If you have column headers, this configuration option will not be considered (the logic will be based on the widths defined in the body section).

Specifically:
- For transposed basic tables, if you configure `defaultHeaderColWidth: [50, 'auto']`, it means that the first column of the transposed table header has a width of 50, and the second column adjusts its width based on the content of the cells.
- For pivot tables, if you configure `defaultHeaderColWidth: [50, 'auto']`, it means that the first column of the row header (first-level dimension) has a width of 50, and the second column (second-level dimension) adjusts its width based on the content of the cells.

## Column width limit: maxWidth + minWidth

In the process of configuring column widths, you may encounter scenarios where you need to limit the maximum or minimum column width of a column. VTable provides `maxWidth` and `maxWidth` Configuration items to limit the maximum and minimum column widths for each column. The following code example shows how to set a column to a maximum column width of 200 and a minimum column width of 50:
Expand Down Expand Up @@ -151,4 +156,11 @@ The calculation mode of table row height `heightMode` can also be configured as
- Adaptive container height mode (adaptive): Use the height of the container to allocate the height of each row.
- Automatic line height mode (autoHeight): Automatically calculate line height based on content, based on fontSize and lineHeight. The related configuration item `autoWrapText` automatically wraps lines, and can calculate the line height based on the multi-line text content after line wrapping.

# FAQ
## Setting Adaptive Content for Specific Columns to Calculate Column Width
If you don't want to calculate the column width for every column, you can use the `width` property in the `columns` configuration instead of setting `widthMode: 'autoWidth'`.

## Adapting Column Width Based on Header Content
If you only need to calculate the width based on the header content, you can use `columnWidthComputeMode: 'only-header'`. However, you need to use it in conjunction with `widthMode: 'autoWidth'`.

So far, we have introduced the table row height and column width calculation function in VTable, including row height, column width configuration, and table width mode. By mastering these functions, you can display and analyze data in VTable more conveniently to meet various practical needs.
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 @@ -38,7 +38,7 @@ VTable.register.editor('number-editor', numberEditor);
VTable.register.editor('date-editor', dateInputEditor);
VTable.register.editor('list-editor', listEditor);
```
Next, you need to specify the editor to use in the columns configuration:
Next, you need to specify the editor to use in the columns configuration(If it is a pivot table, configure the editor in indicators):

```javascript
columns: [
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/guide/en/theme_and_style/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Such as extending for DEFAULT

```
option.theme = vTable.themes.DEFAULT.extends({ headerStyle:{ color: 'red')})
option.theme = vTable.themes.DEFAULT.extends({ headerStyle:{ color: 'red'}})
const tableInstance = new vTable.ListTable(option);
```
Expand Down
103 changes: 82 additions & 21 deletions docs/assets/guide/zh/basic_function/row_height_column_width.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@

在数据分析领域,表格是一种常见的数据展示方式。正确设置表格的行高列宽对于提高数据可读性和美观性具有重要意义。本教程将围绕 VTable 中的表格行高列宽计算功能,带了解如何正确配置行高和列宽以满足实际需求。

# 行高配置
# 列宽计算模式

在 VTable 中,表格列宽度的计算模式`widthMode`可以配置为 `standard`(标准模式)、`adaptive`(自适应容器宽度模式)或 `autoWidth`(自动列宽模式)。[demo示例](https://visactor.io/vtable/demo/basic-functionality/width-mode-autoWidth)。(如果设置了`widthMode: 'autoWidth'`, 那么每一个单元格都会参与计算宽度,可想而知这个计算过程是需要耗费性能的。)

- 标准模式(standard):表格使用`width` 属性指定的宽度作为列宽度,如未指定,则采用 `defaultColWidth``defaultHeaderColWidth ` 设定的默认列宽。
- 自适应容器宽度模式(adaptive):在自适应容器宽度模式下表格使用容器的宽度分配列宽度(每列宽度的比例基于standard模式中的宽度值)。[demo示例](https://visactor.io/vtable/demo/basic-functionality/width-mode-adaptive)
- 自动列宽模式(autoWidth):在自动宽度模式下,根据列头和 body 单元格中的内容自动计算列宽度,忽略设置的 `width` 属性和 `defaultColWidth`

# 行高计算模式

表格行高度的计算模式`heightMode`也可以配置为 `standard`(标准模式)、`adaptive`(自适应容器宽度模式)或 `autoHeight`(自动行高模式)。

- 标准模式(standard):采用 `defaultRowHeight``defaultHeaderRowHeight` 作为行高。
- 自适应容器高度模式(adaptive):使用容器的高度分配每行高度。
- 自动行高模式(autoHeight):根据内容自动计算行高,计算依据fontSize和lineHeight。相关搭配设置项`autoWrapText`自动换行,可以根据换行后的多行文本内容来计算行高。

# 行高相关配置

## 默认行高

Expand All @@ -24,7 +40,45 @@ const table = new VTable.ListTable({
});
```

# 列宽配置
## 行高撑满容器:autoFillHeight
配置项 autoFillHeight,用于控制是否自动撑满容器高度。区别于高度模式`heightMode``adaptive`的自适应容器的效果,autoFillHeight 控制的是只有当行数较少的时候,表格可以自动撑满容器高度,但是当行数超过容器的时候根据真实情况来定行高可出现滚动条。
```javascript
const table = new VTable.ListTable({
autoFillHeight: true
});
```

# 列宽相关配置

## 列宽width
可以在列属性中配置具体的宽度值,或者百分比或者'auto'自动计算列宽。
```
width?: number | string;
```
基本表格配置列宽:

```javascript
const table = new VTable.ListTable({
columns: [
{
// ...其他配置项
width: 200,
},
],
});
```

透视表列宽配置:
```javascript
const table = new VTable.PivotTable({
indicators: [
{
// ...其他配置项
width: 200,
},
],
});
```

## 默认列宽

Expand All @@ -38,14 +92,20 @@ const table = new VTable.ListTable({

## 行表头默认列宽

除了默认列宽的设置,VTable还支持针对行表头的列宽进行设置。通过`defaultHeaderColWidth`配置项进行设置,该配置项可以设定为一个,分别对应各级行表头列的宽度。以下代码示例展示了如何设置一级行表头列宽为 50,二级行表头列宽为 60:
除了默认列宽的设置,VTable还支持针对行表头的列宽进行设置。通过`defaultHeaderColWidth`配置项进行设置,该配置项可以设定为一个,分别对应各级`行表头`列的宽度。以下代码示例展示了如何设置一级行表头列宽为 50,二级行表头列宽为 60:

```javascript
const table = new VTable.ListTable({
defaultHeaderColWidth: [50, 60],
});
```

需要注意的是:这个配置仅针对行表头起作用,如果是列表头的话是不考虑这个配置项的(会按body部分定义的宽度设置来执行逻辑)。

具体的如:
- 转置基本表格,如配置 defaultHeaderColWidth: [50, 'auto'], 表示转置表格的表头第一列宽度50,第二列按单元格内容适应宽度
- 透视表,如配置 defaultHeaderColWidth: [50, 'auto'], 表示透视表的行表头第一列宽度50(也即第一级维度),第二列(第二级维度)按单元格内容适应宽度。

## 列宽限制配置:maxWidth+minWidth

在配置列宽的过程中,您可能遇到需要限制某一列最大或最小列宽的场景。VTable 提供了 `maxWidth``maxWidth` 配置项,用于限制每一列的最大和最小列宽。以下代码示例展示了如何设置某一列的最大列宽为 200,最小列宽为 50:
Expand Down Expand Up @@ -93,29 +153,30 @@ const table = new VTable.ListTable({
autoFillWidth: true
});
```
## 按内容计算列宽只计算表头或者body部分:columnWidthComputeMode
计算内容宽度时限定只计算表头内容,或者body单元格内容,或者全部都适应计算。

## 行高撑满容器:autoFillHeight
配置项 autoFillHeight,用于控制是否自动撑满容器高度。区别于高度模式`heightMode``adaptive`的自适应容器的效果,autoFillHeight 控制的是只有当行数较少的时候,表格可以自动撑满容器高度,但是当行数超过容器的时候根据真实情况来定行高可出现滚动条。
配置项定义:
```
columnWidthComputeMode?: 'normal' | 'only-header' | 'only-body';
```
用法
```javascript
const table = new VTable.ListTable({
autoFillHeight: true
columns: [
{
// ...其他配置项
columnWidthComputeMode: 'only-header'
},
],
});
```

# 列宽计算模式
# FAQ
## 特定列设置自适应内容来计算列宽
如果并不是想每一列都需要计算列宽,可以使用columns中的width来定义,而不用设置`widthMode: 'autoWidth'`
## 列宽根据表头内容自适应
如果只需要计算表头内容宽度的话,可以用`columnWidthComputeMode: 'only-header'`来实现。不过需配合设置`widthMode:'autoWidth'`使用。

在 VTable 中,表格列宽度的计算模式`widthMode`可以配置为 `standard`(标准模式)、`adaptive`(自适应容器宽度模式)或 `autoWidth`(自动列宽模式)。[demo示例](https://visactor.io/vtable/demo/basic-functionality/width-mode-autoWidth)

- 标准模式(standard):表格使用`width` 属性指定的宽度作为列宽度,如未指定,则采用 `defaultColWidth``defaultHeaderColWidth ` 设定的默认列宽。
- 自适应容器宽度模式(adaptive):在自适应容器宽度模式下表格使用容器的宽度分配列宽度(每列宽度的比例基于standard模式中的宽度值)。[demo示例](https://visactor.io/vtable/demo/basic-functionality/width-mode-adaptive)
- 自动列宽模式(autoWidth):在自动宽度模式下,根据列头和 body 单元格中的内容自动计算列宽度,忽略设置的 `width` 属性和 `defaultColWidth`

# 行高计算模式

表格行高度的计算模式`heightMode`也可以配置为 `standard`(标准模式)、`adaptive`(自适应容器宽度模式)或 `autoHeight`(自动行高模式)。

- 标准模式(standard):采用 `defaultRowHeight``defaultHeaderRowHeight` 作为行高。
- 自适应容器高度模式(adaptive):使用容器的高度分配每行高度。
- 自动行高模式(autoHeight):根据内容自动计算行高,计算依据fontSize和lineHeight。相关搭配设置项`autoWrapText`自动换行,可以根据换行后的多行文本内容来计算行高。

至此,我们已经介绍了 VTable 中的表格行高列宽计算功能,包括行高、列宽配置,以及表格宽度模式。通过掌握这些功能,您可以更便捷地 VTable 中进行数据展示与分析,现各种实际需求。
至此,我们已经介绍了 VTable 中的表格行高列宽计算功能,包括行高、列宽配置,以及表格宽度模式。通过掌握这些功能,您可以更便捷地 VTable 中进行数据展示与分析,现各种实际需求。
2 changes: 1 addition & 1 deletion docs/assets/guide/zh/edit/edit_cell.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ VTable.register.editor('number-editor', numberEditor);
VTable.register.editor('date-editor', dateInputEditor);
VTable.register.editor('list-editor', listEditor);
```
接下来需要再columns配置中指定使用的编辑器:
接下来需要再columns配置中指定使用的编辑器(如果是透视表则在indicators配置editor)

```javascript
columns: [
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/guide/zh/theme_and_style/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ VTable 中内置一套默认主题/DEFAULT,一套ARCO风格,一套暗黑主

```
option.theme = vTable.themes.DEFAULT.extends({ headerStyle:{ color: 'red')})
option.theme = vTable.themes.DEFAULT.extends({ headerStyle:{ color: 'red'}})
const tableInstance = new vTable.ListTable(option);
```
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": "0.15.3",
"version": "0.15.4",
"description": "The react version of VTable",
"keywords": [
"react",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { BaseComponentProps } from '../base-component';
import { createComponent } from '../base-component';
import type { IDimension } from '@visactor/vtable';
import type { IRowDimension, IColumnDimension } from '@visactor/vtable';

export type PivotDimensionProps = IDimension & BaseComponentProps;
export type RowPivotDimensionProps = IRowDimension & BaseComponentProps;
export type ColumnPivotDimensionProps = IColumnDimension & BaseComponentProps;

export const PivotColumnDimension = createComponent<PivotDimensionProps>('PivotColumnDimension', 'columns');
export const PivotRowDimension = createComponent<PivotDimensionProps>('PivotRowDimension', 'rows');
export const PivotColumnDimension = createComponent<ColumnPivotDimensionProps>('PivotColumnDimension', 'columns');
export const PivotRowDimension = createComponent<RowPivotDimensionProps>('PivotRowDimension', 'rows');
3 changes: 3 additions & 0 deletions packages/react-vtable/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import * as VTable from '@visactor/vtable';

export * from './tables';
export * from './components';
export { VTable };
2 changes: 1 addition & 1 deletion packages/react-vtable/src/tables/list-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { BaseTableProps } from './base-table';
import { createTable } from './base-table';

export interface ListTableProps
extends Omit<BaseTableProps, 'option' | 'records' | 'type'>,
extends Omit<BaseTableProps, 'records' | 'type'>,
Omit<ListTableConstructorOptions, 'container'> {}

export const ListTable = createTable<React.PropsWithChildren<ListTableProps>>('ListTable', 'list-table');
2 changes: 1 addition & 1 deletion packages/react-vtable/src/tables/pivot-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { BaseTableProps } from './base-table';
import { createTable } from './base-table';

export interface PivotChartProps
extends Omit<BaseTableProps, 'option' | 'records' | 'type'>,
extends Omit<BaseTableProps, 'records' | 'type'>,
Omit<PivotChartConstructorOptions, 'container'> {}

export const PivotChart = createTable<React.PropsWithChildren<PivotChartProps>>('PivotChart', 'pivot-chart');
Expand Down
2 changes: 1 addition & 1 deletion packages/react-vtable/src/tables/pivot-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { BaseTableProps } from './base-table';
import { createTable } from './base-table';

export interface PivotTableProps
extends Omit<BaseTableProps, 'option' | 'records' | 'type'>,
extends Omit<BaseTableProps, 'records' | 'type'>,
Omit<PivotTableConstructorOptions, 'container'> {}

export const PivotTable = createTable<React.PropsWithChildren<PivotTableProps>>('PivotTable', 'pivot-table');
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": "0.15.3",
"version": "0.15.4",
"description": "",
"sideEffects": false,
"main": "cjs/index.js",
Expand Down
39 changes: 39 additions & 0 deletions packages/vtable/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
{
"name": "@visactor/vtable",
"entries": [
{
"version": "0.15.4",
"tag": "@visactor/vtable_v0.15.4",
"date": "Fri, 01 Dec 2023 10:28:56 GMT",
"comments": {
"none": [
{
"comment": "fix: editor object set in column be cloned\n\n"
},
{
"comment": "fix: fix theme style get problem"
},
{
"comment": "fix: fix list table frozen hover color"
},
{
"comment": "fix: fix right bottom frozen cell in getCellRect()"
},
{
"comment": "fix: fix table resize problem when column width limit"
},
{
"comment": "fix: fix custom render renderDefault auto size problem"
},
{
"comment": "fix: fix columnWidthComputeMode config problem"
},
{
"comment": "fix: release tableInstance after resize event trigger\n\n"
},
{
"comment": "refactor: ts define optimize\n\n"
},
{
"comment": "fix: columnWidthComputeMode only-header\n\n"
}
]
}
},
{
"version": "0.15.3",
"tag": "@visactor/vtable_v0.15.3",
Expand Down
26 changes: 25 additions & 1 deletion packages/vtable/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
# Change Log - @visactor/vtable

This log was last generated on Thu, 30 Nov 2023 10:46:46 GMT and should not be manually modified.
This log was last generated on Fri, 01 Dec 2023 10:28:56 GMT and should not be manually modified.

## 0.15.4
Fri, 01 Dec 2023 10:28:56 GMT

### Updates

- fix: editor object set in column be cloned


- fix: fix theme style get problem
- fix: fix list table frozen hover color
- fix: fix right bottom frozen cell in getCellRect()
- fix: fix table resize problem when column width limit
- fix: fix custom render renderDefault auto size problem
- fix: fix columnWidthComputeMode config problem
- fix: release tableInstance after resize event trigger


- refactor: ts define optimize


- fix: columnWidthComputeMode only-header



## 0.15.3
Thu, 30 Nov 2023 10:46:46 GMT
Expand Down
Loading

0 comments on commit 3418328

Please sign in to comment.