@atlaskit/inline-edit
인라인 에디트(Inline Edit)는 같은 페이지에서 읽기와 편집 상태를 전환하는 커스텀 입력 컴포넌트를 보여 주는 폼 컴포넌트예요.
출처: 문서
본문
InlineEdit 컴포넌트
인라인 에디트는 같은 페이지에서 읽기와 편집 상태를 전환하는 커스텀 입력 컴포넌트를 보여 줘요.
- Keywords: inline, edit, editable, text, input
- Categories: form
- Status: general-availability
예시
import InlineEdit from '@atlaskit/inline-edit/inline-edit';
const Example = (): React.JSX.Element => (
<InlineEdit
onConfirm={() => {}}
onCancel={() => {}}
defaultValue="Editable text"
editView={() => <div>Edit view</div>}
readView={() => <div>Read view</div>}
/>
);
export default Example;
Props
| Prop | Type | Description |
|---|---|---|
cancelButtonLabel |
string |
Accessibility label for the cancel action button |
confirmButtonLabel |
string |
Accessibility label for the confirm action button, which saves the field value into editValue |
defaultValue |
any |
The user input entered into the field during editView (required) |
editButtonLabel |
string |
Accessibility label for button, which is used to enter editView from keyboard |
editLabel |
string |
Append 'edit' to the end of the button label (editButtonLabel)which allows |
| users of assistive technologies to understand the purpose of the button | ||
editView |
(fieldProps: ExtendedFieldProps<FieldValue>, ref: React.RefObject<any>) => React.ReactNode |
The component shown when user is editing (when the inline edit is not in readView) (required) |
hideActionButtons |
boolean |
Sets whether the confirm and cancel action buttons are displayed in the bottom right of the field |
isEditing |
boolean |
Sets whether the component shows the readView or the editView |
isRequired |
boolean |
Determines whether the input value can be confirmed as empty |
keepEditViewOpenOnBlur |
boolean |
Sets the view when the element blurs and loses focus (this can happen when a user clicks away) |
label |
string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
Label above the input field that communicates what value should be entered |
onCancel |
() => void |
Exits editView and switches back to readView |
onConfirm |
(value: any, analyticsEvent: UIAnalyticsEvent) => void |
Saves and confirms the value entered into the field (required) |
onEdit |
() => void |
Handler called when readView is clicked |
readView |
() => React.ReactNode |
The component shown when not in editView (required) |
readViewFitContainerWidth |
boolean |
Determines whether the readView has 100% width within its container, or whether it fits the content |
startWithEditViewOpen |
boolean |
Determines whether it begins in editView or readView |
validate |
(value: any, formState: {}, fieldState: {}) => string | void | Promise<string | void> |
Displays an inline dialog with a message when the field input is invalid |
사용 지침
- 커스텀 입력 컴포넌트나 레이아웃이 필요할 때 사용해요.
- 표준 텍스트 필드 용도에는 InlineEditableTextfield를 사용해요.
- 명확한 편집 상태 표시를 제공해요.
콘텐츠 지침
- 명확하고 설명적인 텍스트 콘텐츠를 사용해요.
- 도움이 되는 placeholder 텍스트를 제공해요.
- 적절한 검증 메시지를 사용해요.
- 콘텐츠를 간결하되 의미 있게 유지해요.
접근성 지침
- 적절한 포커스 관리를 보장해요.
- 명확한 편집 상태 표시를 제공해요.
- 적절한 ARIA 속성을 사용해요.
- 키보드 탐색을 고려해요.
InlineEditableTextfield 컴포넌트
인라인 편집 가능 텍스트 필드는 같은 페이지에서 읽기와 편집 상태를 전환하는 텍스트 필드를 보여 줘요.
- Keywords: inline, edit, editable, textfield, text, input
- Categories: form
- Status: general-availability
예시
import React, { useState } from 'react';
import InlineEditableTextfield from '@atlaskit/inline-edit/inline-editable-textfield';
import { Box } from '@atlaskit/primitives/compiled/box';
const InlineEditableTextfieldDefault = (): React.JSX.Element => {
const placeholderLabel = 'Initial description value';
const [editValue, setEditValue] = useState('Default description value');
const validate = (value: string) => {
if (value.length <= 6) {
return 'Please enter a description longer than 6 characters';
}
return undefined;
};
return (
<Box paddingInline="space.100" paddingBlockStart="space.100" paddingBlockEnd="space.600">
<InlineEditableTextfield
defaultValue={editValue}
label="Description"
editButtonLabel={editValue || placeholderLabel}
onConfirm={(value) => setEditValue(value)}
placeholder={placeholderLabel}
validate={validate}
/>
</Box>
);
};
export default InlineEditableTextfieldDefault;
Props
| Prop | Type | Description |
|---|---|---|
cancelButtonLabel |
string |
Accessibility label for the cancel action button |
confirmButtonLabel |
string |
Accessibility label for the confirm action button, which saves the field value into editValue |
defaultValue |
any |
The user input entered into the field during editView (required) |
editButtonLabel |
string |
Accessibility label for button, which is used to enter editView from keyboard |
editLabel |
string |
Append 'edit' to the end of the button label (editButtonLabel)which allows |
| users of assistive technologies to understand the purpose of the button | ||
hideActionButtons |
boolean |
Sets whether the confirm and cancel action buttons are displayed in the bottom right of the field |
isCompact |
boolean |
Sets height of the text field to compact |
isRequired |
boolean |
Determines whether the input value can be confirmed as empty |
keepEditViewOpenOnBlur |
boolean |
Sets the view when the element blurs and loses focus (this can happen when a user clicks away) |
label |
string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
Label above the input field that communicates what value should be entered |
onCancel |
() => void |
Exits editView and switches back to readView |
onConfirm |
(value: string, analyticsEvent: UIAnalyticsEvent) => void |
Calls the editView handler (required) |
placeholder |
string |
Text shown in readView when the field value is an empty string (required) |
readViewFitContainerWidth |
boolean |
Determines whether the readView has 100% width within its container, or whether it fits the content |
startWithEditViewOpen |
boolean |
Determines whether it begins in editView or readView |
validate |
(value: any, formState: {}, fieldState: {}) => string | void | Promise<string | void> |
Displays an inline dialog with a message when the field input is invalid |
사용 지침
- 다듬기가 필요할 수 있는 텍스트 필드의 기존 콘텐츠에 사용해요.
- 페이지의 여러 항목을 한 번에 편집할 수 있을 때 사용해요.
- 화면의 주 기능이 편집이면 사용하지 말고, 대신 텍스트 영역(text area)을 사용해요.
- 커스텀 입력 컴포넌트가 필요하면 InlineEdit을 사용해요.
콘텐츠 지침
- 간결하고 문장형(sentence case) 라벨을 사용해요.
- 빈 상태에는 placeholder 텍스트를 커스터마이즈해요.
- 라벨을 필드에 대해 설명적으로 유지해요.
접근성 지침
- 읽기/편집 상태 간 적절한 포커스 관리를 보장해요.
- 명확한 저장/취소 컨트롤을 제공해요.
- 적절한 ARIA 속성을 사용해요.