@srcroot/ui 0.0.61 → 0.0.63
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.js +3 -3
- package/package.json +1 -1
- package/src/registry/analytics/google-analytics.tsx +25 -23
- package/src/registry/analytics/google-tag-manager.tsx +54 -49
- package/src/registry/analytics/meta-pixel.tsx +29 -25
- package/src/registry/analytics/microsoft-clarity.tsx +19 -17
- package/src/registry/analytics/tiktok-pixel.tsx +15 -13
- package/src/registry/ui/alert.tsx +50 -48
- package/src/registry/ui/aspect-ratio.tsx +27 -25
- package/src/registry/ui/badge.tsx +40 -37
- package/src/registry/ui/breadcrumb.tsx +106 -106
- package/src/registry/ui/button-group.tsx +52 -46
- package/src/registry/ui/card.tsx +68 -58
- package/src/registry/ui/container.tsx +34 -31
- package/src/registry/ui/empty-state.tsx +32 -30
- package/src/registry/ui/form-field.tsx +79 -68
- package/src/registry/ui/image.tsx +128 -120
- package/src/registry/ui/input-group.tsx +78 -72
- package/src/registry/ui/kbd.tsx +46 -44
- package/src/registry/ui/loading-spinner.tsx +84 -80
- package/src/registry/ui/marquee.tsx +43 -45
- package/src/registry/ui/native-select.tsx +42 -40
- package/src/registry/ui/pagination.tsx +115 -101
- package/src/registry/ui/radio.tsx +96 -66
- package/src/registry/ui/skeleton.tsx +15 -14
- package/src/registry/ui/slot.tsx +56 -55
- package/src/registry/ui/text.tsx +42 -41
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import { cn } from "@/lib/utils"
|
|
3
|
-
import { buttonVariants } from "./button"
|
|
1
|
+
"use client";
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
import { buttonVariants } from "./button";
|
|
6
|
+
|
|
7
|
+
interface PaginationProps extends React.HTMLAttributes<HTMLElement> {}
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Pagination component
|
|
9
|
-
*
|
|
11
|
+
*
|
|
10
12
|
* @example
|
|
11
13
|
* <Pagination>
|
|
12
14
|
* <PaginationContent>
|
|
@@ -26,124 +28,136 @@ interface PaginationProps extends React.HTMLAttributes<HTMLElement> { }
|
|
|
26
28
|
* </Pagination>
|
|
27
29
|
*/
|
|
28
30
|
const Pagination = ({ className, ...props }: PaginationProps) => (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
Pagination.displayName = "Pagination"
|
|
31
|
+
<nav
|
|
32
|
+
role="navigation"
|
|
33
|
+
aria-label="pagination"
|
|
34
|
+
className={cn("mx-auto flex w-full justify-center", className)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
Pagination.displayName = "Pagination";
|
|
37
39
|
|
|
38
40
|
const PaginationContent = React.forwardRef<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
HTMLUListElement,
|
|
42
|
+
React.HTMLAttributes<HTMLUListElement>
|
|
41
43
|
>(({ className, ...props }, ref) => (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
))
|
|
48
|
-
PaginationContent.displayName = "PaginationContent"
|
|
44
|
+
<ul
|
|
45
|
+
ref={ref}
|
|
46
|
+
className={cn("flex flex-row items-center gap-1", className)}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
));
|
|
50
|
+
PaginationContent.displayName = "PaginationContent";
|
|
49
51
|
|
|
50
52
|
const PaginationItem = React.forwardRef<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
HTMLLIElement,
|
|
54
|
+
React.LiHTMLAttributes<HTMLLIElement>
|
|
53
55
|
>(({ className, ...props }, ref) => (
|
|
54
|
-
|
|
55
|
-
))
|
|
56
|
-
PaginationItem.displayName = "PaginationItem"
|
|
56
|
+
<li ref={ref} className={cn("", className)} {...props} />
|
|
57
|
+
));
|
|
58
|
+
PaginationItem.displayName = "PaginationItem";
|
|
57
59
|
|
|
58
60
|
interface PaginationLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
isActive?: boolean;
|
|
62
|
+
size?: "default" | "sm" | "lg" | "icon";
|
|
63
|
+
children?: React.ReactNode;
|
|
64
|
+
className?: string;
|
|
65
|
+
href?: string;
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
const PaginationLink = ({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
className,
|
|
70
|
+
isActive,
|
|
71
|
+
size = "icon",
|
|
72
|
+
...props
|
|
71
73
|
}: PaginationLinkProps) => (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
84
|
-
PaginationLink.displayName = "PaginationLink"
|
|
74
|
+
<a
|
|
75
|
+
aria-current={isActive ? "page" : undefined}
|
|
76
|
+
className={cn(
|
|
77
|
+
buttonVariants({
|
|
78
|
+
variant: isActive ? "outline" : "ghost",
|
|
79
|
+
size,
|
|
80
|
+
}),
|
|
81
|
+
className,
|
|
82
|
+
)}
|
|
83
|
+
{...props}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
PaginationLink.displayName = "PaginationLink";
|
|
85
87
|
|
|
86
88
|
const PaginationPrevious = ({
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
className,
|
|
90
|
+
...props
|
|
89
91
|
}: React.ComponentProps<typeof PaginationLink>) => (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
<PaginationLink
|
|
93
|
+
aria-label="Go to previous page"
|
|
94
|
+
size="default"
|
|
95
|
+
className={cn("gap-1 pl-2.5", className)}
|
|
96
|
+
{...props}
|
|
97
|
+
>
|
|
98
|
+
<svg
|
|
99
|
+
className="h-4 w-4"
|
|
100
|
+
fill="none"
|
|
101
|
+
viewBox="0 0 24 24"
|
|
102
|
+
stroke="currentColor"
|
|
103
|
+
strokeWidth={2}
|
|
95
104
|
>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
PaginationPrevious.displayName = "PaginationPrevious"
|
|
105
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M15 19l-7-7 7-7" />
|
|
106
|
+
</svg>
|
|
107
|
+
<span>Previous</span>
|
|
108
|
+
</PaginationLink>
|
|
109
|
+
);
|
|
110
|
+
PaginationPrevious.displayName = "PaginationPrevious";
|
|
103
111
|
|
|
104
112
|
const PaginationNext = ({
|
|
105
|
-
|
|
106
|
-
|
|
113
|
+
className,
|
|
114
|
+
...props
|
|
107
115
|
}: React.ComponentProps<typeof PaginationLink>) => (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
116
|
+
<PaginationLink
|
|
117
|
+
aria-label="Go to next page"
|
|
118
|
+
size="default"
|
|
119
|
+
className={cn("gap-1 pr-2.5", className)}
|
|
120
|
+
{...props}
|
|
121
|
+
>
|
|
122
|
+
<span>Next</span>
|
|
123
|
+
<svg
|
|
124
|
+
className="h-4 w-4"
|
|
125
|
+
fill="none"
|
|
126
|
+
viewBox="0 0 24 24"
|
|
127
|
+
stroke="currentColor"
|
|
128
|
+
strokeWidth={2}
|
|
113
129
|
>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
)
|
|
120
|
-
PaginationNext.displayName = "PaginationNext"
|
|
130
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M9 5l7 7-7 7" />
|
|
131
|
+
</svg>
|
|
132
|
+
</PaginationLink>
|
|
133
|
+
);
|
|
134
|
+
PaginationNext.displayName = "PaginationNext";
|
|
121
135
|
|
|
122
136
|
const PaginationEllipsis = ({
|
|
123
|
-
|
|
124
|
-
|
|
137
|
+
className,
|
|
138
|
+
...props
|
|
125
139
|
}: React.HTMLAttributes<HTMLSpanElement>) => (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
)
|
|
139
|
-
PaginationEllipsis.displayName = "PaginationEllipsis"
|
|
140
|
+
<span
|
|
141
|
+
aria-hidden
|
|
142
|
+
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
|
143
|
+
{...props}
|
|
144
|
+
>
|
|
145
|
+
<svg className="h-4 w-4" fill="currentColor" viewBox="0 0 24 24">
|
|
146
|
+
<circle cx="12" cy="12" r="1" />
|
|
147
|
+
<circle cx="19" cy="12" r="1" />
|
|
148
|
+
<circle cx="5" cy="12" r="1" />
|
|
149
|
+
</svg>
|
|
150
|
+
<span className="sr-only">More pages</span>
|
|
151
|
+
</span>
|
|
152
|
+
);
|
|
153
|
+
PaginationEllipsis.displayName = "PaginationEllipsis";
|
|
140
154
|
|
|
141
155
|
export {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
156
|
+
Pagination,
|
|
157
|
+
PaginationContent,
|
|
158
|
+
PaginationLink,
|
|
159
|
+
PaginationItem,
|
|
160
|
+
PaginationPrevious,
|
|
161
|
+
PaginationNext,
|
|
162
|
+
PaginationEllipsis,
|
|
163
|
+
};
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
3
4
|
|
|
4
5
|
interface RadioGroupContextValue {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
value: string;
|
|
7
|
+
onValueChange: (value: string) => void;
|
|
8
|
+
name: string;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
const RadioGroupContext = React.createContext<RadioGroupContextValue | null>(
|
|
11
|
+
const RadioGroupContext = React.createContext<RadioGroupContextValue | null>(
|
|
12
|
+
null,
|
|
13
|
+
);
|
|
11
14
|
|
|
12
|
-
interface RadioGroupProps extends Omit<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
interface RadioGroupProps extends Omit<
|
|
16
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
17
|
+
"onChange"
|
|
18
|
+
> {
|
|
19
|
+
value?: string;
|
|
20
|
+
onValueChange?: (value: string) => void;
|
|
21
|
+
defaultValue?: string;
|
|
22
|
+
name?: string;
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
/**
|
|
20
26
|
* RadioGroup component
|
|
21
|
-
*
|
|
27
|
+
*
|
|
22
28
|
* @example
|
|
23
29
|
* <RadioGroup value={value} onValueChange={setValue}>
|
|
24
30
|
* <div className="flex items-center space-x-2">
|
|
@@ -32,68 +38,92 @@ interface RadioGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "on
|
|
|
32
38
|
* </RadioGroup>
|
|
33
39
|
*/
|
|
34
40
|
const RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>(
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
(
|
|
42
|
+
{
|
|
43
|
+
className,
|
|
44
|
+
value: controlledValue,
|
|
45
|
+
onValueChange,
|
|
46
|
+
defaultValue = "",
|
|
47
|
+
name = "radio-group",
|
|
48
|
+
children,
|
|
49
|
+
...props
|
|
50
|
+
},
|
|
51
|
+
ref,
|
|
52
|
+
) => {
|
|
53
|
+
const [uncontrolledValue, setUncontrolledValue] =
|
|
54
|
+
React.useState(defaultValue);
|
|
37
55
|
|
|
38
|
-
|
|
39
|
-
|
|
56
|
+
const value =
|
|
57
|
+
controlledValue !== undefined ? controlledValue : uncontrolledValue;
|
|
58
|
+
const setValue = onValueChange || setUncontrolledValue;
|
|
40
59
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
return (
|
|
61
|
+
<RadioGroupContext.Provider
|
|
62
|
+
value={{ value, onValueChange: setValue, name }}
|
|
63
|
+
>
|
|
64
|
+
<div
|
|
65
|
+
ref={ref}
|
|
66
|
+
role="radiogroup"
|
|
67
|
+
className={cn("grid gap-2", className)}
|
|
68
|
+
{...props}
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
71
|
+
</div>
|
|
72
|
+
</RadioGroupContext.Provider>
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
RadioGroup.displayName = "RadioGroup";
|
|
51
77
|
|
|
52
|
-
interface RadioGroupItemProps extends Omit<
|
|
53
|
-
|
|
78
|
+
interface RadioGroupItemProps extends Omit<
|
|
79
|
+
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
80
|
+
"onChange"
|
|
81
|
+
> {
|
|
82
|
+
value: string;
|
|
54
83
|
}
|
|
55
84
|
|
|
56
85
|
const RadioGroupItem = React.forwardRef<HTMLButtonElement, RadioGroupItemProps>(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
86
|
+
({ className, value, ...props }, ref) => {
|
|
87
|
+
const context = React.useContext(RadioGroupContext);
|
|
88
|
+
if (!context)
|
|
89
|
+
throw new Error("RadioGroupItem must be used within RadioGroup");
|
|
60
90
|
|
|
61
|
-
|
|
91
|
+
const isSelected = context.value === value;
|
|
62
92
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
93
|
+
const handleClick = () => {
|
|
94
|
+
context.onValueChange(value);
|
|
95
|
+
};
|
|
66
96
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
97
|
+
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
98
|
+
if (e.key === " " || e.key === "Enter") {
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
handleClick();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
73
103
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
97
|
-
RadioGroupItem.displayName = "RadioGroupItem"
|
|
104
|
+
return (
|
|
105
|
+
<button
|
|
106
|
+
ref={ref}
|
|
107
|
+
type="button"
|
|
108
|
+
role="radio"
|
|
109
|
+
aria-checked={isSelected}
|
|
110
|
+
className={cn(
|
|
111
|
+
"aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
112
|
+
className,
|
|
113
|
+
)}
|
|
114
|
+
onClick={handleClick}
|
|
115
|
+
onKeyDown={handleKeyDown}
|
|
116
|
+
{...props}
|
|
117
|
+
>
|
|
118
|
+
{isSelected && (
|
|
119
|
+
<span className="flex items-center justify-center">
|
|
120
|
+
<span className="h-2 w-2 rounded-full bg-primary" />
|
|
121
|
+
</span>
|
|
122
|
+
)}
|
|
123
|
+
</button>
|
|
124
|
+
);
|
|
125
|
+
},
|
|
126
|
+
);
|
|
127
|
+
RadioGroupItem.displayName = "RadioGroupItem";
|
|
98
128
|
|
|
99
|
-
export { RadioGroup, RadioGroupItem }
|
|
129
|
+
export { RadioGroup, RadioGroupItem };
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Skeleton loading placeholder
|
|
6
|
-
*
|
|
7
|
+
*
|
|
7
8
|
* @example
|
|
8
9
|
* <Skeleton className="h-4 w-[200px]" />
|
|
9
|
-
*
|
|
10
|
+
*
|
|
10
11
|
* @example
|
|
11
12
|
* // Circle skeleton for avatars
|
|
12
13
|
* <Skeleton className="h-12 w-12 rounded-full" />
|
|
13
14
|
*/
|
|
14
15
|
const Skeleton = React.forwardRef<
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
HTMLDivElement,
|
|
17
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
17
18
|
>(({ className, ...props }, ref) => (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
))
|
|
24
|
-
Skeleton.displayName = "Skeleton"
|
|
19
|
+
<div
|
|
20
|
+
ref={ref}
|
|
21
|
+
className={cn("animate-pulse rounded-md bg-primary/10", className)}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
));
|
|
25
|
+
Skeleton.displayName = "Skeleton";
|
|
25
26
|
|
|
26
|
-
export { Skeleton }
|
|
27
|
+
export { Skeleton };
|
package/src/registry/ui/slot.tsx
CHANGED
|
@@ -1,69 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
3
4
|
|
|
4
5
|
export interface SlotProps extends React.HTMLAttributes<HTMLElement> {
|
|
5
|
-
|
|
6
|
+
children?: React.ReactNode;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
const Slot = React.forwardRef<HTMLElement, SlotProps>(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
({ children, className, ...props }, ref) => {
|
|
11
|
+
if (React.isValidElement(children)) {
|
|
12
|
+
const child = children as React.ReactElement<any>;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const mergedProps: Record<string, any> = { ...props };
|
|
15
|
+
if (className) {
|
|
16
|
+
mergedProps.className = className;
|
|
17
|
+
}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
for (const propName in child.props) {
|
|
20
|
+
const slotPropValue = mergedProps[propName];
|
|
21
|
+
const childPropValue = child.props[propName];
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
} else if (propName === "style") {
|
|
34
|
-
mergedProps[propName] = { ...slotPropValue, ...childPropValue }
|
|
35
|
-
} else if (propName === "className") {
|
|
36
|
-
mergedProps[propName] = cn(slotPropValue, childPropValue)
|
|
37
|
-
} else {
|
|
38
|
-
mergedProps[propName] = childPropValue
|
|
39
|
-
}
|
|
23
|
+
if (
|
|
24
|
+
/^on[A-Z]/.test(propName) &&
|
|
25
|
+
typeof slotPropValue === "function" &&
|
|
26
|
+
typeof childPropValue === "function"
|
|
27
|
+
) {
|
|
28
|
+
mergedProps[propName] = (...args: any[]) => {
|
|
29
|
+
childPropValue(...args);
|
|
30
|
+
if (!args[0]?.defaultPrevented) {
|
|
31
|
+
slotPropValue(...args);
|
|
40
32
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
} else if (ref && "current" in ref) {
|
|
49
|
-
(ref as any).current = node
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Handle the child's existing ref
|
|
53
|
-
const childRef = (child as any).ref
|
|
54
|
-
if (typeof childRef === "function") {
|
|
55
|
-
childRef(node)
|
|
56
|
-
} else if (childRef && "current" in childRef) {
|
|
57
|
-
(childRef as any).current = node
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
})
|
|
33
|
+
};
|
|
34
|
+
} else if (propName === "style") {
|
|
35
|
+
mergedProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
36
|
+
} else if (propName === "className") {
|
|
37
|
+
mergedProps[propName] = cn(slotPropValue, childPropValue);
|
|
38
|
+
} else {
|
|
39
|
+
mergedProps[propName] = childPropValue;
|
|
61
40
|
}
|
|
41
|
+
}
|
|
62
42
|
|
|
63
|
-
|
|
43
|
+
return React.cloneElement(child, {
|
|
44
|
+
...mergedProps,
|
|
45
|
+
ref: (node: HTMLElement | null) => {
|
|
46
|
+
// Handle both function and object refs for the forwarded ref
|
|
47
|
+
if (typeof ref === "function") {
|
|
48
|
+
ref(node);
|
|
49
|
+
} else if (ref && "current" in ref) {
|
|
50
|
+
(ref as any).current = node;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Handle the child's existing ref
|
|
54
|
+
const childRef = (child as any).ref;
|
|
55
|
+
if (typeof childRef === "function") {
|
|
56
|
+
childRef(node);
|
|
57
|
+
} else if (childRef && "current" in childRef) {
|
|
58
|
+
(childRef as any).current = node;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|
|
64
62
|
}
|
|
65
|
-
)
|
|
66
63
|
|
|
67
|
-
|
|
64
|
+
return null;
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
Slot.displayName = "Slot";
|
|
68
69
|
|
|
69
|
-
export { Slot }
|
|
70
|
+
export { Slot };
|