@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,157 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { cn } from '../../utils'
|
|
3
|
+
|
|
4
|
+
type TableSize = 'sm' | 'md' | 'lg'
|
|
5
|
+
type TableBorderStyle = 'solid' | 'dashed' | 'none'
|
|
6
|
+
|
|
7
|
+
const sizeOuter: Record<TableSize, string> = {
|
|
8
|
+
sm: 'p-1 rounded-md text-xs',
|
|
9
|
+
md: 'p-1.25 rounded-lg text-sm',
|
|
10
|
+
lg: 'p-1.5 rounded-xl text-base',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const sizeCellPad: Record<TableSize, string> = {
|
|
14
|
+
sm: '[&_th]:p-3 [&_td]:p-3',
|
|
15
|
+
md: '[&_th]:p-3.5 [&_td]:p-3.5',
|
|
16
|
+
lg: '[&_th]:p-4 [&_td]:p-4',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const sizeHeaderCorners: Record<TableSize, string> = {
|
|
20
|
+
sm: '[&>thead>tr:first-child>th:first-child]:rounded-ss-sm [&>thead>tr:first-child>th:last-child]:rounded-se-sm [&>thead>tr:last-child>th:first-child]:rounded-es-sm [&>thead>tr:last-child>th:last-child]:rounded-ee-sm',
|
|
21
|
+
md: '[&>thead>tr:first-child>th:first-child]:rounded-ss-md [&>thead>tr:first-child>th:last-child]:rounded-se-md [&>thead>tr:last-child>th:first-child]:rounded-es-md [&>thead>tr:last-child>th:last-child]:rounded-ee-md',
|
|
22
|
+
lg: '[&>thead>tr:first-child>th:first-child]:rounded-ss-lg [&>thead>tr:first-child>th:last-child]:rounded-se-lg [&>thead>tr:last-child>th:first-child]:rounded-es-lg [&>thead>tr:last-child>th:last-child]:rounded-ee-lg',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const sizeBodyBottomCorners: Record<TableSize, string> = {
|
|
26
|
+
sm: '[&>tbody:last-of-type>tr:last-child>:first-child]:rounded-es-sm [&>tbody:last-of-type>tr:last-child>:last-child]:rounded-ee-sm',
|
|
27
|
+
md: '[&>tbody:last-of-type>tr:last-child>:first-child]:rounded-es-md [&>tbody:last-of-type>tr:last-child>:last-child]:rounded-ee-md',
|
|
28
|
+
lg: '[&>tbody:last-of-type>tr:last-child>:first-child]:rounded-es-lg [&>tbody:last-of-type>tr:last-child>:last-child]:rounded-ee-lg',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const sizeBodyTopCornersNoHeader: Record<TableSize, string> = {
|
|
32
|
+
sm: '[&:not(:has(thead))>tbody:first-of-type>tr:first-child>:first-child]:rounded-ss-sm [&:not(:has(thead))>tbody:first-of-type>tr:first-child>:last-child]:rounded-se-sm',
|
|
33
|
+
md: '[&:not(:has(thead))>tbody:first-of-type>tr:first-child>:first-child]:rounded-ss-md [&:not(:has(thead))>tbody:first-of-type>tr:first-child>:last-child]:rounded-se-md',
|
|
34
|
+
lg: '[&:not(:has(thead))>tbody:first-of-type>tr:first-child>:first-child]:rounded-ss-lg [&:not(:has(thead))>tbody:first-of-type>tr:first-child>:last-child]:rounded-se-lg',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const borderStyleClasses: Record<TableBorderStyle, string> = {
|
|
38
|
+
solid: '[&_td]:border-border [&>tbody_th]:border-border',
|
|
39
|
+
dashed:
|
|
40
|
+
'[&_td]:border-border-strong [&_td]:border-dashed [&>tbody_th]:border-border-strong [&>tbody_th]:border-dashed',
|
|
41
|
+
none: '[&_td]:border-b-0 [&>tbody_th]:border-b-0',
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const tableBaseClasses = cn(
|
|
45
|
+
'w-full border-separate border-spacing-0 bg-background text-foreground border border-border-muted align-middle',
|
|
46
|
+
'[&>thead>tr>th]:bg-background-muted',
|
|
47
|
+
'[&>thead>tr>th]:text-foreground-intense [&>thead>tr>th]:font-medium',
|
|
48
|
+
'[&>tbody_th]:text-foreground-intense [&>tbody_th]:font-medium [&>tbody_th]:border-b',
|
|
49
|
+
'[&_td]:align-middle [&_td]:border-b',
|
|
50
|
+
'[&>tbody:last-of-type>tr:last-child>td]:border-b-0',
|
|
51
|
+
'[&>tbody:last-of-type>tr:last-child>th]:border-b-0',
|
|
52
|
+
'[&>tbody>tr[data-highlighted]]:bg-background-subtle',
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
const stripedRowsClasses = '[&>tbody>tr:nth-child(2n)]:bg-background-subtle'
|
|
56
|
+
const stripedColumnsClasses = '[&>tbody>tr>:nth-child(2n)]:bg-background-subtle'
|
|
57
|
+
const rowHoverClasses =
|
|
58
|
+
'[&>tbody>tr]:transition-colors [&>tbody>tr]:duration-200 motion-reduce:[&>tbody>tr]:transition-none [&>tbody>tr:hover]:bg-background-subtle'
|
|
59
|
+
|
|
60
|
+
interface TableProps extends React.ComponentPropsWithoutRef<'table'> {
|
|
61
|
+
size?: TableSize
|
|
62
|
+
borderStyle?: TableBorderStyle
|
|
63
|
+
stripedRows?: boolean
|
|
64
|
+
stripedColumns?: boolean
|
|
65
|
+
hoverableRows?: boolean
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function Table({
|
|
69
|
+
size = 'md',
|
|
70
|
+
borderStyle = 'solid',
|
|
71
|
+
stripedRows = false,
|
|
72
|
+
stripedColumns = false,
|
|
73
|
+
hoverableRows = false,
|
|
74
|
+
className,
|
|
75
|
+
...props
|
|
76
|
+
}: TableProps) {
|
|
77
|
+
return (
|
|
78
|
+
<table
|
|
79
|
+
data-slot="table"
|
|
80
|
+
className={cn(
|
|
81
|
+
tableBaseClasses,
|
|
82
|
+
sizeOuter[size],
|
|
83
|
+
sizeCellPad[size],
|
|
84
|
+
sizeHeaderCorners[size],
|
|
85
|
+
sizeBodyBottomCorners[size],
|
|
86
|
+
sizeBodyTopCornersNoHeader[size],
|
|
87
|
+
borderStyleClasses[borderStyle],
|
|
88
|
+
stripedRows && stripedRowsClasses,
|
|
89
|
+
stripedColumns && stripedColumnsClasses,
|
|
90
|
+
hoverableRows && rowHoverClasses,
|
|
91
|
+
className,
|
|
92
|
+
)}
|
|
93
|
+
{...props}
|
|
94
|
+
/>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
interface TableCaptionProps extends React.ComponentPropsWithoutRef<'caption'> {
|
|
99
|
+
position?: 'top' | 'bottom'
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function TableCaption({ position = 'bottom', className, ...props }: TableCaptionProps) {
|
|
103
|
+
return (
|
|
104
|
+
<caption
|
|
105
|
+
data-slot="table-caption"
|
|
106
|
+
className={cn(
|
|
107
|
+
'text-foreground-muted',
|
|
108
|
+
position === 'top' ? 'caption-top pb-4' : 'caption-bottom pt-4',
|
|
109
|
+
className,
|
|
110
|
+
)}
|
|
111
|
+
{...props}
|
|
112
|
+
/>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface TableHeaderProps extends React.ComponentPropsWithoutRef<'thead'> {}
|
|
117
|
+
|
|
118
|
+
function TableHeader({ className, ...props }: TableHeaderProps) {
|
|
119
|
+
return <thead data-slot="table-header" className={className} {...props} />
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface TableBodyProps extends React.ComponentPropsWithoutRef<'tbody'> {}
|
|
123
|
+
|
|
124
|
+
function TableBody({ className, ...props }: TableBodyProps) {
|
|
125
|
+
return <tbody data-slot="table-body" className={className} {...props} />
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface TableRowProps extends React.ComponentPropsWithoutRef<'tr'> {
|
|
129
|
+
highlighted?: boolean
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function TableRow({ highlighted, className, ...props }: TableRowProps) {
|
|
133
|
+
return <tr data-slot="table-row" data-highlighted={highlighted ? '' : undefined} className={className} {...props} />
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface TableHeadProps extends React.ComponentPropsWithoutRef<'th'> {}
|
|
137
|
+
|
|
138
|
+
function TableHead({ className, ...props }: TableHeadProps) {
|
|
139
|
+
return <th data-slot="table-head" className={cn('text-start', className)} {...props} />
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface TableCellProps extends React.ComponentPropsWithoutRef<'td'> {}
|
|
143
|
+
|
|
144
|
+
function TableCell({ className, ...props }: TableCellProps) {
|
|
145
|
+
return <td data-slot="table-cell" className={className} {...props} />
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { Table, TableCaption, TableHeader, TableBody, TableRow, TableHead, TableCell }
|
|
149
|
+
export type {
|
|
150
|
+
TableProps,
|
|
151
|
+
TableCaptionProps,
|
|
152
|
+
TableHeaderProps,
|
|
153
|
+
TableBodyProps,
|
|
154
|
+
TableRowProps,
|
|
155
|
+
TableHeadProps,
|
|
156
|
+
TableCellProps,
|
|
157
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { render, screen } from '@testing-library/react'
|
|
3
|
+
import userEvent from '@testing-library/user-event'
|
|
4
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
5
|
+
import { axe } from 'vitest-axe'
|
|
6
|
+
import { Tabs, TabsList, TabsTrigger, TabsContent } from './tabs'
|
|
7
|
+
|
|
8
|
+
function Demo(
|
|
9
|
+
props: Omit<React.ComponentProps<typeof Tabs>, 'children'> & {
|
|
10
|
+
secondDisabled?: boolean
|
|
11
|
+
onTabClick?: (value: string) => void
|
|
12
|
+
} = {},
|
|
13
|
+
) {
|
|
14
|
+
const { secondDisabled = false, onTabClick, ...tabsProps } = props
|
|
15
|
+
return (
|
|
16
|
+
<Tabs defaultValue="one" {...tabsProps}>
|
|
17
|
+
<TabsList>
|
|
18
|
+
<TabsTrigger value="one" onClick={() => onTabClick?.('one')}>
|
|
19
|
+
One
|
|
20
|
+
</TabsTrigger>
|
|
21
|
+
<TabsTrigger value="two" disabled={secondDisabled} onClick={() => onTabClick?.('two')}>
|
|
22
|
+
Two
|
|
23
|
+
</TabsTrigger>
|
|
24
|
+
<TabsTrigger value="three" onClick={() => onTabClick?.('three')}>
|
|
25
|
+
Three
|
|
26
|
+
</TabsTrigger>
|
|
27
|
+
</TabsList>
|
|
28
|
+
<TabsContent value="one">Panel One</TabsContent>
|
|
29
|
+
<TabsContent value="two">Panel Two</TabsContent>
|
|
30
|
+
<TabsContent value="three">Panel Three</TabsContent>
|
|
31
|
+
</Tabs>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe('Tabs', () => {
|
|
36
|
+
it('renders composition with default-active panel visible', () => {
|
|
37
|
+
render(<Demo />)
|
|
38
|
+
expect(screen.getByRole('tablist')).toHaveAttribute('data-slot', 'tabs-list')
|
|
39
|
+
const triggers = screen.getAllByRole('tab')
|
|
40
|
+
expect(triggers).toHaveLength(3)
|
|
41
|
+
expect(triggers[0]).toHaveAttribute('aria-selected', 'true')
|
|
42
|
+
expect(triggers[1]).toHaveAttribute('aria-selected', 'false')
|
|
43
|
+
|
|
44
|
+
expect(screen.getByText('Panel One')).toBeVisible()
|
|
45
|
+
// Inactive panels are unmounted by default (`keepMounted` is false).
|
|
46
|
+
expect(screen.queryByText('Panel Two')).toBeNull()
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('keeps inactive panels in the DOM when keepMounted is set on TabsContent', () => {
|
|
50
|
+
render(
|
|
51
|
+
<Tabs defaultValue="one">
|
|
52
|
+
<TabsList>
|
|
53
|
+
<TabsTrigger value="one">One</TabsTrigger>
|
|
54
|
+
<TabsTrigger value="two">Two</TabsTrigger>
|
|
55
|
+
</TabsList>
|
|
56
|
+
<TabsContent value="one" keepMounted>
|
|
57
|
+
Panel One
|
|
58
|
+
</TabsContent>
|
|
59
|
+
<TabsContent value="two" keepMounted>
|
|
60
|
+
Panel Two
|
|
61
|
+
</TabsContent>
|
|
62
|
+
</Tabs>,
|
|
63
|
+
)
|
|
64
|
+
const inactive = screen.getByText('Panel Two')
|
|
65
|
+
expect(inactive).toBeInTheDocument()
|
|
66
|
+
expect(inactive).not.toBeVisible()
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('switches the active panel on click', async () => {
|
|
70
|
+
const user = userEvent.setup()
|
|
71
|
+
render(<Demo />)
|
|
72
|
+
|
|
73
|
+
await user.click(screen.getByRole('tab', { name: 'Two' }))
|
|
74
|
+
|
|
75
|
+
expect(screen.getByRole('tab', { name: 'Two' })).toHaveAttribute('aria-selected', 'true')
|
|
76
|
+
expect(screen.getByRole('tab', { name: 'One' })).toHaveAttribute('aria-selected', 'false')
|
|
77
|
+
expect(screen.getByText('Panel Two')).toBeVisible()
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('honours defaultValue', () => {
|
|
81
|
+
render(<Demo defaultValue="three" />)
|
|
82
|
+
expect(screen.getByRole('tab', { name: 'Three' })).toHaveAttribute('aria-selected', 'true')
|
|
83
|
+
expect(screen.getByText('Panel Three')).toBeVisible()
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('supports controlled mode', async () => {
|
|
87
|
+
const user = userEvent.setup()
|
|
88
|
+
const onValueChange = vi.fn()
|
|
89
|
+
|
|
90
|
+
function Controlled() {
|
|
91
|
+
const [value, setValue] = React.useState<string>('one')
|
|
92
|
+
return (
|
|
93
|
+
<Demo
|
|
94
|
+
value={value}
|
|
95
|
+
onValueChange={(next, details) => {
|
|
96
|
+
onValueChange(next)
|
|
97
|
+
setValue(next as string)
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
render(<Controlled />)
|
|
104
|
+
expect(screen.getByRole('tab', { name: 'One' })).toHaveAttribute('aria-selected', 'true')
|
|
105
|
+
|
|
106
|
+
await user.click(screen.getByRole('tab', { name: 'Two' }))
|
|
107
|
+
expect(onValueChange).toHaveBeenCalledWith('two')
|
|
108
|
+
expect(screen.getByRole('tab', { name: 'Two' })).toHaveAttribute('aria-selected', 'true')
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('navigates horizontally via Arrow keys and activates on Enter', async () => {
|
|
112
|
+
const user = userEvent.setup()
|
|
113
|
+
render(<Demo />)
|
|
114
|
+
|
|
115
|
+
const first = screen.getByRole('tab', { name: 'One' })
|
|
116
|
+
first.focus()
|
|
117
|
+
|
|
118
|
+
await user.keyboard('{ArrowRight}')
|
|
119
|
+
expect(screen.getByRole('tab', { name: 'Two' })).toHaveFocus()
|
|
120
|
+
|
|
121
|
+
await user.keyboard('{Enter}')
|
|
122
|
+
expect(screen.getByRole('tab', { name: 'Two' })).toHaveAttribute('aria-selected', 'true')
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('navigates vertically via ArrowDown when orientation="vertical"', async () => {
|
|
126
|
+
const user = userEvent.setup()
|
|
127
|
+
render(<Demo orientation="vertical" />)
|
|
128
|
+
|
|
129
|
+
expect(screen.getByRole('tablist')).toHaveAttribute('aria-orientation', 'vertical')
|
|
130
|
+
|
|
131
|
+
const first = screen.getByRole('tab', { name: 'One' })
|
|
132
|
+
first.focus()
|
|
133
|
+
await user.keyboard('{ArrowDown}')
|
|
134
|
+
expect(screen.getByRole('tab', { name: 'Two' })).toHaveFocus()
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('does not activate disabled triggers on click', async () => {
|
|
138
|
+
const user = userEvent.setup()
|
|
139
|
+
const onTabClick = vi.fn()
|
|
140
|
+
render(<Demo secondDisabled onTabClick={onTabClick} />)
|
|
141
|
+
|
|
142
|
+
await user.click(screen.getByRole('tab', { name: 'Two' }))
|
|
143
|
+
expect(onTabClick).not.toHaveBeenCalled()
|
|
144
|
+
expect(screen.getByRole('tab', { name: 'One' })).toHaveAttribute('aria-selected', 'true')
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it('applies data-slot attributes on each sub-component', () => {
|
|
148
|
+
render(<Demo />)
|
|
149
|
+
expect(screen.getByRole('tablist').closest('[data-slot="tabs"]')).not.toBeNull()
|
|
150
|
+
expect(screen.getByRole('tablist')).toHaveAttribute('data-slot', 'tabs-list')
|
|
151
|
+
expect(screen.getAllByRole('tab')[0]).toHaveAttribute('data-slot', 'tabs-trigger')
|
|
152
|
+
expect(screen.getByText('Panel One').closest('[data-slot="tabs-content"]')).not.toBeNull()
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
it('throws when a sub-component is rendered outside <Tabs>', () => {
|
|
156
|
+
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
|
157
|
+
expect(() => render(<TabsTrigger value="x">x</TabsTrigger>)).toThrow(/must be rendered inside <Tabs>/)
|
|
158
|
+
spy.mockRestore()
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
it('has no accessibility violations', async () => {
|
|
162
|
+
const { container } = render(<Demo />)
|
|
163
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
164
|
+
})
|
|
165
|
+
})
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { Tabs as BaseTabs } from '@base-ui/react/tabs'
|
|
5
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
6
|
+
import { cn } from '../../utils'
|
|
7
|
+
|
|
8
|
+
type TabsVariant = 'pill' | 'line'
|
|
9
|
+
type TabsSize = 'sm' | 'md' | 'lg'
|
|
10
|
+
type TabsTriggerSize = TabsSize | 'icon-sm' | 'icon-md' | 'icon-lg'
|
|
11
|
+
type TabsOrientation = 'horizontal' | 'vertical'
|
|
12
|
+
|
|
13
|
+
interface TabsContextValue {
|
|
14
|
+
variant: TabsVariant
|
|
15
|
+
size: TabsSize
|
|
16
|
+
orientation: TabsOrientation
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const TabsContext = React.createContext<TabsContextValue | null>(null)
|
|
20
|
+
|
|
21
|
+
function useTabsContext() {
|
|
22
|
+
const ctx = React.useContext(TabsContext)
|
|
23
|
+
if (!ctx) {
|
|
24
|
+
throw new Error('Tabs sub-components must be rendered inside <Tabs>')
|
|
25
|
+
}
|
|
26
|
+
return ctx
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const tabsListVariants = cva(
|
|
30
|
+
'relative flex w-fit items-center justify-center data-[orientation=vertical]:h-fit data-[orientation=vertical]:flex-col',
|
|
31
|
+
{
|
|
32
|
+
variants: {
|
|
33
|
+
variant: {
|
|
34
|
+
pill: 'gap-0.5 p-0.5 bg-background-muted',
|
|
35
|
+
line: '',
|
|
36
|
+
},
|
|
37
|
+
size: {
|
|
38
|
+
sm: 'data-[orientation=vertical]:min-w-32',
|
|
39
|
+
md: 'data-[orientation=vertical]:min-w-36',
|
|
40
|
+
lg: 'data-[orientation=vertical]:min-w-40',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
compoundVariants: [
|
|
44
|
+
{ variant: 'pill', size: 'sm', class: 'rounded-sm' },
|
|
45
|
+
{ variant: 'pill', size: 'md', class: 'rounded-md' },
|
|
46
|
+
{ variant: 'pill', size: 'lg', class: 'rounded-lg' },
|
|
47
|
+
{ variant: 'line', size: 'sm', class: 'data-[orientation=horizontal]:gap-5' },
|
|
48
|
+
{ variant: 'line', size: 'md', class: 'data-[orientation=horizontal]:gap-6' },
|
|
49
|
+
{ variant: 'line', size: 'lg', class: 'data-[orientation=horizontal]:gap-7' },
|
|
50
|
+
],
|
|
51
|
+
defaultVariants: { variant: 'pill', size: 'md' },
|
|
52
|
+
},
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
const tabsIndicatorVariants = cva(
|
|
56
|
+
'absolute z-0 inset-s-0 transition-[translate,width,height] duration-250 motion-reduce:transition-none data-[orientation=horizontal]:ltr:translate-x-(--active-tab-left) data-[orientation=horizontal]:rtl:-translate-x-(--active-tab-right) data-[orientation=vertical]:translate-y-(--active-tab-top)',
|
|
57
|
+
{
|
|
58
|
+
variants: {
|
|
59
|
+
variant: {
|
|
60
|
+
pill: 'w-(--active-tab-width) data-[orientation=horizontal]:top-0.5 data-[orientation=horizontal]:h-[calc(100%-0.25rem)] data-[orientation=vertical]:top-0 data-[orientation=vertical]:bottom-(--active-tab-bottom) data-[orientation=vertical]:inset-s-0.5 data-[orientation=vertical]:h-(--active-tab-height) rounded-[inherit] bg-white shadow-lg',
|
|
61
|
+
line: cn(
|
|
62
|
+
'rounded-full bg-foreground-intense',
|
|
63
|
+
'data-[orientation=horizontal]:bottom-0 data-[orientation=horizontal]:h-0.5 data-[orientation=horizontal]:w-(--active-tab-width)',
|
|
64
|
+
'data-[orientation=vertical]:top-[calc(var(--active-tab-height)/4)] data-[orientation=vertical]:h-[calc(var(--active-tab-height)/2)] data-[orientation=vertical]:w-0.5',
|
|
65
|
+
),
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
defaultVariants: { variant: 'pill' },
|
|
69
|
+
},
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
const tabsTriggerVariants = cva(
|
|
73
|
+
"group/trigger relative flex shrink-0 cursor-pointer items-stretch data-[orientation=vertical]:w-full text-foreground-strong font-medium select-none outline-ring transition-colors duration-250 motion-reduce:transition-none hover:text-foreground-intense data-active:pointer-events-none data-disabled:opacity-disabled data-disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='stroke-'])]:stroke-[1.85]",
|
|
74
|
+
{
|
|
75
|
+
variants: {
|
|
76
|
+
variant: {
|
|
77
|
+
pill: 'data-active:text-black',
|
|
78
|
+
line: 'data-active:text-foreground-intense',
|
|
79
|
+
},
|
|
80
|
+
size: {
|
|
81
|
+
sm: "text-xs [&_svg:not([class*='size-'])]:size-4",
|
|
82
|
+
md: "text-sm [&_svg:not([class*='size-'])]:size-4.5",
|
|
83
|
+
lg: "text-base [&_svg:not([class*='size-'])]:size-5",
|
|
84
|
+
'icon-sm': "text-xs [&_svg:not([class*='size-'])]:size-4",
|
|
85
|
+
'icon-md': "text-sm [&_svg:not([class*='size-'])]:size-4.5",
|
|
86
|
+
'icon-lg': "text-base [&_svg:not([class*='size-'])]:size-5",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
compoundVariants: [
|
|
90
|
+
{ variant: 'pill', size: 'sm', class: 'rounded-sm' },
|
|
91
|
+
{ variant: 'pill', size: 'md', class: 'rounded-md' },
|
|
92
|
+
{ variant: 'pill', size: 'lg', class: 'rounded-lg' },
|
|
93
|
+
{ variant: 'pill', size: 'icon-sm', class: 'rounded-sm' },
|
|
94
|
+
{ variant: 'pill', size: 'icon-md', class: 'rounded-md' },
|
|
95
|
+
{ variant: 'pill', size: 'icon-lg', class: 'rounded-lg' },
|
|
96
|
+
],
|
|
97
|
+
defaultVariants: { variant: 'pill', size: 'md' },
|
|
98
|
+
},
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
const tabsTriggerInnerVariants = cva(
|
|
102
|
+
'relative isolate flex items-center data-[orientation=horizontal]:justify-center data-[orientation=vertical]:w-full data-[orientation=horizontal]:text-center data-[orientation=vertical]:text-start data-[orientation=horizontal]:whitespace-nowrap transform-gpu transition-transform duration-250 ease-[cubic-bezier(0.175,0.885,0.32,1.5)] motion-reduce:transition-none group-active/trigger:scale-[0.97] group-active/trigger:duration-100 group-active/trigger:ease-in-out group-active/trigger:translate-y-px',
|
|
103
|
+
{
|
|
104
|
+
variants: {
|
|
105
|
+
variant: {
|
|
106
|
+
pill: 'before:absolute before:inset-0 before:-z-1 before:rounded-[inherit] before:pointer-events-none before:transition-colors before:duration-250 group-hover/trigger:before:bg-background-subtle motion-reduce:before:transition-none supports-[font:-apple-system-body]:before:hidden',
|
|
107
|
+
line: '',
|
|
108
|
+
},
|
|
109
|
+
size: {
|
|
110
|
+
sm: 'gap-1 py-2',
|
|
111
|
+
md: 'gap-1.5 py-2.5',
|
|
112
|
+
lg: 'gap-1.5 py-3',
|
|
113
|
+
'icon-sm': 'size-8',
|
|
114
|
+
'icon-md': 'size-10',
|
|
115
|
+
'icon-lg': 'size-12',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
compoundVariants: [
|
|
119
|
+
{
|
|
120
|
+
variant: 'pill',
|
|
121
|
+
size: 'sm',
|
|
122
|
+
class: 'rounded-sm px-3.5 has-data-[icon=end]:pe-2.5 has-data-[icon=start]:ps-2.5',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
variant: 'pill',
|
|
126
|
+
size: 'md',
|
|
127
|
+
class: 'rounded-md px-4.5 has-data-[icon=end]:pe-3 has-data-[icon=start]:ps-3',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
variant: 'pill',
|
|
131
|
+
size: 'lg',
|
|
132
|
+
class: 'rounded-lg px-5.5 has-data-[icon=end]:pe-4 has-data-[icon=start]:ps-4',
|
|
133
|
+
},
|
|
134
|
+
{ variant: 'pill', size: 'icon-sm', class: 'rounded-sm' },
|
|
135
|
+
{ variant: 'pill', size: 'icon-md', class: 'rounded-md' },
|
|
136
|
+
{ variant: 'pill', size: 'icon-lg', class: 'rounded-lg' },
|
|
137
|
+
{
|
|
138
|
+
variant: 'line',
|
|
139
|
+
size: 'sm',
|
|
140
|
+
class:
|
|
141
|
+
'data-[orientation=vertical]:ps-3 data-[orientation=vertical]:has-data-[icon=end]:pe-2 data-[orientation=vertical]:has-data-[icon=start]:ps-2',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
variant: 'line',
|
|
145
|
+
size: 'md',
|
|
146
|
+
class:
|
|
147
|
+
'data-[orientation=vertical]:ps-4 data-[orientation=vertical]:has-data-[icon=end]:pe-3 data-[orientation=vertical]:has-data-[icon=start]:ps-3',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
variant: 'line',
|
|
151
|
+
size: 'lg',
|
|
152
|
+
class:
|
|
153
|
+
'data-[orientation=vertical]:ps-5 data-[orientation=vertical]:has-data-[icon=end]:pe-4 data-[orientation=vertical]:has-data-[icon=start]:ps-4',
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
defaultVariants: { variant: 'pill', size: 'md' },
|
|
157
|
+
},
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
const tabsContentClasses =
|
|
161
|
+
'outline-none transition-[opacity,filter] duration-400 ease-out motion-reduce:transition-none data-[starting-style]:opacity-0 data-[ending-style]:hidden'
|
|
162
|
+
|
|
163
|
+
type BaseTabsRootProps = React.ComponentProps<typeof BaseTabs.Root>
|
|
164
|
+
|
|
165
|
+
interface TabsProps extends BaseTabsRootProps {
|
|
166
|
+
variant?: TabsVariant
|
|
167
|
+
size?: TabsSize
|
|
168
|
+
orientation?: TabsOrientation
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function Tabs({ variant = 'pill', size = 'md', orientation = 'horizontal', className, ...rest }: TabsProps) {
|
|
172
|
+
const ctx = React.useMemo<TabsContextValue>(() => ({ variant, size, orientation }), [variant, size, orientation])
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<TabsContext value={ctx}>
|
|
176
|
+
<BaseTabs.Root
|
|
177
|
+
data-slot="tabs"
|
|
178
|
+
orientation={orientation}
|
|
179
|
+
className={cn('flex gap-6 data-[orientation=horizontal]:flex-col', className)}
|
|
180
|
+
{...rest}
|
|
181
|
+
/>
|
|
182
|
+
</TabsContext>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
type BaseTabsListProps = React.ComponentProps<typeof BaseTabs.List>
|
|
187
|
+
|
|
188
|
+
interface TabsListProps extends BaseTabsListProps, VariantProps<typeof tabsListVariants> {}
|
|
189
|
+
|
|
190
|
+
function TabsList({ variant: variantProp, size: sizeProp, className, children, ...rest }: TabsListProps) {
|
|
191
|
+
const ctx = useTabsContext()
|
|
192
|
+
const variant = variantProp ?? ctx.variant
|
|
193
|
+
const size = sizeProp ?? ctx.size
|
|
194
|
+
|
|
195
|
+
const listCtx = React.useMemo<TabsContextValue>(
|
|
196
|
+
() => ({ variant, size, orientation: ctx.orientation }),
|
|
197
|
+
[variant, size, ctx.orientation],
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<BaseTabs.List data-slot="tabs-list" className={cn(tabsListVariants({ variant, size }), className)} {...rest}>
|
|
202
|
+
<BaseTabs.Indicator
|
|
203
|
+
renderBeforeHydration
|
|
204
|
+
data-slot="tabs-indicator"
|
|
205
|
+
className={tabsIndicatorVariants({ variant })}
|
|
206
|
+
/>
|
|
207
|
+
<TabsContext value={listCtx}>{children}</TabsContext>
|
|
208
|
+
</BaseTabs.List>
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
type BaseTabsTabProps = React.ComponentProps<typeof BaseTabs.Tab>
|
|
213
|
+
|
|
214
|
+
interface TabsTriggerProps extends BaseTabsTabProps {
|
|
215
|
+
variant?: TabsVariant
|
|
216
|
+
size?: TabsTriggerSize
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function TabsTrigger({ variant: variantProp, size: sizeProp, className, children, ...rest }: TabsTriggerProps) {
|
|
220
|
+
const ctx = useTabsContext()
|
|
221
|
+
const variant = variantProp ?? ctx.variant
|
|
222
|
+
const size = sizeProp ?? ctx.size
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<BaseTabs.Tab data-slot="tabs-trigger" className={cn(tabsTriggerVariants({ variant, size }), className)} {...rest}>
|
|
226
|
+
<span
|
|
227
|
+
data-slot="tabs-trigger-inner"
|
|
228
|
+
data-orientation={ctx.orientation}
|
|
229
|
+
className={tabsTriggerInnerVariants({ variant, size })}
|
|
230
|
+
>
|
|
231
|
+
{children}
|
|
232
|
+
</span>
|
|
233
|
+
</BaseTabs.Tab>
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
type BaseTabsPanelProps = React.ComponentProps<typeof BaseTabs.Panel>
|
|
238
|
+
|
|
239
|
+
interface TabsContentProps extends BaseTabsPanelProps {}
|
|
240
|
+
|
|
241
|
+
function TabsContent({ className, ...rest }: TabsContentProps) {
|
|
242
|
+
return <BaseTabs.Panel data-slot="tabs-content" className={cn(tabsContentClasses, className)} {...rest} />
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
|
246
|
+
export type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps }
|