@astryxdesign/core 0.7.7-canary.550ff21 → 0.7.7-canary.559b005
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/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +1 -1
- 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/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 +49 -12
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +15 -10
- 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/InfoTip/InfoTip.d.ts +63 -0
- package/dist/InfoTip/InfoTip.d.ts.map +1 -0
- package/dist/InfoTip/InfoTip.js +126 -0
- package/dist/InfoTip/index.d.ts +10 -0
- package/dist/InfoTip/index.d.ts.map +1 -0
- package/dist/InfoTip/index.js +12 -0
- 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/useBackdropPress.d.ts +27 -0
- package/dist/Layer/useBackdropPress.d.ts.map +1 -0
- package/dist/Layer/useBackdropPress.js +53 -0
- 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/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 +33 -6
- package/dist/SegmentedControl/SegmentedControl.d.ts +3 -1
- package/dist/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControl.js +115 -8
- package/dist/SegmentedControl/SegmentedControlContext.d.ts +6 -0
- package/dist/SegmentedControl/SegmentedControlContext.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.d.ts +1 -0
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +10 -2
- package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts +357 -0
- package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts.map +1 -0
- package/dist/SegmentedControl/useSegmentedSelectionMotion.js +1349 -0
- package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts +70 -0
- package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts.map +1 -0
- package/dist/SegmentedControl/useSegmentedTouchTracking.js +264 -0
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +96 -67
- package/dist/Selector/optionShape.d.ts +24 -0
- package/dist/Selector/optionShape.d.ts.map +1 -0
- package/dist/Selector/optionShape.js +48 -0
- package/dist/Selector/selectableOptionEntries.d.ts +20 -0
- package/dist/Selector/selectableOptionEntries.d.ts.map +1 -0
- package/dist/Selector/selectableOptionEntries.js +38 -0
- package/dist/Selector/utils.d.ts +2 -17
- package/dist/Selector/utils.d.ts.map +1 -1
- package/dist/Selector/utils.js +3 -51
- 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 +74 -0
- package/dist/Switch/switchTouch.d.ts.map +1 -0
- package/dist/Switch/switchTouch.js +125 -0
- package/dist/Switch/useSwitchTouch.d.ts +276 -0
- package/dist/Switch/useSwitchTouch.d.ts.map +1 -0
- package/dist/Switch/useSwitchTouch.js +939 -0
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +4 -3
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +5 -0
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +1 -0
- 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/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +26 -15
- package/dist/astryx.css +125 -2
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +71 -14
- 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/types.d.ts +6 -0
- package/dist/gestures/types.d.ts.map +1 -1
- package/dist/gestures/usePressTracker.d.ts.map +1 -1
- package/dist/gestures/usePressTracker.js +1 -0
- package/dist/gestures/wheelSegmenter.d.ts +14 -3
- package/dist/gestures/wheelSegmenter.d.ts.map +1 -1
- package/dist/gestures/wheelSegmenter.js +32 -8
- package/dist/hooks/actionGroupTracker.d.ts +3 -3
- package/dist/hooks/actionGroupTracker.d.ts.map +1 -1
- package/dist/hooks/actionGroupTracker.js +6 -53
- 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/useHighlightedOptionScroll.d.ts.map +1 -1
- package/dist/hooks/useHighlightedOptionScroll.js +14 -11
- package/dist/hooks/useMediaQuery.d.ts +2 -1
- package/dist/hooks/useMediaQuery.d.ts.map +1 -1
- package/dist/hooks/useMediaQuery.js +7 -4
- 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/i18n/generated-english/InfoTip/InfoTip.generated.d.ts +8 -0
- package/dist/i18n/generated-english/InfoTip/InfoTip.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/InfoTip/InfoTip.generated.js +12 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +2 -1
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/motion/paging.d.ts +16 -5
- package/dist/motion/paging.d.ts.map +1 -1
- package/dist/motion/paging.js +34 -14
- package/dist/motion/roles.d.ts +7 -1
- package/dist/motion/roles.d.ts.map +1 -1
- package/dist/motion/roles.js +20 -1
- package/dist/motion/uikit/index.d.ts +7 -4
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +7 -4
- package/dist/motion/uikit/paging.d.ts +31 -20
- package/dist/motion/uikit/paging.d.ts.map +1 -1
- package/dist/motion/uikit/paging.js +41 -11
- package/dist/motion/uikit/progressBar.d.ts +27 -7
- package/dist/motion/uikit/progressBar.d.ts.map +1 -1
- package/dist/motion/uikit/progressBar.js +31 -11
- package/dist/motion/uikit/segmented.d.ts +55 -0
- package/dist/motion/uikit/segmented.d.ts.map +1 -0
- package/dist/motion/uikit/segmented.js +77 -0
- package/dist/motion/uikit/springs.d.ts +8 -42
- package/dist/motion/uikit/springs.d.ts.map +1 -1
- package/dist/motion/uikit/springs.js +12 -42
- 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/privateAttributes/segmentTitle.stylex.d.ts +5 -0
- package/dist/privateAttributes/segmentTitle.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/segmentTitle.stylex.js +22 -0
- package/dist/utils/browserClickWait.d.ts +35 -0
- package/dist/utils/browserClickWait.d.ts.map +1 -0
- package/dist/utils/browserClickWait.js +123 -0
- package/dist/utils/clickGuard.d.ts +7 -1
- package/dist/utils/clickGuard.d.ts.map +1 -1
- package/dist/utils/clickGuard.js +23 -1
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +5 -0
- package/locales/en.json +4 -0
- package/locales/pseudo.json +3 -0
- package/package.json +9 -4
- package/src/Avatar/Avatar.tsx +3 -1
- package/src/Breadcrumbs/BreadcrumbItem.tsx +4 -1
- package/src/Button/Button.tsx +3 -2
- 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 +62 -11
- package/src/Drawer/Drawer.tsx +27 -10
- package/src/Drawer/useDrawerDialogPresence.ts +4 -0
- package/src/DropdownMenu/DropdownMenu.tsx +28 -6
- package/src/InfoTip/InfoTip.doc.mjs +192 -0
- package/src/InfoTip/InfoTip.tsx +186 -0
- package/src/InfoTip/index.ts +14 -0
- package/src/Layer/layerClickBoundary.ts +2 -2
- package/src/Layer/useBackdropPress.ts +81 -0
- package/src/Layer/usePressPin.ts +516 -0
- package/src/Layer/useTouchTrigger.ts +56 -6
- package/src/Lightbox/Lightbox.tsx +2 -1
- package/src/Popover/usePopover.tsx +71 -9
- package/src/PowerSearch/PowerSearch.tsx +38 -31
- package/src/ProgressBar/ProgressBar.doc.mjs +4 -2
- package/src/ProgressBar/ProgressBar.tsx +67 -7
- package/src/SegmentedControl/SegmentedControl.doc.mjs +3 -3
- package/src/SegmentedControl/SegmentedControl.tsx +179 -5
- package/src/SegmentedControl/SegmentedControlContext.ts +6 -0
- package/src/SegmentedControl/SegmentedControlItem.tsx +14 -2
- package/src/SegmentedControl/useSegmentedSelectionMotion.ts +1637 -0
- package/src/SegmentedControl/useSegmentedTouchTracking.ts +308 -0
- package/src/Selector/Selector.tsx +136 -89
- package/src/Selector/optionShape.ts +64 -0
- package/src/Selector/selectableOptionEntries.ts +39 -0
- package/src/Selector/utils.ts +9 -68
- 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 +186 -0
- package/src/Switch/useSwitchTouch.ts +1051 -0
- package/src/TabList/Tab.tsx +5 -3
- package/src/Toast/Toast.tsx +5 -0
- package/src/Token/Token.tsx +2 -0
- 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/Typeahead.tsx +29 -15
- package/src/gestures/GestureHost.ts +100 -11
- package/src/gestures/PressTracker.ts +10 -0
- package/src/gestures/types.ts +6 -0
- package/src/gestures/usePressTracker.ts +2 -0
- package/src/gestures/wheelSegmenter.ts +36 -7
- package/src/hooks/actionGroupTracker.ts +12 -56
- package/src/hooks/useAttachment.ts +56 -14
- package/src/hooks/useFocusTrap.ts +26 -2
- package/src/hooks/useHighlightedOptionScroll.ts +15 -11
- package/src/hooks/useMediaQuery.doc.mjs +2 -2
- package/src/hooks/useMediaQuery.ts +13 -4
- package/src/hooks/usePager.ts +1446 -0
- package/src/i18n/generated-english/InfoTip/InfoTip.generated.ts +13 -0
- package/src/i18n/generated-locales/en.generated.ts +1 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +1 -0
- package/src/index.ts +1 -0
- package/src/motion/MEASUREMENTS.md +36 -27
- package/src/motion/README.md +3 -1
- package/src/motion/paging.ts +37 -14
- package/src/motion/roles.ts +20 -1
- package/src/motion/uikit/index.ts +6 -5
- package/src/motion/uikit/paging.ts +41 -10
- package/src/motion/uikit/progressBar.ts +31 -11
- package/src/motion/uikit/segmented.ts +74 -0
- package/src/motion/uikit/springs.ts +12 -42
- package/src/motion/uikit/switch.ts +174 -0
- package/src/privateAttributes/pressHoldsDrag.stylex.ts +28 -0
- package/src/privateAttributes/segmentTitle.stylex.ts +22 -0
- package/src/utils/browserClickWait.ts +133 -0
- package/src/utils/clickGuard.ts +28 -1
- package/src/utils/pressFeedback.ts +5 -0
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import React, {useCallback, useEffect, useRef, type ReactNode} from 'react';
|
|
20
20
|
import * as stylex from '@stylexjs/stylex';
|
|
21
21
|
import {useLayer, type ContextRenderProps} from '../Layer/useLayer';
|
|
22
|
-
import {
|
|
22
|
+
import {useFocusTrapInternal} from '../hooks/useFocusTrap';
|
|
23
23
|
import {LayerDepthProvider} from '../Layer/LayerDepthContext';
|
|
24
24
|
import type {StyleXStyles} from '@stylexjs/stylex';
|
|
25
25
|
import {
|
|
@@ -34,6 +34,7 @@ import {rtlStyles} from '../utils';
|
|
|
34
34
|
import {useDevWarning} from '../hooks/useDevWarning';
|
|
35
35
|
import {focusOutlineProps} from '../utils/focusOutline.stylex';
|
|
36
36
|
import {mergeProps} from '../utils/mergeProps';
|
|
37
|
+
import {isFocusDetached} from '../utils/focusReturn';
|
|
37
38
|
import {themeProps} from '../utils/themeProps';
|
|
38
39
|
import {paddingStyles} from '../Layout/padding.stylex';
|
|
39
40
|
import type {SpacingStep} from '../utils/types';
|
|
@@ -422,28 +423,51 @@ function usePopoverImplementation(
|
|
|
422
423
|
|
|
423
424
|
// Track whether to skip auto-focus for the current open event
|
|
424
425
|
const skipAutoFocusRef = useRef(false);
|
|
426
|
+
// Whether `show` focused a content control within the opening event.
|
|
427
|
+
const hasFocusedInGestureRef = useRef(false);
|
|
428
|
+
|
|
429
|
+
// Set when the layer reports it has shown, so `show` can tell a popover
|
|
430
|
+
// that opened within the call from one whose content mounts later.
|
|
431
|
+
const hasShownRef = useRef(false);
|
|
432
|
+
const handleLayerShow = useCallback(() => {
|
|
433
|
+
hasShownRef.current = true;
|
|
434
|
+
onShow?.();
|
|
435
|
+
}, [onShow]);
|
|
425
436
|
|
|
426
437
|
// Core layer for popover positioning
|
|
427
438
|
const layer = useLayer({
|
|
428
439
|
mode: 'context',
|
|
429
440
|
lightDismiss: hasLightDismiss,
|
|
430
|
-
onShow,
|
|
441
|
+
onShow: handleLayerShow,
|
|
431
442
|
onHide,
|
|
432
443
|
});
|
|
433
444
|
|
|
434
445
|
// Focus trap for the popover content. Escape stays registered while light
|
|
435
446
|
// dismiss is on (native popover="auto" closes on Escape regardless), so a
|
|
436
447
|
// host Dialog keeps deferring to this trap instead of double-dismissing.
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
448
|
+
// The element focused when `show` ran: initial focus may move inside before
|
|
449
|
+
// the trap activates, so the trap restores focus here instead.
|
|
450
|
+
const openerRef = useRef<HTMLElement | null>(null);
|
|
451
|
+
const getRestoreTarget = useCallback(() => openerRef.current, []);
|
|
452
|
+
const {containerRef: contentRef, focusFirst} =
|
|
453
|
+
useFocusTrapInternal<HTMLDivElement>({
|
|
454
|
+
isActive: layer.isOpen,
|
|
455
|
+
onEscape: hasEscapeDismiss || hasLightDismiss ? layer.hide : undefined,
|
|
456
|
+
getRestoreTarget,
|
|
457
|
+
});
|
|
441
458
|
|
|
442
459
|
const focusInitialTarget = useCallback(() => {
|
|
443
460
|
const container = contentRef.current;
|
|
444
461
|
if (!container) {
|
|
445
462
|
return;
|
|
446
463
|
}
|
|
464
|
+
// Focus already on a control inside (set in `onShow`, or a press in the
|
|
465
|
+
// content) is where the user or the caller wants it; moving it would
|
|
466
|
+
// undo that.
|
|
467
|
+
const active = container.ownerDocument.activeElement;
|
|
468
|
+
if (active != null && active !== container && container.contains(active)) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
447
471
|
if (focusFirstContentControl(container)) {
|
|
448
472
|
return;
|
|
449
473
|
}
|
|
@@ -459,16 +483,23 @@ function usePopoverImplementation(
|
|
|
459
483
|
// Reset the per-open focus preference after the popover closes.
|
|
460
484
|
if (!layer.isOpen) {
|
|
461
485
|
skipAutoFocusRef.current = false;
|
|
486
|
+
hasFocusedInGestureRef.current = false;
|
|
462
487
|
return;
|
|
463
488
|
}
|
|
464
489
|
if (hasAutoFocus && !skipAutoFocusRef.current) {
|
|
465
490
|
// Wait a frame so the content is mounted. A popover that closes or
|
|
466
491
|
// unmounts first cancels it: the frame would otherwise move focus into
|
|
467
492
|
// content that is no longer shown, after the close had left it alone.
|
|
468
|
-
const frame = requestAnimationFrame(
|
|
493
|
+
const frame = requestAnimationFrame(() => {
|
|
494
|
+
const doc = contentRef.current?.ownerDocument ?? document;
|
|
495
|
+
if (hasFocusedInGestureRef.current && !isFocusDetached(doc)) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
focusInitialTarget();
|
|
499
|
+
});
|
|
469
500
|
return () => cancelAnimationFrame(frame);
|
|
470
501
|
}
|
|
471
|
-
}, [layer.isOpen, hasAutoFocus, focusInitialTarget]);
|
|
502
|
+
}, [layer.isOpen, hasAutoFocus, focusInitialTarget, contentRef]);
|
|
472
503
|
|
|
473
504
|
// Combined ref for trigger element (layer anchor + our ref). It is keyed on
|
|
474
505
|
// the layer's own ref, not the whole layer: the layer object changes with
|
|
@@ -490,9 +521,40 @@ function usePopoverImplementation(
|
|
|
490
521
|
const show = useCallback(
|
|
491
522
|
(showOptions?: {skipAutoFocus?: boolean}) => {
|
|
492
523
|
skipAutoFocusRef.current = showOptions?.skipAutoFocus ?? false;
|
|
524
|
+
hasShownRef.current = false;
|
|
525
|
+
const activeElement = (
|
|
526
|
+
triggerElementRef.current?.ownerDocument ?? document
|
|
527
|
+
).activeElement as HTMLElement | null;
|
|
528
|
+
openerRef.current =
|
|
529
|
+
activeElement != null && !contentRef.current?.contains(activeElement)
|
|
530
|
+
? activeElement
|
|
531
|
+
: null;
|
|
493
532
|
layer.show();
|
|
533
|
+
// When the content is already mounted, the layer shows it within this
|
|
534
|
+
// call, so initial focus lands within the event that opened it: iOS
|
|
535
|
+
// raises its keyboard only for a focus made while the tap is still
|
|
536
|
+
// being handled. The frame in the effect above stays for content that
|
|
537
|
+
// mounts later.
|
|
538
|
+
// Only a content control already rendered takes focus here; content
|
|
539
|
+
// that renders on open (and the dialog-surface fallback) waits for the
|
|
540
|
+
// effect's frame.
|
|
541
|
+
const container = contentRef.current;
|
|
542
|
+
if (
|
|
543
|
+
hasShownRef.current &&
|
|
544
|
+
hasAutoFocus &&
|
|
545
|
+
!skipAutoFocusRef.current &&
|
|
546
|
+
container != null &&
|
|
547
|
+
!container.contains(container.ownerDocument.activeElement) &&
|
|
548
|
+
focusFirstContentControl(container)
|
|
549
|
+
) {
|
|
550
|
+
// Initial focus is done. The effect's frame stays only as a fallback
|
|
551
|
+
// for focus lost to the page (content swapped in the same handler
|
|
552
|
+
// unmounts the control just focused); it must not move focus the user
|
|
553
|
+
// has since moved elsewhere.
|
|
554
|
+
hasFocusedInGestureRef.current = true;
|
|
555
|
+
}
|
|
494
556
|
},
|
|
495
|
-
[layer],
|
|
557
|
+
[layer, hasAutoFocus, contentRef],
|
|
496
558
|
);
|
|
497
559
|
|
|
498
560
|
// Toggle function. Opening delegates to show so every route inherits the
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
type TokenizerOverflowBehavior,
|
|
32
32
|
} from '../Tokenizer';
|
|
33
33
|
import {TokenizerClearAllMessageContext} from '../Tokenizer/TokenizerClearAllMessageContext';
|
|
34
|
+
import {TokenizerItemRemovableContext} from '../Tokenizer/TokenizerItemRemovableContext';
|
|
34
35
|
import {TypeaheadItem} from '../Typeahead/TypeaheadItem';
|
|
35
36
|
import {Token} from '../Token';
|
|
36
37
|
import {Avatar} from '../Avatar';
|
|
@@ -751,6 +752,10 @@ export function PowerSearch({
|
|
|
751
752
|
[config, filters, onChange, setPopoverState],
|
|
752
753
|
);
|
|
753
754
|
|
|
755
|
+
// Tokenizer's Backspace does not go through renderToken. This predicate
|
|
756
|
+
// locks every token of a read-only field.
|
|
757
|
+
const isItemRemovable = useCallback(() => !isReadOnly, [isReadOnly]);
|
|
758
|
+
|
|
754
759
|
// Handle clicking a token to edit
|
|
755
760
|
const handleTokenClick = useCallback(
|
|
756
761
|
(index: number) => {
|
|
@@ -1117,37 +1122,39 @@ export function PowerSearch({
|
|
|
1117
1122
|
{/* The field's Clear all announces PowerSearch's own words
|
|
1118
1123
|
(component:PowerSearch; component:Tokenizer AR7). */}
|
|
1119
1124
|
<TokenizerClearAllMessageContext value={clearAllMessage}>
|
|
1120
|
-
<
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1125
|
+
<TokenizerItemRemovableContext value={isItemRemovable}>
|
|
1126
|
+
<Tokenizer
|
|
1127
|
+
handleRef={tokenizerRef}
|
|
1128
|
+
label={label}
|
|
1129
|
+
isLabelHidden={isLabelHidden}
|
|
1130
|
+
searchSource={searchSource}
|
|
1131
|
+
value={tokenizerValue}
|
|
1132
|
+
onChange={handleTokenizerChange}
|
|
1133
|
+
renderToken={renderToken}
|
|
1134
|
+
renderItem={renderItem}
|
|
1135
|
+
maxMenuItems={MAX_BROWSE_MENU_ITEMS}
|
|
1136
|
+
menuWidth={menuWidth}
|
|
1137
|
+
placeholder={filters.length === 0 ? placeholder : ''}
|
|
1138
|
+
hasAutoFocus={hasAutoFocus}
|
|
1139
|
+
hasClear={hasClear && !isReadOnly}
|
|
1140
|
+
startIcon={startIcon}
|
|
1141
|
+
endContent={combinedEndContent}
|
|
1142
|
+
isDisabled={isDisabled}
|
|
1143
|
+
disabledMessage={disabledMessage}
|
|
1144
|
+
size={size}
|
|
1145
|
+
tokenOverflowBehavior={tokenOverflowBehavior}
|
|
1146
|
+
hasEntriesOnFocus
|
|
1147
|
+
debounceMs={0}
|
|
1148
|
+
status={status}
|
|
1149
|
+
statusVariant={statusVariant}
|
|
1150
|
+
onFocus={onFocus}
|
|
1151
|
+
onBlur={onBlur}
|
|
1152
|
+
containerXstyle={xstyle}
|
|
1153
|
+
containerClassName={className}
|
|
1154
|
+
containerStyle={style}
|
|
1155
|
+
data-testid={testId}
|
|
1156
|
+
/>
|
|
1157
|
+
</TokenizerItemRemovableContext>
|
|
1151
1158
|
</TokenizerClearAllMessageContext>
|
|
1152
1159
|
</div>
|
|
1153
1160
|
{popover.render(popoverContent, {
|
|
@@ -101,7 +101,8 @@ export const docs = {
|
|
|
101
101
|
{
|
|
102
102
|
name: 'isIndeterminate',
|
|
103
103
|
type: 'boolean',
|
|
104
|
-
description:
|
|
104
|
+
description:
|
|
105
|
+
'Animated loading indicator for unknown progress. Under reduced motion it pulses in place instead of sliding.',
|
|
105
106
|
default: 'false',
|
|
106
107
|
},
|
|
107
108
|
{
|
|
@@ -390,7 +391,8 @@ export const docsDense = {
|
|
|
390
391
|
formatValueLabel:
|
|
391
392
|
'Custom value label formatter; defaults to percentage string.',
|
|
392
393
|
variant: 'Semantic color variant.',
|
|
393
|
-
isIndeterminate:
|
|
394
|
+
isIndeterminate:
|
|
395
|
+
'Animated loading indicator for unknown progress. Under reduced motion it pulses in place instead of sliding.',
|
|
394
396
|
marks:
|
|
395
397
|
'Fixed target marks ({value, label?}) drawn on the track in the 0..max scale; stay visible past the fill. Marks inside the fill take the variant on-color; marks on the bare track take the primary text color (secondary when disabled). A label reveals a tooltip on hover/focus. Ignored when indeterminate.',
|
|
396
398
|
isDisabled: 'Visually disabled: grays out fill and text.',
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file ProgressBar.tsx
|
|
7
|
-
* @input Uses React, useId, stylex, tokens and
|
|
7
|
+
* @input Uses React, useId, stylex, tokens, ProgressBarTouch and resolveMotion
|
|
8
8
|
* @output Exports ProgressBar component, ProgressBarProps, ProgressBarVariant types
|
|
9
9
|
* @position Core implementation; consumed by index.ts
|
|
10
10
|
*
|
|
@@ -36,6 +36,10 @@ import {themeProps} from '../utils/themeProps';
|
|
|
36
36
|
import {VisuallyHidden} from '../VisuallyHidden';
|
|
37
37
|
import type {ProgressBarVariantMap} from './index';
|
|
38
38
|
import {useProgressBarTouch} from './ProgressBarTouch';
|
|
39
|
+
import {formatMotionRoleValue} from '../motion/roles';
|
|
40
|
+
import {resolveMotion} from '../motion/resolveMotion';
|
|
41
|
+
import {progressBar} from '../motion/uikit/progressBar';
|
|
42
|
+
import {timing} from '../motion/uikit/timing';
|
|
39
43
|
|
|
40
44
|
// Every mark is wrapped in a Tooltip (marks always carry a label), so load it
|
|
41
45
|
// lazily: a ProgressBar with no marks never bundles the Tooltip chunk. While it
|
|
@@ -117,7 +121,7 @@ export interface ProgressBarProps extends BaseProps<HTMLDivElement> {
|
|
|
117
121
|
* When true, renders an animated indeterminate progress indicator.
|
|
118
122
|
* Use when the progress amount is unknown (e.g. loading, processing).
|
|
119
123
|
* The `value` and `hasValueLabel` props are ignored in this mode.
|
|
120
|
-
*
|
|
124
|
+
* Under reduced motion it pulses in place instead of sliding.
|
|
121
125
|
* @default false
|
|
122
126
|
*/
|
|
123
127
|
isIndeterminate?: boolean;
|
|
@@ -170,6 +174,19 @@ const indeterminateSlideRtl = stylex.keyframes({
|
|
|
170
174
|
},
|
|
171
175
|
});
|
|
172
176
|
|
|
177
|
+
// Under reduced motion the indeterminate fill stops travelling and pulses in
|
|
178
|
+
// place. It goes from full opacity down to the pulse's floor
|
|
179
|
+
// (`--_progress-bar-pulse-floor`, the progress table's) and back. The
|
|
180
|
+
// animation alternates direction each pass.
|
|
181
|
+
const indeterminatePulse = stylex.keyframes({
|
|
182
|
+
from: {
|
|
183
|
+
opacity: 1,
|
|
184
|
+
},
|
|
185
|
+
to: {
|
|
186
|
+
opacity: 'var(--_progress-bar-pulse-floor)',
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
|
|
173
190
|
// =============================================================================
|
|
174
191
|
// Styles
|
|
175
192
|
// =============================================================================
|
|
@@ -266,7 +283,6 @@ const styles = stylex.create({
|
|
|
266
283
|
default: '100%',
|
|
267
284
|
'@media (forced-colors: active)': {
|
|
268
285
|
default: 'var(--_progress-bar-fill, 0%)',
|
|
269
|
-
// Under a finger: the touch minimum and the flip offset (below).
|
|
270
286
|
'@media (pointer: coarse)':
|
|
271
287
|
'calc(max(var(--_progress-bar-fill, 0%), var(--_progress-bar-min, 0px)) + var(--_progress-bar-flip, 0) * 0.01px)',
|
|
272
288
|
},
|
|
@@ -353,17 +369,37 @@ const styles = stylex.create({
|
|
|
353
369
|
'@media (forced-colors: active)': 'CanvasText',
|
|
354
370
|
},
|
|
355
371
|
outlineOffset: {default: null, '@media (forced-colors: active)': '-1px'},
|
|
356
|
-
|
|
372
|
+
// Under reduced motion, on every pointer, the fill spans the whole track
|
|
373
|
+
// as one solid bar, and only its opacity pulses. Each way takes the
|
|
374
|
+
// `progress.reducedMotionPulseMs` role on the `timing.curves.move` curve
|
|
375
|
+
// (`--_progress-bar-pulse`, `--_progress-bar-pulse-curve`, set inline from
|
|
376
|
+
// the progress table). A busy loop: tempo does not scale it.
|
|
377
|
+
width: {
|
|
378
|
+
default: '40%',
|
|
379
|
+
'@media (prefers-reduced-motion: reduce)': '100%',
|
|
380
|
+
},
|
|
357
381
|
borderRadius: radiusVars['--radius-full'],
|
|
358
382
|
animationName: {
|
|
359
383
|
default: indeterminateSlide,
|
|
360
|
-
':is([dir="rtl"] *)':
|
|
384
|
+
':is([dir="rtl"] *)': {
|
|
385
|
+
default: indeterminateSlideRtl,
|
|
386
|
+
'@media (prefers-reduced-motion: reduce)': indeterminatePulse,
|
|
387
|
+
},
|
|
388
|
+
'@media (prefers-reduced-motion: reduce)': indeterminatePulse,
|
|
361
389
|
},
|
|
362
390
|
animationDuration: {
|
|
363
391
|
default: '1.5s',
|
|
364
|
-
'@media (prefers-reduced-motion: reduce)': '
|
|
392
|
+
'@media (prefers-reduced-motion: reduce)': 'var(--_progress-bar-pulse)',
|
|
393
|
+
},
|
|
394
|
+
animationTimingFunction: {
|
|
395
|
+
default: 'ease-in-out',
|
|
396
|
+
'@media (prefers-reduced-motion: reduce)':
|
|
397
|
+
'var(--_progress-bar-pulse-curve)',
|
|
398
|
+
},
|
|
399
|
+
animationDirection: {
|
|
400
|
+
default: null,
|
|
401
|
+
'@media (prefers-reduced-motion: reduce)': 'alternate',
|
|
365
402
|
},
|
|
366
|
-
animationTimingFunction: 'ease-in-out',
|
|
367
403
|
animationIterationCount: 'infinite',
|
|
368
404
|
},
|
|
369
405
|
// A mark is a vertical tick centered on the track via their shared positioning container.
|
|
@@ -474,6 +510,15 @@ const markOnTrackStyles = stylex.create({
|
|
|
474
510
|
},
|
|
475
511
|
});
|
|
476
512
|
|
|
513
|
+
// The reduced-motion pulse's variables, from the progress table.
|
|
514
|
+
type PulseStyle = CSSProperties &
|
|
515
|
+
Record<
|
|
516
|
+
| '--_progress-bar-pulse'
|
|
517
|
+
| '--_progress-bar-pulse-curve'
|
|
518
|
+
| '--_progress-bar-pulse-floor',
|
|
519
|
+
string
|
|
520
|
+
>;
|
|
521
|
+
|
|
477
522
|
// `CSSProperties` has no index signature for custom properties, so the fill's
|
|
478
523
|
// inline style — which publishes the filled share as the private
|
|
479
524
|
// `--_progress-bar-fill` — needs this augmentation to typecheck.
|
|
@@ -487,6 +532,20 @@ type FillStyle = CSSProperties &
|
|
|
487
532
|
string
|
|
488
533
|
>;
|
|
489
534
|
|
|
535
|
+
/**
|
|
536
|
+
* The reduced-motion pulse plays the `progress.reducedMotionPulseMs` role on
|
|
537
|
+
* the `timing.curves.move` curve, down to the progress table's floor.
|
|
538
|
+
*/
|
|
539
|
+
function pulseStyle(element: Element | null): PulseStyle {
|
|
540
|
+
const pulseMs = resolveMotion(element, progressBar, 'reducedMotionPulseMs');
|
|
541
|
+
const curve = resolveMotion(element, timing.curves.move);
|
|
542
|
+
return {
|
|
543
|
+
'--_progress-bar-pulse': `${pulseMs}ms`,
|
|
544
|
+
'--_progress-bar-pulse-curve': formatMotionRoleValue('curve', curve),
|
|
545
|
+
'--_progress-bar-pulse-floor': String(progressBar.reducedMotionPulseFloor),
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
|
|
490
549
|
function defaultFormatValueLabel(value: number, max: number): string {
|
|
491
550
|
const pct = max > 0 ? Math.round((value / max) * 100) : 0;
|
|
492
551
|
return `${pct}%`;
|
|
@@ -662,6 +721,7 @@ export function ProgressBar({
|
|
|
662
721
|
variantStyles[fillVariant],
|
|
663
722
|
),
|
|
664
723
|
)}
|
|
724
|
+
style={pulseStyle(null)}
|
|
665
725
|
/>
|
|
666
726
|
) : (
|
|
667
727
|
<div
|
|
@@ -168,7 +168,7 @@ function WorkspaceCard() {
|
|
|
168
168
|
usage: {
|
|
169
169
|
anatomy,
|
|
170
170
|
description:
|
|
171
|
-
'A segmented button group that allows users to make a single selection from a small set of mutually exclusive options. Use SegmentedControl when all options should be visible at once and the selection controls a value or mode, not page navigation.',
|
|
171
|
+
'A segmented button group that allows users to make a single selection from a small set of mutually exclusive options. Use SegmentedControl when all options should be visible at once and the selection controls a value or mode, not page navigation. Under a finger, on a touch device (a coarse primary pointer), the selection slides to the new segment, whether a tap, an arrow key or a new value moved it; with Reduce Motion nothing travels: the old selection fades out as the new one fades in. There, dragging the selected segment carries the selection along with the selected label’s colour following it, and the segment under the finger is chosen when it lets go (letting go outside the control selects nothing); a tap selects through the browser’s click; a pressed segment shows the shared pressed overlay, and nothing lifts or dims. With a mouse or a pen every change, a click included, slides on the theme’s duration and easing, and dragging the selected segment carries it as a finger does.',
|
|
172
172
|
accessibility: [
|
|
173
173
|
{
|
|
174
174
|
name: 'Text label',
|
|
@@ -240,7 +240,7 @@ export const docsZh = {
|
|
|
240
240
|
usage: {
|
|
241
241
|
anatomy,
|
|
242
242
|
description:
|
|
243
|
-
'A segmented button group that allows users to make a single selection from a small set of mutually exclusive options. Use SegmentedControl when all options should be visible at once and the selection controls a value or mode, not page navigation.',
|
|
243
|
+
'A segmented button group that allows users to make a single selection from a small set of mutually exclusive options. Use SegmentedControl when all options should be visible at once and the selection controls a value or mode, not page navigation. Under a finger, on a touch device (a coarse primary pointer), the selection slides to the new segment, whether a tap, an arrow key or a new value moved it; with Reduce Motion nothing travels: the old selection fades out as the new one fades in. There, dragging the selected segment carries the selection along with the selected label’s colour following it, and the segment under the finger is chosen when it lets go (letting go outside the control selects nothing); a tap selects through the browser’s click; a pressed segment shows the shared pressed overlay, and nothing lifts or dims. With a mouse or a pen every change, a click included, slides on the theme’s duration and easing, and dragging the selected segment carries it as a finger does.',
|
|
244
244
|
bestPractices: [
|
|
245
245
|
{guidance: true, description: 'Use for switching between 2–5 mutually exclusive views or modes where all options should be visible.'},
|
|
246
246
|
{guidance: true, description: 'Provide a descriptive label for the control to ensure the group is accessible to screen readers.'},
|
|
@@ -256,7 +256,7 @@ export const docsDense = {
|
|
|
256
256
|
usage: {
|
|
257
257
|
anatomy,
|
|
258
258
|
description:
|
|
259
|
-
'A segmented button group that allows users to make a single selection from a small set of mutually exclusive options. Use SegmentedControl when all options should be visible at once and the selection controls a value or mode, not page navigation.',
|
|
259
|
+
'A segmented button group that allows users to make a single selection from a small set of mutually exclusive options. Use SegmentedControl when all options should be visible at once and the selection controls a value or mode, not page navigation. Under a finger, on a touch device (a coarse primary pointer), the selection slides to the new segment, whether a tap, an arrow key or a new value moved it; with Reduce Motion nothing travels: the old selection fades out as the new one fades in. There, dragging the selected segment carries the selection along with the selected label’s colour following it, and the segment under the finger is chosen when it lets go (letting go outside the control selects nothing); a tap selects through the browser’s click; a pressed segment shows the shared pressed overlay, and nothing lifts or dims. With a mouse or a pen every change, a click included, slides on the theme’s duration and easing, and dragging the selected segment carries it as a finger does.',
|
|
260
260
|
bestPractices: [
|
|
261
261
|
{guidance: true, description: 'Use for switching between 2–5 mutually exclusive views or modes where all options should be visible.'},
|
|
262
262
|
{guidance: true, description: 'Provide a descriptive label for the control to ensure the group is accessible to screen readers.'},
|