bdsa-react-components 0.1.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.
@@ -0,0 +1,132 @@
1
+ import { default as React } from 'react';
2
+ import { FeatureCollection } from 'geojson';
3
+ import { Viewer as OpenSeadragonViewer, Options as OpenSeadragonOptions } from 'openseadragon';
4
+
5
+ export interface SlideImageInfo {
6
+ /** Image ID from DSA (used if dziUrl is not provided) */
7
+ imageId?: string | number;
8
+ /** Image width in pixels (used if dziUrl is not provided) */
9
+ width?: number;
10
+ /** Image height in pixels (used if dziUrl is not provided) */
11
+ height?: number;
12
+ /** Tile width (used if dziUrl is not provided) */
13
+ tileWidth?: number;
14
+ /** Number of zoom levels (used if dziUrl is not provided) */
15
+ levels?: number;
16
+ /** Base URL for DSA tile server (used if dziUrl is not provided) */
17
+ baseUrl?: string;
18
+ /** DZI descriptor URL (e.g., 'http://bdsa.pathology.emory.edu:8080/api/v1/item/{itemId}/tiles/dzi.dzi')
19
+ * If provided, this will be used instead of manually constructing tile URLs */
20
+ dziUrl?: string;
21
+ }
22
+ export interface AnnotationFeature {
23
+ /** Unique identifier for the annotation */
24
+ id?: string | number;
25
+ /** Left coordinate in pixels */
26
+ left: number;
27
+ /** Top coordinate in pixels */
28
+ top: number;
29
+ /** Width in pixels */
30
+ width: number;
31
+ /** Height in pixels */
32
+ height: number;
33
+ /** Optional color for the annotation stroke */
34
+ color?: string;
35
+ /** Optional group identifier */
36
+ group?: string | number;
37
+ /** Optional label */
38
+ label?: string;
39
+ /** Type of annotation (rectangle, polyline, etc.) */
40
+ annotationType?: 'rectangle' | 'polyline';
41
+ /** Points array for polyline annotations */
42
+ points?: Array<[number, number]>;
43
+ /** Whether polyline is closed */
44
+ closed?: boolean;
45
+ /** Fill color for polyline */
46
+ fillColor?: string;
47
+ /** Store full element for rendering */
48
+ element?: unknown;
49
+ /** Optional additional properties */
50
+ [key: string]: unknown;
51
+ }
52
+ export interface AnnotationInfoProperty {
53
+ /** Key to access the property value from the annotation document */
54
+ key: string;
55
+ /** Display label for this property */
56
+ label: string;
57
+ /** Optional formatter function to transform the value before display */
58
+ formatter?: (value: unknown, doc: {
59
+ id: string | number;
60
+ elementCount: number;
61
+ totalPoints: number;
62
+ types: string[];
63
+ filteredCount?: number;
64
+ filteredPoints?: number;
65
+ }) => string | React.ReactNode;
66
+ /** Whether to display this property (default: true) */
67
+ show?: boolean;
68
+ }
69
+ export interface AnnotationInfoConfig {
70
+ /** Properties to display for each fetched annotation document */
71
+ documentProperties?: AnnotationInfoProperty[];
72
+ /** Whether to show the "Fetched from DSA API" section */
73
+ showFetchedSection?: boolean;
74
+ /** Whether to show the "Provided Annotations" section */
75
+ showProvidedSection?: boolean;
76
+ /** Whether to show the "Total Rendered" section */
77
+ showTotalSection?: boolean;
78
+ /** Custom header text */
79
+ headerText?: string;
80
+ }
81
+ export interface SlideViewerProps {
82
+ /** Image information for the slide to display */
83
+ imageInfo: SlideImageInfo;
84
+ /** Annotations to render on the slide (array of rectangles or GeoJSON) */
85
+ annotations?: AnnotationFeature[] | FeatureCollection;
86
+ /** Annotation IDs to fetch from DSA API (baseUrl/annotation/{id}) */
87
+ annotationIds?: (string | number)[];
88
+ /** Base URL for DSA API (e.g., 'http://bdsa.pathology.emory.edu:8080/api/v1') */
89
+ apiBaseUrl?: string;
90
+ /** Callback when viewer is ready */
91
+ onViewerReady?: (viewer: OpenSeadragonViewer) => void;
92
+ /** Callback when annotation is clicked */
93
+ onAnnotationClick?: (annotation: AnnotationFeature) => void;
94
+ /** Default stroke color for annotations */
95
+ defaultAnnotationColor?: string;
96
+ /** Stroke width for annotations */
97
+ strokeWidth?: number;
98
+ /** Additional OpenSeadragon configuration options */
99
+ osdOptions?: OpenSeadragonOptions;
100
+ /** Custom CSS class name */
101
+ className?: string;
102
+ /** Height for the viewer container (e.g., '600px', '100vh', '100%').
103
+ * Required: OpenSeadragon needs an explicit height to initialize properly. */
104
+ height?: string | number;
105
+ /** Width for the viewer container (defaults to '100%') */
106
+ width?: string | number;
107
+ /** Display information about loaded annotation documents */
108
+ showAnnotationInfo?: boolean;
109
+ /** Configuration for customizing the annotation info panel display */
110
+ annotationInfoConfig?: AnnotationInfoConfig;
111
+ /** Maximum number of points allowed per annotation element (default: 10000).
112
+ * Annotations exceeding this limit will be skipped with a warning. */
113
+ maxPointsPerAnnotation?: number;
114
+ /** Maximum total number of points allowed across all annotations (default: 100000).
115
+ * If exceeded, annotations will be filtered starting from the largest ones. */
116
+ maxTotalPoints?: number;
117
+ /** Custom fetch function for API requests. Useful for adding authentication headers.
118
+ * If not provided, uses the default `fetch`. The function should match the Fetch API signature. */
119
+ fetchFn?: (url: string, options?: RequestInit) => Promise<Response>;
120
+ /** Custom headers to add to all API requests. Merged with fetchFn headers if both are provided. */
121
+ apiHeaders?: HeadersInit;
122
+ /** Show annotation controls panel in the sidebar (default: false) */
123
+ showAnnotationControls?: boolean;
124
+ /** Default opacity for all annotations (0-1, default: 1) */
125
+ defaultAnnotationOpacity?: number;
126
+ }
127
+ /**
128
+ * A slide viewer component that integrates OpenSeadragon with Paper.js annotations
129
+ * for viewing Digital Slide Archive images with annotation overlays.
130
+ */
131
+ export declare const SlideViewer: React.ForwardRefExoticComponent<SlideViewerProps & React.RefAttributes<HTMLDivElement>>;
132
+ //# sourceMappingURL=SlideViewer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SlideViewer.d.ts","sourceRoot":"","sources":["../../../src/components/SlideViewer/SlideViewer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAA;AAGnE,OAAO,KAAK,EAAE,iBAAiB,EAAW,MAAM,SAAS,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,IAAI,mBAAmB,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACnG,OAAO,mBAAmB,CAAA;AAE1B,MAAM,WAAW,cAAc;IAC3B,yDAAyD;IACzD,OAAO,CAAC,EAAE,M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