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

트리 선택(TreeSelect)

원문 보기 위키 갱신

Arco Design의 Data Entry 컴포넌트인 TreeSelect는 트리 구조 데이터를 선택할 수 있게 해줘요. 현재는 단일 선택만 지원해요.

출처: 문서

본문

API

TreeSelect

속성 설명 타입 기본값 버전
allowClear 선택한 옵션을 지울 수 있는지 여부 boolean - -
animation 내부 label 변경에 애니메이션을 추가할지 여부 boolean true 2.15.0
bordered 테두리를 표시할지 여부 boolean true -
disabled 비활성 여부 boolean - -
dragToSort 태그를 드래그로 정렬할 수 있는지 여부 boolean - 2.27.0
error textarea에 오류가 있는지 여부 (지원 중단, 다음 메이저 버전에서 제거돼요. 대신 status='error'를 사용하세요) boolean - -
labelInValue 값 형식을 설정해요. 기본은 string이고, true로 설정하면 값 형식이 { label: string, value: string }로 바뀌어요 boolean - -
loading 로딩 중 여부 boolean - -
multiple 여러 개 선택할지 여부 boolean - -
popupVisible 팝업이 보이는지 여부 boolean - -
treeCheckable 체크박스를 표시할지 여부 boolean - -
treeCheckStrictly 부모와 자식 노드가 연동되는지 여부 boolean - -
unmountOnExit 숨긴 뒤 DOM을 파괴할지 여부 boolean - -
inputValue 입력 검색 값을 설정해요 string - 2.39.0
placeholder 요소의 placeholder string - -
autoWidth 자동 너비예요. minWidth는 기본 0, maxWidth는 기본 100%예요 | boolean| { minWidth?: CSSProperties['minWidth']; maxWidth?: CSSProperties['maxWidth'] } - 2.54.0
fieldNames key, title, isLeaf, disabled, children의 커스텀 필드 이름 TreeProps['fieldNames'] DefaultFieldNames 2.11.0
maxTagCount 표시할 tags의 최대 개수예요. multiple과 label 모드에서만 유효해요. 옵션이 많을 때 responsive 반응형 표시 태그 수를 설정하는 것은 권장하지 않아요. 성능 문제가 생길 수 있어요. | number| 'responsive'| {count: number | 'responsive';render?: (invisibleTagCount: number) => ReactNode;} - 객체 타입은 2.37.0부터, responsive는 2.62.0부터
size 요소의 높이, 24px 28px 32px 36px 'mini' | 'small' | 'default' | 'large' - -
status 상태 'error' | 'warning' - 2.45.0
treeCheckedStrategy 반환 값을 커스터마이징해요 TreeProps['checkedStrategy'] all -
addBefore select 필드 앞(왼쪽)에 표시되는 라벨 텍스트 ReactNode - 2.41.0
clearIcon allowClear일 때 지우기 버튼의 아이콘을 설정해요 ReactNode - 2.26.0
notFoundContent 데이터가 없을 때 표시되는 콘텐츠 ReactNode - -
prefix select 접두사를 커스터마이징해요 ReactNode - 2.11.0
suffixIcon select 접미사 아이콘을 커스터마이징해요 ReactNode - -
arrowIcon select 화살표 아이콘을 커스터마이징해요 ReactNode | null - -
className 추가 css 클래스 string | string[] - -
defaultValue 기본으로 선택되는 노드의 key | string| string[]| { label: ReactNode; value: string; disabled?: boolean }| { label: ReactNode; value: string; disabled?: boolean }[] - -
dropdownMenuStyle 드롭다운 메뉴에 추가할 css 스타일 CSSProperties - 2.3.0
removeIcon multiple과 label 모드에서 선택된 태그의 삭제 아이콘을 커스터마이징해요 ReactNode | null - -
showSearch 단일 모드 Select가 검색 가능한지 여부예요. { retainInputValue: true }는 검색창이 포커스될 때 기존 내용을 유지하고, { retainInputValueWhileSelect: true }는 다중 선택 시 기존 내용을 유지해요. boolean | { retainInputValue?: boolean; retainInputValueWhileSelect?: boolean } - -
style 추가 스타일 CSSProperties - -
treeData 트리 데이터 TreeSelectDataType[] - -
treeProps Tree 컴포넌트의 props Partial<TreeProps> - -
triggerProps Trigger 컴포넌트의 props Partial<TriggerProps> - -
value 선택된 노드의 key | string| string[]| { label: ReactNode; value: string; disabled?: boolean }| { label: ReactNode; value: string; disabled?: boolean }[] - -
dropdownRender 드롭다운 렌더링을 커스터마이징해요 (dom: ReactNode) => ReactNode - 2.3.0
filterTreeNode 입력 값 기준으로 데이터를 필터링해요. inputText와 treeNode 두 파라미터를 받아요. 옵션이 필터 조건에 맞으면 true, 아니면 false를 반환해요. treeNode는 트리 노드예요. (inputText, treeNode: any) => boolean | void - -
getPopupContainer 팝업의 부모 노드 (node: HTMLElement) => Element - -
loadMore 비동기로 데이터를 로드할 때의 콜백 (treeNode: NodeProps, dataRef) => void - -
onChange 선택이 바뀔 때의 콜백 (value: any,extra: {trigger?: NodeProps;checked?: boolean;selected?: boolean;}) => void - extra는 2.29.0부터
onClear 지우기를 클릭할 때의 콜백이고, 파라미터는 현재 드롭다운의 보임 상태예요 (visible: boolean) => void - -
onClick 마우스가 드롭다운 박스를 클릭할 때의 콜백 (e) => void - -
onInputValueChange 입력 검색 값이 바뀔 때의 콜백 (value: string, reason: InputValueChangeReason) => void - 2.39.0
onKeyDown 키보드를 눌렀을 때의 콜백 (e) => void - 2.40.0
onSearch 데이터를 검색할 때의 콜백이에요. undefined이면 이미 있는 데이터 안에서 검색해요 (inputValue: string) => void - -
onVisibleChange 팝업 보임 여부가 바뀔 때의 콜백 (visible: boolean) => void - -
renderFormat Select에 표시될 콘텐츠를 커스터마이징해요. value에 해당하는 Option이 없으면 첫 파라미터가 null이 돼요 (option: NodeProps | null, value: string | LabelValue) => ReactNode - 2.46.0
renderTag 태그 렌더링을 커스터마이징해요. props는 현재 태그 속성, index는 현재 태그 순서, values는 모든 태그의 값이에요 (props: {value: any;label: ReactNode;closable: boolean;onClose: (event) => void;},index: number,values: ObjectValueType[]) => ReactNode - index, values는 2.15.0부터 추가
triggerElement 트리거 요소를 커스터마이징해요 ReactNode | ((params: { value: any }) => ReactNode) - () => ReactNode는 2.31.0부터

LabelValue

export type LabelValue = {
  label: ReactNode;
  value: string;
  disabled?: boolean;
};

FieldNamesType

export type FieldNamesType = {
  key?: string;
  title?: string;
  disabled?: string;
  children?: string;
  isLeaf?: string;
  disableCheckbox?: string;
  checkable?: string;
};

TreeSelectDataType

export type TreeSelectDataType = TreeDataType & {
  value?: string;
};

TreeDataType

export type TreeDataType = NodeProps & {
  key?: string;
  _index?: number;
  children?: TreeDataType[];
  [key: string]: any;
};

InputValueChangeReason

// 造成输入框值改变的原因:用户输入、选中选项、选项下拉框收起
export type InputValueChangeReason =
  | "manual"
  | "optionChecked"
  | "optionListHide";

ObjectValueType

export type ObjectValueType = {
  value?: any;
  label?: ReactNode;
  closable?: boolean;
};

더 알아보기 (Learn more)

더 자세한 내용은 Arco Design 공식 문서에서 확인할 수 있어요.