sag_components 2.0.0-beta182 → 2.0.0-beta184

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
@@ -8956,6 +8956,8 @@ const DropdownSingleNew = ({
8956
8956
  const [hoverOptionsContainer, setHoverOptionsContainer] = React$1.useState(false);
8957
8957
  const inputRef = React$1.useRef(null);
8958
8958
  const containerRef = React$1.useRef(null);
8959
+ const dropdownRef = React$1.useRef(null); // Add ref for the entire dropdown
8960
+
8959
8961
  let filteredOptions = options?.filter(option => option.label.toLowerCase().includes(inputValue.toLowerCase()));
8960
8962
  switch (orderBy) {
8961
8963
  case "asc":
@@ -8974,18 +8976,37 @@ const DropdownSingleNew = ({
8974
8976
  break;
8975
8977
  }
8976
8978
 
8979
+ // Add click outside event listener
8980
+ React$1.useEffect(() => {
8981
+ const handleClickOutside = event => {
8982
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
8983
+ setShowOptions(false);
8984
+ setIsFocused(false);
8985
+ setInputValue("");
8986
+ }
8987
+ };
8988
+
8989
+ // Add event listener when dropdown is open
8990
+ if (showOptions) {
8991
+ document.addEventListener('mousedown', handleClickOutside);
8992
+ document.addEventListener('touchstart', handleClickOutside);
8993
+ }
8994
+
8995
+ // Cleanup event listeners
8996
+ return () => {
8997
+ document.removeEventListener('mousedown', handleClickOutside);
8998
+ document.removeEventListener('touchstart', handleClickOutside);
8999
+ };
9000
+ }, [showOptions]);
9001
+
8977
9002
  // Calculate position when showOptions changes
8978
9003
  React$1.useEffect(() => {
8979
9004
  if (showOptions && containerRef.current) {
8980
9005
  const rect = containerRef.current.getBoundingClientRect();
8981
9006
  const windowHeight = window.innerHeight;
8982
- const dropdownHeight = Math.min(filteredOptions.length * 40 + 20, 240); // Estimate dropdown height
8983
-
8984
- // Check if dropdown would go off-screen at bottom
9007
+ const dropdownHeight = Math.min(filteredOptions.length * 40 + 20, 240);
8985
9008
  const spaceBelow = windowHeight - rect.bottom;
8986
9009
  const spaceAbove = rect.top;
8987
-
8988
- // Show above if there's not enough space below and there's more space above
8989
9010
  setShowAbove(spaceBelow < dropdownHeight && spaceAbove > spaceBelow);
8990
9011
  }
8991
9012
  }, [showOptions, filteredOptions.length]);
@@ -9001,14 +9022,14 @@ const DropdownSingleNew = ({
9001
9022
  inputRef?.current?.focus();
9002
9023
  }
9003
9024
  }, [isFocused]);
9025
+
9026
+ // Modified hover effect - reduced delay and made it conditional
9004
9027
  React$1.useEffect(() => {
9005
- // Add a small delay to prevent dropdown from closing when moving between input and options
9006
9028
  const timer = setTimeout(() => {
9007
9029
  if (!hoverInputContainer && !hoverOptionsContainer && !isFocused) {
9008
9030
  setShowOptions(false);
9009
9031
  }
9010
- }, 100); // 100ms delay allows smooth transition
9011
-
9032
+ }, 100);
9012
9033
  return () => clearTimeout(timer);
9013
9034
  }, [hoverInputContainer, hoverOptionsContainer, isFocused]);
9014
9035
  const toggleOption = option => {
@@ -9094,6 +9115,8 @@ const DropdownSingleNew = ({
9094
9115
  };
9095
9116
  return /*#__PURE__*/React__default["default"].createElement(DropdownWrapper$2, {
9096
9117
  className: "DropdownWrapper",
9118
+ ref: dropdownRef // Add ref to the wrapper
9119
+ ,
9097
9120
  width: width,
9098
9121
  height: height,
9099
9122
  onMouseEnter: () => setHoverInputContainer(true),
@@ -40061,7 +40084,7 @@ const TableBody = ({
40061
40084
  width: "12",
40062
40085
  height: "12",
40063
40086
  fill: "#666"
40064
- }))) : null, columns.map(column => {
40087
+ }))) : expandable === true ? /*#__PURE__*/React__default["default"].createElement("div", null) : null, columns.map(column => {
40065
40088
  const value = row[column.key];
40066
40089
  const formattedValue = formatValue(value, column, row, rowIndex);
40067
40090
  return /*#__PURE__*/React__default["default"].createElement(TableCell, {