@astryxdesign/core 0.7.7-canary.ae97fa8 → 0.7.7-canary.b377b21
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 +4 -1
- package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/AlertDialog/AlertDialog.js +36 -6
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +22 -3
- package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
- package/dist/BottomSheet/useSheetGestures.js +3 -1
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +17 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +13 -2
- package/dist/ComplexSelector/ComplexSelector.d.ts +4 -1
- package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
- package/dist/ComplexSelector/ComplexSelector.js +14 -4
- package/dist/ContextMenu/ContextMenu.js +2 -2
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +7 -31
- package/dist/Field/Field.js +2 -2
- package/dist/HoverCard/HoverCard.d.ts +4 -3
- package/dist/HoverCard/HoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.d.ts +5 -4
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +17 -31
- package/dist/Icon/Icon.d.ts +5 -1
- package/dist/Icon/Icon.d.ts.map +1 -1
- package/dist/Icon/Icon.js +5 -2
- package/dist/Layer/usePressPin.d.ts +17 -5
- package/dist/Layer/usePressPin.d.ts.map +1 -1
- package/dist/Layer/usePressPin.js +62 -12
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +18 -0
- package/dist/PowerSearch/PowerSearch.d.ts +36 -3
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +433 -127
- package/dist/PowerSearch/PowerSearchBottomSheet.d.ts +100 -0
- package/dist/PowerSearch/PowerSearchBottomSheet.d.ts.map +1 -0
- package/dist/PowerSearch/PowerSearchBottomSheet.js +1913 -0
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts +32 -1
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +17 -6
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts +38 -3
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchValueEditor.js +170 -61
- package/dist/PowerSearch/formatFilterValue.d.ts +7 -0
- package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
- package/dist/PowerSearch/formatFilterValue.js +11 -1
- package/dist/PowerSearch/formatTokenValue.d.ts +28 -0
- package/dist/PowerSearch/formatTokenValue.d.ts.map +1 -0
- package/dist/PowerSearch/formatTokenValue.js +160 -0
- package/dist/PowerSearch/powerSearchSheetUtils.d.ts +65 -0
- package/dist/PowerSearch/powerSearchSheetUtils.d.ts.map +1 -0
- package/dist/PowerSearch/powerSearchSheetUtils.js +168 -0
- package/dist/RadioList/RadioList.d.ts.map +1 -1
- package/dist/RadioList/RadioList.js +3 -2
- package/dist/RadioList/RadioListItem.d.ts +1 -1
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +5 -3
- package/dist/Resizable/ResizeHandle.d.ts +2 -1
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +99 -77
- package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts.map +1 -1
- package/dist/SegmentedControl/useSegmentedSelectionMotion.js +3 -3
- package/dist/Slider/sliderTouchController.js +2 -2
- package/dist/Spinner/Spinner.d.ts +1 -1
- package/dist/Spinner/Spinner.d.ts.map +1 -1
- package/dist/Spinner/Spinner.js +60 -58
- package/dist/Switch/useSwitchTouch.js +4 -4
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +29 -8
- package/dist/TextInput/TextInput.d.ts +2 -2
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +10 -7
- package/dist/Toast/Toast.d.ts +11 -1
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +25 -15
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +94 -34
- package/dist/Toast/types.d.ts +9 -3
- package/dist/Toast/types.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.d.ts +19 -1
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +34 -53
- package/dist/Typeahead/TypeaheadItem.d.ts +2 -1
- package/dist/Typeahead/TypeaheadItem.d.ts.map +1 -1
- package/dist/animator/createAnimator.d.ts +98 -0
- package/dist/animator/createAnimator.d.ts.map +1 -0
- package/dist/animator/createAnimator.js +259 -0
- package/dist/astryx.css +35 -6
- package/dist/gestures/PressTracker.d.ts.map +1 -1
- package/dist/gestures/PressTracker.js +4 -3
- package/dist/hooks/actionGroupTracker.d.ts +4 -1
- package/dist/hooks/actionGroupTracker.d.ts.map +1 -1
- package/dist/hooks/actionGroupTracker.js +13 -3
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/pressGroupContext.d.ts +6 -0
- package/dist/hooks/pressGroupContext.d.ts.map +1 -0
- package/dist/hooks/pressGroupContext.js +20 -0
- package/dist/hooks/useActionGroupTracking.d.ts +53 -0
- package/dist/hooks/useActionGroupTracking.d.ts.map +1 -0
- package/dist/hooks/useActionGroupTracking.js +174 -0
- package/dist/hooks/useAnimator.d.ts +41 -0
- package/dist/hooks/useAnimator.d.ts.map +1 -0
- package/dist/hooks/useAnimator.js +70 -0
- package/dist/hooks/useAttachment.d.ts +1 -1
- package/dist/hooks/useAttachment.js +1 -1
- package/dist/hooks/useInputStatusIcon.d.ts +1 -1
- package/dist/hooks/useInputStatusIcon.d.ts.map +1 -1
- package/dist/hooks/useInputStatusIcon.js +2 -2
- package/dist/hooks/useLongPress.d.ts +6 -2
- package/dist/hooks/useLongPress.d.ts.map +1 -1
- package/dist/hooks/useLongPress.js +95 -15
- package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.d.ts +8 -0
- package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.js +42 -0
- package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.js +6 -0
- package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.d.ts +8 -0
- package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.js +14 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +30 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +30 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/internal/indicatorPress.stylex.d.ts +20 -0
- package/dist/internal/indicatorPress.stylex.d.ts.map +1 -0
- package/dist/internal/indicatorPress.stylex.js +26 -0
- package/dist/motion/animator.d.ts +14 -14
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +41 -18
- package/dist/motion/uikit/alert.d.ts +41 -0
- package/dist/motion/uikit/alert.d.ts.map +1 -0
- package/dist/motion/uikit/alert.js +43 -0
- package/dist/privateAttributes/pressGroupItem.stylex.d.ts +15 -0
- package/dist/privateAttributes/pressGroupItem.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/pressGroupItem.stylex.js +23 -0
- package/dist/utils/focusReturn.d.ts +15 -0
- package/dist/utils/focusReturn.d.ts.map +1 -1
- package/dist/utils/focusReturn.js +28 -0
- package/dist/utils/interactionOverlay.stylex.d.ts +3 -2
- package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
- package/dist/utils/interactionOverlay.stylex.js +3 -2
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +19 -6
- package/dist/utils/triggerFocus.d.ts +36 -0
- package/dist/utils/triggerFocus.d.ts.map +1 -0
- package/dist/utils/triggerFocus.js +65 -0
- package/locales/en.json +120 -0
- package/locales/pseudo.json +90 -0
- package/package.json +9 -4
- package/src/AlertDialog/AlertDialog.doc.mjs +2 -2
- package/src/AlertDialog/AlertDialog.tsx +37 -5
- package/src/BottomSheet/BottomSheetPanel.tsx +33 -3
- package/src/BottomSheet/useSheetGestures.ts +3 -1
- package/src/Button/Button.tsx +26 -4
- package/src/CheckboxInput/CheckboxInput.doc.mjs +18 -0
- package/src/CheckboxInput/CheckboxInput.tsx +36 -9
- package/src/ComplexSelector/ComplexSelector.tsx +20 -5
- package/src/ContextMenu/ContextMenu.tsx +2 -2
- package/src/Dialog/Dialog.tsx +10 -31
- package/src/Field/Field.tsx +2 -2
- package/src/HoverCard/HoverCard.doc.mjs +4 -2
- package/src/HoverCard/HoverCard.tsx +4 -3
- package/src/HoverCard/useHoverCard.doc.mjs +178 -36
- package/src/HoverCard/useHoverCard.tsx +46 -52
- package/src/Icon/Icon.doc.mjs +49 -8
- package/src/Icon/Icon.tsx +15 -7
- package/src/Layer/usePressPin.ts +81 -15
- package/src/Lightbox/Lightbox.tsx +18 -0
- package/src/PowerSearch/PowerSearch.doc.mjs +54 -5
- package/src/PowerSearch/PowerSearch.tsx +609 -155
- package/src/PowerSearch/PowerSearchBottomSheet.tsx +2515 -0
- package/src/PowerSearch/PowerSearchEditPopover.tsx +28 -6
- package/src/PowerSearch/PowerSearchValueEditor.tsx +203 -38
- package/src/PowerSearch/formatFilterValue.ts +18 -1
- package/src/PowerSearch/formatTokenValue.ts +215 -0
- package/src/PowerSearch/powerSearchSheetUtils.ts +224 -0
- package/src/RadioList/RadioList.tsx +3 -2
- package/src/RadioList/RadioListItem.tsx +5 -3
- package/src/Resizable/Resizable.doc.mjs +5 -4
- package/src/Resizable/ResizeHandle.tsx +167 -109
- package/src/SegmentedControl/useSegmentedSelectionMotion.ts +6 -3
- package/src/Slider/sliderTouchController.ts +2 -2
- package/src/Spinner/Spinner.tsx +77 -63
- package/src/Switch/useSwitchTouch.ts +4 -4
- package/src/Table/BaseTable.tsx +46 -12
- package/src/TextInput/TextInput.tsx +11 -10
- package/src/Toast/Toast.doc.mjs +4 -3
- package/src/Toast/Toast.tsx +52 -32
- package/src/Toast/ToastViewport.tsx +121 -35
- package/src/Toast/types.ts +9 -3
- package/src/Tooltip/useTooltip.doc.mjs +24 -0
- package/src/Tooltip/useTooltip.tsx +61 -56
- package/src/Typeahead/TypeaheadItem.doc.mjs +6 -3
- package/src/Typeahead/TypeaheadItem.tsx +2 -1
- package/src/animator/createAnimator.doc.mjs +153 -0
- package/src/animator/createAnimator.ts +324 -0
- package/src/gestures/PressTracker.ts +4 -3
- package/src/gestures/README.md +7 -1
- package/src/hooks/actionGroupTracker.ts +20 -5
- package/src/hooks/index.ts +2 -0
- package/src/hooks/pressGroupContext.ts +21 -0
- package/src/hooks/useActionGroupTracking.ts +224 -0
- package/src/hooks/useAnimator.doc.mjs +109 -0
- package/src/hooks/useAnimator.ts +67 -0
- package/src/hooks/useAttachment.ts +1 -1
- package/src/hooks/useInputStatusIcon.tsx +3 -2
- package/src/hooks/useLongPress.doc.mjs +2 -2
- package/src/hooks/useLongPress.ts +136 -15
- package/src/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.ts +43 -0
- package/src/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.ts +6 -0
- package/src/i18n/generated-english/PowerSearch/formatTokenValue.generated.ts +15 -0
- package/src/i18n/generated-locales/en.generated.ts +41 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +42 -0
- package/src/index.ts +13 -0
- package/src/internal/indicatorPress.stylex.ts +24 -0
- package/src/motion/README.md +8 -5
- package/src/motion/animator.ts +61 -29
- package/src/motion/uikit/alert.ts +43 -0
- package/src/privateAttributes/pressGroupItem.stylex.ts +23 -0
- package/src/utils/focusReturn.ts +30 -0
- package/src/utils/interactionOverlay.stylex.ts +3 -2
- package/src/utils/pressFeedback.ts +19 -6
- package/src/utils/triggerFocus.ts +80 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file indicatorPress.stylex.ts
|
|
5
|
+
* @input Uses StyleX
|
|
6
|
+
* @output Exports `indicatorPressScope`, the marker of a first-party
|
|
7
|
+
* indicator that paints its own press
|
|
8
|
+
* @position Internal entry for Astryx's own replacement indicators;
|
|
9
|
+
* CheckboxInput reads it
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import * as stylex from '@stylexjs/stylex';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Marks a first-party replacement indicator that paints its own press, for
|
|
16
|
+
* a shape that CheckboxInput's rounded-square press layer would tint past,
|
|
17
|
+
* such as a circle. CheckboxInput leaves that layer off over an indicator
|
|
18
|
+
* with this marker.
|
|
19
|
+
*
|
|
20
|
+
* @internal Not public API: the touch press reaches the indicator through a
|
|
21
|
+
* private property.
|
|
22
|
+
*/
|
|
23
|
+
export const indicatorPressScope = {
|
|
24
|
+
x1lrrceh: "x1lrrceh",
|
|
25
|
+
$$css: true
|
|
26
|
+
};
|
|
@@ -50,18 +50,18 @@ export interface AnimateOptions {
|
|
|
50
50
|
crossfadeAs?: 'entrance' | 'exit';
|
|
51
51
|
/**
|
|
52
52
|
* When the call's animations start. By default a call from rest starts
|
|
53
|
-
* when the browser commits it
|
|
54
|
-
*
|
|
53
|
+
* when the browser commits it. A call that continues motion on screen (a
|
|
54
|
+
* retarget) starts now, from the value on screen. A curve whose tail
|
|
55
|
+
* already shows as at rest counts as rest. Ignored with `at`.
|
|
55
56
|
* - `'commit'`: a call that continues motion also starts when the browser
|
|
56
|
-
* commits it
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* continues motion on screen (a retarget) starts now, as by default.
|
|
57
|
+
* commits it. The browser dates it, as it dates a call from rest.
|
|
58
|
+
* - `'presented'`: a call from rest leaves its element at rest. Its
|
|
59
|
+
* animations are created two frames later, once the frame with the
|
|
60
|
+
* element at rest has been presented. They then start at their commit,
|
|
61
|
+
* so a busy UI process delays the motion instead of skipping into it.
|
|
62
|
+
* Any other change to the animator before then creates the animations
|
|
63
|
+
* first, in call order. A call that continues motion on screen starts
|
|
64
|
+
* now, as by default.
|
|
65
65
|
*/
|
|
66
66
|
start?: 'commit' | 'presented';
|
|
67
67
|
/**
|
|
@@ -101,7 +101,7 @@ export interface MotionCurve {
|
|
|
101
101
|
readonly isTransition?: boolean;
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
-
* Options of `
|
|
104
|
+
* Options of `createMotionAnimator`.
|
|
105
105
|
*/
|
|
106
106
|
/** How `set` puts values in place. */
|
|
107
107
|
export interface SetOptions {
|
|
@@ -302,7 +302,7 @@ export declare function defaultIsCoarsePointer(): boolean;
|
|
|
302
302
|
*
|
|
303
303
|
* @example
|
|
304
304
|
* ```
|
|
305
|
-
* const animator =
|
|
305
|
+
* const animator = createMotionAnimator(sheet);
|
|
306
306
|
* // finger lifts at 1200 px/s heading for the detent at 0 (a component
|
|
307
307
|
* // passes the spring of its motion role):
|
|
308
308
|
* animator.animate({y: 0}, {spring: {response: 0.45, dampingRatio: 0.9}, velocity: {y: 1200}});
|
|
@@ -311,5 +311,5 @@ export declare function defaultIsCoarsePointer(): boolean;
|
|
|
311
311
|
* animator.stop(['y']);
|
|
312
312
|
* ```
|
|
313
313
|
*/
|
|
314
|
-
export declare function
|
|
314
|
+
export declare function createMotionAnimator(element: HTMLElement | null, options?: AnimatorOptions): Animator;
|
|
315
315
|
//# sourceMappingURL=animator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animator.d.ts","sourceRoot":"","sources":["../../src/motion/animator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"animator.d.ts","sourceRoot":"","sources":["../../src/motion/animator.ts"],"names":[],"mappings":"AAuLA,OAAO,EAAwB,KAAK,iBAAiB,EAAC,MAAM,UAAU,CAAC;AASvE;;GAEG;AACH,MAAM,MAAM,cAAc,GACxB,GAAG,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,MAAM,EAAE,iBAAiB,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAClC;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;IAC/B;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;GAMG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E,WAAW,CAAC,CAAC,EAC/C,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,GAAG,cAAc,CAAC,GACpD,YAAY,CAAC;IAChB;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;IACzE,wEAAwE;IACxE,IAAI,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,cAAc,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC;IACjE;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,cAAc,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,uCAAuC;IACvC,OAAO,IAAI,IAAI,CAAC;CACjB;AAoKD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,CAO3D,CAAC;AAiFF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,WAAW,QAAS,CAAC;AAalC,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,MAAM,CAAC;AA6CvC;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,eAAoB,GAC5B,QAAQ,CAaV;AAyED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAMrD;AAED,kEAAkE;AAClE,wBAAgB,sBAAsB,IAAI,OAAO,CAMhD;AAWD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,OAAO,GAAE,eAAoB,GAC5B,QAAQ,CAq+FV"}
|
package/dist/motion/animator.js
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* @file animator.ts
|
|
5
5
|
* @input An element, target values, and a spring, momentum curves (coast.ts)
|
|
6
6
|
* or any closed-form curve
|
|
7
|
-
* @output Exports `
|
|
8
|
-
* rotate, scale and opacity,
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* @output Exports `createMotionAnimator`, a compositor animator for
|
|
8
|
+
* translate, rotate, scale and opacity, and its option, handle and
|
|
9
|
+
* transition types. It reads presentation values and velocities from the
|
|
10
|
+
* analytic curves. It retargets with the velocity kept, freezes in place on
|
|
11
|
+
* `stop`, and gives completion promises, a shared clock, and UIKit's
|
|
12
|
+
* Reduced Motion substitution.
|
|
12
13
|
* @position Motion foundation (DOM). Internal to core: components use it for
|
|
13
14
|
* every touch-presentation animation; not exported from the package entry
|
|
14
15
|
*
|
|
@@ -212,7 +213,7 @@ import { planReducedMotion } from "./reducedMotionPlan.js";
|
|
|
212
213
|
*/
|
|
213
214
|
|
|
214
215
|
/**
|
|
215
|
-
* Options of `
|
|
216
|
+
* Options of `createMotionAnimator`.
|
|
216
217
|
*/
|
|
217
218
|
/** How `set` puts values in place. */
|
|
218
219
|
|
|
@@ -292,6 +293,18 @@ const SAMPLE_TOLERANCE = {
|
|
|
292
293
|
/** Keyframes start on this grid (ms) and are split where the curve needs it. */
|
|
293
294
|
const SAMPLE_GRID_MS = 1000 / 30;
|
|
294
295
|
|
|
296
|
+
/**
|
|
297
|
+
* A curve within this many sample tolerances of its target can show as at
|
|
298
|
+
* rest. A call on it then starts as one from rest does, at the browser's start.
|
|
299
|
+
*/
|
|
300
|
+
const REST_DISTANCE_TOLERANCES = 2;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* A curve shows as at rest only while it moves at most one `SAMPLE_TOLERANCE`
|
|
304
|
+
* a frame at this rate.
|
|
305
|
+
*/
|
|
306
|
+
const REST_FRAMES_PER_SECOND = 60;
|
|
307
|
+
|
|
295
308
|
/** A curve that has not settled by then (an undamped spring) snaps. */
|
|
296
309
|
const MAX_DURATION_MS = 30_000;
|
|
297
310
|
|
|
@@ -420,7 +433,7 @@ export function animatorFor(element, options = {}) {
|
|
|
420
433
|
const key = options.pseudoElement ?? '';
|
|
421
434
|
let animator = byPseudo.get(key);
|
|
422
435
|
if (animator == null) {
|
|
423
|
-
animator =
|
|
436
|
+
animator = createMotionAnimator(element, options);
|
|
424
437
|
byPseudo.set(key, animator);
|
|
425
438
|
}
|
|
426
439
|
return animator;
|
|
@@ -524,7 +537,7 @@ const REDUCED_TRANSITION = {
|
|
|
524
537
|
*
|
|
525
538
|
* @example
|
|
526
539
|
* ```
|
|
527
|
-
* const animator =
|
|
540
|
+
* const animator = createMotionAnimator(sheet);
|
|
528
541
|
* // finger lifts at 1200 px/s heading for the detent at 0 (a component
|
|
529
542
|
* // passes the spring of its motion role):
|
|
530
543
|
* animator.animate({y: 0}, {spring: {response: 0.45, dampingRatio: 0.9}, velocity: {y: 1200}});
|
|
@@ -533,7 +546,7 @@ const REDUCED_TRANSITION = {
|
|
|
533
546
|
* animator.stop(['y']);
|
|
534
547
|
* ```
|
|
535
548
|
*/
|
|
536
|
-
export function
|
|
549
|
+
export function createMotionAnimator(element, options = {}) {
|
|
537
550
|
const now = options.now ?? defaultNow;
|
|
538
551
|
const frameSource = options.requestFrame ?? (typeof requestAnimationFrame === 'function' ? callback => {
|
|
539
552
|
requestAnimationFrame(() => callback());
|
|
@@ -737,6 +750,14 @@ export function createAnimator(element, options = {}) {
|
|
|
737
750
|
}
|
|
738
751
|
return curveAt(property, time);
|
|
739
752
|
};
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Whether a curve's tail already shows as at rest at `time`. Under a
|
|
756
|
+
* starved main thread the browser commits a call late. A call that starts
|
|
757
|
+
* at its own time then skips that far into its curve. One that starts at
|
|
758
|
+
* the commit holds an element that hardly moves.
|
|
759
|
+
*/
|
|
760
|
+
const showsAtRest = (property, segment, time) => Math.abs(valueAt(property, time) - segment.target) <= REST_DISTANCE_TOLERANCES * SAMPLE_TOLERANCE[property] && Math.abs(velocityAt(property, time)) <= SAMPLE_TOLERANCE[property] * REST_FRAMES_PER_SECOND;
|
|
740
761
|
const velocityAt = (property, time) => {
|
|
741
762
|
const held = segments.get(property);
|
|
742
763
|
if (held != null && isHeld(held)) {
|
|
@@ -1506,10 +1527,10 @@ export function createAnimator(element, options = {}) {
|
|
|
1506
1527
|
// -- starting from rest ---------------------------------------------------
|
|
1507
1528
|
|
|
1508
1529
|
/**
|
|
1509
|
-
* A call starts from rest when nothing on the channels it drives
|
|
1510
|
-
*
|
|
1511
|
-
*
|
|
1512
|
-
* start.
|
|
1530
|
+
* A call starts from rest when nothing on the channels it drives moves on
|
|
1531
|
+
* screen and nothing pins its clock (`at`). A curve still waiting for its
|
|
1532
|
+
* first frame counts as rest, as does one whose tail already shows as at
|
|
1533
|
+
* rest. Returns its start group, or null for an explicit start.
|
|
1513
1534
|
*/
|
|
1514
1535
|
const beginGroup = (time, properties, at, start) => {
|
|
1515
1536
|
if (target == null || typeof target.animate !== 'function') {
|
|
@@ -1538,16 +1559,18 @@ export function createAnimator(element, options = {}) {
|
|
|
1538
1559
|
}
|
|
1539
1560
|
return null;
|
|
1540
1561
|
}
|
|
1541
|
-
// A call that continues motion starts now unless it asks for the
|
|
1542
|
-
// browser's start (`commit`). `presented` asks only for a call from rest
|
|
1543
|
-
//
|
|
1544
|
-
// the value and velocity on screen
|
|
1562
|
+
// A call that continues motion starts now, unless it asks for the
|
|
1563
|
+
// browser's start (`commit`). `presented` asks only for a call from rest.
|
|
1564
|
+
// A curve that still moves is not at rest, so a call on it starts now,
|
|
1565
|
+
// from the value and velocity on screen. A tail that shows as at rest
|
|
1566
|
+
// counts as rest, so a call on it waits, under `presented` for its two
|
|
1567
|
+
// frames.
|
|
1545
1568
|
for (const channel of start === 'commit' ? [] : channels) {
|
|
1546
1569
|
for (const property of CHANNELS[channel]) {
|
|
1547
1570
|
const segment = segments.get(property);
|
|
1548
1571
|
// A call's first frame puts its channels on screen, even before the
|
|
1549
1572
|
// browser reports the start. So such a channel is not at rest either.
|
|
1550
|
-
if (segment != null && time < endOf(property, segment) && (segment.group == null || segment.group.resolved || shownSince(property, segment) != null)) {
|
|
1573
|
+
if (segment != null && time < endOf(property, segment) && (segment.group == null || segment.group.resolved || shownSince(property, segment) != null) && !showsAtRest(property, segment, time)) {
|
|
1551
1574
|
return null;
|
|
1552
1575
|
}
|
|
1553
1576
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file alert.ts
|
|
3
|
+
* @input Nothing; data only
|
|
4
|
+
* @output Exports `alertController`: how UIAlertController (`.alert`) tracks
|
|
5
|
+
* a finger across its actions
|
|
6
|
+
* @position The alert domain of the UIKit constants table (motion/uikit);
|
|
7
|
+
* its springs are `springs.alertPresent` and `springs.alertDismiss`
|
|
8
|
+
*
|
|
9
|
+
* Every value was read from UIKit on the iOS 26.2 simulator. A host app
|
|
10
|
+
* presented `UIAlertController(.alert)` with two and with three actions.
|
|
11
|
+
* Real HID touches drove it, and the action views' highlight was sampled
|
|
12
|
+
* every frame. Lengths are in pt (CSS px), durations in ms.
|
|
13
|
+
*
|
|
14
|
+
* Every leaf carries one or more `@source`; GUESS values also carry the
|
|
15
|
+
* `@measure` task that will confirm or replace them. uikit.test.ts enforces
|
|
16
|
+
* both.
|
|
17
|
+
*
|
|
18
|
+
* SYNC: When modified, update /packages/core/src/motion/MEASUREMENTS.md
|
|
19
|
+
*/
|
|
20
|
+
export declare const alertController: {
|
|
21
|
+
readonly actions: {
|
|
22
|
+
/**
|
|
23
|
+
* How long after touch-down the touched action highlights: none, it is
|
|
24
|
+
* highlighted in the touch-down frame (a tap and a 300 ms hold alike).
|
|
25
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
26
|
+
* iPhone 17 Pro, per-frame highlight of the action views under real HID
|
|
27
|
+
* touches, Oct 23 2026
|
|
28
|
+
*/
|
|
29
|
+
readonly highlightOnsetMs: 0;
|
|
30
|
+
/**
|
|
31
|
+
* How far outside an action the finger may go and keep it highlighted:
|
|
32
|
+
* none. The highlight cleared 1 pt below the action, and a lift there ran
|
|
33
|
+
* nothing. UIButton keeps 70 pt; an alert action does not.
|
|
34
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
35
|
+
* iPhone 17 Pro, per-frame highlight of the action views under real HID
|
|
36
|
+
* touches, Oct 23 2026
|
|
37
|
+
*/
|
|
38
|
+
readonly highlightExpansion: 0;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=alert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../../src/motion/uikit/alert.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,eAAO,MAAM,eAAe;;QAExB;;;;;;WAMG;;QAEH;;;;;;;WAOG;;;CAGG,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file alert.ts
|
|
5
|
+
* @input Nothing; data only
|
|
6
|
+
* @output Exports `alertController`: how UIAlertController (`.alert`) tracks
|
|
7
|
+
* a finger across its actions
|
|
8
|
+
* @position The alert domain of the UIKit constants table (motion/uikit);
|
|
9
|
+
* its springs are `springs.alertPresent` and `springs.alertDismiss`
|
|
10
|
+
*
|
|
11
|
+
* Every value was read from UIKit on the iOS 26.2 simulator. A host app
|
|
12
|
+
* presented `UIAlertController(.alert)` with two and with three actions.
|
|
13
|
+
* Real HID touches drove it, and the action views' highlight was sampled
|
|
14
|
+
* every frame. Lengths are in pt (CSS px), durations in ms.
|
|
15
|
+
*
|
|
16
|
+
* Every leaf carries one or more `@source`; GUESS values also carry the
|
|
17
|
+
* `@measure` task that will confirm or replace them. uikit.test.ts enforces
|
|
18
|
+
* both.
|
|
19
|
+
*
|
|
20
|
+
* SYNC: When modified, update /packages/core/src/motion/MEASUREMENTS.md
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
export const alertController = {
|
|
24
|
+
actions: {
|
|
25
|
+
/**
|
|
26
|
+
* How long after touch-down the touched action highlights: none, it is
|
|
27
|
+
* highlighted in the touch-down frame (a tap and a 300 ms hold alike).
|
|
28
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
29
|
+
* iPhone 17 Pro, per-frame highlight of the action views under real HID
|
|
30
|
+
* touches, Oct 23 2026
|
|
31
|
+
*/
|
|
32
|
+
highlightOnsetMs: 0,
|
|
33
|
+
/**
|
|
34
|
+
* How far outside an action the finger may go and keep it highlighted:
|
|
35
|
+
* none. The highlight cleared 1 pt below the action, and a lift there ran
|
|
36
|
+
* nothing. UIButton keeps 70 pt; an alert action does not.
|
|
37
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
38
|
+
* iPhone 17 Pro, per-frame highlight of the action views under real HID
|
|
39
|
+
* touches, Oct 23 2026
|
|
40
|
+
*/
|
|
41
|
+
highlightExpansion: 0
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file privateAttributes/pressGroupItem.stylex.ts
|
|
3
|
+
* @input Nothing: the private press-group-item attribute
|
|
4
|
+
* @output pressGroupItemProps, which marks an action a group's tracker
|
|
5
|
+
* follows, and isTrackedByGroup, which reads the mark
|
|
6
|
+
* @position Owner module of the private press-group-item attribute: the only
|
|
7
|
+
* file that writes its name. AlertDialog marks its actions, and the press
|
|
8
|
+
* controller (utils/pressFeedback.ts) leaves their press to the group's
|
|
9
|
+
* tracker. No package entry exports it.
|
|
10
|
+
*/
|
|
11
|
+
/** Spread on each action that a group's tracker follows. */
|
|
12
|
+
export declare const pressGroupItemProps: Readonly<Record<string, string>>;
|
|
13
|
+
/** Whether a group's tracker paints the press on `element` or an ancestor. */
|
|
14
|
+
export declare function isTrackedByGroup(element: Element): boolean;
|
|
15
|
+
//# sourceMappingURL=pressGroupItem.stylex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pressGroupItem.stylex.d.ts","sourceRoot":"","sources":["../../src/privateAttributes/pressGroupItem.stylex.ts"],"names":[],"mappings":"AACA;;;;;;;;;GASG;AAIH,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEhE,CAAC;AAEF,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAE1D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
/**
|
|
3
|
+
* @file privateAttributes/pressGroupItem.stylex.ts
|
|
4
|
+
* @input Nothing: the private press-group-item attribute
|
|
5
|
+
* @output pressGroupItemProps, which marks an action a group's tracker
|
|
6
|
+
* follows, and isTrackedByGroup, which reads the mark
|
|
7
|
+
* @position Owner module of the private press-group-item attribute: the only
|
|
8
|
+
* file that writes its name. AlertDialog marks its actions, and the press
|
|
9
|
+
* controller (utils/pressFeedback.ts) leaves their press to the group's
|
|
10
|
+
* tracker. No package entry exports it.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const PRESS_GROUP_ITEM = 'data-astryx-press-group-item';
|
|
14
|
+
|
|
15
|
+
/** Spread on each action that a group's tracker follows. */
|
|
16
|
+
export const pressGroupItemProps = {
|
|
17
|
+
[PRESS_GROUP_ITEM]: ''
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Whether a group's tracker paints the press on `element` or an ancestor. */
|
|
21
|
+
export function isTrackedByGroup(element) {
|
|
22
|
+
return element.closest(`[${PRESS_GROUP_ITEM}]`) != null;
|
|
23
|
+
}
|
|
@@ -75,4 +75,19 @@ export declare function moveFocusLeftBehind(note: FocusWithin | null, target: HT
|
|
|
75
75
|
* in the component that calls this.
|
|
76
76
|
*/
|
|
77
77
|
export declare function focusForLastInput(element: HTMLElement, options?: FocusOptions, modality?: InteractionModality): void;
|
|
78
|
+
/**
|
|
79
|
+
* Prepares the focus return for an open surface that may be removed while
|
|
80
|
+
* open (rendered only while open, or removed with its view). Removing a
|
|
81
|
+
* `<dialog>` runs no close and no browser focus return. Call this while the
|
|
82
|
+
* surface is mounted: it reads the frame that hosts the surface now, because a
|
|
83
|
+
* removed frame's document has no window. Call the returned function from the
|
|
84
|
+
* effect cleanup with the opener.
|
|
85
|
+
*
|
|
86
|
+
* Once the commit has finished, focus moves to the opener only when the
|
|
87
|
+
* surface really left the document (StrictMode's simulated unmount keeps it),
|
|
88
|
+
* the opener is still on the page, and the removal lost focus, both in the
|
|
89
|
+
* surface's document and in the document that hosts its frame. A control the
|
|
90
|
+
* user pressed outside the surface, or outside its frame, keeps its focus.
|
|
91
|
+
*/
|
|
92
|
+
export declare function prepareFocusReturnOnRemoval(surface: Element): (opener: Element | null) => void;
|
|
78
93
|
//# sourceMappingURL=focusReturn.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusReturn.d.ts","sourceRoot":"","sources":["../../src/utils/focusReturn.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,QAAmB,GAAG,OAAO,CAKjE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,OAAO,CAM5E;AAED,mFAAmF;AACnF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;CACjC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,WAAW,GAAG,IAAI,GA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iBAAiB,CAC/B,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,YAAY,EACtB,QAAQ,GAAE,mBAAqD,GAC9D,IAAI,CA2BN;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,OAAO,GACf,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAYlC"}
|
|
@@ -126,4 +126,32 @@ export function focusForLastInput(element, options, modality = getInteractionMod
|
|
|
126
126
|
...options,
|
|
127
127
|
focusVisible: false
|
|
128
128
|
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Prepares the focus return for an open surface that may be removed while
|
|
133
|
+
* open (rendered only while open, or removed with its view). Removing a
|
|
134
|
+
* `<dialog>` runs no close and no browser focus return. Call this while the
|
|
135
|
+
* surface is mounted: it reads the frame that hosts the surface now, because a
|
|
136
|
+
* removed frame's document has no window. Call the returned function from the
|
|
137
|
+
* effect cleanup with the opener.
|
|
138
|
+
*
|
|
139
|
+
* Once the commit has finished, focus moves to the opener only when the
|
|
140
|
+
* surface really left the document (StrictMode's simulated unmount keeps it),
|
|
141
|
+
* the opener is still on the page, and the removal lost focus, both in the
|
|
142
|
+
* surface's document and in the document that hosts its frame. A control the
|
|
143
|
+
* user pressed outside the surface, or outside its frame, keeps its focus.
|
|
144
|
+
*/
|
|
145
|
+
export function prepareFocusReturnOnRemoval(surface) {
|
|
146
|
+
const host = surface.ownerDocument.defaultView?.frameElement ?? null;
|
|
147
|
+
return opener => {
|
|
148
|
+
queueMicrotask(() => {
|
|
149
|
+
if (surface.isConnected || opener == null || !opener.isConnected) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (isFocusLost(surface) && (host == null || isFocusLost(host))) {
|
|
153
|
+
focusForLastInput(opener);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
};
|
|
129
157
|
}
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* SYNC: When modified, update pressFeedback.ts, pressGesture.ts (the fade
|
|
10
10
|
* clock), hooks/usePressFeedback.doc.mjs, the components that paint the touch
|
|
11
11
|
* press off an ancestor scope or a pseudo-element (Switch, Tab,
|
|
12
|
-
* CheckboxInput, RadioListItem, ClickableCard, SelectableCard, Thumbnail)
|
|
13
|
-
* and
|
|
12
|
+
* CheckboxInput, RadioListItem, ClickableCard, SelectableCard, Thumbnail),
|
|
13
|
+
* Button (a tracked action sizes its `:active` image to zero) and
|
|
14
|
+
* scripts/build-css.test.mjs.
|
|
14
15
|
*/
|
|
15
16
|
import * as stylex from '@stylexjs/stylex';
|
|
16
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactionOverlay.stylex.d.ts","sourceRoot":"","sources":["../../src/utils/interactionOverlay.stylex.ts"],"names":[],"mappings":"AAMA
|
|
1
|
+
{"version":3,"file":"interactionOverlay.stylex.d.ts","sourceRoot":"","sources":["../../src/utils/interactionOverlay.stylex.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;GAcG;AAmCH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAG3C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS;;WAEpB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW;IACtB,iEAAiE;;CAEjE,CAAC;AA8HH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8HnC,CAAC"}
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
* SYNC: When modified, update pressFeedback.ts, pressGesture.ts (the fade
|
|
16
16
|
* clock), hooks/usePressFeedback.doc.mjs, the components that paint the touch
|
|
17
17
|
* press off an ancestor scope or a pseudo-element (Switch, Tab,
|
|
18
|
-
* CheckboxInput, RadioListItem, ClickableCard, SelectableCard, Thumbnail)
|
|
19
|
-
* and
|
|
18
|
+
* CheckboxInput, RadioListItem, ClickableCard, SelectableCard, Thumbnail),
|
|
19
|
+
* Button (a tracked action sizes its `:active` image to zero) and
|
|
20
|
+
* scripts/build-css.test.mjs.
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
23
|
// Every surface that paints a press uses one of these styles, so a change to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pressFeedback.d.ts","sourceRoot":"","sources":["../../src/utils/pressFeedback.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pressFeedback.d.ts","sourceRoot":"","sources":["../../src/utils/pressFeedback.ts"],"names":[],"mappings":"AAkDA;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,qDAAqD;AACrD,eAAO,MAAM,cAAc,EAAE;IAAC,QAAQ,CAAC,CAAC,mBAAmB,CAAC,EAAE,EAAE,CAAA;CAE/D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAwoB5C;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,IAAI,CA0BjD"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file pressFeedback.ts
|
|
5
|
-
* @input The press state machine (pressGesture.ts), the menu-press
|
|
6
|
-
*
|
|
5
|
+
* @input The press state machine (pressGesture.ts), the menu-press and
|
|
6
|
+
* press-group markers and the document's pointer, keyboard, scroll and
|
|
7
7
|
* visibility events
|
|
8
8
|
* @output PRESSABLE_ATTRIBUTE, PRESSED_ATTRIBUTE, pressableProps and
|
|
9
9
|
* installPressFeedback
|
|
@@ -38,6 +38,7 @@ import { isCoarsePointer, watchCoarsePointer } from "./coarsePointer.js";
|
|
|
38
38
|
import { subscribeInput } from "./inputStream.js";
|
|
39
39
|
import { TOUCH_QUERY } from "./touchPresentation.js";
|
|
40
40
|
import { holdsPressThroughDrag } from "../privateAttributes/pressHoldsDrag.stylex.js";
|
|
41
|
+
import { isTrackedByGroup } from "../privateAttributes/pressGroupItem.stylex.js";
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* The marker the controller finds with `closest()`. Every Astryx component
|
|
@@ -288,14 +289,19 @@ function stylesheetDroppedActive() {
|
|
|
288
289
|
|
|
289
290
|
/**
|
|
290
291
|
* The surface a mouse button's or the Space key's press paints, if any: the
|
|
291
|
-
* innermost marked surface, outside a menu. A key's
|
|
292
|
-
* focused element that is itself the surface, as
|
|
292
|
+
* innermost marked surface, outside a menu and off a tracked action. A key's
|
|
293
|
+
* press paints only a focused element that is itself the surface, as
|
|
294
|
+
* `:active` does.
|
|
293
295
|
*/
|
|
294
296
|
function buttonSurfaceAt(target, pointerId) {
|
|
295
297
|
const element = surfaceAt(target);
|
|
296
298
|
if (element == null || element.closest(MENU_PRESS_ROOT) != null) {
|
|
297
299
|
return null;
|
|
298
300
|
}
|
|
301
|
+
// A group's tracker follows pointers only, so a key's press stays here.
|
|
302
|
+
if (pointerId != null && isTrackedByGroup(element)) {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
299
305
|
if (pointerId == null && element !== target) {
|
|
300
306
|
return null;
|
|
301
307
|
}
|
|
@@ -379,7 +385,9 @@ function onPointerDown(event) {
|
|
|
379
385
|
const braking = element != null && scrollerIsBraking(element);
|
|
380
386
|
lastTouchAt = Date.now();
|
|
381
387
|
lastTouchTarget = event.target instanceof Node ? event.target : null;
|
|
382
|
-
|
|
388
|
+
// A group's tracker paints a tracked action, so two writers would erase each
|
|
389
|
+
// other's paint. The touch still counts for the brake above.
|
|
390
|
+
if (element == null || braking || isTrackedByGroup(element)) {
|
|
383
391
|
return;
|
|
384
392
|
}
|
|
385
393
|
takeOver(button, element);
|
|
@@ -509,6 +517,11 @@ function activatesOnSpace(target) {
|
|
|
509
517
|
return target instanceof HTMLInputElement && SPACE_ACTIVATED_INPUT_TYPES.has(target.type);
|
|
510
518
|
}
|
|
511
519
|
|
|
520
|
+
/** A tracked action takes no `:active` paint, so a key's press paints here. */
|
|
521
|
+
function isTrackedAction(target) {
|
|
522
|
+
return target instanceof Element && isTrackedByGroup(target);
|
|
523
|
+
}
|
|
524
|
+
|
|
512
525
|
/**
|
|
513
526
|
* Space went down on a focused button that is itself a pressable surface.
|
|
514
527
|
* Heard in the BUBBLE phase, after the page's own handlers, so a press the
|
|
@@ -516,7 +529,7 @@ function activatesOnSpace(target) {
|
|
|
516
529
|
* not engage for one.
|
|
517
530
|
*/
|
|
518
531
|
function onKeyDown(event) {
|
|
519
|
-
if (event.key !== ' ' || event.repeat || event.isComposing || event.defaultPrevented || !activatesOnSpace(event.target) || !stylesheetDroppedActive()) {
|
|
532
|
+
if (event.key !== ' ' || event.repeat || event.isComposing || event.defaultPrevented || !activatesOnSpace(event.target) || !(stylesheetDroppedActive() || isTrackedAction(event.target))) {
|
|
520
533
|
return;
|
|
521
534
|
}
|
|
522
535
|
pressButton(event.target, null);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file triggerFocus.ts
|
|
3
|
+
* @input A focus event on a hover-layer trigger and its focusTrigger value
|
|
4
|
+
* @output Whether that focus counts as focus on the trigger, and a gate that
|
|
5
|
+
* remembers it for the matching blur
|
|
6
|
+
* @position Shared focus-trigger judgement for Tooltip and HoverCard
|
|
7
|
+
*/
|
|
8
|
+
/** When focus on a trigger opens its layer. */
|
|
9
|
+
export type TriggerFocusMode = 'auto' | 'always' | 'never';
|
|
10
|
+
/** Whether `element` is in the tab order or naturally focusable. */
|
|
11
|
+
export declare function isFocusableTrigger(element: HTMLElement): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether a focus event on a trigger (its `currentTarget`) counts as focus on
|
|
14
|
+
* the trigger.
|
|
15
|
+
*
|
|
16
|
+
* Under `auto` it is decided when focus arrives, not when listeners attach: a
|
|
17
|
+
* roving-tabindex member that was `tabindex="-1"` then can be the tab stop
|
|
18
|
+
* now. A trigger that receives focus is focusable by definition, which covers
|
|
19
|
+
* focusable elements this check does not list, such as a `<summary>` or an SVG
|
|
20
|
+
* link. Focus inside the trigger counts only while the trigger is focusable
|
|
21
|
+
* too, so a plain wrapper ignores its children's focus.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isFocusForTrigger(event: Event, mode: TriggerFocusMode): boolean;
|
|
24
|
+
/** Remembers whether a trigger's current focus counted when it arrived. */
|
|
25
|
+
export interface TriggerFocusGate {
|
|
26
|
+
/** On focusin: whether this focus opens the layer. */
|
|
27
|
+
focusIn(event: Event, mode: TriggerFocusMode): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* On focusout: whether this blur closes the layer. A focus that counted
|
|
30
|
+
* closes on blur even if the trigger has since left the tab order.
|
|
31
|
+
*/
|
|
32
|
+
focusOut(event: Event, mode: TriggerFocusMode): boolean;
|
|
33
|
+
}
|
|
34
|
+
/** A gate for one trigger; each hook keeps one for its lifetime. */
|
|
35
|
+
export declare function createTriggerFocusGate(): TriggerFocusGate;
|
|
36
|
+
//# sourceMappingURL=triggerFocus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triggerFocus.d.ts","sourceRoot":"","sources":["../../src/utils/triggerFocus.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,+CAA+C;AAC/C,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE3D,oEAAoE;AACpE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAShE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAWT;AAED,2EAA2E;AAC3E,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC;IACvD;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC;CACzD;AAED,oEAAoE;AACpE,wBAAgB,sBAAsB,IAAI,gBAAgB,CAezD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file triggerFocus.ts
|
|
5
|
+
* @input A focus event on a hover-layer trigger and its focusTrigger value
|
|
6
|
+
* @output Whether that focus counts as focus on the trigger, and a gate that
|
|
7
|
+
* remembers it for the matching blur
|
|
8
|
+
* @position Shared focus-trigger judgement for Tooltip and HoverCard
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** When focus on a trigger opens its layer. */
|
|
12
|
+
|
|
13
|
+
/** Whether `element` is in the tab order or naturally focusable. */
|
|
14
|
+
export function isFocusableTrigger(element) {
|
|
15
|
+
if (element.hasAttribute('tabindex')) {
|
|
16
|
+
return element.tabIndex >= 0;
|
|
17
|
+
}
|
|
18
|
+
const focusableTags = ['A', 'BUTTON', 'INPUT', 'SELECT', 'TEXTAREA'];
|
|
19
|
+
if (focusableTags.includes(element.tagName)) {
|
|
20
|
+
return !element.disabled;
|
|
21
|
+
}
|
|
22
|
+
return element.isContentEditable;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Whether a focus event on a trigger (its `currentTarget`) counts as focus on
|
|
27
|
+
* the trigger.
|
|
28
|
+
*
|
|
29
|
+
* Under `auto` it is decided when focus arrives, not when listeners attach: a
|
|
30
|
+
* roving-tabindex member that was `tabindex="-1"` then can be the tab stop
|
|
31
|
+
* now. A trigger that receives focus is focusable by definition, which covers
|
|
32
|
+
* focusable elements this check does not list, such as a `<summary>` or an SVG
|
|
33
|
+
* link. Focus inside the trigger counts only while the trigger is focusable
|
|
34
|
+
* too, so a plain wrapper ignores its children's focus.
|
|
35
|
+
*/
|
|
36
|
+
export function isFocusForTrigger(event, mode) {
|
|
37
|
+
if (mode === 'always') {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (mode === 'never') {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const trigger = event.currentTarget;
|
|
44
|
+
return trigger != null && (event.target === trigger || isFocusableTrigger(trigger));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Remembers whether a trigger's current focus counted when it arrived. */
|
|
48
|
+
|
|
49
|
+
/** A gate for one trigger; each hook keeps one for its lifetime. */
|
|
50
|
+
export function createTriggerFocusGate() {
|
|
51
|
+
let isCounted = false;
|
|
52
|
+
return {
|
|
53
|
+
focusIn(event, mode) {
|
|
54
|
+
isCounted = isFocusForTrigger(event, mode);
|
|
55
|
+
return isCounted;
|
|
56
|
+
},
|
|
57
|
+
focusOut(event, mode) {
|
|
58
|
+
if (!isCounted && !isFocusForTrigger(event, mode)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
isCounted = false;
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|