@sustaina/shared-ui 1.65.4 → 1.65.5

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.mjs CHANGED
@@ -6296,7 +6296,7 @@ function TooltipContent({
6296
6296
  "data-slot": "tooltip-content",
6297
6297
  sideOffset,
6298
6298
  className: cn(
6299
- "bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
6299
+ "bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance whitespace-pre-wrap",
6300
6300
  className
6301
6301
  ),
6302
6302
  ...props,
@@ -6742,6 +6742,7 @@ var Truncated = ({
6742
6742
  const [isTruncated, setIsTruncated] = React.useState(false);
6743
6743
  const [measureWidth, setMeasureWidth] = React.useState(0);
6744
6744
  const Comp = as;
6745
+ const isStringChildren = typeof children === "string";
6745
6746
  const normalizedChildren = typeof children === "string" ? children.replace(/>/g, ">\u200B") : children;
6746
6747
  const lineClampLines = typeof ellipsis === "number" ? ellipsis : typeof ellipsis === "object" ? ellipsis?.lineClamp ?? 3 : null;
6747
6748
  const enableMeasure = Boolean(ellipsis) && !tooltipProps?.disabled;
@@ -6781,19 +6782,31 @@ var Truncated = ({
6781
6782
  overflow: "hidden"
6782
6783
  };
6783
6784
  }, [lineClampLines, style]);
6784
- const baseContent = /* @__PURE__ */ jsx(Comp, { ref: elementRef, className: cn(truncationClass, className), style: clampedStyle, children: /* @__PURE__ */ jsx(
6785
- EllipsisMeasure,
6785
+ const contentWhitespaceClass = React.useMemo(() => {
6786
+ if (!isStringChildren) return void 0;
6787
+ return truncationClass === "truncate" ? "whitespace-pre" : "whitespace-pre-wrap";
6788
+ }, [isStringChildren, truncationClass]);
6789
+ const baseContent = /* @__PURE__ */ jsx(
6790
+ Comp,
6786
6791
  {
6787
- enableMeasure,
6788
- text: normalizedChildren,
6789
- width: measureWidth,
6790
- rows: lineClampLines ?? 1,
6791
- expanded: false,
6792
- miscDeps: [truncationClass],
6793
- onEllipsis: setIsTruncated,
6794
- children: () => normalizedChildren
6792
+ ref: elementRef,
6793
+ className: cn(truncationClass, contentWhitespaceClass, className),
6794
+ style: clampedStyle,
6795
+ children: /* @__PURE__ */ jsx(
6796
+ EllipsisMeasure,
6797
+ {
6798
+ enableMeasure,
6799
+ text: normalizedChildren,
6800
+ width: measureWidth,
6801
+ rows: lineClampLines ?? 1,
6802
+ expanded: false,
6803
+ miscDeps: [truncationClass],
6804
+ onEllipsis: setIsTruncated,
6805
+ children: () => normalizedChildren
6806
+ }
6807
+ )
6795
6808
  }
6796
- ) });
6809
+ );
6797
6810
  let tooltipContent = normalizedChildren;
6798
6811
  if (typeof ellipsis === "object") {
6799
6812
  tooltipContent = ellipsis?.content ?? normalizedChildren;
@@ -6821,6 +6834,7 @@ var Truncated = ({
6821
6834
  side: tooltipSide,
6822
6835
  className: cn(
6823
6836
  "text-white bg-sus-secondary-gray-10 max-w-xs sm:max-w-md wrap-break-word shadow-lg",
6837
+ isStringChildren && "whitespace-pre-wrap",
6824
6838
  tooltipContentClassName
6825
6839
  ),
6826
6840
  arrowClassName: cn("bg-sus-secondary-gray-10 fill-sus-secondary-gray-10", tooltipArrowClassName),
@@ -8594,7 +8608,7 @@ var sanitizeInput = (val) => {
8594
8608
  if (/[%*~^]/.test(trimmed)) return "__INVALID_WILDCARD__";
8595
8609
  if (/[%><={}\\[\]"']/u.test(trimmed)) return "__INVALID_CHAR__";
8596
8610
  if (/\p{Cc}/u.test(val)) return "__INVALID_CONTROL_CHAR__";
8597
- return trimmed.replace(/\s+/g, " ");
8611
+ return val;
8598
8612
  };
8599
8613
  var numericTypes = ["number"];
8600
8614
  var dateTypes = ["date", "datemonth"];
@@ -16240,7 +16254,10 @@ var DefaultHeader = ({
16240
16254
  "span",
16241
16255
  {
16242
16256
  ref: titleRef,
16243
- className: cn("text-lg font-semibold text-sus-green-1 truncate", classNames?.title),
16257
+ className: cn(
16258
+ "text-lg font-semibold text-sus-green-1 truncate whitespace-pre",
16259
+ classNames?.title
16260
+ ),
16244
16261
  children: title
16245
16262
  }
16246
16263
  ) : null;
@@ -16257,10 +16274,10 @@ var DefaultHeader = ({
16257
16274
  }
16258
16275
  ) : null,
16259
16276
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col min-w-0", children: [
16260
- subtitle ? /* @__PURE__ */ jsx("span", { className: cn("text-xs text-gray-500", classNames?.subtitle), children: subtitle }) : null,
16277
+ subtitle ? /* @__PURE__ */ jsx("span", { className: cn("text-xs text-gray-500 whitespace-pre-wrap", classNames?.subtitle), children: subtitle }) : null,
16261
16278
  textElement ? isTruncated ? /* @__PURE__ */ jsxs(Tooltip, { children: [
16262
16279
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: textElement }),
16263
- /* @__PURE__ */ jsx(TooltipContent, { children: title })
16280
+ /* @__PURE__ */ jsx(TooltipContent, { className: "whitespace-pre-wrap", children: title })
16264
16281
  ] }) : textElement : null
16265
16282
  ] })
16266
16283
  ] }),
@@ -17755,7 +17772,7 @@ var TruncatedMouseEnterDiv = ({
17755
17772
  ref: textRef,
17756
17773
  onMouseEnter: checkTruncation,
17757
17774
  onMouseLeave: () => setIsTruncated(false),
17758
- className: cn("truncate", className),
17775
+ className: cn("truncate whitespace-pre", className),
17759
17776
  children: value
17760
17777
  }
17761
17778
  ) }),