@astryxdesign/core 0.7.6-canary.f73623d → 0.7.6-canary.f899313
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/Badge/Badge.d.ts.map +1 -1
- package/dist/Badge/Badge.js +2 -1
- package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
- package/dist/ComplexSelector/ComplexSelector.js +8 -2
- package/dist/DateInput/MonthScroller.d.ts.map +1 -1
- package/dist/DateInput/MonthScroller.js +17 -18
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +8 -4
- package/dist/DropdownMenu/DropdownMenuGroup.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuGroup.js +2 -1
- package/dist/Field/FieldLabel.d.ts.map +1 -1
- package/dist/Field/FieldLabel.js +27 -2
- package/dist/FieldStatus/FieldStatus.d.ts +3 -0
- package/dist/FieldStatus/FieldStatus.d.ts.map +1 -1
- package/dist/FieldStatus/FieldStatus.js +1 -0
- package/dist/FileInput/FileInput.d.ts +3 -0
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +59 -33
- package/dist/Layer/useTouchTrigger.d.ts +9 -0
- package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
- package/dist/Layer/useTouchTrigger.js +1 -1
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +10 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +19 -9
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +11 -15
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +9 -6
- package/dist/Selector/hooks.js +2 -2
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +82 -10
- package/dist/Token/Token.d.ts +1 -1
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +15 -0
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +16 -1
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +10 -3
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +36 -10
- package/dist/astryx.css +1 -1
- package/dist/i18n/useListFormatter.d.ts +9 -0
- package/dist/i18n/useListFormatter.d.ts.map +1 -0
- package/dist/i18n/useListFormatter.js +41 -0
- package/package.json +18 -5
- package/src/Badge/Badge.tsx +2 -1
- package/src/Chat/ChatMessage.spec.md +64 -65
- package/src/Citation/Citation.spec.md +60 -47
- package/src/ComplexSelector/ComplexSelector.tsx +19 -2
- package/src/DateInput/DateInput.spec.md +74 -57
- package/src/DateInput/MonthScroller.tsx +15 -17
- package/src/DateRangeInput/DateRangeInput.tsx +18 -3
- package/src/DropdownMenu/DropdownMenuGroup.tsx +2 -1
- package/src/Field/Field.doc.mjs +2 -1
- package/src/Field/FieldLabel.doc.mjs +4 -2
- package/src/Field/FieldLabel.spec.md +30 -21
- package/src/Field/FieldLabel.tsx +37 -3
- package/src/FieldStatus/FieldStatus.tsx +7 -0
- package/src/FileInput/FileInput.tsx +69 -28
- package/src/FormLayout/FormLayout.spec.md +11 -19
- package/src/Layer/useTouchTrigger.ts +1 -1
- package/src/Lightbox/Lightbox.spec.md +249 -61
- package/src/Link/Link.tsx +9 -2
- package/src/MultiSelector/MultiSelector.spec.md +121 -114
- package/src/MultiSelector/MultiSelector.tsx +19 -5
- package/src/NumberInput/NumberInput.tsx +11 -18
- package/src/ProgressBar/ProgressBar.spec.md +143 -119
- package/src/Selector/Selector.tsx +16 -6
- package/src/Selector/hooks.ts +2 -2
- package/src/Slider/Slider.spec.md +18 -16
- package/src/Slider/Slider.tsx +101 -9
- package/src/Token/Token.spec.md +24 -23
- package/src/Token/Token.tsx +15 -0
- package/src/Tokenizer/Tokenizer.tsx +10 -0
- package/src/Typeahead/BaseTypeahead.tsx +18 -2
- package/src/Typeahead/Typeahead.tsx +40 -9
- package/src/i18n/useListFormatter.ts +42 -0
- package/dist/Item/ItemMarkerColumns.a11y.chromium.spec.d.ts +0 -2
- package/dist/Item/ItemMarkerColumns.a11y.chromium.spec.js +0 -132
- package/dist/Lightbox/LightboxKeyboard.a11y.browser.spec.d.ts +0 -2
- package/dist/Lightbox/LightboxKeyboard.a11y.browser.spec.js +0 -78
- package/dist/Lightbox/LightboxViewport.a11y.browser.spec.d.ts +0 -2
- package/dist/Lightbox/LightboxViewport.a11y.browser.spec.js +0 -66
- package/dist/List/ListMarkers.a11y.chromium.spec.d.ts +0 -2
- package/dist/List/ListMarkers.a11y.chromium.spec.js +0 -677
- package/dist/Markdown/Markdown.fr23.bench.d.ts +0 -2
- package/dist/Markdown/Markdown.fr23.bench.d.ts.map +0 -1
- package/dist/Markdown/Markdown.fr23.bench.js +0 -152
- package/dist/Markdown/MarkdownTable.a11y.chromium.spec.d.ts +0 -2
- package/dist/Markdown/MarkdownTable.a11y.chromium.spec.js +0 -590
- package/dist/Markdown/plugins/headingLinks.a11y.chromium.spec.d.ts +0 -2
- package/dist/Markdown/plugins/headingLinks.a11y.chromium.spec.js +0 -657
- package/dist/MobileNav/MobileNavPinchZoom.a11y.chromium.spec.d.ts +0 -2
- package/dist/MobileNav/MobileNavPinchZoom.a11y.chromium.spec.js +0 -153
- package/dist/MultiSelector/CreateRow.a11y.chromium.spec.d.ts +0 -2
- package/dist/MultiSelector/CreateRow.a11y.chromium.spec.js +0 -117
- package/dist/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.d.ts +0 -2
- package/dist/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.js +0 -49
- package/dist/MultiSelector/OptionActions.a11y.chromium.spec.d.ts +0 -2
- package/dist/MultiSelector/OptionActions.a11y.chromium.spec.js +0 -273
- package/dist/Outline/OutlineFocus.a11y.chromium.spec.d.ts +0 -2
- package/dist/Outline/OutlineFocus.a11y.chromium.spec.js +0 -421
- package/dist/Typeahead/BaseTypeahead.emptyState.a11y.chromium.spec.d.ts +0 -2
- package/dist/Typeahead/BaseTypeahead.emptyState.a11y.chromium.spec.js +0 -118
- package/dist/reset.a11y.chromium.spec.d.ts +0 -2
- package/dist/reset.a11y.chromium.spec.js +0 -231
- package/dist/reset.until-found.a11y.browser.spec.d.ts +0 -2
- package/dist/reset.until-found.a11y.browser.spec.js +0 -72
- package/src/AlertDialog/AlertDialog.test.tsx +0 -519
- package/src/AlertDialog/__tests__/AlertDialog.a11y.chromium.spec.ts +0 -128
- package/src/AlertDialog/__tests__/AlertDialog.a11y.renders.tsx +0 -52
- package/src/AlertDialog/__tests__/AlertDialog.a11y.states.ts +0 -68
- package/src/AlertDialog/__tests__/AlertDialog.a11y.test.tsx +0 -144
- package/src/AlertDialog/useImperativeAlertDialog.test.tsx +0 -163
- package/src/AppShell/AppShell.test.tsx +0 -1310
- package/src/AppShell/__tests__/AppShellMainKeyboard.a11y.browser.spec.ts +0 -534
- package/src/AppShell/observeMainOverflow.test.ts +0 -173
- package/src/AspectRatio/AspectRatio.test.tsx +0 -398
- package/src/AspectRatio/__tests__/AspectRatioFitLayers.a11y.browser.spec.ts +0 -158
- package/src/Avatar/Avatar.test.tsx +0 -867
- package/src/Avatar/AvatarStatusDot.test.tsx +0 -306
- package/src/Avatar/__tests__/AvatarForcedColors.a11y.chromium.spec.ts +0 -126
- package/src/AvatarGroup/AvatarGroup.test.tsx +0 -313
- package/src/AvatarGroup/AvatarGroupOverflow.test.tsx +0 -263
- package/src/Badge/Badge.test.tsx +0 -125
- package/src/Badge/__tests__/BadgeLargerText.a11y.chromium.spec.ts +0 -260
- package/src/Banner/Banner.test.tsx +0 -879
- package/src/Blockquote/Blockquote.test.tsx +0 -121
- package/src/BottomSheet/BottomSheet.test.tsx +0 -3154
- package/src/BottomSheet/BottomSheetEdgeTint.test.tsx +0 -248
- package/src/BottomSheet/BottomSheetKeyboard.test.tsx +0 -195
- package/src/BottomSheet/BottomSheetPanel.test.tsx +0 -549
- package/src/BottomSheet/BottomSheetReplace.test.tsx +0 -1638
- package/src/BottomSheet/BottomSheetStacking.announce.test.tsx +0 -246
- package/src/BottomSheet/BottomSheetStacking.test.tsx +0 -3184
- package/src/BottomSheet/BottomSheetSwitcher.test.tsx +0 -2010
- package/src/BottomSheet/__tests__/BottomSheetDrag.a11y.chromium.spec.ts +0 -129
- package/src/BottomSheet/__tests__/BottomSheetFocusReturn.a11y.browser.spec.ts +0 -97
- package/src/BottomSheet/__tests__/BottomSheetKeyboard.a11y.browser.spec.ts +0 -415
- package/src/BottomSheet/__tests__/BottomSheetNativeModal.a11y.browser.spec.ts +0 -462
- package/src/BottomSheet/__tests__/BottomSheetPinchZoom.a11y.chromium.spec.ts +0 -247
- package/src/BottomSheet/__tests__/BottomSheetToastOutlet.a11y.chromium.spec.ts +0 -83
- package/src/BottomSheet/snapOffsets.test.ts +0 -254
- package/src/BottomSheet/useSheetGestures.test.ts +0 -1690
- package/src/Breadcrumbs/Breadcrumbs.test.tsx +0 -921
- package/src/Breadcrumbs/__tests__/Breadcrumbs.a11y.chromium.spec.ts +0 -132
- package/src/Breadcrumbs/__tests__/Breadcrumbs.a11y.renders.tsx +0 -45
- package/src/Breadcrumbs/__tests__/Breadcrumbs.a11y.states.ts +0 -81
- package/src/Breadcrumbs/__tests__/Breadcrumbs.a11y.test.tsx +0 -125
- package/src/Button/Button.test.tsx +0 -864
- package/src/Button/__tests__/Button.a11y.chromium.spec.ts +0 -355
- package/src/Button/__tests__/Button.a11y.harnesses.tsx +0 -47
- package/src/Button/__tests__/Button.a11y.known-failures.ts +0 -25
- package/src/Button/__tests__/Button.a11y.renders.tsx +0 -139
- package/src/Button/__tests__/Button.a11y.states.ts +0 -317
- package/src/Button/__tests__/Button.a11y.test.tsx +0 -187
- package/src/ButtonGroup/ButtonGroup.test.tsx +0 -1025
- package/src/Calendar/Calendar.test.tsx +0 -2186
- package/src/Calendar/__tests__/Calendar.a11y.chromium.spec.ts +0 -141
- package/src/Calendar/__tests__/Calendar.a11y.known-failures.ts +0 -12
- package/src/Calendar/__tests__/Calendar.a11y.renders.tsx +0 -57
- package/src/Calendar/__tests__/Calendar.a11y.states.ts +0 -139
- package/src/Calendar/__tests__/Calendar.a11y.test.tsx +0 -137
- package/src/Calendar/dayCellUtils.test.ts +0 -520
- package/src/Calendar/getInitialFocusDate.test.ts +0 -94
- package/src/Calendar/getStandaloneShortWeekdayNames.test.ts +0 -54
- package/src/Calendar/hooks/useCalendarConstraints.test.ts +0 -153
- package/src/Calendar/hooks/useCalendarDays.test.ts +0 -265
- package/src/Calendar/hooks/useCalendarNavigation.test.ts +0 -252
- package/src/Card/Card.test.tsx +0 -202
- package/src/Carousel/Carousel.test.tsx +0 -1036
- package/src/Carousel/__tests__/Carousel.a11y.chromium.spec.ts +0 -207
- package/src/Carousel/__tests__/Carousel.a11y.known-failures.ts +0 -12
- package/src/Carousel/__tests__/Carousel.a11y.renders.tsx +0 -39
- package/src/Carousel/__tests__/Carousel.a11y.states.ts +0 -139
- package/src/Carousel/__tests__/Carousel.a11y.test.tsx +0 -127
- package/src/Center/Center.test.tsx +0 -406
- package/src/Chat/ChatComposer.test.tsx +0 -364
- package/src/Chat/ChatComposerDrawer.test.tsx +0 -130
- package/src/Chat/ChatComposerInput.test.tsx +0 -2136
- package/src/Chat/ChatComposerTokenElement.test.tsx +0 -85
- package/src/Chat/ChatDictationButton.test.tsx +0 -108
- package/src/Chat/ChatLayout.test.tsx +0 -311
- package/src/Chat/ChatLayoutScrollButton.test.tsx +0 -99
- package/src/Chat/ChatMessage.test.tsx +0 -344
- package/src/Chat/ChatMessageBubble.test.tsx +0 -294
- package/src/Chat/ChatMessageList.test.tsx +0 -198
- package/src/Chat/ChatMessageMetadata.test.tsx +0 -66
- package/src/Chat/ChatPastedTextToken.test.tsx +0 -71
- package/src/Chat/ChatSendButton.test.tsx +0 -309
- package/src/Chat/ChatSystemMessage.test.tsx +0 -189
- package/src/Chat/ChatTokenizedText.test.tsx +0 -163
- package/src/Chat/ChatToolCalls.test.tsx +0 -413
- package/src/Chat/__tests__/ChatLayoutScrollButton.a11y.chromium.spec.ts +0 -577
- package/src/Chat/__tests__/ChatLayoutScrollButtonSurface.a11y.chromium.spec.ts +0 -740
- package/src/Chat/__tests__/ChatMessageBubble.a11y.chromium.spec.ts +0 -457
- package/src/Chat/__tests__/ChatMessageBubble.auditProvenance.test.ts +0 -91
- package/src/Chat/__tests__/ChatMessageBubble.auditProvenance.ts +0 -91
- package/src/Chat/__tests__/ChatMessageList.a11y.chromium.spec.ts +0 -465
- package/src/Chat/__tests__/ChatMessageMetadata.a11y.chromium.spec.ts +0 -416
- package/src/Chat/__tests__/ChatSendButton.a11y.chromium.spec.ts +0 -1523
- package/src/Chat/__tests__/ChatSystemMessage.a11y.chromium.spec.ts +0 -1004
- package/src/Chat/__tests__/ChatTokenizedText.a11y.chromium.spec.ts +0 -574
- package/src/Chat/__tests__/useChatStreamScroll.a11y.chromium.spec.ts +0 -263
- package/src/Chat/__tests__/useChatStreamScroll.fixture.tsx +0 -61
- package/src/Chat/useChatDictation.test.tsx +0 -369
- package/src/Chat/useChatNewMessages.test.tsx +0 -209
- package/src/Chat/useChatPasteAsToken.test.ts +0 -191
- package/src/Chat/useChatStreamScroll.test.tsx +0 -381
- package/src/Chat/useTriggerMenu.test.tsx +0 -994
- package/src/CheckboxInput/CheckboxInput.test.tsx +0 -926
- package/src/CheckboxInput/__tests__/Checkbox.a11y.chromium.spec.ts +0 -354
- package/src/CheckboxInput/__tests__/Checkbox.a11y.known-failures.ts +0 -54
- package/src/CheckboxInput/__tests__/Checkbox.a11y.renders.tsx +0 -310
- package/src/CheckboxInput/__tests__/Checkbox.a11y.states.ts +0 -404
- package/src/CheckboxInput/__tests__/Checkbox.a11y.test.tsx +0 -128
- package/src/CheckboxList/CheckboxList.fr10.test.tsx +0 -51
- package/src/CheckboxList/CheckboxList.test.tsx +0 -1159
- package/src/CheckboxList/__tests__/CheckboxList.a11y.chromium.spec.ts +0 -1998
- package/src/Citation/Citation.test.tsx +0 -361
- package/src/ClickableCard/ClickableCard.test.tsx +0 -382
- package/src/Code/Code.test.tsx +0 -75
- package/src/CodeBlock/CodeBlock.highlightStyles.test.tsx +0 -87
- package/src/CodeBlock/CodeBlock.test.tsx +0 -752
- package/src/CodeBlock/CodeLanguage.test.tsx +0 -173
- package/src/CodeBlock/__tests__/CodeBlockCopyClearance.a11y.chromium.spec.ts +0 -325
- package/src/CodeBlock/__tests__/CodeBlockLanguages.a11y.chromium.spec.ts +0 -64
- package/src/CodeBlock/__tests__/CodeBlockOverflowStop.a11y.chromium.spec.ts +0 -126
- package/src/CodeBlock/__tests__/DiffRowPaint.a11y.chromium.spec.ts +0 -94
- package/src/CodeBlock/highlightRanges.test.ts +0 -253
- package/src/CodeBlock/languages.test.ts +0 -402
- package/src/CodeBlock/tokenizer.test.ts +0 -280
- package/src/CodeBlock/tokenizerBudget.test.ts +0 -112
- package/src/Collapsible/Collapsible.test.tsx +0 -620
- package/src/Collapsible/CollapsibleGroup.test.tsx +0 -656
- package/src/Collapsible/__tests__/Collapsible.a11y.chromium.spec.ts +0 -194
- package/src/Collapsible/__tests__/Collapsible.a11y.states.ts +0 -117
- package/src/Collapsible/__tests__/Collapsible.a11y.test.tsx +0 -140
- package/src/Collapsible/__tests__/CollapsibleGroup.a11y.chromium.spec.ts +0 -559
- package/src/Collapsible/__tests__/CollapsibleGroup.a11y.renders.tsx +0 -45
- package/src/Collapsible/__tests__/CollapsibleGroup.a11y.states.ts +0 -139
- package/src/Collapsible/__tests__/CollapsibleGroup.a11y.test.tsx +0 -135
- package/src/Collapsible/__tests__/CollapsibleGroupAccordion.a11y.chromium.spec.ts +0 -141
- package/src/Collapsible/useCollapsible.test.tsx +0 -236
- package/src/CommandPalette/CommandPalette.perf.test.ts +0 -100
- package/src/CommandPalette/CommandPalette.test.tsx +0 -750
- package/src/CommandPalette/CommandPaletteEmpty.test.tsx +0 -101
- package/src/CommandPalette/CommandPaletteFooter.test.tsx +0 -122
- package/src/CommandPalette/CommandPaletteGroup.test.tsx +0 -129
- package/src/CommandPalette/CommandPaletteInput.test.tsx +0 -539
- package/src/CommandPalette/CommandPaletteItem.test.tsx +0 -417
- package/src/CommandPalette/CommandPaletteList.test.tsx +0 -184
- package/src/CommandPalette/__tests__/CommandPalette.a11y.chromium.spec.ts +0 -600
- package/src/CommandPalette/__tests__/CommandPaletteEmptyAudit.a11y.chromium.spec.ts +0 -715
- package/src/CommandPalette/__tests__/CommandPaletteFooter.a11y.chromium.spec.ts +0 -582
- package/src/CommandPalette/__tests__/CommandPaletteInputAudit.a11y.chromium.spec.ts +0 -336
- package/src/CommandPalette/__tests__/CommandPaletteItemAudit.a11y.chromium.spec.ts +0 -523
- package/src/ComplexSelector/ComplexSelector.focusableDisabled.test.tsx +0 -76
- package/src/ComplexSelector/ComplexSelector.fr10.test.tsx +0 -262
- package/src/ComplexSelector/ComplexSelector.test.tsx +0 -1171
- package/src/ComplexSelector/__tests__/ComplexSelector.a11y.chromium.spec.ts +0 -965
- package/src/ContextMenu/ContextMenu.test.tsx +0 -1617
- package/src/ContextMenu/ContextMenu.triggerProps.test.tsx +0 -54
- package/src/ContextMenu/__tests__/ContextMenuAudit.a11y.chromium.spec.ts +0 -439
- package/src/ContextMenu/__tests__/ContextMenuCursorAnchor.a11y.browser.spec.ts +0 -154
- package/src/ContextMenu/__tests__/ContextMenuLongPress.a11y.chromium.spec.ts +0 -117
- package/src/DateInput/DateInput.fr10.test.tsx +0 -283
- package/src/DateInput/DateInput.test.tsx +0 -1571
- package/src/DateInput/DateInputTouch.test.tsx +0 -2948
- package/src/DateInput/MonthScrollerSettle.test.tsx +0 -165
- package/src/DateInput/NativeDateField.test.tsx +0 -741
- package/src/DateInput/Presentation.test.tsx +0 -121
- package/src/DateInput/__tests__/DateInputAudit.a11y.chromium.spec.ts +0 -577
- package/src/DateInput/__tests__/MonthScrollerSteps.interaction.browser.spec.ts +0 -312
- package/src/DateInput/__tests__/WheelPinchZoom.a11y.chromium.spec.ts +0 -171
- package/src/DateRangeInput/DateRangeInput.fr10.test.tsx +0 -165
- package/src/DateRangeInput/DateRangeInput.test.tsx +0 -1151
- package/src/DateTimeInput/DateTimeInput.fr10.test.tsx +0 -319
- package/src/DateTimeInput/DateTimeInput.test.tsx +0 -2656
- package/src/DateTimeInput/DateTimeInputTouch.test.tsx +0 -1071
- package/src/DateTimeInput/NativePickerSegments.test.tsx +0 -657
- package/src/DateTimeInput/Presentation.test.tsx +0 -89
- package/src/Dialog/Dialog.source-build.test.mjs +0 -43
- package/src/Dialog/Dialog.test.tsx +0 -1599
- package/src/Dialog/DialogHeader.test.tsx +0 -477
- package/src/Dialog/__tests__/Dialog.a11y.browser.spec.ts +0 -111
- package/src/Dialog/__tests__/Dialog.a11y.chromium.spec.ts +0 -218
- package/src/Dialog/__tests__/Dialog.a11y.known-failures.ts +0 -28
- package/src/Dialog/__tests__/Dialog.a11y.renders.tsx +0 -107
- package/src/Dialog/__tests__/Dialog.a11y.states.ts +0 -104
- package/src/Dialog/__tests__/Dialog.a11y.test.tsx +0 -102
- package/src/Dialog/__tests__/Dialog.reduced-motion.a11y.browser.spec.ts +0 -252
- package/src/Dialog/__tests__/DialogSecondDocument.a11y.browser.spec.ts +0 -202
- package/src/Dialog/useImperativeDialog.test.tsx +0 -78
- package/src/Divider/Divider.test.tsx +0 -155
- package/src/Drawer/Drawer.test.tsx +0 -1335
- package/src/Drawer/DrawerDirection.test.tsx +0 -127
- package/src/Drawer/DrawerHeader.test.tsx +0 -102
- package/src/Drawer/__tests__/DrawerAudit.a11y.chromium.spec.ts +0 -402
- package/src/Drawer/__tests__/DrawerHeaderAudit.a11y.chromium.spec.ts +0 -298
- package/src/Drawer/__tests__/DrawerNonModalPageScroll.a11y.chromium.spec.ts +0 -267
- package/src/DropdownMenu/DropdownMenu.ssr.test.tsx +0 -93
- package/src/DropdownMenu/DropdownMenu.test.tsx +0 -4498
- package/src/DropdownMenu/DropdownMenuContext.public.test.ts +0 -22
- package/src/DropdownMenu/DropdownMenuLazySheet.test.tsx +0 -126
- package/src/DropdownMenu/DropdownMenuSelectable.test.tsx +0 -635
- package/src/DropdownMenu/DropdownMenuSheetFirstOpen.test.tsx +0 -72
- package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +0 -2442
- package/src/DropdownMenu/__tests__/DropdownMenuDividerAudit.a11y.chromium.spec.ts +0 -281
- package/src/DropdownMenu/__tests__/DropdownMenuDrillIn.a11y.chromium.spec.ts +0 -175
- package/src/DropdownMenu/__tests__/DropdownMenuFocusReturn.a11y.browser.spec.ts +0 -74
- package/src/DropdownMenu/__tests__/DropdownMenuGroupAudit.a11y.chromium.spec.ts +0 -335
- package/src/DropdownMenu/__tests__/DropdownMenuItemAudit.a11y.chromium.spec.ts +0 -367
- package/src/DropdownMenu/__tests__/DropdownMenuRadioGroupAudit.a11y.chromium.spec.ts +0 -328
- package/src/DropdownMenu/__tests__/DropdownMenuRadioItemAudit.a11y.chromium.spec.ts +0 -540
- package/src/DropdownMenu/__tests__/DropdownMenuSubMenuAudit.a11y.chromium.spec.ts +0 -671
- package/src/DropdownMenu/__tests__/Menu.a11y.chromium.spec.ts +0 -158
- package/src/DropdownMenu/__tests__/Menu.a11y.known-failures.ts +0 -26
- package/src/DropdownMenu/__tests__/Menu.a11y.renders.tsx +0 -65
- package/src/DropdownMenu/__tests__/Menu.a11y.states.ts +0 -138
- package/src/DropdownMenu/__tests__/Menu.a11y.test.tsx +0 -136
- package/src/DropdownMenu/__tests__/MenuButton.a11y.chromium.spec.ts +0 -149
- package/src/DropdownMenu/__tests__/MenuButton.a11y.known-failures.ts +0 -12
- package/src/DropdownMenu/__tests__/MenuButton.a11y.renders.tsx +0 -67
- package/src/DropdownMenu/__tests__/MenuButton.a11y.states.ts +0 -141
- package/src/DropdownMenu/__tests__/MenuButton.a11y.test.tsx +0 -138
- package/src/DropdownMenu/__tests__/MenuHeaderFooter.a11y.chromium.spec.ts +0 -231
- package/src/DropdownMenu/__tests__/MenuHoverFocus.a11y.chromium.spec.ts +0 -238
- package/src/DropdownMenu/__tests__/MenuPinchZoom.a11y.chromium.spec.ts +0 -173
- package/src/DropdownMenu/__tests__/MenuPress.a11y.chromium.spec.ts +0 -503
- package/src/DropdownMenu/__tests__/SubMenuHeaderFooter.a11y.chromium.spec.ts +0 -268
- package/src/DropdownMenu/__tests__/warmMenuBottomSheet.tsx +0 -43
- package/src/DropdownMenu/lazyMenuBottomSheet.test.ts +0 -60
- package/src/EmptyState/EmptyState.announce.test.tsx +0 -227
- package/src/EmptyState/EmptyState.test.tsx +0 -284
- package/src/Field/Field.test.tsx +0 -800
- package/src/Field/FieldLabel.test.tsx +0 -244
- package/src/Field/InputClearButton.test.tsx +0 -395
- package/src/Field/__tests__/FieldLabelAudit.a11y.chromium.spec.ts +0 -297
- package/src/Field/fieldInputFamily.test.tsx +0 -160
- package/src/FieldStatus/FieldStatus.test.tsx +0 -482
- package/src/FieldStatus/__tests__/StatusMessage.a11y.chromium.spec.ts +0 -206
- package/src/FieldStatus/__tests__/StatusMessage.a11y.known-failures.ts +0 -13
- package/src/FieldStatus/__tests__/StatusMessage.a11y.renders.tsx +0 -287
- package/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts +0 -302
- package/src/FieldStatus/__tests__/StatusMessage.a11y.test.tsx +0 -154
- package/src/FileInput/FileInput.fr10.test.tsx +0 -21
- package/src/FileInput/FileInput.test.tsx +0 -1291
- package/src/FormLayout/FormLayout.test.tsx +0 -444
- package/src/FormLayout/__snapshots__/FormLayout.test.tsx.snap +0 -46
- package/src/Grid/Grid.test.tsx +0 -509
- package/src/HStack/HStack.test.tsx +0 -129
- package/src/Heading/Heading.test.tsx +0 -328
- package/src/HoverCard/HoverCard.test.tsx +0 -1339
- package/src/Icon/Icon.test.tsx +0 -990
- package/src/Icon/globalIconRegistry.test.tsx +0 -613
- package/src/IconButton/IconButton.test.tsx +0 -156
- package/src/Indicator/Indicator.test.tsx +0 -389
- package/src/Indicator/indicatorRegistry.test.tsx +0 -106
- package/src/InputGroup/InputGroup.test.tsx +0 -502
- package/src/InteractiveRoleContext/InteractiveRoleContext.test.tsx +0 -185
- package/src/Item/Item.source-build.test.mjs +0 -88
- package/src/Item/Item.swipeLayer.test.tsx +0 -74
- package/src/Item/Item.test.tsx +0 -1515
- package/src/Item/ItemMarkerColumns.a11y.chromium.spec.ts +0 -211
- package/src/Item/__tests__/ItemSwipeActions.a11y.chromium.spec.ts +0 -337
- package/src/Item/__tests__/ItemSwipePinchZoom.a11y.chromium.spec.ts +0 -186
- package/src/Kbd/Kbd.test.tsx +0 -299
- package/src/Layer/LayerProvider.test.tsx +0 -143
- package/src/Layer/__tests__/LayerBrowserHide.a11y.chromium.spec.ts +0 -126
- package/src/Layer/__tests__/LayerReducedMotion.a11y.chromium.spec.ts +0 -176
- package/src/Layer/__tests__/TouchTrigger.a11y.chromium.spec.ts +0 -200
- package/src/Layer/anchorName.test.ts +0 -146
- package/src/Layer/layerDismissalFamilies.test.tsx +0 -487
- package/src/Layer/layerDismissalInvariants.test.tsx +0 -501
- package/src/Layer/layerHost.test.ts +0 -117
- package/src/Layer/layerScopedContext.test.tsx +0 -499
- package/src/Layer/layerViewportInset.source-build.test.mjs +0 -90
- package/src/Layer/layerViewportInset.test.ts +0 -120
- package/src/Layer/popoverOperations.test.ts +0 -205
- package/src/Layer/useLayer.test.tsx +0 -2845
- package/src/Layer/useLayerDismissal.test.tsx +0 -580
- package/src/Layer/useTouchTrigger.test.ts +0 -70
- package/src/Layout/Layout.test.tsx +0 -375
- package/src/Layout/LayoutSlots.test.tsx +0 -376
- package/src/Layout/__tests__/Layout.a11y.chromium.spec.ts +0 -134
- package/src/Layout/__tests__/Layout.a11y.renders.tsx +0 -110
- package/src/Layout/__tests__/Layout.a11y.states.ts +0 -93
- package/src/Layout/__tests__/Layout.a11y.test.tsx +0 -142
- package/src/Layout/__tests__/childrenAsContent.test.tsx +0 -59
- package/src/Layout/__tests__/contentWidth.test.tsx +0 -303
- package/src/Layout/__tests__/edgeCompensation.test.tsx +0 -191
- package/src/Layout/__tests__/nestedPadding.test.tsx +0 -264
- package/src/Layout/overlayPaddingReset.test.tsx +0 -224
- package/src/Lightbox/Lightbox.test.tsx +0 -837
- package/src/Lightbox/LightboxKeyboard.a11y.browser.spec.ts +0 -78
- package/src/Lightbox/LightboxViewport.a11y.browser.spec.ts +0 -74
- package/src/Lightbox/useLightbox.test.tsx +0 -263
- package/src/Link/Link.test.tsx +0 -457
- package/src/Link/__tests__/Link.a11y.chromium.spec.ts +0 -153
- package/src/Link/__tests__/Link.a11y.renders.tsx +0 -97
- package/src/Link/__tests__/Link.a11y.states.ts +0 -104
- package/src/Link/__tests__/Link.a11y.test.tsx +0 -127
- package/src/Link/__tests__/Link.navigation.a11y.chromium.spec.ts +0 -262
- package/src/Link/__tests__/Link.truncation.a11y.chromium.spec.ts +0 -58
- package/src/Link/useLinkComponent.test.tsx +0 -572
- package/src/Link/useLinkify.test.tsx +0 -146
- package/src/List/List.test.tsx +0 -1052
- package/src/List/ListItem.source-build.test.mjs +0 -41
- package/src/List/ListMarkers.a11y.chromium.spec.ts +0 -904
- package/src/Markdown/Markdown.codeLanguages.test.tsx +0 -137
- package/src/Markdown/Markdown.fr23.bench.ts +0 -176
- package/src/Markdown/Markdown.fr23.perf.test.ts +0 -484
- package/src/Markdown/Markdown.helpers.perf.test.ts +0 -495
- package/src/Markdown/Markdown.public.test.ts +0 -309
- package/src/Markdown/Markdown.renderBoundary.test.tsx +0 -72
- package/src/Markdown/Markdown.rerender.test.tsx +0 -143
- package/src/Markdown/Markdown.test.tsx +0 -1383
- package/src/Markdown/MarkdownTable.a11y.chromium.spec.ts +0 -727
- package/src/Markdown/__tests__/MarkdownNesting.a11y.chromium.spec.ts +0 -102
- package/src/Markdown/angleDestinations.test.tsx +0 -104
- package/src/Markdown/ast.test.ts +0 -374
- package/src/Markdown/atxHeadingIndentation.test.tsx +0 -53
- package/src/Markdown/blockNesting.test.tsx +0 -124
- package/src/Markdown/blockquoteMarkers.test.tsx +0 -69
- package/src/Markdown/characterReferences.test.ts +0 -47
- package/src/Markdown/codeSpans.test.tsx +0 -65
- package/src/Markdown/emphasis.test.tsx +0 -214
- package/src/Markdown/fenceInfo.test.tsx +0 -47
- package/src/Markdown/imageAlt.test.tsx +0 -84
- package/src/Markdown/incremental.test.ts +0 -1198
- package/src/Markdown/incrementalIndentation.test.tsx +0 -36
- package/src/Markdown/indentedFences.test.tsx +0 -374
- package/src/Markdown/indentedTables.test.tsx +0 -53
- package/src/Markdown/linkBrackets.test.tsx +0 -116
- package/src/Markdown/linkDestinationLinear.test.tsx +0 -54
- package/src/Markdown/linkDestinations.test.tsx +0 -127
- package/src/Markdown/linkTextCode.test.tsx +0 -65
- package/src/Markdown/listBullets.test.tsx +0 -55
- package/src/Markdown/listContinuation.test.tsx +0 -94
- package/src/Markdown/listThematicBreak.test.tsx +0 -49
- package/src/Markdown/longLinkLabels.test.tsx +0 -49
- package/src/Markdown/openFenceFinalNewline.test.tsx +0 -85
- package/src/Markdown/parser.perf.test.ts +0 -398
- package/src/Markdown/parser.public.test.ts +0 -144
- package/src/Markdown/parser.test.ts +0 -1925
- package/src/Markdown/plugin-renderer/MarkdownPluginNodeRenderer.test.tsx +0 -300
- package/src/Markdown/plugins/frontmatter.test.tsx +0 -150
- package/src/Markdown/plugins/headingLinks.a11y.chromium.spec.ts +0 -856
- package/src/Markdown/plugins/headingLinks.ssr.test.tsx +0 -143
- package/src/Markdown/plugins/headingLinks.test.tsx +0 -637
- package/src/Markdown/plugins/protocol.test.tsx +0 -1083
- package/src/Markdown/plugins/semanticFence.test.tsx +0 -655
- package/src/Markdown/plugins/softBreaks.test.tsx +0 -172
- package/src/Markdown/plugins/sourceDecoration.test.tsx +0 -799
- package/src/Markdown/plugins/sourceLines.test.tsx +0 -715
- package/src/Markdown/plugins/textTransform.test.ts +0 -467
- package/src/Markdown/remark.test.tsx +0 -1877
- package/src/Markdown/streaming.test.ts +0 -148
- package/src/Markdown/streamingListShapes.test.tsx +0 -93
- package/src/Markdown/trailingSpaces.test.tsx +0 -45
- package/src/MetadataList/MetadataList.test.tsx +0 -383
- package/src/MobileNav/MobileNav.test.tsx +0 -296
- package/src/MobileNav/MobileNavCloseEdgeCases.test.tsx +0 -584
- package/src/MobileNav/MobileNavCloseTiming.test.ts +0 -58
- package/src/MobileNav/MobileNavCloseVisibility.test.tsx +0 -172
- package/src/MobileNav/MobileNavEntryAnimation.test.tsx +0 -212
- package/src/MobileNav/MobileNavFocus.test.tsx +0 -553
- package/src/MobileNav/MobileNavPinchZoom.a11y.chromium.spec.ts +0 -147
- package/src/MobileNav/MobileNavReopen.test.tsx +0 -118
- package/src/MobileNav/MobileNavScrollbarGutter.test.tsx +0 -109
- package/src/MobileNav/MobileNavToggle.test.tsx +0 -179
- package/src/MobileNav/__tests__/MobileNavHeader.a11y.chromium.spec.ts +0 -89
- package/src/MobileNav/__tests__/MobileNavWidth.a11y.chromium.spec.ts +0 -103
- package/src/MoreMenu/MoreMenu.test.tsx +0 -367
- package/src/MultiSelector/CreateRow.a11y.chromium.spec.ts +0 -148
- package/src/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.ts +0 -72
- package/src/MultiSelector/MultiSelector.focusableDisabled.test.tsx +0 -121
- package/src/MultiSelector/MultiSelector.fr10.test.tsx +0 -221
- package/src/MultiSelector/MultiSelector.test.tsx +0 -4971
- package/src/MultiSelector/OptionActions.a11y.chromium.spec.ts +0 -310
- package/src/MultiSelector/__tests__/MultiSelector.a11y.chromium.spec.ts +0 -46
- package/src/MultiSelector/__tests__/MultiSelector.listbox.a11y.test.tsx +0 -135
- package/src/NavIcon/NavIcon.test.tsx +0 -41
- package/src/NavMenu/NavHeadingMenu.test.tsx +0 -714
- package/src/NavMenu/__tests__/NavMenusSlideSelection.a11y.chromium.spec.ts +0 -137
- package/src/NumberInput/NumberInput.fr10.test.tsx +0 -21
- package/src/NumberInput/NumberInput.test.tsx +0 -2697
- package/src/NumberInput/__tests__/NumberInput.a11y.chromium.spec.ts +0 -124
- package/src/NumberInput/__tests__/NumberInput.a11y.known-failures.ts +0 -26
- package/src/NumberInput/__tests__/NumberInput.a11y.renders.tsx +0 -77
- package/src/NumberInput/__tests__/NumberInput.a11y.states.ts +0 -116
- package/src/NumberInput/__tests__/NumberInput.a11y.test.tsx +0 -154
- package/src/NumberInput/__tests__/NumberInput.coarse-pointer.a11y.chromium.spec.ts +0 -102
- package/src/NumberInput/numberInputCommit.test.ts +0 -72
- package/src/NumberInput/numberParser.docblock.test.ts +0 -234
- package/src/NumberInput/numberParser.test.ts +0 -222
- package/src/Outline/Outline.test.tsx +0 -1134
- package/src/Outline/OutlineFocus.a11y.chromium.spec.ts +0 -551
- package/src/Outline/parseOutlineFromMarkdown.test.ts +0 -104
- package/src/OverflowList/OverflowList.test.tsx +0 -1073
- package/src/Overlay/Overlay.test.tsx +0 -424
- package/src/Pagination/Pagination.test.tsx +0 -1754
- package/src/Popover/Popover.test.tsx +0 -1508
- package/src/Popover/PopoverPresentation.test.tsx +0 -952
- package/src/Popover/__tests__/PopoverSecondDocument.a11y.chromium.spec.ts +0 -267
- package/src/PowerSearch/PowerSearch.test.tsx +0 -1027
- package/src/PowerSearch/PowerSearchEditPopover.test.tsx +0 -1190
- package/src/PowerSearch/PowerSearchFilterEditor.test.tsx +0 -377
- package/src/PowerSearch/PowerSearchToken.test.tsx +0 -230
- package/src/PowerSearch/PowerSearchValueEditor.test.tsx +0 -754
- package/src/PowerSearch/formatFilterValue.test.ts +0 -339
- package/src/PowerSearch/resolveDateTimeRangePart.test.ts +0 -40
- package/src/PowerSearch/usePowerSearchConfig.test.ts +0 -832
- package/src/PowerSearch/usePowerSearchSource.test.ts +0 -621
- package/src/ProgressBar/ProgressBar.test.tsx +0 -928
- package/src/ProgressBar/__tests__/ProgressBar.a11y.chromium.spec.ts +0 -127
- package/src/ProgressBar/__tests__/ProgressBar.a11y.known-failures.ts +0 -12
- package/src/ProgressBar/__tests__/ProgressBar.a11y.renders.tsx +0 -38
- package/src/ProgressBar/__tests__/ProgressBar.a11y.states.ts +0 -123
- package/src/ProgressBar/__tests__/ProgressBar.a11y.test.tsx +0 -107
- package/src/ProgressBar/__tests__/ProgressBarMotion.a11y.chromium.spec.ts +0 -831
- package/src/RadioList/RadioList.fr10.test.tsx +0 -67
- package/src/RadioList/RadioList.test.tsx +0 -1051
- package/src/RadioList/RadioListItem.press.source-build.test.mjs +0 -80
- package/src/RadioList/__tests__/RadioGroup.a11y.chromium.spec.ts +0 -274
- package/src/RadioList/__tests__/RadioGroup.a11y.known-failures.ts +0 -12
- package/src/RadioList/__tests__/RadioGroup.a11y.renders.tsx +0 -232
- package/src/RadioList/__tests__/RadioGroup.a11y.states.ts +0 -503
- package/src/RadioList/__tests__/RadioGroup.a11y.test.tsx +0 -217
- package/src/Resizable/ResizeHandle.test.tsx +0 -1067
- package/src/Resizable/__tests__/ResizeHandle.a11y.chromium.spec.ts +0 -127
- package/src/Resizable/__tests__/ResizeHandle.a11y.known-failures.ts +0 -39
- package/src/Resizable/__tests__/ResizeHandle.a11y.renders.tsx +0 -80
- package/src/Resizable/__tests__/ResizeHandle.a11y.states.ts +0 -197
- package/src/Resizable/__tests__/ResizeHandle.a11y.test.tsx +0 -123
- package/src/Resizable/shippedDirections.test.ts +0 -462
- package/src/Resizable/useResizable.test.ts +0 -1725
- package/src/Resizable/utils.test.ts +0 -74
- package/src/ScrollableArea/ScrollableArea.test.tsx +0 -304
- package/src/Section/Section.test.tsx +0 -376
- package/src/SegmentedControl/SegmentedControl.test.tsx +0 -981
- package/src/SelectableCard/SelectableCard.test.tsx +0 -216
- package/src/Selector/Selector.focusableDisabled.test.tsx +0 -127
- package/src/Selector/Selector.fr10.test.tsx +0 -149
- package/src/Selector/Selector.sheetActiveDescendant.test.tsx +0 -95
- package/src/Selector/Selector.source-build.test.mjs +0 -79
- package/src/Selector/Selector.test.tsx +0 -5117
- package/src/Selector/__tests__/Combobox.a11y.known-failures.ts +0 -27
- package/src/Selector/__tests__/Combobox.a11y.states.ts +0 -145
- package/src/Selector/__tests__/ComboboxField.a11y.chromium.spec.ts +0 -458
- package/src/Selector/__tests__/EmptyStateAnnouncement.a11y.chromium.spec.ts +0 -91
- package/src/Selector/__tests__/Listbox.a11y.chromium.spec.ts +0 -131
- package/src/Selector/__tests__/Listbox.a11y.dom.ts +0 -38
- package/src/Selector/__tests__/Listbox.a11y.inventory.test.ts +0 -63
- package/src/Selector/__tests__/Listbox.a11y.known-failures.ts +0 -12
- package/src/Selector/__tests__/Listbox.a11y.states.ts +0 -232
- package/src/Selector/__tests__/Selector.a11y.chromium.spec.ts +0 -46
- package/src/Selector/__tests__/Selector.combobox.a11y.chromium.spec.ts +0 -109
- package/src/Selector/__tests__/Selector.combobox.a11y.test.tsx +0 -133
- package/src/Selector/__tests__/Selector.listbox.a11y.test.tsx +0 -128
- package/src/Selector/useCombobox.public.test.tsx +0 -89
- package/src/Selector/useCombobox.test.tsx +0 -444
- package/src/SideNav/SideNav.test.tsx +0 -4275
- package/src/SideNav/SideNavRailMotion.test.tsx +0 -620
- package/src/SideNav/__tests__/SideNavRailMotion.interaction.browser.spec.ts +0 -542
- package/src/SizeContext/SizeContext.test.tsx +0 -226
- package/src/Skeleton/Skeleton.test.tsx +0 -148
- package/src/Slider/Slider.fr10.test.tsx +0 -93
- package/src/Slider/Slider.test.tsx +0 -1661
- package/src/Slider/__tests__/Slider.a11y.chromium.spec.ts +0 -125
- package/src/Slider/__tests__/Slider.a11y.known-failures.ts +0 -12
- package/src/Slider/__tests__/Slider.a11y.renders.tsx +0 -42
- package/src/Slider/__tests__/Slider.a11y.states.ts +0 -106
- package/src/Slider/__tests__/Slider.a11y.test.tsx +0 -105
- package/src/Spinner/Spinner.test.tsx +0 -484
- package/src/Stack/Stack.test.tsx +0 -473
- package/src/Stack/StackItem.test.tsx +0 -105
- package/src/StatusDot/StatusDot.test.tsx +0 -213
- package/src/Stepper/Stepper.public.test.ts +0 -91
- package/src/Stepper/Stepper.test.tsx +0 -2130
- package/src/Switch/Switch.focusRing.source-build.test.mjs +0 -81
- package/src/Switch/Switch.test.tsx +0 -1136
- package/src/Switch/__tests__/Switch.a11y.chromium.spec.ts +0 -211
- package/src/Switch/__tests__/Switch.a11y.known-failures.ts +0 -28
- package/src/Switch/__tests__/Switch.a11y.states.ts +0 -275
- package/src/Switch/__tests__/Switch.a11y.test.tsx +0 -144
- package/src/TabList/TabList.test.tsx +0 -1755
- package/src/TabList/__tests__/TabListOverflow.interaction.browser.spec.ts +0 -99
- package/src/TabList/__tests__/TabPressPointer.interaction.browser.spec.ts +0 -163
- package/src/TabList/__tests__/Tabs.a11y.chromium.spec.ts +0 -199
- package/src/TabList/__tests__/Tabs.a11y.known-failures.ts +0 -12
- package/src/TabList/__tests__/Tabs.a11y.renders.tsx +0 -92
- package/src/TabList/__tests__/Tabs.a11y.states.ts +0 -247
- package/src/TabList/__tests__/Tabs.a11y.test.tsx +0 -153
- package/src/Table/Table.perf.test.tsx +0 -569
- package/src/Table/Table.test.tsx +0 -1883
- package/src/Table/TableHeaderCell.test.tsx +0 -291
- package/src/Table/TableSelectionToolbar.test.tsx +0 -109
- package/src/Table/__tests__/Table.a11y.chromium.spec.ts +0 -141
- package/src/Table/__tests__/Table.a11y.contracts.ts +0 -35
- package/src/Table/__tests__/Table.a11y.renders.tsx +0 -112
- package/src/Table/__tests__/Table.a11y.states.ts +0 -136
- package/src/Table/__tests__/Table.a11y.test.tsx +0 -198
- package/src/Table/__tests__/TableMinWidth.a11y.chromium.spec.ts +0 -75
- package/src/Table/__tests__/TableRowGlide.a11y.browser.spec.ts +0 -382
- package/src/Table/__tests__/TableScroll.a11y.chromium.spec.ts +0 -138
- package/src/Table/__tests__/TableStickyDividers.a11y.browser.spec.ts +0 -560
- package/src/Table/plugins/columnResize/useTableColumnResize.test.tsx +0 -941
- package/src/Table/plugins/columnSettings/useTableColumnSettings.test.tsx +0 -175
- package/src/Table/plugins/columnSettings/useTableColumnSettingsState.test.tsx +0 -296
- package/src/Table/plugins/filtering/useTableFilterState.test.tsx +0 -143
- package/src/Table/plugins/filtering/useTableFiltering.test.tsx +0 -357
- package/src/Table/plugins/groupedRows/useTableGroupedRows-perf.test.tsx +0 -112
- package/src/Table/plugins/groupedRows/useTableGroupedRows.test.tsx +0 -409
- package/src/Table/plugins/pagination/useTablePagination-perf.test.tsx +0 -232
- package/src/Table/plugins/pagination/useTablePagination.test.tsx +0 -666
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.glide.test.tsx +0 -280
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.test.tsx +0 -681
- package/src/Table/plugins/rowIndex/useTableRowIndex.test.tsx +0 -132
- package/src/Table/plugins/rowStatus/useTableRowStatus.public.test.ts +0 -92
- package/src/Table/plugins/rowStatus/useTableRowStatus.test.tsx +0 -519
- package/src/Table/plugins/selection/useTableSelection-perf.test.tsx +0 -258
- package/src/Table/plugins/selection/useTableSelection.test.tsx +0 -424
- package/src/Table/plugins/selection/useTableSelectionState.test.tsx +0 -451
- package/src/Table/plugins/sortable/__tests__/useTableSortable.a11y.test.tsx +0 -174
- package/src/Table/plugins/sortable/__tests__/useTableSortable.a11y.ts +0 -86
- package/src/Table/plugins/sortable/useTableSortable.test.tsx +0 -786
- package/src/Table/plugins/sortable/useTableSortableState.test.tsx +0 -580
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.test.tsx +0 -334
- package/src/Table/plugins/tree/useTableTreeData-perf.test.tsx +0 -163
- package/src/Table/plugins/tree/useTableTreeData.test.tsx +0 -992
- package/src/Table/plugins/tree/useTableTreeState.test.tsx +0 -740
- package/src/Table/tableContextMenu.test.tsx +0 -208
- package/src/Text/Text.test.tsx +0 -405
- package/src/Text/useTruncation.test.tsx +0 -196
- package/src/TextArea/TextArea.fr10.test.tsx +0 -21
- package/src/TextArea/TextArea.test.tsx +0 -1317
- package/src/TextInput/TextInput.fr10.test.tsx +0 -21
- package/src/TextInput/TextInput.test.tsx +0 -1280
- package/src/TextInput/__tests__/TextInput.a11y.chromium.spec.ts +0 -214
- package/src/TextInput/__tests__/TextInput.a11y.known-failures.ts +0 -40
- package/src/TextInput/__tests__/TextInput.a11y.renders.tsx +0 -202
- package/src/TextInput/__tests__/TextInput.a11y.states.ts +0 -384
- package/src/TextInput/__tests__/TextInput.a11y.test.tsx +0 -130
- package/src/Thumbnail/Thumbnail.test.tsx +0 -384
- package/src/TimeInput/NativeTimeInput.test.tsx +0 -343
- package/src/TimeInput/Presentation.test.tsx +0 -192
- package/src/TimeInput/TimeInput.fr10.test.tsx +0 -312
- package/src/TimeInput/TimeInput.test.tsx +0 -907
- package/src/Timer/Timer.test.tsx +0 -302
- package/src/Timestamp/Timestamp.test.tsx +0 -1661
- package/src/Timestamp/tooltipEntries.test.ts +0 -566
- package/src/Toast/ToastViewport.modalHost.test.tsx +0 -891
- package/src/Toast/ToastViewport.test.tsx +0 -3130
- package/src/Toast/useToast.test.tsx +0 -258
- package/src/ToggleButton/ToggleButton.test.tsx +0 -1000
- package/src/ToggleButton/__tests__/ToggleButton.a11y.chromium.spec.ts +0 -177
- package/src/ToggleButton/__tests__/ToggleButton.a11y.renders.tsx +0 -133
- package/src/ToggleButton/__tests__/ToggleButton.a11y.states.ts +0 -167
- package/src/ToggleButton/__tests__/ToggleButton.a11y.test.tsx +0 -103
- package/src/Token/Token.test.tsx +0 -707
- package/src/Token/__tests__/TokenRemoveTarget.a11y.chromium.spec.ts +0 -87
- package/src/Tokenizer/Tokenizer.fr10.test.tsx +0 -28
- package/src/Tokenizer/Tokenizer.props-type.test.tsx +0 -126
- package/src/Tokenizer/Tokenizer.ssr.test.tsx +0 -196
- package/src/Tokenizer/Tokenizer.test.tsx +0 -2216
- package/src/Tokenizer/TokenizerBottomSheet.test.tsx +0 -2738
- package/src/Tokenizer/__tests__/TokenizerEndLane.a11y.chromium.spec.ts +0 -505
- package/src/Toolbar/Toolbar.test.tsx +0 -600
- package/src/Toolbar/__tests__/Toolbar.a11y.chromium.spec.ts +0 -176
- package/src/Toolbar/__tests__/Toolbar.a11y.renders.tsx +0 -63
- package/src/Toolbar/__tests__/Toolbar.a11y.states.ts +0 -142
- package/src/Toolbar/__tests__/Toolbar.a11y.test.tsx +0 -126
- package/src/Tooltip/Tooltip.test.tsx +0 -819
- package/src/Tooltip/__tests__/Tooltip.a11y.chromium.spec.ts +0 -141
- package/src/Tooltip/__tests__/Tooltip.a11y.renders.tsx +0 -86
- package/src/Tooltip/__tests__/Tooltip.a11y.states.ts +0 -132
- package/src/Tooltip/__tests__/Tooltip.a11y.test.tsx +0 -126
- package/src/Tooltip/__tests__/TooltipFocusReturn.a11y.chromium.spec.ts +0 -130
- package/src/Tooltip/__tests__/TooltipHoverBridge.a11y.chromium.spec.ts +0 -75
- package/src/Tooltip/__tests__/TooltipTallContent.a11y.browser.spec.ts +0 -673
- package/src/Tooltip/__tests__/TooltipTallContentTracking.a11y.browser.spec.ts +0 -1162
- package/src/Tooltip/useTooltip.test.tsx +0 -483
- package/src/TopNav/TopNav.test.tsx +0 -863
- package/src/TopNav/TopNavMegaMenu.reduced-motion.source-build.test.mjs +0 -83
- package/src/TopNav/TopNavMegaMenu.test.tsx +0 -1153
- package/src/TopNav/TopNavMenu.test.tsx +0 -502
- package/src/TopNav/__tests__/TopNavMobileLongHeading.a11y.chromium.spec.ts +0 -75
- package/src/TreeList/TreeList.test.tsx +0 -1737
- package/src/TreeList/__tests__/TreeList.a11y.chromium.spec.ts +0 -138
- package/src/TreeList/__tests__/TreeList.a11y.renders.tsx +0 -44
- package/src/TreeList/__tests__/TreeList.a11y.states.ts +0 -164
- package/src/TreeList/__tests__/TreeList.a11y.test.tsx +0 -138
- package/src/TreeList/__tests__/TreeListGuideAlignment.interaction.browser.spec.ts +0 -127
- package/src/TreeList/__tests__/TreeListRowNames.a11y.chromium.spec.ts +0 -83
- package/src/Typeahead/BaseTypeahead.emptyState.a11y.chromium.spec.ts +0 -138
- package/src/Typeahead/BaseTypeahead.test.tsx +0 -553
- package/src/Typeahead/Typeahead.fr10.test.tsx +0 -28
- package/src/Typeahead/Typeahead.test.tsx +0 -2984
- package/src/Typeahead/TypeaheadItem.test.tsx +0 -134
- package/src/VStack/VStack.test.tsx +0 -128
- package/src/VisuallyHidden/VisuallyHidden.test.tsx +0 -115
- package/src/__tests__/BusyOwnerAnnouncement.test.tsx +0 -853
- package/src/__tests__/CardPress.a11y.chromium.spec.ts +0 -353
- package/src/__tests__/DisabledTriggerFocus.a11y.chromium.spec.ts +0 -87
- package/src/__tests__/PressModality.a11y.chromium.spec.ts +0 -392
- package/src/__tests__/PressedState.a11y.chromium.spec.ts +0 -814
- package/src/__tests__/TestIcon.tsx +0 -26
- package/src/__tests__/babelPluginAddExtensions.test.ts +0 -190
- package/src/__tests__/fastRoleQueries.ts +0 -66
- package/src/__tests__/forcedColors.ts +0 -60
- package/src/__tests__/internalModulesNotExperimental.test.ts +0 -88
- package/src/__tests__/pressState.ts +0 -216
- package/src/__tests__/stubMatchMedia.test.ts +0 -79
- package/src/__tests__/stubMatchMedia.ts +0 -95
- package/src/__tests__/stylexDeclarations.ts +0 -51
- package/src/__tests__/unthemedLength.ts +0 -34
- package/src/docPropLiterals.test.ts +0 -964
- package/src/docPropReferences.test.ts +0 -178
- package/src/docs-script.test.mjs +0 -55
- package/src/gestures/__tests__/GestureHost.test.ts +0 -2136
- package/src/gestures/__tests__/LongPressGestureRecognizer.test.ts +0 -141
- package/src/gestures/__tests__/PanGestureRecognizer.test.ts +0 -327
- package/src/gestures/__tests__/PinchGestureRecognizer.test.ts +0 -74
- package/src/gestures/__tests__/PressTracker.test.ts +0 -275
- package/src/gestures/__tests__/ScreenEdgePanGestureRecognizer.test.ts +0 -498
- package/src/gestures/__tests__/SwipeGestureRecognizer.test.ts +0 -108
- package/src/gestures/__tests__/TapGestureRecognizer.test.ts +0 -154
- package/src/gestures/__tests__/VelocityTracker.streams.test.ts +0 -243
- package/src/gestures/__tests__/VelocityTracker.test.ts +0 -261
- package/src/gestures/__tests__/arena.test.ts +0 -864
- package/src/gestures/__tests__/arenaContinuous.test.ts +0 -207
- package/src/gestures/__tests__/arenaPinchSwipeEdge.test.ts +0 -193
- package/src/gestures/__tests__/arenaTapLongPress.test.ts +0 -211
- package/src/gestures/__tests__/browser/build-fixture.mjs +0 -46
- package/src/gestures/__tests__/browser/fixture.ts +0 -307
- package/src/gestures/__tests__/browser/gestures.interaction.browser.spec.ts +0 -1137
- package/src/gestures/__tests__/browserNegotiation.test.ts +0 -293
- package/src/gestures/__tests__/fixtures/pointer-streams/README.md +0 -82
- package/src/gestures/__tests__/fixtures/pointer-streams/android-chromium-fling.json +0 -130
- package/src/gestures/__tests__/fixtures/pointer-streams/android-chromium-slow.json +0 -860
- package/src/gestures/__tests__/fixtures/pointer-streams/android-chromium-stop-release.json +0 -357
- package/src/gestures/__tests__/fixtures/pointer-streams/android-firefox-fling.json +0 -66
- package/src/gestures/__tests__/fixtures/pointer-streams/android-firefox-slow.json +0 -268
- package/src/gestures/__tests__/fixtures/pointer-streams/android-firefox-stop-release.json +0 -128
- package/src/gestures/__tests__/fixtures/pointer-streams/capture.html +0 -123
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-mouse-fling.json +0 -64
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-mouse-slow.json +0 -268
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-mouse-stop-release.json +0 -124
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-pen-fling.json +0 -64
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-pen-slow.json +0 -268
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-pen-stop-release.json +0 -124
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-touch-fling.json +0 -84
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-touch-slow.json +0 -381
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-touch-stop-release.json +0 -171
- package/src/gestures/__tests__/fixtures/pointer-streams/ios-safari-fling.json +0 -45
- package/src/gestures/__tests__/fixtures/pointer-streams/ios-safari-slow.json +0 -101
- package/src/gestures/__tests__/fixtures/pointer-streams/ios-safari-stop-release.json +0 -130
- package/src/gestures/__tests__/haptics.test.ts +0 -187
- package/src/gestures/__tests__/harness.ts +0 -252
- package/src/gestures/__tests__/pressTrackerFactory.test.ts +0 -59
- package/src/gestures/__tests__/recognizerKind.test.ts +0 -78
- package/src/gestures/__tests__/touchActionRule.test.ts +0 -54
- package/src/gestures/__tests__/useGestureRecognizer.test.tsx +0 -570
- package/src/hooks/__tests__/MenuPressShadowRoot.a11y.chromium.spec.ts +0 -144
- package/src/hooks/__tests__/menuLinkClicks.ts +0 -71
- package/src/hooks/actionGroupTracker.exports.test.ts +0 -28
- package/src/hooks/actionGroupTracker.test.ts +0 -510
- package/src/hooks/computeOverflow.test.ts +0 -422
- package/src/hooks/deprecatedApis.public.test.ts +0 -33
- package/src/hooks/menuPressGesture.test.ts +0 -253
- package/src/hooks/scrollKeyboardDelegation.test.ts +0 -188
- package/src/hooks/scrollbarGutter.test.ts +0 -167
- package/src/hooks/useAnnounce.modal.test.tsx +0 -1291
- package/src/hooks/useAnnounce.replace.test.tsx +0 -516
- package/src/hooks/useAnnounce.test.tsx +0 -293
- package/src/hooks/useAnnounceRenderedText.adopters.test.tsx +0 -235
- package/src/hooks/useAutoMediaMode.test.ts +0 -109
- package/src/hooks/useBusyAnnouncement.adopters.test.tsx +0 -69
- package/src/hooks/useBusyAnnouncement.test.tsx +0 -112
- package/src/hooks/useClickableContainer.test.tsx +0 -236
- package/src/hooks/useClipboard.test.tsx +0 -151
- package/src/hooks/useContainerReveal.test.tsx +0 -163
- package/src/hooks/useDevWarning.test.tsx +0 -45
- package/src/hooks/useEntryAnimation.ssr.test.tsx +0 -143
- package/src/hooks/useFocusTrap.test.tsx +0 -635
- package/src/hooks/useFocusTrapEscapeShim.test.tsx +0 -166
- package/src/hooks/useGridFocus.test.tsx +0 -165
- package/src/hooks/useHotkeys.test.ts +0 -265
- package/src/hooks/useImageMode.test.ts +0 -133
- package/src/hooks/useInputContainer.test.tsx +0 -180
- package/src/hooks/useInputStatusIcon.test.tsx +0 -240
- package/src/hooks/useIsHydrating.test.tsx +0 -70
- package/src/hooks/useKeyboardHint.test.tsx +0 -92
- package/src/hooks/useListFocus.test.tsx +0 -664
- package/src/hooks/useLongPress.test.tsx +0 -152
- package/src/hooks/useMediaQuery.test.ts +0 -165
- package/src/hooks/useMenuHover.test.tsx +0 -536
- package/src/hooks/useMenuPress.test.tsx +0 -565
- package/src/hooks/useMergedRefs.test.tsx +0 -62
- package/src/hooks/useOverflow.test.ts +0 -504
- package/src/hooks/useRenamedProp.test.tsx +0 -95
- package/src/hooks/useScrollLock.test.ts +0 -248
- package/src/hooks/useScrollOverflow.test.tsx +0 -323
- package/src/hooks/useScrollableArea.test.tsx +0 -836
- package/src/hooks/useStreamingText.test.ts +0 -237
- package/src/hooks/useTreeFocus.test.tsx +0 -351
- package/src/hooks/useTypeahead.test.tsx +0 -351
- package/src/i18n/__tests__/InternationalizationProvider.test.tsx +0 -128
- package/src/i18n/__tests__/e2e-pagination.test.tsx +0 -172
- package/src/i18n/__tests__/e2e-powersearch.test.tsx +0 -166
- package/src/i18n/__tests__/getLocaleDirection.test.ts +0 -40
- package/src/i18n/__tests__/resolve.test.ts +0 -325
- package/src/i18n/__tests__/useCollator.test.tsx +0 -115
- package/src/i18n/__tests__/useDirection.test.tsx +0 -66
- package/src/i18n/__tests__/useLocale.test.tsx +0 -52
- package/src/i18n/useTranslator.test.tsx +0 -267
- package/src/inputFontFloor.test.ts +0 -106
- package/src/internal/tokenizer-presentation.test.ts +0 -29
- package/src/internal/touch.test.ts +0 -44
- package/src/motion/__tests__/animatedLayout.interaction.browser.spec.ts +0 -1613
- package/src/motion/__tests__/animatedLayoutAdopters.interaction.browser.spec.ts +0 -217
- package/src/motion/__tests__/animatedLayoutBundle.ts +0 -17
- package/src/motion/__tests__/animator.interaction.browser.spec.ts +0 -843
- package/src/motion/__tests__/motionBundle.ts +0 -14
- package/src/motion/animatedLayout.boundary.test.ts +0 -155
- package/src/motion/animatedLayout.swap.test.ts +0 -827
- package/src/motion/animatedLayout.test.ts +0 -1154
- package/src/motion/animatedLayoutAdopters.test.tsx +0 -500
- package/src/motion/animator.test.ts +0 -3746
- package/src/motion/bezier.test.ts +0 -52
- package/src/motion/coast.test.ts +0 -99
- package/src/motion/decay.test.ts +0 -120
- package/src/motion/projection.test.ts +0 -107
- package/src/motion/reducedMotion.test.ts +0 -129
- package/src/motion/reducedMotionPlan.test.ts +0 -208
- package/src/motion/resolveMotion.test.ts +0 -123
- package/src/motion/resolveSnapPoint.test.ts +0 -189
- package/src/motion/roles.test.ts +0 -273
- package/src/motion/rubberBand.test.ts +0 -88
- package/src/motion/selectPage.test.ts +0 -31
- package/src/motion/spring.test.ts +0 -650
- package/src/motion/uikit/gestures.test.ts +0 -89
- package/src/motion/uikit/springRows.test.ts +0 -71
- package/src/motion/uikit/tableImports.test.ts +0 -293
- package/src/motion/uikit/uikit.test.ts +0 -364
- package/src/motion/uikit/values.test.ts +0 -121
- package/src/naming.test.ts +0 -44
- package/src/postinstall.test.mjs +0 -216
- package/src/reset.a11y.chromium.spec.ts +0 -238
- package/src/reset.test.ts +0 -205
- package/src/reset.until-found.a11y.browser.spec.ts +0 -76
- package/src/reset.until-found.test.ts +0 -32
- package/src/serverSafeComponents.test.ts +0 -675
- package/src/stylexValidation.source-build.test.mjs +0 -42
- package/src/tailwind-theme.test.ts +0 -153
- package/src/theme/MediaTheme.dom.test.tsx +0 -97
- package/src/theme/Theme.test.tsx +0 -337
- package/src/theme/__tests__/SpacingRootFontSize.a11y.chromium.spec.ts +0 -199
- package/src/theme/contrast.test.ts +0 -94
- package/src/theme/declarationBoundary.test.ts +0 -126
- package/src/theme/defineTheme.test.ts +0 -2028
- package/src/theme/derivedVarRegistry.test.ts +0 -592
- package/src/theme/expandColorScale.test.ts +0 -651
- package/src/theme/expandMotionScale.test.ts +0 -145
- package/src/theme/expandRadiusScale.test.ts +0 -59
- package/src/theme/expandTypeScale.test.ts +0 -351
- package/src/theme/extensibleAxes.test.ts +0 -432
- package/src/theme/generateThemeRules.test.ts +0 -1870
- package/src/theme/hct.test.ts +0 -93
- package/src/theme/onMediaTokens.test.ts +0 -431
- package/src/theme/publicThemeHelperContract.test.ts +0 -67
- package/src/theme/syntax/defineSyntaxTheme.diff.test.ts +0 -91
- package/src/theme/syntax/serverSafeSyntax.test.ts +0 -68
- package/src/theme/syntax/useSyntaxTheme.diff.test.tsx +0 -40
- package/src/theme/themeAdaptations.test.ts +0 -1795
- package/src/theme/themeMotion.test.ts +0 -620
- package/src/theme/themeRegistry.test.ts +0 -59
- package/src/theme/themingTargets.test.ts +0 -589
- package/src/theme/tokenValueCompat.test.ts +0 -204
- package/src/theme/tokens.test.ts +0 -441
- package/src/theme/useTheme.test.tsx +0 -322
- package/src/unicodePropertyEscapes.source-build.test.mjs +0 -69
- package/src/utils/chainEventHandlers.test.ts +0 -39
- package/src/utils/characters.test.ts +0 -141
- package/src/utils/color.test.ts +0 -233
- package/src/utils/composeEventHandlers.test.ts +0 -71
- package/src/utils/customPropertyArmLayering.test.ts +0 -131
- package/src/utils/dateParser.test.ts +0 -402
- package/src/utils/dateTypes.test.ts +0 -40
- package/src/utils/devWarning.test.ts +0 -56
- package/src/utils/edgeAutoscroll.test.ts +0 -192
- package/src/utils/focusReturn.test.ts +0 -119
- package/src/utils/getKey.test.ts +0 -25
- package/src/utils/getNodeText.test.ts +0 -24
- package/src/utils/hitArea.test.ts +0 -628
- package/src/utils/ime.test.ts +0 -32
- package/src/utils/inputAria.test.ts +0 -39
- package/src/utils/interactionModality.test.ts +0 -144
- package/src/utils/isApplePlatform.test.ts +0 -61
- package/src/utils/mergeProps.test.ts +0 -166
- package/src/utils/mergeRefs.test.ts +0 -48
- package/src/utils/parseStyleKey.test.ts +0 -56
- package/src/utils/plainDate.test.ts +0 -938
- package/src/utils/presentation.test.ts +0 -380
- package/src/utils/pressFeedback.test.ts +0 -1012
- package/src/utils/pressGesture.test.ts +0 -332
- package/src/utils/pressPaintPriority.test.ts +0 -80
- package/src/utils/pressPaintSource.test.ts +0 -65
- package/src/utils/pressableCoverage.test.ts +0 -192
- package/src/utils/primaryClick.test.ts +0 -38
- package/src/utils/safeUrl.test.ts +0 -101
- package/src/utils/sharedMutationObserver.test.ts +0 -106
- package/src/utils/sharedResizeObserver.test.ts +0 -283
- package/src/utils/themeProps.test.ts +0 -62
- package/src/utils/timeFormat.test.ts +0 -204
- package/src/utils/timeParser.test.ts +0 -295
- package/src/utils/touchPresentation.test.ts +0 -462
- package/src/utils/unicodeDigits.test.ts +0 -44
package/src/Table/Table.test.tsx
DELETED
|
@@ -1,1883 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file Table.test.tsx
|
|
5
|
-
* @input Uses vitest, @testing-library/react, Table components
|
|
6
|
-
* @output Unit tests for BaseTable and Table
|
|
7
|
-
* @position Testing; validates Table implementation
|
|
8
|
-
*
|
|
9
|
-
* SYNC: When BaseTable.tsx or Table.tsx change, update tests to match new behavior
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {describe, it, expect, vi} from 'vitest';
|
|
13
|
-
import {act, render, screen} from '@testing-library/react';
|
|
14
|
-
import * as stylex from '@stylexjs/stylex';
|
|
15
|
-
import {BaseTable} from './BaseTable';
|
|
16
|
-
import {Table} from './Table';
|
|
17
|
-
import {TableRow} from './TableRow';
|
|
18
|
-
import {TableCell} from './TableCell';
|
|
19
|
-
import {TableHeader} from './TableHeader';
|
|
20
|
-
import {TableBody} from './TableBody';
|
|
21
|
-
import {TableFooter} from './TableFooter';
|
|
22
|
-
import {
|
|
23
|
-
proportional,
|
|
24
|
-
pixel,
|
|
25
|
-
generateColumns,
|
|
26
|
-
resolveColumnWidths,
|
|
27
|
-
resolveTableMinWidth,
|
|
28
|
-
capitalize,
|
|
29
|
-
DEFAULT_FLEXIBLE_COLUMN_MIN_WIDTH,
|
|
30
|
-
DEFAULT_MIN_COLUMN_WIDTH,
|
|
31
|
-
} from './columnUtils';
|
|
32
|
-
import type {TablePlugin, TableColumn, ProportionalWidth} from './types';
|
|
33
|
-
|
|
34
|
-
// =============================================================================
|
|
35
|
-
// Test Data
|
|
36
|
-
// =============================================================================
|
|
37
|
-
|
|
38
|
-
interface User extends Record<string, unknown> {
|
|
39
|
-
name: string;
|
|
40
|
-
age: number;
|
|
41
|
-
email: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const users: User[] = [
|
|
45
|
-
{name: 'Alice', age: 30, email: 'alice@example.com'},
|
|
46
|
-
{name: 'Bob', age: 25, email: 'bob@example.com'},
|
|
47
|
-
{name: 'Charlie', age: 35, email: 'charlie@example.com'},
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
const columns: TableColumn<User>[] = [
|
|
51
|
-
{key: 'name', header: 'Name'},
|
|
52
|
-
{key: 'age', header: 'Age', width: pixel(80)},
|
|
53
|
-
{key: 'email', header: 'Email', width: proportional(2)},
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
// =============================================================================
|
|
57
|
-
// columnUtils Tests
|
|
58
|
-
// =============================================================================
|
|
59
|
-
|
|
60
|
-
describe('columnUtils', () => {
|
|
61
|
-
describe('proportional', () => {
|
|
62
|
-
it('creates a proportional width with default value 1 and default minWidth', () => {
|
|
63
|
-
const w = proportional();
|
|
64
|
-
expect(w).toEqual({
|
|
65
|
-
type: 'proportional',
|
|
66
|
-
value: 1,
|
|
67
|
-
minWidth: DEFAULT_MIN_COLUMN_WIDTH,
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('creates a proportional width with custom value and default minWidth', () => {
|
|
72
|
-
const w = proportional(3);
|
|
73
|
-
expect(w).toEqual({
|
|
74
|
-
type: 'proportional',
|
|
75
|
-
value: 3,
|
|
76
|
-
minWidth: DEFAULT_MIN_COLUMN_WIDTH,
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
describe('pixel', () => {
|
|
82
|
-
it('creates a pixel width', () => {
|
|
83
|
-
const w = pixel(200);
|
|
84
|
-
expect(w).toEqual({type: 'pixel', value: 200});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('capitalize', () => {
|
|
89
|
-
it('capitalizes first letter', () => {
|
|
90
|
-
expect(capitalize('name')).toBe('Name');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('handles empty string', () => {
|
|
94
|
-
expect(capitalize('')).toBe('');
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('handles single character', () => {
|
|
98
|
-
expect(capitalize('a')).toBe('A');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('uppercases an astral-plane letter without splitting it (#4759)', () => {
|
|
102
|
-
// Deseret 𐐨 (U+10428) uppercases to 𐐀 (U+10400); charAt(0) would grab
|
|
103
|
-
// half the surrogate pair and leave the string unchanged.
|
|
104
|
-
expect(capitalize('\u{10428}pple')).toBe('\u{10400}pple');
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe('generateColumns', () => {
|
|
109
|
-
it('generates columns from data keys', () => {
|
|
110
|
-
const cols = generateColumns(users);
|
|
111
|
-
expect(cols).toHaveLength(3);
|
|
112
|
-
expect(cols[0].key).toBe('name');
|
|
113
|
-
expect(cols[0].header).toBe('Name');
|
|
114
|
-
expect(cols[1].key).toBe('age');
|
|
115
|
-
expect(cols[1].header).toBe('Age');
|
|
116
|
-
expect(cols[2].key).toBe('email');
|
|
117
|
-
expect(cols[2].header).toBe('Email');
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('returns empty array for empty data', () => {
|
|
121
|
-
expect(generateColumns([])).toEqual([]);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('assigns content-proportional widths based on data analysis', () => {
|
|
125
|
-
const cols = generateColumns(users);
|
|
126
|
-
// All columns should have proportional type
|
|
127
|
-
for (const col of cols) {
|
|
128
|
-
expect(col.width?.type).toBe('proportional');
|
|
129
|
-
}
|
|
130
|
-
// Columns with longer content should get higher proportion
|
|
131
|
-
const emailCol = cols.find(c => c.key === 'email')!;
|
|
132
|
-
const ageCol = cols.find(c => c.key === 'age')!;
|
|
133
|
-
expect(emailCol.width!.value).toBeGreaterThan(ageCol.width!.value);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('derives min-width from header or longest word', () => {
|
|
137
|
-
const cols = generateColumns(users);
|
|
138
|
-
for (const col of cols) {
|
|
139
|
-
// Min-width should be at least the floor
|
|
140
|
-
expect(
|
|
141
|
-
(col.width as ProportionalWidth).minWidth,
|
|
142
|
-
).toBeGreaterThanOrEqual(60);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('produces stable width values for known data', () => {
|
|
147
|
-
const cols = generateColumns(users);
|
|
148
|
-
// Snapshot: these values should remain stable over time.
|
|
149
|
-
// name: "Charlie" (7 chars) → medium → proportion 2
|
|
150
|
-
// age: "35" (2 chars) → short → proportion 1
|
|
151
|
-
// email: "charlie@example.com" (19 chars) → long → proportion 3
|
|
152
|
-
const nameCol = cols.find(c => c.key === 'name')!;
|
|
153
|
-
const ageCol = cols.find(c => c.key === 'age')!;
|
|
154
|
-
const emailCol = cols.find(c => c.key === 'email')!;
|
|
155
|
-
|
|
156
|
-
expect(nameCol.width).toEqual({
|
|
157
|
-
type: 'proportional',
|
|
158
|
-
value: 2,
|
|
159
|
-
minWidth: 60, // max("Name"=4, "Charlie"=7) * 8 = 56 → floor 60
|
|
160
|
-
});
|
|
161
|
-
expect(ageCol.width).toEqual({
|
|
162
|
-
type: 'proportional',
|
|
163
|
-
value: 1,
|
|
164
|
-
minWidth: 60, // max("Age"=3, "35"=2) * 8 = 24 → floor 60
|
|
165
|
-
});
|
|
166
|
-
expect(emailCol.width).toEqual({
|
|
167
|
-
type: 'proportional',
|
|
168
|
-
value: 3,
|
|
169
|
-
minWidth: 152, // max("Email"=5, "charlie@example.com"=19) * 8 = 152
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('does not analyze non-string/number values', () => {
|
|
174
|
-
const data = [
|
|
175
|
-
{id: 1, meta: {nested: 'object'}, tags: ['a', 'b']},
|
|
176
|
-
{id: 2, meta: {nested: 'thing'}, tags: ['c']},
|
|
177
|
-
];
|
|
178
|
-
const cols = generateColumns(data);
|
|
179
|
-
// meta and tags are objects/arrays — should get 0 content length
|
|
180
|
-
// so their proportion comes only from header length
|
|
181
|
-
const metaCol = cols.find(c => c.key === 'meta')!;
|
|
182
|
-
const tagsCol = cols.find(c => c.key === 'tags')!;
|
|
183
|
-
// Header "Meta" = 4, "Tags" = 4 — both should have same proportion
|
|
184
|
-
expect((metaCol.width as ProportionalWidth).value).toBe(
|
|
185
|
-
(tagsCol.width as ProportionalWidth).value,
|
|
186
|
-
);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('never overrides explicit column widths', () => {
|
|
190
|
-
// generateColumns is only called when no columns prop is provided.
|
|
191
|
-
// This test verifies the contract: explicit widths pass through unchanged.
|
|
192
|
-
const explicit: TableColumn<User>[] = [
|
|
193
|
-
{key: 'name', header: 'Name', width: pixel(200)},
|
|
194
|
-
{
|
|
195
|
-
key: 'email',
|
|
196
|
-
header: 'Email',
|
|
197
|
-
width: proportional(3, {minWidth: 300}),
|
|
198
|
-
},
|
|
199
|
-
];
|
|
200
|
-
// resolveColumnWidths should use the explicit values, not re-derive
|
|
201
|
-
const resolved = resolveColumnWidths(explicit);
|
|
202
|
-
expect(resolved.columns.get('name')?.style.width).toBe('200px');
|
|
203
|
-
expect(resolved.columns.get('email')?.style.minWidth).toBe('300px');
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
describe('proportional with minWidth', () => {
|
|
208
|
-
it('creates a proportional width with explicit minWidth', () => {
|
|
209
|
-
const w = proportional(1, {minWidth: 200});
|
|
210
|
-
expect(w).toEqual({type: 'proportional', value: 1, minWidth: 200});
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('uses DEFAULT_MIN_COLUMN_WIDTH when no minWidth provided', () => {
|
|
214
|
-
const w = proportional(2);
|
|
215
|
-
expect(w).toEqual({
|
|
216
|
-
type: 'proportional',
|
|
217
|
-
value: 2,
|
|
218
|
-
minWidth: DEFAULT_MIN_COLUMN_WIDTH,
|
|
219
|
-
});
|
|
220
|
-
expect(w.minWidth).toBe(DEFAULT_MIN_COLUMN_WIDTH);
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
// =============================================================================
|
|
226
|
-
// BaseTable Tests
|
|
227
|
-
// =============================================================================
|
|
228
|
-
|
|
229
|
-
describe('BaseTable', () => {
|
|
230
|
-
it('renders a table element', () => {
|
|
231
|
-
render(<BaseTable data={users} columns={columns} />);
|
|
232
|
-
expect(screen.getByRole('table')).toBeInTheDocument();
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it('renders column headers as th elements', () => {
|
|
236
|
-
render(<BaseTable data={users} columns={columns} />);
|
|
237
|
-
const headers = screen.getAllByRole('columnheader');
|
|
238
|
-
expect(headers).toHaveLength(3);
|
|
239
|
-
expect(headers[0]).toHaveTextContent('Name');
|
|
240
|
-
expect(headers[1]).toHaveTextContent('Age');
|
|
241
|
-
expect(headers[2]).toHaveTextContent('Email');
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('renders every column header with scope="col"', () => {
|
|
245
|
-
render(<BaseTable data={users} columns={columns} />);
|
|
246
|
-
const headers = screen.getAllByRole('columnheader');
|
|
247
|
-
expect(headers).toHaveLength(3);
|
|
248
|
-
for (const header of headers) {
|
|
249
|
-
expect(header).toHaveAttribute('scope', 'col');
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it('lets a consumer override scope via header html props', () => {
|
|
254
|
-
// A `<th scope="row">` maps to the `rowheader` role, so query the DOM
|
|
255
|
-
// directly to assert the attribute regardless of the resolved ARIA role.
|
|
256
|
-
const plugin: TablePlugin<User> = {
|
|
257
|
-
transformHeaderCell: (props, column) =>
|
|
258
|
-
column.key === 'name'
|
|
259
|
-
? {...props, htmlProps: {...props.htmlProps, scope: 'row'}}
|
|
260
|
-
: props,
|
|
261
|
-
};
|
|
262
|
-
const {container} = render(
|
|
263
|
-
<BaseTable data={users} columns={columns} plugins={[plugin]} />,
|
|
264
|
-
);
|
|
265
|
-
const headerCells = container.querySelectorAll('thead th');
|
|
266
|
-
// columns fixture order: name, age, email — plugin overrides name → 'row'
|
|
267
|
-
expect(headerCells[0]).toHaveAttribute('scope', 'row');
|
|
268
|
-
expect(headerCells[1]).toHaveAttribute('scope', 'col');
|
|
269
|
-
expect(headerCells[2]).toHaveAttribute('scope', 'col');
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it('renders data cells', () => {
|
|
273
|
-
render(<BaseTable data={users} columns={columns} />);
|
|
274
|
-
const cells = screen.getAllByRole('cell');
|
|
275
|
-
// 3 rows * 3 columns = 9 cells
|
|
276
|
-
expect(cells).toHaveLength(9);
|
|
277
|
-
expect(screen.getByText('Alice')).toBeInTheDocument();
|
|
278
|
-
expect(screen.getByText('30')).toBeInTheDocument();
|
|
279
|
-
expect(screen.getByText('alice@example.com')).toBeInTheDocument();
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it('renders correct number of rows', () => {
|
|
283
|
-
render(<BaseTable data={users} columns={columns} />);
|
|
284
|
-
// 1 header row + 3 data rows
|
|
285
|
-
expect(screen.getAllByRole('row')).toHaveLength(4);
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it('does not apply hover styling to the header row when hasHover is set', () => {
|
|
289
|
-
// Use the public Table (provides TableContext); BaseTable alone has no
|
|
290
|
-
// context, so rows wouldn't pick up hover styling at all.
|
|
291
|
-
const {container} = render(
|
|
292
|
-
<Table data={users} columns={columns} hasHover />,
|
|
293
|
-
);
|
|
294
|
-
const headerRow = container.querySelector('thead tr');
|
|
295
|
-
const bodyRow = container.querySelector('tbody tr');
|
|
296
|
-
expect(headerRow).not.toBeNull();
|
|
297
|
-
expect(bodyRow).not.toBeNull();
|
|
298
|
-
|
|
299
|
-
const headerClasses = new Set(
|
|
300
|
-
(headerRow?.className ?? '').split(/\s+/).filter(Boolean),
|
|
301
|
-
);
|
|
302
|
-
// The body row carries hover-styling class(es) that the header row does not.
|
|
303
|
-
const bodyOnlyClasses = (bodyRow?.className ?? '')
|
|
304
|
-
.split(/\s+/)
|
|
305
|
-
.filter(c => c && !headerClasses.has(c));
|
|
306
|
-
expect(bodyOnlyClasses.length).toBeGreaterThan(0);
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
it('auto-generates columns from data keys when columns omitted', () => {
|
|
310
|
-
render(<BaseTable data={users} />);
|
|
311
|
-
const headers = screen.getAllByRole('columnheader');
|
|
312
|
-
expect(headers).toHaveLength(3);
|
|
313
|
-
expect(headers[0]).toHaveTextContent('Name');
|
|
314
|
-
expect(headers[1]).toHaveTextContent('Age');
|
|
315
|
-
expect(headers[2]).toHaveTextContent('Email');
|
|
316
|
-
expect(screen.getByText('Alice')).toBeInTheDocument();
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
it('uses raw key as header when header prop is not provided', () => {
|
|
320
|
-
const cols: TableColumn<User>[] = [{key: 'name'}];
|
|
321
|
-
render(<BaseTable data={users} columns={cols} />);
|
|
322
|
-
expect(screen.getByRole('columnheader')).toHaveTextContent('name');
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
it('renders custom header as ReactNode', () => {
|
|
326
|
-
const cols: TableColumn<User>[] = [
|
|
327
|
-
{key: 'name', header: <span data-testid="custom-header">Full Name</span>},
|
|
328
|
-
];
|
|
329
|
-
render(<BaseTable data={users} columns={cols} />);
|
|
330
|
-
expect(screen.getByTestId('custom-header')).toHaveTextContent('Full Name');
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
it('uses idKey string to key rows', () => {
|
|
334
|
-
render(<BaseTable data={users} columns={columns} idKey="email" />);
|
|
335
|
-
expect(screen.getAllByRole('row')).toHaveLength(4);
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
it('uses idKey function to key rows', () => {
|
|
339
|
-
render(
|
|
340
|
-
<BaseTable data={users} columns={columns} idKey={item => item.email} />,
|
|
341
|
-
);
|
|
342
|
-
expect(screen.getAllByRole('row')).toHaveLength(4);
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
it('renders custom cell renderer', () => {
|
|
346
|
-
const customColumns: TableColumn<User>[] = [
|
|
347
|
-
{
|
|
348
|
-
key: 'name',
|
|
349
|
-
header: 'Name',
|
|
350
|
-
renderCell: (item: User) => (
|
|
351
|
-
<strong data-testid="bold-name">{item.name}</strong>
|
|
352
|
-
),
|
|
353
|
-
},
|
|
354
|
-
];
|
|
355
|
-
render(<BaseTable data={users} columns={customColumns} />);
|
|
356
|
-
const boldNames = screen.getAllByTestId('bold-name');
|
|
357
|
-
expect(boldNames).toHaveLength(3);
|
|
358
|
-
expect(boldNames[0]).toHaveTextContent('Alice');
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
it('renders null/undefined values as empty string', () => {
|
|
362
|
-
const data = [{name: null as unknown as string, age: 0, email: ''}];
|
|
363
|
-
render(<BaseTable data={data} columns={columns} />);
|
|
364
|
-
const cells = screen.getAllByRole('cell');
|
|
365
|
-
// null renders as empty, 0 renders as '0', empty string renders as empty
|
|
366
|
-
expect(cells[0]).toHaveTextContent('');
|
|
367
|
-
expect(cells[1]).toHaveTextContent('0');
|
|
368
|
-
expect(cells[2]).toHaveTextContent('');
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
it('renders children mode instead of data', () => {
|
|
372
|
-
render(
|
|
373
|
-
<BaseTable>
|
|
374
|
-
<tbody>
|
|
375
|
-
<tr>
|
|
376
|
-
<td>Manual cell</td>
|
|
377
|
-
</tr>
|
|
378
|
-
</tbody>
|
|
379
|
-
</BaseTable>,
|
|
380
|
-
);
|
|
381
|
-
expect(screen.getByText('Manual cell')).toBeInTheDocument();
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
it('does not render thead in children mode without columns', () => {
|
|
385
|
-
const {container} = render(
|
|
386
|
-
<BaseTable>
|
|
387
|
-
<tbody>
|
|
388
|
-
<tr>
|
|
389
|
-
<td>Content</td>
|
|
390
|
-
</tr>
|
|
391
|
-
</tbody>
|
|
392
|
-
</BaseTable>,
|
|
393
|
-
);
|
|
394
|
-
expect(container.querySelector('thead')).toBeNull();
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
it('renders empty table when data is empty array', () => {
|
|
398
|
-
render(<BaseTable data={[]} columns={columns} />);
|
|
399
|
-
expect(screen.getByRole('table')).toBeInTheDocument();
|
|
400
|
-
// Header row + empty state row
|
|
401
|
-
expect(screen.getAllByRole('row')).toHaveLength(2);
|
|
402
|
-
expect(screen.getByText('No data')).toBeInTheDocument();
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
it('does not render colgroup', () => {
|
|
406
|
-
const {container} = render(<BaseTable data={users} columns={columns} />);
|
|
407
|
-
expect(container.querySelector('colgroup')).toBeNull();
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
it('forwards ref to the table element', () => {
|
|
411
|
-
const ref = vi.fn();
|
|
412
|
-
render(<BaseTable data={users} columns={columns} ref={ref} />);
|
|
413
|
-
expect(ref).toHaveBeenCalledWith(expect.any(HTMLTableElement));
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
describe('root element styling props (#3679)', () => {
|
|
417
|
-
it('applies className to the table element', () => {
|
|
418
|
-
render(<Table data={users} columns={columns} className="custom-table" />);
|
|
419
|
-
expect(screen.getByRole('table').className).toContain('custom-table');
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
it('applies style to the table element', () => {
|
|
423
|
-
render(<Table data={users} columns={columns} style={{opacity: 0.9}} />);
|
|
424
|
-
expect(screen.getByRole('table').style.opacity).toBe('0.9');
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
it('accepts xstyle without error', () => {
|
|
428
|
-
render(<Table data={users} columns={columns} xstyle={undefined} />);
|
|
429
|
-
expect(screen.getByRole('table')).toBeInTheDocument();
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
it('spreads id and aria attributes onto the table element', () => {
|
|
433
|
-
render(
|
|
434
|
-
<Table
|
|
435
|
-
data={users}
|
|
436
|
-
columns={columns}
|
|
437
|
-
id="users-table"
|
|
438
|
-
aria-label="Users"
|
|
439
|
-
data-analytics="tables"
|
|
440
|
-
/>,
|
|
441
|
-
);
|
|
442
|
-
const table = screen.getByRole('table', {name: 'Users'});
|
|
443
|
-
expect(table.id).toBe('users-table');
|
|
444
|
-
expect(table).toHaveAttribute('data-analytics', 'tables');
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
it('keeps the computed column min-width over a consumer style.minWidth', () => {
|
|
448
|
-
const {tableMinWidth} = resolveColumnWidths(columns);
|
|
449
|
-
render(
|
|
450
|
-
<Table data={users} columns={columns} style={{minWidth: '10px'}} />,
|
|
451
|
-
);
|
|
452
|
-
expect(screen.getByRole('table').style.minWidth).toBe(
|
|
453
|
-
`${tableMinWidth}px`,
|
|
454
|
-
);
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
it('lets a consumer style.minWidth survive when no columns are resolved', () => {
|
|
458
|
-
render(
|
|
459
|
-
<Table style={{minWidth: '10px'}}>
|
|
460
|
-
<tbody>
|
|
461
|
-
<TableRow>
|
|
462
|
-
<TableCell>Cell</TableCell>
|
|
463
|
-
</TableRow>
|
|
464
|
-
</tbody>
|
|
465
|
-
</Table>,
|
|
466
|
-
);
|
|
467
|
-
expect(screen.getByRole('table').style.minWidth).toBe('10px');
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
it('keeps a larger consumer style.minWidth beside width-less column floors', () => {
|
|
471
|
-
const plain: TableColumn<User>[] = [
|
|
472
|
-
{key: 'name'},
|
|
473
|
-
{key: 'age'},
|
|
474
|
-
{key: 'email'},
|
|
475
|
-
{key: 'role'},
|
|
476
|
-
];
|
|
477
|
-
render(<Table data={users} columns={plain} style={{minWidth: 900}} />);
|
|
478
|
-
expect(screen.getByRole('table').style.minWidth).toBe('900px');
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
it.each([
|
|
482
|
-
[undefined, '240px'],
|
|
483
|
-
[900, '900px'],
|
|
484
|
-
[100, '240px'],
|
|
485
|
-
[0, '240px'],
|
|
486
|
-
['900px', '900px'],
|
|
487
|
-
['10px', '240px'],
|
|
488
|
-
['0', '240px'],
|
|
489
|
-
['0rem', '240px'],
|
|
490
|
-
['', '240px'],
|
|
491
|
-
['60rem', 'max(60rem, 240px)'],
|
|
492
|
-
['50%', 'max(50%, 240px)'],
|
|
493
|
-
['calc(100% - 2rem)', 'max(calc(100% - 2rem), 240px)'],
|
|
494
|
-
['var(--table-min)', 'max(var(--table-min), 240px)'],
|
|
495
|
-
['auto', '240px'],
|
|
496
|
-
['max-content', '240px'],
|
|
497
|
-
['min-content', '240px'],
|
|
498
|
-
['fit-content', '240px'],
|
|
499
|
-
['inherit', '240px'],
|
|
500
|
-
['12', '240px'],
|
|
501
|
-
] as const)(
|
|
502
|
-
'resolves a consumer minWidth of %j beside a 240px floor to %s',
|
|
503
|
-
(consumer, expected) => {
|
|
504
|
-
expect(resolveTableMinWidth(consumer, 240)).toBe(expected);
|
|
505
|
-
},
|
|
506
|
-
);
|
|
507
|
-
|
|
508
|
-
it('raises a smaller consumer style.minWidth to the column floors', () => {
|
|
509
|
-
const plain: TableColumn<User>[] = [{key: 'name'}, {key: 'age'}];
|
|
510
|
-
render(<Table data={users} columns={plain} style={{minWidth: '10px'}} />);
|
|
511
|
-
expect(screen.getByRole('table').style.minWidth).toBe(
|
|
512
|
-
`${DEFAULT_FLEXIBLE_COLUMN_MIN_WIDTH * 2}px`,
|
|
513
|
-
);
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
it('keeps the canonical theme class alongside a consumer className', () => {
|
|
517
|
-
render(<Table data={users} columns={columns} className="custom-table" />);
|
|
518
|
-
const table = screen.getByRole('table');
|
|
519
|
-
expect(table.className).toContain('astryx-table');
|
|
520
|
-
expect(table.className).not.toContain('astryx-base-table');
|
|
521
|
-
expect(table.className).toContain('custom-table');
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
it('passes event handlers through to the table element', async () => {
|
|
525
|
-
const onClick = vi.fn();
|
|
526
|
-
render(<Table data={users} columns={columns} onClick={onClick} />);
|
|
527
|
-
screen
|
|
528
|
-
.getByRole('table')
|
|
529
|
-
.dispatchEvent(new MouseEvent('click', {bubbles: true}));
|
|
530
|
-
expect(onClick).toHaveBeenCalledTimes(1);
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
it('applies dynamic xstyle values to the table element', () => {
|
|
534
|
-
const dynamic = stylex.create({
|
|
535
|
-
opacity: (value: number) => ({opacity: value}),
|
|
536
|
-
});
|
|
537
|
-
render(
|
|
538
|
-
<Table data={users} columns={columns} xstyle={dynamic.opacity(0.42)} />,
|
|
539
|
-
);
|
|
540
|
-
expect(screen.getByRole('table').getAttribute('style')).toContain('0.42');
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
it('honors className in children mode', () => {
|
|
544
|
-
render(
|
|
545
|
-
<Table className="custom-table">
|
|
546
|
-
<tbody>
|
|
547
|
-
<TableRow>
|
|
548
|
-
<TableCell>Cell</TableCell>
|
|
549
|
-
</TableRow>
|
|
550
|
-
</tbody>
|
|
551
|
-
</Table>,
|
|
552
|
-
);
|
|
553
|
-
expect(screen.getByRole('table').className).toContain('custom-table');
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
it('honors className on an unwrapped BaseTable (no scrollWrapper)', () => {
|
|
557
|
-
render(
|
|
558
|
-
<BaseTable data={users} columns={columns} className="custom-table" />,
|
|
559
|
-
);
|
|
560
|
-
expect(screen.getByRole('table').className).toContain('custom-table');
|
|
561
|
-
});
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
describe('TableRow styling props', () => {
|
|
565
|
-
it('applies className and style to the row inside a Table', () => {
|
|
566
|
-
render(
|
|
567
|
-
<Table>
|
|
568
|
-
<tbody>
|
|
569
|
-
<TableRow className="custom-row" style={{opacity: 0.9}}>
|
|
570
|
-
<TableCell>Cell</TableCell>
|
|
571
|
-
</TableRow>
|
|
572
|
-
</tbody>
|
|
573
|
-
</Table>,
|
|
574
|
-
);
|
|
575
|
-
const row = screen.getByRole('row');
|
|
576
|
-
expect(row.className).toContain('custom-row');
|
|
577
|
-
expect(row.className).toContain('astryx-table-row');
|
|
578
|
-
expect(row.style.opacity).toBe('0.9');
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
it('applies className to a standalone row (no table context)', () => {
|
|
582
|
-
render(
|
|
583
|
-
<table>
|
|
584
|
-
<tbody>
|
|
585
|
-
<TableRow className="custom-row">
|
|
586
|
-
<td>Cell</td>
|
|
587
|
-
</TableRow>
|
|
588
|
-
</tbody>
|
|
589
|
-
</table>,
|
|
590
|
-
);
|
|
591
|
-
expect(screen.getByRole('row').className).toContain('custom-row');
|
|
592
|
-
});
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
describe('plugin pipeline', () => {
|
|
596
|
-
it('applies transformTable plugin', () => {
|
|
597
|
-
const plugin: TablePlugin<User> = {
|
|
598
|
-
transformTable: props => ({
|
|
599
|
-
...props,
|
|
600
|
-
htmlProps: {...props.htmlProps, 'data-testid': 'plugin-table'},
|
|
601
|
-
}),
|
|
602
|
-
};
|
|
603
|
-
render(<BaseTable data={users} columns={columns} plugins={[plugin]} />);
|
|
604
|
-
expect(screen.getByTestId('plugin-table')).toBeInTheDocument();
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
it('applies transformHeaderRow plugin', () => {
|
|
608
|
-
const plugin: TablePlugin<User> = {
|
|
609
|
-
transformHeaderRow: props => ({
|
|
610
|
-
...props,
|
|
611
|
-
htmlProps: {...props.htmlProps, 'data-testid': 'plugin-header-row'},
|
|
612
|
-
}),
|
|
613
|
-
};
|
|
614
|
-
render(<BaseTable data={users} columns={columns} plugins={[plugin]} />);
|
|
615
|
-
expect(screen.getByTestId('plugin-header-row')).toBeInTheDocument();
|
|
616
|
-
});
|
|
617
|
-
|
|
618
|
-
it('applies transformHeaderCell plugin with column context', () => {
|
|
619
|
-
const receivedKeys: string[] = [];
|
|
620
|
-
const plugin: TablePlugin<User> = {
|
|
621
|
-
transformHeaderCell: (props, column) => {
|
|
622
|
-
receivedKeys.push(column.key);
|
|
623
|
-
return {
|
|
624
|
-
...props,
|
|
625
|
-
htmlProps: {...props.htmlProps, 'data-column': column.key},
|
|
626
|
-
};
|
|
627
|
-
},
|
|
628
|
-
};
|
|
629
|
-
render(<BaseTable data={users} columns={columns} plugins={[plugin]} />);
|
|
630
|
-
expect(receivedKeys).toEqual(['name', 'age', 'email']);
|
|
631
|
-
const headers = screen.getAllByRole('columnheader');
|
|
632
|
-
expect(headers[0]).toHaveAttribute('data-column', 'name');
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
it('applies transformBodyRow plugin with item and index', () => {
|
|
636
|
-
const receivedItems: string[] = [];
|
|
637
|
-
const plugin: TablePlugin<User> = {
|
|
638
|
-
transformBodyRow: (props, item, index) => {
|
|
639
|
-
receivedItems.push(item.name);
|
|
640
|
-
return {
|
|
641
|
-
...props,
|
|
642
|
-
htmlProps: {...props.htmlProps, 'data-row-index': String(index)},
|
|
643
|
-
};
|
|
644
|
-
},
|
|
645
|
-
};
|
|
646
|
-
render(<BaseTable data={users} columns={columns} plugins={[plugin]} />);
|
|
647
|
-
expect(receivedItems).toEqual(['Alice', 'Bob', 'Charlie']);
|
|
648
|
-
});
|
|
649
|
-
|
|
650
|
-
it('applies transformBodyCell plugin with column and item context', () => {
|
|
651
|
-
const calls: {col: string; name: string}[] = [];
|
|
652
|
-
const plugin: TablePlugin<User> = {
|
|
653
|
-
transformBodyCell: (props, column, item) => {
|
|
654
|
-
calls.push({col: column.key, name: item.name});
|
|
655
|
-
return props;
|
|
656
|
-
},
|
|
657
|
-
};
|
|
658
|
-
render(<BaseTable data={users} columns={columns} plugins={[plugin]} />);
|
|
659
|
-
// 3 rows * 3 columns = 9 calls
|
|
660
|
-
expect(calls).toHaveLength(9);
|
|
661
|
-
expect(calls[0]).toEqual({col: 'name', name: 'Alice'});
|
|
662
|
-
});
|
|
663
|
-
|
|
664
|
-
it('isContentSuppressed renders an empty cell and never calls the column renderer', () => {
|
|
665
|
-
const rendered: string[] = [];
|
|
666
|
-
const withRenderer: TableColumn<User>[] = [
|
|
667
|
-
{
|
|
668
|
-
key: 'name',
|
|
669
|
-
header: 'Name',
|
|
670
|
-
renderCell: item => {
|
|
671
|
-
rendered.push(item.name);
|
|
672
|
-
return <b>{item.name}</b>;
|
|
673
|
-
},
|
|
674
|
-
},
|
|
675
|
-
];
|
|
676
|
-
const plugin: TablePlugin<User> = {
|
|
677
|
-
transformBodyCell: (props, _column, item) =>
|
|
678
|
-
item.name === 'Bob' ? {...props, isContentSuppressed: true} : props,
|
|
679
|
-
};
|
|
680
|
-
render(
|
|
681
|
-
<BaseTable data={users} columns={withRenderer} plugins={[plugin]} />,
|
|
682
|
-
);
|
|
683
|
-
expect(rendered).toEqual(['Alice', 'Charlie']);
|
|
684
|
-
const cells = screen.getAllByRole('cell');
|
|
685
|
-
expect(cells[1]).toBeEmptyDOMElement();
|
|
686
|
-
expect(cells[0]).toHaveTextContent('Alice');
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
it('isContentSuppressed also suppresses the default renderer', () => {
|
|
690
|
-
const plugin: TablePlugin<User> = {
|
|
691
|
-
transformBodyCell: props => ({...props, isContentSuppressed: true}),
|
|
692
|
-
};
|
|
693
|
-
render(<BaseTable data={users} columns={columns} plugins={[plugin]} />);
|
|
694
|
-
for (const cell of screen.getAllByRole('cell')) {
|
|
695
|
-
expect(cell).toBeEmptyDOMElement();
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
|
|
699
|
-
it('composes multiple plugins sequentially', () => {
|
|
700
|
-
const plugin1: TablePlugin<User> = {
|
|
701
|
-
transformTable: props => ({
|
|
702
|
-
...props,
|
|
703
|
-
htmlProps: {...props.htmlProps, 'data-first': 'yes'},
|
|
704
|
-
}),
|
|
705
|
-
};
|
|
706
|
-
const plugin2: TablePlugin<User> = {
|
|
707
|
-
transformTable: props => ({
|
|
708
|
-
...props,
|
|
709
|
-
htmlProps: {...props.htmlProps, 'data-second': 'yes'},
|
|
710
|
-
}),
|
|
711
|
-
};
|
|
712
|
-
render(
|
|
713
|
-
<BaseTable
|
|
714
|
-
data={users}
|
|
715
|
-
columns={columns}
|
|
716
|
-
plugins={[plugin1, plugin2]}
|
|
717
|
-
/>,
|
|
718
|
-
);
|
|
719
|
-
const table = screen.getByRole('table');
|
|
720
|
-
expect(table).toHaveAttribute('data-first', 'yes');
|
|
721
|
-
expect(table).toHaveAttribute('data-second', 'yes');
|
|
722
|
-
});
|
|
723
|
-
|
|
724
|
-
it('later plugin can read props set by earlier plugin', () => {
|
|
725
|
-
const plugin1: TablePlugin<User> = {
|
|
726
|
-
transformTable: props => ({
|
|
727
|
-
...props,
|
|
728
|
-
htmlProps: {...props.htmlProps, 'data-step': '1'},
|
|
729
|
-
}),
|
|
730
|
-
};
|
|
731
|
-
const plugin2: TablePlugin<User> = {
|
|
732
|
-
transformTable: props => {
|
|
733
|
-
const step = (props.htmlProps as Record<string, string>)['data-step'];
|
|
734
|
-
return {
|
|
735
|
-
...props,
|
|
736
|
-
htmlProps: {...props.htmlProps, 'data-step': step + ',2'},
|
|
737
|
-
};
|
|
738
|
-
},
|
|
739
|
-
};
|
|
740
|
-
render(
|
|
741
|
-
<BaseTable
|
|
742
|
-
data={users}
|
|
743
|
-
columns={columns}
|
|
744
|
-
plugins={[plugin1, plugin2]}
|
|
745
|
-
/>,
|
|
746
|
-
);
|
|
747
|
-
expect(screen.getByRole('table')).toHaveAttribute('data-step', '1,2');
|
|
748
|
-
});
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
describe('column min-widths', () => {
|
|
752
|
-
it('applies default minWidth on header cells for proportional columns', () => {
|
|
753
|
-
const cols: TableColumn<User>[] = [
|
|
754
|
-
{key: 'name', header: 'Name', width: proportional(1)},
|
|
755
|
-
{key: 'age', header: 'Age', width: proportional(1)},
|
|
756
|
-
];
|
|
757
|
-
render(<BaseTable data={users} columns={cols} />);
|
|
758
|
-
const headers = screen.getAllByRole('columnheader');
|
|
759
|
-
expect(headers[0]).toHaveStyle({
|
|
760
|
-
minWidth: `${DEFAULT_MIN_COLUMN_WIDTH}px`,
|
|
761
|
-
});
|
|
762
|
-
expect(headers[1]).toHaveStyle({
|
|
763
|
-
minWidth: `${DEFAULT_MIN_COLUMN_WIDTH}px`,
|
|
764
|
-
});
|
|
765
|
-
});
|
|
766
|
-
|
|
767
|
-
it('applies explicit minWidth on proportional columns', () => {
|
|
768
|
-
const cols: TableColumn<User>[] = [
|
|
769
|
-
{key: 'name', header: 'Name', width: proportional(1, {minWidth: 200})},
|
|
770
|
-
{key: 'age', header: 'Age', width: proportional(1)},
|
|
771
|
-
];
|
|
772
|
-
render(<BaseTable data={users} columns={cols} />);
|
|
773
|
-
const headers = screen.getAllByRole('columnheader');
|
|
774
|
-
expect(headers[0]).toHaveStyle({minWidth: '200px'});
|
|
775
|
-
expect(headers[1]).toHaveStyle({
|
|
776
|
-
minWidth: `${DEFAULT_MIN_COLUMN_WIDTH}px`,
|
|
777
|
-
});
|
|
778
|
-
});
|
|
779
|
-
|
|
780
|
-
it('sets minWidth on pixel columns to prevent shrinking', () => {
|
|
781
|
-
const cols: TableColumn<User>[] = [
|
|
782
|
-
{key: 'name', header: 'Name', width: pixel(80)},
|
|
783
|
-
{key: 'age', header: 'Age', width: proportional(1)},
|
|
784
|
-
];
|
|
785
|
-
render(<BaseTable data={users} columns={cols} />);
|
|
786
|
-
const headers = screen.getAllByRole('columnheader');
|
|
787
|
-
expect(headers[0]).toHaveStyle({width: '80px', minWidth: '80px'});
|
|
788
|
-
expect(headers[1]).toHaveStyle({
|
|
789
|
-
minWidth: `${DEFAULT_MIN_COLUMN_WIDTH}px`,
|
|
790
|
-
});
|
|
791
|
-
});
|
|
792
|
-
|
|
793
|
-
it('applies content-derived minWidth on auto-generated columns', () => {
|
|
794
|
-
render(<BaseTable data={users} />);
|
|
795
|
-
const headers = screen.getAllByRole('columnheader');
|
|
796
|
-
for (const header of headers) {
|
|
797
|
-
// Each column should have a minWidth derived from content (at least 60px floor)
|
|
798
|
-
const style = header.getAttribute('style') ?? '';
|
|
799
|
-
expect(style).toContain('min-width');
|
|
800
|
-
}
|
|
801
|
-
});
|
|
802
|
-
|
|
803
|
-
it('keeps width-less columns flexible with a compact readability floor', () => {
|
|
804
|
-
const cols: TableColumn<User>[] = [
|
|
805
|
-
{key: 'name', header: 'Name'},
|
|
806
|
-
{key: 'age', header: 'Age'},
|
|
807
|
-
];
|
|
808
|
-
render(<BaseTable data={users} columns={cols} />);
|
|
809
|
-
const headers = screen.getAllByRole('columnheader');
|
|
810
|
-
expect(headers[0]).toHaveStyle({
|
|
811
|
-
width: '50%',
|
|
812
|
-
minWidth: `${DEFAULT_FLEXIBLE_COLUMN_MIN_WIDTH}px`,
|
|
813
|
-
});
|
|
814
|
-
expect(headers[1]).toHaveStyle({
|
|
815
|
-
width: '50%',
|
|
816
|
-
minWidth: `${DEFAULT_FLEXIBLE_COLUMN_MIN_WIDTH}px`,
|
|
817
|
-
});
|
|
818
|
-
expect(screen.getByRole('table')).toHaveStyle({
|
|
819
|
-
minWidth: `${DEFAULT_FLEXIBLE_COLUMN_MIN_WIDTH * 2}px`,
|
|
820
|
-
});
|
|
821
|
-
});
|
|
822
|
-
|
|
823
|
-
it('lets one column set its own floor with proportional minWidth', () => {
|
|
824
|
-
const cols: TableColumn<User>[] = [
|
|
825
|
-
{key: 'name', header: 'Name', width: proportional(1, {minWidth: 96})},
|
|
826
|
-
{key: 'age', header: 'Age', width: proportional(1, {minWidth: 40})},
|
|
827
|
-
{key: 'email', header: 'Email'},
|
|
828
|
-
];
|
|
829
|
-
render(<BaseTable data={users} columns={cols} />);
|
|
830
|
-
const headers = screen.getAllByRole('columnheader');
|
|
831
|
-
// A larger and a smaller authored floor both replace the 60px default
|
|
832
|
-
// for their own column; the width-less column keeps the compact floor.
|
|
833
|
-
expect(headers[0]).toHaveStyle({minWidth: '96px'});
|
|
834
|
-
expect(headers[1]).toHaveStyle({minWidth: '40px'});
|
|
835
|
-
expect(headers[2]).toHaveStyle({
|
|
836
|
-
minWidth: `${DEFAULT_FLEXIBLE_COLUMN_MIN_WIDTH}px`,
|
|
837
|
-
});
|
|
838
|
-
expect(screen.getByRole('table')).toHaveStyle({
|
|
839
|
-
minWidth: `${Math.max(96, 40, DEFAULT_FLEXIBLE_COLUMN_MIN_WIDTH) * 3}px`,
|
|
840
|
-
});
|
|
841
|
-
});
|
|
842
|
-
|
|
843
|
-
it('keeps the width-less floor stable when row content changes', () => {
|
|
844
|
-
const cols: TableColumn<User>[] = [
|
|
845
|
-
{key: 'name', header: 'Name'},
|
|
846
|
-
{key: 'age', header: 'Age'},
|
|
847
|
-
];
|
|
848
|
-
const {rerender} = render(<BaseTable data={[]} columns={cols} />);
|
|
849
|
-
const table = screen.getByRole('table');
|
|
850
|
-
expect(table).toHaveStyle({
|
|
851
|
-
minWidth: `${DEFAULT_FLEXIBLE_COLUMN_MIN_WIDTH * 2}px`,
|
|
852
|
-
});
|
|
853
|
-
|
|
854
|
-
rerender(
|
|
855
|
-
<BaseTable
|
|
856
|
-
data={[
|
|
857
|
-
{
|
|
858
|
-
...users[0],
|
|
859
|
-
name: 'one-unbreakable-token-that-must-not-change-column-sizing',
|
|
860
|
-
},
|
|
861
|
-
]}
|
|
862
|
-
columns={cols}
|
|
863
|
-
/>,
|
|
864
|
-
);
|
|
865
|
-
expect(table).toHaveStyle({
|
|
866
|
-
minWidth: `${DEFAULT_FLEXIBLE_COLUMN_MIN_WIDTH * 2}px`,
|
|
867
|
-
});
|
|
868
|
-
});
|
|
869
|
-
|
|
870
|
-
it('sets table min-width to enforce proportional column minimums', () => {
|
|
871
|
-
const cols: TableColumn<User>[] = [
|
|
872
|
-
{key: 'name', header: 'Name', width: proportional(1)},
|
|
873
|
-
{key: 'age', header: 'Age', width: proportional(1)},
|
|
874
|
-
];
|
|
875
|
-
render(<BaseTable data={users} columns={cols} />);
|
|
876
|
-
const table = screen.getByRole('table');
|
|
877
|
-
// 2 equal columns: 120 * 2 / 1 = 240px
|
|
878
|
-
expect(table).toHaveStyle({
|
|
879
|
-
minWidth: `${DEFAULT_MIN_COLUMN_WIDTH * 2}px`,
|
|
880
|
-
});
|
|
881
|
-
});
|
|
882
|
-
|
|
883
|
-
it('sets table min-width based on most constrained proportional column', () => {
|
|
884
|
-
const cols: TableColumn<User>[] = [
|
|
885
|
-
{key: 'name', header: 'Name', width: proportional(1, {minWidth: 200})},
|
|
886
|
-
{key: 'age', header: 'Age', width: proportional(1)},
|
|
887
|
-
];
|
|
888
|
-
render(<BaseTable data={users} columns={cols} />);
|
|
889
|
-
const table = screen.getByRole('table');
|
|
890
|
-
// name requires: 200 * 2 / 1 = 400px (most constrained)
|
|
891
|
-
// age requires: 120 * 2 / 1 = 240px
|
|
892
|
-
expect(table).toHaveStyle({minWidth: '400px'});
|
|
893
|
-
});
|
|
894
|
-
|
|
895
|
-
it('sets table min-width accounting for pixel and proportional columns', () => {
|
|
896
|
-
const cols: TableColumn<User>[] = [
|
|
897
|
-
{key: 'name', header: 'Name', width: pixel(80)},
|
|
898
|
-
{key: 'age', header: 'Age', width: proportional(1)},
|
|
899
|
-
];
|
|
900
|
-
render(<BaseTable data={users} columns={cols} />);
|
|
901
|
-
const table = screen.getByRole('table');
|
|
902
|
-
// pixel: 80px + proportional requires 120 * 1 / 1 = 120px
|
|
903
|
-
// Table min-width = 80 + 120 = 200px
|
|
904
|
-
expect(table).toHaveStyle({
|
|
905
|
-
minWidth: `${80 + DEFAULT_MIN_COLUMN_WIDTH}px`,
|
|
906
|
-
});
|
|
907
|
-
});
|
|
908
|
-
});
|
|
909
|
-
});
|
|
910
|
-
|
|
911
|
-
// =============================================================================
|
|
912
|
-
// Table Tests
|
|
913
|
-
// =============================================================================
|
|
914
|
-
|
|
915
|
-
describe('Table', () => {
|
|
916
|
-
it('clears a cell when the field is removed from the row object (#3595)', () => {
|
|
917
|
-
const cols: TableColumn<Record<string, unknown>>[] = [
|
|
918
|
-
{key: 'name', header: 'Name'},
|
|
919
|
-
{key: 'status', header: 'Status'},
|
|
920
|
-
];
|
|
921
|
-
const {rerender} = render(
|
|
922
|
-
<Table
|
|
923
|
-
data={[{id: '1', name: 'Alice', status: 'active'}]}
|
|
924
|
-
columns={cols}
|
|
925
|
-
idKey="id"
|
|
926
|
-
/>,
|
|
927
|
-
);
|
|
928
|
-
expect(screen.getByText('active')).toBeInTheDocument();
|
|
929
|
-
|
|
930
|
-
// Clearing a field by omitting it (optimistic update / server response)
|
|
931
|
-
// must re-render the row — the memo previously only compared the keys of
|
|
932
|
-
// the NEW item, so the deleted field's stale value kept rendering.
|
|
933
|
-
rerender(
|
|
934
|
-
<Table data={[{id: '1', name: 'Alice'}]} columns={cols} idKey="id" />,
|
|
935
|
-
);
|
|
936
|
-
expect(screen.queryByText('active')).not.toBeInTheDocument();
|
|
937
|
-
});
|
|
938
|
-
|
|
939
|
-
it('renders a table with correct structure', () => {
|
|
940
|
-
render(<Table data={users} columns={columns} />);
|
|
941
|
-
expect(screen.getByRole('table')).toBeInTheDocument();
|
|
942
|
-
expect(screen.getAllByRole('columnheader')).toHaveLength(3);
|
|
943
|
-
expect(screen.getAllByRole('cell')).toHaveLength(9);
|
|
944
|
-
expect(screen.getAllByRole('row')).toHaveLength(4);
|
|
945
|
-
});
|
|
946
|
-
|
|
947
|
-
it('wraps the table in an observed scroll content box', () => {
|
|
948
|
-
render(<Table data={users} columns={columns} />);
|
|
949
|
-
const table = screen.getByRole('table');
|
|
950
|
-
const content = table.parentElement;
|
|
951
|
-
const wrapper = content?.parentElement;
|
|
952
|
-
expect(content).toHaveAttribute('data-scroll-content');
|
|
953
|
-
expect(wrapper).toBeTruthy();
|
|
954
|
-
expect(wrapper!.className).toContain('astryx-table-scroll-wrapper');
|
|
955
|
-
});
|
|
956
|
-
|
|
957
|
-
it('keeps a fitting scroll container out of the keyboard order', () => {
|
|
958
|
-
render(<Table data={users} columns={columns} />);
|
|
959
|
-
const wrapper = screen.getByRole('group', {name: 'Table'});
|
|
960
|
-
expect(wrapper).not.toHaveAttribute('tabindex');
|
|
961
|
-
expect(wrapper.style.overscrollBehaviorX).toBe('auto');
|
|
962
|
-
});
|
|
963
|
-
|
|
964
|
-
it('names the scroll region after its table, not a generic "Table" (AST-025)', () => {
|
|
965
|
-
render(
|
|
966
|
-
<>
|
|
967
|
-
<Table aria-label="Orders" data={users} columns={columns} />
|
|
968
|
-
<h2 id="refunds-title">Refunds</h2>
|
|
969
|
-
<Table aria-labelledby="refunds-title" data={users} columns={columns} />
|
|
970
|
-
<h2 id="returns-title">Returns</h2>
|
|
971
|
-
<Table
|
|
972
|
-
aria-label="Ignored label"
|
|
973
|
-
aria-labelledby="returns-title"
|
|
974
|
-
data={users}
|
|
975
|
-
columns={columns}
|
|
976
|
-
/>
|
|
977
|
-
<Table data={users} columns={columns} />
|
|
978
|
-
</>,
|
|
979
|
-
);
|
|
980
|
-
expect(screen.getByRole('group', {name: 'Orders'})).toBeInTheDocument();
|
|
981
|
-
expect(screen.getByRole('group', {name: 'Refunds'})).toHaveAttribute(
|
|
982
|
-
'aria-labelledby',
|
|
983
|
-
'refunds-title',
|
|
984
|
-
);
|
|
985
|
-
// With both, the region is named as the table is: by aria-labelledby.
|
|
986
|
-
expect(screen.getByRole('table', {name: 'Returns'})).toBeInTheDocument();
|
|
987
|
-
const returns = screen.getByRole('group', {name: 'Returns'});
|
|
988
|
-
expect(returns).not.toHaveAttribute('aria-label');
|
|
989
|
-
expect(
|
|
990
|
-
screen.queryByRole('group', {name: 'Ignored label'}),
|
|
991
|
-
).not.toBeInTheDocument();
|
|
992
|
-
// An unnamed table keeps the generic fallback.
|
|
993
|
-
expect(screen.getAllByRole('group', {name: 'Table'})).toHaveLength(1);
|
|
994
|
-
});
|
|
995
|
-
|
|
996
|
-
it('preserves scroll-wrapper HTML attributes from plugins', () => {
|
|
997
|
-
const plugin: TablePlugin<User> = {
|
|
998
|
-
transformScrollWrapper: props => ({
|
|
999
|
-
...props,
|
|
1000
|
-
htmlProps: {
|
|
1001
|
-
...props.htmlProps,
|
|
1002
|
-
role: 'region',
|
|
1003
|
-
'aria-label': 'Orders',
|
|
1004
|
-
tabIndex: 2,
|
|
1005
|
-
},
|
|
1006
|
-
}),
|
|
1007
|
-
};
|
|
1008
|
-
render(<Table data={users} columns={columns} plugins={{custom: plugin}} />);
|
|
1009
|
-
const wrapper = screen.getByRole('region', {name: 'Orders'});
|
|
1010
|
-
expect(wrapper).toHaveAttribute('tabindex', '2');
|
|
1011
|
-
});
|
|
1012
|
-
|
|
1013
|
-
it('contains overscroll only while the table scrolls', () => {
|
|
1014
|
-
const frames: FrameRequestCallback[] = [];
|
|
1015
|
-
vi.stubGlobal(
|
|
1016
|
-
'requestAnimationFrame',
|
|
1017
|
-
vi.fn((callback: FrameRequestCallback) => {
|
|
1018
|
-
frames.push(callback);
|
|
1019
|
-
return frames.length;
|
|
1020
|
-
}),
|
|
1021
|
-
);
|
|
1022
|
-
vi.stubGlobal('cancelAnimationFrame', vi.fn());
|
|
1023
|
-
|
|
1024
|
-
try {
|
|
1025
|
-
render(<Table data={users} columns={columns} />);
|
|
1026
|
-
const wrapper = screen.getByRole('group', {name: 'Table'});
|
|
1027
|
-
Object.assign(wrapper.style, {overflowX: 'auto'});
|
|
1028
|
-
for (const [key, value] of Object.entries({
|
|
1029
|
-
clientWidth: 100,
|
|
1030
|
-
clientHeight: 100,
|
|
1031
|
-
scrollWidth: 180,
|
|
1032
|
-
scrollHeight: 100,
|
|
1033
|
-
scrollLeft: 0,
|
|
1034
|
-
scrollTop: 0,
|
|
1035
|
-
})) {
|
|
1036
|
-
Object.defineProperty(wrapper, key, {
|
|
1037
|
-
configurable: true,
|
|
1038
|
-
value,
|
|
1039
|
-
writable: true,
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
act(() => {
|
|
1044
|
-
wrapper.dispatchEvent(new Event('scroll'));
|
|
1045
|
-
frames.splice(0).forEach(callback => callback(performance.now()));
|
|
1046
|
-
});
|
|
1047
|
-
|
|
1048
|
-
expect(wrapper).toHaveAttribute('tabindex', '0');
|
|
1049
|
-
expect(wrapper).toHaveAttribute('data-scrollable-inline', 'true');
|
|
1050
|
-
expect(wrapper.style.overscrollBehaviorX).toBe('contain');
|
|
1051
|
-
|
|
1052
|
-
Object.defineProperty(wrapper, 'scrollWidth', {
|
|
1053
|
-
configurable: true,
|
|
1054
|
-
value: 100,
|
|
1055
|
-
writable: true,
|
|
1056
|
-
});
|
|
1057
|
-
act(() => {
|
|
1058
|
-
wrapper.dispatchEvent(new Event('scroll'));
|
|
1059
|
-
frames.splice(0).forEach(callback => callback(performance.now()));
|
|
1060
|
-
});
|
|
1061
|
-
|
|
1062
|
-
expect(wrapper).not.toHaveAttribute('tabindex');
|
|
1063
|
-
expect(wrapper).not.toHaveAttribute('data-scrollable-inline');
|
|
1064
|
-
expect(wrapper.style.overscrollBehaviorX).toBe('auto');
|
|
1065
|
-
} finally {
|
|
1066
|
-
vi.unstubAllGlobals();
|
|
1067
|
-
}
|
|
1068
|
-
});
|
|
1069
|
-
|
|
1070
|
-
it('uses table-layout: auto in children mode', () => {
|
|
1071
|
-
const {container} = render(
|
|
1072
|
-
<Table dividers="rows">
|
|
1073
|
-
<tbody>
|
|
1074
|
-
<tr>
|
|
1075
|
-
<td>Content</td>
|
|
1076
|
-
</tr>
|
|
1077
|
-
</tbody>
|
|
1078
|
-
</Table>,
|
|
1079
|
-
);
|
|
1080
|
-
const table = container.querySelector('table');
|
|
1081
|
-
expect(table).toHaveStyle({tableLayout: 'auto'});
|
|
1082
|
-
});
|
|
1083
|
-
|
|
1084
|
-
it('uses table-layout: fixed in data-driven mode', () => {
|
|
1085
|
-
const {container} = render(<Table data={users} columns={columns} />);
|
|
1086
|
-
const table = container.querySelector('table');
|
|
1087
|
-
expect(table).toHaveStyle({tableLayout: 'fixed'});
|
|
1088
|
-
});
|
|
1089
|
-
|
|
1090
|
-
it('renders all data values', () => {
|
|
1091
|
-
render(<Table data={users} columns={columns} />);
|
|
1092
|
-
expect(screen.getByText('Alice')).toBeInTheDocument();
|
|
1093
|
-
expect(screen.getByText('Bob')).toBeInTheDocument();
|
|
1094
|
-
expect(screen.getByText('Charlie')).toBeInTheDocument();
|
|
1095
|
-
expect(screen.getByText('30')).toBeInTheDocument();
|
|
1096
|
-
expect(screen.getByText('alice@example.com')).toBeInTheDocument();
|
|
1097
|
-
});
|
|
1098
|
-
|
|
1099
|
-
it('auto-generates columns from data', () => {
|
|
1100
|
-
render(<Table data={users} />);
|
|
1101
|
-
const headers = screen.getAllByRole('columnheader');
|
|
1102
|
-
expect(headers).toHaveLength(3);
|
|
1103
|
-
expect(headers[0]).toHaveTextContent('Name');
|
|
1104
|
-
expect(screen.getByText('Alice')).toBeInTheDocument();
|
|
1105
|
-
});
|
|
1106
|
-
|
|
1107
|
-
it('forwards ref to the table element', () => {
|
|
1108
|
-
const ref = vi.fn();
|
|
1109
|
-
render(<Table data={users} columns={columns} ref={ref} />);
|
|
1110
|
-
expect(ref).toHaveBeenCalledWith(expect.any(HTMLTableElement));
|
|
1111
|
-
});
|
|
1112
|
-
|
|
1113
|
-
describe('density', () => {
|
|
1114
|
-
it('renders with compact density', () => {
|
|
1115
|
-
render(<Table data={users} columns={columns} density="compact" />);
|
|
1116
|
-
expect(screen.getAllByRole('row')).toHaveLength(4);
|
|
1117
|
-
});
|
|
1118
|
-
|
|
1119
|
-
it('renders with balanced density (default)', () => {
|
|
1120
|
-
render(<Table data={users} columns={columns} />);
|
|
1121
|
-
expect(screen.getAllByRole('row')).toHaveLength(4);
|
|
1122
|
-
});
|
|
1123
|
-
|
|
1124
|
-
it('renders with spacious density', () => {
|
|
1125
|
-
render(<Table data={users} columns={columns} density="spacious" />);
|
|
1126
|
-
expect(screen.getAllByRole('row')).toHaveLength(4);
|
|
1127
|
-
});
|
|
1128
|
-
|
|
1129
|
-
it('reflects density as data-density on cells and header cells (theme hook)', () => {
|
|
1130
|
-
// The density lives in internal StyleX classes, so cells expose it as a
|
|
1131
|
-
// data-density attribute on the stable astryx-table-cell /
|
|
1132
|
-
// astryx-table-header-cell targets. This lets a theme override padding
|
|
1133
|
-
// per density (e.g. hold the inline inset while varying the block) via
|
|
1134
|
-
// `defineTheme` — the padding split is otherwise unreachable.
|
|
1135
|
-
const {rerender} = render(
|
|
1136
|
-
<Table data={users} columns={columns} density="spacious" />,
|
|
1137
|
-
);
|
|
1138
|
-
const cell = screen.getAllByRole('cell')[0];
|
|
1139
|
-
const header = screen.getAllByRole('columnheader')[0];
|
|
1140
|
-
expect(cell.className).toContain('astryx-table-cell');
|
|
1141
|
-
expect(cell).toHaveAttribute('data-density', 'spacious');
|
|
1142
|
-
expect(header.className).toContain('astryx-table-header-cell');
|
|
1143
|
-
expect(header).toHaveAttribute('data-density', 'spacious');
|
|
1144
|
-
|
|
1145
|
-
rerender(<Table data={users} columns={columns} density="compact" />);
|
|
1146
|
-
expect(screen.getAllByRole('cell')[0]).toHaveAttribute(
|
|
1147
|
-
'data-density',
|
|
1148
|
-
'compact',
|
|
1149
|
-
);
|
|
1150
|
-
expect(screen.getAllByRole('columnheader')[0]).toHaveAttribute(
|
|
1151
|
-
'data-density',
|
|
1152
|
-
'compact',
|
|
1153
|
-
);
|
|
1154
|
-
});
|
|
1155
|
-
});
|
|
1156
|
-
|
|
1157
|
-
describe('dividers', () => {
|
|
1158
|
-
it('renders with row dividers (default)', () => {
|
|
1159
|
-
render(<Table data={users} columns={columns} />);
|
|
1160
|
-
expect(screen.getByRole('table')).toBeInTheDocument();
|
|
1161
|
-
});
|
|
1162
|
-
|
|
1163
|
-
it('renders with column dividers', () => {
|
|
1164
|
-
render(<Table data={users} columns={columns} dividers="columns" />);
|
|
1165
|
-
expect(screen.getByRole('table')).toBeInTheDocument();
|
|
1166
|
-
});
|
|
1167
|
-
|
|
1168
|
-
it('renders with grid dividers', () => {
|
|
1169
|
-
render(<Table data={users} columns={columns} dividers="grid" />);
|
|
1170
|
-
expect(screen.getByRole('table')).toBeInTheDocument();
|
|
1171
|
-
});
|
|
1172
|
-
|
|
1173
|
-
it('renders with no dividers', () => {
|
|
1174
|
-
render(<Table data={users} columns={columns} dividers="none" />);
|
|
1175
|
-
expect(screen.getByRole('table')).toBeInTheDocument();
|
|
1176
|
-
});
|
|
1177
|
-
});
|
|
1178
|
-
|
|
1179
|
-
describe('striped', () => {
|
|
1180
|
-
it('renders with isStriped rows', () => {
|
|
1181
|
-
render(<Table data={users} columns={columns} isStriped />);
|
|
1182
|
-
expect(screen.getAllByRole('row')).toHaveLength(4);
|
|
1183
|
-
});
|
|
1184
|
-
});
|
|
1185
|
-
|
|
1186
|
-
describe('hover', () => {
|
|
1187
|
-
it('renders with hasHover enabled', () => {
|
|
1188
|
-
render(<Table data={users} columns={columns} hasHover />);
|
|
1189
|
-
expect(screen.getAllByRole('row')).toHaveLength(4);
|
|
1190
|
-
});
|
|
1191
|
-
});
|
|
1192
|
-
|
|
1193
|
-
it('renders with all appearance props combined', () => {
|
|
1194
|
-
render(
|
|
1195
|
-
<Table
|
|
1196
|
-
data={users}
|
|
1197
|
-
columns={columns}
|
|
1198
|
-
density="compact"
|
|
1199
|
-
dividers="grid"
|
|
1200
|
-
isStriped
|
|
1201
|
-
hasHover
|
|
1202
|
-
/>,
|
|
1203
|
-
);
|
|
1204
|
-
expect(screen.getByRole('table')).toBeInTheDocument();
|
|
1205
|
-
expect(screen.getAllByRole('row')).toHaveLength(4);
|
|
1206
|
-
expect(screen.getAllByRole('cell')).toHaveLength(9);
|
|
1207
|
-
});
|
|
1208
|
-
|
|
1209
|
-
it('accepts user plugins alongside XDS styling', () => {
|
|
1210
|
-
const userPlugin: TablePlugin<User> = {
|
|
1211
|
-
transformTable: props => ({
|
|
1212
|
-
...props,
|
|
1213
|
-
htmlProps: {...props.htmlProps, 'data-testid': 'custom-plugin'},
|
|
1214
|
-
}),
|
|
1215
|
-
};
|
|
1216
|
-
render(
|
|
1217
|
-
<Table data={users} columns={columns} plugins={{custom: userPlugin}} />,
|
|
1218
|
-
);
|
|
1219
|
-
expect(screen.getByTestId('custom-plugin')).toBeInTheDocument();
|
|
1220
|
-
});
|
|
1221
|
-
|
|
1222
|
-
it('runs user plugins after XDS styling plugin', () => {
|
|
1223
|
-
const userPlugin: TablePlugin<User> = {
|
|
1224
|
-
transformTable: props => {
|
|
1225
|
-
// XDS plugin should have already added styles
|
|
1226
|
-
expect(props.xstyle.length).toBeGreaterThan(1);
|
|
1227
|
-
return {
|
|
1228
|
-
...props,
|
|
1229
|
-
htmlProps: {...props.htmlProps, 'data-testid': 'after-xds'},
|
|
1230
|
-
};
|
|
1231
|
-
},
|
|
1232
|
-
};
|
|
1233
|
-
render(
|
|
1234
|
-
<Table data={users} columns={columns} plugins={{custom: userPlugin}} />,
|
|
1235
|
-
);
|
|
1236
|
-
expect(screen.getByTestId('after-xds')).toBeInTheDocument();
|
|
1237
|
-
});
|
|
1238
|
-
|
|
1239
|
-
it('renders children mode with TableRow and TableCell', () => {
|
|
1240
|
-
render(
|
|
1241
|
-
<Table density="balanced" dividers="rows">
|
|
1242
|
-
<TableBody>
|
|
1243
|
-
<TableRow>
|
|
1244
|
-
<TableCell>Streamed A</TableCell>
|
|
1245
|
-
<TableCell>Streamed B</TableCell>
|
|
1246
|
-
</TableRow>
|
|
1247
|
-
<TableRow>
|
|
1248
|
-
<TableCell>Streamed C</TableCell>
|
|
1249
|
-
<TableCell>Streamed D</TableCell>
|
|
1250
|
-
</TableRow>
|
|
1251
|
-
</TableBody>
|
|
1252
|
-
</Table>,
|
|
1253
|
-
);
|
|
1254
|
-
expect(screen.getByText('Streamed A')).toBeInTheDocument();
|
|
1255
|
-
expect(screen.getByText('Streamed D')).toBeInTheDocument();
|
|
1256
|
-
expect(screen.getAllByRole('row')).toHaveLength(2);
|
|
1257
|
-
expect(screen.getAllByRole('cell')).toHaveLength(4);
|
|
1258
|
-
});
|
|
1259
|
-
|
|
1260
|
-
// Children mode hands the children straight to <table> — it does not wrap
|
|
1261
|
-
// them the way the data-driven path does. That is deliberate (it is what
|
|
1262
|
-
// makes the section components composable), but it was never written down,
|
|
1263
|
-
// and a caller who skipped the section shipped `<table><tr>` (#5277).
|
|
1264
|
-
it("children mode renders no tbody of its own — the section is the caller's", () => {
|
|
1265
|
-
const {container} = render(
|
|
1266
|
-
<Table density="balanced">
|
|
1267
|
-
{/* The unwrapped shape is the subject of this test, not a mistake. */}
|
|
1268
|
-
{/* eslint-disable-next-line @astryx/require-table-section */}
|
|
1269
|
-
<TableRow>
|
|
1270
|
-
<TableCell>Unwrapped</TableCell>
|
|
1271
|
-
</TableRow>
|
|
1272
|
-
</Table>,
|
|
1273
|
-
);
|
|
1274
|
-
const table = container.querySelector('table');
|
|
1275
|
-
expect(table?.querySelector('tbody')).toBeNull();
|
|
1276
|
-
expect(Array.from(table?.children ?? []).map(el => el.tagName)).toContain(
|
|
1277
|
-
'TR',
|
|
1278
|
-
);
|
|
1279
|
-
});
|
|
1280
|
-
|
|
1281
|
-
// Columns do not bring a thead with them in children mode — BaseTable's
|
|
1282
|
-
// `children ? children : <>...</>` short-circuits the whole data-driven
|
|
1283
|
-
// branch, header included. The header is TableHeader's job here.
|
|
1284
|
-
it('children mode renders no thead even when columns are supplied', () => {
|
|
1285
|
-
const {container} = render(
|
|
1286
|
-
<Table columns={columns}>
|
|
1287
|
-
<TableBody>
|
|
1288
|
-
<TableRow>
|
|
1289
|
-
<TableCell>Only body</TableCell>
|
|
1290
|
-
</TableRow>
|
|
1291
|
-
</TableBody>
|
|
1292
|
-
</Table>,
|
|
1293
|
-
);
|
|
1294
|
-
expect(container.querySelector('thead')).toBeNull();
|
|
1295
|
-
expect(container.querySelector('tbody > tr')).not.toBeNull();
|
|
1296
|
-
});
|
|
1297
|
-
|
|
1298
|
-
it('children mode renders the thead TableHeader supplies', () => {
|
|
1299
|
-
const {container} = render(
|
|
1300
|
-
<Table columns={columns}>
|
|
1301
|
-
<TableHeader>
|
|
1302
|
-
<TableRow isHeaderRow>
|
|
1303
|
-
<TableCell>H</TableCell>
|
|
1304
|
-
</TableRow>
|
|
1305
|
-
</TableHeader>
|
|
1306
|
-
<TableBody>
|
|
1307
|
-
<TableRow>
|
|
1308
|
-
<TableCell>B</TableCell>
|
|
1309
|
-
</TableRow>
|
|
1310
|
-
</TableBody>
|
|
1311
|
-
</Table>,
|
|
1312
|
-
);
|
|
1313
|
-
const table = container.querySelector('table');
|
|
1314
|
-
expect(Array.from(table?.children ?? []).map(el => el.tagName)).toEqual([
|
|
1315
|
-
'THEAD',
|
|
1316
|
-
'TBODY',
|
|
1317
|
-
]);
|
|
1318
|
-
});
|
|
1319
|
-
|
|
1320
|
-
it('children mode puts the rows in the tbody TableBody renders', () => {
|
|
1321
|
-
const {container} = render(
|
|
1322
|
-
<Table density="balanced">
|
|
1323
|
-
<TableBody>
|
|
1324
|
-
<TableRow>
|
|
1325
|
-
<TableCell>Wrapped</TableCell>
|
|
1326
|
-
</TableRow>
|
|
1327
|
-
</TableBody>
|
|
1328
|
-
</Table>,
|
|
1329
|
-
);
|
|
1330
|
-
const table = container.querySelector('table');
|
|
1331
|
-
expect(
|
|
1332
|
-
Array.from(table?.children ?? []).map(el => el.tagName),
|
|
1333
|
-
).not.toContain('TR');
|
|
1334
|
-
expect(table?.querySelector('tbody > tr')).not.toBeNull();
|
|
1335
|
-
});
|
|
1336
|
-
|
|
1337
|
-
it('passes through idKey string to base table', () => {
|
|
1338
|
-
render(<Table data={users} columns={columns} idKey="email" />);
|
|
1339
|
-
expect(screen.getAllByRole('row')).toHaveLength(4);
|
|
1340
|
-
});
|
|
1341
|
-
|
|
1342
|
-
it('passes through idKey function to base table', () => {
|
|
1343
|
-
const idKey = vi.fn((item: User) => item.email);
|
|
1344
|
-
render(<Table data={users} columns={columns} idKey={idKey} />);
|
|
1345
|
-
expect(idKey).toHaveBeenCalledTimes(3);
|
|
1346
|
-
expect(idKey).toHaveBeenCalledWith(users[0]);
|
|
1347
|
-
expect(idKey).toHaveBeenCalledWith(users[1]);
|
|
1348
|
-
expect(idKey).toHaveBeenCalledWith(users[2]);
|
|
1349
|
-
});
|
|
1350
|
-
|
|
1351
|
-
it('applies overflow truncation styles to body cells', () => {
|
|
1352
|
-
// text-overflow: ellipsis + overflow: hidden + white-space: nowrap are applied
|
|
1353
|
-
// via StyleX class names when textOverflow="truncate".
|
|
1354
|
-
const longData = [
|
|
1355
|
-
{
|
|
1356
|
-
name: 'a_very_long_string_without_spaces_that_would_overflow_a_fixed_width_column',
|
|
1357
|
-
value: '42',
|
|
1358
|
-
},
|
|
1359
|
-
];
|
|
1360
|
-
render(<Table data={longData} textOverflow="truncate" />);
|
|
1361
|
-
const cell = screen.getAllByRole('cell')[0];
|
|
1362
|
-
// Cell should have at least one StyleX-generated class applied
|
|
1363
|
-
expect(cell.className.length).toBeGreaterThan(0);
|
|
1364
|
-
// Text content is present in the DOM (truncation is purely visual)
|
|
1365
|
-
expect(cell).toHaveTextContent(
|
|
1366
|
-
'a_very_long_string_without_spaces_that_would_overflow_a_fixed_width_column',
|
|
1367
|
-
);
|
|
1368
|
-
});
|
|
1369
|
-
|
|
1370
|
-
it('wraps text by default (textOverflow="wrap")', () => {
|
|
1371
|
-
render(<Table data={users} columns={columns} />);
|
|
1372
|
-
const cells = screen.getAllByRole('cell');
|
|
1373
|
-
// In wrap mode, no Text wrapper — content renders directly
|
|
1374
|
-
expect(cells[0]).toHaveTextContent('Alice');
|
|
1375
|
-
expect(cells[0]).not.toHaveAttribute('title');
|
|
1376
|
-
});
|
|
1377
|
-
|
|
1378
|
-
it('wraps text when textOverflow="wrap"', () => {
|
|
1379
|
-
render(<Table data={users} columns={columns} textOverflow="wrap" />);
|
|
1380
|
-
const cells = screen.getAllByRole('cell');
|
|
1381
|
-
// In wrap mode, no title attribute is added (text is visible, not hidden)
|
|
1382
|
-
expect(cells[0]).not.toHaveAttribute('title');
|
|
1383
|
-
// Content is present
|
|
1384
|
-
expect(cells[0]).toHaveTextContent('Alice');
|
|
1385
|
-
});
|
|
1386
|
-
|
|
1387
|
-
it('wraps default-rendered cells in Text when textOverflow="truncate"', () => {
|
|
1388
|
-
render(<Table data={users} columns={columns} textOverflow="truncate" />);
|
|
1389
|
-
const cells = screen.getAllByRole('cell');
|
|
1390
|
-
// Default-rendered cells contain an Text child element (a <span>)
|
|
1391
|
-
const textEl = cells[0].querySelector('span');
|
|
1392
|
-
expect(textEl).toBeTruthy();
|
|
1393
|
-
expect(textEl).toHaveTextContent('Alice');
|
|
1394
|
-
});
|
|
1395
|
-
|
|
1396
|
-
it('does not wrap renderCell content in Text when truncating', () => {
|
|
1397
|
-
const cols: TableColumn<User>[] = [
|
|
1398
|
-
{
|
|
1399
|
-
key: 'name',
|
|
1400
|
-
header: 'Name',
|
|
1401
|
-
renderCell: item => <span data-testid="custom">{item.name}</span>,
|
|
1402
|
-
},
|
|
1403
|
-
{key: 'email', header: 'Email'},
|
|
1404
|
-
];
|
|
1405
|
-
render(<Table data={users} columns={cols} textOverflow="truncate" />);
|
|
1406
|
-
// Custom renderCell: consumer owns the content
|
|
1407
|
-
const customCells = screen.getAllByTestId('custom');
|
|
1408
|
-
expect(customCells[0]).toHaveTextContent('Alice');
|
|
1409
|
-
});
|
|
1410
|
-
|
|
1411
|
-
it('sets title attribute on string header cells', () => {
|
|
1412
|
-
render(<Table data={users} columns={columns} />);
|
|
1413
|
-
const headers = screen.getAllByRole('columnheader');
|
|
1414
|
-
// columns fixture order: name, age, email
|
|
1415
|
-
expect(headers[0]).toHaveAttribute('title', 'Name');
|
|
1416
|
-
expect(headers[1]).toHaveAttribute('title', 'Age');
|
|
1417
|
-
expect(headers[2]).toHaveAttribute('title', 'Email');
|
|
1418
|
-
});
|
|
1419
|
-
});
|
|
1420
|
-
|
|
1421
|
-
// =============================================================================
|
|
1422
|
-
// TableRow Tests
|
|
1423
|
-
// =============================================================================
|
|
1424
|
-
|
|
1425
|
-
describe('TableRow', () => {
|
|
1426
|
-
it('renders a tr element', () => {
|
|
1427
|
-
render(
|
|
1428
|
-
<table>
|
|
1429
|
-
<tbody>
|
|
1430
|
-
<TableRow data-testid="test-row">
|
|
1431
|
-
<td>Cell</td>
|
|
1432
|
-
</TableRow>
|
|
1433
|
-
</tbody>
|
|
1434
|
-
</table>,
|
|
1435
|
-
);
|
|
1436
|
-
expect(screen.getByTestId('test-row').tagName).toBe('TR');
|
|
1437
|
-
});
|
|
1438
|
-
|
|
1439
|
-
it('renders children inside the tr', () => {
|
|
1440
|
-
render(
|
|
1441
|
-
<table>
|
|
1442
|
-
<tbody>
|
|
1443
|
-
<TableRow>
|
|
1444
|
-
<td>First</td>
|
|
1445
|
-
<td>Second</td>
|
|
1446
|
-
</TableRow>
|
|
1447
|
-
</tbody>
|
|
1448
|
-
</table>,
|
|
1449
|
-
);
|
|
1450
|
-
expect(screen.getByText('First')).toBeInTheDocument();
|
|
1451
|
-
expect(screen.getByText('Second')).toBeInTheDocument();
|
|
1452
|
-
});
|
|
1453
|
-
|
|
1454
|
-
it('forwards ref to the tr element', () => {
|
|
1455
|
-
const ref = vi.fn();
|
|
1456
|
-
render(
|
|
1457
|
-
<table>
|
|
1458
|
-
<tbody>
|
|
1459
|
-
<TableRow ref={ref}>
|
|
1460
|
-
<td>Cell</td>
|
|
1461
|
-
</TableRow>
|
|
1462
|
-
</tbody>
|
|
1463
|
-
</table>,
|
|
1464
|
-
);
|
|
1465
|
-
expect(ref).toHaveBeenCalledWith(expect.any(HTMLTableRowElement));
|
|
1466
|
-
});
|
|
1467
|
-
|
|
1468
|
-
it('passes through HTML attributes (excluding className/style)', () => {
|
|
1469
|
-
render(
|
|
1470
|
-
<table>
|
|
1471
|
-
<tbody>
|
|
1472
|
-
<TableRow data-testid="row" aria-label="test row">
|
|
1473
|
-
<td>Cell</td>
|
|
1474
|
-
</TableRow>
|
|
1475
|
-
</tbody>
|
|
1476
|
-
</table>,
|
|
1477
|
-
);
|
|
1478
|
-
expect(screen.getByTestId('row')).toHaveAttribute('aria-label', 'test row');
|
|
1479
|
-
});
|
|
1480
|
-
});
|
|
1481
|
-
|
|
1482
|
-
// =============================================================================
|
|
1483
|
-
// TableCell Tests
|
|
1484
|
-
// =============================================================================
|
|
1485
|
-
|
|
1486
|
-
describe('TableCell', () => {
|
|
1487
|
-
it('renders a td element', () => {
|
|
1488
|
-
render(
|
|
1489
|
-
<table>
|
|
1490
|
-
<tbody>
|
|
1491
|
-
<tr>
|
|
1492
|
-
<TableCell data-testid="test-cell">Content</TableCell>
|
|
1493
|
-
</tr>
|
|
1494
|
-
</tbody>
|
|
1495
|
-
</table>,
|
|
1496
|
-
);
|
|
1497
|
-
expect(screen.getByTestId('test-cell').tagName).toBe('TD');
|
|
1498
|
-
});
|
|
1499
|
-
|
|
1500
|
-
it('renders children inside the td', () => {
|
|
1501
|
-
render(
|
|
1502
|
-
<table>
|
|
1503
|
-
<tbody>
|
|
1504
|
-
<tr>
|
|
1505
|
-
<TableCell>
|
|
1506
|
-
<span>Nested content</span>
|
|
1507
|
-
</TableCell>
|
|
1508
|
-
</tr>
|
|
1509
|
-
</tbody>
|
|
1510
|
-
</table>,
|
|
1511
|
-
);
|
|
1512
|
-
expect(screen.getByText('Nested content')).toBeInTheDocument();
|
|
1513
|
-
});
|
|
1514
|
-
|
|
1515
|
-
it('renders empty when no children provided', () => {
|
|
1516
|
-
render(
|
|
1517
|
-
<table>
|
|
1518
|
-
<tbody>
|
|
1519
|
-
<tr>
|
|
1520
|
-
<TableCell data-testid="empty-cell" />
|
|
1521
|
-
</tr>
|
|
1522
|
-
</tbody>
|
|
1523
|
-
</table>,
|
|
1524
|
-
);
|
|
1525
|
-
expect(screen.getByTestId('empty-cell')).toHaveTextContent('');
|
|
1526
|
-
});
|
|
1527
|
-
|
|
1528
|
-
it('forwards ref to the td element', () => {
|
|
1529
|
-
const ref = vi.fn();
|
|
1530
|
-
render(
|
|
1531
|
-
<table>
|
|
1532
|
-
<tbody>
|
|
1533
|
-
<tr>
|
|
1534
|
-
<TableCell ref={ref}>Cell</TableCell>
|
|
1535
|
-
</tr>
|
|
1536
|
-
</tbody>
|
|
1537
|
-
</table>,
|
|
1538
|
-
);
|
|
1539
|
-
expect(ref).toHaveBeenCalledWith(expect.any(HTMLTableCellElement));
|
|
1540
|
-
});
|
|
1541
|
-
|
|
1542
|
-
it('forwards colSpan attribute', () => {
|
|
1543
|
-
render(
|
|
1544
|
-
<table>
|
|
1545
|
-
<tbody>
|
|
1546
|
-
<tr>
|
|
1547
|
-
<TableCell colSpan={3} data-testid="span-cell">
|
|
1548
|
-
Spanning
|
|
1549
|
-
</TableCell>
|
|
1550
|
-
</tr>
|
|
1551
|
-
</tbody>
|
|
1552
|
-
</table>,
|
|
1553
|
-
);
|
|
1554
|
-
expect(screen.getByTestId('span-cell')).toHaveAttribute('colspan', '3');
|
|
1555
|
-
});
|
|
1556
|
-
|
|
1557
|
-
it('forwards rowSpan attribute', () => {
|
|
1558
|
-
render(
|
|
1559
|
-
<table>
|
|
1560
|
-
<tbody>
|
|
1561
|
-
<tr>
|
|
1562
|
-
<TableCell rowSpan={2} data-testid="rowspan-cell">
|
|
1563
|
-
Spanning
|
|
1564
|
-
</TableCell>
|
|
1565
|
-
</tr>
|
|
1566
|
-
</tbody>
|
|
1567
|
-
</table>,
|
|
1568
|
-
);
|
|
1569
|
-
expect(screen.getByTestId('rowspan-cell')).toHaveAttribute('rowspan', '2');
|
|
1570
|
-
});
|
|
1571
|
-
});
|
|
1572
|
-
|
|
1573
|
-
// =============================================================================
|
|
1574
|
-
// Column Alignment Tests
|
|
1575
|
-
// =============================================================================
|
|
1576
|
-
|
|
1577
|
-
describe('column alignment', () => {
|
|
1578
|
-
it('applies textAlign to header and body cells via inline style', () => {
|
|
1579
|
-
const {container} = render(
|
|
1580
|
-
<Table
|
|
1581
|
-
data={users}
|
|
1582
|
-
columns={[
|
|
1583
|
-
{key: 'name', header: 'Name'},
|
|
1584
|
-
{key: 'age', header: 'Age', align: 'end'},
|
|
1585
|
-
{key: 'email', header: 'Email', align: 'center'},
|
|
1586
|
-
]}
|
|
1587
|
-
/>,
|
|
1588
|
-
);
|
|
1589
|
-
|
|
1590
|
-
const headerCells = container.querySelectorAll('th');
|
|
1591
|
-
// First column: no explicit align (default 'start' is handled by CSS default)
|
|
1592
|
-
expect(headerCells[0]).not.toHaveStyle({textAlign: 'end'});
|
|
1593
|
-
expect(headerCells[0]).not.toHaveStyle({textAlign: 'center'});
|
|
1594
|
-
// Second column: end aligned
|
|
1595
|
-
expect(headerCells[1]).toHaveStyle({textAlign: 'end'});
|
|
1596
|
-
// Third column: center aligned
|
|
1597
|
-
expect(headerCells[2]).toHaveStyle({textAlign: 'center'});
|
|
1598
|
-
|
|
1599
|
-
const bodyRows = container.querySelectorAll('tbody tr');
|
|
1600
|
-
const firstRowCells = bodyRows[0].querySelectorAll('td');
|
|
1601
|
-
expect(firstRowCells[1]).toHaveStyle({textAlign: 'end'});
|
|
1602
|
-
expect(firstRowCells[2]).toHaveStyle({textAlign: 'center'});
|
|
1603
|
-
});
|
|
1604
|
-
|
|
1605
|
-
it('defaults to start alignment when align is not specified', () => {
|
|
1606
|
-
const {container} = render(
|
|
1607
|
-
<Table data={users} columns={[{key: 'name', header: 'Name'}]} />,
|
|
1608
|
-
);
|
|
1609
|
-
|
|
1610
|
-
const headerCell = container.querySelector('th');
|
|
1611
|
-
// No textAlign inline style when default
|
|
1612
|
-
expect(headerCell?.style.textAlign).toBeFalsy();
|
|
1613
|
-
});
|
|
1614
|
-
|
|
1615
|
-
it('applies align through the plugin pipeline on BaseTable', () => {
|
|
1616
|
-
const {container} = render(
|
|
1617
|
-
<BaseTable
|
|
1618
|
-
data={users}
|
|
1619
|
-
columns={[
|
|
1620
|
-
{key: 'name', header: 'Name', align: 'center'},
|
|
1621
|
-
{key: 'age', header: 'Age', align: 'end'},
|
|
1622
|
-
]}
|
|
1623
|
-
/>,
|
|
1624
|
-
);
|
|
1625
|
-
|
|
1626
|
-
const headerCells = container.querySelectorAll('th');
|
|
1627
|
-
expect(headerCells[0]).toHaveStyle({textAlign: 'center'});
|
|
1628
|
-
expect(headerCells[1]).toHaveStyle({textAlign: 'end'});
|
|
1629
|
-
|
|
1630
|
-
const bodyCells = container.querySelectorAll('tbody td');
|
|
1631
|
-
expect(bodyCells[0]).toHaveStyle({textAlign: 'center'});
|
|
1632
|
-
expect(bodyCells[1]).toHaveStyle({textAlign: 'end'});
|
|
1633
|
-
});
|
|
1634
|
-
});
|
|
1635
|
-
|
|
1636
|
-
// =============================================================================
|
|
1637
|
-
// Vertical Alignment Tests
|
|
1638
|
-
// =============================================================================
|
|
1639
|
-
|
|
1640
|
-
describe('vertical alignment', () => {
|
|
1641
|
-
it('defaults to middle vertical alignment', () => {
|
|
1642
|
-
const {container} = render(
|
|
1643
|
-
<Table data={users} columns={[{key: 'name', header: 'Name'}]} />,
|
|
1644
|
-
);
|
|
1645
|
-
|
|
1646
|
-
const bodyCell = container.querySelector('tbody td');
|
|
1647
|
-
expect(bodyCell).toHaveStyle({verticalAlign: 'middle'});
|
|
1648
|
-
});
|
|
1649
|
-
|
|
1650
|
-
it('applies top vertical alignment', () => {
|
|
1651
|
-
const {container} = render(
|
|
1652
|
-
<Table
|
|
1653
|
-
data={users}
|
|
1654
|
-
columns={[{key: 'name', header: 'Name'}]}
|
|
1655
|
-
verticalAlign="top"
|
|
1656
|
-
/>,
|
|
1657
|
-
);
|
|
1658
|
-
|
|
1659
|
-
const bodyCell = container.querySelector('tbody td');
|
|
1660
|
-
expect(bodyCell).toHaveStyle({verticalAlign: 'top'});
|
|
1661
|
-
});
|
|
1662
|
-
|
|
1663
|
-
it('applies bottom vertical alignment', () => {
|
|
1664
|
-
const {container} = render(
|
|
1665
|
-
<Table
|
|
1666
|
-
data={users}
|
|
1667
|
-
columns={[{key: 'name', header: 'Name'}]}
|
|
1668
|
-
verticalAlign="bottom"
|
|
1669
|
-
/>,
|
|
1670
|
-
);
|
|
1671
|
-
|
|
1672
|
-
const bodyCell = container.querySelector('tbody td');
|
|
1673
|
-
expect(bodyCell).toHaveStyle({verticalAlign: 'bottom'});
|
|
1674
|
-
});
|
|
1675
|
-
});
|
|
1676
|
-
|
|
1677
|
-
describe('emptyState', () => {
|
|
1678
|
-
it('renders default empty state when data is empty', () => {
|
|
1679
|
-
render(
|
|
1680
|
-
<Table
|
|
1681
|
-
data={[]}
|
|
1682
|
-
columns={[
|
|
1683
|
-
{key: 'name', header: 'Name'},
|
|
1684
|
-
{key: 'age', header: 'Age'},
|
|
1685
|
-
]}
|
|
1686
|
-
/>,
|
|
1687
|
-
);
|
|
1688
|
-
expect(screen.getByText('No data')).toBeInTheDocument();
|
|
1689
|
-
});
|
|
1690
|
-
|
|
1691
|
-
it('renders custom empty state when provided', () => {
|
|
1692
|
-
render(
|
|
1693
|
-
<Table
|
|
1694
|
-
data={[]}
|
|
1695
|
-
columns={[
|
|
1696
|
-
{key: 'name', header: 'Name'},
|
|
1697
|
-
{key: 'age', header: 'Age'},
|
|
1698
|
-
]}
|
|
1699
|
-
emptyState={<div data-testid="empty">No results found</div>}
|
|
1700
|
-
/>,
|
|
1701
|
-
);
|
|
1702
|
-
expect(screen.getByTestId('empty')).toBeInTheDocument();
|
|
1703
|
-
expect(screen.getByText('No results found')).toBeInTheDocument();
|
|
1704
|
-
});
|
|
1705
|
-
|
|
1706
|
-
it('does not render empty state when data has rows', () => {
|
|
1707
|
-
render(
|
|
1708
|
-
<Table
|
|
1709
|
-
data={[{name: 'Alice', age: 30}]}
|
|
1710
|
-
columns={[
|
|
1711
|
-
{key: 'name', header: 'Name'},
|
|
1712
|
-
{key: 'age', header: 'Age'},
|
|
1713
|
-
]}
|
|
1714
|
-
/>,
|
|
1715
|
-
);
|
|
1716
|
-
expect(screen.queryByText('No data')).not.toBeInTheDocument();
|
|
1717
|
-
expect(screen.getByText('Alice')).toBeInTheDocument();
|
|
1718
|
-
});
|
|
1719
|
-
|
|
1720
|
-
it('does not render empty state when data is undefined', () => {
|
|
1721
|
-
render(<Table columns={[{key: 'name', header: 'Name'}]} />);
|
|
1722
|
-
expect(screen.queryByText('No data')).not.toBeInTheDocument();
|
|
1723
|
-
});
|
|
1724
|
-
|
|
1725
|
-
it('disables empty state with false', () => {
|
|
1726
|
-
render(
|
|
1727
|
-
<Table
|
|
1728
|
-
data={[]}
|
|
1729
|
-
columns={[{key: 'name', header: 'Name'}]}
|
|
1730
|
-
emptyState={false}
|
|
1731
|
-
/>,
|
|
1732
|
-
);
|
|
1733
|
-
expect(screen.queryByText('No data')).not.toBeInTheDocument();
|
|
1734
|
-
});
|
|
1735
|
-
|
|
1736
|
-
it('empty state row spans all columns', () => {
|
|
1737
|
-
render(
|
|
1738
|
-
<Table
|
|
1739
|
-
data={[]}
|
|
1740
|
-
columns={[
|
|
1741
|
-
{key: 'name', header: 'Name'},
|
|
1742
|
-
{key: 'age', header: 'Age'},
|
|
1743
|
-
{key: 'role', header: 'Role'},
|
|
1744
|
-
]}
|
|
1745
|
-
emptyState={<div data-testid="empty">Nothing here</div>}
|
|
1746
|
-
/>,
|
|
1747
|
-
);
|
|
1748
|
-
const td = screen.getByTestId('empty').closest('td');
|
|
1749
|
-
expect(td).toHaveAttribute('colspan', '3');
|
|
1750
|
-
});
|
|
1751
|
-
|
|
1752
|
-
it('still renders headers even when data is empty', () => {
|
|
1753
|
-
render(
|
|
1754
|
-
<Table
|
|
1755
|
-
data={[]}
|
|
1756
|
-
columns={[
|
|
1757
|
-
{key: 'name', header: 'Name'},
|
|
1758
|
-
{key: 'age', header: 'Age'},
|
|
1759
|
-
]}
|
|
1760
|
-
/>,
|
|
1761
|
-
);
|
|
1762
|
-
expect(screen.getByText('Name')).toBeInTheDocument();
|
|
1763
|
-
expect(screen.getByText('Age')).toBeInTheDocument();
|
|
1764
|
-
});
|
|
1765
|
-
|
|
1766
|
-
describe('table section rest forwarding', () => {
|
|
1767
|
-
it('forwards data-testid and id to the tbody, thead, and tfoot', () => {
|
|
1768
|
-
const {container} = render(
|
|
1769
|
-
<table>
|
|
1770
|
-
<TableHeader data-testid="thead" id="head-1">
|
|
1771
|
-
<tr>
|
|
1772
|
-
<th>H</th>
|
|
1773
|
-
</tr>
|
|
1774
|
-
</TableHeader>
|
|
1775
|
-
<TableBody data-testid="tbody" id="body-1">
|
|
1776
|
-
<tr>
|
|
1777
|
-
<td>B</td>
|
|
1778
|
-
</tr>
|
|
1779
|
-
</TableBody>
|
|
1780
|
-
<TableFooter data-testid="tfoot" id="foot-1">
|
|
1781
|
-
<tr>
|
|
1782
|
-
<td>F</td>
|
|
1783
|
-
</tr>
|
|
1784
|
-
</TableFooter>
|
|
1785
|
-
</table>,
|
|
1786
|
-
);
|
|
1787
|
-
const thead = container.querySelector('thead')!;
|
|
1788
|
-
const tbody = container.querySelector('tbody')!;
|
|
1789
|
-
const tfoot = container.querySelector('tfoot')!;
|
|
1790
|
-
expect(thead).toHaveAttribute('data-testid', 'thead');
|
|
1791
|
-
expect(thead).toHaveAttribute('id', 'head-1');
|
|
1792
|
-
expect(tbody).toHaveAttribute('data-testid', 'tbody');
|
|
1793
|
-
expect(tbody).toHaveAttribute('id', 'body-1');
|
|
1794
|
-
expect(tfoot).toHaveAttribute('data-testid', 'tfoot');
|
|
1795
|
-
expect(tfoot).toHaveAttribute('id', 'foot-1');
|
|
1796
|
-
});
|
|
1797
|
-
});
|
|
1798
|
-
});
|
|
1799
|
-
|
|
1800
|
-
describe('ARIA row indexing (#3939)', () => {
|
|
1801
|
-
const bodyRows = (container: HTMLElement): HTMLTableRowElement[] =>
|
|
1802
|
-
Array.from(container.querySelectorAll('tbody tr'));
|
|
1803
|
-
|
|
1804
|
-
it('emits no aria-rowindex/aria-rowcount by default', () => {
|
|
1805
|
-
const {container} = render(<Table data={users} columns={columns} />);
|
|
1806
|
-
expect(screen.getByRole('table')).not.toHaveAttribute('aria-rowcount');
|
|
1807
|
-
for (const row of bodyRows(container)) {
|
|
1808
|
-
expect(row).not.toHaveAttribute('aria-rowindex');
|
|
1809
|
-
}
|
|
1810
|
-
});
|
|
1811
|
-
|
|
1812
|
-
it('numbers rows from 1 when rowCount is provided', () => {
|
|
1813
|
-
const {container} = render(
|
|
1814
|
-
<Table data={users} columns={columns} rowCount={users.length} />,
|
|
1815
|
-
);
|
|
1816
|
-
expect(screen.getByRole('table')).toHaveAttribute(
|
|
1817
|
-
'aria-rowcount',
|
|
1818
|
-
String(users.length),
|
|
1819
|
-
);
|
|
1820
|
-
const indices = bodyRows(container).map(r =>
|
|
1821
|
-
r.getAttribute('aria-rowindex'),
|
|
1822
|
-
);
|
|
1823
|
-
expect(indices).toEqual(['1', '2', '3']);
|
|
1824
|
-
});
|
|
1825
|
-
|
|
1826
|
-
it('offsets aria-rowindex by rowIndexStart for a paginated view', () => {
|
|
1827
|
-
// Page 3 of a 10-per-page dataset: first visible row is dataset row 21.
|
|
1828
|
-
const {container} = render(
|
|
1829
|
-
<Table
|
|
1830
|
-
data={users}
|
|
1831
|
-
columns={columns}
|
|
1832
|
-
rowIndexStart={21}
|
|
1833
|
-
rowCount={100}
|
|
1834
|
-
/>,
|
|
1835
|
-
);
|
|
1836
|
-
expect(screen.getByRole('table')).toHaveAttribute('aria-rowcount', '100');
|
|
1837
|
-
const indices = bodyRows(container).map(r =>
|
|
1838
|
-
r.getAttribute('aria-rowindex'),
|
|
1839
|
-
);
|
|
1840
|
-
expect(indices).toEqual(['21', '22', '23']);
|
|
1841
|
-
});
|
|
1842
|
-
|
|
1843
|
-
it('sets aria-rowcount to -1 (unknown) when only rowIndexStart is given', () => {
|
|
1844
|
-
// Windowed/cursor pagination: offset known, total unknown.
|
|
1845
|
-
const {container} = render(
|
|
1846
|
-
<Table data={users} columns={columns} rowIndexStart={5} />,
|
|
1847
|
-
);
|
|
1848
|
-
expect(screen.getByRole('table')).toHaveAttribute('aria-rowcount', '-1');
|
|
1849
|
-
const indices = bodyRows(container).map(r =>
|
|
1850
|
-
r.getAttribute('aria-rowindex'),
|
|
1851
|
-
);
|
|
1852
|
-
expect(indices).toEqual(['5', '6', '7']);
|
|
1853
|
-
});
|
|
1854
|
-
|
|
1855
|
-
it('does not assign an ARIA row index to the header row', () => {
|
|
1856
|
-
render(<Table data={users} columns={columns} rowCount={users.length} />);
|
|
1857
|
-
const header = screen.getAllByRole('row')[0];
|
|
1858
|
-
expect(header).not.toHaveAttribute('aria-rowindex');
|
|
1859
|
-
});
|
|
1860
|
-
|
|
1861
|
-
it('lets a plugin override the seeded aria-rowindex', () => {
|
|
1862
|
-
const plugin: TablePlugin<User> = {
|
|
1863
|
-
transformBodyRow(props, _item, index) {
|
|
1864
|
-
return {
|
|
1865
|
-
...props,
|
|
1866
|
-
htmlProps: {...props.htmlProps, 'aria-rowindex': 100 + index},
|
|
1867
|
-
};
|
|
1868
|
-
},
|
|
1869
|
-
};
|
|
1870
|
-
const {container} = render(
|
|
1871
|
-
<Table
|
|
1872
|
-
data={users}
|
|
1873
|
-
columns={columns}
|
|
1874
|
-
rowCount={users.length}
|
|
1875
|
-
plugins={{custom: plugin}}
|
|
1876
|
-
/>,
|
|
1877
|
-
);
|
|
1878
|
-
const indices = bodyRows(container).map(r =>
|
|
1879
|
-
r.getAttribute('aria-rowindex'),
|
|
1880
|
-
);
|
|
1881
|
-
expect(indices).toEqual(['100', '101', '102']);
|
|
1882
|
-
});
|
|
1883
|
-
});
|