29 lines
604 B
TypeScript
29 lines
604 B
TypeScript
import { computed } from 'vue'
|
|
import type { BaseNodeProps, StandardNodeOptions } from './types'
|
|
|
|
export function useStandardNode<TData>(
|
|
props: BaseNodeProps<TData>,
|
|
options: StandardNodeOptions<TData>
|
|
) {
|
|
const bodyItems = computed(() => {
|
|
return options.body ? options.body(props) : []
|
|
})
|
|
|
|
const badge = computed(() => {
|
|
if (typeof options.badge === 'function') {
|
|
return options.badge(props)
|
|
}
|
|
return options.badge
|
|
})
|
|
|
|
const status = computed(() => options.status?.(props))
|
|
|
|
return {
|
|
props,
|
|
definition: options,
|
|
bodyItems,
|
|
badge,
|
|
status
|
|
}
|
|
}
|