Skip to content

Commit

Permalink
feat(table): allow callback on cell property (#174) (#176)
Browse files Browse the repository at this point in the history
close #174

Co-authored-by: Kia Ishii <kia.king.08@gmail.com>
  • Loading branch information
brc-dd and kiaking committed Dec 15, 2022
1 parent 99be28e commit c3c631d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/components/STableCell.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
<script setup lang="ts">
import { computed } from 'vue'
import { TableCell } from '../composables/Table'
import STableCellAvatar from './STableCellAvatar.vue'
import STableCellAvatars from './STableCellAvatars.vue'
import STableCellDay from './STableCellDay.vue'
import STableCellPill from './STableCellPill.vue'
import STableCellText from './STableCellText.vue'
defineProps<{
const props = defineProps<{
name: string
className?: string
cell?: TableCell
cell?: TableCell | ((value: any, record: any) => TableCell)
value: any
record: any
records: Record<string, any>
}>()
const cell = computed(() =>
typeof props.cell === 'function'
? props.cell(props.value, props.record)
: props.cell
)
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion lib/composables/Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface TableColumn {
label: string
className?: string
dropdown?: DropdownSection[]
cell?: TableCell
cell?: TableCell | ((value: any, record: any) => TableCell)
}

export type TableCell =
Expand Down

0 comments on commit c3c631d

Please sign in to comment.