@moontra/moonui-pro 2.20.2 → 2.20.3
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/package.json +8 -3
- package/plugin/index.d.ts +86 -0
- package/plugin/index.js +308 -0
- package/scripts/postinstall.js +176 -23
- package/src/components/advanced-chart/index.tsx +0 -1246
- package/src/components/advanced-forms/index.tsx +0 -585
- package/src/components/animated-button/index.tsx +0 -385
- package/src/components/calendar/event-dialog.tsx +0 -377
- package/src/components/calendar/index.tsx +0 -1220
- package/src/components/calendar-pro/index.tsx +0 -1697
- package/src/components/color-picker/index.tsx +0 -432
- package/src/components/credit-card-input/index.tsx +0 -406
- package/src/components/dashboard/dashboard-grid.tsx +0 -480
- package/src/components/dashboard/demo.tsx +0 -425
- package/src/components/dashboard/index.tsx +0 -1046
- package/src/components/dashboard/time-range-picker.tsx +0 -336
- package/src/components/dashboard/types.ts +0 -225
- package/src/components/dashboard/widgets/activity-feed.tsx +0 -349
- package/src/components/dashboard/widgets/chart-widget.tsx +0 -418
- package/src/components/dashboard/widgets/comparison-widget.tsx +0 -177
- package/src/components/dashboard/widgets/index.ts +0 -5
- package/src/components/dashboard/widgets/metric-card.tsx +0 -363
- package/src/components/dashboard/widgets/progress-widget.tsx +0 -113
- package/src/components/data-table/data-table-bulk-actions.tsx +0 -204
- package/src/components/data-table/data-table-column-toggle.tsx +0 -169
- package/src/components/data-table/data-table-export.ts +0 -156
- package/src/components/data-table/data-table-filter-drawer.tsx +0 -448
- package/src/components/data-table/index.tsx +0 -845
- package/src/components/draggable-list/index.tsx +0 -100
- package/src/components/error-boundary/index.tsx +0 -232
- package/src/components/file-upload/index.tsx +0 -1660
- package/src/components/floating-action-button/index.tsx +0 -206
- package/src/components/form-wizard/form-wizard-context.tsx +0 -335
- package/src/components/form-wizard/form-wizard-navigation.tsx +0 -118
- package/src/components/form-wizard/form-wizard-progress.tsx +0 -329
- package/src/components/form-wizard/form-wizard-step.tsx +0 -111
- package/src/components/form-wizard/index.tsx +0 -102
- package/src/components/form-wizard/types.ts +0 -77
- package/src/components/gesture-drawer/index.tsx +0 -551
- package/src/components/github-stars/github-api.ts +0 -426
- package/src/components/github-stars/hooks.ts +0 -517
- package/src/components/github-stars/index.tsx +0 -375
- package/src/components/github-stars/types.ts +0 -148
- package/src/components/github-stars/variants.tsx +0 -515
- package/src/components/health-check/index.tsx +0 -439
- package/src/components/hover-card-3d/index.tsx +0 -529
- package/src/components/index.ts +0 -130
- package/src/components/internal/index.ts +0 -78
- package/src/components/kanban/add-card-modal.tsx +0 -502
- package/src/components/kanban/card-detail-modal.tsx +0 -761
- package/src/components/kanban/index.ts +0 -13
- package/src/components/kanban/kanban.tsx +0 -1689
- package/src/components/kanban/types.ts +0 -168
- package/src/components/lazy-component/index.tsx +0 -823
- package/src/components/license-error/index.tsx +0 -31
- package/src/components/magnetic-button/index.tsx +0 -216
- package/src/components/memory-efficient-data/index.tsx +0 -1018
- package/src/components/moonui-quiz-form/index.tsx +0 -817
- package/src/components/navbar/index.tsx +0 -781
- package/src/components/optimized-image/index.tsx +0 -425
- package/src/components/performance-debugger/index.tsx +0 -613
- package/src/components/performance-monitor/index.tsx +0 -808
- package/src/components/phone-number-input/index.tsx +0 -343
- package/src/components/phone-number-input/phone-number-input-simple.tsx +0 -167
- package/src/components/pinch-zoom/index.tsx +0 -566
- package/src/components/quiz-form/index.tsx +0 -479
- package/src/components/rich-text-editor/index.tsx +0 -2322
- package/src/components/rich-text-editor/slash-commands-extension.ts +0 -230
- package/src/components/rich-text-editor/slash-commands.css +0 -35
- package/src/components/rich-text-editor/table-styles.css +0 -65
- package/src/components/sidebar/index.tsx +0 -884
- package/src/components/spotlight-card/index.tsx +0 -191
- package/src/components/swipeable-card/index.tsx +0 -100
- package/src/components/timeline/index.tsx +0 -1183
- package/src/components/ui/accordion.tsx +0 -581
- package/src/components/ui/alert-dialog.tsx +0 -141
- package/src/components/ui/alert.tsx +0 -141
- package/src/components/ui/aspect-ratio.tsx +0 -245
- package/src/components/ui/avatar.tsx +0 -155
- package/src/components/ui/badge.tsx +0 -230
- package/src/components/ui/breadcrumb.tsx +0 -216
- package/src/components/ui/button.tsx +0 -228
- package/src/components/ui/calendar.tsx +0 -387
- package/src/components/ui/card.tsx +0 -216
- package/src/components/ui/checkbox.tsx +0 -259
- package/src/components/ui/collapsible.tsx +0 -631
- package/src/components/ui/color-picker.tsx +0 -97
- package/src/components/ui/command.tsx +0 -948
- package/src/components/ui/dialog.tsx +0 -752
- package/src/components/ui/dropdown-menu.tsx +0 -706
- package/src/components/ui/gesture-drawer.tsx +0 -11
- package/src/components/ui/hover-card.tsx +0 -29
- package/src/components/ui/index.ts +0 -222
- package/src/components/ui/input.tsx +0 -224
- package/src/components/ui/label.tsx +0 -29
- package/src/components/ui/lightbox.tsx +0 -606
- package/src/components/ui/magnetic-button.tsx +0 -129
- package/src/components/ui/media-gallery.tsx +0 -611
- package/src/components/ui/navigation-menu.tsx +0 -130
- package/src/components/ui/pagination.tsx +0 -125
- package/src/components/ui/popover.tsx +0 -185
- package/src/components/ui/progress.tsx +0 -30
- package/src/components/ui/radio-group.tsx +0 -257
- package/src/components/ui/scroll-area.tsx +0 -47
- package/src/components/ui/select.tsx +0 -378
- package/src/components/ui/separator.tsx +0 -145
- package/src/components/ui/sheet.tsx +0 -139
- package/src/components/ui/skeleton.tsx +0 -20
- package/src/components/ui/slider.tsx +0 -354
- package/src/components/ui/spotlight-card.tsx +0 -119
- package/src/components/ui/switch.tsx +0 -86
- package/src/components/ui/table.tsx +0 -331
- package/src/components/ui/tabs-pro.tsx +0 -542
- package/src/components/ui/tabs.tsx +0 -54
- package/src/components/ui/textarea.tsx +0 -28
- package/src/components/ui/toast.tsx +0 -317
- package/src/components/ui/toggle.tsx +0 -119
- package/src/components/ui/tooltip.tsx +0 -151
- package/src/components/virtual-list/index.tsx +0 -668
- package/src/hooks/use-chart.ts +0 -205
- package/src/hooks/use-data-table.ts +0 -182
- package/src/hooks/use-docs-pro-access.ts +0 -13
- package/src/hooks/use-license-check.ts +0 -65
- package/src/hooks/use-subscription.ts +0 -19
- package/src/hooks/use-toast.ts +0 -15
- package/src/index.ts +0 -22
- package/src/lib/ai-providers.ts +0 -377
- package/src/lib/component-metadata.ts +0 -18
- package/src/lib/micro-interactions.ts +0 -255
- package/src/lib/paddle.ts +0 -17
- package/src/lib/utils.ts +0 -6
- package/src/patterns/login-form/index.tsx +0 -276
- package/src/patterns/login-form/types.ts +0 -67
- package/src/setupTests.ts +0 -41
- package/src/styles/advanced-chart.css +0 -239
- package/src/styles/calendar.css +0 -35
- package/src/styles/design-system.css +0 -363
- package/src/styles/index.css +0 -681
- package/src/styles/tailwind.css +0 -7
- package/src/styles/tokens.css +0 -455
- package/src/types/next-auth.d.ts +0 -21
- package/src/use-intersection-observer.tsx +0 -154
- package/src/use-local-storage.tsx +0 -71
- package/src/use-paddle.ts +0 -138
- package/src/use-performance-optimizer.ts +0 -389
- package/src/use-pro-access.ts +0 -141
- package/src/use-scroll-animation.ts +0 -219
- package/src/use-subscription.ts +0 -37
- package/src/use-toast.ts +0 -32
- package/src/utils/chart-helpers.ts +0 -357
- package/src/utils/cn.ts +0 -6
- package/src/utils/data-processing.ts +0 -151
- package/src/utils/license-validator.tsx +0 -183
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import * as SeparatorPrimitive from "@radix-ui/react-separator"
|
|
5
|
-
import { cva, type VariantProps } from "class-variance-authority"
|
|
6
|
-
|
|
7
|
-
import { cn } from "../../lib/utils"
|
|
8
|
-
|
|
9
|
-
const moonUISeparatorVariantsPro = cva(
|
|
10
|
-
"shrink-0 bg-border",
|
|
11
|
-
{
|
|
12
|
-
variants: {
|
|
13
|
-
orientation: {
|
|
14
|
-
horizontal: "h-[1px] w-full",
|
|
15
|
-
vertical: "h-full w-[1px]",
|
|
16
|
-
},
|
|
17
|
-
variant: {
|
|
18
|
-
default: "bg-border",
|
|
19
|
-
dashed: "border-dashed border-border bg-transparent",
|
|
20
|
-
dotted: "border-dotted border-border bg-transparent",
|
|
21
|
-
gradient: "bg-gradient-to-r from-transparent via-border to-transparent",
|
|
22
|
-
},
|
|
23
|
-
size: {
|
|
24
|
-
sm: "",
|
|
25
|
-
md: "",
|
|
26
|
-
lg: "",
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
compoundVariants: [
|
|
30
|
-
{
|
|
31
|
-
orientation: "horizontal",
|
|
32
|
-
variant: "dashed",
|
|
33
|
-
className: "border-t h-0",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
orientation: "vertical",
|
|
37
|
-
variant: "dashed",
|
|
38
|
-
className: "border-l w-0",
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
orientation: "horizontal",
|
|
42
|
-
variant: "dotted",
|
|
43
|
-
className: "border-t h-0",
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
orientation: "vertical",
|
|
47
|
-
variant: "dotted",
|
|
48
|
-
className: "border-l w-0",
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
orientation: "horizontal",
|
|
52
|
-
size: "sm",
|
|
53
|
-
variant: ["dashed", "dotted"],
|
|
54
|
-
className: "border-t-[0.5px]",
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
orientation: "horizontal",
|
|
58
|
-
size: "lg",
|
|
59
|
-
variant: ["dashed", "dotted"],
|
|
60
|
-
className: "border-t-2",
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
orientation: "vertical",
|
|
64
|
-
size: "sm",
|
|
65
|
-
variant: ["dashed", "dotted"],
|
|
66
|
-
className: "border-l-[0.5px]",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
orientation: "vertical",
|
|
70
|
-
size: "lg",
|
|
71
|
-
variant: ["dashed", "dotted"],
|
|
72
|
-
className: "border-l-2",
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
orientation: "horizontal",
|
|
76
|
-
size: "sm",
|
|
77
|
-
variant: ["default", "gradient"],
|
|
78
|
-
className: "h-[0.5px]",
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
orientation: "horizontal",
|
|
82
|
-
size: "lg",
|
|
83
|
-
variant: ["default", "gradient"],
|
|
84
|
-
className: "h-[2px]",
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
orientation: "vertical",
|
|
88
|
-
size: "sm",
|
|
89
|
-
variant: ["default", "gradient"],
|
|
90
|
-
className: "w-[0.5px]",
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
orientation: "vertical",
|
|
94
|
-
size: "lg",
|
|
95
|
-
variant: ["default", "gradient"],
|
|
96
|
-
className: "w-[2px]",
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
defaultVariants: {
|
|
100
|
-
orientation: "horizontal",
|
|
101
|
-
variant: "default",
|
|
102
|
-
size: "md",
|
|
103
|
-
},
|
|
104
|
-
}
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
export interface MoonUISeparatorProProps
|
|
108
|
-
extends Omit<React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>, 'orientation'>,
|
|
109
|
-
VariantProps<typeof moonUISeparatorVariantsPro> {
|
|
110
|
-
orientation?: "horizontal" | "vertical";
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const MoonUISeparatorPro = React.forwardRef<
|
|
114
|
-
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
|
115
|
-
MoonUISeparatorProProps
|
|
116
|
-
>(
|
|
117
|
-
(
|
|
118
|
-
{
|
|
119
|
-
className,
|
|
120
|
-
orientation = "horizontal",
|
|
121
|
-
variant = "default",
|
|
122
|
-
size = "md",
|
|
123
|
-
decorative = true,
|
|
124
|
-
...props
|
|
125
|
-
},
|
|
126
|
-
ref
|
|
127
|
-
) => (
|
|
128
|
-
<SeparatorPrimitive.Root
|
|
129
|
-
ref={ref}
|
|
130
|
-
decorative={decorative}
|
|
131
|
-
orientation={orientation}
|
|
132
|
-
className={cn(
|
|
133
|
-
moonUISeparatorVariantsPro({ orientation, variant, size }),
|
|
134
|
-
className
|
|
135
|
-
)}
|
|
136
|
-
{...props}
|
|
137
|
-
/>
|
|
138
|
-
)
|
|
139
|
-
)
|
|
140
|
-
MoonUISeparatorPro.displayName = SeparatorPrimitive.Root.displayName
|
|
141
|
-
|
|
142
|
-
export { MoonUISeparatorPro, moonUISeparatorVariantsPro };
|
|
143
|
-
|
|
144
|
-
// Backward compatibility exports
|
|
145
|
-
export { MoonUISeparatorPro as Separator, moonUISeparatorVariantsPro as separatorVariants }
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import * as SheetPrimitive from "@radix-ui/react-dialog"
|
|
5
|
-
import { cva, type VariantProps } from "class-variance-authority"
|
|
6
|
-
import { X } from "lucide-react"
|
|
7
|
-
import { cn } from "../../lib/utils"
|
|
8
|
-
|
|
9
|
-
const Sheet = SheetPrimitive.Root
|
|
10
|
-
|
|
11
|
-
const SheetTrigger = SheetPrimitive.Trigger
|
|
12
|
-
|
|
13
|
-
const SheetClose = SheetPrimitive.Close
|
|
14
|
-
|
|
15
|
-
const SheetPortal = SheetPrimitive.Portal
|
|
16
|
-
|
|
17
|
-
const SheetOverlay = React.forwardRef<
|
|
18
|
-
React.ElementRef<typeof SheetPrimitive.Overlay>,
|
|
19
|
-
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
|
|
20
|
-
>(({ className, ...props }, ref) => (
|
|
21
|
-
<SheetPrimitive.Overlay
|
|
22
|
-
className={cn(
|
|
23
|
-
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
24
|
-
className
|
|
25
|
-
)}
|
|
26
|
-
{...props}
|
|
27
|
-
ref={ref}
|
|
28
|
-
/>
|
|
29
|
-
))
|
|
30
|
-
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName
|
|
31
|
-
|
|
32
|
-
const sheetVariants = cva(
|
|
33
|
-
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
|
|
34
|
-
{
|
|
35
|
-
variants: {
|
|
36
|
-
side: {
|
|
37
|
-
top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
|
38
|
-
bottom:
|
|
39
|
-
"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
|
|
40
|
-
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
|
|
41
|
-
right:
|
|
42
|
-
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
defaultVariants: {
|
|
46
|
-
side: "right",
|
|
47
|
-
},
|
|
48
|
-
}
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
interface SheetContentProps
|
|
52
|
-
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
|
|
53
|
-
VariantProps<typeof sheetVariants> {}
|
|
54
|
-
|
|
55
|
-
const SheetContent = React.forwardRef<
|
|
56
|
-
React.ElementRef<typeof SheetPrimitive.Content>,
|
|
57
|
-
SheetContentProps
|
|
58
|
-
>(({ side = "right", className, children, ...props }, ref) => (
|
|
59
|
-
<SheetPortal>
|
|
60
|
-
<SheetOverlay />
|
|
61
|
-
<SheetPrimitive.Content
|
|
62
|
-
ref={ref}
|
|
63
|
-
className={cn(sheetVariants({ side }), className)}
|
|
64
|
-
{...props}
|
|
65
|
-
>
|
|
66
|
-
{children}
|
|
67
|
-
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
|
|
68
|
-
<X className="h-4 w-4" />
|
|
69
|
-
<span className="sr-only">Close</span>
|
|
70
|
-
</SheetPrimitive.Close>
|
|
71
|
-
</SheetPrimitive.Content>
|
|
72
|
-
</SheetPortal>
|
|
73
|
-
))
|
|
74
|
-
SheetContent.displayName = SheetPrimitive.Content.displayName
|
|
75
|
-
|
|
76
|
-
const SheetHeader = ({
|
|
77
|
-
className,
|
|
78
|
-
...props
|
|
79
|
-
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
80
|
-
<div
|
|
81
|
-
className={cn(
|
|
82
|
-
"flex flex-col space-y-2 text-center sm:text-left",
|
|
83
|
-
className
|
|
84
|
-
)}
|
|
85
|
-
{...props}
|
|
86
|
-
/>
|
|
87
|
-
)
|
|
88
|
-
SheetHeader.displayName = "SheetHeader"
|
|
89
|
-
|
|
90
|
-
const SheetFooter = ({
|
|
91
|
-
className,
|
|
92
|
-
...props
|
|
93
|
-
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
94
|
-
<div
|
|
95
|
-
className={cn(
|
|
96
|
-
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
97
|
-
className
|
|
98
|
-
)}
|
|
99
|
-
{...props}
|
|
100
|
-
/>
|
|
101
|
-
)
|
|
102
|
-
SheetFooter.displayName = "SheetFooter"
|
|
103
|
-
|
|
104
|
-
const SheetTitle = React.forwardRef<
|
|
105
|
-
React.ElementRef<typeof SheetPrimitive.Title>,
|
|
106
|
-
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
|
|
107
|
-
>(({ className, ...props }, ref) => (
|
|
108
|
-
<SheetPrimitive.Title
|
|
109
|
-
ref={ref}
|
|
110
|
-
className={cn("text-lg font-semibold text-foreground", className)}
|
|
111
|
-
{...props}
|
|
112
|
-
/>
|
|
113
|
-
))
|
|
114
|
-
SheetTitle.displayName = SheetPrimitive.Title.displayName
|
|
115
|
-
|
|
116
|
-
const SheetDescription = React.forwardRef<
|
|
117
|
-
React.ElementRef<typeof SheetPrimitive.Description>,
|
|
118
|
-
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
|
|
119
|
-
>(({ className, ...props }, ref) => (
|
|
120
|
-
<SheetPrimitive.Description
|
|
121
|
-
ref={ref}
|
|
122
|
-
className={cn("text-sm text-muted-foreground", className)}
|
|
123
|
-
{...props}
|
|
124
|
-
/>
|
|
125
|
-
))
|
|
126
|
-
SheetDescription.displayName = SheetPrimitive.Description.displayName
|
|
127
|
-
|
|
128
|
-
export {
|
|
129
|
-
Sheet,
|
|
130
|
-
SheetPortal,
|
|
131
|
-
SheetOverlay,
|
|
132
|
-
SheetTrigger,
|
|
133
|
-
SheetClose,
|
|
134
|
-
SheetContent,
|
|
135
|
-
SheetHeader,
|
|
136
|
-
SheetFooter,
|
|
137
|
-
SheetTitle,
|
|
138
|
-
SheetDescription,
|
|
139
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { cn } from "../../lib/utils"
|
|
4
|
-
|
|
5
|
-
interface MoonUISkeletonProProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
6
|
-
|
|
7
|
-
export function MoonUISkeletonPro({
|
|
8
|
-
className,
|
|
9
|
-
...props
|
|
10
|
-
}: MoonUISkeletonProProps) {
|
|
11
|
-
return (
|
|
12
|
-
<div
|
|
13
|
-
className={cn("animate-pulse rounded-md bg-muted", className)}
|
|
14
|
-
{...props}
|
|
15
|
-
/>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Backward compatibility export
|
|
20
|
-
export { MoonUISkeletonPro as Skeleton }
|
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
-
|
|
6
|
-
import { cn } from "../../lib/utils"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Slider Component
|
|
10
|
-
*
|
|
11
|
-
* Accessible, customizable slider component fully integrated with the theme system.
|
|
12
|
-
* Used for value ranges like volume, brightness, price ranges.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const moonUISliderVariantsPro = cva(
|
|
16
|
-
"relative flex w-full touch-none select-none items-center",
|
|
17
|
-
{
|
|
18
|
-
variants: {
|
|
19
|
-
size: {
|
|
20
|
-
sm: "h-5",
|
|
21
|
-
default: "h-6",
|
|
22
|
-
md: "h-8",
|
|
23
|
-
lg: "h-10",
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
defaultVariants: {
|
|
27
|
-
size: "default",
|
|
28
|
-
},
|
|
29
|
-
}
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
const sliderTrackVariants = cva(
|
|
33
|
-
"relative h-1.5 w-full grow overflow-hidden rounded-full",
|
|
34
|
-
{
|
|
35
|
-
variants: {
|
|
36
|
-
variant: {
|
|
37
|
-
default: "bg-muted",
|
|
38
|
-
primary: "bg-primary/20",
|
|
39
|
-
secondary: "bg-secondary/20",
|
|
40
|
-
accent: "bg-accent/20",
|
|
41
|
-
success: "bg-success/20",
|
|
42
|
-
warning: "bg-warning/20",
|
|
43
|
-
error: "bg-error/20",
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
defaultVariants: {
|
|
47
|
-
variant: "default",
|
|
48
|
-
},
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
const sliderRangeVariants = cva(
|
|
53
|
-
"absolute h-full",
|
|
54
|
-
{
|
|
55
|
-
variants: {
|
|
56
|
-
variant: {
|
|
57
|
-
default: "bg-foreground",
|
|
58
|
-
primary: "bg-primary",
|
|
59
|
-
secondary: "bg-secondary",
|
|
60
|
-
accent: "bg-accent",
|
|
61
|
-
success: "bg-success",
|
|
62
|
-
warning: "bg-warning",
|
|
63
|
-
error: "bg-error",
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
defaultVariants: {
|
|
67
|
-
variant: "primary",
|
|
68
|
-
},
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
const sliderThumbVariants = cva(
|
|
73
|
-
"block rounded-full border-2 ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
74
|
-
{
|
|
75
|
-
variants: {
|
|
76
|
-
variant: {
|
|
77
|
-
default: "border-foreground bg-background",
|
|
78
|
-
primary: "border-primary bg-background",
|
|
79
|
-
secondary: "border-secondary bg-background",
|
|
80
|
-
accent: "border-accent bg-background",
|
|
81
|
-
success: "border-success bg-background",
|
|
82
|
-
warning: "border-warning bg-background",
|
|
83
|
-
error: "border-error bg-background",
|
|
84
|
-
},
|
|
85
|
-
size: {
|
|
86
|
-
sm: "h-3 w-3",
|
|
87
|
-
default: "h-4 w-4",
|
|
88
|
-
md: "h-5 w-5",
|
|
89
|
-
lg: "h-6 w-6",
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
defaultVariants: {
|
|
93
|
-
variant: "primary",
|
|
94
|
-
size: "default",
|
|
95
|
-
},
|
|
96
|
-
}
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
// Custom type definition for component properties
|
|
100
|
-
type SliderBaseProps = {
|
|
101
|
-
/**
|
|
102
|
-
* Track variant
|
|
103
|
-
*/
|
|
104
|
-
trackVariant?: VariantProps<typeof sliderTrackVariants>["variant"];
|
|
105
|
-
/**
|
|
106
|
-
* Range variant
|
|
107
|
-
*/
|
|
108
|
-
rangeVariant?: VariantProps<typeof sliderRangeVariants>["variant"];
|
|
109
|
-
/**
|
|
110
|
-
* Thumb variant
|
|
111
|
-
*/
|
|
112
|
-
thumbVariant?: VariantProps<typeof sliderThumbVariants>["variant"];
|
|
113
|
-
/**
|
|
114
|
-
* Thumb size
|
|
115
|
-
*/
|
|
116
|
-
thumbSize?: VariantProps<typeof sliderThumbVariants>["size"];
|
|
117
|
-
/**
|
|
118
|
-
* Show value label
|
|
119
|
-
*/
|
|
120
|
-
showValueLabel?: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Value label format function
|
|
123
|
-
*/
|
|
124
|
-
valueLabelFormat?: (value: number) => string;
|
|
125
|
-
/**
|
|
126
|
-
* Value label class name
|
|
127
|
-
*/
|
|
128
|
-
valueLabelClassName?: string;
|
|
129
|
-
/**
|
|
130
|
-
* Slider value
|
|
131
|
-
*/
|
|
132
|
-
value?: number[];
|
|
133
|
-
/**
|
|
134
|
-
* Default value
|
|
135
|
-
*/
|
|
136
|
-
defaultValue?: number[];
|
|
137
|
-
/**
|
|
138
|
-
* Function called when value changes
|
|
139
|
-
*/
|
|
140
|
-
onValueChange?: (value: number[]) => void;
|
|
141
|
-
/**
|
|
142
|
-
* Minimum value
|
|
143
|
-
*/
|
|
144
|
-
min?: number;
|
|
145
|
-
/**
|
|
146
|
-
* Maximum value
|
|
147
|
-
*/
|
|
148
|
-
max?: number;
|
|
149
|
-
/**
|
|
150
|
-
* Step value
|
|
151
|
-
*/
|
|
152
|
-
step?: number;
|
|
153
|
-
/**
|
|
154
|
-
* Slider size
|
|
155
|
-
*/
|
|
156
|
-
size?: VariantProps<typeof moonUISliderVariantsPro>["size"];
|
|
157
|
-
/**
|
|
158
|
-
* Disabled state
|
|
159
|
-
*/
|
|
160
|
-
disabled?: boolean;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Merge HTML properties without defaultValue conflicts
|
|
164
|
-
type SliderProps = SliderBaseProps & Omit<React.HTMLAttributes<HTMLDivElement>, 'defaultValue'>
|
|
165
|
-
|
|
166
|
-
const MoonUISliderPro = React.forwardRef<
|
|
167
|
-
HTMLDivElement,
|
|
168
|
-
SliderProps
|
|
169
|
-
>(({
|
|
170
|
-
className,
|
|
171
|
-
size,
|
|
172
|
-
trackVariant,
|
|
173
|
-
rangeVariant,
|
|
174
|
-
thumbVariant,
|
|
175
|
-
thumbSize,
|
|
176
|
-
showValueLabel = false,
|
|
177
|
-
valueLabelFormat,
|
|
178
|
-
valueLabelClassName,
|
|
179
|
-
value,
|
|
180
|
-
defaultValue = [0],
|
|
181
|
-
onValueChange,
|
|
182
|
-
disabled,
|
|
183
|
-
...props
|
|
184
|
-
}, ref) => {
|
|
185
|
-
// Value management
|
|
186
|
-
const [sliderValue, setSliderValue] = React.useState<number[]>(
|
|
187
|
-
value as number[] || defaultValue as number[] || [0]
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
React.useEffect(() => {
|
|
191
|
-
if (value !== undefined) {
|
|
192
|
-
setSliderValue(value as number[]);
|
|
193
|
-
}
|
|
194
|
-
}, [value]);
|
|
195
|
-
|
|
196
|
-
// Format value label with proper precision handling
|
|
197
|
-
const formatValue = (val: number) => {
|
|
198
|
-
if (valueLabelFormat) {
|
|
199
|
-
return valueLabelFormat(val);
|
|
200
|
-
}
|
|
201
|
-
// Round to avoid floating point precision issues
|
|
202
|
-
const roundedValue = Math.round(val * 100) / 100;
|
|
203
|
-
return `${roundedValue}`;
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
// Calculate percentage for thumb position
|
|
207
|
-
const calculateThumbPercent = (value: number, min: number, max: number) => {
|
|
208
|
-
return ((value - min) / (max - min)) * 100;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
// Handle mouse/touch events
|
|
212
|
-
const trackRef = React.useRef<HTMLDivElement>(null);
|
|
213
|
-
|
|
214
|
-
const min = props.min || 0;
|
|
215
|
-
const max = props.max || 100;
|
|
216
|
-
const step = props.step || 1;
|
|
217
|
-
|
|
218
|
-
// Handle value change with proper precision
|
|
219
|
-
const handleValueChange = (newValues: number[]) => {
|
|
220
|
-
// Round values to avoid floating point precision issues
|
|
221
|
-
const roundedValues = newValues.map(val => {
|
|
222
|
-
if (step < 1) {
|
|
223
|
-
// For decimal steps, round to appropriate decimal places
|
|
224
|
-
const decimals = step.toString().split('.')[1]?.length || 0;
|
|
225
|
-
return Math.round(val * Math.pow(10, decimals)) / Math.pow(10, decimals);
|
|
226
|
-
}
|
|
227
|
-
return Math.round(val);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
setSliderValue(roundedValues);
|
|
231
|
-
if (onValueChange) {
|
|
232
|
-
onValueChange(roundedValues);
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
// Handle track click
|
|
237
|
-
const handleTrackClick = (event: React.MouseEvent<HTMLDivElement>) => {
|
|
238
|
-
if (disabled) return;
|
|
239
|
-
|
|
240
|
-
const track = trackRef.current;
|
|
241
|
-
if (!track) return;
|
|
242
|
-
|
|
243
|
-
const rect = track.getBoundingClientRect();
|
|
244
|
-
const percent = (event.clientX - rect.left) / rect.width;
|
|
245
|
-
const rawValue = min + percent * (max - min);
|
|
246
|
-
const steppedValue = Math.round(rawValue / step) * step;
|
|
247
|
-
const boundedValue = Math.max(min, Math.min(max, steppedValue));
|
|
248
|
-
|
|
249
|
-
const newValues = [...sliderValue];
|
|
250
|
-
// Just update the first thumb for simplicity
|
|
251
|
-
newValues[0] = boundedValue;
|
|
252
|
-
handleValueChange(newValues);
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
const handleThumbMouseDown = (index: number) => (event: React.MouseEvent) => {
|
|
256
|
-
if (disabled) return;
|
|
257
|
-
event.preventDefault();
|
|
258
|
-
|
|
259
|
-
const handleMouseMove = (moveEvent: MouseEvent) => {
|
|
260
|
-
const track = trackRef.current;
|
|
261
|
-
if (!track) return;
|
|
262
|
-
|
|
263
|
-
const rect = track.getBoundingClientRect();
|
|
264
|
-
const percent = (moveEvent.clientX - rect.left) / rect.width;
|
|
265
|
-
const rawValue = min + percent * (max - min);
|
|
266
|
-
const steppedValue = Math.round(rawValue / step) * step;
|
|
267
|
-
const boundedValue = Math.max(min, Math.min(max, steppedValue));
|
|
268
|
-
|
|
269
|
-
const newValues = [...sliderValue];
|
|
270
|
-
newValues[index] = boundedValue;
|
|
271
|
-
handleValueChange(newValues);
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
const handleMouseUp = () => {
|
|
275
|
-
document.removeEventListener('mousemove', handleMouseMove);
|
|
276
|
-
document.removeEventListener('mouseup', handleMouseUp);
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
document.addEventListener('mousemove', handleMouseMove);
|
|
280
|
-
document.addEventListener('mouseup', handleMouseUp);
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
return (
|
|
284
|
-
<div className="w-full" ref={ref} {...props}>
|
|
285
|
-
{showValueLabel && (
|
|
286
|
-
<div className={cn(
|
|
287
|
-
"flex justify-end mb-1 text-sm text-muted-foreground",
|
|
288
|
-
valueLabelClassName
|
|
289
|
-
)}>
|
|
290
|
-
{sliderValue.length === 1 ? (
|
|
291
|
-
<span>{formatValue(sliderValue[0])}</span>
|
|
292
|
-
) : (
|
|
293
|
-
<span>{formatValue(sliderValue[0])} - {formatValue(sliderValue[sliderValue.length - 1])}</span>
|
|
294
|
-
)}
|
|
295
|
-
</div>
|
|
296
|
-
)}
|
|
297
|
-
|
|
298
|
-
<div
|
|
299
|
-
className={cn(moonUISliderVariantsPro({ size }), className)}
|
|
300
|
-
data-disabled={disabled ? true : undefined}
|
|
301
|
-
>
|
|
302
|
-
{/* Track */}
|
|
303
|
-
<div
|
|
304
|
-
ref={trackRef}
|
|
305
|
-
className={cn(sliderTrackVariants({ variant: trackVariant || thumbVariant || "default" }))}
|
|
306
|
-
onClick={handleTrackClick}
|
|
307
|
-
>
|
|
308
|
-
{/* Range */}
|
|
309
|
-
<div
|
|
310
|
-
className={cn(sliderRangeVariants({ variant: rangeVariant || thumbVariant || "primary" }))}
|
|
311
|
-
style={{
|
|
312
|
-
left: '0%',
|
|
313
|
-
width: `${calculateThumbPercent(sliderValue[0], min, max)}%`,
|
|
314
|
-
}}
|
|
315
|
-
/>
|
|
316
|
-
</div>
|
|
317
|
-
|
|
318
|
-
{/* Thumbs */}
|
|
319
|
-
{sliderValue.map((value, i) => (
|
|
320
|
-
<div
|
|
321
|
-
key={i}
|
|
322
|
-
className={cn(sliderThumbVariants({
|
|
323
|
-
variant: thumbVariant || "primary",
|
|
324
|
-
size: thumbSize
|
|
325
|
-
}))}
|
|
326
|
-
style={{
|
|
327
|
-
left: `${calculateThumbPercent(value, min, max)}%`,
|
|
328
|
-
transform: 'translateX(-50%)',
|
|
329
|
-
position: 'absolute',
|
|
330
|
-
top: '50%',
|
|
331
|
-
marginTop: thumbSize === "sm" ? '-6px' : thumbSize === "lg" ? '-12px' : '-8px',
|
|
332
|
-
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
333
|
-
}}
|
|
334
|
-
onMouseDown={handleThumbMouseDown(i)}
|
|
335
|
-
aria-label={`Thumb ${i + 1}`}
|
|
336
|
-
tabIndex={disabled ? -1 : 0}
|
|
337
|
-
role="slider"
|
|
338
|
-
aria-valuemin={min}
|
|
339
|
-
aria-valuemax={max}
|
|
340
|
-
aria-valuenow={value}
|
|
341
|
-
aria-disabled={disabled}
|
|
342
|
-
/>
|
|
343
|
-
))}
|
|
344
|
-
</div>
|
|
345
|
-
</div>
|
|
346
|
-
)
|
|
347
|
-
})
|
|
348
|
-
|
|
349
|
-
MoonUISliderPro.displayName = "MoonUISliderPro"
|
|
350
|
-
|
|
351
|
-
export { MoonUISliderPro };
|
|
352
|
-
|
|
353
|
-
// Backward compatibility exports
|
|
354
|
-
export { MoonUISliderPro as Slider }
|