dse-edit-table 1.1.6 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +138 -0
- package/README.md +138 -0
- package/dist/es/index.js +72663 -0
- package/dist/es/style.css +1 -0
- package/dist/index.cjs +68 -9
- package/package.json +19 -20
- package/dist/index.cjs.map +0 -1
- package/dist/index.js +0 -9533
- package/dist/index.js.map +0 -1
package/README.en.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# DseEditTable UI
|
|
2
|
+
|
|
3
|
+
A Vue 3 editable-table component library built on top of [vxe-table](https://github.com/x-extends/vxe-table) 4.x. It consolidates the repetitive table configuration used across projects (editing, area selection, copy & paste, context menu, virtual scrolling, auto height) into a set of built-in defaults, so it works out of the box.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/dse-edit-table)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- 🚀 **Built-in defaults**: 12 groups of configuration (editing / keyboard / clipboard / area selection / virtual scrolling) work with zero setup; any same-named option you pass is merged with the defaults
|
|
11
|
+
- 📦 **Full vxe-grid pass-through**: undeclared attributes fall through to the inner `vxe-grid` via `$attrs`, so `stripe`, `loading`, `pagerConfig`, etc. keep working
|
|
12
|
+
- ✏️ **Change tracking**: `getUpdateCellData()` returns incremental data containing only the modified fields, ready for submission
|
|
13
|
+
- 🖱️ **Context menu & built-in commands**: since 1.2.0 it ships a default menu (header: add column / delete column / edit column; body: clear rows / add 1 & 10 rows / copy / paste / cut / delete row). Recognized `code`s are executed by the component; the rest are emitted via `@menu-click`
|
|
14
|
+
- 🔗 **v-model friendly**: built-in row/column commands never mutate the input arrays — they produce new arrays and emit `update:data` / `update:columns`, so `v-model:data` and `v-model:columns` work directly
|
|
15
|
+
- 📋 **Excel-like operations**: area selection, copy/cut/paste, fill-handle extension (powered by the bundled `vxe-table-extend-cell-area` plugin)
|
|
16
|
+
- 📐 **Auto height**: table height is computed from the viewport and container position by default, and can be fixed via `height`
|
|
17
|
+
- 📦 **Bundled as one package**: vxe, the menu / area-extension plugins, the xlsx export plugin and ExcelJS are all baked into the build — `vue` is the only dependency you have to provide
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
This library follows a **single-package** model: every runtime dependency except `vue` (a `peerDependency`) is bundled at build time, `dependencies` is empty, so **you only need one package**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# pnpm
|
|
25
|
+
pnpm add dse-edit-table
|
|
26
|
+
|
|
27
|
+
# npm
|
|
28
|
+
npm i dse-edit-table
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
> vxe is already inside the bundle, so **do not `import 'vxe-table'` directly** in your own project: that copy in `node_modules` is a separate instance from the one bundled here, so locales, plugin registrations and `setConfig` calls won't be visible to each other. Ignore this if you only touch vxe through this library. See [Installation · Stylesheet](docs/guide/installation.md).
|
|
32
|
+
|
|
33
|
+
> xlsx export works out of the box (the export plugin and ExcelJS are bundled). See [Installation · Export](docs/guide/installation.md#可选导出插件).
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
// main.js
|
|
39
|
+
import { createApp } from 'vue'
|
|
40
|
+
import App from './App.vue'
|
|
41
|
+
import DseEditTable from 'dse-edit-table'
|
|
42
|
+
import 'dse-edit-table/style.css'
|
|
43
|
+
|
|
44
|
+
createApp(App).use(DseEditTable).mount('#app')
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`use(DseEditTable)` does four things at once: installs `vxe-pc-ui` and `vxe-table`, registers the menu / area-extension plugins, registers the xlsx export plugin (ExcelJS included), and sets up the `zh-CN` locale and icons — so you do **not** need to call `app.use(VxeTable)` again in your app.
|
|
48
|
+
|
|
49
|
+
To grab the component itself, use the named export from the package entry (third-party dependencies are bundled, so the size is dominated by vxe + ExcelJS):
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import { DseEditTable, setupVxeTable } from 'dse-edit-table'
|
|
53
|
+
import 'dse-edit-table/style.css'
|
|
54
|
+
|
|
55
|
+
// without app.use(DseEditTable), the menu / area / xlsx plugins and locale must be installed manually
|
|
56
|
+
setupVxeTable(app)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```vue
|
|
60
|
+
<template>
|
|
61
|
+
<DseEditTable v-model:data="tableData" v-model:columns="columns" />
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<script setup>
|
|
65
|
+
import { ref } from 'vue'
|
|
66
|
+
|
|
67
|
+
const columns = [
|
|
68
|
+
{ type: 'seq', title: 'Seq', width: 60 },
|
|
69
|
+
{
|
|
70
|
+
field: 'name',
|
|
71
|
+
title: 'Name',
|
|
72
|
+
width: 120,
|
|
73
|
+
editRender: { name: 'VxeInput' },
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
field: 'num',
|
|
77
|
+
title: 'Qty',
|
|
78
|
+
width: 100,
|
|
79
|
+
editRender: { name: 'VxeNumberInput' },
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
const tableData = ref([
|
|
84
|
+
{ name: 'Alice', num: 1 },
|
|
85
|
+
{ name: 'Bob', num: 2 },
|
|
86
|
+
])
|
|
87
|
+
</script>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Documentation
|
|
91
|
+
|
|
92
|
+
- Guide: [Intro](docs/guide/getting-started.md) · [Installation](docs/guide/installation.md) · [Usage](docs/guide/usage.md) · [FAQ & Known Issues](docs/guide/faq.md)
|
|
93
|
+
- Components: [Basic](docs/components/basic.md) · [Columns & Slots](docs/components/columns.md) · [Editable](docs/components/edit.md) · [Copy & Paste](docs/components/copy-paste.md) · [Context Menu](docs/components/context-menu.md) · [API](docs/components/api.md)
|
|
94
|
+
|
|
95
|
+
Online docs: `pnpm docs:dev` (local preview), `pnpm docs:build` (build).
|
|
96
|
+
|
|
97
|
+
## Local Development
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pnpm install
|
|
101
|
+
pnpm build # outputs dist/es/index.js (ESM), dist/index.cjs (CJS), dist/style.css
|
|
102
|
+
pnpm docs:dev # docs site
|
|
103
|
+
pnpm test:run # unit tests (vitest + jsdom)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Directory Structure
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
packages/
|
|
110
|
+
├── index.js # library entry, install(app)
|
|
111
|
+
├── components/
|
|
112
|
+
│ ├── DseEditTable/
|
|
113
|
+
│ │ ├── index.vue # component implementation (render function)
|
|
114
|
+
│ │ ├── props.js # defaultProps (prop declarations) + defaultConfigs (built-in defaults)
|
|
115
|
+
│ │ └── emit.js # event declarations
|
|
116
|
+
│ └── __tests__/ # vitest cases (config merge, built-in commands, change tracking)
|
|
117
|
+
├── plugins/
|
|
118
|
+
│ ├── vxe-table.js # vxe installation, i18n, menu / area-extension / xlsx export plugins
|
|
119
|
+
│ └── VxeTable/ # vxe-table-extend-cell-area (area extension, commercial plugin build)
|
|
120
|
+
├── utils/
|
|
121
|
+
│ └── merge.js # shallow merge / deep merge by code utilities
|
|
122
|
+
└── theme/ # reserved theme styles directory
|
|
123
|
+
vite.build.config.js # dual build config (ESM + CJS)
|
|
124
|
+
scripts/build.js # build entry, runs both builds through the Vite JS API
|
|
125
|
+
docs/ # VitePress documentation site
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Versioning
|
|
129
|
+
|
|
130
|
+
- Build layout: dual build. ESM output is `dist/es/index.js`, CJS is a single `dist/index.cjs`. **Only `vue` is external**; every other runtime dependency (vxe-pc-ui / vxe-table / xe-utils / @vxe-ui/plugin-menu / @vueuse/core / vxe-table-plugin-export-xlsx / exceljs) is bundled in (exceljs resolves to its own browser build), and dependency CSS is merged into `dist/style.css`. The price is size: the entry bundle is about 3.0 MB (gzip ~719 kB).
|
|
131
|
+
- `sideEffects` is declared as `true`: the bundle is a single entry whose module-level plugin registrations must survive, so consumers cannot tree-shake it away.
|
|
132
|
+
- `1.2.0`: built-in row/column commands switched to immutable commits (new array + `update:data` / `update:columns`), no longer calls `reloadData`, `DELETE_COLUMN` locates by `field`, fixed the `defaultProps()` invocation crash and `gridId` being overwritten by a DOM reference, added prop `type`/`default`, default context menu and unit tests. This is a **behavior change** — code relying on "reference stays / in-place mutation" needs regression.
|
|
133
|
+
- `1.1.x` targets `vxe-table@4.11.1`; after a vxe-table minor upgrade, re-verify area selection, context menu and editing collection.
|
|
134
|
+
- The library follows semver: adding built-in defaults or changing merge semantics bumps a minor version.
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
[MIT](LICENSE)
|
package/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# DseEditTable UI
|
|
2
|
+
|
|
3
|
+
基于 [vxe-table](https://github.com/x-extends/vxe-table) 4.x 二次封装的 Vue 3 可编辑表格组件库,把项目中重复的表格配置(编辑、区域选择、复制粘贴、右键菜单、虚拟滚动、高度自适应)收敛成一份内置默认值,开箱即用。
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/dse-edit-table)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## 特性
|
|
9
|
+
|
|
10
|
+
- 🚀 **内置默认配置**:编辑 / 键盘 / 剪贴板 / 区域选择 / 虚拟滚动等 12 组配置零配置可用,传入的同名配置会与默认值合并
|
|
11
|
+
- 📦 **完整透传 vxe-grid**:未声明的属性通过 `$attrs` 直接落到内部 `vxe-grid`,`stripe`、`loading`、`pagerConfig` 等照常用
|
|
12
|
+
- ✏️ **变更采集**:`getUpdateCellData()` 返回"仅包含被改动字段"的增量数据,便于提交
|
|
13
|
+
- 🖱️ **右键菜单与内置命令**:1.2.0 起自带默认菜单(表头:添加列 / 删除列 / 编辑列;表体:清空行 / 新增 1、10 行 / 复制 / 粘贴 / 剪切 / 删除行),命中的 `code` 由组件直接执行,其余 `code` 走 `@menu-click`
|
|
14
|
+
- 🔗 **v-model 友好**:内置行/列命令不修改传入数组,而是生成新数组并派发 `update:data` / `update:columns`,`v-model:data`、`v-model:columns` 可直接使用
|
|
15
|
+
- 📋 **类 Excel 操作**:区域选择、复制/剪切/粘贴、填充柄扩展(依赖内置的 `vxe-table-extend-cell-area` 插件)
|
|
16
|
+
- 📐 **高度自适应**:默认按视口与容器位置自动计算表格高度,也可通过 `height` 固定
|
|
17
|
+
- 📦 **单包集成**:vxe 全家桶、菜单/区域插件、xlsx 导出插件与 ExcelJS 全部打进产物,除 `vue` 外无需安装任何依赖
|
|
18
|
+
|
|
19
|
+
## 安装
|
|
20
|
+
|
|
21
|
+
本库采用**单包集成**模型:除 `vue`(`peerDependencies`)外的运行时依赖全部在构建时打进产物,`dependencies` 为空,使用方**只需安装一个包**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# pnpm
|
|
25
|
+
pnpm add dse-edit-table
|
|
26
|
+
|
|
27
|
+
# npm
|
|
28
|
+
npm i dse-edit-table
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
> vxe 已打进产物,**请不要**在项目里再直接 `import 'vxe-table'`:node_modules 里那份与本库内部实例互不相通,会出现语言包、插件注册、配置互相看不到。只通过本库使用 vxe 可忽略。详见 [安装 · 引入样式](docs/guide/installation.md)。
|
|
32
|
+
|
|
33
|
+
> xlsx 导出开箱可用(导出插件与 ExcelJS 已内置),参考 [安装 · 导出能力](docs/guide/installation.md#可选导出插件)。
|
|
34
|
+
|
|
35
|
+
## 快速开始
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
// main.js
|
|
39
|
+
import { createApp } from 'vue'
|
|
40
|
+
import App from './App.vue'
|
|
41
|
+
import DseEditTable from 'dse-edit-table'
|
|
42
|
+
import 'dse-edit-table/style.css'
|
|
43
|
+
|
|
44
|
+
createApp(App).use(DseEditTable).mount('#app')
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`use(DseEditTable)` 会同时完成四件事:安装 `vxe-pc-ui` 与 `vxe-table`、注册菜单/区域扩展插件、注册 xlsx 导出插件(已带入 ExcelJS)、设置中文语言与图标,因此无需在使用方重复 `app.use(VxeTable)`。
|
|
48
|
+
|
|
49
|
+
只想拿到组件本身时,从入口具名导入即可(第三方依赖已打进产物,体积由 vxe + ExcelJS 决定):
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import { DseEditTable, setupVxeTable } from 'dse-edit-table'
|
|
53
|
+
import 'dse-edit-table/style.css'
|
|
54
|
+
|
|
55
|
+
// 不走 app.use(DseEditTable) 时,菜单/区域/xlsx 插件与语言配置需要手动装
|
|
56
|
+
setupVxeTable(app)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```vue
|
|
60
|
+
<template>
|
|
61
|
+
<DseEditTable v-model:data="tableData" v-model:columns="columns" />
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<script setup>
|
|
65
|
+
import { ref } from 'vue'
|
|
66
|
+
|
|
67
|
+
const columns = [
|
|
68
|
+
{ type: 'seq', title: '序号', width: 60 },
|
|
69
|
+
{
|
|
70
|
+
field: 'name',
|
|
71
|
+
title: '姓名',
|
|
72
|
+
width: 120,
|
|
73
|
+
editRender: { name: 'VxeInput' },
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
field: 'num',
|
|
77
|
+
title: '数量',
|
|
78
|
+
width: 100,
|
|
79
|
+
editRender: { name: 'VxeNumberInput' },
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
const tableData = ref([
|
|
84
|
+
{ name: '张三', num: 1 },
|
|
85
|
+
{ name: '李四', num: 2 },
|
|
86
|
+
])
|
|
87
|
+
</script>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 文档
|
|
91
|
+
|
|
92
|
+
- 指南:[介绍](docs/guide/getting-started.md) · [安装](docs/guide/installation.md) · [快速上手](docs/guide/usage.md) · [FAQ 与已知问题](docs/guide/faq.md)
|
|
93
|
+
- 组件:[基础表格](docs/components/basic.md) · [列与插槽](docs/components/columns.md) · [可编辑表格](docs/components/edit.md) · [复制粘贴与区域操作](docs/components/copy-paste.md) · [右键菜单](docs/components/context-menu.md) · [API](docs/components/api.md)
|
|
94
|
+
|
|
95
|
+
在线文档:`pnpm docs:dev`(本地预览),`pnpm docs:build`(构建)。
|
|
96
|
+
|
|
97
|
+
## 本地开发
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pnpm install
|
|
101
|
+
pnpm build # 产出 dist/es/index.js(ESM)、dist/index.cjs(CJS)、dist/style.css
|
|
102
|
+
pnpm docs:dev # 文档站
|
|
103
|
+
pnpm test:run # 单元测试(vitest + jsdom)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 目录结构
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
packages/
|
|
110
|
+
├── index.js # 库入口,install(app)
|
|
111
|
+
├── components/
|
|
112
|
+
│ ├── DseEditTable/
|
|
113
|
+
│ │ ├── index.vue # 组件实现(渲染函数)
|
|
114
|
+
│ │ ├── props.js # defaultProps(prop 声明)+ defaultConfigs(内置默认值)
|
|
115
|
+
│ │ └── emit.js # 事件声明
|
|
116
|
+
│ └── __tests__/ # vitest 用例(配置合并、内置命令、变更采集)
|
|
117
|
+
├── plugins/
|
|
118
|
+
│ ├── vxe-table.js # vxe 安装、国际化、菜单/区域/xlsx 导出插件
|
|
119
|
+
│ └── VxeTable/ # vxe-table-extend-cell-area(区域扩展,商业插件产物)
|
|
120
|
+
├── utils/
|
|
121
|
+
│ └── merge.js # 浅合并 / 按 code 深合并工具
|
|
122
|
+
└── theme/ # 预留主题样式目录
|
|
123
|
+
vite.build.config.js # 双构建配置(ESM + CJS)
|
|
124
|
+
scripts/build.js # 构建入口,按 Vite JS API 依次跑两个构建
|
|
125
|
+
docs/ # VitePress 文档站
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 版本策略
|
|
129
|
+
|
|
130
|
+
- 构建层:双构建。ESM 产物输出到 `dist/es/`,CJS 为单文件 `dist/index.cjs`;**只有 `vue` 是 external**,其余运行时依赖(vxe-pc-ui / vxe-table / xe-utils / @vxe-ui/plugin-menu / @vueuse/core / vxe-table-plugin-export-xlsx / exceljs)全部打进产物(exceljs 用的是它自带的浏览器包),依赖 CSS 统一打进 `dist/style.css`。代价是体积:入口产物约 3.0 MB(gzip 约 719 kB)
|
|
131
|
+
- 产物仍为单入口,所以使用方 tree-shaking 只能摇掉本库自己的组件代码,`vxe-table/dist/index.js` 之类的深路径引用不在对外承诺范围内;`sideEffects` 因此直接声明为 `true`,避免入口里的插件全局注册被摇掉
|
|
132
|
+
- `1.2.0`:内置行/列命令改为不可变提交(新数组 + `update:data` / `update:columns`)、不再调用 `reloadData`、`DELETE_COLUMN` 按 `field` 定位、修复 `defaultProps()` 调用崩溃与 `gridId` 被 DOM 引用覆盖、补齐 prop `type`/`default`、新增默认右键菜单与单元测试。属于**行为变更**,依赖“引用不变 / 就地修改”的业务需回归
|
|
133
|
+
- `1.1.x` 适配 `vxe-table@4.11.1`;vxe-table 小版本升级后需要回归区域选择、右键菜单与编辑采集相关行为
|
|
134
|
+
- 组件库自身遵循 semver:新增内置默认值或改变合并语义会发布 minor 版本
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
[MIT](LICENSE)
|