import React, { useCallback } from 'react';
import { Box, Text } from '@wix/design-system';
import { getFieldTypeIcon } from '../utils/fieldTypePrefixIcons';
export function useCreateWSRColumnBase({ horizontalScroll, showFieldTypeIcons, }) {
    return useCallback((column, index, length) => {
        const { id, title, width, sortable, infoTooltipProps, fieldType } = column;
        const lastColumn = index === length - 1;
        const lastColumnStyleNoHorizontalScroll = width != null
            ? {
                flexBasis: width,
                flexGrow: 1,
            }
            : {
                flex: 1,
            };
        const lastColumnStyle = horizontalScroll
            ? {
                flexBasis: width ?? 0,
                flexShrink: 0,
                flexGrow: 1,
            }
            : lastColumnStyleNoHorizontalScroll;
        const columnStyle = width == null ? { flex: 1 } : undefined;
        const style = lastColumn ? lastColumnStyle : columnStyle;
        const renderedTitle = title && showFieldTypeIcons ? (React.createElement(Box, { gap: "SP1", verticalAlign: "middle", minWidth: 0 },
            React.createElement(Box, { flexShrink: 0 }, getFieldTypeIcon({ fieldType })),
            typeof title === 'string' ? (React.createElement(Text, { size: "small", ellipsis: true, appendTo: "window" }, title)) : (title))) : (title);
        return {
            id,
            key: id ?? index,
            title: renderedTitle,
            style,
            width: lastColumn && !horizontalScroll ? undefined : width,
            sortable: id && sortable ? true : undefined,
            infoTooltipProps: infoTooltipProps?.content
                ? infoTooltipProps
                : undefined,
        };
    }, [horizontalScroll, showFieldTypeIcons]);
}
//# sourceMappingURL=useCreateWSRColumnBase.js.map