@astryxdesign/core 0.7.8 → 0.7.9-canary.7400c1f

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 (203) hide show
  1. package/dist/Calendar/styles.d.ts +1 -1
  2. package/dist/ClickableCard/ClickableCard.d.ts +1 -1
  3. package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
  4. package/dist/ClickableCard/ClickableCard.js +5 -1
  5. package/dist/DateInput/PickerWheel.d.ts.map +1 -1
  6. package/dist/DateInput/PickerWheel.js +7 -1
  7. package/dist/DateRangeInput/DateRangeInput.js +1 -1
  8. package/dist/Dialog/Dialog.d.ts +2 -1
  9. package/dist/Dialog/Dialog.d.ts.map +1 -1
  10. package/dist/Dialog/Dialog.js +8 -1
  11. package/dist/Drawer/useDrawerDialogPresence.d.ts +2 -1
  12. package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -1
  13. package/dist/Drawer/useDrawerDialogPresence.js +11 -2
  14. package/dist/DropdownMenu/DropdownMenu.d.ts +9 -1
  15. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  16. package/dist/DropdownMenu/DropdownMenu.js +9 -4
  17. package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +1 -1
  18. package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +3 -2
  19. package/dist/DropdownMenu/DropdownMenuItem.d.ts.map +1 -1
  20. package/dist/DropdownMenu/DropdownMenuItem.js +3 -2
  21. package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -1
  22. package/dist/DropdownMenu/DropdownMenuRadioItem.js +3 -2
  23. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  24. package/dist/DropdownMenu/DropdownMenuSubMenu.js +3 -2
  25. package/dist/Field/inputDisabledFocus.d.ts +4 -4
  26. package/dist/Field/inputStyles.stylex.d.ts +1 -1
  27. package/dist/FileInput/FileInput.d.ts.map +1 -1
  28. package/dist/FileInput/FileInput.js +16 -2
  29. package/dist/Icon/Icon.d.ts +1 -1
  30. package/dist/InfoTip/InfoTip.d.ts +1 -0
  31. package/dist/InfoTip/InfoTip.d.ts.map +1 -1
  32. package/dist/InfoTip/InfoTip.js +1 -0
  33. package/dist/Item/Item.d.ts +2 -1
  34. package/dist/Item/Item.d.ts.map +1 -1
  35. package/dist/Item/Item.js +29 -6
  36. package/dist/Layer/holdEntranceInput.d.ts +24 -0
  37. package/dist/Layer/holdEntranceInput.d.ts.map +1 -0
  38. package/dist/Layer/holdEntranceInput.js +65 -0
  39. package/dist/Layer/inputHold.d.ts +49 -0
  40. package/dist/Layer/inputHold.d.ts.map +1 -0
  41. package/dist/Layer/inputHold.js +636 -0
  42. package/dist/Layer/preserveAnimations.d.ts +1 -5
  43. package/dist/Layer/preserveAnimations.d.ts.map +1 -1
  44. package/dist/Layer/preserveAnimations.js +12 -214
  45. package/dist/MetadataList/MetadataList.js +1 -1
  46. package/dist/MobileNav/MobileNav.d.ts +11 -1
  47. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  48. package/dist/MobileNav/MobileNav.js +34 -1
  49. package/dist/MoreMenu/MoreMenu.d.ts +5 -3
  50. package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
  51. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  52. package/dist/RadioList/RadioListItem.js +4 -1
  53. package/dist/SelectableCard/SelectableCard.d.ts +1 -1
  54. package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
  55. package/dist/SelectableCard/SelectableCard.js +5 -1
  56. package/dist/Spinner/Spinner.d.ts.map +1 -1
  57. package/dist/Spinner/Spinner.js +12 -2
  58. package/dist/Table/plugins/sortable/useTableSortable.js +1 -1
  59. package/dist/Token/Token.d.ts.map +1 -1
  60. package/dist/Token/Token.js +9 -0
  61. package/dist/Token/TokenLink.d.ts +1 -1
  62. package/dist/Token/TokenLink.d.ts.map +1 -1
  63. package/dist/Token/TokenLink.js +4 -1
  64. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  65. package/dist/Tooltip/useTooltip.js +162 -59
  66. package/dist/TreeList/TreeListItem.d.ts +2 -1
  67. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  68. package/dist/TreeList/TreeListItem.js +27 -3
  69. package/dist/astryx.css +30 -7
  70. package/dist/gestures/GestureHost.d.ts +2 -2
  71. package/dist/gestures/GestureHost.d.ts.map +1 -1
  72. package/dist/gestures/GestureHost.js +21 -6
  73. package/dist/gestures/nativeScroll.d.ts +3 -6
  74. package/dist/gestures/nativeScroll.d.ts.map +1 -1
  75. package/dist/gestures/nativeScroll.js +7 -52
  76. package/dist/gestures/wheelSegmenter.d.ts +68 -1
  77. package/dist/gestures/wheelSegmenter.d.ts.map +1 -1
  78. package/dist/gestures/wheelSegmenter.js +199 -10
  79. package/dist/hooks/menuPressGesture.d.ts +133 -21
  80. package/dist/hooks/menuPressGesture.d.ts.map +1 -1
  81. package/dist/hooks/menuPressGesture.js +155 -30
  82. package/dist/hooks/menuPressValues.d.ts +16 -0
  83. package/dist/hooks/menuPressValues.d.ts.map +1 -0
  84. package/dist/hooks/menuPressValues.js +18 -0
  85. package/dist/hooks/useClickableContainer.d.ts +27 -5
  86. package/dist/hooks/useClickableContainer.d.ts.map +1 -1
  87. package/dist/hooks/useClickableContainer.js +41 -5
  88. package/dist/hooks/useMenuPress.d.ts +34 -1
  89. package/dist/hooks/useMenuPress.d.ts.map +1 -1
  90. package/dist/hooks/useMenuPress.js +93 -5
  91. package/dist/hooks/usePressFeedback.d.ts +6 -6
  92. package/dist/hooks/usePressFeedback.js +6 -6
  93. package/dist/motion/carryAnimations.d.ts +58 -0
  94. package/dist/motion/carryAnimations.d.ts.map +1 -0
  95. package/dist/motion/carryAnimations.js +305 -0
  96. package/dist/motion/transientCopy.d.ts +4 -2
  97. package/dist/motion/transientCopy.d.ts.map +1 -1
  98. package/dist/motion/transientCopy.js +34 -5
  99. package/dist/motion/uikit/gestures.d.ts +41 -0
  100. package/dist/motion/uikit/gestures.d.ts.map +1 -1
  101. package/dist/motion/uikit/gestures.js +25 -0
  102. package/dist/motion/uikit/index.d.ts +1 -1
  103. package/dist/motion/uikit/index.d.ts.map +1 -1
  104. package/dist/motion/uikit/index.js +1 -1
  105. package/dist/privateAttributes/menuPressLit.stylex.d.ts +52 -0
  106. package/dist/privateAttributes/menuPressLit.stylex.d.ts.map +1 -0
  107. package/dist/privateAttributes/menuPressLit.stylex.js +99 -0
  108. package/dist/privateAttributes/press.stylex.d.ts +139 -0
  109. package/dist/privateAttributes/press.stylex.d.ts.map +1 -0
  110. package/dist/privateAttributes/press.stylex.js +98 -0
  111. package/dist/theme/tokens.stylex.d.ts +2 -2
  112. package/dist/theme/tokens.stylex.js +1 -1
  113. package/dist/utils/flatTree.d.ts +6 -3
  114. package/dist/utils/flatTree.d.ts.map +1 -1
  115. package/dist/utils/flatTree.js +13 -3
  116. package/dist/utils/hitArea.d.ts.map +1 -1
  117. package/dist/utils/hitArea.js +82 -5
  118. package/dist/utils/inputStream.d.ts +14 -1
  119. package/dist/utils/inputStream.d.ts.map +1 -1
  120. package/dist/utils/inputStream.js +40 -9
  121. package/dist/utils/interactionOverlay.stylex.d.ts +2 -1
  122. package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
  123. package/dist/utils/interactionOverlay.stylex.js +7 -2
  124. package/dist/utils/pressFeedback.d.ts +7 -0
  125. package/dist/utils/pressFeedback.d.ts.map +1 -1
  126. package/dist/utils/pressFeedback.js +32 -7
  127. package/dist/utils/pressGesture.d.ts +6 -0
  128. package/dist/utils/pressGesture.d.ts.map +1 -1
  129. package/dist/utils/pressGesture.js +17 -0
  130. package/dist/utils/rowPressLayer.stylex.d.ts +14 -0
  131. package/dist/utils/rowPressLayer.stylex.d.ts.map +1 -0
  132. package/dist/utils/rowPressLayer.stylex.js +25 -0
  133. package/dist/utils/scrollView.d.ts +25 -0
  134. package/dist/utils/scrollView.d.ts.map +1 -0
  135. package/dist/utils/scrollView.js +108 -0
  136. package/dist/utils/selectionLock.d.ts.map +1 -1
  137. package/dist/utils/selectionLock.js +1 -10
  138. package/dist/utils/triggerFocus.d.ts +5 -0
  139. package/dist/utils/triggerFocus.d.ts.map +1 -1
  140. package/dist/utils/triggerFocus.js +9 -2
  141. package/package.json +5 -5
  142. package/src/ClickableCard/ClickableCard.tsx +8 -1
  143. package/src/DateInput/PickerWheel.tsx +7 -2
  144. package/src/DateRangeInput/DateRangeInput.tsx +1 -1
  145. package/src/Dialog/Dialog.doc.mjs +1 -1
  146. package/src/Dialog/Dialog.tsx +8 -1
  147. package/src/Drawer/Drawer.doc.mjs +1 -1
  148. package/src/Drawer/useDrawerDialogPresence.ts +9 -2
  149. package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -2
  150. package/src/DropdownMenu/DropdownMenu.tsx +29 -5
  151. package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +5 -1
  152. package/src/DropdownMenu/DropdownMenuItem.tsx +8 -4
  153. package/src/DropdownMenu/DropdownMenuRadioItem.tsx +5 -1
  154. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +5 -1
  155. package/src/FileInput/FileInput.tsx +16 -2
  156. package/src/InfoTip/InfoTip.doc.mjs +26 -2
  157. package/src/InfoTip/InfoTip.tsx +1 -0
  158. package/src/Item/Item.tsx +51 -9
  159. package/src/Layer/holdEntranceInput.ts +84 -0
  160. package/src/Layer/inputHold.ts +734 -0
  161. package/src/Layer/preserveAnimations.ts +12 -275
  162. package/src/MetadataList/MetadataList.tsx +1 -1
  163. package/src/MobileNav/MobileNav.doc.mjs +3 -3
  164. package/src/MobileNav/MobileNav.tsx +34 -1
  165. package/src/MoreMenu/MoreMenu.doc.mjs +2 -4
  166. package/src/MoreMenu/MoreMenu.tsx +5 -3
  167. package/src/RadioList/RadioListItem.tsx +4 -5
  168. package/src/SelectableCard/SelectableCard.tsx +8 -1
  169. package/src/Spinner/Spinner.tsx +13 -3
  170. package/src/Table/plugins/sortable/useTableSortable.tsx +1 -1
  171. package/src/Token/Token.tsx +18 -1
  172. package/src/Token/TokenLink.tsx +7 -1
  173. package/src/Tooltip/useTooltip.tsx +175 -79
  174. package/src/TreeList/TreeListItem.tsx +36 -2
  175. package/src/gestures/GestureHost.ts +21 -5
  176. package/src/gestures/README.md +12 -4
  177. package/src/gestures/nativeScroll.ts +12 -68
  178. package/src/gestures/wheelSegmenter.ts +243 -10
  179. package/src/hooks/menuPressGesture.ts +244 -38
  180. package/src/hooks/menuPressValues.ts +18 -0
  181. package/src/hooks/useClickableContainer.doc.mjs +8 -2
  182. package/src/hooks/useClickableContainer.ts +72 -6
  183. package/src/hooks/useMenuPress.ts +118 -11
  184. package/src/hooks/usePressFeedback.doc.mjs +3 -3
  185. package/src/hooks/usePressFeedback.ts +6 -6
  186. package/src/motion/MEASUREMENTS.md +11 -0
  187. package/src/motion/carryAnimations.ts +389 -0
  188. package/src/motion/transientCopy.ts +45 -5
  189. package/src/motion/uikit/gestures.ts +22 -0
  190. package/src/motion/uikit/index.ts +1 -0
  191. package/src/privateAttributes/menuPressLit.stylex.ts +104 -0
  192. package/src/privateAttributes/press.stylex.ts +244 -0
  193. package/src/theme/tokens.stylex.ts +1 -1
  194. package/src/utils/flatTree.ts +15 -3
  195. package/src/utils/hitArea.ts +107 -5
  196. package/src/utils/inputStream.ts +47 -10
  197. package/src/utils/interactionOverlay.stylex.ts +7 -2
  198. package/src/utils/pressFeedback.ts +31 -6
  199. package/src/utils/pressGesture.ts +24 -1
  200. package/src/utils/rowPressLayer.stylex.ts +27 -0
  201. package/src/utils/scrollView.ts +135 -0
  202. package/src/utils/selectionLock.ts +5 -10
  203. package/src/utils/triggerFocus.ts +17 -4
@@ -5,11 +5,13 @@
5
5
  /**
6
6
  * @file useClickableContainer.ts
7
7
  * @input Container ref, interactive element ref, click/href handlers
8
- * @output onClick and onMouseUp handlers for the container; INTERACTIVE_SELECTORS list;
8
+ * @output onClick, onMouseUp and onPointerDown handlers for the container;
9
+ * INTERACTIVE_SELECTORS list;
9
10
  * hasInteractiveAncestor and the shared innermostInteractive walk
10
11
  * @position Core hook for clickable containers with nested interactive
11
12
  * elements. A click on a nested button or link does not run the card's
12
- * action. Each navigation passes the rule in utils/safeUrl.ts first.
13
+ * action, and a finger press there shows no press on the card. Each navigation
14
+ * passes the rule in utils/safeUrl.ts first.
13
15
  *
14
16
  * SYNC: When modified, update:
15
17
  * - /packages/core/src/hooks/index.ts (export)
@@ -17,6 +19,7 @@
17
19
  import { useCallback, useEffect } from 'react';
18
20
  import { isLayerSurface } from "../Layer/layerSurfacePress.js";
19
21
  import { isSafeUrl } from "../utils/safeUrl.js";
22
+ import { cancelPress } from "../utils/pressFeedback.js";
20
23
 
21
24
  /**
22
25
  * The attribute this hook sets on the container it makes clickable. A click
@@ -90,6 +93,24 @@ function belongsToSomethingElse(element) {
90
93
  return matchesInteractiveSelectors(element) || isLayerSurface(element);
91
94
  }
92
95
 
96
+ /**
97
+ * The touch half of a container's press rule: a finger press that starts on a nested interactive element
98
+ * other than the container's own action does not activate the container, so
99
+ * it ends the press controller's paint on `container`. A mouse or pen press,
100
+ * and a press on the container's surface or on `ownAction`, are left alone.
101
+ * Not part of the package's public API.
102
+ */
103
+ export function cancelNestedTouchPress(event, container, ownAction) {
104
+ const target = event.target;
105
+ if (event.pointerType !== 'touch' || container == null || !(target instanceof Element) || target === event.currentTarget || !hasInteractiveAncestor(target, container) ||
106
+ // The container's own action, such as the control it delegates to: a
107
+ // press on it activates the container.
108
+ ownAction?.contains(target) === true) {
109
+ return;
110
+ }
111
+ cancelPress(container);
112
+ }
113
+
93
114
  /**
94
115
  * Check if there's a text selection inside the node (don't navigate on text select)
95
116
  *
@@ -123,12 +144,16 @@ export function hasTextSelection(node) {
123
144
  * @example
124
145
  * ```
125
146
  * const containerRef = useRef<HTMLDivElement>(null);
126
- * const { onClick, onMouseUp } = useClickableContainer({
147
+ * const { onClick, onMouseUp, onPointerDown } = useClickableContainer({
127
148
  * containerRef,
128
149
  * onClick: () => console.log('card clicked'),
129
150
  * });
130
151
  * return (
131
- * <div ref={containerRef} onClick={onClick} onMouseUp={onMouseUp}>
152
+ * <div
153
+ * ref={containerRef}
154
+ * onClick={onClick}
155
+ * onMouseUp={onMouseUp}
156
+ * onPointerDown={onPointerDown}>
132
157
  * <p>Click anywhere on this card</p>
133
158
  * <button onClick={() => alert('button')}>Nested button</button>
134
159
  * </div>
@@ -226,8 +251,19 @@ export function useClickableContainer({
226
251
  window.open(href, '_blank', 'noopener');
227
252
  }
228
253
  }, [containerRef, href, disabled]);
254
+
255
+ // The press-state counterpart of onClick's rule, for touch: a finger press
256
+ // that would not activate the container shows no press on it. A mouse or
257
+ // pen press keeps its `:active` paint.
258
+ const onPointerDown = useCallback(event => {
259
+ if (disabled) {
260
+ return;
261
+ }
262
+ cancelNestedTouchPress(event, containerRef.current, interactiveRef?.current ?? null);
263
+ }, [containerRef, interactiveRef, disabled]);
229
264
  return {
230
265
  onClick,
231
- onMouseUp
266
+ onMouseUp,
267
+ onPointerDown
232
268
  };
233
269
  }
@@ -2,7 +2,8 @@
2
2
  * @file useMenuPress.ts
3
3
  * @input The menu root, its trigger, the enabled-row selector, and callbacks
4
4
  * for opening, highlighting, activating and dismissing
5
- * @output useMenuPress, the marker attributes, and the activation mark
5
+ * @output useMenuPress, the marker attributes, the activation mark, and the
6
+ * internal useDropdownMenuPress entry with its touch model
6
7
  * @position Core hook for DropdownMenu, ContextMenu, DropdownMenuSubMenu,
7
8
  * Selector and MenuBottomSheetActionList. The transition table lives in
8
9
  * menuPressGesture.ts.
@@ -119,6 +120,30 @@ export interface UseMenuPressReturn {
119
120
  /** End the gesture in flight with nothing acting (the menu closed). */
120
121
  cancel: () => void;
121
122
  }
123
+ /**
124
+ * DropdownMenu's options for the press model: everything the public hook
125
+ * takes, plus its touch model. DropdownMenu reaches the touch model through
126
+ * its `presentation`, so the public hook has no such option.
127
+ *
128
+ * @internal
129
+ */
130
+ export interface DropdownMenuPressOptions extends UseMenuPressOptions {
131
+ /**
132
+ * How the finger that opened the menu from the trigger picks.
133
+ * `'pointer'`: its opening press follows the settle rule. `'uikit'`: it
134
+ * picks only after UIMenu's handoff distance, so the row that appeared
135
+ * under it never acts on a still lift. A mouse is unaffected.
136
+ * @default 'pointer'
137
+ */
138
+ touchModel?: 'pointer' | 'uikit';
139
+ }
140
+ /**
141
+ * What core's own menus get from {@link useDropdownMenuPress}: the public
142
+ * return. Not exported from the hooks entry point.
143
+ *
144
+ * @internal
145
+ */
146
+ export type DropdownMenuPressReturn = UseMenuPressReturn;
122
147
  /**
123
148
  * The press model for a menu: the row under the release acts, the highlight
124
149
  * follows a held pointer, and a mouse opens the menu on press.
@@ -155,4 +180,12 @@ export interface UseMenuPressReturn {
155
180
  * ```
156
181
  */
157
182
  export declare function useMenuPress(options: UseMenuPressOptions): UseMenuPressReturn;
183
+ /**
184
+ * The press model with DropdownMenu's touch model
185
+ * ({@link DropdownMenuPressOptions.touchModel}). Not exported from the hooks
186
+ * entry point.
187
+ *
188
+ * @internal
189
+ */
190
+ export declare function useDropdownMenuPress(options: DropdownMenuPressOptions): DropdownMenuPressReturn;
158
191
  //# sourceMappingURL=useMenuPress.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMenuPress.d.ts","sourceRoot":"","sources":["../../src/hooks/useMenuPress.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EAML,KAAK,oBAAoB,EAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAiBpD,OAAO,EAAC,iBAAiB,EAAC,CAAC;AAE3B;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,mCAAmC,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,yBAAyB,MAAwB,CAAC;AAC/D,iFAAiF;AACjF,eAAO,MAAM,wBAAwB,MAAyB,CAAC;AAC/D;;;;GAIG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WAAW,CAAC,KAAK,IAAI,CAAC;KAC/D,CAAC;IACF;;;;OAIG;IACH,uBAAuB,EAAE,MAAM,OAAO,CAAC;IACvC,uEAAuE;IACvE,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AA0DD;;;;;;GAMG;AACH,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;IACnE;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;CAClC;AAED;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AAczD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAM7E;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,wBAAwB,GAChC,uBAAuB,CA6nBzB"}
@@ -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,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"}