/* Copyright 2026 Marimo. All rights reserved. */ import React, { memo, useRef } from "react"; import type { AppConfig } from "@/core/config/config-schema"; import { useResizeHandle } from "@/hooks/useResizeHandle"; import type { CellColumnId } from "@/utils/id-tree"; import { SortableColumn } from "./sortable-column"; import { storageFn } from "./storage"; interface Props { className?: string; columnId: CellColumnId; index: number; children: React.ReactNode; width: AppConfig["width"]; footer?: React.ReactNode; canDelete: boolean; canMoveLeft: boolean; canMoveRight: boolean; } const { getColumnWidth, saveColumnWidth } = storageFn; export const Column = memo((props: Props) => { const columnRef = useRef(null); if (props.width === "columns") { return ( { saveColumnWidth(props.index, width); }} > {props.children} ); } return ( <>
{props.children}
{props.footer} ); }); Column.displayName = "Column"; interface ResizableComponentProps { startingWidth: number | "contentWidth"; onResize?: (width: number) => void; children: React.ReactNode; } const ResizableComponent = ({ startingWidth, onResize, children, }: ResizableComponentProps) => { const { resizableDivRef, handleRefs, style } = useResizeHandle({ startingWidth, onResize, }); const renderResizeHandler = (ref: React.RefObject) => { return (
); }; return (
{renderResizeHandler(handleRefs.left)}
{children}
{renderResizeHandler(handleRefs.right)}
); };