@choice-ui/react 1.4.9 → 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 childProps = children.props;
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 childProps = children.props;
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 childProps = children.props;
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,2 +1,2 @@
1
- import { default as React } from 'react';
2
- export declare const TooltipTrigger: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
1
+ import { HTMLProps } from 'react';
2
+ export declare const TooltipTrigger: import('react').ForwardRefExoticComponent<Omit<HTMLProps<HTMLElement>, "ref"> & import('react').RefAttributes<HTMLElement>>;
@@ -1,13 +1,12 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Slot } from "../../../slot/dist/index.js";
3
3
  import { useMergeRefs } from "@floating-ui/react";
4
- import React, { forwardRef } from "react";
4
+ import { forwardRef } from "react";
5
5
  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 childrenRef = React.isValidElement(children) ? children.props.ref : void 0;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choice-ui/react",
3
- "version": "1.4.9",
3
+ "version": "1.5.0",
4
4
  "description": "A desktop-first React UI component library built for professional desktop applications with comprehensive documentation",
5
5
  "sideEffects": false,
6
6
  "type": "module",