InlineEdit.Args
const · packages/primitives/src/interaction/inline-edit.ts:71
const Args: Schema.Struct<{
readonly id: Schema.String
readonly blur: Schema.Literals<readonly ['commit', 'cancel']>
}>Primitives / foldkit-primitives/interaction
namespace · packages/primitives/src/interaction/inline-edit.ts:13
export * as InlineEdit from './inline-edit.js'Editing a value where it is shown, in an <input>: a title becomes a text
field on Enter, F2 or a double click, Enter saves, Escape puts it back. The
Model slice is which item is being edited and its draft, and nothing is
read back from the field: every key the field takes arrives as a Message,
so a commit sends what update has, whatever the last frame drew.
A commit of a changed value is the OutMessage Committed; the placement's
onOut saves it, or hands it back to refuse with the reason, which keeps
the editor open on the same draft with that error. A value left as it was
commits nothing.
InlineEdit.Argsconst · packages/primitives/src/interaction/inline-edit.ts:71
const Args: Schema.Struct<{
readonly id: Schema.String
readonly blur: Schema.Literals<readonly ['commit', 'cancel']>
}>InlineEdit.behaviorfunction · packages/primitives/src/interaction/inline-edit.ts:284
function behavior<Field extends string>(
declared: Declared<typeof bundle, Field>,
args: Args,
): <Slots>(
slots: Slots,
) => <Input extends { readonly [K in Field]: Model }, ParentMessage>(
options: BehaviorOptions<Input, Slots, ParentMessage>,
) => Behavior.NamedBehavior<Slots, Input, ParentMessage>Wires a placed InlineEdit to the slots. Each display gets its id, a
double click and its keys; the field gets its id, its value from the
draft, OnInput, OnBlur, aria-invalid and aria-describedby while a
refusal stands, and Enter and Escape as Behaviors.Keys routes, so an
Escape that cancels the edit is default-prevented and closes no dialog
around it. A key an input method is composing reaches none of them.
The field needs a name of its own: give it aria-label (the item's name,
or "Rename …"), as a field with no visible label has none.
InlineEdit.BehaviorOptionsinterface · packages/primitives/src/interaction/inline-edit.ts:254
interface BehaviorOptions<Input, Slots, ParentMessage> {
readonly display: keyof Slots & string
readonly input: keyof Slots & string
readonly error?: keyof Slots & string
readonly value: (input: Input, id: string) => string
readonly disabled?: (input: Input, id: string) => boolean
readonly routes?: ReadonlyArray<Behaviors.Keys.Route<Input, ParentMessage>>
}InlineEdit.bundleconst · packages/primitives/src/interaction/inline-edit.ts:208
const bundle: Bundle.Bundle<"InlineEdit", { readonly id: string; readonly blur: "cancel" | "commit"; }, { readonly editing: Option.Option<{ readonly id: string; readonly initial: string; readonly draft: string; readonly error: Option.Option<string>; }>; }, { readonly _tag: "CompletedFocus"; } | { readonly _tag: "Changed"; readonly id: string; readonly text: string; } | { readonly _tag: "Escaped"; readonly id: string; } | { readonly _tag: "Entered"; readonly id: string; } | { readonly _tag: "Started"; readonly id: string; readonly text: string; } | { readonly _tag: "KeyedOver"; readonly id: string; readonly text: string; readonly key: string; } | { readonly _tag: "Blurred"; readonly id: string; }, { readonly _tag: "Committed"; readonly id: string; readonly value: string; readonly initial: string; }, never, never, NoView, {}, { start: (model: Model, id: string, text: string) => Readonly<{ model: { readonly editing: Option.Option<{ readonly id: string; readonly initial: string; readonly draft: string; readonly error: Option.Option<string>; }>; }; commands?: Update.Commands<{ readonly _tag: "CompletedFocus"; } | { readonly _tag: "Changed"; readonly id: string; readonly text: string; } | { readonly _tag: "Escaped"; readonly id: string; } | { readonly _tag: "Entered"; readonly id: string; } | { readonly _tag: "Started"; readonly id: string; readonly text: string; } | { readonly _tag: "KeyedOver"; readonly id: string; readonly text: string; readonly key: string; } | { readonly _tag: "Blurred"; re …;InlineEdit.Committedconst · packages/primitives/src/interaction/inline-edit.ts:63
const Committed: Schema.TaggedStruct<
'Committed',
{
readonly id: Schema.String
readonly value: Schema.String
readonly initial: Schema.String
}
>InlineEdit.displayIdfunction · packages/primitives/src/interaction/inline-edit.ts:85
function displayId(args: Args, id: string): stringThe DOM id of the element showing item id's value, where focus returns.
InlineEdit.displayKeyfunction · packages/primitives/src/interaction/inline-edit.ts:241
function displayKey(
id: string,
text: string,
key: string,
modifiers: KeyboardModifiers,
): Option.Option<Message>The Message a key where the value shows sends, or none: Enter, F2, Backspace, and a printable key other than Space, none of them with Ctrl, Alt or Meta held (nor Shift, for Enter and F2).
InlineEdit.Editingconst · packages/primitives/src/interaction/inline-edit.ts:22
const Editing: Schema.Struct<{
readonly id: Schema.String
readonly initial: Schema.String
readonly draft: Schema.String
readonly error: Schema.OptionFromNullOr<Schema.String>
}>InlineEdit.errorIdfunction · packages/primitives/src/interaction/inline-edit.ts:87
function errorId(args: Args): stringThe DOM id of the refusal's text, which the field is described by.
InlineEdit.errorOffunction · packages/primitives/src/interaction/inline-edit.ts:374
function errorOf(model: Model): Option.Option<string>The refusal's text while one stands, for the view to draw in the error slot.
InlineEdit.inputIdfunction · packages/primitives/src/interaction/inline-edit.ts:83
function inputId(args: Args): stringThe DOM id of the field.
InlineEdit.Messageconst · packages/primitives/src/interaction/inline-edit.ts:38
const Message: MessageUnion<{
readonly Started: { readonly id: Schema.String; readonly text: Schema.String }
readonly KeyedOver: {
readonly id: Schema.String
readonly text: Schema.String
readonly key: Schema.String
}
readonly Changed: { readonly id: Schema.String; readonly text: Schema.String }
readonly Entered: { readonly id: Schema.String }
readonly Escaped: { readonly id: Schema.String }
readonly Blurred: { readonly id: Schema.String }
readonly CompletedFocus: {}
}>InlineEdit.Modelconst · packages/primitives/src/interaction/inline-edit.ts:33
const Model: Schema.Struct<{
readonly editing: Schema.OptionFromNullOr<
Schema.Struct<{
readonly id: Schema.String
readonly initial: Schema.String
readonly draft: Schema.String
readonly error: Schema.OptionFromNullOr<Schema.String>
}>
>
}>