@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.
- package/dist/AppShell/observeMainOverflow.d.ts.map +1 -1
- package/dist/AppShell/observeMainOverflow.js +9 -6
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +5 -0
- package/dist/Calendar/styles.d.ts +1 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +54 -11
- package/dist/ClickableCard/ClickableCard.d.ts +1 -1
- package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
- package/dist/ClickableCard/ClickableCard.js +5 -1
- package/dist/DateInput/PickerWheel.d.ts.map +1 -1
- package/dist/DateInput/PickerWheel.js +7 -1
- package/dist/DateRangeInput/DateRangeInput.js +1 -1
- package/dist/Dialog/Dialog.d.ts +2 -1
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +12 -1
- package/dist/Drawer/useDrawerDialogPresence.d.ts +2 -1
- package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -1
- package/dist/Drawer/useDrawerDialogPresence.js +11 -2
- package/dist/DropdownMenu/DropdownMenu.d.ts +9 -1
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +9 -4
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +3 -2
- package/dist/DropdownMenu/DropdownMenuItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuItem.js +3 -2
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioItem.js +3 -2
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +3 -2
- package/dist/Field/inputDisabledFocus.d.ts +4 -4
- package/dist/Field/inputStyles.stylex.d.ts +1 -1
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +16 -2
- package/dist/Icon/Icon.d.ts +1 -1
- package/dist/InfoTip/InfoTip.d.ts +1 -0
- package/dist/InfoTip/InfoTip.d.ts.map +1 -1
- package/dist/InfoTip/InfoTip.js +1 -0
- package/dist/InputGroup/InputGroup.d.ts +4 -3
- package/dist/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/InputGroup/InputGroup.js +2 -2
- package/dist/InputGroup/groupStyles.d.ts +1 -1
- package/dist/InputGroup/groupStyles.d.ts.map +1 -1
- package/dist/InputGroup/groupStyles.js +1 -1
- package/dist/Item/Item.d.ts +2 -1
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +29 -6
- package/dist/Layer/holdEntranceInput.d.ts +24 -0
- package/dist/Layer/holdEntranceInput.d.ts.map +1 -0
- package/dist/Layer/holdEntranceInput.js +65 -0
- package/dist/Layer/inputHold.d.ts +49 -0
- package/dist/Layer/inputHold.d.ts.map +1 -0
- package/dist/Layer/inputHold.js +636 -0
- package/dist/Layer/preserveAnimations.d.ts +1 -5
- package/dist/Layer/preserveAnimations.d.ts.map +1 -1
- package/dist/Layer/preserveAnimations.js +12 -214
- package/dist/Layout/LayoutContent.d.ts +3 -1
- package/dist/Layout/LayoutContent.d.ts.map +1 -1
- package/dist/Layout/LayoutContent.js +12 -4
- package/dist/Layout/LayoutPanel.d.ts +4 -1
- package/dist/Layout/LayoutPanel.d.ts.map +1 -1
- package/dist/Layout/LayoutPanel.js +13 -4
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +4 -0
- package/dist/MetadataList/MetadataList.js +1 -1
- package/dist/MobileNav/MobileNav.d.ts +11 -1
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +39 -1
- package/dist/MoreMenu/MoreMenu.d.ts +5 -3
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +22 -4
- package/dist/SelectableCard/SelectableCard.d.ts +1 -1
- package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
- package/dist/SelectableCard/SelectableCard.js +5 -1
- package/dist/Spinner/Spinner.d.ts.map +1 -1
- package/dist/Spinner/Spinner.js +12 -2
- package/dist/Stack/StackItem.d.ts +8 -4
- package/dist/Stack/StackItem.d.ts.map +1 -1
- package/dist/Stack/StackItem.js +17 -4
- package/dist/Table/plugins/sortable/useTableSortable.js +1 -1
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +9 -0
- package/dist/Token/TokenLink.d.ts +1 -1
- package/dist/Token/TokenLink.d.ts.map +1 -1
- package/dist/Token/TokenLink.js +4 -1
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +162 -59
- package/dist/TreeList/TreeListItem.d.ts +2 -1
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +27 -3
- package/dist/astryx.css +35 -8
- package/dist/gestures/GestureHost.d.ts +2 -2
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +21 -6
- package/dist/gestures/PanGestureRecognizer.d.ts +11 -1
- package/dist/gestures/PanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/PanGestureRecognizer.js +15 -1
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts +6 -1
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/nativeScroll.d.ts +3 -6
- package/dist/gestures/nativeScroll.d.ts.map +1 -1
- package/dist/gestures/nativeScroll.js +7 -52
- package/dist/gestures/wheelSegmenter.d.ts +68 -1
- package/dist/gestures/wheelSegmenter.d.ts.map +1 -1
- package/dist/gestures/wheelSegmenter.js +199 -10
- package/dist/hooks/StackItemScrollRegion.d.ts +31 -0
- package/dist/hooks/StackItemScrollRegion.d.ts.map +1 -0
- package/dist/hooks/StackItemScrollRegion.js +40 -0
- package/dist/hooks/menuPressGesture.d.ts +133 -21
- package/dist/hooks/menuPressGesture.d.ts.map +1 -1
- package/dist/hooks/menuPressGesture.js +155 -30
- package/dist/hooks/menuPressValues.d.ts +16 -0
- package/dist/hooks/menuPressValues.d.ts.map +1 -0
- package/dist/hooks/menuPressValues.js +18 -0
- package/dist/hooks/useClickableContainer.d.ts +27 -5
- package/dist/hooks/useClickableContainer.d.ts.map +1 -1
- package/dist/hooks/useClickableContainer.js +41 -5
- package/dist/hooks/useFocusTrap.d.ts +10 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +225 -132
- package/dist/hooks/useMenuPress.d.ts +34 -1
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +93 -5
- package/dist/hooks/usePressFeedback.d.ts +6 -6
- package/dist/hooks/usePressFeedback.js +6 -6
- package/dist/hooks/useScrollRegionProps.d.ts +35 -0
- package/dist/hooks/useScrollRegionProps.d.ts.map +1 -0
- package/dist/hooks/useScrollRegionProps.js +51 -0
- package/dist/i18n/generated-english/hooks/useScrollRegionProps.generated.d.ts +8 -0
- package/dist/i18n/generated-english/hooks/useScrollRegionProps.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/hooks/useScrollRegionProps.generated.js +12 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +1 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +1 -0
- package/dist/motion/carryAnimations.d.ts +58 -0
- package/dist/motion/carryAnimations.d.ts.map +1 -0
- package/dist/motion/carryAnimations.js +305 -0
- package/dist/motion/transientCopy.d.ts +4 -2
- package/dist/motion/transientCopy.d.ts.map +1 -1
- package/dist/motion/transientCopy.js +34 -5
- package/dist/motion/uikit/gestures.d.ts +41 -0
- package/dist/motion/uikit/gestures.d.ts.map +1 -1
- package/dist/motion/uikit/gestures.js +25 -0
- package/dist/motion/uikit/index.d.ts +1 -1
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +1 -1
- package/dist/privateAttributes/menuPressLit.stylex.d.ts +52 -0
- package/dist/privateAttributes/menuPressLit.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/menuPressLit.stylex.js +99 -0
- package/dist/privateAttributes/press.stylex.d.ts +139 -0
- package/dist/privateAttributes/press.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/press.stylex.js +98 -0
- package/dist/theme/tokens.stylex.d.ts +2 -2
- package/dist/theme/tokens.stylex.js +1 -1
- package/dist/utils/flatTree.d.ts +6 -3
- package/dist/utils/flatTree.d.ts.map +1 -1
- package/dist/utils/flatTree.js +13 -3
- package/dist/utils/hitArea.d.ts.map +1 -1
- package/dist/utils/hitArea.js +82 -5
- package/dist/utils/inputStream.d.ts +14 -1
- package/dist/utils/inputStream.d.ts.map +1 -1
- package/dist/utils/inputStream.js +40 -9
- package/dist/utils/interactionOverlay.stylex.d.ts +2 -1
- package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
- package/dist/utils/interactionOverlay.stylex.js +7 -2
- package/dist/utils/pressFeedback.d.ts +7 -0
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +32 -7
- package/dist/utils/pressGesture.d.ts +6 -0
- package/dist/utils/pressGesture.d.ts.map +1 -1
- package/dist/utils/pressGesture.js +17 -0
- package/dist/utils/rowPressLayer.stylex.d.ts +14 -0
- package/dist/utils/rowPressLayer.stylex.d.ts.map +1 -0
- package/dist/utils/rowPressLayer.stylex.js +25 -0
- package/dist/utils/scrollView.d.ts +25 -0
- package/dist/utils/scrollView.d.ts.map +1 -0
- package/dist/utils/scrollView.js +108 -0
- package/dist/utils/selectionLock.d.ts.map +1 -1
- package/dist/utils/selectionLock.js +1 -10
- package/dist/utils/touchHitArea.stylex.d.ts +35 -0
- package/dist/utils/touchHitArea.stylex.d.ts.map +1 -0
- package/dist/utils/touchHitArea.stylex.js +32 -0
- package/dist/utils/triggerFocus.d.ts +5 -0
- package/dist/utils/triggerFocus.d.ts.map +1 -1
- package/dist/utils/triggerFocus.js +9 -2
- package/locales/en.json +4 -0
- package/locales/pseudo.json +3 -0
- package/package.json +5 -5
- package/src/AppShell/observeMainOverflow.ts +9 -6
- package/src/BottomSheet/BottomSheet.tsx +5 -0
- package/src/CheckboxInput/CheckboxInput.doc.mjs +3 -2
- package/src/CheckboxInput/CheckboxInput.tsx +71 -9
- package/src/ClickableCard/ClickableCard.tsx +8 -1
- package/src/DateInput/PickerWheel.tsx +7 -2
- package/src/DateRangeInput/DateRangeInput.tsx +1 -1
- package/src/Dialog/Dialog.doc.mjs +1 -1
- package/src/Dialog/Dialog.tsx +12 -1
- package/src/Drawer/Drawer.doc.mjs +1 -1
- package/src/Drawer/useDrawerDialogPresence.ts +9 -2
- package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -2
- package/src/DropdownMenu/DropdownMenu.tsx +29 -5
- package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +5 -1
- package/src/DropdownMenu/DropdownMenuItem.tsx +8 -4
- package/src/DropdownMenu/DropdownMenuRadioItem.tsx +5 -1
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +5 -1
- package/src/FileInput/FileInput.tsx +16 -2
- package/src/InfoTip/InfoTip.doc.mjs +26 -2
- package/src/InfoTip/InfoTip.tsx +1 -0
- package/src/InputGroup/InputGroup.doc.mjs +4 -3
- package/src/InputGroup/InputGroup.tsx +4 -3
- package/src/InputGroup/groupStyles.ts +3 -1
- package/src/Item/Item.tsx +51 -9
- package/src/Layer/holdEntranceInput.ts +84 -0
- package/src/Layer/inputHold.ts +734 -0
- package/src/Layer/preserveAnimations.ts +12 -275
- package/src/Layout/LayoutContent.doc.mjs +6 -3
- package/src/Layout/LayoutContent.tsx +10 -4
- package/src/Layout/LayoutPanel.doc.mjs +6 -3
- package/src/Layout/LayoutPanel.tsx +11 -4
- package/src/Lightbox/Lightbox.tsx +4 -0
- package/src/MetadataList/MetadataList.tsx +1 -1
- package/src/MobileNav/MobileNav.doc.mjs +3 -3
- package/src/MobileNav/MobileNav.tsx +39 -1
- package/src/MoreMenu/MoreMenu.doc.mjs +2 -4
- package/src/MoreMenu/MoreMenu.tsx +5 -3
- package/src/RadioList/RadioListItem.doc.mjs +3 -2
- package/src/RadioList/RadioListItem.tsx +25 -7
- package/src/SelectableCard/SelectableCard.tsx +8 -1
- package/src/Spinner/Spinner.tsx +13 -3
- package/src/Stack/Stack.doc.mjs +1 -1
- package/src/Stack/StackItem.tsx +27 -13
- package/src/Table/plugins/sortable/useTableSortable.tsx +1 -1
- package/src/Token/Token.tsx +18 -1
- package/src/Token/TokenLink.tsx +7 -1
- package/src/Tooltip/useTooltip.tsx +175 -79
- package/src/TreeList/TreeListItem.tsx +36 -2
- package/src/gestures/GestureHost.ts +21 -5
- package/src/gestures/PanGestureRecognizer.ts +19 -2
- package/src/gestures/README.md +14 -5
- package/src/gestures/ScreenEdgePanGestureRecognizer.ts +6 -1
- package/src/gestures/nativeScroll.ts +12 -68
- package/src/gestures/wheelSegmenter.ts +243 -10
- package/src/hooks/StackItemScrollRegion.tsx +57 -0
- package/src/hooks/menuPressGesture.ts +244 -38
- package/src/hooks/menuPressValues.ts +18 -0
- package/src/hooks/useClickableContainer.doc.mjs +8 -2
- package/src/hooks/useClickableContainer.ts +72 -6
- package/src/hooks/useFocusTrap.ts +268 -151
- package/src/hooks/useMenuPress.ts +118 -11
- package/src/hooks/usePressFeedback.doc.mjs +3 -3
- package/src/hooks/usePressFeedback.ts +6 -6
- package/src/hooks/useScrollRegionProps.ts +76 -0
- package/src/i18n/generated-english/hooks/useScrollRegionProps.generated.ts +13 -0
- package/src/i18n/generated-locales/en.generated.ts +1 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +1 -0
- package/src/motion/MEASUREMENTS.md +11 -0
- package/src/motion/carryAnimations.ts +389 -0
- package/src/motion/transientCopy.ts +45 -5
- package/src/motion/uikit/gestures.ts +22 -0
- package/src/motion/uikit/index.ts +1 -0
- package/src/privateAttributes/menuPressLit.stylex.ts +104 -0
- package/src/privateAttributes/press.stylex.ts +244 -0
- package/src/theme/tokens.stylex.ts +1 -1
- package/src/utils/flatTree.ts +15 -3
- package/src/utils/hitArea.ts +107 -5
- package/src/utils/inputStream.ts +47 -10
- package/src/utils/interactionOverlay.stylex.ts +7 -2
- package/src/utils/pressFeedback.ts +31 -6
- package/src/utils/pressGesture.ts +24 -1
- package/src/utils/rowPressLayer.stylex.ts +27 -0
- package/src/utils/scrollView.ts +135 -0
- package/src/utils/selectionLock.ts +5 -10
- package/src/utils/touchHitArea.stylex.ts +41 -0
- package/src/utils/triggerFocus.ts +17 -4
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file TreeListItem.tsx
|
|
7
|
-
* @input Uses React, StyleX, theme tokens, TreeListBranches
|
|
7
|
+
* @input Uses React, StyleX, theme tokens, TreeListBranches, the shared press
|
|
8
|
+
* overlays and the compositor press layer
|
|
8
9
|
* @output Exports TreeListItem component (internal, not publicly exported)
|
|
9
10
|
* @position Internal implementation; consumed by TreeList.tsx
|
|
10
11
|
*
|
|
@@ -27,8 +28,10 @@ import {
|
|
|
27
28
|
} from '../theme/tokens.stylex';
|
|
28
29
|
import {focusOutlineProps} from '../utils/focusOutline.stylex';
|
|
29
30
|
import {interactionOverlayStyles} from '../utils/interactionOverlay.stylex';
|
|
31
|
+
import {rowPressLayerStyles} from '../privateAttributes/press.stylex';
|
|
30
32
|
import {usePressFeedback} from '../hooks/usePressFeedback';
|
|
31
33
|
import {
|
|
34
|
+
cancelNestedTouchPress,
|
|
32
35
|
hasInteractiveAncestor,
|
|
33
36
|
useClickableContainer,
|
|
34
37
|
} from '../hooks/useClickableContainer';
|
|
@@ -485,6 +488,28 @@ export function TreeListItem({
|
|
|
485
488
|
interactiveRef: linkRef,
|
|
486
489
|
disabled: isDisabled || !forwardsToLink,
|
|
487
490
|
});
|
|
491
|
+
|
|
492
|
+
// A finger press that starts on a control inside the row does not activate
|
|
493
|
+
// the row, so the row shows no press for it. The row's own action, its link
|
|
494
|
+
// or invisible button, activates it. The Chevron does too when the row's
|
|
495
|
+
// surface toggles, since it runs that same toggle.
|
|
496
|
+
const actionButtonRef = useRef<HTMLButtonElement>(null);
|
|
497
|
+
const chevronRef = useRef<HTMLButtonElement>(null);
|
|
498
|
+
const surfaceToggles = onClick == null && handleClick != null;
|
|
499
|
+
const pressOnRow = (event: React.PointerEvent<HTMLDivElement>) => {
|
|
500
|
+
if (isDisabled) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const chevron = chevronRef.current;
|
|
504
|
+
const ownAction =
|
|
505
|
+
surfaceToggles &&
|
|
506
|
+
chevron != null &&
|
|
507
|
+
event.target instanceof Node &&
|
|
508
|
+
chevron.contains(event.target)
|
|
509
|
+
? chevron
|
|
510
|
+
: (linkRef.current ?? actionButtonRef.current);
|
|
511
|
+
cancelNestedTouchPress(event, event.currentTarget, ownAction);
|
|
512
|
+
};
|
|
488
513
|
const {onMouseUp: openLinkOnMiddleClick} = useClickableContainer({
|
|
489
514
|
containerRef: linkRowRef,
|
|
490
515
|
href,
|
|
@@ -566,6 +591,7 @@ export function TreeListItem({
|
|
|
566
591
|
// focusable element to receive Enter/Space). The row's handleClick ignores
|
|
567
592
|
// clicks originating inside a <button>, so this never double-toggles.
|
|
568
593
|
<button
|
|
594
|
+
ref={chevronRef}
|
|
569
595
|
type="button"
|
|
570
596
|
aria-expanded={isExpanded}
|
|
571
597
|
aria-label={t('@astryx.treeList.toggleChildren')}
|
|
@@ -642,6 +668,7 @@ export function TreeListItem({
|
|
|
642
668
|
</LinkComponent>
|
|
643
669
|
) : onClick != null ? (
|
|
644
670
|
<button
|
|
671
|
+
ref={actionButtonRef}
|
|
645
672
|
type="button"
|
|
646
673
|
onClick={onClick}
|
|
647
674
|
aria-disabled={isDisabled || undefined}
|
|
@@ -712,6 +739,10 @@ export function TreeListItem({
|
|
|
712
739
|
densityStyles[density],
|
|
713
740
|
styles.interactive,
|
|
714
741
|
interactionOverlayStyles.backgroundImage,
|
|
742
|
+
// The touch press on a compositor layer (after the
|
|
743
|
+
// overlay, whose own touch paint it turns off).
|
|
744
|
+
rowPressLayerStyles.cell,
|
|
745
|
+
rowPressLayerStyles.cellOnImage,
|
|
715
746
|
isDisabled && styles.disabled,
|
|
716
747
|
isSelected && styles.selected,
|
|
717
748
|
xstyle,
|
|
@@ -732,7 +763,10 @@ export function TreeListItem({
|
|
|
732
763
|
)}
|
|
733
764
|
ref={forwardsToLink ? linkRowRef : undefined}
|
|
734
765
|
onClick={forwardsToLink ? delegateToLink : handleClick}
|
|
735
|
-
onMouseUp={forwardsToLink ? openLinkOnMiddleClick : undefined}
|
|
766
|
+
onMouseUp={forwardsToLink ? openLinkOnMiddleClick : undefined}
|
|
767
|
+
onPointerDown={
|
|
768
|
+
forwardsToLink || handleClick != null ? pressOnRow : undefined
|
|
769
|
+
}>
|
|
736
770
|
<div {...stylex.props(styles.indentedContent)}>{innerContent}</div>
|
|
737
771
|
</div>
|
|
738
772
|
</div>
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file GestureHost.ts
|
|
5
5
|
* @input DOM touch, pointer, click, contextmenu, scroll and focus events of
|
|
6
|
-
* one document; elements with recognizers and consumers attached
|
|
6
|
+
* one document; elements with recognizers and consumers attached; the
|
|
7
|
+
* input hold's held layers (Layer/inputHold `holdsTouch`)
|
|
7
8
|
* @output Exports GestureHost (the DOM side of the gesture system) and
|
|
8
9
|
* getGestureHost (one host per document)
|
|
9
10
|
* @position Browser adapter of packages/core/src/gestures: turns real events
|
|
@@ -149,6 +150,7 @@ import {
|
|
|
149
150
|
import {containsAlongFlatTree} from '../utils/flatTree';
|
|
150
151
|
import {isIosWebKit} from '../utils/touchQueries';
|
|
151
152
|
import {type WheelSegment, WheelSegmenter} from './wheelSegmenter';
|
|
153
|
+
import {holdsTouch} from '../Layer/inputHold';
|
|
152
154
|
import {
|
|
153
155
|
gestureHostStyle,
|
|
154
156
|
type GestureHostStyle,
|
|
@@ -2126,9 +2128,12 @@ export class GestureHost {
|
|
|
2126
2128
|
const recognizers: GestureRecognizer[] = [];
|
|
2127
2129
|
let consumer: TouchConsumer | null = null;
|
|
2128
2130
|
let consumerElement: Element | null = null;
|
|
2131
|
+
// A layer that the input hold holds takes no touch while it presents.
|
|
2132
|
+
// The host asks the hold, so the hold needs nothing from gestures/. A
|
|
2133
|
+
// root-entry component can then use the hold with no gesture code.
|
|
2129
2134
|
if (
|
|
2130
2135
|
target instanceof Node &&
|
|
2131
|
-
[...this.touchGates].some(gate => gate(target))
|
|
2136
|
+
(holdsTouch(target) || [...this.touchGates].some(gate => gate(target)))
|
|
2132
2137
|
) {
|
|
2133
2138
|
return {recognizers, consumer, consumerElement};
|
|
2134
2139
|
}
|
|
@@ -2287,17 +2292,20 @@ export class GestureHost {
|
|
|
2287
2292
|
};
|
|
2288
2293
|
this.wheel = gesture;
|
|
2289
2294
|
}
|
|
2290
|
-
|
|
2295
|
+
let {dx, dy} = wheelPixels(wheel, this.doc.defaultView);
|
|
2291
2296
|
const horizontal = Math.abs(dx) > Math.abs(dy);
|
|
2292
2297
|
// The splitter reads a pan's stream only. A ctrl-wheel pinch has no
|
|
2293
2298
|
// fingers' phase or momentum to tell apart, and ends 100 ms after its
|
|
2294
2299
|
// last wheel.
|
|
2295
2300
|
let seg: WheelSegment | null = null;
|
|
2296
2301
|
if (kind === 'pan') {
|
|
2302
|
+
// Only a trackpad's wheel can join its glide late; a mouse wheel's
|
|
2303
|
+
// notches keep the splitter's other rules.
|
|
2297
2304
|
seg = this.segmenter.push(
|
|
2298
2305
|
time,
|
|
2299
2306
|
horizontal ? dx : dy,
|
|
2300
2307
|
horizontal ? WHEEL_FOLLOW_END_MS : WHEEL_FOLLOW_END_V_MS,
|
|
2308
|
+
scrollTypeOf(wheel) === 'continuous',
|
|
2301
2309
|
);
|
|
2302
2310
|
} else {
|
|
2303
2311
|
this.segmenter.end();
|
|
@@ -2309,6 +2317,14 @@ export class GestureHost {
|
|
|
2309
2317
|
gesture = null;
|
|
2310
2318
|
}
|
|
2311
2319
|
}
|
|
2320
|
+
// A late wheel the glide took was the fingers' first when this one grows.
|
|
2321
|
+
if (seg != null && seg.carried !== 0) {
|
|
2322
|
+
if (horizontal) {
|
|
2323
|
+
dx += seg.carried;
|
|
2324
|
+
} else {
|
|
2325
|
+
dy += seg.carried;
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2312
2328
|
if (gesture == null) {
|
|
2313
2329
|
gesture = this.beginWheel(wheel, kind, dx, dy, time);
|
|
2314
2330
|
this.wheel = gesture;
|
|
@@ -2868,8 +2884,8 @@ export class GestureHost {
|
|
|
2868
2884
|
|
|
2869
2885
|
/**
|
|
2870
2886
|
* Hold touches away from every participant while `gate(target)` answers
|
|
2871
|
-
* true
|
|
2872
|
-
*
|
|
2887
|
+
* true. Returns the release. The input hold's held layers need no gate,
|
|
2888
|
+
* because the host asks `holdsTouch` for every touch.
|
|
2873
2889
|
*/
|
|
2874
2890
|
addTouchGate(gate: (target: Node) => boolean): () => void {
|
|
2875
2891
|
this.touchGates.add(gate);
|
|
@@ -55,7 +55,12 @@ export interface PanGestureRecognizerOptions extends GestureRecognizerOptions<Pa
|
|
|
55
55
|
minimumNumberOfTouches?: number;
|
|
56
56
|
/** @default Infinity */
|
|
57
57
|
maximumNumberOfTouches?: number;
|
|
58
|
-
|
|
58
|
+
/**
|
|
59
|
+
* The travel that begins the pan, px. A function gives each press its own
|
|
60
|
+
* threshold: it reads the press's first touch when that touch lands.
|
|
61
|
+
* @default UIKit's 10
|
|
62
|
+
*/
|
|
63
|
+
hysteresis?: number | ((touch: GestureTouch) => number);
|
|
59
64
|
/** Movement that may begin the pan; anything else fails it. @default 'any' */
|
|
60
65
|
direction?: PanDirection;
|
|
61
66
|
/**
|
|
@@ -117,6 +122,11 @@ export class PanGestureRecognizer extends GestureRecognizer {
|
|
|
117
122
|
travelAtBegan: Point = ZERO;
|
|
118
123
|
|
|
119
124
|
private readonly tracker: VelocityTracker;
|
|
125
|
+
/**
|
|
126
|
+
* Read once per press. A finger that lands later keeps the press's
|
|
127
|
+
* threshold.
|
|
128
|
+
*/
|
|
129
|
+
private readonly hysteresisFor: ((touch: GestureTouch) => number) | null;
|
|
120
130
|
/** The lift's event time once the pan ended: its release (AST-100 FR2). */
|
|
121
131
|
private releaseTime: number | undefined = undefined;
|
|
122
132
|
/** The centroid where the gesture started, in client px. */
|
|
@@ -132,7 +142,10 @@ export class PanGestureRecognizer extends GestureRecognizer {
|
|
|
132
142
|
this.minimumNumberOfTouches = options.minimumNumberOfTouches ?? 1;
|
|
133
143
|
this.maximumNumberOfTouches =
|
|
134
144
|
options.maximumNumberOfTouches ?? Number.POSITIVE_INFINITY;
|
|
135
|
-
|
|
145
|
+
const {hysteresis} = options;
|
|
146
|
+
this.hysteresisFor = typeof hysteresis === 'function' ? hysteresis : null;
|
|
147
|
+
this.hysteresis =
|
|
148
|
+
typeof hysteresis === 'number' ? hysteresis : UIKIT_PAN.hysteresis.value;
|
|
136
149
|
this.direction = options.direction ?? 'any';
|
|
137
150
|
this.axisRatio = options.axisRatio ?? 1;
|
|
138
151
|
this.lockAxis = options.lockAxis ?? false;
|
|
@@ -237,6 +250,10 @@ export class PanGestureRecognizer extends GestureRecognizer {
|
|
|
237
250
|
event: GestureEventContext,
|
|
238
251
|
): void {
|
|
239
252
|
if (this.numberOfTouches === touches.length) {
|
|
253
|
+
const first = touches[0];
|
|
254
|
+
if (this.hysteresisFor != null && first != null) {
|
|
255
|
+
this.hysteresis = this.hysteresisFor(first);
|
|
256
|
+
}
|
|
240
257
|
this.origin = centroid(this.touches.values());
|
|
241
258
|
this.adjust = ZERO;
|
|
242
259
|
this.raw = ZERO;
|
package/src/gestures/README.md
CHANGED
|
@@ -118,7 +118,8 @@ The pan reads its numbers the way `UIPanGestureRecognizer` does, as measured
|
|
|
118
118
|
in the UIKit lab:
|
|
119
119
|
|
|
120
120
|
- It begins once the centroid has moved `hysteresis` (10 px) along either
|
|
121
|
-
axis, not as a distance.
|
|
121
|
+
axis, not as a distance. A function gives each press its own threshold,
|
|
122
|
+
read from the press's first touch when it lands.
|
|
122
123
|
- `translation()` leaves out the travel the threshold took: a slow drag reads
|
|
123
124
|
zero when the pan begins, and a step that overshoots keeps only the
|
|
124
125
|
overshoot. A dragged surface does not jump. `totalTranslation()` is the
|
|
@@ -434,11 +435,15 @@ subscriber cancels it: the host cancels `touchend` and `contextmenu` there
|
|
|
434
435
|
while a claiming participant is attached, never a `touchstart` or a
|
|
435
436
|
`touchmove`, and the click guard (`../utils/clickGuard.ts`) keeps a
|
|
436
437
|
cancelling `click` while it is armed, and from the menu press model's first
|
|
437
|
-
arm on. A
|
|
438
|
+
arm on. A layer's input hold (`../Layer/inputHold.ts`) cancels pointer and
|
|
439
|
+
mouse events, clicks, `touchmove` and `touchend` there while a layer is held,
|
|
440
|
+
never a `touchstart`. A blocking `touchmove` sits on a claiming
|
|
438
441
|
element and on a claimed touch's target, on the document while an element a
|
|
439
442
|
claiming recognizer lives in is moving (Touches on moving elements), or on
|
|
440
|
-
the window only while a page hold is held, so a page
|
|
441
|
-
no scroll.
|
|
443
|
+
the window only while a page hold or a layer's input hold is held, so a page
|
|
444
|
+
of pressables blocks no scroll. The stream records the type of the latest
|
|
445
|
+
pointer event it delivers (`getLastPointerType`); the input hold reads it as
|
|
446
|
+
a layer opens.
|
|
442
447
|
|
|
443
448
|
### Holding the page still
|
|
444
449
|
|
|
@@ -525,7 +530,11 @@ it never moves it; when the fingers carry on instead, their moves absorb
|
|
|
525
530
|
what the pan showed past their travel, or short of it, so it never steps
|
|
526
531
|
back and ends on their travel. Fingers that stop release still, once the end
|
|
527
532
|
time passes. In momentum, a reversal, a delta that grows
|
|
528
|
-
against the decay, or a 50 ms pause starts a new gesture
|
|
533
|
+
against the decay, or a 50 ms pause starts a new gesture; a late, coalesced
|
|
534
|
+
trackpad wheel that continues the glide's deceleration (at or below the next
|
|
535
|
+
step, or near the sum of the next steps its stall spans) belongs to the same
|
|
536
|
+
flick. When the next wheel grows instead, it starts a new gesture with the late
|
|
537
|
+
wheel's travel. A finger, mouse or
|
|
529
538
|
pen that comes down ends it, and a wheel claim keeps the page's text
|
|
530
539
|
selection. A gesture a
|
|
531
540
|
recognizer took is latched to it, as a browser latches a scroller: while it
|
|
@@ -76,12 +76,17 @@ interface EdgeLayout {
|
|
|
76
76
|
*/
|
|
77
77
|
export interface ScreenEdgePanGestureRecognizerOptions extends Omit<
|
|
78
78
|
PanGestureRecognizerOptions,
|
|
79
|
-
'direction' | 'allowedPointerTypes' | 'allowedScrollTypes'
|
|
79
|
+
'direction' | 'allowedPointerTypes' | 'allowedScrollTypes' | 'hysteresis'
|
|
80
80
|
> {
|
|
81
81
|
/** The edges a touch may start from. @default ['leading'] */
|
|
82
82
|
edges?: ReadonlyArray<ScreenEdge>;
|
|
83
83
|
/** Width of the band at each edge, px. */
|
|
84
84
|
edgeRegion?: number;
|
|
85
|
+
/**
|
|
86
|
+
* The travel that begins the pan in its edge zone, px. It is one number for
|
|
87
|
+
* every press, since the zone sets the threshold itself. @default UIKit's 15
|
|
88
|
+
*/
|
|
89
|
+
hysteresis?: number;
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
export class ScreenEdgePanGestureRecognizer extends PanGestureRecognizer {
|
|
@@ -31,33 +31,18 @@
|
|
|
31
31
|
import {isRtlElement} from '../hooks/isRtlElement';
|
|
32
32
|
import type {NativeScrollProbe} from './types';
|
|
33
33
|
import {parentAcrossShadow} from '../utils/flatTree';
|
|
34
|
+
import {
|
|
35
|
+
isInsideScrollView,
|
|
36
|
+
parseTouchAction,
|
|
37
|
+
rootOverflow,
|
|
38
|
+
SCROLLABLE_OVERFLOW as SCROLLABLE,
|
|
39
|
+
type AllowedPans,
|
|
40
|
+
} from '../utils/scrollView';
|
|
34
41
|
|
|
35
42
|
export {parentAcrossShadow};
|
|
36
43
|
|
|
37
|
-
export
|
|
38
|
-
|
|
39
|
-
readonly y: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** Which pans a `touch-action` value lets the browser perform. */
|
|
43
|
-
export function parseTouchAction(value: string): AllowedPans {
|
|
44
|
-
const tokens = value.trim().split(/\s+/);
|
|
45
|
-
if (tokens.includes('auto') || tokens.includes('manipulation')) {
|
|
46
|
-
return {x: true, y: true};
|
|
47
|
-
}
|
|
48
|
-
if (tokens.includes('none')) {
|
|
49
|
-
return {x: false, y: false};
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
x: tokens.some(
|
|
53
|
-
token =>
|
|
54
|
-
token === 'pan-x' || token === 'pan-left' || token === 'pan-right',
|
|
55
|
-
),
|
|
56
|
-
y: tokens.some(
|
|
57
|
-
token => token === 'pan-y' || token === 'pan-up' || token === 'pan-down',
|
|
58
|
-
),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
44
|
+
export {parseTouchAction};
|
|
45
|
+
export type {AllowedPans};
|
|
61
46
|
|
|
62
47
|
interface ChainEntry {
|
|
63
48
|
readonly element: Element;
|
|
@@ -66,15 +51,8 @@ interface ChainEntry {
|
|
|
66
51
|
readonly isRtl: boolean;
|
|
67
52
|
readonly stopsX: boolean;
|
|
68
53
|
readonly stopsY: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* The scroller sits beyond a `position: fixed` ancestor of the touch: it
|
|
71
|
-
* still scrolls under the finger, but it does not carry the touched
|
|
72
|
-
* element, so the element is not inside a scroll view (spec:AST-094 FR11).
|
|
73
|
-
*/
|
|
74
|
-
readonly isBeyondFixed: boolean;
|
|
75
54
|
}
|
|
76
55
|
|
|
77
|
-
const SCROLLABLE = new Set(['auto', 'scroll', 'overlay']);
|
|
78
56
|
const EDGE_TOLERANCE = 1;
|
|
79
57
|
|
|
80
58
|
interface Chain {
|
|
@@ -94,7 +72,6 @@ function buildChain(target: Element, readsTouchAction: boolean): Chain {
|
|
|
94
72
|
let allowX = true;
|
|
95
73
|
let allowY = true;
|
|
96
74
|
let reachedRoot = false;
|
|
97
|
-
let isBeyondFixed = false;
|
|
98
75
|
for (
|
|
99
76
|
let node: Node | null = target;
|
|
100
77
|
node != null;
|
|
@@ -128,15 +105,11 @@ function buildChain(target: Element, readsTouchAction: boolean): Chain {
|
|
|
128
105
|
isRtl: isRtlElement(element as HTMLElement),
|
|
129
106
|
stopsX: behaviorX !== 'auto',
|
|
130
107
|
stopsY: behaviorY !== 'auto',
|
|
131
|
-
isBeyondFixed,
|
|
132
108
|
});
|
|
133
109
|
}
|
|
134
110
|
if (isRoot) {
|
|
135
111
|
break;
|
|
136
112
|
}
|
|
137
|
-
if (style.position === 'fixed') {
|
|
138
|
-
isBeyondFixed = true;
|
|
139
|
-
}
|
|
140
113
|
}
|
|
141
114
|
if (!reachedRoot && root instanceof Element) {
|
|
142
115
|
chain.push({
|
|
@@ -146,7 +119,6 @@ function buildChain(target: Element, readsTouchAction: boolean): Chain {
|
|
|
146
119
|
isRtl: false,
|
|
147
120
|
stopsX: false,
|
|
148
121
|
stopsY: false,
|
|
149
|
-
isBeyondFixed,
|
|
150
122
|
});
|
|
151
123
|
}
|
|
152
124
|
return {entries: chain, allowsPan: allowX || allowY};
|
|
@@ -167,28 +139,6 @@ function overscrollBehavior(style: CSSStyleDeclaration): [string, string] {
|
|
|
167
139
|
return [x || first, y || second];
|
|
168
140
|
}
|
|
169
141
|
|
|
170
|
-
/**
|
|
171
|
-
* The viewport scrolls unless the root or the body clips it (a scroll lock
|
|
172
|
-
* sets `overflow: hidden` on one of them).
|
|
173
|
-
*/
|
|
174
|
-
function rootOverflow(doc: Document, axis: 'x' | 'y'): string {
|
|
175
|
-
const view = doc.defaultView;
|
|
176
|
-
if (view == null) {
|
|
177
|
-
return 'hidden';
|
|
178
|
-
}
|
|
179
|
-
for (const element of [doc.documentElement, doc.body]) {
|
|
180
|
-
if (element == null) {
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
const style = view.getComputedStyle(element);
|
|
184
|
-
const value = axis === 'x' ? style.overflowX : style.overflowY;
|
|
185
|
-
if (value === 'hidden' || value === 'clip') {
|
|
186
|
-
return 'hidden';
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return 'auto';
|
|
190
|
-
}
|
|
191
|
-
|
|
192
142
|
function canMoveY(element: Element, dy: number): boolean {
|
|
193
143
|
if (element.scrollHeight - element.clientHeight <= EDGE_TOLERANCE) {
|
|
194
144
|
return false;
|
|
@@ -288,15 +238,9 @@ export function createNativeScrollProbe(
|
|
|
288
238
|
return chain?.allowsPan === true;
|
|
289
239
|
},
|
|
290
240
|
get isInsideScroller(): boolean {
|
|
291
|
-
return
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
((entry.y &&
|
|
295
|
-
entry.element.scrollHeight - entry.element.clientHeight >
|
|
296
|
-
EDGE_TOLERANCE) ||
|
|
297
|
-
(entry.x &&
|
|
298
|
-
entry.element.scrollWidth - entry.element.clientWidth >
|
|
299
|
-
EDGE_TOLERANCE)),
|
|
241
|
+
return (
|
|
242
|
+
target instanceof Element &&
|
|
243
|
+
isInsideScrollView(target, {readsTouchAction})
|
|
300
244
|
);
|
|
301
245
|
},
|
|
302
246
|
};
|