sag_components 2.0.0-beta191 → 2.0.0-beta193

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.js CHANGED
@@ -12262,13 +12262,16 @@ const Td$1 = styled__default["default"].td`
12262
12262
  `;
12263
12263
  const Tr = styled__default["default"].tr`
12264
12264
  border-bottom: 1px solid #f3f4f6;
12265
- ${({
12266
- enableHover,
12267
- selectHoverColor
12268
- }) => enableHover && `&:hover {
12265
+ ${_ref => {
12266
+ let {
12267
+ enableHover,
12268
+ selectHoverColor
12269
+ } = _ref;
12270
+ return enableHover && `&:hover {
12269
12271
  background-color: ${selectHoverColor};
12270
12272
  cursor: pointer;
12271
- }`}
12273
+ }`;
12274
+ }}
12272
12275
  `;
12273
12276
  const InfoText = styled__default["default"].div`
12274
12277
  font-weight: 400;
@@ -39929,341 +39932,423 @@ const TableBody = /*#__PURE__*/React$1.forwardRef(({
39929
39932
  return tag.replace(/-/g, " ").replace(/\b\w/g, l => l.toUpperCase());
39930
39933
  };
39931
39934
  const formatValue = (value, column, row, rowIndex) => {
39932
- if ((value === null || value === undefined) && column?.fieldType?.toLowerCase() !== "comments") {
39935
+ // Add safety checks at the start
39936
+ if (!column) {
39937
+ console.warn('formatValue called with null/undefined column');
39933
39938
  return "";
39934
39939
  }
39935
-
39936
- // Find the tooltip text for the current value - can be used for different fieldTypes
39937
- const getTooltipText = value => {
39938
- if (column?.tooltipText && Array.isArray(column.tooltipText)) {
39939
- const tooltipItem = column.tooltipText.find(item => item.value === value);
39940
- return tooltipItem ? tooltipItem.label : null;
39940
+ try {
39941
+ if ((value === null || value === undefined) && column?.fieldType?.toLowerCase() !== "comments") {
39942
+ return "";
39941
39943
  }
39942
- return null;
39943
- };
39944
- switch (column?.fieldType?.toLowerCase()) {
39945
- case "currency":
39946
- if (column.format === "$0.00") {
39947
- return `$${parseFloat(value || 0).toFixed(2)}`;
39948
- }
39949
- return value;
39950
- case "text":
39951
- return value?.toString() || "";
39952
- case "number":
39953
- if (column.format && column.format.includes(",")) {
39954
- return (value || 0).toLocaleString();
39944
+
39945
+ // Find the tooltip text for the current value - can be used for different fieldTypes
39946
+ const getTooltipText = value => {
39947
+ try {
39948
+ if (column?.tooltipText && Array.isArray(column.tooltipText)) {
39949
+ const tooltipItem = column.tooltipText.find(item => item && item.value === value);
39950
+ return tooltipItem ? tooltipItem.label : null;
39951
+ }
39952
+ return null;
39953
+ } catch (e) {
39954
+ console.warn('Error in getTooltipText:', e);
39955
+ return null;
39955
39956
  }
39956
- return value;
39957
- case "percentage":
39958
- return `${value || 0}%`;
39959
- case "date":
39960
- if (column.format === "MM/DD/YYYY" && value) {
39957
+ };
39958
+ const fieldType = column?.fieldType?.toLowerCase() || 'text';
39959
+ switch (fieldType) {
39960
+ case "currency":
39961
39961
  try {
39962
- const date = new Date(value);
39963
- return `${(date.getMonth() + 1)?.toString().padStart(2, "0")}/${date.getDate()?.toString().padStart(2, "0")}/${date.getFullYear()}`;
39962
+ if (column.format === "$0.00") {
39963
+ const numValue = parseFloat(value || 0);
39964
+ return `${isNaN(numValue) ? '0.00' : numValue.toFixed(2)}`;
39965
+ }
39966
+ return String(value || "");
39964
39967
  } catch (e) {
39965
- console.warn("Invalid date format:", value);
39966
- return value;
39968
+ console.warn('Error formatting currency:', e);
39969
+ return String(value || "");
39967
39970
  }
39968
- }
39969
- return value;
39970
- case "boolean":
39971
- return value ? "Yes" : "No";
39972
- case "array":
39973
- if (Array.isArray(value)) {
39974
- return value.join(", ");
39975
- }
39976
- return value;
39977
- case "tag":
39978
- if (!value) return "";
39979
- const tagConfig = column.tagConfig || {};
39980
- const colors = tagConfig.colors || {};
39981
- const defaultColor = tagConfig.defaultColor || {
39982
- bg: "#F3F4F6",
39983
- text: "#374151",
39984
- border: "#9CA3AF"
39985
- };
39986
- const maxDisplay = tagConfig.maxDisplay || 3;
39987
- const isMultiple = tagConfig.multiple !== false; // Default to true
39988
-
39989
- // Helper function to create a tag chip with proper tooltip
39990
- const createTagChip = (tagValue, index = 0) => {
39991
- const colorConfig = colors[tagValue] || defaultColor;
39992
- const formattedText = formatTagText(tagValue);
39993
- return /*#__PURE__*/React__default["default"].createElement(TagChip, {
39994
- key: `${tagValue}-${index}`,
39995
- $backgroundColor: colorConfig.bg,
39996
- $textColor: colorConfig.text,
39997
- $borderColor: colorConfig.border,
39998
- $interactive: false,
39999
- title: formattedText // Always show full text in tooltip
40000
- }, /*#__PURE__*/React__default["default"].createElement(TagChipTextWrapper, null, formattedText));
40001
- };
40002
-
40003
- // Handle single tag
40004
- if (typeof value === "string") {
40005
- return /*#__PURE__*/React__default["default"].createElement(TagContainer, null, createTagChip(value));
40006
- }
40007
-
40008
- // Handle multiple tags
40009
- if (Array.isArray(value) && isMultiple) {
40010
- const visibleTags = value.slice(0, maxDisplay);
40011
- const remainingCount = value.length - maxDisplay;
40012
- return /*#__PURE__*/React__default["default"].createElement(TagContainer, null, /*#__PURE__*/React__default["default"].createElement(MultiTagWrapper, null, visibleTags.map((tag, index) => createTagChip(tag, index)), remainingCount > 0 && /*#__PURE__*/React__default["default"].createElement(TagOverflow, {
40013
- title: `${remainingCount} more: ${value.slice(maxDisplay).map(tag => formatTagText(tag)).join(", ")}`
40014
- }, "+", remainingCount)));
40015
- }
40016
-
40017
- // Fallback for array treated as single tag
40018
- if (Array.isArray(value)) {
40019
- return formatValue(value[0], column, row, rowIndex);
40020
- }
40021
- return value;
40022
- case "packagestatus":
40023
- // Helper function to apply tooltip logic
40024
- const applyTooltipLogic = (element, tooltipText) => {
40025
- if (element && tooltipText && tooltipText.trim() !== "") {
40026
- try {
40027
- const rect = element.getBoundingClientRect();
40028
- const {
40029
- offset,
40030
- height
40031
- } = calculateTooltipOffset(tooltipText);
40032
- element.style.setProperty("--tooltip-top", `${rect.top}px`);
40033
- element.style.setProperty("--tooltip-left", `${rect.left}px`);
40034
- element.style.setProperty("--tooltip-width", `${rect.width}px`);
40035
- element.style.setProperty("--tooltip-offset", `${offset}px`);
40036
- element.style.setProperty("--tooltip-height", `${height}px`);
40037
- element.setAttribute("data-tooltip", tooltipText);
40038
- } catch (e) {
40039
- console.warn("Error applying tooltip:", e);
39971
+ case "text":
39972
+ return String(value || "");
39973
+ case "number":
39974
+ try {
39975
+ if (column.format && column.format.includes(",")) {
39976
+ const numValue = Number(value || 0);
39977
+ return isNaN(numValue) ? String(value || "") : numValue.toLocaleString();
40040
39978
  }
39979
+ return String(value || "");
39980
+ } catch (e) {
39981
+ console.warn('Error formatting number:', e);
39982
+ return String(value || "");
40041
39983
  }
40042
- };
40043
- const tooltipText = getTooltipText(value);
40044
- const lowerValue = value?.toLowerCase();
40045
- if (lowerValue === "empty") {
40046
- return /*#__PURE__*/React__default["default"].createElement(ButtonWrapper, {
40047
- ref: el => applyTooltipLogic(el, tooltipText)
40048
- }, /*#__PURE__*/React__default["default"].createElement(Button$1, {
40049
- leftIcon: "Fly",
40050
- text: "Send",
40051
- borderRadius: "8px",
40052
- backgroundColor: "#FFF",
40053
- textColor: "#B1B1B1",
40054
- borderColor: "#D9D9D9",
40055
- hoverTextColor: "#B1B1B1",
40056
- hoverBackgroundColor: "#E6F0F0",
40057
- hoverBorderColor: "#D9D9D9",
40058
- disabledTextColor: "#B1B1B1",
40059
- disabledBackgroundColor: focusedRowIndex === rowIndex ? "#D1E7E7" : hoveredRowIndex === rowIndex ? "#E6F0F0" : "#FFF",
40060
- disabledBorderColor: "#D9D9D9",
40061
- width: "100px",
40062
- height: "32px",
40063
- disabled: true
40064
- }));
40065
- } else if (lowerValue === "draft") {
40066
- return /*#__PURE__*/React__default["default"].createElement(ButtonWrapper, {
40067
- ref: el => applyTooltipLogic(el, tooltipText)
40068
- }, /*#__PURE__*/React__default["default"].createElement(Button$1, {
40069
- leftIcon: "Fly",
40070
- text: "Send",
40071
- borderRadius: "8px",
40072
- backgroundColor: focusedRowIndex === rowIndex ? "#D1E7E7" : hoveredRowIndex === rowIndex ? "#E6F0F0" : "#FFF",
40073
- textColor: buttonColor,
40074
- borderColor: buttonColor,
40075
- hoverTextColor: buttonColor,
40076
- hoverBorderColor: buttonColor,
40077
- hoverBackgroundColor: "#E6F0F0",
40078
- activeBackgroundColor: "#D1E7E7",
40079
- width: "100px",
40080
- height: "32px",
40081
- onClick: e => {
40082
- e.stopPropagation();
40083
- onSendClick && onSendClick(row);
40084
- }
40085
- }));
40086
- } else if (lowerValue === "sent") {
40087
- return /*#__PURE__*/React__default["default"].createElement(SentStatus, {
40088
- ref: el => applyTooltipLogic(el, tooltipText)
40089
- }, /*#__PURE__*/React__default["default"].createElement(OkIcon, {
40090
- width: "24",
40091
- height: "24",
40092
- color: "#5FCC70"
40093
- }), /*#__PURE__*/React__default["default"].createElement("span", null, "All Sent"));
40094
- }
40095
- return value;
40096
- case "status":
40097
- const statusObj = statuses.find(status => status.status === value) || {};
40098
- const [palette0, palette1] = statusObj.palette || ["#F3F4F6", "#374151"];
40099
- return /*#__PURE__*/React__default["default"].createElement(StatusCell$1, {
40100
- color: palette1
40101
- }, /*#__PURE__*/React__default["default"].createElement(StatusCellCircle, {
40102
- backgroundColor: palette0
40103
- }), /*#__PURE__*/React__default["default"].createElement("span", null, value));
40104
- case "comments":
40105
- const commentTextValue = value || "";
40106
- const hasComments = commentTextValue.trim().length > 0;
40107
-
40108
- // Truncate tooltip text if longer than 150 characters
40109
- const commentTooltipText = commentTextValue.length > 150 ? commentTextValue.substring(0, 147) + "..." : commentTextValue;
40110
- return /*#__PURE__*/React__default["default"].createElement(CommentIconWrapper, {
40111
- $buttonColor: buttonColor,
40112
- ref: el => {
40113
- if (el) {
40114
- try {
40115
- if (hasComments) {
40116
- // Add tooltip if there are comments
40117
- const rect = el.getBoundingClientRect();
40118
- const {
40119
- offset,
40120
- height
40121
- } = calculateTooltipOffset(commentTooltipText);
40122
- el.style.setProperty("--tooltip-top", `${rect.top}px`);
40123
- el.style.setProperty("--tooltip-left", `${rect.left}px`);
40124
- el.style.setProperty("--tooltip-width", `${rect.width}px`);
40125
- el.style.setProperty("--tooltip-offset", `${offset}px`);
40126
- el.style.setProperty("--tooltip-height", `${height}px`);
40127
- el.setAttribute("data-tooltip", commentTooltipText);
40128
- } else {
40129
- // Remove tooltip if there are no comments
40130
- el.removeAttribute("data-tooltip");
40131
- el.style.removeProperty("--tooltip-top");
40132
- el.style.removeProperty("--tooltip-left");
40133
- el.style.removeProperty("--tooltip-width");
40134
- el.style.removeProperty("--tooltip-offset");
40135
- el.style.removeProperty("--tooltip-height");
40136
- }
40137
- } catch (e) {
40138
- console.warn("Error handling comment tooltip:", e);
39984
+ case "percentage":
39985
+ return `${value || 0}%`;
39986
+ case "date":
39987
+ try {
39988
+ if (column.format === "MM/DD/YYYY" && value) {
39989
+ const date = new Date(value);
39990
+ if (isNaN(date.getTime())) {
39991
+ return String(value);
40139
39992
  }
39993
+ return `${(date.getMonth() + 1).toString().padStart(2, "0")}/${date.getDate().toString().padStart(2, "0")}/${date.getFullYear()}`;
40140
39994
  }
40141
- },
40142
- onClick: e => {
40143
- e.stopPropagation();
40144
- setCurrentCommentRow(rowIndex);
40145
- setIsCommentModalOpen(true);
39995
+ return String(value || "");
39996
+ } catch (e) {
39997
+ console.warn('Error formatting date:', e);
39998
+ return String(value || "");
40146
39999
  }
40147
- }, /*#__PURE__*/React__default["default"].createElement(CommentIcon, {
40148
- showCircle: hasComments,
40149
- circleColor: buttonColor
40150
- }));
40151
- case "trash":
40152
- // Only show trash icon when row is hovered
40153
- if (hoveredRowIndex !== rowIndex) {
40154
- return null;
40155
- }
40156
- const trashTooltipText = getTooltipText(value);
40157
- if (value === "ENABLED") {
40158
- return /*#__PURE__*/React__default["default"].createElement(TrashIconWrapper$1, {
40159
- $buttonColor: buttonColor,
40160
- ref: el => {
40161
- if (el && trashTooltipText) {
40000
+ case "boolean":
40001
+ return value ? "Yes" : "No";
40002
+ case "array":
40003
+ try {
40004
+ if (Array.isArray(value)) {
40005
+ return value.join(", ");
40006
+ }
40007
+ return String(value || "");
40008
+ } catch (e) {
40009
+ console.warn('Error formatting array:', e);
40010
+ return String(value || "");
40011
+ }
40012
+ case "tag":
40013
+ try {
40014
+ if (!value) return "";
40015
+ const tagConfig = column.tagConfig || {};
40016
+ const colors = tagConfig.colors || {};
40017
+ const defaultColor = tagConfig.defaultColor || {
40018
+ bg: "#F3F4F6",
40019
+ text: "#374151",
40020
+ border: "#9CA3AF"
40021
+ };
40022
+ const maxDisplay = tagConfig.maxDisplay || 3;
40023
+ const isMultiple = tagConfig.multiple !== false;
40024
+ const createTagChip = (tagValue, index = 0) => {
40025
+ const colorConfig = colors[tagValue] || defaultColor;
40026
+ const formattedText = formatTagText(tagValue);
40027
+ return /*#__PURE__*/React__default["default"].createElement(TagChip, {
40028
+ key: `${tagValue}-${index}`,
40029
+ $backgroundColor: colorConfig.bg,
40030
+ $textColor: colorConfig.text,
40031
+ $borderColor: colorConfig.border,
40032
+ $interactive: false,
40033
+ title: formattedText
40034
+ }, /*#__PURE__*/React__default["default"].createElement(TagChipTextWrapper, null, formattedText));
40035
+ };
40036
+ if (typeof value === "string") {
40037
+ return /*#__PURE__*/React__default["default"].createElement(TagContainer, null, createTagChip(value));
40038
+ }
40039
+ if (Array.isArray(value) && isMultiple) {
40040
+ const visibleTags = value.slice(0, maxDisplay);
40041
+ const remainingCount = value.length - maxDisplay;
40042
+ return /*#__PURE__*/React__default["default"].createElement(TagContainer, null, /*#__PURE__*/React__default["default"].createElement(MultiTagWrapper, null, visibleTags.map((tag, index) => createTagChip(tag, index)), remainingCount > 0 && /*#__PURE__*/React__default["default"].createElement(TagOverflow, {
40043
+ title: `${remainingCount} more: ${value.slice(maxDisplay).map(tag => formatTagText(tag)).join(", ")}`
40044
+ }, "+", remainingCount)));
40045
+ }
40046
+ if (Array.isArray(value)) {
40047
+ return formatValue(value[0], column, row, rowIndex);
40048
+ }
40049
+ return String(value || "");
40050
+ } catch (e) {
40051
+ console.warn('Error formatting tag:', e);
40052
+ return String(value || "");
40053
+ }
40054
+ case "packagestatus":
40055
+ try {
40056
+ const applyTooltipLogic = (element, tooltipText) => {
40057
+ if (element && tooltipText && tooltipText.trim() !== "") {
40162
40058
  try {
40163
- const rect = el.getBoundingClientRect();
40164
- const {
40165
- offset,
40166
- height
40167
- } = calculateTooltipOffset(trashTooltipText);
40168
- el.style.setProperty("--tooltip-top", `${rect.top}px`);
40169
- el.style.setProperty("--tooltip-left", `${rect.left}px`);
40170
- el.style.setProperty("--tooltip-width", `${rect.width}px`);
40171
- el.style.setProperty("--tooltip-offset", `${offset}px`);
40172
- el.style.setProperty("--tooltip-height", `${height}px`);
40173
- el.setAttribute("data-tooltip", trashTooltipText);
40059
+ const rect = element.getBoundingClientRect();
40060
+ if (rect.width > 0 && rect.height > 0) {
40061
+ const tooltipInfo = calculateTooltipOffset(tooltipText);
40062
+ if (tooltipInfo) {
40063
+ const {
40064
+ offset,
40065
+ height
40066
+ } = tooltipInfo;
40067
+ element.style.setProperty("--tooltip-top", `${rect.top}px`);
40068
+ element.style.setProperty("--tooltip-left", `${rect.left}px`);
40069
+ element.style.setProperty("--tooltip-width", `${rect.width}px`);
40070
+ element.style.setProperty("--tooltip-offset", `${offset}px`);
40071
+ element.style.setProperty("--tooltip-height", `${height}px`);
40072
+ element.setAttribute("data-tooltip", tooltipText);
40073
+ }
40074
+ }
40174
40075
  } catch (e) {
40175
- console.warn("Error handling trash tooltip:", e);
40076
+ console.warn("Error applying tooltip:", e);
40176
40077
  }
40177
40078
  }
40178
- },
40179
- onClick: e => {
40180
- e.stopPropagation();
40181
- onDeleteClick && onDeleteClick(row);
40079
+ };
40080
+ const tooltipText = getTooltipText(value);
40081
+ // Handle array values (like PackageStatusName)
40082
+ const processedValue = Array.isArray(value) ? value[0] : value;
40083
+ const lowerValue = String(processedValue || "").toLowerCase();
40084
+ if (lowerValue === "empty") {
40085
+ return /*#__PURE__*/React__default["default"].createElement(ButtonWrapper, {
40086
+ ref: el => applyTooltipLogic(el, tooltipText)
40087
+ }, /*#__PURE__*/React__default["default"].createElement(Button$1, {
40088
+ leftIcon: "Fly",
40089
+ text: "Send",
40090
+ borderRadius: "8px",
40091
+ backgroundColor: "#FFF",
40092
+ textColor: "#B1B1B1",
40093
+ borderColor: "#D9D9D9",
40094
+ hoverTextColor: "#B1B1B1",
40095
+ hoverBackgroundColor: "#E6F0F0",
40096
+ hoverBorderColor: "#D9D9D9",
40097
+ disabledTextColor: "#B1B1B1",
40098
+ disabledBackgroundColor: focusedRowIndex === rowIndex ? "#D1E7E7" : hoveredRowIndex === rowIndex ? "#E6F0F0" : "#FFF",
40099
+ disabledBorderColor: "#D9D9D9",
40100
+ width: "100px",
40101
+ height: "32px",
40102
+ disabled: true
40103
+ }));
40104
+ } else if (lowerValue === "draft") {
40105
+ return /*#__PURE__*/React__default["default"].createElement(ButtonWrapper, {
40106
+ ref: el => applyTooltipLogic(el, tooltipText)
40107
+ }, /*#__PURE__*/React__default["default"].createElement(Button$1, {
40108
+ leftIcon: "Fly",
40109
+ text: "Send",
40110
+ borderRadius: "8px",
40111
+ backgroundColor: focusedRowIndex === rowIndex ? "#D1E7E7" : hoveredRowIndex === rowIndex ? "#E6F0F0" : "#FFF",
40112
+ textColor: buttonColor,
40113
+ borderColor: buttonColor,
40114
+ hoverTextColor: buttonColor,
40115
+ hoverBorderColor: buttonColor,
40116
+ hoverBackgroundColor: "#E6F0F0",
40117
+ activeBackgroundColor: "#D1E7E7",
40118
+ width: "100px",
40119
+ height: "32px",
40120
+ onClick: e => {
40121
+ e.stopPropagation();
40122
+ onSendClick && onSendClick(row);
40123
+ }
40124
+ }));
40125
+ } else if (lowerValue === "sent") {
40126
+ return /*#__PURE__*/React__default["default"].createElement(SentStatus, {
40127
+ ref: el => applyTooltipLogic(el, tooltipText)
40128
+ }, /*#__PURE__*/React__default["default"].createElement(OkIcon, {
40129
+ width: "24",
40130
+ height: "24",
40131
+ color: "#5FCC70"
40132
+ }), /*#__PURE__*/React__default["default"].createElement("span", null, "All Sent"));
40182
40133
  }
40183
- }, /*#__PURE__*/React__default["default"].createElement(TrashIcon, {
40184
- width: "14",
40185
- height: "18"
40186
- }));
40187
- } else if (value === "DISABLED") {
40188
- return /*#__PURE__*/React__default["default"].createElement(DisabledTrashIconWrapper$1, {
40189
- ref: el => {
40190
- if (el && trashTooltipText) {
40191
- try {
40192
- const rect = el.getBoundingClientRect();
40193
- const {
40194
- offset,
40195
- height
40196
- } = calculateTooltipOffset(trashTooltipText);
40197
- el.style.setProperty("--tooltip-top", `${rect.top}px`);
40198
- el.style.setProperty("--tooltip-left", `${rect.left}px`);
40199
- el.style.setProperty("--tooltip-width", `${rect.width}px`);
40200
- el.style.setProperty("--tooltip-offset", `${offset}px`);
40201
- el.style.setProperty("--tooltip-height", `${height}px`);
40202
- el.setAttribute("data-tooltip", trashTooltipText);
40203
- } catch (e) {
40204
- console.warn("Error handling disabled trash tooltip:", e);
40134
+ return String(processedValue || "");
40135
+ } catch (e) {
40136
+ console.warn('Error formatting packagestatus:', e);
40137
+ return String(value || "");
40138
+ }
40139
+ case "status":
40140
+ try {
40141
+ const statusObj = statuses.find(status => status && status.status === value) || {};
40142
+ const palette = statusObj.palette || ["#F3F4F6", "#374151"];
40143
+ const [palette0, palette1] = palette;
40144
+ return /*#__PURE__*/React__default["default"].createElement(StatusCell$1, {
40145
+ color: palette1
40146
+ }, /*#__PURE__*/React__default["default"].createElement(StatusCellCircle, {
40147
+ backgroundColor: palette0
40148
+ }), /*#__PURE__*/React__default["default"].createElement("span", null, String(value || "")));
40149
+ } catch (e) {
40150
+ console.warn('Error formatting status:', e);
40151
+ return String(value || "");
40152
+ }
40153
+ case "comments":
40154
+ try {
40155
+ const commentTextValue = String(value || "");
40156
+ const hasComments = commentTextValue.trim().length > 0;
40157
+ const commentTooltipText = commentTextValue.length > 150 ? commentTextValue.substring(0, 147) + "..." : commentTextValue;
40158
+ return /*#__PURE__*/React__default["default"].createElement(CommentIconWrapper, {
40159
+ $buttonColor: buttonColor,
40160
+ ref: el => {
40161
+ if (el) {
40162
+ try {
40163
+ if (hasComments) {
40164
+ const rect = el.getBoundingClientRect();
40165
+ if (rect.width > 0 && rect.height > 0) {
40166
+ const tooltipInfo = calculateTooltipOffset(commentTooltipText);
40167
+ if (tooltipInfo) {
40168
+ const {
40169
+ offset,
40170
+ height
40171
+ } = tooltipInfo;
40172
+ el.style.setProperty("--tooltip-top", `${rect.top}px`);
40173
+ el.style.setProperty("--tooltip-left", `${rect.left}px`);
40174
+ el.style.setProperty("--tooltip-width", `${rect.width}px`);
40175
+ el.style.setProperty("--tooltip-offset", `${offset}px`);
40176
+ el.style.setProperty("--tooltip-height", `${height}px`);
40177
+ el.setAttribute("data-tooltip", commentTooltipText);
40178
+ }
40179
+ }
40180
+ } else {
40181
+ el.removeAttribute("data-tooltip");
40182
+ el.style.removeProperty("--tooltip-top");
40183
+ el.style.removeProperty("--tooltip-left");
40184
+ el.style.removeProperty("--tooltip-width");
40185
+ el.style.removeProperty("--tooltip-offset");
40186
+ el.style.removeProperty("--tooltip-height");
40187
+ }
40188
+ } catch (e) {
40189
+ console.warn("Error handling comment tooltip:", e);
40190
+ }
40205
40191
  }
40192
+ },
40193
+ onClick: e => {
40194
+ e.stopPropagation();
40195
+ setCurrentCommentRow(rowIndex);
40196
+ setIsCommentModalOpen(true);
40206
40197
  }
40198
+ }, /*#__PURE__*/React__default["default"].createElement(CommentIcon, {
40199
+ showCircle: hasComments,
40200
+ circleColor: buttonColor
40201
+ }));
40202
+ } catch (e) {
40203
+ console.warn('Error formatting comments:', e);
40204
+ return String(value || "");
40205
+ }
40206
+ case "trash":
40207
+ try {
40208
+ if (hoveredRowIndex !== rowIndex) {
40209
+ return null;
40207
40210
  }
40208
- }, /*#__PURE__*/React__default["default"].createElement(DisabledTrashIcon, {
40209
- width: "22",
40210
- height: "22"
40211
- }));
40212
- }
40213
- return null;
40214
- case "dropdown":
40215
- if (!column) return null;
40216
- const dropdownKey = `${rowIndex}-${column.key}`;
40217
- const isOpen = openDropdowns[dropdownKey] || false;
40218
- const dropdownOptions = column.dropdownOptions || [];
40219
- const maxDropdownHeight = column.maxDropdownHeight || "200px";
40220
- const dropdownOptionsWidth = column.dropdownOptionsWidth;
40221
- const dropdownOptionsAlignment = column.dropdownOptionsAlignment || "right";
40222
- const placeholder = column.placeholder || "Select...";
40223
-
40224
- // Find the current selected option to display its label
40225
- const currentOption = dropdownOptions.find(option => option.value === value);
40226
- const displayText = currentOption ? currentOption.label : value || placeholder;
40227
- return /*#__PURE__*/React__default["default"].createElement(Dropdown, {
40228
- isOpen: isOpen,
40229
- options: dropdownOptions,
40230
- selectedValue: value,
40231
- displayText: displayText,
40232
- onToggle: e => handleDropdownClick(rowIndex, column.key, e),
40233
- onOptionSelect: (option, e) => handleDropdownOptionClick(row, rowIndex, column.key, option, e),
40234
- maxDropdownHeight: maxDropdownHeight,
40235
- dropdownOptionsWidth: dropdownOptionsWidth,
40236
- dropdownOptionsAlignment: dropdownOptionsAlignment,
40237
- placeholder: placeholder,
40238
- isRowFocused: focusedRowIndex === rowIndex,
40239
- isRowHovered: hoveredRowIndex === rowIndex,
40240
- selectedColor: selectedColor
40241
- });
40242
- case "checkbox":
40243
- const isChecked = Boolean(value);
40244
- return /*#__PURE__*/React__default["default"].createElement("div", {
40245
- style: {
40246
- display: "flex",
40247
- alignItems: "center",
40248
- justifyContent: "center",
40249
- width: "100%",
40250
- height: "100%"
40211
+ const trashTooltipText = getTooltipText(value);
40212
+ const processedValue = String(value || "").toUpperCase();
40213
+ if (processedValue === "ENABLED") {
40214
+ return /*#__PURE__*/React__default["default"].createElement(TrashIconWrapper$1, {
40215
+ $buttonColor: buttonColor,
40216
+ ref: el => {
40217
+ if (el && trashTooltipText) {
40218
+ try {
40219
+ const rect = el.getBoundingClientRect();
40220
+ if (rect.width > 0 && rect.height > 0) {
40221
+ const tooltipInfo = calculateTooltipOffset(trashTooltipText);
40222
+ if (tooltipInfo) {
40223
+ const {
40224
+ offset,
40225
+ height
40226
+ } = tooltipInfo;
40227
+ el.style.setProperty("--tooltip-top", `${rect.top}px`);
40228
+ el.style.setProperty("--tooltip-left", `${rect.left}px`);
40229
+ el.style.setProperty("--tooltip-width", `${rect.width}px`);
40230
+ el.style.setProperty("--tooltip-offset", `${offset}px`);
40231
+ el.style.setProperty("--tooltip-height", `${height}px`);
40232
+ el.setAttribute("data-tooltip", trashTooltipText);
40233
+ }
40234
+ }
40235
+ } catch (e) {
40236
+ console.warn("Error handling trash tooltip:", e);
40237
+ }
40238
+ }
40239
+ },
40240
+ onClick: e => {
40241
+ e.stopPropagation();
40242
+ onDeleteClick && onDeleteClick(row);
40243
+ }
40244
+ }, /*#__PURE__*/React__default["default"].createElement(TrashIcon, {
40245
+ width: "14",
40246
+ height: "18"
40247
+ }));
40248
+ } else if (processedValue === "DISABLED") {
40249
+ return /*#__PURE__*/React__default["default"].createElement(DisabledTrashIconWrapper$1, {
40250
+ ref: el => {
40251
+ if (el && trashTooltipText) {
40252
+ try {
40253
+ const rect = el.getBoundingClientRect();
40254
+ if (rect.width > 0 && rect.height > 0) {
40255
+ const tooltipInfo = calculateTooltipOffset(trashTooltipText);
40256
+ if (tooltipInfo) {
40257
+ const {
40258
+ offset,
40259
+ height
40260
+ } = tooltipInfo;
40261
+ el.style.setProperty("--tooltip-top", `${rect.top}px`);
40262
+ el.style.setProperty("--tooltip-left", `${rect.left}px`);
40263
+ el.style.setProperty("--tooltip-width", `${rect.width}px`);
40264
+ el.style.setProperty("--tooltip-offset", `${offset}px`);
40265
+ el.style.setProperty("--tooltip-height", `${height}px`);
40266
+ el.setAttribute("data-tooltip", trashTooltipText);
40267
+ }
40268
+ }
40269
+ } catch (e) {
40270
+ console.warn("Error handling disabled trash tooltip:", e);
40271
+ }
40272
+ }
40273
+ }
40274
+ }, /*#__PURE__*/React__default["default"].createElement(DisabledTrashIcon, {
40275
+ width: "22",
40276
+ height: "22"
40277
+ }));
40278
+ }
40279
+ return null;
40280
+ } catch (e) {
40281
+ console.warn('Error formatting trash:', e);
40282
+ return null;
40251
40283
  }
40252
- }, /*#__PURE__*/React__default["default"].createElement("input", {
40253
- type: "checkbox",
40254
- checked: isChecked,
40255
- onChange: e => handleCheckboxClick(row, column.key, e),
40256
- onClick: e => e.stopPropagation(),
40257
- style: {
40258
- width: "18px",
40259
- height: "18px",
40260
- cursor: "pointer",
40261
- accentColor: buttonColor
40284
+ case "dropdown":
40285
+ try {
40286
+ if (!column) return null;
40287
+ const dropdownKey = `${rowIndex}-${column.key}`;
40288
+ const isOpen = openDropdowns[dropdownKey] || false;
40289
+ const dropdownOptions = column.dropdownOptions || [];
40290
+ const maxDropdownHeight = column.maxDropdownHeight || "200px";
40291
+ const dropdownOptionsWidth = column.dropdownOptionsWidth;
40292
+ const dropdownOptionsAlignment = column.dropdownOptionsAlignment || "right";
40293
+ const placeholder = column.placeholder || "Select...";
40294
+ const currentOption = dropdownOptions.find(option => option && option.value === value);
40295
+ const displayText = currentOption ? currentOption.label : value || placeholder;
40296
+ return /*#__PURE__*/React__default["default"].createElement(Dropdown, {
40297
+ isOpen: isOpen,
40298
+ options: dropdownOptions,
40299
+ selectedValue: value,
40300
+ displayText: displayText,
40301
+ onToggle: e => handleDropdownClick(rowIndex, column.key, e),
40302
+ onOptionSelect: (option, e) => handleDropdownOptionClick(row, rowIndex, column.key, option, e),
40303
+ maxDropdownHeight: maxDropdownHeight,
40304
+ dropdownOptionsWidth: dropdownOptionsWidth,
40305
+ dropdownOptionsAlignment: dropdownOptionsAlignment,
40306
+ placeholder: placeholder,
40307
+ isRowFocused: focusedRowIndex === rowIndex,
40308
+ isRowHovered: hoveredRowIndex === rowIndex,
40309
+ selectedColor: selectedColor
40310
+ });
40311
+ } catch (e) {
40312
+ console.warn('Error formatting dropdown:', e);
40313
+ return String(value || "");
40262
40314
  }
40263
- }));
40264
- default:
40265
- // Treat default as text
40266
- return value?.toString() ?? "";
40315
+ case "checkbox":
40316
+ try {
40317
+ const isChecked = Boolean(value);
40318
+ return /*#__PURE__*/React__default["default"].createElement("div", {
40319
+ style: {
40320
+ display: "flex",
40321
+ alignItems: "center",
40322
+ justifyContent: "center",
40323
+ width: "100%",
40324
+ height: "100%"
40325
+ }
40326
+ }, /*#__PURE__*/React__default["default"].createElement("input", {
40327
+ type: "checkbox",
40328
+ checked: isChecked,
40329
+ onChange: e => handleCheckboxClick(row, column.key, e),
40330
+ onClick: e => e.stopPropagation(),
40331
+ style: {
40332
+ width: "18px",
40333
+ height: "18px",
40334
+ cursor: "pointer",
40335
+ accentColor: buttonColor
40336
+ }
40337
+ }));
40338
+ } catch (e) {
40339
+ console.warn('Error formatting checkbox:', e);
40340
+ return String(value || "");
40341
+ }
40342
+ default:
40343
+ return String(value || "");
40344
+ }
40345
+ } catch (error) {
40346
+ console.error('Error in formatValue:', error, {
40347
+ value,
40348
+ column,
40349
+ rowIndex
40350
+ });
40351
+ return String(value || "");
40267
40352
  }
40268
40353
  };
40269
40354
  const shouldShowTooltip = (element, content) => {
@@ -40379,39 +40464,57 @@ const TableBody = /*#__PURE__*/React$1.forwardRef(({
40379
40464
  }) : null, columns.map((column, columnIndex) => {
40380
40465
  if (!column || !column.key) {
40381
40466
  console.warn(`Invalid column at index ${columnIndex}:`, column);
40382
- return null;
40467
+ return /*#__PURE__*/React__default["default"].createElement(TableCell, {
40468
+ key: `invalid-${columnIndex}`
40469
+ }, "Invalid Column");
40383
40470
  }
40384
- const value = row[column.key];
40385
- const formattedValue = formatValue(value, column, row, rowIndex);
40386
-
40387
- // Use the chrome shimmer hook safely
40388
- let shimmerText = formattedValue;
40389
- let isShimmering = false;
40471
+ let value, formattedValue, shimmerText, isShimmering;
40390
40472
  try {
40391
- const shimmerResult = useShimmerChromeEffect(formattedValue, rowIndex, indexToShimmer, columnIndex, columns.length);
40392
- if (shimmerResult) {
40393
- shimmerText = shimmerResult.text || formattedValue;
40394
- isShimmering = shimmerResult.isShimmering || false;
40395
- }
40473
+ value = row[column.key];
40474
+ formattedValue = formatValue(value, column, row, rowIndex) || "";
40396
40475
  } catch (e) {
40397
- console.warn("Error with shimmer effect:", e);
40476
+ console.error("Error formatting value:", e);
40477
+ formattedValue = "";
40478
+ }
40479
+
40480
+ // Initialize shimmer defaults
40481
+ shimmerText = formattedValue;
40482
+ isShimmering = false;
40483
+
40484
+ // Only use shimmer hook for text-based fields
40485
+ const isTextBasedField = column.fieldType?.toLowerCase() === "text" || column.fieldType?.toLowerCase() === "currency" || column.fieldType?.toLowerCase() === "number" || column.fieldType?.toLowerCase() === "percentage" || column.fieldType?.toLowerCase() === "date" || !column.fieldType;
40486
+ if (isTextBasedField && typeof useShimmerChromeEffect === 'function') {
40487
+ try {
40488
+ const shimmerResult = useShimmerChromeEffect(String(formattedValue || ""), rowIndex, indexToShimmer, columnIndex, columns.length);
40489
+ if (shimmerResult && typeof shimmerResult === 'object') {
40490
+ shimmerText = shimmerResult.text || formattedValue;
40491
+ isShimmering = Boolean(shimmerResult.isShimmering);
40492
+ }
40493
+ } catch (e) {
40494
+ console.warn("Error with shimmer effect:", e);
40495
+ }
40398
40496
  }
40399
40497
  return /*#__PURE__*/React__default["default"].createElement(TableCell, {
40400
40498
  key: `${column.key}-${rowIndex}`,
40401
40499
  ref: el => {
40402
- if (el && shouldShowTooltip(el)) {
40500
+ if (el && formattedValue && shouldShowTooltip(el)) {
40403
40501
  try {
40404
40502
  const rect = el.getBoundingClientRect();
40405
- const {
40406
- offset,
40407
- height
40408
- } = calculateTooltipOffset(formattedValue.toString(), true);
40409
- el.style.setProperty("--cell-top", `${rect.top}px`);
40410
- el.style.setProperty("--cell-left", `${rect.left}px`);
40411
- el.style.setProperty("--cell-width", `${rect.width}px`);
40412
- el.style.setProperty("--cell-offset", `${offset}px`);
40413
- el.style.setProperty("--cell-height", `${height}px`);
40414
- el.setAttribute("data-tooltip", formattedValue);
40503
+ if (rect.width > 0 && rect.height > 0) {
40504
+ const tooltipInfo = calculateTooltipOffset(String(formattedValue), true);
40505
+ if (tooltipInfo) {
40506
+ const {
40507
+ offset,
40508
+ height
40509
+ } = tooltipInfo;
40510
+ el.style.setProperty("--cell-top", `${rect.top}px`);
40511
+ el.style.setProperty("--cell-left", `${rect.left}px`);
40512
+ el.style.setProperty("--cell-width", `${rect.width}px`);
40513
+ el.style.setProperty("--cell-offset", `${offset}px`);
40514
+ el.style.setProperty("--cell-height", `${height}px`);
40515
+ el.setAttribute("data-tooltip", String(formattedValue));
40516
+ }
40517
+ }
40415
40518
  } catch (e) {
40416
40519
  console.warn("Error setting cell tooltip:", e);
40417
40520
  }
@@ -40421,10 +40524,10 @@ const TableBody = /*#__PURE__*/React$1.forwardRef(({
40421
40524
  $color: column.color,
40422
40525
  $minWidth: column.minWidth,
40423
40526
  $maxWidth: column.maxWidth
40424
- }, column.fieldType?.toLowerCase() === "text" || column.fieldType?.toLowerCase() === "currency" || column.fieldType?.toLowerCase() === "number" || column.fieldType?.toLowerCase() === "percentage" || column.fieldType?.toLowerCase() === "date" || !column.fieldType ? /*#__PURE__*/React__default["default"].createElement(ChromeShimmerText, {
40425
- text: shimmerText,
40527
+ }, isTextBasedField ? typeof ChromeShimmerText === 'function' ? /*#__PURE__*/React__default["default"].createElement(ChromeShimmerText, {
40528
+ text: String(shimmerText || ""),
40426
40529
  isShimmering: isShimmering
40427
- }) : formattedValue);
40530
+ }) : String(shimmerText || "") : formattedValue || "");
40428
40531
  })), expandable && expandedRows[rowIndex] && /*#__PURE__*/React__default["default"].createElement(ExpandedRow, {
40429
40532
  $expandedBackgroundColor: expandedBackgroundColor
40430
40533
  }, /*#__PURE__*/React__default["default"].createElement(TableCell, {