@facter/ds-core 1.33.2 → 1.33.3
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 +12 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3523,6 +3523,7 @@ function CardSelect({
|
|
|
3523
3523
|
const listRef = React10__namespace.useRef(null);
|
|
3524
3524
|
const searchRef = React10__namespace.useRef(null);
|
|
3525
3525
|
const [dropdownPos, setDropdownPos] = React10__namespace.useState({});
|
|
3526
|
+
const [listMaxHeight, setListMaxHeight] = React10__namespace.useState(300);
|
|
3526
3527
|
const filteredOptions = React10__namespace.useMemo(() => {
|
|
3527
3528
|
if (!searchable || onSearch || !search) return options;
|
|
3528
3529
|
const q = search.toLowerCase();
|
|
@@ -3541,9 +3542,14 @@ function CardSelect({
|
|
|
3541
3542
|
if (!open || !containerRef.current) return;
|
|
3542
3543
|
const updatePosition = () => {
|
|
3543
3544
|
const rect = containerRef.current.getBoundingClientRect();
|
|
3544
|
-
const
|
|
3545
|
-
const
|
|
3546
|
-
const
|
|
3545
|
+
const margin = 8;
|
|
3546
|
+
const searchBarHeight = searchable ? 41 : 0;
|
|
3547
|
+
const spaceBelow = window.innerHeight - rect.bottom - margin;
|
|
3548
|
+
const spaceAbove = rect.top - margin;
|
|
3549
|
+
const showAbove = spaceBelow < 150 && spaceAbove > spaceBelow;
|
|
3550
|
+
const availableSpace = showAbove ? spaceAbove : spaceBelow;
|
|
3551
|
+
const maxList = Math.max(Math.min(availableSpace - searchBarHeight - margin, 300), 100);
|
|
3552
|
+
setListMaxHeight(maxList);
|
|
3547
3553
|
setDropdownPos({
|
|
3548
3554
|
position: "fixed",
|
|
3549
3555
|
left: rect.left,
|
|
@@ -3559,7 +3565,7 @@ function CardSelect({
|
|
|
3559
3565
|
window.removeEventListener("scroll", updatePosition, true);
|
|
3560
3566
|
window.removeEventListener("resize", updatePosition);
|
|
3561
3567
|
};
|
|
3562
|
-
}, [open]);
|
|
3568
|
+
}, [open, searchable]);
|
|
3563
3569
|
React10__namespace.useEffect(() => {
|
|
3564
3570
|
if (!open) return;
|
|
3565
3571
|
const handleClickOutside = (e) => {
|
|
@@ -3679,7 +3685,8 @@ function CardSelect({
|
|
|
3679
3685
|
"div",
|
|
3680
3686
|
{
|
|
3681
3687
|
ref: listRef,
|
|
3682
|
-
className: "overflow-y-auto overscroll-contain
|
|
3688
|
+
className: "overflow-y-auto overscroll-contain",
|
|
3689
|
+
style: { maxHeight: listMaxHeight },
|
|
3683
3690
|
onScroll: handleScroll,
|
|
3684
3691
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-border/50 p-2", children: [
|
|
3685
3692
|
filteredOptions.length === 0 && !loading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "py-4 text-center text-sm text-muted-foreground", children: emptyText }) : filteredOptions.map((option) => {
|