@ceed/cds 1.24.1-next.2 → 1.25.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.
package/dist/index.cjs CHANGED
@@ -2217,12 +2217,22 @@ var import_framer_motion17 = require("framer-motion");
2217
2217
  var import_ArrowUpwardRounded = __toESM(require("@mui/icons-material/ArrowUpwardRounded"));
2218
2218
  var EllipsisDiv = (0, import_joy25.styled)("div", {
2219
2219
  name: "DataTable",
2220
- slot: "textEllipsis"
2221
- })({
2222
- overflow: "hidden",
2223
- textOverflow: "ellipsis",
2224
- whiteSpace: "nowrap"
2225
- });
2220
+ slot: "textEllipsis",
2221
+ shouldForwardProp: (prop) => prop !== "lineClamp"
2222
+ })(
2223
+ ({ lineClamp }) => lineClamp && lineClamp > 1 ? {
2224
+ overflow: "hidden",
2225
+ display: "-webkit-box !important",
2226
+ WebkitBoxOrient: "vertical",
2227
+ WebkitLineClamp: lineClamp,
2228
+ whiteSpace: "normal",
2229
+ overflowWrap: "anywhere"
2230
+ } : {
2231
+ overflow: "hidden",
2232
+ textOverflow: "ellipsis",
2233
+ whiteSpace: "nowrap"
2234
+ }
2235
+ );
2226
2236
  var OverlayWrapper = (0, import_joy25.styled)("tr", {
2227
2237
  name: "DataTable",
2228
2238
  slot: "overlayWrapper"
@@ -2904,21 +2914,22 @@ function InfoSign(props) {
2904
2914
  var InfoSign_default = InfoSign;
2905
2915
 
2906
2916
  // src/components/DataTable/components.tsx
2907
- var TextEllipsis = ({ children }) => {
2917
+ var TextEllipsis = ({ children, lineClamp }) => {
2908
2918
  const textRef = (0, import_react24.useRef)(null);
2909
2919
  const [showTooltip, setShowTooltip] = (0, import_react24.useState)(false);
2910
2920
  (0, import_react24.useLayoutEffect)(() => {
2911
2921
  const element = textRef.current;
2912
- if (element) {
2913
- const isTextTruncated = element.scrollWidth > element.clientWidth;
2914
- setShowTooltip(isTextTruncated);
2915
- }
2916
- }, [children]);
2917
- const content = /* @__PURE__ */ import_react24.default.createElement(EllipsisDiv, { ref: textRef }, children);
2918
- if (showTooltip) {
2919
- return /* @__PURE__ */ import_react24.default.createElement(Tooltip_default, { title: children, placement: "top", onClick: (e) => e.stopPropagation() }, content);
2920
- }
2921
- return content;
2922
+ if (!element) return;
2923
+ const checkTruncation = () => {
2924
+ const isTruncated = lineClamp && lineClamp > 1 ? element.scrollHeight > element.clientHeight + 1 : element.scrollWidth > element.clientWidth;
2925
+ setShowTooltip(isTruncated);
2926
+ };
2927
+ checkTruncation();
2928
+ const ro = new ResizeObserver(checkTruncation);
2929
+ ro.observe(element);
2930
+ return () => ro.disconnect();
2931
+ }, [children, lineClamp]);
2932
+ return /* @__PURE__ */ import_react24.default.createElement(Tooltip_default, { title: showTooltip ? children : "", placement: "top", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ import_react24.default.createElement(EllipsisDiv, { ref: textRef, lineClamp }, children));
2922
2933
  };
2923
2934
  var CellTextEllipsis = ({ children }) => {
2924
2935
  const textRef = (0, import_react24.useRef)(null);
@@ -2969,7 +2980,8 @@ var HeadCell = (props) => {
2969
2980
  pinnedEndPosition,
2970
2981
  headerRef,
2971
2982
  tableColRef,
2972
- headerClassName
2983
+ headerClassName,
2984
+ headerLineClamp
2973
2985
  } = props;
2974
2986
  const theme = (0, import_joy32.useTheme)();
2975
2987
  const ref = headerRef;
@@ -3063,7 +3075,7 @@ var HeadCell = (props) => {
3063
3075
  initial: "initial",
3064
3076
  className: computedHeaderClassName
3065
3077
  },
3066
- /* @__PURE__ */ import_react24.default.createElement(Stack_default, { gap: 1, direction: "row", justifyContent: textAlign, alignItems: "center" }, textAlign === "end" && sortIcon, textAlign === "end" && infoSign, /* @__PURE__ */ import_react24.default.createElement(TextEllipsis, null, headerName ?? field, editMode && required && /* @__PURE__ */ import_react24.default.createElement(Asterisk, null, "*")), textAlign === "start" && infoSign, textAlign === "start" && sortIcon),
3078
+ /* @__PURE__ */ import_react24.default.createElement(Stack_default, { gap: 1, direction: "row", justifyContent: textAlign, alignItems: "center", sx: { minWidth: 0 } }, textAlign === "end" && sortIcon, textAlign === "end" && infoSign, /* @__PURE__ */ import_react24.default.createElement(TextEllipsis, { lineClamp: headerLineClamp }, headerName ?? field, editMode && required && /* @__PURE__ */ import_react24.default.createElement(Asterisk, null, "*")), textAlign === "start" && infoSign, textAlign === "start" && sortIcon),
3067
3079
  resizer
3068
3080
  );
3069
3081
  };
package/dist/index.js CHANGED
@@ -2091,12 +2091,22 @@ import { motion as motion17 } from "framer-motion";
2091
2091
  import SortIcon from "@mui/icons-material/ArrowUpwardRounded";
2092
2092
  var EllipsisDiv = styled8("div", {
2093
2093
  name: "DataTable",
2094
- slot: "textEllipsis"
2095
- })({
2096
- overflow: "hidden",
2097
- textOverflow: "ellipsis",
2098
- whiteSpace: "nowrap"
2099
- });
2094
+ slot: "textEllipsis",
2095
+ shouldForwardProp: (prop) => prop !== "lineClamp"
2096
+ })(
2097
+ ({ lineClamp }) => lineClamp && lineClamp > 1 ? {
2098
+ overflow: "hidden",
2099
+ display: "-webkit-box !important",
2100
+ WebkitBoxOrient: "vertical",
2101
+ WebkitLineClamp: lineClamp,
2102
+ whiteSpace: "normal",
2103
+ overflowWrap: "anywhere"
2104
+ } : {
2105
+ overflow: "hidden",
2106
+ textOverflow: "ellipsis",
2107
+ whiteSpace: "nowrap"
2108
+ }
2109
+ );
2100
2110
  var OverlayWrapper = styled8("tr", {
2101
2111
  name: "DataTable",
2102
2112
  slot: "overlayWrapper"
@@ -2787,21 +2797,22 @@ function InfoSign(props) {
2787
2797
  var InfoSign_default = InfoSign;
2788
2798
 
2789
2799
  // src/components/DataTable/components.tsx
2790
- var TextEllipsis = ({ children }) => {
2800
+ var TextEllipsis = ({ children, lineClamp }) => {
2791
2801
  const textRef = useRef5(null);
2792
2802
  const [showTooltip, setShowTooltip] = useState8(false);
2793
2803
  useLayoutEffect(() => {
2794
2804
  const element = textRef.current;
2795
- if (element) {
2796
- const isTextTruncated = element.scrollWidth > element.clientWidth;
2797
- setShowTooltip(isTextTruncated);
2798
- }
2799
- }, [children]);
2800
- const content = /* @__PURE__ */ React22.createElement(EllipsisDiv, { ref: textRef }, children);
2801
- if (showTooltip) {
2802
- return /* @__PURE__ */ React22.createElement(Tooltip_default, { title: children, placement: "top", onClick: (e) => e.stopPropagation() }, content);
2803
- }
2804
- return content;
2805
+ if (!element) return;
2806
+ const checkTruncation = () => {
2807
+ const isTruncated = lineClamp && lineClamp > 1 ? element.scrollHeight > element.clientHeight + 1 : element.scrollWidth > element.clientWidth;
2808
+ setShowTooltip(isTruncated);
2809
+ };
2810
+ checkTruncation();
2811
+ const ro = new ResizeObserver(checkTruncation);
2812
+ ro.observe(element);
2813
+ return () => ro.disconnect();
2814
+ }, [children, lineClamp]);
2815
+ return /* @__PURE__ */ React22.createElement(Tooltip_default, { title: showTooltip ? children : "", placement: "top", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React22.createElement(EllipsisDiv, { ref: textRef, lineClamp }, children));
2805
2816
  };
2806
2817
  var CellTextEllipsis = ({ children }) => {
2807
2818
  const textRef = useRef5(null);
@@ -2852,7 +2863,8 @@ var HeadCell = (props) => {
2852
2863
  pinnedEndPosition,
2853
2864
  headerRef,
2854
2865
  tableColRef,
2855
- headerClassName
2866
+ headerClassName,
2867
+ headerLineClamp
2856
2868
  } = props;
2857
2869
  const theme = useTheme();
2858
2870
  const ref = headerRef;
@@ -2946,7 +2958,7 @@ var HeadCell = (props) => {
2946
2958
  initial: "initial",
2947
2959
  className: computedHeaderClassName
2948
2960
  },
2949
- /* @__PURE__ */ React22.createElement(Stack_default, { gap: 1, direction: "row", justifyContent: textAlign, alignItems: "center" }, textAlign === "end" && sortIcon, textAlign === "end" && infoSign, /* @__PURE__ */ React22.createElement(TextEllipsis, null, headerName ?? field, editMode && required && /* @__PURE__ */ React22.createElement(Asterisk, null, "*")), textAlign === "start" && infoSign, textAlign === "start" && sortIcon),
2961
+ /* @__PURE__ */ React22.createElement(Stack_default, { gap: 1, direction: "row", justifyContent: textAlign, alignItems: "center", sx: { minWidth: 0 } }, textAlign === "end" && sortIcon, textAlign === "end" && infoSign, /* @__PURE__ */ React22.createElement(TextEllipsis, { lineClamp: headerLineClamp }, headerName ?? field, editMode && required && /* @__PURE__ */ React22.createElement(Asterisk, null, "*")), textAlign === "start" && infoSign, textAlign === "start" && sortIcon),
2950
2962
  resizer
2951
2963
  );
2952
2964
  };