@appica/ui-react 1.1.0 → 1.3.0
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 +62 -14
- package/README.md +1 -1
- package/agent-rules.md +2 -2
- package/appica.css +1 -1
- package/dist/components/accordion/accordion.js +1 -0
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/alert/alert.d.ts +1 -1
- package/dist/components/alert/alert.js +1 -0
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.js +2 -1
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/autocomplete/autocomplete.js +3 -2
- package/dist/components/autocomplete/autocomplete.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +1 -1
- package/dist/components/avatar/avatar.js +1 -0
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/background-pattern/background-pattern-interactive.d.ts +2 -1
- package/dist/components/background-pattern/background-pattern-interactive.d.ts.map +1 -1
- package/dist/components/background-pattern/background-pattern-interactive.js +3 -1
- package/dist/components/background-pattern/background-pattern-interactive.js.map +1 -1
- package/dist/components/background-pattern/background-pattern-shared.d.ts +3 -2
- package/dist/components/background-pattern/background-pattern-shared.d.ts.map +1 -1
- package/dist/components/background-pattern/background-pattern-shared.js +47 -15
- package/dist/components/background-pattern/background-pattern-shared.js.map +1 -1
- package/dist/components/background-pattern/background-pattern.d.ts +1 -1
- package/dist/components/background-pattern/background-pattern.d.ts.map +1 -1
- package/dist/components/background-pattern/background-pattern.js +12 -3
- package/dist/components/background-pattern/background-pattern.js.map +1 -1
- package/dist/components/background-pattern/index.js +1 -0
- package/dist/components/background-pattern/index.js.map +1 -1
- package/dist/components/badge/badge.d.ts +2 -2
- package/dist/components/badge/badge.js +2 -1
- package/dist/components/badge/badge.js.map +1 -1
- package/dist/components/border-beam/border-beam.js +1 -0
- package/dist/components/border-beam/border-beam.js.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +2 -1
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/button/button-variants.d.ts +2 -2
- package/dist/components/button/button-variants.js +2 -1
- package/dist/components/button/button-variants.js.map +1 -1
- package/dist/components/button/button.js +1 -0
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button/index.js +1 -0
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button-group/button-group-context.js +1 -0
- package/dist/components/button-group/button-group-context.js.map +1 -1
- package/dist/components/button-group/button-group.js +1 -0
- package/dist/components/button-group/button-group.js.map +1 -1
- package/dist/components/calendar/calendar.js +2 -1
- package/dist/components/calendar/calendar.js.map +1 -1
- package/dist/components/card/card.js +2 -1
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/carousel/carousel.d.ts +3 -11
- package/dist/components/carousel/carousel.d.ts.map +1 -1
- package/dist/components/carousel/carousel.js +25 -1
- package/dist/components/carousel/carousel.js.map +1 -1
- package/dist/components/checkbox/checkbox.js +1 -0
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/checkbox-group/checkbox-group.js +1 -0
- package/dist/components/checkbox-group/checkbox-group.js.map +1 -1
- package/dist/components/chip/chip.d.ts +1 -1
- package/dist/components/chip/chip.js +1 -0
- package/dist/components/chip/chip.js.map +1 -1
- package/dist/components/collapsible/collapsible.js +1 -0
- package/dist/components/collapsible/collapsible.js.map +1 -1
- package/dist/components/color-area/color-area.d.ts.map +1 -1
- package/dist/components/color-area/color-area.js +2 -0
- package/dist/components/color-area/color-area.js.map +1 -1
- package/dist/components/color-picker/color-picker.js +1 -0
- package/dist/components/color-picker/color-picker.js.map +1 -1
- package/dist/components/color-slider/color-slider.d.ts.map +1 -1
- package/dist/components/color-slider/color-slider.js +2 -0
- package/dist/components/color-slider/color-slider.js.map +1 -1
- package/dist/components/color-swatch/color-swatch.d.ts +1 -1
- package/dist/components/color-swatch/color-swatch.js +1 -0
- package/dist/components/color-swatch/color-swatch.js.map +1 -1
- package/dist/components/color-swatch-picker/color-swatch-picker.d.ts +1 -1
- package/dist/components/color-swatch-picker/color-swatch-picker.js +2 -1
- package/dist/components/color-swatch-picker/color-swatch-picker.js.map +1 -1
- package/dist/components/combobox/combobox.d.ts +5 -4
- package/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/combobox.js +5 -3
- package/dist/components/combobox/combobox.js.map +1 -1
- package/dist/components/compare-slider/compare-slider.d.ts +50 -0
- package/dist/components/compare-slider/compare-slider.d.ts.map +1 -0
- package/dist/components/compare-slider/compare-slider.js +321 -0
- package/dist/components/compare-slider/compare-slider.js.map +1 -0
- package/dist/components/context-menu/context-menu.d.ts.map +1 -1
- package/dist/components/context-menu/context-menu.js +7 -1
- package/dist/components/context-menu/context-menu.js.map +1 -1
- package/dist/components/copy-button/copy-button.d.ts +3 -1
- package/dist/components/copy-button/copy-button.d.ts.map +1 -1
- package/dist/components/copy-button/copy-button.js +5 -4
- package/dist/components/copy-button/copy-button.js.map +1 -1
- package/dist/components/countdown/countdown.js +1 -0
- package/dist/components/countdown/countdown.js.map +1 -1
- package/dist/components/date-field/date-field.js +1 -0
- package/dist/components/date-field/date-field.js.map +1 -1
- package/dist/components/date-picker/date-picker.js +1 -0
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/components/dialog/dialog.js +2 -1
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/drawer/drawer.js +1 -0
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +13 -2
- package/dist/components/dropdown-menu/dropdown-menu.d.ts.map +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.js +115 -4
- package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/components/field/field.js +1 -0
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/fieldset/fieldset.js +1 -0
- package/dist/components/fieldset/fieldset.js.map +1 -1
- package/dist/components/form/form.js +1 -0
- package/dist/components/form/form.js.map +1 -1
- package/dist/components/gradient-glow/gradient-glow.d.ts +6 -1
- package/dist/components/gradient-glow/gradient-glow.d.ts.map +1 -1
- package/dist/components/gradient-glow/gradient-glow.js +4 -2
- package/dist/components/gradient-glow/gradient-glow.js.map +1 -1
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/input/input-variants.d.ts +1 -1
- package/dist/components/input/input-variants.js +1 -0
- package/dist/components/input/input-variants.js.map +1 -1
- package/dist/components/input/input.js +1 -0
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/kbd/kbd.js +1 -0
- package/dist/components/kbd/kbd.js.map +1 -1
- package/dist/components/loader/loader.js +1 -0
- package/dist/components/loader/loader.js.map +1 -1
- package/dist/components/menubar/menubar.js +1 -0
- package/dist/components/menubar/menubar.js.map +1 -1
- package/dist/components/meter/meter.js +1 -0
- package/dist/components/meter/meter.js.map +1 -1
- package/dist/components/navigation/index.js +1 -0
- package/dist/components/navigation/index.js.map +1 -1
- package/dist/components/navigation/navigation-context.js +1 -0
- package/dist/components/navigation/navigation-context.js.map +1 -1
- package/dist/components/navigation/navigation-link-variants.d.ts +2 -2
- package/dist/components/navigation/navigation-link-variants.js +2 -1
- package/dist/components/navigation/navigation-link-variants.js.map +1 -1
- package/dist/components/navigation/navigation-link.js +1 -0
- package/dist/components/navigation/navigation-link.js.map +1 -1
- package/dist/components/navigation/navigation.js +1 -0
- package/dist/components/navigation/navigation.js.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.js +2 -1
- package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/number-field/number-field.js +1 -0
- package/dist/components/number-field/number-field.js.map +1 -1
- package/dist/components/otp-field/otp-field.js +1 -0
- package/dist/components/otp-field/otp-field.js.map +1 -1
- package/dist/components/pagination/pagination.js +1 -0
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/popover/popover.js +2 -1
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/preview-card/preview-card.js +2 -1
- package/dist/components/preview-card/preview-card.js.map +1 -1
- package/dist/components/progress/progress.js +1 -0
- package/dist/components/progress/progress.js.map +1 -1
- package/dist/components/radio/radio.js +1 -0
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/radio-group/radio-group.js +1 -0
- package/dist/components/radio-group/radio-group.js.map +1 -1
- package/dist/components/rating/rating.js +1 -0
- package/dist/components/rating/rating.js.map +1 -1
- package/dist/components/scroll-area/scroll-area.js +1 -0
- package/dist/components/scroll-area/scroll-area.js.map +1 -1
- package/dist/components/select/select.js +3 -2
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/separator/separator.js +1 -0
- package/dist/components/separator/separator.js.map +1 -1
- package/dist/components/skeleton/skeleton.js +1 -0
- package/dist/components/skeleton/skeleton.js.map +1 -1
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/slider/slider.js +3 -1
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/sparkline/sparkline.d.ts.map +1 -1
- package/dist/components/sparkline/sparkline.js +2 -0
- package/dist/components/sparkline/sparkline.js.map +1 -1
- package/dist/components/spinner/spinner.js +1 -0
- package/dist/components/spinner/spinner.js.map +1 -1
- package/dist/components/switch/switch.d.ts +15 -15
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/switch/switch.js +1 -0
- package/dist/components/switch/switch.js.map +1 -1
- package/dist/components/table/table.js +1 -0
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +2 -1
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/text-animate/text-animate.js +1 -0
- package/dist/components/text-animate/text-animate.js.map +1 -1
- package/dist/components/textarea/textarea.js +1 -0
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/thumbnail/thumbnail.d.ts +8 -3
- package/dist/components/thumbnail/thumbnail.d.ts.map +1 -1
- package/dist/components/thumbnail/thumbnail.js +3 -0
- package/dist/components/thumbnail/thumbnail.js.map +1 -1
- package/dist/components/time-field/time-field.js +1 -0
- package/dist/components/time-field/time-field.js.map +1 -1
- package/dist/components/toast/toast.js +1 -0
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toc/toc.js +1 -0
- package/dist/components/toc/toc.js.map +1 -1
- package/dist/components/toggle/toggle.js +1 -0
- package/dist/components/toggle/toggle.js.map +1 -1
- package/dist/components/toggle-group/toggle-group.js +1 -0
- package/dist/components/toggle-group/toggle-group.js.map +1 -1
- package/dist/components/toolbar/toolbar.js +1 -0
- package/dist/components/toolbar/toolbar.js.map +1 -1
- package/dist/components/tooltip/tooltip.js +2 -1
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/hooks/use-direction.js +1 -0
- package/dist/hooks/use-direction.js.map +1 -1
- package/dist/hooks/use-dismissible.js +1 -0
- package/dist/hooks/use-dismissible.js.map +1 -1
- package/dist/hooks/use-local-storage.js +1 -0
- package/dist/hooks/use-local-storage.js.map +1 -1
- package/dist/hooks/use-media-query.d.ts +0 -4
- package/dist/hooks/use-media-query.d.ts.map +1 -1
- package/dist/hooks/use-media-query.js +1 -0
- package/dist/hooks/use-media-query.js.map +1 -1
- package/dist/hooks/use-reduced-motion.js +1 -0
- package/dist/hooks/use-reduced-motion.js.map +1 -1
- package/dist/hooks/use-theme.js +1 -0
- package/dist/hooks/use-theme.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/color-control.d.ts +9 -9
- package/dist/internal/color-control.d.ts.map +1 -1
- package/dist/internal/color-control.js +1 -0
- package/dist/internal/color-control.js.map +1 -1
- package/dist/internal/color-math.js +1 -0
- package/dist/internal/color-math.js.map +1 -1
- package/dist/internal/color-picker-context.js +1 -0
- package/dist/internal/color-picker-context.js.map +1 -1
- package/dist/internal/floating.d.ts +2 -2
- package/dist/internal/floating.d.ts.map +1 -1
- package/dist/internal/floating.js +1 -0
- package/dist/internal/floating.js.map +1 -1
- package/dist/internal/modal.d.ts +1 -1
- package/dist/internal/modal.d.ts.map +1 -1
- package/dist/internal/modal.js +1 -0
- package/dist/internal/modal.js.map +1 -1
- package/dist/internal/utils.d.ts +2 -2
- package/dist/internal/utils.d.ts.map +1 -1
- package/dist/internal/utils.js +3 -1
- package/dist/internal/utils.js.map +1 -1
- package/dist/lib/color.js +1 -0
- package/dist/lib/color.js.map +1 -1
- package/dist/providers/direction-provider.js +1 -0
- package/dist/providers/direction-provider.js.map +1 -1
- package/dist/providers/reduced-motion-provider.js +1 -0
- package/dist/providers/reduced-motion-provider.js.map +1 -1
- package/dist/providers/theme-provider/index.js +1 -0
- package/dist/providers/theme-provider/index.js.map +1 -1
- package/dist/providers/theme-provider/theme-provider.js +1 -0
- package/dist/providers/theme-provider/theme-provider.js.map +1 -1
- package/dist/providers/theme-provider/theme-script.js +1 -0
- package/dist/providers/theme-provider/theme-script.js.map +1 -1
- package/package.json +36 -29
- package/src/components/alert-dialog/alert-dialog.tsx +1 -1
- package/src/components/autocomplete/autocomplete.tsx +2 -2
- package/src/components/background-pattern/background-pattern-interactive.tsx +3 -1
- package/src/components/background-pattern/background-pattern-shared.tsx +55 -18
- package/src/components/background-pattern/background-pattern.test.tsx +35 -0
- package/src/components/background-pattern/background-pattern.tsx +11 -4
- package/src/components/badge/badge.tsx +1 -1
- package/src/components/breadcrumb/breadcrumb.tsx +1 -1
- package/src/components/button/button-variants.ts +1 -1
- package/src/components/calendar/calendar.tsx +1 -1
- package/src/components/card/card.tsx +1 -1
- package/src/components/carousel/carousel.test.tsx +38 -0
- package/src/components/carousel/carousel.tsx +28 -12
- package/src/components/color-area/color-area.test.tsx +5 -0
- package/src/components/color-area/color-area.tsx +1 -0
- package/src/components/color-slider/color-slider.test.tsx +5 -0
- package/src/components/color-slider/color-slider.tsx +1 -0
- package/src/components/color-swatch-picker/color-swatch-picker.tsx +1 -1
- package/src/components/combobox/combobox.test.tsx +33 -0
- package/src/components/combobox/combobox.tsx +13 -6
- package/src/components/compare-slider/compare-slider.test.tsx +261 -0
- package/src/components/compare-slider/compare-slider.tsx +397 -0
- package/src/components/context-menu/context-menu.test.tsx +28 -0
- package/src/components/context-menu/context-menu.tsx +6 -1
- package/src/components/copy-button/copy-button.test.tsx +13 -0
- package/src/components/copy-button/copy-button.tsx +11 -5
- package/src/components/dialog/dialog.tsx +1 -1
- package/src/components/dropdown-menu/dropdown-menu.test.tsx +216 -0
- package/src/components/dropdown-menu/dropdown-menu.tsx +134 -3
- package/src/components/gradient-glow/gradient-glow.test.tsx +6 -0
- package/src/components/gradient-glow/gradient-glow.tsx +18 -10
- package/src/components/navigation/navigation-link-variants.ts +1 -1
- package/src/components/navigation-menu/navigation-menu.tsx +2 -2
- package/src/components/popover/popover.tsx +1 -1
- package/src/components/preview-card/preview-card.tsx +1 -1
- package/src/components/select/select.tsx +2 -2
- package/src/components/slider/slider.test.tsx +5 -0
- package/src/components/slider/slider.tsx +2 -1
- package/src/components/sparkline/sparkline.test.tsx +16 -0
- package/src/components/sparkline/sparkline.tsx +1 -0
- package/src/components/tabs/tabs.tsx +1 -1
- package/src/components/thumbnail/thumbnail.test.tsx +8 -0
- package/src/components/thumbnail/thumbnail.tsx +7 -0
- package/src/components/tooltip/tooltip.tsx +1 -1
- package/src/hooks/use-media-query.ts +0 -4
- package/src/index.ts +1 -0
- package/src/internal/utils.test.tsx +8 -1
- package/src/internal/utils.ts +4 -1
- package/styles.css +4 -0
|
@@ -7,10 +7,14 @@ import {
|
|
|
7
7
|
DropdownMenu,
|
|
8
8
|
DropdownMenuCheckboxItem,
|
|
9
9
|
DropdownMenuContent,
|
|
10
|
+
DropdownMenuEmpty,
|
|
11
|
+
DropdownMenuFilterProvider,
|
|
10
12
|
DropdownMenuGroup,
|
|
11
13
|
DropdownMenuGroupLabel,
|
|
14
|
+
DropdownMenuInput,
|
|
12
15
|
DropdownMenuItem,
|
|
13
16
|
DropdownMenuLinkItem,
|
|
17
|
+
DropdownMenuList,
|
|
14
18
|
DropdownMenuRadioGroup,
|
|
15
19
|
DropdownMenuRadioItem,
|
|
16
20
|
DropdownMenuSeparator,
|
|
@@ -86,6 +90,34 @@ describe('DropdownMenu', () => {
|
|
|
86
90
|
expect(item.className).toContain('text-base')
|
|
87
91
|
})
|
|
88
92
|
|
|
93
|
+
it('marks every item kind with data-orientation="vertical"', async () => {
|
|
94
|
+
const user = setupUser()
|
|
95
|
+
render(
|
|
96
|
+
<DropdownMenu>
|
|
97
|
+
<DropdownMenuTrigger>Open</DropdownMenuTrigger>
|
|
98
|
+
<DropdownMenuContent>
|
|
99
|
+
<DropdownMenuItem>Item</DropdownMenuItem>
|
|
100
|
+
<DropdownMenuLinkItem href="https://example.com">Link</DropdownMenuLinkItem>
|
|
101
|
+
<DropdownMenuCheckboxItem>Check</DropdownMenuCheckboxItem>
|
|
102
|
+
<DropdownMenuRadioGroup value="a">
|
|
103
|
+
<DropdownMenuRadioItem value="a">Radio</DropdownMenuRadioItem>
|
|
104
|
+
</DropdownMenuRadioGroup>
|
|
105
|
+
<DropdownMenuSub>
|
|
106
|
+
<DropdownMenuSubTrigger>More</DropdownMenuSubTrigger>
|
|
107
|
+
<DropdownMenuSubContent>
|
|
108
|
+
<DropdownMenuItem>Nested</DropdownMenuItem>
|
|
109
|
+
</DropdownMenuSubContent>
|
|
110
|
+
</DropdownMenuSub>
|
|
111
|
+
</DropdownMenuContent>
|
|
112
|
+
</DropdownMenu>,
|
|
113
|
+
)
|
|
114
|
+
await user.click(screen.getByRole('button', { name: 'Open' }))
|
|
115
|
+
await screen.findByRole('menuitem', { name: 'Item' })
|
|
116
|
+
const items = document.querySelectorAll('[data-slot$="-item"], [data-slot="dropdown-menu-sub-trigger"]')
|
|
117
|
+
expect(items).toHaveLength(5)
|
|
118
|
+
items.forEach((item) => expect(item).toHaveAttribute('data-orientation', 'vertical'))
|
|
119
|
+
})
|
|
120
|
+
|
|
89
121
|
it('renders the popup with size-driven radius', async () => {
|
|
90
122
|
const user = setupUser()
|
|
91
123
|
render(<BasicMenu size="sm" />)
|
|
@@ -224,4 +256,188 @@ describe('DropdownMenu', () => {
|
|
|
224
256
|
const { container } = render(<BasicMenu />)
|
|
225
257
|
expect(await axe(container)).toHaveNoViolations()
|
|
226
258
|
})
|
|
259
|
+
|
|
260
|
+
it('reports highlight changes through onItemHighlighted', async () => {
|
|
261
|
+
const user = setupUser()
|
|
262
|
+
const onItemHighlighted = vi.fn()
|
|
263
|
+
render(
|
|
264
|
+
<DropdownMenu onItemHighlighted={onItemHighlighted}>
|
|
265
|
+
<DropdownMenuTrigger>Open</DropdownMenuTrigger>
|
|
266
|
+
<DropdownMenuContent>
|
|
267
|
+
<DropdownMenuItem>Profile</DropdownMenuItem>
|
|
268
|
+
<DropdownMenuItem>Settings</DropdownMenuItem>
|
|
269
|
+
</DropdownMenuContent>
|
|
270
|
+
</DropdownMenu>,
|
|
271
|
+
)
|
|
272
|
+
await user.click(screen.getByRole('button', { name: 'Open' }))
|
|
273
|
+
await screen.findByRole('menuitem', { name: 'Profile' })
|
|
274
|
+
await user.keyboard('{ArrowDown}')
|
|
275
|
+
await waitFor(() => {
|
|
276
|
+
expect(onItemHighlighted).toHaveBeenCalledWith(
|
|
277
|
+
screen.getByRole('menuitem', { name: 'Profile' }),
|
|
278
|
+
expect.objectContaining({ reason: 'keyboard', event: expect.any(KeyboardEvent) }),
|
|
279
|
+
)
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
it('List: keeps content beside the list out of the menu role', async () => {
|
|
284
|
+
const user = setupUser()
|
|
285
|
+
render(
|
|
286
|
+
<DropdownMenu>
|
|
287
|
+
<DropdownMenuTrigger>Open</DropdownMenuTrigger>
|
|
288
|
+
<DropdownMenuContent>
|
|
289
|
+
<p>Signed in as Sarah</p>
|
|
290
|
+
<DropdownMenuList>
|
|
291
|
+
<DropdownMenuItem>Profile</DropdownMenuItem>
|
|
292
|
+
</DropdownMenuList>
|
|
293
|
+
</DropdownMenuContent>
|
|
294
|
+
</DropdownMenu>,
|
|
295
|
+
)
|
|
296
|
+
await user.click(screen.getByRole('button', { name: 'Open' }))
|
|
297
|
+
const menu = await screen.findByRole('menu')
|
|
298
|
+
expect(menu).toContainElement(screen.getByRole('menuitem', { name: 'Profile' }))
|
|
299
|
+
expect(menu).not.toContainElement(screen.getByText('Signed in as Sarah'))
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
function FilterMenu({ onDuplicate, autoHighlight }: { onDuplicate?: () => void; autoHighlight?: boolean } = {}) {
|
|
304
|
+
return (
|
|
305
|
+
<DropdownMenuFilterProvider {...(autoHighlight && { autoHighlight })}>
|
|
306
|
+
<DropdownMenu>
|
|
307
|
+
<DropdownMenuTrigger>Actions</DropdownMenuTrigger>
|
|
308
|
+
<DropdownMenuContent>
|
|
309
|
+
<DropdownMenuInput aria-label="Filter actions" placeholder="Filter actions" />
|
|
310
|
+
<DropdownMenuEmpty>No actions found.</DropdownMenuEmpty>
|
|
311
|
+
<DropdownMenuList>
|
|
312
|
+
<DropdownMenuGroup>
|
|
313
|
+
<DropdownMenuGroupLabel>File</DropdownMenuGroupLabel>
|
|
314
|
+
<DropdownMenuItem>Rename</DropdownMenuItem>
|
|
315
|
+
<DropdownMenuItem onClick={onDuplicate}>Duplicate</DropdownMenuItem>
|
|
316
|
+
</DropdownMenuGroup>
|
|
317
|
+
<DropdownMenuSeparator />
|
|
318
|
+
<DropdownMenuGroup data-testid="share-group">
|
|
319
|
+
<DropdownMenuGroupLabel>Share</DropdownMenuGroupLabel>
|
|
320
|
+
<DropdownMenuItem>Copy link</DropdownMenuItem>
|
|
321
|
+
</DropdownMenuGroup>
|
|
322
|
+
</DropdownMenuList>
|
|
323
|
+
</DropdownMenuContent>
|
|
324
|
+
</DropdownMenu>
|
|
325
|
+
</DropdownMenuFilterProvider>
|
|
326
|
+
)
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
describe('DropdownMenu filtering', () => {
|
|
330
|
+
it('focuses the search field when opened with a click', async () => {
|
|
331
|
+
const user = setupUser()
|
|
332
|
+
render(<FilterMenu />)
|
|
333
|
+
await user.click(screen.getByRole('button', { name: 'Actions' }))
|
|
334
|
+
const input = await screen.findByRole('searchbox', { name: 'Filter actions' })
|
|
335
|
+
await waitFor(() => expect(input).toHaveFocus())
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
it('narrows the items to the matches and hides groups left empty', async () => {
|
|
339
|
+
const user = setupUser()
|
|
340
|
+
render(<FilterMenu />)
|
|
341
|
+
await user.click(screen.getByRole('button', { name: 'Actions' }))
|
|
342
|
+
await user.type(await screen.findByRole('searchbox', { name: 'Filter actions' }), 'ren')
|
|
343
|
+
await waitFor(() => {
|
|
344
|
+
expect(screen.getAllByRole('menuitem').map((item) => item.textContent)).toEqual(['Rename'])
|
|
345
|
+
})
|
|
346
|
+
expect(screen.getByTestId('share-group')).not.toBeVisible()
|
|
347
|
+
})
|
|
348
|
+
|
|
349
|
+
it('announces the empty message once nothing matches', async () => {
|
|
350
|
+
const user = setupUser()
|
|
351
|
+
render(<FilterMenu />)
|
|
352
|
+
await user.click(screen.getByRole('button', { name: 'Actions' }))
|
|
353
|
+
expect(screen.queryByText('No actions found.')).toBeNull()
|
|
354
|
+
await user.type(await screen.findByRole('searchbox', { name: 'Filter actions' }), 'zzz')
|
|
355
|
+
expect(await screen.findByRole('status')).toHaveTextContent('No actions found.')
|
|
356
|
+
expect(screen.queryAllByRole('menuitem')).toHaveLength(0)
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
it('selects a match with the keyboard while focus stays in the field', async () => {
|
|
360
|
+
const user = setupUser()
|
|
361
|
+
const onDuplicate = vi.fn()
|
|
362
|
+
render(<FilterMenu onDuplicate={onDuplicate} />)
|
|
363
|
+
await user.click(screen.getByRole('button', { name: 'Actions' }))
|
|
364
|
+
const input = await screen.findByRole('searchbox', { name: 'Filter actions' })
|
|
365
|
+
await user.type(input, 'dup')
|
|
366
|
+
await user.keyboard('{ArrowDown}')
|
|
367
|
+
await waitFor(() => {
|
|
368
|
+
expect(screen.getByRole('menuitem', { name: 'Duplicate' })).toHaveAttribute('data-highlighted')
|
|
369
|
+
})
|
|
370
|
+
expect(input).toHaveFocus()
|
|
371
|
+
await user.keyboard('{Enter}')
|
|
372
|
+
expect(onDuplicate).toHaveBeenCalledTimes(1)
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
it('highlights the first match as you type with autoHighlight', async () => {
|
|
376
|
+
const user = setupUser()
|
|
377
|
+
render(<FilterMenu autoHighlight />)
|
|
378
|
+
await user.click(screen.getByRole('button', { name: 'Actions' }))
|
|
379
|
+
await user.type(await screen.findByRole('searchbox', { name: 'Filter actions' }), 'link')
|
|
380
|
+
await waitFor(() => {
|
|
381
|
+
expect(screen.getByRole('menuitem', { name: 'Copy link' })).toHaveAttribute('data-highlighted')
|
|
382
|
+
})
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
it('clears the query from the clear button', async () => {
|
|
386
|
+
const user = setupUser()
|
|
387
|
+
render(<FilterMenu />)
|
|
388
|
+
await user.click(screen.getByRole('button', { name: 'Actions' }))
|
|
389
|
+
const input = await screen.findByRole('searchbox', { name: 'Filter actions' })
|
|
390
|
+
expect(document.querySelector('[data-slot="dropdown-menu-clear"]')).toBeNull()
|
|
391
|
+
await user.type(input, 'ren')
|
|
392
|
+
const clear = document.querySelector<HTMLButtonElement>('[data-slot="dropdown-menu-clear"]')
|
|
393
|
+
expect(clear).not.toBeNull()
|
|
394
|
+
await user.click(clear!)
|
|
395
|
+
expect(input).toHaveValue('')
|
|
396
|
+
await waitFor(() => expect(screen.getAllByRole('menuitem')).toHaveLength(3))
|
|
397
|
+
})
|
|
398
|
+
|
|
399
|
+
it('filters a submenu wrapped in its own provider', async () => {
|
|
400
|
+
const user = setupUser()
|
|
401
|
+
render(
|
|
402
|
+
<DropdownMenu>
|
|
403
|
+
<DropdownMenuTrigger>Open</DropdownMenuTrigger>
|
|
404
|
+
<DropdownMenuContent>
|
|
405
|
+
<DropdownMenuItem>Rename</DropdownMenuItem>
|
|
406
|
+
<DropdownMenuFilterProvider>
|
|
407
|
+
<DropdownMenuSub>
|
|
408
|
+
<DropdownMenuSubTrigger>Move to</DropdownMenuSubTrigger>
|
|
409
|
+
<DropdownMenuSubContent>
|
|
410
|
+
<DropdownMenuInput aria-label="Filter folders" />
|
|
411
|
+
<DropdownMenuList>
|
|
412
|
+
<DropdownMenuItem>Documents</DropdownMenuItem>
|
|
413
|
+
<DropdownMenuItem>Downloads</DropdownMenuItem>
|
|
414
|
+
<DropdownMenuItem>Projects</DropdownMenuItem>
|
|
415
|
+
</DropdownMenuList>
|
|
416
|
+
</DropdownMenuSubContent>
|
|
417
|
+
</DropdownMenuSub>
|
|
418
|
+
</DropdownMenuFilterProvider>
|
|
419
|
+
</DropdownMenuContent>
|
|
420
|
+
</DropdownMenu>,
|
|
421
|
+
)
|
|
422
|
+
await user.click(screen.getByRole('button', { name: 'Open' }))
|
|
423
|
+
expect(screen.queryByRole('searchbox')).toBeNull()
|
|
424
|
+
await screen.findByRole('menuitem', { name: /Move to/ })
|
|
425
|
+
await user.keyboard('{ArrowDown}{ArrowDown}{ArrowRight}')
|
|
426
|
+
const input = await screen.findByRole('searchbox', { name: 'Filter folders' })
|
|
427
|
+
await waitFor(() => expect(input).toHaveFocus())
|
|
428
|
+
await user.keyboard('do')
|
|
429
|
+
await waitFor(() => {
|
|
430
|
+
expect(screen.queryByRole('menuitem', { name: 'Projects' })).toBeNull()
|
|
431
|
+
})
|
|
432
|
+
expect(screen.getByRole('menuitem', { name: 'Documents' })).toBeInTheDocument()
|
|
433
|
+
expect(screen.getByRole('menuitem', { name: 'Downloads' })).toBeInTheDocument()
|
|
434
|
+
})
|
|
435
|
+
|
|
436
|
+
it('has no a11y violations while open', async () => {
|
|
437
|
+
const user = setupUser()
|
|
438
|
+
render(<FilterMenu />)
|
|
439
|
+
await user.click(screen.getByRole('button', { name: 'Actions' }))
|
|
440
|
+
await user.type(await screen.findByRole('searchbox', { name: 'Filter actions' }), 're')
|
|
441
|
+
expect(await axe(document.body)).toHaveNoViolations()
|
|
442
|
+
})
|
|
227
443
|
})
|
|
@@ -5,6 +5,7 @@ import { Menu as BaseMenu } from '@base-ui/react/menu'
|
|
|
5
5
|
import { useReducedMotion } from '../../hooks/use-reduced-motion'
|
|
6
6
|
import { cn } from '../../internal/utils'
|
|
7
7
|
import { type FloatingContentProps, splitFloatingProps } from '../../internal/floating'
|
|
8
|
+
import { inputVariants } from '../input/input-variants'
|
|
8
9
|
import { navigationLinkVariants } from '../navigation/navigation-link-variants'
|
|
9
10
|
|
|
10
11
|
type DropdownMenuSize = 'sm' | 'md' | 'lg'
|
|
@@ -44,6 +45,12 @@ function DropdownMenu({ size = 'md', children, ...rest }: DropdownMenuProps) {
|
|
|
44
45
|
)
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
type DropdownMenuFilterProviderProps = React.ComponentProps<typeof BaseMenu.FilterProvider>
|
|
49
|
+
|
|
50
|
+
function DropdownMenuFilterProvider(props: DropdownMenuFilterProviderProps) {
|
|
51
|
+
return <BaseMenu.FilterProvider {...props} />
|
|
52
|
+
}
|
|
53
|
+
|
|
47
54
|
type DropdownMenuTriggerProps = React.ComponentProps<typeof BaseMenu.Trigger>
|
|
48
55
|
|
|
49
56
|
function DropdownMenuTrigger({ className, ...props }: DropdownMenuTriggerProps) {
|
|
@@ -67,13 +74,20 @@ function popupClassName(size: DropdownMenuSize, className?: string) {
|
|
|
67
74
|
'max-h-(--available-height) w-(--anchor-width) bg-background border-border-overlay flex flex-col border shadow-2xl outline-none',
|
|
68
75
|
POPUP_SIZE[size],
|
|
69
76
|
'origin-(--transform-origin)',
|
|
70
|
-
'motion-safe:transition-[opacity,scale] motion-safe:duration-200 motion-safe:ease-
|
|
77
|
+
'motion-safe:transition-[opacity,scale] motion-safe:duration-200 motion-safe:ease-spring',
|
|
71
78
|
'data-starting-style:motion-safe:scale-90 data-starting-style:motion-safe:opacity-0',
|
|
72
79
|
'data-ending-style:motion-safe:scale-95 data-ending-style:motion-safe:opacity-0 data-ending-style:motion-safe:duration-100 data-ending-style:motion-safe:ease-out',
|
|
73
80
|
className,
|
|
74
81
|
)
|
|
75
82
|
}
|
|
76
83
|
|
|
84
|
+
const POPUP_BODY = cn(
|
|
85
|
+
'flex flex-col gap-0.5 overflow-x-hidden overflow-y-auto p-2',
|
|
86
|
+
'has-data-[slot=dropdown-menu-list]:p-0',
|
|
87
|
+
'has-data-[slot=dropdown-menu-input]:gap-2 has-data-[slot=dropdown-menu-input]:*:data-[slot=dropdown-menu-list]:pt-0',
|
|
88
|
+
'has-data-[slot=dropdown-menu-empty]:*:data-[slot=dropdown-menu-list]:p-0',
|
|
89
|
+
)
|
|
90
|
+
|
|
77
91
|
type DropdownMenuFloatingProps = FloatingContentProps<
|
|
78
92
|
React.ComponentProps<typeof BaseMenu.Positioner>,
|
|
79
93
|
React.ComponentProps<typeof BaseMenu.Portal>
|
|
@@ -97,13 +111,91 @@ function DropdownMenuContent({ className, children, ...props }: DropdownMenuCont
|
|
|
97
111
|
className={cn('isolate z-50', positioner.className as string | undefined)}
|
|
98
112
|
>
|
|
99
113
|
<BaseMenu.Popup data-slot="dropdown-menu-content" className={popupClassName(size, className)} {...popup}>
|
|
100
|
-
<div className=
|
|
114
|
+
<div className={POPUP_BODY}>{children}</div>
|
|
101
115
|
</BaseMenu.Popup>
|
|
102
116
|
</BaseMenu.Positioner>
|
|
103
117
|
</BaseMenu.Portal>
|
|
104
118
|
)
|
|
105
119
|
}
|
|
106
120
|
|
|
121
|
+
const INPUT_RADIUS: Record<DropdownMenuSize, string> = {
|
|
122
|
+
sm: 'rounded-xs',
|
|
123
|
+
md: 'rounded-sm',
|
|
124
|
+
lg: 'rounded-md',
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface DropdownMenuInputProps extends Omit<React.ComponentProps<typeof BaseMenu.Input>, 'className'> {
|
|
128
|
+
/** Extra classes on the frame that holds the field, its search icon and its clear button. */
|
|
129
|
+
className?: string
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function DropdownMenuInput({ className, ...props }: DropdownMenuInputProps) {
|
|
133
|
+
const { size } = useDropdownMenuContext()
|
|
134
|
+
return (
|
|
135
|
+
<div
|
|
136
|
+
data-slot="dropdown-menu-input"
|
|
137
|
+
className={cn(
|
|
138
|
+
inputVariants({ size }),
|
|
139
|
+
'm-2 mb-0 flex w-auto shrink-0 items-center',
|
|
140
|
+
INPUT_RADIUS[size],
|
|
141
|
+
'has-data-highlighted:ring-ring-input has-data-highlighted:border-transparent has-data-highlighted:ring-3',
|
|
142
|
+
className,
|
|
143
|
+
)}
|
|
144
|
+
>
|
|
145
|
+
<SearchIcon className="text-foreground-subtle -ms-0.5" />
|
|
146
|
+
<BaseMenu.Input
|
|
147
|
+
data-slot="dropdown-menu-input-field"
|
|
148
|
+
className="placeholder:text-foreground-subtle h-full min-w-0 flex-1 bg-transparent outline-none"
|
|
149
|
+
{...props}
|
|
150
|
+
/>
|
|
151
|
+
<BaseMenu.Clear
|
|
152
|
+
data-slot="dropdown-menu-clear"
|
|
153
|
+
className="text-foreground-subtle hover:text-foreground shrink-0 cursor-pointer transition-colors duration-200 outline-none motion-reduce:transition-none"
|
|
154
|
+
>
|
|
155
|
+
<ClearIcon className="size-[1em]" />
|
|
156
|
+
</BaseMenu.Clear>
|
|
157
|
+
</div>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const EMPTY_SIZE: Record<DropdownMenuSize, string> = {
|
|
162
|
+
sm: 'px-2.5 py-2 text-xs',
|
|
163
|
+
md: 'px-3 py-2.5 text-sm',
|
|
164
|
+
lg: 'px-3.5 py-3 text-base',
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
type DropdownMenuEmptyProps = React.ComponentProps<typeof BaseMenu.Empty>
|
|
168
|
+
|
|
169
|
+
function DropdownMenuEmpty({ className, ...props }: DropdownMenuEmptyProps) {
|
|
170
|
+
const { size } = useDropdownMenuContext()
|
|
171
|
+
return (
|
|
172
|
+
<BaseMenu.Empty
|
|
173
|
+
data-slot="dropdown-menu-empty"
|
|
174
|
+
className={cn('text-foreground-muted text-center', EMPTY_SIZE[size], className)}
|
|
175
|
+
{...props}
|
|
176
|
+
/>
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
type DropdownMenuListProps = React.ComponentProps<typeof BaseMenu.List>
|
|
181
|
+
|
|
182
|
+
function DropdownMenuList({ className, ...props }: DropdownMenuListProps) {
|
|
183
|
+
return (
|
|
184
|
+
<BaseMenu.List
|
|
185
|
+
data-slot="dropdown-menu-list"
|
|
186
|
+
className={cn(
|
|
187
|
+
'flex min-h-0 flex-1 flex-col gap-0.5 overflow-x-hidden overflow-y-auto p-2 outline-none',
|
|
188
|
+
'*:data-[slot=dropdown-menu-separator]:first:hidden *:data-[slot=dropdown-menu-separator]:last:hidden',
|
|
189
|
+
'*:data-[slot=dropdown-menu-separator]:has-[+[hidden]]:hidden',
|
|
190
|
+
'[&>[hidden]+[data-slot=dropdown-menu-separator]]:hidden',
|
|
191
|
+
'[&>[data-slot=dropdown-menu-separator]+[data-slot=dropdown-menu-separator]]:hidden',
|
|
192
|
+
className,
|
|
193
|
+
)}
|
|
194
|
+
{...props}
|
|
195
|
+
/>
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
|
|
107
199
|
const ITEM_BASE = 'w-full outline-hidden'
|
|
108
200
|
|
|
109
201
|
const ITEM_TEXT: Record<DropdownMenuSize, string> = {
|
|
@@ -119,6 +211,7 @@ function DropdownMenuItem({ className, ...props }: DropdownMenuItemProps) {
|
|
|
119
211
|
return (
|
|
120
212
|
<BaseMenu.Item
|
|
121
213
|
data-slot="dropdown-menu-item"
|
|
214
|
+
data-orientation="vertical"
|
|
122
215
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, className)}
|
|
123
216
|
{...props}
|
|
124
217
|
/>
|
|
@@ -132,6 +225,7 @@ function DropdownMenuLinkItem({ className, ...props }: DropdownMenuLinkItemProps
|
|
|
132
225
|
return (
|
|
133
226
|
<BaseMenu.LinkItem
|
|
134
227
|
data-slot="dropdown-menu-link-item"
|
|
228
|
+
data-orientation="vertical"
|
|
135
229
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, className)}
|
|
136
230
|
{...props}
|
|
137
231
|
/>
|
|
@@ -188,6 +282,7 @@ function DropdownMenuRadioItem({ className, children, ...props }: DropdownMenuRa
|
|
|
188
282
|
return (
|
|
189
283
|
<BaseMenu.RadioItem
|
|
190
284
|
data-slot="dropdown-menu-radio-item"
|
|
285
|
+
data-orientation="vertical"
|
|
191
286
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, 'justify-between', className)}
|
|
192
287
|
{...props}
|
|
193
288
|
>
|
|
@@ -210,6 +305,7 @@ function DropdownMenuCheckboxItem({ className, children, ...props }: DropdownMen
|
|
|
210
305
|
return (
|
|
211
306
|
<BaseMenu.CheckboxItem
|
|
212
307
|
data-slot="dropdown-menu-checkbox-item"
|
|
308
|
+
data-orientation="vertical"
|
|
213
309
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, 'justify-between', className)}
|
|
214
310
|
{...props}
|
|
215
311
|
>
|
|
@@ -239,6 +335,7 @@ function DropdownMenuSubTrigger({ className, children, ...props }: DropdownMenuS
|
|
|
239
335
|
<BaseMenu.SubmenuTrigger className="group/submenu-trigger outline-hidden" {...props}>
|
|
240
336
|
<span
|
|
241
337
|
data-slot="dropdown-menu-sub-trigger"
|
|
338
|
+
data-orientation="vertical"
|
|
242
339
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, 'justify-between', className)}
|
|
243
340
|
>
|
|
244
341
|
<span className={cn('flex flex-1 items-center', ITEM_TEXT[size])}>{children}</span>
|
|
@@ -267,7 +364,7 @@ function DropdownMenuSubContent({ className, children, ...props }: DropdownMenuS
|
|
|
267
364
|
className={cn('isolate z-50', positioner.className as string | undefined)}
|
|
268
365
|
>
|
|
269
366
|
<BaseMenu.Popup data-slot="dropdown-menu-sub-content" className={popupClassName(size, className)} {...popup}>
|
|
270
|
-
<div className=
|
|
367
|
+
<div className={POPUP_BODY}>{children}</div>
|
|
271
368
|
</BaseMenu.Popup>
|
|
272
369
|
</BaseMenu.Positioner>
|
|
273
370
|
</BaseMenu.Portal>
|
|
@@ -313,10 +410,40 @@ function ChevronEndIcon(props: IconProps) {
|
|
|
313
410
|
)
|
|
314
411
|
}
|
|
315
412
|
|
|
413
|
+
function SearchIcon(props: IconProps) {
|
|
414
|
+
return (
|
|
415
|
+
<svg
|
|
416
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
417
|
+
viewBox="0 0 24 24"
|
|
418
|
+
fill="none"
|
|
419
|
+
stroke="currentColor"
|
|
420
|
+
strokeLinecap="round"
|
|
421
|
+
strokeLinejoin="round"
|
|
422
|
+
aria-hidden="true"
|
|
423
|
+
{...props}
|
|
424
|
+
>
|
|
425
|
+
<circle cx="10" cy="10" r="7" />
|
|
426
|
+
<path d="m21 21-6-6" />
|
|
427
|
+
</svg>
|
|
428
|
+
)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function ClearIcon(props: IconProps) {
|
|
432
|
+
return (
|
|
433
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="2 2 16 16" fill="currentColor" aria-hidden="true" {...props}>
|
|
434
|
+
<path d="M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" />
|
|
435
|
+
</svg>
|
|
436
|
+
)
|
|
437
|
+
}
|
|
438
|
+
|
|
316
439
|
export {
|
|
317
440
|
DropdownMenu,
|
|
441
|
+
DropdownMenuFilterProvider,
|
|
318
442
|
DropdownMenuTrigger,
|
|
319
443
|
DropdownMenuContent,
|
|
444
|
+
DropdownMenuInput,
|
|
445
|
+
DropdownMenuEmpty,
|
|
446
|
+
DropdownMenuList,
|
|
320
447
|
DropdownMenuGroup,
|
|
321
448
|
DropdownMenuGroupLabel,
|
|
322
449
|
DropdownMenuItem,
|
|
@@ -331,8 +458,12 @@ export {
|
|
|
331
458
|
}
|
|
332
459
|
export type {
|
|
333
460
|
DropdownMenuProps,
|
|
461
|
+
DropdownMenuFilterProviderProps,
|
|
334
462
|
DropdownMenuTriggerProps,
|
|
335
463
|
DropdownMenuContentProps,
|
|
464
|
+
DropdownMenuInputProps,
|
|
465
|
+
DropdownMenuEmptyProps,
|
|
466
|
+
DropdownMenuListProps,
|
|
336
467
|
DropdownMenuGroupProps,
|
|
337
468
|
DropdownMenuGroupLabelProps,
|
|
338
469
|
DropdownMenuItemProps,
|
|
@@ -33,6 +33,12 @@ describe('GradientGlow', () => {
|
|
|
33
33
|
expect(ring).toHaveAttribute('aria-hidden')
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
+
it('drops the aura but keeps the border ring when glow is off', () => {
|
|
37
|
+
const { container } = render(<GradientGlow glow={false} border />)
|
|
38
|
+
expect(container.querySelector('[data-slot="gradient-glow-aura"]')).toBeNull()
|
|
39
|
+
expect(container.querySelector('[data-slot="gradient-glow-border"]')).not.toBeNull()
|
|
40
|
+
})
|
|
41
|
+
|
|
36
42
|
it('maps the blur prop to a Tailwind utility', () => {
|
|
37
43
|
const { container } = render(<GradientGlow blur="2xl" />)
|
|
38
44
|
const aura = container.querySelector('[data-slot="gradient-glow-aura"]')!
|
|
@@ -30,6 +30,11 @@ interface GradientGlowProps extends React.ComponentProps<'div'> {
|
|
|
30
30
|
* @default 'lg'
|
|
31
31
|
*/
|
|
32
32
|
blur?: GradientGlowBlur
|
|
33
|
+
/**
|
|
34
|
+
* Paint the blurred aura behind the content. Set `false` with `border` for a gradient stroke alone.
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
glow?: boolean
|
|
33
38
|
/**
|
|
34
39
|
* Add a 1px stroke that follows the same animated gradient.
|
|
35
40
|
* @default false
|
|
@@ -81,6 +86,7 @@ function GradientGlow({
|
|
|
81
86
|
to = '#FFD69B',
|
|
82
87
|
angle = 95,
|
|
83
88
|
blur = 'lg',
|
|
89
|
+
glow = true,
|
|
84
90
|
border = false,
|
|
85
91
|
borderWidth = 1,
|
|
86
92
|
speed = 4,
|
|
@@ -140,16 +146,18 @@ function GradientGlow({
|
|
|
140
146
|
style={{ '--gradient-glow-duration': `${speed}s`, ...style } as React.CSSProperties}
|
|
141
147
|
{...props}
|
|
142
148
|
>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
{glow ? (
|
|
150
|
+
<span
|
|
151
|
+
aria-hidden
|
|
152
|
+
data-slot="gradient-glow-aura"
|
|
153
|
+
className={cn(
|
|
154
|
+
'motion-safe:animate-gradient-glow-aura pointer-events-none absolute inset-0 -z-10 rounded-[inherit] opacity-(--gradient-glow-opacity)',
|
|
155
|
+
BLUR_CLASS[blur],
|
|
156
|
+
layerClasses,
|
|
157
|
+
)}
|
|
158
|
+
style={{ background: gradient }}
|
|
159
|
+
/>
|
|
160
|
+
) : null}
|
|
153
161
|
{children}
|
|
154
162
|
{border ? (
|
|
155
163
|
<span
|
|
@@ -3,7 +3,7 @@ import { cn } from '../../internal/utils'
|
|
|
3
3
|
|
|
4
4
|
const base = [
|
|
5
5
|
'relative inline-flex items-center gap-1.5 transform-gpu cursor-pointer font-medium outline-none',
|
|
6
|
-
'transition duration-250 ease-
|
|
6
|
+
'transition duration-250 ease-spring',
|
|
7
7
|
'select-none not-data-popup-open:active:scale-[0.97] not-data-popup-open:active:duration-100 not-data-popup-open:active:ease-in-out not-data-popup-open:active:translate-y-px',
|
|
8
8
|
'data-disabled:opacity-disabled data-disabled:pointer-events-none',
|
|
9
9
|
'group-data-disabled/submenu-trigger:opacity-disabled group-data-disabled/submenu-trigger:pointer-events-none',
|
|
@@ -328,8 +328,8 @@ function NavigationMenuPositioner({
|
|
|
328
328
|
morph && 'h-(--popup-height) w-(--popup-width)',
|
|
329
329
|
'origin-(--transform-origin)',
|
|
330
330
|
morph
|
|
331
|
-
? 'motion-safe:[transition:
|
|
332
|
-
: 'motion-safe:transition-[opacity,scale] motion-safe:duration-300
|
|
331
|
+
? 'motion-safe:[transition:opacity_300ms_var(--ease-spring),scale_300ms_var(--ease-spring),width_300ms_cubic-bezier(0.22,1,0.36,1),height_300ms_cubic-bezier(0.22,1,0.36,1)]'
|
|
332
|
+
: 'motion-safe:ease-spring motion-safe:transition-[opacity,scale] motion-safe:duration-300',
|
|
333
333
|
'data-starting-style:motion-safe:scale-95 data-starting-style:motion-safe:opacity-0',
|
|
334
334
|
'data-ending-style:motion-safe:scale-95 data-ending-style:motion-safe:opacity-0 data-ending-style:motion-safe:duration-150 data-ending-style:motion-safe:ease-out',
|
|
335
335
|
className,
|
|
@@ -55,7 +55,7 @@ function PopoverContent({ className, arrow = true, children, ...props }: Popover
|
|
|
55
55
|
'group-data-[side=inline-start]/popup:border-e-2',
|
|
56
56
|
'group-data-[side=inline-end]/popup:border-s-2',
|
|
57
57
|
],
|
|
58
|
-
'motion-safe:origin-(--transform-origin) motion-safe:transition-[opacity,scale] motion-safe:duration-200
|
|
58
|
+
'motion-safe:ease-spring motion-safe:origin-(--transform-origin) motion-safe:transition-[opacity,scale] motion-safe:duration-200',
|
|
59
59
|
'group-data-starting-style/popup:motion-safe:scale-90 group-data-starting-style/popup:motion-safe:opacity-0',
|
|
60
60
|
'group-data-ending-style/popup:motion-safe:scale-95 group-data-ending-style/popup:motion-safe:opacity-0 group-data-ending-style/popup:motion-safe:duration-100 group-data-ending-style/popup:motion-safe:ease-out',
|
|
61
61
|
className,
|
|
@@ -55,7 +55,7 @@ function PreviewCardContent({ className, arrow = true, children, ...props }: Pre
|
|
|
55
55
|
'group-data-[side=inline-start]/popup:border-e-2',
|
|
56
56
|
'group-data-[side=inline-end]/popup:border-s-2',
|
|
57
57
|
],
|
|
58
|
-
'motion-safe:origin-(--transform-origin) motion-safe:transition-[opacity,scale] motion-safe:duration-200
|
|
58
|
+
'motion-safe:ease-spring motion-safe:origin-(--transform-origin) motion-safe:transition-[opacity,scale] motion-safe:duration-200',
|
|
59
59
|
'group-data-starting-style/popup:motion-safe:scale-90 group-data-starting-style/popup:motion-safe:opacity-0',
|
|
60
60
|
'group-data-ending-style/popup:motion-safe:scale-95 group-data-ending-style/popup:motion-safe:opacity-0 group-data-ending-style/popup:motion-safe:duration-100 group-data-ending-style/popup:motion-safe:ease-out',
|
|
61
61
|
className,
|
|
@@ -265,7 +265,7 @@ function SelectContent({ className, alignItemWithTrigger: alignOverride, childre
|
|
|
265
265
|
'min-w-36',
|
|
266
266
|
alignWithTrigger ? 'w-[calc(var(--anchor-width)+1rem)]' : 'w-(--anchor-width)',
|
|
267
267
|
alignWithTrigger ? 'origin-center' : 'origin-(--transform-origin)',
|
|
268
|
-
'motion-safe:transition-[opacity,scale] motion-safe:duration-200
|
|
268
|
+
'motion-safe:ease-spring motion-safe:transition-[opacity,scale] motion-safe:duration-200',
|
|
269
269
|
'data-starting-style:motion-safe:scale-90 data-starting-style:motion-safe:opacity-0',
|
|
270
270
|
'data-ending-style:motion-safe:scale-95 data-ending-style:motion-safe:opacity-0 data-ending-style:motion-safe:duration-100 data-ending-style:motion-safe:ease-out',
|
|
271
271
|
className,
|
|
@@ -362,7 +362,7 @@ function SelectItem({ className, children, ...props }: SelectItemProps) {
|
|
|
362
362
|
'before:bg-background-muted before:absolute before:inset-0 before:-z-10 before:rounded-[inherit] before:opacity-0',
|
|
363
363
|
'active:translate-y-px active:scale-[0.98]',
|
|
364
364
|
'data-highlighted:not-data-disabled:text-foreground-intense data-highlighted:not-data-disabled:before:opacity-100',
|
|
365
|
-
'motion-safe:
|
|
365
|
+
'motion-safe:ease-spring motion-safe:transition motion-safe:duration-250',
|
|
366
366
|
'motion-safe:active:duration-100 motion-safe:active:ease-in-out',
|
|
367
367
|
'motion-safe:before:transition-opacity motion-safe:before:duration-200 motion-safe:before:ease-out',
|
|
368
368
|
'data-disabled:opacity-disabled data-disabled:pointer-events-none',
|
|
@@ -5,6 +5,11 @@ import { axe } from 'vitest-axe'
|
|
|
5
5
|
import { Slider } from './slider'
|
|
6
6
|
|
|
7
7
|
describe('Slider', () => {
|
|
8
|
+
it('keeps a surrounding Drawer from swiping on any drag that starts on the control', () => {
|
|
9
|
+
const { container } = render(<Slider thumbAriaLabel="Volume" />)
|
|
10
|
+
expect(container.querySelector('[data-slot="slider-control"]')).toHaveAttribute('data-base-ui-swipe-ignore', '')
|
|
11
|
+
})
|
|
12
|
+
|
|
8
13
|
it('renders a single thumb when no value is provided', () => {
|
|
9
14
|
render(<Slider thumbAriaLabel="Volume" />)
|
|
10
15
|
const thumbs = screen.getAllByRole('slider')
|
|
@@ -19,6 +19,7 @@ const TOOLTIP_TILT_TRANSITION = {
|
|
|
19
19
|
|
|
20
20
|
const TOOLTIP_POPUP_TRANSITION = {
|
|
21
21
|
duration: 0.2,
|
|
22
|
+
// `--ease-spring` in styles.css, as numbers: Motion can't read a CSS variable.
|
|
22
23
|
ease: [0.175, 0.885, 0.32, 1.5] satisfies [number, number, number, number],
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -240,7 +241,7 @@ function Slider({
|
|
|
240
241
|
className={cn(rootClasses, className)}
|
|
241
242
|
{...rootProps}
|
|
242
243
|
>
|
|
243
|
-
<BaseSlider.Control data-slot="slider-control" className={controlClasses}>
|
|
244
|
+
<BaseSlider.Control data-slot="slider-control" data-base-ui-swipe-ignore="" className={controlClasses}>
|
|
244
245
|
<BaseSlider.Track data-slot="slider-track" className={trackClasses}>
|
|
245
246
|
<BaseSlider.Indicator data-slot="slider-indicator" className={indicatorClasses} />
|
|
246
247
|
</BaseSlider.Track>
|
|
@@ -23,6 +23,22 @@ function stubRect(el: Element, width = 100) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
describe('Sparkline', () => {
|
|
26
|
+
it('claims horizontal drags from a surrounding Drawer only while it is interactive', () => {
|
|
27
|
+
const chart = (container: HTMLElement) => container.querySelector('[data-slot="sparkline-svg"]')!.parentElement
|
|
28
|
+
const { container: interactive } = render(
|
|
29
|
+
<Sparkline data={DATA}>
|
|
30
|
+
<SparklineChart />
|
|
31
|
+
</Sparkline>,
|
|
32
|
+
)
|
|
33
|
+
expect(chart(interactive)).toHaveAttribute('data-base-ui-swipe-ignore', 'x')
|
|
34
|
+
const { container: still } = render(
|
|
35
|
+
<Sparkline data={DATA}>
|
|
36
|
+
<SparklineChart indicator={false} />
|
|
37
|
+
</Sparkline>,
|
|
38
|
+
)
|
|
39
|
+
expect(chart(still)).not.toHaveAttribute('data-base-ui-swipe-ignore')
|
|
40
|
+
})
|
|
41
|
+
|
|
26
42
|
it('renders a line path for the line variant', () => {
|
|
27
43
|
const { container } = render(
|
|
28
44
|
<Sparkline data={DATA}>
|
|
@@ -271,6 +271,7 @@ function SparklineChart({
|
|
|
271
271
|
aria-label={ariaLabel ?? `${variant} chart`}
|
|
272
272
|
className={cn('relative w-full', className)}
|
|
273
273
|
style={{ height, touchAction: interactive ? 'pan-y' : undefined, ...style }}
|
|
274
|
+
data-base-ui-swipe-ignore={interactive ? 'x' : undefined}
|
|
274
275
|
onPointerDown={interactive ? handlePointerDown : undefined}
|
|
275
276
|
onPointerMove={interactive ? handlePointerMove : undefined}
|
|
276
277
|
onPointerLeave={interactive ? () => setActiveIndex(null) : undefined}
|