@l3mpire/ui 2.26.2 → 2.26.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/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +26 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1133,20 +1133,39 @@ import * as React7 from "react";
|
|
|
1133
1133
|
import * as TooltipPrimitive2 from "@radix-ui/react-tooltip";
|
|
1134
1134
|
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1135
1135
|
var TruncatedText = React7.forwardRef(
|
|
1136
|
-
({ children, tooltip, delayDuration = 300, className, ...props },
|
|
1137
|
-
const
|
|
1138
|
-
React7.useImperativeHandle(ref, () => innerRef.current);
|
|
1136
|
+
({ children, tooltip, delayDuration = 300, className, ...props }, forwardedRef) => {
|
|
1137
|
+
const [el, setEl] = React7.useState(null);
|
|
1139
1138
|
const [isTruncated, setIsTruncated] = React7.useState(false);
|
|
1140
|
-
React7.
|
|
1141
|
-
|
|
1139
|
+
const setRef = React7.useCallback(
|
|
1140
|
+
(node) => {
|
|
1141
|
+
setEl(node);
|
|
1142
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
1143
|
+
else if (forwardedRef) {
|
|
1144
|
+
forwardedRef.current = node;
|
|
1145
|
+
}
|
|
1146
|
+
},
|
|
1147
|
+
[forwardedRef]
|
|
1148
|
+
);
|
|
1149
|
+
React7.useLayoutEffect(() => {
|
|
1142
1150
|
if (!el) return;
|
|
1143
1151
|
const check = () => setIsTruncated(el.scrollWidth > el.clientWidth);
|
|
1144
1152
|
check();
|
|
1145
1153
|
const ro = new ResizeObserver(check);
|
|
1146
1154
|
ro.observe(el);
|
|
1147
1155
|
return () => ro.disconnect();
|
|
1148
|
-
}, [children]);
|
|
1149
|
-
const span = /* @__PURE__ */ jsx7(
|
|
1156
|
+
}, [el, children]);
|
|
1157
|
+
const span = /* @__PURE__ */ jsx7(
|
|
1158
|
+
"span",
|
|
1159
|
+
{
|
|
1160
|
+
ref: setRef,
|
|
1161
|
+
className: cn(
|
|
1162
|
+
"inline-block max-w-full min-w-0 align-bottom truncate",
|
|
1163
|
+
className
|
|
1164
|
+
),
|
|
1165
|
+
...props,
|
|
1166
|
+
children
|
|
1167
|
+
}
|
|
1168
|
+
);
|
|
1150
1169
|
if (!isTruncated) return span;
|
|
1151
1170
|
return /* @__PURE__ */ jsx7(TooltipPrimitive2.Provider, { delayDuration, children: /* @__PURE__ */ jsxs7(TooltipPrimitive2.Root, { children: [
|
|
1152
1171
|
/* @__PURE__ */ jsx7(TooltipPrimitive2.Trigger, { asChild: true, children: span }),
|