rayyy-vue-table-components 1.0.40 → 1.2.0
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 +167 -39
- package/dist/index.es.js +2835 -2838
- package/dist/index.umd.js +6 -6
- package/dist/src/components/index.d.ts +3 -0
- package/dist/src/components/transfer/TransferDialog.vue.d.ts +26 -1
- package/dist/src/index.d.ts +1 -2
- package/package.json +1 -1
- package/src/components/index.ts +3 -0
- package/src/components/transfer/TransferDialog.vue +30 -21
package/README.md
CHANGED
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
- 🎯 完整的 TypeScript 類型支持
|
|
10
10
|
- 📱 響應式設計
|
|
11
11
|
- 🔧 高度可配置
|
|
12
|
-
- 🎛️ 可拖拽的列配置對話框
|
|
13
|
-
- 📋 支持表格列的顯示/隱藏和排序
|
|
14
12
|
|
|
15
13
|
## 安裝
|
|
16
14
|
|
|
@@ -22,18 +20,6 @@ yarn add rayyy-vue-table-components
|
|
|
22
20
|
pnpm add rayyy-vue-table-components
|
|
23
21
|
```
|
|
24
22
|
|
|
25
|
-
### 依賴說明
|
|
26
|
-
|
|
27
|
-
如果您需要使用 `TransferDialog` 組件,還需要安裝 `vuedraggable` 依賴:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
npm install vuedraggable
|
|
31
|
-
# 或
|
|
32
|
-
yarn add vuedraggable
|
|
33
|
-
# 或
|
|
34
|
-
pnpm add vuedraggable
|
|
35
|
-
```
|
|
36
|
-
|
|
37
23
|
## 使用方法
|
|
38
24
|
|
|
39
25
|
### 全局註冊
|
|
@@ -66,21 +52,43 @@ app.use(VueTableComponents)
|
|
|
66
52
|
<p>您確定要執行此操作嗎?</p>
|
|
67
53
|
</BaseDialog>
|
|
68
54
|
|
|
55
|
+
<!-- TransferDialog 示例 -->
|
|
69
56
|
<TransferDialog
|
|
70
57
|
v-model="showTransferDialog"
|
|
71
|
-
:columns-value="
|
|
58
|
+
:columns-value="tableColumns"
|
|
72
59
|
transfer-title="配置表格列"
|
|
73
|
-
@update:submit="
|
|
74
|
-
|
|
60
|
+
@update:submit="handleColumnSubmit"
|
|
61
|
+
>
|
|
62
|
+
<template #list-container="{ columns, clickItemProp, handleItemEvents, handleMousedown }">
|
|
63
|
+
<draggable :list="columns" item-key="prop" delay="200">
|
|
64
|
+
<template #item="{ element, index }">
|
|
65
|
+
<transfer-item
|
|
66
|
+
:columns-value="element"
|
|
67
|
+
:columns-index="index"
|
|
68
|
+
:columns-len="columns.length"
|
|
69
|
+
:class="{
|
|
70
|
+
'transfer-active-bg': element.checkActive,
|
|
71
|
+
'transfer-active-border': clickItemProp === element.prop,
|
|
72
|
+
}"
|
|
73
|
+
@mousedown="handleMousedown(element.prop || '')"
|
|
74
|
+
@update:toTop="handleItemEvents.toTop(index)"
|
|
75
|
+
@update:toBottom="handleItemEvents.toBottom(index)"
|
|
76
|
+
@update:toPre="handleItemEvents.toPre(index)"
|
|
77
|
+
@update:toNext="handleItemEvents.toNext(index)"
|
|
78
|
+
/>
|
|
79
|
+
</template>
|
|
80
|
+
</draggable>
|
|
81
|
+
</template>
|
|
82
|
+
</TransferDialog>
|
|
75
83
|
</template>
|
|
76
84
|
|
|
77
85
|
<script setup lang="ts">
|
|
78
86
|
// 方式一:從主模塊導入
|
|
79
|
-
import { BaseTable, BaseBtn, BaseDialog, TransferDialog } from 'rayyy-vue-table-components'
|
|
87
|
+
import { BaseTable, BaseBtn, BaseDialog, TransferDialog, TransferItem } from 'rayyy-vue-table-components'
|
|
80
88
|
import type { TableColumn, SortChangValue } from 'rayyy-vue-table-components'
|
|
81
89
|
|
|
82
90
|
// 方式二:單獨導入組件
|
|
83
|
-
import { BaseTable
|
|
91
|
+
import { BaseTable } from 'rayyy-vue-table-components/components'
|
|
84
92
|
import type { TableColumn } from 'rayyy-vue-table-components/types'
|
|
85
93
|
|
|
86
94
|
// 方式三:單獨導入類型
|
|
@@ -108,15 +116,17 @@ const columns: TableColumn<User>[] = [
|
|
|
108
116
|
]
|
|
109
117
|
|
|
110
118
|
const loading = ref(false)
|
|
111
|
-
const showTransferDialog = ref(false)
|
|
112
119
|
|
|
113
120
|
const handleSortChange = (sortInfo: SortChangValue<User>) => {
|
|
114
121
|
console.log('排序變更:', sortInfo)
|
|
115
122
|
}
|
|
116
123
|
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
const showTransferDialog = ref(false)
|
|
125
|
+
const tableColumns = ref(columns)
|
|
126
|
+
|
|
127
|
+
const handleColumnSubmit = (newColumns: TableColumn<User>[]) => {
|
|
128
|
+
tableColumns.value = newColumns
|
|
129
|
+
showTransferDialog.value = false
|
|
120
130
|
}
|
|
121
131
|
</script>
|
|
122
132
|
```
|
|
@@ -302,15 +312,29 @@ const tableProps: BaseTableProps<User> = {
|
|
|
302
312
|
|------|------|--------|------|
|
|
303
313
|
| modelValue | `boolean` | - | 對話框顯示狀態 |
|
|
304
314
|
| columnsValue | `TableColumn<T>[]` | `[]` | 表格列配置 |
|
|
305
|
-
| transferTitle | `string` |
|
|
306
|
-
| checkAll | `boolean` | `false` | 是否全選 |
|
|
315
|
+
| transferTitle | `string` | - | 對話框標題 |
|
|
307
316
|
|
|
308
317
|
### TransferDialog Events
|
|
309
318
|
|
|
310
319
|
| 事件名 | 參數 | 說明 |
|
|
311
320
|
|--------|------|------|
|
|
312
|
-
| update:submit | `columns: TableColumn<T>[]` | 提交列配置 |
|
|
313
321
|
| update:modelValue | `value: boolean` | 對話框顯示狀態變更 |
|
|
322
|
+
| update:submit | `columns: TableColumn<T>[]` | 提交列配置 |
|
|
323
|
+
|
|
324
|
+
### TransferDialog Slots
|
|
325
|
+
|
|
326
|
+
| 插槽名 | 參數 | 說明 |
|
|
327
|
+
|--------|------|------|
|
|
328
|
+
| list-container | `{ columns, clickItemProp, handleItemEvents, handleMousedown }` | 自定義列表容器,支持拖拽功能 |
|
|
329
|
+
|
|
330
|
+
### TransferItem Props
|
|
331
|
+
|
|
332
|
+
| 屬性 | 類型 | 默認值 | 說明 |
|
|
333
|
+
|------|------|--------|------|
|
|
334
|
+
| columnsValue | `TableColumn<T>` | - | 列配置對象 |
|
|
335
|
+
| columnsIndex | `number` | - | 列索引 |
|
|
336
|
+
| columnsLen | `number` | - | 總列數 |
|
|
337
|
+
| dialogModalVisible | `boolean` | - | 對話框顯示狀態 |
|
|
314
338
|
|
|
315
339
|
### TableColumn 接口
|
|
316
340
|
|
|
@@ -331,6 +355,123 @@ interface TableColumn<T = Record<string, unknown>> {
|
|
|
331
355
|
}
|
|
332
356
|
```
|
|
333
357
|
|
|
358
|
+
## TransferDialog 使用指南
|
|
359
|
+
|
|
360
|
+
TransferDialog 是一個靈活的表格列配置組件,支持自定義列表容器和拖拽功能。
|
|
361
|
+
|
|
362
|
+
### 基本使用
|
|
363
|
+
|
|
364
|
+
```vue
|
|
365
|
+
<template>
|
|
366
|
+
<TransferDialog
|
|
367
|
+
v-model="showDialog"
|
|
368
|
+
:columns-value="columns"
|
|
369
|
+
transfer-title="配置表格列"
|
|
370
|
+
@update:submit="handleSubmit"
|
|
371
|
+
/>
|
|
372
|
+
</template>
|
|
373
|
+
|
|
374
|
+
<script setup lang="ts">
|
|
375
|
+
import { TransferDialog } from 'rayyy-vue-table-components'
|
|
376
|
+
|
|
377
|
+
const showDialog = ref(false)
|
|
378
|
+
const columns = ref<TableColumn<User>[]>([
|
|
379
|
+
{ prop: 'id', label: 'ID', checkActive: true },
|
|
380
|
+
{ prop: 'name', label: '姓名', checkActive: true },
|
|
381
|
+
{ prop: 'email', label: '郵箱', checkActive: false }
|
|
382
|
+
])
|
|
383
|
+
|
|
384
|
+
const handleSubmit = (newColumns: TableColumn<User>[]) => {
|
|
385
|
+
columns.value = newColumns
|
|
386
|
+
showDialog.value = false
|
|
387
|
+
}
|
|
388
|
+
</script>
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### 自定義拖拽功能
|
|
392
|
+
|
|
393
|
+
```vue
|
|
394
|
+
<template>
|
|
395
|
+
<TransferDialog
|
|
396
|
+
v-model="showDialog"
|
|
397
|
+
:columns-value="columns"
|
|
398
|
+
transfer-title="配置表格列"
|
|
399
|
+
@update:submit="handleSubmit"
|
|
400
|
+
>
|
|
401
|
+
<template #list-container="{ columns, clickItemProp, handleItemEvents, handleMousedown }">
|
|
402
|
+
<!-- 使用 vuedraggable 實現拖拽 -->
|
|
403
|
+
<draggable :list="columns" item-key="prop" delay="200">
|
|
404
|
+
<template #item="{ element, index }">
|
|
405
|
+
<transfer-item
|
|
406
|
+
:columns-value="element"
|
|
407
|
+
:columns-index="index"
|
|
408
|
+
:columns-len="columns.length"
|
|
409
|
+
:class="{
|
|
410
|
+
'transfer-active-bg': element.checkActive,
|
|
411
|
+
'transfer-active-border': clickItemProp === element.prop,
|
|
412
|
+
}"
|
|
413
|
+
@mousedown="handleMousedown(element.prop || '')"
|
|
414
|
+
@update:toTop="handleItemEvents.toTop(index)"
|
|
415
|
+
@update:toBottom="handleItemEvents.toBottom(index)"
|
|
416
|
+
@update:toPre="handleItemEvents.toPre(index)"
|
|
417
|
+
@update:toNext="handleItemEvents.toNext(index)"
|
|
418
|
+
/>
|
|
419
|
+
</template>
|
|
420
|
+
</draggable>
|
|
421
|
+
</template>
|
|
422
|
+
</TransferDialog>
|
|
423
|
+
</template>
|
|
424
|
+
|
|
425
|
+
<script setup lang="ts">
|
|
426
|
+
import { TransferDialog, TransferItem } from 'rayyy-vue-table-components'
|
|
427
|
+
import draggable from 'vuedraggable'
|
|
428
|
+
</script>
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
### 靜態列表(無拖拽)
|
|
432
|
+
|
|
433
|
+
```vue
|
|
434
|
+
<template>
|
|
435
|
+
<TransferDialog
|
|
436
|
+
v-model="showDialog"
|
|
437
|
+
:columns-value="columns"
|
|
438
|
+
transfer-title="配置表格列"
|
|
439
|
+
@update:submit="handleSubmit"
|
|
440
|
+
>
|
|
441
|
+
<template #list-container="{ columns, clickItemProp, handleItemEvents, handleMousedown }">
|
|
442
|
+
<!-- 使用靜態列表 -->
|
|
443
|
+
<div class="transfer-list">
|
|
444
|
+
<template v-for="(element, index) in columns" :key="element.prop">
|
|
445
|
+
<transfer-item
|
|
446
|
+
:columns-value="element"
|
|
447
|
+
:columns-index="index"
|
|
448
|
+
:columns-len="columns.length"
|
|
449
|
+
:class="{
|
|
450
|
+
'transfer-active-bg': element.checkActive,
|
|
451
|
+
'transfer-active-border': clickItemProp === element.prop,
|
|
452
|
+
}"
|
|
453
|
+
@mousedown="handleMousedown(element.prop || '')"
|
|
454
|
+
@update:toTop="handleItemEvents.toTop(index)"
|
|
455
|
+
@update:toBottom="handleItemEvents.toBottom(index)"
|
|
456
|
+
@update:toPre="handleItemEvents.toPre(index)"
|
|
457
|
+
@update:toNext="handleItemEvents.toNext(index)"
|
|
458
|
+
/>
|
|
459
|
+
</template>
|
|
460
|
+
</div>
|
|
461
|
+
</template>
|
|
462
|
+
</TransferDialog>
|
|
463
|
+
</template>
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### 功能特色
|
|
467
|
+
|
|
468
|
+
- ✅ **靈活的列表容器**:通過 slot 自定義列表渲染方式
|
|
469
|
+
- ✅ **可選的拖拽功能**:支持或不支持拖拽排序
|
|
470
|
+
- ✅ **內建排序操作**:上移、下移、置頂、置底
|
|
471
|
+
- ✅ **搜尋過濾**:按列名快速定位
|
|
472
|
+
- ✅ **批量選擇**:全選/取消全選功能
|
|
473
|
+
- ✅ **狀態保持**:記住列的顯示/隱藏狀態
|
|
474
|
+
|
|
334
475
|
## 開發
|
|
335
476
|
|
|
336
477
|
```bash
|
|
@@ -350,19 +491,6 @@ npm run test:unit
|
|
|
350
491
|
npm run lint
|
|
351
492
|
```
|
|
352
493
|
|
|
353
|
-
## 組件列表
|
|
354
|
-
|
|
355
|
-
| 組件 | 說明 | 依賴 |
|
|
356
|
-
|------|------|------|
|
|
357
|
-
| BaseTable | 基礎表格組件 | - |
|
|
358
|
-
| BaseBtn | 基礎按鈕組件 | - |
|
|
359
|
-
| BaseInput | 基礎輸入組件 | - |
|
|
360
|
-
| FilterBtn | 篩選按鈕組件 | - |
|
|
361
|
-
| BaseDialog | 基礎對話框組件 | - |
|
|
362
|
-
| SortTable | 排序表格組件 | - |
|
|
363
|
-
| SearchBar | 搜尋欄組件 | - |
|
|
364
|
-
| TransferDialog | 列配置對話框組件 | vuedraggable |
|
|
365
|
-
|
|
366
494
|
## 許可證
|
|
367
495
|
|
|
368
496
|
MIT License
|