sag_components 2.0.0-beta189 → 2.0.0-beta191

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';
@@ -12252,16 +12252,13 @@ const Td$1 = styled.td`
12252
12252
  `;
12253
12253
  const Tr = styled.tr`
12254
12254
  border-bottom: 1px solid #f3f4f6;
12255
- ${_ref => {
12256
- let {
12257
- enableHover,
12258
- selectHoverColor
12259
- } = _ref;
12260
- return enableHover && `&:hover {
12255
+ ${({
12256
+ enableHover,
12257
+ selectHoverColor
12258
+ }) => enableHover && `&:hover {
12261
12259
  background-color: ${selectHoverColor};
12262
12260
  cursor: pointer;
12263
- }`;
12264
- }}
12261
+ }`}
12265
12262
  `;
12266
12263
  const InfoText = styled.div`
12267
12264
  font-weight: 400;
@@ -39778,9 +39775,9 @@ const ChromeShimmerText = ({
39778
39775
  };
39779
39776
 
39780
39777
  // TableBody.jsx
39781
- const TableBody = ({
39782
- columns,
39783
- data,
39778
+ const TableBody = /*#__PURE__*/forwardRef(({
39779
+ columns = [],
39780
+ data = [],
39784
39781
  onRowClick,
39785
39782
  onSendClick,
39786
39783
  buttonColor,
@@ -39814,9 +39811,8 @@ const TableBody = ({
39814
39811
  // New prop with default
39815
39812
  onDropdownSelected = () => {},
39816
39813
  onCheckboxClick = () => {},
39817
- onHeaderCheckboxClick = () => {},
39818
- ref = null
39819
- }) => {
39814
+ onHeaderCheckboxClick = () => {}
39815
+ }, ref) => {
39820
39816
  const [hoveredRowIndex, setHoveredRowIndex] = useState(null);
39821
39817
  const [focusedRowIndex, setFocusedRowIndex] = useState(null);
39822
39818
  const [isCommentModalOpen, setIsCommentModalOpen] = useState(false);
@@ -39828,8 +39824,33 @@ const TableBody = ({
39828
39824
  const [isFocused, setIsFocused] = useState(false);
39829
39825
  const [hasUserInteracted, setHasUserInteracted] = useState(false);
39830
39826
  const [hasInitialValue, setHasInitialValue] = useState(false);
39827
+
39828
+ // Early return for invalid data
39829
+ if (!Array.isArray(data) || !Array.isArray(columns)) {
39830
+ console.warn("TableBody: Invalid data or columns prop");
39831
+ return null;
39832
+ }
39833
+
39834
+ // Expose methods to parent component via ref
39835
+ useImperativeHandle(ref, () => ({
39836
+ clearFocus: () => {
39837
+ setFocusedRowIndex(null);
39838
+ setHoveredRowIndex(null);
39839
+ },
39840
+ setFocus: index => {
39841
+ setFocusedRowIndex(index);
39842
+ },
39843
+ getFocusedIndex: () => {
39844
+ return focusedRowIndex;
39845
+ },
39846
+ clearSelection: () => {
39847
+ setFocusedRowIndex(null);
39848
+ setHoveredRowIndex(null);
39849
+ setOpenDropdowns({});
39850
+ }
39851
+ }), [focusedRowIndex]);
39831
39852
  useEffect(() => {
39832
- if (isCommentModalOpen && currentCommentRow !== null) {
39853
+ if (isCommentModalOpen && currentCommentRow !== null && data[currentCommentRow]) {
39833
39854
  const initialText = data[currentCommentRow]?.Comments || "";
39834
39855
  setCommentText(initialText);
39835
39856
  setHasInitialValue(Boolean(initialText.trim()));
@@ -39842,7 +39863,7 @@ const TableBody = ({
39842
39863
  }
39843
39864
  }, [resetFocusIndex]);
39844
39865
  useEffect(() => {
39845
- if (changeFocusIndex) {
39866
+ if (changeFocusIndex !== undefined && changeFocusIndex !== null) {
39846
39867
  setFocusedRowIndex(changeFocusIndex);
39847
39868
  }
39848
39869
  }, [changeFocusIndex]);
@@ -39894,41 +39915,46 @@ const TableBody = ({
39894
39915
 
39895
39916
  // Helper function to format tag text
39896
39917
  const formatTagText = tag => {
39897
- if (typeof tag !== "string") return tag;
39918
+ if (typeof tag !== "string") return String(tag || "");
39898
39919
  return tag.replace(/-/g, " ").replace(/\b\w/g, l => l.toUpperCase());
39899
39920
  };
39900
39921
  const formatValue = (value, column, row, rowIndex) => {
39901
- if ((value === null || value === undefined) && column.fieldType?.toLowerCase() !== "comments") {
39922
+ if ((value === null || value === undefined) && column?.fieldType?.toLowerCase() !== "comments") {
39902
39923
  return "";
39903
39924
  }
39904
39925
 
39905
39926
  // Find the tooltip text for the current value - can be used for different fieldTypes
39906
39927
  const getTooltipText = value => {
39907
- if (column.tooltipText && Array.isArray(column.tooltipText)) {
39928
+ if (column?.tooltipText && Array.isArray(column.tooltipText)) {
39908
39929
  const tooltipItem = column.tooltipText.find(item => item.value === value);
39909
39930
  return tooltipItem ? tooltipItem.label : null;
39910
39931
  }
39911
39932
  return null;
39912
39933
  };
39913
- switch (column.fieldType?.toLowerCase()) {
39934
+ switch (column?.fieldType?.toLowerCase()) {
39914
39935
  case "currency":
39915
39936
  if (column.format === "$0.00") {
39916
- return `$${parseFloat(value).toFixed(2)}`;
39937
+ return `$${parseFloat(value || 0).toFixed(2)}`;
39917
39938
  }
39918
39939
  return value;
39919
39940
  case "text":
39920
39941
  return value?.toString() || "";
39921
39942
  case "number":
39922
39943
  if (column.format && column.format.includes(",")) {
39923
- return value.toLocaleString();
39944
+ return (value || 0).toLocaleString();
39924
39945
  }
39925
39946
  return value;
39926
39947
  case "percentage":
39927
- return `${value}%`;
39948
+ return `${value || 0}%`;
39928
39949
  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()}`;
39950
+ if (column.format === "MM/DD/YYYY" && value) {
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()}`;
39954
+ } catch (e) {
39955
+ console.warn("Invalid date format:", value);
39956
+ return value;
39957
+ }
39932
39958
  }
39933
39959
  return value;
39934
39960
  case "boolean":
@@ -39987,17 +40013,21 @@ const TableBody = ({
39987
40013
  // Helper function to apply tooltip logic
39988
40014
  const applyTooltipLogic = (element, tooltipText) => {
39989
40015
  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);
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);
40030
+ }
40001
40031
  }
40002
40032
  };
40003
40033
  const tooltipText = getTooltipText(value);
@@ -40055,7 +40085,7 @@ const TableBody = ({
40055
40085
  return value;
40056
40086
  case "status":
40057
40087
  const statusObj = statuses.find(status => status.status === value) || {};
40058
- const [palette0, palette1] = statusObj.palette;
40088
+ const [palette0, palette1] = statusObj.palette || ["#F3F4F6", "#374151"];
40059
40089
  return /*#__PURE__*/React$1.createElement(StatusCell$1, {
40060
40090
  color: palette1
40061
40091
  }, /*#__PURE__*/React$1.createElement(StatusCellCircle, {
@@ -40071,27 +40101,31 @@ const TableBody = ({
40071
40101
  $buttonColor: buttonColor,
40072
40102
  ref: el => {
40073
40103
  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");
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);
40095
40129
  }
40096
40130
  }
40097
40131
  },
@@ -40115,17 +40149,21 @@ const TableBody = ({
40115
40149
  $buttonColor: buttonColor,
40116
40150
  ref: el => {
40117
40151
  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);
40152
+ 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);
40164
+ } catch (e) {
40165
+ console.warn("Error handling trash tooltip:", e);
40166
+ }
40129
40167
  }
40130
40168
  },
40131
40169
  onClick: e => {
@@ -40140,17 +40178,21 @@ const TableBody = ({
40140
40178
  return /*#__PURE__*/React$1.createElement(DisabledTrashIconWrapper$1, {
40141
40179
  ref: el => {
40142
40180
  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);
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);
40195
+ }
40154
40196
  }
40155
40197
  }
40156
40198
  }, /*#__PURE__*/React$1.createElement(DisabledTrashIcon, {
@@ -40160,13 +40202,14 @@ const TableBody = ({
40160
40202
  }
40161
40203
  return null;
40162
40204
  case "dropdown":
40205
+ if (!column) return null;
40163
40206
  const dropdownKey = `${rowIndex}-${column.key}`;
40164
40207
  const isOpen = openDropdowns[dropdownKey] || false;
40165
40208
  const dropdownOptions = column.dropdownOptions || [];
40166
40209
  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...'
40210
+ const dropdownOptionsWidth = column.dropdownOptionsWidth;
40211
+ const dropdownOptionsAlignment = column.dropdownOptionsAlignment || "right";
40212
+ const placeholder = column.placeholder || "Select...";
40170
40213
 
40171
40214
  // Find the current selected option to display its label
40172
40215
  const currentOption = dropdownOptions.find(option => option.value === value);
@@ -40187,8 +40230,7 @@ const TableBody = ({
40187
40230
  selectedColor: selectedColor
40188
40231
  });
40189
40232
  case "checkbox":
40190
- const isChecked = Boolean(value); // Convert to boolean
40191
-
40233
+ const isChecked = Boolean(value);
40192
40234
  return /*#__PURE__*/React$1.createElement("div", {
40193
40235
  style: {
40194
40236
  display: "flex",
@@ -40201,13 +40243,12 @@ const TableBody = ({
40201
40243
  type: "checkbox",
40202
40244
  checked: isChecked,
40203
40245
  onChange: e => handleCheckboxClick(row, column.key, e),
40204
- onClick: e => e.stopPropagation() // Prevent row click on checkbox click
40205
- ,
40246
+ onClick: e => e.stopPropagation(),
40206
40247
  style: {
40207
40248
  width: "18px",
40208
40249
  height: "18px",
40209
40250
  cursor: "pointer",
40210
- accentColor: buttonColor // Use the theme color for checkbox
40251
+ accentColor: buttonColor
40211
40252
  }
40212
40253
  }));
40213
40254
  default:
@@ -40223,7 +40264,6 @@ const TableBody = ({
40223
40264
  const handleExpandClick = (row, rowIndex, event) => {
40224
40265
  event.stopPropagation();
40225
40266
  if (onExpandRow) {
40226
- // Determine the expand status based on current state
40227
40267
  const expandStatus = expandedRows[rowIndex] ? "isClosed" : "isOpen";
40228
40268
  onExpandRow(row, rowIndex, expandStatus);
40229
40269
  }
@@ -40233,15 +40273,11 @@ const TableBody = ({
40233
40273
  const handleCheckboxClick = (row, columnKey, event) => {
40234
40274
  event.stopPropagation();
40235
40275
  const currentValue = row[columnKey];
40236
- const newValue = !currentValue; // Toggle the value
40237
-
40238
- // Create updated row with new checkbox value
40276
+ const newValue = !currentValue;
40239
40277
  const updatedRow = {
40240
40278
  ...row,
40241
40279
  [columnKey]: newValue
40242
40280
  };
40243
-
40244
- // Fire the onCheckboxClick event with updated row
40245
40281
  if (onCheckboxClick) {
40246
40282
  onCheckboxClick({
40247
40283
  fullRow: updatedRow,
@@ -40265,14 +40301,10 @@ const TableBody = ({
40265
40301
  const handleDropdownOptionClick = (row, rowIndex, columnKey, selectedOption, event) => {
40266
40302
  event.stopPropagation();
40267
40303
  const dropdownKey = `${rowIndex}-${columnKey}`;
40268
-
40269
- // Close the dropdown
40270
40304
  setOpenDropdowns(prev => ({
40271
40305
  ...prev,
40272
40306
  [dropdownKey]: false
40273
40307
  }));
40274
-
40275
- // Fire the onDropdownSelected event with columnKey instead of columnName
40276
40308
  if (onDropdownSelected) {
40277
40309
  onDropdownSelected(row, selectedOption, columnKey);
40278
40310
  }
@@ -40288,72 +40320,109 @@ const TableBody = ({
40288
40320
  document.removeEventListener("click", handleClickOutside);
40289
40321
  };
40290
40322
  }, []);
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);
40323
+
40324
+ // Return null if no data
40325
+ if (data.length === 0) {
40326
+ return /*#__PURE__*/React$1.createElement(StyledTableBody, {
40327
+ ref: ref
40328
+ }, /*#__PURE__*/React$1.createElement(TableRow, null, /*#__PURE__*/React$1.createElement(TableCell, {
40329
+ colSpan: columns.length
40330
+ }, "No data available")));
40331
+ }
40332
+ return /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement(StyledTableBody, {
40333
+ ref: ref
40334
+ }, data.map((row, rowIndex) => {
40335
+ // Skip invalid rows
40336
+ if (!row || typeof row !== 'object') {
40337
+ console.warn(`Invalid row at index ${rowIndex}:`, row);
40338
+ return null;
40339
+ }
40340
+ return /*#__PURE__*/React$1.createElement(React$1.Fragment, {
40341
+ key: row.id || `row-${rowIndex}`
40342
+ }, /*#__PURE__*/React$1.createElement(TableRow, {
40343
+ "data-row-index": rowIndex,
40344
+ className: indexToShimmer === rowIndex ? "shimmer-row" : "",
40345
+ isFocused: focusedRowIndex === rowIndex,
40346
+ selectedColor: selectedColor,
40347
+ onMouseEnter: () => setHoveredRowIndex(rowIndex),
40348
+ onMouseLeave: () => setHoveredRowIndex(null),
40349
+ onClick: () => handleRowClick(row, rowIndex)
40350
+ }, expandable && expandedContent[rowIndex] !== undefined && expandedContent[rowIndex] !== null ? /*#__PURE__*/React$1.createElement(TableCell, {
40351
+ $fieldType: "expand",
40352
+ $minWidth: "16px",
40353
+ $maxWidth: "16px"
40354
+ }, /*#__PURE__*/React$1.createElement(ExpandIcon, {
40355
+ onClick: e => handleExpandClick(row, rowIndex, e),
40356
+ $isExpanded: expandedRows[rowIndex] || false
40357
+ }, expandedRows[rowIndex] ? /*#__PURE__*/React$1.createElement(MenuItemOpenIcon, {
40358
+ width: "12",
40359
+ height: "12",
40360
+ color: "#666"
40361
+ }) : /*#__PURE__*/React$1.createElement(ChervronRightIcon, {
40362
+ width: "12",
40363
+ height: "12",
40364
+ fill: "#666"
40365
+ }))) : expandable === true ? /*#__PURE__*/React$1.createElement(TableCell, {
40366
+ $fieldType: "expand",
40367
+ $minWidth: "16px",
40368
+ $maxWidth: "16px"
40369
+ }) : null, columns.map((column, columnIndex) => {
40370
+ if (!column || !column.key) {
40371
+ console.warn(`Invalid column at index ${columnIndex}:`, column);
40372
+ return null;
40373
+ }
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;
40380
+ try {
40381
+ const shimmerResult = useShimmerChromeEffect(formattedValue, rowIndex, indexToShimmer, columnIndex, columns.length);
40382
+ if (shimmerResult) {
40383
+ shimmerText = shimmerResult.text || formattedValue;
40384
+ isShimmering = shimmerResult.isShimmering || false;
40340
40385
  }
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, {
40386
+ } catch (e) {
40387
+ console.warn("Error with shimmer effect:", e);
40388
+ }
40389
+ return /*#__PURE__*/React$1.createElement(TableCell, {
40390
+ key: `${column.key}-${rowIndex}`,
40391
+ ref: el => {
40392
+ if (el && shouldShowTooltip(el)) {
40393
+ try {
40394
+ 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);
40405
+ } catch (e) {
40406
+ console.warn("Error setting cell tooltip:", e);
40407
+ }
40408
+ }
40409
+ },
40410
+ $fieldType: column.fieldType?.toLowerCase(),
40411
+ $color: column.color,
40412
+ $minWidth: column.minWidth,
40413
+ $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,
40416
+ isShimmering: isShimmering
40417
+ }) : formattedValue);
40418
+ })), expandable && expandedRows[rowIndex] && /*#__PURE__*/React$1.createElement(ExpandedRow, {
40419
+ $expandedBackgroundColor: expandedBackgroundColor
40420
+ }, /*#__PURE__*/React$1.createElement(TableCell, {
40421
+ colSpan: columns.length + 1
40422
+ }, /*#__PURE__*/React$1.createElement(ExpandedContent, {
40423
+ $expandedBackgroundColor: expandedBackgroundColor
40424
+ }, expandedContent[rowIndex] || null))));
40425
+ })), /*#__PURE__*/React$1.createElement(MessageBox, {
40357
40426
  title: "Add Comment",
40358
40427
  isOpen: isCommentModalOpen,
40359
40428
  onClose: handleCommentModalClose,
@@ -40378,7 +40447,7 @@ const TableBody = ({
40378
40447
  onBlur: handleBlur,
40379
40448
  onFocus: handleFocus
40380
40449
  }), /*#__PURE__*/React$1.createElement(CharacterCount, null, commentText.length, "/", commentTextLimit))));
40381
- };
40450
+ });
40382
40451
  TableBody.propTypes = {
40383
40452
  columns: PropTypes.array.isRequired,
40384
40453
  data: PropTypes.array.isRequired,
@@ -40395,10 +40464,14 @@ TableBody.propTypes = {
40395
40464
  statuses: PropTypes.array,
40396
40465
  onCommentSave: PropTypes.func,
40397
40466
  commentTextLimit: PropTypes.number,
40467
+ expandable: PropTypes.bool,
40468
+ expandedRows: PropTypes.object,
40469
+ expandedContent: PropTypes.object,
40470
+ onExpandRow: PropTypes.func,
40471
+ expandedBackgroundColor: PropTypes.string,
40398
40472
  onDropdownSelected: PropTypes.func,
40399
40473
  onCheckboxClick: PropTypes.func,
40400
- onHeaderCheckboxClick: PropTypes.func,
40401
- ref: PropTypes.object
40474
+ onHeaderCheckboxClick: PropTypes.func
40402
40475
  };
40403
40476
  TableBody.displayName = "TableBody";
40404
40477
 
@@ -44815,6 +44888,15 @@ const SelectionTitle = styled.span`
44815
44888
  font-weight: 700;
44816
44889
  line-height: normal;
44817
44890
  `;
44891
+ const ErrorLabel = styled.div`
44892
+ color: red;
44893
+ font-family: Poppins;
44894
+ font-size: 12px;
44895
+ height: 12px;
44896
+ font-style: normal;
44897
+ font-weight: 400;
44898
+ line-height: normal;
44899
+ `;
44818
44900
  const BackTitle = styled.span`
44819
44901
  margin-left: 4px;
44820
44902
  color: #212121;
@@ -44952,19 +45034,26 @@ const NewSubitem = ({
44952
45034
  vendor,
44953
45035
  onBack,
44954
45036
  addNewPackage,
45037
+ updateExistingPackage,
44955
45038
  componentText = "Scale"
44956
45039
  }) => {
44957
45040
  const [negotiatedBrands, setNegotiatedBrands] = useState("");
44958
45041
  const [negotiatedComponent, setNegotiatedComponent] = useState(componentText);
44959
-
45042
+ const [isPackageDuplicated, setIsPackageDuplicated] = useState(false);
44960
45043
  // Form state
44961
- const isApplyEnabled = negotiatedBrands.trim().length > 2;
45044
+ const [isApplyEnabled, setIsApplyEnabled] = useState(negotiatedBrands.trim().length > 2);
44962
45045
  useEffect(() => {
45046
+ console.log("packageObject", vendor);
44963
45047
  if (!packageObject) return;
44964
45048
  if (!packageObject.brands) return;
44965
45049
  setNegotiatedBrands(packageObject.brands);
44966
45050
  setNegotiatedComponent(packageObject.component);
44967
45051
  }, [packageObject]);
45052
+ useEffect(() => {
45053
+ if (packageObject && packageObject.brands === negotiatedBrands) return;
45054
+ setIsPackageDuplicated(vendor.packages.some(pkg => pkg.brands === negotiatedBrands));
45055
+ setIsApplyEnabled(negotiatedBrands.trim().length > 2 && vendor.packages.some(pkg => pkg.brands === negotiatedBrands) === false);
45056
+ }, [negotiatedBrands]);
44968
45057
  return /*#__PURE__*/React$1.createElement(NewSubitemContainer, null, /*#__PURE__*/React$1.createElement(Header, null, /*#__PURE__*/React$1.createElement(BackButton, {
44969
45058
  onClick: onBack
44970
45059
  }, /*#__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 +45071,11 @@ const NewSubitem = ({
44982
45071
  }), /*#__PURE__*/React$1.createElement(Button$1, {
44983
45072
  leftIcon: "none",
44984
45073
  onClick: () => {
44985
- addNewPackage(vendor.name, negotiatedBrands, negotiatedComponent);
45074
+ if (packageObject) {
45075
+ updateExistingPackage(vendor.name, packageObject, negotiatedBrands, negotiatedComponent);
45076
+ } else {
45077
+ addNewPackage(vendor.name, negotiatedBrands, negotiatedComponent);
45078
+ }
44986
45079
  },
44987
45080
  rightIcon: "none",
44988
45081
  size: "small",
@@ -45003,7 +45096,7 @@ const NewSubitem = ({
45003
45096
  onChange: e => setNegotiatedBrands(e.target.value),
45004
45097
  required: true,
45005
45098
  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", {
45099
+ }), 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
45100
  style: {
45008
45101
  color: "red"
45009
45102
  }
@@ -53687,10 +53780,6 @@ const ItemManagerPanel = _ref => {
53687
53780
  const [trashIsHovered, setTrashIsHovered] = useState(false);
53688
53781
  const [headerHeight, setHeaderHeight] = useState(0);
53689
53782
  const headerRef = useRef(null);
53690
- useEffect(() => {
53691
- console.log("Screen changed to:", screen);
53692
- console.log("Selected Vendor:", selectedVendor);
53693
- }, [screen, selectedVendor]);
53694
53783
  useEffect(() => {
53695
53784
  if (headerRef.current) {
53696
53785
  setHeaderHeight(headerRef.current.offsetHeight);