Skip to content

feat(projects): feat(projects): TableColumnCheck title support VNode #716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/hooks/src/use-table.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { computed, reactive, ref } from 'vue';
import type { Ref } from 'vue';
import type { Ref, VNodeChild } from 'vue';
import { jsonClone } from '@sa/utils';
import useBoolean from './use-boolean';
import useLoading from './use-loading';
Expand All @@ -8,9 +8,11 @@ export type MaybePromise<T> = T | Promise<T>;

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

export type TableColumnCheckTitle = string | ((...args: any) => VNodeChild);

export type TableColumnCheck = {
key: string;
title: string;
title: TableColumnCheckTitle;
checked: boolean;
};

Expand Down
5 changes: 4 additions & 1 deletion src/components/advanced/table-column-setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ const columns = defineModel<NaiveUI.TableColumnCheck[]>('columns', {
<div v-for="item in columns" :key="item.key" class="h-36px flex-y-center rd-4px hover:(bg-primary bg-opacity-20)">
<icon-mdi-drag class="mr-8px h-full cursor-move text-icon" />
<NCheckbox v-model:checked="item.checked" class="none_draggable flex-1">
{{ item.title }}
<template v-if="typeof item.title === 'function'">
<component :is="item.title" />
</template>
<template v-else>{{ item.title }}</template>
</NCheckbox>
</div>
</VueDraggable>
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/common/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
if (isTableColumnHasKey(column)) {
checks.push({
key: column.key as string,
title: column.title as string,
title: column.title!,
checked: true
});
} else if (column.type === 'selection') {
Expand Down