An open source design system that's fully customizable and agent ready
TypeScript
chore(gestures): press tracking ships only its press clocks, and the README documents kind and createPressTracker (#9745)
Christopher Chedeauc19ca12b71d0
diff --git a/.changeset/press-tracker-press-clocks.md b/.changeset/press-tracker-press-clocks.mdnew file mode 100644index 0000000000..b9ef5c7f34--- /dev/null+++ b/.changeset/press-tracker-press-clocks.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[chore] Internal: press tracking imports only the UIKit timing table's press clocks, so Switch, Slider, SegmentedControl and DateTimeInput, the controls built on press tracking, no longer ship the whole table. Nothing changes in how a press behaves.++@vjeuxdiff --git a/packages/core/src/gestures/PressTracker.ts b/packages/core/src/gestures/PressTracker.tsindex 4d8564ebc3..c208f63c00 100644--- a/packages/core/src/gestures/PressTracker.ts+++ b/packages/core/src/gestures/PressTracker.ts@@ -47,7 +47,8 @@*/import {UIKIT_CONTROL, UIKIT_PAN, UIKIT_PRESS} from '../motion/uikit/gestures';-import {timing} from '../motion/uikit/timing';+// Importing the whole table bundles its curves into each press-tracking control.+import {press as pressClocks} from '../motion/uikit/timing';import {travel} from './geometry';import type {GestureRecognizer, SelectionLock} from './GestureRecognizer';import type {TapGestureRecognizer} from './TapGestureRecognizer';@@ -154,7 +155,7 @@ export const PRESS_PROFILES = {// The shared press styles release every surface on the deselect clock// until a control runs its own release (UIButton's 250 ms), so a// painter's `fading` never outlasts the fade it shows.- releaseMs: timing.press.highlightOutMs,+ releaseMs: pressClocks.highlightOutMs,},/*** A table or collection cell: inside a scroll view it highlights after the@@ -165,7 +166,7 @@ export const PRESS_PROFILES = {highlightDelay: 'inScrollers',cancelTravel: UIKIT_PAN.hysteresis.value,quickTapFlash: 0,- releaseMs: timing.press.highlightOutMs,+ releaseMs: pressClocks.highlightOutMs,},} as const satisfies Record<string, PressProfile>;diff --git a/packages/core/src/gestures/README.md b/packages/core/src/gestures/README.mdindex 638256b47d..3b42073258 100644--- a/packages/core/src/gestures/README.md+++ b/packages/core/src/gestures/README.md@@ -96,6 +96,10 @@ Once a drag has claimed its finger, a second finger never breaks it.| `PinchGestureRecognizer` | `UIPinchGestureRecognizer` | continuous | `scale` (settable, to re-base it), `velocity` in scale per second, `focalPoint()` || `ScreenEdgePanGestureRecognizer` | `UIScreenEdgePanGestureRecognizer` | continuous | `edges`: `leading` / `trailing`, resolved against the view's writing direction; attached to an edge zone the view lies within; fails as soon as the touch lands outside every requested edge band; a finger's only |+Each recognizer reports what it is in `kind` (`'tap'`, `'longPress'`,+`'pan'`, `'screenEdgePan'`, `'swipe'`, `'pinch'`): code tells the family apart by it, never by `instanceof`+(`architecture:react-component-runtime` INV13).+A recognizer created with `claimsTouches: false` is a watcher (a tab barthat minimizes while the page scrolls): it never claims, so its element getsonly passive listeners and a scroll never waits for it; it prevents no other@@ -174,7 +178,9 @@ innerPan.requireToFail(edgePan);## Touches in the view: `createPressTracker`A pressable control's view-level touch handling, with `UIControl`-semantics:+semantics, built by `createPressTracker(options)`: a factory, as+`architecture:react-component-runtime` INV13 asks of the touch modules outside+the recognizer family (`VelocityTracker` is still a class, its one listed gap):- `touchDown`, `touchDragInside` / `touchDragOutside`, `touchDragEnter` /`touchDragExit`, `touchUpInside` / `touchUpOutside`, `touchCancel`.diff --git a/packages/core/src/gestures/__tests__/GestureHost.bundle.test.ts b/packages/core/src/gestures/__tests__/GestureHost.bundle.test.tsindex d69b2b6275..10f16593f9 100644--- a/packages/core/src/gestures/__tests__/GestureHost.bundle.test.ts+++ b/packages/core/src/gestures/__tests__/GestureHost.bundle.test.ts@@ -5,7 +5,8 @@* @input GestureHost.ts, PressTracker.ts and usePressTracker.ts, bundled and* minified by esbuild* @output The gesture host, the press tracker and its hook carry only the- * UIKit gesture groups they read, never the whole table+ * UIKit gesture groups they read, never the whole table. The press tracker+ * carries only the timing table's press clocks* (architecture:component-style-authoring INV6)* @position Bundle evidence for packages/core/src/gestures: every recognizer* and press tracker attaches through the host, so what it imports ships@@ -102,4 +103,11 @@ describe.each([expect(text).not.toContain(key);}});+ it('carries only the press clocks of the UIKit timing table, never the whole table', () => {+ expect(text).toContain('highlightOutMs:');+ // Rows only the whole timing table has.+ for (const key of ['navigationBarHideShowMs:', 'keyboardNotificationMs:']) {+ expect(text).not.toContain(key);+ }+ });});