plane/web/components/gantt-chart/blocks/blocks-list.tsx

66 lines
1.8 KiB
TypeScript
Raw Normal View History

import { FC } from "react";
// components
import { HEADER_HEIGHT } from "../constants";
2024-03-18 07:42:10 +00:00
import { ChartDataType, IBlockUpdateData, IGanttBlock } from "../types";
import { GanttChartBlock } from "./block";
// types
// constants
export type GanttChartBlocksProps = {
itemsContainerWidth: number;
2024-03-18 07:42:10 +00:00
blockIds: string[];
getBlockById: (id: string, currentViewData?: ChartDataType | undefined) => IGanttBlock;
blockToRender: (data: any) => React.ReactNode;
blockUpdateHandler: (block: any, payload: IBlockUpdateData) => void;
enableBlockLeftResize: boolean;
enableBlockRightResize: boolean;
enableBlockMove: boolean;
enableAddBlock: boolean;
ganttContainerRef: React.RefObject<HTMLDivElement>;
showAllBlocks: boolean;
};
export const GanttChartBlocksList: FC<GanttChartBlocksProps> = (props) => {
const {
itemsContainerWidth,
2024-03-18 07:42:10 +00:00
blockIds,
blockToRender,
blockUpdateHandler,
2024-03-18 07:42:10 +00:00
getBlockById,
enableBlockLeftResize,
enableBlockRightResize,
enableBlockMove,
enableAddBlock,
ganttContainerRef,
showAllBlocks,
} = props;
return (
<div
className="h-full"
style={{
width: `${itemsContainerWidth}px`,
2024-02-13 09:03:24 +00:00
transform: `translateY(${HEADER_HEIGHT}px)`,
}}
>
2024-03-18 07:42:10 +00:00
{blockIds?.map((blockId) => {
return (
<GanttChartBlock
2024-03-18 07:42:10 +00:00
key={blockId}
blockId={blockId}
getBlockById={getBlockById}
showAllBlocks={showAllBlocks}
blockToRender={blockToRender}
blockUpdateHandler={blockUpdateHandler}
enableBlockLeftResize={enableBlockLeftResize}
enableBlockRightResize={enableBlockRightResize}
enableBlockMove={enableBlockMove}
enableAddBlock={enableAddBlock}
ganttContainerRef={ganttContainerRef}
/>
);
})}
</div>
);
};