rayyy-vue-table-components 1.2.6 → 1.2.8

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
@@ -9,6 +9,9 @@
9
9
  - 🎯 完整的 TypeScript 類型支持
10
10
  - 📱 響應式設計
11
11
  - 🔧 高度可配置
12
+ - 🎨 靈活的樣式系統 - 支援多種導入方式
13
+ - 🛠️ 現代化的 Sass 模組系統
14
+ - 💡 TypeScript 樣式工具函數
12
15
 
13
16
  ## 安裝
14
17
 
@@ -20,6 +23,47 @@ yarn add rayyy-vue-table-components
20
23
  pnpm add rayyy-vue-table-components
21
24
  ```
22
25
 
26
+ ## 樣式導入
27
+
28
+ 本組件庫提供多種靈活的樣式導入方式,您可以根據項目需求選擇:
29
+
30
+ ### 方式 1:完整樣式導入(推薦)
31
+
32
+ ```typescript
33
+ // main.ts
34
+ import 'element-plus/dist/index.css'
35
+ import 'rayyy-vue-table-components/styles' // 導入所有組件樣式
36
+ ```
37
+
38
+ 或在 CSS/SCSS 文件中:
39
+
40
+ ```scss
41
+ // styles.scss
42
+ @import 'element-plus/dist/index.css';
43
+ @import 'rayyy-vue-table-components/styles';
44
+ ```
45
+
46
+ ### 方式 2:Element Plus 主題自定義
47
+
48
+ ```scss
49
+ // styles.scss
50
+ @import 'element-plus/dist/index.css';
51
+ @import 'rayyy-vue-table-components/styles/element'; // 只導入 Element 主題
52
+ ```
53
+
54
+ ### 方式 3:TypeScript 樣式工具(推薦用於動態樣式)
55
+
56
+ ```typescript
57
+ // 導入樣式工具函數
58
+ import { tableStyles, createTableCellClass } from 'rayyy-vue-table-components/utils/styles'
59
+
60
+ // 在組件中使用
61
+ const cellClass = createTableCellClass({
62
+ isDismissed: true,
63
+ isHeader: false
64
+ })
65
+ ```
66
+
23
67
  ## 使用方法
24
68
 
25
69
  ### 全局註冊
@@ -27,7 +71,9 @@ pnpm add rayyy-vue-table-components
27
71
  ```typescript
28
72
  import { createApp } from 'vue'
29
73
  import VueTableComponents from 'rayyy-vue-table-components'
30
- import 'rayyy-vue-table-components/dist/rayyy-vue-table-components.css'
74
+
75
+ // 導入樣式(選擇上述任一方式)
76
+ import 'rayyy-vue-table-components/styles'
31
77
 
32
78
  const app = createApp(App)
33
79
  app.use(VueTableComponents)
@@ -94,7 +140,8 @@ import type { TableColumn } from 'rayyy-vue-table-components/types'
94
140
  // 方式三:單獨導入類型
95
141
  import type { SortChangValue } from 'rayyy-vue-table-components/types'
96
142
 
97
- import 'rayyy-vue-table-components/dist/rayyy-vue-table-components.css'
143
+ // 方式四:導入樣式工具函數
144
+ import { tableStyles, createTableCellClass } from 'rayyy-vue-table-components/utils/styles'
98
145
 
99
146
  interface User {
100
147
  id: number
@@ -173,6 +220,25 @@ import type {
173
220
  } from 'rayyy-vue-table-components/types'
174
221
  ```
175
222
 
223
+ ### 樣式工具類型
224
+
225
+ ```typescript
226
+ import type {
227
+ TableStylesType,
228
+ DataTableConfigType
229
+ } from 'rayyy-vue-table-components/utils/styles'
230
+
231
+ // 樣式工具函數
232
+ import {
233
+ tableStyles, // 預定義表格樣式對象
234
+ componentStyles, // 預定義組件樣式對象
235
+ allComponentStyles, // 完整的樣式對象
236
+ dataTableConfig, // 表格配置對象
237
+ createTableCellClass, // 動態生成表格單元格樣式
238
+ createTextClass // 動態生成文字樣式
239
+ } from 'rayyy-vue-table-components/utils/styles'
240
+ ```
241
+
176
242
  ### 使用示例
177
243
 
178
244
  ```typescript
@@ -240,9 +306,87 @@ const tableProps: BaseTableProps<User> = {
240
306
  return row.status === 'active' ? 'active-row' : 'inactive-row'
241
307
  }
242
308
  }
309
+
310
+ // 樣式工具使用示例
311
+ const dynamicCellClass = createTableCellClass({
312
+ isDismissed: user.status === 'inactive',
313
+ isHeader: false
314
+ })
315
+
316
+ const textClass = createTextClass('blue') // 'blue' | 'red' | 'normal'
317
+
318
+ // 在模板中使用預定義樣式
319
+ const cellClasses = [
320
+ tableStyles.cell, // 基礎單元格樣式
321
+ tableStyles.content, // 內容樣式
322
+ user.status === 'inactive' ? tableStyles.dismissed : ''
323
+ ].filter(Boolean).join(' ')
324
+ ```
325
+
326
+ ## 樣式工具 API
327
+
328
+ ### 預定義樣式
329
+
330
+ ```typescript
331
+ // 直接使用預定義樣式
332
+ import { tableStyles, componentStyles } from 'rayyy-vue-table-components/utils/styles'
333
+
334
+ // 表格樣式
335
+ tableStyles.cell // 表格單元格樣式: 'p-0 h-10'
336
+ tableStyles.header // 表格標題樣式: 'bg-primary-15 font-bold text-text text-sm leading-4'
337
+ tableStyles.content // 內容樣式: 'truncate'
338
+ tableStyles.dismissed // 被駁回行樣式: 'bg-blue-20'
339
+ tableStyles.footer // 表格底部樣式: 'font-bold'
340
+ tableStyles.blueText // 藍色文字: 'text-blue-10'
341
+ tableStyles.redText // 紅色文字: 'text-redText'
342
+
343
+ // 組件樣式
344
+ componentStyles.sortTableContainer // SortTable 容器: 'w-full mb-4'
345
+ componentStyles.sortTableFunctionBar // SortTable 功能欄
346
+ componentStyles.filterBtn // FilterBtn 按鈕樣式
347
+ componentStyles.transferActiveBg // Transfer 啟用背景
348
+ componentStyles.baseDialogTitle // Dialog 標題樣式
349
+ componentStyles.cursorGrab // 抓取游標
243
350
  ```
244
351
 
245
- ## API
352
+ ### 動態樣式函數
353
+
354
+ ```typescript
355
+ // 創建動態表格單元格樣式
356
+ createTableCellClass(options?: {
357
+ isDismissed?: boolean
358
+ isHeader?: boolean
359
+ }) => string
360
+
361
+ // 創建文字顏色樣式
362
+ createTextClass(type: 'blue' | 'red' | 'normal' = 'normal') => string
363
+
364
+ // 使用示例
365
+ const cellClass = createTableCellClass({
366
+ isDismissed: true, // 添加被駁回樣式
367
+ isHeader: false // 不是標題行
368
+ })
369
+ // 結果: 'p-0 h-10 bg-blue-20'
370
+
371
+ const textClass = createTextClass('blue')
372
+ // 結果: 'text-blue-10'
373
+ ```
374
+
375
+ ### 配置對象
376
+
377
+ ```typescript
378
+ // 表格配置對象,適用於 Element Plus 表格組件
379
+ import { dataTableConfig } from 'rayyy-vue-table-components/utils/styles'
380
+
381
+ // 在 Element Plus 表格中使用
382
+ <el-table
383
+ :cell-class-name="dataTableConfig.cellClass"
384
+ :header-cell-class-name="dataTableConfig.headerClass"
385
+ >
386
+ </el-table>
387
+ ```
388
+
389
+ ## 組件 API
246
390
 
247
391
  ### BaseTable Props
248
392
 
@@ -481,8 +625,8 @@ npm install
481
625
  # 開發模式
482
626
  npm run dev
483
627
 
484
- # 構建庫
485
- npm run build
628
+ # 構建庫(包含樣式)
629
+ npm run build-lib
486
630
 
487
631
  # 運行測試
488
632
  npm run test:unit
@@ -491,6 +635,35 @@ npm run test:unit
491
635
  npm run lint
492
636
  ```
493
637
 
638
+ ### 樣式開發指南
639
+
640
+ 本組件庫採用現代化的樣式架構:
641
+
642
+ 1. **Sass 模組化**:使用 `@use` 語法替代 `@import`
643
+ 2. **Tailwind CSS 集成**:支援 Tailwind 工具類和自定義樣式
644
+ 3. **TypeScript 樣式工具**:提供類型安全的樣式函數
645
+ 4. **多種導出方式**:支援不同項目需求
646
+
647
+ #### 樣式文件結構
648
+
649
+ ```
650
+ src/assets/styles/
651
+ ├── tailwind.scss # 主樣式入口
652
+ ├── _table.scss # 表格樣式
653
+ ├── _dialog.scss # 對話框樣式
654
+ └── element/
655
+ └── index.scss # Element Plus 主題自定義
656
+
657
+ src/utils/
658
+ └── tableStyles.ts # TypeScript 樣式工具
659
+ ```
660
+
661
+ #### 添加新樣式
662
+
663
+ 1. **SCSS 樣式**:在對應的 `_*.scss` 文件中添加
664
+ 2. **TypeScript 工具**:在 `tableStyles.ts` 中添加新的工具函數
665
+ 3. **導出配置**:在 `package.json` 的 `exports` 中添加新的導出路徑
666
+
494
667
  ## 許可證
495
668
 
496
669
  MIT License