@astryxdesign/core 0.7.17 → 0.7.18-canary.g57306fd
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.map +1 -1
- package/dist/AlertDialog/AlertDialog.js +7 -0
- package/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +5 -3
- package/dist/AppShell/observeMainOverflow.d.ts +5 -0
- package/dist/AppShell/observeMainOverflow.d.ts.map +1 -1
- package/dist/AppShell/observeMainOverflow.js +39 -9
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +8 -0
- package/dist/BottomSheet/useSheetGestures.d.ts +8 -0
- package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
- package/dist/BottomSheet/useSheetGestures.js +16 -1
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +3 -16
- package/dist/Card/Card.d.ts.map +1 -1
- package/dist/Card/Card.js +5 -1
- package/dist/Citation/Citation.d.ts.map +1 -1
- package/dist/Citation/Citation.js +2 -2
- package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
- package/dist/ClickableCard/ClickableCard.js +7 -2
- package/dist/DateInput/DateInput.d.ts +0 -3
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +3 -5
- package/dist/DateInput/NativeDateField.d.ts.map +1 -1
- package/dist/DateInput/NativeDateField.js +3 -5
- package/dist/DateInput/TouchDateField.d.ts.map +1 -1
- package/dist/DateInput/TouchDateField.js +2 -4
- package/dist/DateInput/useTypedDate.d.ts.map +1 -1
- package/dist/DateInput/useTypedDate.js +9 -6
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +13 -9
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +3 -15
- package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
- package/dist/DateTimeInput/TouchDateTimeField.js +2 -14
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +7 -1
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +7 -0
- package/dist/Field/Field.d.ts.map +1 -1
- package/dist/Field/Field.js +2 -1
- package/dist/Field/FieldLabel.d.ts.map +1 -1
- package/dist/Field/FieldLabel.js +9 -2
- package/dist/Field/InputClearButton.d.ts.map +1 -1
- package/dist/Field/InputClearButton.js +23 -0
- package/dist/Field/inputStyles.stylex.d.ts +22 -6
- package/dist/Field/inputStyles.stylex.d.ts.map +1 -1
- package/dist/Field/inputStyles.stylex.js +32 -0
- package/dist/FieldStatus/FieldStatus.d.ts.map +1 -1
- package/dist/FieldStatus/FieldStatus.js +7 -2
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +4 -4
- package/dist/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/InputGroup/InputGroup.js +6 -16
- package/dist/InputGroup/InputGroupText.d.ts.map +1 -1
- package/dist/InputGroup/InputGroupText.js +2 -8
- package/dist/Kbd/Kbd.d.ts +3 -2
- package/dist/Kbd/Kbd.d.ts.map +1 -1
- package/dist/Kbd/Kbd.js +3 -2
- package/dist/Layer/gestureCounter.d.ts +5 -0
- package/dist/Layer/gestureCounter.d.ts.map +1 -1
- package/dist/Layer/gestureCounter.js +40 -4
- package/dist/Layer/layerHost.d.ts +3 -2
- package/dist/Layer/layerHost.d.ts.map +1 -1
- package/dist/Layer/layerHost.js +3 -2
- package/dist/Layer/outsidePanClaim.d.ts +17 -0
- package/dist/Layer/outsidePanClaim.d.ts.map +1 -1
- package/dist/Layer/outsidePanClaim.js +36 -8
- package/dist/Layer/outsidePress.d.ts +7 -1
- package/dist/Layer/outsidePress.d.ts.map +1 -1
- package/dist/Layer/outsidePress.js +9 -2
- package/dist/Layer/useLayer.d.ts +21 -5
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +63 -40
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +7 -0
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +22 -16
- package/dist/NavIcon/NavIcon.d.ts +2 -2
- package/dist/NavIcon/NavIcon.d.ts.map +1 -1
- package/dist/NavIcon/NavIcon.js +2 -2
- package/dist/NavMenu/NavHeadingMenuItem.d.ts.map +1 -1
- package/dist/NavMenu/NavHeadingMenuItem.js +4 -3
- package/dist/NumberInput/NumberInput.d.ts +13 -5
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +6 -17
- package/dist/NumberInput/numberParser.d.ts +9 -2
- package/dist/NumberInput/numberParser.d.ts.map +1 -1
- package/dist/NumberInput/numberParser.js +15 -2
- package/dist/Overlay/OverlayScrim.d.ts.map +1 -1
- package/dist/Overlay/OverlayScrim.js +13 -4
- package/dist/Overlay/useOverlay.d.ts +1 -1
- package/dist/Pagination/Pagination.d.ts +3 -2
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +9 -2
- package/dist/Popover/usePopover.d.ts +37 -6
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +103 -20
- package/dist/PowerSearch/PowerSearch.d.ts +4 -1
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +3 -4
- package/dist/PowerSearch/PowerSearchBottomSheet.d.ts +1 -2
- package/dist/PowerSearch/PowerSearchBottomSheet.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchBottomSheet.js +3 -12
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts +0 -12
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchValueEditor.js +1 -51
- package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
- package/dist/PowerSearch/formatFilterValue.js +6 -8
- package/dist/PowerSearch/formatTokenValue.d.ts +5 -10
- package/dist/PowerSearch/formatTokenValue.d.ts.map +1 -1
- package/dist/PowerSearch/formatTokenValue.js +21 -38
- package/dist/PowerSearch/relativeDateOptions.d.ts +30 -0
- package/dist/PowerSearch/relativeDateOptions.d.ts.map +1 -0
- package/dist/PowerSearch/relativeDateOptions.js +74 -0
- package/dist/ProgressBar/ProgressBar.d.ts +1 -1
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +20 -14
- package/dist/Resizable/createResizable.d.ts.map +1 -1
- package/dist/Resizable/createResizable.js +38 -4
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +5 -3
- package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
- package/dist/SelectableCard/SelectableCard.js +6 -2
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +2 -1
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +4 -1
- package/dist/Stepper/Step.d.ts.map +1 -1
- package/dist/Stepper/Step.js +2 -2
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +2 -0
- package/dist/TabList/TabMenu.d.ts.map +1 -1
- package/dist/TabList/TabMenu.js +2 -0
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +14 -5
- package/dist/Table/Table.d.ts +9 -4
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +9 -4
- package/dist/Table/TableHeaderCell.d.ts.map +1 -1
- package/dist/Table/TableHeaderCell.js +3 -7
- package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortable.js +18 -1
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +34 -24
- package/dist/Table/types.d.ts +5 -5
- package/dist/Text/Text.d.ts.map +1 -1
- package/dist/Text/Text.js +13 -8
- package/dist/Text/TruncationTooltip.d.ts +7 -39
- package/dist/Text/TruncationTooltip.d.ts.map +1 -1
- package/dist/Text/TruncationTooltip.js +47 -128
- package/dist/Text/cutText.d.ts +22 -0
- package/dist/Text/cutText.d.ts.map +1 -0
- package/dist/Text/cutText.js +92 -0
- package/dist/Text/cutTextOnKeyboardFocus.d.ts +41 -0
- package/dist/Text/cutTextOnKeyboardFocus.d.ts.map +1 -0
- package/dist/Text/cutTextOnKeyboardFocus.js +101 -0
- package/dist/Text/textClampContext.d.ts +1 -0
- package/dist/Text/textClampContext.d.ts.map +1 -1
- package/dist/Text/textClampContext.js +10 -5
- package/dist/Text/useTruncation.d.ts +23 -1
- package/dist/Text/useTruncation.d.ts.map +1 -1
- package/dist/Text/useTruncation.js +74 -28
- package/dist/TextInput/TextInput.d.ts +6 -6
- package/dist/Thumbnail/Thumbnail.js +4 -1
- package/dist/TimeInput/TimeInput.d.ts +0 -3
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +3 -5
- package/dist/TimeInput/TouchTimeField.d.ts.map +1 -1
- package/dist/TimeInput/TouchTimeField.js +3 -5
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +22 -16
- package/dist/Timestamp/TimestampHoverCard.d.ts +6 -3
- package/dist/Timestamp/TimestampHoverCard.d.ts.map +1 -1
- package/dist/Timestamp/TimestampHoverCard.js +30 -19
- package/dist/Timestamp/formatInstant.d.ts.map +1 -1
- package/dist/Timestamp/formatInstant.js +3 -3
- package/dist/Timestamp/tooltipEntries.d.ts.map +1 -1
- package/dist/Timestamp/tooltipEntries.js +4 -2
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +62 -31
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +35 -13
- package/dist/Toast/useToast.d.ts.map +1 -1
- package/dist/Toast/useToast.js +35 -14
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +3 -3
- package/dist/astryx.css +36 -8
- package/dist/hooks/useAnnounceRenderedText.d.ts +10 -3
- package/dist/hooks/useAnnounceRenderedText.d.ts.map +1 -1
- package/dist/hooks/useAnnounceRenderedText.js +11 -3
- package/dist/hooks/useFocusTrap.d.ts +12 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +13 -6
- package/dist/hooks/useHotkeys.d.ts +9 -1
- package/dist/hooks/useHotkeys.d.ts.map +1 -1
- package/dist/hooks/useHotkeys.js +52 -2
- package/dist/hooks/useInputStatusIcon.d.ts.map +1 -1
- package/dist/hooks/useInputStatusIcon.js +2 -1
- package/dist/hooks/useKeyboardHint.d.ts.map +1 -1
- package/dist/hooks/useKeyboardHint.js +4 -3
- package/dist/i18n/generated-english/DateRangeInput/DateRangeInput.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/DateRangeInput/DateRangeInput.generated.js +2 -0
- package/dist/i18n/generated-english/MultiSelector/MultiSelector.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/MultiSelector/MultiSelector.generated.js +1 -0
- package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.js +0 -6
- package/dist/i18n/generated-english/PowerSearch/relativeDateOptions.generated.d.ts +8 -0
- package/dist/i18n/generated-english/PowerSearch/relativeDateOptions.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/PowerSearch/relativeDateOptions.generated.js +17 -0
- package/dist/i18n/generated-english/Slider/Slider.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/Slider/Slider.generated.js +1 -0
- package/dist/i18n/generated-english/Thumbnail/Thumbnail.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/Thumbnail/Thumbnail.generated.js +1 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +5 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +5 -0
- package/dist/i18n/getLocaleDirection.d.ts +0 -16
- package/dist/i18n/getLocaleDirection.d.ts.map +1 -1
- package/dist/i18n/getLocaleDirection.js +16 -6
- package/dist/i18n/listFormat.d.ts +22 -0
- package/dist/i18n/listFormat.d.ts.map +1 -0
- package/dist/i18n/listFormat.js +29 -0
- package/dist/i18n/useListFormatter.d.ts +1 -3
- package/dist/i18n/useListFormatter.d.ts.map +1 -1
- package/dist/i18n/useListFormatter.js +5 -12
- package/dist/internal/module-loader.d.ts +15 -0
- package/dist/internal/module-loader.d.ts.map +1 -0
- package/dist/internal/module-loader.js +15 -0
- package/dist/motion/animatedLayout.d.ts +6 -0
- package/dist/motion/animatedLayout.d.ts.map +1 -1
- package/dist/motion/animatedLayout.js +201 -27
- package/dist/palette/color.d.ts +16 -0
- package/dist/palette/color.d.ts.map +1 -1
- package/dist/palette/color.js +37 -1
- package/dist/palette/derive-look.d.ts +235 -0
- package/dist/palette/derive-look.d.ts.map +1 -0
- package/dist/palette/derive-look.js +879 -0
- package/dist/palette/editor-look.d.ts +41 -0
- package/dist/palette/editor-look.d.ts.map +1 -0
- package/dist/palette/editor-look.js +401 -0
- package/dist/palette/mapping.d.ts +99 -6
- package/dist/palette/mapping.d.ts.map +1 -1
- package/dist/palette/mapping.js +68 -11
- package/dist/theme/tokens.d.ts +1 -1
- package/dist/theme/tokens.d.ts.map +1 -1
- package/dist/theme/tokens.js +1 -1
- package/dist/utils/characters.d.ts.map +1 -1
- package/dist/utils/characters.js +7 -0
- package/dist/utils/devWarning.d.ts +18 -0
- package/dist/utils/devWarning.d.ts.map +1 -1
- package/dist/utils/devWarning.js +30 -0
- package/dist/utils/focusReturn.d.ts +2 -0
- package/dist/utils/focusReturn.d.ts.map +1 -1
- package/dist/utils/focusReturn.js +3 -8
- package/dist/utils/hitArea.d.ts +4 -1
- package/dist/utils/hitArea.d.ts.map +1 -1
- package/dist/utils/hitArea.js +72 -9
- package/dist/utils/scrollView.d.ts +2 -2
- package/dist/utils/scrollView.d.ts.map +1 -1
- package/dist/utils/scrollView.js +3 -3
- package/dist/utils/textDirection.d.ts +15 -5
- package/dist/utils/textDirection.d.ts.map +1 -1
- package/dist/utils/textDirection.js +33 -4
- package/dist/utils/touchHitArea.d.ts.map +1 -1
- package/dist/utils/touchHitArea.js +4 -2
- package/dist/virtualization/useInlineListWindow.d.ts.map +1 -1
- package/dist/virtualization/useInlineListWindow.js +63 -4
- package/locales/en.json +26 -6
- package/locales/pseudo.json +15 -0
- package/package.json +10 -5
- package/src/AlertDialog/AlertDialog.tsx +15 -0
- package/src/AlertDialog/useImperativeAlertDialog.doc.mjs +7 -4
- package/src/AppShell/AppShell.tsx +6 -3
- package/src/AppShell/observeMainOverflow.ts +39 -9
- package/src/Badge/Badge.doc.mjs +3 -3
- package/src/BottomSheet/BottomSheet.tsx +15 -0
- package/src/BottomSheet/useSheetGestures.ts +26 -1
- package/src/Button/Button.tsx +3 -23
- package/src/Card/Card.doc.mjs +3 -3
- package/src/Card/Card.tsx +11 -6
- package/src/Chat/ChatSendButton.doc.mjs +6 -6
- package/src/Chat/ChatToolCalls.doc.mjs +1 -1
- package/src/CheckboxInput/CheckboxInput.doc.mjs +3 -3
- package/src/Citation/Citation.tsx +8 -2
- package/src/ClickableCard/ClickableCard.tsx +9 -2
- package/src/ComplexSelector/ComplexSelector.doc.mjs +3 -3
- package/src/ContextMenu/ContextMenuItem.doc.mjs +3 -3
- package/src/DateInput/DateInput.tsx +2 -4
- package/src/DateInput/NativeDateField.tsx +5 -4
- package/src/DateInput/TouchDateField.tsx +2 -3
- package/src/DateInput/useTypedDate.ts +13 -6
- package/src/DateRangeInput/DateRangeInput.tsx +14 -10
- package/src/DateTimeInput/DateTimeInput.tsx +2 -12
- package/src/DateTimeInput/TouchDateTimeField.tsx +2 -11
- package/src/Dialog/Dialog.tsx +15 -1
- package/src/Dialog/useImperativeDialog.doc.mjs +7 -4
- package/src/Drawer/Drawer.tsx +15 -0
- package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -1
- package/src/DropdownMenu/DropdownMenuCheckboxItem.doc.mjs +3 -3
- package/src/DropdownMenu/DropdownMenuItem.doc.mjs +3 -3
- package/src/DropdownMenu/DropdownMenuRadioItem.doc.mjs +3 -3
- package/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs +2 -2
- package/src/Field/Field.doc.mjs +1 -1
- package/src/Field/Field.tsx +2 -1
- package/src/Field/FieldLabel.doc.mjs +3 -3
- package/src/Field/FieldLabel.tsx +11 -3
- package/src/Field/InputClearButton.tsx +27 -0
- package/src/Field/inputStyles.stylex.ts +53 -6
- package/src/FieldStatus/FieldStatus.tsx +7 -2
- package/src/FileInput/FileInput.tsx +12 -2
- package/src/Icon/Icon.doc.mjs +17 -14
- package/src/Icon/useIcon.doc.mjs +6 -6
- package/src/IconButton/IconButton.doc.mjs +2 -2
- package/src/InfoTip/InfoTip.doc.mjs +1 -1
- package/src/InputGroup/InputGroup.tsx +5 -12
- package/src/InputGroup/InputGroupText.tsx +2 -3
- package/src/Kbd/Kbd.doc.mjs +5 -5
- package/src/Kbd/Kbd.tsx +3 -2
- package/src/Layer/gestureCounter.ts +39 -3
- package/src/Layer/layerHost.ts +3 -2
- package/src/Layer/outsidePanClaim.ts +50 -8
- package/src/Layer/outsidePress.ts +18 -4
- package/src/Layer/useLayer.tsx +128 -76
- package/src/Lightbox/Lightbox.tsx +15 -0
- package/src/MoreMenu/MoreMenu.doc.mjs +1 -1
- package/src/MultiSelector/MultiSelector.doc.mjs +2 -2
- package/src/MultiSelector/MultiSelector.tsx +24 -14
- package/src/NavIcon/NavIcon.doc.mjs +19 -10
- package/src/NavIcon/NavIcon.tsx +3 -2
- package/src/NavMenu/NavHeadingMenuItem.tsx +9 -3
- package/src/NumberInput/NumberInput.doc.mjs +12 -12
- package/src/NumberInput/NumberInput.tsx +12 -15
- package/src/NumberInput/numberParser.ts +15 -2
- package/src/Overlay/Overlay.doc.mjs +13 -1
- package/src/Overlay/OverlayScrim.tsx +45 -15
- package/src/Overlay/useOverlay.doc.mjs +7 -7
- package/src/Overlay/useOverlay.tsx +1 -1
- package/src/Pagination/Pagination.doc.mjs +9 -6
- package/src/Pagination/Pagination.tsx +15 -3
- package/src/Popover/usePopover.doc.mjs +14 -4
- package/src/Popover/usePopover.tsx +180 -23
- package/src/PowerSearch/PowerSearch.doc.mjs +165 -15
- package/src/PowerSearch/PowerSearch.tsx +6 -8
- package/src/PowerSearch/PowerSearchBottomSheet.tsx +13 -46
- package/src/PowerSearch/PowerSearchValueEditor.tsx +1 -51
- package/src/PowerSearch/formatFilterValue.ts +8 -9
- package/src/PowerSearch/formatTokenValue.ts +24 -42
- package/src/PowerSearch/relativeDateOptions.ts +84 -0
- package/src/ProgressBar/ProgressBar.doc.mjs +24 -5
- package/src/ProgressBar/ProgressBar.tsx +28 -18
- package/src/Resizable/createResizable.ts +46 -5
- package/src/SegmentedControl/SegmentedControlItem.tsx +4 -3
- package/src/SelectableCard/SelectableCard.tsx +8 -2
- package/src/Selector/Selector.doc.mjs +3 -3
- package/src/Selector/Selector.tsx +3 -1
- package/src/Selector/SelectorOption.doc.mjs +3 -3
- package/src/SideNav/SideNavItem.doc.mjs +6 -6
- package/src/Slider/Slider.tsx +4 -1
- package/src/Stepper/Step.tsx +7 -1
- package/src/Switch/Switch.doc.mjs +3 -3
- package/src/TabList/Tab.tsx +4 -0
- package/src/TabList/TabMenu.tsx +4 -0
- package/src/Table/BaseTable.tsx +14 -4
- package/src/Table/Table.doc.mjs +56 -6
- package/src/Table/Table.tsx +9 -4
- package/src/Table/TableHeaderCell.tsx +2 -8
- package/src/Table/plugins/sortable/useTableSortable.tsx +41 -2
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +49 -20
- package/src/Table/types.ts +5 -5
- package/src/Text/Text.tsx +21 -7
- package/src/Text/TruncationTooltip.tsx +51 -184
- package/src/Text/cutText.tsx +126 -0
- package/src/Text/cutTextOnKeyboardFocus.tsx +148 -0
- package/src/Text/textClampContext.ts +14 -4
- package/src/Text/useTruncation.ts +85 -27
- package/src/TextArea/TextArea.doc.mjs +4 -4
- package/src/TextInput/TextInput.doc.mjs +3 -3
- package/src/Thumbnail/Thumbnail.tsx +1 -1
- package/src/TimeInput/TimeInput.tsx +3 -9
- package/src/TimeInput/TouchTimeField.tsx +6 -4
- package/src/Timestamp/Timestamp.tsx +29 -21
- package/src/Timestamp/TimestampHoverCard.tsx +44 -31
- package/src/Timestamp/formatInstant.ts +7 -3
- package/src/Timestamp/tooltipEntries.ts +4 -2
- package/src/Toast/Toast.doc.mjs +24 -37
- package/src/Toast/Toast.tsx +77 -29
- package/src/Toast/ToastViewport.tsx +33 -13
- package/src/Toast/useToast.tsx +42 -15
- package/src/Tokenizer/Tokenizer.doc.mjs +2 -2
- package/src/Tooltip/useTooltip.tsx +2 -1
- package/src/TopNav/TopNavMegaMenu.doc.mjs +13 -0
- package/src/TopNav/TopNavMenu.doc.mjs +2 -0
- package/src/Typeahead/Typeahead.doc.mjs +2 -2
- package/src/hooks/useAnnounceRenderedText.ts +15 -2
- package/src/hooks/useFocusTrap.ts +27 -4
- package/src/hooks/useHotkeys.doc.mjs +54 -11
- package/src/hooks/useHotkeys.ts +72 -3
- package/src/hooks/useInputStatusIcon.tsx +2 -1
- package/src/hooks/useKeyboardHint.tsx +3 -2
- package/src/i18n/generated-english/DateRangeInput/DateRangeInput.generated.ts +2 -0
- package/src/i18n/generated-english/MultiSelector/MultiSelector.generated.ts +1 -0
- package/src/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.ts +0 -6
- package/src/i18n/generated-english/PowerSearch/relativeDateOptions.generated.ts +18 -0
- package/src/i18n/generated-english/Slider/Slider.generated.ts +1 -0
- package/src/i18n/generated-english/Thumbnail/Thumbnail.generated.ts +1 -0
- package/src/i18n/generated-locales/en.generated.ts +5 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +5 -0
- package/src/i18n/getLocaleDirection.ts +57 -7
- package/src/i18n/listFormat.ts +33 -0
- package/src/i18n/useListFormatter.ts +5 -12
- package/src/internal/module-loader.ts +15 -0
- package/src/motion/animatedLayout.ts +215 -28
- package/src/palette/color.ts +41 -1
- package/src/palette/derive-look.ts +1186 -0
- package/src/palette/editor-look.ts +480 -0
- package/src/palette/mapping.ts +129 -15
- package/src/theme/SyntaxTheme.doc.mjs +1 -1
- package/src/theme/tokens.ts +2 -1
- package/src/theme/useThemeName.doc.mjs +1 -1
- package/src/utils/characters.ts +11 -0
- package/src/utils/devWarning.ts +35 -0
- package/src/utils/focusReturn.ts +3 -11
- package/src/utils/hitArea.ts +87 -18
- package/src/utils/scrollView.ts +3 -2
- package/src/utils/textDirection.ts +33 -5
- package/src/utils/touchHitArea.ts +3 -2
- package/src/virtualization/useInlineListWindow.ts +102 -11
|
@@ -144,27 +144,44 @@ function countPinnedRuns(columns, startKeys, endKeys) {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
147
|
+
* Resolves how one column is pinned from the precomputed offsets. A key on
|
|
148
|
+
* both edges resolves to start. Returns `null` for a column that is not
|
|
149
|
+
* pinned.
|
|
150
150
|
*/
|
|
151
|
-
function resolveStickySide(
|
|
152
|
-
|
|
153
|
-
if (startOffsets?.has(columnKey)) {
|
|
151
|
+
function resolveStickySide(offsets, columnKey) {
|
|
152
|
+
if (offsets.start?.has(columnKey)) {
|
|
154
153
|
return {
|
|
155
154
|
edge: 'start',
|
|
156
|
-
offset:
|
|
155
|
+
offset: offsets.start.get(columnKey) ?? '0px'
|
|
157
156
|
};
|
|
158
157
|
}
|
|
159
|
-
|
|
160
|
-
if (endOffsets?.has(columnKey)) {
|
|
158
|
+
if (offsets.end?.has(columnKey)) {
|
|
161
159
|
return {
|
|
162
160
|
edge: 'end',
|
|
163
|
-
offset:
|
|
161
|
+
offset: offsets.end.get(columnKey) ?? '0px'
|
|
164
162
|
};
|
|
165
163
|
}
|
|
166
164
|
return null;
|
|
167
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Returns a reader of the pinned offsets for a column list. The offsets
|
|
168
|
+
* depend only on the columns and the pinned keys. Each cell of a render reads
|
|
169
|
+
* one result.
|
|
170
|
+
*/
|
|
171
|
+
function createPinnedOffsetsReader(startKeys, endKeys) {
|
|
172
|
+
let lastColumns;
|
|
173
|
+
let last;
|
|
174
|
+
return columns => {
|
|
175
|
+
if (last === undefined || columns !== lastColumns) {
|
|
176
|
+
lastColumns = columns;
|
|
177
|
+
last = {
|
|
178
|
+
start: computeStartOffsets(columns, startKeys),
|
|
179
|
+
end: computeEndOffsets(columns, endKeys)
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return last;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
168
185
|
|
|
169
186
|
// =============================================================================
|
|
170
187
|
// Styles
|
|
@@ -550,6 +567,7 @@ export function useTableStickyColumns(config) {
|
|
|
550
567
|
useLayoutEffect(() => {
|
|
551
568
|
refreshRef.current?.();
|
|
552
569
|
});
|
|
570
|
+
const readOffsets = useMemo(() => createPinnedOffsetsReader(pinned.start, pinned.end), [pinned]);
|
|
553
571
|
const plugin = useMemo(() => ({
|
|
554
572
|
rowModel: 'flat',
|
|
555
573
|
transformTableContext(children) {
|
|
@@ -560,11 +578,7 @@ export function useTableStickyColumns(config) {
|
|
|
560
578
|
});
|
|
561
579
|
},
|
|
562
580
|
transformHeaderCell(props, column) {
|
|
563
|
-
const
|
|
564
|
-
start: s,
|
|
565
|
-
end: e
|
|
566
|
-
} = pinned;
|
|
567
|
-
const side = resolveStickySide(props.columns, column.key, s, e);
|
|
581
|
+
const side = resolveStickySide(readOffsets(props.columns), column.key);
|
|
568
582
|
if (!side) {
|
|
569
583
|
return props;
|
|
570
584
|
}
|
|
@@ -601,11 +615,7 @@ export function useTableStickyColumns(config) {
|
|
|
601
615
|
};
|
|
602
616
|
},
|
|
603
617
|
transformBodyCell(props, column) {
|
|
604
|
-
const
|
|
605
|
-
start: s,
|
|
606
|
-
end: e
|
|
607
|
-
} = pinned;
|
|
608
|
-
const side = resolveStickySide(props.columns, column.key, s, e);
|
|
618
|
+
const side = resolveStickySide(readOffsets(props.columns), column.key);
|
|
609
619
|
if (!side) {
|
|
610
620
|
return props;
|
|
611
621
|
}
|
|
@@ -665,10 +675,10 @@ export function useTableStickyColumns(config) {
|
|
|
665
675
|
};
|
|
666
676
|
}
|
|
667
677
|
}),
|
|
668
|
-
// `
|
|
669
|
-
//
|
|
670
|
-
//
|
|
671
|
-
[attachScrollShadow,
|
|
678
|
+
// `attachScrollShadow` is stable, and `readOffsets` changes only with the
|
|
679
|
+
// pinned keys. So the plugin object changes only when the pinned keys
|
|
680
|
+
// change.
|
|
681
|
+
[attachScrollShadow, readOffsets]);
|
|
672
682
|
registerPinnedColumnRuns(plugin, columns => countPinnedRuns(columns, pinned.start, pinned.end));
|
|
673
683
|
return registerCountIndependentPlugin(plugin);
|
|
674
684
|
}
|
package/dist/Table/types.d.ts
CHANGED
|
@@ -164,18 +164,18 @@ export interface TableColumn<T extends Record<string, unknown>> {
|
|
|
164
164
|
* badges, status dots, formatted text, icons, or composed layouts.
|
|
165
165
|
*
|
|
166
166
|
* @compositionHint Use renderCell to compose rich table cells:
|
|
167
|
-
* -
|
|
168
|
-
* - StatusDot for colored indicators
|
|
167
|
+
* - StatusDot beside a Text label for a status column
|
|
169
168
|
* - Text with color="success"|"error" for formatted values
|
|
170
169
|
* - HStack to combine multiple elements in a cell
|
|
171
170
|
* - Avatar for user/entity cells
|
|
171
|
+
* - Badge only for a rare state that needs action, not in every row
|
|
172
172
|
*
|
|
173
173
|
* @example
|
|
174
|
-
* ```
|
|
174
|
+
* ```
|
|
175
175
|
* renderCell: (item) => (
|
|
176
176
|
* <HStack gap={2} align="center">
|
|
177
|
-
* <StatusDot
|
|
178
|
-
* <
|
|
177
|
+
* <StatusDot variant={item.isActive ? 'success' : 'neutral'} label={item.isActive ? 'Active' : 'Inactive'} />
|
|
178
|
+
* <Text>{item.isActive ? 'Active' : 'Inactive'}</Text>
|
|
179
179
|
* </HStack>
|
|
180
180
|
* )
|
|
181
181
|
* ```
|
package/dist/Text/Text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/Text/Text.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAc,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAElD,OAAO,KAAK,EACV,QAAQ,EAER,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAuBxB,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAG7C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/Text/Text.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAc,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAElD,OAAO,KAAK,EACV,QAAQ,EAER,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAuBxB,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAG7C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAO5C,YAAY,EAAC,QAAQ,EAAE,QAAQ,EAAC,CAAC;AAEjC,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;IAC5D,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC7B;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;IAEpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IAE9C;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,KAAK,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CAC1D;AA2BD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,gBAAgB,CAQpE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,EACnB,IAAa,EACb,IAAI,EACJ,KAAK,EACL,MAAM,EACN,OAAkB,EAClB,QAAY,EACZ,kBAAyB,EACzB,SAAS,EACT,QAAQ,EACR,OAAiB,EACjB,UAAkB,EAClB,gBAAwB,EACxB,iBAAyB,EACzB,MAAM,EACN,SAAS,EACT,KAAK,EACL,EAAE,EAAE,SAAkB,EACtB,QAAQ,EACR,GAAG,EACH,GAAG,KAAK,EACT,EAAE,SAAS,+BA8HX;yBAnJe,IAAI"}
|
package/dist/Text/Text.js
CHANGED
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
import { use, useRef } from 'react';
|
|
19
19
|
import * as stylex from '@stylexjs/stylex';
|
|
20
20
|
import { colorStyles, defaultWeightByTypeStyles, sizeStyles, sizeByTypeStyles, weightStyles, displayStyles, justifyStyles, truncationStyles, wordBreakStyles, textWrapStyles, capsizeStyles, decorationStyles, tabularNumbersStyle, truncationTooltipStyles } from "./text.stylex.js";
|
|
21
|
-
import {
|
|
21
|
+
import { useTruncationMeasure } from "./useTruncation.js";
|
|
22
22
|
import { TruncationTooltip, useTruncationTooltipInterest } from "./TruncationTooltip.js";
|
|
23
23
|
import { composeEventHandlers } from "../utils/composeEventHandlers.js";
|
|
24
24
|
import { mergeProps } from "../utils/mergeProps.js";
|
|
25
25
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
26
26
|
import { themeProps } from "../utils/themeProps.js";
|
|
27
|
-
import { TextClampContext } from "./textClampContext.js";
|
|
27
|
+
import { TextClampContext, TextMeasureOnInterestContext } from "./textClampContext.js";
|
|
28
28
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
29
|
// Default color by text type — custom types fall back to 'primary'
|
|
30
30
|
const defaultColorByType = {
|
|
@@ -123,21 +123,26 @@ export function Text({
|
|
|
123
123
|
// Resolve display - force block when maxLines > 0 or hasCapsize
|
|
124
124
|
const resolvedDisplay = maxLines > 0 || hasCapsize ? 'block' : display;
|
|
125
125
|
|
|
126
|
+
// A Table's default cells mount many texts at once. Text in them measures at
|
|
127
|
+
// each hover, tap or focus, not at mount.
|
|
128
|
+
const measuresOnInterest = use(TextMeasureOnInterestContext) && maxLines > 0 && hasTruncateTooltip !== false;
|
|
129
|
+
|
|
126
130
|
// Truncation detection. Only the tooltip reads the measured overflow, so
|
|
127
131
|
// with the tooltip off the text is clipped by CSS alone and nothing is
|
|
128
132
|
// measured or observed.
|
|
129
|
-
const truncation =
|
|
130
|
-
maxLines: hasTruncateTooltip === false ? 0 : maxLines
|
|
133
|
+
const truncation = useTruncationMeasure({
|
|
134
|
+
maxLines: hasTruncateTooltip === false ? 0 : maxLines,
|
|
135
|
+
measuresOnInterest
|
|
131
136
|
});
|
|
132
137
|
|
|
138
|
+
// Ref for the text element (used as tooltip anchor)
|
|
139
|
+
const textRef = useRef(null);
|
|
140
|
+
|
|
133
141
|
// Tooltip for truncated text
|
|
134
142
|
const tooltipPlacement = typeof hasTruncateTooltip === 'string' ? hasTruncateTooltip : 'above';
|
|
135
143
|
const tooltipEnabled = maxLines > 0 && hasTruncateTooltip !== false && truncation.isTruncated;
|
|
136
144
|
// The tooltip mounts on the first hover, tap or focus, not with the text.
|
|
137
|
-
const tooltipInterest = useTruncationTooltipInterest(tooltipEnabled);
|
|
138
|
-
|
|
139
|
-
// Ref for the text element (used as tooltip anchor)
|
|
140
|
-
const textRef = useRef(null);
|
|
145
|
+
const tooltipInterest = useTruncationTooltipInterest(tooltipEnabled, truncation.measure);
|
|
141
146
|
|
|
142
147
|
// Keep the merged ref stable across rerenders.
|
|
143
148
|
const mergedRef = useMergedRefs(ref, truncation.ref, textRef);
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* @file TruncationTooltip.tsx
|
|
3
3
|
* @input A truncated element's ref, its full text and the tooltip placement
|
|
4
4
|
* @output Exports `useTruncationTooltipInterest`, which loads the Tooltip
|
|
5
|
-
* module once text is truncated
|
|
6
|
-
*
|
|
5
|
+
* module once text is truncated, or after the page's first paint for text
|
|
6
|
+
* that measures on interest, and tracks the first hover, tap or focus on it,
|
|
7
|
+
* and `TruncationTooltip`, the Tooltip that mounts on that interaction
|
|
7
8
|
* @position Shared by Text, Heading and Lab's LineClamp (through Core's internal
|
|
8
9
|
* line-clamp entry). Until the first interaction a page of
|
|
9
10
|
* truncated text mounts no tooltip layers, and the tooltip that then mounts
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
*/
|
|
12
13
|
import { type FocusEvent, type PointerEvent, type ReactNode, type RefObject } from 'react';
|
|
13
14
|
import type { LayerPlacement } from '../Layer/index.js';
|
|
14
|
-
import type { Tooltip as TooltipType
|
|
15
|
+
import type { Tooltip as TooltipType } from '../Tooltip/Tooltip.js';
|
|
15
16
|
import { type TooltipPresentInterestState } from '../Tooltip/tooltipPresentInterest.js';
|
|
16
17
|
type TooltipComponent = typeof TooltipType;
|
|
17
18
|
export interface TruncationTooltipInterest {
|
|
@@ -29,12 +30,13 @@ export interface TruncationTooltipInterest {
|
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
32
|
* Tracks the interaction that mounts a truncated element's tooltip, while
|
|
32
|
-
* `isEnabled
|
|
33
|
+
* `isEnabled` or, with `measure`, while the interaction measures the text
|
|
34
|
+
* truncated, until the mounted tooltip reads it. A finger's arrival does not
|
|
33
35
|
* count: only a press that the touch trigger's recognizer takes for a tap
|
|
34
36
|
* does. Once the tooltip has read the interaction, its own listeners take
|
|
35
37
|
* over.
|
|
36
38
|
*/
|
|
37
|
-
export declare function useTruncationTooltipInterest(isEnabled: boolean): TruncationTooltipInterest;
|
|
39
|
+
export declare function useTruncationTooltipInterest(isEnabled: boolean, measure?: () => boolean): TruncationTooltipInterest;
|
|
38
40
|
/** The truncated element's Tooltip, given the interaction that mounted it. */
|
|
39
41
|
export declare function TruncationTooltip({ anchorRef, content, placement, interest, }: {
|
|
40
42
|
anchorRef: RefObject<HTMLElement | null>;
|
|
@@ -42,39 +44,5 @@ export declare function TruncationTooltip({ anchorRef, content, placement, inter
|
|
|
42
44
|
placement: LayerPlacement;
|
|
43
45
|
interest: TruncationTooltipInterest;
|
|
44
46
|
}): ReactNode;
|
|
45
|
-
type UndescribedTooltipComponent = typeof UndescribedTooltipType;
|
|
46
|
-
export interface CutTextOnKeyboardFocus {
|
|
47
|
-
/** The full text while keyboard focus is inside and the text is cut. */
|
|
48
|
-
readonly cutText: string | null;
|
|
49
|
-
/**
|
|
50
|
-
* The tooltip that shows `cutText` with no description, once its module
|
|
51
|
-
* has loaded (after the first render, as tooltip code loads).
|
|
52
|
-
*/
|
|
53
|
-
readonly Tooltip: UndescribedTooltipComponent | null;
|
|
54
|
-
/** Closes the tooltip; pass it as the tooltip's `onHide` (Escape). */
|
|
55
|
-
readonly hide: () => void;
|
|
56
|
-
readonly onFocus: (event: FocusEvent<HTMLElement>) => void;
|
|
57
|
-
readonly onBlur: (event: FocusEvent<HTMLElement>) => void;
|
|
58
|
-
/** A press closes it, as a press closes a tooltip. */
|
|
59
|
-
readonly onPointerDown: () => void;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Shows a component's cut text in an undescribed tooltip on keyboard focus:
|
|
63
|
-
* a Button's cut label, a table header cell's cut heading. When keyboard focus
|
|
64
|
-
* reaches the anchor (or an element inside it), it measures `measureRef`'s
|
|
65
|
-
* text; if the text is cut, `cutText` holds it until focus leaves the anchor,
|
|
66
|
-
* Escape, or a press. A hover, a pointer-focused field and a touch tap show
|
|
67
|
-
* nothing, and nothing is measured at rest. Internal: the package does not
|
|
68
|
-
* export it.
|
|
69
|
-
*/
|
|
70
|
-
export declare function useCutTextOnKeyboardFocus({ anchorRef, measureRef, isEnabled, isSuppressed, }: {
|
|
71
|
-
/** The element focus reaches and the tooltip attaches to. */
|
|
72
|
-
anchorRef: RefObject<HTMLElement | null>;
|
|
73
|
-
/** The element whose text is cut; the anchor itself when omitted. */
|
|
74
|
-
measureRef?: RefObject<HTMLElement | null>;
|
|
75
|
-
isEnabled: boolean;
|
|
76
|
-
/** Returns true when another tooltip already describes the anchor. */
|
|
77
|
-
isSuppressed?: (anchor: HTMLElement) => boolean;
|
|
78
|
-
}): CutTextOnKeyboardFocus;
|
|
79
47
|
export {};
|
|
80
48
|
//# sourceMappingURL=TruncationTooltip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TruncationTooltip.d.ts","sourceRoot":"","sources":["../../src/Text/TruncationTooltip.tsx"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"TruncationTooltip.d.ts","sourceRoot":"","sources":["../../src/Text/TruncationTooltip.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAE7C,OAAO,KAAK,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAG/D,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,mCAAmC,CAAC;AAE3C,KAAK,gBAAgB,GAAG,OAAO,WAAW,CAAC;AAqB3C,MAAM,WAAW,yBAAyB;IACxC,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC1C,4EAA4E;IAC5E,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC,2BAA2B,CAAC,CAAC;IAC7D,QAAQ,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACpE,QAAQ,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACpE,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACnE,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAC3D,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CAC3D;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,OAAO,EAIlB,OAAO,CAAC,EAAE,MAAM,OAAO,GACtB,yBAAyB,CAqH3B;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,OAAO,EACP,SAAS,EACT,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzC,OAAO,EAAE,SAAS,CAAC;IACnB,SAAS,EAAE,cAAc,CAAC;IAC1B,QAAQ,EAAE,yBAAyB,CAAC;CACrC,GAAG,SAAS,CAYZ"}
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* @file TruncationTooltip.tsx
|
|
7
7
|
* @input A truncated element's ref, its full text and the tooltip placement
|
|
8
8
|
* @output Exports `useTruncationTooltipInterest`, which loads the Tooltip
|
|
9
|
-
* module once text is truncated
|
|
10
|
-
*
|
|
9
|
+
* module once text is truncated, or after the page's first paint for text
|
|
10
|
+
* that measures on interest, and tracks the first hover, tap or focus on it,
|
|
11
|
+
* and `TruncationTooltip`, the Tooltip that mounts on that interaction
|
|
11
12
|
* @position Shared by Text, Heading and Lab's LineClamp (through Core's internal
|
|
12
13
|
* line-clamp entry). Until the first interaction a page of
|
|
13
14
|
* truncated text mounts no tooltip layers, and the tooltip that then mounts
|
|
@@ -15,7 +16,6 @@
|
|
|
15
16
|
*/
|
|
16
17
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
17
18
|
import { createModuleLoader } from "../utils/moduleLoader.js";
|
|
18
|
-
import { useInteractionModalityTrackingFor } from "../utils/interactionModality.js";
|
|
19
19
|
import { useTapRecognizer } from "../Layer/gestureCounter.js";
|
|
20
20
|
import { isElement } from "../utils/nodeType.js";
|
|
21
21
|
import { TooltipPresentInterestContext } from "../Tooltip/tooltipPresentInterest.js";
|
|
@@ -23,47 +23,80 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
23
23
|
// The Tooltip module. Once loaded, a tooltip renders from it at once: no
|
|
24
24
|
// boundary suspends, so the first hover's delay starts on the hover.
|
|
25
25
|
const tooltipModule = createModuleLoader(async () => import("../Tooltip/Tooltip.js"));
|
|
26
|
+
|
|
27
|
+
// The page's texts share one preload. It waits a frame and a task for the
|
|
28
|
+
// paint, then loads the module once. The shared loader keeps no failed load,
|
|
29
|
+
// so the next text tries again.
|
|
30
|
+
const afterPaintModule = createModuleLoader(async () => {
|
|
31
|
+
await new Promise(resolve => {
|
|
32
|
+
requestAnimationFrame(() => {
|
|
33
|
+
setTimeout(resolve, 0);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
return tooltipModule.load();
|
|
37
|
+
});
|
|
38
|
+
const loadAfterNextPaint = afterPaintModule.load;
|
|
26
39
|
/**
|
|
27
40
|
* Tracks the interaction that mounts a truncated element's tooltip, while
|
|
28
|
-
* `isEnabled
|
|
41
|
+
* `isEnabled` or, with `measure`, while the interaction measures the text
|
|
42
|
+
* truncated, until the mounted tooltip reads it. A finger's arrival does not
|
|
29
43
|
* count: only a press that the touch trigger's recognizer takes for a tap
|
|
30
44
|
* does. Once the tooltip has read the interaction, its own listeners take
|
|
31
45
|
* over.
|
|
32
46
|
*/
|
|
33
|
-
export function useTruncationTooltipInterest(isEnabled
|
|
47
|
+
export function useTruncationTooltipInterest(isEnabled,
|
|
48
|
+
// For text that measures on interest: measures now and returns whether the
|
|
49
|
+
// text is truncated, so the interaction that measures it can mount the
|
|
50
|
+
// tooltip.
|
|
51
|
+
measure) {
|
|
34
52
|
const [isWanted, setIsWanted] = useState(false);
|
|
35
53
|
const [tooltip, setTooltip] = useState(() => tooltipModule.loaded()?.Tooltip ?? null);
|
|
36
54
|
// Syncs with the module loader: truncated text loads the Tooltip module, so
|
|
37
|
-
// the first interaction mounts the tooltip at once.
|
|
55
|
+
// the first interaction mounts the tooltip at once. Text that measures on
|
|
56
|
+
// interest has no answer yet. It joins the page's one after-paint preload,
|
|
57
|
+
// so the page shows first, and a hover never hurries the load.
|
|
38
58
|
useEffect(() => {
|
|
39
|
-
if (!isEnabled || tooltip != null) {
|
|
59
|
+
if (!isEnabled && measure == null || tooltip != null) {
|
|
40
60
|
return;
|
|
41
61
|
}
|
|
42
62
|
let isCurrent = true;
|
|
43
|
-
|
|
63
|
+
const show = loaded => {
|
|
44
64
|
if (isCurrent) {
|
|
45
65
|
setTooltip(() => loaded.Tooltip);
|
|
46
66
|
}
|
|
47
|
-
}
|
|
67
|
+
};
|
|
68
|
+
(measure == null ? tooltipModule.load() : loadAfterNextPaint()).then(show, () => {});
|
|
48
69
|
return () => {
|
|
49
70
|
isCurrent = false;
|
|
50
71
|
};
|
|
51
|
-
}, [isEnabled, tooltip]);
|
|
72
|
+
}, [isEnabled, measure, tooltip]);
|
|
52
73
|
const interestRef = useRef({
|
|
53
74
|
interest: null,
|
|
54
75
|
tapEvent: null,
|
|
55
76
|
isRead: false
|
|
56
77
|
});
|
|
57
78
|
const tapRecognizer = useTapRecognizer();
|
|
79
|
+
// A tooltip that read an interaction unmounts while the text fits. When the
|
|
80
|
+
// text is cut off again, the next tooltip reads the next interaction.
|
|
81
|
+
const measureInterest = useCallback(() => {
|
|
82
|
+
if (measure == null) {
|
|
83
|
+
return isEnabled;
|
|
84
|
+
}
|
|
85
|
+
const isTruncated = measure();
|
|
86
|
+
if (isTruncated && !isEnabled) {
|
|
87
|
+
interestRef.current.isRead = false;
|
|
88
|
+
}
|
|
89
|
+
return isTruncated;
|
|
90
|
+
}, [isEnabled, measure]);
|
|
58
91
|
const want = useCallback((interest, tapEvent = null) => {
|
|
59
92
|
const state = interestRef.current;
|
|
60
|
-
if (!
|
|
93
|
+
if (!measureInterest() || state.isRead) {
|
|
61
94
|
return;
|
|
62
95
|
}
|
|
63
96
|
state.interest = interest;
|
|
64
97
|
state.tapEvent = tapEvent;
|
|
65
98
|
setIsWanted(true);
|
|
66
|
-
}, [
|
|
99
|
+
}, [measureInterest]);
|
|
67
100
|
const forget = useCallback(interest => {
|
|
68
101
|
const state = interestRef.current;
|
|
69
102
|
if (!state.isRead && state.interest === interest) {
|
|
@@ -77,7 +110,7 @@ export function useTruncationTooltipInterest(isEnabled) {
|
|
|
77
110
|
}, [want]);
|
|
78
111
|
const onPointerLeave = useCallback(() => forget('hover'), [forget]);
|
|
79
112
|
const onPointerDown = useCallback(event => {
|
|
80
|
-
if (!
|
|
113
|
+
if (!measureInterest() || interestRef.current.isRead) {
|
|
81
114
|
tapRecognizer.forget();
|
|
82
115
|
return;
|
|
83
116
|
}
|
|
@@ -87,7 +120,7 @@ export function useTruncationTooltipInterest(isEnabled) {
|
|
|
87
120
|
if (!isTouch) {
|
|
88
121
|
forget('hover');
|
|
89
122
|
}
|
|
90
|
-
}, [
|
|
123
|
+
}, [measureInterest, tapRecognizer, want, forget]);
|
|
91
124
|
const onFocus = useCallback(event => {
|
|
92
125
|
const target = event.target;
|
|
93
126
|
if (isElement(target) && target.matches(':focus-visible') &&
|
|
@@ -131,118 +164,4 @@ export function TruncationTooltip({
|
|
|
131
164
|
placement: placement
|
|
132
165
|
})
|
|
133
166
|
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/** Whether a box clips its content. */
|
|
137
|
-
function overflows(element) {
|
|
138
|
-
const box = element.clientWidth || (element instanceof HTMLElement ? element.offsetWidth : 0);
|
|
139
|
-
return box > 0 && element.scrollWidth > box;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** Whether an element is visually hidden: a screen-reader-only label. */
|
|
143
|
-
function isVisuallyHidden(element) {
|
|
144
|
-
const style = element.ownerDocument.defaultView?.getComputedStyle(element);
|
|
145
|
-
return style != null && style.position === 'absolute' && (style.clip !== '' && style.clip !== 'auto' || style.clipPath !== '' && style.clipPath !== 'none');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// A field and its value: an input, or a widget that shows a chosen value (a
|
|
149
|
-
// Selector's combobox). Its value is not the component's text.
|
|
150
|
-
const FIELD_SELECTOR = 'input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="combobox"], [role="listbox"], [role="searchbox"], [role="spinbutton"], [role="slider"], [role="textbox"]';
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Whether an element is left out of the measured text: hidden, a hidden copy
|
|
154
|
-
* (ToggleButton's bold-width reservation), visually hidden, or a field, whose
|
|
155
|
-
* value clips inside its own box and is not the cut text.
|
|
156
|
-
*/
|
|
157
|
-
function isLeftOut(element) {
|
|
158
|
-
return element.closest(`[hidden], [aria-hidden="true"], ${FIELD_SELECTOR}`) != null || isVisuallyHidden(element);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/** Whether text is cut: its box, or a box inside it that a reader sees, clips it. */
|
|
162
|
-
function isTextCut(element) {
|
|
163
|
-
return overflows(element) || [...element.querySelectorAll('*')].some(child => !isLeftOut(child) && overflows(child));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* The text a sighted reader sees, without hidden, visually hidden and field
|
|
168
|
-
* text: the label or heading itself.
|
|
169
|
-
*/
|
|
170
|
-
function visibleText(root) {
|
|
171
|
-
let text = '';
|
|
172
|
-
const walk = node => {
|
|
173
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
174
|
-
text += node.textContent ?? '';
|
|
175
|
-
} else if (node instanceof Element && !isLeftOut(node)) {
|
|
176
|
-
node.childNodes.forEach(walk);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
walk(root);
|
|
180
|
-
return text.replace(/\s+/g, ' ').trim();
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Shows a component's cut text in an undescribed tooltip on keyboard focus:
|
|
184
|
-
* a Button's cut label, a table header cell's cut heading. When keyboard focus
|
|
185
|
-
* reaches the anchor (or an element inside it), it measures `measureRef`'s
|
|
186
|
-
* text; if the text is cut, `cutText` holds it until focus leaves the anchor,
|
|
187
|
-
* Escape, or a press. A hover, a pointer-focused field and a touch tap show
|
|
188
|
-
* nothing, and nothing is measured at rest. Internal: the package does not
|
|
189
|
-
* export it.
|
|
190
|
-
*/
|
|
191
|
-
export function useCutTextOnKeyboardFocus({
|
|
192
|
-
anchorRef,
|
|
193
|
-
measureRef,
|
|
194
|
-
isEnabled,
|
|
195
|
-
isSuppressed
|
|
196
|
-
}) {
|
|
197
|
-
const [cutText, setCutText] = useState(null);
|
|
198
|
-
const [Tooltip, setTooltip] = useState(() => tooltipModule.loaded()?.UndescribedTooltip ?? null);
|
|
199
|
-
const readModality = useInteractionModalityTrackingFor(anchorRef, isEnabled);
|
|
200
|
-
// Syncs with the module loader: the tooltip loads after the first render,
|
|
201
|
-
// so keyboard focus shows it at once.
|
|
202
|
-
useEffect(() => {
|
|
203
|
-
if (!isEnabled || Tooltip != null) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
let isCurrent = true;
|
|
207
|
-
tooltipModule.load().then(loaded => {
|
|
208
|
-
if (isCurrent) {
|
|
209
|
-
setTooltip(() => loaded.UndescribedTooltip);
|
|
210
|
-
}
|
|
211
|
-
}, () => {});
|
|
212
|
-
return () => {
|
|
213
|
-
isCurrent = false;
|
|
214
|
-
};
|
|
215
|
-
}, [isEnabled, Tooltip]);
|
|
216
|
-
const hide = useCallback(() => setCutText(null), []);
|
|
217
|
-
const onFocus = event => {
|
|
218
|
-
const anchor = anchorRef.current;
|
|
219
|
-
const measured = measureRef?.current ?? anchor;
|
|
220
|
-
const target = event.target;
|
|
221
|
-
// `:focus-visible` also matches a text field a pointer focused, so the
|
|
222
|
-
// modality reader decides: only keyboard focus counts.
|
|
223
|
-
if (!isEnabled || anchor == null || measured == null || !isElement(target) ||
|
|
224
|
-
// React delivers focus from a portal (a header's filter popover) to the
|
|
225
|
-
// anchor's handlers; only focus inside the anchor counts.
|
|
226
|
-
!anchor.contains(target) || !target.matches(':focus-visible') || readModality() !== 'keyboard') {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
const text = visibleText(measured);
|
|
230
|
-
const isCut = text !== '' && !(isSuppressed?.(anchor) ?? false) && isTextCut(measured);
|
|
231
|
-
setCutText(isCut ? text : null);
|
|
232
|
-
};
|
|
233
|
-
const onBlur = event => {
|
|
234
|
-
const next = event.relatedTarget;
|
|
235
|
-
if (isElement(next) && anchorRef.current?.contains(next)) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
setCutText(null);
|
|
239
|
-
};
|
|
240
|
-
return {
|
|
241
|
-
cutText,
|
|
242
|
-
Tooltip,
|
|
243
|
-
hide,
|
|
244
|
-
onFocus,
|
|
245
|
-
onBlur,
|
|
246
|
-
onPointerDown: hide
|
|
247
|
-
};
|
|
248
167
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file cutText.tsx
|
|
3
|
+
* @input The anchor keyboard focus reached, the element whose text a box may
|
|
4
|
+
* cut short, and the focused element
|
|
5
|
+
* @output Exports `cutTextFor`, which measures that text, and
|
|
6
|
+
* `UndescribedTooltip`, which shows it in full
|
|
7
|
+
* @position Loaded by Text/cutTextOnKeyboardFocus.tsx after the page's first
|
|
8
|
+
* paint, so neither the measurement nor the tooltip is in a page's first
|
|
9
|
+
* load
|
|
10
|
+
*/
|
|
11
|
+
import type { RefObject } from 'react';
|
|
12
|
+
import { UndescribedTooltip } from '../Tooltip/Tooltip.js';
|
|
13
|
+
/**
|
|
14
|
+
* The text keyboard focus on `target` should show for the anchor: the
|
|
15
|
+
* measured element's text (the anchor's own without `measureRef`) when a box
|
|
16
|
+
* cuts it short and focus is inside the anchor; otherwise `null`. With
|
|
17
|
+
* `yieldsToCallerTooltip` (a Button), a caller tooltip that describes the
|
|
18
|
+
* anchor also gives `null`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function cutTextFor(anchorRef: RefObject<HTMLElement | null>, measureRef: RefObject<HTMLElement | null> | undefined, target: Element, yieldsToCallerTooltip: boolean): string | null;
|
|
21
|
+
export { UndescribedTooltip };
|
|
22
|
+
//# sourceMappingURL=cutText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cutText.d.ts","sourceRoot":"","sources":["../../src/Text/cutText.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAgFtD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACxC,UAAU,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,SAAS,EACrD,MAAM,EAAE,OAAO,EACf,qBAAqB,EAAE,OAAO,GAC7B,MAAM,GAAG,IAAI,CAef;AAED,OAAO,EAAC,kBAAkB,EAAC,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file cutText.tsx
|
|
7
|
+
* @input The anchor keyboard focus reached, the element whose text a box may
|
|
8
|
+
* cut short, and the focused element
|
|
9
|
+
* @output Exports `cutTextFor`, which measures that text, and
|
|
10
|
+
* `UndescribedTooltip`, which shows it in full
|
|
11
|
+
* @position Loaded by Text/cutTextOnKeyboardFocus.tsx after the page's first
|
|
12
|
+
* paint, so neither the measurement nor the tooltip is in a page's first
|
|
13
|
+
* load
|
|
14
|
+
*/
|
|
15
|
+
import { UndescribedTooltip } from "../Tooltip/Tooltip.js";
|
|
16
|
+
|
|
17
|
+
/** Whether a box clips its content. */
|
|
18
|
+
function overflows(element) {
|
|
19
|
+
const box = element.clientWidth || (element instanceof HTMLElement ? element.offsetWidth : 0);
|
|
20
|
+
return box > 0 && element.scrollWidth > box;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Whether an element is visually hidden: a screen-reader-only label. */
|
|
24
|
+
function isVisuallyHidden(element) {
|
|
25
|
+
const style = element.ownerDocument.defaultView?.getComputedStyle(element);
|
|
26
|
+
return style != null && style.position === 'absolute' && (style.clip !== '' && style.clip !== 'auto' || style.clipPath !== '' && style.clipPath !== 'none');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// A field and its value: an input, or a widget that shows a chosen value (a
|
|
30
|
+
// Selector's combobox). Its value is not the component's text.
|
|
31
|
+
const FIELD_SELECTOR = 'input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="combobox"], [role="listbox"], [role="searchbox"], [role="spinbutton"], [role="slider"], [role="textbox"]';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Whether an element is left out of the measured text: hidden, a hidden copy
|
|
35
|
+
* (ToggleButton's bold-width reservation), visually hidden, or a field, whose
|
|
36
|
+
* value clips inside its own box and is not the cut text.
|
|
37
|
+
*/
|
|
38
|
+
function isLeftOut(element) {
|
|
39
|
+
return element.closest(`[hidden], [aria-hidden="true"], ${FIELD_SELECTOR}`) != null || isVisuallyHidden(element);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Whether text is cut: its box, or a box inside it that a reader sees, clips it. */
|
|
43
|
+
function isTextCut(element) {
|
|
44
|
+
return overflows(element) || [...element.querySelectorAll('*')].some(child => !isLeftOut(child) && overflows(child));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The text a sighted reader sees, without hidden, visually hidden and field
|
|
49
|
+
* text: the label or heading itself.
|
|
50
|
+
*/
|
|
51
|
+
function visibleText(root) {
|
|
52
|
+
let text = '';
|
|
53
|
+
const walk = node => {
|
|
54
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
55
|
+
text += node.textContent ?? '';
|
|
56
|
+
} else if (node instanceof Element && !isLeftOut(node)) {
|
|
57
|
+
node.childNodes.forEach(walk);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
walk(root);
|
|
61
|
+
return text.replace(/\s+/g, ' ').trim();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Whether a caller's tooltip already describes the anchor (a Button's
|
|
66
|
+
* `tooltip` prop or a wrapping Tooltip). Its tooltip replaces this one, so one
|
|
67
|
+
* tooltip shows at one spot.
|
|
68
|
+
*/
|
|
69
|
+
function hasCallerTooltip(anchor) {
|
|
70
|
+
const ids = anchor.getAttribute('aria-describedby')?.split(/\s+/) ?? [];
|
|
71
|
+
return ids.some(id => id !== '' && anchor.ownerDocument.getElementById(id)?.getAttribute('role') === 'tooltip');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The text keyboard focus on `target` should show for the anchor: the
|
|
76
|
+
* measured element's text (the anchor's own without `measureRef`) when a box
|
|
77
|
+
* cuts it short and focus is inside the anchor; otherwise `null`. With
|
|
78
|
+
* `yieldsToCallerTooltip` (a Button), a caller tooltip that describes the
|
|
79
|
+
* anchor also gives `null`.
|
|
80
|
+
*/
|
|
81
|
+
export function cutTextFor(anchorRef, measureRef, target, yieldsToCallerTooltip) {
|
|
82
|
+
const anchor = anchorRef.current;
|
|
83
|
+
const measured = measureRef?.current ?? anchor;
|
|
84
|
+
// React delivers focus from a portal (a header's filter popover) to the
|
|
85
|
+
// anchor's handlers; only focus inside the anchor counts.
|
|
86
|
+
if (anchor == null || measured == null || !anchor.contains(target) || yieldsToCallerTooltip && hasCallerTooltip(anchor)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const text = visibleText(measured);
|
|
90
|
+
return text !== '' && isTextCut(measured) ? text : null;
|
|
91
|
+
}
|
|
92
|
+
export { UndescribedTooltip };
|