@astryxdesign/core 0.7.5-canary.fccd771 → 0.7.5
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/CHANGELOG.md +211 -10
- package/README.md +15 -12
- package/dist/AlertDialog/AlertDialog.js +1 -1
- package/dist/AppShell/AppShell.d.ts +0 -22
- package/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +155 -1
- package/dist/Avatar/AvatarStatusDot.js +2 -2
- package/dist/Badge/Badge.d.ts.map +1 -1
- package/dist/Badge/Badge.js +18 -2
- package/dist/Banner/Banner.d.ts +1 -0
- package/dist/Banner/Banner.d.ts.map +1 -1
- package/dist/Banner/Banner.js +64 -9
- package/dist/BottomSheet/BottomSheet.d.ts +53 -5
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +435 -198
- package/dist/BottomSheet/BottomSheetHostContext.d.ts +8 -0
- package/dist/BottomSheet/BottomSheetHostContext.d.ts.map +1 -0
- package/dist/BottomSheet/BottomSheetHostContext.js +35 -0
- package/dist/BottomSheet/BottomSheetPanel.d.ts +9 -1
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +77 -23
- package/dist/BottomSheet/BottomSheetSwitcher.d.ts +53 -14
- package/dist/BottomSheet/BottomSheetSwitcher.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetSwitcher.js +229 -27
- package/dist/BottomSheet/BottomSheetSwitcherContext.d.ts +6 -0
- package/dist/BottomSheet/BottomSheetSwitcherContext.d.ts.map +1 -1
- package/dist/BottomSheet/bottomSheetEscape.d.ts +3 -0
- package/dist/BottomSheet/bottomSheetEscape.d.ts.map +1 -0
- package/dist/BottomSheet/bottomSheetEscape.js +20 -0
- package/dist/BottomSheet/bottomSheetStack.d.ts +262 -0
- package/dist/BottomSheet/bottomSheetStack.d.ts.map +1 -0
- package/dist/BottomSheet/bottomSheetStack.js +1675 -0
- package/dist/BottomSheet/useSheetGestures.d.ts +19 -3
- package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
- package/dist/BottomSheet/useSheetGestures.js +43 -14
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +36 -3
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +18 -7
- package/dist/Chat/ChatComposer.d.ts.map +1 -1
- package/dist/Chat/ChatComposer.js +25 -32
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +55 -16
- package/dist/Chat/ChatMessageMetadata.js +2 -2
- package/dist/Chat/ChatPastedTextToken.d.ts.map +1 -1
- package/dist/Chat/ChatPastedTextToken.js +7 -6
- package/dist/Chat/ChatToolCalls.js +4 -4
- package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
- package/dist/ClickableCard/ClickableCard.js +10 -6
- package/dist/CodeBlock/CodeBlock.d.ts +25 -2
- package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.js +58 -19
- package/dist/CodeBlock/grammar.d.ts +134 -0
- package/dist/CodeBlock/grammar.d.ts.map +1 -0
- package/dist/CodeBlock/grammar.js +219 -0
- package/dist/CodeBlock/index.d.ts +2 -0
- package/dist/CodeBlock/index.d.ts.map +1 -1
- package/dist/CodeBlock/index.js +1 -0
- package/dist/CodeBlock/languages/dockerfile.d.ts +3 -0
- package/dist/CodeBlock/languages/dockerfile.d.ts.map +1 -0
- package/dist/CodeBlock/languages/dockerfile.js +45 -0
- package/dist/CodeBlock/languages/graphql.d.ts +3 -0
- package/dist/CodeBlock/languages/graphql.d.ts.map +1 -0
- package/dist/CodeBlock/languages/graphql.js +27 -0
- package/dist/CodeBlock/languages/java.d.ts +3 -0
- package/dist/CodeBlock/languages/java.d.ts.map +1 -0
- package/dist/CodeBlock/languages/java.js +24 -0
- package/dist/CodeBlock/languages/lua.d.ts +3 -0
- package/dist/CodeBlock/languages/lua.d.ts.map +1 -0
- package/dist/CodeBlock/languages/lua.js +21 -0
- package/dist/CodeBlock/languages/objective-c.d.ts +3 -0
- package/dist/CodeBlock/languages/objective-c.d.ts.map +1 -0
- package/dist/CodeBlock/languages/objective-c.js +27 -0
- package/dist/CodeBlock/languages/powershell.d.ts +3 -0
- package/dist/CodeBlock/languages/powershell.d.ts.map +1 -0
- package/dist/CodeBlock/languages/powershell.js +30 -0
- package/dist/CodeBlock/languages/ruby.d.ts +3 -0
- package/dist/CodeBlock/languages/ruby.d.ts.map +1 -0
- package/dist/CodeBlock/languages/ruby.js +24 -0
- package/dist/CodeBlock/languages/thrift.d.ts +3 -0
- package/dist/CodeBlock/languages/thrift.d.ts.map +1 -0
- package/dist/CodeBlock/languages/thrift.js +18 -0
- package/dist/CodeBlock/languages/toml.d.ts +3 -0
- package/dist/CodeBlock/languages/toml.d.ts.map +1 -0
- package/dist/CodeBlock/languages/toml.js +53 -0
- package/dist/CodeBlock/tokenizer.d.ts +8 -4
- package/dist/CodeBlock/tokenizer.d.ts.map +1 -1
- package/dist/CodeBlock/tokenizer.js +158 -8
- package/dist/Collapsible/Collapsible.d.ts +8 -1
- package/dist/Collapsible/Collapsible.d.ts.map +1 -1
- package/dist/Collapsible/Collapsible.js +84 -2
- package/dist/CommandPalette/CommandPalette.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPalette.js +15 -1
- package/dist/CommandPalette/CommandPaletteEmpty.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteEmpty.js +1 -0
- package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteInput.js +14 -2
- package/dist/CommandPalette/busyStartSettle.d.ts +4 -0
- package/dist/CommandPalette/busyStartSettle.d.ts.map +1 -0
- package/dist/CommandPalette/busyStartSettle.js +23 -0
- package/dist/ComplexSelector/ComplexSelector.d.ts +20 -2
- package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
- package/dist/ComplexSelector/ComplexSelector.js +42 -7
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +48 -13
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +12 -5
- package/dist/DateInput/NativeDateField.d.ts.map +1 -1
- package/dist/DateInput/NativeDateField.js +2 -1
- package/dist/DateInput/TouchDateField.d.ts.map +1 -1
- package/dist/DateInput/TouchDateField.js +2 -1
- package/dist/DateInput/Wheel.d.ts.map +1 -1
- package/dist/DateInput/Wheel.js +1 -1
- package/dist/Dialog/Dialog.d.ts +4 -0
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +20 -8
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +18 -13
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +34 -30
- package/dist/DropdownMenu/DropdownMenuGroup.d.ts +7 -4
- package/dist/DropdownMenu/DropdownMenuGroup.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuGroup.js +10 -4
- package/dist/DropdownMenu/DropdownMenuItem.js +3 -3
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts +10 -5
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioItem.js +13 -5
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts +6 -6
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +0 -3
- package/dist/DropdownMenu/MenuBottomSheet.d.ts +11 -4
- package/dist/DropdownMenu/MenuBottomSheet.d.ts.map +1 -1
- package/dist/DropdownMenu/MenuBottomSheet.js +35 -9
- package/dist/DropdownMenu/MenuBottomSheetActionList.js +3 -3
- package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts +2 -0
- package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts.map +1 -1
- package/dist/DropdownMenu/lazyMenuBottomSheet.js +25 -3
- package/dist/DropdownMenu/menuBottomSheet.stylex.d.ts +23 -0
- package/dist/DropdownMenu/menuBottomSheet.stylex.d.ts.map +1 -0
- package/dist/DropdownMenu/menuBottomSheet.stylex.js +29 -0
- package/dist/DropdownMenu/menuItemHover.d.ts +3 -0
- package/dist/DropdownMenu/menuItemHover.d.ts.map +1 -1
- package/dist/DropdownMenu/menuItemHover.js +14 -1
- package/dist/DropdownMenu/menuTouchAction.stylex.d.ts +25 -0
- package/dist/DropdownMenu/menuTouchAction.stylex.d.ts.map +1 -0
- package/dist/DropdownMenu/menuTouchAction.stylex.js +29 -0
- package/dist/DropdownMenu/useMenuDrillIn.d.ts.map +1 -1
- package/dist/DropdownMenu/useMenuDrillIn.js +7 -5
- package/dist/EmptyState/EmptyState.d.ts +4 -2
- package/dist/EmptyState/EmptyState.d.ts.map +1 -1
- package/dist/EmptyState/EmptyState.js +6 -4
- package/dist/Field/Field.js +1 -1
- package/dist/Field/FieldLabel.js +1 -1
- package/dist/Field/PanelSearchInput.d.ts +9 -1
- package/dist/Field/PanelSearchInput.d.ts.map +1 -1
- package/dist/Field/PanelSearchInput.js +31 -22
- package/dist/Field/inputDisabledFocus.d.ts +14 -0
- package/dist/Field/inputDisabledFocus.d.ts.map +1 -0
- package/dist/Field/inputDisabledFocus.js +19 -0
- package/dist/Field/inputStyles.stylex.d.ts +9 -9
- package/dist/Field/inputStyles.stylex.js +9 -9
- package/dist/FieldStatus/FieldStatus.d.ts.map +1 -1
- package/dist/FieldStatus/FieldStatus.js +7 -3
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +22 -12
- package/dist/Icon/Icon.d.ts +37 -5
- package/dist/Icon/Icon.d.ts.map +1 -1
- package/dist/Icon/Icon.js +65 -11
- package/dist/Icon/IconSize.stylex.d.ts +16 -11
- package/dist/Icon/IconSize.stylex.d.ts.map +1 -1
- package/dist/Icon/IconSize.stylex.js +27 -11
- package/dist/Icon/globalIconRegistry.d.ts +71 -4
- package/dist/Icon/globalIconRegistry.d.ts.map +1 -1
- package/dist/Icon/globalIconRegistry.js +163 -23
- package/dist/Icon/index.d.ts +26 -2
- package/dist/Icon/index.d.ts.map +1 -1
- package/dist/Icon/index.js +24 -1
- package/dist/Icon/useIcon.d.ts +5 -1
- package/dist/Icon/useIcon.d.ts.map +1 -1
- package/dist/Icon/useIcon.js +5 -1
- package/dist/InputGroup/InputGroup.d.ts +1 -1
- package/dist/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/InputGroup/InputGroup.js +46 -36
- package/dist/InputGroup/InputGroupInternalContext.d.ts +4 -0
- package/dist/InputGroup/InputGroupInternalContext.d.ts.map +1 -0
- package/dist/InputGroup/InputGroupInternalContext.js +15 -0
- package/dist/InputGroup/InputGroupText.d.ts.map +1 -1
- package/dist/InputGroup/InputGroupText.js +2 -0
- package/dist/InputGroup/groupStyles.d.ts +9 -0
- package/dist/InputGroup/groupStyles.d.ts.map +1 -1
- package/dist/InputGroup/groupStyles.js +28 -14
- package/dist/Item/Item.d.ts +5 -1
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +23 -7
- package/dist/Item/ItemMarkerColumns.a11y.chromium.spec.d.ts +2 -0
- package/dist/Item/ItemMarkerColumns.a11y.chromium.spec.d.ts.map +1 -0
- package/dist/Item/ItemMarkerColumns.a11y.chromium.spec.js +132 -0
- package/dist/Item/ItemMarkerColumnsContext.d.ts +14 -0
- package/dist/Item/ItemMarkerColumnsContext.d.ts.map +1 -0
- package/dist/Item/ItemMarkerColumnsContext.js +18 -0
- package/dist/Item/ItemSwipeLayer.d.ts.map +1 -1
- package/dist/Item/ItemSwipeLayer.js +3 -0
- package/dist/Item/useSwipeAction.d.ts.map +1 -1
- package/dist/Item/useSwipeAction.js +60 -5
- package/dist/Kbd/Kbd.d.ts +2 -2
- package/dist/Kbd/Kbd.d.ts.map +1 -1
- package/dist/Kbd/Kbd.js +18 -11
- package/dist/Layer/layerAnimations.stylex.d.ts +9 -5
- package/dist/Layer/layerAnimations.stylex.d.ts.map +1 -1
- package/dist/Layer/layerAnimations.stylex.js +23 -10
- package/dist/Layer/layerSlideRules.d.ts +62 -2
- package/dist/Layer/layerSlideRules.d.ts.map +1 -1
- package/dist/Layer/layerSlideRules.js +124 -3
- package/dist/Layer/layerStack.d.ts +12 -9
- package/dist/Layer/layerStack.d.ts.map +1 -1
- package/dist/Layer/layerStack.js +116 -53
- package/dist/Layer/modalOutlet.d.ts +44 -6
- package/dist/Layer/modalOutlet.d.ts.map +1 -1
- package/dist/Layer/modalOutlet.js +150 -14
- package/dist/Layer/preserveAnimations.d.ts +11 -0
- package/dist/Layer/preserveAnimations.d.ts.map +1 -0
- package/dist/Layer/preserveAnimations.js +245 -0
- package/dist/Layer/useLayer.d.ts +19 -2
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +531 -44
- package/dist/Layer/useLayerDismissal.d.ts +10 -7
- package/dist/Layer/useLayerDismissal.d.ts.map +1 -1
- package/dist/Layer/useLayerDismissal.js +8 -8
- package/dist/Layer/useTouchTrigger.d.ts +14 -1
- package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
- package/dist/Layer/useTouchTrigger.js +72 -17
- package/dist/Layout/Layout.d.ts.map +1 -1
- package/dist/Layout/Layout.js +4 -0
- package/dist/Layout/LayoutContent.d.ts.map +1 -1
- package/dist/Layout/LayoutContent.js +2 -2
- package/dist/Layout/LayoutFooter.d.ts.map +1 -1
- package/dist/Layout/LayoutFooter.js +2 -1
- package/dist/Layout/LayoutHeader.d.ts.map +1 -1
- package/dist/Layout/LayoutHeader.js +2 -1
- package/dist/Layout/layoutEdges.stylex.d.ts +20 -0
- package/dist/Layout/layoutEdges.stylex.d.ts.map +1 -0
- package/dist/Layout/layoutEdges.stylex.js +28 -0
- package/dist/Lightbox/Lightbox.d.ts +5 -2
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +111 -89
- package/dist/Lightbox/LightboxKeyboard.a11y.browser.spec.d.ts +2 -0
- package/dist/Lightbox/LightboxKeyboard.a11y.browser.spec.d.ts.map +1 -0
- package/dist/Lightbox/LightboxKeyboard.a11y.browser.spec.js +78 -0
- package/dist/Lightbox/LightboxViewport.a11y.browser.spec.d.ts +2 -0
- package/dist/Lightbox/LightboxViewport.a11y.browser.spec.d.ts.map +1 -0
- package/dist/Lightbox/LightboxViewport.a11y.browser.spec.js +65 -0
- package/dist/List/List.d.ts +2 -1
- package/dist/List/List.d.ts.map +1 -1
- package/dist/List/List.js +9 -2
- package/dist/List/ListContext.d.ts +16 -4
- package/dist/List/ListContext.d.ts.map +1 -1
- package/dist/List/ListContext.js +10 -5
- package/dist/List/ListItem.d.ts +7 -1
- package/dist/List/ListItem.d.ts.map +1 -1
- package/dist/List/ListItem.js +52 -8
- package/dist/List/ListMarkers.a11y.chromium.spec.d.ts +2 -0
- package/dist/List/ListMarkers.a11y.chromium.spec.d.ts.map +1 -0
- package/dist/List/ListMarkers.a11y.chromium.spec.js +677 -0
- package/dist/Markdown/Markdown.d.ts +11 -1
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.fr23.bench.js +3 -1
- package/dist/Markdown/Markdown.fr23.sampling.d.ts +16 -0
- package/dist/Markdown/Markdown.fr23.sampling.d.ts.map +1 -1
- package/dist/Markdown/Markdown.fr23.sampling.js +13 -4
- package/dist/Markdown/Markdown.js +41 -14
- package/dist/Markdown/MarkdownTable.a11y.chromium.spec.js +1 -0
- package/dist/MobileNav/MobileNav.d.ts +2 -1
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +46 -37
- package/dist/MobileNav/MobileNavPinchZoom.a11y.chromium.spec.js +1 -0
- package/dist/MobileNav/MobileNavToggle.d.ts +7 -3
- package/dist/MobileNav/MobileNavToggle.d.ts.map +1 -1
- package/dist/MobileNav/MobileNavToggle.js +11 -3
- package/dist/MultiSelector/CreateRow.a11y.chromium.spec.js +53 -6
- package/dist/MultiSelector/MultiSelector.d.ts +1 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.js +1 -0
- package/dist/MultiSelector/MultiSelector.js +21 -5
- package/dist/MultiSelector/OptionActions.a11y.chromium.spec.js +1 -0
- package/dist/NavMenu/NavHeadingMenu.d.ts +1 -1
- package/dist/NavMenu/NavHeadingMenu.d.ts.map +1 -1
- package/dist/NavMenu/NavHeadingMenu.js +29 -5
- package/dist/NavMenu/NavHeadingMenuItem.d.ts.map +1 -1
- package/dist/NavMenu/NavHeadingMenuItem.js +51 -7
- package/dist/NavMenu/NavMenuContext.d.ts +9 -0
- package/dist/NavMenu/NavMenuContext.d.ts.map +1 -1
- package/dist/NavMenu/NavMenuContext.js +9 -0
- package/dist/NumberInput/NumberInput.d.ts +4 -4
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +61 -24
- package/dist/Overlay/Overlay.d.ts +3 -3
- package/dist/Overlay/Overlay.d.ts.map +1 -1
- package/dist/Overlay/Overlay.js +12 -5
- package/dist/Popover/Popover.d.ts +41 -2
- package/dist/Popover/Popover.d.ts.map +1 -1
- package/dist/Popover/Popover.js +276 -44
- package/dist/Popover/index.d.ts +1 -1
- package/dist/Popover/index.d.ts.map +1 -1
- package/dist/Popover/lazyPopoverBottomSheet.d.ts +23 -0
- package/dist/Popover/lazyPopoverBottomSheet.d.ts.map +1 -0
- package/dist/Popover/lazyPopoverBottomSheet.js +40 -0
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +11 -5
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +7 -5
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +8 -0
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +10 -2
- package/dist/ScrollableArea/ScrollableArea.d.ts.map +1 -1
- package/dist/ScrollableArea/ScrollableArea.js +1 -1
- package/dist/SegmentedControl/SegmentedControl.d.ts +1 -1
- package/dist/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControl.js +6 -2
- package/dist/SelectableCard/SelectableCard.d.ts +5 -5
- package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
- package/dist/SelectableCard/SelectableCard.js +15 -11
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +27 -8
- package/dist/Selector/hooks.d.ts +52 -6
- package/dist/Selector/hooks.d.ts.map +1 -1
- package/dist/Selector/hooks.js +145 -2
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +58 -2
- package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
- package/dist/SideNav/SideNavHeading.js +79 -3
- package/dist/SideNav/SideNavItem.d.ts +5 -1
- package/dist/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +36 -13
- package/dist/SideNav/railMotion.d.ts +54 -0
- package/dist/SideNav/railMotion.d.ts.map +1 -0
- package/dist/SideNav/railMotion.js +253 -0
- package/dist/Skeleton/Skeleton.d.ts.map +1 -1
- package/dist/Skeleton/Skeleton.js +12 -3
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +52 -15
- package/dist/StatusDot/StatusDot.d.ts.map +1 -1
- package/dist/StatusDot/StatusDot.js +12 -0
- package/dist/Stepper/Step.d.ts.map +1 -1
- package/dist/Stepper/Step.js +10 -6
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +5 -5
- package/dist/Switch/switch.markers.stylex.d.ts +7 -2
- package/dist/Switch/switch.markers.stylex.d.ts.map +1 -1
- package/dist/Switch/switch.markers.stylex.js +8 -3
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +5 -1
- package/dist/TabList/TabMenu.d.ts.map +1 -1
- package/dist/TabList/TabMenu.js +25 -3
- package/dist/Table/TableCell.d.ts.map +1 -1
- package/dist/Table/TableCell.js +5 -1
- package/dist/Table/TableHeaderCell.d.ts.map +1 -1
- package/dist/Table/TableHeaderCell.js +1 -0
- package/dist/Table/TableRow.d.ts.map +1 -1
- package/dist/Table/TableRow.js +3 -0
- package/dist/Table/glidingDivider.d.ts +96 -0
- package/dist/Table/glidingDivider.d.ts.map +1 -0
- package/dist/Table/glidingDivider.js +275 -0
- package/dist/Table/plugins/columnResize/useTableColumnResize.d.ts.map +1 -1
- package/dist/Table/plugins/columnResize/useTableColumnResize.js +11 -2
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts +8 -0
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +374 -13
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +244 -6
- package/dist/Table/rowDivider.d.ts +34 -0
- package/dist/Table/rowDivider.d.ts.map +1 -0
- package/dist/Table/rowDivider.js +118 -0
- package/dist/TextArea/TextArea.d.ts +6 -4
- package/dist/TextArea/TextArea.d.ts.map +1 -1
- package/dist/TextArea/TextArea.js +15 -12
- package/dist/TextInput/TextInput.d.ts +7 -5
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +43 -22
- package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
- package/dist/Thumbnail/Thumbnail.js +45 -11
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +12 -4
- package/dist/TimeInput/TouchTimeField.d.ts.map +1 -1
- package/dist/TimeInput/TouchTimeField.js +2 -1
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +62 -6
- package/dist/Tokenizer/Tokenizer.d.ts +71 -4
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +430 -45
- package/dist/Tokenizer/TokenizerBottomSheet.d.ts +98 -0
- package/dist/Tokenizer/TokenizerBottomSheet.d.ts.map +1 -0
- package/dist/Tokenizer/TokenizerBottomSheet.js +721 -0
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +9 -3
- package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
- package/dist/TopNav/TopNavHeading.js +26 -0
- package/dist/TopNav/TopNavMegaMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMegaMenu.js +4 -4
- package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMenu.js +32 -4
- package/dist/TreeList/TreeList.d.ts +8 -23
- package/dist/TreeList/TreeList.d.ts.map +1 -1
- package/dist/TreeList/TreeList.js +175 -3
- package/dist/TreeList/TreeListBranches.d.ts.map +1 -1
- package/dist/TreeList/TreeListBranches.js +7 -5
- package/dist/TreeList/TreeListItem.d.ts +7 -1
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +5 -3
- package/dist/Typeahead/BaseTypeahead.d.ts +1 -1
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.emptyState.a11y.chromium.spec.d.ts +2 -0
- package/dist/Typeahead/BaseTypeahead.emptyState.a11y.chromium.spec.d.ts.map +1 -0
- package/dist/Typeahead/BaseTypeahead.emptyState.a11y.chromium.spec.js +118 -0
- package/dist/Typeahead/BaseTypeahead.js +27 -11
- package/dist/Typeahead/Typeahead.d.ts +1 -1
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +31 -14
- package/dist/astryx.css +164 -41
- package/dist/gestures/GestureArena.d.ts +175 -0
- package/dist/gestures/GestureArena.d.ts.map +1 -0
- package/dist/gestures/GestureArena.js +816 -0
- package/dist/gestures/GestureRecognizer.d.ts +239 -0
- package/dist/gestures/GestureRecognizer.d.ts.map +1 -0
- package/dist/gestures/GestureRecognizer.js +487 -0
- package/dist/gestures/LongPressGestureRecognizer.d.ts +32 -0
- package/dist/gestures/LongPressGestureRecognizer.d.ts.map +1 -0
- package/dist/gestures/LongPressGestureRecognizer.js +135 -0
- package/dist/gestures/PanGestureRecognizer.d.ts +117 -0
- package/dist/gestures/PanGestureRecognizer.d.ts.map +1 -0
- package/dist/gestures/PanGestureRecognizer.js +349 -0
- package/dist/gestures/TapGestureRecognizer.d.ts +39 -0
- package/dist/gestures/TapGestureRecognizer.d.ts.map +1 -0
- package/dist/gestures/TapGestureRecognizer.js +151 -0
- package/dist/gestures/VelocityTracker.d.ts +51 -0
- package/dist/gestures/VelocityTracker.d.ts.map +1 -0
- package/dist/gestures/VelocityTracker.js +186 -0
- package/dist/gestures/geometry.d.ts +17 -0
- package/dist/gestures/geometry.d.ts.map +1 -0
- package/dist/gestures/geometry.js +55 -0
- package/dist/gestures/types.d.ts +139 -0
- package/dist/gestures/types.d.ts.map +1 -0
- package/dist/gestures/types.js +67 -0
- package/dist/hooks/AnnounceRenderedText.d.ts +17 -0
- package/dist/hooks/AnnounceRenderedText.d.ts.map +1 -0
- package/dist/hooks/AnnounceRenderedText.js +32 -0
- package/dist/hooks/ModalAnnounceProvider.d.ts +41 -0
- package/dist/hooks/ModalAnnounceProvider.d.ts.map +1 -0
- package/dist/hooks/ModalAnnounceProvider.js +133 -0
- package/dist/hooks/actionGroupTracker.d.ts +98 -0
- package/dist/hooks/actionGroupTracker.d.ts.map +1 -0
- package/dist/hooks/actionGroupTracker.js +338 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/menuPressOnItems.d.ts +19 -0
- package/dist/hooks/menuPressOnItems.d.ts.map +1 -0
- package/dist/hooks/menuPressOnItems.js +32 -0
- package/dist/hooks/modalAnnounce.d.ts +18 -0
- package/dist/hooks/modalAnnounce.d.ts.map +1 -0
- package/dist/hooks/modalAnnounce.js +382 -0
- package/dist/hooks/scrollGeometry.d.ts +28 -0
- package/dist/hooks/scrollGeometry.d.ts.map +1 -1
- package/dist/hooks/scrollGeometry.js +36 -2
- package/dist/hooks/useAdaptivePresentation.d.ts +9 -1
- package/dist/hooks/useAdaptivePresentation.d.ts.map +1 -1
- package/dist/hooks/useAdaptivePresentation.js +33 -8
- package/dist/hooks/useAnimatedLayout.d.ts +42 -0
- package/dist/hooks/useAnimatedLayout.d.ts.map +1 -0
- package/dist/hooks/useAnimatedLayout.js +46 -0
- package/dist/hooks/useAnnounce.d.ts +132 -1
- package/dist/hooks/useAnnounce.d.ts.map +1 -1
- package/dist/hooks/useAnnounce.js +356 -27
- package/dist/hooks/useAnnounceRenderedText.d.ts +19 -2
- package/dist/hooks/useAnnounceRenderedText.d.ts.map +1 -1
- package/dist/hooks/useAnnounceRenderedText.js +52 -11
- package/dist/hooks/useBusyAnnouncement.d.ts +9 -5
- package/dist/hooks/useBusyAnnouncement.d.ts.map +1 -1
- package/dist/hooks/useBusyAnnouncement.js +58 -46
- package/dist/hooks/useFocusTrap.d.ts +1 -1
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +57 -26
- package/dist/hooks/useMenuHover.d.ts.map +1 -1
- package/dist/hooks/useMenuHover.js +6 -2
- package/dist/hooks/useMenuPress.d.ts +4 -2
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +58 -33
- package/dist/hooks/usePressFeedback.d.ts +5 -2
- package/dist/hooks/usePressFeedback.d.ts.map +1 -1
- package/dist/hooks/usePressFeedback.js +5 -2
- package/dist/hooks/useScrollableArea.d.ts +5 -0
- package/dist/hooks/useScrollableArea.d.ts.map +1 -1
- package/dist/hooks/useScrollableArea.js +104 -11
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +33 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +33 -0
- package/dist/internal/tokenizer-presentation.d.ts +21 -0
- package/dist/internal/tokenizer-presentation.d.ts.map +1 -0
- package/dist/internal/tokenizer-presentation.js +21 -0
- package/dist/internal/touch.d.ts +26 -0
- package/dist/internal/touch.d.ts.map +1 -0
- package/dist/internal/touch.js +28 -0
- package/dist/motion/LayoutChangeSnapshot.d.ts +33 -0
- package/dist/motion/LayoutChangeSnapshot.d.ts.map +1 -0
- package/dist/motion/LayoutChangeSnapshot.js +37 -0
- package/dist/motion/animatedLayout.d.ts +190 -0
- package/dist/motion/animatedLayout.d.ts.map +1 -0
- package/dist/motion/animatedLayout.js +1502 -0
- package/dist/motion/animator.d.ts +240 -0
- package/dist/motion/animator.d.ts.map +1 -0
- package/dist/motion/animator.js +2203 -0
- package/dist/motion/bezier.d.ts +18 -0
- package/dist/motion/bezier.d.ts.map +1 -0
- package/dist/motion/bezier.js +60 -0
- package/dist/motion/coast.d.ts +61 -0
- package/dist/motion/coast.d.ts.map +1 -0
- package/dist/motion/coast.js +107 -0
- package/dist/motion/decay.d.ts +41 -0
- package/dist/motion/decay.d.ts.map +1 -0
- package/dist/motion/decay.js +90 -0
- package/dist/motion/projection.d.ts +36 -0
- package/dist/motion/projection.d.ts.map +1 -0
- package/dist/motion/projection.js +92 -0
- package/dist/motion/reducedMotion.d.ts +25 -0
- package/dist/motion/reducedMotion.d.ts.map +1 -0
- package/dist/motion/reducedMotion.js +85 -0
- package/dist/motion/reducedMotion.stylex.d.ts +19 -0
- package/dist/motion/reducedMotion.stylex.d.ts.map +1 -0
- package/dist/motion/reducedMotion.stylex.js +37 -0
- package/dist/motion/reducedMotionPlan.d.ts +89 -0
- package/dist/motion/reducedMotionPlan.d.ts.map +1 -0
- package/dist/motion/reducedMotionPlan.js +194 -0
- package/dist/motion/resolveSnapPoint.d.ts +52 -0
- package/dist/motion/resolveSnapPoint.d.ts.map +1 -0
- package/dist/motion/resolveSnapPoint.js +135 -0
- package/dist/motion/roleValue.d.ts +33 -0
- package/dist/motion/roleValue.d.ts.map +1 -0
- package/dist/motion/roleValue.js +84 -0
- package/dist/motion/roles.d.ts +79 -0
- package/dist/motion/roles.d.ts.map +1 -0
- package/dist/motion/roles.js +199 -0
- package/dist/motion/rubberBand.d.ts +20 -0
- package/dist/motion/rubberBand.d.ts.map +1 -0
- package/dist/motion/rubberBand.js +91 -0
- package/dist/motion/selectPage.d.ts +26 -0
- package/dist/motion/selectPage.d.ts.map +1 -0
- package/dist/motion/selectPage.js +55 -0
- package/dist/motion/spring.d.ts +193 -0
- package/dist/motion/spring.d.ts.map +1 -0
- package/dist/motion/spring.js +442 -0
- package/dist/motion/transientCopy.d.ts +33 -0
- package/dist/motion/transientCopy.d.ts.map +1 -0
- package/dist/motion/transientCopy.js +314 -0
- package/dist/motion/uikit/gestures.d.ts +642 -0
- package/dist/motion/uikit/gestures.d.ts.map +1 -0
- package/dist/motion/uikit/gestures.js +428 -0
- package/dist/motion/uikit/index.d.ts +24 -0
- package/dist/motion/uikit/index.d.ts.map +1 -0
- package/dist/motion/uikit/index.js +26 -0
- package/dist/motion/uikit/navigation.d.ts +54 -0
- package/dist/motion/uikit/navigation.d.ts.map +1 -0
- package/dist/motion/uikit/navigation.js +83 -0
- package/dist/motion/uikit/scroll.d.ts +116 -0
- package/dist/motion/uikit/scroll.d.ts.map +1 -0
- package/dist/motion/uikit/scroll.js +146 -0
- package/dist/motion/uikit/springs.d.ts +545 -0
- package/dist/motion/uikit/springs.d.ts.map +1 -0
- package/dist/motion/uikit/springs.js +548 -0
- package/dist/motion/uikit/timing.d.ts +202 -0
- package/dist/motion/uikit/timing.d.ts.map +1 -0
- package/dist/motion/uikit/timing.js +201 -0
- package/dist/reset.a11y.chromium.spec.js +1 -0
- package/dist/reset.until-found.a11y.browser.spec.js +1 -0
- package/dist/theme/declarationBoundary.d.ts +13 -0
- package/dist/theme/declarationBoundary.d.ts.map +1 -1
- package/dist/theme/declarationBoundary.js +264 -1
- package/dist/theme/defineTheme.d.ts +111 -11
- package/dist/theme/defineTheme.d.ts.map +1 -1
- package/dist/theme/defineTheme.js +97 -7
- package/dist/theme/derivedVarRegistry.d.ts.map +1 -1
- package/dist/theme/derivedVarRegistry.js +9 -0
- package/dist/theme/generateThemeRules.d.ts +6 -2
- package/dist/theme/generateThemeRules.d.ts.map +1 -1
- package/dist/theme/generateThemeRules.js +468 -24
- package/dist/theme/index.d.ts +2 -2
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +1 -1
- package/dist/theme/statusColor.d.ts +48 -0
- package/dist/theme/statusColor.d.ts.map +1 -0
- package/dist/theme/statusColor.js +203 -0
- package/dist/theme/statusRoleDerivation.d.ts +11 -0
- package/dist/theme/statusRoleDerivation.d.ts.map +1 -0
- package/dist/theme/statusRoleDerivation.js +236 -0
- package/dist/theme/syntax/SyntaxTheme.d.ts +1 -1
- package/dist/theme/syntax/SyntaxTheme.js +1 -1
- package/dist/theme/syntax/defineSyntaxTheme.js +1 -1
- package/dist/theme/syntax/presets.d.ts +1 -1
- package/dist/theme/syntax/presets.js +1 -1
- package/dist/theme/syntax/tokens.d.ts +1 -1
- package/dist/theme/syntax/tokens.js +1 -1
- package/dist/theme/themeAdaptations.d.ts +25 -1
- package/dist/theme/themeAdaptations.d.ts.map +1 -1
- package/dist/theme/themeAdaptations.js +30 -1
- package/dist/theme/tokens.d.ts.map +1 -1
- package/dist/theme/tokens.js +16 -1
- package/dist/theme/tokens.stylex.d.ts +42 -2
- package/dist/theme/tokens.stylex.d.ts.map +1 -1
- package/dist/theme/tokens.stylex.js +54 -3
- package/dist/theme/useTheme.d.ts +4 -2
- package/dist/theme/useTheme.d.ts.map +1 -1
- package/dist/theme/useTheme.js +10 -4
- package/dist/utils/edgeAutoscroll.d.ts +53 -0
- package/dist/utils/edgeAutoscroll.d.ts.map +1 -0
- package/dist/utils/edgeAutoscroll.js +81 -0
- package/dist/utils/hitArea.d.ts +72 -0
- package/dist/utils/hitArea.d.ts.map +1 -0
- package/dist/utils/hitArea.js +681 -0
- package/dist/utils/interactionOverlay.stylex.d.ts +4 -1
- package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
- package/dist/utils/interactionOverlay.stylex.js +4 -1
- package/dist/utils/pressFeedback.d.ts +5 -1
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +285 -54
- package/dist/utils/pressGesture.d.ts +13 -1
- package/dist/utils/pressGesture.d.ts.map +1 -1
- package/dist/utils/pressGesture.js +40 -1
- package/dist/utils/touchPresentation.d.ts +48 -0
- package/dist/utils/touchPresentation.d.ts.map +1 -0
- package/dist/utils/touchPresentation.js +133 -0
- package/locales/af-ZA.json +1 -1
- package/locales/ar-SA.json +1 -1
- package/locales/ca-ES.json +1 -1
- package/locales/cs-CZ.json +1 -1
- package/locales/da-DK.json +1 -1
- package/locales/de-DE.json +1 -1
- package/locales/el-GR.json +1 -1
- package/locales/en.json +132 -0
- package/locales/es-ES.json +1 -1
- package/locales/fi-FI.json +1 -1
- package/locales/fr-FR.json +1 -1
- package/locales/he-IL.json +1 -1
- package/locales/hu-HU.json +1 -1
- package/locales/it-IT.json +1 -1
- package/locales/ja-JP.json +1 -1
- package/locales/ko-KR.json +1 -1
- package/locales/nl-NL.json +1 -1
- package/locales/no-NO.json +1 -1
- package/locales/pl-PL.json +1 -1
- package/locales/pseudo.json +99 -0
- package/locales/pt-BR.json +1 -1
- package/locales/pt-PT.json +1 -1
- package/locales/ro-RO.json +1 -1
- package/locales/ru-RU.json +1 -1
- package/locales/sr-SP.json +1 -1
- package/locales/sv-SE.json +1 -1
- package/locales/tr-TR.json +1 -1
- package/locales/uk-UA.json +1 -1
- package/locales/vi-VN.json +1 -1
- package/locales/zh-CN.json +1 -1
- package/locales/zh-TW.json +1 -1
- package/package.json +63 -8
- package/src/AlertDialog/AlertDialog.spec.md +85 -31
- package/src/AlertDialog/AlertDialog.tsx +1 -1
- package/src/AlertDialog/__tests__/AlertDialog.a11y.chromium.spec.ts +1 -0
- package/src/AppShell/AppShell.spec.md +334 -0
- package/src/AppShell/AppShell.tsx +170 -2
- package/src/AspectRatio/AspectRatio.spec.md +179 -0
- package/src/AspectRatio/__tests__/AspectRatioFitLayers.a11y.browser.spec.ts +1 -0
- package/src/Avatar/Avatar.spec.md +253 -0
- package/src/Avatar/AvatarStatusDot.spec.md +93 -79
- package/src/Avatar/AvatarStatusDot.test.tsx +22 -0
- package/src/Avatar/AvatarStatusDot.tsx +2 -2
- package/src/AvatarGroup/AvatarGroup.spec.md +205 -0
- package/src/AvatarGroup/AvatarGroupOverflow.spec.md +123 -120
- package/src/Badge/Badge.spec.md +207 -0
- package/src/Badge/Badge.test.tsx +13 -0
- package/src/Badge/Badge.tsx +38 -2
- package/src/Banner/Banner.spec.md +41 -28
- package/src/Banner/Banner.test.tsx +118 -16
- package/src/Banner/Banner.tsx +94 -7
- package/src/Blockquote/Blockquote.spec.md +171 -0
- package/src/BottomSheet/BottomSheet.doc.mjs +106 -24
- package/src/BottomSheet/BottomSheet.spec.md +271 -40
- package/src/BottomSheet/BottomSheet.test.tsx +491 -5
- package/src/BottomSheet/BottomSheet.tsx +544 -145
- package/src/BottomSheet/BottomSheetHostContext.ts +44 -0
- package/src/BottomSheet/BottomSheetPanel.test.tsx +73 -19
- package/src/BottomSheet/BottomSheetPanel.tsx +178 -63
- package/src/BottomSheet/BottomSheetReplace.test.tsx +1638 -0
- package/src/BottomSheet/BottomSheetStacking.announce.test.tsx +246 -0
- package/src/BottomSheet/BottomSheetStacking.test.tsx +3184 -0
- package/src/BottomSheet/BottomSheetSwitcher.doc.mjs +27 -31
- package/src/BottomSheet/BottomSheetSwitcher.spec.md +138 -43
- package/src/BottomSheet/BottomSheetSwitcher.tsx +275 -26
- package/src/BottomSheet/BottomSheetSwitcherContext.ts +6 -0
- package/src/BottomSheet/__tests__/BottomSheetDrag.a11y.chromium.spec.ts +1 -0
- package/src/BottomSheet/__tests__/BottomSheetFocusReturn.a11y.browser.spec.ts +1 -0
- package/src/BottomSheet/__tests__/BottomSheetKeyboard.a11y.browser.spec.ts +4 -1
- package/src/BottomSheet/__tests__/BottomSheetNativeModal.a11y.browser.spec.ts +1 -0
- package/src/BottomSheet/__tests__/BottomSheetPinchZoom.a11y.chromium.spec.ts +1 -0
- package/src/BottomSheet/__tests__/BottomSheetToastOutlet.a11y.chromium.spec.ts +83 -0
- package/src/BottomSheet/bottomSheetEscape.ts +21 -0
- package/src/BottomSheet/bottomSheetStack.ts +2054 -0
- package/src/BottomSheet/useSheetGestures.ts +68 -12
- package/src/Breadcrumbs/BreadcrumbItem.spec.md +104 -60
- package/src/Breadcrumbs/BreadcrumbItem.tsx +30 -1
- package/src/Breadcrumbs/Breadcrumbs.spec.md +165 -0
- package/src/Breadcrumbs/Breadcrumbs.test.tsx +90 -0
- package/src/Breadcrumbs/__tests__/Breadcrumbs.a11y.chromium.spec.ts +1 -0
- package/src/Button/Button.spec.md +322 -0
- package/src/Button/Button.test.tsx +8 -1
- package/src/Button/Button.tsx +36 -7
- package/src/Button/__tests__/Button.a11y.chromium.spec.ts +1 -0
- package/src/ButtonGroup/ButtonGroup.spec.md +220 -0
- package/src/Calendar/__tests__/Calendar.a11y.chromium.spec.ts +1 -0
- package/src/Card/Card.spec.md +205 -0
- package/src/Carousel/__tests__/Carousel.a11y.chromium.spec.ts +1 -0
- package/src/Center/Center.spec.md +104 -124
- package/src/Chat/ChatComposer.test.tsx +54 -0
- package/src/Chat/ChatComposer.tsx +41 -27
- package/src/Chat/ChatComposerInput.test.tsx +165 -21
- package/src/Chat/ChatComposerInput.tsx +73 -16
- package/src/Chat/ChatMessageMetadata.tsx +1 -1
- package/src/Chat/ChatPastedTextToken.test.tsx +71 -0
- package/src/Chat/ChatPastedTextToken.tsx +8 -7
- package/src/Chat/ChatToolCalls.tsx +5 -5
- package/src/Chat/__tests__/ChatLayoutScrollButton.a11y.chromium.spec.ts +22 -4
- package/src/Chat/__tests__/ChatLayoutScrollButtonSurface.a11y.chromium.spec.ts +1 -0
- package/src/Chat/__tests__/ChatMessageList.a11y.chromium.spec.ts +1 -0
- package/src/Chat/__tests__/ChatMessageMetadata.a11y.chromium.spec.ts +1 -0
- package/src/Chat/__tests__/ChatSendButton.a11y.chromium.spec.ts +1 -0
- package/src/Chat/__tests__/ChatSystemMessage.a11y.chromium.spec.ts +1 -0
- package/src/Chat/__tests__/ChatTokenizedText.a11y.chromium.spec.ts +1 -0
- package/src/Chat/__tests__/useChatStreamScroll.a11y.chromium.spec.ts +1 -0
- package/src/CheckboxInput/CheckboxInput.spec.md +97 -66
- package/src/CheckboxInput/__tests__/Checkbox.a11y.chromium.spec.ts +1 -0
- package/src/CheckboxList/CheckboxList.spec.md +92 -78
- package/src/CheckboxList/CheckboxListItem.spec.md +86 -60
- package/src/CheckboxList/__tests__/CheckboxList.a11y.chromium.spec.ts +1 -0
- package/src/ClickableCard/ClickableCard.doc.mjs +1 -2
- package/src/ClickableCard/ClickableCard.spec.md +124 -128
- package/src/ClickableCard/ClickableCard.test.tsx +14 -3
- package/src/ClickableCard/ClickableCard.tsx +44 -28
- package/src/Code/Code.spec.md +30 -32
- package/src/CodeBlock/CodeBlock.doc.mjs +21 -4
- package/src/CodeBlock/CodeBlock.spec.md +96 -61
- package/src/CodeBlock/CodeBlock.test.tsx +97 -1
- package/src/CodeBlock/CodeBlock.tsx +132 -22
- package/src/CodeBlock/CodeLanguage.test.tsx +173 -0
- package/src/CodeBlock/__tests__/CodeBlockCopyClearance.a11y.chromium.spec.ts +290 -0
- package/src/CodeBlock/__tests__/CodeBlockLanguages.a11y.chromium.spec.ts +64 -0
- package/src/CodeBlock/__tests__/CodeBlockOverflowStop.a11y.chromium.spec.ts +1 -0
- package/src/CodeBlock/__tests__/DiffRowPaint.a11y.chromium.spec.ts +1 -0
- package/src/CodeBlock/grammar.ts +291 -0
- package/src/CodeBlock/index.ts +7 -0
- package/src/CodeBlock/languages/dockerfile.ts +43 -0
- package/src/CodeBlock/languages/graphql.ts +30 -0
- package/src/CodeBlock/languages/java.ts +28 -0
- package/src/CodeBlock/languages/lua.ts +21 -0
- package/src/CodeBlock/languages/objective-c.ts +26 -0
- package/src/CodeBlock/languages/powershell.ts +31 -0
- package/src/CodeBlock/languages/ruby.ts +29 -0
- package/src/CodeBlock/languages/thrift.ts +32 -0
- package/src/CodeBlock/languages/toml.ts +36 -0
- package/src/CodeBlock/languages.test.ts +402 -0
- package/src/CodeBlock/tokenizer.ts +176 -16
- package/src/CodeBlock/tokenizerBudget.test.ts +112 -0
- package/src/Collapsible/Collapsible.doc.mjs +6 -0
- package/src/Collapsible/Collapsible.spec.md +26 -23
- package/src/Collapsible/Collapsible.tsx +121 -2
- package/src/Collapsible/__tests__/Collapsible.a11y.chromium.spec.ts +1 -0
- package/src/Collapsible/__tests__/CollapsibleGroup.a11y.chromium.spec.ts +1 -0
- package/src/Collapsible/__tests__/CollapsibleGroupAccordion.a11y.chromium.spec.ts +1 -0
- package/src/CommandPalette/CommandPalette.perf.test.ts +8 -4
- package/src/CommandPalette/CommandPalette.tsx +17 -1
- package/src/CommandPalette/CommandPaletteEmpty.doc.mjs +6 -3
- package/src/CommandPalette/CommandPaletteEmpty.spec.md +190 -0
- package/src/CommandPalette/CommandPaletteEmpty.tsx +4 -0
- package/src/CommandPalette/CommandPaletteInput.tsx +21 -2
- package/src/CommandPalette/__tests__/CommandPalette.a11y.chromium.spec.ts +1 -0
- package/src/CommandPalette/__tests__/CommandPaletteEmptyAudit.a11y.chromium.spec.ts +715 -0
- package/src/CommandPalette/__tests__/CommandPaletteFooter.a11y.chromium.spec.ts +3 -2
- package/src/CommandPalette/__tests__/CommandPaletteInputAudit.a11y.chromium.spec.ts +1 -0
- package/src/CommandPalette/__tests__/CommandPaletteItemAudit.a11y.chromium.spec.ts +1 -0
- package/src/CommandPalette/busyStartSettle.ts +26 -0
- package/src/ComplexSelector/ComplexSelector.doc.mjs +1 -1
- package/src/ComplexSelector/ComplexSelector.focusableDisabled.test.tsx +1 -1
- package/src/ComplexSelector/ComplexSelector.fr10.test.tsx +9 -9
- package/src/ComplexSelector/ComplexSelector.spec.md +161 -107
- package/src/ComplexSelector/ComplexSelector.test.tsx +236 -17
- package/src/ComplexSelector/ComplexSelector.tsx +69 -4
- package/src/ComplexSelector/__tests__/ComplexSelector.a11y.chromium.spec.ts +965 -0
- package/src/ContextMenu/ContextMenu.doc.mjs +1 -1
- package/src/ContextMenu/ContextMenu.spec.md +38 -30
- package/src/ContextMenu/ContextMenu.test.tsx +189 -11
- package/src/ContextMenu/ContextMenu.tsx +75 -17
- package/src/ContextMenu/__tests__/ContextMenuAudit.a11y.chromium.spec.ts +1 -0
- package/src/ContextMenu/__tests__/ContextMenuCursorAnchor.a11y.browser.spec.ts +1 -0
- package/src/ContextMenu/__tests__/ContextMenuLongPress.a11y.chromium.spec.ts +117 -0
- package/src/DateInput/DateInput.tsx +9 -4
- package/src/DateInput/DateInputTouch.test.tsx +10 -1
- package/src/DateInput/NativeDateField.tsx +2 -1
- package/src/DateInput/TouchDateField.tsx +2 -1
- package/src/DateInput/Wheel.tsx +4 -1
- package/src/DateInput/__tests__/DateInputAudit.a11y.chromium.spec.ts +1 -0
- package/src/DateInput/__tests__/WheelPinchZoom.a11y.chromium.spec.ts +171 -0
- package/src/Dialog/Dialog.doc.mjs +201 -47
- package/src/Dialog/Dialog.spec.md +20 -4
- package/src/Dialog/Dialog.tsx +37 -10
- package/src/Dialog/__tests__/Dialog.a11y.browser.spec.ts +1 -0
- package/src/Dialog/__tests__/Dialog.a11y.chromium.spec.ts +1 -0
- package/src/Dialog/__tests__/Dialog.reduced-motion.a11y.browser.spec.ts +252 -0
- package/src/Divider/Divider.spec.md +79 -70
- package/src/Drawer/Drawer.tsx +38 -35
- package/src/Drawer/__tests__/DrawerAudit.a11y.chromium.spec.ts +1 -0
- package/src/Drawer/__tests__/DrawerHeaderAudit.a11y.chromium.spec.ts +1 -0
- package/src/DropdownMenu/DropdownMenu.spec.md +14 -6
- package/src/DropdownMenu/DropdownMenu.ssr.test.tsx +44 -8
- package/src/DropdownMenu/DropdownMenu.test.tsx +107 -5
- package/src/DropdownMenu/DropdownMenu.tsx +51 -34
- package/src/DropdownMenu/DropdownMenuGroup.doc.mjs +2 -2
- package/src/DropdownMenu/DropdownMenuGroup.tsx +12 -6
- package/src/DropdownMenu/DropdownMenuItem.tsx +5 -5
- package/src/DropdownMenu/DropdownMenuRadioItem.doc.mjs +5 -2
- package/src/DropdownMenu/DropdownMenuRadioItem.spec.md +226 -0
- package/src/DropdownMenu/DropdownMenuRadioItem.tsx +32 -16
- package/src/DropdownMenu/DropdownMenuSelectable.test.tsx +158 -0
- package/src/DropdownMenu/DropdownMenuSheetFirstOpen.test.tsx +72 -0
- package/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs +9 -0
- package/src/DropdownMenu/DropdownMenuSubMenu.spec.md +225 -0
- package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +105 -0
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +6 -6
- package/src/DropdownMenu/MenuBottomSheet.tsx +42 -7
- package/src/DropdownMenu/MenuBottomSheetActionList.tsx +3 -3
- package/src/DropdownMenu/__tests__/DropdownMenuDividerAudit.a11y.chromium.spec.ts +1 -0
- package/src/DropdownMenu/__tests__/DropdownMenuDrillIn.a11y.chromium.spec.ts +1 -0
- package/src/DropdownMenu/__tests__/DropdownMenuFocusReturn.a11y.browser.spec.ts +1 -0
- package/src/DropdownMenu/__tests__/DropdownMenuGroupAudit.a11y.chromium.spec.ts +1 -0
- package/src/DropdownMenu/__tests__/DropdownMenuItemAudit.a11y.chromium.spec.ts +1 -0
- package/src/DropdownMenu/__tests__/DropdownMenuRadioGroupAudit.a11y.chromium.spec.ts +1 -0
- package/src/DropdownMenu/__tests__/DropdownMenuRadioItemAudit.a11y.chromium.spec.ts +540 -0
- package/src/DropdownMenu/__tests__/DropdownMenuSubMenuAudit.a11y.chromium.spec.ts +671 -0
- package/src/DropdownMenu/__tests__/Menu.a11y.chromium.spec.ts +1 -0
- package/src/DropdownMenu/__tests__/MenuButton.a11y.chromium.spec.ts +1 -0
- package/src/DropdownMenu/__tests__/MenuHeaderFooter.a11y.chromium.spec.ts +1 -0
- package/src/DropdownMenu/__tests__/MenuHoverFocus.a11y.chromium.spec.ts +238 -0
- package/src/DropdownMenu/__tests__/MenuPinchZoom.a11y.chromium.spec.ts +1 -0
- package/src/DropdownMenu/__tests__/MenuPress.a11y.chromium.spec.ts +1 -0
- package/src/DropdownMenu/__tests__/SubMenuHeaderFooter.a11y.chromium.spec.ts +1 -0
- package/src/DropdownMenu/lazyMenuBottomSheet.ts +28 -2
- package/src/DropdownMenu/menuBottomSheet.stylex.ts +33 -0
- package/src/DropdownMenu/menuItemHover.ts +13 -1
- package/src/DropdownMenu/menuTouchAction.stylex.ts +28 -0
- package/src/DropdownMenu/modules/useMenuPress.spec.md +90 -62
- package/src/DropdownMenu/useMenuDrillIn.tsx +7 -5
- package/src/EmptyState/EmptyState.announce.test.tsx +227 -0
- package/src/EmptyState/EmptyState.doc.mjs +1 -1
- package/src/EmptyState/EmptyState.spec.md +22 -14
- package/src/EmptyState/EmptyState.test.tsx +8 -8
- package/src/EmptyState/EmptyState.tsx +7 -5
- package/src/Field/Field.spec.md +57 -48
- package/src/Field/Field.tsx +1 -1
- package/src/Field/FieldLabel.spec.md +70 -59
- package/src/Field/FieldLabel.tsx +1 -1
- package/src/Field/PanelSearchInput.tsx +23 -13
- package/src/Field/__tests__/FieldLabelAudit.a11y.chromium.spec.ts +1 -0
- package/src/Field/inputDisabledFocus.ts +28 -0
- package/src/Field/inputStyles.stylex.ts +15 -15
- package/src/FieldStatus/FieldStatus.test.tsx +12 -0
- package/src/FieldStatus/FieldStatus.tsx +12 -3
- package/src/FieldStatus/__tests__/StatusMessage.a11y.chromium.spec.ts +1 -0
- package/src/FileInput/FileInput.doc.mjs +1 -1
- package/src/FileInput/FileInput.test.tsx +102 -0
- package/src/FileInput/FileInput.tsx +18 -12
- package/src/FormLayout/FormLayout.spec.md +69 -51
- package/src/Grid/Grid.spec.md +72 -69
- package/src/Grid/GridSpan.spec.md +158 -0
- package/src/Heading/Heading.spec.md +198 -0
- package/src/HoverCard/HoverCard.spec.md +244 -0
- package/src/HoverCard/HoverCard.test.tsx +93 -3
- package/src/Icon/Icon.doc.mjs +67 -5
- package/src/Icon/Icon.test.tsx +548 -9
- package/src/Icon/Icon.tsx +79 -15
- package/src/Icon/IconSize.stylex.ts +27 -11
- package/src/Icon/globalIconRegistry.test.tsx +395 -3
- package/src/Icon/globalIconRegistry.tsx +184 -36
- package/src/Icon/index.ts +29 -1
- package/src/Icon/useIcon.ts +5 -1
- package/src/IconButton/IconButton.spec.md +197 -0
- package/src/IconButton/IconButton.test.tsx +5 -2
- package/src/InputGroup/InputGroup.spec.md +199 -0
- package/src/InputGroup/InputGroup.test.tsx +120 -0
- package/src/InputGroup/InputGroup.tsx +59 -52
- package/src/InputGroup/InputGroupInternalContext.ts +15 -0
- package/src/InputGroup/InputGroupText.spec.md +139 -0
- package/src/InputGroup/InputGroupText.tsx +2 -0
- package/src/InputGroup/groupStyles.ts +22 -11
- package/src/Item/Item.test.tsx +158 -1
- package/src/Item/Item.tsx +42 -7
- package/src/Item/ItemMarkerColumns.a11y.chromium.spec.ts +211 -0
- package/src/Item/ItemMarkerColumnsContext.tsx +20 -0
- package/src/Item/ItemSwipeLayer.tsx +9 -0
- package/src/Item/__tests__/ItemSwipeActions.a11y.chromium.spec.ts +1 -0
- package/src/Item/__tests__/ItemSwipePinchZoom.a11y.chromium.spec.ts +186 -0
- package/src/Item/useSwipeAction.ts +71 -5
- package/src/Kbd/Kbd.test.tsx +95 -0
- package/src/Kbd/Kbd.tsx +30 -23
- package/src/Layer/LayerProvider.spec.md +149 -0
- package/src/Layer/__tests__/LayerReducedMotion.a11y.chromium.spec.ts +176 -0
- package/src/Layer/__tests__/TouchTrigger.a11y.chromium.spec.ts +200 -0
- package/src/Layer/layerAnimations.stylex.ts +22 -2
- package/src/Layer/layerDismissalInvariants.test.tsx +9 -0
- package/src/Layer/layerSlideRules.ts +141 -8
- package/src/Layer/layerStack.ts +129 -62
- package/src/Layer/modalOutlet.ts +156 -15
- package/src/Layer/preserveAnimations.ts +304 -0
- package/src/Layer/useLayer.doc.mjs +1 -1
- package/src/Layer/useLayer.test.tsx +850 -0
- package/src/Layer/useLayer.tsx +644 -58
- package/src/Layer/useLayerDismissal.test.tsx +85 -2
- package/src/Layer/useLayerDismissal.ts +12 -9
- package/src/Layer/useTouchTrigger.ts +95 -41
- package/src/Layout/Layout.tsx +18 -0
- package/src/Layout/LayoutContent.tsx +5 -14
- package/src/Layout/LayoutFooter.tsx +2 -0
- package/src/Layout/LayoutHeader.tsx +2 -0
- package/src/Layout/__tests__/Layout.a11y.chromium.spec.ts +1 -0
- package/src/Layout/layoutEdges.stylex.ts +25 -0
- package/src/Lightbox/Lightbox.spec.md +9 -8
- package/src/Lightbox/Lightbox.test.tsx +83 -0
- package/src/Lightbox/Lightbox.tsx +149 -125
- package/src/Lightbox/LightboxKeyboard.a11y.browser.spec.ts +78 -0
- package/src/Lightbox/LightboxViewport.a11y.browser.spec.ts +70 -0
- package/src/Link/Link.spec.md +229 -0
- package/src/Link/LinkProvider.spec.md +167 -0
- package/src/Link/__tests__/Link.a11y.chromium.spec.ts +1 -0
- package/src/Link/__tests__/Link.navigation.a11y.chromium.spec.ts +1 -0
- package/src/List/List.spec.md +113 -34
- package/src/List/List.tsx +13 -1
- package/src/List/ListContext.tsx +19 -5
- package/src/List/ListItem.doc.mjs +3 -3
- package/src/List/ListItem.tsx +97 -28
- package/src/List/ListMarkers.a11y.chromium.spec.ts +904 -0
- package/src/Markdown/Markdown.codeLanguages.test.tsx +137 -0
- package/src/Markdown/Markdown.doc.mjs +12 -0
- package/src/Markdown/Markdown.fr23.bench.ts +3 -1
- package/src/Markdown/Markdown.fr23.perf.test.ts +45 -3
- package/src/Markdown/Markdown.fr23.sampling.ts +13 -4
- package/src/Markdown/Markdown.spec.md +71 -59
- package/src/Markdown/Markdown.test.tsx +50 -0
- package/src/Markdown/Markdown.tsx +61 -8
- package/src/Markdown/MarkdownTable.a11y.chromium.spec.ts +1 -0
- package/src/Markdown/__tests__/MarkdownNesting.a11y.chromium.spec.ts +1 -0
- package/src/MobileNav/MobileNav.doc.mjs +2 -2
- package/src/MobileNav/MobileNav.spec.md +161 -64
- package/src/MobileNav/MobileNav.test.tsx +27 -10
- package/src/MobileNav/MobileNav.tsx +51 -38
- package/src/MobileNav/MobileNavPinchZoom.a11y.chromium.spec.ts +1 -0
- package/src/MobileNav/MobileNavToggle.test.tsx +63 -0
- package/src/MobileNav/MobileNavToggle.tsx +13 -5
- package/src/MobileNav/__tests__/MobileNavWidth.a11y.chromium.spec.ts +103 -0
- package/src/MoreMenu/MoreMenu.doc.mjs +2 -2
- package/src/MoreMenu/MoreMenu.spec.md +88 -53
- package/src/MultiSelector/CreateRow.a11y.chromium.spec.ts +67 -9
- package/src/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.ts +1 -0
- package/src/MultiSelector/MultiSelector.test.tsx +122 -10
- package/src/MultiSelector/MultiSelector.tsx +24 -4
- package/src/MultiSelector/OptionActions.a11y.chromium.spec.ts +1 -0
- package/src/MultiSelector/__tests__/MultiSelector.a11y.chromium.spec.ts +1 -0
- package/src/NavIcon/NavIcon.spec.md +66 -38
- package/src/NavMenu/NavHeadingMenu.spec.md +104 -46
- package/src/NavMenu/NavHeadingMenu.test.tsx +276 -2
- package/src/NavMenu/NavHeadingMenu.tsx +42 -4
- package/src/NavMenu/NavHeadingMenuItem.tsx +60 -6
- package/src/NavMenu/NavMenuContext.tsx +11 -0
- package/src/NavMenu/__tests__/NavMenusSlideSelection.a11y.chromium.spec.ts +137 -0
- package/src/NumberInput/NumberInput.doc.mjs +6 -6
- package/src/NumberInput/NumberInput.spec.md +248 -0
- package/src/NumberInput/NumberInput.test.tsx +187 -14
- package/src/NumberInput/NumberInput.tsx +86 -24
- package/src/NumberInput/__tests__/NumberInput.a11y.chromium.spec.ts +1 -0
- package/src/Overlay/Overlay.doc.mjs +2 -2
- package/src/Overlay/Overlay.test.tsx +72 -4
- package/src/Overlay/Overlay.tsx +18 -8
- package/src/Pagination/Pagination.test.tsx +2 -2
- package/src/Popover/Popover.doc.mjs +38 -2
- package/src/Popover/Popover.spec.md +90 -11
- package/src/Popover/Popover.test.tsx +340 -2
- package/src/Popover/Popover.tsx +401 -35
- package/src/Popover/PopoverPresentation.test.tsx +952 -0
- package/src/Popover/__tests__/PopoverSecondDocument.a11y.chromium.spec.ts +205 -0
- package/src/Popover/index.ts +5 -1
- package/src/Popover/lazyPopoverBottomSheet.ts +57 -0
- package/src/Popover/usePopover.tsx +11 -5
- package/src/PowerSearch/PowerSearch.spec.md +423 -53
- package/src/PowerSearch/PowerSearch.test.tsx +77 -1
- package/src/PowerSearch/PowerSearch.tsx +7 -5
- package/src/ProgressBar/ProgressBar.test.tsx +12 -0
- package/src/ProgressBar/ProgressBar.tsx +18 -0
- package/src/ProgressBar/__tests__/ProgressBar.a11y.chromium.spec.ts +1 -0
- package/src/RadioList/RadioList.spec.md +227 -0
- package/src/RadioList/RadioList.test.tsx +34 -7
- package/src/RadioList/RadioListItem.press.source-build.test.mjs +80 -0
- package/src/RadioList/RadioListItem.spec.md +223 -0
- package/src/RadioList/RadioListItem.tsx +26 -12
- package/src/RadioList/__tests__/RadioGroup.a11y.chromium.spec.ts +1 -0
- package/src/Resizable/__tests__/ResizeHandle.a11y.chromium.spec.ts +1 -0
- package/src/ScrollableArea/ScrollableArea.spec.md +6 -5
- package/src/ScrollableArea/ScrollableArea.test.tsx +5 -0
- package/src/ScrollableArea/ScrollableArea.tsx +4 -0
- package/src/Section/Section.spec.md +102 -44
- package/src/SegmentedControl/SegmentedControl.spec.md +162 -53
- package/src/SegmentedControl/SegmentedControl.test.tsx +46 -0
- package/src/SegmentedControl/SegmentedControl.tsx +7 -3
- package/src/SegmentedControl/SegmentedControlItem.spec.md +206 -0
- package/src/SelectableCard/SelectableCard.doc.mjs +7 -6
- package/src/SelectableCard/SelectableCard.spec.md +230 -0
- package/src/SelectableCard/SelectableCard.test.tsx +11 -1
- package/src/SelectableCard/SelectableCard.tsx +49 -33
- package/src/Selector/Selector.sheetActiveDescendant.test.tsx +95 -0
- package/src/Selector/Selector.spec.md +12 -4
- package/src/Selector/Selector.test.tsx +114 -8
- package/src/Selector/Selector.tsx +30 -6
- package/src/Selector/__tests__/ComboboxField.a11y.chromium.spec.ts +458 -0
- package/src/Selector/__tests__/EmptyStateAnnouncement.a11y.chromium.spec.ts +1 -0
- package/src/Selector/__tests__/Listbox.a11y.chromium.spec.ts +1 -0
- package/src/Selector/__tests__/Selector.a11y.chromium.spec.ts +1 -0
- package/src/Selector/__tests__/Selector.combobox.a11y.chromium.spec.ts +1 -0
- package/src/Selector/hooks.ts +234 -10
- package/src/Selector/useCombobox.doc.mjs +156 -9
- package/src/Selector/useCombobox.public.test.tsx +89 -0
- package/src/Selector/useCombobox.test.tsx +444 -0
- package/src/SideNav/SideNav.spec.md +50 -30
- package/src/SideNav/SideNav.test.tsx +425 -25
- package/src/SideNav/SideNav.tsx +85 -1
- package/src/SideNav/SideNavCollapseButton.spec.md +161 -0
- package/src/SideNav/SideNavHeading.spec.md +226 -0
- package/src/SideNav/SideNavHeading.tsx +102 -6
- package/src/SideNav/SideNavItem.spec.md +246 -0
- package/src/SideNav/SideNavItem.tsx +40 -9
- package/src/SideNav/SideNavRailMotion.test.tsx +620 -0
- package/src/SideNav/SideNavSection.spec.md +153 -0
- package/src/SideNav/__tests__/SideNavRailMotion.interaction.browser.spec.ts +417 -0
- package/src/SideNav/railMotion.ts +315 -0
- package/src/Skeleton/Skeleton.spec.md +99 -42
- package/src/Skeleton/Skeleton.test.tsx +108 -1
- package/src/Skeleton/Skeleton.tsx +30 -2
- package/src/Slider/Slider.fr10.test.tsx +34 -0
- package/src/Slider/Slider.test.tsx +172 -0
- package/src/Slider/Slider.tsx +70 -14
- package/src/Slider/__tests__/Slider.a11y.chromium.spec.ts +1 -0
- package/src/Spinner/Spinner.spec.md +231 -0
- package/src/Stack/Stack.spec.md +104 -56
- package/src/StatusDot/StatusDot.spec.md +139 -51
- package/src/StatusDot/StatusDot.test.tsx +13 -0
- package/src/StatusDot/StatusDot.tsx +27 -0
- package/src/Stepper/Step.spec.md +206 -0
- package/src/Stepper/Step.tsx +19 -3
- package/src/Stepper/Stepper.test.tsx +50 -0
- package/src/Switch/Switch.focusRing.source-build.test.mjs +81 -0
- package/src/Switch/Switch.spec.md +150 -66
- package/src/Switch/Switch.tsx +11 -9
- package/src/Switch/__tests__/Switch.a11y.chromium.spec.ts +1 -0
- package/src/Switch/switch.markers.stylex.ts +7 -2
- package/src/TabList/Tab.spec.md +201 -0
- package/src/TabList/Tab.tsx +7 -1
- package/src/TabList/TabList.doc.mjs +3 -3
- package/src/TabList/TabList.test.tsx +27 -0
- package/src/TabList/TabMenu.spec.md +198 -0
- package/src/TabList/TabMenu.tsx +24 -1
- package/src/TabList/__tests__/TabListOverflow.interaction.browser.spec.ts +99 -0
- package/src/TabList/__tests__/Tabs.a11y.chromium.spec.ts +1 -0
- package/src/Table/Table.spec.md +54 -30
- package/src/Table/TableCell.tsx +9 -0
- package/src/Table/TableHeaderCell.tsx +2 -0
- package/src/Table/TableRow.tsx +3 -0
- package/src/Table/__tests__/Table.a11y.chromium.spec.ts +129 -0
- package/src/Table/__tests__/Table.a11y.contracts.ts +35 -0
- package/src/Table/__tests__/Table.a11y.renders.tsx +112 -0
- package/src/Table/__tests__/Table.a11y.states.ts +140 -0
- package/src/Table/__tests__/Table.a11y.test.tsx +198 -0
- package/src/Table/__tests__/TableMinWidth.a11y.chromium.spec.ts +1 -0
- package/src/Table/__tests__/TableRowGlide.a11y.browser.spec.ts +382 -0
- package/src/Table/__tests__/TableScroll.a11y.chromium.spec.ts +1 -0
- package/src/Table/__tests__/TableStickyDividers.a11y.browser.spec.ts +560 -0
- package/src/Table/glidingDivider.ts +336 -0
- package/src/Table/plugins/columnResize/useTableColumnResize.tsx +23 -8
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.glide.test.tsx +280 -0
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.test.tsx +91 -9
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +471 -10
- package/src/Table/plugins/rowStatus/useTableRowStatus.spec.md +4 -4
- package/src/Table/plugins/sortable/__tests__/useTableSortable.a11y.test.tsx +174 -0
- package/src/Table/plugins/sortable/__tests__/useTableSortable.a11y.ts +86 -0
- package/src/Table/plugins/sortable/useTableSortable.test.tsx +0 -12
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.test.tsx +51 -1
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +312 -12
- package/src/Table/rowDivider.ts +154 -0
- package/src/Table/useTableRowExpansion.doc.mjs +8 -0
- package/src/Text/Text.spec.md +114 -127
- package/src/TextArea/TextArea.doc.mjs +6 -6
- package/src/TextArea/TextArea.spec.md +164 -64
- package/src/TextArea/TextArea.test.tsx +65 -6
- package/src/TextArea/TextArea.tsx +27 -15
- package/src/TextInput/TextInput.doc.mjs +8 -8
- package/src/TextInput/TextInput.spec.md +260 -0
- package/src/TextInput/TextInput.test.tsx +126 -10
- package/src/TextInput/TextInput.tsx +57 -23
- package/src/TextInput/__tests__/TextInput.a11y.chromium.spec.ts +1 -0
- package/src/Thumbnail/Thumbnail.doc.mjs +1 -2
- package/src/Thumbnail/Thumbnail.spec.md +244 -0
- package/src/Thumbnail/Thumbnail.test.tsx +120 -7
- package/src/Thumbnail/Thumbnail.tsx +77 -31
- package/src/TimeInput/TimeInput.spec.md +273 -0
- package/src/TimeInput/TimeInput.tsx +12 -4
- package/src/TimeInput/TouchTimeField.tsx +2 -1
- package/src/Timestamp/Timestamp.spec.md +252 -0
- package/src/Toast/Toast.spec.md +300 -0
- package/src/Toast/ToastViewport.modalHost.test.tsx +630 -5
- package/src/Toast/ToastViewport.test.tsx +137 -0
- package/src/Toast/ToastViewport.tsx +63 -6
- package/src/ToggleButton/ToggleButton.spec.md +256 -0
- package/src/ToggleButton/ToggleButtonGroup.spec.md +195 -0
- package/src/ToggleButton/__tests__/ToggleButton.a11y.chromium.spec.ts +1 -0
- package/src/Token/Token.spec.md +271 -0
- package/src/Token/__tests__/TokenRemoveTarget.a11y.chromium.spec.ts +1 -0
- package/src/Tokenizer/Tokenizer.props-type.test.tsx +126 -0
- package/src/Tokenizer/Tokenizer.spec.md +313 -72
- package/src/Tokenizer/Tokenizer.ssr.test.tsx +196 -0
- package/src/Tokenizer/Tokenizer.test.tsx +44 -8
- package/src/Tokenizer/Tokenizer.tsx +586 -41
- package/src/Tokenizer/TokenizerBottomSheet.test.tsx +2719 -0
- package/src/Tokenizer/TokenizerBottomSheet.tsx +957 -0
- package/src/Tokenizer/__tests__/TokenizerEndLane.a11y.chromium.spec.ts +61 -27
- package/src/Toolbar/Toolbar.spec.md +103 -49
- package/src/Toolbar/__tests__/Toolbar.a11y.chromium.spec.ts +1 -0
- package/src/Tooltip/Tooltip.spec.md +161 -36
- package/src/Tooltip/Tooltip.test.tsx +171 -3
- package/src/Tooltip/__tests__/Tooltip.a11y.chromium.spec.ts +1 -0
- package/src/Tooltip/__tests__/Tooltip.a11y.states.ts +2 -2
- package/src/Tooltip/__tests__/TooltipFocusReturn.a11y.chromium.spec.ts +1 -0
- package/src/Tooltip/__tests__/TooltipHoverBridge.a11y.chromium.spec.ts +1 -0
- package/src/Tooltip/__tests__/TooltipTallContent.a11y.browser.spec.ts +673 -0
- package/src/Tooltip/__tests__/TooltipTallContentTracking.a11y.browser.spec.ts +1162 -0
- package/src/Tooltip/useTooltip.tsx +7 -2
- package/src/TopNav/TopNav.spec.md +190 -0
- package/src/TopNav/TopNav.test.tsx +89 -0
- package/src/TopNav/TopNavHeading.spec.md +211 -0
- package/src/TopNav/TopNavHeading.tsx +35 -2
- package/src/TopNav/TopNavItem.spec.md +189 -0
- package/src/TopNav/TopNavMegaMenu.reduced-motion.source-build.test.mjs +83 -0
- package/src/TopNav/TopNavMegaMenu.spec.md +190 -0
- package/src/TopNav/TopNavMegaMenu.tsx +21 -4
- package/src/TopNav/TopNavMegaMenuFeaturedCard.spec.md +150 -0
- package/src/TopNav/TopNavMegaMenuItem.spec.md +155 -0
- package/src/TopNav/TopNavMenu.spec.md +202 -0
- package/src/TopNav/TopNavMenu.test.tsx +65 -1
- package/src/TopNav/TopNavMenu.tsx +30 -1
- package/src/TopNav/__tests__/TopNavMobileLongHeading.a11y.chromium.spec.ts +1 -0
- package/src/TreeList/TreeList.doc.mjs +13 -0
- package/src/TreeList/TreeList.spec.md +54 -35
- package/src/TreeList/TreeList.tsx +234 -2
- package/src/TreeList/TreeListBranches.tsx +8 -6
- package/src/TreeList/TreeListItem.tsx +12 -6
- package/src/TreeList/__tests__/TreeList.a11y.chromium.spec.ts +19 -6
- package/src/TreeList/__tests__/TreeListGuideAlignment.interaction.browser.spec.ts +127 -0
- package/src/TreeList/__tests__/TreeListRowNames.a11y.chromium.spec.ts +1 -0
- package/src/Typeahead/BaseTypeahead.emptyState.a11y.chromium.spec.ts +138 -0
- package/src/Typeahead/BaseTypeahead.test.tsx +201 -4
- package/src/Typeahead/BaseTypeahead.tsx +26 -10
- package/src/Typeahead/Typeahead.test.tsx +114 -1
- package/src/Typeahead/Typeahead.tsx +34 -16
- package/src/VisuallyHidden/VisuallyHidden.spec.md +170 -0
- package/src/__tests__/BusyOwnerAnnouncement.test.tsx +66 -5
- package/src/__tests__/CardPress.a11y.chromium.spec.ts +353 -0
- package/src/__tests__/DisabledTriggerFocus.a11y.chromium.spec.ts +2 -1
- package/src/__tests__/PressModality.a11y.chromium.spec.ts +392 -0
- package/src/__tests__/PressedState.a11y.chromium.spec.ts +1 -0
- package/src/__tests__/pressState.ts +43 -1
- package/src/__tests__/unthemedLength.ts +34 -0
- package/src/gestures/GestureArena.ts +966 -0
- package/src/gestures/GestureRecognizer.ts +626 -0
- package/src/gestures/LongPressGestureRecognizer.ts +186 -0
- package/src/gestures/PanGestureRecognizer.ts +410 -0
- package/src/gestures/TapGestureRecognizer.ts +192 -0
- package/src/gestures/VelocityTracker.ts +194 -0
- package/src/gestures/__tests__/LongPressGestureRecognizer.test.ts +141 -0
- package/src/gestures/__tests__/PanGestureRecognizer.test.ts +327 -0
- package/src/gestures/__tests__/TapGestureRecognizer.test.ts +154 -0
- package/src/gestures/__tests__/VelocityTracker.streams.test.ts +243 -0
- package/src/gestures/__tests__/VelocityTracker.test.ts +261 -0
- package/src/gestures/__tests__/arena.test.ts +824 -0
- package/src/gestures/__tests__/arenaContinuous.test.ts +207 -0
- package/src/gestures/__tests__/arenaTapLongPress.test.ts +211 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/README.md +82 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/android-chromium-fling.json +130 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/android-chromium-slow.json +860 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/android-chromium-stop-release.json +357 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/android-firefox-fling.json +66 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/android-firefox-slow.json +268 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/android-firefox-stop-release.json +128 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/capture.html +123 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-mouse-fling.json +64 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-mouse-slow.json +268 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-mouse-stop-release.json +124 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-pen-fling.json +64 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-pen-slow.json +268 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-pen-stop-release.json +124 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-touch-fling.json +84 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-touch-slow.json +381 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/desktop-chromium-touch-stop-release.json +171 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/ios-safari-fling.json +45 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/ios-safari-slow.json +101 -0
- package/src/gestures/__tests__/fixtures/pointer-streams/ios-safari-stop-release.json +130 -0
- package/src/gestures/__tests__/harness.ts +204 -0
- package/src/gestures/geometry.ts +55 -0
- package/src/gestures/types.ts +161 -0
- package/src/hooks/AnnounceRenderedText.tsx +27 -0
- package/src/hooks/ModalAnnounceProvider.tsx +155 -0
- package/src/hooks/__tests__/MenuPressShadowRoot.a11y.chromium.spec.ts +98 -4
- package/src/hooks/__tests__/menuLinkClicks.ts +71 -0
- package/src/hooks/actionGroupTracker.exports.test.ts +28 -0
- package/src/hooks/actionGroupTracker.test.ts +510 -0
- package/src/hooks/actionGroupTracker.ts +449 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/menuPressOnItems.ts +40 -0
- package/src/hooks/modalAnnounce.ts +439 -0
- package/src/hooks/scrollGeometry.ts +71 -4
- package/src/hooks/useAdaptivePresentation.ts +46 -9
- package/src/hooks/useAnimatedLayout.doc.mjs +101 -0
- package/src/hooks/useAnimatedLayout.ts +61 -0
- package/src/hooks/useAnnounce.doc.mjs +4 -4
- package/src/hooks/useAnnounce.modal.test.tsx +1291 -0
- package/src/hooks/useAnnounce.test.tsx +64 -4
- package/src/hooks/useAnnounce.ts +452 -28
- package/src/hooks/useAnnounceRenderedText.adopters.test.tsx +226 -0
- package/src/hooks/useAnnounceRenderedText.ts +81 -11
- package/src/hooks/useBusyAnnouncement.adopters.test.tsx +69 -0
- package/src/hooks/useBusyAnnouncement.test.tsx +112 -0
- package/src/hooks/useBusyAnnouncement.ts +64 -54
- package/src/hooks/useFocusTrap.doc.mjs +3 -3
- package/src/hooks/useFocusTrap.test.tsx +135 -2
- package/src/hooks/useFocusTrap.ts +59 -27
- package/src/hooks/useMenuHover.ts +6 -2
- package/src/hooks/useMenuPress.doc.mjs +2 -2
- package/src/hooks/useMenuPress.test.tsx +5 -2
- package/src/hooks/useMenuPress.ts +72 -37
- package/src/hooks/usePressFeedback.doc.mjs +4 -4
- package/src/hooks/usePressFeedback.ts +5 -2
- package/src/hooks/useScrollableArea.test.tsx +344 -3
- package/src/hooks/useScrollableArea.ts +120 -12
- package/src/i18n/generated-locales/en.generated.ts +35 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +37 -0
- package/src/internal/tokenizer-presentation.test.ts +29 -0
- package/src/internal/tokenizer-presentation.ts +25 -0
- package/src/internal/touch.test.ts +44 -0
- package/src/internal/touch.ts +41 -0
- package/src/motion/LayoutChangeSnapshot.tsx +50 -0
- package/src/motion/MEASUREMENTS.md +271 -0
- package/src/motion/README.md +218 -0
- package/src/motion/__tests__/animatedLayout.interaction.browser.spec.ts +1613 -0
- package/src/motion/__tests__/animatedLayoutAdopters.interaction.browser.spec.ts +217 -0
- package/src/motion/__tests__/animatedLayoutBundle.ts +17 -0
- package/src/motion/animatedLayout.boundary.test.ts +155 -0
- package/src/motion/animatedLayout.swap.test.ts +827 -0
- package/src/motion/animatedLayout.test.ts +1154 -0
- package/src/motion/animatedLayout.ts +1801 -0
- package/src/motion/animatedLayoutAdopters.test.tsx +500 -0
- package/src/motion/animator.test.ts +2653 -0
- package/src/motion/animator.ts +2794 -0
- package/src/motion/bezier.test.ts +52 -0
- package/src/motion/bezier.ts +64 -0
- package/src/motion/coast.test.ts +99 -0
- package/src/motion/coast.ts +150 -0
- package/src/motion/decay.test.ts +120 -0
- package/src/motion/decay.ts +126 -0
- package/src/motion/projection.test.ts +107 -0
- package/src/motion/projection.ts +116 -0
- package/src/motion/reducedMotion.stylex.ts +41 -0
- package/src/motion/reducedMotion.test.ts +129 -0
- package/src/motion/reducedMotion.ts +94 -0
- package/src/motion/reducedMotionPlan.test.ts +182 -0
- package/src/motion/reducedMotionPlan.ts +263 -0
- package/src/motion/resolveSnapPoint.test.ts +189 -0
- package/src/motion/resolveSnapPoint.ts +169 -0
- package/src/motion/roleValue.ts +105 -0
- package/src/motion/roles.test.ts +256 -0
- package/src/motion/roles.ts +262 -0
- package/src/motion/rubberBand.test.ts +88 -0
- package/src/motion/rubberBand.ts +115 -0
- package/src/motion/selectPage.test.ts +31 -0
- package/src/motion/selectPage.ts +55 -0
- package/src/motion/spring.test.ts +650 -0
- package/src/motion/spring.ts +551 -0
- package/src/motion/transientCopy.ts +374 -0
- package/src/motion/uikit/gestures.test.ts +89 -0
- package/src/motion/uikit/gestures.ts +359 -0
- package/src/motion/uikit/index.ts +80 -0
- package/src/motion/uikit/navigation.ts +83 -0
- package/src/motion/uikit/scroll.ts +141 -0
- package/src/motion/uikit/springRows.test.ts +71 -0
- package/src/motion/uikit/springs.ts +514 -0
- package/src/motion/uikit/timing.ts +210 -0
- package/src/motion/uikit/uikit.test.ts +364 -0
- package/src/motion/uikit/values.test.ts +110 -0
- package/src/reset.a11y.chromium.spec.ts +1 -0
- package/src/reset.until-found.a11y.browser.spec.ts +1 -0
- package/src/serverSafeComponents.test.ts +10 -0
- package/src/tailwind-theme.css +51 -1
- package/src/tailwind-theme.test.ts +51 -0
- package/src/theme/Theme.test.tsx +28 -0
- package/src/theme/__tests__/SpacingRootFontSize.a11y.chromium.spec.ts +1 -0
- package/src/theme/declarationBoundary.ts +282 -1
- package/src/theme/defineTheme.test.ts +529 -12
- package/src/theme/defineTheme.ts +231 -19
- package/src/theme/derivedVarRegistry.test.ts +34 -5
- package/src/theme/derivedVarRegistry.ts +4 -0
- package/src/theme/expandMotionScale.test.ts +17 -0
- package/src/theme/extensibleAxes.test.ts +74 -29
- package/src/theme/generateThemeRules.ts +772 -35
- package/src/theme/index.ts +3 -0
- package/src/theme/onMediaTokens.test.ts +186 -0
- package/src/theme/statusColor.ts +189 -0
- package/src/theme/statusRoleDerivation.ts +289 -0
- package/src/theme/syntax/SyntaxTheme.tsx +1 -1
- package/src/theme/syntax/defineSyntaxTheme.ts +1 -1
- package/src/theme/syntax/presets.ts +1 -1
- package/src/theme/syntax/tokens.ts +1 -1
- package/src/theme/themeAdaptations.test.ts +412 -0
- package/src/theme/themeAdaptations.ts +43 -1
- package/src/theme/tokens.stylex.ts +36 -2
- package/src/theme/tokens.test.ts +111 -1
- package/src/theme/tokens.ts +23 -1
- package/src/theme/useTheme.ts +10 -4
- package/src/utils/customPropertyArmLayering.test.ts +131 -0
- package/src/utils/edgeAutoscroll.test.ts +192 -0
- package/src/utils/edgeAutoscroll.ts +111 -0
- package/src/utils/hitArea.test.ts +628 -0
- package/src/utils/hitArea.ts +770 -0
- package/src/utils/interactionOverlay.stylex.ts +4 -1
- package/src/utils/pressFeedback.test.ts +310 -2
- package/src/utils/pressFeedback.ts +306 -54
- package/src/utils/pressGesture.test.ts +50 -0
- package/src/utils/pressGesture.ts +40 -2
- package/src/utils/touchPresentation.test.ts +323 -0
- package/src/utils/touchPresentation.ts +153 -0
|
@@ -0,0 +1,2719 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
/**
|
|
3
|
+
* @file TokenizerBottomSheet.test.tsx
|
|
4
|
+
* @input Uses vitest, Testing Library, Tokenizer with
|
|
5
|
+
* `experimental.presentation`
|
|
6
|
+
* @output Tests for the experimental sheet presentation: the presentation
|
|
7
|
+
* resolution (`component:Tokenizer` FR16) and the single-sheet touch flow
|
|
8
|
+
* (FR17–FR24, AR6)
|
|
9
|
+
* @position Core tests; validates Tokenizer.tsx and TokenizerBottomSheet.tsx
|
|
10
|
+
*/
|
|
11
|
+
import {
|
|
12
|
+
afterEach,
|
|
13
|
+
beforeAll,
|
|
14
|
+
beforeEach,
|
|
15
|
+
describe,
|
|
16
|
+
expect,
|
|
17
|
+
it,
|
|
18
|
+
vi,
|
|
19
|
+
} from 'vitest';
|
|
20
|
+
import {
|
|
21
|
+
act,
|
|
22
|
+
cleanup,
|
|
23
|
+
fireEvent,
|
|
24
|
+
render,
|
|
25
|
+
screen,
|
|
26
|
+
waitFor,
|
|
27
|
+
within,
|
|
28
|
+
} from '@testing-library/react';
|
|
29
|
+
import {createRef, useState} from 'react';
|
|
30
|
+
import * as stylex from '@stylexjs/stylex';
|
|
31
|
+
import type {TokenizerChange} from './Tokenizer';
|
|
32
|
+
import {TokenizerWithPresentation} from '../internal/tokenizer-presentation';
|
|
33
|
+
import {__resetLiveRegionsForTest} from '../hooks/useAnnounce';
|
|
34
|
+
import {__resetDevWarnings} from '../utils/devWarning';
|
|
35
|
+
import {colorVars} from '../theme/tokens.stylex';
|
|
36
|
+
import type {SearchSource, SearchableItem} from '../Typeahead/types';
|
|
37
|
+
|
|
38
|
+
import {COMPACT_TOUCH_PRESENTATION_QUERY as COMPACT_TOUCH_QUERY} from '../hooks/useAdaptivePresentation';
|
|
39
|
+
import {BottomSheet} from '../BottomSheet/BottomSheet';
|
|
40
|
+
import {
|
|
41
|
+
getBottomSheetStackForTests,
|
|
42
|
+
resetBottomSheetStackForTests,
|
|
43
|
+
} from '../BottomSheet/bottomSheetStack';
|
|
44
|
+
import {getActiveModalOutlet} from '../Layer/modalOutlet';
|
|
45
|
+
|
|
46
|
+
const ITEMS: SearchableItem[] = [
|
|
47
|
+
{id: 'design', label: 'Design'},
|
|
48
|
+
{id: 'eng', label: 'Eng'},
|
|
49
|
+
{id: 'engineer', label: 'Engineer'},
|
|
50
|
+
{id: 'energizer', label: 'Energizer'},
|
|
51
|
+
];
|
|
52
|
+
const source: SearchSource<SearchableItem> = {
|
|
53
|
+
search: q =>
|
|
54
|
+
ITEMS.filter(item => item.label.toLowerCase().includes(q.toLowerCase())),
|
|
55
|
+
bootstrap: () => ITEMS,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
type Presentation = 'popover' | 'bottom-sheet' | 'adaptive';
|
|
59
|
+
|
|
60
|
+
const DEFAULT_INITIAL = [ITEMS[0], ITEMS[1]];
|
|
61
|
+
|
|
62
|
+
function Harness({
|
|
63
|
+
spy,
|
|
64
|
+
presentation = 'bottom-sheet',
|
|
65
|
+
initial = DEFAULT_INITIAL,
|
|
66
|
+
...props
|
|
67
|
+
}: {
|
|
68
|
+
spy?: (
|
|
69
|
+
items: SearchableItem[],
|
|
70
|
+
change: TokenizerChange<SearchableItem>,
|
|
71
|
+
) => void;
|
|
72
|
+
presentation?: Presentation;
|
|
73
|
+
initial?: SearchableItem[];
|
|
74
|
+
hasCreate?: boolean;
|
|
75
|
+
maxEntries?: number;
|
|
76
|
+
isDisabled?: boolean;
|
|
77
|
+
disabledMessage?: string;
|
|
78
|
+
debounceMs?: number;
|
|
79
|
+
onFocus?: (event: React.FocusEvent) => void;
|
|
80
|
+
onBlur?: (event: React.FocusEvent) => void;
|
|
81
|
+
}) {
|
|
82
|
+
const [value, setValue] = useState<SearchableItem[]>(initial);
|
|
83
|
+
return (
|
|
84
|
+
<TokenizerWithPresentation
|
|
85
|
+
label="Tags"
|
|
86
|
+
searchSource={source}
|
|
87
|
+
value={value}
|
|
88
|
+
debounceMs={0}
|
|
89
|
+
placeholder="Add tags"
|
|
90
|
+
onChange={(items, change) => {
|
|
91
|
+
setValue(items);
|
|
92
|
+
spy?.(items, change);
|
|
93
|
+
}}
|
|
94
|
+
experimental={{presentation}}
|
|
95
|
+
{...props}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function stubMatchMedia(matcher: (query: string) => boolean) {
|
|
101
|
+
vi.stubGlobal(
|
|
102
|
+
'matchMedia',
|
|
103
|
+
vi.fn().mockImplementation((query: string) => ({
|
|
104
|
+
matches: matcher(query),
|
|
105
|
+
media: query,
|
|
106
|
+
onchange: null,
|
|
107
|
+
addEventListener: vi.fn(),
|
|
108
|
+
removeEventListener: vi.fn(),
|
|
109
|
+
addListener: vi.fn(),
|
|
110
|
+
removeListener: vi.fn(),
|
|
111
|
+
dispatchEvent: vi.fn(),
|
|
112
|
+
})),
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function stubEnvironment() {
|
|
117
|
+
HTMLDialogElement.prototype.showModal = vi.fn(function (
|
|
118
|
+
this: HTMLDialogElement,
|
|
119
|
+
) {
|
|
120
|
+
this.setAttribute('open', '');
|
|
121
|
+
});
|
|
122
|
+
HTMLDialogElement.prototype.show = vi.fn(function (this: HTMLDialogElement) {
|
|
123
|
+
this.setAttribute('open', '');
|
|
124
|
+
});
|
|
125
|
+
HTMLDialogElement.prototype.close = vi.fn(function (this: HTMLDialogElement) {
|
|
126
|
+
this.removeAttribute('open');
|
|
127
|
+
});
|
|
128
|
+
if (!Element.prototype.setPointerCapture) {
|
|
129
|
+
Element.prototype.setPointerCapture = vi.fn();
|
|
130
|
+
Element.prototype.releasePointerCapture = vi.fn();
|
|
131
|
+
}
|
|
132
|
+
stubMatchMedia(() => false);
|
|
133
|
+
window.scrollTo = vi.fn();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const openTrigger = () => screen.getByRole('button', {name: 'Tags'});
|
|
137
|
+
// The row list carries the progressive-rendering counters (FR21).
|
|
138
|
+
const list = () => document.querySelector<HTMLElement>('[data-total-count]')!;
|
|
139
|
+
|
|
140
|
+
// The sheet surface is loaded with React.lazy, so the first sheet renders a
|
|
141
|
+
// tick after it opens. Open one up front so the module is cached and every
|
|
142
|
+
// later sheet renders synchronously.
|
|
143
|
+
beforeAll(async () => {
|
|
144
|
+
stubEnvironment();
|
|
145
|
+
try {
|
|
146
|
+
render(<Harness />);
|
|
147
|
+
fireEvent.click(openTrigger());
|
|
148
|
+
await screen.findByLabelText('Search Tags', undefined, {timeout: 15000});
|
|
149
|
+
} finally {
|
|
150
|
+
cleanup();
|
|
151
|
+
vi.unstubAllGlobals();
|
|
152
|
+
}
|
|
153
|
+
}, 20000);
|
|
154
|
+
|
|
155
|
+
beforeEach(() => {
|
|
156
|
+
__resetLiveRegionsForTest();
|
|
157
|
+
resetBottomSheetStackForTests();
|
|
158
|
+
stubEnvironment();
|
|
159
|
+
});
|
|
160
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
161
|
+
|
|
162
|
+
describe('Tokenizer experimental.presentation (FR16)', () => {
|
|
163
|
+
it('keeps the inline combobox when experimental is omitted', () => {
|
|
164
|
+
render(
|
|
165
|
+
<TokenizerWithPresentation
|
|
166
|
+
label="Tags"
|
|
167
|
+
searchSource={source}
|
|
168
|
+
value={[ITEMS[0]]}
|
|
169
|
+
onChange={() => {}}
|
|
170
|
+
/>,
|
|
171
|
+
);
|
|
172
|
+
expect(screen.getByRole('combobox')).toBeInTheDocument();
|
|
173
|
+
expect(
|
|
174
|
+
screen.queryByRole('button', {name: 'Tags'}),
|
|
175
|
+
).not.toBeInTheDocument();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('keeps the inline combobox for an empty experimental object and for popover', () => {
|
|
179
|
+
const {unmount} = render(
|
|
180
|
+
<TokenizerWithPresentation
|
|
181
|
+
label="Tags"
|
|
182
|
+
searchSource={source}
|
|
183
|
+
value={[]}
|
|
184
|
+
onChange={() => {}}
|
|
185
|
+
experimental={{}}
|
|
186
|
+
/>,
|
|
187
|
+
);
|
|
188
|
+
expect(screen.getByRole('combobox')).toBeInTheDocument();
|
|
189
|
+
unmount();
|
|
190
|
+
render(<Harness presentation="popover" />);
|
|
191
|
+
expect(screen.getByRole('combobox')).toBeInTheDocument();
|
|
192
|
+
expect(
|
|
193
|
+
screen.queryByRole('button', {name: 'Tags'}),
|
|
194
|
+
).not.toBeInTheDocument();
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('forces the sheet trigger for bottom-sheet on every device', async () => {
|
|
198
|
+
render(<Harness presentation="bottom-sheet" />);
|
|
199
|
+
expect(screen.queryByRole('combobox')).not.toBeInTheDocument();
|
|
200
|
+
const trigger = openTrigger();
|
|
201
|
+
expect(trigger).toHaveAttribute('aria-haspopup', 'dialog');
|
|
202
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
203
|
+
expect(trigger).toHaveTextContent('Design');
|
|
204
|
+
expect(trigger).toHaveTextContent('Eng');
|
|
205
|
+
// Tokens in the trigger are display-only (FR17).
|
|
206
|
+
expect(within(trigger).queryAllByRole('button')).toHaveLength(0);
|
|
207
|
+
|
|
208
|
+
fireEvent.click(trigger);
|
|
209
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'true');
|
|
210
|
+
const sheet = await screen.findByRole('dialog', {name: 'Tags'});
|
|
211
|
+
expect(sheet).toBeInTheDocument();
|
|
212
|
+
expect(HTMLDialogElement.prototype.showModal).toHaveBeenCalled();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('uses the sheet for adaptive presentation on compact touch', async () => {
|
|
216
|
+
stubMatchMedia(query => query === COMPACT_TOUCH_QUERY);
|
|
217
|
+
render(<Harness presentation="adaptive" />);
|
|
218
|
+
expect(screen.queryByRole('combobox')).not.toBeInTheDocument();
|
|
219
|
+
fireEvent.click(openTrigger());
|
|
220
|
+
expect(
|
|
221
|
+
await screen.findByRole('dialog', {name: 'Tags'}),
|
|
222
|
+
).toBeInTheDocument();
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('keeps adaptive presentation inline without compact touch', () => {
|
|
226
|
+
render(<Harness presentation="adaptive" />);
|
|
227
|
+
expect(screen.getByRole('combobox')).toBeInTheDocument();
|
|
228
|
+
expect(
|
|
229
|
+
screen.queryByRole('button', {name: 'Tags'}),
|
|
230
|
+
).not.toBeInTheDocument();
|
|
231
|
+
expect(HTMLDialogElement.prototype.showModal).not.toHaveBeenCalled();
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('shows the trigger placeholder when nothing is selected', () => {
|
|
235
|
+
render(<Harness initial={[]} />);
|
|
236
|
+
expect(openTrigger()).toHaveTextContent('Add tags');
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
describe('Tokenizer sheet presentation (single-sheet touch flow)', () => {
|
|
241
|
+
it('keeps rows stable while open and applies selected-first order on reopen (FR19)', async () => {
|
|
242
|
+
const spy = vi.fn();
|
|
243
|
+
render(<Harness spy={spy} />);
|
|
244
|
+
const trigger = openTrigger();
|
|
245
|
+
fireEvent.click(trigger);
|
|
246
|
+
|
|
247
|
+
await screen.findByRole('checkbox', {name: 'Energizer'});
|
|
248
|
+
const checkboxLabels = () =>
|
|
249
|
+
within(list())
|
|
250
|
+
.getAllByRole('checkbox')
|
|
251
|
+
.map(row => row.getAttribute('aria-label'));
|
|
252
|
+
expect(checkboxLabels()).toEqual([
|
|
253
|
+
'Design',
|
|
254
|
+
'Eng',
|
|
255
|
+
'Engineer',
|
|
256
|
+
'Energizer',
|
|
257
|
+
]);
|
|
258
|
+
expect(screen.getByLabelText('Search Tags')).toBeInTheDocument();
|
|
259
|
+
expect(
|
|
260
|
+
screen.queryByRole('button', {name: 'Add item'}),
|
|
261
|
+
).not.toBeInTheDocument();
|
|
262
|
+
const design = screen.getByRole('checkbox', {name: 'Design'});
|
|
263
|
+
expect(design).toBeChecked();
|
|
264
|
+
expect(design.lastElementChild).toHaveAttribute('aria-hidden', 'true');
|
|
265
|
+
expect(design.lastElementChild).toHaveAttribute('data-size', 'md');
|
|
266
|
+
|
|
267
|
+
fireEvent.click(screen.getByRole('checkbox', {name: 'Energizer'}));
|
|
268
|
+
expect(spy).toHaveBeenCalledWith(
|
|
269
|
+
[ITEMS[0], ITEMS[1], ITEMS[3]],
|
|
270
|
+
expect.objectContaining({type: 'add'}),
|
|
271
|
+
);
|
|
272
|
+
await waitFor(() =>
|
|
273
|
+
expect(screen.getByRole('checkbox', {name: 'Energizer'})).toBeChecked(),
|
|
274
|
+
);
|
|
275
|
+
expect(checkboxLabels()).toEqual([
|
|
276
|
+
'Design',
|
|
277
|
+
'Eng',
|
|
278
|
+
'Engineer',
|
|
279
|
+
'Energizer',
|
|
280
|
+
]);
|
|
281
|
+
|
|
282
|
+
fireEvent.click(screen.getByRole('checkbox', {name: 'Eng'}));
|
|
283
|
+
expect(spy).toHaveBeenLastCalledWith(
|
|
284
|
+
[ITEMS[0], ITEMS[3]],
|
|
285
|
+
expect.objectContaining({type: 'remove'}),
|
|
286
|
+
);
|
|
287
|
+
expect(checkboxLabels()).toEqual([
|
|
288
|
+
'Design',
|
|
289
|
+
'Eng',
|
|
290
|
+
'Engineer',
|
|
291
|
+
'Energizer',
|
|
292
|
+
]);
|
|
293
|
+
|
|
294
|
+
fireEvent.click(screen.getByRole('button', {name: 'Done'}));
|
|
295
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
296
|
+
|
|
297
|
+
await act(async () => {
|
|
298
|
+
fireEvent.click(trigger);
|
|
299
|
+
});
|
|
300
|
+
expect(checkboxLabels()).toEqual([
|
|
301
|
+
'Design',
|
|
302
|
+
'Energizer',
|
|
303
|
+
'Eng',
|
|
304
|
+
'Engineer',
|
|
305
|
+
]);
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('announces additions, removals, and the busy start inside the open modal sheet, not on the page body (AR6; AST-086 FR14)', async () => {
|
|
309
|
+
// jsdom has no showModal(), so an open dialog never matches `:modal`;
|
|
310
|
+
// stand in for the sheet the browser presents modally.
|
|
311
|
+
const matches = Element.prototype.matches;
|
|
312
|
+
const spy = vi
|
|
313
|
+
.spyOn(Element.prototype, 'matches')
|
|
314
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
315
|
+
return selector === ':modal'
|
|
316
|
+
? this instanceof HTMLDialogElement && this.open
|
|
317
|
+
: matches.call(this, selector);
|
|
318
|
+
});
|
|
319
|
+
try {
|
|
320
|
+
// A real debounce, so a typed query has a busy window to announce.
|
|
321
|
+
render(<Harness debounceMs={50} />);
|
|
322
|
+
fireEvent.click(openTrigger());
|
|
323
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
324
|
+
const region = () =>
|
|
325
|
+
dialog.querySelector(
|
|
326
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
327
|
+
);
|
|
328
|
+
const shared = () =>
|
|
329
|
+
document.querySelector('[data-astryx-live-region="polite"]');
|
|
330
|
+
// An instant bootstrap announces no busy start; a debounced typed
|
|
331
|
+
// query does, in the sheet, before its results land.
|
|
332
|
+
await screen.findByRole('checkbox', {name: 'Energizer'});
|
|
333
|
+
expect(region()).toBeNull();
|
|
334
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
335
|
+
target: {value: 'E'},
|
|
336
|
+
});
|
|
337
|
+
await waitFor(() => expect(region()).toHaveTextContent('Loading'));
|
|
338
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
339
|
+
target: {value: ''},
|
|
340
|
+
});
|
|
341
|
+
fireEvent.click(await screen.findByRole('checkbox', {name: 'Energizer'}));
|
|
342
|
+
await waitFor(() =>
|
|
343
|
+
expect(region()).toHaveTextContent('Added Energizer'),
|
|
344
|
+
);
|
|
345
|
+
expect(region()).toHaveAttribute('role', 'status');
|
|
346
|
+
expect(dialog.contains(region())).toBe(true);
|
|
347
|
+
expect(shared()?.textContent ?? '').toBe('');
|
|
348
|
+
fireEvent.click(screen.getByRole('checkbox', {name: 'Design'}));
|
|
349
|
+
await waitFor(() => expect(region()).toHaveTextContent('Removed Design'));
|
|
350
|
+
expect(shared()?.textContent ?? '').toBe('');
|
|
351
|
+
// How a search ended: the result count for a typed query …
|
|
352
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
353
|
+
target: {value: 'En'},
|
|
354
|
+
});
|
|
355
|
+
await waitFor(() => expect(region()).toHaveTextContent('3 results'));
|
|
356
|
+
// … and the empty state's words when it shows.
|
|
357
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
358
|
+
target: {value: 'zzz'},
|
|
359
|
+
});
|
|
360
|
+
await waitFor(() =>
|
|
361
|
+
expect(region()).toHaveTextContent('No results found'),
|
|
362
|
+
);
|
|
363
|
+
expect(shared()?.textContent ?? '').toBe('');
|
|
364
|
+
} finally {
|
|
365
|
+
spy.mockRestore();
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('keeps the inline popover presentation on the shared live region', async () => {
|
|
370
|
+
render(
|
|
371
|
+
<TokenizerWithPresentation
|
|
372
|
+
label="Tags"
|
|
373
|
+
searchSource={source}
|
|
374
|
+
value={[ITEMS[0], ITEMS[1]]}
|
|
375
|
+
onChange={() => {}}
|
|
376
|
+
debounceMs={0}
|
|
377
|
+
/>,
|
|
378
|
+
);
|
|
379
|
+
// Backspace on the empty input removes the last token through the
|
|
380
|
+
// same path the sheet's rows use.
|
|
381
|
+
const input = screen.getByRole('combobox');
|
|
382
|
+
input.focus();
|
|
383
|
+
fireEvent.keyDown(input, {key: 'Backspace'});
|
|
384
|
+
await waitFor(() =>
|
|
385
|
+
expect(
|
|
386
|
+
document.querySelector('[data-astryx-live-region="polite"]'),
|
|
387
|
+
).toHaveTextContent('Removed Eng'),
|
|
388
|
+
);
|
|
389
|
+
expect(
|
|
390
|
+
document.querySelector('[data-astryx-modal-live-region]'),
|
|
391
|
+
).toBeNull();
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it('creates a custom entry with a trailing Add action and announces the created value (FR22)', async () => {
|
|
395
|
+
// jsdom has no showModal(); stand in for the sheet presented modally so
|
|
396
|
+
// the announcement takes the in-dialog route.
|
|
397
|
+
const matches = Element.prototype.matches;
|
|
398
|
+
const modalSpy = vi
|
|
399
|
+
.spyOn(Element.prototype, 'matches')
|
|
400
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
401
|
+
return selector === ':modal'
|
|
402
|
+
? this instanceof HTMLDialogElement && this.open
|
|
403
|
+
: matches.call(this, selector);
|
|
404
|
+
});
|
|
405
|
+
try {
|
|
406
|
+
const spy = vi.fn();
|
|
407
|
+
render(<Harness spy={spy} hasCreate initial={[]} />);
|
|
408
|
+
const trigger = openTrigger();
|
|
409
|
+
fireEvent.click(trigger);
|
|
410
|
+
const search = await screen.findByLabelText('Search Tags');
|
|
411
|
+
fireEvent.change(search, {target: {value: 'Custom'}});
|
|
412
|
+
|
|
413
|
+
expect(
|
|
414
|
+
screen.queryByRole('checkbox', {name: 'Create "Custom"'}),
|
|
415
|
+
).not.toBeInTheDocument();
|
|
416
|
+
const create = await screen.findByRole('button', {name: 'Add Custom'});
|
|
417
|
+
expect(
|
|
418
|
+
screen.queryByRole('button', {name: 'Clear all'}),
|
|
419
|
+
).not.toBeInTheDocument();
|
|
420
|
+
expect(
|
|
421
|
+
screen.queryByRole('button', {name: 'Done'}),
|
|
422
|
+
).not.toBeInTheDocument();
|
|
423
|
+
expect(create).toHaveAttribute('data-size', 'lg');
|
|
424
|
+
expect(screen.getByText('Create "Custom"')).toBeInTheDocument();
|
|
425
|
+
await act(async () => {
|
|
426
|
+
fireEvent.click(create);
|
|
427
|
+
});
|
|
428
|
+
expect(spy).toHaveBeenCalledWith(
|
|
429
|
+
[{id: 'Custom', label: 'Custom'}],
|
|
430
|
+
expect.objectContaining({type: 'create'}),
|
|
431
|
+
);
|
|
432
|
+
await waitFor(() => expect(trigger).toHaveTextContent('Custom'));
|
|
433
|
+
expect(search).toHaveValue('');
|
|
434
|
+
const custom = await screen.findByRole('checkbox', {name: 'Custom'});
|
|
435
|
+
expect(custom).toBeChecked();
|
|
436
|
+
// Announced inside the sheet as the created value, not the row's
|
|
437
|
+
// caption ("Create …"), as the inline field announces it.
|
|
438
|
+
const dialog = screen.getByRole('dialog', {name: 'Tags'});
|
|
439
|
+
await waitFor(() =>
|
|
440
|
+
expect(
|
|
441
|
+
dialog.querySelector(
|
|
442
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
443
|
+
),
|
|
444
|
+
).toHaveTextContent('Added Custom'),
|
|
445
|
+
);
|
|
446
|
+
expect(
|
|
447
|
+
dialog.querySelector(
|
|
448
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
449
|
+
),
|
|
450
|
+
).not.toHaveTextContent('Create');
|
|
451
|
+
} finally {
|
|
452
|
+
modalSpy.mockRestore();
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
it('offers no create row for text that matches a selected label or a result', async () => {
|
|
456
|
+
render(<Harness hasCreate />);
|
|
457
|
+
fireEvent.click(openTrigger());
|
|
458
|
+
const search = await screen.findByLabelText('Search Tags');
|
|
459
|
+
fireEvent.change(search, {target: {value: 'design'}});
|
|
460
|
+
await screen.findByRole('checkbox', {name: 'Design'});
|
|
461
|
+
expect(
|
|
462
|
+
screen.queryByRole('button', {name: /^Add /}),
|
|
463
|
+
).not.toBeInTheDocument();
|
|
464
|
+
fireEvent.change(search, {target: {value: 'ENGINEER'}});
|
|
465
|
+
await screen.findByRole('checkbox', {name: 'Engineer'});
|
|
466
|
+
expect(
|
|
467
|
+
screen.queryByRole('button', {name: /^Add /}),
|
|
468
|
+
).not.toBeInTheDocument();
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
it('renders long lists in 50-item batches and resets the window for search (FR21)', async () => {
|
|
472
|
+
const longItems: SearchableItem[] = Array.from(
|
|
473
|
+
{length: 120},
|
|
474
|
+
(_, index) => ({
|
|
475
|
+
id: `item-${index + 1}`,
|
|
476
|
+
label: `Item ${String(index + 1).padStart(3, '0')}`,
|
|
477
|
+
}),
|
|
478
|
+
);
|
|
479
|
+
const longSource: SearchSource<SearchableItem> = {
|
|
480
|
+
bootstrap: () => longItems,
|
|
481
|
+
search: query =>
|
|
482
|
+
longItems.filter(item =>
|
|
483
|
+
item.label.toLowerCase().includes(query.toLowerCase()),
|
|
484
|
+
),
|
|
485
|
+
};
|
|
486
|
+
render(
|
|
487
|
+
<TokenizerWithPresentation
|
|
488
|
+
label="Items"
|
|
489
|
+
searchSource={longSource}
|
|
490
|
+
value={[]}
|
|
491
|
+
onChange={() => {}}
|
|
492
|
+
maxMenuItems={120}
|
|
493
|
+
debounceMs={0}
|
|
494
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
495
|
+
/>,
|
|
496
|
+
);
|
|
497
|
+
fireEvent.click(screen.getByRole('button', {name: 'Items'}));
|
|
498
|
+
await screen.findByRole('checkbox', {name: 'Item 001'});
|
|
499
|
+
const items = list();
|
|
500
|
+
await waitFor(() => {
|
|
501
|
+
expect(items).toHaveAttribute('data-rendered-count', '50');
|
|
502
|
+
expect(items).toHaveAttribute('data-total-count', '120');
|
|
503
|
+
});
|
|
504
|
+
expect(screen.getAllByRole('checkbox')).toHaveLength(50);
|
|
505
|
+
expect(
|
|
506
|
+
screen.queryByRole('checkbox', {name: 'Item 051'}),
|
|
507
|
+
).not.toBeInTheDocument();
|
|
508
|
+
// Every row's listitem names its place in the whole set, not the
|
|
509
|
+
// rendered window; `checkbox` does not admit the position attributes,
|
|
510
|
+
// so they sit on the listitem that wraps each row.
|
|
511
|
+
const rowList = within(items).getByRole('list');
|
|
512
|
+
const listItems = within(rowList).getAllByRole('listitem');
|
|
513
|
+
expect(listItems).toHaveLength(50);
|
|
514
|
+
expect(listItems[0]).toHaveAttribute('aria-setsize', '120');
|
|
515
|
+
expect(listItems[0]).toHaveAttribute('aria-posinset', '1');
|
|
516
|
+
expect(
|
|
517
|
+
within(listItems[0]).getByRole('checkbox', {name: 'Item 001'}),
|
|
518
|
+
).toBeInTheDocument();
|
|
519
|
+
expect(listItems[49]).toHaveAttribute('aria-setsize', '120');
|
|
520
|
+
expect(listItems[49]).toHaveAttribute('aria-posinset', '50');
|
|
521
|
+
const first = screen.getByRole('checkbox', {name: 'Item 001'});
|
|
522
|
+
expect(first).not.toHaveAttribute('aria-setsize');
|
|
523
|
+
expect(first).not.toHaveAttribute('aria-posinset');
|
|
524
|
+
const fiftieth = screen.getByRole('checkbox', {name: 'Item 050'});
|
|
525
|
+
// Focus reaching the last rendered row renders the next batch, so a
|
|
526
|
+
// keyboard user reaches every row without scrolling.
|
|
527
|
+
fiftieth.focus();
|
|
528
|
+
await waitFor(() =>
|
|
529
|
+
expect(items).toHaveAttribute('data-rendered-count', '100'),
|
|
530
|
+
);
|
|
531
|
+
expect(
|
|
532
|
+
screen
|
|
533
|
+
.getByRole('checkbox', {name: 'Item 051'})
|
|
534
|
+
.closest('[role="listitem"]'),
|
|
535
|
+
).toHaveAttribute('aria-posinset', '51');
|
|
536
|
+
screen.getByRole('checkbox', {name: 'Item 100'}).focus();
|
|
537
|
+
await waitFor(() =>
|
|
538
|
+
expect(items).toHaveAttribute('data-rendered-count', '120'),
|
|
539
|
+
);
|
|
540
|
+
// The window is back to one batch for the scroll part of the test.
|
|
541
|
+
fireEvent.change(screen.getByLabelText('Search Items'), {
|
|
542
|
+
target: {value: 'Item'},
|
|
543
|
+
});
|
|
544
|
+
await waitFor(() =>
|
|
545
|
+
expect(items).toHaveAttribute('data-rendered-count', '50'),
|
|
546
|
+
);
|
|
547
|
+
fireEvent.change(screen.getByLabelText('Search Items'), {
|
|
548
|
+
target: {value: ''},
|
|
549
|
+
});
|
|
550
|
+
await waitFor(() =>
|
|
551
|
+
expect(items).toHaveAttribute('data-rendered-count', '50'),
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
Object.defineProperties(items, {
|
|
555
|
+
clientHeight: {configurable: true, value: 600},
|
|
556
|
+
scrollHeight: {configurable: true, value: 2400},
|
|
557
|
+
scrollTop: {configurable: true, value: 1700, writable: true},
|
|
558
|
+
});
|
|
559
|
+
fireEvent.scroll(items);
|
|
560
|
+
expect(items).toHaveAttribute('data-rendered-count', '100');
|
|
561
|
+
expect(screen.getAllByRole('checkbox')).toHaveLength(100);
|
|
562
|
+
expect(
|
|
563
|
+
screen.getByRole('checkbox', {name: 'Item 100'}),
|
|
564
|
+
).toBeInTheDocument();
|
|
565
|
+
|
|
566
|
+
Object.defineProperties(items, {
|
|
567
|
+
scrollHeight: {configurable: true, value: 4400},
|
|
568
|
+
scrollTop: {configurable: true, value: 3600, writable: true},
|
|
569
|
+
});
|
|
570
|
+
fireEvent.scroll(items);
|
|
571
|
+
expect(items).toHaveAttribute('data-rendered-count', '120');
|
|
572
|
+
expect(screen.getAllByRole('checkbox')).toHaveLength(120);
|
|
573
|
+
|
|
574
|
+
fireEvent.change(screen.getByLabelText('Search Items'), {
|
|
575
|
+
target: {value: 'Item'},
|
|
576
|
+
});
|
|
577
|
+
await waitFor(() =>
|
|
578
|
+
expect(items).toHaveAttribute('data-rendered-count', '50'),
|
|
579
|
+
);
|
|
580
|
+
expect(screen.getAllByRole('checkbox')).toHaveLength(50);
|
|
581
|
+
|
|
582
|
+
fireEvent.scroll(items);
|
|
583
|
+
expect(items).toHaveAttribute('data-rendered-count', '100');
|
|
584
|
+
expect(screen.getAllByRole('checkbox')).toHaveLength(100);
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
it('searches within the same sheet and shows the no-results state (FR18, FR20)', async () => {
|
|
588
|
+
const onChangeQuery = vi.fn();
|
|
589
|
+
const {rerender} = render(
|
|
590
|
+
<TokenizerWithPresentation
|
|
591
|
+
label="Tags"
|
|
592
|
+
searchSource={source}
|
|
593
|
+
value={[ITEMS[0]]}
|
|
594
|
+
onChange={() => {}}
|
|
595
|
+
debounceMs={0}
|
|
596
|
+
onChangeQuery={onChangeQuery}
|
|
597
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
598
|
+
/>,
|
|
599
|
+
);
|
|
600
|
+
fireEvent.click(openTrigger());
|
|
601
|
+
const search = await screen.findByLabelText('Search Tags');
|
|
602
|
+
fireEvent.change(search, {target: {value: 'zzz'}});
|
|
603
|
+
expect(onChangeQuery).toHaveBeenCalledWith('zzz');
|
|
604
|
+
|
|
605
|
+
const title = await screen.findByRole('heading', {
|
|
606
|
+
name: 'No results found',
|
|
607
|
+
});
|
|
608
|
+
// EmptyState is not a live region (it announces itself once when it
|
|
609
|
+
// appears); locate it by its own root.
|
|
610
|
+
const emptyState = title.closest('.astryx-empty-state');
|
|
611
|
+
expect(emptyState).toHaveTextContent('Try a different search.');
|
|
612
|
+
expect(emptyState?.querySelector('.astryx-icon')).toHaveAttribute(
|
|
613
|
+
'data-size',
|
|
614
|
+
'lg',
|
|
615
|
+
);
|
|
616
|
+
// Only one dialog: the sheet searches in place (FR18).
|
|
617
|
+
expect(screen.getAllByRole('dialog')).toHaveLength(1);
|
|
618
|
+
|
|
619
|
+
// A string emptySearchText becomes the empty state's title.
|
|
620
|
+
rerender(
|
|
621
|
+
<TokenizerWithPresentation
|
|
622
|
+
label="Tags"
|
|
623
|
+
searchSource={source}
|
|
624
|
+
value={[ITEMS[0]]}
|
|
625
|
+
onChange={() => {}}
|
|
626
|
+
debounceMs={0}
|
|
627
|
+
emptySearchText="Nothing here"
|
|
628
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
629
|
+
/>,
|
|
630
|
+
);
|
|
631
|
+
expect(
|
|
632
|
+
await screen.findByRole('heading', {name: 'Nothing here'}),
|
|
633
|
+
).toBeInTheDocument();
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
it('shows only the search field for an empty query with nothing to list, as the inline field does — no list, no message, no announcement (FR20)', async () => {
|
|
637
|
+
// A search-only source: typing finds items, the bootstrap set is empty.
|
|
638
|
+
const searchOnly: SearchSource<SearchableItem> = {
|
|
639
|
+
search: (q: string) =>
|
|
640
|
+
ITEMS.filter(item =>
|
|
641
|
+
item.label.toLowerCase().includes(q.toLowerCase()),
|
|
642
|
+
),
|
|
643
|
+
bootstrap: () => [],
|
|
644
|
+
};
|
|
645
|
+
const matches = Element.prototype.matches;
|
|
646
|
+
const modalSpy = vi
|
|
647
|
+
.spyOn(Element.prototype, 'matches')
|
|
648
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
649
|
+
return selector === ':modal'
|
|
650
|
+
? this instanceof HTMLDialogElement && this.open
|
|
651
|
+
: matches.call(this, selector);
|
|
652
|
+
});
|
|
653
|
+
try {
|
|
654
|
+
render(
|
|
655
|
+
<TokenizerWithPresentation
|
|
656
|
+
label="Tags"
|
|
657
|
+
searchSource={searchOnly}
|
|
658
|
+
value={[]}
|
|
659
|
+
onChange={() => {}}
|
|
660
|
+
debounceMs={0}
|
|
661
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
662
|
+
/>,
|
|
663
|
+
);
|
|
664
|
+
fireEvent.click(openTrigger());
|
|
665
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
666
|
+
const search = screen.getByLabelText('Search Tags');
|
|
667
|
+
await act(async () => {
|
|
668
|
+
await Promise.resolve();
|
|
669
|
+
});
|
|
670
|
+
expect(within(dialog).queryByRole('list')).not.toBeInTheDocument();
|
|
671
|
+
expect(within(dialog).queryByRole('heading')).not.toBeInTheDocument();
|
|
672
|
+
expect(screen.queryByText('No items available')).not.toBeInTheDocument();
|
|
673
|
+
expect(dialog.querySelector('.astryx-empty-state')).toBeNull();
|
|
674
|
+
expect(
|
|
675
|
+
within(dialog).queryByRole('img', {name: 'Loading'}),
|
|
676
|
+
).not.toBeInTheDocument();
|
|
677
|
+
// Nothing is announced for a bootstrap that returned nothing: not in
|
|
678
|
+
// the sheet's region, not on the page body.
|
|
679
|
+
expect(
|
|
680
|
+
dialog.querySelector(
|
|
681
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
682
|
+
)?.textContent ?? '',
|
|
683
|
+
).toBe('');
|
|
684
|
+
expect(
|
|
685
|
+
document.querySelector('[data-astryx-live-region="polite"]')
|
|
686
|
+
?.textContent ?? '',
|
|
687
|
+
).toBe('');
|
|
688
|
+
// The footer still closes the sheet (FR18); Clear all is spent.
|
|
689
|
+
expect(within(dialog).getByRole('button', {name: 'Done'})).toBeVisible();
|
|
690
|
+
expect(
|
|
691
|
+
within(dialog).getByRole('button', {name: 'Clear all'}),
|
|
692
|
+
).toHaveAttribute('aria-disabled', 'true');
|
|
693
|
+
// Typing is what finds items.
|
|
694
|
+
fireEvent.change(search, {target: {value: 'En'}});
|
|
695
|
+
await screen.findByRole('checkbox', {name: 'Eng'});
|
|
696
|
+
expect(within(dialog).getByRole('list')).toBeInTheDocument();
|
|
697
|
+
// Clearing returns to the search-only state, silently.
|
|
698
|
+
fireEvent.change(search, {target: {value: ''}});
|
|
699
|
+
await waitFor(() =>
|
|
700
|
+
expect(within(dialog).queryByRole('list')).not.toBeInTheDocument(),
|
|
701
|
+
);
|
|
702
|
+
expect(dialog.querySelector('.astryx-empty-state')).toBeNull();
|
|
703
|
+
} finally {
|
|
704
|
+
modalSpy.mockRestore();
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
it('renders nothing of the sheet at rest: the DOM holds the trigger alone until a press, and again once the exit has completed (INV7)', async () => {
|
|
709
|
+
render(<Harness />);
|
|
710
|
+
const trigger = openTrigger();
|
|
711
|
+
// The lazy chunk may load; give it a tick, then check nothing rendered.
|
|
712
|
+
await act(async () => {
|
|
713
|
+
await new Promise(resolve => setTimeout(resolve, 20));
|
|
714
|
+
});
|
|
715
|
+
const sheetDom = () => ({
|
|
716
|
+
dialog: document.querySelector('dialog'),
|
|
717
|
+
sheet: document.querySelector('.astryx-bottom-sheet'),
|
|
718
|
+
checkboxes: screen.queryAllByRole('checkbox').length,
|
|
719
|
+
search: screen.queryByLabelText('Search Tags'),
|
|
720
|
+
confirmation: screen.queryByRole('alertdialog'),
|
|
721
|
+
});
|
|
722
|
+
expect(sheetDom()).toEqual({
|
|
723
|
+
dialog: null,
|
|
724
|
+
sheet: null,
|
|
725
|
+
checkboxes: 0,
|
|
726
|
+
search: null,
|
|
727
|
+
confirmation: null,
|
|
728
|
+
});
|
|
729
|
+
// Each selected label is in the DOM once: the trigger's token.
|
|
730
|
+
expect(screen.getAllByText('Design')).toHaveLength(1);
|
|
731
|
+
|
|
732
|
+
fireEvent.click(trigger);
|
|
733
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
734
|
+
expect(sheetDom().dialog).not.toBeNull();
|
|
735
|
+
|
|
736
|
+
fireEvent.click(screen.getByRole('button', {name: 'Done'}));
|
|
737
|
+
fireEvent.transitionEnd(document.querySelector('.astryx-bottom-sheet')!, {
|
|
738
|
+
propertyName: 'transform',
|
|
739
|
+
});
|
|
740
|
+
await waitFor(() => expect(trigger).toHaveFocus());
|
|
741
|
+
await waitFor(() => expect(sheetDom().dialog).toBeNull());
|
|
742
|
+
expect(sheetDom()).toEqual({
|
|
743
|
+
dialog: null,
|
|
744
|
+
sheet: null,
|
|
745
|
+
checkboxes: 0,
|
|
746
|
+
search: null,
|
|
747
|
+
confirmation: null,
|
|
748
|
+
});
|
|
749
|
+
expect(screen.getAllByText('Design')).toHaveLength(1);
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
it('mounts the Clear all confirmation only from the press until it closes: no alertdialog while none is pending, focus placed on cancel and on confirm (FR24; INV7)', async () => {
|
|
753
|
+
const matches = Element.prototype.matches;
|
|
754
|
+
const modalSpy = vi
|
|
755
|
+
.spyOn(Element.prototype, 'matches')
|
|
756
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
757
|
+
return selector === ':modal'
|
|
758
|
+
? this instanceof HTMLDialogElement && this.open
|
|
759
|
+
: matches.call(this, selector);
|
|
760
|
+
});
|
|
761
|
+
try {
|
|
762
|
+
render(<Harness />);
|
|
763
|
+
fireEvent.click(openTrigger());
|
|
764
|
+
const sheet = await screen.findByRole('dialog', {name: 'Tags'});
|
|
765
|
+
await screen.findByRole('checkbox', {name: 'Eng'});
|
|
766
|
+
const noConfirmation = () => {
|
|
767
|
+
expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument();
|
|
768
|
+
expect(sheet.querySelectorAll('dialog')).toHaveLength(0);
|
|
769
|
+
};
|
|
770
|
+
noConfirmation();
|
|
771
|
+
const clearAll = screen.getByRole('button', {name: 'Clear all'});
|
|
772
|
+
|
|
773
|
+
// Cancel: the confirmation goes, focus is back on Clear all, nothing
|
|
774
|
+
// changed, nothing announced.
|
|
775
|
+
clearAll.focus();
|
|
776
|
+
fireEvent.click(clearAll);
|
|
777
|
+
const first = await screen.findByRole('alertdialog');
|
|
778
|
+
expect(sheet.contains(first)).toBe(true);
|
|
779
|
+
fireEvent.click(within(first).getByRole('button', {name: 'Cancel'}));
|
|
780
|
+
await waitFor(noConfirmation);
|
|
781
|
+
expect(clearAll).toHaveFocus();
|
|
782
|
+
expect(screen.getByRole('checkbox', {name: 'Design'})).toBeChecked();
|
|
783
|
+
|
|
784
|
+
// Confirm: the confirmation goes, the search field takes focus, the
|
|
785
|
+
// clear is announced inside the sheet.
|
|
786
|
+
fireEvent.click(clearAll);
|
|
787
|
+
const second = await screen.findByRole('alertdialog');
|
|
788
|
+
fireEvent.click(
|
|
789
|
+
within(second).getByRole('button', {name: 'Clear selection'}),
|
|
790
|
+
);
|
|
791
|
+
await waitFor(noConfirmation);
|
|
792
|
+
expect(screen.getByLabelText('Search Tags')).toHaveFocus();
|
|
793
|
+
await waitFor(() =>
|
|
794
|
+
expect(
|
|
795
|
+
sheet.querySelector(
|
|
796
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
797
|
+
),
|
|
798
|
+
).toHaveTextContent('All items removed'),
|
|
799
|
+
);
|
|
800
|
+
} finally {
|
|
801
|
+
modalSpy.mockRestore();
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
it('keeps large equal-width Clear all and Done footer actions while guarding the bulk clear (FR24)', async () => {
|
|
806
|
+
const spy = vi.fn();
|
|
807
|
+
render(<Harness spy={spy} />);
|
|
808
|
+
fireEvent.click(openTrigger());
|
|
809
|
+
await screen.findByRole('checkbox', {name: 'Energizer'});
|
|
810
|
+
|
|
811
|
+
const clearAll = screen.getByRole('button', {name: 'Clear all'});
|
|
812
|
+
const done = screen.getByRole('button', {name: 'Done'});
|
|
813
|
+
expect(clearAll).toHaveAttribute('data-size', 'lg');
|
|
814
|
+
expect(clearAll).toHaveAttribute('data-variant', 'secondary');
|
|
815
|
+
expect(done).toHaveAttribute('data-size', 'lg');
|
|
816
|
+
expect(list().compareDocumentPosition(clearAll)).toBe(
|
|
817
|
+
Node.DOCUMENT_POSITION_FOLLOWING,
|
|
818
|
+
);
|
|
819
|
+
expect(list().compareDocumentPosition(done)).toBe(
|
|
820
|
+
Node.DOCUMENT_POSITION_FOLLOWING,
|
|
821
|
+
);
|
|
822
|
+
fireEvent.click(clearAll);
|
|
823
|
+
const confirmation = screen.getByRole('alertdialog');
|
|
824
|
+
expect(confirmation).toHaveTextContent('Clear all selected items?');
|
|
825
|
+
expect(confirmation).toHaveTextContent(
|
|
826
|
+
'This removes all selected items from Tags.',
|
|
827
|
+
);
|
|
828
|
+
expect(spy).not.toHaveBeenCalled();
|
|
829
|
+
fireEvent.click(
|
|
830
|
+
within(confirmation).getByRole('button', {name: 'Clear selection'}),
|
|
831
|
+
);
|
|
832
|
+
expect(spy).toHaveBeenLastCalledWith(
|
|
833
|
+
[],
|
|
834
|
+
expect.objectContaining({type: 'remove', item: ITEMS[1]}),
|
|
835
|
+
);
|
|
836
|
+
await waitFor(() =>
|
|
837
|
+
expect(screen.getByRole('button', {name: 'Clear all'})).toHaveAttribute(
|
|
838
|
+
'aria-disabled',
|
|
839
|
+
'true',
|
|
840
|
+
),
|
|
841
|
+
);
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
it('keeps a disabled trigger focusable without opening the sheet (FR17; AST-085 FR1, FR2)', () => {
|
|
845
|
+
render(<Harness isDisabled initial={[ITEMS[0]]} />);
|
|
846
|
+
const trigger = openTrigger();
|
|
847
|
+
expect(trigger).not.toHaveAttribute('disabled');
|
|
848
|
+
expect(trigger).toHaveAttribute('aria-disabled', 'true');
|
|
849
|
+
trigger.focus();
|
|
850
|
+
expect(trigger).toHaveFocus();
|
|
851
|
+
fireEvent.click(trigger);
|
|
852
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
853
|
+
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
854
|
+
// A field disabled from the start mounts no sheet at all.
|
|
855
|
+
expect(document.querySelector('dialog')).toBeNull();
|
|
856
|
+
expect(document.querySelector('[data-total-count]')).toBeNull();
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
it('moves focus to the search field after a confirmed Clear all, since Clear all is disabled by then (FR24; AST-085 FR4)', async () => {
|
|
860
|
+
render(<Harness />);
|
|
861
|
+
fireEvent.click(openTrigger());
|
|
862
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
863
|
+
const clearAll = screen.getByRole('button', {name: 'Clear all'});
|
|
864
|
+
clearAll.focus();
|
|
865
|
+
fireEvent.click(clearAll);
|
|
866
|
+
const confirmation = await screen.findByRole('alertdialog');
|
|
867
|
+
fireEvent.click(
|
|
868
|
+
within(confirmation).getByRole('button', {name: 'Clear selection'}),
|
|
869
|
+
);
|
|
870
|
+
await waitFor(() =>
|
|
871
|
+
expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument(),
|
|
872
|
+
);
|
|
873
|
+
const clearAllAfter = screen.getByRole('button', {name: 'Clear all'});
|
|
874
|
+
expect(clearAllAfter).toHaveAttribute('aria-disabled', 'true');
|
|
875
|
+
expect(clearAllAfter).not.toBeDisabled();
|
|
876
|
+
expect(screen.getByLabelText('Search Tags')).toHaveFocus();
|
|
877
|
+
expect(document.activeElement).not.toBe(document.body);
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
it('caps the empty-query bootstrap set at maxMenuItems, as the inline field caps its focus bootstrap (FR20)', async () => {
|
|
881
|
+
// Twenty bootstrap items, two selected (one of them outside the capped
|
|
882
|
+
// window): the sheet lists the selected rows plus the first maxMenuItems
|
|
883
|
+
// bootstrap rows, not the whole set.
|
|
884
|
+
const many = Array.from({length: 20}, (_, i) => ({
|
|
885
|
+
id: `t${String(i).padStart(2, '0')}`,
|
|
886
|
+
label: `Tag ${String(i).padStart(2, '0')}`,
|
|
887
|
+
}));
|
|
888
|
+
const manySource = {
|
|
889
|
+
search: (q: string) =>
|
|
890
|
+
many.filter(item => item.label.toLowerCase().includes(q.toLowerCase())),
|
|
891
|
+
bootstrap: () => many,
|
|
892
|
+
};
|
|
893
|
+
render(
|
|
894
|
+
<TokenizerWithPresentation
|
|
895
|
+
label="Tags"
|
|
896
|
+
searchSource={manySource}
|
|
897
|
+
value={[many[1], many[15]]}
|
|
898
|
+
onChange={() => {}}
|
|
899
|
+
debounceMs={0}
|
|
900
|
+
maxMenuItems={5}
|
|
901
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
902
|
+
/>,
|
|
903
|
+
);
|
|
904
|
+
fireEvent.click(openTrigger());
|
|
905
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
906
|
+
await screen.findByRole('checkbox', {name: 'Tag 00'});
|
|
907
|
+
const rows = within(dialog)
|
|
908
|
+
.getAllByRole('checkbox')
|
|
909
|
+
.map(row => row.getAttribute('aria-label'));
|
|
910
|
+
// Selected first (Tag 01, Tag 15), then the capped bootstrap window's
|
|
911
|
+
// remaining rows (Tag 00, 02, 03, 04): five bootstrap rows in all.
|
|
912
|
+
expect(rows).toEqual([
|
|
913
|
+
'Tag 01',
|
|
914
|
+
'Tag 15',
|
|
915
|
+
'Tag 00',
|
|
916
|
+
'Tag 02',
|
|
917
|
+
'Tag 03',
|
|
918
|
+
'Tag 04',
|
|
919
|
+
]);
|
|
920
|
+
expect(dialog.querySelector('[data-total-count]')).toHaveAttribute(
|
|
921
|
+
'data-total-count',
|
|
922
|
+
'6',
|
|
923
|
+
);
|
|
924
|
+
});
|
|
925
|
+
|
|
926
|
+
it('announces the rows it lists, not the source count: a created value and a maxMenuItems cap (FR20; AR6)', async () => {
|
|
927
|
+
const matches = Element.prototype.matches;
|
|
928
|
+
const modalSpy = vi
|
|
929
|
+
.spyOn(Element.prototype, 'matches')
|
|
930
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
931
|
+
return selector === ':modal'
|
|
932
|
+
? this instanceof HTMLDialogElement && this.open
|
|
933
|
+
: matches.call(this, selector);
|
|
934
|
+
});
|
|
935
|
+
try {
|
|
936
|
+
// "Enzo" is a created value the source never returns; the source has
|
|
937
|
+
// three "en" matches (Eng, Engineer, Energizer), capped to two rows.
|
|
938
|
+
render(
|
|
939
|
+
<TokenizerWithPresentation
|
|
940
|
+
label="Tags"
|
|
941
|
+
searchSource={source}
|
|
942
|
+
value={[{id: 'Enzo', label: 'Enzo'}]}
|
|
943
|
+
onChange={() => {}}
|
|
944
|
+
debounceMs={0}
|
|
945
|
+
maxMenuItems={2}
|
|
946
|
+
hasCreate
|
|
947
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
948
|
+
/>,
|
|
949
|
+
);
|
|
950
|
+
fireEvent.click(openTrigger());
|
|
951
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
952
|
+
const region = () =>
|
|
953
|
+
dialog.querySelector(
|
|
954
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
955
|
+
);
|
|
956
|
+
// Part of the created value: the source returns nothing, but the
|
|
957
|
+
// checked row for Enzo is listed, and the sheet offers a create row
|
|
958
|
+
// for "enz" — two entries, not "0 results".
|
|
959
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
960
|
+
target: {value: 'enz'},
|
|
961
|
+
});
|
|
962
|
+
await screen.findByRole('checkbox', {name: 'Enzo'});
|
|
963
|
+
await screen.findByRole('button', {name: 'Add enz'});
|
|
964
|
+
await waitFor(() => expect(region()).toHaveTextContent('2 results'));
|
|
965
|
+
expect(region()).not.toHaveTextContent('0 results');
|
|
966
|
+
// A query the cap applies to: the source has three matches, capped to
|
|
967
|
+
// two rows, plus the created value's checked row, plus the create row
|
|
968
|
+
// the sheet offers for "en" — four entries listed, four announced (the
|
|
969
|
+
// source count would say two, or three uncapped).
|
|
970
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
971
|
+
target: {value: 'en'},
|
|
972
|
+
});
|
|
973
|
+
await screen.findByRole('button', {name: 'Add en'});
|
|
974
|
+
await waitFor(() => expect(region()).toHaveTextContent('4 results'));
|
|
975
|
+
expect(screen.getAllByRole('checkbox')).toHaveLength(3);
|
|
976
|
+
expect(
|
|
977
|
+
screen.queryByRole('checkbox', {name: 'Energizer'}),
|
|
978
|
+
).not.toBeInTheDocument();
|
|
979
|
+
} finally {
|
|
980
|
+
modalSpy.mockRestore();
|
|
981
|
+
}
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
it('counts the create row it offers, as the inline field counts its create entry (FR20, FR22; AR6)', async () => {
|
|
985
|
+
const matches = Element.prototype.matches;
|
|
986
|
+
const modalSpy = vi
|
|
987
|
+
.spyOn(Element.prototype, 'matches')
|
|
988
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
989
|
+
return selector === ':modal'
|
|
990
|
+
? this instanceof HTMLDialogElement && this.open
|
|
991
|
+
: matches.call(this, selector);
|
|
992
|
+
});
|
|
993
|
+
try {
|
|
994
|
+
render(<Harness hasCreate initial={[]} />);
|
|
995
|
+
fireEvent.click(openTrigger());
|
|
996
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
997
|
+
const region = () =>
|
|
998
|
+
dialog.querySelector(
|
|
999
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
1000
|
+
);
|
|
1001
|
+
// Nothing from the source, one create row offered: "1 result", not
|
|
1002
|
+
// "0 results" over a row the person can act on.
|
|
1003
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
1004
|
+
target: {value: 'Custom'},
|
|
1005
|
+
});
|
|
1006
|
+
await screen.findByRole('button', {name: 'Add Custom'});
|
|
1007
|
+
await waitFor(() => expect(region()).toHaveTextContent('1 result'));
|
|
1008
|
+
expect(region()).not.toHaveTextContent('0 results');
|
|
1009
|
+
// An exact source match offers no create row: the one row counts.
|
|
1010
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
1011
|
+
target: {value: 'Design'},
|
|
1012
|
+
});
|
|
1013
|
+
await screen.findByRole('checkbox', {name: 'Design'});
|
|
1014
|
+
expect(
|
|
1015
|
+
screen.queryByRole('button', {name: 'Add Design'}),
|
|
1016
|
+
).not.toBeInTheDocument();
|
|
1017
|
+
await waitFor(() => expect(region()).toHaveTextContent('1 result'));
|
|
1018
|
+
} finally {
|
|
1019
|
+
modalSpy.mockRestore();
|
|
1020
|
+
}
|
|
1021
|
+
});
|
|
1022
|
+
|
|
1023
|
+
it('keeps a spent Clear all focusable with aria-disabled and no action, instead of native disabled (FR24; AST-085 FR1)', async () => {
|
|
1024
|
+
render(<Harness initial={[]} />);
|
|
1025
|
+
fireEvent.click(openTrigger());
|
|
1026
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
1027
|
+
const clearAll = screen.getByRole('button', {name: 'Clear all'});
|
|
1028
|
+
expect(clearAll).toHaveAttribute('aria-disabled', 'true');
|
|
1029
|
+
expect(clearAll).not.toHaveAttribute('disabled');
|
|
1030
|
+
// In the tab order, and it says why it does nothing.
|
|
1031
|
+
clearAll.focus();
|
|
1032
|
+
expect(clearAll).toHaveFocus();
|
|
1033
|
+
expect(clearAll).toHaveAccessibleDescription('Nothing selected');
|
|
1034
|
+
// A click opens no confirmation.
|
|
1035
|
+
fireEvent.click(clearAll);
|
|
1036
|
+
expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument();
|
|
1037
|
+
});
|
|
1038
|
+
|
|
1039
|
+
it('asks a source rebuilt in render only on open, on a query change, and on clearing — not on a row toggle (FR20)', async () => {
|
|
1040
|
+
const search = vi.fn((q: string) =>
|
|
1041
|
+
ITEMS.filter(item => item.label.toLowerCase().includes(q.toLowerCase())),
|
|
1042
|
+
);
|
|
1043
|
+
const bootstrap = vi.fn(() => ITEMS);
|
|
1044
|
+
function InlineSourceHarness() {
|
|
1045
|
+
const [value, setValue] = useState<SearchableItem[]>([ITEMS[0]]);
|
|
1046
|
+
return (
|
|
1047
|
+
<TokenizerWithPresentation
|
|
1048
|
+
label="Tags"
|
|
1049
|
+
// A new object every render, as a caller writing the source inline
|
|
1050
|
+
// produces; the selection change on each toggle re-renders.
|
|
1051
|
+
searchSource={{search, bootstrap}}
|
|
1052
|
+
value={value}
|
|
1053
|
+
onChange={items => setValue(items)}
|
|
1054
|
+
debounceMs={0}
|
|
1055
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1056
|
+
/>
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
render(<InlineSourceHarness />);
|
|
1060
|
+
fireEvent.click(openTrigger());
|
|
1061
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
1062
|
+
await screen.findByRole('checkbox', {name: 'Eng'});
|
|
1063
|
+
expect(bootstrap).toHaveBeenCalledTimes(1);
|
|
1064
|
+
expect(search).not.toHaveBeenCalled();
|
|
1065
|
+
// Row toggles re-render with a fresh source object: no new request.
|
|
1066
|
+
fireEvent.click(screen.getByRole('checkbox', {name: 'Eng'}));
|
|
1067
|
+
await waitFor(() =>
|
|
1068
|
+
expect(screen.getByRole('checkbox', {name: 'Eng'})).toBeChecked(),
|
|
1069
|
+
);
|
|
1070
|
+
fireEvent.click(screen.getByRole('checkbox', {name: 'Engineer'}));
|
|
1071
|
+
await waitFor(() =>
|
|
1072
|
+
expect(screen.getByRole('checkbox', {name: 'Engineer'})).toBeChecked(),
|
|
1073
|
+
);
|
|
1074
|
+
fireEvent.click(screen.getByRole('checkbox', {name: 'Eng'}));
|
|
1075
|
+
await waitFor(() =>
|
|
1076
|
+
expect(screen.getByRole('checkbox', {name: 'Eng'})).not.toBeChecked(),
|
|
1077
|
+
);
|
|
1078
|
+
expect(bootstrap).toHaveBeenCalledTimes(1);
|
|
1079
|
+
expect(search).not.toHaveBeenCalled();
|
|
1080
|
+
// A query change asks the source once; clearing asks for the bootstrap
|
|
1081
|
+
// set once more.
|
|
1082
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
1083
|
+
target: {value: 'en'},
|
|
1084
|
+
});
|
|
1085
|
+
await waitFor(() => expect(search).toHaveBeenCalledTimes(1));
|
|
1086
|
+
expect(search).toHaveBeenLastCalledWith('en');
|
|
1087
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
1088
|
+
target: {value: ''},
|
|
1089
|
+
});
|
|
1090
|
+
await waitFor(() => expect(bootstrap).toHaveBeenCalledTimes(2));
|
|
1091
|
+
expect(search).toHaveBeenCalledTimes(1);
|
|
1092
|
+
});
|
|
1093
|
+
|
|
1094
|
+
it('announces a confirmed Clear all inside the sheet (AR6; AST-086 FR14)', async () => {
|
|
1095
|
+
// jsdom has no showModal(); stand in for the sheet presented modally so
|
|
1096
|
+
// the announcement takes the in-dialog route.
|
|
1097
|
+
const matches = Element.prototype.matches;
|
|
1098
|
+
const modalSpy = vi
|
|
1099
|
+
.spyOn(Element.prototype, 'matches')
|
|
1100
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
1101
|
+
return selector === ':modal'
|
|
1102
|
+
? this instanceof HTMLDialogElement && this.open
|
|
1103
|
+
: matches.call(this, selector);
|
|
1104
|
+
});
|
|
1105
|
+
try {
|
|
1106
|
+
render(<Harness />);
|
|
1107
|
+
fireEvent.click(openTrigger());
|
|
1108
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
1109
|
+
fireEvent.click(screen.getByRole('button', {name: 'Clear all'}));
|
|
1110
|
+
const confirmation = await screen.findByRole('alertdialog');
|
|
1111
|
+
fireEvent.click(
|
|
1112
|
+
within(confirmation).getByRole('button', {name: 'Clear selection'}),
|
|
1113
|
+
);
|
|
1114
|
+
await waitFor(() =>
|
|
1115
|
+
expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument(),
|
|
1116
|
+
);
|
|
1117
|
+
await waitFor(() =>
|
|
1118
|
+
expect(
|
|
1119
|
+
dialog.querySelector(
|
|
1120
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
1121
|
+
),
|
|
1122
|
+
).toHaveTextContent('All items removed'),
|
|
1123
|
+
);
|
|
1124
|
+
} finally {
|
|
1125
|
+
modalSpy.mockRestore();
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1128
|
+
|
|
1129
|
+
it('keeps and does not report the query when the field is disabled while the sheet is open (FR18)', async () => {
|
|
1130
|
+
const onChangeQuery = vi.fn();
|
|
1131
|
+
const props = {
|
|
1132
|
+
label: 'Tags',
|
|
1133
|
+
searchSource: source,
|
|
1134
|
+
value: [ITEMS[0]],
|
|
1135
|
+
onChange: () => {},
|
|
1136
|
+
onChangeQuery,
|
|
1137
|
+
debounceMs: 0,
|
|
1138
|
+
experimental: {presentation: 'bottom-sheet' as const},
|
|
1139
|
+
};
|
|
1140
|
+
const {rerender} = render(<TokenizerWithPresentation {...props} />);
|
|
1141
|
+
fireEvent.click(openTrigger());
|
|
1142
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
1143
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
1144
|
+
target: {value: 'En'},
|
|
1145
|
+
});
|
|
1146
|
+
onChangeQuery.mockClear();
|
|
1147
|
+
rerender(<TokenizerWithPresentation {...props} isDisabled />);
|
|
1148
|
+
fireEvent.transitionEnd(document.querySelector('.astryx-bottom-sheet')!, {
|
|
1149
|
+
propertyName: 'transform',
|
|
1150
|
+
});
|
|
1151
|
+
// Nothing the person did changed the query, so nothing is reported, and
|
|
1152
|
+
// the caller's mirror and the sheet agree on the next open.
|
|
1153
|
+
expect(onChangeQuery).not.toHaveBeenCalled();
|
|
1154
|
+
rerender(<TokenizerWithPresentation {...props} />);
|
|
1155
|
+
fireEvent.click(openTrigger());
|
|
1156
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
1157
|
+
expect(screen.getByLabelText('Search Tags')).toHaveValue('En');
|
|
1158
|
+
expect(onChangeQuery).not.toHaveBeenCalled();
|
|
1159
|
+
});
|
|
1160
|
+
|
|
1161
|
+
it('reopens settled, not pending, after a forced close kept a query shorter than minQueryLength (FR18, FR20)', async () => {
|
|
1162
|
+
const props = {
|
|
1163
|
+
label: 'Tags',
|
|
1164
|
+
searchSource: source,
|
|
1165
|
+
value: [ITEMS[0]],
|
|
1166
|
+
onChange: () => {},
|
|
1167
|
+
debounceMs: 0,
|
|
1168
|
+
minQueryLength: 3,
|
|
1169
|
+
experimental: {presentation: 'bottom-sheet' as const},
|
|
1170
|
+
};
|
|
1171
|
+
const {rerender} = render(<TokenizerWithPresentation {...props} />);
|
|
1172
|
+
fireEvent.click(openTrigger());
|
|
1173
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
1174
|
+
// Two characters: below the threshold, so nothing is searched.
|
|
1175
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
1176
|
+
target: {value: 'En'},
|
|
1177
|
+
});
|
|
1178
|
+
// The field becomes disabled: the sheet closes, keeping the query.
|
|
1179
|
+
rerender(<TokenizerWithPresentation {...props} isDisabled />);
|
|
1180
|
+
fireEvent.transitionEnd(document.querySelector('.astryx-bottom-sheet')!, {
|
|
1181
|
+
propertyName: 'transform',
|
|
1182
|
+
});
|
|
1183
|
+
await waitFor(() => expect(openTrigger()).toHaveFocus());
|
|
1184
|
+
await waitFor(() =>
|
|
1185
|
+
expect(screen.queryByRole('dialog')).not.toBeInTheDocument(),
|
|
1186
|
+
);
|
|
1187
|
+
rerender(<TokenizerWithPresentation {...props} />);
|
|
1188
|
+
fireEvent.click(openTrigger());
|
|
1189
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
1190
|
+
expect(screen.getByLabelText('Search Tags')).toHaveValue('En');
|
|
1191
|
+
// Mounted open with a query no search runs for: settled at once — no
|
|
1192
|
+
// busy feedback, no aria-busy, only the selected rows the query matches
|
|
1193
|
+
// (none: "Design" does not contain "En"), no empty state, and nothing
|
|
1194
|
+
// announced.
|
|
1195
|
+
await act(async () => {
|
|
1196
|
+
await new Promise(resolve => setTimeout(resolve, 20));
|
|
1197
|
+
});
|
|
1198
|
+
expect(
|
|
1199
|
+
within(dialog).queryByRole('img', {name: 'Loading'}),
|
|
1200
|
+
).not.toBeInTheDocument();
|
|
1201
|
+
expect(dialog.querySelector('[data-total-count]')).not.toHaveAttribute(
|
|
1202
|
+
'aria-busy',
|
|
1203
|
+
);
|
|
1204
|
+
expect(within(dialog).queryAllByRole('checkbox')).toHaveLength(0);
|
|
1205
|
+
expect(dialog.querySelector('.astryx-empty-state')).toBeNull();
|
|
1206
|
+
expect(
|
|
1207
|
+
dialog.querySelector(':scope > [data-astryx-modal-live-region="polite"]')
|
|
1208
|
+
?.textContent ?? '',
|
|
1209
|
+
).toBe('');
|
|
1210
|
+
// Typing on past the threshold searches as usual.
|
|
1211
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
1212
|
+
target: {value: 'Eng'},
|
|
1213
|
+
});
|
|
1214
|
+
await screen.findByRole('checkbox', {name: 'Eng'});
|
|
1215
|
+
});
|
|
1216
|
+
|
|
1217
|
+
it('closes the sheet and returns focus to the trigger when the field becomes disabled (FR17; AST-085 FR2)', async () => {
|
|
1218
|
+
const {rerender} = render(
|
|
1219
|
+
<TokenizerWithPresentation
|
|
1220
|
+
label="Tags"
|
|
1221
|
+
searchSource={source}
|
|
1222
|
+
value={[ITEMS[0]]}
|
|
1223
|
+
onChange={() => {}}
|
|
1224
|
+
debounceMs={0}
|
|
1225
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1226
|
+
/>,
|
|
1227
|
+
);
|
|
1228
|
+
const trigger = openTrigger();
|
|
1229
|
+
fireEvent.click(trigger);
|
|
1230
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
1231
|
+
const search = screen.getByLabelText('Search Tags');
|
|
1232
|
+
search.focus();
|
|
1233
|
+
expect(search).toHaveFocus();
|
|
1234
|
+
|
|
1235
|
+
rerender(
|
|
1236
|
+
<TokenizerWithPresentation
|
|
1237
|
+
label="Tags"
|
|
1238
|
+
searchSource={source}
|
|
1239
|
+
value={[ITEMS[0]]}
|
|
1240
|
+
onChange={() => {}}
|
|
1241
|
+
debounceMs={0}
|
|
1242
|
+
isDisabled
|
|
1243
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1244
|
+
/>,
|
|
1245
|
+
);
|
|
1246
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
1247
|
+
expect(dialog).toHaveAttribute('aria-hidden', 'true');
|
|
1248
|
+
// BottomSheet hands focus back after its exit motion.
|
|
1249
|
+
fireEvent.transitionEnd(document.querySelector('.astryx-bottom-sheet')!, {
|
|
1250
|
+
propertyName: 'transform',
|
|
1251
|
+
});
|
|
1252
|
+
expect(trigger).toHaveFocus();
|
|
1253
|
+
expect(trigger).toHaveAttribute('aria-disabled', 'true');
|
|
1254
|
+
// Re-enabling does not reopen it.
|
|
1255
|
+
rerender(
|
|
1256
|
+
<TokenizerWithPresentation
|
|
1257
|
+
label="Tags"
|
|
1258
|
+
searchSource={source}
|
|
1259
|
+
value={[ITEMS[0]]}
|
|
1260
|
+
onChange={() => {}}
|
|
1261
|
+
debounceMs={0}
|
|
1262
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1263
|
+
/>,
|
|
1264
|
+
);
|
|
1265
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
1266
|
+
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
1267
|
+
});
|
|
1268
|
+
|
|
1269
|
+
it("exposes the caller's ids, the field description, the status and the disabled reason on a disabled trigger, in the inline field's order, before the count and tokens (AR6; AST-085 FR5)", () => {
|
|
1270
|
+
render(
|
|
1271
|
+
<>
|
|
1272
|
+
<span id="hint">Up to five</span>
|
|
1273
|
+
<TokenizerWithPresentation
|
|
1274
|
+
label="Tags"
|
|
1275
|
+
searchSource={source}
|
|
1276
|
+
value={[ITEMS[0], ITEMS[1]]}
|
|
1277
|
+
onChange={() => {}}
|
|
1278
|
+
aria-describedby="hint"
|
|
1279
|
+
description="Pick some"
|
|
1280
|
+
status={{type: 'error', message: 'Pick at least three'}}
|
|
1281
|
+
isDisabled
|
|
1282
|
+
disabledMessage="Locked while syncing"
|
|
1283
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1284
|
+
/>
|
|
1285
|
+
</>,
|
|
1286
|
+
);
|
|
1287
|
+
const trigger = openTrigger();
|
|
1288
|
+
expect(trigger).toHaveAttribute('aria-disabled', 'true');
|
|
1289
|
+
const ids = trigger.getAttribute('aria-describedby')!.split(' ');
|
|
1290
|
+
const texts = ids.map(id => document.getElementById(id)?.textContent);
|
|
1291
|
+
expect(texts).toEqual([
|
|
1292
|
+
'Up to five',
|
|
1293
|
+
'Pick some',
|
|
1294
|
+
'Pick at least three',
|
|
1295
|
+
'Locked while syncing',
|
|
1296
|
+
'2 selected',
|
|
1297
|
+
'Design',
|
|
1298
|
+
'Eng',
|
|
1299
|
+
]);
|
|
1300
|
+
expect(trigger).toHaveAccessibleDescription(
|
|
1301
|
+
'Up to five Pick some Pick at least three Locked while syncing 2 selected Design Eng',
|
|
1302
|
+
);
|
|
1303
|
+
});
|
|
1304
|
+
|
|
1305
|
+
it('describes the trigger with the selected token labels for assistive technology (AR6; AST-020 FR1)', () => {
|
|
1306
|
+
const {unmount} = render(<Harness />);
|
|
1307
|
+
const trigger = openTrigger();
|
|
1308
|
+
expect(trigger).toHaveAccessibleName('Tags');
|
|
1309
|
+
// A catalog count, then each label; the separator is the accessible-name
|
|
1310
|
+
// algorithm's, not a literal (i18n INV1a).
|
|
1311
|
+
expect(trigger).toHaveAccessibleDescription('2 selected Design Eng');
|
|
1312
|
+
// The labels come from the rendered tokens themselves, referenced by id:
|
|
1313
|
+
// in the trigger and its description, each label is in the DOM once
|
|
1314
|
+
// (component-style-authoring INV7); the only hidden text is the count.
|
|
1315
|
+
const ids = trigger.getAttribute('aria-describedby')!.split(' ');
|
|
1316
|
+
expect(ids).toHaveLength(3);
|
|
1317
|
+
const described = ids.map(id => document.getElementById(id)!);
|
|
1318
|
+
expect(described[0]).toHaveTextContent('2 selected');
|
|
1319
|
+
expect(described[1]).toBe(
|
|
1320
|
+
within(trigger).getByText('Design').closest('.astryx-token'),
|
|
1321
|
+
);
|
|
1322
|
+
expect(described[2]).toBe(
|
|
1323
|
+
within(trigger).getByText('Eng').closest('.astryx-token'),
|
|
1324
|
+
);
|
|
1325
|
+
const leaves = (root: Element) =>
|
|
1326
|
+
Array.from(root.querySelectorAll('*')).filter(
|
|
1327
|
+
el => el.children.length === 0 && el.textContent?.trim() !== '',
|
|
1328
|
+
);
|
|
1329
|
+
const texts = [...leaves(trigger), ...leaves(described[0])].map(
|
|
1330
|
+
el => el.textContent,
|
|
1331
|
+
);
|
|
1332
|
+
expect(texts.filter(text => text === 'Design')).toHaveLength(1);
|
|
1333
|
+
expect(texts.filter(text => text === 'Eng')).toHaveLength(1);
|
|
1334
|
+
unmount();
|
|
1335
|
+
render(<Harness initial={[]} />);
|
|
1336
|
+
expect(openTrigger()).not.toHaveAttribute('aria-describedby');
|
|
1337
|
+
});
|
|
1338
|
+
|
|
1339
|
+
it('sends base props and ref to the trigger in the sheet presentation (FR10, INV8)', () => {
|
|
1340
|
+
const ref = createRef<HTMLInputElement>();
|
|
1341
|
+
const onFocus = vi.fn();
|
|
1342
|
+
const onKeyDown = vi.fn();
|
|
1343
|
+
render(
|
|
1344
|
+
<TokenizerWithPresentation
|
|
1345
|
+
label="Tags"
|
|
1346
|
+
searchSource={source}
|
|
1347
|
+
value={[ITEMS[0]]}
|
|
1348
|
+
onChange={() => {}}
|
|
1349
|
+
id="tags-field"
|
|
1350
|
+
data-testid="tags"
|
|
1351
|
+
aria-describedby="hint"
|
|
1352
|
+
description="Pick some"
|
|
1353
|
+
ref={ref}
|
|
1354
|
+
onFocus={onFocus}
|
|
1355
|
+
onKeyDown={onKeyDown}
|
|
1356
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1357
|
+
/>,
|
|
1358
|
+
);
|
|
1359
|
+
const trigger = openTrigger();
|
|
1360
|
+
expect(trigger).toHaveAttribute('id', 'tags-field');
|
|
1361
|
+
expect(trigger).toHaveAttribute('data-testid', 'tags');
|
|
1362
|
+
expect(trigger.getAttribute('aria-describedby')).toContain('hint');
|
|
1363
|
+
expect(trigger).toHaveAccessibleDescription(/Pick some/);
|
|
1364
|
+
expect(ref.current).toBe(trigger);
|
|
1365
|
+
// The label points at the trigger.
|
|
1366
|
+
expect(screen.getByText('Tags', {selector: 'label'})).toHaveAttribute(
|
|
1367
|
+
'for',
|
|
1368
|
+
'tags-field',
|
|
1369
|
+
);
|
|
1370
|
+
fireEvent.focus(trigger);
|
|
1371
|
+
expect(onFocus).toHaveBeenCalledTimes(1);
|
|
1372
|
+
fireEvent.keyDown(trigger, {key: 'ArrowDown'});
|
|
1373
|
+
expect(onKeyDown).toHaveBeenCalledTimes(1);
|
|
1374
|
+
});
|
|
1375
|
+
|
|
1376
|
+
it('treats the sheet as part of the field: no onBlur on open, no onFocus on return, both on a real exit (FR10)', async () => {
|
|
1377
|
+
const onFocus = vi.fn();
|
|
1378
|
+
const onBlur = vi.fn();
|
|
1379
|
+
render(
|
|
1380
|
+
<>
|
|
1381
|
+
<TokenizerWithPresentation
|
|
1382
|
+
label="Tags"
|
|
1383
|
+
searchSource={source}
|
|
1384
|
+
value={[ITEMS[0]]}
|
|
1385
|
+
onChange={() => {}}
|
|
1386
|
+
debounceMs={0}
|
|
1387
|
+
onFocus={onFocus}
|
|
1388
|
+
onBlur={onBlur}
|
|
1389
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1390
|
+
/>
|
|
1391
|
+
<button type="button">Elsewhere</button>
|
|
1392
|
+
</>,
|
|
1393
|
+
);
|
|
1394
|
+
const trigger = openTrigger();
|
|
1395
|
+
// Entering the field from outside reports once.
|
|
1396
|
+
trigger.focus();
|
|
1397
|
+
expect(onFocus).toHaveBeenCalledTimes(1);
|
|
1398
|
+
// Open: focus moves into the field's own sheet, not out of the field.
|
|
1399
|
+
fireEvent.click(trigger);
|
|
1400
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
1401
|
+
screen.getByLabelText('Search Tags').focus();
|
|
1402
|
+
expect(onBlur).not.toHaveBeenCalled();
|
|
1403
|
+
// Done: focus returns from the sheet, not from outside.
|
|
1404
|
+
fireEvent.click(screen.getByRole('button', {name: 'Done'}));
|
|
1405
|
+
fireEvent.transitionEnd(document.querySelector('.astryx-bottom-sheet')!, {
|
|
1406
|
+
propertyName: 'transform',
|
|
1407
|
+
});
|
|
1408
|
+
expect(trigger).toHaveFocus();
|
|
1409
|
+
expect(onFocus).toHaveBeenCalledTimes(1);
|
|
1410
|
+
expect(onBlur).not.toHaveBeenCalled();
|
|
1411
|
+
// A real exit, from the trigger to elsewhere, reports.
|
|
1412
|
+
screen.getByRole('button', {name: 'Elsewhere'}).focus();
|
|
1413
|
+
expect(onBlur).toHaveBeenCalledTimes(1);
|
|
1414
|
+
// And a second open-and-close cycle from outside reports the entry once.
|
|
1415
|
+
trigger.focus();
|
|
1416
|
+
expect(onFocus).toHaveBeenCalledTimes(2);
|
|
1417
|
+
fireEvent.click(trigger);
|
|
1418
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
1419
|
+
fireEvent.click(screen.getByRole('button', {name: 'Done'}));
|
|
1420
|
+
fireEvent.transitionEnd(document.querySelector('.astryx-bottom-sheet')!, {
|
|
1421
|
+
propertyName: 'transform',
|
|
1422
|
+
});
|
|
1423
|
+
expect(onFocus).toHaveBeenCalledTimes(2);
|
|
1424
|
+
expect(onBlur).toHaveBeenCalledTimes(1);
|
|
1425
|
+
});
|
|
1426
|
+
|
|
1427
|
+
it('reports the entry on the return focus when the open came from a click that did not focus the trigger (Safari), so onBlur never comes alone (FR10)', async () => {
|
|
1428
|
+
const onFocus = vi.fn();
|
|
1429
|
+
const onBlur = vi.fn();
|
|
1430
|
+
render(
|
|
1431
|
+
<>
|
|
1432
|
+
<TokenizerWithPresentation
|
|
1433
|
+
label="Tags"
|
|
1434
|
+
searchSource={source}
|
|
1435
|
+
value={[ITEMS[0]]}
|
|
1436
|
+
onChange={() => {}}
|
|
1437
|
+
debounceMs={0}
|
|
1438
|
+
onFocus={onFocus}
|
|
1439
|
+
onBlur={onBlur}
|
|
1440
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1441
|
+
/>
|
|
1442
|
+
<button type="button">Elsewhere</button>
|
|
1443
|
+
</>,
|
|
1444
|
+
);
|
|
1445
|
+
const trigger = openTrigger();
|
|
1446
|
+
// A click with no focus first, as Safari delivers a pointer press on a
|
|
1447
|
+
// button: no entry has been reported when the sheet opens.
|
|
1448
|
+
fireEvent.click(trigger);
|
|
1449
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
1450
|
+
expect(onFocus).not.toHaveBeenCalled();
|
|
1451
|
+
expect(onBlur).not.toHaveBeenCalled();
|
|
1452
|
+
// Done: BottomSheet's return focus is the one focus the trigger gets in
|
|
1453
|
+
// this visit, so it is the entry, and is reported.
|
|
1454
|
+
fireEvent.click(screen.getByRole('button', {name: 'Done'}));
|
|
1455
|
+
fireEvent.transitionEnd(document.querySelector('.astryx-bottom-sheet')!, {
|
|
1456
|
+
propertyName: 'transform',
|
|
1457
|
+
});
|
|
1458
|
+
expect(trigger).toHaveFocus();
|
|
1459
|
+
expect(onFocus).toHaveBeenCalledTimes(1);
|
|
1460
|
+
expect(onBlur).not.toHaveBeenCalled();
|
|
1461
|
+
// Leaving reports the exit: one onFocus, one onBlur.
|
|
1462
|
+
screen.getByRole('button', {name: 'Elsewhere'}).focus();
|
|
1463
|
+
expect(onBlur).toHaveBeenCalledTimes(1);
|
|
1464
|
+
expect(onFocus).toHaveBeenCalledTimes(1);
|
|
1465
|
+
});
|
|
1466
|
+
|
|
1467
|
+
it('runs the open first and then the caller onClick, which cannot cancel it (FR10)', async () => {
|
|
1468
|
+
const order: string[] = [];
|
|
1469
|
+
const onClick = vi.fn((event: React.MouseEvent) => {
|
|
1470
|
+
order.push(
|
|
1471
|
+
(event.currentTarget as HTMLElement).getAttribute('aria-expanded') ??
|
|
1472
|
+
'',
|
|
1473
|
+
);
|
|
1474
|
+
event.preventDefault();
|
|
1475
|
+
});
|
|
1476
|
+
render(
|
|
1477
|
+
<TokenizerWithPresentation
|
|
1478
|
+
label="Tags"
|
|
1479
|
+
searchSource={source}
|
|
1480
|
+
value={[ITEMS[0]]}
|
|
1481
|
+
onChange={() => {}}
|
|
1482
|
+
debounceMs={0}
|
|
1483
|
+
onClick={onClick}
|
|
1484
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1485
|
+
/>,
|
|
1486
|
+
);
|
|
1487
|
+
const trigger = openTrigger();
|
|
1488
|
+
fireEvent.click(trigger);
|
|
1489
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
1490
|
+
// The caller's preventDefault() does not keep the sheet closed, as the
|
|
1491
|
+
// inline field's own click handling runs first and is not cancelable.
|
|
1492
|
+
expect(
|
|
1493
|
+
await screen.findByRole('dialog', {name: 'Tags'}),
|
|
1494
|
+
).toBeInTheDocument();
|
|
1495
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'true');
|
|
1496
|
+
// The caller saw the click on the trigger (its pre-open state in the same
|
|
1497
|
+
// event, since the open commits after the handler).
|
|
1498
|
+
expect(order).toEqual(['false']);
|
|
1499
|
+
});
|
|
1500
|
+
|
|
1501
|
+
it('warns once in development about props with no sheet surface (INV3)', () => {
|
|
1502
|
+
__resetDevWarnings();
|
|
1503
|
+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
1504
|
+
const {rerender} = render(
|
|
1505
|
+
<TokenizerWithPresentation
|
|
1506
|
+
label="Tags"
|
|
1507
|
+
searchSource={source}
|
|
1508
|
+
value={[ITEMS[0]]}
|
|
1509
|
+
onChange={() => {}}
|
|
1510
|
+
hasClear
|
|
1511
|
+
menuWidth={320}
|
|
1512
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1513
|
+
/>,
|
|
1514
|
+
);
|
|
1515
|
+
expect(warn).toHaveBeenCalledTimes(1);
|
|
1516
|
+
expect(warn.mock.calls[0][0]).toMatch(/Tokenizer/);
|
|
1517
|
+
expect(warn.mock.calls[0][0]).toMatch(/`hasClear`, `menuWidth`/);
|
|
1518
|
+
expect(warn.mock.calls[0][0]).toMatch(/bottom-sheet presentation/);
|
|
1519
|
+
rerender(
|
|
1520
|
+
<TokenizerWithPresentation
|
|
1521
|
+
label="Tags"
|
|
1522
|
+
searchSource={source}
|
|
1523
|
+
value={[ITEMS[0], ITEMS[1]]}
|
|
1524
|
+
onChange={() => {}}
|
|
1525
|
+
hasClear
|
|
1526
|
+
menuWidth={320}
|
|
1527
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1528
|
+
/>,
|
|
1529
|
+
);
|
|
1530
|
+
expect(warn).toHaveBeenCalledTimes(1);
|
|
1531
|
+
warn.mockClear();
|
|
1532
|
+
render(
|
|
1533
|
+
<TokenizerWithPresentation
|
|
1534
|
+
label="Other"
|
|
1535
|
+
searchSource={source}
|
|
1536
|
+
value={[]}
|
|
1537
|
+
onChange={() => {}}
|
|
1538
|
+
hasClear
|
|
1539
|
+
menuWidth={320}
|
|
1540
|
+
/>,
|
|
1541
|
+
);
|
|
1542
|
+
// The inline presentation renders them, so nothing to say.
|
|
1543
|
+
expect(warn).not.toHaveBeenCalled();
|
|
1544
|
+
warn.mockRestore();
|
|
1545
|
+
});
|
|
1546
|
+
|
|
1547
|
+
it('is busy, not empty, from open and from each query change until the search settles (FR20)', async () => {
|
|
1548
|
+
vi.useFakeTimers();
|
|
1549
|
+
try {
|
|
1550
|
+
const slow: SearchSource<SearchableItem> = {
|
|
1551
|
+
bootstrap: async () =>
|
|
1552
|
+
new Promise(resolve => setTimeout(() => resolve(ITEMS), 50)),
|
|
1553
|
+
search: async q =>
|
|
1554
|
+
new Promise(resolve =>
|
|
1555
|
+
setTimeout(
|
|
1556
|
+
() =>
|
|
1557
|
+
resolve(
|
|
1558
|
+
ITEMS.filter(item =>
|
|
1559
|
+
item.label.toLowerCase().includes(q.toLowerCase()),
|
|
1560
|
+
),
|
|
1561
|
+
),
|
|
1562
|
+
50,
|
|
1563
|
+
),
|
|
1564
|
+
),
|
|
1565
|
+
};
|
|
1566
|
+
// Default debounceMs (150), so the debounce window is under test too.
|
|
1567
|
+
// hasCreate, so the create row's timing is under test as well.
|
|
1568
|
+
render(
|
|
1569
|
+
<TokenizerWithPresentation
|
|
1570
|
+
label="Tags"
|
|
1571
|
+
searchSource={slow}
|
|
1572
|
+
value={[]}
|
|
1573
|
+
onChange={() => {}}
|
|
1574
|
+
hasCreate
|
|
1575
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1576
|
+
/>,
|
|
1577
|
+
);
|
|
1578
|
+
fireEvent.click(openTrigger());
|
|
1579
|
+
const list = () => document.querySelector('[data-total-count]')!;
|
|
1580
|
+
await act(async () => {
|
|
1581
|
+
await vi.advanceTimersByTimeAsync(0);
|
|
1582
|
+
});
|
|
1583
|
+
expect(list()).toHaveAttribute('aria-busy', 'true');
|
|
1584
|
+
expect(screen.getByRole('img', {name: 'Loading'})).toBeInTheDocument();
|
|
1585
|
+
expect(
|
|
1586
|
+
screen.queryByRole('heading', {name: 'No items available'}),
|
|
1587
|
+
).not.toBeInTheDocument();
|
|
1588
|
+
await act(async () => {
|
|
1589
|
+
await vi.advanceTimersByTimeAsync(250);
|
|
1590
|
+
});
|
|
1591
|
+
expect(list()).not.toHaveAttribute('aria-busy');
|
|
1592
|
+
expect(
|
|
1593
|
+
screen.getByRole('checkbox', {name: 'Design'}),
|
|
1594
|
+
).toBeInTheDocument();
|
|
1595
|
+
|
|
1596
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
1597
|
+
target: {value: 'zzz'},
|
|
1598
|
+
});
|
|
1599
|
+
// Inside the debounce window: busy, no "No results found", no create
|
|
1600
|
+
// row (the previous query's results cannot judge a duplicate), and the
|
|
1601
|
+
// named Loading row sits above the rows still listed from before, so
|
|
1602
|
+
// the person sees that those rows are not the answer yet.
|
|
1603
|
+
expect(
|
|
1604
|
+
screen.queryByRole('button', {name: /^Add /}),
|
|
1605
|
+
).not.toBeInTheDocument();
|
|
1606
|
+
await act(async () => {
|
|
1607
|
+
await vi.advanceTimersByTimeAsync(100);
|
|
1608
|
+
});
|
|
1609
|
+
expect(list()).toHaveAttribute('aria-busy', 'true');
|
|
1610
|
+
const loading = screen.getByRole('img', {name: 'Loading'});
|
|
1611
|
+
const staleRow = screen.getByRole('checkbox', {name: 'Design'});
|
|
1612
|
+
expect(staleRow).toBeInTheDocument();
|
|
1613
|
+
expect(loading.compareDocumentPosition(staleRow)).toBe(
|
|
1614
|
+
Node.DOCUMENT_POSITION_FOLLOWING,
|
|
1615
|
+
);
|
|
1616
|
+
expect(
|
|
1617
|
+
screen.queryByRole('heading', {name: 'No results found'}),
|
|
1618
|
+
).not.toBeInTheDocument();
|
|
1619
|
+
await act(async () => {
|
|
1620
|
+
await vi.advanceTimersByTimeAsync(200);
|
|
1621
|
+
});
|
|
1622
|
+
expect(list()).not.toHaveAttribute('aria-busy');
|
|
1623
|
+
// Settled with no match: the create row is offered now, against this
|
|
1624
|
+
// query's own results, and no empty state shows beside it.
|
|
1625
|
+
expect(screen.getByRole('button', {name: 'Add zzz'})).toBeInTheDocument();
|
|
1626
|
+
expect(
|
|
1627
|
+
screen.queryByRole('heading', {name: 'No results found'}),
|
|
1628
|
+
).not.toBeInTheDocument();
|
|
1629
|
+
} finally {
|
|
1630
|
+
vi.useRealTimers();
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1633
|
+
|
|
1634
|
+
it('describes a disabled trigger with disabledMessage', async () => {
|
|
1635
|
+
render(
|
|
1636
|
+
<Harness isDisabled disabledMessage="Pick a team first" initial={[]} />,
|
|
1637
|
+
);
|
|
1638
|
+
const trigger = openTrigger();
|
|
1639
|
+
fireEvent.focus(trigger);
|
|
1640
|
+
expect(await screen.findByText('Pick a team first')).toBeInTheDocument();
|
|
1641
|
+
});
|
|
1642
|
+
|
|
1643
|
+
it('keeps an unselectable row at the limit focusable but inert (FR23; AST-085 FR1, FR2)', async () => {
|
|
1644
|
+
const spy = vi.fn();
|
|
1645
|
+
render(<Harness spy={spy} initial={[ITEMS[0]]} maxEntries={1} />);
|
|
1646
|
+
fireEvent.click(openTrigger());
|
|
1647
|
+
const row = await screen.findByRole('checkbox', {name: 'Energizer'});
|
|
1648
|
+
expect(row).not.toHaveAttribute('disabled');
|
|
1649
|
+
expect(row).toHaveAttribute('aria-disabled', 'true');
|
|
1650
|
+
fireEvent.click(row);
|
|
1651
|
+
expect(spy).not.toHaveBeenCalled();
|
|
1652
|
+
expect(row).toHaveAttribute('aria-checked', 'false');
|
|
1653
|
+
// In forced colors its indicator border takes GrayText (AST-085 FR6).
|
|
1654
|
+
const indicatorClasses = stylex
|
|
1655
|
+
.props(
|
|
1656
|
+
stylex.create({
|
|
1657
|
+
indicatorBorder: {
|
|
1658
|
+
borderColor: {
|
|
1659
|
+
default: colorVars['--color-border'],
|
|
1660
|
+
'@media (forced-colors: active)': 'GrayText',
|
|
1661
|
+
},
|
|
1662
|
+
},
|
|
1663
|
+
}).indicatorBorder,
|
|
1664
|
+
)
|
|
1665
|
+
.className!.split(' ')
|
|
1666
|
+
.filter(name => !name.includes('__'));
|
|
1667
|
+
const indicator = row.querySelector('.astryx-checkbox-indicator')!;
|
|
1668
|
+
for (const name of indicatorClasses) {
|
|
1669
|
+
expect(indicator).toHaveClass(name);
|
|
1670
|
+
}
|
|
1671
|
+
// The checked row still toggles, making room (FR23).
|
|
1672
|
+
fireEvent.click(screen.getByRole('checkbox', {name: 'Design'}));
|
|
1673
|
+
expect(spy).toHaveBeenLastCalledWith(
|
|
1674
|
+
[],
|
|
1675
|
+
expect.objectContaining({type: 'remove'}),
|
|
1676
|
+
);
|
|
1677
|
+
});
|
|
1678
|
+
|
|
1679
|
+
it('paints a disabled trigger, its placeholder, and its tokens GrayText in forced colors (AST-085 FR6)', () => {
|
|
1680
|
+
const atoms = (style: stylex.StyleXStyles) =>
|
|
1681
|
+
stylex
|
|
1682
|
+
.props(style)
|
|
1683
|
+
.className!.split(' ')
|
|
1684
|
+
.filter(name => !name.includes('__'));
|
|
1685
|
+
const forced = stylex.create({
|
|
1686
|
+
trigger: {
|
|
1687
|
+
borderColor: {
|
|
1688
|
+
default: colorVars['--color-border-emphasized'],
|
|
1689
|
+
'@media (forced-colors: active)': 'GrayText',
|
|
1690
|
+
},
|
|
1691
|
+
color: {default: null, '@media (forced-colors: active)': 'GrayText'},
|
|
1692
|
+
},
|
|
1693
|
+
token: {
|
|
1694
|
+
color: {
|
|
1695
|
+
default: colorVars['--color-text-primary'],
|
|
1696
|
+
'@media (forced-colors: active)': 'GrayText',
|
|
1697
|
+
},
|
|
1698
|
+
},
|
|
1699
|
+
placeholder: {
|
|
1700
|
+
color: {
|
|
1701
|
+
default: colorVars['--color-text-secondary'],
|
|
1702
|
+
'@media (forced-colors: active)': 'GrayText',
|
|
1703
|
+
},
|
|
1704
|
+
},
|
|
1705
|
+
});
|
|
1706
|
+
const {unmount} = render(<Harness isDisabled />);
|
|
1707
|
+
const trigger = openTrigger();
|
|
1708
|
+
for (const name of atoms(forced.trigger)) {
|
|
1709
|
+
expect(trigger).toHaveClass(name);
|
|
1710
|
+
}
|
|
1711
|
+
const tokens = trigger.querySelectorAll('.astryx-token');
|
|
1712
|
+
expect(tokens).toHaveLength(2);
|
|
1713
|
+
for (const token of tokens) {
|
|
1714
|
+
for (const name of atoms(forced.token)) {
|
|
1715
|
+
expect(token).toHaveClass(name);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
unmount();
|
|
1719
|
+
render(<Harness isDisabled initial={[]} />);
|
|
1720
|
+
const placeholder = screen.getByText('Add tags');
|
|
1721
|
+
for (const name of atoms(forced.placeholder)) {
|
|
1722
|
+
expect(placeholder).toHaveClass(name);
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
|
|
1726
|
+
it('renders a row without its action and warns once in development (FR19; AST-058 FR9)', async () => {
|
|
1727
|
+
__resetDevWarnings();
|
|
1728
|
+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
1729
|
+
const withAction: SearchSource<SearchableItem> = {
|
|
1730
|
+
search: () => [],
|
|
1731
|
+
bootstrap: () => [
|
|
1732
|
+
{
|
|
1733
|
+
id: 'design',
|
|
1734
|
+
label: 'Design',
|
|
1735
|
+
action: <button type="button">Go</button>,
|
|
1736
|
+
},
|
|
1737
|
+
{id: 'eng', label: 'Eng'},
|
|
1738
|
+
],
|
|
1739
|
+
};
|
|
1740
|
+
render(
|
|
1741
|
+
<TokenizerWithPresentation
|
|
1742
|
+
label="Tags"
|
|
1743
|
+
searchSource={withAction}
|
|
1744
|
+
value={[]}
|
|
1745
|
+
onChange={() => {}}
|
|
1746
|
+
debounceMs={0}
|
|
1747
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1748
|
+
/>,
|
|
1749
|
+
);
|
|
1750
|
+
fireEvent.click(openTrigger());
|
|
1751
|
+
const row = await screen.findByRole('checkbox', {name: 'Design'});
|
|
1752
|
+
expect(within(row).queryByRole('button')).not.toBeInTheDocument();
|
|
1753
|
+
await waitFor(() => expect(warn).toHaveBeenCalledTimes(1));
|
|
1754
|
+
expect(warn.mock.calls[0][0]).toMatch(/`action`/);
|
|
1755
|
+
expect(warn.mock.calls[0][0]).toMatch(/bottom-sheet rows/);
|
|
1756
|
+
warn.mockRestore();
|
|
1757
|
+
});
|
|
1758
|
+
|
|
1759
|
+
it('keeps focus when adaptive stops resolving to the sheet while it is open (FR16)', async () => {
|
|
1760
|
+
// A matchMedia stub whose match can flip, with a change listener the
|
|
1761
|
+
// test fires, as a phone turned to landscape would.
|
|
1762
|
+
let compact = true;
|
|
1763
|
+
const listeners = new Set<() => void>();
|
|
1764
|
+
vi.stubGlobal(
|
|
1765
|
+
'matchMedia',
|
|
1766
|
+
vi.fn().mockImplementation((query: string) => ({
|
|
1767
|
+
get matches() {
|
|
1768
|
+
return query === COMPACT_TOUCH_QUERY ? compact : false;
|
|
1769
|
+
},
|
|
1770
|
+
media: query,
|
|
1771
|
+
onchange: null,
|
|
1772
|
+
addEventListener: (_: string, cb: () => void) => listeners.add(cb),
|
|
1773
|
+
removeEventListener: (_: string, cb: () => void) =>
|
|
1774
|
+
listeners.delete(cb),
|
|
1775
|
+
addListener: vi.fn(),
|
|
1776
|
+
removeListener: vi.fn(),
|
|
1777
|
+
dispatchEvent: vi.fn(),
|
|
1778
|
+
})),
|
|
1779
|
+
);
|
|
1780
|
+
render(<Harness presentation="adaptive" />);
|
|
1781
|
+
const trigger = openTrigger();
|
|
1782
|
+
fireEvent.click(trigger);
|
|
1783
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
1784
|
+
screen.getByLabelText('Search Tags').focus();
|
|
1785
|
+
|
|
1786
|
+
// The viewport stops being compact while the sheet is open: nothing
|
|
1787
|
+
// changes until the sheet closes.
|
|
1788
|
+
compact = false;
|
|
1789
|
+
act(() => {
|
|
1790
|
+
for (const cb of listeners) cb();
|
|
1791
|
+
});
|
|
1792
|
+
expect(screen.getByRole('dialog', {name: 'Tags'})).toBe(dialog);
|
|
1793
|
+
expect(trigger).toBeInTheDocument();
|
|
1794
|
+
expect(screen.queryByRole('combobox')).not.toBeInTheDocument();
|
|
1795
|
+
|
|
1796
|
+
fireEvent.click(screen.getByRole('button', {name: 'Done'}));
|
|
1797
|
+
// The sheet is closing; the trigger stays mounted to take focus back,
|
|
1798
|
+
// and the inline input does not appear yet.
|
|
1799
|
+
expect(trigger).toBeInTheDocument();
|
|
1800
|
+
expect(screen.queryByRole('combobox')).not.toBeInTheDocument();
|
|
1801
|
+
fireEvent.transitionEnd(document.querySelector('.astryx-bottom-sheet')!, {
|
|
1802
|
+
propertyName: 'transform',
|
|
1803
|
+
});
|
|
1804
|
+
// Focus came back to the trigger, the latch released into the popover
|
|
1805
|
+
// presentation, and the inline input took the focus over.
|
|
1806
|
+
await waitFor(() =>
|
|
1807
|
+
expect(screen.getByRole('combobox')).toBeInTheDocument(),
|
|
1808
|
+
);
|
|
1809
|
+
expect(screen.getByRole('combobox')).toHaveFocus();
|
|
1810
|
+
expect(
|
|
1811
|
+
screen.queryByRole('button', {name: 'Tags'}),
|
|
1812
|
+
).not.toBeInTheDocument();
|
|
1813
|
+
});
|
|
1814
|
+
|
|
1815
|
+
it('types ref for the control it reaches: the input without experimental, input or trigger with it', () => {
|
|
1816
|
+
const inputRef = createRef<HTMLInputElement>();
|
|
1817
|
+
const {unmount} = render(
|
|
1818
|
+
<TokenizerWithPresentation
|
|
1819
|
+
label="Tags"
|
|
1820
|
+
searchSource={source}
|
|
1821
|
+
value={[]}
|
|
1822
|
+
onChange={() => {}}
|
|
1823
|
+
ref={inputRef}
|
|
1824
|
+
/>,
|
|
1825
|
+
);
|
|
1826
|
+
expect(inputRef.current).toBe(screen.getByRole('combobox'));
|
|
1827
|
+
unmount();
|
|
1828
|
+
const wideRef = createRef<HTMLInputElement | HTMLButtonElement>();
|
|
1829
|
+
const {rerender} = render(
|
|
1830
|
+
<TokenizerWithPresentation
|
|
1831
|
+
label="Tags"
|
|
1832
|
+
searchSource={source}
|
|
1833
|
+
value={[]}
|
|
1834
|
+
onChange={() => {}}
|
|
1835
|
+
ref={wideRef}
|
|
1836
|
+
experimental={{presentation: 'popover'}}
|
|
1837
|
+
/>,
|
|
1838
|
+
);
|
|
1839
|
+
expect(wideRef.current).toBe(screen.getByRole('combobox'));
|
|
1840
|
+
rerender(
|
|
1841
|
+
<TokenizerWithPresentation
|
|
1842
|
+
label="Tags"
|
|
1843
|
+
searchSource={source}
|
|
1844
|
+
value={[]}
|
|
1845
|
+
onChange={() => {}}
|
|
1846
|
+
ref={wideRef}
|
|
1847
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1848
|
+
/>,
|
|
1849
|
+
);
|
|
1850
|
+
expect(wideRef.current).toBe(openTrigger());
|
|
1851
|
+
});
|
|
1852
|
+
|
|
1853
|
+
it('does not search, wait, empty out, or announce for a query below minQueryLength (FR20)', async () => {
|
|
1854
|
+
const search = vi.fn(source.search);
|
|
1855
|
+
const spy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
1856
|
+
render(
|
|
1857
|
+
<TokenizerWithPresentation
|
|
1858
|
+
label="Tags"
|
|
1859
|
+
searchSource={{...source, search}}
|
|
1860
|
+
value={[ITEMS[0]]}
|
|
1861
|
+
onChange={() => {}}
|
|
1862
|
+
debounceMs={0}
|
|
1863
|
+
minQueryLength={3}
|
|
1864
|
+
hasCreate
|
|
1865
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1866
|
+
/>,
|
|
1867
|
+
);
|
|
1868
|
+
fireEvent.click(openTrigger());
|
|
1869
|
+
await screen.findByRole('checkbox', {name: 'Eng'});
|
|
1870
|
+
search.mockClear();
|
|
1871
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
1872
|
+
target: {value: 'De'},
|
|
1873
|
+
});
|
|
1874
|
+
// Only the selected row it matches, and the create row; nothing searched,
|
|
1875
|
+
// nothing pending, no empty state.
|
|
1876
|
+
expect(screen.getByRole('checkbox', {name: 'Design'})).toBeInTheDocument();
|
|
1877
|
+
expect(
|
|
1878
|
+
screen.queryByRole('checkbox', {name: 'Eng'}),
|
|
1879
|
+
).not.toBeInTheDocument();
|
|
1880
|
+
expect(screen.getByRole('button', {name: 'Add De'})).toBeInTheDocument();
|
|
1881
|
+
expect(list()).not.toHaveAttribute('aria-busy');
|
|
1882
|
+
expect(
|
|
1883
|
+
screen.queryByRole('img', {name: 'Loading'}),
|
|
1884
|
+
).not.toBeInTheDocument();
|
|
1885
|
+
expect(
|
|
1886
|
+
screen.queryByRole('heading', {name: 'No results found'}),
|
|
1887
|
+
).not.toBeInTheDocument();
|
|
1888
|
+
expect(search).not.toHaveBeenCalled();
|
|
1889
|
+
// One more character crosses the threshold and searches.
|
|
1890
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
1891
|
+
target: {value: 'Des'},
|
|
1892
|
+
});
|
|
1893
|
+
await waitFor(() => expect(search).toHaveBeenCalledWith('Des'));
|
|
1894
|
+
spy.mockRestore();
|
|
1895
|
+
});
|
|
1896
|
+
|
|
1897
|
+
it('announces the rendered empty state when emptySearchText is an element (FR20; AST-056 FR3)', async () => {
|
|
1898
|
+
const matches = Element.prototype.matches;
|
|
1899
|
+
const spy = vi
|
|
1900
|
+
.spyOn(Element.prototype, 'matches')
|
|
1901
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
1902
|
+
return selector === ':modal'
|
|
1903
|
+
? this instanceof HTMLDialogElement && this.open
|
|
1904
|
+
: matches.call(this, selector);
|
|
1905
|
+
});
|
|
1906
|
+
try {
|
|
1907
|
+
render(
|
|
1908
|
+
<TokenizerWithPresentation
|
|
1909
|
+
label="Tags"
|
|
1910
|
+
searchSource={source}
|
|
1911
|
+
value={[]}
|
|
1912
|
+
onChange={() => {}}
|
|
1913
|
+
debounceMs={0}
|
|
1914
|
+
emptySearchText={
|
|
1915
|
+
<p>
|
|
1916
|
+
Nothing called <strong>that</strong>
|
|
1917
|
+
<span aria-hidden="true"> (decorative)</span>
|
|
1918
|
+
</p>
|
|
1919
|
+
}
|
|
1920
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
1921
|
+
/>,
|
|
1922
|
+
);
|
|
1923
|
+
fireEvent.click(openTrigger());
|
|
1924
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
1925
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
1926
|
+
target: {value: 'zzz'},
|
|
1927
|
+
});
|
|
1928
|
+
await waitFor(() =>
|
|
1929
|
+
expect(
|
|
1930
|
+
dialog.querySelector(
|
|
1931
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
1932
|
+
),
|
|
1933
|
+
).toHaveTextContent('Nothing called that'),
|
|
1934
|
+
);
|
|
1935
|
+
expect(
|
|
1936
|
+
dialog.querySelector(
|
|
1937
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
1938
|
+
),
|
|
1939
|
+
).not.toHaveTextContent('decorative');
|
|
1940
|
+
expect(screen.getByText('that')).toBeInTheDocument();
|
|
1941
|
+
} finally {
|
|
1942
|
+
spy.mockRestore();
|
|
1943
|
+
}
|
|
1944
|
+
});
|
|
1945
|
+
|
|
1946
|
+
it('announces the default empty state exactly once inside the sheet (FR20; AST-086 FR6)', async () => {
|
|
1947
|
+
const matches = Element.prototype.matches;
|
|
1948
|
+
const modalSpy = vi
|
|
1949
|
+
.spyOn(Element.prototype, 'matches')
|
|
1950
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
1951
|
+
return selector === ':modal'
|
|
1952
|
+
? this instanceof HTMLDialogElement && this.open
|
|
1953
|
+
: matches.call(this, selector);
|
|
1954
|
+
});
|
|
1955
|
+
try {
|
|
1956
|
+
render(<Harness />);
|
|
1957
|
+
fireEvent.click(openTrigger());
|
|
1958
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
1959
|
+
const region = () =>
|
|
1960
|
+
dialog.querySelector(
|
|
1961
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
1962
|
+
);
|
|
1963
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
1964
|
+
target: {value: 'zzz'},
|
|
1965
|
+
});
|
|
1966
|
+
await screen.findByRole('heading', {name: 'No results found'});
|
|
1967
|
+
await waitFor(() =>
|
|
1968
|
+
expect(region()).toHaveTextContent('No results found'),
|
|
1969
|
+
);
|
|
1970
|
+
// Spoken by EmptyState itself, once: the sheet adds no second copy of
|
|
1971
|
+
// the title or description, joined or otherwise.
|
|
1972
|
+
const text = region()?.textContent ?? '';
|
|
1973
|
+
expect(text.match(/No results found/g)).toHaveLength(1);
|
|
1974
|
+
expect(text.match(/Try a different search\./g)).toHaveLength(1);
|
|
1975
|
+
expect(
|
|
1976
|
+
document.querySelector('[data-astryx-live-region="polite"]')
|
|
1977
|
+
?.textContent ?? '',
|
|
1978
|
+
).toBe('');
|
|
1979
|
+
} finally {
|
|
1980
|
+
modalSpy.mockRestore();
|
|
1981
|
+
}
|
|
1982
|
+
});
|
|
1983
|
+
|
|
1984
|
+
it('settles a rejecting source to no results without an unhandled rejection (FR20)', async () => {
|
|
1985
|
+
const matches = Element.prototype.matches;
|
|
1986
|
+
const spy = vi
|
|
1987
|
+
.spyOn(Element.prototype, 'matches')
|
|
1988
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
1989
|
+
return selector === ':modal'
|
|
1990
|
+
? this instanceof HTMLDialogElement && this.open
|
|
1991
|
+
: matches.call(this, selector);
|
|
1992
|
+
});
|
|
1993
|
+
const rejected = vi.fn();
|
|
1994
|
+
const onRejection = (event: PromiseRejectionEvent) => {
|
|
1995
|
+
rejected(event.reason);
|
|
1996
|
+
event.preventDefault();
|
|
1997
|
+
};
|
|
1998
|
+
window.addEventListener('unhandledrejection', onRejection);
|
|
1999
|
+
try {
|
|
2000
|
+
const flaky: SearchSource<SearchableItem> = {
|
|
2001
|
+
bootstrap: () => ITEMS,
|
|
2002
|
+
search: async q => {
|
|
2003
|
+
if (q === 'boom') {
|
|
2004
|
+
throw new Error('source down');
|
|
2005
|
+
}
|
|
2006
|
+
return source.search(q);
|
|
2007
|
+
},
|
|
2008
|
+
};
|
|
2009
|
+
render(
|
|
2010
|
+
<TokenizerWithPresentation
|
|
2011
|
+
label="Tags"
|
|
2012
|
+
searchSource={flaky}
|
|
2013
|
+
value={[]}
|
|
2014
|
+
onChange={() => {}}
|
|
2015
|
+
debounceMs={0}
|
|
2016
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
2017
|
+
/>,
|
|
2018
|
+
);
|
|
2019
|
+
fireEvent.click(openTrigger());
|
|
2020
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
2021
|
+
const region = () =>
|
|
2022
|
+
dialog.querySelector(
|
|
2023
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
2024
|
+
);
|
|
2025
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
2026
|
+
target: {value: 'En'},
|
|
2027
|
+
});
|
|
2028
|
+
await screen.findByRole('checkbox', {name: 'Energizer'});
|
|
2029
|
+
await waitFor(() => expect(region()).toHaveTextContent('3 results'));
|
|
2030
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
2031
|
+
target: {value: 'boom'},
|
|
2032
|
+
});
|
|
2033
|
+
// Settled: no stale rows, busy cleared, the empty state announced
|
|
2034
|
+
// rather than the old count.
|
|
2035
|
+
await waitFor(() =>
|
|
2036
|
+
expect(
|
|
2037
|
+
screen.getByRole('heading', {name: 'No results found'}),
|
|
2038
|
+
).toBeInTheDocument(),
|
|
2039
|
+
);
|
|
2040
|
+
expect(
|
|
2041
|
+
screen.queryByRole('checkbox', {name: 'Energizer'}),
|
|
2042
|
+
).not.toBeInTheDocument();
|
|
2043
|
+
expect(list()).not.toHaveAttribute('aria-busy');
|
|
2044
|
+
await waitFor(() =>
|
|
2045
|
+
expect(region()).toHaveTextContent('No results found'),
|
|
2046
|
+
);
|
|
2047
|
+
expect(region()).not.toHaveTextContent('3 results');
|
|
2048
|
+
await act(async () => {
|
|
2049
|
+
await new Promise(resolve => setTimeout(resolve, 0));
|
|
2050
|
+
});
|
|
2051
|
+
expect(rejected).not.toHaveBeenCalled();
|
|
2052
|
+
} finally {
|
|
2053
|
+
window.removeEventListener('unhandledrejection', onRejection);
|
|
2054
|
+
spy.mockRestore();
|
|
2055
|
+
}
|
|
2056
|
+
});
|
|
2057
|
+
|
|
2058
|
+
it('retires an unsettled search when a query below minQueryLength follows it, announcing nothing (FR20)', async () => {
|
|
2059
|
+
vi.useFakeTimers();
|
|
2060
|
+
const matches = Element.prototype.matches;
|
|
2061
|
+
const spy = vi
|
|
2062
|
+
.spyOn(Element.prototype, 'matches')
|
|
2063
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
2064
|
+
return selector === ':modal'
|
|
2065
|
+
? this instanceof HTMLDialogElement && this.open
|
|
2066
|
+
: matches.call(this, selector);
|
|
2067
|
+
});
|
|
2068
|
+
try {
|
|
2069
|
+
const slow: SearchSource<SearchableItem> = {
|
|
2070
|
+
bootstrap: () => ITEMS,
|
|
2071
|
+
search: async q =>
|
|
2072
|
+
new Promise(resolve =>
|
|
2073
|
+
setTimeout(() => resolve(source.search(q)), 300),
|
|
2074
|
+
),
|
|
2075
|
+
};
|
|
2076
|
+
render(
|
|
2077
|
+
<TokenizerWithPresentation
|
|
2078
|
+
label="Tags"
|
|
2079
|
+
searchSource={slow}
|
|
2080
|
+
value={[]}
|
|
2081
|
+
onChange={() => {}}
|
|
2082
|
+
debounceMs={0}
|
|
2083
|
+
minQueryLength={3}
|
|
2084
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
2085
|
+
/>,
|
|
2086
|
+
);
|
|
2087
|
+
fireEvent.click(openTrigger());
|
|
2088
|
+
await act(async () => {
|
|
2089
|
+
await vi.advanceTimersByTimeAsync(10);
|
|
2090
|
+
});
|
|
2091
|
+
const dialog = screen.getByRole('dialog', {name: 'Tags'});
|
|
2092
|
+
const region = () =>
|
|
2093
|
+
dialog.querySelector(
|
|
2094
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
2095
|
+
);
|
|
2096
|
+
const search = screen.getByLabelText('Search Tags');
|
|
2097
|
+
// "Eng" searches; before it settles, backspace to "En", below the
|
|
2098
|
+
// threshold: nothing pending, and when the old search returns its rows
|
|
2099
|
+
// do not land and no count is announced.
|
|
2100
|
+
fireEvent.change(search, {target: {value: 'Eng'}});
|
|
2101
|
+
expect(list()).toHaveAttribute('aria-busy', 'true');
|
|
2102
|
+
fireEvent.change(search, {target: {value: 'En'}});
|
|
2103
|
+
expect(list()).not.toHaveAttribute('aria-busy');
|
|
2104
|
+
await act(async () => {
|
|
2105
|
+
await vi.advanceTimersByTimeAsync(400);
|
|
2106
|
+
});
|
|
2107
|
+
expect(
|
|
2108
|
+
screen.queryByRole('checkbox', {name: 'Eng'}),
|
|
2109
|
+
).not.toBeInTheDocument();
|
|
2110
|
+
expect(region()?.textContent ?? '').not.toMatch(/results?/);
|
|
2111
|
+
// A searched query afterwards announces as usual.
|
|
2112
|
+
fireEvent.change(search, {target: {value: 'Ener'}});
|
|
2113
|
+
await act(async () => {
|
|
2114
|
+
await vi.advanceTimersByTimeAsync(400);
|
|
2115
|
+
});
|
|
2116
|
+
expect(
|
|
2117
|
+
screen.getByRole('checkbox', {name: 'Energizer'}),
|
|
2118
|
+
).toBeInTheDocument();
|
|
2119
|
+
await act(async () => {
|
|
2120
|
+
await vi.advanceTimersByTimeAsync(50);
|
|
2121
|
+
});
|
|
2122
|
+
expect(region()).toHaveTextContent('1 result');
|
|
2123
|
+
} finally {
|
|
2124
|
+
spy.mockRestore();
|
|
2125
|
+
vi.useRealTimers();
|
|
2126
|
+
}
|
|
2127
|
+
});
|
|
2128
|
+
|
|
2129
|
+
it('marks the list pending while the bootstrap set reloads after the create row (FR20, FR22)', async () => {
|
|
2130
|
+
vi.useFakeTimers();
|
|
2131
|
+
try {
|
|
2132
|
+
const onChangeQuery = vi.fn();
|
|
2133
|
+
const slow: SearchSource<SearchableItem> = {
|
|
2134
|
+
bootstrap: async () =>
|
|
2135
|
+
new Promise(resolve => setTimeout(() => resolve(ITEMS), 300)),
|
|
2136
|
+
search: async q =>
|
|
2137
|
+
new Promise(resolve =>
|
|
2138
|
+
setTimeout(() => resolve(source.search(q)), 300),
|
|
2139
|
+
),
|
|
2140
|
+
};
|
|
2141
|
+
render(
|
|
2142
|
+
<TokenizerWithPresentation
|
|
2143
|
+
label="Tags"
|
|
2144
|
+
searchSource={slow}
|
|
2145
|
+
value={[]}
|
|
2146
|
+
onChange={() => {}}
|
|
2147
|
+
onChangeQuery={onChangeQuery}
|
|
2148
|
+
debounceMs={0}
|
|
2149
|
+
hasCreate
|
|
2150
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
2151
|
+
/>,
|
|
2152
|
+
);
|
|
2153
|
+
fireEvent.click(openTrigger());
|
|
2154
|
+
await act(async () => {
|
|
2155
|
+
await vi.advanceTimersByTimeAsync(400);
|
|
2156
|
+
});
|
|
2157
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
2158
|
+
target: {value: 'Ops'},
|
|
2159
|
+
});
|
|
2160
|
+
await act(async () => {
|
|
2161
|
+
await vi.advanceTimersByTimeAsync(400);
|
|
2162
|
+
});
|
|
2163
|
+
onChangeQuery.mockClear();
|
|
2164
|
+
fireEvent.click(screen.getByRole('button', {name: 'Add Ops'}));
|
|
2165
|
+
// The query is cleared through the same path a typed change takes:
|
|
2166
|
+
// the bootstrap reload is pending and the change is reported.
|
|
2167
|
+
expect(list()).toHaveAttribute('aria-busy', 'true');
|
|
2168
|
+
expect(screen.getByRole('img', {name: 'Loading'})).toBeInTheDocument();
|
|
2169
|
+
expect(onChangeQuery).toHaveBeenCalledWith('');
|
|
2170
|
+
await act(async () => {
|
|
2171
|
+
await vi.advanceTimersByTimeAsync(400);
|
|
2172
|
+
});
|
|
2173
|
+
expect(list()).not.toHaveAttribute('aria-busy');
|
|
2174
|
+
expect(
|
|
2175
|
+
screen.getByRole('checkbox', {name: 'Design'}),
|
|
2176
|
+
).toBeInTheDocument();
|
|
2177
|
+
} finally {
|
|
2178
|
+
vi.useRealTimers();
|
|
2179
|
+
}
|
|
2180
|
+
});
|
|
2181
|
+
|
|
2182
|
+
it('joins two announcements from one change inside the sheet (AST-086 FR14)', async () => {
|
|
2183
|
+
const matches = Element.prototype.matches;
|
|
2184
|
+
const spy = vi
|
|
2185
|
+
.spyOn(Element.prototype, 'matches')
|
|
2186
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
2187
|
+
return selector === ':modal'
|
|
2188
|
+
? this instanceof HTMLDialogElement && this.open
|
|
2189
|
+
: matches.call(this, selector);
|
|
2190
|
+
});
|
|
2191
|
+
try {
|
|
2192
|
+
render(<Harness hasCreate maxEntries={2} initial={[ITEMS[0]]} />);
|
|
2193
|
+
fireEvent.click(openTrigger());
|
|
2194
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
2195
|
+
const region = () =>
|
|
2196
|
+
dialog.querySelector(
|
|
2197
|
+
':scope > [data-astryx-modal-live-region="polite"]',
|
|
2198
|
+
);
|
|
2199
|
+
// Typing a query that both searches (its count is announced on settle)
|
|
2200
|
+
// and, here with an instant source, settles in the same frame as the
|
|
2201
|
+
// create row appears: the count includes the create row the sheet
|
|
2202
|
+
// offers, as the inline field counts its create entry.
|
|
2203
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
2204
|
+
target: {value: 'Ops'},
|
|
2205
|
+
});
|
|
2206
|
+
await waitFor(() => expect(region()).toHaveTextContent('1 result'));
|
|
2207
|
+
// Two selection changes in one frame: neither is dropped.
|
|
2208
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
2209
|
+
target: {value: ''},
|
|
2210
|
+
});
|
|
2211
|
+
await screen.findByRole('checkbox', {name: 'Eng'});
|
|
2212
|
+
await act(async () => {
|
|
2213
|
+
await new Promise(resolve =>
|
|
2214
|
+
requestAnimationFrame(() => resolve(null)),
|
|
2215
|
+
);
|
|
2216
|
+
await new Promise(resolve =>
|
|
2217
|
+
requestAnimationFrame(() => resolve(null)),
|
|
2218
|
+
);
|
|
2219
|
+
});
|
|
2220
|
+
fireEvent.click(screen.getByRole('checkbox', {name: 'Eng'}));
|
|
2221
|
+
fireEvent.click(screen.getByRole('checkbox', {name: 'Design'}));
|
|
2222
|
+
await waitFor(() =>
|
|
2223
|
+
expect(region()).toHaveTextContent('Added Eng Removed Design'),
|
|
2224
|
+
);
|
|
2225
|
+
} finally {
|
|
2226
|
+
spy.mockRestore();
|
|
2227
|
+
}
|
|
2228
|
+
});
|
|
2229
|
+
|
|
2230
|
+
it('clears the query on Escape dismissal, so the next open lists the bootstrap set and settles (FR18, FR20)', async () => {
|
|
2231
|
+
const onChangeQuery = vi.fn();
|
|
2232
|
+
const search = vi.fn(source.search);
|
|
2233
|
+
render(
|
|
2234
|
+
<TokenizerWithPresentation
|
|
2235
|
+
label="Tags"
|
|
2236
|
+
searchSource={{...source, search}}
|
|
2237
|
+
value={[]}
|
|
2238
|
+
onChange={() => {}}
|
|
2239
|
+
onChangeQuery={onChangeQuery}
|
|
2240
|
+
debounceMs={0}
|
|
2241
|
+
minQueryLength={3}
|
|
2242
|
+
hasCreate
|
|
2243
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
2244
|
+
/>,
|
|
2245
|
+
);
|
|
2246
|
+
fireEvent.click(openTrigger());
|
|
2247
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
2248
|
+
await screen.findByRole('checkbox', {name: 'Design'});
|
|
2249
|
+
// A query below the threshold, then an Escape dismissal: the query does
|
|
2250
|
+
// not survive the close.
|
|
2251
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
2252
|
+
target: {value: 'De'},
|
|
2253
|
+
});
|
|
2254
|
+
expect(screen.getByRole('button', {name: 'Add De'})).toBeInTheDocument();
|
|
2255
|
+
onChangeQuery.mockClear();
|
|
2256
|
+
search.mockClear();
|
|
2257
|
+
fireEvent.keyDown(dialog, {key: 'Escape'});
|
|
2258
|
+
await waitFor(() =>
|
|
2259
|
+
expect(openTrigger()).toHaveAttribute('aria-expanded', 'false'),
|
|
2260
|
+
);
|
|
2261
|
+
expect(onChangeQuery).toHaveBeenCalledWith('');
|
|
2262
|
+
fireEvent.transitionEnd(document.querySelector('.astryx-bottom-sheet')!, {
|
|
2263
|
+
propertyName: 'transform',
|
|
2264
|
+
});
|
|
2265
|
+
// Reopened: the search field is empty, the bootstrap set loads and
|
|
2266
|
+
// settles — no list left pending for a search that never runs.
|
|
2267
|
+
fireEvent.click(openTrigger());
|
|
2268
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
2269
|
+
expect(screen.getByLabelText('Search Tags')).toHaveValue('');
|
|
2270
|
+
await screen.findByRole('checkbox', {name: 'Eng'});
|
|
2271
|
+
expect(list()).not.toHaveAttribute('aria-busy');
|
|
2272
|
+
expect(
|
|
2273
|
+
screen.queryByRole('img', {name: 'Loading'}),
|
|
2274
|
+
).not.toBeInTheDocument();
|
|
2275
|
+
expect(
|
|
2276
|
+
screen.queryByRole('button', {name: /^Add /}),
|
|
2277
|
+
).not.toBeInTheDocument();
|
|
2278
|
+
expect(search).not.toHaveBeenCalled();
|
|
2279
|
+
});
|
|
2280
|
+
|
|
2281
|
+
it('reports the cleared query from the close handler, not during render (FR18; runtime INV2)', async () => {
|
|
2282
|
+
const errors = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
2283
|
+
try {
|
|
2284
|
+
// A caller that mirrors the query into its own state: a render-phase
|
|
2285
|
+
// report would be a cross-component update React warns about.
|
|
2286
|
+
function Mirror() {
|
|
2287
|
+
const [query, setQuery] = useState('');
|
|
2288
|
+
return (
|
|
2289
|
+
<>
|
|
2290
|
+
<TokenizerWithPresentation
|
|
2291
|
+
label="Tags"
|
|
2292
|
+
searchSource={source}
|
|
2293
|
+
value={[]}
|
|
2294
|
+
onChange={() => {}}
|
|
2295
|
+
onChangeQuery={setQuery}
|
|
2296
|
+
debounceMs={0}
|
|
2297
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
2298
|
+
/>
|
|
2299
|
+
<output data-testid="mirror">{query}</output>
|
|
2300
|
+
</>
|
|
2301
|
+
);
|
|
2302
|
+
}
|
|
2303
|
+
render(<Mirror />);
|
|
2304
|
+
fireEvent.click(openTrigger());
|
|
2305
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
2306
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
2307
|
+
target: {value: 'En'},
|
|
2308
|
+
});
|
|
2309
|
+
expect(screen.getByTestId('mirror')).toHaveTextContent('En');
|
|
2310
|
+
fireEvent.keyDown(dialog, {key: 'Escape'});
|
|
2311
|
+
await waitFor(() =>
|
|
2312
|
+
expect(openTrigger()).toHaveAttribute('aria-expanded', 'false'),
|
|
2313
|
+
);
|
|
2314
|
+
expect(screen.getByTestId('mirror')).toHaveTextContent('');
|
|
2315
|
+
const renderPhase = errors.mock.calls.filter(call =>
|
|
2316
|
+
String(call[0]).includes('Cannot update a component'),
|
|
2317
|
+
);
|
|
2318
|
+
expect(renderPhase).toEqual([]);
|
|
2319
|
+
} finally {
|
|
2320
|
+
errors.mockRestore();
|
|
2321
|
+
}
|
|
2322
|
+
});
|
|
2323
|
+
|
|
2324
|
+
it('loads the bootstrap set at once on open: an instant source shows no Loading row and announces nothing (FR20)', async () => {
|
|
2325
|
+
const matches = Element.prototype.matches;
|
|
2326
|
+
const spy = vi
|
|
2327
|
+
.spyOn(Element.prototype, 'matches')
|
|
2328
|
+
.mockImplementation(function (this: Element, selector: string) {
|
|
2329
|
+
return selector === ':modal'
|
|
2330
|
+
? this instanceof HTMLDialogElement && this.open
|
|
2331
|
+
: matches.call(this, selector);
|
|
2332
|
+
});
|
|
2333
|
+
try {
|
|
2334
|
+
// Default debounceMs (150): the open must not wait for it.
|
|
2335
|
+
render(
|
|
2336
|
+
<TokenizerWithPresentation
|
|
2337
|
+
label="Tags"
|
|
2338
|
+
searchSource={source}
|
|
2339
|
+
value={[ITEMS[0]]}
|
|
2340
|
+
onChange={() => {}}
|
|
2341
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
2342
|
+
/>,
|
|
2343
|
+
);
|
|
2344
|
+
fireEvent.click(openTrigger());
|
|
2345
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
2346
|
+
await screen.findByRole('checkbox', {name: 'Eng'});
|
|
2347
|
+
expect(list()).not.toHaveAttribute('aria-busy');
|
|
2348
|
+
expect(
|
|
2349
|
+
screen.queryByRole('img', {name: 'Loading'}),
|
|
2350
|
+
).not.toBeInTheDocument();
|
|
2351
|
+
// Nothing was announced for the open: no region was ever needed.
|
|
2352
|
+
await act(async () => {
|
|
2353
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
2354
|
+
});
|
|
2355
|
+
expect(
|
|
2356
|
+
dialog.querySelector('[data-astryx-modal-live-region]'),
|
|
2357
|
+
).toBeNull();
|
|
2358
|
+
// A typed query still waits for the debounce (busy meanwhile), and
|
|
2359
|
+
// clearing it reloads the bootstrap set at once.
|
|
2360
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
2361
|
+
target: {value: 'En'},
|
|
2362
|
+
});
|
|
2363
|
+
expect(list()).toHaveAttribute('aria-busy', 'true');
|
|
2364
|
+
await waitFor(() => expect(list()).not.toHaveAttribute('aria-busy'));
|
|
2365
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
2366
|
+
target: {value: ''},
|
|
2367
|
+
});
|
|
2368
|
+
await screen.findByRole('checkbox', {name: 'Design'});
|
|
2369
|
+
expect(list()).not.toHaveAttribute('aria-busy');
|
|
2370
|
+
} finally {
|
|
2371
|
+
spy.mockRestore();
|
|
2372
|
+
}
|
|
2373
|
+
});
|
|
2374
|
+
|
|
2375
|
+
it('moves focus to the search field when a settled search removes the focused row (FR20; AST-085 FR4)', async () => {
|
|
2376
|
+
render(<Harness initial={[]} />);
|
|
2377
|
+
fireEvent.click(openTrigger());
|
|
2378
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
2379
|
+
const design = await screen.findByRole('checkbox', {name: 'Design'});
|
|
2380
|
+
design.focus();
|
|
2381
|
+
expect(design).toHaveFocus();
|
|
2382
|
+
// A query Design does not match: the settled search removes the focused
|
|
2383
|
+
// row, and focus lands on the search field, not the page body.
|
|
2384
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
2385
|
+
target: {value: 'En'},
|
|
2386
|
+
});
|
|
2387
|
+
await waitFor(() =>
|
|
2388
|
+
expect(
|
|
2389
|
+
screen.queryByRole('checkbox', {name: 'Design'}),
|
|
2390
|
+
).not.toBeInTheDocument(),
|
|
2391
|
+
);
|
|
2392
|
+
expect(screen.getByLabelText('Search Tags')).toHaveFocus();
|
|
2393
|
+
expect(document.activeElement).not.toBe(document.body);
|
|
2394
|
+
});
|
|
2395
|
+
|
|
2396
|
+
it('awaits a non-native thenable from the source, as the inline field does (FR20)', async () => {
|
|
2397
|
+
// A thenable that is not a native Promise: a library promise, or one
|
|
2398
|
+
// from another realm. Typed as what the source contract names so the
|
|
2399
|
+
// source is a plain object of synchronous functions returning it.
|
|
2400
|
+
const asThenable = (items: SearchableItem[]) =>
|
|
2401
|
+
({
|
|
2402
|
+
then: (resolve: (items: SearchableItem[]) => void) => {
|
|
2403
|
+
resolve(items);
|
|
2404
|
+
},
|
|
2405
|
+
}) as unknown as SearchableItem[];
|
|
2406
|
+
const thenable: SearchSource<SearchableItem> = {
|
|
2407
|
+
bootstrap: () => asThenable(ITEMS),
|
|
2408
|
+
search: q => asThenable(source.search(q) as SearchableItem[]),
|
|
2409
|
+
};
|
|
2410
|
+
const errors = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
2411
|
+
try {
|
|
2412
|
+
render(
|
|
2413
|
+
<TokenizerWithPresentation
|
|
2414
|
+
label="Tags"
|
|
2415
|
+
searchSource={thenable}
|
|
2416
|
+
value={[]}
|
|
2417
|
+
onChange={() => {}}
|
|
2418
|
+
debounceMs={0}
|
|
2419
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
2420
|
+
/>,
|
|
2421
|
+
);
|
|
2422
|
+
fireEvent.click(openTrigger());
|
|
2423
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
2424
|
+
expect(
|
|
2425
|
+
await screen.findByRole('checkbox', {name: 'Design'}),
|
|
2426
|
+
).toBeInTheDocument();
|
|
2427
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
2428
|
+
target: {value: 'Ener'},
|
|
2429
|
+
});
|
|
2430
|
+
expect(
|
|
2431
|
+
await screen.findByRole('checkbox', {name: 'Energizer'}),
|
|
2432
|
+
).toBeInTheDocument();
|
|
2433
|
+
expect(list()).not.toHaveAttribute('aria-busy');
|
|
2434
|
+
expect(errors).not.toHaveBeenCalled();
|
|
2435
|
+
} finally {
|
|
2436
|
+
errors.mockRestore();
|
|
2437
|
+
}
|
|
2438
|
+
});
|
|
2439
|
+
|
|
2440
|
+
it('subscribes to matchMedia only for the adaptive presentation (runtime INV5)', () => {
|
|
2441
|
+
const added: string[] = [];
|
|
2442
|
+
const matchMedia = vi.fn().mockImplementation((query: string) => ({
|
|
2443
|
+
matches: false,
|
|
2444
|
+
media: query,
|
|
2445
|
+
onchange: null,
|
|
2446
|
+
addEventListener: () => {
|
|
2447
|
+
added.push(query);
|
|
2448
|
+
},
|
|
2449
|
+
removeEventListener: vi.fn(),
|
|
2450
|
+
addListener: vi.fn(),
|
|
2451
|
+
removeListener: vi.fn(),
|
|
2452
|
+
dispatchEvent: vi.fn(),
|
|
2453
|
+
}));
|
|
2454
|
+
vi.stubGlobal('matchMedia', matchMedia);
|
|
2455
|
+
// The default popover, with and without the experimental object: no
|
|
2456
|
+
// query is evaluated and no listener is registered.
|
|
2457
|
+
const {unmount} = render(
|
|
2458
|
+
<TokenizerWithPresentation
|
|
2459
|
+
label="Tags"
|
|
2460
|
+
searchSource={source}
|
|
2461
|
+
value={[]}
|
|
2462
|
+
onChange={() => {}}
|
|
2463
|
+
/>,
|
|
2464
|
+
);
|
|
2465
|
+
render(<Harness presentation="popover" />);
|
|
2466
|
+
render(<Harness presentation="bottom-sheet" />);
|
|
2467
|
+
expect(
|
|
2468
|
+
matchMedia.mock.calls.filter(([q]) => q === COMPACT_TOUCH_QUERY),
|
|
2469
|
+
).toHaveLength(0);
|
|
2470
|
+
expect(added.filter(q => q === COMPACT_TOUCH_QUERY)).toHaveLength(0);
|
|
2471
|
+
unmount();
|
|
2472
|
+
// Only adaptive reads the policy, and subscribes once.
|
|
2473
|
+
render(<Harness presentation="adaptive" />);
|
|
2474
|
+
expect(added.filter(q => q === COMPACT_TOUCH_QUERY)).toHaveLength(1);
|
|
2475
|
+
});
|
|
2476
|
+
|
|
2477
|
+
it('moves focus to the sheet panel on open, not the search field (FR18)', async () => {
|
|
2478
|
+
render(<Harness />);
|
|
2479
|
+
fireEvent.click(openTrigger());
|
|
2480
|
+
const dialog = await screen.findByRole('dialog', {name: 'Tags'});
|
|
2481
|
+
await screen.findByRole('checkbox', {name: 'Design'});
|
|
2482
|
+
expect(dialog.contains(document.activeElement)).toBe(true);
|
|
2483
|
+
expect(screen.getByLabelText('Search Tags')).not.toHaveFocus();
|
|
2484
|
+
});
|
|
2485
|
+
|
|
2486
|
+
it('moves focus to the search field after the create row is activated (FR22)', async () => {
|
|
2487
|
+
render(<Harness hasCreate initial={[]} />);
|
|
2488
|
+
fireEvent.click(openTrigger());
|
|
2489
|
+
await screen.findByRole('dialog', {name: 'Tags'});
|
|
2490
|
+
fireEvent.change(screen.getByLabelText('Search Tags'), {
|
|
2491
|
+
target: {value: 'Ops'},
|
|
2492
|
+
});
|
|
2493
|
+
const add = await screen.findByRole('button', {name: 'Add Ops'});
|
|
2494
|
+
add.focus();
|
|
2495
|
+
fireEvent.click(add);
|
|
2496
|
+
expect(
|
|
2497
|
+
screen.queryByRole('button', {name: 'Add Ops'}),
|
|
2498
|
+
).not.toBeInTheDocument();
|
|
2499
|
+
expect(screen.getByLabelText('Search Tags')).toHaveFocus();
|
|
2500
|
+
});
|
|
2501
|
+
|
|
2502
|
+
it("moves focus to the new presentation's control when adaptive changes while the sheet is closed (FR16)", async () => {
|
|
2503
|
+
let compact = true;
|
|
2504
|
+
const listeners = new Set<() => void>();
|
|
2505
|
+
vi.stubGlobal(
|
|
2506
|
+
'matchMedia',
|
|
2507
|
+
vi.fn().mockImplementation((query: string) => ({
|
|
2508
|
+
get matches() {
|
|
2509
|
+
return query === COMPACT_TOUCH_QUERY ? compact : false;
|
|
2510
|
+
},
|
|
2511
|
+
media: query,
|
|
2512
|
+
onchange: null,
|
|
2513
|
+
addEventListener: (_: string, cb: () => void) => listeners.add(cb),
|
|
2514
|
+
removeEventListener: (_: string, cb: () => void) =>
|
|
2515
|
+
listeners.delete(cb),
|
|
2516
|
+
addListener: vi.fn(),
|
|
2517
|
+
removeListener: vi.fn(),
|
|
2518
|
+
dispatchEvent: vi.fn(),
|
|
2519
|
+
})),
|
|
2520
|
+
);
|
|
2521
|
+
const onFocus = vi.fn();
|
|
2522
|
+
const onBlur = vi.fn();
|
|
2523
|
+
render(
|
|
2524
|
+
<Harness presentation="adaptive" onFocus={onFocus} onBlur={onBlur} />,
|
|
2525
|
+
);
|
|
2526
|
+
const trigger = openTrigger();
|
|
2527
|
+
trigger.focus();
|
|
2528
|
+
expect(trigger).toHaveFocus();
|
|
2529
|
+
expect(onFocus).toHaveBeenCalledTimes(1);
|
|
2530
|
+
// Trigger focused, phone turns to landscape: the input takes over, and
|
|
2531
|
+
// the hand-off inside the field reports neither a blur nor a focus.
|
|
2532
|
+
compact = false;
|
|
2533
|
+
act(() => {
|
|
2534
|
+
for (const cb of listeners) cb();
|
|
2535
|
+
});
|
|
2536
|
+
expect(screen.getByRole('combobox')).toHaveFocus();
|
|
2537
|
+
expect(onFocus).toHaveBeenCalledTimes(1);
|
|
2538
|
+
expect(onBlur).not.toHaveBeenCalled();
|
|
2539
|
+
// And back: the input focused, the screen becomes compact again.
|
|
2540
|
+
compact = true;
|
|
2541
|
+
act(() => {
|
|
2542
|
+
for (const cb of listeners) cb();
|
|
2543
|
+
});
|
|
2544
|
+
expect(openTrigger()).toHaveFocus();
|
|
2545
|
+
// Unfocused, a change moves nothing.
|
|
2546
|
+
openTrigger().blur();
|
|
2547
|
+
compact = false;
|
|
2548
|
+
act(() => {
|
|
2549
|
+
for (const cb of listeners) cb();
|
|
2550
|
+
});
|
|
2551
|
+
expect(document.body).toHaveFocus();
|
|
2552
|
+
});
|
|
2553
|
+
|
|
2554
|
+
it('carries hidden form inputs and the field chrome in the sheet presentation', () => {
|
|
2555
|
+
const {container} = render(
|
|
2556
|
+
<TokenizerWithPresentation
|
|
2557
|
+
label="Tags"
|
|
2558
|
+
searchSource={source}
|
|
2559
|
+
value={[ITEMS[0], ITEMS[1]]}
|
|
2560
|
+
onChange={() => {}}
|
|
2561
|
+
htmlName="tags"
|
|
2562
|
+
status={{type: 'error', message: 'Pick at least three'}}
|
|
2563
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
2564
|
+
/>,
|
|
2565
|
+
);
|
|
2566
|
+
const hidden = container.querySelectorAll('input[type="hidden"]');
|
|
2567
|
+
expect(hidden).toHaveLength(2);
|
|
2568
|
+
expect(hidden[0]).toHaveAttribute('name', 'tags');
|
|
2569
|
+
expect(hidden[0]).toHaveValue('design');
|
|
2570
|
+
const trigger = openTrigger();
|
|
2571
|
+
expect(trigger).toHaveClass('astryx-tokenizer');
|
|
2572
|
+
expect(trigger).toHaveAttribute('data-status', 'error');
|
|
2573
|
+
expect(screen.getByText('Pick at least three')).toBeInTheDocument();
|
|
2574
|
+
});
|
|
2575
|
+
|
|
2576
|
+
it('submits nothing while disabled, in the sheet presentation as in the inline field (FR10, FR17)', () => {
|
|
2577
|
+
const field = (
|
|
2578
|
+
presentation: 'popover' | 'bottom-sheet',
|
|
2579
|
+
isDisabled: boolean,
|
|
2580
|
+
) => (
|
|
2581
|
+
<form>
|
|
2582
|
+
<TokenizerWithPresentation
|
|
2583
|
+
label="Tags"
|
|
2584
|
+
searchSource={source}
|
|
2585
|
+
value={[ITEMS[0], ITEMS[1]]}
|
|
2586
|
+
onChange={() => {}}
|
|
2587
|
+
htmlName="tags"
|
|
2588
|
+
isDisabled={isDisabled}
|
|
2589
|
+
experimental={{presentation}}
|
|
2590
|
+
/>
|
|
2591
|
+
</form>
|
|
2592
|
+
);
|
|
2593
|
+
for (const presentation of ['popover', 'bottom-sheet'] as const) {
|
|
2594
|
+
const enabled = render(field(presentation, false));
|
|
2595
|
+
expect(
|
|
2596
|
+
new FormData(enabled.container.querySelector('form')!).getAll('tags'),
|
|
2597
|
+
).toEqual(['design', 'eng']);
|
|
2598
|
+
enabled.unmount();
|
|
2599
|
+
const disabled = render(field(presentation, true));
|
|
2600
|
+
const form = disabled.container.querySelector('form')!;
|
|
2601
|
+
expect([...new FormData(form).keys()]).toEqual([]);
|
|
2602
|
+
expect(form.querySelector('input[type="hidden"]')).toBeNull();
|
|
2603
|
+
disabled.unmount();
|
|
2604
|
+
}
|
|
2605
|
+
});
|
|
2606
|
+
});
|
|
2607
|
+
|
|
2608
|
+
describe('Tokenizer sheet under the BottomSheet stack (component:BottomSheet FR8, FR9; AST-003 FR18)', () => {
|
|
2609
|
+
const stackSummary = () =>
|
|
2610
|
+
getBottomSheetStackForTests().map(({element, isOpen, view}) => {
|
|
2611
|
+
const label = element?.getAttribute('aria-label') ?? '?';
|
|
2612
|
+
const state = !isOpen ? 'exiting' : view.isTop ? 'top' : 'covered';
|
|
2613
|
+
return `${label}:${state}:${view.depth}`;
|
|
2614
|
+
});
|
|
2615
|
+
const finishExit = (dialog: HTMLElement) => {
|
|
2616
|
+
for (const panel of Array.from(
|
|
2617
|
+
dialog.querySelectorAll<HTMLElement>('.astryx-bottom-sheet'),
|
|
2618
|
+
)) {
|
|
2619
|
+
if (panel.closest('dialog') === dialog) {
|
|
2620
|
+
fireEvent.transitionEnd(panel, {propertyName: 'transform'});
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
};
|
|
2624
|
+
/** A field inside a host sheet, as PowerSearch's value step hosts one. */
|
|
2625
|
+
function Hosted() {
|
|
2626
|
+
const [isHostOpen, setIsHostOpen] = useState(false);
|
|
2627
|
+
const [value, setValue] = useState<SearchableItem[]>([ITEMS[0]]);
|
|
2628
|
+
return (
|
|
2629
|
+
<>
|
|
2630
|
+
<button type="button" onClick={() => setIsHostOpen(true)}>
|
|
2631
|
+
Open step
|
|
2632
|
+
</button>
|
|
2633
|
+
<BottomSheet
|
|
2634
|
+
isOpen={isHostOpen}
|
|
2635
|
+
onOpenChange={setIsHostOpen}
|
|
2636
|
+
label="Value">
|
|
2637
|
+
<TokenizerWithPresentation
|
|
2638
|
+
label="Tags"
|
|
2639
|
+
searchSource={source}
|
|
2640
|
+
value={value}
|
|
2641
|
+
onChange={items => setValue(items)}
|
|
2642
|
+
debounceMs={0}
|
|
2643
|
+
experimental={{presentation: 'bottom-sheet'}}
|
|
2644
|
+
/>
|
|
2645
|
+
</BottomSheet>
|
|
2646
|
+
</>
|
|
2647
|
+
);
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
it('opened from inside a host sheet, is one stacked standalone sheet on top: the host recedes, Escape closes only the field sheet, focus returns to the trigger inside the host', async () => {
|
|
2651
|
+
render(<Hosted />);
|
|
2652
|
+
fireEvent.click(screen.getByRole('button', {name: 'Open step'}));
|
|
2653
|
+
const host = screen.getByRole('dialog', {name: 'Value'});
|
|
2654
|
+
expect(stackSummary()).toEqual(['Value:top:0']);
|
|
2655
|
+
const trigger = openTrigger();
|
|
2656
|
+
trigger.focus();
|
|
2657
|
+
fireEvent.click(trigger);
|
|
2658
|
+
const sheet = await screen.findByRole('dialog', {name: 'Tags'});
|
|
2659
|
+
await screen.findByRole('checkbox', {name: 'Eng'});
|
|
2660
|
+
// The field's sheet is the top of the stack; the host is covered and
|
|
2661
|
+
// recedes, and its dialog, which contains the field sheet, is left to the
|
|
2662
|
+
// browser's modal blocking rather than marked inert.
|
|
2663
|
+
expect(stackSummary()).toEqual(['Value:covered:1', 'Tags:top:0']);
|
|
2664
|
+
expect(host).toHaveAttribute('data-sheet-stack', 'covered');
|
|
2665
|
+
expect(host).not.toHaveAttribute('inert');
|
|
2666
|
+
expect(sheet).toHaveAttribute('aria-modal', 'true');
|
|
2667
|
+
expect(sheet).not.toHaveAttribute('inert');
|
|
2668
|
+
// A row toggle works on top of the host.
|
|
2669
|
+
fireEvent.click(within(sheet).getByRole('checkbox', {name: 'Eng'}));
|
|
2670
|
+
await waitFor(() =>
|
|
2671
|
+
expect(within(sheet).getByRole('checkbox', {name: 'Eng'})).toBeChecked(),
|
|
2672
|
+
);
|
|
2673
|
+
// Escape reaches only the top sheet: the field sheet closes, the host
|
|
2674
|
+
// stays open and is the top again; focus returns to the trigger inside
|
|
2675
|
+
// the host (FR9: the opener, inside the revealed sheet).
|
|
2676
|
+
fireEvent.keyDown(sheet, {key: 'Escape'});
|
|
2677
|
+
finishExit(sheet);
|
|
2678
|
+
await waitFor(() =>
|
|
2679
|
+
expect(
|
|
2680
|
+
screen.queryByRole('dialog', {name: 'Tags'}),
|
|
2681
|
+
).not.toBeInTheDocument(),
|
|
2682
|
+
);
|
|
2683
|
+
expect(stackSummary()).toEqual(['Value:top:0']);
|
|
2684
|
+
expect(host).not.toHaveAttribute('data-sheet-stack');
|
|
2685
|
+
expect(host).toHaveAttribute('open');
|
|
2686
|
+
await waitFor(() => expect(openTrigger()).toHaveFocus());
|
|
2687
|
+
// The field's selection survived the dismissal.
|
|
2688
|
+
expect(openTrigger()).toHaveAccessibleDescription(/2 selected Design Eng/);
|
|
2689
|
+
});
|
|
2690
|
+
|
|
2691
|
+
it("the Clear all confirmation opens over the field's sheet and returns into it; a toast raised meanwhile lands in the field's dialog (AST-003 FR18)", async () => {
|
|
2692
|
+
render(<Hosted />);
|
|
2693
|
+
fireEvent.click(screen.getByRole('button', {name: 'Open step'}));
|
|
2694
|
+
fireEvent.click(openTrigger());
|
|
2695
|
+
const sheet = await screen.findByRole('dialog', {name: 'Tags'});
|
|
2696
|
+
await screen.findByRole('checkbox', {name: 'Eng'});
|
|
2697
|
+
// While the field's sheet is the top modal, it is the active outlet for
|
|
2698
|
+
// app-global surfaces: a toast raised from inside lands in its dialog.
|
|
2699
|
+
expect(getActiveModalOutlet()).toBe(sheet);
|
|
2700
|
+
fireEvent.click(within(sheet).getByRole('button', {name: 'Clear all'}));
|
|
2701
|
+
const confirmation = await screen.findByRole('alertdialog');
|
|
2702
|
+
// A Dialog over the sheet does not join the sheet stack (only sheets
|
|
2703
|
+
// count); the field sheet stays the top sheet while covered by it, and
|
|
2704
|
+
// the confirmation is now the latest outlet.
|
|
2705
|
+
expect(stackSummary()).toEqual(['Value:covered:1', 'Tags:top:0']);
|
|
2706
|
+
expect(getActiveModalOutlet()).toBe(confirmation);
|
|
2707
|
+
fireEvent.click(
|
|
2708
|
+
within(confirmation).getByRole('button', {name: 'Clear selection'}),
|
|
2709
|
+
);
|
|
2710
|
+
await waitFor(() =>
|
|
2711
|
+
expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument(),
|
|
2712
|
+
);
|
|
2713
|
+
// Back in the field's sheet: focus on its search field, the sheet the
|
|
2714
|
+
// outlet again, the host still covered beneath.
|
|
2715
|
+
expect(screen.getByLabelText('Search Tags')).toHaveFocus();
|
|
2716
|
+
expect(getActiveModalOutlet()).toBe(sheet);
|
|
2717
|
+
expect(stackSummary()).toEqual(['Value:covered:1', 'Tags:top:0']);
|
|
2718
|
+
});
|
|
2719
|
+
});
|