rayyy-vue-table-components 1.0.1
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 +144 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +7994 -0
- package/dist/index.umd.js +25 -0
- package/dist/rayyy-vue-table-components.css +1 -0
- package/package.json +94 -0
- package/src/components/BaseTable.vue +100 -0
- package/src/types/index.ts +102 -0
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Vue Table Components
|
|
2
|
+
|
|
3
|
+
基於 Vue 3 + Element Plus 的表格組件庫
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- 🚀 基於 Vue 3 + TypeScript
|
|
8
|
+
- 📦 基於 Element Plus
|
|
9
|
+
- 🎯 完整的 TypeScript 類型支持
|
|
10
|
+
- 📱 響應式設計
|
|
11
|
+
- 🔧 高度可配置
|
|
12
|
+
|
|
13
|
+
## 安裝
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @your-scope/vue-table-components
|
|
17
|
+
# 或
|
|
18
|
+
yarn add @your-scope/vue-table-components
|
|
19
|
+
# 或
|
|
20
|
+
pnpm add @your-scope/vue-table-components
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 使用方法
|
|
24
|
+
|
|
25
|
+
### 全局註冊
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { createApp } from 'vue'
|
|
29
|
+
import VueTableComponents from '@your-scope/vue-table-components'
|
|
30
|
+
import '@your-scope/vue-table-components/style.css'
|
|
31
|
+
|
|
32
|
+
const app = createApp(App)
|
|
33
|
+
app.use(VueTableComponents)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 按需引入
|
|
37
|
+
|
|
38
|
+
```vue
|
|
39
|
+
<template>
|
|
40
|
+
<BaseTable
|
|
41
|
+
:data="tableData"
|
|
42
|
+
:columns="columns"
|
|
43
|
+
:loading="loading"
|
|
44
|
+
@column-sort-change="handleSortChange"
|
|
45
|
+
/>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script setup lang="ts">
|
|
49
|
+
import { BaseTable } from '@your-scope/vue-table-components'
|
|
50
|
+
import type { TableColumn, SortChangValue } from '@your-scope/vue-table-components'
|
|
51
|
+
import '@your-scope/vue-table-components/style.css'
|
|
52
|
+
|
|
53
|
+
interface User {
|
|
54
|
+
id: number
|
|
55
|
+
name: string
|
|
56
|
+
email: string
|
|
57
|
+
age: number
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const tableData: User[] = [
|
|
61
|
+
{ id: 1, name: 'John Doe', email: 'john@example.com', age: 30 },
|
|
62
|
+
{ id: 2, name: 'Jane Smith', email: 'jane@example.com', age: 25 }
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
const columns: TableColumn<User>[] = [
|
|
66
|
+
{ prop: 'id', label: 'ID', width: 80 },
|
|
67
|
+
{ prop: 'name', label: '姓名', sortable: true },
|
|
68
|
+
{ prop: 'email', label: '郵箱' },
|
|
69
|
+
{ prop: 'age', label: '年齡', sortable: true }
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
const loading = ref(false)
|
|
73
|
+
|
|
74
|
+
const handleSortChange = (sortInfo: SortChangValue<User>) => {
|
|
75
|
+
console.log('排序變更:', sortInfo)
|
|
76
|
+
}
|
|
77
|
+
</script>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## API
|
|
81
|
+
|
|
82
|
+
### BaseTable Props
|
|
83
|
+
|
|
84
|
+
| 屬性 | 類型 | 默認值 | 說明 |
|
|
85
|
+
|------|------|--------|------|
|
|
86
|
+
| data | `T[]` | `[]` | 表格數據 |
|
|
87
|
+
| columns | `TableColumn<T>[]` | `[]` | 表格列配置 |
|
|
88
|
+
| loading | `boolean` | `false` | 加載狀態 |
|
|
89
|
+
| showSelection | `boolean` | `false` | 是否顯示選擇列 |
|
|
90
|
+
| showSummary | `boolean` | `false` | 是否顯示合計行 |
|
|
91
|
+
| showOverFlowTooltip | `boolean` | `false` | 是否顯示溢出提示 |
|
|
92
|
+
| summaryMethod | `Function` | - | 合計行計算方法 |
|
|
93
|
+
| baseTableRowClassName | `Function` | - | 行樣式類名函數 |
|
|
94
|
+
|
|
95
|
+
### BaseTable Events
|
|
96
|
+
|
|
97
|
+
| 事件名 | 參數 | 說明 |
|
|
98
|
+
|--------|------|------|
|
|
99
|
+
| selection-change | `selection: T[]` | 選擇項變更 |
|
|
100
|
+
| current-change | `currentRow: T` | 當前行變更 |
|
|
101
|
+
| cell-click | `column: TableColumn<T>, row: T` | 單元格點擊 |
|
|
102
|
+
| column-sort-change | `value: SortChangValue<T>` | 列排序變更 |
|
|
103
|
+
|
|
104
|
+
### TableColumn 接口
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
interface TableColumn<T = Record<string, unknown>> {
|
|
108
|
+
prop?: string
|
|
109
|
+
label: string
|
|
110
|
+
width?: number | string
|
|
111
|
+
type?: 'selection' | 'index' | 'expand'
|
|
112
|
+
fixed?: boolean | 'left' | 'right'
|
|
113
|
+
align?: 'center' | 'left' | 'right'
|
|
114
|
+
sortable?: boolean | 'custom'
|
|
115
|
+
formatter?: (row: T) => string
|
|
116
|
+
template?: (row: T) => VNode
|
|
117
|
+
minWidth?: number | string
|
|
118
|
+
headerAlign?: 'center' | 'left' | 'right'
|
|
119
|
+
checkActive?: boolean
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 開發
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# 安裝依賴
|
|
127
|
+
npm install
|
|
128
|
+
|
|
129
|
+
# 開發模式
|
|
130
|
+
npm run dev
|
|
131
|
+
|
|
132
|
+
# 構建庫
|
|
133
|
+
npm run build
|
|
134
|
+
|
|
135
|
+
# 運行測試
|
|
136
|
+
npm run test:unit
|
|
137
|
+
|
|
138
|
+
# 代碼檢查
|
|
139
|
+
npm run lint
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## 許可證
|
|
143
|
+
|
|
144
|
+
MIT License
|
package/dist/favicon.ico
ADDED
|
Binary file
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|