Press.Args
const · packages/primitives/src/interaction/press.ts:53
const Args: Schema.Struct<{ readonly clickSuppressionMs: Schema.Number }>Primitives / foldkit-primitives/interaction
namespace · packages/primitives/src/interaction/press.ts:10
export * as Press from './press.js'Press: pointer and keyboard activation of one element as one fact. A Mount
reports what the element saw (pointer down, up, cancel, key down, up,
click) with the detail Foldkit's declarative attributes do not carry; the
Bundle's update decides what counts as a press; the ghost click that
follows a touch is suppressed by a timed Command on Effect's clock, never
by a clock read in a handler. Activation is an OutMessage, Pressed, so
the placement must say what a press does.
Press.Argsconst · packages/primitives/src/interaction/press.ts:53
const Args: Schema.Struct<{ readonly clickSuppressionMs: Schema.Number }>Press.behaviorfunction · packages/primitives/src/interaction/press.ts:246
function behavior<Field extends string>(
declared: Declared<typeof bundle, Field>,
): <Slots>(
slots: Slots,
) => <Input extends { readonly [K in Field]: Model }, ParentMessage>(
options: BehaviorOptions<Input, Slots>,
) => Behavior.NamedBehavior<Slots, Input, ParentMessage>Attaches the events Mount to the target slot, mapped into the placement's
Messages, and writes data-pressed while down for styling. The element
decides nothing; a click, a touch, Enter, Space, or an assistive
technology's click all reach update and come out as one Pressed.
Press.BehaviorOptionsinterface · packages/primitives/src/interaction/press.ts:234
interface BehaviorOptions<Input, Slots> {
readonly target: keyof Slots & string
readonly disabled?: (input: Input) => boolean
}Press.bundleconst · packages/primitives/src/interaction/press.ts:71
const bundle: Bundle.Bundle<
'Press',
{ readonly clickSuppressionMs: number },
{
readonly pressed: boolean
readonly pointerId: number | null
readonly key: string | null
readonly suppressing: number | null
readonly generation: number
},
| {
readonly _tag: 'Clicked'
readonly detail: number
readonly shiftKey: boolean
}
| {
readonly _tag: 'PointerDown'
readonly pointerId: number
readonly button: number
readonly pointerType: string
}
| {
readonly _tag: 'PointerUp'
readonly pointerId: number
readonly pointerType: string
readonly shiftKey: boolean
}
| { readonly _tag: 'PointerCancelled'; readonly pointerId: number }
| { readonly _tag: 'KeyDown'; readonly key: string; readonly repeat: boolean }
| { readonly _tag: 'KeyUp'; readonly key: string; readonly shiftKey: boolean }
| { readonly _tag: 'Unsuppressed'; readonly generation: number },
{
readonly _tag: 'Pressed'
readonly pointerType: 'keyboard' | 'virtual' | 'mouse' | 'touch' | 'pen'
readonly shiftKey: boolean
},
never,
never,
void,
{},
{}
>Press.eventsconst · packages/primitives/src/interaction/press.ts:140
const events: Mount.MountDefinitionNoArgs<
'PressEvents',
| {
readonly _tag: 'Clicked'
readonly detail: number
readonly shiftKey: boolean
}
| {
readonly _tag: 'PointerDown'
readonly pointerId: number
readonly button: number
readonly pointerType: string
}
| {
readonly _tag: 'PointerUp'
readonly pointerId: number
readonly pointerType: string
readonly shiftKey: boolean
}
| { readonly _tag: 'PointerCancelled'; readonly pointerId: number }
| { readonly _tag: 'KeyDown'; readonly key: string; readonly repeat: boolean }
| { readonly _tag: 'KeyUp'; readonly key: string; readonly shiftKey: boolean }
>The element's press-relevant events as facts. Enter and Space key downs
are default-prevented so a native control does not also click, and Space
does not scroll; the Bundle owns activation. An element marked
aria-disabled="true" (which the Behavior writes) reports nothing, read
at event time so a toggle needs no remount. Nothing else is decided here.
Press.Facttype · packages/primitives/src/interaction/press.ts:131
type Fact = Exclude<
Message,
{
readonly _tag: 'Unsuppressed'
}
>What the element reports; Unsuppressed comes from the timer, not the DOM.
Press.Messageconst · packages/primitives/src/interaction/press.ts:34
const Message: MessageUnion<{
readonly PointerDown: {
readonly pointerId: Schema.Number
readonly button: Schema.Number
readonly pointerType: Schema.String
}
readonly PointerUp: {
readonly pointerId: Schema.Number
readonly pointerType: Schema.String
readonly shiftKey: Schema.Boolean
}
readonly PointerCancelled: { readonly pointerId: Schema.Number }
readonly KeyDown: {
readonly key: Schema.String
readonly repeat: Schema.Boolean
}
readonly KeyUp: {
readonly key: Schema.String
readonly shiftKey: Schema.Boolean
}
readonly Clicked: {
readonly detail: Schema.Number
readonly shiftKey: Schema.Boolean
}
readonly Unsuppressed: { readonly generation: Schema.Number }
}>Press.Modelconst · packages/primitives/src/interaction/press.ts:21
const Model: Schema.Struct<{
readonly pressed: Schema.Boolean
readonly pointerId: Schema.NullOr<Schema.Number>
readonly key: Schema.NullOr<Schema.String>
readonly suppressing: Schema.NullOr<Schema.Number>
readonly generation: Schema.Number
}>Press.PointerTypeconst · packages/primitives/src/interaction/press.ts:18
const PointerType: Schema.Literals<
readonly ['mouse', 'touch', 'pen', 'keyboard', 'virtual']
>Press.Pressedconst · packages/primitives/src/interaction/press.ts:46
const Pressed: Schema.TaggedStruct<
'Pressed',
{
readonly pointerType: Schema.Literals<
readonly ['mouse', 'touch', 'pen', 'keyboard', 'virtual']
>
readonly shiftKey: Schema.Boolean
}
>