@zentauri-ui/zentauri-components 1.3.1 → 1.4.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/README.md +78 -0
- package/cli/cli.integration.test.ts +51 -0
- package/cli/index.mjs +664 -0
- package/cli/registry.json +36 -0
- package/cli/rewrite-imports.mjs +57 -0
- package/cli/rewrite-imports.test.ts +71 -0
- package/dist/ui/slider/slider.d.ts +18 -0
- package/dist/ui/slider/slider.d.ts.map +1 -1
- package/dist/ui/slider.js +21 -25
- package/dist/ui/slider.js.map +1 -1
- package/dist/ui/slider.mjs +21 -25
- package/dist/ui/slider.mjs.map +1 -1
- package/package.json +8 -2
- package/src/hooks/index.ts +48 -0
- package/src/hooks/useBodyScrollLock/index.ts +1 -0
- package/src/hooks/useBodyScrollLock/useBodyScrollLock.test.ts +51 -0
- package/src/hooks/useBodyScrollLock/useBodyScrollLock.ts +48 -0
- package/src/hooks/useClickOutside/index.ts +5 -0
- package/src/hooks/useClickOutside/useClickOutside.test.tsx +60 -0
- package/src/hooks/useClickOutside/useClickOutside.ts +52 -0
- package/src/hooks/useClipboard/index.ts +1 -0
- package/src/hooks/useClipboard/useClipboard.test.ts +101 -0
- package/src/hooks/useClipboard/useClipboard.ts +69 -0
- package/src/hooks/useControllableState/index.ts +4 -0
- package/src/hooks/useControllableState/useControllableState.test.ts +59 -0
- package/src/hooks/useControllableState/useControllableState.ts +49 -0
- package/src/hooks/useDebouncedValue/index.ts +1 -0
- package/src/hooks/useDebouncedValue/useDebouncedValue.test.ts +74 -0
- package/src/hooks/useDebouncedValue/useDebouncedValue.ts +29 -0
- package/src/hooks/useDisclosure/index.ts +5 -0
- package/src/hooks/useDisclosure/useDisclosure.test.ts +64 -0
- package/src/hooks/useDisclosure/useDisclosure.ts +62 -0
- package/src/hooks/useDocumentTitle/index.ts +4 -0
- package/src/hooks/useDocumentTitle/useDocumentTitle.test.ts +40 -0
- package/src/hooks/useDocumentTitle/useDocumentTitle.ts +58 -0
- package/src/hooks/useFocusManagement/index.ts +1 -0
- package/src/hooks/useFocusManagement/useFocusManagement.test.tsx +45 -0
- package/src/hooks/useFocusManagement/useFocusManagement.ts +77 -0
- package/src/hooks/useHover/index.ts +1 -0
- package/src/hooks/useHover/useHover.test.ts +45 -0
- package/src/hooks/useHover/useHover.ts +45 -0
- package/src/hooks/useInView/index.ts +1 -0
- package/src/hooks/useInView/useInView.test.ts +43 -0
- package/src/hooks/useInView/useInView.ts +28 -0
- package/src/hooks/useIntersectionObserver/index.ts +4 -0
- package/src/hooks/useIntersectionObserver/useIntersectionObserver.test.ts +75 -0
- package/src/hooks/useIntersectionObserver/useIntersectionObserver.ts +54 -0
- package/src/hooks/useIsMounted/index.ts +1 -0
- package/src/hooks/useIsMounted/useIsMounted.test.ts +25 -0
- package/src/hooks/useIsMounted/useIsMounted.ts +22 -0
- package/src/hooks/useIsomorphicLayoutEffect/index.ts +1 -0
- package/src/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.test.ts +19 -0
- package/src/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.ts +12 -0
- package/src/hooks/useLocalStorage/index.ts +4 -0
- package/src/hooks/useLocalStorage/useLocalStorage.test.ts +99 -0
- package/src/hooks/useLocalStorage/useLocalStorage.ts +109 -0
- package/src/hooks/useMediaQuery/index.ts +1 -0
- package/src/hooks/useMediaQuery/useMediaQuery.test.ts +63 -0
- package/src/hooks/useMediaQuery/useMediaQuery.ts +37 -0
- package/src/hooks/useNetworkStatus/index.ts +1 -0
- package/src/hooks/useNetworkStatus/useNetworkStatus.test.ts +53 -0
- package/src/hooks/useNetworkStatus/useNetworkStatus.ts +33 -0
- package/src/hooks/usePageVisibility/index.ts +1 -0
- package/src/hooks/usePageVisibility/usePageVisibility.test.ts +21 -0
- package/src/hooks/usePageVisibility/usePageVisibility.ts +31 -0
- package/src/hooks/usePagination/index.ts +6 -0
- package/src/hooks/usePagination/usePagination.test.ts +139 -0
- package/src/hooks/usePagination/usePagination.ts +153 -0
- package/src/hooks/usePrefersColorScheme/index.ts +4 -0
- package/src/hooks/usePrefersColorScheme/usePrefersColorScheme.test.ts +53 -0
- package/src/hooks/usePrefersColorScheme/usePrefersColorScheme.ts +21 -0
- package/src/hooks/usePrefersReducedMotion/index.ts +1 -0
- package/src/hooks/usePrefersReducedMotion/usePrefersReducedMotion.test.ts +27 -0
- package/src/hooks/usePrefersReducedMotion/usePrefersReducedMotion.ts +14 -0
- package/src/hooks/useResizeObserver/index.ts +4 -0
- package/src/hooks/useResizeObserver/useResizeObserver.test.ts +68 -0
- package/src/hooks/useResizeObserver/useResizeObserver.ts +58 -0
- package/src/hooks/useSessionStorage/index.ts +4 -0
- package/src/hooks/useSessionStorage/useSessionStorage.test.ts +54 -0
- package/src/hooks/useSessionStorage/useSessionStorage.ts +84 -0
- package/src/hooks/useThrottledCallback/index.ts +1 -0
- package/src/hooks/useThrottledCallback/useThrottledCallback.test.ts +75 -0
- package/src/hooks/useThrottledCallback/useThrottledCallback.ts +36 -0
- package/src/hooks/useToggle/index.ts +1 -0
- package/src/hooks/useToggle/useToggle.test.ts +40 -0
- package/src/hooks/useToggle/useToggle.ts +22 -0
- package/src/hooks/useWindowSize/index.ts +1 -0
- package/src/hooks/useWindowSize/useWindowSize.test.ts +23 -0
- package/src/hooks/useWindowSize/useWindowSize.ts +39 -0
- package/src/lib/utils.ts +25 -0
- package/src/ui/accordion/accordion-base.tsx +223 -0
- package/src/ui/accordion/accordion.test.tsx +146 -0
- package/src/ui/accordion/accordion.tsx +11 -0
- package/src/ui/accordion/animated/accordion-content-animated.tsx +46 -0
- package/src/ui/accordion/animated/accordion-root-animated.tsx +10 -0
- package/src/ui/accordion/animated/animations.ts +16 -0
- package/src/ui/accordion/animated/index.ts +7 -0
- package/src/ui/accordion/animated/types.ts +7 -0
- package/src/ui/accordion/index.ts +23 -0
- package/src/ui/accordion/types.ts +48 -0
- package/src/ui/accordion/variants.ts +115 -0
- package/src/ui/alert/alert-base.tsx +157 -0
- package/src/ui/alert/alert.test.tsx +150 -0
- package/src/ui/alert/alert.tsx +9 -0
- package/src/ui/alert/animated/alert-animated.tsx +20 -0
- package/src/ui/alert/animated/animations.ts +20 -0
- package/src/ui/alert/animated/index.ts +3 -0
- package/src/ui/alert/animated/types.ts +16 -0
- package/src/ui/alert/index.ts +22 -0
- package/src/ui/alert/types.ts +28 -0
- package/src/ui/alert/variants.ts +74 -0
- package/src/ui/avatar/animated/animations.ts +11 -0
- package/src/ui/avatar/animated/avatar-animated.tsx +25 -0
- package/src/ui/avatar/animated/index.ts +6 -0
- package/src/ui/avatar/animated/types.ts +16 -0
- package/src/ui/avatar/avatar-base.tsx +184 -0
- package/src/ui/avatar/avatar.test.tsx +51 -0
- package/src/ui/avatar/avatar.tsx +11 -0
- package/src/ui/avatar/index.ts +16 -0
- package/src/ui/avatar/types.ts +36 -0
- package/src/ui/avatar/variants.ts +52 -0
- package/src/ui/badge/animated/animations.ts +20 -0
- package/src/ui/badge/animated/badge-animated.tsx +28 -0
- package/src/ui/badge/animated/index.ts +5 -0
- package/src/ui/badge/animated/types.ts +18 -0
- package/src/ui/badge/badge-base.tsx +53 -0
- package/src/ui/badge/badge.test.tsx +48 -0
- package/src/ui/badge/badge.tsx +9 -0
- package/src/ui/badge/index.ts +5 -0
- package/src/ui/badge/types.ts +25 -0
- package/src/ui/badge/variants.ts +85 -0
- package/src/ui/breadcrumb/breadcrumb.test.tsx +62 -0
- package/src/ui/breadcrumb/breadcrumb.tsx +135 -0
- package/src/ui/breadcrumb/index.ts +28 -0
- package/src/ui/breadcrumb/types.ts +29 -0
- package/src/ui/breadcrumb/variants.ts +53 -0
- package/src/ui/buttons/animated/animations.ts +34 -0
- package/src/ui/buttons/animated/button-animated.tsx +70 -0
- package/src/ui/buttons/animated/index.ts +5 -0
- package/src/ui/buttons/animated/types.ts +29 -0
- package/src/ui/buttons/button-base.tsx +59 -0
- package/src/ui/buttons/button.test.tsx +480 -0
- package/src/ui/buttons/button.tsx +9 -0
- package/src/ui/buttons/index.ts +5 -0
- package/src/ui/buttons/types.ts +14 -0
- package/src/ui/buttons/variants.ts +77 -0
- package/src/ui/card/animated/animations.ts +32 -0
- package/src/ui/card/animated/card-animated.tsx +28 -0
- package/src/ui/card/animated/index.ts +12 -0
- package/src/ui/card/animated/types.ts +8 -0
- package/src/ui/card/card-base.tsx +146 -0
- package/src/ui/card/card.test.tsx +79 -0
- package/src/ui/card/card.tsx +11 -0
- package/src/ui/card/index.ts +21 -0
- package/src/ui/card/types.ts +42 -0
- package/src/ui/card/variants.ts +122 -0
- package/src/ui/divider/animated/animations.ts +27 -0
- package/src/ui/divider/animated/divider-animated.tsx +24 -0
- package/src/ui/divider/animated/index.ts +4 -0
- package/src/ui/divider/animated/types.ts +18 -0
- package/src/ui/divider/divider-base.tsx +80 -0
- package/src/ui/divider/divider.tsx +9 -0
- package/src/ui/divider/index.ts +14 -0
- package/src/ui/divider/types.ts +18 -0
- package/src/ui/divider/variants.ts +98 -0
- package/src/ui/drawer/animated/animations.ts +39 -0
- package/src/ui/drawer/animated/drawer-content-animated.tsx +101 -0
- package/src/ui/drawer/animated/index.ts +14 -0
- package/src/ui/drawer/animated/types.ts +18 -0
- package/src/ui/drawer/drawer-base.tsx +259 -0
- package/src/ui/drawer/drawer.test.tsx +132 -0
- package/src/ui/drawer/drawer.tsx +11 -0
- package/src/ui/drawer/index.ts +21 -0
- package/src/ui/drawer/types.ts +39 -0
- package/src/ui/drawer/variants.ts +122 -0
- package/src/ui/dropdown/dropdown.test.tsx +114 -0
- package/src/ui/dropdown/dropdown.tsx +179 -0
- package/src/ui/dropdown/index.ts +15 -0
- package/src/ui/dropdown/types.ts +68 -0
- package/src/ui/dropdown/variants.ts +138 -0
- package/src/ui/empty-state/animated/animations.ts +19 -0
- package/src/ui/empty-state/animated/empty-state-animated.tsx +23 -0
- package/src/ui/empty-state/animated/index.ts +7 -0
- package/src/ui/empty-state/animated/types.ts +26 -0
- package/src/ui/empty-state/empty-state-base.tsx +114 -0
- package/src/ui/empty-state/empty-state.tsx +9 -0
- package/src/ui/empty-state/index.ts +10 -0
- package/src/ui/empty-state/types.ts +19 -0
- package/src/ui/empty-state/variants.ts +51 -0
- package/src/ui/file-upload/file-upload.test.tsx +36 -0
- package/src/ui/file-upload/file-upload.tsx +119 -0
- package/src/ui/file-upload/index.ts +5 -0
- package/src/ui/file-upload/types.ts +21 -0
- package/src/ui/file-upload/variants.ts +29 -0
- package/src/ui/inputs/animated/animations.ts +36 -0
- package/src/ui/inputs/animated/index.ts +5 -0
- package/src/ui/inputs/animated/input-animated.tsx +124 -0
- package/src/ui/inputs/animated/types.ts +40 -0
- package/src/ui/inputs/index.ts +5 -0
- package/src/ui/inputs/input-base.tsx +114 -0
- package/src/ui/inputs/input.test.tsx +414 -0
- package/src/ui/inputs/input.tsx +8 -0
- package/src/ui/inputs/types.ts +18 -0
- package/src/ui/inputs/variants.ts +316 -0
- package/src/ui/modal/animated/animations.ts +29 -0
- package/src/ui/modal/animated/index.ts +5 -0
- package/src/ui/modal/animated/modal-content-animated.tsx +96 -0
- package/src/ui/modal/animated/types.ts +23 -0
- package/src/ui/modal/index.ts +21 -0
- package/src/ui/modal/modal-base.tsx +279 -0
- package/src/ui/modal/modal.test.tsx +129 -0
- package/src/ui/modal/modal.tsx +8 -0
- package/src/ui/modal/types.ts +31 -0
- package/src/ui/modal/variants.ts +109 -0
- package/src/ui/pagination/index.ts +13 -0
- package/src/ui/pagination/pagination.test.tsx +165 -0
- package/src/ui/pagination/pagination.tsx +237 -0
- package/src/ui/pagination/types.ts +66 -0
- package/src/ui/pagination/variants.ts +97 -0
- package/src/ui/progress/animated/animations.ts +9 -0
- package/src/ui/progress/animated/index.ts +17 -0
- package/src/ui/progress/animated/progress-animated.tsx +133 -0
- package/src/ui/progress/animated/types.ts +35 -0
- package/src/ui/progress/index.ts +10 -0
- package/src/ui/progress/progress-base.tsx +151 -0
- package/src/ui/progress/progress.test.tsx +84 -0
- package/src/ui/progress/progress.tsx +12 -0
- package/src/ui/progress/types.ts +33 -0
- package/src/ui/progress/variants.ts +105 -0
- package/src/ui/select/index.ts +25 -0
- package/src/ui/select/select.test.tsx +128 -0
- package/src/ui/select/select.tsx +221 -0
- package/src/ui/select/types.ts +77 -0
- package/src/ui/select/variants.ts +163 -0
- package/src/ui/skeleton/animated/animations.ts +15 -0
- package/src/ui/skeleton/animated/index.ts +20 -0
- package/src/ui/skeleton/animated/skeleton-animated.tsx +119 -0
- package/src/ui/skeleton/animated/types.ts +49 -0
- package/src/ui/skeleton/index.ts +24 -0
- package/src/ui/skeleton/skeleton-base.tsx +288 -0
- package/src/ui/skeleton/skeleton.tsx +8 -0
- package/src/ui/skeleton/types.ts +31 -0
- package/src/ui/skeleton/variants.ts +254 -0
- package/src/ui/slider/index.ts +22 -0
- package/src/ui/slider/slider.test.tsx +94 -0
- package/src/ui/slider/slider.tsx +728 -0
- package/src/ui/slider/types.ts +66 -0
- package/src/ui/slider/variants.ts +81 -0
- package/src/ui/spinner/animated/index.ts +5 -0
- package/src/ui/spinner/animated/spinner.test.tsx +41 -0
- package/src/ui/spinner/animated/spinner.tsx +143 -0
- package/src/ui/spinner/animated/types.ts +11 -0
- package/src/ui/spinner/animated/variants.ts +50 -0
- package/src/ui/stepper/index.ts +22 -0
- package/src/ui/stepper/stepper.test.tsx +183 -0
- package/src/ui/stepper/stepper.tsx +172 -0
- package/src/ui/stepper/types.ts +32 -0
- package/src/ui/stepper/variants.ts +69 -0
- package/src/ui/table/animated/animations.ts +9 -0
- package/src/ui/table/animated/index.ts +15 -0
- package/src/ui/table/animated/table-animated.tsx +15 -0
- package/src/ui/table/animated/types.ts +16 -0
- package/src/ui/table/index.ts +22 -0
- package/src/ui/table/table-base.tsx +197 -0
- package/src/ui/table/table.tsx +13 -0
- package/src/ui/table/types.ts +47 -0
- package/src/ui/table/variants.ts +105 -0
- package/src/ui/tabs/animated/animations.ts +48 -0
- package/src/ui/tabs/animated/index.ts +8 -0
- package/src/ui/tabs/animated/tabs-content-animated.tsx +46 -0
- package/src/ui/tabs/animated/types.ts +24 -0
- package/src/ui/tabs/index.ts +10 -0
- package/src/ui/tabs/tabs-base.tsx +185 -0
- package/src/ui/tabs/tabs.test.tsx +53 -0
- package/src/ui/tabs/tabs.tsx +2 -0
- package/src/ui/tabs/types.ts +88 -0
- package/src/ui/tabs/variants.ts +70 -0
- package/src/ui/toast/animated/animations.ts +17 -0
- package/src/ui/toast/animated/index.ts +9 -0
- package/src/ui/toast/animated/toast-animated.tsx +96 -0
- package/src/ui/toast/animated/types.ts +13 -0
- package/src/ui/toast/index.ts +26 -0
- package/src/ui/toast/toast-base.tsx +231 -0
- package/src/ui/toast/toast.test.tsx +102 -0
- package/src/ui/toast/toast.tsx +13 -0
- package/src/ui/toast/types.ts +57 -0
- package/src/ui/toast/variants.ts +73 -0
- package/src/ui/toggle/animated/animations.ts +9 -0
- package/src/ui/toggle/animated/index.ts +7 -0
- package/src/ui/toggle/animated/toggle-animated.tsx +76 -0
- package/src/ui/toggle/animated/types.ts +13 -0
- package/src/ui/toggle/index.ts +5 -0
- package/src/ui/toggle/toggle-base.tsx +70 -0
- package/src/ui/toggle/toggle.test.tsx +44 -0
- package/src/ui/toggle/toggle.tsx +9 -0
- package/src/ui/toggle/types.ts +18 -0
- package/src/ui/toggle/variants.ts +84 -0
- package/src/ui/tooltip/animated/animations.ts +16 -0
- package/src/ui/tooltip/animated/index.ts +10 -0
- package/src/ui/tooltip/animated/tooltip-content-animated.tsx +47 -0
- package/src/ui/tooltip/animated/types.ts +19 -0
- package/src/ui/tooltip/index.ts +17 -0
- package/src/ui/tooltip/tooltip-base.tsx +152 -0
- package/src/ui/tooltip/tooltip.test.tsx +84 -0
- package/src/ui/tooltip/tooltip.tsx +8 -0
- package/src/ui/tooltip/types.ts +57 -0
- package/src/ui/tooltip/variants.ts +61 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
export const inputVariants = cva(
|
|
4
|
+
[
|
|
5
|
+
"w-full min-w-0 rounded-xl border bg-white/5 text-slate-50 shadow-[0_1px_2px_rgba(15,23,42,0.12)]",
|
|
6
|
+
"ring-offset-slate-950 transition-colors",
|
|
7
|
+
"placeholder:text-slate-500",
|
|
8
|
+
"focus-visible:outline-none",
|
|
9
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
10
|
+
"read-only:cursor-default read-only:bg-white/[0.03]",
|
|
11
|
+
"file:h-8",
|
|
12
|
+
],
|
|
13
|
+
{
|
|
14
|
+
variants: {
|
|
15
|
+
as: {
|
|
16
|
+
input: "",
|
|
17
|
+
textarea: "h-auto! resize-y py-2 align-top",
|
|
18
|
+
file: [
|
|
19
|
+
// Reset native padding so we control it fully
|
|
20
|
+
"p-0! cursor-pointer",
|
|
21
|
+
// File-selector button base styles
|
|
22
|
+
"file:cursor-pointer file:border-0 file:border-r file:border-white/10",
|
|
23
|
+
"file:bg-white/10 file:text-slate-200 file:font-medium",
|
|
24
|
+
"file:transition-colors file:duration-200",
|
|
25
|
+
"hover:file:bg-white/15",
|
|
26
|
+
// Content area padding
|
|
27
|
+
"[&:not(:disabled)]:file:hover:text-white",
|
|
28
|
+
"disabled:file:cursor-not-allowed",
|
|
29
|
+
],
|
|
30
|
+
checkbox: [
|
|
31
|
+
"shrink-0 cursor-pointer appearance-none relative",
|
|
32
|
+
"min-h-0! shadow-none outline-none",
|
|
33
|
+
"border-2 border-white/30 [&:not(:checked)]:bg-transparent",
|
|
34
|
+
"transition-[color,box-shadow,border-color,background-color]",
|
|
35
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
36
|
+
"read-only:cursor-default",
|
|
37
|
+
"checked:after:absolute checked:after:content-[''] checked:after:size-3 checked:after:top-1/2 checked:after:left-1/2 checked:after:-translate-x-1/2 checked:after:-translate-y-1/2 checked:after:rounded-full checked:after:bg-current",
|
|
38
|
+
],
|
|
39
|
+
radio: [
|
|
40
|
+
"shrink-0 cursor-pointer appearance-none rounded-full",
|
|
41
|
+
"min-h-0! shadow-none outline-none",
|
|
42
|
+
"border-2 border-white/30 bg-transparent! read-only:bg-transparent!",
|
|
43
|
+
"ring-2 ring-white/20 ring-offset-2 ring-offset-slate-950",
|
|
44
|
+
"transition-[color,box-shadow,background-color,border-color,box-shadow]",
|
|
45
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
46
|
+
"read-only:cursor-default",
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
appearance: {
|
|
50
|
+
default: "border-white/10 focus-visible:border-white/20",
|
|
51
|
+
warning:
|
|
52
|
+
"border-yellow-500/80 text-yellow-50 placeholder:text-yellow-300/70 focus-visible:border-yellow-400 focus-visible:ring-yellow-400/80",
|
|
53
|
+
error:
|
|
54
|
+
"border-rose-500/80 text-rose-50 placeholder:text-rose-300/70 focus-visible:border-rose-400 focus-visible:ring-rose-400/80",
|
|
55
|
+
success:
|
|
56
|
+
"border-emerald-500/70 text-emerald-50 placeholder:text-emerald-300/70 focus-visible:border-emerald-400 focus-visible:ring-emerald-400/80",
|
|
57
|
+
info: "border-blue-500/80 text-blue-50 placeholder:text-blue-300/70 focus-visible:border-blue-400 focus-visible:ring-blue-400/80",
|
|
58
|
+
violet:
|
|
59
|
+
"border-violet-500/80 text-violet-50 placeholder:text-violet-300/70 focus-visible:border-violet-400 focus-visible:ring-violet-400/80",
|
|
60
|
+
amber:
|
|
61
|
+
"border-amber-500/80 text-amber-50 placeholder:text-amber-300/70 focus-visible:border-amber-400 focus-visible:ring-amber-400/80",
|
|
62
|
+
pink: "border-pink-500/80 text-pink-50 placeholder:text-pink-300/70 focus-visible:border-pink-400 focus-visible:ring-pink-400/80",
|
|
63
|
+
indigo:
|
|
64
|
+
"border-indigo-500/80 text-indigo-50 placeholder:text-indigo-300/70 focus-visible:border-indigo-400 focus-visible:ring-indigo-400/80",
|
|
65
|
+
orange:
|
|
66
|
+
"border-orange-500/80 text-orange-50 placeholder:text-orange-300/70 focus-visible:border-orange-400 focus-visible:ring-orange-400/80",
|
|
67
|
+
},
|
|
68
|
+
size: {
|
|
69
|
+
sm: "h-8 px-3 text-xs",
|
|
70
|
+
md: "h-9 md:h-11 px-4 text-sm",
|
|
71
|
+
lg: "h-10 md:h-12 px-5 text-base",
|
|
72
|
+
},
|
|
73
|
+
ring: {
|
|
74
|
+
true: "focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
75
|
+
false: "",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
defaultVariants: {
|
|
79
|
+
as: "input",
|
|
80
|
+
appearance: "default",
|
|
81
|
+
size: "md",
|
|
82
|
+
ring: true,
|
|
83
|
+
},
|
|
84
|
+
compoundVariants: [
|
|
85
|
+
// ── textarea size overrides ──────────────────────────────────────────
|
|
86
|
+
{
|
|
87
|
+
as: "textarea",
|
|
88
|
+
size: "sm",
|
|
89
|
+
class: "min-h-[5rem]",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
as: "textarea",
|
|
93
|
+
size: "md",
|
|
94
|
+
class: "min-h-[6rem]",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
as: "textarea",
|
|
98
|
+
size: "lg",
|
|
99
|
+
class: "min-h-[7.5rem]",
|
|
100
|
+
},
|
|
101
|
+
// ── file input: size – height & file-button padding ──────────────────
|
|
102
|
+
{
|
|
103
|
+
as: "file",
|
|
104
|
+
size: "sm",
|
|
105
|
+
class: "h-8 text-xs pl-1 file:h-8 file:px-3 file:text-xs",
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
as: "file",
|
|
109
|
+
size: "md",
|
|
110
|
+
class:
|
|
111
|
+
"h-9 md:h-11 text-sm pl-1 file:h-9 md:file:h-11 file:px-4 file:text-sm",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
as: "file",
|
|
115
|
+
size: "lg",
|
|
116
|
+
class:
|
|
117
|
+
"h-10 md:h-12 text-base pl-1 file:h-10 md:file:h-12 file:px-5 file:text-base",
|
|
118
|
+
},
|
|
119
|
+
// ── file input: appearance – file-button accent colour ───────────────
|
|
120
|
+
{
|
|
121
|
+
as: "file",
|
|
122
|
+
appearance: "default",
|
|
123
|
+
class: "file:text-slate-200",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
as: "file",
|
|
127
|
+
appearance: "warning",
|
|
128
|
+
class:
|
|
129
|
+
"file:bg-yellow-500/20 file:text-yellow-200 file:border-yellow-500/40 hover:file:bg-yellow-500/30",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
as: "file",
|
|
133
|
+
appearance: "error",
|
|
134
|
+
class:
|
|
135
|
+
"file:bg-rose-500/20 file:text-rose-200 file:border-rose-500/40 hover:file:bg-rose-500/30",
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
as: "file",
|
|
139
|
+
appearance: "success",
|
|
140
|
+
class:
|
|
141
|
+
"file:bg-emerald-500/20 file:text-emerald-200 file:border-emerald-500/40 hover:file:bg-emerald-500/30",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
as: "file",
|
|
145
|
+
appearance: "info",
|
|
146
|
+
class:
|
|
147
|
+
"file:bg-blue-500/20 file:text-blue-200 file:border-blue-500/40 hover:file:bg-blue-500/30",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
as: "file",
|
|
151
|
+
appearance: "violet",
|
|
152
|
+
class:
|
|
153
|
+
"file:bg-violet-500/20 file:text-violet-200 file:border-violet-500/40 hover:file:bg-violet-500/30",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
as: "file",
|
|
157
|
+
appearance: "amber",
|
|
158
|
+
class:
|
|
159
|
+
"file:bg-amber-500/20 file:text-amber-200 file:border-amber-500/40 hover:file:bg-amber-500/30",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
as: "file",
|
|
163
|
+
appearance: "pink",
|
|
164
|
+
class:
|
|
165
|
+
"file:bg-pink-500/20 file:text-pink-200 file:border-pink-500/40 hover:file:bg-pink-500/30",
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
as: "file",
|
|
169
|
+
appearance: "indigo",
|
|
170
|
+
class:
|
|
171
|
+
"file:bg-indigo-500/20 file:text-indigo-200 file:border-indigo-500/40 hover:file:bg-indigo-500/30",
|
|
172
|
+
},
|
|
173
|
+
// ── checkbox / radio: size (overrides text-field height & padding) ───
|
|
174
|
+
{
|
|
175
|
+
as: "checkbox",
|
|
176
|
+
size: "sm",
|
|
177
|
+
class: "h-4! w-4! min-h-0! rounded-[0.35rem]! px-0! py-0!",
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
as: "checkbox",
|
|
181
|
+
size: "md",
|
|
182
|
+
class: "h-5! w-5! min-h-0! rounded-md! px-0! py-0!",
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
as: "checkbox",
|
|
186
|
+
size: "lg",
|
|
187
|
+
class: "h-6! w-6! min-h-0! rounded-md! px-0! py-0!",
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
as: "radio",
|
|
191
|
+
size: "sm",
|
|
192
|
+
class: "h-4! w-4! min-h-0! px-0! py-0!",
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
as: "radio",
|
|
196
|
+
size: "md",
|
|
197
|
+
class: "h-5! w-5! min-h-0! px-0! py-0!",
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
as: "radio",
|
|
201
|
+
size: "lg",
|
|
202
|
+
class: "h-6! w-6! min-h-0! px-0! py-0!",
|
|
203
|
+
},
|
|
204
|
+
// ── checkbox: appearance (border + tick color; fill stays transparent) ─
|
|
205
|
+
{
|
|
206
|
+
as: "checkbox",
|
|
207
|
+
appearance: "default",
|
|
208
|
+
class:
|
|
209
|
+
"border-slate-400/70! checked:border-slate-200 checked:text-slate-200 hover:border-slate-300 focus-visible:border-slate-300 focus-visible:ring-slate-400/70",
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
as: "checkbox",
|
|
213
|
+
appearance: "warning",
|
|
214
|
+
class:
|
|
215
|
+
"border-yellow-500/70! checked:border-yellow-400 checked:text-yellow-300 hover:border-yellow-400 focus-visible:border-yellow-400 focus-visible:ring-yellow-400/80",
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
as: "checkbox",
|
|
219
|
+
appearance: "error",
|
|
220
|
+
class:
|
|
221
|
+
"border-rose-500/70! checked:border-rose-400 checked:text-rose-300 hover:border-rose-400 focus-visible:border-rose-400 focus-visible:ring-rose-400/80",
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
as: "checkbox",
|
|
225
|
+
appearance: "success",
|
|
226
|
+
class:
|
|
227
|
+
"border-emerald-500/70! checked:border-emerald-400 checked:text-emerald-300 hover:border-emerald-400 focus-visible:border-emerald-400 focus-visible:ring-emerald-400/80",
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
as: "checkbox",
|
|
231
|
+
appearance: "info",
|
|
232
|
+
class:
|
|
233
|
+
"border-blue-500/70! checked:border-blue-400 checked:text-blue-300 hover:border-blue-400 focus-visible:border-blue-400 focus-visible:ring-blue-400/80",
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
as: "checkbox",
|
|
237
|
+
appearance: "violet",
|
|
238
|
+
class:
|
|
239
|
+
"border-violet-500/70! checked:after:bg-violet-400 checked:border-violet-400 checked:text-violet-300 hover:border-violet-400 focus-visible:border-violet-400 focus-visible:ring-violet-400/80",
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
as: "checkbox",
|
|
243
|
+
appearance: "amber",
|
|
244
|
+
class:
|
|
245
|
+
"border-amber-500/70! checked:border-amber-400! checked:text-amber-300 hover:border-amber-400! focus-visible:border-amber-400! focus-visible:ring-amber-400/80!",
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
as: "checkbox",
|
|
249
|
+
appearance: "pink",
|
|
250
|
+
class:
|
|
251
|
+
"border-pink-500/70! checked:border-pink-400 checked:text-pink-300 hover:border-pink-400 focus-visible:border-pink-400 focus-visible:ring-pink-400/80",
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
as: "checkbox",
|
|
255
|
+
appearance: "indigo",
|
|
256
|
+
class:
|
|
257
|
+
"border-indigo-500/70! checked:border-indigo-400! checked:text-indigo-300 hover:border-indigo-400! focus-visible:border-indigo-400! focus-visible:ring-indigo-400/80!",
|
|
258
|
+
},
|
|
259
|
+
// ── radio: appearance (transparent fill, inner dot, coloured offset ring) ─
|
|
260
|
+
{
|
|
261
|
+
as: "radio",
|
|
262
|
+
appearance: "default",
|
|
263
|
+
class:
|
|
264
|
+
"border-slate-400/70! checked:border-slate-200 checked:bg-transparent! checked:shadow-[inset_0_0_0_0.28rem_rgb(226,232,240)]! hover:border-slate-300 focus-visible:border-slate-300 focus-visible:ring-slate-400/70 checked:ring-2! checked:ring-offset-2! checked:ring-offset-slate-950! checked:ring-slate-300/90!",
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
as: "radio",
|
|
268
|
+
appearance: "warning",
|
|
269
|
+
class:
|
|
270
|
+
"border-yellow-500/70! checked:border-yellow-400 checked:bg-transparent! checked:shadow-[inset_0_0_0_0.28rem_rgb(250,204,21)]! hover:border-yellow-400 focus-visible:border-yellow-400 focus-visible:ring-yellow-400/80 checked:ring-2! checked:ring-offset-2! checked:ring-offset-slate-950! checked:ring-yellow-400/90!",
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
as: "radio",
|
|
274
|
+
appearance: "error",
|
|
275
|
+
class:
|
|
276
|
+
"border-rose-500/70! checked:border-rose-400 checked:bg-transparent! checked:shadow-[inset_0_0_0_0.28rem_rgb(251,113,133)]! hover:border-rose-400 focus-visible:border-rose-400 focus-visible:ring-rose-400/80 checked:ring-2! checked:ring-offset-2! checked:ring-offset-slate-950! checked:ring-rose-400/90!",
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
as: "radio",
|
|
280
|
+
appearance: "success",
|
|
281
|
+
class:
|
|
282
|
+
"border-emerald-500/70! checked:border-emerald-400 checked:bg-transparent! checked:shadow-[inset_0_0_0_0.28rem_rgb(52,211,153)]! hover:border-emerald-400 focus-visible:border-emerald-400 focus-visible:ring-emerald-400/80 checked:ring-2! checked:ring-offset-2! checked:ring-offset-slate-950! checked:ring-emerald-400/90!",
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
as: "radio",
|
|
286
|
+
appearance: "info",
|
|
287
|
+
class:
|
|
288
|
+
"border-blue-500/70! checked:border-blue-400 checked:bg-transparent! checked:shadow-[inset_0_0_0_0.28rem_rgb(96,165,250)]! hover:border-blue-400 focus-visible:border-blue-400 focus-visible:ring-blue-400/80 checked:ring-2! checked:ring-offset-2! checked:ring-offset-slate-950! checked:ring-blue-400/90!",
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
as: "radio",
|
|
292
|
+
appearance: "violet",
|
|
293
|
+
class:
|
|
294
|
+
"border-violet-500/70! checked:border-violet-400 checked:bg-transparent! checked:shadow-[inset_0_0_0_0.28rem_rgb(167,139,250)]! hover:border-violet-400 focus-visible:border-violet-400 focus-visible:ring-violet-400/80 checked:ring-2! checked:ring-offset-2! checked:ring-offset-slate-950! checked:ring-violet-400/90!",
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
as: "radio",
|
|
298
|
+
appearance: "amber",
|
|
299
|
+
class:
|
|
300
|
+
"border-amber-500/70! checked:border-amber-400 checked:bg-transparent! checked:shadow-[inset_0_0_0_0.28rem_rgb(251,191,36)]! hover:border-amber-400 focus-visible:border-amber-400 focus-visible:ring-amber-400/80 checked:ring-2! checked:ring-offset-2! checked:ring-offset-slate-950! checked:ring-amber-400/90!",
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
as: "radio",
|
|
304
|
+
appearance: "pink",
|
|
305
|
+
class:
|
|
306
|
+
"border-pink-500/70! checked:border-pink-400 checked:bg-transparent! checked:shadow-[inset_0_0_0_0.28rem_rgb(244,114,182)]! hover:border-pink-400 focus-visible:border-pink-400 focus-visible:ring-pink-400/80 checked:ring-2! checked:ring-offset-2! checked:ring-offset-slate-950! checked:ring-pink-400/90!",
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
as: "radio",
|
|
310
|
+
appearance: "indigo",
|
|
311
|
+
class:
|
|
312
|
+
"border-indigo-500/70! checked:border-indigo-400 checked:bg-transparent! checked:shadow-[inset_0_0_0_0.28rem_rgb(129,140,248)]! hover:border-indigo-400 focus-visible:border-indigo-400 focus-visible:ring-indigo-400/80 checked:ring-2! checked:ring-offset-2! checked:ring-offset-slate-950! checked:ring-indigo-400/90!",
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
},
|
|
316
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ModalAnimationPresets } from "./types";
|
|
2
|
+
|
|
3
|
+
export const modalOverlayAnimationPresets: ModalAnimationPresets = {
|
|
4
|
+
none: {},
|
|
5
|
+
fade: {
|
|
6
|
+
initial: { opacity: 0 },
|
|
7
|
+
animate: { opacity: 1 },
|
|
8
|
+
exit: { opacity: 0 },
|
|
9
|
+
transition: { duration: 0.2 },
|
|
10
|
+
},
|
|
11
|
+
scale: {
|
|
12
|
+
initial: { opacity: 0, scale: 0.96 },
|
|
13
|
+
animate: { opacity: 1, scale: 1 },
|
|
14
|
+
exit: { opacity: 0, scale: 0.96 },
|
|
15
|
+
transition: { type: "spring", stiffness: 420, damping: 32 },
|
|
16
|
+
},
|
|
17
|
+
"slide-up": {
|
|
18
|
+
initial: { opacity: 0, y: 24 },
|
|
19
|
+
animate: { opacity: 1, y: 0 },
|
|
20
|
+
exit: { opacity: 0, y: 16 },
|
|
21
|
+
transition: { type: "spring", stiffness: 380, damping: 30 },
|
|
22
|
+
},
|
|
23
|
+
"slide-down": {
|
|
24
|
+
initial: { opacity: 0, y: -24 },
|
|
25
|
+
animate: { opacity: 1, y: 0 },
|
|
26
|
+
exit: { opacity: 0, y: -16 },
|
|
27
|
+
transition: { type: "spring", stiffness: 380, damping: 30 },
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { AnimatePresence, motion, useReducedMotion } from "framer-motion";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../../lib/utils";
|
|
7
|
+
import { useFocusManagement } from "../../../hooks/useFocusManagement";
|
|
8
|
+
|
|
9
|
+
import { modalOverlayAnimationPresets } from "./animations";
|
|
10
|
+
import type { ModalContentAnimatedProps } from "./types";
|
|
11
|
+
import { modalContentVariants, modalOverlayVariants } from "../variants";
|
|
12
|
+
import { useModalContext } from "../modal-base";
|
|
13
|
+
|
|
14
|
+
export function ModalContentAnimated({
|
|
15
|
+
className,
|
|
16
|
+
size,
|
|
17
|
+
position,
|
|
18
|
+
appearance,
|
|
19
|
+
animation = "scale",
|
|
20
|
+
children,
|
|
21
|
+
ref,
|
|
22
|
+
id,
|
|
23
|
+
style,
|
|
24
|
+
}: ModalContentAnimatedProps) {
|
|
25
|
+
const { open, setOpen, titleId, descriptionId, contentRef } =
|
|
26
|
+
useModalContext("ModalContent");
|
|
27
|
+
const reduceMotion = useReducedMotion();
|
|
28
|
+
const overlayMotion =
|
|
29
|
+
modalOverlayAnimationPresets[reduceMotion ? "fade" : animation];
|
|
30
|
+
const panelMotion =
|
|
31
|
+
modalOverlayAnimationPresets[reduceMotion ? "fade" : animation];
|
|
32
|
+
|
|
33
|
+
useFocusManagement({
|
|
34
|
+
open,
|
|
35
|
+
setOpen,
|
|
36
|
+
contentRef,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const portalTarget = typeof document !== "undefined" ? document.body : null;
|
|
40
|
+
|
|
41
|
+
if (!portalTarget) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return createPortal(
|
|
46
|
+
<AnimatePresence>
|
|
47
|
+
{open ? (
|
|
48
|
+
<div className="fixed inset-0 z-50" data-slot="modal-portal">
|
|
49
|
+
<motion.button
|
|
50
|
+
type="button"
|
|
51
|
+
aria-hidden
|
|
52
|
+
tabIndex={-1}
|
|
53
|
+
data-slot="modal-overlay"
|
|
54
|
+
className={modalOverlayVariants()}
|
|
55
|
+
onClick={() => setOpen(false)}
|
|
56
|
+
initial={animation === "none" ? false : overlayMotion.initial}
|
|
57
|
+
animate={animation === "none" ? undefined : overlayMotion.animate}
|
|
58
|
+
exit={animation === "none" ? undefined : overlayMotion.exit}
|
|
59
|
+
transition={overlayMotion.transition}
|
|
60
|
+
/>
|
|
61
|
+
<motion.div
|
|
62
|
+
ref={(node) => {
|
|
63
|
+
contentRef.current = node;
|
|
64
|
+
if (typeof ref === "function") {
|
|
65
|
+
ref(node);
|
|
66
|
+
} else if (ref) {
|
|
67
|
+
(ref as React.RefObject<HTMLDivElement | null>).current = node;
|
|
68
|
+
}
|
|
69
|
+
}}
|
|
70
|
+
role="dialog"
|
|
71
|
+
aria-modal="true"
|
|
72
|
+
aria-labelledby={titleId}
|
|
73
|
+
aria-describedby={descriptionId}
|
|
74
|
+
data-slot="modal-content"
|
|
75
|
+
tabIndex={-1}
|
|
76
|
+
className={cn(
|
|
77
|
+
modalContentVariants({ size, position, appearance }),
|
|
78
|
+
className,
|
|
79
|
+
)}
|
|
80
|
+
initial={animation === "none" ? false : panelMotion.initial}
|
|
81
|
+
animate={animation === "none" ? undefined : panelMotion.animate}
|
|
82
|
+
exit={animation === "none" ? undefined : panelMotion.exit}
|
|
83
|
+
transition={panelMotion.transition}
|
|
84
|
+
id={id}
|
|
85
|
+
style={style}
|
|
86
|
+
>
|
|
87
|
+
{children}
|
|
88
|
+
</motion.div>
|
|
89
|
+
</div>
|
|
90
|
+
) : null}
|
|
91
|
+
</AnimatePresence>,
|
|
92
|
+
portalTarget,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
ModalContentAnimated.displayName = "ModalContent";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HTMLMotionProps } from "framer-motion";
|
|
2
|
+
import type { ModalContentProps } from "../types";
|
|
3
|
+
|
|
4
|
+
export type ModalAnimation =
|
|
5
|
+
| "none"
|
|
6
|
+
| "fade"
|
|
7
|
+
| "scale"
|
|
8
|
+
| "slide-up"
|
|
9
|
+
| "slide-down";
|
|
10
|
+
|
|
11
|
+
export type ModalContentAnimatedProps = ModalContentProps & {
|
|
12
|
+
animation?: ModalAnimation;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type ModalPresetMotionProps = Pick<
|
|
16
|
+
HTMLMotionProps<"div">,
|
|
17
|
+
"initial" | "animate" | "exit" | "transition"
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
export type ModalAnimationPresets = Record<
|
|
21
|
+
ModalAnimation,
|
|
22
|
+
ModalPresetMotionProps
|
|
23
|
+
>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
export { Modal } from "./modal";
|
|
4
|
+
export {
|
|
5
|
+
ModalTrigger,
|
|
6
|
+
ModalContent,
|
|
7
|
+
ModalTitle,
|
|
8
|
+
ModalBody,
|
|
9
|
+
ModalHeader,
|
|
10
|
+
ModalDescription,
|
|
11
|
+
ModalClose,
|
|
12
|
+
ModalFooter
|
|
13
|
+
} from "./modal-base";
|
|
14
|
+
export type {
|
|
15
|
+
ModalContentProps,
|
|
16
|
+
ModalProps,
|
|
17
|
+
ModalSectionProps,
|
|
18
|
+
ModalTriggerProps,
|
|
19
|
+
ModalContentVariantProps,
|
|
20
|
+
} from "./types";
|
|
21
|
+
export { modalContentVariants, modalOverlayVariants } from "./variants";
|