@appica/ui-react 1.0.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/LICENSE +21 -0
- package/README.md +91 -0
- package/dist/components/accordion/accordion.d.ts +29 -0
- package/dist/components/accordion/accordion.d.ts.map +1 -0
- package/dist/components/accordion/accordion.js +210 -0
- package/dist/components/accordion/accordion.js.map +1 -0
- package/dist/components/alert/alert.d.ts +32 -0
- package/dist/components/alert/alert.d.ts.map +1 -0
- package/dist/components/alert/alert.js +203 -0
- package/dist/components/alert/alert.js.map +1 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +28 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts.map +1 -0
- package/dist/components/alert-dialog/alert-dialog.js +127 -0
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -0
- package/dist/components/autocomplete/autocomplete.d.ts +48 -0
- package/dist/components/autocomplete/autocomplete.d.ts.map +1 -0
- package/dist/components/autocomplete/autocomplete.js +299 -0
- package/dist/components/autocomplete/autocomplete.js.map +1 -0
- package/dist/components/avatar/avatar.d.ts +29 -0
- package/dist/components/avatar/avatar.d.ts.map +1 -0
- package/dist/components/avatar/avatar.js +115 -0
- package/dist/components/avatar/avatar.js.map +1 -0
- package/dist/components/background-pattern/background-pattern-interactive.d.ts +10 -0
- package/dist/components/background-pattern/background-pattern-interactive.d.ts.map +1 -0
- package/dist/components/background-pattern/background-pattern-interactive.js +72 -0
- package/dist/components/background-pattern/background-pattern-interactive.js.map +1 -0
- package/dist/components/background-pattern/background-pattern-shared.d.ts +12 -0
- package/dist/components/background-pattern/background-pattern-shared.d.ts.map +1 -0
- package/dist/components/background-pattern/background-pattern-shared.js +73 -0
- package/dist/components/background-pattern/background-pattern-shared.js.map +1 -0
- package/dist/components/background-pattern/background-pattern.d.ts +23 -0
- package/dist/components/background-pattern/background-pattern.d.ts.map +1 -0
- package/dist/components/background-pattern/background-pattern.js +49 -0
- package/dist/components/background-pattern/background-pattern.js.map +1 -0
- package/dist/components/background-pattern/index.d.ts +4 -0
- package/dist/components/background-pattern/index.d.ts.map +1 -0
- package/dist/components/background-pattern/index.js +3 -0
- package/dist/components/background-pattern/index.js.map +1 -0
- package/dist/components/badge/badge.d.ts +17 -0
- package/dist/components/badge/badge.d.ts.map +1 -0
- package/dist/components/badge/badge.js +134 -0
- package/dist/components/badge/badge.js.map +1 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +24 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -0
- package/dist/components/breadcrumb/breadcrumb.js +106 -0
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -0
- package/dist/components/button/button-variants.d.ts +6 -0
- package/dist/components/button/button-variants.d.ts.map +1 -0
- package/dist/components/button/button-variants.js +69 -0
- package/dist/components/button/button-variants.js.map +1 -0
- package/dist/components/button/button.d.ts +10 -0
- package/dist/components/button/button.d.ts.map +1 -0
- package/dist/components/button/button.js +26 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/index.d.ts +3 -0
- package/dist/components/button/index.d.ts.map +1 -0
- package/dist/components/button/index.js +3 -0
- package/dist/components/button/index.js.map +1 -0
- package/dist/components/button-group/button-group-context.d.ts +13 -0
- package/dist/components/button-group/button-group-context.d.ts.map +1 -0
- package/dist/components/button-group/button-group-context.js +7 -0
- package/dist/components/button-group/button-group-context.js.map +1 -0
- package/dist/components/button-group/button-group.d.ts +12 -0
- package/dist/components/button-group/button-group.d.ts.map +1 -0
- package/dist/components/button-group/button-group.js +45 -0
- package/dist/components/button-group/button-group.js.map +1 -0
- package/dist/components/calendar/calendar.d.ts +14 -0
- package/dist/components/calendar/calendar.d.ts.map +1 -0
- package/dist/components/calendar/calendar.js +228 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/carousel/carousel.d.ts +128 -0
- package/dist/components/carousel/carousel.d.ts.map +1 -0
- package/dist/components/carousel/carousel.js +795 -0
- package/dist/components/carousel/carousel.js.map +1 -0
- package/dist/components/checkbox/checkbox.d.ts +7 -0
- package/dist/components/checkbox/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox/checkbox.js +128 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts +9 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts.map +1 -0
- package/dist/components/checkbox-group/checkbox-group.js +18 -0
- package/dist/components/checkbox-group/checkbox-group.js.map +1 -0
- package/dist/components/chip/chip.d.ts +36 -0
- package/dist/components/chip/chip.d.ts.map +1 -0
- package/dist/components/chip/chip.js +159 -0
- package/dist/components/chip/chip.js.map +1 -0
- package/dist/components/collapsible/collapsible.d.ts +11 -0
- package/dist/components/collapsible/collapsible.d.ts.map +1 -0
- package/dist/components/collapsible/collapsible.js +41 -0
- package/dist/components/collapsible/collapsible.js.map +1 -0
- package/dist/components/combobox/combobox.d.ts +57 -0
- package/dist/components/combobox/combobox.d.ts.map +1 -0
- package/dist/components/combobox/combobox.js +456 -0
- package/dist/components/combobox/combobox.js.map +1 -0
- package/dist/components/context-menu/context-menu.d.ts +43 -0
- package/dist/components/context-menu/context-menu.d.ts.map +1 -0
- package/dist/components/context-menu/context-menu.js +243 -0
- package/dist/components/context-menu/context-menu.js.map +1 -0
- package/dist/components/copy-button/copy-button.d.ts +15 -0
- package/dist/components/copy-button/copy-button.d.ts.map +1 -0
- package/dist/components/copy-button/copy-button.js +126 -0
- package/dist/components/copy-button/copy-button.js.map +1 -0
- package/dist/components/countdown/countdown.d.ts +26 -0
- package/dist/components/countdown/countdown.d.ts.map +1 -0
- package/dist/components/countdown/countdown.js +111 -0
- package/dist/components/countdown/countdown.js.map +1 -0
- package/dist/components/date-field/date-field.d.ts +25 -0
- package/dist/components/date-field/date-field.d.ts.map +1 -0
- package/dist/components/date-field/date-field.js +403 -0
- package/dist/components/date-field/date-field.js.map +1 -0
- package/dist/components/date-picker/date-picker.d.ts +58 -0
- package/dist/components/date-picker/date-picker.d.ts.map +1 -0
- package/dist/components/date-picker/date-picker.js +449 -0
- package/dist/components/date-picker/date-picker.js.map +1 -0
- package/dist/components/dialog/dialog.d.ts +30 -0
- package/dist/components/dialog/dialog.d.ts.map +1 -0
- package/dist/components/dialog/dialog.js +138 -0
- package/dist/components/dialog/dialog.js.map +1 -0
- package/dist/components/drawer/drawer.d.ts +39 -0
- package/dist/components/drawer/drawer.d.ts.map +1 -0
- package/dist/components/drawer/drawer.js +270 -0
- package/dist/components/drawer/drawer.js.map +1 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +43 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts.map +1 -0
- package/dist/components/dropdown-menu/dropdown-menu.js +235 -0
- package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -0
- package/dist/components/field/field.d.ts +15 -0
- package/dist/components/field/field.d.ts.map +1 -0
- package/dist/components/field/field.js +62 -0
- package/dist/components/field/field.js.map +1 -0
- package/dist/components/fieldset/fieldset.d.ts +9 -0
- package/dist/components/fieldset/fieldset.d.ts.map +1 -0
- package/dist/components/fieldset/fieldset.js +20 -0
- package/dist/components/fieldset/fieldset.js.map +1 -0
- package/dist/components/form/form.d.ts +7 -0
- package/dist/components/form/form.d.ts.map +1 -0
- package/dist/components/form/form.js +9 -0
- package/dist/components/form/form.js.map +1 -0
- package/dist/components/gradient-glow/gradient-glow.d.ts +21 -0
- package/dist/components/gradient-glow/gradient-glow.d.ts.map +1 -0
- package/dist/components/gradient-glow/gradient-glow.js +99 -0
- package/dist/components/gradient-glow/gradient-glow.js.map +1 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/components/input/index.d.ts.map +1 -0
- package/dist/components/input/index.js +3 -0
- package/dist/components/input/index.js.map +1 -0
- package/dist/components/input/input-variants.d.ts +7 -0
- package/dist/components/input/input-variants.d.ts.map +1 -0
- package/dist/components/input/input-variants.js +52 -0
- package/dist/components/input/input-variants.js.map +1 -0
- package/dist/components/input/input.d.ts +19 -0
- package/dist/components/input/input.d.ts.map +1 -0
- package/dist/components/input/input.js +96 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/kbd/kbd.d.ts +13 -0
- package/dist/components/kbd/kbd.d.ts.map +1 -0
- package/dist/components/kbd/kbd.js +34 -0
- package/dist/components/kbd/kbd.js.map +1 -0
- package/dist/components/loader/loader.d.ts +10 -0
- package/dist/components/loader/loader.d.ts.map +1 -0
- package/dist/components/loader/loader.js +137 -0
- package/dist/components/loader/loader.js.map +1 -0
- package/dist/components/menubar/menubar.d.ts +44 -0
- package/dist/components/menubar/menubar.d.ts.map +1 -0
- package/dist/components/menubar/menubar.js +114 -0
- package/dist/components/menubar/menubar.js.map +1 -0
- package/dist/components/meter/meter.d.ts +24 -0
- package/dist/components/meter/meter.d.ts.map +1 -0
- package/dist/components/meter/meter.js +105 -0
- package/dist/components/meter/meter.js.map +1 -0
- package/dist/components/navigation/index.d.ts +4 -0
- package/dist/components/navigation/index.d.ts.map +1 -0
- package/dist/components/navigation/index.js +4 -0
- package/dist/components/navigation/index.js.map +1 -0
- package/dist/components/navigation/navigation-context.d.ts +16 -0
- package/dist/components/navigation/navigation-context.d.ts.map +1 -0
- package/dist/components/navigation/navigation-context.js +10 -0
- package/dist/components/navigation/navigation-context.js.map +1 -0
- package/dist/components/navigation/navigation-link-variants.d.ts +9 -0
- package/dist/components/navigation/navigation-link-variants.d.ts.map +1 -0
- package/dist/components/navigation/navigation-link-variants.js +189 -0
- package/dist/components/navigation/navigation-link-variants.js.map +1 -0
- package/dist/components/navigation/navigation-link.d.ts +20 -0
- package/dist/components/navigation/navigation-link.d.ts.map +1 -0
- package/dist/components/navigation/navigation-link.js +54 -0
- package/dist/components/navigation/navigation-link.js.map +1 -0
- package/dist/components/navigation/navigation.d.ts +21 -0
- package/dist/components/navigation/navigation.d.ts.map +1 -0
- package/dist/components/navigation/navigation.js +41 -0
- package/dist/components/navigation/navigation.js.map +1 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +41 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts.map +1 -0
- package/dist/components/navigation-menu/navigation-menu.js +329 -0
- package/dist/components/navigation-menu/navigation-menu.js.map +1 -0
- package/dist/components/number-field/number-field.d.ts +17 -0
- package/dist/components/number-field/number-field.d.ts.map +1 -0
- package/dist/components/number-field/number-field.js +270 -0
- package/dist/components/number-field/number-field.js.map +1 -0
- package/dist/components/otp-field/otp-field.d.ts +19 -0
- package/dist/components/otp-field/otp-field.d.ts.map +1 -0
- package/dist/components/otp-field/otp-field.js +66 -0
- package/dist/components/otp-field/otp-field.js.map +1 -0
- package/dist/components/pagination/pagination.d.ts +29 -0
- package/dist/components/pagination/pagination.d.ts.map +1 -0
- package/dist/components/pagination/pagination.js +92 -0
- package/dist/components/pagination/pagination.js.map +1 -0
- package/dist/components/popover/popover.d.ts +22 -0
- package/dist/components/popover/popover.d.ts.map +1 -0
- package/dist/components/popover/popover.js +108 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/preview-card/preview-card.d.ts +16 -0
- package/dist/components/preview-card/preview-card.d.ts.map +1 -0
- package/dist/components/preview-card/preview-card.js +92 -0
- package/dist/components/preview-card/preview-card.js.map +1 -0
- package/dist/components/progress/progress.d.ts +18 -0
- package/dist/components/progress/progress.d.ts.map +1 -0
- package/dist/components/progress/progress.js +134 -0
- package/dist/components/progress/progress.js.map +1 -0
- package/dist/components/radio/radio.d.ts +7 -0
- package/dist/components/radio/radio.d.ts.map +1 -0
- package/dist/components/radio/radio.js +73 -0
- package/dist/components/radio/radio.js.map +1 -0
- package/dist/components/radio-group/radio-group.d.ts +9 -0
- package/dist/components/radio-group/radio-group.d.ts.map +1 -0
- package/dist/components/radio-group/radio-group.js +19 -0
- package/dist/components/radio-group/radio-group.js.map +1 -0
- package/dist/components/scroll-area/scroll-area.d.ts +14 -0
- package/dist/components/scroll-area/scroll-area.d.ts.map +1 -0
- package/dist/components/scroll-area/scroll-area.js +87 -0
- package/dist/components/scroll-area/scroll-area.js.map +1 -0
- package/dist/components/select/select.d.ts +36 -0
- package/dist/components/select/select.d.ts.map +1 -0
- package/dist/components/select/select.js +345 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/separator/separator.d.ts +10 -0
- package/dist/components/separator/separator.d.ts.map +1 -0
- package/dist/components/separator/separator.js +81 -0
- package/dist/components/separator/separator.js.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +9 -0
- package/dist/components/skeleton/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton/skeleton.js +27 -0
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/slider/slider.d.ts +11 -0
- package/dist/components/slider/slider.d.ts.map +1 -0
- package/dist/components/slider/slider.js +187 -0
- package/dist/components/slider/slider.js.map +1 -0
- package/dist/components/sparkline/sparkline.d.ts +39 -0
- package/dist/components/sparkline/sparkline.d.ts.map +1 -0
- package/dist/components/sparkline/sparkline.js +356 -0
- package/dist/components/sparkline/sparkline.js.map +1 -0
- package/dist/components/spinner/spinner.d.ts +10 -0
- package/dist/components/spinner/spinner.d.ts.map +1 -0
- package/dist/components/spinner/spinner.js +179 -0
- package/dist/components/spinner/spinner.js.map +1 -0
- package/dist/components/switch/switch.d.ts +33 -0
- package/dist/components/switch/switch.d.ts.map +1 -0
- package/dist/components/switch/switch.js +137 -0
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/table/table.d.ts +34 -0
- package/dist/components/table/table.d.ts.map +1 -0
- package/dist/components/table/table.js +108 -0
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +35 -0
- package/dist/components/tabs/tabs.d.ts.map +1 -0
- package/dist/components/tabs/tabs.js +192 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/text-animate/text-animate.d.ts +31 -0
- package/dist/components/text-animate/text-animate.d.ts.map +1 -0
- package/dist/components/text-animate/text-animate.js +230 -0
- package/dist/components/text-animate/text-animate.js.map +1 -0
- package/dist/components/textarea/textarea.d.ts +17 -0
- package/dist/components/textarea/textarea.d.ts.map +1 -0
- package/dist/components/textarea/textarea.js +117 -0
- package/dist/components/textarea/textarea.js.map +1 -0
- package/dist/components/thumbnail/thumbnail.d.ts +26 -0
- package/dist/components/thumbnail/thumbnail.d.ts.map +1 -0
- package/dist/components/thumbnail/thumbnail.js +116 -0
- package/dist/components/thumbnail/thumbnail.js.map +1 -0
- package/dist/components/time-field/time-field.d.ts +25 -0
- package/dist/components/time-field/time-field.d.ts.map +1 -0
- package/dist/components/time-field/time-field.js +488 -0
- package/dist/components/time-field/time-field.js.map +1 -0
- package/dist/components/toast/toast.d.ts +59 -0
- package/dist/components/toast/toast.d.ts.map +1 -0
- package/dist/components/toast/toast.js +239 -0
- package/dist/components/toast/toast.js.map +1 -0
- package/dist/components/toc/toc.d.ts +21 -0
- package/dist/components/toc/toc.d.ts.map +1 -0
- package/dist/components/toc/toc.js +185 -0
- package/dist/components/toc/toc.js.map +1 -0
- package/dist/components/toggle/toggle.d.ts +7 -0
- package/dist/components/toggle/toggle.d.ts.map +1 -0
- package/dist/components/toggle/toggle.js +9 -0
- package/dist/components/toggle/toggle.js.map +1 -0
- package/dist/components/toggle-group/toggle-group.d.ts +7 -0
- package/dist/components/toggle-group/toggle-group.d.ts.map +1 -0
- package/dist/components/toggle-group/toggle-group.js +21 -0
- package/dist/components/toggle-group/toggle-group.js.map +1 -0
- package/dist/components/toolbar/toolbar.d.ts +23 -0
- package/dist/components/toolbar/toolbar.d.ts.map +1 -0
- package/dist/components/toolbar/toolbar.js +56 -0
- package/dist/components/toolbar/toolbar.js.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +16 -0
- package/dist/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip/tooltip.js +64 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/floating.d.ts +47 -0
- package/dist/floating.d.ts.map +1 -0
- package/dist/floating.js +35 -0
- package/dist/floating.js.map +1 -0
- package/dist/hooks/use-direction.d.ts +2 -0
- package/dist/hooks/use-direction.d.ts.map +1 -0
- package/dist/hooks/use-direction.js +3 -0
- package/dist/hooks/use-direction.js.map +1 -0
- package/dist/hooks/use-dismissible.d.ts +16 -0
- package/dist/hooks/use-dismissible.d.ts.map +1 -0
- package/dist/hooks/use-dismissible.js +17 -0
- package/dist/hooks/use-dismissible.js.map +1 -0
- package/dist/hooks/use-local-storage.d.ts +24 -0
- package/dist/hooks/use-local-storage.d.ts.map +1 -0
- package/dist/hooks/use-local-storage.js +127 -0
- package/dist/hooks/use-local-storage.js.map +1 -0
- package/dist/hooks/use-media-query.d.ts +20 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +19 -0
- package/dist/hooks/use-media-query.js.map +1 -0
- package/dist/hooks/use-reduced-motion.d.ts +7 -0
- package/dist/hooks/use-reduced-motion.d.ts.map +1 -0
- package/dist/hooks/use-reduced-motion.js +13 -0
- package/dist/hooks/use-reduced-motion.js.map +1 -0
- package/dist/hooks/use-theme.d.ts +11 -0
- package/dist/hooks/use-theme.d.ts.map +1 -0
- package/dist/hooks/use-theme.js +9 -0
- package/dist/hooks/use-theme.js.map +1 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/modal.d.ts +42 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +18 -0
- package/dist/modal.js.map +1 -0
- package/dist/providers/direction-provider.d.ts +21 -0
- package/dist/providers/direction-provider.d.ts.map +1 -0
- package/dist/providers/direction-provider.js +9 -0
- package/dist/providers/direction-provider.js.map +1 -0
- package/dist/providers/reduced-motion-provider.d.ts +30 -0
- package/dist/providers/reduced-motion-provider.d.ts.map +1 -0
- package/dist/providers/reduced-motion-provider.js +27 -0
- package/dist/providers/reduced-motion-provider.js.map +1 -0
- package/dist/providers/theme-provider/index.d.ts +5 -0
- package/dist/providers/theme-provider/index.d.ts.map +1 -0
- package/dist/providers/theme-provider/index.js +3 -0
- package/dist/providers/theme-provider/index.js.map +1 -0
- package/dist/providers/theme-provider/theme-provider.d.ts +39 -0
- package/dist/providers/theme-provider/theme-provider.d.ts.map +1 -0
- package/dist/providers/theme-provider/theme-provider.js +118 -0
- package/dist/providers/theme-provider/theme-provider.js.map +1 -0
- package/dist/providers/theme-provider/theme-script.d.ts +28 -0
- package/dist/providers/theme-provider/theme-script.d.ts.map +1 -0
- package/dist/providers/theme-provider/theme-script.js +59 -0
- package/dist/providers/theme-provider/theme-script.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +51 -0
- package/dist/utils.js.map +1 -0
- package/package.json +479 -0
- package/src/components/accordion/accordion.test.tsx +220 -0
- package/src/components/accordion/accordion.tsx +269 -0
- package/src/components/alert/alert.test.tsx +188 -0
- package/src/components/alert/alert.tsx +243 -0
- package/src/components/alert-dialog/alert-dialog.test.tsx +141 -0
- package/src/components/alert-dialog/alert-dialog.tsx +179 -0
- package/src/components/autocomplete/autocomplete.test.tsx +384 -0
- package/src/components/autocomplete/autocomplete.tsx +442 -0
- package/src/components/avatar/avatar.test.tsx +368 -0
- package/src/components/avatar/avatar.tsx +142 -0
- package/src/components/background-pattern/background-pattern-interactive.tsx +93 -0
- package/src/components/background-pattern/background-pattern-shared.tsx +96 -0
- package/src/components/background-pattern/background-pattern.test.tsx +97 -0
- package/src/components/background-pattern/background-pattern.tsx +67 -0
- package/src/components/background-pattern/index.ts +3 -0
- package/src/components/badge/badge.test.tsx +58 -0
- package/src/components/badge/badge.tsx +149 -0
- package/src/components/breadcrumb/breadcrumb.test.tsx +174 -0
- package/src/components/breadcrumb/breadcrumb.tsx +146 -0
- package/src/components/button/button-variants.ts +69 -0
- package/src/components/button/button.test.tsx +79 -0
- package/src/components/button/button.tsx +28 -0
- package/src/components/button/index.ts +2 -0
- package/src/components/button-group/button-group-context.ts +18 -0
- package/src/components/button-group/button-group.test.tsx +223 -0
- package/src/components/button-group/button-group.tsx +59 -0
- package/src/components/calendar/calendar.test.tsx +69 -0
- package/src/components/calendar/calendar.tsx +295 -0
- package/src/components/carousel/carousel.test.tsx +493 -0
- package/src/components/carousel/carousel.tsx +1003 -0
- package/src/components/checkbox/checkbox.test.tsx +100 -0
- package/src/components/checkbox/checkbox.tsx +154 -0
- package/src/components/checkbox-group/checkbox-group.test.tsx +86 -0
- package/src/components/checkbox-group/checkbox-group.tsx +21 -0
- package/src/components/chip/chip.test.tsx +242 -0
- package/src/components/chip/chip.tsx +234 -0
- package/src/components/collapsible/collapsible.test.tsx +126 -0
- package/src/components/collapsible/collapsible.tsx +47 -0
- package/src/components/combobox/combobox.test.tsx +410 -0
- package/src/components/combobox/combobox.tsx +598 -0
- package/src/components/context-menu/context-menu.test.tsx +226 -0
- package/src/components/context-menu/context-menu.tsx +345 -0
- package/src/components/copy-button/copy-button.test.tsx +147 -0
- package/src/components/copy-button/copy-button.tsx +141 -0
- package/src/components/countdown/countdown.test.tsx +130 -0
- package/src/components/countdown/countdown.tsx +170 -0
- package/src/components/date-field/date-field.test.tsx +373 -0
- package/src/components/date-field/date-field.tsx +512 -0
- package/src/components/date-picker/date-picker.test.tsx +291 -0
- package/src/components/date-picker/date-picker.tsx +572 -0
- package/src/components/dialog/dialog.test.tsx +173 -0
- package/src/components/dialog/dialog.tsx +190 -0
- package/src/components/drawer/drawer.test.tsx +191 -0
- package/src/components/drawer/drawer.tsx +365 -0
- package/src/components/dropdown-menu/dropdown-menu.test.tsx +227 -0
- package/src/components/dropdown-menu/dropdown-menu.tsx +341 -0
- package/src/components/field/field.test.tsx +84 -0
- package/src/components/field/field.tsx +71 -0
- package/src/components/fieldset/fieldset.test.tsx +62 -0
- package/src/components/fieldset/fieldset.tsx +24 -0
- package/src/components/form/form.test.tsx +61 -0
- package/src/components/form/form.tsx +11 -0
- package/src/components/gradient-glow/gradient-glow.test.tsx +110 -0
- package/src/components/gradient-glow/gradient-glow.tsx +132 -0
- package/src/components/input/index.ts +2 -0
- package/src/components/input/input-variants.ts +52 -0
- package/src/components/input/input.test.tsx +118 -0
- package/src/components/input/input.tsx +120 -0
- package/src/components/kbd/kbd.test.tsx +119 -0
- package/src/components/kbd/kbd.tsx +48 -0
- package/src/components/loader/loader.test.tsx +57 -0
- package/src/components/loader/loader.tsx +163 -0
- package/src/components/menubar/menubar.test.tsx +162 -0
- package/src/components/menubar/menubar.tsx +226 -0
- package/src/components/meter/meter.test.tsx +172 -0
- package/src/components/meter/meter.tsx +144 -0
- package/src/components/navigation/index.ts +3 -0
- package/src/components/navigation/navigation-context.ts +24 -0
- package/src/components/navigation/navigation-link-variants.ts +197 -0
- package/src/components/navigation/navigation-link.tsx +90 -0
- package/src/components/navigation/navigation.test.tsx +253 -0
- package/src/components/navigation/navigation.tsx +74 -0
- package/src/components/navigation-menu/navigation-menu.test.tsx +258 -0
- package/src/components/navigation-menu/navigation-menu.tsx +410 -0
- package/src/components/number-field/number-field.test.tsx +224 -0
- package/src/components/number-field/number-field.tsx +310 -0
- package/src/components/otp-field/otp-field.test.tsx +113 -0
- package/src/components/otp-field/otp-field.tsx +105 -0
- package/src/components/pagination/pagination.test.tsx +147 -0
- package/src/components/pagination/pagination.tsx +139 -0
- package/src/components/popover/popover.test.tsx +135 -0
- package/src/components/popover/popover.tsx +134 -0
- package/src/components/preview-card/preview-card.test.tsx +99 -0
- package/src/components/preview-card/preview-card.tsx +103 -0
- package/src/components/progress/progress.test.tsx +109 -0
- package/src/components/progress/progress.tsx +151 -0
- package/src/components/radio/radio.test.tsx +141 -0
- package/src/components/radio/radio.tsx +94 -0
- package/src/components/radio-group/radio-group.test.tsx +80 -0
- package/src/components/radio-group/radio-group.tsx +22 -0
- package/src/components/scroll-area/scroll-area.test.tsx +133 -0
- package/src/components/scroll-area/scroll-area.tsx +101 -0
- package/src/components/select/select.test.tsx +251 -0
- package/src/components/select/select.tsx +446 -0
- package/src/components/separator/separator.test.tsx +46 -0
- package/src/components/separator/separator.tsx +95 -0
- package/src/components/skeleton/skeleton.test.tsx +55 -0
- package/src/components/skeleton/skeleton.tsx +33 -0
- package/src/components/slider/slider.test.tsx +123 -0
- package/src/components/slider/slider.tsx +262 -0
- package/src/components/sparkline/sparkline.test.tsx +249 -0
- package/src/components/sparkline/sparkline.tsx +446 -0
- package/src/components/spinner/spinner.test.tsx +57 -0
- package/src/components/spinner/spinner.tsx +219 -0
- package/src/components/switch/switch.test.tsx +100 -0
- package/src/components/switch/switch.tsx +166 -0
- package/src/components/table/table.test.tsx +175 -0
- package/src/components/table/table.tsx +157 -0
- package/src/components/tabs/tabs.test.tsx +165 -0
- package/src/components/tabs/tabs.tsx +246 -0
- package/src/components/text-animate/text-animate.test.tsx +125 -0
- package/src/components/text-animate/text-animate.tsx +354 -0
- package/src/components/textarea/textarea.test.tsx +188 -0
- package/src/components/textarea/textarea.tsx +144 -0
- package/src/components/thumbnail/thumbnail.test.tsx +217 -0
- package/src/components/thumbnail/thumbnail.tsx +139 -0
- package/src/components/time-field/time-field.test.tsx +376 -0
- package/src/components/time-field/time-field.tsx +625 -0
- package/src/components/toast/toast.test.tsx +277 -0
- package/src/components/toast/toast.tsx +377 -0
- package/src/components/toc/toc.test.tsx +197 -0
- package/src/components/toc/toc.tsx +233 -0
- package/src/components/toggle/toggle.test.tsx +109 -0
- package/src/components/toggle/toggle.tsx +10 -0
- package/src/components/toggle-group/toggle-group.test.tsx +95 -0
- package/src/components/toggle-group/toggle-group.tsx +21 -0
- package/src/components/toolbar/toolbar.test.tsx +78 -0
- package/src/components/toolbar/toolbar.tsx +77 -0
- package/src/components/tooltip/tooltip.test.tsx +100 -0
- package/src/components/tooltip/tooltip.tsx +78 -0
- package/src/floating.test.ts +40 -0
- package/src/floating.ts +103 -0
- package/src/globals.d.ts +34 -0
- package/src/hooks/use-direction.ts +3 -0
- package/src/hooks/use-dismissible.ts +33 -0
- package/src/hooks/use-local-storage.test.tsx +63 -0
- package/src/hooks/use-local-storage.ts +190 -0
- package/src/hooks/use-media-query.test.tsx +65 -0
- package/src/hooks/use-media-query.ts +38 -0
- package/src/hooks/use-reduced-motion.ts +17 -0
- package/src/hooks/use-theme.ts +16 -0
- package/src/index.ts +76 -0
- package/src/modal.test.ts +34 -0
- package/src/modal.ts +80 -0
- package/src/providers/direction-provider.test.tsx +20 -0
- package/src/providers/direction-provider.tsx +26 -0
- package/src/providers/reduced-motion-provider.test.tsx +42 -0
- package/src/providers/reduced-motion-provider.tsx +58 -0
- package/src/providers/theme-provider/index.ts +4 -0
- package/src/providers/theme-provider/theme-provider.test.tsx +97 -0
- package/src/providers/theme-provider/theme-provider.tsx +169 -0
- package/src/providers/theme-provider/theme-script.tsx +108 -0
- package/src/test/setup.ts +27 -0
- package/src/test/vitest-axe.d.ts +7 -0
- package/src/utils.test.tsx +63 -0
- package/src/utils.ts +57 -0
- package/styles.css +523 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
import userEvent from '@testing-library/user-event'
|
|
3
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
4
|
+
import { axe } from 'vitest-axe'
|
|
5
|
+
import { Navigation, NavigationList, NavigationItem } from './navigation'
|
|
6
|
+
import { type NavigationActiveLink, type NavigationSize } from './navigation-context'
|
|
7
|
+
import { NavigationLink } from './navigation-link'
|
|
8
|
+
|
|
9
|
+
function renderBasic(props?: { activeLink?: NavigationActiveLink; size?: NavigationSize }) {
|
|
10
|
+
return render(
|
|
11
|
+
<Navigation aria-label="Main" {...props}>
|
|
12
|
+
<NavigationList>
|
|
13
|
+
<NavigationItem>
|
|
14
|
+
<NavigationLink href="#home" value="home">
|
|
15
|
+
Home
|
|
16
|
+
</NavigationLink>
|
|
17
|
+
</NavigationItem>
|
|
18
|
+
<NavigationItem>
|
|
19
|
+
<NavigationLink href="#about" value="about">
|
|
20
|
+
About
|
|
21
|
+
</NavigationLink>
|
|
22
|
+
</NavigationItem>
|
|
23
|
+
<NavigationItem>
|
|
24
|
+
<NavigationLink href="#contact" value="contact">
|
|
25
|
+
Contact
|
|
26
|
+
</NavigationLink>
|
|
27
|
+
</NavigationItem>
|
|
28
|
+
</NavigationList>
|
|
29
|
+
</Navigation>,
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe('Navigation', () => {
|
|
34
|
+
it('renders as a <nav> with role and accessible name', () => {
|
|
35
|
+
renderBasic()
|
|
36
|
+
const nav = screen.getByRole('navigation', { name: 'Main' })
|
|
37
|
+
expect(nav.tagName).toBe('NAV')
|
|
38
|
+
expect(nav).toHaveAttribute('data-slot', 'navigation')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('defaults to horizontal orientation via data-orientation', () => {
|
|
42
|
+
renderBasic()
|
|
43
|
+
const nav = screen.getByRole('navigation', { name: 'Main' })
|
|
44
|
+
expect(nav).not.toHaveAttribute('aria-orientation')
|
|
45
|
+
expect(nav).toHaveAttribute('data-orientation', 'horizontal')
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('marks vertical orientation with data-orientation', () => {
|
|
49
|
+
render(
|
|
50
|
+
<Navigation aria-label="Side" orientation="vertical" variant="line">
|
|
51
|
+
<NavigationList>
|
|
52
|
+
<NavigationItem>
|
|
53
|
+
<NavigationLink href="#a" value="a">
|
|
54
|
+
A
|
|
55
|
+
</NavigationLink>
|
|
56
|
+
</NavigationItem>
|
|
57
|
+
</NavigationList>
|
|
58
|
+
</Navigation>,
|
|
59
|
+
)
|
|
60
|
+
const nav = screen.getByRole('navigation', { name: 'Side' })
|
|
61
|
+
expect(nav).toHaveAttribute('data-orientation', 'vertical')
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('renders <ul> for the list and <li> for items', () => {
|
|
65
|
+
renderBasic()
|
|
66
|
+
const list = screen.getByRole('list')
|
|
67
|
+
expect(list.tagName).toBe('UL')
|
|
68
|
+
expect(list).toHaveAttribute('data-slot', 'navigation-list')
|
|
69
|
+
expect(screen.getAllByRole('listitem')).toHaveLength(3)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('activeLink matches the link with the corresponding value', () => {
|
|
73
|
+
renderBasic({ activeLink: 'about' })
|
|
74
|
+
const active = screen.getByRole('link', { current: 'page' })
|
|
75
|
+
expect(active).toHaveTextContent('About')
|
|
76
|
+
expect(active).toHaveAttribute('data-active')
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('per-link active={true} overrides activeLink mismatch', () => {
|
|
80
|
+
render(
|
|
81
|
+
<Navigation aria-label="Main" activeLink="home">
|
|
82
|
+
<NavigationList>
|
|
83
|
+
<NavigationItem>
|
|
84
|
+
<NavigationLink href="#about" value="about" active>
|
|
85
|
+
About
|
|
86
|
+
</NavigationLink>
|
|
87
|
+
</NavigationItem>
|
|
88
|
+
</NavigationList>
|
|
89
|
+
</Navigation>,
|
|
90
|
+
)
|
|
91
|
+
const link = screen.getByRole('link', { name: 'About' })
|
|
92
|
+
expect(link).toHaveAttribute('aria-current', 'page')
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('per-link active={false} overrides activeLink match', () => {
|
|
96
|
+
render(
|
|
97
|
+
<Navigation aria-label="Main" activeLink="home">
|
|
98
|
+
<NavigationList>
|
|
99
|
+
<NavigationItem>
|
|
100
|
+
<NavigationLink href="#home" value="home" active={false}>
|
|
101
|
+
Home
|
|
102
|
+
</NavigationLink>
|
|
103
|
+
</NavigationItem>
|
|
104
|
+
</NavigationList>
|
|
105
|
+
</Navigation>,
|
|
106
|
+
)
|
|
107
|
+
const link = screen.getByRole('link', { name: 'Home' })
|
|
108
|
+
expect(link).not.toHaveAttribute('aria-current')
|
|
109
|
+
expect(link).not.toHaveAttribute('data-active')
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('disabled links carry aria-disabled and data-disabled', () => {
|
|
113
|
+
render(
|
|
114
|
+
<Navigation aria-label="Main">
|
|
115
|
+
<NavigationList>
|
|
116
|
+
<NavigationItem>
|
|
117
|
+
<NavigationLink href="#" disabled>
|
|
118
|
+
Disabled
|
|
119
|
+
</NavigationLink>
|
|
120
|
+
</NavigationItem>
|
|
121
|
+
</NavigationList>
|
|
122
|
+
</Navigation>,
|
|
123
|
+
)
|
|
124
|
+
const link = screen.getByRole('link', { name: 'Disabled' })
|
|
125
|
+
expect(link).toHaveAttribute('aria-disabled', 'true')
|
|
126
|
+
expect(link).toHaveAttribute('data-disabled')
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
it('forwards className alongside variant classes on the link', () => {
|
|
130
|
+
render(
|
|
131
|
+
<Navigation aria-label="Main">
|
|
132
|
+
<NavigationList>
|
|
133
|
+
<NavigationItem>
|
|
134
|
+
<NavigationLink href="#" className="my-link">
|
|
135
|
+
One
|
|
136
|
+
</NavigationLink>
|
|
137
|
+
</NavigationItem>
|
|
138
|
+
</NavigationList>
|
|
139
|
+
</Navigation>,
|
|
140
|
+
)
|
|
141
|
+
const link = screen.getByRole('link', { name: 'One' })
|
|
142
|
+
expect(link.className).toContain('my-link')
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
it('renders the link as a different element via render prop', () => {
|
|
146
|
+
const onClick = vi.fn()
|
|
147
|
+
render(
|
|
148
|
+
<Navigation aria-label="Main">
|
|
149
|
+
<NavigationList>
|
|
150
|
+
<NavigationItem>
|
|
151
|
+
<NavigationLink render={<button type="button" onClick={onClick} />}>Btn</NavigationLink>
|
|
152
|
+
</NavigationItem>
|
|
153
|
+
</NavigationList>
|
|
154
|
+
</Navigation>,
|
|
155
|
+
)
|
|
156
|
+
const el = screen.getByRole('button', { name: 'Btn' })
|
|
157
|
+
expect(el.tagName).toBe('BUTTON')
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
it('fires onClick on the link', async () => {
|
|
161
|
+
const user = userEvent.setup()
|
|
162
|
+
const onClick = vi.fn()
|
|
163
|
+
render(
|
|
164
|
+
<Navigation aria-label="Main">
|
|
165
|
+
<NavigationList>
|
|
166
|
+
<NavigationItem>
|
|
167
|
+
<NavigationLink href="#" onClick={onClick}>
|
|
168
|
+
Click
|
|
169
|
+
</NavigationLink>
|
|
170
|
+
</NavigationItem>
|
|
171
|
+
</NavigationList>
|
|
172
|
+
</Navigation>,
|
|
173
|
+
)
|
|
174
|
+
await user.click(screen.getByRole('link', { name: 'Click' }))
|
|
175
|
+
expect(onClick).toHaveBeenCalledOnce()
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
it('renders NavigationLink standalone without a Navigation root', () => {
|
|
179
|
+
render(<NavigationLink href="#solo">Solo</NavigationLink>)
|
|
180
|
+
const link = screen.getByRole('link', { name: 'Solo' })
|
|
181
|
+
expect(link).toHaveAttribute('data-slot', 'navigation-link')
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('indicator variant wraps children in a label slot and renders an indicator slot', () => {
|
|
185
|
+
render(
|
|
186
|
+
<Navigation aria-label="Side" orientation="vertical" variant="indicator">
|
|
187
|
+
<NavigationList>
|
|
188
|
+
<NavigationItem>
|
|
189
|
+
<NavigationLink href="#one" value="one">
|
|
190
|
+
One
|
|
191
|
+
</NavigationLink>
|
|
192
|
+
</NavigationItem>
|
|
193
|
+
</NavigationList>
|
|
194
|
+
</Navigation>,
|
|
195
|
+
)
|
|
196
|
+
const link = screen.getByRole('link', { name: 'One' })
|
|
197
|
+
expect(link.querySelector('[data-slot="navigation-link-indicator"]')).not.toBeNull()
|
|
198
|
+
const label = link.querySelector('[data-slot="navigation-link-label"]')
|
|
199
|
+
expect(label).not.toBeNull()
|
|
200
|
+
expect(label).toHaveTextContent('One')
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
it('indicator variant accepts a custom indicator node', () => {
|
|
204
|
+
render(
|
|
205
|
+
<NavigationLink variant="indicator" indicator={<span data-testid="custom-indicator" />}>
|
|
206
|
+
Item
|
|
207
|
+
</NavigationLink>,
|
|
208
|
+
)
|
|
209
|
+
expect(screen.getByTestId('custom-indicator')).toBeInTheDocument()
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('stamps data-orientation="horizontal" on links by default', () => {
|
|
213
|
+
renderBasic()
|
|
214
|
+
for (const link of screen.getAllByRole('link')) {
|
|
215
|
+
expect(link).toHaveAttribute('data-orientation', 'horizontal')
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
it('propagates vertical orientation to links via context', () => {
|
|
220
|
+
render(
|
|
221
|
+
<Navigation aria-label="Side" orientation="vertical" variant="line">
|
|
222
|
+
<NavigationList>
|
|
223
|
+
<NavigationItem>
|
|
224
|
+
<NavigationLink href="#a" value="a">
|
|
225
|
+
A
|
|
226
|
+
</NavigationLink>
|
|
227
|
+
</NavigationItem>
|
|
228
|
+
</NavigationList>
|
|
229
|
+
</Navigation>,
|
|
230
|
+
)
|
|
231
|
+
expect(screen.getByRole('link', { name: 'A' })).toHaveAttribute('data-orientation', 'vertical')
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
it('NavigationLink orientation prop overrides context', () => {
|
|
235
|
+
render(
|
|
236
|
+
<Navigation aria-label="Main">
|
|
237
|
+
<NavigationList>
|
|
238
|
+
<NavigationItem>
|
|
239
|
+
<NavigationLink href="#a" orientation="vertical">
|
|
240
|
+
A
|
|
241
|
+
</NavigationLink>
|
|
242
|
+
</NavigationItem>
|
|
243
|
+
</NavigationList>
|
|
244
|
+
</Navigation>,
|
|
245
|
+
)
|
|
246
|
+
expect(screen.getByRole('link', { name: 'A' })).toHaveAttribute('data-orientation', 'vertical')
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
it('has no accessibility violations', async () => {
|
|
250
|
+
const { container } = renderBasic({ activeLink: 'home' })
|
|
251
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
252
|
+
})
|
|
253
|
+
})
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { cn } from '../../utils'
|
|
5
|
+
import {
|
|
6
|
+
NavigationContext,
|
|
7
|
+
useNavigationContext,
|
|
8
|
+
type NavigationSize,
|
|
9
|
+
type NavigationVariant,
|
|
10
|
+
type NavigationActiveLink,
|
|
11
|
+
type NavigationContextValue,
|
|
12
|
+
} from './navigation-context'
|
|
13
|
+
|
|
14
|
+
type NavigationBaseProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'aria-orientation'> & {
|
|
15
|
+
size?: NavigationSize
|
|
16
|
+
activeLink?: NavigationActiveLink
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type NavigationProps = NavigationBaseProps &
|
|
20
|
+
(
|
|
21
|
+
| { orientation?: 'horizontal'; variant?: Extract<NavigationVariant, 'pill' | 'line'> }
|
|
22
|
+
| { orientation: 'vertical'; variant?: Extract<NavigationVariant, 'pill' | 'line' | 'indicator'> }
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
function Navigation({
|
|
26
|
+
className,
|
|
27
|
+
orientation = 'horizontal',
|
|
28
|
+
variant = 'pill',
|
|
29
|
+
size = 'md',
|
|
30
|
+
activeLink = null,
|
|
31
|
+
...props
|
|
32
|
+
}: NavigationProps) {
|
|
33
|
+
const ctx = React.useMemo<NavigationContextValue>(
|
|
34
|
+
() => ({ orientation, variant: variant as NavigationVariant, size, activeLink }),
|
|
35
|
+
[orientation, variant, size, activeLink],
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<NavigationContext.Provider value={ctx}>
|
|
40
|
+
<nav data-slot="navigation" data-orientation={orientation} className={className} {...props} />
|
|
41
|
+
</NavigationContext.Provider>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type NavigationListProps = React.ComponentPropsWithoutRef<'ul'>
|
|
46
|
+
|
|
47
|
+
const HORIZONTAL_GAP: Partial<Record<NavigationVariant, string>> = {
|
|
48
|
+
pill: 'gap-0.5',
|
|
49
|
+
line: 'gap-7',
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const VERTICAL_GAP: Partial<Record<NavigationVariant, string>> = {
|
|
53
|
+
pill: 'gap-0.5',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function NavigationList({ className, ...props }: NavigationListProps) {
|
|
57
|
+
const ctx = useNavigationContext()
|
|
58
|
+
const orientation = ctx?.orientation ?? 'horizontal'
|
|
59
|
+
const variant = ctx?.variant ?? 'pill'
|
|
60
|
+
|
|
61
|
+
const gap = (orientation === 'vertical' ? VERTICAL_GAP : HORIZONTAL_GAP)[variant]
|
|
62
|
+
const layout = cn('flex', orientation === 'vertical' && 'flex-col', gap)
|
|
63
|
+
|
|
64
|
+
return <ul data-slot="navigation-list" role="list" className={cn(layout, className)} {...props} />
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type NavigationItemProps = React.ComponentPropsWithoutRef<'li'>
|
|
68
|
+
|
|
69
|
+
function NavigationItem({ className, ...props }: NavigationItemProps) {
|
|
70
|
+
return <li data-slot="navigation-item" className={className} {...props} />
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { Navigation, NavigationList, NavigationItem }
|
|
74
|
+
export type { NavigationProps, NavigationListProps, NavigationItemProps }
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react'
|
|
2
|
+
import userEvent from '@testing-library/user-event'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
import { axe } from 'vitest-axe'
|
|
5
|
+
import {
|
|
6
|
+
NavigationMenu,
|
|
7
|
+
NavigationMenuContent,
|
|
8
|
+
NavigationMenuIcon,
|
|
9
|
+
NavigationMenuItem,
|
|
10
|
+
NavigationMenuLink,
|
|
11
|
+
NavigationMenuList,
|
|
12
|
+
NavigationMenuTrigger,
|
|
13
|
+
} from './navigation-menu'
|
|
14
|
+
|
|
15
|
+
const setupUser = () => userEvent.setup({ pointerEventsCheck: 0 })
|
|
16
|
+
|
|
17
|
+
interface BasicNavProps {
|
|
18
|
+
variant?: 'pill' | 'line'
|
|
19
|
+
size?: 'sm' | 'md' | 'lg'
|
|
20
|
+
icon?: 'chevron' | 'caret' | 'plus' | false
|
|
21
|
+
orientation?: 'horizontal' | 'vertical'
|
|
22
|
+
backdrop?: boolean
|
|
23
|
+
viewport?: boolean
|
|
24
|
+
morph?: boolean
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function BasicNav({ variant, size, icon, orientation, backdrop, viewport, morph }: BasicNavProps = {}) {
|
|
28
|
+
return (
|
|
29
|
+
<NavigationMenu
|
|
30
|
+
{...(variant && { variant })}
|
|
31
|
+
{...(size && { size })}
|
|
32
|
+
{...(icon !== undefined && { icon })}
|
|
33
|
+
{...(orientation && { orientation })}
|
|
34
|
+
{...(backdrop !== undefined && { backdrop })}
|
|
35
|
+
{...(viewport !== undefined && { viewport })}
|
|
36
|
+
{...(morph !== undefined && { morph })}
|
|
37
|
+
aria-label="Main"
|
|
38
|
+
>
|
|
39
|
+
<NavigationMenuList>
|
|
40
|
+
<NavigationMenuItem>
|
|
41
|
+
<NavigationMenuTrigger>
|
|
42
|
+
Products
|
|
43
|
+
<NavigationMenuIcon />
|
|
44
|
+
</NavigationMenuTrigger>
|
|
45
|
+
<NavigationMenuContent>
|
|
46
|
+
<NavigationMenuLink href="/p/one">Product One</NavigationMenuLink>
|
|
47
|
+
<NavigationMenuLink href="/p/two">Product Two</NavigationMenuLink>
|
|
48
|
+
</NavigationMenuContent>
|
|
49
|
+
</NavigationMenuItem>
|
|
50
|
+
<NavigationMenuItem>
|
|
51
|
+
<NavigationMenuTrigger>
|
|
52
|
+
Company
|
|
53
|
+
<NavigationMenuIcon />
|
|
54
|
+
</NavigationMenuTrigger>
|
|
55
|
+
<NavigationMenuContent>
|
|
56
|
+
<NavigationMenuLink href="/about">About</NavigationMenuLink>
|
|
57
|
+
</NavigationMenuContent>
|
|
58
|
+
</NavigationMenuItem>
|
|
59
|
+
</NavigationMenuList>
|
|
60
|
+
</NavigationMenu>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
describe('NavigationMenu', () => {
|
|
65
|
+
it('renders with the navigation-menu data-slot and horizontal orientation by default', () => {
|
|
66
|
+
const { container } = render(<BasicNav />)
|
|
67
|
+
const root = container.querySelector('[data-slot="navigation-menu"]') as HTMLElement
|
|
68
|
+
expect(root).not.toBeNull()
|
|
69
|
+
expect(root.getAttribute('data-orientation')).toBe('horizontal')
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('applies the pill gap to the list by default', () => {
|
|
73
|
+
const { container } = render(<BasicNav />)
|
|
74
|
+
const list = container.querySelector('[data-slot="navigation-menu-list"]') as HTMLElement
|
|
75
|
+
expect(list.className).toContain('gap-0.5')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('applies the line gap to the list when variant is line', () => {
|
|
79
|
+
const { container } = render(<BasicNav variant="line" />)
|
|
80
|
+
const list = container.querySelector('[data-slot="navigation-menu-list"]') as HTMLElement
|
|
81
|
+
expect(list.className).toContain('gap-7')
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('stacks the list vertically when orientation is vertical', () => {
|
|
85
|
+
const { container } = render(<BasicNav orientation="vertical" />)
|
|
86
|
+
const list = container.querySelector('[data-slot="navigation-menu-list"]') as HTMLElement
|
|
87
|
+
expect(list.className).toContain('flex-col')
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('styles triggers with the pill variant by default', () => {
|
|
91
|
+
const { container } = render(<BasicNav />)
|
|
92
|
+
const trigger = container.querySelector('[data-slot="navigation-menu-trigger"]') as HTMLElement
|
|
93
|
+
expect(trigger.className).toContain('before:bg-background-muted')
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it('styles triggers with the line variant when requested', () => {
|
|
97
|
+
const { container } = render(<BasicNav variant="line" />)
|
|
98
|
+
const trigger = container.querySelector('[data-slot="navigation-menu-trigger"]') as HTMLElement
|
|
99
|
+
expect(trigger.className).toContain('after:bg-no-repeat')
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('mirrors the root orientation onto each trigger', () => {
|
|
103
|
+
const { container } = render(<BasicNav orientation="vertical" />)
|
|
104
|
+
const trigger = container.querySelector('[data-slot="navigation-menu-trigger"]') as HTMLElement
|
|
105
|
+
expect(trigger.getAttribute('data-orientation')).toBe('vertical')
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('propagates size to the trigger text class', () => {
|
|
109
|
+
const { container } = render(<BasicNav size="lg" />)
|
|
110
|
+
const trigger = container.querySelector('[data-slot="navigation-menu-trigger"]') as HTMLElement
|
|
111
|
+
expect(trigger.className).toContain('text-base')
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('renders a chevron icon by default and sizes it by the root size', () => {
|
|
115
|
+
const { container } = render(<BasicNav size="md" />)
|
|
116
|
+
const icon = container.querySelector('[data-slot="navigation-menu-icon"]') as HTMLElement
|
|
117
|
+
expect(icon).not.toBeNull()
|
|
118
|
+
const svg = icon.querySelector('svg') as SVGElement
|
|
119
|
+
expect(svg.getAttribute('viewBox')).toBe('0 0 16 16')
|
|
120
|
+
expect(svg.getAttribute('class') ?? '').toContain('size-4')
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it('renders a caret icon when icon="caret"', () => {
|
|
124
|
+
const { container } = render(<BasicNav icon="caret" />)
|
|
125
|
+
const svg = container.querySelector('[data-slot="navigation-menu-icon"] svg') as SVGElement
|
|
126
|
+
expect(svg.getAttribute('viewBox')).toBe('0 0 24 24')
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
it('renders the plus icon with two rects (so the morph animation works) when icon="plus"', () => {
|
|
130
|
+
const { container } = render(<BasicNav icon="plus" />)
|
|
131
|
+
const svg = container.querySelector('[data-slot="navigation-menu-icon"] svg') as SVGElement
|
|
132
|
+
const rects = svg.querySelectorAll('rect')
|
|
133
|
+
expect(rects).toHaveLength(2)
|
|
134
|
+
// The plus morphs into an ✕ when open: the svg rotates and the vertical bar spins.
|
|
135
|
+
expect(svg.getAttribute('class') ?? '').toContain('group-data-popup-open/navigation-menu-icon:rotate-180')
|
|
136
|
+
expect(rects[1]?.getAttribute('class') ?? '').toContain('group-data-popup-open/navigation-menu-icon:rotate-90')
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it('renders nothing for the icon when icon={false} at the root', () => {
|
|
140
|
+
const { container } = render(<BasicNav icon={false} />)
|
|
141
|
+
expect(container.querySelector('[data-slot="navigation-menu-icon"]')).toBeNull()
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('per-icon override beats the root', () => {
|
|
145
|
+
const { container } = render(
|
|
146
|
+
<NavigationMenu icon="chevron" aria-label="Main">
|
|
147
|
+
<NavigationMenuList>
|
|
148
|
+
<NavigationMenuItem>
|
|
149
|
+
<NavigationMenuTrigger>
|
|
150
|
+
Solo <NavigationMenuIcon icon={false} />
|
|
151
|
+
</NavigationMenuTrigger>
|
|
152
|
+
<NavigationMenuContent>
|
|
153
|
+
<NavigationMenuLink href="/x">X</NavigationMenuLink>
|
|
154
|
+
</NavigationMenuContent>
|
|
155
|
+
</NavigationMenuItem>
|
|
156
|
+
</NavigationMenuList>
|
|
157
|
+
</NavigationMenu>,
|
|
158
|
+
)
|
|
159
|
+
expect(container.querySelector('[data-slot="navigation-menu-icon"]')).toBeNull()
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
it('applies the smaller icon size class when size="sm"', () => {
|
|
163
|
+
const { container } = render(<BasicNav size="sm" />)
|
|
164
|
+
const svg = container.querySelector('[data-slot="navigation-menu-icon"] svg') as SVGElement
|
|
165
|
+
expect(svg.getAttribute('class') ?? '').toContain('size-3.5')
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('opens the menu on trigger click and shows the link inside the popup', async () => {
|
|
169
|
+
const user = setupUser()
|
|
170
|
+
render(<BasicNav />)
|
|
171
|
+
await user.click(screen.getByRole('button', { name: /Products/ }))
|
|
172
|
+
expect(await screen.findByRole('link', { name: 'Product One' })).toBeInTheDocument()
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
it('closes the menu on Escape', async () => {
|
|
176
|
+
const user = setupUser()
|
|
177
|
+
render(<BasicNav />)
|
|
178
|
+
await user.click(screen.getByRole('button', { name: /Products/ }))
|
|
179
|
+
await screen.findByRole('link', { name: 'Product One' })
|
|
180
|
+
await user.keyboard('{Escape}')
|
|
181
|
+
await waitFor(() => {
|
|
182
|
+
expect(screen.queryByRole('link', { name: 'Product One' })).toBeNull()
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it('moves focus between triggers with the arrow keys', async () => {
|
|
187
|
+
const user = setupUser()
|
|
188
|
+
render(<BasicNav />)
|
|
189
|
+
const products = screen.getByRole('button', { name: /Products/ })
|
|
190
|
+
products.focus()
|
|
191
|
+
expect(products).toHaveFocus()
|
|
192
|
+
await user.keyboard('{ArrowRight}')
|
|
193
|
+
expect(screen.getByRole('button', { name: /Company/ })).toHaveFocus()
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
it('renders the backdrop when backdrop={true} after opening', async () => {
|
|
197
|
+
const user = setupUser()
|
|
198
|
+
const { baseElement } = render(<BasicNav backdrop />)
|
|
199
|
+
await user.click(screen.getByRole('button', { name: /Products/ }))
|
|
200
|
+
await screen.findByRole('link', { name: 'Product One' })
|
|
201
|
+
expect(baseElement.querySelector('[data-slot="navigation-menu-backdrop"]')).not.toBeNull()
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
it('applies the popup size CSS vars by default so the popup morphs', async () => {
|
|
205
|
+
const user = setupUser()
|
|
206
|
+
const { baseElement } = render(<BasicNav />)
|
|
207
|
+
await user.click(screen.getByRole('button', { name: /Products/ }))
|
|
208
|
+
await screen.findByRole('link', { name: 'Product One' })
|
|
209
|
+
const popup = baseElement.querySelector('[data-slot="navigation-menu-popup"]') as HTMLElement
|
|
210
|
+
expect(popup.className).toContain('w-(--popup-width)')
|
|
211
|
+
expect(popup.className).toContain('h-(--popup-height)')
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
it('drops the size CSS vars and size transition when morph={false}', async () => {
|
|
215
|
+
const user = setupUser()
|
|
216
|
+
const { baseElement } = render(<BasicNav morph={false} />)
|
|
217
|
+
await user.click(screen.getByRole('button', { name: /Products/ }))
|
|
218
|
+
await screen.findByRole('link', { name: 'Product One' })
|
|
219
|
+
const popup = baseElement.querySelector('[data-slot="navigation-menu-popup"]') as HTMLElement
|
|
220
|
+
expect(popup.className).not.toContain('w-(--popup-width)')
|
|
221
|
+
expect(popup.className).not.toContain('h-(--popup-height)')
|
|
222
|
+
const positioner = baseElement.querySelector('[data-slot="navigation-menu-positioner"]') as HTMLElement
|
|
223
|
+
expect(positioner.className).not.toContain('w-(--positioner-width)')
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
it('omits the backdrop by default', async () => {
|
|
227
|
+
const user = setupUser()
|
|
228
|
+
const { baseElement } = render(<BasicNav />)
|
|
229
|
+
await user.click(screen.getByRole('button', { name: /Products/ }))
|
|
230
|
+
await screen.findByRole('link', { name: 'Product One' })
|
|
231
|
+
expect(baseElement.querySelector('[data-slot="navigation-menu-backdrop"]')).toBeNull()
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
it('skips the auto-rendered viewport when viewport={false}', async () => {
|
|
235
|
+
const user = setupUser()
|
|
236
|
+
const { baseElement } = render(<BasicNav viewport={false} />)
|
|
237
|
+
await user.click(screen.getByRole('button', { name: /Products/ }))
|
|
238
|
+
// No popup means no link from the active content appears.
|
|
239
|
+
await new Promise((resolve) => setTimeout(resolve, 100))
|
|
240
|
+
expect(baseElement.querySelector('[data-slot="navigation-menu-popup"]')).toBeNull()
|
|
241
|
+
expect(screen.queryByRole('link', { name: 'Product One' })).toBeNull()
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
it('opens the popup to inline-end when orientation is vertical', async () => {
|
|
245
|
+
const user = setupUser()
|
|
246
|
+
const { baseElement } = render(<BasicNav orientation="vertical" />)
|
|
247
|
+
await user.click(screen.getByRole('button', { name: /Products/ }))
|
|
248
|
+
await screen.findByRole('link', { name: 'Product One' })
|
|
249
|
+
const positioner = baseElement.querySelector('[data-slot="navigation-menu-popup"]')?.parentElement as HTMLElement
|
|
250
|
+
// Base UI resolves logical sides; data-side reports the physical side. In LTR vertical, inline-end == right.
|
|
251
|
+
expect(['right', 'inline-end']).toContain(positioner.getAttribute('data-side'))
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
it('has no a11y violations in the closed state', async () => {
|
|
255
|
+
const { container } = render(<BasicNav />)
|
|
256
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
257
|
+
})
|
|
258
|
+
})
|