intable 0.0.8 → 0.0.10
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/LICENSE +21 -21
- package/README.md +379 -132
- 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 +41 -0
- package/dist/hooks/index.js +174 -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 +116 -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 +67 -0
- package/dist/plugins/DragPlugin.d.ts +14 -0
- package/dist/plugins/DragPlugin.js +48 -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 +89 -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/{packages/intable/src → dist}/theme/antd.scss +42 -42
- package/{packages/intable/src → dist}/theme/dark.scss +46 -46
- package/{packages/intable/src → dist}/theme/element-plus.scss +38 -38
- package/{packages/intable/src → dist}/theme/github.scss +80 -80
- package/{packages/intable/src → dist}/theme/material.scss +73 -73
- package/{packages/intable/src → dist}/theme/shadcn.scss +66 -66
- package/{packages/intable/src → dist}/theme/stripe.scss +57 -57
- 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/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 huodoushigemi
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 huodoushigemi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,132 +1,379 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
{
|
|
42
|
-
{
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
|
129
|
-
|
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
|
|
|
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` 粘贴。
|
package/dist/__uno.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--un-bg-opacity:100%;--un-content:"";--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-text-opacity:100%;--un-border-opacity:100%;--un-space-y-reverse:initial;--un-space-x-reverse:initial;--un-outline-style:solid;--un-outline-opacity:100%;--un-leading:initial}}@property --un-leading{syntax:"*";inherits:false}@property --un-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --un-outline-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-bg-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-translate-x{syntax:"*";inherits:false;initial-value:0}@property --un-translate-y{syntax:"*";inherits:false;initial-value:0}@property --un-translate-z{syntax:"*";inherits:false;initial-value:0}:root,:host{--spacing:.25rem;--colors-gray-DEFAULT:#99a1af;--text-sm-fontSize:.875rem;--text-sm-lineHeight:1.25rem;--radius-sm:.25rem;--default-transition-timingFunction:cubic-bezier(.4,0,.2,1);--default-transition-duration:.15s;--colors-blue-DEFAULT:#54a2ff;--font-sans:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--default-font-family:var(--font-sans);--default-monoFont-family:var(--font-mono)}@supports (color:lab(0% 0 0)){:root,:host{--colors-gray-DEFAULT:lab(65.9269% -.832677 -8.17474);--colors-blue-DEFAULT:lab(65.0361% -1.42065 -56.9802)}}*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-featureSettings,normal);font-variation-settings:var(--default-font-variationSettings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-monoFont-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-monoFont-featureSettings,normal);font-variation-settings:var(--default-monoFont-variationSettings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden~=until-found])){display:none!important}.container{width:100%}.aic{align-items:center}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.text-3\.5{font-size:.875rem}.lh-\[1\]{--un-leading:1;line-height:1}.m9{margin:36px}.mx-1{margin-inline:4px}.mx-3\!{margin-inline:12px!important}.my-1{margin-block:4px}.ml{margin-left:16px}.ml-\.5{margin-left:2px}.ml-1{margin-left:4px}.mr--1{margin-right:-4px}.mr-1{margin-right:4px}.mr-2{margin-right:8px}.mr-2\.5{margin-right:10px}.p-1{padding:4px}.px,.px-4{padding-inline:16px}.px-2{padding-inline:8px}.py-1{padding-block:4px}.py-2{padding-block:8px}.pl-1{padding-left:4px}.pr-4{padding-right:16px}.ps{padding-inline-start:16px}.outline-0{outline-style:var(--un-outline-style);outline-width:0}.outline-2{outline-style:var(--un-outline-style);outline-width:2px}.outline-blue{outline-color:color-mix(in srgb,var(--colors-blue-DEFAULT)var(--un-outline-opacity),transparent)}.b{border-width:1px}.rd-2{border-radius:.5rem}.rd-sm{border-radius:var(--radius-sm)}.bg-\#dafaea\!{background-color:color-mix(in oklab,#dafaea var(--un-bg-opacity),transparent)!important}.bg-\#ffe8e8\!{background-color:color-mix(in oklab,#ffe8e8 var(--un-bg-opacity),transparent)!important}.bg-\#fff{background-color:color-mix(in oklab,#fff var(--un-bg-opacity),transparent)}.bg-gray\/20{background-color:color-mix(in srgb,var(--colors-gray-DEFAULT)20%,transparent)}.op-75{opacity:.75}.op40{opacity:.4}.flex{display:flex}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.gap-2{gap:8px}.grid{display:grid}.size-4\!{width:16px!important;height:16px!important}.size-full{width:100%;height:100%}.h-1\!{height:4px!important}.h-a\!{height:auto!important}.h-full{height:100%}.max-h-100{max-height:400px}.min-h-40{min-height:160px}.min-h-a\!{min-height:auto!important}.w-10px\!{width:10px!important}.after\:h-1:after{height:4px}.after\:w-1:after{width:4px}.inline{display:inline}.block{display:block}.hidden{display:none}.visible{visibility:visible}.collapse{visibility:collapse}.cursor-s-resize{cursor:s-resize}.cursor-w-resize{cursor:w-resize}.resize{resize:both}.resize-none{resize:none}.select-none{-webkit-user-select:none;user-select:none}.translate-x-1\/2{--un-translate-x:50%;translate:var(--un-translate-x)var(--un-translate-y)}.transform{transform:var(--un-rotate-x)var(--un-rotate-y)var(--un-rotate-z)var(--un-skew-x)var(--un-skew-y)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,--un-gradient-from,--un-gradient-via,--un-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter;transition-timing-function:var(--un-ease,var(--default-transition-timingFunction));transition-duration:var(--un-duration,var(--default-transition-duration))}.items-center{align-items:center}.box-border{box-sizing:border-box}.bottom-0{bottom:0}.left-0{left:0}.right-0{right:0}.top-0{top:0}.justify-end\!{justify-content:flex-end!important}.justify-center{justify-content:center}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.z-1{z-index:1}.z-9{z-index:9}.overflow-auto{overflow:auto}.table{display:table}.table-cell{display:table-cell}@supports (color:color-mix(in lab, red, red)){.outline-blue{outline-color:color-mix(in oklab,var(--colors-blue-DEFAULT)var(--un-outline-opacity),transparent)}.bg-gray\/20{background-color:color-mix(in oklab,var(--colors-gray-DEFAULT)20%,transparent)}}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { spread, template } from "solid-js/web";
|
|
2
|
+
var _tmpl$ = /* @__PURE__ */ template("<svg viewBox=\"0 0 24 24\"width=1.2em height=1.2em><path fill=none stroke=currentColor stroke-linecap=round stroke-linejoin=round stroke-width=2 d=\"m9 18l6-6l-6-6\">"), chevron_right_default = (n = {}) => (() => {
|
|
3
|
+
var r = _tmpl$();
|
|
4
|
+
return spread(r, n, !0, !0), r;
|
|
5
|
+
})();
|
|
6
|
+
export { chevron_right_default as default };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { usePointerDrag } from "../hooks/index.js";
|
|
2
|
+
import { addEventListener, createComponent, delegateEvents, effect, insert, memo, mergeProps, render, spread, style, template, use } from "solid-js/web";
|
|
3
|
+
import { createEffect, createMemo, createSignal, mergeProps as mergeProps$1, onCleanup, onMount, splitProps } from "solid-js";
|
|
4
|
+
import { clamp, sum } from "es-toolkit";
|
|
5
|
+
import { createMutationObserver } from "@solid-primitives/mutation-observer";
|
|
6
|
+
import { createElementBounds } from "@solid-primitives/bounds";
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ template("<div style=position:absolute;z-index:1>"), _tmpl$2 = /* @__PURE__ */ template("<div>"), _tmpl$3 = /* @__PURE__ */ template("<div class=col-hand contenteditable=false>"), _tmpl$4 = /* @__PURE__ */ template("<div class=dot>");
|
|
8
|
+
const Columns = (e) => {
|
|
9
|
+
let [p, h] = splitProps(mergeProps$1({ gap: 0 }, e), ["children"]), g, [v, S] = createSignal([]), C = createMemo(() => v().length), D = () => S([...g.querySelectorAll("& > [tiptap-is=\"column\"]")]);
|
|
10
|
+
onMount(() => D()), createMutationObserver(() => g, { childList: !0 }, () => {
|
|
11
|
+
D(), O.parentElement || g.insertBefore(O, g.firstChild);
|
|
12
|
+
});
|
|
13
|
+
let O = _tmpl$(), k = createElementBounds(() => O, { trackScroll: !1 });
|
|
14
|
+
return createEffect(() => {
|
|
15
|
+
g.insertBefore(O, g.firstChild), onCleanup(() => O.remove());
|
|
16
|
+
}), createEffect(() => {
|
|
17
|
+
v().forEach((e, p) => {
|
|
18
|
+
if (p == v().length - 1) return;
|
|
19
|
+
let g = render(() => createComponent(Hand, {
|
|
20
|
+
index: p,
|
|
21
|
+
get gap() {
|
|
22
|
+
return h.gap;
|
|
23
|
+
},
|
|
24
|
+
reference: e,
|
|
25
|
+
bounds2: k,
|
|
26
|
+
get onAdd() {
|
|
27
|
+
return h.onAdd;
|
|
28
|
+
}
|
|
29
|
+
}), O);
|
|
30
|
+
onCleanup(g);
|
|
31
|
+
});
|
|
32
|
+
let e = g.offsetWidth, p = (C() - 1) * h.gap, _ = (e - p) / C();
|
|
33
|
+
v().forEach((e) => e.style.width ||= `${_}px`);
|
|
34
|
+
let y = v().map((e) => e.offsetWidth), x = sum(y) + p, S = p / C();
|
|
35
|
+
v().forEach((e, p) => e.style.width = `calc(${(y[p] + S) / x * 100}% - ${S}px)`);
|
|
36
|
+
}), (() => {
|
|
37
|
+
var p = _tmpl$2(), m = g;
|
|
38
|
+
return typeof m == "function" ? use(m, p) : g = p, spread(p, mergeProps({ get style() {
|
|
39
|
+
return `display: flex; gap: ${h.gap}px;`;
|
|
40
|
+
} }, h, { get cols() {
|
|
41
|
+
return C();
|
|
42
|
+
} }), !1, !0), insert(p, () => e.children), p;
|
|
43
|
+
})();
|
|
44
|
+
};
|
|
45
|
+
var Hand = (m) => {
|
|
46
|
+
let h = createElementBounds(m.reference, { trackScroll: !1 }), y = createMemo(() => `
|
|
47
|
+
position: absolute;
|
|
48
|
+
width: ${m.gap}px;
|
|
49
|
+
height: ${h.height}px;
|
|
50
|
+
transform: translate(${h.right - m.bounds2.left}px, ${h.top - m.bounds2.top}px);
|
|
51
|
+
`), b;
|
|
52
|
+
return usePointerDrag(() => b, { start(e, p) {
|
|
53
|
+
let h = m.reference, g = h.parentElement, _ = g.offsetWidth, [v, y] = [+g.getAttribute("cols"), +g.getAttribute("gap")], [b, x] = [h, h.nextElementSibling], [S, C] = [b?.offsetWidth || 0, x?.offsetWidth || 0], w = _ * .05, T = S + C - w, E = (v - 1) * y / v;
|
|
54
|
+
p((e, { ox: p }) => {
|
|
55
|
+
b && (b.style.width = `calc(${(clamp(S + p, w, T) + E) / _ * 100}% - ${E}px)`), x && (x.style.width = `calc(${(clamp(C - p, w, T) + E) / _ * 100}% - ${E}px)`);
|
|
56
|
+
});
|
|
57
|
+
} }), (() => {
|
|
58
|
+
var e = _tmpl$3(), h = m.ref;
|
|
59
|
+
typeof h == "function" ? use(h, e) : m.ref = e;
|
|
60
|
+
var x = b;
|
|
61
|
+
return typeof x == "function" ? use(x, e) : b = e, insert(e, (() => {
|
|
62
|
+
var e = memo(() => !!m.onAdd);
|
|
63
|
+
return () => e() && (() => {
|
|
64
|
+
var e = _tmpl$4();
|
|
65
|
+
return addEventListener(e, "pointerdown", { handleEvent: (e) => e.stopPropagation() }), e.$$click = () => m.onAdd(m.index), e;
|
|
66
|
+
})();
|
|
67
|
+
})()), effect((p) => style(e, y(), p)), e;
|
|
68
|
+
})();
|
|
69
|
+
};
|
|
70
|
+
delegateEvents(["click"]);
|
|
71
|
+
export { Columns };
|