@algenium/blocks 1.7.0-rc.5 → 1.7.0-rc.6
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/index.cjs +58 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +59 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8811,6 +8811,63 @@ function PdfViewer({
|
|
|
8811
8811
|
}
|
|
8812
8812
|
);
|
|
8813
8813
|
}
|
|
8814
|
+
function usePdfViewerDialogScrollLock(active) {
|
|
8815
|
+
React2.useLayoutEffect(() => {
|
|
8816
|
+
if (!active || typeof document === "undefined") return;
|
|
8817
|
+
const html = document.documentElement;
|
|
8818
|
+
const body = document.body;
|
|
8819
|
+
const scrollRoots = [
|
|
8820
|
+
...document.querySelectorAll("[data-scroll-lock-root]")
|
|
8821
|
+
];
|
|
8822
|
+
const scrollTopSnapshot = scrollRoots.map((el) => ({
|
|
8823
|
+
el,
|
|
8824
|
+
scrollTop: el.scrollTop
|
|
8825
|
+
}));
|
|
8826
|
+
const targets = /* @__PURE__ */ new Set([html, body, ...scrollRoots]);
|
|
8827
|
+
const snapshot = [...targets].map((el) => ({
|
|
8828
|
+
el,
|
|
8829
|
+
overflow: el.style.overflow,
|
|
8830
|
+
overscrollBehavior: el.style.overscrollBehavior
|
|
8831
|
+
}));
|
|
8832
|
+
const windowScrollY = window.scrollY;
|
|
8833
|
+
for (const el of targets) {
|
|
8834
|
+
el.style.overflow = "hidden";
|
|
8835
|
+
el.style.overscrollBehavior = "none";
|
|
8836
|
+
}
|
|
8837
|
+
const dialogSurfaceSelector = '[data-slot="dialog-content"]';
|
|
8838
|
+
const shouldAllowEventTarget = (target) => target instanceof Element && Boolean(target.closest(dialogSurfaceSelector));
|
|
8839
|
+
const onWheel = (e) => {
|
|
8840
|
+
if (shouldAllowEventTarget(e.target)) return;
|
|
8841
|
+
e.preventDefault();
|
|
8842
|
+
};
|
|
8843
|
+
const onTouchMove = (e) => {
|
|
8844
|
+
if (shouldAllowEventTarget(e.target)) return;
|
|
8845
|
+
e.preventDefault();
|
|
8846
|
+
};
|
|
8847
|
+
window.addEventListener("wheel", onWheel, {
|
|
8848
|
+
capture: true,
|
|
8849
|
+
passive: false
|
|
8850
|
+
});
|
|
8851
|
+
window.addEventListener("touchmove", onTouchMove, {
|
|
8852
|
+
capture: true,
|
|
8853
|
+
passive: false
|
|
8854
|
+
});
|
|
8855
|
+
return () => {
|
|
8856
|
+
window.removeEventListener("wheel", onWheel, { capture: true });
|
|
8857
|
+
window.removeEventListener("touchmove", onTouchMove, {
|
|
8858
|
+
capture: true
|
|
8859
|
+
});
|
|
8860
|
+
for (const { el, overflow, overscrollBehavior } of snapshot) {
|
|
8861
|
+
el.style.overflow = overflow;
|
|
8862
|
+
el.style.overscrollBehavior = overscrollBehavior;
|
|
8863
|
+
}
|
|
8864
|
+
for (const { el, scrollTop } of scrollTopSnapshot) {
|
|
8865
|
+
el.scrollTop = scrollTop;
|
|
8866
|
+
}
|
|
8867
|
+
window.scrollTo(0, windowScrollY);
|
|
8868
|
+
};
|
|
8869
|
+
}, [active]);
|
|
8870
|
+
}
|
|
8814
8871
|
var fullscreenDialogContentClass = "!max-w-none !w-screen !h-screen !p-0 !border-0 !bg-black/95 !rounded-none !top-0 !left-0 !translate-x-0 !translate-y-0 !gap-0 !shadow-none !flex !flex-col data-[state=open]:!zoom-in-100 data-[state=closed]:!zoom-out-100";
|
|
8815
8872
|
function PdfViewerDialog({
|
|
8816
8873
|
open,
|
|
@@ -8826,6 +8883,7 @@ function PdfViewerDialog({
|
|
|
8826
8883
|
const closeLabel = labels?.close ?? "Close";
|
|
8827
8884
|
const dialogTitle = labels?.dialogTitle ?? title ?? "PDF document";
|
|
8828
8885
|
const dialogDescription = labels?.dialogDescription ?? "Document viewer with zoom and page navigation.";
|
|
8886
|
+
usePdfViewerDialogScrollLock(open);
|
|
8829
8887
|
const {
|
|
8830
8888
|
className: forwardedClassName,
|
|
8831
8889
|
toolbarClassName: forwardedToolbarClassName,
|