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.esm.js CHANGED
@@ -8946,6 +8946,8 @@ const DropdownSingleNew = ({
8946
8946
  const [hoverOptionsContainer, setHoverOptionsContainer] = useState(false);
8947
8947
  const inputRef = useRef(null);
8948
8948
  const containerRef = useRef(null);
8949
+ const dropdownRef = useRef(null); // Add ref for the entire dropdown
8950
+
8949
8951
  let filteredOptions = options?.filter(option => option.label.toLowerCase().includes(inputValue.toLowerCase()));
8950
8952
  switch (orderBy) {
8951
8953
  case "asc":
@@ -8964,18 +8966,37 @@ const DropdownSingleNew = ({
8964
8966
  break;
8965
8967
  }
8966
8968
 
8969
+ // Add click outside event listener
8970
+ useEffect(() => {
8971
+ const handleClickOutside = event => {
8972
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
8973
+ setShowOptions(false);
8974
+ setIsFocused(false);
8975
+ setInputValue("");
8976
+ }
8977
+ };
8978
+
8979
+ // Add event listener when dropdown is open
8980
+ if (showOptions) {
8981
+ document.addEventListener('mousedown', handleClickOutside);
8982
+ document.addEventListener('touchstart', handleClickOutside);
8983
+ }
8984
+
8985
+ // Cleanup event listeners
8986
+ return () => {
8987
+ document.removeEventListener('mousedown', handleClickOutside);
8988
+ document.removeEventListener('touchstart', handleClickOutside);
8989
+ };
8990
+ }, [showOptions]);
8991
+
8967
8992
  // Calculate position when showOptions changes
8968
8993
  useEffect(() => {
8969
8994
  if (showOptions && containerRef.current) {
8970
8995
  const rect = containerRef.current.getBoundingClientRect();
8971
8996
  const windowHeight = window.innerHeight;
8972
- const dropdownHeight = Math.min(filteredOptions.length * 40 + 20, 240); // Estimate dropdown height
8973
-
8974
- // Check if dropdown would go off-screen at bottom
8997
+ const dropdownHeight = Math.min(filteredOptions.length * 40 + 20, 240);
8975
8998
  const spaceBelow = windowHeight - rect.bottom;
8976
8999
  const spaceAbove = rect.top;
8977
-
8978
- // Show above if there's not enough space below and there's more space above
8979
9000
  setShowAbove(spaceBelow < dropdownHeight && spaceAbove > spaceBelow);
8980
9001
  }
8981
9002
  }, [showOptions, filteredOptions.length]);
@@ -8991,14 +9012,14 @@ const DropdownSingleNew = ({
8991
9012
  inputRef?.current?.focus();
8992
9013
  }
8993
9014
  }, [isFocused]);
9015
+
9016
+ // Modified hover effect - reduced delay and made it conditional
8994
9017
  useEffect(() => {
8995
- // Add a small delay to prevent dropdown from closing when moving between input and options
8996
9018
  const timer = setTimeout(() => {
8997
9019
  if (!hoverInputContainer && !hoverOptionsContainer && !isFocused) {
8998
9020
  setShowOptions(false);
8999
9021
  }
9000
- }, 100); // 100ms delay allows smooth transition
9001
-
9022
+ }, 100);
9002
9023
  return () => clearTimeout(timer);
9003
9024
  }, [hoverInputContainer, hoverOptionsContainer, isFocused]);
9004
9025
  const toggleOption = option => {
@@ -9084,6 +9105,8 @@ const DropdownSingleNew = ({
9084
9105
  };
9085
9106
  return /*#__PURE__*/React$1.createElement(DropdownWrapper$2, {
9086
9107
  className: "DropdownWrapper",
9108
+ ref: dropdownRef // Add ref to the wrapper
9109
+ ,
9087
9110
  width: width,
9088
9111
  height: height,
9089
9112
  onMouseEnter: () => setHoverInputContainer(true),
@@ -40051,7 +40074,7 @@ const TableBody = ({
40051
40074
  width: "12",
40052
40075
  height: "12",
40053
40076
  fill: "#666"
40054
- }))) : null, columns.map(column => {
40077
+ }))) : expandable === true ? /*#__PURE__*/React$1.createElement("div", null) : null, columns.map(column => {
40055
40078
  const value = row[column.key];
40056
40079
  const formattedValue = formatValue(value, column, row, rowIndex);
40057
40080
  return /*#__PURE__*/React$1.createElement(TableCell, {