import { Flex, Skeleton } from 'antd'
import PropTypes from 'prop-types'
import { HolderOutlined, LoadingOutlined } from '@ant-design/icons'
import ObjectProperty from './ObjectProperty'
import { KANBAN_DEFAULT_COLUMN_WIDTH } from './viewModeUtils'
const ObjectKanbanHeader = ({
columns = [],
categoryProperty,
categoryPropertyDef,
trackRef,
skeletonColumnCount = 0,
lazyLoading = false,
loadingColumnKeys = [],
draggedKey = null,
dropTargetKey = null,
onColumnDragStart,
onColumnDragOver,
onColumnDrop,
onColumnDragEnd
}) => {
const showSkeleton = skeletonColumnCount > 0
const loadingColumnKeySet = new Set(loadingColumnKeys)
return (
{showSkeleton
? Array.from({ length: skeletonColumnCount }).map((_, index) => (
))
: columns.map(({ key: columnKey, value: categoryValue, width }) => {
const showColumnLoading =
lazyLoading || loadingColumnKeySet.has(columnKey)
const isDragging = draggedKey === columnKey
const isDropTarget =
dropTargetKey === columnKey && draggedKey !== columnKey
return (
onColumnDragOver?.(event, columnKey)
}
onDrop={(event) => onColumnDrop?.(event, columnKey)}
>
{categoryPropertyDef ? (
) : null}
{showColumnLoading && (
)}
event.stopPropagation()}
onMouseDown={(event) => event.stopPropagation()}
onDragStart={(event) =>
onColumnDragStart?.(event, columnKey)
}
onDragEnd={onColumnDragEnd}
>
)
})}
)
}
ObjectKanbanHeader.displayName = 'ObjectKanbanHeader'
ObjectKanbanHeader.propTypes = {
columns: PropTypes.arrayOf(
PropTypes.shape({
key: PropTypes.string.isRequired,
value: PropTypes.any,
width: PropTypes.number.isRequired
})
),
categoryProperty: PropTypes.string.isRequired,
categoryPropertyDef: PropTypes.object,
trackRef: PropTypes.object,
skeletonColumnCount: PropTypes.number,
lazyLoading: PropTypes.bool,
loadingColumnKeys: PropTypes.arrayOf(PropTypes.string),
draggedKey: PropTypes.string,
dropTargetKey: PropTypes.string,
onColumnDragStart: PropTypes.func,
onColumnDragOver: PropTypes.func,
onColumnDrop: PropTypes.func,
onColumnDragEnd: PropTypes.func
}
export default ObjectKanbanHeader