@astryxdesign/core 0.7.6 → 0.7.7-canary.0eb44a2
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/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +23 -3
- package/dist/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +1 -1
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +16 -9
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +2 -1
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +3 -2
- package/dist/Chat/ChatComposerInput.d.ts +9 -0
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +2 -0
- package/dist/Chat/ChatMessage.js +2 -2
- package/dist/Chat/chatMessage.vars.stylex.d.ts +8 -8
- package/dist/Chat/chatMessage.vars.stylex.js +8 -8
- package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteInput.js +8 -1
- package/dist/DateInput/MonthScroller.d.ts.map +1 -1
- package/dist/DateInput/MonthScroller.js +72 -2
- package/dist/DateInput/Wheel.d.ts +17 -1
- package/dist/DateInput/Wheel.d.ts.map +1 -1
- package/dist/DateInput/Wheel.js +179 -19
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +63 -49
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +37 -1
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +6 -0
- package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -1
- package/dist/Drawer/useDrawerDialogPresence.js +4 -0
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +20 -4
- package/dist/DropdownMenu/useMenuOverflow.d.ts +13 -3
- package/dist/DropdownMenu/useMenuOverflow.d.ts.map +1 -1
- package/dist/DropdownMenu/useMenuOverflow.js +31 -8
- package/dist/Field/PanelSearchInput.d.ts.map +1 -1
- package/dist/Field/PanelSearchInput.js +8 -1
- package/dist/Field/textEntryTraits.d.ts +6 -6
- package/dist/Field/textEntryTraits.js +6 -6
- package/dist/Layer/layerClickBoundary.d.ts +7 -1
- package/dist/Layer/layerClickBoundary.d.ts.map +1 -1
- package/dist/Layer/layerClickBoundary.js +2 -2
- package/dist/Layer/usePressPin.d.ts +95 -0
- package/dist/Layer/usePressPin.d.ts.map +1 -0
- package/dist/Layer/usePressPin.js +365 -0
- package/dist/Layer/useTouchTrigger.d.ts +23 -1
- package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
- package/dist/Layer/useTouchTrigger.js +45 -7
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +2 -1
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +1 -0
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +56 -7
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +38 -30
- package/dist/ProgressBar/ProgressBar.d.ts +1 -1
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +52 -14
- package/dist/ProgressBar/ProgressBarTouch.d.ts +29 -0
- package/dist/ProgressBar/ProgressBarTouch.d.ts.map +1 -0
- package/dist/ProgressBar/ProgressBarTouch.js +91 -0
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +2 -1
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +25 -13
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +404 -131
- package/dist/Slider/sliderTouchController.d.ts +189 -0
- package/dist/Slider/sliderTouchController.d.ts.map +1 -0
- package/dist/Slider/sliderTouchController.js +1017 -0
- package/dist/Slider/useSliderTouch.d.ts +22 -0
- package/dist/Slider/useSliderTouch.d.ts.map +1 -0
- package/dist/Slider/useSliderTouch.js +56 -0
- package/dist/Switch/Switch.d.ts +1 -1
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +200 -46
- package/dist/Switch/switchFill.d.ts +31 -0
- package/dist/Switch/switchFill.d.ts.map +1 -0
- package/dist/Switch/switchFill.js +88 -0
- package/dist/Switch/switchTouch.d.ts +81 -0
- package/dist/Switch/switchTouch.d.ts.map +1 -0
- package/dist/Switch/switchTouch.js +133 -0
- package/dist/Switch/useSwitchTouch.d.ts +285 -0
- package/dist/Switch/useSwitchTouch.d.ts.map +1 -0
- package/dist/Switch/useSwitchTouch.js +998 -0
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +4 -3
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +12 -5
- package/dist/Tokenizer/TokenizerItemRemovableContext.d.ts +3 -0
- package/dist/Tokenizer/TokenizerItemRemovableContext.d.ts.map +1 -0
- package/dist/Tokenizer/TokenizerItemRemovableContext.js +17 -0
- package/dist/Tooltip/Tooltip.d.ts +30 -6
- package/dist/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip/Tooltip.js +5 -0
- package/dist/Tooltip/index.d.ts +1 -1
- package/dist/Tooltip/index.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.d.ts +31 -5
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +59 -18
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +19 -9
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +26 -15
- package/dist/astryx.css +91 -8
- package/dist/gestures/GestureArena.d.ts +21 -2
- package/dist/gestures/GestureArena.d.ts.map +1 -1
- package/dist/gestures/GestureArena.js +23 -3
- package/dist/gestures/GestureHost.d.ts +123 -3
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +797 -15
- package/dist/gestures/GestureRecognizer.d.ts +15 -1
- package/dist/gestures/GestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/GestureRecognizer.js +12 -0
- package/dist/gestures/PanGestureRecognizer.d.ts +8 -0
- package/dist/gestures/PanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/PinchGestureRecognizer.d.ts +5 -1
- package/dist/gestures/PinchGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/PinchGestureRecognizer.js +10 -0
- package/dist/gestures/PressTracker.d.ts +6 -0
- package/dist/gestures/PressTracker.d.ts.map +1 -1
- package/dist/gestures/PressTracker.js +3 -0
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts +3 -3
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/ScreenEdgePanGestureRecognizer.js +7 -5
- package/dist/gestures/nativeScroll.d.ts +16 -2
- package/dist/gestures/nativeScroll.d.ts.map +1 -1
- package/dist/gestures/nativeScroll.js +39 -8
- package/dist/gestures/recognizerInternals.d.ts +4 -2
- package/dist/gestures/recognizerInternals.d.ts.map +1 -1
- package/dist/gestures/types.d.ts +17 -0
- package/dist/gestures/types.d.ts.map +1 -1
- package/dist/gestures/types.js +7 -0
- package/dist/gestures/usePressTracker.d.ts.map +1 -1
- package/dist/gestures/usePressTracker.js +1 -0
- package/dist/gestures/wheelSegmenter.d.ts +56 -0
- package/dist/gestures/wheelSegmenter.d.ts.map +1 -0
- package/dist/gestures/wheelSegmenter.js +122 -0
- package/dist/hooks/useAttachment.d.ts +16 -8
- package/dist/hooks/useAttachment.d.ts.map +1 -1
- package/dist/hooks/useAttachment.js +35 -15
- package/dist/hooks/useFocusTrap.d.ts +15 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +13 -2
- package/dist/hooks/usePager.d.ts +261 -0
- package/dist/hooks/usePager.d.ts.map +1 -0
- package/dist/hooks/usePager.js +1169 -0
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +140 -19
- package/dist/motion/paging.d.ts +69 -0
- package/dist/motion/paging.d.ts.map +1 -0
- package/dist/motion/paging.js +148 -0
- package/dist/motion/uikit/index.d.ts +8 -4
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +8 -4
- package/dist/motion/uikit/paging.d.ts +171 -0
- package/dist/motion/uikit/paging.d.ts.map +1 -0
- package/dist/motion/uikit/paging.js +192 -0
- package/dist/motion/uikit/progressBar.d.ts +79 -0
- package/dist/motion/uikit/progressBar.d.ts.map +1 -0
- package/dist/motion/uikit/progressBar.js +102 -0
- package/dist/motion/uikit/scroll.d.ts +0 -19
- package/dist/motion/uikit/scroll.d.ts.map +1 -1
- package/dist/motion/uikit/scroll.js +2 -21
- package/dist/motion/uikit/slider.d.ts +97 -0
- package/dist/motion/uikit/slider.d.ts.map +1 -0
- package/dist/motion/uikit/slider.js +111 -0
- package/dist/motion/uikit/springs.d.ts +59 -30
- package/dist/motion/uikit/springs.d.ts.map +1 -1
- package/dist/motion/uikit/springs.js +64 -34
- package/dist/motion/uikit/switch.d.ts +166 -0
- package/dist/motion/uikit/switch.d.ts.map +1 -0
- package/dist/motion/uikit/switch.js +186 -0
- package/dist/privateAttributes/pressHoldsDrag.stylex.d.ts +18 -0
- package/dist/privateAttributes/pressHoldsDrag.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/pressHoldsDrag.stylex.js +28 -0
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +5 -0
- package/dist/utils/selectionLock.d.ts +43 -0
- package/dist/utils/selectionLock.d.ts.map +1 -1
- package/dist/utils/selectionLock.js +394 -6
- package/package.json +5 -5
- package/src/AppShell/AppShell.doc.mjs +10 -0
- package/src/AppShell/AppShell.tsx +48 -2
- package/src/Avatar/Avatar.tsx +3 -1
- package/src/BottomSheet/BottomSheetPanel.tsx +16 -9
- package/src/Breadcrumbs/BreadcrumbItem.tsx +4 -1
- package/src/Button/Button.tsx +3 -2
- package/src/Chat/Chat.doc.mjs +1 -0
- package/src/Chat/ChatComposerInput.doc.mjs +11 -0
- package/src/Chat/ChatComposerInput.tsx +11 -0
- package/src/Chat/ChatMessage.tsx +2 -2
- package/src/Chat/chatMessage.vars.stylex.ts +8 -8
- package/src/CommandPalette/CommandPaletteInput.tsx +6 -0
- package/src/DateInput/MonthScroller.tsx +63 -5
- package/src/DateInput/Wheel.tsx +174 -14
- package/src/DateRangeInput/DateRangeInput.doc.mjs +3 -2
- package/src/DateRangeInput/DateRangeInput.tsx +117 -71
- package/src/Dialog/Dialog.tsx +37 -1
- package/src/Drawer/Drawer.tsx +6 -0
- package/src/Drawer/useDrawerDialogPresence.ts +4 -0
- package/src/DropdownMenu/DropdownMenu.tsx +28 -6
- package/src/DropdownMenu/useMenuOverflow.ts +44 -8
- package/src/Field/PanelSearchInput.tsx +6 -0
- package/src/Field/textEntryTraits.ts +6 -6
- package/src/Layer/layerClickBoundary.ts +2 -2
- package/src/Layer/usePressPin.ts +516 -0
- package/src/Layer/useTouchTrigger.ts +56 -6
- package/src/Lightbox/Lightbox.tsx +2 -1
- package/src/Link/Link.tsx +3 -0
- package/src/Popover/usePopover.tsx +71 -9
- package/src/PowerSearch/PowerSearch.tsx +38 -31
- package/src/ProgressBar/ProgressBar.doc.mjs +7 -5
- package/src/ProgressBar/ProgressBar.tsx +147 -16
- package/src/ProgressBar/ProgressBarTouch.ts +109 -0
- package/src/SegmentedControl/SegmentedControlItem.tsx +2 -1
- package/src/Selector/Selector.tsx +29 -2
- package/src/Slider/Slider.doc.mjs +11 -7
- package/src/Slider/Slider.tsx +539 -132
- package/src/Slider/sliderTouchController.ts +1209 -0
- package/src/Slider/useSliderTouch.ts +78 -0
- package/src/Switch/Switch.doc.mjs +3 -3
- package/src/Switch/Switch.tsx +412 -86
- package/src/Switch/switchFill.ts +106 -0
- package/src/Switch/switchTouch.ts +194 -0
- package/src/Switch/useSwitchTouch.ts +1121 -0
- package/src/TabList/Tab.tsx +5 -3
- package/src/Tokenizer/Tokenizer.tsx +15 -5
- package/src/Tokenizer/TokenizerItemRemovableContext.ts +22 -0
- package/src/Tooltip/Tooltip.doc.mjs +21 -6
- package/src/Tooltip/Tooltip.tsx +42 -5
- package/src/Tooltip/index.ts +1 -0
- package/src/Tooltip/useTooltip.doc.mjs +4 -2
- package/src/Tooltip/useTooltip.tsx +84 -21
- package/src/Typeahead/BaseTypeahead.tsx +16 -8
- package/src/Typeahead/Typeahead.tsx +29 -15
- package/src/gestures/GestureArena.ts +45 -4
- package/src/gestures/GestureHost.ts +958 -15
- package/src/gestures/GestureRecognizer.ts +28 -0
- package/src/gestures/PanGestureRecognizer.ts +8 -0
- package/src/gestures/PinchGestureRecognizer.ts +16 -1
- package/src/gestures/PressTracker.ts +10 -0
- package/src/gestures/README.md +82 -3
- package/src/gestures/ScreenEdgePanGestureRecognizer.ts +7 -5
- package/src/gestures/nativeScroll.ts +49 -9
- package/src/gestures/recognizerInternals.ts +9 -2
- package/src/gestures/types.ts +18 -0
- package/src/gestures/usePressTracker.ts +2 -0
- package/src/gestures/wheelSegmenter.ts +143 -0
- package/src/hooks/useAttachment.ts +56 -14
- package/src/hooks/useFocusTrap.ts +26 -2
- package/src/hooks/usePager.ts +1446 -0
- package/src/motion/MEASUREMENTS.md +36 -27
- package/src/motion/README.md +7 -3
- package/src/motion/animator.ts +193 -25
- package/src/motion/paging.ts +161 -0
- package/src/motion/uikit/index.ts +7 -4
- package/src/motion/uikit/paging.ts +193 -0
- package/src/motion/uikit/progressBar.ts +102 -0
- package/src/motion/uikit/scroll.ts +2 -18
- package/src/motion/uikit/slider.ts +105 -0
- package/src/motion/uikit/springs.ts +53 -32
- package/src/motion/uikit/switch.ts +174 -0
- package/src/privateAttributes/pressHoldsDrag.stylex.ts +28 -0
- package/src/utils/pressFeedback.ts +5 -0
- package/src/utils/selectionLock.ts +501 -6
- package/dist/motion/selectPage.d.ts +0 -26
- package/dist/motion/selectPage.d.ts.map +0 -1
- package/dist/motion/selectPage.js +0 -55
- package/src/motion/selectPage.ts +0 -55
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file switch.ts
|
|
5
|
+
* @input The springs table's measured switch travel (springs.ts)
|
|
6
|
+
* @output Exports `switchControl`: UISwitch's geometry, the springs of its
|
|
7
|
+
* Liquid Glass thumb and of its track color, the drag's rubber band and
|
|
8
|
+
* flip distance, and the release timing
|
|
9
|
+
* @position The switch domain of the UIKit constants table (motion/uikit)
|
|
10
|
+
*
|
|
11
|
+
* The values are UISwitch's on iOS 26.2, read in a UIKit host app on the
|
|
12
|
+
* simulator. Lengths are in pt (CSS px). uikit.test.ts checks each `@source`.
|
|
13
|
+
*
|
|
14
|
+
* SYNC: When modified, update /packages/core/src/motion/MEASUREMENTS.md.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {registerMotionTable} from '../roles';
|
|
18
|
+
import {SWITCH_THUMB_MOVE_SPRING} from './springs';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* UISwitch on iOS 26.2. Under a finger its white thumb lifts into a clear
|
|
22
|
+
* glass lens, and a drag moves it with a rubber band. The track colour slides
|
|
23
|
+
* on a spring of its own. UISwitch plays no haptic.
|
|
24
|
+
*/
|
|
25
|
+
export const switchControl = {
|
|
26
|
+
/**
|
|
27
|
+
* The control's size (width × height): the track.
|
|
28
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
29
|
+
* iPhone 17 Pro, `UISwitch` frame 63 × 28 (intrinsic 61 × 28), track view
|
|
30
|
+
* 63 × 28 with corner radius 14, Oct 23 2026
|
|
31
|
+
*/
|
|
32
|
+
trackSize: [63, 28],
|
|
33
|
+
/**
|
|
34
|
+
* The thumb at rest (width × height), inset equally from the track's top,
|
|
35
|
+
* bottom and nearer end; it never changes size between off and on.
|
|
36
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
37
|
+
* iPhone 17 Pro, `_UILiquidLensView` frame 37 × 24 at x 2 (off) and
|
|
38
|
+
* x 24 (on) inside the 63 × 28 track, Oct 23 2026
|
|
39
|
+
*/
|
|
40
|
+
thumbSize: [37, 24],
|
|
41
|
+
/**
|
|
42
|
+
* The thumb lifted under a finger (width × height). The lens grows about
|
|
43
|
+
* its own center, past the track, and holds this size while the finger
|
|
44
|
+
* stays down.
|
|
45
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
46
|
+
* iPhone 17 Pro, lens bounds settled at 58 × 38.33 during a 1 s hold
|
|
47
|
+
* (center unmoved), Oct 23 2026
|
|
48
|
+
*/
|
|
49
|
+
liftedThumbSize: [58, 38.333],
|
|
50
|
+
/**
|
|
51
|
+
* The lift: the thumb growing to `liftedThumbSize` while its white fill
|
|
52
|
+
* fades out and the clear glass fades in (one spring drives all three).
|
|
53
|
+
* Starts with the touch outside a scroll view, after its content delay
|
|
54
|
+
* inside one. UISwitch keeps it under Reduce Motion; core's Switch does not
|
|
55
|
+
* lift then.
|
|
56
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
57
|
+
* iPhone 17 Pro, per-frame lens bounds during a 1 s hold fitted with one
|
|
58
|
+
* spring for width and height (rms 0.29 pt; the fill's and the glass's
|
|
59
|
+
* opacity overshoot by the same 13 %; the lens's settings read on a tap
|
|
60
|
+
* say damping 0.625, response 0.27, whose 8 % overshoot is short of the
|
|
61
|
+
* frames' 12 %), Oct 23 2026
|
|
62
|
+
*/
|
|
63
|
+
lift: {response: 0.23, dampingRatio: 0.55},
|
|
64
|
+
/**
|
|
65
|
+
* The settle after the finger lifts: the lens shrinking back to
|
|
66
|
+
* `thumbSize` while the white fill returns over the glass.
|
|
67
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
68
|
+
* iPhone 17 Pro, the lens's spring settings read on a tap (damping 0.7,
|
|
69
|
+
* response 0.5); per-frame lens bounds after the lift of a 1 s hold fit
|
|
70
|
+
* one spring at 0.49 / 0.70 (rms 0.065 pt; the opacities undershoot by
|
|
71
|
+
* the same 4.5 %), Oct 23 2026
|
|
72
|
+
*/
|
|
73
|
+
settle: {response: 0.5, dampingRatio: 0.7},
|
|
74
|
+
/**
|
|
75
|
+
* The settle never starts sooner than this after the lift began, so a
|
|
76
|
+
* quick tap still shows the lifted lens, in ms.
|
|
77
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
78
|
+
* iPhone 17 Pro, a 50 ms tap: the lift→settle hand-off fitted at 235 ms
|
|
79
|
+
* after the lift began (rms 0.33 pt), Oct 23 2026
|
|
80
|
+
* @measure M-SW07
|
|
81
|
+
*/
|
|
82
|
+
minimumLiftMs: 235,
|
|
83
|
+
/**
|
|
84
|
+
* The thumb travelling to the committed end after a release or a
|
|
85
|
+
* programmatic change. It starts from the thumb's own velocity.
|
|
86
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
87
|
+
* iPhone 17 Pro, the lens's position behavior read on a tap (damping 1,
|
|
88
|
+
* response 0.3); the lens center after a 50 ms tap and after a 1 s hold
|
|
89
|
+
* fits one spring at 0.31 / 1 (rms 0.11 pt), Oct 23 2026; the springs
|
|
90
|
+
* table's `SWITCH_THUMB_MOVE_SPRING` holds the one value
|
|
91
|
+
*/
|
|
92
|
+
travel: SWITCH_THUMB_MOVE_SPRING,
|
|
93
|
+
/**
|
|
94
|
+
* During a drag the thumb chases the finger: each move retargets this
|
|
95
|
+
* spring at the finger's position, rubber-banded past either end.
|
|
96
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
97
|
+
* iPhone 17 Pro, a 4 s drag off → on → past both ends: the lens center
|
|
98
|
+
* simulated as this spring chasing the rubber-banded finger fits every
|
|
99
|
+
* frame (rms 0.21 pt), Oct 23 2026
|
|
100
|
+
*/
|
|
101
|
+
tracking: {response: 0.36, dampingRatio: 1},
|
|
102
|
+
/**
|
|
103
|
+
* The drag's rubber band past either end: UIScrollView's
|
|
104
|
+
* `(1 − 1 ÷ (x·c ÷ d + 1))·d`. The coefficient c and the dimension d are in
|
|
105
|
+
* pt for the 28 pt control. Scale d with the track height.
|
|
106
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
107
|
+
* iPhone 17 Pro, the same drag fit: c 0.55, d 11.75–12 pt, the
|
|
108
|
+
* translation measured from where the finger landed, Oct 23 2026
|
|
109
|
+
*/
|
|
110
|
+
rubberBand: {coefficient: 0.55, dimension: 12},
|
|
111
|
+
/**
|
|
112
|
+
* A drag flips the switch by the finger, not the thumb. Once the finger is
|
|
113
|
+
* this far from where it landed, toward the other end, the switch shows
|
|
114
|
+
* the other side. The distance is the track width minus the thumb width
|
|
115
|
+
* (63 − 37 pt). Back past where it landed, the starting side shows again.
|
|
116
|
+
* Flips happen on touch events only, so a fast swipe flips on the lift.
|
|
117
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
118
|
+
* iPhone 17 Pro, `UISwitchModernVisualElement` ivars per frame and the
|
|
119
|
+
* "SwitchWellPosition" springs during 1 pt-step drags: the same 26 pt for
|
|
120
|
+
* presses at x 8, 20.5 and 45, with and without a 400 ms hold, mirrored
|
|
121
|
+
* on an on switch; flipping back at the press point, Oct 23 2026
|
|
122
|
+
*/
|
|
123
|
+
flipDistance: 26,
|
|
124
|
+
/**
|
|
125
|
+
* The track color turning on: the well image sliding in on a critically
|
|
126
|
+
* damped spring, starting when the switch flips (the lift of a tap).
|
|
127
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
128
|
+
* iPhone 17 Pro, `CASpringAnimation` "SwitchWellPosition" read: mass 1,
|
|
129
|
+
* stiffness 85.377, damping 18.480 (response 0.68 s), Oct 23 2026
|
|
130
|
+
*/
|
|
131
|
+
wellOn: {mass: 1, stiffness: 85.37720070146501, damping: 18.47995678582231},
|
|
132
|
+
/**
|
|
133
|
+
* The track color turning off: the same well sliding back, faster.
|
|
134
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
135
|
+
* iPhone 17 Pro, `CASpringAnimation` "SwitchWellPosition" read: mass 1,
|
|
136
|
+
* stiffness 246.740, damping 31.416 (response 0.40 s), Oct 23 2026
|
|
137
|
+
*/
|
|
138
|
+
wellOff: {mass: 1, stiffness: 246.74011002723395, damping: 31.41592653589793},
|
|
139
|
+
/**
|
|
140
|
+
* The lifted lens's drop shadow: y offset and radius in pt, then black
|
|
141
|
+
* alpha; none at rest.
|
|
142
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
143
|
+
* iPhone 17 Pro, the lens layer's presented `shadowOffset` (0, 7),
|
|
144
|
+
* `shadowRadius` 3, `shadowOpacity` 0.12 once lifted, 0 at rest,
|
|
145
|
+
* Oct 23 2026
|
|
146
|
+
*/
|
|
147
|
+
liftedShadow: [7, 3, 0.12],
|
|
148
|
+
/**
|
|
149
|
+
* UISwitch plays no haptic on a tap, a hold or a drag.
|
|
150
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
151
|
+
* iPhone 17 Pro, every `UIFeedbackGenerator` entry point hooked: no call
|
|
152
|
+
* on tap, hold, drag or flip, Oct 23 2026
|
|
153
|
+
*/
|
|
154
|
+
haptic: 'none',
|
|
155
|
+
} as const;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Registers the switch table's motion roles as internal roles. Nothing
|
|
159
|
+
* registers on import: Switch's touch presentation calls it once before its
|
|
160
|
+
* first animation, and a second call does nothing.
|
|
161
|
+
*/
|
|
162
|
+
export function registerSwitchTable(): void {
|
|
163
|
+
registerMotionTable('switchControl', switchControl, {
|
|
164
|
+
roles: [
|
|
165
|
+
'lift',
|
|
166
|
+
'settle',
|
|
167
|
+
'travel',
|
|
168
|
+
'tracking',
|
|
169
|
+
'wellOn',
|
|
170
|
+
'wellOff',
|
|
171
|
+
'minimumLiftMs',
|
|
172
|
+
],
|
|
173
|
+
});
|
|
174
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
/**
|
|
3
|
+
* @file privateAttributes/pressHoldsDrag.stylex.ts
|
|
4
|
+
* @input Whether a pressable's own drag moves under the finger
|
|
5
|
+
* @output pressHoldsDragProps, which marks such a pressable, and
|
|
6
|
+
* holdsPressThroughDrag, which reads the mark
|
|
7
|
+
* @position Owner module of the private press-holds-drag attribute: the only
|
|
8
|
+
* file that writes its name. Switch marks its row; the press controller
|
|
9
|
+
* (utils/pressFeedback.ts) keeps the press painted through that row's
|
|
10
|
+
* drag. No package entry exports it.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const PRESS_HOLDS_DRAG = 'data-astryx-press-holds-drag';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Spread on a pressable whose own drag the finger moves, such as a Switch's
|
|
17
|
+
* thumb. The drag is not a scroll, so the press stays painted.
|
|
18
|
+
*/
|
|
19
|
+
export function pressHoldsDragProps(
|
|
20
|
+
holdsDrag: boolean,
|
|
21
|
+
): Readonly<Record<string, string>> {
|
|
22
|
+
return holdsDrag ? {[PRESS_HOLDS_DRAG]: ''} : {};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Whether the press on `element` stays painted through its drag. */
|
|
26
|
+
export function holdsPressThroughDrag(element: Element): boolean {
|
|
27
|
+
return element.hasAttribute(PRESS_HOLDS_DRAG);
|
|
28
|
+
}
|
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
import {isCoarsePointer, watchCoarsePointer} from './coarsePointer';
|
|
46
46
|
import {subscribeInput} from './inputStream';
|
|
47
47
|
import {TOUCH_QUERY} from './touchPresentation';
|
|
48
|
+
import {holdsPressThroughDrag} from '../privateAttributes/pressHoldsDrag.stylex';
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
51
|
* The marker the controller finds with `closest()`. Every Astryx component
|
|
@@ -441,6 +442,10 @@ function onPointerMove(event: PointerEvent): void {
|
|
|
441
442
|
) {
|
|
442
443
|
return;
|
|
443
444
|
}
|
|
445
|
+
// The finger drags the surface's own control: its travel keeps the press.
|
|
446
|
+
if (holdsPressThroughDrag(live.element)) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
444
449
|
apply(
|
|
445
450
|
finger,
|
|
446
451
|
pressGestureStep(live.gesture, {
|