react-zoom-pan-pinch 3.6.1 → 4.0.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 (139) hide show
  1. package/dist/index.cjs.js +770 -277
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +116 -22
  4. package/dist/index.esm.js +766 -269
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +73 -60
  7. package/src/components/index.ts +5 -0
  8. package/src/components/keep-scale/keep-scale.tsx +28 -0
  9. package/src/components/mini-map/mini-map.tsx +292 -0
  10. package/src/components/mini-map/use-resize.hook.ts +74 -0
  11. package/src/components/transform-component/transform-component.module.css +43 -0
  12. package/src/components/transform-component/transform-component.tsx +96 -0
  13. package/src/components/transform-wrapper/transform-wrapper.tsx +39 -0
  14. package/src/components/virtualize/virtualize.tsx +133 -0
  15. package/src/components/virtualize/virtualize.utils.ts +104 -0
  16. package/src/constants/state.constants.ts +99 -0
  17. package/src/core/animations/animations.constants.ts +78 -0
  18. package/src/core/animations/animations.utils.ts +115 -0
  19. package/src/core/bounds/bounds.types.ts +8 -0
  20. package/src/core/bounds/bounds.utils.ts +226 -0
  21. package/src/core/double-click/double-click.logic.ts +127 -0
  22. package/src/core/handlers/handlers.logic.ts +122 -0
  23. package/src/core/handlers/handlers.utils.ts +243 -0
  24. package/src/core/instance.core.ts +704 -0
  25. package/src/core/pan/panning.logic.ts +122 -0
  26. package/src/core/pan/panning.utils.ts +216 -0
  27. package/src/core/pan/velocity.logic.ts +187 -0
  28. package/src/core/pan/velocity.utils.ts +83 -0
  29. package/src/core/pinch/pinch.logic.ts +139 -0
  30. package/src/core/pinch/pinch.utils.ts +95 -0
  31. package/src/core/wheel/wheel.logic.ts +161 -0
  32. package/src/core/wheel/wheel.utils.ts +157 -0
  33. package/src/core/zoom/zoom.logic.ts +71 -0
  34. package/src/core/zoom/zoom.utils.ts +62 -0
  35. package/src/hooks/index.ts +5 -0
  36. package/src/hooks/use-controls.tsx +9 -0
  37. package/src/hooks/use-transform-component.tsx +30 -0
  38. package/src/hooks/use-transform-context.tsx +13 -0
  39. package/src/hooks/use-transform-effect.tsx +22 -0
  40. package/src/hooks/use-transform-init.tsx +28 -0
  41. package/src/hooks/use-zoom-pan-pinch.tsx +48 -0
  42. package/src/index.ts +6 -0
  43. package/src/models/calculations.model.ts +34 -0
  44. package/src/models/context.model.ts +218 -0
  45. package/src/models/helpers.model.ts +15 -0
  46. package/src/models/index.ts +3 -0
  47. package/src/react-app-env.d.ts +1 -0
  48. package/src/stories/assets/big-image.jpeg +0 -0
  49. package/src/stories/assets/map.jpg +0 -0
  50. package/src/stories/assets/medium-image.jpg +0 -0
  51. package/src/stories/assets/pin.svg +1 -0
  52. package/src/stories/assets/small-image.jpg +0 -0
  53. package/src/stories/assets/svg-example.svg +14 -0
  54. package/src/stories/docs/DocTable.tsx +59 -0
  55. package/src/stories/docs/HandlerCards.tsx +102 -0
  56. package/src/stories/docs/Introduction.stories.mdx +135 -0
  57. package/src/stories/docs/PropTable.tsx +116 -0
  58. package/src/stories/docs/docs.module.css +370 -0
  59. package/src/stories/docs/handlers.stories.mdx +7 -0
  60. package/src/stories/docs/handlers.tsx +111 -0
  61. package/src/stories/docs/props.stories.mdx +11 -0
  62. package/src/stories/docs/props.tsx +571 -0
  63. package/src/stories/examples/axis-lock/axis-lock.stories.mdx +35 -0
  64. package/src/stories/examples/axis-lock/example.tsx +114 -0
  65. package/src/stories/examples/bounds/bounds.data.tsx +191 -0
  66. package/src/stories/examples/bounds/bounds.stories.mdx +99 -0
  67. package/src/stories/examples/center-zoomed-out/center-zoomed-out.stories.mdx +206 -0
  68. package/src/stories/examples/cinema/cinema-data.tsx +578 -0
  69. package/src/stories/examples/cinema/cinema.stories.mdx +30 -0
  70. package/src/stories/examples/cinema/example.tsx +378 -0
  71. package/src/stories/examples/cinema/image.png +0 -0
  72. package/src/stories/examples/content/content.stories.mdx +172 -0
  73. package/src/stories/examples/content/mixed-content.data.tsx +624 -0
  74. package/src/stories/examples/content-rerendering/content-updating.stories.mdx +34 -0
  75. package/src/stories/examples/content-rerendering/example.tsx +631 -0
  76. package/src/stories/examples/controls/controls.stories.mdx +120 -0
  77. package/src/stories/examples/image/example.tsx +149 -0
  78. package/src/stories/examples/image/image.stories.mdx +46 -0
  79. package/src/stories/examples/image-annotations/example.tsx +1442 -0
  80. package/src/stories/examples/image-annotations/image-annotations.stories.mdx +39 -0
  81. package/src/stories/examples/image-responsive/example.tsx +152 -0
  82. package/src/stories/examples/image-responsive/image-responsive.stories.mdx +51 -0
  83. package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +107 -0
  84. package/src/stories/examples/initial-transform/example.tsx +233 -0
  85. package/src/stories/examples/initial-transform/initial-transform.stories.mdx +37 -0
  86. package/src/stories/examples/keep-scale/example.tsx +882 -0
  87. package/src/stories/examples/keep-scale/keep-scale.stories.mdx +30 -0
  88. package/src/stories/examples/keep-scale/map.stories.mdx +28 -0
  89. package/src/stories/examples/medical-viewer/chest-xray.tsx +246 -0
  90. package/src/stories/examples/medical-viewer/example.tsx +690 -0
  91. package/src/stories/examples/medical-viewer/medical-viewer.stories.mdx +49 -0
  92. package/src/stories/examples/mini-map/example.tsx +122 -0
  93. package/src/stories/examples/mini-map/mini-map.stories.mdx +26 -0
  94. package/src/stories/examples/miro/example.tsx +1573 -0
  95. package/src/stories/examples/miro/miro.stories.mdx +31 -0
  96. package/src/stories/examples/padding/example.tsx +147 -0
  97. package/src/stories/examples/padding/padding.stories.mdx +35 -0
  98. package/src/stories/examples/product-card/example.tsx +594 -0
  99. package/src/stories/examples/product-card/product-card.stories.mdx +29 -0
  100. package/src/stories/examples/stadium/example.tsx +1040 -0
  101. package/src/stories/examples/stadium/stadium-data.ts +224 -0
  102. package/src/stories/examples/stadium/stadium.stories.mdx +32 -0
  103. package/src/stories/examples/stress/example.tsx +59 -0
  104. package/src/stories/examples/stress/stress-test.stories.mdx +28 -0
  105. package/src/stories/examples/svg-zoom-to-element/creativity.svg +143 -0
  106. package/src/stories/examples/svg-zoom-to-element/example.tsx +95 -0
  107. package/src/stories/examples/svg-zoom-to-element/svg-zoom-to-element.stories.mdx +28 -0
  108. package/src/stories/examples/text-selection/example.tsx +221 -0
  109. package/src/stories/examples/text-selection/text-selection.stories.mdx +31 -0
  110. package/src/stories/examples/velocity/example.tsx +908 -0
  111. package/src/stories/examples/velocity/velocity.stories.mdx +35 -0
  112. package/src/stories/examples/virtualize/example.tsx +239 -0
  113. package/src/stories/examples/virtualize/virtualize.stories.mdx +84 -0
  114. package/src/stories/examples/zoom-to-element/example.tsx +219 -0
  115. package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +31 -0
  116. package/src/stories/hooks/use-controls.stories.mdx +86 -0
  117. package/src/stories/hooks/use-transform-component.stories.mdx +108 -0
  118. package/src/stories/hooks/use-transform-context.stories.mdx +92 -0
  119. package/src/stories/hooks/use-transform-effect.stories.mdx +114 -0
  120. package/src/stories/hooks/use-transform-init.stories.mdx +105 -0
  121. package/src/stories/types/args.types.ts +192 -0
  122. package/src/stories/utils/args.utils.ts +35 -0
  123. package/src/stories/utils/bounds-overlay.tsx +168 -0
  124. package/src/stories/utils/code.utils.tsx +22 -0
  125. package/src/stories/utils/controls.utils.tsx +347 -0
  126. package/src/stories/utils/index.ts +5 -0
  127. package/src/stories/utils/styles.module.css +223 -0
  128. package/src/stories/utils/viewer.styles.ts +34 -0
  129. package/src/styles.css +8 -0
  130. package/src/typings.d.ts +21 -0
  131. package/src/utils/calculations.utils.ts +16 -0
  132. package/src/utils/callback.utils.ts +11 -0
  133. package/src/utils/context.utils.ts +49 -0
  134. package/src/utils/event.utils.ts +38 -0
  135. package/src/utils/helpers.utils.ts +22 -0
  136. package/src/utils/index.ts +8 -0
  137. package/src/utils/ref.utils.ts +32 -0
  138. package/src/utils/state.utils.ts +77 -0
  139. package/src/utils/styles.utils.ts +49 -0
@@ -0,0 +1,1040 @@
1
+ import React, { useCallback, useRef, useState } from "react";
2
+
3
+ import { TransformWrapper, TransformComponent } from "../../../components";
4
+ import { normalizeArgs, Controls, CloseIcon, viewerChrome } from "../../utils";
5
+ import {
6
+ ALL_SEATS,
7
+ CANVAS_HEIGHT,
8
+ CANVAS_WIDTH,
9
+ CATEGORY_META,
10
+ CX,
11
+ CY,
12
+ CONCOURSE_RINGS,
13
+ FACILITY_FEE,
14
+ GATE_POSITIONS,
15
+ PITCH_RX,
16
+ PITCH_RY,
17
+ SEAT_SIZE,
18
+ SECTION_LABELS,
19
+ SERVICE_FEE,
20
+ isOccupied,
21
+ type StadiumSeat,
22
+ } from "./stadium-data";
23
+
24
+ const font =
25
+ 'ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif';
26
+
27
+ type Api = {
28
+ zoomToElement: (target: string | HTMLElement, scale?: number) => void;
29
+ resetTransform: () => void;
30
+ zoomIn: () => void;
31
+ zoomOut: () => void;
32
+ };
33
+
34
+ function hashStub(i: number, id: string): number {
35
+ return (i * 17 + id.length * 31) % 100;
36
+ }
37
+
38
+ function EventHeader() {
39
+ return (
40
+ <header
41
+ style={{
42
+ marginBottom: 22,
43
+ display: "flex",
44
+ flexWrap: "wrap",
45
+ alignItems: "flex-end",
46
+ justifyContent: "space-between",
47
+ gap: 16,
48
+ }}
49
+ >
50
+ <div>
51
+ <div
52
+ style={{
53
+ fontSize: 11,
54
+ fontWeight: 700,
55
+ letterSpacing: "0.14em",
56
+ textTransform: "uppercase",
57
+ color: "rgba(56, 189, 248, 0.9)",
58
+ marginBottom: 6,
59
+ }}
60
+ >
61
+ Lumen Arena · Official map
62
+ </div>
63
+ <h1
64
+ style={{
65
+ margin: 0,
66
+ fontSize: "clamp(1.35rem, 2.5vw, 1.85rem)",
67
+ fontWeight: 800,
68
+ letterSpacing: "-0.03em",
69
+ color: "#f8fafc",
70
+ lineHeight: 1.15,
71
+ }}
72
+ >
73
+ Aurora North Tour
74
+ </h1>
75
+ <p
76
+ style={{
77
+ margin: "8px 0 0",
78
+ fontSize: 14,
79
+ color: "rgba(203, 213, 225, 0.92)",
80
+ }}
81
+ >
82
+ Saturday, June 14 · Doors 7:00 PM · Show 8:30 PM
83
+ </p>
84
+ </div>
85
+ <div
86
+ style={{
87
+ display: "flex",
88
+ alignItems: "center",
89
+ gap: 10,
90
+ padding: "10px 16px",
91
+ borderRadius: 12,
92
+ background: "rgba(15, 23, 42, 0.65)",
93
+ border: "1px solid rgba(148, 163, 184, 0.15)",
94
+ backdropFilter: "blur(12px)",
95
+ }}
96
+ >
97
+ <span
98
+ style={{
99
+ width: 8,
100
+ height: 8,
101
+ borderRadius: "50%",
102
+ background: "#22c55e",
103
+ boxShadow: "0 0 12px rgba(34, 197, 94, 0.7)",
104
+ }}
105
+ />
106
+ <span style={{ fontSize: 13, fontWeight: 600, color: "#e2e8f0" }}>
107
+ Live inventory
108
+ </span>
109
+ </div>
110
+ </header>
111
+ );
112
+ }
113
+
114
+ function LegendChip() {
115
+ return (
116
+ <div
117
+ style={{
118
+ position: "absolute",
119
+ top: 18,
120
+ left: "50%",
121
+ transform: "translateX(-50%)",
122
+ zIndex: 6,
123
+ display: "flex",
124
+ flexWrap: "wrap",
125
+ gap: 12,
126
+ justifyContent: "center",
127
+ padding: "8px 16px",
128
+ borderRadius: 999,
129
+ background: "rgba(2, 6, 23, 0.75)",
130
+ border: "1px solid rgba(148, 163, 184, 0.12)",
131
+ backdropFilter: "blur(10px)",
132
+ pointerEvents: "none",
133
+ }}
134
+ >
135
+ {(Object.keys(CATEGORY_META) as (keyof typeof CATEGORY_META)[]).map(
136
+ (k) => (
137
+ <span
138
+ key={k}
139
+ style={{
140
+ display: "inline-flex",
141
+ alignItems: "center",
142
+ gap: 6,
143
+ fontSize: 11,
144
+ fontWeight: 600,
145
+ color: "rgba(226, 232, 240, 0.85)",
146
+ }}
147
+ >
148
+ <span
149
+ style={{
150
+ width: 10,
151
+ height: 10,
152
+ borderRadius: 3,
153
+ background: CATEGORY_META[k].accent,
154
+ boxShadow: `0 0 10px ${CATEGORY_META[k].glow}`,
155
+ }}
156
+ />
157
+ {CATEGORY_META[k].label}
158
+ </span>
159
+ ),
160
+ )}
161
+ <span
162
+ style={{
163
+ display: "inline-flex",
164
+ alignItems: "center",
165
+ gap: 6,
166
+ fontSize: 11,
167
+ fontWeight: 600,
168
+ color: "rgba(148, 163, 184, 0.7)",
169
+ }}
170
+ >
171
+ <span
172
+ style={{
173
+ width: 10,
174
+ height: 10,
175
+ borderRadius: 3,
176
+ background: "rgba(51, 65, 85, 0.9)",
177
+ }}
178
+ />
179
+ Unavailable
180
+ </span>
181
+ </div>
182
+ );
183
+ }
184
+
185
+ const SEAT_HOVER_CSS = `
186
+ .stadium-seat-svg:not(.stadium-seat-taken) {
187
+ cursor: pointer;
188
+ }
189
+ .stadium-seat-svg:not(.stadium-seat-taken):hover {
190
+ filter: brightness(1.35);
191
+ stroke-width: 2.5;
192
+ }
193
+ `;
194
+
195
+ const seatLookup = new Map<string, StadiumSeat>();
196
+ ALL_SEATS.forEach((s) => seatLookup.set(s.domId, s));
197
+
198
+ const SeatSvg = React.memo(function SeatSvg(props: {
199
+ selectedId: string | null;
200
+ purchased: boolean;
201
+ onSeatClick: (s: StadiumSeat) => void;
202
+ }) {
203
+ const { selectedId, purchased, onSeatClick } = props;
204
+
205
+ const handleClick = useCallback(
206
+ (e: React.MouseEvent<SVGSVGElement>) => {
207
+ const el = (e.target as SVGElement).closest("[data-seat]");
208
+ if (!el) return;
209
+ const domId = el.getAttribute("data-seat");
210
+ if (!domId) return;
211
+ const seat = seatLookup.get(domId);
212
+ if (seat) onSeatClick(seat);
213
+ },
214
+ [onSeatClick],
215
+ );
216
+
217
+ return (
218
+ <svg
219
+ width={CANVAS_WIDTH}
220
+ height={CANVAS_HEIGHT}
221
+ style={{ position: "absolute", inset: 0 }}
222
+ onClick={purchased ? undefined : handleClick}
223
+ >
224
+ {ALL_SEATS.map((seat) => {
225
+ const taken = isOccupied(seat.id);
226
+ const sel = selectedId === seat.id;
227
+ const meta = CATEGORY_META[seat.category];
228
+
229
+ let fill = meta.border;
230
+ if (taken) fill = "#1f2937";
231
+ else if (sel) fill = "#059669";
232
+
233
+ let stroke = meta.border;
234
+ if (taken) stroke = "#374151";
235
+ else if (sel) stroke = "#34d399";
236
+
237
+ const cx = seat.x + SEAT_SIZE / 2;
238
+ const cy = seat.y + SEAT_SIZE / 2;
239
+
240
+ return (
241
+ <rect
242
+ key={seat.id}
243
+ id={seat.domId}
244
+ data-seat={seat.domId}
245
+ className={`stadium-seat-svg${taken ? " stadium-seat-taken" : ""}`}
246
+ x={seat.x}
247
+ y={seat.y}
248
+ width={SEAT_SIZE}
249
+ height={SEAT_SIZE}
250
+ rx={4}
251
+ ry={4}
252
+ fill={fill}
253
+ stroke={stroke}
254
+ strokeWidth={sel ? 2.5 : 1.2}
255
+ opacity={taken ? 0.3 : 1}
256
+ transform={`rotate(${seat.rotation} ${cx} ${cy})`}
257
+ />
258
+ );
259
+ })}
260
+ </svg>
261
+ );
262
+ });
263
+
264
+ function PitchSvg() {
265
+ return (
266
+ <svg
267
+ width={CANVAS_WIDTH}
268
+ height={CANVAS_HEIGHT}
269
+ style={{ position: "absolute", inset: 0, pointerEvents: "none" }}
270
+ aria-hidden
271
+ >
272
+ <defs>
273
+ <linearGradient id="grass" x1="0%" y1="0%" x2="100%" y2="100%">
274
+ <stop offset="0%" stopColor="#15803d" />
275
+ <stop offset="45%" stopColor="#166534" />
276
+ <stop offset="100%" stopColor="#14532d" />
277
+ </linearGradient>
278
+ <pattern
279
+ id="stripes"
280
+ patternUnits="userSpaceOnUse"
281
+ width={56}
282
+ height={CANVAS_HEIGHT}
283
+ >
284
+ <rect width={28} height="100%" fill="rgba(255,255,255,0.03)" />
285
+ <rect x={28} width={28} height="100%" fill="rgba(0,0,0,0.04)" />
286
+ </pattern>
287
+ <radialGradient id="bowl-glow" cx="50%" cy="50%">
288
+ <stop offset="0%" stopColor="rgba(15, 23, 42, 0.25)" />
289
+ <stop offset="100%" stopColor="transparent" />
290
+ </radialGradient>
291
+ </defs>
292
+
293
+ {/* Subtle glow behind bowl */}
294
+ <ellipse
295
+ cx={CX}
296
+ cy={CY}
297
+ rx={PITCH_RX + 500}
298
+ ry={PITCH_RY + 400}
299
+ fill="url(#bowl-glow)"
300
+ />
301
+
302
+ {/* Pitch */}
303
+ <ellipse cx={CX} cy={CY} rx={PITCH_RX} ry={PITCH_RY} fill="url(#grass)" />
304
+ <ellipse
305
+ cx={CX}
306
+ cy={CY}
307
+ rx={PITCH_RX}
308
+ ry={PITCH_RY}
309
+ fill="url(#stripes)"
310
+ />
311
+ <ellipse
312
+ cx={CX}
313
+ cy={CY}
314
+ rx={PITCH_RX}
315
+ ry={PITCH_RY}
316
+ fill="none"
317
+ stroke="rgba(255,255,255,0.25)"
318
+ strokeWidth={3}
319
+ />
320
+
321
+ {/* Center circle */}
322
+ <ellipse
323
+ cx={CX}
324
+ cy={CY}
325
+ rx={80}
326
+ ry={55}
327
+ fill="none"
328
+ stroke="rgba(255,255,255,0.18)"
329
+ strokeWidth={2}
330
+ />
331
+ <circle cx={CX} cy={CY} r={4} fill="rgba(255,255,255,0.2)" />
332
+
333
+ {/* Halfway line */}
334
+ <line
335
+ x1={CX}
336
+ y1={CY - PITCH_RY}
337
+ x2={CX}
338
+ y2={CY + PITCH_RY}
339
+ stroke="rgba(255,255,255,0.15)"
340
+ strokeWidth={2}
341
+ />
342
+
343
+ {/* PITCH label */}
344
+ <text
345
+ x={CX}
346
+ y={CY - 10}
347
+ textAnchor="middle"
348
+ fill="rgba(255,255,255,0.1)"
349
+ style={{
350
+ fontSize: 32,
351
+ fontWeight: 800,
352
+ fontFamily: font,
353
+ letterSpacing: "0.3em",
354
+ }}
355
+ >
356
+ LUMEN ARENA
357
+ </text>
358
+
359
+ {/* Concourse rings (walkways between tiers) */}
360
+ {CONCOURSE_RINGS.map((offset) => (
361
+ <ellipse
362
+ key={offset}
363
+ cx={CX}
364
+ cy={CY}
365
+ rx={PITCH_RX + offset}
366
+ ry={PITCH_RY + offset}
367
+ fill="none"
368
+ stroke="rgba(100, 116, 139, 0.12)"
369
+ strokeWidth={1.5}
370
+ strokeDasharray="8 6"
371
+ />
372
+ ))}
373
+
374
+ {/* Section labels */}
375
+ {SECTION_LABELS.map((s) => (
376
+ <text
377
+ key={s.section}
378
+ x={s.x}
379
+ y={s.y}
380
+ textAnchor="middle"
381
+ dominantBaseline="central"
382
+ fill="rgba(255,255,255,0.08)"
383
+ style={{
384
+ fontSize: 22,
385
+ fontWeight: 800,
386
+ fontFamily: font,
387
+ letterSpacing: "0.2em",
388
+ }}
389
+ >
390
+ {s.section.toUpperCase()}
391
+ </text>
392
+ ))}
393
+
394
+ {/* Gate markers */}
395
+ {GATE_POSITIONS.map((g) => (
396
+ <g key={g.label}>
397
+ <rect
398
+ x={g.x - 20}
399
+ y={g.y - 12}
400
+ width={40}
401
+ height={24}
402
+ rx={6}
403
+ fill="rgba(16, 185, 129, 0.12)"
404
+ stroke="rgba(16, 185, 129, 0.25)"
405
+ strokeWidth={1}
406
+ />
407
+ <text
408
+ x={g.x}
409
+ y={g.y + 1}
410
+ textAnchor="middle"
411
+ dominantBaseline="central"
412
+ fill="rgba(16, 185, 129, 0.5)"
413
+ style={{
414
+ fontSize: 10,
415
+ fontWeight: 800,
416
+ fontFamily: font,
417
+ letterSpacing: "1px",
418
+ }}
419
+ >
420
+ GATE
421
+ </text>
422
+ </g>
423
+ ))}
424
+ </svg>
425
+ );
426
+ }
427
+
428
+ function StadiumCanvas({
429
+ selectedId,
430
+ purchased,
431
+ onSeatClick,
432
+ }: {
433
+ selectedId: string | null;
434
+ purchased: boolean;
435
+ onSeatClick: (s: StadiumSeat) => void;
436
+ }) {
437
+ return (
438
+ <div
439
+ style={{
440
+ position: "relative",
441
+ width: CANVAS_WIDTH,
442
+ height: CANVAS_HEIGHT,
443
+ background:
444
+ "radial-gradient(ellipse 55% 48% at 50% 50%, rgba(15, 23, 42, 0.35) 0%, #020617 72%)",
445
+ fontFamily: font,
446
+ }}
447
+ >
448
+ <style>{SEAT_HOVER_CSS}</style>
449
+ <PitchSvg />
450
+ <SeatSvg
451
+ selectedId={selectedId}
452
+ purchased={purchased}
453
+ onSeatClick={onSeatClick}
454
+ />
455
+ </div>
456
+ );
457
+ }
458
+
459
+ function EmptyPanel() {
460
+ return (
461
+ <div
462
+ style={{
463
+ flex: 1,
464
+ display: "flex",
465
+ flexDirection: "column",
466
+ alignItems: "center",
467
+ justifyContent: "center",
468
+ textAlign: "center",
469
+ padding: "20px 8px",
470
+ }}
471
+ >
472
+ <div
473
+ style={{
474
+ width: 72,
475
+ height: 72,
476
+ borderRadius: "50%",
477
+ background:
478
+ "linear-gradient(145deg, rgba(56, 189, 248, 0.15), rgba(167, 139, 250, 0.12))",
479
+ border: "1px solid rgba(148, 163, 184, 0.2)",
480
+ display: "flex",
481
+ alignItems: "center",
482
+ justifyContent: "center",
483
+ marginBottom: 18,
484
+ }}
485
+ >
486
+ <svg width="32" height="32" viewBox="0 0 24 24" fill="none">
487
+ <path
488
+ d="M12 3L4 9v12h16V9l-8-6z"
489
+ stroke="rgba(148, 163, 184, 0.7)"
490
+ strokeWidth="1.5"
491
+ strokeLinejoin="round"
492
+ />
493
+ <path
494
+ d="M9 14h6M9 18h4"
495
+ stroke="rgba(148, 163, 184, 0.5)"
496
+ strokeWidth="1.5"
497
+ strokeLinecap="round"
498
+ />
499
+ </svg>
500
+ </div>
501
+ <div
502
+ style={{
503
+ fontSize: 17,
504
+ fontWeight: 700,
505
+ color: "#e2e8f0",
506
+ marginBottom: 8,
507
+ }}
508
+ >
509
+ Pick your view
510
+ </div>
511
+ <p
512
+ style={{
513
+ margin: 0,
514
+ fontSize: 13,
515
+ lineHeight: 1.55,
516
+ color: "rgba(148, 163, 184, 0.9)",
517
+ maxWidth: 280,
518
+ }}
519
+ >
520
+ Zoom into the bowl and tap any glowing seat. We&apos;ll frame your spot
521
+ and break down fees like a real checkout.
522
+ </p>
523
+ </div>
524
+ );
525
+ }
526
+
527
+ function PriceBreakdown({ seat }: { seat: StadiumSeat }) {
528
+ const sub = seat.price;
529
+ const total = sub + SERVICE_FEE + FACILITY_FEE;
530
+ return (
531
+ <div style={{ marginBottom: 20 }}>
532
+ {(
533
+ [
534
+ ["Ticket", sub],
535
+ ["Service fee", SERVICE_FEE],
536
+ ["Facility charge", FACILITY_FEE],
537
+ ] as const
538
+ ).map(([label, amt]) => (
539
+ <div
540
+ key={label}
541
+ style={{
542
+ display: "flex",
543
+ justifyContent: "space-between",
544
+ fontSize: 13,
545
+ color: "#94a3b8",
546
+ marginBottom: 8,
547
+ }}
548
+ >
549
+ <span>{label}</span>
550
+ <span style={{ color: "#e2e8f0", fontWeight: 600 }}>${amt}</span>
551
+ </div>
552
+ ))}
553
+ <div
554
+ style={{
555
+ height: 1,
556
+ background: "rgba(71, 85, 105, 0.5)",
557
+ margin: "12px 0",
558
+ }}
559
+ />
560
+ <div
561
+ style={{
562
+ display: "flex",
563
+ justifyContent: "space-between",
564
+ alignItems: "center",
565
+ }}
566
+ >
567
+ <span
568
+ style={{
569
+ fontSize: 14,
570
+ fontWeight: 700,
571
+ color: "#f1f5f9",
572
+ }}
573
+ >
574
+ Total
575
+ </span>
576
+ <span
577
+ style={{
578
+ fontSize: 22,
579
+ fontWeight: 900,
580
+ letterSpacing: "-0.03em",
581
+ color: "#fbbf24",
582
+ }}
583
+ >
584
+ ${total}
585
+ </span>
586
+ </div>
587
+ </div>
588
+ );
589
+ }
590
+
591
+ function SuccessView({ seat }: { seat: StadiumSeat }) {
592
+ return (
593
+ <div style={{ textAlign: "center", padding: "12px 4px 8px" }}>
594
+ <div
595
+ style={{
596
+ width: 64,
597
+ height: 64,
598
+ margin: "0 auto 16px",
599
+ borderRadius: "50%",
600
+ background:
601
+ "linear-gradient(145deg, rgba(34, 197, 94, 0.25), rgba(16, 185, 129, 0.15))",
602
+ border: "1px solid rgba(34, 197, 94, 0.35)",
603
+ display: "flex",
604
+ alignItems: "center",
605
+ justifyContent: "center",
606
+ fontSize: 28,
607
+ }}
608
+ >
609
+ ✓
610
+ </div>
611
+ <h2
612
+ style={{
613
+ margin: "0 0 8px",
614
+ fontSize: 22,
615
+ fontWeight: 800,
616
+ color: "#f8fafc",
617
+ letterSpacing: "-0.02em",
618
+ }}
619
+ >
620
+ You&apos;re in!
621
+ </h2>
622
+ <p
623
+ style={{
624
+ margin: "0 0 20px",
625
+ fontSize: 14,
626
+ lineHeight: 1.5,
627
+ color: "#94a3b8",
628
+ }}
629
+ >
630
+ {seat.section} stand · Row {seat.row} · Seat {seat.number}
631
+ <br />
632
+ <span style={{ color: "#cbd5e1" }}>
633
+ {CATEGORY_META[seat.category].label}
634
+ </span>
635
+ </p>
636
+ <p
637
+ style={{
638
+ margin: 0,
639
+ fontSize: 12,
640
+ color: "rgba(148, 163, 184, 0.75)",
641
+ }}
642
+ >
643
+ Confirmation sent · Add to Apple Wallet (demo)
644
+ </p>
645
+ </div>
646
+ );
647
+ }
648
+
649
+ function TicketStubPreview({ seat }: { seat: StadiumSeat }) {
650
+ return (
651
+ <div
652
+ style={{
653
+ borderRadius: 14,
654
+ padding: "16px 18px",
655
+ background:
656
+ "repeating-linear-gradient(90deg, transparent, transparent 6px, rgba(148,163,184,0.06) 6px, rgba(148,163,184,0.06) 7px), rgba(15, 23, 42, 0.6)",
657
+ border: "1px dashed rgba(148, 163, 184, 0.25)",
658
+ }}
659
+ >
660
+ <div
661
+ style={{
662
+ fontSize: 10,
663
+ fontWeight: 700,
664
+ letterSpacing: "0.15em",
665
+ color: "rgba(148, 163, 184, 0.6)",
666
+ marginBottom: 10,
667
+ }}
668
+ >
669
+ MOBILE ENTRY PREVIEW
670
+ </div>
671
+ <div
672
+ style={{
673
+ display: "grid",
674
+ gridTemplateColumns: "repeat(8, 1fr)",
675
+ gap: 3,
676
+ maxWidth: 120,
677
+ opacity: 0.85,
678
+ }}
679
+ >
680
+ {Array.from({ length: 40 }, (_, i) => {
681
+ const stubHash = hashStub(i, seat.id);
682
+ return (
683
+ <div
684
+ key={stubHash}
685
+ style={{
686
+ aspectRatio: "1",
687
+ borderRadius: 2,
688
+ background: stubHash % 3 === 0 ? "#0f172a" : "#1e293b",
689
+ }}
690
+ />
691
+ );
692
+ })}
693
+ </div>
694
+ <div
695
+ style={{
696
+ marginTop: 12,
697
+ fontSize: 11,
698
+ fontFamily: "ui-monospace, monospace",
699
+ color: "rgba(148, 163, 184, 0.75)",
700
+ letterSpacing: "0.08em",
701
+ }}
702
+ >
703
+ {seat.domId.toUpperCase().replace(/-/g, " · ")}
704
+ </div>
705
+ </div>
706
+ );
707
+ }
708
+
709
+ function TicketPanel({
710
+ seat,
711
+ purchased,
712
+ onPurchase,
713
+ onClear,
714
+ }: {
715
+ seat: StadiumSeat | null;
716
+ purchased: boolean;
717
+ onPurchase: () => void;
718
+ onClear: () => void;
719
+ }) {
720
+ return (
721
+ <aside
722
+ style={{
723
+ flex: "0 1 380px",
724
+ minWidth: 300,
725
+ maxWidth: 420,
726
+ display: "flex",
727
+ flexDirection: "column",
728
+ gap: 16,
729
+ }}
730
+ >
731
+ <div
732
+ style={{
733
+ borderRadius: 20,
734
+ padding: 2,
735
+ background:
736
+ "linear-gradient(135deg, rgba(56, 189, 248, 0.35), rgba(167, 139, 250, 0.25), rgba(251, 191, 36, 0.2))",
737
+ }}
738
+ >
739
+ <div
740
+ style={{
741
+ borderRadius: 18,
742
+ background: "rgba(15, 23, 42, 0.92)",
743
+ backdropFilter: "blur(20px)",
744
+ border: "1px solid rgba(148, 163, 184, 0.1)",
745
+ padding: "22px 22px 20px",
746
+ minHeight: 440,
747
+ display: "flex",
748
+ flexDirection: "column",
749
+ }}
750
+ >
751
+ {!seat && !purchased && <EmptyPanel />}
752
+
753
+ {seat && !purchased && (
754
+ <>
755
+ <div
756
+ style={{
757
+ fontSize: 11,
758
+ fontWeight: 700,
759
+ letterSpacing: "0.12em",
760
+ textTransform: "uppercase",
761
+ color: "rgba(148, 163, 184, 0.85)",
762
+ marginBottom: 14,
763
+ }}
764
+ >
765
+ Your selection
766
+ </div>
767
+ <div
768
+ style={{
769
+ display: "flex",
770
+ alignItems: "flex-start",
771
+ justifyContent: "space-between",
772
+ gap: 12,
773
+ marginBottom: 20,
774
+ }}
775
+ >
776
+ <div>
777
+ <div
778
+ style={{
779
+ fontSize: 42,
780
+ fontWeight: 900,
781
+ letterSpacing: "-0.04em",
782
+ color: "#f8fafc",
783
+ lineHeight: 1,
784
+ }}
785
+ >
786
+ {seat.number}
787
+ </div>
788
+ <div
789
+ style={{
790
+ fontSize: 13,
791
+ color: "rgba(148, 163, 184, 0.95)",
792
+ marginTop: 6,
793
+ }}
794
+ >
795
+ Seat number
796
+ </div>
797
+ </div>
798
+ <div
799
+ style={{
800
+ textAlign: "right",
801
+ paddingTop: 4,
802
+ }}
803
+ >
804
+ <div
805
+ style={{
806
+ fontSize: 15,
807
+ fontWeight: 700,
808
+ color: "#e2e8f0",
809
+ }}
810
+ >
811
+ {seat.section} stand
812
+ </div>
813
+ <div
814
+ style={{
815
+ fontSize: 13,
816
+ color: "#94a3b8",
817
+ marginTop: 4,
818
+ }}
819
+ >
820
+ Row {seat.row}
821
+ </div>
822
+ </div>
823
+ </div>
824
+
825
+ <div
826
+ style={{
827
+ padding: "12px 14px",
828
+ borderRadius: 12,
829
+ background: "rgba(30, 41, 59, 0.65)",
830
+ border: "1px solid rgba(71, 85, 105, 0.35)",
831
+ marginBottom: 18,
832
+ }}
833
+ >
834
+ <div
835
+ style={{
836
+ fontSize: 12,
837
+ fontWeight: 600,
838
+ color: "#cbd5e1",
839
+ marginBottom: 8,
840
+ }}
841
+ >
842
+ {CATEGORY_META[seat.category].label}
843
+ </div>
844
+ <div
845
+ style={{
846
+ fontSize: 12,
847
+ color: "#64748b",
848
+ lineHeight: 1.5,
849
+ }}
850
+ >
851
+ Covered sightline · In-seat service on club rows · Mobile
852
+ entry
853
+ </div>
854
+ </div>
855
+
856
+ <PriceBreakdown seat={seat} />
857
+
858
+ <button
859
+ type="button"
860
+ onClick={onPurchase}
861
+ style={{
862
+ marginTop: "auto",
863
+ padding: "16px 20px",
864
+ borderRadius: 14,
865
+ border: "none",
866
+ fontSize: 15,
867
+ fontWeight: 800,
868
+ fontFamily: "inherit",
869
+ letterSpacing: "-0.01em",
870
+ cursor: "pointer",
871
+ color: "#0f172a",
872
+ background:
873
+ "linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #ea580c 100%)",
874
+ boxShadow:
875
+ "0 4px 24px rgba(245, 158, 11, 0.35), 0 0 0 1px rgba(255,255,255,0.15) inset",
876
+ }}
877
+ >
878
+ Lock this seat · ${seat.price + SERVICE_FEE + FACILITY_FEE}{" "}
879
+ total
880
+ </button>
881
+
882
+ <button
883
+ type="button"
884
+ onClick={onClear}
885
+ style={{
886
+ marginTop: 10,
887
+ padding: "10px",
888
+ borderRadius: 10,
889
+ border: "1px solid rgba(148, 163, 184, 0.2)",
890
+ background: "transparent",
891
+ color: "#94a3b8",
892
+ fontSize: 13,
893
+ fontWeight: 600,
894
+ fontFamily: "inherit",
895
+ cursor: "pointer",
896
+ }}
897
+ >
898
+ Choose a different seat
899
+ </button>
900
+ </>
901
+ )}
902
+
903
+ {purchased && seat && <SuccessView seat={seat} />}
904
+ </div>
905
+ </div>
906
+
907
+ {seat && !purchased && <TicketStubPreview seat={seat} />}
908
+ </aside>
909
+ );
910
+ }
911
+
912
+ export const Example: React.FC<Record<string, unknown>> = (args) => {
913
+ const [selected, setSelected] = useState<StadiumSeat | null>(null);
914
+ const [purchased, setPurchased] = useState(false);
915
+ const apiRef = useRef<Api | null>(null);
916
+
917
+ const onSeatClick = useCallback(
918
+ (seat: StadiumSeat) => {
919
+ if (purchased || isOccupied(seat.id)) return;
920
+ setSelected(seat);
921
+ requestAnimationFrame(() => {
922
+ apiRef.current?.zoomToElement(seat.domId, 3.2);
923
+ });
924
+ },
925
+ [purchased],
926
+ );
927
+
928
+ const clearSelection = useCallback(() => {
929
+ setSelected(null);
930
+ apiRef.current?.resetTransform();
931
+ }, []);
932
+
933
+ const handlePurchase = useCallback(() => {
934
+ if (!selected) return;
935
+ setPurchased(true);
936
+ }, [selected]);
937
+
938
+ return (
939
+ <div
940
+ style={{
941
+ fontFamily: font,
942
+ background:
943
+ "radial-gradient(1200px 600px at 50% -10%, rgba(56, 189, 248, 0.08), transparent), linear-gradient(180deg, #030712 0%, #0f172a 45%, #020617 100%)",
944
+ minHeight: 720,
945
+ padding: "20px 24px 32px",
946
+ borderRadius: 16,
947
+ boxSizing: "border-box",
948
+ }}
949
+ >
950
+ <EventHeader />
951
+
952
+ <div
953
+ style={{
954
+ display: "flex",
955
+ flexWrap: "wrap",
956
+ gap: 20,
957
+ alignItems: "stretch",
958
+ justifyContent: "center",
959
+ }}
960
+ >
961
+ <div style={{ flex: "1 1 640px", minWidth: 320, maxWidth: 980 }}>
962
+ <TransformWrapper
963
+ {...normalizeArgs(args)}
964
+ initialScale={0.42}
965
+ minScale={0.22}
966
+ maxScale={6}
967
+ limitToBounds
968
+ centerZoomedOut
969
+ centerOnInit
970
+ doubleClick={{ disabled: true }}
971
+ >
972
+ {(api) => {
973
+ apiRef.current = api;
974
+ return (
975
+ <div style={{ position: "relative" }}>
976
+ <Controls
977
+ {...api}
978
+ position="top-left"
979
+ extraButtons={[
980
+ ...(selected && !purchased
981
+ ? [
982
+ {
983
+ label: "Clear seat",
984
+ icon: <CloseIcon />,
985
+ onClick: clearSelection,
986
+ },
987
+ ]
988
+ : []),
989
+ ]}
990
+ />
991
+ <LegendChip />
992
+
993
+ <TransformComponent
994
+ wrapperStyle={{
995
+ width: "100%",
996
+ height: "min(62vh, 640px)",
997
+ minHeight: 420,
998
+ ...viewerChrome,
999
+ overflow: "hidden",
1000
+ }}
1001
+ contentStyle={{
1002
+ width: CANVAS_WIDTH,
1003
+ height: CANVAS_HEIGHT,
1004
+ }}
1005
+ >
1006
+ <StadiumCanvas
1007
+ selectedId={selected?.id ?? null}
1008
+ purchased={purchased}
1009
+ onSeatClick={onSeatClick}
1010
+ />
1011
+ </TransformComponent>
1012
+ </div>
1013
+ );
1014
+ }}
1015
+ </TransformWrapper>
1016
+
1017
+ <p
1018
+ style={{
1019
+ margin: "14px 0 0",
1020
+ fontSize: 12,
1021
+ color: "rgba(148, 163, 184, 0.85)",
1022
+ lineHeight: 1.5,
1023
+ }}
1024
+ >
1025
+ Pinch or scroll to zoom. Drag to pan. Tap an available seat to focus
1026
+ it and open your ticket summary — club rows ring the pitch; upper
1027
+ tier is the outer ring.
1028
+ </p>
1029
+ </div>
1030
+
1031
+ <TicketPanel
1032
+ seat={selected}
1033
+ purchased={purchased}
1034
+ onPurchase={handlePurchase}
1035
+ onClear={clearSelection}
1036
+ />
1037
+ </div>
1038
+ </div>
1039
+ );
1040
+ };