@react-pdf-kit/viewer 2.0.0-beta.11 → 2.0.0-beta.12

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 (181) hide show
  1. package/dist/{Combination-54a77a7a.js → Combination-136ff99c.js} +184 -187
  2. package/dist/Paginate.module-4eef00aa.js +8 -0
  3. package/dist/RPLayout.module-b4b23e29.js +14 -0
  4. package/dist/RPSplitter-f6acf13b.js +71 -0
  5. package/dist/ToolbarLayout.module-6e339802.js +12 -0
  6. package/dist/assets/style.css +1 -1
  7. package/dist/assets/style.js +32 -30
  8. package/dist/components/RPController.js +1 -1
  9. package/dist/components/RPDropFileZone.js +1 -1
  10. package/dist/components/RPPages.js +544 -497
  11. package/dist/components/RPProvider.js +32 -22
  12. package/dist/components/icons/DualPageWithCoverIcon.js +22 -0
  13. package/dist/components/layout/LayoutContainer.js +1 -1
  14. package/dist/components/layout/LayoutWrapper.js +1 -1
  15. package/dist/components/layout/RPDefaultLayout.js +58 -36
  16. package/dist/components/layout/RPLayout.js +32 -28
  17. package/dist/components/layout/SkipLink.js +29 -0
  18. package/dist/components/layout/WrapperLayout.js +1 -1
  19. package/dist/components/layout/sidebar/RPSidebar.js +32 -37
  20. package/dist/components/layout/sidebar/RPSplitter.js +6 -59
  21. package/dist/components/layout/sidebar/Thumbnail.js +57 -48
  22. package/dist/components/layout/sidebar/Thumbnails.js +9 -9
  23. package/dist/components/layout/toolbar/DarkModeTool.js +1 -1
  24. package/dist/components/layout/toolbar/DocumentDialog.js +28 -28
  25. package/dist/components/layout/toolbar/DocumentProperties.js +3 -3
  26. package/dist/components/layout/toolbar/FileDownloadTool.js +3 -3
  27. package/dist/components/layout/toolbar/FileUploadTool.js +3 -3
  28. package/dist/components/layout/toolbar/FullScreenTool.js +3 -3
  29. package/dist/components/layout/toolbar/MenuItem.js +2 -2
  30. package/dist/components/layout/toolbar/MenuSeparator.js +2 -2
  31. package/dist/components/layout/toolbar/MostPageTool.js +3 -3
  32. package/dist/components/layout/toolbar/OtherTool.js +43 -34
  33. package/dist/components/layout/toolbar/Paginate.js +53 -46
  34. package/dist/components/layout/toolbar/PrintTool.js +3 -3
  35. package/dist/components/layout/toolbar/RPMenuItem.js +2 -2
  36. package/dist/components/layout/toolbar/RPMoreOptions.js +45 -44
  37. package/dist/components/layout/toolbar/RPToolbar.js +7 -6
  38. package/dist/components/layout/toolbar/RPToolbarEnd.js +6 -5
  39. package/dist/components/layout/toolbar/RotateTool.js +3 -3
  40. package/dist/components/layout/toolbar/ScrollModeTool.js +37 -37
  41. package/dist/components/layout/toolbar/SearchCloseButton.js +1 -1
  42. package/dist/components/layout/toolbar/SearchResultNavigator.js +44 -24
  43. package/dist/components/layout/toolbar/SearchTool.js +138 -117
  44. package/dist/components/layout/toolbar/SelectionModeTool.js +3 -3
  45. package/dist/components/layout/toolbar/ThumbnailTool.js +1 -1
  46. package/dist/components/layout/toolbar/ToolbarCustom.js +43 -27
  47. package/dist/components/layout/toolbar/ToolbarDefault.js +42 -33
  48. package/dist/components/layout/toolbar/ToolbarLayout.js +9 -8
  49. package/dist/components/layout/toolbar/ViewModeTool.js +43 -34
  50. package/dist/components/layout/toolbar/ZoomTool.js +3 -3
  51. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +2 -2
  52. package/dist/components/layout/toolbar/tools/DualPageTool.js +3 -3
  53. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +202 -0
  54. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +6 -6
  55. package/dist/components/layout/toolbar/tools/FileUploadTool.js +5 -5
  56. package/dist/components/layout/toolbar/tools/FirstPageTool.js +197 -0
  57. package/dist/components/layout/toolbar/tools/FullScreenTool.js +16 -15
  58. package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +37 -0
  59. package/dist/components/layout/toolbar/tools/InputPageTool.js +35 -28
  60. package/dist/components/layout/toolbar/tools/LastPageTool.js +197 -0
  61. package/dist/components/layout/toolbar/tools/NextPageTool.js +9 -8
  62. package/dist/components/layout/toolbar/tools/PageScrollingTool.js +37 -0
  63. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +15 -14
  64. package/dist/components/layout/toolbar/tools/PrintTool.js +4 -4
  65. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +12 -5
  66. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +9 -9
  67. package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +18 -10
  68. package/dist/components/layout/toolbar/tools/SinglePageTool.js +2 -2
  69. package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +10 -2
  70. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +13 -12
  71. package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +37 -0
  72. package/dist/components/layout/toolbar/tools/ZoomInTool.js +15 -14
  73. package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +1 -1
  74. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +75 -41
  75. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +12 -11
  76. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +7 -6
  77. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +1 -1
  78. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +11 -11
  79. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +22 -15
  80. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +20 -13
  81. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +22 -14
  82. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +35 -19
  83. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +21 -14
  84. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +33 -19
  85. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +54 -36
  86. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +39 -23
  87. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +52 -29
  88. package/dist/components/page/AnnotationLayer.js +76 -69
  89. package/dist/components/page/CanvasLayer.js +1 -1
  90. package/dist/components/page/CustomElement.js +1 -1
  91. package/dist/components/page/DualPage.js +1 -1
  92. package/dist/components/page/DualPageWithCover.js +131 -0
  93. package/dist/components/page/RPPage.js +1 -1
  94. package/dist/components/page/SinglePage.js +1 -1
  95. package/dist/components/page/TextHighlightLayer.js +1 -1
  96. package/dist/components/page/TextLayer.js +1 -1
  97. package/dist/components/ui/Button.js +14 -12
  98. package/dist/components/ui/Checkbox.js +84 -77
  99. package/dist/components/ui/DropDown.js +2 -2
  100. package/dist/components/ui/Input.js +12 -11
  101. package/dist/components/ui/LoadingIndicator.js +1 -1
  102. package/dist/components/ui/PasswordModal.js +44 -30
  103. package/dist/contexts/DimensionPagesContext.js +1 -1
  104. package/dist/contexts/DropFileZoneContext.js +1 -1
  105. package/dist/contexts/ElementPageContext.js +1 -1
  106. package/dist/contexts/EventCallbackContext.js +12 -8
  107. package/dist/contexts/FileInputContext.js +1 -1
  108. package/dist/contexts/HighlightContext.js +1 -1
  109. package/dist/contexts/LocalizationContext.js +1 -1
  110. package/dist/contexts/PagesRotateContext.js +1 -1
  111. package/dist/contexts/PaginationContext.js +1 -1
  112. package/dist/contexts/PrintContext.js +1 -1
  113. package/dist/contexts/RPDocumentContext.js +1 -1
  114. package/dist/contexts/RenderQueueProvider.js +1 -1
  115. package/dist/contexts/RotationContext.js +1 -1
  116. package/dist/contexts/ScrollModeContext.js +1 -1
  117. package/dist/contexts/SearchContext.js +1 -1
  118. package/dist/contexts/SelectionModeContext.js +1 -1
  119. package/dist/contexts/ThumbnailsContext.js +1 -1
  120. package/dist/contexts/ViewModeContext.js +19 -15
  121. package/dist/contexts/ZoomContext.js +1 -1
  122. package/dist/de_DE-a553b162.js +489 -0
  123. package/dist/{index-4baea9b5.js → index-61f59539.js} +1 -1
  124. package/dist/main.js +115 -99
  125. package/dist/types/components/icons/DualPageWithCoverIcon.d.ts +2 -0
  126. package/dist/types/components/layout/LayoutContainer.d.ts +1 -5
  127. package/dist/types/components/layout/LayoutWrapper.d.ts +1 -5
  128. package/dist/types/components/layout/SkipLink.d.ts +7 -0
  129. package/dist/types/components/layout/sidebar/Thumbnails.d.ts +1 -3
  130. package/dist/types/components/layout/toolbar/RPToolbar.d.ts +1 -3
  131. package/dist/types/components/layout/toolbar/tools/DualPageWithCoverTool.d.ts +3 -0
  132. package/dist/types/components/layout/toolbar/tools/FirstPageTool.d.ts +3 -0
  133. package/dist/types/components/layout/toolbar/tools/HorizontalScrollingTool.d.ts +3 -0
  134. package/dist/types/components/layout/toolbar/tools/LastPageTool.d.ts +3 -0
  135. package/dist/types/components/layout/toolbar/tools/PageScrollingTool.d.ts +3 -0
  136. package/dist/types/components/layout/toolbar/tools/VerticalScrollingTool.d.ts +3 -0
  137. package/dist/types/components/page/DualPageWithCover.d.ts +5 -0
  138. package/dist/types/components/page/RPPage.d.ts +1 -3
  139. package/dist/types/components/ui/Button.d.ts +1 -3
  140. package/dist/types/components/ui/Checkbox.d.ts +1 -0
  141. package/dist/types/components/ui/Input.d.ts +1 -3
  142. package/dist/types/components/ui/RPTooltip.d.ts +1 -3
  143. package/dist/types/locales/de_DE.json.d.ts +83 -0
  144. package/dist/types/locales/en_US.json.d.ts +2 -0
  145. package/dist/types/locales/it_IT.json.d.ts +2 -0
  146. package/dist/types/locales/pt_PT.json.d.ts +2 -0
  147. package/dist/types/locales/th_TH.json.d.ts +2 -0
  148. package/dist/types/locales/zh_CN.json.d.ts +2 -0
  149. package/dist/types/main.d.ts +7 -1
  150. package/dist/types/utils/annotations.d.ts +10 -1
  151. package/dist/types/utils/calculatePage.d.ts +3 -3
  152. package/dist/types/utils/hooks/usePresentPage.d.ts +2 -1
  153. package/dist/types/utils/hooks/useTextSelection.d.ts +7 -0
  154. package/dist/types/utils/types.d.ts +34 -3
  155. package/dist/types/utils/withRef.d.ts +5 -4
  156. package/dist/utils/annotations.js +145 -150
  157. package/dist/utils/calculatePage.js +17 -11
  158. package/dist/utils/getZoomLevel.js +9 -9
  159. package/dist/utils/highlight.js +139 -139
  160. package/dist/utils/hooks/useFileDownload.js +1 -1
  161. package/dist/utils/hooks/useLicense.js +1 -1
  162. package/dist/utils/hooks/useLoadPdf.js +1 -1
  163. package/dist/utils/hooks/useLocalization.js +12 -11
  164. package/dist/utils/hooks/usePageRotateContext.js +1 -1
  165. package/dist/utils/hooks/usePaginate.js +1 -1
  166. package/dist/utils/hooks/usePinch.js +1 -1
  167. package/dist/utils/hooks/usePresentPage.js +45 -45
  168. package/dist/utils/hooks/usePrint.js +1 -1
  169. package/dist/utils/hooks/useRotate.js +1 -1
  170. package/dist/utils/hooks/useScrollToPage.js +1 -1
  171. package/dist/utils/hooks/useSearch.js +76 -62
  172. package/dist/utils/hooks/useTextSelection.js +76 -0
  173. package/dist/utils/hooks/useThumbnail.js +1 -1
  174. package/dist/utils/hooks/useVirtualReactWindow.js +60 -42
  175. package/dist/utils/types.js +14 -13
  176. package/dist/utils/withRef.js +5 -5
  177. package/package.json +2 -3
  178. package/dist/Paginate.module-206a7d7d.js +0 -8
  179. package/dist/RPLayout.module-967bf4bc.js +0 -13
  180. package/dist/ToolbarLayout.module-1fee0a18.js +0 -11
  181. package/dist/th_TH-d627cd51.js +0 -398
@@ -1 +1,2 @@
1
- export declare const usePresentPage: (totalColumns: number, totalRows: number, element?: HTMLElement) => void;
1
+ import { ViewMode } from '../types';
2
+ export declare const usePresentPage: (totalColumns: number, totalRows: number, element?: HTMLElement, viewMode?: ViewMode) => void;
@@ -0,0 +1,7 @@
1
+ import { TextSelectionData } from '../types';
2
+ interface UseTextSelectionOptions {
3
+ onTextSelect?: (selection: TextSelectionData | null) => void;
4
+ pagesRef: HTMLElement | null;
5
+ }
6
+ export declare const useTextSelection: ({ onTextSelect, pagesRef }: UseTextSelectionOptions) => void;
7
+ export {};
@@ -64,7 +64,7 @@ export interface OutlineDestinationName {
64
64
  name: string;
65
65
  }
66
66
  export type OutlineDestination = [
67
- OutlineRef | number,
67
+ (OutlineRef | number),
68
68
  OutlineDestinationName,
69
69
  ...any[]
70
70
  ];
@@ -129,6 +129,8 @@ export type Localization = {
129
129
  singlePageTooltip?: string;
130
130
  dualPageLabel?: string;
131
131
  dualPageTooltip?: string;
132
+ dualPageWithCoverLabel?: string;
133
+ dualPageWithCoverTooltip?: string;
132
134
  documentPropertiesLabel?: string;
133
135
  documentPropertiesTooltip?: string;
134
136
  propertiesFilenameLabel?: string;
@@ -294,7 +296,8 @@ export interface ThumbnailRenderedList {
294
296
  }
295
297
  export declare enum ViewMode {
296
298
  SINGLE_PAGE = "Single",
297
- DUAL_PAGE = "Dual"
299
+ DUAL_PAGE = "Dual",
300
+ DUAL_PAGE_WITH_COVER = "DualWithCover"
298
301
  }
299
302
  export type PDFSrc = string | URL | TypedArray | PDFDataRangeTransport | DocumentInitParameters | undefined | null;
300
303
  export type RPSrc = Omit<PDFSrc, 'DocumentInitParameters' | 'PDFDataRangeTransport'>;
@@ -447,7 +450,11 @@ export declare enum ThemeVariables {
447
450
  CONTAINER_FOCUS_OUTLINE_WIDTH = "--rp-container-focus-outline-width",
448
451
  CONTAINER_FOCUS_OUTLINE_COLOR = "--rp-container-focus-outline-color",
449
452
  CONTAINER_FOCUS_OUTLINE_OFFSET = "--rp-container-focus-outline-offset",
450
- BUTTON_BORDER_RADIUS = "--rp-button-border-radius"
453
+ BUTTON_BORDER_RADIUS = "--rp-button-border-radius",
454
+ SKIP_LINK_FONT_SIZE = "--rp-skip-link-font-size",
455
+ SKIP_LINK_COLOR = "--rp-skip-link-color",
456
+ SKIP_LINK_BACKGROUND_COLOR = "--rp-skip-link-background-color",
457
+ SKIP_LINK_BORDER_COLOR = "--rp-skip-link-border-color"
451
458
  }
452
459
  export interface DarkModeProviderProps extends PropsWithChildren, Partial<Omit<DarkMode, 'setDarkMode'>> {
453
460
  }
@@ -462,10 +469,29 @@ export interface CharacterMap {
462
469
  url: string;
463
470
  isCompressed: boolean;
464
471
  }
472
+ interface Dimension {
473
+ width: number;
474
+ height: number;
475
+ }
476
+ interface Point {
477
+ x: number;
478
+ y: number;
479
+ }
480
+ export interface PageSelectionRect {
481
+ pageNumber: number;
482
+ pageBasedBoundingRects: Array<Dimension & RectPosition>;
483
+ pageDimension: Dimension;
484
+ pagePositionInWindow: Point;
485
+ }
486
+ export interface TextSelectionData {
487
+ text: string;
488
+ pageSelections: PageSelectionRect[];
489
+ }
465
490
  export interface EventCallbackContextType {
466
491
  onPageChange?: (page: number) => void;
467
492
  onRotate?: (rotation: Record<number, number>) => void;
468
493
  onScroll?: (scroll: Event) => void;
494
+ onTextSelect?: (selection: TextSelectionData | null) => void;
469
495
  }
470
496
  export interface RPProviderProps extends PropsWithChildren, LoadPDFOptions, RPControllerProps, EventCallbackContextType {
471
497
  src: RPSrc;
@@ -527,6 +553,7 @@ export interface ViewModeContextType {
527
553
  columnCount: number;
528
554
  setSinglePage: () => void;
529
555
  setDualPage: () => void;
556
+ setDualPageWithCover: () => void;
530
557
  viewMode: ViewMode;
531
558
  }
532
559
  export interface ViewModeInitialProps {
@@ -573,6 +600,7 @@ export interface Match {
573
600
  oIndex: number;
574
601
  pageIndex: number;
575
602
  rect: RectPosition;
603
+ rects?: RectPosition[];
576
604
  }
577
605
  export interface MatchValue extends Match {
578
606
  page: number;
@@ -785,6 +813,7 @@ export interface RPHorizontalBarIcons {
785
813
  rotateCounterClockwiseIcon?: React.ReactNode;
786
814
  singlePageIcon?: React.ReactNode;
787
815
  dualPageIcon?: React.ReactNode;
816
+ dualPageWithCoverIcon?: React.ReactNode;
788
817
  pageScrollIcon?: React.ReactNode;
789
818
  verticalScrollIcon?: React.ReactNode;
790
819
  horizontalScrollIcon?: React.ReactNode;
@@ -833,6 +862,7 @@ export interface RPMoreOptionsIcons {
833
862
  handModeIcon?: React.ReactNode;
834
863
  singlePageIcon?: React.ReactNode;
835
864
  dualPageIcon?: React.ReactNode;
865
+ dualPageWithCoverIcon?: React.ReactNode;
836
866
  pageScrollIcon?: React.ReactNode;
837
867
  verticalScrollIcon?: React.ReactNode;
838
868
  horizontalScrollIcon?: React.ReactNode;
@@ -874,6 +904,7 @@ export interface SelectionModeProps extends ToolVisible {
874
904
  export interface ViewModeIcons {
875
905
  singlePageIcon: React.ReactNode;
876
906
  dualPageIcon: React.ReactNode;
907
+ dualPageWithCoverIcon?: React.ReactNode;
877
908
  }
878
909
  export interface ViewModeProps extends ToolVisible {
879
910
  icons?: ViewModeIcons;
@@ -1,4 +1,5 @@
1
- import { ForwardRefRenderFunction, PropsWithoutRef, Ref } from 'react';
2
- export declare const withRef: <R extends HTMLElement, P = object>(render: ForwardRefRenderFunction<R, PropsWithoutRef<P>>) => import('react').ForwardRefExoticComponent<PropsWithoutRef<P> & import('react').RefAttributes<R>> | ((props: PropsWithoutRef<P> & {
3
- ref?: Ref<R>;
4
- }) => import('react').ReactNode);
1
+ import { ForwardRefExoticComponent, RefAttributes, PropsWithoutRef, Ref, ReactElement } from 'react';
2
+ type WithRefRender<R extends HTMLElement, P> = (props: PropsWithoutRef<P>, ref: Ref<R>) => ReactElement | null;
3
+ type WithRefComponent<R extends HTMLElement, P> = ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<R>>;
4
+ export declare const withRef: <R extends HTMLElement, P = object>(render: WithRefRender<R, P>) => WithRefComponent<R, P>;
5
+ export {};
@@ -1,22 +1,22 @@
1
- import { sanitizeExternalUrl as I } from "./sanitizeExternalUrl.js";
1
+ import { sanitizeExternalUrl as x } from "./sanitizeExternalUrl.js";
2
2
  import { AnnotationType as l } from "./types.js";
3
- import { dateFormatter as B } from "./dateFormatter.js";
4
- import "../th_TH-d627cd51.js";
5
- const v = ["click", "dblclick", "input", "change", "mouseover"], g = /* @__PURE__ */ new Map(), x = (e, t) => `${e.loadingTask.docId}___${t.num}R${t.gen === 0 ? "" : t.gen}`;
6
- function C(e, t) {
7
- const n = x(e, t);
8
- return g.has(n) ? g.get(n) ?? null : null;
3
+ import { dateFormatter as T } from "./dateFormatter.js";
4
+ import "../de_DE-a553b162.js";
5
+ const p = ["click", "dblclick", "input", "change", "mouseover"], b = /* @__PURE__ */ new Map(), h = (e, s) => `${e.loadingTask.docId}___${s.num}R${s.gen === 0 ? "" : s.gen}`;
6
+ function y(e, s) {
7
+ const t = h(e, s);
8
+ return b.has(t) ? b.get(t) ?? null : null;
9
9
  }
10
- const S = (e, t, n) => {
11
- g.set(x(e, t), n);
12
- }, T = (e, t) => {
13
- switch (t[1].name) {
10
+ const O = (e, s, t) => {
11
+ b.set(h(e, s), t);
12
+ }, g = (e, s) => {
13
+ switch (s[1].name) {
14
14
  case "XYZ":
15
15
  return {
16
- bottomOffset: (n, s) => t[3] === null ? s : t[3],
17
- leftOffset: (n, s) => t[2] === null ? 0 : t[2],
16
+ bottomOffset: (t, n) => s[3] === null ? n : s[3],
17
+ leftOffset: (t, n) => s[2] === null ? 0 : s[2],
18
18
  pageIndex: e,
19
- scaleTo: t[4]
19
+ scaleTo: s[4]
20
20
  };
21
21
  case "Fit":
22
22
  case "FitB":
@@ -29,7 +29,7 @@ const S = (e, t, n) => {
29
29
  case "FitH":
30
30
  case "FitBH":
31
31
  return {
32
- bottomOffset: t[2],
32
+ bottomOffset: s[2],
33
33
  leftOffset: 0,
34
34
  pageIndex: e,
35
35
  scaleTo: 1
@@ -42,132 +42,126 @@ const S = (e, t, n) => {
42
42
  scaleTo: 1
43
43
  };
44
44
  }
45
- }, M = (e) => {
45
+ }, E = (e) => {
46
46
  e && (() => {
47
- const n = e == null ? void 0 : e.querySelectorAll(
47
+ const t = e == null ? void 0 : e.querySelectorAll(
48
48
  '[data-l10n-id="pdfjs-annotation-date-time-string"]'
49
49
  );
50
- n == null || n.forEach((s) => {
51
- const { date: a, time: o, dateObj: i } = JSON.parse(s.dataset.l10nArgs ?? "{}");
52
- a && o ? s.textContent = `${a}, ${o}` : i && (s.textContent = B(i));
50
+ t == null || t.forEach((n) => {
51
+ const { date: o, time: a, dateObj: i } = JSON.parse(n.dataset.l10nArgs ?? "{}");
52
+ o && a ? n.textContent = `${o}, ${a}` : i && (n.textContent = T(i));
53
53
  });
54
54
  })();
55
55
  };
56
- async function E(e, t) {
57
- let n;
58
- if (typeof t == "string" ? n = await e.getDestination(t) : n = t, n && typeof n[0] == "object" && n[0] !== null) {
59
- const s = n[0], a = C(e, s);
60
- if (a === null) {
61
- const o = await e.getPageIndex(s);
62
- return S(e, s, o), await E(e, n);
56
+ async function N(e, s) {
57
+ let t;
58
+ if (typeof s == "string" ? t = await e.getDestination(s) : t = s, t && typeof t[0] == "object" && t[0] !== null) {
59
+ const n = t[0], o = y(e, n);
60
+ if (o === null) {
61
+ const a = await e.getPageIndex(n);
62
+ return O(e, n, a), await N(e, t);
63
63
  } else
64
- return T(a, n);
64
+ return g(o, t);
65
65
  } else
66
- return T(n[0], n);
66
+ return g(t[0], t);
67
67
  }
68
- function P(e, t) {
69
- for (const n of v)
70
- e.addEventListener(n, t);
68
+ function L(e, s) {
69
+ for (const t of p)
70
+ e.addEventListener(t, s);
71
71
  }
72
- function $(e, t) {
73
- for (const n of v)
74
- e.removeEventListener(n, t);
72
+ function C(e, s) {
73
+ for (const t of p)
74
+ e.removeEventListener(t, s);
75
75
  }
76
- function D(e) {
77
- const { id: t, url: n, unsafeUrl: s } = e;
78
- new MutationObserver((o, i) => {
79
- const c = document.querySelector(`[data-annotation-id="${t}"]`);
76
+ function R(e) {
77
+ const { id: s, url: t, unsafeUrl: n } = e;
78
+ new MutationObserver((a, i) => {
79
+ const c = document.querySelector(`[data-annotation-id="${s}"]`);
80
80
  if (c) {
81
- const r = c.querySelector("a"), p = I((n || s) ?? "", "");
82
- r && (r == null || r.setAttribute("target", "_blank"), r == null || r.setAttribute("href", p), r == null || r.setAttribute("rel", "noopener noreferrer")), i.disconnect();
81
+ const r = c.querySelector("a"), A = x((t || n) ?? "", "");
82
+ r && (r == null || r.setAttribute("target", "_blank"), r == null || r.setAttribute("href", A), r == null || r.setAttribute("rel", "noopener noreferrer")), i.disconnect();
83
83
  }
84
84
  }).observe(document.body, { childList: !0, subtree: !0 });
85
85
  }
86
- function U(e, t, n) {
87
- const { rotation: s, scale: a } = t, o = s % 180 === 0;
86
+ function F(e, s, t) {
87
+ const { rotation: n, scale: o } = s, a = n % 180 === 0;
88
88
  if (e.fieldType === "Btn" && e.pushButton) {
89
89
  const i = e.rect[2] - e.rect[0], c = e.rect[3] - e.rect[1], r = document.createElement("canvas");
90
- r.setAttribute("width", ((o ? i : c) * a).toString()), r.setAttribute("height", ((o ? c : i) * a).toString()), n.set(e.id, r);
90
+ r.setAttribute("width", ((a ? i : c) * o).toString()), r.setAttribute("height", ((a ? c : i) * o).toString()), t.set(e.id, r);
91
91
  }
92
92
  }
93
- function V(e) {
94
- var o;
95
- let t = e;
96
- for (; t.tagName !== "SECTION"; )
97
- t = t.parentElement;
98
- const n = t.getAttribute("aria-haspopup") === "dialog", s = t.classList.contains("popupAnnotation");
99
- if (!n && !s)
100
- return;
101
- let a = t.id || t.getAttribute("aria-controls");
102
- if (a || (a = (o = t.firstChild) == null ? void 0 : o.id), a && t.parentElement) {
103
- const i = t.parentElement.querySelector(`[aria-controls="${a}"]`);
104
- i && new MutationObserver((r, p) => {
105
- const b = document.querySelectorAll(".popupDate");
106
- b.length > 0 && (b.forEach((m) => {
107
- if (m.innerHTML)
108
- return !1;
109
- const N = m.getAttribute("data-l10n-args");
110
- if (N) {
111
- const { date: h, time: O, dateObj: A } = JSON.parse(N);
112
- if (h && O)
113
- m.textContent = `${h}, ${O}`;
114
- else if (A) {
115
- const _ = new Date(A);
116
- m.textContent = _.toLocaleString();
117
- }
93
+ function S(e) {
94
+ e.querySelectorAll("[tabindex]").forEach((t) => {
95
+ const n = t.getAttribute("tabindex");
96
+ n && parseInt(n, 10) > 0 && (t.tagName === "A" || t.tagName === "BUTTON" || t.getAttribute("role") === "button" || t.getAttribute("role") === "link" || t.classList.contains("linkAnnotation") ? t.setAttribute("tabindex", "0") : t.removeAttribute("tabindex"));
97
+ });
98
+ }
99
+ function U(e) {
100
+ e.querySelectorAll("a").forEach((t) => {
101
+ const n = t.textContent && t.textContent.trim().length > 0, o = t.getAttribute("aria-label");
102
+ if (!n && !o) {
103
+ const a = t.getAttribute("href") || "";
104
+ let i;
105
+ if (!a || a.startsWith("#") || a.startsWith("javascript:"))
106
+ i = "Link to page in document";
107
+ else
108
+ try {
109
+ i = `External link to ${new URL(a, window.location.href).hostname.replace("www.", "")}`;
110
+ } catch {
111
+ i = "External link";
118
112
  }
119
- }), p.disconnect());
120
- }).observe(i, { childList: !0, subtree: !0 });
121
- }
113
+ t.setAttribute("aria-label", i);
114
+ }
115
+ });
122
116
  }
123
- function d(e, t, n) {
124
- const s = [];
125
- if (n)
126
- for (const a of n)
127
- a[e] === t && s.push(a);
128
- return s;
117
+ function d(e, s, t) {
118
+ const n = [];
119
+ if (t)
120
+ for (const o of t)
121
+ o[e] === s && n.push(o);
122
+ return n;
129
123
  }
130
- function u(e, t) {
131
- return { type: e, data: t };
124
+ function u(e, s) {
125
+ return { type: e, data: s };
132
126
  }
133
- async function k(e, t) {
127
+ async function I(e, s) {
134
128
  if (e.dest)
135
129
  if (typeof e.dest == "string") {
136
- const n = await E(t, e.dest);
130
+ const t = await N(s, e.dest);
137
131
  return u(l.INTERNAL_LINK, {
138
- referencedPage: n.pageIndex,
132
+ referencedPage: t.pageIndex,
139
133
  offset: null
140
134
  });
141
135
  } else {
142
- const n = await t.getPageIndex(e.dest[0]);
136
+ const t = await s.getPageIndex(e.dest[0]);
143
137
  return u(l.INTERNAL_LINK, {
144
- referencedPage: n,
138
+ referencedPage: t,
145
139
  offset: {
146
140
  left: e.dest[2],
147
141
  bottom: e.dest[3]
148
142
  }
149
143
  });
150
144
  }
151
- else if (e.url)
145
+ else if (e.url || e.unsafeUrl)
152
146
  return u(l.LINK, {
153
- url: e.url,
147
+ url: e.url ?? e.unsafeUrl,
154
148
  unsafeUrl: e.unsafeUrl
155
149
  });
156
150
  }
157
- function y(e) {
158
- for (const t of e.getElementsByTagName("span")) {
159
- let n = t.textContent;
160
- const s = JSON.parse(t.dataset.l10nArgs ?? "{}");
161
- if (n)
162
- for (const a in s)
163
- n = n.replace(`{{${a}}}`, s[a]);
164
- t.textContent = n;
151
+ function m(e) {
152
+ for (const s of e.getElementsByTagName("span")) {
153
+ let t = s.textContent;
154
+ const n = JSON.parse(s.dataset.l10nArgs ?? "{}");
155
+ if (t)
156
+ for (const o in n)
157
+ t = t.replace(`{{${o}}}`, n[o]);
158
+ s.textContent = t;
165
159
  }
166
160
  }
167
- function w(e) {
161
+ function v(e) {
168
162
  return u(l.FILE_ATTACHMENT, e.file);
169
163
  }
170
- function f(e, t) {
164
+ function f(e, s) {
171
165
  switch (e.type) {
172
166
  case "textarea":
173
167
  case "text":
@@ -177,22 +171,22 @@ function f(e, t) {
177
171
  });
178
172
  case "select-one":
179
173
  case "select-multiple":
174
+ const t = [];
175
+ for (const o of e.options)
176
+ t.push({
177
+ value: o.value,
178
+ label: o.label
179
+ });
180
180
  const n = [];
181
- for (const a of e.options)
181
+ for (const o of e.selectedOptions)
182
182
  n.push({
183
- value: a.value,
184
- label: a.label
185
- });
186
- const s = [];
187
- for (const a of e.selectedOptions)
188
- s.push({
189
- value: a.value,
190
- label: a.label
183
+ value: o.value,
184
+ label: o.label
191
185
  });
192
186
  return u(l.FORM_SELECT, {
193
187
  fieldName: e.name,
194
- value: s,
195
- options: n
188
+ value: n,
189
+ options: t
196
190
  });
197
191
  case "checkbox":
198
192
  return u(l.FORM_CHECKBOX, {
@@ -202,64 +196,64 @@ function f(e, t) {
202
196
  case "radio":
203
197
  return u(l.FORM_RADIO, {
204
198
  fieldName: e.name,
205
- ...t
199
+ ...s
206
200
  });
207
201
  case "button":
208
202
  return u(l.FORM_BUTTON, {
209
203
  fieldName: e.name,
210
- ...t
204
+ ...s
211
205
  });
212
206
  }
213
207
  }
214
- async function j(e, t, n) {
215
- var a;
216
- let s = e.target.parentNode;
217
- if (s.tagName === "DIV" && (s = s.firstChild), typeof s.className != "object")
218
- if (s.className === "linkAnnotation" && e.type === "click") {
219
- const o = (a = s.dataset) == null ? void 0 : a.annotationId;
220
- if (o) {
221
- const i = d("id", o, n);
208
+ async function W(e, s, t) {
209
+ var o;
210
+ let n = e.target.parentNode;
211
+ if (n.tagName === "DIV" && (n = n.firstChild), typeof n.className != "object")
212
+ if (n.className === "linkAnnotation" && e.type === "click") {
213
+ const a = (o = n.dataset) == null ? void 0 : o.annotationId;
214
+ if (a) {
215
+ const i = d("id", a, t);
222
216
  if (i.length)
223
- return await k(i[0], t);
217
+ return await I(i[0], s);
224
218
  }
225
219
  } else if (
226
220
  /* annotation.className.includes('popupAnnotation') || */
227
- s.className.includes("textAnnotation")
221
+ n.className.includes("textAnnotation")
228
222
  )
229
- y(s);
230
- else if (s.className.includes("fileAttachmentAnnotation")) {
231
- y(s);
232
- const o = s.dataset.annotationId;
233
- if (o && e.type === "dblclick")
234
- return w(d("id", o, n)[0]);
235
- } else if (s.className.includes("textWidgetAnnotation") && e.type === "input") {
236
- let o = s.getElementsByTagName("input")[0];
237
- return o || (o = s.getElementsByTagName("textarea")[0]), f(o);
223
+ m(n);
224
+ else if (n.className.includes("fileAttachmentAnnotation")) {
225
+ m(n);
226
+ const a = n.dataset.annotationId;
227
+ if (a && e.type === "dblclick")
228
+ return v(d("id", a, t)[0]);
229
+ } else if (n.className.includes("textWidgetAnnotation") && e.type === "input") {
230
+ let a = n.getElementsByTagName("input")[0];
231
+ return a || (a = n.getElementsByTagName("textarea")[0]), f(a);
238
232
  } else {
239
- if (s.className.includes("choiceWidgetAnnotation") && e.type === "input")
240
- return f(s.getElementsByTagName("select")[0]);
241
- if (s.className.includes("buttonWidgetAnnotation checkBox") && e.type === "change")
242
- return f(s.getElementsByTagName("input")[0]);
243
- if (s.className.includes("buttonWidgetAnnotation radioButton") && e.type === "change") {
244
- const o = s.dataset.annotationId;
245
- if (o) {
246
- const i = d("id", o, n)[0], c = [];
233
+ if (n.className.includes("choiceWidgetAnnotation") && e.type === "input")
234
+ return f(n.getElementsByTagName("select")[0]);
235
+ if (n.className.includes("buttonWidgetAnnotation checkBox") && e.type === "change")
236
+ return f(n.getElementsByTagName("input")[0]);
237
+ if (n.className.includes("buttonWidgetAnnotation radioButton") && e.type === "change") {
238
+ const a = n.dataset.annotationId;
239
+ if (a) {
240
+ const i = d("id", a, t)[0], c = [];
247
241
  for (const r of d(
248
242
  "fieldName",
249
243
  i.fieldName,
250
- n
244
+ t
251
245
  ))
252
246
  r.buttonValue && c.push(r.buttonValue);
253
- return f(s.getElementsByTagName("input")[0], {
247
+ return f(n.getElementsByTagName("input")[0], {
254
248
  value: i.buttonValue,
255
249
  defaultValue: i.fieldValue,
256
250
  options: c
257
251
  });
258
252
  }
259
- } else if (s.className.includes("buttonWidgetAnnotation pushButton") && e.type === "click") {
260
- const o = s.dataset.annotationId;
261
- if (o) {
262
- const i = d("id", o, n)[0], { action: c } = i;
253
+ } else if (n.className.includes("buttonWidgetAnnotation pushButton") && e.type === "click") {
254
+ const a = n.dataset.annotationId;
255
+ if (a) {
256
+ const i = d("id", a, t)[0], { action: c } = i;
263
257
  return c && ["Print", "SaveAs"].includes(c) ? { type: l.BUTTON, data: i } : i.resetForm ? f(
264
258
  { name: i.fieldName, type: "button" },
265
259
  { actions: i.actions, reset: !0 }
@@ -272,11 +266,12 @@ async function j(e, t, n) {
272
266
  }
273
267
  }
274
268
  export {
275
- j as annotationEventsHandler,
276
- P as bindLayerEvents,
277
- D as handleAnnotationLink,
278
- U as handleAnnotationWidget,
279
- V as handleAriaHasPopup,
280
- M as insertDateText,
281
- $ as unbindLayerEvents
269
+ W as annotationEventsHandler,
270
+ L as bindLayerEvents,
271
+ U as enhanceLinkAccessibility,
272
+ S as fixTabIndexAccessibility,
273
+ R as handleAnnotationLink,
274
+ F as handleAnnotationWidget,
275
+ E as insertDateText,
276
+ C as unbindLayerEvents
282
277
  };
@@ -1,15 +1,21 @@
1
- const d = (e, t, o) => e * o + t + 1, a = (e, t) => {
2
- const o = e - 1, n = Math.floor(o / t), s = (o - n * t) % t;
3
- return { rowIndex: n, columnIndex: s };
4
- }, h = (e, t) => {
5
- const o = [], n = [];
6
- return e.heights.forEach((s, c) => {
7
- const r = a(c + 1, t), i = e.widths[c];
8
- o[r.rowIndex] = Math.max(o[r.rowIndex] || 0, s), n[r.columnIndex] = Math.max(n[r.columnIndex] || 0, i);
9
- }), { rowsHeight: o, columnsWidth: n };
1
+ const d = (o, e, s, t = !1) => t ? o === 0 ? e === 0 ? 1 : -1 : 1 + (o - 1) * s + e + 1 : o * s + e + 1, g = (o, e, s = !1) => {
2
+ if (s) {
3
+ if (o === 1)
4
+ return { rowIndex: 0, columnIndex: 0 };
5
+ const n = o - 1 - 1, f = Math.floor(n / e) + 1, i = n % e;
6
+ return { rowIndex: f, columnIndex: i };
7
+ }
8
+ const t = o - 1, r = Math.floor(t / e), c = (t - r * e) % e;
9
+ return { rowIndex: r, columnIndex: c };
10
+ }, x = (o, e, s = !1) => {
11
+ const t = [], r = [];
12
+ return o.heights.forEach((c, a) => {
13
+ const n = g(a + 1, e, s), f = o.widths[a];
14
+ t[n.rowIndex] = Math.max(t[n.rowIndex] || 0, c), r[n.columnIndex] = Math.max(r[n.columnIndex] || 0, f);
15
+ }), { rowsHeight: t, columnsWidth: r };
10
16
  };
11
17
  export {
12
- h as getGridDimension,
18
+ x as getGridDimension,
13
19
  d as getPageFromPosition,
14
- a as getPositionFromPage
20
+ g as getPositionFromPage
15
21
  };
@@ -1,24 +1,24 @@
1
- import { SCROLL_BAR_WIDTH as n, PAGE_PADDING as f } from "./constants.js";
2
- import { ViewMode as i, ZoomLevel as r } from "./types.js";
3
- import "../th_TH-d627cd51.js";
4
- const D = (o, t, a, e, A, c) => {
1
+ import { SCROLL_BAR_WIDTH as a, PAGE_PADDING as f } from "./constants.js";
2
+ import { ViewMode as A, ZoomLevel as r } from "./types.js";
3
+ import "../de_DE-a553b162.js";
4
+ const E = (o, t, _, e, c, m) => {
5
5
  if (typeof o == "number")
6
6
  return o;
7
- const m = c === i.DUAL_PAGE ? 2 * e : e;
7
+ const n = m === A.DUAL_PAGE || m === A.DUAL_PAGE_WITH_COVER ? 2 * e : e;
8
8
  switch (o) {
9
9
  case r.PAGE_FIT:
10
10
  const s = Math.min(
11
- (t - n) / m,
12
- (a - f) / A
11
+ (t - a) / n,
12
+ (_ - f) / c
13
13
  );
14
14
  return Math.floor(s * 100);
15
15
  case r.PAGE_WIDTH:
16
- return Math.floor((t - n) / m * 100);
16
+ return Math.floor((t - a) / n * 100);
17
17
  case r.ACTUAL:
18
18
  default:
19
19
  return 100;
20
20
  }
21
21
  };
22
22
  export {
23
- D as getZoomLevel
23
+ E as getZoomLevel
24
24
  };