@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.
Files changed (47) hide show
  1. package/dist/browser/actions/Dropdown.js +4 -3
  2. package/dist/browser/actions/Dropdown.js.map +1 -1
  3. package/dist/browser/actions/menu-rows.js +1 -1
  4. package/dist/browser/actions/menu-rows.js.map +1 -1
  5. package/dist/browser/content/PdfPages.js +159 -44
  6. package/dist/browser/content/PdfPages.js.map +1 -1
  7. package/dist/browser/content/PdfViewer.js +59 -21
  8. package/dist/browser/content/PdfViewer.js.map +1 -1
  9. package/dist/browser/content/pdf-viewer-engine.js +1 -1
  10. package/dist/browser/layout/FloatingWindow.js +122 -75
  11. package/dist/browser/layout/FloatingWindow.js.map +1 -1
  12. package/dist/browser/layout/Panes.js +640 -212
  13. package/dist/browser/layout/Panes.js.map +1 -1
  14. package/dist/browser/layout/index.js +1 -1
  15. package/dist/browser/layout/index.js.map +1 -1
  16. package/dist/browser/layout/panes-layout.js +169 -0
  17. package/dist/browser/layout/panes-layout.js.map +1 -1
  18. package/dist/browser/layout/panes-messages.js +108 -2
  19. package/dist/browser/layout/panes-messages.js.map +1 -1
  20. package/dist/ssr/actions/Dropdown.js +4 -4
  21. package/dist/ssr/actions/Dropdown.js.map +1 -1
  22. package/dist/ssr/actions/menu-rows.js +1 -1
  23. package/dist/ssr/actions/menu-rows.js.map +1 -1
  24. package/dist/ssr/content/PdfPages.js +159 -44
  25. package/dist/ssr/content/PdfPages.js.map +1 -1
  26. package/dist/ssr/content/PdfViewer.js +40 -8
  27. package/dist/ssr/content/PdfViewer.js.map +1 -1
  28. package/dist/ssr/layout/FloatingWindow.js +37 -15
  29. package/dist/ssr/layout/FloatingWindow.js.map +1 -1
  30. package/dist/ssr/layout/Panes.js +396 -41
  31. package/dist/ssr/layout/Panes.js.map +1 -1
  32. package/dist/ssr/layout/index.js +1 -1
  33. package/dist/ssr/layout/index.js.map +1 -1
  34. package/dist/ssr/layout/panes-layout.js +169 -0
  35. package/dist/ssr/layout/panes-layout.js.map +1 -1
  36. package/dist/ssr/layout/panes-messages.js +108 -2
  37. package/dist/ssr/layout/panes-messages.js.map +1 -1
  38. package/dist/styles.css +1 -1
  39. package/dist/types/actions/Dropdown.d.ts +4 -3
  40. package/dist/types/content/PdfPages.d.ts +8 -3
  41. package/dist/types/content/PdfViewer.d.ts +12 -4
  42. package/dist/types/layout/FloatingWindow.d.ts +6 -0
  43. package/dist/types/layout/Panes.d.ts +15 -0
  44. package/dist/types/layout/index.d.ts +2 -2
  45. package/dist/types/layout/panes-layout.d.ts +51 -0
  46. package/dist/types/layout/panes-messages.d.ts +55 -0
  47. package/package.json +1 -1
@@ -13,9 +13,10 @@ import { addEventListener as _$addEventListener } from "solid-js/web";
13
13
  import { setProperty as _$setProperty } from "solid-js/web";
14
14
  import { createComponent as _$createComponent } from "solid-js/web";
15
15
  var _tmpl$ = /*#__PURE__*/_$template(`<button type=button class=k2b-button data-variant=secondary data-size=sm>`),
16
- _tmpl$2 = /*#__PURE__*/_$template(`<p role=alert class=k2b-pdf-viewer__notice>`),
17
- _tmpl$3 = /*#__PURE__*/_$template(`<div><!$><!/><!$><!/><!$><!/>`);
18
- import { createEffect, createSignal, lazy, on, onCleanup, Show } from "solid-js";
16
+ _tmpl$2 = /*#__PURE__*/_$template(`<span class=k2b-pdf-viewer__progress aria-hidden=true>`),
17
+ _tmpl$3 = /*#__PURE__*/_$template(`<p role=alert class=k2b-pdf-viewer__notice>`),
18
+ _tmpl$4 = /*#__PURE__*/_$template(`<div><!$><!/><!$><!/><!$><!/><!$><!/>`);
19
+ import { batch, createEffect, createSignal, lazy, on, onCleanup, Show } from "solid-js";
19
20
  import { announce } from "../feedback/announce";
20
21
  import { useUiMessages } from "../intl/messages";
21
22
  import Placeholder from "../surfaces/Placeholder";
@@ -41,13 +42,18 @@ const toBlob = async response => {
41
42
  return blob;
42
43
  };
43
44
 
45
+ /** A load that ends within this time shows no progress line; a person reads a shorter wait as instant. */
46
+ const QUIET_DELAY_MS = 400;
47
+
44
48
  // The pages and pdf.js load only once a document shows, so a page that never shows one carries neither.
45
49
  const PdfPages = lazy(() => import("./PdfPages"));
46
50
 
47
51
  /**
48
52
  * Shows a PDF with pdf.js on a grey, rounded ground: pages as images with selectable text and a small pill for the
49
53
  * page, zoom, and fit. Pass the document as `data`, or a `request` that loads it; the viewer shows the empty, loading,
50
- * and error states in the same area, so nothing around it moves.
54
+ * and error states in the same area, so nothing around it moves. A new document loads behind the shown pages, which
55
+ * keep their zoom and, for the same pages under the same title, their scroll position; a thin line on the top edge
56
+ * shows a longer wait, and a failed load replaces the pages with its error.
51
57
  */
52
58
  export default function PdfViewer(props) {
53
59
  const messages = useUiMessages();
@@ -59,6 +65,8 @@ export default function PdfViewer(props) {
59
65
  // pdf.js could not draw the shown document; the error state offers it in a new tab.
60
66
  const [undrawable, setUndrawable] = createSignal(false);
61
67
  const [drawn, setDrawn] = createSignal(false);
68
+ // A new document is opening while the previous one stays drawn.
69
+ const [replacing, setReplacing] = createSignal(false);
62
70
  const [tabBlocked, setTabBlocked] = createSignal(false);
63
71
  let root;
64
72
  let generation = 0;
@@ -70,9 +78,13 @@ export default function PdfViewer(props) {
70
78
  generation += 1;
71
79
  fetching?.abort();
72
80
  });
81
+
82
+ /** A drawn document stays until the new one's first pages are drawn; otherwise the loading state shows. */
73
83
  const show = document => {
84
+ const keep = drawn() && Boolean(shown()) && !undrawable();
74
85
  setUndrawable(false);
75
- setDrawn(false);
86
+ setDrawn(keep);
87
+ setReplacing(keep);
76
88
  setError(null);
77
89
  setShown(document);
78
90
  };
@@ -170,6 +182,7 @@ export default function PdfViewer(props) {
170
182
  const undrawableNow = cause => {
171
183
  setUndrawable(true);
172
184
  setDrawn(false);
185
+ setReplacing(false);
173
186
  announce(pdfMessages().pdfPreviewNoViewer);
174
187
  props.onError?.(cause);
175
188
  };
@@ -181,6 +194,15 @@ export default function PdfViewer(props) {
181
194
  if (!shown()) return loading() || !onDemand() && !props.disabled && (props.data !== undefined || props.request) ? "loading" : "idle";
182
195
  return drawn() ? null : "loading";
183
196
  };
197
+ // While the shown pages wait for a new document, a quiet line appears after a short wait, so a fast load never flickers.
198
+ const busy = () => !status() && (loading() || replacing());
199
+ const [quiet, setQuiet] = createSignal(false);
200
+ createEffect(on(busy, waiting => {
201
+ setQuiet(false);
202
+ if (!waiting) return;
203
+ const timer = setTimeout(() => setQuiet(true), QUIET_DELAY_MS);
204
+ onCleanup(() => clearTimeout(timer));
205
+ }));
184
206
  // A document pdf.js cannot draw can still open in the browser's viewer, and a generated one can render again, for
185
207
  // example after its template input was corrected.
186
208
  const undrawableActions = () => props.open || onDemand() ? [_$createComponent(Show, {
@@ -207,13 +229,15 @@ export default function PdfViewer(props) {
207
229
  return _el$;
208
230
  })();
209
231
  return (() => {
210
- var _el$2 = _$getNextElement(_tmpl$3),
211
- _el$4 = _el$2.firstChild,
212
- [_el$5, _co$] = _$getNextMarker(_el$4.nextSibling),
213
- _el$6 = _el$5.nextSibling,
214
- [_el$7, _co$2] = _$getNextMarker(_el$6.nextSibling),
215
- _el$8 = _el$7.nextSibling,
216
- [_el$9, _co$3] = _$getNextMarker(_el$8.nextSibling);
232
+ var _el$2 = _$getNextElement(_tmpl$4),
233
+ _el$5 = _el$2.firstChild,
234
+ [_el$6, _co$] = _$getNextMarker(_el$5.nextSibling),
235
+ _el$7 = _el$6.nextSibling,
236
+ [_el$8, _co$2] = _$getNextMarker(_el$7.nextSibling),
237
+ _el$9 = _el$8.nextSibling,
238
+ [_el$0, _co$3] = _$getNextMarker(_el$9.nextSibling),
239
+ _el$1 = _el$0.nextSibling,
240
+ [_el$10, _co$4] = _$getNextMarker(_el$1.nextSibling);
217
241
  var _ref$ = root;
218
242
  typeof _ref$ === "function" ? _$use(_ref$, _el$2) : root = _el$2;
219
243
  _$insert(_el$2, _$createComponent(Show, {
@@ -244,7 +268,10 @@ export default function PdfViewer(props) {
244
268
  },
245
269
  onReady: drawnDocument => {
246
270
  const waiting = document.activeElement === root;
247
- setDrawn(true);
271
+ batch(() => {
272
+ setDrawn(true);
273
+ setReplacing(false);
274
+ });
248
275
  if (waiting) root?.querySelector(".k2b-pdf-viewer__pages")?.focus();
249
276
  props.onReady?.(drawnDocument);
250
277
  },
@@ -253,7 +280,7 @@ export default function PdfViewer(props) {
253
280
  return props.onPage;
254
281
  }
255
282
  })
256
- }), _el$5, _co$);
283
+ }), _el$6, _co$);
257
284
  _$insert(_el$2, _$createComponent(Show, {
258
285
  get when() {
259
286
  return status();
@@ -276,29 +303,40 @@ export default function PdfViewer(props) {
276
303
  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;
277
304
  }
278
305
  })
279
- }), _el$7, _co$2);
306
+ }), _el$8, _co$2);
307
+ _$insert(_el$2, _$createComponent(Show, {
308
+ get when() {
309
+ return quiet();
310
+ },
311
+ get children() {
312
+ return _$getNextElement(_tmpl$2);
313
+ }
314
+ }), _el$0, _co$3);
280
315
  _$insert(_el$2, _$createComponent(Show, {
281
316
  get when() {
282
317
  return tabBlocked();
283
318
  },
284
319
  get children() {
285
- var _el$3 = _$getNextElement(_tmpl$2);
286
- _$insert(_el$3, () => pdfMessages().pdfPreviewTabBlocked);
287
- return _el$3;
320
+ var _el$4 = _$getNextElement(_tmpl$3);
321
+ _$insert(_el$4, () => pdfMessages().pdfPreviewTabBlocked);
322
+ return _el$4;
288
323
  }
289
- }), _el$9, _co$3);
324
+ }), _el$10, _co$4);
290
325
  _$effect(_p$ => {
291
326
  var _v$ = `k2b-pdf-viewer ${props.class ?? ""}`,
292
327
  _v$2 = status() ?? "shown",
293
- _v$3 = status() ? -1 : undefined;
328
+ _v$3 = status() ? -1 : undefined,
329
+ _v$4 = busy() ? "true" : undefined;
294
330
  _v$ !== _p$.e && _$className(_el$2, _p$.e = _v$);
295
331
  _v$2 !== _p$.t && _$setAttribute(_el$2, "data-state", _p$.t = _v$2);
296
332
  _v$3 !== _p$.a && _$setAttribute(_el$2, "tabindex", _p$.a = _v$3);
333
+ _v$4 !== _p$.o && _$setAttribute(_el$2, "aria-busy", _p$.o = _v$4);
297
334
  return _p$;
298
335
  }, {
299
336
  e: undefined,
300
337
  t: undefined,
301
- a: undefined
338
+ a: undefined,
339
+ o: undefined
302
340
  });
303
341
  return _el$2;
304
342
  })();
@@ -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,CA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EnB,MAAM;UAAA,OACJ,qBAAK,CAAC,CAAC,KAAK,MAAM,IAAI,QAAQ,CAAC,CAAC,OAC5B,MAAM,CAAC,KAAK,CAAC,SAAS,IAAI,WAAW,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,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;QAAA;MAAA;IAGtB;IAAA,kCAEF,IAAI;MAAA,IAAC,IAAI;QAAA,OAAE,UAAU,CAAC,CAAC;MAAA;MAAA;QAAA;QAAA,sBAEnB,WAAW,CAAC,CAAC,CAAC,oBAAoB;QAAA;MAAA;IAAA;IAAA;MAAA,UAxDhC,kBAAkB,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE;QAAA,OAChC,MAAM,CAAC,CAAC,IAAI,OAAO;QAAA,OAErB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS;MAAA;MAAA;MAAA;MAAA;IAAA;MAAA;MAAA;MAAA;IAAA;IAAA;EAAA;AA0DzC;AAAC","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>\n </Show>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,KAAK,EAAE,YAAY,EAAE,YAAY,EAAY,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,QAAQ,UAAU;AACjG,SAAS,QAAQ,QAAQ,sBAAsB;AAC/C,SAAS,aAAa,QAAQ,kBAAkB;AAChD,OAAO,WAAW,MAAM,yBAAyB;AAEjD,SAAS,kBAAkB,EAAE,cAAc,QAAQ,gBAAgB;;AAEnE;;AAwDA,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,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