@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,488 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useFieldRootContext } from '@base-ui/react/internals/field-root-context';
|
|
5
|
+
import { cn } from '../../utils.js';
|
|
6
|
+
import { inputVariants } from '../input/input-variants.js';
|
|
7
|
+
|
|
8
|
+
const EMPTY_PARTS = { hours: null, minutes: null, seconds: null };
|
|
9
|
+
const TOKEN_PATTERN = "HH|H|hh|h|mm|m|ss|s|a";
|
|
10
|
+
const PLACEHOLDERS = {
|
|
11
|
+
H: "HH",
|
|
12
|
+
HH: "HH",
|
|
13
|
+
h: "hh",
|
|
14
|
+
hh: "hh",
|
|
15
|
+
m: "mm",
|
|
16
|
+
mm: "mm",
|
|
17
|
+
s: "ss",
|
|
18
|
+
ss: "ss",
|
|
19
|
+
a: "AM"
|
|
20
|
+
};
|
|
21
|
+
function tokenToType(token) {
|
|
22
|
+
if (token === "H" || token === "HH") return "hour24";
|
|
23
|
+
if (token === "h" || token === "hh") return "hour12";
|
|
24
|
+
if (token === "m" || token === "mm") return "minute";
|
|
25
|
+
if (token === "s" || token === "ss") return "second";
|
|
26
|
+
return "period";
|
|
27
|
+
}
|
|
28
|
+
function parseFormat(formatStr) {
|
|
29
|
+
const nodes = [];
|
|
30
|
+
const re = new RegExp(TOKEN_PATTERN, "g");
|
|
31
|
+
let lastIndex = 0;
|
|
32
|
+
let segmentIndex = 0;
|
|
33
|
+
let match;
|
|
34
|
+
while ((match = re.exec(formatStr)) !== null) {
|
|
35
|
+
if (match.index > lastIndex) {
|
|
36
|
+
nodes.push({ kind: "literal", text: formatStr.slice(lastIndex, match.index) });
|
|
37
|
+
}
|
|
38
|
+
const token = match[0];
|
|
39
|
+
nodes.push({ kind: "segment", type: tokenToType(token), token, index: segmentIndex++ });
|
|
40
|
+
lastIndex = match.index + token.length;
|
|
41
|
+
}
|
|
42
|
+
if (lastIndex < formatStr.length) {
|
|
43
|
+
nodes.push({ kind: "literal", text: formatStr.slice(lastIndex) });
|
|
44
|
+
}
|
|
45
|
+
return nodes;
|
|
46
|
+
}
|
|
47
|
+
function pad2(n) {
|
|
48
|
+
return String(n).padStart(2, "0");
|
|
49
|
+
}
|
|
50
|
+
function partsFromString(s) {
|
|
51
|
+
if (!s) return EMPTY_PARTS;
|
|
52
|
+
const m = /^(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?(?:\.\d+)?$/.exec(s);
|
|
53
|
+
if (!m) return EMPTY_PARTS;
|
|
54
|
+
const hours = Number(m[1]);
|
|
55
|
+
const minutes = Number(m[2]);
|
|
56
|
+
const seconds = m[3] != null ? Number(m[3]) : null;
|
|
57
|
+
if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59) return EMPTY_PARTS;
|
|
58
|
+
if (seconds != null && (seconds < 0 || seconds > 59)) return EMPTY_PARTS;
|
|
59
|
+
return { hours, minutes, seconds };
|
|
60
|
+
}
|
|
61
|
+
function partsToString(p, includeSeconds) {
|
|
62
|
+
if (p.hours == null || p.minutes == null) return null;
|
|
63
|
+
if (includeSeconds && p.seconds == null) return null;
|
|
64
|
+
if (includeSeconds) return `${pad2(p.hours)}:${pad2(p.minutes)}:${pad2(p.seconds)}`;
|
|
65
|
+
return `${pad2(p.hours)}:${pad2(p.minutes)}`;
|
|
66
|
+
}
|
|
67
|
+
function to12(h24) {
|
|
68
|
+
if (h24 === 0) return { hour12: 12, period: "AM" };
|
|
69
|
+
if (h24 === 12) return { hour12: 12, period: "PM" };
|
|
70
|
+
if (h24 > 12) return { hour12: h24 - 12, period: "PM" };
|
|
71
|
+
return { hour12: h24, period: "AM" };
|
|
72
|
+
}
|
|
73
|
+
function from12(hour12, period) {
|
|
74
|
+
const h = hour12 % 12;
|
|
75
|
+
return period === "PM" ? h + 12 : h;
|
|
76
|
+
}
|
|
77
|
+
function periodOf(hours) {
|
|
78
|
+
if (hours == null) return null;
|
|
79
|
+
return hours >= 12 ? "PM" : "AM";
|
|
80
|
+
}
|
|
81
|
+
function getSegmentRange(token) {
|
|
82
|
+
if (token === "H" || token === "HH") return { min: 0, max: 23, maxDigits: 2 };
|
|
83
|
+
if (token === "h" || token === "hh") return { min: 1, max: 12, maxDigits: 2 };
|
|
84
|
+
if (token === "a") return { min: 0, max: 1, maxDigits: 1 };
|
|
85
|
+
return { min: 0, max: 59, maxDigits: 2 };
|
|
86
|
+
}
|
|
87
|
+
function getDisplayHour12(hours) {
|
|
88
|
+
if (hours == null) return null;
|
|
89
|
+
return to12(hours).hour12;
|
|
90
|
+
}
|
|
91
|
+
function displayPart(part, token, parts) {
|
|
92
|
+
if (token === "a") {
|
|
93
|
+
const period = periodOf(parts.hours);
|
|
94
|
+
return period ?? PLACEHOLDERS.a;
|
|
95
|
+
}
|
|
96
|
+
if (token === "h" || token === "hh") {
|
|
97
|
+
const h12 = getDisplayHour12(parts.hours);
|
|
98
|
+
if (h12 == null) return PLACEHOLDERS[token];
|
|
99
|
+
return token === "hh" ? pad2(h12) : String(h12);
|
|
100
|
+
}
|
|
101
|
+
if (part == null) return PLACEHOLDERS[token];
|
|
102
|
+
if (token === "HH" || token === "mm" || token === "ss") return pad2(part);
|
|
103
|
+
return String(part);
|
|
104
|
+
}
|
|
105
|
+
function ariaText(token, parts) {
|
|
106
|
+
if (token === "a") {
|
|
107
|
+
const period = periodOf(parts.hours);
|
|
108
|
+
return period ?? "Empty";
|
|
109
|
+
}
|
|
110
|
+
if (token === "h" || token === "hh") {
|
|
111
|
+
const h12 = getDisplayHour12(parts.hours);
|
|
112
|
+
return h12 == null ? "Empty" : String(h12);
|
|
113
|
+
}
|
|
114
|
+
const val = token === "H" || token === "HH" ? parts.hours : token === "m" || token === "mm" ? parts.minutes : parts.seconds;
|
|
115
|
+
return val == null ? "Empty" : String(val);
|
|
116
|
+
}
|
|
117
|
+
function ariaLabel(type) {
|
|
118
|
+
if (type === "hour24" || type === "hour12") return "hour";
|
|
119
|
+
if (type === "minute") return "minute";
|
|
120
|
+
if (type === "second") return "second";
|
|
121
|
+
return "period";
|
|
122
|
+
}
|
|
123
|
+
function setHourFromInput(prev, token, value) {
|
|
124
|
+
if (token === "h" || token === "hh") {
|
|
125
|
+
const period = periodOf(prev.hours) ?? "AM";
|
|
126
|
+
return { ...prev, hours: from12(value, period) };
|
|
127
|
+
}
|
|
128
|
+
return { ...prev, hours: value };
|
|
129
|
+
}
|
|
130
|
+
function togglePeriod(prev, target) {
|
|
131
|
+
const current = periodOf(prev.hours);
|
|
132
|
+
if (prev.hours == null) {
|
|
133
|
+
const next2 = target ?? "AM";
|
|
134
|
+
return { ...prev, hours: next2 === "PM" ? 12 : 0 };
|
|
135
|
+
}
|
|
136
|
+
const next = target ?? (current === "AM" ? "PM" : "AM");
|
|
137
|
+
if (next === current) return prev;
|
|
138
|
+
return { ...prev, hours: next === "PM" ? prev.hours + 12 : prev.hours - 12 };
|
|
139
|
+
}
|
|
140
|
+
function TimeField({
|
|
141
|
+
className,
|
|
142
|
+
value,
|
|
143
|
+
defaultValue,
|
|
144
|
+
onValueChange,
|
|
145
|
+
format = "HH:mm",
|
|
146
|
+
variant = "outline",
|
|
147
|
+
size = "md",
|
|
148
|
+
startSlot,
|
|
149
|
+
endSlot,
|
|
150
|
+
disabled: disabledProp,
|
|
151
|
+
readOnly,
|
|
152
|
+
required,
|
|
153
|
+
name: nameProp,
|
|
154
|
+
unstyled,
|
|
155
|
+
ref,
|
|
156
|
+
...rest
|
|
157
|
+
}) {
|
|
158
|
+
const field = useFieldRootContext(true);
|
|
159
|
+
const disabled = disabledProp || field.disabled;
|
|
160
|
+
const name = nameProp ?? field.name;
|
|
161
|
+
const ariaInvalid = rest["aria-invalid"];
|
|
162
|
+
const invalid = ariaInvalid === true || ariaInvalid === "true" || field.invalid === true;
|
|
163
|
+
const nodes = React.useMemo(() => parseFormat(format), [format]);
|
|
164
|
+
const segmentCount = React.useMemo(() => nodes.reduce((n, x) => n + (x.kind === "segment" ? 1 : 0), 0), [nodes]);
|
|
165
|
+
const includeSeconds = React.useMemo(
|
|
166
|
+
() => nodes.some((n) => n.kind === "segment" && (n.token === "s" || n.token === "ss")),
|
|
167
|
+
[nodes]
|
|
168
|
+
);
|
|
169
|
+
const isControlled = value !== void 0;
|
|
170
|
+
const [internalParts, setInternalParts] = React.useState(() => partsFromString(value ?? defaultValue));
|
|
171
|
+
const [commitTick, setCommitTick] = React.useState(0);
|
|
172
|
+
const lastValueRef = React.useRef(value ?? "");
|
|
173
|
+
const lastCommittedRef = React.useRef(
|
|
174
|
+
partsToString(partsFromString(value ?? defaultValue), includeSeconds) ?? ""
|
|
175
|
+
);
|
|
176
|
+
React.useEffect(() => {
|
|
177
|
+
if (!isControlled) return;
|
|
178
|
+
const v = value ?? "";
|
|
179
|
+
if (v !== lastValueRef.current) {
|
|
180
|
+
lastValueRef.current = v;
|
|
181
|
+
lastCommittedRef.current = v;
|
|
182
|
+
setInternalParts(partsFromString(value));
|
|
183
|
+
}
|
|
184
|
+
}, [isControlled, value]);
|
|
185
|
+
const parts = internalParts;
|
|
186
|
+
const partsRef = React.useRef(parts);
|
|
187
|
+
partsRef.current = parts;
|
|
188
|
+
const onValueChangeRef = React.useRef(onValueChange);
|
|
189
|
+
onValueChangeRef.current = onValueChange;
|
|
190
|
+
const includeSecondsRef = React.useRef(includeSeconds);
|
|
191
|
+
includeSecondsRef.current = includeSeconds;
|
|
192
|
+
const commit = React.useCallback((updater) => {
|
|
193
|
+
const next = updater(partsRef.current);
|
|
194
|
+
setInternalParts(next);
|
|
195
|
+
const serialized = partsToString(next, includeSecondsRef.current);
|
|
196
|
+
if (serialized) {
|
|
197
|
+
if (serialized !== lastCommittedRef.current) {
|
|
198
|
+
lastCommittedRef.current = serialized;
|
|
199
|
+
onValueChangeRef.current?.(serialized);
|
|
200
|
+
setCommitTick((t) => t + 1);
|
|
201
|
+
}
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const allEmpty = next.hours == null && next.minutes == null && next.seconds == null;
|
|
205
|
+
if (allEmpty && lastCommittedRef.current !== "") {
|
|
206
|
+
lastCommittedRef.current = "";
|
|
207
|
+
onValueChangeRef.current?.(null);
|
|
208
|
+
setCommitTick((t) => t + 1);
|
|
209
|
+
}
|
|
210
|
+
}, []);
|
|
211
|
+
React.useEffect(() => {
|
|
212
|
+
if (commitTick === 0 || !isControlled) return;
|
|
213
|
+
const v = value ?? "";
|
|
214
|
+
const serialized = partsToString(partsRef.current, includeSecondsRef.current) ?? "";
|
|
215
|
+
if (v !== serialized) {
|
|
216
|
+
lastValueRef.current = v;
|
|
217
|
+
lastCommittedRef.current = v;
|
|
218
|
+
setInternalParts(partsFromString(value));
|
|
219
|
+
}
|
|
220
|
+
}, [commitTick]);
|
|
221
|
+
const segmentRefs = React.useRef([]);
|
|
222
|
+
const typingCountRef = React.useRef(/* @__PURE__ */ new Map());
|
|
223
|
+
const setSegmentRef = React.useMemo(() => {
|
|
224
|
+
const cache = /* @__PURE__ */ new Map();
|
|
225
|
+
return (index) => {
|
|
226
|
+
let cb = cache.get(index);
|
|
227
|
+
if (!cb) {
|
|
228
|
+
cb = (el) => {
|
|
229
|
+
segmentRefs.current[index] = el;
|
|
230
|
+
};
|
|
231
|
+
cache.set(index, cb);
|
|
232
|
+
}
|
|
233
|
+
return cb;
|
|
234
|
+
};
|
|
235
|
+
}, []);
|
|
236
|
+
const focusSegment = React.useCallback((idx) => {
|
|
237
|
+
segmentRefs.current[idx]?.focus();
|
|
238
|
+
}, []);
|
|
239
|
+
const onRootMouseDown = React.useCallback(
|
|
240
|
+
(e) => {
|
|
241
|
+
if (disabled) return;
|
|
242
|
+
const target = e.target;
|
|
243
|
+
if (target.closest('[data-slot="time-field-segment"]')) return;
|
|
244
|
+
if (target.closest('button, a, input, select, textarea, label, [role="button"]')) return;
|
|
245
|
+
e.preventDefault();
|
|
246
|
+
const p = partsRef.current;
|
|
247
|
+
const isEmpty = (type) => type === "minute" ? p.minutes == null : type === "second" ? p.seconds == null : p.hours == null;
|
|
248
|
+
const firstEmpty = nodes.find((n) => n.kind === "segment" && isEmpty(n.type));
|
|
249
|
+
focusSegment(firstEmpty ? firstEmpty.index : 0);
|
|
250
|
+
},
|
|
251
|
+
[disabled, focusSegment, nodes]
|
|
252
|
+
);
|
|
253
|
+
const processCharInput = React.useCallback(
|
|
254
|
+
(seg, ch) => {
|
|
255
|
+
if (disabled || readOnly) return;
|
|
256
|
+
const p = partsRef.current;
|
|
257
|
+
if (seg.token === "a") {
|
|
258
|
+
if (/[aApP]/.test(ch)) {
|
|
259
|
+
typingCountRef.current.delete(seg.index);
|
|
260
|
+
const target = ch.toLowerCase() === "a" ? "AM" : "PM";
|
|
261
|
+
commit((prev) => togglePeriod(prev, target));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (ch === ":" || ch === "/" || ch === "-" || ch === "." || ch === "," || ch === " ") {
|
|
265
|
+
if (seg.index < segmentCount - 1) focusSegment(seg.index + 1);
|
|
266
|
+
}
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (ch === ":" || ch === "/" || ch === "-" || ch === "." || ch === "," || ch === " ") {
|
|
270
|
+
typingCountRef.current.delete(seg.index);
|
|
271
|
+
if (seg.index < segmentCount - 1) focusSegment(seg.index + 1);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (ch < "0" || ch > "9") return;
|
|
275
|
+
const range = getSegmentRange(seg.token);
|
|
276
|
+
const digit = Number(ch);
|
|
277
|
+
const count = typingCountRef.current.get(seg.index) ?? 0;
|
|
278
|
+
const base = seg.token === "h" || seg.token === "hh" ? getDisplayHour12(p.hours) : seg.token === "H" || seg.token === "HH" ? p.hours : seg.token === "m" || seg.token === "mm" ? p.minutes : p.seconds;
|
|
279
|
+
let displayVal;
|
|
280
|
+
if (count === 0 || base == null) {
|
|
281
|
+
displayVal = digit;
|
|
282
|
+
} else {
|
|
283
|
+
const tentative = base * 10 + digit;
|
|
284
|
+
displayVal = tentative > range.max ? digit : tentative;
|
|
285
|
+
}
|
|
286
|
+
if (displayVal < range.min) displayVal = range.min;
|
|
287
|
+
typingCountRef.current.set(seg.index, count + 1);
|
|
288
|
+
commit((prev) => {
|
|
289
|
+
if (seg.type === "hour24" || seg.type === "hour12") return setHourFromInput(prev, seg.token, displayVal);
|
|
290
|
+
if (seg.type === "minute") return { ...prev, minutes: displayVal };
|
|
291
|
+
return { ...prev, seconds: displayVal };
|
|
292
|
+
});
|
|
293
|
+
const reachedMaxDigits = (typingCountRef.current.get(seg.index) ?? 0) >= range.maxDigits;
|
|
294
|
+
const cantFitAnother = displayVal * 10 > range.max;
|
|
295
|
+
if (reachedMaxDigits || cantFitAnother) {
|
|
296
|
+
typingCountRef.current.delete(seg.index);
|
|
297
|
+
if (seg.index < segmentCount - 1) focusSegment(seg.index + 1);
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
[commit, disabled, focusSegment, readOnly, segmentCount]
|
|
301
|
+
);
|
|
302
|
+
const onSegmentKeyDown = React.useCallback(
|
|
303
|
+
(e, seg) => {
|
|
304
|
+
if (disabled) return;
|
|
305
|
+
const p = partsRef.current;
|
|
306
|
+
if (e.key === "Tab") return;
|
|
307
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
308
|
+
e.preventDefault();
|
|
309
|
+
const goNext = e.key === "ArrowRight";
|
|
310
|
+
typingCountRef.current.delete(seg.index);
|
|
311
|
+
const target = goNext ? seg.index + 1 : seg.index - 1;
|
|
312
|
+
if (target >= 0 && target < segmentCount) focusSegment(target);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (e.key === "Home") {
|
|
316
|
+
e.preventDefault();
|
|
317
|
+
typingCountRef.current.delete(seg.index);
|
|
318
|
+
focusSegment(0);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
if (e.key === "End") {
|
|
322
|
+
e.preventDefault();
|
|
323
|
+
typingCountRef.current.delete(seg.index);
|
|
324
|
+
focusSegment(segmentCount - 1);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (readOnly) return;
|
|
328
|
+
if (seg.token === "a") {
|
|
329
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
330
|
+
e.preventDefault();
|
|
331
|
+
typingCountRef.current.delete(seg.index);
|
|
332
|
+
commit((prev) => togglePeriod(prev));
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (e.key === "Backspace" || e.key === "Delete") {
|
|
336
|
+
e.preventDefault();
|
|
337
|
+
typingCountRef.current.delete(seg.index);
|
|
338
|
+
if (p.hours == null && e.key === "Backspace" && seg.index > 0) {
|
|
339
|
+
focusSegment(seg.index - 1);
|
|
340
|
+
} else {
|
|
341
|
+
commit((prev) => ({ ...prev, hours: null }));
|
|
342
|
+
}
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (e.key.length === 1) {
|
|
346
|
+
e.preventDefault();
|
|
347
|
+
processCharInput(seg, e.key);
|
|
348
|
+
}
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const partVal = seg.token === "h" || seg.token === "hh" ? getDisplayHour12(p.hours) : seg.token === "H" || seg.token === "HH" ? p.hours : seg.token === "m" || seg.token === "mm" ? p.minutes : p.seconds;
|
|
352
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
353
|
+
e.preventDefault();
|
|
354
|
+
typingCountRef.current.delete(seg.index);
|
|
355
|
+
const range = getSegmentRange(seg.token);
|
|
356
|
+
const stepUp = e.key === "ArrowUp";
|
|
357
|
+
let next;
|
|
358
|
+
if (partVal == null) {
|
|
359
|
+
next = stepUp ? range.min : range.max;
|
|
360
|
+
} else {
|
|
361
|
+
let nb = stepUp ? partVal + 1 : partVal - 1;
|
|
362
|
+
if (nb > range.max) nb = range.min;
|
|
363
|
+
if (nb < range.min) nb = range.max;
|
|
364
|
+
next = nb;
|
|
365
|
+
}
|
|
366
|
+
commit((prev) => {
|
|
367
|
+
if (seg.type === "hour24" || seg.type === "hour12") return setHourFromInput(prev, seg.token, next);
|
|
368
|
+
if (seg.type === "minute") return { ...prev, minutes: next };
|
|
369
|
+
return { ...prev, seconds: next };
|
|
370
|
+
});
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if (e.key === "Backspace" || e.key === "Delete") {
|
|
374
|
+
e.preventDefault();
|
|
375
|
+
typingCountRef.current.delete(seg.index);
|
|
376
|
+
if (partVal == null && e.key === "Backspace" && seg.index > 0) {
|
|
377
|
+
focusSegment(seg.index - 1);
|
|
378
|
+
} else {
|
|
379
|
+
commit((prev) => {
|
|
380
|
+
if (seg.type === "hour24" || seg.type === "hour12") return { ...prev, hours: null };
|
|
381
|
+
if (seg.type === "minute") return { ...prev, minutes: null };
|
|
382
|
+
return { ...prev, seconds: null };
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (e.key.length === 1) {
|
|
388
|
+
e.preventDefault();
|
|
389
|
+
processCharInput(seg, e.key);
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
[commit, disabled, focusSegment, processCharInput, readOnly, segmentCount]
|
|
393
|
+
);
|
|
394
|
+
const onSegmentBeforeInput = React.useCallback(
|
|
395
|
+
(e, seg) => {
|
|
396
|
+
e.preventDefault();
|
|
397
|
+
const data = e.nativeEvent.data;
|
|
398
|
+
if (!data) return;
|
|
399
|
+
for (const ch of data) processCharInput(seg, ch);
|
|
400
|
+
},
|
|
401
|
+
[processCharInput]
|
|
402
|
+
);
|
|
403
|
+
const onSegmentFocus = React.useCallback((seg) => {
|
|
404
|
+
typingCountRef.current.delete(seg.index);
|
|
405
|
+
}, []);
|
|
406
|
+
const onSegmentBlur = React.useCallback((seg) => {
|
|
407
|
+
typingCountRef.current.delete(seg.index);
|
|
408
|
+
}, []);
|
|
409
|
+
const hiddenValue = partsToString(parts, includeSeconds) ?? "";
|
|
410
|
+
return /* @__PURE__ */ jsxs(
|
|
411
|
+
"div",
|
|
412
|
+
{
|
|
413
|
+
"data-slot": "time-field",
|
|
414
|
+
"data-disabled": disabled || void 0,
|
|
415
|
+
"data-invalid": invalid || void 0,
|
|
416
|
+
"aria-invalid": invalid || void 0,
|
|
417
|
+
"aria-disabled": disabled || void 0,
|
|
418
|
+
role: "group",
|
|
419
|
+
ref,
|
|
420
|
+
className: cn(
|
|
421
|
+
unstyled ? "inline-flex min-w-0 items-center select-none data-disabled:pointer-events-none data-disabled:cursor-not-allowed" : cn(
|
|
422
|
+
inputVariants({ variant, size, state: "within" }),
|
|
423
|
+
"select-none",
|
|
424
|
+
"data-disabled:border-border-strong! data-disabled:bg-background-subtle! data-disabled:opacity-disabled data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:border-dashed"
|
|
425
|
+
),
|
|
426
|
+
className
|
|
427
|
+
),
|
|
428
|
+
...rest,
|
|
429
|
+
onMouseDown: (e) => {
|
|
430
|
+
rest.onMouseDown?.(e);
|
|
431
|
+
if (!e.defaultPrevented) onRootMouseDown(e);
|
|
432
|
+
},
|
|
433
|
+
children: [
|
|
434
|
+
startSlot ? /* @__PURE__ */ jsx("div", { "data-slot": "time-field-start", className: "-ms-1 shrink-0", children: startSlot }) : null,
|
|
435
|
+
/* @__PURE__ */ jsx("div", { "data-slot": "time-field-segments", dir: "ltr", className: "text-foreground flex min-w-0 flex-1 items-center", children: nodes.map((node, i) => {
|
|
436
|
+
if (node.kind === "literal") {
|
|
437
|
+
return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-foreground-subtle whitespace-pre", children: node.text }, `l-${i}`);
|
|
438
|
+
}
|
|
439
|
+
const isPeriod = node.token === "a";
|
|
440
|
+
const range = getSegmentRange(node.token);
|
|
441
|
+
const partVal = node.token === "a" ? null : node.token === "h" || node.token === "hh" ? getDisplayHour12(parts.hours) : node.token === "H" || node.token === "HH" ? parts.hours : node.token === "m" || node.token === "mm" ? parts.minutes : parts.seconds;
|
|
442
|
+
const isPlaceholder = isPeriod ? parts.hours == null : partVal == null;
|
|
443
|
+
const editable = !disabled && !readOnly;
|
|
444
|
+
const periodValue = isPeriod ? periodOf(parts.hours) : null;
|
|
445
|
+
const periodAriaNow = periodValue === "AM" ? 0 : periodValue === "PM" ? 1 : void 0;
|
|
446
|
+
return /* @__PURE__ */ jsx(
|
|
447
|
+
"span",
|
|
448
|
+
{
|
|
449
|
+
ref: setSegmentRef(node.index),
|
|
450
|
+
role: "spinbutton",
|
|
451
|
+
tabIndex: disabled ? -1 : 0,
|
|
452
|
+
contentEditable: editable,
|
|
453
|
+
suppressContentEditableWarning: true,
|
|
454
|
+
inputMode: isPeriod ? "text" : "numeric",
|
|
455
|
+
enterKeyHint: "next",
|
|
456
|
+
autoCorrect: "off",
|
|
457
|
+
spellCheck: false,
|
|
458
|
+
"aria-label": ariaLabel(node.type),
|
|
459
|
+
"aria-readonly": readOnly || void 0,
|
|
460
|
+
"aria-valuemin": isPeriod ? 0 : range.min,
|
|
461
|
+
"aria-valuemax": isPeriod ? 1 : range.max,
|
|
462
|
+
"aria-valuenow": isPeriod ? periodAriaNow : partVal ?? void 0,
|
|
463
|
+
"aria-valuetext": ariaText(node.token, parts),
|
|
464
|
+
"data-slot": "time-field-segment",
|
|
465
|
+
"data-placeholder": isPlaceholder || void 0,
|
|
466
|
+
onBeforeInput: (e) => onSegmentBeforeInput(e, node),
|
|
467
|
+
onKeyDown: (e) => onSegmentKeyDown(e, node),
|
|
468
|
+
onFocus: () => onSegmentFocus(node),
|
|
469
|
+
onBlur: () => onSegmentBlur(node),
|
|
470
|
+
className: cn(
|
|
471
|
+
"rounded-3xs inline-block px-0.5 caret-transparent transition-colors duration-200 outline-none motion-reduce:transition-none",
|
|
472
|
+
"focus:bg-(--selection-color)",
|
|
473
|
+
"data-placeholder:text-foreground-subtle"
|
|
474
|
+
),
|
|
475
|
+
children: displayPart(partVal, node.token, parts)
|
|
476
|
+
},
|
|
477
|
+
`s-${node.index}`
|
|
478
|
+
);
|
|
479
|
+
}) }),
|
|
480
|
+
endSlot ? /* @__PURE__ */ jsx("div", { "data-slot": "time-field-end", className: "-me-1 shrink-0", children: endSlot }) : null,
|
|
481
|
+
name ? /* @__PURE__ */ jsx("input", { type: "hidden", name, value: hiddenValue, required, disabled }) : null
|
|
482
|
+
]
|
|
483
|
+
}
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export { TimeField };
|
|
488
|
+
//# sourceMappingURL=time-field.js.map
|