Skip to content

Commit a1a5c74

Browse files
authored
feat(projects): feat(projects): TableColumnCheck title support VNode (#716)
1 parent be6080b commit a1a5c74

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Diff for: packages/hooks/src/use-table.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { computed, reactive, ref } from 'vue';
2-
import type { Ref } from 'vue';
2+
import type { Ref, VNodeChild } from 'vue';
33
import { jsonClone } from '@sa/utils';
44
import useBoolean from './use-boolean';
55
import useLoading from './use-loading';
@@ -8,9 +8,11 @@ export type MaybePromise<T> = T | Promise<T>;
88

99
export type ApiFn = (args: any) => Promise<unknown>;
1010

11+
export type TableColumnCheckTitle = string | ((...args: any) => VNodeChild);
12+
1113
export type TableColumnCheck = {
1214
key: string;
13-
title: string;
15+
title: TableColumnCheckTitle;
1416
checked: boolean;
1517
};
1618

Diff for: src/components/advanced/table-column-setting.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ const columns = defineModel<NaiveUI.TableColumnCheck[]>('columns', {
2525
<div v-for="item in columns" :key="item.key" class="h-36px flex-y-center rd-4px hover:(bg-primary bg-opacity-20)">
2626
<icon-mdi-drag class="mr-8px h-full cursor-move text-icon" />
2727
<NCheckbox v-model:checked="item.checked" class="none_draggable flex-1">
28-
{{ item.title }}
28+
<template v-if="typeof item.title === 'function'">
29+
<component :is="item.title" />
30+
</template>
31+
<template v-else>{{ item.title }}</template>
2932
</NCheckbox>
3033
</div>
3134
</VueDraggable>

Diff for: src/hooks/common/table.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
6464
if (isTableColumnHasKey(column)) {
6565
checks.push({
6666
key: column.key as string,
67-
title: column.title as string,
67+
title: column.title!,
6868
checked: true
6969
});
7070
} else if (column.type === 'selection') {

0 commit comments

Comments
 (0)