| 1 | import { cva } from "class-variance-authority"; |
| 2 | import { PlateElement, type PlateElementProps } from "platejs/react"; |
| 3 | |
| 4 | import { cn } from "@/lib/utils"; |
| 5 | import { type TArrowListElement } from "../plugins/arrow-plugin"; |
| 6 | |
| 7 | export const arrowItemVariants = cva("my-4 mb-8 grid w-full overflow-visible", { |
| 8 | variants: { |
| 9 | orientation: { |
| 10 | vertical: "", |
| 11 | horizontal: "grid w-full grid-flow-col overflow-visible", |
| 12 | }, |
| 13 | }, |
| 14 | }); |
| 15 | |
| 16 | export default function ArrowList(props: PlateElementProps<TArrowListElement>) { |
| 17 | const { element } = props; |
| 18 | const { orientation, alignment = "center" } = element; |
| 19 | |
| 20 | return ( |
| 21 | <PlateElement {...props} className="relative"> |
| 22 | {/* Container for alignment control */} |
| 23 | <div |
| 24 | className={cn( |
| 25 | "flex w-full", |
| 26 | // Apply alignment to the container, not the arrow list structure |
| 27 | alignment === "left" && "justify-start", |
| 28 | alignment === "right" && "justify-end", |
| 29 | alignment === "center" && "justify-center", |
| 30 | )} |
| 31 | > |
| 32 | {/* Arrow list structure - always full width */} |
| 33 | <div |
| 34 | className={cn( |
| 35 | arrowItemVariants({ |
| 36 | orientation: orientation, |
| 37 | }), |
| 38 | "w-full", // Ensure full width |
| 39 | )} |
| 40 | > |
| 41 | {props.children} |
| 42 | </div> |
| 43 | </div> |
| 44 | </PlateElement> |
| 45 | ); |
| 46 | } |
| 47 |