rayyy-vue-table-components 1.3.10 → 1.3.12
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 +509 -28
- package/dist/index.es.js +3210 -3125
- package/dist/index.umd.js +10 -10
- package/dist/rayyy-vue-table-components.css +1 -1
- package/dist/src/components/form/BaseMultipleInput.vue.d.ts +3 -3
- package/dist/src/components/tables/BaseTable.vue.d.ts +6 -1
- package/dist/src/components/tables/SortTable.vue.d.ts +7 -2
- package/dist/src/components/tables/TitleTable.vue.d.ts +7 -4
- package/dist/src/types/components.d.ts +18 -2
- package/package.json +1 -1
- package/src/components/tables/BaseTable.vue +28 -0
- package/src/components/tables/SortTable.vue +14 -0
- package/src/components/tables/TitleTable.vue +14 -1
- package/src/types/components.d.ts +18 -2
package/README.md
CHANGED
|
@@ -7,18 +7,20 @@
|
|
|
7
7
|
<img src="https://img.shields.io/badge/vue-3.x-brightgreen.svg" alt="vue">
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
|
-
基於 Vue 3 + Element Plus
|
|
10
|
+
基於 Vue 3 + Element Plus + TypeScript 的現代化組件庫,提供豐富的表格、表單、佈局和交互組件,支援完整的 TypeScript 類型定義和現代化開發體驗。
|
|
11
11
|
|
|
12
12
|
## ✨ 特性
|
|
13
13
|
|
|
14
|
-
- 🚀 **現代化技術棧** - 基於 Vue 3 + TypeScript + Element Plus
|
|
15
|
-
- 📦 **開箱即用** -
|
|
16
|
-
- 🎯 **類型安全** - 完整的 TypeScript
|
|
17
|
-
- 📱 **響應式設計** -
|
|
18
|
-
- 🔧 **高度可配置** -
|
|
19
|
-
- 🎨 **樣式系統** -
|
|
20
|
-
- 🛠️ **現代化工具** - Sass 模組化 + TypeScript 樣式工具
|
|
21
|
-
- 💡 **豐富組件** -
|
|
14
|
+
- 🚀 **現代化技術棧** - 基於 Vue 3 + TypeScript + Element Plus + Tailwind CSS
|
|
15
|
+
- 📦 **開箱即用** - 提供完整的組件解決方案,包含表格、表單、佈局、交互組件
|
|
16
|
+
- 🎯 **類型安全** - 完整的 TypeScript 類型定義,支援智能提示和類型檢查
|
|
17
|
+
- 📱 **響應式設計** - 使用 Tailwind CSS,適配各種設備尺寸
|
|
18
|
+
- 🔧 **高度可配置** - 靈活的配置選項和豐富的插槽支持
|
|
19
|
+
- 🎨 **樣式系統** - 多種樣式導入方式,支援自定義主題和 Tailwind CSS 集成
|
|
20
|
+
- 🛠️ **現代化工具** - Sass 模組化 + TypeScript 樣式工具 + 自動導入
|
|
21
|
+
- 💡 **豐富組件** - 17+ 個組件,涵蓋表格、表單、佈局、對話框、穿梭框等
|
|
22
|
+
- 🧪 **完整測試** - 單元測試 + E2E 測試,確保組件穩定性
|
|
23
|
+
- 📚 **詳細文檔** - 完整的 API 文檔和使用示例
|
|
22
24
|
|
|
23
25
|
## 📦 安裝
|
|
24
26
|
|
|
@@ -186,7 +188,9 @@ import 'rayyy-vue-table-components/styles'
|
|
|
186
188
|
|
|
187
189
|
## 📚 組件示例
|
|
188
190
|
|
|
189
|
-
###
|
|
191
|
+
### 🗂️ 表格組件
|
|
192
|
+
|
|
193
|
+
#### BaseTable - 基礎數據表格
|
|
190
194
|
|
|
191
195
|
基礎的數據表格組件,支援排序、選擇、自定義列等功能。
|
|
192
196
|
|
|
@@ -299,7 +303,94 @@ const handleSelectionChange = (selection: Product[]) => {
|
|
|
299
303
|
```
|
|
300
304
|
</details>
|
|
301
305
|
|
|
302
|
-
###
|
|
306
|
+
### 🎛️ 表單組件
|
|
307
|
+
|
|
308
|
+
#### BaseInput - 基礎輸入框
|
|
309
|
+
|
|
310
|
+
增強的輸入框組件,支援多種類型和驗證功能。
|
|
311
|
+
|
|
312
|
+
<details>
|
|
313
|
+
<summary>基本用法</summary>
|
|
314
|
+
|
|
315
|
+
```vue
|
|
316
|
+
<template>
|
|
317
|
+
<div class="space-y-4">
|
|
318
|
+
<BaseInput
|
|
319
|
+
v-model="inputValue"
|
|
320
|
+
placeholder="請輸入內容"
|
|
321
|
+
:clearable="true"
|
|
322
|
+
/>
|
|
323
|
+
<BaseInput
|
|
324
|
+
v-model="passwordValue"
|
|
325
|
+
type="password"
|
|
326
|
+
placeholder="請輸入密碼"
|
|
327
|
+
show-password
|
|
328
|
+
/>
|
|
329
|
+
<BaseInput
|
|
330
|
+
v-model="emailValue"
|
|
331
|
+
type="email"
|
|
332
|
+
placeholder="請輸入郵箱"
|
|
333
|
+
:validate="validateEmail"
|
|
334
|
+
/>
|
|
335
|
+
</div>
|
|
336
|
+
</template>
|
|
337
|
+
|
|
338
|
+
<script setup lang="ts">
|
|
339
|
+
import { ref } from 'vue'
|
|
340
|
+
import { BaseInput } from 'rayyy-vue-table-components'
|
|
341
|
+
|
|
342
|
+
const inputValue = ref('')
|
|
343
|
+
const passwordValue = ref('')
|
|
344
|
+
const emailValue = ref('')
|
|
345
|
+
|
|
346
|
+
const validateEmail = (value: string) => {
|
|
347
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
|
348
|
+
return emailRegex.test(value) || '請輸入有效的郵箱地址'
|
|
349
|
+
}
|
|
350
|
+
</script>
|
|
351
|
+
```
|
|
352
|
+
</details>
|
|
353
|
+
|
|
354
|
+
#### BaseMultipleInput - 多標籤輸入
|
|
355
|
+
|
|
356
|
+
支援多標籤輸入的組件,適用於標籤管理和多值輸入場景。
|
|
357
|
+
|
|
358
|
+
<details>
|
|
359
|
+
<summary>基本用法</summary>
|
|
360
|
+
|
|
361
|
+
```vue
|
|
362
|
+
<template>
|
|
363
|
+
<BaseMultipleInput
|
|
364
|
+
v-model="tags"
|
|
365
|
+
placeholder="輸入標籤後按 Enter 確認"
|
|
366
|
+
:max-tags="10"
|
|
367
|
+
:validate="validateTag"
|
|
368
|
+
@change="handleTagsChange"
|
|
369
|
+
/>
|
|
370
|
+
</template>
|
|
371
|
+
|
|
372
|
+
<script setup lang="ts">
|
|
373
|
+
import { ref } from 'vue'
|
|
374
|
+
import { BaseMultipleInput } from 'rayyy-vue-table-components'
|
|
375
|
+
|
|
376
|
+
const tags = ref<string[]>(['Vue', 'TypeScript'])
|
|
377
|
+
|
|
378
|
+
const validateTag = (tag: string) => {
|
|
379
|
+
if (tag.length < 2) return '標籤長度至少 2 個字符'
|
|
380
|
+
if (tag.length > 20) return '標籤長度不能超過 20 個字符'
|
|
381
|
+
return true
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const handleTagsChange = (newTags: string[]) => {
|
|
385
|
+
console.log('標籤變更:', newTags)
|
|
386
|
+
}
|
|
387
|
+
</script>
|
|
388
|
+
```
|
|
389
|
+
</details>
|
|
390
|
+
|
|
391
|
+
### 🎨 交互組件
|
|
392
|
+
|
|
393
|
+
#### BaseBtn - 按鈕組件
|
|
303
394
|
|
|
304
395
|
增強的按鈕組件,支援多種樣式和狀態。
|
|
305
396
|
|
|
@@ -341,7 +432,54 @@ const handleClick = () => {
|
|
|
341
432
|
```
|
|
342
433
|
</details>
|
|
343
434
|
|
|
344
|
-
|
|
435
|
+
#### SearchBar - 搜尋欄組件
|
|
436
|
+
|
|
437
|
+
功能豐富的搜尋欄組件,支援即時搜尋和搜尋建議。
|
|
438
|
+
|
|
439
|
+
<details>
|
|
440
|
+
<summary>基本用法</summary>
|
|
441
|
+
|
|
442
|
+
```vue
|
|
443
|
+
<template>
|
|
444
|
+
<SearchBar
|
|
445
|
+
v-model="searchKeyword"
|
|
446
|
+
placeholder="搜尋用戶、郵箱或電話..."
|
|
447
|
+
:suggestions="suggestions"
|
|
448
|
+
@search="handleSearch"
|
|
449
|
+
@suggestion-click="handleSuggestionClick"
|
|
450
|
+
/>
|
|
451
|
+
</template>
|
|
452
|
+
|
|
453
|
+
<script setup lang="ts">
|
|
454
|
+
import { ref, computed } from 'vue'
|
|
455
|
+
import { SearchBar } from 'rayyy-vue-table-components'
|
|
456
|
+
|
|
457
|
+
const searchKeyword = ref('')
|
|
458
|
+
const allSuggestions = ref([
|
|
459
|
+
'張三', '李四', '王五', '趙六'
|
|
460
|
+
])
|
|
461
|
+
|
|
462
|
+
const suggestions = computed(() => {
|
|
463
|
+
if (!searchKeyword.value) return []
|
|
464
|
+
return allSuggestions.value.filter(item =>
|
|
465
|
+
item.includes(searchKeyword.value)
|
|
466
|
+
)
|
|
467
|
+
})
|
|
468
|
+
|
|
469
|
+
const handleSearch = (keyword: string) => {
|
|
470
|
+
console.log('搜尋關鍵字:', keyword)
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const handleSuggestionClick = (suggestion: string) => {
|
|
474
|
+
searchKeyword.value = suggestion
|
|
475
|
+
}
|
|
476
|
+
</script>
|
|
477
|
+
```
|
|
478
|
+
</details>
|
|
479
|
+
|
|
480
|
+
### 💬 對話框組件
|
|
481
|
+
|
|
482
|
+
#### BaseDialog - 基礎對話框
|
|
345
483
|
|
|
346
484
|
靈活的對話框組件,支援多種配置選項。
|
|
347
485
|
|
|
@@ -387,7 +525,9 @@ const handleCancel = () => {
|
|
|
387
525
|
```
|
|
388
526
|
</details>
|
|
389
527
|
|
|
390
|
-
###
|
|
528
|
+
### 🏗️ 佈局組件
|
|
529
|
+
|
|
530
|
+
#### MainPanel - 主面板組件
|
|
391
531
|
|
|
392
532
|
靈活的主面板組件,提供標題、返回按鈕和可自定義高度的滾動區域。
|
|
393
533
|
|
|
@@ -497,7 +637,267 @@ import { MainPanel } from 'rayyy-vue-table-components'
|
|
|
497
637
|
```
|
|
498
638
|
</details>
|
|
499
639
|
|
|
500
|
-
|
|
640
|
+
#### DetailLayout - 詳細頁面佈局
|
|
641
|
+
|
|
642
|
+
專門用於詳細頁面的佈局組件,支援編輯模式和只讀模式切換。
|
|
643
|
+
|
|
644
|
+
<details>
|
|
645
|
+
<summary>基本用法</summary>
|
|
646
|
+
|
|
647
|
+
```vue
|
|
648
|
+
<template>
|
|
649
|
+
<DetailLayout
|
|
650
|
+
title="用戶詳細信息"
|
|
651
|
+
:editable="isEditable"
|
|
652
|
+
:loading="loading"
|
|
653
|
+
@save="handleSave"
|
|
654
|
+
@cancel="handleCancel"
|
|
655
|
+
@back="handleBack"
|
|
656
|
+
>
|
|
657
|
+
<template #header>
|
|
658
|
+
<div class="flex items-center justify-between">
|
|
659
|
+
<h1 class="text-2xl font-bold">用戶管理</h1>
|
|
660
|
+
<BaseBtn
|
|
661
|
+
type="primary"
|
|
662
|
+
@click="toggleEdit"
|
|
663
|
+
>
|
|
664
|
+
{{ isEditable ? '保存' : '編輯' }}
|
|
665
|
+
</BaseBtn>
|
|
666
|
+
</div>
|
|
667
|
+
</template>
|
|
668
|
+
|
|
669
|
+
<template #main>
|
|
670
|
+
<div class="space-y-6">
|
|
671
|
+
<div class="grid grid-cols-2 gap-4">
|
|
672
|
+
<BaseInput
|
|
673
|
+
v-model="userForm.name"
|
|
674
|
+
label="姓名"
|
|
675
|
+
:disabled="!isEditable"
|
|
676
|
+
/>
|
|
677
|
+
<BaseInput
|
|
678
|
+
v-model="userForm.email"
|
|
679
|
+
label="郵箱"
|
|
680
|
+
type="email"
|
|
681
|
+
:disabled="!isEditable"
|
|
682
|
+
/>
|
|
683
|
+
</div>
|
|
684
|
+
</div>
|
|
685
|
+
</template>
|
|
686
|
+
</DetailLayout>
|
|
687
|
+
</template>
|
|
688
|
+
|
|
689
|
+
<script setup lang="ts">
|
|
690
|
+
import { ref } from 'vue'
|
|
691
|
+
import { DetailLayout, BaseBtn, BaseInput } from 'rayyy-vue-table-components'
|
|
692
|
+
|
|
693
|
+
const isEditable = ref(false)
|
|
694
|
+
const loading = ref(false)
|
|
695
|
+
|
|
696
|
+
const userForm = ref({
|
|
697
|
+
name: '張三',
|
|
698
|
+
email: 'zhangsan@example.com'
|
|
699
|
+
})
|
|
700
|
+
|
|
701
|
+
const toggleEdit = () => {
|
|
702
|
+
isEditable.value = !isEditable.value
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
const handleSave = async () => {
|
|
706
|
+
loading.value = true
|
|
707
|
+
// 模擬保存操作
|
|
708
|
+
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
709
|
+
loading.value = false
|
|
710
|
+
isEditable.value = false
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
const handleCancel = () => {
|
|
714
|
+
isEditable.value = false
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
const handleBack = () => {
|
|
718
|
+
// 返回上一頁
|
|
719
|
+
console.log('返回上一頁')
|
|
720
|
+
}
|
|
721
|
+
</script>
|
|
722
|
+
```
|
|
723
|
+
</details>
|
|
724
|
+
|
|
725
|
+
#### FilterLayout - 篩選頁面佈局
|
|
726
|
+
|
|
727
|
+
專門用於篩選頁面的佈局組件,支援自定義篩選表單。
|
|
728
|
+
|
|
729
|
+
<details>
|
|
730
|
+
<summary>基本用法</summary>
|
|
731
|
+
|
|
732
|
+
```vue
|
|
733
|
+
<template>
|
|
734
|
+
<FilterLayout
|
|
735
|
+
main-title="用戶管理"
|
|
736
|
+
filter-title="篩選條件"
|
|
737
|
+
@submit="handleFilterSubmit"
|
|
738
|
+
@reset="handleFilterReset"
|
|
739
|
+
>
|
|
740
|
+
<template #filter-form>
|
|
741
|
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
742
|
+
<BaseInput
|
|
743
|
+
v-model="filterForm.keyword"
|
|
744
|
+
label="關鍵字"
|
|
745
|
+
placeholder="搜尋姓名或郵箱"
|
|
746
|
+
/>
|
|
747
|
+
<BaseSelector
|
|
748
|
+
v-model="filterForm.status"
|
|
749
|
+
label="狀態"
|
|
750
|
+
:options="statusOptions"
|
|
751
|
+
/>
|
|
752
|
+
<BaseInput
|
|
753
|
+
v-model="filterForm.dateRange"
|
|
754
|
+
label="創建時間"
|
|
755
|
+
type="daterange"
|
|
756
|
+
/>
|
|
757
|
+
</div>
|
|
758
|
+
</template>
|
|
759
|
+
</FilterLayout>
|
|
760
|
+
</template>
|
|
761
|
+
|
|
762
|
+
<script setup lang="ts">
|
|
763
|
+
import { ref } from 'vue'
|
|
764
|
+
import { FilterLayout, BaseInput, BaseSelector } from 'rayyy-vue-table-components'
|
|
765
|
+
|
|
766
|
+
const filterForm = ref({
|
|
767
|
+
keyword: '',
|
|
768
|
+
status: '',
|
|
769
|
+
dateRange: []
|
|
770
|
+
})
|
|
771
|
+
|
|
772
|
+
const statusOptions = [
|
|
773
|
+
{ label: '全部', value: '' },
|
|
774
|
+
{ label: '啟用', value: 'active' },
|
|
775
|
+
{ label: '禁用', value: 'inactive' }
|
|
776
|
+
]
|
|
777
|
+
|
|
778
|
+
const handleFilterSubmit = () => {
|
|
779
|
+
console.log('篩選條件:', filterForm.value)
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
const handleFilterReset = () => {
|
|
783
|
+
filterForm.value = {
|
|
784
|
+
keyword: '',
|
|
785
|
+
status: '',
|
|
786
|
+
dateRange: []
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
</script>
|
|
790
|
+
```
|
|
791
|
+
</details>
|
|
792
|
+
|
|
793
|
+
#### SearchableListPanel - 整合式搜尋面板
|
|
794
|
+
|
|
795
|
+
整合搜尋、篩選、分頁功能的綜合面板組件。
|
|
796
|
+
|
|
797
|
+
<details>
|
|
798
|
+
<summary>基本用法</summary>
|
|
799
|
+
|
|
800
|
+
```vue
|
|
801
|
+
<template>
|
|
802
|
+
<SearchableListPanel
|
|
803
|
+
title="用戶列表"
|
|
804
|
+
:data="tableData"
|
|
805
|
+
:columns="columns"
|
|
806
|
+
:loading="loading"
|
|
807
|
+
:pagination="pagination"
|
|
808
|
+
@search="handleSearch"
|
|
809
|
+
@filter="handleFilter"
|
|
810
|
+
@page-change="handlePageChange"
|
|
811
|
+
>
|
|
812
|
+
<template #firstButton>
|
|
813
|
+
<BaseBtn type="primary" @click="handleAdd">
|
|
814
|
+
新增用戶
|
|
815
|
+
</BaseBtn>
|
|
816
|
+
</template>
|
|
817
|
+
|
|
818
|
+
<template #customButton>
|
|
819
|
+
<BaseBtn type="default" @click="handleExport">
|
|
820
|
+
導出數據
|
|
821
|
+
</BaseBtn>
|
|
822
|
+
</template>
|
|
823
|
+
|
|
824
|
+
<template #filter-content>
|
|
825
|
+
<div class="space-y-4">
|
|
826
|
+
<BaseInput
|
|
827
|
+
v-model="filterForm.keyword"
|
|
828
|
+
label="關鍵字"
|
|
829
|
+
placeholder="搜尋姓名或郵箱"
|
|
830
|
+
/>
|
|
831
|
+
<BaseSelector
|
|
832
|
+
v-model="filterForm.status"
|
|
833
|
+
label="狀態"
|
|
834
|
+
:options="statusOptions"
|
|
835
|
+
/>
|
|
836
|
+
</div>
|
|
837
|
+
</template>
|
|
838
|
+
</SearchableListPanel>
|
|
839
|
+
</template>
|
|
840
|
+
|
|
841
|
+
<script setup lang="ts">
|
|
842
|
+
import { ref } from 'vue'
|
|
843
|
+
import { SearchableListPanel, BaseBtn, BaseInput, BaseSelector } from 'rayyy-vue-table-components'
|
|
844
|
+
|
|
845
|
+
const loading = ref(false)
|
|
846
|
+
const tableData = ref([
|
|
847
|
+
{ id: 1, name: '張三', email: 'zhangsan@example.com', status: 'active' },
|
|
848
|
+
{ id: 2, name: '李四', email: 'lisi@example.com', status: 'inactive' }
|
|
849
|
+
])
|
|
850
|
+
|
|
851
|
+
const columns = [
|
|
852
|
+
{ prop: 'id', label: 'ID', width: 80 },
|
|
853
|
+
{ prop: 'name', label: '姓名' },
|
|
854
|
+
{ prop: 'email', label: '郵箱' },
|
|
855
|
+
{ prop: 'status', label: '狀態' }
|
|
856
|
+
]
|
|
857
|
+
|
|
858
|
+
const pagination = ref({
|
|
859
|
+
current: 1,
|
|
860
|
+
pageSize: 10,
|
|
861
|
+
total: 100
|
|
862
|
+
})
|
|
863
|
+
|
|
864
|
+
const filterForm = ref({
|
|
865
|
+
keyword: '',
|
|
866
|
+
status: ''
|
|
867
|
+
})
|
|
868
|
+
|
|
869
|
+
const statusOptions = [
|
|
870
|
+
{ label: '全部', value: '' },
|
|
871
|
+
{ label: '啟用', value: 'active' },
|
|
872
|
+
{ label: '禁用', value: 'inactive' }
|
|
873
|
+
]
|
|
874
|
+
|
|
875
|
+
const handleSearch = (keyword: string) => {
|
|
876
|
+
console.log('搜尋:', keyword)
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
const handleFilter = (filters: any) => {
|
|
880
|
+
console.log('篩選:', filters)
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
const handlePageChange = (page: number, pageSize: number) => {
|
|
884
|
+
console.log('分頁變更:', page, pageSize)
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
const handleAdd = () => {
|
|
888
|
+
console.log('新增用戶')
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
const handleExport = () => {
|
|
892
|
+
console.log('導出數據')
|
|
893
|
+
}
|
|
894
|
+
</script>
|
|
895
|
+
```
|
|
896
|
+
</details>
|
|
897
|
+
|
|
898
|
+
### 🔄 轉移組件
|
|
899
|
+
|
|
900
|
+
#### TransferDialog - 穿梭框對話框
|
|
501
901
|
|
|
502
902
|
用於表格列配置的穿梭框組件,支援拖拽排序。
|
|
503
903
|
|
|
@@ -602,6 +1002,7 @@ const handleColumnSubmit = (newColumns: TableColumn<User>[]) => {
|
|
|
602
1002
|
| `showOverFlowTooltip` | `boolean` | `false` | 是否顯示溢出提示 |
|
|
603
1003
|
| `summaryMethod` | `SummaryMethod<T>` | - | 合計行計算方法 |
|
|
604
1004
|
| `baseTableRowClassName` | `RowClassNameGetter<T>` | - | 行樣式類名函數 |
|
|
1005
|
+
| `showOperator` | `boolean` | `false` | 是否顯示操作列 |
|
|
605
1006
|
|
|
606
1007
|
#### Events
|
|
607
1008
|
|
|
@@ -611,6 +1012,8 @@ const handleColumnSubmit = (newColumns: TableColumn<User>[]) => {
|
|
|
611
1012
|
| `current-change` | `currentRow: T \| null` | 當前行變更時觸發 |
|
|
612
1013
|
| `cell-click` | `column: TableColumn<T>, row: T` | 單元格點擊時觸發 |
|
|
613
1014
|
| `column-sort-change` | `value: SortChangValue<T>` | 列排序變更時觸發 |
|
|
1015
|
+
| `click:checkRow` | `row: T` | 查看按鈕點擊時觸發 |
|
|
1016
|
+
| `click:editRow` | `row: T` | 編輯按鈕點擊時觸發 |
|
|
614
1017
|
|
|
615
1018
|
#### Slots
|
|
616
1019
|
|
|
@@ -921,9 +1324,11 @@ const getRowClass = ({ row, rowIndex }: any) => {
|
|
|
921
1324
|
|
|
922
1325
|
### 環境要求
|
|
923
1326
|
|
|
924
|
-
- Node.js
|
|
925
|
-
-
|
|
926
|
-
-
|
|
1327
|
+
- Node.js 22.0+
|
|
1328
|
+
- npm 10.0+
|
|
1329
|
+
- Vue 3.5+
|
|
1330
|
+
- Element Plus 2.11+
|
|
1331
|
+
- TypeScript 5.8+
|
|
927
1332
|
|
|
928
1333
|
### 本地開發
|
|
929
1334
|
|
|
@@ -935,37 +1340,99 @@ cd vue-table-components
|
|
|
935
1340
|
# 安裝依賴
|
|
936
1341
|
npm install
|
|
937
1342
|
|
|
938
|
-
#
|
|
1343
|
+
# 開發模式(啟動演示網站)
|
|
939
1344
|
npm run dev
|
|
940
1345
|
|
|
941
|
-
#
|
|
1346
|
+
# 構建組件庫
|
|
942
1347
|
npm run build-lib
|
|
943
1348
|
|
|
944
|
-
#
|
|
1349
|
+
# 構建演示網站
|
|
1350
|
+
npm run build-demo
|
|
1351
|
+
|
|
1352
|
+
# 運行單元測試
|
|
945
1353
|
npm run test:unit
|
|
946
1354
|
|
|
947
|
-
#
|
|
1355
|
+
# 運行 E2E 測試
|
|
1356
|
+
npm run test:e2e
|
|
1357
|
+
|
|
1358
|
+
# 代碼檢查和格式化
|
|
948
1359
|
npm run lint
|
|
1360
|
+
npm run format
|
|
1361
|
+
|
|
1362
|
+
# TypeScript 類型檢查
|
|
1363
|
+
npm run type-check
|
|
1364
|
+
```
|
|
1365
|
+
|
|
1366
|
+
### 快速發布
|
|
1367
|
+
|
|
1368
|
+
使用內建的發布腳本快速發布新版本:
|
|
1369
|
+
|
|
1370
|
+
```bash
|
|
1371
|
+
# 修復版本 (1.3.10 -> 1.3.11)
|
|
1372
|
+
npm run release:patch
|
|
1373
|
+
|
|
1374
|
+
# 次要版本 (1.3.10 -> 1.4.0)
|
|
1375
|
+
npm run release:minor
|
|
1376
|
+
|
|
1377
|
+
# 主要版本 (1.3.10 -> 2.0.0)
|
|
1378
|
+
npm run release:major
|
|
949
1379
|
```
|
|
950
1380
|
|
|
1381
|
+
發布腳本會自動執行:
|
|
1382
|
+
- ✅ 運行所有測試
|
|
1383
|
+
- ✅ 代碼品質檢查
|
|
1384
|
+
- ✅ TypeScript 類型檢查
|
|
1385
|
+
- ✅ 構建組件庫
|
|
1386
|
+
- ✅ 更新版本號
|
|
1387
|
+
- ✅ 創建 git tag
|
|
1388
|
+
- ✅ 推送到遠端
|
|
1389
|
+
- ✅ 發布到 npm
|
|
1390
|
+
|
|
951
1391
|
### 項目結構
|
|
952
1392
|
|
|
953
1393
|
```
|
|
954
1394
|
src/
|
|
955
1395
|
├── components/ # 組件源碼
|
|
956
|
-
│ ├──
|
|
957
|
-
│ ├──
|
|
958
|
-
│
|
|
959
|
-
│
|
|
1396
|
+
│ ├── form/ # 表單組件
|
|
1397
|
+
│ │ ├── BaseInput.vue
|
|
1398
|
+
│ │ └── BaseMultipleInput.vue
|
|
1399
|
+
│ ├── items/ # 交互組件
|
|
1400
|
+
│ │ ├── BaseBtn.vue
|
|
1401
|
+
│ │ ├── BaseDialog.vue
|
|
1402
|
+
│ │ ├── BaseWaringDialog.vue
|
|
1403
|
+
│ │ └── SearchBar.vue
|
|
1404
|
+
│ ├── tables/ # 表格組件
|
|
1405
|
+
│ │ ├── BaseTable.vue
|
|
1406
|
+
│ │ ├── SortTable.vue
|
|
1407
|
+
│ │ └── TitleTable.vue
|
|
1408
|
+
│ ├── layout/ # 佈局組件
|
|
1409
|
+
│ │ ├── MainPanel.vue
|
|
1410
|
+
│ │ ├── DetailLayout.vue
|
|
1411
|
+
│ │ ├── FilterLayout.vue
|
|
1412
|
+
│ │ ├── FunctionHeader.vue
|
|
1413
|
+
│ │ └── SearchableListPanel.vue
|
|
1414
|
+
│ ├── transfer/ # 轉移組件
|
|
1415
|
+
│ │ ├── TransferDialog.vue
|
|
1416
|
+
│ │ └── transferItem.vue
|
|
1417
|
+
│ └── index.ts # 組件導出
|
|
960
1418
|
├── assets/styles/ # 樣式文件
|
|
961
1419
|
│ ├── tailwind.scss # 主樣式入口
|
|
962
|
-
│ ├── _base.scss #
|
|
963
|
-
│ ├── _tables.scss #
|
|
1420
|
+
│ ├── _base.scss # 基礎樣式
|
|
1421
|
+
│ ├── _tables.scss # 表格相關樣式
|
|
964
1422
|
│ ├── _dialogs.scss # 對話框相關樣式
|
|
965
|
-
│ ├── _components.scss #
|
|
1423
|
+
│ ├── _components.scss # 組件樣式
|
|
966
1424
|
│ └── element/ # Element Plus 主題
|
|
967
1425
|
├── types/ # 類型定義
|
|
1426
|
+
│ ├── components.d.ts # 組件類型定義
|
|
1427
|
+
│ └── index.ts # 類型導出
|
|
968
1428
|
├── utils/ # 工具函數
|
|
1429
|
+
│ ├── tableHelper.ts # 表格工具函數
|
|
1430
|
+
│ └── routeFormatters.ts # 路由格式化
|
|
1431
|
+
├── views/ # 演示頁面
|
|
1432
|
+
│ ├── demo/ # 組件演示
|
|
1433
|
+
│ └── DemoPage.vue # 演示首頁
|
|
1434
|
+
├── router/ # 路由配置
|
|
1435
|
+
├── const/ # 常量定義
|
|
969
1436
|
└── index.ts # 主入口文件
|
|
970
1437
|
```
|
|
971
1438
|
|
|
@@ -992,12 +1459,26 @@ src/
|
|
|
992
1459
|
|
|
993
1460
|
查看 [CHANGELOG.md](./CHANGELOG.md) 了解詳細的版本更新記錄。
|
|
994
1461
|
|
|
1462
|
+
### 組件統計
|
|
1463
|
+
|
|
1464
|
+
本組件庫目前包含 **17+ 個組件**,涵蓋以下類別:
|
|
1465
|
+
|
|
1466
|
+
| 類別 | 組件數量 | 主要組件 |
|
|
1467
|
+
|------|----------|----------|
|
|
1468
|
+
| 🗂️ 表格組件 | 3 | BaseTable, SortTable, TitleTable |
|
|
1469
|
+
| 🎛️ 表單組件 | 2 | BaseInput, BaseMultipleInput |
|
|
1470
|
+
| 🎨 交互組件 | 4 | BaseBtn, BaseDialog, BaseWaringDialog, SearchBar |
|
|
1471
|
+
| 🏗️ 佈局組件 | 5 | MainPanel, DetailLayout, FilterLayout, FunctionHeader, SearchableListPanel |
|
|
1472
|
+
| 🔄 轉移組件 | 2 | TransferDialog, TransferItem |
|
|
1473
|
+
|
|
995
1474
|
### 相關鏈接
|
|
996
1475
|
|
|
997
1476
|
- [Vue 3 官方文檔](https://vuejs.org/)
|
|
998
1477
|
- [Element Plus 官方文檔](https://element-plus.org/)
|
|
999
1478
|
- [TypeScript 官方文檔](https://www.typescriptlang.org/)
|
|
1000
1479
|
- [Tailwind CSS 官方文檔](https://tailwindcss.com/)
|
|
1480
|
+
- [Vite 官方文檔](https://vitejs.dev/)
|
|
1481
|
+
- [Vitest 測試框架](https://vitest.dev/)
|
|
1001
1482
|
|
|
1002
1483
|
## 📄 許可證
|
|
1003
1484
|
|