@moontra/moonui-pro 2.2.2 → 2.2.4
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/dist/index.mjs +41089 -39395
- package/package.json +1 -2
- package/src/components/index.ts +4 -2
- package/src/components/internal/index.ts +78 -0
- package/src/components/ui/accordion.tsx +73 -0
- package/src/components/ui/alert.tsx +142 -0
- package/src/components/ui/aspect-ratio.tsx +81 -0
- package/src/components/ui/breadcrumb.tsx +221 -0
- package/src/components/ui/checkbox.tsx +2 -2
- package/src/components/ui/collapsible.tsx +135 -0
- package/src/components/ui/command.tsx +225 -0
- package/src/components/ui/dropdown-menu.tsx +18 -2
- package/src/components/ui/index.ts +157 -35
- package/src/components/ui/label.tsx +2 -2
- package/src/components/ui/pagination.tsx +122 -0
- package/src/components/ui/radio-group.tsx +261 -0
- package/src/components/ui/table.tsx +334 -0
- package/src/components/ui/toggle.tsx +56 -0
- package/src/utils/cn.ts +2 -65
- package/dist/index.d.ts +0 -850
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react"
|
|
3
|
+
import { cn } from "../../lib/utils"
|
|
4
|
+
import { ButtonProps, buttonVariants } from "./button"
|
|
5
|
+
|
|
6
|
+
const MoonUIPaginationPro = ({ className, ...props }: React.ComponentProps<"nav">) => (
|
|
7
|
+
<nav
|
|
8
|
+
role="navigation"
|
|
9
|
+
aria-label="pagination"
|
|
10
|
+
className={cn("mx-auto flex w-full justify-center", className)}
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
)
|
|
14
|
+
MoonUIPaginationPro.displayName = "PaginationPro"
|
|
15
|
+
|
|
16
|
+
const MoonUIPaginationContentPro = React.forwardRef<
|
|
17
|
+
HTMLUListElement,
|
|
18
|
+
React.ComponentProps<"ul">
|
|
19
|
+
>(({ className, ...props }, ref) => (
|
|
20
|
+
<ul
|
|
21
|
+
ref={ref}
|
|
22
|
+
className={cn("flex flex-row items-center gap-1", className)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
))
|
|
26
|
+
MoonUIPaginationContentPro.displayName = "PaginationContentPro"
|
|
27
|
+
|
|
28
|
+
const MoonUIPaginationItemPro = React.forwardRef<
|
|
29
|
+
HTMLLIElement,
|
|
30
|
+
React.ComponentProps<"li">
|
|
31
|
+
>(({ className, ...props }, ref) => (
|
|
32
|
+
<li ref={ref} className={cn("", className)} {...props} />
|
|
33
|
+
))
|
|
34
|
+
MoonUIPaginationItemPro.displayName = "PaginationItemPro"
|
|
35
|
+
|
|
36
|
+
type PaginationLinkProps = {
|
|
37
|
+
isActive?: boolean
|
|
38
|
+
} & Pick<ButtonProps, "size"> &
|
|
39
|
+
React.ComponentProps<"a">
|
|
40
|
+
|
|
41
|
+
const MoonUIPaginationLinkPro = ({
|
|
42
|
+
className,
|
|
43
|
+
isActive,
|
|
44
|
+
size = "icon",
|
|
45
|
+
...props
|
|
46
|
+
}: PaginationLinkProps) => (
|
|
47
|
+
<a
|
|
48
|
+
aria-current={isActive ? "page" : undefined}
|
|
49
|
+
className={cn(
|
|
50
|
+
MoonUIbuttonVariantsPro({
|
|
51
|
+
variant: isActive ? "outline" : "ghost",
|
|
52
|
+
size,
|
|
53
|
+
}),
|
|
54
|
+
className
|
|
55
|
+
)}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
)
|
|
59
|
+
MoonUIPaginationLinkPro.displayName = "PaginationLinkPro"
|
|
60
|
+
|
|
61
|
+
const MoonUIPaginationPreviousPro = ({
|
|
62
|
+
className,
|
|
63
|
+
...props
|
|
64
|
+
}: React.ComponentProps<typeof PaginationLink>) => (
|
|
65
|
+
<PaginationLink
|
|
66
|
+
aria-label="Go to previous page"
|
|
67
|
+
size="default"
|
|
68
|
+
className={cn("gap-1 pl-2.5", className)}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
<ChevronLeft className="h-4 w-4" />
|
|
72
|
+
<span>Previous</span>
|
|
73
|
+
</PaginationLink>
|
|
74
|
+
)
|
|
75
|
+
MoonUIPaginationPreviousPro.displayName = "PaginationPreviousPro"
|
|
76
|
+
|
|
77
|
+
const MoonUIPaginationNextPro = ({
|
|
78
|
+
className,
|
|
79
|
+
...props
|
|
80
|
+
}: React.ComponentProps<typeof PaginationLink>) => (
|
|
81
|
+
<PaginationLink
|
|
82
|
+
aria-label="Go to next page"
|
|
83
|
+
size="default"
|
|
84
|
+
className={cn("gap-1 pr-2.5", className)}
|
|
85
|
+
{...props}
|
|
86
|
+
>
|
|
87
|
+
<span>Next</span>
|
|
88
|
+
<ChevronRight className="h-4 w-4" />
|
|
89
|
+
</PaginationLink>
|
|
90
|
+
)
|
|
91
|
+
MoonUIPaginationNextPro.displayName = "PaginationNextPro"
|
|
92
|
+
|
|
93
|
+
const MoonUIPaginationEllipsisPro = ({
|
|
94
|
+
className,
|
|
95
|
+
...props
|
|
96
|
+
}: React.ComponentProps<"span">) => (
|
|
97
|
+
<span
|
|
98
|
+
aria-hidden
|
|
99
|
+
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
|
100
|
+
{...props}
|
|
101
|
+
>
|
|
102
|
+
<MoreHorizontal className="h-4 w-4" />
|
|
103
|
+
<span className="sr-only">More pages</span>
|
|
104
|
+
</span>
|
|
105
|
+
)
|
|
106
|
+
MoonUIPaginationEllipsisPro.displayName = "PaginationEllipsisPro"
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
// Internal aliases for Pro component usage
|
|
110
|
+
export const PaginationInternal = MoonUIPaginationPro
|
|
111
|
+
export const PaginationContentInternal = MoonUIPaginationContentPro
|
|
112
|
+
export const PaginationItemInternal = MoonUIPaginationItemPro
|
|
113
|
+
export const PaginationLinkInternal = MoonUIPaginationLinkPro
|
|
114
|
+
export const PaginationPreviousInternal = MoonUIPaginationPreviousPro
|
|
115
|
+
export const PaginationNextInternal = MoonUIPaginationNextPro
|
|
116
|
+
export const PaginationEllipsisInternal = MoonUIPaginationEllipsisPro
|
|
117
|
+
|
|
118
|
+
// Pro exports
|
|
119
|
+
export { MoonUIPaginationPro, MoonUIPaginationContentPro, MoonUIPaginationItemPro, MoonUIPaginationLinkPro, MoonUIPaginationPreviousPro, MoonUIPaginationNextPro, MoonUIPaginationEllipsisPro }
|
|
120
|
+
|
|
121
|
+
// Clean exports (without MoonUI prefix for easier usage)
|
|
122
|
+
export { MoonUIPaginationPro as Pagination, MoonUIPaginationContentPro as PaginationContent, MoonUIPaginationItemPro as PaginationItem, MoonUIPaginationLinkPro as PaginationLink, MoonUIPaginationPreviousPro as PaginationPrevious, MoonUIPaginationNextPro as PaginationNext, MoonUIPaginationEllipsisPro as PaginationEllipsis }
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Circle } from "lucide-react";
|
|
5
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
|
+
|
|
7
|
+
import { cn } from "../../lib/utils";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Radio Group Component
|
|
11
|
+
*
|
|
12
|
+
* Accessible, customizable, and fully integrated with the theme system radio button group.
|
|
13
|
+
* Allows users to select a single option from a group of choices.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const MoonUIradioGroupItemVariantsPro = cva(
|
|
17
|
+
"aspect-square border focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
18
|
+
{
|
|
19
|
+
variants: {
|
|
20
|
+
variant: {
|
|
21
|
+
default: "border-border bg-background text-primary",
|
|
22
|
+
outline: "border-border bg-transparent text-primary",
|
|
23
|
+
filled: "border-primary bg-primary/10 text-primary",
|
|
24
|
+
},
|
|
25
|
+
size: {
|
|
26
|
+
sm: "h-3.5 w-3.5",
|
|
27
|
+
default: "h-4 w-4",
|
|
28
|
+
md: "h-5 w-5",
|
|
29
|
+
lg: "h-6 w-6",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
variant: "default",
|
|
34
|
+
size: "default",
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
export interface RadioGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
40
|
+
/**
|
|
41
|
+
* Radio group value
|
|
42
|
+
*/
|
|
43
|
+
value?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Function to call when radio group value changes
|
|
46
|
+
*/
|
|
47
|
+
onValueChange?: (value: string) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Radio group disabled state
|
|
50
|
+
*/
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Radio group name
|
|
54
|
+
*/
|
|
55
|
+
name?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const MoonUIRadioGroupContextPro = React.createContext<{
|
|
59
|
+
value?: string;
|
|
60
|
+
onValueChange?: (value: string) => void;
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
name?: string;
|
|
63
|
+
}>({});
|
|
64
|
+
|
|
65
|
+
const MoonUIRadioGroupPro = React.forwardRef<HTMLDivElement, RadioGroupProps>(
|
|
66
|
+
({ className, value, onValueChange, disabled, name, ...props }, ref) => {
|
|
67
|
+
return (
|
|
68
|
+
<RadioGroupContext.Provider value={{ value, onValueChange, disabled, name }}>
|
|
69
|
+
<div
|
|
70
|
+
ref={ref}
|
|
71
|
+
role="radiogroup"
|
|
72
|
+
className={cn("grid gap-2", className)}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
</RadioGroupContext.Provider>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
MoonUIRadioGroupPro.displayName = "RadioGroupPro";
|
|
80
|
+
|
|
81
|
+
export interface RadioGroupItemProps
|
|
82
|
+
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'>,
|
|
83
|
+
VariantProps<typeof radioGroupItemVariants> {
|
|
84
|
+
/**
|
|
85
|
+
* Custom indicator component
|
|
86
|
+
*/
|
|
87
|
+
indicator?: React.ReactNode;
|
|
88
|
+
/**
|
|
89
|
+
* HTML id for radio button
|
|
90
|
+
*/
|
|
91
|
+
id?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Radio button value
|
|
94
|
+
*/
|
|
95
|
+
value: string;
|
|
96
|
+
/**
|
|
97
|
+
* Radio button disabled state
|
|
98
|
+
*/
|
|
99
|
+
disabled?: boolean;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const MoonUIRadioGroupItemPro = React.forwardRef<
|
|
103
|
+
HTMLInputElement,
|
|
104
|
+
RadioGroupItemProps
|
|
105
|
+
>(({ className, variant, size, indicator, id, value, disabled, ...props }, ref) => {
|
|
106
|
+
// Get context values from radio group
|
|
107
|
+
const MoonUIradioGroupPro = React.useContext(RadioGroupContext);
|
|
108
|
+
const MoonUIgeneratedIdPro = React.useId();
|
|
109
|
+
const MoonUIradioIdPro = id || generatedId;
|
|
110
|
+
const MoonUIisCheckedPro = radioGroup.value === value;
|
|
111
|
+
|
|
112
|
+
// Call onValueChange function when RadioGroupItem changes
|
|
113
|
+
const MoonUIhandleChangePro = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
114
|
+
if (radioGroup.onValueChange) {
|
|
115
|
+
radioGroup.onValueChange(e.target.value);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (props.onChange) {
|
|
119
|
+
props.onChange(e);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div className="relative flex items-center">
|
|
125
|
+
<input
|
|
126
|
+
type="radio"
|
|
127
|
+
id={radioId}
|
|
128
|
+
ref={ref}
|
|
129
|
+
value={value}
|
|
130
|
+
checked={isChecked}
|
|
131
|
+
disabled={disabled || radioGroup.disabled}
|
|
132
|
+
name={radioGroup.name}
|
|
133
|
+
onChange={handleChange}
|
|
134
|
+
className="sr-only"
|
|
135
|
+
{...props}
|
|
136
|
+
/>
|
|
137
|
+
<label
|
|
138
|
+
htmlFor={radioId}
|
|
139
|
+
className={cn(
|
|
140
|
+
radioGroupItemVariants({ variant, size }),
|
|
141
|
+
"rounded-full",
|
|
142
|
+
"focus-visible:ring-primary/50",
|
|
143
|
+
"relative inline-flex shrink-0 cursor-pointer items-center justify-center overflow-hidden",
|
|
144
|
+
disabled && "cursor-not-allowed opacity-50",
|
|
145
|
+
className
|
|
146
|
+
)}
|
|
147
|
+
>
|
|
148
|
+
<span className={cn(
|
|
149
|
+
"absolute inset-0 pointer-events-none",
|
|
150
|
+
isChecked && "flex items-center justify-center"
|
|
151
|
+
)}>
|
|
152
|
+
{isChecked && (indicator || <Circle className="h-[60%] w-[60%] fill-current text-current" />)}
|
|
153
|
+
</span>
|
|
154
|
+
</label>
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
});
|
|
158
|
+
MoonUIRadioGroupItemPro.displayName = "RadioGroupItemPro";
|
|
159
|
+
|
|
160
|
+
// Radio Label Component
|
|
161
|
+
interface RadioLabelProps extends React.HTMLAttributes<HTMLLabelElement> {
|
|
162
|
+
/**
|
|
163
|
+
* HTML id for radio button
|
|
164
|
+
*/
|
|
165
|
+
htmlFor?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Label content
|
|
168
|
+
*/
|
|
169
|
+
children: React.ReactNode;
|
|
170
|
+
/**
|
|
171
|
+
* Disabled state style
|
|
172
|
+
*/
|
|
173
|
+
disabled?: boolean;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const MoonUIRadioLabelPro = React.forwardRef<HTMLLabelElement, RadioLabelProps>(
|
|
177
|
+
({ className, htmlFor, children, disabled = false, ...props }, ref) => {
|
|
178
|
+
return (
|
|
179
|
+
<label
|
|
180
|
+
ref={ref}
|
|
181
|
+
htmlFor={htmlFor}
|
|
182
|
+
className={cn(
|
|
183
|
+
"text-sm font-medium leading-none ml-2 text-foreground",
|
|
184
|
+
disabled && "cursor-not-allowed opacity-70",
|
|
185
|
+
className
|
|
186
|
+
)}
|
|
187
|
+
{...props}
|
|
188
|
+
>
|
|
189
|
+
{children}
|
|
190
|
+
</label>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
MoonUIRadioLabelPro.displayName = "RadioLabelPro";
|
|
195
|
+
|
|
196
|
+
// Radio Item and Label combination
|
|
197
|
+
interface RadioItemWithLabelProps extends RadioGroupItemProps {
|
|
198
|
+
/**
|
|
199
|
+
* Label content
|
|
200
|
+
*/
|
|
201
|
+
label: React.ReactNode;
|
|
202
|
+
/**
|
|
203
|
+
* HTML classes for label
|
|
204
|
+
*/
|
|
205
|
+
labelClassName?: string;
|
|
206
|
+
/**
|
|
207
|
+
* HTML id for radio button
|
|
208
|
+
*/
|
|
209
|
+
id?: string;
|
|
210
|
+
/**
|
|
211
|
+
* Disabled state
|
|
212
|
+
*/
|
|
213
|
+
disabled?: boolean;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const MoonUIRadioItemWithLabelPro = React.forwardRef<
|
|
217
|
+
HTMLInputElement,
|
|
218
|
+
RadioItemWithLabelProps
|
|
219
|
+
>(({
|
|
220
|
+
id,
|
|
221
|
+
label,
|
|
222
|
+
labelClassName,
|
|
223
|
+
...radioProps
|
|
224
|
+
}, ref) => {
|
|
225
|
+
const MoonUIgeneratedIdPro = React.useId();
|
|
226
|
+
const MoonUIradioIdPro = id || generatedId;
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<div className="flex items-center">
|
|
230
|
+
<RadioGroupItem ref={ref} id={radioId} {...radioProps} />
|
|
231
|
+
<RadioLabel
|
|
232
|
+
htmlFor={radioId}
|
|
233
|
+
disabled={radioProps.disabled}
|
|
234
|
+
className={labelClassName}
|
|
235
|
+
>
|
|
236
|
+
{label}
|
|
237
|
+
</RadioLabel>
|
|
238
|
+
</div>
|
|
239
|
+
);
|
|
240
|
+
});
|
|
241
|
+
MoonUIRadioItemWithLabelPro.displayName = "RadioItemWithLabelPro";
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
// Internal aliases for Pro component usage
|
|
245
|
+
export const radioGroupItemVariantsInternal = MoonUIradioGroupItemVariantsPro
|
|
246
|
+
export const RadioGroupContextInternal = MoonUIRadioGroupContextPro
|
|
247
|
+
export const RadioGroupInternal = MoonUIRadioGroupPro
|
|
248
|
+
export const RadioGroupItemInternal = MoonUIRadioGroupItemPro
|
|
249
|
+
export const radioGroupInternal = MoonUIradioGroupPro
|
|
250
|
+
export const generatedIdInternal = MoonUIgeneratedIdPro
|
|
251
|
+
export const radioIdInternal = MoonUIradioIdPro
|
|
252
|
+
export const isCheckedInternal = MoonUIisCheckedPro
|
|
253
|
+
export const handleChangeInternal = MoonUIhandleChangePro
|
|
254
|
+
export const RadioLabelInternal = MoonUIRadioLabelPro
|
|
255
|
+
export const RadioItemWithLabelInternal = MoonUIRadioItemWithLabelPro
|
|
256
|
+
|
|
257
|
+
// Pro exports
|
|
258
|
+
export { MoonUIradioGroupItemVariantsPro, MoonUIRadioGroupContextPro, MoonUIRadioGroupPro, MoonUIRadioGroupItemPro, MoonUIgeneratedIdPro, MoonUIradioIdPro, MoonUIisCheckedPro, MoonUIhandleChangePro, MoonUIRadioLabelPro, MoonUIRadioItemWithLabelPro }
|
|
259
|
+
|
|
260
|
+
// Clean exports (without MoonUI prefix for easier usage)
|
|
261
|
+
export { MoonUIradioGroupItemVariantsPro as radioGroupItemVariants, MoonUIRadioGroupContextPro as RadioGroupContext, MoonUIRadioGroupPro as RadioGroup, MoonUIRadioGroupItemPro as RadioGroupItem, MoonUIgeneratedIdPro as generatedId, MoonUIradioIdPro as radioId, MoonUIisCheckedPro as isChecked, MoonUIhandleChangePro as handleChange, MoonUIRadioLabelPro as RadioLabel, MoonUIRadioItemWithLabelPro as RadioItemWithLabel };
|