@astryxdesign/core 0.7.15-canary.gf890983 → 0.7.15

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +72 -2
  2. package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
  3. package/dist/BottomSheet/BottomSheetPanel.js +5 -4
  4. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  5. package/dist/CheckboxInput/CheckboxInput.js +10 -23
  6. package/dist/Item/Item.js +2 -2
  7. package/dist/Layer/useTouchTrigger.d.ts +12 -1
  8. package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
  9. package/dist/Layer/useTouchTrigger.js +22 -3
  10. package/dist/Outline/useScrollSpy.d.ts.map +1 -1
  11. package/dist/Outline/useScrollSpy.js +22 -18
  12. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  13. package/dist/RadioList/RadioListItem.js +6 -32
  14. package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
  15. package/dist/Resizable/ResizeHandle.js +5 -10
  16. package/dist/Resizable/useResizable.d.ts.map +1 -1
  17. package/dist/Resizable/useResizable.js +6 -5
  18. package/dist/Stepper/Step.js +8 -8
  19. package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
  20. package/dist/Table/plugins/sortable/useTableSortableState.js +8 -4
  21. package/dist/Text/TruncationTooltip.d.ts.map +1 -1
  22. package/dist/Text/TruncationTooltip.js +10 -1
  23. package/dist/Toast/ToastViewport.d.ts.map +1 -1
  24. package/dist/Toast/ToastViewport.js +31 -6
  25. package/dist/Token/Token.js +2 -2
  26. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  27. package/dist/Tooltip/useTooltip.js +1 -1
  28. package/dist/TreeList/TreeListItem.js +2 -2
  29. package/dist/gestures/GestureHost.d.ts +38 -0
  30. package/dist/gestures/GestureHost.d.ts.map +1 -1
  31. package/dist/gestures/GestureHost.js +95 -1
  32. package/dist/gestures/contextRequest.d.ts +43 -0
  33. package/dist/gestures/contextRequest.d.ts.map +1 -0
  34. package/dist/gestures/contextRequest.js +167 -0
  35. package/dist/hooks/useClickableContainer.d.ts +1 -1
  36. package/dist/hooks/useClickableContainer.d.ts.map +1 -1
  37. package/dist/hooks/useClickableContainer.js +2 -2
  38. package/dist/hooks/useCommittedRef.d.ts +20 -0
  39. package/dist/hooks/useCommittedRef.d.ts.map +1 -0
  40. package/dist/hooks/useCommittedRef.js +38 -0
  41. package/dist/hooks/useMenuPress.d.ts.map +1 -1
  42. package/dist/hooks/useMenuPress.js +23 -27
  43. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  44. package/dist/i18n/generated-locales/en.generated.js +2 -1
  45. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  46. package/dist/i18n/generated-locales/pseudo.generated.js +2 -1
  47. package/dist/internal/committed-ref.d.ts +15 -0
  48. package/dist/internal/committed-ref.d.ts.map +1 -0
  49. package/dist/internal/committed-ref.js +15 -0
  50. package/dist/internal/touch.d.ts +2 -1
  51. package/dist/internal/touch.d.ts.map +1 -1
  52. package/dist/internal/touch.js +1 -0
  53. package/dist/keyboard/keyboardHeight.d.ts.map +1 -1
  54. package/dist/keyboard/keyboardHeight.js +13 -9
  55. package/dist/keyboard/useMobileKeyboard.d.ts.map +1 -1
  56. package/dist/keyboard/useMobileKeyboard.js +8 -7
  57. package/dist/privateAttributes/press.stylex.d.ts +40 -10
  58. package/dist/privateAttributes/press.stylex.d.ts.map +1 -1
  59. package/dist/privateAttributes/press.stylex.js +46 -10
  60. package/locales/en.json +4 -0
  61. package/locales/pseudo.json +3 -0
  62. package/package.json +10 -5
  63. package/src/BottomSheet/BottomSheetPanel.tsx +5 -4
  64. package/src/CheckboxInput/CheckboxInput.tsx +20 -60
  65. package/src/Item/Item.tsx +2 -2
  66. package/src/Layer/useTouchTrigger.ts +30 -1
  67. package/src/Outline/useScrollSpy.ts +22 -22
  68. package/src/RadioList/RadioListItem.tsx +19 -79
  69. package/src/Resizable/ResizeHandle.tsx +5 -6
  70. package/src/Resizable/useResizable.ts +5 -5
  71. package/src/Stepper/Step.tsx +6 -6
  72. package/src/Stepper/Stepper.doc.mjs +8 -2
  73. package/src/Table/plugins/sortable/useTableSortableState.tsx +10 -4
  74. package/src/Text/TruncationTooltip.tsx +16 -1
  75. package/src/Toast/ToastViewport.tsx +31 -5
  76. package/src/Token/Token.tsx +2 -2
  77. package/src/Tooltip/useTooltip.tsx +1 -0
  78. package/src/TreeList/TreeListItem.tsx +2 -2
  79. package/src/gestures/GestureHost.ts +125 -1
  80. package/src/gestures/README.md +21 -0
  81. package/src/gestures/contextRequest.ts +206 -0
  82. package/src/hooks/useClickableContainer.ts +2 -2
  83. package/src/hooks/useCommittedRef.ts +39 -0
  84. package/src/hooks/useMenuPress.ts +59 -62
  85. package/src/i18n/generated-locales/en.generated.ts +1 -0
  86. package/src/i18n/generated-locales/pseudo.generated.ts +1 -0
  87. package/src/internal/committed-ref.ts +15 -0
  88. package/src/internal/touch.ts +3 -0
  89. package/src/keyboard/keyboardHeight.ts +15 -17
  90. package/src/keyboard/useMobileKeyboard.ts +8 -7
  91. package/src/privateAttributes/press.stylex.ts +109 -10
@@ -27,6 +27,7 @@ import {
27
27
  type RefObject,
28
28
  } from 'react';
29
29
  import {currentGesture} from '../Layer/gestureCounter';
30
+ import {useCommittedRef} from './useCommittedRef';
30
31
  import {isInputShield} from '../Layer/inputHold';
31
32
  import {
32
33
  IDLE_MENU_PRESS,
@@ -383,8 +384,7 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
383
384
  publicOptions.longPressDelayMs === undefined ? 'uikit' : 'pointer',
384
385
  isInScrollView: isInsideScrollView,
385
386
  };
386
- const optionsRef = useRef(options);
387
- optionsRef.current = options;
387
+ const optionsRef = useCommittedRef(options);
388
388
  // The highlight, and the hover focus of the rows in this menu, follow the
389
389
  // last input, which this tracks for the menu's own document.
390
390
  useInteractionModalityTrackingFor(options.menuRef);
@@ -440,7 +440,7 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
440
440
  optionsRef.current.triggerRef?.current?.ownerDocument ??
441
441
  document
442
442
  );
443
- }, []);
443
+ }, [optionsRef]);
444
444
 
445
445
  const resolvePoint = useCallback(
446
446
  (event: PointerEvent): ResolvedPoint => {
@@ -491,7 +491,7 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
491
491
  }
492
492
  return {row, isInMenu, isOnTrigger};
493
493
  },
494
- [getDocument],
494
+ [getDocument, optionsRef],
495
495
  );
496
496
 
497
497
  const stopAutoscroll = useCallback(() => {
@@ -570,49 +570,47 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
570
570
  focusForLastInput(target, {preventScroll: true});
571
571
  }
572
572
  },
573
- [getDocument],
573
+ [getDocument, optionsRef],
574
574
  );
575
575
 
576
- const activate = useCallback((row: HTMLElement, release: PointerEvent) => {
577
- // Every click this dispatches passes the shared click guard.
578
- withoutClickGuard(() => {
579
- const {onActivate} = optionsRef.current;
580
- isModelActivation = true;
581
- try {
582
- if (onActivate != null) {
583
- onActivate(row, release);
584
- return;
576
+ const activate = useCallback(
577
+ (row: HTMLElement, release: PointerEvent) => {
578
+ // Every click this dispatches passes the shared click guard.
579
+ withoutClickGuard(() => {
580
+ const {onActivate} = optionsRef.current;
581
+ isModelActivation = true;
582
+ try {
583
+ if (onActivate != null) {
584
+ onActivate(row, release);
585
+ return;
586
+ }
587
+ // The row acts as its own click would. `detail: 0` marks a dispatched
588
+ // activation, as a keyboard's does, so the click guard lets it pass.
589
+ // The button and the modifiers are the release's.
590
+ row.dispatchEvent(
591
+ new MouseEvent('click', {
592
+ bubbles: true,
593
+ cancelable: true,
594
+ composed: true,
595
+ detail: 0,
596
+ button: release.button,
597
+ clientX: release.clientX,
598
+ clientY: release.clientY,
599
+ screenX: release.screenX,
600
+ screenY: release.screenY,
601
+ ctrlKey: release.ctrlKey,
602
+ shiftKey: release.shiftKey,
603
+ altKey: release.altKey,
604
+ metaKey: release.metaKey,
605
+ }),
606
+ );
607
+ } finally {
608
+ isModelActivation = false;
585
609
  }
586
- // The row acts as its own click would. `detail: 0` marks a dispatched
587
- // activation, as a keyboard's does, so the click guard lets it pass.
588
- // The button and the modifiers are the release's.
589
- row.dispatchEvent(
590
- new MouseEvent('click', {
591
- bubbles: true,
592
- cancelable: true,
593
- composed: true,
594
- detail: 0,
595
- button: release.button,
596
- clientX: release.clientX,
597
- clientY: release.clientY,
598
- screenX: release.screenX,
599
- screenY: release.screenY,
600
- ctrlKey: release.ctrlKey,
601
- shiftKey: release.shiftKey,
602
- altKey: release.altKey,
603
- metaKey: release.metaKey,
604
- }),
605
- );
606
- } finally {
607
- isModelActivation = false;
608
- }
609
- });
610
- }, []);
611
-
612
- // Declared before `step` so the mutual recursion through refs type-checks.
613
- const stepRef = useRef<
614
- (event: MenuPressInput<HTMLElement>, native?: PointerEvent) => void
615
- >(() => {});
610
+ });
611
+ },
612
+ [optionsRef],
613
+ );
616
614
 
617
615
  const applyEffect = useCallback(
618
616
  (
@@ -688,7 +686,7 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
688
686
  }
689
687
  }
690
688
  },
691
- [activate, endGesture, getDocument, highlight, stopAutoscroll],
689
+ [activate, endGesture, getDocument, highlight, optionsRef, stopAutoscroll],
692
690
  );
693
691
 
694
692
  const step = useCallback(
@@ -699,7 +697,8 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
699
697
  },
700
698
  [applyEffect],
701
699
  );
702
- stepRef.current = step;
700
+ // The trigger context is built once, so it calls `step` through this ref.
701
+ const stepRef = useCommittedRef(step);
703
702
 
704
703
  const getScroller = useCallback((): HTMLElement | null => {
705
704
  const {getScroller: custom, menuRef} = optionsRef.current;
@@ -711,7 +710,7 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
711
710
  return null;
712
711
  }
713
712
  return menu.scrollHeight > menu.clientHeight + 1 ? menu : null;
714
- }, []);
713
+ }, [optionsRef]);
715
714
 
716
715
  const updateAutoscroll = useCallback(
717
716
  (event: PointerEvent) => {
@@ -751,7 +750,7 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
751
750
  const last = lastPointerEventRef.current;
752
751
  if (last != null) {
753
752
  const point = resolvePoint(last);
754
- stepRef.current(
753
+ step(
755
754
  {
756
755
  type: 'move',
757
756
  row: point.row,
@@ -765,7 +764,7 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
765
764
  };
766
765
  autoscroll.update();
767
766
  },
768
- [autoscroll, getScroller, resolvePoint, stopAutoscroll],
767
+ [autoscroll, getScroller, resolvePoint, step, stopAutoscroll],
769
768
  );
770
769
 
771
770
  const attach = useCallback(
@@ -789,12 +788,12 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
789
788
  y: event.clientY,
790
789
  });
791
790
  if (isPending === false) {
792
- stepRef.current({type: 'cancel'});
791
+ step({type: 'cancel'});
793
792
  }
794
793
  return;
795
794
  }
796
795
  const point = resolvePoint(event);
797
- stepRef.current(
796
+ step(
798
797
  {
799
798
  type: 'move',
800
799
  row: point.row,
@@ -814,7 +813,7 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
814
813
  return;
815
814
  }
816
815
  const point = resolvePoint(event);
817
- stepRef.current(
816
+ step(
818
817
  {
819
818
  type: 'up',
820
819
  row: point.row,
@@ -833,20 +832,20 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
833
832
  if (event.pointerId !== pointerIdRef.current) {
834
833
  return;
835
834
  }
836
- stepRef.current({type: 'cancel'});
835
+ step({type: 'cancel'});
837
836
  };
838
837
  const onOtherPointerDown = (event: PointerEvent) => {
839
838
  // Any press ends a withdrawn gesture: its finger lifted where the
840
839
  // page could not see it, and the new press's click must act.
841
840
  if (gestureRef.current.phase === 'withdrawn') {
842
- stepRef.current({type: 'cancel'});
841
+ step({type: 'cancel'});
843
842
  return;
844
843
  }
845
844
  // A second pointer ends the gesture: two fingers are a pinch or a
846
845
  // scroll, never a pick.
847
846
  if (event.pointerId !== pointerIdRef.current) {
848
847
  ignoredPointerIdRef.current = event.pointerId;
849
- stepRef.current({type: 'cancel'});
848
+ step({type: 'cancel'});
850
849
  }
851
850
  };
852
851
  const onBlur = () => {
@@ -855,7 +854,7 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
855
854
  // these listeners until its release. That release acts on nothing, and
856
855
  // its click is swallowed. A mouse press ends as a cancel and keeps its
857
856
  // click.
858
- stepRef.current({type: 'withdraw'});
857
+ step({type: 'withdraw'});
859
858
  };
860
859
 
861
860
  doc.addEventListener('pointermove', onMove, true);
@@ -871,7 +870,7 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
871
870
  view?.removeEventListener('blur', onBlur);
872
871
  };
873
872
  },
874
- [getDocument, resolvePoint, updateAutoscroll],
873
+ [getDocument, optionsRef, resolvePoint, step, updateAutoscroll],
875
874
  );
876
875
 
877
876
  // `touch-action` was decided when the finger landed; the page must not
@@ -892,10 +891,8 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
892
891
  }, [getDocument]);
893
892
 
894
893
  // The trigger half below drives the model through this stable context.
895
- const installRef = useRef(installTouchMovePreventer);
896
- installRef.current = installTouchMovePreventer;
897
- const attachRef = useRef(attach);
898
- attachRef.current = attach;
894
+ const installRef = useCommittedRef(installTouchMovePreventer);
895
+ const attachRef = useCommittedRef(attach);
899
896
  const holdDetectorsRef = useRef<{
900
897
  plain: LongPressDetectorHandlers;
901
898
  scroller: LongPressDetectorHandlers;
@@ -989,7 +986,7 @@ export function useMenuPress(input: UseMenuPressOptions): UseMenuPressReturn {
989
986
  native,
990
987
  );
991
988
  },
992
- [attach, resolvePoint, step],
989
+ [attach, optionsRef, resolvePoint, step],
993
990
  );
994
991
 
995
992
  const isTriggerClickFromPress = useCallback((): boolean => {
@@ -728,6 +728,7 @@ const runtimeCatalog: Readonly<Record<string, string>> = {
728
728
  '@astryx.comments.postFailed': "Your comment couldn't be posted.",
729
729
  '@astryx.infoTip.label': 'More information',
730
730
  '@astryx.navigationStack.back': 'Back',
731
+ '@astryx.searchField.cancel': 'Cancel',
731
732
  };
732
733
 
733
734
  export default runtimeCatalog;
@@ -740,6 +740,7 @@ const runtimeCatalog: Readonly<Record<string, string>> = {
740
740
  '@astryx.comments.postFailed': "⟦Ýóúř çóɱɱéñţ çóúłðñ'ţ ƀé þóšţéð.⟧",
741
741
  '@astryx.infoTip.label': '⟦Ṁóřé íñƒóřɱàţíóñ⟧',
742
742
  '@astryx.navigationStack.back': '⟦Ɓàçķ⟧',
743
+ '@astryx.searchField.cancel': '⟦Çàñçéł⟧',
743
744
  };
744
745
 
745
746
  export default runtimeCatalog;
@@ -0,0 +1,15 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ /**
3
+ * @file committed-ref.ts
4
+ * @input Core's latest-value ref hooks
5
+ * @output `@astryxdesign/core/internal/committed-ref`: useCommittedRef and
6
+ * useCommittedRefInto, re-exported by name for Lab components
7
+ * @position An internal entry reserved for Astryx's own packages:
8
+ * undocumented, outside the public API and its compatibility promise,
9
+ * versioned in lockstep with Core, and allowed only in Core and Lab by the
10
+ * `@astryx/no-core-internal-import` lint rule. Core components import the
11
+ * same module by relative path. Named re-exports only.
12
+ *
13
+ * SYNC: When modified, update scripts/sync-exports.js.
14
+ */
15
+ export {useCommittedRef, useCommittedRefInto} from '../hooks/useCommittedRef';
@@ -60,9 +60,11 @@ export {useGestureRecognizer} from '../gestures/useGestureRecognizer';
60
60
  // only the theme's state-change motion.
61
61
  export {createMotionEngine} from '../motion/animator';
62
62
  export type {
63
+ AnimateOptions,
63
64
  Animator as MotionEngine,
64
65
  AnimatorOptions as MotionEngineOptions,
65
66
  MotionCurve,
67
+ MotionHandle,
66
68
  } from '../motion/animator';
67
69
  export {cubicBezier} from '../motion/bezier';
68
70
  export {mapProgress} from '../motion/progress';
@@ -87,6 +89,7 @@ export {resolveMotion} from '../motion/resolveMotion';
87
89
  export {solveSpring, toSpring} from '../motion/spring';
88
90
  export type {SpringDescription} from '../motion/spring';
89
91
  export {navigation} from '../motion/uikit/navigation';
92
+ export {timing} from '../motion/uikit/timing';
90
93
  export {
91
94
  NAVIGATION_BAR_ELEMENTS_SPRING,
92
95
  NAVIGATION_INTERACTIVE_POP_FINISH_SPRING,
@@ -19,7 +19,7 @@
19
19
  import {armClickGuard} from '../utils/clickGuard';
20
20
  import {matchesMediaQuery} from '../utils/coarsePointer';
21
21
  import {subscribeInput} from '../utils/inputStream';
22
- import {isNode} from '../utils/nodeType';
22
+ import {isElement, isHTMLElement, isNode} from '../utils/nodeType';
23
23
  import {layoutViewportHeight} from '../utils/layoutViewport';
24
24
  import {PRESS_SLOP_PX} from '../utils/pressGesture';
25
25
  import {caretAt} from '../utils/selectionLock';
@@ -306,28 +306,26 @@ export function getKeyboardHeight(win: Window): number {
306
306
  export function isTextEntryControl(
307
307
  element: Element | null,
308
308
  ): element is HTMLElement {
309
- if (
310
- element instanceof HTMLElement &&
311
- element.getAttribute('inputmode') === 'none'
312
- ) {
309
+ // Reads the kind by name, so an element of another window (a same-origin
310
+ // iframe, a Picture-in-Picture window) passes too.
311
+ if (!isHTMLElement(element) || element.getAttribute('inputmode') === 'none') {
313
312
  return false;
314
313
  }
315
- if (element instanceof HTMLTextAreaElement) {
316
- return !element.disabled && !element.readOnly;
314
+ if (element.localName === 'textarea') {
315
+ const textArea = element as HTMLTextAreaElement;
316
+ return !textArea.disabled && !textArea.readOnly;
317
317
  }
318
- if (element instanceof HTMLInputElement) {
318
+ if (element.localName === 'input') {
319
+ const input = element as HTMLInputElement;
319
320
  return (
320
- !element.disabled &&
321
- !element.readOnly &&
321
+ !input.disabled &&
322
+ !input.readOnly &&
322
323
  !NON_TEXT_INPUT_TYPES.has(
323
- (element.getAttribute('type') ?? 'text').toLowerCase(),
324
+ (input.getAttribute('type') ?? 'text').toLowerCase(),
324
325
  )
325
326
  );
326
327
  }
327
- return (
328
- element instanceof HTMLElement &&
329
- element.matches('[contenteditable]:not([contenteditable="false"])')
330
- );
328
+ return element.matches('[contenteditable]:not([contenteditable="false"])');
331
329
  }
332
330
 
333
331
  /** The text-entry control inside `container` that `target` is or labels. */
@@ -335,7 +333,7 @@ export function findTextEntryControl(
335
333
  target: EventTarget | null,
336
334
  container: HTMLElement,
337
335
  ): HTMLElement | null {
338
- if (!(target instanceof Element)) {
336
+ if (!isElement(target)) {
339
337
  return null;
340
338
  }
341
339
 
@@ -347,7 +345,7 @@ export function findTextEntryControl(
347
345
  }
348
346
 
349
347
  const label = target.closest('label');
350
- const control = label instanceof HTMLLabelElement ? label.control : null;
348
+ const control = isHTMLElement(label) ? label.control : null;
351
349
  return container.contains(control) && isTextEntryControl(control)
352
350
  ? control
353
351
  : null;
@@ -16,6 +16,7 @@
16
16
  import {useCallback, useEffect, useRef, useState, type RefObject} from 'react';
17
17
  import {flushSync} from 'react-dom';
18
18
  import {useAttachment} from '../hooks/useAttachment';
19
+ import {useCommittedRef} from '../hooks/useCommittedRef';
19
20
  import {useMediaQuery} from '../hooks/useMediaQuery';
20
21
  import {
21
22
  animatorFor,
@@ -186,12 +187,12 @@ export function useMobileKeyboard(
186
187
  const [keyboardInset, setKeyboardInset] = useState(0);
187
188
  const hasKeyboardLayoutRef = useRef(false);
188
189
  const retainKeyboardLayoutRef = useRef(false);
189
- const isEnabledRef = useRef(isEnabled);
190
- const isExpandedRef = useRef(isExpanded);
191
- const isOpenRef = useRef(isOpen);
192
- isEnabledRef.current = isEnabled;
193
- isExpandedRef.current = isExpanded;
194
- isOpenRef.current = isOpen;
190
+ // The committed options, which the listeners and the dismissal read. They
191
+ // are current before any layout effect, where an earlier sibling can move
192
+ // focus.
193
+ const isEnabledRef = useCommittedRef(isEnabled);
194
+ const isExpandedRef = useCommittedRef(isExpanded);
195
+ const isOpenRef = useCommittedRef(isOpen);
195
196
  // Touch-only work, the ride and the reveal-pan watch, attaches only under a
196
197
  // coarse primary pointer (the touch query). Under a fine one, the hook
197
198
  // registers no touch listener.
@@ -220,7 +221,7 @@ export function useMobileKeyboard(
220
221
  focusTarget.focus({preventScroll: true});
221
222
  }
222
223
  },
223
- [targetRef],
224
+ [isEnabledRef, targetRef],
224
225
  );
225
226
 
226
227
  // Syncs the on-screen keyboard with closing: a target that closes blurs its
@@ -6,17 +6,13 @@
6
6
  /**
7
7
  * @file privateAttributes/press.stylex.ts
8
8
  * @input StyleX, the overlay color tokens, the touch press strength
9
- * (`pressVars`) and the theme's exit motion tokens
10
- * @output `rowPressLayerStyles`, the compositor press layer for list rows,
11
- * which Button also composes. Its styles: `cell`, and `cellOnImage` for a
12
- * `backgroundImage` row. `cellOnImagePressOnly` is for a row whose fill is
13
- * the hover tone, and `overDividers` for a row of a List with dividers. Also
14
- * `controlPressLayerStyles`, what Button adds to that layer (`control`),
15
- * and `rowPressPaintStyles`, a CheckboxList row's press paint for its box.
9
+ * (`pressVars`), the theme's exit motion tokens and the indicator scope
10
+ * marker
11
+ * @output Ready-made press styles for list rows, Button and the layer over a
12
+ * selection control's box. No package entry exports them.
16
13
  * @position Owner module of the private press attribute: the press controller
17
- * (utils/pressFeedback.ts) writes it, and this file reads it. No package
18
- * entry exports it. Item, ListItem, TreeList, Button and CheckboxListItem
19
- * compose its styles; utils/interactionOverlay.cell.test.ts tests the row layer.
14
+ * (utils/pressFeedback.ts) writes it, and this file reads it.
15
+ * utils/interactionOverlay.cell.test.ts tests the row layer.
20
16
  */
21
17
 
22
18
  import * as stylex from '@stylexjs/stylex';
@@ -28,6 +24,7 @@ import {
28
24
  } from '../theme/tokens.stylex';
29
25
  import {reducedMotionFadeConsts} from '../motion/reducedMotion.stylex';
30
26
  import {pressVars} from '../utils/interactionOverlay.stylex';
27
+ import {indicatorScope} from '../Indicator/indicator.markers.stylex';
31
28
 
32
29
  // The overlay's arm selectors (interactionOverlay.stylex.ts), restated here:
33
30
  // StyleX resolves a style's keys within its own file.
@@ -42,6 +39,36 @@ const PRESSED_FADING = '[data-astryx-press="fading"]';
42
39
  */
43
40
  const PRESSED_ANY =
44
41
  ':is([data-astryx-press="on"],[data-astryx-press="fading"])';
42
+ /** The element is pressed, and the press controller does not paint the press. */
43
+ const ACTIVE_UNPAINTED = `:active:not(${PRESSED_ON},${PRESSED_FADING})`;
44
+
45
+ /**
46
+ * The nested controls that keep their own press, each at `:active`. It is
47
+ * INTERACTIVE_SELECTORS (hooks/useClickableContainer.ts), which StyleX cannot
48
+ * import, less the read-only ones. A RadioList row's own radio is the row's
49
+ * action, so its press is the row's. CSS cannot tell it from a nested radio
50
+ * input, so a nested one presses the circle too.
51
+ * RadioListItem.press.source-build.test.mjs keeps the two lists equal.
52
+ */
53
+ const NESTED_CONTROL_ACTIVE =
54
+ 'button:not([aria-readonly="true"]):active,' +
55
+ 'a:not([aria-readonly="true"]):active,' +
56
+ 'input:not([type="radio"],[aria-readonly="true"]):active,' +
57
+ 'select:not([aria-readonly="true"]):active,' +
58
+ 'textarea:not([aria-readonly="true"]):active,' +
59
+ '[role="button"]:not([aria-readonly="true"]):active,' +
60
+ '[role="link"]:not([aria-readonly="true"]):active,' +
61
+ '[role="checkbox"]:not([aria-readonly="true"]):active,' +
62
+ '[role="radio"]:not([aria-readonly="true"]):active,' +
63
+ '[role="switch"]:not([aria-readonly="true"]):active,' +
64
+ '[role="tab"]:not([aria-readonly="true"]):active,' +
65
+ '[role="menuitem"]:not([aria-readonly="true"]):active,' +
66
+ '[role="option"]:not([aria-readonly="true"]):active,' +
67
+ '[role="combobox"]:not([aria-readonly="true"]):active,' +
68
+ '[role="listbox"]:not([aria-readonly="true"]):active,' +
69
+ '[role="slider"]:not([aria-readonly="true"]):active,' +
70
+ '[role="spinbutton"]:not([aria-readonly="true"]):active,' +
71
+ '[data-pressable-container]:not([aria-readonly="true"]):active';
45
72
 
46
73
  const PRESS_ALPHA = pressVars['--astryx-press-alpha'];
47
74
 
@@ -373,4 +400,76 @@ export const rowPressPaintStyles = stylex.create({
373
400
  ':is([data-astryx-press="fading"])': 'var(--_press-paint-image)',
374
401
  },
375
402
  },
403
+ // A RadioList row declares the paint of a press the controller does not
404
+ // paint. A press through a nested control is that control's, as the row's
405
+ // container rule decides for the controller. The `:has()` is on the row
406
+ // itself and reaches no descendant selector, so a change inside the row
407
+ // re-checks the row alone. The circle's layer reads the paint through
408
+ // inheritance.
409
+ radioRow: {
410
+ '--_radio-row-press': {
411
+ default: null,
412
+ [`${ACTIVE_UNPAINTED}:not(:has(${NESTED_CONTROL_ACTIVE}))`]: {
413
+ default: colorVars['--color-overlay-pressed'],
414
+ [COARSE]: 'transparent',
415
+ },
416
+ },
417
+ },
418
+ });
419
+
420
+ /**
421
+ * Ready-made press paint for a selection control. `handDown` goes on
422
+ * CheckboxInput's row. `activeFill` and `image` go on the layer over the box
423
+ * or a RadioList option's circle. They read the press attribute off the
424
+ * indicator scope marker, as the hover tint does.
425
+ */
426
+ export const indicatorPressPaintStyles = stylex.create({
427
+ // A row hands its press image down to an indicator that paints its own
428
+ // press, but only in the row's own press states. A pressed outer row hands
429
+ // down nothing, as for the built-in box. The property has no default: a
430
+ // layered stylesheet ranks a default above the arms. Only CheckboxInput's
431
+ // row declares it. A menu item paints its own press, so a mapped indicator
432
+ // there paints none.
433
+ handDown: {
434
+ '--_indicator-press-image': {
435
+ default: null,
436
+ [PRESSED_ON]: pressedOverlayImage,
437
+ [PRESSED_FADING]: pressedOverlayImage,
438
+ },
439
+ // While the controller paints the press, the indicator's `:active` fill
440
+ // stays off, so a mouse's press paints once.
441
+ '--_indicator-active-press': {
442
+ default: null,
443
+ [PRESSED_ON]: 'transparent',
444
+ [PRESSED_FADING]: 'transparent',
445
+ },
446
+ },
447
+ // The `:active` fill, only for a press the controller does not paint. Under
448
+ // a coarse pointer it is dropped.
449
+ activeFill: {
450
+ '::after': {
451
+ backgroundColor: {
452
+ default: 'transparent',
453
+ [stylex.when.ancestor(ACTIVE_UNPAINTED, indicatorScope)]: {
454
+ default: colorVars['--color-overlay-pressed'],
455
+ [COARSE]: 'transparent',
456
+ },
457
+ },
458
+ },
459
+ },
460
+ // The controller's press paints as an image layer over the colour. An image
461
+ // change is discrete, so no transition can delay the onset. Only the
462
+ // strength moves: the row's `pressedAlpha` arms set it to 1 while on, and
463
+ // 1 → 0 over the release. This holds for every pointer, because the
464
+ // controller writes the attribute only for a press it paints.
465
+ image: {
466
+ '::after': {
467
+ backgroundImage: {
468
+ default: null,
469
+ [stylex.when.ancestor(PRESSED_ON, indicatorScope)]: pressedOverlayImage,
470
+ [stylex.when.ancestor(PRESSED_FADING, indicatorScope)]:
471
+ pressedOverlayImage,
472
+ },
473
+ },
474
+ },
376
475
  });