@open-mercato/ui 0.6.7-develop.6595.1.e93ecd3cfa → 0.6.7-develop.6597.1.b8f069b7fe
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/.turbo/turbo-build.log +1 -1
- package/dist/backend/DataTable.js +22 -1
- package/dist/backend/DataTable.js.map +2 -2
- package/dist/backend/utils/viewport.js +9 -0
- package/dist/backend/utils/viewport.js.map +7 -0
- package/package.json +3 -3
- package/src/backend/DataTable.tsx +27 -1
- package/src/backend/utils/__tests__/viewport.test.ts +26 -0
- package/src/backend/utils/viewport.ts +18 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -36,6 +36,7 @@ import { apiCall, withScopedApiRequestHeaders } from "./utils/apiCall.js";
|
|
|
36
36
|
import { buildOptimisticLockHeader } from "./utils/optimisticLock.js";
|
|
37
37
|
import { useGuardedMutation } from "./injection/useGuardedMutation.js";
|
|
38
38
|
import { raiseCrudError } from "./utils/serverErrors.js";
|
|
39
|
+
import { computeMenuViewportShiftX } from "./utils/viewport.js";
|
|
39
40
|
import { PerspectiveSidebar } from "./PerspectiveSidebar.js";
|
|
40
41
|
import { Popover, PopoverTrigger, PopoverContent } from "../primitives/popover.js";
|
|
41
42
|
import { formatWithPublicDateFormat, normalizeDateFormatPattern } from "../primitives/date-format.js";
|
|
@@ -370,8 +371,27 @@ function ExportMenu({ config, sections }) {
|
|
|
370
371
|
const disabled = Boolean(config.disabled);
|
|
371
372
|
const hasSections = sections.length > 0;
|
|
372
373
|
const [open, setOpen] = React.useState(false);
|
|
374
|
+
const [menuOffsetX, setMenuOffsetX] = React.useState(0);
|
|
373
375
|
const buttonRef = React.useRef(null);
|
|
374
376
|
const menuRef = React.useRef(null);
|
|
377
|
+
React.useLayoutEffect(() => {
|
|
378
|
+
if (!open) {
|
|
379
|
+
setMenuOffsetX(0);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const measure = () => {
|
|
383
|
+
const el = menuRef.current;
|
|
384
|
+
if (!el || typeof window === "undefined") return;
|
|
385
|
+
const previousTransform = el.style.transform;
|
|
386
|
+
el.style.transform = "none";
|
|
387
|
+
const rect = el.getBoundingClientRect();
|
|
388
|
+
el.style.transform = previousTransform;
|
|
389
|
+
setMenuOffsetX(computeMenuViewportShiftX(rect, window.innerWidth));
|
|
390
|
+
};
|
|
391
|
+
measure();
|
|
392
|
+
window.addEventListener("resize", measure);
|
|
393
|
+
return () => window.removeEventListener("resize", measure);
|
|
394
|
+
}, [open]);
|
|
375
395
|
React.useEffect(() => {
|
|
376
396
|
if (!open || !hasSections) return;
|
|
377
397
|
const onDocClick = (event) => {
|
|
@@ -446,7 +466,8 @@ function ExportMenu({ config, sections }) {
|
|
|
446
466
|
{
|
|
447
467
|
ref: menuRef,
|
|
448
468
|
role: "menu",
|
|
449
|
-
className: "absolute right-0 mt-2 w-60 rounded-md border bg-background py-2 shadow z-dropdown",
|
|
469
|
+
className: "absolute right-0 mt-2 w-60 max-w-[calc(100vw-1rem)] rounded-md border bg-background py-2 shadow z-dropdown",
|
|
470
|
+
style: menuOffsetX ? { transform: `translateX(${menuOffsetX}px)` } : void 0,
|
|
450
471
|
children: sections.map((section, idx) => /* @__PURE__ */ jsxs("div", { className: idx > 0 ? "mt-2 border-t pt-3" : "", children: [
|
|
451
472
|
/* @__PURE__ */ jsxs("div", { className: "px-3", children: [
|
|
452
473
|
/* @__PURE__ */ jsx("div", { className: "text-xs font-semibold uppercase text-muted-foreground", children: section.title }),
|