Skip to content

Commit

Permalink
Merge pull request #1994 from VisActor/feat/package-size
Browse files Browse the repository at this point in the history
Feat/package size
  • Loading branch information
Rui-Sun committed Jul 5, 2024
2 parents fbcaa1c + cb663df commit d1b4d94
Show file tree
Hide file tree
Showing 87 changed files with 590 additions and 1,202 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "feat: optimize package size & add load on demand feature",
"type": "minor"
}
],
"packageName": "@visactor/vtable"
}
9 changes: 9 additions & 0 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions docs/assets/guide/en/Load_on_Demand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# VTable on-demand loading

By default, `ListTable`, `PivotTable` and `PivotChart` introduced from `@visactor/vtable` package contain all table-related components, which is a complete table component library.

In order to meet the needs of package size optimization, VTable provides two types, `ListTableSimple` and `PivotTableSimple`, which are the most simplified lists and pivot tables, respectively. They only support text display and do not contain external components such as menus and titles. If you need some functions, you can load them on demand. The usage is as follows:

```js
// ListTableSimple, PivotTableSimple are the simplest list and pivot table components, which do not include cell types and any components other than text
import {ListTableSimple, PivotTableSimple, registerTitle, registerTooltip} from '@visactor/vtable';

// Register title component
registerTitle();

// Register tooltip component
registerTooltip();
```

## Load functions on demand

### Functional components

* registerAxis: axis component
* registerEmptyTip: empty prompt component
* registerLegend: legend component
* registerMenu: menu component
* registerTitle: title component
* registerTooltip: tooltip component

### Cell type

* registerChartCell: chart cell
* registerCheckboxCell: checkbox cell
* registerImageCell: Image cell
* registerProgressBarCell: Progress bar cell
* registerRadioCell: Radio button cell
* registerSparkLineCell: Sparkline cell
* registerTextCell: Text cell
* registerVideoCell: Video cell
7 changes: 7 additions & 0 deletions docs/assets/guide/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,13 @@
}
]
},
{
"path": "Load_on_Demand",
"title": {
"zh": "按需加载",
"en": "Load on Demand"
}
},
{
"path": "search",
"title": {
Expand Down
38 changes: 38 additions & 0 deletions docs/assets/guide/zh/Load_on_Demand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# VTable 按需加载

默认从 `@visactor/vtable` 包中引入的 `ListTable``PivotTable``PivotChart` 包含所有的表格相关的组件,是一个完整的表格组件库。

为了满足包体积优化的需求,VTable提供了 `ListTableSimple``PivotTableSimple` 两个类型,分别是最简化的列表和透视表,只支持文字类型的显示,不包含菜单、标题等外部组件。如果需要部分功能,可以进行按需加载,使用方法如下:

```js
// ListTableSimple, PivotTableSimple 是最简单的列表和透视表组件,不包除了文字之外的单元格类型和任何组件
import {ListTableSimple, PivotTableSimple, registerTitle, registerTooltip} from '@visactor/vtable';

// 注册标题组件
registerTitle();

// 注册tooltip组件
registerTooltip();
```

## 按需加载功能

### 功能组件

* registerAxis: 坐标轴组件
* registerEmptyTip: 空白提示组件
* registerLegend: 图例组件
* registerMenu: 菜单组件
* registerTitle: 标题组件
* registerTooltip: tooltip组件

### 单元格类型

* registerChartCell: 图表单元格
* registerCheckboxCell: 复选框单元格
* registerImageCell: 图片单元格
* registerProgressBarCell: 进度条单元格
* registerRadioCell: 单选框单元格
* registerSparkLineCell: 迷你图单元格
* registerTextCell: 文字单元格
* registerVideoCell: 视频单元格
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import records from '../data/marketsales.json';
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
describe('listTable getCellRect test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import records from '../data/marketsales.json';
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
describe('listTable getCellRect test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
describe('listTable-cellType-function init test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
describe('listTable-cellType init test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
describe('listTable-checkbox init test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-len */
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import * as VTable from '../../src/index';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
const generatePersons = count => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import records from '../data/marketsales.json';
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
describe('listTable-menu init test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import records from '../data/marketsales.json';
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
describe('listTable-title init test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import records from '../data/marketsales.json';
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import * as VTable from '../../src/index';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable/__tests__/edit/pivotTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestPivotTable
import records from '../data/marketsales.json';
import { PivotTable } from '../../src/PivotTable';
import { PivotTable } from '../../src';
import { register } from '../../src';
import { InputEditor } from '@visactor/vtable-editors';
import { createDiv } from '../dom';
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable/__tests__/listTable-1W.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import { ListTable } from '../src/ListTable';
import { ListTable } from '../src';
import * as VTable from '../src/index';
import { createDiv } from './dom';
global.__VERSION__ = 'none';
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable/__tests__/listTable.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import records from './data/marketsales.json';
import { ListTable } from '../src/ListTable';
import { ListTable } from '../src';
import { createDiv } from './dom';
global.__VERSION__ = 'none';
describe('listTable init test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import records from '../data/marketsales.json';
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
describe('listTable init test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import records from '../data/marketsales.json';
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import { createDiv, removeDom } from '../dom';
global.__VERSION__ = 'none';
describe('listTable-autoRowHeight init test', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable/__tests__/options/listTable-frozen.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import records from '../data/marketsales.json';
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
describe('listTable-frozen init test', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable/__tests__/options/listTable-sort.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestListTable
import records from '../data/marketsales.json';
import { ListTable } from '../../src/ListTable';
import { ListTable } from '../../src';
import { createDiv } from '../dom';
global.__VERSION__ = 'none';
describe('listTable init test', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable/__tests__/pivotTable-analysis.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestPivotTable
import records from './data/marketsales.json';
import { PivotTable } from '../src/PivotTable';
import { PivotTable } from '../src';
import * as VTable from '../src/index';
import { createDiv } from './dom';
global.__VERSION__ = 'none';
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable/__tests__/pivotTable-tree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestPivotTable
import records from './data/North_American_Superstore_pivot_extension_rows.json';
import { PivotTable } from '../src/PivotTable';
import { PivotTable } from '../src';
import { createDiv } from './dom';
global.__VERSION__ = 'none';
describe('pivotTableTree init test', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable/__tests__/pivotTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @ts-nocheck
// 有问题可对照demo unitTestPivotTable
import records from './data/marketsales.json';
import { PivotTable } from '../src/PivotTable';
import { PivotTable } from '../src';
import { createDiv } from './dom';
global.__VERSION__ = 'none';
describe('pivotTable init test', () => {
Expand Down
13 changes: 11 additions & 2 deletions packages/vtable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@
"url": "https://VisActor.io/"
},
"license": "MIT",
"sideEffects": true,
"sideEffects": [
"./src/ListTable-all.js",
"./src/ListTable-simple.js",
"./src/PivotTable-all.js",
"./src/PivotTable-simple.js",
"./src/PivotChart.js",
"./src/index.js",
"./src/scenegraph/scenegraph.js"
],
"main": "cjs/index.js",
"module": "es/index.js",
"types": "es/index.d.ts",
Expand Down Expand Up @@ -56,6 +64,7 @@
"@visactor/vutils": "~0.18.9",
"@visactor/vscale": "~0.18.1",
"@visactor/vdataset": "~0.18.1",
"@visactor/vutils-extension": "~1.11.5",
"cssfontparser": "^1.2.1"
},
"devDependencies": {
Expand Down Expand Up @@ -123,4 +132,4 @@
"url": "https://github.com/VisActor/VTable.git",
"directory": "packages/vtable"
}
}
}
36 changes: 36 additions & 0 deletions packages/vtable/src/ListTable-all.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { ListTable } from './ListTable';
import {
registerAxis,
registerEmptyTip,
registerLegend,
registerMenu,
registerTitle,
registerTooltip
} from './components';
import {
registerChartCell,
registerCheckboxCell,
registerImageCell,
registerProgressBarCell,
registerRadioCell,
registerSparkLineCell,
registerTextCell,
registerVideoCell
} from './scenegraph/group-creater/cell-type';

registerAxis();
registerEmptyTip();
registerLegend();
registerMenu();
registerTitle();
registerTooltip();

registerChartCell();
registerCheckboxCell();
registerImageCell();
registerProgressBarCell();
registerRadioCell();
registerSparkLineCell();
registerTextCell();
registerVideoCell();
export class ListTableAll extends ListTable {}
5 changes: 5 additions & 0 deletions packages/vtable/src/ListTable-simple.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ListTable } from './ListTable';
import { registerTextCell } from './scenegraph/group-creater/cell-type';

registerTextCell();
export class ListTableSimple extends ListTable {}
Loading

0 comments on commit d1b4d94

Please sign in to comment.