@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 CHANGED
@@ -104,8 +104,7 @@ interface TruncatedTextProps extends Omit<React.HTMLAttributes<HTMLSpanElement>,
104
104
  children: string;
105
105
  /**
106
106
  * Optional explicit tooltip body. Defaults to `children`. Useful when the
107
- * displayed string is formatted (e.g. with separators) but the tooltip
108
- * should show a different form.
107
+ * displayed string is formatted but the tooltip should show a different form.
109
108
  */
110
109
  tooltip?: React.ReactNode;
111
110
  /** Hover delay before the tooltip opens (ms). */
package/dist/index.d.ts CHANGED
@@ -104,8 +104,7 @@ interface TruncatedTextProps extends Omit<React.HTMLAttributes<HTMLSpanElement>,
104
104
  children: string;
105
105
  /**
106
106
  * Optional explicit tooltip body. Defaults to `children`. Useful when the
107
- * displayed string is formatted (e.g. with separators) but the tooltip
108
- * should show a different form.
107
+ * displayed string is formatted but the tooltip should show a different form.
109
108
  */
110
109
  tooltip?: React.ReactNode;
111
110
  /** Hover delay before the tooltip opens (ms). */
package/dist/index.js CHANGED
@@ -1314,20 +1314,39 @@ var React7 = __toESM(require("react"));
1314
1314
  var TooltipPrimitive2 = __toESM(require("@radix-ui/react-tooltip"));
1315
1315
  var import_jsx_runtime7 = require("react/jsx-runtime");
1316
1316
  var TruncatedText = React7.forwardRef(
1317
- ({ children, tooltip, delayDuration = 300, className, ...props }, ref) => {
1318
- const innerRef = React7.useRef(null);
1319
- React7.useImperativeHandle(ref, () => innerRef.current);
1317
+ ({ children, tooltip, delayDuration = 300, className, ...props }, forwardedRef) => {
1318
+ const [el, setEl] = React7.useState(null);
1320
1319
  const [isTruncated, setIsTruncated] = React7.useState(false);
1321
- React7.useEffect(() => {
1322
- const el = innerRef.current;
1320
+ const setRef = React7.useCallback(
1321
+ (node) => {
1322
+ setEl(node);
1323
+ if (typeof forwardedRef === "function") forwardedRef(node);
1324
+ else if (forwardedRef) {
1325
+ forwardedRef.current = node;
1326
+ }
1327
+ },
1328
+ [forwardedRef]
1329
+ );
1330
+ React7.useLayoutEffect(() => {
1323
1331
  if (!el) return;
1324
1332
  const check = () => setIsTruncated(el.scrollWidth > el.clientWidth);
1325
1333
  check();
1326
1334
  const ro = new ResizeObserver(check);
1327
1335
  ro.observe(el);
1328
1336
  return () => ro.disconnect();
1329
- }, [children]);
1330
- const span = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { ref: innerRef, className: cn("truncate", className), ...props, children });
1337
+ }, [el, children]);
1338
+ const span = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1339
+ "span",
1340
+ {
1341
+ ref: setRef,
1342
+ className: cn(
1343
+ "inline-block max-w-full min-w-0 align-bottom truncate",
1344
+ className
1345
+ ),
1346
+ ...props,
1347
+ children
1348
+ }
1349
+ );
1331
1350
  if (!isTruncated) return span;
1332
1351
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipPrimitive2.Provider, { delayDuration, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipPrimitive2.Root, { children: [
1333
1352
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipPrimitive2.Trigger, { asChild: true, children: span }),