sag_components 2.0.0-beta188 → 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';
@@ -10579,24 +10579,23 @@ const QuarterPopupPicker = ({
10579
10579
  };
10580
10580
 
10581
10581
  /* eslint-disable import/no-extraneous-dependencies */
10582
- const QuarterPicker = _ref => {
10583
- let {
10584
- availableQuarters,
10585
- // ["Q1-2024"]
10586
- label,
10587
- onChange,
10588
- borderRadius,
10589
- required,
10590
- width,
10591
- height,
10592
- placeholder,
10593
- disabled,
10594
- borderColor,
10595
- borderColorFocus,
10596
- textColor,
10597
- selectedValue,
10598
- startYear
10599
- } = _ref;
10582
+ const QuarterPicker = ({
10583
+ availableQuarters,
10584
+ // ["Q1-2024"]
10585
+ label,
10586
+ onChange,
10587
+ borderRadius,
10588
+ required,
10589
+ width,
10590
+ height,
10591
+ placeholder,
10592
+ disabled,
10593
+ borderColor,
10594
+ borderColorFocus,
10595
+ textColor,
10596
+ selectedValue,
10597
+ startYear
10598
+ }) => {
10600
10599
  const [isFocused, setIsFocused] = useState(false);
10601
10600
  const [isOpen, setIsOpen] = useState(false);
10602
10601
  const [value, setValue] = useState('');
@@ -11038,23 +11037,22 @@ const MonthPopupPicker = ({
11038
11037
  };
11039
11038
 
11040
11039
  /* eslint-disable import/no-extraneous-dependencies */
11041
- const MonthPicker = _ref => {
11042
- let {
11043
- availableMonths,
11044
- label,
11045
- onChange,
11046
- borderRadius,
11047
- required,
11048
- width,
11049
- height,
11050
- placeholder,
11051
- disabled,
11052
- borderColor,
11053
- borderColorFocus,
11054
- textColor,
11055
- selectedValue,
11056
- startYear
11057
- } = _ref;
11040
+ const MonthPicker = ({
11041
+ availableMonths,
11042
+ label,
11043
+ onChange,
11044
+ borderRadius,
11045
+ required,
11046
+ width,
11047
+ height,
11048
+ placeholder,
11049
+ disabled,
11050
+ borderColor,
11051
+ borderColorFocus,
11052
+ textColor,
11053
+ selectedValue,
11054
+ startYear
11055
+ }) => {
11058
11056
  const [isFocused, setIsFocused] = useState(false);
11059
11057
  const [isOpen, setIsOpen] = useState(false);
11060
11058
  const [value, setValue] = useState('');
@@ -24165,22 +24163,21 @@ const DeleteIcon = styled.div`
24165
24163
  position: absolute;
24166
24164
  `;
24167
24165
 
24168
- const QuickFilterDropdownSingle = _ref => {
24169
- let {
24170
- label,
24171
- hoverColor,
24172
- options,
24173
- selectedValue,
24174
- placeHolder,
24175
- onChange,
24176
- disabled,
24177
- width,
24178
- error,
24179
- errorMessage,
24180
- xIconShow,
24181
- labelColor,
24182
- showLabelOnTop
24183
- } = _ref;
24166
+ const QuickFilterDropdownSingle = ({
24167
+ label,
24168
+ hoverColor,
24169
+ options,
24170
+ selectedValue,
24171
+ placeHolder,
24172
+ onChange,
24173
+ disabled,
24174
+ width,
24175
+ error,
24176
+ errorMessage,
24177
+ xIconShow,
24178
+ labelColor,
24179
+ showLabelOnTop
24180
+ }) => {
24184
24181
  const [isFocused, setIsFocused] = useState(false);
24185
24182
  const [showOptions, setShowOptions] = useState(false);
24186
24183
  const [inputValue, setInputValue] = useState("");
@@ -24577,24 +24574,23 @@ const IconContainer$2 = styled.div`
24577
24574
  cursor: pointer;
24578
24575
  `;
24579
24576
 
24580
- const QuickFilterDropdownMultiSelection = _ref => {
24581
- let {
24582
- label,
24583
- labelEmptyValue,
24584
- options,
24585
- selectedValue,
24586
- placeHolder,
24587
- onChange,
24588
- required,
24589
- disabled,
24590
- width,
24591
- error,
24592
- errorMessage,
24593
- labelColor,
24594
- xIconShow,
24595
- checkBoxColor,
24596
- showLabelOnTop
24597
- } = _ref;
24577
+ const QuickFilterDropdownMultiSelection = ({
24578
+ label,
24579
+ labelEmptyValue,
24580
+ options,
24581
+ selectedValue,
24582
+ placeHolder,
24583
+ onChange,
24584
+ required,
24585
+ disabled,
24586
+ width,
24587
+ error,
24588
+ errorMessage,
24589
+ labelColor,
24590
+ xIconShow,
24591
+ checkBoxColor,
24592
+ showLabelOnTop
24593
+ }) => {
24598
24594
  const [isFocused, setIsFocused] = useState(false);
24599
24595
  const [showOptions, setShowOptions] = useState(false);
24600
24596
  const [inputValue, setInputValue] = useState('');
@@ -39742,11 +39738,11 @@ const ChromeShimmerText = ({
39742
39738
  transition: 'all 0.3s ease'
39743
39739
  };
39744
39740
  if (!isShimmering) {
39745
- return /*#__PURE__*/React.createElement("span", null, text);
39741
+ return /*#__PURE__*/React$1.createElement("span", null, text);
39746
39742
  }
39747
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
39743
+ return /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement("span", {
39748
39744
  style: shimmerStyle
39749
- }, text), /*#__PURE__*/React.createElement("style", {
39745
+ }, text), /*#__PURE__*/React$1.createElement("style", {
39750
39746
  jsx: true
39751
39747
  }, `
39752
39748
  @-webkit-keyframes chromeShine {
@@ -39782,9 +39778,9 @@ const ChromeShimmerText = ({
39782
39778
  };
39783
39779
 
39784
39780
  // TableBody.jsx
39785
- const TableBody = ({
39786
- columns,
39787
- data,
39781
+ const TableBody = /*#__PURE__*/forwardRef(({
39782
+ columns = [],
39783
+ data = [],
39788
39784
  onRowClick,
39789
39785
  onSendClick,
39790
39786
  buttonColor,
@@ -39818,9 +39814,8 @@ const TableBody = ({
39818
39814
  // New prop with default
39819
39815
  onDropdownSelected = () => {},
39820
39816
  onCheckboxClick = () => {},
39821
- onHeaderCheckboxClick = () => {},
39822
- ref = null
39823
- }) => {
39817
+ onHeaderCheckboxClick = () => {}
39818
+ }, ref) => {
39824
39819
  const [hoveredRowIndex, setHoveredRowIndex] = useState(null);
39825
39820
  const [focusedRowIndex, setFocusedRowIndex] = useState(null);
39826
39821
  const [isCommentModalOpen, setIsCommentModalOpen] = useState(false);
@@ -39832,8 +39827,14 @@ const TableBody = ({
39832
39827
  const [isFocused, setIsFocused] = useState(false);
39833
39828
  const [hasUserInteracted, setHasUserInteracted] = useState(false);
39834
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
+ }
39835
39836
  useEffect(() => {
39836
- if (isCommentModalOpen && currentCommentRow !== null) {
39837
+ if (isCommentModalOpen && currentCommentRow !== null && data[currentCommentRow]) {
39837
39838
  const initialText = data[currentCommentRow]?.Comments || "";
39838
39839
  setCommentText(initialText);
39839
39840
  setHasInitialValue(Boolean(initialText.trim()));
@@ -39846,7 +39847,7 @@ const TableBody = ({
39846
39847
  }
39847
39848
  }, [resetFocusIndex]);
39848
39849
  useEffect(() => {
39849
- if (changeFocusIndex) {
39850
+ if (changeFocusIndex !== undefined && changeFocusIndex !== null) {
39850
39851
  setFocusedRowIndex(changeFocusIndex);
39851
39852
  }
39852
39853
  }, [changeFocusIndex]);
@@ -39898,41 +39899,46 @@ const TableBody = ({
39898
39899
 
39899
39900
  // Helper function to format tag text
39900
39901
  const formatTagText = tag => {
39901
- if (typeof tag !== "string") return tag;
39902
+ if (typeof tag !== "string") return String(tag || "");
39902
39903
  return tag.replace(/-/g, " ").replace(/\b\w/g, l => l.toUpperCase());
39903
39904
  };
39904
39905
  const formatValue = (value, column, row, rowIndex) => {
39905
- if ((value === null || value === undefined) && column.fieldType?.toLowerCase() !== "comments") {
39906
+ if ((value === null || value === undefined) && column?.fieldType?.toLowerCase() !== "comments") {
39906
39907
  return "";
39907
39908
  }
39908
39909
 
39909
39910
  // Find the tooltip text for the current value - can be used for different fieldTypes
39910
39911
  const getTooltipText = value => {
39911
- if (column.tooltipText && Array.isArray(column.tooltipText)) {
39912
+ if (column?.tooltipText && Array.isArray(column.tooltipText)) {
39912
39913
  const tooltipItem = column.tooltipText.find(item => item.value === value);
39913
39914
  return tooltipItem ? tooltipItem.label : null;
39914
39915
  }
39915
39916
  return null;
39916
39917
  };
39917
- switch (column.fieldType?.toLowerCase()) {
39918
+ switch (column?.fieldType?.toLowerCase()) {
39918
39919
  case "currency":
39919
39920
  if (column.format === "$0.00") {
39920
- return `$${parseFloat(value).toFixed(2)}`;
39921
+ return `$${parseFloat(value || 0).toFixed(2)}`;
39921
39922
  }
39922
39923
  return value;
39923
39924
  case "text":
39924
39925
  return value?.toString() || "";
39925
39926
  case "number":
39926
39927
  if (column.format && column.format.includes(",")) {
39927
- return value.toLocaleString();
39928
+ return (value || 0).toLocaleString();
39928
39929
  }
39929
39930
  return value;
39930
39931
  case "percentage":
39931
- return `${value}%`;
39932
+ return `${value || 0}%`;
39932
39933
  case "date":
39933
- if (column.format === "MM/DD/YYYY") {
39934
- const date = new Date(value);
39935
- 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
+ }
39936
39942
  }
39937
39943
  return value;
39938
39944
  case "boolean":
@@ -39991,17 +39997,21 @@ const TableBody = ({
39991
39997
  // Helper function to apply tooltip logic
39992
39998
  const applyTooltipLogic = (element, tooltipText) => {
39993
39999
  if (element && tooltipText && tooltipText.trim() !== "") {
39994
- const rect = element.getBoundingClientRect();
39995
- const {
39996
- offset,
39997
- height
39998
- } = calculateTooltipOffset(tooltipText);
39999
- element.style.setProperty("--tooltip-top", `${rect.top}px`);
40000
- element.style.setProperty("--tooltip-left", `${rect.left}px`);
40001
- element.style.setProperty("--tooltip-width", `${rect.width}px`);
40002
- element.style.setProperty("--tooltip-offset", `${offset}px`);
40003
- element.style.setProperty("--tooltip-height", `${height}px`);
40004
- 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
+ }
40005
40015
  }
40006
40016
  };
40007
40017
  const tooltipText = getTooltipText(value);
@@ -40059,7 +40069,7 @@ const TableBody = ({
40059
40069
  return value;
40060
40070
  case "status":
40061
40071
  const statusObj = statuses.find(status => status.status === value) || {};
40062
- const [palette0, palette1] = statusObj.palette;
40072
+ const [palette0, palette1] = statusObj.palette || ["#F3F4F6", "#374151"];
40063
40073
  return /*#__PURE__*/React$1.createElement(StatusCell$1, {
40064
40074
  color: palette1
40065
40075
  }, /*#__PURE__*/React$1.createElement(StatusCellCircle, {
@@ -40075,27 +40085,31 @@ const TableBody = ({
40075
40085
  $buttonColor: buttonColor,
40076
40086
  ref: el => {
40077
40087
  if (el) {
40078
- if (hasComments) {
40079
- // Add tooltip if there are comments
40080
- const rect = el.getBoundingClientRect();
40081
- const {
40082
- offset,
40083
- height
40084
- } = calculateTooltipOffset(commentTooltipText);
40085
- el.style.setProperty("--tooltip-top", `${rect.top}px`);
40086
- el.style.setProperty("--tooltip-left", `${rect.left}px`);
40087
- el.style.setProperty("--tooltip-width", `${rect.width}px`);
40088
- el.style.setProperty("--tooltip-offset", `${offset}px`);
40089
- el.style.setProperty("--tooltip-height", `${height}px`);
40090
- el.setAttribute("data-tooltip", commentTooltipText);
40091
- } else {
40092
- // Remove tooltip if there are no comments
40093
- el.removeAttribute("data-tooltip");
40094
- el.style.removeProperty("--tooltip-top");
40095
- el.style.removeProperty("--tooltip-left");
40096
- el.style.removeProperty("--tooltip-width");
40097
- el.style.removeProperty("--tooltip-offset");
40098
- 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);
40099
40113
  }
40100
40114
  }
40101
40115
  },
@@ -40119,17 +40133,21 @@ const TableBody = ({
40119
40133
  $buttonColor: buttonColor,
40120
40134
  ref: el => {
40121
40135
  if (el && trashTooltipText) {
40122
- const rect = el.getBoundingClientRect();
40123
- const {
40124
- offset,
40125
- height
40126
- } = calculateTooltipOffset(trashTooltipText);
40127
- el.style.setProperty("--tooltip-top", `${rect.top}px`);
40128
- el.style.setProperty("--tooltip-left", `${rect.left}px`);
40129
- el.style.setProperty("--tooltip-width", `${rect.width}px`);
40130
- el.style.setProperty("--tooltip-offset", `${offset}px`);
40131
- el.style.setProperty("--tooltip-height", `${height}px`);
40132
- 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
+ }
40133
40151
  }
40134
40152
  },
40135
40153
  onClick: e => {
@@ -40144,17 +40162,21 @@ const TableBody = ({
40144
40162
  return /*#__PURE__*/React$1.createElement(DisabledTrashIconWrapper$1, {
40145
40163
  ref: el => {
40146
40164
  if (el && trashTooltipText) {
40147
- const rect = el.getBoundingClientRect();
40148
- const {
40149
- offset,
40150
- height
40151
- } = calculateTooltipOffset(trashTooltipText);
40152
- el.style.setProperty("--tooltip-top", `${rect.top}px`);
40153
- el.style.setProperty("--tooltip-left", `${rect.left}px`);
40154
- el.style.setProperty("--tooltip-width", `${rect.width}px`);
40155
- el.style.setProperty("--tooltip-offset", `${offset}px`);
40156
- el.style.setProperty("--tooltip-height", `${height}px`);
40157
- 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
+ }
40158
40180
  }
40159
40181
  }
40160
40182
  }, /*#__PURE__*/React$1.createElement(DisabledTrashIcon, {
@@ -40164,13 +40186,14 @@ const TableBody = ({
40164
40186
  }
40165
40187
  return null;
40166
40188
  case "dropdown":
40189
+ if (!column) return null;
40167
40190
  const dropdownKey = `${rowIndex}-${column.key}`;
40168
40191
  const isOpen = openDropdowns[dropdownKey] || false;
40169
40192
  const dropdownOptions = column.dropdownOptions || [];
40170
40193
  const maxDropdownHeight = column.maxDropdownHeight || "200px";
40171
- const dropdownOptionsWidth = column.dropdownOptionsWidth; // Get from column config
40172
- const dropdownOptionsAlignment = column.dropdownOptionsAlignment || "right"; // Get from column config, default to 'right'
40173
- 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...";
40174
40197
 
40175
40198
  // Find the current selected option to display its label
40176
40199
  const currentOption = dropdownOptions.find(option => option.value === value);
@@ -40191,8 +40214,7 @@ const TableBody = ({
40191
40214
  selectedColor: selectedColor
40192
40215
  });
40193
40216
  case "checkbox":
40194
- const isChecked = Boolean(value); // Convert to boolean
40195
-
40217
+ const isChecked = Boolean(value);
40196
40218
  return /*#__PURE__*/React$1.createElement("div", {
40197
40219
  style: {
40198
40220
  display: "flex",
@@ -40205,13 +40227,12 @@ const TableBody = ({
40205
40227
  type: "checkbox",
40206
40228
  checked: isChecked,
40207
40229
  onChange: e => handleCheckboxClick(row, column.key, e),
40208
- onClick: e => e.stopPropagation() // Prevent row click on checkbox click
40209
- ,
40230
+ onClick: e => e.stopPropagation(),
40210
40231
  style: {
40211
40232
  width: "18px",
40212
40233
  height: "18px",
40213
40234
  cursor: "pointer",
40214
- accentColor: buttonColor // Use the theme color for checkbox
40235
+ accentColor: buttonColor
40215
40236
  }
40216
40237
  }));
40217
40238
  default:
@@ -40227,7 +40248,6 @@ const TableBody = ({
40227
40248
  const handleExpandClick = (row, rowIndex, event) => {
40228
40249
  event.stopPropagation();
40229
40250
  if (onExpandRow) {
40230
- // Determine the expand status based on current state
40231
40251
  const expandStatus = expandedRows[rowIndex] ? "isClosed" : "isOpen";
40232
40252
  onExpandRow(row, rowIndex, expandStatus);
40233
40253
  }
@@ -40237,15 +40257,11 @@ const TableBody = ({
40237
40257
  const handleCheckboxClick = (row, columnKey, event) => {
40238
40258
  event.stopPropagation();
40239
40259
  const currentValue = row[columnKey];
40240
- const newValue = !currentValue; // Toggle the value
40241
-
40242
- // Create updated row with new checkbox value
40260
+ const newValue = !currentValue;
40243
40261
  const updatedRow = {
40244
40262
  ...row,
40245
40263
  [columnKey]: newValue
40246
40264
  };
40247
-
40248
- // Fire the onCheckboxClick event with updated row
40249
40265
  if (onCheckboxClick) {
40250
40266
  onCheckboxClick({
40251
40267
  fullRow: updatedRow,
@@ -40269,14 +40285,10 @@ const TableBody = ({
40269
40285
  const handleDropdownOptionClick = (row, rowIndex, columnKey, selectedOption, event) => {
40270
40286
  event.stopPropagation();
40271
40287
  const dropdownKey = `${rowIndex}-${columnKey}`;
40272
-
40273
- // Close the dropdown
40274
40288
  setOpenDropdowns(prev => ({
40275
40289
  ...prev,
40276
40290
  [dropdownKey]: false
40277
40291
  }));
40278
-
40279
- // Fire the onDropdownSelected event with columnKey instead of columnName
40280
40292
  if (onDropdownSelected) {
40281
40293
  onDropdownSelected(row, selectedOption, columnKey);
40282
40294
  }
@@ -40292,72 +40304,109 @@ const TableBody = ({
40292
40304
  document.removeEventListener("click", handleClickOutside);
40293
40305
  };
40294
40306
  }, []);
40295
- 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, {
40296
- key: rowIndex
40297
- }, /*#__PURE__*/React$1.createElement(TableRow, {
40298
- "data-row-index": rowIndex,
40299
- className: indexToShimmer === rowIndex ? "shimmer-row" : "",
40300
- isFocused: focusedRowIndex === rowIndex,
40301
- selectedColor: selectedColor,
40302
- onMouseEnter: () => setHoveredRowIndex(rowIndex),
40303
- onMouseLeave: () => setHoveredRowIndex(null),
40304
- onClick: () => handleRowClick(row, rowIndex)
40305
- }, expandable && expandedContent[rowIndex] !== null ? /*#__PURE__*/React$1.createElement(TableCell, {
40306
- $fieldType: "expand",
40307
- $minWidth: "16px",
40308
- $maxWidth: "16px"
40309
- }, /*#__PURE__*/React$1.createElement(ExpandIcon, {
40310
- onClick: e => handleExpandClick(row, rowIndex, e),
40311
- $isExpanded: expandedRows[rowIndex] || false
40312
- }, expandedRows[rowIndex] ? /*#__PURE__*/React$1.createElement(MenuItemOpenIcon, {
40313
- width: "12",
40314
- height: "12",
40315
- color: "#666"
40316
- }) : /*#__PURE__*/React$1.createElement(ChervronRightIcon, {
40317
- width: "12",
40318
- height: "12",
40319
- fill: "#666"
40320
- }))) : expandable === true ? /*#__PURE__*/React$1.createElement("div", null) : null, columns.map((column, columnIndex) => {
40321
- const value = row[column.key];
40322
- const formattedValue = formatValue(value, column, row, rowIndex);
40323
-
40324
- // Use the chrome shimmer hook that only animates when this row matches indexToShimmer
40325
- const {
40326
- text: shimmerText,
40327
- isShimmering
40328
- } = useShimmerChromeEffect(formattedValue, rowIndex, indexToShimmer, columnIndex, columns.length);
40329
- return /*#__PURE__*/React$1.createElement(TableCell, {
40330
- key: column.key,
40331
- ref: el => {
40332
- if (el && shouldShowTooltip(el)) {
40333
- const rect = el.getBoundingClientRect();
40334
- const {
40335
- offset,
40336
- height
40337
- } = calculateTooltipOffset(formattedValue.toString(), true);
40338
- el.style.setProperty("--cell-top", `${rect.top}px`);
40339
- el.style.setProperty("--cell-left", `${rect.left}px`);
40340
- el.style.setProperty("--cell-width", `${rect.width}px`);
40341
- el.style.setProperty("--cell-offset", `${offset}px`);
40342
- el.style.setProperty("--cell-height", `${height}px`);
40343
- 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;
40344
40369
  }
40345
- },
40346
- $fieldType: column.fieldType?.toLowerCase(),
40347
- $color: column.color,
40348
- $minWidth: column.minWidth,
40349
- $maxWidth: column.maxWidth
40350
- }, 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, {
40351
- text: shimmerText,
40352
- isShimmering: isShimmering
40353
- }) : formattedValue);
40354
- })), expandable && expandedRows[rowIndex] && /*#__PURE__*/React$1.createElement(ExpandedRow, {
40355
- $expandedBackgroundColor: expandedBackgroundColor
40356
- }, /*#__PURE__*/React$1.createElement(TableCell, {
40357
- colSpan: columns.length + 1
40358
- }, /*#__PURE__*/React$1.createElement(ExpandedContent, {
40359
- $expandedBackgroundColor: expandedBackgroundColor
40360
- }, 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, {
40361
40410
  title: "Add Comment",
40362
40411
  isOpen: isCommentModalOpen,
40363
40412
  onClose: handleCommentModalClose,
@@ -40382,7 +40431,7 @@ const TableBody = ({
40382
40431
  onBlur: handleBlur,
40383
40432
  onFocus: handleFocus
40384
40433
  }), /*#__PURE__*/React$1.createElement(CharacterCount, null, commentText.length, "/", commentTextLimit))));
40385
- };
40434
+ });
40386
40435
  TableBody.propTypes = {
40387
40436
  columns: PropTypes.array.isRequired,
40388
40437
  data: PropTypes.array.isRequired,
@@ -40399,10 +40448,14 @@ TableBody.propTypes = {
40399
40448
  statuses: PropTypes.array,
40400
40449
  onCommentSave: PropTypes.func,
40401
40450
  commentTextLimit: PropTypes.number,
40451
+ expandable: PropTypes.bool,
40452
+ expandedRows: PropTypes.object,
40453
+ expandedContent: PropTypes.object,
40454
+ onExpandRow: PropTypes.func,
40455
+ expandedBackgroundColor: PropTypes.string,
40402
40456
  onDropdownSelected: PropTypes.func,
40403
40457
  onCheckboxClick: PropTypes.func,
40404
- onHeaderCheckboxClick: PropTypes.func,
40405
- ref: PropTypes.object
40458
+ onHeaderCheckboxClick: PropTypes.func
40406
40459
  };
40407
40460
  TableBody.displayName = "TableBody";
40408
40461
 
@@ -44819,6 +44872,15 @@ const SelectionTitle = styled.span`
44819
44872
  font-weight: 700;
44820
44873
  line-height: normal;
44821
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
+ `;
44822
44884
  const BackTitle = styled.span`
44823
44885
  margin-left: 4px;
44824
44886
  color: #212121;
@@ -44956,19 +45018,26 @@ const NewSubitem = ({
44956
45018
  vendor,
44957
45019
  onBack,
44958
45020
  addNewPackage,
45021
+ updateExistingPackage,
44959
45022
  componentText = "Scale"
44960
45023
  }) => {
44961
45024
  const [negotiatedBrands, setNegotiatedBrands] = useState("");
44962
45025
  const [negotiatedComponent, setNegotiatedComponent] = useState(componentText);
44963
-
45026
+ const [isPackageDuplicated, setIsPackageDuplicated] = useState(false);
44964
45027
  // Form state
44965
- const isApplyEnabled = negotiatedBrands.trim().length > 2;
45028
+ const [isApplyEnabled, setIsApplyEnabled] = useState(negotiatedBrands.trim().length > 2);
44966
45029
  useEffect(() => {
45030
+ console.log("packageObject", vendor);
44967
45031
  if (!packageObject) return;
44968
45032
  if (!packageObject.brands) return;
44969
45033
  setNegotiatedBrands(packageObject.brands);
44970
45034
  setNegotiatedComponent(packageObject.component);
44971
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]);
44972
45041
  return /*#__PURE__*/React$1.createElement(NewSubitemContainer, null, /*#__PURE__*/React$1.createElement(Header, null, /*#__PURE__*/React$1.createElement(BackButton, {
44973
45042
  onClick: onBack
44974
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, {
@@ -44986,7 +45055,11 @@ const NewSubitem = ({
44986
45055
  }), /*#__PURE__*/React$1.createElement(Button$1, {
44987
45056
  leftIcon: "none",
44988
45057
  onClick: () => {
44989
- addNewPackage(vendor.name, negotiatedBrands, negotiatedComponent);
45058
+ if (packageObject) {
45059
+ updateExistingPackage(vendor.name, packageObject, negotiatedBrands, negotiatedComponent);
45060
+ } else {
45061
+ addNewPackage(vendor.name, negotiatedBrands, negotiatedComponent);
45062
+ }
44990
45063
  },
44991
45064
  rightIcon: "none",
44992
45065
  size: "small",
@@ -45007,7 +45080,7 @@ const NewSubitem = ({
45007
45080
  onChange: e => setNegotiatedBrands(e.target.value),
45008
45081
  required: true,
45009
45082
  placeholder: "Specify by text the participated brands, divided by commas"
45010
- })), /*#__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", {
45011
45084
  style: {
45012
45085
  color: "red"
45013
45086
  }
@@ -53691,10 +53764,6 @@ const ItemManagerPanel = _ref => {
53691
53764
  const [trashIsHovered, setTrashIsHovered] = useState(false);
53692
53765
  const [headerHeight, setHeaderHeight] = useState(0);
53693
53766
  const headerRef = useRef(null);
53694
- useEffect(() => {
53695
- console.log("Screen changed to:", screen);
53696
- console.log("Selected Vendor:", selectedVendor);
53697
- }, [screen, selectedVendor]);
53698
53767
  useEffect(() => {
53699
53768
  if (headerRef.current) {
53700
53769
  setHeaderHeight(headerRef.current.offsetHeight);