@octaviaflow/core 3.0.18-beta.2 → 3.0.18-beta.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/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/index.cjs +23 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +106 -84
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownMenu/DropdownMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownMenu/DropdownMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAA8B,MAAM,OAAO,CAAC;AAQnE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,SAAS,CAAC;IACnB,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAoND,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,KAAK,EACL,KAAe,EACf,SAAS,EACT,gBAAgB,EAChB,mBAA0B,EAC1B,aAAoB,EACpB,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,GAClC,EAAE,iBAAiB,2CAyCnB"}
|
package/dist/index.cjs
CHANGED
|
@@ -12002,14 +12002,36 @@ function MenuPopup({
|
|
|
12002
12002
|
nonSepItems[idx]?.onClick?.();
|
|
12003
12003
|
state.close();
|
|
12004
12004
|
};
|
|
12005
|
+
const ESTIMATED_ITEM_H = 34;
|
|
12006
|
+
const ESTIMATED_SEPARATOR_H = 9;
|
|
12007
|
+
const POPUP_PADDING_V = 8;
|
|
12008
|
+
const VIEWPORT_MARGIN = 8;
|
|
12009
|
+
const estimatedHeight = (0, import_react58.useMemo)(() => {
|
|
12010
|
+
const itemsTotal = menuItems.reduce(
|
|
12011
|
+
(acc, item) => acc + (item.separator ? ESTIMATED_SEPARATOR_H : ESTIMATED_ITEM_H),
|
|
12012
|
+
0
|
|
12013
|
+
);
|
|
12014
|
+
return itemsTotal + POPUP_PADDING_V * 2;
|
|
12015
|
+
}, [menuItems]);
|
|
12005
12016
|
const getStyle = () => {
|
|
12006
12017
|
if (!triggerRef.current) return {};
|
|
12007
12018
|
const rect = triggerRef.current.getBoundingClientRect();
|
|
12019
|
+
const viewportH = window.innerHeight;
|
|
12020
|
+
const spaceBelow = viewportH - rect.bottom;
|
|
12021
|
+
const spaceAbove = rect.top;
|
|
12022
|
+
const openUp = spaceBelow < estimatedHeight && spaceAbove > spaceBelow;
|
|
12008
12023
|
const style = {
|
|
12009
12024
|
position: "fixed",
|
|
12010
12025
|
zIndex: 1200,
|
|
12011
|
-
|
|
12026
|
+
// Cap the menu so it never spills beyond the viewport — pairs
|
|
12027
|
+
// with overflow-y:auto on the popup itself (set in CSS).
|
|
12028
|
+
maxHeight: Math.max(120, (openUp ? spaceAbove : spaceBelow) - VIEWPORT_MARGIN)
|
|
12012
12029
|
};
|
|
12030
|
+
if (openUp) {
|
|
12031
|
+
style.bottom = viewportH - rect.top + 4;
|
|
12032
|
+
} else {
|
|
12033
|
+
style.top = rect.bottom + 4;
|
|
12034
|
+
}
|
|
12013
12035
|
if (align === "end") {
|
|
12014
12036
|
style.right = window.innerWidth - rect.right;
|
|
12015
12037
|
} else {
|