@northlight/ui 2.15.3 → 2.15.4
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/es/northlight.d.ts +2 -15
- package/dist/es/northlight.js +3 -62
- package/dist/es/northlight.js.map +1 -1
- package/dist/umd/northlight.cjs +3 -62
- package/dist/umd/northlight.cjs.map +1 -1
- package/dist/umd/northlight.min.cjs +3 -3
- package/dist/umd/northlight.min.cjs.map +1 -1
- package/package.json +4 -4
package/dist/umd/northlight.cjs
CHANGED
|
@@ -11560,49 +11560,6 @@
|
|
|
11560
11560
|
return value;
|
|
11561
11561
|
};
|
|
11562
11562
|
|
|
11563
|
-
const useAdaptiveMenuPlacement = ({
|
|
11564
|
-
dropdownHeightPx,
|
|
11565
|
-
containerRef
|
|
11566
|
-
}) => {
|
|
11567
|
-
const [menuPlacement, setMenuPlacement] = React.useState("bottom");
|
|
11568
|
-
const selectContainerRef = React.useRef(null);
|
|
11569
|
-
const adjustMenuPlacement = () => {
|
|
11570
|
-
if (ramda.isNil(selectContainerRef.current))
|
|
11571
|
-
return;
|
|
11572
|
-
let node = selectContainerRef.current.parentNode;
|
|
11573
|
-
while (node.parentNode) {
|
|
11574
|
-
const { overflowY, maxHeight, height } = getComputedStyle(node);
|
|
11575
|
-
if (overflowY !== "visible" || maxHeight || height)
|
|
11576
|
-
break;
|
|
11577
|
-
node = node.parentNode;
|
|
11578
|
-
}
|
|
11579
|
-
const selectRect = selectContainerRef.current.getBoundingClientRect();
|
|
11580
|
-
const containerRect = containerRef && containerRef.current ? containerRef.current.getBoundingClientRect() : node.getBoundingClientRect();
|
|
11581
|
-
const pxToContainerBottom = Math.abs(
|
|
11582
|
-
selectRect.bottom - containerRect.bottom
|
|
11583
|
-
);
|
|
11584
|
-
const pxToContainerTop = Math.abs(selectRect.top - containerRect.top);
|
|
11585
|
-
const pxToWindowBottom = Math.abs(selectRect.bottom - window.innerHeight);
|
|
11586
|
-
const shouldBeAtTop = dropdownHeightPx > pxToContainerBottom && pxToContainerTop > pxToContainerBottom || dropdownHeightPx > pxToWindowBottom && selectRect.top > pxToWindowBottom;
|
|
11587
|
-
setMenuPlacement(shouldBeAtTop ? "top" : "bottom");
|
|
11588
|
-
};
|
|
11589
|
-
React.useEffect(() => {
|
|
11590
|
-
adjustMenuPlacement();
|
|
11591
|
-
window.addEventListener("resize", adjustMenuPlacement);
|
|
11592
|
-
window.addEventListener("scroll", adjustMenuPlacement);
|
|
11593
|
-
return () => {
|
|
11594
|
-
window.removeEventListener("resize", adjustMenuPlacement);
|
|
11595
|
-
window.addEventListener("scroll", adjustMenuPlacement);
|
|
11596
|
-
};
|
|
11597
|
-
}, []);
|
|
11598
|
-
return { selectContainerRef, menuPlacement };
|
|
11599
|
-
};
|
|
11600
|
-
|
|
11601
|
-
const DROPDOWN_MAX_HEIGHT = 300;
|
|
11602
|
-
const DROPDOWN_MIN_HEIGHT = 55;
|
|
11603
|
-
const DROPDOWN_OPTION_HEIGHT = 37;
|
|
11604
|
-
const DROPDOWN_PADDING = 30;
|
|
11605
|
-
|
|
11606
11563
|
var __defProp$m = Object.defineProperty;
|
|
11607
11564
|
var __defProps$2 = Object.defineProperties;
|
|
11608
11565
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
@@ -11647,9 +11604,7 @@
|
|
|
11647
11604
|
customOption = null,
|
|
11648
11605
|
customTag = null,
|
|
11649
11606
|
value,
|
|
11650
|
-
icon
|
|
11651
|
-
containerRef,
|
|
11652
|
-
dropdownMinHeightPx = DROPDOWN_MIN_HEIGHT
|
|
11607
|
+
icon
|
|
11653
11608
|
} = _b, rest = __objRest$h(_b, [
|
|
11654
11609
|
"options",
|
|
11655
11610
|
"isMulti",
|
|
@@ -11662,9 +11617,7 @@
|
|
|
11662
11617
|
"customOption",
|
|
11663
11618
|
"customTag",
|
|
11664
11619
|
"value",
|
|
11665
|
-
"icon"
|
|
11666
|
-
"containerRef",
|
|
11667
|
-
"dropdownMinHeightPx"
|
|
11620
|
+
"icon"
|
|
11668
11621
|
]);
|
|
11669
11622
|
const handleChange = useSelectCallbacks({
|
|
11670
11623
|
onChange,
|
|
@@ -11686,18 +11639,7 @@
|
|
|
11686
11639
|
}
|
|
11687
11640
|
return prevOptions.current;
|
|
11688
11641
|
}, [options]);
|
|
11689
|
-
|
|
11690
|
-
Math.min(
|
|
11691
|
-
ramda.length(options || []) * DROPDOWN_OPTION_HEIGHT + DROPDOWN_PADDING,
|
|
11692
|
-
DROPDOWN_MAX_HEIGHT
|
|
11693
|
-
),
|
|
11694
|
-
dropdownMinHeightPx
|
|
11695
|
-
);
|
|
11696
|
-
const { selectContainerRef, menuPlacement } = useAdaptiveMenuPlacement({
|
|
11697
|
-
dropdownHeightPx,
|
|
11698
|
-
containerRef
|
|
11699
|
-
});
|
|
11700
|
-
return /* @__PURE__ */ React.createElement(react.Box, { w: "full", "data-testid": testId, "data-role": "select-container", ref: selectContainerRef }, /* @__PURE__ */ React.createElement(
|
|
11642
|
+
return /* @__PURE__ */ React.createElement(react.Box, { w: "full", "data-testid": testId }, /* @__PURE__ */ React.createElement(
|
|
11701
11643
|
chakraReactSelect.Select,
|
|
11702
11644
|
__spreadValues$m(__spreadProps$2(__spreadValues$m({
|
|
11703
11645
|
isMulti,
|
|
@@ -11715,7 +11657,6 @@
|
|
|
11715
11657
|
customOption,
|
|
11716
11658
|
customTag,
|
|
11717
11659
|
icon,
|
|
11718
|
-
menuPlacement,
|
|
11719
11660
|
components: customComponents,
|
|
11720
11661
|
ref
|
|
11721
11662
|
}), rest)
|