viewdoc 0.1.1 → 0.2.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 (44) hide show
  1. package/README.md +6 -3
  2. package/dist/DocxViewer-VQN3BESX.js +8 -0
  3. package/dist/DocxViewer-VQN3BESX.js.map +1 -0
  4. package/dist/PdfViewer-NVAQBI2Y.js +8 -0
  5. package/dist/PdfViewer-NVAQBI2Y.js.map +1 -0
  6. package/dist/XlsxViewer-SQMAF5UA.js +8 -0
  7. package/dist/XlsxViewer-SQMAF5UA.js.map +1 -0
  8. package/dist/chunk-4VVVAGYE.js +110 -0
  9. package/dist/chunk-4VVVAGYE.js.map +1 -0
  10. package/dist/chunk-KRN2POC4.js +174 -0
  11. package/dist/chunk-KRN2POC4.js.map +1 -0
  12. package/dist/chunk-LE4YTMPN.js +135 -0
  13. package/dist/chunk-LE4YTMPN.js.map +1 -0
  14. package/dist/chunk-OA35SYM6.js +432 -0
  15. package/dist/chunk-OA35SYM6.js.map +1 -0
  16. package/dist/docx.cjs +566 -0
  17. package/dist/docx.cjs.map +1 -0
  18. package/dist/docx.d.cts +43 -0
  19. package/dist/docx.d.ts +43 -0
  20. package/dist/docx.js +8 -0
  21. package/dist/docx.js.map +1 -0
  22. package/dist/index.cjs +235 -116
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +9 -150
  25. package/dist/index.d.ts +9 -150
  26. package/dist/index.js +21 -828
  27. package/dist/index.js.map +1 -1
  28. package/dist/pdf.cjs +631 -0
  29. package/dist/pdf.cjs.map +1 -0
  30. package/dist/pdf.d.cts +45 -0
  31. package/dist/pdf.d.ts +45 -0
  32. package/dist/pdf.js +8 -0
  33. package/dist/pdf.js.map +1 -0
  34. package/dist/useDraggable-QvFR-4DD.d.cts +33 -0
  35. package/dist/useDraggable-QvFR-4DD.d.ts +33 -0
  36. package/dist/xlsx.cjs +591 -0
  37. package/dist/xlsx.cjs.map +1 -0
  38. package/dist/xlsx.d.cts +43 -0
  39. package/dist/xlsx.d.ts +43 -0
  40. package/dist/xlsx.js +8 -0
  41. package/dist/xlsx.js.map +1 -0
  42. package/package.json +16 -1
  43. package/dist/styles.d.cts +0 -2
  44. package/dist/styles.d.ts +0 -2
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties } from 'react';
3
+ import { V as ViewerTheme, P as Position } from './useDraggable-QvFR-4DD.js';
4
+ export { D as DraggableControls, U as UseDraggableOptions, u as useDraggable } from './useDraggable-QvFR-4DD.js';
3
5
 
4
6
  type DocViewerFileType = 'image' | 'pdf' | 'docx' | 'xlsx';
5
7
  /**
@@ -10,38 +12,6 @@ declare function getUrlExtension(uri: string): string | null;
10
12
  /** Maps a URL (or explicit extension/mime hint) to the viewer type DocViewer should render. */
11
13
  declare function detectFileType(uri: string, hint?: string): DocViewerFileType | null;
12
14
 
13
- interface ViewerTheme {
14
- /** Background color of the viewer canvas area. */
15
- background?: string;
16
- /** Background color of the toolbar strip. */
17
- toolbarBackground?: string;
18
- /** Border color under the toolbar. */
19
- toolbarBorderColor?: string;
20
- /** Hover background for toolbar buttons. */
21
- toolbarButtonHoverBackground?: string;
22
- /** Text/icon color used across the toolbar. */
23
- textColor?: string;
24
- /** Corner radius of the outer viewer container. */
25
- borderRadius?: string;
26
- /** Corner radius of individual toolbar buttons. */
27
- toolbarButtonRadius?: string;
28
- }
29
-
30
- interface Position {
31
- x: number;
32
- y: number;
33
- }
34
- interface UseDraggableOptions {
35
- defaultPosition?: Position;
36
- /** Allow dragging via the returned handle props. Default: true. */
37
- draggable?: boolean;
38
- }
39
- interface DraggableControls {
40
- position: Position;
41
- onDragHandlePointerDown: (e: React.PointerEvent) => void;
42
- }
43
- declare function useDraggable(options?: UseDraggableOptions): DraggableControls;
44
-
45
15
  interface DocViewerProps {
46
16
  /** URL of the file to display. */
47
17
  uri: string;
@@ -55,6 +25,11 @@ interface DocViewerProps {
55
25
  type?: DocViewerFileType | string;
56
26
  /** Rendered when the file type can't be detected and no `type` override was given. */
57
27
  fallback?: ReactNode;
28
+ /**
29
+ * Rendered while the PDF/DOCX/XLSX viewer's code is being downloaded (those are lazy-loaded so
30
+ * that using DocViewer for images alone doesn't pull in pdfjs-dist/mammoth/xlsx). Default: null.
31
+ */
32
+ loadingFallback?: ReactNode;
58
33
  className?: string;
59
34
  style?: CSSProperties;
60
35
  /** Width of the viewer. Accepts any CSS size (e.g. 1200, '1200px', '100%'). Default: 1200. */
@@ -77,7 +52,7 @@ interface DocViewerProps {
77
52
  /** Initial position when floating. Default: centered in the viewport. */
78
53
  defaultPosition?: Position;
79
54
  }
80
- declare function DocViewer({ uri, fileName, type, fallback, ...rest }: DocViewerProps): react.JSX.Element;
55
+ declare function DocViewer({ uri, fileName, type, fallback, loadingFallback, ...rest }: DocViewerProps): react.JSX.Element;
81
56
 
82
57
  interface ImageViewerProps {
83
58
  /** URL or data URI of the image to display. */
@@ -119,122 +94,6 @@ interface ImageViewerProps {
119
94
  }
120
95
  declare function ImageViewer({ uri, fileName, className, style, width, height, minScale, maxScale, zoomStep, enableZoomControls, enableWheelZoom, enablePan, enableFullscreen, enableDownload, onDownload, theme, floating, windowDraggable, defaultPosition, }: ImageViewerProps): react.JSX.Element;
121
96
 
122
- interface PdfViewerProps {
123
- /** URL or data URI of the PDF to display. */
124
- uri: string;
125
- /** Used as the suggested filename on download. */
126
- fileName?: string;
127
- className?: string;
128
- style?: CSSProperties;
129
- /** Width of the viewer. Accepts any CSS size (e.g. 1200, '1200px', '100%'). Default: 1200. */
130
- width?: number | string;
131
- /** Height of the viewer. Accepts any CSS size (e.g. 700, '700px', '100vh'). Default: 700. */
132
- height?: number | string;
133
- /** Minimum zoom scale. Default: 0.25 */
134
- minScale?: number;
135
- /** Maximum zoom scale. Default: 5 */
136
- maxScale?: number;
137
- /** Zoom increment per step (buttons / Ctrl+scroll). Default: 0.25 */
138
- zoomStep?: number;
139
- /** Canvas render resolution multiplier (crispness at high zoom). Default: 1.5 */
140
- renderScale?: number;
141
- /** Show zoom in/out and reset-to-100% controls. Default: true. */
142
- enableZoomControls?: boolean;
143
- /** Allow Ctrl/Cmd + scroll wheel to zoom. Default: true. */
144
- enableWheelZoom?: boolean;
145
- /** Show the fullscreen toggle button. Default: true. */
146
- enableFullscreen?: boolean;
147
- /** Show the download button. Default: true. */
148
- enableDownload?: boolean;
149
- /** Called when the download button is clicked. If omitted, downloads `uri` directly. */
150
- onDownload?: () => void;
151
- /** Colors/radii to override the default look (toolbar background, text color, etc). */
152
- theme?: ViewerTheme;
153
- /** Render as a floating window (position: fixed) that can be dragged, instead of filling the parent. Default: true. */
154
- floating?: boolean;
155
- /** When floating, allow dragging the window by its toolbar. Default: true. */
156
- windowDraggable?: boolean;
157
- /** Initial position when floating. Default: centered in the viewport. */
158
- defaultPosition?: Position;
159
- }
160
- declare function PdfViewer({ uri, fileName, className, style, width, height, minScale, maxScale, zoomStep, renderScale, enableZoomControls, enableWheelZoom, enableFullscreen, enableDownload, onDownload, theme, floating, windowDraggable, defaultPosition, }: PdfViewerProps): react.JSX.Element;
161
-
162
- interface DocxViewerProps {
163
- /** URL of the .docx file to display. */
164
- uri: string;
165
- /** Used as the suggested filename on download. */
166
- fileName?: string;
167
- className?: string;
168
- style?: CSSProperties;
169
- /** Width of the viewer. Accepts any CSS size (e.g. 1200, '1200px', '100%'). Default: 1200. */
170
- width?: number | string;
171
- /** Height of the viewer. Accepts any CSS size (e.g. 700, '700px', '100vh'). Default: 700. */
172
- height?: number | string;
173
- /** Minimum zoom scale. Default: 0.5 */
174
- minScale?: number;
175
- /** Maximum zoom scale. Default: 3 */
176
- maxScale?: number;
177
- /** Zoom increment per step (buttons / Ctrl+scroll). Default: 0.25 */
178
- zoomStep?: number;
179
- /** Show zoom in/out and reset-to-100% controls. Default: true. */
180
- enableZoomControls?: boolean;
181
- /** Allow Ctrl/Cmd + scroll wheel to zoom. Default: true. */
182
- enableWheelZoom?: boolean;
183
- /** Show the fullscreen toggle button. Default: true. */
184
- enableFullscreen?: boolean;
185
- /** Show the download button. Default: true. */
186
- enableDownload?: boolean;
187
- /** Called when the download button is clicked. If omitted, downloads `uri` directly. */
188
- onDownload?: () => void;
189
- /** Colors/radii to override the default look (toolbar background, text color, etc). */
190
- theme?: ViewerTheme;
191
- /** Render as a floating window (position: fixed) that can be dragged, instead of filling the parent. Default: true. */
192
- floating?: boolean;
193
- /** When floating, allow dragging the window by its toolbar. Default: true. */
194
- windowDraggable?: boolean;
195
- /** Initial position when floating. Default: centered in the viewport. */
196
- defaultPosition?: Position;
197
- }
198
- declare function DocxViewer({ uri, fileName, className, style, width, height, minScale, maxScale, zoomStep, enableZoomControls, enableWheelZoom, enableFullscreen, enableDownload, onDownload, theme, floating, windowDraggable, defaultPosition, }: DocxViewerProps): react.JSX.Element;
199
-
200
- interface XlsxViewerProps {
201
- /** URL of the .xlsx/.xls (legacy binary supported)/.csv file to display. */
202
- uri: string;
203
- /** Used as the suggested filename on download. */
204
- fileName?: string;
205
- className?: string;
206
- style?: CSSProperties;
207
- /** Width of the viewer. Accepts any CSS size (e.g. 1200, '1200px', '100%'). Default: 1200. */
208
- width?: number | string;
209
- /** Height of the viewer. Accepts any CSS size (e.g. 700, '700px', '100vh'). Default: 700. */
210
- height?: number | string;
211
- /** Minimum zoom scale. Default: 0.5 */
212
- minScale?: number;
213
- /** Maximum zoom scale. Default: 3 */
214
- maxScale?: number;
215
- /** Zoom increment per step (buttons / Ctrl+scroll). Default: 0.25 */
216
- zoomStep?: number;
217
- /** Show zoom in/out and reset-to-100% controls. Default: true. */
218
- enableZoomControls?: boolean;
219
- /** Allow Ctrl/Cmd + scroll wheel to zoom. Default: true. */
220
- enableWheelZoom?: boolean;
221
- /** Show the fullscreen toggle button. Default: true. */
222
- enableFullscreen?: boolean;
223
- /** Show the download button. Default: true. */
224
- enableDownload?: boolean;
225
- /** Called when the download button is clicked. If omitted, downloads `uri` directly. */
226
- onDownload?: () => void;
227
- /** Colors/radii to override the default look (toolbar background, text color, etc). */
228
- theme?: ViewerTheme;
229
- /** Render as a floating window (position: fixed) that can be dragged, instead of filling the parent. Default: true. */
230
- floating?: boolean;
231
- /** When floating, allow dragging the window by its toolbar. Default: true. */
232
- windowDraggable?: boolean;
233
- /** Initial position when floating. Default: centered in the viewport. */
234
- defaultPosition?: Position;
235
- }
236
- declare function XlsxViewer({ uri, fileName, className, style, width, height, minScale, maxScale, zoomStep, enableZoomControls, enableWheelZoom, enableFullscreen, enableDownload, onDownload, theme, floating, windowDraggable, defaultPosition, }: XlsxViewerProps): react.JSX.Element;
237
-
238
97
  interface ZoomPanState {
239
98
  scale: number;
240
99
  translateX: number;
@@ -313,4 +172,4 @@ interface ToolbarProps {
313
172
  }
314
173
  declare function Toolbar({ scale, onZoomIn, onZoomOut, onReset, onFullscreen, onDownload, isFullscreen, showZoomControls, dragHandle, onDragHandlePointerDown, extra, }: ToolbarProps): react.JSX.Element;
315
174
 
316
- export { DocViewer, type DocViewerFileType, type DocViewerProps, DocxViewer, type DocxViewerProps, type DraggableControls, ImageViewer, type ImageViewerProps, PdfViewer, type PdfViewerProps, type Position, Toolbar, type UseDraggableOptions, ViewerShell, type ViewerTheme, XlsxViewer, type XlsxViewerProps, type ZoomPanControls, type ZoomPanOptions, type ZoomPanState, detectFileType, getUrlExtension, useDraggable, useZoomPan };
175
+ export { DocViewer, type DocViewerFileType, type DocViewerProps, ImageViewer, type ImageViewerProps, Position, Toolbar, ViewerShell, ViewerTheme, type ZoomPanControls, type ZoomPanOptions, type ZoomPanState, detectFileType, getUrlExtension, useZoomPan };