Files
Gildas Garcia b30db91d71 chore: cleanup UI patterns exports (#47406)
## Problem

We now export components under a subpath in ui-patterns to avoid barrel
files as they slow down every tools (from IDE to linters, etc.) and may
also affect bundles our users have to download.

## Solution

- Remove the UI patterns index file
- Fix invalid impors
2026-06-30 09:23:17 +02:00

48 lines
1.4 KiB
TypeScript

import { useIntersectionObserver } from '@uidotdev/usehooks'
import { useEffect, type ReactNode } from 'react'
import { TableCell, TableRow } from 'ui'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import type { BucketsTablePaginationProps } from './BucketsTable.types'
import { VirtualizedTableCell, VirtualizedTableRow } from '@/components/ui/VirtualizedTable'
type LoadMoreRowProps = {
mode: 'standard' | 'virtualized'
colSpan: number
} & BucketsTablePaginationProps
export const LoadMoreRow = ({
mode,
colSpan,
hasMore = false,
isLoadingMore = false,
onLoadMore,
}: LoadMoreRowProps): ReactNode => {
const [sentinelRef, entry] = useIntersectionObserver({
threshold: 0,
rootMargin: '200px 0px 200px 0px',
})
useEffect(() => {
if (entry?.isIntersecting && hasMore && !isLoadingMore) {
onLoadMore?.()
}
}, [entry?.isIntersecting, hasMore, isLoadingMore, onLoadMore])
if (!hasMore && !isLoadingMore) return null
const RowComponent = mode === 'standard' ? TableRow : VirtualizedTableRow
const CellComponent = mode === 'standard' ? TableCell : VirtualizedTableCell
return (
<RowComponent ref={sentinelRef}>
{Array.from({ length: colSpan }, (_, idx) => (
<CellComponent key={idx}>
{idx !== 0 && idx !== colSpan - 1 && <ShimmeringLoader className="w-3/4" />}
</CellComponent>
))}
</RowComponent>
)
}