@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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
/**
|
|
3
|
+
* @file privateAttributes/menuPressLit.stylex.ts
|
|
4
|
+
* @input The row that a held finger or pen lights in a menu
|
|
5
|
+
* @output Exports markMenuPressLit and clearMenuPressLit, which mark that row,
|
|
6
|
+
* and isMenuPressLit, which reads the mark. It also exports
|
|
7
|
+
* menuPressLitRowStyle, which paints the marked row. The hold pair,
|
|
8
|
+
* holdMenuPressPaint and releaseMenuPressPaint, keeps the other rows off
|
|
9
|
+
* their pressed paint, and isMenuPressPaintHeld reads that hold.
|
|
10
|
+
* @position Owner module of the private menu-press-lit attribute: the only
|
|
11
|
+
* file that writes its name. The menu press model (hooks/useMenuPress.ts)
|
|
12
|
+
* marks the row; DropdownMenu's rows compose the styles. No package entry
|
|
13
|
+
* exports it.
|
|
14
|
+
*
|
|
15
|
+
* SYNC: Each row that composes menuPressLitRowStyle reads
|
|
16
|
+
* `--_menu-row-focus-paint` in its `:focus` background, and a row with an
|
|
17
|
+
* `:active` background reads `--_menu-row-active-paint` there:
|
|
18
|
+
* - /packages/core/src/DropdownMenu/DropdownMenuItem.tsx
|
|
19
|
+
* - /packages/core/src/DropdownMenu/DropdownMenuCheckboxItem.tsx
|
|
20
|
+
* - /packages/core/src/DropdownMenu/DropdownMenuRadioItem.tsx
|
|
21
|
+
* - /packages/core/src/DropdownMenu/DropdownMenuSubMenu.tsx
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import * as stylex from '@stylexjs/stylex';
|
|
25
|
+
import "../theme/tokens.stylex.js";
|
|
26
|
+
import { colorVars } from "../theme/tokens.stylex.js";
|
|
27
|
+
const MENU_PRESS_LIT = 'data-astryx-menu-press-lit';
|
|
28
|
+
const ACTIVE_PAINT = '--_menu-row-active-paint';
|
|
29
|
+
|
|
30
|
+
/** Marks `row` as the row that a held finger or pen lights. */
|
|
31
|
+
export function markMenuPressLit(row) {
|
|
32
|
+
row.setAttribute(MENU_PRESS_LIT, '');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Removes the mark from `row`. */
|
|
36
|
+
export function clearMenuPressLit(row) {
|
|
37
|
+
row.removeAttribute(MENU_PRESS_LIT);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Whether a held finger or pen lights `row`. */
|
|
41
|
+
export function isMenuPressLit(row) {
|
|
42
|
+
return row.hasAttribute(MENU_PRESS_LIT);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Keeps `menu`'s rows off their `:active` paint while a held finger or pen
|
|
47
|
+
* presses in it. The row the press began on stays `:active` as the press
|
|
48
|
+
* moves on. The lit row keeps the pressed overlay through its own mark.
|
|
49
|
+
*/
|
|
50
|
+
export function holdMenuPressPaint(menu) {
|
|
51
|
+
menu.style.setProperty(ACTIVE_PAINT, 'transparent');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Gives `menu`'s rows their `:active` paint back. */
|
|
55
|
+
export function releaseMenuPressPaint(menu) {
|
|
56
|
+
menu.style.removeProperty(ACTIVE_PAINT);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Whether a held finger or pen keeps `menu`'s rows off their `:active` paint. */
|
|
60
|
+
export function isMenuPressPaintHeld(menu) {
|
|
61
|
+
return menu.style.getPropertyValue(ACTIVE_PAINT) !== '';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A value for each attribute state. The index signature gives StyleX the value
|
|
66
|
+
* type, which it cannot read from a literal attribute key.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
const litRowPaint = {
|
|
70
|
+
'--_menu-row-focus-paint': {
|
|
71
|
+
default: null,
|
|
72
|
+
'[data-astryx-menu-press-lit]': colorVars['--color-overlay-pressed']
|
|
73
|
+
},
|
|
74
|
+
'--_menu-row-active-paint': {
|
|
75
|
+
default: null,
|
|
76
|
+
'[data-astryx-menu-press-lit]': colorVars['--color-overlay-pressed']
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const styles = {
|
|
80
|
+
row: {
|
|
81
|
+
"--_menu-row-focus-paint": "x1ar3rj9",
|
|
82
|
+
"--_menu-row-active-paint": "xcukuoe",
|
|
83
|
+
$$css: true
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Compose on a menu row whose `:focus` background is
|
|
89
|
+
* `var(--_menu-row-focus-paint, <hover overlay>)`, and whose `:active`
|
|
90
|
+
* background, if any, is `var(--_menu-row-active-paint, <pressed overlay>)`.
|
|
91
|
+
* The row paints the hover overlay on focus, and the pressed overlay while a
|
|
92
|
+
* held finger or pen lights it.
|
|
93
|
+
* Under a finger, the hover overlay is too faint to follow. The variable has
|
|
94
|
+
* no default: a layered stylesheet emits a default unlayered, and it would
|
|
95
|
+
* beat the attribute arm. The value resolves on the row, so a theme set on any
|
|
96
|
+
* ancestor applies. The style sets only a custom property, which shares no
|
|
97
|
+
* key with StyleX's CSS property type, so TypeScript needs the wider type.
|
|
98
|
+
*/
|
|
99
|
+
export const menuPressLitRowStyle = styles.row;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file privateAttributes/press.stylex.ts
|
|
3
|
+
* @input StyleX, the semantic overlay color tokens, the touch press strength
|
|
4
|
+
* (`pressVars`, utils/interactionOverlay.stylex.ts) and the row layer's
|
|
5
|
+
* clocks (utils/rowPressLayer.stylex.ts)
|
|
6
|
+
* @output `rowPressLayerStyles`: the compositor press layer for list rows
|
|
7
|
+
* (`cell`) and its own-image arms for a row on the `backgroundImage`
|
|
8
|
+
* variant (`cellOnImage`)
|
|
9
|
+
* @position Owner module of the private press attribute for the row layer:
|
|
10
|
+
* the press controller (utils/pressFeedback.ts) writes the attribute, and
|
|
11
|
+
* this file reads it. No package entry exports it. Item and TreeList
|
|
12
|
+
* compose these styles after their overlay variant;
|
|
13
|
+
* utils/interactionOverlay.cell.test.ts tests them.
|
|
14
|
+
*/
|
|
15
|
+
import * as stylex from '@stylexjs/stylex';
|
|
16
|
+
export declare const rowPressLayerStyles: Readonly<{
|
|
17
|
+
readonly cell: Readonly<{
|
|
18
|
+
readonly backgroundImage: stylex.StyleXClassNameFor<"backgroundImage", unknown>;
|
|
19
|
+
readonly animationName: stylex.StyleXClassNameFor<"animationName", unknown>;
|
|
20
|
+
readonly isolation: stylex.StyleXClassNameFor<"isolation", "isolate" | null>;
|
|
21
|
+
readonly '::before': stylex.StyleXClassNameFor<"::before", {
|
|
22
|
+
readonly content: {
|
|
23
|
+
readonly default: null;
|
|
24
|
+
readonly "@media (pointer: coarse)": {
|
|
25
|
+
readonly default: null;
|
|
26
|
+
readonly ":where(:not(:disabled,[aria-disabled=\"true\"]))": {
|
|
27
|
+
readonly default: null;
|
|
28
|
+
readonly ":is([data-astryx-press=\"on\"],[data-astryx-press=\"fading\"])": "\"\"";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
readonly position: {
|
|
33
|
+
readonly default: null;
|
|
34
|
+
readonly "@media (pointer: coarse)": {
|
|
35
|
+
readonly default: null;
|
|
36
|
+
readonly ":is([data-astryx-press=\"on\"],[data-astryx-press=\"fading\"])": "absolute";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
readonly inset: {
|
|
40
|
+
readonly default: null;
|
|
41
|
+
readonly "@media (pointer: coarse)": {
|
|
42
|
+
readonly default: null;
|
|
43
|
+
readonly ":is([data-astryx-press=\"on\"],[data-astryx-press=\"fading\"])": 0;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
readonly zIndex: {
|
|
47
|
+
readonly default: null;
|
|
48
|
+
readonly "@media (pointer: coarse)": {
|
|
49
|
+
readonly default: null;
|
|
50
|
+
readonly ":is([data-astryx-press=\"on\"],[data-astryx-press=\"fading\"])": -1;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
readonly borderRadius: {
|
|
54
|
+
readonly default: null;
|
|
55
|
+
readonly "@media (pointer: coarse)": {
|
|
56
|
+
readonly default: null;
|
|
57
|
+
readonly ":is([data-astryx-press=\"on\"],[data-astryx-press=\"fading\"])": "inherit";
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
readonly pointerEvents: {
|
|
61
|
+
readonly default: null;
|
|
62
|
+
readonly "@media (pointer: coarse)": {
|
|
63
|
+
readonly default: null;
|
|
64
|
+
readonly ":is([data-astryx-press=\"on\"],[data-astryx-press=\"fading\"])": "none";
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
readonly backgroundColor: {
|
|
68
|
+
readonly default: null;
|
|
69
|
+
readonly "@media (pointer: coarse)": {
|
|
70
|
+
readonly default: null;
|
|
71
|
+
readonly ":is([data-astryx-press=\"on\"],[data-astryx-press=\"fading\"])": stylex.StyleXVar<"light-dark(#05365919, #FFFFFF19)">;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
readonly opacity: {
|
|
75
|
+
readonly default: null;
|
|
76
|
+
readonly "@media (pointer: coarse)": {
|
|
77
|
+
readonly default: null;
|
|
78
|
+
readonly "[data-astryx-press=\"on\"]": 1;
|
|
79
|
+
readonly "[data-astryx-press=\"fading\"]": 0;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
readonly animationName: {
|
|
83
|
+
readonly default: null;
|
|
84
|
+
readonly "@media (pointer: coarse)": {
|
|
85
|
+
readonly default: null;
|
|
86
|
+
readonly ":where(:not(:disabled,[aria-disabled=\"true\"]))": {
|
|
87
|
+
readonly default: null;
|
|
88
|
+
readonly "[data-astryx-press=\"fading\"]": string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
readonly animationDuration: {
|
|
93
|
+
readonly default: null;
|
|
94
|
+
readonly "@media (pointer: coarse)": {
|
|
95
|
+
readonly default: null;
|
|
96
|
+
readonly "[data-astryx-press=\"fading\"]": {
|
|
97
|
+
readonly default: string;
|
|
98
|
+
readonly "@media (prefers-reduced-motion: reduce)": string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
readonly animationTimingFunction: {
|
|
103
|
+
readonly default: null;
|
|
104
|
+
readonly "@media (pointer: coarse)": {
|
|
105
|
+
readonly default: null;
|
|
106
|
+
readonly "[data-astryx-press=\"fading\"]": string;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
readonly animationFillMode: {
|
|
110
|
+
readonly default: null;
|
|
111
|
+
readonly "@media (pointer: coarse)": {
|
|
112
|
+
readonly default: null;
|
|
113
|
+
readonly "[data-astryx-press=\"fading\"]": "both";
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
}>;
|
|
117
|
+
}>;
|
|
118
|
+
readonly cellWithoutLayer: Readonly<{
|
|
119
|
+
readonly backgroundImage: stylex.StyleXClassNameFor<"backgroundImage", "none">;
|
|
120
|
+
readonly animationName: stylex.StyleXClassNameFor<"animationName", unknown>;
|
|
121
|
+
readonly isolation: stylex.StyleXClassNameFor<"isolation", "auto" | null>;
|
|
122
|
+
readonly '::before': stylex.StyleXClassNameFor<"::before", {
|
|
123
|
+
readonly content: {
|
|
124
|
+
readonly default: null;
|
|
125
|
+
readonly "@media (pointer: coarse)": {
|
|
126
|
+
readonly default: null;
|
|
127
|
+
readonly ":where(:not(:disabled,[aria-disabled=\"true\"]))": {
|
|
128
|
+
readonly default: null;
|
|
129
|
+
readonly ":is([data-astryx-press=\"on\"],[data-astryx-press=\"fading\"])": "none";
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
}>;
|
|
134
|
+
}>;
|
|
135
|
+
readonly cellOnImage: Readonly<{
|
|
136
|
+
readonly backgroundImage: stylex.StyleXClassNameFor<"backgroundImage", string | null>;
|
|
137
|
+
}>;
|
|
138
|
+
}>;
|
|
139
|
+
//# sourceMappingURL=press.stylex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"press.stylex.d.ts","sourceRoot":"","sources":["../../src/privateAttributes/press.stylex.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAsD3C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyK9B,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @astryx/no-hover-on-disabled -- Every hover branch is
|
|
4
|
+
* nested beneath ENABLED below, as in interactionOverlay.stylex.ts. */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @file privateAttributes/press.stylex.ts
|
|
8
|
+
* @input StyleX, the semantic overlay color tokens, the touch press strength
|
|
9
|
+
* (`pressVars`, utils/interactionOverlay.stylex.ts) and the row layer's
|
|
10
|
+
* clocks (utils/rowPressLayer.stylex.ts)
|
|
11
|
+
* @output `rowPressLayerStyles`: the compositor press layer for list rows
|
|
12
|
+
* (`cell`) and its own-image arms for a row on the `backgroundImage`
|
|
13
|
+
* variant (`cellOnImage`)
|
|
14
|
+
* @position Owner module of the private press attribute for the row layer:
|
|
15
|
+
* the press controller (utils/pressFeedback.ts) writes the attribute, and
|
|
16
|
+
* this file reads it. No package entry exports it. Item and TreeList
|
|
17
|
+
* compose these styles after their overlay variant;
|
|
18
|
+
* utils/interactionOverlay.cell.test.ts tests them.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import * as stylex from '@stylexjs/stylex';
|
|
22
|
+
import "../theme/tokens.stylex.js";
|
|
23
|
+
import { colorVars } from "../theme/tokens.stylex.js";
|
|
24
|
+
import "../utils/interactionOverlay.stylex.js";
|
|
25
|
+
import { pressVars } from "../utils/interactionOverlay.stylex.js";
|
|
26
|
+
import "../utils/rowPressLayer.stylex.js";
|
|
27
|
+
import { cellPressConsts } from "../utils/rowPressLayer.stylex.js";
|
|
28
|
+
|
|
29
|
+
// The overlay's arm selectors (interactionOverlay.stylex.ts), restated here:
|
|
30
|
+
// StyleX resolves a style's keys within its own file.
|
|
31
|
+
const ENABLED = ':where(:not(:disabled,[aria-disabled="true"]))';
|
|
32
|
+
const HOVER_HOVER = '@media (hover: hover)';
|
|
33
|
+
const COARSE = '@media (pointer: coarse)';
|
|
34
|
+
const PRESSED_ON = '[data-astryx-press="on"]';
|
|
35
|
+
const PRESSED_FADING = '[data-astryx-press="fading"]';
|
|
36
|
+
/**
|
|
37
|
+
* A press in any of its states: the row layer exists only then, so at rest a
|
|
38
|
+
* row's own `::before` and its stacking are untouched.
|
|
39
|
+
*/
|
|
40
|
+
const PRESSED_ANY = ':is([data-astryx-press="on"],[data-astryx-press="fading"])';
|
|
41
|
+
const PRESS_ALPHA = pressVars['--astryx-press-alpha'];
|
|
42
|
+
const hoverImage = `linear-gradient(${colorVars['--color-overlay-hover']}, ${colorVars['--color-overlay-hover']})`;
|
|
43
|
+
const pressedImage = `linear-gradient(${colorVars['--color-overlay-pressed']}, ${colorVars['--color-overlay-pressed']})`;
|
|
44
|
+
/** The overlay's paint, read back off the element (its gradient layer). */
|
|
45
|
+
const pressedOverlayImage = 'var(--_press-paint-image)';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The overlay's strength release (interactionOverlay.stylex.ts), restated so
|
|
49
|
+
* a fine pointer keeps it: the same keyframes, so the same animation.
|
|
50
|
+
*/
|
|
51
|
+
const pressRelease = "x10jkm1t-B";
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The row layer's clock as CSS. It is the strength release's clock, scaled
|
|
55
|
+
* by the theme's `--_astryx-motion-tempo` up to 1.5, so the layer and the
|
|
56
|
+
* strength land together.
|
|
57
|
+
*/
|
|
58
|
+
const CELL_RELEASE = `calc(${cellPressConsts.cellReleaseMs}ms * min(var(--_astryx-motion-tempo, 1), 1.5))`;
|
|
59
|
+
/** The same clock under Reduce Motion: a tempo may shorten it, never lengthen it. */
|
|
60
|
+
const CELL_RELEASE_REDUCED = `min(${cellPressConsts.cellReleaseMs}ms, calc(${cellPressConsts.cellReleaseMs}ms * var(--_astryx-motion-tempo, 1)))`;
|
|
61
|
+
const REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';
|
|
62
|
+
|
|
63
|
+
/** Opacity 1 → 0: the row layer leaves; its fading arm runs it. */
|
|
64
|
+
const cellRelease = "x1jn504y-B";
|
|
65
|
+
|
|
66
|
+
/** The release's curve: the table's gentle ease-out. */
|
|
67
|
+
const RELEASE_EASE = cellPressConsts.cellReleaseEase;
|
|
68
|
+
export const rowPressLayerStyles = {
|
|
69
|
+
cell: {
|
|
70
|
+
kKwaWg: "x7ngsy6 x10ogxw0 xubczrd x18xnkjv",
|
|
71
|
+
kKVMdj: "x14e4jsf x6su2wr",
|
|
72
|
+
kHBbk8: "xif6eam",
|
|
73
|
+
kgeoSG: "x1ocadqd",
|
|
74
|
+
kEoFBp: "x1ukh9kf",
|
|
75
|
+
kFcpXp: "xrkptjy",
|
|
76
|
+
kxmVGU: "xjscm90",
|
|
77
|
+
kPB484: "x1kec4ew",
|
|
78
|
+
km8f2m: "x13r5q6d",
|
|
79
|
+
kLkRvE: "x1dn949c",
|
|
80
|
+
k5QlbN: "xw7rim2 xr9xsjc",
|
|
81
|
+
k7EzDT: "x1bxn267",
|
|
82
|
+
kQZAMR: "x16lp0i7 x1bf026e",
|
|
83
|
+
kZiNAr: "x1gyhjqm",
|
|
84
|
+
k8Tatv: "x1dn5vsf",
|
|
85
|
+
$$css: true
|
|
86
|
+
},
|
|
87
|
+
cellWithoutLayer: {
|
|
88
|
+
kKwaWg: "x18o3ruo",
|
|
89
|
+
kKVMdj: "x14e4jsf",
|
|
90
|
+
kHBbk8: "xrqzsdu",
|
|
91
|
+
kgeoSG: "x1995whq",
|
|
92
|
+
$$css: true
|
|
93
|
+
},
|
|
94
|
+
cellOnImage: {
|
|
95
|
+
kKwaWg: "x7uyq82 x3f84ok x7ngsy6 x10ogxw0 xubczrd x18xnkjv xmvprkv xetgvay",
|
|
96
|
+
$$css: true
|
|
97
|
+
}
|
|
98
|
+
};
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import * as stylex from '@stylexjs/stylex';
|
|
17
17
|
export declare const colorDefaults: {
|
|
18
|
-
readonly '--color-accent': "light-dark(#0064E0, #
|
|
18
|
+
readonly '--color-accent': "light-dark(#0064E0, #0171E3)";
|
|
19
19
|
readonly '--color-accent-muted': "light-dark(#0082FB33, #0082FB3F)";
|
|
20
20
|
readonly '--color-on-accent': "light-dark(#FFFFFF, #FFFFFF)";
|
|
21
21
|
readonly '--color-neutral': "light-dark(rgba(5, 54, 89, 0.1), rgba(223, 226, 229, 0.2))";
|
|
@@ -115,7 +115,7 @@ export declare const colorDefaults: {
|
|
|
115
115
|
readonly '--color-text-yellow': "light-dark(#753F07, #FBCE03)";
|
|
116
116
|
};
|
|
117
117
|
export declare const colorVars: stylex.VarGroup<Readonly<{
|
|
118
|
-
readonly '--color-accent': "light-dark(#0064E0, #
|
|
118
|
+
readonly '--color-accent': "light-dark(#0064E0, #0171E3)";
|
|
119
119
|
readonly '--color-accent-muted': "light-dark(#0082FB33, #0082FB3F)";
|
|
120
120
|
readonly '--color-on-accent': "light-dark(#FFFFFF, #FFFFFF)";
|
|
121
121
|
readonly '--color-neutral': "light-dark(rgba(5, 54, 89, 0.1), rgba(223, 226, 229, 0.2))";
|
|
@@ -24,7 +24,7 @@ import * as stylex from '@stylexjs/stylex';
|
|
|
24
24
|
|
|
25
25
|
export const colorDefaults = {
|
|
26
26
|
// Core semantic
|
|
27
|
-
'--color-accent': 'light-dark(#0064E0, #
|
|
27
|
+
'--color-accent': 'light-dark(#0064E0, #0171E3)',
|
|
28
28
|
'--color-accent-muted': 'light-dark(#0082FB33, #0082FB3F)',
|
|
29
29
|
'--color-on-accent': 'light-dark(#FFFFFF, #FFFFFF)',
|
|
30
30
|
'--color-neutral': 'light-dark(rgba(5, 54, 89, 0.1), rgba(223, 226, 229, 0.2))',
|
package/dist/utils/flatTree.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file flatTree.ts
|
|
3
3
|
* @input A DOM node
|
|
4
|
-
* @output Exports parentAcrossShadow,
|
|
4
|
+
* @output Exports parentAcrossShadow, containsAlongFlatTree, which walks it,
|
|
5
|
+
* and deepActiveElement
|
|
5
6
|
* @position The flat-tree parent the browser scrolls and dispatches
|
|
6
|
-
* through, shared by the gesture host's native-scroll probe
|
|
7
|
+
* through, shared by the gesture host's native-scroll probe, the
|
|
7
8
|
* selection lock (which the press feedback controller uses without the
|
|
8
|
-
* gesture system)
|
|
9
|
+
* gesture system) and the Layer module's input hold
|
|
9
10
|
*/
|
|
10
11
|
/** The node's parent, crossing out of shadow roots. */
|
|
11
12
|
export declare function parentAcrossShadow(node: Node): Node | null;
|
|
@@ -14,4 +15,6 @@ export declare function parentAcrossShadow(node: Node): Node | null;
|
|
|
14
15
|
* shadow root to its host, which `Node.contains` does not follow.
|
|
15
16
|
*/
|
|
16
17
|
export declare function containsAlongFlatTree(ancestor: Node, node: Node): boolean;
|
|
18
|
+
/** The focused element of `doc`, inside open shadow roots too. */
|
|
19
|
+
export declare function deepActiveElement(doc: Document | null | undefined): Element | null;
|
|
17
20
|
//# sourceMappingURL=flatTree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatTree.d.ts","sourceRoot":"","sources":["../../src/utils/flatTree.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"flatTree.d.ts","sourceRoot":"","sources":["../../src/utils/flatTree.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,uDAAuD;AACvD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAa1D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAOzE;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,GAC/B,OAAO,GAAG,IAAI,CAMhB"}
|
package/dist/utils/flatTree.js
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file flatTree.ts
|
|
5
5
|
* @input A DOM node
|
|
6
|
-
* @output Exports parentAcrossShadow,
|
|
6
|
+
* @output Exports parentAcrossShadow, containsAlongFlatTree, which walks it,
|
|
7
|
+
* and deepActiveElement
|
|
7
8
|
* @position The flat-tree parent the browser scrolls and dispatches
|
|
8
|
-
* through, shared by the gesture host's native-scroll probe
|
|
9
|
+
* through, shared by the gesture host's native-scroll probe, the
|
|
9
10
|
* selection lock (which the press feedback controller uses without the
|
|
10
|
-
* gesture system)
|
|
11
|
+
* gesture system) and the Layer module's input hold
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
/** The node's parent, crossing out of shadow roots. */
|
|
@@ -35,4 +36,13 @@ export function containsAlongFlatTree(ancestor, node) {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The focused element of `doc`, inside open shadow roots too. */
|
|
42
|
+
export function deepActiveElement(doc) {
|
|
43
|
+
let active = doc?.activeElement ?? null;
|
|
44
|
+
while (active?.shadowRoot?.activeElement != null) {
|
|
45
|
+
active = active.shadowRoot.activeElement;
|
|
46
|
+
}
|
|
47
|
+
return active;
|
|
38
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hitArea.d.ts","sourceRoot":"","sources":["../../src/utils/hitArea.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hitArea.d.ts","sourceRoot":"","sources":["../../src/utils/hitArea.ts"],"names":[],"mappings":"AAgCA,+BAA+B;AAC/B,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,mEAAmE;AACnE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,qDAAqD;AACrD,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,6CAA6C;AAC7C,eAAO,MAAM,aAAa,EAAE,SAAkD,CAAC;AAE/E;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;CAKvB,CAAC;AAmCX;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,OAAO,EACf,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,EAClC,OAAO,GAAE,MAAyB,GACjC,SAAS,CA4CX;AAYD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,GAAE,MAAyB,GACjC,MAAM,CAoBR;AAED,gDAAgD;AAChD,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAI5E;AAsjBD,iCAAiC;AACjC,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAW3C;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,EACrC,EAAC,OAA0B,EAAC,GAAE,mBAAwB,GACrD,MAAM,IAAI,CAyDZ"}
|
package/dist/utils/hitArea.js
CHANGED
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
// live control measures: only under a coarse primary pointer (AST-094), only on
|
|
25
25
|
// screen, and in one read pass per frame within a 4 ms budget. Until the first
|
|
26
26
|
// pass the insets are 0, so first paint never overlaps anything.
|
|
27
|
+
// The insets are lengths in the control's own box, so a pass measures in its
|
|
28
|
+
// layout px. A layer that opens from a smaller scale then keeps the insets of
|
|
29
|
+
// the size it settles at.
|
|
27
30
|
import { observeContent } from "./sharedMutationObserver.js";
|
|
28
31
|
|
|
29
32
|
/** A rect in client pixels. */
|
|
@@ -263,6 +266,74 @@ function plainRect(element) {
|
|
|
263
266
|
bottom
|
|
264
267
|
};
|
|
265
268
|
}
|
|
269
|
+
|
|
270
|
+
/** A box that the transforms around it leave at its layout size. */
|
|
271
|
+
const UNSCALED = {
|
|
272
|
+
x: 1,
|
|
273
|
+
y: 1
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/** One axis of a box's scale on screen: its client size over its layout size. */
|
|
277
|
+
function axisScale(onScreen, layout) {
|
|
278
|
+
if (!(layout > 0) || !(onScreen > 0)) {
|
|
279
|
+
return 1;
|
|
280
|
+
}
|
|
281
|
+
const scale = onScreen / layout;
|
|
282
|
+
// Within rounding of 1 the box is at its layout size: no change to the rects.
|
|
283
|
+
return Math.abs(scale - 1) < 1e-3 ? 1 : scale;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* How far the transforms around `element` scale its box on screen, per axis.
|
|
288
|
+
* A layer that opens from a smaller scale scales every rect inside it, while
|
|
289
|
+
* the layout box keeps the size the layer settles at. Only a scale is
|
|
290
|
+
* expected: a rotated or skewed box would read as a larger scale.
|
|
291
|
+
*/
|
|
292
|
+
function screenScale(element, onScreen) {
|
|
293
|
+
// The offset size is the layout size in whole pixels, unaffected by
|
|
294
|
+
// transforms, and costs no style resolution. A box with none, such as an SVG
|
|
295
|
+
// element or a jsdom box, reads as unscaled.
|
|
296
|
+
const box = element;
|
|
297
|
+
const offsetWidth = box.offsetWidth ?? 0;
|
|
298
|
+
const offsetHeight = box.offsetHeight ?? 0;
|
|
299
|
+
if (offsetWidth === 0 || offsetHeight === 0) {
|
|
300
|
+
return UNSCALED;
|
|
301
|
+
}
|
|
302
|
+
// Within a pixel of its layout size the box reads as unscaled, which bounds
|
|
303
|
+
// the inset error at about a pixel. Only a box that a transform shrinks or
|
|
304
|
+
// grows reads its exact size from the computed style.
|
|
305
|
+
if (Math.abs(onScreen.right - onScreen.left - offsetWidth) <= 1 && Math.abs(onScreen.bottom - onScreen.top - offsetHeight) <= 1) {
|
|
306
|
+
return UNSCALED;
|
|
307
|
+
}
|
|
308
|
+
const style = element.ownerDocument.defaultView?.getComputedStyle(element);
|
|
309
|
+
if (style == null || !style.width.endsWith('px')) {
|
|
310
|
+
return UNSCALED;
|
|
311
|
+
}
|
|
312
|
+
const px = value => Number.parseFloat(value) || 0;
|
|
313
|
+
const isContentBox = style.boxSizing !== 'border-box';
|
|
314
|
+
const width = px(style.width) + (isContentBox ? px(style.paddingLeft) + px(style.paddingRight) + px(style.borderLeftWidth) + px(style.borderRightWidth) : 0);
|
|
315
|
+
const height = px(style.height) + (isContentBox ? px(style.paddingTop) + px(style.paddingBottom) + px(style.borderTopWidth) + px(style.borderBottomWidth) : 0);
|
|
316
|
+
return {
|
|
317
|
+
x: axisScale(onScreen.right - onScreen.left, width),
|
|
318
|
+
y: axisScale(onScreen.bottom - onScreen.top, height)
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* `rect` in the layout px of the box at `origin`: its offset from `origin`,
|
|
324
|
+
* divided by that box's scale on screen.
|
|
325
|
+
*/
|
|
326
|
+
function inLayout(rect, origin, scale) {
|
|
327
|
+
if (scale.x === 1 && scale.y === 1) {
|
|
328
|
+
return rect;
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
left: origin.left + (rect.left - origin.left) / scale.x,
|
|
332
|
+
top: origin.top + (rect.top - origin.top) / scale.y,
|
|
333
|
+
right: origin.left + (rect.right - origin.left) / scale.x,
|
|
334
|
+
bottom: origin.top + (rect.bottom - origin.top) / scale.y
|
|
335
|
+
};
|
|
336
|
+
}
|
|
266
337
|
/** The watched element `element` belongs to, if any (itself included). */
|
|
267
338
|
function watchedOwner(element) {
|
|
268
339
|
for (let node = element; node != null; node = node.parentElement) {
|
|
@@ -297,14 +368,15 @@ function readCandidates(doc) {
|
|
|
297
368
|
/** A control's rect and clamped insets, from candidates already read. */
|
|
298
369
|
function measureOne(watch, candidates) {
|
|
299
370
|
const target = plainRect(watch.element);
|
|
371
|
+
const scale = screenScale(watch.element, target);
|
|
300
372
|
// Two targets each growing up to half the minimum reach each other from a
|
|
301
373
|
// minimum apart.
|
|
302
374
|
const reach = Math.max(0, watch.minSize);
|
|
303
375
|
const band = grown(target, {
|
|
304
|
-
top: reach,
|
|
305
|
-
right: reach,
|
|
306
|
-
bottom: reach,
|
|
307
|
-
left: reach
|
|
376
|
+
top: reach * scale.y,
|
|
377
|
+
right: reach * scale.x,
|
|
378
|
+
bottom: reach * scale.y,
|
|
379
|
+
left: reach * scale.x
|
|
308
380
|
});
|
|
309
381
|
const neighbours = candidates.filter(({
|
|
310
382
|
element,
|
|
@@ -314,7 +386,12 @@ function measureOne(watch, candidates) {
|
|
|
314
386
|
}) => rect);
|
|
315
387
|
return {
|
|
316
388
|
target,
|
|
317
|
-
insets
|
|
389
|
+
// The insets are in the control's layout px. The returned rects stay in
|
|
390
|
+
// screen px for a touch's distance checks. A neighbour maps by the
|
|
391
|
+
// control's scale, as if it is in the same layer. A neighbour outside that
|
|
392
|
+
// layer then reads farther away. A touch compares screen distances, so it
|
|
393
|
+
// still counts that neighbour.
|
|
394
|
+
insets: clampedHitInsets(inLayout(target, target, scale), neighbours.map(rect => inLayout(rect, target, scale)), watch.minSize),
|
|
318
395
|
neighbours
|
|
319
396
|
};
|
|
320
397
|
}
|
|
@@ -6,12 +6,25 @@ export interface InputSubscriptionOptions {
|
|
|
6
6
|
* @default false
|
|
7
7
|
*/
|
|
8
8
|
readonly cancels?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The subscriber runs before every subscriber that is not first. When it
|
|
11
|
+
* returns `true`, no later subscriber hears the event.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
readonly first?: boolean;
|
|
9
15
|
}
|
|
10
16
|
/** The events a window's capture phase sees: its own, and the document's. */
|
|
11
17
|
export type InputEventMap = WindowEventMap & DocumentEventMap;
|
|
18
|
+
/**
|
|
19
|
+
* The type of the latest pointer event `view`'s stream delivered: `mouse`,
|
|
20
|
+
* `pen` or `touch`, or `null` before any. The stream hears a pointer event
|
|
21
|
+
* type only while a subscriber listens to it, as press feedback does on any
|
|
22
|
+
* page with a pressable. Reading it adds no listener.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getLastPointerType(view: Window): string | null;
|
|
12
25
|
/**
|
|
13
26
|
* Listen to `type` on `view`'s capture phase through its shared native
|
|
14
27
|
* listener. Returns the unsubscribe; calling it again does nothing.
|
|
15
28
|
*/
|
|
16
|
-
export declare function subscribeInput<K extends keyof InputEventMap>(view: Window, type: K, listener: (event: InputEventMap[K]) =>
|
|
29
|
+
export declare function subscribeInput<K extends keyof InputEventMap>(view: Window, type: K, listener: (event: InputEventMap[K]) => unknown, { cancels, first }?: InputSubscriptionOptions): () => void;
|
|
17
30
|
//# sourceMappingURL=inputStream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputStream.d.ts","sourceRoot":"","sources":["../../src/utils/inputStream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inputStream.d.ts","sourceRoot":"","sources":["../../src/utils/inputStream.ts"],"names":[],"mappings":"AAgDA,0CAA0C;AAC1C,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,6EAA6E;AAC7E,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAM9D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE9D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,aAAa,EAC1D,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,OAAO,EAC9C,EAAC,OAAe,EAAE,KAAa,EAAC,GAAE,wBAA6B,GAC9D,MAAM,IAAI,CA4CZ"}
|