@octaviaflow/core 3.0.18-beta.2 → 3.0.18-beta.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/components/DropdownMenu/DropdownMenu.d.ts +8 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/index.cjs +34 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +117 -87
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -39,6 +39,13 @@ export interface DropdownMenuProps {
|
|
|
39
39
|
"aria-label"?: string;
|
|
40
40
|
/** id of an element that labels the trigger; alternative to aria-label. */
|
|
41
41
|
"aria-labelledby"?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Pin the popup's width to the trigger's rendered width. Useful when the
|
|
44
|
+
* trigger is wide (a full Sidebar user card, an Input combobox, etc.) and
|
|
45
|
+
* a narrow `min-width: 180px` popup would look detached. Default `false`
|
|
46
|
+
* — the popup sizes to its content.
|
|
47
|
+
*/
|
|
48
|
+
matchTriggerWidth?: boolean;
|
|
42
49
|
}
|
|
43
|
-
export declare function DropdownMenu({ trigger, items, align, className, triggerClassName, closeOnOutsideClick, closeOnEscape, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, }: DropdownMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export declare function DropdownMenu({ trigger, items, align, className, triggerClassName, closeOnOutsideClick, closeOnEscape, matchTriggerWidth, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, }: DropdownMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
44
51
|
//# sourceMappingURL=DropdownMenu.d.ts.map
|
|
@@ -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;IAC3B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AA8ND,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,KAAK,EACL,KAAe,EACf,SAAS,EACT,gBAAgB,EAChB,mBAA0B,EAC1B,aAAoB,EACpB,iBAAyB,EACzB,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,GAClC,EAAE,iBAAiB,2CA0CnB"}
|
package/dist/index.cjs
CHANGED
|
@@ -11960,7 +11960,8 @@ function MenuPopup({
|
|
|
11960
11960
|
align,
|
|
11961
11961
|
className,
|
|
11962
11962
|
closeOnOutsideClick,
|
|
11963
|
-
closeOnEscape
|
|
11963
|
+
closeOnEscape,
|
|
11964
|
+
matchTriggerWidth
|
|
11964
11965
|
}) {
|
|
11965
11966
|
const menuRef = (0, import_react58.useRef)(null);
|
|
11966
11967
|
(0, import_react58.useEffect)(() => {
|
|
@@ -12002,19 +12003,45 @@ function MenuPopup({
|
|
|
12002
12003
|
nonSepItems[idx]?.onClick?.();
|
|
12003
12004
|
state.close();
|
|
12004
12005
|
};
|
|
12006
|
+
const ESTIMATED_ITEM_H = 34;
|
|
12007
|
+
const ESTIMATED_SEPARATOR_H = 9;
|
|
12008
|
+
const POPUP_PADDING_V = 8;
|
|
12009
|
+
const VIEWPORT_MARGIN = 8;
|
|
12010
|
+
const estimatedHeight = (0, import_react58.useMemo)(() => {
|
|
12011
|
+
const itemsTotal = menuItems.reduce(
|
|
12012
|
+
(acc, item) => acc + (item.separator ? ESTIMATED_SEPARATOR_H : ESTIMATED_ITEM_H),
|
|
12013
|
+
0
|
|
12014
|
+
);
|
|
12015
|
+
return itemsTotal + POPUP_PADDING_V * 2;
|
|
12016
|
+
}, [menuItems]);
|
|
12005
12017
|
const getStyle = () => {
|
|
12006
12018
|
if (!triggerRef.current) return {};
|
|
12007
12019
|
const rect = triggerRef.current.getBoundingClientRect();
|
|
12020
|
+
const viewportH = window.innerHeight;
|
|
12021
|
+
const spaceBelow = viewportH - rect.bottom;
|
|
12022
|
+
const spaceAbove = rect.top;
|
|
12023
|
+
const openUp = spaceBelow < estimatedHeight && spaceAbove > spaceBelow;
|
|
12008
12024
|
const style = {
|
|
12009
12025
|
position: "fixed",
|
|
12010
12026
|
zIndex: 1200,
|
|
12011
|
-
|
|
12027
|
+
// Cap the menu so it never spills beyond the viewport — pairs
|
|
12028
|
+
// with overflow-y:auto on the popup itself (set in CSS).
|
|
12029
|
+
maxHeight: Math.max(120, (openUp ? spaceAbove : spaceBelow) - VIEWPORT_MARGIN)
|
|
12012
12030
|
};
|
|
12031
|
+
if (openUp) {
|
|
12032
|
+
style.bottom = viewportH - rect.top + 4;
|
|
12033
|
+
} else {
|
|
12034
|
+
style.top = rect.bottom + 4;
|
|
12035
|
+
}
|
|
12013
12036
|
if (align === "end") {
|
|
12014
12037
|
style.right = window.innerWidth - rect.right;
|
|
12015
12038
|
} else {
|
|
12016
12039
|
style.left = rect.left;
|
|
12017
12040
|
}
|
|
12041
|
+
if (matchTriggerWidth) {
|
|
12042
|
+
style.width = rect.width;
|
|
12043
|
+
style.minWidth = rect.width;
|
|
12044
|
+
}
|
|
12018
12045
|
return style;
|
|
12019
12046
|
};
|
|
12020
12047
|
let nonSepIdx = 0;
|
|
@@ -12070,6 +12097,7 @@ function DropdownMenu({
|
|
|
12070
12097
|
triggerClassName,
|
|
12071
12098
|
closeOnOutsideClick = true,
|
|
12072
12099
|
closeOnEscape = true,
|
|
12100
|
+
matchTriggerWidth = false,
|
|
12073
12101
|
"aria-label": ariaLabel,
|
|
12074
12102
|
"aria-labelledby": ariaLabelledby
|
|
12075
12103
|
}) {
|
|
@@ -12103,7 +12131,8 @@ function DropdownMenu({
|
|
|
12103
12131
|
align,
|
|
12104
12132
|
className,
|
|
12105
12133
|
closeOnOutsideClick,
|
|
12106
|
-
closeOnEscape
|
|
12134
|
+
closeOnEscape,
|
|
12135
|
+
matchTriggerWidth
|
|
12107
12136
|
}
|
|
12108
12137
|
)
|
|
12109
12138
|
] });
|
|
@@ -22516,7 +22545,8 @@ function SidebarUserCard({ user }) {
|
|
|
22516
22545
|
{
|
|
22517
22546
|
trigger: body,
|
|
22518
22547
|
items: user.menu,
|
|
22519
|
-
align: "
|
|
22548
|
+
align: "start",
|
|
22549
|
+
matchTriggerWidth: true,
|
|
22520
22550
|
"aria-label": labelText,
|
|
22521
22551
|
triggerClassName: "ods-sidebar__user-card"
|
|
22522
22552
|
}
|