tanstack-table-vue 0.0.6 → 0.0.7
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 +92 -0
- package/dist/components/TSTable.cjs.map +1 -1
- package/dist/components/TSTable.js.map +1 -1
- package/dist/index.d.ts +26 -6
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# @tanstack-table-vue/core
|
|
2
|
+
|
|
3
|
+
Core package for TanStack Table Vue integration.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package contains the core functionality for integrating TanStack Table with Vue.js. It provides:
|
|
8
|
+
|
|
9
|
+
- TSTable component for rendering tables
|
|
10
|
+
- Column processing utilities
|
|
11
|
+
- Type definitions and helpers
|
|
12
|
+
- Slot management system
|
|
13
|
+
|
|
14
|
+
## Components
|
|
15
|
+
|
|
16
|
+
### TSTable
|
|
17
|
+
|
|
18
|
+
The main component that renders the table structure. It accepts:
|
|
19
|
+
|
|
20
|
+
- `columns`: Column definitions
|
|
21
|
+
- `data`: Table data
|
|
22
|
+
- `tableOptions`: TanStack Table options
|
|
23
|
+
|
|
24
|
+
```vue
|
|
25
|
+
<TSTable :columns="columns" :data="data" :tableOptions="tableOptions">
|
|
26
|
+
<!-- Slots for customization -->
|
|
27
|
+
</TSTable>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Utilities
|
|
31
|
+
|
|
32
|
+
### Column Processing
|
|
33
|
+
|
|
34
|
+
The package includes utilities for processing columns and managing slots:
|
|
35
|
+
|
|
36
|
+
- `processColumns`: Converts column definitions to TanStack Table format
|
|
37
|
+
- `getHeader`, `getCell`, `getFooter`: Slot management functions
|
|
38
|
+
|
|
39
|
+
### Types
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
interface TSTableProps<TData extends RowData & object> {
|
|
43
|
+
columns: ColumnDef<TData>[]
|
|
44
|
+
data: TData[]
|
|
45
|
+
tableOptions?: Record<string, any>
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Usage with Slots
|
|
50
|
+
|
|
51
|
+
The package provides a flexible slot system:
|
|
52
|
+
|
|
53
|
+
```vue
|
|
54
|
+
<TSTable :columns="columns" :data="data">
|
|
55
|
+
<!-- Header slot -->
|
|
56
|
+
<template #header-columnId="{ column }">
|
|
57
|
+
Custom Header
|
|
58
|
+
</template>
|
|
59
|
+
|
|
60
|
+
<!-- Cell slot -->
|
|
61
|
+
<template #cell-columnId="{ value, row }">
|
|
62
|
+
Custom Cell
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<!-- Footer slot -->
|
|
66
|
+
<template #footer-columnId="{ column }">
|
|
67
|
+
Custom Footer
|
|
68
|
+
</template>
|
|
69
|
+
</TSTable>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Internal Architecture
|
|
73
|
+
|
|
74
|
+
The package uses a slot-based system instead of render functions, making it more Vue-idiomatic. Key features:
|
|
75
|
+
|
|
76
|
+
- Automatic header generation from accessorKey
|
|
77
|
+
- Flexible slot naming based on column IDs
|
|
78
|
+
- Support for nested column groups
|
|
79
|
+
- Integration with TanStack Table's sorting, filtering, and other features
|
|
80
|
+
|
|
81
|
+
## Contributing
|
|
82
|
+
|
|
83
|
+
When contributing to this package, please:
|
|
84
|
+
|
|
85
|
+
1. Maintain type safety
|
|
86
|
+
2. Follow Vue.js best practices
|
|
87
|
+
3. Update tests for any new functionality
|
|
88
|
+
4. Document any public APIs
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TSTable.cjs","sources":["../../src/components/TSTable.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ColumnDef, RowData, Table } from '@tanstack/vue-table'\n\nexport interface TSTableProps<TData extends RowData & object> {\n columns: ColumnDef<TData>[]\n data: TData[]\n tableOptions?: Record<string, any>\n}\n</script>\n\n<script setup lang=\"ts\" generic=\"TData extends RowData & object\">\nimport { computed, useSlots } from 'vue'\nimport { useVueTable, createColumnHelper, type ColumnDef as TStackColumnDef, getCoreRowModel } from '@tanstack/vue-table'\nimport { processColumns } from '../shared'\n\nconst props = defineProps<TSTableProps<TData>>()\n\nconst slots = useSlots()\nconst columnHelper = createColumnHelper<TData>()\n\nconst processedColumns = computed(() => {\n const initialTable = useVueTable<TData>({\n columns: props.columns as unknown as TStackColumnDef<TData>[],\n data: props.data,\n getCoreRowModel: getCoreRowModel(),\n ...props.tableOptions\n })\n return processColumns(columnHelper, props.columns, slots, initialTable)\n})\n\nconst tableOptions = {\n columns: processedColumns.value,\n data: props.data,\n getCoreRowModel: getCoreRowModel(),\n ...props.tableOptions\n}\n\nconst table = useVueTable<TData>(tableOptions)\n\ndefineSlots<{\n default: (props: {\n table: Table<TData>;\n }) => any;\n\n [key: `header-${string}`]: (props:
|
|
1
|
+
{"version":3,"file":"TSTable.cjs","sources":["../../src/components/TSTable.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ColumnDef, RowData, Table } from '@tanstack/vue-table'\nimport type { CellSlotProps, FooterSlotProps, HeaderSlotProps } from '../shared/types'\n\nexport interface TSTableProps<TData extends RowData & object> {\n columns: ColumnDef<TData>[]\n data: TData[]\n tableOptions?: Record<string, any>\n}\n</script>\n\n<script setup lang=\"ts\" generic=\"TData extends RowData & object\">\nimport { computed, useSlots } from 'vue'\nimport { useVueTable, createColumnHelper, type ColumnDef as TStackColumnDef, getCoreRowModel } from '@tanstack/vue-table'\nimport { processColumns } from '../shared'\n\nconst props = defineProps<TSTableProps<TData>>()\n\nconst slots = useSlots()\nconst columnHelper = createColumnHelper<TData>()\n\nconst processedColumns = computed(() => {\n const initialTable = useVueTable<TData>({\n columns: props.columns as unknown as TStackColumnDef<TData>[],\n data: props.data,\n getCoreRowModel: getCoreRowModel(),\n ...props.tableOptions\n })\n return processColumns(columnHelper, props.columns, slots, initialTable)\n})\n\nconst tableOptions = {\n columns: processedColumns.value,\n data: props.data,\n getCoreRowModel: getCoreRowModel(),\n ...props.tableOptions\n}\n\nconst table = useVueTable<TData>(tableOptions)\n\ndefineSlots<{\n default: (props: {\n table: Table<TData>;\n }) => any;\n\n [key: `header-${string}`]: (props: HeaderSlotProps<TData>) => any;\n [key: `cell-${string}`]: (props: CellSlotProps<TData>) => any;\n [key: `footer-${string}`]: (props: FooterSlotProps<TData>) => any;\n}>()\n</script>\n\n<template>\n <slot :table=\"table\" />\n</template>"],"names":["useSlots","createColumnHelper","computed","useVueTable","getCoreRowModel","processColumns"],"mappings":";;;;;;;;;;;;;;;AAgBA,IAAA,MAAM,KAAQ,GAAA,OAAA;AAEd,IAAA,MAAM,QAAQA,YAAS,EAAA;AACvB,IAAA,MAAM,eAAeC,2BAA0B,EAAA;AAE/C,IAAM,MAAA,gBAAA,GAAmBC,aAAS,MAAM;AACtC,MAAqBC,oBAAmB,CAAA;AAAA,QACtC,SAAS,KAAM,CAAA,OAAA;AAAA,QACf,MAAM,KAAM,CAAA,IAAA;AAAA,QACZ,iBAAiBC,wBAAgB,EAAA;AAAA,QACjC,GAAG,KAAM,CAAA;AAAA,OACV;AACD,MAAA,OAAOC,2BAAe,CAAA,YAAA,EAAc,KAAM,CAAA,OAAA,EAAS,KAAmB,CAAA;AAAA,KACvE,CAAA;AAED,IAAA,MAAM,YAAe,GAAA;AAAA,MACnB,SAAS,gBAAiB,CAAA,KAAA;AAAA,MAC1B,MAAM,KAAM,CAAA,IAAA;AAAA,MACZ,iBAAiBD,wBAAgB,EAAA;AAAA,MACjC,GAAG,KAAM,CAAA;AAAA,KACX;AAEA,IAAM,MAAA,KAAA,GAAQD,qBAAmB,YAAY,CAAA;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TSTable.js","sources":["../../src/components/TSTable.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ColumnDef, RowData, Table } from '@tanstack/vue-table'\n\nexport interface TSTableProps<TData extends RowData & object> {\n columns: ColumnDef<TData>[]\n data: TData[]\n tableOptions?: Record<string, any>\n}\n</script>\n\n<script setup lang=\"ts\" generic=\"TData extends RowData & object\">\nimport { computed, useSlots } from 'vue'\nimport { useVueTable, createColumnHelper, type ColumnDef as TStackColumnDef, getCoreRowModel } from '@tanstack/vue-table'\nimport { processColumns } from '../shared'\n\nconst props = defineProps<TSTableProps<TData>>()\n\nconst slots = useSlots()\nconst columnHelper = createColumnHelper<TData>()\n\nconst processedColumns = computed(() => {\n const initialTable = useVueTable<TData>({\n columns: props.columns as unknown as TStackColumnDef<TData>[],\n data: props.data,\n getCoreRowModel: getCoreRowModel(),\n ...props.tableOptions\n })\n return processColumns(columnHelper, props.columns, slots, initialTable)\n})\n\nconst tableOptions = {\n columns: processedColumns.value,\n data: props.data,\n getCoreRowModel: getCoreRowModel(),\n ...props.tableOptions\n}\n\nconst table = useVueTable<TData>(tableOptions)\n\ndefineSlots<{\n default: (props: {\n table: Table<TData>;\n }) => any;\n\n [key: `header-${string}`]: (props:
|
|
1
|
+
{"version":3,"file":"TSTable.js","sources":["../../src/components/TSTable.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ColumnDef, RowData, Table } from '@tanstack/vue-table'\nimport type { CellSlotProps, FooterSlotProps, HeaderSlotProps } from '../shared/types'\n\nexport interface TSTableProps<TData extends RowData & object> {\n columns: ColumnDef<TData>[]\n data: TData[]\n tableOptions?: Record<string, any>\n}\n</script>\n\n<script setup lang=\"ts\" generic=\"TData extends RowData & object\">\nimport { computed, useSlots } from 'vue'\nimport { useVueTable, createColumnHelper, type ColumnDef as TStackColumnDef, getCoreRowModel } from '@tanstack/vue-table'\nimport { processColumns } from '../shared'\n\nconst props = defineProps<TSTableProps<TData>>()\n\nconst slots = useSlots()\nconst columnHelper = createColumnHelper<TData>()\n\nconst processedColumns = computed(() => {\n const initialTable = useVueTable<TData>({\n columns: props.columns as unknown as TStackColumnDef<TData>[],\n data: props.data,\n getCoreRowModel: getCoreRowModel(),\n ...props.tableOptions\n })\n return processColumns(columnHelper, props.columns, slots, initialTable)\n})\n\nconst tableOptions = {\n columns: processedColumns.value,\n data: props.data,\n getCoreRowModel: getCoreRowModel(),\n ...props.tableOptions\n}\n\nconst table = useVueTable<TData>(tableOptions)\n\ndefineSlots<{\n default: (props: {\n table: Table<TData>;\n }) => any;\n\n [key: `header-${string}`]: (props: HeaderSlotProps<TData>) => any;\n [key: `cell-${string}`]: (props: CellSlotProps<TData>) => any;\n [key: `footer-${string}`]: (props: FooterSlotProps<TData>) => any;\n}>()\n</script>\n\n<template>\n <slot :table=\"table\" />\n</template>"],"names":[],"mappings":";;;;;;;;;;;;;AAgBA,IAAA,MAAM,KAAQ,GAAA,OAAA;AAEd,IAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,IAAA,MAAM,eAAe,kBAA0B,EAAA;AAE/C,IAAM,MAAA,gBAAA,GAAmB,SAAS,MAAM;AACtC,MAAqB,WAAmB,CAAA;AAAA,QACtC,SAAS,KAAM,CAAA,OAAA;AAAA,QACf,MAAM,KAAM,CAAA,IAAA;AAAA,QACZ,iBAAiB,eAAgB,EAAA;AAAA,QACjC,GAAG,KAAM,CAAA;AAAA,OACV;AACD,MAAA,OAAO,cAAe,CAAA,YAAA,EAAc,KAAM,CAAA,OAAA,EAAS,KAAmB,CAAA;AAAA,KACvE,CAAA;AAED,IAAA,MAAM,YAAe,GAAA;AAAA,MACnB,SAAS,gBAAiB,CAAA,KAAA;AAAA,MAC1B,MAAM,KAAM,CAAA,IAAA;AAAA,MACZ,iBAAiB,eAAgB,EAAA;AAAA,MACjC,GAAG,KAAM,CAAA;AAAA,KACX;AAEA,IAAM,MAAA,KAAA,GAAQ,YAAmB,YAAY,CAAA;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { AllowedComponentProps } from 'vue';
|
|
2
|
+
import { CellContext } from '@tanstack/vue-table';
|
|
3
|
+
import { Column } from '@tanstack/vue-table';
|
|
2
4
|
import { ColumnDef } from '@tanstack/vue-table';
|
|
3
5
|
import { ColumnHelper } from '@tanstack/vue-table';
|
|
4
6
|
import { ComponentCustomProps } from 'vue';
|
|
7
|
+
import { HeaderContext } from '@tanstack/vue-table';
|
|
5
8
|
import { PublicProps } from 'vue';
|
|
9
|
+
import { Row } from '@tanstack/vue-table';
|
|
6
10
|
import { RowData } from '@tanstack/vue-table';
|
|
7
11
|
import { ShallowUnwrapRef } from 'vue';
|
|
8
12
|
import { Slots } from 'vue';
|
|
@@ -14,6 +18,22 @@ declare type __VLS_PrettifyLocal<T> = {
|
|
|
14
18
|
[K in keyof T]: T[K];
|
|
15
19
|
} & {};
|
|
16
20
|
|
|
21
|
+
export declare interface CellSlotProps<TData extends RowData> {
|
|
22
|
+
row: Row<TData>;
|
|
23
|
+
context: CellContext<TData, unknown>;
|
|
24
|
+
value: any;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare interface FooterSlotProps<TData extends RowData> {
|
|
28
|
+
column: Column<TData>;
|
|
29
|
+
context: HeaderContext<TData, unknown>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export declare interface HeaderSlotProps<TData extends RowData> {
|
|
33
|
+
column: Column<TData>;
|
|
34
|
+
context: HeaderContext<TData, unknown>;
|
|
35
|
+
}
|
|
36
|
+
|
|
17
37
|
export declare const processColumns: <TData extends RowData & object>(columnHelper: ColumnHelper<TData>, columns: ColumnDef<TData>[], slots: Readonly<Slots>, table: Table<TData>) => ColumnDef<TData>[];
|
|
18
38
|
|
|
19
39
|
export declare const TSTable: <TData extends RowData & object>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
@@ -21,16 +41,16 @@ export declare const TSTable: <TData extends RowData & object>(__VLS_props: NonN
|
|
|
21
41
|
expose(exposed: ShallowUnwrapRef< {}>): void;
|
|
22
42
|
attrs: any;
|
|
23
43
|
slots: Readonly<{
|
|
24
|
-
[key: `header-${string}`]: (props:
|
|
25
|
-
[key: `cell-${string}`]: (props:
|
|
26
|
-
[key: `footer-${string}`]: (props:
|
|
44
|
+
[key: `header-${string}`]: (props: HeaderSlotProps<TData>) => any;
|
|
45
|
+
[key: `cell-${string}`]: (props: CellSlotProps<TData>) => any;
|
|
46
|
+
[key: `footer-${string}`]: (props: FooterSlotProps<TData>) => any;
|
|
27
47
|
default: (props: {
|
|
28
48
|
table: Table<TData>;
|
|
29
49
|
}) => any;
|
|
30
50
|
}> & {
|
|
31
|
-
[key: `header-${string}`]: (props:
|
|
32
|
-
[key: `cell-${string}`]: (props:
|
|
33
|
-
[key: `footer-${string}`]: (props:
|
|
51
|
+
[key: `header-${string}`]: (props: HeaderSlotProps<TData>) => any;
|
|
52
|
+
[key: `cell-${string}`]: (props: CellSlotProps<TData>) => any;
|
|
53
|
+
[key: `footer-${string}`]: (props: FooterSlotProps<TData>) => any;
|
|
34
54
|
default: (props: {
|
|
35
55
|
table: Table<TData>;
|
|
36
56
|
}) => any;
|