@astryxdesign/core 0.7.7-canary.c0929c8 → 0.7.7-canary.c19ca12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AlertDialog/AlertDialog.d.ts +4 -1
- package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/AlertDialog/AlertDialog.js +36 -6
- package/dist/AppShell/useCloseMobileDrawerOnActivate.d.ts +13 -0
- package/dist/AppShell/useCloseMobileDrawerOnActivate.d.ts.map +1 -0
- package/dist/AppShell/useCloseMobileDrawerOnActivate.js +45 -0
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +79 -9
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +23 -4
- package/dist/BottomSheet/bottomSheetStack.d.ts.map +1 -1
- package/dist/BottomSheet/bottomSheetStack.js +5 -4
- package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
- package/dist/BottomSheet/useSheetGestures.js +3 -1
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts +2 -1
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +7 -3
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +47 -3
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +13 -2
- package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxList.js +7 -1
- package/dist/CheckboxList/CheckboxListContext.d.ts +6 -0
- package/dist/CheckboxList/CheckboxListContext.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +10 -2
- package/dist/ComplexSelector/ComplexSelector.d.ts +4 -1
- package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
- package/dist/ComplexSelector/ComplexSelector.js +14 -4
- package/dist/ContextMenu/ContextMenu.js +2 -2
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +5 -2
- package/dist/DateInput/MonthScroller.d.ts.map +1 -1
- package/dist/DateInput/MonthScroller.js +13 -27
- package/dist/DateInput/Wheel.d.ts.map +1 -1
- package/dist/DateInput/Wheel.js +22 -41
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +5 -2
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +23 -45
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +15 -11
- package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -1
- package/dist/Drawer/useDrawerDialogPresence.js +5 -1
- package/dist/Field/Field.js +2 -2
- package/dist/Field/PanelSearchInput.d.ts +9 -1
- package/dist/Field/PanelSearchInput.d.ts.map +1 -1
- package/dist/Field/PanelSearchInput.js +3 -1
- package/dist/HoverCard/HoverCard.d.ts +4 -3
- package/dist/HoverCard/HoverCard.d.ts.map +1 -1
- package/dist/HoverCard/HoverCard.js +27 -2
- package/dist/HoverCard/useHoverCard.d.ts +5 -4
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +17 -31
- package/dist/Icon/Icon.d.ts +5 -1
- package/dist/Icon/Icon.d.ts.map +1 -1
- package/dist/Icon/Icon.js +5 -2
- package/dist/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/layerAnimations.stylex.d.ts +7 -8
- package/dist/Layer/layerAnimations.stylex.d.ts.map +1 -1
- package/dist/Layer/layerAnimations.stylex.js +25 -20
- 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 +20 -10
- package/dist/Layer/usePressPin.d.ts.map +1 -1
- package/dist/Layer/usePressPin.js +66 -18
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +18 -0
- package/dist/MobileNav/MobileNav.js +0 -1
- package/dist/MultiSelector/hooks.d.ts.map +1 -1
- package/dist/MultiSelector/hooks.js +2 -4
- package/dist/Outline/Outline.d.ts +2 -4
- package/dist/Outline/Outline.d.ts.map +1 -1
- package/dist/Outline/Outline.js +4 -52
- package/dist/Outline/useOutlineFromMarkdown.d.ts.map +1 -1
- package/dist/Outline/useOutlineFromMarkdown.js +1 -0
- package/dist/Outline/useScrollSpy.js +3 -3
- package/dist/PowerSearch/PowerSearch.d.ts +36 -3
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +571 -302
- package/dist/PowerSearch/PowerSearchBottomSheet.d.ts +100 -0
- package/dist/PowerSearch/PowerSearchBottomSheet.d.ts.map +1 -0
- package/dist/PowerSearch/PowerSearchBottomSheet.js +1913 -0
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts +32 -1
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +17 -6
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts +38 -3
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchValueEditor.js +170 -61
- package/dist/PowerSearch/formatFilterValue.d.ts +7 -0
- package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
- package/dist/PowerSearch/formatFilterValue.js +11 -1
- package/dist/PowerSearch/formatTokenValue.d.ts +28 -0
- package/dist/PowerSearch/formatTokenValue.d.ts.map +1 -0
- package/dist/PowerSearch/formatTokenValue.js +160 -0
- package/dist/PowerSearch/powerSearchSheetUtils.d.ts +65 -0
- package/dist/PowerSearch/powerSearchSheetUtils.d.ts.map +1 -0
- package/dist/PowerSearch/powerSearchSheetUtils.js +168 -0
- package/dist/RadioList/RadioList.d.ts.map +1 -1
- package/dist/RadioList/RadioList.js +8 -2
- package/dist/RadioList/RadioListItem.d.ts +1 -1
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +5 -3
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +118 -260
- package/dist/Resizable/resizeGesture.d.ts +91 -0
- package/dist/Resizable/resizeGesture.d.ts.map +1 -0
- package/dist/Resizable/resizeGesture.js +251 -0
- 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 +8 -1
- 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/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +3 -9
- package/dist/Slider/sliderTouchController.js +2 -2
- package/dist/Spinner/Spinner.d.ts +1 -1
- package/dist/Spinner/Spinner.d.ts.map +1 -1
- package/dist/Spinner/Spinner.js +60 -58
- package/dist/Switch/switchTouch.d.ts +0 -7
- package/dist/Switch/switchTouch.d.ts.map +1 -1
- package/dist/Switch/switchTouch.js +2 -10
- package/dist/Switch/useSwitchTouch.d.ts +2 -11
- package/dist/Switch/useSwitchTouch.d.ts.map +1 -1
- package/dist/Switch/useSwitchTouch.js +35 -93
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +29 -8
- package/dist/TextInput/TextInput.d.ts +2 -2
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +10 -7
- package/dist/Toast/Toast.d.ts +11 -1
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +30 -15
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +94 -34
- package/dist/Toast/types.d.ts +9 -3
- package/dist/Toast/types.d.ts.map +1 -1
- package/dist/Token/Token.d.ts +2 -2
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +13 -4
- package/dist/Token/TokenNamingContext.d.ts +14 -0
- package/dist/Token/TokenNamingContext.d.ts.map +1 -0
- package/dist/Token/TokenNamingContext.js +23 -0
- package/dist/Tokenizer/Tokenizer.d.ts +46 -59
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +40 -57
- package/dist/Tokenizer/TokenizerBottomSheet.d.ts +25 -28
- package/dist/Tokenizer/TokenizerBottomSheet.d.ts.map +1 -1
- package/dist/Tokenizer/TokenizerBottomSheet.js +157 -54
- package/dist/Tokenizer/TokenizerItemRemovableContext.d.ts +3 -0
- package/dist/Tokenizer/TokenizerItemRemovableContext.d.ts.map +1 -0
- package/dist/Tokenizer/TokenizerItemRemovableContext.js +19 -0
- package/dist/Tooltip/Tooltip.d.ts +25 -30
- package/dist/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip/Tooltip.js +24 -5
- package/dist/Tooltip/index.d.ts +1 -1
- package/dist/Tooltip/index.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.d.ts +45 -28
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +52 -59
- package/dist/TopNav/TopNavItem.d.ts.map +1 -1
- package/dist/TopNav/TopNavItem.js +4 -7
- package/dist/TopNav/TopNavMegaMenuItem.d.ts.map +1 -1
- package/dist/TopNav/TopNavMegaMenuItem.js +4 -7
- package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMenu.js +4 -7
- package/dist/Typeahead/TypeaheadItem.d.ts +2 -1
- package/dist/Typeahead/TypeaheadItem.d.ts.map +1 -1
- package/dist/animator/createAnimator.d.ts +98 -0
- package/dist/animator/createAnimator.d.ts.map +1 -0
- package/dist/animator/createAnimator.js +259 -0
- package/dist/astryx.css +96 -7
- package/dist/gestures/GestureHost.d.ts +27 -1
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +157 -21
- package/dist/gestures/PressTracker.d.ts.map +1 -1
- package/dist/gestures/PressTracker.js +4 -3
- package/dist/hooks/actionGroupTracker.d.ts +7 -4
- package/dist/hooks/actionGroupTracker.d.ts.map +1 -1
- package/dist/hooks/actionGroupTracker.js +19 -56
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/pressGroupContext.d.ts +6 -0
- package/dist/hooks/pressGroupContext.d.ts.map +1 -0
- package/dist/hooks/pressGroupContext.js +20 -0
- package/dist/hooks/useActionGroupTracking.d.ts +53 -0
- package/dist/hooks/useActionGroupTracking.d.ts.map +1 -0
- package/dist/hooks/useActionGroupTracking.js +174 -0
- package/dist/hooks/useAnimator.d.ts +41 -0
- package/dist/hooks/useAnimator.d.ts.map +1 -0
- package/dist/hooks/useAnimator.js +70 -0
- package/dist/hooks/useAttachment.d.ts +1 -1
- package/dist/hooks/useAttachment.js +1 -1
- package/dist/hooks/useHighlightedOptionScroll.d.ts +11 -1
- package/dist/hooks/useHighlightedOptionScroll.d.ts.map +1 -1
- package/dist/hooks/useHighlightedOptionScroll.js +112 -11
- package/dist/hooks/useInputStatusIcon.d.ts +1 -1
- package/dist/hooks/useInputStatusIcon.d.ts.map +1 -1
- package/dist/hooks/useInputStatusIcon.js +2 -2
- package/dist/hooks/useLongPress.d.ts +6 -2
- package/dist/hooks/useLongPress.d.ts.map +1 -1
- package/dist/hooks/useLongPress.js +95 -15
- package/dist/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/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +4 -2
- 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-english/PowerSearch/PowerSearch.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/PowerSearch/PowerSearch.generated.js +1 -0
- package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.d.ts +8 -0
- package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.js +42 -0
- package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.js +6 -0
- package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.d.ts +8 -0
- package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.js +14 -0
- package/dist/i18n/generated-english/Tokenizer/TokenizerBottomSheet.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/Tokenizer/TokenizerBottomSheet.generated.js +7 -1
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +33 -1
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +33 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/internal/SheetConfirmation.d.ts +11 -0
- package/dist/internal/SheetConfirmation.d.ts.map +1 -0
- package/dist/internal/SheetConfirmation.js +92 -0
- package/dist/internal/indicatorPress.stylex.d.ts +20 -0
- package/dist/internal/indicatorPress.stylex.d.ts.map +1 -0
- package/dist/internal/indicatorPress.stylex.js +26 -0
- package/dist/internal/sheetDraft.d.ts +35 -0
- package/dist/internal/sheetDraft.d.ts.map +1 -0
- package/dist/internal/sheetDraft.js +65 -0
- package/dist/internal/touch-sheet.d.ts +21 -0
- package/dist/internal/touch-sheet.d.ts.map +1 -0
- package/dist/internal/touch-sheet.js +19 -0
- package/dist/internal/useDismissSearchOnTouchDrag.d.ts +24 -0
- package/dist/internal/useDismissSearchOnTouchDrag.d.ts.map +1 -0
- package/dist/internal/useDismissSearchOnTouchDrag.js +56 -0
- package/dist/motion/animator.d.ts +14 -14
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +41 -18
- package/dist/motion/reducedMotion.d.ts +24 -0
- package/dist/motion/reducedMotion.d.ts.map +1 -1
- package/dist/motion/reducedMotion.js +78 -1
- 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/alert.d.ts +41 -0
- package/dist/motion/uikit/alert.d.ts.map +1 -0
- package/dist/motion/uikit/alert.js +43 -0
- package/dist/motion/uikit/index.d.ts +6 -5
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +6 -5
- 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 +0 -18
- package/dist/motion/uikit/springs.d.ts.map +1 -1
- package/dist/motion/uikit/springs.js +5 -21
- package/dist/privateAttributes/pressGroupItem.stylex.d.ts +15 -0
- package/dist/privateAttributes/pressGroupItem.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/pressGroupItem.stylex.js +23 -0
- package/dist/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 +14 -1
- package/dist/utils/clickGuard.d.ts.map +1 -1
- package/dist/utils/clickGuard.js +46 -1
- package/dist/utils/dateParser.d.ts.map +1 -1
- package/dist/utils/dateParser.js +12 -0
- package/dist/utils/focusReturn.d.ts +15 -0
- package/dist/utils/focusReturn.d.ts.map +1 -1
- package/dist/utils/focusReturn.js +28 -0
- package/dist/utils/interactionOverlay.stylex.d.ts +3 -2
- package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
- package/dist/utils/interactionOverlay.stylex.js +3 -2
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +19 -6
- package/dist/utils/triggerFocus.d.ts +36 -0
- package/dist/utils/triggerFocus.d.ts.map +1 -0
- package/dist/utils/triggerFocus.js +65 -0
- package/locales/en.json +128 -0
- package/locales/pseudo.json +96 -0
- package/package.json +18 -8
- package/src/AlertDialog/AlertDialog.doc.mjs +2 -2
- package/src/AlertDialog/AlertDialog.tsx +37 -5
- package/src/AppShell/useCloseMobileDrawerOnActivate.ts +52 -0
- package/src/BottomSheet/BottomSheet.tsx +95 -10
- package/src/BottomSheet/BottomSheetPanel.tsx +40 -5
- package/src/BottomSheet/bottomSheetStack.ts +8 -4
- package/src/BottomSheet/useSheetGestures.ts +3 -1
- package/src/Breadcrumbs/BreadcrumbItem.tsx +13 -3
- package/src/Button/Button.tsx +63 -5
- package/src/CheckboxInput/CheckboxInput.doc.mjs +18 -0
- package/src/CheckboxInput/CheckboxInput.tsx +36 -9
- package/src/CheckboxList/CheckboxList.doc.mjs +4 -2
- package/src/CheckboxList/CheckboxList.tsx +6 -0
- package/src/CheckboxList/CheckboxListContext.tsx +6 -0
- package/src/CheckboxList/CheckboxListItem.tsx +11 -2
- package/src/ComplexSelector/ComplexSelector.tsx +20 -5
- package/src/ContextMenu/ContextMenu.tsx +2 -2
- package/src/DateInput/DateInput.tsx +8 -2
- package/src/DateInput/MonthScroller.tsx +18 -22
- package/src/DateInput/Wheel.tsx +30 -32
- package/src/DateTimeInput/DateTimeInput.tsx +8 -2
- package/src/Dialog/Dialog.tsx +54 -45
- package/src/Drawer/Drawer.tsx +28 -11
- package/src/Drawer/useDrawerDialogPresence.ts +5 -1
- package/src/Field/Field.tsx +2 -2
- package/src/Field/PanelSearchInput.tsx +11 -0
- package/src/HoverCard/HoverCard.doc.mjs +4 -2
- package/src/HoverCard/HoverCard.tsx +35 -4
- package/src/HoverCard/useHoverCard.doc.mjs +178 -36
- package/src/HoverCard/useHoverCard.tsx +46 -52
- package/src/Icon/Icon.doc.mjs +49 -8
- package/src/Icon/Icon.tsx +15 -7
- package/src/InfoTip/InfoTip.doc.mjs +192 -0
- package/src/InfoTip/InfoTip.tsx +186 -0
- package/src/InfoTip/index.ts +14 -0
- package/src/Layer/layerAnimations.stylex.ts +24 -16
- package/src/Layer/useBackdropPress.ts +81 -0
- package/src/Layer/usePressPin.ts +86 -26
- package/src/Lightbox/Lightbox.tsx +18 -0
- package/src/MobileNav/MobileNav.tsx +1 -1
- package/src/MultiSelector/hooks.ts +2 -4
- package/src/Outline/Outline.doc.mjs +177 -51
- package/src/Outline/Outline.tsx +5 -57
- package/src/Outline/useOutlineFromMarkdown.doc.mjs +157 -0
- package/src/Outline/useOutlineFromMarkdown.ts +1 -0
- package/src/Outline/useScrollSpy.ts +3 -3
- package/src/PowerSearch/PowerSearch.doc.mjs +55 -6
- package/src/PowerSearch/PowerSearch.tsx +798 -324
- package/src/PowerSearch/PowerSearchBottomSheet.tsx +2515 -0
- package/src/PowerSearch/PowerSearchEditPopover.tsx +28 -6
- package/src/PowerSearch/PowerSearchValueEditor.tsx +203 -38
- package/src/PowerSearch/formatFilterValue.ts +18 -1
- package/src/PowerSearch/formatTokenValue.ts +215 -0
- package/src/PowerSearch/powerSearchSheetUtils.ts +224 -0
- package/src/RadioList/RadioList.doc.mjs +4 -2
- package/src/RadioList/RadioList.tsx +7 -2
- package/src/RadioList/RadioListItem.tsx +5 -3
- package/src/Resizable/ResizeHandle.tsx +133 -328
- package/src/Resizable/resizeGesture.ts +368 -0
- 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 +12 -1
- package/src/SegmentedControl/useSegmentedSelectionMotion.ts +1640 -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/SideNav/SideNavItem.tsx +3 -7
- package/src/Slider/sliderTouchController.ts +2 -2
- package/src/Spinner/Spinner.tsx +77 -63
- package/src/Switch/switchTouch.ts +2 -10
- package/src/Switch/useSwitchTouch.ts +38 -104
- package/src/Table/BaseTable.tsx +46 -12
- package/src/TextInput/TextInput.tsx +11 -10
- package/src/Toast/Toast.doc.mjs +4 -3
- package/src/Toast/Toast.tsx +57 -32
- package/src/Toast/ToastViewport.tsx +121 -35
- package/src/Toast/types.ts +9 -3
- package/src/Token/Token.tsx +15 -4
- package/src/Token/TokenNamingContext.ts +28 -0
- package/src/Tokenizer/Tokenizer.doc.mjs +16 -0
- package/src/Tokenizer/Tokenizer.tsx +89 -85
- package/src/Tokenizer/TokenizerBottomSheet.tsx +219 -93
- package/src/Tokenizer/TokenizerItemRemovableContext.ts +24 -0
- package/src/Tooltip/Tooltip.doc.mjs +123 -54
- package/src/Tooltip/Tooltip.tsx +36 -39
- package/src/Tooltip/index.ts +0 -1
- package/src/Tooltip/useTooltip.doc.mjs +171 -33
- package/src/Tooltip/useTooltip.tsx +98 -86
- package/src/TopNav/TopNavItem.tsx +6 -5
- package/src/TopNav/TopNavMegaMenuItem.tsx +6 -5
- package/src/TopNav/TopNavMenu.tsx +6 -5
- package/src/Typeahead/TypeaheadItem.doc.mjs +6 -3
- package/src/Typeahead/TypeaheadItem.tsx +2 -1
- package/src/animator/createAnimator.doc.mjs +153 -0
- package/src/animator/createAnimator.ts +324 -0
- package/src/gestures/GestureHost.ts +198 -20
- package/src/gestures/PressTracker.ts +4 -3
- package/src/gestures/README.md +7 -1
- package/src/hooks/actionGroupTracker.ts +32 -61
- package/src/hooks/index.ts +2 -0
- package/src/hooks/pressGroupContext.ts +21 -0
- package/src/hooks/useActionGroupTracking.ts +224 -0
- package/src/hooks/useAnimator.doc.mjs +109 -0
- package/src/hooks/useAnimator.ts +67 -0
- package/src/hooks/useAttachment.ts +1 -1
- package/src/hooks/useHighlightedOptionScroll.ts +123 -15
- package/src/hooks/useInputStatusIcon.tsx +3 -2
- package/src/hooks/useLongPress.doc.mjs +2 -2
- package/src/hooks/useLongPress.ts +136 -15
- package/src/hooks/useMediaQuery.doc.mjs +2 -2
- package/src/hooks/useMediaQuery.ts +13 -4
- package/src/hooks/useMenuPress.ts +8 -2
- package/src/i18n/generated-english/InfoTip/InfoTip.generated.ts +13 -0
- package/src/i18n/generated-english/PowerSearch/PowerSearch.generated.ts +1 -0
- package/src/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.ts +43 -0
- package/src/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.ts +6 -0
- package/src/i18n/generated-english/PowerSearch/formatTokenValue.generated.ts +15 -0
- package/src/i18n/generated-english/Tokenizer/TokenizerBottomSheet.generated.ts +7 -1
- package/src/i18n/generated-locales/en.generated.ts +43 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +44 -0
- package/src/index.ts +14 -0
- package/src/internal/SheetConfirmation.tsx +101 -0
- package/src/internal/indicatorPress.stylex.ts +24 -0
- package/src/internal/sheetDraft.ts +80 -0
- package/src/internal/touch-sheet.ts +21 -0
- package/src/internal/useDismissSearchOnTouchDrag.ts +69 -0
- package/src/motion/MEASUREMENTS.md +7 -0
- package/src/motion/README.md +9 -5
- package/src/motion/animator.ts +61 -29
- package/src/motion/reducedMotion.ts +79 -1
- package/src/motion/roles.ts +20 -1
- package/src/motion/uikit/alert.ts +43 -0
- package/src/motion/uikit/index.ts +5 -5
- package/src/motion/uikit/segmented.ts +74 -0
- package/src/motion/uikit/springs.ts +5 -21
- package/src/privateAttributes/pressGroupItem.stylex.ts +23 -0
- package/src/privateAttributes/segmentTitle.stylex.ts +22 -0
- package/src/utils/browserClickWait.ts +133 -0
- package/src/utils/clickGuard.ts +64 -1
- package/src/utils/dateParser.ts +16 -0
- package/src/utils/focusReturn.ts +30 -0
- package/src/utils/interactionOverlay.stylex.ts +3 -2
- package/src/utils/pressFeedback.ts +19 -6
- package/src/utils/triggerFocus.ts +80 -0
- package/dist/internal/tokenizer-presentation.d.ts +0 -21
- package/dist/internal/tokenizer-presentation.d.ts.map +0 -1
- package/dist/internal/tokenizer-presentation.js +0 -21
- package/src/internal/tokenizer-presentation.ts +0 -25
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file useSegmentedTouchTracking.ts
|
|
3
|
+
* @input The radiogroup element, the selection motion controller and whether
|
|
4
|
+
* the control is enabled
|
|
5
|
+
* @output useSegmentedTouchTracking (a press of any pointer, landing to
|
|
6
|
+
* lift, and its ClickWait), and segmentTargetAt, measureSegments and
|
|
7
|
+
* liftTargetAt, the segment a pointer counts for
|
|
8
|
+
* @position Internal to SegmentedControl; drives useSegmentedSelectionMotion.ts
|
|
9
|
+
*
|
|
10
|
+
* SYNC: When modified, update:
|
|
11
|
+
* - /packages/core/src/SegmentedControl/useSegmentedSelectionMotion.ts
|
|
12
|
+
* - /packages/core/src/SegmentedControl/__tests__/SegmentedControl.interaction.browser.spec.ts
|
|
13
|
+
*/
|
|
14
|
+
import { type RefObject } from 'react';
|
|
15
|
+
import { type SegmentedSelectionMotion } from './useSegmentedSelectionMotion.js';
|
|
16
|
+
/**
|
|
17
|
+
* A tap's click still to come. Until it runs, a focus move the tap causes
|
|
18
|
+
* selects nothing. A key press, the next press or a cancel ends the wait.
|
|
19
|
+
*/
|
|
20
|
+
export interface ClickWait {
|
|
21
|
+
readonly isAwaiting: () => boolean;
|
|
22
|
+
readonly end: () => void;
|
|
23
|
+
}
|
|
24
|
+
/** The control's box as measured when the finger landed: viewport px. */
|
|
25
|
+
export interface ControlBounds {
|
|
26
|
+
readonly left: number;
|
|
27
|
+
readonly top: number;
|
|
28
|
+
readonly right: number;
|
|
29
|
+
readonly bottom: number;
|
|
30
|
+
}
|
|
31
|
+
/** A segment as measured when the finger landed: its viewport span, px. */
|
|
32
|
+
export interface SegmentSpan {
|
|
33
|
+
readonly element: HTMLElement;
|
|
34
|
+
readonly left: number;
|
|
35
|
+
readonly right: number;
|
|
36
|
+
}
|
|
37
|
+
/** Every segment of `track`, disabled ones included, measured once. */
|
|
38
|
+
export declare function measureSegments(track: HTMLElement): SegmentSpan[];
|
|
39
|
+
/**
|
|
40
|
+
* The segment a finger at viewport `x` counts for: the one under it, else the
|
|
41
|
+
* nearest. A gap between two segments splits at its middle, as UIKit's
|
|
42
|
+
* segments share an edge. Past the ends, the end segment counts. The result is
|
|
43
|
+
* null when that segment is disabled.
|
|
44
|
+
*/
|
|
45
|
+
export declare function segmentTargetAt(x: number, segments: ReadonlyArray<SegmentSpan>): HTMLElement | null;
|
|
46
|
+
/**
|
|
47
|
+
* The segment a lift at viewport (`x`, `y`) commits: inside the control's
|
|
48
|
+
* `bounds`, the one `segmentTargetAt` counts it for; outside them, none. A
|
|
49
|
+
* press that slides off cancels, because the control selects rather than
|
|
50
|
+
* toggles: a second press would not undo it.
|
|
51
|
+
*/
|
|
52
|
+
export declare function liftTargetAt(x: number, y: number, bounds: ControlBounds, segments: ReadonlyArray<SegmentSpan>): HTMLElement | null;
|
|
53
|
+
/**
|
|
54
|
+
* Tracks a press on the control as UIKit's segmented control does. The press
|
|
55
|
+
* tracker reports the press from landing to lift. It never claims the
|
|
56
|
+
* pointer, so a vertical drag still scrolls the page. A horizontal pan
|
|
57
|
+
* carries the lens. It claims the pointer only past its slop, and the lift
|
|
58
|
+
* still ends the press.
|
|
59
|
+
*
|
|
60
|
+
* The lift decides the segment, wherever the press began. Inside the control,
|
|
61
|
+
* the segment under the pointer counts, else the nearest one. Outside the
|
|
62
|
+
* control, nothing counts.
|
|
63
|
+
*
|
|
64
|
+
* A tap gets the browser's own click. A drag gets no click from the browser,
|
|
65
|
+
* so the tracker clicks the segment at the lift. Either way the item's
|
|
66
|
+
* `onClick` runs once and can cancel the selection. A mouse and a pen are
|
|
67
|
+
* tracked as a finger is. Keyboard and assistive technology keep the click.
|
|
68
|
+
*/
|
|
69
|
+
export declare function useSegmentedTouchTracking(trackRef: RefObject<HTMLElement | null>, motion: SegmentedSelectionMotion, isEnabled: boolean): ClickWait;
|
|
70
|
+
//# sourceMappingURL=useSegmentedTouchTracking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSegmentedTouchTracking.d.ts","sourceRoot":"","sources":["../../src/SegmentedControl/useSegmentedTouchTracking.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAmB,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAYvD,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,+BAA+B,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,OAAO,CAAC;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,IAAI,CAAC;CAC1B;AAKD,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,EAAE,CAQjE;AASD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,aAAa,CAAC,WAAW,CAAC,GACnC,WAAW,GAAG,IAAI,CAWpB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,aAAa,CAAC,WAAW,CAAC,GACnC,WAAW,GAAG,IAAI,CAUpB;AAID;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACvC,MAAM,EAAE,wBAAwB,EAChC,SAAS,EAAE,OAAO,GACjB,SAAS,CAgKX"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file useSegmentedTouchTracking.ts
|
|
7
|
+
* @input The radiogroup element, the selection motion controller and whether
|
|
8
|
+
* the control is enabled
|
|
9
|
+
* @output useSegmentedTouchTracking (a press of any pointer, landing to
|
|
10
|
+
* lift, and its ClickWait), and segmentTargetAt, measureSegments and
|
|
11
|
+
* liftTargetAt, the segment a pointer counts for
|
|
12
|
+
* @position Internal to SegmentedControl; drives useSegmentedSelectionMotion.ts
|
|
13
|
+
*
|
|
14
|
+
* SYNC: When modified, update:
|
|
15
|
+
* - /packages/core/src/SegmentedControl/useSegmentedSelectionMotion.ts
|
|
16
|
+
* - /packages/core/src/SegmentedControl/__tests__/SegmentedControl.interaction.browser.spec.ts
|
|
17
|
+
*/
|
|
18
|
+
import { useRef, useState } from 'react';
|
|
19
|
+
import { PanGestureRecognizer } from "../gestures/PanGestureRecognizer.js";
|
|
20
|
+
import { useGestureRecognizer } from "../gestures/useGestureRecognizer.js";
|
|
21
|
+
import { usePressTracker } from "../gestures/usePressTracker.js";
|
|
22
|
+
import { createActionGroupTracker } from "../hooks/actionGroupTracker.js";
|
|
23
|
+
import { lockSelection } from "../gestures/selectionLock.js";
|
|
24
|
+
import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
|
|
25
|
+
import { awaitBrowserClick, clickForLift } from "../utils/browserClickWait.js";
|
|
26
|
+
import { SEGMENT_SELECTOR } from "./useSegmentedSelectionMotion.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A tap's click still to come. Until it runs, a focus move the tap causes
|
|
30
|
+
* selects nothing. A key press, the next press or a cancel ends the wait.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/** A ref to nothing: hooks given it attach nothing. */
|
|
34
|
+
const DETACHED = {
|
|
35
|
+
current: null
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** The control's box as measured when the finger landed: viewport px. */
|
|
39
|
+
|
|
40
|
+
/** A segment as measured when the finger landed: its viewport span, px. */
|
|
41
|
+
|
|
42
|
+
/** Every segment of `track`, disabled ones included, measured once. */
|
|
43
|
+
export function measureSegments(track) {
|
|
44
|
+
return Array.from(track.querySelectorAll(SEGMENT_SELECTOR), element => {
|
|
45
|
+
const rect = element.getBoundingClientRect();
|
|
46
|
+
return {
|
|
47
|
+
element,
|
|
48
|
+
left: rect.left,
|
|
49
|
+
right: rect.right
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function isDisabled(element) {
|
|
54
|
+
return element.hasAttribute('disabled') || element.getAttribute('aria-disabled') === 'true';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The segment a finger at viewport `x` counts for: the one under it, else the
|
|
59
|
+
* nearest. A gap between two segments splits at its middle, as UIKit's
|
|
60
|
+
* segments share an edge. Past the ends, the end segment counts. The result is
|
|
61
|
+
* null when that segment is disabled.
|
|
62
|
+
*/
|
|
63
|
+
export function segmentTargetAt(x, segments) {
|
|
64
|
+
let best = null;
|
|
65
|
+
let distance = Infinity;
|
|
66
|
+
for (const segment of segments) {
|
|
67
|
+
const d = Math.max(segment.left - x, 0, x - segment.right);
|
|
68
|
+
if (d < distance) {
|
|
69
|
+
distance = d;
|
|
70
|
+
best = segment;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return best != null && !isDisabled(best.element) ? best.element : null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The segment a lift at viewport (`x`, `y`) commits: inside the control's
|
|
78
|
+
* `bounds`, the one `segmentTargetAt` counts it for; outside them, none. A
|
|
79
|
+
* press that slides off cancels, because the control selects rather than
|
|
80
|
+
* toggles: a second press would not undo it.
|
|
81
|
+
*/
|
|
82
|
+
export function liftTargetAt(x, y, bounds, segments) {
|
|
83
|
+
if (x < bounds.left || x > bounds.right || y < bounds.top || y > bounds.bottom) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return segmentTargetAt(x, segments);
|
|
87
|
+
}
|
|
88
|
+
const NO_BOUNDS = {
|
|
89
|
+
left: 0,
|
|
90
|
+
top: 0,
|
|
91
|
+
right: -1,
|
|
92
|
+
bottom: -1
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Tracks a press on the control as UIKit's segmented control does. The press
|
|
97
|
+
* tracker reports the press from landing to lift. It never claims the
|
|
98
|
+
* pointer, so a vertical drag still scrolls the page. A horizontal pan
|
|
99
|
+
* carries the lens. It claims the pointer only past its slop, and the lift
|
|
100
|
+
* still ends the press.
|
|
101
|
+
*
|
|
102
|
+
* The lift decides the segment, wherever the press began. Inside the control,
|
|
103
|
+
* the segment under the pointer counts, else the nearest one. Outside the
|
|
104
|
+
* control, nothing counts.
|
|
105
|
+
*
|
|
106
|
+
* A tap gets the browser's own click. A drag gets no click from the browser,
|
|
107
|
+
* so the tracker clicks the segment at the lift. Either way the item's
|
|
108
|
+
* `onClick` runs once and can cancel the selection. A mouse and a pen are
|
|
109
|
+
* tracked as a finger is. Keyboard and assistive technology keep the click.
|
|
110
|
+
*/
|
|
111
|
+
export function useSegmentedTouchTracking(trackRef, motion, isEnabled) {
|
|
112
|
+
/** The horizontal pan began for this touch: it is a drag, not a tap. */
|
|
113
|
+
const isDraggingRef = useRef(false);
|
|
114
|
+
/** The segments as the finger found them (disabled ones too). */
|
|
115
|
+
const segmentsRef = useRef([]);
|
|
116
|
+
/** The control's box as the finger found it: a lift outside it cancels. */
|
|
117
|
+
const boundsRef = useRef(NO_BOUNDS);
|
|
118
|
+
const trackerRef = useRef(null);
|
|
119
|
+
const tracker = trackerRef.current ??= createActionGroupTracker(() => ({
|
|
120
|
+
roots: () => [trackRef.current],
|
|
121
|
+
itemSelector: SEGMENT_SELECTOR,
|
|
122
|
+
highlightExpansion: 0,
|
|
123
|
+
// The press controller writes the shared press paint on the touched
|
|
124
|
+
// segment, as everywhere under a finger. The tracker paints nothing of its
|
|
125
|
+
// own. A held lens shows the selected face.
|
|
126
|
+
paintsHighlight: false,
|
|
127
|
+
resolveTarget: (x, y, _targets) => liftTargetAt(x, y, boundsRef.current, segmentsRef.current),
|
|
128
|
+
onActivated: (item, cancelled) => {
|
|
129
|
+
const track = trackRef.current;
|
|
130
|
+
const value = item.dataset.value;
|
|
131
|
+
if (track != null && value != null) {
|
|
132
|
+
motion.clicked(track, value, cancelled);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
swallowsNativeClick: true
|
|
136
|
+
}));
|
|
137
|
+
/** Click waits still running: an unmount ends them. */
|
|
138
|
+
const pendingClicksRef = useRef(new Set());
|
|
139
|
+
/**
|
|
140
|
+
* A tap lifted and its click has not run. After a direct click, the
|
|
141
|
+
* browser's late copy can still move focus, so the wait then lasts until the
|
|
142
|
+
* next key or press.
|
|
143
|
+
*/
|
|
144
|
+
const clickToComeRef = useRef(false);
|
|
145
|
+
const [clickWait] = useState(() => ({
|
|
146
|
+
isAwaiting: () => clickToComeRef.current,
|
|
147
|
+
end: () => {
|
|
148
|
+
clickToComeRef.current = false;
|
|
149
|
+
}
|
|
150
|
+
}));
|
|
151
|
+
// Ends the tracker's window listeners and any click wait on unmount.
|
|
152
|
+
useIsomorphicLayoutEffect(() => {
|
|
153
|
+
const pendingClicks = pendingClicksRef.current;
|
|
154
|
+
return () => {
|
|
155
|
+
tracker.dispose();
|
|
156
|
+
clickWait.end();
|
|
157
|
+
for (const end of [...pendingClicks]) {
|
|
158
|
+
end();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}, [tracker, clickWait]);
|
|
162
|
+
|
|
163
|
+
// Every pointer type is tracked. A disabled control attaches nothing.
|
|
164
|
+
const attachRef = isEnabled ? trackRef : DETACHED;
|
|
165
|
+
usePressTracker(attachRef, {
|
|
166
|
+
isEnabled: () => isEnabled,
|
|
167
|
+
onControlEvent: (event, touch) => {
|
|
168
|
+
const track = trackRef.current;
|
|
169
|
+
if (track == null) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
switch (event) {
|
|
173
|
+
case 'touchDown':
|
|
174
|
+
{
|
|
175
|
+
clickWait.end();
|
|
176
|
+
isDraggingRef.current = false;
|
|
177
|
+
segmentsRef.current = measureSegments(track);
|
|
178
|
+
const rect = track.getBoundingClientRect();
|
|
179
|
+
boundsRef.current = {
|
|
180
|
+
left: rect.left,
|
|
181
|
+
top: rect.top,
|
|
182
|
+
right: rect.right,
|
|
183
|
+
bottom: rect.bottom
|
|
184
|
+
};
|
|
185
|
+
tracker.begin(touch.x, touch.y);
|
|
186
|
+
motion.begin(track, tracker.beganOn, touch.pointerType === 'touch');
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
case 'touchUpInside':
|
|
190
|
+
case 'touchUpOutside':
|
|
191
|
+
{
|
|
192
|
+
// The lift decides, wherever the press began. A lift outside the
|
|
193
|
+
// control commits nothing.
|
|
194
|
+
tracker.move(touch.x, touch.y);
|
|
195
|
+
const lifted = tracker.highlighted;
|
|
196
|
+
const isTap = event === 'touchUpInside' && !isDraggingRef.current && lifted != null && lifted === tracker.beganOn;
|
|
197
|
+
const value = motion.release(lifted);
|
|
198
|
+
if (value != null && isTap && lifted != null) {
|
|
199
|
+
// A tap: the browser's own click commits it.
|
|
200
|
+
tracker.cancel();
|
|
201
|
+
clickToComeRef.current = true;
|
|
202
|
+
const pending = pendingClicksRef.current;
|
|
203
|
+
const endWait = awaitBrowserClick(lifted, {
|
|
204
|
+
onClicked: isCancelled => {
|
|
205
|
+
pending.delete(endWait);
|
|
206
|
+
clickWait.end();
|
|
207
|
+
motion.clicked(track, value, isCancelled);
|
|
208
|
+
},
|
|
209
|
+
onNoClick: () => {
|
|
210
|
+
pending.delete(endWait);
|
|
211
|
+
motion.clicked(track, value, clickForLift(lifted));
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
pending.add(endWait);
|
|
215
|
+
} else if (value != null) {
|
|
216
|
+
// No click comes from the browser for a drag: the segment's own
|
|
217
|
+
// click, inside the lift's event; its onClick may veto it.
|
|
218
|
+
tracker.end();
|
|
219
|
+
} else {
|
|
220
|
+
tracker.cancel();
|
|
221
|
+
}
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
case 'touchCancel':
|
|
225
|
+
clickWait.end();
|
|
226
|
+
tracker.cancel();
|
|
227
|
+
motion.cancel();
|
|
228
|
+
break;
|
|
229
|
+
case 'touchDragInside':
|
|
230
|
+
case 'touchDragOutside':
|
|
231
|
+
case 'touchDragEnter':
|
|
232
|
+
case 'touchDragExit':
|
|
233
|
+
// The horizontal pan carries the lens.
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
useGestureRecognizer(attachRef, () => new PanGestureRecognizer({
|
|
239
|
+
name: 'segmented-control-drag',
|
|
240
|
+
direction: 'horizontal',
|
|
241
|
+
cancelsTouchesInView: false,
|
|
242
|
+
// No title is selectable under a held finger, as in UIKit. A hold on
|
|
243
|
+
// the track does something: a drag carries the lens and commits where
|
|
244
|
+
// it lifts. So this recognizer brings the lock, and the host turns off
|
|
245
|
+
// text selection and the callout on the track while a finger is down.
|
|
246
|
+
selectionLock: lockSelection
|
|
247
|
+
}), recognizer => {
|
|
248
|
+
if (recognizer.state === 'began') {
|
|
249
|
+
isDraggingRef.current = true;
|
|
250
|
+
}
|
|
251
|
+
if (recognizer.state === 'began' || recognizer.state === 'changed') {
|
|
252
|
+
const {
|
|
253
|
+
x,
|
|
254
|
+
y
|
|
255
|
+
} = recognizer.location();
|
|
256
|
+
// The lens chases the finger, then the tracker moves the highlight.
|
|
257
|
+
motion.drag(x);
|
|
258
|
+
tracker.move(x, y);
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
isEnabled
|
|
262
|
+
});
|
|
263
|
+
return clickWait;
|
|
264
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Selector.d.ts","sourceRoot":"","sources":["../../src/Selector/Selector.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Selector.d.ts","sourceRoot":"","sources":["../../src/Selector/Selector.tsx"],"names":[],"mappings":"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"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* - /apps/storybook/stories/InputGroup.stories.tsx
|
|
19
19
|
* - /packages/cli/assets/templates/blocks/components/Selector/ (showcase blocks)
|
|
20
20
|
*/
|
|
21
|
-
import React, { use, useCallback, useEffect, useId, useMemo, useOptimistic, useRef, useState, useTransition } from 'react';
|
|
21
|
+
import React, { memo, use, useCallback, useEffect, useId, useMemo, useOptimistic, useRef, useState, useTransition } from 'react';
|
|
22
22
|
import * as stylex from '@stylexjs/stylex';
|
|
23
23
|
import { inputDisabledFocusStyles } from "../Field/inputDisabledFocus.js";
|
|
24
24
|
import { useTooltip } from "../Tooltip/index.js";
|
|
@@ -37,7 +37,8 @@ import { useAnnounce } from "../hooks/useAnnounce.js";
|
|
|
37
37
|
import { useAnnounceRenderedText } from "../hooks/useAnnounceRenderedText.js";
|
|
38
38
|
import "../theme/tokens.stylex.js";
|
|
39
39
|
import { colorVars, sizeVars, spacingVars, radiusVars, durationVars, easeVars, typographyVars, fontWeightVars, typeScaleVars, borderVars } from "../theme/tokens.stylex.js";
|
|
40
|
-
import { isOptionData, isDivider, isSection, normalizeOption
|
|
40
|
+
import { isOptionData, isDivider, isSection, normalizeOption } from "./utils.js";
|
|
41
|
+
import { getSelectableOptionEntries } from "./selectableOptionEntries.js";
|
|
41
42
|
import { useCombobox, useSelectedItemOffset } from "./hooks.js";
|
|
42
43
|
import { useMenuPress } from "../hooks/useMenuPress.js";
|
|
43
44
|
import { useMenuOverflow } from "../DropdownMenu/useMenuOverflow.js";
|
|
@@ -310,6 +311,79 @@ function DefaultOption({
|
|
|
310
311
|
description: option.description
|
|
311
312
|
});
|
|
312
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* Keep each prop stable across renders that do not change this row. A new
|
|
316
|
+
* `onSelect` or `renderOption` re-renders every row.
|
|
317
|
+
*/
|
|
318
|
+
const SelectorOptionRow = /*#__PURE__*/memo(function SelectorOptionRow({
|
|
319
|
+
item,
|
|
320
|
+
flatIndex,
|
|
321
|
+
id,
|
|
322
|
+
isHighlighted,
|
|
323
|
+
isSelected,
|
|
324
|
+
size,
|
|
325
|
+
indicatorPosition,
|
|
326
|
+
renderOption,
|
|
327
|
+
SelectionMark,
|
|
328
|
+
onSelect,
|
|
329
|
+
onHover
|
|
330
|
+
}) {
|
|
331
|
+
/*
|
|
332
|
+
* Rendered UNCONDITIONALLY, with the state passed down: the default
|
|
333
|
+
* check draws nothing when unchecked, but a theme that replaces the
|
|
334
|
+
* `check` indicator with a radio needs the unselected state to draw
|
|
335
|
+
* its empty circle. `{isSelected && …}` would make that impossible.
|
|
336
|
+
*
|
|
337
|
+
* `selector-check` stays the stable target for the mark's position
|
|
338
|
+
* in the row; the indicator owns what the mark looks like.
|
|
339
|
+
*/
|
|
340
|
+
const mark = /*#__PURE__*/_jsx("span", {
|
|
341
|
+
...{
|
|
342
|
+
className: "x3nfvp2 x6s0dn4 xl56j7k x2lah0s xgomdpo xjl7jj"
|
|
343
|
+
},
|
|
344
|
+
children: /*#__PURE__*/_jsx(SelectionMark, {
|
|
345
|
+
state: isSelected ? 'checked' : 'unchecked',
|
|
346
|
+
size: "sm",
|
|
347
|
+
isDisabled: item.disabled ?? false,
|
|
348
|
+
...themeProps('selector-check')
|
|
349
|
+
})
|
|
350
|
+
});
|
|
351
|
+
const optionContent = /*#__PURE__*/_jsx("span", {
|
|
352
|
+
...{
|
|
353
|
+
className: "x78zum5 x6s0dn4 x1txdalj x98rzlu xeuugli"
|
|
354
|
+
},
|
|
355
|
+
children: renderOption ? renderOption(item) : /*#__PURE__*/_jsx(DefaultOption, {
|
|
356
|
+
option: item
|
|
357
|
+
})
|
|
358
|
+
});
|
|
359
|
+
return /*#__PURE__*/_jsx("div", {
|
|
360
|
+
id: id,
|
|
361
|
+
role: "option",
|
|
362
|
+
"aria-selected": isSelected,
|
|
363
|
+
"aria-disabled": item.disabled,
|
|
364
|
+
onClick: () => onSelect(item),
|
|
365
|
+
onMouseEnter: () => onHover(item, flatIndex),
|
|
366
|
+
...mergeProps(
|
|
367
|
+
// Stable theme target on the option row itself, mirroring
|
|
368
|
+
// `multi-selector-option`: it carries the row's size and runtime
|
|
369
|
+
// state so a theme can express "selected option at large" or
|
|
370
|
+
// restyle a given row density without structural selectors. The
|
|
371
|
+
// row's padding is split across a base and a per-size override (the
|
|
372
|
+
// default `md` trims the block axis), so `size` is what a theme
|
|
373
|
+
// needs to reach it. Named `-option-row` because `selector-option`
|
|
374
|
+
// is the public SelectorOption content primitive, not this row.
|
|
375
|
+
themeProps('selector-option-row', {
|
|
376
|
+
size,
|
|
377
|
+
selected: isSelected ? 'selected' : null,
|
|
378
|
+
disabled: item.disabled ? 'disabled' : null
|
|
379
|
+
}), stylex.props(styles.item, itemSizeStyles[size], isHighlighted && styles.itemHighlighted, isSelected && styles.itemSelected, item.disabled && styles.itemDisabled)),
|
|
380
|
+
children: indicatorPosition === 'start' ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
381
|
+
children: [mark, optionContent]
|
|
382
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
383
|
+
children: [optionContent, mark]
|
|
384
|
+
})
|
|
385
|
+
});
|
|
386
|
+
});
|
|
313
387
|
|
|
314
388
|
// Case-insensitive substring match for a single option. The one predicate used
|
|
315
389
|
// by both the flat filter (count + keyboard nav) and the grouped renderer, so
|
|
@@ -482,7 +556,10 @@ export function Selector(props) {
|
|
|
482
556
|
const triggerLabelledBy = ariaLabelledByProp != null ? joinAriaIDs(ariaLabelledBy ?? fieldLabelId, ariaLabelledByProp) : ariaLabelledBy;
|
|
483
557
|
|
|
484
558
|
// Flatten options for keyboard navigation
|
|
485
|
-
const
|
|
559
|
+
const selectableEntries = useMemo(() => getSelectableOptionEntries(options), [options]);
|
|
560
|
+
const selectableItems = useMemo(() => selectableEntries.map(entry => entry.item), [selectableEntries]);
|
|
561
|
+
// Rows need the same item object on every render, or their memo fails.
|
|
562
|
+
const normalizedOf = useMemo(() => new Map(selectableEntries.map(entry => [entry.source, entry.item])), [selectableEntries]);
|
|
486
563
|
|
|
487
564
|
// `action` is declared on the shared option type for `MultiSelector`;
|
|
488
565
|
// this listbox has not adopted it, so it renders the option without the
|
|
@@ -900,67 +977,19 @@ export function Selector(props) {
|
|
|
900
977
|
const SelectionMark = useIndicator('check');
|
|
901
978
|
|
|
902
979
|
// Render an individual item
|
|
903
|
-
const renderItem = useCallback((item, flatIndex) => {
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
const mark = /*#__PURE__*/_jsx("span", {
|
|
917
|
-
...{
|
|
918
|
-
className: "x3nfvp2 x6s0dn4 xl56j7k x2lah0s xgomdpo xjl7jj"
|
|
919
|
-
},
|
|
920
|
-
children: /*#__PURE__*/_jsx(SelectionMark, {
|
|
921
|
-
state: isSelected ? 'checked' : 'unchecked',
|
|
922
|
-
size: "sm",
|
|
923
|
-
isDisabled: item.disabled ?? false,
|
|
924
|
-
...themeProps('selector-check')
|
|
925
|
-
})
|
|
926
|
-
});
|
|
927
|
-
const optionContent = /*#__PURE__*/_jsx("span", {
|
|
928
|
-
...{
|
|
929
|
-
className: "x78zum5 x6s0dn4 x1txdalj x98rzlu xeuugli"
|
|
930
|
-
},
|
|
931
|
-
children: renderOption ? renderOption(item) : /*#__PURE__*/_jsx(DefaultOption, {
|
|
932
|
-
option: item
|
|
933
|
-
})
|
|
934
|
-
});
|
|
935
|
-
const content = indicatorPosition === 'start' ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
936
|
-
children: [mark, optionContent]
|
|
937
|
-
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
938
|
-
children: [optionContent, mark]
|
|
939
|
-
});
|
|
940
|
-
return /*#__PURE__*/_jsx("div", {
|
|
941
|
-
id: getItemId(flatIndex),
|
|
942
|
-
role: "option",
|
|
943
|
-
"aria-selected": isSelected,
|
|
944
|
-
"aria-disabled": item.disabled,
|
|
945
|
-
onClick: () => onItemSelect(item),
|
|
946
|
-
onMouseEnter: () => onItemMouseEnter(item, flatIndex),
|
|
947
|
-
...mergeProps(
|
|
948
|
-
// Stable theme target on the option row itself, mirroring
|
|
949
|
-
// `multi-selector-option`: it carries the row's size and runtime
|
|
950
|
-
// state so a theme can express "selected option at large" or
|
|
951
|
-
// restyle a given row density without structural selectors. The
|
|
952
|
-
// row's padding is split across a base and a per-size override (the
|
|
953
|
-
// default `md` trims the block axis), so `size` is what a theme
|
|
954
|
-
// needs to reach it. Named `-option-row` because `selector-option`
|
|
955
|
-
// is the public SelectorOption content primitive, not this row.
|
|
956
|
-
themeProps('selector-option-row', {
|
|
957
|
-
size,
|
|
958
|
-
selected: isSelected ? 'selected' : null,
|
|
959
|
-
disabled: item.disabled ? 'disabled' : null
|
|
960
|
-
}), stylex.props(styles.item, itemSizeStyles[size], isHighlighted && styles.itemHighlighted, isSelected && styles.itemSelected, item.disabled && styles.itemDisabled)),
|
|
961
|
-
children: content
|
|
962
|
-
}, item.value);
|
|
963
|
-
}, [renderOption, indicatorPosition, highlightedIndex, size, normalizedValue, getItemId, onItemSelect, onItemMouseEnter, SelectionMark]);
|
|
980
|
+
const renderItem = useCallback((item, flatIndex) => /*#__PURE__*/_jsx(SelectorOptionRow, {
|
|
981
|
+
item: item,
|
|
982
|
+
flatIndex: flatIndex,
|
|
983
|
+
id: getItemId(flatIndex),
|
|
984
|
+
isHighlighted: flatIndex === highlightedIndex,
|
|
985
|
+
isSelected: item.value === normalizedValue,
|
|
986
|
+
size: size,
|
|
987
|
+
indicatorPosition: indicatorPosition,
|
|
988
|
+
renderOption: renderOption,
|
|
989
|
+
SelectionMark: SelectionMark,
|
|
990
|
+
onSelect: onItemSelect,
|
|
991
|
+
onHover: onItemMouseEnter
|
|
992
|
+
}, item.value), [renderOption, indicatorPosition, highlightedIndex, size, normalizedValue, getItemId, onItemSelect, onItemMouseEnter, SelectionMark]);
|
|
964
993
|
|
|
965
994
|
// Render all options (handling sections/dividers)
|
|
966
995
|
const renderOptions = useCallback(() => {
|
|
@@ -1005,7 +1034,7 @@ export function Selector(props) {
|
|
|
1005
1034
|
} else if (isSection(option)) {
|
|
1006
1035
|
const sectionItems = [];
|
|
1007
1036
|
for (const opt of option.options) {
|
|
1008
|
-
const normalized = normalizeOption(opt);
|
|
1037
|
+
const normalized = normalizedOf.get(opt) ?? normalizeOption(opt);
|
|
1009
1038
|
if (isSearching && !optionMatchesQuery(normalized, searchQuery)) {
|
|
1010
1039
|
continue;
|
|
1011
1040
|
}
|
|
@@ -1034,7 +1063,7 @@ export function Selector(props) {
|
|
|
1034
1063
|
}), sectionItems]
|
|
1035
1064
|
}, `section-${i}`));
|
|
1036
1065
|
} else if (isOptionData(option)) {
|
|
1037
|
-
const normalized = normalizeOption(option);
|
|
1066
|
+
const normalized = normalizedOf.get(option) ?? normalizeOption(option);
|
|
1038
1067
|
if (isSearching && !optionMatchesQuery(normalized, searchQuery)) {
|
|
1039
1068
|
continue;
|
|
1040
1069
|
}
|
|
@@ -1043,7 +1072,7 @@ export function Selector(props) {
|
|
|
1043
1072
|
}
|
|
1044
1073
|
}
|
|
1045
1074
|
return elements;
|
|
1046
|
-
}, [options, renderItem, hasSearch, searchQuery, filteredItems, isLoading, emptyText, emptySearchText]);
|
|
1075
|
+
}, [options, normalizedOf, renderItem, hasSearch, searchQuery, filteredItems, isLoading, emptyText, emptySearchText]);
|
|
1047
1076
|
|
|
1048
1077
|
// The detached message box renders its own leading status icon, so the
|
|
1049
1078
|
// on-field icon would duplicate it — keep the chevron indicator instead.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file optionShape.ts
|
|
3
|
+
* @input Selector option values
|
|
4
|
+
* @output The option type guards and `normalizeOption`
|
|
5
|
+
* @position Internal; re-exported by utils.ts, the public entry point
|
|
6
|
+
*/
|
|
7
|
+
import type { SelectorOptionType, SelectorOptionData, SelectorDivider, SelectorSection } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Type guard: check if option is a selectable option (string or OptionData)
|
|
10
|
+
*/
|
|
11
|
+
export declare function isOptionData(option: SelectorOptionType): option is SelectorOptionData | string;
|
|
12
|
+
/**
|
|
13
|
+
* Type guard: check if option is a divider
|
|
14
|
+
*/
|
|
15
|
+
export declare function isDivider(option: SelectorOptionType): option is SelectorDivider;
|
|
16
|
+
/**
|
|
17
|
+
* Type guard: check if option is a section
|
|
18
|
+
*/
|
|
19
|
+
export declare function isSection(option: SelectorOptionType): option is SelectorSection;
|
|
20
|
+
/**
|
|
21
|
+
* Normalize string or option to consistent shape
|
|
22
|
+
*/
|
|
23
|
+
export declare function normalizeOption(option: string | SelectorOptionData): SelectorOptionData;
|
|
24
|
+
//# sourceMappingURL=optionShape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optionShape.d.ts","sourceRoot":"","sources":["../../src/Selector/optionShape.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,kBAAkB,GACzB,MAAM,IAAI,kBAAkB,GAAG,MAAM,CAKvC;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,kBAAkB,GACzB,MAAM,IAAI,eAAe,CAI3B;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,kBAAkB,GACzB,MAAM,IAAI,eAAe,CAI3B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,GAAG,kBAAkB,GAClC,kBAAkB,CAQpB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file optionShape.ts
|
|
5
|
+
* @input Selector option values
|
|
6
|
+
* @output The option type guards and `normalizeOption`
|
|
7
|
+
* @position Internal; re-exported by utils.ts, the public entry point
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Type guard: check if option is a selectable option (string or OptionData)
|
|
12
|
+
*/
|
|
13
|
+
export function isOptionData(option) {
|
|
14
|
+
if (typeof option === 'string') {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return !('type' in option);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Type guard: check if option is a divider
|
|
22
|
+
*/
|
|
23
|
+
export function isDivider(option) {
|
|
24
|
+
return typeof option === 'object' && 'type' in option && option.type === 'divider';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Type guard: check if option is a section
|
|
29
|
+
*/
|
|
30
|
+
export function isSection(option) {
|
|
31
|
+
return typeof option === 'object' && 'type' in option && option.type === 'section';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Normalize string or option to consistent shape
|
|
36
|
+
*/
|
|
37
|
+
export function normalizeOption(option) {
|
|
38
|
+
if (typeof option === 'string') {
|
|
39
|
+
return {
|
|
40
|
+
value: option,
|
|
41
|
+
label: option
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
...option,
|
|
46
|
+
label: option.label ?? option.value
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file selectableOptionEntries.ts
|
|
3
|
+
* @input Selector options, with sections and dividers
|
|
4
|
+
* @output `getSelectableOptionEntries`: each selectable item with the option
|
|
5
|
+
* it was given as
|
|
6
|
+
* @position Internal; the one walk behind utils.ts's `getSelectableOptions`
|
|
7
|
+
* and Selector's rows
|
|
8
|
+
*/
|
|
9
|
+
import type { SelectorOptionType, SelectorOptionData } from './types.js';
|
|
10
|
+
/** A selectable option as given, and its normalized data. */
|
|
11
|
+
export interface SelectableOptionEntry {
|
|
12
|
+
readonly source: string | SelectorOptionData;
|
|
13
|
+
readonly item: SelectorOptionData;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Every selectable option (sections flattened, dividers skipped), each with
|
|
17
|
+
* the option it was given as.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getSelectableOptionEntries(options: SelectorOptionType[]): SelectableOptionEntry[];
|
|
20
|
+
//# sourceMappingURL=selectableOptionEntries.d.ts.map
|