react-zoom-pan-pinch 4.0.0 → 4.0.2
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.
- package/package.json +4 -3
- package/src/stories/assets/big-image.jpeg +0 -0
- package/src/stories/assets/map.jpg +0 -0
- package/src/stories/assets/medium-image.jpg +0 -0
- package/src/stories/assets/pin.svg +0 -1
- package/src/stories/assets/small-image.jpg +0 -0
- package/src/stories/assets/svg-example.svg +0 -14
- package/src/stories/docs/DocTable.tsx +0 -59
- package/src/stories/docs/HandlerCards.tsx +0 -102
- package/src/stories/docs/Introduction.stories.mdx +0 -135
- package/src/stories/docs/PropTable.tsx +0 -116
- package/src/stories/docs/docs.module.css +0 -370
- package/src/stories/docs/handlers.stories.mdx +0 -7
- package/src/stories/docs/handlers.tsx +0 -111
- package/src/stories/docs/props.stories.mdx +0 -11
- package/src/stories/docs/props.tsx +0 -571
- package/src/stories/examples/axis-lock/axis-lock.stories.mdx +0 -35
- package/src/stories/examples/axis-lock/example.tsx +0 -114
- package/src/stories/examples/bounds/bounds.data.tsx +0 -191
- package/src/stories/examples/bounds/bounds.stories.mdx +0 -99
- package/src/stories/examples/center-zoomed-out/center-zoomed-out.stories.mdx +0 -206
- package/src/stories/examples/cinema/cinema-data.tsx +0 -578
- package/src/stories/examples/cinema/cinema.stories.mdx +0 -30
- package/src/stories/examples/cinema/example.tsx +0 -378
- package/src/stories/examples/cinema/image.png +0 -0
- package/src/stories/examples/content/content.stories.mdx +0 -172
- package/src/stories/examples/content/mixed-content.data.tsx +0 -624
- package/src/stories/examples/content-rerendering/content-updating.stories.mdx +0 -34
- package/src/stories/examples/content-rerendering/example.tsx +0 -631
- package/src/stories/examples/controls/controls.stories.mdx +0 -120
- package/src/stories/examples/image/example.tsx +0 -149
- package/src/stories/examples/image/image.stories.mdx +0 -46
- package/src/stories/examples/image-annotations/example.tsx +0 -1442
- package/src/stories/examples/image-annotations/image-annotations.stories.mdx +0 -39
- package/src/stories/examples/image-responsive/example.tsx +0 -152
- package/src/stories/examples/image-responsive/image-responsive.stories.mdx +0 -51
- package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +0 -107
- package/src/stories/examples/initial-transform/example.tsx +0 -233
- package/src/stories/examples/initial-transform/initial-transform.stories.mdx +0 -37
- package/src/stories/examples/keep-scale/example.tsx +0 -882
- package/src/stories/examples/keep-scale/keep-scale.stories.mdx +0 -30
- package/src/stories/examples/keep-scale/map.stories.mdx +0 -28
- package/src/stories/examples/medical-viewer/chest-xray.tsx +0 -246
- package/src/stories/examples/medical-viewer/example.tsx +0 -690
- package/src/stories/examples/medical-viewer/medical-viewer.stories.mdx +0 -49
- package/src/stories/examples/mini-map/example.tsx +0 -122
- package/src/stories/examples/mini-map/mini-map.stories.mdx +0 -26
- package/src/stories/examples/miro/example.tsx +0 -1573
- package/src/stories/examples/miro/miro.stories.mdx +0 -31
- package/src/stories/examples/padding/example.tsx +0 -147
- package/src/stories/examples/padding/padding.stories.mdx +0 -35
- package/src/stories/examples/product-card/example.tsx +0 -594
- package/src/stories/examples/product-card/product-card.stories.mdx +0 -29
- package/src/stories/examples/stadium/example.tsx +0 -1040
- package/src/stories/examples/stadium/stadium-data.ts +0 -224
- package/src/stories/examples/stadium/stadium.stories.mdx +0 -32
- package/src/stories/examples/stress/example.tsx +0 -59
- package/src/stories/examples/stress/stress-test.stories.mdx +0 -28
- package/src/stories/examples/svg-zoom-to-element/creativity.svg +0 -143
- package/src/stories/examples/svg-zoom-to-element/example.tsx +0 -95
- package/src/stories/examples/svg-zoom-to-element/svg-zoom-to-element.stories.mdx +0 -28
- package/src/stories/examples/text-selection/example.tsx +0 -221
- package/src/stories/examples/text-selection/text-selection.stories.mdx +0 -31
- package/src/stories/examples/velocity/example.tsx +0 -908
- package/src/stories/examples/velocity/velocity.stories.mdx +0 -35
- package/src/stories/examples/virtualize/example.tsx +0 -239
- package/src/stories/examples/virtualize/virtualize.stories.mdx +0 -84
- package/src/stories/examples/zoom-to-element/example.tsx +0 -219
- package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +0 -31
- package/src/stories/hooks/use-controls.stories.mdx +0 -86
- package/src/stories/hooks/use-transform-component.stories.mdx +0 -108
- package/src/stories/hooks/use-transform-context.stories.mdx +0 -92
- package/src/stories/hooks/use-transform-effect.stories.mdx +0 -114
- package/src/stories/hooks/use-transform-init.stories.mdx +0 -105
- package/src/stories/types/args.types.ts +0 -192
- package/src/stories/utils/args.utils.ts +0 -35
- package/src/stories/utils/bounds-overlay.tsx +0 -168
- package/src/stories/utils/code.utils.tsx +0 -22
- package/src/stories/utils/controls.utils.tsx +0 -347
- package/src/stories/utils/index.ts +0 -5
- package/src/stories/utils/styles.module.css +0 -223
- package/src/stories/utils/viewer.styles.ts +0 -34
|
@@ -1,690 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import { TransformWrapper, TransformComponent } from "../../../components";
|
|
4
|
-
import { useTransformComponent } from "../../../hooks";
|
|
5
|
-
import { Controls, normalizeArgs } from "../../utils";
|
|
6
|
-
import { ChestXray, XRAY_W, XRAY_H } from "./chest-xray";
|
|
7
|
-
|
|
8
|
-
const font =
|
|
9
|
-
'ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif';
|
|
10
|
-
const mono = '"SF Mono", ui-monospace, "Cascadia Code", monospace';
|
|
11
|
-
|
|
12
|
-
type WindowPreset = {
|
|
13
|
-
id: string;
|
|
14
|
-
label: string;
|
|
15
|
-
brightness: number;
|
|
16
|
-
contrast: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const PRESETS: WindowPreset[] = [
|
|
20
|
-
{ id: "default", label: "Default", brightness: 1, contrast: 1 },
|
|
21
|
-
{ id: "lung", label: "Lung", brightness: 1.3, contrast: 1.6 },
|
|
22
|
-
{ id: "bone", label: "Bone", brightness: 0.85, contrast: 2.0 },
|
|
23
|
-
{ id: "soft", label: "Soft tissue", brightness: 1.15, contrast: 0.85 },
|
|
24
|
-
{ id: "mediastinum", label: "Mediastinum", brightness: 0.9, contrast: 1.35 },
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
interface Finding {
|
|
28
|
-
id: string;
|
|
29
|
-
x: number;
|
|
30
|
-
y: number;
|
|
31
|
-
label: string;
|
|
32
|
-
detail: string;
|
|
33
|
-
severity: "normal" | "mild" | "significant";
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const FINDINGS: Finding[] = [
|
|
37
|
-
{
|
|
38
|
-
id: "f1",
|
|
39
|
-
x: 320,
|
|
40
|
-
y: 580,
|
|
41
|
-
label: "Cardiomediastinal",
|
|
42
|
-
detail: "Heart size within normal limits. No mediastinal widening.",
|
|
43
|
-
severity: "normal",
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: "f2",
|
|
47
|
-
x: 680,
|
|
48
|
-
y: 450,
|
|
49
|
-
label: "Left hilum",
|
|
50
|
-
detail: "Mildly prominent left hilum — consider lymphadenopathy.",
|
|
51
|
-
severity: "mild",
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
id: "f3",
|
|
55
|
-
x: 250,
|
|
56
|
-
y: 720,
|
|
57
|
-
label: "Right base",
|
|
58
|
-
detail: "Subtle opacity at right costophrenic angle — small effusion?",
|
|
59
|
-
severity: "significant",
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
id: "f4",
|
|
63
|
-
x: 512,
|
|
64
|
-
y: 300,
|
|
65
|
-
label: "Trachea",
|
|
66
|
-
detail: "Midline trachea. No deviation.",
|
|
67
|
-
severity: "normal",
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
|
|
71
|
-
const SEV_COLORS: Record<Finding["severity"], string> = {
|
|
72
|
-
normal: "#22c55e",
|
|
73
|
-
mild: "#f59e0b",
|
|
74
|
-
significant: "#ef4444",
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/* ── Toolbar primitives ─────────────────────────────────────── */
|
|
78
|
-
|
|
79
|
-
function ToolbarGroup({
|
|
80
|
-
label,
|
|
81
|
-
children,
|
|
82
|
-
}: {
|
|
83
|
-
label: string;
|
|
84
|
-
children: React.ReactNode;
|
|
85
|
-
}) {
|
|
86
|
-
return (
|
|
87
|
-
<div style={{ display: "flex", alignItems: "center", gap: 4 }}>
|
|
88
|
-
<span
|
|
89
|
-
style={{
|
|
90
|
-
fontSize: 10,
|
|
91
|
-
fontWeight: 700,
|
|
92
|
-
letterSpacing: "0.08em",
|
|
93
|
-
textTransform: "uppercase",
|
|
94
|
-
color: "#444",
|
|
95
|
-
marginRight: 4,
|
|
96
|
-
whiteSpace: "nowrap",
|
|
97
|
-
}}
|
|
98
|
-
>
|
|
99
|
-
{label}
|
|
100
|
-
</span>
|
|
101
|
-
{children}
|
|
102
|
-
</div>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function ToolbarButton({
|
|
107
|
-
label,
|
|
108
|
-
active,
|
|
109
|
-
onClick,
|
|
110
|
-
accent,
|
|
111
|
-
}: {
|
|
112
|
-
label: string;
|
|
113
|
-
active: boolean;
|
|
114
|
-
onClick: () => void;
|
|
115
|
-
accent: string;
|
|
116
|
-
}) {
|
|
117
|
-
return (
|
|
118
|
-
<button
|
|
119
|
-
type="button"
|
|
120
|
-
onClick={onClick}
|
|
121
|
-
style={{
|
|
122
|
-
fontFamily: "inherit",
|
|
123
|
-
fontSize: 11,
|
|
124
|
-
fontWeight: 600,
|
|
125
|
-
padding: "5px 10px",
|
|
126
|
-
borderRadius: 6,
|
|
127
|
-
border: active ? `1px solid ${accent}55` : "1px solid #222",
|
|
128
|
-
background: active ? `${accent}18` : "transparent",
|
|
129
|
-
color: active ? accent : "#666",
|
|
130
|
-
cursor: "pointer",
|
|
131
|
-
whiteSpace: "nowrap",
|
|
132
|
-
}}
|
|
133
|
-
>
|
|
134
|
-
{label}
|
|
135
|
-
</button>
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function ToolbarDivider() {
|
|
140
|
-
return (
|
|
141
|
-
<span
|
|
142
|
-
style={{
|
|
143
|
-
width: 1,
|
|
144
|
-
height: 20,
|
|
145
|
-
background: "#222",
|
|
146
|
-
margin: "0 6px",
|
|
147
|
-
flexShrink: 0,
|
|
148
|
-
}}
|
|
149
|
-
/>
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/* ── DICOM corner overlays ──────────────────────────────────── */
|
|
154
|
-
|
|
155
|
-
const overlayBase: React.CSSProperties = {
|
|
156
|
-
position: "absolute",
|
|
157
|
-
zIndex: 10,
|
|
158
|
-
fontFamily: mono,
|
|
159
|
-
fontSize: 11,
|
|
160
|
-
lineHeight: 1.6,
|
|
161
|
-
color: "#888",
|
|
162
|
-
pointerEvents: "none",
|
|
163
|
-
userSelect: "none",
|
|
164
|
-
textShadow: "0 1px 4px rgba(0,0,0,0.9)",
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
function DicomOverlayTL() {
|
|
168
|
-
return (
|
|
169
|
-
<div style={{ ...overlayBase, top: 16, left: 16 }}>
|
|
170
|
-
<div style={{ color: "#aaa", fontWeight: 700, marginBottom: 2 }}>
|
|
171
|
-
SMITH, JOHN A
|
|
172
|
-
</div>
|
|
173
|
-
<div>DOB: 15-Mar-1978 · M</div>
|
|
174
|
-
<div>MRN: 00847291</div>
|
|
175
|
-
<div style={{ marginTop: 6, fontSize: 10, color: "#555" }}>
|
|
176
|
-
Lumen Regional Medical Center
|
|
177
|
-
</div>
|
|
178
|
-
</div>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function DicomOverlayTR({
|
|
183
|
-
preset,
|
|
184
|
-
inverted,
|
|
185
|
-
}: {
|
|
186
|
-
preset: WindowPreset;
|
|
187
|
-
inverted: boolean;
|
|
188
|
-
}) {
|
|
189
|
-
return (
|
|
190
|
-
<div style={{ ...overlayBase, top: 16, right: 16, textAlign: "right" }}>
|
|
191
|
-
<div>CR · PA Chest</div>
|
|
192
|
-
<div>2024-12-08 14:32</div>
|
|
193
|
-
<div style={{ marginTop: 6 }}>
|
|
194
|
-
W: {(preset.contrast * 400).toFixed(0)} L:{" "}
|
|
195
|
-
{(preset.brightness * 40).toFixed(0)}
|
|
196
|
-
</div>
|
|
197
|
-
{inverted && <div style={{ color: "#60a5fa" }}>INVERTED</div>}
|
|
198
|
-
</div>
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function DicomOverlayBL() {
|
|
203
|
-
return (
|
|
204
|
-
<div style={{ ...overlayBase, bottom: 50, left: 16 }}>
|
|
205
|
-
<div>Series: 1 · Image: 1/1</div>
|
|
206
|
-
<div>
|
|
207
|
-
Matrix: {XRAY_W} × {XRAY_H}
|
|
208
|
-
</div>
|
|
209
|
-
</div>
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/* ── Finding marker on image ────────────────────────────────── */
|
|
214
|
-
|
|
215
|
-
function FindingMarker({
|
|
216
|
-
finding: f,
|
|
217
|
-
active,
|
|
218
|
-
onToggle,
|
|
219
|
-
}: {
|
|
220
|
-
finding: Finding;
|
|
221
|
-
active: boolean;
|
|
222
|
-
onToggle: () => void;
|
|
223
|
-
}) {
|
|
224
|
-
const color = SEV_COLORS[f.severity];
|
|
225
|
-
|
|
226
|
-
return (
|
|
227
|
-
<>
|
|
228
|
-
<button
|
|
229
|
-
type="button"
|
|
230
|
-
id={`finding-${f.id}`}
|
|
231
|
-
aria-label={f.label}
|
|
232
|
-
onClick={(e) => {
|
|
233
|
-
e.stopPropagation();
|
|
234
|
-
onToggle();
|
|
235
|
-
}}
|
|
236
|
-
style={{
|
|
237
|
-
position: "absolute",
|
|
238
|
-
left: f.x,
|
|
239
|
-
top: f.y,
|
|
240
|
-
width: 24,
|
|
241
|
-
height: 24,
|
|
242
|
-
marginLeft: -12,
|
|
243
|
-
marginTop: -12,
|
|
244
|
-
borderRadius: "50%",
|
|
245
|
-
border: `2px solid ${color}`,
|
|
246
|
-
background: active ? `${color}35` : "transparent",
|
|
247
|
-
cursor: "pointer",
|
|
248
|
-
boxShadow: active
|
|
249
|
-
? `0 0 0 6px ${color}22, 0 0 16px ${color}44`
|
|
250
|
-
: `0 0 12px ${color}33`,
|
|
251
|
-
transition: "box-shadow 0.2s ease, background 0.2s ease",
|
|
252
|
-
zIndex: active ? 8 : 5,
|
|
253
|
-
padding: 0,
|
|
254
|
-
}}
|
|
255
|
-
/>
|
|
256
|
-
|
|
257
|
-
{active && (
|
|
258
|
-
<div
|
|
259
|
-
style={{
|
|
260
|
-
position: "absolute",
|
|
261
|
-
left: f.x + 20,
|
|
262
|
-
top: f.y - 16,
|
|
263
|
-
zIndex: 20,
|
|
264
|
-
minWidth: 220,
|
|
265
|
-
maxWidth: 300,
|
|
266
|
-
padding: "10px 14px",
|
|
267
|
-
borderRadius: 10,
|
|
268
|
-
background: "rgba(10, 10, 10, 0.94)",
|
|
269
|
-
border: `1px solid ${color}55`,
|
|
270
|
-
boxShadow: `0 12px 36px rgba(0,0,0,0.6), 0 0 0 1px ${color}22`,
|
|
271
|
-
fontFamily: font,
|
|
272
|
-
pointerEvents: "auto",
|
|
273
|
-
}}
|
|
274
|
-
>
|
|
275
|
-
<div
|
|
276
|
-
style={{
|
|
277
|
-
display: "flex",
|
|
278
|
-
alignItems: "center",
|
|
279
|
-
gap: 8,
|
|
280
|
-
marginBottom: 8,
|
|
281
|
-
}}
|
|
282
|
-
>
|
|
283
|
-
<span
|
|
284
|
-
style={{
|
|
285
|
-
width: 8,
|
|
286
|
-
height: 8,
|
|
287
|
-
borderRadius: "50%",
|
|
288
|
-
background: color,
|
|
289
|
-
boxShadow: `0 0 8px ${color}`,
|
|
290
|
-
flexShrink: 0,
|
|
291
|
-
}}
|
|
292
|
-
/>
|
|
293
|
-
<span
|
|
294
|
-
style={{
|
|
295
|
-
fontSize: 12,
|
|
296
|
-
fontWeight: 700,
|
|
297
|
-
color: "#e2e8f0",
|
|
298
|
-
}}
|
|
299
|
-
>
|
|
300
|
-
{f.label}
|
|
301
|
-
</span>
|
|
302
|
-
<span
|
|
303
|
-
style={{
|
|
304
|
-
marginLeft: "auto",
|
|
305
|
-
fontSize: 10,
|
|
306
|
-
fontWeight: 600,
|
|
307
|
-
textTransform: "uppercase",
|
|
308
|
-
letterSpacing: "0.06em",
|
|
309
|
-
color,
|
|
310
|
-
}}
|
|
311
|
-
>
|
|
312
|
-
{f.severity}
|
|
313
|
-
</span>
|
|
314
|
-
</div>
|
|
315
|
-
<p
|
|
316
|
-
style={{
|
|
317
|
-
margin: 0,
|
|
318
|
-
fontSize: 12,
|
|
319
|
-
lineHeight: 1.55,
|
|
320
|
-
color: "#94a3b8",
|
|
321
|
-
}}
|
|
322
|
-
>
|
|
323
|
-
{f.detail}
|
|
324
|
-
</p>
|
|
325
|
-
</div>
|
|
326
|
-
)}
|
|
327
|
-
</>
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/* ── Finding chip in bottom panel ───────────────────────────── */
|
|
332
|
-
|
|
333
|
-
function FindingChip({
|
|
334
|
-
finding: f,
|
|
335
|
-
active,
|
|
336
|
-
onToggle,
|
|
337
|
-
}: {
|
|
338
|
-
finding: Finding;
|
|
339
|
-
active: boolean;
|
|
340
|
-
onToggle: () => void;
|
|
341
|
-
}) {
|
|
342
|
-
const color = SEV_COLORS[f.severity];
|
|
343
|
-
return (
|
|
344
|
-
<button
|
|
345
|
-
type="button"
|
|
346
|
-
onClick={onToggle}
|
|
347
|
-
style={{
|
|
348
|
-
display: "inline-flex",
|
|
349
|
-
alignItems: "center",
|
|
350
|
-
gap: 8,
|
|
351
|
-
padding: "8px 14px",
|
|
352
|
-
borderRadius: 10,
|
|
353
|
-
border: active ? `1px solid ${color}66` : "1px solid #1f1f1f",
|
|
354
|
-
background: active ? `${color}14` : "#111",
|
|
355
|
-
cursor: "pointer",
|
|
356
|
-
fontFamily: "inherit",
|
|
357
|
-
}}
|
|
358
|
-
>
|
|
359
|
-
<span
|
|
360
|
-
style={{
|
|
361
|
-
width: 7,
|
|
362
|
-
height: 7,
|
|
363
|
-
borderRadius: "50%",
|
|
364
|
-
background: color,
|
|
365
|
-
boxShadow: active ? `0 0 8px ${color}` : "none",
|
|
366
|
-
flexShrink: 0,
|
|
367
|
-
}}
|
|
368
|
-
/>
|
|
369
|
-
<span style={{ fontSize: 12, fontWeight: 600, color: "#ccc" }}>
|
|
370
|
-
{f.label}
|
|
371
|
-
</span>
|
|
372
|
-
</button>
|
|
373
|
-
);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/* ── Ruler overlay ──────────────────────────────────────────── */
|
|
377
|
-
|
|
378
|
-
function RulerOverlay() {
|
|
379
|
-
const tickCount = Math.floor(XRAY_H / 100);
|
|
380
|
-
|
|
381
|
-
return (
|
|
382
|
-
<div
|
|
383
|
-
style={{
|
|
384
|
-
position: "absolute",
|
|
385
|
-
left: 6,
|
|
386
|
-
top: 0,
|
|
387
|
-
width: 32,
|
|
388
|
-
height: XRAY_H,
|
|
389
|
-
pointerEvents: "none",
|
|
390
|
-
zIndex: 6,
|
|
391
|
-
}}
|
|
392
|
-
>
|
|
393
|
-
<div
|
|
394
|
-
style={{
|
|
395
|
-
position: "absolute",
|
|
396
|
-
left: 14,
|
|
397
|
-
top: 0,
|
|
398
|
-
width: 1,
|
|
399
|
-
height: "100%",
|
|
400
|
-
background: "rgba(52, 211, 153, 0.45)",
|
|
401
|
-
}}
|
|
402
|
-
/>
|
|
403
|
-
{Array.from({ length: tickCount + 1 }, (_, i) => {
|
|
404
|
-
const y = i * 100;
|
|
405
|
-
const major = i % 5 === 0;
|
|
406
|
-
return (
|
|
407
|
-
<React.Fragment key={i}>
|
|
408
|
-
<div
|
|
409
|
-
style={{
|
|
410
|
-
position: "absolute",
|
|
411
|
-
left: major ? 6 : 10,
|
|
412
|
-
top: y,
|
|
413
|
-
width: major ? 18 : 10,
|
|
414
|
-
height: 1,
|
|
415
|
-
background: major
|
|
416
|
-
? "rgba(52, 211, 153, 0.7)"
|
|
417
|
-
: "rgba(52, 211, 153, 0.35)",
|
|
418
|
-
}}
|
|
419
|
-
/>
|
|
420
|
-
{major && (
|
|
421
|
-
<span
|
|
422
|
-
style={{
|
|
423
|
-
position: "absolute",
|
|
424
|
-
left: 28,
|
|
425
|
-
top: y - 5,
|
|
426
|
-
fontSize: 9,
|
|
427
|
-
fontFamily: mono,
|
|
428
|
-
fontWeight: 600,
|
|
429
|
-
color: "rgba(52, 211, 153, 0.65)",
|
|
430
|
-
}}
|
|
431
|
-
>
|
|
432
|
-
{i}
|
|
433
|
-
</span>
|
|
434
|
-
)}
|
|
435
|
-
</React.Fragment>
|
|
436
|
-
);
|
|
437
|
-
})}
|
|
438
|
-
|
|
439
|
-
{/* Horizontal ruler at top */}
|
|
440
|
-
<div
|
|
441
|
-
style={{
|
|
442
|
-
position: "absolute",
|
|
443
|
-
left: 0,
|
|
444
|
-
top: 0,
|
|
445
|
-
width: XRAY_W,
|
|
446
|
-
height: 20,
|
|
447
|
-
}}
|
|
448
|
-
>
|
|
449
|
-
<div
|
|
450
|
-
style={{
|
|
451
|
-
position: "absolute",
|
|
452
|
-
left: 0,
|
|
453
|
-
top: 14,
|
|
454
|
-
width: XRAY_W,
|
|
455
|
-
height: 1,
|
|
456
|
-
background: "rgba(52, 211, 153, 0.3)",
|
|
457
|
-
}}
|
|
458
|
-
/>
|
|
459
|
-
{Array.from({ length: Math.floor(XRAY_W / 100) + 1 }, (_, i) => {
|
|
460
|
-
const x = i * 100;
|
|
461
|
-
const major = i % 5 === 0;
|
|
462
|
-
return (
|
|
463
|
-
<React.Fragment key={`h-${i}`}>
|
|
464
|
-
<div
|
|
465
|
-
style={{
|
|
466
|
-
position: "absolute",
|
|
467
|
-
left: x,
|
|
468
|
-
top: major ? 6 : 10,
|
|
469
|
-
width: 1,
|
|
470
|
-
height: major ? 14 : 6,
|
|
471
|
-
background: major
|
|
472
|
-
? "rgba(52, 211, 153, 0.6)"
|
|
473
|
-
: "rgba(52, 211, 153, 0.3)",
|
|
474
|
-
}}
|
|
475
|
-
/>
|
|
476
|
-
</React.Fragment>
|
|
477
|
-
);
|
|
478
|
-
})}
|
|
479
|
-
</div>
|
|
480
|
-
</div>
|
|
481
|
-
);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/* ── Scale badge ────────────────────────────────────────────── */
|
|
485
|
-
|
|
486
|
-
function ScaleBadge() {
|
|
487
|
-
return useTransformComponent(({ state }) => (
|
|
488
|
-
<div
|
|
489
|
-
style={{
|
|
490
|
-
position: "absolute",
|
|
491
|
-
bottom: 16,
|
|
492
|
-
right: 16,
|
|
493
|
-
zIndex: 10,
|
|
494
|
-
padding: "4px 10px",
|
|
495
|
-
borderRadius: 6,
|
|
496
|
-
background: "rgba(0, 0, 0, 0.7)",
|
|
497
|
-
border: "1px solid rgba(255,255,255,0.1)",
|
|
498
|
-
color: "#aaa",
|
|
499
|
-
fontSize: 11,
|
|
500
|
-
fontWeight: 600,
|
|
501
|
-
fontFamily: mono,
|
|
502
|
-
pointerEvents: "none",
|
|
503
|
-
userSelect: "none",
|
|
504
|
-
}}
|
|
505
|
-
>
|
|
506
|
-
{(state.scale * 100).toFixed(0)}%
|
|
507
|
-
</div>
|
|
508
|
-
));
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/* ── Main component ─────────────────────────────────────────── */
|
|
512
|
-
|
|
513
|
-
export const Example: React.FC<Record<string, unknown>> = (args) => {
|
|
514
|
-
const normalized = normalizeArgs(args);
|
|
515
|
-
const [activePreset, setActivePreset] = useState<string>("default");
|
|
516
|
-
const [inverted, setInverted] = useState(false);
|
|
517
|
-
const [showFindings, setShowFindings] = useState(true);
|
|
518
|
-
const [showRuler, setShowRuler] = useState(false);
|
|
519
|
-
const [activeFinding, setActiveFinding] = useState<string | null>(null);
|
|
520
|
-
|
|
521
|
-
const preset = PRESETS.find((p) => p.id === activePreset)!;
|
|
522
|
-
|
|
523
|
-
const imageFilter = [
|
|
524
|
-
`brightness(${preset.brightness})`,
|
|
525
|
-
`contrast(${preset.contrast})`,
|
|
526
|
-
inverted ? "invert(1)" : "",
|
|
527
|
-
]
|
|
528
|
-
.filter(Boolean)
|
|
529
|
-
.join(" ");
|
|
530
|
-
|
|
531
|
-
const toggleFinding = useCallback((id: string) => {
|
|
532
|
-
setActiveFinding((prev) => (prev === id ? null : id));
|
|
533
|
-
}, []);
|
|
534
|
-
|
|
535
|
-
return (
|
|
536
|
-
<div
|
|
537
|
-
style={{
|
|
538
|
-
fontFamily: font,
|
|
539
|
-
background: "#000",
|
|
540
|
-
borderRadius: 14,
|
|
541
|
-
overflow: "hidden",
|
|
542
|
-
boxSizing: "border-box",
|
|
543
|
-
}}
|
|
544
|
-
>
|
|
545
|
-
{/* Toolbar */}
|
|
546
|
-
<div
|
|
547
|
-
style={{
|
|
548
|
-
display: "flex",
|
|
549
|
-
flexWrap: "wrap",
|
|
550
|
-
gap: 6,
|
|
551
|
-
padding: "10px 16px",
|
|
552
|
-
borderBottom: "1px solid #1a1a1a",
|
|
553
|
-
background: "#0a0a0a",
|
|
554
|
-
alignItems: "center",
|
|
555
|
-
}}
|
|
556
|
-
>
|
|
557
|
-
{/* Presets */}
|
|
558
|
-
<ToolbarGroup label="Window">
|
|
559
|
-
{PRESETS.map((p) => (
|
|
560
|
-
<ToolbarButton
|
|
561
|
-
key={p.id}
|
|
562
|
-
label={p.label}
|
|
563
|
-
active={activePreset === p.id}
|
|
564
|
-
onClick={() => setActivePreset(p.id)}
|
|
565
|
-
accent="#e2e8f0"
|
|
566
|
-
/>
|
|
567
|
-
))}
|
|
568
|
-
</ToolbarGroup>
|
|
569
|
-
|
|
570
|
-
<ToolbarDivider />
|
|
571
|
-
|
|
572
|
-
<ToolbarGroup label="Display">
|
|
573
|
-
<ToolbarButton
|
|
574
|
-
label="Invert"
|
|
575
|
-
active={inverted}
|
|
576
|
-
onClick={() => setInverted((v) => !v)}
|
|
577
|
-
accent="#60a5fa"
|
|
578
|
-
/>
|
|
579
|
-
<ToolbarButton
|
|
580
|
-
label="Findings"
|
|
581
|
-
active={showFindings}
|
|
582
|
-
onClick={() => {
|
|
583
|
-
setShowFindings((v) => !v);
|
|
584
|
-
if (showFindings) setActiveFinding(null);
|
|
585
|
-
}}
|
|
586
|
-
accent="#a78bfa"
|
|
587
|
-
/>
|
|
588
|
-
<ToolbarButton
|
|
589
|
-
label="Ruler"
|
|
590
|
-
active={showRuler}
|
|
591
|
-
onClick={() => setShowRuler((v) => !v)}
|
|
592
|
-
accent="#34d399"
|
|
593
|
-
/>
|
|
594
|
-
</ToolbarGroup>
|
|
595
|
-
</div>
|
|
596
|
-
|
|
597
|
-
<div style={{ position: "relative" }}>
|
|
598
|
-
{/* DICOM corner overlays */}
|
|
599
|
-
<DicomOverlayTL />
|
|
600
|
-
<DicomOverlayTR preset={preset} inverted={inverted} />
|
|
601
|
-
<DicomOverlayBL />
|
|
602
|
-
|
|
603
|
-
<TransformWrapper
|
|
604
|
-
{...normalized}
|
|
605
|
-
centerOnInit
|
|
606
|
-
centerZoomedOut
|
|
607
|
-
minScale={0.25}
|
|
608
|
-
maxScale={10}
|
|
609
|
-
doubleClick={{ step: 1.8 }}
|
|
610
|
-
>
|
|
611
|
-
{(utils) => (
|
|
612
|
-
<>
|
|
613
|
-
<Controls {...utils} position="bottom-right" />
|
|
614
|
-
<ScaleBadge />
|
|
615
|
-
<TransformComponent
|
|
616
|
-
wrapperStyle={{
|
|
617
|
-
width: "100%",
|
|
618
|
-
height: "min(640px, 72vh)",
|
|
619
|
-
minHeight: 420,
|
|
620
|
-
background: "#000",
|
|
621
|
-
}}
|
|
622
|
-
contentStyle={{
|
|
623
|
-
width: XRAY_W,
|
|
624
|
-
height: XRAY_H,
|
|
625
|
-
}}
|
|
626
|
-
>
|
|
627
|
-
<div style={{ position: "relative" }}>
|
|
628
|
-
<div
|
|
629
|
-
style={{
|
|
630
|
-
filter: imageFilter,
|
|
631
|
-
transition: "filter 0.25s ease",
|
|
632
|
-
}}
|
|
633
|
-
>
|
|
634
|
-
<ChestXray />
|
|
635
|
-
</div>
|
|
636
|
-
|
|
637
|
-
{showRuler && <RulerOverlay />}
|
|
638
|
-
|
|
639
|
-
{showFindings &&
|
|
640
|
-
FINDINGS.map((f) => (
|
|
641
|
-
<FindingMarker
|
|
642
|
-
key={f.id}
|
|
643
|
-
finding={f}
|
|
644
|
-
active={activeFinding === f.id}
|
|
645
|
-
onToggle={() => toggleFinding(f.id)}
|
|
646
|
-
/>
|
|
647
|
-
))}
|
|
648
|
-
</div>
|
|
649
|
-
</TransformComponent>
|
|
650
|
-
</>
|
|
651
|
-
)}
|
|
652
|
-
</TransformWrapper>
|
|
653
|
-
</div>
|
|
654
|
-
|
|
655
|
-
{/* Findings panel */}
|
|
656
|
-
{showFindings && (
|
|
657
|
-
<div
|
|
658
|
-
style={{
|
|
659
|
-
borderTop: "1px solid #1a1a1a",
|
|
660
|
-
background: "#0a0a0a",
|
|
661
|
-
padding: "12px 16px",
|
|
662
|
-
}}
|
|
663
|
-
>
|
|
664
|
-
<div
|
|
665
|
-
style={{
|
|
666
|
-
fontSize: 10,
|
|
667
|
-
fontWeight: 700,
|
|
668
|
-
letterSpacing: "0.12em",
|
|
669
|
-
textTransform: "uppercase",
|
|
670
|
-
color: "#555",
|
|
671
|
-
marginBottom: 10,
|
|
672
|
-
}}
|
|
673
|
-
>
|
|
674
|
-
Findings ({FINDINGS.length})
|
|
675
|
-
</div>
|
|
676
|
-
<div style={{ display: "flex", flexWrap: "wrap", gap: 8 }}>
|
|
677
|
-
{FINDINGS.map((f) => (
|
|
678
|
-
<FindingChip
|
|
679
|
-
key={f.id}
|
|
680
|
-
finding={f}
|
|
681
|
-
active={activeFinding === f.id}
|
|
682
|
-
onToggle={() => toggleFinding(f.id)}
|
|
683
|
-
/>
|
|
684
|
-
))}
|
|
685
|
-
</div>
|
|
686
|
-
</div>
|
|
687
|
-
)}
|
|
688
|
-
</div>
|
|
689
|
-
);
|
|
690
|
-
};
|