ChatDocumentReference

Data Display

업로드 문서의 페이지·인용 구간을 보여주는 카드.

Usage

어시스턴트 답변이 특정 업로드 파일의 특정 페이지를 근거로 들 때 사용합니다. 웹 URL 출처는 Message.Sources, 검색 청크 나열은 ChatRetrievalChunks, 인라인 각주는 ChatInlineCitation을 대신 사용하세요.

import

import

import { ChatDocumentReference } from '@mildang/design-system/unofficial/Chat';

예제를 복사해 쓸 때 필요한 준비

@mildang/styled-system 은 이 저장소에서 Panda 가 생성하는 산출물이다. 저장소 안에서는 turbo run ship 이후 쓸 수 있고, 패키지 소비자는 자기 Panda 산출물이나 다른 레이아웃 수단으로 바꿔야 한다.

API Reference

ChatDocumentReference Props

Prop

Type

Default

anchors
필수

readonly DocumentAnchor[]

지정 안 함

pages
필수

number

지정 안 함

title
필수

string

지정 안 함

activePage

number

지정 안 함

fileType

string

지정 안 함

labels

Partial<ChatDocumentReferenceLabels>

지정 안 함

onJump

(page: number) => void

지정 안 함

같은 패밀리

@mildang/design-system/unofficial/Chat 에서 같이 내보내는 컴포넌트다.

예제

기본

import type { ComponentProps } from 'react';
import { ChatDocumentReference } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatDocumentReference>;
const DEFAULT_ARGS: Props = { title: '재시도 정책 설계.pdf', pages: 48, anchors: [{ page: 4, quote: '토큰 만료(401)에서만 한 번 재시도한다.' }, { page: 12, quote: '네트워크 오류는 재시도 대상이 아니며 그대로 상위로 전파한다.' }, { page: 12, quote: '재시도 간격은 지수 백오프로 늘리되 상한을 둔다.' }], fileType: 'pdf' };
export default function DocumentReferenceDefaultExample(props: Partial<Props> = {}) { return <ChatDocumentReference {...DEFAULT_ARGS} {...props} />; }

인용 하나

import type { ComponentProps } from 'react';
import { ChatDocumentReference } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatDocumentReference>;
const DEFAULT_ARGS: Props = { title: 'RFC-2026-03 인터셉터.pdf', pages: 9, anchors: [{ page: 3, quote: '재시도 상한이 없으면 만료된 세션이 오래 살아남는다.' }], activePage: 3, fileType: 'pdf' };
export default function DocumentReferenceSingleAnchorExample(props: Partial<Props> = {}) { return <ChatDocumentReference {...DEFAULT_ARGS} {...props} />; }

파일 타입별 아이콘

코드

import { css } from '@mildang/styled-system/css';
import { ChatDocumentReference } from '@mildang/design-system/unofficial/Chat';

const DocumentReferenceFileTypesExample = () => (
    <div className={css({ display: 'flex', flexDirection: 'column', gap: '12' })}>
      <ChatDocumentReference
        title="2026 예산.xlsx"
        pages={6}
        anchors={[{ page: 2, quote: '3분기 인프라 예산은 전 분기 대비 12% 늘었다.' }]}
        fileType="xlsx"
      />
      <ChatDocumentReference
        title="온보딩 안내.docx"
        pages={12}
        anchors={[{ page: 5, quote: '첫 주에는 페어 리뷰만 받고 직접 머지하지 않는다.' }]}
        fileType="docx"
      />
      <ChatDocumentReference
        title="확장자 없는 문서"
        pages={3}
        anchors={[{ page: 1, quote: '지원하지 않는 확장자는 기본 글리프로 떨어진다.' }]}
      />
    </div>
  );

export default DocumentReferenceFileTypesExample;

페이지 이동 인터랙션

코드

import { useState } from 'react';
import { css } from '@mildang/styled-system/css';
import { ChatDocumentReference } from '@mildang/design-system/unofficial/Chat';
import { DocumentAnchor } from '@mildang/design-system/unofficial/Chat';

// 12쪽이 두 번 인용된다 — 한 쪽에 여러 앵커가 걸리는 정상 케이스다.
const ANCHORS: readonly DocumentAnchor[] = [
  { page: 4, quote: '토큰 만료(401)에서만 한 번 재시도한다.' },
  { page: 12, quote: '네트워크 오류는 재시도 대상이 아니며 그대로 상위로 전파한다.' },
  { page: 12, quote: '재시도 간격은 지수 백오프로 늘리되 상한을 둔다.' },
];

/** 활성 쪽은 앱(뷰어)이 소유한다 — 스토리에서는 `useState` 가 그 역할을 대신한다. */
const ViewerDemo = () => {
  const [page, setPage] = useState(12);

  return (
    <div className={css({ display: 'flex', flexDirection: 'column', gap: '12' })}>
      <ChatDocumentReference
        title="재시도 정책 설계.pdf"
        pages={48}
        anchors={ANCHORS}
        activePage={page}
        fileType="pdf"
        onJump={setPage}
      />
      <span className={css({ textStyle: 'chat-small-text-R', color: 'neutral.text.low' })}>
        뷰어가 보고 있는 쪽: {page}
      </span>
    </div>
  );
};

const DocumentReferenceInteractiveExample = () => <ViewerDemo />;

export default DocumentReferenceInteractiveExample;