import { Col, type ColProps, Row, type RowProps } from "antd";
import React from "react";

export interface ColumnsProps extends RowProps {
  /** 列数 */
  columns?: number;
}
export interface ColumnsProps extends ColProps {}

export const Columns = React.forwardRef<HTMLDivElement, ColumnsProps>(
  (props, ref) => {
    const { align, gutter, justify, wrap, columns = 1, ...rest } = props;
    return (
      <Row
        ref={ref}
        align={align}
        gutter={gutter}
        justify={justify}
        wrap={wrap}
      >
        {Array.from({ length: columns }, (_, i) => 0 + i).map((key) => (
          <Col key={key} {...rest} />
        ))}
      </Row>
    );
  }
);
