@astryxdesign/core 0.7.5 → 0.7.6-canary.0ef60dd
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/AlertDialog/AlertDialog.d.ts +1 -1
- package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/AlertDialog/AlertDialog.js +5 -5
- package/dist/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +12 -3
- package/dist/Badge/Badge.d.ts.map +1 -1
- package/dist/Badge/Badge.js +7 -1
- package/dist/BottomSheet/BottomSheet.js +1 -1
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +2 -1
- package/dist/BottomSheet/useSheetGestures.d.ts +12 -0
- package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
- package/dist/BottomSheet/useSheetGestures.js +30 -3
- package/dist/Button/Button.js +4 -4
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +6 -5
- package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
- package/dist/ClickableCard/ClickableCard.js +37 -4
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +12 -4
- package/dist/DateInput/MonthScroller.d.ts.map +1 -1
- package/dist/DateInput/MonthScroller.js +101 -15
- package/dist/DateInput/TouchDateField.d.ts.map +1 -1
- package/dist/DateInput/TouchDateField.js +8 -3
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +1 -1
- package/dist/DateTimeInput/DateTimeInput.d.ts +5 -2
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +23 -12
- package/dist/DateTimeInput/NativeTimeSegment.d.ts.map +1 -1
- package/dist/DateTimeInput/NativeTimeSegment.js +5 -4
- package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
- package/dist/DateTimeInput/TouchDateTimeField.js +4 -3
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +34 -9
- package/dist/Dialog/DialogHeader.d.ts.map +1 -1
- package/dist/Dialog/DialogHeader.js +5 -4
- package/dist/Divider/Divider.d.ts.map +1 -1
- package/dist/Divider/Divider.js +2 -1
- package/dist/Drawer/Drawer.d.ts +1 -0
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +7 -2
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +7 -3
- package/dist/DropdownMenu/MenuBottomSheetActionList.d.ts.map +1 -1
- package/dist/DropdownMenu/MenuBottomSheetActionList.js +6 -5
- package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts +20 -2
- package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts.map +1 -1
- package/dist/DropdownMenu/lazyMenuBottomSheet.js +31 -3
- package/dist/DropdownMenu/renderDropdownItems.d.ts.map +1 -1
- package/dist/DropdownMenu/renderDropdownItems.js +21 -16
- package/dist/EmptyState/EmptyState.d.ts.map +1 -1
- package/dist/EmptyState/EmptyState.js +2 -1
- package/dist/Field/FieldLabel.d.ts +1 -1
- package/dist/Field/FieldLabel.d.ts.map +1 -1
- package/dist/Field/FieldLabel.js +4 -4
- package/dist/Field/InputClearButton.js +3 -3
- package/dist/Field/PanelSearchInput.js +2 -2
- package/dist/FieldStatus/FieldStatus.js +2 -2
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +7 -1
- package/dist/Heading/Heading.js +1 -1
- package/dist/Icon/Icon.js +1 -1
- package/dist/Indicator/CheckIndicator.d.ts.map +1 -1
- package/dist/Indicator/CheckIndicator.js +2 -1
- package/dist/Indicator/CheckboxIndicator.d.ts.map +1 -1
- package/dist/Indicator/CheckboxIndicator.js +3 -1
- package/dist/Indicator/RadioIndicator.d.ts.map +1 -1
- package/dist/Indicator/RadioIndicator.js +3 -1
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +2 -1
- package/dist/Item/ItemSwipeLayer.js +1 -1
- package/dist/Layer/popoverOperations.d.ts +27 -0
- package/dist/Layer/popoverOperations.d.ts.map +1 -0
- package/dist/Layer/popoverOperations.js +159 -0
- package/dist/Layer/useLayer.d.ts +1 -1
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +93 -59
- package/dist/Layout/Layout.js +1 -1
- package/dist/Layout/LayoutContent.js +1 -1
- package/dist/Layout/LayoutFooter.js +1 -1
- package/dist/Layout/LayoutHeader.js +1 -1
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +5 -0
- package/dist/Lightbox/LightboxViewport.a11y.browser.spec.js +5 -4
- package/dist/List/List.js +1 -1
- package/dist/List/ListItem.js +3 -3
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +7 -2
- package/dist/MultiSelector/CreateRow.a11y.chromium.spec.js +7 -6
- package/dist/MultiSelector/MultiSelector.d.ts +1 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +26 -10
- package/dist/NumberInput/NumberInput.d.ts +3 -1
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +3 -3
- package/dist/NumberInput/numberParser.d.ts +3 -0
- package/dist/NumberInput/numberParser.d.ts.map +1 -1
- package/dist/NumberInput/numberParser.js +7 -44
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +16 -12
- package/dist/Resizable/useResizable.d.ts.map +1 -1
- package/dist/Resizable/useResizable.js +28 -2
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +4 -1
- package/dist/Selector/useSelectorPresentation.d.ts +8 -1
- package/dist/Selector/useSelectorPresentation.d.ts.map +1 -1
- package/dist/Selector/useSelectorPresentation.js +20 -4
- package/dist/Skeleton/Skeleton.d.ts.map +1 -1
- package/dist/Skeleton/Skeleton.js +1 -1
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +10 -2
- package/dist/Spinner/Spinner.d.ts.map +1 -1
- package/dist/Spinner/Spinner.js +3 -3
- package/dist/Stack/Stack.js +1 -1
- package/dist/Stack/StackItem.js +1 -1
- package/dist/TabList/TabList.d.ts.map +1 -1
- package/dist/TabList/TabList.js +16 -1
- package/dist/Table/plugins/columnResize/useTableColumnResize.d.ts.map +1 -1
- package/dist/Table/plugins/columnResize/useTableColumnResize.js +9 -1
- package/dist/Text/Text.js +1 -1
- package/dist/Text/useTruncation.d.ts.map +1 -1
- package/dist/Text/useTruncation.js +23 -5
- package/dist/TextArea/TextArea.d.ts +1 -1
- package/dist/TextArea/TextArea.d.ts.map +1 -1
- package/dist/TextArea/TextArea.js +13 -2
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +3 -3
- package/dist/TimeInput/TimeInput.d.ts +6 -2
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +21 -14
- package/dist/TimeInput/TouchTimeField.d.ts.map +1 -1
- package/dist/TimeInput/TouchTimeField.js +5 -4
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +2 -2
- package/dist/Timestamp/TimestampHoverCard.js +4 -4
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +60 -20
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +82 -51
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +13 -2
- package/dist/Tokenizer/TokenizerBottomSheet.js +3 -3
- package/dist/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar/Toolbar.js +2 -1
- package/dist/TopNav/TopNavMegaMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMegaMenu.js +3 -0
- package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMenu.js +1 -0
- package/dist/Typeahead/Typeahead.d.ts +1 -1
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +9 -1
- package/dist/astryx.css +20 -4
- package/dist/gestures/GestureArena.d.ts +6 -0
- package/dist/gestures/GestureArena.d.ts.map +1 -1
- package/dist/gestures/GestureArena.js +39 -0
- package/dist/gestures/GestureHost.d.ts +352 -0
- package/dist/gestures/GestureHost.d.ts.map +1 -0
- package/dist/gestures/GestureHost.js +1773 -0
- package/dist/gestures/GestureRecognizer.d.ts +10 -0
- package/dist/gestures/GestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/GestureRecognizer.js +16 -0
- package/dist/gestures/LongPressGestureRecognizer.d.ts +1 -0
- package/dist/gestures/LongPressGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/LongPressGestureRecognizer.js +3 -0
- package/dist/gestures/PanGestureRecognizer.d.ts +1 -0
- package/dist/gestures/PanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/PanGestureRecognizer.js +3 -0
- package/dist/gestures/PinchGestureRecognizer.d.ts +31 -0
- package/dist/gestures/PinchGestureRecognizer.d.ts.map +1 -0
- package/dist/gestures/PinchGestureRecognizer.js +128 -0
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts +71 -0
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts.map +1 -0
- package/dist/gestures/ScreenEdgePanGestureRecognizer.js +223 -0
- package/dist/gestures/SwipeGestureRecognizer.d.ts +37 -0
- package/dist/gestures/SwipeGestureRecognizer.d.ts.map +1 -0
- package/dist/gestures/SwipeGestureRecognizer.js +148 -0
- package/dist/gestures/TapGestureRecognizer.d.ts +1 -0
- package/dist/gestures/TapGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/TapGestureRecognizer.js +3 -0
- package/dist/gestures/VelocityTracker.d.ts +6 -2
- package/dist/gestures/VelocityTracker.d.ts.map +1 -1
- package/dist/gestures/VelocityTracker.js +7 -3
- package/dist/gestures/haptics.d.ts +65 -0
- package/dist/gestures/haptics.d.ts.map +1 -0
- package/dist/gestures/haptics.js +182 -0
- package/dist/gestures/nativeScroll.d.ts +42 -0
- package/dist/gestures/nativeScroll.d.ts.map +1 -0
- package/dist/gestures/nativeScroll.js +228 -0
- package/dist/gestures/touchAction.d.ts +60 -0
- package/dist/gestures/touchAction.d.ts.map +1 -0
- package/dist/gestures/touchAction.js +157 -0
- package/dist/gestures/touchActionRule.d.ts +34 -0
- package/dist/gestures/touchActionRule.d.ts.map +1 -0
- package/dist/gestures/touchActionRule.js +140 -0
- package/dist/gestures/types.d.ts +18 -7
- package/dist/gestures/types.d.ts.map +1 -1
- package/dist/gestures/types.js +22 -2
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/modalAnnounce.d.ts.map +1 -1
- package/dist/hooks/modalAnnounce.js +107 -61
- package/dist/hooks/useAdaptivePresentation.d.ts.map +1 -1
- package/dist/hooks/useAdaptivePresentation.js +4 -1
- package/dist/hooks/useAnnounce.d.ts +101 -42
- package/dist/hooks/useAnnounce.d.ts.map +1 -1
- package/dist/hooks/useAnnounce.js +161 -75
- package/dist/hooks/useAnnounceRenderedText.d.ts +11 -3
- package/dist/hooks/useAnnounceRenderedText.d.ts.map +1 -1
- package/dist/hooks/useAnnounceRenderedText.js +5 -3
- package/dist/hooks/useBusyAnnouncement.d.ts.map +1 -1
- package/dist/hooks/useBusyAnnouncement.js +6 -12
- package/dist/hooks/useMenuHover.d.ts.map +1 -1
- package/dist/hooks/useMenuHover.js +12 -1
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +5 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +5 -0
- package/dist/motion/animator.d.ts +7 -1
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +119 -27
- package/dist/theme/defineTheme.d.ts +19 -5
- package/dist/theme/defineTheme.d.ts.map +1 -1
- package/dist/theme/defineTheme.js +64 -4
- package/dist/theme/domainTokens/domainTokenDefaults.d.ts +3 -0
- package/dist/theme/domainTokens/domainTokenDefaults.d.ts.map +1 -0
- package/dist/theme/domainTokens/domainTokenDefaults.js +19 -0
- package/dist/theme/domainTokens/index.d.ts +5 -4
- package/dist/theme/domainTokens/index.d.ts.map +1 -1
- package/dist/theme/domainTokens/index.js +5 -9
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/motionKnobs.d.ts +56 -0
- package/dist/theme/motionKnobs.d.ts.map +1 -0
- package/dist/theme/motionKnobs.js +48 -0
- package/dist/theme/resolveThemeValues.d.ts +11 -4
- package/dist/theme/resolveThemeValues.d.ts.map +1 -1
- package/dist/theme/resolveThemeValues.js +40 -4
- package/dist/theme/themeAdaptations.d.ts +7 -3
- package/dist/theme/themeAdaptations.d.ts.map +1 -1
- package/dist/theme/themeAdaptations.js +36 -7
- package/dist/theme/themeMotion.d.ts +96 -0
- package/dist/theme/themeMotion.d.ts.map +1 -0
- package/dist/theme/themeMotion.js +177 -0
- package/dist/theme/tokenReferences.d.ts +31 -0
- package/dist/theme/tokenReferences.d.ts.map +1 -0
- package/dist/theme/tokenReferences.js +132 -0
- package/dist/theme/tokens.d.ts +1 -0
- package/dist/theme/tokens.d.ts.map +1 -1
- package/dist/theme/tokens.js +9 -129
- package/dist/theme/tokens.stylex.d.ts +12 -0
- package/dist/theme/tokens.stylex.d.ts.map +1 -1
- package/dist/theme/tokens.stylex.js +12 -0
- package/dist/utils/focusReturn.d.ts +17 -1
- package/dist/utils/focusReturn.d.ts.map +1 -1
- package/dist/utils/focusReturn.js +11 -4
- package/dist/utils/getNodeText.d.ts +8 -0
- package/dist/utils/getNodeText.d.ts.map +1 -0
- package/dist/utils/getNodeText.js +37 -0
- package/dist/utils/interactionModality.d.ts +11 -2
- package/dist/utils/interactionModality.d.ts.map +1 -1
- package/dist/utils/interactionModality.js +58 -5
- package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
- package/dist/utils/interactionOverlay.stylex.js +17 -8
- package/dist/utils/plainDate.d.ts +2 -0
- package/dist/utils/plainDate.d.ts.map +1 -1
- package/dist/utils/plainDate.js +46 -3
- package/dist/utils/presentation.d.ts +50 -0
- package/dist/utils/presentation.d.ts.map +1 -0
- package/dist/utils/presentation.js +125 -0
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +20 -1
- package/dist/utils/primaryClick.d.ts +11 -0
- package/dist/utils/primaryClick.d.ts.map +1 -0
- package/dist/utils/primaryClick.js +25 -0
- package/dist/utils/timeFormat.d.ts +47 -0
- package/dist/utils/timeFormat.d.ts.map +1 -0
- package/dist/utils/timeFormat.js +240 -0
- package/dist/utils/touchPresentation.d.ts.map +1 -1
- package/dist/utils/touchPresentation.js +5 -3
- package/dist/utils/touchPresentation.stylex.d.ts +15 -0
- package/dist/utils/touchPresentation.stylex.d.ts.map +1 -0
- package/dist/utils/touchPresentation.stylex.js +33 -0
- package/dist/utils/unicodeDigits.d.ts +20 -0
- package/dist/utils/unicodeDigits.d.ts.map +1 -0
- package/dist/utils/unicodeDigits.js +70 -0
- package/locales/en.json +23 -3
- package/locales/pseudo.json +15 -0
- package/package.json +5 -4
- package/src/AlertDialog/AlertDialog.tsx +6 -5
- package/src/AlertDialog/__tests__/AlertDialog.a11y.chromium.spec.ts +18 -6
- package/src/Avatar/Avatar.spec.md +22 -22
- package/src/Avatar/Avatar.tsx +18 -1
- package/src/Avatar/__tests__/AvatarForcedColors.a11y.chromium.spec.ts +126 -0
- package/src/Badge/Badge.doc.mjs +1 -1
- package/src/Badge/Badge.tsx +19 -2
- package/src/Badge/__tests__/BadgeLargerText.a11y.chromium.spec.ts +260 -0
- package/src/BottomSheet/BottomSheet.test.tsx +46 -0
- package/src/BottomSheet/BottomSheet.tsx +1 -1
- package/src/BottomSheet/BottomSheetPanel.tsx +2 -1
- package/src/BottomSheet/useSheetGestures.test.ts +52 -0
- package/src/BottomSheet/useSheetGestures.ts +37 -6
- package/src/Breadcrumbs/__tests__/Breadcrumbs.a11y.chromium.spec.ts +18 -6
- package/src/Button/Button.tsx +4 -4
- package/src/Calendar/Calendar.spec.md +87 -48
- package/src/Calendar/__tests__/Calendar.a11y.chromium.spec.ts +21 -7
- package/src/Carousel/__tests__/Carousel.a11y.chromium.spec.ts +21 -7
- package/src/CheckboxInput/CheckboxInput.tsx +6 -5
- package/src/ClickableCard/ClickableCard.test.tsx +96 -0
- package/src/ClickableCard/ClickableCard.tsx +48 -4
- package/src/Collapsible/Collapsible.spec.md +2 -0
- package/src/Collapsible/CollapsibleGroup.spec.md +57 -29
- package/src/Collapsible/__tests__/Collapsible.a11y.chromium.spec.ts +18 -7
- package/src/Collapsible/__tests__/CollapsibleGroupAccordion.a11y.chromium.spec.ts +18 -6
- package/src/ComplexSelector/ComplexSelector.test.tsx +37 -0
- package/src/ContextMenu/ContextMenu.test.tsx +35 -0
- package/src/DateInput/DateInput.test.tsx +115 -3
- package/src/DateInput/DateInput.tsx +29 -14
- package/src/DateInput/DateInputTouch.test.tsx +76 -0
- package/src/DateInput/MonthScroller.tsx +106 -20
- package/src/DateInput/MonthScrollerSettle.test.tsx +165 -0
- package/src/DateInput/TouchDateField.tsx +14 -3
- package/src/DateInput/__tests__/MonthScrollerSteps.interaction.browser.spec.ts +312 -0
- package/src/DateRangeInput/DateRangeInput.test.tsx +46 -3
- package/src/DateRangeInput/DateRangeInput.tsx +16 -12
- package/src/DateTimeInput/DateTimeInput.doc.mjs +10 -8
- package/src/DateTimeInput/DateTimeInput.spec.md +75 -51
- package/src/DateTimeInput/DateTimeInput.test.tsx +81 -0
- package/src/DateTimeInput/DateTimeInput.tsx +46 -24
- package/src/DateTimeInput/NativeTimeSegment.tsx +4 -6
- package/src/DateTimeInput/TouchDateTimeField.tsx +3 -7
- package/src/Dialog/Dialog.test.tsx +216 -2
- package/src/Dialog/Dialog.tsx +42 -9
- package/src/Dialog/DialogHeader.tsx +5 -4
- package/src/Dialog/__tests__/DialogSecondDocument.a11y.browser.spec.ts +202 -0
- package/src/Divider/Divider.tsx +2 -1
- package/src/Drawer/Drawer.spec.md +111 -80
- package/src/Drawer/Drawer.test.tsx +35 -0
- package/src/Drawer/Drawer.tsx +13 -2
- package/src/Drawer/DrawerHeader.spec.md +181 -0
- package/src/Drawer/__tests__/DrawerNonModalPageScroll.a11y.chromium.spec.ts +267 -0
- package/src/DropdownMenu/DropdownMenu.test.tsx +41 -0
- package/src/DropdownMenu/DropdownMenu.tsx +10 -3
- package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +34 -0
- package/src/DropdownMenu/MenuBottomSheetActionList.tsx +6 -5
- package/src/DropdownMenu/__tests__/Menu.a11y.chromium.spec.ts +19 -7
- package/src/DropdownMenu/__tests__/MenuButton.a11y.chromium.spec.ts +21 -9
- package/src/DropdownMenu/lazyMenuBottomSheet.test.ts +60 -0
- package/src/DropdownMenu/lazyMenuBottomSheet.ts +36 -7
- package/src/DropdownMenu/renderDropdownItems.tsx +24 -19
- package/src/EmptyState/EmptyState.tsx +2 -1
- package/src/Field/FieldLabel.tsx +5 -4
- package/src/Field/InputClearButton.tsx +3 -3
- package/src/Field/PanelSearchInput.tsx +2 -2
- package/src/FieldStatus/FieldStatus.tsx +2 -2
- package/src/FileInput/FileInput.test.tsx +21 -0
- package/src/FileInput/FileInput.tsx +4 -1
- package/src/FormLayout/FormLayout.spec.md +7 -8
- package/src/Heading/Heading.tsx +1 -1
- package/src/Icon/Icon.tsx +1 -1
- package/src/Indicator/CheckIndicator.spec.md +47 -42
- package/src/Indicator/CheckIndicator.tsx +2 -1
- package/src/Indicator/CheckboxIndicator.spec.md +40 -37
- package/src/Indicator/CheckboxIndicator.tsx +3 -1
- package/src/Indicator/Indicator.spec.md +188 -0
- package/src/Indicator/RadioIndicator.tsx +3 -1
- package/src/Item/Item.tsx +2 -1
- package/src/Item/ItemSwipeLayer.tsx +1 -1
- package/src/Kbd/Kbd.spec.md +81 -38
- package/src/Layer/__tests__/LayerBrowserHide.a11y.chromium.spec.ts +126 -0
- package/src/Layer/popoverOperations.test.ts +205 -0
- package/src/Layer/popoverOperations.ts +172 -0
- package/src/Layer/useLayer.test.tsx +348 -1
- package/src/Layer/useLayer.tsx +118 -71
- package/src/Layout/Layout.spec.md +127 -131
- package/src/Layout/Layout.tsx +1 -1
- package/src/Layout/LayoutContent.spec.md +205 -0
- package/src/Layout/LayoutContent.tsx +1 -1
- package/src/Layout/LayoutFooter.spec.md +190 -0
- package/src/Layout/LayoutFooter.tsx +1 -1
- package/src/Layout/LayoutHeader.spec.md +193 -0
- package/src/Layout/LayoutHeader.tsx +1 -1
- package/src/Layout/LayoutPanel.spec.md +194 -0
- package/src/Layout/__tests__/Layout.a11y.chromium.spec.ts +18 -6
- package/src/Lightbox/Lightbox.test.tsx +18 -0
- package/src/Lightbox/Lightbox.tsx +5 -0
- package/src/Lightbox/LightboxViewport.a11y.browser.spec.ts +8 -4
- package/src/Link/__tests__/Link.a11y.chromium.spec.ts +18 -8
- package/src/List/List.tsx +1 -1
- package/src/List/ListItem.spec.md +205 -0
- package/src/List/ListItem.tsx +3 -3
- package/src/MetadataList/MetadataList.spec.md +187 -0
- package/src/MetadataList/MetadataListItem.spec.md +165 -0
- package/src/MobileNav/MobileNav.test.tsx +15 -0
- package/src/MobileNav/MobileNav.tsx +9 -1
- package/src/MobileNav/__tests__/MobileNavHeader.a11y.chromium.spec.ts +89 -0
- package/src/MoreMenu/MoreMenu.test.tsx +11 -0
- package/src/MultiSelector/CreateRow.a11y.chromium.spec.ts +7 -8
- package/src/MultiSelector/MultiSelector.spec.md +7 -4
- package/src/MultiSelector/MultiSelector.test.tsx +270 -1
- package/src/MultiSelector/MultiSelector.tsx +25 -10
- package/src/MultiSelector/__tests__/MultiSelector.listbox.a11y.test.tsx +8 -1
- package/src/NavMenu/NavHeadingMenu.spec.md +1 -5
- package/src/NumberInput/NumberInput.doc.mjs +13 -7
- package/src/NumberInput/NumberInput.spec.md +59 -37
- package/src/NumberInput/NumberInput.tsx +13 -3
- package/src/NumberInput/__tests__/NumberInput.coarse-pointer.a11y.chromium.spec.ts +102 -0
- package/src/NumberInput/numberParser.ts +7 -45
- package/src/ProgressBar/ProgressBar.test.tsx +108 -32
- package/src/ProgressBar/ProgressBar.tsx +58 -10
- package/src/ProgressBar/__tests__/ProgressBar.a11y.chromium.spec.ts +21 -9
- package/src/ProgressBar/__tests__/ProgressBarMotion.a11y.chromium.spec.ts +831 -0
- package/src/Resizable/__tests__/ResizeHandle.a11y.chromium.spec.ts +21 -14
- package/src/Resizable/useResizable.test.ts +43 -0
- package/src/Resizable/useResizable.ts +32 -9
- package/src/SegmentedControl/SegmentedControl.test.tsx +84 -0
- package/src/SegmentedControl/SegmentedControlItem.tsx +11 -5
- package/src/Selector/Selector.test.tsx +90 -1
- package/src/Selector/__tests__/Selector.combobox.a11y.test.tsx +8 -1
- package/src/Selector/__tests__/Selector.listbox.a11y.test.tsx +8 -1
- package/src/Selector/useSelectorPresentation.ts +31 -3
- package/src/SideNav/SideNav.test.tsx +27 -0
- package/src/SideNav/__tests__/SideNavRailMotion.interaction.browser.spec.ts +176 -51
- package/src/Skeleton/Skeleton.tsx +3 -1
- package/src/Slider/Slider.test.tsx +31 -0
- package/src/Slider/Slider.tsx +8 -3
- package/src/Slider/__tests__/Slider.a11y.chromium.spec.ts +19 -7
- package/src/Spinner/Spinner.tsx +5 -3
- package/src/Stack/Stack.tsx +1 -1
- package/src/Stack/StackItem.tsx +1 -1
- package/src/TabList/TabList.test.tsx +58 -4
- package/src/TabList/TabList.tsx +16 -1
- package/src/TabList/__tests__/TabPressPointer.interaction.browser.spec.ts +163 -0
- package/src/Table/__tests__/Table.a11y.chromium.spec.ts +18 -6
- package/src/Table/plugins/columnResize/useTableColumnResize.test.tsx +22 -0
- package/src/Table/plugins/columnResize/useTableColumnResize.tsx +8 -4
- package/src/Text/Text.tsx +1 -1
- package/src/Text/useTruncation.test.tsx +128 -1
- package/src/Text/useTruncation.ts +23 -5
- package/src/TextArea/TextArea.spec.md +10 -13
- package/src/TextArea/TextArea.test.tsx +60 -0
- package/src/TextArea/TextArea.tsx +15 -1
- package/src/TextInput/TextInput.test.tsx +21 -0
- package/src/TextInput/TextInput.tsx +3 -1
- package/src/TimeInput/NativeTimeInput.test.tsx +17 -0
- package/src/TimeInput/Presentation.test.tsx +21 -0
- package/src/TimeInput/TimeInput.doc.mjs +8 -8
- package/src/TimeInput/TimeInput.spec.md +45 -48
- package/src/TimeInput/TimeInput.test.tsx +76 -0
- package/src/TimeInput/TimeInput.tsx +36 -18
- package/src/TimeInput/TouchTimeField.tsx +4 -6
- package/src/Timestamp/Timestamp.spec.md +6 -12
- package/src/Timestamp/Timestamp.test.tsx +30 -5
- package/src/Timestamp/Timestamp.tsx +6 -2
- package/src/Timestamp/TimestampHoverCard.tsx +4 -4
- package/src/Toast/Toast.spec.md +14 -20
- package/src/Toast/Toast.tsx +104 -36
- package/src/Toast/ToastViewport.test.tsx +719 -1
- package/src/Toast/ToastViewport.tsx +100 -50
- package/src/Tokenizer/Tokenizer.spec.md +5 -3
- package/src/Tokenizer/Tokenizer.test.tsx +68 -0
- package/src/Tokenizer/Tokenizer.tsx +14 -2
- package/src/Tokenizer/TokenizerBottomSheet.test.tsx +15 -4
- package/src/Tokenizer/TokenizerBottomSheet.tsx +3 -3
- package/src/Toolbar/Toolbar.spec.md +5 -6
- package/src/Toolbar/Toolbar.test.tsx +30 -0
- package/src/Toolbar/Toolbar.tsx +2 -1
- package/src/Toolbar/__tests__/Toolbar.a11y.chromium.spec.ts +18 -6
- package/src/Tooltip/__tests__/Tooltip.a11y.chromium.spec.ts +18 -7
- package/src/TopNav/TopNav.test.tsx +27 -0
- package/src/TopNav/TopNavMegaMenu.test.tsx +21 -0
- package/src/TopNav/TopNavMegaMenu.tsx +4 -1
- package/src/TopNav/TopNavMenu.test.tsx +17 -0
- package/src/TopNav/TopNavMenu.tsx +1 -0
- package/src/Typeahead/Typeahead.test.tsx +40 -0
- package/src/Typeahead/Typeahead.tsx +12 -1
- package/src/__tests__/pressState.ts +8 -4
- package/src/gestures/GestureArena.ts +35 -0
- package/src/gestures/GestureHost.ts +2065 -0
- package/src/gestures/GestureRecognizer.ts +18 -0
- package/src/gestures/LongPressGestureRecognizer.ts +4 -0
- package/src/gestures/PanGestureRecognizer.ts +4 -0
- package/src/gestures/PinchGestureRecognizer.ts +148 -0
- package/src/gestures/ScreenEdgePanGestureRecognizer.ts +256 -0
- package/src/gestures/SwipeGestureRecognizer.ts +197 -0
- package/src/gestures/TapGestureRecognizer.ts +4 -0
- package/src/gestures/VelocityTracker.ts +10 -3
- package/src/gestures/__tests__/GestureHost.test.ts +2087 -0
- package/src/gestures/__tests__/PanGestureRecognizer.test.ts +4 -4
- package/src/gestures/__tests__/PinchGestureRecognizer.test.ts +74 -0
- package/src/gestures/__tests__/ScreenEdgePanGestureRecognizer.test.ts +498 -0
- package/src/gestures/__tests__/SwipeGestureRecognizer.test.ts +108 -0
- package/src/gestures/__tests__/arena.test.ts +5 -0
- package/src/gestures/__tests__/arenaPinchSwipeEdge.test.ts +193 -0
- package/src/gestures/__tests__/browser/build-fixture.mjs +46 -0
- package/src/gestures/__tests__/browser/fixture.ts +307 -0
- package/src/gestures/__tests__/browser/gestures.interaction.browser.spec.ts +1137 -0
- package/src/gestures/__tests__/browserNegotiation.test.ts +293 -0
- package/src/gestures/__tests__/haptics.test.ts +187 -0
- package/src/gestures/__tests__/harness.ts +21 -2
- package/src/gestures/__tests__/recognizerKind.test.ts +78 -0
- package/src/gestures/__tests__/touchActionRule.test.ts +54 -0
- package/src/gestures/haptics.ts +203 -0
- package/src/gestures/nativeScroll.ts +277 -0
- package/src/gestures/touchAction.ts +191 -0
- package/src/gestures/touchActionRule.ts +157 -0
- package/src/gestures/types.ts +30 -9
- package/src/hooks/index.ts +5 -1
- package/src/hooks/modalAnnounce.ts +129 -72
- package/src/hooks/useAdaptivePresentation.ts +4 -1
- package/src/hooks/useAnnounce.doc.mjs +35 -3
- package/src/hooks/useAnnounce.replace.test.tsx +516 -0
- package/src/hooks/useAnnounce.ts +209 -102
- package/src/hooks/useAnnounceRenderedText.adopters.test.tsx +10 -1
- package/src/hooks/useAnnounceRenderedText.ts +17 -3
- package/src/hooks/useBusyAnnouncement.ts +7 -10
- package/src/hooks/useMenuHover.ts +15 -1
- package/src/i18n/generated-locales/en.generated.ts +6 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +6 -0
- package/src/motion/README.md +11 -1
- package/src/motion/animator.test.ts +151 -3
- package/src/motion/animator.ts +149 -33
- package/src/theme/Theme.doc.mjs +1 -1
- package/src/theme/defineTheme.ts +117 -8
- package/src/theme/derivedVarRegistry.test.ts +4 -0
- package/src/theme/domainTokens/domainTokenDefaults.ts +19 -0
- package/src/theme/domainTokens/index.ts +6 -10
- package/src/theme/expandMotionScale.test.ts +1 -1
- package/src/theme/index.ts +5 -0
- package/src/theme/motionKnobs.ts +82 -0
- package/src/theme/resolveThemeValues.ts +68 -6
- package/src/theme/themeAdaptations.ts +52 -12
- package/src/theme/themeMotion.test.ts +620 -0
- package/src/theme/themeMotion.ts +221 -0
- package/src/theme/tokenReferences.ts +149 -0
- package/src/theme/tokens.stylex.ts +10 -0
- package/src/theme/tokens.ts +15 -158
- package/src/utils/focusReturn.ts +17 -6
- package/src/utils/getNodeText.test.ts +24 -0
- package/src/utils/getNodeText.ts +37 -0
- package/src/utils/interactionModality.test.ts +45 -1
- package/src/utils/interactionModality.ts +64 -5
- package/src/utils/interactionOverlay.stylex.ts +12 -3
- package/src/utils/plainDate.test.ts +90 -0
- package/src/utils/plainDate.ts +58 -3
- package/src/utils/presentation.test.ts +380 -0
- package/src/utils/presentation.ts +180 -0
- package/src/utils/pressFeedback.test.ts +138 -0
- package/src/utils/pressFeedback.ts +34 -11
- package/src/utils/pressPaintPriority.test.ts +80 -0
- package/src/utils/primaryClick.test.ts +38 -0
- package/src/utils/primaryClick.ts +28 -0
- package/src/utils/timeFormat.test.ts +204 -0
- package/src/utils/timeFormat.ts +314 -0
- package/src/utils/touchPresentation.stylex.ts +43 -0
- package/src/utils/touchPresentation.test.ts +140 -1
- package/src/utils/touchPresentation.ts +5 -3
- package/src/utils/unicodeDigits.test.ts +44 -0
- package/src/utils/unicodeDigits.ts +71 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file SwipeGestureRecognizer.ts
|
|
5
|
+
* @input Touches from a GestureArena
|
|
6
|
+
* @output Exports SwipeGestureRecognizer (UISwipeGestureRecognizer), its
|
|
7
|
+
* options and direction type
|
|
8
|
+
* @position Discrete recognizer of packages/core/src/gestures
|
|
9
|
+
*
|
|
10
|
+
* Recognized WHILE the fingers move, as UIKit's is: as soon as the centroid
|
|
11
|
+
* has travelled `minimumDistance` along an allowed direction, within
|
|
12
|
+
* `maximumDuration` of touch-down, with off-axis travel no more than
|
|
13
|
+
* `maximumSecondaryMovement` px across it. Off-axis travel past that
|
|
14
|
+
* allowance, or the distance travelled the wrong way, rules a direction out;
|
|
15
|
+
* the swipe fails once every allowed direction is ruled out, as it does for
|
|
16
|
+
* too many fingers, the duration running out, and a lift before it was
|
|
17
|
+
* recognized.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { UIKIT_SWIPE } from "../motion/uikit/gestures.js";
|
|
21
|
+
import { centroid } from "./geometry.js";
|
|
22
|
+
import { GestureRecognizer } from "./GestureRecognizer.js";
|
|
23
|
+
const SWIPE = UIKIT_SWIPE;
|
|
24
|
+
export class SwipeGestureRecognizer extends GestureRecognizer {
|
|
25
|
+
get kind() {
|
|
26
|
+
return 'swipe';
|
|
27
|
+
}
|
|
28
|
+
/** The direction of the recognized swipe. */
|
|
29
|
+
recognizedDirection = null;
|
|
30
|
+
origin = {
|
|
31
|
+
x: 0,
|
|
32
|
+
y: 0
|
|
33
|
+
};
|
|
34
|
+
/** Directions this touch's path has ruled out. */
|
|
35
|
+
ruledOut = new Set();
|
|
36
|
+
/** The centroid at the previous move. */
|
|
37
|
+
last = null;
|
|
38
|
+
constructor(options = {}) {
|
|
39
|
+
super(options);
|
|
40
|
+
const direction = options.direction ?? ['right'];
|
|
41
|
+
this.directions = typeof direction === 'string' ? [direction] : direction;
|
|
42
|
+
this.numberOfTouchesRequired = options.numberOfTouchesRequired ?? 1;
|
|
43
|
+
this.minimumDistance = options.minimumDistance ?? SWIPE.minimumDistance.value;
|
|
44
|
+
this.maximumDuration = options.maximumDuration ?? SWIPE.maximumDuration.value;
|
|
45
|
+
this.maximumSecondaryMovement = options.maximumSecondaryMovement ?? SWIPE.maximumSecondaryMovement.value;
|
|
46
|
+
}
|
|
47
|
+
get isDiscrete() {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
get nativeTouchBehavior() {
|
|
51
|
+
const horizontal = this.directions.some(direction => direction === 'left' || direction === 'right');
|
|
52
|
+
const vertical = this.directions.some(direction => direction === 'up' || direction === 'down');
|
|
53
|
+
return {
|
|
54
|
+
panX: !horizontal,
|
|
55
|
+
panY: !vertical,
|
|
56
|
+
pinchZoom: true,
|
|
57
|
+
doubleTapZoom: false
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
touchesBegan(touches, event) {
|
|
61
|
+
if (this.numberOfTouches > this.numberOfTouchesRequired) {
|
|
62
|
+
this.setState('failed');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (this.numberOfTouches === touches.length) {
|
|
66
|
+
this.setTimer(event.time + this.maximumDuration, () => {
|
|
67
|
+
// A swipe already recognized, waiting on a recognizer it requires to
|
|
68
|
+
// fail, holds its recognition (spec:AST-094 FR15).
|
|
69
|
+
if (this.pending == null) {
|
|
70
|
+
this.setState('failed');
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Measure from where every required finger is down.
|
|
75
|
+
this.origin = centroid(this.touches.values());
|
|
76
|
+
this.last = null;
|
|
77
|
+
}
|
|
78
|
+
touchesMoved() {
|
|
79
|
+
if (this.pending != null || this.numberOfTouches !== this.numberOfTouchesRequired) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const current = centroid(this.touches.values());
|
|
83
|
+
const from = this.last ?? this.origin;
|
|
84
|
+
this.last = current;
|
|
85
|
+
for (const direction of this.directions) {
|
|
86
|
+
if (this.ruledOut.has(direction)) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
// Along and across this direction at the start and the end of the
|
|
90
|
+
// move. The path between two events is read as a straight segment, so
|
|
91
|
+
// the verdict does not depend on how far apart the events were.
|
|
92
|
+
const [along0, across0] = this.project(direction, from);
|
|
93
|
+
const [along1, across1] = this.project(direction, current);
|
|
94
|
+
const reaches = segmentCrossing(along0, along1, this.minimumDistance);
|
|
95
|
+
const strays = Math.max(segmentCrossing(across0, across1, this.maximumSecondaryMovement), segmentCrossing(-across0, -across1, this.maximumSecondaryMovement));
|
|
96
|
+
const strayAt = strays < 0 ? Infinity : strays;
|
|
97
|
+
if (reaches >= 0 && reaches <= strayAt) {
|
|
98
|
+
this.recognizedDirection = direction;
|
|
99
|
+
this.setState('ended');
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// Off-axis travel past the allowance, or the distance the wrong way,
|
|
103
|
+
// rules a direction out for good.
|
|
104
|
+
if (strays >= 0 || along1 <= -this.minimumDistance) {
|
|
105
|
+
this.ruledOut.add(direction);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (this.directions.every(direction => this.ruledOut.has(direction))) {
|
|
109
|
+
this.setState('failed');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Travel along and across `direction` from the origin to `point`. */
|
|
114
|
+
project(direction, point) {
|
|
115
|
+
const dx = point.x - this.origin.x;
|
|
116
|
+
const dy = point.y - this.origin.y;
|
|
117
|
+
return direction === 'left' ? [-dx, dy] : direction === 'right' ? [dx, dy] : direction === 'up' ? [-dy, dx] : [dy, dx];
|
|
118
|
+
}
|
|
119
|
+
touchesEnded() {
|
|
120
|
+
// Recognized and waiting, it holds past the lift (FR15).
|
|
121
|
+
if (this.pending == null) {
|
|
122
|
+
this.setState('failed');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
reset() {
|
|
126
|
+
this.recognizedDirection = null;
|
|
127
|
+
this.ruledOut.clear();
|
|
128
|
+
this.last = null;
|
|
129
|
+
this.origin = {
|
|
130
|
+
x: 0,
|
|
131
|
+
y: 0
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Where on the segment from `start` to `end` (0 to 1) the value first
|
|
138
|
+
* reaches `limit`; 0 when it starts there, -1 when it never does.
|
|
139
|
+
*/
|
|
140
|
+
function segmentCrossing(start, end, limit) {
|
|
141
|
+
if (start >= limit) {
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
if (end < limit) {
|
|
145
|
+
return -1;
|
|
146
|
+
}
|
|
147
|
+
return (limit - start) / (end - start);
|
|
148
|
+
}
|
|
@@ -11,6 +11,7 @@ export interface TapGestureRecognizerOptions extends GestureRecognizerOptions<Ta
|
|
|
11
11
|
maximumTapDuration?: number;
|
|
12
12
|
}
|
|
13
13
|
export declare class TapGestureRecognizer extends GestureRecognizer {
|
|
14
|
+
get kind(): GestureRecognizer['kind'];
|
|
14
15
|
numberOfTapsRequired: number;
|
|
15
16
|
numberOfTouchesRequired: number;
|
|
16
17
|
allowableMovement: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TapGestureRecognizer.d.ts","sourceRoot":"","sources":["../../src/gestures/TapGestureRecognizer.ts"],"names":[],"mappings":"AAuBA,OAAO,EACL,iBAAiB,EAEjB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAC,mBAAmB,EAAE,YAAY,EAAQ,MAAM,SAAS,CAAC;AAEtE,MAAM,WAAW,2BAA4B,SAAQ,wBAAwB,CAAC,oBAAoB,CAAC;IACjG,iBAAiB;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iBAAiB;IACjB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAID,qBAAa,oBAAqB,SAAQ,iBAAiB;IACzD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uBAAuB,EAAE,MAAM,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,0BAA0B,EAAE,MAAM,CAAC;IACnC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAE3B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,iBAAiB,CAAK;IAC9B,4DAA4D;IAC5D,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,0EAA0E;IAC1E,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,QAAQ,CAA4B;gBAEhC,OAAO,GAAE,2BAAgC;IAerD,IAAa,UAAU,IAAI,OAAO,CAEjC;IAED,IAAa,mBAAmB,IAAI,mBAAmB,CAEtD;IAED,qDAAqD;IACrD,IAAI,aAAa,IAAI,MAAM,CAE1B;IAEQ,UAAU,IAAI,OAAO;cAIX,YAAY,CAC7B,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,EACpC,KAAK,EAAE,mBAAmB,GACzB,IAAI;cAoCY,YAAY,CAAC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,GAAG,IAAI;cAMxD,YAAY,CAC7B,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,EACpC,KAAK,EAAE,mBAAmB,GACzB,IAAI;cA6BY,KAAK,IAAI,IAAI;CAQjC"}
|
|
1
|
+
{"version":3,"file":"TapGestureRecognizer.d.ts","sourceRoot":"","sources":["../../src/gestures/TapGestureRecognizer.ts"],"names":[],"mappings":"AAuBA,OAAO,EACL,iBAAiB,EAEjB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAC,mBAAmB,EAAE,YAAY,EAAQ,MAAM,SAAS,CAAC;AAEtE,MAAM,WAAW,2BAA4B,SAAQ,wBAAwB,CAAC,oBAAoB,CAAC;IACjG,iBAAiB;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iBAAiB;IACjB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAID,qBAAa,oBAAqB,SAAQ,iBAAiB;IACzD,IAAa,IAAI,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAE7C;IAED,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uBAAuB,EAAE,MAAM,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,0BAA0B,EAAE,MAAM,CAAC;IACnC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAE3B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,iBAAiB,CAAK;IAC9B,4DAA4D;IAC5D,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,0EAA0E;IAC1E,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,QAAQ,CAA4B;gBAEhC,OAAO,GAAE,2BAAgC;IAerD,IAAa,UAAU,IAAI,OAAO,CAEjC;IAED,IAAa,mBAAmB,IAAI,mBAAmB,CAEtD;IAED,qDAAqD;IACrD,IAAI,aAAa,IAAI,MAAM,CAE1B;IAEQ,UAAU,IAAI,OAAO;cAIX,YAAY,CAC7B,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,EACpC,KAAK,EAAE,mBAAmB,GACzB,IAAI;cAoCY,YAAY,CAAC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,GAAG,IAAI;cAMxD,YAAY,CAC7B,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,EACpC,KAAK,EAAE,mBAAmB,GACzB,IAAI;cA6BY,KAAK,IAAI,IAAI;CAQjC"}
|
|
@@ -24,6 +24,9 @@ import { distance, travel } from "./geometry.js";
|
|
|
24
24
|
import { GestureRecognizer, MANIPULATION } from "./GestureRecognizer.js";
|
|
25
25
|
const TAP = UIKIT_TAP;
|
|
26
26
|
export class TapGestureRecognizer extends GestureRecognizer {
|
|
27
|
+
get kind() {
|
|
28
|
+
return 'tap';
|
|
29
|
+
}
|
|
27
30
|
tapCount = 0;
|
|
28
31
|
isTapInProgress = false;
|
|
29
32
|
maxTouchesThisTap = 0;
|
|
@@ -27,9 +27,13 @@ export declare class VelocityTracker {
|
|
|
27
27
|
* Record a position. Timestamps must not go backwards (an older sample is
|
|
28
28
|
* ignored), and a moved sample at the newest moved sample's timestamp
|
|
29
29
|
* replaces it. A sample at the newest position is not motion: it changes
|
|
30
|
-
* no velocity
|
|
30
|
+
* no velocity, unless `isMotion` says the contact moved anyway (a pinch's
|
|
31
|
+
* value holding while both fingers move, which reads as zero velocity for
|
|
32
|
+
* that interval).
|
|
31
33
|
*/
|
|
32
|
-
add(x: number, y: number, time: number
|
|
34
|
+
add(x: number, y: number, time: number, { isMotion }?: {
|
|
35
|
+
isMotion?: boolean;
|
|
36
|
+
}): void;
|
|
33
37
|
/** Record every sample in order. */
|
|
34
38
|
addSamples(samples: ReadonlyArray<TouchSample>): void;
|
|
35
39
|
/** The newest sample, if any. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VelocityTracker.d.ts","sourceRoot":"","sources":["../../src/gestures/VelocityTracker.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAEhD,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,6CAA6C;IAC7C,OAAO,CAAC,MAAM,CAA4B;IAC1C;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAqB;IAClC,0CAA0C;IAC1C,OAAO,CAAC,KAAK,CAAK;IAClB,mDAAmD;IACnD,OAAO,CAAC,GAAG,CAAe;IAC1B,OAAO,CAAC,WAAW,CAAe;gBAEtB,OAAO,GAAE,sBAA2B;IAIhD,2CAA2C;IAC3C,KAAK,IAAI,IAAI;IAQb
|
|
1
|
+
{"version":3,"file":"VelocityTracker.d.ts","sourceRoot":"","sources":["../../src/gestures/VelocityTracker.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAEhD,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,6CAA6C;IAC7C,OAAO,CAAC,MAAM,CAA4B;IAC1C;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAqB;IAClC,0CAA0C;IAC1C,OAAO,CAAC,KAAK,CAAK;IAClB,mDAAmD;IACnD,OAAO,CAAC,GAAG,CAAe;IAC1B,OAAO,CAAC,WAAW,CAAe;gBAEtB,OAAO,GAAE,sBAA2B;IAIhD,2CAA2C;IAC3C,KAAK,IAAI,IAAI;IAQb;;;;;;;OAOG;IACH,GAAG,CACD,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,MAAM,EACZ,EAAC,QAAgB,EAAC,GAAE;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAM,GAC5C,IAAI;IAwBP,oCAAoC;IACpC,UAAU,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,IAAI;IAMrD,iCAAiC;IACjC,IAAI,UAAU,IAAI,WAAW,GAAG,IAAI,CAEnC;IAED;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK;IAOrC;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,KAAK;IAO1C,OAAO,CAAC,QAAQ;CAQjB"}
|
|
@@ -77,9 +77,13 @@ export class VelocityTracker {
|
|
|
77
77
|
* Record a position. Timestamps must not go backwards (an older sample is
|
|
78
78
|
* ignored), and a moved sample at the newest moved sample's timestamp
|
|
79
79
|
* replaces it. A sample at the newest position is not motion: it changes
|
|
80
|
-
* no velocity
|
|
80
|
+
* no velocity, unless `isMotion` says the contact moved anyway (a pinch's
|
|
81
|
+
* value holding while both fingers move, which reads as zero velocity for
|
|
82
|
+
* that interval).
|
|
81
83
|
*/
|
|
82
|
-
add(x, y, time
|
|
84
|
+
add(x, y, time, {
|
|
85
|
+
isMotion = false
|
|
86
|
+
} = {}) {
|
|
83
87
|
if (this.newest != null && time < this.newest.time) {
|
|
84
88
|
return;
|
|
85
89
|
}
|
|
@@ -89,7 +93,7 @@ export class VelocityTracker {
|
|
|
89
93
|
time
|
|
90
94
|
};
|
|
91
95
|
const last = this.moved[this.moved.length - 1];
|
|
92
|
-
if (last != null && x === last.x && y === last.y) {
|
|
96
|
+
if (last != null && x === last.x && y === last.y && !isMotion) {
|
|
93
97
|
return;
|
|
94
98
|
}
|
|
95
99
|
if (last != null && time === last.time) {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file haptics.ts
|
|
3
|
+
* @input A feedback kind, or a label element a real finger will tap
|
|
4
|
+
* @output Exports playHaptic (vibration where the platform has it),
|
|
5
|
+
* attachTapHaptic (iOS Safari's tap-moment light impact) and the support
|
|
6
|
+
* probes
|
|
7
|
+
* @position Haptics of packages/core/src/gestures; the kinds and the
|
|
8
|
+
* vibration patterns live in the constants table (motion/uikit/gestures.ts)
|
|
9
|
+
*
|
|
10
|
+
* The web has one haptics API, `navigator.vibrate`, and iOS Safari does not
|
|
11
|
+
* implement it. iOS Safari does play a haptic in exactly one place: when a
|
|
12
|
+
* REAL tap toggles an `<input type="checkbox" switch>`, by landing on the
|
|
13
|
+
* switch or on a `<label>` tied to it (and during a native drag-flip of the
|
|
14
|
+
* switch). That haptic is UIImpactFeedbackGenerator(.light). WebKit requires
|
|
15
|
+
* a user gesture AND a trusted event for it: a `label.click()` from script
|
|
16
|
+
* does not play it (WebKit bug 309082, May 2026), so nothing can fire a
|
|
17
|
+
* haptic later from JavaScript, and mid-drag haptics (detent snaps, picker
|
|
18
|
+
* ticks) cannot exist in iOS Safari.
|
|
19
|
+
*
|
|
20
|
+
* So there are two tools:
|
|
21
|
+
*
|
|
22
|
+
* - `attachTapHaptic(label)` puts a visually hidden switch inside a label the
|
|
23
|
+
* control renders as its tap target: every real tap on the label plays the
|
|
24
|
+
* light impact at the moment of the tap. The switch itself never takes the
|
|
25
|
+
* touch (`pointer-events: none`; WebKit marks a switch's `touchstart`
|
|
26
|
+
* handled, which would stop a pan starting on it from scrolling the page),
|
|
27
|
+
* and its own events never reach the page.
|
|
28
|
+
* - `playHaptic(kind)` vibrates where `navigator.vibrate` exists (Android
|
|
29
|
+
* browsers) with the kind's pattern, and does nothing elsewhere.
|
|
30
|
+
*
|
|
31
|
+
* UIKit's haptics follow the system setting, not Reduce Motion, so neither
|
|
32
|
+
* tool consults `prefers-reduced-motion`.
|
|
33
|
+
*/
|
|
34
|
+
import { type HapticFeedbackKind } from '../motion/uikit/gestures.js';
|
|
35
|
+
/** Marks the hidden switch, so click handlers can recognize and ignore it. */
|
|
36
|
+
export declare const HAPTIC_SWITCH_ATTRIBUTE = "data-astryx-haptic-switch";
|
|
37
|
+
/** Whether this browser vibrates at all. */
|
|
38
|
+
export declare function canVibrate(): boolean;
|
|
39
|
+
/** Whether this browser knows the switch control (Safari 17.4 and later). */
|
|
40
|
+
export declare function supportsSwitchControl(doc?: Document): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Vibrate for a feedback kind where `navigator.vibrate` exists. Returns
|
|
43
|
+
* whether anything was played. Never plays on iOS, which has no vibration
|
|
44
|
+
* API; use `attachTapHaptic` for the tap moment there.
|
|
45
|
+
*/
|
|
46
|
+
export declare function playHaptic(kind: HapticFeedbackKind): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Make every real tap on `label` play iOS Safari's light impact, by giving it
|
|
49
|
+
* a hidden switch to toggle. Returns a function that removes the switch.
|
|
50
|
+
* Harmless where switches have no haptics.
|
|
51
|
+
*
|
|
52
|
+
* - The switch never keeps the focus: where a label's activation focuses
|
|
53
|
+
* its control (Chromium), the focus goes on to the label's own control,
|
|
54
|
+
* or back where it was, so it never lands on an `aria-hidden` element.
|
|
55
|
+
* - A label that already has a control keeps it: the switch takes the
|
|
56
|
+
* label's activation (it goes first) and hands the click on to that
|
|
57
|
+
* control, so the tap plays and the control still toggles. The control
|
|
58
|
+
* keeps its name too: while the switch is attached it is labelled by the
|
|
59
|
+
* label through `aria-labelledby`, unless it already names itself. A control
|
|
60
|
+
* that is itself a switch plays on its own, and a label tied to its
|
|
61
|
+
* control by `for` cannot be given a second one: both are left as they
|
|
62
|
+
* are.
|
|
63
|
+
*/
|
|
64
|
+
export declare function attachTapHaptic(label: HTMLLabelElement): () => void;
|
|
65
|
+
//# sourceMappingURL=haptics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"haptics.d.ts","sourceRoot":"","sources":["../../src/gestures/haptics.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAElC,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AAEnE,4CAA4C;AAC5C,wBAAgB,UAAU,IAAI,OAAO,CAIpC;AAED,6EAA6E;AAC7E,wBAAgB,qBAAqB,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,OAAO,CAQ7D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAK5D;AA0BD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAuFnE"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file haptics.ts
|
|
5
|
+
* @input A feedback kind, or a label element a real finger will tap
|
|
6
|
+
* @output Exports playHaptic (vibration where the platform has it),
|
|
7
|
+
* attachTapHaptic (iOS Safari's tap-moment light impact) and the support
|
|
8
|
+
* probes
|
|
9
|
+
* @position Haptics of packages/core/src/gestures; the kinds and the
|
|
10
|
+
* vibration patterns live in the constants table (motion/uikit/gestures.ts)
|
|
11
|
+
*
|
|
12
|
+
* The web has one haptics API, `navigator.vibrate`, and iOS Safari does not
|
|
13
|
+
* implement it. iOS Safari does play a haptic in exactly one place: when a
|
|
14
|
+
* REAL tap toggles an `<input type="checkbox" switch>`, by landing on the
|
|
15
|
+
* switch or on a `<label>` tied to it (and during a native drag-flip of the
|
|
16
|
+
* switch). That haptic is UIImpactFeedbackGenerator(.light). WebKit requires
|
|
17
|
+
* a user gesture AND a trusted event for it: a `label.click()` from script
|
|
18
|
+
* does not play it (WebKit bug 309082, May 2026), so nothing can fire a
|
|
19
|
+
* haptic later from JavaScript, and mid-drag haptics (detent snaps, picker
|
|
20
|
+
* ticks) cannot exist in iOS Safari.
|
|
21
|
+
*
|
|
22
|
+
* So there are two tools:
|
|
23
|
+
*
|
|
24
|
+
* - `attachTapHaptic(label)` puts a visually hidden switch inside a label the
|
|
25
|
+
* control renders as its tap target: every real tap on the label plays the
|
|
26
|
+
* light impact at the moment of the tap. The switch itself never takes the
|
|
27
|
+
* touch (`pointer-events: none`; WebKit marks a switch's `touchstart`
|
|
28
|
+
* handled, which would stop a pan starting on it from scrolling the page),
|
|
29
|
+
* and its own events never reach the page.
|
|
30
|
+
* - `playHaptic(kind)` vibrates where `navigator.vibrate` exists (Android
|
|
31
|
+
* browsers) with the kind's pattern, and does nothing elsewhere.
|
|
32
|
+
*
|
|
33
|
+
* UIKit's haptics follow the system setting, not Reduce Motion, so neither
|
|
34
|
+
* tool consults `prefers-reduced-motion`.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
import { HAPTIC_VIBRATION_PATTERNS } from "../motion/uikit/gestures.js";
|
|
38
|
+
|
|
39
|
+
/** Marks the hidden switch, so click handlers can recognize and ignore it. */
|
|
40
|
+
export const HAPTIC_SWITCH_ATTRIBUTE = 'data-astryx-haptic-switch';
|
|
41
|
+
|
|
42
|
+
/** Whether this browser vibrates at all. */
|
|
43
|
+
export function canVibrate() {
|
|
44
|
+
return typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Whether this browser knows the switch control (Safari 17.4 and later). */
|
|
48
|
+
export function supportsSwitchControl(doc) {
|
|
49
|
+
const target = doc ?? (typeof document === 'undefined' ? null : document);
|
|
50
|
+
if (target == null) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const input = target.createElement('input');
|
|
54
|
+
input.type = 'checkbox';
|
|
55
|
+
return 'switch' in input;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Vibrate for a feedback kind where `navigator.vibrate` exists. Returns
|
|
60
|
+
* whether anything was played. Never plays on iOS, which has no vibration
|
|
61
|
+
* API; use `attachTapHaptic` for the tap moment there.
|
|
62
|
+
*/
|
|
63
|
+
export function playHaptic(kind) {
|
|
64
|
+
if (!canVibrate()) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return navigator.vibrate([...HAPTIC_VIBRATION_PATTERNS[kind].value]);
|
|
68
|
+
}
|
|
69
|
+
const VISUALLY_HIDDEN = 'position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;' + 'overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;' + 'opacity:0;pointer-events:none;';
|
|
70
|
+
let nextLabelId = 0;
|
|
71
|
+
|
|
72
|
+
/** A native disabled control, or one marked `aria-disabled`. */
|
|
73
|
+
function isDisabledControl(control) {
|
|
74
|
+
return control.matches(':disabled') || control.getAttribute('aria-disabled') === 'true';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Whether `input` is a switch checkbox, which plays the tap haptic itself. */
|
|
78
|
+
function isSwitch(input) {
|
|
79
|
+
return input.type === 'checkbox' && input.hasAttribute('switch');
|
|
80
|
+
}
|
|
81
|
+
function swallow(event) {
|
|
82
|
+
event.stopPropagation();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Make every real tap on `label` play iOS Safari's light impact, by giving it
|
|
87
|
+
* a hidden switch to toggle. Returns a function that removes the switch.
|
|
88
|
+
* Harmless where switches have no haptics.
|
|
89
|
+
*
|
|
90
|
+
* - The switch never keeps the focus: where a label's activation focuses
|
|
91
|
+
* its control (Chromium), the focus goes on to the label's own control,
|
|
92
|
+
* or back where it was, so it never lands on an `aria-hidden` element.
|
|
93
|
+
* - A label that already has a control keeps it: the switch takes the
|
|
94
|
+
* label's activation (it goes first) and hands the click on to that
|
|
95
|
+
* control, so the tap plays and the control still toggles. The control
|
|
96
|
+
* keeps its name too: while the switch is attached it is labelled by the
|
|
97
|
+
* label through `aria-labelledby`, unless it already names itself. A control
|
|
98
|
+
* that is itself a switch plays on its own, and a label tied to its
|
|
99
|
+
* control by `for` cannot be given a second one: both are left as they
|
|
100
|
+
* are.
|
|
101
|
+
*/
|
|
102
|
+
export function attachTapHaptic(label) {
|
|
103
|
+
const existing = label.control;
|
|
104
|
+
if (existing instanceof HTMLInputElement && isSwitch(existing) || existing != null && label.htmlFor !== '') {
|
|
105
|
+
return () => {};
|
|
106
|
+
}
|
|
107
|
+
const doc = label.ownerDocument;
|
|
108
|
+
const input = doc.createElement('input');
|
|
109
|
+
input.type = 'checkbox';
|
|
110
|
+
input.setAttribute('switch', '');
|
|
111
|
+
input.setAttribute(HAPTIC_SWITCH_ATTRIBUTE, '');
|
|
112
|
+
input.setAttribute('aria-hidden', 'true');
|
|
113
|
+
input.tabIndex = -1;
|
|
114
|
+
input.style.cssText = VISUALLY_HIDDEN;
|
|
115
|
+
// The label's activation clicks the switch, and that click would bubble
|
|
116
|
+
// through the control as a second click: keep it, and the switch's
|
|
117
|
+
// change events, inside. A label with a control of its own gets that
|
|
118
|
+
// click handed on, so the control still toggles.
|
|
119
|
+
// A disabled control gives no feedback (spec:AST-094 FR23): its label's
|
|
120
|
+
// activation neither toggles the switch, so nothing plays, nor reaches
|
|
121
|
+
// the control.
|
|
122
|
+
const onClick = event => {
|
|
123
|
+
event.stopPropagation();
|
|
124
|
+
if (existing != null && isDisabledControl(existing)) {
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
existing?.click();
|
|
129
|
+
};
|
|
130
|
+
const onFocus = event => {
|
|
131
|
+
const previous = event.relatedTarget;
|
|
132
|
+
if (existing instanceof HTMLElement && existing.tabIndex >= 0 && !isDisabledControl(existing)) {
|
|
133
|
+
existing.focus({
|
|
134
|
+
preventScroll: true
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (doc.activeElement !== input) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (previous instanceof HTMLElement && previous.isConnected) {
|
|
141
|
+
previous.focus({
|
|
142
|
+
preventScroll: true
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (doc.activeElement === input) {
|
|
146
|
+
input.blur();
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
input.addEventListener('click', onClick);
|
|
150
|
+
input.addEventListener('change', swallow);
|
|
151
|
+
input.addEventListener('input', swallow);
|
|
152
|
+
input.addEventListener('focus', onFocus);
|
|
153
|
+
// The switch becomes the label's control, so the control the label named
|
|
154
|
+
// is named through `aria-labelledby` instead (the switch is aria-hidden,
|
|
155
|
+
// so the label's text is the name).
|
|
156
|
+
let labelledControl = null;
|
|
157
|
+
let addedLabelId = false;
|
|
158
|
+
if (existing != null) {
|
|
159
|
+
label.prepend(input);
|
|
160
|
+
if (existing instanceof HTMLElement && !existing.hasAttribute('aria-labelledby') && !existing.hasAttribute('aria-label')) {
|
|
161
|
+
if (label.id === '') {
|
|
162
|
+
label.id = `astryx-haptic-label-${nextLabelId += 1}`;
|
|
163
|
+
addedLabelId = true;
|
|
164
|
+
}
|
|
165
|
+
existing.setAttribute('aria-labelledby', label.id);
|
|
166
|
+
labelledControl = existing;
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
label.appendChild(input);
|
|
170
|
+
}
|
|
171
|
+
return () => {
|
|
172
|
+
labelledControl?.removeAttribute('aria-labelledby');
|
|
173
|
+
if (addedLabelId) {
|
|
174
|
+
label.removeAttribute('id');
|
|
175
|
+
}
|
|
176
|
+
input.removeEventListener('click', onClick);
|
|
177
|
+
input.removeEventListener('change', swallow);
|
|
178
|
+
input.removeEventListener('input', swallow);
|
|
179
|
+
input.removeEventListener('focus', onFocus);
|
|
180
|
+
input.remove();
|
|
181
|
+
};
|
|
182
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file nativeScroll.ts
|
|
3
|
+
* @input An element a touch landed on
|
|
4
|
+
* @output Exports createNativeScrollProbe (the NativeScrollProbe a host gives
|
|
5
|
+
* each touch) and parseTouchAction
|
|
6
|
+
* @position DOM half of the scroll coordination in packages/core/src/gestures
|
|
7
|
+
*
|
|
8
|
+
* Answers one question for a recognizer without letting it touch the DOM:
|
|
9
|
+
* would the browser scroll something if this finger moved that way?
|
|
10
|
+
*
|
|
11
|
+
* The browser scrolls the innermost scroller that has room, then chains
|
|
12
|
+
* outward, so the answer is "yes" while ANY scroller under the touch can
|
|
13
|
+
* still move in that direction, with three narrowings that match the
|
|
14
|
+
* browser's own:
|
|
15
|
+
*
|
|
16
|
+
* - `touch-action` between the touch target and a scroller must allow the
|
|
17
|
+
* axis, or the browser will not pan that scroller with a finger;
|
|
18
|
+
* - an `overscroll-behavior` other than `auto` on the axis stops the chain at
|
|
19
|
+
* that scroller (a sheet body with `contain` never scrolls the page);
|
|
20
|
+
* - a finger moving down scrolls content toward its START (scrollTop
|
|
21
|
+
* decreasing), and horizontally the range follows the writing direction
|
|
22
|
+
* (RTL `scrollLeft` runs from minus the overflow to zero).
|
|
23
|
+
*
|
|
24
|
+
* Styles are read once per touch, on the first question; scroll offsets are
|
|
25
|
+
* read fresh on every question, since a native scroll moves them.
|
|
26
|
+
*/
|
|
27
|
+
import type { NativeScrollProbe } from './types.js';
|
|
28
|
+
export interface AllowedPans {
|
|
29
|
+
readonly x: boolean;
|
|
30
|
+
readonly y: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** Which pans a `touch-action` value lets the browser perform. */
|
|
33
|
+
export declare function parseTouchAction(value: string): AllowedPans;
|
|
34
|
+
/**
|
|
35
|
+
* The node's parent in the flat tree: a slotted node's slot, then out of
|
|
36
|
+
* shadow roots to their hosts, so a scroller inside a shadow tree around the
|
|
37
|
+
* slot is found.
|
|
38
|
+
*/
|
|
39
|
+
export declare function parentAcrossShadow(node: Node): Node | null;
|
|
40
|
+
/** A probe of the native scrollers under `target`. */
|
|
41
|
+
export declare function createNativeScrollProbe(target: unknown): NativeScrollProbe;
|
|
42
|
+
//# sourceMappingURL=nativeScroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeScroll.d.ts","sourceRoot":"","sources":["../../src/gestures/nativeScroll.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAiB3D;AAoBD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAY1D;AAuID,sDAAsD;AACtD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,GAAG,iBAAiB,CAiD1E"}
|