@astryxdesign/core 0.7.8 → 0.7.9-canary.0a64fdb

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 (276) hide show
  1. package/dist/AppShell/observeMainOverflow.d.ts.map +1 -1
  2. package/dist/AppShell/observeMainOverflow.js +9 -6
  3. package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
  4. package/dist/BottomSheet/BottomSheet.js +5 -0
  5. package/dist/Calendar/styles.d.ts +1 -1
  6. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  7. package/dist/CheckboxInput/CheckboxInput.js +54 -11
  8. package/dist/ClickableCard/ClickableCard.d.ts +1 -1
  9. package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
  10. package/dist/ClickableCard/ClickableCard.js +5 -1
  11. package/dist/DateInput/PickerWheel.d.ts.map +1 -1
  12. package/dist/DateInput/PickerWheel.js +7 -1
  13. package/dist/DateRangeInput/DateRangeInput.js +1 -1
  14. package/dist/Dialog/Dialog.d.ts +2 -1
  15. package/dist/Dialog/Dialog.d.ts.map +1 -1
  16. package/dist/Dialog/Dialog.js +12 -1
  17. package/dist/Drawer/useDrawerDialogPresence.d.ts +2 -1
  18. package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -1
  19. package/dist/Drawer/useDrawerDialogPresence.js +11 -2
  20. package/dist/DropdownMenu/DropdownMenu.d.ts +9 -1
  21. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  22. package/dist/DropdownMenu/DropdownMenu.js +9 -4
  23. package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +1 -1
  24. package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +3 -2
  25. package/dist/DropdownMenu/DropdownMenuItem.d.ts.map +1 -1
  26. package/dist/DropdownMenu/DropdownMenuItem.js +3 -2
  27. package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -1
  28. package/dist/DropdownMenu/DropdownMenuRadioItem.js +3 -2
  29. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  30. package/dist/DropdownMenu/DropdownMenuSubMenu.js +3 -2
  31. package/dist/Field/inputDisabledFocus.d.ts +4 -4
  32. package/dist/Field/inputStyles.stylex.d.ts +1 -1
  33. package/dist/FileInput/FileInput.d.ts.map +1 -1
  34. package/dist/FileInput/FileInput.js +16 -2
  35. package/dist/Icon/Icon.d.ts +1 -1
  36. package/dist/InfoTip/InfoTip.d.ts +1 -0
  37. package/dist/InfoTip/InfoTip.d.ts.map +1 -1
  38. package/dist/InfoTip/InfoTip.js +1 -0
  39. package/dist/InputGroup/InputGroup.d.ts +4 -3
  40. package/dist/InputGroup/InputGroup.d.ts.map +1 -1
  41. package/dist/InputGroup/InputGroup.js +2 -2
  42. package/dist/InputGroup/groupStyles.d.ts +1 -1
  43. package/dist/InputGroup/groupStyles.d.ts.map +1 -1
  44. package/dist/InputGroup/groupStyles.js +1 -1
  45. package/dist/Item/Item.d.ts +2 -1
  46. package/dist/Item/Item.d.ts.map +1 -1
  47. package/dist/Item/Item.js +29 -6
  48. package/dist/Layer/holdEntranceInput.d.ts +24 -0
  49. package/dist/Layer/holdEntranceInput.d.ts.map +1 -0
  50. package/dist/Layer/holdEntranceInput.js +65 -0
  51. package/dist/Layer/inputHold.d.ts +49 -0
  52. package/dist/Layer/inputHold.d.ts.map +1 -0
  53. package/dist/Layer/inputHold.js +636 -0
  54. package/dist/Layer/preserveAnimations.d.ts +1 -5
  55. package/dist/Layer/preserveAnimations.d.ts.map +1 -1
  56. package/dist/Layer/preserveAnimations.js +12 -214
  57. package/dist/Layout/LayoutContent.d.ts +3 -1
  58. package/dist/Layout/LayoutContent.d.ts.map +1 -1
  59. package/dist/Layout/LayoutContent.js +12 -4
  60. package/dist/Layout/LayoutPanel.d.ts +4 -1
  61. package/dist/Layout/LayoutPanel.d.ts.map +1 -1
  62. package/dist/Layout/LayoutPanel.js +13 -4
  63. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  64. package/dist/Lightbox/Lightbox.js +4 -0
  65. package/dist/MetadataList/MetadataList.js +1 -1
  66. package/dist/MobileNav/MobileNav.d.ts +11 -1
  67. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  68. package/dist/MobileNav/MobileNav.js +39 -1
  69. package/dist/MoreMenu/MoreMenu.d.ts +5 -3
  70. package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
  71. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  72. package/dist/RadioList/RadioListItem.js +22 -4
  73. package/dist/SelectableCard/SelectableCard.d.ts +1 -1
  74. package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
  75. package/dist/SelectableCard/SelectableCard.js +5 -1
  76. package/dist/Spinner/Spinner.d.ts.map +1 -1
  77. package/dist/Spinner/Spinner.js +12 -2
  78. package/dist/Stack/StackItem.d.ts +8 -4
  79. package/dist/Stack/StackItem.d.ts.map +1 -1
  80. package/dist/Stack/StackItem.js +17 -4
  81. package/dist/Table/plugins/sortable/useTableSortable.js +1 -1
  82. package/dist/Token/Token.d.ts.map +1 -1
  83. package/dist/Token/Token.js +9 -0
  84. package/dist/Token/TokenLink.d.ts +1 -1
  85. package/dist/Token/TokenLink.d.ts.map +1 -1
  86. package/dist/Token/TokenLink.js +4 -1
  87. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  88. package/dist/Tooltip/useTooltip.js +162 -59
  89. package/dist/TreeList/TreeListItem.d.ts +2 -1
  90. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  91. package/dist/TreeList/TreeListItem.js +27 -3
  92. package/dist/astryx.css +35 -8
  93. package/dist/gestures/GestureHost.d.ts +2 -2
  94. package/dist/gestures/GestureHost.d.ts.map +1 -1
  95. package/dist/gestures/GestureHost.js +21 -6
  96. package/dist/gestures/PanGestureRecognizer.d.ts +11 -1
  97. package/dist/gestures/PanGestureRecognizer.d.ts.map +1 -1
  98. package/dist/gestures/PanGestureRecognizer.js +15 -1
  99. package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts +6 -1
  100. package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts.map +1 -1
  101. package/dist/gestures/nativeScroll.d.ts +3 -6
  102. package/dist/gestures/nativeScroll.d.ts.map +1 -1
  103. package/dist/gestures/nativeScroll.js +7 -52
  104. package/dist/gestures/wheelSegmenter.d.ts +68 -1
  105. package/dist/gestures/wheelSegmenter.d.ts.map +1 -1
  106. package/dist/gestures/wheelSegmenter.js +199 -10
  107. package/dist/hooks/StackItemScrollRegion.d.ts +31 -0
  108. package/dist/hooks/StackItemScrollRegion.d.ts.map +1 -0
  109. package/dist/hooks/StackItemScrollRegion.js +40 -0
  110. package/dist/hooks/menuPressGesture.d.ts +133 -21
  111. package/dist/hooks/menuPressGesture.d.ts.map +1 -1
  112. package/dist/hooks/menuPressGesture.js +155 -30
  113. package/dist/hooks/menuPressValues.d.ts +16 -0
  114. package/dist/hooks/menuPressValues.d.ts.map +1 -0
  115. package/dist/hooks/menuPressValues.js +18 -0
  116. package/dist/hooks/useClickableContainer.d.ts +27 -5
  117. package/dist/hooks/useClickableContainer.d.ts.map +1 -1
  118. package/dist/hooks/useClickableContainer.js +41 -5
  119. package/dist/hooks/useFocusTrap.d.ts +10 -0
  120. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  121. package/dist/hooks/useFocusTrap.js +225 -132
  122. package/dist/hooks/useMenuPress.d.ts +34 -1
  123. package/dist/hooks/useMenuPress.d.ts.map +1 -1
  124. package/dist/hooks/useMenuPress.js +93 -5
  125. package/dist/hooks/usePressFeedback.d.ts +6 -6
  126. package/dist/hooks/usePressFeedback.js +6 -6
  127. package/dist/hooks/useScrollRegionProps.d.ts +35 -0
  128. package/dist/hooks/useScrollRegionProps.d.ts.map +1 -0
  129. package/dist/hooks/useScrollRegionProps.js +51 -0
  130. package/dist/i18n/generated-english/hooks/useScrollRegionProps.generated.d.ts +8 -0
  131. package/dist/i18n/generated-english/hooks/useScrollRegionProps.generated.d.ts.map +1 -0
  132. package/dist/i18n/generated-english/hooks/useScrollRegionProps.generated.js +12 -0
  133. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  134. package/dist/i18n/generated-locales/en.generated.js +1 -0
  135. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  136. package/dist/i18n/generated-locales/pseudo.generated.js +1 -0
  137. package/dist/motion/carryAnimations.d.ts +58 -0
  138. package/dist/motion/carryAnimations.d.ts.map +1 -0
  139. package/dist/motion/carryAnimations.js +305 -0
  140. package/dist/motion/transientCopy.d.ts +4 -2
  141. package/dist/motion/transientCopy.d.ts.map +1 -1
  142. package/dist/motion/transientCopy.js +34 -5
  143. package/dist/motion/uikit/gestures.d.ts +41 -0
  144. package/dist/motion/uikit/gestures.d.ts.map +1 -1
  145. package/dist/motion/uikit/gestures.js +25 -0
  146. package/dist/motion/uikit/index.d.ts +1 -1
  147. package/dist/motion/uikit/index.d.ts.map +1 -1
  148. package/dist/motion/uikit/index.js +1 -1
  149. package/dist/privateAttributes/menuPressLit.stylex.d.ts +52 -0
  150. package/dist/privateAttributes/menuPressLit.stylex.d.ts.map +1 -0
  151. package/dist/privateAttributes/menuPressLit.stylex.js +99 -0
  152. package/dist/privateAttributes/press.stylex.d.ts +139 -0
  153. package/dist/privateAttributes/press.stylex.d.ts.map +1 -0
  154. package/dist/privateAttributes/press.stylex.js +98 -0
  155. package/dist/theme/tokens.stylex.d.ts +2 -2
  156. package/dist/theme/tokens.stylex.js +1 -1
  157. package/dist/utils/flatTree.d.ts +6 -3
  158. package/dist/utils/flatTree.d.ts.map +1 -1
  159. package/dist/utils/flatTree.js +13 -3
  160. package/dist/utils/hitArea.d.ts.map +1 -1
  161. package/dist/utils/hitArea.js +82 -5
  162. package/dist/utils/inputStream.d.ts +14 -1
  163. package/dist/utils/inputStream.d.ts.map +1 -1
  164. package/dist/utils/inputStream.js +40 -9
  165. package/dist/utils/interactionOverlay.stylex.d.ts +2 -1
  166. package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
  167. package/dist/utils/interactionOverlay.stylex.js +7 -2
  168. package/dist/utils/pressFeedback.d.ts +7 -0
  169. package/dist/utils/pressFeedback.d.ts.map +1 -1
  170. package/dist/utils/pressFeedback.js +32 -7
  171. package/dist/utils/pressGesture.d.ts +6 -0
  172. package/dist/utils/pressGesture.d.ts.map +1 -1
  173. package/dist/utils/pressGesture.js +17 -0
  174. package/dist/utils/rowPressLayer.stylex.d.ts +14 -0
  175. package/dist/utils/rowPressLayer.stylex.d.ts.map +1 -0
  176. package/dist/utils/rowPressLayer.stylex.js +25 -0
  177. package/dist/utils/scrollView.d.ts +25 -0
  178. package/dist/utils/scrollView.d.ts.map +1 -0
  179. package/dist/utils/scrollView.js +108 -0
  180. package/dist/utils/selectionLock.d.ts.map +1 -1
  181. package/dist/utils/selectionLock.js +1 -10
  182. package/dist/utils/touchHitArea.stylex.d.ts +35 -0
  183. package/dist/utils/touchHitArea.stylex.d.ts.map +1 -0
  184. package/dist/utils/touchHitArea.stylex.js +32 -0
  185. package/dist/utils/triggerFocus.d.ts +5 -0
  186. package/dist/utils/triggerFocus.d.ts.map +1 -1
  187. package/dist/utils/triggerFocus.js +9 -2
  188. package/locales/en.json +4 -0
  189. package/locales/pseudo.json +3 -0
  190. package/package.json +5 -5
  191. package/src/AppShell/observeMainOverflow.ts +9 -6
  192. package/src/BottomSheet/BottomSheet.tsx +5 -0
  193. package/src/CheckboxInput/CheckboxInput.doc.mjs +3 -2
  194. package/src/CheckboxInput/CheckboxInput.tsx +71 -9
  195. package/src/ClickableCard/ClickableCard.tsx +8 -1
  196. package/src/DateInput/PickerWheel.tsx +7 -2
  197. package/src/DateRangeInput/DateRangeInput.tsx +1 -1
  198. package/src/Dialog/Dialog.doc.mjs +1 -1
  199. package/src/Dialog/Dialog.tsx +12 -1
  200. package/src/Drawer/Drawer.doc.mjs +1 -1
  201. package/src/Drawer/useDrawerDialogPresence.ts +9 -2
  202. package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -2
  203. package/src/DropdownMenu/DropdownMenu.tsx +29 -5
  204. package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +5 -1
  205. package/src/DropdownMenu/DropdownMenuItem.tsx +8 -4
  206. package/src/DropdownMenu/DropdownMenuRadioItem.tsx +5 -1
  207. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +5 -1
  208. package/src/FileInput/FileInput.tsx +16 -2
  209. package/src/InfoTip/InfoTip.doc.mjs +26 -2
  210. package/src/InfoTip/InfoTip.tsx +1 -0
  211. package/src/InputGroup/InputGroup.doc.mjs +4 -3
  212. package/src/InputGroup/InputGroup.tsx +4 -3
  213. package/src/InputGroup/groupStyles.ts +3 -1
  214. package/src/Item/Item.tsx +51 -9
  215. package/src/Layer/holdEntranceInput.ts +84 -0
  216. package/src/Layer/inputHold.ts +734 -0
  217. package/src/Layer/preserveAnimations.ts +12 -275
  218. package/src/Layout/LayoutContent.doc.mjs +6 -3
  219. package/src/Layout/LayoutContent.tsx +10 -4
  220. package/src/Layout/LayoutPanel.doc.mjs +6 -3
  221. package/src/Layout/LayoutPanel.tsx +11 -4
  222. package/src/Lightbox/Lightbox.tsx +4 -0
  223. package/src/MetadataList/MetadataList.tsx +1 -1
  224. package/src/MobileNav/MobileNav.doc.mjs +3 -3
  225. package/src/MobileNav/MobileNav.tsx +39 -1
  226. package/src/MoreMenu/MoreMenu.doc.mjs +2 -4
  227. package/src/MoreMenu/MoreMenu.tsx +5 -3
  228. package/src/RadioList/RadioListItem.doc.mjs +3 -2
  229. package/src/RadioList/RadioListItem.tsx +25 -7
  230. package/src/SelectableCard/SelectableCard.tsx +8 -1
  231. package/src/Spinner/Spinner.tsx +13 -3
  232. package/src/Stack/Stack.doc.mjs +1 -1
  233. package/src/Stack/StackItem.tsx +27 -13
  234. package/src/Table/plugins/sortable/useTableSortable.tsx +1 -1
  235. package/src/Token/Token.tsx +18 -1
  236. package/src/Token/TokenLink.tsx +7 -1
  237. package/src/Tooltip/useTooltip.tsx +175 -79
  238. package/src/TreeList/TreeListItem.tsx +36 -2
  239. package/src/gestures/GestureHost.ts +21 -5
  240. package/src/gestures/PanGestureRecognizer.ts +19 -2
  241. package/src/gestures/README.md +14 -5
  242. package/src/gestures/ScreenEdgePanGestureRecognizer.ts +6 -1
  243. package/src/gestures/nativeScroll.ts +12 -68
  244. package/src/gestures/wheelSegmenter.ts +243 -10
  245. package/src/hooks/StackItemScrollRegion.tsx +57 -0
  246. package/src/hooks/menuPressGesture.ts +244 -38
  247. package/src/hooks/menuPressValues.ts +18 -0
  248. package/src/hooks/useClickableContainer.doc.mjs +8 -2
  249. package/src/hooks/useClickableContainer.ts +72 -6
  250. package/src/hooks/useFocusTrap.ts +268 -151
  251. package/src/hooks/useMenuPress.ts +118 -11
  252. package/src/hooks/usePressFeedback.doc.mjs +3 -3
  253. package/src/hooks/usePressFeedback.ts +6 -6
  254. package/src/hooks/useScrollRegionProps.ts +76 -0
  255. package/src/i18n/generated-english/hooks/useScrollRegionProps.generated.ts +13 -0
  256. package/src/i18n/generated-locales/en.generated.ts +1 -0
  257. package/src/i18n/generated-locales/pseudo.generated.ts +1 -0
  258. package/src/motion/MEASUREMENTS.md +11 -0
  259. package/src/motion/carryAnimations.ts +389 -0
  260. package/src/motion/transientCopy.ts +45 -5
  261. package/src/motion/uikit/gestures.ts +22 -0
  262. package/src/motion/uikit/index.ts +1 -0
  263. package/src/privateAttributes/menuPressLit.stylex.ts +104 -0
  264. package/src/privateAttributes/press.stylex.ts +244 -0
  265. package/src/theme/tokens.stylex.ts +1 -1
  266. package/src/utils/flatTree.ts +15 -3
  267. package/src/utils/hitArea.ts +107 -5
  268. package/src/utils/inputStream.ts +47 -10
  269. package/src/utils/interactionOverlay.stylex.ts +7 -2
  270. package/src/utils/pressFeedback.ts +31 -6
  271. package/src/utils/pressGesture.ts +24 -1
  272. package/src/utils/rowPressLayer.stylex.ts +27 -0
  273. package/src/utils/scrollView.ts +135 -0
  274. package/src/utils/selectionLock.ts +5 -10
  275. package/src/utils/touchHitArea.stylex.ts +41 -0
  276. package/src/utils/triggerFocus.ts +17 -4
@@ -6,7 +6,8 @@
6
6
  * @file useMenuPress.ts
7
7
  * @input The menu root, its trigger, the enabled-row selector, and callbacks
8
8
  * for opening, highlighting, activating and dismissing
9
- * @output useMenuPress, the marker attributes, and the activation mark
9
+ * @output useMenuPress, the marker attributes, the activation mark, and the
10
+ * internal useDropdownMenuPress entry with its touch model
10
11
  * @position Core hook for DropdownMenu, ContextMenu, DropdownMenuSubMenu,
11
12
  * Selector and MenuBottomSheetActionList. The transition table lives in
12
13
  * menuPressGesture.ts.
@@ -19,13 +20,14 @@
19
20
  */
20
21
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
21
22
  import { currentGesture } from "../Layer/gestureCounter.js";
22
- import { IDLE_MENU_PRESS, menuPressStep } from "./menuPressGesture.js";
23
+ import { IDLE_MENU_PRESS, menuPressTransition } from "./menuPressGesture.js";
23
24
  import { MENU_PRESS_MARKER } from "./menuPressMarker.js";
24
25
  import { useLongPressDetector } from "./useLongPress.js";
25
26
  import { edgeAutoscroll } from "../utils/edgeAutoscroll.js";
26
27
  import { focusForLastInput } from "../utils/focusReturn.js";
27
28
  import { useInteractionModalityTrackingFor } from "../utils/interactionModality.js";
28
29
  import { LONG_PRESS_DURATION_MS } from "../motion/uikit/longPress.js";
30
+ import { clearMenuPressLit, holdMenuPressPaint, markMenuPressLit, releaseMenuPressPaint } from "../privateAttributes/menuPressLit.stylex.js";
29
31
  import { __resetClickGuardForTest, armClickGuard, CLICK_GUARD_WINDOW_MS, withoutClickGuard } from "../utils/clickGuard.js";
30
32
  export { MENU_PRESS_MARKER };
31
33
  const MENU_PRESS_ROOT_SELECTOR = `[${MENU_PRESS_MARKER}]`;
@@ -124,6 +126,34 @@ function isInMenuTree(element, root) {
124
126
  const owner = element.closest(MENU_PRESS_ROOT_SELECTOR);
125
127
  return owner != null && getOutermostRoot(owner) === root;
126
128
  }
129
+
130
+ /**
131
+ * DropdownMenu's options for the press model: everything the public hook
132
+ * takes, plus its touch model. DropdownMenu reaches the touch model through
133
+ * its `presentation`, so the public hook has no such option.
134
+ *
135
+ * @internal
136
+ */
137
+
138
+ /**
139
+ * What core's own menus get from {@link useDropdownMenuPress}: the public
140
+ * return. Not exported from the hooks entry point.
141
+ *
142
+ * @internal
143
+ */
144
+
145
+ /**
146
+ * Where a pointer is, for a finger's handoff distance. Positions reach the
147
+ * machine only under `touchModel: 'uikit'`. Without them, it keeps the settle
148
+ * rule.
149
+ */
150
+ function handoffPosition(event, hasHandoff) {
151
+ return hasHandoff ? {
152
+ x: event.clientX,
153
+ y: event.clientY
154
+ } : {};
155
+ }
156
+
127
157
  /**
128
158
  * The press model for a menu: the row under the release acts, the highlight
129
159
  * follows a held pointer, and a mouse opens the menu on press.
@@ -160,6 +190,26 @@ function isInMenuTree(element, root) {
160
190
  * ```
161
191
  */
162
192
  export function useMenuPress(options) {
193
+ // The touch model is DropdownMenu's alone; an untyped caller's
194
+ // `touchModel` does not reach the model.
195
+ const {
196
+ touchModel: _touchModel,
197
+ ...publicOptions
198
+ } = options;
199
+ return useDropdownMenuPress({
200
+ ...publicOptions,
201
+ touchModel: 'pointer'
202
+ });
203
+ }
204
+
205
+ /**
206
+ * The press model with DropdownMenu's touch model
207
+ * ({@link DropdownMenuPressOptions.touchModel}). Not exported from the hooks
208
+ * entry point.
209
+ *
210
+ * @internal
211
+ */
212
+ export function useDropdownMenuPress(options) {
163
213
  const optionsRef = useRef(options);
164
214
  optionsRef.current = options;
165
215
  // The highlight, and the hover focus of the rows in this menu, follow the
@@ -247,8 +297,18 @@ export function useMenuPress(options) {
247
297
  autoscroll.stop();
248
298
  autoscrollRef.current = null;
249
299
  }, [autoscroll]);
300
+ const litRowRef = useRef(null);
301
+ const heldMenuRef = useRef(null);
250
302
  const endGesture = useCallback(() => {
251
303
  longPressApiRef.current?.cancel();
304
+ if (litRowRef.current != null) {
305
+ clearMenuPressLit(litRowRef.current);
306
+ litRowRef.current = null;
307
+ }
308
+ if (heldMenuRef.current != null) {
309
+ releaseMenuPressPaint(heldMenuRef.current);
310
+ heldMenuRef.current = null;
311
+ }
252
312
  touchMovePreventerRef.current?.();
253
313
  touchMovePreventerRef.current = null;
254
314
  stopAutoscroll();
@@ -259,10 +319,36 @@ export function useMenuPress(options) {
259
319
  gestureRef.current = IDLE_MENU_PRESS;
260
320
  }, [stopAutoscroll]);
261
321
  const highlight = useCallback(row => {
322
+ // A held finger or pen marks the row it lights, for the row's pressed
323
+ // paint. A held mouse keeps the hover tint, as on a desktop.
324
+ const gesture = gestureRef.current;
325
+ const isHeld = gesture.phase !== 'idle' && gesture.pointerType !== 'mouse';
326
+ const lit = isHeld ? row : null;
327
+ if (litRowRef.current !== lit) {
328
+ if (litRowRef.current != null) {
329
+ clearMenuPressLit(litRowRef.current);
330
+ }
331
+ litRowRef.current = lit;
332
+ if (lit != null) {
333
+ markMenuPressLit(lit);
334
+ }
335
+ }
262
336
  const {
263
337
  onHighlight,
264
338
  menuRef
265
339
  } = optionsRef.current;
340
+ // The row the press began on stays :active where a pointer hovers, so
341
+ // the menu holds every row but the lit one off that paint.
342
+ const held = isHeld ? menuRef.current : null;
343
+ if (heldMenuRef.current !== held) {
344
+ if (heldMenuRef.current != null) {
345
+ releaseMenuPressPaint(heldMenuRef.current);
346
+ }
347
+ heldMenuRef.current = held;
348
+ if (held != null) {
349
+ holdMenuPressPaint(held);
350
+ }
351
+ }
266
352
  if (onHighlight != null) {
267
353
  onHighlight(row);
268
354
  return;
@@ -369,7 +455,7 @@ export function useMenuPress(options) {
369
455
  }
370
456
  }, [activate, endGesture, getDocument, highlight]);
371
457
  const step = useCallback((event, native) => {
372
- const result = menuPressStep(gestureRef.current, event);
458
+ const result = menuPressTransition(gestureRef.current, event);
373
459
  gestureRef.current = result.gesture;
374
460
  applyEffect(result.effect, result.gesture, native);
375
461
  }, [applyEffect]);
@@ -466,7 +552,8 @@ export function useMenuPress(options) {
466
552
  type: 'move',
467
553
  row: point.row,
468
554
  isInMenu: point.isInMenu,
469
- time: Date.now()
555
+ time: Date.now(),
556
+ ...handoffPosition(event, optionsRef.current.touchModel === 'uikit')
470
557
  }, event);
471
558
  updateAutoscroll(event);
472
559
  };
@@ -480,7 +567,8 @@ export function useMenuPress(options) {
480
567
  row: point.row,
481
568
  isInMenu: point.isInMenu,
482
569
  isOnTrigger: point.isOnTrigger,
483
- time: Date.now()
570
+ time: Date.now(),
571
+ ...handoffPosition(event, optionsRef.current.touchModel === 'uikit')
484
572
  }, event);
485
573
  };
486
574
  const onCancel = event => {
@@ -7,11 +7,11 @@ import { pressableProps } from '../utils/pressFeedback.js';
7
7
  * `interactionOverlayStyles` (from `@astryxdesign/core/utils`) on the same
8
8
  * element: `backgroundColor` or `backgroundImage` for a surface whose hover
9
9
  * and press are the system's overlays, `pressedBackgroundColor` for one
10
- * whose hover is its own. The controller writes its attribute on the element
11
- * while a touch press is believed (after the onset delay, cancelled by travel
12
- * or by a scroll) and for the release, and the composed style paints the
13
- * pressed token at the press's strength on the first frame and fades it over
14
- * the release, keeping `:active` for a mouse on a desktop. On a phone or
10
+ * whose hover is its own. Under a finger the controller tracks the press the
11
+ * way UIKit tracks a control and writes its
12
+ * attribute on the element while the press is held and for the release; the
13
+ * composed style paints the pressed token on the first frame and fades it
14
+ * over the release, keeping `:active` for a mouse on a desktop. On a phone or
15
15
  * tablet the stylesheet drops `:active` for every press, so the controller
16
16
  * also paints a mouse, trackpad or Space-key press there, at once. A press is
17
17
  * themed through `--color-overlay-pressed`, which the hold, the flash and the
@@ -27,7 +27,7 @@ import { pressableProps } from '../utils/pressFeedback.js';
27
27
  * @example
28
28
  * ```
29
29
  * const pressable = usePressFeedback();
30
- * return <div role="button" {...pressable} {...stylex.props(styles.row)} />;
30
+ * return <button {...pressable} {...stylex.props(styles.button)} />;
31
31
  * ```
32
32
  */
33
33
  export declare function usePressFeedback(): typeof pressableProps;
@@ -25,11 +25,11 @@ import { installPressFeedback, pressableProps } from "../utils/pressFeedback.js"
25
25
  * `interactionOverlayStyles` (from `@astryxdesign/core/utils`) on the same
26
26
  * element: `backgroundColor` or `backgroundImage` for a surface whose hover
27
27
  * and press are the system's overlays, `pressedBackgroundColor` for one
28
- * whose hover is its own. The controller writes its attribute on the element
29
- * while a touch press is believed (after the onset delay, cancelled by travel
30
- * or by a scroll) and for the release, and the composed style paints the
31
- * pressed token at the press's strength on the first frame and fades it over
32
- * the release, keeping `:active` for a mouse on a desktop. On a phone or
28
+ * whose hover is its own. Under a finger the controller tracks the press the
29
+ * way UIKit tracks a control and writes its
30
+ * attribute on the element while the press is held and for the release; the
31
+ * composed style paints the pressed token on the first frame and fades it
32
+ * over the release, keeping `:active` for a mouse on a desktop. On a phone or
33
33
  * tablet the stylesheet drops `:active` for every press, so the controller
34
34
  * also paints a mouse, trackpad or Space-key press there, at once. A press is
35
35
  * themed through `--color-overlay-pressed`, which the hold, the flash and the
@@ -45,7 +45,7 @@ import { installPressFeedback, pressableProps } from "../utils/pressFeedback.js"
45
45
  * @example
46
46
  * ```
47
47
  * const pressable = usePressFeedback();
48
- * return <div role="button" {...pressable} {...stylex.props(styles.row)} />;
48
+ * return <button {...pressable} {...stylex.props(styles.button)} />;
49
49
  * ```
50
50
  */
51
51
  export function usePressFeedback() {
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @file useScrollRegionProps.ts
3
+ * @input Whether a region may scroll, and the caller's role and label
4
+ * @output useScrollRegionProps: a ref for the region, and the role and
5
+ * accessible name that the region carries while its content overflows
6
+ * @position Internal hook for LayoutContent, LayoutPanel and StackItem.
7
+ *
8
+ * SYNC: When modified, update:
9
+ * - /packages/core/src/hooks/useScrollRegionProps.test.tsx
10
+ * - /packages/core/src/AppShell/observeMainOverflow.ts
11
+ */
12
+ import { type AriaRole, type RefCallback } from 'react';
13
+ export interface ScrollRegionOptions {
14
+ /** Whether the region may scroll at all (`overflow: auto`). */
15
+ isScrollable: boolean;
16
+ /** The caller's role. It always wins, and takes no default name. */
17
+ role?: AriaRole;
18
+ /** The caller's accessible name. It always wins. */
19
+ label?: string;
20
+ }
21
+ export interface ScrollRegionProps {
22
+ ref: RefCallback<HTMLElement>;
23
+ role: AriaRole | undefined;
24
+ 'aria-label': string | undefined;
25
+ }
26
+ /**
27
+ * The region's ref, role and accessible name. While the region may scroll
28
+ * and its content overflows, it is a group named by the caller's `label`, or
29
+ * by the translated "Content". A caller's `role` is kept with only the
30
+ * caller's `label`: a single main landmark relies on its role alone. When
31
+ * the region does not scroll, the caller's own `role` and `label` pass
32
+ * through unchanged.
33
+ */
34
+ export declare function useScrollRegionProps({ isScrollable, role, label, }: ScrollRegionOptions): ScrollRegionProps;
35
+ //# sourceMappingURL=useScrollRegionProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollRegionProps.d.ts","sourceRoot":"","sources":["../../src/hooks/useScrollRegionProps.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH,OAAO,EAAwB,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAC,MAAM,OAAO,CAAC;AAU7E,MAAM,WAAW,mBAAmB;IAClC,+DAA+D;IAC/D,YAAY,EAAE,OAAO,CAAC;IACtB,oEAAoE;IACpE,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAC9B,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,YAAY,EACZ,IAAI,EACJ,KAAK,GACN,EAAE,mBAAmB,GAAG,iBAAiB,CAsBzC"}
@@ -0,0 +1,51 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file useScrollRegionProps.ts
7
+ * @input Whether a region may scroll, and the caller's role and label
8
+ * @output useScrollRegionProps: a ref for the region, and the role and
9
+ * accessible name that the region carries while its content overflows
10
+ * @position Internal hook for LayoutContent, LayoutPanel and StackItem.
11
+ *
12
+ * SYNC: When modified, update:
13
+ * - /packages/core/src/hooks/useScrollRegionProps.test.tsx
14
+ * - /packages/core/src/AppShell/observeMainOverflow.ts
15
+ */
16
+ import { useCallback, useState } from 'react';
17
+ import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
18
+ import english from "../i18n/generated-english/hooks/useScrollRegionProps.generated.js";
19
+ import { observeMainOverflow } from "../AppShell/observeMainOverflow.js";
20
+ registerEnglishFallback(english);
21
+ /**
22
+ * The region's ref, role and accessible name. While the region may scroll
23
+ * and its content overflows, it is a group named by the caller's `label`, or
24
+ * by the translated "Content". A caller's `role` is kept with only the
25
+ * caller's `label`: a single main landmark relies on its role alone. When
26
+ * the region does not scroll, the caller's own `role` and `label` pass
27
+ * through unchanged.
28
+ */
29
+ export function useScrollRegionProps({
30
+ isScrollable,
31
+ role,
32
+ label
33
+ }) {
34
+ const t = useComponentTranslator();
35
+ const [overflows, setOverflows] = useState(false);
36
+ // A caller's role takes no default name, so its region is not observed.
37
+ const hasRole = role != null;
38
+ const ref = useCallback(element => {
39
+ if (element == null || !isScrollable || hasRole) {
40
+ setOverflows(false);
41
+ return undefined;
42
+ }
43
+ return observeMainOverflow(element, setOverflows);
44
+ }, [hasRole, isScrollable]);
45
+ const isGroup = !hasRole && isScrollable && overflows;
46
+ return {
47
+ ref,
48
+ role: role ?? (isGroup ? 'group' : undefined),
49
+ 'aria-label': label ?? (isGroup ? t('@astryx.scrollRegion.label') : undefined)
50
+ };
51
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @generated by scripts/generate-i18n-runtime.mjs from packages/core/locales/en.json,
3
+ * holding the English for the catalog keys named in packages/core/src/hooks/useScrollRegionProps.ts.
4
+ * Do not edit by hand. Run `pnpm generate:i18n-runtime` instead.
5
+ */
6
+ declare const english: Readonly<Record<string, string>>;
7
+ export default english;
8
+ //# sourceMappingURL=useScrollRegionProps.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollRegionProps.generated.d.ts","sourceRoot":"","sources":["../../../../src/i18n/generated-english/hooks/useScrollRegionProps.generated.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,QAAA,MAAM,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE7C,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,12 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @generated by scripts/generate-i18n-runtime.mjs from packages/core/locales/en.json,
5
+ * holding the English for the catalog keys named in packages/core/src/hooks/useScrollRegionProps.ts.
6
+ * Do not edit by hand. Run `pnpm generate:i18n-runtime` instead.
7
+ */
8
+
9
+ const english = {
10
+ "@astryx.scrollRegion.label": "Content"
11
+ };
12
+ export default english;
@@ -1 +1 @@
1
- {"version":3,"file":"en.generated.d.ts","sourceRoot":"","sources":["../../../src/i18n/generated-locales/en.generated.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,QAAA,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmqBpD,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"en.generated.d.ts","sourceRoot":"","sources":["../../../src/i18n/generated-locales/en.generated.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,QAAA,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoqBpD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -338,6 +338,7 @@ const runtimeCatalog = {
338
338
  '@astryx.banner.expand': 'Expand',
339
339
  '@astryx.button.loading': 'Loading',
340
340
  '@astryx.spinner.loading': 'Loading',
341
+ '@astryx.scrollRegion.label': 'Content',
341
342
  '@astryx.chatComposerDrawer.expand': 'Expand {label}',
342
343
  '@astryx.chatComposerDrawer.collapse': 'Collapse {label}',
343
344
  '@astryx.chatDictationButton.startDictation': 'Start dictation',
@@ -1 +1 @@
1
- {"version":3,"file":"pseudo.generated.d.ts","sourceRoot":"","sources":["../../../src/i18n/generated-locales/pseudo.generated.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,QAAA,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA+qBpD,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"pseudo.generated.d.ts","sourceRoot":"","sources":["../../../src/i18n/generated-locales/pseudo.generated.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,QAAA,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgrBpD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -338,6 +338,7 @@ const runtimeCatalog = {
338
338
  '@astryx.banner.expand': '⟦Éẋþàñð⟧',
339
339
  '@astryx.button.loading': '⟦Łóàðíñĝ⟧',
340
340
  '@astryx.spinner.loading': '⟦Łóàðíñĝ⟧',
341
+ '@astryx.scrollRegion.label': '⟦Çóñţéñţ⟧',
341
342
  '@astryx.chatComposerDrawer.expand': '⟦Éẋþàñð {label}⟧',
342
343
  '@astryx.chatComposerDrawer.collapse': '⟦Çółłàþšé {label}⟧',
343
344
  '@astryx.chatDictationButton.startDictation': '⟦Šţàřţ ðíçţàţíóñ⟧',
@@ -0,0 +1,58 @@
1
+ type Writable = Record<string, unknown>;
2
+ /** One animation's state, read before the browser starts it afresh. */
3
+ export interface SavedAnimation {
4
+ animation: Animation;
5
+ name: string;
6
+ target: Element | null;
7
+ pseudoElement: string | null;
8
+ values: Writable;
9
+ effectValues: Writable;
10
+ timing: EffectTiming | null;
11
+ keyframes: ComputedKeyframe[] | null;
12
+ playState: AnimationPlayState;
13
+ replaceState: AnimationReplaceState;
14
+ }
15
+ /**
16
+ * Reads one animation's state generically, from what the platform exposes.
17
+ * That is every accessor with a setter on the animation's and its effect's
18
+ * prototype chains, every field of the effect's timing, and its keyframes. Only values
19
+ * that differ from the recreated animation's are written back, so a value the
20
+ * stylesheet controls stays under its control. A few members are not plain
21
+ * state and are written in their own step (`ORDERED`). The Animation and
22
+ * effect objects themselves cannot be carried over: the old ones keep their
23
+ * listeners and promises.
24
+ */
25
+ export declare function saveAnimation(animation: Animation): SavedAnimation;
26
+ /**
27
+ * Puts each state `saved` holds on the CSS animations and transitions of
28
+ * `root` and its subtree that are not among `survivors`. Each CSS animation
29
+ * the browser started afresh takes the state of the one it replaces. It is
30
+ * matched by element, pseudo-element and name, in order, and then by name
31
+ * alone (an effect script moved to another element or pseudo-element). Each
32
+ * transition whose animation no longer runs resumes as a script animation in
33
+ * its state. One started afresh that replaces none is finished: an entrance
34
+ * that had played and been dropped, or a transition from `@starting-style`.
35
+ * Script animations are left as they are.
36
+ */
37
+ export declare function restoreAnimations(root: Element, saved: ReadonlyArray<SavedAnimation>, survivors: ReadonlySet<Animation>): void;
38
+ /** The CSS animations and transitions `saveAnimations` read. */
39
+ export type SavedAnimations = ReadonlyArray<SavedAnimation>;
40
+ /**
41
+ * Reads the state of every CSS animation and transition of `root` and its
42
+ * subtree, for `carryAnimations` to give a copy of it.
43
+ */
44
+ export declare function saveAnimations(root: Element): SavedAnimations;
45
+ /**
46
+ * Carries on in `copy`, a clone of the root `saved` was read from, now laid
47
+ * out, the CSS animations and transitions its element ran. A clone starts
48
+ * each CSS animation again and runs no transition but a `@starting-style`
49
+ * one. So each CSS animation the clone started takes the state of its
50
+ * element's, and each transition runs on as a script animation. One the
51
+ * clone started that its element no longer ran is finished: an entrance that
52
+ * had played, or a `@starting-style` transition. `copyOf` maps each element
53
+ * of the cloned subtree to its copy. The element's own animations keep
54
+ * running, so the copy's take no id or event handler.
55
+ */
56
+ export declare function carryAnimations(saved: SavedAnimations, copy: Element, copyOf: (element: Element) => Element | null): void;
57
+ export {};
58
+ //# sourceMappingURL=carryAnimations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carryAnimations.d.ts","sourceRoot":"","sources":["../../src/motion/carryAnimations.ts"],"names":[],"mappings":"AA+BA,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAsDxC,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,QAAQ,CAAC;IACjB,YAAY,EAAE,QAAQ,CAAC;IACvB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACrC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,YAAY,EAAE,qBAAqB,CAAC;CACrC;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,CAyBlE;AAsJD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,EACpC,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,GAChC,IAAI,CA8CN;AAED,gEAAgE;AAChE,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;AAE5D;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,CAQ7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAG,IAAI,GAC3C,IAAI,CASN"}