@astryxdesign/core 0.7.7-canary.550ff21 → 0.7.7-canary.559b005

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 (264) hide show
  1. package/dist/Avatar/Avatar.d.ts.map +1 -1
  2. package/dist/Avatar/Avatar.js +1 -1
  3. package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
  4. package/dist/Breadcrumbs/BreadcrumbItem.js +2 -1
  5. package/dist/Button/Button.d.ts.map +1 -1
  6. package/dist/Button/Button.js +3 -2
  7. package/dist/DateInput/Wheel.d.ts +17 -1
  8. package/dist/DateInput/Wheel.d.ts.map +1 -1
  9. package/dist/DateInput/Wheel.js +179 -19
  10. package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
  11. package/dist/DateRangeInput/DateRangeInput.js +63 -49
  12. package/dist/Dialog/Dialog.d.ts.map +1 -1
  13. package/dist/Dialog/Dialog.js +49 -12
  14. package/dist/Drawer/Drawer.d.ts.map +1 -1
  15. package/dist/Drawer/Drawer.js +15 -10
  16. package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -1
  17. package/dist/Drawer/useDrawerDialogPresence.js +4 -0
  18. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  19. package/dist/DropdownMenu/DropdownMenu.js +20 -4
  20. package/dist/InfoTip/InfoTip.d.ts +63 -0
  21. package/dist/InfoTip/InfoTip.d.ts.map +1 -0
  22. package/dist/InfoTip/InfoTip.js +126 -0
  23. package/dist/InfoTip/index.d.ts +10 -0
  24. package/dist/InfoTip/index.d.ts.map +1 -0
  25. package/dist/InfoTip/index.js +12 -0
  26. package/dist/Layer/layerClickBoundary.d.ts +7 -1
  27. package/dist/Layer/layerClickBoundary.d.ts.map +1 -1
  28. package/dist/Layer/layerClickBoundary.js +2 -2
  29. package/dist/Layer/useBackdropPress.d.ts +27 -0
  30. package/dist/Layer/useBackdropPress.d.ts.map +1 -0
  31. package/dist/Layer/useBackdropPress.js +53 -0
  32. package/dist/Layer/usePressPin.d.ts +95 -0
  33. package/dist/Layer/usePressPin.d.ts.map +1 -0
  34. package/dist/Layer/usePressPin.js +365 -0
  35. package/dist/Layer/useTouchTrigger.d.ts +23 -1
  36. package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
  37. package/dist/Layer/useTouchTrigger.js +45 -7
  38. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  39. package/dist/Lightbox/Lightbox.js +2 -1
  40. package/dist/Popover/usePopover.d.ts.map +1 -1
  41. package/dist/Popover/usePopover.js +56 -7
  42. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  43. package/dist/PowerSearch/PowerSearch.js +38 -30
  44. package/dist/ProgressBar/ProgressBar.d.ts +1 -1
  45. package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
  46. package/dist/ProgressBar/ProgressBar.js +33 -6
  47. package/dist/SegmentedControl/SegmentedControl.d.ts +3 -1
  48. package/dist/SegmentedControl/SegmentedControl.d.ts.map +1 -1
  49. package/dist/SegmentedControl/SegmentedControl.js +115 -8
  50. package/dist/SegmentedControl/SegmentedControlContext.d.ts +6 -0
  51. package/dist/SegmentedControl/SegmentedControlContext.d.ts.map +1 -1
  52. package/dist/SegmentedControl/SegmentedControlItem.d.ts +1 -0
  53. package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
  54. package/dist/SegmentedControl/SegmentedControlItem.js +10 -2
  55. package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts +357 -0
  56. package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts.map +1 -0
  57. package/dist/SegmentedControl/useSegmentedSelectionMotion.js +1349 -0
  58. package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts +70 -0
  59. package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts.map +1 -0
  60. package/dist/SegmentedControl/useSegmentedTouchTracking.js +264 -0
  61. package/dist/Selector/Selector.d.ts.map +1 -1
  62. package/dist/Selector/Selector.js +96 -67
  63. package/dist/Selector/optionShape.d.ts +24 -0
  64. package/dist/Selector/optionShape.d.ts.map +1 -0
  65. package/dist/Selector/optionShape.js +48 -0
  66. package/dist/Selector/selectableOptionEntries.d.ts +20 -0
  67. package/dist/Selector/selectableOptionEntries.d.ts.map +1 -0
  68. package/dist/Selector/selectableOptionEntries.js +38 -0
  69. package/dist/Selector/utils.d.ts +2 -17
  70. package/dist/Selector/utils.d.ts.map +1 -1
  71. package/dist/Selector/utils.js +3 -51
  72. package/dist/Switch/Switch.d.ts +1 -1
  73. package/dist/Switch/Switch.d.ts.map +1 -1
  74. package/dist/Switch/Switch.js +200 -46
  75. package/dist/Switch/switchFill.d.ts +31 -0
  76. package/dist/Switch/switchFill.d.ts.map +1 -0
  77. package/dist/Switch/switchFill.js +88 -0
  78. package/dist/Switch/switchTouch.d.ts +74 -0
  79. package/dist/Switch/switchTouch.d.ts.map +1 -0
  80. package/dist/Switch/switchTouch.js +125 -0
  81. package/dist/Switch/useSwitchTouch.d.ts +276 -0
  82. package/dist/Switch/useSwitchTouch.d.ts.map +1 -0
  83. package/dist/Switch/useSwitchTouch.js +939 -0
  84. package/dist/TabList/Tab.d.ts.map +1 -1
  85. package/dist/TabList/Tab.js +4 -3
  86. package/dist/Toast/Toast.d.ts.map +1 -1
  87. package/dist/Toast/Toast.js +5 -0
  88. package/dist/Token/Token.d.ts.map +1 -1
  89. package/dist/Token/Token.js +1 -0
  90. package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
  91. package/dist/Tokenizer/Tokenizer.js +12 -5
  92. package/dist/Tokenizer/TokenizerItemRemovableContext.d.ts +3 -0
  93. package/dist/Tokenizer/TokenizerItemRemovableContext.d.ts.map +1 -0
  94. package/dist/Tokenizer/TokenizerItemRemovableContext.js +17 -0
  95. package/dist/Tooltip/Tooltip.d.ts +30 -6
  96. package/dist/Tooltip/Tooltip.d.ts.map +1 -1
  97. package/dist/Tooltip/Tooltip.js +5 -0
  98. package/dist/Tooltip/index.d.ts +1 -1
  99. package/dist/Tooltip/index.d.ts.map +1 -1
  100. package/dist/Tooltip/useTooltip.d.ts +31 -5
  101. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  102. package/dist/Tooltip/useTooltip.js +59 -18
  103. package/dist/Typeahead/Typeahead.d.ts.map +1 -1
  104. package/dist/Typeahead/Typeahead.js +26 -15
  105. package/dist/astryx.css +125 -2
  106. package/dist/gestures/GestureHost.d.ts.map +1 -1
  107. package/dist/gestures/GestureHost.js +71 -14
  108. package/dist/gestures/PressTracker.d.ts +6 -0
  109. package/dist/gestures/PressTracker.d.ts.map +1 -1
  110. package/dist/gestures/PressTracker.js +3 -0
  111. package/dist/gestures/types.d.ts +6 -0
  112. package/dist/gestures/types.d.ts.map +1 -1
  113. package/dist/gestures/usePressTracker.d.ts.map +1 -1
  114. package/dist/gestures/usePressTracker.js +1 -0
  115. package/dist/gestures/wheelSegmenter.d.ts +14 -3
  116. package/dist/gestures/wheelSegmenter.d.ts.map +1 -1
  117. package/dist/gestures/wheelSegmenter.js +32 -8
  118. package/dist/hooks/actionGroupTracker.d.ts +3 -3
  119. package/dist/hooks/actionGroupTracker.d.ts.map +1 -1
  120. package/dist/hooks/actionGroupTracker.js +6 -53
  121. package/dist/hooks/useAttachment.d.ts +16 -8
  122. package/dist/hooks/useAttachment.d.ts.map +1 -1
  123. package/dist/hooks/useAttachment.js +35 -15
  124. package/dist/hooks/useFocusTrap.d.ts +15 -0
  125. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  126. package/dist/hooks/useFocusTrap.js +13 -2
  127. package/dist/hooks/useHighlightedOptionScroll.d.ts.map +1 -1
  128. package/dist/hooks/useHighlightedOptionScroll.js +14 -11
  129. package/dist/hooks/useMediaQuery.d.ts +2 -1
  130. package/dist/hooks/useMediaQuery.d.ts.map +1 -1
  131. package/dist/hooks/useMediaQuery.js +7 -4
  132. package/dist/hooks/usePager.d.ts +261 -0
  133. package/dist/hooks/usePager.d.ts.map +1 -0
  134. package/dist/hooks/usePager.js +1169 -0
  135. package/dist/i18n/generated-english/InfoTip/InfoTip.generated.d.ts +8 -0
  136. package/dist/i18n/generated-english/InfoTip/InfoTip.generated.d.ts.map +1 -0
  137. package/dist/i18n/generated-english/InfoTip/InfoTip.generated.js +12 -0
  138. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  139. package/dist/i18n/generated-locales/en.generated.js +2 -1
  140. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  141. package/dist/i18n/generated-locales/pseudo.generated.js +2 -1
  142. package/dist/index.d.ts +1 -0
  143. package/dist/index.d.ts.map +1 -1
  144. package/dist/index.js +1 -0
  145. package/dist/motion/paging.d.ts +16 -5
  146. package/dist/motion/paging.d.ts.map +1 -1
  147. package/dist/motion/paging.js +34 -14
  148. package/dist/motion/roles.d.ts +7 -1
  149. package/dist/motion/roles.d.ts.map +1 -1
  150. package/dist/motion/roles.js +20 -1
  151. package/dist/motion/uikit/index.d.ts +7 -4
  152. package/dist/motion/uikit/index.d.ts.map +1 -1
  153. package/dist/motion/uikit/index.js +7 -4
  154. package/dist/motion/uikit/paging.d.ts +31 -20
  155. package/dist/motion/uikit/paging.d.ts.map +1 -1
  156. package/dist/motion/uikit/paging.js +41 -11
  157. package/dist/motion/uikit/progressBar.d.ts +27 -7
  158. package/dist/motion/uikit/progressBar.d.ts.map +1 -1
  159. package/dist/motion/uikit/progressBar.js +31 -11
  160. package/dist/motion/uikit/segmented.d.ts +55 -0
  161. package/dist/motion/uikit/segmented.d.ts.map +1 -0
  162. package/dist/motion/uikit/segmented.js +77 -0
  163. package/dist/motion/uikit/springs.d.ts +8 -42
  164. package/dist/motion/uikit/springs.d.ts.map +1 -1
  165. package/dist/motion/uikit/springs.js +12 -42
  166. package/dist/motion/uikit/switch.d.ts +166 -0
  167. package/dist/motion/uikit/switch.d.ts.map +1 -0
  168. package/dist/motion/uikit/switch.js +186 -0
  169. package/dist/privateAttributes/pressHoldsDrag.stylex.d.ts +18 -0
  170. package/dist/privateAttributes/pressHoldsDrag.stylex.d.ts.map +1 -0
  171. package/dist/privateAttributes/pressHoldsDrag.stylex.js +28 -0
  172. package/dist/privateAttributes/segmentTitle.stylex.d.ts +5 -0
  173. package/dist/privateAttributes/segmentTitle.stylex.d.ts.map +1 -0
  174. package/dist/privateAttributes/segmentTitle.stylex.js +22 -0
  175. package/dist/utils/browserClickWait.d.ts +35 -0
  176. package/dist/utils/browserClickWait.d.ts.map +1 -0
  177. package/dist/utils/browserClickWait.js +123 -0
  178. package/dist/utils/clickGuard.d.ts +7 -1
  179. package/dist/utils/clickGuard.d.ts.map +1 -1
  180. package/dist/utils/clickGuard.js +23 -1
  181. package/dist/utils/pressFeedback.d.ts.map +1 -1
  182. package/dist/utils/pressFeedback.js +5 -0
  183. package/locales/en.json +4 -0
  184. package/locales/pseudo.json +3 -0
  185. package/package.json +9 -4
  186. package/src/Avatar/Avatar.tsx +3 -1
  187. package/src/Breadcrumbs/BreadcrumbItem.tsx +4 -1
  188. package/src/Button/Button.tsx +3 -2
  189. package/src/DateInput/Wheel.tsx +174 -14
  190. package/src/DateRangeInput/DateRangeInput.doc.mjs +3 -2
  191. package/src/DateRangeInput/DateRangeInput.tsx +117 -71
  192. package/src/Dialog/Dialog.tsx +62 -11
  193. package/src/Drawer/Drawer.tsx +27 -10
  194. package/src/Drawer/useDrawerDialogPresence.ts +4 -0
  195. package/src/DropdownMenu/DropdownMenu.tsx +28 -6
  196. package/src/InfoTip/InfoTip.doc.mjs +192 -0
  197. package/src/InfoTip/InfoTip.tsx +186 -0
  198. package/src/InfoTip/index.ts +14 -0
  199. package/src/Layer/layerClickBoundary.ts +2 -2
  200. package/src/Layer/useBackdropPress.ts +81 -0
  201. package/src/Layer/usePressPin.ts +516 -0
  202. package/src/Layer/useTouchTrigger.ts +56 -6
  203. package/src/Lightbox/Lightbox.tsx +2 -1
  204. package/src/Popover/usePopover.tsx +71 -9
  205. package/src/PowerSearch/PowerSearch.tsx +38 -31
  206. package/src/ProgressBar/ProgressBar.doc.mjs +4 -2
  207. package/src/ProgressBar/ProgressBar.tsx +67 -7
  208. package/src/SegmentedControl/SegmentedControl.doc.mjs +3 -3
  209. package/src/SegmentedControl/SegmentedControl.tsx +179 -5
  210. package/src/SegmentedControl/SegmentedControlContext.ts +6 -0
  211. package/src/SegmentedControl/SegmentedControlItem.tsx +14 -2
  212. package/src/SegmentedControl/useSegmentedSelectionMotion.ts +1637 -0
  213. package/src/SegmentedControl/useSegmentedTouchTracking.ts +308 -0
  214. package/src/Selector/Selector.tsx +136 -89
  215. package/src/Selector/optionShape.ts +64 -0
  216. package/src/Selector/selectableOptionEntries.ts +39 -0
  217. package/src/Selector/utils.ts +9 -68
  218. package/src/Switch/Switch.doc.mjs +3 -3
  219. package/src/Switch/Switch.tsx +412 -86
  220. package/src/Switch/switchFill.ts +106 -0
  221. package/src/Switch/switchTouch.ts +186 -0
  222. package/src/Switch/useSwitchTouch.ts +1051 -0
  223. package/src/TabList/Tab.tsx +5 -3
  224. package/src/Toast/Toast.tsx +5 -0
  225. package/src/Token/Token.tsx +2 -0
  226. package/src/Tokenizer/Tokenizer.tsx +15 -5
  227. package/src/Tokenizer/TokenizerItemRemovableContext.ts +22 -0
  228. package/src/Tooltip/Tooltip.doc.mjs +21 -6
  229. package/src/Tooltip/Tooltip.tsx +42 -5
  230. package/src/Tooltip/index.ts +1 -0
  231. package/src/Tooltip/useTooltip.doc.mjs +4 -2
  232. package/src/Tooltip/useTooltip.tsx +84 -21
  233. package/src/Typeahead/Typeahead.tsx +29 -15
  234. package/src/gestures/GestureHost.ts +100 -11
  235. package/src/gestures/PressTracker.ts +10 -0
  236. package/src/gestures/types.ts +6 -0
  237. package/src/gestures/usePressTracker.ts +2 -0
  238. package/src/gestures/wheelSegmenter.ts +36 -7
  239. package/src/hooks/actionGroupTracker.ts +12 -56
  240. package/src/hooks/useAttachment.ts +56 -14
  241. package/src/hooks/useFocusTrap.ts +26 -2
  242. package/src/hooks/useHighlightedOptionScroll.ts +15 -11
  243. package/src/hooks/useMediaQuery.doc.mjs +2 -2
  244. package/src/hooks/useMediaQuery.ts +13 -4
  245. package/src/hooks/usePager.ts +1446 -0
  246. package/src/i18n/generated-english/InfoTip/InfoTip.generated.ts +13 -0
  247. package/src/i18n/generated-locales/en.generated.ts +1 -0
  248. package/src/i18n/generated-locales/pseudo.generated.ts +1 -0
  249. package/src/index.ts +1 -0
  250. package/src/motion/MEASUREMENTS.md +36 -27
  251. package/src/motion/README.md +3 -1
  252. package/src/motion/paging.ts +37 -14
  253. package/src/motion/roles.ts +20 -1
  254. package/src/motion/uikit/index.ts +6 -5
  255. package/src/motion/uikit/paging.ts +41 -10
  256. package/src/motion/uikit/progressBar.ts +31 -11
  257. package/src/motion/uikit/segmented.ts +74 -0
  258. package/src/motion/uikit/springs.ts +12 -42
  259. package/src/motion/uikit/switch.ts +174 -0
  260. package/src/privateAttributes/pressHoldsDrag.stylex.ts +28 -0
  261. package/src/privateAttributes/segmentTitle.stylex.ts +22 -0
  262. package/src/utils/browserClickWait.ts +133 -0
  263. package/src/utils/clickGuard.ts +28 -1
  264. package/src/utils/pressFeedback.ts +5 -0
@@ -19,7 +19,7 @@
19
19
  import React, {useCallback, useEffect, useRef, type ReactNode} from 'react';
20
20
  import * as stylex from '@stylexjs/stylex';
21
21
  import {useLayer, type ContextRenderProps} from '../Layer/useLayer';
22
- import {useFocusTrap} from '../hooks/useFocusTrap';
22
+ import {useFocusTrapInternal} from '../hooks/useFocusTrap';
23
23
  import {LayerDepthProvider} from '../Layer/LayerDepthContext';
24
24
  import type {StyleXStyles} from '@stylexjs/stylex';
25
25
  import {
@@ -34,6 +34,7 @@ import {rtlStyles} from '../utils';
34
34
  import {useDevWarning} from '../hooks/useDevWarning';
35
35
  import {focusOutlineProps} from '../utils/focusOutline.stylex';
36
36
  import {mergeProps} from '../utils/mergeProps';
37
+ import {isFocusDetached} from '../utils/focusReturn';
37
38
  import {themeProps} from '../utils/themeProps';
38
39
  import {paddingStyles} from '../Layout/padding.stylex';
39
40
  import type {SpacingStep} from '../utils/types';
@@ -422,28 +423,51 @@ function usePopoverImplementation(
422
423
 
423
424
  // Track whether to skip auto-focus for the current open event
424
425
  const skipAutoFocusRef = useRef(false);
426
+ // Whether `show` focused a content control within the opening event.
427
+ const hasFocusedInGestureRef = useRef(false);
428
+
429
+ // Set when the layer reports it has shown, so `show` can tell a popover
430
+ // that opened within the call from one whose content mounts later.
431
+ const hasShownRef = useRef(false);
432
+ const handleLayerShow = useCallback(() => {
433
+ hasShownRef.current = true;
434
+ onShow?.();
435
+ }, [onShow]);
425
436
 
426
437
  // Core layer for popover positioning
427
438
  const layer = useLayer({
428
439
  mode: 'context',
429
440
  lightDismiss: hasLightDismiss,
430
- onShow,
441
+ onShow: handleLayerShow,
431
442
  onHide,
432
443
  });
433
444
 
434
445
  // Focus trap for the popover content. Escape stays registered while light
435
446
  // dismiss is on (native popover="auto" closes on Escape regardless), so a
436
447
  // host Dialog keeps deferring to this trap instead of double-dismissing.
437
- const {containerRef: contentRef, focusFirst} = useFocusTrap<HTMLDivElement>({
438
- isActive: layer.isOpen,
439
- onEscape: hasEscapeDismiss || hasLightDismiss ? layer.hide : undefined,
440
- });
448
+ // The element focused when `show` ran: initial focus may move inside before
449
+ // the trap activates, so the trap restores focus here instead.
450
+ const openerRef = useRef<HTMLElement | null>(null);
451
+ const getRestoreTarget = useCallback(() => openerRef.current, []);
452
+ const {containerRef: contentRef, focusFirst} =
453
+ useFocusTrapInternal<HTMLDivElement>({
454
+ isActive: layer.isOpen,
455
+ onEscape: hasEscapeDismiss || hasLightDismiss ? layer.hide : undefined,
456
+ getRestoreTarget,
457
+ });
441
458
 
442
459
  const focusInitialTarget = useCallback(() => {
443
460
  const container = contentRef.current;
444
461
  if (!container) {
445
462
  return;
446
463
  }
464
+ // Focus already on a control inside (set in `onShow`, or a press in the
465
+ // content) is where the user or the caller wants it; moving it would
466
+ // undo that.
467
+ const active = container.ownerDocument.activeElement;
468
+ if (active != null && active !== container && container.contains(active)) {
469
+ return;
470
+ }
447
471
  if (focusFirstContentControl(container)) {
448
472
  return;
449
473
  }
@@ -459,16 +483,23 @@ function usePopoverImplementation(
459
483
  // Reset the per-open focus preference after the popover closes.
460
484
  if (!layer.isOpen) {
461
485
  skipAutoFocusRef.current = false;
486
+ hasFocusedInGestureRef.current = false;
462
487
  return;
463
488
  }
464
489
  if (hasAutoFocus && !skipAutoFocusRef.current) {
465
490
  // Wait a frame so the content is mounted. A popover that closes or
466
491
  // unmounts first cancels it: the frame would otherwise move focus into
467
492
  // content that is no longer shown, after the close had left it alone.
468
- const frame = requestAnimationFrame(focusInitialTarget);
493
+ const frame = requestAnimationFrame(() => {
494
+ const doc = contentRef.current?.ownerDocument ?? document;
495
+ if (hasFocusedInGestureRef.current && !isFocusDetached(doc)) {
496
+ return;
497
+ }
498
+ focusInitialTarget();
499
+ });
469
500
  return () => cancelAnimationFrame(frame);
470
501
  }
471
- }, [layer.isOpen, hasAutoFocus, focusInitialTarget]);
502
+ }, [layer.isOpen, hasAutoFocus, focusInitialTarget, contentRef]);
472
503
 
473
504
  // Combined ref for trigger element (layer anchor + our ref). It is keyed on
474
505
  // the layer's own ref, not the whole layer: the layer object changes with
@@ -490,9 +521,40 @@ function usePopoverImplementation(
490
521
  const show = useCallback(
491
522
  (showOptions?: {skipAutoFocus?: boolean}) => {
492
523
  skipAutoFocusRef.current = showOptions?.skipAutoFocus ?? false;
524
+ hasShownRef.current = false;
525
+ const activeElement = (
526
+ triggerElementRef.current?.ownerDocument ?? document
527
+ ).activeElement as HTMLElement | null;
528
+ openerRef.current =
529
+ activeElement != null && !contentRef.current?.contains(activeElement)
530
+ ? activeElement
531
+ : null;
493
532
  layer.show();
533
+ // When the content is already mounted, the layer shows it within this
534
+ // call, so initial focus lands within the event that opened it: iOS
535
+ // raises its keyboard only for a focus made while the tap is still
536
+ // being handled. The frame in the effect above stays for content that
537
+ // mounts later.
538
+ // Only a content control already rendered takes focus here; content
539
+ // that renders on open (and the dialog-surface fallback) waits for the
540
+ // effect's frame.
541
+ const container = contentRef.current;
542
+ if (
543
+ hasShownRef.current &&
544
+ hasAutoFocus &&
545
+ !skipAutoFocusRef.current &&
546
+ container != null &&
547
+ !container.contains(container.ownerDocument.activeElement) &&
548
+ focusFirstContentControl(container)
549
+ ) {
550
+ // Initial focus is done. The effect's frame stays only as a fallback
551
+ // for focus lost to the page (content swapped in the same handler
552
+ // unmounts the control just focused); it must not move focus the user
553
+ // has since moved elsewhere.
554
+ hasFocusedInGestureRef.current = true;
555
+ }
494
556
  },
495
- [layer],
557
+ [layer, hasAutoFocus, contentRef],
496
558
  );
497
559
 
498
560
  // Toggle function. Opening delegates to show so every route inherits the
@@ -31,6 +31,7 @@ import {
31
31
  type TokenizerOverflowBehavior,
32
32
  } from '../Tokenizer';
33
33
  import {TokenizerClearAllMessageContext} from '../Tokenizer/TokenizerClearAllMessageContext';
34
+ import {TokenizerItemRemovableContext} from '../Tokenizer/TokenizerItemRemovableContext';
34
35
  import {TypeaheadItem} from '../Typeahead/TypeaheadItem';
35
36
  import {Token} from '../Token';
36
37
  import {Avatar} from '../Avatar';
@@ -751,6 +752,10 @@ export function PowerSearch({
751
752
  [config, filters, onChange, setPopoverState],
752
753
  );
753
754
 
755
+ // Tokenizer's Backspace does not go through renderToken. This predicate
756
+ // locks every token of a read-only field.
757
+ const isItemRemovable = useCallback(() => !isReadOnly, [isReadOnly]);
758
+
754
759
  // Handle clicking a token to edit
755
760
  const handleTokenClick = useCallback(
756
761
  (index: number) => {
@@ -1117,37 +1122,39 @@ export function PowerSearch({
1117
1122
  {/* The field's Clear all announces PowerSearch's own words
1118
1123
  (component:PowerSearch; component:Tokenizer AR7). */}
1119
1124
  <TokenizerClearAllMessageContext value={clearAllMessage}>
1120
- <Tokenizer
1121
- handleRef={tokenizerRef}
1122
- label={label}
1123
- isLabelHidden={isLabelHidden}
1124
- searchSource={searchSource}
1125
- value={tokenizerValue}
1126
- onChange={handleTokenizerChange}
1127
- renderToken={renderToken}
1128
- renderItem={renderItem}
1129
- maxMenuItems={MAX_BROWSE_MENU_ITEMS}
1130
- menuWidth={menuWidth}
1131
- placeholder={filters.length === 0 ? placeholder : ''}
1132
- hasAutoFocus={hasAutoFocus}
1133
- hasClear={hasClear && !isReadOnly}
1134
- startIcon={startIcon}
1135
- endContent={combinedEndContent}
1136
- isDisabled={isDisabled}
1137
- disabledMessage={disabledMessage}
1138
- size={size}
1139
- tokenOverflowBehavior={tokenOverflowBehavior}
1140
- hasEntriesOnFocus
1141
- debounceMs={0}
1142
- status={status}
1143
- statusVariant={statusVariant}
1144
- onFocus={onFocus}
1145
- onBlur={onBlur}
1146
- containerXstyle={xstyle}
1147
- containerClassName={className}
1148
- containerStyle={style}
1149
- data-testid={testId}
1150
- />
1125
+ <TokenizerItemRemovableContext value={isItemRemovable}>
1126
+ <Tokenizer
1127
+ handleRef={tokenizerRef}
1128
+ label={label}
1129
+ isLabelHidden={isLabelHidden}
1130
+ searchSource={searchSource}
1131
+ value={tokenizerValue}
1132
+ onChange={handleTokenizerChange}
1133
+ renderToken={renderToken}
1134
+ renderItem={renderItem}
1135
+ maxMenuItems={MAX_BROWSE_MENU_ITEMS}
1136
+ menuWidth={menuWidth}
1137
+ placeholder={filters.length === 0 ? placeholder : ''}
1138
+ hasAutoFocus={hasAutoFocus}
1139
+ hasClear={hasClear && !isReadOnly}
1140
+ startIcon={startIcon}
1141
+ endContent={combinedEndContent}
1142
+ isDisabled={isDisabled}
1143
+ disabledMessage={disabledMessage}
1144
+ size={size}
1145
+ tokenOverflowBehavior={tokenOverflowBehavior}
1146
+ hasEntriesOnFocus
1147
+ debounceMs={0}
1148
+ status={status}
1149
+ statusVariant={statusVariant}
1150
+ onFocus={onFocus}
1151
+ onBlur={onBlur}
1152
+ containerXstyle={xstyle}
1153
+ containerClassName={className}
1154
+ containerStyle={style}
1155
+ data-testid={testId}
1156
+ />
1157
+ </TokenizerItemRemovableContext>
1151
1158
  </TokenizerClearAllMessageContext>
1152
1159
  </div>
1153
1160
  {popover.render(popoverContent, {
@@ -101,7 +101,8 @@ export const docs = {
101
101
  {
102
102
  name: 'isIndeterminate',
103
103
  type: 'boolean',
104
- description: 'Animated loading indicator for unknown progress.',
104
+ description:
105
+ 'Animated loading indicator for unknown progress. Under reduced motion it pulses in place instead of sliding.',
105
106
  default: 'false',
106
107
  },
107
108
  {
@@ -390,7 +391,8 @@ export const docsDense = {
390
391
  formatValueLabel:
391
392
  'Custom value label formatter; defaults to percentage string.',
392
393
  variant: 'Semantic color variant.',
393
- isIndeterminate: 'Animated loading indicator for unknown progress.',
394
+ isIndeterminate:
395
+ 'Animated loading indicator for unknown progress. Under reduced motion it pulses in place instead of sliding.',
394
396
  marks:
395
397
  'Fixed target marks ({value, label?}) drawn on the track in the 0..max scale; stay visible past the fill. Marks inside the fill take the variant on-color; marks on the bare track take the primary text color (secondary when disabled). A label reveals a tooltip on hover/focus. Ignored when indeterminate.',
396
398
  isDisabled: 'Visually disabled: grays out fill and text.',
@@ -4,7 +4,7 @@
4
4
 
5
5
  /**
6
6
  * @file ProgressBar.tsx
7
- * @input Uses React, useId, stylex, tokens and ProgressBarTouch
7
+ * @input Uses React, useId, stylex, tokens, ProgressBarTouch and resolveMotion
8
8
  * @output Exports ProgressBar component, ProgressBarProps, ProgressBarVariant types
9
9
  * @position Core implementation; consumed by index.ts
10
10
  *
@@ -36,6 +36,10 @@ import {themeProps} from '../utils/themeProps';
36
36
  import {VisuallyHidden} from '../VisuallyHidden';
37
37
  import type {ProgressBarVariantMap} from './index';
38
38
  import {useProgressBarTouch} from './ProgressBarTouch';
39
+ import {formatMotionRoleValue} from '../motion/roles';
40
+ import {resolveMotion} from '../motion/resolveMotion';
41
+ import {progressBar} from '../motion/uikit/progressBar';
42
+ import {timing} from '../motion/uikit/timing';
39
43
 
40
44
  // Every mark is wrapped in a Tooltip (marks always carry a label), so load it
41
45
  // lazily: a ProgressBar with no marks never bundles the Tooltip chunk. While it
@@ -117,7 +121,7 @@ export interface ProgressBarProps extends BaseProps<HTMLDivElement> {
117
121
  * When true, renders an animated indeterminate progress indicator.
118
122
  * Use when the progress amount is unknown (e.g. loading, processing).
119
123
  * The `value` and `hasValueLabel` props are ignored in this mode.
120
- * Respects `prefers-reduced-motion` by slowing the animation.
124
+ * Under reduced motion it pulses in place instead of sliding.
121
125
  * @default false
122
126
  */
123
127
  isIndeterminate?: boolean;
@@ -170,6 +174,19 @@ const indeterminateSlideRtl = stylex.keyframes({
170
174
  },
171
175
  });
172
176
 
177
+ // Under reduced motion the indeterminate fill stops travelling and pulses in
178
+ // place. It goes from full opacity down to the pulse's floor
179
+ // (`--_progress-bar-pulse-floor`, the progress table's) and back. The
180
+ // animation alternates direction each pass.
181
+ const indeterminatePulse = stylex.keyframes({
182
+ from: {
183
+ opacity: 1,
184
+ },
185
+ to: {
186
+ opacity: 'var(--_progress-bar-pulse-floor)',
187
+ },
188
+ });
189
+
173
190
  // =============================================================================
174
191
  // Styles
175
192
  // =============================================================================
@@ -266,7 +283,6 @@ const styles = stylex.create({
266
283
  default: '100%',
267
284
  '@media (forced-colors: active)': {
268
285
  default: 'var(--_progress-bar-fill, 0%)',
269
- // Under a finger: the touch minimum and the flip offset (below).
270
286
  '@media (pointer: coarse)':
271
287
  'calc(max(var(--_progress-bar-fill, 0%), var(--_progress-bar-min, 0px)) + var(--_progress-bar-flip, 0) * 0.01px)',
272
288
  },
@@ -353,17 +369,37 @@ const styles = stylex.create({
353
369
  '@media (forced-colors: active)': 'CanvasText',
354
370
  },
355
371
  outlineOffset: {default: null, '@media (forced-colors: active)': '-1px'},
356
- width: '40%',
372
+ // Under reduced motion, on every pointer, the fill spans the whole track
373
+ // as one solid bar, and only its opacity pulses. Each way takes the
374
+ // `progress.reducedMotionPulseMs` role on the `timing.curves.move` curve
375
+ // (`--_progress-bar-pulse`, `--_progress-bar-pulse-curve`, set inline from
376
+ // the progress table). A busy loop: tempo does not scale it.
377
+ width: {
378
+ default: '40%',
379
+ '@media (prefers-reduced-motion: reduce)': '100%',
380
+ },
357
381
  borderRadius: radiusVars['--radius-full'],
358
382
  animationName: {
359
383
  default: indeterminateSlide,
360
- ':is([dir="rtl"] *)': indeterminateSlideRtl,
384
+ ':is([dir="rtl"] *)': {
385
+ default: indeterminateSlideRtl,
386
+ '@media (prefers-reduced-motion: reduce)': indeterminatePulse,
387
+ },
388
+ '@media (prefers-reduced-motion: reduce)': indeterminatePulse,
361
389
  },
362
390
  animationDuration: {
363
391
  default: '1.5s',
364
- '@media (prefers-reduced-motion: reduce)': '3s',
392
+ '@media (prefers-reduced-motion: reduce)': 'var(--_progress-bar-pulse)',
393
+ },
394
+ animationTimingFunction: {
395
+ default: 'ease-in-out',
396
+ '@media (prefers-reduced-motion: reduce)':
397
+ 'var(--_progress-bar-pulse-curve)',
398
+ },
399
+ animationDirection: {
400
+ default: null,
401
+ '@media (prefers-reduced-motion: reduce)': 'alternate',
365
402
  },
366
- animationTimingFunction: 'ease-in-out',
367
403
  animationIterationCount: 'infinite',
368
404
  },
369
405
  // A mark is a vertical tick centered on the track via their shared positioning container.
@@ -474,6 +510,15 @@ const markOnTrackStyles = stylex.create({
474
510
  },
475
511
  });
476
512
 
513
+ // The reduced-motion pulse's variables, from the progress table.
514
+ type PulseStyle = CSSProperties &
515
+ Record<
516
+ | '--_progress-bar-pulse'
517
+ | '--_progress-bar-pulse-curve'
518
+ | '--_progress-bar-pulse-floor',
519
+ string
520
+ >;
521
+
477
522
  // `CSSProperties` has no index signature for custom properties, so the fill's
478
523
  // inline style — which publishes the filled share as the private
479
524
  // `--_progress-bar-fill` — needs this augmentation to typecheck.
@@ -487,6 +532,20 @@ type FillStyle = CSSProperties &
487
532
  string
488
533
  >;
489
534
 
535
+ /**
536
+ * The reduced-motion pulse plays the `progress.reducedMotionPulseMs` role on
537
+ * the `timing.curves.move` curve, down to the progress table's floor.
538
+ */
539
+ function pulseStyle(element: Element | null): PulseStyle {
540
+ const pulseMs = resolveMotion(element, progressBar, 'reducedMotionPulseMs');
541
+ const curve = resolveMotion(element, timing.curves.move);
542
+ return {
543
+ '--_progress-bar-pulse': `${pulseMs}ms`,
544
+ '--_progress-bar-pulse-curve': formatMotionRoleValue('curve', curve),
545
+ '--_progress-bar-pulse-floor': String(progressBar.reducedMotionPulseFloor),
546
+ };
547
+ }
548
+
490
549
  function defaultFormatValueLabel(value: number, max: number): string {
491
550
  const pct = max > 0 ? Math.round((value / max) * 100) : 0;
492
551
  return `${pct}%`;
@@ -662,6 +721,7 @@ export function ProgressBar({
662
721
  variantStyles[fillVariant],
663
722
  ),
664
723
  )}
724
+ style={pulseStyle(null)}
665
725
  />
666
726
  ) : (
667
727
  <div
@@ -168,7 +168,7 @@ function WorkspaceCard() {
168
168
  usage: {
169
169
  anatomy,
170
170
  description:
171
- 'A segmented button group that allows users to make a single selection from a small set of mutually exclusive options. Use SegmentedControl when all options should be visible at once and the selection controls a value or mode, not page navigation.',
171
+ 'A segmented button group that allows users to make a single selection from a small set of mutually exclusive options. Use SegmentedControl when all options should be visible at once and the selection controls a value or mode, not page navigation. Under a finger, on a touch device (a coarse primary pointer), the selection slides to the new segment, whether a tap, an arrow key or a new value moved it; with Reduce Motion nothing travels: the old selection fades out as the new one fades in. There, dragging the selected segment carries the selection along with the selected label’s colour following it, and the segment under the finger is chosen when it lets go (letting go outside the control selects nothing); a tap selects through the browser’s click; a pressed segment shows the shared pressed overlay, and nothing lifts or dims. With a mouse or a pen every change, a click included, slides on the theme’s duration and easing, and dragging the selected segment carries it as a finger does.',
172
172
  accessibility: [
173
173
  {
174
174
  name: 'Text label',
@@ -240,7 +240,7 @@ export const docsZh = {
240
240
  usage: {
241
241
  anatomy,
242
242
  description:
243
- 'A segmented button group that allows users to make a single selection from a small set of mutually exclusive options. Use SegmentedControl when all options should be visible at once and the selection controls a value or mode, not page navigation.',
243
+ 'A segmented button group that allows users to make a single selection from a small set of mutually exclusive options. Use SegmentedControl when all options should be visible at once and the selection controls a value or mode, not page navigation. Under a finger, on a touch device (a coarse primary pointer), the selection slides to the new segment, whether a tap, an arrow key or a new value moved it; with Reduce Motion nothing travels: the old selection fades out as the new one fades in. There, dragging the selected segment carries the selection along with the selected label’s colour following it, and the segment under the finger is chosen when it lets go (letting go outside the control selects nothing); a tap selects through the browser’s click; a pressed segment shows the shared pressed overlay, and nothing lifts or dims. With a mouse or a pen every change, a click included, slides on the theme’s duration and easing, and dragging the selected segment carries it as a finger does.',
244
244
  bestPractices: [
245
245
  {guidance: true, description: 'Use for switching between 2–5 mutually exclusive views or modes where all options should be visible.'},
246
246
  {guidance: true, description: 'Provide a descriptive label for the control to ensure the group is accessible to screen readers.'},
@@ -256,7 +256,7 @@ export const docsDense = {
256
256
  usage: {
257
257
  anatomy,
258
258
  description:
259
- 'A segmented button group that allows users to make a single selection from a small set of mutually exclusive options. Use SegmentedControl when all options should be visible at once and the selection controls a value or mode, not page navigation.',
259
+ 'A segmented button group that allows users to make a single selection from a small set of mutually exclusive options. Use SegmentedControl when all options should be visible at once and the selection controls a value or mode, not page navigation. Under a finger, on a touch device (a coarse primary pointer), the selection slides to the new segment, whether a tap, an arrow key or a new value moved it; with Reduce Motion nothing travels: the old selection fades out as the new one fades in. There, dragging the selected segment carries the selection along with the selected label’s colour following it, and the segment under the finger is chosen when it lets go (letting go outside the control selects nothing); a tap selects through the browser’s click; a pressed segment shows the shared pressed overlay, and nothing lifts or dims. With a mouse or a pen every change, a click included, slides on the theme’s duration and easing, and dragging the selected segment carries it as a finger does.',
260
260
  bestPractices: [
261
261
  {guidance: true, description: 'Use for switching between 2–5 mutually exclusive views or modes where all options should be visible.'},
262
262
  {guidance: true, description: 'Provide a descriptive label for the control to ensure the group is accessible to screen readers.'},