@astryxdesign/core 0.7.6 → 0.7.7-canary.0eb44a2
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/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +1 -1
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +16 -9
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +2 -1
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +3 -2
- 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/DateInput/Wheel.d.ts +17 -1
- package/dist/DateInput/Wheel.d.ts.map +1 -1
- package/dist/DateInput/Wheel.js +179 -19
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +63 -49
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +37 -1
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +6 -0
- package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -1
- package/dist/Drawer/useDrawerDialogPresence.js +4 -0
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +20 -4
- 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 +365 -0
- package/dist/Layer/useTouchTrigger.d.ts +23 -1
- package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
- package/dist/Layer/useTouchTrigger.js +45 -7
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +2 -1
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +1 -0
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +56 -7
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +38 -30
- package/dist/ProgressBar/ProgressBar.d.ts +1 -1
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +52 -14
- 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/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +2 -1
- 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/Switch/Switch.d.ts +1 -1
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +200 -46
- package/dist/Switch/switchFill.d.ts +31 -0
- package/dist/Switch/switchFill.d.ts.map +1 -0
- package/dist/Switch/switchFill.js +88 -0
- package/dist/Switch/switchTouch.d.ts +81 -0
- package/dist/Switch/switchTouch.d.ts.map +1 -0
- package/dist/Switch/switchTouch.js +133 -0
- package/dist/Switch/useSwitchTouch.d.ts +285 -0
- package/dist/Switch/useSwitchTouch.d.ts.map +1 -0
- package/dist/Switch/useSwitchTouch.js +998 -0
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +4 -3
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +12 -5
- package/dist/Tokenizer/TokenizerItemRemovableContext.d.ts +3 -0
- package/dist/Tokenizer/TokenizerItemRemovableContext.d.ts.map +1 -0
- package/dist/Tokenizer/TokenizerItemRemovableContext.js +17 -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/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +26 -15
- package/dist/astryx.css +91 -8
- 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 +797 -15
- 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/PressTracker.d.ts +6 -0
- package/dist/gestures/PressTracker.d.ts.map +1 -1
- package/dist/gestures/PressTracker.js +3 -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 +17 -0
- package/dist/gestures/types.d.ts.map +1 -1
- package/dist/gestures/types.js +7 -0
- package/dist/gestures/usePressTracker.d.ts.map +1 -1
- package/dist/gestures/usePressTracker.js +1 -0
- package/dist/gestures/wheelSegmenter.d.ts +56 -0
- package/dist/gestures/wheelSegmenter.d.ts.map +1 -0
- package/dist/gestures/wheelSegmenter.js +122 -0
- package/dist/hooks/useAttachment.d.ts +16 -8
- package/dist/hooks/useAttachment.d.ts.map +1 -1
- package/dist/hooks/useAttachment.js +35 -15
- package/dist/hooks/useFocusTrap.d.ts +15 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +13 -2
- package/dist/hooks/usePager.d.ts +261 -0
- package/dist/hooks/usePager.d.ts.map +1 -0
- package/dist/hooks/usePager.js +1169 -0
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +140 -19
- package/dist/motion/paging.d.ts +69 -0
- package/dist/motion/paging.d.ts.map +1 -0
- package/dist/motion/paging.js +148 -0
- package/dist/motion/uikit/index.d.ts +8 -4
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +8 -4
- package/dist/motion/uikit/paging.d.ts +171 -0
- package/dist/motion/uikit/paging.d.ts.map +1 -0
- package/dist/motion/uikit/paging.js +192 -0
- package/dist/motion/uikit/progressBar.d.ts +79 -0
- package/dist/motion/uikit/progressBar.d.ts.map +1 -0
- package/dist/motion/uikit/progressBar.js +102 -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 +59 -30
- package/dist/motion/uikit/springs.d.ts.map +1 -1
- package/dist/motion/uikit/springs.js +64 -34
- package/dist/motion/uikit/switch.d.ts +166 -0
- package/dist/motion/uikit/switch.d.ts.map +1 -0
- package/dist/motion/uikit/switch.js +186 -0
- package/dist/privateAttributes/pressHoldsDrag.stylex.d.ts +18 -0
- package/dist/privateAttributes/pressHoldsDrag.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/pressHoldsDrag.stylex.js +28 -0
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +5 -0
- 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/Avatar/Avatar.tsx +3 -1
- package/src/BottomSheet/BottomSheetPanel.tsx +16 -9
- package/src/Breadcrumbs/BreadcrumbItem.tsx +4 -1
- package/src/Button/Button.tsx +3 -2
- 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/DateInput/Wheel.tsx +174 -14
- package/src/DateRangeInput/DateRangeInput.doc.mjs +3 -2
- package/src/DateRangeInput/DateRangeInput.tsx +117 -71
- package/src/Dialog/Dialog.tsx +37 -1
- package/src/Drawer/Drawer.tsx +6 -0
- package/src/Drawer/useDrawerDialogPresence.ts +4 -0
- package/src/DropdownMenu/DropdownMenu.tsx +28 -6
- 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 +516 -0
- package/src/Layer/useTouchTrigger.ts +56 -6
- package/src/Lightbox/Lightbox.tsx +2 -1
- package/src/Link/Link.tsx +3 -0
- package/src/Popover/usePopover.tsx +71 -9
- package/src/PowerSearch/PowerSearch.tsx +38 -31
- package/src/ProgressBar/ProgressBar.doc.mjs +7 -5
- package/src/ProgressBar/ProgressBar.tsx +147 -16
- package/src/ProgressBar/ProgressBarTouch.ts +109 -0
- package/src/SegmentedControl/SegmentedControlItem.tsx +2 -1
- 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/Switch/Switch.doc.mjs +3 -3
- package/src/Switch/Switch.tsx +412 -86
- package/src/Switch/switchFill.ts +106 -0
- package/src/Switch/switchTouch.ts +194 -0
- package/src/Switch/useSwitchTouch.ts +1121 -0
- package/src/TabList/Tab.tsx +5 -3
- package/src/Tokenizer/Tokenizer.tsx +15 -5
- package/src/Tokenizer/TokenizerItemRemovableContext.ts +22 -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/Typeahead/Typeahead.tsx +29 -15
- package/src/gestures/GestureArena.ts +45 -4
- package/src/gestures/GestureHost.ts +958 -15
- package/src/gestures/GestureRecognizer.ts +28 -0
- package/src/gestures/PanGestureRecognizer.ts +8 -0
- package/src/gestures/PinchGestureRecognizer.ts +16 -1
- package/src/gestures/PressTracker.ts +10 -0
- 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 +18 -0
- package/src/gestures/usePressTracker.ts +2 -0
- package/src/gestures/wheelSegmenter.ts +143 -0
- package/src/hooks/useAttachment.ts +56 -14
- package/src/hooks/useFocusTrap.ts +26 -2
- package/src/hooks/usePager.ts +1446 -0
- package/src/motion/MEASUREMENTS.md +36 -27
- package/src/motion/README.md +7 -3
- package/src/motion/animator.ts +193 -25
- package/src/motion/paging.ts +161 -0
- package/src/motion/uikit/index.ts +7 -4
- package/src/motion/uikit/paging.ts +193 -0
- package/src/motion/uikit/progressBar.ts +102 -0
- package/src/motion/uikit/scroll.ts +2 -18
- package/src/motion/uikit/slider.ts +105 -0
- package/src/motion/uikit/springs.ts +53 -32
- package/src/motion/uikit/switch.ts +174 -0
- package/src/privateAttributes/pressHoldsDrag.stylex.ts +28 -0
- package/src/utils/pressFeedback.ts +5 -0
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../src/TabList/Tab.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,EAAc,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAYzD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAO5C,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../src/TabList/Tab.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,EAAc,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAYzD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAO5C,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAQrD,MAAM,WAAW,QAAS,SAAQ,SAAS,CAAC,iBAAiB,CAAC;IAC5D;;;;OAIG;IACH,EAAE,CAAC,EAAE,iBAAiB,CAAC;IACvB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACnC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB;AA2KD;;;;;;;;;;;GAWG;AACH,wBAAgB,GAAG,CAAC,EAClB,EAAE,EACF,GAAG,EACH,KAAK,EACL,KAAK,EACL,aAAqB,EACrB,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,MAAM,EACN,SAAS,EACT,KAAK,EACL,OAAO,EACP,GAAG,SAAS,EACb,EAAE,QAAQ,qBAoLV;yBApMe,GAAG"}
|
package/dist/TabList/Tab.js
CHANGED
|
@@ -31,6 +31,7 @@ import { useDevWarning } from "../hooks/useDevWarning.js";
|
|
|
31
31
|
import { EDGE_COMP_ATTR } from "../Layout/edgeCompensation.stylex.js";
|
|
32
32
|
import { themeProps } from "../utils/themeProps.js";
|
|
33
33
|
import { focusOutlineProps } from "../utils/focusOutline.stylex.js";
|
|
34
|
+
import { isRenderable } from "../utils/isRenderable.js";
|
|
34
35
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
36
|
// =============================================================================
|
|
36
37
|
// Styles
|
|
@@ -190,7 +191,7 @@ export function Tab({
|
|
|
190
191
|
const isTabsPattern = tabListCtx.pattern === 'tabs';
|
|
191
192
|
const isLink = href != null && !isTabsPattern;
|
|
192
193
|
const isTabRole = isTabsPattern && !isLink;
|
|
193
|
-
const displayIcon = isSelected && selectedIcon ? selectedIcon : icon;
|
|
194
|
+
const displayIcon = isSelected && isRenderable(selectedIcon) ? selectedIcon : icon;
|
|
194
195
|
const hasVisibleLabel = !isLabelHidden && label !== '';
|
|
195
196
|
const isDisabled = restProps['aria-disabled'] === true || restProps['aria-disabled'] === 'true';
|
|
196
197
|
const handleSelect = useCallback(event => {
|
|
@@ -210,7 +211,7 @@ export function Tab({
|
|
|
210
211
|
const controls = panelId ?? restProps['aria-controls'];
|
|
211
212
|
useDevWarning('Tab', 'a tab in a role="tablist" TabList controls nothing: pass panelId with ' + 'the id of the panel it opens, so assistive technology can associate ' + 'the two.', isTabRole && controls == null);
|
|
212
213
|
useDevWarning('Tab', 'panelId does nothing outside a role="tablist" TabList — the navigation ' + 'pattern has no panel to associate. Give the TabList role="tablist", ' + 'or drop the panelId.', !isTabsPattern && panelId != null);
|
|
213
|
-
const iconElement = displayIcon ? /*#__PURE__*/_jsx("span", {
|
|
214
|
+
const iconElement = isRenderable(displayIcon) ? /*#__PURE__*/_jsx("span", {
|
|
214
215
|
...stylex.props(styles.icon, iconSizeStyles[size]),
|
|
215
216
|
children: displayIcon
|
|
216
217
|
}) : null;
|
|
@@ -284,7 +285,7 @@ export function Tab({
|
|
|
284
285
|
children: label
|
|
285
286
|
})]
|
|
286
287
|
}) : null;
|
|
287
|
-
const endContentElement = endContent ? /*#__PURE__*/_jsx("span", {
|
|
288
|
+
const endContentElement = isRenderable(endContent) ? /*#__PURE__*/_jsx("span", {
|
|
288
289
|
...{
|
|
289
290
|
className: "x3nfvp2 x6s0dn4 x2lah0s"
|
|
290
291
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tokenizer.d.ts","sourceRoot":"","sources":["../../src/Tokenizer/Tokenizer.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,EAYZ,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAUf,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Tokenizer.d.ts","sourceRoot":"","sources":["../../src/Tokenizer/Tokenizer.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,EAYZ,KAAK,SAAS,EAEf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C,EAAE,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;CACxC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,8BAA8B,CAAC,CAAC,SAAS,cAAc,IAAI,IAAI,CACzE,cAAc,CAAC,CAAC,CAAC,EACjB,KAAK,CACN,GAAG;IACF,8EAA8E;IAC9E,YAAY,CAAC,EAAE,4BAA4B,CAAC;IAC5C;;;OAGG;IACH,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,CAAC;CACvD,CAAC;AAmXF,wBAAgB,SAAS,CAAC,CAAC,SAAS,cAAc,EAChD,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GACvB,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;yBAFL,SAAS;;;AA+kCzB;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,EAAgB,CACpD,CAAC,SAAS,cAAc,EAExB,KAAK,EAAE,8BAA8B,CAAC,CAAC,CAAC,KACrC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
|
|
@@ -32,6 +32,7 @@ import { useFieldInputStyling } from "../Field/fieldParts.js";
|
|
|
32
32
|
import { inputDisabledFocusStyles } from "../Field/inputDisabledFocus.js";
|
|
33
33
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
34
34
|
import { TokenizerClearAllMessageContext } from "./TokenizerClearAllMessageContext.js";
|
|
35
|
+
import { TokenizerItemRemovableContext } from "./TokenizerItemRemovableContext.js";
|
|
35
36
|
import { useBusyAnnouncement } from "../hooks/useBusyAnnouncement.js";
|
|
36
37
|
import { useAdaptivePresentation } from "../hooks/useAdaptivePresentation.js";
|
|
37
38
|
import { useIsHydrating } from "../hooks/useIsHydrating.js";
|
|
@@ -57,6 +58,7 @@ import { themeProps } from "../utils/themeProps.js";
|
|
|
57
58
|
import { useResolvedRequired } from "../hooks/useResolvedRequired.js";
|
|
58
59
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
59
60
|
import english from "../i18n/generated-english/Tokenizer/Tokenizer.generated.js";
|
|
61
|
+
import { isRenderable } from "../utils/isRenderable.js";
|
|
60
62
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
61
63
|
registerEnglishFallback(english);
|
|
62
64
|
|
|
@@ -644,6 +646,11 @@ export function Tokenizer({
|
|
|
644
646
|
// `endContent`, a clear button, or all three — so its width is measured
|
|
645
647
|
// rather than assumed, and the input reserves it.
|
|
646
648
|
const [laneRef, laneReserve] = useEndLaneReserve(END_LANE_INSET);
|
|
649
|
+
// A composing component can lock tokens (PowerSearch's read-only field).
|
|
650
|
+
// Backspace and the token remove controls skip a locked token. Clear all
|
|
651
|
+
// does not check it.
|
|
652
|
+
const isItemRemovable = use(TokenizerItemRemovableContext);
|
|
653
|
+
const canRemoveItem = useCallback(item => isItemRemovable?.(item) ?? true, [isItemRemovable]);
|
|
647
654
|
// The half of the lane's contents this component knows about. The busy half
|
|
648
655
|
// is the leaf's own business — folding it in here would mean reading the
|
|
649
656
|
// busy state during this render, which is exactly the re-render the store
|
|
@@ -851,7 +858,7 @@ export function Tokenizer({
|
|
|
851
858
|
// input and the per-token remove buttons route through here, so the
|
|
852
859
|
// announcement covers both.
|
|
853
860
|
const handleRemove = useCallback((item, options) => {
|
|
854
|
-
if (isDisabled) {
|
|
861
|
+
if (isDisabled || !canRemoveItem(item)) {
|
|
855
862
|
return false;
|
|
856
863
|
}
|
|
857
864
|
const newItems = value.filter(v => v.id !== item.id);
|
|
@@ -866,7 +873,7 @@ export function Tokenizer({
|
|
|
866
873
|
}
|
|
867
874
|
inputRef.current?.focus();
|
|
868
875
|
return true;
|
|
869
|
-
}, [value, onChange, isDisabled, announce, t]);
|
|
876
|
+
}, [value, onChange, isDisabled, canRemoveItem, announce, t]);
|
|
870
877
|
|
|
871
878
|
// Handle clearing all items
|
|
872
879
|
// A composing component that words its own Clear all (PowerSearch) provides
|
|
@@ -966,7 +973,7 @@ export function Tokenizer({
|
|
|
966
973
|
status: status?.type,
|
|
967
974
|
disabled: isDisabled ? 'disabled' : null
|
|
968
975
|
}), stylex.props(inputWrapperStyles.base, styles.wrapper, value.length > 0 && styles.wrapperWithTokens, isTruncated ? truncatedSizeStyles[size] : sizeStyle, isTruncated && styles.truncatedWrapper, isDisabled && inputWrapperStyles.disabled, isDisabled && inputDisabledFocusStyles.nestedRing, status && inputStatusBorderStyles[status.type], status && !isDisabled && inputStatusHoverShadowStyles[status.type], status && inputStatusFocusWithinStyles[status.type], controlXstyle), controlClassName, controlStyle),
|
|
969
|
-
children: [startIcon && /*#__PURE__*/_jsx("span", {
|
|
976
|
+
children: [isRenderable(startIcon) && /*#__PURE__*/_jsx("span", {
|
|
970
977
|
...{
|
|
971
978
|
0: {},
|
|
972
979
|
1: {
|
|
@@ -1151,7 +1158,7 @@ export function Tokenizer({
|
|
|
1151
1158
|
// as Selector's bottom-sheet trigger does; the sheet's own rows
|
|
1152
1159
|
// and search field carry the touch-sized targets.
|
|
1153
1160
|
sizeStyles[size], value.length > 0 && styles.wrapperWithTokens, isDisabled && inputWrapperStyles.disabled, isDisabled && styles.sheetTriggerDisabled, status && inputStatusBorderStyles[status.type], status && !isDisabled && inputStatusHoverShadowStyles[status.type], status && inputStatusFocusWithinStyles[status.type], controlXstyle), controlClassName, controlStyle),
|
|
1154
|
-
children: [startIcon && /*#__PURE__*/_jsx("span", {
|
|
1161
|
+
children: [isRenderable(startIcon) && /*#__PURE__*/_jsx("span", {
|
|
1155
1162
|
...{
|
|
1156
1163
|
0: {},
|
|
1157
1164
|
1: {
|
|
@@ -1222,7 +1229,7 @@ export function Tokenizer({
|
|
|
1222
1229
|
disabled: isDisabled ? 'disabled' : null
|
|
1223
1230
|
}), stylex.props(inputWrapperStyles.base, styles.wrapper, value.length > 0 && styles.wrapperWithTokens, placeholderSizeStyle, isTruncated && styles.truncatedWrapper, isDisabled && inputWrapperStyles.disabled, status && inputStatusBorderStyles[status.type], status && !isDisabled && inputStatusHoverShadowStyles[status.type], status && inputStatusFocusWithinStyles[status.type], controlXstyle), controlClassName, controlStyle),
|
|
1224
1231
|
children: isTruncated && /*#__PURE__*/_jsxs(_Fragment, {
|
|
1225
|
-
children: [startIcon && renderIconSlot(startIcon, {
|
|
1232
|
+
children: [isRenderable(startIcon) && renderIconSlot(startIcon, {
|
|
1226
1233
|
size: 'sm',
|
|
1227
1234
|
color: 'secondary'
|
|
1228
1235
|
}), /*#__PURE__*/_jsx(OverflowList, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenizerItemRemovableContext.d.ts","sourceRoot":"","sources":["../../src/Tokenizer/TokenizerItemRemovableContext.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,6BAA6B,kCAChC,cAAc,KAAK,OAAO,SAC7B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file TokenizerItemRemovableContext.ts
|
|
7
|
+
* @input None
|
|
8
|
+
* @output A context carrying a predicate that tells which tokens the user can
|
|
9
|
+
* remove
|
|
10
|
+
* @position Internal to Core: not exported from the Tokenizer barrel. A
|
|
11
|
+
* component that composes Tokenizer and locks some tokens (PowerSearch: every
|
|
12
|
+
* filter of a read-only field) provides it. Backspace then removes nothing
|
|
13
|
+
* while the last token is locked. Without it, every token is removable.
|
|
14
|
+
*/
|
|
15
|
+
import { createContext } from 'react';
|
|
16
|
+
export const TokenizerItemRemovableContext = /*#__PURE__*/createContext(null);
|
|
17
|
+
TokenizerItemRemovableContext.displayName = 'TokenizerItemRemovableContext';
|
|
@@ -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;;;;;;;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AC;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,CAA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AAmB,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,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,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
|
...{
|