@zonetrix/viewer 1.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.
package/README.md ADDED
@@ -0,0 +1,165 @@
1
+ # @zonetrix/viewer
2
+
3
+ Lightweight React component for rendering interactive seat maps. Perfect for booking systems, event ticketing, and venue management.
4
+
5
+ ## Features
6
+
7
+ - 🎯 **Read-only rendering** - Display seat maps without editing capabilities
8
+ - 🔄 **Interactive selection** - Click seats to select/deselect
9
+ - 🌐 **API integration** - Load configs from JSON file or API endpoint
10
+ - 🎨 **Customizable** - Override colors and styles
11
+ - 📱 **Responsive** - Works on all screen sizes
12
+ - ⚡ **Lightweight** - Minimal dependencies, small bundle size
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @zonetrix/viewer
18
+ # or
19
+ yarn add @zonetrix/viewer
20
+ # or
21
+ pnpm add @zonetrix/viewer
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Basic Example (with JSON file)
27
+
28
+ ```tsx
29
+ import { SeatMapViewer } from '@zonetrix/viewer';
30
+ import config from './my-venue-config.json';
31
+
32
+ function App() {
33
+ return (
34
+ <SeatMapViewer
35
+ config={config}
36
+ onSeatSelect={(seat) => console.log('Selected:', seat)}
37
+ onSeatDeselect={(seat) => console.log('Deselected:', seat)}
38
+ />
39
+ );
40
+ }
41
+ ```
42
+
43
+ ### With API URL
44
+
45
+ ```tsx
46
+ import { SeatMapViewer } from '@zonetrix/viewer';
47
+
48
+ function App() {
49
+ return (
50
+ <SeatMapViewer
51
+ configUrl="https://api.example.com/venue/123/config"
52
+ onSeatSelect={(seat) => console.log('Selected:', seat)}
53
+ />
54
+ );
55
+ }
56
+ ```
57
+
58
+ ### With Seat State Overrides
59
+
60
+ ```tsx
61
+ import { SeatMapViewer } from '@seat-map-studio/viewer';
62
+
63
+ function App() {
64
+ const [reservedSeats, setReservedSeats] = useState(['A-1', 'A-2', 'B-5']);
65
+ const [unavailableSeats] = useState(['C-1']);
66
+
67
+ return (
68
+ <SeatMapViewer
69
+ config={config}
70
+ reservedSeats={reservedSeats}
71
+ unavailableSeats={unavailableSeats}
72
+ onSeatSelect={(seat) => {
73
+ // Handle seat selection
74
+ }}
75
+ />
76
+ );
77
+ }
78
+ ```
79
+
80
+ ### Custom Colors
81
+
82
+ ```tsx
83
+ import { SeatMapViewer } from '@seat-map-studio/viewer';
84
+
85
+ function App() {
86
+ return (
87
+ <SeatMapViewer
88
+ config={config}
89
+ colorOverrides={{
90
+ seatAvailable: '#00ff00',
91
+ seatSelected: '#0000ff',
92
+ seatReserved: '#ffff00',
93
+ seatUnavailable: '#ff0000',
94
+ }}
95
+ />
96
+ );
97
+ }
98
+ ```
99
+
100
+ ## API Reference
101
+
102
+ ### Props
103
+
104
+ | Prop | Type | Default | Description |
105
+ |------|------|---------|-------------|
106
+ | `config` | `SeatMapConfig` | - | Seat map configuration object |
107
+ | `configUrl` | `string` | - | URL to fetch configuration from |
108
+ | `reservedSeats` | `string[]` | `[]` | Array of seat IDs/numbers to mark as reserved |
109
+ | `unavailableSeats` | `string[]` | `[]` | Array of seat IDs/numbers to mark as unavailable |
110
+ | `onSeatSelect` | `(seat: SeatData) => void` | - | Called when a seat is selected |
111
+ | `onSeatDeselect` | `(seat: SeatData) => void` | - | Called when a seat is deselected |
112
+ | `onSelectionChange` | `(seats: SeatData[]) => void` | - | Called when selection changes |
113
+ | `colorOverrides` | `Partial<ColorSettings>` | - | Custom color overrides |
114
+ | `showTooltip` | `boolean` | `true` | Show tooltip on hover |
115
+ | `zoomEnabled` | `boolean` | `true` | Enable mouse wheel zoom |
116
+ | `className` | `string` | `''` | Additional CSS classes |
117
+ | `onConfigLoad` | `(config: SeatMapConfig) => void` | - | Called when config is loaded |
118
+ | `onError` | `(error: Error) => void` | - | Called on error |
119
+
120
+ ### Types
121
+
122
+ #### SeatData
123
+ ```typescript
124
+ interface SeatData {
125
+ seatState: 'available' | 'reserved' | 'selected' | 'unavailable';
126
+ shape?: 'circle' | 'square' | 'rounded-square';
127
+ sectionName?: string;
128
+ rowLabel?: string;
129
+ columnLabel?: string;
130
+ price?: number;
131
+ seatNumber?: string;
132
+ }
133
+ ```
134
+
135
+ #### SeatMapConfig
136
+ ```typescript
137
+ interface SeatMapConfig {
138
+ version: string;
139
+ metadata: {
140
+ name: string;
141
+ description?: string;
142
+ createdAt: string;
143
+ updatedAt: string;
144
+ venue?: string;
145
+ capacity?: number;
146
+ };
147
+ canvas: {
148
+ width: number;
149
+ height: number;
150
+ backgroundColor: string;
151
+ };
152
+ colors: ColorSettings;
153
+ seats: SerializedSeat[];
154
+ sections?: SerializedSection[];
155
+ stages?: SerializedStage[];
156
+ }
157
+ ```
158
+
159
+ ## Creating Seat Map Configs
160
+
161
+ Use [@seat-map-studio/creator](../creator) to visually design and export seat map configurations.
162
+
163
+ ## License
164
+
165
+ MIT
@@ -0,0 +1,18 @@
1
+ import { SeatMapConfig, SeatData, ColorSettings } from '../types';
2
+
3
+ export interface SeatMapViewerProps {
4
+ config?: SeatMapConfig;
5
+ configUrl?: string;
6
+ reservedSeats?: string[];
7
+ unavailableSeats?: string[];
8
+ onSeatSelect?: (seat: SeatData) => void;
9
+ onSeatDeselect?: (seat: SeatData) => void;
10
+ onSelectionChange?: (seats: SeatData[]) => void;
11
+ colorOverrides?: Partial<ColorSettings>;
12
+ showTooltip?: boolean;
13
+ zoomEnabled?: boolean;
14
+ className?: string;
15
+ onConfigLoad?: (config: SeatMapConfig) => void;
16
+ onError?: (error: Error) => void;
17
+ }
18
+ export declare const SeatMapViewer: React.FC<SeatMapViewerProps>;
@@ -0,0 +1,10 @@
1
+ import { SeatMapConfig } from '../types';
2
+
3
+ interface UseConfigFetcherResult {
4
+ config: SeatMapConfig | null;
5
+ loading: boolean;
6
+ error: Error | null;
7
+ refetch: () => void;
8
+ }
9
+ export declare function useConfigFetcher(configUrl?: string): UseConfigFetcherResult;
10
+ export {};
@@ -0,0 +1,5 @@
1
+ export { SeatMapViewer } from './components/SeatMapViewer';
2
+ export type { SeatMapViewerProps } from './components/SeatMapViewer';
3
+ export type { SeatState, SeatShape, SeatData, SerializedSeat, SerializedSection, SerializedStage, ColorSettings, SeatMapConfig, } from './types';
4
+ export { DEFAULT_COLORS } from './types';
5
+ export { useConfigFetcher } from './hooks/useConfigFetcher';