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.js CHANGED
@@ -10589,24 +10589,23 @@ const QuarterPopupPicker = ({
10589
10589
  };
10590
10590
 
10591
10591
  /* eslint-disable import/no-extraneous-dependencies */
10592
- const QuarterPicker = _ref => {
10593
- let {
10594
- availableQuarters,
10595
- // ["Q1-2024"]
10596
- label,
10597
- onChange,
10598
- borderRadius,
10599
- required,
10600
- width,
10601
- height,
10602
- placeholder,
10603
- disabled,
10604
- borderColor,
10605
- borderColorFocus,
10606
- textColor,
10607
- selectedValue,
10608
- startYear
10609
- } = _ref;
10592
+ const QuarterPicker = ({
10593
+ availableQuarters,
10594
+ // ["Q1-2024"]
10595
+ label,
10596
+ onChange,
10597
+ borderRadius,
10598
+ required,
10599
+ width,
10600
+ height,
10601
+ placeholder,
10602
+ disabled,
10603
+ borderColor,
10604
+ borderColorFocus,
10605
+ textColor,
10606
+ selectedValue,
10607
+ startYear
10608
+ }) => {
10610
10609
  const [isFocused, setIsFocused] = React$1.useState(false);
10611
10610
  const [isOpen, setIsOpen] = React$1.useState(false);
10612
10611
  const [value, setValue] = React$1.useState('');
@@ -11048,23 +11047,22 @@ const MonthPopupPicker = ({
11048
11047
  };
11049
11048
 
11050
11049
  /* eslint-disable import/no-extraneous-dependencies */
11051
- const MonthPicker = _ref => {
11052
- let {
11053
- availableMonths,
11054
- label,
11055
- onChange,
11056
- borderRadius,
11057
- required,
11058
- width,
11059
- height,
11060
- placeholder,
11061
- disabled,
11062
- borderColor,
11063
- borderColorFocus,
11064
- textColor,
11065
- selectedValue,
11066
- startYear
11067
- } = _ref;
11050
+ const MonthPicker = ({
11051
+ availableMonths,
11052
+ label,
11053
+ onChange,
11054
+ borderRadius,
11055
+ required,
11056
+ width,
11057
+ height,
11058
+ placeholder,
11059
+ disabled,
11060
+ borderColor,
11061
+ borderColorFocus,
11062
+ textColor,
11063
+ selectedValue,
11064
+ startYear
11065
+ }) => {
11068
11066
  const [isFocused, setIsFocused] = React$1.useState(false);
11069
11067
  const [isOpen, setIsOpen] = React$1.useState(false);
11070
11068
  const [value, setValue] = React$1.useState('');
@@ -24175,22 +24173,21 @@ const DeleteIcon = styled__default["default"].div`
24175
24173
  position: absolute;
24176
24174
  `;
24177
24175
 
24178
- const QuickFilterDropdownSingle = _ref => {
24179
- let {
24180
- label,
24181
- hoverColor,
24182
- options,
24183
- selectedValue,
24184
- placeHolder,
24185
- onChange,
24186
- disabled,
24187
- width,
24188
- error,
24189
- errorMessage,
24190
- xIconShow,
24191
- labelColor,
24192
- showLabelOnTop
24193
- } = _ref;
24176
+ const QuickFilterDropdownSingle = ({
24177
+ label,
24178
+ hoverColor,
24179
+ options,
24180
+ selectedValue,
24181
+ placeHolder,
24182
+ onChange,
24183
+ disabled,
24184
+ width,
24185
+ error,
24186
+ errorMessage,
24187
+ xIconShow,
24188
+ labelColor,
24189
+ showLabelOnTop
24190
+ }) => {
24194
24191
  const [isFocused, setIsFocused] = React$1.useState(false);
24195
24192
  const [showOptions, setShowOptions] = React$1.useState(false);
24196
24193
  const [inputValue, setInputValue] = React$1.useState("");
@@ -24587,24 +24584,23 @@ const IconContainer$2 = styled__default["default"].div`
24587
24584
  cursor: pointer;
24588
24585
  `;
24589
24586
 
24590
- const QuickFilterDropdownMultiSelection = _ref => {
24591
- let {
24592
- label,
24593
- labelEmptyValue,
24594
- options,
24595
- selectedValue,
24596
- placeHolder,
24597
- onChange,
24598
- required,
24599
- disabled,
24600
- width,
24601
- error,
24602
- errorMessage,
24603
- labelColor,
24604
- xIconShow,
24605
- checkBoxColor,
24606
- showLabelOnTop
24607
- } = _ref;
24587
+ const QuickFilterDropdownMultiSelection = ({
24588
+ label,
24589
+ labelEmptyValue,
24590
+ options,
24591
+ selectedValue,
24592
+ placeHolder,
24593
+ onChange,
24594
+ required,
24595
+ disabled,
24596
+ width,
24597
+ error,
24598
+ errorMessage,
24599
+ labelColor,
24600
+ xIconShow,
24601
+ checkBoxColor,
24602
+ showLabelOnTop
24603
+ }) => {
24608
24604
  const [isFocused, setIsFocused] = React$1.useState(false);
24609
24605
  const [showOptions, setShowOptions] = React$1.useState(false);
24610
24606
  const [inputValue, setInputValue] = React$1.useState('');
@@ -39752,11 +39748,11 @@ const ChromeShimmerText = ({
39752
39748
  transition: 'all 0.3s ease'
39753
39749
  };
39754
39750
  if (!isShimmering) {
39755
- return /*#__PURE__*/React.createElement("span", null, text);
39751
+ return /*#__PURE__*/React__default["default"].createElement("span", null, text);
39756
39752
  }
39757
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
39753
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("span", {
39758
39754
  style: shimmerStyle
39759
- }, text), /*#__PURE__*/React.createElement("style", {
39755
+ }, text), /*#__PURE__*/React__default["default"].createElement("style", {
39760
39756
  jsx: true
39761
39757
  }, `
39762
39758
  @-webkit-keyframes chromeShine {
@@ -39792,9 +39788,9 @@ const ChromeShimmerText = ({
39792
39788
  };
39793
39789
 
39794
39790
  // TableBody.jsx
39795
- const TableBody = ({
39796
- columns,
39797
- data,
39791
+ const TableBody = /*#__PURE__*/React$1.forwardRef(({
39792
+ columns = [],
39793
+ data = [],
39798
39794
  onRowClick,
39799
39795
  onSendClick,
39800
39796
  buttonColor,
@@ -39828,9 +39824,8 @@ const TableBody = ({
39828
39824
  // New prop with default
39829
39825
  onDropdownSelected = () => {},
39830
39826
  onCheckboxClick = () => {},
39831
- onHeaderCheckboxClick = () => {},
39832
- ref = null
39833
- }) => {
39827
+ onHeaderCheckboxClick = () => {}
39828
+ }, ref) => {
39834
39829
  const [hoveredRowIndex, setHoveredRowIndex] = React$1.useState(null);
39835
39830
  const [focusedRowIndex, setFocusedRowIndex] = React$1.useState(null);
39836
39831
  const [isCommentModalOpen, setIsCommentModalOpen] = React$1.useState(false);
@@ -39842,8 +39837,14 @@ const TableBody = ({
39842
39837
  const [isFocused, setIsFocused] = React$1.useState(false);
39843
39838
  const [hasUserInteracted, setHasUserInteracted] = React$1.useState(false);
39844
39839
  const [hasInitialValue, setHasInitialValue] = React$1.useState(false);
39840
+
39841
+ // Early return for invalid data
39842
+ if (!Array.isArray(data) || !Array.isArray(columns)) {
39843
+ console.warn("TableBody: Invalid data or columns prop");
39844
+ return null;
39845
+ }
39845
39846
  React$1.useEffect(() => {
39846
- if (isCommentModalOpen && currentCommentRow !== null) {
39847
+ if (isCommentModalOpen && currentCommentRow !== null && data[currentCommentRow]) {
39847
39848
  const initialText = data[currentCommentRow]?.Comments || "";
39848
39849
  setCommentText(initialText);
39849
39850
  setHasInitialValue(Boolean(initialText.trim()));
@@ -39856,7 +39857,7 @@ const TableBody = ({
39856
39857
  }
39857
39858
  }, [resetFocusIndex]);
39858
39859
  React$1.useEffect(() => {
39859
- if (changeFocusIndex) {
39860
+ if (changeFocusIndex !== undefined && changeFocusIndex !== null) {
39860
39861
  setFocusedRowIndex(changeFocusIndex);
39861
39862
  }
39862
39863
  }, [changeFocusIndex]);
@@ -39908,41 +39909,46 @@ const TableBody = ({
39908
39909
 
39909
39910
  // Helper function to format tag text
39910
39911
  const formatTagText = tag => {
39911
- if (typeof tag !== "string") return tag;
39912
+ if (typeof tag !== "string") return String(tag || "");
39912
39913
  return tag.replace(/-/g, " ").replace(/\b\w/g, l => l.toUpperCase());
39913
39914
  };
39914
39915
  const formatValue = (value, column, row, rowIndex) => {
39915
- if ((value === null || value === undefined) && column.fieldType?.toLowerCase() !== "comments") {
39916
+ if ((value === null || value === undefined) && column?.fieldType?.toLowerCase() !== "comments") {
39916
39917
  return "";
39917
39918
  }
39918
39919
 
39919
39920
  // Find the tooltip text for the current value - can be used for different fieldTypes
39920
39921
  const getTooltipText = value => {
39921
- if (column.tooltipText && Array.isArray(column.tooltipText)) {
39922
+ if (column?.tooltipText && Array.isArray(column.tooltipText)) {
39922
39923
  const tooltipItem = column.tooltipText.find(item => item.value === value);
39923
39924
  return tooltipItem ? tooltipItem.label : null;
39924
39925
  }
39925
39926
  return null;
39926
39927
  };
39927
- switch (column.fieldType?.toLowerCase()) {
39928
+ switch (column?.fieldType?.toLowerCase()) {
39928
39929
  case "currency":
39929
39930
  if (column.format === "$0.00") {
39930
- return `$${parseFloat(value).toFixed(2)}`;
39931
+ return `$${parseFloat(value || 0).toFixed(2)}`;
39931
39932
  }
39932
39933
  return value;
39933
39934
  case "text":
39934
39935
  return value?.toString() || "";
39935
39936
  case "number":
39936
39937
  if (column.format && column.format.includes(",")) {
39937
- return value.toLocaleString();
39938
+ return (value || 0).toLocaleString();
39938
39939
  }
39939
39940
  return value;
39940
39941
  case "percentage":
39941
- return `${value}%`;
39942
+ return `${value || 0}%`;
39942
39943
  case "date":
39943
- if (column.format === "MM/DD/YYYY") {
39944
- const date = new Date(value);
39945
- return `${(date.getMonth() + 1)?.toString().padStart(2, "0")}/${date.getDate()?.toString().padStart(2, "0")}/${date.getFullYear()}`;
39944
+ if (column.format === "MM/DD/YYYY" && value) {
39945
+ try {
39946
+ const date = new Date(value);
39947
+ return `${(date.getMonth() + 1)?.toString().padStart(2, "0")}/${date.getDate()?.toString().padStart(2, "0")}/${date.getFullYear()}`;
39948
+ } catch (e) {
39949
+ console.warn("Invalid date format:", value);
39950
+ return value;
39951
+ }
39946
39952
  }
39947
39953
  return value;
39948
39954
  case "boolean":
@@ -40001,17 +40007,21 @@ const TableBody = ({
40001
40007
  // Helper function to apply tooltip logic
40002
40008
  const applyTooltipLogic = (element, tooltipText) => {
40003
40009
  if (element && tooltipText && tooltipText.trim() !== "") {
40004
- const rect = element.getBoundingClientRect();
40005
- const {
40006
- offset,
40007
- height
40008
- } = calculateTooltipOffset(tooltipText);
40009
- element.style.setProperty("--tooltip-top", `${rect.top}px`);
40010
- element.style.setProperty("--tooltip-left", `${rect.left}px`);
40011
- element.style.setProperty("--tooltip-width", `${rect.width}px`);
40012
- element.style.setProperty("--tooltip-offset", `${offset}px`);
40013
- element.style.setProperty("--tooltip-height", `${height}px`);
40014
- element.setAttribute("data-tooltip", tooltipText);
40010
+ try {
40011
+ const rect = element.getBoundingClientRect();
40012
+ const {
40013
+ offset,
40014
+ height
40015
+ } = calculateTooltipOffset(tooltipText);
40016
+ element.style.setProperty("--tooltip-top", `${rect.top}px`);
40017
+ element.style.setProperty("--tooltip-left", `${rect.left}px`);
40018
+ element.style.setProperty("--tooltip-width", `${rect.width}px`);
40019
+ element.style.setProperty("--tooltip-offset", `${offset}px`);
40020
+ element.style.setProperty("--tooltip-height", `${height}px`);
40021
+ element.setAttribute("data-tooltip", tooltipText);
40022
+ } catch (e) {
40023
+ console.warn("Error applying tooltip:", e);
40024
+ }
40015
40025
  }
40016
40026
  };
40017
40027
  const tooltipText = getTooltipText(value);
@@ -40069,7 +40079,7 @@ const TableBody = ({
40069
40079
  return value;
40070
40080
  case "status":
40071
40081
  const statusObj = statuses.find(status => status.status === value) || {};
40072
- const [palette0, palette1] = statusObj.palette;
40082
+ const [palette0, palette1] = statusObj.palette || ["#F3F4F6", "#374151"];
40073
40083
  return /*#__PURE__*/React__default["default"].createElement(StatusCell$1, {
40074
40084
  color: palette1
40075
40085
  }, /*#__PURE__*/React__default["default"].createElement(StatusCellCircle, {
@@ -40085,27 +40095,31 @@ const TableBody = ({
40085
40095
  $buttonColor: buttonColor,
40086
40096
  ref: el => {
40087
40097
  if (el) {
40088
- if (hasComments) {
40089
- // Add tooltip if there are comments
40090
- const rect = el.getBoundingClientRect();
40091
- const {
40092
- offset,
40093
- height
40094
- } = calculateTooltipOffset(commentTooltipText);
40095
- el.style.setProperty("--tooltip-top", `${rect.top}px`);
40096
- el.style.setProperty("--tooltip-left", `${rect.left}px`);
40097
- el.style.setProperty("--tooltip-width", `${rect.width}px`);
40098
- el.style.setProperty("--tooltip-offset", `${offset}px`);
40099
- el.style.setProperty("--tooltip-height", `${height}px`);
40100
- el.setAttribute("data-tooltip", commentTooltipText);
40101
- } else {
40102
- // Remove tooltip if there are no comments
40103
- el.removeAttribute("data-tooltip");
40104
- el.style.removeProperty("--tooltip-top");
40105
- el.style.removeProperty("--tooltip-left");
40106
- el.style.removeProperty("--tooltip-width");
40107
- el.style.removeProperty("--tooltip-offset");
40108
- el.style.removeProperty("--tooltip-height");
40098
+ try {
40099
+ if (hasComments) {
40100
+ // Add tooltip if there are comments
40101
+ const rect = el.getBoundingClientRect();
40102
+ const {
40103
+ offset,
40104
+ height
40105
+ } = calculateTooltipOffset(commentTooltipText);
40106
+ el.style.setProperty("--tooltip-top", `${rect.top}px`);
40107
+ el.style.setProperty("--tooltip-left", `${rect.left}px`);
40108
+ el.style.setProperty("--tooltip-width", `${rect.width}px`);
40109
+ el.style.setProperty("--tooltip-offset", `${offset}px`);
40110
+ el.style.setProperty("--tooltip-height", `${height}px`);
40111
+ el.setAttribute("data-tooltip", commentTooltipText);
40112
+ } else {
40113
+ // Remove tooltip if there are no comments
40114
+ el.removeAttribute("data-tooltip");
40115
+ el.style.removeProperty("--tooltip-top");
40116
+ el.style.removeProperty("--tooltip-left");
40117
+ el.style.removeProperty("--tooltip-width");
40118
+ el.style.removeProperty("--tooltip-offset");
40119
+ el.style.removeProperty("--tooltip-height");
40120
+ }
40121
+ } catch (e) {
40122
+ console.warn("Error handling comment tooltip:", e);
40109
40123
  }
40110
40124
  }
40111
40125
  },
@@ -40129,17 +40143,21 @@ const TableBody = ({
40129
40143
  $buttonColor: buttonColor,
40130
40144
  ref: el => {
40131
40145
  if (el && trashTooltipText) {
40132
- const rect = el.getBoundingClientRect();
40133
- const {
40134
- offset,
40135
- height
40136
- } = calculateTooltipOffset(trashTooltipText);
40137
- el.style.setProperty("--tooltip-top", `${rect.top}px`);
40138
- el.style.setProperty("--tooltip-left", `${rect.left}px`);
40139
- el.style.setProperty("--tooltip-width", `${rect.width}px`);
40140
- el.style.setProperty("--tooltip-offset", `${offset}px`);
40141
- el.style.setProperty("--tooltip-height", `${height}px`);
40142
- el.setAttribute("data-tooltip", trashTooltipText);
40146
+ try {
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);
40158
+ } catch (e) {
40159
+ console.warn("Error handling trash tooltip:", e);
40160
+ }
40143
40161
  }
40144
40162
  },
40145
40163
  onClick: e => {
@@ -40154,17 +40172,21 @@ const TableBody = ({
40154
40172
  return /*#__PURE__*/React__default["default"].createElement(DisabledTrashIconWrapper$1, {
40155
40173
  ref: el => {
40156
40174
  if (el && trashTooltipText) {
40157
- const rect = el.getBoundingClientRect();
40158
- const {
40159
- offset,
40160
- height
40161
- } = calculateTooltipOffset(trashTooltipText);
40162
- el.style.setProperty("--tooltip-top", `${rect.top}px`);
40163
- el.style.setProperty("--tooltip-left", `${rect.left}px`);
40164
- el.style.setProperty("--tooltip-width", `${rect.width}px`);
40165
- el.style.setProperty("--tooltip-offset", `${offset}px`);
40166
- el.style.setProperty("--tooltip-height", `${height}px`);
40167
- el.setAttribute("data-tooltip", trashTooltipText);
40175
+ try {
40176
+ const rect = el.getBoundingClientRect();
40177
+ const {
40178
+ offset,
40179
+ height
40180
+ } = calculateTooltipOffset(trashTooltipText);
40181
+ el.style.setProperty("--tooltip-top", `${rect.top}px`);
40182
+ el.style.setProperty("--tooltip-left", `${rect.left}px`);
40183
+ el.style.setProperty("--tooltip-width", `${rect.width}px`);
40184
+ el.style.setProperty("--tooltip-offset", `${offset}px`);
40185
+ el.style.setProperty("--tooltip-height", `${height}px`);
40186
+ el.setAttribute("data-tooltip", trashTooltipText);
40187
+ } catch (e) {
40188
+ console.warn("Error handling disabled trash tooltip:", e);
40189
+ }
40168
40190
  }
40169
40191
  }
40170
40192
  }, /*#__PURE__*/React__default["default"].createElement(DisabledTrashIcon, {
@@ -40174,13 +40196,14 @@ const TableBody = ({
40174
40196
  }
40175
40197
  return null;
40176
40198
  case "dropdown":
40199
+ if (!column) return null;
40177
40200
  const dropdownKey = `${rowIndex}-${column.key}`;
40178
40201
  const isOpen = openDropdowns[dropdownKey] || false;
40179
40202
  const dropdownOptions = column.dropdownOptions || [];
40180
40203
  const maxDropdownHeight = column.maxDropdownHeight || "200px";
40181
- const dropdownOptionsWidth = column.dropdownOptionsWidth; // Get from column config
40182
- const dropdownOptionsAlignment = column.dropdownOptionsAlignment || "right"; // Get from column config, default to 'right'
40183
- const placeholder = column.placeholder || "Select..."; // Get from column config, default to 'Select...'
40204
+ const dropdownOptionsWidth = column.dropdownOptionsWidth;
40205
+ const dropdownOptionsAlignment = column.dropdownOptionsAlignment || "right";
40206
+ const placeholder = column.placeholder || "Select...";
40184
40207
 
40185
40208
  // Find the current selected option to display its label
40186
40209
  const currentOption = dropdownOptions.find(option => option.value === value);
@@ -40201,8 +40224,7 @@ const TableBody = ({
40201
40224
  selectedColor: selectedColor
40202
40225
  });
40203
40226
  case "checkbox":
40204
- const isChecked = Boolean(value); // Convert to boolean
40205
-
40227
+ const isChecked = Boolean(value);
40206
40228
  return /*#__PURE__*/React__default["default"].createElement("div", {
40207
40229
  style: {
40208
40230
  display: "flex",
@@ -40215,13 +40237,12 @@ const TableBody = ({
40215
40237
  type: "checkbox",
40216
40238
  checked: isChecked,
40217
40239
  onChange: e => handleCheckboxClick(row, column.key, e),
40218
- onClick: e => e.stopPropagation() // Prevent row click on checkbox click
40219
- ,
40240
+ onClick: e => e.stopPropagation(),
40220
40241
  style: {
40221
40242
  width: "18px",
40222
40243
  height: "18px",
40223
40244
  cursor: "pointer",
40224
- accentColor: buttonColor // Use the theme color for checkbox
40245
+ accentColor: buttonColor
40225
40246
  }
40226
40247
  }));
40227
40248
  default:
@@ -40237,7 +40258,6 @@ const TableBody = ({
40237
40258
  const handleExpandClick = (row, rowIndex, event) => {
40238
40259
  event.stopPropagation();
40239
40260
  if (onExpandRow) {
40240
- // Determine the expand status based on current state
40241
40261
  const expandStatus = expandedRows[rowIndex] ? "isClosed" : "isOpen";
40242
40262
  onExpandRow(row, rowIndex, expandStatus);
40243
40263
  }
@@ -40247,15 +40267,11 @@ const TableBody = ({
40247
40267
  const handleCheckboxClick = (row, columnKey, event) => {
40248
40268
  event.stopPropagation();
40249
40269
  const currentValue = row[columnKey];
40250
- const newValue = !currentValue; // Toggle the value
40251
-
40252
- // Create updated row with new checkbox value
40270
+ const newValue = !currentValue;
40253
40271
  const updatedRow = {
40254
40272
  ...row,
40255
40273
  [columnKey]: newValue
40256
40274
  };
40257
-
40258
- // Fire the onCheckboxClick event with updated row
40259
40275
  if (onCheckboxClick) {
40260
40276
  onCheckboxClick({
40261
40277
  fullRow: updatedRow,
@@ -40279,14 +40295,10 @@ const TableBody = ({
40279
40295
  const handleDropdownOptionClick = (row, rowIndex, columnKey, selectedOption, event) => {
40280
40296
  event.stopPropagation();
40281
40297
  const dropdownKey = `${rowIndex}-${columnKey}`;
40282
-
40283
- // Close the dropdown
40284
40298
  setOpenDropdowns(prev => ({
40285
40299
  ...prev,
40286
40300
  [dropdownKey]: false
40287
40301
  }));
40288
-
40289
- // Fire the onDropdownSelected event with columnKey instead of columnName
40290
40302
  if (onDropdownSelected) {
40291
40303
  onDropdownSelected(row, selectedOption, columnKey);
40292
40304
  }
@@ -40302,72 +40314,109 @@ const TableBody = ({
40302
40314
  document.removeEventListener("click", handleClickOutside);
40303
40315
  };
40304
40316
  }, []);
40305
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(StyledTableBody, null, data.map((row, rowIndex) => /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
40306
- key: rowIndex
40307
- }, /*#__PURE__*/React__default["default"].createElement(TableRow, {
40308
- "data-row-index": rowIndex,
40309
- className: indexToShimmer === rowIndex ? "shimmer-row" : "",
40310
- isFocused: focusedRowIndex === rowIndex,
40311
- selectedColor: selectedColor,
40312
- onMouseEnter: () => setHoveredRowIndex(rowIndex),
40313
- onMouseLeave: () => setHoveredRowIndex(null),
40314
- onClick: () => handleRowClick(row, rowIndex)
40315
- }, expandable && expandedContent[rowIndex] !== null ? /*#__PURE__*/React__default["default"].createElement(TableCell, {
40316
- $fieldType: "expand",
40317
- $minWidth: "16px",
40318
- $maxWidth: "16px"
40319
- }, /*#__PURE__*/React__default["default"].createElement(ExpandIcon, {
40320
- onClick: e => handleExpandClick(row, rowIndex, e),
40321
- $isExpanded: expandedRows[rowIndex] || false
40322
- }, expandedRows[rowIndex] ? /*#__PURE__*/React__default["default"].createElement(MenuItemOpenIcon, {
40323
- width: "12",
40324
- height: "12",
40325
- color: "#666"
40326
- }) : /*#__PURE__*/React__default["default"].createElement(ChervronRightIcon, {
40327
- width: "12",
40328
- height: "12",
40329
- fill: "#666"
40330
- }))) : expandable === true ? /*#__PURE__*/React__default["default"].createElement("div", null) : null, columns.map((column, columnIndex) => {
40331
- const value = row[column.key];
40332
- const formattedValue = formatValue(value, column, row, rowIndex);
40333
-
40334
- // Use the chrome shimmer hook that only animates when this row matches indexToShimmer
40335
- const {
40336
- text: shimmerText,
40337
- isShimmering
40338
- } = useShimmerChromeEffect(formattedValue, rowIndex, indexToShimmer, columnIndex, columns.length);
40339
- return /*#__PURE__*/React__default["default"].createElement(TableCell, {
40340
- key: column.key,
40341
- ref: el => {
40342
- if (el && shouldShowTooltip(el)) {
40343
- const rect = el.getBoundingClientRect();
40344
- const {
40345
- offset,
40346
- height
40347
- } = calculateTooltipOffset(formattedValue.toString(), true);
40348
- el.style.setProperty("--cell-top", `${rect.top}px`);
40349
- el.style.setProperty("--cell-left", `${rect.left}px`);
40350
- el.style.setProperty("--cell-width", `${rect.width}px`);
40351
- el.style.setProperty("--cell-offset", `${offset}px`);
40352
- el.style.setProperty("--cell-height", `${height}px`);
40353
- el.setAttribute("data-tooltip", formattedValue);
40317
+
40318
+ // Return null if no data
40319
+ if (data.length === 0) {
40320
+ return /*#__PURE__*/React__default["default"].createElement(StyledTableBody, {
40321
+ ref: ref
40322
+ }, /*#__PURE__*/React__default["default"].createElement(TableRow, null, /*#__PURE__*/React__default["default"].createElement(TableCell, {
40323
+ colSpan: columns.length
40324
+ }, "No data available")));
40325
+ }
40326
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(StyledTableBody, {
40327
+ ref: ref
40328
+ }, data.map((row, rowIndex) => {
40329
+ // Skip invalid rows
40330
+ if (!row || typeof row !== 'object') {
40331
+ console.warn(`Invalid row at index ${rowIndex}:`, row);
40332
+ return null;
40333
+ }
40334
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
40335
+ key: row.id || `row-${rowIndex}`
40336
+ }, /*#__PURE__*/React__default["default"].createElement(TableRow, {
40337
+ "data-row-index": rowIndex,
40338
+ className: indexToShimmer === rowIndex ? "shimmer-row" : "",
40339
+ isFocused: focusedRowIndex === rowIndex,
40340
+ selectedColor: selectedColor,
40341
+ onMouseEnter: () => setHoveredRowIndex(rowIndex),
40342
+ onMouseLeave: () => setHoveredRowIndex(null),
40343
+ onClick: () => handleRowClick(row, rowIndex)
40344
+ }, expandable && expandedContent[rowIndex] !== undefined && expandedContent[rowIndex] !== null ? /*#__PURE__*/React__default["default"].createElement(TableCell, {
40345
+ $fieldType: "expand",
40346
+ $minWidth: "16px",
40347
+ $maxWidth: "16px"
40348
+ }, /*#__PURE__*/React__default["default"].createElement(ExpandIcon, {
40349
+ onClick: e => handleExpandClick(row, rowIndex, e),
40350
+ $isExpanded: expandedRows[rowIndex] || false
40351
+ }, expandedRows[rowIndex] ? /*#__PURE__*/React__default["default"].createElement(MenuItemOpenIcon, {
40352
+ width: "12",
40353
+ height: "12",
40354
+ color: "#666"
40355
+ }) : /*#__PURE__*/React__default["default"].createElement(ChervronRightIcon, {
40356
+ width: "12",
40357
+ height: "12",
40358
+ fill: "#666"
40359
+ }))) : expandable === true ? /*#__PURE__*/React__default["default"].createElement(TableCell, {
40360
+ $fieldType: "expand",
40361
+ $minWidth: "16px",
40362
+ $maxWidth: "16px"
40363
+ }) : null, columns.map((column, columnIndex) => {
40364
+ if (!column || !column.key) {
40365
+ console.warn(`Invalid column at index ${columnIndex}:`, column);
40366
+ return null;
40367
+ }
40368
+ const value = row[column.key];
40369
+ const formattedValue = formatValue(value, column, row, rowIndex);
40370
+
40371
+ // Use the chrome shimmer hook safely
40372
+ let shimmerText = formattedValue;
40373
+ let isShimmering = false;
40374
+ try {
40375
+ const shimmerResult = useShimmerChromeEffect(formattedValue, rowIndex, indexToShimmer, columnIndex, columns.length);
40376
+ if (shimmerResult) {
40377
+ shimmerText = shimmerResult.text || formattedValue;
40378
+ isShimmering = shimmerResult.isShimmering || false;
40354
40379
  }
40355
- },
40356
- $fieldType: column.fieldType?.toLowerCase(),
40357
- $color: column.color,
40358
- $minWidth: column.minWidth,
40359
- $maxWidth: column.maxWidth
40360
- }, column.fieldType?.toLowerCase() === "text" || column.fieldType?.toLowerCase() === "currency" || column.fieldType?.toLowerCase() === "number" || column.fieldType?.toLowerCase() === "percentage" || column.fieldType?.toLowerCase() === "date" || !column.fieldType ? /*#__PURE__*/React__default["default"].createElement(ChromeShimmerText, {
40361
- text: shimmerText,
40362
- isShimmering: isShimmering
40363
- }) : formattedValue);
40364
- })), expandable && expandedRows[rowIndex] && /*#__PURE__*/React__default["default"].createElement(ExpandedRow, {
40365
- $expandedBackgroundColor: expandedBackgroundColor
40366
- }, /*#__PURE__*/React__default["default"].createElement(TableCell, {
40367
- colSpan: columns.length + 1
40368
- }, /*#__PURE__*/React__default["default"].createElement(ExpandedContent, {
40369
- $expandedBackgroundColor: expandedBackgroundColor
40370
- }, expandedContent[rowIndex] || null)))))), /*#__PURE__*/React__default["default"].createElement(MessageBox, {
40380
+ } catch (e) {
40381
+ console.warn("Error with shimmer effect:", e);
40382
+ }
40383
+ return /*#__PURE__*/React__default["default"].createElement(TableCell, {
40384
+ key: `${column.key}-${rowIndex}`,
40385
+ ref: el => {
40386
+ if (el && shouldShowTooltip(el)) {
40387
+ try {
40388
+ const rect = el.getBoundingClientRect();
40389
+ const {
40390
+ offset,
40391
+ height
40392
+ } = calculateTooltipOffset(formattedValue.toString(), true);
40393
+ el.style.setProperty("--cell-top", `${rect.top}px`);
40394
+ el.style.setProperty("--cell-left", `${rect.left}px`);
40395
+ el.style.setProperty("--cell-width", `${rect.width}px`);
40396
+ el.style.setProperty("--cell-offset", `${offset}px`);
40397
+ el.style.setProperty("--cell-height", `${height}px`);
40398
+ el.setAttribute("data-tooltip", formattedValue);
40399
+ } catch (e) {
40400
+ console.warn("Error setting cell tooltip:", e);
40401
+ }
40402
+ }
40403
+ },
40404
+ $fieldType: column.fieldType?.toLowerCase(),
40405
+ $color: column.color,
40406
+ $minWidth: column.minWidth,
40407
+ $maxWidth: column.maxWidth
40408
+ }, column.fieldType?.toLowerCase() === "text" || column.fieldType?.toLowerCase() === "currency" || column.fieldType?.toLowerCase() === "number" || column.fieldType?.toLowerCase() === "percentage" || column.fieldType?.toLowerCase() === "date" || !column.fieldType ? /*#__PURE__*/React__default["default"].createElement(ChromeShimmerText, {
40409
+ text: shimmerText,
40410
+ isShimmering: isShimmering
40411
+ }) : formattedValue);
40412
+ })), expandable && expandedRows[rowIndex] && /*#__PURE__*/React__default["default"].createElement(ExpandedRow, {
40413
+ $expandedBackgroundColor: expandedBackgroundColor
40414
+ }, /*#__PURE__*/React__default["default"].createElement(TableCell, {
40415
+ colSpan: columns.length + 1
40416
+ }, /*#__PURE__*/React__default["default"].createElement(ExpandedContent, {
40417
+ $expandedBackgroundColor: expandedBackgroundColor
40418
+ }, expandedContent[rowIndex] || null))));
40419
+ })), /*#__PURE__*/React__default["default"].createElement(MessageBox, {
40371
40420
  title: "Add Comment",
40372
40421
  isOpen: isCommentModalOpen,
40373
40422
  onClose: handleCommentModalClose,
@@ -40392,7 +40441,7 @@ const TableBody = ({
40392
40441
  onBlur: handleBlur,
40393
40442
  onFocus: handleFocus
40394
40443
  }), /*#__PURE__*/React__default["default"].createElement(CharacterCount, null, commentText.length, "/", commentTextLimit))));
40395
- };
40444
+ });
40396
40445
  TableBody.propTypes = {
40397
40446
  columns: PropTypes.array.isRequired,
40398
40447
  data: PropTypes.array.isRequired,
@@ -40409,10 +40458,14 @@ TableBody.propTypes = {
40409
40458
  statuses: PropTypes.array,
40410
40459
  onCommentSave: PropTypes.func,
40411
40460
  commentTextLimit: PropTypes.number,
40461
+ expandable: PropTypes.bool,
40462
+ expandedRows: PropTypes.object,
40463
+ expandedContent: PropTypes.object,
40464
+ onExpandRow: PropTypes.func,
40465
+ expandedBackgroundColor: PropTypes.string,
40412
40466
  onDropdownSelected: PropTypes.func,
40413
40467
  onCheckboxClick: PropTypes.func,
40414
- onHeaderCheckboxClick: PropTypes.func,
40415
- ref: PropTypes.object
40468
+ onHeaderCheckboxClick: PropTypes.func
40416
40469
  };
40417
40470
  TableBody.displayName = "TableBody";
40418
40471
 
@@ -44829,6 +44882,15 @@ const SelectionTitle = styled__default["default"].span`
44829
44882
  font-weight: 700;
44830
44883
  line-height: normal;
44831
44884
  `;
44885
+ const ErrorLabel = styled__default["default"].div`
44886
+ color: red;
44887
+ font-family: Poppins;
44888
+ font-size: 12px;
44889
+ height: 12px;
44890
+ font-style: normal;
44891
+ font-weight: 400;
44892
+ line-height: normal;
44893
+ `;
44832
44894
  const BackTitle = styled__default["default"].span`
44833
44895
  margin-left: 4px;
44834
44896
  color: #212121;
@@ -44966,19 +45028,26 @@ const NewSubitem = ({
44966
45028
  vendor,
44967
45029
  onBack,
44968
45030
  addNewPackage,
45031
+ updateExistingPackage,
44969
45032
  componentText = "Scale"
44970
45033
  }) => {
44971
45034
  const [negotiatedBrands, setNegotiatedBrands] = React$1.useState("");
44972
45035
  const [negotiatedComponent, setNegotiatedComponent] = React$1.useState(componentText);
44973
-
45036
+ const [isPackageDuplicated, setIsPackageDuplicated] = React$1.useState(false);
44974
45037
  // Form state
44975
- const isApplyEnabled = negotiatedBrands.trim().length > 2;
45038
+ const [isApplyEnabled, setIsApplyEnabled] = React$1.useState(negotiatedBrands.trim().length > 2);
44976
45039
  React$1.useEffect(() => {
45040
+ console.log("packageObject", vendor);
44977
45041
  if (!packageObject) return;
44978
45042
  if (!packageObject.brands) return;
44979
45043
  setNegotiatedBrands(packageObject.brands);
44980
45044
  setNegotiatedComponent(packageObject.component);
44981
45045
  }, [packageObject]);
45046
+ React$1.useEffect(() => {
45047
+ if (packageObject && packageObject.brands === negotiatedBrands) return;
45048
+ setIsPackageDuplicated(vendor.packages.some(pkg => pkg.brands === negotiatedBrands));
45049
+ setIsApplyEnabled(negotiatedBrands.trim().length > 2 && vendor.packages.some(pkg => pkg.brands === negotiatedBrands) === false);
45050
+ }, [negotiatedBrands]);
44982
45051
  return /*#__PURE__*/React__default["default"].createElement(NewSubitemContainer, null, /*#__PURE__*/React__default["default"].createElement(Header, null, /*#__PURE__*/React__default["default"].createElement(BackButton, {
44983
45052
  onClick: onBack
44984
45053
  }, /*#__PURE__*/React__default["default"].createElement(ArrowLeftIcon, null)), /*#__PURE__*/React__default["default"].createElement(BackTitle, null, vendor.name)), /*#__PURE__*/React__default["default"].createElement(SelectionTitle, null, "Add Package"), /*#__PURE__*/React__default["default"].createElement(ButtonsContainer, null, /*#__PURE__*/React__default["default"].createElement(Button$1, {
@@ -44996,7 +45065,11 @@ const NewSubitem = ({
44996
45065
  }), /*#__PURE__*/React__default["default"].createElement(Button$1, {
44997
45066
  leftIcon: "none",
44998
45067
  onClick: () => {
44999
- addNewPackage(vendor.name, negotiatedBrands, negotiatedComponent);
45068
+ if (packageObject) {
45069
+ updateExistingPackage(vendor.name, packageObject, negotiatedBrands, negotiatedComponent);
45070
+ } else {
45071
+ addNewPackage(vendor.name, negotiatedBrands, negotiatedComponent);
45072
+ }
45000
45073
  },
45001
45074
  rightIcon: "none",
45002
45075
  size: "small",
@@ -45017,7 +45090,7 @@ const NewSubitem = ({
45017
45090
  onChange: e => setNegotiatedBrands(e.target.value),
45018
45091
  required: true,
45019
45092
  placeholder: "Specify by text the participated brands, divided by commas"
45020
- })), /*#__PURE__*/React__default["default"].createElement(NegotiatedContainer, null, /*#__PURE__*/React__default["default"].createElement(AddNegotiatedBrand, null, "Component ", /*#__PURE__*/React__default["default"].createElement("span", {
45093
+ }), isPackageDuplicated ? /*#__PURE__*/React__default["default"].createElement(ErrorLabel, null, "Package already exists for that vendor, Please enter a unique package.") : /*#__PURE__*/React__default["default"].createElement(ErrorLabel, null)), /*#__PURE__*/React__default["default"].createElement(NegotiatedContainer, null, /*#__PURE__*/React__default["default"].createElement(AddNegotiatedBrand, null, "Component ", /*#__PURE__*/React__default["default"].createElement("span", {
45021
45094
  style: {
45022
45095
  color: "red"
45023
45096
  }
@@ -53701,10 +53774,6 @@ const ItemManagerPanel = _ref => {
53701
53774
  const [trashIsHovered, setTrashIsHovered] = React$1.useState(false);
53702
53775
  const [headerHeight, setHeaderHeight] = React$1.useState(0);
53703
53776
  const headerRef = React$1.useRef(null);
53704
- React$1.useEffect(() => {
53705
- console.log("Screen changed to:", screen);
53706
- console.log("Selected Vendor:", selectedVendor);
53707
- }, [screen, selectedVendor]);
53708
53777
  React$1.useEffect(() => {
53709
53778
  if (headerRef.current) {
53710
53779
  setHeaderHeight(headerRef.current.offsetHeight);