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