rayyy-vue-table-components 1.0.39 → 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 CHANGED
@@ -51,11 +51,40 @@ app.use(VueTableComponents)
51
51
  <BaseDialog v-model="showDialog" title="確認操作">
52
52
  <p>您確定要執行此操作嗎?</p>
53
53
  </BaseDialog>
54
+
55
+ <!-- TransferDialog 示例 -->
56
+ <TransferDialog
57
+ v-model="showTransferDialog"
58
+ :columns-value="tableColumns"
59
+ transfer-title="配置表格列"
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>
54
83
  </template>
55
84
 
56
85
  <script setup lang="ts">
57
86
  // 方式一:從主模塊導入
58
- import { BaseTable, BaseBtn, BaseDialog } from 'rayyy-vue-table-components'
87
+ import { BaseTable, BaseBtn, BaseDialog, TransferDialog, TransferItem } from 'rayyy-vue-table-components'
59
88
  import type { TableColumn, SortChangValue } from 'rayyy-vue-table-components'
60
89
 
61
90
  // 方式二:單獨導入組件
@@ -91,6 +120,14 @@ const loading = ref(false)
91
120
  const handleSortChange = (sortInfo: SortChangValue<User>) => {
92
121
  console.log('排序變更:', sortInfo)
93
122
  }
123
+
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
130
+ }
94
131
  </script>
95
132
  ```
96
133
 
@@ -269,6 +306,36 @@ const tableProps: BaseTableProps<User> = {
269
306
  | bodyLoading | `boolean` | `false` | 內容區域加載狀態 |
270
307
  | submitLoading | `boolean` | `false` | 提交按鈕加載狀態 |
271
308
 
309
+ ### TransferDialog Props
310
+
311
+ | 屬性 | 類型 | 默認值 | 說明 |
312
+ |------|------|--------|------|
313
+ | modelValue | `boolean` | - | 對話框顯示狀態 |
314
+ | columnsValue | `TableColumn<T>[]` | `[]` | 表格列配置 |
315
+ | transferTitle | `string` | - | 對話框標題 |
316
+
317
+ ### TransferDialog Events
318
+
319
+ | 事件名 | 參數 | 說明 |
320
+ |--------|------|------|
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` | - | 對話框顯示狀態 |
338
+
272
339
  ### TableColumn 接口
273
340
 
274
341
  ```typescript
@@ -288,6 +355,123 @@ interface TableColumn<T = Record<string, unknown>> {
288
355
  }
289
356
  ```
290
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
+
291
475
  ## 開發
292
476
 
293
477
  ```bash