@astryxdesign/core 0.7.17 → 0.7.18-canary.g32556bb
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/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +8 -2
- 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/inputHold.d.ts +13 -0
- package/dist/Layer/inputHold.d.ts.map +1 -1
- package/dist/Layer/inputHold.js +203 -14
- 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/MetadataList/MetadataList.d.ts +1 -1
- package/dist/MetadataList/MetadataList.d.ts.map +1 -1
- package/dist/MetadataList/MetadataList.js +8 -0
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +37 -17
- 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 +173 -185
- 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/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +1 -1
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +53 -8
- 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 +30 -8
- 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/TableCell.d.ts.map +1 -1
- package/dist/Table/TableCell.js +2 -2
- package/dist/Table/TableHeaderCell.d.ts.map +1 -1
- package/dist/Table/TableHeaderCell.js +3 -7
- package/dist/Table/TableRow.d.ts.map +1 -1
- package/dist/Table/TableRow.js +10 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts +11 -3
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +203 -51
- package/dist/Table/plugins/rowIndex/useTableRowIndex.d.ts.map +1 -1
- package/dist/Table/plugins/rowIndex/useTableRowIndex.js +4 -1
- package/dist/Table/plugins/rowStatus/useTableRowStatus.d.ts.map +1 -1
- package/dist/Table/plugins/rowStatus/useTableRowStatus.js +2 -0
- 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/tableColumnAdmission.d.ts +7 -0
- package/dist/Table/tableColumnAdmission.d.ts.map +1 -1
- package/dist/Table/tableColumnAdmission.js +15 -0
- 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 +112 -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/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar/Toolbar.js +20 -3
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +3 -3
- package/dist/astryx.css +41 -10
- 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 +34 -0
- package/dist/i18n/listFormat.d.ts.map +1 -0
- package/dist/i18n/listFormat.js +45 -0
- package/dist/i18n/useListFormatter.d.ts +7 -3
- package/dist/i18n/useListFormatter.d.ts.map +1 -1
- package/dist/i18n/useListFormatter.js +16 -13
- 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/mergeProps.d.ts.map +1 -1
- package/dist/utils/mergeProps.js +53 -38
- 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 +29 -5
- package/dist/utils/textDirection.d.ts.map +1 -1
- package/dist/utils/textDirection.js +56 -4
- package/dist/utils/themeProps.d.ts.map +1 -1
- package/dist/utils/themeProps.js +22 -3
- 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/Item/Item.tsx +10 -1
- 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/inputHold.ts +241 -18
- 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/MetadataList/MetadataList.tsx +8 -0
- package/src/MoreMenu/MoreMenu.doc.mjs +1 -1
- package/src/MultiSelector/MultiSelector.doc.mjs +2 -2
- package/src/MultiSelector/MultiSelector.tsx +45 -15
- 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 +182 -223
- 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/SideNav/SideNavItem.tsx +3 -0
- package/src/Slider/Slider.tsx +48 -6
- 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 +35 -7
- package/src/Table/Table.doc.mjs +63 -6
- package/src/Table/Table.tsx +9 -4
- package/src/Table/TableCell.tsx +5 -2
- package/src/Table/TableHeaderCell.tsx +2 -8
- package/src/Table/TableRow.tsx +10 -1
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +250 -53
- package/src/Table/plugins/rowIndex/useTableRowIndex.tsx +10 -1
- package/src/Table/plugins/rowStatus/useTableRowStatus.tsx +5 -0
- package/src/Table/plugins/sortable/useTableSortable.tsx +41 -2
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +49 -20
- package/src/Table/tableColumnAdmission.ts +23 -0
- package/src/Table/types.ts +5 -5
- package/src/Table/useTableRowsVirtualization.doc.mjs +2 -2
- 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 +158 -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/Toolbar/Toolbar.tsx +20 -6
- 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 +55 -0
- package/src/i18n/useListFormatter.ts +22 -13
- 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/mergeProps.ts +57 -34
- package/src/utils/scrollView.ts +3 -2
- package/src/utils/textDirection.ts +65 -5
- package/src/utils/themeProps.ts +22 -3
- package/src/utils/touchHitArea.ts +3 -2
- package/src/virtualization/useInlineListWindow.ts +102 -11
|
@@ -194,27 +194,54 @@ function countPinnedRuns(
|
|
|
194
194
|
type StickySide = {edge: 'start' | 'end'; offset: string};
|
|
195
195
|
|
|
196
196
|
/**
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
197
|
+
* Resolves how one column is pinned from the precomputed offsets. A key on
|
|
198
|
+
* both edges resolves to start. Returns `null` for a column that is not
|
|
199
|
+
* pinned.
|
|
200
200
|
*/
|
|
201
201
|
function resolveStickySide(
|
|
202
|
-
|
|
202
|
+
offsets: PinnedOffsets,
|
|
203
203
|
columnKey: string,
|
|
204
|
-
startKeys: string[],
|
|
205
|
-
endKeys: string[],
|
|
206
204
|
): StickySide | null {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return {edge: 'start', offset: startOffsets.get(columnKey) ?? '0px'};
|
|
205
|
+
if (offsets.start?.has(columnKey)) {
|
|
206
|
+
return {edge: 'start', offset: offsets.start.get(columnKey) ?? '0px'};
|
|
210
207
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return {edge: 'end', offset: endOffsets.get(columnKey) ?? '0px'};
|
|
208
|
+
if (offsets.end?.has(columnKey)) {
|
|
209
|
+
return {edge: 'end', offset: offsets.end.get(columnKey) ?? '0px'};
|
|
214
210
|
}
|
|
215
211
|
return null;
|
|
216
212
|
}
|
|
217
213
|
|
|
214
|
+
interface PinnedOffsets {
|
|
215
|
+
start: Map<string, string> | null;
|
|
216
|
+
end: Map<string, string> | null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Returns a reader of the pinned offsets for a column list. The offsets
|
|
221
|
+
* depend only on the columns and the pinned keys. Each cell of a render reads
|
|
222
|
+
* one result.
|
|
223
|
+
*/
|
|
224
|
+
function createPinnedOffsetsReader(
|
|
225
|
+
startKeys: string[],
|
|
226
|
+
endKeys: string[],
|
|
227
|
+
): (
|
|
228
|
+
columns: ReadonlyArray<TableColumn<Record<string, unknown>>> | undefined,
|
|
229
|
+
) => PinnedOffsets {
|
|
230
|
+
let lastColumns:
|
|
231
|
+
ReadonlyArray<TableColumn<Record<string, unknown>>> | undefined;
|
|
232
|
+
let last: PinnedOffsets | undefined;
|
|
233
|
+
return columns => {
|
|
234
|
+
if (last === undefined || columns !== lastColumns) {
|
|
235
|
+
lastColumns = columns;
|
|
236
|
+
last = {
|
|
237
|
+
start: computeStartOffsets(columns, startKeys),
|
|
238
|
+
end: computeEndOffsets(columns, endKeys),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
return last;
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
218
245
|
// =============================================================================
|
|
219
246
|
// Styles
|
|
220
247
|
// =============================================================================
|
|
@@ -676,6 +703,10 @@ export function useTableStickyColumns<T extends Record<string, unknown>>(
|
|
|
676
703
|
refreshRef.current?.();
|
|
677
704
|
});
|
|
678
705
|
|
|
706
|
+
const readOffsets = useMemo(
|
|
707
|
+
() => createPinnedOffsetsReader(pinned.start, pinned.end),
|
|
708
|
+
[pinned],
|
|
709
|
+
);
|
|
679
710
|
const plugin = useMemo(
|
|
680
711
|
(): TablePlugin<T> => ({
|
|
681
712
|
rowModel: 'flat',
|
|
@@ -691,8 +722,7 @@ export function useTableStickyColumns<T extends Record<string, unknown>>(
|
|
|
691
722
|
props: HeaderCellRenderProps,
|
|
692
723
|
column: TableColumn<T>,
|
|
693
724
|
): HeaderCellRenderProps {
|
|
694
|
-
const
|
|
695
|
-
const side = resolveStickySide(props.columns, column.key, s, e);
|
|
725
|
+
const side = resolveStickySide(readOffsets(props.columns), column.key);
|
|
696
726
|
if (!side) {
|
|
697
727
|
return props;
|
|
698
728
|
}
|
|
@@ -732,8 +762,7 @@ export function useTableStickyColumns<T extends Record<string, unknown>>(
|
|
|
732
762
|
props: BodyCellRenderProps,
|
|
733
763
|
column: TableColumn<T>,
|
|
734
764
|
): BodyCellRenderProps {
|
|
735
|
-
const
|
|
736
|
-
const side = resolveStickySide(props.columns, column.key, s, e);
|
|
765
|
+
const side = resolveStickySide(readOffsets(props.columns), column.key);
|
|
737
766
|
if (!side) {
|
|
738
767
|
return props;
|
|
739
768
|
}
|
|
@@ -801,10 +830,10 @@ export function useTableStickyColumns<T extends Record<string, unknown>>(
|
|
|
801
830
|
};
|
|
802
831
|
},
|
|
803
832
|
}),
|
|
804
|
-
// `
|
|
805
|
-
//
|
|
806
|
-
//
|
|
807
|
-
[attachScrollShadow,
|
|
833
|
+
// `attachScrollShadow` is stable, and `readOffsets` changes only with the
|
|
834
|
+
// pinned keys. So the plugin object changes only when the pinned keys
|
|
835
|
+
// change.
|
|
836
|
+
[attachScrollShadow, readOffsets],
|
|
808
837
|
);
|
|
809
838
|
registerPinnedColumnRuns(plugin, columns =>
|
|
810
839
|
countPinnedRuns(columns, pinned.start, pinned.end),
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type {ReactNode} from 'react';
|
|
9
9
|
import type {TableColumn} from './types';
|
|
10
|
+
import {sharedWeakMap} from '../utils/sharedRealm';
|
|
10
11
|
const heightSafe = new WeakMap<object, boolean>();
|
|
12
|
+
const fallbackReasons = sharedWeakMap<object, string>(
|
|
13
|
+
'table/table-column-admission/fallback-reasons',
|
|
14
|
+
1,
|
|
15
|
+
);
|
|
11
16
|
const logicalRenderers = new WeakMap<
|
|
12
17
|
object,
|
|
13
18
|
(logicalIndex: number) => ReactNode
|
|
@@ -24,6 +29,24 @@ export function registerFixedHeightColumn<T extends Record<string, unknown>>(
|
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Names why a first-party column keeps Table from windowing its rows, for the
|
|
34
|
+
* development warning. Without one, the warning reads as a caller's renderCell.
|
|
35
|
+
*/
|
|
36
|
+
export function registerWindowFallbackReason<T extends Record<string, unknown>>(
|
|
37
|
+
column: TableColumn<T>,
|
|
38
|
+
reason: string,
|
|
39
|
+
): void {
|
|
40
|
+
fallbackReasons.set(column, reason);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The reason a first-party column keeps Table from windowing, if it has one. */
|
|
44
|
+
export function getWindowFallbackReason<T extends Record<string, unknown>>(
|
|
45
|
+
column: TableColumn<T>,
|
|
46
|
+
): string | undefined {
|
|
47
|
+
return fallbackReasons.get(column);
|
|
48
|
+
}
|
|
49
|
+
|
|
27
50
|
/**
|
|
28
51
|
* Widens logical-position columns to the measured widths, by column index,
|
|
29
52
|
* that fit the last position. A column keeps a declared width that already
|
package/src/Table/types.ts
CHANGED
|
@@ -201,18 +201,18 @@ export interface TableColumn<T extends Record<string, unknown>> {
|
|
|
201
201
|
* badges, status dots, formatted text, icons, or composed layouts.
|
|
202
202
|
*
|
|
203
203
|
* @compositionHint Use renderCell to compose rich table cells:
|
|
204
|
-
* -
|
|
205
|
-
* - StatusDot for colored indicators
|
|
204
|
+
* - StatusDot beside a Text label for a status column
|
|
206
205
|
* - Text with color="success"|"error" for formatted values
|
|
207
206
|
* - HStack to combine multiple elements in a cell
|
|
208
207
|
* - Avatar for user/entity cells
|
|
208
|
+
* - Badge only for a rare state that needs action, not in every row
|
|
209
209
|
*
|
|
210
210
|
* @example
|
|
211
|
-
* ```
|
|
211
|
+
* ```
|
|
212
212
|
* renderCell: (item) => (
|
|
213
213
|
* <HStack gap={2} align="center">
|
|
214
|
-
* <StatusDot
|
|
215
|
-
* <
|
|
214
|
+
* <StatusDot variant={item.isActive ? 'success' : 'neutral'} label={item.isActive ? 'Active' : 'Inactive'} />
|
|
215
|
+
* <Text>{item.isActive ? 'Active' : 'Inactive'}</Text>
|
|
216
216
|
* </HStack>
|
|
217
217
|
* )
|
|
218
218
|
* ```
|
|
@@ -6,7 +6,7 @@ export const docs = {
|
|
|
6
6
|
subComponentOf: 'Table',
|
|
7
7
|
displayName: 'useTableRowsVirtualization',
|
|
8
8
|
description:
|
|
9
|
-
"Returns an opaque capability for fixed-height flat-row Table windowing. Pass the capability to Table.virtualization and keep the complete data, columns, explicit stable idKey and plugins on Table. Sizes are positive finite CSS pixels. The Table scrolls inside the height its parent gives it and fills all of it. Give the Table's parent a height, fixed or relative, or a flex child, so windowing can bound the rows; with no height every row renders. Make the Table the parent's only child, or a flex child with min-height: 0 beside a heading or toolbar. Supported rows use single-line content; explicit wrapping,
|
|
9
|
+
"Returns an opaque capability for fixed-height flat-row Table windowing. Pass the capability to Table.virtualization and keep the complete data, columns, explicit stable idKey and plugins on Table. Sizes are positive finite CSS pixels. The Table scrolls inside the height its parent gives it and fills all of it. Give the Table's parent a height, fixed or relative, or a flex child, so windowing can bound the rows; with no height every row renders. Make the Table the parent's only child, or a flex child with min-height: 0 beside a heading or toolbar. Supported rows use single-line content; explicit wrapping, non-flat rows or invalid identity use ordinary full rendering. What stays windowed: a column without renderCell (its default cell renders the row's value as single-line text) and the row-number (useTableRowIndex, counting from 1) and selection (useTableSelection) columns. A column with a custom renderCell turns windowing off for the whole table, because Table cannot check that the cell keeps the fixed row height; it renders every row and warns in development, naming the column. A useTableRowStatus column, or a useTableRowIndex column that counts from another number, turns windowing off too. To window a table, put the text a column shows in the row data and leave renderCell off that column. Windowing uses the Table-owned scroll wrapper; a caller-provided scrollWrapper takes diagnostic full-render fallback. Mounted rows retain native table semantics and full-table positions; unmounted rows are not promised screen-reader discovery.",
|
|
10
10
|
props: [
|
|
11
11
|
{
|
|
12
12
|
name: 'rowHeight',
|
|
@@ -28,7 +28,7 @@ export const docs = {
|
|
|
28
28
|
/** @type {import('@astryxdesign/cli/authoring').ComponentTranslationDoc} */
|
|
29
29
|
export const docsDense = {
|
|
30
30
|
description:
|
|
31
|
-
'Geometry-only fixed-height flat-row opt-in for Table.virtualization. Keep full data and stable idKey on Table. Positive finite CSS-pixel sizes; unsupported content, geometry, identity or a caller scrollWrapper falls back to full rendering. Native mounted-row semantics, not discovery of unmounted rows.',
|
|
31
|
+
'Geometry-only fixed-height flat-row opt-in for Table.virtualization. Keep full data and stable idKey on Table. Positive finite CSS-pixel sizes; unsupported content, geometry, identity or a caller scrollWrapper falls back to full rendering. Native mounted-row semantics, not discovery of unmounted rows. Windowed: columns without renderCell, row-number (from 1) and selection columns; any custom renderCell turns windowing off for the table, with a development warning naming the column.',
|
|
32
32
|
propDescriptions: {
|
|
33
33
|
rowHeight:
|
|
34
34
|
'Total body-row pitch including density padding and borders; text and supported controls must fit. Taller equal rows window at their measured height.',
|
package/src/Text/Text.tsx
CHANGED
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
tabularNumbersStyle,
|
|
47
47
|
truncationTooltipStyles,
|
|
48
48
|
} from './text.stylex';
|
|
49
|
-
import {
|
|
49
|
+
import {useTruncationMeasure} from './useTruncation';
|
|
50
50
|
import {
|
|
51
51
|
TruncationTooltip,
|
|
52
52
|
useTruncationTooltipInterest,
|
|
@@ -57,7 +57,10 @@ import {mergeProps} from '../utils/mergeProps';
|
|
|
57
57
|
import {useMergedRefs} from '../hooks/useMergedRefs';
|
|
58
58
|
import type {BaseProps} from '../BaseProps';
|
|
59
59
|
import {themeProps} from '../utils/themeProps';
|
|
60
|
-
import {
|
|
60
|
+
import {
|
|
61
|
+
TextClampContext,
|
|
62
|
+
TextMeasureOnInterestContext,
|
|
63
|
+
} from './textClampContext';
|
|
61
64
|
|
|
62
65
|
export type {TextType, TextSize};
|
|
63
66
|
|
|
@@ -262,23 +265,34 @@ export function Text({
|
|
|
262
265
|
// Resolve display - force block when maxLines > 0 or hasCapsize
|
|
263
266
|
const resolvedDisplay = maxLines > 0 || hasCapsize ? 'block' : display;
|
|
264
267
|
|
|
268
|
+
// A Table's default cells mount many texts at once. Text in them measures at
|
|
269
|
+
// each hover, tap or focus, not at mount.
|
|
270
|
+
const measuresOnInterest =
|
|
271
|
+
use(TextMeasureOnInterestContext) &&
|
|
272
|
+
maxLines > 0 &&
|
|
273
|
+
hasTruncateTooltip !== false;
|
|
274
|
+
|
|
265
275
|
// Truncation detection. Only the tooltip reads the measured overflow, so
|
|
266
276
|
// with the tooltip off the text is clipped by CSS alone and nothing is
|
|
267
277
|
// measured or observed.
|
|
268
|
-
const truncation =
|
|
278
|
+
const truncation = useTruncationMeasure({
|
|
269
279
|
maxLines: hasTruncateTooltip === false ? 0 : maxLines,
|
|
280
|
+
measuresOnInterest,
|
|
270
281
|
});
|
|
271
282
|
|
|
283
|
+
// Ref for the text element (used as tooltip anchor)
|
|
284
|
+
const textRef = useRef<HTMLElement>(null);
|
|
285
|
+
|
|
272
286
|
// Tooltip for truncated text
|
|
273
287
|
const tooltipPlacement: LayerPlacement =
|
|
274
288
|
typeof hasTruncateTooltip === 'string' ? hasTruncateTooltip : 'above';
|
|
275
289
|
const tooltipEnabled =
|
|
276
290
|
maxLines > 0 && hasTruncateTooltip !== false && truncation.isTruncated;
|
|
277
291
|
// The tooltip mounts on the first hover, tap or focus, not with the text.
|
|
278
|
-
const tooltipInterest = useTruncationTooltipInterest(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
292
|
+
const tooltipInterest = useTruncationTooltipInterest(
|
|
293
|
+
tooltipEnabled,
|
|
294
|
+
truncation.measure,
|
|
295
|
+
);
|
|
282
296
|
|
|
283
297
|
// Keep the merged ref stable across rerenders.
|
|
284
298
|
const mergedRef = useMergedRefs(ref, truncation.ref, textRef);
|
|
@@ -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
|
|
@@ -26,11 +27,7 @@ import {
|
|
|
26
27
|
} from 'react';
|
|
27
28
|
import type {LayerPlacement} from '../Layer';
|
|
28
29
|
import {createModuleLoader} from '../utils/moduleLoader';
|
|
29
|
-
import type {
|
|
30
|
-
Tooltip as TooltipType,
|
|
31
|
-
UndescribedTooltip as UndescribedTooltipType,
|
|
32
|
-
} from '../Tooltip/Tooltip';
|
|
33
|
-
import {useInteractionModalityTrackingFor} from '../utils/interactionModality';
|
|
30
|
+
import type {Tooltip as TooltipType} from '../Tooltip/Tooltip';
|
|
34
31
|
import {useTapRecognizer} from '../Layer/gestureCounter';
|
|
35
32
|
import {isElement} from '../utils/nodeType';
|
|
36
33
|
import {
|
|
@@ -46,6 +43,19 @@ const tooltipModule = createModuleLoader(
|
|
|
46
43
|
async () => import('../Tooltip/Tooltip'),
|
|
47
44
|
);
|
|
48
45
|
|
|
46
|
+
// The page's texts share one preload. It waits a frame and a task for the
|
|
47
|
+
// paint, then loads the module once. The shared loader keeps no failed load,
|
|
48
|
+
// so the next text tries again.
|
|
49
|
+
const afterPaintModule = createModuleLoader(async () => {
|
|
50
|
+
await new Promise<void>(resolve => {
|
|
51
|
+
requestAnimationFrame(() => {
|
|
52
|
+
setTimeout(resolve, 0);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
return tooltipModule.load();
|
|
56
|
+
});
|
|
57
|
+
const loadAfterNextPaint = afterPaintModule.load;
|
|
58
|
+
|
|
49
59
|
export interface TruncationTooltipInterest {
|
|
50
60
|
/** Whether a hover, tap or focus has reached the element. It stays true. */
|
|
51
61
|
readonly isWanted: boolean;
|
|
@@ -62,54 +72,74 @@ export interface TruncationTooltipInterest {
|
|
|
62
72
|
|
|
63
73
|
/**
|
|
64
74
|
* Tracks the interaction that mounts a truncated element's tooltip, while
|
|
65
|
-
* `isEnabled
|
|
75
|
+
* `isEnabled` or, with `measure`, while the interaction measures the text
|
|
76
|
+
* truncated, until the mounted tooltip reads it. A finger's arrival does not
|
|
66
77
|
* count: only a press that the touch trigger's recognizer takes for a tap
|
|
67
78
|
* does. Once the tooltip has read the interaction, its own listeners take
|
|
68
79
|
* over.
|
|
69
80
|
*/
|
|
70
81
|
export function useTruncationTooltipInterest(
|
|
71
82
|
isEnabled: boolean,
|
|
83
|
+
// For text that measures on interest: measures now and returns whether the
|
|
84
|
+
// text is truncated, so the interaction that measures it can mount the
|
|
85
|
+
// tooltip.
|
|
86
|
+
measure?: () => boolean,
|
|
72
87
|
): TruncationTooltipInterest {
|
|
73
88
|
const [isWanted, setIsWanted] = useState(false);
|
|
74
89
|
const [tooltip, setTooltip] = useState<TooltipComponent | null>(
|
|
75
90
|
() => tooltipModule.loaded()?.Tooltip ?? null,
|
|
76
91
|
);
|
|
77
92
|
// Syncs with the module loader: truncated text loads the Tooltip module, so
|
|
78
|
-
// the first interaction mounts the tooltip at once.
|
|
93
|
+
// the first interaction mounts the tooltip at once. Text that measures on
|
|
94
|
+
// interest has no answer yet. It joins the page's one after-paint preload,
|
|
95
|
+
// so the page shows first, and a hover never hurries the load.
|
|
79
96
|
useEffect(() => {
|
|
80
|
-
if (!isEnabled || tooltip != null) {
|
|
97
|
+
if ((!isEnabled && measure == null) || tooltip != null) {
|
|
81
98
|
return;
|
|
82
99
|
}
|
|
83
100
|
let isCurrent = true;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
const show = (loaded: {Tooltip: TooltipComponent}) => {
|
|
102
|
+
if (isCurrent) {
|
|
103
|
+
setTooltip(() => loaded.Tooltip);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
(measure == null ? tooltipModule.load() : loadAfterNextPaint()).then(
|
|
107
|
+
show,
|
|
90
108
|
() => {},
|
|
91
109
|
);
|
|
92
110
|
return () => {
|
|
93
111
|
isCurrent = false;
|
|
94
112
|
};
|
|
95
|
-
}, [isEnabled, tooltip]);
|
|
113
|
+
}, [isEnabled, measure, tooltip]);
|
|
96
114
|
const interestRef = useRef<TooltipPresentInterestState>({
|
|
97
115
|
interest: null,
|
|
98
116
|
tapEvent: null,
|
|
99
117
|
isRead: false,
|
|
100
118
|
});
|
|
101
119
|
const tapRecognizer = useTapRecognizer();
|
|
120
|
+
// A tooltip that read an interaction unmounts while the text fits. When the
|
|
121
|
+
// text is cut off again, the next tooltip reads the next interaction.
|
|
122
|
+
const measureInterest = useCallback((): boolean => {
|
|
123
|
+
if (measure == null) {
|
|
124
|
+
return isEnabled;
|
|
125
|
+
}
|
|
126
|
+
const isTruncated = measure();
|
|
127
|
+
if (isTruncated && !isEnabled) {
|
|
128
|
+
interestRef.current.isRead = false;
|
|
129
|
+
}
|
|
130
|
+
return isTruncated;
|
|
131
|
+
}, [isEnabled, measure]);
|
|
102
132
|
const want = useCallback(
|
|
103
133
|
(interest: 'hover' | 'tap' | 'focus', tapEvent: Event | null = null) => {
|
|
104
134
|
const state = interestRef.current;
|
|
105
|
-
if (!
|
|
135
|
+
if (!measureInterest() || state.isRead) {
|
|
106
136
|
return;
|
|
107
137
|
}
|
|
108
138
|
state.interest = interest;
|
|
109
139
|
state.tapEvent = tapEvent;
|
|
110
140
|
setIsWanted(true);
|
|
111
141
|
},
|
|
112
|
-
[
|
|
142
|
+
[measureInterest],
|
|
113
143
|
);
|
|
114
144
|
const forget = useCallback((interest: 'hover' | 'focus') => {
|
|
115
145
|
const state = interestRef.current;
|
|
@@ -128,7 +158,7 @@ export function useTruncationTooltipInterest(
|
|
|
128
158
|
const onPointerLeave = useCallback(() => forget('hover'), [forget]);
|
|
129
159
|
const onPointerDown = useCallback(
|
|
130
160
|
(event: PointerEvent<HTMLElement>) => {
|
|
131
|
-
if (!
|
|
161
|
+
if (!measureInterest() || interestRef.current.isRead) {
|
|
132
162
|
tapRecognizer.forget();
|
|
133
163
|
return;
|
|
134
164
|
}
|
|
@@ -143,7 +173,7 @@ export function useTruncationTooltipInterest(
|
|
|
143
173
|
forget('hover');
|
|
144
174
|
}
|
|
145
175
|
},
|
|
146
|
-
[
|
|
176
|
+
[measureInterest, tapRecognizer, want, forget],
|
|
147
177
|
);
|
|
148
178
|
const onFocus = useCallback(
|
|
149
179
|
(event: FocusEvent<HTMLElement>) => {
|
|
@@ -197,166 +227,3 @@ export function TruncationTooltip({
|
|
|
197
227
|
</TooltipPresentInterestContext>
|
|
198
228
|
);
|
|
199
229
|
}
|
|
200
|
-
|
|
201
|
-
/** Whether a box clips its content. */
|
|
202
|
-
function overflows(element: Element): boolean {
|
|
203
|
-
const box =
|
|
204
|
-
element.clientWidth ||
|
|
205
|
-
(element instanceof HTMLElement ? element.offsetWidth : 0);
|
|
206
|
-
return box > 0 && element.scrollWidth > box;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/** Whether an element is visually hidden: a screen-reader-only label. */
|
|
210
|
-
function isVisuallyHidden(element: Element): boolean {
|
|
211
|
-
const style = element.ownerDocument.defaultView?.getComputedStyle(element);
|
|
212
|
-
return (
|
|
213
|
-
style != null &&
|
|
214
|
-
style.position === 'absolute' &&
|
|
215
|
-
((style.clip !== '' && style.clip !== 'auto') ||
|
|
216
|
-
(style.clipPath !== '' && style.clipPath !== 'none'))
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// A field and its value: an input, or a widget that shows a chosen value (a
|
|
221
|
-
// Selector's combobox). Its value is not the component's text.
|
|
222
|
-
const FIELD_SELECTOR =
|
|
223
|
-
'input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="combobox"], [role="listbox"], [role="searchbox"], [role="spinbutton"], [role="slider"], [role="textbox"]';
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Whether an element is left out of the measured text: hidden, a hidden copy
|
|
227
|
-
* (ToggleButton's bold-width reservation), visually hidden, or a field, whose
|
|
228
|
-
* value clips inside its own box and is not the cut text.
|
|
229
|
-
*/
|
|
230
|
-
function isLeftOut(element: Element): boolean {
|
|
231
|
-
return (
|
|
232
|
-
element.closest(`[hidden], [aria-hidden="true"], ${FIELD_SELECTOR}`) !=
|
|
233
|
-
null || isVisuallyHidden(element)
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/** Whether text is cut: its box, or a box inside it that a reader sees, clips it. */
|
|
238
|
-
function isTextCut(element: HTMLElement): boolean {
|
|
239
|
-
return (
|
|
240
|
-
overflows(element) ||
|
|
241
|
-
[...element.querySelectorAll('*')].some(
|
|
242
|
-
child => !isLeftOut(child) && overflows(child),
|
|
243
|
-
)
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* The text a sighted reader sees, without hidden, visually hidden and field
|
|
249
|
-
* text: the label or heading itself.
|
|
250
|
-
*/
|
|
251
|
-
function visibleText(root: HTMLElement): string {
|
|
252
|
-
let text = '';
|
|
253
|
-
const walk = (node: Node) => {
|
|
254
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
255
|
-
text += node.textContent ?? '';
|
|
256
|
-
} else if (node instanceof Element && !isLeftOut(node)) {
|
|
257
|
-
node.childNodes.forEach(walk);
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
walk(root);
|
|
261
|
-
return text.replace(/\s+/g, ' ').trim();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
type UndescribedTooltipComponent = typeof UndescribedTooltipType;
|
|
265
|
-
|
|
266
|
-
export interface CutTextOnKeyboardFocus {
|
|
267
|
-
/** The full text while keyboard focus is inside and the text is cut. */
|
|
268
|
-
readonly cutText: string | null;
|
|
269
|
-
/**
|
|
270
|
-
* The tooltip that shows `cutText` with no description, once its module
|
|
271
|
-
* has loaded (after the first render, as tooltip code loads).
|
|
272
|
-
*/
|
|
273
|
-
readonly Tooltip: UndescribedTooltipComponent | null;
|
|
274
|
-
/** Closes the tooltip; pass it as the tooltip's `onHide` (Escape). */
|
|
275
|
-
readonly hide: () => void;
|
|
276
|
-
readonly onFocus: (event: FocusEvent<HTMLElement>) => void;
|
|
277
|
-
readonly onBlur: (event: FocusEvent<HTMLElement>) => void;
|
|
278
|
-
/** A press closes it, as a press closes a tooltip. */
|
|
279
|
-
readonly onPointerDown: () => void;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Shows a component's cut text in an undescribed tooltip on keyboard focus:
|
|
284
|
-
* a Button's cut label, a table header cell's cut heading. When keyboard focus
|
|
285
|
-
* reaches the anchor (or an element inside it), it measures `measureRef`'s
|
|
286
|
-
* text; if the text is cut, `cutText` holds it until focus leaves the anchor,
|
|
287
|
-
* Escape, or a press. A hover, a pointer-focused field and a touch tap show
|
|
288
|
-
* nothing, and nothing is measured at rest. Internal: the package does not
|
|
289
|
-
* export it.
|
|
290
|
-
*/
|
|
291
|
-
export function useCutTextOnKeyboardFocus({
|
|
292
|
-
anchorRef,
|
|
293
|
-
measureRef,
|
|
294
|
-
isEnabled,
|
|
295
|
-
isSuppressed,
|
|
296
|
-
}: {
|
|
297
|
-
/** The element focus reaches and the tooltip attaches to. */
|
|
298
|
-
anchorRef: RefObject<HTMLElement | null>;
|
|
299
|
-
/** The element whose text is cut; the anchor itself when omitted. */
|
|
300
|
-
measureRef?: RefObject<HTMLElement | null>;
|
|
301
|
-
isEnabled: boolean;
|
|
302
|
-
/** Returns true when another tooltip already describes the anchor. */
|
|
303
|
-
isSuppressed?: (anchor: HTMLElement) => boolean;
|
|
304
|
-
}): CutTextOnKeyboardFocus {
|
|
305
|
-
const [cutText, setCutText] = useState<string | null>(null);
|
|
306
|
-
const [Tooltip, setTooltip] = useState<UndescribedTooltipComponent | null>(
|
|
307
|
-
() => tooltipModule.loaded()?.UndescribedTooltip ?? null,
|
|
308
|
-
);
|
|
309
|
-
const readModality = useInteractionModalityTrackingFor(anchorRef, isEnabled);
|
|
310
|
-
// Syncs with the module loader: the tooltip loads after the first render,
|
|
311
|
-
// so keyboard focus shows it at once.
|
|
312
|
-
useEffect(() => {
|
|
313
|
-
if (!isEnabled || Tooltip != null) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
let isCurrent = true;
|
|
317
|
-
tooltipModule.load().then(
|
|
318
|
-
loaded => {
|
|
319
|
-
if (isCurrent) {
|
|
320
|
-
setTooltip(() => loaded.UndescribedTooltip);
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
|
-
() => {},
|
|
324
|
-
);
|
|
325
|
-
return () => {
|
|
326
|
-
isCurrent = false;
|
|
327
|
-
};
|
|
328
|
-
}, [isEnabled, Tooltip]);
|
|
329
|
-
const hide = useCallback(() => setCutText(null), []);
|
|
330
|
-
const onFocus = (event: FocusEvent<HTMLElement>) => {
|
|
331
|
-
const anchor = anchorRef.current;
|
|
332
|
-
const measured = measureRef?.current ?? anchor;
|
|
333
|
-
const target = event.target;
|
|
334
|
-
// `:focus-visible` also matches a text field a pointer focused, so the
|
|
335
|
-
// modality reader decides: only keyboard focus counts.
|
|
336
|
-
if (
|
|
337
|
-
!isEnabled ||
|
|
338
|
-
anchor == null ||
|
|
339
|
-
measured == null ||
|
|
340
|
-
!isElement(target) ||
|
|
341
|
-
// React delivers focus from a portal (a header's filter popover) to the
|
|
342
|
-
// anchor's handlers; only focus inside the anchor counts.
|
|
343
|
-
!anchor.contains(target) ||
|
|
344
|
-
!target.matches(':focus-visible') ||
|
|
345
|
-
readModality() !== 'keyboard'
|
|
346
|
-
) {
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
const text = visibleText(measured);
|
|
350
|
-
const isCut =
|
|
351
|
-
text !== '' && !(isSuppressed?.(anchor) ?? false) && isTextCut(measured);
|
|
352
|
-
setCutText(isCut ? text : null);
|
|
353
|
-
};
|
|
354
|
-
const onBlur = (event: FocusEvent<HTMLElement>) => {
|
|
355
|
-
const next = event.relatedTarget;
|
|
356
|
-
if (isElement(next) && anchorRef.current?.contains(next)) {
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
setCutText(null);
|
|
360
|
-
};
|
|
361
|
-
return {cutText, Tooltip, hide, onFocus, onBlur, onPointerDown: hide};
|
|
362
|
-
}
|