@astryxdesign/core 0.7.8-canary.fbb81c6 → 0.7.8
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/CHANGELOG.md +132 -0
- package/dist/ClickableCard/ClickableCard.d.ts +1 -1
- package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
- package/dist/ClickableCard/ClickableCard.js +1 -5
- package/dist/DateInput/PickerWheel.d.ts.map +1 -1
- package/dist/DateInput/PickerWheel.js +1 -7
- package/dist/DropdownMenu/DropdownMenu.d.ts +1 -9
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +4 -9
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +2 -3
- package/dist/DropdownMenu/DropdownMenuItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuItem.js +2 -3
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioItem.js +2 -3
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +2 -3
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +1 -6
- package/dist/Layer/preserveAnimations.d.ts +5 -1
- package/dist/Layer/preserveAnimations.d.ts.map +1 -1
- package/dist/Layer/preserveAnimations.js +214 -12
- package/dist/MoreMenu/MoreMenu.d.ts +3 -5
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/SelectableCard/SelectableCard.d.ts +1 -1
- package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
- package/dist/SelectableCard/SelectableCard.js +1 -5
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +1 -3
- package/dist/astryx.css +2 -6
- package/dist/hooks/menuPressGesture.d.ts +21 -132
- package/dist/hooks/menuPressGesture.d.ts.map +1 -1
- package/dist/hooks/menuPressGesture.js +30 -155
- package/dist/hooks/useClickableContainer.d.ts +5 -19
- package/dist/hooks/useClickableContainer.d.ts.map +1 -1
- package/dist/hooks/useClickableContainer.js +5 -28
- package/dist/hooks/useMenuPress.d.ts +1 -34
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +5 -93
- package/dist/motion/transientCopy.d.ts +2 -4
- package/dist/motion/transientCopy.d.ts.map +1 -1
- package/dist/motion/transientCopy.js +5 -34
- package/dist/motion/uikit/gestures.d.ts +0 -41
- package/dist/motion/uikit/gestures.d.ts.map +1 -1
- package/dist/motion/uikit/gestures.js +0 -25
- package/dist/motion/uikit/index.d.ts +1 -1
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +1 -1
- package/dist/utils/pressFeedback.d.ts +0 -7
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +1 -16
- package/package.json +5 -5
- package/src/ClickableCard/ClickableCard.tsx +1 -8
- package/src/DateInput/PickerWheel.tsx +2 -7
- package/src/DropdownMenu/DropdownMenu.doc.mjs +2 -1
- package/src/DropdownMenu/DropdownMenu.tsx +5 -29
- package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +1 -5
- package/src/DropdownMenu/DropdownMenuItem.tsx +4 -8
- package/src/DropdownMenu/DropdownMenuRadioItem.tsx +1 -5
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +1 -5
- package/src/Item/Item.tsx +5 -15
- package/src/Layer/preserveAnimations.ts +275 -12
- package/src/MoreMenu/MoreMenu.doc.mjs +4 -2
- package/src/MoreMenu/MoreMenu.tsx +3 -5
- package/src/SelectableCard/SelectableCard.tsx +1 -8
- package/src/TreeList/TreeListItem.tsx +6 -8
- package/src/hooks/menuPressGesture.ts +38 -243
- package/src/hooks/useClickableContainer.doc.mjs +2 -8
- package/src/hooks/useClickableContainer.ts +6 -52
- package/src/hooks/useMenuPress.ts +11 -118
- package/src/motion/MEASUREMENTS.md +0 -11
- package/src/motion/transientCopy.ts +5 -45
- package/src/motion/uikit/gestures.ts +0 -22
- package/src/motion/uikit/index.ts +0 -1
- package/src/utils/pressFeedback.ts +1 -16
- package/dist/hooks/menuPressValues.d.ts +0 -16
- package/dist/hooks/menuPressValues.d.ts.map +0 -1
- package/dist/hooks/menuPressValues.js +0 -18
- package/dist/motion/carryAnimations.d.ts +0 -58
- package/dist/motion/carryAnimations.d.ts.map +0 -1
- package/dist/motion/carryAnimations.js +0 -305
- package/dist/privateAttributes/menuPressLit.stylex.d.ts +0 -52
- package/dist/privateAttributes/menuPressLit.stylex.d.ts.map +0 -1
- package/dist/privateAttributes/menuPressLit.stylex.js +0 -99
- package/src/hooks/menuPressValues.ts +0 -18
- package/src/motion/carryAnimations.ts +0 -389
- package/src/privateAttributes/menuPressLit.stylex.ts +0 -104
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
* @file useMenuPress.ts
|
|
7
7
|
* @input The menu root, its trigger, the enabled-row selector, and callbacks
|
|
8
8
|
* for opening, highlighting, activating and dismissing
|
|
9
|
-
* @output useMenuPress, the marker attributes, the activation mark
|
|
10
|
-
* internal useDropdownMenuPress entry with its touch model
|
|
9
|
+
* @output useMenuPress, the marker attributes, and the activation mark
|
|
11
10
|
* @position Core hook for DropdownMenu, ContextMenu, DropdownMenuSubMenu,
|
|
12
11
|
* Selector and MenuBottomSheetActionList. The transition table lives in
|
|
13
12
|
* menuPressGesture.ts.
|
|
@@ -30,10 +29,10 @@ import {
|
|
|
30
29
|
import {currentGesture} from '../Layer/gestureCounter';
|
|
31
30
|
import {
|
|
32
31
|
IDLE_MENU_PRESS,
|
|
33
|
-
|
|
34
|
-
type
|
|
35
|
-
type
|
|
36
|
-
type
|
|
32
|
+
menuPressStep,
|
|
33
|
+
type MenuPressEffect,
|
|
34
|
+
type MenuPressEvent,
|
|
35
|
+
type MenuPressGesture,
|
|
37
36
|
type MenuPressPointerType,
|
|
38
37
|
} from './menuPressGesture';
|
|
39
38
|
import {MENU_PRESS_MARKER} from './menuPressMarker';
|
|
@@ -46,12 +45,6 @@ import {edgeAutoscroll} from '../utils/edgeAutoscroll';
|
|
|
46
45
|
import {focusForLastInput} from '../utils/focusReturn';
|
|
47
46
|
import {useInteractionModalityTrackingFor} from '../utils/interactionModality';
|
|
48
47
|
import {LONG_PRESS_DURATION_MS} from '../motion/uikit/longPress';
|
|
49
|
-
import {
|
|
50
|
-
clearMenuPressLit,
|
|
51
|
-
holdMenuPressPaint,
|
|
52
|
-
markMenuPressLit,
|
|
53
|
-
releaseMenuPressPaint,
|
|
54
|
-
} from '../privateAttributes/menuPressLit.stylex';
|
|
55
48
|
import {
|
|
56
49
|
__resetClickGuardForTest,
|
|
57
50
|
armClickGuard,
|
|
@@ -242,44 +235,6 @@ interface ResolvedPoint {
|
|
|
242
235
|
isOnTrigger: boolean;
|
|
243
236
|
}
|
|
244
237
|
|
|
245
|
-
/**
|
|
246
|
-
* DropdownMenu's options for the press model: everything the public hook
|
|
247
|
-
* takes, plus its touch model. DropdownMenu reaches the touch model through
|
|
248
|
-
* its `presentation`, so the public hook has no such option.
|
|
249
|
-
*
|
|
250
|
-
* @internal
|
|
251
|
-
*/
|
|
252
|
-
export interface DropdownMenuPressOptions extends UseMenuPressOptions {
|
|
253
|
-
/**
|
|
254
|
-
* How the finger that opened the menu from the trigger picks.
|
|
255
|
-
* `'pointer'`: its opening press follows the settle rule. `'uikit'`: it
|
|
256
|
-
* picks only after UIMenu's handoff distance, so the row that appeared
|
|
257
|
-
* under it never acts on a still lift. A mouse is unaffected.
|
|
258
|
-
* @default 'pointer'
|
|
259
|
-
*/
|
|
260
|
-
touchModel?: 'pointer' | 'uikit';
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* What core's own menus get from {@link useDropdownMenuPress}: the public
|
|
265
|
-
* return. Not exported from the hooks entry point.
|
|
266
|
-
*
|
|
267
|
-
* @internal
|
|
268
|
-
*/
|
|
269
|
-
export type DropdownMenuPressReturn = UseMenuPressReturn;
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Where a pointer is, for a finger's handoff distance. Positions reach the
|
|
273
|
-
* machine only under `touchModel: 'uikit'`. Without them, it keeps the settle
|
|
274
|
-
* rule.
|
|
275
|
-
*/
|
|
276
|
-
function handoffPosition(
|
|
277
|
-
event: PointerEvent,
|
|
278
|
-
hasHandoff: boolean,
|
|
279
|
-
): {x?: number; y?: number} {
|
|
280
|
-
return hasHandoff ? {x: event.clientX, y: event.clientY} : {};
|
|
281
|
-
}
|
|
282
|
-
|
|
283
238
|
/**
|
|
284
239
|
* The press model for a menu: the row under the release acts, the highlight
|
|
285
240
|
* follows a held pointer, and a mouse opens the menu on press.
|
|
@@ -316,30 +271,13 @@ function handoffPosition(
|
|
|
316
271
|
* ```
|
|
317
272
|
*/
|
|
318
273
|
export function useMenuPress(options: UseMenuPressOptions): UseMenuPressReturn {
|
|
319
|
-
// The touch model is DropdownMenu's alone; an untyped caller's
|
|
320
|
-
// `touchModel` does not reach the model.
|
|
321
|
-
const {touchModel: _touchModel, ...publicOptions} =
|
|
322
|
-
options as DropdownMenuPressOptions;
|
|
323
|
-
return useDropdownMenuPress({...publicOptions, touchModel: 'pointer'});
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* The press model with DropdownMenu's touch model
|
|
328
|
-
* ({@link DropdownMenuPressOptions.touchModel}). Not exported from the hooks
|
|
329
|
-
* entry point.
|
|
330
|
-
*
|
|
331
|
-
* @internal
|
|
332
|
-
*/
|
|
333
|
-
export function useDropdownMenuPress(
|
|
334
|
-
options: DropdownMenuPressOptions,
|
|
335
|
-
): DropdownMenuPressReturn {
|
|
336
274
|
const optionsRef = useRef(options);
|
|
337
275
|
optionsRef.current = options;
|
|
338
276
|
// The highlight, and the hover focus of the rows in this menu, follow the
|
|
339
277
|
// last input, which this tracks for the menu's own document.
|
|
340
278
|
useInteractionModalityTrackingFor(options.menuRef);
|
|
341
279
|
|
|
342
|
-
const gestureRef = useRef<
|
|
280
|
+
const gestureRef = useRef<MenuPressGesture<HTMLElement>>(IDLE_MENU_PRESS);
|
|
343
281
|
const pointerIdRef = useRef<number | null>(null);
|
|
344
282
|
const detachRef = useRef<(() => void) | null>(null);
|
|
345
283
|
// `useLongPress` detects the held finger, as in ContextMenu, so the hold
|
|
@@ -436,18 +374,8 @@ export function useDropdownMenuPress(
|
|
|
436
374
|
autoscrollRef.current = null;
|
|
437
375
|
}, [autoscroll]);
|
|
438
376
|
|
|
439
|
-
const litRowRef = useRef<HTMLElement | null>(null);
|
|
440
|
-
const heldMenuRef = useRef<HTMLElement | null>(null);
|
|
441
377
|
const endGesture = useCallback(() => {
|
|
442
378
|
longPressApiRef.current?.cancel();
|
|
443
|
-
if (litRowRef.current != null) {
|
|
444
|
-
clearMenuPressLit(litRowRef.current);
|
|
445
|
-
litRowRef.current = null;
|
|
446
|
-
}
|
|
447
|
-
if (heldMenuRef.current != null) {
|
|
448
|
-
releaseMenuPressPaint(heldMenuRef.current);
|
|
449
|
-
heldMenuRef.current = null;
|
|
450
|
-
}
|
|
451
379
|
touchMovePreventerRef.current?.();
|
|
452
380
|
touchMovePreventerRef.current = null;
|
|
453
381
|
stopAutoscroll();
|
|
@@ -460,34 +388,7 @@ export function useDropdownMenuPress(
|
|
|
460
388
|
|
|
461
389
|
const highlight = useCallback(
|
|
462
390
|
(row: HTMLElement | null) => {
|
|
463
|
-
// A held finger or pen marks the row it lights, for the row's pressed
|
|
464
|
-
// paint. A held mouse keeps the hover tint, as on a desktop.
|
|
465
|
-
const gesture = gestureRef.current;
|
|
466
|
-
const isHeld =
|
|
467
|
-
gesture.phase !== 'idle' && gesture.pointerType !== 'mouse';
|
|
468
|
-
const lit = isHeld ? row : null;
|
|
469
|
-
if (litRowRef.current !== lit) {
|
|
470
|
-
if (litRowRef.current != null) {
|
|
471
|
-
clearMenuPressLit(litRowRef.current);
|
|
472
|
-
}
|
|
473
|
-
litRowRef.current = lit;
|
|
474
|
-
if (lit != null) {
|
|
475
|
-
markMenuPressLit(lit);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
391
|
const {onHighlight, menuRef} = optionsRef.current;
|
|
479
|
-
// The row the press began on stays :active where a pointer hovers, so
|
|
480
|
-
// the menu holds every row but the lit one off that paint.
|
|
481
|
-
const held = isHeld ? menuRef.current : null;
|
|
482
|
-
if (heldMenuRef.current !== held) {
|
|
483
|
-
if (heldMenuRef.current != null) {
|
|
484
|
-
releaseMenuPressPaint(heldMenuRef.current);
|
|
485
|
-
}
|
|
486
|
-
heldMenuRef.current = held;
|
|
487
|
-
if (held != null) {
|
|
488
|
-
holdMenuPressPaint(held);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
392
|
if (onHighlight != null) {
|
|
492
393
|
onHighlight(row);
|
|
493
394
|
return;
|
|
@@ -548,13 +449,13 @@ export function useDropdownMenuPress(
|
|
|
548
449
|
|
|
549
450
|
// Declared before `step` so the mutual recursion through refs type-checks.
|
|
550
451
|
const stepRef = useRef<
|
|
551
|
-
(event:
|
|
452
|
+
(event: MenuPressEvent<HTMLElement>, native?: PointerEvent) => void
|
|
552
453
|
>(() => {});
|
|
553
454
|
|
|
554
455
|
const applyEffect = useCallback(
|
|
555
456
|
(
|
|
556
|
-
effect:
|
|
557
|
-
gesture:
|
|
457
|
+
effect: MenuPressEffect<HTMLElement>,
|
|
458
|
+
gesture: MenuPressGesture<HTMLElement>,
|
|
558
459
|
native: PointerEvent | undefined,
|
|
559
460
|
) => {
|
|
560
461
|
const doc = getDocument();
|
|
@@ -610,8 +511,8 @@ export function useDropdownMenuPress(
|
|
|
610
511
|
);
|
|
611
512
|
|
|
612
513
|
const step = useCallback(
|
|
613
|
-
(event:
|
|
614
|
-
const result =
|
|
514
|
+
(event: MenuPressEvent<HTMLElement>, native?: PointerEvent) => {
|
|
515
|
+
const result = menuPressStep(gestureRef.current, event);
|
|
615
516
|
gestureRef.current = result.gesture;
|
|
616
517
|
applyEffect(result.effect, result.gesture, native);
|
|
617
518
|
},
|
|
@@ -718,10 +619,6 @@ export function useDropdownMenuPress(
|
|
|
718
619
|
row: point.row,
|
|
719
620
|
isInMenu: point.isInMenu,
|
|
720
621
|
time: Date.now(),
|
|
721
|
-
...handoffPosition(
|
|
722
|
-
event,
|
|
723
|
-
optionsRef.current.touchModel === 'uikit',
|
|
724
|
-
),
|
|
725
622
|
},
|
|
726
623
|
event,
|
|
727
624
|
);
|
|
@@ -739,10 +636,6 @@ export function useDropdownMenuPress(
|
|
|
739
636
|
isInMenu: point.isInMenu,
|
|
740
637
|
isOnTrigger: point.isOnTrigger,
|
|
741
638
|
time: Date.now(),
|
|
742
|
-
...handoffPosition(
|
|
743
|
-
event,
|
|
744
|
-
optionsRef.current.touchModel === 'uikit',
|
|
745
|
-
),
|
|
746
639
|
},
|
|
747
640
|
event,
|
|
748
641
|
);
|
|
@@ -314,14 +314,3 @@ scroll view coasts with 0.25 × the pan's velocity plus 0.75 × its value one
|
|
|
314
314
|
event earlier (four HID releases; `velocity.scrollReleaseWeight`, which a
|
|
315
315
|
pan's `scrollVelocity()` reads). On UIKit, Reduce Motion with Prefer Cross-Fade changes
|
|
316
316
|
nothing on a picker; the Wheel follows design:reduced-motion instead.
|
|
317
|
-
|
|
318
|
-
## Menus (UIMenu)
|
|
319
|
-
|
|
320
|
-
Probe: the UIKit lab host app with a UIButton whose `UIMenu` is its primary
|
|
321
|
-
action (`showsMenuAsPrimaryAction`), three to twelve items, on a plain view
|
|
322
|
-
and inside a UIScrollView; the gesture-state, presentation-modifier,
|
|
323
|
-
display-link and feedback hooks; real HID touches.
|
|
324
|
-
|
|
325
|
-
| ID | Scene | Gesture | Extract | Method |
|
|
326
|
-
| ----- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------ |
|
|
327
|
-
| M-MN2 | button on a plain view | hold until the menu is open, then lift still; move 8 pt down, 8 pt right, 12 pt down, (7, 7), (8, 8) and lift; move 6 pt before the open and 6 pt after | row picked or not; handoff and list-selection recognizer states; highlighted row per frame: threshold, metric, where it is counted from | C |
|
|
@@ -15,12 +15,9 @@
|
|
|
15
15
|
* technology, carries no ids or test ids, joins no form or radio group (a
|
|
16
16
|
* copied checked radio would uncheck the live one), and its frames and media
|
|
17
17
|
* load nothing. Laying it out changes no ancestor's position, and a scaled
|
|
18
|
-
* host draws it at the old size.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* Laid in a host outside the element's own ancestors, it keeps what it
|
|
22
|
-
* inherited from them: its inherited properties and custom properties that
|
|
23
|
-
* differ from the host's are written on it.
|
|
18
|
+
* host draws it at the old size. Laid in a host outside the element's own
|
|
19
|
+
* ancestors, it keeps what it inherited from them: its inherited properties
|
|
20
|
+
* and custom properties that differ from the host's are written on it.
|
|
24
21
|
* Limits: a rule keyed on a removed `id`, or matched through an ancestor
|
|
25
22
|
* between the host and the element (`.collapsed .label`), does not style the
|
|
26
23
|
* copy as it styled the element; and content holding a canvas whose pixels read back
|
|
@@ -31,12 +28,6 @@
|
|
|
31
28
|
* SYNC: When modified, update /packages/core/src/motion/animatedLayout.ts
|
|
32
29
|
*/
|
|
33
30
|
|
|
34
|
-
import {
|
|
35
|
-
carryAnimations,
|
|
36
|
-
saveAnimations,
|
|
37
|
-
type SavedAnimations,
|
|
38
|
-
} from './carryAnimations';
|
|
39
|
-
|
|
40
31
|
/** Above this many elements, old content is not copied: the new one enters. */
|
|
41
32
|
const MAX_COPIED_ELEMENTS = 1500;
|
|
42
33
|
|
|
@@ -160,22 +151,11 @@ const scrollOffsets = new WeakMap<
|
|
|
160
151
|
ReadonlyArray<readonly [Element, number, number]>
|
|
161
152
|
>();
|
|
162
153
|
|
|
163
|
-
/**
|
|
164
|
-
* The CSS animations and transitions a copy's element ran, and the copy of
|
|
165
|
-
* each element in the copied subtree. The copy carries them on once laid out
|
|
166
|
-
* (`placeOver`).
|
|
167
|
-
*/
|
|
168
|
-
const carriedMotion = new WeakMap<
|
|
169
|
-
HTMLElement,
|
|
170
|
-
{saved: SavedAnimations; copyOf: ReadonlyMap<Element, Element>}
|
|
171
|
-
>();
|
|
172
|
-
|
|
173
154
|
/**
|
|
174
155
|
* A copy that takes no part: no ids or test ids, no form or radio group (a
|
|
175
156
|
* copied checked radio would uncheck the live one), no label for a live
|
|
176
157
|
* control, and copied frames and media load nothing. Scrolled descendants
|
|
177
|
-
* keep their offsets
|
|
178
|
-
* on from where they were, once the copy is laid out (`placeOver`).
|
|
158
|
+
* keep their offsets once the copy is laid out (`placeOver`).
|
|
179
159
|
*/
|
|
180
160
|
export function inertCopy(element: HTMLElement): HTMLElement | null {
|
|
181
161
|
const copy = element.cloneNode(true) as HTMLElement;
|
|
@@ -189,10 +169,6 @@ export function inertCopy(element: HTMLElement): HTMLElement | null {
|
|
|
189
169
|
});
|
|
190
170
|
scrollOffsets.set(copy, offsets);
|
|
191
171
|
inheritedValues.set(copy, readInherited(element));
|
|
192
|
-
carriedMotion.set(copy, {
|
|
193
|
-
saved: saveAnimations(element),
|
|
194
|
-
copyOf: new Map(sourceNodes.map((node, index) => [node, copyNodes[index]])),
|
|
195
|
-
});
|
|
196
172
|
for (const node of copyNodes) {
|
|
197
173
|
for (const name of [
|
|
198
174
|
'id',
|
|
@@ -239,8 +215,7 @@ export function paintedBackground(element: Element): string {
|
|
|
239
215
|
/**
|
|
240
216
|
* Lay `element` over `rect` (viewport coordinates), absolutely, as the last
|
|
241
217
|
* child of `host`, wherever its containing block is: no ancestor's position
|
|
242
|
-
* changes.
|
|
243
|
-
* CSS animations and transitions its element ran carry on in it.
|
|
218
|
+
* changes.
|
|
244
219
|
*/
|
|
245
220
|
export function placeOver(
|
|
246
221
|
element: HTMLElement,
|
|
@@ -302,15 +277,6 @@ export function placeOver(
|
|
|
302
277
|
node.scrollLeft = left;
|
|
303
278
|
}
|
|
304
279
|
}
|
|
305
|
-
const carried = carriedMotion.get(element);
|
|
306
|
-
if (carried != null) {
|
|
307
|
-
carriedMotion.delete(element);
|
|
308
|
-
carryAnimations(
|
|
309
|
-
carried.saved,
|
|
310
|
-
element,
|
|
311
|
-
node => carried.copyOf.get(node) ?? null,
|
|
312
|
-
);
|
|
313
|
-
}
|
|
314
280
|
}
|
|
315
281
|
|
|
316
282
|
/**
|
|
@@ -357,12 +323,6 @@ export function visiblePartCopy(element: HTMLElement): {
|
|
|
357
323
|
if (values != null) {
|
|
358
324
|
inheritedValues.set(holder, values);
|
|
359
325
|
}
|
|
360
|
-
// The content's CSS motion carries on when the holder is laid out.
|
|
361
|
-
const carried = carriedMotion.get(content);
|
|
362
|
-
if (carried != null) {
|
|
363
|
-
carriedMotion.set(holder, carried);
|
|
364
|
-
carriedMotion.delete(content);
|
|
365
|
-
}
|
|
366
326
|
const box = element.getBoundingClientRect();
|
|
367
327
|
return {
|
|
368
328
|
copy: holder,
|
|
@@ -251,27 +251,6 @@ export const UIKIT_PRESS = {
|
|
|
251
251
|
momentumMemory: {value: 3000, unit: 'ms'},
|
|
252
252
|
} as const satisfies Record<string, GestureConstant>;
|
|
253
253
|
|
|
254
|
-
/**
|
|
255
|
-
* UIMenu presented by a button whose menu is its primary action: how far the
|
|
256
|
-
* finger that opened it travels before it picks. DropdownMenu's press model
|
|
257
|
-
* reads a copy in `hooks/menuPressValues.ts`.
|
|
258
|
-
*/
|
|
259
|
-
export const UIKIT_MENU_PRESS = {
|
|
260
|
-
/**
|
|
261
|
-
* After the menu opens under a still-held finger, the finger travels this
|
|
262
|
-
* far before it starts picking. The distance is a straight line from the
|
|
263
|
-
* first sample the menu receives after it opened. Until then nothing is
|
|
264
|
-
* lit, and lifting acts on nothing.
|
|
265
|
-
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
266
|
-
* iPhone 17 Pro, gesture-state hook, steps 150 ms apart, Oct 23 2026
|
|
267
|
-
* (M-MN2): with the menu open under a held finger and a 1 pt first step,
|
|
268
|
-
* moves of (0, 9) and (7, 7) picked nothing; (0, 10), (0, 11), (10, 0),
|
|
269
|
-
* (9, 9) and (10, 10) picked; a 9 pt step followed by 3 pt more picked
|
|
270
|
-
* nothing
|
|
271
|
-
*/
|
|
272
|
-
handoff: {value: 10, unit: 'px'},
|
|
273
|
-
} as const satisfies Record<string, GestureConstant>;
|
|
274
|
-
|
|
275
254
|
export const UIKIT_VELOCITY = {
|
|
276
255
|
/**
|
|
277
256
|
* UIPanGestureRecognizer.velocity(in:) is this times the newest event's
|
|
@@ -339,7 +318,6 @@ export const UIKIT_GESTURES = {
|
|
|
339
318
|
screenEdgePan: UIKIT_SCREEN_EDGE_PAN,
|
|
340
319
|
control: UIKIT_CONTROL,
|
|
341
320
|
press: UIKIT_PRESS,
|
|
342
|
-
menuPress: UIKIT_MENU_PRESS,
|
|
343
321
|
velocity: UIKIT_VELOCITY,
|
|
344
322
|
} as const;
|
|
345
323
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* press-group markers and the document's pointer, keyboard, scroll and
|
|
7
7
|
* visibility events
|
|
8
8
|
* @output PRESSABLE_ATTRIBUTE, PRESSED_ATTRIBUTE, pressableProps,
|
|
9
|
-
* pressFadeMs
|
|
9
|
+
* pressFadeMs and installPressFeedback
|
|
10
10
|
* @position The DOM half of the touch press model. usePressFeedback installs
|
|
11
11
|
* it, and the CSS arms live in interactionOverlay.stylex.ts.
|
|
12
12
|
*
|
|
@@ -381,21 +381,6 @@ function finish(slot: Slot): void {
|
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
/**
|
|
385
|
-
* Ends the press the controller follows on `element`, and its paint, at once.
|
|
386
|
-
* A clickable container calls it when a press starts on an interactive
|
|
387
|
-
* element inside it: that press does not activate the container, so the
|
|
388
|
-
* container shows no press.
|
|
389
|
-
*/
|
|
390
|
-
export function cancelPress(element: Element): void {
|
|
391
|
-
if (finger.live?.element === element) {
|
|
392
|
-
finish(finger);
|
|
393
|
-
}
|
|
394
|
-
if (button.live?.element === element) {
|
|
395
|
-
finish(button);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
384
|
/** A new press on an element owns its paint: the other slot's gesture there ends. */
|
|
400
385
|
function takeOver(other: Slot, element: HTMLElement): void {
|
|
401
386
|
if (other.live?.element === element) {
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file menuPressValues.ts
|
|
3
|
-
* @input None
|
|
4
|
-
* @output The UIKit value the menu press model reads
|
|
5
|
-
* @position A copy of one UIKit table entry, motion/uikit gestures.ts
|
|
6
|
-
* `UIKIT_MENU_PRESS.handoff`. A menu then bundles this number, not the
|
|
7
|
-
* table with its measurement records. The table stays the source and
|
|
8
|
-
* documents the measurement. menuPressValues.test.ts fails when the copy
|
|
9
|
-
* drifts.
|
|
10
|
-
*
|
|
11
|
-
* SYNC: When modified, update:
|
|
12
|
-
* - /packages/core/src/motion/uikit/gestures.ts
|
|
13
|
-
*/
|
|
14
|
-
/** How far the opening finger travels after the menu opens before it picks. */
|
|
15
|
-
export declare const MENU_PRESS_HANDOFF_PX = 10;
|
|
16
|
-
//# sourceMappingURL=menuPressValues.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"menuPressValues.d.ts","sourceRoot":"","sources":["../../src/hooks/menuPressValues.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,KAAK,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file menuPressValues.ts
|
|
5
|
-
* @input None
|
|
6
|
-
* @output The UIKit value the menu press model reads
|
|
7
|
-
* @position A copy of one UIKit table entry, motion/uikit gestures.ts
|
|
8
|
-
* `UIKIT_MENU_PRESS.handoff`. A menu then bundles this number, not the
|
|
9
|
-
* table with its measurement records. The table stays the source and
|
|
10
|
-
* documents the measurement. menuPressValues.test.ts fails when the copy
|
|
11
|
-
* drifts.
|
|
12
|
-
*
|
|
13
|
-
* SYNC: When modified, update:
|
|
14
|
-
* - /packages/core/src/motion/uikit/gestures.ts
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/** How far the opening finger travels after the menu opens before it picks. */
|
|
18
|
-
export const MENU_PRESS_HANDOFF_PX = 10;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
type Writable = Record<string, unknown>;
|
|
2
|
-
/** One animation's state, read before the browser starts it afresh. */
|
|
3
|
-
export interface SavedAnimation {
|
|
4
|
-
animation: Animation;
|
|
5
|
-
name: string;
|
|
6
|
-
target: Element | null;
|
|
7
|
-
pseudoElement: string | null;
|
|
8
|
-
values: Writable;
|
|
9
|
-
effectValues: Writable;
|
|
10
|
-
timing: EffectTiming | null;
|
|
11
|
-
keyframes: ComputedKeyframe[] | null;
|
|
12
|
-
playState: AnimationPlayState;
|
|
13
|
-
replaceState: AnimationReplaceState;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Reads one animation's state generically, from what the platform exposes.
|
|
17
|
-
* That is every accessor with a setter on the animation's and its effect's
|
|
18
|
-
* prototype chains, every field of the effect's timing, and its keyframes. Only values
|
|
19
|
-
* that differ from the recreated animation's are written back, so a value the
|
|
20
|
-
* stylesheet controls stays under its control. A few members are not plain
|
|
21
|
-
* state and are written in their own step (`ORDERED`). The Animation and
|
|
22
|
-
* effect objects themselves cannot be carried over: the old ones keep their
|
|
23
|
-
* listeners and promises.
|
|
24
|
-
*/
|
|
25
|
-
export declare function saveAnimation(animation: Animation): SavedAnimation;
|
|
26
|
-
/**
|
|
27
|
-
* Puts each state `saved` holds on the CSS animations and transitions of
|
|
28
|
-
* `root` and its subtree that are not among `survivors`. Each CSS animation
|
|
29
|
-
* the browser started afresh takes the state of the one it replaces. It is
|
|
30
|
-
* matched by element, pseudo-element and name, in order, and then by name
|
|
31
|
-
* alone (an effect script moved to another element or pseudo-element). Each
|
|
32
|
-
* transition whose animation no longer runs resumes as a script animation in
|
|
33
|
-
* its state. One started afresh that replaces none is finished: an entrance
|
|
34
|
-
* that had played and been dropped, or a transition from `@starting-style`.
|
|
35
|
-
* Script animations are left as they are.
|
|
36
|
-
*/
|
|
37
|
-
export declare function restoreAnimations(root: Element, saved: ReadonlyArray<SavedAnimation>, survivors: ReadonlySet<Animation>): void;
|
|
38
|
-
/** The CSS animations and transitions `saveAnimations` read. */
|
|
39
|
-
export type SavedAnimations = ReadonlyArray<SavedAnimation>;
|
|
40
|
-
/**
|
|
41
|
-
* Reads the state of every CSS animation and transition of `root` and its
|
|
42
|
-
* subtree, for `carryAnimations` to give a copy of it.
|
|
43
|
-
*/
|
|
44
|
-
export declare function saveAnimations(root: Element): SavedAnimations;
|
|
45
|
-
/**
|
|
46
|
-
* Carries on in `copy`, a clone of the root `saved` was read from, now laid
|
|
47
|
-
* out, the CSS animations and transitions its element ran. A clone starts
|
|
48
|
-
* each CSS animation again and runs no transition but a `@starting-style`
|
|
49
|
-
* one. So each CSS animation the clone started takes the state of its
|
|
50
|
-
* element's, and each transition runs on as a script animation. One the
|
|
51
|
-
* clone started that its element no longer ran is finished: an entrance that
|
|
52
|
-
* had played, or a `@starting-style` transition. `copyOf` maps each element
|
|
53
|
-
* of the cloned subtree to its copy. The element's own animations keep
|
|
54
|
-
* running, so the copy's take no id or event handler.
|
|
55
|
-
*/
|
|
56
|
-
export declare function carryAnimations(saved: SavedAnimations, copy: Element, copyOf: (element: Element) => Element | null): void;
|
|
57
|
-
export {};
|
|
58
|
-
//# sourceMappingURL=carryAnimations.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"carryAnimations.d.ts","sourceRoot":"","sources":["../../src/motion/carryAnimations.ts"],"names":[],"mappings":"AA+BA,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAsDxC,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,QAAQ,CAAC;IACjB,YAAY,EAAE,QAAQ,CAAC;IACvB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACrC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,YAAY,EAAE,qBAAqB,CAAC;CACrC;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,CAyBlE;AAsJD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,EACpC,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,GAChC,IAAI,CA8CN;AAED,gEAAgE;AAChE,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;AAE5D;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,CAQ7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAG,IAAI,GAC3C,IAAI,CASN"}
|