intable 0.0.8 → 0.0.9
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.md +263 -16
- package/dist/__uno.css +1 -0
- package/dist/chevron-right.js +6 -0
- package/dist/components/Columns.d.ts +3 -0
- package/dist/components/Columns.js +71 -0
- package/dist/components/DocTree.d.ts +4 -0
- package/dist/components/DocTree.js +32 -0
- package/dist/components/Menu.d.ts +1 -0
- package/dist/components/Menu.js +107 -0
- package/dist/components/Popover.d.ts +14 -0
- package/dist/components/Popover.js +41 -0
- package/dist/components/RecycleList.d.ts +26 -0
- package/dist/components/RecycleList.js +39 -0
- package/dist/components/Render.d.ts +4 -0
- package/dist/components/Render.js +20 -0
- package/dist/components/Split.d.ts +15 -0
- package/dist/components/Split.js +76 -0
- package/dist/components/Tree.d.ts +37 -0
- package/dist/components/Tree.js +82 -0
- package/dist/components/utils.d.ts +3 -0
- package/dist/components/utils.js +8 -0
- package/dist/hooks/index.d.ts +40 -0
- package/dist/hooks/index.js +157 -0
- package/dist/hooks/useDir.d.ts +11 -0
- package/dist/hooks/useDir.js +42 -0
- package/dist/hooks/useSelector.d.ts +16 -0
- package/dist/hooks/useSelector.js +69 -0
- package/dist/hooks/useSort.d.ts +18 -0
- package/dist/hooks/useSort.js +83 -0
- package/dist/hooks/useVirtualizer.d.ts +30 -0
- package/dist/hooks/useVirtualizer.js +97 -0
- package/dist/index.d.ts +147 -0
- package/dist/index.js +386 -0
- package/dist/loading.js +6 -0
- package/dist/plugins/CellChangeHighlightPlugin.d.ts +2 -0
- package/dist/plugins/CellChangeHighlightPlugin.js +4 -0
- package/dist/plugins/CellMergePlugin.d.ts +45 -0
- package/dist/plugins/CellMergePlugin.js +78 -0
- package/dist/plugins/CellSelectionPlugin.d.ts +15 -0
- package/dist/plugins/CellSelectionPlugin.js +113 -0
- package/dist/plugins/CommandPlugin.d.ts +14 -0
- package/dist/plugins/CommandPlugin.js +31 -0
- package/dist/plugins/CopyPastePlugin.d.ts +14 -0
- package/dist/plugins/CopyPastePlugin.js +47 -0
- package/dist/plugins/DiffPlugin.d.ts +29 -0
- package/dist/plugins/DiffPlugin.js +66 -0
- package/dist/plugins/DragPlugin.d.ts +14 -0
- package/dist/plugins/DragPlugin.js +47 -0
- package/dist/plugins/EditablePlugin.d.ts +51 -0
- package/dist/plugins/EditablePlugin.js +177 -0
- package/dist/plugins/ExpandPlugin.d.ts +18 -0
- package/dist/plugins/ExpandPlugin.js +46 -0
- package/dist/plugins/HeaderGroup.d.ts +11 -0
- package/dist/plugins/HeaderGroup.js +171 -0
- package/dist/plugins/HistoryPlugin.d.ts +10 -0
- package/dist/plugins/HistoryPlugin.js +27 -0
- package/dist/plugins/MenuPlugin.d.ts +19 -0
- package/dist/plugins/MenuPlugin.js +132 -0
- package/dist/plugins/RenderPlugin/components.d.ts +5 -0
- package/dist/plugins/RenderPlugin/components.js +87 -0
- package/dist/plugins/RenderPlugin/index.d.ts +30 -0
- package/dist/plugins/RenderPlugin/index.js +49 -0
- package/dist/plugins/ResizePlugin.d.ts +27 -0
- package/dist/plugins/ResizePlugin.js +82 -0
- package/dist/plugins/RowGroupPlugin.d.ts +18 -0
- package/dist/plugins/RowGroupPlugin.js +88 -0
- package/dist/plugins/RowSelectionPlugin.d.ts +20 -0
- package/dist/plugins/RowSelectionPlugin.js +42 -0
- package/dist/plugins/TreePlugin.d.ts +24 -0
- package/dist/plugins/TreePlugin.js +110 -0
- package/dist/plugins/VirtualScrollPlugin.d.ts +15 -0
- package/dist/plugins/VirtualScrollPlugin.js +123 -0
- package/dist/plugins/ZodValidatorPlugin.d.ts +38 -0
- package/dist/plugins/ZodValidatorPlugin.js +12 -0
- package/dist/plus.js +6 -0
- package/dist/rolldown_runtime.js +9 -0
- package/dist/style.css +3 -0
- package/dist/tree.d.ts +1 -0
- package/dist/tree.js +12 -0
- package/dist/types/auto-imports.d.js +0 -0
- package/dist/utils.d.ts +31 -0
- package/dist/utils.js +71 -0
- package/dist/wc.d.ts +1 -0
- package/dist/wc.js +21 -0
- package/dist/web-component.d.ts +1 -0
- package/dist/web-component.js +2 -0
- package/dist/x.js +6 -0
- package/package.json +38 -35
- package/.github/copilot-instructions.md +0 -102
- package/docs/index-BaMALNy6.css +0 -1
- package/docs/index-CDN48t9E.js +0 -3
- package/docs/index-Cc4RNkLY.css +0 -1
- package/docs/index-MRnbkYmU.js +0 -3
- package/docs/index.html +0 -15
- package/docs/vite.svg +0 -1
- package/index.html +0 -13
- package/packages/intable/README.md +0 -379
- package/packages/intable/package.json +0 -51
- package/packages/intable/src/assets/ClearFormat.svg +0 -3
- package/packages/intable/src/assets/Forms.svg +0 -4
- package/packages/intable/src/assets/MergeCell.svg +0 -4
- package/packages/intable/src/assets/SplitCell.svg +0 -4
- package/packages/intable/src/assets/gap.svg +0 -3
- package/packages/intable/src/assets/loading.svg +0 -12
- package/packages/intable/src/assets/paint.svg +0 -9
- package/packages/intable/src/assets/solid.svg +0 -1
- package/packages/intable/src/components/Columns.tsx +0 -86
- package/packages/intable/src/components/DocTree.tsx +0 -36
- package/packages/intable/src/components/Menu.tsx +0 -109
- package/packages/intable/src/components/Popover.tsx +0 -55
- package/packages/intable/src/components/RecycleList.tsx +0 -99
- package/packages/intable/src/components/Render.tsx +0 -26
- package/packages/intable/src/components/Split.tsx +0 -56
- package/packages/intable/src/components/Tree.tsx +0 -115
- package/packages/intable/src/components/utils.tsx +0 -12
- package/packages/intable/src/hooks/index.ts +0 -200
- package/packages/intable/src/hooks/useDir.ts +0 -78
- package/packages/intable/src/hooks/useSelector.ts +0 -91
- package/packages/intable/src/hooks/useSort.tsx +0 -118
- package/packages/intable/src/hooks/useVirtualizer.ts +0 -180
- package/packages/intable/src/index.tsx +0 -489
- package/packages/intable/src/plugins/CellChangeHighlightPlugin.tsx +0 -5
- package/packages/intable/src/plugins/CellMergePlugin.tsx +0 -153
- package/packages/intable/src/plugins/CellSelectionPlugin.tsx +0 -175
- package/packages/intable/src/plugins/CommandPlugin.tsx +0 -74
- package/packages/intable/src/plugins/CopyPastePlugin.tsx +0 -99
- package/packages/intable/src/plugins/DiffPlugin.tsx +0 -120
- package/packages/intable/src/plugins/DragPlugin.tsx +0 -81
- package/packages/intable/src/plugins/EditablePlugin.tsx +0 -252
- package/packages/intable/src/plugins/ExpandPlugin.tsx +0 -80
- package/packages/intable/src/plugins/HeaderGroup.tsx +0 -289
- package/packages/intable/src/plugins/HistoryPlugin.tsx +0 -49
- package/packages/intable/src/plugins/MenuPlugin.tsx +0 -195
- package/packages/intable/src/plugins/RenderPlugin/components.tsx +0 -51
- package/packages/intable/src/plugins/RenderPlugin/index.tsx +0 -81
- package/packages/intable/src/plugins/ResizePlugin.tsx +0 -122
- package/packages/intable/src/plugins/RowGroupPlugin.tsx +0 -122
- package/packages/intable/src/plugins/RowSelectionPlugin.tsx +0 -65
- package/packages/intable/src/plugins/TreePlugin.tsx +0 -212
- package/packages/intable/src/plugins/VirtualScrollPlugin.tsx +0 -190
- package/packages/intable/src/plugins/ZodValidatorPlugin.tsx +0 -61
- package/packages/intable/src/style.scss +0 -244
- package/packages/intable/src/tree.ts +0 -13
- package/packages/intable/src/types/auto-imports.d.ts +0 -13
- package/packages/intable/src/utils.ts +0 -122
- package/packages/intable/src/wc.tsx +0 -35
- package/packages/intable/src/web-component.ts +0 -1
- package/packages/react/package.json +0 -36
- package/packages/react/src/index.ts +0 -44
- package/packages/react/src/plugins/antd.ts +0 -94
- package/packages/react/src/style.scss +0 -12
- package/packages/react/src/types/auto-imports.d.ts +0 -10
- package/packages/vue/package.json +0 -34
- package/packages/vue/src/index.ts +0 -63
- package/packages/vue/src/plugins/element-plus.ts +0 -69
- package/packages/vue/src/style.scss +0 -12
- package/packages/vue/src/types/auto-imports.d.ts +0 -10
- package/pnpm-workspace.yaml +0 -2
- package/public/vite.svg +0 -1
- package/scripts/build.js +0 -184
- package/scripts/publish.js +0 -95
- package/src/assets/ClearFormat.svg +0 -3
- package/src/assets/Forms.svg +0 -4
- package/src/assets/MergeCell.svg +0 -4
- package/src/assets/SplitCell.svg +0 -4
- package/src/assets/gap.svg +0 -3
- package/src/assets/loading.svg +0 -12
- package/src/assets/paint.svg +0 -9
- package/src/assets/solid.svg +0 -1
- package/src/demo-vue.ts +0 -54
- package/src/index.scss +0 -105
- package/src/index.tsx +0 -20
- package/src/pages/demo/BasicDemo.tsx +0 -19
- package/src/pages/demo/CellMergeDemo.tsx +0 -41
- package/src/pages/demo/CellSelectionDemo.tsx +0 -24
- package/src/pages/demo/CompositeDemo.tsx +0 -60
- package/src/pages/demo/CopyPasteDemo.tsx +0 -26
- package/src/pages/demo/DiffDemo.tsx +0 -33
- package/src/pages/demo/DragDemo.tsx +0 -25
- package/src/pages/demo/EditableDemo.tsx +0 -58
- package/src/pages/demo/ExpandDemo.tsx +0 -32
- package/src/pages/demo/HeaderGroupDemo.tsx +0 -36
- package/src/pages/demo/HistoryDemo.tsx +0 -28
- package/src/pages/demo/ReactDemo.tsx +0 -59
- package/src/pages/demo/ResizeDemo.tsx +0 -24
- package/src/pages/demo/RowGroupDemo.tsx +0 -43
- package/src/pages/demo/RowSelectionDemo.tsx +0 -27
- package/src/pages/demo/TreeDemo.tsx +0 -45
- package/src/pages/demo/VirtualScrollDemo.tsx +0 -21
- package/src/pages/demo/helpers.tsx +0 -39
- package/src/pages/demo/index.tsx +0 -180
- package/src/pages/index.tsx +0 -2
- package/src/pages/website.scss +0 -37
- package/src/pages/website.tsx +0 -651
- package/src/styles/index.scss +0 -172
- package/src/types/auto-imports.d.ts +0 -13
- package/stats.html +0 -4949
- package/tsconfig.app.json +0 -34
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -70
- /package/{packages/intable/src → dist}/theme/antd.scss +0 -0
- /package/{packages/intable/src → dist}/theme/dark.scss +0 -0
- /package/{packages/intable/src → dist}/theme/element-plus.scss +0 -0
- /package/{packages/intable/src → dist}/theme/github.scss +0 -0
- /package/{packages/intable/src → dist}/theme/material.scss +0 -0
- /package/{packages/intable/src → dist}/theme/shadcn.scss +0 -0
- /package/{packages/intable/src → dist}/theme/stripe.scss +0 -0
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: intable
|
|
3
|
-
description: A high-performance, plugin-based Excel-like table component for SolidJS with virtual scroll, cell editing, validation, copy/paste, row grouping, tree data, column/row drag, merge cells, diff view, and multi-framework support (Vue, React).
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# intable
|
|
7
|
-
|
|
8
|
-
## 特征
|
|
9
|
-
|
|
10
|
-
- 类似 Excel 的表格组件
|
|
11
|
-
- 单元格多选、复制、粘贴
|
|
12
|
-
- 单元格编辑、数据校验
|
|
13
|
-
- 列宽、行高可调整
|
|
14
|
-
- 列、行可拖拽
|
|
15
|
-
- 虚拟滚动
|
|
16
|
-
- 数据分组
|
|
17
|
-
- 行展开
|
|
18
|
-
- 树嵌套
|
|
19
|
-
- 插件易扩展
|
|
20
|
-
- 多框架支持(Vue、React)
|
|
21
|
-
- 多 UI库支持(Antd、ElementPlus)
|
|
22
|
-
|
|
23
|
-
## 快速开始
|
|
24
|
-
|
|
25
|
-
<details>
|
|
26
|
-
<summary>solid-js</summary>
|
|
27
|
-
|
|
28
|
-
**安装**
|
|
29
|
-
|
|
30
|
-
```sh
|
|
31
|
-
pnpm add intable
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
**使用**
|
|
35
|
-
|
|
36
|
-
```jsx
|
|
37
|
-
import Intable from 'intable'
|
|
38
|
-
|
|
39
|
-
const App = () => {
|
|
40
|
-
const columns = [
|
|
41
|
-
{ id: 'name', name: '名称' },
|
|
42
|
-
{ id: 'date', name: '日期' },
|
|
43
|
-
{ id: 'address', name: '地址' },
|
|
44
|
-
]
|
|
45
|
-
|
|
46
|
-
const data = [
|
|
47
|
-
{ date: '2016-05-03', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
|
|
48
|
-
{ date: '2016-05-02', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
|
|
49
|
-
{ date: '2016-05-04', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
|
|
50
|
-
{ date: '2016-05-01', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
return <Intable data={data} columns={columns} />
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
</details>
|
|
57
|
-
|
|
58
|
-
<details>
|
|
59
|
-
<summary>vue</summary>
|
|
60
|
-
|
|
61
|
-
**安装**
|
|
62
|
-
|
|
63
|
-
```sh
|
|
64
|
-
pnpm add @intable/vue
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**使用**
|
|
68
|
-
|
|
69
|
-
```html
|
|
70
|
-
<template>
|
|
71
|
-
<Intable :data="data" :columns="columns" />
|
|
72
|
-
</template>
|
|
73
|
-
|
|
74
|
-
<script setup>
|
|
75
|
-
import Intable from '@intable/vue'
|
|
76
|
-
|
|
77
|
-
const columns = [
|
|
78
|
-
{ id: 'name', name: '名称' },
|
|
79
|
-
{ id: 'date', name: '日期' },
|
|
80
|
-
{ id: 'address', name: '地址' },
|
|
81
|
-
]
|
|
82
|
-
|
|
83
|
-
const data = [
|
|
84
|
-
{ date: '2016-05-03', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
|
|
85
|
-
{ date: '2016-05-02', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
|
|
86
|
-
{ date: '2016-05-04', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
|
|
87
|
-
{ date: '2016-05-01', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
|
|
88
|
-
]
|
|
89
|
-
</script>
|
|
90
|
-
```
|
|
91
|
-
</details>
|
|
92
|
-
|
|
93
|
-
<details>
|
|
94
|
-
<summary>react</summary>
|
|
95
|
-
|
|
96
|
-
**安装**
|
|
97
|
-
|
|
98
|
-
```sh
|
|
99
|
-
pnpm add @intable/react
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**使用**
|
|
103
|
-
|
|
104
|
-
```jsx
|
|
105
|
-
import Intable from '@intable/react'
|
|
106
|
-
|
|
107
|
-
const App = () => {
|
|
108
|
-
const columns = [
|
|
109
|
-
{ id: 'name', name: '名称' },
|
|
110
|
-
{ id: 'date', name: '日期' },
|
|
111
|
-
{ id: 'address', name: '地址' },
|
|
112
|
-
]
|
|
113
|
-
|
|
114
|
-
const data = [
|
|
115
|
-
{ date: '2016-05-03', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
|
|
116
|
-
{ date: '2016-05-02', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
|
|
117
|
-
{ date: '2016-05-04', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
|
|
118
|
-
{ date: '2016-05-01', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
|
|
119
|
-
]
|
|
120
|
-
|
|
121
|
-
return <Intable data={data} columns={columns} />
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
</details>
|
|
125
|
-
|
|
126
|
-
## Props
|
|
127
|
-
|
|
128
|
-
| 属性名 | 描述 | 类型 | 默认值 |
|
|
129
|
-
| ------------ | ------------ | ------------------------------- | ------- |
|
|
130
|
-
| data | 数据 | any[] | |
|
|
131
|
-
| columns | 展示列 | Column[] | |
|
|
132
|
-
| rowKey | 行唯一键字段 | string | `'id'` |
|
|
133
|
-
| index | 显示序号 | boolean | false |
|
|
134
|
-
| border | 显示纵向边框 | boolean | false |
|
|
135
|
-
| stickyHeader | 表头吸顶 | boolean | false |
|
|
136
|
-
| size | 尺寸 | `'large' \| 'default' \| 'small'` | — |
|
|
137
|
-
| plugins | 插件列表 | Plugin[] | `[]` |
|
|
138
|
-
|
|
139
|
-
## Column
|
|
140
|
-
|
|
141
|
-
| 属性名 | 描述 | 类型 |
|
|
142
|
-
| -------- | ---------------------- | ----------------------------- |
|
|
143
|
-
| id | 字段名,对应数据 key | string \| symbol |
|
|
144
|
-
| name | 表头显示名称 | string |
|
|
145
|
-
| width | 列宽(px) | number |
|
|
146
|
-
| fixed | 固定列 | `'left' \| 'right'` |
|
|
147
|
-
| render | 自定义渲染器 | `string \| Render` |
|
|
148
|
-
| enum | 枚举映射(用于渲染) | `Record<string,any> \| {label?,value}[]` |
|
|
149
|
-
| editable | 是否可编辑 | boolean |
|
|
150
|
-
| editor | 编辑器类型或自定义实现 | `string \| Editor` |
|
|
151
|
-
| resizable| 是否允许调整列宽 | boolean |
|
|
152
|
-
|
|
153
|
-
## 插件
|
|
154
|
-
|
|
155
|
-
插件通过 `plugins` 属性传入,部分插件需从对应路径手动引入。
|
|
156
|
-
|
|
157
|
-
---
|
|
158
|
-
|
|
159
|
-
### VirtualScrollPlugin — 虚拟滚动
|
|
160
|
-
|
|
161
|
-
大数据量下只渲染可见行列,显著提升性能。
|
|
162
|
-
|
|
163
|
-
```jsx
|
|
164
|
-
import { VirtualScrollPlugin } from 'intable/plugins/VirtualScrollPlugin'
|
|
165
|
-
|
|
166
|
-
<Intable
|
|
167
|
-
plugins={[VirtualScrollPlugin]}
|
|
168
|
-
virtual={{
|
|
169
|
-
y: { estimateSize: () => 40, overscan: 10 }, // 行虚拟化参数
|
|
170
|
-
x: { overscan: 5 }, // 列虚拟化参数
|
|
171
|
-
}}
|
|
172
|
-
/>
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
### EditablePlugin — 单元格编辑
|
|
178
|
-
|
|
179
|
-
在 Column 上设置 `editable: true` 开启单元格编辑,双击或输入字符进入编辑状态。
|
|
180
|
-
|
|
181
|
-
```jsx
|
|
182
|
-
const columns = [
|
|
183
|
-
{ id: 'name', name: '姓名', editable: true },
|
|
184
|
-
{ id: 'age', name: '年龄', editable: true, editor: 'number' },
|
|
185
|
-
{ id: 'type', name: '类型', editable: true, editor: 'select', enum: { 1: 'A', 2: 'B' } },
|
|
186
|
-
{ id: 'date', name: '日期', editable: true, editor: 'date' },
|
|
187
|
-
]
|
|
188
|
-
|
|
189
|
-
<Intable columns={columns} onDataChange={setData} />
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
内置编辑器类型:`text`(默认)、`number`、`select`、`date`、`time`、`datetime`、`switch`、`checkbox`、`rate`、`color`、`file`。
|
|
193
|
-
|
|
194
|
-
搭配 UI 库插件可直接使用对应组件:
|
|
195
|
-
- **Antd**:`import { AntdPlugin } from '@intable/react/plugins/antd'`
|
|
196
|
-
- **Element Plus**:`import { ElementPlusPlugin } from '@intable/vue/plugins/element-plus'`
|
|
197
|
-
|
|
198
|
-
---
|
|
199
|
-
|
|
200
|
-
### RowSelectionPlugin — 行选择
|
|
201
|
-
|
|
202
|
-
```jsx
|
|
203
|
-
<Intable
|
|
204
|
-
rowSelection={{
|
|
205
|
-
enable: true,
|
|
206
|
-
multiple: true, // 多选,默认 true
|
|
207
|
-
value: selectedRows, // 受控选中值
|
|
208
|
-
selectable: row => row.age > 18, // 可选条件
|
|
209
|
-
onChange: rows => setSelected(rows),
|
|
210
|
-
}}
|
|
211
|
-
/>
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
---
|
|
215
|
-
|
|
216
|
-
### ExpandPlugin — 行展开
|
|
217
|
-
|
|
218
|
-
点击行首箭头展开自定义内容区域。
|
|
219
|
-
|
|
220
|
-
```jsx
|
|
221
|
-
<Intable
|
|
222
|
-
expand={{
|
|
223
|
-
enable: true,
|
|
224
|
-
render: ({ data, y }) => <div>详情:{data.name}</div>,
|
|
225
|
-
}}
|
|
226
|
-
/>
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
### RowGroupPlugin — 行分组
|
|
232
|
-
|
|
233
|
-
按指定字段对行进行分级树形分组,支持展开/折叠。
|
|
234
|
-
|
|
235
|
-
```jsx
|
|
236
|
-
<Intable
|
|
237
|
-
rowGroup={{ fields: ['type', 'subType'] }}
|
|
238
|
-
/>
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
---
|
|
242
|
-
|
|
243
|
-
### TreePlugin — 树形数据
|
|
244
|
-
|
|
245
|
-
渲染嵌套 `children` 字段的树状数据,支持展开/折叠,自动缩进。
|
|
246
|
-
|
|
247
|
-
```jsx
|
|
248
|
-
const data = [
|
|
249
|
-
{ id: 1, name: '总部', children: [
|
|
250
|
-
{ id: 2, name: '研发部' },
|
|
251
|
-
{ id: 3, name: '产品部', children: [
|
|
252
|
-
{ id: 4, name: '设计组' },
|
|
253
|
-
]},
|
|
254
|
-
]},
|
|
255
|
-
]
|
|
256
|
-
|
|
257
|
-
<Intable
|
|
258
|
-
tree={{ children: 'children' }} // 子节点字段名,默认 'children'
|
|
259
|
-
data={data}
|
|
260
|
-
columns={[{ id: 'name', name: '名称' }]}
|
|
261
|
-
/>
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
---
|
|
265
|
-
|
|
266
|
-
### ResizePlugin — 调整列宽 / 行高
|
|
267
|
-
|
|
268
|
-
拖动表头右侧边框调整列宽,拖动行底部边框调整行高。
|
|
269
|
-
|
|
270
|
-
```jsx
|
|
271
|
-
<Intable
|
|
272
|
-
resizable={{
|
|
273
|
-
col: { enable: true, min: 60, max: 600 },
|
|
274
|
-
row: { enable: true, min: 28, max: 200 },
|
|
275
|
-
}}
|
|
276
|
-
onColumnsChange={cols => setColumns(cols)}
|
|
277
|
-
/>
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
也可在单列上单独控制:
|
|
281
|
-
|
|
282
|
-
```js
|
|
283
|
-
{ id: 'name', name: '姓名', resizable: false } // 禁止该列拖拽
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
---
|
|
287
|
-
|
|
288
|
-
### DragPlugin — 列 / 行拖拽排序
|
|
289
|
-
|
|
290
|
-
长按后拖拽列标题或行首单元格可重新排序。
|
|
291
|
-
|
|
292
|
-
```jsx
|
|
293
|
-
<Intable
|
|
294
|
-
colDrag={true} // 开启列拖拽
|
|
295
|
-
rowDrag={true} // 开启行拖拽
|
|
296
|
-
onColumnsChange={cols => setColumns(cols)}
|
|
297
|
-
/>
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
---
|
|
301
|
-
|
|
302
|
-
### HistoryPlugin — 撤销 / 重做
|
|
303
|
-
|
|
304
|
-
记录数据变更历史,支持 `Ctrl+Z` / `Ctrl+Y`。
|
|
305
|
-
|
|
306
|
-
```jsx
|
|
307
|
-
import { HistoryPlugin } from 'intable/plugins/HistoryPlugin'
|
|
308
|
-
|
|
309
|
-
<Intable plugins={[HistoryPlugin]} />
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
通过命令调用:
|
|
313
|
-
```js
|
|
314
|
-
store.history.undo()
|
|
315
|
-
store.history.redo()
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
---
|
|
319
|
-
|
|
320
|
-
### DiffPlugin — 数据差异对比
|
|
321
|
-
|
|
322
|
-
将当前数据与快照进行比较,高亮新增/删除/修改行,支持提交。
|
|
323
|
-
|
|
324
|
-
```jsx
|
|
325
|
-
import { DiffPlugin } from 'intable/plugins/DiffPlugin'
|
|
326
|
-
|
|
327
|
-
<Intable
|
|
328
|
-
plugins={[DiffPlugin]}
|
|
329
|
-
diff={{
|
|
330
|
-
added: true, // 高亮新增行,默认 true
|
|
331
|
-
removed: true, // 高亮删除行,默认 true
|
|
332
|
-
changed: true, // 高亮修改行,默认 true
|
|
333
|
-
onCommit: (data, { added, removed, changed }) => save(data),
|
|
334
|
-
}}
|
|
335
|
-
/>
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
`Ctrl+S` 触发提交,或通过命令:
|
|
339
|
-
```js
|
|
340
|
-
store.commands.diffCommit()
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
---
|
|
344
|
-
|
|
345
|
-
### CellMergePlugin — 单元格合并
|
|
346
|
-
|
|
347
|
-
通过 `merge` 回调或 Column 的 `mergeRow` 快捷属性合并相邻单元格。
|
|
348
|
-
|
|
349
|
-
```jsx
|
|
350
|
-
// 方式一:全局 merge 回调
|
|
351
|
-
<Intable
|
|
352
|
-
merge={(row, col, y, x) => {
|
|
353
|
-
if (col.id === 'name') {
|
|
354
|
-
let rowspan = 1
|
|
355
|
-
while (data[y + rowspan]?.name === row.name) rowspan++
|
|
356
|
-
return rowspan > 1 ? { rowspan } : null
|
|
357
|
-
}
|
|
358
|
-
}}
|
|
359
|
-
/>
|
|
360
|
-
|
|
361
|
-
// 方式二:列级 mergeRow 快捷属性(自动合并相邻等值行)
|
|
362
|
-
const columns = [
|
|
363
|
-
{ id: 'type', name: '类型', mergeRow: true },
|
|
364
|
-
{ id: 'name', name: '名称' },
|
|
365
|
-
]
|
|
366
|
-
<Intable columns={columns} />
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
---
|
|
370
|
-
|
|
371
|
-
### CellSelectionPlugin — 单元格多选
|
|
372
|
-
|
|
373
|
-
鼠标拖拽或 `Shift+点击` 选择矩形区域,箭头键移动焦点。
|
|
374
|
-
|
|
375
|
-
---
|
|
376
|
-
|
|
377
|
-
### CopyPastePlugin — 复制粘贴
|
|
378
|
-
|
|
379
|
-
`Ctrl+C` 复制选中区域为 TSV 格式,`Ctrl+V` 粘贴。
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "intable",
|
|
3
|
-
"version": "0.0.8",
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
],
|
|
9
|
-
"main": "./dist/index.js",
|
|
10
|
-
"module": "./dist/index.js",
|
|
11
|
-
"exports": {
|
|
12
|
-
".": "./dist/index.js",
|
|
13
|
-
"./theme/*": "./dist/theme/*",
|
|
14
|
-
"./*": {
|
|
15
|
-
"import": "./dist/*.js",
|
|
16
|
-
"types": "./dist/*.d.ts"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"@floating-ui/dom": "^1.7.4",
|
|
21
|
-
"@solid-primitives/bounds": "^0.1.3",
|
|
22
|
-
"@solid-primitives/deep": "^0.3.3",
|
|
23
|
-
"@solid-primitives/event-listener": "^2.4.3",
|
|
24
|
-
"@solid-primitives/history": "^0.2.2",
|
|
25
|
-
"@solid-primitives/keyboard": "^1.3.3",
|
|
26
|
-
"@solid-primitives/media": "^2.3.3",
|
|
27
|
-
"@solid-primitives/memo": "^1.4.3",
|
|
28
|
-
"@solid-primitives/mutation-observer": "^1.2.2",
|
|
29
|
-
"@solid-primitives/pointer": "^0.3.3",
|
|
30
|
-
"@solid-primitives/props": "^3.2.2",
|
|
31
|
-
"@solid-primitives/resize-observer": "^2.1.3",
|
|
32
|
-
"@solid-primitives/scroll": "^2.1.3",
|
|
33
|
-
"@solid-primitives/storage": "^4.3.3",
|
|
34
|
-
"@solid-primitives/utils": "^6.3.2",
|
|
35
|
-
"@tanstack/solid-virtual": "^3.13.12",
|
|
36
|
-
"es-toolkit": "^1.39.10",
|
|
37
|
-
"floating-ui-solid": "^1.0.63",
|
|
38
|
-
"solid-element": "^1.9.1",
|
|
39
|
-
"solid-js": "^1.9.9",
|
|
40
|
-
"tinykeys": "^3.0.0",
|
|
41
|
-
"uuid": "^13.0.0",
|
|
42
|
-
"zod": "^4.3.6"
|
|
43
|
-
},
|
|
44
|
-
"publishConfig": {
|
|
45
|
-
"access": "public",
|
|
46
|
-
"registry": "https://registry.npmjs.org/"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"diff": "^8.0.2"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
2
|
-
<path fill="currentColor" d="m14.031 1.888l9.657 9.657l-8.345 8.345l-.27.272H20v2H6.748L.253 15.667zm.322 16.164l6.507-6.507l-6.829-6.828l-6.828 6.828l6.828 6.828l.32-.323zM5.788 12.96l-2.707 2.707l4.495 4.495h4.68l.365-.37z" />
|
|
3
|
-
</svg>
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
2
|
-
<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
3
|
-
d="M12 3a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3m7-14h7a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-7M5 7H4a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h1m12-5h.01M13 12h.01" />
|
|
4
|
-
</svg>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
2
|
-
<g>
|
|
3
|
-
<rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".14" />
|
|
4
|
-
<rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".29" transform="rotate(30 12 12)" />
|
|
5
|
-
<rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".43" transform="rotate(60 12 12)" />
|
|
6
|
-
<rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".57" transform="rotate(90 12 12)" />
|
|
7
|
-
<rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".71" transform="rotate(120 12 12)" />
|
|
8
|
-
<rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".86" transform="rotate(150 12 12)" />
|
|
9
|
-
<rect width="2" height="5" x="11" y="1" fill="currentColor" transform="rotate(180 12 12)" />
|
|
10
|
-
<animateTransform attributeName="transform" calcMode="discrete" dur="0.75s" repeatCount="indefinite" type="rotate" values="0 12 12;30 12 12;60 12 12;90 12 12;120 12 12;150 12 12;180 12 12;210 12 12;240 12 12;270 12 12;300 12 12;330 12 12;360 12 12" />
|
|
11
|
-
</g>
|
|
12
|
-
</svg>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
2
|
-
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
|
|
3
|
-
color="currentColor">
|
|
4
|
-
<path
|
|
5
|
-
d="M22 12c0-5.523-4.477-10-10-10S2 6.477 2 12s4.477 10 10 10c.842 0 2 .116 2-1c0-.609-.317-1.079-.631-1.546c-.46-.683-.917-1.359-.369-2.454c.667-1.333 1.778-1.333 3.482-1.333c.851 0 1.851 0 3.018-.167c2.101-.3 2.5-1.592 2.5-3.5M7 15.002L7.009 15" />
|
|
6
|
-
<circle cx="9.5" cy="8.5" r="1.5" />
|
|
7
|
-
<circle cx="16.5" cy="9.5" r="1.5" />
|
|
8
|
-
</g>
|
|
9
|
-
</svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 166 155.3"><path d="M163 35S110-4 69 5l-3 1c-6 2-11 5-14 9l-2 3-15 26 26 5c11 7 25 10 38 7l46 9 18-30z" fill="#76b3e1"/><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="27.5" y1="3" x2="152" y2="63.5"><stop offset=".1" stop-color="#76b3e1"/><stop offset=".3" stop-color="#dcf2fd"/><stop offset="1" stop-color="#76b3e1"/></linearGradient><path d="M163 35S110-4 69 5l-3 1c-6 2-11 5-14 9l-2 3-15 26 26 5c11 7 25 10 38 7l46 9 18-30z" opacity=".3" fill="url(#a)"/><path d="M52 35l-4 1c-17 5-22 21-13 35 10 13 31 20 48 15l62-21S92 26 52 35z" fill="#518ac8"/><linearGradient id="b" gradientUnits="userSpaceOnUse" x1="95.8" y1="32.6" x2="74" y2="105.2"><stop offset="0" stop-color="#76b3e1"/><stop offset=".5" stop-color="#4377bb"/><stop offset="1" stop-color="#1f3b77"/></linearGradient><path d="M52 35l-4 1c-17 5-22 21-13 35 10 13 31 20 48 15l62-21S92 26 52 35z" opacity=".3" fill="url(#b)"/><linearGradient id="c" gradientUnits="userSpaceOnUse" x1="18.4" y1="64.2" x2="144.3" y2="149.8"><stop offset="0" stop-color="#315aa9"/><stop offset=".5" stop-color="#518ac8"/><stop offset="1" stop-color="#315aa9"/></linearGradient><path d="M134 80a45 45 0 00-48-15L24 85 4 120l112 19 20-36c4-7 3-15-2-23z" fill="url(#c)"/><linearGradient id="d" gradientUnits="userSpaceOnUse" x1="75.2" y1="74.5" x2="24.4" y2="260.8"><stop offset="0" stop-color="#4377bb"/><stop offset=".5" stop-color="#1a336b"/><stop offset="1" stop-color="#1a336b"/></linearGradient><path d="M114 115a45 45 0 00-48-15L4 120s53 40 94 30l3-1c17-5 23-21 13-34z" fill="url(#d)"/></svg>
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { createEffect, createMemo, createSignal, mergeProps, onCleanup, onMount, splitProps } from 'solid-js'
|
|
2
|
-
import { render } from 'solid-js/web'
|
|
3
|
-
import { createMutationObserver } from '@solid-primitives/mutation-observer'
|
|
4
|
-
import { createElementBounds } from '@solid-primitives/bounds'
|
|
5
|
-
import { clamp, sum } from 'es-toolkit'
|
|
6
|
-
import { usePointerDrag } from '../hooks'
|
|
7
|
-
|
|
8
|
-
export const Columns = (attrs: Partial<{ gap: number }>) => {
|
|
9
|
-
const [_, props] = splitProps(mergeProps({ gap: 0 }, attrs), ['children'])
|
|
10
|
-
|
|
11
|
-
let ref!: HTMLElement
|
|
12
|
-
|
|
13
|
-
const [children, setChildren] = createSignal<HTMLElement[]>([])
|
|
14
|
-
const cols = createMemo(() => children().length)
|
|
15
|
-
|
|
16
|
-
const update = () => setChildren([...ref!.querySelectorAll('& > [tiptap-is="column"]')])
|
|
17
|
-
onMount(() => update())
|
|
18
|
-
createMutationObserver(() => ref, { childList: true }, () => {
|
|
19
|
-
update()
|
|
20
|
-
container.parentElement || ref.insertBefore(container, ref.firstChild)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const container = <div style='position: absolute; z-index: 1' /> as HTMLElement
|
|
24
|
-
const bounds2 = createElementBounds(() => container, { trackScroll: false })
|
|
25
|
-
createEffect(() => {
|
|
26
|
-
ref.insertBefore(container, ref.firstChild)
|
|
27
|
-
onCleanup(() => container.remove())
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
createEffect(() => {
|
|
31
|
-
children().forEach((el, i) => {
|
|
32
|
-
if (i == children().length - 1) return
|
|
33
|
-
const dispose = render(() => <Hand index={i} gap={props.gap} reference={el} bounds2={bounds2} onAdd={props.onAdd} />, container)
|
|
34
|
-
onCleanup(dispose)
|
|
35
|
-
})
|
|
36
|
-
const cw = ref.offsetWidth
|
|
37
|
-
const tgap = (cols() - 1) * props.gap
|
|
38
|
-
const meanw = (cw - tgap) / cols()
|
|
39
|
-
children().forEach(el => el.style.width ||= `${meanw}px`)
|
|
40
|
-
const ws = children().map(el => el.offsetWidth)
|
|
41
|
-
const sumw = sum(ws) + tgap
|
|
42
|
-
const sgap = tgap / cols()
|
|
43
|
-
children().forEach((el, i) => el.style.width = `calc(${(ws[i] + sgap) / sumw * 100}% - ${sgap}px)`)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<div ref={ref} style={`display: flex; gap: ${props.gap}px;`} {...props} cols={cols()}>
|
|
48
|
-
{attrs.children}
|
|
49
|
-
</div>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const Hand = (props) => {
|
|
54
|
-
const bounds = createElementBounds(props.reference, { trackScroll: false })
|
|
55
|
-
|
|
56
|
-
const style = createMemo(() => (`
|
|
57
|
-
position: absolute;
|
|
58
|
-
width: ${props.gap}px;
|
|
59
|
-
height: ${bounds.height}px;
|
|
60
|
-
transform: translate(${bounds.right - props.bounds2.left}px, ${bounds.top - props.bounds2.top}px);
|
|
61
|
-
`))
|
|
62
|
-
|
|
63
|
-
let el: HTMLElement
|
|
64
|
-
usePointerDrag(() => el, {
|
|
65
|
-
start(e, move) {
|
|
66
|
-
const col = props.reference!
|
|
67
|
-
const container = col.parentElement!, cw = container.offsetWidth
|
|
68
|
-
const [cols, gap] = [+container.getAttribute('cols')!, +container.getAttribute('gap')!]
|
|
69
|
-
const [left, right] = [col, col.nextElementSibling as HTMLElement]
|
|
70
|
-
const [lw, rw] = [left?.offsetWidth || 0, right?.offsetWidth || 0]
|
|
71
|
-
const minw = cw * .05, maxw = lw + rw - minw
|
|
72
|
-
const sgap = (cols - 1) * gap / cols
|
|
73
|
-
|
|
74
|
-
move((e, { ox }) => {
|
|
75
|
-
left && (left.style.width = `calc(${(clamp(lw + ox, minw, maxw) + sgap) / cw * 100}% - ${sgap}px)`)
|
|
76
|
-
right && (right.style.width = `calc(${(clamp(rw - ox, minw, maxw) + sgap) / cw * 100}% - ${sgap}px)`)
|
|
77
|
-
})
|
|
78
|
-
},
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<div ref={el} ref={props.ref} class='col-hand' style={style()} contenteditable='false'>
|
|
83
|
-
{props.onAdd && <div class='dot' onClick={() => props.onAdd(props.index)} on:pointerdown={{ handleEvent: e => e.stopPropagation() }} />}
|
|
84
|
-
</div>
|
|
85
|
-
)
|
|
86
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Editor, NodeType } from '@tiptap/core'
|
|
2
|
-
import { useMemoAsync } from '../hooks'
|
|
3
|
-
import { createEffect, createMemo, createSignal, splitProps } from 'solid-js'
|
|
4
|
-
import { delay } from 'es-toolkit'
|
|
5
|
-
import { Tree } from './Tree'
|
|
6
|
-
|
|
7
|
-
export function DocTree(_: { editor: Editor }) {
|
|
8
|
-
const [props, attrs] = splitProps(_, ['editor'])
|
|
9
|
-
|
|
10
|
-
const [count, setCount] = createSignal(0)
|
|
11
|
-
createEffect(() => props.editor.on('update', () => setCount(v => ++v)))
|
|
12
|
-
|
|
13
|
-
const json = useMemoAsync(() => (count(), delay(300).then(() => props.editor.getJSON())), {})
|
|
14
|
-
|
|
15
|
-
const headings = createMemo(() => {
|
|
16
|
-
return (function walker (node: NodeType, queue = [], queue2 = []) {
|
|
17
|
-
if (node.type === 'heading') {
|
|
18
|
-
let i = queue.length
|
|
19
|
-
while (i--) if (queue[i].level < node.attrs.level) break
|
|
20
|
-
const item = { label: node.content?.map(e => e.text).join(''), level: node.attrs.level }
|
|
21
|
-
queue.push(item)
|
|
22
|
-
if (i > -1) (queue[i].children ??= []).push(item)
|
|
23
|
-
else queue2.push(item)
|
|
24
|
-
} else {
|
|
25
|
-
node.content?.forEach(e => walker(e, queue, queue2))
|
|
26
|
-
}
|
|
27
|
-
return queue2
|
|
28
|
-
})(json())
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div class="doc-tree" {...attrs}>
|
|
33
|
-
<Tree data={headings()} class='min-h-40 max-h-100 overflow-auto' />
|
|
34
|
-
</div>
|
|
35
|
-
)
|
|
36
|
-
}
|