dse-edit-table 1.2.0 → 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 CHANGED
@@ -1,36 +1,138 @@
1
- # edit-tablt-ui
1
+ # DseEditTable UI
2
2
 
3
- #### Description
4
- {**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
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.
5
4
 
6
- #### Software Architecture
7
- Software architecture description
5
+ [![npm version](https://img.shields.io/npm/v/dse-edit-table.svg)](https://www.npmjs.com/package/dse-edit-table)
6
+ [![license](https://img.shields.io/npm/l/dse-edit-table.svg)](LICENSE)
8
7
 
9
- #### Installation
8
+ ## Features
10
9
 
11
- 1. xxxx
12
- 2. xxxx
13
- 3. xxxx
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
14
18
 
15
- #### Instructions
19
+ ## Installation
16
20
 
17
- 1. xxxx
18
- 2. xxxx
19
- 3. xxxx
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**:
20
22
 
21
- #### Contribution
23
+ ```bash
24
+ # pnpm
25
+ pnpm add dse-edit-table
22
26
 
23
- 1. Fork the repository
24
- 2. Create Feat_xxx branch
25
- 3. Commit your code
26
- 4. Create Pull Request
27
+ # npm
28
+ npm i dse-edit-table
29
+ ```
27
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).
28
32
 
29
- #### Gitee Feature
33
+ > xlsx export works out of the box (the export plugin and ExcelJS are bundled). See [Installation · Export](docs/guide/installation.md#可选导出插件).
30
34
 
31
- 1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
32
- 2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
33
- 3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
34
- 4. The most valuable open source project [GVP](https://gitee.com/gvp)
35
- 5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
36
- 6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
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 CHANGED
@@ -14,20 +14,23 @@
14
14
  - 🔗 **v-model 友好**:内置行/列命令不修改传入数组,而是生成新数组并派发 `update:data` / `update:columns`,`v-model:data`、`v-model:columns` 可直接使用
15
15
  - 📋 **类 Excel 操作**:区域选择、复制/剪切/粘贴、填充柄扩展(依赖内置的 `vxe-table-extend-cell-area` 插件)
16
16
  - 📐 **高度自适应**:默认按视口与容器位置自动计算表格高度,也可通过 `height` 固定
17
+ - 📦 **单包集成**:vxe 全家桶、菜单/区域插件、xlsx 导出插件与 ExcelJS 全部打进产物,除 `vue` 外无需安装任何依赖
17
18
 
18
19
  ## 安装
19
20
 
20
- 组件库把 `vxe-table`、`vxe-pc-ui` 等声明为 peerDependencies,需要在使用方项目中一并安装:
21
+ 本库采用**单包集成**模型:除 `vue`(`peerDependencies`)外的运行时依赖全部在构建时打进产物,`dependencies` 为空,使用方**只需安装一个包**:
21
22
 
22
23
  ```bash
23
24
  # pnpm
24
- pnpm add dse-edit-table vxe-table@4.11.1 vxe-pc-ui @vxe-ui/plugin-menu
25
+ pnpm add dse-edit-table
25
26
 
26
27
  # npm
27
- npm i dse-edit-table vxe-table@4.11.1 vxe-pc-ui @vxe-ui/plugin-menu
28
+ npm i dse-edit-table
28
29
  ```
29
30
 
30
- > 需要 xlsx / html 导出时,额外安装 `vxe-table-plugin-export-xlsx` 与 `xlsx`,参考 [安装 · 可选导出插件](docs/guide/installation.md#可选导出插件)。
31
+ > vxe 已打进产物,**请不要**在项目里再直接 `import 'vxe-table'`:node_modules 里那份与本库内部实例互不相通,会出现语言包、插件注册、配置互相看不到。只通过本库使用 vxe 可忽略。详见 [安装 · 引入样式](docs/guide/installation.md)。
32
+
33
+ > xlsx 导出开箱可用(导出插件与 ExcelJS 已内置),参考 [安装 · 导出能力](docs/guide/installation.md#可选导出插件)。
31
34
 
32
35
  ## 快速开始
33
36
 
@@ -41,7 +44,17 @@ import 'dse-edit-table/style.css'
41
44
  createApp(App).use(DseEditTable).mount('#app')
42
45
  ```
43
46
 
44
- `use(DseEditTable)` 会同时完成三件事:安装 `vxe-pc-ui` 与 `vxe-table`、注册菜单/区域扩展插件、设置中文语言与图标,因此无需在使用方重复 `app.use(VxeTable)`。
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
+ ```
45
58
 
46
59
  ```vue
47
60
  <template>
@@ -53,8 +66,18 @@ import { ref } from 'vue'
53
66
 
54
67
  const columns = [
55
68
  { type: 'seq', title: '序号', width: 60 },
56
- { field: 'name', title: '姓名', width: 120, editRender: { name: 'VxeInput' } },
57
- { field: 'num', title: '数量', width: 100, editRender: { name: 'VxeNumberInput' } },
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
+ },
58
81
  ]
59
82
 
60
83
  const tableData = ref([
@@ -75,7 +98,7 @@ const tableData = ref([
75
98
 
76
99
  ```bash
77
100
  pnpm install
78
- pnpm build # 产出 dist/index.js、dist/index.cjs、dist/style.css
101
+ pnpm build # 产出 dist/es/index.js(ESM)、dist/index.cjs(CJS)、dist/style.css
79
102
  pnpm docs:dev # 文档站
80
103
  pnpm test:run # 单元测试(vitest + jsdom)
81
104
  ```
@@ -92,15 +115,20 @@ packages/
92
115
  │ │ └── emit.js # 事件声明
93
116
  │ └── __tests__/ # vitest 用例(配置合并、内置命令、变更采集)
94
117
  ├── plugins/
95
- │ ├── vxe-table.js # vxe 安装、国际化、菜单插件、区域扩展插件
118
+ │ ├── vxe-table.js # vxe 安装、国际化、菜单/区域/xlsx 导出插件
96
119
  │ └── VxeTable/ # vxe-table-extend-cell-area(区域扩展,商业插件产物)
120
+ ├── utils/
121
+ │ └── merge.js # 浅合并 / 按 code 深合并工具
97
122
  └── theme/ # 预留主题样式目录
98
- utils/merge.js # 浅合并 / 按 code 深合并工具
123
+ vite.build.config.js # 双构建配置(ESM + CJS)
124
+ scripts/build.js # 构建入口,按 Vite JS API 依次跑两个构建
99
125
  docs/ # VitePress 文档站
100
126
  ```
101
127
 
102
128
  ## 版本策略
103
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`,避免入口里的插件全局注册被摇掉
104
132
  - `1.2.0`:内置行/列命令改为不可变提交(新数组 + `update:data` / `update:columns`)、不再调用 `reloadData`、`DELETE_COLUMN` 按 `field` 定位、修复 `defaultProps()` 调用崩溃与 `gridId` 被 DOM 引用覆盖、补齐 prop `type`/`default`、新增默认右键菜单与单元测试。属于**行为变更**,依赖“引用不变 / 就地修改”的业务需回归
105
133
  - `1.1.x` 适配 `vxe-table@4.11.1`;vxe-table 小版本升级后需要回归区域选择、右键菜单与编辑采集相关行为
106
134
  - 组件库自身遵循 semver:新增内置默认值或改变合并语义会发布 minor 版本