@weasel-js/gestures 1.10.1 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +236 -16
- package/dist/index.js +244 -34
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MenuShortcut } from '@weasel-js/menu';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Declarative gesture taxonomy. Single source of truth for:
|
|
3
5
|
* - which gestures hit-test (have a `.target` slot in the route string)
|
|
@@ -7,7 +9,7 @@
|
|
|
7
9
|
* Reflection, matcher, and inspector UI all read this table. Adding a new
|
|
8
10
|
* gesture name in one place updates every consumer.
|
|
9
11
|
*/
|
|
10
|
-
type GestureName = 'click' | 'pointerDown' | 'hover' | 'dblTap' | 'drag' | 'wheel' | 'pinch' | 'keyDown' | 'keyUp' | 'keyHeld' | 'contextMenu' | 'longPress' | 'multiTouch' | 'multiTouchTap' | 'drop' | 'paste';
|
|
12
|
+
type GestureName = 'click' | 'pointerDown' | 'hover' | 'dblTap' | 'drag' | 'wheel' | 'pinch' | 'keyDown' | 'keyUp' | 'keyHeld' | 'contextMenu' | 'longPress' | 'multiTouch' | 'multiTouchTap' | 'drop' | 'carry' | 'paste';
|
|
11
13
|
/**
|
|
12
14
|
* Gesture kinds an affordance claim can bar, in the spec vocabulary bindings
|
|
13
15
|
* are written in. `'pointer'` is one token because `pointerDown` / `click` /
|
|
@@ -79,10 +81,13 @@ type RoutePhase = 'initial' | 'engaged';
|
|
|
79
81
|
* argSlot = '(' argValue ')' -- whitespace inside parens is significant
|
|
80
82
|
* targetSlot = '=>' WS targetValue -- omitted slot defaults to '*' for hasTarget
|
|
81
83
|
* modSlot = modAtom (WS modAtom)*
|
|
82
|
-
* modAtom = sigil modName
|
|
84
|
+
* modAtom = sigil (modName | 'held')
|
|
83
85
|
* sigil = '+' | '?' -- ! @ # $ % ^ & * reserved as id-prefix
|
|
84
86
|
* modName = 'mod' | 'shift' | 'alt' | 'ctrl' | 'meta'
|
|
85
87
|
*
|
|
88
|
+
* `held` is a pressed button, read as a modifier is: `?held` a button may be
|
|
89
|
+
* held, `+held` one must be, absent none may. Only `hover` takes it.
|
|
90
|
+
*
|
|
86
91
|
* The truly-loose form (any channel, any phase) is `[*:*]`.
|
|
87
92
|
*
|
|
88
93
|
* Examples:
|
|
@@ -150,6 +155,9 @@ interface ParsedRoute {
|
|
|
150
155
|
target: string | undefined;
|
|
151
156
|
/** Structured modifier requirements; empty map = "no modifiers held". */
|
|
152
157
|
modifiers: ParsedModifiers;
|
|
158
|
+
/** Whether a pressed button may or must be held. Absent, none may. Only on
|
|
159
|
+
* `hover`. */
|
|
160
|
+
held?: ModRequirement;
|
|
153
161
|
}
|
|
154
162
|
/** Parse a route string into its slots, filling in the shorthand defaults the
|
|
155
163
|
* grammar defines (bare phases mean channel `&`; an omitted arg or target
|
|
@@ -336,7 +344,8 @@ interface PointerDownSpec {
|
|
|
336
344
|
}
|
|
337
345
|
/**
|
|
338
346
|
* The pointer moving over the surface with no button pressed. Fires on every
|
|
339
|
-
* such move; a held pointer's moves belong to its drag and fire nothing here
|
|
347
|
+
* such move; a held pointer's moves belong to its drag and fire nothing here,
|
|
348
|
+
* unless `held` says otherwise.
|
|
340
349
|
*
|
|
341
350
|
* With `motion: 'leave'` it fires instead when the pointer passes out of what
|
|
342
351
|
* the binding targets: onto something its `target` does not match, or off the
|
|
@@ -347,11 +356,16 @@ interface PointerDownSpec {
|
|
|
347
356
|
* runs, not only the best one, and the move still reaches the hover-cursor
|
|
348
357
|
* pump. There is no press to own, so bind an immediate action, not an ongoing
|
|
349
358
|
* one. Its params carry `worldX` / `worldY`, `clientX` / `clientY`,
|
|
350
|
-
* `affordance`, `bodyTarget`, and `
|
|
359
|
+
* `affordance`, `bodyTarget`, `mods`, and `held`.
|
|
351
360
|
*/
|
|
352
361
|
interface HoverSpec {
|
|
353
362
|
kind: 'hover';
|
|
354
363
|
motion?: 'move' | 'leave';
|
|
364
|
+
/** Whether a pressed button may (`'optional'`) or must (`true`) be held, as
|
|
365
|
+
* `mods` says of a modifier; omitted, a held pointer's moves are not hovers.
|
|
366
|
+
* Such a binding still claims nothing, so the drag keeps its moves. Leaving
|
|
367
|
+
* the surface is a leave whether or not a button is held. */
|
|
368
|
+
held?: true | 'optional';
|
|
355
369
|
target?: TargetSpec;
|
|
356
370
|
mods?: ModSpec;
|
|
357
371
|
phase?: PhaseSpec;
|
|
@@ -397,6 +411,29 @@ interface DropSpec {
|
|
|
397
411
|
mods?: ModSpec;
|
|
398
412
|
phase?: PhaseSpec;
|
|
399
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* A press that began elsewhere on the page, carried over the canvas: a palette
|
|
416
|
+
* item dragged in, a row dragged out of a list. The in-app sibling of
|
|
417
|
+
* {@link DropSpec}, which is the OS's drag. A carry is begun with `startCarry`.
|
|
418
|
+
* `types` filters by the payload's `type`, as globs; omitted or empty matches
|
|
419
|
+
* any carry.
|
|
420
|
+
*
|
|
421
|
+
* An ongoing action bound here starts when the carry comes over the surface:
|
|
422
|
+
* its moves update it, the release commits it, and leaving the surface or
|
|
423
|
+
* canceling the press cancels it. An immediate action fires once, on the
|
|
424
|
+
* release.
|
|
425
|
+
*
|
|
426
|
+
* `target` is matched against what is under the carry. With one, an ongoing
|
|
427
|
+
* action starts on the first step that is over its target, as the carry comes
|
|
428
|
+
* over or as it moves on, and an immediate action fires only on a release over it.
|
|
429
|
+
*/
|
|
430
|
+
interface CarrySpec {
|
|
431
|
+
kind: 'carry';
|
|
432
|
+
types?: string[];
|
|
433
|
+
target?: TargetSpec;
|
|
434
|
+
mods?: ModSpec;
|
|
435
|
+
phase?: PhaseSpec;
|
|
436
|
+
}
|
|
400
437
|
/** System-clipboard paste of external content. Same `types` semantics as
|
|
401
438
|
* {@link DropSpec} — omitted or empty = matches any paste. */
|
|
402
439
|
interface PasteSpec {
|
|
@@ -406,7 +443,7 @@ interface PasteSpec {
|
|
|
406
443
|
phase?: PhaseSpec;
|
|
407
444
|
}
|
|
408
445
|
/** The full union of supported gesture spec kinds. */
|
|
409
|
-
type GestureSpec = KeySpec | KeyHeldSpec | WheelSpec | PinchSpec | ClickSpec | DoubleClickSpec | ContextMenuSpec | DragSpec | PointerDownSpec | HoverSpec | LongPressSpec | MultiTouchSpec | MultiTouchTapSpec | DropSpec | PasteSpec;
|
|
446
|
+
type GestureSpec = KeySpec | KeyHeldSpec | WheelSpec | PinchSpec | ClickSpec | DoubleClickSpec | ContextMenuSpec | DragSpec | PointerDownSpec | HoverSpec | LongPressSpec | MultiTouchSpec | MultiTouchTapSpec | DropSpec | CarrySpec | PasteSpec;
|
|
410
447
|
|
|
411
448
|
/**
|
|
412
449
|
* Mini-grammar for the `arg` slot of `keyDown` / `keyUp` routes.
|
|
@@ -447,7 +484,7 @@ declare function keyRouteToSpec(r: ParsedKeyRoute): KeySpec;
|
|
|
447
484
|
* Wildcards become omitted fields: a `*` target, direction or MIME list, and a
|
|
448
485
|
* `[*:*]` phase slot. `[*]` is `[&:*]`, which an ambient binding never
|
|
449
486
|
* matches, so it stays a phase atom. A `keyDown` / `keyHeld` arg is read as a
|
|
450
|
-
* key route, so `keyDown(z?shift)` yields `mods.shift: 'optional'`; a drop or
|
|
487
|
+
* key route, so `keyDown(z?shift)` yields `mods.shift: 'optional'`; a drop, carry, or
|
|
451
488
|
* paste arg is a `|`-separated MIME list.
|
|
452
489
|
*
|
|
453
490
|
* Throws on a route no spec can express: `keyUp`, a key or finger-count
|
|
@@ -519,13 +556,6 @@ declare function modifierComboToParsed(key: ModifierCombo): ParsedModifiers;
|
|
|
519
556
|
* `name=req` pairs joined by `&`. */
|
|
520
557
|
declare function canonicalModifiers(mods: ParsedModifiers): string;
|
|
521
558
|
|
|
522
|
-
/** Keyboard/pointer modifier flags carried by every {@link InputEvent} arm. */
|
|
523
|
-
interface EventModifiers {
|
|
524
|
-
altKey: boolean;
|
|
525
|
-
ctrlKey: boolean;
|
|
526
|
-
metaKey: boolean;
|
|
527
|
-
shiftKey: boolean;
|
|
528
|
-
}
|
|
529
559
|
/**
|
|
530
560
|
* Body-target classification from the scene hit-test. Populated by
|
|
531
561
|
* `useGestureDispatcher` when a `classifyTarget` thunk is supplied to its
|
|
@@ -552,6 +582,28 @@ interface BodyClassification {
|
|
|
552
582
|
/** Semantic kind of the hit body. Undefined on empty canvas, and undefined
|
|
553
583
|
* on a body whose kind the scene can't name — never guessed. */
|
|
554
584
|
kind?: BodyKind;
|
|
585
|
+
/** The node classified. Matching ignores it. */
|
|
586
|
+
id?: string;
|
|
587
|
+
/** What a double-click at this point names, where that is not the body hit: the group a hit
|
|
588
|
+
* member belongs to. A double click's targets match against it. Absent, the hit is named. */
|
|
589
|
+
doubleClick?: {
|
|
590
|
+
body: BodyTarget;
|
|
591
|
+
kind?: BodyKind;
|
|
592
|
+
id?: string;
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
/** The body a double-click names, as a press carries it to the double click it composes. */
|
|
596
|
+
interface DoubleClickBody {
|
|
597
|
+
bodyTarget: BodyTarget;
|
|
598
|
+
bodyKind?: BodyKind;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/** Keyboard/pointer modifier flags carried by every {@link InputEvent} arm. */
|
|
602
|
+
interface EventModifiers {
|
|
603
|
+
altKey: boolean;
|
|
604
|
+
ctrlKey: boolean;
|
|
605
|
+
metaKey: boolean;
|
|
606
|
+
shiftKey: boolean;
|
|
555
607
|
}
|
|
556
608
|
/** A keystroke. */
|
|
557
609
|
interface KeyEvent extends EventModifiers {
|
|
@@ -760,6 +812,8 @@ interface HoverEvent extends EventModifiers {
|
|
|
760
812
|
from?: HoverWhere;
|
|
761
813
|
/** The pointer has left the surface. Where it is and what it is over are its last move's. */
|
|
762
814
|
off?: boolean;
|
|
815
|
+
/** A button was held through this move. Never set on `off`. */
|
|
816
|
+
held?: boolean;
|
|
763
817
|
/** World-space position of the pointer. */
|
|
764
818
|
x: number;
|
|
765
819
|
y: number;
|
|
@@ -850,6 +904,25 @@ interface DropEvent extends EventModifiers {
|
|
|
850
904
|
clientX?: number;
|
|
851
905
|
clientY?: number;
|
|
852
906
|
}
|
|
907
|
+
/** A carry over the canvas (`startCarry`). `stage` is what it did here: came
|
|
908
|
+
* over, moved, was released, or left — off the surface, or canceled on it. */
|
|
909
|
+
interface CarryEvent extends EventModifiers {
|
|
910
|
+
kind: 'carry';
|
|
911
|
+
stage: 'enter' | 'move' | 'drop' | 'leave';
|
|
912
|
+
pointerId?: number;
|
|
913
|
+
/** The payload's type, which a spec's `types` globs filter, and the payload. */
|
|
914
|
+
type: string;
|
|
915
|
+
value: unknown;
|
|
916
|
+
/** World-space position (post view transform). */
|
|
917
|
+
x: number;
|
|
918
|
+
y: number;
|
|
919
|
+
clientX: number;
|
|
920
|
+
clientY: number;
|
|
921
|
+
/** What is under the carry, classified as a press there would be. */
|
|
922
|
+
affordance?: unknown;
|
|
923
|
+
bodyTarget?: BodyTarget;
|
|
924
|
+
bodyKind?: BodyKind;
|
|
925
|
+
}
|
|
853
926
|
/** External content pasted from the system clipboard. Carries no point. */
|
|
854
927
|
interface PasteEvent extends EventModifiers {
|
|
855
928
|
kind: 'paste';
|
|
@@ -864,7 +937,7 @@ interface PasteEvent extends EventModifiers {
|
|
|
864
937
|
* The `affordance?` field on {@link PointerDownEvent} is widened to `unknown`
|
|
865
938
|
* in this package — the kit narrows it back to `AffordanceHit` at consumption.
|
|
866
939
|
*/
|
|
867
|
-
type InputEvent = KeyEvent | KeyHeldEvent | WheelEvent | PinchEvent | PointerDownEvent | PointerMoveEvent | HoverEvent | PointerUpEvent | PointerCancelEvent | ClickEvent | DoubleClickEvent | ContextMenuEvent | LongPressEvent | MultiTouchEvent | MultiTouchTapEvent | DropEvent | PasteEvent;
|
|
940
|
+
type InputEvent = KeyEvent | KeyHeldEvent | WheelEvent | PinchEvent | PointerDownEvent | PointerMoveEvent | HoverEvent | PointerUpEvent | PointerCancelEvent | ClickEvent | DoubleClickEvent | ContextMenuEvent | LongPressEvent | MultiTouchEvent | MultiTouchTapEvent | DropEvent | CarryEvent | PasteEvent;
|
|
868
941
|
|
|
869
942
|
/**
|
|
870
943
|
* The stylus fields `src` carries, as a spread-able partial: a sample that
|
|
@@ -998,6 +1071,134 @@ declare function matchIngestTypes(items: readonly {
|
|
|
998
1071
|
*/
|
|
999
1072
|
declare function isApplePlatform(): boolean;
|
|
1000
1073
|
|
|
1074
|
+
/** One key of a shortcut as a keyboard prints it. */
|
|
1075
|
+
interface KeyLegend {
|
|
1076
|
+
/** Glyph drawn for the key (modifier or key). */
|
|
1077
|
+
label: string;
|
|
1078
|
+
/** When true, the key may be held but is not required to trigger the action
|
|
1079
|
+
* (e.g. an optional modifier). Defaults to false. */
|
|
1080
|
+
optional?: boolean;
|
|
1081
|
+
}
|
|
1082
|
+
/** Logical modifier name. Matches the kit's `ModifierKey` in shape — kept as a
|
|
1083
|
+
* local type so `weasel-ui` stays independent of `@weasel-js/core`. */
|
|
1084
|
+
type LogicalMod = 'mod' | 'shift' | 'alt' | 'ctrl' | 'meta';
|
|
1085
|
+
/** Detected (or overridden) platform. `'mod'` resolves to ⌘ on macOS,
|
|
1086
|
+
* Ctrl on Windows / Linux. */
|
|
1087
|
+
type Platform = 'macos' | 'windows' | 'linux';
|
|
1088
|
+
/** Visual form of a modifier or named-key label.
|
|
1089
|
+
*
|
|
1090
|
+
* - `'auto'` (default): the per-entry, per-platform default — whatever
|
|
1091
|
+
* label is actually printed on the physical key. macOS keys show the
|
|
1092
|
+
* Apple glyphs (⌘ ⌥ ⌃ ⇧ ⎋ ↵ ⇥). Windows keys mostly show text
|
|
1093
|
+
* (Ctrl, Alt, Shift) BUT the Win key shows its logo (⊞) and the
|
|
1094
|
+
* context-menu key shows ▤. Linux mirrors Windows with Super (⊞).
|
|
1095
|
+
* - `'symbol'` forces a glyph wherever the key has one: Apple's on macOS,
|
|
1096
|
+
* ISO/IEC 9995-7's elsewhere (⎈ Ctrl, ⎇ Alt, ⎋ Esc). A key with no
|
|
1097
|
+
* symbol still falls back to text.
|
|
1098
|
+
* - `'text'` always spells the label out (Cmd / Option / Esc / Enter). */
|
|
1099
|
+
type LegendStyle = 'auto' | 'symbol' | 'text';
|
|
1100
|
+
/** A modifier to render, named platform-independently. */
|
|
1101
|
+
interface LogicalModSpec {
|
|
1102
|
+
name: LogicalMod;
|
|
1103
|
+
/** Marks this modifier as optional (may be held but isn't required).
|
|
1104
|
+
* Forwarded as the resulting `KeyLegend.optional`. */
|
|
1105
|
+
optional?: boolean;
|
|
1106
|
+
}
|
|
1107
|
+
/** Options for {@link keySpecsFromMods}. */
|
|
1108
|
+
interface KeySpecsFromModsOptions {
|
|
1109
|
+
/** Override OS detection. Defaults to {@link detectPlatform}. */
|
|
1110
|
+
platform?: Platform;
|
|
1111
|
+
/** Defaults to `'auto'`. Pass `'symbol'` or `'text'` to force a specific
|
|
1112
|
+
* style regardless of platform. */
|
|
1113
|
+
legend?: LegendStyle;
|
|
1114
|
+
/** Labels that replace the platform and legend tables', by a modifier's
|
|
1115
|
+
* logical name (`mod`, `shift`, `alt`, `ctrl`, `meta`) or a key's
|
|
1116
|
+
* `KeyboardEvent.key` (`Escape`, `Home`, `z`): a whole keyboard's worth
|
|
1117
|
+
* for a layout, a locale, or a keyboard of one's own. */
|
|
1118
|
+
labels?: KeyLabels;
|
|
1119
|
+
}
|
|
1120
|
+
/** Key labels by modifier name or `KeyboardEvent.key`. See {@link KeySpecsFromModsOptions.labels}. */
|
|
1121
|
+
type KeyLabels = Readonly<Record<string, string>>;
|
|
1122
|
+
/** Every label {@link keySpecsFromMods} can produce, on any platform and legend. */
|
|
1123
|
+
declare const MODIFIER_LABELS: ReadonlySet<string>;
|
|
1124
|
+
/** The platform whose key legends to draw. Whether `mod` is ⌘ comes from
|
|
1125
|
+
* `isApplePlatform`, the same read the dispatcher
|
|
1126
|
+
* matches `mod` with, so a keycap names the key that fires. With no
|
|
1127
|
+
* `navigator` (a server render) it answers `'macos'`, the kit's docs
|
|
1128
|
+
* convention; an unrecognized browser reads as `'linux'`. */
|
|
1129
|
+
declare function detectPlatform(): Platform;
|
|
1130
|
+
/**
|
|
1131
|
+
* Map a list of **logical** modifiers (`'mod'`, `'shift'`, …) to **visual**
|
|
1132
|
+
* `KeyLegend`s appropriate for the current platform — `'mod'` means "Cmd on
|
|
1133
|
+
* Mac, Ctrl on Win/Linux".
|
|
1134
|
+
*
|
|
1135
|
+
* ```ts
|
|
1136
|
+
* <KeySequence
|
|
1137
|
+
* keys={keySpecsFromMods([{ name: 'mod' }, { name: 'shift', optional: true }])}
|
|
1138
|
+
* />
|
|
1139
|
+
* ```
|
|
1140
|
+
*/
|
|
1141
|
+
declare function keySpecsFromMods(mods: readonly LogicalModSpec[], opts?: KeySpecsFromModsOptions): readonly KeyLegend[];
|
|
1142
|
+
/**
|
|
1143
|
+
* Render a raw `KeyboardEvent.key` value as a platform-appropriate
|
|
1144
|
+
* `KeyLegend`. Named non-modifier keys (Esc, Enter, Tab, Space, Backspace,
|
|
1145
|
+
* Delete, arrows) get the platform's conventional form. Letter / digit /
|
|
1146
|
+
* other keys pass through upper-cased.
|
|
1147
|
+
*
|
|
1148
|
+
* ```ts
|
|
1149
|
+
* keySpecFromKey('Escape', { platform: 'macos' }) // { label: '⎋' }
|
|
1150
|
+
* keySpecFromKey('Escape', { platform: 'windows' }) // { label: 'Esc' }
|
|
1151
|
+
* keySpecFromKey('p') // { label: 'P' }
|
|
1152
|
+
* ```
|
|
1153
|
+
*
|
|
1154
|
+
* Symbol mode off macOS draws ISO/IEC 9995-7's symbols where the key
|
|
1155
|
+
* has one, though Windows and Linux keyboards print the text form.
|
|
1156
|
+
*/
|
|
1157
|
+
declare function keySpecFromKey(raw: string, opts?: KeySpecsFromModsOptions & {
|
|
1158
|
+
optional?: boolean;
|
|
1159
|
+
}): KeyLegend;
|
|
1160
|
+
|
|
1161
|
+
/** A keyboard shortcut as the formatters read it: `@weasel-js/menu`'s `MenuShortcut`. */
|
|
1162
|
+
type ShortcutInput = MenuShortcut;
|
|
1163
|
+
/** Options for {@link formatShortcut} and {@link formatShortcutParts}. */
|
|
1164
|
+
interface FormatShortcutOptions {
|
|
1165
|
+
/** Defaults to the detected platform. */
|
|
1166
|
+
platform?: Platform;
|
|
1167
|
+
}
|
|
1168
|
+
/** Format a shortcut as an array of display chips, one per key: the
|
|
1169
|
+
* modifiers, then the key, each as the platform's keyboard prints it, so
|
|
1170
|
+
* `mod` is `⌘` on macOS and `Ctrl` elsewhere. UIs that want a boxed per-key
|
|
1171
|
+
* look render each chip in its own element. `shift: 'optional'` is treated
|
|
1172
|
+
* as falsy. */
|
|
1173
|
+
declare function formatShortcutParts(b: ShortcutInput | undefined, opts?: FormatShortcutOptions): readonly string[] | undefined;
|
|
1174
|
+
/** Format a shortcut as a single display string. Order: mod, shift, alt,
|
|
1175
|
+
* key. On macOS the glyphs run together (`⌘⇧Z`); elsewhere the keys are
|
|
1176
|
+
* spelled out and joined with `+` (`Ctrl+Shift+Z`). Returns `undefined` for
|
|
1177
|
+
* `undefined` input so callers can `??` a fallback. When `key` is an array,
|
|
1178
|
+
* the first element is used. `shift: 'optional'` is treated as falsy. */
|
|
1179
|
+
declare function formatShortcut(b: ShortcutInput | undefined, opts?: FormatShortcutOptions): string | undefined;
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* A shortcut as key legends, one per key, as `@weasel-js/ui`'s `KeySequence` draws them: mod, shift, alt, then the
|
|
1183
|
+
* key, each in the platform's own legend (`⌘` on macOS, `Ctrl` elsewhere).
|
|
1184
|
+
* `formatShortcutParts` is these labels as strings. `shift: 'optional'`
|
|
1185
|
+
* becomes an optional key; a key list
|
|
1186
|
+
* renders its first key. Returns `undefined` for no shortcut.
|
|
1187
|
+
*
|
|
1188
|
+
* ```tsx
|
|
1189
|
+
* <KeySequence keys={keySpecsFromShortcut({ key: 'z', mod: true, shift: true })} />
|
|
1190
|
+
* ```
|
|
1191
|
+
*/
|
|
1192
|
+
declare function keySpecsFromShortcut(shortcut: ShortcutInput | undefined, opts?: KeySpecsFromModsOptions): readonly KeyLegend[] | undefined;
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* The legend of the physical key a `KeyboardEvent.code` names (`KeyA`, `ShiftLeft`, `ArrowUp`), as
|
|
1196
|
+
* {@link keySpecFromKey} prints that key on the platform: `MetaLeft` is `⌘` on macOS and `⊞` on
|
|
1197
|
+
* Windows. Letters and punctuation print as a US keyboard prints them. `opts.labels` answers by code
|
|
1198
|
+
* first, then as it does for {@link keySpecFromKey} and {@link keySpecsFromMods}.
|
|
1199
|
+
*/
|
|
1200
|
+
declare function keySpecFromCode(code: string, opts?: KeySpecsFromModsOptions): KeyLegend;
|
|
1201
|
+
|
|
1001
1202
|
/**
|
|
1002
1203
|
* The nearest element `from` sits inside that can host a portalled overlay,
|
|
1003
1204
|
* or `null` when there is none and the body is the only answer.
|
|
@@ -1027,7 +1228,7 @@ declare function fixedSeat(from: Element | null | undefined): FixedSeat;
|
|
|
1027
1228
|
* [1] mods — count of required modifier keys (shift/alt/ctrl/meta/mod).
|
|
1028
1229
|
* `'optional'` does NOT count.
|
|
1029
1230
|
* [2] phase — how much the spec's `phase` narrows; see `phaseRank`.
|
|
1030
|
-
* [3] exact — per-kind tiebreak: 2 for a drop/paste spec with a
|
|
1231
|
+
* [3] exact — per-kind tiebreak: 2 for a drop/carry/paste spec with a
|
|
1031
1232
|
* non-empty `types` MIME filter, else 1.
|
|
1032
1233
|
*
|
|
1033
1234
|
* Identical tuples fall back to registration order in the matcher's
|
|
@@ -1102,6 +1303,8 @@ interface PressFacts extends EventModifiers {
|
|
|
1102
1303
|
affordance?: unknown;
|
|
1103
1304
|
bodyTarget?: BodyTarget;
|
|
1104
1305
|
bodyKind?: BodyKind;
|
|
1306
|
+
/** Replayed onto the double click in place of `bodyTarget` and `bodyKind`. */
|
|
1307
|
+
doubleClickBody?: DoubleClickBody;
|
|
1105
1308
|
}
|
|
1106
1309
|
/** Where and how a press was released, for the click it turned out to be. */
|
|
1107
1310
|
interface ReleaseFacts extends EventModifiers {
|
|
@@ -1184,6 +1387,13 @@ interface PointerSample extends EventModifiers, PointerSampleStylus {
|
|
|
1184
1387
|
clientY: number;
|
|
1185
1388
|
/** What the originating event was aimed at. */
|
|
1186
1389
|
target?: unknown;
|
|
1390
|
+
/**
|
|
1391
|
+
* When the input happened, on the recognizer clock's timeline: a DOM event's
|
|
1392
|
+
* `timeStamp` beside `performance.now()`. The windows between two inputs are
|
|
1393
|
+
* measured on it, so a long task that delays an event's handling does not
|
|
1394
|
+
* widen them. Read as the clock's `now()` when absent, 0, or ahead of it.
|
|
1395
|
+
*/
|
|
1396
|
+
timeStamp?: number;
|
|
1187
1397
|
}
|
|
1188
1398
|
/** A pointer going down, with what the host found under it. */
|
|
1189
1399
|
interface PressSample extends PointerSample {
|
|
@@ -1195,6 +1405,8 @@ interface PressSample extends PointerSample {
|
|
|
1195
1405
|
affordance?: unknown;
|
|
1196
1406
|
bodyTarget?: BodyTarget;
|
|
1197
1407
|
bodyKind?: BodyKind;
|
|
1408
|
+
/** What a double click this press completes lands on, where not the body hit. */
|
|
1409
|
+
doubleClickBody?: DoubleClickBody;
|
|
1198
1410
|
}
|
|
1199
1411
|
|
|
1200
1412
|
/**
|
|
@@ -1233,6 +1445,14 @@ interface PointerRecognizerOptions {
|
|
|
1233
1445
|
toSurface?: (client: Point) => Point;
|
|
1234
1446
|
/** Long-press hold time in ms, read at each press. Default `LONG_PRESS_MS`. */
|
|
1235
1447
|
longPressMs?: () => number | undefined;
|
|
1448
|
+
/** Longest gap in ms between two clicks of a double click, read at each click. Default `DOUBLE_CLICK_MAX_MS`. */
|
|
1449
|
+
doubleClickMs?: () => number | undefined;
|
|
1450
|
+
/** Farthest two clicks of a double click may land apart, in CSS px. Default `DOUBLE_CLICK_MAX_PX`. */
|
|
1451
|
+
doubleClickPx?: () => number | undefined;
|
|
1452
|
+
/** Farthest a multitouch tap's fingers may travel, in CSS px. Default `TAP_THRESHOLD_PX`. */
|
|
1453
|
+
tapPx?: () => number | undefined;
|
|
1454
|
+
/** Travel in CSS px that makes a press a drag, read at each move. Default `DRAG_THRESHOLD_PX`. */
|
|
1455
|
+
dragPx?: () => number | undefined;
|
|
1236
1456
|
clicks?: ClickMemory;
|
|
1237
1457
|
observer?: RecognizerObserver;
|
|
1238
1458
|
}
|
|
@@ -1303,4 +1523,4 @@ declare function activatesFocusedControl(e: KeyboardEvent): boolean;
|
|
|
1303
1523
|
*/
|
|
1304
1524
|
declare function focusedControlOwnsKey(e: KeyboardEvent): boolean;
|
|
1305
1525
|
|
|
1306
|
-
export { ACTIVE_SIGILS, type BodyClassification, type BodyKind, type BodyTarget, CONTROL_SELECTOR, type ChannelRef, type ClaimableGesture, type ClickEvent, type ClickMemory, type ClickObserver, type ClickSpec, type ContextMenuEvent, type ContextMenuSpec, DOUBLE_CLICK_MAX_MS, DOUBLE_CLICK_MAX_PX, DRAG_THRESHOLD_PX, type DescribeRouteOptions, type DoubleClickEvent, type DoubleClickSpec, type DragSpec, type DropEvent, type DropSpec, type EventModifiers, type FixedSeat, GESTURE_DESCRIPTORS, type GestureArgSpec, type GestureDescriptor, type GestureName, type GestureSpec, type HeldPointers, type HeldPress, type HoverEvent, type HoverSpec, type HoverWhere, type IngestItem, type InputEvent, type KeyEvent, type KeyHeldEvent, type KeyHeldSpec, type KeySpec, LONG_PRESS_MS, type LongPressEvent, type LongPressSpec, MOD_NAME_SET, type ModRequirement, type ModSpec, type ModifierCombo, type ModifierKey, type ModifiersEvent, type MultiTouchEvent, type MultiTouchGeometry, type MultiTouchSpec, type MultiTouchTapEvent, type MultiTouchTapSpec, type OptionalMod, type ParsedKeyRoute, type ParsedModifiers, type ParsedRoute, type PasteEvent, type PasteSpec, type PhaseAtom, type PhaseContext, type PhaseSpec, type PinchEvent, type PinchSpec, type Point, type PointerCancelEvent, type PointerDownEvent, type PointerDownSpec, type PointerIdentity, type PointerMoveEvent, type PointerRecognizer, type PointerRecognizerOptions, type PointerSample, type PointerSampleStylus, type PointerUpEvent, type PressFacts, type PressSample, RESERVED_ID_NAMES, RESERVED_ID_PREFIXES, RESERVED_SIGILS, ROUTE_FIELD_DEFINITIONS, ROUTE_TERMS, type RecognizerClock, type RecognizerObserver, type RecognizerSink, type ReleaseFacts, type ReleaseOutcome, type RouteDescriptionPart, type RouteFieldName, type RoutePhase, type RouteTermLabel, TAP_THRESHOLD_PX, type TargetPredicate, type TargetSpec, type TargetSpecForm, UNKNOWN_MIME, VALID_MOD_NAMES, type WheelEvent, type WheelSpec, activatesFocusedControl, bodyPredicate, canonicalModifiers, clickEvents, collapseShiftPairs, createPointerRecognizer, describeRoute, describeRouteParts, fixedSeat, focusedControlOwnsKey, formatKeyRoute, formatPhaseAtom, formatRoute, getGestureDescriptor, heldPointers, hitPredicate, isApplePlatform, isEditableTarget, isInControlWithin, isKnownGestureName, keyRouteToSpec, longPressEvents, matchIngestTypes, matchKey, matchModifiers, matchPhase, matchSpec, matchTarget, mimeMatchesGlob, modifierComboToParsed, mods, multiTouchGeometry, nearestPortalHost, parseKeyRoute, parseRoute, parseTargetSpec, pastDragThreshold, routeGestureForSpecKind, routeToSpec, specKindForRouteGesture, specificity, stylusOf };
|
|
1526
|
+
export { ACTIVE_SIGILS, type BodyClassification, type BodyKind, type BodyTarget, CONTROL_SELECTOR, type CarryEvent, type CarrySpec, type ChannelRef, type ClaimableGesture, type ClickEvent, type ClickMemory, type ClickObserver, type ClickSpec, type ContextMenuEvent, type ContextMenuSpec, DOUBLE_CLICK_MAX_MS, DOUBLE_CLICK_MAX_PX, DRAG_THRESHOLD_PX, type DescribeRouteOptions, type DoubleClickBody, type DoubleClickEvent, type DoubleClickSpec, type DragSpec, type DropEvent, type DropSpec, type EventModifiers, type FixedSeat, type FormatShortcutOptions, GESTURE_DESCRIPTORS, type GestureArgSpec, type GestureDescriptor, type GestureName, type GestureSpec, type HeldPointers, type HeldPress, type HoverEvent, type HoverSpec, type HoverWhere, type IngestItem, type InputEvent, type KeyEvent, type KeyHeldEvent, type KeyHeldSpec, type KeyLabels, type KeyLegend, type KeySpec, type KeySpecsFromModsOptions, LONG_PRESS_MS, type LegendStyle, type LogicalMod, type LogicalModSpec, type LongPressEvent, type LongPressSpec, MODIFIER_LABELS, MOD_NAME_SET, type ModRequirement, type ModSpec, type ModifierCombo, type ModifierKey, type ModifiersEvent, type MultiTouchEvent, type MultiTouchGeometry, type MultiTouchSpec, type MultiTouchTapEvent, type MultiTouchTapSpec, type OptionalMod, type ParsedKeyRoute, type ParsedModifiers, type ParsedRoute, type PasteEvent, type PasteSpec, type PhaseAtom, type PhaseContext, type PhaseSpec, type PinchEvent, type PinchSpec, type Platform, type Point, type PointerCancelEvent, type PointerDownEvent, type PointerDownSpec, type PointerIdentity, type PointerMoveEvent, type PointerRecognizer, type PointerRecognizerOptions, type PointerSample, type PointerSampleStylus, type PointerUpEvent, type PressFacts, type PressSample, RESERVED_ID_NAMES, RESERVED_ID_PREFIXES, RESERVED_SIGILS, ROUTE_FIELD_DEFINITIONS, ROUTE_TERMS, type RecognizerClock, type RecognizerObserver, type RecognizerSink, type ReleaseFacts, type ReleaseOutcome, type RouteDescriptionPart, type RouteFieldName, type RoutePhase, type RouteTermLabel, type ShortcutInput, TAP_THRESHOLD_PX, type TargetPredicate, type TargetSpec, type TargetSpecForm, UNKNOWN_MIME, VALID_MOD_NAMES, type WheelEvent, type WheelSpec, activatesFocusedControl, bodyPredicate, canonicalModifiers, clickEvents, collapseShiftPairs, createPointerRecognizer, describeRoute, describeRouteParts, detectPlatform, fixedSeat, focusedControlOwnsKey, formatKeyRoute, formatPhaseAtom, formatRoute, formatShortcut, formatShortcutParts, getGestureDescriptor, heldPointers, hitPredicate, isApplePlatform, isEditableTarget, isInControlWithin, isKnownGestureName, keyRouteToSpec, keySpecFromCode, keySpecFromKey, keySpecsFromMods, keySpecsFromShortcut, longPressEvents, matchIngestTypes, matchKey, matchModifiers, matchPhase, matchSpec, matchTarget, mimeMatchesGlob, modifierComboToParsed, mods, multiTouchGeometry, nearestPortalHost, parseKeyRoute, parseRoute, parseTargetSpec, pastDragThreshold, routeGestureForSpecKind, routeToSpec, specKindForRouteGesture, specificity, stylusOf };
|