init
This commit is contained in:
28
frontend/src/components/nodes/shared/useStandardNode.ts
Normal file
28
frontend/src/components/nodes/shared/useStandardNode.ts
Normal file
@ -0,0 +1,28 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user