View as Markdown

API reference: @salmonui/editors/inline-edit

InlineEditPropsinterface

import type { InlineEditProps } from '@salmonui/editors/inline-edit';
interface InlineEditProps<T = string> extends RootProps {
    readonly value?: T | undefined;
    readonly defaultValue?: T | undefined;
    readonly save?: ((value: T, options: {
        readonly signal: AbortSignal;
    }) => void | PromiseLike<void>) | undefined;
    readonly mode?: 'inline' | 'popover' | undefined;
    readonly trigger?: 'click' | 'doubleClick' | 'editButton' | undefined;
    readonly blurAction?: 'save' | 'cancel' | 'keep' | undefined;
    readonly saveOnEnter?: boolean | undefined;
    readonly showActions?: boolean | undefined;
    readonly renderActions?: ((context: InlineEditActionsContext) => ReactNode) | undefined;
    readonly validation?: InlineEditValidation<T> | undefined;
    readonly placeholder?: ReactNode;
    readonly renderPreview?: ((context: {
        readonly value: T;
        readonly placeholder: ReactNode;
    }) => ReactNode) | undefined;
    readonly label?: string | undefined;
    readonly editing?: boolean | undefined;
    readonly defaultEditing?: boolean | undefined;
    readonly onEditingChange?: ((editing: boolean, event: InlineEditEditingChangeEvent) => void) | undefined;
    readonly disabled?: boolean | undefined;
    readonly name?: string | undefined;
    readonly popoverProps?: {
        readonly placement?: Placement | undefined;
        readonly offset?: number | undefined;
    } | undefined;
    readonly localeText?: Partial<InlineEditLocaleText> | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly classNames?: Partial<Record<InlineEditPart, string>> | undefined;
    readonly styles?: Partial<Record<InlineEditPart, CSSProperties>> | undefined;
    readonly ref?: Ref<InlineEditApi> | undefined;
    readonly children?: ((context: InlineEditRenderContext<T>) => ReactNode) | undefined;
    readonly onBeforeEditStart?: ((event: InlineEditStartEvent & InlineEditCancellable) => void) | undefined;
    readonly onEditStart?: ((event: InlineEditStartEvent) => void) | undefined;
    readonly onBeforeSave?: ((event: InlineEditSaveEvent<T> & InlineEditCancellable) => void) | undefined;
    readonly onSave?: ((event: InlineEditSaveEvent<T>) => void) | undefined;
    readonly onSaveError?: ((event: InlineEditSaveErrorEvent<T>) => void) | undefined;
    readonly onBeforeEditCancel?: ((event: InlineEditCancelEvent<T> & InlineEditCancellable) => void) | undefined;
    readonly onEditCancel?: ((event: InlineEditCancelEvent<T>) => void) | undefined;
    readonly onDraftChange?: ((event: InlineEditDraftChangeEvent<T>) => void) | undefined;
}
InlineEditProps members (34)
NameSignatureDescription
valueoptionalreadonly value?: T | undefined;

Saved value (controlled).

defaultValueoptionalreadonly defaultValue?: T | undefined;

Initial saved value when uncontrolled. Default ''.

saveoptionalreadonly save?: ((value: T, options: { readonly signal: AbortSignal; }) => void | PromiseLike<void>) | undefined;

Persists a value. May return a promise: pending state, abort on cancel or unmount, rejection keeps editing.

modeoptionalreadonly mode?: 'inline' | 'popover' | undefined;

'popover' (default) opens the editor in a non-modal dialog anchored to the preview; 'inline' replaces the preview.

triggeroptionalreadonly trigger?: 'click' | 'doubleClick' | 'editButton' | undefined;

What starts editing. Default 'click'.

blurActionoptionalreadonly blurAction?: 'save' | 'cancel' | 'keep' | undefined;

What focus leaving the editor does. Default 'save'.

saveOnEnteroptionalreadonly saveOnEnter?: boolean | undefined;

Enter saves (Mod+Enter in a textarea). Default true.

showActionsoptionalreadonly showActions?: boolean | undefined;

Shows the Save and Cancel buttons. Default true.

renderActionsoptionalreadonly renderActions?: ((context: InlineEditActionsContext) => ReactNode) | undefined;

Replaces the default actions.

validationoptionalreadonly validation?: InlineEditValidation<T> | undefined;
placeholderoptionalreadonly placeholder?: ReactNode;

Shown when the value is empty. Default localeText.empty.

renderPreviewoptionalreadonly renderPreview?: ((context: { readonly value: T; readonly placeholder: ReactNode; }) => ReactNode) | undefined;

Display state content. Default String(value).

labeloptionalreadonly label?: string | undefined;

Field label: the accessible name of the preview and the editor.

editingoptionalreadonly editing?: boolean | undefined;

Editing state.

defaultEditingoptionalreadonly defaultEditing?: boolean | undefined;
onEditingChangeoptionalreadonly onEditingChange?: ((editing: boolean, event: InlineEditEditingChangeEvent) => void) | undefined;
disabledoptionalreadonly disabled?: boolean | undefined;
nameoptionalreadonly name?: string | undefined;

Form field name: a hidden input carries the saved value.

popoverPropsoptionalreadonly popoverProps?: { readonly placement?: Placement | undefined; readonly offset?: number | undefined; } | undefined;

Popover placement and offset.

localeTextoptionalreadonly localeText?: Partial<InlineEditLocaleText> | undefined;
classNameoptionalreadonly className?: string | undefined;
styleoptionalreadonly style?: CSSProperties | undefined;
classNamesoptionalreadonly classNames?: Partial<Record<InlineEditPart, string>> | undefined;
stylesoptionalreadonly styles?: Partial<Record<InlineEditPart, CSSProperties>> | undefined;
refoptionalreadonly ref?: Ref<InlineEditApi> | undefined;
childrenoptionalreadonly children?: ((context: InlineEditRenderContext<T>) => ReactNode) | undefined;

The edit element. Default: a text input.

onBeforeEditStartoptionalreadonly onBeforeEditStart?: ((event: InlineEditStartEvent & InlineEditCancellable) => void) | undefined;
onEditStartoptionalreadonly onEditStart?: ((event: InlineEditStartEvent) => void) | undefined;
onBeforeSaveoptionalreadonly onBeforeSave?: ((event: InlineEditSaveEvent<T> & InlineEditCancellable) => void) | undefined;
onSaveoptionalreadonly onSave?: ((event: InlineEditSaveEvent<T>) => void) | undefined;
onSaveErroroptionalreadonly onSaveError?: ((event: InlineEditSaveErrorEvent<T>) => void) | undefined;
onBeforeEditCanceloptionalreadonly onBeforeEditCancel?: ((event: InlineEditCancelEvent<T> & InlineEditCancellable) => void) | undefined;
onEditCanceloptionalreadonly onEditCancel?: ((event: InlineEditCancelEvent<T>) => void) | undefined;
onDraftChangeoptionalreadonly onDraftChange?: ((event: InlineEditDraftChangeEvent<T>) => void) | undefined;