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

인플레이스 (Inplace)

원문 보기 위키 갱신

컴파운드 구성 방식의, 스타일 없는 접근성 좋은 인라인 편집(inline editing) 컴포넌트예요.

출처: 문서

본문

Features (기능)

  • 4개의 하위 컴포넌트(Root, Display, Content, Close)를 갖춘 컴파운드 API예요.

Usage (사용법)

import { Inplace } from 'primereact/inplace';
<Inplace.Root>
    <Inplace.Display></Inplace.Display>
    <Inplace.Content>
        <input />
        <Inplace.Close></Inplace.Close>
    </Inplace.Content>
</Inplace.Root>

Behavior (동작)

다형성 렌더링 (Polymorphic Rendering)

어떤 하위 컴포넌트든 as를 써서 렌더링되는 HTML 요소를 바꿀 수 있어요.

<Inplace.Close as="button">Done</Inplace.Close>

기본 요소: Root=div, Display=div, Content=div, Close=div이에요.

렌더 함수 children (Render Function Children)

Content는 children으로 렌더 함수를 받아 컴포넌트 인스턴스에 접근할 수 있게 해줘요.

<Inplace.Content>{(instance) => <span>Open: {String(instance.inplace?.state.open)}</span>}</Inplace.Content>

API

InplaceRoot

Attribute Value
data-scope "inplace"
data-part "root"
data-open Present when open
data-closed Present when closed
data-disabled Present when disabled
Label Type Description
root InplaceRootPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.
content InplaceRootPassThroughType<HTMLAttributes> Used to pass attributes to the content's DOM element.
display InplaceRootPassThroughType<HTMLAttributes> Used to pass attributes to the display's DOM element.
close InplaceRootPassThroughType<HTMLAttributes> Used to pass attributes to the close's DOM element.

InplaceDisplay

Attribute Value
data-scope "inplace"
data-part "display"
data-open Present when open
data-closed Present when closed
data-disabled Present when disabled
Label Type Description
root InplaceDisplayPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

InplaceContent

Label Type Description
root InplaceContentPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

InplaceClose

Attribute Value
data-scope "inplace"
data-part "close"
data-open Present when open
data-closed Present when closed
data-disabled Present when disabled
Label Type Description
root InplaceClosePassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

Accessibility (접근성)

스크린 리더 (Screen Reader)

Inplace는 기본적으로 aria-live="polite"를 사용해서 콘텐츠 변경을 스크린 리더가 알려주도록 해요. display 요소는 키보드 포커스를 위해 tabIndex={0}을 가져요.

키보드 지원 (Keyboard Support)

Key Function
enter Activates the display, showing the content.
space Activates the display, showing the content.

더 알아보기 (Learn more)