@zonetrix/viewer 1.1.0 → 2.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.
package/README.md CHANGED
@@ -14,8 +14,10 @@ Lightweight React component for rendering interactive seat maps in your booking
14
14
  - 🌐 **Flexible Config Loading** - Load from JSON files or API endpoints
15
15
  - 🔍 **Mouse Wheel Zoom** - Smooth zoom with configurable limits
16
16
  - 🎨 **Customizable Colors** - Override default colors to match your brand
17
+ - 🏢 **Multi-floor Support** - Filter and display seats by floor
18
+ - 👁️ **Hidden Seats** - Automatically filters out hidden seats
17
19
  - 📱 **Responsive** - Works seamlessly across all screen sizes
18
- - ⚡ **Lightweight** - Minimal dependencies (~95KB gzipped)
20
+ - ⚡ **Lightweight** - Minimal dependencies
19
21
  - 🔒 **Type-safe** - Full TypeScript support
20
22
 
21
23
  ## Installation
@@ -31,7 +33,30 @@ pnpm add @zonetrix/viewer
31
33
  ### Peer Dependencies
32
34
 
33
35
  ```bash
34
- npm install react react-dom
36
+ npm install react react-dom konva react-konva
37
+ ```
38
+
39
+ ## Exports
40
+
41
+ ```typescript
42
+ // Main component
43
+ import { SeatMapViewer } from '@zonetrix/viewer';
44
+ import type { SeatMapViewerProps } from '@zonetrix/viewer';
45
+
46
+ // Types
47
+ import type {
48
+ SeatState,
49
+ SeatShape,
50
+ SeatData,
51
+ SeatMapConfig,
52
+ ColorSettings
53
+ } from '@zonetrix/viewer';
54
+
55
+ // Hooks
56
+ import { useConfigFetcher } from '@zonetrix/viewer';
57
+
58
+ // Constants
59
+ import { DEFAULT_COLORS } from '@zonetrix/viewer';
35
60
  ```
36
61
 
37
62
  ## Quick Start
@@ -40,6 +65,7 @@ npm install react react-dom
40
65
 
41
66
  ```tsx
42
67
  import { SeatMapViewer } from '@zonetrix/viewer';
68
+ import type { SeatData, SeatMapConfig } from '@zonetrix/viewer';
43
69
  import venueConfig from './venue-config.json';
44
70
 
45
71
  function BookingApp() {
@@ -77,14 +103,19 @@ function BookingApp() {
77
103
  |------|------|----------|-------------|
78
104
  | `config` | `SeatMapConfig` | No* | Seat map configuration object |
79
105
  | `configUrl` | `string` | No* | URL to fetch configuration from |
106
+ | `floorId` | `string` | No | Filter seats/stages by floor ID |
107
+ | `onFloorChange` | `(floorId: string) => void` | No | Callback when floor changes |
80
108
  | `reservedSeats` | `string[]` | No | Array of seat IDs/numbers to mark as reserved |
81
109
  | `unavailableSeats` | `string[]` | No | Array of seat IDs/numbers to mark as unavailable |
82
110
  | `onSeatSelect` | `(seat: SeatData) => void` | No | Callback when a seat is selected |
83
111
  | `onSeatDeselect` | `(seat: SeatData) => void` | No | Callback when a seat is deselected |
84
112
  | `onSelectionChange` | `(seats: SeatData[]) => void` | No | Callback when selection changes |
85
113
  | `colorOverrides` | `Partial<ColorSettings>` | No | Custom colors for seat states |
114
+ | `showTooltip` | `boolean` | No | Show tooltips on hover (default: true) |
86
115
  | `zoomEnabled` | `boolean` | No | Enable/disable mouse wheel zoom (default: true) |
87
- | `showSelectedCount` | `boolean` | No | Show selected seats counter (default: true) |
116
+ | `className` | `string` | No | Custom CSS class for the container |
117
+ | `onConfigLoad` | `(config: SeatMapConfig) => void` | No | Callback when config is loaded |
118
+ | `onError` | `(error: Error) => void` | No | Callback when an error occurs |
88
119
 
89
120
  *Note: Either `config` or `configUrl` must be provided.
90
121
 
@@ -226,6 +257,68 @@ function MobileOptimized() {
226
257
  }
227
258
  ```
228
259
 
260
+ ### 6. Multi-floor Venue
261
+
262
+ ```tsx
263
+ import { useState } from 'react';
264
+ import { SeatMapViewer } from '@zonetrix/viewer';
265
+
266
+ function MultiFloorVenue() {
267
+ const [currentFloor, setCurrentFloor] = useState('floor_1');
268
+
269
+ return (
270
+ <div>
271
+ {/* Floor selector */}
272
+ <div className="floor-tabs">
273
+ {venueConfig.floors?.map((floor) => (
274
+ <button
275
+ key={floor.id}
276
+ onClick={() => setCurrentFloor(floor.id)}
277
+ className={currentFloor === floor.id ? 'active' : ''}
278
+ >
279
+ {floor.name}
280
+ </button>
281
+ ))}
282
+ </div>
283
+
284
+ <SeatMapViewer
285
+ config={venueConfig}
286
+ floorId={currentFloor}
287
+ onFloorChange={setCurrentFloor}
288
+ onSeatSelect={(seat) => handleSelection(seat)}
289
+ />
290
+ </div>
291
+ );
292
+ }
293
+ ```
294
+
295
+ ### 7. Error Handling
296
+
297
+ ```tsx
298
+ import { SeatMapViewer } from '@zonetrix/viewer';
299
+
300
+ function RobustViewer() {
301
+ const handleConfigLoad = (config) => {
302
+ console.log('Config loaded:', config.metadata.name);
303
+ console.log('Total seats:', config.seats.length);
304
+ };
305
+
306
+ const handleError = (error) => {
307
+ console.error('Failed to load seat map:', error.message);
308
+ // Show error notification to user
309
+ };
310
+
311
+ return (
312
+ <SeatMapViewer
313
+ configUrl="https://api.example.com/venues/123/config"
314
+ onConfigLoad={handleConfigLoad}
315
+ onError={handleError}
316
+ onSeatSelect={(seat) => console.log('Selected:', seat)}
317
+ />
318
+ );
319
+ }
320
+ ```
321
+
229
322
  ## Configuration Format
230
323
 
231
324
  The viewer accepts a `SeatMapConfig` object. You can create these configurations using our creator studio or build them programmatically.
@@ -289,15 +382,18 @@ interface SeatData {
289
382
  columnLabel?: string;
290
383
  price?: number;
291
384
  seatNumber?: string;
385
+ floorId?: string;
292
386
  }
293
387
  ```
294
388
 
295
389
  ### SeatState
296
390
 
297
391
  ```typescript
298
- type SeatState = 'available' | 'reserved' | 'selected' | 'unavailable';
392
+ type SeatState = 'available' | 'reserved' | 'selected' | 'unavailable' | 'hidden';
299
393
  ```
300
394
 
395
+ Note: Hidden seats are automatically filtered out from the viewer.
396
+
301
397
  ### SeatShape
302
398
 
303
399
  ```typescript
@@ -314,6 +410,7 @@ interface ColorSettings {
314
410
  seatReserved: string;
315
411
  seatSelected: string;
316
412
  seatUnavailable: string;
413
+ seatHidden: string;
317
414
  gridLines: string;
318
415
  currency: string;
319
416
  }
@@ -327,6 +424,7 @@ interface ColorSettings {
327
424
  | `reserved` | Seat is booked by another user | ❌ No | Yellow/Warning color |
328
425
  | `selected` | Seat is selected by current user | ✅ Yes (to deselect) | Primary/Blue color |
329
426
  | `unavailable` | Seat is blocked (maintenance, etc.) | ❌ No | Gray color |
427
+ | `hidden` | Seat exists but is not displayed | ❌ No | Not rendered |
330
428
 
331
429
  ## Events & Callbacks
332
430
 
@@ -1,8 +1,11 @@
1
+ import { default as React } from 'react';
1
2
  import { SeatMapConfig, SeatData, ColorSettings } from '../types';
2
3
 
3
4
  export interface SeatMapViewerProps {
4
5
  config?: SeatMapConfig;
5
6
  configUrl?: string;
7
+ floorId?: string;
8
+ onFloorChange?: (floorId: string) => void;
6
9
  reservedSeats?: string[];
7
10
  unavailableSeats?: string[];
8
11
  onSeatSelect?: (seat: SeatData) => void;