import { type CSSProperties, type ReactNode } from 'react'; import { type SColor } from '../../lib/color'; import { type SIconName } from '../SIcon'; import { type SSelectOption } from '../SSelect'; export type SRow = Record; /** `STableColumn.renderCell`에 전달되는 컨텍스트 */ export interface STableCellContext { row: SRow; /** `field` + `format`이 적용된 표시 값 */ value: any; column: STableColumn; /** 보이는 컬럼 기준 인덱스 */ colIndex: number; /** 현재 렌더 중인 행 목록 기준 인덱스 (페이지/가상 스크롤 윈도우 기준) */ rowIndex: number; /** 행 선택 여부 */ isSelected: boolean; /** STable이 이 셀에 적용하려던 클래스 (구분선·말줄임·sticky 그림자 포함) */ className: string; /** STable이 이 셀에 적용하려던 스타일 (패딩·정렬·폭·sticky offset 포함) */ style: CSSProperties; } export interface STableColumn { name: string; label: string; /** 값 접근: 필드명 또는 접근 함수 */ field: string | ((row: SRow) => any); align?: 'left' | 'center' | 'right'; width?: string; /** 고정폭 없이 자동 너비 (sticky/resize 계산에서 제외) */ autoWidth?: boolean; /** 리사이즈 최소/최대 너비 (px) */ minWidth?: number; maxWidth?: number; /** 표시 포맷 */ format?: (value: any, row: SRow) => string; visible?: boolean; icon?: SIconName; /** 헤더 아이콘 색상. 팔레트 키(`grey_65`, `red_95` …) 또는 임의 CSS 색상 */ iconColor?: SColor; /** 셀 커스텀 렌더 (React 확장) — `` 안쪽 내용만 교체한다 */ render?: (row: SRow, value: any) => ReactNode; /** * 셀(``) 자체를 커스텀 렌더 (React 확장). 반환한 엘리먼트가 그대로 ``가 되므로 * `colSpan` / `rowSpan`을 직접 지정할 수 있다. `render`보다 우선한다. * * - `ctx.className` / `ctx.style`을 그대로 펼쳐야 구분선·정렬·sticky 등 기본 스타일이 유지된다. * - `null`(또는 `false`)을 반환하면 그 자리에는 ``를 만들지 않는다. * 다른 셀의 `colSpan` / `rowSpan`에 덮이는 자리를 이렇게 비운다. * - 병합은 sticky 컬럼(인덱스 기준 offset 계산)과 함께 쓰지 않는 것을 전제로 한다. * `rowSpan`은 행을 잘라 쓰는 가상 스크롤 / 내부 페이지네이션과 경계에서 어긋날 수 있다. */ renderCell?: (ctx: STableCellContext) => ReactNode; /** 헤더 셀 커스텀 렌더 (React 확장) */ renderHeader?: (column: STableColumn, index: number) => ReactNode; /** 본문 셀 커스텀 클래스. 함수를 주면 행마다 다른 클래스를 반환할 수 있다 */ tdClass?: string | ((row: SRow) => string | undefined); /** 헤더 셀 커스텀 클래스/스타일 (sd-table thClass/thStyle) */ thClass?: string; thStyle?: CSSProperties; } export interface STablePagination { page: number; rowsPerPage: number; lastPage?: number; } export interface STableStickyColumn { left?: number; right?: number; } /** STable ref 명령형 API (sd-table @Method 대응) */ export interface STableHandle { /** 행 선택 여부 */ isRowSelected: (row: SRow) => boolean; /** 주어진 행들의 전체 선택 상태 (true/false/null=indeterminate) */ getIsAllChecked: (rows: SRow[]) => boolean | null; /** 내부 페이지네이션 정보 (useInternalPagination 아니면 null) */ getPaginationInfo: () => { startIndex: number; endIndex: number; currentPage: number; rowsPerPage: number; } | null; /** 컬럼 sticky 스타일 (CSS 변수 + 고정폭) */ getStickyStyle: (colIdx: number) => CSSProperties; /** 가상 스크롤 총 행 수 설정 */ setRowCount: (count: number) => void; /** 단일 행 선택 토글 (sd-table updateRowSelect) — onSelectedChange 발생 */ updateRowSelect: (row: SRow) => void; /** 주어진 행들 전체 선택/해제 (sd-table toggleSelectAll) — onSelectedChange 발생 */ toggleSelectAll: (checked: boolean, rows: SRow[]) => void; } export interface STableProps { columns?: STableColumn[]; rows?: SRow[]; /** 행 식별 필드 */ rowKey?: string; /** 행 선택 체크박스 */ selectable?: boolean; selected?: SRow[]; onSelectedChange?: (rows: SRow[]) => void; /** 컬럼 너비 조절 */ resizable?: boolean; width?: string; height?: string; /** @deprecated 헤더는 항상 세로 스크롤에서 제외되어 고정됩니다 (body만 세로 스크롤) */ stickyHeader?: boolean; /** 고정할 좌/우 컬럼 수 */ stickyColumn?: STableStickyColumn; /** border-radius 제어 */ radius?: 'default' | 'useTop' | 'full'; noDataLabel?: string; /** * 데이터가 없을 때 body 영역 전체를 대체하는 슬롯. * 지정하면 `noDataLabel` 대신 이 콘텐츠가 헤더 아래 영역을 채우며, 버튼 등 인터랙션도 동작한다. */ noDataSlot?: ReactNode; isLoading?: boolean; dense?: boolean; /** true면 행에 마우스를 올려도 hover 배경(grey_05)을 표시하지 않는다 */ noHover?: boolean; /** 페이지네이션 (있으면 하단 표시) */ pagination?: STablePagination; onPageChange?: (page: number) => void; /** 테이블 내부에서 페이지네이션을 직접 관리 (rows를 내부 슬라이싱) */ useInternalPagination?: boolean; /** 페이지당 행 수 셀렉트 표시 */ useRowsPerPageSelect?: boolean; rowsPerPageOption?: SSelectOption[]; onRowsPerPageChange?: (perPage: number) => void; /** 가상 스크롤 */ useVirtualScroll?: boolean; rowHeight?: number; virtualBuffer?: number; virtualEndThreshold?: number; onVirtualUpdate?: (range: { from: number; to: number; }) => void; onVirtualReachEnd?: (info: { from: number; to: number; rowCount: number; threshold: number; }) => void; /** 테이블 식별자 (없으면 자동 생성) */ tableId?: string; /** 행 클릭 */ onRowClick?: (row: SRow) => void; className?: string; style?: CSSProperties; } /** * STable — sd-table 포팅. 컬럼/행 + 선택 + sticky 헤더/컬럼 + 리사이즈 + * 내부 페이지네이션 + rows-per-page + 가상 스크롤 + 로딩 + dense. */ export declare const STable: import("react").ForwardRefExoticComponent>;