본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

@atlaskit/table-tree — 테이블 트리

원문 보기 위키 갱신

중첩된 정보 계층을 보여주기 위한 확장 가능한 테이블 컴포넌트예요. 계층적 데이터를 트리 구조로 표시할 때 사용해요.

출처: 문서

본문

Cell component

테이블 트리 행의 단일 셀이에요. 열 데이터를 표시하려면 Row 안에서 사용해요.

  • 키워드: table-tree, cell, table, data
  • 카테고리: text and data display
  • 상태: general-availability

Props

Prop Type Description
children string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal Children content, used when composing a table tree from internal components
columnIndex number
indentLevel number Sets the indent level for the cell
singleLine boolean Sets whether the cell contents should wrap or display on a single line and be truncated
width string | number The width of the header item

사용 지침

  • 과도한 들여쓰기는 피하세요 — 스캔 가능성과 화면 확대 사용자에게 영향을 줘요
  • 접근성을 위해 자르기보다 줄바꿈을 선호해요

Header component

테이블 트리의 단일 열 헤더예요. 각 열을 정의하려면 Headers 안에서 사용해요.

  • 키워드: table-tree, header, table, column
  • 카테고리: text and data display
  • 상태: general-availability

Props

Prop Type Description
children string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal The contents of the header
columnIndex number
id string
onClick () => void
role string
width string | number Width of the header item

사용 지침

  • 구조화된 표 데이터에만 사용해요 — 레이아웃 용도로는 절대 사용하지 마세요

Headers component

테이블 열 헤더의 컨테이너예요. 열을 정의하려면 Header 컴포넌트와 함께 사용해요.

  • 키워드: table-tree, headers, table, columns
  • 카테고리: text and data display
  • 상태: general-availability

Props

Prop Type Description
children ReactElement<any, string | React.JSXElementConstructor<any>> | ReactElement<any, string | React.JSXElementConstructor<any>>[] (required)

사용 지침

  • 열 헤더를 간단한 언어로 명확히 라벨링해요
  • 테이블에 접근 가능한 이름을 제공해요

Row component

테이블 트리의 단일 행이에요. 각 데이터 항목에 Rows render prop 안에서 사용해요.

  • 키워드: table-tree, row, table, expandable
  • 카테고리: text and data display
  • 상태: general-availability

Props

Prop Type Description
children string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal Children contained in the row
collapseLabel string This is the accessible name for the collapse chevron button, used to tell assistive technology what the button is for
data { id: string; } Data to render
depth number The depth used for rendering an indent
expandLabel string This is the accessible name for the expand chevron button, used to tell assistive technology what the button is for
hasChildren boolean Whether the row has children
isDefaultExpanded boolean Sets the default expanded state of the row
isExpanded boolean Controls the expanded state of the row
itemId string ID for the row item
items Item[] The data used to render the row and descendants
mainColumnForExpandCollapseLabel string | number Adds detail to the expand and collapse row button's aria label by appending the value from the given column
onCollapse (data: Item, analytics?: UIAnalyticsEvent) => void | Promise<void> Callback called when the row collapses
onExpand (data: Item, analytics?: UIAnalyticsEvent) => void | Promise<void> Callback called when the row expands
renderChildren () => React.ReactNode Children to render under the row
shouldExpandOnClick boolean Use this to set whether a row with children should expand when clicked anywhere within the row

사용 지침

  • 행에 상호작용 요소(버튼, 드롭다운)가 없을 때만 클릭 시 확장을 허용해요

Rows component

테이블 트리 행의 컨테이너예요. 중첩 데이터로 확장 가능한 행을 렌더링해요.

  • 키워드: table-tree, rows, table, data
  • 카테고리: text and data display
  • 상태: general-availability

Props

Prop Type Description
items T[] The data used to render the set of rows
loadingLabel string This is an accessible name for the loading state's spinner
render (args: T & { children?: T[]; content?: Content; }) => React.ReactElement<RowProps<T>, string | React.JSXElementConstructor<any>> Render function for child rows (required)

사용 지침

  • 중요한 정보는 최상위에 두어 사용자가 자주 확장할 필요가 없게 해요
  • 스캔 가능성을 위해 들여쓰기를 제한해요
  • 자르기는 피하세요 — 콘텐츠가 셀 너비를 초과하면 줄바꿈을 선호해요

Table tree component

테이블 트리는 중첩된 정보 계층을 보여주는 확장 가능한 테이블이에요.

  • 키워드: table-tree, table, tree, expandable, nested, hierarchy, rows
  • 카테고리: text and data display
  • 상태: general-availability

예시

import React, { PureComponent } from 'react';
import { Cell } from '@atlaskit/table-tree/cell';
import { Header } from '@atlaskit/table-tree/header';
import { Headers } from '@atlaskit/table-tree/headers';
import { Row } from '@atlaskit/table-tree/row';
import { Rows } from '@atlaskit/table-tree/rows';
import TableTree from '@atlaskit/table-tree/table-tree';
import staticData from './data-cleancode-toc.json';
export default class extends PureComponent<any, any> {
	state: any = {
		expansionMap: {
			1: true,
		},
	};
	render(): React.JSX.Element {
		const { expansionMap } = this.state;
		return (
			<div>
				<TableTree>
					<Headers>
						<Header width={200}>Chapter title</Header>
						<Header width={120}>Numbering</Header>
						<Header width={100}>Page</Header>
					</Headers>
					<Rows
						items={staticData.children}
						render={({ title, numbering, page, children }: any) => (
							<Row
								itemId={numbering}
								items={children}
								hasChildren={children.length > 0}
								isExpanded={Boolean(expansionMap[numbering])}
								onExpand={() =>
									this.setState({
										expansionMap: {
											...expansionMap,
											[numbering]: true,
										},
									})
								}
								onCollapse={() =>
									this.setState({
										expansionMap: {
											...expansionMap,
											[numbering]: false,
										},
									})
								}
							>
								<Cell singleLine>{title}</Cell>
								<Cell>{numbering}</Cell>
								<Cell>{page}</Cell>
							</Row>
						)}
					/>
				</TableTree>
			</div>
		);
	}
}

Props

Prop Type Description
children string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal The contents of the table
columns React.ElementType<any, keyof React.JSX.IntrinsicElements>[] Each column component is used to render the cells in that column
columnWidths ColumnWidth[] The widths of the columns in the table
headers string[] The header text of the columns of the table
items Item[] The data used to render the table
label string This is an aria-label attribute
mainColumnForExpandCollapseLabel string | number The value used to extend the expand or collapse button label in cases where row has child rows
referencedLabel string This is an aria-labelledby attribute
shouldExpandOnClick boolean Use this to set whether a row with children should expand when clicked anywhere within the row

더 알아보기 (Learn more)