@astryxdesign/core 0.7.6 → 0.7.7-canary.1d04d40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +23 -3
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +16 -9
- package/dist/Chat/ChatComposerInput.d.ts +9 -0
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +2 -0
- package/dist/Chat/ChatMessage.js +2 -2
- package/dist/Chat/chatMessage.vars.stylex.d.ts +8 -8
- package/dist/Chat/chatMessage.vars.stylex.js +8 -8
- package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteInput.js +8 -1
- package/dist/DateInput/MonthScroller.d.ts.map +1 -1
- package/dist/DateInput/MonthScroller.js +72 -2
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +6 -0
- package/dist/DropdownMenu/useMenuOverflow.d.ts +13 -3
- package/dist/DropdownMenu/useMenuOverflow.d.ts.map +1 -1
- package/dist/DropdownMenu/useMenuOverflow.js +31 -8
- package/dist/Field/PanelSearchInput.d.ts.map +1 -1
- package/dist/Field/PanelSearchInput.js +8 -1
- package/dist/Field/textEntryTraits.d.ts +6 -6
- package/dist/Field/textEntryTraits.js +6 -6
- package/dist/Layer/layerClickBoundary.d.ts +7 -1
- package/dist/Layer/layerClickBoundary.d.ts.map +1 -1
- package/dist/Layer/layerClickBoundary.js +2 -2
- package/dist/Layer/usePressPin.d.ts +95 -0
- package/dist/Layer/usePressPin.d.ts.map +1 -0
- package/dist/Layer/usePressPin.js +335 -0
- package/dist/Layer/useTouchTrigger.d.ts +23 -1
- package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
- package/dist/Layer/useTouchTrigger.js +29 -2
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +1 -0
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +20 -9
- package/dist/ProgressBar/ProgressBarTouch.d.ts +29 -0
- package/dist/ProgressBar/ProgressBarTouch.d.ts.map +1 -0
- package/dist/ProgressBar/ProgressBarTouch.js +91 -0
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +25 -13
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +404 -131
- package/dist/Slider/sliderTouchController.d.ts +189 -0
- package/dist/Slider/sliderTouchController.d.ts.map +1 -0
- package/dist/Slider/sliderTouchController.js +1017 -0
- package/dist/Slider/useSliderTouch.d.ts +22 -0
- package/dist/Slider/useSliderTouch.d.ts.map +1 -0
- package/dist/Slider/useSliderTouch.js +56 -0
- package/dist/Tooltip/Tooltip.d.ts +30 -6
- package/dist/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip/Tooltip.js +5 -0
- package/dist/Tooltip/index.d.ts +1 -1
- package/dist/Tooltip/index.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.d.ts +31 -5
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +59 -18
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +19 -9
- package/dist/astryx.css +40 -6
- package/dist/gestures/GestureArena.d.ts +21 -2
- package/dist/gestures/GestureArena.d.ts.map +1 -1
- package/dist/gestures/GestureArena.js +23 -3
- package/dist/gestures/GestureHost.d.ts +123 -3
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +791 -12
- package/dist/gestures/GestureRecognizer.d.ts +15 -1
- package/dist/gestures/GestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/GestureRecognizer.js +12 -0
- package/dist/gestures/PanGestureRecognizer.d.ts +8 -0
- package/dist/gestures/PanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/PinchGestureRecognizer.d.ts +5 -1
- package/dist/gestures/PinchGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/PinchGestureRecognizer.js +10 -0
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts +3 -3
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/ScreenEdgePanGestureRecognizer.js +7 -5
- package/dist/gestures/nativeScroll.d.ts +16 -2
- package/dist/gestures/nativeScroll.d.ts.map +1 -1
- package/dist/gestures/nativeScroll.js +39 -8
- package/dist/gestures/recognizerInternals.d.ts +4 -2
- package/dist/gestures/recognizerInternals.d.ts.map +1 -1
- package/dist/gestures/types.d.ts +11 -0
- package/dist/gestures/types.d.ts.map +1 -1
- package/dist/gestures/types.js +7 -0
- package/dist/gestures/wheelSegmenter.d.ts +45 -0
- package/dist/gestures/wheelSegmenter.d.ts.map +1 -0
- package/dist/gestures/wheelSegmenter.js +98 -0
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +140 -19
- package/dist/motion/paging.d.ts +58 -0
- package/dist/motion/paging.d.ts.map +1 -0
- package/dist/motion/paging.js +128 -0
- package/dist/motion/uikit/index.d.ts +5 -3
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +5 -3
- package/dist/motion/uikit/paging.d.ts +160 -0
- package/dist/motion/uikit/paging.d.ts.map +1 -0
- package/dist/motion/uikit/paging.js +162 -0
- package/dist/motion/uikit/progressBar.d.ts +59 -0
- package/dist/motion/uikit/progressBar.d.ts.map +1 -0
- package/dist/motion/uikit/progressBar.js +82 -0
- package/dist/motion/uikit/scroll.d.ts +0 -19
- package/dist/motion/uikit/scroll.d.ts.map +1 -1
- package/dist/motion/uikit/scroll.js +2 -21
- package/dist/motion/uikit/slider.d.ts +97 -0
- package/dist/motion/uikit/slider.d.ts.map +1 -0
- package/dist/motion/uikit/slider.js +111 -0
- package/dist/motion/uikit/springs.d.ts +46 -1
- package/dist/motion/uikit/springs.d.ts.map +1 -1
- package/dist/motion/uikit/springs.js +48 -4
- package/dist/utils/selectionLock.d.ts +43 -0
- package/dist/utils/selectionLock.d.ts.map +1 -1
- package/dist/utils/selectionLock.js +394 -6
- package/package.json +5 -5
- package/src/AppShell/AppShell.doc.mjs +10 -0
- package/src/AppShell/AppShell.tsx +48 -2
- package/src/BottomSheet/BottomSheetPanel.tsx +16 -9
- package/src/Chat/Chat.doc.mjs +1 -0
- package/src/Chat/ChatComposerInput.doc.mjs +11 -0
- package/src/Chat/ChatComposerInput.tsx +11 -0
- package/src/Chat/ChatMessage.tsx +2 -2
- package/src/Chat/chatMessage.vars.stylex.ts +8 -8
- package/src/CommandPalette/CommandPaletteInput.tsx +6 -0
- package/src/DateInput/MonthScroller.tsx +63 -5
- package/src/Drawer/Drawer.tsx +6 -0
- package/src/DropdownMenu/useMenuOverflow.ts +44 -8
- package/src/Field/PanelSearchInput.tsx +6 -0
- package/src/Field/textEntryTraits.ts +6 -6
- package/src/Layer/layerClickBoundary.ts +2 -2
- package/src/Layer/usePressPin.ts +481 -0
- package/src/Layer/useTouchTrigger.ts +37 -1
- package/src/Link/Link.tsx +3 -0
- package/src/ProgressBar/ProgressBar.doc.mjs +3 -3
- package/src/ProgressBar/ProgressBar.tsx +82 -11
- package/src/ProgressBar/ProgressBarTouch.ts +109 -0
- package/src/Selector/Selector.tsx +29 -2
- package/src/Slider/Slider.doc.mjs +11 -7
- package/src/Slider/Slider.tsx +539 -132
- package/src/Slider/sliderTouchController.ts +1209 -0
- package/src/Slider/useSliderTouch.ts +78 -0
- package/src/Tooltip/Tooltip.doc.mjs +21 -6
- package/src/Tooltip/Tooltip.tsx +42 -5
- package/src/Tooltip/index.ts +1 -0
- package/src/Tooltip/useTooltip.doc.mjs +4 -2
- package/src/Tooltip/useTooltip.tsx +84 -21
- package/src/Typeahead/BaseTypeahead.tsx +16 -8
- package/src/gestures/GestureArena.ts +45 -4
- package/src/gestures/GestureHost.ts +949 -12
- package/src/gestures/GestureRecognizer.ts +28 -0
- package/src/gestures/PanGestureRecognizer.ts +8 -0
- package/src/gestures/PinchGestureRecognizer.ts +16 -1
- package/src/gestures/README.md +82 -3
- package/src/gestures/ScreenEdgePanGestureRecognizer.ts +7 -5
- package/src/gestures/nativeScroll.ts +49 -9
- package/src/gestures/recognizerInternals.ts +9 -2
- package/src/gestures/types.ts +12 -0
- package/src/gestures/wheelSegmenter.ts +114 -0
- package/src/motion/MEASUREMENTS.md +8 -1
- package/src/motion/README.md +6 -3
- package/src/motion/animator.ts +193 -25
- package/src/motion/paging.ts +138 -0
- package/src/motion/uikit/index.ts +5 -3
- package/src/motion/uikit/paging.ts +162 -0
- package/src/motion/uikit/progressBar.ts +82 -0
- package/src/motion/uikit/scroll.ts +2 -18
- package/src/motion/uikit/slider.ts +105 -0
- package/src/motion/uikit/springs.ts +37 -2
- package/src/utils/selectionLock.ts +501 -6
- package/dist/motion/selectPage.d.ts +0 -26
- package/dist/motion/selectPage.d.ts.map +0 -1
- package/dist/motion/selectPage.js +0 -55
- package/src/motion/selectPage.ts +0 -55
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type SliderTouchModel, type SliderTouchParts } from './sliderTouchController.js';
|
|
2
|
+
export type { SliderTouchModel, SliderTouchParts } from './sliderTouchController.js';
|
|
3
|
+
export interface UseSliderTouchOptions {
|
|
4
|
+
/** The slider is enabled: its gestures attach for every pointer. */
|
|
5
|
+
readonly isEnabled: boolean;
|
|
6
|
+
readonly model: SliderTouchModel;
|
|
7
|
+
readonly getParts: () => SliderTouchParts | null;
|
|
8
|
+
/** Re-attaches when the thumbs or the orientation change. */
|
|
9
|
+
readonly thumbCount: number;
|
|
10
|
+
/**
|
|
11
|
+
* Whether each thumb renders inside its value tooltip: changing it mounts
|
|
12
|
+
* new thumbs. So the gestures re-attach.
|
|
13
|
+
*/
|
|
14
|
+
readonly thumbsWrapped: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Wires UISlider's tracking to a rendered Slider for every pointer, while it
|
|
18
|
+
* is enabled. Slider's own pointer handlers then take only a mouse press on
|
|
19
|
+
* the track.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useSliderTouch({ isEnabled, model, getParts, thumbCount, thumbsWrapped, }: UseSliderTouchOptions): void;
|
|
22
|
+
//# sourceMappingURL=useSliderTouch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSliderTouch.d.ts","sourceRoot":"","sources":["../../src/Slider/useSliderTouch.ts"],"names":[],"mappings":"AAoBA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EAAC,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AAEhF,MAAM,WAAW,qBAAqB;IACpC,oEAAoE;IACpE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,gBAAgB,GAAG,IAAI,CAAC;IACjD,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,KAAK,EACL,QAAQ,EACR,UAAU,EACV,aAAa,GACd,EAAE,qBAAqB,GAAG,IAAI,CAwB9B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file useSliderTouch.ts
|
|
7
|
+
* @input Slider's value model and parts, and sliderTouchController.ts
|
|
8
|
+
* @output Exports `useSliderTouch` (the React wiring) and the
|
|
9
|
+
* `SliderTouchModel` and `SliderTouchParts` types
|
|
10
|
+
* @position Internal to Slider. It is the touch layer's one import site, so
|
|
11
|
+
* a desktop build can swap that module whole.
|
|
12
|
+
*
|
|
13
|
+
* SYNC: When modified, update:
|
|
14
|
+
* - /packages/core/src/Slider/sliderTouchController.ts
|
|
15
|
+
* - /packages/core/src/Slider/Slider.tsx (the model and the parts)
|
|
16
|
+
* - /packages/core/src/Slider/useSliderTouch.test.tsx
|
|
17
|
+
*/
|
|
18
|
+
import { useEffect, useState } from 'react';
|
|
19
|
+
import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
|
|
20
|
+
import { SliderTouchController } from "./sliderTouchController.js";
|
|
21
|
+
/**
|
|
22
|
+
* Wires UISlider's tracking to a rendered Slider for every pointer, while it
|
|
23
|
+
* is enabled. Slider's own pointer handlers then take only a mouse press on
|
|
24
|
+
* the track.
|
|
25
|
+
*/
|
|
26
|
+
export function useSliderTouch({
|
|
27
|
+
isEnabled,
|
|
28
|
+
model,
|
|
29
|
+
getParts,
|
|
30
|
+
thumbCount,
|
|
31
|
+
thumbsWrapped
|
|
32
|
+
}) {
|
|
33
|
+
// The parts getter reads only refs. So the first one stays current.
|
|
34
|
+
const [controller] = useState(() => new SliderTouchController(model, getParts));
|
|
35
|
+
// Hands the controller this render's model: the values and callbacks it
|
|
36
|
+
// reads from gesture callbacks outside React's render.
|
|
37
|
+
useIsomorphicLayoutEffect(() => {
|
|
38
|
+
controller.setModel(model);
|
|
39
|
+
});
|
|
40
|
+
const {
|
|
41
|
+
isHorizontal
|
|
42
|
+
} = model;
|
|
43
|
+
// Synchronizes the thumbs with the document's gesture host. Their
|
|
44
|
+
// PressTrackers and pans attach while the slider is enabled. They detach,
|
|
45
|
+
// ending any interaction silently, when it is disabled or the thumbs
|
|
46
|
+
// change.
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!isEnabled) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return controller.attach();
|
|
52
|
+
}, [controller, isEnabled, thumbCount, isHorizontal, thumbsWrapped]);
|
|
53
|
+
// Releases the controller's animators and gesture host listeners on
|
|
54
|
+
// unmount.
|
|
55
|
+
useEffect(() => () => controller.dispose(), [controller]);
|
|
56
|
+
}
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* - /packages/cli/assets/templates/blocks/components/Tooltip/ (showcase blocks)
|
|
11
11
|
*/
|
|
12
12
|
import React, { type ReactElement, type ReactNode } from 'react';
|
|
13
|
-
import { type TooltipFocusTrigger, type TooltipTouchTrigger } from './useTooltip.js';
|
|
13
|
+
import { type TooltipFocusTrigger, type TooltipTriggerBehavior, type TooltipTouchTrigger } from './useTooltip.js';
|
|
14
14
|
import type { LayerAlignment, LayerPlacement } from '../Layer/useLayer.js';
|
|
15
|
-
export type { TooltipFocusTrigger, TooltipTouchTrigger } from './useTooltip.js';
|
|
15
|
+
export type { TooltipFocusTrigger, TooltipTriggerBehavior, TooltipTouchTrigger, } from './useTooltip.js';
|
|
16
16
|
export interface TooltipProps {
|
|
17
17
|
/**
|
|
18
18
|
* The trigger element(s). Children refs are preserved.
|
|
@@ -67,14 +67,38 @@ export interface TooltipProps {
|
|
|
67
67
|
* - `auto`: tap opens the tooltip, unless the trigger performs an action of
|
|
68
68
|
* its own (a button, a link, a form control) — that tap belongs to the
|
|
69
69
|
* control, and a hint about a control the user just operated is noise
|
|
70
|
-
* - `tap`: tap always opens the tooltip
|
|
71
|
-
* as a button wants: it looks like an action to the DOM, but revealing the
|
|
72
|
-
* tooltip is the only thing it does
|
|
70
|
+
* - `tap`: tap always opens the tooltip, even on a trigger that acts
|
|
73
71
|
* - `none`: touch never opens the tooltip
|
|
74
72
|
*
|
|
73
|
+
* It decides only under `triggerBehavior="adaptive"`, the default.
|
|
74
|
+
*
|
|
75
75
|
* @default 'auto'
|
|
76
76
|
*/
|
|
77
77
|
touchTrigger?: TooltipTouchTrigger;
|
|
78
|
+
/**
|
|
79
|
+
* How the trigger opens the tooltip:
|
|
80
|
+
* - `adaptive` (the default): hover and focus preview it. A tap opens it
|
|
81
|
+
* unless the trigger performs an action of its own. While `touchTrigger`
|
|
82
|
+
* remains, it decides those taps.
|
|
83
|
+
* - `hover`: hover and focus preview it; no touch or pen tap opens it.
|
|
84
|
+
* - `toggle`: on a button trigger, a click, a tap, Enter, or Space pins the
|
|
85
|
+
* tooltip open, and the same press closes it. Hover and keyboard focus
|
|
86
|
+
* still preview it. A pinned tooltip stays until Escape, a second press,
|
|
87
|
+
* a press outside, or focus leaving. The press stops at the trigger. Its
|
|
88
|
+
* default action is prevented, and the trigger's own handlers still run.
|
|
89
|
+
* No clickable row or card around the trigger activates. With
|
|
90
|
+
* `anchorRef`, the anchor's own `onClick` runs, and a plain `onClick`
|
|
91
|
+
* element around it receives the press unless that `onClick` stops it.
|
|
92
|
+
* Astryx clickable rows, cards, and containers ignore it, except an Item
|
|
93
|
+
* row when the anchor is not a native button. The trigger reports
|
|
94
|
+
* `aria-expanded` and `aria-controls`, and the tooltip's text is
|
|
95
|
+
* announced once when it pins. Use it for a trigger whose information
|
|
96
|
+
* lives only in the tooltip, such as an info icon. `touchTrigger` is
|
|
97
|
+
* ignored.
|
|
98
|
+
*
|
|
99
|
+
* @default 'adaptive'
|
|
100
|
+
*/
|
|
101
|
+
triggerBehavior?: TooltipTriggerBehavior;
|
|
78
102
|
/**
|
|
79
103
|
* Whether the tooltip is enabled.
|
|
80
104
|
* When false, hover/focus triggers are disabled.
|
|
@@ -128,7 +152,7 @@ export interface TooltipProps {
|
|
|
128
152
|
* </Tooltip>
|
|
129
153
|
* ```
|
|
130
154
|
*/
|
|
131
|
-
export declare function Tooltip({ children, anchorRef, content, placement, alignment, delay, hideDelay, focusTrigger, touchTrigger, isEnabled, onOpenChange, hasHoverIndication, isOpen, isDefaultOpen, }: TooltipProps): ReactElement;
|
|
155
|
+
export declare function Tooltip({ children, anchorRef, content, placement, alignment, delay, hideDelay, focusTrigger, touchTrigger, triggerBehavior, isEnabled, onOpenChange, hasHoverIndication, isOpen, isDefaultOpen, }: TooltipProps): ReactElement;
|
|
132
156
|
export declare namespace Tooltip {
|
|
133
157
|
var displayName: string;
|
|
134
158
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,EAGZ,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,EAGZ,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAGtE,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAiBtB,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAEhD;;;OAGG;IACH,OAAO,EAAE,SAAS,CAAC;IAEnB;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAE3B;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAE3B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAEnC;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAEnC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC;IAEzC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAEzC;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAEtC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAiBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,EACtB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,SAAmB,EACnB,SAAoB,EACpB,KAAW,EACX,SAAa,EACb,YAAqB,EACrB,YAAqB,EACrB,eAA4B,EAC5B,SAAgB,EAChB,YAAY,EACZ,kBAA2B,EAC3B,MAAM,EACN,aAAa,GACd,EAAE,YAAY,GAAG,YAAY,CAkK7B;yBAlLe,OAAO"}
|
package/dist/Tooltip/Tooltip.js
CHANGED
|
@@ -17,6 +17,7 @@ import React, { useCallback, useRef } from 'react';
|
|
|
17
17
|
import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
|
|
18
18
|
import * as stylex from '@stylexjs/stylex';
|
|
19
19
|
import { useTooltip } from "./useTooltip.js";
|
|
20
|
+
import { stopPressPinClick } from "../Layer/usePressPin.js";
|
|
20
21
|
import "../theme/tokens.stylex.js";
|
|
21
22
|
import { colorVars } from "../theme/tokens.stylex.js";
|
|
22
23
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -59,6 +60,7 @@ export function Tooltip({
|
|
|
59
60
|
hideDelay = 0,
|
|
60
61
|
focusTrigger = 'auto',
|
|
61
62
|
touchTrigger = 'auto',
|
|
63
|
+
triggerBehavior = 'adaptive',
|
|
62
64
|
isEnabled = true,
|
|
63
65
|
onOpenChange,
|
|
64
66
|
hasHoverIndication = 'auto',
|
|
@@ -85,6 +87,7 @@ export function Tooltip({
|
|
|
85
87
|
hideDelay,
|
|
86
88
|
focusTrigger,
|
|
87
89
|
touchTrigger,
|
|
90
|
+
triggerBehavior,
|
|
88
91
|
isEnabled,
|
|
89
92
|
isOpen,
|
|
90
93
|
isDefaultOpen,
|
|
@@ -188,6 +191,7 @@ export function Tooltip({
|
|
|
188
191
|
ref: tooltip.ref,
|
|
189
192
|
tabIndex: 0,
|
|
190
193
|
"aria-describedby": tooltip.describedBy,
|
|
194
|
+
onClick: stopPressPinClick,
|
|
191
195
|
...{
|
|
192
196
|
0: {
|
|
193
197
|
className: "xt0psk2"
|
|
@@ -205,6 +209,7 @@ export function Tooltip({
|
|
|
205
209
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
206
210
|
children: [/*#__PURE__*/_jsx("div", {
|
|
207
211
|
ref: wrapperRef,
|
|
212
|
+
onClick: stopPressPinClick,
|
|
208
213
|
...{
|
|
209
214
|
className: "xjp7ctv"
|
|
210
215
|
},
|
package/dist/Tooltip/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* SYNC: When adding new Tooltip files, update exports here
|
|
8
8
|
*/
|
|
9
9
|
export { useTooltip } from './useTooltip.js';
|
|
10
|
-
export type { TooltipFocusTrigger, TooltipTouchTrigger, TooltipOptions, TooltipReturn, } from './useTooltip.js';
|
|
10
|
+
export type { TooltipFocusTrigger, TooltipTriggerBehavior, TooltipTouchTrigger, TooltipOptions, TooltipReturn, } from './useTooltip.js';
|
|
11
11
|
export { Tooltip } from './Tooltip.js';
|
|
12
12
|
export type { TooltipProps } from './Tooltip.js';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Tooltip/index.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAGH,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,aAAa,GACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,YAAY,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Tooltip/index.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAGH,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,cAAc,EACd,aAAa,GACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,YAAY,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file useTooltip.tsx
|
|
3
|
-
* @input Uses useLayer,
|
|
3
|
+
* @input Uses useLayer, usePressPin, React hooks
|
|
4
4
|
* @output Exports useTooltip hook with stable trigger refs for hover/focus/tap tooltips
|
|
5
5
|
* @position Layer hook; builds on useLayer for tooltip behavior
|
|
6
6
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { type ReactNode, type RefCallback } from 'react';
|
|
11
11
|
import { type ContextRenderProps, type LayerAlignment, type LayerPlacement } from '../Layer/useLayer.js';
|
|
12
|
-
import {
|
|
12
|
+
import type { LayerTouchTrigger } from '../Layer/useTouchTrigger.js';
|
|
13
13
|
/**
|
|
14
14
|
* Focus trigger behavior for tooltips
|
|
15
15
|
*/
|
|
@@ -18,6 +18,13 @@ export type TooltipFocusTrigger = 'auto' | 'always' | 'never';
|
|
|
18
18
|
* Touch trigger behavior for tooltips
|
|
19
19
|
*/
|
|
20
20
|
export type TooltipTouchTrigger = LayerTouchTrigger;
|
|
21
|
+
/**
|
|
22
|
+
* How the trigger opens the tooltip. `adaptive`, the default, previews it on
|
|
23
|
+
* hover and focus, and a tap opens it unless the trigger acts. `hover`
|
|
24
|
+
* previews it on hover and focus, and no touch or pen tap opens it. `toggle`
|
|
25
|
+
* pins it on a click, tap, Enter, or Space on a button trigger.
|
|
26
|
+
*/
|
|
27
|
+
export type TooltipTriggerBehavior = 'adaptive' | 'hover' | 'toggle';
|
|
21
28
|
export interface TooltipOptions {
|
|
22
29
|
/**
|
|
23
30
|
* Position placement relative to anchor
|
|
@@ -54,14 +61,33 @@ export interface TooltipOptions {
|
|
|
54
61
|
* - `auto`: tap opens the tooltip, unless the trigger performs an action of
|
|
55
62
|
* its own (a button, a link, a form control) — that tap belongs to the
|
|
56
63
|
* control, and a hint about a control the user just operated is noise
|
|
57
|
-
* - `tap`: tap always opens the tooltip
|
|
58
|
-
* as a button wants: it looks like an action to the DOM, but revealing the
|
|
59
|
-
* tooltip is the only thing it does
|
|
64
|
+
* - `tap`: tap always opens the tooltip, even on a trigger that acts
|
|
60
65
|
* - `none`: touch never opens the tooltip
|
|
61
66
|
*
|
|
67
|
+
* It decides only under `triggerBehavior="adaptive"`, the default.
|
|
68
|
+
*
|
|
62
69
|
* @default 'auto'
|
|
63
70
|
*/
|
|
64
71
|
touchTrigger?: TooltipTouchTrigger;
|
|
72
|
+
/**
|
|
73
|
+
* How the trigger opens the tooltip:
|
|
74
|
+
* - `adaptive` (the default): hover and focus preview it. A tap opens it
|
|
75
|
+
* unless the trigger performs an action of its own. While `touchTrigger`
|
|
76
|
+
* remains, it decides those taps.
|
|
77
|
+
* - `hover`: hover and focus preview it; no touch or pen tap opens it.
|
|
78
|
+
* - `toggle`: on a button trigger, a click, a tap, Enter, or Space pins the
|
|
79
|
+
* tooltip open, and the same press closes it. Hover and keyboard focus
|
|
80
|
+
* still preview it. A pinned tooltip stays until Escape, a second press,
|
|
81
|
+
* a press outside, or focus leaving. Astryx clickable rows and cards
|
|
82
|
+
* ignore the pinning press, except an Item row on a trigger that is not
|
|
83
|
+
* a native button. The `Tooltip` component also stops it at a child
|
|
84
|
+
* trigger. A hook caller stops a plain `onClick` ancestor itself. The
|
|
85
|
+
* trigger reports `aria-expanded` and `aria-controls`, and the tooltip's
|
|
86
|
+
* text is announced once when it pins. `touchTrigger` is ignored.
|
|
87
|
+
*
|
|
88
|
+
* @default 'adaptive'
|
|
89
|
+
*/
|
|
90
|
+
triggerBehavior?: TooltipTriggerBehavior;
|
|
65
91
|
/**
|
|
66
92
|
* Whether the tooltip is enabled.
|
|
67
93
|
* When false, hover/focus triggers are disabled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../src/Tooltip/useTooltip.tsx"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,
|
|
1
|
+
{"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../src/Tooltip/useTooltip.tsx"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AA+ChE;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAE3B;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAE3B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAEnC;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAEnC;;;;;;;;;;;;;;;;;OAiBG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC;IAEzC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IAEpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,GAAG,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAE9B;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAEtC;;;;OAIG;IACH,cAAc,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAEzC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;;;;OAOG;IACH,aAAa,EAAE,CACb,QAAQ,EAAE,SAAS,EACnB,KAAK,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,aAAa,CAAC,KAC5C,SAAS,CAAC;CAChB;AAyBD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,wBAAgB,UAAU,CAAC,OAAO,GAAE,cAAmB,GAAG,aAAa,CAqdtE"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file useTooltip.tsx
|
|
7
|
-
* @input Uses useLayer,
|
|
7
|
+
* @input Uses useLayer, usePressPin, React hooks
|
|
8
8
|
* @output Exports useTooltip hook with stable trigger refs for hover/focus/tap tooltips
|
|
9
9
|
* @position Layer hook; builds on useLayer for tooltip behavior
|
|
10
10
|
*
|
|
@@ -14,9 +14,11 @@
|
|
|
14
14
|
import { useCallback, useEffect, useRef } from 'react';
|
|
15
15
|
import * as stylex from '@stylexjs/stylex';
|
|
16
16
|
import { useLayerInternal } from "../Layer/useLayer.js";
|
|
17
|
-
import {
|
|
17
|
+
import { useAnnounceRenderedText } from "../hooks/useAnnounceRenderedText.js";
|
|
18
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
18
19
|
import { layerAnimations } from "../Layer/layerAnimations.stylex.js";
|
|
19
20
|
import { registerLayerSurface } from "../Layer/layerSurfacePress.js";
|
|
21
|
+
import { usePressPin } from "../Layer/usePressPin.js";
|
|
20
22
|
import { useLayerDismissal } from "../Layer/useLayerDismissal.js";
|
|
21
23
|
import { themeProps } from "../utils/themeProps.js";
|
|
22
24
|
import "../theme/tokens.stylex.js";
|
|
@@ -49,6 +51,13 @@ const styles = {
|
|
|
49
51
|
* Touch trigger behavior for tooltips
|
|
50
52
|
*/
|
|
51
53
|
|
|
54
|
+
/**
|
|
55
|
+
* How the trigger opens the tooltip. `adaptive`, the default, previews it on
|
|
56
|
+
* hover and focus, and a tap opens it unless the trigger acts. `hover`
|
|
57
|
+
* previews it on hover and focus, and no touch or pen tap opens it. `toggle`
|
|
58
|
+
* pins it on a click, tap, Enter, or Space on a button trigger.
|
|
59
|
+
*/
|
|
60
|
+
|
|
52
61
|
/**
|
|
53
62
|
* Check if an element is naturally focusable
|
|
54
63
|
*/
|
|
@@ -104,6 +113,7 @@ export function useTooltip(options = {}) {
|
|
|
104
113
|
hideDelay = 0,
|
|
105
114
|
focusTrigger = 'auto',
|
|
106
115
|
touchTrigger = 'auto',
|
|
116
|
+
triggerBehavior = 'adaptive',
|
|
107
117
|
isEnabled = true,
|
|
108
118
|
isOpen,
|
|
109
119
|
isDefaultOpen = false,
|
|
@@ -157,23 +167,42 @@ export function useTooltip(options = {}) {
|
|
|
157
167
|
clearTimeouts();
|
|
158
168
|
hideLayer();
|
|
159
169
|
}, [clearTimeouts, hideLayer]);
|
|
170
|
+
|
|
171
|
+
// A press pins the tooltip under `triggerBehavior="toggle"`. The pin also
|
|
172
|
+
// owns the tooltip's touch trigger, so this one call wires both.
|
|
160
173
|
const {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
174
|
+
isToggleTrigger,
|
|
175
|
+
isHeldOpen: isPressHeldOpen,
|
|
176
|
+
attach: attachPressPin,
|
|
177
|
+
unpin: unpinPress,
|
|
178
|
+
isPinShown,
|
|
179
|
+
touch: {
|
|
180
|
+
isTouchPointerRef,
|
|
181
|
+
isTouchInteraction,
|
|
182
|
+
handlePointerEnter,
|
|
183
|
+
handlePointerDown: handleTouchPointerDown,
|
|
184
|
+
clearTapOpen
|
|
185
|
+
}
|
|
186
|
+
} = usePressPin({
|
|
187
|
+
triggerBehavior,
|
|
167
188
|
touchTrigger,
|
|
168
189
|
isEnabled,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
layerId
|
|
190
|
+
isOpen,
|
|
191
|
+
isLayerOpen,
|
|
192
|
+
layerId,
|
|
172
193
|
triggerRef,
|
|
194
|
+
component: 'Tooltip',
|
|
173
195
|
show: showNow,
|
|
174
|
-
hide: hideNow
|
|
196
|
+
hide: hideNow,
|
|
197
|
+
report: next => next ? onShow?.() : onHide?.()
|
|
175
198
|
});
|
|
176
199
|
|
|
200
|
+
// Only a pin announces the text: a preview is already the trigger's
|
|
201
|
+
// description.
|
|
202
|
+
const contentRef = useRef(null);
|
|
203
|
+
useAnnounceRenderedText(contentRef, isPinShown, 'pinned');
|
|
204
|
+
const contentRefs = useMergedRefs(contentRef, registerLayerSurface);
|
|
205
|
+
|
|
177
206
|
// Schedule show with delay (suppressed when isOpen is false)
|
|
178
207
|
const scheduleShow = useCallback(() => {
|
|
179
208
|
if (!isEnabled || isOpen === false) {
|
|
@@ -201,7 +230,7 @@ export function useTooltip(options = {}) {
|
|
|
201
230
|
// trigger onto the tooltip surface without the tooltip vanishing — required
|
|
202
231
|
// for WCAG 1.4.13 (Content on Hover or Focus: hoverable).
|
|
203
232
|
const scheduleHide = useCallback(() => {
|
|
204
|
-
if (isOpen === true) {
|
|
233
|
+
if (isOpen === true || isPressHeldOpen()) {
|
|
205
234
|
return;
|
|
206
235
|
}
|
|
207
236
|
clearTimeouts();
|
|
@@ -209,7 +238,7 @@ export function useTooltip(options = {}) {
|
|
|
209
238
|
hideTimeoutRef.current = setTimeout(() => {
|
|
210
239
|
hideLayer();
|
|
211
240
|
}, effectiveHideDelay);
|
|
212
|
-
}, [isOpen, clearTimeouts, hideLayer, hideDelay]);
|
|
241
|
+
}, [isOpen, isPressHeldOpen, clearTimeouts, hideLayer, hideDelay]);
|
|
213
242
|
|
|
214
243
|
// Cancel a pending hide (e.g. the pointer entered the tooltip surface).
|
|
215
244
|
const cancelHide = useCallback(() => {
|
|
@@ -286,6 +315,10 @@ export function useTooltip(options = {}) {
|
|
|
286
315
|
clearTimeouts();
|
|
287
316
|
showLayer();
|
|
288
317
|
}, [isEnabled, isFocusForTrigger, isTouchInteraction, clearTimeouts, showLayer]);
|
|
318
|
+
|
|
319
|
+
// A pinned tooltip's focus-leave close is the pin's own: it listens on the
|
|
320
|
+
// trigger whatever `focusTrigger` is. This schedules the unpinned hide,
|
|
321
|
+
// which a held tooltip skips.
|
|
289
322
|
const handleFocusOut = useCallback(e => {
|
|
290
323
|
if (!focusCountedRef.current && !isFocusForTrigger(e)) {
|
|
291
324
|
return;
|
|
@@ -302,6 +335,11 @@ export function useTooltip(options = {}) {
|
|
|
302
335
|
// A touch press is a different gesture (it may be the only way to open the
|
|
303
336
|
// tooltip at all), so the touch path answers it first.
|
|
304
337
|
const handlePointerDown = useCallback(event => {
|
|
338
|
+
// A press on a toggle trigger pins or closes through its click. It
|
|
339
|
+
// neither hides the preview here nor waits for a tap verdict.
|
|
340
|
+
if (isToggleTrigger(triggerRef.current)) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
305
343
|
if (handleTouchPointerDown(event)) {
|
|
306
344
|
return;
|
|
307
345
|
}
|
|
@@ -310,7 +348,7 @@ export function useTooltip(options = {}) {
|
|
|
310
348
|
}
|
|
311
349
|
clearTimeouts();
|
|
312
350
|
hideLayer();
|
|
313
|
-
}, [handleTouchPointerDown, isOpen, clearTimeouts, hideLayer]);
|
|
351
|
+
}, [isToggleTrigger, handleTouchPointerDown, isOpen, clearTimeouts, hideLayer]);
|
|
314
352
|
|
|
315
353
|
// Interaction ref that handles event listeners only
|
|
316
354
|
const interactionRef = useCallback(el => {
|
|
@@ -341,7 +379,8 @@ export function useTooltip(options = {}) {
|
|
|
341
379
|
}
|
|
342
380
|
}
|
|
343
381
|
triggerRef.current = el;
|
|
344
|
-
|
|
382
|
+
attachPressPin(el);
|
|
383
|
+
}, [attachPressPin, focusTrigger, handleMouseEnter, handleMouseLeave, handleFocusIn, handleFocusOut, handlePointerEnter, handlePointerDown]);
|
|
345
384
|
|
|
346
385
|
// Combined ref - shorthand for calling both positionRef and interactionRef
|
|
347
386
|
const ref = useCallback(el => {
|
|
@@ -414,6 +453,7 @@ export function useTooltip(options = {}) {
|
|
|
414
453
|
onDismiss: () => {
|
|
415
454
|
clearTimeouts();
|
|
416
455
|
clearTapOpen();
|
|
456
|
+
unpinPress();
|
|
417
457
|
if (isOpen !== undefined) {
|
|
418
458
|
onHide?.();
|
|
419
459
|
return;
|
|
@@ -446,14 +486,15 @@ export function useTooltip(options = {}) {
|
|
|
446
486
|
// something else in the shared interactive-ancestor walk, so a
|
|
447
487
|
// clickable container around the trigger leaves the press alone while
|
|
448
488
|
// document listeners still see it.
|
|
489
|
+
// The pin's announcement reads this element's text.
|
|
449
490
|
_jsx("div", {
|
|
450
|
-
ref:
|
|
491
|
+
ref: contentRefs,
|
|
451
492
|
...{
|
|
452
493
|
className: "xfsso4q xy143xn x12gdq22 x1djylfy xw5ewwj x13faqbe"
|
|
453
494
|
},
|
|
454
495
|
children: children
|
|
455
496
|
}), renderProps);
|
|
456
|
-
}, [renderLayer, placement, alignment, popoverXstyle, cancelHide, scheduleHide]);
|
|
497
|
+
}, [renderLayer, placement, alignment, popoverXstyle, cancelHide, scheduleHide, contentRefs]);
|
|
457
498
|
return {
|
|
458
499
|
ref,
|
|
459
500
|
positionRef: layerRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseTypeahead.d.ts","sourceRoot":"","sources":["../../src/Typeahead/BaseTypeahead.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAgCnD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAgB,cAAc,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseTypeahead.d.ts","sourceRoot":"","sources":["../../src/Typeahead/BaseTypeahead.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAgCnD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAgB,cAAc,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC;AAmBzE,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,IAAI,CACxE,SAAS,CAAC,WAAW,CAAC,EACtB,UAAU,CACX;IACC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClC;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAE9B;;OAEG;IACH,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAEhB;;OAEG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IAEnC;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,CAAC;IAEpC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;OAUG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;;;;;;OAaG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC;IAE5B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAExC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAEzC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;IAEtD;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,CAAC;IAE3B;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAE1C;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAE/D;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CAC3B;AA8MD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,EAq1CrB,CAAC,CAAC,SAAS,cAAc,EAC5B,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,KACzB,KAAK,CAAC,YAAY,CAAC"}
|
|
@@ -46,6 +46,7 @@ import { layerViewportInset } from "../Layer/layerViewportInset.stylex.js";
|
|
|
46
46
|
import { clampInlineSize } from "../Layer/clampInlineSize.js";
|
|
47
47
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
48
48
|
import english from "../i18n/generated-english/Typeahead/BaseTypeahead.generated.js";
|
|
49
|
+
import { textEntryTraitAttributes } from "../Field/textEntryTraits.js";
|
|
49
50
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
50
51
|
registerEnglishFallback(english);
|
|
51
52
|
// =============================================================================
|
|
@@ -311,8 +312,9 @@ export const BaseTypeahead = function BaseTypeahead({
|
|
|
311
312
|
const displayedResults = useMemo(() => displayOrder(results, queryEntryCount), [results, queryEntryCount]);
|
|
312
313
|
// Committed values (Tokenizer's tokens) leave the shown rows in the same
|
|
313
314
|
// render that commits them, before any reload answers, so a list never
|
|
314
|
-
// offers a token (component:Tokenizer FR13).
|
|
315
|
-
//
|
|
315
|
+
// offers a token (component:Tokenizer FR13). Until the reload answers, the
|
|
316
|
+
// highlight stays on its item when that item remains; the reloaded list
|
|
317
|
+
// highlights its first row. The previous key is remembered in state, like
|
|
316
318
|
// `sourceOfState` below.
|
|
317
319
|
const committedChoices = useCommittedChoices();
|
|
318
320
|
const committedChoicesKey = committedChoices?.key;
|
|
@@ -753,7 +755,12 @@ export const BaseTypeahead = function BaseTypeahead({
|
|
|
753
755
|
resultsGenRef.current = gen;
|
|
754
756
|
const shown = bootstrapResults.slice(0, maxMenuItems);
|
|
755
757
|
const nextHighlightedIndex = shown.length > 0 ? 0 : -1;
|
|
758
|
+
// A focus load that yields no choice, or fails (it arrives here empty),
|
|
759
|
+
// closes the list rather than leaving it open and empty. A typed
|
|
760
|
+
// query's empty search is not a focus load and keeps its empty-search
|
|
761
|
+
// message.
|
|
756
762
|
if (results.length === 0 && shown.length === 0 && highlightedIndex === -1) {
|
|
763
|
+
popover.hide();
|
|
757
764
|
return;
|
|
758
765
|
}
|
|
759
766
|
setHeldHeight(null);
|
|
@@ -761,14 +768,10 @@ export const BaseTypeahead = function BaseTypeahead({
|
|
|
761
768
|
setHighlightedIndex(nextHighlightedIndex);
|
|
762
769
|
if (bootstrapResults.length > 0) {
|
|
763
770
|
showLayer();
|
|
764
|
-
} else
|
|
765
|
-
// A Tokenizer list left with no eligible choice (its focus entries
|
|
766
|
-
// all committed, or the request failed) closes rather than staying
|
|
767
|
-
// open and empty (component:Tokenizer FR15). A plain Typeahead
|
|
768
|
-
// provides no committed choices and keeps its current behavior.
|
|
771
|
+
} else {
|
|
769
772
|
popover.hide();
|
|
770
773
|
}
|
|
771
|
-
}, [highlightedIndex, maxMenuItems, results.length, showLayer, replaceResults, popover
|
|
774
|
+
}, [highlightedIndex, maxMenuItems, results.length, showLayer, replaceResults, popover]);
|
|
772
775
|
|
|
773
776
|
// Perform bootstrap
|
|
774
777
|
const performBootstrap = useCallback(async () => {
|
|
@@ -1216,7 +1219,14 @@ export const BaseTypeahead = function BaseTypeahead({
|
|
|
1216
1219
|
readOnly: isFocusableDisabled || undefined,
|
|
1217
1220
|
autoFocus: hasAutoFocus,
|
|
1218
1221
|
"data-autofocus": hasAutoFocus || undefined,
|
|
1219
|
-
autoComplete: "off"
|
|
1222
|
+
autoComplete: "off"
|
|
1223
|
+
// Autocorrect would rewrite names and identifiers. The key is only a
|
|
1224
|
+
// label: Enter still commits the highlighted option.
|
|
1225
|
+
,
|
|
1226
|
+
...textEntryTraitAttributes({
|
|
1227
|
+
enterKeyHint: 'search',
|
|
1228
|
+
hasAutoCorrect: false
|
|
1229
|
+
}),
|
|
1220
1230
|
...mergeProps(stylex.props(styles.input, isDisabled && styles.inputDisabled, inputXStyle, xstyle), className, style)
|
|
1221
1231
|
}), isLoading && busyLane == null && /*#__PURE__*/_jsx("span", {
|
|
1222
1232
|
...{
|