intable 0.0.7 → 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/theme/dark.scss +46 -0
- package/dist/theme/github.scss +80 -0
- package/dist/theme/material.scss +73 -0
- package/dist/theme/shadcn.scss +66 -0
- package/dist/theme/stripe.scss +57 -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 -30
- 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 -14
- 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 -481
- 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 -63
- package/packages/intable/src/plugins/DiffPlugin.tsx +0 -107
- 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 -31
- 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/demo.tsx +0 -107
- package/src/index.scss +0 -105
- 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 -63
- /package/{packages/intable/src → dist}/theme/antd.scss +0 -0
- /package/{packages/intable/src → dist}/theme/element-plus.scss +0 -0
package/README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
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
|
+
|
|
1
6
|
# intable
|
|
2
7
|
|
|
3
8
|
## 特征
|
|
@@ -5,10 +10,12 @@
|
|
|
5
10
|
- 类似 Excel 的表格组件
|
|
6
11
|
- 单元格多选、复制、粘贴
|
|
7
12
|
- 单元格编辑、数据校验
|
|
8
|
-
-
|
|
13
|
+
- 列宽、行高可调整
|
|
14
|
+
- 列、行可拖拽
|
|
9
15
|
- 虚拟滚动
|
|
10
16
|
- 数据分组
|
|
11
17
|
- 行展开
|
|
18
|
+
- 树嵌套
|
|
12
19
|
- 插件易扩展
|
|
13
20
|
- 多框架支持(Vue、React)
|
|
14
21
|
- 多 UI库支持(Antd、ElementPlus)
|
|
@@ -27,7 +34,6 @@ pnpm add intable
|
|
|
27
34
|
**使用**
|
|
28
35
|
|
|
29
36
|
```jsx
|
|
30
|
-
import { render } from 'solid-js/web'
|
|
31
37
|
import Intable from 'intable'
|
|
32
38
|
|
|
33
39
|
const App = () => {
|
|
@@ -46,8 +52,6 @@ const App = () => {
|
|
|
46
52
|
|
|
47
53
|
return <Intable data={data} columns={columns} />
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
render(() => <App />)
|
|
51
55
|
```
|
|
52
56
|
</details>
|
|
53
57
|
|
|
@@ -57,14 +61,14 @@ render(() => <App />)
|
|
|
57
61
|
**安装**
|
|
58
62
|
|
|
59
63
|
```sh
|
|
60
|
-
pnpm add @intable/
|
|
64
|
+
pnpm add @intable/vue
|
|
61
65
|
```
|
|
62
66
|
|
|
63
67
|
**使用**
|
|
64
68
|
|
|
65
69
|
```html
|
|
66
70
|
<template>
|
|
67
|
-
<Intable data=
|
|
71
|
+
<Intable :data="data" :columns="columns" />
|
|
68
72
|
</template>
|
|
69
73
|
|
|
70
74
|
<script setup>
|
|
@@ -98,7 +102,7 @@ pnpm add @intable/react
|
|
|
98
102
|
**使用**
|
|
99
103
|
|
|
100
104
|
```jsx
|
|
101
|
-
import Intable from 'intable'
|
|
105
|
+
import Intable from '@intable/react'
|
|
102
106
|
|
|
103
107
|
const App = () => {
|
|
104
108
|
const columns = [
|
|
@@ -121,12 +125,255 @@ const App = () => {
|
|
|
121
125
|
|
|
122
126
|
## Props
|
|
123
127
|
|
|
124
|
-
| 属性名 | 描述 | 类型 | 默认值
|
|
125
|
-
| ------------ | ------------ | ------------------------------- |
|
|
126
|
-
| data | 数据 | any[] |
|
|
127
|
-
| columns | 展示列 | Column[] |
|
|
128
|
-
|
|
|
129
|
-
|
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
|
|
|
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;--default-transition-timingFunction:cubic-bezier(.4,0,.2,1);--default-transition-duration:.15s;--radius-sm:.25rem;--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% -.832707 -8.17474);--colors-blue-DEFAULT:lab(65.0361% -1.42062 -56.9803)}}*,: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 };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useMemoAsync } from "../hooks/index.js";
|
|
2
|
+
import { Tree } from "./Tree.js";
|
|
3
|
+
import { createComponent, insert, spread, template } from "solid-js/web";
|
|
4
|
+
import { createEffect, createMemo, createSignal, splitProps } from "solid-js";
|
|
5
|
+
import { delay } from "es-toolkit";
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template("<div class=doc-tree>");
|
|
7
|
+
function DocTree(d) {
|
|
8
|
+
let [f, p] = splitProps(d, ["editor"]), [m, h] = createSignal(0);
|
|
9
|
+
createEffect(() => f.editor.on("update", () => h((e) => ++e)));
|
|
10
|
+
let g = useMemoAsync(() => (m(), delay(300).then(() => f.editor.getJSON())), {}), _ = createMemo(() => function e(s, c = [], l = []) {
|
|
11
|
+
if (s.type === "heading") {
|
|
12
|
+
let e = c.length;
|
|
13
|
+
for (; e-- && !(c[e].level < s.attrs.level););
|
|
14
|
+
let u = {
|
|
15
|
+
label: s.content?.map((e) => e.text).join(""),
|
|
16
|
+
level: s.attrs.level
|
|
17
|
+
};
|
|
18
|
+
c.push(u), e > -1 ? (c[e].children ??= []).push(u) : l.push(u);
|
|
19
|
+
} else s.content?.forEach((s) => e(s, c, l));
|
|
20
|
+
return l;
|
|
21
|
+
}(g()));
|
|
22
|
+
return (() => {
|
|
23
|
+
var e = _tmpl$();
|
|
24
|
+
return spread(e, p, !1, !0), insert(e, createComponent(Tree, {
|
|
25
|
+
get data() {
|
|
26
|
+
return _();
|
|
27
|
+
},
|
|
28
|
+
class: "min-h-40 max-h-100 overflow-auto"
|
|
29
|
+
})), e;
|
|
30
|
+
})();
|
|
31
|
+
}
|
|
32
|
+
export { DocTree };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Menu(props: any): import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { unFn } from "../utils.js";
|
|
2
|
+
import { useSignle2 } from "../hooks/index.js";
|
|
3
|
+
import { createRender } from "./Render.js";
|
|
4
|
+
import { VDir } from "../hooks/useDir.js";
|
|
5
|
+
import { Popover } from "./Popover.js";
|
|
6
|
+
import loading_default from "../loading.js";
|
|
7
|
+
import { className, createComponent, effect, insert, memo, mergeProps, spread, template, use } from "solid-js/web";
|
|
8
|
+
import { children, createContext, createEffect, createMemo, createSignal, onMount, splitProps, useContext } from "solid-js";
|
|
9
|
+
import { createMutable } from "solid-js/store";
|
|
10
|
+
import { combineProps } from "@solid-primitives/props";
|
|
11
|
+
import { delay } from "es-toolkit";
|
|
12
|
+
import { pointerHover } from "@solid-primitives/pointer";
|
|
13
|
+
import { isEmpty } from "es-toolkit/compat";
|
|
14
|
+
import { autoUpdate, createFloating, offset } from "floating-ui-solid";
|
|
15
|
+
var _tmpl$ = /* @__PURE__ */ template("<div><div>"), _tmpl$2 = /* @__PURE__ */ template("<div>"), _tmpl$3 = /* @__PURE__ */ template("<div class=\"px-4 py-2 op40\">无内容");
|
|
16
|
+
function Menu(k) {
|
|
17
|
+
let P = createContext({ deep: 0 }), F = createRender({
|
|
18
|
+
is: (D) => {
|
|
19
|
+
let O = useContext(P), [A, j] = splitProps(D, [
|
|
20
|
+
"children",
|
|
21
|
+
"label",
|
|
22
|
+
"icon",
|
|
23
|
+
"isActive",
|
|
24
|
+
"cb",
|
|
25
|
+
"menu",
|
|
26
|
+
"popover"
|
|
27
|
+
]), M = createMemo(() => k.x && O.deep == 1), N, [F, L] = createSignal(), [R, z] = useSignle2(!1, { before: () => delay(100) }), B = createMemo(() => F() ? createFloating({
|
|
28
|
+
strategy: "fixed",
|
|
29
|
+
placement: M() ? "bottom-start" : "right-start",
|
|
30
|
+
...A.menu,
|
|
31
|
+
elements: {
|
|
32
|
+
reference: () => N,
|
|
33
|
+
floating: F
|
|
34
|
+
},
|
|
35
|
+
whileElementsMounted(i, E, D) {
|
|
36
|
+
return autoUpdate(i, E, D, {
|
|
37
|
+
ancestorResize: !0,
|
|
38
|
+
elementResize: !0,
|
|
39
|
+
layoutShift: !0,
|
|
40
|
+
ancestorScroll: !0
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}).floatingStyles : void 0);
|
|
44
|
+
createEffect(() => {
|
|
45
|
+
F() && Object.assign(F().style, B()?.() ?? {});
|
|
46
|
+
});
|
|
47
|
+
let V = createMutable({ loading: !1 });
|
|
48
|
+
async function H() {
|
|
49
|
+
if (V.loading) return;
|
|
50
|
+
let i = A.cb?.();
|
|
51
|
+
if (i instanceof Promise) try {
|
|
52
|
+
await i, V.loading = !0;
|
|
53
|
+
} finally {
|
|
54
|
+
V.loading = !1, k.onAction?.(A);
|
|
55
|
+
}
|
|
56
|
+
else k.onAction?.(A);
|
|
57
|
+
}
|
|
58
|
+
return onMount(() => {
|
|
59
|
+
createComponent(Popover, mergeProps({
|
|
60
|
+
strategy: "fixed",
|
|
61
|
+
reference: N,
|
|
62
|
+
portal: N
|
|
63
|
+
}, () => D.popover, { get middleware() {
|
|
64
|
+
return [offset({ mainAxis: 4 })];
|
|
65
|
+
} }));
|
|
66
|
+
}), children(() => A.children), (() => {
|
|
67
|
+
var E = _tmpl$(), D = E.firstChild;
|
|
68
|
+
use(pointerHover, E, () => z);
|
|
69
|
+
var O = N;
|
|
70
|
+
return typeof O == "function" ? use(O, E) : N = E, spread(E, mergeProps(() => combineProps({ class: `li flex aic rd-2 ${M() ? "my-1 p-1" : "mx-1 pl-1 pr-4 py-1"} ${unFn(A.isActive) && "active"}` }, j), { "on:click": H }), !1, !0), insert(D, (() => {
|
|
71
|
+
var i = memo(() => !!V.loading);
|
|
72
|
+
return () => i() ? createComponent(loading_default, {}) : A.icon;
|
|
73
|
+
})()), insert(E, () => A.label, null), insert(E, (() => {
|
|
74
|
+
var i = memo(() => !!(R() && A.children));
|
|
75
|
+
return () => i() && createComponent(I, {
|
|
76
|
+
ref: L,
|
|
77
|
+
class: "z-1",
|
|
78
|
+
get children() {
|
|
79
|
+
return A.children;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
})(), null), effect(() => className(D, `flex aic ${M() ? "" : k.density == "comfortable" ? "ml-1 mr-2.5" : "ml-.5 mr-1"} `)), E;
|
|
83
|
+
})();
|
|
84
|
+
},
|
|
85
|
+
processProps: (i) => {
|
|
86
|
+
let E = 0;
|
|
87
|
+
return Array.isArray(i.children) && i.children.forEach((i) => !i.is && typeof i == "object" && (i["data-index"] = E++)), i;
|
|
88
|
+
}
|
|
89
|
+
}), I = (i) => {
|
|
90
|
+
let E = useContext(P), D = createMutable({ deep: E.deep + 1 });
|
|
91
|
+
return createComponent(P.Provider, {
|
|
92
|
+
value: D,
|
|
93
|
+
get children() {
|
|
94
|
+
var E = _tmpl$2();
|
|
95
|
+
return use(VDir, E, () => i.usedir), spread(E, mergeProps(() => combineProps({ class: `${k.x && D.deep == 1 ? "tt-menu-x flex" : "tt-menu max-h-100"} overflow-auto` }, i), { "on:click": (i) => i.stopPropagation() }), !1, !0), insert(E, () => ((i) => isEmpty(i) ? _tmpl$3() : i)(i.children)), E;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
return createComponent(F, mergeProps(() => combineProps({}, k), {
|
|
100
|
+
is: I,
|
|
101
|
+
items: null,
|
|
102
|
+
get children() {
|
|
103
|
+
return k.items;
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
export { Menu };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
import { type createFloatingProps, type ReferenceType } from 'floating-ui-solid';
|
|
3
|
+
import type { AutoUpdateOptions } from '@floating-ui/dom';
|
|
4
|
+
export declare function Popover(attrs: FloatingProps): JSX.Element;
|
|
5
|
+
type FloatingProps = {
|
|
6
|
+
reference: ReferenceType;
|
|
7
|
+
floating?: JSX.Element | (() => JSX.Element);
|
|
8
|
+
portal?: HTMLElement;
|
|
9
|
+
trigger?: 'click' | 'hover';
|
|
10
|
+
} & createFloatingProps;
|
|
11
|
+
export declare function Floating(attrs: FloatingProps & {
|
|
12
|
+
update?: Partial<AutoUpdateOptions>;
|
|
13
|
+
}): JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useClicked, useHover, useMemoAsync } from "../hooks/index.js";
|
|
2
|
+
import { Portal, createComponent, memo, mergeProps } from "solid-js/web";
|
|
3
|
+
import { children, createEffect, createMemo, splitProps } from "solid-js";
|
|
4
|
+
import { delay } from "es-toolkit";
|
|
5
|
+
import { autoUpdate, createFloating } from "floating-ui-solid";
|
|
6
|
+
function Popover(s) {
|
|
7
|
+
let [c, u] = splitProps(s, ["reference", "floating"]), d = (s.trigger == "click" ? useClicked : useHover)(() => [m(), h()].filter((e) => e)), p = useMemoAsync(() => s.trigger == "click" ? d() : d() ? delay(100).then(() => !0) : delay(200).then(() => !1)), m = children(() => s.reference), h = children(() => p() ? s.floating : void 0);
|
|
8
|
+
return createComponent(Floating, mergeProps(u, {
|
|
9
|
+
reference: m,
|
|
10
|
+
floating: h
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
function Floating(e) {
|
|
14
|
+
let [a, o] = splitProps(e, ["reference", "floating"]), l = children(() => e.reference), f = children(() => e.floating), h = createMemo(() => f() ? createFloating({
|
|
15
|
+
whileElementsMounted(a, o, s) {
|
|
16
|
+
return autoUpdate(a, o, s, {
|
|
17
|
+
ancestorResize: !0,
|
|
18
|
+
elementResize: !0,
|
|
19
|
+
layoutShift: !0,
|
|
20
|
+
ancestorScroll: !0,
|
|
21
|
+
...e.update
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
...o,
|
|
25
|
+
elements: {
|
|
26
|
+
reference: l,
|
|
27
|
+
floating: f
|
|
28
|
+
}
|
|
29
|
+
}).floatingStyles : void 0);
|
|
30
|
+
return createEffect(() => {
|
|
31
|
+
f() && Object.assign(f().style, h()?.() ?? {});
|
|
32
|
+
}), [memo(l), memo(() => memo(() => !!(o.portal && f()))() ? createComponent(Portal, {
|
|
33
|
+
get mount() {
|
|
34
|
+
return o.portal;
|
|
35
|
+
},
|
|
36
|
+
get children() {
|
|
37
|
+
return f();
|
|
38
|
+
}
|
|
39
|
+
}) : f())];
|
|
40
|
+
}
|
|
41
|
+
export { Floating, Popover };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
/**
|
|
3
|
+
* RecycleList — a keyed list component with DOM recycling.
|
|
4
|
+
*
|
|
5
|
+
* Works like SolidJS `<For>` (keyed by reference identity) but instead of
|
|
6
|
+
* destroying DOM when items leave the list, it hides and pools those DOM
|
|
7
|
+
* nodes. When new items enter, a pooled slot is reused by swapping the
|
|
8
|
+
* reactive signals, avoiding the cost of creating & hydrating fresh DOM.
|
|
9
|
+
*
|
|
10
|
+
* Each slot gets its own `createRoot` so that its inner reactive tree
|
|
11
|
+
* (memos, effects) is NOT owned by the reconciliation memo — preventing
|
|
12
|
+
* SolidJS from disposing child computations when the outer memo re-runs.
|
|
13
|
+
*
|
|
14
|
+
* Ideal for virtual-scroll scenarios where items constantly enter/leave
|
|
15
|
+
* the viewport but the DOM structure per item is identical.
|
|
16
|
+
*
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <RecycleList each={visibleItems()}>
|
|
19
|
+
* {(item, index) => <div>{item().name} at {index()}</div>}
|
|
20
|
+
* </RecycleList>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function RecycleList<T>(props: {
|
|
24
|
+
each: T[];
|
|
25
|
+
children: (item: () => T, index: () => number) => JSX.Element;
|
|
26
|
+
}): JSX.Element;
|