vue3-smart-table 1.0.2 → 1.0.3
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 +1209 -169
- package/dist/index.css +1 -0
- package/dist/vue3-smart-table.cjs.js +2 -21
- package/dist/vue3-smart-table.cjs.js.map +1 -0
- package/dist/vue3-smart-table.es.js +560 -397
- package/dist/vue3-smart-table.es.js.map +1 -0
- package/dist/vue3-smart-table.umd.js +3 -0
- package/dist/vue3-smart-table.umd.js.map +1 -0
- package/package.json +19 -6
- package/src/assets/vue.svg +1 -0
- package/src/components/SmartTable/column/index.vue +170 -0
- package/src/components/SmartTable/config.ts +124 -0
- package/src/components/SmartTable/hooks/useOperationColumn.ts +136 -0
- package/src/components/SmartTable/hooks/useTableColumns.ts +143 -0
- package/src/components/SmartTable/index.vue +99 -0
- package/src/components/SmartTable/renderer.ts +173 -0
- package/src/components/SmartTable/renderers/index.ts +307 -0
- package/src/components/SmartTable/renderers/input.vue +31 -0
- package/src/components/SmartTable/renderers/inputNumber.vue +33 -0
- package/src/components/SmartTable/renderers/select.vue +41 -0
- package/src/components/SmartTable/types.ts +229 -0
- package/src/components/SmartTable/utils/path.ts +29 -0
- package/src/index.ts +38 -0
- package/src/types/enhanced.ts +51 -0
- package/dist/vue3-smart-table.css +0 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 增强类型系统 - 提供更好的类型推断
|
|
3
|
+
*/
|
|
4
|
+
import type { ColumnConfig, RendererName } from '../components/SmartTable/types'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 提取行数据的类型
|
|
8
|
+
*/
|
|
9
|
+
export type ExtractRowType<T> = T extends ColumnConfig<infer R> ? R : never
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 根据列配置提取表格数据类型
|
|
13
|
+
*/
|
|
14
|
+
export type TableDataFromColumns<T extends ColumnConfig[]> = T extends (infer C)[]
|
|
15
|
+
? C extends ColumnConfig<infer R>
|
|
16
|
+
? R
|
|
17
|
+
: any
|
|
18
|
+
: any
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 渲染器 Props 类型推断
|
|
22
|
+
*/
|
|
23
|
+
export type InferRendererProps<T extends RendererName> =
|
|
24
|
+
T extends 'html'
|
|
25
|
+
? { style?: string; class?: string; [key: string]: any }
|
|
26
|
+
: T extends 'copy'
|
|
27
|
+
? { successText?: string; errorText?: string; iconColor?: string; [key: string]: any }
|
|
28
|
+
: T extends 'img'
|
|
29
|
+
? { width?: string | number; height?: string | number; fit?: string; previewSrcList?: string[]; [key: string]: any }
|
|
30
|
+
: T extends 'dict'
|
|
31
|
+
? { options: Array<{ label: string; value: string | number; listClass?: string; cssClass?: string }>; showValue?: boolean }
|
|
32
|
+
: T extends 'map'
|
|
33
|
+
? { options: Record<string | number, any> }
|
|
34
|
+
: T extends 'input'
|
|
35
|
+
? { placeholder?: string; size?: 'small' | 'default' | 'large'; clearable?: boolean }
|
|
36
|
+
: T extends 'select'
|
|
37
|
+
? { options: Array<{ label: string; value: string | number }>; placeholder?: string; clearable?: boolean }
|
|
38
|
+
: { [key: string]: any }
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 快捷创建列的辅助函数(类型安全简化版)
|
|
42
|
+
*/
|
|
43
|
+
export function defineColumn(
|
|
44
|
+
key: string,
|
|
45
|
+
config?: Partial<Omit<ColumnConfig, 'key'>>
|
|
46
|
+
): ColumnConfig {
|
|
47
|
+
return {
|
|
48
|
+
key,
|
|
49
|
+
...config
|
|
50
|
+
} as ColumnConfig
|
|
51
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.copy-wrapper:hover .copy-btn{display:inline-block!important}.smart-table[data-v-338b77db]{width:100%}
|