@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.
- package/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +23 -3
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +16 -9
- package/dist/Chat/ChatComposerInput.d.ts +9 -0
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +2 -0
- package/dist/Chat/ChatMessage.js +2 -2
- package/dist/Chat/chatMessage.vars.stylex.d.ts +8 -8
- package/dist/Chat/chatMessage.vars.stylex.js +8 -8
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +6 -0
- package/dist/DropdownMenu/useMenuOverflow.d.ts +13 -3
- package/dist/DropdownMenu/useMenuOverflow.d.ts.map +1 -1
- package/dist/DropdownMenu/useMenuOverflow.js +31 -8
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +1 -0
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +25 -13
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +404 -131
- package/dist/Slider/sliderTouchController.d.ts +189 -0
- package/dist/Slider/sliderTouchController.d.ts.map +1 -0
- package/dist/Slider/sliderTouchController.js +1017 -0
- package/dist/Slider/useSliderTouch.d.ts +22 -0
- package/dist/Slider/useSliderTouch.d.ts.map +1 -0
- package/dist/Slider/useSliderTouch.js +56 -0
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +10 -8
- package/dist/astryx.css +33 -6
- package/dist/gestures/GestureArena.d.ts.map +1 -1
- package/dist/gestures/GestureArena.js +4 -1
- package/dist/gestures/GestureHost.d.ts +72 -2
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +643 -5
- package/dist/gestures/GestureRecognizer.d.ts +15 -1
- package/dist/gestures/GestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/GestureRecognizer.js +12 -0
- package/dist/gestures/PanGestureRecognizer.d.ts +8 -0
- package/dist/gestures/PanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/PinchGestureRecognizer.d.ts +5 -1
- package/dist/gestures/PinchGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/PinchGestureRecognizer.js +10 -0
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts +3 -3
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/ScreenEdgePanGestureRecognizer.js +7 -5
- package/dist/gestures/nativeScroll.d.ts +16 -2
- package/dist/gestures/nativeScroll.d.ts.map +1 -1
- package/dist/gestures/nativeScroll.js +39 -8
- package/dist/gestures/recognizerInternals.d.ts +4 -2
- package/dist/gestures/recognizerInternals.d.ts.map +1 -1
- package/dist/gestures/types.d.ts +11 -0
- package/dist/gestures/types.d.ts.map +1 -1
- package/dist/gestures/types.js +7 -0
- package/dist/gestures/wheelSegmenter.d.ts +45 -0
- package/dist/gestures/wheelSegmenter.d.ts.map +1 -0
- package/dist/gestures/wheelSegmenter.js +98 -0
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +77 -14
- package/dist/motion/uikit/index.d.ts +2 -1
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +2 -1
- package/dist/motion/uikit/slider.d.ts +97 -0
- package/dist/motion/uikit/slider.d.ts.map +1 -0
- package/dist/motion/uikit/slider.js +111 -0
- package/dist/motion/uikit/springs.d.ts +46 -1
- package/dist/motion/uikit/springs.d.ts.map +1 -1
- package/dist/motion/uikit/springs.js +48 -4
- package/package.json +5 -5
- package/src/AppShell/AppShell.doc.mjs +10 -0
- package/src/AppShell/AppShell.tsx +48 -2
- package/src/BottomSheet/BottomSheetPanel.tsx +16 -9
- package/src/Chat/Chat.doc.mjs +1 -0
- package/src/Chat/ChatComposerInput.doc.mjs +11 -0
- package/src/Chat/ChatComposerInput.tsx +11 -0
- package/src/Chat/ChatMessage.tsx +2 -2
- package/src/Chat/chatMessage.vars.stylex.ts +8 -8
- package/src/Drawer/Drawer.tsx +6 -0
- package/src/DropdownMenu/useMenuOverflow.ts +44 -8
- package/src/Link/Link.tsx +3 -0
- package/src/Selector/Selector.tsx +29 -2
- package/src/Slider/Slider.doc.mjs +11 -7
- package/src/Slider/Slider.tsx +539 -132
- package/src/Slider/sliderTouchController.ts +1209 -0
- package/src/Slider/useSliderTouch.ts +78 -0
- package/src/Typeahead/BaseTypeahead.tsx +9 -8
- package/src/gestures/GestureArena.ts +1 -0
- package/src/gestures/GestureHost.ts +765 -5
- package/src/gestures/GestureRecognizer.ts +28 -0
- package/src/gestures/PanGestureRecognizer.ts +8 -0
- package/src/gestures/PinchGestureRecognizer.ts +16 -1
- package/src/gestures/README.md +63 -0
- package/src/gestures/ScreenEdgePanGestureRecognizer.ts +7 -5
- package/src/gestures/nativeScroll.ts +49 -9
- package/src/gestures/recognizerInternals.ts +9 -2
- package/src/gestures/types.ts +12 -0
- package/src/gestures/wheelSegmenter.ts +114 -0
- package/src/motion/animator.ts +115 -19
- package/src/motion/uikit/index.ts +2 -1
- package/src/motion/uikit/slider.ts +105 -0
- 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).
|
|
611
|
-
//
|
|
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
|
|
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()) {
|