@choice-ui/react 1.4.8 → 1.5.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.
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React, { forwardRef, useMemo } from "react";
|
|
3
|
+
const REACT_MAJOR = parseInt(React.version.split(".")[0], 10);
|
|
4
|
+
const IS_REACT_19 = REACT_MAJOR >= 19;
|
|
5
|
+
function getChildRef(children) {
|
|
6
|
+
if (IS_REACT_19) {
|
|
7
|
+
return children.props.ref;
|
|
8
|
+
}
|
|
9
|
+
return children.ref;
|
|
10
|
+
}
|
|
3
11
|
const Slot = forwardRef(
|
|
4
12
|
({ children, ...slotProps }, forwardedRef) => {
|
|
5
13
|
const slottedChild = useMemo(() => {
|
|
6
14
|
if (!React.isValidElement(children)) {
|
|
7
15
|
return children;
|
|
8
16
|
}
|
|
9
|
-
const
|
|
10
|
-
const childRef = childProps.ref;
|
|
17
|
+
const childRef = getChildRef(children);
|
|
11
18
|
const mergedProps = mergeProps(slotProps, children.props);
|
|
12
19
|
return React.cloneElement(children, {
|
|
13
20
|
...mergedProps,
|
|
@@ -24,8 +31,7 @@ const SlotClone = forwardRef(
|
|
|
24
31
|
if (!React.isValidElement(children)) {
|
|
25
32
|
return children;
|
|
26
33
|
}
|
|
27
|
-
const
|
|
28
|
-
const childRef = childProps.ref;
|
|
34
|
+
const childRef = getChildRef(children);
|
|
29
35
|
const mergedProps = mergeProps(slotProps, children.props);
|
|
30
36
|
return React.cloneElement(children, {
|
|
31
37
|
...mergedProps,
|
|
@@ -83,8 +89,7 @@ function useSlot(children, slotProps, forwardedRef) {
|
|
|
83
89
|
if (!React.isValidElement(children)) {
|
|
84
90
|
return children;
|
|
85
91
|
}
|
|
86
|
-
const
|
|
87
|
-
const childRef = childProps.ref;
|
|
92
|
+
const childRef = getChildRef(children);
|
|
88
93
|
const mergedProps = mergeProps(slotProps, children.props);
|
|
89
94
|
return React.cloneElement(children, {
|
|
90
95
|
...mergedProps,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Kbd } from "../../kbd/dist/index.js";
|
|
2
2
|
import { useMergeRefs, useDelayGroup, useTransitionStyles, FloatingPortal, offset, flip, shift, arrow, useFloating, autoUpdate, useHover, useFocus, useDismiss, useRole, useInteractions } from "@floating-ui/react";
|
|
3
3
|
import { FloatingDelayGroup } from "@floating-ui/react";
|
|
4
|
-
import { forwardRef, createContext, useMemo, useState, useRef, useContext } from "react";
|
|
4
|
+
import React, { forwardRef, createContext, useMemo, useState, useRef, useContext } from "react";
|
|
5
5
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
6
6
|
import { Slot } from "../../slot/dist/index.js";
|
|
7
7
|
import { tcv, tcx } from "../../../shared/utils/tcx/tcx.js";
|
|
@@ -183,7 +183,7 @@ var TooltipContent = forwardRef(
|
|
|
183
183
|
var TooltipTrigger = forwardRef(
|
|
184
184
|
function TooltipTrigger2({ children, ...props }, propRef) {
|
|
185
185
|
const state = useTooltipState();
|
|
186
|
-
const childrenRef = children
|
|
186
|
+
const childrenRef = React.isValidElement(children) ? children.props.ref : void 0;
|
|
187
187
|
const ref = useMergeRefs([state.refs.setReference, propRef, childrenRef]);
|
|
188
188
|
return /* @__PURE__ */ jsx(
|
|
189
189
|
Slot,
|
|
@@ -6,8 +6,7 @@ import { useTooltipState } from "../context/tooltip-context.js";
|
|
|
6
6
|
const TooltipTrigger = forwardRef(
|
|
7
7
|
function TooltipTrigger2({ children, ...props }, propRef) {
|
|
8
8
|
const state = useTooltipState();
|
|
9
|
-
const
|
|
10
|
-
const ref = useMergeRefs([state.refs.setReference, propRef, childrenRef]);
|
|
9
|
+
const ref = useMergeRefs([state.refs.setReference, propRef]);
|
|
11
10
|
return /* @__PURE__ */ jsx(
|
|
12
11
|
Slot,
|
|
13
12
|
{
|
package/package.json
CHANGED