@astryxdesign/core 0.7.6 → 0.7.7-canary.36f8ea1

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 (101) hide show
  1. package/dist/AppShell/AppShell.d.ts.map +1 -1
  2. package/dist/AppShell/AppShell.js +23 -3
  3. package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
  4. package/dist/BottomSheet/BottomSheetPanel.js +16 -9
  5. package/dist/Chat/ChatComposerInput.d.ts +9 -0
  6. package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
  7. package/dist/Chat/ChatComposerInput.js +2 -0
  8. package/dist/Chat/ChatMessage.js +2 -2
  9. package/dist/Chat/chatMessage.vars.stylex.d.ts +8 -8
  10. package/dist/Chat/chatMessage.vars.stylex.js +8 -8
  11. package/dist/Drawer/Drawer.d.ts.map +1 -1
  12. package/dist/Drawer/Drawer.js +6 -0
  13. package/dist/DropdownMenu/useMenuOverflow.d.ts +13 -3
  14. package/dist/DropdownMenu/useMenuOverflow.d.ts.map +1 -1
  15. package/dist/DropdownMenu/useMenuOverflow.js +31 -8
  16. package/dist/Link/Link.d.ts.map +1 -1
  17. package/dist/Link/Link.js +1 -0
  18. package/dist/Selector/Selector.d.ts.map +1 -1
  19. package/dist/Selector/Selector.js +25 -13
  20. package/dist/Slider/Slider.d.ts.map +1 -1
  21. package/dist/Slider/Slider.js +404 -131
  22. package/dist/Slider/sliderTouchController.d.ts +189 -0
  23. package/dist/Slider/sliderTouchController.d.ts.map +1 -0
  24. package/dist/Slider/sliderTouchController.js +1017 -0
  25. package/dist/Slider/useSliderTouch.d.ts +22 -0
  26. package/dist/Slider/useSliderTouch.d.ts.map +1 -0
  27. package/dist/Slider/useSliderTouch.js +56 -0
  28. package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
  29. package/dist/Typeahead/BaseTypeahead.js +10 -8
  30. package/dist/astryx.css +33 -6
  31. package/dist/gestures/GestureArena.d.ts.map +1 -1
  32. package/dist/gestures/GestureArena.js +4 -1
  33. package/dist/gestures/GestureHost.d.ts +72 -2
  34. package/dist/gestures/GestureHost.d.ts.map +1 -1
  35. package/dist/gestures/GestureHost.js +643 -5
  36. package/dist/gestures/GestureRecognizer.d.ts +15 -1
  37. package/dist/gestures/GestureRecognizer.d.ts.map +1 -1
  38. package/dist/gestures/GestureRecognizer.js +12 -0
  39. package/dist/gestures/PanGestureRecognizer.d.ts +8 -0
  40. package/dist/gestures/PanGestureRecognizer.d.ts.map +1 -1
  41. package/dist/gestures/PinchGestureRecognizer.d.ts +5 -1
  42. package/dist/gestures/PinchGestureRecognizer.d.ts.map +1 -1
  43. package/dist/gestures/PinchGestureRecognizer.js +10 -0
  44. package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts +3 -3
  45. package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts.map +1 -1
  46. package/dist/gestures/ScreenEdgePanGestureRecognizer.js +7 -5
  47. package/dist/gestures/nativeScroll.d.ts +16 -2
  48. package/dist/gestures/nativeScroll.d.ts.map +1 -1
  49. package/dist/gestures/nativeScroll.js +39 -8
  50. package/dist/gestures/recognizerInternals.d.ts +4 -2
  51. package/dist/gestures/recognizerInternals.d.ts.map +1 -1
  52. package/dist/gestures/types.d.ts +11 -0
  53. package/dist/gestures/types.d.ts.map +1 -1
  54. package/dist/gestures/types.js +7 -0
  55. package/dist/gestures/wheelSegmenter.d.ts +45 -0
  56. package/dist/gestures/wheelSegmenter.d.ts.map +1 -0
  57. package/dist/gestures/wheelSegmenter.js +98 -0
  58. package/dist/motion/animator.d.ts.map +1 -1
  59. package/dist/motion/animator.js +77 -14
  60. package/dist/motion/uikit/index.d.ts +2 -1
  61. package/dist/motion/uikit/index.d.ts.map +1 -1
  62. package/dist/motion/uikit/index.js +2 -1
  63. package/dist/motion/uikit/slider.d.ts +97 -0
  64. package/dist/motion/uikit/slider.d.ts.map +1 -0
  65. package/dist/motion/uikit/slider.js +111 -0
  66. package/dist/motion/uikit/springs.d.ts +46 -1
  67. package/dist/motion/uikit/springs.d.ts.map +1 -1
  68. package/dist/motion/uikit/springs.js +48 -4
  69. package/package.json +5 -5
  70. package/src/AppShell/AppShell.doc.mjs +10 -0
  71. package/src/AppShell/AppShell.tsx +48 -2
  72. package/src/BottomSheet/BottomSheetPanel.tsx +16 -9
  73. package/src/Chat/Chat.doc.mjs +1 -0
  74. package/src/Chat/ChatComposerInput.doc.mjs +11 -0
  75. package/src/Chat/ChatComposerInput.tsx +11 -0
  76. package/src/Chat/ChatMessage.tsx +2 -2
  77. package/src/Chat/chatMessage.vars.stylex.ts +8 -8
  78. package/src/Drawer/Drawer.tsx +6 -0
  79. package/src/DropdownMenu/useMenuOverflow.ts +44 -8
  80. package/src/Link/Link.tsx +3 -0
  81. package/src/Selector/Selector.tsx +29 -2
  82. package/src/Slider/Slider.doc.mjs +11 -7
  83. package/src/Slider/Slider.tsx +539 -132
  84. package/src/Slider/sliderTouchController.ts +1209 -0
  85. package/src/Slider/useSliderTouch.ts +78 -0
  86. package/src/Typeahead/BaseTypeahead.tsx +9 -8
  87. package/src/gestures/GestureArena.ts +1 -0
  88. package/src/gestures/GestureHost.ts +765 -5
  89. package/src/gestures/GestureRecognizer.ts +28 -0
  90. package/src/gestures/PanGestureRecognizer.ts +8 -0
  91. package/src/gestures/PinchGestureRecognizer.ts +16 -1
  92. package/src/gestures/README.md +63 -0
  93. package/src/gestures/ScreenEdgePanGestureRecognizer.ts +7 -5
  94. package/src/gestures/nativeScroll.ts +49 -9
  95. package/src/gestures/recognizerInternals.ts +9 -2
  96. package/src/gestures/types.ts +12 -0
  97. package/src/gestures/wheelSegmenter.ts +114 -0
  98. package/src/motion/animator.ts +115 -19
  99. package/src/motion/uikit/index.ts +2 -1
  100. package/src/motion/uikit/slider.ts +105 -0
  101. package/src/motion/uikit/springs.ts +37 -2
@@ -0,0 +1,78 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file useSliderTouch.ts
7
+ * @input Slider's value model and parts, and sliderTouchController.ts
8
+ * @output Exports `useSliderTouch` (the React wiring) and the
9
+ * `SliderTouchModel` and `SliderTouchParts` types
10
+ * @position Internal to Slider. It is the touch layer's one import site, so
11
+ * a desktop build can swap that module whole.
12
+ *
13
+ * SYNC: When modified, update:
14
+ * - /packages/core/src/Slider/sliderTouchController.ts
15
+ * - /packages/core/src/Slider/Slider.tsx (the model and the parts)
16
+ * - /packages/core/src/Slider/useSliderTouch.test.tsx
17
+ */
18
+
19
+ import {useEffect, useState} from 'react';
20
+ import {useIsomorphicLayoutEffect} from '../hooks/useIsomorphicLayoutEffect';
21
+ import {
22
+ SliderTouchController,
23
+ type SliderTouchModel,
24
+ type SliderTouchParts,
25
+ } from './sliderTouchController';
26
+
27
+ export type {SliderTouchModel, SliderTouchParts} from './sliderTouchController';
28
+
29
+ export interface UseSliderTouchOptions {
30
+ /** The slider is enabled: its gestures attach for every pointer. */
31
+ readonly isEnabled: boolean;
32
+ readonly model: SliderTouchModel;
33
+ readonly getParts: () => SliderTouchParts | null;
34
+ /** Re-attaches when the thumbs or the orientation change. */
35
+ readonly thumbCount: number;
36
+ /**
37
+ * Whether each thumb renders inside its value tooltip: changing it mounts
38
+ * new thumbs. So the gestures re-attach.
39
+ */
40
+ readonly thumbsWrapped: boolean;
41
+ }
42
+
43
+ /**
44
+ * Wires UISlider's tracking to a rendered Slider for every pointer, while it
45
+ * is enabled. Slider's own pointer handlers then take only a mouse press on
46
+ * the track.
47
+ */
48
+ export function useSliderTouch({
49
+ isEnabled,
50
+ model,
51
+ getParts,
52
+ thumbCount,
53
+ thumbsWrapped,
54
+ }: UseSliderTouchOptions): void {
55
+ // The parts getter reads only refs. So the first one stays current.
56
+ const [controller] = useState(
57
+ () => new SliderTouchController(model, getParts),
58
+ );
59
+ // Hands the controller this render's model: the values and callbacks it
60
+ // reads from gesture callbacks outside React's render.
61
+ useIsomorphicLayoutEffect(() => {
62
+ controller.setModel(model);
63
+ });
64
+ const {isHorizontal} = model;
65
+ // Synchronizes the thumbs with the document's gesture host. Their
66
+ // PressTrackers and pans attach while the slider is enabled. They detach,
67
+ // ending any interaction silently, when it is disabled or the thumbs
68
+ // change.
69
+ useEffect(() => {
70
+ if (!isEnabled) {
71
+ return undefined;
72
+ }
73
+ return controller.attach();
74
+ }, [controller, isEnabled, thumbCount, isHorizontal, thumbsWrapped]);
75
+ // Releases the controller's animators and gesture host listeners on
76
+ // unmount.
77
+ useEffect(() => () => controller.dispose(), [controller]);
78
+ }
@@ -607,8 +607,9 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({
607
607
  );
608
608
  // Committed values (Tokenizer's tokens) leave the shown rows in the same
609
609
  // render that commits them, before any reload answers, so a list never
610
- // offers a token (component:Tokenizer FR13). The highlight stays on its item
611
- // when that item remains. The previous key is remembered in state, like
610
+ // offers a token (component:Tokenizer FR13). Until the reload answers, the
611
+ // highlight stays on its item when that item remains; the reloaded list
612
+ // highlights its first row. The previous key is remembered in state, like
612
613
  // `sourceOfState` below.
613
614
  const committedChoices = useCommittedChoices();
614
615
  const committedChoicesKey = committedChoices?.key;
@@ -1119,11 +1120,16 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({
1119
1120
  resultsGenRef.current = gen;
1120
1121
  const shown = bootstrapResults.slice(0, maxMenuItems);
1121
1122
  const nextHighlightedIndex = shown.length > 0 ? 0 : -1;
1123
+ // A focus load that yields no choice, or fails (it arrives here empty),
1124
+ // closes the list rather than leaving it open and empty. A typed
1125
+ // query's empty search is not a focus load and keeps its empty-search
1126
+ // message.
1122
1127
  if (
1123
1128
  results.length === 0 &&
1124
1129
  shown.length === 0 &&
1125
1130
  highlightedIndex === -1
1126
1131
  ) {
1132
+ popover.hide();
1127
1133
  return;
1128
1134
  }
1129
1135
  setHeldHeight(null);
@@ -1131,11 +1137,7 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({
1131
1137
  setHighlightedIndex(nextHighlightedIndex);
1132
1138
  if (bootstrapResults.length > 0) {
1133
1139
  showLayer();
1134
- } else if (committedChoices != null) {
1135
- // A Tokenizer list left with no eligible choice (its focus entries
1136
- // all committed, or the request failed) closes rather than staying
1137
- // open and empty (component:Tokenizer FR15). A plain Typeahead
1138
- // provides no committed choices and keeps its current behavior.
1140
+ } else {
1139
1141
  popover.hide();
1140
1142
  }
1141
1143
  },
@@ -1146,7 +1148,6 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({
1146
1148
  showLayer,
1147
1149
  replaceResults,
1148
1150
  popover,
1149
- committedChoices,
1150
1151
  ],
1151
1152
  );
1152
1153
 
@@ -228,6 +228,7 @@ export class GestureArena {
228
228
  target: input.target,
229
229
  scroll: input.scroll ?? null,
230
230
  takenByBrowser: false,
231
+ ...(input.scrollType == null ? {} : {scrollType: input.scrollType}),
231
232
  };
232
233
  const participants: GestureRecognizer[] = [];
233
234
  for (const [depth, recognizer] of input.recognizers.entries()) {