@react-pdf-kit/viewer 2.0.0-beta.0 → 2.0.0-beta.10

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 (212) hide show
  1. package/dist/Combination-54a77a7a.js +701 -0
  2. package/dist/MostPageTool.module-13578ad6.js +6 -0
  3. package/dist/OtherTool.module-a4be5f1f.js +6 -0
  4. package/dist/Paginate.module-206a7d7d.js +8 -0
  5. package/dist/PaginationContext-9217cab4.js +201 -0
  6. package/dist/{LayoutWrapper-a871c161.js → RPLayout.module-967bf4bc.js} +3 -9
  7. package/dist/RPToolbar.module-27d7fe77.js +10 -0
  8. package/dist/{RotateTool.module-03987eba.js → RotateTool.module-67946714.js} +1 -1
  9. package/dist/SearchTool.module-99f60dc7.js +16 -0
  10. package/dist/ToolbarLayout.module-1fee0a18.js +11 -0
  11. package/dist/{ZoomTool.module-6c5eabbb.js → ZoomTool.module-7082af8c.js} +1 -1
  12. package/dist/assets/style.css +1 -0
  13. package/dist/assets/style.js +75 -0
  14. package/dist/components/RPConfig.js +14 -1489
  15. package/dist/components/RPController.js +109 -66
  16. package/dist/components/RPDropFileZone.js +26 -12
  17. package/dist/components/RPPages.js +991 -58
  18. package/dist/components/RPProvider.js +107 -19
  19. package/dist/components/RPTheme.js +6 -5
  20. package/dist/components/icons/DualPageIcon.js +6 -6
  21. package/dist/components/icons/LoaderIcon.js +1 -1
  22. package/dist/components/icons/SinglePageIcon.js +6 -6
  23. package/dist/components/layout/Container.js +1 -1
  24. package/dist/components/layout/LayoutContainer.js +32 -57
  25. package/dist/components/layout/LayoutWrapper.js +9 -4
  26. package/dist/components/layout/RPDefaultLayout.js +214 -14
  27. package/dist/components/layout/RPLayout.js +143 -41
  28. package/dist/components/layout/WrapperLayout.js +22 -9
  29. package/dist/components/layout/sidebar/RPSidebar.js +110 -13
  30. package/dist/components/layout/sidebar/RPSplitter.js +1 -1
  31. package/dist/components/layout/sidebar/Thumbnail.js +129 -52
  32. package/dist/components/layout/sidebar/Thumbnails.js +75 -6
  33. package/dist/components/layout/toolbar/DarkModeTool.js +24 -13
  34. package/dist/components/layout/toolbar/DocumentDialog.js +311 -56
  35. package/dist/components/layout/toolbar/DocumentProperties.js +21 -8
  36. package/dist/components/layout/toolbar/FileDownloadTool.js +48 -13
  37. package/dist/components/layout/toolbar/FileUploadTool.js +34 -10
  38. package/dist/components/layout/toolbar/FullScreenTool.js +43 -28
  39. package/dist/components/layout/toolbar/MenuItem.js +15 -8
  40. package/dist/components/layout/toolbar/MenuSeparator.js +11 -4
  41. package/dist/components/layout/toolbar/MostPageTool.js +72 -51
  42. package/dist/components/layout/toolbar/OtherTool.js +188 -22
  43. package/dist/components/layout/toolbar/Paginate.js +136 -17
  44. package/dist/components/layout/toolbar/PrintTool.js +70 -13
  45. package/dist/components/layout/toolbar/PropertyItem.js +1 -1
  46. package/dist/components/layout/toolbar/RPMenuItem.js +23 -13
  47. package/dist/components/layout/toolbar/RPMoreOptions.js +119 -47
  48. package/dist/components/layout/toolbar/RPToolbar.js +148 -8
  49. package/dist/components/layout/toolbar/RPToolbarEnd.js +118 -7
  50. package/dist/components/layout/toolbar/RotateTool.js +42 -18
  51. package/dist/components/layout/toolbar/ScrollModeTool.js +33 -21
  52. package/dist/components/layout/toolbar/SearchCloseButton.js +30 -7
  53. package/dist/components/layout/toolbar/SearchResultNavigator.js +87 -8
  54. package/dist/components/layout/toolbar/SearchTool.js +236 -54
  55. package/dist/components/layout/toolbar/SelectionModeTool.js +22 -10
  56. package/dist/components/layout/toolbar/ThumbnailTool.js +32 -10
  57. package/dist/components/layout/toolbar/ToolbarCustom.js +52 -55
  58. package/dist/components/layout/toolbar/ToolbarDefault.js +144 -58
  59. package/dist/components/layout/toolbar/ToolbarLayout.js +149 -6
  60. package/dist/components/layout/toolbar/ViewModeTool.js +31 -19
  61. package/dist/components/layout/toolbar/ZoomTool.js +104 -84
  62. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +38 -12
  63. package/dist/components/layout/toolbar/tools/DualPageTool.js +26 -0
  64. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +31 -9
  65. package/dist/components/layout/toolbar/tools/FileUploadTool.js +29 -8
  66. package/dist/components/layout/toolbar/tools/FullScreenTool.js +25 -13
  67. package/dist/components/layout/toolbar/tools/InputPageTool.js +66 -26
  68. package/dist/components/layout/toolbar/tools/NextPageTool.js +36 -47
  69. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +51 -11
  70. package/dist/components/layout/toolbar/tools/PrintTool.js +29 -7
  71. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +31 -8
  72. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +34 -11
  73. package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +31 -0
  74. package/dist/components/layout/toolbar/tools/SinglePageTool.js +26 -0
  75. package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +17 -6
  76. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +35 -13
  77. package/dist/components/layout/toolbar/tools/ZoomInTool.js +49 -20
  78. package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +27 -0
  79. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +57 -23
  80. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +47 -18
  81. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +122 -45
  82. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +37 -11
  83. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +18 -5
  84. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +36 -11
  85. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +25 -50
  86. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +24 -9
  87. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +47 -54
  88. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +32 -7
  89. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +36 -12
  90. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +26 -14
  91. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +27 -15
  92. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +30 -18
  93. package/dist/components/page/AnnotationLayer.js +130 -54
  94. package/dist/components/page/CanvasLayer.js +62 -49
  95. package/dist/components/page/CustomElement.js +49 -18
  96. package/dist/components/page/DualPage.js +97 -4
  97. package/dist/components/page/RPPage.js +134 -51
  98. package/dist/components/page/SinglePage.js +87 -4
  99. package/dist/components/page/TextHighlightLayer.js +195 -57
  100. package/dist/components/page/TextLayer.js +193 -52
  101. package/dist/components/ui/Button.js +9 -8
  102. package/dist/components/ui/Checkbox.js +27 -25
  103. package/dist/components/ui/DropDown.js +21 -14
  104. package/dist/components/ui/Input.js +10 -9
  105. package/dist/components/ui/LoadingIndicator.js +45 -5
  106. package/dist/components/ui/PasswordModal.js +18 -15
  107. package/dist/components/ui/RPTooltip.js +98 -95
  108. package/dist/contexts/DimensionPagesContext.js +35 -17
  109. package/dist/contexts/DropFileZoneContext.js +32 -22
  110. package/dist/contexts/ElementPageContext.js +114 -51
  111. package/dist/contexts/EventCallbackContext.js +30 -0
  112. package/dist/contexts/FileInputContext.js +32 -22
  113. package/dist/contexts/FullScreenContext.js +17 -10
  114. package/dist/contexts/GlobalCurrentPage.js +13 -10
  115. package/dist/contexts/HighlightContext.js +24 -11
  116. package/dist/contexts/LicenseContext.js +1 -0
  117. package/dist/contexts/LoaderContext.js +10 -9
  118. package/dist/contexts/LocalizationContext.js +25 -29
  119. package/dist/contexts/PagesRotateContext.js +36 -18
  120. package/dist/contexts/PaginationContext.js +32 -4
  121. package/dist/contexts/PrintContext.js +76 -6
  122. package/dist/contexts/RPDocumentContext.js +48 -30
  123. package/dist/contexts/RenderQueueProvider.js +70 -8
  124. package/dist/contexts/RotationContext.js +25 -15
  125. package/dist/contexts/ScrollModeContext.js +7 -6
  126. package/dist/contexts/SearchContext.js +94 -6
  127. package/dist/contexts/SelectionModeContext.js +5 -4
  128. package/dist/contexts/ThumbnailsContext.js +41 -6
  129. package/dist/contexts/ViewModeContext.js +10 -9
  130. package/dist/contexts/ZoomContext.js +48 -38
  131. package/dist/floating-ui.react-dom-5ec29bd6.js +1327 -0
  132. package/dist/index-4baea9b5.js +1198 -0
  133. package/dist/index-655864a7.js +27 -0
  134. package/dist/{index-35c7f4a2.js → index-c0faa594.js} +63 -86
  135. package/dist/index-e3ee9457.js +150 -0
  136. package/dist/libInjectCss.js +9 -0
  137. package/dist/main.js +269 -84
  138. package/dist/types/assets/style.d.ts +1 -0
  139. package/dist/types/components/icons/DualPageIcon.d.ts +1 -1
  140. package/dist/types/components/icons/SinglePageIcon.d.ts +1 -1
  141. package/dist/types/components/layout/toolbar/tools/DualPageTool.d.ts +3 -0
  142. package/dist/types/components/layout/toolbar/tools/SelectionModeSwitcherTool.d.ts +3 -0
  143. package/dist/types/components/layout/toolbar/tools/SinglePageTool.d.ts +3 -0
  144. package/dist/types/components/layout/toolbar/tools/ZoomLevelDisplay.d.ts +7 -0
  145. package/dist/types/contexts/EventCallbackContext.d.ts +5 -0
  146. package/dist/types/contexts/RenderQueueProvider.d.ts +2 -2
  147. package/dist/types/libInjectCss.d.ts +1 -0
  148. package/dist/types/main.d.ts +6 -6
  149. package/dist/types/utils/annotations.d.ts +3 -3
  150. package/dist/types/utils/approximateFragtion.d.ts +9 -0
  151. package/dist/types/utils/getElementPositionInPage.d.ts +5 -0
  152. package/dist/types/utils/hooks/useCopyText.d.ts +1 -0
  153. package/dist/types/utils/hooks/usePrint.d.ts +3 -2
  154. package/dist/types/utils/hooks/useSearch.d.ts +1 -2
  155. package/dist/types/utils/injectPrintCSS.d.ts +1 -0
  156. package/dist/types/utils/link_service.d.ts +11 -1
  157. package/dist/types/utils/renderPage.d.ts +2 -2
  158. package/dist/types/utils/types.d.ts +38 -5
  159. package/dist/types/utils/zoom.d.ts +2 -0
  160. package/dist/utils/annotations.js +125 -149
  161. package/dist/utils/approximateFragtion.js +22 -0
  162. package/dist/utils/getElementPositionInPage.js +84 -0
  163. package/dist/utils/getWordPositionInPage.js +5 -5
  164. package/dist/utils/getZoomLevel.js +9 -8
  165. package/dist/utils/highlight.js +72 -72
  166. package/dist/utils/hooks/useCopyText.js +36 -0
  167. package/dist/utils/hooks/useDarkModeProps.js +3 -2
  168. package/dist/utils/hooks/useFileDownload.js +29 -54
  169. package/dist/utils/hooks/useHighlight.js +34 -33
  170. package/dist/utils/hooks/useLicense.js +1 -1
  171. package/dist/utils/hooks/useLoadPdf.js +44 -36
  172. package/dist/utils/hooks/useLoadWorker.js +11 -8
  173. package/dist/utils/hooks/useLocalization.js +13 -13
  174. package/dist/utils/hooks/usePageRotateContext.js +33 -17
  175. package/dist/utils/hooks/usePaginate.js +26 -49
  176. package/dist/utils/hooks/usePinch.js +62 -41
  177. package/dist/utils/hooks/usePresentPage.js +80 -50
  178. package/dist/utils/hooks/usePrint.js +181 -55
  179. package/dist/utils/hooks/useRotate.js +21 -7
  180. package/dist/utils/hooks/useScrollToPage.js +26 -51
  181. package/dist/utils/hooks/useSearch.js +141 -55
  182. package/dist/utils/hooks/useThumbnail.js +55 -55
  183. package/dist/utils/hooks/useVirtualReactWindow.js +70 -52
  184. package/dist/utils/hooks/useWatermark.js +18 -15
  185. package/dist/utils/injectPrintCSS.js +22 -0
  186. package/dist/utils/link_service.js +49 -9
  187. package/dist/utils/renderPage.js +13 -10
  188. package/dist/utils/zoom.js +6 -0
  189. package/package.json +6 -8
  190. package/dist/SearchCloseButton-cbf182aa.js +0 -33
  191. package/dist/ToolbarLayout.module-c588d36b.js +0 -3411
  192. package/dist/assets/Button.css +0 -1
  193. package/dist/assets/Checkbox.css +0 -1
  194. package/dist/assets/Container.css +0 -1
  195. package/dist/assets/DropDown.css +0 -1
  196. package/dist/assets/Input.css +0 -1
  197. package/dist/assets/LayoutWrapper.css +0 -1
  198. package/dist/assets/LoaderIcon.css +0 -1
  199. package/dist/assets/MenuItem.css +0 -1
  200. package/dist/assets/MenuSeparator.css +0 -1
  201. package/dist/assets/PasswordModal.css +0 -1
  202. package/dist/assets/PropertyItem.css +0 -1
  203. package/dist/assets/RPDropFileZone.css +0 -1
  204. package/dist/assets/RPSplitter.css +0 -1
  205. package/dist/assets/RPTooltip.css +0 -1
  206. package/dist/assets/RotateTool.css +0 -1
  207. package/dist/assets/SearchCloseButton.css +0 -1
  208. package/dist/assets/ToolbarLayout.css +0 -1
  209. package/dist/assets/WrapperLayout.css +0 -1
  210. package/dist/assets/ZoomTool.css +0 -1
  211. package/dist/floating-ui.react-dom-6b2fe0df.js +0 -1474
  212. package/dist/index-f563c6f0.js +0 -1889
@@ -224,10 +224,11 @@ export interface DarkModeProps {
224
224
  export interface DarkMode extends DarkModeProps {
225
225
  onDarkModeChange: (value: boolean) => void;
226
226
  }
227
- export interface renderOptions {
227
+ export interface RenderOptions {
228
228
  scale?: number;
229
229
  rotate?: number;
230
230
  renderForms?: boolean;
231
+ interactiveForm?: boolean;
231
232
  }
232
233
  export interface License {
233
234
  validating?: boolean;
@@ -321,13 +322,18 @@ export interface PreparePrintProgress {
321
322
  totalPages: number;
322
323
  percentage: number;
323
324
  }
325
+ export interface PrintConfiguration {
326
+ visibleDefaultProgress?: boolean;
327
+ }
328
+ export type PrintOptions = PrintConfiguration | React.MouseEvent<{}>;
324
329
  export interface PrintToolProps {
325
- print: () => void;
330
+ print: (options?: PrintOptions) => Promise<void>;
326
331
  cancel: () => void;
327
332
  setOnProgress: (callback: (progress: PreparePrintProgress) => void) => void;
328
333
  setOnComplete: (callback: () => void) => void;
329
334
  setOnError: (callback: (error: Error) => void) => void;
330
335
  progress: PreparePrintProgress;
336
+ showDefaultProgress?: boolean;
331
337
  }
332
338
  export interface ThumbnailToolProps {
333
339
  onClick: () => void;
@@ -456,7 +462,12 @@ export interface CharacterMap {
456
462
  url: string;
457
463
  isCompressed: boolean;
458
464
  }
459
- export interface RPProviderProps extends PropsWithChildren, LoadPDFOptions, RPControllerProps {
465
+ export interface EventCallbackContextType {
466
+ onPageChange?: (page: number) => void;
467
+ onRotate?: (rotation: Record<number, number>) => void;
468
+ onScroll?: (scroll: Event) => void;
469
+ }
470
+ export interface RPProviderProps extends PropsWithChildren, LoadPDFOptions, RPControllerProps, EventCallbackContextType {
460
471
  src: RPSrc;
461
472
  workerUrl?: string;
462
473
  characterMap?: CharacterMap;
@@ -468,6 +479,8 @@ export interface RPControllerProps extends PropsWithChildren, DarkModeProviderPr
468
479
  locale?: string;
469
480
  localization?: LocalizationMap;
470
481
  downloadFilename?: string;
482
+ initialSelectionMode?: SelectionMode;
483
+ interactiveForm?: boolean;
471
484
  }
472
485
  export interface RPConfigProps extends Omit<ConfigContextType, 'workerUrlAdded'>, RPThemeContextType, PropsWithChildren {
473
486
  workerUrl?: string;
@@ -502,6 +515,7 @@ export interface ZoomContextType {
502
515
  export type ZoomProps = Omit<ZoomContextType, 'currentZoom'>;
503
516
  export type InitialStateContextType = {
504
517
  instanceId: string;
518
+ interactiveForm?: boolean;
505
519
  } & ZoomProviderProps & PageProviderProps & ViewModeInitialProps & ScrollModeInitialProps & RotateProviderProps;
506
520
  export interface ZoomProviderProps {
507
521
  initialScale?: number | ZoomLevel;
@@ -535,6 +549,12 @@ export interface ScrollModeInitialProps {
535
549
  initialScrollMode?: ScrollMode;
536
550
  }
537
551
  export interface RectPosition {
552
+ left: number;
553
+ bottom: number;
554
+ width: number;
555
+ height: number;
556
+ }
557
+ export interface ElementPosition {
538
558
  left: number;
539
559
  top: number;
540
560
  width: number;
@@ -605,8 +625,7 @@ export interface SearchContextType {
605
625
  prevMatch: () => void;
606
626
  searchOptions: SearchOptions;
607
627
  setSearchOptions: Dispatch<SetStateAction<SearchOptions>>;
608
- currentMatchElement: HTMLElement | null;
609
- setCurrentMatchElement: Dispatch<SetStateAction<HTMLElement | null>>;
628
+ setCurrentMatchPosition: Dispatch<React.SetStateAction<number>>;
610
629
  }
611
630
  export declare enum SelectionMode {
612
631
  TEXT = "TEXT",
@@ -623,7 +642,11 @@ export type LoaderImage = JSX.Element | string;
623
642
  export interface LoadPDFOptions {
624
643
  onLoadError?: (error: any) => void;
625
644
  onLoaded?: (pdfDocument: PDFDocumentProxy) => void;
645
+ onLoadProgress?: (progress: number) => void;
626
646
  loaderImage?: LoaderImage;
647
+ disableAutoFetch?: boolean;
648
+ disableStream?: boolean;
649
+ rangeChunkSize?: number;
627
650
  }
628
651
  export interface ScrollPosition {
629
652
  left: number;
@@ -659,6 +682,9 @@ export interface useElementPage {
659
682
  removeElement: (pageNumber: number, index: number) => void;
660
683
  clearElements: (pageNumber: number) => void;
661
684
  elementList: Record<number, Array<HTMLElement | JSX.Element>>;
685
+ scrollToElement: (page: number, index: number, config?: {
686
+ behavior: 'smooth' | 'auto' | 'instant';
687
+ }) => void;
662
688
  }
663
689
  export interface MatchHighlight extends MatchValue {
664
690
  keyword: string | RegExp;
@@ -710,6 +736,13 @@ export interface ThemeSwitcherIcons {
710
736
  export interface ThemeSwitcherToolProps {
711
737
  icons?: ThemeSwitcherIcons;
712
738
  }
739
+ export interface SelectionModeSwitcherIcons {
740
+ textSelectionIcon?: React.ReactNode;
741
+ handModeIcon?: React.ReactNode;
742
+ }
743
+ export interface SelectionModeSwitcherToolProps {
744
+ icons?: SelectionModeSwitcherIcons;
745
+ }
713
746
  export interface ToolbarSection {
714
747
  component: React.ReactNode;
715
748
  }
@@ -0,0 +1,2 @@
1
+ export declare const isZoomOutDisabled: (currentZoom: number) => boolean;
2
+ export declare const isZoomInDisabled: (currentZoom: number) => boolean;
@@ -1,19 +1,20 @@
1
- import { sanitizeExternalUrl as L } from "./sanitizeExternalUrl.js";
2
- import { AnnotationSubType as _, AnnotationType as l } from "./types.js";
3
- import { dateFormatter as I } from "./dateFormatter.js";
4
- const v = ["click", "dblclick", "input", "change"], g = /* @__PURE__ */ new Map(), E = (e, t) => `${e.loadingTask.docId}___${t.num}R${t.gen === 0 ? "" : t.gen}`;
5
- function x(e, t) {
6
- const n = E(e, t);
1
+ import { sanitizeExternalUrl as I } from "./sanitizeExternalUrl.js";
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);
7
8
  return g.has(n) ? g.get(n) ?? null : null;
8
9
  }
9
- const B = (e, t, n) => {
10
- g.set(E(e, t), n);
11
- }, O = (e, t) => {
10
+ const S = (e, t, n) => {
11
+ g.set(x(e, t), n);
12
+ }, T = (e, t) => {
12
13
  switch (t[1].name) {
13
14
  case "XYZ":
14
15
  return {
15
- bottomOffset: (n, a) => t[3] === null ? a : t[3],
16
- leftOffset: (n, a) => t[2] === null ? 0 : t[2],
16
+ bottomOffset: (n, s) => t[3] === null ? s : t[3],
17
+ leftOffset: (n, s) => t[2] === null ? 0 : t[2],
17
18
  pageIndex: e,
18
19
  scaleTo: t[4]
19
20
  };
@@ -41,123 +42,98 @@ const B = (e, t, n) => {
41
42
  scaleTo: 1
42
43
  };
43
44
  }
45
+ }, M = (e) => {
46
+ e && (() => {
47
+ const n = e == null ? void 0 : e.querySelectorAll(
48
+ '[data-l10n-id="pdfjs-annotation-date-time-string"]'
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));
53
+ });
54
+ })();
44
55
  };
45
- async function b(e, t) {
56
+ async function E(e, t) {
46
57
  let n;
47
58
  if (typeof t == "string" ? n = await e.getDestination(t) : n = t, n && typeof n[0] == "object" && n[0] !== null) {
48
- const a = n[0], s = x(e, a);
49
- if (s === null) {
50
- const r = await e.getPageIndex(a);
51
- return B(e, a, r), await b(e, n);
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);
52
63
  } else
53
- return O(s, n);
64
+ return T(a, n);
54
65
  } else
55
- return O(n[0], n);
66
+ return T(n[0], n);
56
67
  }
57
- const H = (e) => {
58
- const n = e.target.parentNode;
59
- if (!n)
60
- return;
61
- const a = new MutationObserver((s) => {
62
- s.forEach(() => {
63
- n.querySelectorAll(
64
- '[data-l10n-id="pdfjs-annotation-date-time-string"]'
65
- ).forEach((o) => {
66
- const c = o.getAttribute("data-l10n-args");
67
- if (c) {
68
- try {
69
- const { dateObj: i } = JSON.parse(c);
70
- i && (o.textContent = I(i));
71
- } catch {
72
- }
73
- a.disconnect();
74
- }
75
- });
76
- });
77
- });
78
- return a.observe(n, {
79
- childList: !0,
80
- // Watch for changes to child elements
81
- subtree: !0,
82
- // Watch all descendants, not just direct children
83
- attributes: !0
84
- // Watch for changes to attributes
85
- }), () => a.disconnect();
86
- }, M = (e, t, n, a) => {
87
- if (e.type !== "click")
88
- return;
89
- const s = e.target, r = s.getAttribute("data-element-id"), o = s.getAttribute("href");
90
- if (o && o !== "#")
91
- return;
92
- const c = t.find((i) => i.id === r);
93
- !c || c.annotationType !== _.Link || c.dest && b(n, c.dest).then((i) => {
94
- a(i);
95
- });
96
- };
97
68
  function P(e, t) {
98
69
  for (const n of v)
99
70
  e.addEventListener(n, t);
100
71
  }
101
- function U(e, t) {
72
+ function $(e, t) {
102
73
  for (const n of v)
103
74
  e.removeEventListener(n, t);
104
75
  }
105
- function V(e) {
106
- const { id: t, url: n, unsafeUrl: a } = e;
107
- new MutationObserver((r, o) => {
76
+ function D(e) {
77
+ const { id: t, url: n, unsafeUrl: s } = e;
78
+ new MutationObserver((o, i) => {
108
79
  const c = document.querySelector(`[data-annotation-id="${t}"]`);
109
80
  if (c) {
110
- const i = c.querySelector("a"), p = L((n || a) ?? "", "");
111
- i && (i == null || i.setAttribute("target", "_blank"), i == null || i.setAttribute("href", p), i == null || i.setAttribute("rel", "noopener noreferrer")), o.disconnect();
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();
112
83
  }
113
84
  }).observe(document.body, { childList: !0, subtree: !0 });
114
85
  }
115
- function $(e, t, n) {
116
- const { rotation: a, scale: s } = t, r = a % 180 === 0;
86
+ function U(e, t, n) {
87
+ const { rotation: s, scale: a } = t, o = s % 180 === 0;
117
88
  if (e.fieldType === "Btn" && e.pushButton) {
118
- const o = e.rect[2] - e.rect[0], c = e.rect[3] - e.rect[1], i = document.createElement("canvas");
119
- i.setAttribute("width", ((r ? o : c) * s).toString()), i.setAttribute("height", ((r ? c : o) * s).toString()), n.set(e.id, i);
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);
120
91
  }
121
92
  }
122
- function k(e) {
123
- var r;
93
+ function V(e) {
94
+ var o;
124
95
  let t = e;
125
96
  for (; t.tagName !== "SECTION"; )
126
97
  t = t.parentElement;
127
- const n = t.getAttribute("aria-haspopup") === "dialog", a = t.classList.contains("popupAnnotation");
128
- if (!n && !a)
98
+ const n = t.getAttribute("aria-haspopup") === "dialog", s = t.classList.contains("popupAnnotation");
99
+ if (!n && !s)
129
100
  return;
130
- let s = t.id || t.getAttribute("aria-controls");
131
- if (s || (s = (r = t.firstChild) == null ? void 0 : r.id), s && t.parentElement) {
132
- const o = t.parentElement.querySelector(`[aria-controls="${s}"]`);
133
- o && new MutationObserver((i, p) => {
134
- const h = document.querySelectorAll(".popupDate");
135
- h.length > 0 && (h.forEach((m) => {
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) => {
136
107
  if (m.innerHTML)
137
108
  return !1;
138
109
  const N = m.getAttribute("data-l10n-args");
139
110
  if (N) {
140
- const { date: y, time: A } = JSON.parse(N);
141
- y && A && (m.textContent = `${y}, ${A}`);
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
+ }
142
118
  }
143
119
  }), p.disconnect());
144
- }).observe(o, { childList: !0, subtree: !0 });
120
+ }).observe(i, { childList: !0, subtree: !0 });
145
121
  }
146
122
  }
147
123
  function d(e, t, n) {
148
- const a = [];
124
+ const s = [];
149
125
  if (n)
150
- for (const s of n)
151
- s[e] === t && a.push(s);
152
- return a;
126
+ for (const a of n)
127
+ a[e] === t && s.push(a);
128
+ return s;
153
129
  }
154
130
  function u(e, t) {
155
131
  return { type: e, data: t };
156
132
  }
157
- async function S(e, t) {
133
+ async function k(e, t) {
158
134
  if (e.dest)
159
135
  if (typeof e.dest == "string") {
160
- const n = await b(t, e.dest);
136
+ const n = await E(t, e.dest);
161
137
  return u(l.INTERNAL_LINK, {
162
138
  referencedPage: n.pageIndex,
163
139
  offset: null
@@ -178,13 +154,13 @@ async function S(e, t) {
178
154
  unsafeUrl: e.unsafeUrl
179
155
  });
180
156
  }
181
- function T(e) {
157
+ function y(e) {
182
158
  for (const t of e.getElementsByTagName("span")) {
183
159
  let n = t.textContent;
184
- const a = JSON.parse(t.dataset.l10nArgs ?? "{}");
160
+ const s = JSON.parse(t.dataset.l10nArgs ?? "{}");
185
161
  if (n)
186
- for (const s in a)
187
- n = n.replace(`{{${s}}}`, a[s]);
162
+ for (const a in s)
163
+ n = n.replace(`{{${a}}}`, s[a]);
188
164
  t.textContent = n;
189
165
  }
190
166
  }
@@ -202,20 +178,20 @@ function f(e, t) {
202
178
  case "select-one":
203
179
  case "select-multiple":
204
180
  const n = [];
205
- for (const s of e.options)
181
+ for (const a of e.options)
206
182
  n.push({
207
- value: s.value,
208
- label: s.label
183
+ value: a.value,
184
+ label: a.label
209
185
  });
210
- const a = [];
211
- for (const s of e.selectedOptions)
212
- a.push({
213
- value: s.value,
214
- label: s.label
186
+ const s = [];
187
+ for (const a of e.selectedOptions)
188
+ s.push({
189
+ value: a.value,
190
+ label: a.label
215
191
  });
216
192
  return u(l.FORM_SELECT, {
217
193
  fieldName: e.name,
218
- value: a,
194
+ value: s,
219
195
  options: n
220
196
  });
221
197
  case "checkbox":
@@ -235,72 +211,72 @@ function f(e, t) {
235
211
  });
236
212
  }
237
213
  }
238
- async function D(e, t, n) {
239
- var s;
240
- let a = e.target.parentNode;
241
- if (a.tagName === "DIV" && (a = a.firstChild), k(a), typeof a.className != "object")
242
- if (a.className === "linkAnnotation" && e.type === "click") {
243
- const r = (s = a.dataset) == null ? void 0 : s.annotationId;
244
- if (r) {
245
- const o = d("id", r, n);
246
- if (o.length)
247
- return await S(o[0], t);
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);
222
+ if (i.length)
223
+ return await k(i[0], t);
248
224
  }
249
225
  } else if (
250
226
  /* annotation.className.includes('popupAnnotation') || */
251
- a.className.includes("textAnnotation")
227
+ s.className.includes("textAnnotation")
252
228
  )
253
- T(a);
254
- else if (a.className.includes("fileAttachmentAnnotation")) {
255
- T(a);
256
- const r = a.dataset.annotationId;
257
- if (r && e.type === "dblclick")
258
- return w(d("id", r, n)[0]);
259
- } else if (a.className.includes("textWidgetAnnotation") && e.type === "input") {
260
- let r = a.getElementsByTagName("input")[0];
261
- return r || (r = a.getElementsByTagName("textarea")[0]), f(r);
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);
262
238
  } else {
263
- if (a.className.includes("choiceWidgetAnnotation") && e.type === "input")
264
- return f(a.getElementsByTagName("select")[0]);
265
- if (a.className.includes("buttonWidgetAnnotation checkBox") && e.type === "change")
266
- return f(a.getElementsByTagName("input")[0]);
267
- if (a.className.includes("buttonWidgetAnnotation radioButton") && e.type === "change") {
268
- const r = a.dataset.annotationId;
269
- if (r) {
270
- const o = d("id", r, n)[0], c = [];
271
- for (const i of d(
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 = [];
247
+ for (const r of d(
272
248
  "fieldName",
273
- o.fieldName,
249
+ i.fieldName,
274
250
  n
275
251
  ))
276
- i.buttonValue && c.push(i.buttonValue);
277
- return f(a.getElementsByTagName("input")[0], {
278
- value: o.buttonValue,
279
- defaultValue: o.fieldValue,
252
+ r.buttonValue && c.push(r.buttonValue);
253
+ return f(s.getElementsByTagName("input")[0], {
254
+ value: i.buttonValue,
255
+ defaultValue: i.fieldValue,
280
256
  options: c
281
257
  });
282
258
  }
283
- } else if (a.className.includes("buttonWidgetAnnotation pushButton") && e.type === "click") {
284
- const r = a.dataset.annotationId;
285
- if (r) {
286
- const o = d("id", r, n)[0], { action: c } = o;
287
- return c && ["Print", "SaveAs"].includes(c) ? { type: l.BUTTON, data: o } : o.resetForm ? f(
288
- { name: o.fieldName, type: "button" },
289
- { actions: o.actions, reset: !0 }
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;
263
+ return c && ["Print", "SaveAs"].includes(c) ? { type: l.BUTTON, data: i } : i.resetForm ? f(
264
+ { name: i.fieldName, type: "button" },
265
+ { actions: i.actions, reset: !0 }
290
266
  ) : f(
291
- { name: o.fieldName, type: "button" },
292
- { actions: o.actions, reset: !1 }
267
+ { name: i.fieldName, type: "button" },
268
+ { actions: i.actions, reset: !1 }
293
269
  );
294
270
  }
295
271
  }
296
272
  }
297
273
  }
298
274
  export {
299
- D as annotationEventsHandler,
300
- H as annotationsEvents,
275
+ j as annotationEventsHandler,
301
276
  P as bindLayerEvents,
302
- V as handleAnnotationLink,
303
- $ as handleAnnotationWidget,
304
- M as handleClick,
305
- U as unbindLayerEvents
277
+ D as handleAnnotationLink,
278
+ U as handleAnnotationWidget,
279
+ V as handleAriaHasPopup,
280
+ M as insertDateText,
281
+ $ as unbindLayerEvents
306
282
  };
@@ -0,0 +1,22 @@
1
+ function u(t) {
2
+ if (Math.floor(t) === t)
3
+ return [t, 1];
4
+ const e = 1 / t, s = 8;
5
+ if (e > s)
6
+ return [1, s];
7
+ if (Math.floor(e) === e)
8
+ return [1, e];
9
+ const r = t > 1 ? e : t;
10
+ let i = 0, n = 1, o = 1, l = 1;
11
+ for (; ; ) {
12
+ const c = i + o, f = n + l;
13
+ if (f > s)
14
+ break;
15
+ r <= c / f ? (o = c, l = f) : (i = c, n = f);
16
+ }
17
+ let a;
18
+ return r - i / n < o / l - r ? a = r === t ? [i, n] : [n, i] : a = r === t ? [o, l] : [l, o], a;
19
+ }
20
+ export {
21
+ u as approximateFraction
22
+ };
@@ -0,0 +1,84 @@
1
+ function g(e, o) {
2
+ !e || typeof e != "object" || Object.entries(e).forEach(([d, i]) => {
3
+ if (i == null)
4
+ return;
5
+ const s = d.replace(/([A-Z])/g, "-$1").toLowerCase(), n = [
6
+ "width",
7
+ "height",
8
+ "top",
9
+ "right",
10
+ "bottom",
11
+ "left",
12
+ "margin",
13
+ "margin-top",
14
+ "margin-right",
15
+ "margin-bottom",
16
+ "margin-left",
17
+ "padding",
18
+ "padding-top",
19
+ "padding-right",
20
+ "padding-bottom",
21
+ "padding-left",
22
+ "border-width",
23
+ "border-top-width",
24
+ "border-right-width",
25
+ "border-bottom-width",
26
+ "border-left-width",
27
+ "font-size",
28
+ "line-height",
29
+ "letter-spacing",
30
+ "word-spacing",
31
+ "min-width",
32
+ "min-height",
33
+ "max-width",
34
+ "max-height",
35
+ "flex-basis",
36
+ "grid-gap",
37
+ "grid-row-gap",
38
+ "grid-column-gap"
39
+ ];
40
+ let t;
41
+ typeof i == "number" && i !== 0 ? t = n.includes(s) ? `${i}px` : String(i) : t = String(i), o.style.setProperty(s, t);
42
+ });
43
+ }
44
+ const f = (e, o, d, i, s) => {
45
+ let n = "center";
46
+ switch (i) {
47
+ case 90:
48
+ n = `${e.width / 2}px ${e.width / 2}px`;
49
+ break;
50
+ case -90:
51
+ case 270:
52
+ n = `${e.height / 2}px ${e.height / 2}px`;
53
+ break;
54
+ default:
55
+ n = "center";
56
+ }
57
+ const t = document.createElement("div");
58
+ t.id = "parent-element", t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.style.setProperty("--scale-factor", s.toString()), t.style.setProperty("--rotation", i.toString()), t.style.setProperty("--transform-origin", n), t.style.left = "-99999px", t.style.visibility = "hidden", t.style.position = "absolute";
59
+ const l = document.createElement("div");
60
+ l.style.position = "relative", l.style.width = "100%", l.style.height = "100%", t.appendChild(l);
61
+ let r;
62
+ if (d instanceof HTMLElement)
63
+ r = d.cloneNode(!0), l.appendChild(r);
64
+ else {
65
+ const p = d.props;
66
+ r = document.createElement("div"), p.style && g(p.style, r), p.className && (r.className = p.className), l.appendChild(r);
67
+ }
68
+ o.appendChild(t);
69
+ const c = t.getBoundingClientRect(), h = r.getBoundingClientRect();
70
+ o.removeChild(t);
71
+ const a = {
72
+ top: o.clientHeight / 2,
73
+ left: o.clientWidth / 2
74
+ };
75
+ return {
76
+ left: h.left - c.left - a.left,
77
+ top: h.top - c.top - a.top,
78
+ width: h.width,
79
+ height: h.height
80
+ };
81
+ };
82
+ export {
83
+ f as getElementPagePosition
84
+ };
@@ -1,5 +1,5 @@
1
1
  const a = (i, h, l, o, n) => {
2
- const c = l.height * o, s = l.width * o, y = l.top * o, w = l.left * o, d = {
2
+ const c = l.height * o, s = l.width * o, y = l.bottom * o, m = l.left * o, d = {
3
3
  width: n % 180 === 90 ? i.height : i.width,
4
4
  height: n % 180 === 90 ? i.width : i.height
5
5
  }, r = {
@@ -8,16 +8,16 @@ const a = (i, h, l, o, n) => {
8
8
  }, t = document.createElement("div");
9
9
  t.style.width = `${d.width}px`, t.style.height = `${d.height}px`, t.style.position = "absolute", t.style.transform = `rotate(${n}deg)`, t.style.transformOrigin = "center center", t.style.visibility = "hidden", t.style.left = "-99999px";
10
10
  const e = document.createElement("div");
11
- e.style.position = "absolute", e.style.width = `${s}px`, e.style.height = `${c}px`, e.style.position = "absolute", e.style.bottom = `${y}px`, e.style.left = `${w}px`, t.appendChild(e), h.appendChild(t);
12
- const p = t.getBoundingClientRect(), g = e.getBoundingClientRect();
11
+ e.style.position = "absolute", e.style.width = `${s}px`, e.style.height = `${c}px`, e.style.position = "absolute", e.style.bottom = `${y}px`, e.style.left = `${m}px`, t.appendChild(e), h.appendChild(t);
12
+ const g = t.getBoundingClientRect(), p = e.getBoundingClientRect();
13
13
  h.removeChild(t);
14
14
  const u = {
15
15
  top: h.clientHeight / 2,
16
16
  left: h.clientWidth / 2
17
17
  };
18
18
  return {
19
- leftInPage: g.left - p.left - u.left + r.width / 2,
20
- topInPage: g.top - p.top - u.top + r.height / 2
19
+ leftInPage: p.left - g.left - u.left + r.width / 2,
20
+ topInPage: p.top - g.top - u.top + r.height / 2
21
21
  };
22
22
  };
23
23
  export {
@@ -1,23 +1,24 @@
1
- import { SCROLL_BAR_WIDTH as a, PAGE_PADDING as f } from "./constants.js";
2
- import { ViewMode as u, ZoomLevel as r } from "./types.js";
3
- const l = (o, t, m, e, A, c) => {
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) => {
4
5
  if (typeof o == "number")
5
6
  return o;
6
- const n = c === u.DUAL_PAGE ? 2 * e : e;
7
+ const m = c === i.DUAL_PAGE ? 2 * e : e;
7
8
  switch (o) {
8
9
  case r.PAGE_FIT:
9
10
  const s = Math.min(
10
- (t - a) / n,
11
- (m - f) / A
11
+ (t - n) / m,
12
+ (a - f) / A
12
13
  );
13
14
  return Math.floor(s * 100);
14
15
  case r.PAGE_WIDTH:
15
- return Math.floor((t - a) / n * 100);
16
+ return Math.floor((t - n) / m * 100);
16
17
  case r.ACTUAL:
17
18
  default:
18
19
  return 100;
19
20
  }
20
21
  };
21
22
  export {
22
- l as getZoomLevel
23
+ D as getZoomLevel
23
24
  };