@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,125 @@
|
|
|
1
|
+
import { render, screen, act } from '@testing-library/react'
|
|
2
|
+
import { describe, it, expect, vi, afterEach } from 'vitest'
|
|
3
|
+
import { axe } from 'vitest-axe'
|
|
4
|
+
import { TextAnimate, type TextAnimateUnitContext } from './text-animate'
|
|
5
|
+
import { ReducedMotionProvider } from '../../providers/reduced-motion-provider'
|
|
6
|
+
|
|
7
|
+
afterEach(() => {
|
|
8
|
+
vi.useRealTimers()
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
describe('TextAnimate', () => {
|
|
12
|
+
it('always exposes the full text to assistive tech via an sr-only copy', () => {
|
|
13
|
+
render(
|
|
14
|
+
<TextAnimate autoPlay={false} progress={0}>
|
|
15
|
+
Hello world
|
|
16
|
+
</TextAnimate>,
|
|
17
|
+
)
|
|
18
|
+
// The visual layer is aria-hidden; the sr-only node carries the real text.
|
|
19
|
+
expect(screen.getByText('Hello world')).toHaveClass('sr-only')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('splits into per-character units at full progress', () => {
|
|
23
|
+
const { container } = render(
|
|
24
|
+
<TextAnimate effect="flip" progress={1}>
|
|
25
|
+
abc
|
|
26
|
+
</TextAnimate>,
|
|
27
|
+
)
|
|
28
|
+
const units = container.querySelectorAll('[data-slot="text-animate-unit"]')
|
|
29
|
+
expect(units).toHaveLength(3)
|
|
30
|
+
expect(Array.from(units, (u) => u.textContent).join('')).toBe('abc')
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('splits by word when the effect/level calls for it', () => {
|
|
34
|
+
const { container } = render(
|
|
35
|
+
<TextAnimate by="word" effect="highlight" progress={1}>
|
|
36
|
+
one two three
|
|
37
|
+
</TextAnimate>,
|
|
38
|
+
)
|
|
39
|
+
const units = container.querySelectorAll('[data-slot="text-animate-unit"]')
|
|
40
|
+
expect(units).toHaveLength(3)
|
|
41
|
+
expect(units[0]).toHaveTextContent('one')
|
|
42
|
+
expect(units[2]).toHaveTextContent('three')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('drives the animation from a controlled progress value', () => {
|
|
46
|
+
const { container, rerender } = render(
|
|
47
|
+
<TextAnimate effect="typewriter" progress={0}>
|
|
48
|
+
Hi
|
|
49
|
+
</TextAnimate>,
|
|
50
|
+
)
|
|
51
|
+
const visual = container.querySelector('[aria-hidden="true"]')!
|
|
52
|
+
// Nothing typed yet (aside from the caret element which has no text).
|
|
53
|
+
expect(visual.textContent).toBe('')
|
|
54
|
+
|
|
55
|
+
rerender(
|
|
56
|
+
<TextAnimate effect="typewriter" progress={1}>
|
|
57
|
+
Hi
|
|
58
|
+
</TextAnimate>,
|
|
59
|
+
)
|
|
60
|
+
expect(visual.textContent).toContain('Hi')
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('passes a custom effect function the local progress and unit context', () => {
|
|
64
|
+
const effect = vi.fn((p: number, _ctx: TextAnimateUnitContext) => ({ style: { opacity: p } }))
|
|
65
|
+
render(
|
|
66
|
+
<TextAnimate effect={effect} by="char" stagger={0} progress={0.5}>
|
|
67
|
+
ab
|
|
68
|
+
</TextAnimate>,
|
|
69
|
+
)
|
|
70
|
+
expect(effect).toHaveBeenCalled()
|
|
71
|
+
const [, ctx] = effect.mock.calls[0]!
|
|
72
|
+
expect(ctx).toMatchObject({ total: 2, by: 'char', globalProgress: 0.5 })
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('advances the built-in clock with requestAnimationFrame to reveal text over time', async () => {
|
|
76
|
+
// Each frame ticks the mock clock forward, so elapsed time actually grows.
|
|
77
|
+
let t = 0
|
|
78
|
+
vi.spyOn(performance, 'now').mockImplementation(() => t)
|
|
79
|
+
const rafSpy = vi.spyOn(globalThis, 'requestAnimationFrame').mockImplementation((cb: FrameRequestCallback) => {
|
|
80
|
+
t += 700
|
|
81
|
+
return setTimeout(() => cb(t), 0) as unknown as number
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const { container } = render(
|
|
85
|
+
<TextAnimate effect="typewriter" duration={1}>
|
|
86
|
+
Hi
|
|
87
|
+
</TextAnimate>,
|
|
88
|
+
)
|
|
89
|
+
const visual = container.querySelector('[aria-hidden="true"]')!
|
|
90
|
+
expect(visual.textContent).toBe('')
|
|
91
|
+
|
|
92
|
+
for (let i = 0; i < 6; i++) {
|
|
93
|
+
await act(async () => {
|
|
94
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
expect(visual.textContent).toContain('Hi')
|
|
98
|
+
|
|
99
|
+
rafSpy.mockRestore()
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('renders the final, fully-revealed frame under reduced motion', () => {
|
|
103
|
+
const { container } = render(
|
|
104
|
+
<ReducedMotionProvider disableAnimations>
|
|
105
|
+
<TextAnimate effect="typewriter" duration={5}>
|
|
106
|
+
Hello
|
|
107
|
+
</TextAnimate>
|
|
108
|
+
</ReducedMotionProvider>,
|
|
109
|
+
)
|
|
110
|
+
const visual = container.querySelector('[aria-hidden="true"]')!
|
|
111
|
+
// reduced motion snaps the internal clock's output straight to the last frame.
|
|
112
|
+
expect(visual.textContent).toContain('Hello')
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('has no accessibility violations', async () => {
|
|
116
|
+
const { container } = render(
|
|
117
|
+
<p>
|
|
118
|
+
<TextAnimate effect="highlight" progress={1}>
|
|
119
|
+
Accessible animated text
|
|
120
|
+
</TextAnimate>
|
|
121
|
+
</p>,
|
|
122
|
+
)
|
|
123
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
124
|
+
})
|
|
125
|
+
})
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { useReducedMotion } from '../../hooks/use-reduced-motion'
|
|
5
|
+
import { cn } from '../../utils'
|
|
6
|
+
|
|
7
|
+
type TextAnimateSegment = 'char' | 'word' | 'line'
|
|
8
|
+
|
|
9
|
+
type TextAnimateEffectName = 'typewriter' | 'scramble' | 'rise' | 'highlight' | 'wave' | 'flip' | 'shimmer'
|
|
10
|
+
|
|
11
|
+
interface TextAnimateUnitContext {
|
|
12
|
+
index: number
|
|
13
|
+
total: number
|
|
14
|
+
text: string
|
|
15
|
+
by: TextAnimateSegment
|
|
16
|
+
globalProgress: number
|
|
17
|
+
reduced: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type TextAnimateEffect = (
|
|
21
|
+
progress: number,
|
|
22
|
+
ctx: TextAnimateUnitContext,
|
|
23
|
+
) => {
|
|
24
|
+
style?: React.CSSProperties
|
|
25
|
+
className?: string
|
|
26
|
+
content?: React.ReactNode
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface PresetConfig {
|
|
30
|
+
fn: TextAnimateEffect
|
|
31
|
+
by: TextAnimateSegment
|
|
32
|
+
stagger: number
|
|
33
|
+
continuous: boolean
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const SCRAMBLE_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789#%&@$?/<>*'
|
|
37
|
+
const SCRAMBLE_STEPS = 10
|
|
38
|
+
|
|
39
|
+
const presets: Record<TextAnimateEffectName, PresetConfig> = {
|
|
40
|
+
typewriter: {
|
|
41
|
+
by: 'char',
|
|
42
|
+
stagger: 1,
|
|
43
|
+
continuous: false,
|
|
44
|
+
fn: (p, ctx) => {
|
|
45
|
+
const typed = p > 0
|
|
46
|
+
const head = Math.min(Math.floor(ctx.globalProgress * ctx.total), ctx.total - 1)
|
|
47
|
+
const onEdge = ctx.index === head && ctx.globalProgress < 1
|
|
48
|
+
const caret = (onEdge || (ctx.globalProgress >= 1 && ctx.index === ctx.total - 1)) && (
|
|
49
|
+
<span
|
|
50
|
+
aria-hidden="true"
|
|
51
|
+
className="motion-safe:animate-text-caret"
|
|
52
|
+
style={{
|
|
53
|
+
display: 'inline-block',
|
|
54
|
+
width: '0.08em',
|
|
55
|
+
height: '1em',
|
|
56
|
+
marginInlineStart: '0.04em',
|
|
57
|
+
backgroundColor: 'currentColor',
|
|
58
|
+
verticalAlign: 'text-bottom',
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
)
|
|
62
|
+
return {
|
|
63
|
+
content: (
|
|
64
|
+
<>
|
|
65
|
+
{typed ? ctx.text : ''}
|
|
66
|
+
{caret}
|
|
67
|
+
</>
|
|
68
|
+
),
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
scramble: {
|
|
74
|
+
by: 'char',
|
|
75
|
+
stagger: 0.6,
|
|
76
|
+
continuous: false,
|
|
77
|
+
fn: (p, ctx) => {
|
|
78
|
+
if (p >= 1 || ctx.text.trim() === '' || ctx.reduced) return {}
|
|
79
|
+
const step = Math.floor(p * SCRAMBLE_STEPS)
|
|
80
|
+
const glyph = SCRAMBLE_CHARS[(ctx.index * 131 + step * 977) % SCRAMBLE_CHARS.length]
|
|
81
|
+
return { content: glyph, style: { opacity: 0.55 + p * 0.45 } }
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
rise: {
|
|
86
|
+
by: 'char',
|
|
87
|
+
stagger: 0.7,
|
|
88
|
+
continuous: false,
|
|
89
|
+
fn: (p, ctx) => {
|
|
90
|
+
if (ctx.reduced) return {}
|
|
91
|
+
const eased = 1 - Math.pow(1 - p, 3)
|
|
92
|
+
return {
|
|
93
|
+
style: {
|
|
94
|
+
display: 'inline-block',
|
|
95
|
+
overflow: 'hidden',
|
|
96
|
+
verticalAlign: 'bottom',
|
|
97
|
+
paddingBottom: '0.12em',
|
|
98
|
+
marginBottom: '-0.12em',
|
|
99
|
+
},
|
|
100
|
+
content: (
|
|
101
|
+
<span style={{ display: 'inline-block', transform: `translateY(${((1 - eased) * 110).toFixed(2)}%)` }}>
|
|
102
|
+
{ctx.text}
|
|
103
|
+
</span>
|
|
104
|
+
),
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
highlight: {
|
|
110
|
+
by: 'word',
|
|
111
|
+
stagger: 0.85,
|
|
112
|
+
continuous: false,
|
|
113
|
+
fn: (p) => ({ style: { opacity: 0.18 + 0.82 * p } }),
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
wave: {
|
|
117
|
+
by: 'char',
|
|
118
|
+
stagger: 0,
|
|
119
|
+
continuous: true,
|
|
120
|
+
fn: (_p, ctx) => {
|
|
121
|
+
if (ctx.reduced) return {}
|
|
122
|
+
const y = Math.sin(ctx.globalProgress * Math.PI * 2 + ctx.index * 0.55)
|
|
123
|
+
return { style: { display: 'inline-block', transform: `translateY(${(-y * 0.16).toFixed(3)}em)` } }
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
flip: {
|
|
128
|
+
by: 'char',
|
|
129
|
+
stagger: 0.7,
|
|
130
|
+
continuous: false,
|
|
131
|
+
fn: (p, ctx) => {
|
|
132
|
+
if (ctx.reduced) return {}
|
|
133
|
+
return {
|
|
134
|
+
style: {
|
|
135
|
+
display: 'inline-block',
|
|
136
|
+
transformOrigin: '50% 0%',
|
|
137
|
+
backfaceVisibility: 'hidden',
|
|
138
|
+
transform: `perspective(600px) rotateX(${((1 - p) * -90).toFixed(2)}deg)`,
|
|
139
|
+
opacity: p < 0.5 ? p * 2 : 1,
|
|
140
|
+
},
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
shimmer: {
|
|
146
|
+
by: 'char',
|
|
147
|
+
stagger: 0,
|
|
148
|
+
continuous: true,
|
|
149
|
+
fn: (_p, ctx) => {
|
|
150
|
+
if (ctx.reduced || ctx.text.trim() === '') return {}
|
|
151
|
+
const band = 4
|
|
152
|
+
const head = ctx.globalProgress * (ctx.total + band) - band
|
|
153
|
+
const lit = Math.max(0, 1 - Math.abs(ctx.index - head) / band)
|
|
154
|
+
return { style: { opacity: 0.4 + 0.6 * lit } }
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface BuiltChar {
|
|
160
|
+
ch: string
|
|
161
|
+
index: number
|
|
162
|
+
}
|
|
163
|
+
interface BuiltWord {
|
|
164
|
+
text: string
|
|
165
|
+
index: number
|
|
166
|
+
chars: BuiltChar[] | null
|
|
167
|
+
}
|
|
168
|
+
interface BuiltLine {
|
|
169
|
+
text: string
|
|
170
|
+
index: number
|
|
171
|
+
words: BuiltWord[] | null
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function tokenize(text: string, by: TextAnimateSegment): { lines: BuiltLine[]; total: number } {
|
|
175
|
+
let u = 0
|
|
176
|
+
const lines = text.split('\n').map<BuiltLine>((lineText) => {
|
|
177
|
+
if (by === 'line') {
|
|
178
|
+
return { text: lineText, index: u++, words: null }
|
|
179
|
+
}
|
|
180
|
+
const words = (lineText.length ? lineText.split(' ') : ['']).map<BuiltWord>((word) => {
|
|
181
|
+
if (by === 'word') {
|
|
182
|
+
return { text: word, index: u++, chars: null }
|
|
183
|
+
}
|
|
184
|
+
const chars = Array.from(word).map<BuiltChar>((ch) => ({ ch, index: u++ }))
|
|
185
|
+
return { text: word, index: -1, chars }
|
|
186
|
+
})
|
|
187
|
+
return { text: lineText, index: -1, words }
|
|
188
|
+
})
|
|
189
|
+
return { lines, total: u }
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const MIN_UNIT_DURATION = 1e-4
|
|
193
|
+
|
|
194
|
+
function clamp01(value: number): number {
|
|
195
|
+
return value < 0 ? 0 : value > 1 ? 1 : value
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface UnitProps {
|
|
199
|
+
text: string
|
|
200
|
+
index: number
|
|
201
|
+
total: number
|
|
202
|
+
by: TextAnimateSegment
|
|
203
|
+
stagger: number
|
|
204
|
+
globalProgress: number
|
|
205
|
+
reduced: boolean
|
|
206
|
+
effect: TextAnimateEffect
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function Unit({ text, index, total, by, stagger, globalProgress, reduced, effect }: UnitProps) {
|
|
210
|
+
const start = (index / total) * stagger
|
|
211
|
+
const duration = Math.max(1 - stagger, MIN_UNIT_DURATION)
|
|
212
|
+
const local = clamp01((globalProgress - start) / duration)
|
|
213
|
+
|
|
214
|
+
const { style, className, content } = effect(local, { index, total, text, by, globalProgress, reduced })
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<span data-slot="text-animate-unit" className={className} style={style}>
|
|
218
|
+
{content === undefined ? text : content}
|
|
219
|
+
</span>
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface TextAnimateProps extends Omit<React.ComponentProps<'span'>, 'children'> {
|
|
224
|
+
children: string
|
|
225
|
+
effect?: TextAnimateEffectName | TextAnimateEffect
|
|
226
|
+
by?: TextAnimateSegment
|
|
227
|
+
progress?: number
|
|
228
|
+
autoPlay?: boolean
|
|
229
|
+
loop?: boolean
|
|
230
|
+
duration?: number
|
|
231
|
+
delay?: number
|
|
232
|
+
stagger?: number
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function TextAnimate({
|
|
236
|
+
children,
|
|
237
|
+
effect = 'typewriter',
|
|
238
|
+
by,
|
|
239
|
+
progress,
|
|
240
|
+
autoPlay = true,
|
|
241
|
+
loop,
|
|
242
|
+
duration = 1.6,
|
|
243
|
+
delay = 0,
|
|
244
|
+
stagger,
|
|
245
|
+
className,
|
|
246
|
+
...props
|
|
247
|
+
}: TextAnimateProps) {
|
|
248
|
+
const reduced = useReducedMotion()
|
|
249
|
+
const text = String(children)
|
|
250
|
+
|
|
251
|
+
const preset = typeof effect === 'string' ? presets[effect] : null
|
|
252
|
+
const effectFn = preset ? preset.fn : (effect as TextAnimateEffect)
|
|
253
|
+
const segment = by ?? preset?.by ?? 'char'
|
|
254
|
+
const resolvedStagger = clamp01(stagger ?? preset?.stagger ?? 0.5)
|
|
255
|
+
const shouldLoop = loop ?? preset?.continuous ?? false
|
|
256
|
+
|
|
257
|
+
const controlled = progress != null
|
|
258
|
+
|
|
259
|
+
const [clock, setClock] = React.useState(controlled ? clamp01(progress) : autoPlay ? 0 : 1)
|
|
260
|
+
|
|
261
|
+
const containerRef = React.useRef<HTMLSpanElement>(null)
|
|
262
|
+
const [visible, setVisible] = React.useState(true)
|
|
263
|
+
React.useEffect(() => {
|
|
264
|
+
const el = containerRef.current
|
|
265
|
+
if (!el || typeof IntersectionObserver === 'undefined') return
|
|
266
|
+
const io = new IntersectionObserver((entries) => {
|
|
267
|
+
setVisible(entries[0]?.isIntersecting ?? true)
|
|
268
|
+
})
|
|
269
|
+
io.observe(el)
|
|
270
|
+
return () => io.disconnect()
|
|
271
|
+
}, [])
|
|
272
|
+
|
|
273
|
+
React.useEffect(() => {
|
|
274
|
+
if (controlled || !autoPlay || reduced) return
|
|
275
|
+
if (shouldLoop && !visible) return
|
|
276
|
+
let raf = 0
|
|
277
|
+
let startedAt: number | null = null
|
|
278
|
+
const totalMs = Math.max(duration, 0.001) * 1000
|
|
279
|
+
const delayMs = Math.max(delay, 0) * 1000
|
|
280
|
+
|
|
281
|
+
const tick = (now: number) => {
|
|
282
|
+
if (startedAt === null) startedAt = now + delayMs
|
|
283
|
+
const elapsed = now - startedAt
|
|
284
|
+
if (elapsed < 0) {
|
|
285
|
+
raf = requestAnimationFrame(tick)
|
|
286
|
+
return
|
|
287
|
+
}
|
|
288
|
+
const raw = elapsed / totalMs
|
|
289
|
+
const value = shouldLoop ? raw % 1 : Math.min(raw, 1)
|
|
290
|
+
setClock(value)
|
|
291
|
+
if (shouldLoop || raw < 1) raf = requestAnimationFrame(tick)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
raf = requestAnimationFrame(tick)
|
|
295
|
+
return () => cancelAnimationFrame(raf)
|
|
296
|
+
}, [controlled, autoPlay, reduced, duration, delay, shouldLoop, visible])
|
|
297
|
+
|
|
298
|
+
const globalProgress = controlled ? clamp01(progress) : reduced ? 1 : clock
|
|
299
|
+
|
|
300
|
+
const { lines, total } = React.useMemo(() => tokenize(text, segment), [text, segment])
|
|
301
|
+
|
|
302
|
+
const unitProps = { total, by: segment, stagger: resolvedStagger, globalProgress, reduced, effect: effectFn }
|
|
303
|
+
const multiline = lines.length > 1
|
|
304
|
+
|
|
305
|
+
return (
|
|
306
|
+
<span ref={containerRef} data-slot="text-animate" className={cn('inline-block', className)} {...props}>
|
|
307
|
+
<span className="sr-only">{text}</span>
|
|
308
|
+
<span aria-hidden="true" suppressHydrationWarning>
|
|
309
|
+
{lines.map((line, li) => {
|
|
310
|
+
const lineStyle = multiline ? ({ display: 'block' } as const) : undefined
|
|
311
|
+
|
|
312
|
+
if (line.words === null) {
|
|
313
|
+
return (
|
|
314
|
+
<span key={li} style={lineStyle}>
|
|
315
|
+
<Unit {...unitProps} text={line.text} index={line.index} />
|
|
316
|
+
</span>
|
|
317
|
+
)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return (
|
|
321
|
+
<span key={li} style={lineStyle}>
|
|
322
|
+
{line.words.map((word, wi) => {
|
|
323
|
+
const sep = wi < line.words!.length - 1 ? ' ' : ''
|
|
324
|
+
|
|
325
|
+
if (word.chars === null) {
|
|
326
|
+
return (
|
|
327
|
+
<React.Fragment key={wi}>
|
|
328
|
+
<Unit {...unitProps} text={word.text} index={word.index} />
|
|
329
|
+
{sep}
|
|
330
|
+
</React.Fragment>
|
|
331
|
+
)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return (
|
|
335
|
+
<React.Fragment key={wi}>
|
|
336
|
+
<span style={{ display: 'inline-block', whiteSpace: 'pre' }}>
|
|
337
|
+
{word.chars.map((c) => (
|
|
338
|
+
<Unit {...unitProps} key={c.index} text={c.ch} index={c.index} />
|
|
339
|
+
))}
|
|
340
|
+
</span>
|
|
341
|
+
{sep}
|
|
342
|
+
</React.Fragment>
|
|
343
|
+
)
|
|
344
|
+
})}
|
|
345
|
+
</span>
|
|
346
|
+
)
|
|
347
|
+
})}
|
|
348
|
+
</span>
|
|
349
|
+
</span>
|
|
350
|
+
)
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export { TextAnimate }
|
|
354
|
+
export type { TextAnimateProps, TextAnimateEffect, TextAnimateEffectName, TextAnimateSegment, TextAnimateUnitContext }
|
|
@@ -0,0 +1,188 @@
|
|
|
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 * as React from 'react'
|
|
6
|
+
import { Textarea } from './textarea'
|
|
7
|
+
import { Field, FieldLabel } from '../field/field'
|
|
8
|
+
|
|
9
|
+
describe('Textarea', () => {
|
|
10
|
+
it('associates with a Field label (matching for/id, like Input)', () => {
|
|
11
|
+
render(
|
|
12
|
+
<Field>
|
|
13
|
+
<FieldLabel>Bio</FieldLabel>
|
|
14
|
+
<Textarea />
|
|
15
|
+
</Field>,
|
|
16
|
+
)
|
|
17
|
+
// getByLabelText only resolves when the label's `for` matches the control id.
|
|
18
|
+
const textarea = screen.getByLabelText('Bio')
|
|
19
|
+
expect(textarea.tagName).toBe('TEXTAREA')
|
|
20
|
+
expect(textarea.id).not.toBe('')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('associates with a Field label when wrapped (slots/clearable)', () => {
|
|
24
|
+
render(
|
|
25
|
+
<Field>
|
|
26
|
+
<FieldLabel>Notes</FieldLabel>
|
|
27
|
+
<Textarea clearable />
|
|
28
|
+
</Field>,
|
|
29
|
+
)
|
|
30
|
+
expect(screen.getByLabelText('Notes').tagName).toBe('TEXTAREA')
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('renders with textbox role', () => {
|
|
34
|
+
render(<Textarea aria-label="Bio" />)
|
|
35
|
+
expect(screen.getByRole('textbox', { name: 'Bio' })).toBeInTheDocument()
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('accepts user typing across multiple lines', async () => {
|
|
39
|
+
const user = userEvent.setup()
|
|
40
|
+
render(<Textarea aria-label="Notes" />)
|
|
41
|
+
const textarea = screen.getByRole('textbox')
|
|
42
|
+
await user.type(textarea, 'line one{enter}line two')
|
|
43
|
+
expect(textarea).toHaveValue('line one\nline two')
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('calls onChange when typing in a controlled textarea', async () => {
|
|
47
|
+
const user = userEvent.setup()
|
|
48
|
+
const onChange = vi.fn()
|
|
49
|
+
|
|
50
|
+
function Controlled() {
|
|
51
|
+
const [value, setValue] = React.useState('')
|
|
52
|
+
return (
|
|
53
|
+
<Textarea
|
|
54
|
+
aria-label="Controlled"
|
|
55
|
+
value={value}
|
|
56
|
+
onChange={(e) => {
|
|
57
|
+
setValue(e.target.value)
|
|
58
|
+
onChange(e.target.value)
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
render(<Controlled />)
|
|
65
|
+
await user.type(screen.getByRole('textbox'), 'hi')
|
|
66
|
+
expect(onChange).toHaveBeenCalledWith('hi')
|
|
67
|
+
expect(screen.getByRole('textbox')).toHaveValue('hi')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('is disabled when the disabled prop is set', async () => {
|
|
71
|
+
const user = userEvent.setup()
|
|
72
|
+
render(<Textarea aria-label="Disabled" disabled />)
|
|
73
|
+
const textarea = screen.getByRole('textbox')
|
|
74
|
+
expect(textarea).toBeDisabled()
|
|
75
|
+
await user.type(textarea, 'x')
|
|
76
|
+
expect(textarea).toHaveValue('')
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('applies size padding-y classes', () => {
|
|
80
|
+
render(<Textarea aria-label="Large" inputSize="lg" />)
|
|
81
|
+
expect(screen.getByRole('textbox').className).toContain('py-3')
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('applies variant classes', () => {
|
|
85
|
+
render(<Textarea aria-label="Soft" variant="soft" />)
|
|
86
|
+
expect(screen.getByRole('textbox').className).toContain('bg-background-muted')
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('overrides h-X from inputVariants so rows controls height', () => {
|
|
90
|
+
render(<Textarea aria-label="Rows" rows={5} />)
|
|
91
|
+
const textarea = screen.getByRole('textbox')
|
|
92
|
+
expect(textarea).toHaveAttribute('rows', '5')
|
|
93
|
+
expect(textarea.className).toContain('h-auto')
|
|
94
|
+
expect(textarea.className).not.toMatch(/(?:^|\s)h-(?:8|10|12)(?:\s|$)/)
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it('enforces a per-size min-height floor on the textarea', () => {
|
|
98
|
+
render(<Textarea aria-label="Min height" inputSize="md" />)
|
|
99
|
+
expect(screen.getByRole('textbox').className).toContain('min-h-20')
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('wrapper owns the resize handle and seeds height from rows', () => {
|
|
103
|
+
render(<Textarea aria-label="Wrapped" rows={6} startSlot={<span data-testid="s">@</span>} />)
|
|
104
|
+
const wrapper = screen.getByTestId('s').closest('[data-slot="textarea-wrapper"]') as HTMLElement
|
|
105
|
+
expect(wrapper.className).toContain('resize-y')
|
|
106
|
+
expect(wrapper.className).toContain('h-(--textarea-h)')
|
|
107
|
+
expect(wrapper.className).toContain('min-h-20')
|
|
108
|
+
expect(wrapper.className).not.toMatch(/(?:^|\s)h-(?:8|10|12)(?:\s|$)/)
|
|
109
|
+
expect(wrapper.style.getPropertyValue('--textarea-h')).toBe('calc(6 * 1lh + 2 * 0.625rem + 2px)')
|
|
110
|
+
|
|
111
|
+
const textarea = screen.getByRole('textbox')
|
|
112
|
+
expect(textarea.className).toContain('resize-none')
|
|
113
|
+
expect(textarea.className).toContain('self-stretch')
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('bare disabled textarea carries data-disabled so it picks up data-disabled: classes from inputVariants', () => {
|
|
117
|
+
render(<Textarea aria-label="Disabled style" disabled />)
|
|
118
|
+
const textarea = screen.getByRole('textbox')
|
|
119
|
+
expect(textarea).toHaveAttribute('data-disabled')
|
|
120
|
+
expect(textarea.className).toContain('data-disabled:border-dashed')
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it('bare textarea omits data-disabled when not disabled', () => {
|
|
124
|
+
render(<Textarea aria-label="Enabled" />)
|
|
125
|
+
expect(screen.getByRole('textbox')).not.toHaveAttribute('data-disabled')
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('bridges aria-invalid to data-invalid on the bare textarea', () => {
|
|
129
|
+
render(<Textarea aria-label="Notes" aria-invalid />)
|
|
130
|
+
const textarea = screen.getByRole('textbox')
|
|
131
|
+
expect(textarea).toHaveAttribute('aria-invalid', 'true')
|
|
132
|
+
expect(textarea).toHaveAttribute('data-invalid')
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('bridges aria-invalid to data-invalid on the wrapper when slots are present', () => {
|
|
136
|
+
const { container } = render(<Textarea aria-label="Notes" aria-invalid endSlot={<span>@</span>} />)
|
|
137
|
+
expect(container.querySelector('[data-slot="textarea-wrapper"]')).toHaveAttribute('data-invalid')
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
it('bare textarea omits data-invalid when valid', () => {
|
|
141
|
+
render(<Textarea aria-label="Enabled" />)
|
|
142
|
+
expect(screen.getByRole('textbox')).not.toHaveAttribute('data-invalid')
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
it('forwards an outer ref', () => {
|
|
146
|
+
const ref = React.createRef<HTMLTextAreaElement>()
|
|
147
|
+
render(<Textarea aria-label="Ref" ref={ref} />)
|
|
148
|
+
expect(ref.current).toBeInstanceOf(HTMLTextAreaElement)
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
it('renders the clear button when clearable and clears the value', async () => {
|
|
152
|
+
const user = userEvent.setup()
|
|
153
|
+
const onClear = vi.fn()
|
|
154
|
+
render(<Textarea aria-label="Notes" clearable onClear={onClear} />)
|
|
155
|
+
|
|
156
|
+
const textarea = screen.getByRole('textbox')
|
|
157
|
+
await user.type(textarea, 'hello')
|
|
158
|
+
expect(textarea).toHaveValue('hello')
|
|
159
|
+
|
|
160
|
+
await user.click(screen.getByRole('button', { name: 'Clear input' }))
|
|
161
|
+
expect(textarea).toHaveValue('')
|
|
162
|
+
expect(onClear).toHaveBeenCalledOnce()
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
it('renders startSlot and endSlot when provided', () => {
|
|
166
|
+
render(
|
|
167
|
+
<Textarea
|
|
168
|
+
aria-label="With slots"
|
|
169
|
+
startSlot={<span data-testid="start">@</span>}
|
|
170
|
+
endSlot={<span data-testid="end">md</span>}
|
|
171
|
+
/>,
|
|
172
|
+
)
|
|
173
|
+
expect(screen.getByTestId('start')).toBeInTheDocument()
|
|
174
|
+
expect(screen.getByTestId('end')).toBeInTheDocument()
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it('aligns slots to the top with line-height matched wrapper', () => {
|
|
178
|
+
render(<Textarea aria-label="Slot align" startSlot={<span data-testid="start">@</span>} />)
|
|
179
|
+
const startWrapper = screen.getByTestId('start').parentElement
|
|
180
|
+
expect(startWrapper?.className).toContain('h-lh')
|
|
181
|
+
expect(startWrapper?.className).toContain('items-center')
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('has no accessibility violations', async () => {
|
|
185
|
+
const { container } = render(<Textarea aria-label="Bio" />)
|
|
186
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
187
|
+
})
|
|
188
|
+
})
|