overflow-toolbar 0.1.5 → 0.1.7
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/README.md +24 -0
- package/dist/components/MuiOverflow/MuiOverflowMenu.js +3 -3
- package/dist/components/MuiOverflow/MuiOverflowMenu.js.map +1 -1
- package/dist/components/Overflow/OverflowMenu.d.ts.map +1 -1
- package/dist/components/Overflow/OverflowMenu.js +28 -26
- package/dist/components/Overflow/OverflowMenu.js.map +1 -1
- package/dist/components/RxOverflow/RxOverflowMenu.js +6 -5
- package/dist/components/RxOverflow/RxOverflowMenu.js.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -156,6 +156,30 @@ Framework-agnostic controller class for building custom implementations.
|
|
|
156
156
|
| `disconnect()` | Stop observing and clear all applied styles/attributes |
|
|
157
157
|
| `update()` | Re-scan children and restart (call after DOM changes) |
|
|
158
158
|
|
|
159
|
+
## Important: No Wrapper Elements
|
|
160
|
+
|
|
161
|
+
`OverflowItem` and `OverflowMenu` components **must** be direct children of the `Overflow` container. Do not wrap them in `<div>`, `<span>`, layout components, or any other intermediate elements.
|
|
162
|
+
|
|
163
|
+
The overflow engine scans immediate children for internal role markers to measure, track, and transition items between states. Wrapper elements break this scan, causing items to never collapse, never appear in the menu, or fail to transition between visible/min/hidden states.
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
{/* WRONG — wrapper breaks overflow behavior */}
|
|
167
|
+
<RxOverflow>
|
|
168
|
+
<div className="group">
|
|
169
|
+
<RxOverflowItem menuid="a"><button>A</button></RxOverflowItem>
|
|
170
|
+
<RxOverflowItem menuid="b"><button>B</button></RxOverflowItem>
|
|
171
|
+
</div>
|
|
172
|
+
</RxOverflow>
|
|
173
|
+
|
|
174
|
+
{/* CORRECT — items are direct children */}
|
|
175
|
+
<RxOverflow>
|
|
176
|
+
<RxOverflowItem menuid="a"><button>A</button></RxOverflowItem>
|
|
177
|
+
<RxOverflowItem menuid="b"><button>B</button></RxOverflowItem>
|
|
178
|
+
</RxOverflow>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The same rule applies to the vanilla JS variant — `<li>` elements with `data-overflow-role` must be direct children of the `<ul>` container.
|
|
182
|
+
|
|
159
183
|
## Modes
|
|
160
184
|
|
|
161
185
|
### Compact Mode
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import i from "@mui/material/Menu";
|
|
3
3
|
import l from "../Overflow/OverflowMenu.js";
|
|
4
|
-
function M({ opener:
|
|
5
|
-
return /* @__PURE__ */
|
|
4
|
+
function M({ opener: n, children: o }) {
|
|
5
|
+
return /* @__PURE__ */ r(l, { opener: n, renderMenu: ({ anchorEl: u, open: t, onClose: e, children: f }) => /* @__PURE__ */ r(i, { anchorEl: u, open: t, onClose: e, onClick: e, children: f }), children: o });
|
|
6
6
|
}
|
|
7
7
|
const a = Object.assign(M, { overflowRole: "menu" });
|
|
8
8
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MuiOverflowMenu.js","sources":["../../../src/components/MuiOverflow/MuiOverflowMenu.tsx"],"sourcesContent":["import Menu from '@mui/material/Menu';\nimport type { ReactNode } from 'react';\nimport { OverflowMenu, type RenderMenuProps } from '../Overflow';\n\ninterface MuiOverflowMenuProps {\n opener: ReactNode;\n children: ReactNode;\n}\n\nfunction MuiOverflowMenu({ opener, children }: MuiOverflowMenuProps) {\n const renderMenu = ({ anchorEl, open, onClose, children: menuChildren }: RenderMenuProps) => (\n <Menu anchorEl={anchorEl} open={open} onClose={onClose}>\n {menuChildren}\n </Menu>\n );\n\n return (\n <OverflowMenu opener={opener} renderMenu={renderMenu}>\n {children}\n </OverflowMenu>\n );\n}\n\nexport default Object.assign(MuiOverflowMenu, { overflowRole: 'menu' as const });\n"],"names":["MuiOverflowMenu","opener","children","jsx","OverflowMenu","anchorEl","open","onClose","menuChildren","Menu","MuiOverflowMenu_default"],"mappings":";;;AASA,SAASA,EAAgB,EAAE,QAAAC,GAAQ,UAAAC,KAAkC;AAOnE,SACE,gBAAAC,EAACC,GAAA,EAAa,QAAAH,GAAgB,YAPb,CAAC,EAAE,UAAAI,GAAU,MAAAC,GAAM,SAAAC,GAAS,UAAUC,
|
|
1
|
+
{"version":3,"file":"MuiOverflowMenu.js","sources":["../../../src/components/MuiOverflow/MuiOverflowMenu.tsx"],"sourcesContent":["import Menu from '@mui/material/Menu';\nimport type { ReactNode } from 'react';\nimport { OverflowMenu, type RenderMenuProps } from '../Overflow';\n\ninterface MuiOverflowMenuProps {\n opener: ReactNode;\n children: ReactNode;\n}\n\nfunction MuiOverflowMenu({ opener, children }: MuiOverflowMenuProps) {\n const renderMenu = ({ anchorEl, open, onClose, children: menuChildren }: RenderMenuProps) => (\n <Menu anchorEl={anchorEl} open={open} onClose={onClose} onClick={onClose}>\n {menuChildren}\n </Menu>\n );\n\n return (\n <OverflowMenu opener={opener} renderMenu={renderMenu}>\n {children}\n </OverflowMenu>\n );\n}\n\nexport default Object.assign(MuiOverflowMenu, { overflowRole: 'menu' as const });\n"],"names":["MuiOverflowMenu","opener","children","jsx","OverflowMenu","anchorEl","open","onClose","menuChildren","Menu","MuiOverflowMenu_default"],"mappings":";;;AASA,SAASA,EAAgB,EAAE,QAAAC,GAAQ,UAAAC,KAAkC;AAOnE,SACE,gBAAAC,EAACC,GAAA,EAAa,QAAAH,GAAgB,YAPb,CAAC,EAAE,UAAAI,GAAU,MAAAC,GAAM,SAAAC,GAAS,UAAUC,QACvD,gBAAAL,EAACM,KAAK,UAAAJ,GAAoB,MAAAC,GAAY,SAAAC,GAAkB,SAASA,GAC9D,UAAAC,GACH,GAKG,UAAAN,EAAA,CACH;AAEJ;AAEA,MAAAQ,IAAe,OAAO,OAAOV,GAAiB,EAAE,cAAc,QAAiB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverflowMenu.d.ts","sourceRoot":"","sources":["../../../src/components/Overflow/OverflowMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"OverflowMenu.d.ts","sourceRoot":"","sources":["../../../src/components/Overflow/OverflowMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAIxG,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,UAAU,iBAAiB;IACzB,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,SAAS,CAAC;CACnD;AAED,iBAAS,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,iBAAiB,2CA4DxE;;;;AAED,wBAA8E"}
|
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useOverflow as
|
|
4
|
-
function
|
|
5
|
-
const { hiddenMap:
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as d, jsxs as I, Fragment as M } from "react/jsx-runtime";
|
|
2
|
+
import { useState as b, useRef as u, useEffect as j, Children as x, isValidElement as y, Fragment as F } from "react";
|
|
3
|
+
import { useOverflow as H } from "./OverflowContext.js";
|
|
4
|
+
function R({ opener: a, children: m, renderMenu: f }) {
|
|
5
|
+
const { hiddenMap: s } = H(), [l, t] = b(null), o = u(null), h = !!l, n = [...s.values()].some((e) => e === "hidden"), i = u(n);
|
|
6
|
+
j(() => {
|
|
7
|
+
i.current && !n && t(null), i.current = n;
|
|
8
8
|
}, [n]);
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const p = () => {
|
|
10
|
+
const e = o.current?.firstElementChild;
|
|
11
|
+
t(e ?? o.current);
|
|
12
|
+
}, v = () => {
|
|
12
13
|
t(null);
|
|
13
14
|
}, r = [];
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
x.forEach(m, (e) => {
|
|
16
|
+
y(e) && r.push({ menuid: e.props.menuid, content: e.props.children });
|
|
16
17
|
});
|
|
17
|
-
const C = r.filter(({ menuid: e }) => e === void 0 ? !0 :
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const C = r.filter(({ menuid: e }) => e === void 0 ? !0 : s.get(e) === "hidden"), E = r.some(({ menuid: e }) => e === void 0), c = !n && !E, O = C.map(({ menuid: e, content: g }, w) => /* @__PURE__ */ d(F, { children: g }, e ?? `menu-item-${w}`));
|
|
19
|
+
return /* @__PURE__ */ I(M, { children: [
|
|
20
|
+
/* @__PURE__ */ d(
|
|
21
|
+
"li",
|
|
22
|
+
{
|
|
23
|
+
ref: o,
|
|
24
|
+
className: "overflow-opener",
|
|
25
|
+
"data-state": c ? "hidden" : void 0,
|
|
26
|
+
style: c ? { display: "none" } : void 0,
|
|
27
|
+
onClick: p,
|
|
28
|
+
children: a
|
|
24
29
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return /* @__PURE__ */ M(j, { children: [
|
|
28
|
-
/* @__PURE__ */ x("li", { className: "overflow-opener", "data-state": a ? "hidden" : void 0, style: a ? { display: "none" } : void 0, children: O }),
|
|
29
|
-
h({ anchorEl: c, open: p, onClose: u, children: g })
|
|
30
|
+
),
|
|
31
|
+
f({ anchorEl: l, open: h, onClose: v, children: O })
|
|
30
32
|
] });
|
|
31
33
|
}
|
|
32
|
-
const
|
|
34
|
+
const B = Object.assign(R, { overflowRole: "menu" });
|
|
33
35
|
export {
|
|
34
|
-
|
|
36
|
+
B as default
|
|
35
37
|
};
|
|
36
38
|
//# sourceMappingURL=OverflowMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverflowMenu.js","sources":["../../../src/components/Overflow/OverflowMenu.tsx"],"sourcesContent":["import { Children,
|
|
1
|
+
{"version":3,"file":"OverflowMenu.js","sources":["../../../src/components/Overflow/OverflowMenu.tsx"],"sourcesContent":["import { Children, Fragment, isValidElement, type ReactNode, useEffect, useRef, useState } from 'react';\nimport { useOverflow } from './OverflowContext';\nimport type { OverflowItemProps } from './OverflowItem';\n\nexport interface RenderMenuProps {\n anchorEl: HTMLElement | null;\n open: boolean;\n onClose: () => void;\n children: ReactNode;\n}\n\ninterface OverflowMenuProps {\n opener: ReactNode;\n children: ReactNode;\n renderMenu: (props: RenderMenuProps) => ReactNode;\n}\n\nfunction OverflowMenu({ opener, children, renderMenu }: OverflowMenuProps) {\n const { hiddenMap } = useOverflow();\n const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);\n const openerRef = useRef<HTMLLIElement>(null);\n const open = Boolean(anchorEl);\n\n const hasHiddenItems = [...hiddenMap.values()].some(s => s === 'hidden');\n const prevHasHidden = useRef(hasHiddenItems);\n\n // Auto-close when no items are fully hidden\n useEffect(() => {\n if (prevHasHidden.current && !hasHiddenItems) {\n setAnchorEl(null);\n }\n prevHasHidden.current = hasHiddenItems;\n }, [hasHiddenItems]);\n\n const handleOpen = () => {\n const button = openerRef.current?.firstElementChild as HTMLElement | null;\n setAnchorEl(button ?? openerRef.current);\n };\n\n const handleClose = () => {\n setAnchorEl(null);\n };\n\n // Collect menuid set from children to determine which are \"menu-only\"\n const menuItems: { menuid: string | undefined; content: ReactNode }[] = [];\n Children.forEach(children, (child) => {\n if (!isValidElement<OverflowItemProps>(child)) return;\n menuItems.push({ menuid: child.props.menuid, content: child.props.children });\n });\n\n // Determine visible menu items: show when fully hidden or menu-only\n const visibleItems = menuItems.filter(({ menuid }) => {\n if (menuid === undefined) return true; // no menuid = always shown in menu\n return hiddenMap.get(menuid) === 'hidden'; // shown when fully hidden in toolbar\n });\n\n const hasMenuOnlyItems = menuItems.some(({ menuid }) => menuid === undefined);\n const hidden = !hasHiddenItems && !hasMenuOnlyItems;\n\n const menuChildren = visibleItems.map(({ menuid, content }, i) => (\n <Fragment key={menuid ?? `menu-item-${i}`}>{content}</Fragment>\n ));\n\n return (\n <>\n <li\n ref={openerRef}\n className=\"overflow-opener\"\n data-state={hidden ? 'hidden' : undefined}\n style={hidden ? { display: 'none' } : undefined}\n onClick={handleOpen}\n >\n {opener}\n </li>\n {renderMenu({ anchorEl, open, onClose: handleClose, children: menuChildren })}\n </>\n );\n}\n\nexport default Object.assign(OverflowMenu, { overflowRole: 'menu' as const });\n"],"names":["OverflowMenu","opener","children","renderMenu","hiddenMap","useOverflow","anchorEl","setAnchorEl","useState","openerRef","useRef","open","hasHiddenItems","s","prevHasHidden","useEffect","handleOpen","button","handleClose","menuItems","Children","child","isValidElement","visibleItems","menuid","hasMenuOnlyItems","hidden","menuChildren","content","i","jsx","Fragment","jsxs","OverflowMenu$1"],"mappings":";;;AAiBA,SAASA,EAAa,EAAE,QAAAC,GAAQ,UAAAC,GAAU,YAAAC,KAAiC;AACzE,QAAM,EAAE,WAAAC,EAAA,IAAcC,EAAA,GAChB,CAACC,GAAUC,CAAW,IAAIC,EAA6B,IAAI,GAC3DC,IAAYC,EAAsB,IAAI,GACtCC,IAAO,EAAQL,GAEfM,IAAiB,CAAC,GAAGR,EAAU,OAAA,CAAQ,EAAE,KAAK,CAAAS,MAAKA,MAAM,QAAQ,GACjEC,IAAgBJ,EAAOE,CAAc;AAG3C,EAAAG,EAAU,MAAM;AACd,IAAID,EAAc,WAAW,CAACF,KAC5BL,EAAY,IAAI,GAElBO,EAAc,UAAUF;AAAA,EAC1B,GAAG,CAACA,CAAc,CAAC;AAEnB,QAAMI,IAAa,MAAM;AACvB,UAAMC,IAASR,EAAU,SAAS;AAClC,IAAAF,EAAYU,KAAUR,EAAU,OAAO;AAAA,EACzC,GAEMS,IAAc,MAAM;AACxB,IAAAX,EAAY,IAAI;AAAA,EAClB,GAGMY,IAAkE,CAAA;AACxE,EAAAC,EAAS,QAAQlB,GAAU,CAACmB,MAAU;AACpC,IAAKC,EAAkCD,CAAK,KAC5CF,EAAU,KAAK,EAAE,QAAQE,EAAM,MAAM,QAAQ,SAASA,EAAM,MAAM,SAAA,CAAU;AAAA,EAC9E,CAAC;AAGD,QAAME,IAAeJ,EAAU,OAAO,CAAC,EAAE,QAAAK,QACnCA,MAAW,SAAkB,KAC1BpB,EAAU,IAAIoB,CAAM,MAAM,QAClC,GAEKC,IAAmBN,EAAU,KAAK,CAAC,EAAE,QAAAK,EAAA,MAAaA,MAAW,MAAS,GACtEE,IAAS,CAACd,KAAkB,CAACa,GAE7BE,IAAeJ,EAAa,IAAI,CAAC,EAAE,QAAAC,GAAQ,SAAAI,EAAA,GAAWC,MAC1D,gBAAAC,EAACC,GAAA,EAA2C,UAAAH,KAA7BJ,KAAU,aAAaK,CAAC,EAAa,CACrD;AAED,SACE,gBAAAG,EAAAD,GAAA,EACE,UAAA;AAAA,IAAA,gBAAAD;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAKrB;AAAA,QACL,WAAU;AAAA,QACV,cAAYiB,IAAS,WAAW;AAAA,QAChC,OAAOA,IAAS,EAAE,SAAS,WAAW;AAAA,QACtC,SAASV;AAAA,QAER,UAAAf;AAAA,MAAA;AAAA,IAAA;AAAA,IAEFE,EAAW,EAAE,UAAAG,GAAU,MAAAK,GAAM,SAASO,GAAa,UAAUS,GAAc;AAAA,EAAA,GAC9E;AAEJ;AAEA,MAAAM,IAAe,OAAO,OAAOjC,GAAc,EAAE,cAAc,QAAiB;"}
|
|
@@ -3,17 +3,17 @@ import * as r from "@radix-ui/react-popover";
|
|
|
3
3
|
import { useRef as s } from "react";
|
|
4
4
|
import a from "../Overflow/OverflowMenu.js";
|
|
5
5
|
function d({ opener: n, children: o }) {
|
|
6
|
-
return /* @__PURE__ */ e(a, { opener: n, renderMenu: ({ anchorEl:
|
|
6
|
+
return /* @__PURE__ */ e(a, { opener: n, renderMenu: ({ anchorEl: u, open: t, onClose: f, children: l }) => /* @__PURE__ */ e(m, { anchorEl: u, open: t, onClose: f, children: l }), children: o });
|
|
7
7
|
}
|
|
8
8
|
const v = Object.assign(d, { overflowRole: "menu" });
|
|
9
|
-
function m({ anchorEl: n, open: o, onClose:
|
|
9
|
+
function m({ anchorEl: n, open: o, onClose: i, children: u }) {
|
|
10
10
|
const t = s({
|
|
11
11
|
getBoundingClientRect: () => new DOMRect()
|
|
12
12
|
});
|
|
13
13
|
return n && (t.current = {
|
|
14
14
|
getBoundingClientRect: () => n.getBoundingClientRect()
|
|
15
|
-
}), /* @__PURE__ */ c(r.Root, { open: o, onOpenChange: (
|
|
16
|
-
|
|
15
|
+
}), /* @__PURE__ */ c(r.Root, { open: o, onOpenChange: (f) => {
|
|
16
|
+
f || i();
|
|
17
17
|
}, children: [
|
|
18
18
|
/* @__PURE__ */ e(r.Anchor, { virtualRef: t }),
|
|
19
19
|
/* @__PURE__ */ e(r.Portal, { children: /* @__PURE__ */ e(
|
|
@@ -22,7 +22,8 @@ function m({ anchorEl: n, open: o, onClose: f, children: i }) {
|
|
|
22
22
|
className: "rx-menu-panel",
|
|
23
23
|
sideOffset: 4,
|
|
24
24
|
align: "start",
|
|
25
|
-
|
|
25
|
+
onClick: i,
|
|
26
|
+
children: u
|
|
26
27
|
}
|
|
27
28
|
) })
|
|
28
29
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RxOverflowMenu.js","sources":["../../../src/components/RxOverflow/RxOverflowMenu.tsx"],"sourcesContent":["import * as Popover from '@radix-ui/react-popover';\nimport { type ReactNode, useRef } from 'react';\nimport { OverflowMenu, type RenderMenuProps } from '../Overflow';\n\ninterface RxOverflowMenuProps {\n opener: ReactNode;\n children: ReactNode;\n}\n\nfunction RxOverflowMenu({ opener, children }: RxOverflowMenuProps) {\n const renderMenu = ({ anchorEl, open, onClose, children: menuChildren }: RenderMenuProps) => (\n <RxPopoverMenu anchorEl={anchorEl} open={open} onClose={onClose}>\n {menuChildren}\n </RxPopoverMenu>\n );\n\n return (\n <OverflowMenu opener={opener} renderMenu={renderMenu}>\n {children}\n </OverflowMenu>\n );\n}\n\nexport default Object.assign(RxOverflowMenu, { overflowRole: 'menu' as const });\n\nfunction RxPopoverMenu({ anchorEl, open, onClose, children }: RenderMenuProps) {\n const virtualRef = useRef<{ getBoundingClientRect: () => DOMRect }>({\n getBoundingClientRect: () => new DOMRect(),\n });\n\n // Update synchronously during render so the popover positions correctly\n // on the same frame it opens (useEffect would be one frame too late).\n if (anchorEl) {\n virtualRef.current = {\n getBoundingClientRect: () => anchorEl.getBoundingClientRect(),\n };\n }\n\n return (\n <Popover.Root open={open} onOpenChange={(o) => { if (!o) onClose(); }}>\n <Popover.Anchor virtualRef={virtualRef} />\n <Popover.Portal>\n <Popover.Content\n className=\"rx-menu-panel\"\n sideOffset={4}\n align=\"start\"\n >\n {children}\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n"],"names":["RxOverflowMenu","opener","children","jsx","OverflowMenu","anchorEl","open","onClose","menuChildren","RxPopoverMenu","RxOverflowMenu_default","virtualRef","useRef","Popover","o"],"mappings":";;;;AASA,SAASA,EAAe,EAAE,QAAAC,GAAQ,UAAAC,KAAiC;AAOjE,SACE,gBAAAC,EAACC,GAAA,EAAa,QAAAH,GAAgB,YAPb,CAAC,EAAE,UAAAI,GAAU,MAAAC,GAAM,SAAAC,GAAS,UAAUC,EAAA,MACvD,gBAAAL,EAACM,GAAA,EAAc,UAAAJ,GAAoB,MAAAC,GAAY,SAAAC,GAC5C,UAAAC,GACH,GAKG,UAAAN,EAAA,CACH;AAEJ;AAEA,MAAAQ,IAAe,OAAO,OAAOV,GAAgB,EAAE,cAAc,QAAiB;AAE9E,SAASS,EAAc,EAAE,UAAAJ,GAAU,MAAAC,GAAM,SAAAC,GAAS,UAAAL,KAA6B;AAC7E,QAAMS,IAAaC,EAAiD;AAAA,IAClE,uBAAuB,MAAM,IAAI,QAAA;AAAA,EAAQ,CAC1C;AAID,SAAIP,MACFM,EAAW,UAAU;AAAA,IACnB,uBAAuB,MAAMN,EAAS,sBAAA;AAAA,EAAsB,sBAK7DQ,EAAQ,MAAR,EAAa,MAAAP,GAAY,cAAc,CAACQ,MAAM;AAAE,IAAKA,KAAGP,EAAA;AAAA,EAAW,GAClE,UAAA;AAAA,IAAA,gBAAAJ,EAACU,EAAQ,QAAR,EAAe,YAAAF,EAAA,CAAwB;AAAA,IACxC,gBAAAR,EAACU,EAAQ,QAAR,EACC,UAAA,gBAAAV;AAAA,MAACU,EAAQ;AAAA,MAAR;AAAA,QACC,WAAU;AAAA,QACV,YAAY;AAAA,QACZ,OAAM;AAAA,
|
|
1
|
+
{"version":3,"file":"RxOverflowMenu.js","sources":["../../../src/components/RxOverflow/RxOverflowMenu.tsx"],"sourcesContent":["import * as Popover from '@radix-ui/react-popover';\nimport { type ReactNode, useRef } from 'react';\nimport { OverflowMenu, type RenderMenuProps } from '../Overflow';\n\ninterface RxOverflowMenuProps {\n opener: ReactNode;\n children: ReactNode;\n}\n\nfunction RxOverflowMenu({ opener, children }: RxOverflowMenuProps) {\n const renderMenu = ({ anchorEl, open, onClose, children: menuChildren }: RenderMenuProps) => (\n <RxPopoverMenu anchorEl={anchorEl} open={open} onClose={onClose}>\n {menuChildren}\n </RxPopoverMenu>\n );\n\n return (\n <OverflowMenu opener={opener} renderMenu={renderMenu}>\n {children}\n </OverflowMenu>\n );\n}\n\nexport default Object.assign(RxOverflowMenu, { overflowRole: 'menu' as const });\n\nfunction RxPopoverMenu({ anchorEl, open, onClose, children }: RenderMenuProps) {\n const virtualRef = useRef<{ getBoundingClientRect: () => DOMRect }>({\n getBoundingClientRect: () => new DOMRect(),\n });\n\n // Update synchronously during render so the popover positions correctly\n // on the same frame it opens (useEffect would be one frame too late).\n if (anchorEl) {\n virtualRef.current = {\n getBoundingClientRect: () => anchorEl.getBoundingClientRect(),\n };\n }\n\n return (\n <Popover.Root open={open} onOpenChange={(o) => { if (!o) onClose(); }}>\n <Popover.Anchor virtualRef={virtualRef} />\n <Popover.Portal>\n <Popover.Content\n className=\"rx-menu-panel\"\n sideOffset={4}\n align=\"start\"\n onClick={onClose}\n >\n {children}\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n"],"names":["RxOverflowMenu","opener","children","jsx","OverflowMenu","anchorEl","open","onClose","menuChildren","RxPopoverMenu","RxOverflowMenu_default","virtualRef","useRef","Popover","o"],"mappings":";;;;AASA,SAASA,EAAe,EAAE,QAAAC,GAAQ,UAAAC,KAAiC;AAOjE,SACE,gBAAAC,EAACC,GAAA,EAAa,QAAAH,GAAgB,YAPb,CAAC,EAAE,UAAAI,GAAU,MAAAC,GAAM,SAAAC,GAAS,UAAUC,EAAA,MACvD,gBAAAL,EAACM,GAAA,EAAc,UAAAJ,GAAoB,MAAAC,GAAY,SAAAC,GAC5C,UAAAC,GACH,GAKG,UAAAN,EAAA,CACH;AAEJ;AAEA,MAAAQ,IAAe,OAAO,OAAOV,GAAgB,EAAE,cAAc,QAAiB;AAE9E,SAASS,EAAc,EAAE,UAAAJ,GAAU,MAAAC,GAAM,SAAAC,GAAS,UAAAL,KAA6B;AAC7E,QAAMS,IAAaC,EAAiD;AAAA,IAClE,uBAAuB,MAAM,IAAI,QAAA;AAAA,EAAQ,CAC1C;AAID,SAAIP,MACFM,EAAW,UAAU;AAAA,IACnB,uBAAuB,MAAMN,EAAS,sBAAA;AAAA,EAAsB,sBAK7DQ,EAAQ,MAAR,EAAa,MAAAP,GAAY,cAAc,CAACQ,MAAM;AAAE,IAAKA,KAAGP,EAAA;AAAA,EAAW,GAClE,UAAA;AAAA,IAAA,gBAAAJ,EAACU,EAAQ,QAAR,EAAe,YAAAF,EAAA,CAAwB;AAAA,IACxC,gBAAAR,EAACU,EAAQ,QAAR,EACC,UAAA,gBAAAV;AAAA,MAACU,EAAQ;AAAA,MAAR;AAAA,QACC,WAAU;AAAA,QACV,YAAY;AAAA,QACZ,OAAM;AAAA,QACN,SAASN;AAAA,QAER,UAAAL;AAAA,MAAA;AAAA,IAAA,EACH,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "overflow-toolbar",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Responsive toolbar overflow component — items automatically collapse into a dropdown menu as the container shrinks. Supports visible, icon-only (min), and hidden states. Ships with React (Radix UI), MUI, and vanilla JS implementations.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -110,7 +110,11 @@
|
|
|
110
110
|
"test:unit": "vitest run --project unit",
|
|
111
111
|
"test:coverage": "vitest run --project unit --coverage",
|
|
112
112
|
"typecheck": "tsc -p tsconfig.build.json --noEmit",
|
|
113
|
-
"
|
|
113
|
+
"prepublishOnly": "pnpm run build:lib && pnpm run test:unit",
|
|
114
|
+
"release:patch": "npm version patch && npm publish --access public",
|
|
115
|
+
"release:minor": "npm version minor && npm publish --access public",
|
|
116
|
+
"release:major": "npm version major && npm publish --access public",
|
|
117
|
+
"prepare": "husky"
|
|
114
118
|
},
|
|
115
119
|
"dependencies": {
|
|
116
120
|
"clsx": "^2.0.0",
|
|
@@ -167,6 +171,7 @@
|
|
|
167
171
|
"eslint-plugin-react-refresh": "^0.4.24",
|
|
168
172
|
"eslint-plugin-storybook": "^10.2.14",
|
|
169
173
|
"globals": "^16.5.0",
|
|
174
|
+
"husky": "^9.1.7",
|
|
170
175
|
"jsdom": "^28.1.0",
|
|
171
176
|
"lucide-react": "^0.576.0",
|
|
172
177
|
"playwright": "^1.58.2",
|