Selection.Args
const · packages/primitives/src/interaction/selection.ts:38
const Args: Schema.Struct<{
readonly mode: Schema.Literals<readonly ['single', 'multiple', 'none']>
readonly allowEmpty: Schema.Boolean
}>Primitives / foldkit-primitives/interaction
namespace · packages/primitives/src/interaction/selection.ts:10
export * as Selection from './selection.js'Selection over a set of items: which ids are selected, and the anchor a
range extends from. mode is 'single' (a click replaces), 'multiple'
(a click toggles), or 'none'. Single mode keeps one item selected unless
allowEmpty. A range needs the items' order, which the view knows and the
Bundle does not, so Ranged carries it. The Behavior says the state in
ARIA and wires a plain click; a Shift range comes from Press, whose
Pressed carries shiftKey.
Selection.Argsconst · packages/primitives/src/interaction/selection.ts:38
const Args: Schema.Struct<{
readonly mode: Schema.Literals<readonly ['single', 'multiple', 'none']>
readonly allowEmpty: Schema.Boolean
}>Selection.behaviorfunction · packages/primitives/src/interaction/selection.ts:122
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>,
) => Behavior.NamedBehavior<Slots, Input, ParentMessage>Writes aria-selected on each item from the placed slice, and
aria-multiselectable on the container in multiple mode; wires OnClick
to Activated unless told not to. A disabled item gets no click.
Selection.BehaviorOptionsinterface · packages/primitives/src/interaction/selection.ts:106
interface BehaviorOptions<Input, Slots> {
readonly container?: keyof Slots & string
readonly item: keyof Slots & string
readonly items: (input: Input) => Behaviors.Collection.Items<unknown>
readonly click?: boolean
}Selection.betweenfunction · packages/primitives/src/interaction/selection.ts:48
function between(
order: ReadonlyArray<string>,
from: string | null,
to: string,
): ReadonlyArray<string>The ids between from and to in order, inclusive, in order's order.
Selection.bundleconst · packages/primitives/src/interaction/selection.ts:60
const bundle: Bundle.Bundle<
'Selection',
{
readonly mode: 'none' | 'single' | 'multiple'
readonly allowEmpty: boolean
},
{ readonly selected: readonly string[]; readonly anchor: string | null },
| { readonly _tag: 'Cleared' }
| { readonly _tag: 'Activated'; readonly id: string }
| {
readonly _tag: 'Ranged'
readonly id: string
readonly order: readonly string[]
}
| { readonly _tag: 'Replaced'; readonly ids: readonly string[] },
never,
never,
never,
void,
{},
{}
>Selection.Messageconst · packages/primitives/src/interaction/selection.ts:28
const Message: MessageUnion<{
readonly Activated: { readonly id: Schema.String }
readonly Ranged: {
readonly id: Schema.String
readonly order: Schema.$Array<Schema.String>
}
readonly Replaced: { readonly ids: Schema.$Array<Schema.String> }
readonly Cleared: {}
}>Selection.Modeconst · packages/primitives/src/interaction/selection.ts:17
const Mode: Schema.Literals<readonly ['single', 'multiple', 'none']>Selection.Modelconst · packages/primitives/src/interaction/selection.ts:20
const Model: Schema.Struct<{
readonly selected: Schema.$Array<Schema.String>
readonly anchor: Schema.NullOr<Schema.String>
}>