Skip to content

Commit 9a81998

Browse files
authored
Merge pull request #3792 from VisActor/3788-bug-focusHighlight-plugin
3788 bug focus highlight plugin
2 parents b56bd12 + c4816b4 commit 9a81998

24 files changed

+233
-86
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "refactor: plugins update progress #3788\n\n",
5+
"type": "none",
6+
"packageName": "@visactor/vtable"
7+
}
8+
],
9+
"packageName": "@visactor/vtable",
10+
"email": "892739385@qq.com"
11+
}

docs/assets/api/en/methods.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,12 @@
66

77
Update table configuration items, which will be automatically redrawn after being called.
88

9-
updateConfig parameter description:
10-
11-
- keepData: When the new option does not pass in records or dataSource, whether to retain the original data. The default is false
12-
139
```ts
1410
/**
1511
*Update options currently only support full updates
1612
* @param options
1713
*/
18-
updateOption(options: BaseTableConstructorOptions,updateConfig?:{
19-
//When the new option does not pass in records or dataSource, whether to retain the original data. The default is false
20-
keepData?:boolean
21-
}) => void
14+
updateOption(options: BaseTableConstructorOptions) => void
2215
```
2316

2417
If you need to update a single configuration item, please refer to the other `update**` interfaces below

docs/assets/api/zh/methods.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,12 @@
66

77
更新表格配置项,调用后会自动重绘。
88

9-
updateConfig 参数说明:
10-
11-
- keepData: 当新的option没有传入records或者dataSource时,是否保留原本的数据。默认为false
12-
139
```ts
1410
/**
1511
* 更新options 目前只支持全量更新
1612
* @param options
1713
*/
18-
updateOption(options: BaseTableConstructorOptions,updateConfig?:{
19-
//当新的option没有传入records或者dataSource时,是否保留原本的数据
20-
keepData?:boolean
21-
}) => void
14+
updateOption(options: BaseTableConstructorOptions) => void
2215
```
2316

2417
如果需要更新单个配置项,请参考下面其他`update**`接口

docs/assets/demo/zh/plugin/excel-online-editing.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ VTable.register.editor('input', input_editor);
6161
});
6262

6363
const columnSeries = new VTablePlugins.ColumnSeriesPlugin({
64-
columnCount: 26
64+
columnCount: 26,
65+
autoExtendColumnTriggerKeys: ['ArrowRight', 'Tab']
6566
});
6667
const rowSeries = new VTablePlugins.RowSeriesPlugin({
6768
rowCount: 100,
69+
autoExtendRowTriggerKeys: ['ArrowDown', 'Enter'],
6870
//records数据以外 填充空行数据
6971
fillRowRecord: (index) => {
7072
return [];
@@ -105,7 +107,11 @@ VTable.register.editor('input', input_editor);
105107
textAlign: 'center'
106108
}
107109
}),
110+
frozenColCount: 1,
108111
defaultRowHeight: 30,
112+
keyboardOptions: {
113+
moveFocusCellOnEnter: true
114+
},
109115
plugins: [addRowColumn, columnSeries, rowSeries, highlightPlugin, excelEditCellKeyboardPlugin]
110116
};
111117
const tableInstance = new VTable.ListTable( document.getElementById(CONTAINER_ID),option);

docs/assets/guide/en/plugin/contribute.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ Plugins need to implement the `VTable.plugins.IVTablePlugin` interface.
1919
export interface IVTablePlugin {
2020
// Plugin unique identifier
2121
id: string;
22+
// Plugin name
23+
name: string;
2224
// Plugin runtime trigger
2325
runTime: TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][];
2426
// Initialization method, called after VTable instance creation and before first render
2527
run: (...args: any[]) => void;
2628
// Update method, called when table data or configuration updates
27-
update?: (table: BaseTableAPI, options?: any) => void;
29+
update?: () => void;
2830
// Destruction method, called before VTable instance is destroyed
2931
release?: (table: BaseTableAPI) => void;
3032
}
@@ -46,7 +48,7 @@ sequenceDiagram
4648
participant ListTable
4749
participant EventManager
4850
participant PluginManager
49-
participant Plugin as IVTablePlugin
51+
participant Plugin as VTablePlugin
5052
participant RenderManager
5153
5254
%% Initialization
@@ -65,13 +67,17 @@ sequenceDiagram
6567
Plugin->>Plugin: process event logic
6668
end
6769
68-
Plugin->>RenderManager: requestRender()
69-
RenderManager->>ListTable: render updates
70+
Plugin->>ListTable: render request to update table
7071
ListTable->>DOM: update display
7172
72-
%% Release
73+
74+
%% table.updateOption
75+
ListTable->>PluginManager: updateOption
76+
PluginManager->>Plugin: updatePlugins()
77+
%% table.release
7378
ListTable->>PluginManager: release
7479
PluginManager->>Plugin: release()
80+
7581
```
7682

7783
From the above diagram, you can understand the runtime timing of plugins:

docs/assets/guide/en/plugin/row-column-series.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface ColumnSeriesOptions {
1919
* Whether to automatically extend columns
2020
* @default true
2121
*/
22-
autoExtendColumn?: boolean;
22+
autoExtendColumnTriggerKeys?: ('ArrowRight' | 'Tab')[];
2323
}
2424

2525
export interface RowSeriesOptions {
@@ -30,7 +30,7 @@ export interface RowSeriesOptions {
3030
* Whether to automatically extend rows
3131
* @default true
3232
*/
33-
autoExtendRow?: boolean;
33+
autoExtendRowTriggerKeys?: ('ArrowDown' | 'Enter')[];
3434
}
3535
```
3636

docs/assets/guide/zh/plugin/contribute.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
export interface IVTablePlugin {
2020
// 插件唯一标识
2121
id: string;
22+
// 插件名称
23+
name: string;
2224
// 插件运行时机
2325
runTime: TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][];
2426
// 初始化方法,在VTable实例创建后、首次渲染前调用
2527
run: (...args: any[]) => void;
2628
// 更新方法,当表格数据或配置更新时调用
27-
update?: (table: BaseTableAPI, options?: any) => void;
29+
update?: () => void;
2830
// 销毁方法,在VTable实例销毁前调用
2931
release?: (table: BaseTableAPI) => void;
3032
}
@@ -46,7 +48,7 @@ sequenceDiagram
4648
participant ListTable
4749
participant EventManager
4850
participant PluginManager
49-
participant Plugin as IVTablePlugin
51+
participant Plugin as VTablePlugin
5052
participant RenderManager
5153
5254
%% Initialization
@@ -65,13 +67,17 @@ sequenceDiagram
6567
Plugin->>Plugin: process event logic
6668
end
6769
68-
Plugin->>RenderManager: requestRender()
69-
RenderManager->>ListTable: render updates
70+
Plugin->>ListTable: render request to update table
7071
ListTable->>DOM: update display
7172
72-
%% Release
73+
74+
%% table.updateOption
75+
ListTable->>PluginManager: updateOption
76+
PluginManager->>Plugin: updatePlugins()
77+
%% table.release
7378
ListTable->>PluginManager: release
7479
PluginManager->>Plugin: release()
80+
7581
```
7682

7783
通过上图可以了解到插件的运行时机:

docs/assets/guide/zh/plugin/row-column-series.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface ColumnSeriesOptions {
1919
* 是否自动扩展列
2020
* @default true
2121
*/
22-
autoExtendColumn?: boolean;
22+
autoExtendColumnTriggerKeys?: ('ArrowRight' | 'Tab')[];
2323
}
2424

2525
export interface RowSeriesOptions {
@@ -30,7 +30,7 @@ export interface RowSeriesOptions {
3030
* 是否自动扩展行
3131
* @default true
3232
*/
33-
autoExtendRow?: boolean;
33+
autoExtendRowTriggerKeys?: ('ArrowDown' | 'Enter')[];
3434
}
3535
```
3636

packages/vtable-plugins/demo/combine-plugins/combine-plugins.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ export function createTable() {
3131
});
3232

3333
const columnSeries = new ColumnSeriesPlugin({
34-
columnCount: 3
34+
columnCount: 26,
35+
autoExtendColumnTriggerKeys: ['ArrowRight', 'Tab']
3536
});
3637
const rowSeries = new RowSeriesPlugin({
37-
rowCount: 6,
38+
rowCount: 100,
39+
autoExtendRowTriggerKeys: ['ArrowDown', 'Enter'],
3840
fillRowRecord: (index: number) => {
3941
return [];
4042
},
@@ -74,11 +76,12 @@ export function createTable() {
7476
textAlign: 'center'
7577
}
7678
}),
79+
frozenColCount: 1,
80+
defaultRowHeight: 30,
7781
keyboardOptions: {
7882
moveFocusCellOnEnter: true
7983
// editCellOnEnter: false
8084
},
81-
defaultRowHeight: 30,
8285
plugins: [addRowColumn, columnSeries, rowSeries, highlightPlugin, excelEditCellKeyboardPlugin]
8386
};
8487
const tableInstance = new VTable.ListTable(option);

packages/vtable-plugins/demo/focus-highlight/focus-highlight.ts

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,70 @@ export function createTable() {
100100
};
101101
const tableInstance = new VTable.ListTable(option);
102102
window.tableInstance = tableInstance;
103-
103+
const columns1: VTable.ColumnsDefine = [
104+
{
105+
field: 'image',
106+
title: '行号',
107+
width: 80,
108+
cellType: 'image',
109+
keepAspectRatio: true
110+
},
111+
{
112+
field: 'id',
113+
title: 'ID',
114+
width: 'auto',
115+
minWidth: 50,
116+
sort: true
117+
},
118+
{
119+
field: 'email1',
120+
title: 'email',
121+
width: 200,
122+
sort: true,
123+
style: {
124+
underline: true,
125+
underlineDash: [2, 0],
126+
underlineOffset: 3
127+
}
128+
},
129+
{
130+
title: 'full name',
131+
columns: [
132+
{
133+
field: 'name',
134+
title: 'First Name',
135+
width: 200
136+
},
137+
{
138+
field: 'name',
139+
title: 'Last Name',
140+
width: 200
141+
}
142+
]
143+
},
144+
{
145+
field: 'date1',
146+
title: 'birthday',
147+
width: 200
148+
}
149+
];
150+
setTimeout(() => {
151+
const option1: VTable.ListTableConstructorOptions = {
152+
container: document.getElementById(CONTAINER_ID),
153+
records,
154+
columns: columns1,
155+
theme: VTable.themes.DARK,
156+
select: {
157+
headerSelectMode: 'cell'
158+
},
159+
// heightMode: 'adaptive',
160+
// select: {
161+
// disableSelect: true
162+
// },
163+
plugins: [highlightPlugin]
164+
};
165+
tableInstance.updateOption(option1);
166+
}, 2000);
104167
bindDebugTool(tableInstance.scenegraph.stage, {
105168
customGrapicKeys: ['col', 'row']
106169
});

packages/vtable-plugins/demo/highlight-header/highlight-header.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,50 @@ export function createTable() {
9494
};
9595
const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID)!, option);
9696
window.tableInstance = tableInstance;
97+
const columns1: VTable.ColumnsDefine = [
98+
{
99+
field: 'id',
100+
title: 'ID ( input-editor )',
101+
width: 'auto',
102+
minWidth: 50,
103+
sort: true,
104+
headerEditor: 'input-editor',
105+
editor: 'input-editor'
106+
},
107+
{
108+
field: 'date1',
109+
title: 'birthday ( date_input_editor )',
110+
width: 300,
111+
editor: 'date_input_editor'
112+
},
113+
{
114+
field: 'sex',
115+
title: 'sex ( list_editor )',
116+
width: 300,
117+
editor: 'list_editor'
118+
}
119+
];
120+
setTimeout(() => {
121+
const option1: VTable.ListTableConstructorOptions = {
122+
container: document.getElementById(CONTAINER_ID),
123+
records,
124+
columns: columns1,
125+
select: {
126+
outsideClickDeselect: true,
127+
headerSelectMode: 'body'
128+
},
97129

130+
editCellTrigger: 'click',
131+
autoWrapText: true,
132+
editor: 'input-editor',
133+
menu: {
134+
contextMenuItems: ['copy', 'paste', 'delete', '...']
135+
},
136+
rowSeriesNumber: {},
137+
plugins: [highlightPlugin]
138+
};
139+
tableInstance.updateOption(option1);
140+
}, 2000);
98141
bindDebugTool(tableInstance.scenegraph.stage, {
99142
customGrapicKeys: ['col', 'row']
100143
});

packages/vtable-plugins/src/add-row-column.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export interface AddRowColumnOptions {
2727
* 当鼠标离开table的cell时,会隐藏添加行和列的dot和加号
2828
*/
2929
export class AddRowColumnPlugin implements VTable.plugins.IVTablePlugin {
30-
id = 'add-row-column';
30+
id = `add-row-column-${Date.now()}`;
31+
name = 'Add Row Column';
3132
runTime = [
3233
VTable.TABLE_EVENT_TYPE.MOUSEENTER_CELL,
3334
VTable.TABLE_EVENT_TYPE.MOUSELEAVE_CELL,

packages/vtable-plugins/src/carousel-animation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface ICarouselAnimationPluginOptions {
1717
customDistColFunction?: (col: number, table: BaseTableAPI) => { distCol: number; animation?: boolean } | undefined;
1818
}
1919

20+
/** @deprecated 请使用 TableCarouselAnimationPlugin 代替 */
2021
export class CarouselAnimationPlugin {
2122
table: BaseTableAPI;
2223

0 commit comments

Comments
 (0)