@astryxdesign/core 0.7.6 → 0.7.7-canary.0d1ddcd
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/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteInput.js +8 -1
- package/dist/DateInput/MonthScroller.d.ts.map +1 -1
- package/dist/DateInput/MonthScroller.js +72 -2
- 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/Field/PanelSearchInput.d.ts.map +1 -1
- package/dist/Field/PanelSearchInput.js +8 -1
- package/dist/Field/textEntryTraits.d.ts +6 -6
- package/dist/Field/textEntryTraits.js +6 -6
- 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 +19 -9
- 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 +140 -19
- package/dist/motion/paging.d.ts +58 -0
- package/dist/motion/paging.d.ts.map +1 -0
- package/dist/motion/paging.js +128 -0
- 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/paging.d.ts +160 -0
- package/dist/motion/uikit/paging.d.ts.map +1 -0
- package/dist/motion/uikit/paging.js +162 -0
- package/dist/motion/uikit/scroll.d.ts +0 -19
- package/dist/motion/uikit/scroll.d.ts.map +1 -1
- package/dist/motion/uikit/scroll.js +2 -21
- 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/CommandPalette/CommandPaletteInput.tsx +6 -0
- package/src/DateInput/MonthScroller.tsx +63 -5
- package/src/Drawer/Drawer.tsx +6 -0
- package/src/DropdownMenu/useMenuOverflow.ts +44 -8
- package/src/Field/PanelSearchInput.tsx +6 -0
- package/src/Field/textEntryTraits.ts +6 -6
- 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 +16 -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/MEASUREMENTS.md +8 -1
- package/src/motion/README.md +3 -2
- package/src/motion/animator.ts +193 -25
- package/src/motion/paging.ts +138 -0
- package/src/motion/uikit/index.ts +2 -1
- package/src/motion/uikit/paging.ts +162 -0
- package/src/motion/uikit/scroll.ts +2 -18
- package/src/motion/uikit/slider.ts +105 -0
- package/src/motion/uikit/springs.ts +37 -2
- package/dist/motion/selectPage.d.ts +0 -26
- package/dist/motion/selectPage.d.ts.map +0 -1
- package/dist/motion/selectPage.js +0 -55
- package/src/motion/selectPage.ts +0 -55
|
@@ -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
|
+
}
|
|
@@ -79,6 +79,7 @@ import {
|
|
|
79
79
|
useComponentTranslator,
|
|
80
80
|
} from '../i18n/useComponentTranslator';
|
|
81
81
|
import english from '../i18n/generated-english/Typeahead/BaseTypeahead.generated';
|
|
82
|
+
import {textEntryTraitAttributes} from '../Field/textEntryTraits';
|
|
82
83
|
|
|
83
84
|
registerEnglishFallback(english);
|
|
84
85
|
// =============================================================================
|
|
@@ -607,8 +608,9 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({
|
|
|
607
608
|
);
|
|
608
609
|
// Committed values (Tokenizer's tokens) leave the shown rows in the same
|
|
609
610
|
// render that commits them, before any reload answers, so a list never
|
|
610
|
-
// offers a token (component:Tokenizer FR13).
|
|
611
|
-
//
|
|
611
|
+
// offers a token (component:Tokenizer FR13). Until the reload answers, the
|
|
612
|
+
// highlight stays on its item when that item remains; the reloaded list
|
|
613
|
+
// highlights its first row. The previous key is remembered in state, like
|
|
612
614
|
// `sourceOfState` below.
|
|
613
615
|
const committedChoices = useCommittedChoices();
|
|
614
616
|
const committedChoicesKey = committedChoices?.key;
|
|
@@ -1119,11 +1121,16 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({
|
|
|
1119
1121
|
resultsGenRef.current = gen;
|
|
1120
1122
|
const shown = bootstrapResults.slice(0, maxMenuItems);
|
|
1121
1123
|
const nextHighlightedIndex = shown.length > 0 ? 0 : -1;
|
|
1124
|
+
// A focus load that yields no choice, or fails (it arrives here empty),
|
|
1125
|
+
// closes the list rather than leaving it open and empty. A typed
|
|
1126
|
+
// query's empty search is not a focus load and keeps its empty-search
|
|
1127
|
+
// message.
|
|
1122
1128
|
if (
|
|
1123
1129
|
results.length === 0 &&
|
|
1124
1130
|
shown.length === 0 &&
|
|
1125
1131
|
highlightedIndex === -1
|
|
1126
1132
|
) {
|
|
1133
|
+
popover.hide();
|
|
1127
1134
|
return;
|
|
1128
1135
|
}
|
|
1129
1136
|
setHeldHeight(null);
|
|
@@ -1131,11 +1138,7 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({
|
|
|
1131
1138
|
setHighlightedIndex(nextHighlightedIndex);
|
|
1132
1139
|
if (bootstrapResults.length > 0) {
|
|
1133
1140
|
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.
|
|
1141
|
+
} else {
|
|
1139
1142
|
popover.hide();
|
|
1140
1143
|
}
|
|
1141
1144
|
},
|
|
@@ -1146,7 +1149,6 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({
|
|
|
1146
1149
|
showLayer,
|
|
1147
1150
|
replaceResults,
|
|
1148
1151
|
popover,
|
|
1149
|
-
committedChoices,
|
|
1150
1152
|
],
|
|
1151
1153
|
);
|
|
1152
1154
|
|
|
@@ -1722,6 +1724,12 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({
|
|
|
1722
1724
|
autoFocus={hasAutoFocus}
|
|
1723
1725
|
data-autofocus={hasAutoFocus || undefined}
|
|
1724
1726
|
autoComplete="off"
|
|
1727
|
+
// Autocorrect would rewrite names and identifiers. The key is only a
|
|
1728
|
+
// label: Enter still commits the highlighted option.
|
|
1729
|
+
{...textEntryTraitAttributes({
|
|
1730
|
+
enterKeyHint: 'search',
|
|
1731
|
+
hasAutoCorrect: false,
|
|
1732
|
+
})}
|
|
1725
1733
|
{...mergeProps(
|
|
1726
1734
|
stylex.props(
|
|
1727
1735
|
styles.input,
|
|
@@ -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()) {
|