@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,310 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { NumberField as BaseNumberField, type NumberFieldRoot } from '@base-ui/react/number-field'
|
|
5
|
+
import { type VariantProps } from 'class-variance-authority'
|
|
6
|
+
import { AnimatePresence, LazyMotion, domAnimation, m } from 'motion/react'
|
|
7
|
+
import { cn } from '../../utils'
|
|
8
|
+
import { useReducedMotion } from '../../hooks/use-reduced-motion'
|
|
9
|
+
import { buttonVariants } from '../button/button-variants'
|
|
10
|
+
import { inputVariants } from '../input/input-variants'
|
|
11
|
+
|
|
12
|
+
type NumberFieldVariant = NonNullable<VariantProps<typeof inputVariants>['variant']>
|
|
13
|
+
type NumberFieldSize = NonNullable<VariantProps<typeof inputVariants>['size']>
|
|
14
|
+
type AnimDirection = 'up' | 'down'
|
|
15
|
+
|
|
16
|
+
const numberFieldWidth: Record<NumberFieldSize, string> = {
|
|
17
|
+
sm: 'w-24',
|
|
18
|
+
md: 'w-30',
|
|
19
|
+
lg: 'w-35',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const stepperSize: Record<NumberFieldSize, { size: 'icon-sm' | 'icon-md' | 'icon-lg'; override: string }> = {
|
|
23
|
+
sm: { size: 'icon-sm', override: 'size-7 rounded-xs [&_svg]:size-3.5!' },
|
|
24
|
+
md: { size: 'icon-md', override: 'size-9 rounded-sm [&_svg]:size-4!' },
|
|
25
|
+
lg: { size: 'icon-lg', override: 'size-11 rounded-md [&_svg]:size-4.5!' },
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const stepperButtonVariant: Record<NumberFieldVariant, 'soft' | 'outline'> = {
|
|
29
|
+
outline: 'soft',
|
|
30
|
+
soft: 'outline',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const inputSizeClasses: Record<NumberFieldSize, string> = {
|
|
34
|
+
sm: 'text-xs pointer-coarse:text-base',
|
|
35
|
+
md: 'text-sm pointer-coarse:text-base',
|
|
36
|
+
lg: 'text-base',
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const digitVariants = {
|
|
40
|
+
enter: (dir: AnimDirection) => ({
|
|
41
|
+
y: dir === 'up' ? '100%' : '-100%',
|
|
42
|
+
opacity: 0,
|
|
43
|
+
}),
|
|
44
|
+
center: { y: '0%', opacity: 1 },
|
|
45
|
+
exit: (dir: AnimDirection) => ({
|
|
46
|
+
y: dir === 'up' ? '-100%' : '100%',
|
|
47
|
+
opacity: 0,
|
|
48
|
+
}),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const DIGIT_TRANSITION = { duration: 0.22, ease: [0.4, 0, 0.2, 1] satisfies [number, number, number, number] }
|
|
52
|
+
|
|
53
|
+
function AnimatedDigit({ char, direction }: { char: string; direction: AnimDirection }) {
|
|
54
|
+
return (
|
|
55
|
+
<span className="relative inline-block overflow-hidden">
|
|
56
|
+
<AnimatePresence custom={direction} mode="popLayout" initial={false}>
|
|
57
|
+
<m.span
|
|
58
|
+
key={char}
|
|
59
|
+
custom={direction}
|
|
60
|
+
variants={digitVariants}
|
|
61
|
+
initial="enter"
|
|
62
|
+
animate="center"
|
|
63
|
+
exit="exit"
|
|
64
|
+
transition={DIGIT_TRANSITION}
|
|
65
|
+
className="inline-block"
|
|
66
|
+
>
|
|
67
|
+
{char}
|
|
68
|
+
</m.span>
|
|
69
|
+
</AnimatePresence>
|
|
70
|
+
</span>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function AnimatedNumber({ value, direction }: { value: string; direction: AnimDirection }) {
|
|
75
|
+
const chars = React.useMemo(() => Array.from(value), [value])
|
|
76
|
+
return (
|
|
77
|
+
<span className="inline-flex leading-none">
|
|
78
|
+
{chars.map((ch, i) => {
|
|
79
|
+
const fromRight = chars.length - 1 - i
|
|
80
|
+
return <AnimatedDigit key={`r${fromRight}`} char={ch} direction={direction} />
|
|
81
|
+
})}
|
|
82
|
+
</span>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface NumberFieldProps extends Omit<React.ComponentProps<typeof BaseNumberField.Root>, 'className'> {
|
|
87
|
+
variant?: NumberFieldVariant
|
|
88
|
+
size?: NumberFieldSize
|
|
89
|
+
className?: string
|
|
90
|
+
placeholder?: string
|
|
91
|
+
inputProps?: React.ComponentProps<typeof BaseNumberField.Input>
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function NumberField({
|
|
95
|
+
className,
|
|
96
|
+
variant = 'outline',
|
|
97
|
+
size = 'md',
|
|
98
|
+
onValueChange,
|
|
99
|
+
onValueCommitted,
|
|
100
|
+
format,
|
|
101
|
+
locale,
|
|
102
|
+
value: controlledValue,
|
|
103
|
+
defaultValue,
|
|
104
|
+
min,
|
|
105
|
+
placeholder = ' ',
|
|
106
|
+
inputProps,
|
|
107
|
+
...rootProps
|
|
108
|
+
}: NumberFieldProps) {
|
|
109
|
+
const resolvedVariant: NumberFieldVariant = variant
|
|
110
|
+
const resolvedSize: NumberFieldSize = size
|
|
111
|
+
const stepperVariant = stepperButtonVariant[resolvedVariant]
|
|
112
|
+
const { size: stepperBtnSize, override: stepperOverride } = stepperSize[resolvedSize]
|
|
113
|
+
const stepperClass = cn(buttonVariants({ variant: stepperVariant, size: stepperBtnSize }), stepperOverride)
|
|
114
|
+
|
|
115
|
+
const ariaInvalid = rootProps['aria-invalid']
|
|
116
|
+
const invalid = ariaInvalid === true || ariaInvalid === 'true'
|
|
117
|
+
|
|
118
|
+
const reduced = useReducedMotion()
|
|
119
|
+
|
|
120
|
+
const formatter = React.useMemo(() => {
|
|
121
|
+
try {
|
|
122
|
+
return new Intl.NumberFormat(locale, format)
|
|
123
|
+
} catch {
|
|
124
|
+
return new Intl.NumberFormat()
|
|
125
|
+
}
|
|
126
|
+
}, [locale, format])
|
|
127
|
+
|
|
128
|
+
const formatValue = React.useCallback(
|
|
129
|
+
(value: number | null | undefined) => (value == null || Number.isNaN(value) ? '' : formatter.format(value)),
|
|
130
|
+
[formatter],
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
const isControlled = controlledValue !== undefined
|
|
134
|
+
const [internalValue, setInternalValue] = React.useState<number | null>(defaultValue ?? null)
|
|
135
|
+
const currentValue = isControlled ? controlledValue : internalValue
|
|
136
|
+
|
|
137
|
+
const [state, setState] = React.useState<{ value: string; direction: AnimDirection }>(() => ({
|
|
138
|
+
value: formatValue(controlledValue ?? defaultValue ?? null),
|
|
139
|
+
direction: 'up',
|
|
140
|
+
}))
|
|
141
|
+
|
|
142
|
+
const [prevValue, setPrevValue] = React.useState<number | null | undefined>(currentValue)
|
|
143
|
+
if (prevValue !== currentValue) {
|
|
144
|
+
setPrevValue(currentValue)
|
|
145
|
+
const next = formatValue(currentValue)
|
|
146
|
+
setState((prev) => (prev.value === next ? prev : { ...prev, value: next }))
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const handleValueChange: NonNullable<typeof onValueChange> = (value, details) => {
|
|
150
|
+
if (!isControlled) setInternalValue(value)
|
|
151
|
+
setState((prev) => ({
|
|
152
|
+
value: formatValue(value),
|
|
153
|
+
direction:
|
|
154
|
+
details.reason === 'decrement-press' ? 'down' : details.reason === 'increment-press' ? 'up' : prev.direction,
|
|
155
|
+
}))
|
|
156
|
+
onValueChange?.(value, details)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const handleValueCommitted: NonNullable<typeof onValueCommitted> = (value, details) => {
|
|
160
|
+
onValueCommitted?.(value, details)
|
|
161
|
+
if (value != null) return
|
|
162
|
+
const fallback = min ?? 0
|
|
163
|
+
if (!isControlled) setInternalValue(fallback)
|
|
164
|
+
setState((prev) => ({ ...prev, value: formatValue(fallback) }))
|
|
165
|
+
const syntheticDetails: NumberFieldRoot.ChangeEventDetails = {
|
|
166
|
+
reason: 'none',
|
|
167
|
+
event: details.event,
|
|
168
|
+
cancel: () => {},
|
|
169
|
+
allowPropagation: () => {},
|
|
170
|
+
isCanceled: false,
|
|
171
|
+
isPropagationAllowed: false,
|
|
172
|
+
trigger: undefined,
|
|
173
|
+
}
|
|
174
|
+
onValueChange?.(fallback, syntheticDetails)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const [isFocused, setIsFocused] = React.useState(false)
|
|
178
|
+
const suppressFocusRef = React.useRef(false)
|
|
179
|
+
|
|
180
|
+
const handleStepperPointerDown = () => {
|
|
181
|
+
suppressFocusRef.current = true
|
|
182
|
+
setIsFocused(false)
|
|
183
|
+
setTimeout(() => {
|
|
184
|
+
suppressFocusRef.current = false
|
|
185
|
+
}, 0)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const handleInputPointerDown = () => setIsFocused(true)
|
|
189
|
+
const handleInputFocus = () => {
|
|
190
|
+
if (suppressFocusRef.current) return
|
|
191
|
+
setIsFocused(true)
|
|
192
|
+
}
|
|
193
|
+
const handleInputBlur = () => setIsFocused(false)
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<BaseNumberField.Root
|
|
197
|
+
data-slot="number-field"
|
|
198
|
+
className={cn(
|
|
199
|
+
inputVariants({ variant: resolvedVariant, size: resolvedSize, state: 'within' }),
|
|
200
|
+
'h-auto shrink-0 p-px',
|
|
201
|
+
numberFieldWidth[resolvedSize],
|
|
202
|
+
className,
|
|
203
|
+
)}
|
|
204
|
+
onValueChange={handleValueChange}
|
|
205
|
+
onValueCommitted={handleValueCommitted}
|
|
206
|
+
format={format}
|
|
207
|
+
locale={locale}
|
|
208
|
+
min={min}
|
|
209
|
+
value={currentValue}
|
|
210
|
+
{...rootProps}
|
|
211
|
+
{...(invalid ? { 'data-invalid': '' } : {})}
|
|
212
|
+
>
|
|
213
|
+
<BaseNumberField.Decrement
|
|
214
|
+
data-slot="number-field-decrement"
|
|
215
|
+
aria-label="Decrease value"
|
|
216
|
+
className={stepperClass}
|
|
217
|
+
onPointerDown={handleStepperPointerDown}
|
|
218
|
+
>
|
|
219
|
+
<MinusIcon />
|
|
220
|
+
</BaseNumberField.Decrement>
|
|
221
|
+
|
|
222
|
+
<LazyMotion features={domAnimation} strict>
|
|
223
|
+
<div className="relative flex-1 self-stretch overflow-hidden">
|
|
224
|
+
<BaseNumberField.Input
|
|
225
|
+
data-slot="number-field-input"
|
|
226
|
+
placeholder={placeholder}
|
|
227
|
+
{...inputProps}
|
|
228
|
+
onPointerDown={(e) => {
|
|
229
|
+
inputProps?.onPointerDown?.(e)
|
|
230
|
+
handleInputPointerDown()
|
|
231
|
+
}}
|
|
232
|
+
onFocus={(e) => {
|
|
233
|
+
inputProps?.onFocus?.(e)
|
|
234
|
+
handleInputFocus()
|
|
235
|
+
}}
|
|
236
|
+
onBlur={(e) => {
|
|
237
|
+
inputProps?.onBlur?.(e)
|
|
238
|
+
handleInputBlur()
|
|
239
|
+
}}
|
|
240
|
+
className={cn(
|
|
241
|
+
'peer text-foreground absolute inset-0 h-full w-full bg-transparent text-center outline-none',
|
|
242
|
+
inputSizeClasses[resolvedSize],
|
|
243
|
+
!reduced &&
|
|
244
|
+
!isFocused &&
|
|
245
|
+
'not-placeholder-shown:text-transparent not-placeholder-shown:caret-transparent',
|
|
246
|
+
inputProps?.className,
|
|
247
|
+
)}
|
|
248
|
+
/>
|
|
249
|
+
{!reduced && (
|
|
250
|
+
<div
|
|
251
|
+
data-slot="number-field-overlay"
|
|
252
|
+
aria-hidden="true"
|
|
253
|
+
className={cn(
|
|
254
|
+
'text-foreground pointer-events-none absolute inset-0 z-10 flex items-center justify-center peer-placeholder-shown:invisible',
|
|
255
|
+
isFocused && 'invisible',
|
|
256
|
+
inputSizeClasses[resolvedSize],
|
|
257
|
+
)}
|
|
258
|
+
>
|
|
259
|
+
<AnimatedNumber value={state.value} direction={state.direction} />
|
|
260
|
+
</div>
|
|
261
|
+
)}
|
|
262
|
+
</div>
|
|
263
|
+
</LazyMotion>
|
|
264
|
+
|
|
265
|
+
<BaseNumberField.Increment
|
|
266
|
+
data-slot="number-field-increment"
|
|
267
|
+
aria-label="Increase value"
|
|
268
|
+
className={stepperClass}
|
|
269
|
+
onPointerDown={handleStepperPointerDown}
|
|
270
|
+
>
|
|
271
|
+
<PlusIcon />
|
|
272
|
+
</BaseNumberField.Increment>
|
|
273
|
+
</BaseNumberField.Root>
|
|
274
|
+
)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function MinusIcon() {
|
|
278
|
+
return (
|
|
279
|
+
<svg
|
|
280
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
281
|
+
viewBox="0 0 24 24"
|
|
282
|
+
fill="none"
|
|
283
|
+
stroke="currentColor"
|
|
284
|
+
strokeLinecap="round"
|
|
285
|
+
strokeLinejoin="round"
|
|
286
|
+
aria-hidden="true"
|
|
287
|
+
>
|
|
288
|
+
<path d="M5 12h14" />
|
|
289
|
+
</svg>
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function PlusIcon() {
|
|
294
|
+
return (
|
|
295
|
+
<svg
|
|
296
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
297
|
+
viewBox="0 0 24 24"
|
|
298
|
+
fill="none"
|
|
299
|
+
stroke="currentColor"
|
|
300
|
+
strokeLinecap="round"
|
|
301
|
+
strokeLinejoin="round"
|
|
302
|
+
aria-hidden="true"
|
|
303
|
+
>
|
|
304
|
+
<path d="M12 5v14M5 12h14" />
|
|
305
|
+
</svg>
|
|
306
|
+
)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export { NumberField }
|
|
310
|
+
export type { NumberFieldProps }
|
|
@@ -0,0 +1,113 @@
|
|
|
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 { OTPField, OTPFieldInput, OTPFieldSeparator } from './otp-field'
|
|
7
|
+
|
|
8
|
+
const LENGTH = 4
|
|
9
|
+
|
|
10
|
+
function renderField(props: Partial<React.ComponentProps<typeof OTPField>> = {}) {
|
|
11
|
+
return render(
|
|
12
|
+
<OTPField length={LENGTH} aria-label="Verification code" {...props}>
|
|
13
|
+
{Array.from({ length: LENGTH }, (_, index) => (
|
|
14
|
+
<OTPFieldInput key={index} aria-label={`Character ${index + 1} of ${LENGTH}`} />
|
|
15
|
+
))}
|
|
16
|
+
</OTPField>,
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe('OTPField', () => {
|
|
21
|
+
it('renders the requested number of input slots', () => {
|
|
22
|
+
renderField()
|
|
23
|
+
expect(screen.getAllByRole('textbox')).toHaveLength(LENGTH)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('accepts user typing across slots and updates the value', async () => {
|
|
27
|
+
const user = userEvent.setup()
|
|
28
|
+
const onValueChange = vi.fn()
|
|
29
|
+
renderField({ onValueChange })
|
|
30
|
+
|
|
31
|
+
screen.getAllByRole('textbox')[0]!.focus()
|
|
32
|
+
await user.keyboard('1234')
|
|
33
|
+
|
|
34
|
+
expect(onValueChange).toHaveBeenLastCalledWith('1234', expect.objectContaining({ reason: expect.any(String) }))
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('fires onValueComplete when all slots are filled', async () => {
|
|
38
|
+
const user = userEvent.setup()
|
|
39
|
+
const onValueComplete = vi.fn()
|
|
40
|
+
renderField({ onValueComplete })
|
|
41
|
+
|
|
42
|
+
screen.getAllByRole('textbox')[0]!.focus()
|
|
43
|
+
await user.keyboard('9876')
|
|
44
|
+
|
|
45
|
+
expect(onValueComplete).toHaveBeenCalledWith('9876', expect.any(Object))
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('disables every slot when disabled', () => {
|
|
49
|
+
renderField({ disabled: true })
|
|
50
|
+
for (const input of screen.getAllByRole('textbox')) {
|
|
51
|
+
expect(input).toBeDisabled()
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('applies the size class to inputs', () => {
|
|
56
|
+
renderField({ size: 'lg' })
|
|
57
|
+
const first = screen.getAllByRole('textbox')[0]!
|
|
58
|
+
expect(first.className).toContain('h-12')
|
|
59
|
+
expect(first.className).toContain('w-12')
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('applies the variant class to inputs', () => {
|
|
63
|
+
renderField({ variant: 'soft' })
|
|
64
|
+
expect(screen.getAllByRole('textbox')[0]!.className).toContain('bg-background-muted')
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('bridges a standalone aria-invalid to data-invalid on the input', () => {
|
|
68
|
+
render(
|
|
69
|
+
<OTPField>
|
|
70
|
+
<OTPFieldInput aria-label="Character 1 of 1" aria-invalid />
|
|
71
|
+
</OTPField>,
|
|
72
|
+
)
|
|
73
|
+
const input = screen.getAllByRole('textbox')[0]!
|
|
74
|
+
expect(input).toHaveAttribute('aria-invalid', 'true')
|
|
75
|
+
expect(input).toHaveAttribute('data-invalid')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('does not set data-invalid when valid', () => {
|
|
79
|
+
render(
|
|
80
|
+
<OTPField>
|
|
81
|
+
<OTPFieldInput aria-label="Character 1 of 1" />
|
|
82
|
+
</OTPField>,
|
|
83
|
+
)
|
|
84
|
+
expect(screen.getAllByRole('textbox')[0]!).not.toHaveAttribute('data-invalid')
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('renders a separator between groups', () => {
|
|
88
|
+
render(
|
|
89
|
+
<OTPField length={4} aria-label="Code">
|
|
90
|
+
<OTPFieldInput aria-label="Character 1 of 4" />
|
|
91
|
+
<OTPFieldInput aria-label="Character 2 of 4" />
|
|
92
|
+
<OTPFieldSeparator data-testid="separator" />
|
|
93
|
+
<OTPFieldInput aria-label="Character 3 of 4" />
|
|
94
|
+
<OTPFieldInput aria-label="Character 4 of 4" />
|
|
95
|
+
</OTPField>,
|
|
96
|
+
)
|
|
97
|
+
expect(screen.getByTestId('separator')).toBeInTheDocument()
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('has no accessibility violations', async () => {
|
|
101
|
+
const { container } = render(
|
|
102
|
+
<>
|
|
103
|
+
<label htmlFor="otp">Verification code</label>
|
|
104
|
+
<OTPField id="otp" length={LENGTH}>
|
|
105
|
+
{Array.from({ length: LENGTH }, (_, index) => (
|
|
106
|
+
<OTPFieldInput key={index} aria-label={`Character ${index + 1} of ${LENGTH}`} />
|
|
107
|
+
))}
|
|
108
|
+
</OTPField>
|
|
109
|
+
</>,
|
|
110
|
+
)
|
|
111
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
112
|
+
})
|
|
113
|
+
})
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { OTPField as BaseOTPField } from '@base-ui/react/otp-field'
|
|
5
|
+
import { type VariantProps } from 'class-variance-authority'
|
|
6
|
+
import { cn } from '../../utils'
|
|
7
|
+
import { inputVariants } from '../input/input-variants'
|
|
8
|
+
|
|
9
|
+
type OTPFieldVariant = NonNullable<VariantProps<typeof inputVariants>['variant']>
|
|
10
|
+
type OTPFieldSize = NonNullable<VariantProps<typeof inputVariants>['size']>
|
|
11
|
+
|
|
12
|
+
interface OTPFieldContextValue {
|
|
13
|
+
variant: OTPFieldVariant
|
|
14
|
+
size: OTPFieldSize
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const OTPFieldContext = React.createContext<OTPFieldContextValue | null>(null)
|
|
18
|
+
|
|
19
|
+
function useOTPFieldContext() {
|
|
20
|
+
const ctx = React.useContext(OTPFieldContext)
|
|
21
|
+
if (!ctx) {
|
|
22
|
+
throw new Error('OTPField sub-components must be rendered inside <OTPField>')
|
|
23
|
+
}
|
|
24
|
+
return ctx
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const INPUT_SQUARE: Record<OTPFieldSize, string> = {
|
|
28
|
+
sm: 'w-8',
|
|
29
|
+
md: 'w-10',
|
|
30
|
+
lg: 'w-12',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const SEPARATOR_SIZE: Record<OTPFieldSize, string> = {
|
|
34
|
+
sm: 'w-3 [&_svg]:size-3',
|
|
35
|
+
md: 'w-4 [&_svg]:size-3.5',
|
|
36
|
+
lg: 'w-5 [&_svg]:size-4.5',
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface OTPFieldProps extends Omit<React.ComponentProps<typeof BaseOTPField.Root>, 'className'> {
|
|
40
|
+
variant?: OTPFieldVariant
|
|
41
|
+
size?: OTPFieldSize
|
|
42
|
+
className?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function OTPField({ variant = 'outline', size = 'md', className, children, ...props }: OTPFieldProps) {
|
|
46
|
+
const ctx = React.useMemo<OTPFieldContextValue>(() => ({ variant, size }), [variant, size])
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<OTPFieldContext.Provider value={ctx}>
|
|
50
|
+
<BaseOTPField.Root data-slot="otp-field" className={cn('flex w-fit items-center gap-1', className)} {...props}>
|
|
51
|
+
{children}
|
|
52
|
+
</BaseOTPField.Root>
|
|
53
|
+
</OTPFieldContext.Provider>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type OTPFieldInputProps = React.ComponentProps<typeof BaseOTPField.Input>
|
|
58
|
+
|
|
59
|
+
function OTPFieldInput({ className, ...props }: OTPFieldInputProps) {
|
|
60
|
+
const { variant, size } = useOTPFieldContext()
|
|
61
|
+
|
|
62
|
+
const ariaInvalid = props['aria-invalid']
|
|
63
|
+
const invalid = ariaInvalid === true || ariaInvalid === 'true'
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<BaseOTPField.Input
|
|
67
|
+
data-slot="otp-field-input"
|
|
68
|
+
className={cn(
|
|
69
|
+
inputVariants({ variant, size, state: 'self' }),
|
|
70
|
+
'px-0 text-center focus:placeholder:text-transparent',
|
|
71
|
+
INPUT_SQUARE[size],
|
|
72
|
+
className,
|
|
73
|
+
)}
|
|
74
|
+
{...props}
|
|
75
|
+
{...(invalid ? { 'data-invalid': '' } : {})}
|
|
76
|
+
/>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type OTPFieldSeparatorProps = React.ComponentProps<typeof BaseOTPField.Separator>
|
|
81
|
+
|
|
82
|
+
function OTPFieldSeparator({ className, children, ...props }: OTPFieldSeparatorProps) {
|
|
83
|
+
const { size } = useOTPFieldContext()
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<BaseOTPField.Separator
|
|
87
|
+
data-slot="otp-field-separator"
|
|
88
|
+
className={cn('text-border-strong flex items-center justify-center', SEPARATOR_SIZE[size], className)}
|
|
89
|
+
{...props}
|
|
90
|
+
>
|
|
91
|
+
{children ?? <SeparatorMark />}
|
|
92
|
+
</BaseOTPField.Separator>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function SeparatorMark() {
|
|
97
|
+
return (
|
|
98
|
+
<svg aria-hidden="true" viewBox="0 0 20 4" fill="none">
|
|
99
|
+
<path d="M2 2H18" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
|
|
100
|
+
</svg>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { OTPField, OTPFieldInput, OTPFieldSeparator }
|
|
105
|
+
export type { OTPFieldProps, OTPFieldInputProps, OTPFieldSeparatorProps }
|
|
@@ -0,0 +1,147 @@
|
|
|
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 { Pagination, PaginationList, PaginationItem, PaginationLink, PaginationEllipsis } from './pagination'
|
|
6
|
+
|
|
7
|
+
function renderBasic(props?: React.ComponentProps<typeof Pagination>) {
|
|
8
|
+
return render(
|
|
9
|
+
<Pagination {...props}>
|
|
10
|
+
<PaginationList>
|
|
11
|
+
<PaginationItem>
|
|
12
|
+
<PaginationLink href="#prev" aria-label="Go to previous page">
|
|
13
|
+
Prev
|
|
14
|
+
</PaginationLink>
|
|
15
|
+
</PaginationItem>
|
|
16
|
+
<PaginationItem>
|
|
17
|
+
<PaginationLink href="#1">1</PaginationLink>
|
|
18
|
+
</PaginationItem>
|
|
19
|
+
<PaginationItem>
|
|
20
|
+
<PaginationLink href="#2" active>
|
|
21
|
+
2
|
|
22
|
+
</PaginationLink>
|
|
23
|
+
</PaginationItem>
|
|
24
|
+
<PaginationItem>
|
|
25
|
+
<PaginationLink href="#3">3</PaginationLink>
|
|
26
|
+
</PaginationItem>
|
|
27
|
+
<PaginationItem>
|
|
28
|
+
<PaginationEllipsis />
|
|
29
|
+
</PaginationItem>
|
|
30
|
+
<PaginationItem>
|
|
31
|
+
<PaginationLink href="#next" aria-label="Go to next page">
|
|
32
|
+
Next
|
|
33
|
+
</PaginationLink>
|
|
34
|
+
</PaginationItem>
|
|
35
|
+
</PaginationList>
|
|
36
|
+
</Pagination>,
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe('Pagination', () => {
|
|
41
|
+
it('renders a nav with pagination role and label', () => {
|
|
42
|
+
renderBasic()
|
|
43
|
+
const nav = screen.getByRole('navigation', { name: 'pagination' })
|
|
44
|
+
expect(nav.tagName).toBe('NAV')
|
|
45
|
+
expect(nav).toHaveAttribute('data-slot', 'pagination')
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('renders content as a ul and items as li', () => {
|
|
49
|
+
renderBasic()
|
|
50
|
+
const list = screen.getByRole('list')
|
|
51
|
+
expect(list.tagName).toBe('UL')
|
|
52
|
+
expect(list).toHaveAttribute('data-slot', 'pagination-list')
|
|
53
|
+
const items = screen.getAllByRole('listitem')
|
|
54
|
+
expect(items).toHaveLength(6)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('marks the active link with aria-current and data-active', () => {
|
|
58
|
+
renderBasic()
|
|
59
|
+
const active = screen.getByRole('link', { current: 'page' })
|
|
60
|
+
expect(active).toHaveTextContent('2')
|
|
61
|
+
expect(active).toHaveAttribute('data-active')
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('marks disabled links with aria-disabled and data-disabled', () => {
|
|
65
|
+
render(
|
|
66
|
+
<Pagination>
|
|
67
|
+
<PaginationList>
|
|
68
|
+
<PaginationItem>
|
|
69
|
+
<PaginationLink href="#" disabled aria-label="Previous">
|
|
70
|
+
Prev
|
|
71
|
+
</PaginationLink>
|
|
72
|
+
</PaginationItem>
|
|
73
|
+
</PaginationList>
|
|
74
|
+
</Pagination>,
|
|
75
|
+
)
|
|
76
|
+
const link = screen.getByRole('link', { name: 'Previous' })
|
|
77
|
+
expect(link).toHaveAttribute('aria-disabled', 'true')
|
|
78
|
+
expect(link).toHaveAttribute('data-disabled')
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('forwards className alongside variant classes on the link', () => {
|
|
82
|
+
render(
|
|
83
|
+
<Pagination>
|
|
84
|
+
<PaginationList>
|
|
85
|
+
<PaginationItem>
|
|
86
|
+
<PaginationLink href="#" className="my-link">
|
|
87
|
+
1
|
|
88
|
+
</PaginationLink>
|
|
89
|
+
</PaginationItem>
|
|
90
|
+
</PaginationList>
|
|
91
|
+
</Pagination>,
|
|
92
|
+
)
|
|
93
|
+
const link = screen.getByRole('link', { name: '1' })
|
|
94
|
+
expect(link.className).toContain('my-link')
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it('renders link as a different element via render prop', () => {
|
|
98
|
+
const onClick = vi.fn()
|
|
99
|
+
render(
|
|
100
|
+
<Pagination>
|
|
101
|
+
<PaginationList>
|
|
102
|
+
<PaginationItem>
|
|
103
|
+
<PaginationLink render={<button type="button" onClick={onClick} />}>5</PaginationLink>
|
|
104
|
+
</PaginationItem>
|
|
105
|
+
</PaginationList>
|
|
106
|
+
</Pagination>,
|
|
107
|
+
)
|
|
108
|
+
const el = screen.getByRole('button', { name: '5' })
|
|
109
|
+
expect(el.tagName).toBe('BUTTON')
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('fires onClick on the link', async () => {
|
|
113
|
+
const user = userEvent.setup()
|
|
114
|
+
const onClick = vi.fn()
|
|
115
|
+
render(
|
|
116
|
+
<Pagination>
|
|
117
|
+
<PaginationList>
|
|
118
|
+
<PaginationItem>
|
|
119
|
+
<PaginationLink href="#" onClick={onClick}>
|
|
120
|
+
1
|
|
121
|
+
</PaginationLink>
|
|
122
|
+
</PaginationItem>
|
|
123
|
+
</PaginationList>
|
|
124
|
+
</Pagination>,
|
|
125
|
+
)
|
|
126
|
+
await user.click(screen.getByRole('link', { name: '1' }))
|
|
127
|
+
expect(onClick).toHaveBeenCalledOnce()
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('renders the ellipsis as a decorative (aria-hidden) element', () => {
|
|
131
|
+
renderBasic()
|
|
132
|
+
const ellipsis = document.querySelector('[data-slot="pagination-ellipsis"]')
|
|
133
|
+
expect(ellipsis).not.toBeNull()
|
|
134
|
+
expect(ellipsis).toHaveAttribute('aria-hidden')
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('throws when a sub-component is used outside Pagination', () => {
|
|
138
|
+
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
|
139
|
+
expect(() => render(<PaginationLink href="#">1</PaginationLink>)).toThrow(/must be rendered inside <Pagination>/)
|
|
140
|
+
spy.mockRestore()
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('has no accessibility violations', async () => {
|
|
144
|
+
const { container } = renderBasic()
|
|
145
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
146
|
+
})
|
|
147
|
+
})
|