Skip to Content
ComponentsCalsFileUpload

FileUpload

파일 업로드 컴포넌트. 드래그 앤 드롭 또는 클릭으로 파일을 업로드하고, 업로드된 파일 목록을 관리한다.


개요

Foundation의 FileUpload 컴포넌트를 래핑하여 CALS 폼 시스템과 통합한다. 허용 확장자·MIME 타입·파일 크기·개수 검증, 읽기 전용, 기존 파일 다운로드·미리보기 등 비즈니스 요구사항을 지원한다.

주요 특징

  • 드래그 앤 드롭: Atlassian Pragmatic DnD 기반 안정적인 파일 드롭
  • 파일 검증: 확장자, MIME 타입, 크기, 빈 파일 검사
  • 읽기 전용: 업로드 영역·삭제 숨김, 열기·다운로드 유지
  • 기존 파일: 서버 저장 파일 목록 + 다운로드/미리보기 콜백
  • FormItem 통합: 레이블, 필수 표시, 수평 배치, 도움말 지원
  • 디자인 토큰: Foundation 토큰 시스템 완벽 호환

기본 사용

드래그 앤 드롭 또는 클릭으로 파일을 업로드한다.

0 file / -

Drop file or Click to upload


파일 검증

accept, allowedExtensions, maxFileSize, maxFileCount로 업로드 규칙을 설정한다.

0 file / -

Drop file or Click to upload


읽기 전용

readOnly이면 업로드 영역과 삭제 버튼이 숨겨지고, 기존 파일의 열기·다운로드만 표시된다.

1 file / 1.95 MB
보고서.pdf
1.95 MB

레이블 / 필수

FormItem 래핑으로 레이블, 필수 표시, 수평 레이아웃을 지원한다.

0 file / -

Drop file or Click to upload

0 file / -

Drop file or Click to upload

0 file / -

Drop file or Click to upload


라벨 도움말

labelTooltip으로 레이블 옆에 도움말 아이콘을 표시한다.

0 file / -

Drop file or Click to upload


API Reference

Props

PropTypeDefaultDescription
valueFile[]-새로 추가된 파일 (controlled)
onChange(files: File[]) => void-파일 변경 콜백
existingFilesCalsExistingFile[]-서버 저장 기존 파일 목록
onRemoveExisting(file: CalsExistingFile) => void-기존 파일 삭제 콜백
acceptstring-허용 MIME 타입 (HTML accept)
allowedExtensionsstring-허용 확장자 (콤마 구분)
maxFileSizenumber5최대 파일 크기 (MB)
maxFileCountnumber5최대 파일 수
multiplebooleantrue다중 파일 선택
readOnlyboolean-읽기 전용
visiblebooleantrue표시 여부
rejectEmptyFilebooleantrue빈 파일 차단
heightnumber | string-컴포넌트 높이
labelReactNode-레이블 텍스트
showLabelboolean-빈 레이블 공간 표시
labelTooltipstring-레이블 도움말
requiredboolean-필수 입력
orientation"vertical" | "horizontal"-레이블 위치
classNamestring-컨테이너 CSS 클래스
formClassNamestring-FormItem 래퍼 CSS 클래스

Events

EventTypeDescription
onChange(files: File[]) => void파일 변경 시 호출
onError(error: string) => void에러 발생 시 호출
onRemoveExisting(file: CalsExistingFile) => void기존 파일 삭제 시 호출
onDownload(file: CalsExistingFile) => void파일 다운로드 시 호출
onPreview(file: CalsExistingFile) => void파일 열기/미리보기 시 호출

Ref API

MethodTypeDescription
focus()() => void드롭존 포커스 이동
blur()() => void포커스 해제
elementHTMLElement컨테이너 DOM 요소

접근성

권장 사항

  • label prop으로 업로드 영역에 의미 있는 레이블 제공
  • required 설정 시 aria-required 자동 적용
  • ✅ 키보드(Enter/Space)로 파일 선택 대화상자 열기 지원
  • ❌ 아이콘만 있는 버튼에 aria-label 누락 금지

관련 컴포넌트

Last updated on