sag_components 2.0.0-beta189 → 2.0.0-beta190

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
@@ -1,4 +1,4 @@
1
- import React$1, { useState, useRef, useEffect, useMemo, useCallback, useImperativeHandle } from 'react';
1
+ import React$1, { useState, useRef, useEffect, useMemo, useCallback, forwardRef, useImperativeHandle } from 'react';
2
2
  import styled, { keyframes, css, styled as styled$1 } from 'styled-components';
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { ResponsiveContainer, PieChart as PieChart$1, Pie, Cell, Tooltip as Tooltip$3, BarChart as BarChart$1, CartesianGrid, XAxis, YAxis, Bar, LabelList, ReferenceLine, LineChart, Line, AreaChart as AreaChart$1, Legend, Area, ScatterChart, ZAxis, Scatter, Brush, ComposedChart } from 'recharts';
@@ -39778,9 +39778,9 @@ const ChromeShimmerText = ({
39778
39778
  };
39779
39779
 
39780
39780
  // TableBody.jsx
39781
- const TableBody = ({
39782
- columns,
39783
- data,
39781
+ const TableBody = /*#__PURE__*/forwardRef(({
39782
+ columns = [],
39783
+ data = [],
39784
39784
  onRowClick,
39785
39785
  onSendClick,
39786
39786
  buttonColor,
@@ -39814,9 +39814,8 @@ const TableBody = ({
39814
39814
  // New prop with default
39815
39815
  onDropdownSelected = () => {},
39816
39816
  onCheckboxClick = () => {},
39817
- onHeaderCheckboxClick = () => {},
39818
- ref = null
39819
- }) => {
39817
+ onHeaderCheckboxClick = () => {}
39818
+ }, ref) => {
39820
39819
  const [hoveredRowIndex, setHoveredRowIndex] = useState(null);
39821
39820
  const [focusedRowIndex, setFocusedRowIndex] = useState(null);
39822
39821
  const [isCommentModalOpen, setIsCommentModalOpen] = useState(false);
@@ -39828,8 +39827,14 @@ const TableBody = ({
39828
39827
  const [isFocused, setIsFocused] = useState(false);
39829
39828
  const [hasUserInteracted, setHasUserInteracted] = useState(false);
39830
39829
  const [hasInitialValue, setHasInitialValue] = useState(false);
39830
+
39831
+ // Early return for invalid data
39832
+ if (!Array.isArray(data) || !Array.isArray(columns)) {
39833
+ console.warn("TableBody: Invalid data or columns prop");
39834
+ return null;
39835
+ }
39831
39836
  useEffect(() => {
39832
- if (isCommentModalOpen && currentCommentRow !== null) {
39837
+ if (isCommentModalOpen && currentCommentRow !== null && data[currentCommentRow]) {
39833
39838
  const initialText = data[currentCommentRow]?.Comments || "";
39834
39839
  setCommentText(initialText);
39835
39840
  setHasInitialValue(Boolean(initialText.trim()));
@@ -39842,7 +39847,7 @@ const TableBody = ({
39842
39847
  }
39843
39848
  }, [resetFocusIndex]);
39844
39849
  useEffect(() => {
39845
- if (changeFocusIndex) {
39850
+ if (changeFocusIndex !== undefined && changeFocusIndex !== null) {
39846
39851
  setFocusedRowIndex(changeFocusIndex);
39847
39852
  }
39848
39853
  }, [changeFocusIndex]);
@@ -39894,41 +39899,46 @@ const TableBody = ({
39894
39899
 
39895
39900
  // Helper function to format tag text
39896
39901
  const formatTagText = tag => {
39897
- if (typeof tag !== "string") return tag;
39902
+ if (typeof tag !== "string") return String(tag || "");
39898
39903
  return tag.replace(/-/g, " ").replace(/\b\w/g, l => l.toUpperCase());
39899
39904
  };
39900
39905
  const formatValue = (value, column, row, rowIndex) => {
39901
- if ((value === null || value === undefined) && column.fieldType?.toLowerCase() !== "comments") {
39906
+ if ((value === null || value === undefined) && column?.fieldType?.toLowerCase() !== "comments") {
39902
39907
  return "";
39903
39908
  }
39904
39909
 
39905
39910
  // Find the tooltip text for the current value - can be used for different fieldTypes
39906
39911
  const getTooltipText = value => {
39907
- if (column.tooltipText && Array.isArray(column.tooltipText)) {
39912
+ if (column?.tooltipText && Array.isArray(column.tooltipText)) {
39908
39913
  const tooltipItem = column.tooltipText.find(item => item.value === value);
39909
39914
  return tooltipItem ? tooltipItem.label : null;
39910
39915
  }
39911
39916
  return null;
39912
39917
  };
39913
- switch (column.fieldType?.toLowerCase()) {
39918
+ switch (column?.fieldType?.toLowerCase()) {
39914
39919
  case "currency":
39915
39920
  if (column.format === "$0.00") {
39916
- return `$${parseFloat(value).toFixed(2)}`;
39921
+ return `$${parseFloat(value || 0).toFixed(2)}`;
39917
39922
  }
39918
39923
  return value;
39919
39924
  case "text":
39920
39925
  return value?.toString() || "";
39921
39926
  case "number":
39922
39927
  if (column.format && column.format.includes(",")) {
39923
- return value.toLocaleString();
39928
+ return (value || 0).toLocaleString();
39924
39929
  }
39925
39930
  return value;
39926
39931
  case "percentage":
39927
- return `${value}%`;
39932
+ return `${value || 0}%`;
39928
39933
  case "date":
39929
- if (column.format === "MM/DD/YYYY") {
39930
- const date = new Date(value);
39931
- return `${(date.getMonth() + 1)?.toString().padStart(2, "0")}/${date.getDate()?.toString().padStart(2, "0")}/${date.getFullYear()}`;
39934
+ if (column.format === "MM/DD/YYYY" && value) {
39935
+ try {
39936
+ const date = new Date(value);
39937
+ return `${(date.getMonth() + 1)?.toString().padStart(2, "0")}/${date.getDate()?.toString().padStart(2, "0")}/${date.getFullYear()}`;
39938
+ } catch (e) {
39939
+ console.warn("Invalid date format:", value);
39940
+ return value;
39941
+ }
39932
39942
  }
39933
39943
  return value;
39934
39944
  case "boolean":
@@ -39987,17 +39997,21 @@ const TableBody = ({
39987
39997
  // Helper function to apply tooltip logic
39988
39998
  const applyTooltipLogic = (element, tooltipText) => {
39989
39999
  if (element && tooltipText && tooltipText.trim() !== "") {
39990
- const rect = element.getBoundingClientRect();
39991
- const {
39992
- offset,
39993
- height
39994
- } = calculateTooltipOffset(tooltipText);
39995
- element.style.setProperty("--tooltip-top", `${rect.top}px`);
39996
- element.style.setProperty("--tooltip-left", `${rect.left}px`);
39997
- element.style.setProperty("--tooltip-width", `${rect.width}px`);
39998
- element.style.setProperty("--tooltip-offset", `${offset}px`);
39999
- element.style.setProperty("--tooltip-height", `${height}px`);
40000
- element.setAttribute("data-tooltip", tooltipText);
40000
+ try {
40001
+ const rect = element.getBoundingClientRect();
40002
+ const {
40003
+ offset,
40004
+ height
40005
+ } = calculateTooltipOffset(tooltipText);
40006
+ element.style.setProperty("--tooltip-top", `${rect.top}px`);
40007
+ element.style.setProperty("--tooltip-left", `${rect.left}px`);
40008
+ element.style.setProperty("--tooltip-width", `${rect.width}px`);
40009
+ element.style.setProperty("--tooltip-offset", `${offset}px`);
40010
+ element.style.setProperty("--tooltip-height", `${height}px`);
40011
+ element.setAttribute("data-tooltip", tooltipText);
40012
+ } catch (e) {
40013
+ console.warn("Error applying tooltip:", e);
40014
+ }
40001
40015
  }
40002
40016
  };
40003
40017
  const tooltipText = getTooltipText(value);
@@ -40055,7 +40069,7 @@ const TableBody = ({
40055
40069
  return value;
40056
40070
  case "status":
40057
40071
  const statusObj = statuses.find(status => status.status === value) || {};
40058
- const [palette0, palette1] = statusObj.palette;
40072
+ const [palette0, palette1] = statusObj.palette || ["#F3F4F6", "#374151"];
40059
40073
  return /*#__PURE__*/React$1.createElement(StatusCell$1, {
40060
40074
  color: palette1
40061
40075
  }, /*#__PURE__*/React$1.createElement(StatusCellCircle, {
@@ -40071,27 +40085,31 @@ const TableBody = ({
40071
40085
  $buttonColor: buttonColor,
40072
40086
  ref: el => {
40073
40087
  if (el) {
40074
- if (hasComments) {
40075
- // Add tooltip if there are comments
40076
- const rect = el.getBoundingClientRect();
40077
- const {
40078
- offset,
40079
- height
40080
- } = calculateTooltipOffset(commentTooltipText);
40081
- el.style.setProperty("--tooltip-top", `${rect.top}px`);
40082
- el.style.setProperty("--tooltip-left", `${rect.left}px`);
40083
- el.style.setProperty("--tooltip-width", `${rect.width}px`);
40084
- el.style.setProperty("--tooltip-offset", `${offset}px`);
40085
- el.style.setProperty("--tooltip-height", `${height}px`);
40086
- el.setAttribute("data-tooltip", commentTooltipText);
40087
- } else {
40088
- // Remove tooltip if there are no comments
40089
- el.removeAttribute("data-tooltip");
40090
- el.style.removeProperty("--tooltip-top");
40091
- el.style.removeProperty("--tooltip-left");
40092
- el.style.removeProperty("--tooltip-width");
40093
- el.style.removeProperty("--tooltip-offset");
40094
- el.style.removeProperty("--tooltip-height");
40088
+ try {
40089
+ if (hasComments) {
40090
+ // Add tooltip if there are comments
40091
+ const rect = el.getBoundingClientRect();
40092
+ const {
40093
+ offset,
40094
+ height
40095
+ } = calculateTooltipOffset(commentTooltipText);
40096
+ el.style.setProperty("--tooltip-top", `${rect.top}px`);
40097
+ el.style.setProperty("--tooltip-left", `${rect.left}px`);
40098
+ el.style.setProperty("--tooltip-width", `${rect.width}px`);
40099
+ el.style.setProperty("--tooltip-offset", `${offset}px`);
40100
+ el.style.setProperty("--tooltip-height", `${height}px`);
40101
+ el.setAttribute("data-tooltip", commentTooltipText);
40102
+ } else {
40103
+ // Remove tooltip if there are no comments
40104
+ el.removeAttribute("data-tooltip");
40105
+ el.style.removeProperty("--tooltip-top");
40106
+ el.style.removeProperty("--tooltip-left");
40107
+ el.style.removeProperty("--tooltip-width");
40108
+ el.style.removeProperty("--tooltip-offset");
40109
+ el.style.removeProperty("--tooltip-height");
40110
+ }
40111
+ } catch (e) {
40112
+ console.warn("Error handling comment tooltip:", e);
40095
40113
  }
40096
40114
  }
40097
40115
  },
@@ -40115,17 +40133,21 @@ const TableBody = ({
40115
40133
  $buttonColor: buttonColor,
40116
40134
  ref: el => {
40117
40135
  if (el && trashTooltipText) {
40118
- const rect = el.getBoundingClientRect();
40119
- const {
40120
- offset,
40121
- height
40122
- } = calculateTooltipOffset(trashTooltipText);
40123
- el.style.setProperty("--tooltip-top", `${rect.top}px`);
40124
- el.style.setProperty("--tooltip-left", `${rect.left}px`);
40125
- el.style.setProperty("--tooltip-width", `${rect.width}px`);
40126
- el.style.setProperty("--tooltip-offset", `${offset}px`);
40127
- el.style.setProperty("--tooltip-height", `${height}px`);
40128
- el.setAttribute("data-tooltip", trashTooltipText);
40136
+ try {
40137
+ const rect = el.getBoundingClientRect();
40138
+ const {
40139
+ offset,
40140
+ height
40141
+ } = calculateTooltipOffset(trashTooltipText);
40142
+ el.style.setProperty("--tooltip-top", `${rect.top}px`);
40143
+ el.style.setProperty("--tooltip-left", `${rect.left}px`);
40144
+ el.style.setProperty("--tooltip-width", `${rect.width}px`);
40145
+ el.style.setProperty("--tooltip-offset", `${offset}px`);
40146
+ el.style.setProperty("--tooltip-height", `${height}px`);
40147
+ el.setAttribute("data-tooltip", trashTooltipText);
40148
+ } catch (e) {
40149
+ console.warn("Error handling trash tooltip:", e);
40150
+ }
40129
40151
  }
40130
40152
  },
40131
40153
  onClick: e => {
@@ -40140,17 +40162,21 @@ const TableBody = ({
40140
40162
  return /*#__PURE__*/React$1.createElement(DisabledTrashIconWrapper$1, {
40141
40163
  ref: el => {
40142
40164
  if (el && trashTooltipText) {
40143
- const rect = el.getBoundingClientRect();
40144
- const {
40145
- offset,
40146
- height
40147
- } = calculateTooltipOffset(trashTooltipText);
40148
- el.style.setProperty("--tooltip-top", `${rect.top}px`);
40149
- el.style.setProperty("--tooltip-left", `${rect.left}px`);
40150
- el.style.setProperty("--tooltip-width", `${rect.width}px`);
40151
- el.style.setProperty("--tooltip-offset", `${offset}px`);
40152
- el.style.setProperty("--tooltip-height", `${height}px`);
40153
- el.setAttribute("data-tooltip", trashTooltipText);
40165
+ try {
40166
+ const rect = el.getBoundingClientRect();
40167
+ const {
40168
+ offset,
40169
+ height
40170
+ } = calculateTooltipOffset(trashTooltipText);
40171
+ el.style.setProperty("--tooltip-top", `${rect.top}px`);
40172
+ el.style.setProperty("--tooltip-left", `${rect.left}px`);
40173
+ el.style.setProperty("--tooltip-width", `${rect.width}px`);
40174
+ el.style.setProperty("--tooltip-offset", `${offset}px`);
40175
+ el.style.setProperty("--tooltip-height", `${height}px`);
40176
+ el.setAttribute("data-tooltip", trashTooltipText);
40177
+ } catch (e) {
40178
+ console.warn("Error handling disabled trash tooltip:", e);
40179
+ }
40154
40180
  }
40155
40181
  }
40156
40182
  }, /*#__PURE__*/React$1.createElement(DisabledTrashIcon, {
@@ -40160,13 +40186,14 @@ const TableBody = ({
40160
40186
  }
40161
40187
  return null;
40162
40188
  case "dropdown":
40189
+ if (!column) return null;
40163
40190
  const dropdownKey = `${rowIndex}-${column.key}`;
40164
40191
  const isOpen = openDropdowns[dropdownKey] || false;
40165
40192
  const dropdownOptions = column.dropdownOptions || [];
40166
40193
  const maxDropdownHeight = column.maxDropdownHeight || "200px";
40167
- const dropdownOptionsWidth = column.dropdownOptionsWidth; // Get from column config
40168
- const dropdownOptionsAlignment = column.dropdownOptionsAlignment || "right"; // Get from column config, default to 'right'
40169
- const placeholder = column.placeholder || "Select..."; // Get from column config, default to 'Select...'
40194
+ const dropdownOptionsWidth = column.dropdownOptionsWidth;
40195
+ const dropdownOptionsAlignment = column.dropdownOptionsAlignment || "right";
40196
+ const placeholder = column.placeholder || "Select...";
40170
40197
 
40171
40198
  // Find the current selected option to display its label
40172
40199
  const currentOption = dropdownOptions.find(option => option.value === value);
@@ -40187,8 +40214,7 @@ const TableBody = ({
40187
40214
  selectedColor: selectedColor
40188
40215
  });
40189
40216
  case "checkbox":
40190
- const isChecked = Boolean(value); // Convert to boolean
40191
-
40217
+ const isChecked = Boolean(value);
40192
40218
  return /*#__PURE__*/React$1.createElement("div", {
40193
40219
  style: {
40194
40220
  display: "flex",
@@ -40201,13 +40227,12 @@ const TableBody = ({
40201
40227
  type: "checkbox",
40202
40228
  checked: isChecked,
40203
40229
  onChange: e => handleCheckboxClick(row, column.key, e),
40204
- onClick: e => e.stopPropagation() // Prevent row click on checkbox click
40205
- ,
40230
+ onClick: e => e.stopPropagation(),
40206
40231
  style: {
40207
40232
  width: "18px",
40208
40233
  height: "18px",
40209
40234
  cursor: "pointer",
40210
- accentColor: buttonColor // Use the theme color for checkbox
40235
+ accentColor: buttonColor
40211
40236
  }
40212
40237
  }));
40213
40238
  default:
@@ -40223,7 +40248,6 @@ const TableBody = ({
40223
40248
  const handleExpandClick = (row, rowIndex, event) => {
40224
40249
  event.stopPropagation();
40225
40250
  if (onExpandRow) {
40226
- // Determine the expand status based on current state
40227
40251
  const expandStatus = expandedRows[rowIndex] ? "isClosed" : "isOpen";
40228
40252
  onExpandRow(row, rowIndex, expandStatus);
40229
40253
  }
@@ -40233,15 +40257,11 @@ const TableBody = ({
40233
40257
  const handleCheckboxClick = (row, columnKey, event) => {
40234
40258
  event.stopPropagation();
40235
40259
  const currentValue = row[columnKey];
40236
- const newValue = !currentValue; // Toggle the value
40237
-
40238
- // Create updated row with new checkbox value
40260
+ const newValue = !currentValue;
40239
40261
  const updatedRow = {
40240
40262
  ...row,
40241
40263
  [columnKey]: newValue
40242
40264
  };
40243
-
40244
- // Fire the onCheckboxClick event with updated row
40245
40265
  if (onCheckboxClick) {
40246
40266
  onCheckboxClick({
40247
40267
  fullRow: updatedRow,
@@ -40265,14 +40285,10 @@ const TableBody = ({
40265
40285
  const handleDropdownOptionClick = (row, rowIndex, columnKey, selectedOption, event) => {
40266
40286
  event.stopPropagation();
40267
40287
  const dropdownKey = `${rowIndex}-${columnKey}`;
40268
-
40269
- // Close the dropdown
40270
40288
  setOpenDropdowns(prev => ({
40271
40289
  ...prev,
40272
40290
  [dropdownKey]: false
40273
40291
  }));
40274
-
40275
- // Fire the onDropdownSelected event with columnKey instead of columnName
40276
40292
  if (onDropdownSelected) {
40277
40293
  onDropdownSelected(row, selectedOption, columnKey);
40278
40294
  }
@@ -40288,72 +40304,109 @@ const TableBody = ({
40288
40304
  document.removeEventListener("click", handleClickOutside);
40289
40305
  };
40290
40306
  }, []);
40291
- return /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement(StyledTableBody, null, data.map((row, rowIndex) => /*#__PURE__*/React$1.createElement(React$1.Fragment, {
40292
- key: rowIndex
40293
- }, /*#__PURE__*/React$1.createElement(TableRow, {
40294
- "data-row-index": rowIndex,
40295
- className: indexToShimmer === rowIndex ? "shimmer-row" : "",
40296
- isFocused: focusedRowIndex === rowIndex,
40297
- selectedColor: selectedColor,
40298
- onMouseEnter: () => setHoveredRowIndex(rowIndex),
40299
- onMouseLeave: () => setHoveredRowIndex(null),
40300
- onClick: () => handleRowClick(row, rowIndex)
40301
- }, expandable && expandedContent[rowIndex] !== null ? /*#__PURE__*/React$1.createElement(TableCell, {
40302
- $fieldType: "expand",
40303
- $minWidth: "16px",
40304
- $maxWidth: "16px"
40305
- }, /*#__PURE__*/React$1.createElement(ExpandIcon, {
40306
- onClick: e => handleExpandClick(row, rowIndex, e),
40307
- $isExpanded: expandedRows[rowIndex] || false
40308
- }, expandedRows[rowIndex] ? /*#__PURE__*/React$1.createElement(MenuItemOpenIcon, {
40309
- width: "12",
40310
- height: "12",
40311
- color: "#666"
40312
- }) : /*#__PURE__*/React$1.createElement(ChervronRightIcon, {
40313
- width: "12",
40314
- height: "12",
40315
- fill: "#666"
40316
- }))) : expandable === true ? /*#__PURE__*/React$1.createElement("div", null) : null, columns.map((column, columnIndex) => {
40317
- const value = row[column.key];
40318
- const formattedValue = formatValue(value, column, row, rowIndex);
40319
-
40320
- // Use the chrome shimmer hook that only animates when this row matches indexToShimmer
40321
- const {
40322
- text: shimmerText,
40323
- isShimmering
40324
- } = useShimmerChromeEffect(formattedValue, rowIndex, indexToShimmer, columnIndex, columns.length);
40325
- return /*#__PURE__*/React$1.createElement(TableCell, {
40326
- key: column.key,
40327
- ref: el => {
40328
- if (el && shouldShowTooltip(el)) {
40329
- const rect = el.getBoundingClientRect();
40330
- const {
40331
- offset,
40332
- height
40333
- } = calculateTooltipOffset(formattedValue.toString(), true);
40334
- el.style.setProperty("--cell-top", `${rect.top}px`);
40335
- el.style.setProperty("--cell-left", `${rect.left}px`);
40336
- el.style.setProperty("--cell-width", `${rect.width}px`);
40337
- el.style.setProperty("--cell-offset", `${offset}px`);
40338
- el.style.setProperty("--cell-height", `${height}px`);
40339
- el.setAttribute("data-tooltip", formattedValue);
40307
+
40308
+ // Return null if no data
40309
+ if (data.length === 0) {
40310
+ return /*#__PURE__*/React$1.createElement(StyledTableBody, {
40311
+ ref: ref
40312
+ }, /*#__PURE__*/React$1.createElement(TableRow, null, /*#__PURE__*/React$1.createElement(TableCell, {
40313
+ colSpan: columns.length
40314
+ }, "No data available")));
40315
+ }
40316
+ return /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement(StyledTableBody, {
40317
+ ref: ref
40318
+ }, data.map((row, rowIndex) => {
40319
+ // Skip invalid rows
40320
+ if (!row || typeof row !== 'object') {
40321
+ console.warn(`Invalid row at index ${rowIndex}:`, row);
40322
+ return null;
40323
+ }
40324
+ return /*#__PURE__*/React$1.createElement(React$1.Fragment, {
40325
+ key: row.id || `row-${rowIndex}`
40326
+ }, /*#__PURE__*/React$1.createElement(TableRow, {
40327
+ "data-row-index": rowIndex,
40328
+ className: indexToShimmer === rowIndex ? "shimmer-row" : "",
40329
+ isFocused: focusedRowIndex === rowIndex,
40330
+ selectedColor: selectedColor,
40331
+ onMouseEnter: () => setHoveredRowIndex(rowIndex),
40332
+ onMouseLeave: () => setHoveredRowIndex(null),
40333
+ onClick: () => handleRowClick(row, rowIndex)
40334
+ }, expandable && expandedContent[rowIndex] !== undefined && expandedContent[rowIndex] !== null ? /*#__PURE__*/React$1.createElement(TableCell, {
40335
+ $fieldType: "expand",
40336
+ $minWidth: "16px",
40337
+ $maxWidth: "16px"
40338
+ }, /*#__PURE__*/React$1.createElement(ExpandIcon, {
40339
+ onClick: e => handleExpandClick(row, rowIndex, e),
40340
+ $isExpanded: expandedRows[rowIndex] || false
40341
+ }, expandedRows[rowIndex] ? /*#__PURE__*/React$1.createElement(MenuItemOpenIcon, {
40342
+ width: "12",
40343
+ height: "12",
40344
+ color: "#666"
40345
+ }) : /*#__PURE__*/React$1.createElement(ChervronRightIcon, {
40346
+ width: "12",
40347
+ height: "12",
40348
+ fill: "#666"
40349
+ }))) : expandable === true ? /*#__PURE__*/React$1.createElement(TableCell, {
40350
+ $fieldType: "expand",
40351
+ $minWidth: "16px",
40352
+ $maxWidth: "16px"
40353
+ }) : null, columns.map((column, columnIndex) => {
40354
+ if (!column || !column.key) {
40355
+ console.warn(`Invalid column at index ${columnIndex}:`, column);
40356
+ return null;
40357
+ }
40358
+ const value = row[column.key];
40359
+ const formattedValue = formatValue(value, column, row, rowIndex);
40360
+
40361
+ // Use the chrome shimmer hook safely
40362
+ let shimmerText = formattedValue;
40363
+ let isShimmering = false;
40364
+ try {
40365
+ const shimmerResult = useShimmerChromeEffect(formattedValue, rowIndex, indexToShimmer, columnIndex, columns.length);
40366
+ if (shimmerResult) {
40367
+ shimmerText = shimmerResult.text || formattedValue;
40368
+ isShimmering = shimmerResult.isShimmering || false;
40340
40369
  }
40341
- },
40342
- $fieldType: column.fieldType?.toLowerCase(),
40343
- $color: column.color,
40344
- $minWidth: column.minWidth,
40345
- $maxWidth: column.maxWidth
40346
- }, 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, {
40347
- text: shimmerText,
40348
- isShimmering: isShimmering
40349
- }) : formattedValue);
40350
- })), expandable && expandedRows[rowIndex] && /*#__PURE__*/React$1.createElement(ExpandedRow, {
40351
- $expandedBackgroundColor: expandedBackgroundColor
40352
- }, /*#__PURE__*/React$1.createElement(TableCell, {
40353
- colSpan: columns.length + 1
40354
- }, /*#__PURE__*/React$1.createElement(ExpandedContent, {
40355
- $expandedBackgroundColor: expandedBackgroundColor
40356
- }, expandedContent[rowIndex] || null)))))), /*#__PURE__*/React$1.createElement(MessageBox, {
40370
+ } catch (e) {
40371
+ console.warn("Error with shimmer effect:", e);
40372
+ }
40373
+ return /*#__PURE__*/React$1.createElement(TableCell, {
40374
+ key: `${column.key}-${rowIndex}`,
40375
+ ref: el => {
40376
+ if (el && shouldShowTooltip(el)) {
40377
+ try {
40378
+ const rect = el.getBoundingClientRect();
40379
+ const {
40380
+ offset,
40381
+ height
40382
+ } = calculateTooltipOffset(formattedValue.toString(), true);
40383
+ el.style.setProperty("--cell-top", `${rect.top}px`);
40384
+ el.style.setProperty("--cell-left", `${rect.left}px`);
40385
+ el.style.setProperty("--cell-width", `${rect.width}px`);
40386
+ el.style.setProperty("--cell-offset", `${offset}px`);
40387
+ el.style.setProperty("--cell-height", `${height}px`);
40388
+ el.setAttribute("data-tooltip", formattedValue);
40389
+ } catch (e) {
40390
+ console.warn("Error setting cell tooltip:", e);
40391
+ }
40392
+ }
40393
+ },
40394
+ $fieldType: column.fieldType?.toLowerCase(),
40395
+ $color: column.color,
40396
+ $minWidth: column.minWidth,
40397
+ $maxWidth: column.maxWidth
40398
+ }, 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, {
40399
+ text: shimmerText,
40400
+ isShimmering: isShimmering
40401
+ }) : formattedValue);
40402
+ })), expandable && expandedRows[rowIndex] && /*#__PURE__*/React$1.createElement(ExpandedRow, {
40403
+ $expandedBackgroundColor: expandedBackgroundColor
40404
+ }, /*#__PURE__*/React$1.createElement(TableCell, {
40405
+ colSpan: columns.length + 1
40406
+ }, /*#__PURE__*/React$1.createElement(ExpandedContent, {
40407
+ $expandedBackgroundColor: expandedBackgroundColor
40408
+ }, expandedContent[rowIndex] || null))));
40409
+ })), /*#__PURE__*/React$1.createElement(MessageBox, {
40357
40410
  title: "Add Comment",
40358
40411
  isOpen: isCommentModalOpen,
40359
40412
  onClose: handleCommentModalClose,
@@ -40378,7 +40431,7 @@ const TableBody = ({
40378
40431
  onBlur: handleBlur,
40379
40432
  onFocus: handleFocus
40380
40433
  }), /*#__PURE__*/React$1.createElement(CharacterCount, null, commentText.length, "/", commentTextLimit))));
40381
- };
40434
+ });
40382
40435
  TableBody.propTypes = {
40383
40436
  columns: PropTypes.array.isRequired,
40384
40437
  data: PropTypes.array.isRequired,
@@ -40395,10 +40448,14 @@ TableBody.propTypes = {
40395
40448
  statuses: PropTypes.array,
40396
40449
  onCommentSave: PropTypes.func,
40397
40450
  commentTextLimit: PropTypes.number,
40451
+ expandable: PropTypes.bool,
40452
+ expandedRows: PropTypes.object,
40453
+ expandedContent: PropTypes.object,
40454
+ onExpandRow: PropTypes.func,
40455
+ expandedBackgroundColor: PropTypes.string,
40398
40456
  onDropdownSelected: PropTypes.func,
40399
40457
  onCheckboxClick: PropTypes.func,
40400
- onHeaderCheckboxClick: PropTypes.func,
40401
- ref: PropTypes.object
40458
+ onHeaderCheckboxClick: PropTypes.func
40402
40459
  };
40403
40460
  TableBody.displayName = "TableBody";
40404
40461
 
@@ -44815,6 +44872,15 @@ const SelectionTitle = styled.span`
44815
44872
  font-weight: 700;
44816
44873
  line-height: normal;
44817
44874
  `;
44875
+ const ErrorLabel = styled.div`
44876
+ color: red;
44877
+ font-family: Poppins;
44878
+ font-size: 12px;
44879
+ height: 12px;
44880
+ font-style: normal;
44881
+ font-weight: 400;
44882
+ line-height: normal;
44883
+ `;
44818
44884
  const BackTitle = styled.span`
44819
44885
  margin-left: 4px;
44820
44886
  color: #212121;
@@ -44952,19 +45018,26 @@ const NewSubitem = ({
44952
45018
  vendor,
44953
45019
  onBack,
44954
45020
  addNewPackage,
45021
+ updateExistingPackage,
44955
45022
  componentText = "Scale"
44956
45023
  }) => {
44957
45024
  const [negotiatedBrands, setNegotiatedBrands] = useState("");
44958
45025
  const [negotiatedComponent, setNegotiatedComponent] = useState(componentText);
44959
-
45026
+ const [isPackageDuplicated, setIsPackageDuplicated] = useState(false);
44960
45027
  // Form state
44961
- const isApplyEnabled = negotiatedBrands.trim().length > 2;
45028
+ const [isApplyEnabled, setIsApplyEnabled] = useState(negotiatedBrands.trim().length > 2);
44962
45029
  useEffect(() => {
45030
+ console.log("packageObject", vendor);
44963
45031
  if (!packageObject) return;
44964
45032
  if (!packageObject.brands) return;
44965
45033
  setNegotiatedBrands(packageObject.brands);
44966
45034
  setNegotiatedComponent(packageObject.component);
44967
45035
  }, [packageObject]);
45036
+ useEffect(() => {
45037
+ if (packageObject && packageObject.brands === negotiatedBrands) return;
45038
+ setIsPackageDuplicated(vendor.packages.some(pkg => pkg.brands === negotiatedBrands));
45039
+ setIsApplyEnabled(negotiatedBrands.trim().length > 2 && vendor.packages.some(pkg => pkg.brands === negotiatedBrands) === false);
45040
+ }, [negotiatedBrands]);
44968
45041
  return /*#__PURE__*/React$1.createElement(NewSubitemContainer, null, /*#__PURE__*/React$1.createElement(Header, null, /*#__PURE__*/React$1.createElement(BackButton, {
44969
45042
  onClick: onBack
44970
45043
  }, /*#__PURE__*/React$1.createElement(ArrowLeftIcon, null)), /*#__PURE__*/React$1.createElement(BackTitle, null, vendor.name)), /*#__PURE__*/React$1.createElement(SelectionTitle, null, "Add Package"), /*#__PURE__*/React$1.createElement(ButtonsContainer, null, /*#__PURE__*/React$1.createElement(Button$1, {
@@ -44982,7 +45055,11 @@ const NewSubitem = ({
44982
45055
  }), /*#__PURE__*/React$1.createElement(Button$1, {
44983
45056
  leftIcon: "none",
44984
45057
  onClick: () => {
44985
- addNewPackage(vendor.name, negotiatedBrands, negotiatedComponent);
45058
+ if (packageObject) {
45059
+ updateExistingPackage(vendor.name, packageObject, negotiatedBrands, negotiatedComponent);
45060
+ } else {
45061
+ addNewPackage(vendor.name, negotiatedBrands, negotiatedComponent);
45062
+ }
44986
45063
  },
44987
45064
  rightIcon: "none",
44988
45065
  size: "small",
@@ -45003,7 +45080,7 @@ const NewSubitem = ({
45003
45080
  onChange: e => setNegotiatedBrands(e.target.value),
45004
45081
  required: true,
45005
45082
  placeholder: "Specify by text the participated brands, divided by commas"
45006
- })), /*#__PURE__*/React$1.createElement(NegotiatedContainer, null, /*#__PURE__*/React$1.createElement(AddNegotiatedBrand, null, "Component ", /*#__PURE__*/React$1.createElement("span", {
45083
+ }), isPackageDuplicated ? /*#__PURE__*/React$1.createElement(ErrorLabel, null, "Package already exists for that vendor, Please enter a unique package.") : /*#__PURE__*/React$1.createElement(ErrorLabel, null)), /*#__PURE__*/React$1.createElement(NegotiatedContainer, null, /*#__PURE__*/React$1.createElement(AddNegotiatedBrand, null, "Component ", /*#__PURE__*/React$1.createElement("span", {
45007
45084
  style: {
45008
45085
  color: "red"
45009
45086
  }
@@ -53687,10 +53764,6 @@ const ItemManagerPanel = _ref => {
53687
53764
  const [trashIsHovered, setTrashIsHovered] = useState(false);
53688
53765
  const [headerHeight, setHeaderHeight] = useState(0);
53689
53766
  const headerRef = useRef(null);
53690
- useEffect(() => {
53691
- console.log("Screen changed to:", screen);
53692
- console.log("Selected Vendor:", selectedVendor);
53693
- }, [screen, selectedVendor]);
53694
53767
  useEffect(() => {
53695
53768
  if (headerRef.current) {
53696
53769
  setHeaderHeight(headerRef.current.offsetHeight);