sag_components 2.0.0-beta252 → 2.0.0-beta254

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
@@ -10581,24 +10581,23 @@ const QuarterPopupPicker = ({
10581
10581
  };
10582
10582
 
10583
10583
  /* eslint-disable import/no-extraneous-dependencies */
10584
- const QuarterPicker = _ref => {
10585
- let {
10586
- availableQuarters,
10587
- // ["Q1-2024"]
10588
- label,
10589
- onChange,
10590
- borderRadius,
10591
- required,
10592
- width,
10593
- height,
10594
- placeholder,
10595
- disabled,
10596
- borderColor,
10597
- borderColorFocus,
10598
- textColor,
10599
- selectedValue,
10600
- startYear
10601
- } = _ref;
10584
+ const QuarterPicker = ({
10585
+ availableQuarters,
10586
+ // ["Q1-2024"]
10587
+ label,
10588
+ onChange,
10589
+ borderRadius,
10590
+ required,
10591
+ width,
10592
+ height,
10593
+ placeholder,
10594
+ disabled,
10595
+ borderColor,
10596
+ borderColorFocus,
10597
+ textColor,
10598
+ selectedValue,
10599
+ startYear
10600
+ }) => {
10602
10601
  const [isFocused, setIsFocused] = useState(false);
10603
10602
  const [isOpen, setIsOpen] = useState(false);
10604
10603
  const [value, setValue] = useState('');
@@ -11040,23 +11039,22 @@ const MonthPopupPicker = ({
11040
11039
  };
11041
11040
 
11042
11041
  /* eslint-disable import/no-extraneous-dependencies */
11043
- const MonthPicker = _ref => {
11044
- let {
11045
- availableMonths,
11046
- label,
11047
- onChange,
11048
- borderRadius,
11049
- required,
11050
- width,
11051
- height,
11052
- placeholder,
11053
- disabled,
11054
- borderColor,
11055
- borderColorFocus,
11056
- textColor,
11057
- selectedValue,
11058
- startYear
11059
- } = _ref;
11042
+ const MonthPicker = ({
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
+ }) => {
11060
11058
  const [isFocused, setIsFocused] = useState(false);
11061
11059
  const [isOpen, setIsOpen] = useState(false);
11062
11060
  const [value, setValue] = useState('');
@@ -24167,22 +24165,21 @@ const DeleteIcon = styled.div`
24167
24165
  position: absolute;
24168
24166
  `;
24169
24167
 
24170
- const QuickFilterDropdownSingle = _ref => {
24171
- let {
24172
- label,
24173
- hoverColor,
24174
- options,
24175
- selectedValue,
24176
- placeHolder,
24177
- onChange,
24178
- disabled,
24179
- width,
24180
- error,
24181
- errorMessage,
24182
- xIconShow,
24183
- labelColor,
24184
- showLabelOnTop
24185
- } = _ref;
24168
+ const QuickFilterDropdownSingle = ({
24169
+ label,
24170
+ hoverColor,
24171
+ options,
24172
+ selectedValue,
24173
+ placeHolder,
24174
+ onChange,
24175
+ disabled,
24176
+ width,
24177
+ error,
24178
+ errorMessage,
24179
+ xIconShow,
24180
+ labelColor,
24181
+ showLabelOnTop
24182
+ }) => {
24186
24183
  const [isFocused, setIsFocused] = useState(false);
24187
24184
  const [showOptions, setShowOptions] = useState(false);
24188
24185
  const [inputValue, setInputValue] = useState("");
@@ -24639,26 +24636,25 @@ const IconContainer$2 = styled.div`
24639
24636
  cursor: pointer;
24640
24637
  `;
24641
24638
 
24642
- const QuickFilterDropdownMultiSelection = _ref => {
24643
- let {
24644
- label,
24645
- labelEmptyValue,
24646
- options,
24647
- selectedValue,
24648
- placeHolder,
24649
- onChange,
24650
- required,
24651
- disabled,
24652
- width,
24653
- height,
24654
- error,
24655
- errorMessage,
24656
- labelColor,
24657
- xIconShow,
24658
- checkBoxColor,
24659
- showLabelOnTop,
24660
- dropdownHeight
24661
- } = _ref;
24639
+ const QuickFilterDropdownMultiSelection = ({
24640
+ label,
24641
+ labelEmptyValue,
24642
+ options,
24643
+ selectedValue,
24644
+ placeHolder,
24645
+ onChange,
24646
+ required,
24647
+ disabled,
24648
+ width,
24649
+ height,
24650
+ error,
24651
+ errorMessage,
24652
+ labelColor,
24653
+ xIconShow,
24654
+ checkBoxColor,
24655
+ showLabelOnTop,
24656
+ dropdownHeight
24657
+ }) => {
24662
24658
  const [isFocused, setIsFocused] = useState(false);
24663
24659
  const [showOptions, setShowOptions] = useState(false);
24664
24660
  const [inputValue, setInputValue] = useState('');
@@ -36168,9 +36164,9 @@ const ToggleSlider = styled.span`
36168
36164
  }
36169
36165
  `;
36170
36166
 
36171
- /**
36172
- * ToggleSwitch component for on/off states.
36173
- * Supports small/large sizes and disabled state.
36167
+ /**
36168
+ * ToggleSwitch component for on/off states.
36169
+ * Supports small/large sizes and disabled state.
36174
36170
  */
36175
36171
  function ToggleSwitch(_ref) {
36176
36172
  let {
@@ -37744,23 +37740,19 @@ const FilterPop = props => {
37744
37740
  isAsc = true,
37745
37741
  selectedAttributes: propSelectedAttributes = {},
37746
37742
  showSearch = true,
37747
- searchPlaceholder = "Search..."
37743
+ searchPlaceholder = "Search...",
37744
+ itemHeight = 32,
37745
+ overscan = 5
37748
37746
  } = props;
37749
-
37750
- // State for search term
37751
37747
  const [searchTerm, setSearchTerm] = useState("");
37752
-
37753
- // CRITICAL FIX: Use internal state for selected attributes
37754
37748
  const [selectedAttributes, setSelectedAttributes] = useState({});
37749
+ const [scrollTop, setScrollTop] = useState(0);
37755
37750
  const isInitialMount = useRef(true);
37756
-
37757
- // Add hardcoded "Select All" as first item
37751
+ const scrollContainerRef = useRef(null);
37758
37752
  const fullList = useMemo(() => [{
37759
37753
  value: "All",
37760
37754
  label: "Select All"
37761
37755
  }, ...list], [list]);
37762
-
37763
- // Create initial state - all items selected by default
37764
37756
  const createInitialState = () => {
37765
37757
  const initialState = {};
37766
37758
  fullList.forEach(item => {
@@ -37768,11 +37760,8 @@ const FilterPop = props => {
37768
37760
  });
37769
37761
  return initialState;
37770
37762
  };
37771
-
37772
- // CRITICAL: Initialize and sync with props only when necessary
37773
37763
  useEffect(() => {
37774
37764
  if (isInitialMount.current) {
37775
- // First mount: use props or create initial state
37776
37765
  if (Object.keys(propSelectedAttributes).length > 0) {
37777
37766
  setSelectedAttributes(propSelectedAttributes);
37778
37767
  } else {
@@ -37780,8 +37769,6 @@ const FilterPop = props => {
37780
37769
  }
37781
37770
  isInitialMount.current = false;
37782
37771
  } else {
37783
- // After mount: only update if props explicitly changed and are non-empty
37784
- // This prevents reset when parent re-renders
37785
37772
  if (Object.keys(propSelectedAttributes).length > 0) {
37786
37773
  const propsString = JSON.stringify(propSelectedAttributes);
37787
37774
  const currentString = JSON.stringify(selectedAttributes);
@@ -37790,9 +37777,7 @@ const FilterPop = props => {
37790
37777
  }
37791
37778
  }
37792
37779
  }
37793
- }, [propSelectedAttributes]); // Only depend on props
37794
-
37795
- // Update selected attributes when list changes to include new items
37780
+ }, [propSelectedAttributes]);
37796
37781
  useEffect(() => {
37797
37782
  if (!isInitialMount.current && list.length > 0) {
37798
37783
  setSelectedAttributes(prev => {
@@ -37800,38 +37785,28 @@ const FilterPop = props => {
37800
37785
  ...prev
37801
37786
  };
37802
37787
  let hasChanges = false;
37803
-
37804
- // Add any new items from the list that aren't in current selection
37805
37788
  fullList.forEach(item => {
37806
37789
  if (item.value !== "All" && !(item.value in updated)) {
37807
- updated[item.value] = true; // New items default to selected
37790
+ updated[item.value] = true;
37808
37791
  hasChanges = true;
37809
37792
  }
37810
37793
  });
37811
-
37812
- // Remove items that no longer exist in the list
37813
37794
  Object.keys(updated).forEach(key => {
37814
37795
  if (key !== "All" && !fullList.find(item => item.value === key)) {
37815
37796
  delete updated[key];
37816
37797
  hasChanges = true;
37817
37798
  }
37818
37799
  });
37819
-
37820
- // Update "Select All" state
37821
37800
  if (hasChanges) {
37822
37801
  updated.All = areAllNonAllItemsSelected(updated);
37823
37802
  }
37824
37803
  return hasChanges ? updated : prev;
37825
37804
  });
37826
37805
  }
37827
- }, [list]); // Only when list changes
37828
-
37829
- // Helper function to get non-"All" items
37806
+ }, [list]);
37830
37807
  const getNonAllItems = () => {
37831
37808
  return fullList.filter(item => item.value !== "All");
37832
37809
  };
37833
-
37834
- // Filter items based on search term
37835
37810
  const filteredList = useMemo(() => {
37836
37811
  if (!searchTerm.trim()) {
37837
37812
  return fullList;
@@ -37843,22 +37818,34 @@ const FilterPop = props => {
37843
37818
  });
37844
37819
  return [fullList.find(item => item.value === "All"), ...filteredNonAllItems];
37845
37820
  }, [fullList, searchTerm]);
37846
-
37847
- // Sort the filtered list based on the `isAsc` prop
37848
37821
  const sortedList = useMemo(() => {
37849
37822
  return [...filteredList.filter(item => item.value === "All"), ...filteredList.filter(item => item.value !== "All").sort((a, b) => {
37850
37823
  return isAsc ? a.label.localeCompare(b.label) : b.label.localeCompare(a.label);
37851
37824
  })];
37852
37825
  }, [filteredList, isAsc]);
37853
-
37854
- // Helper functions for "Select All" logic
37826
+ const {
37827
+ visibleItems,
37828
+ totalHeight,
37829
+ offsetY
37830
+ } = useMemo(() => {
37831
+ const containerHeight = parseInt(maxHeight) || 400;
37832
+ const startIndex = Math.max(0, Math.floor(scrollTop / itemHeight) - overscan);
37833
+ const endIndex = Math.min(sortedList.length, Math.ceil((scrollTop + containerHeight) / itemHeight) + overscan);
37834
+ const visible = sortedList.slice(startIndex, endIndex).map((item, idx) => ({
37835
+ ...item,
37836
+ index: startIndex + idx
37837
+ }));
37838
+ return {
37839
+ visibleItems: visible,
37840
+ totalHeight: sortedList.length * itemHeight,
37841
+ offsetY: startIndex * itemHeight
37842
+ };
37843
+ }, [sortedList, scrollTop, itemHeight, overscan, maxHeight]);
37855
37844
  const areAllNonAllItemsSelected = function () {
37856
37845
  let attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : selectedAttributes;
37857
37846
  const nonAllItems = getNonAllItems();
37858
37847
  return nonAllItems.every(item => attributes[item.value]);
37859
37848
  };
37860
-
37861
- // Helper functions for visible filtered items
37862
37849
  const getVisibleNonAllItems = () => {
37863
37850
  return sortedList.filter(item => item.value !== "All");
37864
37851
  };
@@ -37873,8 +37860,6 @@ const FilterPop = props => {
37873
37860
  const visibleItems = getVisibleNonAllItems();
37874
37861
  return visibleItems.some(item => attributes[item.value]);
37875
37862
  };
37876
-
37877
- // Create the efficient data structure
37878
37863
  const createFilterData = attributes => {
37879
37864
  const nonAllItems = getNonAllItems();
37880
37865
  const selectedItems = nonAllItems.filter(item => attributes[item.value]);
@@ -37953,8 +37938,6 @@ const FilterPop = props => {
37953
37938
  allItems: resetState
37954
37939
  });
37955
37940
  };
37956
-
37957
- // Function to determine checkbox state for "Select All"
37958
37941
  const getSelectAllCheckboxProps = () => {
37959
37942
  const visibleItems = getVisibleNonAllItems();
37960
37943
  if (visibleItems.length === 0) {
@@ -37985,9 +37968,20 @@ const FilterPop = props => {
37985
37968
  };
37986
37969
  const handleSearchChange = e => {
37987
37970
  setSearchTerm(e.target.value);
37971
+ setScrollTop(0); // Reset scroll on search
37972
+ if (scrollContainerRef.current) {
37973
+ scrollContainerRef.current.scrollTop = 0;
37974
+ }
37988
37975
  };
37989
37976
  const clearSearch = () => {
37990
37977
  setSearchTerm("");
37978
+ setScrollTop(0);
37979
+ if (scrollContainerRef.current) {
37980
+ scrollContainerRef.current.scrollTop = 0;
37981
+ }
37982
+ };
37983
+ const handleScroll = e => {
37984
+ setScrollTop(e.target.scrollTop);
37991
37985
  };
37992
37986
  return /*#__PURE__*/React$1.createElement(FilterPopContainer, {
37993
37987
  width: width,
@@ -38000,19 +37994,39 @@ const FilterPop = props => {
38000
37994
  value: searchTerm,
38001
37995
  onChange: handleSearchChange,
38002
37996
  accentColor: color
38003
- }), /*#__PURE__*/React$1.createElement(CheckboxGroup, {
37997
+ }), /*#__PURE__*/React$1.createElement("div", {
37998
+ ref: scrollContainerRef,
37999
+ onScroll: handleScroll,
38000
+ style: {
38001
+ maxHeight: maxHeight,
38002
+ overflowY: "auto",
38003
+ position: "relative"
38004
+ }
38005
+ }, sortedList.length === 1 ? /*#__PURE__*/React$1.createElement(NoResultsMessage, null, "No items match your search") : /*#__PURE__*/React$1.createElement("div", {
38006
+ style: {
38007
+ height: `${totalHeight}px`,
38008
+ position: "relative"
38009
+ }
38010
+ }, /*#__PURE__*/React$1.createElement(CheckboxGroup, {
38004
38011
  style: {
38005
38012
  display: doubleColumn ? "grid" : "flex",
38006
38013
  gridTemplateColumns: doubleColumn ? "1fr 1fr" : "none",
38007
- gap: "8px"
38014
+ gap: "8px",
38015
+ position: "absolute",
38016
+ top: `${offsetY}px`,
38017
+ left: 0,
38018
+ right: 0
38008
38019
  }
38009
- }, sortedList.length === 1 ? /*#__PURE__*/React$1.createElement(NoResultsMessage, null, "No items match your search") : sortedList.map(item => {
38020
+ }, visibleItems.map(item => {
38010
38021
  const isSelectAll = item.value === "All";
38011
38022
  const checkboxProps = isSelectAll ? getSelectAllCheckboxProps() : {};
38012
38023
  const isChecked = isSelectAll ? checkboxProps.checked : selectedAttributes[item.value] || false;
38013
38024
  return /*#__PURE__*/React$1.createElement(CheckboxLabel, {
38014
38025
  width: !doubleColumn ?? width,
38015
- key: item.value
38026
+ key: item.value,
38027
+ style: {
38028
+ height: `${itemHeight}px`
38029
+ }
38016
38030
  }, /*#__PURE__*/React$1.createElement("div", {
38017
38031
  style: {
38018
38032
  width: "20px",
@@ -38035,7 +38049,7 @@ const FilterPop = props => {
38035
38049
  handleCheckboxChange(item.value);
38036
38050
  }
38037
38051
  })), /*#__PURE__*/React$1.createElement("span", null, item.label));
38038
- })), /*#__PURE__*/React$1.createElement(ButtonWrapper$2, null, showSearch && searchTerm && /*#__PURE__*/React$1.createElement(ResetButton$1, {
38052
+ })))), /*#__PURE__*/React$1.createElement(ButtonWrapper$2, null, showSearch && searchTerm && /*#__PURE__*/React$1.createElement(ResetButton$1, {
38039
38053
  onClick: clearSearch,
38040
38054
  style: {
38041
38055
  marginRight: "8px"
@@ -42862,14 +42876,27 @@ const TableBody = /*#__PURE__*/forwardRef(({
42862
42876
  return `${value || 0}%`;
42863
42877
  case "date":
42864
42878
  try {
42879
+ let formattedDate = value;
42865
42880
  if (column.format === "MM/DD/YYYY" && value) {
42866
42881
  const date = new Date(value);
42867
42882
  if (isNaN(date.getTime())) {
42868
42883
  return String(value);
42869
42884
  }
42870
- return `${(date.getMonth() + 1).toString().padStart(2, "0")}/${date.getDate().toString().padStart(2, "0")}/${date.getFullYear()}`;
42885
+ formattedDate = `${(date.getMonth() + 1).toString().padStart(2, "0")}/${date.getDate().toString().padStart(2, "0")}/${date.getFullYear()}`;
42886
+ } else {
42887
+ formattedDate = String(value || "");
42871
42888
  }
42872
- return String(value || "");
42889
+
42890
+ // Check if this column should check for expiration
42891
+ if (column.checkExpiration !== false && value && isDateExpired(value)) {
42892
+ return /*#__PURE__*/React$1.createElement("span", {
42893
+ style: {
42894
+ color: "#D23630",
42895
+ textDecoration: "line-through"
42896
+ }
42897
+ }, formattedDate);
42898
+ }
42899
+ return formattedDate;
42873
42900
  } catch (e) {
42874
42901
  console.warn('Error formatting date:', e);
42875
42902
  return String(value || "");
@@ -43373,7 +43400,21 @@ const TableBody = /*#__PURE__*/forwardRef(({
43373
43400
  rowIndex: rowIndex
43374
43401
  });
43375
43402
  }
43376
- console.log('handler--------', row, columnKey, currentValue, rowIndex);
43403
+ };
43404
+
43405
+ // Helper function to check if date is expired (past current date)
43406
+ const isDateExpired = dateString => {
43407
+ if (!dateString) return false;
43408
+ try {
43409
+ const date = new Date(dateString);
43410
+ if (isNaN(date.getTime())) return false;
43411
+ const today = new Date();
43412
+ today.setHours(0, 0, 0, 0); // Reset time to start of day for fair comparison
43413
+ date.setHours(0, 0, 0, 0);
43414
+ return date < today;
43415
+ } catch (error) {
43416
+ return false;
43417
+ }
43377
43418
  };
43378
43419
  return /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement(StyledTableBody, {
43379
43420
  ref: ref