문서 표와 그리드

UITreeGrid

계층형 행을 펼치고 셀 사이를 이동합니다.

기본 사용법

계층형 행과 셀 구성

제품 플랫폼 행을 접거나 펼쳐 하위 서비스를 확인합니다. 서비스, 담당 팀, 상태를 열 제목과 함께 읽을 수 있습니다.

서비스
담당 팀
상태
제품 플랫폼
플랫폼
운영 중
문서 검색
서비스
점검 중
공개 API
서버
운영 중
지원 센터
운영
운영 중
<script setup lang="ts">
import {
  UITabularRows,
  UITreeGrid,
  UITreeGridCell,
  UITreeGridDisclosure,
  UITreeGridHeader,
  UITreeGridHeaderCell,
  UITreeGridRow,
  UIDataStatus,
} from "@connextable/ui";
import { ChevronRight } from "@lucide/vue";

const headers = ["서비스", "담당 팀", "상태"];
const services = [
  {
    id: "platform",
    parentID: null,
    name: "제품 플랫폼",
    owner: "플랫폼",
    status: "운영 중",
  },
  {
    id: "search",
    parentID: "platform",
    name: "문서 검색",
    owner: "서비스",
    status: "점검 중",
  },
  {
    id: "api",
    parentID: "platform",
    name: "공개 API",
    owner: "서버",
    status: "운영 중",
  },
  {
    id: "support",
    parentID: null,
    name: "지원 센터",
    owner: "운영",
    status: "운영 중",
  },
];
const rows = services.map(({ id, parentID }) => ({
  id,
  parentID,
  cells: [`${id}-name`, `${id}-owner`, `${id}-status`],
}));
const values = new Map(
  services.flatMap<[string, string]>(({ id, name, owner, status }) => [
    [`${id}-name`, name],
    [`${id}-owner`, owner],
    [`${id}-status`, status],
  ]),
);
</script>

<template>
  <UITreeGrid
    :rows="rows"
    :headers="headers"
    :default-expanded-value="['platform']"
    readonly
    :get-cell-value="(id) => values.get(id) ?? ''"
    :set-cell-value="() => {}"
    aria-label="서비스 목록"
    v-slot="{ expandedValue }"
  >
    <UITreeGridHeader>
      <UITreeGridHeaderCell
        v-for="(_, index) in headers"
        :key="index"
        :column-index="index + 1"
      />
    </UITreeGridHeader>
    <UITabularRows>
      <UITreeGridRow
        v-for="(service, index) in services.filter(
          (row) =>
            row.parentID === null || expandedValue.includes(row.parentID),
        )"
        :key="service.id"
        :value="service.id"
        :row-index="index + 1"
        :level="service.parentID ? 2 : 1"
        :expandable="service.id === 'platform'"
      >
        <UITreeGridCell :value="`${service.id}-name`" :column-index="1">
          <UITreeGridDisclosure
            v-if="service.id === 'platform'"
            as="button"
            type="button"
            :for="service.id"
            aria-label="제품 플랫폼 하위 서비스"
          >
            <ChevronRight aria-hidden="true" />
          </UITreeGridDisclosure>
          {{ service.name }}
        </UITreeGridCell>
        <UITreeGridCell :value="`${service.id}-owner`" :column-index="2">{{
          service.owner
        }}</UITreeGridCell>
        <UITreeGridCell :value="`${service.id}-status`" :column-index="3">
          <UIDataStatus
            :tone="service.status === '운영 중' ? 'success' : 'warning'"
            >{{ service.status }}</UIDataStatus
          >
        </UITreeGridCell>
      </UITreeGridRow>
    </UITabularRows>
  </UITreeGrid>
</template>

설정과 동작

열 제목 파트

그리드의 열 제목을 Header와 HeaderCell로 구성합니다.

실전 예제

하위 행의 담당자 편집

웹사이트 담당자 옆 연필 버튼을 누르세요. Enter로 적용하고 Escape로 취소합니다.

폴더와 파일을 계층으로 탐색

팀 문서와 회의 기록을 차례로 펼칩니다. 깊이가 다른 항목을 들여쓰기로 읽을 수 있습니다.

구성 컴포넌트

구조와 배치

UITreeGridHeader

본문 앞에 놓이는 제목이나 설명을 담습니다.

열 제목 파트 예제
UITreeGridHeaderCell

그리드 열의 이름을 표시합니다.

열 제목 파트 예제
UITreeGridRow

그리드에서 같은 행에 놓이는 셀을 묶습니다.

열 제목 파트 예제
UITreeGridGroup

상위 항목에 속한 하위 항목을 묶습니다.

하위 행의 담당자 편집 예제

값 입력과 선택

UITreeGridCell

그리드에서 선택하거나 탐색할 항목입니다.

열 제목 파트 예제
UITreeGridEditor

현재 값을 입력하거나 편집하는 영역을 연결합니다.

하위 행의 담당자 편집 예제
UITabularEditTrigger

편집 가능한 값과 연필 아이콘을 표시하고 클릭하면 셀 편집기에 포커스를 옮깁니다.

하위 행의 담당자 편집 예제

탐색과 동작

UITreeGridDisclosure

하위 항목을 펼치거나 접습니다.

열 제목 파트 예제

주요 API

속성과 모델

Row value

행 컨트롤과 연결할 행 id입니다.

Cell column-index

셀의 열 위치를 지정합니다.

Disclosure for

이 컨트롤이 펼칠 행의 id입니다.

전체 속성, 이벤트와 슬롯

UITreeGrid

headers
readonly string[] | undefined
model-value
string | null | undefined
default-value
string | null | undefined
expanded-value
readonly string[] | undefined
default-expanded-value
readonly string[] | undefined
highlighted-value
string | null | undefined
default-highlighted-value
string | null | undefined
edit-mode
TreeGridEditMode | undefined
default-edit-mode
TreeGridEditMode | undefined
disabled
boolean | undefined
readonly
boolean | undefined
policies
TreeGridPolicies<string> | undefined
as
PrimitiveAs | undefined
as-child
boolean | undefined
@update:model-value
(_value: string | null) => any
rows필수
readonly TreeGridRowInput<string, string>[]
@update:edit-mode
(_value: TreeGridEditMode) => any
@update:highlighted-value
(_value: string | null) => any
get-cell-value필수
(id: string) => string
set-cell-value필수
(id: string, value: string) => void
@update:expanded-value
(_value: readonly string[]) => any
#default
(props: TreeGridRootSlotProps) => VNodeChild

UITreeGridHeader

as
PrimitiveAs | undefined
as-child
boolean | undefined
#default
(props: { readonly headers: readonly string[]; }) => VNodeChild

UITreeGridHeaderCell

as
PrimitiveAs | undefined
as-child
boolean | undefined
column-index필수
number
#default
(props: TreeGridHeaderCellSlotProps) => VNodeChild

UITreeGridRow

as
PrimitiveAs | undefined
as-child
boolean | undefined
level
number | undefined
expandable
boolean | undefined
value필수
string
row-index필수
number
#default
(props: TreeGridRowSlotProps) => VNodeChild

UITreeGridGroup

force-present
boolean | undefined
as
PrimitiveAs | undefined
as-child
boolean | undefined
for필수
string
#default
(props: TreeGridRootSlotProps) => VNodeChild

UITreeGridCell

as
PrimitiveAs | undefined
as-child
boolean | undefined
value필수
string
column-index필수
number
#default
(props: TreeGridCellSlotProps) => VNodeChild

UITreeGridDisclosure

as
PrimitiveAs | undefined
as-child
boolean | undefined
for필수
string
#default
(props: TreeGridRowSlotProps) => VNodeChild

UITreeGridEditor

force-present
boolean | undefined
label
string | undefined
for필수
string

UITabularEditTrigger

@click
(event: MouseEvent) => any
#default
(props: {}) => any