@algenium/blocks 1.7.0-rc.4 → 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 +109 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +111 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8224,7 +8224,7 @@ function PdfThumbnailStrip({
|
|
|
8224
8224
|
const canvas = canvasRef.current;
|
|
8225
8225
|
if (!canvas) return;
|
|
8226
8226
|
const viewport = page.getViewport({ scale: 1 });
|
|
8227
|
-
const thumbMax =
|
|
8227
|
+
const thumbMax = 176;
|
|
8228
8228
|
const s = thumbMax / Math.max(viewport.width, viewport.height);
|
|
8229
8229
|
const vp = page.getViewport({ scale: s });
|
|
8230
8230
|
const ctx = canvas.getContext("2d");
|
|
@@ -8248,8 +8248,8 @@ function PdfThumbnailStrip({
|
|
|
8248
8248
|
type: "button",
|
|
8249
8249
|
onClick: () => onPick(pageNumber),
|
|
8250
8250
|
className: cn(
|
|
8251
|
-
"flex w-full flex-col items-center gap-1 rounded-md p-
|
|
8252
|
-
active ? "bg-
|
|
8251
|
+
"flex w-full flex-col items-center gap-1 rounded-md p-2 transition-colors hover:bg-white/5",
|
|
8252
|
+
active ? "bg-white/10" : ""
|
|
8253
8253
|
),
|
|
8254
8254
|
"aria-label": label,
|
|
8255
8255
|
"aria-current": active ? "page" : void 0,
|
|
@@ -8258,11 +8258,11 @@ function PdfThumbnailStrip({
|
|
|
8258
8258
|
"canvas",
|
|
8259
8259
|
{
|
|
8260
8260
|
ref: canvasRef,
|
|
8261
|
-
className: "block max-w-full rounded-sm
|
|
8261
|
+
className: "block max-w-full overflow-hidden rounded-sm bg-black",
|
|
8262
8262
|
"aria-hidden": true
|
|
8263
8263
|
}
|
|
8264
8264
|
),
|
|
8265
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-
|
|
8265
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] tabular-nums text-neutral-400", children: pageNumber })
|
|
8266
8266
|
]
|
|
8267
8267
|
}
|
|
8268
8268
|
);
|
|
@@ -8297,6 +8297,7 @@ function PdfViewer({
|
|
|
8297
8297
|
const errorLabelFallback = mergedLabels.error ?? "Failed to load PDF";
|
|
8298
8298
|
const toolbarId = React2.useId();
|
|
8299
8299
|
const pageInputId = `${toolbarId}-page`;
|
|
8300
|
+
const thumbnailNavId = `${toolbarId}-thumbnails`;
|
|
8300
8301
|
const scrollRef = React2.useRef(null);
|
|
8301
8302
|
const observerRef = React2.useRef(null);
|
|
8302
8303
|
const lastReportedPage = React2.useRef(0);
|
|
@@ -8638,6 +8639,7 @@ function PdfViewer({
|
|
|
8638
8639
|
resetZoomAct
|
|
8639
8640
|
]
|
|
8640
8641
|
);
|
|
8642
|
+
const thumbnailsRailEligible = enableThumbnailSidebar && !busy && pagesMap !== null && pageCount > 0;
|
|
8641
8643
|
if (loadError) {
|
|
8642
8644
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8643
8645
|
"div",
|
|
@@ -8667,6 +8669,20 @@ function PdfViewer({
|
|
|
8667
8669
|
toolbarClassName
|
|
8668
8670
|
),
|
|
8669
8671
|
children: [
|
|
8672
|
+
thumbnailsRailEligible ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
8673
|
+
Button,
|
|
8674
|
+
{
|
|
8675
|
+
type: "button",
|
|
8676
|
+
variant: "outline",
|
|
8677
|
+
size: "icon-sm",
|
|
8678
|
+
className: "hidden md:inline-flex",
|
|
8679
|
+
onClick: () => setThumbnailSidebarOpen((v) => !v),
|
|
8680
|
+
"aria-label": toggleThumbLabel,
|
|
8681
|
+
"aria-expanded": thumbnailSidebarOpen,
|
|
8682
|
+
"aria-controls": thumbnailNavId,
|
|
8683
|
+
children: thumbnailSidebarOpen ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelLeftOpen, { className: "size-4", "aria-hidden": true }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelRightOpen, { className: "size-4", "aria-hidden": true })
|
|
8684
|
+
}
|
|
8685
|
+
) : null,
|
|
8670
8686
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-xs tabular-nums sm:text-sm", children: busy || pagesMap === null ? "\u2014" : pageOfFormatter(currentVisiblePage, pageCount) }),
|
|
8671
8687
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: pageInputId, className: "sr-only", children: resolvedGoToLabel }),
|
|
8672
8688
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -8742,12 +8758,13 @@ function PdfViewer({
|
|
|
8742
8758
|
}
|
|
8743
8759
|
),
|
|
8744
8760
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-h-0 flex-1 overflow-hidden", children: [
|
|
8745
|
-
|
|
8761
|
+
thumbnailsRailEligible && thumbnailSidebarOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
8746
8762
|
"nav",
|
|
8747
8763
|
{
|
|
8748
|
-
|
|
8764
|
+
id: thumbnailNavId,
|
|
8765
|
+
className: "hidden w-[220px] shrink-0 flex-col overflow-y-auto border-r border-neutral-900 bg-black py-3 pl-3 pr-2 md:flex",
|
|
8749
8766
|
"aria-label": thumbnailSidebarLabel,
|
|
8750
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-
|
|
8767
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: layouts.map((layout) => {
|
|
8751
8768
|
const pg = pagesMap.get(layout.pageNumber);
|
|
8752
8769
|
return pg ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
8753
8770
|
PdfThumbnailStrip,
|
|
@@ -8763,50 +8780,94 @@ function PdfViewer({
|
|
|
8763
8780
|
}) })
|
|
8764
8781
|
}
|
|
8765
8782
|
) : null,
|
|
8766
|
-
/* @__PURE__ */ jsxRuntime.
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
{
|
|
8793
|
-
page: pg,
|
|
8794
|
-
layout,
|
|
8795
|
-
scale,
|
|
8796
|
-
visible,
|
|
8797
|
-
pageClassName
|
|
8798
|
-
},
|
|
8799
|
-
layout.pageNumber
|
|
8800
|
-
) : null;
|
|
8801
|
-
}) })
|
|
8802
|
-
}
|
|
8803
|
-
)
|
|
8804
|
-
] })
|
|
8783
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8784
|
+
"div",
|
|
8785
|
+
{
|
|
8786
|
+
ref: scrollRef,
|
|
8787
|
+
tabIndex: 0,
|
|
8788
|
+
onKeyDown: handleKeyDown,
|
|
8789
|
+
className: "relative min-h-[240px] min-w-0 flex-1 overflow-auto outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
8790
|
+
"aria-busy": busy,
|
|
8791
|
+
"aria-label": busy ? loadingLabel : "PDF pages",
|
|
8792
|
+
children: busy || pagesMap === null ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground p-6 text-sm", children: loadingLabel }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center gap-4 pb-8 pt-2", children: layouts.map((layout) => {
|
|
8793
|
+
const pg = pagesMap.get(layout.pageNumber);
|
|
8794
|
+
const visible = (ratios[layout.pageNumber] ?? 0) >= 1e-3;
|
|
8795
|
+
return pg ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
8796
|
+
PdfPageCanvas,
|
|
8797
|
+
{
|
|
8798
|
+
page: pg,
|
|
8799
|
+
layout,
|
|
8800
|
+
scale,
|
|
8801
|
+
visible,
|
|
8802
|
+
pageClassName
|
|
8803
|
+
},
|
|
8804
|
+
layout.pageNumber
|
|
8805
|
+
) : null;
|
|
8806
|
+
}) })
|
|
8807
|
+
}
|
|
8808
|
+
)
|
|
8805
8809
|
] })
|
|
8806
8810
|
]
|
|
8807
8811
|
}
|
|
8808
8812
|
);
|
|
8809
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
|
+
}
|
|
8810
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";
|
|
8811
8872
|
function PdfViewerDialog({
|
|
8812
8873
|
open,
|
|
@@ -8822,6 +8883,7 @@ function PdfViewerDialog({
|
|
|
8822
8883
|
const closeLabel = labels?.close ?? "Close";
|
|
8823
8884
|
const dialogTitle = labels?.dialogTitle ?? title ?? "PDF document";
|
|
8824
8885
|
const dialogDescription = labels?.dialogDescription ?? "Document viewer with zoom and page navigation.";
|
|
8886
|
+
usePdfViewerDialogScrollLock(open);
|
|
8825
8887
|
const {
|
|
8826
8888
|
className: forwardedClassName,
|
|
8827
8889
|
toolbarClassName: forwardedToolbarClassName,
|