cr-ui-lib 1.1.50 → 1.1.51

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.d.mts CHANGED
@@ -326,6 +326,7 @@ interface GroupedCheckboxDropdownProps {
326
326
  hasIcon?: boolean;
327
327
  iconClass?: string;
328
328
  placeholderClass?: string;
329
+ isTop?: boolean;
329
330
  }
330
331
  declare const GroupedCheckboxDropdown: React$1.FC<GroupedCheckboxDropdownProps>;
331
332
 
package/dist/index.d.ts CHANGED
@@ -326,6 +326,7 @@ interface GroupedCheckboxDropdownProps {
326
326
  hasIcon?: boolean;
327
327
  iconClass?: string;
328
328
  placeholderClass?: string;
329
+ isTop?: boolean;
329
330
  }
330
331
  declare const GroupedCheckboxDropdown: React$1.FC<GroupedCheckboxDropdownProps>;
331
332
 
package/dist/index.js CHANGED
@@ -4018,7 +4018,9 @@ var GroupedCheckboxDropdown = ({
4018
4018
  placeholder = "Required",
4019
4019
  hasIcon = true,
4020
4020
  iconClass = "",
4021
- placeholderClass = ""
4021
+ placeholderClass = "",
4022
+ isTop
4023
+ // <-- ADDED (no default value)
4022
4024
  }) => {
4023
4025
  const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);
4024
4026
  const [dropdownPosition, setDropdownPosition] = React.useState({
@@ -4054,7 +4056,8 @@ var GroupedCheckboxDropdown = ({
4054
4056
  const rect = containerRef.current.getBoundingClientRect();
4055
4057
  const viewportHeight = window.innerHeight;
4056
4058
  const dropdownHeight = 300;
4057
- const shouldOpenUpward = rect.bottom + dropdownHeight > viewportHeight;
4059
+ const autoShouldOpenUpward = rect.bottom + dropdownHeight > viewportHeight && rect.top - dropdownHeight > 0;
4060
+ const shouldOpenUpward = isTop === true ? true : isTop === false ? false : autoShouldOpenUpward;
4058
4061
  setDropdownPosition({
4059
4062
  top: shouldOpenUpward ? rect.top + window.scrollY - dropdownHeight - 4 : rect.bottom + window.scrollY + 4,
4060
4063
  // open downward
@@ -4062,7 +4065,7 @@ var GroupedCheckboxDropdown = ({
4062
4065
  width: rect.width
4063
4066
  });
4064
4067
  }
4065
- }, [isDropdownOpen, usePortal]);
4068
+ }, [isDropdownOpen, usePortal, isTop]);
4066
4069
  const allOptionKeys = React.useMemo(
4067
4070
  () => options.flatMap((group) => group.options.map((opt) => opt.key)),
4068
4071
  [options]
@@ -4079,15 +4082,18 @@ var GroupedCheckboxDropdown = ({
4079
4082
  "div",
4080
4083
  {
4081
4084
  style: usePortal ? {
4085
+ // --- UPDATED PORTAL STYLE ---
4082
4086
  position: "absolute",
4083
- top: `${dropdownPosition.top + 4}px`,
4087
+ top: `${dropdownPosition.top}px`,
4088
+ // <-- REMOVED + 4
4084
4089
  left: `${dropdownPosition.left}px`,
4085
4090
  width: `${dropdownPosition.width}px`
4086
4091
  } : {
4092
+ // --- UPDATED NON-PORTAL STYLE ---
4087
4093
  position: "absolute",
4088
- top: "100%",
4094
+ ...isTop ? { bottom: "100%", marginBottom: "4px" } : { top: "100%", marginTop: "4px" },
4095
+ // Open downward (default)
4089
4096
  left: 0,
4090
- marginTop: "4px",
4091
4097
  width: "100%",
4092
4098
  zIndex: 99
4093
4099
  },