Skip to content

Commit 93f7837

Browse files
authored
feat: enhance TSTable component with new slot type definitions and improve TypeScript configuration (#3)
1 parent 92db98b commit 93f7837

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

packages/core/src/components/TSTable.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import type { ColumnDef, RowData, Table } from '@tanstack/vue-table'
3+
import type { CellSlotProps, FooterSlotProps, HeaderSlotProps } from '../shared/types'
34
45
export interface TSTableProps<TData extends RowData & object> {
56
columns: ColumnDef<TData>[]
@@ -42,9 +43,9 @@ defineSlots<{
4243
table: Table<TData>;
4344
}) => any;
4445
45-
[key: `header-${string}`]: (props: any) => any;
46-
[key: `cell-${string}`]: (props: any) => any;
47-
[key: `footer-${string}`]: (props: any) => any;
46+
[key: `header-${string}`]: (props: HeaderSlotProps<TData>) => any;
47+
[key: `cell-${string}`]: (props: CellSlotProps<TData>) => any;
48+
[key: `footer-${string}`]: (props: FooterSlotProps<TData>) => any;
4849
}>()
4950
</script>
5051

packages/core/src/shared/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './utils'
2+
export * from './types'

packages/core/src/shared/types.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { CellContext, Column, HeaderContext, Row, RowData } from '@tanstack/vue-table'
2+
3+
export interface HeaderSlotProps<TData extends RowData> {
4+
column: Column<TData>
5+
context: HeaderContext<TData, unknown>
6+
}
7+
8+
export interface CellSlotProps<TData extends RowData> {
9+
row: Row<TData>
10+
context: CellContext<TData, unknown>
11+
value: any
12+
}
13+
14+
export interface FooterSlotProps<TData extends RowData> {
15+
column: Column<TData>
16+
context: HeaderContext<TData, unknown>
17+
}

packages/core/tsconfig.app.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
"extends": "@vue/tsconfig/tsconfig.dom.json",
33
"compilerOptions": {
44
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5-
65
/* Linting */
76
"strict": true,
87
"noUnusedLocals": true,
98
"noUnusedParameters": true,
109
"noFallthroughCasesInSwitch": true,
11-
"noUncheckedSideEffectImports": true
10+
"noUncheckedSideEffectImports": true,
11+
"esModuleInterop": true,
1212
},
13-
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
14-
}
13+
"include": [
14+
"src/**/*.ts",
15+
"src/**/*.tsx",
16+
"src/**/*.vue"
17+
]
18+
}

0 commit comments

Comments
 (0)