@k2b/ui 0.57.0 → 0.58.0
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/browser/actions/Dropdown.js +4 -3
- package/dist/browser/actions/Dropdown.js.map +1 -1
- package/dist/browser/actions/menu-rows.js +1 -1
- package/dist/browser/actions/menu-rows.js.map +1 -1
- package/dist/browser/content/PdfPages.js +159 -44
- package/dist/browser/content/PdfPages.js.map +1 -1
- package/dist/browser/content/PdfViewer.js +59 -21
- package/dist/browser/content/PdfViewer.js.map +1 -1
- package/dist/browser/content/pdf-viewer-engine.js +1 -1
- package/dist/browser/layout/FloatingWindow.js +122 -75
- package/dist/browser/layout/FloatingWindow.js.map +1 -1
- package/dist/browser/layout/Panes.js +640 -212
- package/dist/browser/layout/Panes.js.map +1 -1
- package/dist/browser/layout/index.js +1 -1
- package/dist/browser/layout/index.js.map +1 -1
- package/dist/browser/layout/panes-layout.js +169 -0
- package/dist/browser/layout/panes-layout.js.map +1 -1
- package/dist/browser/layout/panes-messages.js +108 -2
- package/dist/browser/layout/panes-messages.js.map +1 -1
- package/dist/ssr/actions/Dropdown.js +4 -4
- package/dist/ssr/actions/Dropdown.js.map +1 -1
- package/dist/ssr/actions/menu-rows.js +1 -1
- package/dist/ssr/actions/menu-rows.js.map +1 -1
- package/dist/ssr/content/PdfPages.js +159 -44
- package/dist/ssr/content/PdfPages.js.map +1 -1
- package/dist/ssr/content/PdfViewer.js +40 -8
- package/dist/ssr/content/PdfViewer.js.map +1 -1
- package/dist/ssr/layout/FloatingWindow.js +37 -15
- package/dist/ssr/layout/FloatingWindow.js.map +1 -1
- package/dist/ssr/layout/Panes.js +396 -41
- package/dist/ssr/layout/Panes.js.map +1 -1
- package/dist/ssr/layout/index.js +1 -1
- package/dist/ssr/layout/index.js.map +1 -1
- package/dist/ssr/layout/panes-layout.js +169 -0
- package/dist/ssr/layout/panes-layout.js.map +1 -1
- package/dist/ssr/layout/panes-messages.js +108 -2
- package/dist/ssr/layout/panes-messages.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/actions/Dropdown.d.ts +4 -3
- package/dist/types/content/PdfPages.d.ts +8 -3
- package/dist/types/content/PdfViewer.d.ts +12 -4
- package/dist/types/layout/FloatingWindow.d.ts +6 -0
- package/dist/types/layout/Panes.d.ts +15 -0
- package/dist/types/layout/index.d.ts +2 -2
- package/dist/types/layout/panes-layout.d.ts +51 -0
- package/dist/types/layout/panes-messages.d.ts +55 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["content/PdfPages.tsx"],"sourcesContent":["import { batch, createEffect, createMemo, createSignal, For, type JSX, on, onCleanup, onMount, Show } from \"solid-js\";\nimport { Toolbar } from \"../actions/Toolbar\";\nimport { openPdfDocument, type PdfDocumentHandle, type PdfPageImage, type PdfPageSize, pageImageWidth } from \"./pdf-document\";\nimport { usePdfMessages } from \"./pdf-messages\";\n\n/** One extra icon at the end of the pill, such as open in a new tab or render again. */\nexport type PdfPagesAction = { label: string; icon: string; disabled?: boolean; onClick: () => void };\n\nexport type PdfPagesProps = {\n /** The PDF itself. A new value opens that document. */\n data: Blob | ArrayBuffer;\n /** The document's name, for the scroll area and the page images. */\n title: string;\n /** Without the zoom bar, always fitted. Defaults to `true`. */\n zoom?: boolean;\n /** With `zoom` false, a factor of the fitted width, for a host that zooms with its own controls. Defaults to 1. */\n scale?: number;\n /**\n * How a fitted document fills the area: `\"width\"` (the default) fits each page to the area's width, for reading;\n * `\"page\"` shows the whole first page in the area's height, narrower, for a preview beside other content.\n * Fitted pages never grow past 100 %.\n */\n fit?: \"width\" | \"page\";\n /** Shows only this page (zero-based) instead of all pages one below the other. */\n page?: number;\n /** The first visible page is drawn; a host can drop its loading state. */\n onReady?: (document: { pages: number }) => void;\n /** The document could not be opened, or a page could not be drawn and has no image yet. */\n onError?: (error: unknown) => void;\n /** The page in the middle of the view changed (zero-based), for a host that shows \"Page 2 / 4\" itself. */\n onPage?: (index: number) => void;\n /** Icons after the fit, in this order. */\n actions?: readonly PdfPagesAction[];\n};\n\n/** CSS pixels per PDF point at 100 %: 96 dpi on screen, 72 points per inch. */\nconst POINT = 96 / 72;\n/** Steps for − and + in percent; Ctrl or ⌘ with the wheel and two fingers zoom freely between the first and the last. */\nexport const PDF_ZOOM_STEPS = [25, 50, 75, 100, 125, 150, 200, 300] as const;\nconst SMALLEST = PDF_ZOOM_STEPS[0];\nconst LARGEST = PDF_ZOOM_STEPS[PDF_ZOOM_STEPS.length - 1] ?? 300;\n/** Horizontal padding of the page stack, both sides together. */\nconst INSET = 24;\n/** Vertical padding of the page stack, top and the room for the bar below together (`.k2b-pdf-viewer__stack`). */\nconst BLOCK_INSET = 12 + 56;\n/** Pages within this distance of the view draw; farther ones keep only their box. */\nconst NEAR_MARGIN = \"150% 0px\";\n/** At most this many drawn pages stay in memory; the ones out of view are released first. */\nconst KEPT_IMAGES = 24;\n\n/** The next zoom step above or below `percent`; at either end it stays there. */\nexport const nextPdfZoomStep = (percent: number, direction: 1 | -1): number =>\n direction === 1\n ? (PDF_ZOOM_STEPS.find((step) => step > percent + 0.5) ?? LARGEST)\n : ([...PDF_ZOOM_STEPS].reverse().find((step) => step < percent - 0.5) ?? SMALLEST);\n\n/**\n * The width in CSS pixels of a fitted page: as wide as the area, for `\"page\"` at most as wide as the whole page fits\n * into the area's height, and never past 100 %, so zooming the browser out does not make the page grow.\n */\nexport const fittedPageWidth = (\n fit: \"width\" | \"page\",\n area: { width: number; height: number },\n page: { width: number; height: number },\n): number => {\n const natural = page.width * POINT;\n const byHeight = fit === \"page\" ? (area.height * page.width) / Math.max(1, page.height) : Number.POSITIVE_INFINITY;\n return Math.max(1, Math.floor(Math.min(area.width, byHeight, natural)));\n};\n\n/**\n * The page width most pages share, at a tie the first page's. \"Width\" fits every page to the area, so a landscape page\n * among portrait ones never scrolls sideways; percentages and fixed zoom follow this common width.\n */\nexport const commonPageWidth = (pages: readonly PdfPageSize[]): number => {\n const counts = new Map<number, number>();\n for (const page of pages) counts.set(Math.round(page.width), (counts.get(Math.round(page.width)) ?? 0) + 1);\n let best = Math.round(pages[0]?.width ?? 1);\n let most = 0;\n for (const [width, count] of counts)\n if (count > most) {\n best = width;\n most = count;\n }\n return Math.max(1, best);\n};\n\n/**\n * The pages behind `PdfViewer`, loaded only once a document shows. A PDF drawn by pdf.js in every browser: pages as\n * images in one scroll area, an invisible text layer over each page to select, copy, and find text, and a small pill. Only pages near the view are drawn and carry text; the others\n * keep their size, so the scroll bar is right from the start. Printing and forms stay with the browser's own viewer.\n */\nexport default function PdfPages(props: PdfPagesProps): JSX.Element {\n const messages = usePdfMessages();\n const [doc, setDoc] = createSignal<PdfDocumentHandle | null>(null);\n const pages = (): readonly PdfPageSize[] => doc()?.pages ?? [];\n const shown = () =>\n props.page === undefined ? pages().map((_, index) => index) : [props.page].filter((index) => index < pages().length);\n const [images, setImages] = createSignal<ReadonlyMap<number, PdfPageImage>>(new Map());\n const [near, setNear] = createSignal<ReadonlySet<number>>(new Set());\n const [fitWidth, setFitWidth] = createSignal(true);\n const [fixed, setFixed] = createSignal(POINT);\n const [inner, setInner] = createSignal(0);\n const [innerHeight, setInnerHeight] = createSignal(0);\n const [current, setCurrent] = createSignal(0);\n createEffect(on(current, (index) => props.onPage?.(index)));\n const [ready, setReady] = createSignal(false);\n let area: HTMLDivElement | undefined;\n let drawRun: AbortController | undefined;\n let drawTimer: ReturnType<typeof setTimeout> | undefined;\n let gone = false;\n\n const releaseAll = () => {\n for (const image of images().values()) URL.revokeObjectURL(image.url);\n setImages(new Map());\n };\n\n // Opening: a new `data` opens a new document and closes the previous one.\n createEffect(\n on(\n () => props.data,\n (data) => {\n const opening = new AbortController();\n let opened: PdfDocumentHandle | null = null;\n onCleanup(() => {\n opening.abort();\n drawRun?.abort();\n releaseAll();\n void opened?.close();\n });\n setReady(false);\n void openPdfDocument(data, opening.signal).then(\n (handle) => {\n if (!handle || opening.signal.aborted) return void handle?.close();\n opened = handle;\n // A document without pages has nothing to draw; the host shows its fallback instead of waiting forever.\n if (handle.pages.length === 0) return void props.onError?.(new Error(\"The PDF has no pages\"));\n setDoc(handle);\n },\n (error: unknown) => {\n if (!opening.signal.aborted) props.onError?.(error);\n },\n );\n },\n ),\n );\n onCleanup(() => {\n gone = true;\n clearTimeout(drawTimer);\n });\n\n const commonWidth = createMemo(() => commonPageWidth(pages()));\n const fitMode = () => props.fit ?? \"width\";\n /** Every fitted page is this wide, so a landscape page among portrait ones never scrolls sideways. */\n const fittedWidth = () => {\n // The whole page that shows first, also with `page`, fits the area's real height, however short.\n const first = pages()[shown()[0] ?? 0] ?? { width: commonWidth(), height: commonWidth() };\n const height = first.height * (commonWidth() / first.width);\n return fittedPageWidth(\n fitMode(),\n { width: Math.max(120, inner()), height: Math.max(1, innerHeight()) },\n { width: commonWidth(), height },\n );\n };\n /** CSS pixels per point of the common page width; percent, steps, and fixed zoom follow from it. */\n /** A host that zooms with its own controls scales the fitted width; the viewer's own zoom then stays off. */\n const hostScale = () => (props.zoom === false ? (props.scale ?? 1) : 1);\n const factor = () => (fitWidth() ? (fittedWidth() * hostScale()) / commonWidth() : fixed());\n const percent = () => Math.round((factor() / POINT) * 100);\n const pageWidth = (page: PdfPageSize) =>\n fitWidth() ? Math.max(1, Math.floor(fittedWidth() * hostScale())) : Math.max(1, Math.floor(page.width * fixed()));\n\n /**\n * Draws each near page whose image is too small (blurred) or far too large (memory) for its shown size. A new zoom or\n * scroll aborts and continues. A page that fails keeps its old image; without one, `onError` reports it.\n */\n const redraw = async () => {\n drawRun?.abort();\n const run = new AbortController();\n drawRun = run;\n const handle = doc();\n if (!handle) return;\n const order = shown().filter((index) => near().has(index));\n for (const index of order) {\n const page = pages()[index];\n if (!page) continue;\n const target = pageImageWidth(pageWidth(page), window.devicePixelRatio, page.height / page.width);\n const existing = images().get(index);\n if (existing && target <= existing.width * 1.15 && target >= existing.width * 0.5) continue;\n const image = await handle.draw(index, target, run.signal).catch(() => \"failed\" as const);\n if (run.signal.aborted || gone || doc() !== handle) {\n if (image && image !== \"failed\") URL.revokeObjectURL(image.url);\n return;\n }\n if (image === \"failed\" || !image) {\n if (existing) continue;\n props.onError?.(new Error(`Page ${index + 1} could not be drawn`));\n return;\n }\n setImages((previous) => {\n const next = new Map(previous);\n next.set(index, image);\n // Keep memory bounded: release drawn pages out of view, oldest first, past the limit.\n for (const key of next.keys()) {\n if (next.size <= KEPT_IMAGES) break;\n if (near().has(key)) continue;\n const released = next.get(key);\n if (released) URL.revokeObjectURL(released.url);\n next.delete(key);\n }\n return next;\n });\n if (existing) URL.revokeObjectURL(existing.url);\n if (!ready()) {\n setReady(true);\n props.onReady?.({ pages: pages().length });\n }\n }\n };\n const scheduleRedraw = (delay: number) => {\n clearTimeout(drawTimer);\n drawTimer = setTimeout(() => void redraw(), delay);\n };\n createEffect(on(factor, () => scheduleRedraw(200), { defer: true }));\n createEffect(on(near, () => scheduleRedraw(0), { defer: true }));\n // A new document of the same shape keeps the page boxes and the near set, so it draws on its own.\n createEffect(on(doc, () => scheduleRedraw(0), { defer: true }));\n createEffect(\n on(\n () => props.page,\n () => {\n if (area) area.scrollTop = 0;\n scheduleRedraw(0);\n },\n { defer: true },\n ),\n );\n\n /**\n * Zooms to `target` (CSS pixels per point) around a point of the area (pointer, between the fingers, else the\n * centre) that stays where it is. The point counts relative to the page under it, because padding, gaps, and the\n * centring of narrow pages do not grow with the zoom.\n */\n const zoomTo = (target: number, clientX?: number, clientY?: number) => {\n if (props.zoom === false || !area) return;\n const before = factor();\n const next = (Math.min(LARGEST, Math.max(SMALLEST, (target / POINT) * 100)) / 100) * POINT;\n if (Math.abs(next - before) < 1e-4) return;\n const box = area.getBoundingClientRect();\n const x = clientX ?? box.left + area.clientWidth / 2;\n const y = clientY ?? box.top + area.clientHeight / 2;\n const boxes = [...area.querySelectorAll<HTMLElement>(\"[data-pdf-page]\")];\n const distance = (page: HTMLElement) => {\n const rect = page.getBoundingClientRect();\n return y < rect.top ? rect.top - y : y > rect.bottom ? y - rect.bottom : 0;\n };\n const anchor = boxes.reduce<HTMLElement | undefined>(\n (best, page) => (!best || distance(page) < distance(best) ? page : best),\n undefined,\n );\n const anchorBefore = anchor?.getBoundingClientRect();\n const relativeX = anchorBefore ? (x - anchorBefore.left) / anchorBefore.width : 0;\n const relativeY = anchorBefore ? (y - anchorBefore.top) / anchorBefore.height : 0;\n batch(() => {\n setFitWidth(false);\n setFixed(next);\n });\n if (!anchor) return;\n const anchorAfter = anchor.getBoundingClientRect();\n area.scrollLeft += anchorAfter.left + relativeX * anchorAfter.width - x;\n area.scrollTop += anchorAfter.top + relativeY * anchorAfter.height - y;\n };\n const step = (direction: 1 | -1) => zoomTo((nextPdfZoomStep(percent(), direction) / 100) * POINT);\n const fit = () => {\n if (!area || fitWidth()) return;\n const before = factor();\n const top = area.scrollTop;\n setFitWidth(true);\n area.scrollLeft = 0;\n area.scrollTop = (top * factor()) / before;\n };\n\n onMount(() => {\n if (!area) return;\n const scroller = area;\n const measureArea = () => {\n setInner(scroller.clientWidth - INSET);\n setInnerHeight(scroller.clientHeight - BLOCK_INSET);\n };\n measureArea();\n const resize = new ResizeObserver(measureArea);\n resize.observe(scroller);\n // Pages near the view draw and carry their text; the observer follows every page box as it appears. Without an\n // IntersectionObserver every page counts as near, as MapView does.\n const nearPages =\n typeof IntersectionObserver === \"undefined\"\n ? undefined\n : new IntersectionObserver(\n (entries) => {\n setNear((previous) => {\n const next = new Set(previous);\n for (const entry of entries) {\n const index = Number(entry.target.getAttribute(\"data-pdf-page\"));\n if (entry.isIntersecting) next.add(index);\n else next.delete(index);\n }\n return next;\n });\n },\n { root: scroller, rootMargin: NEAR_MARGIN },\n );\n if (!nearPages) createEffect(() => setNear(new Set(shown())));\n // Page boxes come and go with the document and `page`: new ones are observed, removed ones released, so a detached\n // page and its image are never kept alive.\n const observed = new Set<HTMLElement>();\n const watched = new MutationObserver(() => {\n for (const page of observed)\n if (!page.isConnected) {\n nearPages?.unobserve(page);\n observed.delete(page);\n }\n for (const page of scroller.querySelectorAll<HTMLElement>(\"[data-pdf-page]\")) {\n if (observed.has(page)) continue;\n observed.add(page);\n nearPages?.observe(page);\n }\n });\n watched.observe(scroller, { childList: true, subtree: true });\n // The page in the middle of the view is the current one.\n let frame = 0;\n const track = () => {\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(() => {\n const middle = scroller.getBoundingClientRect().top + scroller.clientHeight / 2;\n for (const page of scroller.querySelectorAll<HTMLElement>(\"[data-pdf-page]\")) {\n const rect = page.getBoundingClientRect();\n if (rect.bottom >= middle) {\n setCurrent(Number(page.dataset.pdfPage));\n break;\n }\n }\n });\n };\n // Ctrl or ⌘ with the wheel; a trackpad pinch sends the same with Ctrl. Without a key the wheel scrolls as always.\n const wheel = (event: WheelEvent) => {\n if (!(event.ctrlKey || event.metaKey)) return;\n event.preventDefault();\n const delta = Math.max(-120, Math.min(120, event.deltaMode === 1 ? event.deltaY * 16 : event.deltaY));\n zoomTo(factor() * Math.exp(-delta * 0.002), event.clientX, event.clientY);\n };\n // Two fingers on touch; `touch-action: pan-x pan-y` leaves scrolling to the browser but keeps page zoom out.\n let pinch: { distance: number; factor: number } | null = null;\n const spread = (touches: TouchList) => {\n const [a, b] = [touches[0], touches[1]];\n return a && b ? Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY) : 0;\n };\n const touchStart = (event: TouchEvent) => {\n if (event.touches.length === 2) pinch = { distance: spread(event.touches) || 1, factor: factor() };\n };\n const touchMove = (event: TouchEvent) => {\n const [a, b] = [event.touches[0], event.touches[1]];\n if (!pinch || !a || !b) return;\n event.preventDefault();\n zoomTo((pinch.factor * spread(event.touches)) / pinch.distance, (a.clientX + b.clientX) / 2, (a.clientY + b.clientY) / 2);\n };\n const touchEnd = (event: TouchEvent) => {\n if (event.touches.length < 2) pinch = null;\n };\n // Safari on a Mac reports a trackpad pinch as its own gesture (`scale`), not as a wheel.\n let gestureStart = 0;\n const gestureBegin = (event: Event) => {\n if (pinch) return;\n event.preventDefault();\n gestureStart = factor();\n };\n const gestureChange = (event: Event) => {\n const scale: unknown = Reflect.get(event, \"scale\");\n if (pinch || !gestureStart || typeof scale !== \"number\") return;\n event.preventDefault();\n const x: unknown = Reflect.get(event, \"clientX\");\n const y: unknown = Reflect.get(event, \"clientY\");\n zoomTo(gestureStart * scale, typeof x === \"number\" ? x : undefined, typeof y === \"number\" ? y : undefined);\n };\n const gestureEnd = () => {\n gestureStart = 0;\n };\n // A selection does not jump across gaps while the layer knows a drag is selecting (its end marker then fills it).\n const selectEnd = () => {\n for (const layer of scroller.querySelectorAll(\".k2b-pdf-viewer__text[data-selecting]\")) layer.removeAttribute(\"data-selecting\");\n };\n scroller.addEventListener(\"scroll\", track, { passive: true });\n scroller.addEventListener(\"wheel\", wheel, { passive: false });\n scroller.addEventListener(\"touchstart\", touchStart, { passive: true });\n scroller.addEventListener(\"touchmove\", touchMove, { passive: false });\n scroller.addEventListener(\"touchend\", touchEnd);\n scroller.addEventListener(\"touchcancel\", touchEnd);\n scroller.addEventListener(\"gesturestart\", gestureBegin);\n scroller.addEventListener(\"gesturechange\", gestureChange);\n scroller.addEventListener(\"gestureend\", gestureEnd);\n window.addEventListener(\"pointerup\", selectEnd);\n onCleanup(() => {\n cancelAnimationFrame(frame);\n resize.disconnect();\n nearPages?.disconnect();\n watched.disconnect();\n scroller.removeEventListener(\"scroll\", track);\n scroller.removeEventListener(\"wheel\", wheel);\n scroller.removeEventListener(\"touchstart\", touchStart);\n scroller.removeEventListener(\"touchmove\", touchMove);\n scroller.removeEventListener(\"touchend\", touchEnd);\n scroller.removeEventListener(\"touchcancel\", touchEnd);\n scroller.removeEventListener(\"gesturestart\", gestureBegin);\n scroller.removeEventListener(\"gesturechange\", gestureChange);\n scroller.removeEventListener(\"gestureend\", gestureEnd);\n window.removeEventListener(\"pointerup\", selectEnd);\n });\n });\n\n return (\n // Out of keyboard reach until the first page is drawn, so focus never lands on a viewer still being prepared.\n <div class=\"k2b-pdf-viewer__document\" data-drawn={ready() ? \"\" : undefined} inert={!ready()}>\n {/* One scroll area: fitted to the width it scrolls only down, zoomed the same area also scrolls sideways. */}\n <div\n ref={area}\n class=\"k2b-pdf-viewer__pages\"\n data-fit={fitWidth() ? \"\" : undefined}\n data-zoom={percent()}\n tabIndex={0}\n role=\"document\"\n aria-label={props.title}\n >\n <div class=\"k2b-pdf-viewer__stack\">\n <For each={shown()}>\n {(index) => {\n const page = () => pages()[index] ?? { width: 1, height: 1 };\n const width = () => pageWidth(page());\n const image = () => images().get(index);\n return (\n <div\n class=\"k2b-pdf-viewer__page\"\n data-pdf-page={index}\n style={{\n width: `${width()}px`,\n \"aspect-ratio\": `${page().width} / ${page().height}`,\n \"--total-scale-factor\": String(width() / page().width),\n }}\n >\n <Show when={image()}>\n {(drawn) => (\n <img\n src={drawn().url}\n width={drawn().width}\n height={drawn().height}\n draggable={false}\n alt={`${props.title}: ${messages().pdfPage({ number: index + 1, total: pages().length })}`}\n />\n )}\n </Show>\n <Show when={near().has(index) && doc()} keyed>\n {(handle) => <PdfTextLayer document={handle} index={index} />}\n </Show>\n </div>\n );\n }}\n </For>\n </div>\n </div>\n {/* The pill: page and zoom unless `zoom` is false, then the host's actions, which stay without zoom. */}\n <Show when={doc() && (props.zoom !== false || (props.actions?.length ?? 0) > 0)}>\n <div class=\"k2b-pdf-viewer__bar\">\n <Toolbar label={messages().pdfZoom}>\n <Show when={props.zoom !== false}>\n <Show when={props.page === undefined && pages().length > 1}>\n <Toolbar.Label class=\"k2b-pdf-viewer__page-number\">\n <span class=\"k2b-sr-only\">{messages().pdfPage({ number: current() + 1, total: pages().length })}</span>\n <span aria-hidden=\"true\">{messages().pdfPageShort({ number: current() + 1, total: pages().length })}</span>\n </Toolbar.Label>\n <Toolbar.Separator />\n </Show>\n <Toolbar.Action label={messages().pdfZoomOut} icon=\"ti ti-minus\" disabled={percent() <= SMALLEST} onClick={() => step(-1)} />\n <Toolbar.Label class=\"k2b-pdf-viewer__percent\">\n <span aria-live=\"polite\">{messages().pdfZoomPercent({ value: percent() })}</span>\n </Toolbar.Label>\n <Toolbar.Action label={messages().pdfZoomIn} icon=\"ti ti-plus\" disabled={percent() >= LARGEST} onClick={() => step(1)} />\n <Toolbar.Separator />\n {/* Icons only; the pressed state is the blue icon without a fill. */}\n <Toolbar.Action\n label={fitMode() === \"page\" ? messages().pdfFitPageLabel : messages().pdfFitWidthLabel}\n icon={fitMode() === \"page\" ? \"ti ti-arrows-vertical\" : \"ti ti-arrows-horizontal\"}\n pressed={fitWidth()}\n onClick={fit}\n />\n </Show>\n <For each={props.actions ?? []}>\n {(action) => <Toolbar.Action label={action.label} icon={action.icon} disabled={action.disabled} onClick={action.onClick} />}\n </For>\n </Toolbar>\n </div>\n </Show>\n </div>\n );\n}\n\n/** One page's text layer; pdf.js builds it once, and zoom changes only `--total-scale-factor` on the page. */\nfunction PdfTextLayer(props: { document: PdfDocumentHandle; index: number }): JSX.Element {\n let layer: HTMLDivElement | undefined;\n onMount(() => {\n if (!layer) return;\n const container = layer;\n const abort = new AbortController();\n onCleanup(() => abort.abort());\n void props.document.textLayer(props.index, container, abort.signal).then(\n () => {\n if (abort.signal.aborted) return;\n const end = document.createElement(\"div\");\n end.className = \"k2b-pdf-viewer__text-end\";\n container.append(end);\n },\n () => undefined,\n );\n });\n return <div ref={layer} class=\"k2b-pdf-viewer__text\" onPointerDown={() => layer?.setAttribute(\"data-selecting\", \"\")} />;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,EAAY,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,QAAQ,UAAU;AACrH,SAAS,OAAO,QAAQ,oBAAoB;AAC5C,SAAS,eAAe,EAA+D,cAAc,QAAQ,gBAAgB;AAC7H,SAAS,cAAc,QAAQ,gBAAgB;;AAE/C;;AA8BA;AACA,MAAM,KAAK,GAAG,EAAE,GAAG,EAAE;AACrB;AAC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Gf,GAAG;cAAA,IAAC,IAAI;gBAAA,OAAE,KAAK,CAAC,OAAO,IAAI,EAAE;cAAA;cAAA,UAC1B,MAAM,sBAAM,OAAO,CAAC,MAAM;gBAAA,IAAC,KAAK;kBAAA,OAAE,MAAM,CAAC,KAAK;gBAAA;gBAAA,IAAE,IAAI;kBAAA,OAAE,MAAM,CAAC,IAAI;gBAAA;gBAAA,IAAE,QAAQ;kBAAA,OAAE,MAAM,CAAC,QAAQ;gBAAA;gBAAA,IAAE,OAAO;kBAAA,OAAE,MAAM,CAAC,OAAO;gBAAA;cAAA;YAAI;UAAA;QAAA;MAAA;IAAA;EAAA;AAOzI;;AAEA;AACA,SAAS,YAAY,CAAC,KAAqD,EAAe;EACxF,IAAI,KAAiC;EACrC,OAAO,CAAC,MAAM;IACZ,IAAI,CAAC,KAAK,EAAE;IACZ,MAAM,SAAS,GAAG,KAAK;IACvB,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,CAAC;IACnC,SAAS,CAAC,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9B,KAAK,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CACtE,MAAM;MACJ,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE;MAC1B,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;MACzC,GAAG,CAAC,SAAS,GAAG,0BAA0B;MAC1C,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;IACvB,CAAC,EACD,MAAM,SACR,CAAC;EACH,CAAC,CAAC;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["content/PdfPages.tsx"],"sourcesContent":["import { batch, createEffect, createMemo, createSignal, For, type JSX, on, onCleanup, onMount, Show, untrack } from \"solid-js\";\nimport { Toolbar } from \"../actions/Toolbar\";\nimport { openPdfDocument, type PdfDocumentHandle, type PdfPageImage, type PdfPageSize, pageImageWidth } from \"./pdf-document\";\nimport { usePdfMessages } from \"./pdf-messages\";\n\n/** One extra icon at the end of the pill, such as open in a new tab or render again. */\nexport type PdfPagesAction = { label: string; icon: string; disabled?: boolean; onClick: () => void };\n\nexport type PdfPagesProps = {\n /** The PDF itself. A new value opens that document. */\n data: Blob | ArrayBuffer;\n /** The document's name, for the scroll area and the page images. */\n title: string;\n /** Without the zoom bar, always fitted. Defaults to `true`. */\n zoom?: boolean;\n /** With `zoom` false, a factor of the fitted width, for a host that zooms with its own controls. Defaults to 1. */\n scale?: number;\n /**\n * How a fitted document fills the area: `\"width\"` (the default) fits each page to the area's width, for reading;\n * `\"page\"` shows the whole first page in the area's height, narrower, for a preview beside other content.\n * Fitted pages never grow past 100 %.\n */\n fit?: \"width\" | \"page\";\n /** Shows only this page (zero-based) instead of all pages one below the other. */\n page?: number;\n /**\n * The first visible page of a document is drawn; a host can drop its loading state. A new `data` calls it again once\n * its pages have replaced the previous document's.\n */\n onReady?: (document: { pages: number }) => void;\n /** The document could not be opened, or a page could not be drawn and has no image yet. */\n onError?: (error: unknown) => void;\n /** The page in the middle of the view changed (zero-based), for a host that shows \"Page 2 / 4\" itself. */\n onPage?: (index: number) => void;\n /** Icons after the fit, in this order. */\n actions?: readonly PdfPagesAction[];\n};\n\n/** CSS pixels per PDF point at 100 %: 96 dpi on screen, 72 points per inch. */\nconst POINT = 96 / 72;\n/** Steps for − and + in percent; Ctrl or ⌘ with the wheel and two fingers zoom freely between the first and the last. */\nexport const PDF_ZOOM_STEPS = [25, 50, 75, 100, 125, 150, 200, 300] as const;\nconst SMALLEST = PDF_ZOOM_STEPS[0];\nconst LARGEST = PDF_ZOOM_STEPS[PDF_ZOOM_STEPS.length - 1] ?? 300;\n/** Horizontal padding of the page stack, both sides together. */\nconst INSET = 24;\n/** Vertical padding of the page stack, top and the room for the bar below together (`.k2b-pdf-viewer__stack`). */\nconst BLOCK_INSET = 12 + 56;\n/** Pages within this distance of the view draw; farther ones keep only their box. */\nconst NEAR_MARGIN = \"150% 0px\";\n/** At most this many drawn pages stay in memory; the ones out of view are released first. */\nconst KEPT_IMAGES = 24;\n/** The longest a page waits for an idle moment before its text layer is built anyway. */\nconst IDLE_TEXT_MS = 200;\n\n/** The next zoom step above or below `percent`; at either end it stays there. */\nexport const nextPdfZoomStep = (percent: number, direction: 1 | -1): number =>\n direction === 1\n ? (PDF_ZOOM_STEPS.find((step) => step > percent + 0.5) ?? LARGEST)\n : ([...PDF_ZOOM_STEPS].reverse().find((step) => step < percent - 0.5) ?? SMALLEST);\n\n/**\n * The width in CSS pixels of a fitted page: as wide as the area, for `\"page\"` at most as wide as the whole page fits\n * into the area's height, and never past 100 %, so zooming the browser out does not make the page grow.\n */\nexport const fittedPageWidth = (\n fit: \"width\" | \"page\",\n area: { width: number; height: number },\n page: { width: number; height: number },\n): number => {\n const natural = page.width * POINT;\n const byHeight = fit === \"page\" ? (area.height * page.width) / Math.max(1, page.height) : Number.POSITIVE_INFINITY;\n return Math.max(1, Math.floor(Math.min(area.width, byHeight, natural)));\n};\n\n/**\n * The page width most pages share, at a tie the first page's. \"Width\" fits every page to the area, so a landscape page\n * among portrait ones never scrolls sideways; percentages and fixed zoom follow this common width.\n */\nexport const commonPageWidth = (pages: readonly PdfPageSize[]): number => {\n const counts = new Map<number, number>();\n for (const page of pages) counts.set(Math.round(page.width), (counts.get(Math.round(page.width)) ?? 0) + 1);\n let best = Math.round(pages[0]?.width ?? 1);\n let most = 0;\n for (const [width, count] of counts)\n if (count > most) {\n best = width;\n most = count;\n }\n return Math.max(1, best);\n};\n\n/**\n * The pages behind `PdfViewer`, loaded only once a document shows. A PDF drawn by pdf.js in every browser: pages as\n * images in one scroll area, an invisible text layer over each page to select, copy, and find text, and a small pill.\n * Only pages near the view are drawn; the others keep their size, so the scroll bar is right from the start. Every page\n * gets its text, near pages first, so the browser's find reaches the whole document. Printing and forms stay with the\n * browser's own viewer.\n */\nexport default function PdfPages(props: PdfPagesProps): JSX.Element {\n const messages = usePdfMessages();\n const [doc, setDoc] = createSignal<PdfDocumentHandle | null>(null);\n const pages = (): readonly PdfPageSize[] => doc()?.pages ?? [];\n const shown = () =>\n props.page === undefined ? pages().map((_, index) => index) : [props.page].filter((index) => index < pages().length);\n const [images, setImages] = createSignal<ReadonlyMap<number, PdfPageImage>>(new Map());\n const [near, setNear] = createSignal<ReadonlySet<number>>(new Set());\n const [fitWidth, setFitWidth] = createSignal(true);\n const [fixed, setFixed] = createSignal(POINT);\n const [inner, setInner] = createSignal(0);\n const [innerHeight, setInnerHeight] = createSignal(0);\n const [current, setCurrent] = createSignal(0);\n createEffect(on(current, (index) => props.onPage?.(index)));\n const [ready, setReady] = createSignal(false);\n // Pages with a text layer. Near pages get theirs at once; once the first page is drawn, the others follow one after\n // another while the browser is idle, so its find reaches the whole document. A layer, once built, stays; together they\n // hold the document's own text, which `PDF_LIMITS` bounds.\n const [texted, setTexted] = createSignal<ReadonlySet<number>>(new Set());\n createEffect(on(near, (pagesNear) => setTexted((previous) => new Set([...previous, ...pagesNear])), { defer: true }));\n let idleText: (() => void) | undefined;\n /** Adds the next page without text, unless one is already waiting; each settled layer asks for the next. */\n const textNext = () => {\n if (idleText || !ready() || gone) return;\n const next = shown().find((index) => !texted().has(index));\n if (next === undefined) return;\n const add = () => {\n idleText = undefined;\n if (gone) return;\n // Came near meanwhile: its layer is already on its way, so go on with the next page.\n if (texted().has(next)) return textNext();\n setTexted((previous) => new Set(previous).add(next));\n };\n if (typeof requestIdleCallback === \"function\") {\n const handle = requestIdleCallback(add, { timeout: IDLE_TEXT_MS });\n idleText = () => cancelIdleCallback(handle);\n } else {\n // Without idle callbacks (Safari), yielding one task lets input and drawing go first.\n const handle = setTimeout(add, 0);\n idleText = () => clearTimeout(handle);\n }\n };\n createEffect(on([ready, doc], () => textNext()));\n let area: HTMLDivElement | undefined;\n let drawRun: AbortController | undefined;\n let drawTimer: ReturnType<typeof setTimeout> | undefined;\n let gone = false;\n // The name the shown document opened under.\n let shownTitle = untrack(() => props.title);\n\n const release = (map: ReadonlyMap<number, PdfPageImage>) => {\n for (const image of map.values()) URL.revokeObjectURL(image.url);\n };\n const indicesOf = (list: readonly PdfPageSize[]) =>\n props.page === undefined ? list.map((_, index) => index) : [props.page].filter((index) => index < list.length);\n\n const commonWidth = createMemo(() => commonPageWidth(pages()));\n const fitMode = () => props.fit ?? \"width\";\n /** Every fitted page of `list` is this wide, so a landscape page among portrait ones never scrolls sideways. */\n const fittedWidthOf = (list: readonly PdfPageSize[], common: number) => {\n // The whole page that shows first, also with `page`, fits the area's real height, however short.\n const first = list[indicesOf(list)[0] ?? 0] ?? { width: common, height: common };\n const height = first.height * (common / first.width);\n return fittedPageWidth(fitMode(), { width: Math.max(120, inner()), height: Math.max(1, innerHeight()) }, { width: common, height });\n };\n const fittedWidth = createMemo(() => fittedWidthOf(pages(), commonWidth()));\n /** CSS pixels per point of the common page width; percent, steps, and fixed zoom follow from it. */\n /** A host that zooms with its own controls scales the fitted width; the viewer's own zoom then stays off. */\n const hostScale = () => (props.zoom === false ? (props.scale ?? 1) : 1);\n const factor = () => (fitWidth() ? (fittedWidth() * hostScale()) / commonWidth() : fixed());\n const percent = () => Math.round((factor() / POINT) * 100);\n const widthAt = (fitted: number, page: PdfPageSize) =>\n fitWidth() ? Math.max(1, Math.floor(fitted * hostScale())) : Math.max(1, Math.floor(page.width * fixed()));\n const pageWidth = (page: PdfPageSize) => widthAt(fittedWidth(), page);\n\n /**\n * Draws the pages of a new document that will show first: with the same pages as the shown one, the drawn pages\n * near the view, else the first page. `null` after an abort or when the first of them cannot be drawn.\n */\n const prepare = async (handle: PdfDocumentHandle, same: boolean, signal: AbortSignal) => {\n const list = handle.pages;\n const indices = indicesOf(list);\n const nearShown = same ? indices.filter((index) => near().has(index)) : [];\n const targets = nearShown.length > 0 ? nearShown : indices.slice(0, 1);\n const fitted = fittedWidthOf(list, commonPageWidth(list));\n const drawn = new Map<number, PdfPageImage>();\n for (const index of targets) {\n const page = list[index];\n if (!page) continue;\n const target = pageImageWidth(widthAt(fitted, page), window.devicePixelRatio, page.height / page.width);\n const image = await handle.draw(index, target, signal).catch(() => \"failed\" as const);\n if (signal.aborted || gone) {\n if (image && image !== \"failed\") URL.revokeObjectURL(image.url);\n release(drawn);\n return null;\n }\n if (image === \"failed\" || !image) {\n // A later page draws again once it is near; without the first one, nothing of the new document could show.\n if (drawn.size > 0) continue;\n props.onError?.(new Error(`Page ${index + 1} could not be drawn`));\n return null;\n }\n drawn.set(index, image);\n }\n return drawn;\n };\n\n /**\n * Opening: a new `data` opens a new document. The shown one keeps its pages, zoom, and scroll position until the new\n * document's first pages are drawn, then both change in one step. A newer `data` stops a document still opening.\n */\n createEffect(\n on(\n () => props.data,\n (data) => {\n const opening = new AbortController();\n // Aborting destroys the document, so it stops only a document still opening, never the shown one.\n let adopted = false;\n onCleanup(() => {\n if (!adopted) opening.abort();\n });\n const title = untrack(() => props.title);\n void openPdfDocument(data, opening.signal).then(\n async (handle) => {\n if (!handle || opening.signal.aborted) return void handle?.close();\n // A document without pages has nothing to draw; the host shows its fallback instead of waiting forever.\n if (handle.pages.length === 0) {\n void handle.close();\n return void props.onError?.(new Error(\"The PDF has no pages\"));\n }\n const previous = doc();\n if (!previous) {\n adopted = true;\n shownTitle = title;\n return void setDoc(handle);\n }\n // The same pages under the same name, such as a regenerated report, keep the scroll position.\n const same =\n title === shownTitle &&\n handle.pages.length === previous.pages.length &&\n handle.pages.every(\n (page, index) =>\n Math.round(page.width) === Math.round(previous.pages[index]?.width ?? -1) &&\n Math.round(page.height) === Math.round(previous.pages[index]?.height ?? -1),\n );\n const drawn = await prepare(handle, same, opening.signal);\n if (!drawn || opening.signal.aborted || gone) {\n if (drawn) release(drawn);\n return void handle.close();\n }\n adopted = true;\n drawRun?.abort();\n const replaced = images();\n // The new document's text starts again from the pages near the view, in the same step as its pages.\n batch(() => {\n setDoc(handle);\n setImages(drawn);\n setTexted(new Set(near()));\n });\n shownTitle = title;\n release(replaced);\n void previous.close();\n if (!same && area) {\n area.scrollTop = 0;\n area.scrollLeft = 0;\n }\n setReady(true);\n props.onReady?.({ pages: handle.pages.length });\n },\n (error: unknown) => {\n if (!opening.signal.aborted) props.onError?.(error);\n },\n );\n },\n ),\n );\n onCleanup(() => {\n gone = true;\n idleText?.();\n clearTimeout(drawTimer);\n drawRun?.abort();\n release(images());\n void doc()?.close();\n });\n\n /**\n * Draws each near page whose image is too small (blurred) or far too large (memory) for its shown size. A new zoom or\n * scroll aborts and continues. A page that fails keeps its old image; without one, `onError` reports it.\n */\n const redraw = async () => {\n drawRun?.abort();\n const run = new AbortController();\n drawRun = run;\n const handle = doc();\n if (!handle) return;\n const order = shown().filter((index) => near().has(index));\n for (const index of order) {\n const page = pages()[index];\n if (!page) continue;\n const target = pageImageWidth(pageWidth(page), window.devicePixelRatio, page.height / page.width);\n const existing = images().get(index);\n if (existing && target <= existing.width * 1.15 && target >= existing.width * 0.5) continue;\n const image = await handle.draw(index, target, run.signal).catch(() => \"failed\" as const);\n if (run.signal.aborted || gone || doc() !== handle) {\n if (image && image !== \"failed\") URL.revokeObjectURL(image.url);\n return;\n }\n if (image === \"failed\" || !image) {\n if (existing) continue;\n props.onError?.(new Error(`Page ${index + 1} could not be drawn`));\n return;\n }\n setImages((previous) => {\n const next = new Map(previous);\n next.set(index, image);\n // Keep memory bounded: release drawn pages out of view, oldest first, past the limit.\n for (const key of next.keys()) {\n if (next.size <= KEPT_IMAGES) break;\n if (near().has(key)) continue;\n const released = next.get(key);\n if (released) URL.revokeObjectURL(released.url);\n next.delete(key);\n }\n return next;\n });\n if (existing) URL.revokeObjectURL(existing.url);\n if (!ready()) {\n setReady(true);\n props.onReady?.({ pages: pages().length });\n }\n }\n };\n const scheduleRedraw = (delay: number) => {\n clearTimeout(drawTimer);\n drawTimer = setTimeout(() => void redraw(), delay);\n };\n createEffect(on(factor, () => scheduleRedraw(200), { defer: true }));\n createEffect(on(near, () => scheduleRedraw(0), { defer: true }));\n // A new document of the same shape keeps the page boxes and the near set, so it draws on its own.\n createEffect(on(doc, () => scheduleRedraw(0), { defer: true }));\n createEffect(\n on(\n () => props.page,\n () => {\n if (area) area.scrollTop = 0;\n scheduleRedraw(0);\n },\n { defer: true },\n ),\n );\n\n /**\n * Zooms to `target` (CSS pixels per point) around a point of the area (pointer, between the fingers, else the\n * centre) that stays where it is. The point counts relative to the page under it, because padding, gaps, and the\n * centring of narrow pages do not grow with the zoom.\n */\n const zoomTo = (target: number, clientX?: number, clientY?: number) => {\n if (props.zoom === false || !area) return;\n const before = factor();\n const next = (Math.min(LARGEST, Math.max(SMALLEST, (target / POINT) * 100)) / 100) * POINT;\n if (Math.abs(next - before) < 1e-4) return;\n const box = area.getBoundingClientRect();\n const x = clientX ?? box.left + area.clientWidth / 2;\n const y = clientY ?? box.top + area.clientHeight / 2;\n const boxes = [...area.querySelectorAll<HTMLElement>(\"[data-pdf-page]\")];\n const distance = (page: HTMLElement) => {\n const rect = page.getBoundingClientRect();\n return y < rect.top ? rect.top - y : y > rect.bottom ? y - rect.bottom : 0;\n };\n const anchor = boxes.reduce<HTMLElement | undefined>(\n (best, page) => (!best || distance(page) < distance(best) ? page : best),\n undefined,\n );\n const anchorBefore = anchor?.getBoundingClientRect();\n const relativeX = anchorBefore ? (x - anchorBefore.left) / anchorBefore.width : 0;\n const relativeY = anchorBefore ? (y - anchorBefore.top) / anchorBefore.height : 0;\n batch(() => {\n setFitWidth(false);\n setFixed(next);\n });\n if (!anchor) return;\n const anchorAfter = anchor.getBoundingClientRect();\n area.scrollLeft += anchorAfter.left + relativeX * anchorAfter.width - x;\n area.scrollTop += anchorAfter.top + relativeY * anchorAfter.height - y;\n };\n const step = (direction: 1 | -1) => zoomTo((nextPdfZoomStep(percent(), direction) / 100) * POINT);\n const fit = () => {\n if (!area || fitWidth()) return;\n const before = factor();\n const top = area.scrollTop;\n setFitWidth(true);\n area.scrollLeft = 0;\n area.scrollTop = (top * factor()) / before;\n };\n\n onMount(() => {\n if (!area) return;\n const scroller = area;\n const measureArea = () => {\n setInner(scroller.clientWidth - INSET);\n setInnerHeight(scroller.clientHeight - BLOCK_INSET);\n };\n measureArea();\n const resize = new ResizeObserver(measureArea);\n resize.observe(scroller);\n // Pages near the view draw and get their text first; the observer follows every page box as it appears. Without an\n // IntersectionObserver every page counts as near, as MapView does.\n const nearPages =\n typeof IntersectionObserver === \"undefined\"\n ? undefined\n : new IntersectionObserver(\n (entries) => {\n setNear((previous) => {\n const next = new Set(previous);\n for (const entry of entries) {\n const index = Number(entry.target.getAttribute(\"data-pdf-page\"));\n if (entry.isIntersecting) next.add(index);\n else next.delete(index);\n }\n return next;\n });\n },\n { root: scroller, rootMargin: NEAR_MARGIN },\n );\n if (!nearPages) createEffect(() => setNear(new Set(shown())));\n // Page boxes come and go with the document and `page`: new ones are observed, removed ones released, so a detached\n // page and its image are never kept alive.\n const observed = new Set<HTMLElement>();\n const watched = new MutationObserver(() => {\n for (const page of observed)\n if (!page.isConnected) {\n nearPages?.unobserve(page);\n observed.delete(page);\n }\n for (const page of scroller.querySelectorAll<HTMLElement>(\"[data-pdf-page]\")) {\n if (observed.has(page)) continue;\n observed.add(page);\n nearPages?.observe(page);\n }\n });\n watched.observe(scroller, { childList: true, subtree: true });\n // The page in the middle of the view is the current one.\n let frame = 0;\n const track = () => {\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(() => {\n const middle = scroller.getBoundingClientRect().top + scroller.clientHeight / 2;\n for (const page of scroller.querySelectorAll<HTMLElement>(\"[data-pdf-page]\")) {\n const rect = page.getBoundingClientRect();\n if (rect.bottom >= middle) {\n setCurrent(Number(page.dataset.pdfPage));\n break;\n }\n }\n });\n };\n // Ctrl or ⌘ with the wheel; a trackpad pinch sends the same with Ctrl. Without a key the wheel scrolls as always.\n const wheel = (event: WheelEvent) => {\n if (!(event.ctrlKey || event.metaKey)) return;\n event.preventDefault();\n const delta = Math.max(-120, Math.min(120, event.deltaMode === 1 ? event.deltaY * 16 : event.deltaY));\n zoomTo(factor() * Math.exp(-delta * 0.002), event.clientX, event.clientY);\n };\n // Two fingers on touch; `touch-action: pan-x pan-y` leaves scrolling to the browser but keeps page zoom out.\n let pinch: { distance: number; factor: number } | null = null;\n const spread = (touches: TouchList) => {\n const [a, b] = [touches[0], touches[1]];\n return a && b ? Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY) : 0;\n };\n const touchStart = (event: TouchEvent) => {\n if (event.touches.length === 2) pinch = { distance: spread(event.touches) || 1, factor: factor() };\n };\n const touchMove = (event: TouchEvent) => {\n const [a, b] = [event.touches[0], event.touches[1]];\n if (!pinch || !a || !b) return;\n event.preventDefault();\n zoomTo((pinch.factor * spread(event.touches)) / pinch.distance, (a.clientX + b.clientX) / 2, (a.clientY + b.clientY) / 2);\n };\n const touchEnd = (event: TouchEvent) => {\n if (event.touches.length < 2) pinch = null;\n };\n // Safari on a Mac reports a trackpad pinch as its own gesture (`scale`), not as a wheel.\n let gestureStart = 0;\n const gestureBegin = (event: Event) => {\n if (pinch) return;\n event.preventDefault();\n gestureStart = factor();\n };\n const gestureChange = (event: Event) => {\n const scale: unknown = Reflect.get(event, \"scale\");\n if (pinch || !gestureStart || typeof scale !== \"number\") return;\n event.preventDefault();\n const x: unknown = Reflect.get(event, \"clientX\");\n const y: unknown = Reflect.get(event, \"clientY\");\n zoomTo(gestureStart * scale, typeof x === \"number\" ? x : undefined, typeof y === \"number\" ? y : undefined);\n };\n const gestureEnd = () => {\n gestureStart = 0;\n };\n // A selection does not jump across gaps while the layer knows a drag is selecting (its end marker then fills it).\n const selectEnd = () => {\n for (const layer of scroller.querySelectorAll(\".k2b-pdf-viewer__text[data-selecting]\")) layer.removeAttribute(\"data-selecting\");\n };\n scroller.addEventListener(\"scroll\", track, { passive: true });\n scroller.addEventListener(\"wheel\", wheel, { passive: false });\n scroller.addEventListener(\"touchstart\", touchStart, { passive: true });\n scroller.addEventListener(\"touchmove\", touchMove, { passive: false });\n scroller.addEventListener(\"touchend\", touchEnd);\n scroller.addEventListener(\"touchcancel\", touchEnd);\n scroller.addEventListener(\"gesturestart\", gestureBegin);\n scroller.addEventListener(\"gesturechange\", gestureChange);\n scroller.addEventListener(\"gestureend\", gestureEnd);\n window.addEventListener(\"pointerup\", selectEnd);\n onCleanup(() => {\n cancelAnimationFrame(frame);\n resize.disconnect();\n nearPages?.disconnect();\n watched.disconnect();\n scroller.removeEventListener(\"scroll\", track);\n scroller.removeEventListener(\"wheel\", wheel);\n scroller.removeEventListener(\"touchstart\", touchStart);\n scroller.removeEventListener(\"touchmove\", touchMove);\n scroller.removeEventListener(\"touchend\", touchEnd);\n scroller.removeEventListener(\"touchcancel\", touchEnd);\n scroller.removeEventListener(\"gesturestart\", gestureBegin);\n scroller.removeEventListener(\"gesturechange\", gestureChange);\n scroller.removeEventListener(\"gestureend\", gestureEnd);\n window.removeEventListener(\"pointerup\", selectEnd);\n });\n });\n\n return (\n // Out of keyboard reach until the first page is drawn, so focus never lands on a viewer still being prepared.\n <div class=\"k2b-pdf-viewer__document\" data-drawn={ready() ? \"\" : undefined} inert={!ready()}>\n {/* One scroll area: fitted to the width it scrolls only down, zoomed the same area also scrolls sideways. */}\n <div\n ref={area}\n class=\"k2b-pdf-viewer__pages\"\n data-fit={fitWidth() ? \"\" : undefined}\n data-zoom={percent()}\n tabIndex={0}\n role=\"document\"\n aria-label={props.title}\n >\n <div class=\"k2b-pdf-viewer__stack\">\n <For each={shown()}>\n {(index) => {\n const page = () => pages()[index] ?? { width: 1, height: 1 };\n const width = () => pageWidth(page());\n const image = () => images().get(index);\n return (\n <div\n class=\"k2b-pdf-viewer__page\"\n data-pdf-page={index}\n style={{\n width: `${width()}px`,\n \"aspect-ratio\": `${page().width} / ${page().height}`,\n \"--total-scale-factor\": String(width() / page().width),\n }}\n >\n <Show when={image()}>\n {(drawn) => (\n <img\n src={drawn().url}\n width={drawn().width}\n height={drawn().height}\n draggable={false}\n alt={`${props.title}: ${messages().pdfPage({ number: index + 1, total: pages().length })}`}\n />\n )}\n </Show>\n <Show when={texted().has(index) && doc()} keyed>\n {(handle) => <PdfTextLayer document={handle} index={index} onSettled={textNext} />}\n </Show>\n </div>\n );\n }}\n </For>\n </div>\n </div>\n {/* The pill: page and zoom unless `zoom` is false, then the host's actions, which stay without zoom. */}\n <Show when={doc() && (props.zoom !== false || (props.actions?.length ?? 0) > 0)}>\n <div class=\"k2b-pdf-viewer__bar\">\n <Toolbar label={messages().pdfZoom}>\n <Show when={props.zoom !== false}>\n <Show when={props.page === undefined && pages().length > 1}>\n <Toolbar.Label class=\"k2b-pdf-viewer__page-number\">\n <span class=\"k2b-sr-only\">{messages().pdfPage({ number: current() + 1, total: pages().length })}</span>\n <span aria-hidden=\"true\">{messages().pdfPageShort({ number: current() + 1, total: pages().length })}</span>\n </Toolbar.Label>\n <Toolbar.Separator />\n </Show>\n <Toolbar.Action label={messages().pdfZoomOut} icon=\"ti ti-minus\" disabled={percent() <= SMALLEST} onClick={() => step(-1)} />\n <Toolbar.Label class=\"k2b-pdf-viewer__percent\">\n <span aria-live=\"polite\">{messages().pdfZoomPercent({ value: percent() })}</span>\n </Toolbar.Label>\n <Toolbar.Action label={messages().pdfZoomIn} icon=\"ti ti-plus\" disabled={percent() >= LARGEST} onClick={() => step(1)} />\n <Toolbar.Separator />\n {/* Icons only; the pressed state is the blue icon without a fill. */}\n <Toolbar.Action\n label={fitMode() === \"page\" ? messages().pdfFitPageLabel : messages().pdfFitWidthLabel}\n icon={fitMode() === \"page\" ? \"ti ti-arrows-vertical\" : \"ti ti-arrows-horizontal\"}\n pressed={fitWidth()}\n onClick={fit}\n />\n </Show>\n <For each={props.actions ?? []}>\n {(action) => <Toolbar.Action label={action.label} icon={action.icon} disabled={action.disabled} onClick={action.onClick} />}\n </For>\n </Toolbar>\n </div>\n </Show>\n </div>\n );\n}\n\n/** One page's text layer; pdf.js builds it once, and zoom changes only `--total-scale-factor` on the page. */\nfunction PdfTextLayer(props: { document: PdfDocumentHandle; index: number; onSettled: () => void }): JSX.Element {\n let layer: HTMLDivElement | undefined;\n onMount(() => {\n if (!layer) return;\n const container = layer;\n const abort = new AbortController();\n onCleanup(() => abort.abort());\n void props.document.textLayer(props.index, container, abort.signal).then(\n () => {\n if (abort.signal.aborted) return;\n const end = document.createElement(\"div\");\n end.className = \"k2b-pdf-viewer__text-end\";\n container.append(end);\n props.onSettled();\n },\n () => {\n if (!abort.signal.aborted) props.onSettled();\n },\n );\n });\n return <div ref={layer} class=\"k2b-pdf-viewer__text\" onPointerDown={() => layer?.setAttribute(\"data-selecting\", \"\")} />;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,EAAY,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,QAAQ,UAAU;AAC9H,SAAS,OAAO,QAAQ,oBAAoB;AAC5C,SAAS,eAAe,EAA+D,cAAc,QAAQ,gBAAgB;AAC7H,SAAS,cAAc,QAAQ,gBAAgB;;AAE/C;;AAiCA;AACA,MAAM,KAAK,GAAG,EAAE,GAAG,EAAE;AACrB;AACA,OAAO,MAAM,cAAc,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU;AAC5E,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC;AAClC,MAAM,OAAO,GAAG,cAAc,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG;AAChE;AACA,MAAM,KAAK,GAAG,EAAE;AAChB;AACA,MAAM,WAAW,GAAG,EAAE,GAAG,EAAE;AAC3B;AACA,MAAM,WAAW,GAAG,UAAU;AAC9B;AACA,MAAM,WAAW,GAAG,EAAE;AACtB;AACA,MAAM,YAAY,GAAG,GAAG;;AAExB;AACA,OAAO,MAAM,eAAe,GAAG,CAAC,OAAe,EAAE,SAAiB,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4E,EAAe;EAC/G,IAAI,KAAiC;EACrC,OAAO,CAAC,MAAM;IACZ,IAAI,CAAC,KAAK,EAAE;IACZ,MAAM,SAAS,GAAG,KAAK;IACvB,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,CAAC;IACnC,SAAS,CAAC,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9B,KAAK,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CACtE,MAAM;MACJ,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE;MAC1B,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;MACzC,GAAG,CAAC,SAAS,GAAG,0BAA0B;MAC1C,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;MACrB,KAAK,CAAC,SAAS,CAAC,CAAC;IACnB,CAAC,EACD,MAAM;MACJ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9C,CACF,CAAC;EACH,CAAC,CAAC;EACF;AACF","ignoreList":[]}
|
|
@@ -4,9 +4,10 @@ import { escape as _$escape } from "solid-js/web";
|
|
|
4
4
|
import { ssrAttribute as _$ssrAttribute } from "solid-js/web";
|
|
5
5
|
import { createComponent as _$createComponent } from "solid-js/web";
|
|
6
6
|
var _tmpl$ = ["<button type=\"button\" class=\"k2b-button\" data-variant=\"secondary\" data-size=\"sm\"", ">", "</button>"],
|
|
7
|
-
_tmpl$2 =
|
|
8
|
-
_tmpl$3 = ["<
|
|
9
|
-
|
|
7
|
+
_tmpl$2 = "<span class=\"k2b-pdf-viewer__progress\" aria-hidden=\"true\"></span>",
|
|
8
|
+
_tmpl$3 = ["<p role=\"alert\" class=\"k2b-pdf-viewer__notice\">", "</p>"],
|
|
9
|
+
_tmpl$4 = ["<div class=\"", "\"", ">", "", "", "", "</div>"];
|
|
10
|
+
import { batch, createEffect, createSignal, lazy, on, onCleanup, Show } from "solid-js";
|
|
10
11
|
import { announce } from "../feedback/announce";
|
|
11
12
|
import { useUiMessages } from "../intl/messages";
|
|
12
13
|
import Placeholder from "../surfaces/Placeholder";
|
|
@@ -32,13 +33,18 @@ const toBlob = async response => {
|
|
|
32
33
|
return blob;
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
/** A load that ends within this time shows no progress line; a person reads a shorter wait as instant. */
|
|
37
|
+
const QUIET_DELAY_MS = 400;
|
|
38
|
+
|
|
35
39
|
// The pages and pdf.js load only once a document shows, so a page that never shows one carries neither.
|
|
36
40
|
const PdfPages = lazy(() => import("./PdfPages"));
|
|
37
41
|
|
|
38
42
|
/**
|
|
39
43
|
* Shows a PDF with pdf.js on a grey, rounded ground: pages as images with selectable text and a small pill for the
|
|
40
44
|
* page, zoom, and fit. Pass the document as `data`, or a `request` that loads it; the viewer shows the empty, loading,
|
|
41
|
-
* and error states in the same area, so nothing around it moves.
|
|
45
|
+
* and error states in the same area, so nothing around it moves. A new document loads behind the shown pages, which
|
|
46
|
+
* keep their zoom and, for the same pages under the same title, their scroll position; a thin line on the top edge
|
|
47
|
+
* shows a longer wait, and a failed load replaces the pages with its error.
|
|
42
48
|
*/
|
|
43
49
|
export default function PdfViewer(props) {
|
|
44
50
|
const messages = useUiMessages();
|
|
@@ -50,6 +56,8 @@ export default function PdfViewer(props) {
|
|
|
50
56
|
// pdf.js could not draw the shown document; the error state offers it in a new tab.
|
|
51
57
|
const [undrawable, setUndrawable] = createSignal(false);
|
|
52
58
|
const [drawn, setDrawn] = createSignal(false);
|
|
59
|
+
// A new document is opening while the previous one stays drawn.
|
|
60
|
+
const [replacing, setReplacing] = createSignal(false);
|
|
53
61
|
const [tabBlocked, setTabBlocked] = createSignal(false);
|
|
54
62
|
let root;
|
|
55
63
|
let generation = 0;
|
|
@@ -61,9 +69,13 @@ export default function PdfViewer(props) {
|
|
|
61
69
|
generation += 1;
|
|
62
70
|
fetching?.abort();
|
|
63
71
|
});
|
|
72
|
+
|
|
73
|
+
/** A drawn document stays until the new one's first pages are drawn; otherwise the loading state shows. */
|
|
64
74
|
const show = document => {
|
|
75
|
+
const keep = drawn() && Boolean(shown()) && !undrawable();
|
|
65
76
|
setUndrawable(false);
|
|
66
|
-
setDrawn(
|
|
77
|
+
setDrawn(keep);
|
|
78
|
+
setReplacing(keep);
|
|
67
79
|
setError(null);
|
|
68
80
|
setShown(document);
|
|
69
81
|
};
|
|
@@ -161,6 +173,7 @@ export default function PdfViewer(props) {
|
|
|
161
173
|
const undrawableNow = cause => {
|
|
162
174
|
setUndrawable(true);
|
|
163
175
|
setDrawn(false);
|
|
176
|
+
setReplacing(false);
|
|
164
177
|
announce(pdfMessages().pdfPreviewNoViewer);
|
|
165
178
|
props.onError?.(cause);
|
|
166
179
|
};
|
|
@@ -172,6 +185,15 @@ export default function PdfViewer(props) {
|
|
|
172
185
|
if (!shown()) return loading() || !onDemand() && !props.disabled && (props.data !== undefined || props.request) ? "loading" : "idle";
|
|
173
186
|
return drawn() ? null : "loading";
|
|
174
187
|
};
|
|
188
|
+
// While the shown pages wait for a new document, a quiet line appears after a short wait, so a fast load never flickers.
|
|
189
|
+
const busy = () => !status() && (loading() || replacing());
|
|
190
|
+
const [quiet, setQuiet] = createSignal(false);
|
|
191
|
+
createEffect(on(busy, waiting => {
|
|
192
|
+
setQuiet(false);
|
|
193
|
+
if (!waiting) return;
|
|
194
|
+
const timer = setTimeout(() => setQuiet(true), QUIET_DELAY_MS);
|
|
195
|
+
onCleanup(() => clearTimeout(timer));
|
|
196
|
+
}));
|
|
175
197
|
// A document pdf.js cannot draw can still open in the browser's viewer, and a generated one can render again, for
|
|
176
198
|
// example after its template input was corrected.
|
|
177
199
|
const undrawableActions = () => props.open || onDemand() ? [_$createComponent(Show, {
|
|
@@ -190,7 +212,7 @@ export default function PdfViewer(props) {
|
|
|
190
212
|
}
|
|
191
213
|
})] : undefined;
|
|
192
214
|
const action = (label, run, disabled) => _$ssr(_tmpl$, _$ssrAttribute("disabled", disabled, true), _$escape(label));
|
|
193
|
-
return _$ssr(_tmpl$
|
|
215
|
+
return _$ssr(_tmpl$4, `k2b-pdf-viewer ${_$escape(props.class ?? "", true)}`, _$ssrAttribute("data-state", _$escape(status() ?? "shown", true), false) + _$ssrAttribute("tabindex", status() ? -1 : _$escape(undefined, true), false) + _$ssrAttribute("aria-busy", busy() ? "true" : _$escape(undefined, true), false), _$escape(_$createComponent(Show, {
|
|
194
216
|
get when() {
|
|
195
217
|
return _$memo(() => !!!undrawable())() && shown();
|
|
196
218
|
},
|
|
@@ -218,7 +240,10 @@ export default function PdfViewer(props) {
|
|
|
218
240
|
},
|
|
219
241
|
onReady: drawnDocument => {
|
|
220
242
|
const waiting = document.activeElement === root;
|
|
221
|
-
|
|
243
|
+
batch(() => {
|
|
244
|
+
setDrawn(true);
|
|
245
|
+
setReplacing(false);
|
|
246
|
+
});
|
|
222
247
|
if (waiting) root?.querySelector(".k2b-pdf-viewer__pages")?.focus();
|
|
223
248
|
props.onReady?.(drawnDocument);
|
|
224
249
|
},
|
|
@@ -249,12 +274,19 @@ export default function PdfViewer(props) {
|
|
|
249
274
|
return _$memo(() => !!(state() === "idle" && onDemand()))() ? action(props.loadLabel ?? pdfMessages().previewPdf, () => void load(), props.disabled) : _$memo(() => !!(state() === "error" && (props.request || typeof props.data === "string")))() ? action(messages().retry, () => void load(), loading() || props.disabled) : _$memo(() => state() === "undrawable")() ? undrawableActions() : undefined;
|
|
250
275
|
}
|
|
251
276
|
})
|
|
277
|
+
})), _$escape(_$createComponent(Show, {
|
|
278
|
+
get when() {
|
|
279
|
+
return quiet();
|
|
280
|
+
},
|
|
281
|
+
get children() {
|
|
282
|
+
return _$ssr(_tmpl$2);
|
|
283
|
+
}
|
|
252
284
|
})), _$escape(_$createComponent(Show, {
|
|
253
285
|
get when() {
|
|
254
286
|
return tabBlocked();
|
|
255
287
|
},
|
|
256
288
|
get children() {
|
|
257
|
-
return _$ssr(_tmpl$
|
|
289
|
+
return _$ssr(_tmpl$3, _$escape(pdfMessages().pdfPreviewTabBlocked));
|
|
258
290
|
}
|
|
259
291
|
})));
|
|
260
292
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["content/PdfViewer.tsx"],"sourcesContent":["import { createEffect, createSignal, type JSX, lazy, on, onCleanup, Show } from \"solid-js\";\nimport { announce } from \"../feedback/announce\";\nimport { useUiMessages } from \"../intl/messages\";\nimport Placeholder from \"../surfaces/Placeholder\";\nimport type { PdfPagesAction } from \"./PdfPages\";\nimport { resolvePdfMessages, usePdfMessages } from \"./pdf-messages\";\n\n/** Loads a PDF when the viewer needs it. A failed `Response` becomes the error state with its `message`. */\nexport type PdfViewerRequest = () => Promise<Response | Blob>;\n\nexport type PdfViewerProps = {\n /** The document's name, for the page area, the page images, and a tab opened from the pill. */\n title: string;\n /**\n * The PDF to show: its bytes, or the address of one on this site, which the viewer fetches. A new value shows that\n * document. Pass either `data` or `request`.\n */\n data?: Blob | ArrayBuffer | string;\n /** Requests the PDF: at once with `autoLoad`, otherwise from the action in the empty state. */\n request?: PdfViewerRequest;\n /** Runs `request` as soon as the viewer shows. Without it, the person starts it. */\n autoLoad?: boolean;\n /** Keeps a requested document from loading, such as while its input is incomplete. */\n disabled?: boolean;\n /** The empty state's text before an on-demand request. */\n emptyText?: string;\n /** Names the action that runs an on-demand `request`; once a document shows, it renders again from the pill. */\n loadLabel?: string;\n /**\n * Adds \"Open in new tab\" to the pill and the error state: `true` opens the shown document, an address opens that\n * address, which reloads and keeps the document's name.\n */\n open?: boolean | string;\n /** Without the zoom controls, always fitted. Defaults to `true`. */\n zoom?: boolean;\n /**\n * With `zoom` false, a factor of the fitted width, such as 1.5, for a host that zooms with its own controls, like\n * `Lightbox`. Defaults to 1.\n */\n scale?: number;\n /**\n * How a fitted document fills the area: `\"width\"` (the default) fits each page to the area's width, for reading;\n * `\"page\"` shows the whole first page in the area's height, narrower, for a preview beside other content.\n * Fitted pages never grow past 100 %.\n */\n fit?: \"width\" | \"page\";\n /** Shows only this page (zero-based) instead of all pages one below the other. */\n page?: number;\n /** The first visible page is drawn; `pages` counts the document's pages, such as for a host's \"4 pages\". */\n onReady?: (document: { pages: number }) => void;\n /** The request failed, or pdf.js could not open or draw the document; the viewer shows its error state. */\n onError?: (error: unknown) => void;\n /** The page in the middle of the view changed (zero-based), for a host that shows \"Page 2 / 4\" itself. */\n onPage?: (index: number) => void;\n class?: string;\n};\n\nconst readErrorMessage = async (response: Response): Promise<string> => {\n try {\n const data = (await response.json()) as unknown;\n if (data && typeof data === \"object\" && \"message\" in data && typeof data.message === \"string\") return data.message;\n } catch {\n // Fall through to the HTTP status fallback.\n }\n return resolvePdfMessages().pdfPreviewHttpError({ status: response.status });\n};\n\nconst toBlob = async (response: Response | Blob): Promise<Blob> => {\n const blob = response instanceof Response ? (response.ok ? await response.blob() : null) : response;\n if (!blob) throw new Error(await readErrorMessage(response as Response));\n if (blob.type && blob.type !== \"application/pdf\") throw new Error(`PDF preview returned ${blob.type} instead of application/pdf`);\n return blob;\n};\n\n// The pages and pdf.js load only once a document shows, so a page that never shows one carries neither.\nconst PdfPages = lazy(() => import(\"./PdfPages\"));\n\n/**\n * Shows a PDF with pdf.js on a grey, rounded ground: pages as images with selectable text and a small pill for the\n * page, zoom, and fit. Pass the document as `data`, or a `request` that loads it; the viewer shows the empty, loading,\n * and error states in the same area, so nothing around it moves.\n */\nexport default function PdfViewer(props: PdfViewerProps): JSX.Element {\n const messages = useUiMessages();\n const pdfMessages = usePdfMessages();\n // The document pdf.js draws.\n const [shown, setShown] = createSignal<Blob | ArrayBuffer | null>(null);\n const [loading, setLoading] = createSignal(false);\n const [error, setError] = createSignal<string | null>(null);\n // pdf.js could not draw the shown document; the error state offers it in a new tab.\n const [undrawable, setUndrawable] = createSignal(false);\n const [drawn, setDrawn] = createSignal(false);\n const [tabBlocked, setTabBlocked] = createSignal(false);\n let root: HTMLDivElement | undefined;\n let generation = 0;\n let disposed = false;\n // Fetching an address stops when the viewer goes or loads another one.\n let fetching: AbortController | undefined;\n onCleanup(() => {\n disposed = true;\n generation += 1;\n fetching?.abort();\n });\n\n const show = (document: Blob | ArrayBuffer) => {\n setUndrawable(false);\n setDrawn(false);\n setError(null);\n setShown(document);\n };\n\n /**\n * Loads from the address or the request. A person's click waits for a running load; a changed source (`replace`)\n * supersedes it. A newer load or the end of the viewer drops a late answer.\n */\n const load = async (replace = false) => {\n const source = props.data;\n const request =\n typeof source === \"string\"\n ? () => {\n fetching?.abort();\n fetching = new AbortController();\n return fetch(source, { credentials: \"same-origin\", signal: fetching.signal });\n }\n : source\n ? undefined\n : props.request;\n if (!request || (loading() && !replace) || props.disabled) return;\n const current = ++generation;\n // The focused render or retry action leaves with the state it belongs to: keyboard focus moves to the viewer at\n // once instead of dropping to the page.\n const focused = root?.contains(document.activeElement) ?? false;\n setLoading(true);\n setError(null);\n setUndrawable(false);\n if (focused && root && !root.contains(document.activeElement)) root.focus();\n try {\n const blob = await toBlob(await request());\n if (disposed || current !== generation) return;\n show(blob);\n } catch (cause) {\n if (disposed || current !== generation) return;\n setError(cause instanceof Error ? cause.message : pdfMessages().pdfPreview);\n // A host that shows its own states, such as the Lightbox, learns of a failed request as of an undrawable file.\n props.onError?.(cause);\n } finally {\n if (!disposed && current === generation) setLoading(false);\n if (focused && document.activeElement === document.body) root?.focus();\n }\n };\n\n // Bytes show at once and an address loads, again whenever `data` changes; either replaces a running load.\n createEffect(\n on(\n () => props.data,\n (data) => {\n if (data instanceof Blob || data instanceof ArrayBuffer) {\n fetching?.abort();\n generation += 1;\n setLoading(false);\n show(data);\n } else if (typeof data === \"string\") void load(true);\n },\n ),\n );\n // An automatic request runs once it may, and again for a new request, which replaces a running one.\n let requested: PdfViewerRequest | undefined;\n createEffect(\n on(\n () => [props.data, props.request, props.autoLoad, props.disabled] as const,\n ([data, request, autoLoad, disabled]) => {\n if (data !== undefined || !request || !autoLoad || disabled) return;\n if (request === requested && (shown() || loading())) return;\n requested = request;\n void load(true);\n },\n ),\n );\n\n const openInTab = async () => {\n setTabBlocked(false);\n const address = typeof props.open === \"string\" ? props.open : null;\n if (address) {\n // Without \"noopener\" in the call, so the browser reports a blocked tab; `opener = null` cuts the link instead.\n const tab = window.open(address, \"_blank\");\n setTabBlocked(!tab);\n if (tab) tab.opener = null;\n return;\n }\n const pdf = shown();\n if (!pdf) return;\n const tab = window.open(\"\", \"_blank\");\n setTabBlocked(!tab);\n if (!tab) return;\n tab.opener = null;\n tab.document.title = props.title;\n tab.document.body.textContent = pdfMessages().pdfPreviewRendering;\n const url = URL.createObjectURL(pdf instanceof Blob ? pdf : new Blob([pdf], { type: \"application/pdf\" }));\n tab.location.href = url;\n window.setTimeout(() => URL.revokeObjectURL(url), 60_000);\n };\n\n const onDemand = () => Boolean(props.request) && !props.autoLoad && props.data === undefined;\n const actions = (): PdfPagesAction[] => [\n ...(props.open ? [{ label: pdfMessages().pdfOpenInTab, icon: \"ti ti-external-link\", onClick: () => void openInTab() }] : []),\n ...(onDemand()\n ? [\n {\n label: props.loadLabel ?? pdfMessages().previewPdf,\n icon: loading() ? \"ti ti-loader-2 k2b-spin\" : \"ti ti-refresh\",\n disabled: loading() || props.disabled,\n onClick: () => void load(),\n },\n ]\n : []),\n ];\n\n const undrawableNow = (cause: unknown) => {\n setUndrawable(true);\n setDrawn(false);\n announce(pdfMessages().pdfPreviewNoViewer);\n props.onError?.(cause);\n };\n\n // One placeholder for every state but the drawn document, in the same area.\n const status = (): \"idle\" | \"loading\" | \"error\" | \"undrawable\" | null => {\n if (error()) return \"error\";\n if (undrawable()) return \"undrawable\";\n if (!shown()) return loading() || (!onDemand() && !props.disabled && (props.data !== undefined || props.request)) ? \"loading\" : \"idle\";\n return drawn() ? null : \"loading\";\n };\n // A document pdf.js cannot draw can still open in the browser's viewer, and a generated one can render again, for\n // example after its template input was corrected.\n const undrawableActions = () =>\n props.open || onDemand() ? (\n <>\n <Show when={onDemand()}>{action(props.loadLabel ?? pdfMessages().previewPdf, () => void load(), loading() || props.disabled)}</Show>\n <Show when={props.open}>{action(pdfMessages().pdfOpenInTab, () => void openInTab())}</Show>\n </>\n ) : undefined;\n const action = (label: string, run: () => void, disabled?: boolean) => (\n <button type=\"button\" class=\"k2b-button\" data-variant=\"secondary\" data-size=\"sm\" disabled={disabled} onClick={run}>\n {label}\n </button>\n );\n\n return (\n <div\n ref={root}\n class={`k2b-pdf-viewer ${props.class ?? \"\"}`}\n data-state={status() ?? \"shown\"}\n // While a placeholder shows, the viewer holds keyboard focus that has nowhere else to go.\n tabIndex={status() ? -1 : undefined}\n >\n <Show when={!undrawable() && shown()}>\n {(pdf) => (\n <PdfPages\n data={pdf()}\n title={props.title}\n zoom={props.zoom}\n scale={props.scale}\n fit={props.fit}\n page={props.page}\n actions={actions()}\n onReady={(drawnDocument) => {\n const waiting = document.activeElement === root;\n setDrawn(true);\n if (waiting) root?.querySelector<HTMLElement>(\".k2b-pdf-viewer__pages\")?.focus();\n props.onReady?.(drawnDocument);\n }}\n onError={undrawableNow}\n onPage={props.onPage}\n />\n )}\n </Show>\n <Show when={status()}>\n {(state) => (\n <Placeholder\n class=\"k2b-pdf-viewer__placeholder\"\n state={state() === \"loading\" ? \"loading\" : state() === \"error\" ? \"error\" : \"empty\"}\n icon={state() === \"idle\" || state() === \"undrawable\" ? \"ti ti-file-type-pdf\" : undefined}\n title={state() === \"loading\" ? messages().loading : state() === \"undrawable\" ? pdfMessages().pdfPreviewNoViewer : undefined}\n description={\n state() === \"idle\"\n ? (props.emptyText ?? pdfMessages().renderPdfPreview)\n : state() === \"error\"\n ? (error() ?? undefined)\n : state() === \"undrawable\"\n ? pdfMessages().pdfPreviewNoViewerDescription\n : undefined\n }\n action={\n state() === \"idle\" && onDemand()\n ? action(props.loadLabel ?? pdfMessages().previewPdf, () => void load(), props.disabled)\n : state() === \"error\" && (props.request || typeof props.data === \"string\")\n ? action(messages().retry, () => void load(), loading() || props.disabled)\n : state() === \"undrawable\"\n ? undrawableActions()\n : undefined\n }\n />\n )}\n </Show>\n <Show when={tabBlocked()}>\n <p role=\"alert\" class=\"k2b-pdf-viewer__notice\">\n {pdfMessages().pdfPreviewTabBlocked}\n </p>\n </Show>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,YAAY,EAAE,YAAY,EAAY,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,QAAQ,UAAU;AAC1F,SAAS,QAAQ,QAAQ,sBAAsB;AAC/C,SAAS,aAAa,QAAQ,kBAAkB;AAChD,OAAO,WAAW,MAAM,yBAAyB;AAEjD,SAAS,kBAAkB,EAAE,cAAc,QAAQ,gBAAgB;;AAEnE;;AAkDA,MAAM,gBAAgB,GAAG,MAAO,QAAkB,IAAsB;EACtE,IAAI;IACF,MAAM,IAAI,GAAI,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAa;IAC/C,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,SAAS,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,OAAO,IAAI,CAAC,OAAO;EACpH,CAAC,CAAC,MAAM;IACN;EAAA;EAEF,OAAO,kBAAkB,CAAC,CAAC,CAAC,mBAAmB,CAAC;IAAE,MAAM,EAAE,QAAQ,CAAC;EAAO,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,MAAM,GAAG,MAAO,QAAyB,IAAoB;EACjE,MAAM,IAAI,GAAG,QAAQ,YAAY,QAAQ,GAAI,QAAQ,CAAC,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,GAAI,QAAQ;EACnG,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,CAAC,MAAM,gBAAgB,CAAC,QAAoB,CAAC,CAAC;EACxE,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE,MAAM,IAAI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AC,GACtF,qBAAK,CAAC,CAAC,KAAK,OAAO,KAAK,KAAK,CAAC,OAAO,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,OACtE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GACxE,kBAAK,CAAC,CAAC,KAAK,YAAY,MACtB,iBAAiB,CAAC,CAAC,GACnB,SAAS;MAAA;IAAA;EAGtB,gCAEF,IAAI;IAAA,IAAC,IAAI;MAAA,OAAE,UAAU,CAAC,CAAC;IAAA;IAAA;MAAA,+BAEnB,WAAW,CAAC,CAAC,CAAC,oBAAoB;IAAA;EAAA;AAK7C","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["content/PdfViewer.tsx"],"sourcesContent":["import { batch, createEffect, createSignal, type JSX, lazy, on, onCleanup, Show } from \"solid-js\";\nimport { announce } from \"../feedback/announce\";\nimport { useUiMessages } from \"../intl/messages\";\nimport Placeholder from \"../surfaces/Placeholder\";\nimport type { PdfPagesAction } from \"./PdfPages\";\nimport { resolvePdfMessages, usePdfMessages } from \"./pdf-messages\";\n\n/** Loads a PDF when the viewer needs it. A failed `Response` becomes the error state with its `message`. */\nexport type PdfViewerRequest = () => Promise<Response | Blob>;\n\nexport type PdfViewerProps = {\n /** The document's name, for the page area, the page images, and a tab opened from the pill. */\n title: string;\n /**\n * The PDF to show: its bytes, or the address of one on this site, which the viewer fetches. A new value shows that\n * document; the shown pages stay until its first pages are drawn. Pass either `data` or `request`.\n */\n data?: Blob | ArrayBuffer | string;\n /**\n * Requests the PDF: at once with `autoLoad`, otherwise from the action in the empty state. A new request replaces a\n * running one, and the shown pages stay while it loads.\n */\n request?: PdfViewerRequest;\n /** Runs `request` as soon as the viewer shows. Without it, the person starts it. */\n autoLoad?: boolean;\n /** Keeps a requested document from loading, such as while its input is incomplete. */\n disabled?: boolean;\n /** The empty state's text before an on-demand request. */\n emptyText?: string;\n /** Names the action that runs an on-demand `request`; once a document shows, it renders again from the pill. */\n loadLabel?: string;\n /**\n * Adds \"Open in new tab\" to the pill and the error state: `true` opens the shown document, an address opens that\n * address, which reloads and keeps the document's name.\n */\n open?: boolean | string;\n /** Without the zoom controls, always fitted. Defaults to `true`. */\n zoom?: boolean;\n /**\n * With `zoom` false, a factor of the fitted width, such as 1.5, for a host that zooms with its own controls, like\n * `Lightbox`. Defaults to 1.\n */\n scale?: number;\n /**\n * How a fitted document fills the area: `\"width\"` (the default) fits each page to the area's width, for reading;\n * `\"page\"` shows the whole first page in the area's height, narrower, for a preview beside other content.\n * Fitted pages never grow past 100 %.\n */\n fit?: \"width\" | \"page\";\n /** Shows only this page (zero-based) instead of all pages one below the other. */\n page?: number;\n /**\n * The first visible page is drawn, again for each new document; `pages` counts the document's pages, such as for a\n * host's \"4 pages\".\n */\n onReady?: (document: { pages: number }) => void;\n /** The request failed, or pdf.js could not open or draw the document; the viewer shows its error state. */\n onError?: (error: unknown) => void;\n /** The page in the middle of the view changed (zero-based), for a host that shows \"Page 2 / 4\" itself. */\n onPage?: (index: number) => void;\n class?: string;\n};\n\nconst readErrorMessage = async (response: Response): Promise<string> => {\n try {\n const data = (await response.json()) as unknown;\n if (data && typeof data === \"object\" && \"message\" in data && typeof data.message === \"string\") return data.message;\n } catch {\n // Fall through to the HTTP status fallback.\n }\n return resolvePdfMessages().pdfPreviewHttpError({ status: response.status });\n};\n\nconst toBlob = async (response: Response | Blob): Promise<Blob> => {\n const blob = response instanceof Response ? (response.ok ? await response.blob() : null) : response;\n if (!blob) throw new Error(await readErrorMessage(response as Response));\n if (blob.type && blob.type !== \"application/pdf\") throw new Error(`PDF preview returned ${blob.type} instead of application/pdf`);\n return blob;\n};\n\n/** A load that ends within this time shows no progress line; a person reads a shorter wait as instant. */\nconst QUIET_DELAY_MS = 400;\n\n// The pages and pdf.js load only once a document shows, so a page that never shows one carries neither.\nconst PdfPages = lazy(() => import(\"./PdfPages\"));\n\n/**\n * Shows a PDF with pdf.js on a grey, rounded ground: pages as images with selectable text and a small pill for the\n * page, zoom, and fit. Pass the document as `data`, or a `request` that loads it; the viewer shows the empty, loading,\n * and error states in the same area, so nothing around it moves. A new document loads behind the shown pages, which\n * keep their zoom and, for the same pages under the same title, their scroll position; a thin line on the top edge\n * shows a longer wait, and a failed load replaces the pages with its error.\n */\nexport default function PdfViewer(props: PdfViewerProps): JSX.Element {\n const messages = useUiMessages();\n const pdfMessages = usePdfMessages();\n // The document pdf.js draws.\n const [shown, setShown] = createSignal<Blob | ArrayBuffer | null>(null);\n const [loading, setLoading] = createSignal(false);\n const [error, setError] = createSignal<string | null>(null);\n // pdf.js could not draw the shown document; the error state offers it in a new tab.\n const [undrawable, setUndrawable] = createSignal(false);\n const [drawn, setDrawn] = createSignal(false);\n // A new document is opening while the previous one stays drawn.\n const [replacing, setReplacing] = createSignal(false);\n const [tabBlocked, setTabBlocked] = createSignal(false);\n let root: HTMLDivElement | undefined;\n let generation = 0;\n let disposed = false;\n // Fetching an address stops when the viewer goes or loads another one.\n let fetching: AbortController | undefined;\n onCleanup(() => {\n disposed = true;\n generation += 1;\n fetching?.abort();\n });\n\n /** A drawn document stays until the new one's first pages are drawn; otherwise the loading state shows. */\n const show = (document: Blob | ArrayBuffer) => {\n const keep = drawn() && Boolean(shown()) && !undrawable();\n setUndrawable(false);\n setDrawn(keep);\n setReplacing(keep);\n setError(null);\n setShown(document);\n };\n\n /**\n * Loads from the address or the request. A person's click waits for a running load; a changed source (`replace`)\n * supersedes it. A newer load or the end of the viewer drops a late answer.\n */\n const load = async (replace = false) => {\n const source = props.data;\n const request =\n typeof source === \"string\"\n ? () => {\n fetching?.abort();\n fetching = new AbortController();\n return fetch(source, { credentials: \"same-origin\", signal: fetching.signal });\n }\n : source\n ? undefined\n : props.request;\n if (!request || (loading() && !replace) || props.disabled) return;\n const current = ++generation;\n // The focused render or retry action leaves with the state it belongs to: keyboard focus moves to the viewer at\n // once instead of dropping to the page.\n const focused = root?.contains(document.activeElement) ?? false;\n setLoading(true);\n setError(null);\n setUndrawable(false);\n if (focused && root && !root.contains(document.activeElement)) root.focus();\n try {\n const blob = await toBlob(await request());\n if (disposed || current !== generation) return;\n show(blob);\n } catch (cause) {\n if (disposed || current !== generation) return;\n setError(cause instanceof Error ? cause.message : pdfMessages().pdfPreview);\n // A host that shows its own states, such as the Lightbox, learns of a failed request as of an undrawable file.\n props.onError?.(cause);\n } finally {\n if (!disposed && current === generation) setLoading(false);\n if (focused && document.activeElement === document.body) root?.focus();\n }\n };\n\n // Bytes show at once and an address loads, again whenever `data` changes; either replaces a running load.\n createEffect(\n on(\n () => props.data,\n (data) => {\n if (data instanceof Blob || data instanceof ArrayBuffer) {\n fetching?.abort();\n generation += 1;\n setLoading(false);\n show(data);\n } else if (typeof data === \"string\") void load(true);\n },\n ),\n );\n // An automatic request runs once it may, and again for a new request, which replaces a running one.\n let requested: PdfViewerRequest | undefined;\n createEffect(\n on(\n () => [props.data, props.request, props.autoLoad, props.disabled] as const,\n ([data, request, autoLoad, disabled]) => {\n if (data !== undefined || !request || !autoLoad || disabled) return;\n if (request === requested && (shown() || loading())) return;\n requested = request;\n void load(true);\n },\n ),\n );\n\n const openInTab = async () => {\n setTabBlocked(false);\n const address = typeof props.open === \"string\" ? props.open : null;\n if (address) {\n // Without \"noopener\" in the call, so the browser reports a blocked tab; `opener = null` cuts the link instead.\n const tab = window.open(address, \"_blank\");\n setTabBlocked(!tab);\n if (tab) tab.opener = null;\n return;\n }\n const pdf = shown();\n if (!pdf) return;\n const tab = window.open(\"\", \"_blank\");\n setTabBlocked(!tab);\n if (!tab) return;\n tab.opener = null;\n tab.document.title = props.title;\n tab.document.body.textContent = pdfMessages().pdfPreviewRendering;\n const url = URL.createObjectURL(pdf instanceof Blob ? pdf : new Blob([pdf], { type: \"application/pdf\" }));\n tab.location.href = url;\n window.setTimeout(() => URL.revokeObjectURL(url), 60_000);\n };\n\n const onDemand = () => Boolean(props.request) && !props.autoLoad && props.data === undefined;\n const actions = (): PdfPagesAction[] => [\n ...(props.open ? [{ label: pdfMessages().pdfOpenInTab, icon: \"ti ti-external-link\", onClick: () => void openInTab() }] : []),\n ...(onDemand()\n ? [\n {\n label: props.loadLabel ?? pdfMessages().previewPdf,\n icon: loading() ? \"ti ti-loader-2 k2b-spin\" : \"ti ti-refresh\",\n disabled: loading() || props.disabled,\n onClick: () => void load(),\n },\n ]\n : []),\n ];\n\n const undrawableNow = (cause: unknown) => {\n setUndrawable(true);\n setDrawn(false);\n setReplacing(false);\n announce(pdfMessages().pdfPreviewNoViewer);\n props.onError?.(cause);\n };\n\n // One placeholder for every state but the drawn document, in the same area.\n const status = (): \"idle\" | \"loading\" | \"error\" | \"undrawable\" | null => {\n if (error()) return \"error\";\n if (undrawable()) return \"undrawable\";\n if (!shown()) return loading() || (!onDemand() && !props.disabled && (props.data !== undefined || props.request)) ? \"loading\" : \"idle\";\n return drawn() ? null : \"loading\";\n };\n // While the shown pages wait for a new document, a quiet line appears after a short wait, so a fast load never flickers.\n const busy = () => !status() && (loading() || replacing());\n const [quiet, setQuiet] = createSignal(false);\n createEffect(\n on(busy, (waiting) => {\n setQuiet(false);\n if (!waiting) return;\n const timer = setTimeout(() => setQuiet(true), QUIET_DELAY_MS);\n onCleanup(() => clearTimeout(timer));\n }),\n );\n // A document pdf.js cannot draw can still open in the browser's viewer, and a generated one can render again, for\n // example after its template input was corrected.\n const undrawableActions = () =>\n props.open || onDemand() ? (\n <>\n <Show when={onDemand()}>{action(props.loadLabel ?? pdfMessages().previewPdf, () => void load(), loading() || props.disabled)}</Show>\n <Show when={props.open}>{action(pdfMessages().pdfOpenInTab, () => void openInTab())}</Show>\n </>\n ) : undefined;\n const action = (label: string, run: () => void, disabled?: boolean) => (\n <button type=\"button\" class=\"k2b-button\" data-variant=\"secondary\" data-size=\"sm\" disabled={disabled} onClick={run}>\n {label}\n </button>\n );\n\n return (\n <div\n ref={root}\n class={`k2b-pdf-viewer ${props.class ?? \"\"}`}\n data-state={status() ?? \"shown\"}\n // While a placeholder shows, the viewer holds keyboard focus that has nowhere else to go.\n tabIndex={status() ? -1 : undefined}\n aria-busy={busy() ? \"true\" : undefined}\n >\n <Show when={!undrawable() && shown()}>\n {(pdf) => (\n <PdfPages\n data={pdf()}\n title={props.title}\n zoom={props.zoom}\n scale={props.scale}\n fit={props.fit}\n page={props.page}\n actions={actions()}\n onReady={(drawnDocument) => {\n const waiting = document.activeElement === root;\n batch(() => {\n setDrawn(true);\n setReplacing(false);\n });\n if (waiting) root?.querySelector<HTMLElement>(\".k2b-pdf-viewer__pages\")?.focus();\n props.onReady?.(drawnDocument);\n }}\n onError={undrawableNow}\n onPage={props.onPage}\n />\n )}\n </Show>\n <Show when={status()}>\n {(state) => (\n <Placeholder\n class=\"k2b-pdf-viewer__placeholder\"\n state={state() === \"loading\" ? \"loading\" : state() === \"error\" ? \"error\" : \"empty\"}\n icon={state() === \"idle\" || state() === \"undrawable\" ? \"ti ti-file-type-pdf\" : undefined}\n title={state() === \"loading\" ? messages().loading : state() === \"undrawable\" ? pdfMessages().pdfPreviewNoViewer : undefined}\n description={\n state() === \"idle\"\n ? (props.emptyText ?? pdfMessages().renderPdfPreview)\n : state() === \"error\"\n ? (error() ?? undefined)\n : state() === \"undrawable\"\n ? pdfMessages().pdfPreviewNoViewerDescription\n : undefined\n }\n action={\n state() === \"idle\" && onDemand()\n ? action(props.loadLabel ?? pdfMessages().previewPdf, () => void load(), props.disabled)\n : state() === \"error\" && (props.request || typeof props.data === \"string\")\n ? action(messages().retry, () => void load(), loading() || props.disabled)\n : state() === \"undrawable\"\n ? undrawableActions()\n : undefined\n }\n />\n )}\n </Show>\n <Show when={quiet()}>\n <span class=\"k2b-pdf-viewer__progress\" aria-hidden=\"true\" />\n </Show>\n <Show when={tabBlocked()}>\n <p role=\"alert\" class=\"k2b-pdf-viewer__notice\">\n {pdfMessages().pdfPreviewTabBlocked}\n </p>\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CAAC,CAAC;IAAA;IAAA;MAAA,+BAEnB,WAAW,CAAC,CAAC,CAAC,oBAAoB;IAAA;EAAA;AAK7C","ignoreList":[]}
|
|
@@ -10,13 +10,14 @@ var _tmpl$ = ["<div class=\"k2b-floating-window-scrim\" aria-hidden=\"true\" sty
|
|
|
10
10
|
_tmpl$3 = ["<div class=\"k2b-floating-window__actions\">", "</div>"],
|
|
11
11
|
_tmpl$4 = "<i class=\"ti ti-minus\" aria-hidden=\"true\"></i>",
|
|
12
12
|
_tmpl$5 = ["<i", " aria-hidden=\"true\"></i>"],
|
|
13
|
-
_tmpl$6 = "<
|
|
14
|
-
_tmpl$7 =
|
|
15
|
-
_tmpl$8 = ["<button type=\"button\" class=\"k2b-floating-
|
|
16
|
-
_tmpl$9 = ["<
|
|
13
|
+
_tmpl$6 = ["<span class=\"k2b-floating-window__size-label\"><span", ">", "</span><span", ">", "</span></span>"],
|
|
14
|
+
_tmpl$7 = "<i class=\"ti ti-x\" aria-hidden=\"true\"></i>",
|
|
15
|
+
_tmpl$8 = ["<section class=\"", "\"", " style=\"", "\" role=\"dialog\"", " tabindex=\"-1\"><header>", "<div class=\"k2b-floating-window__heading\"><button type=\"button\" data-window-move class=\"k2b-floating-window__title\"", "><span", ">", "</span></button>", "</div>", "<div class=\"k2b-floating-window__controls\">", "", "</div></header><div class=\"k2b-floating-window__body\">", "</div>", "</section>"],
|
|
16
|
+
_tmpl$9 = ["<button type=\"button\" class=\"k2b-floating-window__resize\"", " style=\"", "\"", "></button>"],
|
|
17
|
+
_tmpl$0 = ["<div class=\"k2b-floating-window__resize\"", " style=\"", "\" aria-hidden=\"true\"></div>"];
|
|
17
18
|
import { createEffect, createMemo, createSignal, createUniqueId, on, onCleanup, onMount, Show, untrack } from "solid-js";
|
|
18
19
|
import { Portal, render } from "solid-js/web";
|
|
19
|
-
import { IconButton } from "../actions/Button";
|
|
20
|
+
import { Button, IconButton } from "../actions/Button";
|
|
20
21
|
import { returnFocus, ringOnReturn } from "../internal/focus-return";
|
|
21
22
|
import { getK2bPortalRoot } from "../internal/portal";
|
|
22
23
|
import { RenderErrorBoundary } from "../internal/render-error";
|
|
@@ -371,7 +372,7 @@ export default function FloatingWindow(props) {
|
|
|
371
372
|
get children() {
|
|
372
373
|
return _$ssr(_tmpl$, _$ssrStyleProperty("left:", `${_$escape(bounds().x, true)}px`) + _$ssrStyleProperty(";top:", `${_$escape(bounds().y, true)}px`) + _$ssrStyleProperty(";width:", `${_$escape(bounds().width, true)}px`) + _$ssrStyleProperty(";height:", `${_$escape(bounds().height, true)}px`) + _$ssrStyleProperty(";border-radius:", _$escape(bounds().radius, true)) + _$ssrStyleProperty(";z-index:", _$escape(layer(), true)));
|
|
373
374
|
}
|
|
374
|
-
}), _$ssr(_tmpl$
|
|
375
|
+
}), _$ssr(_tmpl$8, `k2b-floating-window ${_$escape(props.class ?? "", true)}`, _$ssrAttribute("data-mobile", mobile() ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("data-state", _$escape(state(), true), false), _$ssrStyleProperty("--k2b-window-accent:", _$escape(props.accent, true)) + _$ssrStyleProperty(";left:", frameRect() ? `${_$escape(frameRect().x, true)}px` : _$escape(undefined, true)) + _$ssrStyleProperty(";top:", frameRect() ? `${_$escape(frameRect().y, true)}px` : _$escape(undefined, true)) + _$ssrStyleProperty(";width:", frameRect() ? `${_$escape(frameRect().width, true)}px` : _$escape(undefined, true)) + _$ssrStyleProperty(";height:", frameRect() ? `${_$escape(frameRect().height, true)}px` : _$escape(undefined, true)) + _$ssrStyleProperty(";z-index:", _$escape(layer(), true)), _$ssrAttribute("aria-modal", modal() ? "true" : "false", false) + _$ssrAttribute("aria-labelledby", _$escape(titleId, true), false), _$escape(_$createComponent(Show, {
|
|
375
376
|
get when() {
|
|
376
377
|
return props.icon;
|
|
377
378
|
},
|
|
@@ -411,14 +412,35 @@ export default function FloatingWindow(props) {
|
|
|
411
412
|
}
|
|
412
413
|
});
|
|
413
414
|
}
|
|
414
|
-
}), _$createComponent(
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
415
|
+
}), _$createComponent(Show, {
|
|
416
|
+
get when() {
|
|
417
|
+
return props.sizeControl === "text";
|
|
418
|
+
},
|
|
419
|
+
get fallback() {
|
|
420
|
+
return _$createComponent(IconButton, {
|
|
421
|
+
size: "sm",
|
|
422
|
+
get label() {
|
|
423
|
+
return _$memo(() => state() === "maximized")() ? floatingWindowMessages().restoreSize : floatingWindowMessages().maximizeWindow;
|
|
424
|
+
},
|
|
425
|
+
onClick: () => changeState(state() === "maximized" ? "normal" : "maximized"),
|
|
426
|
+
get children() {
|
|
427
|
+
return _$ssr(_tmpl$5, _$ssrAttribute("class", state() === "maximized" ? "ti ti-arrows-diagonal-minimize-2" : "ti ti-arrows-diagonal", false));
|
|
428
|
+
}
|
|
429
|
+
});
|
|
418
430
|
},
|
|
419
|
-
onClick: () => changeState(state() === "maximized" ? "normal" : "maximized"),
|
|
420
431
|
get children() {
|
|
421
|
-
return _$
|
|
432
|
+
return _$createComponent(Button, {
|
|
433
|
+
size: "sm",
|
|
434
|
+
variant: "ghost",
|
|
435
|
+
"class": "k2b-floating-window__size",
|
|
436
|
+
get ["aria-label"]() {
|
|
437
|
+
return _$memo(() => state() === "maximized")() ? floatingWindowMessages().restoreSize : floatingWindowMessages().maximizeWindow;
|
|
438
|
+
},
|
|
439
|
+
onClick: () => changeState(state() === "maximized" ? "normal" : "maximized"),
|
|
440
|
+
get children() {
|
|
441
|
+
return [_$ssr(_tmpl$5, _$ssrAttribute("class", state() === "maximized" ? "ti ti-arrows-diagonal-minimize-2" : "ti ti-arrows-diagonal", false)), _$ssr(_tmpl$6, _$ssrAttribute("aria-hidden", state() === "maximized" ? "true" : _$escape(undefined, true), false), _$escape(floatingWindowMessages().maximizeWindow), _$ssrAttribute("aria-hidden", state() === "maximized" ? _$escape(undefined, true) : "true", false), _$escape(floatingWindowMessages().restoreSize))];
|
|
442
|
+
}
|
|
443
|
+
});
|
|
422
444
|
}
|
|
423
445
|
})];
|
|
424
446
|
}
|
|
@@ -430,16 +452,16 @@ export default function FloatingWindow(props) {
|
|
|
430
452
|
},
|
|
431
453
|
onClick: close,
|
|
432
454
|
get children() {
|
|
433
|
-
return _$ssr(_tmpl$
|
|
455
|
+
return _$ssr(_tmpl$7);
|
|
434
456
|
}
|
|
435
457
|
})), _$escape(props.children), _$escape(_$createComponent(Show, {
|
|
436
458
|
get when() {
|
|
437
459
|
return movable();
|
|
438
460
|
},
|
|
439
461
|
get children() {
|
|
440
|
-
return handles.map(([edge, cursor]) => edge === "bottom-right" ? _$ssr(_tmpl$
|
|
462
|
+
return handles.map(([edge, cursor]) => edge === "bottom-right" ? _$ssr(_tmpl$9, _$ssrAttribute("data-edge", _$escape(edge, true), false), _$ssrStyleProperty("cursor:", _$escape(cursor, true)), _$ssrAttribute("aria-label", _$escape(floatingWindowMessages().resizeWindow, true), false)) : // Cloud exposes a single keyboard-resizable corner; the remaining
|
|
441
463
|
// edges stay pointer-only so the window adds one tab stop, not eight.
|
|
442
|
-
_$ssr(_tmpl$
|
|
464
|
+
_$ssr(_tmpl$0, _$ssrAttribute("data-edge", _$escape(edge, true), false), _$ssrStyleProperty("cursor:", _$escape(cursor, true))));
|
|
443
465
|
}
|
|
444
466
|
})))];
|
|
445
467
|
return _$createComponent(Portal, {
|